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

Go to the source code of this file.

Enumerations

enum  {
  BTL_SUBSTATE_TRY_COMMAND_RECOVER = 1 , BTL_SUBSTATE_AWAIT_WATER_BLOCK = 2 , BTL_SUBSTATE_CHECK_WATER_BLOCK = 10 , BTL_SUBSTATE_CHECK_CLOUD_NINE = 11 ,
  BTL_SUBSTATE_AWAIT_CLOUD_NINE = 12 , BTL_SUBSTATE_CHECK_TURBO_CHARGE = 15 , BTL_SUBSTATE_AWAIT_TURBO_CHARGE = 16 , BTL_SUBSTATE_AWAIT_OUTTA_SIGHT = 20 ,
  BTL_SUBSTATE_TRY_STATUS_DAMAGE = 21 , BTL_SUBSTATE_TRY_STATUS_RECOVER = 22 , BTL_SUBSTATE_END_DELAY = 30 , BTL_SUBSTATE_RESET_STATE = 100
}
 

Functions

b32 dispatch_damage_tick_event_player (s32 damageAmount, s32 event)
 
void update_water_block (void)
 
void update_cloud_nine (void)
 
void update_turbo_charge (void)
 
void update_status_damage (void)
 
void update_command_loss (void)
 
void btl_state_update_begin_player_turn (void)
 
void btl_state_draw_begin_player_turn (void)
 

Enumeration Type Documentation

◆ anonymous enum

Enumerator
BTL_SUBSTATE_TRY_COMMAND_RECOVER 
BTL_SUBSTATE_AWAIT_WATER_BLOCK 
BTL_SUBSTATE_CHECK_WATER_BLOCK 
BTL_SUBSTATE_CHECK_CLOUD_NINE 
BTL_SUBSTATE_AWAIT_CLOUD_NINE 
BTL_SUBSTATE_CHECK_TURBO_CHARGE 
BTL_SUBSTATE_AWAIT_TURBO_CHARGE 
BTL_SUBSTATE_AWAIT_OUTTA_SIGHT 
BTL_SUBSTATE_TRY_STATUS_DAMAGE 
BTL_SUBSTATE_TRY_STATUS_RECOVER 
BTL_SUBSTATE_END_DELAY 
BTL_SUBSTATE_RESET_STATE 

Definition at line 6 of file player_turn_begin.c.

6 {
7 // BTL_SUBSTATE_INIT = 0,
20};
@ BTL_SUBSTATE_TRY_STATUS_DAMAGE
@ BTL_SUBSTATE_CHECK_TURBO_CHARGE
@ BTL_SUBSTATE_AWAIT_WATER_BLOCK
@ BTL_SUBSTATE_AWAIT_CLOUD_NINE
@ BTL_SUBSTATE_RESET_STATE
@ BTL_SUBSTATE_AWAIT_TURBO_CHARGE
@ BTL_SUBSTATE_CHECK_WATER_BLOCK
@ BTL_SUBSTATE_AWAIT_OUTTA_SIGHT
@ BTL_SUBSTATE_TRY_STATUS_RECOVER
@ BTL_SUBSTATE_CHECK_CLOUD_NINE
@ BTL_SUBSTATE_TRY_COMMAND_RECOVER
@ BTL_SUBSTATE_END_DELAY

Function Documentation

◆ dispatch_damage_tick_event_player()

b32 dispatch_damage_tick_event_player ( s32 damageAmount,
s32 event )

Definition at line 1127 of file dmg_player.c.

1127 {
1129
1131 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
1133}
BSS s32 PopupMenu_SelectedIndex
b32 dispatch_damage_event_player(s32 damageAmount, s32 event, b32 noHitSound)
@ ELEMENT_END
Definition enums.h:2147
@ DMG_SRC_DEFAULT
Definition enums.h:2014
BattleStatus gBattleStatus
Definition battle.cpp:14

Referenced by update_status_damage().

◆ update_water_block()

void update_water_block ( void )

Definition at line 22 of file player_turn_begin.c.

