Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
mystery.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "entity.h"
5#include "ld_addrs.h"
6#include "include_asset.h"
7
8#define NAMESPACE battle_item_mystery
9
11
13
14
15#include "battle/move/item/mystery.png.h"
16INCLUDE_IMG("battle/move/item/mystery.png", battle_item_mystery_png);
17INCLUDE_PAL("battle/move/item/mystery.pal", battle_item_mystery_pal);
18
19Vtx N(model)[] = {
20 { .v = {{ -16, -16, 0 }, false, { 0, 0 }, { 0, 0, 0, 255 }}},
21 { .v = {{ 15, -16, 0 }, false, { 1024, 0 }, { 0, 0, 0, 255 }}},
22 { .v = {{ 15, 15, 0 }, false, { 1024, 1024 }, { 0, 0, 0, 255 }}},
23 { .v = {{ -16, 15, 0 }, false, { 0, 1024 }, { 0, 0, 0, 255 }}},
24};
25
26Gfx N(displayList)[] = {
28 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
42 gsSP1Triangle(0, 1, 2, 0),
43 gsSP1Triangle(0, 2, 3, 0),
46};
47
49
50s32 N(D_802A227C_72D82C)[8] = {
59};
60
61s32 N(D_802A229C_72D84C)[8] = {
70};
71
73
74BSS s32 D_802A25C4; // unused?
83
84void N(func_802A123C_72C7EC(void)) {
85 s32 id;
86 s32 i;
87
88 if (D_802A25E4 < 6) {
89 if (D_802A25E4 > 0) {
90 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);
91 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 108, 90, 139, 118);
92
93 for (i = 0; i < ARRAY_COUNT(D_802A25C8); i++) {
94 id = D_802A25C8[i];
95 hud_element_set_render_pos(id, 124, (i * 26) + 104 - (D_802A25EC / 100));
97 }
98 id = D_802A25C8[0];
99 hud_element_set_render_pos(id, 124, (i * 26) + 104 - (D_802A25EC / 100));
101 }
102 }
103}
104
105API_CALLABLE(N(func_802A13E4_72C994)) {
112 s32 i;
113
114 if (isInitialCall) {
115 D_802A25E4 = 0;
116 }
117
118 switch (D_802A25E4) {
119 case 0:
121 D_802A25EC = rand_int(18200);
122 D_802A25F0 = 1000;
124
125 if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) {
126 u8 type;
127 f32 zoom;
128
130 if (zoom >= 215.0f) {
132 }
133 }
134
135 for (i = 0; i < ARRAY_COUNT(D_802A25C8); i++) {
137 D_802A25C8[i] = hid;
139 }
140 D_802A25E4 = 1;
141 return ApiStatus_BLOCK;
142 case 1:
144 if (D_802A25EC / 100 >= 182) {
145 D_802A25EC -= 18200;
146 }
147
148 if (D_802A25F0 > 400) {
149 D_802A25F0 -= 10;
150 } else if (D_802A25F0 > 100) {
151 D_802A25F0 -= 5;
152 } else {
153 D_802A25F0 -= 1;
154 }
155
156 if (D_802A25F0 < 10) {
157 D_802A25E8 = D_802A25EC / 100;
158
159 if (((D_802A25EC / 100) % 26) < 13) {
160 if (rand_int(100) < 80) {
161 D_802A25E4 = 2;
162 } else {
163 D_802A25E4 = 3;
164 }
165 break;
166 }
167
168 if (rand_int(100) < 60) {
169 D_802A25E4 = 3;
170 } else {
171 D_802A25E4 = 2;
172 }
173 }
174 break;
175 case 2:
176 temp_a0_4 = D_802A25E8 % 26;
177 var_v0_2 = temp_a0_4 + 3;
178 if (var_v0_2 < 0) {
179 var_v0_2 += 3;
180 }
181 temp_a0_4 = var_v0_2 >> 2;
183 D_802A25EC = D_802A25E8 * 100;
184 if (temp_a0_4 == 0) {
185 D_802A25E4 = 4;
186 }
187 break;
188 case 3:
189 temp_v1_3 = D_802A25E8 % 26;
190 if (temp_v1_3 == 0) {
191 D_802A25E4 = 4;
192 break;
193 }
194 temp_a0_4 = 26 - temp_v1_3;
195 var_v0_3 = temp_a0_4 + 3;
196 if (var_v0_3 < 0) {
197 var_v0_3 += 3;
198 }
199 temp_a0_4 = var_v0_3 >> 2;
201 D_802A25EC = D_802A25E8 * 100;
202 break;
203 case 4:
204 D_802A25F4 = 20;
205 D_802A25E4 = 5;
206 break;
207 case 5:
208 if (D_802A25F4 != 0) {
209 D_802A25F4--;
210 break;
211 }
212
213 var_v0_3 = i = D_802A25E8 / 26; // use of i required to match
214 battleStatus->moveArgument = D_802A25FC[D_802A25E8 / 26];
215 script->varTable[0] = battleStatus->moveArgument;
217 for (i = 0; i < ARRAY_COUNT(D_802A25C8); i++) {
219 }
220 return ApiStatus_DONE2;
221 }
222 return ApiStatus_BLOCK;
223}
224
225API_CALLABLE(N(func_802A188C_72CE3C)) {
226 Bytecode* args = script->ptrReadPos;
227 s32 a = evt_get_variable(script, *args++);
228 s32 b = evt_get_variable(script, *args++);
229 s32 c = evt_get_variable(script, *args++);
230
231 fx_damage_stars(FX_DAMAGE_STARS_2, a, b, c, 0, -1.0f, 0, 5);
232
233 return ApiStatus_DONE2;
234}
235
239 Thread
240 Wait(220)
245 Wait(2)
246 IfNe(LVar0, 133)
248 Return
249 EndIf
252 Add(LVar1, 150)
257 Thread
258 Set(LVar0, 0)
259 Loop(18)
260 Add(LVar0, -60)
262 Wait(1)
263 EndLoop
266 Add(LVar2, 5)
268 Thread
269 Add(LVar0, 60)
270 Add(LVar1, 0)
280 Return
281 End
282};
BSS s32 PopupMenu_SelectedIndex
s32 HudElemID
Bytecode EvtScript[]
#define rand_int
#define draw_box
@ FX_DAMAGE_STARS_2
Definition effects.h:358
s32 EntityModelScript[]
Definition entity.h:7
#define STANDARD_ENTITY_MODEL_SCRIPT(gfx, renderMode)
Definition entity.h:56
@ WINDOW_STYLE_7
Definition enums.h:5962
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3608
@ SCREEN_LAYER_BACK
Definition enums.h:2369
@ SOUND_DING
Definition enums.h:1309
@ SOUND_MYSTERY_REEL
Definition enums.h:1179
@ RENDER_MODE_ALPHATEST
Definition enums.h:3310
@ ACTOR_PLAYER
Definition enums.h:2118
@ ACTOR_SELF
Definition enums.h:2117
@ EVENT_HIT
Definition enums.h:2165
@ BTL_DARKNESS_STATE_NONE
Definition enums.h:5950
#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
void free_worker(s32)
Definition worker.c:176
void get_screen_overlay_params(s32, u8 *type, f32 *zoom)
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
EvtScript EVS_UseMystery
Definition use_items.c:203
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
IconHudScriptPair gItemHudScripts[]
BSS s32 D_802A25EC
Definition mystery.c:78
BSS s32 * D_802A25FC
Definition mystery.c:82
BSS s32 D_802A25E4
Definition mystery.c:76
BSS s32 D_802A25E8
Definition mystery.c:77
BSS s32 D_802A25C4
Definition mystery.c:74
BSS s32 D_802A25F4
Definition mystery.c:80
BSS s32 D_802A25F0
Definition mystery.c:79
BSS s32 D_802A25F8
Definition mystery.c:81
BSS s32 D_802A25C8[7]
Definition mystery.c:75
ApiStatus CreateVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityJumpGravity(Evt *script, b32 isInitialCall)
ApiStatus DeleteVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityJumpTo(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRotation(Evt *script, b32 isInitialCall)
#define Ref(sym)
Address/pointer constant.
Definition macros.h:61
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:366
#define SCREEN_WIDTH
Definition macros.h:108
#define IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:273
#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 EndLoop
Marks the end of a loop.
Definition macros.h:249
#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 Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:577
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:246
#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 Return
Kills the current EVT thread.
Definition macros.h:218
#define Jump(EVT_SOURCE)
Jumps to a given instruction pointer and begins execution from there.
Definition macros.h:223
ItemData gItemTable[]
Gfx * gMainGfxPos
Definition cam_main.c:14
BattleStatus gBattleStatus
Definition battle.cpp:14
void fx_damage_stars(s32, f32, f32, f32, f32, f32, f32, s32)