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

Go to the source code of this file.

Functions

void entity_StarBoxLauncher_setupGfx (s32 entityIndex)
 
void entity_StarBoxLauncher_check_launch (Entity *entity)
 
void entity_StarBoxLauncher_update_face_anim (Entity *entity)
 
void entity_StarBoxLauncher_shake_box (Entity *entity)
 
void entity_StarBoxLauncher_restore_pos (Entity *entity)
 
void entity_StarBoxLauncher_launch (Entity *entity)
 
void func_802BC99C_E312EC (Entity *entity)
 
void entity_StarBoxLauncher_start_script (Entity *entity)
 
void entity_StarBoxLauncher_init (Entity *entity)
 

Variables

Gfx Entity_StarBoxLauncher_RenderBottom []
 
Gfx Entity_StarBoxLauncher_RenderTop []
 
unsigned char D_0A000D08_E56748 []
 
unsigned char D_0A000508_E55F48 []
 
u8 D_802BCAA0_E313F0 []
 
EntityScript Entity_StarBoxLauncher_Script
 
EntityModelScript Entity_StarBoxLauncher_RenderScript = STANDARD_ENTITY_MODEL_SCRIPT(Entity_StarBoxLauncher_RenderTop, RENDER_MODE_SURFACE_OPA)
 
EntityBlueprint Entity_StarBoxLauncher
 

Function Documentation

◆ entity_StarBoxLauncher_setupGfx()

void entity_StarBoxLauncher_setupGfx ( s32 entityIndex)

Definition at line 32 of file StarBoxLauncher.c.

32 {
33 Gfx* gfxPos = gMainGfxPos;
34 Entity* entity = get_entity_by_index(entityIndex);
36 Matrix4f sp10;
37 Matrix4f sp50;
38
39 guMtxIdentF(sp10);
40 guTranslateF(sp50, entity->pos.x, data->basePosY, entity->pos.z);
41 guMtxCatF(sp50, sp10, sp50);
43 gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
44 gSPDisplayList(gfxPos++, ENTITY_ADDR(entity, Gfx*, Entity_StarBoxLauncher_RenderBottom));
45 gSPPopMatrix(gfxPos++, G_MTX_MODELVIEW);
46
47 gDPPipeSync(gfxPos++);
48 gDPSetTextureLUT(gfxPos++, G_TT_RGBA16);
49 gDPLoadTLUT_pal16(gfxPos++, 0, D_0A000D08_E56748);
50 gSPTexture(gfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
51 gDPSetCombineMode(gfxPos++, G_CC_MODULATEIA, G_CC_MODULATEIA);
52 gDPSetTextureDetail(gfxPos++, G_TD_CLAMP);
53 gDPSetTextureLOD(gfxPos++, G_TL_TILE);
54 gDPLoadTextureBlock_4b(gfxPos++, D_0A000508_E55F48, G_IM_FMT_CI, 128, 32, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 7, 5, G_TX_NOLOD, G_TX_NOLOD);
55 gDPSetTexturePersp(gfxPos++, G_TP_PERSP);
56 gDPSetTextureFilter(gfxPos++, G_TF_BILERP);
57 gDPSetTileSize(gfxPos++, G_TX_RENDERTILE, data->faceTexOffset * 4, 0, (data->faceTexOffset + 124) * 4, 31 * 4);
58
59 gMainGfxPos = gfxPos;
60}
struct StarBoxLauncherData * starBoxLauncher
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define ENTITY_ADDR(entity, type, data)
Definition entity.h:64
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
unsigned char D_0A000508_E55F48[]
unsigned char D_0A000D08_E56748[]
Gfx Entity_StarBoxLauncher_RenderBottom[]
EntityData dataBuf
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by entity_StarBoxLauncher_init().

◆ entity_StarBoxLauncher_check_launch()

void entity_StarBoxLauncher_check_launch ( Entity * entity)

Definition at line 62 of file StarBoxLauncher.c.

62 {
63 u16 currentFloor = gCollisionStatus.curFloor;
65 PlayerStatus* playerStatus = &gPlayerStatus;
66 s32 actionState = playerStatus->actionState;
67 f32 x,y,z,hitDepth;
68 s32 result = 0;
69
70 if ((currentFloor & COLLISION_WITH_ENTITY_BIT) && (currentFloor & 0xFF) == entity->listIndex && actionState == ACTION_STATE_HAMMER) {
71 x = playerStatus->pos.x;
72 y = playerStatus->pos.y + 5.0f;
73 z = playerStatus->pos.z;
74 hitDepth = 10.0f;
75
76 add_vec2D_polar(&x, &z, 10.0f, player_get_side_angle());
77 if (npc_raycast_down_sides(COLLIDER_FLAG_IGNORE_PLAYER, &x, &y, &z, &hitDepth) != 0) {
80 }
81 }
82 } else if ((entity->collisionFlags & ENTITY_COLLISION_PLAYER_TOUCH_FLOOR) && (actionState == ACTION_STATE_SPIN_POUND || actionState == ACTION_STATE_TORNADO_POUND)) {
83 result = 1;
85 result = -1;
86 }
87
88 if (result != 0) {
89 data->flags &= ~1;
90 fx_damage_stars(FX_DAMAGE_STARS_3, entity->pos.x, entity->pos.y + 35.0f, entity->pos.z, 0, -1.0f, 0, 3);
91 if (result > 0) {
92 data->flags |= 1;
93 }
94 entity->pos.y -= 2.0f;
96 data->timer = 4;
98 playerStatus->camResetDelay = 5;
99 }
100}
#define npc_raycast_down_sides
@ FX_DAMAGE_STARS_3
Definition effects.h:359
@ COLLIDER_FLAG_IGNORE_PLAYER
Definition enums.h:4696
@ ENTITY_TYPE_STAR_BOX_LAUNCHER
Definition enums.h:2586
@ ENTITY_COLLISION_PLAYER_HAMMER
Definition enums.h:2654
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ ACTION_STATE_HAMMER
Definition enums.h:2446
s32 disable_player_static_collisions(void)
Definition 77480.c:972
f32 player_get_side_angle(void)
Definition 7BB60.c:1178
u32 get_entity_type(s32 arg0)
Definition entity.c:568
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
u8 collisionFlags
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
s32 NpcHitQueryColliderID
PlayerStatus gPlayerStatus
Definition 77480.c:39
void fx_damage_stars(s32, f32, f32, f32, f32, f32, f32, s32)