22 {
24 Actor* player = battleStatus->playerActor;
25
26 switch (gBattleSubState) {
28 // allow state to be frozen here
29 if (battleStatus->stateFreezeCount != 0) {
30 return;
31 }
32
33 // is water block active?
34 if (battleStatus->waterBlockTurnsLeft == 0) {
36 return;
37 }
38
39 // decrement buff duration by 1 turn
40 battleStatus->waterBlockTurnsLeft--;
41 battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_WATER_BLOCK].turnsLeft = battleStatus->waterBlockTurnsLeft;
42 if (battleStatus->waterBlockTurnsLeft > 0) {
44 return;
45 }
46
47 // buff has ended
48 battleStatus->waterBlockEffect->flags |= FX_INSTANCE_FLAG_DISMISS;
49 fx_water_block(FX_WATER_BLOCK_DESTROY, player->curPos.x, player->curPos.y + 18.0f, player->curPos.z + 5.0f, 1.5f, 10);
50 fx_water_splash(0, player->curPos.x - 10.0f, player->curPos.y + 5.0f, player->curPos.z + 5.0f, 1.0f, 24);
51 fx_water_splash(0, player->curPos.x - 15.0f, player->curPos.y + 32.0f, player->curPos.z + 5.0f, 1.0f, 24);
52 fx_water_splash(1, player->curPos.x + 15.0f, player->curPos.y + 22.0f, player->curPos.z + 5.0f, 1.0f, 24);
53 battleStatus->waterBlockEffect = NULL;
55
56 // new substate will wait for popup to go away
59 break;
60
63 return;
64 }
66 break;
67 }
68}
Vec3f curPos
@ FX_BUFF_DATA_WATER_BLOCK
Definition effects.h:2318
@ FX_WATER_BLOCK_DESTROY
Definition effects.h:1540
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3551
@ BTL_MSG_WATER_BLOCK_END
Definition enums.h:3739
@ SOUND_DESTROY_WATER_BLOCK
Definition enums.h:1018
void btl_show_battle_message(s32 messageIndex, s32 duration)
s32 btl_is_popup_displayed(void)
void sfx_play_sound(s32 soundID)
s32 gBattleSubState
Definition battle.cpp:17

Referenced by btl_state_update_begin_player_turn().

◆ update_cloud_nine()

void update_cloud_nine ( void )

Definition at line 70 of file player_turn_begin.c.

70 {
72
73 switch (gBattleSubState) {
75 // is could nine active?
76 if (battleStatus->cloudNineTurnsLeft == 0) {
78 return;
79 }
80
81 // decrement buff duration by 1 turn
83 battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_CLOUD_NINE].turnsLeft = battleStatus->cloudNineTurnsLeft;
84 if (battleStatus->cloudNineTurnsLeft > 0) {
86 return;
87 }
88
89 // buff has ended
90 remove_effect(battleStatus->cloudNineEffect);
91 battleStatus->cloudNineEffect = NULL;
92
93 // new substate will wait for popup to go away
96 break;
97
100 return;
101 }
103 break;
104 }
105}
#define remove_effect
@ FX_BUFF_DATA_CLOUD_NINE
Definition effects.h:2319
@ BTL_MSG_CLOUD_NINE_END
Definition enums.h:3741

Referenced by btl_state_update_begin_player_turn().

◆ update_turbo_charge()

void update_turbo_charge ( void )

Definition at line 107 of file player_turn_begin.c.

107 {
109
110 switch (gBattleSubState) {
112 // is turbo charge active?
113 if (battleStatus->turboChargeTurnsLeft == 0) {
115 return;
116 }
117
118 // consume the 'stored' turn if player was buffed after theyd used their turn
122 return;
123 }
124
125 // decrement buff duration by 1 turn
126 battleStatus->turboChargeTurnsLeft--;
127 battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_TURBO_CHARGE].turnsLeft = battleStatus->turboChargeTurnsLeft;
128 if (battleStatus->turboChargeTurnsLeft > 0) {
130 return;
131 }
132
133 // new substate will wait for popup to go away
136 break;
137
140 return;
141 }
143 break;
144 }
145}
@ FX_BUFF_DATA_TURBO_CHARGE
Definition effects.h:2320
@ BTL_MSG_TURBO_CHARGE_END
Definition enums.h:3743
@ BS_FLAGS2_STORED_TURBO_CHARGE_TURN
Definition enums.h:3644

Referenced by btl_state_update_begin_player_turn().

◆ update_status_damage()

void update_status_damage ( void )

Definition at line 147 of file player_turn_begin.c.

