From d70fd2d8a00c0bfffa27f38e2080e8eb30dbf64f Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 18 Jul 2023 16:42:46 +1000 Subject: [PATCH] Q1BSP: make the player's bbox fit the player's cliphull This is necessary for correct collision behaviour (otherwise the player's "head" can poke into ceilings). Also sets the correct bbox on Q2BSP and disables crouching on Q1BSP. Signed-off-by: bones_was_here --- qcsrc/common/physics/player.qc | 63 +++++++++++++++++++++++++--------- qcsrc/server/client.qc | 5 +-- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 1c280253d..670aa8549 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -64,23 +64,48 @@ void Physics_UpdateStats(entity this) STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, this) = Physics_ClientOption(this, "airspeedlimit_nonqw", autocvar_sv_airspeedlimit_nonqw) * maxspd_mod; } - /* Q3 uses the following: - * MIN '-15 -15 -24' - * MAX '15 15 32' - * VIEW_OFS '0 0 26' - * CROUCH_MIN '-15 -15 -24' - * CROUCH_MAX '15 15 16' - * CROUCH_VIEW_OFS '0 0 12' - * but xon player models have a different z offset to suit the origin at 24/69 - * at q3compat hitbox and model scale the equivalent offset is origin at 20/56 - */ - bool q3hb = q3compat && autocvar_sv_q3compat_changehitbox; - STAT(PL_MIN, this) = q3hb ? '-15 -15 -20' : autocvar_sv_player_mins; - STAT(PL_MAX, this) = q3hb ? '15 15 36' : autocvar_sv_player_maxs; - STAT(PL_VIEW_OFS, this) = q3hb ? '0 0 30' : autocvar_sv_player_viewoffset; - STAT(PL_CROUCH_MIN, this) = q3hb ? '-15 -15 -20' : autocvar_sv_player_crouch_mins; - STAT(PL_CROUCH_MAX, this) = q3hb ? '15 15 20' : autocvar_sv_player_crouch_maxs; - STAT(PL_CROUCH_VIEW_OFS, this) = q3hb ? '0 0 16' : autocvar_sv_player_crouch_viewoffset; + if (autocvar_sv_mapformat_is_quake3) + { + /* Q3 uses the following: + * MIN '-15 -15 -24' + * MAX '15 15 32' + * VIEW_OFS '0 0 26' + * CROUCH_MIN '-15 -15 -24' + * CROUCH_MAX '15 15 16' + * CROUCH_VIEW_OFS '0 0 12' + * but Xonotic player models have a different z offset to suit origin at 24/69. + * At q3compat hitbox dimensions and model scale the equivalent offset is origin at 20/56. + * See also: model .scale in PutPlayerInServer(). + */ + bool q3hb = q3compat && autocvar_sv_q3compat_changehitbox; + STAT(PL_MIN, this) = q3hb ? '-15 -15 -20' : autocvar_sv_player_mins; + STAT(PL_MAX, this) = q3hb ? '15 15 36' : autocvar_sv_player_maxs; + STAT(PL_VIEW_OFS, this) = q3hb ? '0 0 30' : autocvar_sv_player_viewoffset; + STAT(PL_CROUCH_MIN, this) = q3hb ? '-15 -15 -20' : autocvar_sv_player_crouch_mins; + STAT(PL_CROUCH_MAX, this) = q3hb ? '15 15 20' : autocvar_sv_player_crouch_maxs; + STAT(PL_CROUCH_VIEW_OFS, this) = q3hb ? '0 0 16' : autocvar_sv_player_crouch_viewoffset; + } + else + { + /* Quake and Q2 use a wider bbox matching the Q1BSP 32x32x56 cliphull: + * MIN '-16 -16 -24' + * MAX '16 16 32' + * VIEW_OFS '0 0 22' + * Quake doesn't support crouching, Q2 has a very low crouch: + * CROUCH_MIN '-16 -16 -24' + * CROUCH_MAX '16 16 4' + * CROUCH_VIEW_OFS '0 0 -2' + * We probably want a higher VIEW_OFS and Xonotic models don't crouch low enough for Q2 settings + * so these are the same heights as for Q3 above. + */ + STAT(PL_MIN, this) = '-16 -16 -20'; + STAT(PL_MAX, this) = '16 16 36'; + STAT(PL_VIEW_OFS, this) = '0 0 30'; + STAT(PL_CROUCH_MIN, this) = '-16 -16 -20'; + // Q1BSP has no cliphull to support crouching so disable it there, see PM_ClientMovement_UpdateStatus(). + STAT(PL_CROUCH_MAX, this) = autocvar_sv_mapformat_is_quake2 ? '16 16 20' : STAT(PL_MAX, this); + STAT(PL_CROUCH_VIEW_OFS, this) = autocvar_sv_mapformat_is_quake2 ? '0 0 16' : STAT(PL_VIEW_OFS, this); + } // old stats // fix some new settings @@ -168,6 +193,10 @@ void PM_ClientMovement_UpdateStatus(entity this) MUTATOR_CALLHOOK(PlayerCanCrouch, this, do_crouch); do_crouch = M_ARGV(1, bool); + // Disable crouching on Q1BSP because it lacks a suitable cliphull (HLBSP added one). + if (STAT(PL_CROUCH_MAX, this).z == STAT(PL_MAX, this).z) + do_crouch = false; + if (do_crouch) { if (!IS_DUCKED(this)) { SET_DUCKED(this); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index c1ee3aceb..6a66b4aba 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -643,8 +643,9 @@ void PutPlayerInServer(entity this) this.respawn_flags = 0; this.respawn_time = 0; STAT(RESPAWN_TIME, this) = 0; - // DP model scaling uses 1/16 accuracy and 13/16 is closest to 56/69 - this.scale = ((q3compat && autocvar_sv_q3compat_changehitbox) ? 0.8125 : autocvar_sv_player_scale); + this.scale = ((q3compat && autocvar_sv_q3compat_changehitbox) || !autocvar_sv_mapformat_is_quake3) + ? 0.8125 // DP model scaling uses 1/16 accuracy and 13/16 is closest to 56/69 + : autocvar_sv_player_scale; this.fade_time = 0; this.pain_finished = 0; this.pushltime = 0; -- 2.39.2