Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Pursuit + Emergency Exit causing double switches and Pursuit user fainting causing target to not finish switch #5849

Merged
merged 3 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3230,6 +3230,13 @@ void SwitchInClearSetData(u32 battler)
gBattleStruct->boosterEnergyActivates &= ~(1u << battler);
gBattleStruct->canPickupItem &= ~(1u << battler);

if (gBattleStruct->pursuitTarget & (1u << battler))
{
gBattleStruct->pursuitTarget = 0;
gBattleStruct->pursuitSwitchByMove = FALSE;
gBattleStruct->pursuitStoredSwitch = 0;
}

for (i = 0; i < ARRAY_COUNT(gSideTimers); i++)
{
// Switched into sticky web user slot, so reset stored battler ID
Expand Down Expand Up @@ -3360,9 +3367,13 @@ const u8* FaintClearSetData(u32 battler)
gBattleStruct->lastTakenMoveFrom[battler][1] = 0;
gBattleStruct->lastTakenMoveFrom[battler][2] = 0;
gBattleStruct->lastTakenMoveFrom[battler][3] = 0;
gBattleStruct->pursuitTarget = 0;
gBattleStruct->pursuitSwitchByMove = FALSE;
gBattleStruct->pursuitStoredSwitch = 0;

if (gBattleStruct->pursuitTarget & (1u << battler))
{
gBattleStruct->pursuitTarget = 0;
gBattleStruct->pursuitSwitchByMove = FALSE;
gBattleStruct->pursuitStoredSwitch = 0;
}

gBattleStruct->palaceFlags &= ~(1u << battler);
gBattleStruct->boosterEnergyActivates &= ~(1u << battler);
Expand Down
63 changes: 63 additions & 0 deletions test/battle/move_effect/pursuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,4 +610,67 @@ SINGLE_BATTLE_TEST("Pursuit attacks a switching foe and switchin is correctly st
}
}

SINGLE_BATTLE_TEST("Pursuit doesn't cause mon with Emergency Exit to switch twice")
{
GIVEN {
PLAYER(SPECIES_GOLISOPOD) { HP(101); MaxHP(200); Ability(ABILITY_EMERGENCY_EXIT); }
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_VOLTORB);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_PURSUIT); SEND_OUT(player, 2); }
} SCENE {
SWITCH_OUT_MESSAGE("Golisopod");
ANIMATION(ANIM_TYPE_MOVE, MOVE_PURSUIT, opponent);
ABILITY_POPUP(player, ABILITY_EMERGENCY_EXIT);
SEND_IN_MESSAGE("Voltorb");
} THEN {
EXPECT_EQ(player->species, SPECIES_VOLTORB);
}
}

SINGLE_BATTLE_TEST("Pursuit user gets forced out by Red Card and target still switches out")
{
GIVEN {
ASSUME(gItemsInfo[ITEM_RED_CARD].holdEffect == HOLD_EFFECT_RED_CARD);
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_RED_CARD); }
PLAYER(SPECIES_VOLTORB);
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_VOLTORB);
} WHEN {
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_PURSUIT); }
} SCENE {
SWITCH_OUT_MESSAGE("Wobbuffet");
ANIMATION(ANIM_TYPE_MOVE, MOVE_PURSUIT, opponent);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("The opposing Voltorb was dragged out!");
SEND_IN_MESSAGE("Voltorb");
} THEN {
EXPECT_EQ(player->species, SPECIES_VOLTORB);
EXPECT_EQ(opponent->species, SPECIES_VOLTORB);
}
}

SINGLE_BATTLE_TEST("Pursuit user faints to Life Orb and target still switches out")
{
GIVEN {
ASSUME(gItemsInfo[ITEM_LIFE_ORB].holdEffect == HOLD_EFFECT_LIFE_ORB);
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_VOLTORB);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LIFE_ORB); HP(1); }
OPPONENT(SPECIES_VOLTORB);
} WHEN {
TURN { SWITCH(player, 1); MOVE(opponent, MOVE_PURSUIT); SEND_OUT(opponent, 1); }
} SCENE {
SWITCH_OUT_MESSAGE("Wobbuffet");
ANIMATION(ANIM_TYPE_MOVE, MOVE_PURSUIT, opponent);
HP_BAR(opponent);
MESSAGE("The opposing Wobbuffet fainted!");
SEND_IN_MESSAGE("Voltorb");
} THEN {
EXPECT_EQ(player->species, SPECIES_VOLTORB);
EXPECT_EQ(opponent->species, SPECIES_VOLTORB);
}
}

TO_DO_BATTLE_TEST("Baton Pass doesn't cause Pursuit to increase its power or priority");
Loading