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

Fix Baton Pass breaking on Memento #4773

Merged
merged 2 commits into from
Jun 12, 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
6 changes: 3 additions & 3 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3677,8 +3677,8 @@ const u8* FaintClearSetData(u32 battler)
gBattleStruct->zmove.toBeUsed[battler] = MOVE_NONE;
gBattleStruct->zmove.effect = EFFECT_HIT;
// Clear Dynamax data
UndoDynamax(battler);
UndoDynamax(battler);

return result;
}

Expand Down Expand Up @@ -5835,7 +5835,7 @@ static void TryEvolvePokemon(void)
sTriedEvolving |= gBitTable[i];

if (species == SPECIES_NONE && (gLeveledUpInBattle & gBitTable[i]))
{
{
gLeveledUpInBattle &= ~(gBitTable[i]);
species = GetEvolutionTargetSpecies(&gPlayerParty[i], EVO_MODE_BATTLE_ONLY, gLeveledUpInBattle, NULL);
}
Expand Down
16 changes: 10 additions & 6 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ static void Cmd_adjustdamage(void)
gLastUsedItem = gBattleMons[gBattlerTarget].item;
gSpecialStatuses[gBattlerTarget].focusBanded = FALSE;
gSpecialStatuses[gBattlerTarget].focusSashed = FALSE;

}
else if (gSpecialStatuses[gBattlerTarget].sturdied)
{
Expand Down Expand Up @@ -3225,8 +3225,8 @@ void SetMoveEffect(bool32 primary, bool32 certain)
{
gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[gBattleScripting.moveEffect];
gBattlescriptCurrInstr++;
}
else
}
else
{
gBattlescriptCurrInstr++;
}
Expand Down Expand Up @@ -6285,7 +6285,7 @@ static void Cmd_moveend(void)
break;
}
}

if (!(gBattleStruct->lastMoveFailed & gBitTable[gBattlerAttacker]
|| (!gSpecialStatuses[gBattlerAttacker].dancerUsedMove
&& gBattleStruct->bouncedMoveIsUsed)))
Expand Down Expand Up @@ -7030,8 +7030,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
Loading