Nuclide
Software Development Kit for id Technology (BETA)
Item.h
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,
27 ITEMFL_CHANGED_ANGULARVELOCITY,
28 ITEMFL_CHANGED_RENDERPROPS,
29 ITEMFL_CHANGED_SIZE,
30 ITEMFL_CHANGED_FLAGS,
31 ITEMFL_CHANGED_SOLID,
32 ITEMFL_CHANGED_FRAME,
33 ITEMFL_CHANGED_SKIN,
34 ITEMFL_CHANGED_MOVETYPE,
35 ITEMFL_CHANGED_EFFECTS,
36 ITEMFL_CHANGED_SCALE,
37 ITEMFL_CHANGED_ENTITYDEF,
38 ITEMFL_CHANGED_CHAIN,
39} nsitem_changed_t;
40
138{
139public:
140 void ncItem(void);
141
142 /* overrides */
143#ifdef SERVER
144 virtual void Spawned(void);
145 virtual bool ItemBonusCheck(entity);
146 virtual bool ItemPickupCheck(entity);
147 virtual void GiveBonusItems(entity);
148 virtual void Touch(entity);
149 virtual void Respawn(void);
150 virtual void SpawnKey(string, string);
151 virtual void Input(entity, string, string);
152 virtual void Save(float);
153 virtual void Restore(string,string);
154 virtual void EvaluateEntity(void);
155 virtual float SendEntity(entity,float);
156
157 /* item related accessors */
158 nonvirtual void SetFloating(int);
159 nonvirtual bool GetFloating(void);
160 nonvirtual void SetSpinning(bool);
161 nonvirtual bool GetSpinning(void);
162 nonvirtual void PickupRespawn(void);
163 nonvirtual void SetRespawnTime(float);
164
165 /* only if the entity is usable in the inventory. */
166 virtual void OnInventoryUse(void);
167
169 virtual void OnPickup(void);
170
172 virtual void OnUse(entity);
173
174 virtual void PrintDebugInfo(void);
176 nonvirtual void BecomePickup(void);
177#endif
178
180 virtual void AddedToInventory(void);
182 virtual void RemovedFromInventory(void);
183
184#ifdef CLIENT
185 virtual void ReceiveEntity(float,float);
186 virtual void ReceiveEvent(float);
187 virtual void PredictPreFrame(void);
188 virtual void PredictPostFrame(void);
189#endif
190
191 virtual bool IsWeapon(void);
192 virtual bool InInventory(void);
193
194 virtual void OnRemoveEntity(void);
195
196private:
198 virtual void _AddedCallback(void);
200 virtual void _RemovedCallback(void);
201
202 int m_itemWasDropped;
203
204 /* item related spawn keys */
205 string m_sndAcquire;
206 string m_sndRespawn;
207 float m_itemRespawn;
208 string m_sndHum;
209 int m_itemPickupFloats;
210 bool m_itemPickupSpins;
211 string m_itemName;
212 string m_itemWeapon;
213
214 int m_itemGivesHealth;
215 int m_itemGivesArmor;
216 int m_itemGivesBonusHealth;
217 int m_itemGivesBonusArmor;
218 bool m_itemNoTouch;
219 bool m_itemCarries;
220 string m_itemRequiresItem;
221
222 int m_itemGivesAmmo[MAX_AMMO_TYPES];
223
224#ifdef CLIENT
225 NETWORKED_FLOAT(chain_entnum)
226 NETWORKED_FLOAT(owner_entnum)
227#endif
228
229#ifdef SERVER
230 float m_hiddenModelIndex;
231 float m_hiddenSequence;
232#endif
233
234 ncItem m_nextItem;
235 ncItem m_nextItem_net;
236 entity owner_net;
237};
This entity class represents inventory items, weapons.
Definition: Item.h:138
virtual bool IsWeapon(void)
Definition: Item.qc:765
virtual void PredictPreFrame(void)
Definition: Item.qc:682
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: Item.qc:610
virtual void AddedToInventory(void)
Called when an item was added to someones inventory.
Definition: Item.qc:749
virtual void RemovedFromInventory(void)
Called when an item was removed from someones inventory.
Definition: Item.qc:754
virtual void OnUse(entity)
Overridable: Called when this item is used.
Definition: Item.qc:255
virtual void OnInventoryUse(void)
Definition: Item.qc:430
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: Item.qc:39
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: Item.qc:489
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: Item.qc:69
virtual bool ItemPickupCheck(entity)
Definition: Item.qc:303
nonvirtual bool GetFloating(void)
Definition: Item.qc:398
nonvirtual void BecomePickup(void)
Call to turn a weapon into a pickup.
Definition: Item.qc:447
virtual void PrintDebugInfo(void)
Definition: Item.qc:435
nonvirtual void SetRespawnTime(float)
Definition: Item.qc:261
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: Item.qc:242
nonvirtual void SetFloating(int)
Definition: Item.qc:392
nonvirtual void PickupRespawn(void)
Definition: Item.qc:417
virtual void PredictPostFrame(void)
Definition: Item.qc:723
nonvirtual void SetSpinning(bool)
Definition: Item.qc:404
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: Item.qc:322
nonvirtual bool GetSpinning(void)
Definition: Item.qc:410
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: Item.qc:175
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: Item.qc:143
void ncItem(void)
Definition: Item.qc:18
virtual void OnPickup(void)
Overridable: Called when this item is picked up.
Definition: Item.qc:425
virtual void ReceiveEvent(float)
Definition: Item.qc:677
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition: Item.qc:50
virtual bool ItemBonusCheck(entity)
Definition: Item.qc:267
virtual void GiveBonusItems(entity)
Definition: Item.qc:772
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
Definition: Item.qc:558
virtual bool InInventory(void)
Definition: Item.qc:759
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition: Item.qc:742
This entity class represents physically-simulated entities.
Definition: PhysicsEntity.h:106
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37