Fixes Parting Shot / Eject Pack interaction

This commit is contained in:
AlexOn1ine 2025-01-06 20:55:11 +01:00
parent adb4a1ff48
commit c2abcab3d6
3 changed files with 37 additions and 14 deletions

View file

@ -6461,18 +6461,22 @@ static void Cmd_moveend(void)
gLastUsedItem = gBattleMons[battler].item; gLastUsedItem = gBattleMons[battler].item;
if (gMovesInfo[gCurrentMove].effect == EFFECT_HIT_ESCAPE) if (gMovesInfo[gCurrentMove].effect == EFFECT_HIT_ESCAPE)
gBattlescriptCurrInstr = BattleScript_MoveEnd; // Prevent user switch-in selection gBattlescriptCurrInstr = BattleScript_MoveEnd; // Prevent user switch-in selection
effect = TRUE;
BattleScriptPushCursor();
gBattleStruct->usedEjectItem |= 1u << battler;
if (ejectButtonBattlers & (1u << battler)) if (ejectButtonBattlers & (1u << battler))
{ {
effect = TRUE;
gBattleStruct->usedEjectItem |= 1u << battler;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_EjectButtonActivates; gBattlescriptCurrInstr = BattleScript_EjectButtonActivates;
AI_DATA->ejectButtonSwitch = TRUE; AI_DATA->ejectButtonSwitch = TRUE;
} }
else // Eject Pack else // Eject Pack
{ {
if (!(gBattleResources->flags->flags[gBattlerTarget] & RESOURCE_FLAG_EMERGENCY_EXIT)) if (!(gBattleResources->flags->flags[gBattlerTarget] & RESOURCE_FLAG_EMERGENCY_EXIT)
&& !(gMovesInfo[gCurrentMove].effect == EFFECT_PARTING_SHOT && CanBattlerSwitch(gBattlerAttacker)))
{ {
effect = TRUE;
gBattleStruct->usedEjectItem |= 1u << battler;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_EjectPackActivates; gBattlescriptCurrInstr = BattleScript_EjectPackActivates;
AI_DATA->ejectPackSwitch = TRUE; AI_DATA->ejectPackSwitch = TRUE;
gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage = TRUE; gSpecialStatuses[gBattlerAttacker].preventLifeOrbDamage = TRUE;

View file

@ -102,3 +102,22 @@ SINGLE_BATTLE_TEST("Eject Pack activates once intimidate mon switches in")
MESSAGE("Wobbuffet is switched out with the Eject Pack!"); MESSAGE("Wobbuffet is switched out with the Eject Pack!");
} }
} }
SINGLE_BATTLE_TEST("Eject Pack will not activate if Parting Shot user can switch out")
{
ASSUME(gItemsInfo[ITEM_EJECT_PACK].holdEffect == HOLD_EFFECT_EJECT_PACK);
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_EJECT_PACK); }
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_PARTING_SHOT); SEND_OUT(opponent, 1); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_PARTING_SHOT, opponent);
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet is switched out with the Eject Pack!");
}
}
}

View file

