Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
player_move.c
Go to the documentation of this file.
1
2#include "states.h"
3#include "script_api/battle.h"
4
5enum {
6 // BTL_SUBSTATE_INIT = 0,
17};
18
21 Actor* player = battleStatus->playerActor;
22 Actor* partner = battleStatus->partnerActor;
23 s32 messageIndex;
24 Actor* actor;
25 Evt* script;
28 s32 i;
29
31 battleStatus->stateFreezeCount = 0;
32 battleStatus->actionResult = ACTION_RESULT_NONE;
33 battleStatus->blockResult = BLOCK_RESULT_NONE;
34 battleStatus->lastAttackDamage = 0;
35 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
40 if (partner != NULL) {
42 }
45 player->statusAfflicted = 0;
48
49 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
50 actor = battleStatus->enemyActors[i];
51 if (actor != NULL) {
52 actor->statusAfflicted = 0;
53 }
54 }
55
56 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
57 actor = battleStatus->enemyActors[i];
58 if (actor != NULL) {
61 }
62 }
63
64 if (battleStatus->moveCategory == BTL_MENU_TYPE_JUMP || battleStatus->moveCategory == BTL_MENU_TYPE_SMASH) {
65 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_ATK_BOOST) {
66 battleStatus->merleeAttackBoost = 3;
67 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
70 player->takeTurnScript = script;
71 player->takeTurnScriptID = script->id;
72 script->owner1.actorID = ACTOR_PLAYER;
76 } else {
79 }
80 } else {
83 }
84 }
85
86 switch (gBattleSubState) {
88 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
89 break;
90 }
91 player->takeTurnScript = NULL;
93 if (battleStatus->selectedMoveID != MOVE_NONE) {
94 tipIndex = gMoveTable[battleStatus->selectedMoveID].actionTip;
95 if (tipIndex >= 0) {
97 }
98 }
99 }
102 break;
104 if (BattleSubstateDelay != 0) {
106 } else {
108 }
109 break;
110 }
111
112 switch (gBattleSubState) {
119 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
122 } else {
124 }
125 player->takeTurnScript = script;
127 player->takeTurnScriptID = script->id;
128 script->owner1.actorID = ACTOR_PLAYER;
129 break;
131 // wait for player battle phase script to finish
133 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
134 break;
135 }
136 player->takeTurnScript = NULL;
137 }
138
140
141 // wait for player battle event script to finish
142 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
143 break;
144 }
145 player->handleEventScript = NULL;
146
147 // wait for partner battle event script to finish
148 if (partner != NULL) {
149 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
150 break;
151 }
152 partner->handleEventScript = NULL;
153 }
154
155 // wait for all enemy battle phase scripts to finish
157 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
158 actor = battleStatus->enemyActors[i];
159 if (actor != NULL && actor->takeTurnScript != NULL) {
162 } else {
163 actor->takeTurnScript = NULL;
164 }
165 }
166 }
167 if (enemyNotDone) {
168 break;
169 }
170
171 // wait for all enemy battle event scripts to finish
173 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
174 actor = battleStatus->enemyActors[i];
175 if (actor != NULL && actor->handleEventScript != NULL) {
178 } else {
179 actor->handleEventScript = NULL;
180 }
181 }
182 }
183 if (enemyNotDone) {
184 break;
185 }
186
187 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
188 actor = battleStatus->enemyActors[i];
189 if (actor != NULL) {
191 }
192 }
193
194 if (battleStatus->stateFreezeCount != 0) {
195 break;
196 }
197
200 break;
201 }
202
207 return;
208 }
209
210 if ((battleStatus->moveCategory == BTL_MENU_TYPE_SMASH)
211 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE0)
212 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE)
213 && (battleStatus->selectedMoveID != MOVE_SUPER_SMASH_CHARGE)
214 ) {
216 }
217
218 if ((battleStatus->moveCategory == BTL_MENU_TYPE_JUMP)
219 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE0)
220 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE)
221 && (battleStatus->selectedMoveID != MOVE_SUPER_JUMP_CHARGE)
222 ) {
224 }
225
227 battleStatus->jumpCharge = 0;
228 }
230 battleStatus->hammerCharge = 0;
231 }
232
233 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
234 actor = battleStatus->enemyActors[i];
235 if (actor != NULL && !(actor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
237 }
238 }
239
241
243 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
244 actor = battleStatus->enemyActors[i];
245 if (actor != NULL) {
246 if (actor->statusAfflicted != 0) {
248 break;
249 }
250 }
251 }
252
253 if (!enemyNotDone) {
255 } else {
257 switch (actor->statusAfflicted) {
258 case STATUS_KEY_DIZZY:
259 messageIndex = BTL_MSG_ENEMY_DAZED;
260 break;
261 case STATUS_KEY_SLEEP:
262 messageIndex = BTL_MSG_ENEMY_ASLEEP;
263 break;
265 messageIndex = BTL_MSG_ENEMY_FROZEN;
266 break;
268 messageIndex = BTL_MSG_ENEMY_POISONED;
269 break;
271 messageIndex = BTL_MSG_ENEMY_SHRUNK;
272 break;
274 messageIndex = BTL_MSG_ENEMY_PARALYZED;
275 break;
277 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
278 break;
279 case STATUS_KEY_STOP:
280 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
281 break;
282 default:
283 messageIndex = 0;
285 break;
286 }
288 btl_show_battle_message(messageIndex, 60);
289 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
290 actor = battleStatus->enemyActors[i];
291 if (actor != NULL) {
292 actor->statusAfflicted = 0;
293 }
294 }
296 }
297 break;
299 if (!btl_is_popup_displayed()) {
301 btl_cam_move(15);
304 }
305 break;
307 if (BattleSubstateDelay != 0) {
309 } else {
311 }
312 break;
313 }
314
315 switch (gBattleSubState) {
317 if (player->statusAfflicted != 0) {
319 switch (player->statusAfflicted) {
320 case STATUS_KEY_DIZZY:
321 messageIndex = BTL_MSG_PLAYER_DAZED;
322 break;
323 case STATUS_KEY_SLEEP:
324 messageIndex = BTL_MSG_PLAYER_ASLEEP;
325 break;
327 messageIndex = BTL_MSG_PLAYER_FROZEN;
328 break;
330 messageIndex = BTL_MSG_PLAYER_POISONED;
331 break;
333 messageIndex = BTL_MSG_PLAYER_SHRUNK;
334 break;
336 messageIndex = BTL_MSG_PLAYER_PARALYZED;
337 break;
339 messageIndex = BTL_MSG_PLAYER_CHARGED;
340 break;
341 default:
342 messageIndex = 0;
344 break;
345 }
346 btl_show_battle_message(messageIndex, 60);
347 player->statusAfflicted = 0;
348 player->disableDismissTimer = 0;
351
352 } else {
354 }
355 break;
357 if (!btl_is_popup_displayed()) {
359 btl_cam_move(15);
362 }
363 break;
365 if (BattleSubstateDelay != 0) {
367 } else {
369 }
370 break;
371 }
372
374 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
375 player->takeTurnScript = NULL;
377 }
378 }
379}
380
BSS s32 PopupMenu_SelectedIndex
BSS s32 BattleSubstateDelay
struct Evt * takeTurnScript
s8 disableDismissTimer
struct Evt * handleEventScript
s32 takeTurnScriptID
s32 handleEventScriptID
s8 statusAfflicted
@ MERLEE_SPELL_ATK_BOOST
Definition enums.h:1937
@ MERLEE_SPELL_NONE
Definition enums.h:1936
@ BS_FLAGS1_10000
Definition enums.h:3618
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3623
@ BS_FLAGS1_JUMP_CHARGED
Definition enums.h:3631
@ BS_FLAGS1_HAMMER_CHARGED
Definition enums.h:3630
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3601
@ BS_FLAGS1_EXECUTING_MOVE
Definition enums.h:3611
@ BTL_MSG_PLAYER_FROZEN
Definition enums.h:3712
@ BTL_MSG_PLAYER_POISONED
Definition enums.h:3713
@ BTL_MSG_PLAYER_PARALYZED
Definition enums.h:3715
@ BTL_MSG_ENEMY_ASLEEP
Definition enums.h:3719
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:3716
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:3711
@ BTL_MSG_ENEMY_POISONED
Definition enums.h:3721
@ BTL_MSG_PLAYER_SHRUNK
Definition enums.h:3714
@ BTL_MSG_ENEMY_CANT_MOVE
Definition enums.h:3725
@ BTL_MSG_ENEMY_PARALYZED
Definition enums.h:3723
@ BTL_MSG_ENEMY_FROZEN
Definition enums.h:3720
@ BTL_MSG_ENEMY_DAZED
Definition enums.h:3718
@ BTL_MSG_FIRST_ACTION_TIP
Definition enums.h:3746
@ BTL_MSG_ENEMY_ELECTRIFIED
Definition enums.h:3724
@ BTL_MSG_ENEMY_SHRUNK
Definition enums.h:3722
@ BTL_MSG_PLAYER_DAZED
Definition enums.h:3710
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3576
@ PHASE_MERLEE_ATTACK_BONUS
Definition enums.h:2103
@ PHASE_EXECUTE_ACTION
Definition enums.h:2091
@ BTL_MENU_TYPE_SMASH
Definition enums.h:3827
@ BTL_MENU_TYPE_JUMP
Definition enums.h:3826
@ BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER
Definition enums.h:3640
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ STATUS_KEY_PARALYZE
Definition enums.h:2806
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_KEY_STATIC
Definition enums.h:2812
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ STATUS_KEY_STOP
Definition enums.h:2809
@ STATUS_KEY_SHRINK
Definition enums.h:2811
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ STATUS_KEY_POISON
Definition enums.h:2810
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4410
@ BTL_CAM_PLAYER_STATUS_AFFLICTED
Definition enums.h:4440
@ BATTLE_STATE_END_DEMO_BATTLE
Definition enums.h:3696
@ BATTLE_STATE_END_PLAYER_TURN
Definition enums.h:3686
@ DMG_SRC_DEFAULT
Definition enums.h:2014
@ ABILITY_BERSERKER
Definition enums.h:457
@ SOUND_INFLICT_KO
Definition enums.h:1548
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3377
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3374
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3376
@ BLOCK_RESULT_NONE
Definition enums.h:1998
@ ACTION_RESULT_NONE
Definition enums.h:1989
@ EVT_PRIORITY_A
Definition evt.h:154
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
void reset_all_actor_sounds(Actor *)
Definition 190B20.c:2670
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void decrement_status_bar_disabled(void)
Definition inventory.c:1656
void btl_update_ko_status(void)
Definition 190B20.c:2601
void reset_actor_turn_info(void)
Definition 190B20.c:710
void close_action_command_instruction_popup(void)
void btl_cam_use_preset(s32)
Definition camera.c:1919
void btl_cam_target_actor(s32)
Definition camera.c:1926
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void btl_show_battle_message(s32 messageIndex, s32 duration)
void btl_cam_move(s16)
Definition camera.c:1953
s32 does_script_exist(s32 id)
void btl_set_state(s32 battleState)
s32 btl_is_popup_displayed(void)
void increment_status_bar_disabled(void)
Definition inventory.c:1664
EvtScript EVS_Peach_HandlePhase
EvtScript EVS_Mario_HandlePhase
void btl_state_draw_player_move(void)
@ BTL_SUBSTATE_SHOW_TIP_DELAY
Definition player_move.c:8
@ BTL_SUBSTATE_BEGIN_SHOW_TIP
Definition player_move.c:7
@ BTL_SUBSTATE_POST_ENEMY_STATUS_POPUP
Definition player_move.c:12
@ BTL_SUBSTATE_AWAIT_PLAYER_STATUS_POPUP
Definition player_move.c:14
@ BTL_SUBSTATE_AWAIT_ENEMY_STATUS_POPUP
Definition player_move.c:11
@ BTL_SUBSTATE_POST_PLAYER_STATUS_POPUP
Definition player_move.c:15
@ BTL_SUBSTATE_EXECUTE_MOVE
Definition player_move.c:9
@ BTL_SUBSTATE_CHECK_PLAYER_STATUS
Definition player_move.c:13
@ BTL_SUBSTATE_AWAIT_DONE
Definition player_move.c:16
@ BTL_SUBSTATE_HANDLE_RESULTS
Definition player_move.c:10
void btl_state_update_player_move(void)
Definition player_move.c:19
void sfx_play_sound(s32 soundID)
#define ARRAY_COUNT(arr)
Definition macros.h:40
@ BTL_SUBSTATE_INIT
Definition states.h:8
GameStatus * gGameStatusPtr
Definition main_loop.c:31
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17
MoveData gMoveTable[]