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

Go to the source code of this file.

Enumerations

enum  {
  HIDX_FRAME = 0 , HIDX_WAIT = 1 , HIDX_CHARGE_A = 2 , HIDX_CHARGE_B = 3 ,
  HIDX_CHARGE_C = 4 , HIDX_STICK = 5 , HIDX_RIGHT_ON = 6
}
 

Functions

void N update (void)
 
void N draw (void)
 
void N free (void)
 

Variables

s32 actionCmdTableHammer []
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HIDX_FRAME 
HIDX_WAIT 
HIDX_CHARGE_A 
HIDX_CHARGE_B 
HIDX_CHARGE_C 
HIDX_STICK 
HIDX_RIGHT_ON 

Definition at line 9 of file hammer.c.

9 {
10 HIDX_FRAME = 0,
11 HIDX_WAIT = 1,
12 HIDX_CHARGE_A = 2,
13 HIDX_CHARGE_B = 3,
14 HIDX_CHARGE_C = 4,
15 HIDX_STICK = 5,
16 HIDX_RIGHT_ON = 6,
17};
@ HIDX_CHARGE_C
Definition hammer.c:14
@ HIDX_STICK
Definition hammer.c:15
@ HIDX_FRAME
Definition hammer.c:10
@ HIDX_CHARGE_A
Definition hammer.c:12
@ HIDX_RIGHT_ON
Definition hammer.c:16
@ HIDX_WAIT
Definition hammer.c:11
@ HIDX_CHARGE_B
Definition hammer.c:13

Function Documentation

◆ update()

void N update ( void )

Definition at line 122 of file hammer.c.

