Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
player_first_strike.c
Go to the documentation of this file.
1#include "states.h"
2#include "script_api/battle.h"
3
4enum {
5 // BTL_SUBSTATE_INIT = 0,
9};
10
12
19 Evt* script;
20 Actor* enemy;
22 s32 i;
23
24 switch (gBattleSubState) {
28 if (playerData->playerFirstStrikes < 9999) {
29 playerData->playerFirstStrikes++;
30 }
31
32 // clear rush flags to initialize
33 battleStatus->rushFlags = RUSH_FLAG_NONE;
35
36 // set rush flags based on danger/peril status
40 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
41 }
43 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
45 battleStatus->rushFlags |= RUSH_FLAG_POWER;
46 }
47 }
48 }
49
50 // setup dummy 'menu selection' for player move
51 switch (encounterStatus->hitType) {
53 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
54 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_JUMP;
55 battleStatus->moveArgument = encounterStatus->hitTier;
57 break;
59 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
60 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_HAMMER;
61 battleStatus->moveArgument = encounterStatus->hitTier;
63 break;
66 return;
67 }
68 // let the enemy know a first strike is coming
69 enemy = get_actor(ACTOR_ENEMY0);
70 if (enemy->handleEventSource != NULL) {
74 enemy->handleEventScriptID = script->id;
75 script->owner1.actorID = enemy->actorID;
76 }
78 break;
80 enemy = get_actor(ACTOR_ENEMY0);
81 if (enemy->handleEventSource != NULL) {
83 break;
84 } else {
85 enemy->handleEventScript = NULL;
86 }
87 }
88
89 func_80263230(player, enemy);
90 battleStatus->stateFreezeCount = 0;
91 battleStatus->lastAttackDamage = 0;
92 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
100 // begin the player turn script
101 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
103 player->takeTurnScript = script;
104 player->takeTurnScriptID = script->id;
105 script->owner1.actorID = ACTOR_PLAYER;
108 break;
110 if (BattleSubstateDelay != 0) {
112 } else {
114 }
115
116 // wait for player move script
118 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
119 break;
120 }
121 player->takeTurnScript = NULL;
122 }
123
125
126 // wait for player handle event script
127 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
128 break;
129 }
130 player->handleEventScript = NULL;
131
132 // wait for partner handle event script
133 if (partner != NULL) {
134 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
135 break;
136 }
137 partner->handleEventScript = NULL;
138 }
139
140 // wait for all enemy turn scripts
142 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
143 enemy = battleStatus->enemyActors[i];
144 if (enemy != NULL && enemy->takeTurnScript != NULL) {
147 } else {
148 enemy->takeTurnScript = NULL;
149 }
150 }
151 }
152 if (enemyNotDone) {
153 break;
154 }
155
156 // wait for all enemy handle event scripts
158 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
159 enemy = battleStatus->enemyActors[i];
160 if (enemy != NULL && enemy->handleEventScript != NULL) {
163 } else {
164 enemy->handleEventScript = NULL;
165 }
166 }
167 }
168 if (enemyNotDone) {
169 break;
170 }
171
172 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
173 enemy = battleStatus->enemyActors[i];
174 if (enemy != NULL) {
176 }
177 }
178
179 if (battleStatus->stateFreezeCount == 0) {
182 Actor* target;
183
185 return;
186 }
187
188 target = get_actor(player->targetActorID);
189 if (target != NULL) {
190 if (target->handleEventSource != NULL) {
191 target->lastEventType = EVENT_END_FIRST_STRIKE;
193 target->handleEventScript = script;
194 target->handleEventScriptID = script->id;
195 script->owner1.actorID = target->actorID;
196 }
197 }
199 } else {
201 }
202 }
203 break;
206 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
207 enemy = battleStatus->enemyActors[i];
208 if (enemy != NULL && enemy->handleEventScript != NULL) {
211 } else {
212 enemy->handleEventScript = NULL;
213 }
214 }
215 }
216 if (enemyNotDone) {
217 break;
218 }
219 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
220 player->takeTurnScript = NULL;
222 }
223 break;
224 }
225}
226
s32 BattleScreenFadeAmt
Definition 16C8E0.c:50
s16 EndDemoWhiteOut
Definition 16C8E0.c:13
BSS s32 PopupMenu_SelectedIndex
BSS b32 BattleCanShowFirstStrike
BSS s32 BattleSubstateDelay
struct Evt * takeTurnScript
EvtScript * handleEventSource
struct Evt * handleEventScript
s32 takeTurnScriptID
s16 targetActorID
s32 handleEventScriptID
@ OVERLAY_NONE
Definition enums.h:2373
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2374
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3623
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3576
@ RUSH_FLAG_NONE
Definition enums.h:4915
@ RUSH_FLAG_MEGA
Definition enums.h:4916
@ RUSH_FLAG_POWER
Definition enums.h:4917
@ PHASE_FIRST_STRIKE
Definition enums.h:2092
@ BTL_MENU_TYPE_SMASH
Definition enums.h:3827
@ BTL_MENU_TYPE_JUMP
Definition enums.h:3826
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3651
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3654
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ ENCOUNTER_TRIGGER_JUMP
Definition enums.h:269
@ ENCOUNTER_TRIGGER_HAMMER
Definition enums.h:271
@ ENCOUNTER_TRIGGER_PARTNER
Definition enums.h:273
@ BTL_CAM_MIDPOINT_CLOSE
Definition enums.h:4417
@ BATTLE_STATE_END_DEMO_BATTLE
Definition enums.h:3696
@ BATTLE_STATE_BEGIN_TURN
Definition enums.h:3669
@ BATTLE_STATE_PARTNER_FIRST_STRIKE
Definition enums.h:3667
@ DMG_SRC_DEFAULT
Definition enums.h:2014
@ ABILITY_POWER_RUSH
Definition enums.h:466
@ ABILITY_MEGA_RUSH
Definition enums.h:456
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_ENEMY0
Definition enums.h:2120
@ EVENT_BEGIN_FIRST_STRIKE
Definition enums.h:2206
@ EVENT_END_FIRST_STRIKE
Definition enums.h:2204
@ EVT_PRIORITY_A
Definition evt.h:154
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:162
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void decrement_status_bar_disabled(void)
Definition inventory.c:1656
void reset_actor_turn_info(void)
Definition 190B20.c:710
void set_screen_overlay_params_front(u8, f32)
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)
s32 func_80263230(Actor *, Actor *)
Definition 190B20.c:558
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
s32 does_script_exist(s32 id)
void btl_set_state(s32 battleState)
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653
void increment_status_bar_disabled(void)
Definition inventory.c:1664
EvtScript EVS_Mario_HandlePhase
EncounterStatus gCurrentEncounter
Definition encounter.c:175
void btl_state_update_first_strike(void)
@ BTL_SUBSTATE_AWAIT_SCRIPTS
@ BTL_SUBSTATE_AWAIT_ENEMY_DONE
@ BTL_SUBSTATE_AWAIT_ENEMY_READY
void btl_merlee_on_first_strike(void)
void btl_state_draw_first_stike(void)
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PERIL_THRESHOLD
Definition battle.h:277
#define DANGER_THRESHOLD
Definition battle.h:276
@ BTL_SUBSTATE_INIT
Definition states.h:8
struct Actor * partnerActor
struct Actor * playerActor
GameStatus * gGameStatusPtr
Definition main_loop.c:31
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17
MoveData gMoveTable[]