Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
battle.h
Go to the documentation of this file.
1#ifndef _BATTLE_BATTLE_H_
2#define _BATTLE_BATTLE_H_
3
4#include "common.h"
5#include "message_ids.h"
6
7// Terminates foreground model lists
8#define STAGE_MODEL_LIST_END 0
9
59
79
81 BTL_VAR_DuplighostCopyFlags = 0, // used by duplighost
87 // index of the last enemy boosted by a magikoopa
88 // intended to prevent multiple boosts for the same actor in the same turn
89 // selected enemies go from left to right and are reset if none are found
91 BTL_VAR_LastCopiedPartner = 3, // used by duplighost
92 BTL_VAR_KoopatrolSummonCount_0 = 4, // count summons from Koopatrol and 'children' originally from column 0
93 BTL_VAR_KoopatrolSummonCount_1 = 5, // count summons from Koopatrol and 'children' originally from column 1
94 BTL_VAR_KoopatrolSummonCount_2 = 6, // count summons from Koopatrol and 'children' originally from column 2
95 BTL_VAR_KoopatrolSummonCount_3 = 7, // count summons from Koopatrol and 'children' originally from column 3
96};
97
98// document special actor vars referenced from other actors
104
105extern s32 bActorNames[];
106
107typedef struct BattleMoveEntry {
108 /* 0x00 */ u8* romStart;
109 /* 0x04 */ u8* romEnd;
110 /* 0x08 */ u8* vramStart;
112} BattleMoveEntry; // size = 0x10
113
114#define BTL_MOVE(name, script) \
115{ \
116 .romStart = battle_move_##name##_ROM_START, \
117 .romEnd = battle_move_##name##_ROM_END, \
118 .vramStart = battle_move_##name##_VRAM, \
119 .mainScript = &battle_move_##name##_##script \
120}
121
122#define BTL_ITEM(name) \
123{ \
124 .romStart = name##_ROM_START, \
125 .romEnd = name##_ROM_END, \
126 .vramStart = name##_VRAM, \
127 .mainScript = &battle_item_##name##_##EVS_UseItem \
128}
129
130typedef struct ActorBlueprint {
131 /* 0x00 */ s32 flags;
132 /* 0x04 */ s16 maxHP;
133 /* 0x06 */ u8 type;
134 /* 0x07 */ u8 level;
135 /* 0x08 */ s16 partCount;
136 /* 0x0A */ char unk_0A[2];
137 /* 0x0C */ struct ActorPartBlueprint* partsData;
139 /* 0x14 */ s32* statusTable;
140 /* 0x18 */ u8 escapeChance;
141 /* 0x19 */ u8 airLiftChance;
142 /* 0x1A */ u8 hurricaneChance;
143 /* 0x1B */ u8 spookChance;
144 /* 0x1C */ u8 upAndAwayChance;
145 /* 0x1D */ u8 spinSmashReq;
146 /* 0x1E */ u8 powerBounceChance;
147 /* 0x1F */ u8 coinReward;
148 /* 0x20 */ Vec2b size;
152} ActorBlueprint; // size = 0x28
153
154typedef struct FormationRow {
156 /* 0x04 */ union {
157 s32 index;
158 Vec3i* vec;
160 /* 0x08 */ s32 priority;
161 /* 0x0C */ s32 var0;
162 /* 0x10 */ s32 var1;
163 /* 0x14 */ s32 var2;
164 /* 0x18 */ s32 var3;
165} FormationRow; // size = 0x1C * n
166
168
169typedef struct StaticFormationActor {
170 /* 0x00 */ char unk_00[0x4];
171} StaticFormationActor; // size = ??
172
173typedef struct StaticFormationEntry {
174 /* 0x00 */ char* sjisName;
175 /* 0x04 */ s32 numActors;
177 /* 0x0C */ char* stageName;
178 /* 0x10 */ char unk_10[0x4];
179} StaticFormationEntry; // size = 0x20
180
181typedef struct Stage {
182 /* 0x00 */ char* texture;
183 /* 0x04 */ const char* shape;
184 /* 0x08 */ const char* hit;
185 /* 0x0C */ EvtScript* preBattle; // sets BattleStatus::controlScript on battle start
186 /* 0x10 */ EvtScript* postBattle; // sets BattleStatus::controlScript on battle end
187 /* 0x14 */ char* bg;
188 /* 0x18 */ s32* foregroundModelList;
189 /* 0x1C */ s32 stageEnemyCount; // number of enemies in the stageFormation
190 /* 0x20 */ Formation* stageFormation; // extra enemies native to this stage
191 /* 0x24 */ s32 stageEnemyChance; // 1/(N+1) chance for stageFormation enemies to spawn
192} Stage; // size = 0x28
193
195typedef struct Battle {
196 /* 0x00 */ const char* name;
197 /* 0x04 */ s32 formationSize;
198 /* 0x08 */ Formation* formation;
199 /* 0x0C */ Stage* stage;
200 /* 0x10 */ EvtScript* onBattleStart; // sets BattleStatus::controlScript on battle start, overrides Stage::preBattle
201} Battle; // size = 0x14
202
204
206typedef struct StageListRow {
207 /* 0x00 */ const char* name;
208 /* 0x04 */ Stage* stage;
209} StageListRow; // size = 0x08
210
212
213typedef struct BattleArea {
214 /* 0x00 */ char* name;
215 /* 0x04 */ void* dmaStart;
216 /* 0x08 */ void* dmaEnd;
217 /* 0x0C */ void* dmaDest;
218 /* 0x10 */ BattleList* battles;
219 /* 0x14 */ StageList* stages;
220 /* 0x18 */ s32 unused_18;
221 /* 0x1C */ DmaTable* dmaTable;
222} BattleArea; // size = 0x20
223
224extern BattleArea gBattleAreas[0x30];
225
226#define BATTLE(formation, stage, name) { name, ARRAY_COUNT(formation), (Formation*) formation, &stage }
227#define BATTLE_WITH_SCRIPT(formation, stage, script, name) { name, ARRAY_COUNT(formation), (Formation*) formation, &stage, &script }
228
229#define ACTOR_BY_IDX(_name, _idx, _priority, args...) { .actor = &_name, .home = { .index = _idx }, .priority = _priority, args }
230#define ACTOR_BY_POS(_name, _pos, _priority, args...) { .actor = &_name, .home = { .vec = &_pos }, .priority = _priority, args }
231
232#define STAGE(_name, _stage) { .name = _name, .stage = &_stage }
233
234typedef struct ActorSounds {
235 /* 0x00 */ s32 walk[2];
236 /* 0x08 */ s32 fly[2];
237 /* 0x10 */ s32 jump;
238 /* 0x14 */ s32 hurt;
239 /* 0x18 */ s16 delay[2];
240} ActorSounds; // size = 0x1C
241
243
244typedef struct ActorOffsets {
245 /* 0x00 */ Vec3b tattleCam;
246 /* 0x03 */ s8 shadow;
247} ActorOffsets; // size = 0x04
248
249// TODO look into making options here better. it's really an array of 5 substructs, each having an [8][2] array
251 /* 0x00 */ s16 randomChance;
252 /* 0x02 */ s16 hpBasedChance;
253 /* 0x04 */ s32 options[80];
254} PlayerCelebrationAnimOptions; // size = 0x144
255
257
259
260void load_demo_battle(u32 index);
261Actor* create_actor(Formation formation);
262
263#define EXEC_DEATH_NO_SPINNING -12345
264#define ACTOR_API_SKIP_ARG -12345678
265
266#define DANGER_THRESHOLD 5
267#define PERIL_THRESHOLD 1
268
269#endif
Bytecode EvtScript[]
ActorBlueprint * actor
Definition battle.h:155
u8 hurricaneChance
Definition battle.h:142
s32 walk[2]
Definition battle.h:235
Vec2b statusIconOffset
Definition battle.h:150
ActorOffsets bActorOffsets[]
ActorSounds bActorSoundTable[]
union FormationRow::@102 home
Vec2b statusTextOffset
Definition battle.h:151
EvtScript * mainScript
Definition battle.h:111
EvtScript * preBattle
Definition battle.h:185
Vec3b tattleCam
Definition battle.h:245
BattleArea gBattleAreas[0x30]
Definition battle.c:50
char * texture
Definition battle.h:182
const char * shape
Definition battle.h:183
s32 * foregroundModelList
Definition battle.h:188
struct ActorPartBlueprint * partsData
Definition battle.h:137
Battle * gCurrentBattlePtr
Definition battle.c:19
s32 priority
Actors with higher priority values take their turn first.
Definition battle.h:160
s32 unused_18
Definition battle.h:220
BattleAreaIDs
Definition battle.h:10
@ BTL_AREA_KGR
Definition battle.h:30
@ BTL_AREA_ISK_1
Definition battle.h:22
@ BTL_AREA_TRD_2
Definition battle.h:18
@ BTL_AREA_OMO
Definition battle.h:27
@ BTL_AREA_HOS
Definition battle.h:15
@ BTL_AREA_ISK_2
Definition battle.h:23
@ BTL_AREA_TRD_3
Definition battle.h:19
@ BTL_AREA_KMR_3
Definition battle.h:13
@ BTL_AREA_KZN2
Definition battle.h:34
@ BTL_AREA_TIK2
Definition battle.h:38
@ BTL_AREA_OMO2_5
Definition battle.h:56
@ BTL_AREA_KPA4
Definition battle.h:48
@ BTL_AREA_IWA
Definition battle.h:20
@ BTL_AREA_KPA2
Definition battle.h:46
@ BTL_AREA_NOK
Definition battle.h:16
@ BTL_AREA_KZN
Definition battle.h:33
@ BTL_AREA_MIM
Definition battle.h:24
@ BTL_AREA_UNUSED_28
Definition battle.h:51
@ BTL_AREA_KPA3
Definition battle.h:47
@ BTL_AREA_JAN2
Definition battle.h:32
@ BTL_AREA_OMO2_2
Definition battle.h:53
@ BTL_AREA_TIK
Definition battle.h:37
@ BTL_AREA_KKJ
Definition battle.h:49
@ BTL_AREA_SBK
Definition battle.h:21
@ BTL_AREA_KMR_1
Definition battle.h:11
@ BTL_AREA_OMO2_4
Definition battle.h:55
@ BTL_AREA_OMO2_3
Definition battle.h:54
@ BTL_AREA_DIG
Definition battle.h:50
@ BTL_AREA_TRD_1
Definition battle.h:17
@ BTL_AREA_OMO2_6
Definition battle.h:57
@ BTL_AREA_PRA
Definition battle.h:42
@ BTL_AREA_MAC
Definition battle.h:14
@ BTL_AREA_JAN
Definition battle.h:31
@ BTL_AREA_KMR_2
Definition battle.h:12
@ BTL_AREA_TIK3
Definition battle.h:39
@ BTL_AREA_ARN
Definition battle.h:25
@ BTL_AREA_SAM2
Definition battle.h:41
@ BTL_AREA_SAM
Definition battle.h:40
@ BTL_AREA_KPA
Definition battle.h:45
@ BTL_AREA_PRA2
Definition battle.h:43
@ BTL_AREA_FLO
Definition battle.h:35
@ BTL_AREA_OMO2_1
Definition battle.h:52
@ BTL_AREA_OMO2
Definition battle.h:28
@ BTL_AREA_FLO2
Definition battle.h:36
@ BTL_AREA_PRA3
Definition battle.h:44
@ BTL_AREA_OMO3
Definition battle.h:29
@ BTL_AREA_DGB
Definition battle.h:26
void * dmaDest
Definition battle.h:217
BattleList * battles
Definition battle.h:218
Stage * stage
Definition battle.h:199
s16 delay[2]
Number of frames to wait between walk/fly sounds. Negative values are in distance.
Definition battle.h:239
u8 upAndAwayChance
Definition battle.h:144
char * name
JP debug name.
Definition battle.h:214
s32 fly[2]
Definition battle.h:236
CommonActorVars
Definition battle.h:99
@ AVAR_JungleFuzzy_Generation
Definition battle.h:102
@ AVAR_SpearGuy_Generation
Definition battle.h:101
@ AVAR_DryBones_Collapsed
Definition battle.h:100
Formation * stageFormation
Definition battle.h:190
EvtScript * initScript
Definition battle.h:138
void load_demo_battle(u32 index)
Definition battle.c:190
Battle BattleList[]
Definition battle.h:203
StaticFormationActor * actors
Definition battle.h:176
BattleVars
Definition battle.h:80
@ BTL_VAR_KoopatrolSummonCount_2
Definition battle.h:94
@ BTL_VAL_HyperSync_Active
Definition battle.h:86
@ BTL_VAR_DuplighostCopyFlags
Definition battle.h:81
@ BTL_VAR_KoopatrolSummonCount_0
Definition battle.h:92
@ BTL_VAL_HyperSync_Done
Definition battle.h:85
@ BTL_VAR_LastCopiedPartner
Definition battle.h:91
@ BTL_VAR_Magikoopa_LastIndexBoosted
Definition battle.h:90
@ BTL_VAR_KoopatrolSummonCount_1
Definition battle.h:93
@ BTL_VAL_HyperSync_None
Definition battle.h:84
@ BTL_VAL_Duplighost_HasCopied
Definition battle.h:82
@ BTL_VAR_HyperSync
Definition battle.h:83
@ BTL_VAR_KoopatrolSummonCount_3
Definition battle.h:95
Formation * formation
Definition battle.h:198
s32 formationSize
Definition battle.h:197
s32 stageEnemyChance
Definition battle.h:191
Stage * stage
Definition battle.h:208
Vec2b healthBarOffset
Definition battle.h:149
EvtScript * postBattle
Definition battle.h:186
BattlePositions
Definition battle.h:60
@ BTL_POS_GROUND_B
Definition battle.h:62
@ BTL_POS_AIR_B
Definition battle.h:66
@ BTL_POS_GROUND_D
Definition battle.h:64
@ BTL_POS_CENTER
Definition battle.h:77
@ BTL_POS_AIR_D
Definition battle.h:68
@ BTL_POS_AIR_A
Definition battle.h:65
@ BTL_POS_AIR_C
Definition battle.h:67
@ BTL_POS_GROUND_A
Definition battle.h:61
@ BTL_POS_HIGH_D
Definition battle.h:72
@ BTL_POS_GROUND_C
Definition battle.h:63
@ BTL_POS_TOP_A
Definition battle.h:73
@ BTL_POS_TOP_D
Definition battle.h:76
@ BTL_POS_HIGH_A
Definition battle.h:69
@ BTL_POS_TOP_C
Definition battle.h:75
@ BTL_POS_HIGH_C
Definition battle.h:71
@ BTL_POS_HIGH_B
Definition battle.h:70
@ BTL_POS_TOP_B
Definition battle.h:74
EvtScript * onBattleStart
Definition battle.h:200
FormationRow Formation[]
Definition battle.h:167
s32 stageEnemyCount
Definition battle.h:189
const char * hit
Definition battle.h:184
char * bg
Definition battle.h:187
DmaTable * dmaTable
Definition battle.h:221
const char * name
Map ID.
Definition battle.h:207
u8 powerBounceChance
Definition battle.h:146
char unk_0A[2]
Definition battle.h:136
StageListRow StageList[]
Definition battle.h:211
char unk_10[0x4]
Definition battle.h:178
StageList * stages
Definition battle.h:219
void * dmaEnd
Definition battle.h:216
const char * name
Debug SJIS name.
Definition battle.h:196
s32 bActorNames[]
Actor * create_actor(Formation formation)
Definition 190B20.c:1676
char unk_00[0x4]
Definition battle.h:170
s32 * statusTable
Definition battle.h:139
void * dmaStart
Definition battle.h:215
Zero-terminated.
Definition battle.h:195
Zero-terminated.
Definition battle.h:206