From 0fe863aabc2ac7f4ae9d5f7a07b0a70906ec18e3 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 13 Feb 2021 23:06:06 +0100 Subject: [PATCH] Server: Add water stepping, wading and swimming sounds + script definitions --- .../sound/footsteps.sndshd | 23 ++++++++++++ src/server/footsteps.qc | 35 ++++++++++++++++--- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/platform/base_scripts.pk3dir/sound/footsteps.sndshd b/platform/base_scripts.pk3dir/sound/footsteps.sndshd index cd97ce22..d7bbff5f 100644 --- a/platform/base_scripts.pk3dir/sound/footsteps.sndshd +++ b/platform/base_scripts.pk3dir/sound/footsteps.sndshd @@ -237,3 +237,26 @@ step_ladder.right sample player/pl_ladder3.wav sample player/pl_ladder4.wav } + +step_wade.left +{ + sample player/pl_wade1.wav + sample player/pl_wade2.wav +} +step_wade.right +{ + sample player/pl_wade3.wav + sample player/pl_wade4.wav +} + +step_swim.left +{ + sample player/pl_swim1.wav + sample player/pl_swim2.wav +} +step_swim.right +{ + sample player/pl_swim3.wav + sample player/pl_swim4.wav +} + diff --git a/src/server/footsteps.qc b/src/server/footsteps.qc index e3794016..aa779adb 100755 --- a/src/server/footsteps.qc +++ b/src/server/footsteps.qc @@ -56,6 +56,10 @@ Footsteps_Init(void) Sound_Precache("step_wood.right"); Sound_Precache("step_ladder.left"); Sound_Precache("step_ladder.right"); + Sound_Precache("step_wade.left"); + Sound_Precache("step_wade.right"); + Sound_Precache("step_swim.left"); + Sound_Precache("step_swim.right"); } /* @@ -267,10 +271,32 @@ Footsteps_Update(void) return; } - /* make it so we step once we land */ - if (!(pl.flags & FL_ONGROUND) && !(pl.flags & FL_ONLADDER)) { - pl.step_time = 0.0f; - return; + if (pl.waterlevel == 1) { + if (pl.step) { + Sound_Play(pl, CHAN_BODY, "step_slosh.left"); + } else { + Sound_Play(pl, CHAN_BODY, "step_slosh.right"); + } + pl.step_time = time + 0.35f; + } else if (pl.waterlevel == 2) { + if (pl.step) { + Sound_Play(pl, CHAN_BODY, "step_wade.left"); + } else { + Sound_Play(pl, CHAN_BODY, "step_wade.right"); + } + pl.step_time = time + 1.0f; + } else if (pl.waterlevel == 3) { + if (pl.step) { + Sound_Play(pl, CHAN_BODY, "step_swim.left"); + } else { + Sound_Play(pl, CHAN_BODY, "step_swim.right"); + } + pl.step_time = time + 2.0f; + } else { + /* make it so we step once we land */ + if (!(pl.flags & FL_ONGROUND) && !(pl.flags & FL_ONLADDER)) { + pl.step_time = 0.0f; + return; } /* the footsteps call might overwrite this later */ @@ -288,6 +314,7 @@ Footsteps_Update(void) default: Footsteps_Default(pl); } + } /* switch between feet */ pl.step = 1 - pl.step;