Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
start_battle.c File Reference

Go to the source code of this file.

Enumerations

enum  { BTL_SUBSTATE_CREATE_ENEMIES = 1 , BTL_SUBSTATE_CHECK_FIRST_STRIKE = 4 , BTL_SUBSTATE_FADE_IN = 7 , BTL_SUBSTATE_DONE = 8 }
 

Functions

void load_stage_assets (Stage *stage)
 
void btl_state_update_normal_start (void)
 
void btl_state_draw_normal_start (void)
 

Variables

ShapeFile gMapShapeData
 
StageListRowgCurrentStagePtr
 
s32 bActorsIgnoreDuringCount []
 
EvtScript EVS_OnBattleInit
 
EvtScript EVS_Mario_OnActorCreate
 
EvtScript EVS_Peach_OnActorCreate
 
EvtScript EVS_MarioEnterStage
 
EvtScript EVS_PeachEnterStage
 
BSS s32 BattleEnemiesCreated
 

Enumeration Type Documentation

◆ anonymous enum

Enumerator
BTL_SUBSTATE_CREATE_ENEMIES 
BTL_SUBSTATE_CHECK_FIRST_STRIKE 
BTL_SUBSTATE_FADE_IN 
BTL_SUBSTATE_DONE 

Definition at line 15 of file start_battle.c.

15 {
16 // BTL_SUBSTATE_INIT = 0,
21};
@ BTL_SUBSTATE_CHECK_FIRST_STRIKE
@ BTL_SUBSTATE_CREATE_ENEMIES
@ BTL_SUBSTATE_DONE
@ BTL_SUBSTATE_FADE_IN

Function Documentation

◆ load_stage_assets()

void load_stage_assets ( Stage * stage)

Definition at line 25 of file start_battle.c.

25 {
26 void* compressedAsset;
29 s32 size;
30
34
35 ASSERT(size <= 0x8000);
36
39 if (rootModel != NULL) {
41 }
43
44 if (stage->bg != NULL) {
45 load_map_bg(stage->bg);
47 }
48}
BSS s32 PopupMenu_SelectedIndex
#define ASSERT(condition)
void * load_asset_by_name(const char *assetName, u32 *decompressedSize)
Definition world.c:251
void set_background(BackgroundHeader *)
Definition background.c:40
void load_battle_hit_asset(const char *hitName)
Definition collision.c:166
void load_data_for_models(struct ModelNode *model, s32 romOffset, s32 size)
Definition model.c:3318
void load_map_bg(char *optAssetName)
Definition background.c:14
s32 get_asset_offset(char *, s32 *)
Definition world.c:273
s32 general_heap_free(void *data)
Definition heap.c:18
void decode_yay0(void *src, void *dst)
ModelNode * root
Definition model.h:174
ShapeFileHeader header
Definition model.h:183
char * texture
Definition battle.h:182
const char * shape
Definition battle.h:183
const char * hit
Definition battle.h:184
char * bg
Definition battle.h:187
ShapeFile gMapShapeData
Definition heaps.c:16
BackgroundHeader gBackgroundImage

Referenced by btl_state_update_normal_start().

◆ btl_state_update_normal_start()

void btl_state_update_normal_start ( void )

Definition at line 50 of file start_battle.c.

