PartyBattlerShouldAvoidHazards fix

AI was loading and modifying wrong data in the RAM
This commit is contained in:
kleeenexfeu 2021-11-15 16:48:44 +01:00 committed by GitHub
parent b3b3cd2c67
commit ea34d4694d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2408,9 +2408,19 @@ static bool32 AnyUsefulStatIsRaised(u8 battler)
return FALSE;
}
struct Pokemon *GetPartyBattlerPartyData(u8 battlerId, u8 switchBattler)
{
struct Pokemon *mon;
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
mon = &gPlayerParty[switchBattler];
else
mon = &gEnemyParty[switchBattler];
return mon;
}
static bool32 PartyBattlerShouldAvoidHazards(u8 currBattler, u8 switchBattler)
{
struct Pokemon *mon = GetBattlerPartyData(switchBattler);
struct Pokemon *mon = GetPartyBattlerPartyData(currBattler, switchBattler);
u16 ability = GetMonAbility(mon); // we know our own party data
u16 holdEffect = GetBattlerHoldEffect(GetMonData(mon, MON_DATA_HELD_ITEM), TRUE);
u32 flags = gSideStatuses[GetBattlerSide(currBattler)] & (SIDE_STATUS_SPIKES | SIDE_STATUS_STEALTH_ROCK | SIDE_STATUS_STICKY_WEB | SIDE_STATUS_TOXIC_SPIKES);