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

Go to the source code of this file.

Functions

void entity_Padlock_setupGfx (s32 entityIndex)
 
void entity_Padlock_push_player (Entity *entity)
 
void entity_Padlock_idle (Entity *entity)
 
void entity_Padlock_init (Entity *entity)
 
void entity_PadlockRedFrame_init (Entity *entity)
 
void entity_PadlockRedFace_init (Entity *entity)
 
void entity_PadlockBlueFace_init (Entity *entity)
 

Variables

Gfx Entity_Padlock_Render []
 
Gfx Entity_Padlock_RenderShackle []
 
Mtx Entity_Padlock_mtxShackle
 
Gfx Entity_PadlockRedFrame_Render []
 
Gfx Entity_PadlockRedFrame_RenderShackle []
 
Mtx Entity_PadlockRedFrame_mtxShackle
 
Gfx Entity_PadlockRedFace_Render []
 
Gfx Entity_PadlockRedFace_RenderShackle []
 
Mtx Entity_PadlockRedFace_mtxShackle
 
Gfx Entity_PadlockBlueFace_Render []
 
Gfx Entity_PadlockBlueFace_RenderShackle []
 
Mtx Entity_PadlockBlueFace_mtxShackle
 
EntityScript Entity_Padlock_Script
 
EntityModelScript Entity_Padlock_RenderScript = STANDARD_ENTITY_MODEL_SCRIPT(Entity_Padlock_Render, RENDER_MODE_SURFACE_OPA)
 
EntityModelScript Entity_PadlockRedFrame_RenderScript = STANDARD_ENTITY_MODEL_SCRIPT(Entity_PadlockRedFrame_Render, RENDER_MODE_SURFACE_OPA)
 
EntityModelScript Entity_PadlockRedFace_RenderScript = STANDARD_ENTITY_MODEL_SCRIPT(Entity_PadlockRedFace_Render, RENDER_MODE_SURFACE_OPA)
 
EntityModelScript Entity_PadlockBlueFace_RenderScript = STANDARD_ENTITY_MODEL_SCRIPT(Entity_PadlockBlueFace_Render, RENDER_MODE_SURFACE_OPA)
 
EntityBlueprint Entity_Padlock
 
EntityBlueprint Entity_PadlockRedFrame
 
EntityBlueprint Entity_PadlockRedFace
 
EntityBlueprint Entity_PadlockBlueFace
 

Function Documentation

◆ entity_Padlock_setupGfx()

void entity_Padlock_setupGfx ( s32 entityIndex)

Definition at line 20 of file Padlock.c.

20 {
21 Entity* entity = get_entity_by_index(entityIndex);
22 PadlockData* data = entity->dataBuf.padlock;
23 Matrix4f sp18;
24 Matrix4f sp58;
25 Matrix4f sp98;
26 Matrix4f spD8;
27
28 guMtxIdentF(sp58);
29 guMtxL2F(sp98, data->shackleMtx);
30 guMtxCatF(sp58, sp98, sp98);
31 sp98[3][0] += data->shacklePos;
32 guRotateF(spD8, entity->rot.x, -1.0f, 0.0f, 0.0f);
33 guMtxCatF(spD8, sp98, sp98);
34 guRotateF(spD8, entity->rot.z, 0.0f, 0.0f, 1.0f);
35 guRotateF(sp18, entity->rot.x, 1.0f, 0.0f, 0.0f);
36 guMtxCatF(spD8, sp18, sp18);
37 guRotateF(spD8, entity->rot.y, 0.0f, 1.0f, 0.0f);
38 guMtxCatF(sp18, spD8, spD8);
39 guMtxCatF(sp98, spD8, sp98);
40 guScaleF(sp18, entity->scale.x, entity->scale.y, entity->scale.z);
41 guMtxCatF(sp98, sp18, sp18);
42 guTranslateF(sp58, entity->pos.x, entity->pos.y, entity->pos.z);
43 guMtxCatF(sp18, sp58, sp58);
45
46 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
47 gSPDisplayList(gMainGfxPos++, data->shackleGfx);
48 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
49}
struct PadlockData * padlock
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
Gfx * shackleGfx
Definition entity.h:263
Mtx * shackleMtx
Definition entity.h:262
f32 shacklePos
Definition entity.h:255
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_Padlock_init(), entity_PadlockBlueFace_init(), entity_PadlockRedFace_init(), and entity_PadlockRedFrame_init().

◆ entity_Padlock_push_player()

void entity_Padlock_push_player ( Entity * entity)

Definition at line 51 of file Padlock.c.

