mirror of
https://github.com/rh-hideout/pokeemerald-expansion.git
synced 2026-03-21 09:55:42 -05:00
Fix AI debug timers (#9585)
Some checks are pending
CI / build-emerald (push) Waiting to run
CI / build-firered (push) Waiting to run
CI / build-leafgreen (push) Waiting to run
CI / release (push) Waiting to run
CI / test (push) Waiting to run
CI / build (push) Blocked by required conditions
CI / docs_validate (push) Waiting to run
CI / allcontributors (push) Waiting to run
Docs / deploy (push) Waiting to run
Some checks are pending
CI / build-emerald (push) Waiting to run
CI / build-firered (push) Waiting to run
CI / build-leafgreen (push) Waiting to run
CI / release (push) Waiting to run
CI / test (push) Waiting to run
CI / build (push) Blocked by required conditions
CI / docs_validate (push) Waiting to run
CI / allcontributors (push) Waiting to run
Docs / deploy (push) Waiting to run
This commit is contained in:
parent
6034c13eab
commit
d50afab833
|
|
@ -136,6 +136,8 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData);
|
|||
void ResetDynamicAiFunctions(void);
|
||||
void AI_TrySwitchOrUseItem(enum BattlerId battler);
|
||||
void CalcBattlerAiMovesData(struct AiLogicData *aiData, enum BattlerId battlerAtk, enum BattlerId battlerDef, u32 weather, u32 fieldStatus);
|
||||
void AIDebugTimerStart(void);
|
||||
void AIDebugTimerEnd(void);
|
||||
|
||||
extern AiSwitchFunc gDynamicAiSwitchFunc;
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,20 @@ static s32 (*const sBattleAiFuncTable[])(enum BattlerId, enum BattlerId, enum Mo
|
|||
};
|
||||
|
||||
// Functions
|
||||
void AIDebugTimerStart()
|
||||
{
|
||||
// Set delay timer to count how long it takes for AI to choose action/move
|
||||
gBattleStruct->aiDelayTimer = gMain.vblankCounter1;
|
||||
CycleCountStart();
|
||||
}
|
||||
|
||||
void AIDebugTimerEnd()
|
||||
{
|
||||
// We add to existing to compound multiple calls
|
||||
gBattleStruct->aiDelayFrames += gMain.vblankCounter1 - gBattleStruct->aiDelayTimer;
|
||||
gBattleStruct->aiDelayCycles += CycleCountEnd();
|
||||
}
|
||||
|
||||
void BattleAI_SetupItems(void)
|
||||
{
|
||||
u8 *data = (u8 *)gBattleHistory;
|
||||
|
|
@ -370,6 +384,9 @@ void ComputeBattlerDecisions(enum BattlerId battler)
|
|||
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
AIDebugTimerStart();
|
||||
|
||||
// Setup battler and prediction data
|
||||
BattleAI_SetupAIData(0xF, battler);
|
||||
SetupAIPredictionData(battler, SWITCH_MID_BATTLE_OPTIONAL);
|
||||
|
|
@ -389,6 +406,9 @@ void ComputeBattlerDecisions(enum BattlerId battler)
|
|||
BattlerChooseNonMoveAction();
|
||||
ModifySwitchAfterMoveScoring(battler);
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
AIDebugTimerEnd();
|
||||
|
||||
gAiLogicData->aiCalcInProgress = FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -707,8 +727,10 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)
|
|||
if (!(gBattleTypeFlags & BATTLE_TYPE_HAS_AI) && !IsWildMonSmart())
|
||||
return;
|
||||
|
||||
// Set delay timer to count how long it takes for AI to choose action/move
|
||||
gBattleStruct->aiDelayTimer = gMain.vblankCounter1;
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
AIDebugTimerStart();
|
||||
|
||||
aiData->weatherHasEffect = HasWeatherEffect();
|
||||
weather = AI_GetWeather();
|
||||
|
|
@ -716,9 +738,6 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)
|
|||
// get/assume all battler data and simulate AI damage
|
||||
battlersCount = gBattlersCount;
|
||||
|
||||
gAiLogicData->aiCalcInProgress = TRUE;
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
CycleCountStart();
|
||||
for (enum BattlerId battlerAtk = 0; battlerAtk < battlersCount; battlerAtk++)
|
||||
{
|
||||
if (!IsBattlerAlive(battlerAtk))
|
||||
|
|
@ -749,8 +768,8 @@ void SetAiLogicDataForTurn(struct AiLogicData *aiData)
|
|||
}
|
||||
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
// We add to existing to compound multiple calls
|
||||
gBattleStruct->aiDelayCycles += CycleCountEnd();
|
||||
AIDebugTimerEnd();
|
||||
|
||||
gAiLogicData->aiCalcInProgress = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2003,8 +2003,6 @@ static void HandleChooseActionAfterDma3(enum BattlerId battler)
|
|||
gBattle_BG0_Y = DISPLAY_HEIGHT;
|
||||
if (gBattleStruct->aiDelayTimer != 0)
|
||||
{
|
||||
gBattleStruct->aiDelayFrames = gMain.vblankCounter1 - gBattleStruct->aiDelayTimer;
|
||||
gBattleStruct->aiDelayTimer = 0;
|
||||
if (DEBUG_AI_DELAY_TIMER)
|
||||
{
|
||||
static const u8 sFramesText[] = _(" frames thinking\n");
|
||||
|
|
@ -2017,6 +2015,8 @@ static void HandleChooseActionAfterDma3(enum BattlerId battler)
|
|||
StringAppend(gDisplayedStringBattle, sCyclesText);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
|
||||
}
|
||||
gBattleStruct->aiDelayTimer = 0;
|
||||
gBattleStruct->aiDelayFrames = 0;
|
||||
}
|
||||
gBattlerControllerFuncs[battler] = HandleInputChooseAction;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ EVs: 252 Atk / 252 Def / 6 SpA
|
|||
|
||||
=== DEBUG_TRAINER_AI ===
|
||||
Name: Debugger
|
||||
AI: Basic Trainer
|
||||
AI: Smart Trainer
|
||||
Class: Rival
|
||||
Battle Type: Singles
|
||||
Pic: Steven
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user