122 {
124 BattleStatus* battleStatus = &gBattleStatus;
125 Actor* partner = battleStatus->partnerActor;
126 HudElemID hid;
127 f32 oneThird;
128 s32 inputWindow;
129 s32 bufferPos;
130 s32 i;
131 s32 new_var;
132
133 switch (acs->state) {
134 case AC_STATE_INIT:
136
137 hid = acs->hudElemIDs[HIDX_FRAME];
138 if (acs->showHud) {
140 }
141 hud_element_set_alpha(hid, 255);
142
143 hid = acs->hudElemIDs[HIDX_WAIT];
144 if (acs->showHud) {
146 }
147 hud_element_set_alpha(hid, 255);
148
149 hid = acs->hudElemIDs[HIDX_CHARGE_A];
150 if (acs->showHud) {
152 }
153 hud_element_set_alpha(hid, 255);
154
155 hid = acs->hudElemIDs[HIDX_CHARGE_B];
156 if (acs->showHud) {
158 }
159 hud_element_set_alpha(hid, 255);
160
161 hid = acs->hudElemIDs[HIDX_CHARGE_C];
162 if (acs->showHud) {
164 }
165 hud_element_set_alpha(hid, 255);
166
167 hid = acs->hudElemIDs[HIDX_STICK];
168 if (acs->showHud) {
170 }
171 hud_element_set_alpha(hid, 255);
172
173 acs->state = AC_STATE_APPEAR;
174 break;
175 case AC_STATE_APPEAR:
177 acs->hudPosX += 20;
178 if (acs->hudPosX > 50) {
179 acs->hudPosX = 50;
180 }
187 if (acs->autoSucceed != 0) {
188 hid = acs->hudElemIDs[HIDX_RIGHT_ON];
189 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY);
190 if (acs->showHud) {
192 break;
193 }
194 }
195 break;
196 case AC_STATE_START:
198 if (acs->prepareTime < 15) {
205 }
206
207 if (acs->prepareTime != 0) {
208 acs->prepareTime--;
209 return;
210 }
211
212 acs->stateTimer = 0;
213 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) && battleStatus->actionCommandMode < AC_MODE_TUTORIAL) {
214 acs->hammerMissedStart = TRUE;
215 }
216 acs->state = AC_STATE_ACTIVE;
217
218 // fallthrough
219 case AC_STATE_ACTIVE:
221
222 if (battleStatus->actionCommandMode <= AC_MODE_TUTORIAL_BLOCK) {
223 return;
224 }
225
226 inputWindow = battleStatus->actionCmdDifficultyTable[acs->difficulty];
227 new_var = inputWindow + 2;
228 oneThird = (acs->duration - new_var) / 3;
229
230 if (acs->stateTimer < oneThird) {
232 battleStatus->actionProgress = 0;
233 if (acs->stateTimer == 0) {
234 if (acs->playHammerSounds) {
236 }
237 }
238 } else if (acs->stateTimer < oneThird * 2) {
240 battleStatus->actionProgress = 1;
241 if (acs->stateTimer == oneThird) {
242 if (acs->playHammerSounds) {
244 }
245 }
246 } else if (acs->stateTimer < oneThird * 3) {
248 battleStatus->actionProgress = 2;
249 if (acs->stateTimer == oneThird * 2) {
250 if (acs->playHammerSounds) {
252 }
253 }
254 }
255
256 if (acs->stateTimer == (-(inputWindow + 1) + acs->duration)) {
257 battleStatus->actionProgress = 3;
260 if (acs->playHammerSounds) {
262 }
263 if (acs->autoSucceed != 0 && acs->autoSucceed != 2) {
264 acs->autoSucceed = 2;
265 acs->stateTimer = acs->duration - 4;
266 }
267 }
268 inputWindow = battleStatus->actionCmdDifficultyTable[acs->difficulty] - (acs->duration - acs->stateTimer) + 3;
269 if (inputWindow < 0) {
270 inputWindow = 0;
271 }
272
273 // has the stick been release too early?
274 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)
275 && inputWindow == 0
276 && acs->autoSucceed == 0
277 && battleStatus->actionCommandMode < AC_MODE_TUTORIAL
278 ) {
279 battleStatus->actionQuality = AC_QUALITY_FAILED;
280 battleStatus->actionResult = ACTION_RESULT_EARLY;
282 return;
283 }
284
285 // step back several frames in the input buffer
286 bufferPos = battleStatus->inputBufferPos;
287 bufferPos -= inputWindow;
288 if (bufferPos < 0) {
289 bufferPos += ARRAY_COUNT(battleStatus->holdInputBuffer);
290 }
291
292 // has the stick been released within the window?
293 if (battleStatus->actionQuality == 0) {
294 for (i = 0; i < inputWindow; i++) {
295 if (bufferPos >= ARRAY_COUNT(battleStatus->holdInputBuffer)) {
296 bufferPos -= ARRAY_COUNT(battleStatus->holdInputBuffer);
297 }
298
299 if (!(battleStatus->holdInputBuffer[bufferPos] & BUTTON_STICK_LEFT) || acs->autoSucceed != 0) {
300 battleStatus->actionQuality = 1;
301 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
303 }
304 bufferPos++;
305 }
306 }
307
308 if (battleStatus->actionCommandMode < AC_MODE_TUTORIAL || acs->stateTimer != acs->duration) {
309 acs->stateTimer++;
310 if (acs->duration < acs->stateTimer) {
311 if (battleStatus->actionQuality == 0) {
312 battleStatus->actionQuality = AC_QUALITY_FAILED;
313 }
314
315 if (battleStatus->actionQuality == 1) {
317 }
318
320 acs->stateTimer = 5;
321 acs->state = AC_STATE_DISPOSE;
322 }
323 }
324 break;
325 case AC_STATE_DISPOSE:
326 if (acs->stateTimer != 0) {
327 acs->stateTimer--;
328 return;
329 }
331 break;
332 }
333}
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
HudScript HES_TimingCharge3
#define AC_QUALITY_FAILED
Definition action_cmd.h:66
HudElemID hudElemIDs[16]
Definition action_cmd.h:83
HudScript HES_TimingReady
@ 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
HudScript HES_StickTapNeutral
HudScript HES_TimingCharge2
HudScript HES_TimingCharge1
@ AC_MODE_TUTORIAL_BLOCK
Definition action_cmd.h:59
@ AC_MODE_TUTORIAL
Definition action_cmd.h:62
s32 HudElemID
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BS_FLAGS1_2000
Definition enums.h:3581
@ SOUND_TIMING_BAR_TICK
Definition enums.h:952
@ SOUND_TIMING_BAR_GO
Definition enums.h:953
@ ACTION_RESULT_EARLY
Definition enums.h:1966
@ 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_play_sound(s32 soundID)
Definition sfx.c:517
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define POPUP_MSG_OFF
Definition battle.h:270
#define POPUP_MSG_ON
Definition battle.h:269
s32 holdInputBuffer[64]
struct Actor * partnerActor
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11

◆ draw()

◆ free()

Variable Documentation

◆ actionCmdTableHammer

s32 actionCmdTableHammer[]
extern

Definition at line 29 of file action_cmd.c.

29{ 11, 10, 9, 8, 7, 6, 5, 4 };