8 float ons_sprite_cp_red, ons_sprite_cp_blue, ons_sprite_cp_neut;
9 float ons_sprite_gen_red, ons_sprite_gen_blue, ons_sprite_gen_shielded;
11 void() onslaught_updatelinks =
13 local entity l, links;
14 local float stop, t1, t2, t3, t4;
15 // first check if the game has ended
16 dprint("--- updatelinks ---\n");
17 links = findchain(classname, "onslaught_link");
18 // mark generators as being shielded and networked
19 l = findchain(classname, "onslaught_generator");
23 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
25 dprint(etos(l), " (generator) is destroyed\n");
26 l.islinked = l.iscaptured;
27 l.isshielded = l.iscaptured;
30 // mark points as shielded and not networked
31 l = findchain(classname, "onslaught_controlpoint");
36 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
39 // flow power outward from the generators through the network
43 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
53 // if both points are captured by the same team, and only one of
54 // them is powered, mark the other one as powered as well
55 if (l.enemy.iscaptured && l.goalentity.iscaptured)
56 if (l.enemy.islinked != l.goalentity.islinked)
57 if (l.enemy.team == l.goalentity.team)
59 if (!l.goalentity.islinked)
62 l.goalentity.islinked = TRUE;
63 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
65 else if (!l.enemy.islinked)
68 l.enemy.islinked = TRUE;
69 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
75 // now that we know which points are powered we can mark their neighbors
76 // as unshielded if team differs
80 if (l.goalentity.team != l.enemy.team)
82 if (l.goalentity.islinked)
84 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
85 l.enemy.isshielded = FALSE;
89 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
90 l.goalentity.isshielded = FALSE;
95 // now update the takedamage and alpha variables on generator shields
96 l = findchain(classname, "onslaught_generator");
101 dprint(etos(l), " (generator) is shielded\n");
103 l.takedamage = DAMAGE_NO;
104 l.bot_attack = FALSE;
108 dprint(etos(l), " (generator) is not shielded\n");
110 l.takedamage = DAMAGE_AIM;
115 // now update the takedamage and alpha variables on control point icons
116 l = findchain(classname, "onslaught_controlpoint");
121 dprint(etos(l), " (point) is shielded\n");
125 l.goalentity.takedamage = DAMAGE_NO;
126 l.goalentity.bot_attack = FALSE;
131 dprint(etos(l), " (point) is not shielded\n");
135 l.goalentity.takedamage = DAMAGE_AIM;
136 l.goalentity.bot_attack = TRUE;
141 // count generators owned by each team
142 t1 = t2 = t3 = t4 = 0;
143 l = findchain(classname, "onslaught_generator");
148 if (l.team == COLOR_TEAM1) t1 = 1;
149 if (l.team == COLOR_TEAM2) t2 = 1;
150 if (l.team == COLOR_TEAM3) t3 = 1;
151 if (l.team == COLOR_TEAM4) t4 = 1;
155 // see if multiple teams remain (if not, it's game over)
156 if (t1 + t2 + t3 + t4 < 2)
157 dprint("--- game over ---\n");
159 dprint("--- done updating links ---\n");
162 float onslaught_controlpoint_can_be_linked(entity cp, float t)
165 // check to see if this player has a legitimate claim to capture this
166 // control point - more specifically that there is a captured path of
167 // points leading back to the team generator
168 e = findchain(classname, "onslaught_link");
171 if (e.goalentity == cp)
173 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
174 if (e.enemy.islinked)
176 dprint(" which is linked");
177 if (e.enemy.team == t)
179 dprint(" and has the correct team!\n");
183 dprint(" but has the wrong team\n");
188 else if (e.enemy == cp)
190 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
191 if (e.goalentity.islinked)
193 dprint(" which is linked");
194 if (e.goalentity.team == t)
196 dprint(" and has a team!\n");
200 dprint(" but has the wrong team\n");
210 float onslaught_controlpoint_attackable(entity cp, float t)
220 else if(cp.goalentity)
222 // if there's already an icon built, nothing happens
225 if(onslaught_controlpoint_can_be_linked(cp, t))
231 if(onslaught_controlpoint_can_be_linked(cp, t))
237 void() onslaught_generator_think =
241 self.nextthink = ceil(time + 1);
242 if (cvar("timelimit"))
243 if (time > cvar("timelimit") * 60 - 60)
245 // self.max_health / 300 gives 5 minutes of overtime.
246 // control points reduce the overtime duration.
247 sound(self, CHAN_AUTO, "sound/onslaught/generator_decay.wav", 1, ATTN_NORM);
249 e = findchain(classname, "onslaught_controlpoint");
252 if (e.team != self.team)
257 d = d * self.max_health / 300;
258 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
262 void() onslaught_generator_deaththink =
267 self.nextthink = time + 0.1;
268 self.count = self.count - 1;
269 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
270 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
271 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
276 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
277 sound(self, CHAN_AUTO, "sound/weapons/rocket_impact.wav", 1, ATTN_NORM);
281 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_generator_damage =
285 if (attacker != self)
289 // this is protected by a shield, so ignore the damage
290 if (time > self.pain_finished)
291 if (attacker.classname == "player")
293 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
294 self.pain_finished = time + 1;
298 if (time > self.pain_finished)
300 self.pain_finished = time + 5;
301 bprint(ColoredTeamName(self.team), " generator under attack!\n");
302 play2team(self.team, "sound/onslaught/generator_underattack.wav");
305 self.health = self.health - damage;
306 // choose an animation frame based on health
307 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
308 // see if the generator is still functional, or dying
312 lh = ceil(self.lasthealth / 100) * 100;
313 h = ceil(self.health / 100) * 100;
315 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
316 self.lasthealth = self.health;
320 if (attacker == self)
321 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
323 bprint(ColoredTeamName(self.team), " generator destroyed by ", ColoredTeamName(attacker.team), "!\n");
324 self.iscaptured = FALSE;
325 self.islinked = FALSE;
326 self.isshielded = FALSE;
327 self.takedamage = DAMAGE_NO; // can't be hurt anymore
328 self.event_damage = SUB_Null; // won't do anything if hurt
329 self.count = 30; // 30 explosions
330 self.think = onslaught_generator_deaththink; // explosion sequence
331 self.nextthink = time; // start exploding immediately
332 self.think(); // do the first explosion now
333 onslaught_updatelinks();
337 // update links after a delay
338 void() onslaught_generator_delayed =
340 onslaught_updatelinks();
341 // now begin normal thinking
342 self.think = onslaught_generator_think;
343 self.nextthink = time;
346 float onslaught_generator_waypointsprite_for_player(entity e)
348 if(e.classname == "player")
349 if(e.team == self.owner.team)
351 if(self.owner.team == COLOR_TEAM1)
352 return ons_sprite_gen_red;
353 else if(self.owner.team == COLOR_TEAM2)
354 return ons_sprite_gen_blue;
356 if(self.owner.isshielded)
357 return ons_sprite_gen_shielded;
358 if(self.owner.team == COLOR_TEAM1)
359 return ons_sprite_gen_red;
360 else if(self.owner.team == COLOR_TEAM2)
361 return ons_sprite_gen_blue;
365 float onslaught_controlpoint_waypointsprite_for_player(entity e)
368 if(e.classname == "player")
370 a = onslaught_controlpoint_attackable(self.owner, e.team);
371 if(a == -1 || a == 1) // own point, or fire at it
373 if(self.owner.team == COLOR_TEAM1)
374 return ons_sprite_cp_red;
375 else if(self.owner.team == COLOR_TEAM2)
376 return ons_sprite_cp_blue;
378 else if(a == 2) // touch it
379 return ons_sprite_cp_neut;
383 if(self.owner.team == COLOR_TEAM1)
384 return ons_sprite_cp_red;
385 else if(self.owner.team == COLOR_TEAM2)
386 return ons_sprite_cp_blue;
388 return ons_sprite_cp_neut;
393 /*QUAKED onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
396 onslaught_link entities can target this.
399 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
400 "targetname" - name that onslaught_link entities will use to target this.
402 void() onslaught_generator =
410 if(!ons_sprite_cp_blue)
412 precache_model("models/sprites/ons-cp-blue.sp2");
413 setmodel(self, "models/sprites/ons-cp-blue.sp2");
414 ons_sprite_cp_blue = self.modelindex;
415 precache_model("models/sprites/ons-cp-red.sp2");
416 setmodel(self, "models/sprites/ons-cp-red.sp2");
417 ons_sprite_cp_red = self.modelindex;
418 precache_model("models/sprites/ons-cp-neut.sp2");
419 setmodel(self, "models/sprites/ons-cp-neut.sp2");
420 ons_sprite_cp_neut = self.modelindex;
421 precache_model("models/sprites/ons-gen-blue.sp2");
422 setmodel(self, "models/sprites/ons-gen-blue.sp2");
423 ons_sprite_gen_blue = self.modelindex;
424 precache_model("models/sprites/ons-gen-red.sp2");
425 setmodel(self, "models/sprites/ons-gen-red.sp2");
426 ons_sprite_gen_red = self.modelindex;
427 precache_model("models/sprites/ons-gen-shielded.sp2");
428 setmodel(self, "models/sprites/ons-gen-shielded.sp2");
429 ons_sprite_gen_shielded = self.modelindex;
433 precache_model("models/onslaught/generator.md3");
434 precache_model("models/onslaught/generator_shield.md3");
435 precache_sound("sound/onslaught/generator_decay.wav");
436 precache_sound("sound/weapons/grenade_impact.wav");
437 precache_sound("sound/weapons/rocket_impact.wav");
438 precache_sound("sound/onslaught/generator_underattack.wav");
440 objerror("team must be set");
441 self.colormap = 1024 + (self.team - 1) * 17;
442 self.solid = SOLID_BSP;
443 self.movetype = MOVETYPE_NONE;
444 self.lasthealth = self.max_health = self.health = 3000;
445 setmodel(self, "models/onslaught/generator.md3");
446 //setsize(self, '-32 -32 -24', '32 32 64');
447 setorigin(self, self.origin);
448 self.takedamage = DAMAGE_AIM;
449 self.bot_attack = TRUE;
450 self.event_damage = onslaught_generator_damage;
451 self.iscaptured = TRUE;
452 self.islinked = TRUE;
453 self.isshielded = TRUE;
454 // spawn shield model which indicates whether this can be damaged
455 self.enemy = e = spawn();
457 e.movetype = MOVETYPE_NONE;
458 e.effects = EF_ADDITIVE;
459 setmodel(e, "models/onslaught/generator_shield.md3");
460 //setsize(e, '-32 -32 0', '32 32 128');
461 setorigin(e, self.origin);
462 e.colormap = self.colormap;
464 self.think = onslaught_generator_delayed;
465 self.nextthink = time + 0.2;
467 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
468 self.sprite.waypointsprite_for_player = onslaught_generator_waypointsprite_for_player;
471 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_controlpoint_icon_damage =
476 if (self.owner.isshielded)
478 // this is protected by a shield, so ignore the damage
479 if (time > self.pain_finished)
480 if (attacker.classname == "player")
482 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
483 self.pain_finished = time + 1;
487 if (time > self.pain_finished)
488 if (attacker.classname == "player")
490 play2team(self.team, "sound/onslaught/controlpoint_underattack.wav");
491 self.pain_finished = time + 5;
493 self.health = self.health - damage;
494 self.alpha = self.health / self.max_health;
495 self.pain_finished = time + 1;
496 // colormod flash when shot
497 self.colormod = '2 2 2';
500 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
501 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
502 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", ColoredTeamName(attacker.team), "\n");
503 self.owner.goalentity = world;
504 self.owner.islinked = FALSE;
505 self.owner.iscaptured = FALSE;
507 self.owner.colormap = 1024;
508 onslaught_updatelinks();
510 // Use targets now (somebody make sure this is in the right place..)
513 activator = self.owner;
521 void() onslaught_controlpoint_icon_think =
523 self.nextthink = time + 0.1;
524 if (time > self.pain_finished + 1)
526 self.health = self.health + self.count;
527 if (self.health >= self.max_health)
528 self.health = self.max_health;
530 self.alpha = self.health / self.max_health;
531 // colormod flash when shot
532 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
535 void() onslaught_controlpoint_icon_buildthink =
539 self.nextthink = time + 0.1;
540 self.health = self.health + self.count;
541 if (self.health >= self.max_health)
543 self.health = self.max_health;
544 self.count = self.count * 0.2; // slow repair rate from now on
545 self.think = onslaught_controlpoint_icon_think;
546 sound(self, CHAN_BODY, "sound/onslaught/controlpoint_built.wav", 1, ATTN_NORM);
547 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
548 self.owner.iscaptured = TRUE;
549 onslaught_updatelinks();
551 // Use targets now (somebody make sure this is in the right place..)
558 self.alpha = self.health / self.max_health;
559 // colormod flash when shot
560 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
563 void() onslaught_controlpoint_touch =
566 if (other.classname != "player")
568 if(onslaught_controlpoint_attackable(self, other.team) != 2)
570 // we've verified that this player has a legitimate claim to this point,
571 // so start building the captured point icon (which only captures this
572 // point if it successfully builds without being destroyed first)
573 self.goalentity = e = spawn();
576 e.health = e.max_health * 0.1;
577 e.alpha = e.health / e.max_health;
578 e.solid = SOLID_BBOX;
579 e.movetype = MOVETYPE_NONE;
580 setmodel(e, "models/onslaught/controlpoint_icon.md3");
581 setsize(e, '-32 -32 -32', '32 32 32');
582 setorigin(e, self.origin + '0 0 96');
583 e.takedamage = DAMAGE_AIM;
585 e.event_damage = onslaught_controlpoint_icon_damage;
587 e.colormap = 1024 + (e.team - 1) * 17;
588 e.think = onslaught_controlpoint_icon_buildthink;
589 e.nextthink = time + 0.1;
590 e.count = e.max_health / 50; // how long it takes to build
591 sound(e, CHAN_BODY, "sound/onslaught/controlpoint_build.wav", 1, ATTN_NORM);
593 self.colormap = e.colormap;
596 /*QUAKED onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
597 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
599 This should link to an onslaught_controlpoint entity or onslaught_generator entity.
602 "targetname" - name that onslaught_link entities will use to target this.
603 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
604 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
606 void() onslaught_controlpoint =
614 precache_model("models/onslaught/controlpoint_pad.md3");
615 precache_model("models/onslaught/controlpoint_shield.md3");
616 precache_model("models/onslaught/controlpoint_icon.md3");
617 precache_sound("sound/onslaught/controlpoint_build.wav");
618 precache_sound("sound/onslaught/controlpoint_built.wav");
619 precache_sound("sound/weapons/grenade_impact.wav");
620 precache_sound("sound/onslaught/damageblockedbyshield.wav");
621 precache_sound("sound/onslaught/controlpoint_underattack.wav");
622 self.solid = SOLID_BSP;
623 self.movetype = MOVETYPE_NONE;
624 setmodel(self, "models/onslaught/controlpoint_pad.md3");
625 //setsize(self, '-32 -32 0', '32 32 8');
626 setorigin(self, self.origin);
627 self.touch = onslaught_controlpoint_touch;
629 self.colormap = 1024;
630 self.iscaptured = FALSE;
631 self.islinked = FALSE;
632 self.isshielded = TRUE;
633 // spawn shield model which indicates whether this can be damaged
634 self.enemy = e = spawn();
636 e.movetype = MOVETYPE_NONE;
637 e.effects = EF_ADDITIVE;
638 setmodel(e, "models/onslaught/controlpoint_shield.md3");
639 //setsize(e, '-32 -32 0', '32 32 128');
640 setorigin(e, self.origin);
641 e.colormap = self.colormap;
642 onslaught_updatelinks();
644 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
645 self.sprite.waypointsprite_for_player = onslaught_controlpoint_waypointsprite_for_player;
648 void() onslaught_link_delayed =
650 self.goalentity = find(world, targetname, self.target);
651 self.enemy = find(world, targetname, self.target2);
652 if (!self.goalentity)
653 objerror("can not find target\n");
655 objerror("can not find target2\n");
656 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
659 /*QUAKED onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
660 Link between control points.
662 This entity targets two different onslaught_controlpoint or onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
665 "target" - first control point.
666 "target2" - second control point.
668 void() onslaught_link =
675 if (self.target == "" || self.target2 == "")
676 objerror("target and target2 must be set\n");
677 self.think = onslaught_link_delayed;
678 self.nextthink = time + 0.1;