From 26cdc0f0034a3ca5315b1d9c4dfe5882bd3580cc Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 13 Apr 2023 00:31:34 +0100 Subject: [PATCH] Fix particle behaviours for indicating being slowed - For players interacting with terrain: - If a terrain is tagged with offroad, only use footstep if player is being slowed by it - If a player is not on terrain with footsteps but is being slowed down, use default footsteps as a substitute This matches behaviour of the previous entry in the series, which was good for communicating the gameplay functionality of being slowed down. --- src/k_terrain.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index d0f3d52bf..e4f311a11 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -955,10 +955,14 @@ static void K_SpawnFootstepParticle(mobj_t *mo, t_footstep_t *fs, tic_t timer) See header file for description. --------------------------------------------------*/ + +#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; + boolean offroadslowed = false; if (mo == NULL || P_MobjWasRemoved(mo) == true) { @@ -966,31 +970,53 @@ void K_HandleFootstepParticles(mobj_t *mo) return; } - if (!(mo->flags & MF_APPLYTERRAIN) || mo->terrain == NULL) - { - // No TERRAIN effects for this object. - return; - } + offroadslowed = (mo->player != NULL && mo->player->boostpower < FRACUNIT); - fs = K_GetFootstepByIndex(mo->terrain->footstepID); - - if (fs == NULL || fs->mobjType == MT_NULL || fs->frequency <= 0) + if (!offroadslowed) { - // No particles to spawn. - return; + if (!(mo->flags & MF_APPLYTERRAIN) || mo->terrain == NULL) + { + // No TERRAIN effects for this object. + return; + } + + fs = K_GetFootstepByIndex(mo->terrain->footstepID); } if (mo->player != NULL) { + // Match behaviour of the previous entry in the series: + // Only do footsteps for offroad if you're slowed by it, + // and guarantee the defaults if none were found for this. + if (offroadslowed) + { + if (INVALIDFOOTSTEP) + { + fs = K_GetFootstepByIndex(defaultOffroadFootstep); + } + } + else if (mo->terrain->offroad != 0) + { + return; + } + // Offset timer by player ID. timer += mo->player - players; } + 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); } +#undef INVALIDFOOTSTEP + /*-------------------------------------------------- static void K_CleanupTerrainOverlay(mobj_t *mo)