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

Go to the source code of this file.

Enumerations

enum  {
  BTL_SUBSTATE_RESET_ENEMIES = 1 , BTL_SUBSTATE_AWAIT_ALL = 2 , BTL_SUBSTATE_RESET_POSITIONS = 3 , BTL_SUBSTATE_TRY_MERLEE_DEF = 4 ,
  BTL_SUBSTATE_NOTIFY_ENEMY_PHASE = 5 , BTL_SUBSTATE_AWAIT_ENEMY_PHASE = 6 , BTL_SUBSTATE_DONE = 7
}
 

Functions

void btl_state_update_transfer_turn (void)
 
void btl_state_draw_transfer_turn (void)
 

Enumeration Type Documentation

◆ anonymous enum

Enumerator
BTL_SUBSTATE_RESET_ENEMIES 
BTL_SUBSTATE_AWAIT_ALL 
BTL_SUBSTATE_RESET_POSITIONS 
BTL_SUBSTATE_TRY_MERLEE_DEF 
BTL_SUBSTATE_NOTIFY_ENEMY_PHASE 
BTL_SUBSTATE_AWAIT_ENEMY_PHASE 
BTL_SUBSTATE_DONE 

Definition at line 5 of file turn_transfer.c.

5 {
6 // BTL_SUBSTATE_INIT = 0,
14};
@ BTL_SUBSTATE_TRY_MERLEE_DEF
@ BTL_SUBSTATE_RESET_ENEMIES
@ BTL_SUBSTATE_NOTIFY_ENEMY_PHASE
@ BTL_SUBSTATE_RESET_POSITIONS
@ BTL_SUBSTATE_AWAIT_ALL
@ BTL_SUBSTATE_AWAIT_ENEMY_PHASE
@ BTL_SUBSTATE_DONE

Function Documentation

◆ btl_state_update_transfer_turn()

void btl_state_update_transfer_turn ( void )

Definition at line 16 of file turn_transfer.c.

