diff --git a/src/battle_util.c b/src/battle_util.c index ec7654caf0..167d5bf599 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6794,7 +6794,7 @@ static u8 ItemHealHp(u32 battler, u32 itemId, bool32 end2, bool32 percentHeal) gBattlescriptCurrInstr = BattleScript_ItemHealHP_RemoveItemRet; } if (gBattleResources->flags->flags[battler] & RESOURCE_FLAG_EMERGENCY_EXIT - && GetNonDynamaxMaxHP(battler) > gBattleMons[battler].maxHP / 2) + && GetNonDynamaxHP(battler) >= GetNonDynamaxMaxHP(battler) / 2) gBattleResources->flags->flags[battler] &= ~RESOURCE_FLAG_EMERGENCY_EXIT; return ITEM_HP_CHANGE; diff --git a/test/battle/ability/emergency_exit.c b/test/battle/ability/emergency_exit.c index 73c7ebbe00..68724450e1 100644 --- a/test/battle/ability/emergency_exit.c +++ b/test/battle/ability/emergency_exit.c @@ -8,10 +8,7 @@ SINGLE_BATTLE_TEST("Emergency Exit switches out when taking 50% max-hp damage") OPPONENT(SPECIES_GOLISOPOD) { Ability(ABILITY_EMERGENCY_EXIT); MaxHP(263); HP(262); }; OPPONENT(SPECIES_WOBBUFFET); } WHEN { - TURN { - MOVE(player, MOVE_SUPER_FANG); - SEND_OUT(opponent, 1); - } + TURN { MOVE(player, MOVE_SUPER_FANG); SEND_OUT(opponent, 1); } } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_SUPER_FANG, player); HP_BAR(opponent); @@ -19,16 +16,14 @@ SINGLE_BATTLE_TEST("Emergency Exit switches out when taking 50% max-hp damage") } } -SINGLE_BATTLE_TEST("Emergency Exit switches out when taking 50% max-hp damage after a restore hp hold effect was used") +SINGLE_BATTLE_TEST("Emergency Exit does not switch out when going below 50% max-HP but healed via held item back above the threshold") { 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); - } + TURN { MOVE(player, MOVE_SUPER_FANG); } } SCENE { ANIMATION(ANIM_TYPE_MOVE, MOVE_SUPER_FANG, player); HP_BAR(opponent); @@ -36,3 +31,19 @@ SINGLE_BATTLE_TEST("Emergency Exit switches out when taking 50% max-hp damage af NOT ABILITY_POPUP(opponent, ABILITY_EMERGENCY_EXIT); } } + +SINGLE_BATTLE_TEST("Emergency Exit switches out when going below 50% max-HP but healing via held item is not enough to go back above the threshold") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) + OPPONENT(SPECIES_GOLISOPOD) { Ability(ABILITY_EMERGENCY_EXIT); MaxHP(263); HP(133); Item(ITEM_ORAN_BERRY); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SUPER_FANG); SEND_OUT(opponent, 1); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SUPER_FANG, player); + HP_BAR(opponent); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent); + ABILITY_POPUP(opponent, ABILITY_EMERGENCY_EXIT); + } +}