From f450789a08fab3797c2c94a11e125d911c861f4d Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 1 May 2023 17:52:43 +0100 Subject: [PATCH] Final rearrangement - If terrain has footsteps, always show those footsteps regardless of player speed slowdown - Otherwise, if player is slowed down, show default offroad particles --- src/k_terrain.c | 50 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index 25dab93b7..55a6be6a4 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -956,12 +956,12 @@ static void K_SpawnFootstepParticle(mobj_t *mo, t_footstep_t *fs, tic_t timer) See header file for description. --------------------------------------------------*/ -#define INVALIDFOOTSTEP(footstep) (footstep == NULL || footstep->mobjType == MT_NULL || footstep->frequency <= 0) +#define INVALIDFOOTSTEP (fs == NULL || fs->mobjType == MT_NULL || fs->frequency <= 0) void K_HandleFootstepParticles(mobj_t *mo) { tic_t timer = leveltime; - t_footstep_t *fs = NULL, *ofs = NULL; + t_footstep_t *fs = NULL; if (mo == NULL || P_MobjWasRemoved(mo) == true) { @@ -973,35 +973,51 @@ void K_HandleFootstepParticles(mobj_t *mo) { // Offset the timer. timer += mo->player - players; - - if (mo->player->boostpower < FRACUNIT) - { - // Create default offroad footstep - ofs = K_GetFootstepByIndex(defaultOffroadFootstep); - - if (!INVALIDFOOTSTEP(ofs)) - { - K_SpawnFootstepParticle(mo, ofs, timer); - } - } } if (!(mo->flags & MF_APPLYTERRAIN) || mo->terrain == NULL) { // No TERRAIN effects for this object. - return; + goto offroadhandle; } fs = K_GetFootstepByIndex(mo->terrain->footstepID); - if (INVALIDFOOTSTEP(fs) || ofs == fs) + if (INVALIDFOOTSTEP) + { + // No particles to spawn. + goto offroadhandle; + } + + // Idea for later: if different spawning styles are desired, + // we can put a switch case here! + K_SpawnFootstepParticle(mo, fs, timer); + + return; + +offroadhandle: + // ...unless you're + // - A player and + if (mo->player == NULL) + { + return; + } + + // - Being affected by offroad + if (mo->player->boostpower >= FRACUNIT) + { + return; + } + + // in which case make default offroad footstep! + fs = K_GetFootstepByIndex(defaultOffroadFootstep); + + if (INVALIDFOOTSTEP) { // No particles to spawn. return; } - // Idea for later: if different spawning styles are desired, - // we can put a switch case here! K_SpawnFootstepParticle(mo, fs, timer); }