2 float generator_precached;
5 vector randompos(vector m1, vector m2)
9 v_x = m2_x * random() + m1_x;
10 v_y = m2_y * random() + m1_y;
11 v_z = m2_z * random() + m1_z;
15 void generator_precache()
17 if(generator_precached)
18 return; // already precached
20 precache_model("models/onslaught/generator.md3");
21 precache_model("models/onslaught/generator_dead.md3");
22 precache_model("models/onslaught/generator_dmg1.md3");
23 precache_model("models/onslaught/generator_dmg2.md3");
24 precache_model("models/onslaught/generator_dmg3.md3");
25 precache_model("models/onslaught/generator_dmg4.md3");
26 precache_model("models/onslaught/generator_dmg5.md3");
27 precache_model("models/onslaught/generator_dmg6.md3");
28 precache_model("models/onslaught/generator_dmg7.md3");
29 precache_model("models/onslaught/generator_dmg8.md3");
30 precache_model("models/onslaught/generator_dmg9.md3");
31 precache_model("models/onslaught/generator_dead.md3");
33 precache_model("models/onslaught/ons_ray.md3");
34 precache_sound("onslaught/shockwave.wav");
35 precache_sound("weapons/grenade_impact.wav");
36 precache_sound("weapons/rocket_impact.wav");
38 precache_model("models/onslaught/gen_gib1.md3");
39 precache_model("models/onslaught/gen_gib2.md3");
40 precache_model("models/onslaught/gen_gib3.md3");
42 generator_precached = TRUE;
45 void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
47 self.velocity = self.velocity + vforce;
52 void gib_draw_noburn()
54 if(time >= self.giblifetime)
60 if(time >= self.move_time)
63 self.move_time = time + 0.05;
65 if(time > self.giblifetime)
80 pointparticles(particleeffectnum("onslaught_generator_gib_flame"), self.origin, '0 0 0', 1);
83 void ons_throwgib(vector v_from, vector v_to, string smodel, float f_lifetime, float b_burn)
89 setmodel(gib, smodel);
90 setorigin(gib, v_from);
91 gib.solid = SOLID_CORPSE;
92 gib.move_movetype = MOVETYPE_BOUNCE;
93 gib.movetype = MOVETYPE_BOUNCE;
95 gib.move_velocity = v_to;
96 gib.move_origin = v_from;
100 gib.drawmask = MASK_NORMAL;
101 gib.giblifetime = time + f_lifetime;
106 gib.draw = gib_draw_noburn;
109 void onslaught_generator_ray_think()
111 self.nextthink = time + 0.05;
114 self.think = SUB_Remove;
127 void onslaught_generator_ray_spawn(vector org)
131 setmodel(e, "models/onslaught/ons_ray.md3");
133 e.angles = randomvec() * 360;
135 e.scale = random() * 5 + 8;
136 e.think = onslaught_generator_ray_think;
137 e.nextthink = time + 0.05;
140 void generator_draw()
145 if(time < self.move_time)
154 if(self.count==40||self.count==20)
156 sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTN_NORM);
157 pointparticles(particleeffectnum("electro_combo"), self.origin, '0 0 0', 6);
165 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 6, TRUE);
167 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 6, TRUE);
169 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 6, TRUE);
175 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
176 pointparticles(particleeffectnum("onslaught_generator_gib_explode"), org, '0 0 0', 1);
179 // Short explosion sound + small explosion
182 te_explosion(self.origin);
183 sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
187 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
188 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
193 onslaught_generator_ray_spawn(self.origin);
201 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
202 sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
205 self.move_time = time + 0.05;
211 void generator_damage(float hp)
214 setmodel(self, "models/onslaught/generator_dead.md3");
215 else if(hp < self.max_health * 0.10)
216 setmodel(self, "models/onslaught/generator_dmg9.md3");
217 else if(hp < self.max_health * 0.20)
218 setmodel(self, "models/onslaught/generator_dmg8.md3");
219 else if(hp < self.max_health * 0.30)
220 setmodel(self, "models/onslaught/generator_dmg7.md3");
221 else if(hp < self.max_health * 0.40)
222 setmodel(self, "models/onslaught/generator_dmg6.md3");
223 else if(hp < self.max_health * 0.50)
224 setmodel(self, "models/onslaught/generator_dmg5.md3");
225 else if(hp < self.max_health * 0.60)
226 setmodel(self, "models/onslaught/generator_dmg4.md3");
227 else if(hp < self.max_health * 0.70)
228 setmodel(self, "models/onslaught/generator_dmg3.md3");
229 else if(hp < self.max_health * 0.80)
230 setmodel(self, "models/onslaught/generator_dmg2.md3");
231 else if(hp < self.max_health * 0.90)
232 setmodel(self, "models/onslaught/generator_dmg1.md3");
233 else if(hp <= self.max_health || hp >= self.max_health)
234 setmodel(self, "models/onslaught/generator.md3");
236 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
239 void generator_construct()
241 self.netname = "Generator";
243 setorigin(self, self.origin);
244 setmodel(self, "models/onslaught/generator.md3");
245 setsize(self, GENERATOR_MIN, GENERATOR_MAX);
247 self.move_movetype = MOVETYPE_NOCLIP;
248 self.solid = SOLID_BBOX;
249 self.movetype = MOVETYPE_NOCLIP;
250 self.move_origin = self.origin;
251 self.move_time = time;
252 self.drawmask = MASK_NORMAL;
254 self.draw = generator_draw;
258 void generator_changeteam()
262 self.glowmod = Team_ColorRGB(self.team - 1);
263 self.teamradar_color = Team_ColorRGB(self.team - 1);
264 self.colormap = 1024 + (self.team - 1) * 17;
268 self.colormap = 1024;
269 self.glowmod = '1 1 0';
270 self.teamradar_color = '1 1 0';
281 self.origin_x = ReadCoord();
282 self.origin_y = ReadCoord();
283 self.origin_z = ReadCoord();
284 setorigin(self, self.origin);
286 self.health = ReadByte();
287 self.max_health = ReadByte();
288 self.count = ReadByte();
289 self.team = ReadByte();
294 generator_changeteam();
295 generator_precache();
296 generator_construct();
303 if(_tmp != self.team)
306 generator_changeteam();
311 if(_tmp != self.health)
312 generator_damage(_tmp);
320 float generator_send(entity to, float sf)
322 WriteByte(MSG_ENTITY, ENT_CLIENT_GENERATOR);
323 WriteByte(MSG_ENTITY, sf);
326 WriteCoord(MSG_ENTITY, self.origin_x);
327 WriteCoord(MSG_ENTITY, self.origin_y);
328 WriteCoord(MSG_ENTITY, self.origin_z);
330 WriteByte(MSG_ENTITY, self.health);
331 WriteByte(MSG_ENTITY, self.max_health);
332 WriteByte(MSG_ENTITY, self.count);
333 WriteByte(MSG_ENTITY, self.team);
338 WriteByte(MSG_ENTITY, self.team);
341 WriteByte(MSG_ENTITY, 0);
343 WriteByte(MSG_ENTITY, ceil((self.health / self.max_health) * 255));
349 void generator_link(void() spawnproc)
351 Net_LinkEntity(self, TRUE, 0, generator_send);
352 self.think = spawnproc;
353 self.nextthink = time;