From 70f32c97a45d4c89cd00dd43ab4384d9a16bdba5 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Wed, 27 Apr 2022 15:03:00 -0700 Subject: [PATCH] NSVehicle: Add method CanDriverCrouch() to deal with player physics restrictions. --- src/gs-entbase/shared/NSVehicle.h | 2 ++ src/gs-entbase/shared/NSVehicle.qc | 16 +++++++++++----- src/shared/defs.h | 1 - src/shared/include.src | 1 - src/shared/player.qc | 7 ++++++- src/shared/player_pmove.qc | 17 ++++++++++++----- src/shared/vehicles.h | 17 ----------------- src/shared/vehicles.qc | 28 ---------------------------- 8 files changed, 31 insertions(+), 58 deletions(-) delete mode 100644 src/shared/vehicles.h delete mode 100644 src/shared/vehicles.qc diff --git a/src/gs-entbase/shared/NSVehicle.h b/src/gs-entbase/shared/NSVehicle.h index b8239fac..53cfee20 100644 --- a/src/gs-entbase/shared/NSVehicle.h +++ b/src/gs-entbase/shared/NSVehicle.h @@ -59,6 +59,8 @@ class NSVehicle:NSSurfacePropEntity virtual void(base_player) PlayerLeave; virtual void() PlayerInput; virtual float(void) DriverAnimation; + + virtual bool(void) CanDriverCrouch; }; enumflags diff --git a/src/gs-entbase/shared/NSVehicle.qc b/src/gs-entbase/shared/NSVehicle.qc index 709ee70a..dbdf1fa6 100644 --- a/src/gs-entbase/shared/NSVehicle.qc +++ b/src/gs-entbase/shared/NSVehicle.qc @@ -14,6 +14,12 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +bool +NSVehicle::CanDriverCrouch(void) +{ + return (false); +} + float NSVehicle::DriverAnimation(void) { @@ -30,17 +36,17 @@ NSVehicle::GetDriver(void) bool NSVehicle::HideViewWeapon(void) { - return false; + return (false); } bool NSVehicle::HideCrosshair(void) { - return true; + return (true); } bool NSVehicle::HidePlayermodel(void) { - return true; + return (true); } void @@ -61,9 +67,9 @@ NSVehicle::IsLocalDriver(void) DriverRelink(); if (m_eDriver == pSeat->m_ePlayer) - return true; + return (true); else - return false; + return (false); } void diff --git a/src/shared/defs.h b/src/shared/defs.h index cf77b7fa..ebf26cad 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -54,7 +54,6 @@ #include "platform.h" #include "propdata.h" #include "surfaceproperties.h" -#include "vehicles.h" #include "colors.h" #define BSPVER_PREREL 28 diff --git a/src/shared/include.src b/src/shared/include.src index 5b2c96ae..03b1db36 100644 --- a/src/shared/include.src +++ b/src/shared/include.src @@ -9,5 +9,4 @@ player.qc player_pmove.qc propdata.qc surfaceproperties.qc -vehicles.qc #endlist diff --git a/src/shared/player.qc b/src/shared/player.qc index c14b4dc1..f91f4336 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -109,7 +109,12 @@ base_player::ClientInput(void) } /* allow vehicles to prevent weapon logic from happening */ - Vehicle_Input(this); + if (vehicle) { + NSVehicle veh = (NSVehicle)vehicle; + + if (veh.PlayerInput) + veh.PlayerInput(); + } /* weapon/item logic of what the player controls */ Game_Input((player)this); diff --git a/src/shared/player_pmove.qc b/src/shared/player_pmove.qc index 5dc917e2..f64131a3 100644 --- a/src/shared/player_pmove.qc +++ b/src/shared/player_pmove.qc @@ -225,16 +225,13 @@ base_player::Physics_MaxSpeed(void) void base_player::Physics_InputPreMove(void) { + NSVehicle veh = (NSVehicle)vehicle; + /* when pressing the 'use' button, we also walk slower for precision */ if (input_buttons & INPUT_BUTTON5) { input_movevalues *= 0.25; } - if (flags & FL_FROZEN || movetype == MOVETYPE_NONE) { - input_movevalues = [0,0,0]; - input_buttons &= ~INPUT_BUTTON2; - } - /* move camera up (noclip, fly) when holding jump */ if (input_buttons & INPUT_BUTTON2) { input_movevalues[2] = 240; @@ -243,6 +240,16 @@ base_player::Physics_InputPreMove(void) if (input_buttons & INPUT_BUTTON8) { input_movevalues[2] = -240; } + + if (flags & FL_FROZEN || movetype == MOVETYPE_NONE) { + input_movevalues = [0,0,0]; + input_buttons &= ~INPUT_BUTTON2; + } + + /* suppress crouching in vehicles */ + if (veh) + if (veh.CanDriverCrouch() == false) + input_buttons &= ~INPUT_BUTTON8; } /* timers get processed here after physics are run */ diff --git a/src/shared/vehicles.h b/src/shared/vehicles.h deleted file mode 100644 index b0c03efd..00000000 --- a/src/shared/vehicles.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2016-2020 Marco Cawthorne - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -void Vehicle_Input(base_player); diff --git a/src/shared/vehicles.qc b/src/shared/vehicles.qc deleted file mode 100644 index 06742f37..00000000 --- a/src/shared/vehicles.qc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016-2020 Marco Cawthorne - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -void -Vehicle_Input(base_player bp) -{ - player pl = (player)bp; - - if (pl.vehicle) { - NSVehicle veh = (NSVehicle)pl.vehicle; - - if (veh.PlayerInput) - veh.PlayerInput(); - } -};