Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
BlueWarpPipe.c File Reference

Go to the source code of this file.

Functions

void entity_BlueWarpPipe_setupGfx (s32 entityIndex)
 
void entity_BlueWarpPipe_check_if_active (Entity *entity)
 
void entity_BlueWarpPipe_rise_up (Entity *entity)
 
void entity_BlueWarpPipe_wait_for_player_to_get_off (Entity *entity)
 
void entity_BlueWarpPipe_idle (Entity *entity)
 
void entity_BlueWarpPipe_set_player_move_to_center (Entity *entity)
 
void entity_BlueWarpPipe_wait_player_move_to_center (Entity *entity)
 
void entity_BlueWarpPipe_enter_pipe_init (Entity *bluePipe)
 
void entity_BlueWarpPipe_enter_pipe_update (Entity *entity)
 
void entity_BlueWarpPipe_start_bound_script (Entity *entity)
 
void entity_init_BlueWarpPipe (Entity *entity)
 

Variables

Gfx Entity_BlueWarpPipe_RenderPipe []
 
Gfx Entity_BlueWarpPipe_RenderBase []
 
EntityScript Entity_BlueWarpPipe_Script
 
EntityModelScript Entity_BlueWarpPipe_RenderScript = STANDARD_ENTITY_MODEL_SCRIPT(Entity_BlueWarpPipe_RenderPipe, RENDER_MODE_SURFACE_OPA)
 
EntityBlueprint Entity_BlueWarpPipe
 

Function Documentation

◆ entity_BlueWarpPipe_setupGfx()

void entity_BlueWarpPipe_setupGfx ( s32 entityIndex)

Definition at line 153 of file BlueWarpPipe.c.

153 {
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}
Gfx Entity_BlueWarpPipe_RenderBase[]
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
struct BlueWarpPipeData * bluePipe
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
EntityData dataBuf
Vec3f scale
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by entity_init_BlueWarpPipe().

◆ entity_BlueWarpPipe_check_if_active()

void entity_BlueWarpPipe_check_if_active ( Entity * entity)

Definition at line 19 of file BlueWarpPipe.c.

19 {
20 BlueWarpPipeData* pipeData;
21
22 pipeData = entity->dataBuf.bluePipe;
23 if (get_global_flag(pipeData->flagIndex)) {
24 pipeData->timer = 16;
26 }
27}
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
s32 get_global_flag(s32 index)
Definition vars_access.c:89

◆ entity_BlueWarpPipe_rise_up()

void entity_BlueWarpPipe_rise_up ( Entity * entity)

Definition at line 29 of file BlueWarpPipe.c.

29 {
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}

◆ entity_BlueWarpPipe_wait_for_player_to_get_off()

void entity_BlueWarpPipe_wait_for_player_to_get_off ( Entity * entity)

Definition at line 41 of file BlueWarpPipe.c.

41 {
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}
#define NO_COLLIDER
Definition macros.h:156
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
GameStatus * gGameStatusPtr
Definition main_loop.c:32

◆ entity_BlueWarpPipe_idle()

void entity_BlueWarpPipe_idle ( Entity * entity)

Definition at line 65 of file BlueWarpPipe.c.

65 {
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}
#define atan2
@ PS_FLAG_NO_STATIC_COLLISION
Definition enums.h:3051
@ PS_FLAG_INPUT_DISABLED
Definition enums.h:3052
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
u8 collisionFlags
s32 gOverrideFlags
Definition main_loop.c:11
PlayerStatus gPlayerStatus
Definition 77480.c:39

◆ entity_BlueWarpPipe_set_player_move_to_center()

void entity_BlueWarpPipe_set_player_move_to_center ( Entity * entity)

Definition at line 86 of file BlueWarpPipe.c.

