Add B_ANIMATE_MON_AFTER_KO - mons animate after scoring a KO (#6451)

This commit is contained in:
psf 2025-03-26 03:39:25 -07:00 committed by GitHub
parent 1fd25e3d97
commit b60fcc9a72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 0 deletions

View File

@ -257,6 +257,7 @@
#define B_QUICK_MOVE_CURSOR_TO_RUN FALSE // If set to TRUE, pushing B in the battle options against a wild encounter will move the cursor to the run option
#define B_MOVE_DESCRIPTION_BUTTON L_BUTTON // If set to a button other than B_LAST_USED_BALL_BUTTON, pressing this button will open the move description menu
#define B_SHOW_USELESS_Z_MOVE_INFO FALSE // If set to TRUE, Z-moves without additional effects like newer gen status moves will say "no additional effect"
#define B_ANIMATE_MON_AFTER_KO TRUE // If set to TRUE, if a Pokémon on the opposite site faints, the non-fainted Pokemon will display a victory animation.
#define B_SHOW_DYNAMAX_MESSAGE FALSE // If set to TRUE, an additional battle message is shown after completing Dynamaxing/Gigantamaxing.
// Catching settings

View File

@ -25,6 +25,7 @@
#include "text.h"
#include "constants/abilities.h"
#include "constants/songs.h"
#include "pokemon_animation.h"
static EWRAM_DATA u8 sLinkSendTaskId = 0;
static EWRAM_DATA u8 sLinkReceiveTaskId = 0;
@ -42,6 +43,9 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId);
static void Task_StartSendOutAnim(u8 taskId);
static void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite);
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite);
static u32 ReturnAnimIdForBattler(bool32 isPlayerSide, u32 specificBattler);
static void LaunchKOAnimation(u32 battlerId, u16 animId, bool32 isFront);
static void AnimateMonAfterKnockout(u32 battler);
void HandleLinkBattleSetup(void)
{
@ -2571,6 +2575,7 @@ void BtlController_HandleTrainerSlideBack(u32 battler, s16 data0, bool32 startAn
void BtlController_HandleFaintAnimation(u32 battler)
{
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[battler]);
if (gBattleSpritesDataPtr->healthBoxesData[battler].animationState == 0)
{
if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
@ -2601,6 +2606,7 @@ void BtlController_HandleFaintAnimation(u32 battler)
// The player's sprite is removed in Controller_FaintPlayerMon. Controller_FaintOpponentMon only removes the healthbox once the sprite is removed by SpriteCB_FaintOpponentMon.
}
}
AnimateMonAfterKnockout(battler);
}
#undef sSpeedX
@ -3015,3 +3021,48 @@ void BtlController_HandleBattleAnimation(u32 battler, bool32 ignoreSE, bool32 up
BattleTv_SetDataBasedOnAnimation(animationId);
}
}
static void AnimateMonAfterKnockout(u32 battler)
{
if (B_ANIMATE_MON_AFTER_KO == FALSE)
return;
u32 oppositeBattler = BATTLE_OPPOSITE(battler);
u32 partnerBattler = BATTLE_PARTNER(oppositeBattler);
bool32 wasPlayerSideKnockedOut = (GetBattlerSide(battler) == B_SIDE_PLAYER);
if (IsBattlerAlive(oppositeBattler))
LaunchKOAnimation(oppositeBattler, ReturnAnimIdForBattler(wasPlayerSideKnockedOut, oppositeBattler), wasPlayerSideKnockedOut);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && IsBattlerAlive(partnerBattler))
LaunchKOAnimation(partnerBattler, ReturnAnimIdForBattler(wasPlayerSideKnockedOut, partnerBattler), wasPlayerSideKnockedOut);
}
static void LaunchKOAnimation(u32 battlerId, u16 animId, bool32 isFront)
{
u32 species = gBattleMons[battlerId].species;
u32 spriteId = gBattlerSpriteIds[battlerId];
if (isFront)
{
LaunchAnimationTaskForFrontSprite(&gSprites[spriteId], animId);
if (HasTwoFramesAnimation(species))
StartSpriteAnim(&gSprites[spriteId], 1);
}
else
{
LaunchAnimationTaskForBackSprite(&gSprites[spriteId], animId);
}
PlayCry_Normal(species, CRY_PRIORITY_NORMAL);
}
static u32 ReturnAnimIdForBattler(bool32 wasPlayerSideKnockedOut, u32 specificBattler)
{
if (wasPlayerSideKnockedOut)
return gSpeciesInfo[gBattleMons[specificBattler].species].frontAnimId;
else
return GetSpeciesBackAnimSet(gBattleMons[specificBattler].species);
}