Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
fire_shell.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "battle/action_cmd.h"
3
4#define NAMESPACE action_command_fire_shell
5
6s32 D_802A9950_427320[5] = { 0, 25, 50, 75, 75 };
7s32 D_802A9964_427334[4] = { 40, 70, 99, 200 };
8s32 D_802A9974_427344[5] = { 35, 60, 80, 99, 200 };
9s32 D_802A9988_427358[6] = { 35, 35, 60, 80, 99, 200 };
10
11extern s32 actionCmdTableFireShell[];
12
13API_CALLABLE(N(init)) {
14 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
15 BattleStatus* battleStatus = &gBattleStatus;
16 s32 id;
17
18 battleStatus->unk_82 = 100;
20 battleStatus->actionResult = ACTION_RESULT_NONE;
21
23 battleStatus->actionSuccess = 0;
24 return ApiStatus_DONE2;
25 }
27
28 actionCommandStatus->actionCommandID = ACTION_COMMAND_FIRE_SHELL;
29 actionCommandStatus->showHud = TRUE;
30 actionCommandStatus->hudPrepareTime = 30;
31 actionCommandStatus->state = 0;
32 actionCommandStatus->wrongButtonPressed = FALSE;
33 actionCommandStatus->barFillLevel = 0;
34 actionCommandStatus->barFillWidth = 0;
35 actionCommandStatus->isBarFilled = FALSE;
36 battleStatus->actionSuccess = 0;
37 actionCommandStatus->hudPosX = -48;
38 actionCommandStatus->hudPosY = 80;
39
41 actionCommandStatus->hudElements[0] = id;
42 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
45
47 actionCommandStatus->hudElements[1] = id;
48 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
51
53 actionCommandStatus->hudElements[2] = id;
54 hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
57
58 return ApiStatus_DONE2;
59}
60
62
63void N(update)(void) {
64 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
65 BattleStatus* battleStatus = &gBattleStatus;
66 Actor* partner = battleStatus->partnerActor;
67 s32 id;
68 s32 cutoff;
69 s32 fillLevel;
70
71 switch (actionCommandStatus->state) {
72 case 0:
74
75 id = actionCommandStatus->hudElements[0];
76 hud_element_set_alpha(id, 255);
77 if (actionCommandStatus->showHud) {
79 }
80
81 id = actionCommandStatus->hudElements[1];
82 hud_element_set_alpha(id, 255);
83 if (actionCommandStatus->showHud) {
85 }
86
87 actionCommandStatus->state = 1;
88 break;
89 case 1:
91 actionCommandStatus->hudPosX += 20;
92 if (actionCommandStatus->hudPosX > 50) {
93 actionCommandStatus->hudPosX = 50;
94 }
95 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
96 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
97 break;
98 case 10:
100 if (actionCommandStatus->prepareTime != 0) {
101 actionCommandStatus->prepareTime--;
102 return;
103 }
104 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_StickMashLeft);
105 actionCommandStatus->barFillLevel = 0;
106 battleStatus->unk_85 = 0;
107 actionCommandStatus->unk_5C = 0;
108 actionCommandStatus->frameCounter = actionCommandStatus->duration;
110 actionCommandStatus->state = 11;
111 case 11:
113
114 if (!actionCommandStatus->isBarFilled) {
115 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
116 actionCommandStatus->barFillLevel -= D_802A9950_427320[actionCommandStatus->barFillLevel / cutoff / 20];
117 if (actionCommandStatus->barFillLevel < 0) {
118 actionCommandStatus->barFillLevel = 0;
119 }
120 if (!actionCommandStatus->isBarFilled) {
121 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
122 actionCommandStatus->unk_5C = 1;
123 }
124
125 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) && (actionCommandStatus->unk_5C != 0)) {
126 actionCommandStatus->barFillLevel += (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 950) / 100;
127 actionCommandStatus->unk_5C = 0;
128 }
129
130 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
131 actionCommandStatus->barFillLevel -= (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 950) / 100;
132 }
133 }
134 }
135
136 if (actionCommandStatus->barFillLevel < 0) {
137 actionCommandStatus->barFillLevel = 0;
138 }
139
140 if (actionCommandStatus->barFillLevel > 10000) {
141 id = actionCommandStatus->hudElements[2];
142 actionCommandStatus->barFillLevel = 10000;
143 actionCommandStatus->isBarFilled = TRUE;
144 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY + 28);
146 }
147
148 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
150 switch (partner->actorBlueprint->level) {
152 if (battleStatus->actionQuality >= D_802A9964_427334[battleStatus->unk_85]) {
153 battleStatus->unk_85++;
154 }
155 if (battleStatus->unk_85 > 0 && (battleStatus->actionQuality < D_802A9964_427334[battleStatus->unk_85 - 1])) {
156 battleStatus->unk_85--;
157 }
158 break;
160 if (battleStatus->actionQuality >= D_802A9974_427344[battleStatus->unk_85]) {
161 battleStatus->unk_85++;
162 }
163 if (battleStatus->unk_85 > 0 && (battleStatus->actionQuality < D_802A9974_427344[battleStatus->unk_85 - 1])) {
164 battleStatus->unk_85--;
165 }
166 break;
168 if (battleStatus->actionQuality >= D_802A9988_427358[battleStatus->unk_85]) {
169 battleStatus->unk_85++;
170 }
171 if (battleStatus->unk_85 > 0 && (battleStatus->actionQuality < D_802A9988_427358[battleStatus->unk_85 - 1])) {
172 battleStatus->unk_85--;
173 }
174 break;
175 }
176
177 if (actionCommandStatus->frameCounter != 0) {
178 actionCommandStatus->frameCounter--;
179 return;
180 }
181
182 if (actionCommandStatus->barFillLevel == 0) {
183 battleStatus->actionSuccess = -1;
184 } else {
185 battleStatus->actionSuccess = actionCommandStatus->barFillLevel / 100;
186 }
187
188 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1];
189 if (cutoff >= battleStatus->actionSuccess) {
190 battleStatus->actionResult = ACTION_RESULT_MINUS_2;
191 } else {
192 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
193 }
194
195 if (battleStatus->actionSuccess == 100) {
197 }
200 actionCommandStatus->frameCounter = 5;
201 actionCommandStatus->state = 12;
202 break;
203 case 12:
204 if (actionCommandStatus->frameCounter != 0) {
205 actionCommandStatus->frameCounter--;
206 return;
207 }
209 break;
210 }
211}
212
214
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_StickNeutral
HudScript HES_BlueMeter
HudScript HES_StickMashLeft
HudScript HES_100pct
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
struct ActorBlueprint * actorBlueprint
@ ACTION_COMMAND_FIRE_SHELL
Definition enums.h:3481
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ PARTNER_RANK_NORMAL
Definition enums.h:2018
@ PARTNER_RANK_SUPER
Definition enums.h:2019
@ PARTNER_RANK_ULTRA
Definition enums.h:2020
@ 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
s32 D_802A9988_427358[6]
Definition fire_shell.c:9
s32 D_802A9950_427320[5]
Definition fire_shell.c:6
s32 actionCmdTableFireShell[]
Definition action_cmd.c:36
s32 D_802A9964_427334[4]
Definition fire_shell.c:7
s32 D_802A9974_427344[5]
Definition fire_shell.c:8
void N update(void)
Definition fire_shell.c:63
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
struct Actor * partnerActor
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11
void N init(Npc *bombette)
Definition bombette.c:66