Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
projectile.qc File Reference
Include dependency graph for projectile.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HANDLE(id)

Functions

void Ent_RemoveProjectile (entity this)
void loopsound (entity e, int ch, Sound samp, float vol, float attn)
 NET_HANDLE (ENT_CLIENT_PROJECTILE, bool isnew)
 PRECACHE (Projectiles)
void Projectile_Draw (entity this)
void Projectile_DrawTrail (entity this, vector to)
void Projectile_ResetTrail (entity this, vector to)
void SUB_Stop (entity this, entity toucher)

Variables

float alpha
vector colormod
int csqcprojectile_type
vector glowmod
float scale

Macro Definition Documentation

◆ HANDLE

#define HANDLE ( id)
Value:
case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##id);
#define setmodel(this, m)
Definition model.qh:26

Referenced by NET_HANDLE().

Function Documentation

◆ Ent_RemoveProjectile()

void Ent_RemoveProjectile ( entity this)

Definition at line 211 of file projectile.qc.

212{
213 if (this.count & 0x80)
214 {
215 tracebox(this.origin, this.mins, this.maxs, this.origin + this.velocity * 0.05, MOVE_NORMAL, this);
217 }
218}
float count
Definition powerups.qc:22
const float MOVE_NORMAL
vector mins
vector velocity
vector trace_endpos
vector maxs
vector origin
void Projectile_DrawTrail(entity this, vector to)
Definition projectile.qc:32

References count, entity(), maxs, mins, MOVE_NORMAL, origin, Projectile_DrawTrail(), trace_endpos, and velocity.

Referenced by NET_HANDLE().

◆ loopsound()

void loopsound ( entity e,
int ch,
Sound samp,
float vol,
float attn )

Definition at line 201 of file projectile.qc.

202{
203 TC(int, ch);
204 if (e.silent)
205 return;
206
207 sound(e, ch, samp, vol, attn);
208 e.snd_looping = ch;
209}
#define TC(T, sym)
Definition _all.inc:82
#define sound(e, c, s, v, a)
Definition sound.qh:52

References entity(), sound, and TC.

Referenced by MUTATOR_HOOKFUNCTION(), NET_HANDLE(), and NET_HANDLE().

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_PROJECTILE ,
bool isnew )

Definition at line 220 of file projectile.qc.

