Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
strange_cake.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "hud_element.h"
5#include "sprite/player.h"
6#include "include_asset.h"
7
8#define NAMESPACE battle_item_strange_cake
9
12
13
14#include "battle/move/item/strange_cake1.png.h"
15INCLUDE_IMG("battle/move/item/strange_cake1.png", battle_item_strange_cake1_png);
16INCLUDE_PAL("battle/move/item/strange_cake1.pal", battle_item_strange_cake1_pal);
17
18#include "battle/move/item/strange_cake2.png.h"
19INCLUDE_IMG("battle/move/item/strange_cake2.png", battle_item_strange_cake2_png);
20INCLUDE_PAL("battle/move/item/strange_cake2.pal", battle_item_strange_cake2_pal);
21
22#include "battle/move/item/strange_cake3.png.h"
23INCLUDE_IMG("battle/move/item/strange_cake3.png", battle_item_strange_cake3_png);
24INCLUDE_PAL("battle/move/item/strange_cake3.pal", battle_item_strange_cake3_pal);
25
29
32};
33
34// indexes into D_802A2848_732B48
36 0, 1, 2, 0, 1, 0
37};
38
39BSS s32 D_802A2DD4; // unused?
47
48void N(func_802A123C_73153C(void)) {
49 s32 id;
50 s32 i;
51
52 if (D_802A2DEC < 6) {
53 if (D_802A2DEC > 0) {
54 draw_box(0, WINDOW_STYLE_7, 106, 86, 0, 36, 36, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, nullptr, nullptr, nullptr, SCREEN_WIDTH, SCREEN_HEIGHT, nullptr);
55 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 108, 90, 139, 118);
56
57 for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) {
58 id = D_802A2DD8[i];
59 hud_element_set_render_pos(id, 124, (i * 26) + 104 - (D_802A2DF4 / 100));
61 }
62 id = D_802A2DD8[0];
63 hud_element_set_render_pos(id, 124, (i * 26) + 104 - (D_802A2DF4 / 100));
65 }
66 }
67}
68
69API_CALLABLE(N(func_802A13E4_7316E4)) {
76 s32 i;
77
78 if (isInitialCall) {
79 D_802A2DEC = 0;
80 }
81
82 switch (D_802A2DEC) {
83 case 0:
85 D_802A2DF4 = rand_int(13000);
86 D_802A2DF8 = 1000;
87
88 for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) {
90 D_802A2DD8[i] = hid;
92 }
93 D_802A2DEC = 1;
94
95 return ApiStatus_BLOCK;
96 case 1:
98 if (D_802A2DF4 / 100 >= 130) {
99 D_802A2DF4 -= 13000;
100 }
101
102 if (D_802A2DF8 > 400) {
103 D_802A2DF8 -= 10;
104 } else if (D_802A2DF8 > 100) {
105 D_802A2DF8 -= 5;
106 } else {
107 D_802A2DF8 -= 1;
108 }
109
110 if (D_802A2DF8 < 10) {
111 D_802A2DF0 = D_802A2DF4 / 100;
112
113 if (((D_802A2DF4 / 100) % 26) < 13) {
114 if (rand_int(100) < 80) {
115 D_802A2DEC = 2;
116 } else {
117 D_802A2DEC = 3;
118 }
119 break;
120 }
121
122 if (rand_int(100) < 60) {
123 D_802A2DEC = 3;
124 } else {
125 D_802A2DEC = 2;
126 }
127 }
128 break;
129 case 2:
130 temp_a0_4 = D_802A2DF0 % 26;
131 var_v0_2 = temp_a0_4 + 3;
132 if (var_v0_2 < 0) {
133 var_v0_2 += 3;
134 }
135 temp_a0_4 = var_v0_2 >> 2;
137 D_802A2DF4 = D_802A2DF0 * 100;
138 if (temp_a0_4 == 0) {
139 D_802A2DEC = 4;
140 }
141 break;
142 case 3:
143 temp_v1_3 = D_802A2DF0 % 26;
144 if (temp_v1_3 == 0) {
145 D_802A2DEC = 4;
146 break;
147 }
148 temp_a0_4 = 26 - temp_v1_3;
149 var_v0_3 = temp_a0_4 + 3;
150 if (var_v0_3 < 0) {
151 var_v0_3 += 3;
152 }
153 temp_a0_4 = var_v0_3 >> 2;
155 D_802A2DF4 = D_802A2DF0 * 100;
156 break;
157 case 4:
158 D_802A2DFC = 20;
159 D_802A2DEC = 5;
160 break;
161 case 5:
162 if (D_802A2DFC != 0) {
163 D_802A2DFC--;
164 break;
165 }
166
167 var_v0_3 = i = D_802A2DF0 / 26; // use of i required to match
168 battleStatus->moveArgument = N(D_802A2858_732B58)[var_v0_3];
169 script->varTable[0] = battleStatus->moveArgument;
171 for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) {
173 }
174 return ApiStatus_DONE2;
175 }
176 return ApiStatus_BLOCK;
177}
178
179API_CALLABLE(N(SpawnHeartRecoveryFX)) {
180 Bytecode* args = script->ptrReadPos;
181 s32 a = evt_get_variable(script, *args++);
182 s32 b = evt_get_variable(script, *args++);
183 s32 c = evt_get_variable(script, *args++);
184 s32 d = evt_get_variable(script, *args++);
185
186 fx_recover(0, a, b, c, d);
187 return ApiStatus_DONE2;
188}
189
190API_CALLABLE(N(SpawnFlowerRecoveryFX)) {
191 Bytecode* args = script->ptrReadPos;
192 s32 a = evt_get_variable(script, *args++);
193 s32 b = evt_get_variable(script, *args++);
194 s32 c = evt_get_variable(script, *args++);
195 s32 d = evt_get_variable(script, *args++);
196
197 fx_recover(1, a, b, c, d);
198 return ApiStatus_DONE2;
199}
200
201#if !VERSION_PAL
202#include "common/AddHP.inc.c"
203#include "common/AddFP.inc.c"
204
205API_CALLABLE(N(func_802A1A40_731D40)) {
208
209 playerData->curHP += item->potencyA;
210 if (playerData->curHP > playerData->curMaxHP) {
211 playerData->curHP = playerData->curMaxHP;
212 }
213
214 script->varTable[3] = item->potencyA;
215
216 return ApiStatus_DONE2;
217}
218#endif
219
220API_CALLABLE(N(func_802A1A8C_731D8C)) {
223
224 playerData->curFP += item->potencyB;
225 if (playerData->curFP > playerData->curMaxFP) {
226 playerData->curFP = playerData->curMaxFP;
227 }
228
229 script->varTable[3] = item->potencyB;
230
231 return ApiStatus_DONE2;
232}
233
234API_CALLABLE(N(func_802A1AD8_731DD8)) {
236 Actor* player = battleStatus->playerActor;
237
239 player->statusAfflicted = 0;
240
241 return ApiStatus_DONE2;
242}
243
244API_CALLABLE(N(func_802A1B14_731E14)) {
246 Actor* player = battleStatus->playerActor;
247 ActorPart* part = player->partsTable;
248
250 player->statusAfflicted = 0;
252
253 return ApiStatus_DONE2;
254}
255
256API_CALLABLE(N(func_802A1B68_731E68)) {
258 Actor* player = battleStatus->playerActor;
259
261 player->statusAfflicted = 0;
262
263 return ApiStatus_DONE2;
264}
265
266extern EvtScript N(script7);
267extern EvtScript N(script8);
268extern EvtScript N(script9);
269
274 Set(LVar1, 0)
276 ExecWait(N(EatItem))
279 Add(LVar0, 20)
280 Add(LVar1, 25)
283 Add(LVar1, 25)
285#if !VERSION_PAL
286 Call(N(AddFP), LVar3)
287#endif
288 Wait(10)
290 Wait(30)
294 Wait(20)
296 Else
298 Set(LVar1, 0)
300 ExecWait(N(EatItem))
302 EndIf
303 Wait(10)
304 Thread
305 Wait(220)
310 Wait(2)
312 CaseEq(0)
313 ExecWait(N(script7))
314 CaseEq(1)
315 ExecWait(N(script8))
316 CaseEq(2)
317 ExecWait(N(script9))
320 Return
321 End
322};
323
324EvtScript N(script7) = {
327 Add(LVar1, 20)
330 Wait(20)
333 Return
334 End
335};
336
337EvtScript N(script8) = {
340 Add(LVar1, 20)
343 Wait(20)
346 Return
347 End
348};
349
350EvtScript N(script9) = {
356 Wait(20)
359 Return
360 End
361};
362
BSS s32 PopupMenu_SelectedIndex
struct ActorPart * partsTable
s32 HudElemID
Bytecode EvtScript[]
s8 statusAfflicted
#define rand_int
#define draw_box
@ WINDOW_STYLE_7
Definition enums.h:5962
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:3716
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:3711
@ BTL_MSG_PLAYER_TRANSPARENT
Definition enums.h:3717
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2815
@ STATUS_KEY_STATIC
Definition enums.h:2812
@ STATUS_KEY_SLEEP
Definition enums.h:2807
@ SOUND_DING
Definition enums.h:1309
@ SOUND_MYSTERY_REEL
Definition enums.h:1179
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_PART_FLAG_TRANSPARENT
Definition enums.h:3391
#define ApiStatus_DONE2
Definition evt.h:119
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:117
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:1814
void free_worker(s32)
Definition worker.c:176
s32 create_worker_frontUI(void(*updateFunc)(void), void(*drawFunc)(void))
Definition worker.c:63
void hud_element_draw_without_clipping(s32 id)
HudElemID hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_MANUAL_RENDER
Definition hud_element.h:78
#define HES_TEMPLATE_CI_ENUM_SIZE(name, sizeX, sizeY)
Basic HudScript used for static CI images, setting size with hs_SetTileSize.
s32 HudScript[]
Definition hud_element.h:9
EvtScript EVS_PlaySleepHitFX
Definition dmg_player.c:85
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
ApiStatus ShowRecoveryShimmer(Evt *script, b32 isInitialCall)
ApiStatus ShowStartRecoveryShimmer(Evt *script, b32 isInitialCall)
#define Else
Marks the end of an if statement and the start of the else block.
Definition macros.h:296
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:312
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:366
#define CaseEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR. It also marks the end of any pre...
Definition macros.h:320
#define SCREEN_WIDTH
Definition macros.h:108
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:214
#define Add(VAR, INT_VALUE)
Definition macros.h:377
#define BSS
Definition macros.h:6
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define Float(DOUBLE)
Definition macros.h:52
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:299
#define SCREEN_HEIGHT
Definition macros.h:109
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:476
#define Thread
Marks the start of a thread block.
Definition macros.h:545
#define EndThread
Marks the end of a thread block.
Definition macros.h:548
#define LVar2
Definition macros.h:151
#define LVar1
Definition macros.h:150
#define LVarA
Definition macros.h:159
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:255
#define PlayEffect(args...)
Definition macros.h:811
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:363
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:270
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:577
#define LVar3
Definition macros.h:152
#define LVar0
Definition macros.h:149
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
Definition macros.h:371
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:456
#define Return
Kills the current EVT thread.
Definition macros.h:218
BSS s32 D_802A2DF8
BSS s32 D_802A2DD8[5]
BSS s32 D_802A2DFC
BSS s32 D_802A2DF0
BSS s32 D_802A2DEC
BSS s32 D_802A2DF4
BSS s32 D_802A2DD4
BSS s32 D_802A2E00
ItemData gItemTable[]
Gfx * gMainGfxPos
Definition cam_main.c:14
PlayerData gPlayerData
Definition 77480.c:39
BattleStatus gBattleStatus
Definition battle.cpp:14