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

Go to the source code of this file.

Macros

#define METER_FILL_RATE   850
 
#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 actionCmdTableAirRaid []
 

Macro Definition Documentation

◆ METER_FILL_RATE

#define METER_FILL_RATE   850

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

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

Function Documentation

◆ update()

void N update ( void )

Definition at line 109 of file air_raid.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
137 if (acs->hudPrepareTime != 0) {
138 acs->hudPrepareTime--;
139 return;
140 }
141
142 acs->hudPosX += 20;
143 if (acs->hudPosX > 50) {
144 acs->hudPosX = 50;
145 }
146
149 break;
150 case AC_STATE_START:
152
153 if (acs->prepareTime != 0) {
154 acs->prepareTime--;
155 return;
156 }
157
159 acs->meterFillLevel = 0;
160 battleStatus->resultTier = 0;
161 acs->airRaid.holdingLeft = FALSE;
162 acs->stateTimer = acs->duration;
164 acs->state = AC_STATE_ACTIVE;
165
166 // fallthrough
167 case AC_STATE_ACTIVE:
169
170 // meter can drain if it hasn't been fully filled
171 if (!acs->isMeterFilled) {
172 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
173 acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / cutoff);
174 if (acs->meterFillLevel < 0) {
175 acs->meterFillLevel = 0;
176 }
177 }
178
179 // check for meter-filling input
180 if (!acs->isMeterFilled) {
181 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
182 acs->airRaid.holdingLeft = TRUE;
183 }
184
185 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)) {
186 if (acs->airRaid.holdingLeft) {
188 acs->airRaid.holdingLeft = FALSE;
189 }
190 }
191
192 // right stick inputs actively drain the meter
193 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
195 }
196 }
197
198
199 if (acs->meterFillLevel < 0) {
200 acs->meterFillLevel = 0;
201 }
202
203 // handle meter reaching 100%
204 if (acs->meterFillLevel > MAX_MASH_UNITS) {
206 acs->isMeterFilled = TRUE;
207 hid = acs->hudElemIDs[HIDX_100_PCT];
208 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
210 }
211
212 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
214
215 // resultTier is not used by this move; uses actionProgress instead via the move script
216 switch (partner->actorBlueprint->level) {
218 if (battleStatus->actionProgress >= N(BasicThresholds)[battleStatus->resultTier]) {
219 battleStatus->resultTier++;
220 }
221
222 if (battleStatus->resultTier > 0 && battleStatus->actionProgress < N(BasicThresholds)[battleStatus->resultTier - 1]) {
223 battleStatus->resultTier--;
224 }
225 break;
227 if (battleStatus->actionProgress >= N(SuperThresholds)[battleStatus->resultTier]) {
228 battleStatus->resultTier++;
229 }
230 if (battleStatus->resultTier > 0 && battleStatus->actionProgress < N(SuperThresholds)[battleStatus->resultTier - 1]) {
231 battleStatus->resultTier--;
232 }
233 break;
235 if (battleStatus->actionProgress >= N(UltraThresholds)[battleStatus->resultTier]) {
236 battleStatus->resultTier++;
237 }
238 if (battleStatus->resultTier > 0 && battleStatus->actionProgress < N(UltraThresholds)[battleStatus->resultTier - 1]) {
239 battleStatus->resultTier--;
240 }
241 break;
242 }
243
244 if (acs->stateTimer != 0) {
245 acs->stateTimer--;
246 break;
247 }
248
249 if (acs->meterFillLevel == 0) {
250 battleStatus->actionQuality = AC_QUALITY_FAILED;
251 } else {
252 battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
253 }
254
255 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
256 if (battleStatus->actionQuality > cutoff) {
257 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
258 } else {
260 }
261
262 if (battleStatus->actionQuality == 100) {
263 // only count 100% fill as success for this action command
265 }
266
269 acs->stateTimer = 5;
270 acs->state = AC_STATE_DISPOSE;
271 break;
272 case AC_STATE_DISPOSE:
273 if (acs->stateTimer != 0) {
274 acs->stateTimer--;
275 break;
276 }
278 break;
279 }
280}
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
#define GET_DRAIN_RATE(pct)
Definition air_raid.c:20
#define METER_FILL_RATE
Definition air_raid.c:16
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
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

◆ actionCmdTableAirRaid

s32 actionCmdTableAirRaid[]
extern

Definition at line 41 of file action_cmd.c.

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