mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-10-26 02:21:07 -05:00
Merge pull request #122 from lhearachel/trainer_ai
Start Documenting Trainer AI Routines
This commit is contained in:
@@ -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;
|
||||
|
||||
36
include/battle/trainer_ai.h
Normal file
36
include/battle/trainer_ai.h
Normal file
@@ -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
include/constants/battle/trainer_ai.h
Normal file
46
include/constants/battle/trainer_ai.h
Normal file
@@ -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
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef POKEPLATINUM_OV14_0221FC20_H
|
||||
#define POKEPLATINUM_OV14_0221FC20_H
|
||||
|
||||
#include "struct_decls/battle_system.h"
|
||||
#include "battle/battle_context.h"
|
||||
|
||||
void ov14_0221FC20(BattleSystem * param0, BattleContext * param1, u8 param2, u8 param3);
|
||||
u8 ov14_0221FCF4(BattleSystem * param0, u8 param1);
|
||||
int ov14_022243BC(BattleSystem * param0, int param1);
|
||||
|
||||
#endif // POKEPLATINUM_OV14_0221FC20_H
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -144,7 +144,7 @@
|
||||
#include "overlay012/ov12_022380BC.h"
|
||||
#include "overlay013/ov13_0221FC20.h"
|
||||
#include "overlay013/ov13_022264F4.h"
|
||||
#include "overlay014/ov14_0221FC20.h"
|
||||
#include "battle/trainer_ai.h"
|
||||
#include "overlay016/ov16_0223B140.h"
|
||||
#include "overlay016/ov16_0223DF00.h"
|
||||
#include "battle/battle_lib.h"
|
||||
@@ -3190,7 +3190,7 @@ static void ov16_02260AB4 (SysTask * param0, void * param1)
|
||||
UnkStruct_ov16_0225D5B8 * v0 = (UnkStruct_ov16_0225D5B8 *)param1;
|
||||
int v1;
|
||||
|
||||
v1 = ov14_022243BC(v0->unk_00, v0->unk_09);
|
||||
v1 = TrainerAI_PickCommand(v0->unk_00, v0->unk_09);
|
||||
|
||||
ov16_022656D4(v0->unk_00, v0->unk_09, v1);
|
||||
ov16_02266ABC(v0->unk_00, v0->unk_09, v0->unk_08);
|
||||
@@ -3385,7 +3385,7 @@ static void ov16_02260DB0 (SysTask * param0, void * param1)
|
||||
v1 = BattleSystem_Context(v0->unk_00);
|
||||
|
||||
if ((v3 & (0x1 | 0x100)) || (BattleSystem_BattleStatus(v0->unk_00) & 0x1) || (Battler_Side(v0->unk_00, v0->unk_1D) == 0)) {
|
||||
v2 = ov14_0221FCF4(v0->unk_00, v0->unk_1D);
|
||||
v2 = TrainerAI_Main(v0->unk_00, v0->unk_1D);
|
||||
|
||||
switch (v2) {
|
||||
case 0xff:
|
||||
|
||||
Reference in New Issue
Block a user