147 {
149 Actor* player = battleStatus->playerActor;
150 ActorPart* part = &player->partsTable[0];
151 s8 debuffDuration;
152 s32 koDuration;
154 s32 i;
155
157 if (player->debuff == STATUS_KEY_POISON && player->stoneStatus == 0) {
160 }
161
162 // clear rush flags to initialize
163 battleStatus->rushFlags = RUSH_FLAG_NONE;
165
166 // set rush flags based on danger/peril status
170 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
171 }
173 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
175 battleStatus->rushFlags |= RUSH_FLAG_POWER;
176 }
177 }
178 }
180 }
181
183 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
184 player->handleEventScript = NULL;
186 return;
187 }
188
190 player->disableDismissTimer = 0;
192
194 if (player->debuff != 0) {
195 player->debuffDuration = 1;
196 }
197 if (player->staticStatus != 0) {
198 player->staticDuration = 1;
199 }
200 if (player->stoneStatus != 0) {
201 player->stoneDuration = 1;
202 }
203 if (player->koStatus != 0) {
204 player->koDuration = 1;
205 }
206 if (player->transparentStatus != 0) {
207 player->transparentDuration = 1;
208 }
209 }
210
211 if (player->stoneStatus != 0) {
212 player->stoneDuration--;
213 if (player->stoneDuration <= 0) {
214 player->stoneStatus = 0;
216 }
217 } else {
218 if (!is_ability_active(ABILITY_ZAP_TAP) && player->staticStatus != 0) {
219 player->staticDuration--;
220 if (player->staticDuration <= 0) {
221 player->staticStatus = 0;
223 }
224 }
225 if (player->transparentStatus != 0) {
226 player->transparentDuration--;
228 if (player->transparentDuration <= 0) {
229 player->transparentStatus = 0;
232 }
233 }
234
235 if (player->debuff != 0) {
236 if (player->debuff <= STATUS_KEY_POISON) {
238 }
240 player->debuffDuration--;
241 if (player->debuffDuration <= 0) {
242 if (player->debuff == STATUS_KEY_FROZEN) {
245 player->icePillarEffect = NULL;
247 } else {
249 }
250 player->debuff = 0;
251 player->debuffDuration = 0;
253 }
254 }
255
256 debuffDuration = player->debuffDuration;
257 prevDuration = player->koDuration;
258 player->koDuration = debuffDuration;
259 if (debuffDuration > 0) {
260 player->koStatus = STATUS_KEY_KO;
261 player->disableEffect->data.disableX->koDuration = player->koDuration;
262 } else if (prevDuration != debuffDuration) {
263 player->koStatus = 0;
264 player->koDuration = 0;
266 }
267 }
268
269 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
270 Actor* enemy = battleStatus->enemyActors[i];
271
272 if (enemy != NULL) {
274 if (enemy->chillOutTurns != 0) {
275 enemy->chillOutTurns--;
276 if (enemy->chillOutTurns == 0) {
277 enemy->chillOutAmount = 0;
280 }
281 }
282 }
283 }
285 }
286 }
287}
BSS s32 BattleStatusUpdateDelay
BSS b32 BattleSkipActorTurn
struct EffectInstance * disableEffect
s8 transparentStatus
s8 disableDismissTimer
struct Evt * handleEventScript
struct ActorPart * partsTable
struct EffectInstance * icePillarEffect
s8 chillOutAmount
s32 handleEventScriptID
s16 hudElementDataIndex
s8 staticDuration
s8 debuffDuration
s8 transparentDuration
struct DisableXFXData * disableX
Definition effects.h:2529
EffectInstanceDataPtr data
Definition effects.h:2605
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3608
@ RUSH_FLAG_NONE
Definition enums.h:4915
@ RUSH_FLAG_MEGA
Definition enums.h:4916
@ RUSH_FLAG_POWER
Definition enums.h:4917
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3654
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_KEY_KO
Definition enums.h:2814
@ STATUS_KEY_POISON
Definition enums.h:2810
@ ABILITY_FEELING_FINE
Definition enums.h:450
@ ABILITY_POWER_RUSH
Definition enums.h:466
@ ABILITY_MEGA_RUSH
Definition enums.h:456
@ ABILITY_ZAP_TAP
Definition enums.h:455
@ SOUND_FROZEN_SHATTER
Definition enums.h:725
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3377
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3376
@ EVENT_HIT
Definition enums.h:2165
@ EVENT_RECOVER_STATUS
Definition enums.h:2200
@ EVENT_RECOVER_FROZEN
Definition enums.h:2201
@ ACTOR_PART_FLAG_TRANSPARENT
Definition enums.h:3391
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
void remove_status_debuff(s32)
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void remove_status_static(s32)
void remove_status_transparent(s32)
void dispatch_event_player(s32)
Definition dmg_player.c:131
s32 does_script_exist(s32 id)
void remove_status_chill_out(s32)
b32 dispatch_damage_tick_event_player(s32 damageAmount, s32 event)
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PERIL_THRESHOLD
Definition battle.h:277
#define DANGER_THRESHOLD
Definition battle.h:276
PlayerData gPlayerData
Definition 77480.c:39

Referenced by btl_state_update_begin_player_turn().

◆ update_command_loss()

void update_command_loss ( void )

Definition at line 289 of file player_turn_begin.c.

