From 092c690f9f20598cede028854d6919445bbc9d40 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 3 Dec 2015 17:33:17 +1000 Subject: [PATCH] Strip some player-only stuff out of the main CreatureFrame loop --- qcsrc/server/cl_client.qc | 53 +++++++++++++++++++++++++++++++++++++ qcsrc/server/sv_main.qc | 55 --------------------------------------- 2 files changed, 53 insertions(+), 55 deletions(-) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index f68cff0a4..4fa6820f8 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2520,6 +2520,57 @@ void PlayerPreThink () self.clip_load = self.clip_size = 0; } +void Player_Footsteps(entity this) +{ + // play stupid sounds + if (g_footsteps && !gameover && (this.flags & FL_ONGROUND)) + if (!this.crouch && (vlen(this.velocity) > autocvar_sv_maxspeed * 0.6) && this.deadflag == DEAD_NO && time < this.lastground + 0.2) + { + if((time > this.nextstep) || (time < (this.nextstep - 10.0))) + { + this.nextstep = time + 0.3 + random() * 0.1; + trace_dphitq3surfaceflags = 0; + tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this); + /* + if(trace_fraction == 1) + dprint("nohit\n"); + else + dprint(ftos(trace_dphitq3surfaceflags), "\n"); + */ + if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) + { + if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) + GlobalSound(this, GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND); + else + GlobalSound(this, GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND); + } + } + } +} + +void DrownPlayer(entity this) +{ + if(this.deadflag != DEAD_NO) + return; + + if (this.waterlevel != WATERLEVEL_SUBMERGED) + { + if(this.air_finished < time) + PlayerSound(this, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND); + this.air_finished = time + autocvar_g_balance_contents_drowndelay; + this.dmg = 2; + } + else if (this.air_finished < time) + { // drown! + if (!this.deadflag) + if (this.pain_finished < time) + { + Damage (this, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, this.origin, '0 0 0'); + this.pain_finished = time + 0.5; + } + } +} + /* ============= PlayerPostThink @@ -2571,6 +2622,8 @@ void PlayerPostThink () //CheckPlayerJump(); if(IS_PLAYER(self)) { + DrownPlayer(self); + Player_Footsteps(self); CheckRules_Player(); UpdateChatBubble(); if (self.impulse) diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index f05203c58..90e9f7938 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -28,29 +28,6 @@ .float lastground; .int state; -void CreatureFrame_drowning(entity this) -{ - if(!IS_VEHICLE(this) && !(this.flags & FL_PROJECTILE) && !IS_MONSTER(this)) // vehicles, monsters and projectiles don't drown - { - if (this.waterlevel != WATERLEVEL_SUBMERGED) - { - if(this.air_finished < time) - PlayerSound(this, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND); - this.air_finished = time + autocvar_g_balance_contents_drowndelay; - this.dmg = 2; - } - else if (this.air_finished < time) - { // drown! - if (!this.deadflag) - if (this.pain_finished < time) - { - Damage (this, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, this.origin, '0 0 0'); - this.pain_finished = time + 0.5; - } - } - } -} - void CreatureFrame_hotliquids(entity this) { if (this.dmgtime < time) @@ -100,8 +77,6 @@ void CreatureFrame_Liquids(entity this) this.dmgtime = 0; } - CreatureFrame_drowning(this); - CreatureFrame_hotliquids(this); } else @@ -139,35 +114,6 @@ void CreatureFrame_FallDamage(entity this) } } -void CreatureFrame_Footsteps(entity this) -{ - // play stupid sounds - if (g_footsteps && !gameover && (this.flags & FL_ONGROUND)) - if (!IS_VEHICLE(this) && !(this.flags & FL_PROJECTILE)) - if (!this.crouch && (vlen(this.velocity) > autocvar_sv_maxspeed * 0.6) && !this.deadflag && time < this.lastground + 0.2) - { - if((time > this.nextstep) || (time < (this.nextstep - 10.0))) - { - this.nextstep = time + 0.3 + random() * 0.1; - trace_dphitq3surfaceflags = 0; - tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this); - /* - if(trace_fraction == 1) - dprint("nohit\n"); - else - dprint(ftos(trace_dphitq3surfaceflags), "\n"); - */ - if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) - { - if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) - GlobalSound(this, GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND); - else - GlobalSound(this, GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND); - } - } - } -} - void CreatureFrame_All() { for(entity e = world; (e = findfloat(e, damagedbycontents, true)); ) @@ -176,7 +122,6 @@ void CreatureFrame_All() CreatureFrame_Liquids(e); CreatureFrame_FallDamage(e); - CreatureFrame_Footsteps(e); e.oldvelocity = e.velocity; } -- 2.39.2