Fix AI boosting stats into mon with Haze (#6894)

This commit is contained in:
Pawkkie 2025-05-22 15:05:02 -04:00 committed by GitHub
parent 9554146738
commit 0530f49fd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2192,6 +2192,31 @@ bool32 HasMoveWithEffect(u32 battlerId, enum BattleMoveEffects effect)
return FALSE;
}
bool32 HasBattlerSideMoveWithEffect(u32 battler, u32 effect)
{
if (HasMoveWithEffect(battler, effect))
return TRUE;
if (IsDoubleBattle() && HasMoveWithEffect(BATTLE_OPPOSITE(battler), effect))
return TRUE;
return FALSE;
}
// HasSideMoveWithMoveEffect checks if the AI knows a side has a move effect,
// while HasBattlerSideUsedMoveWithEffect checks if the side has ever used a move effect.
// The former acts the same way as the latter if AI_FLAG_OMNISCIENT isn't used.
bool32 HasBattlerSideUsedMoveWithEffect(u32 battler, u32 effect)
{
u32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (GetMoveEffect(gBattleHistory->usedMoves[battler][i]) == effect)
return TRUE;
if (IsDoubleBattle() && GetMoveEffect(gBattleHistory->usedMoves[BATTLE_OPPOSITE(battler)][i]) == effect)
return TRUE;
}
return FALSE;
}
bool32 HasNonVolatileMoveEffect(u32 battlerId, u32 effect)
{
s32 i;
@ -2237,6 +2262,31 @@ bool32 HasMoveWithAdditionalEffect(u32 battlerId, u32 moveEffect)
return FALSE;
}
bool32 HasBattlerSideMoveWithAdditionalEffect(u32 battler, u32 moveEffect)
{
if (HasMoveWithAdditionalEffect(battler, moveEffect))
return TRUE;
if (IsDoubleBattle() && HasMoveWithAdditionalEffect(BATTLE_OPPOSITE(battler), moveEffect))
return TRUE;
return FALSE;
}
// HasBattlerSideMoveWithAdditionalEffect checks if the AI knows a side has a move effect,
// while HasBattlerSideUsedMoveWithAdditionalEffect checks if the side has ever used a move effect.
// The former acts the same way as the latter if AI_FLAG_OMNISCIENT isn't used.
bool32 HasBattlerSideUsedMoveWithAdditionalEffect(u32 battler, u32 moveEffect)
{
u32 i;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (MoveHasAdditionalEffect(gBattleHistory->usedMoves[battler][i], moveEffect))
return TRUE;
if (IsDoubleBattle() && MoveHasAdditionalEffect(gBattleHistory->usedMoves[BATTLE_OPPOSITE(battler)][i], moveEffect))
return TRUE;
}
return FALSE;
}
bool32 HasMoveWithCriticalHitChance(u32 battlerId)
{
s32 i;
@ -4071,10 +4121,19 @@ static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef,
return NO_INCREASE;
// Don't increase stats if opposing battler has Encore
if (HasMoveWithEffect(battlerDef, EFFECT_ENCORE))
if (HasBattlerSideMoveWithEffect(battlerDef, EFFECT_ENCORE))
return NO_INCREASE;
if (IsDoubleBattle() && HasMoveWithEffect(GetPartnerBattler(battlerDef), EFFECT_ENCORE))
// Don't increase stats if opposing battler has used Haze effect
if (HasBattlerSideUsedMoveWithEffect(battlerDef, EFFECT_HAZE)
|| HasBattlerSideUsedMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_CLEAR_SMOG)
|| HasBattlerSideUsedMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_HAZE))
return NO_INCREASE;
// Don't increase if AI is at +1 and opponent has Haze effect
if (gBattleMons[battlerAtk].statStages[statId] >= MAX_STAT_STAGE - 5 && (HasBattlerSideMoveWithEffect(battlerDef, EFFECT_HAZE)
|| HasBattlerSideMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_CLEAR_SMOG)
|| HasBattlerSideMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_HAZE)))
return NO_INCREASE;
// Predicting switch