86 {
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}
s32 disable_player_input(void)
Definition 77480.c:990
s32 disable_player_static_collisions(void)
Definition 77480.c:972
void move_player(s32 duration, f32 heading, f32 speed)
Definition 7BB60.c:57
f32 get_xz_dist_to_player(f32, f32)
Definition 77480.c:960
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

◆ entity_BlueWarpPipe_wait_player_move_to_center()

void entity_BlueWarpPipe_wait_player_move_to_center ( Entity * entity)

Definition at line 109 of file BlueWarpPipe.c.

109 {
110 BlueWarpPipeData* pipeData = entity->dataBuf.bluePipe;
111
112 if (--pipeData->timer == -1) {
114 }
115}

◆ entity_BlueWarpPipe_enter_pipe_init()

void entity_BlueWarpPipe_enter_pipe_init ( Entity * bluePipe)

Definition at line 117 of file BlueWarpPipe.c.

117 {
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}
@ IMGFX_SET_ANIM
Definition enums.h:5122
@ IMGFX_ANIM_VERTICAL_PIPE_CURL
Definition enums.h:5140
@ SOUND_ENTER_PIPE
Definition enums.h:785
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
void disable_player_shadow(void)
Definition 77480.c:968
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
void set_player_imgfx_all(s32 animID, ImgFXType imgfxType, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
Definition sprite.c:995
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4

◆ entity_BlueWarpPipe_enter_pipe_update()

void entity_BlueWarpPipe_enter_pipe_update ( Entity * entity)

Definition at line 130 of file BlueWarpPipe.c.

130 {
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}
@ IMGFX_CLEAR
Definition enums.h:5117

◆ entity_BlueWarpPipe_start_bound_script()

void entity_BlueWarpPipe_start_bound_script ( Entity * entity)

Definition at line 145 of file BlueWarpPipe.c.

145 {
146 EvtScript* triggerScriptStart = entity->dataBuf.bluePipe->onEnterPipeEvt;
147
148 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
149 entity->boundScriptBytecode = triggerScriptStart;
150 entity_start_script(entity);
151}
Bytecode EvtScript[]
EvtScript * onEnterPipeEvt
Definition entity.h:217
s32 entity_start_script(Entity *entity)
Definition entity.c:560
EvtScript * boundScriptBytecode

◆ entity_init_BlueWarpPipe()

void entity_init_BlueWarpPipe ( Entity * entity)

Definition at line 170 of file BlueWarpPipe.c.

170 {
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}
void entity_BlueWarpPipe_setupGfx(s32 entityIndex)
s32 CreateEntityVarArgBuffer[]
Definition entity.c:35
void(* renderSetupFunc)(s32)

Variable Documentation

◆ Entity_BlueWarpPipe_RenderPipe

Gfx Entity_BlueWarpPipe_RenderPipe[]
extern

Definition at line 57 of file BlueWarpPipe.c.

57 {
58 gsDPPipeSync(),
59 gsSPTexture(0x0080, 0x0080, 0, G_TX_RENDERTILE, G_OFF),
60 gsSPClearGeometryMode(G_LIGHTING),
61 gsSPSetGeometryMode(G_CULL_BACK | G_SHADING_SMOOTH),
62 gsSPVertex(D_0A000000_E58CD0, 6, 0),
63 gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
64 gsSP2Triangles(0, 3, 4, 0, 0, 4, 5, 0),
66 gsSPVertex(D_0A000060_E58D30, 30, 0),
67 gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
68 gsSP2Triangles(4, 5, 1, 0, 4, 1, 0, 0),
69 gsSP2Triangles(3, 2, 6, 0, 3, 6, 7, 0),
70 gsSP2Triangles(8, 9, 7, 0, 8, 7, 6, 0),
71 gsSP2Triangles(10, 11, 12, 0, 10, 12, 13, 0),
72 gsSP2Triangles(13, 12, 14, 0, 13, 14, 15, 0),
73 gsSP2Triangles(15, 14, 16, 0, 15, 16, 17, 0),
74 gsSP2Triangles(17, 16, 18, 0, 17, 18, 19, 0),
75 gsSP2Triangles(20, 21, 5, 0, 20, 5, 4, 0),
76 gsSP2Triangles(9, 8, 21, 0, 9, 21, 20, 0),
77 gsSP2Triangles(22, 23, 24, 0, 22, 24, 25, 0),
78 gsSP2Triangles(25, 24, 26, 0, 25, 26, 27, 0),
79 gsSP2Triangles(27, 26, 28, 0, 27, 28, 29, 0),
80 gsSPVertex(&D_0A000060_E58D30[10], 2, 0),
81 gsSPVertex(&D_0A000060_E58D30[22], 2, 2),
82 gsSPVertex(&D_0A000060_E58D30[30], 10, 4),
83 gsSP2Triangles(4, 9, 10, 0, 4, 10, 6, 0),
84 gsSP2Triangles(5, 11, 9, 0, 5, 9, 4, 0),
85 gsSP2Triangles(6, 10, 3, 0, 6, 3, 2, 0),
86 gsSP2Triangles(7, 12, 13, 0, 7, 13, 8, 0),
87 gsSP2Triangles(8, 13, 1, 0, 8, 1, 0, 0),
88 gsSPEndDisplayList(),
89};
Gfx Entity_BlueWarpPipe_LoadTexturePipe[]

◆ Entity_BlueWarpPipe_RenderBase

Gfx Entity_BlueWarpPipe_RenderBase[]
extern

Definition at line 47 of file BlueWarpPipe.c.

47 {
48 gsDPPipeSync(),
50 gsSPClearGeometryMode(G_LIGHTING | G_SHADING_SMOOTH),
51 gsSPClearGeometryMode(G_CULL_BACK),
52 gsSPVertex(D_0A0002E0_E58FB0, 4, 0),
53 gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
54 gsSPEndDisplayList(),
55};
Gfx Entity_BlueWarpPipe_LoadTextureBase[]

Referenced by entity_BlueWarpPipe_setupGfx().

◆ Entity_BlueWarpPipe_Script

EntityScript Entity_BlueWarpPipe_Script
Initial value:
= {
}
void entity_BlueWarpPipe_start_bound_script(Entity *entity)
void entity_BlueWarpPipe_wait_player_move_to_center(Entity *entity)
void entity_BlueWarpPipe_idle(Entity *entity)
void entity_BlueWarpPipe_enter_pipe_update(Entity *entity)
void entity_BlueWarpPipe_check_if_active(Entity *entity)
void entity_BlueWarpPipe_wait_for_player_to_get_off(Entity *entity)
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)
#define es_Call(func)
Definition entity.h:37
#define es_SetCallback(func, time)
Definition entity.h:38
#define es_End
Definition entity.h:35

Definition at line 188 of file BlueWarpPipe.c.

◆ Entity_BlueWarpPipe_RenderScript

◆ Entity_BlueWarpPipe

EntityBlueprint Entity_BlueWarpPipe
Initial value:
= {
.flags = 0,
.typeDataSize = sizeof(BlueWarpPipeData),
.renderCommandList = Entity_BlueWarpPipe_RenderScript,
.modelAnimationNodes = 0,
.updateEntityScript = Entity_BlueWarpPipe_Script,
.fpHandleCollision = NULL,
{ .dma = ENTITY_ROM(BlueWarpPipe) },
.aabbSize = { 40, 50, 40}
}
EntityModelScript Entity_BlueWarpPipe_RenderScript
void entity_init_BlueWarpPipe(Entity *entity)
EntityScript Entity_BlueWarpPipe_Script
#define ENTITY_ROM(name)
Definition entity.h:65
@ ENTITY_TYPE_BLUE_WARP_PIPE
Definition enums.h:2582

Definition at line 203 of file BlueWarpPipe.c.

203 {
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};