From: MirceaKitsune Date: Sat, 3 Mar 2012 14:02:05 +0000 (+0200) Subject: Simplify and improve my last commit X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=103659a2a46de82d759fdcea28e39b328190af5c;p=voretournament%2Fvoretournament.git Simplify and improve my last commit --- 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); }