Nuclide
Software Development Kit for id Technology
NSVehicle.h
1/*
2 * Copyright (c) 2016-2024 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17var bool autocvar_vehicle_developer = false;
18void
19_NSVehicle_Log(string className, string functionName, float edictNum, string warnMessage)
20{
21 if (autocvar_g_logTimestamps)
22 printf("^9%f ^2%s (%d) ^7: %s\n", time, functionName, edictNum, warnMessage);
23 else
24 printf("^2%s (%d) ^7: %s\n", functionName, edictNum, warnMessage);
25}
26#define NSVehicle_Log(...) if (autocvar_vehicle_developer == true) _NSVehicle_Log(classname, __FUNC__, num_for_edict(this), sprintf(__VA_ARGS__))
27
33{
34public:
35 void NSVehicle(void);
36
37#ifdef CLIENT
38 virtual void DriverRelink(void);
39 virtual bool IsLocalDriver(void);
40 virtual void PredictPreFrame(void);
41 virtual void PredictPostFrame(void);
42 virtual void ReceiveEntity(float,float);
43 virtual void UpdateView(void);
44 virtual bool HideViewWeapon(void);
45 virtual bool HideCrosshair(void);
46 virtual bool HidePlayermodel(void);
47#endif
48
49#ifdef SERVER
50 nonvirtual vector GetExitPos(void);
51 virtual void EvaluateEntity(void);
52 virtual float SendEntity(entity,float);
53 virtual void Save(float);
54 virtual void Restore(string,string);
55#endif
56
57 nonvirtual entity GetDriver(void);
58 virtual void PlayerUpdateFlags(void);
59 virtual void PlayerAlign(void);
60 virtual void PlayerEnter(NSClientPlayer);
61 virtual void PlayerLeave(NSClientPlayer);
62 virtual void PlayerInput(void);
63 virtual float DriverAnimation(void);
64
65 virtual bool CanDriverCrouch(void);
66 virtual bool PreventPlayerMovement(void);
67 virtual bool PreventPlayerFire(void);
68
69private:
70 int m_iVehicleFlags;
71 int m_iMoveButtons;
72 vector m_vecMoveValues;
73 NSEntity m_eDriver;
74 NSEntity m_eDriver_net;
75 NSEntity m_eDriverLast;
76 vector m_vecPlayerPos;
77 vector m_vecExitPos;
78
79 /* FIXME: Aren't those already defined in parent classes? */
80 PREDICTED_VECTOR_N(angles)
81 PREDICTED_VECTOR_N(origin)
82 PREDICTED_VECTOR_N(velocity)
83
84#ifdef CLIENT
85 PREDICTED_FLOAT(driver_entnum)
86#endif
87};
88
90{
91 VEHFL_CHANGED_ORIGIN,
92 VEHFL_CHANGED_ANGLES,
93 VEHFL_CHANGED_MODELINDEX,
94 VEHFL_CHANGED_SOLID,
95 VEHFL_CHANGED_MOVETYPE,
96 VEHFL_CHANGED_SIZE,
97 VEHFL_CHANGED_VELOCITY,
98 VEHFL_CHANGED_DRIVER
99};
100
102{
103 VHF_FROZEN,
104 VHF_NOATTACK
105};
This entity class represents every player client.
Definition: NSClientPlayer.h:28
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
This entity represents an NSRenderableEntity with interactive surface properties.
Definition: NSSurfacePropEntity.h:52
This entity class represents vehicles that are predicted across the network.
Definition: NSVehicle.h:33
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: NSVehicle.qc:176
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSVehicle.qc:31
virtual float DriverAnimation(void)
Definition: NSVehicle.qc:93
virtual void PlayerEnter(NSClientPlayer)
Definition: NSVehicle.qc:424
void NSVehicle(void)
Definition: NSVehicle.qc:18
virtual void PlayerLeave(NSClientPlayer)
Definition: NSVehicle.qc:449
virtual void PlayerUpdateFlags(void)
Definition: NSVehicle.qc:396
virtual void PredictPostFrame(void)
Definition: NSVehicle.qc:163
virtual bool CanDriverCrouch(void)
Definition: NSVehicle.qc:75
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
virtual bool HideCrosshair(void)
Definition: NSVehicle.qc:111
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
Definition: NSVehicle.qc:44
nonvirtual vector GetExitPos(void)
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
virtual bool IsLocalDriver(void)
Definition: NSVehicle.qc:134
virtual bool PreventPlayerFire(void)
Definition: NSVehicle.qc:87
virtual void DriverRelink(void)
Definition: NSVehicle.qc:122
virtual void PredictPreFrame(void)
Definition: NSVehicle.qc:150
virtual bool HidePlayermodel(void)
Definition: NSVehicle.qc:116
virtual void PlayerAlign(void)
Definition: NSVehicle.qc:406
virtual void UpdateView(void)
Definition: NSVehicle.qc:145
virtual bool PreventPlayerMovement(void)
Definition: NSVehicle.qc:81
nonvirtual entity GetDriver(void)
Definition: NSVehicle.qc:99
virtual bool HideViewWeapon(void)
Definition: NSVehicle.qc:106
virtual void PlayerInput(void)
Definition: NSVehicle.qc:390
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37