Nuclide
Software Development Kit for id Technology (BETA)
Player.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
140class
142{
143public:
144 void ncPlayer(void);
145
146 virtual void PlayGesture(float gestureAnim, float overrideTime);
147
148 virtual void ProcessInput(void);
149 virtual void PreFrame(void);
150 virtual void PostFrame(void);
151
152 virtual void Physics_Fall(float);
153 virtual void Physics_Crouch(void);
154 virtual void Physics_Prone(void);
155 virtual void Physics_Jump(void);
156 virtual void Physics_CheckJump(float);
157 virtual void Physics_SetViewParms(void);
158 virtual void Physics_WaterJump(void);
159 virtual void Physics_WaterMove(void);
160 virtual float Physics_MaxSpeed(void);
161 virtual void Physics_InputPreMove(void);
162 virtual void Physics_InputPostMove(void);
163 virtual void Physics_Run(void);
164
165 virtual bool IsFakeSpectator(void);
166 virtual bool IsRealSpectator(void);
167 virtual bool IsDead(void);
168 virtual bool IsPlayer(void);
169 virtual void SharedInputFrame(void);
170
172 virtual bool CanSprint(void);
174 virtual bool CanProne(void);
176 virtual bool CanCrouch(void);
178 virtual bool CanLean(void);
179
181 virtual void UpdatePlayerAnimation(float);
182
183 virtual void Damage(entity, entity, ncDict, float, vector, vector);
184 virtual bool CanPickupEntity(ncEntity toPickUp, float massLimit, float sizeLimit);
185
186#ifdef CLIENT
187 virtual void VehicleRelink(void);
188 virtual void OnRemoveEntity(void);
189 virtual void ReceiveEntity(float,float);
190 virtual void _ReceiveComplete(float, float);
191 virtual void PredictPreFrame(void);
192 virtual void PredictPostFrame(void);
193 virtual void ClientInputFrame(void);
194
195 virtual vector CalculateLean(vector);
196 virtual void UpdateAliveCam(void);
197
199 virtual void UpdatePlayerJaw(float);
200
202 virtual void UpdatePlayerAttachments(bool);
203
204 virtual float predraw(void);
205 virtual void postdraw(void);
206
207#endif
208
209#ifdef SERVER
210 /* overrides */
211 virtual void Save(float);
212 virtual void Restore(string,string);
213 virtual void Spawned(void);
214 virtual void Respawn(void);
215 virtual void EvaluateEntity(void);
216 virtual float SendEntity(entity,float);
217 virtual void Death(entity, entity, int, vector, vector, int);
218 virtual void ServerInputFrame(void);
219 virtual void Input(entity, string, string);
220
222 virtual float OptimiseChangedFlags(entity,float);
223
225 virtual void MakePlayer(void);
227 virtual void MakeTempSpectator(void);
229 virtual void MakeSpectator(void);
230
232 virtual void InputUse_Down(void);
234 virtual void InputUse_Up(void);
235
236 /* 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. */
237 virtual bool CanPickupEntity(ncEntity, float, float);
238 /* 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.*/
239 nonvirtual void PickupEntity(ncEntity);
240
241#endif
242
243 nonvirtual float WeaponAnimTime(void);
244
245 virtual void Footsteps_Update(void);
246
247private:
248 nonvirtual void _UpdatePMoveVars(void);
249
250#ifdef CLIENT
251 NETWORKED_INT(m_weaponAnimSequence)
252 NETWORKED_FLOAT(vehicle_entnum)
253#endif
254
255#ifdef SERVER
256 float m_weaponCookingTime;
257#endif
258
259 NETWORKED_FLOAT(health)
260
261 /* animation */
262 PREDICTED_FLOAT(anim_top)
263 PREDICTED_FLOAT(anim_top_time)
264 PREDICTED_FLOAT(anim_top_delay)
265 PREDICTED_FLOAT(anim_bottom)
266 PREDICTED_FLOAT(anim_bottom_time)
267
268 NETWORKED_FLOAT_N(colormap)
269 NETWORKED_FLOAT_N(gflags)
270 NETWORKED_FLOAT(viewzoom)
271 NETWORKED_VECTOR_N(view_ofs)
272 NETWORKED_VECTOR_N(m_pmoveBaseVelocity)
273 NETWORKED_VECTOR_N(v_angle)
274 NETWORKED_FLOAT_N(gravity)
275 NETWORKED_FLOAT_N(friction)
276
277 NETWORKED_FLOAT(m_timeUntilNextAttack)
278 NETWORKED_FLOAT(m_timeUntilNextIdle)
279 NETWORKED_FLOAT(m_timeUntilReloaded)
280 NETWORKED_FLOAT(m_timeSinceJump)
281 NETWORKED_FLOAT(m_timeSinceTeleport)
282 NETWORKED_VECTOR(m_punchAngle)
283 NETWORKED_VECTOR(m_punchVelocity)
284
285 NETWORKED_INT(m_weaponAnimSequence)
286 NETWORKED_FLOAT(m_weaponAnimTime)
287
288 /* We can't use the default .items field, because FTE will assume
289 * effects of some bits. Such as invisibility, quad, etc.
290 * also, modders probably want 32 bits for items. */
291 NETWORKED_FLOAT_N(activeweapon)
292 ncItem m_itemList_net;
293 int m_ammoTypes_net[MAX_AMMO_TYPES];
294
295 /* vehicle info */
296 NETWORKED_ENT(vehicle)
297 NETWORKED_VECTOR(m_pmoveHookVelocity)
298
299#ifdef CLIENT
300 int sequence;
301
302 /* external weapon model */
303 ncRenderableEntity p_model;
304 int p_hand_bone;
305 int p_model_bone;
306 float lastweapon;
307#endif
308 ncPMoveVars m_pmoveVars;
309
310#ifdef SERVER
311 int voted;
312 int step;
313 float m_timeUntilNextFootstep;
314
315 int m_underwaterDamageDealt;
316 float m_timeUnderwater;
317 float m_timeUntilNextPainSFX;
318
319 entity last_used;
320
321 float pb_angle_delta;
322 float pb_player_delta;
323 vector pb_last_angles;
324
325 int m_friendlyFireDamageDealt;
326#endif
327
328 entity m_holdingEntity;
329
330
331
332 virtual void Event_DrawWeapon(void);
333 virtual void Event_FireWeapon(void);
334 virtual void Event_ReloadWeaponStart(void);
335 virtual void Event_ReloadWeapon(void);
336 virtual void Event_ReloadWeaponEnd(void);
337 virtual void Event_HolsterWeapon(void);
338};
339
340/* all potential SendFlags bits we can possibly send */
342{
343 PLAYER_MODELINDEX,
344 PLAYER_ORIGIN,
345 PLAYER_ANGLES,
346 PLAYER_VELOCITY,
347 PLAYER_FLAGS,
348 PLAYER_WEAPON,
349 PLAYER_ITEMS,
350 PLAYER_HEALTH,
351 PLAYER_SIZE,
352 PLAYER_MOVETYPE,
353 PLAYER_PUNCHANGLE,
354 PLAYER_VIEWZOOM,
355 PLAYER_TIMINGS,
356 PLAYER_VEHICLE,
357 PLAYER_SPECTATE,
358 PLAYER_AMMOTYPES,
359 PLAYER_WEAPONFRAME,
360 PLAYER_TOPFRAME,
361 PLAYER_BOTTOMFRAME,
362 PLAYER_CUSTOMFIELDSTART,
363};
364
365.bool _isPlayer;
This class is responsible for handling groups of key/value pairs.
Definition: Dict.h:42
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
This entity class represents inventory items, weapons.
Definition: Item.h:138
This class networks pmove related variables to each client.
Definition: pmove.h:45
This entity class represents every player client.
Definition: Player.h:142
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: RenderableEntity.h:94
This entity class represents every spectator client.
Definition: Spectator.h:69
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37