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
48{
49public:
50 void NSProjectile(void);
51
52#ifdef CLIENT
53 virtual void ReceiveEntity(float, float);
54 virtual float predraw(void);
55#endif
56
57#ifdef SERVER
59 nonvirtual void SetImpact(void(entity, entity));
61 nonvirtual void Animate(int, int, float);
63 nonvirtual void AnimateOnce(int, int, float);
64
66 virtual void Touch(entity);
67 virtual void Spawned(void);
68 virtual void Pain(entity, entity, int, vector, int);
69 virtual void Death(entity, entity, int, vector, int);
70
71 virtual void SpawnKey(string, string);
72 virtual void EvaluateEntity(void);
73 virtual float SendEntity(entity, float);
74 virtual void Save(float);
75 virtual void Restore(string, string);
76
77 virtual void Trigger(entity, triggermode_t);
78
79 nonvirtual void _FuseEnded(void);
80 nonvirtual void _Explode(void);
81
82 virtual void _LaunchHitscan(vector, vector, float);
83
84 /* launch the projectile into the world */
85 virtual void Launch(vector, vector, float, float, float);
86
87 nonvirtual void SetLightColor(vector);
88 nonvirtual void SetLightRadius(float);
89
90 nonvirtual void EnableDetonateOnFuse(bool);
91 nonvirtual void EnableDetonateOnDeath(bool);
92 nonvirtual void EnableDetonateOnWorld(bool);
93 nonvirtual void EnableDetonateOnActor(bool);
94 nonvirtual void EnableStickToWorld(bool);
95 nonvirtual void EnableStickToActor(bool);
96 nonvirtual void EnableThrustHoming(bool);
97 nonvirtual void EnableInheritVelocity(bool);
98#endif
99
100private:
102 NETWORKED_VECTOR(m_vecLightColor)
103 NETWORKED_FLOAT(m_flLightRadius)
104
105#ifdef SERVER
106 /* sprite animation gubbins */
107 int m_iProjectileAnimEnd;
108 int m_iProjectileAnimStart;
109 float m_flProjectileFramerate;
110
111 /* temp */
112 float m_flDmgMultiplier;
113
114 /* defAPI */
115 string m_defDamage;
116 string m_defSplashDamage;
117 vector m_vecLaunchVelocity;
118 float m_flThrust;
119 float m_flThrustStart;
120 float m_flThrustEnd;
121 float m_flFrictionLinear; /* TODO */
122 float m_flBounce;
123 float m_flMass; /* TODO */
124 float m_flGravity; /* TODO */
125 float m_flFuse;
126 bool m_bDetonateOnFuse;
127 bool m_bDetonateOnDeath;
128 bool m_bDetonateOnWorld;
129 bool m_bDetonateOnActor;
130 bool m_bImpactEffect; /* TODO */
131 bool m_bImpactGib; /* TODO */
132 bool m_bImpactSurfData; /* TODO */
133 string m_matDetonate;
134 float m_flDecalSize;
135 string m_partSmokeFly;
136 string m_partModelDetonate;
137 string m_partSmokeDetonate;
138 string m_partSmokeBounce;
139 string m_partSmokeFuse;
140 string m_defProjectileDebris;
141 int m_iDebrisCount;
142 bool m_bDebrisStick;
143 vector m_vecDebrisOffset;
144 vector m_vecImpactPos;
145
146 float m_flLightOffset; /* TODO */
147 vector m_vecExplodeLightColor; /* TODO */
148 float m_fExplodelLightRadius; /* TODO */
149 float m_fExplodelLightFadetime; /* TODO */
150 string m_sndFly;
151 string m_sndExplode;
152 string m_sndBounce;
153 vector m_vecSpawnMins;
154 vector m_vecSpawnMaxs;
155 float m_flSpawnFrame;
156 vector m_vecSpawnOrigin;
157
158 /* ETQW-additions */
159 bool m_bIsBullet;
160 NSSurfacePropEntity m_eMultiTarget;
161 int m_iMultiValue;
162 int m_iMultiBody;
163 int m_iShots;
164 vector m_vecSpread;
165 float m_flDamage;
166 string m_strDecalGroup;
167 float m_flRange;
168
169 /* Nuclide additions */
170 bool m_bStickToWorld;
171 bool m_bStickToActor;
172 bool m_bThrustHoming;
173 bool m_bInheritVelocity;
174
175 NSTimer m_thrustHandler;
176
177 nonvirtual void _AnimateThink(void);
178 nonvirtual void _ThrustThink(void);
179 nonvirtual void _AnimateThinkDead(void);
180
181 virtual void _ApplyDamage(void);
182 virtual void _FireSingle(vector,vector,float,float);
183
184 virtual void OnRemoveEntity(void);
185#endif
186};
187
188#ifdef SERVER
189NSProjectile NSProjectile_SpawnDef(string entityDef, NSEntity theOwner);
190NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles);
191NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID);
192#endif
float traileffectnum
Definition: NSProjectile.h:40
NSProjectile NSProjectile_SpawnDefAttachment(string entityDef, NSEntity theOwner, int attachmentID)
Definition: NSProjectile.qc:1179
NSProjectile NSProjectile_SpawnDefAtPosition(string entityDef, NSEntity theOwner, vector vecOrigin, vector vecAngles)
Definition: NSProjectile.qc:1166
NSProjectile NSProjectile_SpawnDef(string entityDef, NSEntity theOwner)
Definition: NSProjectile.qc:1151
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:54
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:619
nonvirtual void EnableStickToWorld(bool)
Definition: NSProjectile.qc:595
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: NSProjectile.qc:487
void NSProjectile(void)
Definition: NSProjectile.qc:18
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: NSProjectile.qc:493
nonvirtual void EnableThrustHoming(bool)
Definition: NSProjectile.qc:607
virtual void Touch(entity)
Called upon the projectile touching another object.
Definition: NSProjectile.qc:503
nonvirtual void SetLightColor(vector)
Definition: NSProjectile.qc:559
nonvirtual void EnableInheritVelocity(bool)
Definition: NSProjectile.qc:613
virtual void Restore(string, string)
Similar to NSIO::SpawnKey but for save-game fields.
Definition: NSProjectile.qc:333
nonvirtual void EnableStickToActor(bool)
Definition: NSProjectile.qc:601
nonvirtual void EnableDetonateOnActor(bool)
Definition: NSProjectile.qc:589
nonvirtual void Animate(int, int, float)
When called, will animated between two frame positions at a specified framerate on loop.
Definition: NSProjectile.qc:652
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:663
nonvirtual void SetLightRadius(float)
Definition: NSProjectile.qc:565
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:1048
nonvirtual void EnableDetonateOnDeath(bool)
Definition: NSProjectile.qc:577
nonvirtual void EnableDetonateOnWorld(bool)
Definition: NSProjectile.qc:583
nonvirtual void EnableDetonateOnFuse(bool)
Definition: NSProjectile.qc:571
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSProjectile.qc:278
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: NSProjectile.qc:1113
virtual void _LaunchHitscan(vector, vector, float)
Definition: NSProjectile.qc:750
nonvirtual void _Explode(void)
Definition: NSProjectile.qc:690
virtual void Launch(vector, vector, float, float, float)
Definition: NSProjectile.qc:970
virtual void SpawnKey(string, string)
This method handles entity key/value pairs on map load.
Definition: NSProjectile.qc:86
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition: NSProjectile.qc:1073
virtual float predraw(void)
Definition: NSProjectile.qc:1139
virtual void Death(entity, entity, int, vector, int)
Called when the health is equal or below 0.
Definition: NSProjectile.qc:547
virtual void Pain(entity, entity, int, vector, int)
Called whenever the entity receives damage.
Definition: NSProjectile.qc:541
nonvirtual void _FuseEnded(void)
Definition: NSProjectile.qc:674
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
#define NETWORKED_FLOAT(x)
Definition: defs.h:21
#define NETWORKED_VECTOR(x)
Definition: defs.h:22
#define NETWORKED_FLOAT_N(x)
Definition: defs.h:29