Nuclide
Software Development Kit for id Technology
NSProjectile.h
1/*
2 * Copyright (c) 2016-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 PROJ_CHANGED_ORIGIN_X,
20 PROJ_CHANGED_ORIGIN_Y,
21 PROJ_CHANGED_ORIGIN_Z,
22 PROJ_CHANGED_ANGLES_X,
23 PROJ_CHANGED_ANGLES_Y,
24 PROJ_CHANGED_ANGLES_Z,
25 PROJ_CHANGED_MODELINDEX,
26 PROJ_CHANGED_SIZE,
27 PROJ_CHANGED_FRAME,
28 PROJ_CHANGED_SKIN,
29 PROJ_CHANGED_EFFECTS,
30 PROJ_CHANGED_BODY,
31 PROJ_CHANGED_SCALE,
32 PROJ_CHANGED_VELOCITY,
33 PROJ_CHANGED_ANGULARVELOCITY,
34 PROJ_CHANGED_RENDERCOLOR,
35 PROJ_CHANGED_RENDERAMT,
36 PROJ_CHANGED_RENDERMODE,
37} nsprojectile_changed_t;
38
39.void(entity, entity) m_pImpact;
40.float traileffectnum;
41
48{
49public:
50 void NSProjectile(void);
51
52#ifdef CLIENT
53 virtual void ReceiveEntity(float, float);
54 virtual float predraw(void);
55 virtual void postdraw(void);
56#endif
57
58#ifdef SERVER
60 nonvirtual void SetImpact(void(entity, entity));
62 nonvirtual void Animate(int, int, float);
64 nonvirtual void AnimateOnce(int, int, float);
65
67 virtual void Touch(entity);
68 virtual void Spawned(void);
69 virtual void Pain(entity, entity, int, vector, vector, int);
70 virtual void Death(entity, entity, int, vector, vector, int);
71
72 virtual void SpawnKey(string, string);
73 virtual void EvaluateEntity(void);
74 virtual float SendEntity(entity, float);
75 virtual void Save(float);
76 virtual void Restore(string, string);
77
78 virtual void Trigger(entity, triggermode_t);
79
80 nonvirtual void _FuseEnded(void);
81 nonvirtual void _Explode(entity);
82
83 virtual void _LaunchHitscan(vector, vector, float);
84
85 /* launch the projectile into the world */
86 virtual void Launch(vector, vector, float, float, float);
87
88 nonvirtual void SetLightColor(vector);
89 nonvirtual void SetLightRadius(float);
90
91 nonvirtual void SetWeaponOwner(NSWeapon);
92 nonvirtual NSWeapon GetWeaponOwner(void);
93
94 nonvirtual void EnableDetonateOnFuse(bool);
95 nonvirtual void EnableDetonateOnDeath(bool);
96 nonvirtual void EnableDetonateOnWorld(bool);
97 nonvirtual void EnableDetonateOnActor(bool);
98 nonvirtual void EnableStickToWorld(bool);
99 nonvirtual void EnableStickToActor(bool);
100 nonvirtual void EnableThrustHoming(bool);
101 nonvirtual void EnableInheritVelocity(bool);
102#endif
103
104private:
105 NETWORKED_FLOAT_N(traileffectnum)
106 NETWORKED_VECTOR(m_vecLightColor)
107 NETWORKED_FLOAT(m_flLightRadius)
108
109#ifdef SERVER
110 /* sprite animation gubbins */
111 int m_iProjectileAnimEnd;
112 int m_iProjectileAnimStart;
113 float m_flProjectileFramerate;
114
115 /* temp */
116 float m_flDmgMultiplier;
117 float m_trackDelayTime;
118
119 /* defAPI */
120 string m_defDamage;
121 string m_defSplashDamage;
122 vector m_vecLaunchVelocity;
123 float m_flThrust;
124 float m_flThrustStart;
125 float m_flThrustEnd;
126 float m_flFrictionLinear; /* TODO */
127 float m_flBounce;
128 float m_flMass; /* TODO */
129 float m_flGravity; /* TODO */
130 float m_flFuse;
131 bool m_bDetonateOnFuse;
132 bool m_bDetonateOnDeath;
133 bool m_bDetonateOnWorld;
134 bool m_bDetonateOnActor;
135 bool m_bImpactEffect; /* TODO */
136 bool m_bImpactGib; /* TODO */
137 bool m_bImpactSurfData; /* TODO */
138 string m_matDetonate;
139 float m_flDecalSize;
140 string m_partSmokeFly;
141 string m_partFXPath;
142 string m_partModelDetonate;
143 string m_partSmokeDetonate;
144 string m_partSmokeBounce;
145 string m_partSmokeFuse;
146 string m_defProjectileDebris;
147 int m_iDebrisCount;
148 bool m_bDebrisStick;
149 vector m_vecDebrisOffset;
150 vector m_vecDetonateOffset;
151 vector m_vecDamageOffset;
152 vector m_vecImpactPos;
153 bool m_bThrown;
154
155 float m_flLightOffset; /* TODO */
156 vector m_vecExplodeLightColor; /* TODO */
157 float m_fExplodelLightRadius; /* TODO */
158 float m_fExplodelLightFadetime; /* TODO */
159 string m_sndFly;
160 string m_sndExplode;
161 string m_sndBounce;
162 vector m_vecSpawnMins;
163 vector m_vecSpawnMaxs;
164 float m_flSpawnFrame;
165 vector m_vecSpawnOrigin;
166 NSWeapon m_weaponOwner;
167
168 /* ETQW-additions */
169 bool m_bIsBullet;
170 NSSurfacePropEntity m_eMultiTarget;
171 int m_iMultiValue;
172 int m_iMultiBody;
173 int m_iShots;
174 vector m_vecSpread;
175 float m_flDamage;
176 string m_strDecalGroup;
177 float m_flRange;
178
179 /* Nuclide additions */
180 bool m_bStickToWorld;
181 bool m_bStickToActor;
182 bool m_bThrustHoming;
183 bool m_bInheritVelocity;
184 bool m_bReflect;
185 bool m_bTrackEnemy;
186 vector m_trackJitter;
187 float m_trackDelay;
188 string m_defPlaneImpact;
189
190 NSTimer m_thrustHandler;
191 vector m_hitLocation;
192
193 nonvirtual void _AnimateThink(void);
194 nonvirtual void _ThrustThink(void);
195 nonvirtual void _AnimateThinkDead(void);
196
197 virtual void _ApplyDamage(void);
198 virtual void _FireSingle(vector,vector,float,float);
199
200 virtual void OnRemoveEntity(void);
201#endif
202};
203
204#ifdef SERVER
205NSProjectile NSProjectile_SpawnDef(string entityDef, NSActor theOwner);
206NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSActor theOwner, vector vecOrigin, vector vecAngles);
207NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSActor theOwner, int attachmentID);
208#endif
This entity class represents an object with choreographed/free-form movement.
Definition: NSNavAI.h:50
This entity class represents an attack.
Definition: NSAttack.h:22
This entity class represents an interactive projectile.
Definition: NSProjectile.h:48
nonvirtual void SetImpact(void(entity, entity))
Sets the function that'll be called upon impact of the projectile onto a surface.
Definition: NSProjectile.qc:680
nonvirtual void _Explode(entity)
Definition: NSProjectile.qc:747
nonvirtual void EnableStickToWorld(bool)
Definition: NSProjectile.qc:656
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: NSProjectile.qc:525
void NSProjectile(void)
Definition: NSProjectile.qc:18
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: NSProjectile.qc:531
virtual void postdraw(void)
Client: Run after the rendering of 3D world is complete.
Definition: NSProjectile.qc:1306
virtual void Death(entity, entity, int, vector, vector, int)
Called when the health is equal or below 0.
Definition: NSProjectile.qc:596
nonvirtual void EnableThrustHoming(bool)
Definition: NSProjectile.qc:668
virtual void Touch(entity)
Called upon the projectile touching another object.
Definition: NSProjectile.qc:541
nonvirtual void SetLightColor(vector)
Definition: NSProjectile.qc:608
nonvirtual void EnableInheritVelocity(bool)
Definition: NSProjectile.qc:674
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
Definition: NSProjectile.qc:365
nonvirtual void EnableStickToActor(bool)
Definition: NSProjectile.qc:662
nonvirtual void EnableDetonateOnActor(bool)
Definition: NSProjectile.qc:650
nonvirtual void Animate(int, int, float)
When called, will animated between two frame positions at a specified framerate on loop.
Definition: NSProjectile.qc:712
nonvirtual void AnimateOnce(int, int, float)
When called, will animated between two frame positions at a specified framerate and remove itself whe...
Definition: NSProjectile.qc:722
nonvirtual void SetLightRadius(float)
Definition: NSProjectile.qc:614
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
Definition: NSProjectile.qc:1213
nonvirtual void EnableDetonateOnDeath(bool)
Definition: NSProjectile.qc:638
nonvirtual void EnableDetonateOnWorld(bool)
Definition: NSProjectile.qc:644
nonvirtual void EnableDetonateOnFuse(bool)
Definition: NSProjectile.qc:632
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSProjectile.qc:308
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: NSProjectile.qc:1280
virtual void _LaunchHitscan(vector, vector, float)
Definition: NSProjectile.qc:847
virtual void Pain(entity, entity, int, vector, vector, int)
Called whenever the entity receives damage.
Definition: NSProjectile.qc:590
nonvirtual void SetWeaponOwner(NSWeapon)
Definition: NSProjectile.qc:620
virtual void Launch(vector, vector, float, float, float)
Definition: NSProjectile.qc:1085
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSProjectile.qc:89
nonvirtual NSWeapon GetWeaponOwner(void)
Definition: NSProjectile.qc:626
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: NSProjectile.qc:1238
virtual float predraw(void)
Definition: NSProjectile.qc:1316
nonvirtual void _FuseEnded(void)
Definition: NSProjectile.qc:732
This entity represents an NSRenderableEntity with interactive surface properties.
Definition: NSSurfacePropEntity.h:52
This class provides a way to trigger a function in the future.
Definition: NSTimer.h:26
This entity class represents weapon based items.
Definition: NSWeapon.h:170
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
entityDefAPI_t entityDef
Definition: api.h:363