51 {
52 PlayerStatus* playerStatus = &gPlayerStatus;
53 PadlockData* data = entity->dataBuf.padlock;
54 f32 deltaX, deltaZ;
55
56 if (playerStatus->colliderHeight < fabs(playerStatus->pos.y - entity->pos.y)) {
58 } else {
59 entity->flags &= ~ENTITY_FLAG_DISABLE_COLLISION;
60 }
61
63 if (data->pushSpeed == 0.0f) {
65 }
66
67 data->pushSpeed += 0.5;
68
69 if (data->pushSpeed >= 2.5) {
70 data->pushSpeed = 2.5f;
71 }
72
73 deltaX = data->pushSpeed * sin_rad(DEG_TO_RAD(180.0f - entity->rot.y));
74 deltaZ = data->pushSpeed * cos_rad(DEG_TO_RAD(180.0f - entity->rot.y));
75
76 playerStatus->pos.x += deltaX;
77 playerStatus->pos.z -= deltaZ;
78 } else {
79 data->pushSpeed = 0.0f;
80 }
81}
f32 pushSpeed
Definition entity.h:254
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ ENTITY_FLAG_DISABLE_COLLISION
Definition enums.h:2618
f64 fabs(f64 f)
f32 cos_rad(f32 x)
Definition 43F0.c:717
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
f32 sin_rad(f32 x)
Definition 43F0.c:713
#define DEG_TO_RAD(deg)
Definition macros.h:134
u8 collisionFlags
PlayerStatus gPlayerStatus
Definition 77480.c:39

Referenced by entity_Padlock_idle().

◆ entity_Padlock_idle()

void entity_Padlock_idle ( Entity * entity)

Definition at line 83 of file Padlock.c.

83 {
84 PadlockData* data = entity->dataBuf.padlock;
85
86 switch (data->state) {
87 case 0:
89 if (entity->flags & ENTITY_FLAG_USED) {
90 data->state++;
92 }
93 break;
94 case 1:
95 data->shacklePos += 5.0f;
96 if (data->shacklePos >= 20.0f) {
97 data->shacklePos = 20.0f;
98 data->state++;
99 entity->rot.z += 12.0;
100 data->fallSpeed = -2.0f;
101 data->rotSpeed = 0.2f;
102 }
103 break;
104 case 2:
105 data->rotSpeed += 0.2;
106 entity->rot.x += data->rotSpeed;
107
108 data->fallSpeed -= 1.0;
109 entity->pos.y += data->fallSpeed;
110
111 if (entity->pos.y <= entity->shadowPosY) {
112 entity->pos.y = entity->shadowPosY;
113 data->fallSpeed = 5.0f;
114 data->rotSpeed = 3.0f;
115 data->state++;
116 fx_sparkles(FX_SPARKLES_0, entity->pos.x, entity->pos.y + 25.0f, entity->pos.z, 10.0f);
118 }
119 break;
120 case 3:
121 data->rotSpeed += 0.2;
122 entity->rot.x += data->rotSpeed;
123
124 data->fallSpeed -= 2.0;
125 entity->pos.y += data->fallSpeed;
126
127 if (entity->pos.y <= entity->shadowPosY) {
128 entity->pos.y = entity->shadowPosY;
129 data->timer = 2;
130 data->fallSpeed = 10.0f;
131 data->rotSpeed = 0.2f;
132 data->state++;
134 }
135 break;
136 case 4:
137 if (--data->timer <= 0) {
138 data->state++;
139 }
140 break;
141 case 5:
142 data->rotSpeed *= 2.0f;
143 if (data->rotSpeed > 30.0f) {
144 data->rotSpeed = 30.0f;
145 }
146 entity->rot.x += data->rotSpeed;
147 if (entity->rot.x >= 90.0) {
148 entity->rot.x = 90.0f;
149 data->rotSpeed = -20.0f;
150 data->state++;
152 }
153 break;
154 case 6:
155 data->rotSpeed += 10.0f;
156 if (data->rotSpeed > 30.0f) {
157 data->rotSpeed = 30.0f;
158 }
159 entity->rot.x += data->rotSpeed;
160 if (entity->rot.x >= 90.0) {
161 entity->rot.x = 90.0f;
162 data->timer = 5;
163 data->state++;
165 }
166 break;
167 case 7:
168 if (--data->timer <= 0) {
169 data->state++;
170 entity_start_script(entity);
171 data->timer = 5;
172 }
173 break;
174 case 8:
175 if (--data->timer <= 0) {
176 data->state++;
179 }
180 break;
181 }
182
183 if (data->state == 2 || data->state == 3 || data->state == 4 || data->state == 5 || data->state == 6 || data->state == 7 || data->state == 8) {
184 data->blinkCounter++;
185 if (data->blinkCounter & 1) {
186 entity->flags |= ENTITY_FLAG_HIDDEN;
187 } else {
188 entity->flags &= ~ENTITY_FLAG_HIDDEN;
189 }
190 }
191}
void entity_Padlock_push_player(Entity *entity)
Definition Padlock.c:51
@ FX_SPARKLES_0
Definition effects.h:234
u8 blinkCounter
Definition entity.h:258
f32 fallSpeed
Definition entity.h:256
f32 rotSpeed
Definition entity.h:257
@ SOUND_USE_KEY
Definition enums.h:983
@ SOUND_LOCK_DROP
Definition enums.h:984
@ ENTITY_FLAG_HIDDEN
Definition enums.h:2613
@ ENTITY_FLAG_USED
Definition enums.h:2633
s32 entity_start_script(Entity *entity)
Definition entity.c:560
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void sfx_play_sound(s32 soundID)
Definition sfx.c:517

