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

Go to the source code of this file.

Functions

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

Variables

s32 actionCmdTableHammer []
 

Function Documentation

◆ update()

void N update ( void )

Definition at line 109 of file hammer.c.

109 {
110 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
111 BattleStatus* battleStatus = &gBattleStatus;
112 Actor* partner = battleStatus->partnerActor;
113 s32 id;
114 f32 temp_f20;
115 s32 phi_s0;
116 s32 new_var;
117 s32 a;
118
119 switch (actionCommandStatus->state) {
120 case 0:
122
123 id = actionCommandStatus->hudElements[0];
124 if (actionCommandStatus->showHud) {
126 }
127 hud_element_set_alpha(id, 255);
128
129 id = actionCommandStatus->hudElements[1];
130 if (actionCommandStatus->showHud) {
132 }
133 hud_element_set_alpha(id, 255);
134
135 id = actionCommandStatus->hudElements[2];
136 if (actionCommandStatus->showHud) {
138 }
139 hud_element_set_alpha(id, 255);
140
141 id = actionCommandStatus->hudElements[3];
142 if (actionCommandStatus->showHud) {
144 }
145 hud_element_set_alpha(id, 255);
146
147 id = actionCommandStatus->hudElements[4];
148 if (actionCommandStatus->showHud) {
150 }
151 hud_element_set_alpha(id, 255);
152
153 id = actionCommandStatus->hudElements[5];
154 if (actionCommandStatus->showHud) {
156 }
157 hud_element_set_alpha(id, 255);
158
159 actionCommandStatus->state = 1;
160 break;
161 case 1:
163 actionCommandStatus->hudPosX += 20;
164 if (actionCommandStatus->hudPosX > 50) {
165 actionCommandStatus->hudPosX = 50;
166 }
167 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
168 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX + 21, actionCommandStatus->hudPosY - 3);
169 hud_element_set_render_pos(actionCommandStatus->hudElements[2], actionCommandStatus->hudPosX + 5, actionCommandStatus->hudPosY + 1);
170 hud_element_set_render_pos(actionCommandStatus->hudElements[3], actionCommandStatus->hudPosX - 7, actionCommandStatus->hudPosY + 1);
171 hud_element_set_render_pos(actionCommandStatus->hudElements[4], actionCommandStatus->hudPosX - 19, actionCommandStatus->hudPosY + 1);
172 hud_element_set_render_pos(actionCommandStatus->hudElements[5], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY - 23);
173 if (actionCommandStatus->autoSucceed != 0) {
174 id = actionCommandStatus->hudElements[6];
175 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY);
176 if (actionCommandStatus->showHud) {
178 break;
179 }
180 }
181 break;
182 case 10:
184 if (actionCommandStatus->prepareTime < 15) {
185 hud_element_set_alpha(actionCommandStatus->hudElements[0], 255);
186 hud_element_set_alpha(actionCommandStatus->hudElements[1], 255);
187 hud_element_set_alpha(actionCommandStatus->hudElements[2], 255);
188 hud_element_set_alpha(actionCommandStatus->hudElements[3], 255);
189 hud_element_set_alpha(actionCommandStatus->hudElements[4], 255);
190 hud_element_set_alpha(actionCommandStatus->hudElements[5], 255);
191 }
192
193 if (actionCommandStatus->prepareTime != 0) {
194 actionCommandStatus->prepareTime--;
195 return;
196 }
197
198 actionCommandStatus->frameCounter = 0;
199 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) && battleStatus->actionCommandMode < ACTION_COMMAND_MODE_TUTORIAL) {
200 actionCommandStatus->hammerMissedStart = TRUE;
201 }
202 actionCommandStatus->state = 11;
203 case 11:
205
207 return;
208 }
209
210 phi_s0 = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty];
211 new_var = phi_s0 + 2;
212 temp_f20 = (actionCommandStatus->duration - new_var) / 3;
213
214 if (actionCommandStatus->frameCounter < temp_f20) {
215 hud_element_set_script(actionCommandStatus->hudElements[4], &HES_TimingCharge3);
216 battleStatus->actionQuality = 0;
217 if (actionCommandStatus->frameCounter == 0 && actionCommandStatus->playHammerSounds) {
219 }
220 } else if (actionCommandStatus->frameCounter < temp_f20 * 2) {
221 hud_element_set_script(actionCommandStatus->hudElements[3], &HES_TimingCharge2);
222 battleStatus->actionQuality = 1;
223 if (actionCommandStatus->frameCounter == temp_f20) {
224 if (actionCommandStatus->playHammerSounds) {
226 }
227 }
228 } else if (actionCommandStatus->frameCounter < temp_f20 * 3.0f) {
229 hud_element_set_script(actionCommandStatus->hudElements[2], &HES_TimingCharge1);
230 battleStatus->actionQuality = 2;
231 if (actionCommandStatus->frameCounter == temp_f20 * 2) {
232 if (actionCommandStatus->playHammerSounds) {
234 }
235 }
236 }
237
238 if (actionCommandStatus->frameCounter == (~phi_s0 + actionCommandStatus->duration)) {
239 battleStatus->actionQuality = 3;
240 hud_element_set_script(actionCommandStatus->hudElements[1], &HES_TimingReady);
241 hud_element_set_script(actionCommandStatus->hudElements[5], &HES_StickTapNeutral);
242 if (actionCommandStatus->playHammerSounds) {
244 }
245 if (actionCommandStatus->autoSucceed != 0 && actionCommandStatus->autoSucceed != 2) {
246 actionCommandStatus->autoSucceed = 2;
247 actionCommandStatus->frameCounter = actionCommandStatus->duration - 4;
248 }
249 }
250
251 a = actionCommandStatus->duration - actionCommandStatus->frameCounter;
252 phi_s0 = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] - a + 3;
253 if (phi_s0 < 0) {
254 phi_s0 = 0;
255 }
256
257 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) &&
258 phi_s0 == 0 &&
259 actionCommandStatus->autoSucceed == 0 &&
261 {
262 battleStatus->actionSuccess = -1;
263 battleStatus->actionResult = ACTION_RESULT_EARLY;
265 } else {
266 s32 i;
267 s32 bufferPos;
268
269 bufferPos = battleStatus->inputBufferPos;
270 bufferPos -= phi_s0;
271 if (bufferPos < 0) {
272 bufferPos += ARRAY_COUNT(battleStatus->holdInputBuffer);
273 }
274
275 if (battleStatus->actionSuccess == 0) {
276 for (i = 0; i < phi_s0; i++, bufferPos++) {
277 if (bufferPos >= ARRAY_COUNT(battleStatus->holdInputBuffer)) {
278 bufferPos -= ARRAY_COUNT(battleStatus->holdInputBuffer);
279 }
280
281 if (!(battleStatus->holdInputBuffer[bufferPos] & BUTTON_STICK_LEFT) ||
282 actionCommandStatus->autoSucceed != 0)
283 {
284 battleStatus->actionSuccess = 1;
285 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
287 }
288 }
289 }
290
291 if (battleStatus->actionCommandMode < ACTION_COMMAND_MODE_TUTORIAL || actionCommandStatus->frameCounter != actionCommandStatus->duration) {
292 actionCommandStatus->frameCounter++;
293 if (actionCommandStatus->duration < actionCommandStatus->frameCounter) {
294 if (battleStatus->actionSuccess == 0) {
295 battleStatus->actionSuccess = -1;
296 }
297
298 if (battleStatus->actionSuccess == 1) {
300 }
301
303 actionCommandStatus->frameCounter = 5;
304 actionCommandStatus->state = 12;
305 }
306 }
307 }
308 break;
309 case 12:
310 if (actionCommandStatus->frameCounter != 0) {
311 actionCommandStatus->frameCounter--;
312 return;
313 }
315 break;
316 }
317}
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
void func_80269160(void)
Definition action_cmd.c:655
void action_command_free(void)
Definition action_cmd.c:446
HudScript HES_TimingCharge3
HudScript HES_TimingReady
HudScript HES_StickTapNeutral
HudScript HES_TimingCharge2
HudScript HES_TimingCharge1
@ ACTION_COMMAND_MODE_TUTORIAL
Definition action_cmd.h:40
@ ACTION_COMMAND_MODE_TUTORIAL_BLOCK
Definition action_cmd.h:37
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BS_FLAGS1_2000
Definition enums.h:3582
@ 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.
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define ARRAY_COUNT(arr)
Definition macros.h:40
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 };