Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
spook.c File Reference

Go to the source code of this file.

Functions

void N update (void)
 

Variables

s32 D_802A9920_430940 [8] = { 0, 25, 50, 75, 75, 0, 0, 0 }
 
s32 actionCmdTableSpook []
 

Function Documentation

◆ update()

void N update ( void )

Definition at line 60 of file spook.c.

60 {
61 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
62 BattleStatus* battleStatus = &gBattleStatus;
63 s32 id;
64 s32 cutoff;
65 s32 fillLevel;
66
67 switch (actionCommandStatus->state) {
68 case 0:
70
71 id = actionCommandStatus->hudElements[0];
72 hud_element_set_alpha(id, 255);
73 if (actionCommandStatus->showHud) {
75 }
76
77 id = actionCommandStatus->hudElements[1];
78 hud_element_set_alpha(id, 255);
79 if (actionCommandStatus->showHud) {
81 }
82
83 actionCommandStatus->state = 1;
84 break;
85 case 1:
87 actionCommandStatus->hudPosX += 20;
88 if (actionCommandStatus->hudPosX > 50) {
89 actionCommandStatus->hudPosX = 50;
90 }
91 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
92 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
93 break;
94 case 10:
96 if (actionCommandStatus->prepareTime != 0) {
97 actionCommandStatus->prepareTime--;
98 return;
99 }
100 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_StickMashLeft);
101 actionCommandStatus->barFillLevel = 0;
102 battleStatus->actionQuality = 0;
103 actionCommandStatus->unk_5C = 0;
104 actionCommandStatus->frameCounter = actionCommandStatus->duration;
106 actionCommandStatus->state = 11;
107 case 11:
109 if (!actionCommandStatus->isBarFilled) {
110 if (actionCommandStatus->targetWeakness != 0) {
111 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals];
112
113 actionCommandStatus->barFillLevel -= D_802A9920_430940[actionCommandStatus->barFillLevel / cutoff / 20];
114 if (actionCommandStatus->barFillLevel < 0) {
115 actionCommandStatus->barFillLevel = 0;
116 }
117 } else {
118 actionCommandStatus->barFillLevel -= 10;
119 if (actionCommandStatus->barFillLevel < 0) {
120 actionCommandStatus->barFillLevel = 0;
121 }
122 }
123
124 if (!actionCommandStatus->isBarFilled) {
125 if (actionCommandStatus->targetWeakness != 0) {
126
127 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
128 actionCommandStatus->unk_5C = TRUE;
129 }
130
131 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) && actionCommandStatus->unk_5C) {
132 s32 a = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty];
133 s32 b = actionCommandStatus->targetWeakness * 850;
134
135 actionCommandStatus->barFillLevel += (a * b) / 10000;
136 actionCommandStatus->unk_5C = 0;
137 }
138
139 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
140 s32 a = battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty];
141 s32 b = actionCommandStatus->targetWeakness * 850;
142
143 actionCommandStatus->barFillLevel -= (a * b) / 10000;
144 }
145 } else {
146 if (battleStatus->curButtonsDown & BUTTON_STICK_LEFT) {
147 actionCommandStatus->unk_5C = TRUE;
148 }
149
150 if (!(battleStatus->curButtonsDown & BUTTON_STICK_LEFT) && actionCommandStatus->unk_5C) {
151 actionCommandStatus->barFillLevel += 100;
152 if (actionCommandStatus->barFillLevel >= 500) {
153 actionCommandStatus->barFillLevel = 500;
154 }
155 actionCommandStatus->unk_5C = 0;
156 }
157
158 if (battleStatus->curButtonsPressed & BUTTON_STICK_RIGHT) {
159 actionCommandStatus->barFillLevel -= 100;
160 }
161 }
162 }
163 }
164
165 if (actionCommandStatus->barFillLevel < 0) {
166 actionCommandStatus->barFillLevel = 0;
167 }
168 if (actionCommandStatus->barFillLevel > 10000) {
169 id = actionCommandStatus->hudElements[2];
170 actionCommandStatus->barFillLevel = 10000;
171 actionCommandStatus->isBarFilled = TRUE;
172 hud_element_set_render_pos(id, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY + 28);
174 }
175
176 battleStatus->actionQuality = actionCommandStatus->barFillLevel / 100;
178
179 if (actionCommandStatus->frameCounter != 0) {
180 actionCommandStatus->frameCounter--;
181 return;
182 }
183
184 fillLevel = actionCommandStatus->barFillLevel;
185 if (actionCommandStatus->targetWeakness == 0) {
186 fillLevel = 0;
187 }
188
189 if (fillLevel == 0) {
190 battleStatus->actionSuccess = -1;
191 } else {
192 battleStatus->actionSuccess = fillLevel / 100;
193
194 }
195
196 cutoff = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1];
197 if (battleStatus->actionSuccess > cutoff) {
198 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
199 } else {
200 battleStatus->actionResult = ACTION_RESULT_MINUS_2;
201 }
202
203 if (battleStatus->actionSuccess == 100) {
205 }
208 actionCommandStatus->frameCounter = 5;
209 actionCommandStatus->state = 12;
210 break;
211 case 12:
212 if (actionCommandStatus->targetWeakness == 0) {
213 actionCommandStatus->barFillLevel -= 100;
214 if (actionCommandStatus->barFillLevel < 0) {
215 actionCommandStatus->barFillLevel = 0;
216 }
217 }
218
219 if (actionCommandStatus->frameCounter != 0) {
220 actionCommandStatus->frameCounter--;
221 return;
222 }
224 break;
225 }
226}
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
HudScript HES_StickMashLeft
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ SOUND_LOOP_CHARGE_BAR
Definition enums.h:1646
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_MINUS_2
Definition enums.h:1965
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_pos(s32 id, s32 x, s32 y)
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
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 D_802A9920_430940[8]
Definition spook.c:7
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11

Variable Documentation

◆ D_802A9920_430940

s32 D_802A9920_430940[8] = { 0, 25, 50, 75, 75, 0, 0, 0 }

Definition at line 7 of file spook.c.

7{ 0, 25, 50, 75, 75, 0, 0, 0 };

Referenced by update().

◆ actionCmdTableSpook

s32 actionCmdTableSpook[]
extern

Definition at line 48 of file action_cmd.c.

48{ 130, 120, 110, 100, 90, 80, 70, 60 };