◆ entity_Padlock_init()

void entity_Padlock_init ( Entity * entity)

Definition at line 193 of file Padlock.c.

193 {
194 PadlockData* data;
195
197 data = entity->dataBuf.padlock;
198 data->shackleMtx = ENTITY_ADDR(entity, Mtx*, &Entity_Padlock_mtxShackle);
200}
Gfx Entity_Padlock_RenderShackle[]
Definition Padlock.c:77
void entity_Padlock_setupGfx(s32 entityIndex)
Definition Padlock.c:20
Mtx Entity_Padlock_mtxShackle
Definition Padlock.c:54
#define ENTITY_ADDR(entity, type, data)
Definition entity.h:64
void(* renderSetupFunc)(s32)

◆ entity_PadlockRedFrame_init()

void entity_PadlockRedFrame_init ( Entity * entity)

Definition at line 202 of file Padlock.c.

202 {
203 PadlockData* data;
204
206 data = entity->dataBuf.padlock;
209}
Gfx Entity_PadlockRedFrame_RenderShackle[]
Mtx Entity_PadlockRedFrame_mtxShackle

◆ entity_PadlockRedFace_init()

void entity_PadlockRedFace_init ( Entity * entity)

Definition at line 211 of file Padlock.c.

211 {
212 PadlockData* data;
213
215 data = entity->dataBuf.padlock;
218}
Gfx Entity_PadlockRedFace_RenderShackle[]
Mtx Entity_PadlockRedFace_mtxShackle

◆ entity_PadlockBlueFace_init()

void entity_PadlockBlueFace_init ( Entity * entity)

Definition at line 220 of file Padlock.c.

220 {
221 PadlockData* data;
222
224 data = entity->dataBuf.padlock;
227}
Gfx Entity_PadlockBlueFace_RenderShackle[]
Mtx Entity_PadlockBlueFace_mtxShackle

Variable Documentation

◆ Entity_Padlock_Render

Gfx Entity_Padlock_Render[]
extern

Definition at line 167 of file Padlock.c.

167 {
168 gsSPDisplayList(Entity_Padlock_RenderBody),
169 gsSPDisplayList(Entity_Padlock_RenderFace),
170 gsSPDisplayList(Entity_Padlock_RenderKeyhole),
171 gsSPEndDisplayList(),
172};
Gfx Entity_Padlock_RenderFace[]
Definition Padlock.c:94
Gfx Entity_Padlock_RenderKeyhole[]
Definition Padlock.c:82
Gfx Entity_Padlock_RenderBody[]
Definition Padlock.c:107

◆ Entity_Padlock_RenderShackle

Gfx Entity_Padlock_RenderShackle[]
extern

Definition at line 77 of file Padlock.c.

77 {
78 gsSPDisplayList(Entity_Padlock_RenderShackleMain),
79 gsSPEndDisplayList(),
80};
Gfx Entity_Padlock_RenderShackleMain[]
Definition Padlock.c:61

Referenced by entity_Padlock_init().

◆ Entity_Padlock_mtxShackle

Mtx Entity_Padlock_mtxShackle
extern

Definition at line 54 of file Padlock.c.

Referenced by entity_Padlock_init().

◆ Entity_PadlockRedFrame_Render

Gfx Entity_PadlockRedFrame_Render[]
extern

Definition at line 152 of file PadlockRedFrame.c.

152 {
153 gsSPDisplayList(Entity_PadlockRedFrame_RenderMain),
155 gsSPEndDisplayList(),
156};
Gfx Entity_PadlockRedFrame_RenderShackle[]
Gfx Entity_PadlockRedFrame_RenderMain[]

