Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
partner_first_strike.c
Go to the documentation of this file.
1#include "states.h"
2#include "battle/battle.h"
3
4enum {
5 // BTL_SUBSTATE_INIT = 0,
9};
10
13 Actor* player = battleStatus->playerActor;
14 Actor* partner = battleStatus->partnerActor;
15 Actor* actor;
18 Evt* script;
19 s32 level;
20 s32 i;
21
22 switch (gBattleSubState) {
25 // setup dummy 'menu selection' for partner move
26 level = partner->actorBlueprint->level;
27 switch (gPlayerData.curPartner) {
28 case PARTNER_KOOPER:
30 battleStatus->moveArgument = 0;
31 battleStatus->selectedMoveID = level + MOVE_SHELL_TOSS1;
32 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
33 break;
36 battleStatus->moveArgument = 0;
37 battleStatus->selectedMoveID = level + MOVE_BODY_SLAM1;
38 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
39 break;
40 }
41 // let the enemy know a first strike is coming
42 actor = get_actor(ACTOR_ENEMY0);
43 if (actor->handleEventSource != NULL) {
47 actor->handleEventScriptID = script->id;
48 script->owner1.actorID = actor->actorID;
49 }
51 break;
54 target = &partner->targetData[partner->targetIndexList[0]];
55 partner->targetActorID = target->actorID;
56 partner->targetPartID = target->partID;
57 battleStatus->stateFreezeCount = 0;
58 battleStatus->lastAttackDamage = 0;
59 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
67 // begin the partner turn script
68 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
69 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
70 partner->takeTurnScript = script;
71 partner->takeTurnScriptID = script->id;
72 script->owner1.actorID = ACTOR_PARTNER;
75 break;
77 if (BattleSubstateDelay != 0) {
79 } else {
81 }
82 // wait for partner move script
83 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
84 break;
85 }
86 partner->takeTurnScript = NULL;
87 // wait for partner handle event script
88 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
89 break;
90 }
91 partner->handleEventScript = NULL;
92 // wait for player handle event script
94 break;
95 }
96 player->handleEventScript = NULL;
97
98 // wait for all enemy turn scripts
100 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
101 actor = battleStatus->enemyActors[i];
102 if (actor != NULL && actor->takeTurnScript != NULL) {
105 } else {
106 actor->takeTurnScript = NULL;
107 }
108 }
109 }
110 if (enemyNotDone) {
111 break;
112 }
113
114 // wait for all enemy handle event scripts
116 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
117 actor = battleStatus->enemyActors[i];
118 if (actor != NULL && actor->handleEventScript != NULL) {
121 } else {
122 actor->handleEventScript = NULL;
123 }
124 }
125 }
126 if (enemyNotDone) {
127 break;
128 }
129
130 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
131 actor = battleStatus->enemyActors[i];
132 if (actor != NULL) {
134 }
135 }
136
137 if (battleStatus->stateFreezeCount == 0) {
140 return;
141 }
142
143 actor = get_actor(partner->targetActorID);
144 if (actor != NULL) {
145 if (actor->handleEventSource != NULL) {
148 actor->handleEventScript = script;
149 actor->handleEventScriptID = script->id;
150 script->owner1.actorID = actor->actorID;
151 }
152 }
154 }
155 break;
158 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
159 actor = battleStatus->enemyActors[i];
160 if (actor != NULL && actor->handleEventScript != NULL) {
163 } else {
164 actor->handleEventScript = NULL;
165 }
166 }
167 }
168 if (!enemyNotDone) {
170 }
171 break;
172 }
173}
174
s32 BattleScreenFadeAmt
Definition 16C8E0.c:50
BSS s32 PopupMenu_SelectedIndex
BSS b32 BattleCanShowFirstStrike
BSS s32 BattleSubstateDelay
struct Evt * takeTurnScript
EvtScript * handleEventSource
struct Evt * handleEventScript
s32 takeTurnScriptID
s32 handleEventScriptID
@ OVERLAY_NONE
Definition enums.h:2373
@ OVERLAY_SCREEN_COLOR
Definition enums.h:2374
@ BS_FLAGS1_PARTNER_ACTING
Definition enums.h:3621
@ PHASE_FIRST_STRIKE
Definition enums.h:2092
@ BTL_MENU_TYPE_CHANGE_PARTNER
Definition enums.h:3831
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3651
@ BTL_CAM_MIDPOINT_CLOSE
Definition enums.h:4417
@ BATTLE_STATE_BEGIN_TURN
Definition enums.h:3669
@ DMG_SRC_DEFAULT
Definition enums.h:2014
@ ACTOR_PARTNER
Definition enums.h:2119
@ ACTOR_ENEMY0
Definition enums.h:2120
@ PARTNER_BOMBETTE
Definition enums.h:2922
@ PARTNER_KOOPER
Definition enums.h:2921
@ 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 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)
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
s32 does_script_exist(s32 id)
void btl_set_state(s32 battleState)
void create_current_pos_target_list(Actor *actor)
Definition 190B20.c:472
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653
void increment_status_bar_disabled(void)
Definition inventory.c:1664
void btl_state_draw_partner_striking_first(void)
@ BTL_SUBSTATE_AWAIT_SCRIPTS
@ BTL_SUBSTATE_AWAIT_ENEMY_DONE
@ BTL_SUBSTATE_AWAIT_ENEMY_READY
void btl_state_update_partner_striking_first(void)
#define ARRAY_COUNT(arr)
Definition macros.h:40
@ BTL_SUBSTATE_INIT
Definition states.h:8
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14
s32 gBattleSubState
Definition battle.cpp:17
MoveData gMoveTable[]