Skip to content

Commit

Permalink
Fixes AI not being aware during calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine committed Jul 17, 2024
1 parent cfcac0b commit 19fff81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 19fff81

Please sign in to comment.