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

Go to the source code of this file.

Macros

#define METER_DRAIN_RATE   250
 
#define GET_DRAIN_RATE(pct)   (N(DrainRateTable)[((pct) / (ONE_PCT_MASH / 5))])
 
#define GET_FILL_RATE(pct)   (N(FillRateTable)[((pct) / (ONE_PCT_MASH / 5))])
 

Enumerations

enum  { HIDX_BUTTON = 0 , HIDX_METER = 1 }
 

Functions

void N update (void)
 
void N draw (void)
 
void N free (void)
 

Variables

s32 actionCmdTableSquirt []
 

Macro Definition Documentation

◆ METER_DRAIN_RATE

#define METER_DRAIN_RATE   250

Definition at line 15 of file squirt.c.

Referenced by update().

◆ GET_DRAIN_RATE

#define GET_DRAIN_RATE ( pct)    (N(DrainRateTable)[((pct) / (ONE_PCT_MASH / 5))])

Definition at line 21 of file squirt.c.

Referenced by update().

◆ GET_FILL_RATE

#define GET_FILL_RATE ( pct)    (N(FillRateTable)[((pct) / (ONE_PCT_MASH / 5))])

Definition at line 22 of file squirt.c.

Referenced by update().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HIDX_BUTTON 
HIDX_METER 

Definition at line 9 of file squirt.c.

9 {
10 HIDX_BUTTON = 0,
11 HIDX_METER = 1,
12};
@ HIDX_METER
Definition squirt.c:11
@ HIDX_BUTTON
Definition squirt.c:10

Function Documentation

◆ update()

void N update ( void )

Definition at line 93 of file squirt.c.

93 {
95 BattleStatus* battleStatus = &gBattleStatus;
96 HudElemID hid;
97 s32 fillPct;
98 s32 cutoff;
99 s32 idx;
100
101 switch (acs->state) {
102 case AC_STATE_INIT:
104
105 hid = acs->hudElemIDs[HIDX_BUTTON];
106 if (acs->showHud) {
108 }
109 hud_element_set_alpha(hid, 255);
110
111 hid = acs->hudElemIDs[HIDX_METER];
112 hud_element_set_alpha(hid, 255);
113 if (acs->showHud) {
115 }
116
117 acs->state = AC_STATE_APPEAR;
118 break;
119 case AC_STATE_APPEAR:
121
122 acs->hudPosX += 20;
123 if (acs->hudPosX > 50) {
124 acs->hudPosX = 50;
125 }
126
129 break;
130 case AC_STATE_START:
132
133 if (acs->prepareTime != 0) {
134 acs->prepareTime--;
135 break;
136 }
137
139 acs->meterFillLevel = 0;
140 acs->squirt.draining = FALSE;
141 acs->stateTimer = acs->duration;
143 acs->state = AC_STATE_ACTIVE;
144
145 // fallthrough
146 case AC_STATE_ACTIVE:
148
149 // meter filling and draining
150 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
151 fillPct = acs->meterFillLevel / cutoff;
152 if (!acs->squirt.draining) {
153 if (!(battleStatus->curButtonsDown & BUTTON_A)) {
154 acs->meterFillLevel -= GET_DRAIN_RATE(fillPct);
155 if (acs->meterFillLevel < 0) {
156 acs->meterFillLevel = 0;
157 }
158 } else {
159 s32 amt = GET_FILL_RATE(fillPct);
160 acs->meterFillLevel += SCALE_BY_PCT(amt, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
161 if (acs->meterFillLevel > MAX_MASH_UNITS) {
163 acs->squirt.draining = TRUE;
164 }
165 }
166 } else {
168 if (acs->meterFillLevel <= 0) {
169 acs->meterFillLevel = 0;
170 acs->squirt.draining = FALSE;
171 }
172 }
173
174 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
176
177 hid = acs->hudElemIDs[HIDX_BUTTON];
178 if (fillPct < 80) {
181 }
182 } else {
185 }
186 }
187
188 if (acs->stateTimer != 0) {
189 acs->stateTimer--;
190 break;
191 }
192
193 if (acs->meterFillLevel == 0) {
194 battleStatus->actionQuality = AC_QUALITY_FAILED;
195 } else {
196 battleStatus->actionQuality = battleStatus->actionProgress;
197 }
198
199 // a good result is filling the meter over halfway to the second-highest interval
200 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
201 if (battleStatus->actionProgress <= cutoff / 2) {
203 } else {
204 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
205 }
206
207 if (battleStatus->actionQuality == 100) {
208 // only count 100% fill as success for this action command
210 }
211
214 acs->stateTimer = 5;
215 acs->state = AC_STATE_DISPOSE;
216 break;
217 case AC_STATE_DISPOSE:
218 if (acs->stateTimer != 0) {
219 acs->stateTimer--;
220 break;
221 }
223 break;
224 }
225}
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_PressAButton
HudScript HES_AButtonDown
#define MAX_MASH_UNITS
Definition action_cmd.h:75
#define METER_DRAIN_RATE
Definition squirt.c:15
#define GET_DRAIN_RATE(pct)
Definition squirt.c:21
#define GET_FILL_RATE(pct)
Definition squirt.c:22
s32 HudElemID
@ BUTTON_A
Definition enums.h:2790
@ SOUND_LOOP_CHARGE_METER
Definition enums.h:1646
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_METER_BELOW_HALF
Definition enums.h:1964
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)
HudScript * hud_element_get_script(s32 id)
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

◆ draw()

void N draw ( void )

Definition at line 227 of file squirt.c.

227 {
229 s32 hudX, hudY;
230 HudElemID hid;
231
233 hid = acs->hudElemIDs[HIDX_METER];
235 hud_element_get_render_pos(hid, &hudX, &hudY);
236 if (!acs->squirt.draining) {
238 } else {
240 }
241}
void draw_mash_meter_multicolor_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor)
Definition action_cmd.c:231
void draw_mash_meter_mode_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor, s32 colorMode)
Definition action_cmd.c:241
@ MASH_METER_MODE_ONE_COLOR
Definition action_cmd.h:55
void hud_element_get_render_pos(s32 id, s32 *x, s32 *y)
void hud_element_draw_clipped(s32 id)

◆ free()

void N free ( void )

Variable Documentation

◆ actionCmdTableSquirt

s32 actionCmdTableSquirt[]
extern

Definition at line 42 of file action_cmd.c.

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