Nuclide
Software Development Kit for id Technology (BETA)
Projectile.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
204{
205public:
206 void ncProjectile(void);
207
208#ifdef CLIENT
209 virtual void ReceiveEntity(float, float);
210 virtual float predraw(void);
211 virtual void postdraw(void);
212#endif
213
214#ifdef SERVER
216 nonvirtual void SetImpact(void(entity, entity));
218 nonvirtual void Animate(int, int, float);
220 nonvirtual void AnimateOnce(int, int, float);
221
223 virtual void Touch(entity);
224 virtual void Spawned(void);
225 virtual void Pain(entity, entity, int, vector, vector, int);
226 virtual void Death(entity, entity, int, vector, vector, int);
227
228 virtual void SpawnKey(string, string);
229 virtual void EvaluateEntity(void);
230 virtual float SendEntity(entity, float);
231 virtual void Save(float);
232 virtual void Restore(string, string);
233
234 virtual void Trigger(entity, triggermode_t);
235
236 nonvirtual void _FuseEnded(void);
237 nonvirtual void _Explode(entity);
238 virtual void HasExploded(void);
239
240 virtual void _LaunchHitscan(vector, vector, float);
241
242 /* launch the projectile into the world */
243 virtual void Launch(vector, vector, float, float, float);
244
245 nonvirtual void SetLightColor(vector);
246 nonvirtual void SetLightRadius(float);
247
248 nonvirtual void SetWeaponOwner(ncWeapon);
249 nonvirtual ncWeapon GetWeaponOwner(void);
250
251 nonvirtual void EnableDetonateOnFuse(bool);
252 nonvirtual void EnableDetonateOnDeath(bool);
253 nonvirtual void EnableDetonateOnWorld(bool);
254 nonvirtual void EnableDetonateOnActor(bool);
255 nonvirtual void EnableStickToWorld(bool);
256 nonvirtual void EnableStickToActor(bool);
257 nonvirtual void EnableThrustHoming(bool);
258 nonvirtual void EnableInheritVelocity(bool);
259#endif
260
261private:
262 NETWORKED_FLOAT_N(traileffectnum)
263 NETWORKED_VECTOR(m_vecLightColor)
264 NETWORKED_FLOAT(m_flLightRadius)
265
266#ifdef SERVER
267 /* I/O system */
268 string m_outputOnDetonate;
269
270 /* sprite animation gubbins */
271 int m_iProjectileAnimEnd;
272 int m_iProjectileAnimStart;
273 float m_flProjectileFramerate;
274
275 /* temp */
276 float m_flDmgMultiplier;
277 float m_trackDelayTime;
278
279 /* defAPI */
280 string m_defDamage;
281 string m_defSplashDamage;
282 vector m_vecLaunchVelocity;
283 float m_flThrust;
284 float m_flThrustStart;
285 float m_flThrustEnd;
286 float m_flFrictionLinear; /* TODO */
287 float m_flBounce;
288 float m_flMass; /* TODO */
289 float m_flGravity; /* TODO */
290 float m_flFuse;
291 bool m_bDetonateOnFuse;
292 bool m_bDetonateOnDeath;
293 bool m_bDetonateOnWorld;
294 bool m_bDetonateOnActor;
295 bool m_bImpactEffect; /* TODO */
296 bool m_bImpactGib; /* TODO */
297 bool m_bImpactSurfData; /* TODO */
298 string m_matDetonate;
299 float m_flDecalSize;
300 string m_partSmokeFly;
301 string m_partFXPath;
302 string m_partModelDetonate;
303 string m_partSmokeDetonate;
304 string m_partSmokeBounce;
305 string m_partSmokeFuse;
306 string m_defProjectileDebris;
307 int m_iDebrisCount;
308 bool m_bDebrisStick;
309 vector m_vecDebrisOffset;
310 vector m_vecDetonateOffset;
311 vector m_vecDamageOffset;
312 vector m_vecImpactPos;
313 bool m_bThrown;
314
315 float m_flLightOffset; /* TODO */
316 vector m_vecExplodeLightColor; /* TODO */
317 float m_fExplodelLightRadius; /* TODO */
318 float m_fExplodelLightFadetime; /* TODO */
319 string m_sndFly;
320 string m_sndExplode;
321 string m_sndBounce;
322 vector m_vecSpawnMins;
323 vector m_vecSpawnMaxs;
324 float m_flSpawnFrame;
325 vector m_vecSpawnOrigin;
326 ncWeapon m_weaponOwner;
327
328 /* ETQW-additions */
329 bool m_bIsBullet;
330 ncSurfacePropEntity m_eMultiTarget;
331 int m_iMultiValue;
332 int m_iMultiBody;
333 int m_iShots;
334 vector m_vecSpread;
335 float m_flDamage;
336 string m_strDecalGroup;
337 float m_flRange;
338
339 /* Nuclide additions */
340 bool m_bStickToWorld;
341 bool m_bStickToActor;
342 bool m_bThrustHoming;
343 bool m_bInheritVelocity;
344 bool m_bReflect;
345 bool m_bTrackEnemy;
346 vector m_trackJitter;
347 float m_trackDelay;
348 string m_defPlaneImpact;
349
350 ncTimer m_thrustHandler;
351 vector m_hitLocation;
352 bool m_noFX;
353 vector m_lastPlaneNormal;
354
355 nonvirtual void _AnimateThink(void);
356 nonvirtual void _ThrustThink(void);
357 nonvirtual void _AnimateThinkDead(void);
358
359 virtual void _ApplyDamage(void);
360 virtual void _FireSingle(vector,vector,float,float);
361
362 virtual void OnRemoveEntity(void);
363#endif
364};
365
366#ifdef SERVER
367ncProjectile ncProjectile_SpawnDef(string entityDef, ncActor theOwner);
368ncProjectile ncProjectile_SpawnDefAtPosition(string entityDef, ncActor theOwner, vector vecOrigin, vector vecAngles);
369ncProjectile ncProjectile_SpawnDefAttachment(string entityDef, ncActor theOwner, int attachmentID);
370#endif
This entity class represents an object with choreographed/free-form movement.
Definition: Actor.h:93
This entity class represents an attack.
Definition: Attack.h:36
This entity class represents an interactive projectile.
Definition: Projectile.h:204
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
Definition: Projectile.qc:1258
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: Projectile.qc:532
nonvirtual ncWeapon GetWeaponOwner(void)
Definition: Projectile.qc:638
nonvirtual void _Explode(entity)
Definition: Projectile.qc:765
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: Projectile.qc:90
nonvirtual void Animate(int, int, float)
When called, will animated between two frame positions at a specified framerate on loop.
Definition: Projectile.qc:724
nonvirtual void SetLightRadius(float)
Definition: Projectile.qc:626
nonvirtual void AnimateOnce(int, int, float)
When called, will animated between two frame positions at a specified framerate and remove itself whe...
Definition: Projectile.qc:734
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: Projectile.qc:538
virtual void HasExploded(void)
Definition: Projectile.qc:759
virtual void postdraw(void)
Client: Run after the rendering of 3D world is complete.
Definition: Projectile.qc:1357
virtual void Pain(entity, entity, int, vector, vector, int)
Called whenever the entity receives damage.
Definition: Projectile.qc:602
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: Projectile.qc:1329
void ncProjectile(void)
Definition: Projectile.qc:18
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: Projectile.qc:1285
nonvirtual void EnableDetonateOnWorld(bool)
Definition: Projectile.qc:656
nonvirtual void SetLightColor(vector)
Definition: Projectile.qc:620
virtual void Touch(entity)
Called upon the projectile touching another object.
Definition: Projectile.qc:552
nonvirtual void EnableStickToWorld(bool)
Definition: Projectile.qc:668
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: Projectile.qc:372
nonvirtual void EnableDetonateOnActor(bool)
Definition: Projectile.qc:662
virtual void _LaunchHitscan(vector, vector, float)
Definition: Projectile.qc:880
nonvirtual void EnableInheritVelocity(bool)
Definition: Projectile.qc:686
nonvirtual void EnableDetonateOnFuse(bool)
Definition: Projectile.qc:644
nonvirtual void EnableThrustHoming(bool)
Definition: Projectile.qc:680
nonvirtual void SetImpact(void(entity, entity))
Sets the function that'll be called upon impact of the projectile onto a surface.
Definition: Projectile.qc:692
nonvirtual void SetWeaponOwner(ncWeapon)
Definition: Projectile.qc:632
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: Projectile.qc:315
virtual float predraw(void)
Definition: Projectile.qc:1367
nonvirtual void EnableStickToActor(bool)
Definition: Projectile.qc:674
virtual void Death(entity, entity, int, vector, vector, int)
Called when the health is equal or below 0.
Definition: Projectile.qc:608
virtual void Launch(vector, vector, float, float, float)
Definition: Projectile.qc:1129
nonvirtual void _FuseEnded(void)
Definition: Projectile.qc:744
nonvirtual void EnableDetonateOnDeath(bool)
Definition: Projectile.qc:650
This entity represents an ncRenderableEntity with interactive surface properties.
Definition: SurfacePropEntity.h:70
This class provides a way to trigger a function in the future.
Definition: Timer.h:26
This entity class represents weapon based items.
Definition: Weapon.h:300
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
entityDefAPI_t entityDef
Access entityDefAPI_t functions using this variable.
Definition: api.h:436