Xonotic
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)   case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##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
 
float scale
 

Macro Definition Documentation

◆ HANDLE

#define HANDLE (   id)    case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##id);

Referenced by NET_HANDLE().

Function Documentation

◆ Ent_RemoveProjectile()

void Ent_RemoveProjectile ( entity  this)

Definition at line 177 of file projectile.qc.

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

Referenced by NET_HANDLE().

178 {
179  if (this.count & 0x80)
180  {
181  tracebox(this.origin, this.mins, this.maxs, this.origin + this.velocity * 0.05, MOVE_NORMAL, this);
183  }
184 }
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
vector maxs
Definition: csprogsdefs.qc:113
origin
Definition: ent_cs.qc:114
void Projectile_DrawTrail(entity this, vector to)
Definition: projectile.qc:29
vector mins
Definition: csprogsdefs.qc:113
vector trace_endpos
Definition: csprogsdefs.qc:37
float count
Definition: powerups.qc:22
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loopsound()

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

Definition at line 167 of file projectile.qc.

References sound, and TC.

Referenced by NET_HANDLE().

168 {
169  TC(int, ch);
170  if (e.silent)
171  return;
172 
173  sound(e, ch, samp, vol, attn);
174  e.snd_looping = ch;
175 }
#define TC(T, sym)
Definition: _all.inc:82
#define sound(e, c, s, v, a)
Definition: sound.qh:52
+ Here is the caller graph for this function:

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_PROJECTILE  ,
bool  isnew 
)

Definition at line 186 of file projectile.qc.

References ATTEN_NORM, avelocity, BIT, bouncefactor, bouncestop, CH_SHOTS_SINGLE, cnt, colormap, colormapPaletteColor, colormod, count, EFFECT_ROCKETMINSTA_LASER(), Ent_RemoveProjectile(), error(), fade_rate, fade_time, 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_GRENADE, PROJECTILE_GRENADE_BOUNCING, PROJECTILE_HAGAR_BOUNCING, PROJECTILE_MINE, PROJECTILE_PORTO_BLUE, PROJECTILE_PORTO_RED, PROJECTILE_RAPTORBOMB, PROJECTILE_RAPTORBOMBLET, PROJECTILE_RAPTORCANNON, PROJECTILE_ROCKET, PROJECTILE_RPC, PROJECTILE_SEEKER, PROJECTILE_SHAMBLER_LIGHTNING, PROJECTILE_SPIDERROCKET, PROJECTILE_TAG, PROJECTILE_WAKIROCKET, randomvec(), scale, set_movetype(), SET_ONGROUND, setorigin(), solid, SOLID_TRIGGER, spawntime, SUB_Stop(), team, teamplay, ticrate, time, UNSET_ONGROUND, velocity, VOL_BASE, WEP_CVAR, and WEP_CVAR_SEC.

