Fix some ai action check happening before the logic was computed (#7867)

Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
FosterProgramming 2025-10-07 23:05:29 +02:00 committed by GitHub
parent f5e3464e83
commit d6efe24bbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -319,7 +319,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler)
gAiBattleData->chosenTarget[battler] = gBattlerTarget;
}
bool32 BattlerChoseNonMoveAction(void)
bool32 BattlerChooseNonMoveAction(void)
{
if (gAiThinkingStruct->aiAction & AI_ACTION_FLEE)
{
@ -361,10 +361,6 @@ void ComputeBattlerDecisions(u32 battler)
bool32 isAiBattler = (gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) && (BattlerHasAi(battler) && !(gBattleTypeFlags & BATTLE_TYPE_PALACE));
if (isAiBattler || CanAiPredictMove())
{
// If ai is about to flee or chosen to watch player, no need to calc anything
if (isAiBattler && BattlerChoseNonMoveAction())
return;
// Risky AI switches aggressively even mid battle
enum SwitchType switchType = (gAiThinkingStruct->aiFlags[battler] & AI_FLAG_RISKY) ? SWITCH_AFTER_KO : SWITCH_MID_BATTLE;
@ -385,6 +381,8 @@ void ComputeBattlerDecisions(u32 battler)
// AI's move scoring
gAiBattleData->chosenMoveIndex[battler] = BattleAI_ChooseMoveIndex(battler); // Calculate score and chose move index
if (isAiBattler)
BattlerChooseNonMoveAction();
ModifySwitchAfterMoveScoring(battler);
gAiLogicData->aiCalcInProgress = FALSE;