Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
surfaces.c
Go to the documentation of this file.
1#include "surfaces.h"
2#include "effects.h"
3
10
13
15
17
18void surface_set_walk_effect(s32 effect) {
19 SurfaceWalkEffectType = effect;
20}
21
22API_CALLABLE(SetSurfaceWalkEffect) {
23 Bytecode* args = script->ptrReadPos;
24 s32 effect = evt_get_variable(script, *args++);
25
27 return ApiStatus_DONE2;
28}
29
37b32 PlayerNextFootParity = FALSE; // FALSE => RIGHT, TRUE => LEFT
40
41// Particles (dust, flowers, snow) and etc
82
84 f32 sinAngle, cosAngle;
85 f32 x, y, z;
86
87 // spawn effects if landing from a decent height
90 && LandedTimeInAir >= 10
91 ) {
95 switch (SurfaceWalkEffectType) {
97 fx_landing_dust(0, x, y, z, 0.0f);
98 break;
100 fx_misc_particles(3, x, y, z, 13.0f, 10.0f, 1.0f, 5, 30);
101 break;
102 }
103 return;
104 }
105
106 // spawn effects if ground pounding
109 ) {
110 x = gPlayerStatus.pos.x;
111 y = gPlayerStatus.pos.y;
112 z = gPlayerStatus.pos.z;
113 switch (SurfaceWalkEffectType) {
115 fx_landing_dust(0, x, y, z, 0.0f);
116 break;
118 fx_misc_particles(3, x, y, z, gPlayerStatus.colliderDiameter, 10.0f, 1.0f, 5, 40);
119 break;
120 }
121 return;
122 }
123
124 // spawn effects if spinning and moving
126 if (PlayerDustSpawnDelay++ >= 4) {
128
129 switch (SurfaceWalkEffectType) {
131 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw)), &sinAngle, &cosAngle);
132 fx_walking_dust(
133 0,
134 gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * 0.2f),
135 gPlayerStatus.pos.y + 1.5f,
136 gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * 0.2f),
137 sinAngle,
138 cosAngle
139 );
140 break;
143 fx_misc_particles(
144 3,
146 gPlayerStatus.pos.y + 1.5f,
148 13.0f, 10.0f, 1.0f, 5, 30
149 );
150 break;
151 }
152 }
153 return;
154 }
155
156 // spawn effects if running or starting a spin
159 ) {
160 if (PlayerDustSpawnDelay++ >= 4) {
162
163 switch (SurfaceWalkEffectType) {
165 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw)), &sinAngle, &cosAngle);
166 fx_walking_dust(
167 0,
168 gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * 0.2f),
169 gPlayerStatus.pos.y + 1.5f,
170 gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * 0.2f),
171 sinAngle,
172 cosAngle
173 );
174 break;
177 fx_misc_particles(
178 3,
180 gPlayerStatus.pos.y + 1.5f,
182 13.0f, 10.0f, 1.0f, 5, 30
183 );
184 break;
185 }
186 }
187 return;
188 }
189
190 // reset the delay
192 return;
193}
194
196 f32 sinAngle, cosAngle;
197 f32 x, y, z;
198
202 ) {
203 x = gPlayerStatus.pos.x;
204 z = gPlayerStatus.pos.z;
205 y = gPlayerStatus.pos.y + 14.0f;
206
207 fx_flower_splash(x, y, z, PlayerFlowerSplashAngle);
210 return;
211 }
212
214 if (PlayerFlowerSplashDelay > 5) {
216 }
217
221 ) {
222 if (PlayerFlowerTrailDelay++ > 0) {
224 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw)), &sinAngle, &cosAngle);
225
226 x = gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * -0.4f);
227 z = gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * -0.4f);
228 y = gPlayerStatus.pos.y + 15.5f;
229
230 fx_flower_trail(0, x, y, z, -gPlayerStatus.curYaw + rand_int(10) - 5.0f, PlayerFlowerTrailVariant);
232 }
233 return;
234 }
235
237 return;
238}
239
241 f32 sinAngle, cosAngle;
242 f32 dx, dy, dz;
243 s32 i;
244
248 && LandedTimeInAir >= 10
249 ) {
250 fx_cloud_puff(
252 (gPlayerStatus.pos.y + 14.0f) - 5.0f,
255 );
257
258 for (i = 0; i < 4; i++) {
259 dx = rand_int(10) - 5;
260 dz = rand_int(10) - 5;
261 dy = -2.0f - ((SQ(dx) + SQ(dz)) / 5.0f);
262
263 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw + (i * 90))), &sinAngle, &cosAngle);
264 fx_cloud_trail(
265 0,
266 gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * -0.3f) + dx,
267 gPlayerStatus.pos.y + 15.5f + dy,
268 gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * -0.3f) + dz
269 );
270 }
271 return;
272 }
273
277 ) {
278 dx = rand_int(10) - 5;
279 dz = rand_int(10) - 5;
280 dy = -2.0f - ((SQ(dx) + SQ(dz)) / 5.0f);
281
282 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw)), &sinAngle, &cosAngle);
283 fx_cloud_trail(
284 1,
285 gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * -0.3f) + dx,
286 gPlayerStatus.pos.y + 15.5f + dy,
287 gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * -0.3f) + dz
288 );
289
290 }
291 return;
292}
293
321
323 f32 sinAngle, cosAngle;
324
330 ) {
331 if (PlayerHedgeSpawnDelay++ >= 4) {
333 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw)), &sinAngle, &cosAngle);
334 fx_falling_leaves(
335 0,
336 gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * 0.2f),
337 40.0f,
338 gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * 0.2f)
339 );
340 }
341 return;
342 }
343
345 return;
346}
347
349 f32 sinAngle, cosAngle;
350
356 ) {
357 if (PlayerWaterSpawnDelay++ >= 4) {
359 sin_cos_rad(DEG_TO_RAD(clamp_angle(-gPlayerStatus.curYaw)), &sinAngle, &cosAngle);
360 fx_rising_bubble(
361 0,
362 gPlayerStatus.pos.x + (gPlayerStatus.colliderDiameter * sinAngle * 0.2f),
363 gPlayerStatus.pos.y + 0.0f,
364 gPlayerStatus.pos.z + (gPlayerStatus.colliderDiameter * cosAngle * 0.2f),
365 0.0f
366 );
367 }
368 return;
369 }
370
372 return;
373}
374
386
393
395 s32 surfaceType;
396
397 if ((npc->flags & NPC_FLAG_INVISIBLE) || !(npc->flags & NPC_FLAG_TOUCHES_GROUND) || npc->moveSpeed == 0.0f) {
398 return;
399 }
400
402 switch (surfaceType) {
405 break;
408 break;
410 npc_surface_spawn_snow_fx(npc, mode);
411 break;
414 break;
417 break;
418 default:
420 break;
421 }
422}
423
425 f32 sinTheta, cosTheta;
426 f32 x, y, z;
427
428 if (mode == SURFACE_INTERACT_LAND) {
429 x = npc->pos.x;
430 y = npc->pos.y + 0.0f;
431 z = npc->pos.z;
432
433 switch (SurfaceWalkEffectType) {
435 fx_landing_dust(0, x, y, z, NpcDustSpawnAngle);
437 break;
439 fx_misc_particles(3, x, y, z, 13.0f, 10.0f, 1.0f, 5, 30);
440 break;
441 }
442 } else if (mode != SURFACE_INTERACT_WALK) {
443 if (NpcDustSpawnDelay++ >= 4) {
445
446 switch (SurfaceWalkEffectType) {
448 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw)), &sinTheta, &cosTheta);
449 fx_walking_dust(0,
450 npc->pos.x + (npc->collisionDiameter * sinTheta * 0.2f),
451 npc->pos.y + 1.5f,
452 npc->pos.z + (npc->collisionDiameter * cosTheta * 0.2f),
453 sinTheta,
454 cosTheta);
455 break;
457 sin_cos_rad(DEG_TO_RAD(clamp_angle(npc->yaw)), &sinTheta, &cosTheta);
458 fx_misc_particles(3,
459 npc->pos.x + (npc->collisionDiameter * sinTheta),
460 npc->pos.y + 1.5f,
461 npc->pos.z + (npc->collisionDiameter * cosTheta),
462 5.0f, 10.0f, 1.0f, 5, 30);
463 break;
464 }
465 }
466 }
467}
468
470 f32 sinAngle, cosAngle;
471 f32 x, y, z;
472
473 if (mode == SURFACE_INTERACT_LAND && NpcFlowerSplashDelay == 5) {
474 x = npc->pos.x;
475 y = npc->pos.y + + 14.0f;
476 z = npc->pos.z;
477
478 fx_flower_splash(x, y, z, NpcFlowerSplashAngle);
481 return;
482 }
483
485 if (NpcFlowerSplashDelay > 5) {
487 }
488
489 if (NpcFlowerTrailDelay++ > 0) {
491
492 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw)), &sinAngle, &cosAngle);
493 x = npc->pos.x + (npc->collisionDiameter * sinAngle * -0.4f);
494 z = npc->pos.z + (npc->collisionDiameter * cosAngle * -0.4f);
495 y = npc->pos.y + 15.5f;
496
497 fx_flower_trail(1, x, y, z, -npc->yaw + rand_int(10) - 5.0f, NpcFlowerTrailVariant);
499 }
500}
501
503 f32 sinAngle, cosAngle;
504 f32 dx, dy, dz;
505 s32 i;
506
507 if (mode == SURFACE_INTERACT_LAND) {
508 fx_cloud_puff(npc->pos.x, (npc->pos.y + 14.0f) - 5.0f, npc->pos.z, NpcCloudPuffAngle);
509
511
512 for (i = 0; i < 4; i++) {
513 dx = rand_int(10) - 5;
514 dz = rand_int(10) - 5;
515 dy = -2.0f - ((SQ(dx) + SQ(dz)) / 5.0f);
516
517 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw + (i * 90))), &sinAngle, &cosAngle);
518 fx_cloud_trail(
519 1,
520 npc->pos.x + (npc->collisionDiameter * sinAngle * -0.3f) + dx,
521 npc->pos.y + 15.5f + dy,
522 npc->pos.z + (npc->collisionDiameter * cosAngle * -0.3f) + dz
523 );
524 }
525 } else {
526 dx = rand_int(10) - 5;
527 dz = rand_int(10) - 5;
528 dy = -2.0f - ((SQ(dx) + SQ(dz)) / 5.0f);
529
530 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw)), &sinAngle, &cosAngle);
531 fx_cloud_trail(
532 1,
533 npc->pos.x + (npc->collisionDiameter * sinAngle * -0.3f) + dx,
534 npc->pos.y + 15.5f + dy,
535 npc->pos.z + (npc->collisionDiameter * cosAngle * -0.3f) + dz
536 );
537 }
538}
539
541 f32 sinAngle, cosAngle;
542
544 return;
545 }
546
547 if (NpcSnowSpawnDelay++ >= 4) {
549 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw)), &sinAngle, &cosAngle);
550 fx_footprint(
551 npc->pos.x + (npc->collisionDiameter * sinAngle * 0.2f),
552 npc->pos.y + 1.5f,
553 npc->pos.z + (npc->collisionDiameter * cosAngle * 0.2f),
554 -npc->yaw,
557 }
558}
559
561 f32 sinAngle, cosAngle;
562
563 if (NpcHedgeSpawnDelay++ >= 4) {
565 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw)), &sinAngle, &cosAngle);
566 fx_falling_leaves(
567 1,
568 npc->pos.x + (npc->collisionDiameter * sinAngle * 0.2f),
569 40.0f,
570 npc->pos.z + (npc->collisionDiameter * cosAngle * 0.2f));
571 }
572}
573
575 f32 sinAngle, cosAngle;
576
577 if (NpcWaterSpawnDelay++ >= 4) {
579 sin_cos_rad(DEG_TO_RAD(clamp_angle(-npc->yaw)), &sinAngle, &cosAngle);
580 fx_rising_bubble(
581 0,
582 npc->pos.x + (npc->collisionDiameter * sinAngle * 0.2f),
583 npc->pos.y + 0.0f,
584 npc->pos.z + (npc->collisionDiameter * cosAngle * 0.2f),
585 0.0f);
586 }
587}
s32 b32
#define rand_int
#define clamp_angle
@ SURFACE_TYPE_HEDGES
used within hedge maze in flo_11
Definition enums.h:4679
@ SURFACE_TYPE_DEFAULT
Definition enums.h:4670
@ SURFACE_TYPE_SNOW
Definition enums.h:4678
@ SURFACE_TYPE_WATER
Definition enums.h:4671
@ SURFACE_TYPE_CLOUD
used with clouds in flo_19 and flo_21
Definition enums.h:4677
@ SURFACE_TYPE_FLOWERS
Definition enums.h:4676
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ PS_FLAG_SPECIAL_LAND
Definition enums.h:3048
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4693
@ PARTNER_LAKILESTER
Definition enums.h:2893
@ ACTION_STATE_JUMP
Definition enums.h:2430
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ ACTION_STATE_LAND
Definition enums.h:2437
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_SPIN
Definition enums.h:2454
@ ACTION_STATE_RUN
Definition enums.h:2428
SurfaceInteractMode
Definition enums.h:4683
@ SURFACE_INTERACT_WALK
Definition enums.h:4684
@ SURFACE_INTERACT_LAND
Definition enums.h:4686
@ NPC_FLAG_TOUCHES_GROUND
Definition enums.h:3020
@ NPC_FLAG_INVISIBLE
Definition enums.h:2999
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:706
#define BSS
Definition macros.h:7
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define SQ(x)
Definition macros.h:166
s16 collisionDiameter
s32 flags
Vec3f pos
s16 curFloor
f32 moveSpeed
void player_surface_spawn_water_fx(void)
Definition surfaces.c:348
f32 PlayerFlowerSplashAngle
Definition surfaces.c:31
s16 NpcHedgeSpawnDelay
Definition surfaces.c:384
s32 NpcFlowerTrailVariant
Definition surfaces.c:380
s32 SurfaceWalkEffectType
Definition surfaces.c:16
f32 PlayerCloudPuffAngle
Definition surfaces.c:35
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:394
s16 NpcWaterSpawnDelay
Definition surfaces.c:385
void player_surface_spawn_cloud_fx(void)
Definition surfaces.c:240
s16 NpcDustSpawnDelay
Definition surfaces.c:375
f32 NpcFlowerSplashAngle
Definition surfaces.c:378
s16 PlayerFlowerTrailDelay
Definition surfaces.c:33
void npc_surface_spawn_water_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:574
void player_surface_spawn_hedges_fx(void)
Definition surfaces.c:322
s16 PlayerFlowerSplashDelay
Definition surfaces.c:32
s16 PlayerDustSpawnDelay
Definition surfaces.c:30
s16 NpcSnowSpawnDelay
Definition surfaces.c:382
BSS s32 PrevTimeInAir
Definition surfaces.c:11
void player_surface_spawn_flower_fx(void)
Definition surfaces.c:195
s16 PlayerWaterSpawnDelay
Definition surfaces.c:39
f32 NpcDustSpawnAngle
Definition surfaces.c:376
BSS s32 LandedTimeInAir
Definition surfaces.c:12
void player_surface_spawn_snow_fx(void)
Definition surfaces.c:294
void npc_surface_spawn_snow_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:540
void npc_surface_spawn_flower_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:469
void npc_surface_spawn_cloud_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:502
void player_surface_spawn_fx(void)
Definition surfaces.c:42
s16 NpcFlowerTrailDelay
Definition surfaces.c:379
b32 PlayerNextFootParity
Definition surfaces.c:37
void npc_surface_spawn_basic_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:424
s32 PlayerFlowerTrailVariant
Definition surfaces.c:34
void surface_set_walk_effect(s32 effect)
Select the type of surface effect spawned by the player while moving The effect is reset between maps...
Definition surfaces.c:18
s32 PrevSurfaceType
Definition surfaces.c:14
s16 NpcFlowerSplashDelay
Definition surfaces.c:377
s16 PlayerHedgeSpawnDelay
Definition surfaces.c:38
s32 NpcNextFootParity
Definition surfaces.c:383
s16 PlayerSnowSpawnDelay
Definition surfaces.c:36
void npc_surface_spawn_hedges_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:560
void player_surface_spawn_basic_fx(void)
Definition surfaces.c:83
f32 NpcCloudPuffAngle
Definition surfaces.c:381
@ SURFACE_WALK_FX_STANDARD
Definition surfaces.h:7
@ SURFACE_WALK_FX_SPARKLE
Definition surfaces.h:8
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
PartnerStatus gPartnerStatus
Definition partners.c:42
PlayerStatus gPlayerStatus
Definition 77480.c:39