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
13static s32 _pad = 0; // XXX
14
15#include "battle/move/item/strange_cake1.png.h"
16INCLUDE_IMG("battle/move/item/strange_cake1.png", battle_item_strange_cake1_png);
17INCLUDE_PAL("battle/move/item/strange_cake1.pal", battle_item_strange_cake1_pal);
18
19#include "battle/move/item/strange_cake2.png.h"
20INCLUDE_IMG("battle/move/item/strange_cake2.png", battle_item_strange_cake2_png);
21INCLUDE_PAL("battle/move/item/strange_cake2.pal", battle_item_strange_cake2_pal);
22
23#include "battle/move/item/strange_cake3.png.h"
24INCLUDE_IMG("battle/move/item/strange_cake3.png", battle_item_strange_cake3_png);
25INCLUDE_PAL("battle/move/item/strange_cake3.pal", battle_item_strange_cake3_pal);
26
27HudScript N(D_802A27D0) = HES_TEMPLATE_CI_ENUM_SIZE(battle_item_strange_cake1, 32, 32);
28HudScript N(D_802A27F8) = HES_TEMPLATE_CI_ENUM_SIZE(battle_item_strange_cake2, 32, 32);
29HudScript N(D_802A2820) = HES_TEMPLATE_CI_ENUM_SIZE(battle_item_strange_cake3, 32, 32);
30
31HudScript* N(D_802A2848_732B48)[] = {
32 &N(D_802A27F8), &N(D_802A2820), &N(D_802A27D0), &N(D_802A27F8)
33};
34
35// indexes into D_802A2848_732B48
36s32 N(D_802A2858_732B58)[] = {
37 0, 1, 2, 0, 1, 0
38};
39
40BSS s32 D_802A2DD4; // unused?
48
49void N(func_802A123C_73153C(void)) {
50 s32 var_s3;
51 s32 id;
52 s32 i;
53
54 if (D_802A2DEC < 6) {
55 if (D_802A2DEC > 0) {
56 draw_box(0, WINDOW_STYLE_7, 106, 86, 0, 36, 36, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
57 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 108, 90, 139, 118);
58
59 for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) {
60 id = D_802A2DD8[i];
61 hud_element_set_render_pos(id, 124, (i * 26) + 104 - (D_802A2DF4 / 100));
63 }
64 id = D_802A2DD8[0];
65 hud_element_set_render_pos(id, 124, (i * 26) + 104 - (D_802A2DF4 / 100));
67 }
68 }
69}
70
71API_CALLABLE(N(func_802A13E4_7316E4)) {
72 BattleStatus* battleStatus = &gBattleStatus;
73 s32 temp_a0_4;
74 s32 temp_v1_3;
75 s32 var_v0_2;
76 s32 var_v0_3;
77 s32 id;
78 s32 i;
79
80 if (isInitialCall) {
81 D_802A2DEC = 0;
82 }
83
84 switch (D_802A2DEC) {
85 case 0:
86 D_802A2E00 = create_worker_frontUI(NULL, N(func_802A123C_73153C));
87 D_802A2DF4 = rand_int(13000);
88 D_802A2DF8 = 1000;
89
90 for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) {
91 id = hud_element_create(N(D_802A2848_732B48)[N(D_802A2858_732B58)[i]]);
92 D_802A2DD8[i] = id;
94 }
95 D_802A2DEC = 1;
96
97 return ApiStatus_BLOCK;
98 case 1:
100 if (D_802A2DF4 / 100 >= 130) {
101 D_802A2DF4 -= 13000;
102 }
103
104 if (D_802A2DF8 > 400) {
105 D_802A2DF8 -= 10;
106 } else if (D_802A2DF8 > 100) {
107 D_802A2DF8 -= 5;
108 } else {
109 D_802A2DF8 -= 1;
110 }
111
112 if (D_802A2DF8 < 10) {
113 D_802A2DF0 = D_802A2DF4 / 100;
114
115 if (((D_802A2DF4 / 100) % 26) < 13) {
116 if (rand_int(100) < 80) {
117 D_802A2DEC = 2;
118 } else {
119 D_802A2DEC = 3;
120 }
121 break;
122 }
123
124 if (rand_int(100) < 60) {
125 D_802A2DEC = 3;
126 } else {
127 D_802A2DEC = 2;
128 }
129 }
130 break;
131 case 2:
132 temp_a0_4 = D_802A2DF0 % 26;
133 var_v0_2 = temp_a0_4 + 3;
134 if (var_v0_2 < 0) {
135 var_v0_2 += 3;
136 }
137 temp_a0_4 = var_v0_2 >> 2;
138 D_802A2DF0 -= temp_a0_4;
139 D_802A2DF4 = D_802A2DF0 * 100;
140 if (temp_a0_4 == 0) {
141 D_802A2DEC = 4;
142 }
143 break;
144 case 3:
145 temp_v1_3 = D_802A2DF0 % 26;
146 if (temp_v1_3 == 0) {
147 D_802A2DEC = 4;
148 break;
149 }
150 temp_a0_4 = 26 - temp_v1_3;
151 var_v0_3 = temp_a0_4 + 3;
152 if (var_v0_3 < 0) {
153 var_v0_3 += 3;
154 }
155 temp_a0_4 = var_v0_3 >> 2;
156 D_802A2DF0 += temp_a0_4;
157 D_802A2DF4 = D_802A2DF0 * 100;
158 break;
159 case 4:
160 D_802A2DFC = 20;
161 D_802A2DEC = 5;
162 break;
163 case 5:
164 if (D_802A2DFC != 0) {
165 D_802A2DFC--;
166 break;
167 }
168
169 var_v0_3 = i = D_802A2DF0 / 26; // use of i required to match
170 battleStatus->moveArgument = N(D_802A2858_732B58)[var_v0_3];
171 script->varTable[0] = battleStatus->moveArgument;
173 for (i = 0; i < ARRAY_COUNT(D_802A2DD8); i++) {
175 }
176 return ApiStatus_DONE2;
177 }
178 return ApiStatus_BLOCK;
179}
180
181API_CALLABLE(N(SpawnHeartRecoveryFX)) {
182 Bytecode* args = script->ptrReadPos;
183 s32 a = evt_get_variable(script, *args++);
184 s32 b = evt_get_variable(script, *args++);
185 s32 c = evt_get_variable(script, *args++);
186 s32 d = evt_get_variable(script, *args++);
187
188 fx_recover(0, a, b, c, d);
189 return ApiStatus_DONE2;
190}
191
192API_CALLABLE(N(SpawnFlowerRecoveryFX)) {
193 Bytecode* args = script->ptrReadPos;
194 s32 a = evt_get_variable(script, *args++);
195 s32 b = evt_get_variable(script, *args++);
196 s32 c = evt_get_variable(script, *args++);
197 s32 d = evt_get_variable(script, *args++);
198
199 fx_recover(1, a, b, c, d);
200 return ApiStatus_DONE2;
201}
202
203#if !VERSION_PAL
204#include "common/AddHP.inc.c"
205#include "common/AddFP.inc.c"
206
207API_CALLABLE(N(func_802A1A40_731D40)) {
208 ItemData* item = &gItemTable[ITEM_KOOKY_COOKIE];
209 PlayerData* playerData = &gPlayerData;
210
211 playerData->curHP += item->potencyA;
212 if (playerData->curHP > playerData->curMaxHP) {
213 playerData->curHP = playerData->curMaxHP;
214 }
215
216 script->varTable[3] = item->potencyA;
217
218 return ApiStatus_DONE2;
219}
220#endif
221
222API_CALLABLE(N(func_802A1A8C_731D8C)) {
223 ItemData* item = &gItemTable[ITEM_KOOKY_COOKIE];
224 PlayerData* playerData = &gPlayerData;
225
226 playerData->curFP += item->potencyB;
227 if (playerData->curFP > playerData->curMaxFP) {
228 playerData->curFP = playerData->curMaxFP;
229 }
230
231 script->varTable[3] = item->potencyB;
232
233 return ApiStatus_DONE2;
234}
235
236API_CALLABLE(N(func_802A1AD8_731DD8)) {
237 BattleStatus* battleStatus = &gBattleStatus;
238 Actor* player = battleStatus->playerActor;
239
241 player->statusAfflicted = 0;
242
243 return ApiStatus_DONE2;
244}
245
246API_CALLABLE(N(func_802A1B14_731E14)) {
247 BattleStatus* battleStatus = &gBattleStatus;
248 Actor* player = battleStatus->playerActor;
249 ActorPart* part = player->partsTable;
250
252 player->statusAfflicted = 0;
254
255 return ApiStatus_DONE2;
256}
257
258API_CALLABLE(N(func_802A1B68_731E68)) {
259 BattleStatus* battleStatus = &gBattleStatus;
260 Actor* player = battleStatus->playerActor;
261
263 player->statusAfflicted = 0;
264
265 return ApiStatus_DONE2;
266}
267
268extern EvtScript N(script7);
269extern EvtScript N(script8);
270extern EvtScript N(script9);
271
272EvtScript N(EVS_UseItem) = {
273 Call(GetMenuSelection, LVar0, LVar1, LVar2)
274 IfEq(LVar1, ITEM_KOOKY_COOKIE)
275 SetConst(LVarA, ITEM_KOOKY_COOKIE)
276 Set(LVar1, 0)
277 ExecWait(N(UseItemWithEffect))
278 ExecWait(N(EatItem))
279 Call(N(func_802A1A8C_731D8C))
280 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
281 Add(LVar0, 20)
282 Add(LVar1, 25)
283 Call(N(SpawnFlowerRecoveryFX), LVar0, LVar1, LVar2, LVar3)
284 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
285 Add(LVar1, 25)
287#if !VERSION_PAL
288 Call(N(AddFP), LVar3)
289#endif
290 Wait(10)
291 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_ThumbsUp)
292 Wait(30)
293 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
295 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
296 Wait(20)
297 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_UsePower)
298 Else
299 SetConst(LVarA, ITEM_STRANGE_CAKE)
300 Set(LVar1, 0)
301 ExecWait(N(UseItemWithEffect))
302 ExecWait(N(EatItem))
303 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_UsePower)
304 EndIf
305 Wait(10)
306 Thread
307 Wait(220)
308 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_DING)
310 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_MYSTERY_REEL)
311 Call(N(func_802A13E4_7316E4))
312 Wait(2)
314 CaseEq(0)
315 ExecWait(N(script7))
316 CaseEq(1)
317 ExecWait(N(script8))
318 CaseEq(2)
319 ExecWait(N(script9))
321 ExecWait(N(PlayerGoHome))
322 Return
323 End
324};
325
326EvtScript N(script7) = {
327 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
328 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
329 Add(LVar1, 20)
330 PlayEffect(EFFECT_SNAKING_STATIC, 0, LVar0, LVar1, LVar2, Float(1.0), 30, 0)
331 Call(N(func_802A1AD8_731DD8))
332 Wait(20)
333 Call(ShowMessageBox, BTL_MSG_PLAYER_CHARGED, 60)
334 Call(WaitForMessageBoxDone)
335 Return
336 End
337};
338
339EvtScript N(script8) = {
340 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
341 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
342 Add(LVar1, 20)
343 PlayEffect(EFFECT_RADIAL_SHIMMER, 6, LVar0, LVar1, LVar2, Float(1.0), 30, 0)
344 Call(N(func_802A1B14_731E14))
345 Wait(20)
346 Call(ShowMessageBox, BTL_MSG_PLAYER_TRANSPARENT, 60)
347 Call(WaitForMessageBoxDone)
348 Return
349 End
350};
351
352EvtScript N(script9) = {
353 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_MarioB1_Sleep)
354 Call(SetGoalToTarget, ACTOR_PLAYER)
355 Call(GetGoalPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
357 Call(N(func_802A1B68_731E68))
358 Wait(20)
359 Call(ShowMessageBox, BTL_MSG_PLAYER_ASLEEP, 60)
360 Call(WaitForMessageBoxDone)
361 Return
362 End
363};
364
struct ActorPart * partsTable
Bytecode EvtScript[]
s8 statusAfflicted
#define rand_int
#define draw_box
@ WINDOW_STYLE_7
Definition enums.h:6377
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:4074
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:4069
@ BTL_MSG_PLAYER_TRANSPARENT
Definition enums.h:4075
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2210
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ SOUND_DING
Definition enums.h:1306
@ SOUND_MYSTERY_REEL
Definition enums.h:1176
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_PART_FLAG_TRANSPARENT
Definition enums.h:3357
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:2084
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)
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_free(s32 id)
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
#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:295
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:311
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#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:319
#define SCREEN_WIDTH
Definition macros.h:105
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define Float(DOUBLE)
Definition macros.h:51
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define SCREEN_HEIGHT
Definition macros.h:106
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define Thread
Marks the start of a thread block.
Definition macros.h:544
#define EndThread
Marks the end of a thread block.
Definition macros.h:547
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define PlayEffect(args...)
Definition macros.h:807
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:362
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:269
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define LVar3
Definition macros.h:151
#define LVar0
Definition macros.h:148
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
Definition macros.h:370
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:455
#define Return
Kills the current EVT thread.
Definition macros.h:217
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
struct Actor * playerActor
ItemData gItemTable[]
Gfx * gMainGfxPos
Definition cam_main.c:15
PlayerData gPlayerData
Definition 77480.c:40
BattleStatus gBattleStatus
Definition battle.c:11