Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
body_slam.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_body_slam
5
6extern s32 actionCmdTableBodySlam[];
7
8API_CALLABLE(N(init)) {
9 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
10 BattleStatus* battleStatus = &gBattleStatus;
11 s32 id;
12
13 battleStatus->unk_82 = 100;
15 battleStatus->actionResult = ACTION_RESULT_NONE;
17 battleStatus->actionSuccess = 0;
18 return ApiStatus_DONE2;
19 }
20
22 actionCommandStatus->actionCommandID = ACTION_COMMAND_BODY_SLAM;
23 actionCommandStatus->showHud = TRUE;
24 actionCommandStatus->state = 0;
25 actionCommandStatus->wrongButtonPressed = FALSE;
26 actionCommandStatus->barFillLevel = 0;
27 actionCommandStatus->barFillWidth = 0;
28 actionCommandStatus->isBarFilled = FALSE;
29 battleStatus->actionSuccess = 0;
30 actionCommandStatus->hudPosX = -48;
31 actionCommandStatus->hudPosY = 80;
32
34 actionCommandStatus->hudElements[0] = id;
35 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
38
40 actionCommandStatus->hudElements[1] = id;
41 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
44
46 actionCommandStatus->hudElements[3] = id;
47 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
50
52 actionCommandStatus->hudElements[2] = id;
53 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 41, actionCommandStatus->hudPosY + 22);
56 return ApiStatus_DONE2;
57}
58
60
61void N(update)(void) {
62 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
63 BattleStatus* battleStatus = &gBattleStatus;
64 s32 id;
65 s32 phi_v0;
66
67 switch (actionCommandStatus->state) {
68 case 0:
70
71 id = actionCommandStatus->hudElements[0];
72 hud_element_set_alpha(id, 255);
73 if (actionCommandStatus->showHud) {
75 }
76
77 id = actionCommandStatus->hudElements[1];
78 hud_element_set_alpha(id, 255);
79 if (actionCommandStatus->showHud) {
81 }
82
83 id = actionCommandStatus->hudElements[2];
84 hud_element_set_alpha(id, 255);
85 if (actionCommandStatus->showHud) {
87 }
88
89 id = actionCommandStatus->hudElements[3];
90 hud_element_set_alpha(id, 255);
91 if (actionCommandStatus->showHud) {
93 }
94
95 actionCommandStatus->state = 1;
96 break;
97 case 1:
99 actionCommandStatus->hudPosX += 20;
100 if (actionCommandStatus->hudPosX > 50) {
101 actionCommandStatus->hudPosX = 50;
102 }
103 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
104 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
105 hud_element_set_render_pos(actionCommandStatus->hudElements[2], actionCommandStatus->hudPosX + 41, actionCommandStatus->hudPosY + 22);
106 hud_element_set_render_pos(actionCommandStatus->hudElements[3], actionCommandStatus->hudPosX + 42, actionCommandStatus->hudPosY + 24);
107 break;
108 case 10:
110 if (actionCommandStatus->prepareTime != 0) {
111 actionCommandStatus->prepareTime--;
112 return;
113 }
114 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_AButtonDown);
115 actionCommandStatus->barFillLevel = 0;
116 actionCommandStatus->thresholdLevel = 0;
117 actionCommandStatus->frameCounter = actionCommandStatus->duration;
119 actionCommandStatus->state = 11;
120 case 11:
122
123 if (battleStatus->curButtonsDown & BUTTON_A) {
124 actionCommandStatus->barFillLevel += 154;
125 actionCommandStatus->thresholdLevel += 154;
126 } else {
127 actionCommandStatus->frameCounter = 0;
128 }
129
130 if (actionCommandStatus->barFillLevel >= 10000) {
131 actionCommandStatus->barFillLevel = 10000;
132 hud_element_set_script(actionCommandStatus->hudElements[2], &HES_TimingReady);
133 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_AButton);
134 if (!actionCommandStatus->isBarFilled) {
136 actionCommandStatus->isBarFilled = TRUE;
137 }
138 }
139
140 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
142 if (actionCommandStatus->frameCounter != 0) {
143 actionCommandStatus->frameCounter--;
144 return;
145 }
146
147 if (actionCommandStatus->thresholdLevel < 10000) {
148 battleStatus->actionSuccess = -1;
149 } else if (actionCommandStatus->thresholdLevel - (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 154) >= 10309) {
150 battleStatus->actionSuccess = -1;
151 } else {
152 battleStatus->actionSuccess = 1;
153 }
154
155 battleStatus->actionResult = ACTION_RESULT_FAIL;
156 if (battleStatus->actionSuccess == 1) {
158 }
161 actionCommandStatus->frameCounter = 5;
162 actionCommandStatus->state = 12;
163 break;
164 case 12:
165 if (actionCommandStatus->frameCounter != 0) {
166 actionCommandStatus->frameCounter--;
167 return;
168 }
170 break;
171 }
172}
173
186
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
void draw_mash_meter_multicolor(s32 posX, s32 posY, s32 fillValue)
Definition action_cmd.c:226
void func_80269160(void)
Definition action_cmd.c:655
void action_command_free(void)
Definition action_cmd.c:446
void action_command_init_status(void)
Definition action_cmd.c:256
HudScript HES_AButton
HudScript HES_TimingReady
HudScript HES_TimingWait
HudScript HES_BlueMeter
HudScript HES_AButtonDown
HudScript HES_FillGaugeResult
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
void N free(void)
Definition body_slam.c:187
s32 actionCmdTableBodySlam[]
Definition action_cmd.c:39
void N update(void)
Definition body_slam.c:61
void N draw(void)
Definition body_slam.c:174
@ ACTION_COMMAND_BODY_SLAM
Definition enums.h:3484
@ BUTTON_A
Definition enums.h:2790
@ SOUND_TIMING_BAR_GO
Definition enums.h:953
@ SOUND_LOOP_CHARGE_BAR
Definition enums.h:1646
@ ACTION_RESULT_NONE
Definition enums.h:1963
@ ACTION_RESULT_FAIL
Definition enums.h:1967
#define ApiStatus_DONE2
Definition evt.h:118
void btl_set_popup_duration(s32 duration)
void hud_element_get_render_pos(s32 id, s32 *x, s32 *y)
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_depth(s32 id, s32 z)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_draw_clipped(s32 id)
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:74
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
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
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66