50 {
54 Stage* stage;
55 Actor* actor;
56 Evt* script;
58 s32 type;
59 s32 i;
60 s32 j;
61
62 s32* types;
63
65 if (gOverrideBattlePtr != NULL) {
67 }
68
69 if (gCurrentStagePtr == NULL) {
70 stage = battle->stage;
71 } else {
72 stage = gCurrentStagePtr->stage;
73 }
74
75 battleStatus->curStage = stage;
76 switch (gBattleSubState) {
78 #if DX_DEBUG_MENU
80 #endif
81
82 BattleEnemiesCreated = battle->formationSize;
84
85 load_stage_assets(stage);
86
89 }
90
91 battleStatus->controlScript = NULL;
92 battleStatus->camMovementScript = NULL;
93 battleStatus->unk_90 = 0;
94 battleStatus->preUpdateCallback = NULL;
95 battleStatus->initBattleCallback = NULL;
96 battleStatus->curSubmenu = 0;
97 battleStatus->lastSelectedAbility = 0;
98 battleStatus->curPartnerSubmenu = 0;
99 battleStatus->lastPartnerPowerSelection = 0;
100 battleStatus->totalStarPoints = 0;
101 battleStatus->pendingStarPoints = 0;
102 battleStatus->incrementStarPointDelay = 0;
103 battleStatus->damageTaken = 0;
104 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
105 battleStatus->actionCommandMode = AC_MODE_NOT_LEARNED;
110 battleStatus->actionCommandMode = AC_MODE_LEARNED;
111 }
112 battleStatus->actionQuality = 0;
113 battleStatus->maxActionQuality = 0;
114 battleStatus->enabledMenusFlags = -1;
115 battleStatus->enabledStarPowersFlags = -1;
116 battleStatus->itemUsesLeft = 0;
117 battleStatus->hammerCharge = 0;
118 battleStatus->jumpCharge = 0;
119 battleStatus->unk_98 = 0;
120 battleStatus->hpDrainCount = 0;
122 if (currentEncounter->forbidFleeing) {
124 }
125 battleStatus->endBattleFadeOutRate = 10;
126 battleStatus->waitForState = BATTLE_STATE_NONE;
127 battleStatus->hammerLossTurns = -1;
128 battleStatus->jumpLossTurns = -1;
129 battleStatus->itemLossTurns = -1;
130 battleStatus->outtaSightActive = 0;
131 battleStatus->waterBlockTurnsLeft = 0;
132 battleStatus->waterBlockAmount = 0;
133 battleStatus->waterBlockEffect = NULL;
134 battleStatus->cloudNineTurnsLeft = 0;
135 battleStatus->cloudNineDodgeChance = 0;
136 battleStatus->cloudNineEffect = NULL;
137 battleStatus->reflectFlags = 0;
138 battleStatus->turboChargeTurnsLeft = 0;
139 battleStatus->turboChargeAmount = 0;
140 battleStatus->stateFreezeCount = 0;
141 battleStatus->merleeAttackBoost = 0;
142 battleStatus->merleeDefenseBoost = 0;
144 battleStatus->unk_433 = -1;
145 battleStatus->hustleTurns = 0;
146 battleStatus->nextActorOrdinal = 0;
147 battleStatus->cancelTurnMode = 0;
154
155 for (i = 0; i < ARRAY_COUNT(battleStatus->varTable); i++) {
156 battleStatus->varTable[i] = 0;
157 }
158
160 battleStatus->inputBitmask = 0xFFFFF & ~(BUTTON_START | 0xC0);
161 battleStatus->buffEffect = fx_partner_buff(0, 0.0f, 0.0f, 0.0f, 0.0f, 0);
165 battleStatus->camMovementScript = script;
166 battleStatus->camMovementScriptID = script->id;
168 break;
170 // wait for camera initialization to finish
171 if (does_script_exist(battleStatus->camMovementScriptID)) {
172 break;
173 }
174
175 if (stage->preBattle != NULL) {
177 battleStatus->controlScript = script;
178 battleStatus->controlScriptID = script->id;
179 }
180
183
184 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
185 battleStatus->enemyActors[i] = NULL;
186 }
187 battleStatus->initialEnemyCount = 0;
188
189 for (i = 0; i < BattleEnemiesCreated; i++) {
190 create_actor(&(*battle->formation)[i]);
192 actor = battleStatus->enemyActors[i];
193
194 while (TRUE) {
195 type = *types;
196 if (type == -1) {
197 battleStatus->initialEnemyCount++;
198 break;
199 } else if (actor->actorType == type) {
200 break;
201 }
202 types++;
203 }
204
205 actor->instigatorValue = 0;
206 if (i == 0) {
207 actor->instigatorValue = currentEncounter->instigatorValue;
208 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
210 }
211 }
212 }
213
214 if (stage->stageEnemyCount != 0) {
215 if (stage->stageEnemyChance == 0 || (stage->stageEnemyChance > 0 && (rand_int(stage->stageEnemyChance) == 0))) {
217 for (j = 0; i < BattleEnemiesCreated; i++, j++) {
218 create_actor(&(*stage->stageFormation)[j]);
219 actor = battleStatus->enemyActors[i];
220 actor->instigatorValue = 0;
221 if (i == 0) {
222 actor->instigatorValue = 0;
223 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
225 }
226 }
227
228 }
229 }
230 }
231
233 actor = battleStatus->playerActor;
236 } else {
238 }
239 actor->takeTurnScript = script;
240 actor->takeTurnScriptID = script->id;
241 script->owner1.actorID = ACTOR_PLAYER;
244 break;
247 for (i = 0; i < BattleEnemiesCreated; i++) {
248 actor = battleStatus->enemyActors[i];
251 break;
252 } else {
253 actor->takeTurnScript = NULL;
254 }
255 }
256 if (enemyNotDone) {
257 break;
258 }
259
260 actor = battleStatus->playerActor;
262 break;
263 }
264 actor->takeTurnScript = NULL;
265
266 actor = battleStatus->partnerActor;
267 if (actor != NULL) {
269 break;
270 }
271 actor->takeTurnScript = NULL;
272 }
273
274 if (battle->onBattleStart != NULL) {
275 script = start_script(battle->onBattleStart, EVT_PRIORITY_A, 0);
276 battleStatus->controlScript = script;
277 battleStatus->controlScriptID = script->id;
278 }
279 if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) {
282 }
284 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
285 }
286
287 switch (currentEncounter->firstStrikeType) {
290 break;
293 break;
294 default:
296 actor = battleStatus->playerActor;
299 } else {
301 }
302 actor->takeTurnScript = script;
303 actor->takeTurnScriptID = script->id;
304 script->owner1.actorID = ACTOR_PLAYER;
305 }
306
307 if (currentEncounter->curEnemy != NULL
308 && currentEncounter->curEnemy->encountered == ENCOUNTER_TRIGGER_SPIN
310 ) {
311 actor = battleStatus->enemyActors[0];
313 actor->takeTurnScript = script;
314 actor->takeTurnScriptID = script->id;
315 script->owner1.enemyID = ACTOR_ENEMY0;
316 }
317
321 break;
322 }
323 break;
325 if (BattleScreenFadeAmt == 0) {
327 break;
328 }
329
331 if (BattleSubstateDelay == 15) {
333 }
334
337 } else {
339 }
340
341 if (BattleScreenFadeAmt < 0) {
343 }
344 break;
346 if (battleStatus->stateFreezeCount == 0) {
349 }
350 break;
351 }
352}
s32 BattleScreenFadeAmt
Definition 16C8E0.c:50
Actor * create_actor(Formation formation)
Definition 190B20.c:1408
@ AC_MODE_NOT_LEARNED
Definition action_cmd.h:60
@ AC_MODE_LEARNED
Definition action_cmd.h:61
BSS Battle * gCurrentBattlePtr
Definition battle.cpp:22
BSS s32 BattleSubstateDelay
struct Evt * takeTurnScript
s32 takeTurnScriptID
s8 instigatorValue
#define rand_int
@ MERLEE_SPELL_NONE
Definition enums.h:1936
@ OVERLAY_NONE
Definition enums.h:2373
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2374
@ BUTTON_START
Definition enums.h:2773
@ BS_FLAGS1_ACTORS_VISIBLE
Definition enums.h:3598
@ SCREEN_LAYER_BACK
Definition enums.h:2369
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3576
@ CAMERA_FLAG_DISABLED
Definition enums.h:4306
@ BS_FLAGS2_CAN_FLEE
Definition enums.h:3642
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ ENCOUNTER_TRIGGER_SPIN
Definition enums.h:270
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2837
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BATTLE_STATE_ENEMY_FIRST_STRIKE
Definition enums.h:3668
@ BATTLE_STATE_FIRST_STRIKE
Definition enums.h:3666
@ BATTLE_STATE_BEGIN_TURN
Definition enums.h:3669
@ BATTLE_STATE_NONE
Definition enums.h:3664
@ ABILITY_CHILL_OUT
Definition enums.h:453
@ ABILITY_DIZZY_ATTACK
Definition enums.h:481
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_ENEMY0
Definition enums.h:2120
@ FIRST_STRIKE_NONE
Definition enums.h:3492
@ FIRST_STRIKE_ENEMY
Definition enums.h:3494
@ FIRST_STRIKE_PLAYER
Definition enums.h:3493
@ BTL_DARKNESS_STATE_NONE
Definition enums.h:5950
@ CAM_TATTLE
Definition enums.h:1828
@ CAM_DEFAULT
Definition enums.h:1826
@ CAM_BATTLE
Definition enums.h:1827
@ EVT_PRIORITY_A
Definition evt.h:154
void load_partner_actor(void)
Definition 190B20.c:1154
void set_screen_overlay_params_back(u8, f32)
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
void setup_status_bar_for_battle(void)
Definition inventory.c:1471
void set_screen_overlay_params_front(u8, f32)
void btl_cam_use_preset(s32)
Definition camera.c:1919
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void set_screen_overlay_color(s32, u8, u8, u8)
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2313
s32 does_script_exist(s32 id)
void load_player_actor(void)
Definition 190B20.c:940
void btl_set_state(s32 battleState)
void set_curtain_scale_goal(f32 scale)
Definition curtains.c:285
EvtScript EVS_ApplyDizzyAttack
EncounterStatus gCurrentEncounter
Definition encounter.c:175
#define ARRAY_COUNT(arr)
Definition macros.h:40
EvtScript * preBattle
Definition battle.h:185
Formation * stageFormation
Definition battle.h:190
s32 stageEnemyChance
Definition battle.h:191
Stage * stage
Definition battle.h:208
s32 stageEnemyCount
Definition battle.h:189
Zero-terminated.
Definition battle.h:195
BSS s32 BattleEnemiesCreated
EvtScript EVS_PeachEnterStage
EvtScript EVS_Peach_OnActorCreate
StageListRow * gCurrentStagePtr
Definition battle.cpp:12
void load_stage_assets(Stage *stage)
EvtScript EVS_MarioEnterStage
s32 bActorsIgnoreDuringCount[]
EvtScript EVS_OnBattleInit
Definition camera.c:1171
EvtScript EVS_Mario_OnActorCreate
@ BTL_SUBSTATE_INIT
Definition states.h:8
s32 gCurrentBattleID
Definition battle.cpp:19
GameStatus * gGameStatusPtr
Definition main_loop.c:31
struct Battle * gOverrideBattlePtr
Definition battle.cpp:21
Camera gCameras[4]
Definition cam_main.c:16
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gCurrentCameraID
Definition cam_math.c:5
s32 gCurrentStageID
Definition battle.cpp:20
s32 gBattleSubState
Definition battle.cpp:17
StatusBar gStatusBar
Definition inventory.c:22

