1 #include "../../common/triggers/subs.qh"
3 float autocvar_g_onslaught_spawn_at_controlpoints;
4 float autocvar_g_onslaught_spawn_at_generator;
5 float autocvar_g_onslaught_cp_proxydecap;
6 float autocvar_g_onslaught_cp_proxydecap_distance = 512;
7 float autocvar_g_onslaught_cp_proxydecap_dps = 100;
9 void onslaught_generator_updatesprite(entity e);
10 void onslaught_controlpoint_updatesprite(entity e);
11 void onslaught_link_checkupdate();
17 .float isgenneighbor_red;
18 .float isgenneighbor_blue;
19 .float iscpneighbor_red;
20 .float iscpneighbor_blue;
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 == NUM_TEAM_1)
167 l.enemy.isgenneighbor_red = true;
168 else if(l.goalentity.team == NUM_TEAM_2)
169 l.enemy.isgenneighbor_blue = true;
173 if(l.goalentity.team == NUM_TEAM_1)
174 l.enemy.iscpneighbor_red = true;
175 else if(l.goalentity.team == NUM_TEAM_2)
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 == NUM_TEAM_1)
189 l.goalentity.isgenneighbor_red = true;
190 else if(l.enemy.team == NUM_TEAM_2)
191 l.goalentity.isgenneighbor_blue = true;
195 if(l.enemy.team == NUM_TEAM_1)
196 l.goalentity.iscpneighbor_red = true;
197 else if(l.enemy.team == NUM_TEAM_2)
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 == NUM_TEAM_1) t1 = 1;
258 if (l.team == NUM_TEAM_2) t2 = 1;
259 if (l.team == NUM_TEAM_3) t3 = 1;
260 if (l.team == NUM_TEAM_4) 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 == NUM_TEAM_2)
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, NUM_TEAM_1 + NUM_TEAM_2 - 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, NUM_TEAM_1 + NUM_TEAM_2 - 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)
396 Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT);
397 overtime_msg_time = time;
399 // self.max_health / 300 gives 5 minutes of overtime.
400 // control points reduce the overtime duration.
401 sound(self, CH_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTEN_NORM);
403 e = findchain(classname, "onslaught_controlpoint");
406 if (e.team != self.team)
412 if(autocvar_g_campaign && autocvar__campaign_testrun)
413 d = d * self.max_health;
415 d = d * self.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
417 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
419 else if (overtime_msg_time)
420 overtime_msg_time = 0;
422 if(!self.isshielded && self.wait < time)
424 self.wait = time + 5;
425 FOR_EACH_REALPLAYER(e)
427 if(SAME_TEAM(e, self))
429 Send_Notification(NOTIF_ONE, e, MSG_CENTER, CENTER_ONS_NOTSHIELDED);
430 soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTEN_NONE); // FIXME: Uniqe sound?
437 void onslaught_generator_ring_spawn(vector org)
439 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);
442 void onslaught_generator_ray_think()
444 self.nextthink = time + 0.05;
447 self.think = SUB_Remove;
460 void onslaught_generator_ray_spawn(vector org)
464 setmodel(e, "models/onslaught/ons_ray.md3");
466 e.angles = randomvec() * 360;
468 e.scale = random() * 5 + 8;
469 e.think = onslaught_generator_ray_think;
470 e.nextthink = time + 0.05;
473 void onslaught_generator_shockwave_spawn(vector org)
475 shockwave_spawn("models/onslaught/shockwave.md3", org, -64, 0.75, 0.5);
478 void onslaught_generator_damage_think()
480 if(self.owner.health < 0)
482 self.think = SUB_Remove;
485 self.nextthink = time+0.1;
487 // damaged fx (less probable the more damaged is the generator)
488 if(random() < 0.9 - self.owner.health / self.owner.max_health)
491 pointparticles(particleeffectnum("electro_ballexplode"), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
492 sound(self, CH_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);
495 pointparticles(particleeffectnum("torch_small"), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
498 void onslaught_generator_damage_spawn(entity gd_owner)
503 e.health = self.owner.health;
504 setorigin(e, gd_owner.origin);
505 e.think = onslaught_generator_damage_think;
506 e.nextthink = time+1;
509 void onslaught_generator_deaththink()
518 if(self.count==40||self.count==20)
520 onslaught_generator_ring_spawn(self.origin);
521 sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTEN_NORM);
529 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 6, true);
531 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 6, true);
533 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 6, true);
539 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
540 pointparticles(particleeffectnum("onslaught_generator_gib_explode"), org, '0 0 0', 1);
543 // Short explosion sound + small explosion
546 te_explosion(self.origin);
547 sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTEN_NORM);
551 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
552 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
557 onslaught_generator_ray_spawn(self.origin);
565 onslaught_generator_shockwave_spawn(org);
566 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
567 sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
570 self.nextthink = time + 0.05;
572 self.count = self.count - 1;
575 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
582 if (attacker != self)
586 // this is protected by a shield, so ignore the damage
587 if (time > self.pain_finished)
588 if (IS_PLAYER(attacker))
590 play2(attacker, "onslaught/damageblockedbyshield.wav");
591 self.pain_finished = time + 1;
595 if (time > self.pain_finished)
597 self.pain_finished = time + 10;
598 bprint(Team_ColoredFullName(self.team), " generator under attack!\n");
599 play2team(self.team, "onslaught/generator_underattack.wav");
602 self.health = self.health - damage;
603 WaypointSprite_UpdateHealth(self.sprite, self.health);
604 // choose an animation frame based on health
605 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
606 // see if the generator is still functional, or dying
609 #ifdef ONSLAUGHT_SPAM
611 lh = ceil(self.lasthealth / 100) * 100;
612 h = ceil(self.health / 100) * 100;
614 bprint(Team_ColoredFullName(self.team), " generator has less than ", ftos(h), " health remaining\n");
616 self.lasthealth = self.health;
618 else if (!warmup_stage)
620 if (attacker == self)
621 bprint(Team_ColoredFullName(self.team), " generator spontaneously exploded due to overtime!\n");
625 t = Team_ColoredFullName(attacker.team);
626 bprint(Team_ColoredFullName(self.team), " generator destroyed by ", t, "!\n");
628 self.iscaptured = false;
629 self.islinked = false;
630 self.isshielded = false;
631 self.takedamage = DAMAGE_NO; // can't be hurt anymore
632 self.event_damage = func_null; // won't do anything if hurt
633 self.count = 0; // reset counter
634 self.think = onslaught_generator_deaththink; // explosion sequence
635 self.nextthink = time; // start exploding immediately
636 self.think(); // do the first explosion now
638 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
640 onslaught_updatelinks();
644 setmodel(self, "models/onslaught/generator_dead.md3");
645 else if(self.health < self.max_health * 0.10)
646 setmodel(self, "models/onslaught/generator_dmg9.md3");
647 else if(self.health < self.max_health * 0.20)
648 setmodel(self, "models/onslaught/generator_dmg8.md3");
649 else if(self.health < self.max_health * 0.30)
650 setmodel(self, "models/onslaught/generator_dmg7.md3");
651 else if(self.health < self.max_health * 0.40)
652 setmodel(self, "models/onslaught/generator_dmg6.md3");
653 else if(self.health < self.max_health * 0.50)
654 setmodel(self, "models/onslaught/generator_dmg5.md3");
655 else if(self.health < self.max_health * 0.60)
656 setmodel(self, "models/onslaught/generator_dmg4.md3");
657 else if(self.health < self.max_health * 0.70)
658 setmodel(self, "models/onslaught/generator_dmg3.md3");
659 else if(self.health < self.max_health * 0.80)
660 setmodel(self, "models/onslaught/generator_dmg2.md3");
661 else if(self.health < self.max_health * 0.90)
662 setmodel(self, "models/onslaught/generator_dmg1.md3");
663 setsize(self, '-52 -52 -14', '52 52 75');
665 // Throw some flaming gibs on damage, more damage = more chance for gib
666 if(random() < damage/220)
668 sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
671 ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib1.md3", 5, true);
673 ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib2.md3", 5, true);
675 ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib3.md3", 5, true);
679 // particles on every hit
680 pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
684 sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTEN_NORM);
686 sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);
689 //throw some gibs on damage
690 if(random() < damage/200+0.2)
692 ons_throwgib(hitloc + '0 0 20', randomvec()*360, "models/onslaught/gen_gib1.md3", 5, false);
695 // update links after a delay
696 void onslaught_generator_delayed()
698 onslaught_updatelinks();
699 // now begin normal thinking
700 self.think = onslaught_generator_think;
701 self.nextthink = time;
704 string onslaught_generator_waypointsprite_for_team(entity e, float t)
708 if(e.team == NUM_TEAM_1)
709 return "ons-gen-red";
710 else if(e.team == NUM_TEAM_2)
711 return "ons-gen-blue";
714 return "ons-gen-shielded";
715 if(e.team == NUM_TEAM_1)
716 return "ons-gen-red";
717 else if(e.team == NUM_TEAM_2)
718 return "ons-gen-blue";
722 void onslaught_generator_updatesprite(entity e)
725 s1 = onslaught_generator_waypointsprite_for_team(e, NUM_TEAM_1);
726 s2 = onslaught_generator_waypointsprite_for_team(e, NUM_TEAM_2);
727 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
728 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
730 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
732 e.lastteam = e.team + 2;
733 e.lastshielded = e.isshielded;
736 if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2)
737 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, false));
739 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
743 if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2)
744 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, false));
746 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
748 WaypointSprite_Ping(e.sprite);
752 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
757 a = onslaught_controlpoint_attackable(e, t);
758 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
760 if(e.team == NUM_TEAM_1)
761 return "ons-cp-atck-red";
762 else if(e.team == NUM_TEAM_2)
763 return "ons-cp-atck-blue";
765 return "ons-cp-atck-neut";
767 else if(a == -2) // DEFEND THIS ONE NOW
769 if(e.team == NUM_TEAM_1)
770 return "ons-cp-dfnd-red";
771 else if(e.team == NUM_TEAM_2)
772 return "ons-cp-dfnd-blue";
774 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
776 if(e.team == NUM_TEAM_1)
778 else if(e.team == NUM_TEAM_2)
779 return "ons-cp-blue";
781 else if(a == 2) // touch it
782 return "ons-cp-neut";
786 if(e.team == NUM_TEAM_1)
788 else if(e.team == NUM_TEAM_2)
789 return "ons-cp-blue";
791 return "ons-cp-neut";
796 void onslaught_controlpoint_updatesprite(entity e)
799 s1 = onslaught_controlpoint_waypointsprite_for_team(e, NUM_TEAM_1);
800 s2 = onslaught_controlpoint_waypointsprite_for_team(e, NUM_TEAM_2);
801 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
802 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
805 sh = !(onslaught_controlpoint_can_be_linked(e, NUM_TEAM_1) || onslaught_controlpoint_can_be_linked(e, NUM_TEAM_2));
807 if(e.lastteam != e.team + 2 || e.lastshielded != sh || e.iscaptured != e.lastcaptured)
809 if(e.iscaptured) // don't mess up build bars!
813 WaypointSprite_UpdateMaxHealth(e.sprite, 0);
817 WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
818 WaypointSprite_UpdateHealth(e.sprite, e.goalentity.health);
823 if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2)
824 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, false));
826 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
830 if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2)
831 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, false));
833 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
835 WaypointSprite_Ping(e.sprite);
837 e.lastteam = e.team + 2;
839 e.lastcaptured = e.iscaptured;
843 void onslaught_generator_reset()
845 self.team = self.team_saved;
846 self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
847 self.takedamage = DAMAGE_AIM;
848 self.bot_attack = true;
849 self.iscaptured = true;
850 self.islinked = true;
851 self.isshielded = true;
852 self.enemy.solid = SOLID_NOT;
853 self.think = onslaught_generator_delayed;
854 self.nextthink = time + 0.2;
855 setmodel(self, "models/onslaught/generator.md3");
856 setsize(self, '-52 -52 -14', '52 52 75');
860 setorigin(self, self.origin + '0 0 20');
864 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
865 WaypointSprite_UpdateHealth(self.sprite, self.health);
868 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
871 spawnfunc_onslaught_link entities can target this.
874 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
875 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
877 void spawnfunc_onslaught_generator()
886 precache_model("models/onslaught/generator.md3");
887 precache_model("models/onslaught/generator_shield.md3");
888 precache_model("models/onslaught/generator_dmg1.md3");
889 precache_model("models/onslaught/generator_dmg2.md3");
890 precache_model("models/onslaught/generator_dmg3.md3");
891 precache_model("models/onslaught/generator_dmg4.md3");
892 precache_model("models/onslaught/generator_dmg5.md3");
893 precache_model("models/onslaught/generator_dmg6.md3");
894 precache_model("models/onslaught/generator_dmg7.md3");
895 precache_model("models/onslaught/generator_dmg8.md3");
896 precache_model("models/onslaught/generator_dmg9.md3");
897 precache_model("models/onslaught/generator_dead.md3");
898 precache_model("models/onslaught/shockwave.md3");
899 precache_model("models/onslaught/shockwavetransring.md3");
900 precache_model("models/onslaught/gen_gib1.md3");
901 precache_model("models/onslaught/gen_gib2.md3");
902 precache_model("models/onslaught/gen_gib3.md3");
903 precache_model("models/onslaught/ons_ray.md3");
904 precache_sound("onslaught/generator_decay.wav");
905 precache_sound("weapons/grenade_impact.wav");
906 precache_sound("weapons/rocket_impact.wav");
907 precache_sound("onslaught/generator_underattack.wav");
908 precache_sound("onslaught/shockwave.wav");
909 precache_sound("onslaught/ons_hit1.wav");
910 precache_sound("onslaught/ons_hit2.wav");
911 precache_sound("onslaught/electricity_explode.wav");
913 objerror("team must be set");
915 if(self.team == NUM_TEAM_1)
916 ons_red_generator = self;
918 if(self.team == NUM_TEAM_2)
919 ons_blue_generator = self;
921 self.team_saved = self.team;
922 self.colormap = 1024 + (self.team - 1) * 17;
923 self.solid = SOLID_BBOX;
924 self.movetype = MOVETYPE_NONE;
925 self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
926 setmodel(self, "models/onslaught/generator.md3");
927 setsize(self, '-52 -52 -14', '52 52 75');
928 setorigin(self, self.origin);
929 self.takedamage = DAMAGE_AIM;
930 self.bot_attack = true;
931 self.event_damage = onslaught_generator_damage;
932 self.iscaptured = true;
933 self.islinked = true;
934 self.isshielded = true;
935 // helper entity that create fx when generator is damaged
936 onslaught_generator_damage_spawn(self);
937 // spawn shield model which indicates whether this can be damaged
938 self.enemy = spawn();
939 setattachment(self.enemy , self, "");
940 self.enemy.classname = "onslaught_generator_shield";
941 self.enemy.solid = SOLID_NOT;
942 self.enemy.movetype = MOVETYPE_NONE;
943 self.enemy.effects = EF_ADDITIVE;
944 setmodel(self.enemy, "models/onslaught/generator_shield.md3");
945 //setorigin(e, self.origin);
946 self.enemy.colormap = self.colormap;
947 self.enemy.team = self.team;
948 //self.think = onslaught_generator_delayed;
949 //self.nextthink = time + 0.2;
950 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
952 WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
953 WaypointSprite_UpdateRule(self.sprite, NUM_TEAM_2, SPRITERULE_TEAMPLAY);
954 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
955 WaypointSprite_UpdateHealth(self.sprite, self.health);
957 waypoint_spawnforitem(self);
959 onslaught_updatelinks();
961 self.reset = onslaught_generator_reset;
966 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
968 float ons_notification_time_team1;
969 float ons_notification_time_team2;
971 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
978 if (self.owner.isshielded)
980 // this is protected by a shield, so ignore the damage
981 if (time > self.pain_finished)
982 if (IS_PLAYER(attacker))
984 play2(attacker, "onslaught/damageblockedbyshield.wav");
985 self.pain_finished = time + 1;
990 if (IS_PLAYER(attacker))
993 if(self.team == NUM_TEAM_1)
995 if(time - ons_notification_time_team1 > 10)
998 ons_notification_time_team1 = time;
1001 else if(self.team == NUM_TEAM_2)
1003 if(time - ons_notification_time_team2 > 10)
1006 ons_notification_time_team2 = time;
1013 play2team(self.team, "onslaught/controlpoint_underattack.wav");
1016 self.health = self.health - damage;
1017 if(self.owner.iscaptured)
1018 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1020 WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / sys_frametime));
1021 self.pain_finished = time + 1;
1022 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
1023 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
1024 // colormod flash when shot
1025 self.colormod = '2 2 2';
1026 // particles on every hit
1027 pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
1028 //sound on every hit
1030 sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTEN_NORM);
1032 sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTEN_NORM);
1034 if (self.health < 0)
1036 sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTEN_NORM);
1037 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
1040 t = Team_ColoredFullName(attacker.team);
1041 bprint(Team_ColoredFullName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
1042 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 3, false);
1043 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, false);
1044 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.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);
1047 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, false);
1048 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, false);
1050 self.owner.goalentity = world;
1051 self.owner.islinked = false;
1052 self.owner.iscaptured = false;
1053 self.owner.team = 0;
1054 self.owner.colormap = 1024;
1056 WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
1058 onslaught_updatelinks();
1060 // Use targets now (somebody make sure this is in the right place..)
1068 self.owner.waslinked = self.owner.islinked;
1069 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
1070 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
1071 //setsize(self, '-32 -32 0', '32 32 8');
1077 void onslaught_controlpoint_icon_think()
1080 self.nextthink = time + sys_frametime;
1082 if(autocvar_g_onslaught_cp_proxydecap)
1084 float _enemy_count = 0;
1085 float _friendly_count = 0;
1089 FOR_EACH_PLAYER(_player)
1091 if(!_player.deadflag)
1093 _dist = vlen(_player.origin - self.origin);
1094 if(_dist < autocvar_g_onslaught_cp_proxydecap_distance)
1096 if(_player.team == self.team)
1104 _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * sys_frametime);
1105 _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * sys_frametime);
1107 self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
1108 if(self.health <= 0)
1110 onslaught_controlpoint_icon_damage(self, self, 1, 0, self.origin, '0 0 0');
1115 if (time > self.pain_finished + 5)
1117 if(self.health < self.max_health)
1119 self.health = self.health + self.count;
1120 if (self.health >= self.max_health)
1121 self.health = self.max_health;
1122 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1125 if (self.health < self.max_health * 0.25)
1126 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
1127 else if (self.health < self.max_health * 0.50)
1128 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
1129 else if (self.health < self.max_health * 0.75)
1130 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
1131 else if (self.health < self.max_health * 0.90)
1132 setmodel(self, "models/onslaught/controlpoint_icon.md3");
1133 // colormod flash when shot
1134 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1136 if(self.owner.islinked != self.owner.waslinked)
1138 // unteam the spawnpoint if needed
1140 t = self.owner.team;
1141 if(!self.owner.islinked)
1142 self.owner.team = 0;
1150 self.owner.team = t;
1152 self.owner.waslinked = self.owner.islinked;
1155 if (self.punchangle.x > 0)
1157 self.punchangle_x = self.punchangle.x - 60 * sys_frametime;
1158 if (self.punchangle.x < 0)
1159 self.punchangle_x = 0;
1161 else if (self.punchangle.x < 0)
1163 self.punchangle_x = self.punchangle.x + 60 * sys_frametime;
1164 if (self.punchangle.x > 0)
1165 self.punchangle_x = 0;
1168 if (self.punchangle.y > 0)
1170 self.punchangle_y = self.punchangle.y - 60 * sys_frametime;
1171 if (self.punchangle.y < 0)
1172 self.punchangle_y = 0;
1174 else if (self.punchangle.y < 0)
1176 self.punchangle_y = self.punchangle.y + 60 * sys_frametime;
1177 if (self.punchangle.y > 0)
1178 self.punchangle_y = 0;
1181 if (self.punchangle.z > 0)
1183 self.punchangle_z = self.punchangle.z - 60 * sys_frametime;
1184 if (self.punchangle.z < 0)
1185 self.punchangle_z = 0;
1187 else if (self.punchangle.z < 0)
1189 self.punchangle_z = self.punchangle.z + 60 * sys_frametime;
1190 if (self.punchangle.z > 0)
1191 self.punchangle_z = 0;
1194 self.angles_x = self.punchangle.x;
1195 self.angles_y = self.punchangle.y + self.mangle.y;
1196 self.angles_z = self.punchangle.z;
1197 self.mangle_y = self.mangle.y + 45 * sys_frametime;
1199 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd));
1200 self.cp_bob_spd = self.cp_bob_spd + 1.875 * sys_frametime;
1201 if(self.cp_bob_dmg.z > 0)
1202 self.cp_bob_dmg_z = self.cp_bob_dmg.z - 3 * sys_frametime;
1204 self.cp_bob_dmg_z = 0;
1205 setorigin(self,self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg);
1208 if(random() < 0.6 - self.health / self.max_health)
1210 pointparticles(particleeffectnum("electricity_sparks"), self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
1213 sound(self, CH_PAIN, "onslaught/ons_spark1.wav", VOL_BASE, ATTEN_NORM);
1214 else if (random() > 0.5)
1215 sound(self, CH_PAIN, "onslaught/ons_spark2.wav", VOL_BASE, ATTEN_NORM);
1219 void onslaught_controlpoint_icon_buildthink()
1224 self.nextthink = time + sys_frametime;
1226 // only do this if there is power
1227 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
1231 self.health = self.health + self.count;
1233 if (self.health >= self.max_health)
1235 self.health = self.max_health;
1236 self.count = autocvar_g_onslaught_cp_regen * sys_frametime; // slow repair rate from now on
1237 self.think = onslaught_controlpoint_icon_think;
1238 sound(self, CH_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTEN_NORM);
1239 bprint(Team_ColoredFullName(self.team), " captured ", self.owner.message, " control point\n");
1240 self.owner.iscaptured = true;
1242 WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
1243 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1245 onslaught_updatelinks();
1247 // Use targets now (somebody make sure this is in the right place..)
1253 self.cp_origin = self.origin;
1254 self.cp_bob_origin = '0 0 0.1';
1255 self.cp_bob_spd = 0;
1257 self.alpha = self.health / self.max_health;
1258 // colormod flash when shot
1259 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1260 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
1261 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
1262 //setsize(self, '-32 -32 0', '32 32 8');
1264 if(random() < 0.9 - self.health / self.max_health)
1265 pointparticles(particleeffectnum("rage"), self.origin + 10 * randomvec(), '0 0 -1', 1);
1271 void onslaught_controlpoint_touch()
1275 if (!IS_PLAYER(other))
1277 a = onslaught_controlpoint_attackable(self, other.team);
1278 if(a != 2 && a != 4)
1280 // we've verified that this player has a legitimate claim to this point,
1281 // so start building the captured point icon (which only captures this
1282 // point if it successfully builds without being destroyed first)
1283 self.goalentity = e = spawn();
1284 e.classname = "onslaught_controlpoint_icon";
1286 e.max_health = autocvar_g_onslaught_cp_health;
1287 e.health = autocvar_g_onslaught_cp_buildhealth;
1288 e.solid = SOLID_BBOX;
1289 e.movetype = MOVETYPE_NONE;
1290 setmodel(e, "models/onslaught/controlpoint_icon.md3");
1291 setsize(e, '-32 -32 -32', '32 32 32');
1292 setorigin(e, self.origin + '0 0 96');
1293 e.takedamage = DAMAGE_AIM;
1294 e.bot_attack = true;
1295 e.event_damage = onslaught_controlpoint_icon_damage;
1296 e.team = other.team;
1297 e.colormap = 1024 + (e.team - 1) * 17;
1298 e.think = onslaught_controlpoint_icon_buildthink;
1299 e.nextthink = time + sys_frametime;
1300 e.count = (e.max_health - e.health) * sys_frametime / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
1301 sound(e, CH_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTEN_NORM);
1303 self.colormap = e.colormap;
1304 WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / sys_frametime));
1305 onslaught_updatelinks();
1308 void onslaught_controlpoint_think()
1310 self.nextthink = time;
1311 CSQCMODEL_AUTOUPDATE();
1314 void onslaught_controlpoint_reset()
1316 if(self.goalentity && self.goalentity != world)
1317 remove(self.goalentity);
1318 self.goalentity = world;
1320 self.colormap = 1024;
1321 self.iscaptured = false;
1322 self.islinked = false;
1323 self.isshielded = true;
1324 self.enemy.solid = SOLID_NOT;
1325 self.enemy.colormap = self.colormap;
1326 self.think = onslaught_controlpoint_think;
1327 self.enemy.think = func_null;
1328 self.nextthink = time; // don't like func_null :P
1329 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1330 //setsize(self, '-32 -32 0', '32 32 8');
1332 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
1334 onslaught_updatelinks();
1337 SUB_UseTargets(); // to reset the structures, playerspawns etc.
1339 CSQCMODEL_AUTOUPDATE();
1342 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
1343 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
1345 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
1348 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
1349 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
1350 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
1353 void spawnfunc_onslaught_controlpoint()
1361 precache_model("models/onslaught/controlpoint_pad.md3");
1362 precache_model("models/onslaught/controlpoint_pad2.md3");
1363 precache_model("models/onslaught/controlpoint_shield.md3");
1364 precache_model("models/onslaught/controlpoint_icon.md3");
1365 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
1366 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
1367 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
1368 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
1369 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
1370 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
1371 precache_sound("onslaught/controlpoint_build.wav");
1372 precache_sound("onslaught/controlpoint_built.wav");
1373 precache_sound("weapons/grenade_impact.wav");
1374 precache_sound("onslaught/damageblockedbyshield.wav");
1375 precache_sound("onslaught/controlpoint_underattack.wav");
1376 precache_sound("onslaught/ons_spark1.wav");
1377 precache_sound("onslaught/ons_spark2.wav");
1379 self.solid = SOLID_BBOX;
1380 self.movetype = MOVETYPE_NONE;
1381 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1382 //setsize(self, '-32 -32 0', '32 32 8');
1385 setorigin(self, self.origin + '0 0 20');
1388 self.touch = onslaught_controlpoint_touch;
1390 self.colormap = 1024;
1391 self.iscaptured = false;
1392 self.islinked = false;
1393 self.isshielded = true;
1395 // spawn shield model which indicates whether this can be damaged
1396 self.enemy = spawn();
1397 self.enemy.classname = "onslaught_controlpoint_shield";
1398 self.enemy.solid = SOLID_NOT;
1399 self.enemy.movetype = MOVETYPE_NONE;
1400 self.enemy.effects = EF_ADDITIVE;
1401 setmodel(self.enemy , "models/onslaught/controlpoint_shield.md3");
1403 setattachment(self.enemy , self, "");
1404 //setsize(e, '-32 -32 0', '32 32 128');
1406 //setorigin(e, self.origin);
1407 self.enemy.colormap = self.colormap;
1409 waypoint_spawnforitem(self);
1411 self.think = onslaught_controlpoint_think;
1412 self.nextthink = time;
1414 WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
1415 WaypointSprite_UpdateRule(self.sprite, NUM_TEAM_2, SPRITERULE_TEAMPLAY);
1417 onslaught_updatelinks();
1419 self.reset = onslaught_controlpoint_reset;
1421 CSQCMODEL_AUTOINIT();
1424 float onslaught_link_send(entity to, float sendflags)
1426 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1427 WriteByte(MSG_ENTITY, sendflags);
1430 WriteCoord(MSG_ENTITY, self.goalentity.origin.x);
1431 WriteCoord(MSG_ENTITY, self.goalentity.origin.y);
1432 WriteCoord(MSG_ENTITY, self.goalentity.origin.z);
1436 WriteCoord(MSG_ENTITY, self.enemy.origin.x);
1437 WriteCoord(MSG_ENTITY, self.enemy.origin.y);
1438 WriteCoord(MSG_ENTITY, self.enemy.origin.z);
1442 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1447 void onslaught_link_checkupdate()
1449 // TODO check if the two sides have moved (currently they won't move anyway)
1450 float redpower, bluepower;
1452 redpower = bluepower = 0;
1453 if(self.goalentity.islinked)
1455 if(self.goalentity.team == NUM_TEAM_1)
1457 else if(self.goalentity.team == NUM_TEAM_2)
1460 if(self.enemy.islinked)
1462 if(self.enemy.team == NUM_TEAM_1)
1464 else if(self.enemy.team == NUM_TEAM_2)
1469 if(redpower == 1 && bluepower == 2)
1470 cc = (NUM_TEAM_1 - 1) * 0x01 + (NUM_TEAM_2 - 1) * 0x10;
1471 else if(redpower == 2 && bluepower == 1)
1472 cc = (NUM_TEAM_1 - 1) * 0x10 + (NUM_TEAM_2 - 1) * 0x01;
1474 cc = (NUM_TEAM_1 - 1) * 0x11;
1476 cc = (NUM_TEAM_2 - 1) * 0x11;
1480 //print(etos(self), " rp=", ftos(redpower), " bp=", ftos(bluepower), " ");
1481 //print("cc=", ftos(cc), "\n");
1483 if(cc != self.clientcolors)
1485 self.clientcolors = cc;
1486 self.SendFlags |= 4;
1489 self.nextthink = time;
1492 void onslaught_link_delayed()
1494 self.goalentity = find(world, targetname, self.target);
1495 self.enemy = find(world, targetname, self.target2);
1496 if (!self.goalentity)
1497 objerror("can not find target\n");
1499 objerror("can not find target2\n");
1500 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1501 self.SendFlags |= 3;
1502 self.think = onslaught_link_checkupdate;
1503 self.nextthink = time;
1506 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1507 Link between control points.
1509 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.
1512 "target" - first control point.
1513 "target2" - second control point.
1515 void spawnfunc_onslaught_link()
1522 if (self.target == "" || self.target2 == "")
1523 objerror("target and target2 must be set\n");
1524 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1525 Net_LinkEntity(self, false, 0, onslaught_link_send);
1528 MUTATOR_HOOKFUNCTION(ons_BuildMutatorsString)
1530 ret_string = strcat(ret_string, ":ONS");
1534 MUTATOR_HOOKFUNCTION(ons_BuildMutatorsPrettyString)
1536 ret_string = strcat(ret_string, ", Onslaught");
1540 MUTATOR_HOOKFUNCTION(ons_Spawn_Score)
1544 float _neer_home = (random() > 0.5 ? true : false);
1546 RandomSelection_Init();
1548 if(self.team == NUM_TEAM_1)
1549 RandomSelection_Add(ons_red_generator, 0, string_null, 1, 1);
1551 if(self.team == NUM_TEAM_2)
1552 RandomSelection_Add(ons_blue_generator, 0, string_null, 1, 1);
1554 entity _cp = findchain(classname, "onslaught_controlpoint"):
1557 if(_cp.team == self.team)
1558 RandomSelection_Add(_cp, 0, string_null, 1, 1);
1563 if(RandomSelection_chosen_ent)
1565 self.tur_head = RandomSelection_chosen_ent;
1566 spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_FOUND;
1568 else if(self.team == spawn_spot.team)
1569 spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate
1576 MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
1578 if(!autocvar_g_onslaught_spawn_at_controlpoints)
1581 if(random() < 0.5) // 50/50 chane to use default spawnsystem.
1584 float _close_to_home = ((random() > 0.5) ? true : false);
1585 entity _best = world, _trg_gen = world;
1586 float _score, _best_score = MAX_SHOT_DISTANCE;
1588 RandomSelection_Init();
1590 if(self.team == NUM_TEAM_1)
1593 _trg_gen = ons_blue_generator;
1595 _trg_gen = ons_red_generator;
1598 if(self.team == NUM_TEAM_2)
1601 _trg_gen = ons_blue_generator;
1603 _trg_gen = ons_red_generator;
1606 entity _cp = findchain(classname, "onslaught_controlpoint");
1609 if(_cp.team == self.team)
1611 _score = vlen(_trg_gen.origin - _cp.origin);
1612 if(_score < _best_score)
1615 _best_score = _score;
1625 for(i = 0; i < 10; ++i)
1627 _loc = _best.origin + '0 0 96';
1628 _loc += ('0 1 0' * random()) * 128;
1629 tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
1630 if(trace_fraction == 1.0 && !trace_startsolid)
1632 setorigin(self, _loc);
1633 self.angles = normalize(_loc - _best.origin) * RAD2DEG;
1640 if(!autocvar_g_onslaught_spawn_at_generator)
1643 _trg_gen = ((self.team == NUM_TEAM_1) ? ons_red_generator : ons_blue_generator);
1645 for(i = 0; i < 10; ++i)
1647 _loc = _trg_gen.origin + '0 0 96';
1648 _loc += ('0 1 0' * random()) * 128;
1649 tracebox(_loc, PL_MIN, PL_MAX, _loc, MOVE_NORMAL, self);
1650 if(trace_fraction == 1.0 && !trace_startsolid)
1652 setorigin(self, _loc);
1653 self.angles = normalize(_loc - _trg_gen.origin) * RAD2DEG;
1662 MUTATOR_HOOKFUNCTION(ons_MonsterThink)
1664 entity e = find(world, targetname, self.target);
1671 MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
1673 entity e, ee = world;
1677 e = find(world,target,self.targetname);
1694 MUTATOR_DEFINITION(gamemode_onslaught)
1696 MUTATOR_HOOK(BuildMutatorsPrettyString, ons_BuildMutatorsPrettyString, CBC_ORDER_ANY);
1697 MUTATOR_HOOK(BuildMutatorsString, ons_BuildMutatorsString, CBC_ORDER_ANY);
1698 MUTATOR_HOOK(PlayerSpawn, ons_PlayerSpawn, CBC_ORDER_ANY);
1699 MUTATOR_HOOK(MonsterMove, ons_MonsterThink, CBC_ORDER_ANY);
1700 MUTATOR_HOOK(MonsterSpawn, ons_MonsterSpawn, CBC_ORDER_ANY);
1701 //MUTATOR_HOOK(Spawn_Score, ons_Spawn_Score, CBC_ORDER_ANY);
1705 if(time > 1) // game loads at time 1
1706 error("This is a game type and it cannot be added at runtime.");
1711 print("This is a game type and it cannot be removed at runtime.");