Xonotic
cl_generator.qc File Reference
#include "cl_generator.qh"
+ Include dependency graph for cl_generator.qc:

Go to the source code of this file.

Functions

void generator_changeteam (entity this)
 
void generator_construct (entity this, bool isnew)
 
void generator_damage (entity this, float hp)
 
void generator_draw (entity this)
 
 NET_HANDLE (ENT_CLIENT_GENERATOR, bool isnew)
 
void ons_generator_ray_draw (entity this)
 
void ons_generator_ray_spawn (vector org)
 

Variables

float alpha
 
int count
 
vector glowmod
 
float max_health
 
float scale
 

Function Documentation

◆ generator_changeteam()

void generator_changeteam ( entity  this)

Definition at line 172 of file cl_generator.qc.

References colormap, glowmod, team, and Team_ColorRGB().

Referenced by NET_HANDLE().

173 {
174  if(this.team)
175  {
176  this.glowmod = Team_ColorRGB(this.team - 1);
177  this.teamradar_color = Team_ColorRGB(this.team - 1);
178  this.colormap = 1024 + (this.team - 1) * 17;
179  }
180  else
181  {
182  this.colormap = 1024;
183  this.glowmod = '1 1 0';
184  this.teamradar_color = '1 1 0';
185  }
186 }
float colormap
Definition: csprogsdefs.qc:131
vector glowmod
int team
Definition: main.qh:157
vector Team_ColorRGB(int teamid)
Definition: teams.qh:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generator_construct()

void generator_construct ( entity  this,
bool  isnew 
)

Definition at line 147 of file cl_generator.qc.

References alpha, classname, drawmask, g_drawables, generator_draw(), GENERATOR_MAX, GENERATOR_MIN, IL_PUSH(), MASK_NORMAL, move_time, MOVETYPE_NOCLIP, netname, origin, set_movetype(), setmodel, setorigin(), solid, SOLID_BBOX, and time.

Referenced by NET_HANDLE().

148 {
149  this.netname = "Generator";
150  this.classname = "onslaught_generator";
151 
152  if(isnew)
153  {
154  IL_PUSH(g_onsgenerators, this);
155  IL_PUSH(g_drawables, this);
156  }
157 
158  setorigin(this, this.origin);
159  setmodel(this, MDL_ONS_GEN);
160  setsize(this, GENERATOR_MIN, GENERATOR_MAX);
161 
163  this.solid = SOLID_BBOX;
165  this.move_time = time;
166  this.drawmask = MASK_NORMAL;
167  this.alpha = 1;
168  this.draw = generator_draw;
169 }
string netname
Definition: powerups.qc:20
const vector GENERATOR_MIN
Definition: cl_generator.qh:3
origin
Definition: ent_cs.qc:114
string classname
Definition: csprogsdefs.qc:107
#define setmodel(this, m)
Definition: model.qh:26
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float alpha
Definition: cl_generator.qc:3
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
float MOVETYPE_NOCLIP
Definition: progsdefs.qc:254
float move_time
Definition: movetypes.qh:77
const vector GENERATOR_MAX
Definition: cl_generator.qh:4
const float SOLID_BBOX
Definition: csprogsdefs.qc:246
setorigin(ent, v)
float time
Definition: csprogsdefs.qc:16
IntrusiveList g_drawables
Definition: main.qh:77
void set_movetype(entity this, int mt)
float solid
Definition: csprogsdefs.qc:99
void generator_draw(entity this)
Definition: cl_generator.qc:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generator_damage()

void generator_damage ( entity  this,
float  hp 
)

Definition at line 119 of file cl_generator.qc.

References GENERATOR_MAX, GENERATOR_MIN, max_health, and setmodel.

Referenced by NET_HANDLE().

