Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
whirlwind.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3#include "battle/action_cmd/whirlwind_bubble.png.h"
4#include "include_asset.h"
5
6#define NAMESPACE action_command_whirlwind
7
8INCLUDE_IMG("battle/action_cmd/whirlwind_1.png", battle_action_cmd_whirlwind_1_png);
9INCLUDE_PAL("battle/action_cmd/whirlwind_1.pal", battle_action_cmd_whirlwind_1_pal);
10
11INCLUDE_IMG("battle/action_cmd/whirlwind_2.png", battle_action_cmd_whirlwind_2_png);
12INCLUDE_PAL("battle/action_cmd/whirlwind_2.pal", battle_action_cmd_whirlwind_2_pal);
13
14INCLUDE_IMG("battle/action_cmd/whirlwind_3.png", battle_action_cmd_whirlwind_3_png);
15INCLUDE_PAL("battle/action_cmd/whirlwind_3.pal", battle_action_cmd_whirlwind_3_pal);
16
17INCLUDE_IMG("battle/action_cmd/whirlwind_4.png", battle_action_cmd_whirlwind_4_png);
18INCLUDE_PAL("battle/action_cmd/whirlwind_4.pal", battle_action_cmd_whirlwind_4_pal);
19
20INCLUDE_IMG("battle/action_cmd/whirlwind_5.png", battle_action_cmd_whirlwind_5_png);
21INCLUDE_PAL("battle/action_cmd/whirlwind_5.pal", battle_action_cmd_whirlwind_5_pal);
22
23INCLUDE_IMG("battle/action_cmd/whirlwind_6.png", battle_action_cmd_whirlwind_6_png);
24INCLUDE_PAL("battle/action_cmd/whirlwind_6.pal", battle_action_cmd_whirlwind_6_pal);
25
26INCLUDE_IMG("battle/action_cmd/whirlwind_7.png", battle_action_cmd_whirlwind_7_png);
27INCLUDE_PAL("battle/action_cmd/whirlwind_7.pal", battle_action_cmd_whirlwind_7_pal);
28
29INCLUDE_IMG("battle/action_cmd/whirlwind_bubble.png", battle_action_cmd_whirlwind_bubble_png);
30INCLUDE_PAL("battle/action_cmd/whirlwind_bubble.pal", battle_action_cmd_whirlwind_bubble_pal);
31
32HudScript HES_Whirlwind1 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_1, 24, 24);
33
34HudScript HES_Whirlwind2 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_2, 24, 24);
35
36HudScript HES_Whirlwind3 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_3, 24, 24);
37
38HudScript HES_Whirlwind4 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_4, 24, 24);
39
40HudScript HES_Whirlwind5 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_5, 24, 24);
41
42HudScript HES_Whirlwind6 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_6, 24, 24);
43
44HudScript HES_Whirlwind7 = HES_TEMPLATE_CI_ENUM_SIZE(battle_action_cmd_whirlwind_7, 24, 24);
45
46HudScript HES_WhirlwindBubble = HES_TEMPLATE_CI_CUSTOM_SIZE(battle_action_cmd_whirlwind_bubble,
47 battle_action_cmd_whirlwind_bubble_png_width, battle_action_cmd_whirlwind_bubble_png_height);
48
49s32 D_802AA844_4254B4[] = { 0, 25, 50, 75, 100, 100 };
50
51s32 D_802AA85C_4254CC[] = { 50, 50, 50, 50, 75, 75, 75, 100, 100, 100, 100 };
52
56
60
61s32 D_802AA8B4_425524[] = { 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1 };
62
63extern s32 actionCmdTableWhirlwind[];
64
65API_CALLABLE(N(init)) {
66 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
67 BattleStatus* battleStatus = &gBattleStatus;
68 Bytecode* args = script->ptrReadPos;
69 s16 temp_v0;
70 s32 id;
71
72 battleStatus->unk_82 = 5;
75 battleStatus->actionSuccess = 0;
76 return ApiStatus_DONE2;
77 }
78
80 actionCommandStatus->targetWeakness = evt_get_variable(script, *args++);
81 actionCommandStatus->actionCommandID = ACTION_COMMAND_WHIRLWIND;
82 actionCommandStatus->state = 0;
83 actionCommandStatus->wrongButtonPressed = FALSE;
84 actionCommandStatus->barFillLevel = 0;
85 actionCommandStatus->barFillWidth = 0;
86 if (actionCommandStatus->targetWeakness == 0) {
87 battleStatus->actionQuality = 0;
88 } else {
89 battleStatus->actionQuality = 3;
90 }
91 actionCommandStatus->hudPosX = -48;
92 actionCommandStatus->hudPosY = 80;
93
95 actionCommandStatus->hudElements[0] = id;
97 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
99
101 actionCommandStatus->hudElements[1] = id;
102 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
105
107 actionCommandStatus->hudElements[2] = id;
108 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 54, actionCommandStatus->hudPosY + 28);
111
113 actionCommandStatus->hudElements[3] = id;
114 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 60, actionCommandStatus->hudPosY + 28);
117
118 return ApiStatus_DONE2;
119}
120
121API_CALLABLE(N(start)) {
122 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
123 BattleStatus* battleStatus = &gBattleStatus;
124 Bytecode* args = script->ptrReadPos;
125
127 battleStatus->actionSuccess = 0;
128 return ApiStatus_DONE2;
129 }
130
132 actionCommandStatus->prepareTime = evt_get_variable(script, *args++);
133 actionCommandStatus->duration = evt_get_variable(script, *args++);
134 actionCommandStatus->difficulty = evt_get_variable(script, *args++);
135 actionCommandStatus->difficulty = adjust_action_command_difficulty(actionCommandStatus->difficulty);
136 actionCommandStatus->wrongButtonPressed = FALSE;
137 actionCommandStatus->barFillLevel = 0;
138 actionCommandStatus->barFillWidth = 0;
139 battleStatus->actionSuccess = 0;
140 battleStatus->actionResult = ACTION_RESULT_FAIL;
141 if (actionCommandStatus->targetWeakness == 0) {
142 battleStatus->actionQuality = 0;
143 } else {
144 battleStatus->actionQuality = 3;
145 }
146 actionCommandStatus->state = 10;
147 gBattleStatus.flags1 &= ~BS_FLAGS1_FREE_ACTION_COMMAND;
148 return ApiStatus_DONE2;
149}
150
151void N(update)(void) {
152 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
153 BattleStatus* battleStatus = &gBattleStatus;
154 s32 id;
155 s32 cutoff;
156 s32 temp;
157 s32 amt;
158
159 switch (actionCommandStatus->state) {
160 case 0:
162
163 id = actionCommandStatus->hudElements[0];
164 if (actionCommandStatus->showHud) {
166 }
167 hud_element_set_alpha(id, 255);
168
169 id = actionCommandStatus->hudElements[1];
170 hud_element_set_alpha(id, 255);
171 if (actionCommandStatus->showHud) {
173 }
174
175 id = actionCommandStatus->hudElements[2];
176 hud_element_set_alpha(id, 255);
177 if (actionCommandStatus->showHud) {
179 }
180
181 id = actionCommandStatus->hudElements[3];
182 hud_element_set_alpha(id, 255);
183 if (actionCommandStatus->showHud) {
185 }
186
187 actionCommandStatus->state = 1;
188 break;
189 case 1:
191 actionCommandStatus->hudPosX += 20;
192 if (actionCommandStatus->hudPosX > 50) {
193 actionCommandStatus->hudPosX = 50;
194 }
195 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
196 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
197 hud_element_set_render_pos(actionCommandStatus->hudElements[2], actionCommandStatus->hudPosX + 54, actionCommandStatus->hudPosY + 23);
198 hud_element_set_render_pos(actionCommandStatus->hudElements[3], actionCommandStatus->hudPosX + 60, actionCommandStatus->hudPosY + 23);
199 break;
200 case 10:
202 if (actionCommandStatus->prepareTime != 0) {
203 actionCommandStatus->prepareTime--;
204 return;
205 }
206 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_MashAButton);
207 actionCommandStatus->barFillLevel = 0;
208 actionCommandStatus->state = 11;
209 actionCommandStatus->frameCounter = actionCommandStatus->duration;
210 case 11:
212 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
213 temp = actionCommandStatus->barFillLevel / cutoff;
214 if (actionCommandStatus->targetWeakness == 0) {
215 amt = D_802AA844_4254B4[temp / 20];
216 } else {
217 amt = D_802AA85C_4254CC[temp / 10];
218 }
219 actionCommandStatus->barFillLevel -= amt;
220
221 if (actionCommandStatus->barFillLevel < 0) {
222 actionCommandStatus->barFillLevel = 0;
223 }
224
225 if (!actionCommandStatus->berserkerEnabled) {
226 if (battleStatus->curButtonsPressed & BUTTON_A) {
227 s32 amt;
228
229 if (actionCommandStatus->targetWeakness == 0) {
230 amt = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 5;
231 } else {
232 amt = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 6;
233 }
234 actionCommandStatus->barFillLevel += amt;
235 }
236 } else {
237 actionCommandStatus->barFillLevel += battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] / 4;
238 actionCommandStatus->barFillLevel += rand_int(battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] / 4);
239 }
240
241 if (actionCommandStatus->barFillLevel > cutoff * 100) {
242 actionCommandStatus->barFillLevel = cutoff * 100;
243 }
244 if (!actionCommandStatus->targetWeakness) {
245 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 2000;
246 } else {
247 battleStatus->actionQuality = D_802AA8B4_425524[actionCommandStatus->barFillLevel / 1000];
248 }
249
250 if (actionCommandStatus->frameCounter != 0) {
251 actionCommandStatus->frameCounter--;
252 return;
253 }
254 battleStatus->actionResult = ACTION_RESULT_NONE;
255 battleStatus->actionSuccess = battleStatus->actionQuality;
257 actionCommandStatus->frameCounter = 5;
258 actionCommandStatus->state = 12;
259 break;
260 case 12:
261 if (actionCommandStatus->frameCounter != 0) {
262 actionCommandStatus->frameCounter--;
263 return;
264 }
266 break;
267 }
268}
269
270void N(draw)(void) {
271 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
272 BattleStatus* battleStatus = &gBattleStatus;
273 s32 x, y;
274 s32 id;
275
276 if (!actionCommandStatus->berserkerEnabled) {
277 hud_element_draw_clipped(actionCommandStatus->hudElements[0]);
278 }
279 id = actionCommandStatus->hudElements[1];
281 hud_element_get_render_pos(id, &x, &y);
282
283 draw_mash_meter_multicolor_with_divisor(x, y, actionCommandStatus->barFillLevel / 100, 1);
284 hud_element_draw_clipped(actionCommandStatus->hudElements[3]);
285 id = actionCommandStatus->hudElements[2];
286 if (!actionCommandStatus->targetWeakness) {
287 if (D_802AA888_4254F8[battleStatus->actionQuality] != hud_element_get_script(id)) {
289 }
290 } else {
291 if (D_802AA8A0_425510[battleStatus->actionQuality] != hud_element_get_script(id)) {
293 }
294 }
296}
297
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
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 action_command_init_status(void)
Definition action_cmd.c:256
HudScript HES_AButton
HudScript HES_BlueMeter
HudScript HES_MashAButton
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
HudScript HES_Whirlwind1
Definition whirlwind.c:32
HudScript * D_802AA888_4254F8[]
Definition whirlwind.c:53
HudScript HES_Whirlwind6
Definition whirlwind.c:42
HudScript HES_Whirlwind4
Definition whirlwind.c:38
HudScript HES_Whirlwind2
Definition whirlwind.c:34
s32 actionCmdTableWhirlwind[]
Definition action_cmd.c:32
HudScript HES_Whirlwind7
Definition whirlwind.c:44
HudScript HES_Whirlwind3
Definition whirlwind.c:36
void N free(void)
Definition whirlwind.c:298
HudScript * D_802AA8A0_425510[]
Definition whirlwind.c:57
s32 D_802AA8B4_425524[]
Definition whirlwind.c:61
s32 D_802AA844_4254B4[]
Definition whirlwind.c:49
void N update(void)
Definition whirlwind.c:151
HudScript HES_WhirlwindBubble
Definition whirlwind.c:46
void N draw(void)
Definition whirlwind.c:270
HudScript HES_Whirlwind5
Definition whirlwind.c:40
s32 D_802AA85C_4254CC[]
Definition whirlwind.c:51
#define rand_int
@ ACTION_COMMAND_WHIRLWIND
Definition enums.h:3477
@ BUTTON_A
Definition enums.h:2790
@ ACTION_RESULT_NONE
Definition enums.h:1963
@ 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
#define HES_TEMPLATE_CI_CUSTOM_SIZE(name, sizeX, sizeY)
Basic HudScript used for static CI images, setting size with hs_SetCustomSize.
#define HES_TEMPLATE_CI_ENUM_SIZE(name, sizeX, sizeY)
Basic HudScript used for static CI images, setting size with hs_SetTileSize.
s32 HudScript[]
Definition hud_element.h:9
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66