Nuclide
Software Development Kit for id Technology (BETA)
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 ncPlayer(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, ncDict, float, vector, vector);
68 virtual bool CanPickupEntity(ncEntity toPickUp, float massLimit, float sizeLimit);
69
70#ifdef CLIENT
71 virtual void VehicleRelink(void);
72 virtual void OnRemoveEntity(void);
73 virtual void ReceiveEntity(float,float);
74 virtual void _ReceiveComplete(float, float);
75 virtual void PredictPreFrame(void);
76 virtual void PredictPostFrame(void);
77 virtual void ClientInputFrame(void);
78
79 virtual vector CalculateLean(vector);
80 virtual void UpdateAliveCam(void);
81
83 virtual void UpdatePlayerJaw(float);
84
86 virtual void UpdatePlayerAttachments(bool);
87
88 virtual float predraw(void);
89 virtual void postdraw(void);
90
91#endif
92
93#ifdef SERVER
94 /* overrides */
95 virtual void Save(float);
96 virtual void Restore(string,string);
97 virtual void Spawned(void);
98 virtual void Respawn(void);
99 virtual void EvaluateEntity(void);
100 virtual float SendEntity(entity,float);
101 virtual void Death(entity, entity, int, vector, vector, int);
102 virtual void ServerInputFrame(void);
103 virtual void Input(entity, string, string);
104
106 virtual float OptimiseChangedFlags(entity,float);
107
109 virtual void MakePlayer(void);
111 virtual void MakeTempSpectator(void);
113 virtual void MakeSpectator(void);
114
116 virtual void InputUse_Down(void);
118 virtual void InputUse_Up(void);
119
120 /* 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. */
121 virtual bool CanPickupEntity(ncEntity, float, float);
122 /* 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.*/
123 nonvirtual void PickupEntity(ncEntity);
124
125#endif
126
127 virtual void Footsteps_Update(void);
128
129 nonvirtual void _UpdatePMoveVars(void);
130
131private:
132
133#ifdef CLIENT
134 NETWORKED_INT(weaponframe)
135 NETWORKED_FLOAT(vehicle_entnum)
136#endif
137
138#ifdef SERVER
139 NETWORKED_INT_N(weaponframe)
140 float nadeCookingTime;
141#endif
142
143 NETWORKED_FLOAT(health)
144
145 NETWORKED_FLOAT_N(colormap)
146 NETWORKED_FLOAT_N(gflags)
147 NETWORKED_FLOAT(viewzoom)
148 NETWORKED_VECTOR_N(view_ofs)
149 NETWORKED_VECTOR_N(basevelocity)
150 NETWORKED_VECTOR_N(v_angle)
151 NETWORKED_FLOAT_N(gravity)
152 NETWORKED_FLOAT_N(friction)
153
154 NETWORKED_FLOAT(w_attack_next)
155 NETWORKED_FLOAT(w_idle_next)
156 NETWORKED_FLOAT(w_reload_next)
157 NETWORKED_FLOAT(jump_time)
158 NETWORKED_FLOAT(teleport_time)
159 NETWORKED_FLOAT(weapontime)
160 NETWORKED_VECTOR(punchangle)
161 NETWORKED_VECTOR(punchvelocity)
162
163 /* We can't use the default .items field, because FTE will assume
164 * effects of some bits. Such as invisibility, quad, etc.
165 * also, modders probably want 32 bits for items. */
166 NETWORKED_INT(g_items)
167 NETWORKED_FLOAT_N(activeweapon)
168 ncItem m_itemList_net;
169 int m_iAmmoTypes_net[MAX_AMMO_TYPES];
170
171
172 /* vehicle info */
173 NETWORKED_ENT(vehicle)
174
175 /* these are NOT networked */
176 int a_ammo1;
177 int a_ammo2;
178 int a_ammo3;
179
180 NETWORKED_VECTOR(grapvelocity)
181
182#ifdef CLIENT
183 int sequence;
184
185 /* external weapon model */
186 ncRenderableEntity p_model;
187 int p_hand_bone;
188 int p_model_bone;
189 float lastweapon;
190#endif
191 ncPMoveVars m_pmoveVars;
192
193#ifdef SERVER
194 int voted;
195 int step;
196 float step_time;
197
198 int m_iUnderwaterDamage;
199 float m_flUnderwaterTime;
200 float m_flPainTime;
201
202 entity last_used;
203
204 float pb_angle_delta;
205 float pb_player_delta;
206 vector pb_last_angles;
207
208 int m_iFriendlyDMG;
209#endif
210
211 entity m_holdingEntity;
212};
213
214/* all potential SendFlags bits we can possibly send */
216{
217 PLAYER_MODELINDEX,
218 PLAYER_ORIGIN,
219 PLAYER_ANGLES,
220 PLAYER_VELOCITY,
221 PLAYER_FLAGS,
222 PLAYER_WEAPON,
223 PLAYER_ITEMS,
224 PLAYER_HEALTH,
225 PLAYER_SIZE,
226 PLAYER_MOVETYPE,
227 PLAYER_PUNCHANGLE,
228 PLAYER_VIEWZOOM,
229 PLAYER_TIMINGS,
230 PLAYER_VEHICLE,
231 PLAYER_SPECTATE,
232 PLAYER_AMMOTYPES,
233 PLAYER_WEAPONFRAME,
234 PLAYER_CUSTOMFIELDSTART,
235};
236
237#ifdef SERVER
238void obituary(string, string, string, string);
239#endif
This class is responsible for handling groups of key/value pairs.
Definition: NSDict.h:42
ncEntity 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 class represents every player client.
Definition: NSClientPlayer.h:28
virtual void InputUse_Up(void)
Called when we let go of the button bound to +use.
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
nonvirtual void PickupEntity(ncEntity)
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
virtual bool CanPickupEntity(ncEntity, float, float)
virtual float OptimiseChangedFlags(entity, float)
Helper function that will optimise the changed-flags of your player entity.
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
virtual void InputUse_Down(void)
Called when we press the button bound to +use.
virtual void MakePlayer(void)
When called, will turn the client into a proper player.
virtual void MakeTempSpectator(void)
When called, will turn the client into a spectator until the next round.
virtual void MakeSpectator(void)
When called, will turn the client into a general spectator.
virtual void Spawned(void)
Called when the entity is fulled initialized.
virtual void Death(entity, entity, int, vector, vector, int)
Called when the health is equal or below 0.
virtual void ServerInputFrame(void)
Server: This is where the input* variables arrive after sending them out from the client (see ClientI...
This entity represents any ncEntity with advanced rendering properties.
Definition: NSRenderableEntity.h:94
This entity class represents every spectator client.
Definition: NSClientSpectator.h:69
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37