Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
slot_machine.inc.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
4
5// namespace not defined here; actor is associated with stages
6
7extern EvtScript N(EVS_Init);
8extern EvtScript N(EVS_Idle);
9extern EvtScript N(EVS_TakeTurn);
11
12// data pertaining to the slot machine itself is stored here, where all the interactable block actors can access it
13BSS s32 N(SharedSlotMachineData)[10];
14
15#define BUF_GameState ArrayVar(1)
16// current state for each reel
17#define BUF_ReelState1 ArrayVar(2)
18#define BUF_ReelState2 ArrayVar(3)
19#define BUF_ReelState3 ArrayVar(4)
20// current angle for each reel
21#define BUF_ReelAngle1 ArrayVar(5)
22#define BUF_ReelAngle2 ArrayVar(6)
23#define BUF_ReelAngle3 ArrayVar(7)
24// how much further to rotate each reel before stopping
25#define BUF_ReelLeft1 ArrayVar(8)
26#define BUF_ReelLeft2 ArrayVar(9)
27#define BUF_ReelLeft3 ArrayVar(10)
28
29enum N(GameStates) {
30 SLOTS_STATE_INERT = 0, // waiting for START block to be hit
31 SLOTS_STATE_ACTIVE = 1, // the reels are spinning; hit one of blocks to stop them
32 SLOTS_STATE_PAYOUT = 2, // one round is complete, coins may be dropping
33};
34
35enum N(ReelStates) {
40};
41
42enum N(ActorPartIDs) {
43 PRT_MAIN = 1,
44};
45
46enum N(ActorVars) {
52};
53
54#define SYM_SHYGUY 0
55#define SYM_STAR 1
56#define SYM_COIN 2
57
61
62s32 N(DefenseTable)[] = {
65};
66
67s32 N(StatusTable)[] = {
90};
91
93 {
95 .index = PRT_MAIN,
96 .posOffset = { 0, 0, 0 },
97 .targetOffset = { 0, 0 },
98 .opacity = 255,
99 .idleAnimations = NULL,
100 .defenseTable = N(DefenseTable),
101 .eventFlags = ACTOR_EVENT_FLAGS_NONE,
102 .elementImmunityFlags = 0,
103 .projectileTargetOffset = { 0, 0 },
104 },
105};
106
111 .maxHP = 99,
112 .partCount = ARRAY_COUNT(N(ActorParts)),
113 .partsData = N(ActorParts),
114 .initScript = &N(EVS_Init),
115 .statusTable = N(StatusTable),
116 .escapeChance = 0,
117 .airLiftChance = 0,
118 .hurricaneChance = 0,
119 .spookChance = 0,
120 .upAndAwayChance = 0,
121 .spinSmashReq = 0,
122 .powerBounceChance = 0,
123 .coinReward = 0,
124 .size = { 44, 40 },
125 .healthBarOffset = { 0, 0 },
126 .statusIconOffset = { -10, 20 },
127 .statusTextOffset = { 10, 20 },
128};
129
134 .maxHP = 99,
135 .partCount = ARRAY_COUNT(N(ActorParts)),
136 .partsData = N(ActorParts),
137 .initScript = &N(EVS_Init),
138 .statusTable = N(StatusTable),
139 .escapeChance = 0,
140 .airLiftChance = 0,
141 .hurricaneChance = 0,
142 .spookChance = 0,
143 .upAndAwayChance = 0,
144 .spinSmashReq = 0,
145 .powerBounceChance = 0,
146 .coinReward = 0,
147 .size = { 44, 40 },
148 .healthBarOffset = { 0, 0 },
149 .statusIconOffset = { -10, 20 },
150 .statusTextOffset = { 10, 20 },
151};
152
153API_CALLABLE(N(IsDemoBattle)) {
154 script->varTable[0] = FALSE;
156 script->varTable[0] = TRUE;
157 }
158
159 return ApiStatus_DONE2;
160}
161
162API_CALLABLE(N(Add1Coin)) {
163 add_coins(1);
164 return ApiStatus_DONE2;
165}
166
167EvtScript N(EVS_Init) = {
168#if VERSION_PAL
172 EndIf
174#endif
183 Call(RandInt, 8, LVar0)
184 Mul(LVar0, 45)
186 Call(RandInt, 8, LVar0)
187 Mul(LVar0, 45)
189 Call(RandInt, 8, LVar0)
190 Mul(LVar0, 45)
193 IfEq(LVar0, TRUE)
198 EndIf
199 Return
200 End
201};
202
203EvtScript N(EVS_Idle) = {
206 Set(LVarE, 0)
207 Set(LVarF, 0)
208 Label(0)
212 // do nothing
216 // no nothing
224 EndIf
226 Mod(LVar0, 45)
227 IfNe(LVar0, 0)
229 Else
231 EndIf
239 // no nothing
247 EndIf
249 Mod(LVar0, 45)
250 IfNe(LVar0, 0)
252 Else
254 EndIf
262 // no nothing
270 EndIf
272 Mod(LVar0, 45)
273 IfNe(LVar0, 0)
275 Else
277 EndIf
283 // wrap angles
284 IfGe(BUF_ReelAngle1, 360)
285 Sub(BUF_ReelAngle1, 360)
286 EndIf
287 IfGe(BUF_ReelAngle2, 360)
288 Sub(BUF_ReelAngle2, 360)
289 EndIf
290 IfGe(BUF_ReelAngle3, 360)
291 Sub(BUF_ReelAngle3, 360)
292 EndIf
294 Add(LVarF, -277)
296 EndIf
298 Add(LVarF, -1110)
300 EndIf
302 Add(LVarF, -3330)
304 EndIf
306 Goto(1)
307 EndIf
309 Goto(1)
310 EndIf
313 Goto(1)
314 EndIf
320 Div(LVar0, 45)
324 Div(LVar0, 45)
328 Div(LVar0, 45)
331 Loop(0)
334 EndIf
337 EndIf
340 EndIf
341 Thread
342 #if !VERSION_PAL
344 #endif
346 Call(SetBattleCamTarget, 0, 100, 0)
352 Loop(10)
354 Call(N(Add1Coin))
355 Wait(1)
357 Call(N(Add1Coin))
358 Wait(1)
360 Call(N(Add1Coin))
361 Wait(10)
362 EndLoop
364 Loop(10)
366 Call(N(Add1Coin))
367 Wait(1)
369 Call(N(Add1Coin))
370 Wait(1)
372 Call(N(Add1Coin))
373 Wait(10)
374 EndLoop
376 Loop(10)
378 Call(N(Add1Coin))
379 Wait(1)
381 Call(N(Add1Coin))
382 Wait(1)
384 Call(N(Add1Coin))
385 Wait(10)
386 EndLoop
392 #if !VERSION_PAL
394 #endif
396 #if VERSION_PAL
397 Wait(75)
400 Wait(30)
401 #endif
404 EndLoop
405 #if VERSION_PAL
407 #endif
408 EndIf
409 Label(1)
410 Wait(1)
411 Goto(0)
412 Return
413 End
414};
415
428 Call(TranslateModel, MODEL_o408, 0, -2, 0)
429 Wait(1)
430 Call(TranslateModel, MODEL_o408, 0, -6, 0)
431 Wait(1)
432 Call(TranslateModel, MODEL_o408, 0, -7, 0)
433 Wait(4)
434 Call(TranslateModel, MODEL_o408, 0, -4, 0)
435 Wait(1)
436 Call(TranslateModel, MODEL_o408, 0, -2, 0)
437 Wait(1)
438 Call(TranslateModel, MODEL_o408, 0, -1, 0)
439 Wait(1)
446 Call(TranslateModel, MODEL_o409, 0, -2, 0)
447 Wait(1)
448 Call(TranslateModel, MODEL_o409, 0, -6, 0)
449 Wait(1)
450 Call(TranslateModel, MODEL_o409, 0, -7, 0)
451 Wait(4)
452 Call(TranslateModel, MODEL_o409, 0, -4, 0)
453 Wait(1)
454 Call(TranslateModel, MODEL_o409, 0, -2, 0)
455 Wait(1)
456 Call(TranslateModel, MODEL_o409, 0, -1, 0)
457 Wait(1)
460#if VERSION_PAL
462#endif
463 Set(BUF_ReelLeft1, 100)
464 Set(BUF_ReelLeft2, 150)
465 Set(BUF_ReelLeft3, 200)
469 EndIf
471 Call(TranslateModel, MODEL_o409, 0, -2, 0)
472 Wait(1)
473 Call(TranslateModel, MODEL_o409, 0, -6, 0)
474 Wait(1)
475 Call(TranslateModel, MODEL_o409, 0, -7, 0)
476 Wait(4)
477 Call(TranslateModel, MODEL_o409, 0, -4, 0)
478 Wait(1)
479 Call(TranslateModel, MODEL_o409, 0, -2, 0)
480 Wait(1)
481 Call(TranslateModel, MODEL_o409, 0, -1, 0)
482 Wait(1)
485#if VERSION_PAL
487#endif
488 Set(BUF_ReelLeft1, 150)
489 Set(BUF_ReelLeft2, 100)
490 Set(BUF_ReelLeft3, 200)
494 EndIf
496 Call(TranslateModel, MODEL_o409, 0, -2, 0)
497 Wait(1)
498 Call(TranslateModel, MODEL_o409, 0, -6, 0)
499 Wait(1)
500 Call(TranslateModel, MODEL_o409, 0, -7, 0)
501 Wait(4)
502 Call(TranslateModel, MODEL_o409, 0, -4, 0)
503 Wait(1)
504 Call(TranslateModel, MODEL_o409, 0, -2, 0)
505 Wait(1)
506 Call(TranslateModel, MODEL_o409, 0, -1, 0)
507 Wait(1)
510#if VERSION_PAL
512#endif
513 Set(BUF_ReelLeft1, 200)
514 Set(BUF_ReelLeft2, 150)
515 Set(BUF_ReelLeft3, 100)
519 EndIf
529 // do nothing
533 // do nothing
537 Return
538 End
539};
540
543 // do nothing
544 Return
545 End
546};
BSS s32 PopupMenu_SelectedIndex
Bytecode EvtScript[]
#define MODEL_o409
#define MODEL_o421
#define MODEL_o419
#define MODEL_o418
#define MODEL_o412
#define MODEL_o417
#define MODEL_o413
#define MODEL_o423
#define MODEL_o422
@ TEX_PANNER_MAIN
Definition enums.h:4414
@ TEX_PANNER_B
Definition enums.h:4408
@ LANGUAGE_ES
Definition enums.h:6402
@ LANGUAGE_FR
Definition enums.h:6401
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_NORMAL
Definition enums.h:2115
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3542
@ ACTOR_EVENT_FLAGS_NONE
Definition enums.h:3370
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ALWAYS_SMALL
Definition enums.h:2317
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_TURN_MOD_DEFAULT
Definition enums.h:2227
@ STATUS_TURN_MOD_PARALYZE
Definition enums.h:2234
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_TURN_MOD_SLEEP
Definition enums.h:2228
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2232
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_END
Definition enums.h:2196
@ STATUS_TURN_MOD_POISON
Definition enums.h:2233
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_TURN_MOD_STOP
Definition enums.h:2237
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_TURN_MOD_FROZEN
Definition enums.h:2230
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_TURN_MOD_STATIC
Definition enums.h:2229
@ STATUS_TURN_MOD_FEAR
Definition enums.h:2231
@ STATUS_KEY_NORMAL
Definition enums.h:2197
@ STATUS_TURN_MOD_SHRINK
Definition enums.h:2235
@ STATUS_KEY_DEFAULT
Definition enums.h:2198
@ BTL_CAM_DEFAULT
Definition enums.h:4823
@ BTL_CAM_REPOSITION
Definition enums.h:4840
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_INVISIBLE
Actor is not rendered.
Definition enums.h:3324
@ ACTOR_FLAG_NO_SHADOW
Hide shadow.
Definition enums.h:3325
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3334
@ ACTOR_FLAG_NO_HEALTH_BAR
Definition enums.h:3337
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3339
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_BURN_HIT
Definition enums.h:2136
@ EVENT_SPIKE_CONTACT
Definition enums.h:2163
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_BURN_DEATH
Definition enums.h:2157
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_SHOCK_DEATH
Definition enums.h:2159
@ EVENT_SPIN_SMASH_HIT
Definition enums.h:2133
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2154
@ EVENT_HIT_COMBO
Definition enums.h:2131
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_SHOCK_HIT
Definition enums.h:2165
@ EVENT_BURN_CONTACT
Definition enums.h:2164
@ ACTOR_PART_FLAG_PRIMARY_TARGET
Definition enums.h:3362
#define ApiStatus_DONE2
Definition evt.h:118
#define MODEL_o424
#define MODEL_o414
#define MODEL_o408
s32 add_coins(s32 amt)
Definition inventory.c:2076
ApiStatus TranslateModel(Evt *script, b32 isInitialCall)
Translates the given model's position.
ApiStatus RotateModel(Evt *script, b32 isInitialCall)
Rotates the model the given amount on the selected axis.
ApiStatus SetTexPanOffset(Evt *script, b32 isInitialCall)
Sets offsets for texture panners.
ApiStatus SetModelTexVariant(Evt *script, b32 isInitialCall)
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus EnableTexPanning(Evt *script, b32 isInitialCall)
Enables or disables texture panning on the given model.
#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 Ref(sym)
Address/pointer constant.
Definition macros.h:60
#define Mul(VAR, INT_VALUE)
Definition macros.h:378
#define IfGe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR >= RVAR.
Definition macros.h:284
#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 Sub(VAR, INT_VALUE)
Definition macros.h:377
#define LVarF
Definition macros.h:163
#define IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:272
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define UseBuf(INT_PTR)
Loads a s32 pointer for use with subsequent EVT_BUF_READ commands.
Definition macros.h:389
#define Mod(VAR, INT_VALUE)
Definition macros.h:380
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define EndLoop
Marks the end of a loop.
Definition macros.h:248
#define EndCaseGroup
Marks the end of a switch case group (CaseOrEq and/or CaseAndEq), stopping fallthrough.
Definition macros.h:352
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define BSS
Definition macros.h:7
#define LVarC
Definition macros.h:160
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define CaseOrEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR.
Definition macros.h:341
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVarB
Definition macros.h:159
#define BreakLoop
Breaks out of the innermost loop.
Definition macros.h:251
#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 UseArray(INT_PTR)
Loads an s32 array pointer into the current thread for use with ArrayVar(INDEX).
Definition macros.h:425
#define Div(VAR, INT_VALUE)
Definition macros.h:379
#define BreakSwitch
Marks the end of a switch case.
Definition macros.h:359
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define BufPeek(OFFSET, VAR)
Gets the s32 at the given offset of the buffer and stores it in the given variable,...
Definition macros.h:404
#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 Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVarE
Definition macros.h:162
#define LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
#define BUF_ReelState1
#define SYM_SHYGUY
#define BUF_ReelAngle1
#define BUF_ReelState3
#define BUF_ReelLeft1
#define BUF_ReelAngle2
#define SYM_STAR
#define BUF_ReelAngle3
#define BUF_ReelLeft3
#define BUF_ReelLeft2
#define BUF_ReelState2
#define SYM_COIN
#define BUF_GameState
GameStatus * gGameStatusPtr
Definition main_loop.c:32