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

voidupdate (void)
 
voiddraw (void)
 
voidfree (void)
 

Variables

s32 actionCmdTableHammer []
 

Enumeration Type Documentation

◆ 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 {
129 s32 i;
130 s32 new_var;
131
132 switch (acs->state) {
133 case AC_STATE_INIT:
135
136 hid = acs->hudElemIDs[HIDX_FRAME];
137 if (acs->showHud) {
139 }
141
142 hid = acs->hudElemIDs[HIDX_WAIT];
143 if (acs->showHud) {
145 }
147
148 hid = acs->hudElemIDs[HIDX_CHARGE_A];
149 if (acs->showHud) {
151 }
153
154 hid = acs->hudElemIDs[HIDX_CHARGE_B];
155 if (acs->showHud) {
157 }
159
160 hid = acs->hudElemIDs[HIDX_CHARGE_C];
161 if (acs->showHud) {
163 }
165
166 hid = acs->hudElemIDs[HIDX_STICK];
167 if (acs->showHud) {
169 }
171
172 acs->state = AC_STATE_APPEAR;
173 break;
174 case AC_STATE_APPEAR:
176 acs->hudPosX += 20;
177 if (acs->hudPosX > 50) {
178 acs->hudPosX = 50;
179 }
180 hud_element_set_render_pos(acs->hudElemIDs[HIDX_FRAME], acs->hudPosX, acs->hudPosY);
181 hud_element_set_render_pos(acs->hudElemIDs[HIDX_WAIT], acs->hudPosX + 21, acs->hudPosY - 3);
182 hud_element_set_render_pos(acs->hudElemIDs[HIDX_CHARGE_A], acs->hudPosX + 5, acs->hudPosY + 1);
183 hud_element_set_render_pos(acs->hudElemIDs[HIDX_CHARGE_B], acs->hudPosX - 7, acs->hudPosY + 1);
184 hud_element_set_render_pos(acs->hudElemIDs[HIDX_CHARGE_C], acs->hudPosX - 19, acs->hudPosY + 1);
185 hud_element_set_render_pos(acs->hudElemIDs[HIDX_STICK], acs->hudPosX, acs->hudPosY - 23);
186 if (acs->autoSucceed != 0) {
187 hid = acs->hudElemIDs[HIDX_RIGHT_ON];
188 hud_element_set_render_pos(hid, acs->hudPosX + 50, acs->hudPosY);
189 if (acs->showHud) {
191 break;
192 }
193 }
194 break;
195 case AC_STATE_START:
197 if (acs->prepareTime < 15) {
198 hud_element_set_alpha(acs->hudElemIDs[HIDX_FRAME], 255);
199 hud_element_set_alpha(acs->hudElemIDs[HIDX_WAIT], 255);
200 hud_element_set_alpha(acs->hudElemIDs[HIDX_CHARGE_A], 255);
201 hud_element_set_alpha(acs->hudElemIDs[HIDX_CHARGE_B], 255);
202 hud_element_set_alpha(acs->hudElemIDs[HIDX_CHARGE_C], 255);
203 hud_element_set_alpha(acs->hudElemIDs[HIDX_STICK], 255);
204 }
205
206 if (acs->prepareTime != 0) {
207 acs->prepareTime--;
208 return;
209 }
210
211 acs->stateTimer = 0;
212 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) && battleStatus->actionCommandMode < AC_MODE_TUTORIAL) {
213 acs->hammerMissedStart = true;
214 }
215 acs->state = AC_STATE_ACTIVE;
216
217 // fallthrough
218 case AC_STATE_ACTIVE:
220
221 if (battleStatus->actionCommandMode <= AC_MODE_TUTORIAL_BLOCK) {
222 return;
223 }
224
225 inputWindow = battleStatus->actionCmdDifficultyTable[acs->difficulty];
226 new_var = inputWindow + 2;
227 oneThird = (acs->duration - new_var) / 3;
228
229 if (acs->stateTimer < oneThird) {
231 battleStatus->actionProgress = 0;
232 if (acs->stateTimer == 0) {
233 if (acs->playHammerSounds) {
235 }
236 }
237 } else if (acs->stateTimer < oneThird * 2) {
239 battleStatus->actionProgress = 1;
240 if (acs->stateTimer == oneThird) {
241 if (acs->playHammerSounds) {
243 }
244 }
245 } else if (acs->stateTimer < oneThird * 3) {
247 battleStatus->actionProgress = 2;
248 if (acs->stateTimer == oneThird * 2) {
249 if (acs->playHammerSounds) {
251 }
252 }
253 }
254
255 if (acs->stateTimer == (-(inputWindow + 1) + acs->duration)) {
256 battleStatus->actionProgress = 3;
259 if (acs->playHammerSounds) {
261 }
262 if (acs->autoSucceed != 0 && acs->autoSucceed != 2) {
263 acs->autoSucceed = 2;
264 acs->stateTimer = acs->duration - 4;
265 }
266 }
267 inputWindow = battleStatus->actionCmdDifficultyTable[acs->difficulty] - (acs->duration - acs->stateTimer) + 3;
268 if (inputWindow < 0) {
269 inputWindow = 0;
270 }
271
272 // has the stick been release too early?
273 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)
274 && inputWindow == 0
275 && acs->autoSucceed == 0
276 && battleStatus->actionCommandMode < AC_MODE_TUTORIAL
277 ) {
278 battleStatus->actionQuality = AC_QUALITY_FAILED;
279 battleStatus->actionResult = ACTION_RESULT_EARLY;
281 return;
282 }
283
284 // step back several frames in the input buffer
285 bufferPos = battleStatus->inputBufferPos;
287 if (bufferPos < 0) {
288 bufferPos += ARRAY_COUNT(battleStatus->holdInputBuffer);
289 }
290
291 // has the stick been released within the window?
292 if (battleStatus->actionQuality == 0) {
293 for (i = 0; i < inputWindow; i++) {
294 if (bufferPos >= ARRAY_COUNT(battleStatus->holdInputBuffer)) {
295 bufferPos -= ARRAY_COUNT(battleStatus->holdInputBuffer);
296 }
297
298 if (!(battleStatus->holdInputBuffer[bufferPos] & BUTTON_STICK_LEFT) || acs->autoSucceed != 0) {
299 battleStatus->actionQuality = 1;
300 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
302 }
303 bufferPos++;
304 }
305 }
306
307 if (battleStatus->actionCommandMode < AC_MODE_TUTORIAL || acs->stateTimer != acs->duration) {
308 acs->stateTimer++;
309 if (acs->duration < acs->stateTimer) {
310 if (battleStatus->actionQuality == 0) {
311 battleStatus->actionQuality = AC_QUALITY_FAILED;
312 }
313
314 if (battleStatus->actionQuality == 1) {
316 }
317
319 acs->stateTimer = 5;
320 acs->state = AC_STATE_DISPOSE;
321 }
322 }
323 break;
324 case AC_STATE_DISPOSE:
325 if (acs->stateTimer != 0) {
326 acs->stateTimer--;
327 return;
328 }
330 break;
331 }
332}
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
HudScript HES_TimingCharge3
#define AC_QUALITY_FAILED
Definition action_cmd.h:66
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:2779
@ BS_FLAGS1_2000
Definition enums.h:3615
@ SOUND_TIMING_BAR_TICK
Definition enums.h:955
@ SOUND_TIMING_BAR_GO
Definition enums.h:956
@ ACTION_RESULT_EARLY
Definition enums.h:1992
@ 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_play_sound(s32 soundID)
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define POPUP_MSG_OFF
Definition battle.h:280
#define POPUP_MSG_ON
Definition battle.h:279
BattleStatus gBattleStatus
Definition battle.cpp:14

◆ 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 };