◆ entity_StarBoxLauncher_update_face_anim()

void entity_StarBoxLauncher_update_face_anim ( Entity * entity)

Definition at line 102 of file StarBoxLauncher.c.

102 {
104 s32 i;
105
106 data->faceAnimTimer--;
107 if (data->faceAnimTimer <= 0) {
108 i = data->faceDataIndex;
109 if (D_802BCAA0_E313F0[i] != 0xFF) {
110 data->faceTexOffset = D_802BCAA0_E313F0[i++];
111 data->faceAnimTimer = D_802BCAA0_E313F0[i++];
112 data->faceDataIndex = i;
113 }
114 }
115}
u8 D_802BCAA0_E313F0[]

Referenced by entity_StarBoxLauncher_launch().

◆ entity_StarBoxLauncher_shake_box()

void entity_StarBoxLauncher_shake_box ( Entity * entity)

Definition at line 117 of file StarBoxLauncher.c.

117 {
119 entity->pos.x = data->basePosX + (data->timer & 1 ? 1.0f : -1.0f);
120 data->timer--;
121}

◆ entity_StarBoxLauncher_restore_pos()

void entity_StarBoxLauncher_restore_pos ( Entity * entity)

Definition at line 123 of file StarBoxLauncher.c.

123 {
125 entity->pos.x = data->basePosX;
126 entity->pos.z = data->basePosZ;
127}

◆ entity_StarBoxLauncher_launch()

void entity_StarBoxLauncher_launch ( Entity * entity)

Definition at line 129 of file StarBoxLauncher.c.

