From ffb0e2004951897fd22c332029b3592783ec6f9f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 5 Aug 2023 23:27:56 +0200 Subject: [PATCH] hide show party status summary --- include/battle_controllers.h | 2 + src/battle_controller_link_opponent.c | 50 +---------------------- src/battle_controller_link_partner.c | 36 +--------------- src/battle_controller_opponent.c | 50 +---------------------- src/battle_controller_player.c | 41 ++----------------- src/battle_controller_player_partner.c | 36 +--------------- src/battle_controller_recorded_opponent.c | 49 +--------------------- src/battle_controller_recorded_player.c | 36 +--------------- src/battle_controller_safari.c | 6 --- src/battle_controller_wally.c | 11 +---- src/battle_controllers.c | 50 +++++++++++++++++++++++ 11 files changed, 69 insertions(+), 298 deletions(-) diff --git a/include/battle_controllers.h b/include/battle_controllers.h index aa1d28c42..6dbdb1431 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -282,6 +282,8 @@ void BtlController_HandlePlayFanfareOrBGM(void); void BtlController_HandleFaintingCry(void); void BtlController_HandleIntroSlide(void); void BtlController_HandleSpriteInvisibility(void); +void BtlController_HandleDrawPartyStatusSummary(u32 battler, u32 side, bool32 considerDelay); +void BtlController_HandleHidePartyStatusSummary(void); void BtlController_HandleBattleAnimation(u32 battler, bool32 ignoreSE, bool32 updateTvData); // player controller diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index aa6c3b55c..a003387ed 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -39,7 +39,6 @@ static void LinkOpponentHandlePrintString(void); static void LinkOpponentHandleHealthBarUpdate(void); static void LinkOpponentHandleIntroTrainerBallThrow(void); static void LinkOpponentHandleDrawPartyStatusSummary(void); -static void LinkOpponentHandleHidePartyStatusSummary(void); static void LinkOpponentHandleBattleAnimation(void); static void LinkOpponentHandleLinkStandbyMsg(void); static void LinkOpponentHandleEndLinkBattle(void); @@ -52,7 +51,6 @@ static void SetLinkOpponentMonData(u8 monId); static void LinkOpponentDoMoveAnimation(void); static void Task_StartSendOutAnim(u8 taskId); static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite); -static void EndDrawPartyStatusSummary(void); static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { @@ -105,7 +103,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = LinkOpponentHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = LinkOpponentHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = LinkOpponentHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = BtlController_Empty, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = LinkOpponentHandleBattleAnimation, @@ -717,51 +715,7 @@ static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite) static void LinkOpponentHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - LinkOpponentBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay < 2) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay++; - return; - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay = 0; - } - } - - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - LinkOpponentBufferExecCompleted(); - } -} - -static void LinkOpponentHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - LinkOpponentBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_OPPONENT, TRUE); } static void LinkOpponentHandleBattleAnimation(void) diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 7d489c1f6..7f9e382af 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -38,7 +38,6 @@ static void LinkPartnerHandlePrintString(void); static void LinkPartnerHandleHealthBarUpdate(void); static void LinkPartnerHandleIntroTrainerBallThrow(void); static void LinkPartnerHandleDrawPartyStatusSummary(void); -static void LinkPartnerHandleHidePartyStatusSummary(void); static void LinkPartnerHandleBattleAnimation(void); static void LinkPartnerHandleLinkStandbyMsg(void); static void LinkPartnerHandleEndLinkBattle(void); @@ -50,7 +49,6 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst); static void SetLinkPartnerMonData(u8 monId); static void LinkPartnerDoMoveAnimation(void); static void Task_StartSendOutAnim(u8 taskId); -static void EndDrawPartyStatusSummary(void); static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { @@ -103,7 +101,7 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = LinkPartnerHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = LinkPartnerHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = LinkPartnerHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = BtlController_Empty, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = LinkPartnerHandleBattleAnimation, @@ -564,37 +562,7 @@ static void Task_StartSendOutAnim(u8 taskId) static void LinkPartnerHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - LinkPartnerBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - LinkPartnerBufferExecCompleted(); - } -} - -static void LinkPartnerHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - LinkPartnerBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE); } static void LinkPartnerHandleBattleAnimation(void) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 37dc2760e..145fe81f7 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -53,7 +53,6 @@ static void OpponentHandleChoosePokemon(void); static void OpponentHandleHealthBarUpdate(void); static void OpponentHandleIntroTrainerBallThrow(void); static void OpponentHandleDrawPartyStatusSummary(void); -static void OpponentHandleHidePartyStatusSummary(void); static void OpponentHandleBattleAnimation(void); static void OpponentHandleEndLinkBattle(void); static u8 CountAIAliveNonEggMonsExcept(u8 slotToIgnore); @@ -66,7 +65,6 @@ static void SetOpponentMonData(u8 monId); static void OpponentDoMoveAnimation(void); static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite); static void Task_StartSendOutAnim(u8 taskId); -static void EndDrawPartyStatusSummary(void); static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { @@ -119,7 +117,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = OpponentHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = OpponentHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = OpponentHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = BtlController_Empty, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = OpponentHandleBattleAnimation, @@ -989,51 +987,7 @@ static void Task_StartSendOutAnim(u8 taskId) static void OpponentHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - OpponentBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay < 2) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay++; - return; - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay = 0; - } - } - - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - OpponentBufferExecCompleted(); - } -} - -static void OpponentHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - OpponentBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_OPPONENT, TRUE); } static void OpponentHandleBattleAnimation(void) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 730e0b268..21a58a93c 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -66,7 +66,6 @@ static void PlayerHandleOneReturnValue(void); static void PlayerHandleOneReturnValue_Duplicate(void); static void PlayerHandleIntroTrainerBallThrow(void); static void PlayerHandleDrawPartyStatusSummary(void); -static void PlayerHandleHidePartyStatusSummary(void); static void PlayerHandleEndBounceEffect(void); static void PlayerHandleBattleAnimation(void); static void PlayerHandleLinkStandbyMsg(void); @@ -95,7 +94,6 @@ static u32 CopyPlayerMonData(u8, u8 *); static void SetPlayerMonData(u8); static void PlayerDoMoveAnimation(void); static void Task_StartSendOutAnim(u8); -static void EndDrawPartyStatusSummary(void); static void ReloadMoveNames(void); @@ -150,7 +148,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = PlayerHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = PlayerHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = PlayerHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = PlayerHandleEndBounceEffect, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = PlayerHandleBattleAnimation, @@ -2311,38 +2309,7 @@ static void Task_StartSendOutAnim(u8 taskId) static void PlayerHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - PlayerBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - // If intro, skip the delay after drawing - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - PlayerBufferExecCompleted(); - } -} - -static void PlayerHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - PlayerBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE); } static void PlayerHandleEndBounceEffect(void) @@ -2405,7 +2372,7 @@ static void PlayerHandleEndLinkBattle(void) gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks; } -static void WaitForDebug(void) +static void Controller_WaitForDebug(void) { if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { @@ -2417,5 +2384,5 @@ static void PlayerHandleBattleDebug(void) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); SetMainCallback2(CB2_BattleDebugMenu); - gBattlerControllerFuncs[gActiveBattler] = WaitForDebug; + gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForDebug; } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 8da64af4e..8676ecade 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -43,7 +43,6 @@ static void PlayerPartnerHandleChoosePokemon(void); static void PlayerPartnerHandleHealthBarUpdate(void); static void PlayerPartnerHandleIntroTrainerBallThrow(void); static void PlayerPartnerHandleDrawPartyStatusSummary(void); -static void PlayerPartnerHandleHidePartyStatusSummary(void); static void PlayerPartnerHandleBattleAnimation(void); static void PlayerPartnerHandleEndLinkBattle(void); @@ -59,7 +58,6 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst); static void SetPlayerPartnerMonData(u8 monId); static void PlayerPartnerDoMoveAnimation(void); static void Task_StartSendOutAnim(u8 taskId); -static void EndDrawPartyStatusSummary(void); static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { @@ -112,7 +110,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = PlayerPartnerHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = PlayerPartnerHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = PlayerPartnerHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = BtlController_Empty, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = PlayerPartnerHandleBattleAnimation, @@ -656,37 +654,7 @@ static void Task_StartSendOutAnim(u8 taskId) static void PlayerPartnerHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - PlayerPartnerBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - PlayerPartnerBufferExecCompleted(); - } -} - -static void PlayerPartnerHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - PlayerPartnerBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE); } static void PlayerPartnerHandleBattleAnimation(void) diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 917a78473..ce2d667ee 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -47,7 +47,6 @@ static void RecordedOpponentHandleStatusIconUpdate(void); static void RecordedOpponentHandleStatusAnimation(void); static void RecordedOpponentHandleIntroTrainerBallThrow(void); static void RecordedOpponentHandleDrawPartyStatusSummary(void); -static void RecordedOpponentHandleHidePartyStatusSummary(void); static void RecordedOpponentHandleBattleAnimation(void); static void RecordedOpponentHandleEndLinkBattle(void); @@ -112,7 +111,7 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = RecordedOpponentHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = RecordedOpponentHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = RecordedOpponentHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = BtlController_Empty, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = RecordedOpponentHandleBattleAnimation, @@ -725,51 +724,7 @@ static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite) static void RecordedOpponentHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - RecordedOpponentBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay < 2) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay++; - return; - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].opponentDrawPartyStatusSummaryDelay = 0; - } - } - - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - RecordedOpponentBufferExecCompleted(); - } -} - -static void RecordedOpponentHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - RecordedOpponentBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_OPPONENT, TRUE); } static void RecordedOpponentHandleBattleAnimation(void) diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 57a978546..d18b17fd5 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -43,7 +43,6 @@ static void RecordedPlayerHandleStatusIconUpdate(void); static void RecordedPlayerHandleStatusAnimation(void); static void RecordedPlayerHandleIntroTrainerBallThrow(void); static void RecordedPlayerHandleDrawPartyStatusSummary(void); -static void RecordedPlayerHandleHidePartyStatusSummary(void); static void RecordedPlayerHandleBattleAnimation(void); static void RecordedPlayerHandleEndLinkBattle(void); @@ -54,7 +53,6 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst); static void SetRecordedPlayerMonData(u8 monId); static void RecordedPlayerDoMoveAnimation(void); static void Task_StartSendOutAnim(u8 taskId); -static void EndDrawPartyStatusSummary(void); static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = { @@ -107,7 +105,7 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) [CONTROLLER_INTROSLIDE] = BtlController_HandleIntroSlide, [CONTROLLER_INTROTRAINERBALLTHROW] = RecordedPlayerHandleIntroTrainerBallThrow, [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = RecordedPlayerHandleDrawPartyStatusSummary, - [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = RecordedPlayerHandleHidePartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = BtlController_HandleHidePartyStatusSummary, [CONTROLLER_ENDBOUNCE] = BtlController_Empty, [CONTROLLER_SPRITEINVISIBILITY] = BtlController_HandleSpriteInvisibility, [CONTROLLER_BATTLEANIMATION] = RecordedPlayerHandleBattleAnimation, @@ -754,37 +752,7 @@ static void Task_StartSendOutAnim(u8 taskId) static void RecordedPlayerHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - RecordedPlayerBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - - if (gBattleResources->bufferA[gActiveBattler][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93; - - gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary; - } -} - -static void EndDrawPartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; - RecordedPlayerBufferExecCompleted(); - } -} - -static void RecordedPlayerHandleHidePartyStatusSummary(void) -{ - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) - gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; - RecordedPlayerBufferExecCompleted(); + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, TRUE); } static void RecordedPlayerHandleBattleAnimation(void) diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 7252bfa40..a8761b1b3 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -36,7 +36,6 @@ static void SafariHandleFaintingCry(void); static void SafariHandleIntroTrainerBallThrow(void); static void SafariHandleBattleAnimation(void); static void SafariHandleEndLinkBattle(void); -static void SafariHandleBattleDebug(void); static void SafariBufferRunCommand(void); static void SafariBufferExecCompleted(void); @@ -362,8 +361,3 @@ static void SafariHandleEndLinkBattle(void) if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)) gBattlerControllerFuncs[gActiveBattler] = SafariSetBattleEndCallbacks; } - -static void SafariHandleBattleDebug(void) -{ - SafariBufferExecCompleted(); -} diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 9633a3be8..8b3252dc9 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -601,16 +601,7 @@ static void Task_StartSendOutAnim(u8 taskId) static void WallyHandleDrawPartyStatusSummary(void) { - if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) - { - WallyBufferExecCompleted(); - } - else - { - gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); - WallyBufferExecCompleted(); - } + BtlController_HandleDrawPartyStatusSummary(gActiveBattler, B_SIDE_PLAYER, FALSE); } static void WallyHandleBattleAnimation(void) diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 7499ca91a..5a4e56477 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -2205,6 +2205,15 @@ void Controller_WaitForString(void) BattleControllerComplete(gActiveBattler); } +static void Controller_WaitForPartyStatusSummary(void) +{ + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92) + { + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0; + BattleControllerComplete(gActiveBattler); + } +} + static void Controller_HitAnimation(void) { u32 spriteId = gBattlerSpriteIds[gActiveBattler]; @@ -2569,6 +2578,47 @@ void BtlController_HandleSpriteInvisibility(void) BattleControllerComplete(gActiveBattler); } +void BtlController_HandleDrawPartyStatusSummary(u32 battler, u32 side, bool32 considerDelay) +{ + if (gBattleResources->bufferA[battler][1] != 0 && GetBattlerSide(battler) == B_SIDE_PLAYER) + { + BattleControllerComplete(battler); + } + else + { + gBattleSpritesDataPtr->healthBoxesData[battler].partyStatusSummaryShown = 1; + + if (side == B_SIDE_OPPONENT && gBattleResources->bufferA[battler][2] != 0) + { + if (gBattleSpritesDataPtr->healthBoxesData[battler].opponentDrawPartyStatusSummaryDelay < 2) + { + gBattleSpritesDataPtr->healthBoxesData[battler].opponentDrawPartyStatusSummaryDelay++; + return; + } + else + { + gBattleSpritesDataPtr->healthBoxesData[battler].opponentDrawPartyStatusSummaryDelay = 0; + } + } + + gBattlerStatusSummaryTaskId[battler] = CreatePartyStatusSummarySprites(battler, (struct HpAndStatus *)&gBattleResources->bufferA[battler][4], gBattleResources->bufferA[battler][1], gBattleResources->bufferA[battler][2]); + gBattleSpritesDataPtr->healthBoxesData[battler].partyStatusDelayTimer = 0; + + // If intro, skip the delay after drawing + if (considerDelay && gBattleResources->bufferA[battler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[battler].partyStatusDelayTimer = 93; + + gBattlerControllerFuncs[battler] = Controller_WaitForPartyStatusSummary; + } +} + +void BtlController_HandleHidePartyStatusSummary(void) +{ + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; + BattleControllerComplete(gActiveBattler); +} + void BtlController_HandleBattleAnimation(u32 battler, bool32 ignoreSE, bool32 updateTvData) { if (ignoreSE || !IsBattleSEPlaying(battler))