120 {
121  if(hp <= 0)
122  setmodel(this, MDL_ONS_GEN_DEAD);
123  else if(hp < this.max_health * 0.10)
124  setmodel(this, MDL_ONS_GEN9);
125  else if(hp < this.max_health * 0.20)
126  setmodel(this, MDL_ONS_GEN8);
127  else if(hp < this.max_health * 0.30)
128  setmodel(this, MDL_ONS_GEN7);
129  else if(hp < this.max_health * 0.40)
130  setmodel(this, MDL_ONS_GEN6);
131  else if(hp < this.max_health * 0.50)
132  setmodel(this, MDL_ONS_GEN5);
133  else if(hp < this.max_health * 0.60)
134  setmodel(this, MDL_ONS_GEN4);
135  else if(hp < this.max_health * 0.70)
136  setmodel(this, MDL_ONS_GEN3);
137  else if(hp < this.max_health * 0.80)
138  setmodel(this, MDL_ONS_GEN2);
139  else if(hp < this.max_health * 0.90)
140  setmodel(this, MDL_ONS_GEN1);
141  else if(hp <= this.max_health || hp >= this.max_health)
142  setmodel(this, MDL_ONS_GEN);
143 
144  setsize(this, GENERATOR_MIN, GENERATOR_MAX);
145 }
const vector GENERATOR_MIN
Definition: cl_generator.qh:3
#define setmodel(this, m)
Definition: model.qh:26
const vector GENERATOR_MAX
Definition: cl_generator.qh:4
float max_health
Definition: cl_generator.qc:6
+ Here is the caller graph for this function:

◆ generator_draw()

void generator_draw ( entity  this)

Definition at line 46 of file cl_generator.qc.

References ATTEN_NORM, CH_TRIGGER, count, GetResource(), max_health, maxs, mins, move_time, ons_generator_ray_spawn(), origin, pointparticles, random(), randompos(), RES_HEALTH, sound, time, vector(), and VOL_BASE.

Referenced by generator_construct().

47 {
48  if(time < this.move_time)
49  return;
50 
51  if(GetResource(this, RES_HEALTH) > 0)
52  {
53  // damaged fx (less probable the more damaged is the generator)
54  if(random() < 0.9 - GetResource(this, RES_HEALTH) / this.max_health)
55  if(random() < 0.01)
56  {
57  pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
58  sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
59  }
60  else
61  pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
62 
63  this.move_time = time + 0.1;
64 
65  return;
66  }
67 
68  if(this.count <= 0)
69  return;
70 
71  vector org;
72  int i;
73 
74  // White shockwave
75  if(this.count==40||this.count==20)
76  {
77  sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
78  pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
79  }
80 
81  // rays
82  if(random() > 0.25)
83  {
85  }
86 
87  // Spawn fire balls
88  for(i=0;i < 10;++i)
89  {
90  org = this.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
91  pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
92  }
93 
94  // Short explosion sound + small explosion
95  if(random() < 0.25)
96  {
97  te_explosion(this.origin);
98  sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
99  }
100 
101  // Particles
102  org = this.origin + randompos(this.mins + '8 8 8', this.maxs + '-8 -8 -8');
103  pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
104 
105  // Final explosion
106  if(this.count==1)
107  {
108  org = this.origin;
109  te_explosion(org);
110  pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
111  sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
112  }
113 
114  this.move_time = time + 0.05;
115 
116  this.count -= 1;
117 }
vector maxs
Definition: csprogsdefs.qc:113
origin
Definition: ent_cs.qc:114
RES_HEALTH
Definition: ent_cs.qc:126
ERASEABLE vector randompos(vector m1, vector m2)
Definition: vector.qh:49
vector mins
Definition: csprogsdefs.qc:113
const int CH_TRIGGER
Definition: sound.qh:12
#define pointparticles
Definition: csprogsdefs.qh:13
const float VOL_BASE
Definition: sound.qh:36
const float ATTEN_NORM
Definition: sound.qh:30
void ons_generator_ray_spawn(vector org)
Definition: cl_generator.qc:31
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float move_time
Definition: movetypes.qh:77
int count
Definition: cl_generator.qc:5
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
float max_health
Definition: cl_generator.qc:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_GENERATOR  ,
bool  isnew 
)

Definition at line 188 of file cl_generator.qc.

References count, generator_changeteam(), generator_construct(), generator_damage(), GetResource(), GSF_SETUP, GSF_STATUS, max_health, origin, RES_HEALTH, setorigin(), SetResourceExplicit(), and team.

