-
Notifications
You must be signed in to change notification settings - Fork 56
Make Pokémon animate after a KO
nico edited this page Apr 12, 2024
·
2 revisions
By nico.
Want Pokémon to do a little jig on the grave of their enemies? This is the tutorial for you!
Untitled.video.3.mp4
To implement the change, do the following in src/battle_controllers.c
:
First, add this line at the very top:
+ #include "pokemon_animation.h"
Then, apply the following changes to this function:
void BtlController_HandleFaintAnimation(u32 battler)
{
+ SetHealthboxSpriteInvisible(gHealthboxSpriteIds[battler]);
if (gBattleSpritesDataPtr->healthBoxesData[battler].animationState == 0)
{
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
InitAndLaunchSpecialAnimation(battler, battler, battler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[battler].animationState++;
}
else
{
if (!gBattleSpritesDataPtr->healthBoxesData[battler].specialAnimActive)
{
gBattleSpritesDataPtr->healthBoxesData[battler].animationState = 0;
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
gSprites[gBattlerSpriteIds[battler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[battler]].sSpeedY = 5;
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[battler] = Controller_FaintPlayerMon;
}
else
{
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET);
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_FaintOpponentMon;
gBattlerControllerFuncs[battler] = Controller_FaintOpponentMon;
}
// The player's sprite callback just slides the mon, the opponent's removes the sprite.
// The player's sprite is removed in Controller_FaintPlayerMon. Controller_FaintOpponentMon only removes the healthbox once the sprite is removed by SpriteCB_FaintOpponentMon.
}
}
+ if(GetBattlerSide(battler) == B_SIDE_PLAYER)
+ {
+ LaunchAnimationTaskForFrontSprite(&gSprites[gBattlerSpriteIds[BATTLE_OPPOSITE(battler)]], gSpeciesInfo[gBattleMons[BATTLE_OPPOSITE(battler)].species].frontAnimId);
+ PlayCry_Normal(gBattleMons[BATTLE_OPPOSITE(battler)].species, CRY_PRIORITY_NORMAL);
+ if (HasTwoFramesAnimation(gBattleMons[BATTLE_OPPOSITE(battler)].species))
+ StartSpriteAnim(&gSprites[gBattlerSpriteIds[BATTLE_OPPOSITE(battler)]], 1);
+ if(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
+ {
+ LaunchAnimationTaskForFrontSprite(&gSprites[gBattlerSpriteIds[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))]], gSpeciesInfo[gBattleMons[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))].species].frontAnimId);
+ PlayCry_Normal(gBattleMons[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))].species, CRY_PRIORITY_NORMAL);
+ if (HasTwoFramesAnimation(gBattleMons[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))].species))
+ StartSpriteAnim(&gSprites[gBattlerSpriteIds[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))]], 1);
+ }
+ }
+ else if(GetBattlerSide(battler) == B_SIDE_OPPONENT)
+ {
+ LaunchAnimationTaskForBackSprite(&gSprites[gBattlerSpriteIds[BATTLE_OPPOSITE(battler)]], gSpeciesInfo[gBattleMons[BATTLE_OPPOSITE(battler)].species].backAnimId);
+ PlayCry_Normal(gBattleMons[BATTLE_OPPOSITE(battler)].species, CRY_PRIORITY_NORMAL);
+ if(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
+ {
+ LaunchAnimationTaskForBackSprite(&gSprites[gBattlerSpriteIds[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))]], gSpeciesInfo[gBattleMons[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))].species].backAnimId);
+ PlayCry_Normal(gBattleMons[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))].species, CRY_PRIORITY_NORMAL);
+ }
+ }
+}
And that's all done!
git clone https://github.com/pret/pokeemerald.git cd pokeemerald git remote rename origin upstream git remote add origin https://github.com/DEN-DALI-KAVKA/Copy-of-the-World.git git push -u origin