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 ITEMFL_CHANGED_MODELINDEX,
19 ITEMFL_CHANGED_ORIGIN_X,
20 ITEMFL_CHANGED_ORIGIN_Y,
21 ITEMFL_CHANGED_ORIGIN_Z,
22 ITEMFL_CHANGED_ANGLES_X,
23 ITEMFL_CHANGED_ANGLES_Y,
24 ITEMFL_CHANGED_ANGLES_Z,
25 ITEMFL_CHANGED_VELOCITY,
26 ITEMFL_CHANGED_ANGULARVELOCITY,
27 ITEMFL_CHANGED_RENDERPROPS,
28 ITEMFL_CHANGED_SIZE,
29 ITEMFL_CHANGED_FLAGS,
30 ITEMFL_CHANGED_SOLID,
31 ITEMFL_CHANGED_FRAME,
32 ITEMFL_CHANGED_SKIN,
33 ITEMFL_CHANGED_MOVETYPE,
34 ITEMFL_CHANGED_EFFECTS,
35 ITEMFL_CHANGED_SCALE,
36 ITEMFL_CHANGED_ENTITYDEF,
37 ITEMFL_CHANGED_CHAIN,
38} nsitem_changed_t;
39
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, bool);
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 virtual void OnMapFinishedLoading(void);
157
158 /* item related accessors */
159 nonvirtual void SetFloating(int);
160 nonvirtual bool GetFloating(void);
161 nonvirtual void SetSpinning(bool);
162 nonvirtual bool GetSpinning(void);
163 nonvirtual void PickupRespawn(void);
164 nonvirtual void SetRespawnTime(float);
165
166 /* only if the entity is usable in the inventory. */
167 virtual void OnInventoryUse(void);
168
170 virtual void OnPickup(void);
171
173 virtual void OnUse(entity);
174
175 virtual void PrintDebugInfo(void);
177 nonvirtual void BecomePickup(void);
178
179 nonvirtual void BecomeSolid(void);
180 nonvirtual void BecomeDropped(void);
181#endif
182
184 virtual void AddedToInventory(void);
186 virtual void RemovedFromInventory(void);
187
188#ifdef CLIENT
189 virtual void ReceiveEntity(float,float);
190 virtual void ReceiveEvent(float);
191 virtual void PredictPreFrame(void);
192 virtual void PredictPostFrame(void);
193#endif
194
195 virtual bool IsWeapon(void);
196 virtual bool InInventory(void);
197
198 virtual void OnRemoveEntity(void);
199
200private:
202 virtual void _AddedCallback(void);
204 virtual void _RemovedCallback(void);
205
206 int m_itemWasDropped;
207
208 /* item related spawn keys */
209 string m_sndAcquire;
210 string m_sndRespawn;
211 float m_itemRespawn;
212 string m_sndHum;
213 int m_itemPickupFloats;
214 bool m_itemPickupSpins;
215 string m_itemName;
216 string m_itemWeapon;
217
218 int m_itemGivesHealth;
219 int m_itemGivesArmor;
220 float m_itemGivesAir;
221 int m_itemGivesBonusHealth;
222 int m_itemGivesBonusArmor;
223 bool m_itemNoTouch;
224 bool m_itemCarries;
225 string m_itemRequiresItem;
226 bool _m_itemTouchPickup; /* whether the item was touched for pick-up */
227
228 int m_itemGivesAmmo[MAX_AMMO_TYPES];
229
230#ifdef CLIENT
231 NETWORKED_FLOAT(chain_entnum)
232 NETWORKED_FLOAT(owner_entnum)
233#endif
234
235#ifdef SERVER
236 float m_hiddenModelIndex;
237 float m_hiddenSequence;
238#endif
239
240 ncItem m_nextItem;
241 ncItem m_nextItem_net;
242 entity owner_net;
243 entity m_oldOwner;
244};
This entity class represents inventory items, weapons.
Definition: Item.h:138
nonvirtual void BecomeDropped(void)
Definition: Item.qc:554
virtual bool IsWeapon(void)
Definition: Item.qc:892
virtual void PredictPreFrame(void)
Definition: Item.qc:804
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: Item.qc:731
virtual void AddedToInventory(void)
Called when an item was added to someones inventory.
Definition: Item.qc:876
virtual void RemovedFromInventory(void)
Called when an item was removed from someones inventory.
Definition: Item.qc:881
virtual void OnUse(entity)
Overridable: Called when this item is used.
Definition: Item.qc:324
nonvirtual void BecomeSolid(void)
Definition: Item.qc:547
virtual void OnInventoryUse(void)
Definition: Item.qc:530
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: Item.qc:45
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: Item.qc:606
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: Item.qc:99
virtual void OnMapFinishedLoading(void)
Overridable: Called when the level finished loading.
Definition: Item.qc:83
virtual bool ItemPickupCheck(entity)
Definition: Item.qc:377
nonvirtual bool GetFloating(void)
Definition: Item.qc:498
nonvirtual void BecomePickup(void)
Call to turn a weapon into a pickup.
Definition: Item.qc:565
virtual void PrintDebugInfo(void)
Definition: Item.qc:535
nonvirtual void SetRespawnTime(float)
Definition: Item.qc:330
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: Item.qc:279
nonvirtual void SetFloating(int)
Definition: Item.qc:492
nonvirtual void PickupRespawn(void)
Definition: Item.qc:517
virtual void GiveBonusItems(entity, bool)
Definition: Item.qc:899
virtual void PredictPostFrame(void)
Definition: Item.qc:827
nonvirtual void SetSpinning(bool)
Definition: Item.qc:504
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: Item.qc:396
nonvirtual bool GetSpinning(void)
Definition: Item.qc:510
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: Item.qc:209
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: Item.qc:176
void ncItem(void)
Definition: Item.qc:18
virtual void OnPickup(void)
Overridable: Called when this item is picked up.
Definition: Item.qc:525
virtual void ReceiveEvent(float)
Definition: Item.qc:799
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:76
virtual bool ItemBonusCheck(entity)
Definition: Item.qc:336
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:679
virtual bool InInventory(void)
Definition: Item.qc:886
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition: Item.qc:868
This entity class represents physically-simulated entities.
Definition: PhysicsEntity.h:131
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37