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");
325 t = ColoredTeamName(attacker.team);
326 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
328 self.iscaptured = FALSE;
329 self.islinked = FALSE;
330 self.isshielded = FALSE;
331 self.takedamage = DAMAGE_NO; // can't be hurt anymore
332 self.event_damage = SUB_Null; // won't do anything if hurt
333 self.count = 30; // 30 explosions
334 self.think = onslaught_generator_deaththink; // explosion sequence
335 self.nextthink = time; // start exploding immediately
336 self.think(); // do the first explosion now
337 onslaught_updatelinks();
341 // update links after a delay
342 void() onslaught_generator_delayed =
344 onslaught_updatelinks();
345 // now begin normal thinking
346 self.think = onslaught_generator_think;
347 self.nextthink = time;
350 float onslaught_generator_waypointsprite_for_player(entity e)
352 if(e.classname == "player")
353 if(e.team == self.owner.team)
355 if(self.owner.team == COLOR_TEAM1)
356 return ons_sprite_gen_red;
357 else if(self.owner.team == COLOR_TEAM2)
358 return ons_sprite_gen_blue;
360 if(self.owner.isshielded)
361 return ons_sprite_gen_shielded;
362 if(self.owner.team == COLOR_TEAM1)
363 return ons_sprite_gen_red;
364 else if(self.owner.team == COLOR_TEAM2)
365 return ons_sprite_gen_blue;
369 float onslaught_controlpoint_waypointsprite_for_player(entity e)
372 if(e.classname == "player")
374 a = onslaught_controlpoint_attackable(self.owner, e.team);
375 if(self.owner.team == e.team || a == -1 || a == 1) // own point, or fire at it
377 if(self.owner.team == COLOR_TEAM1)
378 return ons_sprite_cp_red;
379 else if(self.owner.team == COLOR_TEAM2)
380 return ons_sprite_cp_blue;
382 else if(a == 2) // touch it
383 return ons_sprite_cp_neut;
387 if(self.owner.team == COLOR_TEAM1)
388 return ons_sprite_cp_red;
389 else if(self.owner.team == COLOR_TEAM2)
390 return ons_sprite_cp_blue;
392 return ons_sprite_cp_neut;
397 /*QUAKED onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
400 onslaught_link entities can target this.
403 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
404 "targetname" - name that onslaught_link entities will use to target this.
406 void() onslaught_generator =
414 if(!ons_sprite_cp_blue)
416 precache_model("models/sprites/ons-cp-blue.sp2");
417 setmodel(self, "models/sprites/ons-cp-blue.sp2");
418 ons_sprite_cp_blue = self.modelindex;
419 precache_model("models/sprites/ons-cp-red.sp2");
420 setmodel(self, "models/sprites/ons-cp-red.sp2");
421 ons_sprite_cp_red = self.modelindex;
422 precache_model("models/sprites/ons-cp-neut.sp2");
423 setmodel(self, "models/sprites/ons-cp-neut.sp2");
424 ons_sprite_cp_neut = self.modelindex;
425 precache_model("models/sprites/ons-gen-blue.sp2");
426 setmodel(self, "models/sprites/ons-gen-blue.sp2");
427 ons_sprite_gen_blue = self.modelindex;
428 precache_model("models/sprites/ons-gen-red.sp2");
429 setmodel(self, "models/sprites/ons-gen-red.sp2");
430 ons_sprite_gen_red = self.modelindex;
431 precache_model("models/sprites/ons-gen-shielded.sp2");
432 setmodel(self, "models/sprites/ons-gen-shielded.sp2");
433 ons_sprite_gen_shielded = self.modelindex;
437 precache_model("models/onslaught/generator.md3");
438 precache_model("models/onslaught/generator_shield.md3");
439 precache_sound("sound/onslaught/generator_decay.wav");
440 precache_sound("sound/weapons/grenade_impact.wav");
441 precache_sound("sound/weapons/rocket_impact.wav");
442 precache_sound("sound/onslaught/generator_underattack.wav");
444 objerror("team must be set");
445 self.colormap = 1024 + (self.team - 1) * 17;
446 self.solid = SOLID_BSP;
447 self.movetype = MOVETYPE_NONE;
448 self.lasthealth = self.max_health = self.health = 3000;
449 setmodel(self, "models/onslaught/generator.md3");
450 //setsize(self, '-32 -32 -24', '32 32 64');
451 setorigin(self, self.origin);
452 self.takedamage = DAMAGE_AIM;
453 self.bot_attack = TRUE;
454 self.event_damage = onslaught_generator_damage;
455 self.iscaptured = TRUE;
456 self.islinked = TRUE;
457 self.isshielded = TRUE;
458 // spawn shield model which indicates whether this can be damaged
459 self.enemy = e = spawn();
461 e.movetype = MOVETYPE_NONE;
462 e.effects = EF_ADDITIVE;
463 setmodel(e, "models/onslaught/generator_shield.md3");
464 //setsize(e, '-32 -32 0', '32 32 128');
465 setorigin(e, self.origin);
466 e.colormap = self.colormap;
468 self.think = onslaught_generator_delayed;
469 self.nextthink = time + 0.2;
471 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
472 self.sprite.waypointsprite_for_player = onslaught_generator_waypointsprite_for_player;
475 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_controlpoint_icon_damage =
480 if (self.owner.isshielded)
482 // this is protected by a shield, so ignore the damage
483 if (time > self.pain_finished)
484 if (attacker.classname == "player")
486 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
487 self.pain_finished = time + 1;
491 if (time > self.pain_finished)
492 if (attacker.classname == "player")
494 play2team(self.team, "sound/onslaught/controlpoint_underattack.wav");
495 self.pain_finished = time + 5;
497 self.health = self.health - damage;
498 self.alpha = self.health / self.max_health;
499 self.pain_finished = time + 1;
500 // colormod flash when shot
501 self.colormod = '2 2 2';
504 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
505 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
506 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", ColoredTeamName(attacker.team), "\n");
507 self.owner.goalentity = world;
508 self.owner.islinked = FALSE;
509 self.owner.iscaptured = FALSE;
511 self.owner.colormap = 1024;
512 onslaught_updatelinks();
514 // Use targets now (somebody make sure this is in the right place..)
517 activator = self.owner;
525 void() onslaught_controlpoint_icon_think =
527 self.nextthink = time + 0.1;
528 if (time > self.pain_finished + 1)
530 self.health = self.health + self.count;
531 if (self.health >= self.max_health)
532 self.health = self.max_health;
534 self.alpha = self.health / self.max_health;
535 // colormod flash when shot
536 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
539 void() onslaught_controlpoint_icon_buildthink =
543 self.nextthink = time + 0.1;
544 self.health = self.health + self.count;
545 if (self.health >= self.max_health)
547 self.health = self.max_health;
548 self.count = self.count * 0.2; // slow repair rate from now on
549 self.think = onslaught_controlpoint_icon_think;
550 sound(self, CHAN_BODY, "sound/onslaught/controlpoint_built.wav", 1, ATTN_NORM);
551 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
552 self.owner.iscaptured = TRUE;
553 onslaught_updatelinks();
555 // Use targets now (somebody make sure this is in the right place..)
562 self.alpha = self.health / self.max_health;
563 // colormod flash when shot
564 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
567 void() onslaught_controlpoint_touch =
570 if (other.classname != "player")
572 if(onslaught_controlpoint_attackable(self, other.team) != 2)
574 // we've verified that this player has a legitimate claim to this point,
575 // so start building the captured point icon (which only captures this
576 // point if it successfully builds without being destroyed first)
577 self.goalentity = e = spawn();
580 e.health = e.max_health * 0.1;
581 e.alpha = e.health / e.max_health;
582 e.solid = SOLID_BBOX;
583 e.movetype = MOVETYPE_NONE;
584 setmodel(e, "models/onslaught/controlpoint_icon.md3");
585 setsize(e, '-32 -32 -32', '32 32 32');
586 setorigin(e, self.origin + '0 0 96');
587 e.takedamage = DAMAGE_AIM;
589 e.event_damage = onslaught_controlpoint_icon_damage;
591 e.colormap = 1024 + (e.team - 1) * 17;
592 e.think = onslaught_controlpoint_icon_buildthink;
593 e.nextthink = time + 0.1;
594 e.count = e.max_health / 50; // how long it takes to build
595 sound(e, CHAN_BODY, "sound/onslaught/controlpoint_build.wav", 1, ATTN_NORM);
597 self.colormap = e.colormap;
600 /*QUAKED onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
601 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
603 This should link to an onslaught_controlpoint entity or onslaught_generator entity.
606 "targetname" - name that onslaught_link entities will use to target this.
607 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
608 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
610 void() onslaught_controlpoint =
618 precache_model("models/onslaught/controlpoint_pad.md3");
619 precache_model("models/onslaught/controlpoint_shield.md3");
620 precache_model("models/onslaught/controlpoint_icon.md3");
621 precache_sound("sound/onslaught/controlpoint_build.wav");
622 precache_sound("sound/onslaught/controlpoint_built.wav");
623 precache_sound("sound/weapons/grenade_impact.wav");
624 precache_sound("sound/onslaught/damageblockedbyshield.wav");
625 precache_sound("sound/onslaught/controlpoint_underattack.wav");
626 self.solid = SOLID_BSP;
627 self.movetype = MOVETYPE_NONE;
628 setmodel(self, "models/onslaught/controlpoint_pad.md3");
629 //setsize(self, '-32 -32 0', '32 32 8');
630 setorigin(self, self.origin);
631 self.touch = onslaught_controlpoint_touch;
633 self.colormap = 1024;
634 self.iscaptured = FALSE;
635 self.islinked = FALSE;
636 self.isshielded = TRUE;
637 // spawn shield model which indicates whether this can be damaged
638 self.enemy = e = spawn();
640 e.movetype = MOVETYPE_NONE;
641 e.effects = EF_ADDITIVE;
642 setmodel(e, "models/onslaught/controlpoint_shield.md3");
643 //setsize(e, '-32 -32 0', '32 32 128');
644 setorigin(e, self.origin);
645 e.colormap = self.colormap;
646 onslaught_updatelinks();
648 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
649 self.sprite.waypointsprite_for_player = onslaught_controlpoint_waypointsprite_for_player;
652 void() onslaught_link_delayed =
654 self.goalentity = find(world, targetname, self.target);
655 self.enemy = find(world, targetname, self.target2);
656 if (!self.goalentity)
657 objerror("can not find target\n");
659 objerror("can not find target2\n");
660 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
663 /*QUAKED onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
664 Link between control points.
666 This entity targets two different onslaught_controlpoint or onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
669 "target" - first control point.
670 "target2" - second control point.
672 void() onslaught_link =
679 if (self.target == "" || self.target2 == "")
680 objerror("target and target2 must be set\n");
681 self.think = onslaught_link_delayed;
682 self.nextthink = time + 0.1;