From 6139b12a49a69d5933aa971913a8a61541d5a957 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 2 Feb 2021 23:30:08 -0700 Subject: [PATCH] fix hp boxes not dissapearing --- include/battle_interface.h | 2 +- src/battle_anim.c | 26 ++++++++++++++++++++++++-- src/battle_anim_throw.c | 6 +++--- src/battle_interface.c | 37 ++----------------------------------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/include/battle_interface.h b/include/battle_interface.h index d06c44e884..0bcadaaacb 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -74,7 +74,7 @@ void SetHealthboxSpriteInvisible(u8 healthboxSpriteId); void SetHealthboxSpriteVisible(u8 healthboxSpriteId); void DestoryHealthboxSprite(u8 healthboxSpriteId); void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly); -void UpdateOamPriorityInAllHealthboxes(u8 priority); +void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHpBoxes); void InitBattlerHealthboxCoords(u8 battler); void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent); void SwapHpBarsWithHpText(void); diff --git a/src/battle_anim.c b/src/battle_anim.c index cb7ea5bea0..f20d30dabb 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -18,6 +18,7 @@ #include "task.h" #include "constants/battle_anim.h" #include "constants/battle_config.h" +#include "constants/battle_moves.h" #define ANIM_SPRITE_INDEX_COUNT 8 @@ -2198,11 +2199,32 @@ void DoMoveAnim(u16 move) void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim) { s32 i; + bool32 hideHpBoxes = (tableId == MOVE_TRANSFORM) ? FALSE : TRUE; + + if (!isMoveAnim) + { + switch (tableId) + { + case B_ANIM_TURN_TRAP: + case B_ANIM_LEECH_SEED_DRAIN: + case B_ANIM_MON_HIT: + case B_ANIM_SNATCH_MOVE: + case B_ANIM_FUTURE_SIGHT_HIT: + case B_ANIM_DOOM_DESIRE_HIT: + case B_ANIM_WISH_HEAL: + case B_ANIM_MEGA_EVOLUTION: + hideHpBoxes = TRUE; + break; + default: + hideHpBoxes = FALSE; + break; + } + } if (!IsContest()) { sub_80A8278(); - UpdateOamPriorityInAllHealthboxes(0); + UpdateOamPriorityInAllHealthboxes(0, hideHpBoxes); for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (GetBattlerSide(i) != B_SIDE_PLAYER) @@ -2511,7 +2533,7 @@ static void ScriptCmd_end(void) if (!IsContest()) { sub_80A8278(); - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, TRUE); } gAnimScriptActive = FALSE; } diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index cd686af5ca..869daf030f 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -1332,7 +1332,7 @@ static void SpriteCB_Ball_Capture_Step(struct Sprite *sprite) else if (sprite->sTimer == 95) { gDoingBattleAnim = FALSE; - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, FALSE); m4aMPlayAllStop(); PlaySE(MUS_RG_CAUGHT_INTRO); } @@ -1515,7 +1515,7 @@ static void SpriteCB_Ball_Release_Wait(struct Sprite *sprite) sprite->sFrame = 0; sprite->callback = DestroySpriteAfterOneFrame; gDoingBattleAnim = 0; - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, FALSE); } } @@ -1557,7 +1557,7 @@ static void SpriteCB_Ball_Block_Step(struct Sprite *sprite) sprite->sFrame = 0; sprite->callback = DestroySpriteAfterOneFrame; gDoingBattleAnim = 0; - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, FALSE); } } diff --git a/src/battle_interface.c b/src/battle_interface.c index 73b66a7ff0..9cf708f37a 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -944,39 +944,6 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 u8 spriteIds[4] = {healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId}; int i; - switch (gBattleResources->bufferA[gBattleAnimAttacker][0]) - { - case CONTROLLER_MOVEANIMATION: - if (gBattleResources->bufferA[gBattleAnimAttacker][1] == MOVE_TRANSFORM) - return; - break; - case CONTROLLER_BALLTHROWANIM: - return; //throwing ball does not hide hp boxes - case CONTROLLER_BATTLEANIMATION: - //check special anims that hide health boxes - switch (gBattleResources->bufferA[gBattleAnimAttacker][1]) - { - case B_ANIM_TURN_TRAP: - case B_ANIM_LEECH_SEED_DRAIN: - case B_ANIM_MON_HIT: - case B_ANIM_SNATCH_MOVE: - case B_ANIM_FUTURE_SIGHT_HIT: - case B_ANIM_DOOM_DESIRE_HIT: - case B_ANIM_WISH_HEAL: - //new - case B_ANIM_MEGA_EVOLUTION: - case B_ANIM_TERRAIN_MISTY: - case B_ANIM_TERRAIN_GRASSY: - case B_ANIM_TERRAIN_ELECTRIC: - case B_ANIM_TERRAIN_PSYCHIC: - break; - } - return; //all other special anims dont hide - default: - return; - } - - // if we've reached here, we should hide hp boxes for (i = 0; i < NELEMS(spriteIds); i++) { if (spriteIds[i] == 0xFF) @@ -994,7 +961,7 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 } } -void UpdateOamPriorityInAllHealthboxes(u8 priority) +void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHPBoxes) { s32 i; @@ -1012,7 +979,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority) gSprites[indicatorSpriteId].oam.priority = priority; #if B_HIDE_HEALTHBOXES_DURING_ANIMS - if (IsBattlerAlive(i)) + if (hideHPBoxes && IsBattlerAlive(i)) TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId); #endif }