129 {
131 f64 temp;
132
133 switch (data->state) {
134 case 0:
135 data->faceAnimTimer = 0;
136 data->faceDataIndex = 0;
137 data->state++;
138 data->riseSpeedPhase = 90.0f;
142 // fallthrough
143 case 1:
144 temp = entity->pos.y;
145 entity->pos.y = temp + 8.0 * sin_rad(DEG_TO_RAD(data->riseSpeedPhase));
146 data->riseSpeedPhase += 2.0f;
147 if (data->riseSpeedPhase >= 180.0f) {
148 data->riseSpeedPhase = 180.0f;
149 }
150
151 if (entity->pos.y > data->basePosY + 50.0f) {
152 entity->pos.y = data->basePosY + 50.0f;
153 data->maxRotZ = 2.0f;
154 data->state++;
155 data->riseVel = 3.0f;
156 data->rotZPhase = 90.0f;
157 }
158 break;
159 case 2:
160 entity->rot.z = data->maxRotZ * sin_rad(DEG_TO_RAD(data->rotZPhase));
161 clamp_angle(entity->rot.z);
162 data->rotZPhase += 30.0f;
163 if (data->rotZPhase >= 360.0f) {
164 data->rotZPhase -= 360.0f;
165 }
166
167 entity->pos.y += data->riseVel * cos_rad(DEG_TO_RAD(data->riseSpeedPhase));
168 data->riseSpeedPhase += 30.0f;
169 if (data->riseSpeedPhase >= 360.0f) {
170 data->riseSpeedPhase -= 360.0f;
171 }
172
173 data->riseVel -= 0.08;
174 if (data->riseVel < 2.8) {
175 data->state++;
176 }
177 break;
178 case 3:
179 data->maxRotZ -= 0.1;
180 if (data->maxRotZ <= 0.0f) {
181 data->maxRotZ = 0.0f;
182 }
183
184 entity->rot.z = data->maxRotZ * sin_rad(DEG_TO_RAD(data->rotZPhase));
185 clamp_angle(entity->rot.z);
186 data->rotZPhase += 30.0f;
187 if (data->rotZPhase >= 360.0f) {
188 data->rotZPhase -= 360.0f;
189 }
190
192
193 entity->pos.y += data->riseVel * cos_rad(DEG_TO_RAD(data->riseSpeedPhase));
194 data->riseSpeedPhase += 30.0f;
195 if (data->riseSpeedPhase >= 360.0f) {
196 data->riseSpeedPhase -= 360.0f;
197 }
198
199 data->riseVel -= 0.08;
200 if (data->riseVel <= 0.0f) {
201 data->riseVel = 0.0f;
202 data->timer = 8;
203 data->state++;
204 entity->rot.z = 0.0f;
205 }
206 break;
207 case 4:
208 if (--data->timer == 0) {
209 data->state++;
210 }
211 break;
212 case 5:
213 entity->pos.y -= 8.0f;
214 if (entity->pos.y <= data->basePosY) {
215 entity->pos.y = data->basePosY;
216 data->state++;
217 }
218 break;
219 case 6:
221 data->state = 0;
223 break;
224 }
225}
#define clamp_angle
@ SOUND_STAR_BOX_LAUNCHER
Definition enums.h:1426
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 sin_rad(f32 x)
Definition 43F0.c:713
s32 enable_player_static_collisions(void)
Definition 77480.c:980
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
void entity_StarBoxLauncher_update_face_anim(Entity *entity)
#define DEG_TO_RAD(deg)
Definition macros.h:134

◆ func_802BC99C_E312EC()

void func_802BC99C_E312EC ( Entity * entity)

Definition at line 227 of file StarBoxLauncher.c.

227 {
228 if (!(entity->flags & ENTITY_FLAG_2000000)) {
230 }
231}
@ ENTITY_FLAG_2000000
Definition enums.h:2638

◆ entity_StarBoxLauncher_start_script()

void entity_StarBoxLauncher_start_script ( Entity * entity)

Definition at line 233 of file StarBoxLauncher.c.

233 {
235 if (data->flags & 1) {
236 entity_start_script(entity);
237 }
238}
s32 entity_start_script(Entity *entity)
Definition entity.c:560

◆ entity_StarBoxLauncher_init()

void entity_StarBoxLauncher_init ( Entity * entity)

Definition at line 240 of file StarBoxLauncher.c.

240 {
243 data->basePosX = entity->pos.x;
244 data->basePosY = entity->pos.y;
245 data->basePosZ = entity->pos.z;
246}
void entity_StarBoxLauncher_setupGfx(s32 entityIndex)
void(* renderSetupFunc)(s32)

Variable Documentation

◆ Entity_StarBoxLauncher_RenderBottom

Gfx Entity_StarBoxLauncher_RenderBottom[]
extern

Definition at line 120 of file StarBoxLauncher.c.

120 {
121 gsSPDisplayList(Entity_StarBoxLauncher_RenderBox),
122 gsSPEndDisplayList(),
123};
Gfx Entity_StarBoxLauncher_RenderBox[]

Referenced by entity_StarBoxLauncher_setupGfx().

◆ Entity_StarBoxLauncher_RenderTop

Gfx Entity_StarBoxLauncher_RenderTop[]
extern

