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

Go to the source code of this file.

Macros

#define HAND_METER_FILL_TICK   1300
 
#define FAN_METER_FILL_TICK   850
 
#define FAIL_METER_FILL_TICK   1100
 
#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

voidupdate (void)
 

Variables

s32 actionCmdTableSmack []
 

Macro Definition Documentation

◆ HAND_METER_FILL_TICK

#define HAND_METER_FILL_TICK   1300

Definition at line 16 of file smack.c.

Referenced by update().

◆ FAN_METER_FILL_TICK

#define FAN_METER_FILL_TICK   850

Definition at line 17 of file smack.c.

Referenced by update().

◆ FAIL_METER_FILL_TICK

#define FAIL_METER_FILL_TICK   1100

Definition at line 18 of file smack.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 smack.c.

Referenced by update().

Enumeration Type Documentation

◆ anonymous enum

Enumerator
HIDX_STICK 
HIDX_METER 
HIDX_100_PCT 

Definition at line 9 of file smack.c.

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

Function Documentation

◆ update()

void N update ( void )

Definition at line 110 of file smack.c.

110 {
113 Actor* partnerActor = battleStatus->partnerActor;
115 s32 cutoff;
116
117 switch (acs->state) {
118 case AC_STATE_INIT:
120 hid = acs->hudElemIDs[HIDX_STICK];
122 if (acs->showHud) {
124 }
125 hid = acs->hudElemIDs[HIDX_METER];
127 if (acs->showHud) {
129 }
130 acs->state = AC_STATE_APPEAR;
131 break;
132 case AC_STATE_APPEAR:
134 if (acs->hudPrepareTime != 0) {
135 acs->hudPrepareTime--;
136 break;
137 }
138
139 acs->hudPosX += 20;
140 if (acs->hudPosX > 50) {
141 acs->hudPosX = 50;
142 }
143
144 hud_element_set_render_pos(acs->hudElemIDs[HIDX_STICK], acs->hudPosX, acs->hudPosY);
145 hud_element_set_render_pos(acs->hudElemIDs[HIDX_METER], acs->hudPosX, acs->hudPosY + 28);
146 break;
147 case AC_STATE_START:
149 if (acs->prepareTime != 0) {
150 acs->prepareTime--;
151 break;
152 }
154 acs->meterFillLevel = 0;
155 battleStatus->resultTier = 0;
156 acs->smack.holdingLeft = false;
157 acs->stateTimer = acs->duration;
159 acs->state = AC_STATE_ACTIVE;
160
161 // fallthrough
162 case AC_STATE_ACTIVE:
164
165 // meter can drain if it hasn't been fully filled
166 if (!acs->isMeterFilled) {
167 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals];
168 acs->meterFillLevel -= GET_DRAIN_RATE(acs->meterFillLevel / cutoff);
169 if (acs->meterFillLevel < 0) {
170 acs->meterFillLevel = 0;
171 }
172 }
173
174 // check for meter-filling input
175 if (!acs->isMeterFilled) {
176 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
177 acs->smack.holdingLeft = true;
178 }
179
180 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)) {
181 if (acs->smack.holdingLeft) {
182 if (acs->variation == ACV_SMACK_HAND) {
183 // regular smack
184 acs->meterFillLevel += SCALE_BY_PCT(HAND_METER_FILL_TICK, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
185 } else {
186 // fan smack
187 acs->meterFillLevel += SCALE_BY_PCT(FAN_METER_FILL_TICK, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
188 }
189 acs->smack.holdingLeft = false;
190 }
191 }
192 // right stick inputs actively drain the meter
193 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
194 acs->meterFillLevel -= SCALE_BY_PCT(FAIL_METER_FILL_TICK, battleStatus->actionCmdDifficultyTable[acs->difficulty]);
195 }
196 }
197
198 if (acs->meterFillLevel < 0) {
199 acs->meterFillLevel = 0;
200 }
201
202 // handle meter reaching 100%
203 if (acs->meterFillLevel > MAX_MASH_UNITS) {
204 acs->meterFillLevel = MAX_MASH_UNITS;
205 acs->isMeterFilled = true;
206 hid = acs->hudElemIDs[HIDX_100_PCT];
207 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY + 28);
209 }
210
211 battleStatus->actionProgress = acs->meterFillLevel / ONE_PCT_MASH;
213
214 switch (partnerActor->actorBlueprint->level) {
216 if (battleStatus->actionProgress >= N(BasicHitThresholds)[battleStatus->resultTier]) {
217 battleStatus->resultTier++;
218 }
219
220 if (battleStatus->resultTier > 0) {
221 if (battleStatus->actionProgress < N(BasicHitThresholds)[battleStatus->resultTier - 1]) {
222 battleStatus->resultTier--;
223 }
224 }
225 break;
227 if (battleStatus->actionProgress >= N(SuperHitThresholds)[battleStatus->resultTier]) {
228 battleStatus->resultTier++;
229 }
230
231 if (battleStatus->resultTier > 0) {
232 if (battleStatus->actionProgress < N(SuperHitThresholds)[battleStatus->resultTier - 1]) {
233 battleStatus->resultTier--;
234 }
235 }
236 break;
238 if (acs->variation == ACV_SMACK_HAND) {
239 if (battleStatus->actionProgress >= N(UltraHitThresholds)[battleStatus->resultTier]) {
240 battleStatus->resultTier++;
241 }
242
243 if (battleStatus->resultTier > 0) {
244 if (battleStatus->actionProgress < N(UltraHitThresholds)[battleStatus->resultTier - 1]) {
245 battleStatus->resultTier--;
246 }
247 }
248 } else {
249 if (battleStatus->actionProgress >= N(FanHitThresholds)[battleStatus->resultTier]) {
250 battleStatus->resultTier++;
251 }
252
253 if (battleStatus->resultTier > 0) {
254 if (battleStatus->actionProgress < N(FanHitThresholds)[battleStatus->resultTier - 1]) {
255 battleStatus->resultTier--;
256 }
257 }
258 }
259 break;
260 }
261
262 if (acs->stateTimer != 0) {
263 acs->stateTimer--;
264 break;
265 }
266
267 if (acs->meterFillLevel == 0) {
268 battleStatus->actionQuality = AC_QUALITY_FAILED;
269 } else {
270 battleStatus->actionQuality = acs->meterFillLevel / ONE_PCT_MASH;
271 }
272
273 cutoff = acs->mashMeterCutoffs[acs->mashMeterNumIntervals - 1];
274 if (battleStatus->actionQuality > cutoff) {
275 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
276 } else {
278 }
279
280 if (battleStatus->actionQuality == 100) {
282 }
283
286 acs->stateTimer = 5;
287 acs->state = AC_STATE_DISPOSE;
288 break;
289 case AC_STATE_DISPOSE:
290 if (acs->stateTimer != 0) {
291 acs->stateTimer--;
292 break;
293 }
295 break;
296 }
297}
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_StickMashLeft
#define MAX_MASH_UNITS
Definition action_cmd.h:75
struct ActorBlueprint * actorBlueprint
s32 HudElemID
@ BUTTON_STICK_LEFT
Definition enums.h:2779
@ BUTTON_STICK_RIGHT
Definition enums.h:2780
@ PARTNER_RANK_NORMAL
Definition enums.h:2051
@ PARTNER_RANK_SUPER
Definition enums.h:2052
@ PARTNER_RANK_ULTRA
Definition enums.h:2053
@ SOUND_LOOP_CHARGE_METER
Definition enums.h:1649
@ ACTION_RESULT_METER_NOT_ENOUGH
Definition enums.h:1991
@ ACTION_RESULT_SUCCESS
Definition enums.h:1994
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)
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 GET_DRAIN_RATE(pct)
Definition smack.c:22
#define FAIL_METER_FILL_TICK
Definition smack.c:18
#define HAND_METER_FILL_TICK
Definition smack.c:16
#define FAN_METER_FILL_TICK
Definition smack.c:17
@ ACV_SMACK_HAND
Definition smack.h:18
#define POPUP_MSG_OFF
Definition battle.h:280
#define POPUP_MSG_ON
Definition battle.h:279
BattleStatus gBattleStatus
Definition battle.cpp:14

Variable Documentation

◆ actionCmdTableSmack

s32 actionCmdTableSmack[]
extern

Definition at line 45 of file action_cmd.c.

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