6 void() onslaught_updatelinks =
9 local float stop, t1, t2, t3, t4;
10 // first check if the game has ended
11 dprint("--- updatelinks ---\n");
12 links = findchain(classname, "onslaught_link");
13 // mark generators as being shielded and networked
14 l = findchain(classname, "onslaught_generator");
18 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
20 dprint(etos(l), " (generator) is destroyed\n");
21 l.islinked = l.iscaptured;
22 l.isshielded = l.iscaptured;
25 // mark points as shielded and not networked
26 l = findchain(classname, "onslaught_controlpoint");
31 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
34 // flow power outward from the generators through the network
38 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
48 // if both points are captured by the same team, and only one of
49 // them is powered, mark the other one as powered as well
50 if (l.enemy.iscaptured && l.goalentity.iscaptured)
51 if (l.enemy.islinked != l.goalentity.islinked)
52 if (l.enemy.team == l.goalentity.team)
54 if (!l.goalentity.islinked)
57 l.goalentity.islinked = TRUE;
58 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
60 else if (!l.enemy.islinked)
63 l.enemy.islinked = TRUE;
64 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
70 // now that we know which points are powered we can mark their neighbors
71 // as unshielded if team differs
75 if (l.goalentity.team != l.enemy.team)
77 if (l.goalentity.islinked)
79 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
80 l.enemy.isshielded = FALSE;
84 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
85 l.goalentity.isshielded = FALSE;
90 // now update the takedamage and alpha variables on generator shields
91 l = findchain(classname, "onslaught_generator");
96 dprint(etos(l), " (generator) is shielded\n");
98 l.takedamage = DAMAGE_NO;
103 dprint(etos(l), " (generator) is not shielded\n");
105 l.takedamage = DAMAGE_AIM;
110 // now update the takedamage and alpha variables on control point icons
111 l = findchain(classname, "onslaught_controlpoint");
116 dprint(etos(l), " (point) is shielded\n");
120 l.goalentity.takedamage = DAMAGE_NO;
121 l.goalentity.bot_attack = FALSE;
126 dprint(etos(l), " (point) is not shielded\n");
130 l.goalentity.takedamage = DAMAGE_AIM;
131 l.goalentity.bot_attack = TRUE;
136 // count generators owned by each team
137 t1 = t2 = t3 = t4 = 0;
138 l = findchain(classname, "onslaught_generator");
143 if (l.team == COLOR_TEAM1) t1 = 1;
144 if (l.team == COLOR_TEAM2) t2 = 1;
145 if (l.team == COLOR_TEAM3) t3 = 1;
146 if (l.team == COLOR_TEAM4) t4 = 1;
150 // see if multiple teams remain (if not, it's game over)
151 if (t1 + t2 + t3 + t4 < 2)
152 dprint("--- game over ---\n");
154 dprint("--- done updating links ---\n");
157 void() onslaught_generator_think =
161 self.nextthink = ceil(time + 1);
162 if (cvar("timelimit"))
163 if (time > cvar("timelimit") * 60 - 60)
165 // self.max_health / 300 gives 5 minutes of overtime.
166 // control points reduce the overtime duration.
167 sound(self, CHAN_AUTO, "sound/onslaught/generator_decay.wav", 1, ATTN_NORM);
169 e = findchain(classname, "onslaught_controlpoint");
172 if (e.team != self.team)
177 d = d * self.max_health / 300;
178 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
182 void() onslaught_generator_deaththink =
187 self.nextthink = time + 0.1;
188 self.count = self.count - 1;
189 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
190 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
191 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
196 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
197 sound(self, CHAN_AUTO, "sound/weapons/rocket_impact.wav", 1, ATTN_NORM);
201 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_generator_damage =
205 if (attacker != self)
209 // this is protected by a shield, so ignore the damage
210 if (time > self.pain_finished)
211 if (attacker.classname == "player")
213 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
214 self.pain_finished = time + 1;
218 if (time > self.pain_finished)
220 self.pain_finished = time + 5;
221 bprint(ColoredTeamName(self.team), " generator under attack!\n");
222 play2team(self.team, "sound/onslaught/generator_underattack.wav");
225 self.health = self.health - damage;
226 // choose an animation frame based on health
227 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
228 // see if the generator is still functional, or dying
230 bprint(ColoredTeamName(self.team), " generator has ", ftos(floor(self.health)), " health remaining\n");
233 if (attacker == self)
234 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
236 bprint(ColoredTeamName(self.team), " generator destroyed by ", ColoredTeamName(attacker.team), "!\n");
237 self.iscaptured = FALSE;
238 self.islinked = FALSE;
239 self.isshielded = FALSE;
240 self.takedamage = DAMAGE_NO; // can't be hurt anymore
241 self.event_damage = SUB_Null; // won't do anything if hurt
242 self.count = 30; // 30 explosions
243 self.think = onslaught_generator_deaththink; // explosion sequence
244 self.nextthink = time; // start exploding immediately
245 self.think(); // do the first explosion now
246 onslaught_updatelinks();
250 // update links after a delay
251 void() onslaught_generator_delayed =
253 onslaught_updatelinks();
254 // now begin normal thinking
255 self.think = onslaught_generator_think;
256 self.nextthink = time;
259 /*QUAKED onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
262 onslaught_link entities can target this.
265 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
266 "targetname" - name that onslaught_link entities will use to target this.
268 void() onslaught_generator =
276 precache_model("models/onslaught/generator.md3");
277 precache_model("models/onslaught/generator_shield.md3");
278 precache_sound("sound/onslaught/generator_decay.wav");
279 precache_sound("sound/weapons/grenade_impact.wav");
280 precache_sound("sound/weapons/rocket_impact.wav");
281 precache_sound("sound/onslaught/generator_underattack.wav");
283 objerror("team must be set");
284 self.colormap = 1024 + (self.team - 1) * 17;
285 self.solid = SOLID_BSP;
286 self.movetype = MOVETYPE_NONE;
287 self.max_health = self.health = 3000;
288 setmodel(self, "models/onslaught/generator.md3");
289 //setsize(self, '-32 -32 -24', '32 32 64');
290 setorigin(self, self.origin);
291 self.takedamage = DAMAGE_AIM;
292 self.bot_attack = TRUE;
293 self.event_damage = onslaught_generator_damage;
294 self.iscaptured = TRUE;
295 self.islinked = TRUE;
296 self.isshielded = TRUE;
297 // spawn shield model which indicates whether this can be damaged
298 self.enemy = e = spawn();
300 e.movetype = MOVETYPE_NONE;
301 e.effects = EF_ADDITIVE;
302 setmodel(e, "models/onslaught/generator_shield.md3");
303 //setsize(e, '-32 -32 0', '32 32 128');
304 setorigin(e, self.origin);
305 e.colormap = self.colormap;
308 // use our "target"s (spawn points linked to generator for Morphed..)
312 self.think = onslaught_generator_delayed;
313 self.nextthink = time + 0.2;
316 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_controlpoint_icon_damage =
321 if (self.owner.isshielded)
323 // this is protected by a shield, so ignore the damage
324 if (time > self.pain_finished)
325 if (attacker.classname == "player")
327 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
328 self.pain_finished = time + 1;
332 if (time > self.pain_finished)
333 if (attacker.classname == "player")
335 play2team(self.team, "sound/onslaught/controlpoint_underattack.wav");
336 self.pain_finished = time + 5;
338 self.health = self.health - damage;
339 self.alpha = self.health / self.max_health;
340 self.pain_finished = time + 1;
341 // colormod flash when shot
342 self.colormod = '2 2 2';
345 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
346 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
347 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", ColoredTeamName(attacker.team), "\n");
348 self.owner.goalentity = world;
349 self.owner.islinked = FALSE;
350 self.owner.iscaptured = FALSE;
352 self.owner.colormap = 1024;
353 onslaught_updatelinks();
355 // Use targets now (somebody make sure this is in the right place..)
358 activator = self.owner;
366 void() onslaught_controlpoint_icon_think =
368 self.nextthink = time + 0.1;
369 if (time > self.pain_finished + 1)
371 self.health = self.health + self.count;
372 if (self.health >= self.max_health)
373 self.health = self.max_health;
375 self.alpha = self.health / self.max_health;
376 // colormod flash when shot
377 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
380 void() onslaught_controlpoint_icon_buildthink =
384 self.nextthink = time + 0.1;
385 self.health = self.health + self.count;
386 if (self.health >= self.max_health)
388 self.health = self.max_health;
389 self.count = self.count * 0.2; // slow repair rate from now on
390 self.think = onslaught_controlpoint_icon_think;
391 sound(self, CHAN_BODY, "sound/onslaught/controlpoint_built.wav", 1, ATTN_NORM);
392 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
393 self.owner.iscaptured = TRUE;
394 onslaught_updatelinks();
396 // Use targets now (somebody make sure this is in the right place..)
403 self.alpha = self.health / self.max_health;
404 // colormod flash when shot
405 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
408 void() onslaught_controlpoint_touch =
411 if (other.classname != "player")
413 // if there's already an icon built, nothing happens
419 // shielded points are definitely off-limits
425 // check to see if this player has a legitimate claim to capture this
426 // control point - more specifically that there is a captured path of
427 // points leading back to the team generator
428 e = findchain(classname, "onslaught_link");
431 if (e.goalentity == self)
433 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
434 if (e.enemy.islinked)
436 dprint(" which is linked");
437 if (e.enemy.team == other.team)
439 dprint(" and has the correct team!\n");
443 dprint(" but has the wrong team\n");
448 else if (e.enemy == self)
450 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
451 if (e.goalentity.islinked)
453 dprint(" which is linked");
454 if (e.goalentity.team == other.team)
456 dprint(" and has a team!\n");
460 dprint(" but has the wrong team\n");
472 // we've verified that this player has a legitimate claim to this point,
473 // so start building the captured point icon (which only captures this
474 // point if it successfully builds without being destroyed first)
475 self.goalentity = e = spawn();
478 e.health = e.max_health * 0.1;
479 e.alpha = e.health / e.max_health;
480 e.solid = SOLID_BBOX;
481 e.movetype = MOVETYPE_NONE;
482 setmodel(e, "models/onslaught/controlpoint_icon.md3");
483 setsize(e, '-32 -32 -32', '32 32 32');
484 setorigin(e, self.origin + '0 0 96');
485 e.takedamage = DAMAGE_AIM;
487 e.event_damage = onslaught_controlpoint_icon_damage;
489 e.colormap = 1024 + (e.team - 1) * 17;
490 e.think = onslaught_controlpoint_icon_buildthink;
491 e.nextthink = time + 0.1;
492 e.count = e.max_health / 50; // how long it takes to build
493 sound(e, CHAN_BODY, "sound/onslaught/controlpoint_build.wav", 1, ATTN_NORM);
495 self.colormap = e.colormap;
498 /*QUAKED onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
499 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
501 This should link to an onslaught_controlpoint entity or onslaught_generator entity.
504 "targetname" - name that onslaught_link entities will use to target this.
505 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
506 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
508 void() onslaught_controlpoint =
516 precache_model("models/onslaught/controlpoint_pad.md3");
517 precache_model("models/onslaught/controlpoint_shield.md3");
518 precache_model("models/onslaught/controlpoint_icon.md3");
519 precache_sound("sound/onslaught/controlpoint_build.wav");
520 precache_sound("sound/onslaught/controlpoint_built.wav");
521 precache_sound("sound/weapons/grenade_impact.wav");
522 precache_sound("sound/onslaught/damageblockedbyshield.wav");
523 precache_sound("sound/onslaught/controlpoint_underattack.wav");
524 self.solid = SOLID_BSP;
525 self.movetype = MOVETYPE_NONE;
526 setmodel(self, "models/onslaught/controlpoint_pad.md3");
527 //setsize(self, '-32 -32 0', '32 32 8');
528 setorigin(self, self.origin);
529 self.touch = onslaught_controlpoint_touch;
531 self.colormap = 1024;
532 self.iscaptured = FALSE;
533 self.islinked = FALSE;
534 self.isshielded = TRUE;
535 // spawn shield model which indicates whether this can be damaged
536 self.enemy = e = spawn();
538 e.movetype = MOVETYPE_NONE;
539 e.effects = EF_ADDITIVE;
540 setmodel(e, "models/onslaught/controlpoint_shield.md3");
541 //setsize(e, '-32 -32 0', '32 32 128');
542 setorigin(e, self.origin);
543 e.colormap = self.colormap;
544 onslaught_updatelinks();
547 void() onslaught_link_delayed =
549 self.goalentity = find(world, targetname, self.target);
550 self.enemy = find(world, targetname, self.target2);
551 if (!self.goalentity)
552 objerror("can not find target\n");
554 objerror("can not find target2\n");
555 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
558 /*QUAKED onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
559 Link between control points.
561 This entity targets two different onslaught_controlpoint or onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
564 "target" - first control point.
565 "target2" - second control point.
567 void() onslaught_link =
574 if (self.target == "" || self.target2 == "")
575 objerror("target and target2 must be set\n");
576 self.think = onslaught_link_delayed;
577 self.nextthink = time + 0.1;