187 {
188  // projectile properties:
189  // kind (interpolated, or clientside)
190  //
191  // modelindex
192  // origin
193  // scale
194  // if clientside:
195  // velocity
196  // gravity
197  // soundindex (hardcoded list)
198  // effects
199  //
200  // projectiles don't send angles, because they always follow the velocity
201 
202  int f = ReadByte();
203  this.count = (f & 0x80);
204  this.flags |= FL_PROJECTILE;
206  this.solid = SOLID_TRIGGER;
207  // this.effects = EF_NOMODELFLAGS;
208 
209  // this should make collisions with bmodels more exact, but it leads to
210  // projectiles no longer being able to lie on a bmodel
212  if (f & 0x40)
213  SET_ONGROUND(this);
214  else
215  UNSET_ONGROUND(this);
216 
217  if (!this.move_time)
218  {
219  // for some unknown reason, we don't need to care for
220  // sv_gameplayfix_delayprojectiles here.
221  this.move_time = time;
222  this.spawntime = time;
223  }
224  else
225  {
226  this.move_time = max(this.move_time, time);
227  }
228 
229  if (!(this.count & 0x80))
231 
232  if (f & 1)
233  {
234  this.origin = ReadVector();
235  setorigin(this, this.origin);
236  if (this.count & 0x80)
237  {
238  this.velocity = ReadVector();
239  if (f & 0x10)
240  this.gravity = ReadCoord();
241  else
242  this.gravity = 0; // none
243  }
244 
245  if (time == this.spawntime || (this.count & 0x80) || (f & 0x08))
246  {
247  this.trail_oldorigin = this.origin;
248  if (!(this.count & 0x80))
250  }
251 
252  if (f & 0x20)
253  {
254  this.fade_time = time + ReadByte() * ticrate;
255  this.fade_rate = 1 / (ReadByte() * ticrate);
256  }
257  else
258  {
259  this.fade_time = 0;
260  this.fade_rate = 0;
261  }
262 
263  int proj_team = ReadByte();
264  this.team = proj_team - 1;
265 
266  if(teamplay)
267  {
268  if(proj_team)
269  this.colormap = (this.team) * 0x11; // note: team - 1 on server (client uses different numbers)
270  else
271  this.colormap = 0x00;
272  this.colormap |= BIT(10); // RENDER_COLORMAPPED
273  }
274  else
275  this.colormap = proj_team;
276  // TODO: projectiles use glowmaps for their color, not teams
277  #if 0
278  if(this.colormap > 0)
279  this.glowmod = colormapPaletteColor(this.colormap & 0x0F, true) * 2;
280  else
281  this.glowmod = '1 1 1';
282  #endif
283  }
284 
285  if (f & 2)
286  {
287  this.cnt = ReadByte();
288 
289  this.silent = (this.cnt & 0x80);
290  this.cnt = (this.cnt & 0x7F);
291 
292  this.scale = 1;
293  this.traileffect = 0;
294  switch (this.cnt)
295  {
296 #define HANDLE(id) case PROJECTILE_##id: setmodel(this, MDL_PROJECTILE_##id);
297  HANDLE(ELECTRO) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
298  HANDLE(ROCKET) this.traileffect = EFFECT_TR_ROCKET.m_id; this.scale = 2; break;
299  HANDLE(CRYLINK) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
300  HANDLE(CRYLINK_BOUNCING) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
301  HANDLE(ELECTRO_BEAM) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
302  HANDLE(GRENADE) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
303  HANDLE(GRENADE_BOUNCING) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
304  HANDLE(MINE) this.traileffect = EFFECT_TR_GRENADE.m_id; break;
305  HANDLE(BLASTER) this.traileffect = EFFECT_Null.m_id; break;
306  HANDLE(ARC_BOLT) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; break;
307  HANDLE(HLAC) this.traileffect = EFFECT_Null.m_id; break;
308  HANDLE(PORTO_RED) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
309  HANDLE(PORTO_BLUE) this.traileffect = EFFECT_TR_WIZSPIKE.m_id; this.scale = 4; break;
310  HANDLE(HOOKBOMB) this.traileffect = EFFECT_TR_KNIGHTSPIKE.m_id; break;
311  HANDLE(HAGAR) this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
312  HANDLE(HAGAR_BOUNCING) this.traileffect = EFFECT_HAGAR_ROCKET.m_id; this.scale = 0.75; break;
313  HANDLE(FIREBALL) this.modelindex = 0; this.traileffect = EFFECT_FIREBALL.m_id; break; // particle effect is good enough
314  HANDLE(FIREMINE) this.modelindex = 0; this.traileffect = EFFECT_FIREMINE.m_id; break; // particle effect is good enough
315  HANDLE(TAG) this.traileffect = EFFECT_TR_ROCKET.m_id; break;
316  HANDLE(FLAC) this.scale = 0.4; this.traileffect = EFFECT_FLAC_TRAIL.m_id; break;
317  HANDLE(SEEKER) this.traileffect = EFFECT_SEEKER_TRAIL.m_id; break;
318 
319  HANDLE(MAGE_SPIKE) this.traileffect = EFFECT_TR_VORESPIKE.m_id; break;
320  HANDLE(SHAMBLER_LIGHTNING) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
321 
322  HANDLE(RAPTORBOMB) this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
323  HANDLE(RAPTORBOMBLET) this.gravity = 1; this.avelocity = '0 0 180'; this.traileffect = EFFECT_Null.m_id; break;
324  HANDLE(RAPTORCANNON) this.traileffect = EFFECT_TR_CRYLINKPLASMA.m_id; break;
325 
326  HANDLE(SPIDERROCKET) this.traileffect = EFFECT_SPIDERBOT_ROCKET_TRAIL.m_id; break;
327  HANDLE(WAKIROCKET) this.traileffect = EFFECT_RACER_ROCKET_TRAIL.m_id; break;
328  HANDLE(WAKICANNON) this.traileffect = EFFECT_Null.m_id; break;
329 
330  HANDLE(BUMBLE_GUN) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
331  HANDLE(BUMBLE_BEAM) this.traileffect = EFFECT_TR_NEXUIZPLASMA.m_id; break;
332 
333  HANDLE(RPC) this.traileffect = EFFECT_TR_ROCKET.m_id; break;
334 
335  HANDLE(ROCKETMINSTA_LASER) this.traileffect = EFFECT_ROCKETMINSTA_LASER(this.team).m_id; break;
336 #undef HANDLE
337  default:
338  if (MUTATOR_CALLHOOK(Ent_Projectile, this))
339  break;
340 
341  error("Received invalid CSQC projectile, can't work with this!");
342  break;
343  }
344 
345  this.mins = '0 0 0';
346  this.maxs = '0 0 0';
347  this.colormod = '0 0 0';
348  settouch(this, SUB_Stop);
350  this.alphamod = 1;
351 
352  switch (this.cnt)
353  {
354  case PROJECTILE_ELECTRO:
355  // only new engines support sound moving with object
356  loopsound(this, CH_SHOTS_SINGLE, SND_ELECTRO_FLY, VOL_BASE, ATTEN_NORM);
357  this.mins = '-4 -4 -4';
358  this.maxs = '4 4 4';
360  settouch(this, func_null);
361  this.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
362  this.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
363  break;
364  case PROJECTILE_RPC:
365  case PROJECTILE_ROCKET:
366  loopsound(this, CH_SHOTS_SINGLE, SND_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
367  this.mins = '-3 -3 -3';
368  this.maxs = '3 3 3';
369  break;
370  case PROJECTILE_GRENADE:
371  this.mins = '-3 -3 -3';
372  this.maxs = '3 3 3';
373  break;
375  this.mins = '-3 -3 -3';
376  this.maxs = '3 3 3';
378  settouch(this, func_null);
379  this.bouncefactor = WEP_CVAR(mortar, bouncefactor);
380  this.bouncestop = WEP_CVAR(mortar, bouncestop);
381  break;
383  this.mins = '-8 -8 -8';
384  this.maxs = '8 8 8';
385  this.scale = 2.5;
386  this.avelocity = randomvec() * 720;
387  break;
388  case PROJECTILE_MINE:
389  this.mins = '-4 -4 -4';
390  this.maxs = '4 4 4';
391  break;
393  this.colormod = '2 1 1';
394  this.alphamod = 0.5;
396  settouch(this, func_null);
397  break;
399  this.colormod = '1 1 2';
400  this.alphamod = 0.5;
402  settouch(this, func_null);
403  break;
406  settouch(this, func_null);
407  break;
410  settouch(this, func_null);
411  break;
412  case PROJECTILE_FIREBALL:
413  loopsound(this, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
414  this.mins = '-16 -16 -16';
415  this.maxs = '16 16 16';
416  break;
417  case PROJECTILE_FIREMINE:
418  loopsound(this, CH_SHOTS_SINGLE, SND_FIREBALL_FLY, VOL_BASE, ATTEN_NORM);
420  settouch(this, func_null);
421  this.mins = '-4 -4 -4';
422  this.maxs = '4 4 4';
423  break;
424  case PROJECTILE_TAG:
425  this.mins = '-2 -2 -2';
426  this.maxs = '2 2 2';
427  break;
428  case PROJECTILE_FLAC:
429  this.mins = '-2 -2 -2';
430  this.maxs = '2 2 2';
431  break;
432  case PROJECTILE_SEEKER:
433  loopsound(this, CH_SHOTS_SINGLE, SND_TAG_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
434  this.mins = '-4 -4 -4';
435  this.maxs = '4 4 4';
436  break;
437  case PROJECTILE_ARC_BOLT:
439  settouch(this, func_null);
440  break;
442  this.mins = '-3 -3 -3';
443  this.maxs = '3 3 3';
444  break;
446  break;
448  break;
450  loopsound(this, CH_SHOTS_SINGLE, SND_TAG_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
451  break;
453  loopsound(this, CH_SHOTS_SINGLE, SND_TAG_ROCKET_FLY, VOL_BASE, ATTEN_NORM);
454  break;
455  /*
456  case PROJECTILE_WAKICANNON:
457  break;
458  case PROJECTILE_BUMBLE_GUN:
459  // only new engines support sound moving with object
460  loopsound(this, CH_SHOTS_SINGLE, SND_ELECTRO_FLY, VOL_BASE, ATTEN_NORM);
461  this.mins = '0 0 -4';
462  this.maxs = '0 0 -4';
463  this.move_movetype = MOVETYPE_BOUNCE;
464  settouch(this, func_null);
465  this.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
466  this.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
467  break;
468  */
469  default:
470  break;
471  }
472 
473  MUTATOR_CALLHOOK(EditProjectile, this);
474 
475  setsize(this, this.mins, this.maxs);
476  }
477 
478  return = true;
479 
480  if (this.gravity)
481  {
482  if (this.move_movetype == MOVETYPE_FLY)
486  }
487  else
488  {
489  if (this.move_movetype == MOVETYPE_TOSS)
490  set_movetype(this, MOVETYPE_FLY);
491  if (this.move_movetype == MOVETYPE_BOUNCE)
493  }
494 
495  if (!(this.count & 0x80))
497 
498  this.draw = Projectile_Draw;
499  if (isnew) IL_PUSH(g_drawables, this);
500  this.entremove = Ent_RemoveProjectile;
501 }
const int PROJECTILE_TAG
Definition: projectiles.qh:5
const int PROJECTILE_PORTO_RED
Definition: projectiles.qh:15
const int PROJECTILE_GRENADE
Definition: projectiles.qh:8
void InterpolateOrigin_Note(entity this)
Definition: interpolate.qc:37
#define WEP_CVAR_SEC(wepname, name)
Definition: all.qh:301
#define HANDLE(id)
float colormap
Definition: csprogsdefs.qc:131
int iflags
Definition: interpolate.qh:26
void InterpolateOrigin_Undo(entity this)
snap origin to iorigin2 (actual origin)
Definition: interpolate.qc:159
const int PROJECTILE_SPIDERROCKET
Definition: projectiles.qh:27
float modelindex
Definition: csprogsdefs.qc:91
int team
Definition: main.qh:157
const int IFLAG_INTERNALMASK
Definition: interpolate.qh:37
float MOVETYPE_TOSS
Definition: progsdefs.qc:252
const int PROJECTILE_RAPTORBOMBLET
Definition: projectiles.qh:26
fade_rate
Definition: projectile.qh:14
Definition: hlac.qh:3
const int PROJECTILE_MINE
Definition: projectiles.qh:10
float MOVETYPE_BOUNCEMISSILE
Definition: progsdefs.qc:257
vector maxs
Definition: csprogsdefs.qc:113
const int IFLAG_AUTOANGLES
Definition: interpolate.qh:29
#define WEP_CVAR(wepname, name)
Definition: all.qh:299
void loopsound(entity e, int ch, Sound samp, float vol, float attn)
Definition: projectile.qc:167
float bouncestop
origin
Definition: ent_cs.qc:114
vector avelocity
Definition: csprogsdefs.qc:105
float MOVETYPE_BOUNCE
Definition: progsdefs.qc:256
entity EFFECT_ROCKETMINSTA_LASER(int teamid)
Definition: all.inc:274
void Projectile_Draw(entity this)
Definition: projectile.qc:49
#define UNSET_ONGROUND(s)
Definition: movetypes.qh:18
const int PROJECTILE_CRYLINK_BOUNCING
Definition: projectiles.qh:20
float move_movetype
Definition: movetypes.qh:76
const int PROJECTILE_HAGAR_BOUNCING
Definition: projectiles.qh:19
const int PROJECTILE_PORTO_BLUE
Definition: projectiles.qh:16
const int PROJECTILE_FIREBALL
Definition: projectiles.qh:21
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
float bouncefactor
vector mins
Definition: csprogsdefs.qc:113
float cnt
Definition: powerups.qc:24
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
const int PROJECTILE_SHAMBLER_LIGHTNING
Definition: projectiles.qh:35
const int PROJECTILE_ARC_BOLT
Definition: projectiles.qh:39
const int PROJECTILE_ROCKET
Definition: projectiles.qh:4
vector colormod
Definition: projectile.qc:15
float move_nomonsters
Definition: movetypes.qh:88
const float VOL_BASE
Definition: sound.qh:36
const int PROJECTILE_WAKIROCKET
Definition: projectiles.qh:28
float teamplay
Definition: progsdefs.qc:31
const float ATTEN_NORM
Definition: sound.qh:30
const int PROJECTILE_FIREMINE
Definition: projectiles.qh:22
void SUB_Stop(entity this, entity toucher)
Definition: projectile.qc:17
float scale
Definition: projectile.qc:14
float gravity
Definition: items.qh:16
const int IFLAG_ORIGIN
Definition: interpolate.qh:36
const int PROJECTILE_RAPTORBOMB
Definition: projectiles.qh:25
const int PROJECTILE_ELECTRO
Definition: projectiles.qh:3
float flags
Definition: csprogsdefs.qc:129
const int PROJECTILE_SEEKER
Definition: projectiles.qh:13
float move_time
Definition: movetypes.qh:77
#define SET_ONGROUND(s)
Definition: movetypes.qh:17
float count
Definition: powerups.qc:22
const int PROJECTILE_FLAC
Definition: projectiles.qh:14
float fade_time
Definition: common.qh:22
const float SOLID_TRIGGER
Definition: csprogsdefs.qc:245
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
void InterpolateOrigin_Reset(entity this)
Definition: interpolate.qc:32
setorigin(ent, v)
const int PROJECTILE_GRENADE_BOUNCING
Definition: projectiles.qh:9
const int PROJECTILE_RPC
Definition: projectiles.qh:43
const int PROJECTILE_RAPTORCANNON
Definition: projectiles.qh:24
const int CH_SHOTS_SINGLE
Definition: sound.qh:15
vector glowmod
float MOVE_WORLDONLY
void Ent_RemoveProjectile(entity this)
Definition: projectile.qc:177
float spawntime
Definition: items.qh:15
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
IntrusiveList g_drawables
Definition: main.qh:77
const int IFLAG_ANGLES
Definition: interpolate.qh:28
void set_movetype(entity this, int mt)
float MOVETYPE_FLY
Definition: progsdefs.qc:251
#define colormapPaletteColor(c, isPants)
Definition: color.qh:5
var void func_null()
float ticrate
Definition: main.qh:182
float solid
Definition: csprogsdefs.qc:99
+ Here is the call graph for this function:

◆ PRECACHE()

PRECACHE ( Projectiles  )

Definition at line 503 of file projectile.qc.

References MUTATOR_CALLHOOK.

504 {
505  MUTATOR_CALLHOOK(PrecacheProjectiles);
506 }
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140

◆ Projectile_Draw()

void Projectile_Draw ( entity  this)

Definition at line 49 of file projectile.qc.

References alpha, angles, AnglesTransform_FromAngles(), AnglesTransform_Multiply(), AnglesTransform_ToAngles(), autocvar_cl_projectiles_sloppy, avelocity, bound(), cnt, count, drawmask, 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_ResetTrail(), PROJECTILE_ROCKET, renderflags, spawntime, time, v_forward, v_right, v_up, vectoangles(), vector(), and velocity.

Referenced by NET_HANDLE().

50 {
51  vector rot;
52  vector trailorigin;
53  int f;
54  bool drawn;
55  float t;
56  float a;
57 
58  f = this.flags;
59 
60  if (this.count & 0x80)
61  {
62  // UNSET_ONGROUND(this);
65  // the trivial movetypes do not have to match the
66  // server's ticrate as they are ticrate independent
67  // NOTE: this assumption is only true if MOVETYPE_FLY
68  // projectiles detonate on impact. If they continue
69  // moving, we might still be ticrate dependent.
70  else
72  if (!IS_ONGROUND(this))
73  if (this.velocity != '0 0 0')
74  this.angles = vectoangles(this.velocity);
75  }
76  else
77  {
79  }
80 
81  if (this.count & 0x80)
82  {
83  drawn = (time >= this.spawntime - 0.02);
84  t = max(time, this.spawntime);
85  }
86  else
87  {
88  drawn = (this.iflags & IFLAG_VALID);
89  t = time;
90  }
91  bool is_nade = Projectile_isnade(this.cnt);
92 
93  if (!(f & FL_ONGROUND))
94  {
95  rot = '0 0 0';
96  if (is_nade) rot = this.avelocity;
97  else switch (this.cnt)
98  {
100  rot = '0 -1000 0'; // sideways
101  break;
102  case PROJECTILE_HOOKBOMB:
103  rot = '1000 0 0'; // forward
104  break;
105  case PROJECTILE_ROCKET:
106  rot = '0 0 720'; // spinning
107  break;
108  }
109 
110  if (rot)
111  {
112  if (!rot.x && !rot.y)
113  {
114  // cheaper z-only rotation formula
115  this.angles.z = (rot.z * (t - this.spawntime)) % 360;
116  if (this.angles.z < 0)
117  this.angles.z += 360;
118  }
119  else
121  }
122  }
123 
124  a = 1 - (time - this.fade_time) * this.fade_rate;
125  this.alpha = bound(0, this.alphamod * a, 1);
126  if (this.alpha <= 0)
127  drawn = 0;
128  this.renderflags = 0;
129 
130  vector ang = this.angles;
131  ang.x = -ang.x;
132  trailorigin = this.origin;
133  if (is_nade)
134  {
135  makevectors(ang);
136  trailorigin += v_up * 4;
137  }
138  else switch (this.cnt)
139  {
140  case PROJECTILE_GRENADE:
142  makevectors(ang);
143  trailorigin += v_right * 1 + v_forward * -10;
144  break;
145  }
146 
147  if (drawn)
148  Projectile_DrawTrail(this, trailorigin);
149  else
150  Projectile_ResetTrail(this, trailorigin);
151 
152  this.drawmask = 0;
153 
154  if (!drawn)
155  return;
156 
157  switch (this.cnt)
158  {
159  // Possibly add dlights here.
160  default:
161  break;
162  }
163 
164  this.drawmask = MASK_NORMAL;
165 }
const int PROJECTILE_GRENADE
Definition: projectiles.qh:8
float MOVETYPE_NONE
Definition: progsdefs.qc:246
vector AnglesTransform_ToAngles(vector v)
int iflags
Definition: interpolate.qh:26
vector AnglesTransform_FromAngles(vector v)
bool autocvar_cl_projectiles_sloppy
Definition: projectile.qh:5
float FL_ONGROUND
Definition: progsdefs.qc:240
const int IFLAG_VALID
Definition: interpolate.qh:30
float alpha
Definition: projectile.qc:13
fade_rate
Definition: projectile.qh:14
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
origin
Definition: ent_cs.qc:114
void Movetype_Physics_NoMatchServer(entity this)
Definition: movetypes.qc:839
vector avelocity
Definition: csprogsdefs.qc:105
float move_movetype
Definition: movetypes.qh:76
float renderflags
Definition: main.qh:95
void Projectile_DrawTrail(entity this, vector to)
Definition: projectile.qc:29
void Projectile_ResetTrail(entity this, vector to)
Definition: projectile.qc:23
float cnt
Definition: powerups.qc:24
void Movetype_Physics_MatchServer(entity this, bool sloppy)
Definition: movetypes.qc:851
vector v_up
Definition: csprogsdefs.qc:31
const int PROJECTILE_ROCKET
Definition: projectiles.qh:4
vector AnglesTransform_Multiply(vector t1, vector t2)
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float flags
Definition: csprogsdefs.qc:129
float count
Definition: powerups.qc:22
float fade_time
Definition: common.qh:22
vector v_right
Definition: csprogsdefs.qc:31
const int PROJECTILE_GRENADE_BOUNCING
Definition: projectiles.qh:9
vector angles
Definition: csprogsdefs.qc:104
float spawntime
Definition: items.qh:15
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
#define makevectors
Definition: post.qh:21
void InterpolateOrigin_Do(entity this)
set origin based on iorigin1 (old pos), iorigin2 (desired pos), and time
Definition: interpolate.qc:129
float MOVETYPE_FLY
Definition: progsdefs.qc:251
const int PROJECTILE_HOOKBOMB
Definition: projectiles.qh:17
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Projectile_DrawTrail()

void Projectile_DrawTrail ( entity  this,
vector  to 
)

Definition at line 29 of file projectile.qc.

References alpha, cnt, entity(), particleeffectnum, particles_alphamax, particles_alphamin, PARTICLES_DRAWASTRAIL, particles_fade, PARTICLES_USEALPHA, PARTICLES_USEFADE, PROJECTILE_FIREMINE, REGISTRY_GET, sqrt(), time, to, vector(), and velocity.

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

30 {
31  vector from = this.trail_oldorigin;
32  // float t0 = this.trail_oldtime;
33  this.trail_oldorigin = to;
34  this.trail_oldtime = time;
35 
36  // force the effect even for stationary firemine
37  if (this.cnt == PROJECTILE_FIREMINE)
38  if (from == to)
39  from.z += 1;
40 
41  if (this.traileffect)
42  {
44  entity eff = REGISTRY_GET(Effects, this.traileffect);
45  boxparticles(particleeffectnum(eff), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
46  }
47 }
float alpha
Definition: projectile.qc:13
entity() spawn
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
entity to
Definition: self.qh:96
float particles_fade
float PARTICLES_USEALPHA
float PARTICLES_USEFADE
float particles_alphamin
float cnt
Definition: powerups.qc:24
const int PROJECTILE_FIREMINE
Definition: projectiles.qh:22
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float PARTICLES_DRAWASTRAIL
float particles_alphamax
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
#define particleeffectnum(e)
Definition: effect.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Projectile_ResetTrail()

void Projectile_ResetTrail ( entity  this,
vector  to 
)

Definition at line 23 of file projectile.qc.

References time, and to.

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

24 {
25  this.trail_oldorigin = to;
26  this.trail_oldtime = time;
27 }
entity to
Definition: self.qh:96
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ SUB_Stop()

void SUB_Stop ( entity  this,
entity  toucher 
)

Definition at line 17 of file projectile.qc.

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

Referenced by NET_HANDLE().

18 {
19  this.velocity = this.avelocity = '0 0 0';
21 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
vector avelocity
Definition: csprogsdefs.qc:105
vector velocity
Definition: csprogsdefs.qc:103
void set_movetype(entity this, int mt)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ alpha

float alpha

Definition at line 13 of file projectile.qc.

Referenced by Projectile_Draw(), and Projectile_DrawTrail().

◆ colormod

vector colormod

Definition at line 15 of file projectile.qc.

Referenced by NET_HANDLE().

◆ scale