mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
Add ai delay timer (#3302)
This commit is contained in:
commit
623015bd8d
@ -679,6 +679,8 @@ struct BattleStruct
|
||||
bool8 trainerSlideMegaEvolutionMsgDone;
|
||||
bool8 trainerSlideZMoveMsgDone;
|
||||
bool8 trainerSlideBeforeFirstTurnMsgDone;
|
||||
u32 aiDelayTimer; // Counts number of frames AI takes to choose an action.
|
||||
u32 aiDelayFrames; // Number of frames it took to choose an action.
|
||||
};
|
||||
|
||||
// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider,
|
||||
|
@ -27,7 +27,7 @@ u8 BattleAI_ChooseMoveOrAction(void);
|
||||
void Ai_InitPartyStruct(void);
|
||||
void Ai_UpdateSwitchInData(u32 battler);
|
||||
void Ai_UpdateFaintData(u32 battler);
|
||||
void GetAiLogicData(void);
|
||||
void SetAiLogicDataForTurn(void);
|
||||
|
||||
extern u8 sBattler_AI;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
// Battle Debug Menu
|
||||
#define DEBUG_BATTLE_MENU TRUE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button.
|
||||
#define DEBUG_AI_DELAY_TIMER FALSE // If set to TRUE, displays the number of frames it takes for the AI to choose a move. Replaces the "What will PKMN do" text. Useful for devs or anyone who modifies the AI code and wants to see if it doesn't take too long to run.
|
||||
|
||||
// Pokémon Debug
|
||||
#define DEBUG_POKEMON_MENU TRUE // Enables a debug menu for pokemon sprites and icons, accessed by pressing SELECT in the summary screen.
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "malloc.h"
|
||||
#include "battle.h"
|
||||
#include "battle_anim.h"
|
||||
@ -335,7 +336,7 @@ void Ai_UpdateFaintData(u32 battler)
|
||||
aiMon->isFainted = TRUE;
|
||||
}
|
||||
|
||||
static void SetBattlerAiData(u8 battler)
|
||||
static void SetBattlerAiData(u32 battler)
|
||||
{
|
||||
AI_DATA->abilities[battler] = AI_GetAbility(battler);
|
||||
AI_DATA->items[battler] = gBattleMons[battler].item;
|
||||
@ -346,7 +347,7 @@ static void SetBattlerAiData(u8 battler)
|
||||
AI_DATA->moveLimitations[battler] = CheckMoveLimitations(battler, 0, MOVE_LIMITATIONS_ALL);
|
||||
}
|
||||
|
||||
void GetAiLogicData(void)
|
||||
void SetAiLogicDataForTurn(void)
|
||||
{
|
||||
u32 battlerAtk, battlerDef, i, move;
|
||||
u8 effectiveness;
|
||||
@ -357,6 +358,8 @@ void GetAiLogicData(void)
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_HAS_AI) && !IsWildMonSmart())
|
||||
return;
|
||||
|
||||
gBattleStruct->aiDelayTimer = gMain.vblankCounter1;
|
||||
|
||||
// get/assume all battler data
|
||||
for (i = 0; i < gBattlersCount; i++)
|
||||
{
|
||||
|
@ -1889,6 +1889,19 @@ static void HandleChooseActionAfterDma3(u32 battler)
|
||||
{
|
||||
gBattle_BG0_X = 0;
|
||||
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 sText_AIDelay[] = _("AI delay:\n{B_BUFF1} frames");
|
||||
PREPARE_HWORD_NUMBER_BUFFER(gBattleTextBuff1, 3, gBattleStruct->aiDelayFrames);
|
||||
BattleStringExpandPlaceholdersToDisplayedString(sText_AIDelay);
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_ACTION_PROMPT);
|
||||
}
|
||||
#endif // DEBUG_AI_DELAY_TIMER
|
||||
}
|
||||
gBattlerControllerFuncs[battler] = HandleInputChooseAction;
|
||||
}
|
||||
}
|
||||
|
@ -3724,7 +3724,7 @@ static void DoBattleIntro(void)
|
||||
gBattleStruct->switchInAbilitiesCounter = 0;
|
||||
gBattleStruct->switchInItemsCounter = 0;
|
||||
gBattleStruct->overworldWeatherDone = FALSE;
|
||||
GetAiLogicData(); // get assumed abilities, hold effects, etc of all battlers
|
||||
SetAiLogicDataForTurn(); // get assumed abilities, hold effects, etc of all battlers
|
||||
Ai_InitPartyStruct(); // Save mons party counts, and first 2/4 mons on the battlefield.
|
||||
gBattleMainFunc = TryDoEventsBeforeFirstTurn;
|
||||
}
|
||||
@ -3857,7 +3857,7 @@ static void TryDoEventsBeforeFirstTurn(void)
|
||||
|
||||
gRandomTurnNumber = Random();
|
||||
|
||||
GetAiLogicData(); // get assumed abilities, hold effects, etc of all battlers
|
||||
SetAiLogicDataForTurn(); // get assumed abilities, hold effects, etc of all battlers
|
||||
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
|
||||
{
|
||||
@ -3949,7 +3949,7 @@ void BattleTurnPassed(void)
|
||||
|
||||
*(&gBattleStruct->absentBattlerFlags) = gAbsentBattlerFlags;
|
||||
BattlePutTextOnWindow(gText_EmptyString3, B_WIN_MSG);
|
||||
GetAiLogicData(); // get assumed abilities, hold effects, etc of all battlers
|
||||
SetAiLogicDataForTurn(); // get assumed abilities, hold effects, etc of all battlers
|
||||
gBattleMainFunc = HandleTurnActionSelectionState;
|
||||
gRandomTurnNumber = Random();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user