Ignore Illusion if the pokemon is the last slot in the party.

This commit is contained in:
Ultimate Bob 2023-05-09 02:33:12 +10:00
parent f985eefaa1
commit 64c2eb39c0

View file

@ -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)]];