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

voidupdate (void)
 
voiddraw (void)
 
voidfree (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

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 {
98 s32 cutoff;
99
100 switch (acs->state) {
101 case AC_STATE_INIT:
103
104 hid = acs->hudElemIDs[HIDX_BUTTON];
105 if (acs->showHud) {
107 }
109
110 hid = acs->hudElemIDs[HIDX_METER];
112 if (acs->showHud) {
114 }
115
116 acs->state = AC_STATE_APPEAR;
117 break;
118 case AC_STATE_APPEAR:
120
121 acs->hudPosX += 20;
122 if (acs->hudPosX > 50) {
123 acs->hudPosX = 50;
124 }
125
126 hud_element_set_render_pos(acs->hudElemIDs[HIDX_BUTTON], acs->hudPosX, acs->hudPosY);
127 hud_element_set_render_pos(acs->hudElemIDs[HIDX_METER], acs->hudPosX, acs->hudPosY + 28);
128 break;
129 case AC_STATE_START:
131
132 if (acs->prepareTime != 0) {
133 acs->prepareTime--;
134 break;
135 }
136
138 acs->meterFillLevel = 0;
139 acs->squirt.draining = false;
140 acs->stateTimer = acs->duration;
142 acs->state = AC_STATE_ACTIVE;
143
144 // fallthrough
145 case AC_STATE_ACTIVE:
147
148 // meter filling and draining
149 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
150 fillPct = acs->meterFillLevel / cutoff;
151 if (!acs->squirt.draining) {
152 if (!(battleStatus->curButtonsDown & BUTTON_A)) {
153 acs->meterFillLevel -= GET_DRAIN_RATE(fillPct);
154 if (acs->meterFillLevel < 0) {
155 acs->meterFillLevel = 0;
156 }
157 } else {
159 acs->meterFillLevel += SCALE_BY_PCT(amt, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
160 if (acs->meterFillLevel > MAX_MASH_UNITS) {
161 acs->meterFillLevel = MAX_MASH_UNITS;
162 acs->squirt.draining = true;
163 }
164 }
165 } else {
166 acs->meterFillLevel -= METER_DRAIN_RATE;
167 if (acs->meterFillLevel <= 0) {
168 acs->meterFillLevel = 0;
169 acs->squirt.draining = false;
170 }
171 }
172
173 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
175
176 hid = acs->hudElemIDs[HIDX_BUTTON];
177 if (fillPct < 80) {
180 }
181 } else {
184 }
185 }
186
187 if (acs->stateTimer != 0) {
188 acs->stateTimer--;
189 break;
190 }
191
192 if (acs->meterFillLevel == 0) {
193 battleStatus->actionQuality = AC_QUALITY_FAILED;
194 } else {
195 battleStatus->actionQuality = battleStatus->actionProgress;
196 }
197
198 // a good result is filling the meter over halfway to the second-highest interval
199 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
200 if (battleStatus->actionProgress <= cutoff / 2) {
202 } else {
203 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
204 }
205
206 if (battleStatus->actionQuality == 100) {
207 // only count 100% fill as success for this action command
209 }
210
213 acs->stateTimer = 5;
214 acs->state = AC_STATE_DISPOSE;
215 break;
216 case AC_STATE_DISPOSE:
217 if (acs->stateTimer != 0) {
218 acs->stateTimer--;
219 break;
220 }
222 break;
223 }
224}
BSS s32 PopupMenu_SelectedIndex
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:654
#define AC_QUALITY_FAILED
Definition action_cmd.h:66
@ 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:2776
@ SOUND_LOOP_CHARGE_METER
Definition enums.h:1649
@ ACTION_RESULT_SUCCESS
Definition enums.h:1994
@ ACTION_RESULT_METER_BELOW_HALF
Definition enums.h:1990
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)
void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
#define POPUP_MSG_OFF
Definition battle.h:280
#define POPUP_MSG_ON
Definition battle.h:279
BattleStatus gBattleStatus
Definition battle.cpp:14

◆ draw()

void N draw ( void )

Definition at line 226 of file squirt.c.

226 {
228 s32 hudX, hudY;
230
232 hid = acs->hudElemIDs[HIDX_METER];
235 if (!acs->squirt.draining) {
237 } else {
239 }
240}
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()

Variable Documentation

◆ actionCmdTableSquirt

s32 actionCmdTableSquirt[]
extern

Definition at line 42 of file action_cmd.c.

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