Multibattles Illusion party boundaries fix (#7308)

This commit is contained in:
grintoul 2025-07-11 08:53:03 +01:00 committed by GitHub
parent c7b2c771e1
commit d63f859db6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 6 deletions

View File

@ -297,7 +297,7 @@ bool32 TryClearIllusion(u32 battler, u32 caseID);
u32 GetIllusionMonSpecies(u32 battler);
struct Pokemon *GetIllusionMonPtr(u32 battler);
void ClearIllusionMon(u32 battler);
u32 GetIllusionMonPartyId(struct Pokemon *party, struct Pokemon *mon, struct Pokemon *partnerMon);
u32 GetIllusionMonPartyId(struct Pokemon *party, struct Pokemon *mon, struct Pokemon *partnerMon, u32 battler);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battler);
bool32 ShouldGetStatBadgeBoost(u16 flagId, u32 battler);
u32 GetBattleMoveCategory(u32 move);

View File

@ -3187,7 +3187,7 @@ static void IllusionNickHack(u32 battler, u32 partyId, u8 *dst)
else
partnerMon = mon;
id = GetIllusionMonPartyId(gEnemyParty, mon, partnerMon);
id = GetIllusionMonPartyId(gEnemyParty, mon, partnerMon, battler);
}
if (id != PARTY_SIZE)

View File

@ -10373,11 +10373,29 @@ u32 GetIllusionMonSpecies(u32 battler)
return SPECIES_NONE;
}
u32 GetIllusionMonPartyId(struct Pokemon *party, struct Pokemon *mon, struct Pokemon *partnerMon)
u32 GetIllusionMonPartyId(struct Pokemon *party, struct Pokemon *mon, struct Pokemon *partnerMon, u32 battler)
{
s32 id;
s32 partyEnd=6;
s32 partyStart=0;
// Adjust party search range for Multibattles and Player vs two-trainers
if((GetBattlerSide(battler) == B_SIDE_PLAYER && (gBattleTypeFlags & BATTLE_TYPE_MULTI))
|| (GetBattlerSide(battler) == B_SIDE_OPPONENT && (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
{
if((GetBattlerPosition(battler) == B_POSITION_PLAYER_LEFT) || (GetBattlerPosition(battler) == B_POSITION_OPPONENT_LEFT))
{
partyEnd = 3;
partyStart = 0;
}
else
{
partyEnd = 6;
partyStart = 3;
}
}
// Find last alive non-egg pokemon.
for (id = PARTY_SIZE - 1; id >= 0; id--)
for (s32 id = partyEnd - 1; id >= partyStart; id--)
{
if (GetMonData(&party[id], MON_DATA_SANITY_HAS_SPECIES)
&& GetMonData(&party[id], MON_DATA_HP)
@ -10411,7 +10429,7 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battler)
else
partnerMon = mon;
id = GetIllusionMonPartyId(party, mon, partnerMon);
id = GetIllusionMonPartyId(party, mon, partnerMon, battler);
if (id != PARTY_SIZE)
{
gBattleStruct->illusion[battler].state = ILLUSION_ON;