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.
This commit is contained in:
toaster 2023-04-13 00:31:34 +01:00
parent 08266c44c6
commit 26cdc0f003

View file

@ -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)