6 void() onslaught_updatelinks =
9 local float stop, t1, t2, t3, t4;
10 // first check if the game has ended
11 t1 = t2 = t3 = t4 = 0;
12 l = findchain(classname, "onslaught_generator");
17 if (l.team == COLOR_TEAM1) t1 = 1;
18 if (l.team == COLOR_TEAM2) t2 = 1;
19 if (l.team == COLOR_TEAM3) t3 = 1;
20 if (l.team == COLOR_TEAM4) t4 = 1;
24 if (t1 + t2 + t3 + t4 < 2)
26 // game over, only one team remains (or none)
29 // mark generators as being shielded and networked
30 l = findchain(classname, "onslaught_generator");
33 l.islinked = l.iscaptured;
34 l.isshielded = l.iscaptured;
37 // mark points as shielded and not networked
38 l = findchain(classname, "onslaught_controlpoint");
45 // flow power outward from the generators through the network
46 links = findchain(classname, "onslaught_link");
54 // if both points are captured by the same team, and only one of
55 // them is powered, mark the other one as powered as well
56 if (l.enemy.team == l.goalentity.team)
58 if (l.goalentity.islinked)
60 if (l.enemy.iscaptured)
61 if (!l.enemy.islinked)
64 l.enemy.islinked = TRUE;
69 if (l.goalentity.iscaptured)
70 if (!l.goalentity.islinked)
73 l.goalentity.islinked = TRUE;
80 // now that we know which points are powered we can mark their neighbors
81 // as unshielded if team differs
85 if (l.goalentity.team != l.enemy.team)
87 if (l.goalentity.islinked)
88 l.enemy.isshielded = FALSE;
90 l.goalentity.isshielded = FALSE;
94 // now update the takedamage and alpha variables on generator shields
95 l = findchain(classname, "onslaught_generator");
101 l.takedamage = DAMAGE_AIM;
106 l.takedamage = DAMAGE_AIM;
110 // now update the takedamage and alpha variables on control point icons
111 l = findchain(classname, "onslaught_controlpoint");
118 l.goalentity.takedamage = DAMAGE_AIM;
124 l.goalentity.takedamage = DAMAGE_AIM;
130 void() onslaught_generator_think =
132 self.nextthink = ceil(time + 1);
133 if (cvar("timelimit"))
134 if (time > cvar("timelimit") * 60 - 60)
136 // self.max_health / 120 gives 2 minutes of overtime
137 sound(self, CHAN_AUTO, "sound/onslaught/generator_decay.wav", 1, ATTN_NORM);
138 Damage(self, self, self, self.max_health / 60, DEATH_HURTTRIGGER, self.origin, '0 0 0');
142 void() onslaught_generator_deaththink =
147 self.nextthink = time + 0.1;
148 self.count = self.count - 1;
149 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
150 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
151 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
156 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
157 sound(self, CHAN_AUTO, "sound/weapons/rocket_impact.wav", 1, ATTN_NORM);
161 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_generator_damage =
165 if (attacker != self)
169 // this is protected by a shield, so ignore the damage
170 if (time > self.pain_finished)
171 if (attacker.classname == "player")
173 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
174 self.pain_finished = time + 1;
178 if (time > self.pain_finished)
180 self.pain_finished = time + 5;
181 bprint(ColoredTeamName(self.team), " generator under attack!\n");
182 play2team(self.team, "sound/onslaught/generator_underattack.wav");
185 self.health = self.health - damage;
186 // choose an animation frame based on health
187 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
188 // see if the generator is still functional, or dying
190 bprint(ColoredTeamName(self.team), " generator has ", ftos(floor(self.health)), " health remaining\n");
193 if (attacker == self)
194 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
196 bprint(ColoredTeamName(self.team), " generator destroyed by ", ColoredTeamName(attacker.team), "!\n");
197 self.iscaptured = FALSE;
198 self.islinked = FALSE;
199 self.isshielded = FALSE;
200 self.takedamage = DAMAGE_NO; // can't be hurt anymore
201 self.event_damage = SUB_Null; // won't do anything if hurt
202 self.count = 30; // 30 explosions
203 self.think = onslaught_generator_deaththink; // explosion sequence
204 self.nextthink = time; // start exploding immediately
205 self.think(); // do the first explosion now
206 onslaught_updatelinks();
210 // update links after a delay
211 void() onslaught_generator_delayed =
213 onslaught_updatelinks();
214 // now begin normal thinking
215 self.think = onslaught_generator_think;
216 self.nextthink = time;
219 /*QUAKED onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
222 onslaught_link entities can target this.
225 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
226 "targetname" - name that onslaught_link entities will use to target this.
228 void() onslaught_generator =
236 precache_model("models/onslaught/generator.md3");
237 precache_model("models/onslaught/generator_shield.md3");
238 precache_sound("sound/onslaught/generator_decay.wav");
239 precache_sound("sound/weapons/grenade_impact.wav");
240 precache_sound("sound/weapons/rocket_impact.wav");
241 precache_sound("sound/onslaught/generator_underattack.wav");
243 objerror("team must be set");
244 self.solid = SOLID_BSP;
245 self.movetype = MOVETYPE_NONE;
246 self.max_health = self.health = 1000;
247 setmodel(self, "models/onslaught/generator.md3");
248 //setsize(self, '-32 -32 -24', '32 32 64');
249 setorigin(self, self.origin);
250 self.takedamage = DAMAGE_AIM;
251 self.event_damage = onslaught_generator_damage;
252 self.iscaptured = TRUE;
253 self.islinked = TRUE;
254 self.isshielded = TRUE;
255 // spawn shield model which indicates whether this can be damaged
256 self.enemy = e = spawn();
258 e.movetype = MOVETYPE_NONE;
259 e.effects = EF_ADDITIVE;
260 setmodel(e, "models/onslaught/generator_shield.md3");
261 //setsize(e, '-32 -32 0', '32 32 128');
262 setorigin(e, self.origin);
263 e.colormap = self.colormap;
264 self.think = onslaught_generator_delayed;
265 self.nextthink = time + 0.2;
268 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_controlpoint_icon_damage =
272 if (self.owner.isshielded)
274 // this is protected by a shield, so ignore the damage
275 if (time > self.pain_finished)
276 if (attacker.classname == "player")
278 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
279 self.pain_finished = time + 1;
283 if (time > self.pain_finished)
284 if (attacker.classname == "player")
286 play2team(self.team, "sound/onslaught/controlpoint_underattack.wav");
287 self.pain_finished = time + 5;
289 self.health = self.health - damage;
290 self.alpha = self.health / self.max_health;
291 self.pain_finished = time + 1;
292 // colormod flash when shot
293 self.colormod = '2 2 2';
296 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
297 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
298 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", ColoredTeamName(attacker.team), "\n");
299 self.owner.goalentity = world;
300 self.owner.islinked = FALSE;
301 self.owner.iscaptured = FALSE;
303 self.owner.colormap = 1024;
304 onslaught_updatelinks();
309 void() onslaught_controlpoint_icon_think =
311 self.nextthink = time + 0.1;
312 if (time > self.pain_finished + 1)
314 self.health = self.health + self.count;
315 if (self.health >= self.max_health)
316 self.health = self.max_health;
318 self.alpha = self.health / self.max_health;
319 // colormod flash when shot
320 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
323 void() onslaught_controlpoint_icon_buildthink =
325 self.nextthink = time + 0.1;
326 self.health = self.health + self.count;
327 if (self.health >= self.max_health)
329 self.health = self.max_health;
330 self.count = self.count * 0.2; // slow repair rate from now on
331 self.think = onslaught_controlpoint_icon_think;
332 sound(self, CHAN_BODY, "sound/onslaught/controlpoint_built.wav", 1, ATTN_NORM);
333 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
334 self.owner.iscaptured = TRUE;
335 onslaught_updatelinks();
337 self.alpha = self.health / self.max_health;
338 // colormod flash when shot
339 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
342 void() onslaught_controlpoint_touch =
345 if (other.classname != "player")
347 // if there's already an icon built, nothing happens
350 // shielded points are definitely off-limits
353 // check to see if this player has a legitimate claim to capture this
354 // control point - more specifically that there is a captured path of
355 // points leading back to the team generator
356 e = findchain(classname, "onslaught_link");
359 if (e.goalentity == self)
361 if (e.enemy.islinked)
362 if (e.enemy.team == other.team)
365 else if (e.enemy == self)
367 if (e.goalentity.islinked)
368 if (e.goalentity.team == other.team)
375 // we've verified that this player has a legitimate claim to this point,
376 // so start building the captured point icon (which only captures this
377 // point if it successfully builds without being destroyed first)
378 self.goalentity = e = spawn();
381 e.health = e.max_health * 0.1;
382 e.alpha = e.health / e.max_health;
383 e.solid = SOLID_BBOX;
384 e.movetype = MOVETYPE_NONE;
385 setmodel(e, "models/onslaught/controlpoint_icon.md3");
386 setsize(e, '-32 -32 -32', '32 32 32');
387 setorigin(e, self.origin + '0 0 96');
388 e.takedamage = DAMAGE_AIM;
389 e.event_damage = onslaught_controlpoint_icon_damage;
391 e.think = onslaught_controlpoint_icon_buildthink;
392 e.nextthink = time + 0.1;
393 e.count = e.max_health / 50; // how long it takes to build
394 sound(e, CHAN_BODY, "sound/onslaught/controlpoint_build.wav", 1, ATTN_NORM);
396 self.colormap = 1024 + (self.team - 1) * 17;
399 /*QUAKED onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
400 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
402 This should link to an onslaught_controlpoint entity or onslaught_generator entity.
405 "targetname" - name that onslaught_link entities will use to target this.
406 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
407 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
409 void() onslaught_controlpoint =
417 precache_model("models/onslaught/controlpoint_pad.md3");
418 precache_model("models/onslaught/controlpoint_shield.md3");
419 precache_model("models/onslaught/controlpoint_icon.md3");
420 precache_sound("sound/onslaught/controlpoint_build.wav");
421 precache_sound("sound/onslaught/controlpoint_built.wav");
422 precache_sound("sound/weapons/grenade_impact.wav");
423 precache_sound("sound/onslaught/damageblockedbyshield.wav");
424 precache_sound("sound/onslaught/controlpoint_underattack.wav");
425 self.solid = SOLID_BSP;
426 self.movetype = MOVETYPE_NONE;
427 setmodel(self, "models/onslaught/controlpoint_pad.md3");
428 //setsize(self, '-32 -32 0', '32 32 8');
429 setorigin(self, self.origin);
430 self.touch = onslaught_controlpoint_touch;
431 self.colormap = 1024;
432 self.iscaptured = FALSE;
433 self.islinked = FALSE;
434 self.isshielded = TRUE;
435 // spawn shield model which indicates whether this can be damaged
436 self.enemy = e = spawn();
438 e.movetype = MOVETYPE_NONE;
439 e.effects = EF_ADDITIVE;
440 setmodel(e, "models/onslaught/controlpoint_shield.md3");
441 //setsize(e, '-32 -32 0', '32 32 128');
442 setorigin(e, self.origin);
443 e.colormap = self.colormap;
444 onslaught_updatelinks();
447 void() onslaught_link_delayed =
449 self.goalentity = find(world, targetname, self.target);
450 self.enemy = find(world, targetname, self.target2);
451 if (!self.goalentity)
452 objerror("can not find target\n");
454 objerror("can not find target2\n");
457 /*QUAKED onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
458 Link between control points.
460 This entity targets two different onslaught_controlpoint or onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
463 "target" - first control point.
464 "target2" - second control point.
466 void() onslaught_link =
473 if (self.target == "" || self.target2 == "")
474 objerror("target and target2 must be set\n");
475 self.think = onslaught_link_delayed;
476 self.nextthink = time + 0.1;