Skip to content

Commit

Permalink
Fix Eject Button triggering on crash damage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine committed Dec 9, 2023
1 parent c7f59d0 commit c9f988b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -5858,9 +5858,9 @@ static void Cmd_moveend(void)
u8 battler = battlers[i];
// Attacker is the damage-dealer, battler is mon to be switched out
if (IsBattlerAlive(battler)
&& gBattlerAttacker != battler
&& GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_EJECT_BUTTON
&& !DoesSubstituteBlockMove(gBattlerAttacker, battler, gCurrentMove)
&& (gSpecialStatuses[battler].physicalDmg != 0 || gSpecialStatuses[battler].specialDmg != 0)
&& TARGET_TURN_DAMAGED
&& CountUsablePartyMons(battler) > 0) // Has mon to switch into
{
gBattleScripting.battler = battler;
Expand Down
21 changes: 21 additions & 0 deletions test/battle/hold_effect/eject_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,24 @@ SINGLE_BATTLE_TEST("Eject Button is activated before Emergency Exit")
MESSAGE("Foe Golisopod is switched out with the Eject Button!");
}
}

SINGLE_BATTLE_TEST("Eject Button is not triggered after High Jump Kick crash damage")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_EJECT_BUTTON); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN {
MOVE(player, MOVE_PROTECT);
MOVE(opponent, MOVE_HIGH_JUMP_KICK);
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_PROTECT, player);
MESSAGE("Foe Wobbuffet kept going and crashed!");
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("Foe Wobbuffet is switched out with the Eject Button!");
}
}
}

0 comments on commit c9f988b

Please sign in to comment.