Fix battle frontier random loss (#3990)

Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
Bassoonian 2024-01-15 22:07:27 +01:00 committed by GitHub
parent f6c08c08b6
commit 1182368330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4363,50 +4363,22 @@ static void Cmd_getexp(void)
}
}
static bool32 NoAliveMonsForPlayerAndPartner(void)
{
u32 i;
u32 HP_count = 0;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER))
{
for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i])))
{
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
}
}
}
return (HP_count == 0);
}
bool32 NoAliveMonsForPlayer(void)
{
u32 i;
u32 maxI = PARTY_SIZE;
u32 HP_count = 0;
if (B_MULTI_BATTLE_WHITEOUT < GEN_4 && gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER))
maxI = MULTI_PARTY_SIZE;
// Get total HP for the player's party to determine if the player has lost
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER))
for (i = 0; i < maxI; i++)
{
// In multi battle with Steven, skip his Pokémon
for (i = 0; i < MULTI_PARTY_SIZE; i++)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i])))
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
}
}
else
{
for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
&& (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->arenaLostPlayerMons & gBitTable[i])))
{
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
}
HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
}
}
@ -4446,16 +4418,9 @@ static void Cmd_checkteamslost(void)
if (gBattleControllerExecFlags)
return;
if (B_MULTI_BATTLE_WHITEOUT >= GEN_4 && gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER))
{
if (NoAliveMonsForPlayerAndPartner())
gBattleOutcome |= B_OUTCOME_LOST;
}
else
{
if (NoAliveMonsForPlayer())
gBattleOutcome |= B_OUTCOME_LOST;
}
if (NoAliveMonsForPlayer())
gBattleOutcome |= B_OUTCOME_LOST;
if (NoAliveMonsForOpponent())
gBattleOutcome |= B_OUTCOME_WON;