Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
air_raid.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_air_raid
5
6s32 D_802A9970_429C90[] = { 0, 25, 50, 75, 75 };
7s32 D_802A9984_429CA4[] = { 40, 70, 99, 200 };
8s32 D_802A9994_429CB4[] = { 35, 60, 80, 99, 200 };
9s32 D_802A99A8_429CC8[] = { 35, 35, 60, 80, 99, 200 };
10
11extern s32 actionCmdTableAirRaid[];
12
13API_CALLABLE(N(init)) {
14 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
15 BattleStatus* battleStatus = &gBattleStatus;
16 s32 hudElement;
17
18 battleStatus->unk_82 = 100;
20 battleStatus->actionResult = ACTION_RESULT_NONE;
21
23 battleStatus->actionSuccess = 0;
24 return ApiStatus_DONE2;
25 }
26
28
29 actionCommandStatus->actionCommandID = ACTION_COMMAND_AIR_RAID;
30 actionCommandStatus->showHud = TRUE;
31 actionCommandStatus->hudPrepareTime = 30;
32 actionCommandStatus->state = 0;
33 actionCommandStatus->wrongButtonPressed = FALSE;
34 actionCommandStatus->barFillLevel = 0;
35 actionCommandStatus->barFillWidth = 0;
36 actionCommandStatus->isBarFilled = FALSE;
37 battleStatus->actionSuccess = 0;
38 actionCommandStatus->hudPosX = -48;
39 actionCommandStatus->hudPosY = 80;
40
42 actionCommandStatus->hudElements[0] = hudElement;
43 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
44 hud_element_set_render_depth(hudElement, 0);
46
47 hudElement = hud_element_create(&HES_BlueMeter);
48 actionCommandStatus->hudElements[1] = hudElement;
49 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
50 hud_element_set_render_depth(hudElement, 0);
52
53 hudElement = hud_element_create(&HES_100pct);
54 actionCommandStatus->hudElements[2] = hudElement;
55 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
56 hud_element_set_render_depth(hudElement, 0);
58
59 return ApiStatus_DONE2;
60}
61
63
64void N(update)(void) {
65 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
66 BattleStatus* battleStatus = &gBattleStatus;
67 Actor* partner = battleStatus->partnerActor;
68 s32 cutoff;
69 s32 id;
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
92 if (actionCommandStatus->hudPrepareTime != 0) {
93 actionCommandStatus->hudPrepareTime--;
94 return;
95 }
96
97 actionCommandStatus->hudPosX += 20;
98 if (actionCommandStatus->hudPosX > 50) {
99 actionCommandStatus->hudPosX = 50;
100 }
101
102 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
103 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
104 break;
105 case 10:
107
108 if (actionCommandStatus->prepareTime != 0) {
109 actionCommandStatus->prepareTime--;
110 return;
111 }
112
113 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_StickMashLeft);
114 actionCommandStatus->barFillLevel = 0;
115 battleStatus->unk_85 = 0;
116 actionCommandStatus->unk_5C = 0;
117 actionCommandStatus->frameCounter = actionCommandStatus->duration;
119 actionCommandStatus->state = 11;
120 // fallthrough
121 case 11:
123 if (!actionCommandStatus->isBarFilled) {
124 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
125
126 actionCommandStatus->barFillLevel -= D_802A9970_429C90[actionCommandStatus->barFillLevel / cutoff / 20];
127 if (actionCommandStatus->barFillLevel < 0) {
128 actionCommandStatus->barFillLevel = 0;
129 }
130
131 if (!actionCommandStatus->isBarFilled) {
132 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
133 actionCommandStatus->unk_5C = 1;
134 }
135
136 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT)) {
137 if (actionCommandStatus->unk_5C != 0) {
138 actionCommandStatus->barFillLevel += (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 850) / 100;
139 actionCommandStatus->unk_5C = 0;
140 }
141 }
142
143 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
144 actionCommandStatus->barFillLevel -= (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 850) / 100;
145 }
146 }
147 }
148
149 if (actionCommandStatus->barFillLevel < 0) {
150 actionCommandStatus->barFillLevel = 0;
151 }
152
153 if (actionCommandStatus->barFillLevel > 10000) {
154 id = actionCommandStatus->hudElements[2];
155 actionCommandStatus->barFillLevel = 10000;
156 actionCommandStatus->isBarFilled = TRUE;
157 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY + 28);
159 }
160
161 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
163
164 switch (partner->actorBlueprint->level) {
166 if (battleStatus->actionQuality >= D_802A9984_429CA4[battleStatus->unk_85]) {
167 battleStatus->unk_85++;
168 }
169
170 if (battleStatus->unk_85 > 0 && battleStatus->actionQuality < D_802A9984_429CA4[battleStatus->unk_85 - 1]) {
171 battleStatus->unk_85--;
172 }
173 break;
175 if (battleStatus->actionQuality >= D_802A9994_429CB4[battleStatus->unk_85]) {
176 battleStatus->unk_85++;
177 }
178 if (battleStatus->unk_85 > 0 && battleStatus->actionQuality < D_802A9994_429CB4[battleStatus->unk_85 - 1]) {
179 battleStatus->unk_85--;
180 }
181 break;
183 if (battleStatus->actionQuality >= D_802A99A8_429CC8[battleStatus->unk_85]) {
184 battleStatus->unk_85++;
185 }
186 if (battleStatus->unk_85 > 0 && battleStatus->actionQuality < D_802A99A8_429CC8[battleStatus->unk_85 - 1]) {
187 battleStatus->unk_85--;
188 }
189 break;
190 }
191
192 if (actionCommandStatus->frameCounter != 0) {
193 actionCommandStatus->frameCounter--;
194 return;
195 }
196
197 if (actionCommandStatus->barFillLevel == 0) {
198 battleStatus->actionSuccess = -1;
199 } else {
200 battleStatus->actionSuccess = actionCommandStatus->barFillLevel / 100;
201 }
202
203 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1];
204 if (battleStatus->actionSuccess <= cutoff) {
205 battleStatus->actionResult = ACTION_RESULT_MINUS_2;
206 } else {
207 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
208 }
209
210 if (battleStatus->actionSuccess == 100) {
212 }
213
216 actionCommandStatus->frameCounter = 5;
217 actionCommandStatus->state = 12;
218 break;
219 case 12:
220 if (actionCommandStatus->frameCounter != 0) {
221 actionCommandStatus->frameCounter--;
222 return;
223 }
225 break;
226 }
227}
228
230
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
s32 D_802A9994_429CB4[]
Definition air_raid.c:8
s32 D_802A9970_429C90[]
Definition air_raid.c:6
s32 D_802A9984_429CA4[]
Definition air_raid.c:7
void N update(void)
Definition air_raid.c:64
s32 D_802A99A8_429CC8[]
Definition air_raid.c:9
s32 actionCmdTableAirRaid[]
Definition action_cmd.c:41
struct ActorBlueprint * actorBlueprint
@ ACTION_COMMAND_AIR_RAID
Definition enums.h:3486
@ 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
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