diff --git a/src/k_terrain.c b/src/k_terrain.c index 0e986469f..7c182ab8a 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -868,6 +868,9 @@ 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; @@ -879,31 +882,60 @@ void K_HandleFootstepParticles(mobj_t *mo) return; } + if (mo->player) + { + // Offset the timer. + timer += mo->player - players; + } + if (!(mo->flags & MF_APPLYTERRAIN) || mo->terrain == NULL) { // No TERRAIN effects for this object. - return; + goto offroadhandle; } fs = K_GetFootstepByIndex(mo->terrain->footstepID); - if (fs == NULL || fs->mobjType == MT_NULL || fs->frequency <= 0) + if (INVALIDFOOTSTEP) { // No particles to spawn. - return; - } - - if (mo->player != NULL) - { - // Offset timer by player ID. - timer += mo->player - players; + 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; + } + + K_SpawnFootstepParticle(mo, fs, timer); } +#undef INVALIDFOOTSTEP + /*-------------------------------------------------- static void K_CleanupTerrainOverlay(mobj_t *mo)