Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
BlueWarpPipe.c
Go to the documentation of this file.
1#include "common.h"
2#include "vars_access.h"
3#include "npc.h"
4#include "sprite.h"
5#include "ld_addrs.h"
6#include "entity.h"
7#include "sprite/player.h"
8
9#if VERSION_JP // TODO remove once segments are split
10extern Addr entity_model_BlueWarpPipe_ROM_END;
11extern Addr entity_model_BlueWarpPipe_ROM_START;
12#endif
13
16
17void entity_BlueWarpPipe_setupGfx(s32 entityIndex);
18
20 BlueWarpPipeData* pipeData;
21
22 pipeData = entity->dataBuf.bluePipe;
23 if (get_global_flag(pipeData->flagIndex)) {
24 pipeData->timer = 16;
26 }
27}
28
30 BlueWarpPipeData* pipeData = entity->dataBuf.bluePipe;
31
32 pipeData->timer--;
33 if ((pipeData->timer != -1) && !pipeData->isRaised) {
34 entity->pos.y += 2.3125;
35 } else {
36 pipeData->timer = 0;
38 }
39}
40
42 BlueWarpPipeData* pipeData = entity->dataBuf.bluePipe;
43
44 if (pipeData->entryID == gGameStatusPtr->entryID) {
45 switch (pipeData->timer) {
46 case 0:
47 if (gCollisionStatus.curFloor > 0) {
48 pipeData->timer = 1;
49 }
50 break;
51 case 1:
53 pipeData->timer = 2;
54 }
55 break;
56 default:
58 break;
59 }
60 } else {
62 }
63}
64
66 PlayerStatus* playerStatus = &gPlayerStatus;
67
70
71 if (!(playerStatus->flags & (PS_FLAG_NO_STATIC_COLLISION | PS_FLAG_INPUT_DISABLED))) {
72 s32 stickAxisX = abs(playerStatus->stickAxis[0]);
73 s32 stickAxisZ = playerStatus->stickAxis[1];
74
75 if ((stickAxisX != 0) || (stickAxisZ != 0)) {
76 if (atan2(0.0f, 0.0f, stickAxisX, stickAxisZ) < 60.0f) {
78 }
79 }
80 }
81 } else {
82 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
83 }
84}
85
87 PlayerStatus* playerStatus = &gPlayerStatus;
88 BlueWarpPipeData* pipeData = entity->dataBuf.bluePipe;
90 f32 angle;
91 f32 entryX;
92 f32 entryZ;
93
94 entryX = (*mapSettings->entryList)[pipeData->entryID].x;
95 entryZ = (*mapSettings->entryList)[pipeData->entryID].z;
96 pipeData->timer = get_xz_dist_to_player(entryX, entryZ) / playerStatus->runSpeed;
97 if (pipeData->timer == 0) {
98 pipeData->timer = 1;
99 }
100
101 entryX = (*mapSettings->entryList)[pipeData->entryID].x;
102 entryZ = (*mapSettings->entryList)[pipeData->entryID].z;
103 angle = atan2(playerStatus->pos.x, playerStatus->pos.z, entryX, entryZ);
106 move_player(pipeData->timer, angle, playerStatus->runSpeed);
107}
108
110 BlueWarpPipeData* pipeData = entity->dataBuf.bluePipe;
111
112 if (--pipeData->timer == -1) {
114 }
115}
116
118 PlayerStatus* playerStatus = &gPlayerStatus;
119 BlueWarpPipeData* pipeData = bluePipe->dataBuf.bluePipe;
120
121 playerStatus->targetYaw = gCameras[gCurrentCameraID].curYaw + 180.0f;
122 pipeData->timer = 25;
123 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
124
128}
129
131 PlayerStatus* playerStatus = &gPlayerStatus;
132 BlueWarpPipeData* pipeData = entity->dataBuf.bluePipe;
133
134 playerStatus->pos.y--;
135 pipeData->timer--;
136
137 if (pipeData->timer == -1) {
138 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
139 playerStatus->pos.y -= 50.0f;
140 set_player_imgfx_all(ANIM_Mario1_Idle, IMGFX_CLEAR, 0, 0, 0, 0, 0);
142 }
143}
144
146 EvtScript* triggerScriptStart = entity->dataBuf.bluePipe->onEnterPipeEvt;
147
148 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
149 entity->boundScriptBytecode = triggerScriptStart;
150 entity_start_script(entity);
151}
152
153void entity_BlueWarpPipe_setupGfx(s32 entityIndex) {
154 Gfx* gfxPos = gMainGfxPos;
155 Entity* entity = get_entity_by_index(entityIndex);
156 BlueWarpPipeData* data = entity->dataBuf.bluePipe;
157 Matrix4f sp10;
158 Matrix4f sp50;
159
160 guScaleF(sp10, entity->scale.x, entity->scale.y, entity->scale.z);
161 guTranslateF(sp50, entity->pos.x, data->finalPosY + 1.0f, entity->pos.z);
162 guMtxCatF(sp10, sp50, sp50);
164 gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
165 gSPDisplayList(gfxPos++, Entity_BlueWarpPipe_RenderBase);
166 gSPPopMatrix(gfxPos++, G_MTX_MODELVIEW);
167 gMainGfxPos = gfxPos;
168}
169
171 BlueWarpPipeData* data;
172 s32 entryID = CreateEntityVarArgBuffer[0];
173 EvtScript* enterPipeEvt = (EvtScript*)CreateEntityVarArgBuffer[1];
174 s32 flagIndex = CreateEntityVarArgBuffer[2];
175
177
178 data = entity->dataBuf.bluePipe;
179 data->entryID = entryID;
180 data->onEnterPipeEvt = enterPipeEvt;
181 data->flagIndex = flagIndex;
182 data->finalPosY = entity->pos.y;
183 data->isRaised = get_global_flag(data->flagIndex);
184
185 entity->pos.y -= (data->isRaised ? 15.0 : 52.0);
186}
187
200
202
204 .flags = 0,
205 .typeDataSize = sizeof(BlueWarpPipeData),
206 .renderCommandList = Entity_BlueWarpPipe_RenderScript,
207 .modelAnimationNodes = 0,
208 .fpInit = entity_init_BlueWarpPipe,
209 .updateEntityScript = Entity_BlueWarpPipe_Script,
210 .fpHandleCollision = NULL,
211 { .dma = ENTITY_ROM(BlueWarpPipe) },
212 .entityType = ENTITY_TYPE_BLUE_WARP_PIPE,
213 .aabbSize = { 40, 50, 40}
214};
EntityModelScript Entity_BlueWarpPipe_RenderScript
void entity_init_BlueWarpPipe(Entity *entity)
void entity_BlueWarpPipe_start_bound_script(Entity *entity)
Gfx Entity_BlueWarpPipe_RenderPipe[]
void entity_BlueWarpPipe_wait_player_move_to_center(Entity *entity)
EntityBlueprint Entity_BlueWarpPipe
EntityScript Entity_BlueWarpPipe_Script
void entity_BlueWarpPipe_idle(Entity *entity)
void entity_BlueWarpPipe_enter_pipe_update(Entity *entity)
Gfx Entity_BlueWarpPipe_RenderBase[]
void entity_BlueWarpPipe_check_if_active(Entity *entity)
void entity_BlueWarpPipe_wait_for_player_to_get_off(Entity *entity)
void entity_BlueWarpPipe_setupGfx(s32 entityIndex)
void entity_BlueWarpPipe_rise_up(Entity *entity)
void entity_BlueWarpPipe_enter_pipe_init(Entity *bluePipe)
void entity_BlueWarpPipe_set_player_move_to_center(Entity *entity)
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
Bytecode EvtScript[]
struct BlueWarpPipeData * bluePipe
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define atan2
#define guScaleF
s32 CreateEntityVarArgBuffer[]
Definition entity.c:35
s32 EntityModelScript[]
Definition entity.h:7
#define es_Call(func)
Definition entity.h:37
#define STANDARD_ENTITY_MODEL_SCRIPT(gfx, renderMode)
Definition entity.h:56
#define es_SetCallback(func, time)
Definition entity.h:38
EvtScript * onEnterPipeEvt
Definition entity.h:217
#define ENTITY_ROM(name)
Definition entity.h:65
s32 EntityScript[]
Definition entity.h:6
#define es_End
Definition entity.h:35
@ IMGFX_CLEAR
Definition enums.h:5117
@ IMGFX_SET_ANIM
Definition enums.h:5122
@ PS_FLAG_NO_STATIC_COLLISION
Definition enums.h:3051
@ PS_FLAG_INPUT_DISABLED
Definition enums.h:3052
@ IMGFX_ANIM_VERTICAL_PIPE_CURL
Definition enums.h:5140
@ ENTITY_TYPE_BLUE_WARP_PIPE
Definition enums.h:2582
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ SOUND_ENTER_PIPE
Definition enums.h:785
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
s32 disable_player_input(void)
Definition 77480.c:990
s32 entity_start_script(Entity *entity)
Definition entity.c:560
s32 disable_player_static_collisions(void)
Definition 77480.c:972
void move_player(s32 duration, f32 heading, f32 speed)
Definition 7BB60.c:57
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
f32 get_xz_dist_to_player(f32, f32)
Definition 77480.c:960
void disable_player_shadow(void)
Definition 77480.c:968
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define NO_COLLIDER
Definition macros.h:156
MapSettings * get_current_map_settings(void)
Definition world.c:224
EntryList * entryList
Definition map.h:32
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:26
void set_player_imgfx_all(s32 animID, ImgFXType imgfxType, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
Definition sprite.c:995
void(* renderSetupFunc)(s32)
EntityData dataBuf
EvtScript * boundScriptBytecode
Vec3f scale
u8 collisionFlags
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
s32 gOverrideFlags
Definition main_loop.c:11
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16
s32 get_global_flag(s32 index)
Definition vars_access.c:89