From 64ba52d2142051146af38df73c4c14c205641879 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:41:22 +0100 Subject: [PATCH] Remove redundant AI score increases (#3504) * Remove redundant AI score increases * review applied * fix score --- data/battle_scripts_1.s | 2 +- include/battle_ai_util.h | 1 - include/constants/battle_move_effects.h | 2 +- src/battle_ai_main.c | 124 ++------------------ src/battle_ai_util.c | 1 - src/battle_script_commands.c | 2 +- src/battle_tv.c | 2 +- src/battle_util.c | 2 +- src/data/battle_moves.h | 70 ++++++------ test/battle/ai_check_viability.c | 145 ++++++++++++++++++++++++ 10 files changed, 195 insertions(+), 156 deletions(-) create mode 100644 test/battle/ai_check_viability.c diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f4c614aa7cf1..f87ae01b0e31 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -188,7 +188,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectMemento @ EFFECT_MEMENTO .4byte BattleScript_EffectHit @ EFFECT_FACADE .4byte BattleScript_EffectFocusPunch @ EFFECT_FOCUS_PUNCH - .4byte BattleScript_EffectSmellingsalt @ EFFECT_SMELLINGSALT + .4byte BattleScript_EffectSmellingsalt @ EFFECT_SMELLING_SALTS .4byte BattleScript_EffectFollowMe @ EFFECT_FOLLOW_ME .4byte BattleScript_EffectNaturePower @ EFFECT_NATURE_POWER .4byte BattleScript_EffectCharge @ EFFECT_CHARGE diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index 76362a2c7a9b..3d37a185c730 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -128,7 +128,6 @@ bool32 ShouldFakeOut(u32 battlerAtk, u32 battlerDef, u32 move); bool32 HasThawingMove(u32 battler); bool32 IsStatRaisingEffect(u32 effect); bool32 IsStatLoweringEffect(u32 effect); -bool32 IsStatRaisingEffect(u32 effect); bool32 IsAttackBoostMoveEffect(u32 effect); bool32 IsUngroundingEffect(u32 effect); bool32 IsSemiInvulnerable(u32 battlerDef, u32 move); diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 91b74feee7a9..aa378ac15da8 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -167,7 +167,7 @@ #define EFFECT_MEMENTO 163 #define EFFECT_FACADE 164 #define EFFECT_FOCUS_PUNCH 165 -#define EFFECT_SMELLINGSALT 166 +#define EFFECT_SMELLING_SALTS 166 #define EFFECT_FOLLOW_ME 167 #define EFFECT_NATURE_POWER 168 #define EFFECT_CHARGE 169 diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 2e99def5e78a..8339195ea728 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1684,10 +1684,6 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) if (gDisableStructs[battlerAtk].stockpileCounter >= 3) ADJUST_SCORE(-10); break; - case EFFECT_SPIT_UP: - if (gDisableStructs[battlerAtk].stockpileCounter <= 1) - ADJUST_SCORE(-10); - break; case EFFECT_SWALLOW: if (gDisableStructs[battlerAtk].stockpileCounter == 0) { @@ -3295,63 +3291,16 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score // check thawing moves if ((gBattleMons[battlerAtk].status1 & (STATUS1_FREEZE | STATUS1_FROSTBITE)) && gBattleMoves[move].thawsUser) - score += (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) ? 20 : 10; - - // check burn - if (gBattleMons[battlerAtk].status1 & STATUS1_BURN) - { - switch (aiData->abilities[battlerAtk]) - { - case ABILITY_GUTS: - break; - case ABILITY_NATURAL_CURE: - if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING - && HasOnlyMovesWithSplit(battlerAtk, SPLIT_PHYSICAL, TRUE)) - score = 90; // Force switch if all your attacking moves are physical and you have Natural Cure. - break; - default: - if (IS_MOVE_PHYSICAL(move) && gBattleMoves[move].effect != EFFECT_FACADE) - ADJUST_SCORE(-2); - break; - } - } + ADJUST_SCORE(10); - // check frostbite - if (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE) + // check burn / frostbite + if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING && AI_DATA->abilities[battlerAtk] == ABILITY_NATURAL_CURE) { - switch (aiData->abilities[battlerAtk]) - { - case ABILITY_GUTS: - break; - case ABILITY_NATURAL_CURE: - if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_SMART_SWITCHING - && HasOnlyMovesWithSplit(battlerAtk, SPLIT_SPECIAL, TRUE)) - score = 90; // Force switch if all your attacking moves are special and you have Natural Cure. - break; - default: - if (IS_MOVE_SPECIAL(move) && gBattleMoves[move].effect != EFFECT_FACADE) - ADJUST_SCORE(-2); - break; - } + if ((gBattleMons[battlerAtk].status1 & STATUS1_BURN && HasOnlyMovesWithSplit(battlerAtk, SPLIT_PHYSICAL, TRUE)) + || (gBattleMons[battlerAtk].status1 & STATUS1_FROSTBITE && HasOnlyMovesWithSplit(battlerAtk, SPLIT_SPECIAL, TRUE))) + ADJUST_SCORE(-20); // Force switch if all your attacking moves are physical and you have Natural Cure. } - // attacker ability checks - switch (aiData->abilities[battlerAtk]) - { - case ABILITY_MOXIE: - case ABILITY_BEAST_BOOST: - case ABILITY_CHILLING_NEIGH: - case ABILITY_GRIM_NEIGH: - case ABILITY_AS_ONE_ICE_RIDER: - case ABILITY_AS_ONE_SHADOW_RIDER: - if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // Attacker should go first - { - if (CanIndexMoveFaintTarget(battlerAtk, battlerDef, movesetIndex, 0)) - ADJUST_SCORE(8); // prioritize killing target for stat boost - } - break; - } // ability checks - // move effect checks switch (moveEffect) { @@ -3363,11 +3312,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score IncreaseSleepScore(battlerAtk, battlerDef, move, &score); break; case EFFECT_ABSORB: - if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_BIG_ROOT) - ADJUST_SCORE(1); - if (effectiveness <= AI_EFFECTIVENESS_x0_5 && AI_RandLessThan(50)) - ADJUST_SCORE(-3); - break; + if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_BIG_ROOT && effectiveness >= AI_EFFECTIVENESS_x1) + ADJUST_SCORE(2); case EFFECT_EXPLOSION: case EFFECT_MEMENTO: if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_WILL_SUICIDE && gBattleMons[battlerDef].statStages[STAT_EVASION] < 7) @@ -3581,11 +3527,6 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score if (aiData->hpPercents[battlerAtk] < 90) ADJUST_SCORE(-2); break; - case EFFECT_DREAM_EATER: - if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP)) - break; - ADJUST_SCORE(1); // if target is asleep, dream eater is a pretty good move even without draining - // fallthrough case EFFECT_ACUPRESSURE: break; case EFFECT_ATTACK_ACCURACY_UP: // hone claws @@ -3734,20 +3675,12 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score || HasHighCritRatioMove(battlerAtk)) ADJUST_SCORE(2); break; - case EFFECT_CONFUSE_HIT: - if (sereneGraceBoost) - ADJUST_SCORE(1); - //fallthrough case EFFECT_CONFUSE: IncreaseConfusionScore(battlerAtk, battlerDef, move, &score); break; case EFFECT_PARALYZE: IncreaseParalyzeScore(battlerAtk, battlerDef, move, &score); break; - case EFFECT_GRAV_APPLE: - if (gFieldStatuses & STATUS_FIELD_GRAVITY) - ADJUST_SCORE(2); - // fall through case EFFECT_ATTACK_DOWN_HIT: case EFFECT_DEFENSE_DOWN_HIT: case EFFECT_SPECIAL_ATTACK_DOWN_HIT: @@ -4243,14 +4176,6 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score IncreaseStatUpScore(battlerAtk, battlerDef, STAT_DEF, &score); IncreaseStatUpScore(battlerAtk, battlerDef, STAT_SPDEF, &score); break; - case EFFECT_SPIT_UP: - if (gDisableStructs[battlerAtk].stockpileCounter >= 2) - ADJUST_SCORE(1); - break; - case EFFECT_ROLLOUT: - if (gBattleMons[battlerAtk].status2 & STATUS2_DEFENSE_CURL) - ADJUST_SCORE(8); - break; case EFFECT_SWAGGER: if (HasMoveEffect(battlerAtk, EFFECT_FOUL_PLAY) || HasMoveEffect(battlerAtk, EFFECT_PSYCH_UP) @@ -4745,11 +4670,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score ADJUST_SCORE(2); break; case EFFECT_PLEDGE: - if (isDoubleBattle) - { - if (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE)) - ADJUST_SCORE(3); // Partner might use pledge move - } + if (isDoubleBattle && HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE)) + ADJUST_SCORE(3); // Partner might use pledge move break; case EFFECT_TRICK_ROOM: if (!(gFieldStatuses & STATUS_FIELD_TRICK_ROOM) && GetBattlerSideSpeedAverage(battlerAtk) < GetBattlerSideSpeedAverage(battlerDef)) @@ -4952,15 +4874,6 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score ADJUST_SCORE(3); } break; - case EFFECT_FLAIL: - if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_FASTER) // Ai goes first - { - if (aiData->hpPercents[battlerAtk] < 20) - ADJUST_SCORE(1); - else if (aiData->hpPercents[battlerAtk] < 8) - ADJUST_SCORE(2); - } - break; case EFFECT_SHORE_UP: if ((AI_GetWeather(aiData) & B_WEATHER_SANDSTORM) && ShouldRecover(battlerAtk, battlerDef, move, 67)) @@ -4968,10 +4881,6 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score else if (ShouldRecover(battlerAtk, battlerDef, move, 50)) ADJUST_SCORE(2); break; - case EFFECT_FACADE: - if (gBattleMons[battlerAtk].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON | STATUS1_FROSTBITE)) - ADJUST_SCORE(1); - break; case EFFECT_FOCUS_PUNCH: if (!isDoubleBattle && effectiveness > AI_EFFECTIVENESS_x0_5) { @@ -4981,19 +4890,6 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score ADJUST_SCORE(1); } break; - case EFFECT_SMELLINGSALT: - if (gBattleMons[battlerDef].status1 & STATUS1_PARALYSIS) - ADJUST_SCORE(2); - break; - case EFFECT_WAKE_UP_SLAP: - if (gBattleMons[battlerDef].status1 & STATUS1_SLEEP) - ADJUST_SCORE(2); - break; - case EFFECT_REVENGE: - if (!(gBattleMons[battlerDef].status1 & STATUS1_SLEEP) - && !(gBattleMons[battlerDef].status2 & (STATUS2_INFATUATION | STATUS2_CONFUSION))) - ADJUST_SCORE(2); - break; case EFFECT_ENDEAVOR: if (AI_WhoStrikesFirst(battlerAtk, battlerDef, move) == AI_IS_SLOWER) // Opponent faster { diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index c4d543dfe092..dd06a69eaf00 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -373,7 +373,6 @@ static const u16 sIgnoredPowerfulMoveEffects[] = EFFECT_RECHARGE, EFFECT_SKULL_BASH, EFFECT_SOLAR_BEAM, - EFFECT_SPIT_UP, EFFECT_FOCUS_PUNCH, EFFECT_SUPERPOWER, EFFECT_ERUPTION, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a0bd9faf2aca..34b861a6d48b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -979,7 +979,7 @@ static const u16 sFinalStrikeOnlyEffects[] = EFFECT_SECRET_POWER, EFFECT_SMACK_DOWN, EFFECT_SPARKLING_ARIA, - EFFECT_SMELLINGSALT, + EFFECT_SMELLING_SALTS, EFFECT_WAKE_UP_SLAP, EFFECT_HIT_ESCAPE, EFFECT_RECOIL_HP_25, diff --git a/src/battle_tv.c b/src/battle_tv.c index 361b6fa2b9e3..af485df70d27 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -253,7 +253,7 @@ static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_MEMENTO] = 7, [EFFECT_FACADE] = 1, [EFFECT_FOCUS_PUNCH] = 7, - [EFFECT_SMELLINGSALT] = 1, + [EFFECT_SMELLING_SALTS] = 1, [EFFECT_FOLLOW_ME] = 5, [EFFECT_NATURE_POWER] = 0, [EFFECT_CHARGE] = 4, diff --git a/src/battle_util.c b/src/battle_util.c index 7974ff8effb7..91e6e69b5778 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8555,7 +8555,7 @@ static inline u32 CalcMoveBasePower(u32 move, u32 battlerAtk, u32 battlerDef, u3 if (gBattleMons[battlerDef].status1 & STATUS1_SLEEP || abilityDef == ABILITY_COMATOSE) basePower *= 2; break; - case EFFECT_SMELLINGSALT: + case EFFECT_SMELLING_SALTS: if (gBattleMons[battlerDef].status1 & STATUS1_PARALYSIS) basePower *= 2; break; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 0ad7cc07196d..543c21e1d590 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -4748,7 +4748,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = #else .power = 60, #endif - .effect = EFFECT_SMELLINGSALT, + .effect = EFFECT_SMELLING_SALTS, .type = TYPE_NORMAL, .accuracy = 100, .pp = 10, @@ -15142,7 +15142,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_RAISE_TEAM_DEFENSE, }, - + [MOVE_G_MAX_VINE_LASH] = { //ANIM TODO .effect = EFFECT_MAX_MOVE, @@ -15156,7 +15156,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_VINE_LASH, }, - + [MOVE_G_MAX_WILDFIRE] = { .effect = EFFECT_MAX_MOVE, @@ -15170,7 +15170,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_WILDFIRE, }, - + [MOVE_G_MAX_CANNONADE] = { //ANIM TODO .effect = EFFECT_MAX_MOVE, @@ -15184,7 +15184,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_CANNONADE, }, - + [MOVE_G_MAX_BEFUDDLE] = { .effect = EFFECT_MAX_MOVE, @@ -15198,7 +15198,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_EFFECT_SPORE_FOES, }, - + [MOVE_G_MAX_VOLT_CRASH] = { .effect = EFFECT_MAX_MOVE, @@ -15212,7 +15212,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_PARALYZE_FOES, }, - + [MOVE_G_MAX_GOLD_RUSH] = { .effect = EFFECT_MAX_MOVE, @@ -15226,7 +15226,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_CONFUSE_FOES_PAY_DAY, }, - + [MOVE_G_MAX_CHI_STRIKE] = { .effect = EFFECT_MAX_MOVE, @@ -15240,7 +15240,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_CRIT_PLUS, }, - + [MOVE_G_MAX_TERROR] = { .effect = EFFECT_MAX_MOVE, @@ -15254,7 +15254,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_MEAN_LOOK, }, - + [MOVE_G_MAX_FOAM_BURST] = { .effect = EFFECT_MAX_MOVE, @@ -15268,7 +15268,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_LOWER_SPEED_2_FOES, }, - + [MOVE_G_MAX_RESONANCE] = { .effect = EFFECT_MAX_MOVE, @@ -15282,7 +15282,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_AURORA_VEIL, }, - + [MOVE_G_MAX_CUDDLE] = { .effect = EFFECT_MAX_MOVE, @@ -15296,7 +15296,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_INFATUATE_FOES, }, - + [MOVE_G_MAX_REPLENISH] = { .effect = EFFECT_MAX_MOVE, @@ -15310,7 +15310,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_RECYCLE_BERRIES, }, - + [MOVE_G_MAX_MALODOR] = { .effect = EFFECT_MAX_MOVE, @@ -15324,7 +15324,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_POISON_FOES, }, - + [MOVE_G_MAX_MELTDOWN] = { .effect = EFFECT_MAX_MOVE, @@ -15338,7 +15338,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_TORMENT_FOES, }, - + [MOVE_G_MAX_DRUM_SOLO] = { //ANIM TODO .effect = EFFECT_MAX_MOVE, @@ -15353,7 +15353,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .argument = MAX_EFFECT_FIXED_POWER, //EFFECT TODO .ignoresTargetAbility = TRUE, }, - + [MOVE_G_MAX_FIREBALL] = { //ANIM TODO .effect = EFFECT_MAX_MOVE, @@ -15368,7 +15368,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .argument = MAX_EFFECT_FIXED_POWER, //EFFECT TODO .ignoresTargetAbility = TRUE, }, - + [MOVE_G_MAX_HYDROSNIPE] = { //ANIM TODO .effect = EFFECT_MAX_MOVE, @@ -15383,7 +15383,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .argument = MAX_EFFECT_FIXED_POWER, //EFFECT TODO .ignoresTargetAbility = TRUE, }, - + [MOVE_G_MAX_WIND_RAGE] = { .effect = EFFECT_MAX_MOVE, @@ -15397,7 +15397,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_DEFOG, }, - + [MOVE_G_MAX_GRAVITAS] = { .effect = EFFECT_MAX_MOVE, @@ -15411,7 +15411,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_GRAVITY, }, - + [MOVE_G_MAX_STONESURGE] = { .effect = EFFECT_MAX_MOVE, @@ -15425,7 +15425,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_STEALTH_ROCK, }, - + [MOVE_G_MAX_VOLCALITH] = { .effect = EFFECT_MAX_MOVE, @@ -15439,7 +15439,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_VOLCALITH, }, - + [MOVE_G_MAX_TARTNESS] = { .effect = EFFECT_MAX_MOVE, @@ -15453,7 +15453,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_LOWER_EVASIVENESS_FOES, }, - + [MOVE_G_MAX_SWEETNESS] = { .effect = EFFECT_MAX_MOVE, @@ -15467,7 +15467,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_AROMATHERAPY, }, - + [MOVE_G_MAX_SANDBLAST] = { .effect = EFFECT_MAX_MOVE, @@ -15481,7 +15481,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_SANDBLAST_FOES, }, - + [MOVE_G_MAX_STUN_SHOCK] = { .effect = EFFECT_MAX_MOVE, @@ -15495,7 +15495,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_POISON_PARALYZE_FOES, }, - + [MOVE_G_MAX_CENTIFERNO] = { .effect = EFFECT_MAX_MOVE, @@ -15509,7 +15509,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_FIRE_SPIN_FOES, }, - + [MOVE_G_MAX_SMITE] = { .effect = EFFECT_MAX_MOVE, @@ -15523,7 +15523,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_CONFUSE_FOES, }, - + [MOVE_G_MAX_SNOOZE] = { @@ -15538,7 +15538,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_YAWN_FOE, }, - + [MOVE_G_MAX_FINALE] = { .effect = EFFECT_MAX_MOVE, @@ -15552,7 +15552,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_HEAL_TEAM, }, - + [MOVE_G_MAX_STEELSURGE] = { .effect = EFFECT_MAX_MOVE, @@ -15566,7 +15566,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_STEELSURGE, }, - + [MOVE_G_MAX_DEPLETION] = { .effect = EFFECT_MAX_MOVE, @@ -15580,7 +15580,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_SPITE, }, - + [MOVE_G_MAX_ONE_BLOW] = { .effect = EFFECT_MAX_MOVE, @@ -15594,7 +15594,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_BYPASS_PROTECT, //EFFECT TODO }, - + [MOVE_G_MAX_RAPID_FLOW] = { //ANIM TODO .effect = EFFECT_MAX_MOVE, @@ -15608,5 +15608,5 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_DYNAMAX] = .split = SPLIT_PHYSICAL, .argument = MAX_EFFECT_BYPASS_PROTECT, //EFFECT TODO }, - + }; diff --git a/test/battle/ai_check_viability.c b/test/battle/ai_check_viability.c new file mode 100644 index 000000000000..11052fb163d8 --- /dev/null +++ b/test/battle/ai_check_viability.c @@ -0,0 +1,145 @@ +#include "global.h" +#include "test/battle.h" +#include "battle_ai_util.h" + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_BODY_SLAM].effect == EFFECT_PARALYZE_HIT); +} + +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Facade") +{ + u16 status1, expectedMove; + + PARAMETRIZE { status1 = STATUS1_NONE; expectedMove = MOVE_BODY_SLAM; } + PARAMETRIZE { status1 = STATUS1_BURN; expectedMove = MOVE_FACADE; } + + GIVEN { + ASSUME(gBattleMoves[MOVE_FACADE].effect == EFFECT_FACADE); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { HP(60); } + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_BODY_SLAM, MOVE_FACADE); Status1(status1); } + } WHEN { + TURN { EXPECT_MOVE(opponent, expectedMove); } + } SCENE { + if (expectedMove == MOVE_FACADE) + MESSAGE("Wobbuffet fainted!"); + } +} + +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Smelling Salt") +{ + u16 status1, expectedMove; + + PARAMETRIZE { status1 = STATUS1_NONE; expectedMove = MOVE_BODY_SLAM; } + PARAMETRIZE { status1 = STATUS1_PARALYSIS; expectedMove = MOVE_SMELLING_SALTS; } + + GIVEN { + ASSUME(B_UPDATED_MOVE_DATA >= GEN_6); + ASSUME(gBattleMoves[MOVE_SMELLING_SALTS].effect == EFFECT_SMELLING_SALTS); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { HP(60); Status1(status1); } + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_BODY_SLAM, MOVE_SMELLING_SALTS); } + } WHEN { + TURN { EXPECT_MOVE(opponent, expectedMove); } + } SCENE { + if (expectedMove == MOVE_SMELLING_SALTS) + MESSAGE("Wobbuffet fainted!"); + } +} + +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Wake Up Slap") +{ + u16 status1, expectedMove; + + PARAMETRIZE { status1 = STATUS1_NONE; expectedMove = MOVE_BODY_SLAM; } + PARAMETRIZE { status1 = STATUS1_SLEEP; expectedMove = MOVE_WAKE_UP_SLAP; } + + GIVEN { + ASSUME(B_UPDATED_MOVE_DATA >= GEN_6); + ASSUME(gBattleMoves[MOVE_WAKE_UP_SLAP].effect == EFFECT_WAKE_UP_SLAP); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_MEGANIUM) { HP(35); Status1(status1); } + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_BODY_SLAM, MOVE_WAKE_UP_SLAP); } + } WHEN { + TURN { EXPECT_MOVE(opponent, expectedMove); } + } SCENE { + if (expectedMove == MOVE_WAKE_UP_SLAP) + MESSAGE("Meganium fainted!"); + } +} + +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Grav Apple") +{ + u32 movePlayer; + u16 expectedMove; + + PARAMETRIZE { movePlayer = MOVE_CELEBRATE; expectedMove = MOVE_TROP_KICK; } + PARAMETRIZE { movePlayer = MOVE_GRAVITY; expectedMove = MOVE_GRAV_APPLE; } + + GIVEN { + ASSUME(gBattleMoves[MOVE_GRAV_APPLE].effect == EFFECT_GRAV_APPLE); + ASSUME(gBattleMoves[MOVE_TROP_KICK].effect == EFFECT_ATTACK_DOWN_HIT); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { HP(81); Speed(20); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(10); Moves(MOVE_TROP_KICK, MOVE_GRAV_APPLE); } + } WHEN { + TURN { MOVE(player, movePlayer); EXPECT_MOVE(opponent, MOVE_TROP_KICK); } + TURN { MOVE(player, MOVE_CELEBRATE); EXPECT_MOVE(opponent, expectedMove); } + } SCENE { + if (expectedMove == MOVE_GRAV_APPLE) + MESSAGE("Wobbuffet fainted!"); + } +} + +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Flail") +{ + u16 hp, expectedMove; + + PARAMETRIZE { hp = 490; expectedMove = MOVE_BODY_SLAM; } + PARAMETRIZE { hp = 5; expectedMove = MOVE_FLAIL; } + + GIVEN { + ASSUME(gBattleMoves[MOVE_FLAIL].effect == EFFECT_FLAIL); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { Speed(10); } + OPPONENT(SPECIES_WOBBUFFET) { HP(hp); MaxHP(490); Speed(20); Moves(MOVE_BODY_SLAM, MOVE_FLAIL); } + } WHEN { + TURN { EXPECT_MOVE(opponent, expectedMove); } + } +} + +AI_SINGLE_BATTLE_TEST("AI will only use Dream Eater if target is asleep") +{ + u16 status1, expectedMove; + + PARAMETRIZE { status1 = STATUS1_NONE; expectedMove = MOVE_BODY_SLAM; } + PARAMETRIZE { status1 = STATUS1_SLEEP; expectedMove = MOVE_DREAM_EATER; } + + GIVEN { + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_MEGANIUM) { HP(38); Status1(status1); } + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_BODY_SLAM, MOVE_DREAM_EATER); } + } WHEN { + TURN { EXPECT_MOVE(opponent, expectedMove); } + } SCENE { + if (expectedMove == MOVE_DREAM_EATER) + MESSAGE("Meganium fainted!"); + } +} + +AI_SINGLE_BATTLE_TEST("AI sees increased base power of Spit Up") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_STOCKPILE].effect == EFFECT_STOCKPILE); + ASSUME(gBattleMoves[MOVE_SPIT_UP].effect == EFFECT_SPIT_UP); + AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT); + PLAYER(SPECIES_WOBBUFFET) { HP(43); } + OPPONENT(SPECIES_WOBBUFFET) { Moves(MOVE_STOCKPILE, MOVE_SPIT_UP, MOVE_TACKLE); } + } WHEN { + TURN { EXPECT_MOVE(opponent, MOVE_STOCKPILE); } + TURN { EXPECT_MOVE(opponent, MOVE_SPIT_UP); } + } SCENE { + // MESSAGE("Wobbuffet fainted!"); + } +}