Fixed double battles send out breaking (#6822)

This commit is contained in:
cawtds 2025-05-12 18:07:22 +02:00 committed by GitHub
parent 5f86fd7de6
commit be03feca94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5345,6 +5345,27 @@ static void Cmd_getexp(void)
}
}
static u32 CountAliveMonsForBattlerSide(u32 battler)
{
u32 aliveMons = 0;
struct Pokemon *party = GetBattlerParty(battler);
for (u32 partyMon = 0; partyMon < PARTY_SIZE; partyMon++)
{
if (GetMonData(&party[partyMon], MON_DATA_SPECIES)
&& GetMonData(&party[partyMon], MON_DATA_HP) > 0
&& !GetMonData(&party[partyMon], MON_DATA_IS_EGG))
aliveMons++;
}
return aliveMons;
}
bool32 NoAliveMonsForBattlerSide(u32 battler)
{
return CountAliveMonsForBattlerSide(battler) == 0;
}
bool32 NoAliveMonsForPlayer(void)
{
u32 i;
@ -5460,7 +5481,12 @@ static void Cmd_checkteamslost(void)
}
else
{
if (emptyOpponentSpots != 0 && emptyPlayerSpots != 0)
u32 occupiedPlayerSpots = (gBattlersCount / 2) - emptyPlayerSpots;
u32 occupiedOpponentSpots = (gBattlersCount / 2) - emptyOpponentSpots;
u32 alivePlayerPartyMons = CountAliveMonsForBattlerSide(B_POSITION_PLAYER_LEFT) - occupiedPlayerSpots;
u32 aliveOpponentPartyMons = CountAliveMonsForBattlerSide(B_POSITION_OPPONENT_LEFT) - occupiedOpponentSpots;
if (emptyPlayerSpots > 0 && alivePlayerPartyMons > 0 && emptyOpponentSpots > 0 && aliveOpponentPartyMons > 0)
gBattlescriptCurrInstr = cmd->jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;