Nuclide
Software Development Kit for id Technology
NSClientPlayer.h
1/*
2 * Copyright (c) 2016-2022 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
17noref .vector v_angle;
18
26class
28{
29public:
30 void NSClientPlayer(void);
31
32 virtual void ProcessInput(void);
33 virtual void PreFrame(void);
34 virtual void PostFrame(void);
35
36 virtual void Physics_Fall(float);
37 virtual void Physics_Crouch(void);
38 virtual void Physics_Prone(void);
39 virtual void Physics_Jump(void);
40 virtual void Physics_CheckJump(float);
41 virtual void Physics_SetViewParms(void);
42 virtual void Physics_WaterJump(void);
43 virtual void Physics_WaterMove(void);
44 virtual float Physics_MaxSpeed(void);
45 virtual void Physics_InputPreMove(void);
46 virtual void Physics_InputPostMove(void);
47 virtual void Physics_Run(void);
48
49 virtual bool IsFakeSpectator(void);
50 virtual bool IsRealSpectator(void);
51 virtual bool IsDead(void);
52 virtual bool IsPlayer(void);
53 virtual void SharedInputFrame(void);
54
56 virtual bool CanSprint(void);
58 virtual bool CanProne(void);
60 virtual bool CanCrouch(void);
62 virtual bool CanLean(void);
63
65 virtual void UpdatePlayerAnimation(float);
66
67 virtual void Damage(entity, entity, NSDict, float, vector, vector);
68
69#ifdef CLIENT
70 virtual void VehicleRelink(void);
71 virtual void OnRemoveEntity(void);
72 virtual void ReceiveEntity(float,float);
73 virtual void _ReceiveComplete(float, float);
74 virtual void PredictPreFrame(void);
75 virtual void PredictPostFrame(void);
76 virtual void ClientInputFrame(void);
77
78 virtual vector CalculateLean(vector);
79 virtual void UpdateAliveCam(void);
80
82 virtual void UpdatePlayerJaw(float);
83
85 virtual void UpdatePlayerAttachments(bool);
86
87 virtual float predraw(void);
88 virtual void postdraw(void);
89
90#endif
91
92#ifdef SERVER
93 /* overrides */
94 virtual void Save(float);
95 virtual void Restore(string,string);
96 virtual void Spawned(void);
97 virtual void Respawn(void);
98 virtual void EvaluateEntity(void);
99 virtual float SendEntity(entity,float);
100 virtual void Death(entity, entity, int, vector, vector, int);
101 virtual void ServerInputFrame(void);
102 virtual void Input(entity, string, string);
103
105 virtual float OptimiseChangedFlags(entity,float);
106
108 virtual void MakePlayer(void);
110 virtual void MakeTempSpectator(void);
112 virtual void MakeSpectator(void);
113
115 virtual void InputUse_Down(void);
117 virtual void InputUse_Up(void);
118
119 /* Returns whether we're able to pick up an entity in the game with +use. If `true` you can then use PickupEntity() to attach it to the player. */
120 virtual bool CanPickupEntity(NSEntity, float, float);
121 /* Will attach an entity to the player. It's position will continously update in front of the player camera, but in XR modes it may be attached to one of the hands instead.*/
122 nonvirtual void PickupEntity(NSEntity);
123
124#endif
125
126 virtual void Footsteps_Update(void);
127
128 nonvirtual void _UpdatePMoveVars(void);
129
130private:
131
132#ifdef CLIENT
133 NETWORKED_INT(weaponframe)
134 NETWORKED_FLOAT(vehicle_entnum)
135#endif
136
137#ifdef SERVER
138 NETWORKED_INT_N(weaponframe)
139 float nadeCookingTime;
140#endif
141
142 NETWORKED_FLOAT(health)
143
144 NETWORKED_FLOAT_N(colormap)
145 NETWORKED_FLOAT_N(gflags)
146 NETWORKED_FLOAT(viewzoom)
147 NETWORKED_VECTOR_N(view_ofs)
148 NETWORKED_VECTOR_N(basevelocity)
149 NETWORKED_VECTOR_N(v_angle)
150 NETWORKED_FLOAT_N(gravity)
151 NETWORKED_FLOAT_N(friction)
152
153 NETWORKED_FLOAT(w_attack_next)
154 NETWORKED_FLOAT(w_idle_next)
155 NETWORKED_FLOAT(w_reload_next)
156 NETWORKED_FLOAT(jump_time)
157 NETWORKED_FLOAT(teleport_time)
158 NETWORKED_FLOAT(weapontime)
159 NETWORKED_VECTOR(punchangle)
160 NETWORKED_VECTOR(punchvelocity)
161
162 /* We can't use the default .items field, because FTE will assume
163 * effects of some bits. Such as invisibility, quad, etc.
164 * also, modders probably want 32 bits for items. */
165 NETWORKED_INT(g_items)
166 NETWORKED_FLOAT_N(activeweapon)
167 NSItem m_itemList_net;
168 int m_iAmmoTypes_net[MAX_AMMO_TYPES];
169
170
171 /* vehicle info */
172 NETWORKED_ENT(vehicle)
173
174 /* these are NOT networked */
175 int a_ammo1;
176 int a_ammo2;
177 int a_ammo3;
178
179 NETWORKED_VECTOR(grapvelocity)
180
181#ifdef CLIENT
182 int sequence;
183
184 /* external weapon model */
185 NSRenderableEntity p_model;
186 int p_hand_bone;
187 int p_model_bone;
188 float lastweapon;
189#endif
190 NSPMoveVars m_pmoveVars;
191
192#ifdef SERVER
193 int voted;
194 int step;
195 float step_time;
196
197 int m_iUnderwaterDamage;
198 float m_flUnderwaterTime;
199 float m_flPainTime;
200
201 entity last_used;
202
203 float pb_angle_delta;
204 float pb_player_delta;
205 vector pb_last_angles;
206
207 int m_iFriendlyDMG;
208#endif
209
210 entity m_holdingEntity;
211};
212
213/* all potential SendFlags bits we can possibly send */
215{
216 PLAYER_MODELINDEX,
217 PLAYER_ORIGIN,
218 PLAYER_ANGLES,
219 PLAYER_VELOCITY,
220 PLAYER_FLAGS,
221 PLAYER_WEAPON,
222 PLAYER_ITEMS,
223 PLAYER_HEALTH,
224 PLAYER_SIZE,
225 PLAYER_MOVETYPE,
226 PLAYER_PUNCHANGLE,
227 PLAYER_VIEWZOOM,
228 PLAYER_TIMINGS,
229 PLAYER_VEHICLE,
230 PLAYER_SPECTATE,
231 PLAYER_AMMOTYPES,
232 PLAYER_WEAPONFRAME,
233 PLAYER_CUSTOMFIELDSTART,
234};
235
236#ifdef SERVER
237void obituary(string, string, string, string);
238#endif
This entity class represents every player client.
Definition: NSClientPlayer.h:28
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
virtual void Spawned(void)
Called when the entity is fulled initialized.
virtual float OptimiseChangedFlags(entity, float)
Helper function that will optimise the changed-flags of your player entity.
virtual void ServerInputFrame(void)
Server: This is where the input* variables arrive after sending them out from the client (see ClientI...
virtual void InputUse_Up(void)
Called when we let go of the button bound to +use.
virtual void Death(entity, entity, int, vector, vector, int)
Called when the health is equal or below 0.
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
virtual void InputUse_Down(void)
Called when we press the button bound to +use.
virtual void MakeTempSpectator(void)
When called, will turn the client into a spectator until the next round.
virtual void MakePlayer(void)
When called, will turn the client into a proper player.
nonvirtual void PickupEntity(NSEntity)
virtual void MakeSpectator(void)
When called, will turn the client into a general spectator.
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
This entity class represents every spectator client.
Definition: NSClientSpectator.h:69
This class is responsible for handling groups of key/value pairs.
Definition: NSDict.h:42
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
This entity class represents inventory items, weapons.
Definition: NSItem.h:67
This class networks pmove related variables to each client.
Definition: pmove.h:45
This entity represents any NSEntity with advanced rendering properties.
Definition: NSRenderableEntity.h:94
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37