Skip to content

Commit

Permalink
Remove global sBattler_AI (#6128)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Jan 29, 2025
1 parent 94c98e6 commit 32eb5df
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 96 deletions.
24 changes: 17 additions & 7 deletions include/battle_ai_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,41 @@ typedef s32 (*AiScoreFunc)(u32, u32, u32, s32);
#define SET_SCORE(battler, movesetIndex, val) \
do \
{ \
TestRunner_Battle_AISetScore(__FILE__, __LINE__, battler, movesetIndex, val); \
if (TESTING) \
{ \
TestRunner_Battle_AISetScore(__FILE__, __LINE__, battler, movesetIndex, val); \
} \
AI_THINKING_STRUCT->score[movesetIndex] = val; \
} while (0) \

#define ADJUST_SCORE(val) \
do \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, sBattler_AI, AI_THINKING_STRUCT->movesetIndex, val); \
if (TESTING) \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, battlerAtk, AI_THINKING_STRUCT->movesetIndex, val); \
} \
score += val; \
} while (0) \

#define ADJUST_AND_RETURN_SCORE(val) \
do \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, sBattler_AI, AI_THINKING_STRUCT->movesetIndex, val); \
if (TESTING) \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, battlerAtk, AI_THINKING_STRUCT->movesetIndex, val); \
} \
score += val; \
return score; \
} while (0) \

#define ADJUST_SCORE_PTR(val) \
do \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, sBattler_AI, AI_THINKING_STRUCT->movesetIndex, val); \
if (TESTING) \
{ \
TestRunner_Battle_AIAdjustScore(__FILE__, __LINE__, battlerAtk, AI_THINKING_STRUCT->movesetIndex, val); \
} \
(*score) += val; \
} while (0) \

Expand All @@ -98,13 +110,11 @@ typedef s32 (*AiScoreFunc)(u32, u32, u32, s32);
void BattleAI_SetupItems(void);
void BattleAI_SetupFlags(void);
void BattleAI_SetupAIData(u8 defaultScoreMoves, u32 battler);
u32 BattleAI_ChooseMoveOrAction(void);
u32 BattleAI_ChooseMoveOrAction(u32 battler);
void Ai_InitPartyStruct(void);
void Ai_UpdateSwitchInData(u32 battler);
void Ai_UpdateFaintData(u32 battler);
void SetAiLogicDataForTurn(struct AiLogicData *aiData);
void ResetDynamicAiFunc(void);

extern u8 sBattler_AI;

#endif // GUARD_BATTLE_AI_MAIN_H
8 changes: 4 additions & 4 deletions include/battle_ai_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ bool32 CanTargetMoveFaintAi(u32 move, u32 battlerDef, u32 battlerAtk, u32 nHits)
bool32 CanTargetFaintAiWithMod(u32 battlerDef, u32 battlerAtk, s32 hpMod, s32 dmgMod);
s32 AI_DecideKnownAbilityForTurn(u32 battlerId);
u32 AI_DecideHoldEffectForTurn(u32 battlerId);
bool32 DoesBattlerIgnoreAbilityChecks(u32 atkAbility, u32 move);
u32 AI_GetWeather(struct AiLogicData *aiData);
bool32 DoesBattlerIgnoreAbilityChecks(u32 battlerAtk, u32 atkAbility, u32 move);
u32 AI_GetWeather(void);
bool32 CanAIFaintTarget(u32 battlerAtk, u32 battlerDef, u32 numHits);
bool32 CanIndexMoveFaintTarget(u32 battlerAtk, u32 battlerDef, u32 index, u32 numHits);
bool32 HasDamagingMove(u32 battlerId);
Expand All @@ -84,7 +84,7 @@ u32 AI_GetBattlerAbility(u32 battler);

// stat stage checks
bool32 AnyStatIsRaised(u32 battlerId);
bool32 ShouldLowerStat(u32 battler, u32 battlerAbility, u32 stat);
bool32 ShouldLowerStat(u32 battlerAtk, u32 battlerDef, u32 battlerAbility, u32 stat);
bool32 BattlerStatCanRise(u32 battler, u32 battlerAbility, u32 stat);
bool32 AreBattlersStatsMaxed(u32 battler);
u32 CountPositiveStatStages(u32 battlerId);
Expand Down Expand Up @@ -125,7 +125,7 @@ bool32 HasMoveWithLowAccuracy(u32 battlerAtk, u32 battlerDef, u32 accCheck, bool
bool32 HasAnyKnownMove(u32 battlerId);
bool32 IsAromaVeilProtectedEffect(u32 moveEffect);
bool32 IsNonVolatileStatusMoveEffect(u32 moveEffect);
bool32 IsMoveRedirectionPrevented(u32 move, u32 atkAbility);
bool32 IsMoveRedirectionPrevented(u32 battlerAtk, u32 move, u32 atkAbility);
bool32 IsMoveEncouragedToHit(u32 battlerAtk, u32 battlerDef, u32 move);
bool32 IsHazardMoveEffect(u32 moveEffect);
bool32 IsTwoTurnNotSemiInvulnerableMove(u32 battlerAtk, u32 move);
Expand Down
Loading

0 comments on commit 32eb5df

Please sign in to comment.