From: TimePath Date: Sun, 13 Mar 2016 04:16:24 +0000 (+1100) Subject: natural crouch: initial commit X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=75f6789979e62f2134ea4f9a05d0f89795fd3115;p=xonotic%2Fxonotic-data.pk3dir.git natural crouch: initial commit --- diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 28db23dc1..088d8f4fe 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -210,6 +210,8 @@ const int SERVERFLAG_PLAYERSTATS = 4; vector autocvar_sv_player_maxs = '16 16 45'; vector autocvar_sv_player_mins = '-16 -16 -24'; vector autocvar_sv_player_viewoffset = '0 0 20'; +/** pull legs up in the air */ +bool autocvar_sv_player_crouch_natural = false; vector autocvar_sv_player_crouch_maxs = '16 16 25'; vector autocvar_sv_player_crouch_mins = '-16 -16 -24'; vector autocvar_sv_player_crouch_viewoffset = '0 0 20'; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 28d9c6c1a..7d7383a0c 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -216,7 +216,7 @@ void PutObserverInServer(entity this) // needed for player sounds this.model = ""; FixPlayermodel(this); - } + } setmodel(this, MDL_Null); setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL)); this.view_ofs = '0 0 0'; @@ -2279,20 +2279,46 @@ void PlayerPreThink () do_crouch = false; } - if (do_crouch) { - if (!this.crouch) { + if (do_crouch) + { + if (!this.crouch) + { this.crouch = true; - this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, this); - setsize(this, STAT(PL_CROUCH_MIN, this), STAT(PL_CROUCH_MAX, this)); + vector mn = STAT(PL_CROUCH_MIN, this); + vector mx = STAT(PL_CROUCH_MAX, this); + if (autocvar_sv_player_crouch_natural && !IS_ONGROUND(this)) { + // pull feet up + float h = STAT(PL_MAX, this).z - STAT(PL_CROUCH_MAX, this).z; + mn.z += h; + mx.z += h; + this.view_ofs = STAT(PL_VIEW_OFS, this); + } else { + this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, this); + } + setsize(this, mn, mx); // setanim(this, this.anim_duck, false, true, true); // this anim is BROKEN anyway } - } else if (this.crouch) { - tracebox(this.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), this.origin, false, this); - if (!trace_startsolid) { - this.crouch = false; - this.view_ofs = STAT(PL_VIEW_OFS, this); - setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this)); - } + } + else + { + if (this.crouch) + { + vector mn = STAT(PL_MIN, this); + vector mx = STAT(PL_MAX, this); + if (autocvar_sv_player_crouch_natural && IS_ONGROUND(this)) { + // let feet down + float h = STAT(PL_MAX, this).z - STAT(PL_CROUCH_MAX, this).z; + mn.z += h; + mx.z += h; + } + tracebox(this.origin, mn, mx, this.origin, false, this); + if (!trace_startsolid) + { + this.crouch = false; + this.view_ofs = STAT(PL_VIEW_OFS, this); + setsize(this, STAT(PL_MIN, this), STAT(PL_MAX, this)); + } + } } FixPlayermodel(this);