Skip to content

Commit

Permalink
Fix Baton Pass breaking on Memento (#4773)
Browse files Browse the repository at this point in the history
* Fix Baton Pass breaking on Memento

* doubled headers
  • Loading branch information
DizzyEggg authored Jun 12, 2024
1 parent 251019d commit a172597
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -7032,8 +7032,12 @@ static void Cmd_openpartyscreen(void)
if (gAbsentBattlerFlags & gBitTable[battlerOpposite])
battlerOpposite ^= BIT_FLANK;

BtlController_EmitLinkStandbyMsg(battlerOpposite, BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE);
MarkBattlerForControllerExec(battlerOpposite);
// Make sure we're checking a valid battler. In edge case scenarios - battler could be absent and battlerOpposite would become a non-existent one softlocking the game.
if (battlerOpposite < gBattlersCount)
{
BtlController_EmitLinkStandbyMsg(battlerOpposite, BUFFER_A, LINK_STANDBY_MSG_ONLY, FALSE);
MarkBattlerForControllerExec(battlerOpposite);
}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/battle/move_effect/baton_pass.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gMovesInfo[MOVE_BATON_PASS].effect == EFFECT_BATON_PASS);
}

// This softlocked the game before.
SINGLE_BATTLE_TEST("Baton Pass used after Memento works correctly")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WYNAUT);
OPPONENT(SPECIES_CATERPIE);
} WHEN {
TURN { MOVE(player, MOVE_MEMENTO); SEND_OUT(player, 1); MOVE(opponent, MOVE_BATON_PASS); SEND_OUT(opponent, 1); }
} SCENE {
MESSAGE("Wobbuffet used Memento!");
MESSAGE("Wobbuffet fainted!");
MESSAGE("Foe Wynaut used Baton Pass!");
MESSAGE("2 sent out Caterpie!");
MESSAGE("Go! Wobbuffet!");
}
}

TO_DO_BATTLE_TEST("Baton Pass switches out the user");
TO_DO_BATTLE_TEST("Baton Pass fails if there's no valid party Pokémon left");
TO_DO_BATTLE_TEST("Baton Pass passes both positive and negative stat changes");
Expand Down

0 comments on commit a172597

Please sign in to comment.