From 28506b4cf85fec2507dd911cea9455959ac1a409 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Sat, 7 Oct 2023 19:31:25 +0200 Subject: [PATCH] Use move flags instead of lists for AI calcs (#3389) --- include/battle_ai_util.h | 2 -- src/battle_ai_main.c | 3 +- src/battle_ai_util.c | 65 +--------------------------------------- 3 files changed, 2 insertions(+), 68 deletions(-) diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index 6a51963ae3..37e9c509da 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -112,8 +112,6 @@ bool32 IsStatLoweringMoveEffect(u32 moveEffect); bool32 IsMoveRedirectionPrevented(u32 move, u32 atkAbility); bool32 IsMoveEncouragedToHit(u32 battlerAtk, u32 battlerDef, u32 move); bool32 IsHazardMoveEffect(u32 moveEffect); -bool32 MoveCallsOtherMove(u32 move); -bool32 MoveRequiresRecharging(u32 move); bool32 IsEncoreEncouragedEffect(u32 moveEffect); void ProtectChecks(u32 battlerAtk, u32 battlerDef, u32 move, u32 predictedMove, s32 *score); bool32 ShouldSetSandstorm(u32 battler, u32 ability, u32 holdEffect); diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 9ff37fd45d..14562ba3cb 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2534,8 +2534,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) if (instructedMove == MOVE_NONE || gBattleMoves[instructedMove].instructBanned - || MoveRequiresRecharging(instructedMove) - || MoveCallsOtherMove(instructedMove) + || gBattleMoves[instructedMove].effect == EFFECT_RECHARGE || IsZMove(instructedMove) || (gLockedMoves[battlerDef] != 0 && gLockedMoves[battlerDef] != 0xFFFF) || gBattleMons[battlerDef].status2 & STATUS2_MULTIPLETURNS diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index b6d3d4f363..cbda89d66e 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -383,41 +383,6 @@ static const u16 sIgnoredPowerfulMoveEffects[] = IGNORED_MOVES_END }; -static const u16 sIgnoreMoldBreakerMoves[] = -{ - MOVE_MOONGEIST_BEAM, - MOVE_SUNSTEEL_STRIKE, - MOVE_PHOTON_GEYSER, - MOVE_LIGHT_THAT_BURNS_THE_SKY, - MOVE_MENACING_MOONRAZE_MAELSTROM, - MOVE_SEARING_SUNRAZE_SMASH, -}; - -static const u16 sRechargeMoves[] = -{ - MOVE_HYPER_BEAM, - MOVE_BLAST_BURN, - MOVE_HYDRO_CANNON, - MOVE_FRENZY_PLANT, - MOVE_GIGA_IMPACT, - MOVE_ROCK_WRECKER, - MOVE_ROAR_OF_TIME, - MOVE_PRISMATIC_LASER, - MOVE_METEOR_ASSAULT, - MOVE_ETERNABEAM, -}; - -static const u16 sOtherMoveCallingMoves[] = -{ - MOVE_ASSIST, - MOVE_COPYCAT, - MOVE_ME_FIRST, - MOVE_METRONOME, - MOVE_MIRROR_MOVE, - MOVE_NATURE_POWER, - MOVE_SLEEP_TALK, -}; - // Functions u32 GetAIChosenMove(u32 battlerId) { @@ -1505,13 +1470,7 @@ bool32 DoesBattlerIgnoreAbilityChecks(u32 atkAbility, u32 move) if (AI_THINKING_STRUCT->aiFlags & AI_FLAG_NEGATE_UNAWARE) return FALSE; // AI handicap flag: doesn't understand ability suppression concept - for (i = 0; i < ARRAY_COUNT(sIgnoreMoldBreakerMoves); i++) - { - if (move == sIgnoreMoldBreakerMoves[i]) - return TRUE; - } - - if (IsMoldBreakerTypeAbility(atkAbility)) + if (IsMoldBreakerTypeAbility(atkAbility) || gBattleMoves[move].ignoresTargetAbility) return TRUE; return FALSE; @@ -2453,28 +2412,6 @@ bool32 IsEncoreEncouragedEffect(u32 moveEffect) return FALSE; } -bool32 MoveRequiresRecharging(u32 move) -{ - u32 i; - for (i = 0; i < ARRAY_COUNT(sRechargeMoves); i++) - { - if (move == sRechargeMoves[i]) - return TRUE; - } - return FALSE; -} - -bool32 MoveCallsOtherMove(u32 move) -{ - u32 i; - for (i = 0; i < ARRAY_COUNT(sOtherMoveCallingMoves); i++) - { - if (move == sOtherMoveCallingMoves[i]) - return TRUE; - } - return FALSE; -} - static u32 GetLeechSeedDamage(u32 battlerId) { u32 damage = 0;