port Cmd_forcerandomswitch fakematch fix

This commit is contained in:
Kurausukun
2020-10-26 00:17:26 -04:00
parent af0a1cb7bf
commit 9ca406b15d
+8 -12
View File
@@ -7131,17 +7131,12 @@ static void Cmd_forcerandomswitch(void)
s32 battler1PartyId = 0; s32 battler1PartyId = 0;
s32 battler2PartyId = 0; s32 battler2PartyId = 0;
#ifdef NONMATCHING s32 firstMonId;
s32 lastMonId = 0; // + 1 s32 lastMonId = 0; // + 1
#else s32 monsCount;
register s32 lastMonId asm("r8") = 0; // + 1
#endif // NONMATCHING
s32 firstMonId = 0;
s32 monsCount = 0;
struct Pokemon* party = NULL; struct Pokemon* party = NULL;
s32 validMons = 0; s32 validMons = 0;
s32 minNeeded = 0; s32 minNeeded;
if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)) if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER))
{ {
@@ -7250,17 +7245,18 @@ static void Cmd_forcerandomswitch(void)
else else
{ {
if (TryDoForceSwitchOut()) if (TryDoForceSwitchOut())
{
do
{ {
do do
{ {
i = Random() % monsCount; i = Random() % monsCount;
i += firstMonId; i += firstMonId;
} }
while (i == battler2PartyId while (i == battler2PartyId || i == battler1PartyId);
|| i == battler1PartyId } while (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE || GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE
|| GetMonData(&party[i], MON_DATA_HP) == 0); || GetMonData(&party[i], MON_DATA_HP) == 0); //should be one while loop, but that doesn't match.
} }
*(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i; *(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i;