Merge pull request #520 from ghoulslash/battle_engine

Add Toggle Healthbox Visibility Feature
This commit is contained in:
ExpoSeed 2020-10-31 23:07:39 -05:00 committed by GitHub
commit 1b65e1a1f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 1 deletions

View File

@ -145,4 +145,6 @@
#define B_NEW_IMPACT_PALETTE TRUE // If set to TRUE, it updates the basic 'hit' palette.
#define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette.
#define HIDE_HEALTHBOXES_DURING_ANIMS TRUE //if TRUE, hides healthboxes during move animations
#endif // GUARD_CONSTANTS_BATTLE_CONFIG_H

View File

@ -939,10 +939,65 @@ void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBattlerO
}
static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 healthboxRightSpriteId, u8 healthbarSpriteId, u8 indicatorSpriteId)
{
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)
continue;
switch (priority)
{
case 0: //start of anim -> make invisible
gSprites[spriteIds[i]].invisible = TRUE;
break;
case 1: //end of anim -> make visible
gSprites[spriteIds[i]].invisible = FALSE;
break;
}
}
}
void UpdateOamPriorityInAllHealthboxes(u8 priority)
{
s32 i;
for (i = 0; i < gBattlersCount; i++)
{
u8 healthboxLeftSpriteId = gHealthboxSpriteIds[i];
@ -955,6 +1010,11 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
gSprites[healthbarSpriteId].oam.priority = priority;
if (indicatorSpriteId != 0xFF)
gSprites[indicatorSpriteId].oam.priority = priority;
#if HIDE_HEALTHBOXES_DURING_ANIMS
if (IsBattlerAlive(i))
TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId);
#endif
}
}