Referenced by btl_update().

◆ btl_state_draw_normal_start()

void btl_state_draw_normal_start ( void )

Definition at line 354 of file start_battle.c.

Referenced by btl_draw_ui().

Variable Documentation

◆ gMapShapeData

ShapeFile gMapShapeData
extern

Definition at line 16 of file heaps.c.

Referenced by load_stage_assets().

◆ gCurrentStagePtr

StageListRow* gCurrentStagePtr
extern

◆ bActorsIgnoreDuringCount

s32 bActorsIgnoreDuringCount[]
extern

◆ EVS_OnBattleInit

EvtScript EVS_OnBattleInit
extern

Definition at line 1171 of file camera.c.

1171 {
1173 Call(SetCamViewport, CAM_BATTLE, 12, 20, 296, 200)
1174 Call(SetCamBGColor, CAM_BATTLE, 0, 0, 0)
1176 Wait(1)
1180 Call(SetCamLookTarget, CAM_BATTLE, -75, 35, 0)
1183 Return
1184 End
1185};
@ CAM_UPDATE_NO_INTERP
Definition enums.h:4346
ApiStatus SetCamEnabled(Evt *script, b32 isInitialCall)
ApiStatus SetCamViewport(Evt *script, b32 isInitialCall)
ApiStatus InitVirtualEntityList(Evt *script, b32 isInitialCall)
ApiStatus InitAnimatedModels(Evt *script, b32 isInitialCall)
ApiStatus SetCamLookTarget(Evt *script, b32 isInitialCall)
ApiStatus SetCamBGColor(Evt *script, b32 isInitialCall)
ApiStatus SetNoInterpCamParams(Evt *script, b32 isInitialCall)
ApiStatus SetCamPerspective(Evt *script, b32 isInitialCall)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:214
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:255
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:577
#define Return
Kills the current EVT thread.
Definition macros.h:218

