summaryrefslogtreecommitdiff
path: root/src/battle_script_commands.c
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-09-09 16:27:24 -0400
committerGitHub <noreply@github.com>2020-09-09 16:27:24 -0400
commitd260943249387a5d25cbb60886b6c8aa72e3f24f (patch)
tree7e326cc3ea683c03827e7715fa7ef1836e87671d /src/battle_script_commands.c
parent8f6d6b933e081d6e7a35b52bd36da9d11952145b (diff)
parent7f1827767c27c6b696a9cd1a8c15b2b31a125b78 (diff)
Merge pull request #1182 from PokeCodec/PokemonLogicFix
Fix more fakematches
Diffstat (limited to 'src/battle_script_commands.c')
-rw-r--r--src/battle_script_commands.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 7ded6fcd8..e3405bc0c 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -7127,18 +7127,12 @@ static void Cmd_forcerandomswitch(void)
s32 i;
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))
{
@@ -7250,14 +7244,14 @@ 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, conjoined by an ||, but that doesn't match. Equivalent logic though
}
*(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i;