NSVehicle: Add method CanDriverCrouch() to deal with player physics restrictions.
This commit is contained in:
parent
278d688159
commit
70f32c97a4
8 changed files with 31 additions and 58 deletions
|
@ -59,6 +59,8 @@ class NSVehicle:NSSurfacePropEntity
|
|||
virtual void(base_player) PlayerLeave;
|
||||
virtual void() PlayerInput;
|
||||
virtual float(void) DriverAnimation;
|
||||
|
||||
virtual bool(void) CanDriverCrouch;
|
||||
};
|
||||
|
||||
enumflags
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#include "platform.h"
|
||||
#include "propdata.h"
|
||||
#include "surfaceproperties.h"
|
||||
#include "vehicles.h"
|
||||
#include "colors.h"
|
||||
|
||||
#define BSPVER_PREREL 28
|
||||
|
|
|
@ -9,5 +9,4 @@ player.qc
|
|||
player_pmove.qc
|
||||
propdata.qc
|
||||
surfaceproperties.qc
|
||||
vehicles.qc
|
||||
#endlist
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
||||
*
|
||||
* 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);
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
||||
*
|
||||
* 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();
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue