Fix ShouldPivot overwriting random memory (#7882)
Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
parent
015a0fea03
commit
ffe0936ff1
@ -3174,14 +3174,16 @@ enum AIPivot ShouldPivot(u32 battlerAtk, u32 battlerDef, u32 defAbility, u32 mov
|
||||
u32 battlerToSwitch;
|
||||
u32 predictedMoveSpeedCheck = GetIncomingMoveSpeedCheck(battlerAtk, battlerDef, gAiLogicData);
|
||||
|
||||
battlerToSwitch = gBattleStruct->AI_monToSwitchIntoId[battlerAtk];
|
||||
|
||||
// Palafin always wants to activate Zero to Hero
|
||||
if (gBattleMons[battlerAtk].species == SPECIES_PALAFIN_ZERO
|
||||
&& gBattleMons[battlerAtk].ability == ABILITY_ZERO_TO_HERO
|
||||
&& CountUsablePartyMons(battlerAtk) != 0)
|
||||
return SHOULD_PIVOT;
|
||||
|
||||
battlerToSwitch = gAiLogicData->mostSuitableMonId[battlerAtk];
|
||||
// This shouldn't ever happen, but it's there to make sure we don't accidentally read past the gParty array.
|
||||
if (battlerToSwitch >= PARTY_SIZE)
|
||||
battlerToSwitch = 0;
|
||||
if (PartyBattlerShouldAvoidHazards(battlerAtk, battlerToSwitch))
|
||||
return DONT_PIVOT;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user