diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c2c4e6c41..14866bbca 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4666,19 +4666,16 @@ static void Cmd_jumpifcantswitch(void) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - #ifndef NONMATCHING - asm("":::"r5"); - #endif // NONMATCHING if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) party = gEnemyParty; else party = gPlayerParty; - i = 0; + lastMonId = 0; if (gActiveBattler & 2) - i = 3; + lastMonId = 3; - for (lastMonId = i + 3; i < lastMonId; i++) + for (i = lastMonId; i < lastMonId + 3; i++) { if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&party[i], MON_DATA_IS_EGG) @@ -4687,7 +4684,7 @@ static void Cmd_jumpifcantswitch(void) break; } - if (i == lastMonId) + if (i == lastMonId + 3) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -4700,18 +4697,18 @@ static void Cmd_jumpifcantswitch(void) { party = gPlayerParty; - i = 0; + lastMonId = 0; if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gActiveBattler)) == TRUE) - i = 3; + lastMonId = 3; } else { party = gEnemyParty; if (gActiveBattler == 1) - i = 0; + lastMonId = 0; else - i = 3; + lastMonId = 3; } } else @@ -4721,12 +4718,12 @@ static void Cmd_jumpifcantswitch(void) else party = gPlayerParty; - i = 0; + lastMonId = 0; if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gActiveBattler)) == TRUE) - i = 3; + lastMonId = 3; } - for (lastMonId = i + 3; i < lastMonId; i++) + for (i = lastMonId; i < lastMonId + 3; i++) { if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&party[i], MON_DATA_IS_EGG) @@ -4735,7 +4732,7 @@ static void Cmd_jumpifcantswitch(void) break; } - if (i == lastMonId) + if (i == lastMonId + 3) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -4744,11 +4741,11 @@ static void Cmd_jumpifcantswitch(void) { party = gEnemyParty; - i = 0; + lastMonId = 0; if (gActiveBattler == B_POSITION_OPPONENT_RIGHT) - i = 3; + lastMonId = 3; - for (lastMonId = i + 3; i < lastMonId; i++) + for (i = lastMonId; i < lastMonId + 3; i++) { if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&party[i], MON_DATA_IS_EGG) @@ -4757,7 +4754,7 @@ static void Cmd_jumpifcantswitch(void) break; } - if (i == lastMonId) + if (i == lastMonId + 3) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6;