◆ Entity_PadlockRedFrame_RenderShackle

Gfx Entity_PadlockRedFrame_RenderShackle[]
extern

Definition at line 95 of file PadlockRedFrame.c.

95 {
97 gsSPEndDisplayList(),
98};
Gfx Entity_PadlockRedFrame_RenderShackleMain[]

Referenced by entity_PadlockRedFrame_init().

◆ Entity_PadlockRedFrame_mtxShackle

Mtx Entity_PadlockRedFrame_mtxShackle
extern

Definition at line 39 of file PadlockRedFrame.c.

Referenced by entity_PadlockRedFrame_init().

◆ Entity_PadlockRedFace_Render

Gfx Entity_PadlockRedFace_Render[]
extern

Definition at line 172 of file PadlockRedFace.c.

172 {
173 gsSPDisplayList(Entity_PadlockRedFace_RenderMain),
175 gsSPEndDisplayList(),
176};
Gfx Entity_PadlockRedFace_RenderShackle[]
Gfx Entity_PadlockRedFace_RenderMain[]

◆ Entity_PadlockRedFace_RenderShackle

Gfx Entity_PadlockRedFace_RenderShackle[]
extern

Definition at line 75 of file PadlockRedFace.c.

75 {
77 gsSPEndDisplayList(),
78};
Gfx Entity_PadlockRedFace_RenderShackleMain[]

Referenced by entity_PadlockRedFace_init().

◆ Entity_PadlockRedFace_mtxShackle

Mtx Entity_PadlockRedFace_mtxShackle
extern

Definition at line 52 of file PadlockRedFace.c.

Referenced by entity_PadlockRedFace_init().

◆ Entity_PadlockBlueFace_Render

Gfx Entity_PadlockBlueFace_Render[]
extern

Definition at line 172 of file PadlockBlueFace.c.

172 {
173 gsSPDisplayList(Entity_PadlockBlueFace_RenderMain),
175 gsSPEndDisplayList(),
176};
Gfx Entity_PadlockBlueFace_RenderShackle[]
Gfx Entity_PadlockBlueFace_RenderMain[]

◆ Entity_PadlockBlueFace_RenderShackle

Gfx Entity_PadlockBlueFace_RenderShackle[]
extern

Definition at line 75 of file PadlockBlueFace.c.

75 {
77 gsSPEndDisplayList(),
78};
Gfx Entity_PadlockBlueFace_RenderShackleMain[]

Referenced by entity_PadlockBlueFace_init().

◆ Entity_PadlockBlueFace_mtxShackle

Mtx Entity_PadlockBlueFace_mtxShackle
extern

Definition at line 52 of file PadlockBlueFace.c.

Referenced by entity_PadlockBlueFace_init().

◆ Entity_Padlock_Script

EntityScript Entity_Padlock_Script
Initial value:
= {
}
void entity_Padlock_idle(Entity *entity)
Definition Padlock.c:83
#define es_SetCallback(func, time)
Definition entity.h:38
#define es_SetFlags(flags)
Definition entity.h:43
#define es_End
Definition entity.h:35
@ ENTITY_FLAG_PENDING_INSTANCE_DELETE
Definition enums.h:2642

Definition at line 229 of file Padlock.c.

◆ Entity_Padlock_RenderScript

◆ Entity_PadlockRedFrame_RenderScript

Definition at line 236 of file Padlock.c.

◆ Entity_PadlockRedFace_RenderScript

Definition at line 237 of file Padlock.c.

◆ Entity_PadlockBlueFace_RenderScript

Definition at line 238 of file Padlock.c.

◆ Entity_Padlock

EntityBlueprint Entity_Padlock
Initial value:
= {
.typeDataSize = sizeof(PadlockData),
.renderCommandList = Entity_Padlock_RenderScript,
.modelAnimationNodes = 0,
.updateEntityScript = Entity_Padlock_Script,
.fpHandleCollision = NULL,
{ .dma = ENTITY_ROM(Padlock) },
.entityType = ENTITY_TYPE_PADLOCK,
.aabbSize = { 30, 175, 10 }
}
EntityScript Entity_Padlock_Script
Definition Padlock.c:229
EntityModelScript Entity_Padlock_RenderScript
Definition Padlock.c:235
void entity_Padlock_init(Entity *entity)
Definition Padlock.c:193
#define ENTITY_ROM(name)
Definition entity.h:65
@ ENTITY_TYPE_PADLOCK
Definition enums.h:2546
@ ENTITY_FLAG_HAS_SHADOW
Definition enums.h:2621
@ ENTITY_FLAG_400
Definition enums.h:2623
@ ENTITY_FLAG_SHOWS_INSPECT_PROMPT
Definition enums.h:2625

