diff --git a/src/battle_util.c b/src/battle_util.c index 1e56ab1914..ec7654caf0 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -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; diff --git a/test/battle/ability/emergency_exit.c b/test/battle/ability/emergency_exit.c index ad1fd630a0..73c7ebbe00 100644 --- a/test/battle/ability/emergency_exit.c +++ b/test/battle/ability/emergency_exit.c @@ -4,17 +4,35 @@ 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); }; + PLAYER(SPECIES_WOBBUFFET); + 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); + } +}