Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
enter_exit.c
Go to the documentation of this file.
1#include "common.h"
2#include "../partners.h"
3
4extern s32 DoorModelsSwingCCW[3];
5extern s32 DoorModelsSwingCW[3];
6
7API_CALLABLE(CheckUsingRideablePartner) {
9
10 script->varTable[10] = 0;
13 script->varTable[10] = 0;
14 } else {
15 script->varTable[10] = 1;
16 script->varTablePtr[11] = partner_get_enter_map_script();
17 script->varTable[13] = playerStatus->targetYaw;
18 }
19 }
20 return ApiStatus_DONE2;
21}
22
23API_CALLABLE(TeleportPartnerToPlayer) {
25 Npc* partner;
26
28 return ApiStatus_DONE2;
29 }
30
32 partner->pos.x = playerStatus->pos.x;
33 partner->pos.z = playerStatus->pos.z;
34
35 if (partner_is_flying()) {
36 partner->pos.y = playerStatus->pos.y;
37 }
38
39 set_npc_yaw(partner, playerStatus->targetYaw);
41 return ApiStatus_DONE2;
42}
43
48
52
55 f32 angle = clamp_angle((playerStatus->spriteFacingAngle < 180.0f) ? (90.0f) : (-90.0f));
56
57 partner->pos.x = playerStatus->pos.x;
58 partner->pos.y = playerStatus->pos.y;
59 partner->pos.z = playerStatus->pos.z;
60 add_vec2D_polar(&partner->pos.x, &partner->pos.z, playerStatus->colliderDiameter + 5, angle);
62 }
63
64 camera->needsReinit = TRUE;
65 return ApiStatus_DONE2;
66}
67
68API_CALLABLE(EnterPlayerPostPipe) {
72
73 if (isInitialCall) {
74 playerStatus->pos.x = (*mapSettings->entryList)[gGameStatusPtr->entryID].x;
75 playerStatus->pos.z = (*mapSettings->entryList)[gGameStatusPtr->entryID].z;
76 script->varTable[2] = (*mapSettings->entryList)[gGameStatusPtr->entryID].y;
77 playerStatus->pos.y = script->varTable[2] - 40;
79 } else {
80 playerStatus->pos.y += 1.0f;
81 if (!(playerStatus->pos.y < script->varTable[2])) {
82 playerStatus->pos.y = script->varTable[2];
85 }
86 }
90 return ret;
91}
92
93API_CALLABLE(ShortenPartnerTetherDistance) {
95 return ApiStatus_DONE2;
96}
97
98API_CALLABLE(ResetPartnerTetherDistance) {
100 return ApiStatus_DONE2;
101}
102
103API_CALLABLE(PlayerMoveToDoor) {
104 Bytecode* args = script->ptrReadPos;
106
107 if (isInitialCall) {
108 script->functionTemp[0] = evt_get_variable(script, *args++);
109 move_player(script->functionTemp[0], playerStatus->targetYaw, playerStatus->runSpeed);
110 }
111
112 script->functionTemp[0]--;
113 if (script->functionTemp[0] < 0) {
114 return ApiStatus_DONE1;
115 } else {
116 return ApiStatus_BLOCK;
117 }
118}
119
120API_CALLABLE(GetEntryCoords) {
121 Bytecode* args = script->ptrReadPos;
123 Vec4f* entryList = (Vec4f*)mapSettings->entryList;
124 s32 index = evt_get_variable(script, *args++);
125
126 evt_set_variable(script, *args++, entryList[index].x);
127 evt_set_variable(script, *args++, entryList[index].y);
128 evt_set_variable(script, *args++, entryList[index].z);
129 evt_set_variable(script, *args++, entryList[index].yaw);
130
131 return ApiStatus_DONE2;
132}
133
134API_CALLABLE(SetupSingleDoor) {
135 if (script->varTable[3] >= 0) {
136 DoorModelsSwingCCW[0] = script->varTable[2];
137 DoorModelsSwingCCW[1] = -1;
138 DoorModelsSwingCW[0] = -1;
139 } else {
140 DoorModelsSwingCW[0] = script->varTable[2];
141 DoorModelsSwingCW[1] = -1;
142 DoorModelsSwingCCW[0] = -1;
143 }
144
145 script->varTablePtr[2] = &DoorModelsSwingCCW;
146 script->varTablePtr[3] = &DoorModelsSwingCW;
147
148 return ApiStatus_DONE2;
149}
150
151API_CALLABLE(SetupSplitSingleDoor) {
152 if (script->varTable[3] >= 0) {
153 DoorModelsSwingCCW[0] = script->varTable[2];
154 DoorModelsSwingCCW[1] = script->varTable[4];
155 DoorModelsSwingCCW[2] = -1;
156 DoorModelsSwingCW[0] = -1;
157 } else {
158 DoorModelsSwingCW[0] = script->varTable[2];
159 DoorModelsSwingCW[1] = script->varTable[4];
160 DoorModelsSwingCW[2] = -1;
161 DoorModelsSwingCCW[0] = -1;
162 }
163
164 script->varTablePtr[2] = &DoorModelsSwingCCW;
165 script->varTablePtr[3] = &DoorModelsSwingCW;
166
167 return ApiStatus_DONE2;
168}
169
170API_CALLABLE(SetupDoubleDoors) {
171 DoorModelsSwingCCW[0] = script->varTable[2];
172 DoorModelsSwingCCW[1] = -1;
173
174 DoorModelsSwingCW[0] = script->varTable[3];
175 DoorModelsSwingCW[1] = -1;
176
177 script->varTablePtr[3] = &DoorModelsSwingCW;
178 script->varTablePtr[2] = &DoorModelsSwingCCW;
179
180 return ApiStatus_DONE2;
181}
182
183API_CALLABLE(SetupSplitDoubleDoors) {
184 DoorModelsSwingCCW[0] = script->varTable[2];
185 DoorModelsSwingCCW[1] = script->varTable[4];
186 DoorModelsSwingCCW[2] = -1;
187
188 DoorModelsSwingCW[0] = script->varTable[3];
189 DoorModelsSwingCW[1] = script->varTable[5];
190 DoorModelsSwingCW[2] = -1;
191
192 script->varTablePtr[3] = &DoorModelsSwingCW;
193 script->varTablePtr[2] = &DoorModelsSwingCCW;
194
195 return ApiStatus_DONE2;
196}
197
219
241
262
273
282
299
306
313
320
327
334
341
348
355
405
410 Loop(0)
412 IfEq(LVarA, -1)
414 EndIf
415 Call(RotateModel, LVarA, -80, 0, 1, 0)
416 EndLoop
418 Loop(0)
420 IfEq(LVarA, -1)
422 EndIf
423 Call(RotateModel, LVarA, -80, 0, -1, 0)
424 EndLoop
428 IfEq(LVarA, 0)
431 Else
432 Set(LVar0, 1)
433 Set(LVarC, 1)
434 Set(LVar4, 15)
436 EndIf
437 Thread
438 Wait(8)
441 Call(MakeLerp, -80, 0, 10, EASING_LINEAR)
442 Label(0)
445 Loop(0)
447 IfEq(LVarA, -1)
449 EndIf
450 Call(RotateModel, LVarA, LVar0, 0, 1, 0)
451 EndLoop
453 Loop(0)
455 IfEq(LVarA, -1)
457 EndIf
458 Call(RotateModel, LVarA, LVar0, 0, -1, 0)
459 EndLoop
460 Wait(1)
461 IfNe(LVar1, 0)
462 Goto(0)
463 EndIf
466 Return
467 End
468};
BSS s32 PopupMenu_SelectedIndex
Bytecode EvtScript[]
#define clamp_angle
EvtScript ExitSplitSingleDoor
Definition enter_exit.c:314
EvtScript EnterSingleDoor
Definition enter_exit.c:307
EvtScript EnterSplitDoubleDoor
Definition enter_exit.c:349
EvtScript ExitWalk
Definition enter_exit.c:283
EvtScript EnterSplitSingleDoor
Definition enter_exit.c:321
EvtScript ExitSplitDoubleDoor
Definition enter_exit.c:342
EvtScript EnterDoubleDoor
Definition enter_exit.c:335
s32 DoorModelsSwingCW[3]
Definition script_list.c:66
EvtScript EnterSavePoint
Definition enter_exit.c:274
s32 DoorModelsSwingCCW[3]
Definition script_list.c:67
EvtScript ExitDoubleDoor
Definition enter_exit.c:328
EvtScript EnterWalk
Definition enter_exit.c:198
EvtScript ExitSingleDoor
Definition enter_exit.c:300
EvtScript BaseEnterDoor
Definition enter_exit.c:406
EvtScript BaseExitDoor
Definition enter_exit.c:356
EvtScript EnterWalkCustom
Definition enter_exit.c:242
EvtScript EnterWalkShort
Definition enter_exit.c:220
EvtScript EnterPostPipe
Definition enter_exit.c:263
@ PS_FLAG_CAMERA_DOESNT_FOLLOW
Definition enums.h:3075
@ COLLIDER_FLAGS_UPPER_MASK
Definition enums.h:4691
@ NPC_PARTNER
Definition enums.h:2528
@ EASING_LINEAR
Definition enums.h:510
@ SOUND_DOOR_CLOSE
Definition enums.h:1694
@ SOUND_DOOR_OPEN
Definition enums.h:1693
@ PARTNER_NONE
Definition enums.h:2885
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
s32 ApiStatus
Definition evt.h:115
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1689
void partner_clear_player_tracking(Npc *partner)
Definition partners.c:2436
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1846
void move_player(s32 duration, f32 heading, f32 speed)
Definition 7BB60.c:57
s32 partner_is_flying(void)
Definition partners.c:572
void enable_partner_ai(void)
Definition partners.c:2390
EvtScript * partner_get_enter_map_script(void)
Definition partners.c:1058
void partner_set_tether_distance(f32)
Definition partners.c:2401
void partner_reset_tether_distance(void)
Definition partners.c:2405
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:684
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:994
void set_npc_yaw(Npc *npc, f32 yaw)
Definition npc.c:1245
ApiStatus ClearPartnerMoveHistory(Evt *script, b32 isInitialCall)
ApiStatus func_802D2148(Evt *script, b32 isInitialCall)
ApiStatus UseEntryHeading(Evt *script, b32 isInitialCall)
ApiStatus RotateModel(Evt *script, b32 isInitialCall)
Rotates the model the given amount on the selected axis.
ApiStatus DisablePlayerInput(Evt *script, b32 isInitialCall)
Disables player and partner input, and disables the status menu.
ApiStatus UpdateLerp(Evt *script, b32 isInitialCall)
ApiStatus UseExitHeading(Evt *script, b32 isInitialCall)
ApiStatus PlayerMoveTo(Evt *script, b32 isInitialCall)
ApiStatus DisablePlayerPhysics(Evt *script, b32 isInitialCall)
Disables player physics if disable is TRUE, enables it if FALSE.
ApiStatus MakeLerp(Evt *script, b32 isInitialCall)
ApiStatus InterpPlayerYaw(Evt *script, b32 isInitialCall)
ApiStatus ModifyColliderFlags(Evt *script, b32 isInitialCall)
Set flags for collider + siblings + children.
ApiStatus PlaySoundAt(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 Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#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 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 LVarC
Definition macros.h:160
#define BufRead1(VAR)
Consumes the next s32 from the buffer and stores it in the given variable.
Definition macros.h:392
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVarB
Definition macros.h:159
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define LVar7
Definition macros.h:155
#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 LVar8
Definition macros.h:156
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define LVarD
Definition macros.h:161
#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 LVarE
Definition macros.h:162
#define LVar0
Definition macros.h:148
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:455
#define Return
Kills the current EVT thread.
Definition macros.h:217
MapSettings * get_current_map_settings(void)
Definition world.c:224
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:18
Vec3f targetPos
PartnerStatus gPartnerStatus
Definition partners.c:42
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
PlayerData gPlayerData
Definition 77480.c:40
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4