Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Documenting Trainer AI Routines #122

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/battle/ai_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "item.h"
#include "move_table.h"
typedef struct AIContext {
u8 scriptCursor;
u8 evalStep;
u8 moveSlot;
u16 move;

s8 moveCurPP[4];
s8 moveScore[4];

int calcTemp;
u32 thinkingMask;
Expand Down
36 changes: 36 additions & 0 deletions include/battle/trainer_ai.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef POKEPLATINUM_BATTLE_TRAINER_AI_H
#define POKEPLATINUM_BATTLE_TRAINER_AI_H

#include "struct_decls/battle_system.h"
#include "battle/battle_context.h"

/**
* @brief Initialize the trainer AI for a given battler.
*
* @param battleSys
* @param battleCtx
* @param battler The battler to be initialized
* @param initScore Bitmask of moves to have their scores initialized; moves
* flagged as such will be initially scored at 100 instead of 0.
*/
void TrainerAI_Init(BattleSystem *battleSys, BattleContext *battleCtx, u8 battler, u8 initScore);

/**
* @brief Execute the trainer AI routine for a given battler.
*
* @param battleSys
* @param battler The battler to be executed
* @return AI execution routine result
*/
u8 TrainerAI_Main(BattleSystem *battleSys, u8 battler);

/**
* @brief Pick the command for a battler to execute.
*
* @param battleSys
* @param battler The battler who is waiting to choose their turn's action
* @return The action to be executed for this battler
*/
int TrainerAI_PickCommand(BattleSystem *battleSys, int battler);

#endif // POKEPLATINUM_BATTLE_TRAINER_AI_H
46 changes: 46 additions & 0 deletions include/constants/battle/trainer_ai.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef POKEPLATINUM_CONSTANTS_BATTLE_TRAINER_AI_H
#define POKEPLATINUM_CONSTANTS_BATTLE_TRAINER_AI_H

#define AI_FLAG_BASIC (1 << 0)
#define AI_FLAG_EVAL_ATTACK (1 << 1)
#define AI_FLAG_EXPERT (1 << 2)
#define AI_FLAG_SETUP_FIRST_TURN (1 << 3)
#define AI_FLAG_RISKY (1 << 4)
#define AI_FLAG_DAMAGE_PRIORITY (1 << 5)
#define AI_FLAG_BATON_PASS (1 << 6)
#define AI_FLAG_TAG_STRATEGY (1 << 7)
#define AI_FLAG_CHECK_HP (1 << 8)
#define AI_FLAG_WEATHER (1 << 9)
#define AI_FLAG_HARRASSMENT (1 << 10)
#define AI_FLAG_ROAMING_POKEMON (1 << 29)

#define AI_INIT_SCORE_MOVE_1 (1 << 0)
#define AI_INIT_SCORE_MOVE_2 (1 << 1)
#define AI_INIT_SCORE_MOVE_3 (1 << 2)
#define AI_INIT_SCORE_MOVE_4 (1 << 3)

#define AI_INIT_SCORE_ALL_MOVES (AI_INIT_SCORE_MOVE_1 | AI_INIT_SCORE_MOVE_2 | AI_INIT_SCORE_MOVE_3 | AI_INIT_SCORE_MOVE_4)

#define AI_STATUS_FLAG_DONE (1 << 0)
#define AI_STATUS_FLAG_ESCAPE (1 << 1)
#define AI_STATUS_FLAG_SAFARI (1 << 2)
#define AI_STATUS_FLAG_BREAK (1 << 3)
#define AI_STATUS_FLAG_CONTINUE (1 << 4)

#define AI_STATUS_FLAG_DONE_OFF (AI_STATUS_FLAG_DONE ^ 0xFF)
#define AI_STATUS_FLAG_ESCAPE_OFF (AI_STATUS_FLAG_ESCAPE ^ 0xFF)
#define AI_STATUS_FLAG_SAFARI_OFF (AI_STATUS_FLAG_SAFARI ^ 0xFF)
#define AI_STATUS_FLAG_BREAK_OFF (AI_STATUS_FLAG_BREAK ^ 0xFF)
#define AI_STATUS_FLAG_CONTINUE_OFF (AI_STATUS_FLAG_CONTINUE ^ 0xFF)

enum {
AI_ENEMY_ATTACK_1 = 0,
AI_ENEMY_ATTACK_2,
AI_ENEMY_ATTACK_3,
AI_ENEMY_ATTACK_4,
AI_ENEMY_ESCAPE,
AI_ENEMY_SAFARI,
AI_ENEMY_SWITCH,
};

#endif
11 changes: 0 additions & 11 deletions include/overlay014/ov14_0221FC20.h

This file was deleted.

2 changes: 1 addition & 1 deletion platinum.us/main.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ Overlay overlay13
Overlay overlay14
{
After overlay11
Object main.nef.p/src_overlay014_ov14_0221FC20.c.o
Object main.nef.p/src_overlay014_trainer_ai.c.o
Object main.nef.p/overlay014/asm_overlay014_ov14_022248A4.s.o
}

Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ pokeplatinum_c = files(
'overlay013/ov13_02227BDC.c',
'overlay013/ov13_02228128.c',
'overlay013/ov13_02228A38.c',
'overlay014/ov14_0221FC20.c',
'overlay014/trainer_ai.c',
'overlay015/ov15_dummy.c',
'overlay016/ov16_0223B140.c',
'overlay016/ov16_0223DF00.c',
Expand Down
Loading
Loading