Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
BetaFloorPanels.inc.c
Go to the documentation of this file.
1#include "common.h"
2
3// unused early(?) versions of both flippable and breakable floor panels.
4// unlike those fpund in the final game, models and colliders for these panels must be
5// manually set up by the map author. a usable flip panel example is found in tst_13.
6
7extern EvtScript N(EVS_BetaBreakFloor_Touch);
8extern EvtScript N(EVS_BetaPanel_PoundAtop);
9extern EvtScript N(EVS_BetaPanel_PoundNearby);
10
11API_CALLABLE(N(CheckShouldBreakFloor)) {
12 PlayerStatus* playerStatus = &gPlayerStatus;
13 s32* array = script->array;
14 f32 distance = dist2D(playerStatus->pos.x, playerStatus->pos.z, array[2], array[3]);
15
16 script->varTable[0] = 1;
17 if ((playerStatus->actionState != ACTION_STATE_SPIN_POUND)
18 && (playerStatus->actionState != ACTION_STATE_TORNADO_POUND)) {
19 script->varTable[0] = 0;
20 }
21 if (script->array[4] <= distance) {
22 script->varTable[0] = 0;
23 }
24
25 return ApiStatus_DONE2;
26}
27
28API_CALLABLE(N(CheckShouldFlipFloor)) {
29 PlayerStatus* playerStatus = &gPlayerStatus;
30 f32 distance = dist2D(
31 playerStatus->pos.x, playerStatus->pos.z,
32 script->array[2], script->array[4]);
33
34 script->varTable[0] = 0;
35 if (distance < 112.5f) {
36 script->varTable[0] = 2;
37 }
38 if (distance < 37.5f) {
39 script->varTable[0] = 1;
40 }
41
42 return ApiStatus_DONE2;
43}
44
45// breakable panels
46EvtScript N(EVS_BetaBreakFloor_Setup) = {
49 BufRead1(LVar0) // modelID
50 Set(ArrayVar(0), LVar0)
51 BufRead1(LVar0) // colliderID
52 Set(ArrayVar(1), LVar0)
53 BufRead1(LVar0) // posX
54 Set(ArrayVar(2), LVar0)
55 BufRead1(LVar0) // posZ
56 Set(ArrayVar(3), LVar0)
57 BufRead1(LVar0) // radius
58 Set(ArrayVar(4), LVar0)
59 BufRead1(LVar0) // callback event
60 Set(ArrayVar(5), LVar0)
62 BindTrigger(Ref(N(EVS_BetaBreakFloor_Touch)), TRIGGER_FLOOR_TOUCH, ArrayVar(0), 1, 0)
63 Return
64 End
65};
66
67EvtScript N(EVS_BetaBreakFloor_Touch) = {
69 Call(N(CheckShouldBreakFloor))
70 IfEq(LVar0, 0)
71 Return
72 EndIf
73 Loop(5)
75 Call(EnableModel, ArrayVar(1), TRUE)
76 Wait(1)
78 Call(EnableModel, ArrayVar(1), FALSE)
79 Wait(1)
81 IfNe(ArrayVar(5), 0)
83 EndIf
84 Return
85 End
86};
87
88// flippable panels
89EvtScript N(EVS_BetaPanel_Setup) = {
92 BufRead1(LVar1) // modelID
93 Set(ArrayVar(0), LVar1)
94 BufRead1(LVar1) // colliderID
95 Set(ArrayVar(1), LVar1)
96 BufRead1(LVar1) // posX
97 Set(ArrayVar(2), LVar1)
98 BufRead1(LVar1) // posY
99 Set(ArrayVar(3), LVar1)
100 BufRead1(LVar1) // posZ
101 Set(ArrayVar(4), LVar1)
102 BufRead1(LVar1) // itemID
103 Set(ArrayVar(5), LVar1)
105 Label(0)
106 Label(1)
109 Goto(2)
110 EndIf
112 Goto(2)
113 EndIf
114 Wait(1)
115 Goto(0)
116 Label(2)
118 Wait(1)
119 IfNe(LVar2, ArrayVar(3))
120 Goto(2)
121 EndIf
122 Call(N(CheckShouldFlipFloor))
123 IfEq(LVar0, 1)
124 ExecWait(N(EVS_BetaPanel_PoundAtop))
125 EndIf
126 IfEq(LVar0, 2)
127 ExecWait(N(EVS_BetaPanel_PoundNearby))
128 EndIf
129 Label(3)
131 Wait(1)
133 Goto(3)
134 EndIf
136 Goto(3)
137 EndIf
138 Goto(0)
139 Return
140 End
141};
142
143EvtScript N(EVS_BetaPanel_PoundAtop) = {
147 Label(2)
150 Set(LVar5, LVar3)
151 Add(LVar5, LVar0)
154 Wait(1)
155 IfEq(LVar1, 1)
156 Goto(2)
157 EndIf
159 Label(3)
162 Set(LVar5, LVar3)
163 Add(LVar5, LVar0)
166 Wait(1)
167 IfEq(LVar1, 1)
168 Goto(3)
169 EndIf
170 Return
171 End
172};
173
174EvtScript N(EVS_BetaPanel_PoundNearby) = {
177 Set(LVar2, 0)
179 Label(2)
182 Add(LVar2, 45)
183 Call(RotateModel, ArrayVar(0), LVar2, 1, 0, 0)
184 Wait(1)
185 IfEq(LVar1, 1)
186 Goto(2)
187 EndIf
189 Label(3)
192 Add(LVar2, 45)
193 Call(RotateModel, ArrayVar(0), LVar2, 1, 0, 0)
194 Wait(1)
195 IfEq(LVar1, 1)
196 Goto(3)
197 EndIf
198 Return
199 End
200};
Bytecode EvtScript[]
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ALWAYS
Definition enums.h:2294
@ COLLIDER_FLAGS_UPPER_MASK
Definition enums.h:4692
@ EASING_QUADRATIC_IN
Definition enums.h:511
@ EASING_QUADRATIC_OUT
Definition enums.h:514
@ MODIFY_COLLIDER_FLAGS_SET_BITS
Definition enums.h:4705
@ MODIFY_COLLIDER_FLAGS_CLEAR_BITS
Definition enums.h:4706
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_SPIN_JUMP
Definition enums.h:2441
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ ACTION_STATE_TORNADO_JUMP
Definition enums.h:2443
@ TRIGGER_FLOOR_TOUCH
Definition enums.h:2677
#define ApiStatus_DONE2
Definition evt.h:118
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
ApiStatus SetPlayerPos(Evt *script, b32 isInitialCall)
Sets the player position.
ApiStatus EnableModel(Evt *script, b32 isInitialCall)
Enables or disables the given model.
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 UpdateLerp(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerActionState(Evt *script, b32 isInitialCall)
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
ApiStatus UpdateColliderTransform(Evt *script, b32 isInitialCall)
Applies transformation from parent model.
ApiStatus ParentColliderToModel(Evt *script, b32 isInitialCall)
Associates a model with a collider and applies the model's transformation.
ApiStatus MakeLerp(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerPos(Evt *script, b32 isInitialCall)
ApiStatus ModifyColliderFlags(Evt *script, b32 isInitialCall)
Set flags for collider + siblings + children.
#define ArrayVar(INDEX)
User Word.
Definition macros.h:122
#define Ref(sym)
Address/pointer constant.
Definition macros.h:60
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#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 Add(VAR, INT_VALUE)
Definition macros.h:376
#define EndLoop
Marks the end of a loop.
Definition macros.h:248
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define BufRead1(VAR)
Consumes the next s32 from the buffer and stores it in the given variable.
Definition macros.h:392
#define BindTrigger(EVT_SOURCE, TRIGGER, COLLIDER_ID, UNK_A3, TRIGGER_PTR_OUTVAR)
Sets up a script to launch when a particular event is triggered.
Definition macros.h:499
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define MallocArray(SIZE, OUT_PTR_VAR)
Allocates a new array of the given size for use with ArrayVar(INDEX).
Definition macros.h:433
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVar5
Definition macros.h:153
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define UseArray(INT_PTR)
Loads an s32 array pointer into the current thread for use with ArrayVar(INDEX).
Definition macros.h:425
#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 LVar9
Definition macros.h:157
#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 LVar4
Definition macros.h:152
#define LVar3
Definition macros.h:151
#define LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
PlayerStatus gPlayerStatus
Definition 77480.c:39