diff --git a/include/config/ai.h b/include/config/ai.h index 987e1fff5e..91ee3525ae 100644 --- a/include/config/ai.h +++ b/include/config/ai.h @@ -55,6 +55,7 @@ // AI move scoring #define STATUS_MOVE_FOCUS_PUNCH_CHANCE 50 // Chance the AI will use a status move if the player's best move is Focus Punch +#define BOOST_INTO_HAZE_CHANCE 0 // Chance the AI will use a stat boosting move if the player has used Haze // AI damage calc considerations #define RISKY_AI_CRIT_STAGE_THRESHOLD 2 // Stat stages at which Risky will assume it gets a crit diff --git a/include/random.h b/include/random.h index dc3c73cc3a..f23ff2f184 100644 --- a/include/random.h +++ b/include/random.h @@ -199,6 +199,7 @@ enum RandomTag RNG_AI_PREDICT_SWITCH, RNG_AI_PREDICT_MOVE, RNG_AI_STATUS_FOCUS_PUNCH, + RNG_AI_BOOST_INTO_HAZE, RNG_HEALER, RNG_DEXNAV_ENCOUNTER_LEVEL, }; diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index a8b34da119..d84a7b6343 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -4124,9 +4124,10 @@ static enum AIScore IncreaseStatUpScoreInternal(u32 battlerAtk, u32 battlerDef, return NO_INCREASE; // Don't increase stats if opposing battler has used Haze effect - if (HasBattlerSideUsedMoveWithEffect(battlerDef, EFFECT_HAZE) + if (!RandomPercentage(RNG_AI_BOOST_INTO_HAZE, BOOST_INTO_HAZE_CHANCE) && + (HasBattlerSideUsedMoveWithEffect(battlerDef, EFFECT_HAZE) || HasBattlerSideUsedMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_CLEAR_SMOG) - || HasBattlerSideUsedMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_HAZE)) + || HasBattlerSideUsedMoveWithAdditionalEffect(battlerDef, MOVE_EFFECT_HAZE))) return NO_INCREASE; // Don't increase if AI is at +1 and opponent has Haze effect diff --git a/test/battle/ai/ai.c b/test/battle/ai/ai.c index 0c5d8793c8..fcef7ac4f7 100644 --- a/test/battle/ai/ai.c +++ b/test/battle/ai/ai.c @@ -865,3 +865,18 @@ AI_SINGLE_BATTLE_TEST("AI will not set up Weather if it wont have any affect") TURN { MOVE(player, MOVE_SCRATCH); EXPECT_MOVE(opponent, MOVE_RAIN_DANCE); } } } + +AI_SINGLE_BATTLE_TEST("AI won't use stat boosting moves if the player has used Haze") +{ + PASSES_RANDOMLY(BOOST_INTO_HAZE_CHANCE, 100, RNG_AI_BOOST_INTO_HAZE); + GIVEN { + ASSUME(GetMoveEffect(MOVE_HAZE) == EFFECT_HAZE); + ASSUME(GetMoveEffect(MOVE_DRAGON_DANCE) == EFFECT_DRAGON_DANCE); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { Moves(MOVE_SCRATCH, MOVE_HAZE); } + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_SCRATCH, MOVE_DRAGON_DANCE); } + } WHEN { + TURN { MOVE(player, MOVE_HAZE); EXPECT_MOVE(opponent, MOVE_DRAGON_DANCE); } + TURN { MOVE(player, MOVE_HAZE); EXPECT_MOVE(opponent, MOVE_DRAGON_DANCE); } + } +}