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

Go to the source code of this file.

Functions

void N update (void)
 
void N draw (void)
 
void N free (void)
 

Variables

BSS s32 D_802A9920
 
s32 actionCmdTableFlee []
 

Function Documentation

◆ update()

void N update ( void )

Definition at line 92 of file flee.c.

92 {
93 s32 temp;
94 s32 hudElement;
95 BattleStatus* battleStatus = &gBattleStatus;
96 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
97
98 switch (actionCommandStatus->state) {
99 case 0:
100 hudElement = actionCommandStatus->hudElements[0];
101 hud_element_set_alpha(hudElement, 0xFF);
102 if (actionCommandStatus->showHud) {
104 }
105
106 hudElement = actionCommandStatus->hudElements[1];
107 hud_element_set_alpha(hudElement, 0xFF);
108 if (actionCommandStatus->showHud) {
110 }
111
112 hudElement = actionCommandStatus->hudElements[2];
113 hud_element_set_alpha(hudElement, 0xFF);
114 if (actionCommandStatus->showHud) {
116 }
117
118 hudElement = actionCommandStatus->hudElements[3];
119 hud_element_set_alpha(hudElement, 0xFF);
120 if (actionCommandStatus->showHud) {
122 }
123
124 actionCommandStatus->state = 1;
125 break;
126 case 1:
127 actionCommandStatus->hudPosX += 20;
128 if (actionCommandStatus->hudPosX > 50) {
129 actionCommandStatus->hudPosX = 50;
130 }
131 hud_element_set_render_pos(actionCommandStatus->hudElements[0], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
132 hud_element_set_render_pos(actionCommandStatus->hudElements[1], actionCommandStatus->hudPosX, actionCommandStatus->hudPosY + 28);
133 break;
134 case 10:
135 if (actionCommandStatus->prepareTime != 0) {
136 actionCommandStatus->prepareTime--;
137 break;
138 }
139
140 hud_element_set_script(actionCommandStatus->hudElements[0], &HES_MashAButton);
141 D_802A9920 = 1;
142 actionCommandStatus->state = 11;
143 actionCommandStatus->frameCounter = actionCommandStatus->duration;
144 case 11:
145 if (battleStatus->actionCommandMode != ACTION_COMMAND_MODE_NOT_LEARNED && (battleStatus->curButtonsPressed & BUTTON_A)) {
146 actionCommandStatus->barFillLevel += (battleStatus->actionCmdDifficultyTable[actionCommandStatus->difficulty] * 180 / 100);
147 }
148 if (actionCommandStatus->barFillLevel >= 10000) {
149 hudElement = actionCommandStatus->hudElements[4];
150 actionCommandStatus->barFillLevel = 10000;
151 actionCommandStatus->isBarFilled = TRUE;
152 hud_element_set_render_pos(hudElement, actionCommandStatus->hudPosX + 50, actionCommandStatus->hudPosY + 28);
154 }
155
156 battleStatus->actionSuccess = actionCommandStatus->barFillLevel / 100;
157 if (actionCommandStatus->frameCounter == 0) {
158 if (battleStatus->actionSuccess >= (100 - actionCommandStatus->thresholdLevel)) {
159 battleStatus->actionResult = ACTION_RESULT_SUCCESS;
160 battleStatus->actionSuccess = 1;
161 } else {
162 battleStatus->actionResult = ACTION_RESULT_MINUS_2;
163 battleStatus->actionSuccess = -1;
164 }
165 actionCommandStatus->frameCounter = 20;
166 actionCommandStatus->state = 12;
167 } else {
168 actionCommandStatus->frameCounter--;
169 }
170 break;
171 case 12:
172 if (actionCommandStatus->frameCounter != 0) {
173 actionCommandStatus->frameCounter--;
174 break;
175 }
177 break;
178 }
179
180 switch (actionCommandStatus->state) {
181 case 1:
182 case 10:
183 case 11:
184 temp = actionCommandStatus->unk_5A == 0 ? 7 : 8;
185 if (actionCommandStatus->unk_5C == 0) {
186 actionCommandStatus->thresholdLevel += temp;
187 if (actionCommandStatus->thresholdLevel >= 100) {
188 actionCommandStatus->thresholdLevel = 100;
189 actionCommandStatus->unk_5C = 1;
190 }
191 break;
192 }
193 actionCommandStatus->thresholdLevel -= temp;
194 if (actionCommandStatus->thresholdLevel <= 0) {
195 actionCommandStatus->thresholdLevel = 0;
196 actionCommandStatus->unk_5C = 0;
197 }
198 }
199}
BSS ActionCommandStatus gActionCommandStatus
Definition action_cmd.c:91
void action_command_free(void)
Definition action_cmd.c:446
HudScript HES_MashAButton
@ ACTION_COMMAND_MODE_NOT_LEARNED
Definition action_cmd.h:38
@ BUTTON_A
Definition enums.h:2790
@ ACTION_RESULT_SUCCESS
Definition enums.h:1968
@ ACTION_RESULT_MINUS_2
Definition enums.h:1965
BSS s32 D_802A9920
Definition flee.c:6
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.
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:74
s32 * actionCmdDifficultyTable
BattleStatus gBattleStatus
Definition battle.c:11

◆ draw()

void N draw ( void )

Definition at line 201 of file flee.c.

201 {
202 s32 y;
203 s32 x;
204 s32 temp_a1;
205 s32 hudElement;
206 s32 temp_v1;
207
208 BattleStatus* battleStatus = &gBattleStatus;
209 ActionCommandStatus* actionCommandStatus = &gActionCommandStatus;
210
211 temp_v1 = (100 - actionCommandStatus->thresholdLevel) * 60;
212 x = 60 - temp_v1 / 100;
213 temp_a1 = x - 31;
214
215 hud_element_set_render_pos(actionCommandStatus->hudElements[3], actionCommandStatus->hudPosX - temp_a1, actionCommandStatus->hudPosY + 17);
216 hud_element_set_render_pos(actionCommandStatus->hudElements[2], actionCommandStatus->hudPosX + 31 - x, actionCommandStatus->hudPosY - 1);
217
219 hud_element_draw_clipped(actionCommandStatus->hudElements[0]);
220 }
221
222 hudElement = actionCommandStatus->hudElements[1];
223 hud_element_draw_clipped(hudElement);
224 hud_element_get_render_pos(hudElement, &x, &y);
225
226 if (D_802A9920 == 0) {
227 draw_mash_meter_multicolor_with_divisor(x, y, actionCommandStatus->barFillLevel / 100, 1);
228 } else {
229 if (!actionCommandStatus->isBarFilled) {
230 draw_mash_meter_multicolor_with_divisor(x, y, actionCommandStatus->barFillLevel / 100, 4);
231 } else {
232 draw_mash_meter_blink(x, y, actionCommandStatus->barFillLevel / 100);
233 }
234 }
235
236 hud_element_draw_clipped(actionCommandStatus->hudElements[2]);
237 hud_element_draw_clipped(actionCommandStatus->hudElements[3]);
238 hud_element_draw_clipped(actionCommandStatus->hudElements[4]);
239}
void draw_mash_meter_multicolor_with_divisor(s32 posX, s32 posY, s32 fillValue, s32 divisor)
Definition action_cmd.c:231
void draw_mash_meter_blink(s32 posX, s32 posY, s32 fillValue)
Definition action_cmd.c:246
void hud_element_get_render_pos(s32 id, s32 *x, s32 *y)
void hud_element_draw_clipped(s32 id)

◆ free()

Variable Documentation

◆ D_802A9920

BSS s32 D_802A9920

Definition at line 6 of file flee.c.

Referenced by draw(), and update().

◆ actionCmdTableFlee

s32 actionCmdTableFlee[]
extern

Definition at line 30 of file action_cmd.c.

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