Skip to content

Commit

Permalink
Fixes Emergency Exit when hp is restored over tag out range
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine committed Jan 21, 2024
1 parent 73a1fa3 commit 4fe8752
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6793,6 +6793,10 @@ static u8 ItemHealHp(u32 battler, u32 itemId, bool32 end2, bool32 percentHeal)
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ItemHealHP_RemoveItemRet;
}
if (gBattleResources->flags->flags[battler] & RESOURCE_FLAG_EMERGENCY_EXIT
&& GetNonDynamaxMaxHP(battler) > gBattleMons[battler].maxHP / 2)
gBattleResources->flags->flags[battler] &= ~RESOURCE_FLAG_EMERGENCY_EXIT;

return ITEM_HP_CHANGE;
}
return 0;
Expand Down
24 changes: 21 additions & 3 deletions test/battle/ability/emergency_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,34 @@ SINGLE_BATTLE_TEST("Emergency Exit switches out when taking 50% max-hp damage")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Attack(1314); }; // will deal exactly 132 damage, putting GOLISOPOD just under half hp
OPPONENT(SPECIES_GOLISOPOD) { Ability(ABILITY_EMERGENCY_EXIT); MaxHP(263); HP(263); };
OPPONENT(SPECIES_GOLISOPOD) { Ability(ABILITY_EMERGENCY_EXIT); MaxHP(263); HP(262); };
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN {
MOVE(player, MOVE_POUND);
MOVE(player, MOVE_SUPER_FANG);
SEND_OUT(opponent, 1);
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_POUND, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_SUPER_FANG, player);
HP_BAR(opponent);
ABILITY_POPUP(opponent, ABILITY_EMERGENCY_EXIT);
}
}

SINGLE_BATTLE_TEST("Emergency Exit switches out when taking 50% max-hp damage after a restore hp hold effect was used")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET)
OPPONENT(SPECIES_GOLISOPOD) { Ability(ABILITY_EMERGENCY_EXIT); MaxHP(263); HP(262); Item(ITEM_SITRUS_BERRY); };
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN {
MOVE(player, MOVE_SUPER_FANG);
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SUPER_FANG, player);
HP_BAR(opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
NOT ABILITY_POPUP(opponent, ABILITY_EMERGENCY_EXIT);
}
}

0 comments on commit 4fe8752

Please sign in to comment.