Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
spiny_surge.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_spiny_surge
5
6s32 D_802A9860_42F680[8] = { 0, 25, 50, 75, 75, 0, 0, 0 };
7
9
10extern s32 actionCmdTableSpinySurge[];
11
12API_CALLABLE(N(init)) {
13 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
14 BattleStatus* battleStatus = &gBattleStatus;
15 s32 id;
16
17 battleStatus->unk_82 = 16;
19
21 battleStatus->actionSuccess = 0;
22 return ApiStatus_DONE2;
23 }
24
26
27 actionCommandStatus->actionCommandID = ACTION_COMMAND_SPINY_SURGE;
28 actionCommandStatus->state = 0;
29 actionCommandStatus->wrongButtonPressed = FALSE;
30 actionCommandStatus->barFillLevel = 0;
31 actionCommandStatus->barFillWidth = 0;
32 actionCommandStatus->isBarFilled = FALSE;
33 battleStatus->actionSuccess = 0;
34 battleStatus->actionResult = ACTION_RESULT_FAIL;
35 actionCommandStatus->hudPrepareTime = 30;
36 actionCommandStatus->hudPosX = -48;
37 actionCommandStatus->hudPosY = 80;
38
40 actionCommandStatus->hudElements[0] = id;
41 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
44
46 actionCommandStatus->hudElements[1] = id;
47 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
50
52 actionCommandStatus->hudElements[2] = id;
53 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
56
57 return ApiStatus_DONE2;
58}
59
60API_CALLABLE(N(start)) {
61 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
62 BattleStatus* battleStatus = &gBattleStatus;
63 Bytecode* args = script->ptrReadPos;
64
66 battleStatus->actionSuccess = 0;
67 return ApiStatus_DONE2;
68 }
69
71
72 actionCommandStatus->prepareTime = evt_get_variable(script, *args++);
73 actionCommandStatus->duration = evt_get_variable(script, *args++);
74 actionCommandStatus->difficulty = evt_get_variable(script, *args++);
75 actionCommandStatus->difficulty = adjust_action_command_difficulty(actionCommandStatus->difficulty);
76
77 actionCommandStatus->wrongButtonPressed = FALSE;
78 actionCommandStatus->barFillLevel = 0;
79 actionCommandStatus->barFillWidth = 0;
80 battleStatus->actionSuccess = 0;
81 actionCommandStatus->state = 10;
82 battleStatus->flags1 &= ~BS_FLAGS1_FREE_ACTION_COMMAND;
83
85
86 return ApiStatus_DONE2;
87}
88
89void N(update)(void) {
90 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
91 BattleStatus* battleStatus = &gBattleStatus;
92 s32 id;
93 s32 cutoff;
94
95 switch (actionCommandStatus->state) {
96 case 0:
98
99 id = actionCommandStatus->hudElements[0];
100 hud_element_set_alpha(id, 255);
101 if (actionCommandStatus->showHud) {
103 }
104
105 id = actionCommandStatus->hudElements[1];
106 hud_element_set_alpha(id, 255);
107 if (actionCommandStatus->showHud) {
109 }
110
111 actionCommandStatus->state = 1;
112 break;
113 case 1:
115
116 if (actionCommandStatus->hudPrepareTime != 0) {
117 actionCommandStatus->hudPrepareTime--;
118 break;
119 }
120
121 actionCommandStatus->hudPosX += 20;
122 if (actionCommandStatus->hudPosX > 50) {
123 actionCommandStatus->hudPosX = 50;
124 }
125
126 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX,
127 actionCommandStatus->hudPosY);
128 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX,
129 actionCommandStatus->hudPosY + 28);
130 break;
131 case 10:
133
134 if (actionCommandStatus->prepareTime != 0) {
135 actionCommandStatus->prepareTime--;
136 break;
137 }
138
139 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_StickMashLeft);
140 actionCommandStatus->unk_5C = 0;
141 D_802A98C0 = 0;
142 actionCommandStatus->frameCounter = actionCommandStatus->duration;
144 actionCommandStatus->state = 11;
145
146 // fallthrough
147 case 11:
149 if (!actionCommandStatus->isBarFilled) {
150 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
151 actionCommandStatus->barFillLevel -=
152 D_802A9860_42F680[actionCommandStatus->barFillLevel / cutoff / 20];
153
154 if (actionCommandStatus->barFillLevel < 0) {
155 actionCommandStatus->barFillLevel = 0;
156 }
157
158 if (!actionCommandStatus->isBarFilled) {
159 if (battleStatus->curButtonsPressed & BUTTON_STICK_LEFT) {
160 actionCommandStatus->barFillLevel += (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 1250) / 100;
161 }
162 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
163 actionCommandStatus->barFillLevel -= (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 1250) / 100;
164 }
165 }
166 }
167
168 if (actionCommandStatus->barFillLevel < 0) {
169 actionCommandStatus->barFillLevel = 0;
170 }
171
172 if (actionCommandStatus->barFillLevel > 10000) {
173 id = actionCommandStatus->hudElements[2];
174 actionCommandStatus->barFillLevel = 10000;
175 actionCommandStatus->isBarFilled = TRUE;
176 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY + 28);
178 }
179
181 actionCommandStatus->unk_5C = 1;
182 }
184 actionCommandStatus->unk_5C = -1;
185 }
186
187 if (!(D_802A98C0 & BUTTON_STICK_LEFT) &&
188 !(battleStatus->curButtonsDown & BUTTON_STICK_RIGHT) &&
189 actionCommandStatus->unk_5C == 1)
190 {
191 actionCommandStatus->unk_5C = 2;
192 }
193 battleStatus->actionSuccess = actionCommandStatus->barFillLevel / 100;
194 D_802A98C0 = battleStatus->curButtonsDown;
195 battleStatus->actionQuality = actionCommandStatus->unk_5C;
196
198
199 if (actionCommandStatus->frameCounter != 0) {
200 actionCommandStatus->frameCounter--;
201 return;
202 }
203
204 if (actionCommandStatus->barFillLevel == 0) {
205 battleStatus->actionSuccess = -1;
206 } else {
207 battleStatus->actionSuccess = actionCommandStatus->barFillLevel / 100;
208 }
209
210 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1];
211 if (cutoff >= battleStatus->actionSuccess) {
212 battleStatus->actionResult = ACTION_RESULT_MINUS_2;
213 } else {
214 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
215 }
216
217 if (battleStatus->actionSuccess == 100) {
219 }
220
223 actionCommandStatus->frameCounter = 5;
224 actionCommandStatus->state = 12;
225 break;
226 case 12:
227 if (actionCommandStatus->frameCounter != 0) {
228 actionCommandStatus->frameCounter--;
229 } else {
231 }
232 break;
233 }
234}
235
237
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
void func_80269160(void)
Definition action_cmd.c:655
void action_command_free(void)
Definition action_cmd.c:446
s32 adjust_action_command_difficulty(s32 arg0)
Definition action_cmd.c:101
void action_command_init_status(void)
Definition action_cmd.c:256
void func_80269118(void)
Definition action_cmd.c:641
HudScript HES_StickNeutral
HudScript HES_BlueMeter
HudScript HES_StickMashLeft
HudScript HES_100pct
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
@ ACTION_COMMAND_SPINY_SURGE
Definition enums.h:3491
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ SOUND_LOOP_CHARGE_BAR
Definition enums.h:1646
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_MINUS_2
Definition enums.h:1965
@ ACTION_RESULT_FAIL
Definition enums.h:1967
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
void btl_set_popup_duration(s32 duration)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_depth(s32 id, s32 z)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:74
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
void sfx_stop_sound(s32 soundID)
Definition sfx.c:507
void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
Definition sfx.c:492
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
Definition sfx.c:458
#define BSS
Definition macros.h:7
s32 actionCmdTableSpinySurge[]
Definition action_cmd.c:46
BSS s32 D_802A98C0
Definition spiny_surge.c:8
s32 D_802A9860_42F680[8]
Definition spiny_surge.c:6
void N update(void)
Definition spiny_surge.c:89
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66