289 {
291 Actor* player = battleStatus->playerActor;
292 Evt* script;
294
297 return;
298 }
300 battleStatus->stateFreezeCount = 0;
301 if (battleStatus->hammerLossTurns >= 0) {
302 battleStatus->hammerLossTurns--;
303 if (battleStatus->hammerLossTurns == -1) {
305 player->takeTurnScript = script;
306 player->takeTurnScriptID = script->id;
307 script->owner1.actorID = ACTOR_PLAYER;
308 script->varTable[0] = itemSpawnOffsetX;
309 itemSpawnOffsetX += 8;
310 script->varTable[10] = BTL_MENU_TYPE_SMASH;
311 battleStatus->stateFreezeCount = 1;
312 }
313 }
314
315 if (battleStatus->jumpLossTurns >= 0) {
316 battleStatus->jumpLossTurns--;
317 if (battleStatus->jumpLossTurns == -1) {
319 player->takeTurnScript = script;
320 player->takeTurnScriptID = script->id;
321 script->owner1.actorID = ACTOR_PLAYER;
322 script->varTable[0] = itemSpawnOffsetX;
323 itemSpawnOffsetX += 8;
324 script->varTable[10] = BTL_MENU_TYPE_JUMP;
325 battleStatus->stateFreezeCount = 1;
326 }
327 }
328
329 if (battleStatus->itemLossTurns >= 0) {
330 battleStatus->itemLossTurns--;
331 if (battleStatus->itemLossTurns == -1) {
333 player->takeTurnScript = script;
334 player->takeTurnScriptID = script->id;
335 script->owner1.actorID = ACTOR_PLAYER;
336 script->varTable[0] = itemSpawnOffsetX;
337 itemSpawnOffsetX += 8;
338 script->varTable[10] = BTL_MENU_TYPE_ITEMS;
339 battleStatus->stateFreezeCount = 1;
340 }
341 }
343 }
344}
struct Evt * takeTurnScript
s32 takeTurnScriptID
@ BTL_MENU_TYPE_SMASH
Definition enums.h:3827
@ BTL_MENU_TYPE_JUMP
Definition enums.h:3826
@ BTL_MENU_TYPE_ITEMS
Definition enums.h:3828
@ ACTOR_PLAYER
Definition enums.h:2118
@ EVT_PRIORITY_A
Definition evt.h:154
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653
EvtScript EVS_PlayerRegainAbility

Referenced by btl_state_update_begin_player_turn().

◆ btl_state_update_begin_player_turn()

void btl_state_update_begin_player_turn ( void )

Definition at line 346 of file player_turn_begin.c.

346 {
348 Actor* player = battleStatus->playerActor;
349 Actor* partner = battleStatus->partnerActor;
350 Evt* script;
351
354 btl_cam_move(5);
356 }
357
358 switch (gBattleSubState) {
363 battleStatus->actionResult = ACTION_RESULT_NONE;
364 battleStatus->blockResult = BLOCK_RESULT_NONE;
365 battleStatus->selectedMoveID = 0;
368 player->disableDismissTimer = 0;
370
371 if (partner != NULL) {
373 partner->disableDismissTimer = 0;
374 }
375
376 battleStatus->stateFreezeCount = 0;
379
380 if (battleStatus->outtaSightActive != 0) {
381 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
382 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
383 partner->handlePhaseScript = script;
385 partner->handlePhaseScriptID = script->id;
386 script->owner1.actorID = ACTOR_PARTNER;
387 } else {
389 }
390 }
391 break;
393 if (!does_script_exist(partner->handlePhaseScriptID)) {
394 battleStatus->outtaSightActive = 0;
397 }
398 break;
399 }
400
404
407
409 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
410 player->handleEventScript = NULL;
411
413 return;
414 }
415
416 if (BattleStatusUpdateDelay != 0) {
418 return;
419 }
420
424 } else{
426 }
427 }
428 }
429}
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3601
@ PHASE_ENEMY_BEGIN
Definition enums.h:2101
@ BS_FLAGS2_PLAYER_TURN_USED
Definition enums.h:3638
@ BS_FLAGS2_PARTNER_TURN_USED
Definition enums.h:3639
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BATTLE_STATE_BEGIN_PARTNER_TURN
Definition enums.h:3672
@ BATTLE_STATE_SWITCH_TO_PLAYER
Definition enums.h:3674
@ ACTOR_PARTNER
Definition enums.h:2119
@ BLOCK_RESULT_NONE
Definition enums.h:1998
@ ACTION_RESULT_NONE
Definition enums.h:1989
void reset_actor_turn_info(void)
Definition 190B20.c:710
void btl_cam_use_preset(s32)
Definition camera.c:1919
void btl_cam_move(s16)
Definition camera.c:1953
s32 btl_cam_is_moving_done(void)
Definition camera.c:1980
void btl_set_state(s32 battleState)
void update_turbo_charge(void)
void update_cloud_nine(void)
void update_water_block(void)
void update_status_damage(void)
void update_command_loss(void)
@ BTL_SUBSTATE_INIT
Definition states.h:8

Referenced by btl_update().

◆ btl_state_draw_begin_player_turn()

void btl_state_draw_begin_player_turn ( void )

Definition at line 431 of file player_turn_begin.c.

431 {
432}

Referenced by btl_draw_ui().