From 0b4c1aa2759a08581acc83d949e0c509a0207822 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 5 Aug 2023 20:42:19 +0200 Subject: [PATCH] more work on controllers --- include/battle_controllers.h | 3 ++ src/battle_controller_link_opponent.c | 35 ++------------------ src/battle_controller_link_partner.c | 35 ++------------------ src/battle_controller_opponent.c | 35 ++------------------ src/battle_controller_player.c | 35 ++------------------ src/battle_controller_player_partner.c | 39 ++--------------------- src/battle_controller_recorded_opponent.c | 21 ++---------- src/battle_controller_recorded_player.c | 21 ++---------- src/battle_controllers.c | 33 +++++++++++++++++++ 9 files changed, 51 insertions(+), 206 deletions(-) diff --git a/include/battle_controllers.h b/include/battle_controllers.h index d54e24bb4d..8d8dddae69 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -267,6 +267,9 @@ void BtlController_HandleReturnMonToBall(void); void BtlController_HandleFaintAnimation(void); void BtlController_HandleSuccessBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture); void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture); +void DoStatusIconUpdate(u32 battler); +void BtlController_HandleStatusIconUpdate(void); +void BtlController_HandleStatusAnimation(void); void BtlController_HandleClearUnkVar(void); void BtlController_HandleSetUnkVar(void); void BtlController_HandleClearUnkFlag(void); diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index a1a69294d4..e8863c75e6 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -37,8 +37,6 @@ static void LinkOpponentHandleTrainerSlideBack(void); static void LinkOpponentHandleMoveAnimation(void); static void LinkOpponentHandlePrintString(void); static void LinkOpponentHandleHealthBarUpdate(void); -static void LinkOpponentHandleStatusIconUpdate(void); -static void LinkOpponentHandleStatusAnimation(void); static void LinkOpponentHandleIntroTrainerBallThrow(void); static void LinkOpponentHandleDrawPartyStatusSummary(void); static void LinkOpponentHandleHidePartyStatusSummary(void); @@ -84,8 +82,8 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_23] = BtlController_Empty, [CONTROLLER_HEALTHBARUPDATE] = LinkOpponentHandleHealthBarUpdate, [CONTROLLER_EXPUPDATE] = BtlController_Empty, - [CONTROLLER_STATUSICONUPDATE] = LinkOpponentHandleStatusIconUpdate, - [CONTROLLER_STATUSANIMATION] = LinkOpponentHandleStatusAnimation, + [CONTROLLER_STATUSICONUPDATE] = BtlController_HandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = BtlController_HandleStatusAnimation, [CONTROLLER_STATUSXOR] = BtlController_Empty, [CONTROLLER_DATATRANSFER] = BtlController_Empty, [CONTROLLER_DMA3TRANSFER] = BtlController_Empty, @@ -418,12 +416,6 @@ static void SwitchIn_TryShinyAnim(void) } } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - LinkOpponentBufferExecCompleted(); -} - static void LinkOpponentBufferExecCompleted(void) { gBattlerControllerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand; @@ -683,29 +675,6 @@ static void LinkOpponentHandleHealthBarUpdate(void) gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } -static void LinkOpponentHandleStatusIconUpdate(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - -static void LinkOpponentHandleStatusAnimation(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - static void LinkOpponentHandleIntroTrainerBallThrow(void) { u8 taskId; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index af2d75fbc3..20cc10dadc 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -36,8 +36,6 @@ static void LinkPartnerHandleTrainerSlideBack(void); static void LinkPartnerHandleMoveAnimation(void); static void LinkPartnerHandlePrintString(void); static void LinkPartnerHandleHealthBarUpdate(void); -static void LinkPartnerHandleStatusIconUpdate(void); -static void LinkPartnerHandleStatusAnimation(void); static void LinkPartnerHandleIntroTrainerBallThrow(void); static void LinkPartnerHandleDrawPartyStatusSummary(void); static void LinkPartnerHandleHidePartyStatusSummary(void); @@ -82,8 +80,8 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_23] = BtlController_Empty, [CONTROLLER_HEALTHBARUPDATE] = LinkPartnerHandleHealthBarUpdate, [CONTROLLER_EXPUPDATE] = BtlController_Empty, - [CONTROLLER_STATUSICONUPDATE] = LinkPartnerHandleStatusIconUpdate, - [CONTROLLER_STATUSANIMATION] = LinkPartnerHandleStatusAnimation, + [CONTROLLER_STATUSICONUPDATE] = BtlController_HandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = BtlController_HandleStatusAnimation, [CONTROLLER_STATUSXOR] = BtlController_Empty, [CONTROLLER_DATATRANSFER] = BtlController_Empty, [CONTROLLER_DMA3TRANSFER] = BtlController_Empty, @@ -323,12 +321,6 @@ static void LinkPartnerBufferExecCompleted(void) } } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - LinkPartnerBufferExecCompleted(); -} - static void LinkPartnerHandleLoadMonSprite(void) { BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad); @@ -504,29 +496,6 @@ static void LinkPartnerHandleHealthBarUpdate(void) gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } -static void LinkPartnerHandleStatusIconUpdate(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - -static void LinkPartnerHandleStatusAnimation(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - static void LinkPartnerHandleIntroTrainerBallThrow(void) { u8 paletteNum; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 653458994d..51a59ec56c 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -51,8 +51,6 @@ static void OpponentHandleChooseMove(void); static void OpponentHandleChooseItem(void); static void OpponentHandleChoosePokemon(void); static void OpponentHandleHealthBarUpdate(void); -static void OpponentHandleStatusIconUpdate(void); -static void OpponentHandleStatusAnimation(void); static void OpponentHandleIntroTrainerBallThrow(void); static void OpponentHandleDrawPartyStatusSummary(void); static void OpponentHandleHidePartyStatusSummary(void); @@ -98,8 +96,8 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_23] = BtlController_Empty, [CONTROLLER_HEALTHBARUPDATE] = OpponentHandleHealthBarUpdate, [CONTROLLER_EXPUPDATE] = BtlController_Empty, - [CONTROLLER_STATUSICONUPDATE] = OpponentHandleStatusIconUpdate, - [CONTROLLER_STATUSANIMATION] = OpponentHandleStatusAnimation, + [CONTROLLER_STATUSICONUPDATE] = BtlController_HandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = BtlController_HandleStatusAnimation, [CONTROLLER_STATUSXOR] = BtlController_Empty, [CONTROLLER_DATATRANSFER] = BtlController_Empty, [CONTROLLER_DMA3TRANSFER] = BtlController_Empty, @@ -439,12 +437,6 @@ static void SwitchIn_TryShinyAnim(void) } } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - OpponentBufferExecCompleted(); -} - static void OpponentBufferExecCompleted(void) { gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand; @@ -950,29 +942,6 @@ static void OpponentHandleHealthBarUpdate(void) gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } -static void OpponentHandleStatusIconUpdate(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - -static void OpponentHandleStatusAnimation(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - static void OpponentHandleIntroTrainerBallThrow(void) { u8 taskId; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index ed026fb060..dc1cb777ad 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -58,8 +58,6 @@ static void PlayerHandleChoosePokemon(void); static void PlayerHandleCmd23(void); static void PlayerHandleHealthBarUpdate(void); static void PlayerHandleExpUpdate(void); -static void PlayerHandleStatusIconUpdate(void); -static void PlayerHandleStatusAnimation(void); static void PlayerHandleStatusXor(void); static void PlayerHandleDMA3Transfer(void); static void PlayerHandlePlayBGM(void); @@ -130,8 +128,8 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_23] = PlayerHandleCmd23, [CONTROLLER_HEALTHBARUPDATE] = PlayerHandleHealthBarUpdate, [CONTROLLER_EXPUPDATE] = PlayerHandleExpUpdate, - [CONTROLLER_STATUSICONUPDATE] = PlayerHandleStatusIconUpdate, - [CONTROLLER_STATUSANIMATION] = PlayerHandleStatusAnimation, + [CONTROLLER_STATUSICONUPDATE] = BtlController_HandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = BtlController_HandleStatusAnimation, [CONTROLLER_STATUSXOR] = PlayerHandleStatusXor, [CONTROLLER_DATATRANSFER] = BtlController_Empty, [CONTROLLER_DMA3TRANSFER] = PlayerHandleDMA3Transfer, @@ -1705,12 +1703,6 @@ void CB2_SetUpReshowBattleScreenAfterMenu2(void) SetMainCallback2(ReshowBattleScreenAfterMenu); } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - PlayerBufferExecCompleted(); -} - static void PrintLinkStandbyMsg(void) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -2197,29 +2189,6 @@ static void PlayerHandleExpUpdate(void) #undef tExpTask_gainedExp_2 #undef tExpTask_frames -static void PlayerHandleStatusIconUpdate(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - -static void PlayerHandleStatusAnimation(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - static void PlayerHandleStatusXor(void) { u8 val = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_STATUS) ^ gBattleResources->bufferA[gActiveBattler][1]; diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 38616e7ec7..1cebed0a91 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -42,8 +42,6 @@ static void PlayerPartnerHandleChooseMove(void); static void PlayerPartnerHandleChoosePokemon(void); static void PlayerPartnerHandleHealthBarUpdate(void); static void PlayerPartnerHandleExpUpdate(void); -static void PlayerPartnerHandleStatusIconUpdate(void); -static void PlayerPartnerHandleStatusAnimation(void); static void PlayerPartnerHandleIntroTrainerBallThrow(void); static void PlayerPartnerHandleDrawPartyStatusSummary(void); static void PlayerPartnerHandleHidePartyStatusSummary(void); @@ -92,8 +90,8 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_23] = BtlController_Empty, [CONTROLLER_HEALTHBARUPDATE] = PlayerPartnerHandleHealthBarUpdate, [CONTROLLER_EXPUPDATE] = PlayerPartnerHandleExpUpdate, - [CONTROLLER_STATUSICONUPDATE] = PlayerPartnerHandleStatusIconUpdate, - [CONTROLLER_STATUSANIMATION] = PlayerPartnerHandleStatusAnimation, + [CONTROLLER_STATUSICONUPDATE] = BtlController_HandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = BtlController_HandleStatusAnimation, [CONTROLLER_STATUSXOR] = BtlController_Empty, [CONTROLLER_DATATRANSFER] = BtlController_Empty, [CONTROLLER_DMA3TRANSFER] = BtlController_Empty, @@ -505,12 +503,6 @@ static void PlayerPartnerBufferExecCompleted(void) } } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - PlayerPartnerBufferExecCompleted(); -} - static void PlayerPartnerHandleLoadMonSprite(void) { BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad); @@ -768,6 +760,7 @@ static void PlayerPartnerHandleHealthBarUpdate(void) static void PlayerPartnerHandleExpUpdate(void) { u8 monId = gBattleResources->bufferA[gActiveBattler][1]; + s32 taskId, expPointsToGive; if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL) { @@ -775,9 +768,6 @@ static void PlayerPartnerHandleExpUpdate(void) } else { - s16 expPointsToGive; - u8 taskId; - LoadBattleBarGfx(1); GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); // unused return value expPointsToGive = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); @@ -794,29 +784,6 @@ static void PlayerPartnerHandleExpUpdate(void) #undef tExpTask_bank #undef tExpTask_frames -static void PlayerPartnerHandleStatusIconUpdate(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - -static void PlayerPartnerHandleStatusAnimation(void) -{ - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } -} - static void PlayerPartnerHandleIntroTrainerBallThrow(void) { u8 paletteNum; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 27cf11c62d..7948ae4597 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -409,12 +409,6 @@ static void SwitchIn_TryShinyAnim(void) } } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - RecordedOpponentBufferExecCompleted(); -} - static void RecordedOpponentBufferExecCompleted(void) { gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand; @@ -670,13 +664,7 @@ static void RecordedOpponentHandleStatusIconUpdate(void) { if (!IsBattleSEPlaying(gActiveBattler)) { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - + DoStatusIconUpdate(gActiveBattler); if (gTestRunnerEnabled) TestRunner_Battle_RecordStatus1(battlerId, GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_STATUS)); } @@ -684,12 +672,7 @@ static void RecordedOpponentHandleStatusIconUpdate(void) static void RecordedOpponentHandleStatusAnimation(void) { - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } + BtlController_HandleStatusAnimation(); } static void RecordedOpponentHandleIntroTrainerBallThrow(void) diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 5122107b9e..df345ec242 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -404,12 +404,6 @@ static void RecordedPlayerBufferExecCompleted(void) } } -static void CompleteOnFinishedStatusAnimation(void) -{ - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) - RecordedPlayerBufferExecCompleted(); -} - static void RecordedPlayerHandleLoadMonSprite(void) { BtlController_HandleLoadMonSprite(gActiveBattler, gPlayerParty, WaitForMonAnimAfterLoad); @@ -684,13 +678,7 @@ static void RecordedPlayerHandleStatusIconUpdate(void) { if (!IsBattleSEPlaying(gActiveBattler)) { - u8 battlerId; - - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON); - battlerId = gActiveBattler; - gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0; - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - + DoStatusIconUpdate(gActiveBattler); if (gTestRunnerEnabled) TestRunner_Battle_RecordStatus1(battlerId, GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_STATUS)); } @@ -698,12 +686,7 @@ static void RecordedPlayerHandleStatusIconUpdate(void) static void RecordedPlayerHandleStatusAnimation(void) { - if (!IsBattleSEPlaying(gActiveBattler)) - { - InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], - gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); - gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; - } + BtlController_HandleStatusAnimation(); } static void RecordedPlayerHandleIntroTrainerBallThrow(void) diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 8678a4d3fe..d01cd5b4b4 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -2191,6 +2191,12 @@ static void Controller_WaitForBattleAnimation(void) BattleControllerComplete(gActiveBattler); } +static void Controller_WaitForStatusAnimation(void) +{ + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) + BattleControllerComplete(gActiveBattler); +} + static void Controller_HitAnimation(void) { u32 spriteId = gBattlerSpriteIds[gActiveBattler]; @@ -2413,6 +2419,33 @@ void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool HandleBallThrow(battler, target, animId, allowCriticalCapture); } +void DoStatusIconUpdate(u32 battler) +{ + struct Pokemon *party = GetBattlerParty(battler); + + UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &party[gBattlerPartyIndexes[battler]], HEALTHBOX_STATUS_ICON); + gBattleSpritesDataPtr->healthBoxesData[battler].statusAnimActive = 0; + gBattlerControllerFuncs[battler] = Controller_WaitForStatusAnimation; +} + +void BtlController_HandleStatusIconUpdate(void) +{ + if (!IsBattleSEPlaying(gActiveBattler)) + { + DoStatusIconUpdate(gActiveBattler); + } +} + +void BtlController_HandleStatusAnimation(void) +{ + if (!IsBattleSEPlaying(gActiveBattler)) + { + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); + gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForStatusAnimation; + } +} + void BtlController_HandleClearUnkVar(void) { gUnusedControllerStruct.unk = 0;