1 #include "cl_generator.qh"
8 void ons_generator_ray_draw(entity this)
10 if(time < this.move_time)
13 this.move_time = time + 0.05;
17 IL_REMOVE(g_drawables, this);
31 void ons_generator_ray_spawn(vector org)
33 entity e = new(ons_ray);
34 setmodel(e, MDL_ONS_RAY);
36 e.angles = randomvec() * 360;
37 set_movetype(e, MOVETYPE_NONE);
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);
46 void generator_draw(entity this)
48 if(time < this.move_time)
53 // damaged fx (less probable the more damaged is the generator)
54 if(random() < 0.9 - this.health / this.max_health)
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);
61 pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
63 this.move_time = time + 0.1;
75 if(this.count==40||this.count==20)
77 sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
78 pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
84 ons_generator_ray_spawn(this.origin);
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);
94 // Short explosion sound + small explosion
97 te_explosion(this.origin);
98 sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
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);
110 pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
111 sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
114 this.move_time = time + 0.05;
119 void generator_damage(entity this, float hp)
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);
144 setsize(this, GENERATOR_MIN, GENERATOR_MAX);
147 void generator_construct(entity this, bool isnew)
149 this.netname = "Generator";
150 this.classname = "onslaught_generator";
154 IL_PUSH(g_onsgenerators, this);
155 IL_PUSH(g_drawables, this);
158 setorigin(this, this.origin);
159 setmodel(this, MDL_ONS_GEN);
160 setsize(this, GENERATOR_MIN, GENERATOR_MAX);
162 set_movetype(this, MOVETYPE_NOCLIP);
163 this.solid = SOLID_BBOX;
164 set_movetype(this, MOVETYPE_NOCLIP);
165 this.move_time = time;
166 this.drawmask = MASK_NORMAL;
168 this.draw = generator_draw;
172 void generator_changeteam(entity this)
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;
182 this.colormap = 1024;
183 this.glowmod = '1 1 0';
184 this.teamradar_color = '1 1 0';
188 NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
195 this.origin_x = ReadCoord();
196 this.origin_y = ReadCoord();
197 this.origin_z = ReadCoord();
198 setorigin(this, this.origin);
200 this.health = ReadByte();
201 this.max_health = ReadByte();
202 this.count = ReadByte();
203 this.team = ReadByte();
208 generator_changeteam(this);
209 generator_construct(this, isnew);
216 if(_tmp != this.team)
219 generator_changeteam(this);
224 if(_tmp != this.health)
225 generator_damage(this, _tmp);