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
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 209 of file projectile.qc.

210{
211 if (this.count & 0x80)
212 {
213 tracebox(this.origin, this.mins, this.maxs, this.origin + this.velocity * 0.05, MOVE_NORMAL, this);
215 }
216}
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:30

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 199 of file projectile.qc.

200{
201 TC(int, ch);
202 if (e.silent)
203 return;
204
205 sound(e, ch, samp, vol, attn);
206 e.snd_looping = ch;
207}
#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 218 of file projectile.qc.

219{
220 // projectile properties:
221 // kind (interpolated, or clientside)
222 //
223 // modelindex
224 // origin
225 // scale
226 // if clientside:
227 // velocity
228 // gravity
229 // soundindex (hardcoded list)
230 // effects
231 //
232 // projectiles don't send angles, because they always follow the velocity
233
234 int f = ReadByte();
235 this.count = (f & 0x80);
236 this.flags |= FL_PROJECTILE;
238 this.solid = SOLID_TRIGGER;
239 // this.effects = EF_NOMODELFLAGS;
240
241 // this should make collisions with bmodels more exact, but it leads to
242 // projectiles no longer being able to lie on a bmodel
244 if (f & 0x40)
245 SET_ONGROUND(this);
246 else
247 UNSET_ONGROUND(this);
248
249 if (!this.move_time)
250 {
251 // for some unknown reason, we don't need to care for
252 // sv_gameplayfix_delayprojectiles here.
253 this.move_time = time;
254 this.spawntime = time;
255 }
256 else
257 {
258 this.move_time = max(this.move_time, time);
259 }
260
261 if (!(this.count & 0x80))
263
264 if (f & 1)
265 {
266 this.origin = ReadVector();
267 setorigin(this, this.origin);
268 if (this.count & 0x80)
269 {
270 this.velocity = ReadVector();
271 if (f & 0x10)
272 this.gravity = ReadCoord();
273 else
274 this.gravity = 0; // none
275 }
276
277 if (time == this.spawntime || (this.count & 0x80) || (f & 0x08))
278 {
279 this.trail_oldorigin = this.origin;
280 if (!(this.count & 0x80))
282 }
283
284 if (f & 0x20)
285 {
286 float fadetime = ReadByte();
287 float faderate = ReadByte();
288
289 // workaround for division by 0
290 // TODO: apply fade settings WITHOUT ticrate here and multiply during use cases
291 if(ticrate <= 0)
292 {
293 this.fade_time = 0;
294 this.fade_rate = 0;
295 }
296 else
297 {
298 this.fade_time = time + fadetime * ticrate;
299 this.fade_rate = 1 / (faderate * ticrate);
300 }
301 }
302 else
303 {
304 this.fade_time = 0;
305 this.fade_rate = 0;
306 }
307
308 int proj_team = ReadByte();
309
310 if(teamplay)
311 {
312 this.team = proj_team - 1;
313 if(proj_team)
314 this.colormap = (this.team) * 0x11; // note: team - 1 on server (client uses different numbers)
315 else
316 this.colormap = 0x00;
317 this.colormap |= BIT(10); // RENDER_COLORMAPPED
318 }
319 else
320 {
321 this.team = 0;
322 this.colormap = proj_team;
323 }
324 // TODO: projectiles use glowmaps for their color, not teams
325 #if 0
326 if(this.colormap > 0)
327 this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true);
328 else
329 this.glowmod = '1 1 1';
330 #endif
331 }
332
333 if (f & 2)
334 {
335 this.cnt = ReadByte();
336
337 this.silent = (this.cnt & 0x80);
338 this.cnt = (this.cnt & 0x7F);
339
340 this.scale = 1;
341 this.traileffect = 0;
342 switch (this.cnt)
343 {
344#define HANDLE(id) case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##id);
345 HANDLE(ELECTRO) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
346 HANDLE(ROCKET) this.traileffect = EFFECT_TR_ROCKET.m_id; this.scale = 2; break;
347 HANDLE(CRYLINK) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
348 HANDLE(CRYLINK_BOUNCING) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
349 HANDLE(ELECTRO_BEAM) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
350 HANDLE(GRENADE) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
351 HANDLE(GRENADE_BOUNCING) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
352 HANDLE(MINE) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
353 HANDLE(BLASTER) this.traileffect = EFFECT_Null.m_id; break;
354 HANDLE(ARC_BOLT) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; break;
355 HANDLE(HLAC) this.traileffect = EFFECT_Null.m_id; break;
356 HANDLE(PORTO_RED) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
357 HANDLE(PORTO_BLUE) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
358 HANDLE(HOOKBOMB) this.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
359 HANDLE(HAGAR) this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
360 HANDLE(HAGAR_BOUNCING) this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
361 HANDLE(FIREBALL) this.modelindex = 0; this.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
362 HANDLE(FIREMINE) this.modelindex = 0; this.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
363 HANDLE(TAG) this.traileffect = EFFECT_TR_ROCKET.m_id; break;
364 HANDLE(FLAC) this.scale = 0.4; this.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
365 HANDLE(SEEKER) this.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
366
367 HANDLE(MAGE_SPIKE) this.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
368 HANDLE(GOLEM_LIGHTNING) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
369
370 HANDLE(RAPTORBOMB) this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
371 HANDLE(RAPTORBOMBLET) this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
372 HANDLE(RAPTORCANNON) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
373
374 HANDLE(SPIDERROCKET) this.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
375 HANDLE(WAKIROCKET) this.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
376 HANDLE(WAKICANNON) this.traileffect = EFFECT_Null.m_id; break;
377
378 HANDLE(BUMBLE_GUN) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
379 HANDLE(BUMBLE_BEAM) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
380
381 HANDLE(RPC) this.traileffect = EFFECT_TR_ROCKET.m_id; break;
382
383 HANDLE(ROCKETMINSTA_LASER) this.traileffect = EFFECT_ROCKETMINSTA_LASER.m_id; break;
384#undef HANDLE
385 default:
386 if (MUTATOR_CALLHOOK(Ent_Projectile, this))
387 break;
388
389 error("Received invalid CSQC projectile, can't work with this!");
390 break;
391 }
392
393 this.mins = '0 0 0';
394 this.maxs = '0 0 0';
395 this.colormod = '0 0 0';
396 settouch(this, SUB_Stop);
398 this.alphamod = 1;
399
400 switch (this.cnt)
401 {
403 // only new engines support sound moving with object
404 loopsound(this, CH_SHOTS_SINGLE, SND_ELECTRO_FLY, VOL_BASE, ATTEN_NORM);
405 this.mins = '-4 -4 -4';
406 this.maxs = '4 4 4';
408 settouch(this, func_null);
409 this.bouncefactor = WEP_CVAR_SEC(WEP_ELECTRO, bouncefactor);
410 this.bouncestop = WEP_CVAR_SEC(WEP_ELECTRO, bouncestop);
411 break;
412 case PROJECTILE_RPC:
414 loopsound(this, CH_SHOTS_SINGLE, SND_DEVASTATOR_FLY, VOL_BASE, ATTEN_NORM);
415 this.mins = '-3 -3 -3';
416 this.maxs = '3 3 3';
417 break;
419 this.mins = '-3 -3 -3';
420 this.maxs = '3 3 3';
421 break;
423 this.mins = '-3 -3 -3';
424 this.maxs = '3 3 3';
426 settouch(this, func_null);
427 this.bouncefactor = WEP_CVAR(WEP_MORTAR, bouncefactor);
428 this.bouncestop = WEP_CVAR(WEP_MORTAR, bouncestop);
429 break;
431 this.mins = '-8 -8 -8';
432 this.maxs = '8 8 8';
433 this.scale = 2.5;
434 this.avelocity = randomvec() * 720;
435 break;
436 case PROJECTILE_MINE:
437 this.mins = '-4 -4 -4';
438 this.maxs = '4 4 4';
439 this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true);
440 break;
442 this.colormod = '2 1 1';
443 this.alphamod = 0.5;
445 settouch(this, func_null);
446 break;
448 this.colormod = '1 1 2';
449 this.alphamod = 0.5;
451 settouch(this, func_null);
452 break;
455 settouch(this, func_null);
456 break;
459 settouch(this, func_null);
460 break;
462 loopsound(this, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
463 this.mins = '-16 -16 -16';
464 this.maxs = '16 16 16';
465 break;
467 loopsound(this, CH_SHOTS_SINGLE, SND_FIREBALL_FLY, VOL_BASE, ATTEN_NORM);
469 settouch(this, func_null);
470 this.mins = '-4 -4 -4';
471 this.maxs = '4 4 4';
472 break;
473 case PROJECTILE_TAG:
474 this.mins = '-2 -2 -2';
475 this.maxs = '2 2 2';
476 break;
477 case PROJECTILE_FLAC:
478 this.mins = '-2 -2 -2';
479 this.maxs = '2 2 2';
480 break;
482 loopsound(this, CH_SHOTS_SINGLE, SND_SEEKER_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
483 this.mins = '-4 -4 -4';
484 this.maxs = '4 4 4';
485 break;
488 settouch(this, func_null);
489 break;
491 this.mins = '-3 -3 -3';
492 this.maxs = '3 3 3';
493 break;
495 break;
497 break;
499 loopsound(this, CH_SHOTS_SINGLE, SND_VEH_SPIDERBOT_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
500 break;
502 loopsound(this, CH_SHOTS_SINGLE, SND_VEH_RACER_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
503 break;
505 if(this.colormap > 0)
506 this.colormod = colormapPaletteColor(this.colormap & 0x0F, true);
507 break;
508 default:
509 break;
510 }
511
512 MUTATOR_CALLHOOK(EditProjectile, this);
513
514 setsize(this, this.mins, this.maxs);
515 }
516
517 return = true;
518
519 if (this.gravity)
520 {
521 if (this.move_movetype == MOVETYPE_FLY)
525 }
526 else
527 {
528 if (this.move_movetype == MOVETYPE_TOSS)
530 if (this.move_movetype == MOVETYPE_BOUNCE)
532 }
533
534 if (!(this.count & 0x80))
536
537 this.draw = Projectile_Draw;
538 if (isnew) IL_PUSH(g_drawables, this);
539 this.entremove = Ent_RemoveProjectile;
540}
#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
float cnt
Definition powerups.qc:24
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
vector glowmod
bool silent
solid
Definition ent_cs.qc:165
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:367
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:47
float move_nomonsters
Definition movetypes.qh:88
const int MOVETYPE_BOUNCEMISSILE
Definition movetypes.qh:140
float move_time
Definition movetypes.qh:77
float move_movetype
Definition movetypes.qh:76
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
const int MOVETYPE_FLY
Definition movetypes.qh:134
const int MOVETYPE_TOSS
Definition movetypes.qh:135
float bouncestop
Definition movetypes.qh:46
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
var void func_null()
#define error
Definition pre.qh:6
void Projectile_Draw(entity this)
Definition projectile.qc:80
float scale
Definition projectile.qc:14
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:18
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:73
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:321
#define WEP_CVAR_SEC(wep, name)
Definition all.qh:323

References ATTEN_NORM, avelocity, BIT, bouncefactor, bouncestop, CH_SHOTS_SINGLE, cnt, colormap, colormapPaletteColor, colormod, count, 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 542 of file projectile.qc.

543{
544 MUTATOR_CALLHOOK(PrecacheProjectiles);
545}

References MUTATOR_CALLHOOK.

◆ Projectile_Draw()

void Projectile_Draw ( entity this)

Definition at line 80 of file projectile.qc.

81{
82 vector rot;
83 vector trailorigin;
84 int f;
85 bool drawn;
86 float t;
87 float a;
88
89 f = this.flags;
90
91 if (this.count & 0x80)
92 {
93 // UNSET_ONGROUND(this);
96 // the trivial movetypes do not have to match the
97 // server's ticrate as they are ticrate independent
98 // NOTE: this assumption is only true if MOVETYPE_FLY
99 // projectiles detonate on impact. If they continue
100 // moving, we might still be ticrate dependent.
101 else
103 if (!IS_ONGROUND(this))
104 if (this.velocity != '0 0 0')
105 this.angles = vectoangles(this.velocity);
106 }
107 else
108 {
110 }
111
112 if (this.count & 0x80)
113 {
114 drawn = (time >= this.spawntime - 0.02);
115 t = max(time, this.spawntime);
116 }
117 else
118 {
119 drawn = (this.iflags & IFLAG_VALID);
120 t = time;
121 }
122 bool is_nade = Projectile_isnade(this.cnt);
123
124 if (!(f & FL_ONGROUND))
125 {
126 rot = '0 0 0';
127 if (is_nade) rot = this.avelocity;
128 else switch (this.cnt)
129 {
131 rot = '0 -1000 0'; // sideways
132 break;
134 rot = '1000 0 0'; // forward
135 break;
137 rot = '0 0 720'; // spinning
138 break;
139 }
140
141 if (rot)
142 {
143 if (!rot.x && !rot.y)
144 {
145 // cheaper z-only rotation formula
146 this.angles.z = (rot.z * (t - this.spawntime)) % 360;
147 if (this.angles.z < 0)
148 this.angles.z += 360;
149 }
150 else
152 }
153 }
154
155 // negation used to ensure a zero fade_(time/rate) does not affect opacity
156 a = 1 - (time - this.fade_time) * this.fade_rate;
157 this.alpha = bound(0, this.alphamod * a, 1);
158 if (this.alpha <= 0)
159 drawn = 0;
160 this.renderflags = 0;
161
162 vector ang = this.angles;
163 ang.x = -ang.x;
164 trailorigin = this.origin;
165 if (is_nade)
166 {
168 trailorigin += v_up * 4;
169 }
170 else switch (this.cnt)
171 {
175 trailorigin += v_right * 1 + v_forward * -10;
176 break;
177 }
178
179 if (drawn)
180 Projectile_DrawTrail(this, trailorigin);
181 else
182 Projectile_ResetTrail(this, trailorigin);
183
184 this.drawmask = 0;
185
186 if (!drawn)
187 return;
188
189 switch (this.cnt)
190 {
191 // Possibly add dlights here.
192 default:
193 break;
194 }
195
196 this.drawmask = MASK_NORMAL;
197}
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:77
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:121
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:129
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define makevectors
Definition post.qh:21
void Projectile_ResetTrail(entity this, vector to)
Definition projectile.qc:24
bool autocvar_cl_projectiles_sloppy
Definition projectile.qh:5
const int PROJECTILE_HOOKBOMB
vector
Definition self.qh:92
vector vector ang
Definition self.qh:92

References alpha, ang, angles, AnglesTransform_FromAngles(), AnglesTransform_Multiply(), AnglesTransform_ToAngles(), autocvar_cl_projectiles_sloppy, avelocity, bound(), cnt, count, 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 30 of file projectile.qc.

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

References alpha, cnt, colormod, 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 24 of file projectile.qc.

25{
26 this.trail_oldorigin = to;
27 this.trail_oldtime = time;
28}

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 18 of file projectile.qc.

19{
20 this.velocity = this.avelocity = '0 0 0';
22}

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.

◆ glowmod

vector glowmod

Definition at line 16 of file projectile.qc.

◆ scale