From 19fff811604c41d637d9a3dd482fd8aa5534d345 Mon Sep 17 00:00:00 2001 From: AlexOn1ine Date: Wed, 17 Jul 2024 22:13:09 +0200 Subject: [PATCH] Fixes AI not being aware during calcs --- src/battle_ai_main.c | 8 ++++++++ src/battle_ai_util.c | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index d9055162341b..789237264e83 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -461,12 +461,20 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData) aiData->weatherHasEffect = WEATHER_HAS_EFFECT; // get/assume all battler data and simulate AI damage battlersCount = gBattlersCount; + for (battlerAtk = 0; battlerAtk < battlersCount; battlerAtk++) { if (!IsBattlerAlive(battlerAtk)) continue; SetBattlerAiData(battlerAtk, aiData); + } + + for (battlerAtk = 0; battlerAtk < battlersCount; battlerAtk++) + { + if (!IsBattlerAlive(battlerAtk)) + continue; + SetBattlerAiMovesData(aiData, battlerAtk, battlersCount); } } diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index b57d474bb8ed..b9770ba95091 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -378,10 +378,8 @@ bool32 IsDamageMoveUnusable(u32 move, u32 battlerAtk, u32 battlerDef) else battlerDefAbility = aiData->abilities[battlerDef]; - // Battler doesn't see partners Ability for some reason. - // This is a small hack to avoid the issue but should be investigated if (battlerDef == BATTLE_PARTNER(battlerAtk)) - battlerDefAbility = GetBattlerAbility(battlerDef); + battlerDefAbility = aiData->abilities[battlerDef]; switch (battlerDefAbility) {