Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
stop_leech.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_stop_leech
5
6extern s32 actionCmdTableStopLeech[];
7
8API_CALLABLE(N(init)) {
9 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
10 BattleStatus* battleStatus = &gBattleStatus;
11 s32 hudElement;
12
13 battleStatus->unk_82 = 5;
16 battleStatus->actionSuccess = 0;
17 return ApiStatus_DONE2;
18 }
19
21 actionCommandStatus->actionCommandID = ACTION_COMMAND_STOP_LEECH;
22 actionCommandStatus->hudPosX = -48;
23 actionCommandStatus->state = 0;
24 actionCommandStatus->wrongButtonPressed = FALSE;
25 actionCommandStatus->barFillLevel = 0;
26 actionCommandStatus->barFillWidth = 0;
27 actionCommandStatus->hudPosY = 80;
28
29 hudElement = hud_element_create(&HES_AButton);
30 actionCommandStatus->hudElements[0] = hudElement;
32 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
33 hud_element_set_render_depth(hudElement, 0);
34
35 hudElement = hud_element_create(&HES_BlueMeter);
36 actionCommandStatus->hudElements[1] = hudElement;
37 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
38 hud_element_set_render_depth(hudElement, 0);
40 return ApiStatus_DONE2;
41}
42
43API_CALLABLE(N(start)) {
44 Bytecode* args = script->ptrReadPos;
45 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
46 BattleStatus* battleStatus = &gBattleStatus;
47
49 battleStatus->actionSuccess = 0;
50 return ApiStatus_DONE2;
51 }
52
54 actionCommandStatus->prepareTime = evt_get_variable(script, *args++);
55 actionCommandStatus->duration = evt_get_variable(script, *args++);
56 actionCommandStatus->difficulty = evt_get_variable(script, *args++);
57 actionCommandStatus->difficulty = adjust_action_command_difficulty(actionCommandStatus->difficulty);
58 actionCommandStatus->wrongButtonPressed = FALSE;
59 actionCommandStatus->barFillLevel = 0;
60 actionCommandStatus->barFillWidth = 0;
61 battleStatus->actionSuccess = 0;
62 battleStatus->actionResult = ACTION_RESULT_FAIL;
63 actionCommandStatus->state = 10;
64 battleStatus->flags1 &= ~BS_FLAGS1_FREE_ACTION_COMMAND;
65
66 return ApiStatus_DONE2;
67}
68
69void N(update)(void) {
70 BattleStatus* battleStatus = &gBattleStatus;
71 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
72 s32 hudElement;
73 s16 hudElementX;
74
75 switch (actionCommandStatus->state) {
76 case 0:
78 hudElement = actionCommandStatus->hudElements[0];
79 if (actionCommandStatus->showHud) {
81 }
82 hud_element_set_alpha(hudElement, 0xFF);
83 hudElement = actionCommandStatus->hudElements[1];
84 hud_element_set_alpha(hudElement, 0xFF);
85 if (actionCommandStatus->showHud) {
87 }
88 actionCommandStatus->state = 1;
89 break;
90 case 1:
92 hudElementX = actionCommandStatus->hudPosX + 20;
93 actionCommandStatus->hudPosX = hudElementX;
94 if (hudElementX > 50) {
95 actionCommandStatus->hudPosX = 50;
96 }
97 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
98 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
99 break;
100 case 10:
102 if (actionCommandStatus->prepareTime != 0) {
103 actionCommandStatus->prepareTime -= 1;
104 break;
105 }
106 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_MashAButton);
107 actionCommandStatus->barFillLevel = 0;
108 actionCommandStatus->state = 11;
109 actionCommandStatus->frameCounter = actionCommandStatus->duration;
110 case 11:
112 if (!actionCommandStatus->berserkerEnabled) {
113 if (battleStatus->curButtonsPressed & BUTTON_A) {
114 actionCommandStatus->barFillLevel += battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty];
115 }
116 } else {
117 actionCommandStatus->barFillLevel += battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] / 6;
118 actionCommandStatus->barFillLevel += rand_int((battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty]) / 6);
119 }
120 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
121 if (actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals] <= battleStatus->actionQuality) {
122 actionCommandStatus->frameCounter = 0;
123 }
124
125 if (actionCommandStatus->frameCounter == 0) {
127 actionCommandStatus->frameCounter = 5;
128 actionCommandStatus->state = 12;
129 break;
130 }
131 actionCommandStatus->frameCounter -= 1;
132 break;
133 case 12:
134 if (actionCommandStatus->frameCounter != 0) {
135 actionCommandStatus->frameCounter -= 1;
136 break;
137 }
138 battleStatus->actionSuccess = 1;
139 battleStatus->actionResult = ACTION_RESULT_NONE;
141 default:
142 break;
143 }
144}
145
146void N(draw)(void) {
147 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
148 s32 x, y;
149 s32 hudElement;
150
151 if (!actionCommandStatus->berserkerEnabled) {
152 hud_element_draw_clipped(actionCommandStatus->hudElements[0]);
153 }
154
155 hudElement = actionCommandStatus->hudElements[1];
156 hud_element_draw_clipped(hudElement);
157 hud_element_get_render_pos(hudElement, &x, &y);
158 draw_mash_meter_multicolor_with_divisor(x, y, actionCommandStatus->barFillLevel / 100, 2);
159}
160
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
#define rand_int
@ ACTION_COMMAND_STOP_LEECH
Definition enums.h:3478
@ 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)
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 N free(void)
Definition stop_leech.c:161
s32 actionCmdTableStopLeech[]
Definition action_cmd.c:33
void N update(void)
Definition stop_leech.c:69
void N draw(void)
Definition stop_leech.c:146
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66