Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
squirt.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_squirt
5
6s32 D_802A9760_42A480[] = { 300, 300, 265, 220, 175, 175 };
7s32 D_802A9778_42A498[] = { 300, 300, 265, 220, 175, 175 };
8
9extern s32 actionCmdTableSquirt[];
10
11API_CALLABLE(N(init)) {
12 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
13 BattleStatus* battleStatus = &gBattleStatus;
14 s32 id;
15
16 battleStatus->unk_82 = 5;
19 battleStatus->actionSuccess = 0;
20 return ApiStatus_DONE2;
21 }
22
24 actionCommandStatus->actionCommandID = ACTION_COMMAND_SQUIRT;
25 actionCommandStatus->state = 0;
26 actionCommandStatus->wrongButtonPressed = FALSE;
27 actionCommandStatus->barFillLevel = 0;
28 actionCommandStatus->barFillWidth = 0;
29 battleStatus->actionQuality = 0;
30 actionCommandStatus->hudPosX = -48;
31 actionCommandStatus->unk_5C = 0;
32 actionCommandStatus->hudPosY = 80;
33
35 actionCommandStatus->hudElements[0] = id;
37 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
39
41 actionCommandStatus->hudElements[1] = id;
42 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
45
46 return ApiStatus_DONE2;
47}
48
49API_CALLABLE(N(start)) {
50 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
51 BattleStatus* battleStatus = &gBattleStatus;
52 Bytecode* args = script->ptrReadPos;
53
55 battleStatus->actionSuccess = 0;
56 return ApiStatus_DONE2;
57 }
58
60 actionCommandStatus->prepareTime = evt_get_variable(script, *args++);
61 actionCommandStatus->duration = evt_get_variable(script, *args++);
62 actionCommandStatus->difficulty = evt_get_variable(script, *args++);
63 actionCommandStatus->difficulty = adjust_action_command_difficulty(actionCommandStatus->difficulty);
64 actionCommandStatus->wrongButtonPressed = FALSE;
65 actionCommandStatus->barFillLevel = 0;
66 actionCommandStatus->barFillWidth = 0;
67 battleStatus->actionSuccess = 0;
68 battleStatus->actionResult = ACTION_RESULT_FAIL;
69 actionCommandStatus->state = 10;
70 battleStatus->flags1 &= ~BS_FLAGS1_FREE_ACTION_COMMAND;
72 return ApiStatus_DONE2;
73}
74
75void N(update)(void) {
76 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
77 BattleStatus* battleStatus = &gBattleStatus;
78 s32 id;
79 s32 mashMeterCutoff;
80 s32 cutoff;
81 s32 temp;
82
83 switch (actionCommandStatus->state) {
84 case 0:
86
87 id = actionCommandStatus->hudElements[0];
88 if (actionCommandStatus->showHud) {
90 }
91 hud_element_set_alpha(id, 255);
92
93 id = actionCommandStatus->hudElements[1];
94 hud_element_set_alpha(id, 255);
95 if (actionCommandStatus->showHud) {
97 }
98
99 actionCommandStatus->state = 1;
100 break;
101 case 1:
103
104 actionCommandStatus->hudPosX += 20;
105 if (actionCommandStatus->hudPosX > 50) {
106 actionCommandStatus->hudPosX = 50;
107 }
108
109 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX,
110 actionCommandStatus->hudPosY);
111 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX,
112 actionCommandStatus->hudPosY + 28);
113 break;
114 case 10:
116
117 if (actionCommandStatus->prepareTime != 0) {
118 actionCommandStatus->prepareTime--;
119 break;
120 }
121
122 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_AButtonDown);
123 actionCommandStatus->barFillLevel = 0;
124 actionCommandStatus->unk_5C = 0;
125 actionCommandStatus->frameCounter = actionCommandStatus->duration;
127 actionCommandStatus->state = 11;
128 // fallthrough
129 case 11:
131 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
132 temp = actionCommandStatus->barFillLevel / cutoff;
133 if (actionCommandStatus->unk_5C == 0) {
134 if (!(battleStatus->curButtonsDown & BUTTON_A)) {
135 actionCommandStatus->barFillLevel -= D_802A9760_42A480[temp / 20];
136 if (actionCommandStatus->barFillLevel < 0) {
137 actionCommandStatus->barFillLevel = 0;
138 }
139 } else {
140 actionCommandStatus->barFillLevel += D_802A9778_42A498[temp / 20] * battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] / 100;
141 if (actionCommandStatus->barFillLevel > 10000) {
142 actionCommandStatus->barFillLevel = 10000;
143 actionCommandStatus->unk_5C = 1;
144 }
145 }
146 } else {
147 actionCommandStatus->barFillLevel -= 250;
148 if (actionCommandStatus->barFillLevel <= 0) {
149 actionCommandStatus->barFillLevel = 0;
150 actionCommandStatus->unk_5C = 0;
151 }
152 }
153
154 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
156 id = actionCommandStatus->hudElements[0];
157 if (temp < 80) {
160 }
161 } else {
164 }
165 }
166
167 if (actionCommandStatus->frameCounter != 0) {
168 actionCommandStatus->frameCounter--;
169 return;
170 }
171
172 if (actionCommandStatus->barFillLevel == 0) {
173 battleStatus->actionSuccess = -1;
174 } else {
175 battleStatus->actionSuccess = battleStatus->actionQuality;
176 }
177
178 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1];
179 if (cutoff / 2 < battleStatus->actionQuality) {
180 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
181 } else {
182 battleStatus->actionResult = ACTION_RESULT_MINUS_4;
183 }
184
185 if (battleStatus->actionSuccess == 100) {
187 }
190 actionCommandStatus->frameCounter = 5;
191 actionCommandStatus->state = 12;
192 break;
193 case 12:
194 if (actionCommandStatus->frameCounter != 0) {
195 actionCommandStatus->frameCounter--;
196 } else {
198 }
199 break;
200 }
201}
202
203void N(draw)(void) {
204 s32 x, y;
205 s32 id;
206 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
207
208 hud_element_draw_clipped(actionCommandStatus->hudElements[0]);
209 id = actionCommandStatus->hudElements[1];
211 hud_element_get_render_pos(id, &x, &y);
212 if (actionCommandStatus->unk_5C == 0) {
213 draw_mash_meter_multicolor_with_divisor(x, y, actionCommandStatus->barFillLevel / 100, 1);
214 } else {
216 }
217}
218
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
void draw_mash_meter_multicolor_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor)
Definition action_cmd.c:231
s32 adjust_action_command_difficulty(s32 arg0)
Definition action_cmd.c:101
void draw_mash_meter_mode_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor, s32 colorMode)
Definition action_cmd.c:241
void action_command_init_status(void)
Definition action_cmd.c:256
void func_80269118(void)
Definition action_cmd.c:641
HudScript HES_AButton
@ MASH_METER_MODE_ONE_COLOR
Definition action_cmd.h:33
HudScript HES_BlueMeter
HudScript HES_PressAButton
HudScript HES_AButtonDown
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
s32 D_802A9778_42A498[]
Definition squirt.c:7
s32 D_802A9760_42A480[]
Definition squirt.c:6
void N free(void)
Definition squirt.c:219
void N update(void)
Definition squirt.c:75
s32 actionCmdTableSquirt[]
Definition action_cmd.c:42
void N draw(void)
Definition squirt.c:203
@ ACTION_COMMAND_SQUIRT
Definition enums.h:3487
@ BUTTON_A
Definition enums.h:2790
@ SOUND_LOOP_CHARGE_BAR
Definition enums.h:1646
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_MINUS_4
Definition enums.h:1964
@ ACTION_RESULT_FAIL
Definition enums.h:1967
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
void btl_set_popup_duration(s32 duration)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
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)
HudScript * hud_element_get_script(s32 id)
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
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66