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 NETWORKED_FLOAT_N(colormap)
266 NETWORKED_FLOAT_N(gflags)
267 NETWORKED_FLOAT(viewzoom)
268 NETWORKED_VECTOR_N(view_ofs)
269 NETWORKED_FLOAT_N(vw_index)
270 NETWORKED_VECTOR_N(m_pmoveBaseVelocity)
271 NETWORKED_VECTOR_N(v_angle)
272 NETWORKED_FLOAT_N(gravity)
273 NETWORKED_FLOAT_N(friction)
274 NETWORKED_FLOAT(speedmod)
275
276 NETWORKED_VECTOR_N(m_pmoveLadderNormal)
277
278 NETWORKED_FLOAT(m_timeUntilNextAttack)
279 NETWORKED_FLOAT(m_timeUntilNextIdle)
280 NETWORKED_FLOAT(m_timeUntilReloaded)
281 NETWORKED_FLOAT(m_timeSinceJump)
282 NETWORKED_FLOAT(m_timeSinceTeleport)
283 NETWORKED_VECTOR(m_punchAngle)
284 NETWORKED_VECTOR(m_punchVelocity)
285
286 NETWORKED_INT(m_weaponAnimSequence)
287 NETWORKED_FLOAT(m_weaponAnimTime)
288
289 /* We can't use the default .items field, because FTE will assume
290 * effects of some bits. Such as invisibility, quad, etc.
291 * also, modders probably want 32 bits for items. */
292 NETWORKED_FLOAT_N(activeweapon)
293 ncItem m_itemList_net;
294 int m_ammoTypes_net[MAX_AMMO_TYPES];
295
296 /* vehicle info */
297 NETWORKED_ENT(vehicle)
298 NETWORKED_VECTOR(m_pmoveHookVelocity)
299
300#ifdef CLIENT
301 int sequence;
302
303 /* external weapon model */
304 ncRenderableEntity p_model;
305 int p_hand_bone;
306 int p_model_bone;
307 float lastweapon;
308#endif
309 ncPMoveVars m_pmoveVars;
310
311#ifdef SERVER
312 int voted;
313 int step;
314 float m_timeUntilNextFootstep;
315
316 int m_underwaterDamageDealt;
317 float m_timeUnderwater;
318 float m_timeUntilNextPainSFX;
319
320 entity last_used;
321
322 float pb_angle_delta;
323 float pb_player_delta;
324 vector pb_last_angles;
325
326 int m_friendlyFireDamageDealt;
327#endif
328
329 entity m_holdingEntity;
330
331
332
333 virtual void Event_DrawWeapon(void);
334 virtual void Event_FireWeapon(void);
335 virtual void Event_ReloadWeaponStart(void);
336 virtual void Event_ReloadWeapon(void);
337 virtual void Event_ReloadWeaponEnd(void);
338 virtual void Event_HolsterWeapon(void);
339};
340
341/* all potential SendFlags bits we can possibly send */
343{
344 PLAYER_MODELINDEX,
345 PLAYER_ORIGIN,
346 PLAYER_ANGLES,
347 PLAYER_VELOCITY,
348 PLAYER_FLAGS,
349 PLAYER_WEAPON,
350 PLAYER_ITEMS,
351 PLAYER_HEALTH,
352 PLAYER_SIZE,
353 PLAYER_MOVETYPE,
354 PLAYER_PUNCHANGLE,
355 PLAYER_VIEWZOOM,
356 PLAYER_TIMINGS,
357 PLAYER_VEHICLE,
358 PLAYER_SPECTATE,
359 PLAYER_AMMOTYPES,
360 PLAYER_WEAPONFRAME,
361 PLAYER_TOPFRAME,
362 PLAYER_BOTTOMFRAME,
363 PLAYER_CUSTOMFIELDSTART,
364};
365
366.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: PMoveVars.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:95
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