@ -6,7 +6,7 @@ ASSUMPTIONS
ASSUME(gMovesInfo[MOVE_U_TURN].effect == EFFECT_HIT_ESCAPE); ASSUME(gMovesInfo[MOVE_U_TURN].effect == EFFECT_HIT_ESCAPE);
} }
SINGLE_BATTLE_TEST("U-turn switches the user out") SINGLE_BATTLE_TEST("Hit Escape: U-turn switches the user out")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET);
@ -21,7 +21,7 @@ SINGLE_BATTLE_TEST("U-turn switches the user out")
} }
} }
SINGLE_BATTLE_TEST("U-turn does not switch the user out if the battle ends") SINGLE_BATTLE_TEST("Hit Escape: U-turn does not switch the user out if the battle ends")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET);
@ -35,7 +35,7 @@ SINGLE_BATTLE_TEST("U-turn does not switch the user out if the battle ends")
} }
} }
SINGLE_BATTLE_TEST("U-turn does not switch the user out if no replacements") SINGLE_BATTLE_TEST("Hit Escape: U-turn does not switch the user out if no replacements")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET);
@ -48,7 +48,7 @@ SINGLE_BATTLE_TEST("U-turn does not switch the user out if no replacements")
} }
} }
SINGLE_BATTLE_TEST("U-turn does not switch the user out if replacements fainted") SINGLE_BATTLE_TEST("Hit Escape: U-turn does not switch the user out if replacements fainted")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET);
@ -62,7 +62,7 @@ SINGLE_BATTLE_TEST("U-turn does not switch the user out if replacements fainted"
} }
} }
SINGLE_BATTLE_TEST("U-turn does not switch the user out if Wimp Out activates") SINGLE_BATTLE_TEST("Hit Escape: U-turn does not switch the user out if Wimp Out activates")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET);
@ -79,7 +79,7 @@ SINGLE_BATTLE_TEST("U-turn does not switch the user out if Wimp Out activates")
} }
} }
SINGLE_BATTLE_TEST("U-turn switches the user out if Wimp Out fails to activate") SINGLE_BATTLE_TEST("Hit Escape: U-turn switches the user out if Wimp Out fails to activate")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_WOBBUFFET); PLAYER(SPECIES_WOBBUFFET);
@ -95,7 +95,7 @@ SINGLE_BATTLE_TEST("U-turn switches the user out if Wimp Out fails to activate")
} }
} }
SINGLE_BATTLE_TEST("U-turn switches the user out after Ice Face activates") SINGLE_BATTLE_TEST("Hit Escape: U-turn switches the user out after Ice Face activates")
{ {
GIVEN { GIVEN {
ASSUME(gMovesInfo[MOVE_U_TURN].category == DAMAGE_CATEGORY_PHYSICAL); ASSUME(gMovesInfo[MOVE_U_TURN].category == DAMAGE_CATEGORY_PHYSICAL);
@ -113,7 +113,7 @@ SINGLE_BATTLE_TEST("U-turn switches the user out after Ice Face activates")
} }
} }
SINGLE_BATTLE_TEST("Held items are consumed immediately after a mon switched in by U-turn and Intimidate activates after it: player side") SINGLE_BATTLE_TEST("Hit Escape: Held items are consumed immediately after a mon switched in by U-turn and Intimidate activates after it: player side")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_TAPU_KOKO) { Ability(ABILITY_ELECTRIC_SURGE); }; PLAYER(SPECIES_TAPU_KOKO) { Ability(ABILITY_ELECTRIC_SURGE); };
@ -136,7 +136,7 @@ SINGLE_BATTLE_TEST("Held items are consumed immediately after a mon switched in
} }
} }
SINGLE_BATTLE_TEST("Held items are consumed immediately after a mon switched in by U-turn and Intimidate activates after it: opposing side") SINGLE_BATTLE_TEST("Hit Escape: Held items are consumed immediately after a mon switched in by U-turn and Intimidate activates after it: opposing side")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_TAPU_KOKO) { Ability(ABILITY_ELECTRIC_SURGE); }; PLAYER(SPECIES_TAPU_KOKO) { Ability(ABILITY_ELECTRIC_SURGE); };
@ -159,7 +159,7 @@ SINGLE_BATTLE_TEST("Held items are consumed immediately after a mon switched in
} }
} }
SINGLE_BATTLE_TEST("Electric Seed boost is received by the right pokemon after U-turn and Intimidate") SINGLE_BATTLE_TEST("Hit Escape: Electric Seed boost is received by the right pokemon after U-turn and Intimidate")
{ {
GIVEN { GIVEN {
PLAYER(SPECIES_TAPU_KOKO) { Ability(ABILITY_ELECTRIC_SURGE); }; PLAYER(SPECIES_TAPU_KOKO) { Ability(ABILITY_ELECTRIC_SURGE); };