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

Go to the source code of this file.

Macros

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

Enumerations

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

Functions

void N update (void)
 

Variables

s32 actionCmdTableDizzyShell []
 

Macro Definition Documentation

◆ METER_FILL_TICK

#define METER_FILL_TICK   850

Definition at line 17 of file dizzy_shell.c.

Referenced by update().

◆ GET_DRAIN_RATE

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

Definition at line 21 of file dizzy_shell.c.

Referenced by update().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HIDX_BUTTON 
HIDX_METER 
HIDX_100_PCT 

Definition at line 10 of file dizzy_shell.c.

10 {
11 HIDX_BUTTON = 0,
12 HIDX_METER = 1,
13 HIDX_100_PCT = 2,
14};
@ HIDX_METER
Definition dizzy_shell.c:12
@ HIDX_BUTTON
Definition dizzy_shell.c:11
@ HIDX_100_PCT
Definition dizzy_shell.c:13

Function Documentation

◆ update()

void N update ( void )

Definition at line 103 of file dizzy_shell.c.

103 {
105 BattleStatus* battleStatus = &gBattleStatus;
106 HudElemID hid;
107 s32 cutoff;
108 s32 fillLevel;
109
110 switch (acs->state) {
111 case AC_STATE_INIT:
113
114 hid = acs->hudElemIDs[HIDX_BUTTON];
115 hud_element_set_alpha(hid, 255);
116 if (acs->showHud) {
118 }
119
120 hid = acs->hudElemIDs[HIDX_METER];
121 hud_element_set_alpha(hid, 255);
122 if (acs->showHud) {
124 }
125
126 acs->state = AC_STATE_APPEAR;
127 break;
128 case AC_STATE_APPEAR:
130 acs->hudPosX += 20;
131 if (acs->hudPosX > 50) {
132 acs->hudPosX = 50;
133 }
136 break;
137 case AC_STATE_START:
139 if (acs->prepareTime != 0) {
140 acs->prepareTime--;
141 return;
142 }
144 acs->meterFillLevel = 0;
145 acs->stateTimer = acs->duration;
147 acs->state = AC_STATE_ACTIVE;
148
149 // fallthrough
150 case AC_STATE_ACTIVE:
152
153 // meter can drain if it hasn't been fully filled
154 if (!acs->isMeterFilled) {
155 if (acs->statusChance != 0) {
156 s32 maxFillLevel = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
157 acs->meterFillLevel -= GET_DRAIN_RATE (acs->meterFillLevel / maxFillLevel);
158 if (acs->meterFillLevel < 0) {
159 acs->meterFillLevel = 0;
160 }
161 } else {
162 acs->meterFillLevel -= 10;
163 if (acs->meterFillLevel < 0) {
164 acs->meterFillLevel = 0;
165 }
166 }
167 }
168
169 // check for meter-filling input
170 if (battleStatus->curButtonsPressed & BUTTON_A) {
171 s32 difficultyPct = battleStatus->actionCmdDifficultyTable[acs->difficulty];
172 s32 effectivenessPct = METER_FILL_TICK * acs->statusChance;
173 // divide by 100 for each percent-based multiplier
174 s32 fillAmt = (difficultyPct * effectivenessPct) / (100 * 100);
175
176 if (fillAmt != 0) {
177 acs->meterFillLevel += fillAmt;
178 } else {
180 if (acs->meterFillLevel >= 5 * ONE_PCT_MASH) {
181 acs->meterFillLevel = 5 * ONE_PCT_MASH;
182 }
183 }
184 }
185
186 // handle meter reaching 100%
187 if (acs->meterFillLevel >= MAX_MASH_UNITS) {
189 acs->isMeterFilled = TRUE;
190 hid = acs->hudElemIDs[HIDX_100_PCT];
191 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
193 }
194
195 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
197
198 if (acs->stateTimer != 0) {
199 acs->stateTimer--;
200 break;
201 }
202
203 fillLevel = acs->meterFillLevel;
204 if (acs->statusChance == 0) {
205 fillLevel = 0;
206 }
207
208 if (fillLevel == 0) {
209 battleStatus->actionQuality = AC_QUALITY_FAILED;
210 } else {
211 battleStatus->actionQuality = fillLevel / ONE_PCT_MASH;
212
213 }
214
215 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
216 if (battleStatus->actionQuality >= cutoff) {
217 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
218 } else {
220 }
221
222 if (battleStatus->actionQuality == 100) {
223 // only could 100% fill as success for this action command
225 }
228 acs->stateTimer = 5;
229 acs->state = AC_STATE_DISPOSE;
230 break;
231 case AC_STATE_DISPOSE:
232 if (acs->statusChance == 0) {
233 acs->meterFillLevel -= 100;
234 if (acs->meterFillLevel < 0) {
235 acs->meterFillLevel = 0;
236 }
237 }
238
239 if (acs->stateTimer != 0) {
240 acs->stateTimer--;
241 break;
242 }
244 break;
245 }
246}
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
HudScript HES_MashAButton
#define MAX_MASH_UNITS
Definition action_cmd.h:75
s32 HudElemID
#define METER_FILL_TICK
Definition dizzy_shell.c:17
#define GET_DRAIN_RATE(pct)
Definition dizzy_shell.c:21
@ BUTTON_A
Definition enums.h:2790
@ 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
#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

◆ actionCmdTableDizzyShell

s32 actionCmdTableDizzyShell[]
extern

Definition at line 35 of file action_cmd.c.

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