1 float autocvar_g_onslaught_spawn_at_controlpoints;
2 float autocvar_g_onslaught_spawn_at_generator;
3 float autocvar_g_onslaught_controlpoints_proxycap;
4 float autocvar_g_onslaught_controlpoints_proxycap_distance = 512;
5 float autocvar_g_onslaught_controlpoints_proxycap_dps = 100;
7 void onslaught_generator_updatesprite(entity e);
8 void onslaught_controlpoint_updatesprite(entity e);
9 void onslaught_link_checkupdate();
15 .float isgenneighbor_red;
16 .float isgenneighbor_blue;
17 .float iscpneighbor_red;
18 .float iscpneighbor_blue;
25 .string model1, model2, model3;
27 entity ons_red_generator;
28 entity ons_blue_generator;
30 void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
32 self.velocity = self.velocity + vforce;
36 void ons_throwgib_think()
40 self.nextthink = time + 0.05;
42 d = self.giblifetime - time;
46 self.think = SUB_Remove;
54 pointparticles(particleeffectnum("onslaught_generator_gib_flame"), self.origin, '0 0 0', 1);
57 void ons_throwgib(vector v_from, vector v_to, string smodel, float f_lifetime, float b_burn)
63 setmodel(gib, smodel);
64 setorigin(gib, v_from);
65 gib.solid = SOLID_BBOX;
66 gib.movetype = MOVETYPE_BOUNCE;
67 gib.takedamage = DAMAGE_YES;
68 gib.event_damage = ons_gib_damage;
70 gib.effects = EF_LOWPRECISION;
71 gib.flags = FL_NOTARGET;
73 gib.giblifetime = time + f_lifetime;
77 gib.think = ons_throwgib_think;
78 gib.nextthink = time + 0.05;
81 SUB_SetFade(gib, gib.giblifetime, 2);
84 void onslaught_updatelinks()
87 float stop, t1, t2, t3, t4;
88 // first check if the game has ended
89 dprint("--- updatelinks ---\n");
90 links = findchain(classname, "onslaught_link");
91 // mark generators as being shielded and networked
92 l = findchain(classname, "onslaught_generator");
96 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
98 dprint(etos(l), " (generator) is destroyed\n");
99 l.islinked = l.iscaptured;
100 l.isshielded = l.iscaptured;
103 // mark points as shielded and not networked
104 l = findchain(classname, "onslaught_controlpoint");
109 l.isgenneighbor_red = FALSE;
110 l.isgenneighbor_blue = FALSE;
111 l.iscpneighbor_red = FALSE;
112 l.iscpneighbor_blue = FALSE;
113 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
116 // flow power outward from the generators through the network
120 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
130 // if both points are captured by the same team, and only one of
131 // them is powered, mark the other one as powered as well
132 if (l.enemy.iscaptured && l.goalentity.iscaptured)
133 if (l.enemy.islinked != l.goalentity.islinked)
134 if (l.enemy.team == l.goalentity.team)
136 if (!l.goalentity.islinked)
139 l.goalentity.islinked = TRUE;
140 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
142 else if (!l.enemy.islinked)
145 l.enemy.islinked = TRUE;
146 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
152 // now that we know which points are powered we can mark their neighbors
153 // as unshielded if team differs
157 if (l.goalentity.islinked)
159 if (l.goalentity.team != l.enemy.team)
161 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
162 l.enemy.isshielded = FALSE;
164 if(l.goalentity.classname == "onslaught_generator")
166 if(l.goalentity.team == COLOR_TEAM1)
167 l.enemy.isgenneighbor_red = TRUE;
168 else if(l.goalentity.team == COLOR_TEAM2)
169 l.enemy.isgenneighbor_blue = TRUE;
173 if(l.goalentity.team == COLOR_TEAM1)
174 l.enemy.iscpneighbor_red = TRUE;
175 else if(l.goalentity.team == COLOR_TEAM2)
176 l.enemy.iscpneighbor_blue = TRUE;
179 if (l.enemy.islinked)
181 if (l.goalentity.team != l.enemy.team)
183 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
184 l.goalentity.isshielded = FALSE;
186 if(l.enemy.classname == "onslaught_generator")
188 if(l.enemy.team == COLOR_TEAM1)
189 l.goalentity.isgenneighbor_red = TRUE;
190 else if(l.enemy.team == COLOR_TEAM2)
191 l.goalentity.isgenneighbor_blue = TRUE;
195 if(l.enemy.team == COLOR_TEAM1)
196 l.goalentity.iscpneighbor_red = TRUE;
197 else if(l.enemy.team == COLOR_TEAM2)
198 l.goalentity.iscpneighbor_blue = TRUE;
203 // now update the takedamage and alpha variables on generator shields
204 l = findchain(classname, "onslaught_generator");
209 dprint(etos(l), " (generator) is shielded\n");
211 l.takedamage = DAMAGE_NO;
212 l.bot_attack = FALSE;
216 dprint(etos(l), " (generator) is not shielded\n");
218 l.takedamage = DAMAGE_AIM;
223 // now update the takedamage and alpha variables on control point icons
224 l = findchain(classname, "onslaught_controlpoint");
229 dprint(etos(l), " (point) is shielded\n");
233 l.goalentity.takedamage = DAMAGE_NO;
234 l.goalentity.bot_attack = FALSE;
239 dprint(etos(l), " (point) is not shielded\n");
243 l.goalentity.takedamage = DAMAGE_AIM;
244 l.goalentity.bot_attack = TRUE;
247 onslaught_controlpoint_updatesprite(l);
250 // count generators owned by each team
251 t1 = t2 = t3 = t4 = 0;
252 l = findchain(classname, "onslaught_generator");
257 if (l.team == COLOR_TEAM1) t1 = 1;
258 if (l.team == COLOR_TEAM2) t2 = 1;
259 if (l.team == COLOR_TEAM3) t3 = 1;
260 if (l.team == COLOR_TEAM4) t4 = 1;
262 onslaught_generator_updatesprite(l);
265 // see if multiple teams remain (if not, it's game over)
266 if (t1 + t2 + t3 + t4 < 2)
267 dprint("--- game over ---\n");
269 dprint("--- done updating links ---\n");
272 float onslaught_controlpoint_can_be_linked(entity cp, float t)
276 if(cp.isgenneighbor_red)
278 if(cp.iscpneighbor_red)
281 else if(t == COLOR_TEAM2)
283 if(cp.isgenneighbor_blue)
285 if(cp.iscpneighbor_blue)
291 // check to see if this player has a legitimate claim to capture this
292 // control point - more specifically that there is a captured path of
293 // points leading back to the team generator
294 e = findchain(classname, "onslaught_link");
297 if (e.goalentity == cp)
299 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
300 if (e.enemy.islinked)
302 dprint(" which is linked");
303 if (e.enemy.team == t)
305 dprint(" and has the correct team!\n");
309 dprint(" but has the wrong team\n");
314 else if (e.enemy == cp)
316 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
317 if (e.goalentity.islinked)
319 dprint(" which is linked");
320 if (e.goalentity.team == t)
322 dprint(" and has a team!\n");
326 dprint(" but has the wrong team\n");
337 float onslaught_controlpoint_attackable(entity cp, float t)
338 // -2: SAME TEAM, attackable by enemy!
343 // 3: attack it (HIGH PRIO)
344 // 4: touch it (HIGH PRIO)
352 else if(cp.goalentity)
354 // if there's already an icon built, nothing happens
357 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
358 if(a) // attackable by enemy?
359 return -2; // EMERGENCY!
362 // we know it can be linked, so no need to check
364 a = onslaught_controlpoint_can_be_linked(cp, t);
365 if(a == 2) // near our generator?
366 return 3; // EMERGENCY!
372 if(onslaught_controlpoint_can_be_linked(cp, t))
374 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
376 return 4; // GET THIS ONE NOW!
378 return 2; // TOUCH ME
384 float overtime_msg_time;
385 void onslaught_generator_think()
389 self.nextthink = ceil(time + 1);
392 if (autocvar_timelimit && time > game_starttime + autocvar_timelimit * 60)
394 if (!overtime_msg_time)
397 centerprint(e, "^3Now playing ^1OVERTIME^3!\n^3Generators start now to decay.\n^3The more control points your team holds,\n^3the faster the enemy generator decays.");
398 overtime_msg_time = time;
400 // self.max_health / 300 gives 5 minutes of overtime.
401 // control points reduce the overtime duration.
402 sound(self, CH_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTN_NORM);
404 e = findchain(classname, "onslaught_controlpoint");
407 if (e.team != self.team)
413 if(autocvar_g_campaign && autocvar__campaign_testrun)
414 d = d * self.max_health;
416 d = d * self.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
418 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
420 else if (overtime_msg_time)
421 overtime_msg_time = 0;
423 if(!self.isshielded && self.wait < time)
425 self.wait = time + 5;
428 if(e.team == self.team)
430 centerprint(e, "^1Your generator is NOT shielded!\n^7Re-capture controlpoints to shield it!");
431 soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTN_NONE); // FIXME: Uniqe sound?
438 void onslaught_generator_ring_spawn(vector org)
440 modeleffect_spawn("models/onslaught/shockwavetransring.md3", 0, 0, org, '0 0 0', '0 0 0', '0 0 0', 0, -16, 0.1, 1.25, 0.25);
443 void onslaught_generator_ray_think()
445 self.nextthink = time + 0.05;
448 self.think = SUB_Remove;
461 void onslaught_generator_ray_spawn(vector org)
465 setmodel(e, "models/onslaught/ons_ray.md3");
467 e.angles = randomvec() * 360;
469 e.scale = random() * 5 + 8;
470 e.think = onslaught_generator_ray_think;
471 e.nextthink = time + 0.05;
474 void onslaught_generator_shockwave_spawn(vector org)
476 shockwave_spawn("models/onslaught/shockwave.md3", org, -64, 0.75, 0.5);
479 void onslaught_generator_damage_think()
481 if(self.owner.health < 0)
483 self.think = SUB_Remove;
486 self.nextthink = time+0.1;
488 // damaged fx (less probable the more damaged is the generator)
489 if(random() < 0.9 - self.owner.health / self.owner.max_health)
492 pointparticles(particleeffectnum("electro_ballexplode"), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
493 sound(self, CH_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM);
496 pointparticles(particleeffectnum("torch_small"), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
499 void onslaught_generator_damage_spawn(entity gd_owner)
504 e.health = self.owner.health;
505 setorigin(e, gd_owner.origin);
506 e.think = onslaught_generator_damage_think;
507 e.nextthink = time+1;
510 void onslaught_generator_deaththink()
519 if(self.count==40||self.count==20)
521 onslaught_generator_ring_spawn(self.origin);
522 sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTN_NORM);
530 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 6, TRUE);
532 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 6, TRUE);
534 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 6, TRUE);
540 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
541 pointparticles(particleeffectnum("onslaught_generator_gib_explode"), org, '0 0 0', 1);
544 // Short explosion sound + small explosion
547 te_explosion(self.origin);
548 sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
552 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
553 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
558 onslaught_generator_ray_spawn(self.origin);
566 onslaught_generator_shockwave_spawn(org);
567 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
568 sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
571 self.nextthink = time + 0.05;
573 self.count = self.count - 1;
576 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
583 if (attacker != self)
587 // this is protected by a shield, so ignore the damage
588 if (time > self.pain_finished)
589 if (attacker.classname == "player")
591 play2(attacker, "onslaught/damageblockedbyshield.wav");
592 self.pain_finished = time + 1;
596 if (time > self.pain_finished)
598 self.pain_finished = time + 10;
599 bprint(ColoredTeamName(self.team), " generator under attack!\n");
600 play2team(self.team, "onslaught/generator_underattack.wav");
603 self.health = self.health - damage;
604 WaypointSprite_UpdateHealth(self.sprite, self.health);
605 // choose an animation frame based on health
606 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
607 // see if the generator is still functional, or dying
610 #ifdef ONSLAUGHT_SPAM
612 lh = ceil(self.lasthealth / 100) * 100;
613 h = ceil(self.health / 100) * 100;
615 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
617 self.lasthealth = self.health;
619 else if not(inWarmupStage)
621 if (attacker == self)
622 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
626 t = ColoredTeamName(attacker.team);
627 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
629 self.iscaptured = FALSE;
630 self.islinked = FALSE;
631 self.isshielded = FALSE;
632 self.takedamage = DAMAGE_NO; // can't be hurt anymore
633 self.event_damage = func_null; // won't do anything if hurt
634 self.count = 0; // reset counter
635 self.think = onslaught_generator_deaththink; // explosion sequence
636 self.nextthink = time; // start exploding immediately
637 self.think(); // do the first explosion now
639 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
641 onslaught_updatelinks();
645 setmodel(self, "models/onslaught/generator_dead.md3");
646 else if(self.health < self.max_health * 0.10)
647 setmodel(self, "models/onslaught/generator_dmg9.md3");
648 else if(self.health < self.max_health * 0.20)
649 setmodel(self, "models/onslaught/generator_dmg8.md3");
650 else if(self.health < self.max_health * 0.30)
651 setmodel(self, "models/onslaught/generator_dmg7.md3");
652 else if(self.health < self.max_health * 0.40)
653 setmodel(self, "models/onslaught/generator_dmg6.md3");
654 else if(self.health < self.max_health * 0.50)
655 setmodel(self, "models/onslaught/generator_dmg5.md3");
656 else if(self.health < self.max_health * 0.60)
657 setmodel(self, "models/onslaught/generator_dmg4.md3");
658 else if(self.health < self.max_health * 0.70)
659 setmodel(self, "models/onslaught/generator_dmg3.md3");
660 else if(self.health < self.max_health * 0.80)
661 setmodel(self, "models/onslaught/generator_dmg2.md3");
662 else if(self.health < self.max_health * 0.90)
663 setmodel(self, "models/onslaught/generator_dmg1.md3");
664 setsize(self, '-52 -52 -14', '52 52 75');
666 // Throw some flaming gibs on damage, more damage = more chance for gib
667 if(random() < damage/220)
669 sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
672 ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib1.md3", 5, TRUE);
674 ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib2.md3", 5, TRUE);
676 ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib3.md3", 5, TRUE);
680 // particles on every hit
681 pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
685 sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTN_NORM);
687 sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM);
690 //throw some gibs on damage
691 if(random() < damage/200+0.2)
693 ons_throwgib(hitloc + '0 0 20', randomvec()*360, "models/onslaught/gen_gib1.md3", 5, FALSE);
696 // update links after a delay
697 void onslaught_generator_delayed()
699 onslaught_updatelinks();
700 // now begin normal thinking
701 self.think = onslaught_generator_think;
702 self.nextthink = time;
705 string onslaught_generator_waypointsprite_for_team(entity e, float t)
709 if(e.team == COLOR_TEAM1)
710 return "ons-gen-red";
711 else if(e.team == COLOR_TEAM2)
712 return "ons-gen-blue";
715 return "ons-gen-shielded";
716 if(e.team == COLOR_TEAM1)
717 return "ons-gen-red";
718 else if(e.team == COLOR_TEAM2)
719 return "ons-gen-blue";
723 void onslaught_generator_updatesprite(entity e)
726 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
727 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
728 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
729 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
731 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
733 e.lastteam = e.team + 2;
734 e.lastshielded = e.isshielded;
737 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
738 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
740 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
744 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
745 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, FALSE));
747 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
749 WaypointSprite_Ping(e.sprite);
753 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
758 a = onslaught_controlpoint_attackable(e, t);
759 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
761 if(e.team == COLOR_TEAM1)
762 return "ons-cp-atck-red";
763 else if(e.team == COLOR_TEAM2)
764 return "ons-cp-atck-blue";
766 return "ons-cp-atck-neut";
768 else if(a == -2) // DEFEND THIS ONE NOW
770 if(e.team == COLOR_TEAM1)
771 return "ons-cp-dfnd-red";
772 else if(e.team == COLOR_TEAM2)
773 return "ons-cp-dfnd-blue";
775 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
777 if(e.team == COLOR_TEAM1)
779 else if(e.team == COLOR_TEAM2)
780 return "ons-cp-blue";
782 else if(a == 2) // touch it
783 return "ons-cp-neut";
787 if(e.team == COLOR_TEAM1)
789 else if(e.team == COLOR_TEAM2)
790 return "ons-cp-blue";
792 return "ons-cp-neut";
797 void onslaught_controlpoint_updatesprite(entity e)
800 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
801 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
802 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
803 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
806 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
808 if(e.lastteam != e.team + 2 || e.lastshielded != sh || e.iscaptured != e.lastcaptured)
810 if(e.iscaptured) // don't mess up build bars!
814 WaypointSprite_UpdateMaxHealth(e.sprite, 0);
818 WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
819 WaypointSprite_UpdateHealth(e.sprite, e.goalentity.health);
824 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
825 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
827 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
831 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
832 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, FALSE));
834 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
836 WaypointSprite_Ping(e.sprite);
838 e.lastteam = e.team + 2;
840 e.lastcaptured = e.iscaptured;
844 void onslaught_generator_reset()
846 self.team = self.team_saved;
847 self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
848 self.takedamage = DAMAGE_AIM;
849 self.bot_attack = TRUE;
850 self.iscaptured = TRUE;
851 self.islinked = TRUE;
852 self.isshielded = TRUE;
853 self.enemy.solid = SOLID_NOT;
854 self.think = onslaught_generator_delayed;
855 self.nextthink = time + 0.2;
856 setmodel(self, "models/onslaught/generator.md3");
857 setsize(self, '-52 -52 -14', '52 52 75');
862 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
863 WaypointSprite_UpdateHealth(self.sprite, self.health);
866 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
869 spawnfunc_onslaught_link entities can target this.
872 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
873 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
875 void spawnfunc_onslaught_generator()
884 precache_model("models/onslaught/generator.md3");
885 precache_model("models/onslaught/generator_shield.md3");
886 precache_model("models/onslaught/generator_dmg1.md3");
887 precache_model("models/onslaught/generator_dmg2.md3");
888 precache_model("models/onslaught/generator_dmg3.md3");
889 precache_model("models/onslaught/generator_dmg4.md3");
890 precache_model("models/onslaught/generator_dmg5.md3");
891 precache_model("models/onslaught/generator_dmg6.md3");
892 precache_model("models/onslaught/generator_dmg7.md3");
893 precache_model("models/onslaught/generator_dmg8.md3");
894 precache_model("models/onslaught/generator_dmg9.md3");
895 precache_model("models/onslaught/generator_dead.md3");
896 precache_model("models/onslaught/shockwave.md3");
897 precache_model("models/onslaught/shockwavetransring.md3");
898 precache_model("models/onslaught/gen_gib1.md3");
899 precache_model("models/onslaught/gen_gib2.md3");
900 precache_model("models/onslaught/gen_gib3.md3");
901 precache_model("models/onslaught/ons_ray.md3");
902 precache_sound("onslaught/generator_decay.wav");
903 precache_sound("weapons/grenade_impact.wav");
904 precache_sound("weapons/rocket_impact.wav");
905 precache_sound("onslaught/generator_underattack.wav");
906 precache_sound("onslaught/shockwave.wav");
907 precache_sound("onslaught/ons_hit1.wav");
908 precache_sound("onslaught/ons_hit2.wav");
909 precache_sound("onslaught/electricity_explode.wav");
911 objerror("team must be set");
913 if(self.team == COLOR_TEAM1)
914 ons_red_generator = self;
916 if(self.team == COLOR_TEAM2)
917 ons_blue_generator = self;
919 self.team_saved = self.team;
920 self.colormap = 1024 + (self.team - 1) * 17;
921 self.solid = SOLID_BBOX;
922 self.movetype = MOVETYPE_NONE;
923 self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
924 setmodel(self, "models/onslaught/generator.md3");
925 setsize(self, '-52 -52 -14', '52 52 75');
926 setorigin(self, self.origin);
927 self.takedamage = DAMAGE_AIM;
928 self.bot_attack = TRUE;
929 self.event_damage = onslaught_generator_damage;
930 self.iscaptured = TRUE;
931 self.islinked = TRUE;
932 self.isshielded = TRUE;
933 // helper entity that create fx when generator is damaged
934 onslaught_generator_damage_spawn(self);
935 // spawn shield model which indicates whether this can be damaged
936 self.enemy = spawn();
937 setattachment(self.enemy , self, "");
938 self.enemy.classname = "onslaught_generator_shield";
939 self.enemy.solid = SOLID_NOT;
940 self.enemy.movetype = MOVETYPE_NONE;
941 self.enemy.effects = EF_ADDITIVE;
942 setmodel(self.enemy, "models/onslaught/generator_shield.md3");
943 //setorigin(e, self.origin);
944 self.enemy.colormap = self.colormap;
945 self.enemy.team = self.team;
946 //self.think = onslaught_generator_delayed;
947 //self.nextthink = time + 0.2;
948 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
950 WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
951 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
952 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
953 WaypointSprite_UpdateHealth(self.sprite, self.health);
955 waypoint_spawnforitem(self);
957 onslaught_updatelinks();
959 self.reset = onslaught_generator_reset;
964 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
966 float ons_notification_time_team1;
967 float ons_notification_time_team2;
969 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
976 if (self.owner.isshielded)
978 // this is protected by a shield, so ignore the damage
979 if (time > self.pain_finished)
980 if (attacker.classname == "player")
982 play2(attacker, "onslaught/damageblockedbyshield.wav");
983 self.pain_finished = time + 1;
988 if (attacker.classname == "player")
991 if(self.team == COLOR_TEAM1)
993 if(time - ons_notification_time_team1 > 10)
996 ons_notification_time_team1 = time;
999 else if(self.team == COLOR_TEAM2)
1001 if(time - ons_notification_time_team2 > 10)
1004 ons_notification_time_team2 = time;
1011 play2team(self.team, "onslaught/controlpoint_underattack.wav");
1014 self.health = self.health - damage;
1015 if(self.owner.iscaptured)
1016 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1018 WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / sys_frametime));
1019 self.pain_finished = time + 1;
1020 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
1021 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
1022 // colormod flash when shot
1023 self.colormod = '2 2 2';
1024 // particles on every hit
1025 pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
1026 //sound on every hit
1028 sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTN_NORM);
1030 sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTN_NORM);
1032 if (self.health < 0)
1034 sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
1035 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
1038 t = ColoredTeamName(attacker.team);
1039 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
1040 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 3, FALSE);
1041 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, FALSE);
1042 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, FALSE);
1043 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
1044 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
1045 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
1046 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
1048 self.owner.goalentity = world;
1049 self.owner.islinked = FALSE;
1050 self.owner.iscaptured = FALSE;
1051 self.owner.team = 0;
1052 self.owner.colormap = 1024;
1054 WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
1056 onslaught_updatelinks();
1058 // Use targets now (somebody make sure this is in the right place..)
1066 self.owner.waslinked = self.owner.islinked;
1067 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
1068 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
1069 //setsize(self, '-32 -32 0', '32 32 8');
1075 void onslaught_controlpoint_icon_think()
1078 self.nextthink = time + sys_frametime;
1080 if(autocvar_g_onslaught_controlpoints_proxycap)
1082 float _enemy_count = 0;
1083 float _friendly_count = 0;
1087 FOR_EACH_PLAYER(_player)
1089 if(!_player.deadflag)
1091 _dist = vlen(_player.origin - self.origin);
1092 if(_dist < autocvar_g_onslaught_controlpoints_proxycap_distance)
1094 if(_player.team == self.team)
1102 _friendly_count = _friendly_count * (autocvar_g_onslaught_controlpoints_proxycap_dps * sys_frametime);
1103 _enemy_count = _enemy_count * (autocvar_g_onslaught_controlpoints_proxycap_dps * sys_frametime);
1105 self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
1106 if(self.health <= 0)
1108 onslaught_controlpoint_icon_damage(self, self, 1, 0, self.origin, '0 0 0');
1113 if (time > self.pain_finished + 5)
1115 if(self.health < self.max_health)
1117 self.health = self.health + self.count;
1118 if (self.health >= self.max_health)
1119 self.health = self.max_health;
1120 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1123 if (self.health < self.max_health * 0.25)
1124 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
1125 else if (self.health < self.max_health * 0.50)
1126 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
1127 else if (self.health < self.max_health * 0.75)
1128 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
1129 else if (self.health < self.max_health * 0.90)
1130 setmodel(self, "models/onslaught/controlpoint_icon.md3");
1131 // colormod flash when shot
1132 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1134 if(self.owner.islinked != self.owner.waslinked)
1136 // unteam the spawnpoint if needed
1138 t = self.owner.team;
1139 if(!self.owner.islinked)
1140 self.owner.team = 0;
1148 self.owner.team = t;
1150 self.owner.waslinked = self.owner.islinked;
1153 if (self.punchangle_x > 0)
1155 self.punchangle_x = self.punchangle_x - 60 * sys_frametime;
1156 if (self.punchangle_x < 0)
1157 self.punchangle_x = 0;
1159 else if (self.punchangle_x < 0)
1161 self.punchangle_x = self.punchangle_x + 60 * sys_frametime;
1162 if (self.punchangle_x > 0)
1163 self.punchangle_x = 0;
1166 if (self.punchangle_y > 0)
1168 self.punchangle_y = self.punchangle_y - 60 * sys_frametime;
1169 if (self.punchangle_y < 0)
1170 self.punchangle_y = 0;
1172 else if (self.punchangle_y < 0)
1174 self.punchangle_y = self.punchangle_y + 60 * sys_frametime;
1175 if (self.punchangle_y > 0)
1176 self.punchangle_y = 0;
1179 if (self.punchangle_z > 0)
1181 self.punchangle_z = self.punchangle_z - 60 * sys_frametime;
1182 if (self.punchangle_z < 0)
1183 self.punchangle_z = 0;
1185 else if (self.punchangle_z < 0)
1187 self.punchangle_z = self.punchangle_z + 60 * sys_frametime;
1188 if (self.punchangle_z > 0)
1189 self.punchangle_z = 0;
1192 self.angles_x = self.punchangle_x;
1193 self.angles_y = self.punchangle_y + self.mangle_y;
1194 self.angles_z = self.punchangle_z;
1195 self.mangle_y = self.mangle_y + 45 * sys_frametime;
1197 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd));
1198 self.cp_bob_spd = self.cp_bob_spd + 1.875 * sys_frametime;
1199 if(self.cp_bob_dmg_z > 0)
1200 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 3 * sys_frametime;
1202 self.cp_bob_dmg_z = 0;
1203 setorigin(self,self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg);
1206 if(random() < 0.6 - self.health / self.max_health)
1208 pointparticles(particleeffectnum("electricity_sparks"), self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
1211 sound(self, CH_PAIN, "onslaught/ons_spark1.wav", VOL_BASE, ATTN_NORM);
1212 else if (random() > 0.5)
1213 sound(self, CH_PAIN, "onslaught/ons_spark2.wav", VOL_BASE, ATTN_NORM);
1217 void onslaught_controlpoint_icon_buildthink()
1222 self.nextthink = time + sys_frametime;
1224 // only do this if there is power
1225 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
1229 self.health = self.health + self.count;
1231 if (self.health >= self.max_health)
1233 self.health = self.max_health;
1234 self.count = autocvar_g_onslaught_cp_regen * sys_frametime; // slow repair rate from now on
1235 self.think = onslaught_controlpoint_icon_think;
1236 sound(self, CH_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
1237 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
1238 self.owner.iscaptured = TRUE;
1240 WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
1241 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1243 onslaught_updatelinks();
1245 // Use targets now (somebody make sure this is in the right place..)
1251 self.cp_origin = self.origin;
1252 self.cp_bob_origin = '0 0 0.1';
1253 self.cp_bob_spd = 0;
1255 self.alpha = self.health / self.max_health;
1256 // colormod flash when shot
1257 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1258 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
1259 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
1260 //setsize(self, '-32 -32 0', '32 32 8');
1262 if(random() < 0.9 - self.health / self.max_health)
1263 pointparticles(particleeffectnum("rage"), self.origin + 10 * randomvec(), '0 0 -1', 1);
1269 void onslaught_controlpoint_touch()
1273 if (other.classname != "player")
1275 a = onslaught_controlpoint_attackable(self, other.team);
1276 if(a != 2 && a != 4)
1278 // we've verified that this player has a legitimate claim to this point,
1279 // so start building the captured point icon (which only captures this
1280 // point if it successfully builds without being destroyed first)
1281 self.goalentity = e = spawn();
1282 e.classname = "onslaught_controlpoint_icon";
1284 e.max_health = autocvar_g_onslaught_cp_health;
1285 e.health = autocvar_g_onslaught_cp_buildhealth;
1286 e.solid = SOLID_BBOX;
1287 e.movetype = MOVETYPE_NONE;
1288 setmodel(e, "models/onslaught/controlpoint_icon.md3");
1289 setsize(e, '-32 -32 -32', '32 32 32');
1290 setorigin(e, self.origin + '0 0 96');
1291 e.takedamage = DAMAGE_AIM;
1292 e.bot_attack = TRUE;
1293 e.event_damage = onslaught_controlpoint_icon_damage;
1294 e.team = other.team;
1295 e.colormap = 1024 + (e.team - 1) * 17;
1296 e.think = onslaught_controlpoint_icon_buildthink;
1297 e.nextthink = time + sys_frametime;
1298 e.count = (e.max_health - e.health) * sys_frametime / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
1299 sound(e, CH_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
1301 self.colormap = e.colormap;
1302 WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / sys_frametime));
1303 onslaught_updatelinks();
1306 void onslaught_controlpoint_reset()
1308 if(self.goalentity && self.goalentity != world)
1309 remove(self.goalentity);
1310 self.goalentity = world;
1312 self.colormap = 1024;
1313 self.iscaptured = FALSE;
1314 self.islinked = FALSE;
1315 self.isshielded = TRUE;
1316 self.enemy.solid = SOLID_NOT;
1317 self.enemy.colormap = self.colormap;
1318 self.think = self.enemy.think = func_null;
1319 self.nextthink = 0; // don't like func_null :P
1320 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1321 //setsize(self, '-32 -32 0', '32 32 8');
1323 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
1325 onslaught_updatelinks();
1328 SUB_UseTargets(); // to reset the structures, playerspawns etc.
1331 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
1332 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
1334 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
1337 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
1338 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
1339 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
1343 void onslaught_controlpoint_think()
1345 self.nextthink = time;
1346 //if(autocvar_g_onslaught_controlpoints_proxycap)
1349 float _friendly_count;
1353 FOR_EACH_PLAYER(_player)
1355 if(!_player.deadflag)
1357 _dist = vlen(_player.origin - self.origin);
1358 if(_dist < autocvar_g_onslaught_controlpoints_proxycap_distance)
1360 if(_player.team == self.team)
1368 _friendly_count = _friendly_count * (autocvar_g_onslaught_controlpoints_proxycap_dps * sys_frametime);
1369 _enemy_count = _enemy_count * (autocvar_g_onslaught_controlpoints_proxycap_dps * sys_frametime);
1371 self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
1372 if(self.health <= 0)
1374 onslaught_controlpoint_icon_damage(self, self, 1, 0, self.origin, '0 0 0');
1378 if(self.health == max_health)
1385 void spawnfunc_onslaught_controlpoint()
1393 precache_model("models/onslaught/controlpoint_pad.md3");
1394 precache_model("models/onslaught/controlpoint_pad2.md3");
1395 precache_model("models/onslaught/controlpoint_shield.md3");
1396 precache_model("models/onslaught/controlpoint_icon.md3");
1397 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
1398 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
1399 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
1400 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
1401 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
1402 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
1403 precache_sound("onslaught/controlpoint_build.wav");
1404 precache_sound("onslaught/controlpoint_built.wav");
1405 precache_sound("weapons/grenade_impact.wav");
1406 precache_sound("onslaught/damageblockedbyshield.wav");
1407 precache_sound("onslaught/controlpoint_underattack.wav");
1408 precache_sound("onslaught/ons_spark1.wav");
1409 precache_sound("onslaught/ons_spark2.wav");
1410 self.solid = SOLID_BBOX;
1411 self.movetype = MOVETYPE_NONE;
1412 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1413 //setsize(self, '-32 -32 0', '32 32 8');
1417 setorigin(self, self.origin);
1418 self.touch = onslaught_controlpoint_touch;
1420 self.colormap = 1024;
1421 self.iscaptured = FALSE;
1422 self.islinked = FALSE;
1423 self.isshielded = TRUE;
1424 // spawn shield model which indicates whether this can be damaged
1425 self.enemy = spawn();
1426 self.enemy.classname = "onslaught_controlpoint_shield";
1427 self.enemy.solid = SOLID_NOT;
1428 self.enemy.movetype = MOVETYPE_NONE;
1429 self.enemy.effects = EF_ADDITIVE;
1430 setmodel(self.enemy , "models/onslaught/controlpoint_shield.md3");
1432 setattachment(self.enemy , self, "");
1433 //setsize(e, '-32 -32 0', '32 32 128');
1435 //setorigin(e, self.origin);
1436 self.enemy.colormap = self.colormap;
1438 waypoint_spawnforitem(self);
1440 WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
1441 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
1443 onslaught_updatelinks();
1445 self.reset = onslaught_controlpoint_reset;
1448 float onslaught_link_send(entity to, float sendflags)
1450 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1451 WriteByte(MSG_ENTITY, sendflags);
1454 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
1455 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
1456 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1460 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1461 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1462 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1466 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1471 void onslaught_link_checkupdate()
1473 // TODO check if the two sides have moved (currently they won't move anyway)
1474 float redpower, bluepower;
1476 redpower = bluepower = 0;
1477 if(self.goalentity.islinked)
1479 if(self.goalentity.team == COLOR_TEAM1)
1481 else if(self.goalentity.team == COLOR_TEAM2)
1484 if(self.enemy.islinked)
1486 if(self.enemy.team == COLOR_TEAM1)
1488 else if(self.enemy.team == COLOR_TEAM2)
1493 if(redpower == 1 && bluepower == 2)
1494 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1495 else if(redpower == 2 && bluepower == 1)
1496 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1498 cc = (COLOR_TEAM1 - 1) * 0x11;
1500 cc = (COLOR_TEAM2 - 1) * 0x11;
1504 //print(etos(self), " rp=", ftos(redpower), " bp=", ftos(bluepower), " ");
1505 //print("cc=", ftos(cc), "\n");
1507 if(cc != self.clientcolors)
1509 self.clientcolors = cc;
1510 self.SendFlags |= 4;
1513 self.nextthink = time;
1516 void onslaught_link_delayed()
1518 self.goalentity = find(world, targetname, self.target);
1519 self.enemy = find(world, targetname, self.target2);
1520 if (!self.goalentity)
1521 objerror("can not find target\n");
1523 objerror("can not find target2\n");
1524 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1525 self.SendFlags |= 3;
1526 self.think = onslaught_link_checkupdate;
1527 self.nextthink = time;
1530 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1531 Link between control points.
1533 This entity targets two different spawnfunc_onslaught_controlpoint or spawnfunc_onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
1536 "target" - first control point.
1537 "target2" - second control point.
1539 void spawnfunc_onslaught_link()
1546 if (self.target == "" || self.target2 == "")
1547 objerror("target and target2 must be set\n");
1548 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1549 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);
1552 MUTATOR_HOOKFUNCTION(ons_BuildMutatorsString)
1554 ret_string = strcat(ret_string, ":ONS");
1558 MUTATOR_HOOKFUNCTION(ons_BuildMutatorsPrettyString)
1560 ret_string = strcat(ret_string, ", Onslught");
1564 MUTATOR_HOOKFUNCTION(ons_Spawn_Score)
1568 float _neer_home = (random() > 0.5 ? TRUE : FALSE);
1570 RandomSelection_Init();
1572 if(self.team == COLOR_TEAM1)
1573 RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1);
1575 if(self.team == COLOR_TEAM2)
1576 RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1);
1578 entity _cp = findchain(classname, "onslaught_controlpoint"):
1581 if(_cp.team == self.team)
1582 RandomSelection_Add(_cp, 0, string_null, 1, 1);
1587 if(RandomSelection_chosen_ent)
1589 self.tur_head = RandomSelection_chosen_ent;
1590 spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_FOUND;
1592 else if(self.team == spawn_spot.team)
1593 spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate
1600 MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
1602 if(!autocvar_g_onslaught_spawn_at_controlpoints)
1605 if(random() < 0.5) // 50/50 chane to use default spawnsystem.
1608 float _close_to_home = ((random() > 0.5) ? TRUE : FALSE);
1609 entity _best = world, _trg_gen = world;
1610 float _score, _best_score = MAX_SHOT_DISTANCE;
1612 RandomSelection_Init();
1614 if(self.team == COLOR_TEAM1)
1617 _trg_gen = ons_blue_generator;
1619 _trg_gen = ons_red_generator;
1622 if(self.team == COLOR_TEAM2)
1625 _trg_gen = ons_blue_generator;
1627 _trg_gen = ons_red_generator;
1630 entity _cp = findchain(classname, "onslaught_controlpoint");
1633 if(_cp.team == self.team)
1635 _score = vlen(_trg_gen.origin - _cp.origin);
1636 if(_score < _best_score)
1639 _best_score = _score;
1649 for(i = 0; i < 10; ++i)
1651 _loc = _best.origin + '0 0 96';
1652 _loc += ('0 1 0' * random()) * 128;
1653 tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
1654 if(trace_fraction == 1.0 && !trace_startsolid)
1656 setorigin(self, _loc);
1657 self.angles = normalize(_loc - _best.origin) * RAD2DEG;
1664 if(!autocvar_g_onslaught_spawn_at_generator)
1667 _trg_gen = ((self.team == COLOR_TEAM1) ? ons_red_generator : ons_blue_generator);
1669 for(i = 0; i < 10; ++i)
1671 _loc = _trg_gen.origin + '0 0 96';
1672 _loc += ('0 1 0' * random()) * 128;
1673 tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
1674 if(trace_fraction == 1.0 && !trace_startsolid)
1676 setorigin(self, _loc);
1677 self.angles = normalize(_loc - _trg_gen.origin) * RAD2DEG;
1686 MUTATOR_DEFINITION(gamemode_onslaught)
1688 //MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
1689 //MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
1690 //MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
1691 //MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
1692 MUTATOR_HOOK(BuildMutatorsPrettyString, ons_BuildMutatorsPrettyString, CBC_ORDER_ANY);
1693 MUTATOR_HOOK(BuildMutatorsString, ons_BuildMutatorsString, CBC_ORDER_ANY);
1694 MUTATOR_HOOK(PlayerSpawn, ons_PlayerSpawn, CBC_ORDER_ANY);
1695 //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY);
1699 if(time > 1) // game loads at time 1
1700 error("This is a game type and it cannot be added at runtime.");
1705 print("This is a game type and it cannot be removed at runtime.");