Skip to content

Commit

Permalink
fix for multi 2vs1 opponent sends out too many mons bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Bivurnum committed Feb 22, 2025
1 parent 5b4de20 commit ed7e510
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ed7e510

Please sign in to comment.