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 virtual void Physics_InputSprint(void);
165
166 virtual bool IsFakeSpectator(void);
167 virtual bool IsRealSpectator(void);
168 virtual bool IsDead(void);
169 virtual bool IsPlayer(void);
170 virtual void SharedInputFrame(void);
171
173 virtual bool CanSprint(void);
175 virtual bool CanProne(void);
177 virtual bool CanCrouch(void);
179 virtual bool CanLean(void);
180
182 virtual void UpdatePlayerAnimation(float);
183
184 virtual void Damage(entity, entity, ncDict, float, vector, vector);
185 virtual bool CanPickupEntity(ncEntity toPickUp, float massLimit, float sizeLimit);
186
187#ifdef CLIENT
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 virtual void Spawned(void);
210
211#ifdef SERVER
212 /* overrides */
213 virtual void Save(float);
214 virtual void Restore(string,string);
215 virtual void Respawn(void);
216 virtual void EvaluateEntity(void);
217 virtual float SendEntity(entity,float);
218 virtual void Death(entity, entity, int, vector, vector, int);
219 virtual void ServerInputFrame(void);
220 virtual void Input(entity, string, string);
221
223 virtual float OptimiseChangedFlags(entity,float);
224
226 virtual void MakePlayer(void);
228 virtual void MakeTempSpectator(void);
230 virtual void MakeSpectator(void);
231
233 virtual void InputUse_Down(void);
235 virtual void InputUse_Up(void);
236
237 /* 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. */
238 virtual bool CanPickupEntity(ncEntity, float, float);
239 /* 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.*/
240 nonvirtual void PickupEntity(ncEntity);
241
242#endif
243
244 nonvirtual float WeaponAnimTime(void);
245
246 virtual void Footsteps_Update(void);
247
248private:
249 nonvirtual void _UpdatePMoveVars(void);
250
251#ifdef CLIENT
252 NETWORKED_INT(m_weaponAnimSequence)
253 NETWORKED_FLOAT(vehicle_entnum)
254
255 float clsndindex_idle;
256#endif
257
258#ifdef SERVER
259 float m_weaponCookingTime;
260#endif
261
262 NETWORKED_FLOAT(health)
263 NETWORKED_FLOAT(sndindex_idle)
264
265 /* animation */
266 NETWORKED_FLOAT(anim_top)
267 NETWORKED_FLOAT(anim_top_time)
268 NETWORKED_FLOAT(anim_top_delay)
269 NETWORKED_FLOAT(anim_bottom)
270 NETWORKED_FLOAT(anim_bottom_time)
271
272 NETWORKED_FLOAT_N(colormap)
273 NETWORKED_FLOAT_N(gflags)
274 NETWORKED_FLOAT(viewzoom)
275 NETWORKED_VECTOR_N(view_ofs)
276 NETWORKED_FLOAT_N(vw_index)
277 NETWORKED_VECTOR_N(m_pmoveBaseVelocity)
278 NETWORKED_VECTOR_N(v_angle)
279 NETWORKED_FLOAT_N(gravity)
280 NETWORKED_FLOAT_N(friction)
281 NETWORKED_FLOAT(speedmod)
282
283 NETWORKED_VECTOR_N(m_pmoveLadderNormal)
284
285 NETWORKED_FLOAT(m_timeUntilNextAttack)
286 NETWORKED_FLOAT(m_timeUntilNextIdle)
287 NETWORKED_FLOAT(m_timeUntilReloaded)
288 NETWORKED_FLOAT(m_timeSinceJump)
289 NETWORKED_FLOAT(m_timeSinceTeleport)
290 NETWORKED_VECTOR(m_punchAngle)
291 NETWORKED_VECTOR(m_punchVelocity)
292
293 NETWORKED_INT(m_weaponAnimSequence)
294 NETWORKED_FLOAT(m_weaponAnimTime)
295
296 /* We can't use the default .items field, because FTE will assume
297 * effects of some bits. Such as invisibility, quad, etc.
298 * also, modders probably want 32 bits for items. */
299 NETWORKED_FLOAT_N(activeweapon)
300 ncItem m_itemList_net;
301 int m_ammoTypes_net[MAX_AMMO_TYPES];
302
303 /* vehicle info */
304 NETWORKED_ENT(vehicle)
305 NETWORKED_VECTOR(m_pmoveHookVelocity)
306
307#ifdef CLIENT
308 int sequence;
309
310 /* external weapon model */
311 ncRenderableEntity p_model;
312 int p_hand_bone;
313 int p_model_bone;
314 float lastweapon;
315#endif
316 ncPMoveVars m_pmoveVars;
317
318#ifdef SERVER
319 int voted;
320 int step;
321 float m_timeUntilNextFootstep;
322
323 int m_underwaterDamageDealt;
324 float m_timeUnderwater;
325 float m_timeUntilNextPainSFX;
326
327 entity last_used;
328
329 float pb_angle_delta;
330 float pb_player_delta;
331 vector pb_last_angles;
332
333 int m_friendlyFireDamageDealt;
334#endif
335
336 entity m_holdingEntity;
337 NETWORKED_FLOAT(m_animBackend)
338
339
340
341 virtual void Event_DrawWeapon(void);
342 virtual void Event_FireWeapon(void);
343 virtual void Event_ReloadWeaponStart(void);
344 virtual void Event_ReloadWeapon(void);
345 virtual void Event_ReloadWeaponEnd(void);
346 virtual void Event_HolsterWeapon(void);
347
348 nonvirtual void UpdatePlayerAnimation_Skeletal(float timelength);
349 nonvirtual void UpdatePlayerAnimation_Goose(float timelength);
350 nonvirtual void UpdatePlayerAnimation_Valve(float timelength);
351};
352
353/* all potential SendFlags bits we can possibly send */
355{
356 PLAYER_MODELINDEX,
357 PLAYER_ORIGIN,
358 PLAYER_ANGLES,
359 PLAYER_VELOCITY,
360 PLAYER_FLAGS,
361 PLAYER_WEAPON,
362 PLAYER_ITEMS,
363 PLAYER_HEALTH,
364 PLAYER_SIZE,
365 PLAYER_MOVETYPE,
366 PLAYER_PUNCHANGLE,
367 PLAYER_VIEWZOOM,
368 PLAYER_TIMINGS,
369 PLAYER_VEHICLE,
370 PLAYER_SPECTATE,
371 PLAYER_AMMOTYPES,
372 PLAYER_WEAPONFRAME,
373 PLAYER_TOPFRAME,
374 PLAYER_BOTTOMFRAME,
375 PLAYER_CUSTOMFIELDSTART,
376};
377
378.bool _isPlayer;
This class is responsible for handling groups of key/value pairs.
Definition: Dict.h:35
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:46
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 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:60
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37