16 {
18 Actor* player = battleStatus->playerActor;
19 Actor* partner = battleStatus->partnerActor;
20 Actor* actor;
21 ActorState* state;
22 Evt* script;
24 s32 i;
25
27
31 return;
32 }
33
34 if (partner != NULL) {
37 return;
38 }
39 }
40
43 if (partner != NULL) {
46 }
47
54 }
55
57 // await all enemy event scripts
59 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
60 actor = battleStatus->enemyActors[i];
61 if (actor != NULL && actor->handleEventScript != NULL) {
64 } else {
65 actor->handleEventScript = NULL;
66 }
67 }
68 }
69 if (waitingForScript) {
70 return;
71 }
72
74
75 // prepare each enemy actor for the coming turn
76 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
77 actor = battleStatus->enemyActors[i];
78
79 if (actor == NULL) {
80 continue;
81 }
82
85
86 if (actor->debuff != 0) {
87 if (actor->debuff == STATUS_KEY_UNUSED
88 || actor->debuff == STATUS_KEY_DIZZY
89 || actor->debuff == STATUS_KEY_PARALYZE
90 || actor->debuff == STATUS_KEY_SLEEP
91 || actor->debuff == STATUS_KEY_FROZEN
92 || actor->debuff == STATUS_KEY_STOP
93 ) {
95 }
96 actor->debuffDuration--;
97 if (actor->debuffDuration <= 0) {
98 actor->debuff = 0;
102 }
103 }
104
105 if (actor->staticStatus != 0) {
106 actor->staticDuration--;
107 if (actor->staticDuration <= 0) {
108 actor->staticStatus = 0;
111 }
112 }
113
114 if (actor->transparentStatus != 0) {
115 actor->transparentDuration--;
116 if (actor->transparentDuration <= 0) {
117 actor->transparentStatus = 0;
120 }
121 }
122
123 if (actor->stoneStatus != 0) {
124 actor->stoneDuration--;
125 if (actor->stoneDuration <= 0) {
126 actor->stoneStatus = 0;
128 }
129 }
130
131 oldKoDuration = actor->koDuration;
132 actor->koDuration = actor->debuffDuration;
133 if (actor->koDuration > 0) {
134 actor->koStatus = STATUS_KEY_KO;
136 } else if (oldKoDuration != actor->koDuration) {
137 actor->koStatus = 0;
139 }
140 if (actor->debuff == STATUS_KEY_POISON) {
144 }
145 }
147 }
148
150 // wait for player HandleEvent script to finish
151 if(player->handleEventScript != NULL) {
153 return;
154 } else {
155 player->handleEventScript = NULL;
156 }
157 }
158
159 // wait for partner HandleEvent script to finish
160 if (partner != NULL) {
161 if (partner->handleEventScript != NULL) {
162 if (does_script_exist(partner->handleEventScriptID)) {
163 return;
164 } else {
165 partner->handleEventScript = NULL;
166 }
167 }
168 }
169
170 // wait for all enemy HandleEvent scripts to finish
172 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
173 actor = battleStatus->enemyActors[i];
174 if (actor != NULL && actor->handleEventScript != NULL) {
177 } else {
178 actor->handleEventScript = NULL;
179 }
180 }
181 }
182 if (waitingForScript) {
183 return;
184 }
185
187 return;
188 }
189
191
196 } else {
201 state = &partner->state;
202 if (!battleStatus->outtaSightActive) {
203 partner->state.curPos.x = partner->homePos.x;
204 partner->state.curPos.z = partner->homePos.z;
205 partner->state.goalPos.x = player->homePos.x;
206 partner->state.goalPos.z = player->homePos.z;
207 } else {
208 partner->state.curPos.x = partner->homePos.x;
209 partner->state.curPos.z = partner->homePos.z;
210 partner->state.goalPos.x = partner->homePos.x;
211 partner->state.goalPos.z = partner->homePos.z + 5.0f;
212 partner->homePos.x = player->homePos.x;
213 partner->homePos.z = player->homePos.z;
214 }
215 state->moveTime = 4;
216 state->angle = 0.0f;
218 }
219 }
220
222 if (partner->state.moveTime != 0) {
223 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
224 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
225 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
226 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
227 }
228 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
229 partner->yaw = clamp_angle(partner->state.angle);
230 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
231 player->yaw = clamp_angle(partner->state.angle);
232 partner->state.angle += 90.0f;
233
234 if (partner->state.moveTime != 0) {
235 partner->state.moveTime--;
236 } else {
237 partner->curPos.x = partner->state.goalPos.x;
238 partner->curPos.z = partner->state.goalPos.z;
239 player->curPos.x = partner->state.curPos.x;
240 player->curPos.z = partner->state.curPos.z;
241 if (!battleStatus->outtaSightActive) {
242 partner->homePos.x = partner->curPos.x;
243 partner->homePos.z = partner->curPos.z;
244 player->homePos.x = player->curPos.x;
245 player->homePos.z = player->curPos.z;
246 } else {
247 player->homePos.x = player->curPos.x;
248 player->homePos.z = player->curPos.z;
249 }
252 }
253 }
254
256 if (BattleStatusUpdateDelay != 0) {
258 return;
259 }
260
261 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_DEF_BOOST) {
262 battleStatus->merleeDefenseBoost = 3;
263 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
266 player->takeTurnScript = script;
267 player->takeTurnScriptID = script->id;
268 script->owner1.actorID = ACTOR_PLAYER;
269 }
273 if (partner != NULL) {
276 }
282 }
283
285 // potentially wait for the merlee script to end
286 if (player->takeTurnScript != NULL) {
287 if (does_script_exist(player->takeTurnScriptID)) {
288 return;
289 } else {
290 player->takeTurnScript = NULL;
291 }
292 }
293
294 // initiate all enemy PHASE_PLAYER_END scripts
295 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
296 actor = battleStatus->enemyActors[i];
297 if (actor != NULL && actor->handlePhaseSource != NULL) {
298 battleStatus->battlePhase = PHASE_PLAYER_END;
300 actor->handlePhaseScript = script;
301 actor->handlePhaseScriptID = script->id;
302 script->owner1.enemyID = i | ACTOR_CLASS_ENEMY;
303 }
304 }
305
307 }
308
310 // await all the enemy PHASE_PLAYER_END scripts
312 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
313 actor = battleStatus->enemyActors[i];
314 // interesting: this condition checks for handlePhaseSource instead of handlePhaseScript,
315 // which is the expected pattern. result: handlePhaseScript is never NULL'd. minor bug?
316 if (actor != NULL && actor->handlePhaseSource != NULL) {
319 }
320 }
321 }
322 if (waitingForScript) {
323 return;
324 }
325
327 }
328
331 }
332}
BSS s32 PopupMenu_SelectedIndex
BSS s32 BattleStatusUpdateDelay
struct EffectInstance * disableEffect
struct Evt * handlePhaseScript
struct Evt * takeTurnScript
s8 transparentStatus
struct Evt * handleEventScript
s32 takeTurnScriptID
EvtScript * handlePhaseSource
Vec3f homePos
s32 handleEventScriptID
s16 hudElementDataIndex
Vec3f curPos
s8 staticDuration
s32 handlePhaseScriptID
s8 debuffDuration
s8 transparentDuration
#define clamp_angle
struct DisableXFXData * disableX
Definition effects.h:2529
EffectInstanceDataPtr data
Definition effects.h:2605
@ MERLEE_SPELL_DEF_BOOST
Definition enums.h:1938
@ MERLEE_SPELL_NONE
Definition enums.h:1936
@ ACTOR_CLASS_ENEMY
Definition enums.h:2112
@ BS_FLAGS1_PLAYER_IN_BACK
Definition enums.h:3622
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3608
@ PHASE_MERLEE_DEFENSE_BONUS
Definition enums.h:2104
@ PHASE_PLAYER_END
Definition enums.h:2102
@ BS_FLAGS2_PLAYER_TURN_USED
Definition enums.h:3638
@ BS_FLAGS2_PARTNER_TURN_USED
Definition enums.h:3639
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3643
@ STATUS_KEY_PARALYZE
Definition enums.h:2806
@ STATUS_KEY_FROZEN
Definition enums.h:2808
@ STATUS_KEY_KO
Definition enums.h:2814
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ STATUS_KEY_UNUSED
Definition enums.h:2804
@ STATUS_KEY_STOP
Definition enums.h:2809
@ STATUS_KEY_DIZZY
Definition enums.h:2805
@ STATUS_KEY_POISON
Definition enums.h:2810
@ BTL_CAM_DEFAULT
Definition enums.h:4409
@ BATTLE_STATE_NEXT_ENEMY
Definition enums.h:3684
@ BATTLE_STATE_SWITCH_TO_PARTNER
Definition enums.h:3675
@ BATTLE_STATE_SWITCH_TO_PLAYER
Definition enums.h:3674
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_FLAG_SKIP_TURN
Definition enums.h:3370
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3377
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3373
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3376
@ EVENT_HIT
Definition enums.h:2165
@ EVENT_RECOVER_STATUS
Definition enums.h:2200
@ EVT_PRIORITY_A
Definition evt.h:154
void remove_status_debuff(s32)
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:102
void remove_status_static(s32)
void reset_actor_turn_info(void)
Definition 190B20.c:710
void remove_status_transparent(s32)
void btl_cam_use_preset(s32)
Definition camera.c:1919
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:875
s32 does_script_exist(s32 id)
f32 sin_rad(f32 x)
Definition 43F0.c:711
void btl_set_state(s32 battleState)
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653
EvtScript EVS_Mario_HandlePhase
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define DEG_TO_RAD(deg)
Definition macros.h:146
@ BTL_SUBSTATE_INIT
Definition states.h:8
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17

Referenced by btl_update().

◆ btl_state_draw_transfer_turn()

void btl_state_draw_transfer_turn ( void )

Definition at line 334 of file turn_transfer.c.

334 {
335}

Referenced by btl_draw_ui().