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

Go to the source code of this file.

Enumerations

enum  { BTL_SUBSTATE_AWAIT_ENEMY_READY = 1 , BTL_SUBSTATE_AWAIT_SCRIPTS = 2 , BTL_SUBSTATE_AWAIT_ENEMY_DONE = 3 }
 

Functions

void btl_merlee_on_first_strike (void)
 
void btl_state_update_first_strike (void)
 
void btl_state_draw_first_stike (void)
 

Enumeration Type Documentation

◆ anonymous enum

Enumerator
BTL_SUBSTATE_AWAIT_ENEMY_READY 
BTL_SUBSTATE_AWAIT_SCRIPTS 
BTL_SUBSTATE_AWAIT_ENEMY_DONE 

Definition at line 4 of file player_first_strike.c.

4 {
5 // BTL_SUBSTATE_INIT = 0,
9};
@ BTL_SUBSTATE_AWAIT_SCRIPTS
@ BTL_SUBSTATE_AWAIT_ENEMY_DONE
@ BTL_SUBSTATE_AWAIT_ENEMY_READY

Function Documentation

◆ btl_merlee_on_first_strike()

void btl_merlee_on_first_strike ( void )

Definition at line 65 of file btl_states_actions.c.

65 {
69
71 && battleStatus->nextMerleeSpellType != MERLEE_SPELL_EXP_BOOST
72 && battleStatus->nextMerleeSpellType != MERLEE_SPELL_COIN_BOOST
73 && playerData->merleeCastsLeft > 0)
74 {
75 if (playerData->merleeTurnCount <= 0) {
76 s32 temp = rand_int(100);
77
78 if (currentEncounter->curEnemy != NULL) {
79 if (currentEncounter->curEnemy->flags & ACTOR_FLAG_NO_HEALTH_BAR) {
80 // 46/101 ≈ 45.5%
81 if (temp <= 45) {
82 playerData->merleeSpellType = MERLEE_SPELL_ATK_BOOST;
83 } else if (temp <= 90) { // 45/101 ≈ 44.6%
84 playerData->merleeSpellType = MERLEE_SPELL_DEF_BOOST;
85 } else { // 10/101 ≈ 9.9%
86 playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
87 }
88 } else if (temp <= 30) { // 31/101 ≈ 30.7%
89 playerData->merleeSpellType = MERLEE_SPELL_ATK_BOOST;
90 } else if (temp <= 60) { // 30/101 ≈ 29.7%
91 playerData->merleeSpellType = MERLEE_SPELL_DEF_BOOST;
92 } else if (temp <= 80) { // 20/101 ≈ 19.8%
93 playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
94 } else { // 20/101 ≈ 19.8%
95 playerData->merleeSpellType = MERLEE_SPELL_COIN_BOOST;
96 }
97 } else if (temp <= 30) { // 31/101 ≈ 30.7%
98 playerData->merleeSpellType = MERLEE_SPELL_ATK_BOOST;
99 } else if (temp <= 60) { // 30/101 ≈ 29.7%
100 playerData->merleeSpellType = MERLEE_SPELL_DEF_BOOST;
101 } else if (temp <= 80) { // 20/101 ≈ 19.8%
102 playerData->merleeSpellType = MERLEE_SPELL_EXP_BOOST;
103 } else { // 20/101 ≈ 19.8%
104 playerData->merleeSpellType = MERLEE_SPELL_COIN_BOOST;
105 }
106
107 if (playerData->merleeSpellType == MERLEE_SPELL_COIN_BOOST) {
108 temp = rand_int(8) + 5;
109 } else {
110 temp = rand_int(5) + 5;
111 }
112 playerData->merleeTurnCount = temp;
113 }
114
115 if (playerData->merleeSpellType == MERLEE_SPELL_EXP_BOOST || playerData->merleeSpellType == MERLEE_SPELL_COIN_BOOST) {
116 if (playerData->merleeTurnCount >= 2) {
117 playerData->merleeTurnCount--;
118 } else {
119 battleStatus->nextMerleeSpellType = playerData->merleeSpellType;
120 playerData->merleeTurnCount = 0;
121 playerData->merleeCastsLeft--;
122 }
123 }
124 }
125}
BSS s32 PopupMenu_SelectedIndex
#define rand_int
@ MERLEE_SPELL_COIN_BOOST
Definition enums.h:1940
@ MERLEE_SPELL_EXP_BOOST
Definition enums.h:1939
@ MERLEE_SPELL_ATK_BOOST
Definition enums.h:1937
@ MERLEE_SPELL_DEF_BOOST
Definition enums.h:1938
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ ACTOR_FLAG_NO_HEALTH_BAR
Definition enums.h:3371
EncounterStatus gCurrentEncounter
Definition encounter.c:175
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14

Referenced by btl_state_update_first_strike().

◆ btl_state_update_first_strike()

void btl_state_update_first_strike ( void )

Definition at line 13 of file player_first_strike.c.

13 {
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}
BSS b32 BattleCanShowFirstStrike
BSS s32 BattleSubstateDelay
struct Evt * takeTurnScript
EvtScript * handleEventSource
struct Evt * handleEventScript
s32 takeTurnScriptID
s16 targetActorID
s32 handleEventScriptID
@ 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
@ 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 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
void btl_merlee_on_first_strike(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
s32 gBattleSubState
Definition battle.cpp:17
MoveData gMoveTable[]

Referenced by btl_update().

◆ btl_state_draw_first_stike()

void btl_state_draw_first_stike ( void )

Definition at line 227 of file player_first_strike.c.

227 {
229 if (BattleScreenFadeAmt == 0) {
231 } else {
234 } else {
236 }
237
238 if (BattleScreenFadeAmt < 0) {
240 }
242 }
243 }
244}
s32 BattleScreenFadeAmt
Definition 16C8E0.c:50
s16 EndDemoWhiteOut
Definition 16C8E0.c:13
@ OVERLAY_NONE
Definition enums.h:2373
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2374
void set_screen_overlay_params_front(u8, f32)

Referenced by btl_draw_ui().