Definition at line 98 of file StarBoxLauncher.c.

98 {
99 gsSPDisplayList(Entity_StarBoxLauncher_RenderFace),
101 gsSPDisplayList(Entity_StarBoxLauncher_RenderChain),
102 gsSPEndDisplayList(),
103};
Gfx Entity_StarBoxLauncher_RenderChain[]
Gfx Entity_StarBoxLauncher_RenderFace[]
Gfx Entity_StarBoxLauncher_RenderBoxCover[]

◆ D_0A000D08_E56748

unsigned char D_0A000D08_E56748[]
extern

◆ D_0A000508_E55F48

unsigned char D_0A000508_E55F48[]
extern

◆ D_802BCAA0_E313F0

u8 D_802BCAA0_E313F0[]
Initial value:
= {
0x00, 0x02,
0xE0, 0x02,
0xC0, 0x02,
0xA0, 0x02,
0x00, 0x02,
0xE0, 0x02,
0xC0, 0x02,
0xA0, 0x02,
0x00, 0x02,
0xE0, 0x02,
0xC0, 0x02,
0xA0, 0x02,
0x00, 0x02,
0xE0, 0x02,
0xC0, 0x02,
0xA0, 0x02,
0x00, 0x02,
0xFF, 0x00
}

Definition at line 11 of file StarBoxLauncher.c.

11 {
12 0x00, 0x02,
13 0xE0, 0x02,
14 0xC0, 0x02,
15 0xA0, 0x02,
16 0x00, 0x02,
17 0xE0, 0x02,
18 0xC0, 0x02,
19 0xA0, 0x02,
20 0x00, 0x02,
21 0xE0, 0x02,
22 0xC0, 0x02,
23 0xA0, 0x02,
24 0x00, 0x02,
25 0xE0, 0x02,
26 0xC0, 0x02,
27 0xA0, 0x02,
28 0x00, 0x02,
29 0xFF, 0x00
30};

Referenced by entity_StarBoxLauncher_launch(), and entity_StarBoxLauncher_update_face_anim().

◆ Entity_StarBoxLauncher_Script

EntityScript Entity_StarBoxLauncher_Script
Initial value:
= {
es_SetCallback(NULL, 3)
es_SetCallback(NULL, 1)
}
#define es_Call(func)
Definition entity.h:37
#define es_Restart
Definition entity.h:40
#define es_SetCallback(func, time)
Definition entity.h:38
#define es_End
Definition entity.h:35
void entity_StarBoxLauncher_shake_box(Entity *entity)
void func_802BC99C_E312EC(Entity *entity)
void entity_StarBoxLauncher_launch(Entity *entity)
void entity_StarBoxLauncher_start_script(Entity *entity)
void entity_StarBoxLauncher_restore_pos(Entity *entity)
void entity_StarBoxLauncher_check_launch(Entity *entity)

Definition at line 248 of file StarBoxLauncher.c.

◆ Entity_StarBoxLauncher_RenderScript

◆ Entity_StarBoxLauncher

EntityBlueprint Entity_StarBoxLauncher
Initial value:
= {
.flags = ENTITY_FLAG_8000,
.typeDataSize = sizeof(StarBoxLauncherData),
.modelAnimationNodes = 0,
.updateEntityScript = Entity_StarBoxLauncher_Script,
.fpHandleCollision = NULL,
{ .dma = ENTITY_ROM(StarBoxLauncher) },
.aabbSize = { 35, 35, 35 }
}
#define ENTITY_ROM(name)
Definition entity.h:65
@ ENTITY_FLAG_8000
Definition enums.h:2628
void entity_StarBoxLauncher_init(Entity *entity)
EntityModelScript Entity_StarBoxLauncher_RenderScript
EntityScript Entity_StarBoxLauncher_Script

Definition at line 263 of file StarBoxLauncher.c.

263 {
264 .flags = ENTITY_FLAG_8000,
265 .typeDataSize = sizeof(StarBoxLauncherData),
266 .renderCommandList = Entity_StarBoxLauncher_RenderScript,
267 .modelAnimationNodes = 0,
269 .updateEntityScript = Entity_StarBoxLauncher_Script,
270 .fpHandleCollision = NULL,
271 { .dma = ENTITY_ROM(StarBoxLauncher) },
272 .entityType = ENTITY_TYPE_STAR_BOX_LAUNCHER,
273 .aabbSize = { 35, 35, 35 }
274};