189 {
190  return = true;
191  int sf = ReadByte();
192 
193  if(sf & GSF_SETUP)
194  {
195  this.origin = ReadVector();
196  setorigin(this, this.origin);
197 
198  SetResourceExplicit(this, RES_HEALTH, ReadByte());
199  this.max_health = ReadByte();
200  this.count = ReadByte();
201  this.team = ReadByte();
202 
203  if(!this.count)
204  this.count = 40;
205 
206  generator_changeteam(this);
207  generator_construct(this, isnew);
208  }
209 
210  if(sf & GSF_STATUS)
211  {
212  int _tmp;
213  _tmp = ReadByte();
214  if(_tmp != this.team)
215  {
216  this.team = _tmp;
217  generator_changeteam(this);
218  }
219 
220  _tmp = ReadByte();
221 
222  if(_tmp != GetResource(this, RES_HEALTH))
223  generator_damage(this, _tmp);
224 
225  SetResourceExplicit(this, RES_HEALTH, _tmp);
226  }
227 }
void generator_changeteam(entity this)
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
int team
Definition: main.qh:157
void generator_construct(entity this, bool isnew)
origin
Definition: ent_cs.qc:114
RES_HEALTH
Definition: ent_cs.qc:126
const int GSF_SETUP
Definition: cl_generator.qh:7
void generator_damage(entity this, float hp)
const int GSF_STATUS
Definition: cl_generator.qh:6
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
setorigin(ent, v)
int count
Definition: cl_generator.qc:5
float max_health
Definition: cl_generator.qc:6
+ Here is the call graph for this function:

◆ ons_generator_ray_draw()

void ons_generator_ray_draw ( entity  this)

Definition at line 8 of file cl_generator.qc.

References alpha, count, g_drawables, IL_REMOVE(), move_time, scale, and time.

Referenced by ons_generator_ray_spawn().

9 {
10  if(time < this.move_time)
11  return;
12 
13  this.move_time = time + 0.05;
14 
15  if(this.count > 10)
16  {
17  IL_REMOVE(g_drawables, this);
18  delete(this);
19  return;
20  }
21 
22  if(this.count > 5)
23  this.alpha -= 0.1;
24  else
25  this.alpha += 0.1;
26 
27  this.scale += 0.2;
28  this.count +=1;
29 }
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
float scale
Definition: cl_generator.qc:4
float alpha
Definition: cl_generator.qc:3
float move_time
Definition: movetypes.qh:77
int count
Definition: cl_generator.qc:5
float time
Definition: csprogsdefs.qc:16
IntrusiveList g_drawables
Definition: main.qh:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ons_generator_ray_spawn()

void ons_generator_ray_spawn ( vector  org)

Definition at line 31 of file cl_generator.qc.

References entity(), g_drawables, IL_PUSH(), MASK_NORMAL, MOVETYPE_NONE, ons_generator_ray_draw(), random(), randomvec(), set_movetype(), setmodel, setorigin(), and time.

Referenced by generator_draw().

32 {
33  entity e = new(ons_ray);
34  setmodel(e, MDL_ONS_RAY);
35  setorigin(e, org);
36  e.angles = randomvec() * 360;
38  e.alpha = 0;
39  e.scale = random() * 5 + 8;
40  e.move_time = time + 0.05;
41  e.drawmask = MASK_NORMAL;
42  e.draw = ons_generator_ray_draw;
43  IL_PUSH(g_drawables, e);
44 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
entity() spawn
#define setmodel(this, m)
Definition: model.qh:26
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
void ons_generator_ray_draw(entity this)
Definition: cl_generator.qc:8
setorigin(ent, v)
float time
Definition: csprogsdefs.qc:16
IntrusiveList g_drawables
Definition: main.qh:77
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 3 of file cl_generator.qc.

Referenced by generator_construct(), and ons_generator_ray_draw().

◆ count

int count

Definition at line 5 of file cl_generator.qc.

Referenced by generator_draw(), NET_HANDLE(), and ons_generator_ray_draw().

◆ glowmod

vector glowmod

Definition at line 171 of file cl_generator.qc.

Referenced by generator_changeteam().

◆ max_health

float max_health

Definition at line 6 of file cl_generator.qc.

Referenced by generator_damage(), generator_draw(), and NET_HANDLE().

◆ scale

float scale

Definition at line 4 of file cl_generator.qc.

Referenced by ons_generator_ray_draw().