221{
222 // projectile properties:
223 // kind (interpolated, or clientside)
224 //
225 // modelindex
226 // origin
227 // scale
228 // if clientside:
229 // velocity
230 // gravity
231 // soundindex (hardcoded list)
232 // effects
233 //
234 // projectiles don't send angles, because they always follow the velocity
235
236 int f = ReadByte();
237 this.count = (f & 0x80);
238 this.flags |= FL_PROJECTILE;
240 this.solid = SOLID_TRIGGER;
241 // this.effects = EF_NOMODELFLAGS;
242
243 // this should make collisions with bmodels more exact, but it leads to
244 // projectiles no longer being able to lie on a bmodel
246 if (f & 0x40)
247 SET_ONGROUND(this);
248 else
249 UNSET_ONGROUND(this);
250
251 if (!this.move_time)
252 {
253 // for some unknown reason, we don't need to care for
254 // sv_gameplayfix_delayprojectiles here.
255 this.move_time = time;
256 this.spawntime = time;
257 }
258 else
259 {
260 this.move_time = max(this.move_time, time);
261 }
262
263 if (!(this.count & 0x80))
265
266 if (f & 1)
267 {
268 this.origin = ReadVector();
269 setorigin(this, this.origin);
270 if (this.count & 0x80)
271 {
272 this.velocity = ReadVector();
273 if (f & 0x10)
274 this.gravity = ReadCoord();
275 else
276 this.gravity = 0; // none
277 }
278
279 if (time == this.spawntime || (this.count & 0x80) || (f & 0x08))
280 {
281 this.trail_oldorigin = this.origin;
282 if (!(this.count & 0x80))
284 }
285
286 if (f & 0x20)
287 {
288 float fadetime = ReadByte();
289 float faderate = ReadByte();
290
291 // workaround for division by 0
292 // TODO: apply fade settings WITHOUT ticrate here and multiply during use cases
293 if(ticrate <= 0)
294 {
295 this.fade_time = 0;
296 this.fade_rate = 0;
297 }
298 else
299 {
300 this.fade_time = time + fadetime * ticrate;
301 this.fade_rate = 1 / (faderate * ticrate);
302 }
303 }
304 else
305 {
306 this.fade_time = 0;
307 this.fade_rate = 0;
308 }
309
310 int proj_team = ReadByte();
311
312 if(teamplay)
313 {
314 this.team = proj_team - 1;
315 if(proj_team)
316 this.colormap = (this.team) * 0x11; // note: team - 1 on server (client uses different numbers)
317 else
318 this.colormap = 0x00;
319 this.colormap |= BIT(10); // RENDER_COLORMAPPED
320 }
321 else
322 {
323 this.team = 0;
324 this.colormap = proj_team;
325 }
326 // TODO: projectiles use glowmaps for their color, not teams
327 #if 0
328 if(this.colormap > 0)
329 this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true);
330 else
331 this.glowmod = '1 1 1';
332 #endif
333 }
334
335 this.silent = (f & 4);
336
337 if (f & 2)
338 {
340
341 this.scale = 1;
342 this.traileffect = 0;
343 switch (this.csqcprojectile_type)
344 {
345#define HANDLE(id) case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##id);
346 HANDLE(ELECTRO) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
347 HANDLE(ROCKET) this.traileffect = EFFECT_TR_ROCKET.m_id; this.scale = 2; break;
348 HANDLE(CRYLINK) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
349 HANDLE(CRYLINK_BOUNCING) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
350 HANDLE(ELECTRO_BEAM) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
351 HANDLE(GRENADE) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
352 HANDLE(GRENADE_BOUNCING) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
353 HANDLE(MINE) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
354 HANDLE(BLASTER) this.traileffect = EFFECT_Null.m_id; break;
355 HANDLE(ARC_BOLT) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; break;
356 HANDLE(HLAC) this.traileffect = EFFECT_Null.m_id; break;
357 HANDLE(PORTO_RED) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
358 HANDLE(PORTO_BLUE) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
359 HANDLE(HOOKBOMB) this.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
360 HANDLE(HAGAR) this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
361 HANDLE(HAGAR_BOUNCING) this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
362 HANDLE(FIREBALL) this.modelindex = 0; this.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
363 HANDLE(FIREMINE) this.modelindex = 0; this.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
364 HANDLE(TAG) this.traileffect = EFFECT_TR_ROCKET.m_id; break;
365 HANDLE(FLAC) this.scale = 0.4; this.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
366 HANDLE(SEEKER) this.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
367
368 HANDLE(MAGE_SPIKE) this.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
369 HANDLE(GOLEM_LIGHTNING) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
370
371 HANDLE(RAPTORBOMB) this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
372 HANDLE(RAPTORBOMBLET) this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
373 HANDLE(RAPTORCANNON) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
374
375 HANDLE(SPIDERROCKET) this.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
376 HANDLE(WAKIROCKET) this.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
377 HANDLE(WAKICANNON) this.traileffect = EFFECT_Null.m_id; break;
378
379 HANDLE(BUMBLE_GUN) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
380 HANDLE(BUMBLE_BEAM) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
381
382 HANDLE(RPC) this.traileffect = EFFECT_TR_ROCKET.m_id; break;
383
384 HANDLE(ROCKETMINSTA_LASER) this.traileffect = EFFECT_ROCKETMINSTA_LASER.m_id; break;
385#undef HANDLE
386 default:
387 if (MUTATOR_CALLHOOK(Ent_Projectile, this))
388 break;
389
390 error("Received invalid CSQC projectile, can't work with this!");
391 break;
392 }
393
394 this.mins = '0 0 0';
395 this.maxs = '0 0 0';
396 this.colormod = '0 0 0';
397 settouch(this, SUB_Stop);
399 this.alphamod = 1;
400
401 switch (this.csqcprojectile_type)
402 {
404 // only new engines support sound moving with object
405 loopsound(this, CH_SHOTS_SINGLE, SND_ELECTRO_FLY, VOL_BASE, ATTEN_NORM);
406 this.mins = '-4 -4 -4';
407 this.maxs = '4 4 4';
409 settouch(this, func_null);
410 this.bouncefactor = WEP_CVAR_SEC(WEP_ELECTRO, bouncefactor);
411 this.bouncestop = WEP_CVAR_SEC(WEP_ELECTRO, bouncestop);
412 break;
413 case PROJECTILE_RPC:
415 loopsound(this, CH_SHOTS_SINGLE, SND_DEVASTATOR_FLY, VOL_BASE, ATTEN_NORM);
416 this.mins = '-3 -3 -3';
417 this.maxs = '3 3 3';
418 break;
420 this.mins = '-3 -3 -3';
421 this.maxs = '3 3 3';
422 break;
424 this.mins = '-3 -3 -3';
425 this.maxs = '3 3 3';
427 settouch(this, func_null);
428 this.bouncefactor = WEP_CVAR(WEP_MORTAR, bouncefactor);
429 this.bouncestop = WEP_CVAR(WEP_MORTAR, bouncestop);
430 break;
432 this.mins = '-8 -8 -8';
433 this.maxs = '8 8 8';
434 this.scale = 2.5;
435 this.avelocity = randomvec() * 720;
436 break;
437 case PROJECTILE_MINE:
438 this.mins = '-4 -4 -4';
439 this.maxs = '4 4 4';
440 this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true);
441 break;
443 this.colormod = '2 1 1';
444 this.alphamod = 0.5;
446 settouch(this, func_null);
447 break;
449 this.colormod = '1 1 2';
450 this.alphamod = 0.5;
452 settouch(this, func_null);
453 break;
456 settouch(this, func_null);
457 break;
460 settouch(this, func_null);
461 break;
463 loopsound(this, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
464 this.mins = '-16 -16 -16';
465 this.maxs = '16 16 16';
466 break;
468 loopsound(this, CH_SHOTS_SINGLE, SND_FIREBALL_FLY, VOL_BASE, ATTEN_NORM);
470 settouch(this, func_null);
471 this.mins = '-4 -4 -4';
472 this.maxs = '4 4 4';
473 break;
474 case PROJECTILE_TAG:
475 this.mins = '-2 -2 -2';
476 this.maxs = '2 2 2';
477 break;
478 case PROJECTILE_FLAC:
479 this.mins = '-2 -2 -2';
480 this.maxs = '2 2 2';
481 break;
483 loopsound(this, CH_SHOTS_SINGLE, SND_SEEKER_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
484 this.mins = '-4 -4 -4';
485 this.maxs = '4 4 4';
486 break;
489 settouch(this, func_null);
490 break;
492 this.mins = '-3 -3 -3';
493 this.maxs = '3 3 3';
494 break;
496 break;
498 break;
500 loopsound(this, CH_SHOTS_SINGLE, SND_VEH_SPIDERBOT_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
501 break;
503 loopsound(this, CH_SHOTS_SINGLE, SND_VEH_RACER_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
504 break;
506 if(this.colormap > 0)
507 this.colormod = colormapPaletteColor(this.colormap & 0x0F, true);
508 break;
509 default:
510 break;
511 }
512
513 MUTATOR_CALLHOOK(EditProjectile, this);
514
515 setsize(this, this.mins, this.maxs);
516 }
517
518 return = true;
519
520 if (this.gravity)
521 {
522 if (this.move_movetype == MOVETYPE_FLY)
526 }
527 else
528 {
529 if (this.move_movetype == MOVETYPE_TOSS)
531 if (this.move_movetype == MOVETYPE_BOUNCE)
533 }
534
535 if (!(this.count & 0x80))
537
538 this.draw = Projectile_Draw;
539 if (isnew) IL_PUSH(g_drawables, this);
540 this.entremove = Ent_RemoveProjectile;
541}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
Definition hlac.qh:11
vector colormod
Definition powerups.qc:21
float gravity
Definition items.qh:17
float spawntime
Definition items.qh:16
IntrusiveList g_drawables
Definition main.qh:91
int team
Definition main.qh:188
float ticrate
Definition main.qh:209
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
const int FL_PROJECTILE
Definition constants.qh:85
float flags
const float SOLID_TRIGGER
float modelindex
vector avelocity
float time
float MOVE_WORLDONLY
float colormap
float solid
vector glowmod
bool silent
void InterpolateOrigin_Undo(entity this)
snap origin to iorigin2 (actual origin)
void InterpolateOrigin_Reset(entity this)
void InterpolateOrigin_Note(entity this)
const int IFLAG_AUTOANGLES
const int IFLAG_INTERNALMASK
const int IFLAG_ANGLES
const int IFLAG_ORIGIN
int iflags
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define ReadVector()
Definition net.qh:349
int ReadByte()
vector randomvec(void)
float max(float f,...)
fadetime
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
#define SET_ONGROUND(s)
Definition movetypes.qh:17
float bouncefactor
Definition movetypes.qh:45
float move_nomonsters
Definition movetypes.qh:92
const int MOVETYPE_BOUNCEMISSILE
Definition movetypes.qh:144
float move_time
Definition movetypes.qh:81
float move_movetype
Definition movetypes.qh:80
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
const int MOVETYPE_FLY
Definition movetypes.qh:138
const int MOVETYPE_TOSS
Definition movetypes.qh:139
float bouncestop
Definition movetypes.qh:44
const int MOVETYPE_BOUNCE
Definition movetypes.qh:143
var void func_null()
#define error
Definition pre.qh:6
void Projectile_Draw(entity this)
Definition projectile.qc:82
float scale
Definition projectile.qc:14
int csqcprojectile_type
Definition projectile.qc:18
void loopsound(entity e, int ch, Sound samp, float vol, float attn)
void Ent_RemoveProjectile(entity this)
#define HANDLE(id)
void SUB_Stop(entity this, entity toucher)
Definition projectile.qc:20
fade_rate
Definition projectile.qh:14
const int PROJECTILE_WAKIROCKET
const int PROJECTILE_TAG
Definition projectiles.qh:5
const int PROJECTILE_GRENADE_BOUNCING
Definition projectiles.qh:9
const int PROJECTILE_GOLEM_LIGHTNING
const int PROJECTILE_ELECTRO
Definition projectiles.qh:3
const int PROJECTILE_FIREMINE
const int PROJECTILE_PORTO_BLUE
const int PROJECTILE_FIREBALL
const int PROJECTILE_RAPTORCANNON
const int PROJECTILE_CRYLINK_BOUNCING
const int PROJECTILE_RPC
const int PROJECTILE_FLAC
const int PROJECTILE_ROCKETMINSTA_LASER
const int PROJECTILE_HAGAR_BOUNCING
const int PROJECTILE_ROCKET
Definition projectiles.qh:4
const int PROJECTILE_MINE
const int PROJECTILE_SPIDERROCKET
const int PROJECTILE_RAPTORBOMBLET
const int PROJECTILE_PORTO_RED
const int PROJECTILE_RAPTORBOMB
const int PROJECTILE_GRENADE
Definition projectiles.qh:8
const int PROJECTILE_ARC_BOLT
const int PROJECTILE_SEEKER
#define settouch(e, f)
Definition self.qh:77
float fade_time
Definition common.qh:23
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS_SINGLE
Definition sound.qh:15
const float ATTEN_NORM
Definition sound.qh:30
bool teamplay
Definition teams.qh:59
#define WEP_CVAR(wep, name)
Definition all.qh:337
#define WEP_CVAR_SEC(wep, name)
Definition all.qh:339

References ATTEN_NORM, avelocity, BIT, bouncefactor, bouncestop, CH_SHOTS_SINGLE, colormap, colormapPaletteColor, colormod, count, csqcprojectile_type, Ent_RemoveProjectile(), error, fade_rate, fade_time, fadetime, FL_PROJECTILE, flags, func_null(), g_drawables, glowmod, gravity, HANDLE, IFLAG_ANGLES, IFLAG_AUTOANGLES, IFLAG_INTERNALMASK, IFLAG_ORIGIN, iflags, IL_PUSH(), InterpolateOrigin_Note(), InterpolateOrigin_Reset(), InterpolateOrigin_Undo(), loopsound(), max(), maxs, mins, modelindex, move_movetype, move_nomonsters, move_time, MOVE_WORLDONLY, MOVETYPE_BOUNCE, MOVETYPE_BOUNCEMISSILE, MOVETYPE_FLY, MOVETYPE_TOSS, MUTATOR_CALLHOOK, origin, PROJECTILE_ARC_BOLT, PROJECTILE_CRYLINK_BOUNCING, Projectile_Draw(), PROJECTILE_ELECTRO, PROJECTILE_FIREBALL, PROJECTILE_FIREMINE, PROJECTILE_FLAC, PROJECTILE_GOLEM_LIGHTNING, PROJECTILE_GRENADE, PROJECTILE_GRENADE_BOUNCING, PROJECTILE_HAGAR_BOUNCING, PROJECTILE_MINE, PROJECTILE_PORTO_BLUE, PROJECTILE_PORTO_RED, PROJECTILE_RAPTORBOMB, PROJECTILE_RAPTORBOMBLET, PROJECTILE_RAPTORCANNON, PROJECTILE_ROCKET, PROJECTILE_ROCKETMINSTA_LASER, PROJECTILE_RPC, PROJECTILE_SEEKER, PROJECTILE_SPIDERROCKET, PROJECTILE_TAG, PROJECTILE_WAKIROCKET, randomvec(), ReadByte(), ReadVector, scale, set_movetype(), SET_ONGROUND, settouch, silent, solid, SOLID_TRIGGER, spawntime, SUB_Stop(), team, teamplay, ticrate, time, UNSET_ONGROUND, velocity, VOL_BASE, WEP_CVAR, and WEP_CVAR_SEC.

◆ PRECACHE()

PRECACHE ( Projectiles )

Definition at line 543 of file projectile.qc.

544{
545 MUTATOR_CALLHOOK(PrecacheProjectiles);
546}

References MUTATOR_CALLHOOK.

◆ Projectile_Draw()

void Projectile_Draw ( entity this)

Definition at line 82 of file projectile.qc.

83{
84 vector rot;
85 vector trailorigin;
86 int f;
87 bool drawn;
88 float t;
89 float a;
90
91 f = this.flags;
92
93 if (this.count & 0x80)
94 {
95 // UNSET_ONGROUND(this);
98 // the trivial movetypes do not have to match the
99 // server's ticrate as they are ticrate independent
100 // NOTE: this assumption is only true if MOVETYPE_FLY
101 // projectiles detonate on impact. If they continue
102 // moving, we might still be ticrate dependent.
103 else
105 if (!IS_ONGROUND(this))
106 if (this.velocity != '0 0 0')
107 this.angles = vectoangles(this.velocity);
108 }
109 else
110 {
112 }
113
114 if (this.count & 0x80)
115 {
116 drawn = (time >= this.spawntime - 0.02);
117 t = max(time, this.spawntime);
118 }
119 else
120 {
121 drawn = (this.iflags & IFLAG_VALID);
122 t = time;
123 }
124 bool is_nade = Projectile_isnade(this.csqcprojectile_type);
125
126 if (!(f & FL_ONGROUND))
127 {
128 rot = '0 0 0';
129 if (is_nade) rot = this.avelocity;
130 else switch (this.csqcprojectile_type)
131 {
133 rot = '0 -1000 0'; // sideways
134 break;
136 rot = '1000 0 0'; // forward
137 break;
139 rot = '0 0 720'; // spinning
140 break;
141 }
142
143 if (rot)
144 {
145 if (!rot.x && !rot.y)
146 {
147 // cheaper z-only rotation formula
148 this.angles.z = (rot.z * (t - this.spawntime)) % 360;
149 if (this.angles.z < 0)
150 this.angles.z += 360;
151 }
152 else
154 }
155 }
156
157 // negation used to ensure a zero fade_(time/rate) does not affect opacity
158 a = 1 - (time - this.fade_time) * this.fade_rate;
159 this.alpha = bound(0, this.alphamod * a, 1);
160 if (this.alpha <= 0)
161 drawn = 0;
162 this.renderflags = 0;
163
164 vector ang = this.angles;
165 ang.x = -ang.x;
166 trailorigin = this.origin;
167 if (is_nade)
168 {
170 trailorigin += v_up * 4;
171 }
172 else switch (this.csqcprojectile_type)
173 {
177 trailorigin += v_right * 1 + v_forward * -10;
178 break;
179 }
180
181 if (drawn)
182 Projectile_DrawTrail(this, trailorigin);
183 else
184 Projectile_ResetTrail(this, trailorigin);
185
186 this.drawmask = 0;
187
188 if (!drawn)
189 return;
190
191 switch (this.csqcprojectile_type)
192 {
193 // Possibly add dlights here.
194 default:
195 break;
196 }
197
198 this.drawmask = MASK_NORMAL;
199}
vector AnglesTransform_ToAngles(vector v)
vector AnglesTransform_Multiply(vector t1, vector t2)
vector AnglesTransform_FromAngles(vector v)
bool Projectile_isnade(int p)
Definition cl_nades.qc:82
float alpha
Definition items.qc:13
float renderflags
Definition main.qh:111
const int FL_ONGROUND
Definition constants.qh:78
vector v_up
float drawmask
const float MASK_NORMAL
vector v_right
vector v_forward
ent angles
Definition ent_cs.qc:146
void InterpolateOrigin_Do(entity this)
set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time
const int IFLAG_VALID
float bound(float min, float value, float max)
vector vectoangles(vector v)
void Movetype_Physics_MatchServer(entity this, bool sloppy)
Definition movetypes.qc:817
void Movetype_Physics_NoMatchServer(entity this)
Definition movetypes.qc:805
const int MOVETYPE_NONE
Definition movetypes.qh:133
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define makevectors
Definition post.qh:21
void Projectile_ResetTrail(entity this, vector to)
Definition projectile.qc:26
bool autocvar_cl_projectiles_sloppy
Definition projectile.qh:5
const int PROJECTILE_HOOKBOMB
vector
Definition self.qh:96
vector vector ang
Definition self.qh:96

References alpha, ang, angles, AnglesTransform_FromAngles(), AnglesTransform_Multiply(), AnglesTransform_ToAngles(), autocvar_cl_projectiles_sloppy, avelocity, bound(), count, csqcprojectile_type, drawmask, entity(), fade_rate, fade_time, FL_ONGROUND, flags, IFLAG_VALID, iflags, InterpolateOrigin_Do(), IS_ONGROUND, makevectors, MASK_NORMAL, max(), move_movetype, MOVETYPE_FLY, MOVETYPE_NONE, Movetype_Physics_MatchServer(), Movetype_Physics_NoMatchServer(), origin, Projectile_DrawTrail(), PROJECTILE_GRENADE, PROJECTILE_GRENADE_BOUNCING, PROJECTILE_HOOKBOMB, Projectile_isnade(), Projectile_ResetTrail(), PROJECTILE_ROCKET, renderflags, spawntime, time, v_forward, v_right, v_up, vectoangles(), vector, and velocity.

Referenced by NET_HANDLE().

◆ Projectile_DrawTrail()

void Projectile_DrawTrail ( entity this,
vector to )

Definition at line 32 of file projectile.qc.

33{
34 vector from = this.trail_oldorigin;
35 // float t0 = this.trail_oldtime;
36 this.trail_oldorigin = to;
37 this.trail_oldtime = time;
38
39 // force the effect even for stationary firemine
41 if (from == to)
42 ++from.z;
43
44 // Note: alpha value 0 actually means 1 on entities.
45 // This can be relevant when coming from CSQCModel_Effects_Apply.
46 float a = (this.alpha == 0) ? 1 : this.alpha;
47
48 // TODO: Do we actually need alpha support? Consider removing this
49 // support entirely and instead making necessary adjustments in
50 // effectinfo.
51 //
52 // Right now (2024-12-30), only Crylink can generate alpha via
53 // fade_rate/fade_time, and only PROJECTILE_PORTO_* set a fixed alpha
54 // (and reuse the Arc's TE_WIZSPIKE).
55 if (this.traileffect && a > 0)
56 {
57 float f = PARTICLES_DRAWASTRAIL;
58 if (a < 1)
59 {
60 // Do some of the fading using particle count, and some of it using alpha.
61 // Fading by particle count is less smooth but also cheaper to render.
62 // A higher power here performs more of the fading using particle count.
63 const float fade_power = 0.5;
64 particles_fade = pow(a, fade_power);
65 particles_alphamin = particles_alphamax = a / particles_fade; // == pow(a, 1 - fade_power)
67 //LOG_INFOF("particle fade: %f alpha: %f", particles_fade, particles_alphamin);
68 }
69 //else
70 // LOG_INFOF("particle fade skipped");
71
72 if (this.colormod != '0 0 0')
73 {
76 }
77 entity eff = REGISTRY_GET(Effects, this.traileffect);
78 boxparticles(particleeffectnum(eff), this, from, to, this.velocity, this.velocity, 1, f);
79 }
80}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector particles_colormin
float particles_alphamax
vector particles_colormax
float PARTICLES_USEALPHA
float particles_alphamin
float PARTICLES_USECOLOR
float particles_fade
float PARTICLES_USEFADE
float PARTICLES_DRAWASTRAIL
#define particleeffectnum(e)
Definition effect.qh:3
#define pow(a, b)
Definition _all.inc:67
#define REGISTRY_GET(id, i)
Definition registry.qh:62
entity this
Definition self.qh:76

References alpha, colormod, csqcprojectile_type, entity(), particleeffectnum, particles_alphamax, particles_alphamin, particles_colormax, particles_colormin, PARTICLES_DRAWASTRAIL, particles_fade, PARTICLES_USEALPHA, PARTICLES_USECOLOR, PARTICLES_USEFADE, pow, PROJECTILE_FIREMINE, REGISTRY_GET, time, vector, and velocity.

Referenced by CSQCModel_Effects_Apply(), Ent_RemoveProjectile(), and Projectile_Draw().

◆ Projectile_ResetTrail()

void Projectile_ResetTrail ( entity this,
vector to )

Definition at line 26 of file projectile.qc.

27{
28 this.trail_oldorigin = to;
29 this.trail_oldtime = time;
30}

References entity(), time, and vector.

Referenced by CSQCModel_Effects_Apply(), CSQCModel_Effects_PostUpdate(), and Projectile_Draw().

◆ SUB_Stop()

void SUB_Stop ( entity this,
entity toucher )

Definition at line 20 of file projectile.qc.

21{
22 this.velocity = this.avelocity = '0 0 0';
24}

References avelocity, entity(), MOVETYPE_NONE, set_movetype(), toucher, and velocity.

Referenced by NET_HANDLE().

Variable Documentation

◆ alpha

float alpha

Definition at line 13 of file projectile.qc.

◆ colormod

vector colormod

Definition at line 15 of file projectile.qc.

◆ csqcprojectile_type

int csqcprojectile_type

◆ glowmod

vector glowmod

Definition at line 16 of file projectile.qc.

◆ scale