From 103659a2a46de82d759fdcea28e39b328190af5c Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sat, 3 Mar 2012 16:02:05 +0200 Subject: [PATCH] Simplify and improve my last commit --- data/qcsrc/server/miscfunctions.qc | 11 +++++++++++ data/qcsrc/server/sv_main.qc | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 23bb44bb..3d682845 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -2601,3 +2601,14 @@ void defer(float fdelay, void() func) e.think = defer_think; e.nextthink = time + fdelay; } + +// returns 1 if player is at minimum size and 0 if player is at normal size +float playersize_micro(entity e) +{ + return bound(0, (e.health / cvar("g_healthsize_center") - 1) / (cvar("g_healthsize_min") / cvar("g_healthsize_center") - 1), 1); +} +// returns 0 if player is at normal size and 1 if player is at maximum size +float playersize_macro(entity e) +{ + return bound(0, (e.health / cvar("g_healthsize_max") - 1) / (cvar("g_healthsize_center") / cvar("g_healthsize_max") - 1), 1); +} diff --git a/data/qcsrc/server/sv_main.qc b/data/qcsrc/server/sv_main.qc index b8baf296..fc146744 100644 --- a/data/qcsrc/server/sv_main.qc +++ b/data/qcsrc/server/sv_main.qc @@ -106,14 +106,10 @@ void CreatureFrame (void) */ if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) { - float micro_to_normal, normal_to_macro; - micro_to_normal = 1 - bound(0, (self.health / cvar("g_healthsize_center") - 1) / (cvar("g_healthsize_min") / cvar("g_healthsize_center") - 1), 1); - normal_to_macro = 1 - bound(0, (self.health / cvar("g_healthsize_max") - 1) / (cvar("g_healthsize_center") / cvar("g_healthsize_max") - 1), 1); - if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) - GlobalSound(globalsound_metalstep, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * micro_to_normal, 1)); + GlobalSound(globalsound_metalstep, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * (1 - playersize_micro(self)), 1)); else - GlobalSound(globalsound_step, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * micro_to_normal, 1)); + GlobalSound(globalsound_step, CHAN_PLAYER, VOICETYPE_PLAYERSOUND, bound(0, VOL_BASE * (1 - playersize_micro(self)), 1)); //sound(self, CHAN_AUTO, "misc/macro_footstep.wav", VOL_BASE, ATTN_NORM); } -- 2.39.2