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
48{
49public:
50 void ncProjectile(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 virtual void HasExploded(void);
83
84 virtual void _LaunchHitscan(vector, vector, float);
85
86 /* launch the projectile into the world */
87 virtual void Launch(vector, vector, float, float, float);
88
89 nonvirtual void SetLightColor(vector);
90 nonvirtual void SetLightRadius(float);
91
92 nonvirtual void SetWeaponOwner(ncWeapon);
93 nonvirtual ncWeapon GetWeaponOwner(void);
94
95 nonvirtual void EnableDetonateOnFuse(bool);
96 nonvirtual void EnableDetonateOnDeath(bool);
97 nonvirtual void EnableDetonateOnWorld(bool);
98 nonvirtual void EnableDetonateOnActor(bool);
99 nonvirtual void EnableStickToWorld(bool);
100 nonvirtual void EnableStickToActor(bool);
101 nonvirtual void EnableThrustHoming(bool);
102 nonvirtual void EnableInheritVelocity(bool);
103#endif
104
105private:
106 NETWORKED_FLOAT_N(traileffectnum)
107 NETWORKED_VECTOR(m_vecLightColor)
108 NETWORKED_FLOAT(m_flLightRadius)
109
110#ifdef SERVER
111 /* sprite animation gubbins */
112 int m_iProjectileAnimEnd;
113 int m_iProjectileAnimStart;
114 float m_flProjectileFramerate;
115
116 /* temp */
117 float m_flDmgMultiplier;
118 float m_trackDelayTime;
119
120 /* defAPI */
121 string m_defDamage;
122 string m_defSplashDamage;
123 vector m_vecLaunchVelocity;
124 float m_flThrust;
125 float m_flThrustStart;
126 float m_flThrustEnd;
127 float m_flFrictionLinear; /* TODO */
128 float m_flBounce;
129 float m_flMass; /* TODO */
130 float m_flGravity; /* TODO */
131 float m_flFuse;
132 bool m_bDetonateOnFuse;
133 bool m_bDetonateOnDeath;
134 bool m_bDetonateOnWorld;
135 bool m_bDetonateOnActor;
136 bool m_bImpactEffect; /* TODO */
137 bool m_bImpactGib; /* TODO */
138 bool m_bImpactSurfData; /* TODO */
139 string m_matDetonate;
140 float m_flDecalSize;
141 string m_partSmokeFly;
142 string m_partFXPath;
143 string m_partModelDetonate;
144 string m_partSmokeDetonate;
145 string m_partSmokeBounce;
146 string m_partSmokeFuse;
147 string m_defProjectileDebris;
148 int m_iDebrisCount;
149 bool m_bDebrisStick;
150 vector m_vecDebrisOffset;
151 vector m_vecDetonateOffset;
152 vector m_vecDamageOffset;
153 vector m_vecImpactPos;
154 bool m_bThrown;
155
156 float m_flLightOffset; /* TODO */
157 vector m_vecExplodeLightColor; /* TODO */
158 float m_fExplodelLightRadius; /* TODO */
159 float m_fExplodelLightFadetime; /* TODO */
160 string m_sndFly;
161 string m_sndExplode;
162 string m_sndBounce;
163 vector m_vecSpawnMins;
164 vector m_vecSpawnMaxs;
165 float m_flSpawnFrame;
166 vector m_vecSpawnOrigin;
167 ncWeapon m_weaponOwner;
168
169 /* ETQW-additions */
170 bool m_bIsBullet;
171 ncSurfacePropEntity m_eMultiTarget;
172 int m_iMultiValue;
173 int m_iMultiBody;
174 int m_iShots;
175 vector m_vecSpread;
176 float m_flDamage;
177 string m_strDecalGroup;
178 float m_flRange;
179
180 /* Nuclide additions */
181 bool m_bStickToWorld;
182 bool m_bStickToActor;
183 bool m_bThrustHoming;
184 bool m_bInheritVelocity;
185 bool m_bReflect;
186 bool m_bTrackEnemy;
187 vector m_trackJitter;
188 float m_trackDelay;
189 string m_defPlaneImpact;
190
191 ncTimer m_thrustHandler;
192 vector m_hitLocation;
193 bool m_noFX;
194
195 nonvirtual void _AnimateThink(void);
196 nonvirtual void _ThrustThink(void);
197 nonvirtual void _AnimateThinkDead(void);
198
199 virtual void _ApplyDamage(void);
200 virtual void _FireSingle(vector,vector,float,float);
201
202 virtual void OnRemoveEntity(void);
203#endif
204};
205
206#ifdef SERVER
207ncProjectile ncProjectile_SpawnDef(string entityDef, ncActor theOwner);
208ncProjectile ncProjectile_SpawnDefAtPosition(string entityDef, ncActor theOwner, vector vecOrigin, vector vecAngles);
209ncProjectile ncProjectile_SpawnDefAttachment(string entityDef, ncActor theOwner, int attachmentID);
210#endif
This entity class represents an object with choreographed/free-form movement.
Definition: Actor.h:72
This entity class represents an attack.
Definition: Attack.h:22
This entity class represents an interactive projectile.
Definition: Projectile.h:48
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:1224
virtual void Trigger(entity, triggermode_t)
Called whenever we're legacy triggered by another object or function.
Definition: Projectile.qc:529
nonvirtual ncWeapon GetWeaponOwner(void)
Definition: Projectile.qc:630
nonvirtual void _Explode(entity)
Definition: Projectile.qc:757
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:716
nonvirtual void SetLightRadius(float)
Definition: Projectile.qc:618
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:726
virtual void Spawned(void)
Called when the entity is fulled initialized.
Definition: Projectile.qc:535
virtual void HasExploded(void)
Definition: Projectile.qc:751
virtual void postdraw(void)
Client: Run after the rendering of 3D world is complete.
Definition: Projectile.qc:1317
virtual void Pain(entity, entity, int, vector, vector, int)
Called whenever the entity receives damage.
Definition: Projectile.qc:594
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
Definition: Projectile.qc:1291
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:1249
nonvirtual void EnableDetonateOnWorld(bool)
Definition: Projectile.qc:648
nonvirtual void SetLightColor(vector)
Definition: Projectile.qc:612
virtual void Touch(entity)
Called upon the projectile touching another object.
Definition: Projectile.qc:545
nonvirtual void EnableStickToWorld(bool)
Definition: Projectile.qc:660
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: Projectile.qc:369
nonvirtual void EnableDetonateOnActor(bool)
Definition: Projectile.qc:654
virtual void _LaunchHitscan(vector, vector, float)
Definition: Projectile.qc:858
nonvirtual void EnableInheritVelocity(bool)
Definition: Projectile.qc:678
nonvirtual void EnableDetonateOnFuse(bool)
Definition: Projectile.qc:636
nonvirtual void EnableThrustHoming(bool)
Definition: Projectile.qc:672
nonvirtual void SetImpact(void(entity, entity))
Sets the function that'll be called upon impact of the projectile onto a surface.
Definition: Projectile.qc:684
nonvirtual void SetWeaponOwner(ncWeapon)
Definition: Projectile.qc:624
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: Projectile.qc:312
virtual float predraw(void)
Definition: Projectile.qc:1327
nonvirtual void EnableStickToActor(bool)
Definition: Projectile.qc:666
virtual void Death(entity, entity, int, vector, vector, int)
Called when the health is equal or below 0.
Definition: Projectile.qc:600
virtual void Launch(vector, vector, float, float, float)
Definition: Projectile.qc:1096
nonvirtual void _FuseEnded(void)
Definition: Projectile.qc:736
nonvirtual void EnableDetonateOnDeath(bool)
Definition: Projectile.qc:642
This entity represents an ncRenderableEntity with interactive surface properties.
Definition: SurfacePropEntity.h:52
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:170
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
entityDefAPI_t entityDef
Definition: api.h:366