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

Go to the source code of this file.

Macros

#define BASIC_FILL_TICK   940
 
#define SUPER_FILL_TICK   800
 
#define ULTRA_FILL_TICK   740
 
#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 actionCmdTableBomb []
 

Macro Definition Documentation

◆ BASIC_FILL_TICK

#define BASIC_FILL_TICK   940

Definition at line 16 of file bomb.c.

Referenced by update().

◆ SUPER_FILL_TICK

#define SUPER_FILL_TICK   800

Definition at line 17 of file bomb.c.

Referenced by update().

◆ ULTRA_FILL_TICK

#define ULTRA_FILL_TICK   740

Definition at line 18 of file bomb.c.

Referenced by update().

◆ GET_DRAIN_RATE

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

Definition at line 22 of file bomb.c.

Referenced by update().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HIDX_BUTTON 
HIDX_METER 
HIDX_100_PCT 

Definition at line 9 of file bomb.c.

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

Function Documentation

◆ update()

void N update ( void )

Definition at line 104 of file bomb.c.

104 {
106 BattleStatus* battleStatus = &gBattleStatus;
107 HudElemID hid;
108 s32 cutoff;
109
110 switch (acs->state) {
111 case AC_STATE_INIT:
113 hid = acs->hudElemIDs[HIDX_BUTTON];
114 hud_element_set_alpha(hid, 255);
115 if (acs->showHud) {
117 }
118
119 hid = acs->hudElemIDs[HIDX_METER];
120 hud_element_set_alpha(hid, 255);
121 if (acs->showHud) {
123 }
124
125 acs->state = AC_STATE_APPEAR;
126 break;
127 case AC_STATE_APPEAR:
129
130 acs->hudPosX += 20;
131 if (acs->hudPosX > 50) {
132 acs->hudPosX = 50;
133 }
134
137 break;
138 case AC_STATE_START:
140
141 if (acs->prepareTime != 0) {
142 acs->prepareTime--;
143 break;
144 }
145
147 acs->meterFillLevel = 0;
148 acs->stateTimer = acs->duration;
150 acs->state = AC_STATE_ACTIVE;
151
152 // fallthrough
153 case AC_STATE_ACTIVE:
155
156 // meter can drain if it hasn't been fully filled
157 if (!acs->isMeterFilled) {
158 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
159 acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / cutoff);
160 if (acs->meterFillLevel < 0) {
161 acs->meterFillLevel = 0;
162 }
163 }
164
165 // check for meter-filling input
166 if (battleStatus->curButtonsPressed & BUTTON_A) {
167 switch (acs->variation) {
168 case ACV_BOMB_BASIC:
170 break;
171 case ACV_BOMB_SUPER:
173 break;
174 case ACV_BOMB_ULTRA:
176 break;
177 }
178 }
179
180 // handle meter reaching 100%
181 if (acs->meterFillLevel > MAX_MASH_UNITS) {
183 acs->isMeterFilled = TRUE;
184 hid = acs->hudElemIDs[HIDX_100_PCT];
185 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
187 }
188
189 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
191
192 if (acs->stateTimer != 0) {
193 acs->stateTimer--;
194 break;
195 }
196
197 if (acs->meterFillLevel == 0) {
198 battleStatus->actionQuality = AC_QUALITY_FAILED;
199 } else {
200 battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
201 }
202
203 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
204 if (battleStatus->actionQuality > cutoff) {
205 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
206 } else {
208 }
209
210 if (battleStatus->actionQuality == 100) {
211 // only count 100% fill as success for this action command
213 }
214
217 acs->stateTimer = 5;
218 acs->state = AC_STATE_DISPOSE;
219 break;
220 case AC_STATE_DISPOSE:
221 if (acs->stateTimer != 0) {
222 acs->stateTimer--;
223 break;
224 }
226 break;
227 }
228}
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_MashAButton
#define MAX_MASH_UNITS
Definition action_cmd.h:75
#define ULTRA_FILL_TICK
Definition bomb.c:18
#define GET_DRAIN_RATE(pct)
Definition bomb.c:22
#define SUPER_FILL_TICK
Definition bomb.c:17
#define BASIC_FILL_TICK
Definition bomb.c:16
@ ACV_BOMB_ULTRA
Definition bomb.h:20
@ ACV_BOMB_BASIC
Definition bomb.h:18
@ ACV_BOMB_SUPER
Definition bomb.h:19
s32 HudElemID
@ 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

◆ actionCmdTableBomb

s32 actionCmdTableBomb[]
extern

Definition at line 38 of file action_cmd.c.

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