Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
bomb.c
Go to the documentation of this file.
1#include "common.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_bomb
5
6s32 D_802A9810_428280[] = { 0, 25, 50, 75, 75, 0, 0, 0 };
7
8extern s32 actionCmdTableBomb[];
9
10API_CALLABLE(N(init)) {
11 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
12 BattleStatus* battleStatus = &gBattleStatus;
13 s32 hudElement;
14
15 battleStatus->unk_82 = 100;
17 battleStatus->actionResult = ACTION_RESULT_NONE;
18
20 battleStatus->actionSuccess = 0;
21 return ApiStatus_DONE2;
22 }
23
25 actionCommandStatus->actionCommandID = ACTION_COMMAND_BOMB;
26 actionCommandStatus->showHud = TRUE;
27 actionCommandStatus->state = 0;
28 actionCommandStatus->wrongButtonPressed = FALSE;
29 actionCommandStatus->barFillLevel = 0;
30 actionCommandStatus->barFillWidth = 0;
31 actionCommandStatus->isBarFilled = FALSE;
32 battleStatus->actionSuccess = 0;
33
34 actionCommandStatus->hudPosX = -48;
35 actionCommandStatus->hudPosY = 80;
36
37 hudElement = hud_element_create(&HES_AButton);
38 actionCommandStatus->hudElements[0] = hudElement;
39 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
40 hud_element_set_render_depth(hudElement, 0);
42
43 hudElement = hud_element_create(&HES_BlueMeter);
44 actionCommandStatus->hudElements[1] = hudElement;
45 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
46 hud_element_set_render_depth(hudElement, 0);
48
49 hudElement = hud_element_create(&HES_100pct);
50 actionCommandStatus->hudElements[2] = hudElement;
51 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
52 hud_element_set_render_depth(hudElement, 0);
54
55 return ApiStatus_DONE2;
56}
57
59
60void N(update)(void) {
61 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
62 BattleStatus* battleStatus = &gBattleStatus;
63 s32 hudElement;
64 s32 mashMeterCutoff;
65
66 switch (actionCommandStatus->state) {
67 case 0:
69 hudElement = actionCommandStatus->hudElements[0];
70 hud_element_set_alpha(hudElement, 255);
71 if (actionCommandStatus->showHud) {
73 }
74
75 hudElement = actionCommandStatus->hudElements[1];
76 hud_element_set_alpha(hudElement, 255);
77 if (actionCommandStatus->showHud) {
79 }
80
81 actionCommandStatus->state = 1;
82 break;
83 case 1:
85
86 actionCommandStatus->hudPosX += 20;
87 if (actionCommandStatus->hudPosX > 50) {
88 actionCommandStatus->hudPosX = 50;
89 }
90
91 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX,
92 actionCommandStatus->hudPosY);
93 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX,
94 actionCommandStatus->hudPosY + 28);
95 break;
96 case 10:
98
99 if (actionCommandStatus->prepareTime != 0) {
100 actionCommandStatus->prepareTime--;
101 break;
102 }
103
104 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_MashAButton);
105 actionCommandStatus->barFillLevel = 0;
106 actionCommandStatus->frameCounter = actionCommandStatus->duration;
108 actionCommandStatus->state = 11;
109
110 // fallthrough
111 case 11:
113 if (!actionCommandStatus->isBarFilled) {
114 mashMeterCutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
115 actionCommandStatus->barFillLevel -=
116 D_802A9810_428280[actionCommandStatus->barFillLevel / mashMeterCutoff / 20];
117
118 if (actionCommandStatus->barFillLevel < 0) {
119 actionCommandStatus->barFillLevel = 0;
120 }
121 }
122
123 if (battleStatus->curButtonsPressed & BUTTON_A) {
124 switch (actionCommandStatus->targetWeakness) {
125 case 0: {
126 s32 fillOffset = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 235 * 4;
127 actionCommandStatus->barFillLevel += fillOffset / 100;
128 break;
129 }
130 case 1:
131 actionCommandStatus->barFillLevel += battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 8;
132 break;
133 case 2: {
134 s32 fillOffset = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 185 * 4;
135 actionCommandStatus->barFillLevel += fillOffset / 100;
136 break;
137 }
138 }
139 }
140
141 if (actionCommandStatus->barFillLevel > 10000) {
142 hudElement = actionCommandStatus->hudElements[2];
143 actionCommandStatus->barFillLevel = 10000;
144 actionCommandStatus->isBarFilled = TRUE;
145 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX + 50,
146 actionCommandStatus->hudPosY + 28);
148 }
149
150 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
152
153 if (actionCommandStatus->frameCounter == 0) {
154 if (actionCommandStatus->barFillLevel == 0) {
155 battleStatus->actionSuccess = -1;
156 } else {
157 battleStatus->actionSuccess = actionCommandStatus->barFillLevel / 100;
158 }
159
160 mashMeterCutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1];
161 if (mashMeterCutoff >= battleStatus->actionSuccess) {
162 battleStatus->actionResult = ACTION_RESULT_MINUS_2;
163 } else {
164 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
165 }
166
167 if (battleStatus->actionSuccess == 100) {
169 }
170
173 actionCommandStatus->frameCounter = 5;
174 actionCommandStatus->state = 12;
175 } else {
176 actionCommandStatus->frameCounter--;
177 }
178 break;
179 case 12:
180 if (actionCommandStatus->frameCounter != 0) {
181 actionCommandStatus->frameCounter--;
182 } else {
184 }
185 break;
186 }
187}
188
190
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 action_command_init_status(void)
Definition action_cmd.c:256
HudScript HES_AButton
HudScript HES_BlueMeter
HudScript HES_MashAButton
HudScript HES_100pct
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
s32 D_802A9810_428280[]
Definition bomb.c:6
s32 actionCmdTableBomb[]
Definition action_cmd.c:38
void N update(void)
Definition bomb.c:60
@ ACTION_COMMAND_BOMB
Definition enums.h:3483
@ BUTTON_A
Definition enums.h:2790
@ SOUND_LOOP_CHARGE_BAR
Definition enums.h:1646
@ ACTION_RESULT_NONE
Definition enums.h:1963
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_MINUS_2
Definition enums.h:1965
#define ApiStatus_DONE2
Definition evt.h:118
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_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.
@ 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