Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
Plants1.c
Go to the documentation of this file.
1#include "common.h"
2#include "sprite.h"
3#include "entity.h"
4#include "animation_script.h"
5#include "ld_addrs.h"
6#include "model.h"
7#include "sprite/player.h"
8
9extern Gfx Entity_RenderNone[];
17extern Mtx D_0A001098_E9C598;
18extern Gfx D_0A0013B8_E9C8B8[];
19extern Mtx D_0A000B70_E9D470;
20extern Gfx D_0A000D18_E9D618[];
22
25
26void entity_SpinningFlower_setupGfx(s32 entityIndex) {
27 Entity* entity = get_entity_by_index(entityIndex);
29 Gfx* gfxPos = gMainGfxPos;
30 Matrix4f sp18;
31 Matrix4f sp58;
32 Matrix4f sp98;
33 Gfx* gfx;
34
35 guMtxL2F(sp18, ENTITY_ADDR(entity, Mtx*, &D_0A000B70_E9D470));
36 guRotateF(sp58, data->rot.x, 1.0f, 0.0f, 0.0f);
37 guRotateF(sp98, data->rot.z, 0.0f, 0.0f, 1.0f);
38 guMtxCatF(sp58, sp98, sp98);
39 guRotateF(sp58, data->rot.y, 0.0f, 1.0f, 0.0f);
40 guMtxCatF(sp98, sp58, sp58);
41 guMtxCatF(sp58, sp18, sp18);
42 guMtxF2L(sp18, &data->unk_30);
44 gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
45 gfx = ENTITY_ADDR(entity, Gfx*, D_0A000D18_E9D618);
46 gSPDisplayList(gfxPos++, gfx);
47 gSPPopMatrix(gfxPos++, G_MTX_MODELVIEW);
48 gMainGfxPos = gfxPos;
49}
50
66
69 PlayerStatus* playerStatus = &gPlayerStatus;
70
72 switch (data->state) {
73 case 0:
74 data->unk_18 = 0;
75 data->unk_00 = 0;
76 data->state = 1;
77 data->rot.x = 0.0f;
78 data->rot.z = 0.0f;
79 break;
80 case 1:
82 data->spinSpeed += 0.02;
83 if (data->spinSpeed > 2.0) {
84 if (data->spinSpeed > 2.0) {
85 data->spinSpeed -= 0.4;
86 }
87 }
88 } else {
89 data->spinSpeed += 0.8;
90 if (data->spinSpeed > 14.0f) {
91 data->spinSpeed = 14.0f;
92 }
93 }
94 break;
95 }
96
97 data->rot.y = clamp_angle(data->rot.y + data->spinSpeed);
98
100 (playerStatus->animFlags & PA_FLAG_SPINNING) &&
101 fabs(dist2D(entity->pos.x, entity->pos.z, playerStatus->pos.x, playerStatus->pos.z)) < 60.0)
102 {
104 }
105}
106
109
110 func_802BB000_E2D930(entity);
111 data->spinSpeed += 2.0;
112 if (data->spinSpeed > 40.0f) {
113 data->spinSpeed = 40.0f;
114 }
115 data->rot.y = clamp_angle(data->rot.y + data->spinSpeed);
116}
117
120 s32 x, y, z;
121
125 if (!(x | y | z)) {
126 x = entity->pos.x;
127 y = entity->pos.y + 100.0f;
128 z = entity->pos.z;
129 }
130
131 data->goalPos.x = x;
132 data->goalPos.y = y;
133 data->goalPos.z = z;
134 data->state = 0;
136}
137
141
146
147void entity_PinkFlowerLight_setupGfx(s32 entityIndex) {
148 Entity* entity = get_entity_by_index(entityIndex);
149 PinkFlowerData* data = entity->dataBuf.pinkFlower;
150 Gfx* gfxPos = gMainGfxPos;
151 Matrix4f sp18;
152 Matrix4f sp58;
153 f32 sinAngle, cosAngle;
154
155 guRotateF(sp58, entity->rot.y, 0.0f, 1.0f, 0.0f);
156 guScaleF(sp18, entity->scale.x, entity->scale.x, entity->scale.x);
157 guMtxCatF(sp18, sp58, sp58);
158 guMtxL2F(sp18, ENTITY_ADDR(entity, Mtx*, &D_0A001098_E9C598));
159 sin_cos_rad(DEG_TO_RAD(gCameras[CAM_DEFAULT].curYaw + 180.0f), &sinAngle, &cosAngle);
160 sp18[3][1] += 10.0f;
161 sp18[3][2] -= 10.0f;
162 guMtxCatF(sp58, sp18, sp18);
163 guRotateF(sp58, entity->rot.z, 0.0f, 0.0f, 1.0f);
164 guMtxCatF(sp18, sp58, sp18);
165 guRotateF(sp58, data->initialRotY, 0.0f, 1.0f, 0.0f);
166 guMtxCatF(sp18, sp58, sp18);
167 guTranslateF(sp58, entity->pos.x + 16.0f * sinAngle, entity->pos.y , entity->pos.z - 16.0f * cosAngle);
168 guMtxCatF(sp18, sp58, sp18);
169 gDPSetCombineMode(gfxPos++, PM_CC_01, PM_CC_02);
170 gDPSetPrimColor(gfxPos++, 0, 0, 0, 0, 0, entity->alpha);
172 gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
173 gSPDisplayList(gfxPos++, D_0A0013B8_E9C8B8);
174 gSPPopMatrix(gfxPos++, G_MTX_MODELVIEW);
175 gMainGfxPos = gfxPos;
176}
177
179 PinkFlowerData* data = entity->dataBuf.pinkFlower;
180
184 entity->flags &= ~ENTITY_FLAG_SHOWS_INSPECT_PROMPT;
186 if (data->state == 0) {
187 data->state = 1;
190 }
191 }
192 }
193}
194
196 PinkFlowerData* data = entity->dataBuf.pinkFlower;
197 Entity* newEntity;
198 s32 entityIndex;
199
201 entityIndex = create_entity(&Entity_PinkFlowerLight, (s32)entity->pos.x, (s32)entity->pos.y, (s32)entity->pos.z, 0, MAKE_ENTITY_END);
202 data->linkedEntityIndex = entityIndex;
203 newEntity = get_entity_by_index(entityIndex);
204 data = newEntity->dataBuf.pinkFlower;
205 data->linkedEntityIndex = entity->listIndex;
206 data->initialRotY = newEntity->rot.y;
207}
208
210 entity->scale.x = 0.0f;
212}
213
215 PinkFlowerData* data = entity->dataBuf.pinkFlower;
216
217 switch (data->timer) {
218 case 0:
219 if (data->state != 0) {
220 data->state = 0;
221 data->timer++;
222 entity->rot.z = -25.0f;
223 entity->scale.x = 1.8f;
224 entity->alpha = 255;
225 }
226 break;
227 case 1:
228 entity->rot.z += 1.0f;
229 if (entity->rot.z >= 8.0f) {
230 entity->rot.z = 8.0f;
231 }
232
233 entity->alpha -= 6;
234 if (entity->alpha < 6) {
235 entity->alpha = 6;
236 }
237
238 entity->scale.x -= 0.03;
239 if (entity->scale.x <= 0.1) {
240 data->timer = 0;
241 entity->scale.x = 0.0f;
242 }
243 entity->scale.y = entity->scale.x;
244 entity->scale.z = entity->scale.x;
245 break;
246 }
247
249 entity->rot.y = gCameras[CAM_DEFAULT].curYaw;
250}
251
253 CymbalPlantData* data = entity->dataBuf.cymbalPlant;
254 data->dist = fabs(dist2D(entity->pos.x - 2.0f, entity->pos.z - 2.0f, gPlayerStatus.pos.x, gPlayerStatus.pos.z) * 0.25);
255 data->angle = atan2(gPlayerStatus.pos.x, gPlayerStatus.pos.z, entity->pos.x - 2.0f, entity->pos.z - 2.0f);
256}
257
265
267 CymbalPlantData* data = entity->dataBuf.cymbalPlant;
268 PartnerStatus* partnerStatus = &gPartnerStatus;
269 PlayerStatus* playerStatus = &gPlayerStatus;
270 f32 yaw;
271 f32 targetYaw;
272
273 switch (data->state) {
274 case 0:
276 if (partnerStatus->actingPartner != 0) {
278 }
280 playerStatus->animFlags |= PA_FLAG_INTERRUPT_SPIN;
281 data->timer = 4;
282 data->unk_01++;
283 data->state++;
288 func_802BB8D4_E2E204(entity);
289 } else {
290 data->unk_01 = 0;
291 }
292 break;
293 case 1:
294 playerStatus->animFlags |= PA_FLAG_INTERRUPT_SPIN;
295 if (--data->timer == 0) {
296 start_rumble(128, 10);
297 data->timer = 30;
298 data->state++;
299 yaw = playerStatus->spriteFacingAngle;
300 playerStatus->spriteFacingAngle = 80.0f;
301 playerStatus->flags |= PS_FLAG_ROTATION_LOCKED;
302 D_802BCE20 = yaw;
303 }
304 func_802BB98C_E2E2BC(entity);
305 break;
306 case 2:
307 if (--data->timer == 0) {
308 data->state++;
310 set_player_imgfx_all(ANIM_Mario1_Idle, IMGFX_SET_ANIM, IMGFX_ANIM_CYMBAL_CRUSH, 1, 1, 0, 0);
311 }
312 break;
313 case 3:
314 data->state++;
315 break;
316 case 4:
317 playerStatus->spriteFacingAngle = D_802BCE20;
318 targetYaw = 270.0f;
319 if (D_802BCE20 != 0.0f) {
320 targetYaw = 90.0f;
321 }
322 playerStatus->targetYaw = targetYaw;
323 data->timer = 80;
324 data->state++;
325 break;
326 case 5:
327 if (--data->timer == 0) {
328 data->state++;
331 playerStatus->flags &= ~PS_FLAG_ROTATION_LOCKED;
332 }
333 break;
334 case 6:
336 data->state = 0;
339 }
340 break;
341 }
342}
343
352
361
367
372
375
376DmaEntry Entity_CymbalPlant_dma[] = { ENTITY_ROM(CymbalPlant_gfx), ENTITY_ROM(CymbalPlant_anim) };
377DmaEntry Entity_PinkFlower_dma[] = { ENTITY_ROM(PinkFlower_gfx), ENTITY_ROM(PinkFlower_anim) };
378
381 .typeDataSize = sizeof(CymbalPlantData),
382 .renderCommandList = Entity_CymbalPlant_AnimationIdle,
383 .modelAnimationNodes = Entity_CymbalPlant_Mesh,
384 .fpInit = NULL,
385 .updateEntityScript = Entity_CymbalPlant_Update,
386 .fpHandleCollision = NULL,
387 { .dmaList = Entity_CymbalPlant_dma },
388 .entityType = ENTITY_TYPE_CYMBAL_PLANT,
389 .aabbSize = { 103, 30, 24 }
390};
391
394 .typeDataSize = sizeof(PinkFlowerData),
395 .renderCommandList = Entity_PinkFlower_AnimationIdle,
396 .modelAnimationNodes = Entity_PinkFlower_Mesh,
397 .fpInit = entity_PinkFlower_init,
398 .updateEntityScript = Entity_PinkFlower_Script,
399 .fpHandleCollision = NULL,
400 { .dmaList = Entity_PinkFlower_dma },
401 .entityType = ENTITY_TYPE_PINK_FLOWER,
402 .aabbSize = { 44, 100, 25 }
403};
404
407 .typeDataSize = sizeof(PinkFlowerData),
408 .renderCommandList = Entity_PinkFlowerLight_RenderScript,
409 .modelAnimationNodes = 0,
411 .updateEntityScript = Entity_PinkFlowerLight_Script,
412 .fpHandleCollision = NULL,
413 { .dma = ENTITY_ROM(PinkFlower_gfx) },
414 .entityType = ENTITY_TYPE_PINK_FLOWER,
415 .aabbSize = { 44, 100, 25 }
416};
417
419 .flags = 0,
420 .typeDataSize = sizeof(SpinningFlowerData),
421 .renderCommandList = Entity_SpinningFlower_RenderScript,
422 .modelAnimationNodes = 0,
424 .updateEntityScript = Entity_SpinningFlower_Script,
425 .fpHandleCollision = NULL,
426 { .dma = ENTITY_ROM(SpinningFlower) },
427 .entityType = ENTITY_TYPE_SPINNING_FLOWER,
428 .aabbSize = { 45, 22, 42 }
429};
void entity_PinkFlowerLight_idle(Entity *entity)
Definition Plants1.c:214
AnimScript Entity_PinkFlower_AnimationLightUp
Mtx D_0A001098_E9C598
StaticAnimatorNode * Entity_PinkFlower_Mesh[]
AnimScript Entity_CymbalPlant_AnimationIdle
void func_802BB228_E2DB58(Entity *entity)
Definition Plants1.c:107
DmaEntry Entity_PinkFlower_dma[]
Definition Plants1.c:377
EntityBlueprint Entity_CymbalPlant
Definition Plants1.c:379
void func_802BB8D4_E2E204(Entity *entity)
Definition Plants1.c:252
void func_802BB0A0_E2D9D0(Entity *entity)
Definition Plants1.c:67
EntityScript Entity_SpinningFlower_Script
Definition Plants1.c:344
void entity_PinkFlower_idle(Entity *entity)
Definition Plants1.c:178
void entity_PinkFlowerLight_init(Entity *entity)
Definition Plants1.c:209
EntityScript Entity_PinkFlower_Script
Definition Plants1.c:353
void entity_SpinningFlower_init(Entity *entity)
Definition Plants1.c:118
EntityBlueprint Entity_SpinningFlower
Definition Plants1.c:418
EntityScript Entity_CymbalPlant_Update
Definition Plants1.c:368
Gfx D_0A0013B8_E9C8B8[]
void entity_PinkFlower_init(Entity *entity)
Definition Plants1.c:195
AnimScript Entity_CymbalPlant_AnimationGrab
void entity_PinkFlowerLight_setupGfx(s32 entityIndex)
Definition Plants1.c:147
void func_802BB000_E2D930(Entity *entity)
Definition Plants1.c:51
Mtx D_0A000B70_E9D470
Gfx D_0A000D18_E9D618[]
DmaEntry Entity_CymbalPlant_dma[]
Definition Plants1.c:376
void entity_CymbalPlant_idle(Entity *entity)
Definition Plants1.c:266
Gfx Entity_SpinningFlower_Render[]
EntityBlueprint Entity_PinkFlowerLight
Definition Plants1.c:405
EntityModelScript Entity_SpinningFlower_RenderScript
Definition Plants1.c:374
void func_802BB98C_E2E2BC(Entity *entity)
Definition Plants1.c:258
void func_802BB314_E2DC44(Entity *entity)
Definition Plants1.c:138
StaticAnimatorNode * Entity_CymbalPlant_Mesh[]
Gfx Entity_RenderNone[]
Definition Shadow.c:69
void entity_SpinningFlower_setupGfx(s32 entityIndex)
Definition Plants1.c:26
BSS Vec3s FlowerGoalPosition
Definition Plants1.c:24
void func_802BB34C_E2DC7C(Entity *entity)
Definition Plants1.c:142
EntityModelScript Entity_PinkFlowerLight_RenderScript
Definition Plants1.c:373
EntityBlueprint Entity_PinkFlower
Definition Plants1.c:392
AnimScript Entity_PinkFlower_AnimationIdle
BSS f32 D_802BCE20
Definition Plants1.c:23
EntityScript Entity_PinkFlowerLight_Script
Definition Plants1.c:362
s16 AnimScript[]
struct CymbalPlantData * cymbalPlant
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
struct SpinningFlowerData * spinningFlower
struct PinkFlowerData * pinkFlower
#define guRotateF
#define sfx_play_sound_at_position
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define clamp_angle
#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 es_Restart
Definition entity.h:40
#define STANDARD_ENTITY_MODEL_SCRIPT(gfx, renderMode)
Definition entity.h:56
f32 initialRotY
Definition entity.h:354
#define ENTITY_ADDR(entity, type, data)
Definition entity.h:64
#define es_SetCallback(func, time)
Definition entity.h:38
#define es_SetFlags(flags)
Definition entity.h:43
#define ENTITY_ROM(name)
Definition entity.h:65
s32 EntityScript[]
Definition entity.h:6
u16 linkedEntityIndex
Definition entity.h:353
#define es_End
Definition entity.h:35
#define es_PlaySound(soundId)
Definition entity.h:45
@ IMGFX_CLEAR
Definition enums.h:5117
@ IMGFX_SET_ANIM
Definition enums.h:5122
@ PS_FLAG_ROTATION_LOCKED
Definition enums.h:3065
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ IMGFX_ANIM_CYMBAL_CRUSH
Definition enums.h:5157
@ SOUND_ID_TRIGGER_CHANGE_SOUND
Definition enums.h:532
@ ENTITY_TYPE_PINK_FLOWER
Definition enums.h:2594
@ ENTITY_TYPE_CYMBAL_PLANT
Definition enums.h:2593
@ ENTITY_TYPE_SPINNING_FLOWER
Definition enums.h:2595
@ PA_FLAG_INTERRUPT_SPIN
Definition enums.h:3110
@ PA_FLAG_INTERRUPT_USE_PARTNER
forces actions with bow, parakarry, watt, and lakilester to end (sushie not tested)
Definition enums.h:3093
@ PA_FLAG_SPINNING
Definition enums.h:3107
@ PA_FLAG_INTERACT_PROMPT_AVAILABLE
! prompt
Definition enums.h:3095
@ ENTITY_COLLISION_PLAYER_HAMMER
Definition enums.h:2654
@ ENTITY_COLLISION_PLAYER_TOUCH_WALL
Definition enums.h:2651
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ SOUND_LRAW_SPINNING_FLOWER
Definition enums.h:1215
@ SOUND_PLANTS_CYMBAL_CRASH
Definition enums.h:728
@ SOUND_LOOP_SPINNING_FLOWER
Definition enums.h:1687
@ SOUND_PLANTS_LIGHT_UP
Definition enums.h:730
@ RENDER_MODE_SURFACE_XLU_LAYER2
Definition enums.h:3287
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
@ ENTITY_FLAG_HAS_ANIMATED_MODEL
Definition enums.h:2616
@ ENTITY_FLAG_400
Definition enums.h:2623
@ ENTITY_FLAG_FIXED_SHADOW_SIZE
Definition enums.h:2622
@ ENTITY_FLAG_SHOWS_INSPECT_PROMPT
Definition enums.h:2625
@ ENTITY_FLAG_DISABLE_COLLISION
Definition enums.h:2618
@ ENTITY_FLAG_CIRCULAR_SHADOW
Definition enums.h:2624
@ ACTION_STATE_RIDE
Definition enums.h:2461
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_USE_SPINNING_FLOWER
Definition enums.h:2457
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ CAM_DEFAULT
Definition enums.h:1800
#define MAKE_ENTITY_END
Definition evt.h:107
void start_rumble(s32, s32)
Definition rumble.c:15
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
void play_model_animation(s32, s16 *)
Definition animator.c:1101
f64 fabs(f64 f)
s32 disable_player_input(void)
Definition 77480.c:990
s32 enable_player_input(void)
Definition 77480.c:998
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
s32 phys_adjust_cam_on_landing(void)
Definition 7E9D0.c:46
s32 is_picking_up_item(void)
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void enable_partner_ai(void)
Definition partners.c:2390
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
void func_800EF300(void)
Definition partners.c:2382
s32 create_entity(EntityBlueprint *bp,...)
Definition entity.c:1195
ModelAnimator * get_animator_by_index(s32 animModelID)
Definition animator.c:1041
void snd_stop_tracking_env_sound_pos(s32 soundID, s32 keepPlaying)
Definition sfx.c:447
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
#define BSS
Definition macros.h:7
#define PM_CC_01
Definition macros.h:276
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define PM_CC_02
Definition macros.h:277
void set_player_imgfx_all(s32 animID, ImgFXType imgfxType, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
Definition sprite.c:995
void set_player_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 flags)
Definition sprite.c:969
@ PLAYER_SPRITE_MAIN
Definition sprite.h:26
Vec3f targetPos
s16 virtualModelIndex
void(* renderSetupFunc)(s32)
EntityData dataBuf
Vec3f scale
u8 collisionFlags
PartnerStatus gPartnerStatus
Definition partners.c:42
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
DisplayContext * gDisplayContext
Definition cam_main.c:16