Nuclide
Software Development Kit for id Tech
NSProjectile.h
Go to the documentation of this file.
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;
41
45{
46private:
48 NETWORKED_VECTOR(m_vecLightColor)
49 NETWORKED_FLOAT(m_flLightRadius)
50
51#ifdef SERVER
52 /* sprite animation gubbins */
53 int m_iProjectileAnimEnd;
54 int m_iProjectileAnimStart;
55 float m_flProjectileFramerate;
56
57 /* temp */
58 float m_flDmgMultiplier;
59
60 /* defAPI */
61 string m_defDamage;
62 string m_defSplashDamage;
63 vector m_vecLaunchVelocity;
64 float m_flThrust;
65 float m_flThrustStart;
66 float m_flThrustEnd;
67 float m_flFrictionLinear; /* TODO */
68 float m_flBounce;
69 float m_flMass; /* TODO */
70 float m_flGravity; /* TODO */
71 float m_flFuse;
72 bool m_bDetonateOnFuse;
73 bool m_bDetonateOnDeath;
74 bool m_bDetonateOnWorld;
75 bool m_bDetonateOnActor;
76 bool m_bImpactEffect; /* TODO */
77 bool m_bImpactGib; /* TODO */
78 string m_matDetonate;
79 float m_flDecalSize;
80 string m_partSmokeFly;
81 string m_partModelDetonate;
82 string m_partSmokeDetonate;
83 string m_partSmokeBounce;
84 string m_partSmokeFuse;
85 string m_defProjectileDebris;
86 int m_iDebrisCount;
87
88 float m_flLightOffset; /* TODO */
89 vector m_vecExplodeLightColor; /* TODO */
90 float m_fExplodelLightRadius; /* TODO */
91 float m_fExplodelLightFadetime; /* TODO */
92 string m_sndFly;
93 string m_sndExplode;
94 string m_sndBounce;
95 vector m_vecSpawnMins;
96 vector m_vecSpawnMaxs;
97 float m_flSpawnFrame;
98 vector m_vecSpawnOrigin;
99
100 /* ETQW-additions */
101 bool m_bIsBullet;
102
103 /* Nuclide additions */
104 bool m_bStickToWorld;
105 bool m_bStickToActor;
106 bool m_bThrustHoming;
107 bool m_bInheritVelocity;
108
109 NSTimer m_thrustHandler;
110
111 nonvirtual void _AnimateThink(void);
112 nonvirtual void _ThrustThink(void);
113 nonvirtual void _AnimateThinkDead(void);
114
115 virtual void OnRemoveEntity(void);
116#endif
117
118public:
119 void NSProjectile(void);
120
121#ifdef CLIENT
122 virtual void ReceiveEntity(float, float);
123 virtual float predraw(void);
124#endif
125
126#ifdef SERVER
128 nonvirtual void SetImpact(void(entity, entity));
130 nonvirtual void Animate(int, int, float);
132 nonvirtual void AnimateOnce(int, int, float);
133
135 virtual void Touch(entity);
136 virtual void Spawned(void);
137 virtual void Death(void);
138 virtual void Pain(void);
139
140 virtual void SpawnKey(string, string);
141 virtual void EvaluateEntity(void);
142 virtual float SendEntity(entity, float);
143 virtual void Save(float);
144 virtual void Restore(string, string);
145
146 virtual void Trigger(entity, triggermode_t);
147
148 nonvirtual void _FuseEnded(void);
149 nonvirtual void _Explode(void);
150
151 nonvirtual void _LaunchHitscan(vector, vector, float);
152
153 /* launch the projectile into the world */
154 nonvirtual void Launch(vector, vector, float, float, float);
155
156 nonvirtual void SetLightColor(vector);
157 nonvirtual void SetLightRadius(float);
158
159 nonvirtual void EnableDetonateOnFuse(bool);
160 nonvirtual void EnableDetonateOnDeath(bool);
161 nonvirtual void EnableDetonateOnWorld(bool);
162 nonvirtual void EnableDetonateOnActor(bool);
163 nonvirtual void EnableStickToWorld(bool);
164 nonvirtual void EnableStickToActor(bool);
165 nonvirtual void EnableThrustHoming(bool);
166 nonvirtual void EnableInheritVelocity(bool);
167#endif
168};
169
170#ifdef SERVER
171NSProjectile NSProjectile_SpawnDef(string entityDef, NSEntity theOwner);
172NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles);
173NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID);
174#endif
float traileffectnum
Definition: NSProjectile.h:40
NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID)
Definition: NSProjectile.qc:964
NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles)
Definition: NSProjectile.qc:951
NSProjectile NSProjectile_SpawnDef(string entityDef, NSEntity theOwner)
Definition: NSProjectile.qc:930
typedef enumflags
Definition: NSProjectile.h:18
triggermode_t
The type of trigger activation.
Definition: NSTrigger.h:40
NSEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:52
This entity class represents an interactive projectile.
Definition: NSProjectile.h:45
nonvirtual void SetImpact(void(entity, entity))
Sets the function that'll be called upon impact of the projectile onto a surface.
Definition: NSProjectile.qc:588
nonvirtual void EnableStickToWorld(bool)
Definition: NSProjectile.qc:564
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: NSProjectile.qc:453
void NSProjectile(void)
Definition: NSProjectile.qc:18
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: NSProjectile.qc:459
virtual void Death(void)
Called when the health is equal or below 0.
Definition: NSProjectile.qc:516
nonvirtual void EnableThrustHoming(bool)
Definition: NSProjectile.qc:576
virtual void Touch(entity)
Called upon the projectile touching another object.
Definition: NSProjectile.qc:469
nonvirtual void SetLightColor(vector)
Definition: NSProjectile.qc:528
nonvirtual void EnableInheritVelocity(bool)
Definition: NSProjectile.qc:582
virtual void Restore(string, string)
Similar to ::SpawnKey but for save-game fields.
Definition: NSProjectile.qc:299
nonvirtual void EnableStickToActor(bool)
Definition: NSProjectile.qc:570
nonvirtual void EnableDetonateOnActor(bool)
Definition: NSProjectile.qc:558
nonvirtual void Animate(int, int, float)
When called, will animated between two frame positions at a specified framerate on loop.
Definition: NSProjectile.qc:621
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:632
nonvirtual void SetLightRadius(float)
Definition: NSProjectile.qc:534
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:827
nonvirtual void EnableDetonateOnDeath(bool)
Definition: NSProjectile.qc:546
nonvirtual void EnableDetonateOnWorld(bool)
Definition: NSProjectile.qc:552
nonvirtual void EnableDetonateOnFuse(bool)
Definition: NSProjectile.qc:540
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSProjectile.qc:244
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: NSProjectile.qc:892
nonvirtual void _LaunchHitscan(vector, vector, float)
Definition: NSProjectile.qc:696
nonvirtual void _Explode(void)
Definition: NSProjectile.qc:656
virtual void Pain(void)
Called whenever the entity receives damage.
Definition: NSProjectile.qc:510
nonvirtual void Launch(vector, vector, float, float, float)
Definition: NSProjectile.qc:748
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSProjectile.qc:78
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: NSProjectile.qc:852
virtual float predraw(void)
Definition: NSProjectile.qc:918
nonvirtual void _FuseEnded(void)
Definition: NSProjectile.qc:643
This entity represents an NSRenderableEntity with interactive surface properties.
Definition: NSSurfacePropEntity.h:49
This class provides a way to trigger a function in the future.
Definition: NSTimer.h:23
vector(vector) normalize
entity() spawn
#define NETWORKED_FLOAT(x)
Definition: defs.h:19
#define NETWORKED_VECTOR(x)
Definition: defs.h:20
#define NETWORKED_FLOAT_N(x)
Definition: defs.h:26