diff options
author | Kurausukun <lord.uber1@gmail.com> | 2020-10-26 00:17:26 -0400 |
---|---|---|
committer | Kurausukun <lord.uber1@gmail.com> | 2020-10-26 00:17:26 -0400 |
commit | 9ca406b15d0f0146643b18155d5ffd6cc337fcbb (patch) | |
tree | 86394bb65f8419edbbfa98fea2c564dbf380b46e | |
parent | af0a1cb7bf71b8d27cc33db4ddca040ad1e8eb35 (diff) |
port Cmd_forcerandomswitch fakematch fix
-rw-r--r-- | src/battle_script_commands.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 512830900..a16cfff3b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7131,17 +7131,12 @@ static void Cmd_forcerandomswitch(void) s32 battler1PartyId = 0; s32 battler2PartyId = 0; - #ifdef NONMATCHING - s32 lastMonId = 0; // + 1 - #else - register s32 lastMonId asm("r8") = 0; // + 1 - #endif // NONMATCHING - - s32 firstMonId = 0; - s32 monsCount = 0; + s32 firstMonId; + s32 lastMonId = 0; // + 1 + s32 monsCount; struct Pokemon* party = NULL; s32 validMons = 0; - s32 minNeeded = 0; + s32 minNeeded; if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)) { @@ -7253,14 +7248,15 @@ static void Cmd_forcerandomswitch(void) { do { - i = Random() % monsCount; - i += firstMonId; - } - while (i == battler2PartyId - || i == battler1PartyId - || GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE + do + { + i = Random() % monsCount; + i += firstMonId; + } + while (i == battler2PartyId || i == battler1PartyId); + } while (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE || 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; |