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

Go to the source code of this file.

Macros

#define METER_FILL_TICK   950
 
#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 actionCmdTableFireShell []
 

Macro Definition Documentation

◆ METER_FILL_TICK

#define METER_FILL_TICK   950

Definition at line 16 of file fire_shell.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 fire_shell.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 fire_shell.c.

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

Function Documentation

◆ update()

void N update ( void )

Definition at line 109 of file fire_shell.c.

109 {
111 BattleStatus* battleStatus = &gBattleStatus;
112 Actor* partner = battleStatus->partnerActor;
113 HudElemID hid;
114 s32 cutoff;
115
116 switch (acs->state) {
117 case AC_STATE_INIT:
119
120 hid = acs->hudElemIDs[HIDX_STICK];
121 hud_element_set_alpha(hid, 255);
122 if (acs->showHud) {
124 }
125
126 hid = acs->hudElemIDs[HIDX_METER];
127 hud_element_set_alpha(hid, 255);
128 if (acs->showHud) {
130 }
131
132 acs->state = AC_STATE_APPEAR;
133 break;
134 case AC_STATE_APPEAR:
136 acs->hudPosX += 20;
137 if (acs->hudPosX > 50) {
138 acs->hudPosX = 50;
139 }
142 break;
143 case AC_STATE_START:
145 if (acs->prepareTime != 0) {
146 acs->prepareTime--;
147 return;
148 }
150 acs->meterFillLevel = 0;
151 battleStatus->resultTier = 0;
152 acs->fireShell.holdingLeft = FALSE;
153 acs->stateTimer = acs->duration;
155 acs->state = AC_STATE_ACTIVE;
156
157 // fallthrough
158 case AC_STATE_ACTIVE:
160
161 // meter can drain if it hasn't been fully filled
162 if (!acs->isMeterFilled) {
163 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
164 acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / cutoff);
165 if (acs->meterFillLevel < 0) {
166 acs->meterFillLevel = 0;
167 }
168 }
169
170 // check for meter-filling input
171 if (!acs->isMeterFilled) {
172 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
173 acs->fireShell.holdingLeft = TRUE;
174 }
175
176 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)) {
177 if (acs->fireShell.holdingLeft != 0) {
178 s32 difficultyPct = battleStatus->actionCmdDifficultyTable[acs->difficulty];
179 acs->meterFillLevel += SCALE_BY_PCT(METER_FILL_TICK, difficultyPct);
180 acs->fireShell.holdingLeft = FALSE;
181 }
182 }
183
184 // right stick inputs actively drain the meter
185 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
186 s32 difficultyPct = battleStatus->actionCmdDifficultyTable[acs->difficulty];
187 acs->meterFillLevel -= SCALE_BY_PCT(METER_FILL_TICK, difficultyPct);
188 }
189 }
190
191 if (acs->meterFillLevel < 0) {
192 acs->meterFillLevel = 0;
193 }
194
195 // handle meter reaching 100%
196 if (acs->meterFillLevel > MAX_MASH_UNITS) {
198 acs->isMeterFilled = TRUE;
199 hid = acs->hudElemIDs[HIDX_100_PCT];
200 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
202 }
203
204 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
206
207 // resultTier is not used by this move; uses actionProgress instead via the move script
208 switch (partner->actorBlueprint->level) {
210 if (battleStatus->actionProgress >= N(BasicThresholds)[battleStatus->resultTier]) {
211 battleStatus->resultTier++;
212 }
213 if (battleStatus->resultTier > 0 && (battleStatus->actionProgress < N(BasicThresholds)[battleStatus->resultTier - 1])) {
214 battleStatus->resultTier--;
215 }
216 break;
218 if (battleStatus->actionProgress >= N(SuperThresholds)[battleStatus->resultTier]) {
219 battleStatus->resultTier++;
220 }
221 if (battleStatus->resultTier > 0 && (battleStatus->actionProgress < N(SuperThresholds)[battleStatus->resultTier - 1])) {
222 battleStatus->resultTier--;
223 }
224 break;
226 if (battleStatus->actionProgress >= N(UltraThresholds)[battleStatus->resultTier]) {
227 battleStatus->resultTier++;
228 }
229 if (battleStatus->resultTier > 0 && (battleStatus->actionProgress < N(UltraThresholds)[battleStatus->resultTier - 1])) {
230 battleStatus->resultTier--;
231 }
232 break;
233 }
234
235 if (acs->stateTimer != 0) {
236 acs->stateTimer--;
237 break;
238 }
239
240 if (acs->meterFillLevel == 0) {
241 battleStatus->actionQuality = AC_QUALITY_FAILED;
242 } else {
243 battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
244 }
245
246 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
247 if (battleStatus->actionQuality > cutoff) {
248 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
249 } else {
251 }
252
253 if (battleStatus->actionQuality == 100) {
254 // only count 100% fill as success for this action command
256 }
257
260 acs->stateTimer = 5;
261 acs->state = AC_STATE_DISPOSE;
262 break;
263 case AC_STATE_DISPOSE:
264 if (acs->stateTimer != 0) {
265 acs->stateTimer--;
266 break;
267 }
269 break;
270 }
271}
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
struct ActorBlueprint * actorBlueprint
s32 HudElemID
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ PARTNER_RANK_NORMAL
Definition enums.h:2018
@ PARTNER_RANK_SUPER
Definition enums.h:2019
@ PARTNER_RANK_ULTRA
Definition enums.h:2020
@ SOUND_LOOP_CHARGE_METER
Definition enums.h:1646
@ ACTION_RESULT_METER_NOT_ENOUGH
Definition enums.h:1965
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
#define METER_FILL_TICK
Definition fire_shell.c:16
#define GET_DRAIN_RATE(pct)
Definition fire_shell.c:20
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
struct Actor * partnerActor
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11

Variable Documentation

◆ actionCmdTableFireShell

s32 actionCmdTableFireShell[]
extern

Definition at line 36 of file action_cmd.c.

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