Nuclide
Software Development Kit for id Tech
NSItem.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023-2024 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
17typedef enumflags
18{
19 ITEMFL_CHANGED_MODELINDEX,
20 ITEMFL_CHANGED_ORIGIN_X,
21 ITEMFL_CHANGED_ORIGIN_Y,
22 ITEMFL_CHANGED_ORIGIN_Z,
23 ITEMFL_CHANGED_ANGLES_X,
24 ITEMFL_CHANGED_ANGLES_Y,
25 ITEMFL_CHANGED_ANGLES_Z,
26 ITEMFL_CHANGED_VELOCITY_X,
27 ITEMFL_CHANGED_VELOCITY_Y,
28 ITEMFL_CHANGED_VELOCITY_Z,
29 ITEMFL_CHANGED_ANGULARVELOCITY,
30 ITEMFL_CHANGED_SIZE,
31 ITEMFL_CHANGED_FLAGS,
32 ITEMFL_CHANGED_SOLID,
33 ITEMFL_CHANGED_FRAME,
34 ITEMFL_CHANGED_SKIN,
35 ITEMFL_CHANGED_MOVETYPE,
36 ITEMFL_CHANGED_EFFECTS,
37 ITEMFL_CHANGED_SCALE,
38 ITEMFL_CHANGED_ENTITYDEF,
39 ITEMFL_CHANGED_CHAIN,
40} nsitem_changed_t;
41
68{
69public:
70 void NSItem(void);
71
72 /* overrides */
73#ifdef SERVER
74 virtual void Spawned(void);
75 virtual void Touch(entity);
76 virtual void Respawn(void);
77 virtual void SpawnKey(string, string);
78 virtual void Save(float);
79 virtual void Restore(string,string);
80 virtual void EvaluateEntity(void);
81 virtual float SendEntity(entity,float);
82
83 /* item related accessors */
84 nonvirtual void SetItem(int i);
85 nonvirtual int GetItem(void);
86 nonvirtual void SetFloating(int);
87 nonvirtual bool GetFloating(void);
88 nonvirtual void SetSpinning(bool);
89 nonvirtual bool GetSpinning(void);
90 nonvirtual void PickupRespawn(void);
91
92 /* only if the entity is usable in the inventory. */
93 virtual void OnInventoryUse(void);
94
96 virtual void OnPickup(void);
97
98 virtual void PrintDebugInfo(void);
100 nonvirtual void BecomePickup(void);
101#endif
102
104 virtual void AddedToInventory(void);
106 virtual void RemovedFromInventory(void);
107
108#ifdef CLIENT
109 virtual void ReceiveEntity(float,float);
110 virtual void ReceiveEvent(float);
111 virtual void PredictPreFrame(void);
112 virtual void PredictPostFrame(void);
113#endif
114
115 virtual bool IsWeapon(void);
116
117private:
119 nonvirtual void _AddedCallback(void);
121 nonvirtual void _RemovedCallback(void);
122
123 int m_iClip;
124 int m_iWasDropped;
125
126 /* item related spawn keys */
127 int m_iInvItem;
128 string m_sndAcquire;
129 string m_sndRespawn;
130 string m_sndHum;
131 int m_bFloating;
132 bool m_bSpins;
133 string m_strInvName;
134 string m_strInvWeapon;
135
136 int m_iGiveHealth;
137 int m_iGiveArmor;
138 bool m_bNoTouch;
139 bool m_bInvCarry;
140 string m_strRequires;
141
142 int m_GiveAmmo[MAX_AMMO_TYPES];
143
144#ifdef CLIENT
145 NETWORKED_FLOAT(chain_entnum)
146 NETWORKED_FLOAT(owner_entnum)
147#endif
148
149 entity chain_net;
150 entity owner_net;
151};
typedef enumflags
Definition: NSItem.h:18
This entity class represents inventory items, weapons.
Definition: NSItem.h:68
nonvirtual int GetItem(void)
Definition: NSItem.qc:240
nonvirtual void SetSpinning(bool)
Definition: NSItem.qc:257
virtual void OnInventoryUse(void)
Definition: NSItem.qc:282
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
Definition: NSItem.qc:150
nonvirtual void SetFloating(int)
Definition: NSItem.qc:245
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: NSItem.qc:316
virtual void PredictPreFrame(void)
Definition: NSItem.qc:454
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSItem.qc:129
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: NSItem.qc:48
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
Definition: NSItem.qc:362
nonvirtual bool GetFloating(void)
Definition: NSItem.qc:251
virtual void RemovedFromInventory(void)
Called when an item was removed from someones inventory.
Definition: NSItem.qc:508
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: NSItem.qc:398
virtual void OnPickup(void)
Overridable: Called when this item is picked up.
Definition: NSItem.qc:277
virtual bool IsWeapon(void)
Definition: NSItem.qc:516
virtual void PrintDebugInfo(void)
Definition: NSItem.qc:287
virtual void AddedToInventory(void)
Called when an item was added to someones inventory.
Definition: NSItem.qc:503
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSItem.qc:72
nonvirtual bool GetSpinning(void)
Definition: NSItem.qc:263
virtual void PredictPostFrame(void)
Definition: NSItem.qc:484
void NSItem(void)
Definition: NSItem.qc:18
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: NSItem.qc:38
virtual void ReceiveEvent(float)
Definition: NSItem.qc:449
nonvirtual void PickupRespawn(void)
Definition: NSItem.qc:270
nonvirtual void BecomePickup(void)
Call to turn a weapon into a pickup.
Definition: NSItem.qc:301
nonvirtual void SetItem(int i)
Definition: NSItem.qc:231
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: NSItem.qc:203
This entity represents any NSEntity with advanced rendering properties.
Definition: NSRenderableEntity.h:94
#define MAX_AMMO_TYPES
Definition: defs.h:69
#define NETWORKED_FLOAT(x)
Definition: defs.h:21