Nuclide
Software Development Kit for id Technology
NSItem.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
67{
68public:
69 void NSItem(void);
70
71 /* overrides */
72#ifdef SERVER
73 virtual void Spawned(void);
74 virtual bool ItemPickupCheck(entity);
75 virtual void Touch(entity);
76 virtual void Respawn(void);
77 virtual void SpawnKey(string, string);
78 virtual void Input(entity, string, string);
79 virtual void Save(float);
80 virtual void Restore(string,string);
81 virtual void EvaluateEntity(void);
82 virtual float SendEntity(entity,float);
83
84 /* item related accessors */
85 nonvirtual void SetFloating(int);
86 nonvirtual bool GetFloating(void);
87 nonvirtual void SetSpinning(bool);
88 nonvirtual bool GetSpinning(void);
89 nonvirtual void PickupRespawn(void);
90
91 /* only if the entity is usable in the inventory. */
92 virtual void OnInventoryUse(void);
93
95 virtual void OnPickup(void);
96
98 virtual void OnUse(entity);
99
100 virtual void PrintDebugInfo(void);
102 nonvirtual void BecomePickup(void);
103#endif
104
106 virtual void AddedToInventory(void);
108 virtual void RemovedFromInventory(void);
109
110#ifdef CLIENT
111 virtual void ReceiveEntity(float,float);
112 virtual void ReceiveEvent(float);
113 virtual void PredictPreFrame(void);
114 virtual void PredictPostFrame(void);
115#endif
116
117 virtual bool IsWeapon(void);
118 virtual bool InInventory(void);
119
120private:
122 virtual void _AddedCallback(void);
124 virtual void _RemovedCallback(void);
125
126 int m_iClip;
127 int m_iWasDropped;
128
129 /* item related spawn keys */
130 int m_iInvItem;
131 string m_sndAcquire;
132 string m_sndRespawn;
133 string m_sndHum;
134 int m_bFloating;
135 bool m_bSpins;
136 string m_strInvName;
137 string m_strInvWeapon;
138
139 int m_iGiveHealth;
140 int m_iGiveArmor;
141 bool m_bNoTouch;
142 bool m_bInvCarry;
143 string m_strRequires;
144
145 int m_GiveAmmo[MAX_AMMO_TYPES];
146
147#ifdef CLIENT
148 NETWORKED_FLOAT(chain_entnum)
149 NETWORKED_FLOAT(owner_entnum)
150#endif
151
152 NSItem m_nextItem;
153 NSItem m_nextItem_net;
154 entity owner_net;
155};
This entity class represents inventory items, weapons.
Definition: NSItem.h:67
nonvirtual void SetSpinning(bool)
Definition: NSItem.qc:306
virtual void OnInventoryUse(void)
Definition: NSItem.qc:332
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
Definition: NSItem.qc:154
nonvirtual void SetFloating(int)
Definition: NSItem.qc:294
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: NSItem.qc:392
virtual void PredictPreFrame(void)
Definition: NSItem.qc:561
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSItem.qc:133
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:49
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:446
virtual bool ItemPickupCheck(entity)
Definition: NSItem.qc:222
nonvirtual bool GetFloating(void)
Definition: NSItem.qc:300
virtual bool InInventory(void)
Definition: NSItem.qc:634
virtual void RemovedFromInventory(void)
Called when an item was removed from someones inventory.
Definition: NSItem.qc:629
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: NSItem.qc:490
virtual void OnPickup(void)
Overridable: Called when this item is picked up.
Definition: NSItem.qc:327
virtual bool IsWeapon(void)
Definition: NSItem.qc:640
virtual void PrintDebugInfo(void)
Definition: NSItem.qc:337
virtual void OnUse(entity)
Overridable: Called when this item is used.
Definition: NSItem.qc:216
virtual void AddedToInventory(void)
Called when an item was added to someones inventory.
Definition: NSItem.qc:624
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSItem.qc:68
nonvirtual bool GetSpinning(void)
Definition: NSItem.qc:312
virtual void PredictPostFrame(void)
Definition: NSItem.qc:605
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:556
nonvirtual void PickupRespawn(void)
Definition: NSItem.qc:319
nonvirtual void BecomePickup(void)
Call to turn a weapon into a pickup.
Definition: NSItem.qc:351
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: NSItem.qc:207
virtual void Touch(entity)
Called whenever we're touching another entity.
Definition: NSItem.qc:261
This entity class represents physically-simulated entities.
Definition: NSPhysicsEntity.h:106
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37