Nuclide
Software Development Kit for id Technology (BETA)
Vehicle.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_ncVehicle_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 ncVehicle_Log(...) if (autocvar_vehicle_developer == true) _ncVehicle_Log(classname, __FUNC__, num_for_edict(this), sprintf(__VA_ARGS__))
27
33{
34public:
35 void ncVehicle(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 virtual void Input(entity eAct, string strInput, string strData);
56#endif
57
58 nonvirtual entity GetDriver(void);
59 virtual void PlayerUpdateFlags(void);
60 virtual void PlayerAlign(void);
61 virtual void PlayerEnter(ncPlayer);
62 virtual void PlayerLeave(ncPlayer);
63 virtual void PlayerInput(void);
64 virtual float DriverAnimation(void);
65
66 virtual bool CanDriverCrouch(void);
67 virtual bool PreventPlayerMovement(void);
68 virtual bool PreventPlayerFire(void);
69
70private:
71 int m_iVehicleFlags;
72 int m_iMoveButtons;
73 vector m_vecMoveValues;
74 ncEntity m_eDriver;
75 ncEntity m_eDriver_net;
76 ncEntity m_eDriverLast;
77 vector m_vecPlayerPos;
78 vector m_vecExitPos;
79
80 /* FIXME: Aren't those already defined in parent classes? */
81 NETWORKED_VECTOR_N(angles)
82 NETWORKED_VECTOR_N(origin)
83 NETWORKED_VECTOR_N(velocity)
84
85#ifdef CLIENT
86 NETWORKED_FLOAT(driver_entnum)
87#endif
88};
89
91{
92 VEHFL_CHANGED_ORIGIN,
93 VEHFL_CHANGED_ANGLES,
94 VEHFL_CHANGED_MODELINDEX,
95 VEHFL_CHANGED_SOLID,
96 VEHFL_CHANGED_MOVETYPE,
97 VEHFL_CHANGED_SIZE,
98 VEHFL_CHANGED_VELOCITY,
99 VEHFL_CHANGED_DRIVER
100};
101
103{
104 VHF_FROZEN,
105 VHF_NOATTACK
106};
107
131{
132private:
133 /* map-entity fields */
134 vector m_vecSeatOffest;
135
136 vector m_vecControlMins;
137 vector m_vecControlMaxs;
138
139 float m_flUseTime;
140 NETWORKED_VECTOR(vehicleOrigin)
141 NETWORKED_VECTOR(vehicleAngles)
142 NETWORKED_FLOAT(m_flTurn)
143 vector m_firstPersonOrg;
144
145#ifdef SERVER
146 vector entryPosition;
147#endif
148
149public:
150 void ncVehicleSeat(void);
151
152 virtual void Physics(void);
153 virtual void PlayerInput(void);
154 virtual void OnRemoveEntity(void);
155
156
157#ifdef CLIENT
158 virtual bool HideViewWeapon(void);
159 virtual void PredictPreFrame(void);
160 virtual void PredictPostFrame(void);
161 virtual void ReceiveEntity(float,float);
162 virtual void UpdateView(void);
163#endif
164
165#ifdef SERVER
166 virtual void Respawn(void);
167 virtual void OnPlayerUse(void);
168 virtual void EvaluateEntity(void);
169 virtual float SendEntity(entity,float);
170 virtual void SpawnKey(string keyName, string setValue);
171#endif
172};
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
This entity class represents every player client.
Definition: Player.h:142
This entity represents an ncRenderableEntity with interactive surface properties.
Definition: SurfacePropEntity.h:71
Shared-Entity: Model Based Vehicle.
Definition: Vehicle.h:131
virtual void PredictPostFrame(void)
Definition: VehicleSeat.qc:121
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: VehicleSeat.qc:329
virtual void PredictPreFrame(void)
Definition: VehicleSeat.qc:109
virtual void PlayerInput(void)
Definition: VehicleSeat.qc:140
virtual void SpawnKey(string keyName, string setValue)
This method handles entity key/value pairs on map load.
Definition: VehicleSeat.qc:284
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
Definition: VehicleSeat.qc:294
void ncVehicleSeat(void)
Definition: VehicleSeat.qc:36
virtual void UpdateView(void)
Definition: VehicleSeat.qc:84
virtual void OnPlayerUse(void)
Definition: VehicleSeat.qc:164
virtual bool HideViewWeapon(void)
Definition: VehicleSeat.qc:44
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: VehicleSeat.qc:224
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition: VehicleSeat.qc:76
virtual void Physics(void)
Definition: VehicleSeat.qc:51
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: VehicleSeat.qc:200
This entity class represents vehicles that are predicted across the network.
Definition: Vehicle.h:33
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
virtual void PredictPreFrame(void)
Definition: Vehicle.qc:166
virtual bool PreventPlayerMovement(void)
Definition: Vehicle.qc:97
nonvirtual entity GetDriver(void)
Definition: Vehicle.qc:115
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: Vehicle.qc:192
virtual bool CanDriverCrouch(void)
Definition: Vehicle.qc:91
virtual bool HidePlayermodel(void)
Definition: Vehicle.qc:132
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: Vehicle.qc:34
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: Vehicle.qc:47
virtual bool IsLocalDriver(void)
Definition: Vehicle.qc:150
virtual void PlayerEnter(ncPlayer)
Definition: Vehicle.qc:437
virtual float DriverAnimation(void)
Definition: Vehicle.qc:109
virtual void PlayerUpdateFlags(void)
Definition: Vehicle.qc:409
virtual void DriverRelink(void)
Definition: Vehicle.qc:138
virtual bool PreventPlayerFire(void)
Definition: Vehicle.qc:103
virtual void UpdateView(void)
Definition: Vehicle.qc:161
virtual void PlayerInput(void)
Definition: Vehicle.qc:403
virtual void PlayerLeave(ncPlayer)
Definition: Vehicle.qc:462
virtual bool HideCrosshair(void)
Definition: Vehicle.qc:127
virtual void Input(entity eAct, string strInput, string strData)
Called when we are being prompted by another object/function with an input message.
Definition: Vehicle.qc:77
nonvirtual vector GetExitPos(void)
virtual bool HideViewWeapon(void)
Definition: Vehicle.qc:122
virtual void PredictPostFrame(void)
Definition: Vehicle.qc:179
void ncVehicle(void)
Definition: Vehicle.qc:20
virtual void PlayerAlign(void)
Definition: Vehicle.qc:419
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37