From 64c2eb39c0f65632ed06b1b19bbf2fca4dc7b089 Mon Sep 17 00:00:00 2001 From: Ultimate Bob Date: Tue, 9 May 2023 02:33:12 +1000 Subject: [PATCH] Ignore Illusion if the pokemon is the last slot in the party. --- src/battle_util.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index cd65d58093..dd6e2bc06e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -10398,12 +10398,19 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId) { struct Pokemon *party, *partnerMon; s32 i, id; + u8 side, partyCount; gBattleStruct->illusion[battlerId].set = 1; if (GetMonAbility(mon) != ABILITY_ILLUSION) return FALSE; party = GetBattlerParty(battlerId); + side = GetBattlerSide(battlerId); + partyCount = side == B_SIDE_PLAYER ? gPlayerPartyCount : gEnemyPartyCount; + + // If this pokemon is last in the party, ignore Illusion. + if (&party[partyCount - 1] == mon) + return FALSE; if (IsBattlerAlive(BATTLE_PARTNER(battlerId))) partnerMon = &party[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]];