From 2a6fd2495418200af20c4c12cebbd9b8975604b7 Mon Sep 17 00:00:00 2001 From: Bivurnum <147376167+Bivurnum@users.noreply.github.com> Date: Tue, 25 Feb 2025 15:15:09 -0600 Subject: [PATCH] fix for multi 2vs1 opponent sends out too many mons bug (#6324) --- src/battle_util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 8096e8e487..28da294042 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3816,6 +3816,21 @@ bool32 HasNoMonsToSwitch(u32 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2 playerId = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); party = gEnemyParty; + // Edge case: If both opposing Pokemon were knocked out on the same turn, + // make sure opponent only sents out the final Pokemon once. + if (battler == playerId + && (gHitMarker & HITMARKER_FAINTED(flankId)) + && (gHitMarker & HITMARKER_FAINTED(playerId))) + { + u8 count = 0; + for (i = 0; i < PARTY_SIZE; i++) + if (IsValidForBattle(&party[i])) + count++; + + if (count < 2) + return TRUE; + } + if (partyIdBattlerOn1 == PARTY_SIZE) partyIdBattlerOn1 = gBattlerPartyIndexes[flankId]; if (partyIdBattlerOn2 == PARTY_SIZE)