Xonotic
projectile.qh File Reference
+ Include dependency graph for projectile.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 classfield (Projectile).int traileffect
 
void Ent_RemoveProjectile (entity this)
 
 entityclass (Projectile)
 
void loopsound (entity e, int ch, Sound samp, float vol, float attn)
 
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

bool autocvar_cl_projectiles_sloppy
 
 fade_rate
 
 iorigin2
 

Function Documentation

◆ classfield()

classfield ( Projectile  )

◆ 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:

◆ entityclass()

entityclass ( Projectile  )

◆ 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:

◆ 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

◆ autocvar_cl_projectiles_sloppy

bool autocvar_cl_projectiles_sloppy

Definition at line 5 of file projectile.qh.

Referenced by Projectile_Draw(), and train_next().

◆ fade_rate

◆ iorigin2

iorigin2

Definition at line 10 of file projectile.qh.