Skip to content

Commit

Permalink
Flag check
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawkkie committed Jan 20, 2025
1 parent 0d84a25 commit aa56750
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ static u32 GetAiFlags(u16 trainerId)
if (flags & AI_FLAG_SMART_SWITCHING)
flags |= AI_FLAG_SMART_MON_CHOICES;

// Automatically includes AI_FLAG_PREDICT_SWITCH if AI_FLAG_PREDICT_INCOMING_MON is being used
if (flags & AI_FLAG_PREDICT_INCOMING_MON)
flags |= AI_FLAG_PREDICT_SWITCH;

if (sDynamicAiFunc != NULL)
flags |= AI_FLAG_DYNAMIC_FUNC;

Expand Down
10 changes: 5 additions & 5 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4205,11 +4205,6 @@ void SetupAISwitchingData(u32 battler, bool32 isAiRisky)
{
s32 opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(battler)));

// AI's data
AI_DATA->mostSuitableMonId[battler] = GetMostSuitableMonToSwitchInto(battler, isAiRisky);
if (ShouldSwitch(battler))
AI_DATA->shouldSwitch |= (1u << battler);

// AI's predicting data
if ((AI_THINKING_STRUCT->aiFlags[battler] & AI_FLAG_PREDICT_SWITCH))
{
Expand All @@ -4223,6 +4218,11 @@ void SetupAISwitchingData(u32 battler, bool32 isAiRisky)
// Determine whether AI will use predictions this turn
AI_DATA->predictingSwitch = RandomPercentage(RNG_AI_PREDICT_SWITCH, 50);
}

// AI's data
AI_DATA->mostSuitableMonId[battler] = GetMostSuitableMonToSwitchInto(battler, isAiRisky);
if (ShouldSwitch(battler))
AI_DATA->shouldSwitch |= (1u << battler);
}

static void HandleTurnActionSelectionState(void)
Expand Down

0 comments on commit aa56750

Please sign in to comment.