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

Go to the source code of this file.

Macros

#define METER_FILL_TICK   1250
 
#define GET_DRAIN_RATE(pct)   PCT_TO_TABLE_RATE(N(DrainRateTable), pct)
 

Enumerations

enum  { HIDX_STICK = 0 , HIDX_METER = 1 , HIDX_100_PCT = 2 }
 

Functions

void N update (void)
 

Variables

s32 actionCmdTableSpinySurge []
 
BSS s32 PrevButtons
 

Macro Definition Documentation

◆ METER_FILL_TICK

#define METER_FILL_TICK   1250

Definition at line 16 of file spiny_surge.c.

Referenced by update().

◆ GET_DRAIN_RATE

#define GET_DRAIN_RATE ( pct)    PCT_TO_TABLE_RATE(N(DrainRateTable), pct)

Definition at line 20 of file spiny_surge.c.

Referenced by update().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HIDX_STICK 
HIDX_METER 
HIDX_100_PCT 

Definition at line 9 of file spiny_surge.c.

9 {
10 HIDX_STICK = 0,
11 HIDX_METER = 1,
12 HIDX_100_PCT = 2,
13};
@ HIDX_METER
Definition spiny_surge.c:11
@ HIDX_STICK
Definition spiny_surge.c:10
@ HIDX_100_PCT
Definition spiny_surge.c:12

Function Documentation

◆ update()

void N update ( void )

Definition at line 101 of file spiny_surge.c.

101 {
103 BattleStatus* battleStatus = &gBattleStatus;
104 HudElemID hid;
105 s32 cutoff;
106
107 switch (acs->state) {
108 case AC_STATE_INIT:
110
111 hid = acs->hudElemIDs[HIDX_STICK];
112 hud_element_set_alpha(hid, 255);
113 if (acs->showHud) {
115 }
116
117 hid = acs->hudElemIDs[HIDX_METER];
118 hud_element_set_alpha(hid, 255);
119 if (acs->showHud) {
121 }
122
123 acs->state = AC_STATE_APPEAR;
124 break;
125 case AC_STATE_APPEAR:
127
128 if (acs->hudPrepareTime != 0) {
129 acs->hudPrepareTime--;
130 break;
131 }
132
133 acs->hudPosX += 20;
134 if (acs->hudPosX > 50) {
135 acs->hudPosX = 50;
136 }
137
140 break;
141 case AC_STATE_START:
143
144 if (acs->prepareTime != 0) {
145 acs->prepareTime--;
146 break;
147 }
148
150 acs->spinySurge.tossState = SPINY_SURGE_NONE;
151 PrevButtons = 0;
152 acs->stateTimer = acs->duration;
154 acs->state = AC_STATE_ACTIVE;
155
156 // fallthrough
157 case AC_STATE_ACTIVE:
159
160 // meter can drain if it hasn't been fully filled
161 if (!acs->isMeterFilled) {
162 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
163 acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / cutoff);
164 if (acs->meterFillLevel < 0) {
165 acs->meterFillLevel = 0;
166 }
167 }
168
169 // check for meter-filling input
170 if (!acs->isMeterFilled) {
171 if (battleStatus->curButtonsPressed & BUTTON_STICK_LEFT) {
173 }
174 // right stick inputs actively drain the meter
175 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
177 }
178 }
179
180 if (acs->meterFillLevel < 0) {
181 acs->meterFillLevel = 0;
182 }
183
184 // handle meter reaching 100%
185 if (acs->meterFillLevel > MAX_MASH_UNITS) {
187 acs->isMeterFilled = TRUE;
188 hid = acs->hudElemIDs[HIDX_100_PCT];
189 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
191 }
192
193 // set signal value for the move script to play throwing animations
195 acs->spinySurge.tossState = SPINY_SURGE_HOLD;
196 }
198 acs->spinySurge.tossState = SPINY_SURGE_RESET;
199 }
201 && !(battleStatus->curButtonsDown & BUTTON_STICK_RIGHT)
202 && acs->spinySurge.tossState == SPINY_SURGE_HOLD
203 ) {
204 acs->spinySurge.tossState = SPINY_SURGE_THROW;
205 }
206 battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
207 PrevButtons = battleStatus->curButtonsDown;
208 battleStatus->actionProgress = acs->spinySurge.tossState;
209
211
212 if (acs->stateTimer != 0) {
213 acs->stateTimer--;
214 break;
215 }
216
217 if (acs->meterFillLevel == 0) {
218 battleStatus->actionQuality = AC_QUALITY_FAILED;
219 } else {
220 battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
221 }
222
223 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
224 if (battleStatus->actionQuality > cutoff) {
225 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
226 } else {
228 }
229
230 if (battleStatus->actionQuality == 100) {
231 // only count 100% fill as success for this action command
233 }
234
237 acs->stateTimer = 5;
238 acs->state = AC_STATE_DISPOSE;
239 break;
240 case AC_STATE_DISPOSE:
241 if (acs->stateTimer != 0) {
242 acs->stateTimer--;
243 break;
244 }
246 break;
247 }
248}
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
void action_command_free(void)
Definition action_cmd.c:446
void increment_action_command_success_count(void)
Definition action_cmd.c:655
#define AC_QUALITY_FAILED
Definition action_cmd.h:66
HudElemID hudElemIDs[16]
Definition action_cmd.h:83
@ AC_STATE_APPEAR
Definition action_cmd.h:35
@ AC_STATE_DISPOSE
Definition action_cmd.h:38
@ AC_STATE_INIT
Definition action_cmd.h:34
@ AC_STATE_ACTIVE
Definition action_cmd.h:37
@ AC_STATE_START
Definition action_cmd.h:36
#define ONE_PCT_MASH
Definition action_cmd.h:69
#define SCALE_BY_PCT(x, pct)
Definition action_cmd.h:77
HudScript HES_StickMashLeft
#define MAX_MASH_UNITS
Definition action_cmd.h:75
s32 HudElemID
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ SOUND_LOOP_CHARGE_METER
Definition enums.h:1646
@ ACTION_RESULT_METER_NOT_ENOUGH
Definition enums.h:1965
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
void btl_set_popup_duration(s32 duration)
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:72
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
BSS s32 PrevButtons
Definition spiny_surge.c:22
#define METER_FILL_TICK
Definition spiny_surge.c:16
#define GET_DRAIN_RATE(pct)
Definition spiny_surge.c:20
@ SPINY_SURGE_RESET
Definition spiny_surge.h:17
@ SPINY_SURGE_NONE
Definition spiny_surge.h:18
@ SPINY_SURGE_THROW
Definition spiny_surge.h:20
@ SPINY_SURGE_HOLD
Definition spiny_surge.h:19
#define POPUP_MSG_OFF
Definition battle.h:270
#define POPUP_MSG_ON
Definition battle.h:269
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11

Variable Documentation

◆ actionCmdTableSpinySurge

s32 actionCmdTableSpinySurge[]
extern

Definition at line 46 of file action_cmd.c.

46{ 130, 120, 110, 100, 90, 80, 70, 60 };

◆ PrevButtons

BSS s32 PrevButtons

Definition at line 22 of file spiny_surge.c.

Referenced by update().