Referenced by btl_state_update_normal_start().

◆ EVS_Mario_OnActorCreate

EvtScript EVS_Mario_OnActorCreate
extern

Definition at line 662 of file player_events.c.

662 {
663 Return
664 End
665};

Referenced by btl_state_update_normal_start().

◆ EVS_Peach_OnActorCreate

EvtScript EVS_Peach_OnActorCreate
extern

Definition at line 667 of file player_events.c.

667 {
668 Return
669 End
670};

Referenced by btl_state_update_normal_start().

◆ EVS_MarioEnterStage

EvtScript EVS_MarioEnterStage
extern

Definition at line 672 of file player_events.c.

672 {
674 Call(SetBattleCamTarget, -80, 35, 8)
677 Sub(LVar0, 100)
679 Call(RandInt, 100, LVar0)
681 CaseGt(50)
686 CaseGt(20)
691 Call(PlayerHopToGoal, 18, 0, 0)
693 Wait(7)
701 Call(ShakeCam, 1, 0, 5, Float(1.0))
705 Wait(10)
707 Wait(10)
710 Return
711 End
712};
@ BTL_CAM_PLAYER_ENTRY
Definition enums.h:4429
@ SOUND_TRIP
Definition enums.h:787
@ ACTOR_SELF
Definition enums.h:2117
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:312
#define EndChildThread
Marks the end of a child thread block.
Definition macros.h:564
#define Sub(VAR, INT_VALUE)
Definition macros.h:378
#define Float(DOUBLE)
Definition macros.h:52
#define CaseDefault
Marks the start of a switch case that executes unconditionally. It also marks the end of any previous...
Definition macros.h:338
#define LVar2
Definition macros.h:151
#define LVar1
Definition macros.h:150
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:363
#define ChildThread
Marks the start of a child thread block.
Definition macros.h:561
#define CaseGt(RVAR)
Marks the start of a switch case that executes only if LVAR <= RVAR. It also marks the end of any pre...
Definition macros.h:329
#define LVar0
Definition macros.h:149

Referenced by btl_state_update_normal_start().

◆ EVS_PeachEnterStage

◆ BattleEnemiesCreated

BSS s32 BattleEnemiesCreated

Definition at line 23 of file start_battle.c.

Referenced by btl_state_update_normal_start().