Definition at line 240 of file Padlock.c.

240 {
242 .typeDataSize = sizeof(PadlockData),
243 .renderCommandList = Entity_Padlock_RenderScript,
244 .modelAnimationNodes = 0,
245 .fpInit = entity_Padlock_init,
246 .updateEntityScript = Entity_Padlock_Script,
247 .fpHandleCollision = NULL,
248 { .dma = ENTITY_ROM(Padlock) },
249 .entityType = ENTITY_TYPE_PADLOCK,
250 .aabbSize = { 30, 175, 10 }
251};

◆ Entity_PadlockRedFrame

EntityBlueprint Entity_PadlockRedFrame
Initial value:
= {
.typeDataSize = sizeof(PadlockData),
.modelAnimationNodes = 0,
.updateEntityScript = Entity_Padlock_Script,
.fpHandleCollision = NULL,
{ .dma = ENTITY_ROM(PadlockRedFrame) },
.aabbSize = { 30, 175, 10 }
}
EntityModelScript Entity_PadlockRedFrame_RenderScript
Definition Padlock.c:236
void entity_PadlockRedFrame_init(Entity *entity)
Definition Padlock.c:202
@ ENTITY_TYPE_PADLOCK_RED_FRAME
Definition enums.h:2547

Definition at line 253 of file Padlock.c.

253 {
255 .typeDataSize = sizeof(PadlockData),
256 .renderCommandList = Entity_PadlockRedFrame_RenderScript,
257 .modelAnimationNodes = 0,
259 .updateEntityScript = Entity_Padlock_Script,
260 .fpHandleCollision = NULL,
261 { .dma = ENTITY_ROM(PadlockRedFrame) },
262 .entityType = ENTITY_TYPE_PADLOCK_RED_FRAME,
263 .aabbSize = { 30, 175, 10 }
264};

◆ Entity_PadlockRedFace

EntityBlueprint Entity_PadlockRedFace
Initial value:
= {
.typeDataSize = sizeof(PadlockData),
.renderCommandList = Entity_PadlockRedFace_RenderScript,
.modelAnimationNodes = 0,
.updateEntityScript = Entity_Padlock_Script,
.fpHandleCollision = NULL,
{ .dma = ENTITY_ROM(PadlockRedFace) },
.aabbSize = { 30, 175, 10 }
}
void entity_PadlockRedFace_init(Entity *entity)
Definition Padlock.c:211
EntityModelScript Entity_PadlockRedFace_RenderScript
Definition Padlock.c:237
@ ENTITY_TYPE_PADLOCK_RED_FACE
Definition enums.h:2548

Definition at line 266 of file Padlock.c.

266 {
268 .typeDataSize = sizeof(PadlockData),
269 .renderCommandList = Entity_PadlockRedFace_RenderScript,
270 .modelAnimationNodes = 0,
272 .updateEntityScript = Entity_Padlock_Script,
273 .fpHandleCollision = NULL,
274 { .dma = ENTITY_ROM(PadlockRedFace) },
275 .entityType = ENTITY_TYPE_PADLOCK_RED_FACE,
276 .aabbSize = { 30, 175, 10 }
277 };

◆ Entity_PadlockBlueFace

EntityBlueprint Entity_PadlockBlueFace
Initial value:
= {
.typeDataSize = sizeof(PadlockData),
.modelAnimationNodes = 0,
.updateEntityScript = Entity_Padlock_Script,
.fpHandleCollision = NULL,
{ .dma = ENTITY_ROM(PadlockBlueFace) },
.aabbSize = { 30, 175, 10 }
}
void entity_PadlockBlueFace_init(Entity *entity)
Definition Padlock.c:220
EntityModelScript Entity_PadlockBlueFace_RenderScript
Definition Padlock.c:238
@ ENTITY_TYPE_PADLOCK_BLUE_FACE
Definition enums.h:2549

Definition at line 279 of file Padlock.c.

279 {
281 .typeDataSize = sizeof(PadlockData),
282 .renderCommandList = Entity_PadlockBlueFace_RenderScript,
283 .modelAnimationNodes = 0,
285 .updateEntityScript = Entity_Padlock_Script,
286 .fpHandleCollision = NULL,
287 { .dma = ENTITY_ROM(PadlockBlueFace) },
288 .entityType = ENTITY_TYPE_PADLOCK_BLUE_FACE,
289 .aabbSize = { 30, 175, 10 }
290};