1 void onslaught_generator_updatesprite(entity e);
2 void onslaught_controlpoint_updatesprite(entity e);
3 void onslaught_link_checkupdate();
9 .float isgenneighbor_red;
10 .float isgenneighbor_blue;
11 .float iscpneighbor_red;
12 .float iscpneighbor_blue;
18 .string model1, model2, model3;
21 void onslaught_generator_boom_think()
23 self.nextthink = time + 0.05;
26 self.think = SUB_Remove;
32 void onslaught_generator_boom_spawn(vector org, float fscale)
36 setmodel(e, "models/onslaught/boom.md3");
40 setsize(e, e.mins * e.scale, e.maxs * e.scale);
41 e.angles = randomvec() * 360;
43 e.effects = EF_NOSHADOW;
45 e.think = onslaught_generator_boom_think;
46 e.nextthink = time + 0.05;
49 void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
51 self.velocity = self.velocity + vforce;
55 void ons_throwgib_think()
59 self.nextthink = time + 0.05;
60 if(self.count > self.giblifetime)
62 self.think = SUB_Remove;
65 if(self.count > self.giblifetime-10)
67 org = self.origin + 20 * randomvec();
68 onslaught_generator_boom_spawn(org, random()*0.5+0.3);
72 void ons_throwgib(vector v_from, vector v_to, string smodel, float f_lifetime, float f_fadetime, float b_burn)
78 setmodel(gib, smodel);
79 setorigin(gib, v_from);
80 gib.solid = SOLID_BBOX;
81 gib.movetype = MOVETYPE_BOUNCE;
82 gib.takedamage = DAMAGE_YES;
83 gib.event_damage = ons_gib_damage;
85 gib.effects = EF_LOWPRECISION;
86 gib.flags = FL_NOTARGET;
88 gib.giblifetime = f_lifetime;
92 gib.think = ons_throwgib_think;
93 gib.nextthink = time + 0.05;
96 SUB_SetFade(gib, time + f_lifetime, 2);
99 void onslaught_updatelinks()
101 local entity l, links;
102 local float stop, t1, t2, t3, t4;
103 // first check if the game has ended
104 dprint("--- updatelinks ---\n");
105 links = findchain(classname, "onslaught_link");
106 // mark generators as being shielded and networked
107 l = findchain(classname, "onslaught_generator");
111 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
113 dprint(etos(l), " (generator) is destroyed\n");
114 l.islinked = l.iscaptured;
115 l.isshielded = l.iscaptured;
118 // mark points as shielded and not networked
119 l = findchain(classname, "onslaught_controlpoint");
124 l.isgenneighbor_red = FALSE;
125 l.isgenneighbor_blue = FALSE;
126 l.iscpneighbor_red = FALSE;
127 l.iscpneighbor_blue = FALSE;
128 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
131 // flow power outward from the generators through the network
135 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
145 // if both points are captured by the same team, and only one of
146 // them is powered, mark the other one as powered as well
147 if (l.enemy.iscaptured && l.goalentity.iscaptured)
148 if (l.enemy.islinked != l.goalentity.islinked)
149 if (l.enemy.team == l.goalentity.team)
151 if (!l.goalentity.islinked)
154 l.goalentity.islinked = TRUE;
155 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
157 else if (!l.enemy.islinked)
160 l.enemy.islinked = TRUE;
161 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
167 // now that we know which points are powered we can mark their neighbors
168 // as unshielded if team differs
172 if (l.goalentity.team != l.enemy.team)
174 if (l.goalentity.islinked)
176 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
177 l.enemy.isshielded = FALSE;
178 if(l.goalentity.classname == "onslaught_generator")
180 if(l.goalentity.team == COLOR_TEAM1)
181 l.enemy.isgenneighbor_red = TRUE;
182 else if(l.goalentity.team == COLOR_TEAM2)
183 l.enemy.isgenneighbor_blue = TRUE;
187 if(l.goalentity.team == COLOR_TEAM1)
188 l.enemy.iscpneighbor_red = TRUE;
189 else if(l.goalentity.team == COLOR_TEAM2)
190 l.enemy.iscpneighbor_blue = TRUE;
193 if (l.enemy.islinked)
195 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
196 l.goalentity.isshielded = FALSE;
197 if(l.enemy.classname == "onslaught_generator")
199 if(l.enemy.team == COLOR_TEAM1)
200 l.goalentity.isgenneighbor_red = TRUE;
201 else if(l.enemy.team == COLOR_TEAM2)
202 l.goalentity.isgenneighbor_blue = TRUE;
206 if(l.enemy.team == COLOR_TEAM1)
207 l.goalentity.iscpneighbor_red = TRUE;
208 else if(l.enemy.team == COLOR_TEAM2)
209 l.goalentity.iscpneighbor_blue = TRUE;
215 // now update the takedamage and alpha variables on generator shields
216 l = findchain(classname, "onslaught_generator");
221 dprint(etos(l), " (generator) is shielded\n");
223 l.takedamage = DAMAGE_NO;
224 l.bot_attack = FALSE;
228 dprint(etos(l), " (generator) is not shielded\n");
230 l.takedamage = DAMAGE_AIM;
235 // now update the takedamage and alpha variables on control point icons
236 l = findchain(classname, "onslaught_controlpoint");
241 dprint(etos(l), " (point) is shielded\n");
245 l.goalentity.takedamage = DAMAGE_NO;
246 l.goalentity.bot_attack = FALSE;
251 dprint(etos(l), " (point) is not shielded\n");
255 l.goalentity.takedamage = DAMAGE_AIM;
256 l.goalentity.bot_attack = TRUE;
259 onslaught_controlpoint_updatesprite(l);
262 // count generators owned by each team
263 t1 = t2 = t3 = t4 = 0;
264 l = findchain(classname, "onslaught_generator");
269 if (l.team == COLOR_TEAM1) t1 = 1;
270 if (l.team == COLOR_TEAM2) t2 = 1;
271 if (l.team == COLOR_TEAM3) t3 = 1;
272 if (l.team == COLOR_TEAM4) t4 = 1;
274 onslaught_generator_updatesprite(l);
277 // see if multiple teams remain (if not, it's game over)
278 if (t1 + t2 + t3 + t4 < 2)
279 dprint("--- game over ---\n");
281 dprint("--- done updating links ---\n");
284 float onslaught_controlpoint_can_be_linked(entity cp, float t)
288 if(cp.isgenneighbor_red)
290 if(cp.iscpneighbor_red)
293 else if(t == COLOR_TEAM2)
295 if(cp.isgenneighbor_blue)
297 if(cp.iscpneighbor_blue)
303 // check to see if this player has a legitimate claim to capture this
304 // control point - more specifically that there is a captured path of
305 // points leading back to the team generator
306 e = findchain(classname, "onslaught_link");
309 if (e.goalentity == cp)
311 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
312 if (e.enemy.islinked)
314 dprint(" which is linked");
315 if (e.enemy.team == t)
317 dprint(" and has the correct team!\n");
321 dprint(" but has the wrong team\n");
326 else if (e.enemy == cp)
328 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
329 if (e.goalentity.islinked)
331 dprint(" which is linked");
332 if (e.goalentity.team == t)
334 dprint(" and has a team!\n");
338 dprint(" but has the wrong team\n");
349 float onslaught_controlpoint_attackable(entity cp, float t)
350 // -2: SAME TEAM, attackable by enemy!
355 // 3: attack it (HIGH PRIO)
356 // 4: touch it (HIGH PRIO)
364 else if(cp.goalentity)
366 // if there's already an icon built, nothing happens
369 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
370 if(a) // attackable by enemy?
371 return -2; // EMERGENCY!
374 // we know it can be linked, so no need to check
376 a = onslaught_controlpoint_can_be_linked(cp, t);
377 if(a == 2) // near our generator?
378 return 3; // EMERGENCY!
384 if(onslaught_controlpoint_can_be_linked(cp, t))
386 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
388 return 4; // GET THIS ONE NOW!
390 return 2; // TOUCH ME
396 void onslaught_generator_think()
400 self.nextthink = ceil(time + 1);
401 if (cvar("timelimit"))
402 if (time > cvar("timelimit") * 60 - 60)
404 // self.max_health / 300 gives 5 minutes of overtime.
405 // control points reduce the overtime duration.
406 sound(self, CHAN_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTN_NORM);
408 e = findchain(classname, "onslaught_controlpoint");
411 if (e.team != self.team)
416 d = d * self.max_health / 300;
417 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
422 void onslaught_generator_ring_think()
424 self.nextthink = time + 0.05;
427 self.think = SUB_Remove;
431 self.scale = self.count * 4;
433 self.frame = self.count;
439 void onslaught_generator_ring_spawn(vector org)
443 setmodel(e, "models/onslaught/shockwavetransring.md3");
449 e.think = onslaught_generator_ring_think;
450 e.nextthink = time + 0.05;
452 void onslaught_generator_ray_think()
454 self.nextthink = time + 0.05;
457 self.think = SUB_Remove;
470 void onslaught_generator_ray_spawn(vector org)
474 setmodel(e, "models/onslaught/ons_ray.md3");
476 e.angles = randomvec() * 360;
478 e.scale = random() * 5 + 8;
479 e.think = onslaught_generator_ray_think;
480 e.nextthink = time + 0.05;
483 void onslaught_generator_shockwave_think()
485 self.nextthink = time + 0.05;
488 self.think = SUB_Remove;
497 self.scale = self.count * 4;
498 setsize(self, self.mins * self.scale, self.maxs * self.scale);
499 self.frame = self.count;
504 void onslaught_generator_shockwave_spawn(vector org)
508 setmodel(e, "models/onslaught/shockwave.md3");
516 e.think = onslaught_generator_shockwave_think;
517 e.nextthink = time + 0.05;
520 void onslaught_generator_damage_think()
522 if(self.owner.health < 0)
524 self.think = SUB_Remove;
527 self.nextthink = time+0.1;
529 // damaged fx (less probable the more damaged is the generator)
530 if(random() < 0.9 - self.owner.health / self.owner.max_health)
533 pointparticles(particleeffectnum("electro_ballexplode"), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
534 sound(self, CHAN_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM);
537 pointparticles(particleeffectnum("torch_small"), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
540 void onslaught_generator_damage_spawn(entity gd_owner)
545 e.health = self.owner.health;
546 setorigin(e, gd_owner.origin);
547 e.think = onslaught_generator_damage_think;
548 e.nextthink = time+1;
551 void onslaught_generator_deaththink()
560 if(self.count==40||self.count==20)
562 onslaught_generator_ring_spawn(self.origin);
563 sound(self, CHAN_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTN_NORM);
571 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 25, 1, 1);
573 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 20, 1, 1);
575 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 15, 1, 1);
581 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
582 onslaught_generator_boom_spawn(org, (6-i)/5+0.3);
585 // Short explosion sound + small explosion
588 te_explosion(self.origin);
589 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
593 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
594 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
599 onslaught_generator_ray_spawn(self.origin);
607 onslaught_generator_shockwave_spawn(org);
608 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
609 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
612 self.nextthink = time + 0.05;
614 self.count = self.count - 1;
617 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
622 if (attacker != self)
626 // this is protected by a shield, so ignore the damage
627 if (time > self.pain_finished)
628 if (attacker.classname == "player")
630 play2(attacker, "onslaught/damageblockedbyshield.wav");
631 self.pain_finished = time + 1;
635 if (time > self.pain_finished)
637 self.pain_finished = time + 10;
638 bprint(ColoredTeamName(self.team), " generator under attack!\n");
639 play2team(self.team, "onslaught/generator_underattack.wav");
642 self.health = self.health - damage;
643 // choose an animation frame based on health
644 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
645 // see if the generator is still functional, or dying
649 lh = ceil(self.lasthealth / 100) * 100;
650 h = ceil(self.health / 100) * 100;
652 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
653 self.lasthealth = self.health;
657 if (attacker == self)
658 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
662 t = ColoredTeamName(attacker.team);
663 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
665 self.iscaptured = FALSE;
666 self.islinked = FALSE;
667 self.isshielded = FALSE;
668 self.takedamage = DAMAGE_NO; // can't be hurt anymore
669 self.event_damage = SUB_Null; // won't do anything if hurt
670 self.count = 0; // reset counter
671 self.think = onslaught_generator_deaththink; // explosion sequence
672 self.nextthink = time; // start exploding immediately
673 self.think(); // do the first explosion now
674 onslaught_updatelinks();
677 setmodel(self, "models/onslaught/generator_dead.md3");
678 else if(self.health < self.max_health * 0.10)
679 setmodel(self, "models/onslaught/generator_dmg9.md3");
680 else if(self.health < self.max_health * 0.20)
681 setmodel(self, "models/onslaught/generator_dmg8.md3");
682 else if(self.health < self.max_health * 0.30)
683 setmodel(self, "models/onslaught/generator_dmg7.md3");
684 else if(self.health < self.max_health * 0.40)
685 setmodel(self, "models/onslaught/generator_dmg6.md3");
686 else if(self.health < self.max_health * 0.50)
687 setmodel(self, "models/onslaught/generator_dmg5.md3");
688 else if(self.health < self.max_health * 0.60)
689 setmodel(self, "models/onslaught/generator_dmg4.md3");
690 else if(self.health < self.max_health * 0.70)
691 setmodel(self, "models/onslaught/generator_dmg3.md3");
692 else if(self.health < self.max_health * 0.80)
693 setmodel(self, "models/onslaught/generator_dmg2.md3");
694 else if(self.health < self.max_health * 0.90)
695 setmodel(self, "models/onslaught/generator_dmg1.md3");
696 setsize(self, '-52 -52 -14', '52 52 75');
698 // Throw some flaming gibs on damage, more damage = more chance for gib
699 if(random() < damage/220)
701 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
704 ons_throwgib(hitloc, (force * -1) + '0 0 40', "models/onslaught/gen_gib1.md3", 7, 1, 1);
706 ons_throwgib(hitloc, (force * -1)+ '0 0 40', "models/onslaught/gen_gib2.md3", 6, 1, 1);
708 ons_throwgib(hitloc, (force * -1)+ '0 0 40', "models/onslaught/gen_gib3.md3", 5, 1, 1);
712 // particles on every hit
713 pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
717 sound(self, CHAN_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTN_NORM);
719 sound(self, CHAN_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM);
722 //throw some gibs on damage
723 if(random() < damage/200+0.2)
725 ons_throwgib(hitloc, randomvec()*360, "models/onslaught/gen_gib1.md3", 1, 1, 0);
728 // update links after a delay
729 void onslaught_generator_delayed()
731 onslaught_updatelinks();
732 // now begin normal thinking
733 self.think = onslaught_generator_think;
734 self.nextthink = time;
737 string onslaught_generator_waypointsprite_for_team(entity e, float t)
741 if(e.team == COLOR_TEAM1)
742 return "ons-gen-red";
743 else if(e.team == COLOR_TEAM2)
744 return "ons-gen-blue";
747 return "ons-gen-shielded";
748 if(e.team == COLOR_TEAM1)
749 return "ons-gen-red";
750 else if(e.team == COLOR_TEAM2)
751 return "ons-gen-blue";
755 void onslaught_generator_updatesprite(entity e)
758 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
759 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
760 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
761 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
763 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
765 e.lastteam = e.team + 2;
766 e.lastshielded = e.isshielded;
769 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
770 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
772 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
776 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
777 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, FALSE));
779 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
781 WaypointSprite_Ping(e.sprite);
785 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
790 a = onslaught_controlpoint_attackable(e, t);
791 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
793 if(e.team == COLOR_TEAM1)
794 return "ons-cp-atck-red";
795 else if(e.team == COLOR_TEAM2)
796 return "ons-cp-atck-blue";
798 return "ons-cp-atck-neut";
800 else if(a == -2) // DEFEND THIS ONE NOW
802 if(e.team == COLOR_TEAM1)
803 return "ons-cp-dfnd-red";
804 else if(e.team == COLOR_TEAM2)
805 return "ons-cp-dfnd-blue";
807 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
809 if(e.team == COLOR_TEAM1)
811 else if(e.team == COLOR_TEAM2)
812 return "ons-cp-blue";
814 else if(a == 2) // touch it
815 return "ons-cp-neut";
819 if(e.team == COLOR_TEAM1)
821 else if(e.team == COLOR_TEAM2)
822 return "ons-cp-blue";
824 return "ons-cp-neut";
829 void onslaught_controlpoint_updatesprite(entity e)
832 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
833 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
834 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
835 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
838 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
840 if(e.lastteam != e.team + 2 || e.lastshielded != sh)
842 e.lastteam = e.team + 2;
846 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
847 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
849 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
853 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
854 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, FALSE));
856 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
858 WaypointSprite_Ping(e.sprite);
862 void onslaught_generator_reset()
864 self.team = self.team_saved;
865 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
866 self.takedamage = DAMAGE_AIM;
867 self.bot_attack = TRUE;
868 self.iscaptured = TRUE;
869 self.islinked = TRUE;
870 self.isshielded = TRUE;
871 self.enemy.solid = SOLID_NOT;
872 self.think = onslaught_generator_delayed;
873 self.nextthink = time + 0.2;
874 setmodel(self, "models/onslaught/generator.md3");
877 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
880 spawnfunc_onslaught_link entities can target this.
883 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
884 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
886 void spawnfunc_onslaught_generator()
895 precache_model("models/onslaught/generator.md3");
896 precache_model("models/onslaught/generator_shield.md3");
897 precache_model("models/onslaught/generator_dmg1.md3");
898 precache_model("models/onslaught/generator_dmg2.md3");
899 precache_model("models/onslaught/generator_dmg3.md3");
900 precache_model("models/onslaught/generator_dmg4.md3");
901 precache_model("models/onslaught/generator_dmg5.md3");
902 precache_model("models/onslaught/generator_dmg6.md3");
903 precache_model("models/onslaught/generator_dmg7.md3");
904 precache_model("models/onslaught/generator_dmg8.md3");
905 precache_model("models/onslaught/generator_dmg9.md3");
906 precache_model("models/onslaught/generator_dead.md3");
907 precache_model("models/onslaught/boom.md3");
908 precache_model("models/onslaught/shockwave.md3");
909 precache_model("models/onslaught/shockwavetransring.md3");
910 precache_model("models/onslaught/gen_gib1.md3");
911 precache_model("models/onslaught/gen_gib2.md3");
912 precache_model("models/onslaught/gen_gib3.md3");
913 precache_model("models/onslaught/ons_ray.md3");
914 precache_sound("onslaught/generator_decay.wav");
915 precache_sound("weapons/grenade_impact.wav");
916 precache_sound("weapons/rocket_impact.wav");
917 precache_sound("onslaught/generator_underattack.wav");
918 precache_sound("onslaught/shockwave.wav");
919 precache_sound("onslaught/ons_hit1.wav");
920 precache_sound("onslaught/ons_hit2.wav");
921 precache_sound("onslaught/electricity_explode.wav");
923 objerror("team must be set");
924 self.team_saved = self.team;
925 self.colormap = 1024 + (self.team - 1) * 17;
926 self.solid = SOLID_BBOX;
927 self.movetype = MOVETYPE_NONE;
928 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
929 setmodel(self, "models/onslaught/generator.md3");
930 setsize(self, '-52 -52 -14', '52 52 75');
931 setorigin(self, self.origin);
932 self.takedamage = DAMAGE_AIM;
933 self.bot_attack = TRUE;
934 self.event_damage = onslaught_generator_damage;
935 self.iscaptured = TRUE;
936 self.islinked = TRUE;
937 self.isshielded = TRUE;
938 // helper entity that create fx when generator is damaged
939 onslaught_generator_damage_spawn(self);
940 // spawn shield model which indicates whether this can be damaged
941 self.enemy = e = spawn();
942 e.classname = "onslaught_generator_shield";
944 e.movetype = MOVETYPE_NONE;
945 e.effects = EF_ADDITIVE;
946 setmodel(e, "models/onslaught/generator_shield.md3");
947 setorigin(e, self.origin);
948 e.colormap = self.colormap;
950 self.think = onslaught_generator_delayed;
951 self.nextthink = time + 0.2;
952 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
954 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
955 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
957 waypoint_spawnforitem(self);
959 onslaught_updatelinks();
961 self.reset = onslaught_generator_reset;
966 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
967 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
972 if (self.owner.isshielded)
974 // this is protected by a shield, so ignore the damage
975 if (time > self.pain_finished)
976 if (attacker.classname == "player")
978 play2(attacker, "onslaught/damageblockedbyshield.wav");
979 self.pain_finished = time + 1;
983 if (time > self.pain_finished)
984 if (attacker.classname == "player")
986 play2team(self.team, "onslaught/controlpoint_underattack.wav");
987 self.pain_finished = time + 10;
989 self.health = self.health - damage;
990 self.pain_finished = time + 1;
991 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
992 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
993 // colormod flash when shot
994 self.colormod = '2 2 2';
995 // particles on every hit
996 pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
999 sound(self, CHAN_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTN_NORM);
1001 sound(self, CHAN_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTN_NORM);
1003 if (self.health < 0)
1005 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
1006 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
1009 t = ColoredTeamName(attacker.team);
1010 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
1011 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 5, 1, 0);
1012 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 5, 1, 0);
1013 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 5, 1, 0);
1014 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1015 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1016 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1017 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1019 self.owner.goalentity = world;
1020 self.owner.islinked = FALSE;
1021 self.owner.iscaptured = FALSE;
1022 self.owner.team = 0;
1023 self.owner.colormap = 1024;
1024 onslaught_updatelinks();
1026 // Use targets now (somebody make sure this is in the right place..)
1034 self.owner.waslinked = self.owner.islinked;
1035 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
1036 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
1037 //setsize(self, '-32 -32 0', '32 32 8');
1043 void onslaught_controlpoint_icon_think()
1046 self.nextthink = time + 0.05;
1047 if (time > self.pain_finished + 5)
1049 self.health = self.health + self.count;
1050 if (self.health >= self.max_health)
1051 self.health = self.max_health;
1053 if (self.health < self.max_health * 0.25)
1054 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
1055 else if (self.health < self.max_health * 0.50)
1056 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
1057 else if (self.health < self.max_health * 0.75)
1058 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
1059 else if (self.health < self.max_health * 0.90)
1060 setmodel(self, "models/onslaught/controlpoint_icon.md3");
1061 // colormod flash when shot
1062 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1064 if(self.owner.islinked != self.owner.waslinked)
1066 // unteam the spawnpoint if needed
1068 t = self.owner.team;
1069 if(!self.owner.islinked)
1070 self.owner.team = 0;
1078 self.owner.team = t;
1080 self.owner.waslinked = self.owner.islinked;
1082 if (self.punchangle_x > 2)
1083 self.punchangle_x = self.punchangle_x - 2;
1084 else if (self.punchangle_x < -2)
1085 self.punchangle_x = self.punchangle_x + 2;
1087 self.punchangle_x = 0;
1088 if (self.punchangle_y > 2)
1089 self.punchangle_y = self.punchangle_y - 2;
1090 else if (self.punchangle_y < -2)
1091 self.punchangle_y = self.punchangle_y + 2;
1093 self.punchangle_y = 0;
1094 if (self.punchangle_z > 2)
1095 self.punchangle_z = self.punchangle_z - 2;
1096 else if (self.punchangle_z < -2)
1097 self.punchangle_z = self.punchangle_z + 2;
1099 self.punchangle_z = 0;
1100 self.angles_x = self.punchangle_x;
1101 self.angles_y = self.punchangle_y + self.mangle_y;
1102 self.angles_z = self.punchangle_z;
1103 self.mangle_y = self.mangle_y + 1.5;
1105 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd / 8));
1106 self.cp_bob_spd = self.cp_bob_spd + 0.5;
1107 if(self.cp_bob_dmg_z > 0)
1108 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 0.1;
1110 self.cp_bob_dmg_z = 0;
1111 self.origin = self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg;
1114 if(random() < 0.6 - self.health / self.max_health)
1116 pointparticles(particleeffectnum("electricity_sparks"), self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
1119 sound(self, CHAN_PAIN, "onslaught/ons_spark1.wav", VOL_BASE, ATTN_NORM);
1120 else if (random() > 0.5)
1121 sound(self, CHAN_PAIN, "onslaught/ons_spark2.wav", VOL_BASE, ATTN_NORM);
1125 void onslaught_controlpoint_icon_buildthink()
1130 self.nextthink = time + 0.05;
1132 // only do this if there is power
1133 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
1137 self.health = self.health + self.count;
1139 if (self.health >= self.max_health)
1141 self.health = self.max_health;
1142 self.count = self.count * 0.1; // slow repair rate from now on
1143 self.think = onslaught_controlpoint_icon_think;
1144 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
1145 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
1146 self.owner.iscaptured = TRUE;
1147 onslaught_updatelinks();
1149 // Use targets now (somebody make sure this is in the right place..)
1155 self.cp_origin = self.origin;
1156 self.cp_bob_origin = '0 0 0.1';
1157 self.cp_bob_spd = 0;
1159 self.alpha = self.health / self.max_health;
1160 // colormod flash when shot
1161 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1162 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
1163 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
1164 //setsize(self, '-32 -32 0', '32 32 8');
1166 if(random() < 0.9 - self.health / self.max_health)
1167 pointparticles(particleeffectnum("rage"), self.origin + 10 * randomvec(), '0 0 -1', 1);
1173 void onslaught_controlpoint_touch()
1177 if (other.classname != "player")
1179 a = onslaught_controlpoint_attackable(self, other.team);
1180 if(a != 2 && a != 4)
1182 // we've verified that this player has a legitimate claim to this point,
1183 // so start building the captured point icon (which only captures this
1184 // point if it successfully builds without being destroyed first)
1185 self.goalentity = e = spawn();
1186 e.classname = "onslaught_controlpoint_icon";
1188 e.max_health = cvar("g_onslaught_cp_health");
1189 e.health = e.max_health * 0.1;
1190 e.solid = SOLID_BBOX;
1191 e.movetype = MOVETYPE_NONE;
1192 setmodel(e, "models/onslaught/controlpoint_icon.md3");
1193 setsize(e, '-32 -32 -32', '32 32 32');
1194 setorigin(e, self.origin + '0 0 96');
1195 e.takedamage = DAMAGE_AIM;
1196 e.bot_attack = TRUE;
1197 e.event_damage = onslaught_controlpoint_icon_damage;
1198 e.team = other.team;
1199 e.colormap = 1024 + (e.team - 1) * 17;
1200 e.think = onslaught_controlpoint_icon_buildthink;
1201 e.nextthink = time + 0.1;
1202 e.count = e.max_health / 100; // how long it takes to build
1203 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
1205 self.colormap = e.colormap;
1208 void onslaught_controlpoint_reset()
1210 if(self.goalentity && self.goalentity != world)
1211 remove(self.goalentity);
1212 self.goalentity = world;
1214 self.colormap = 1024;
1215 self.iscaptured = FALSE;
1216 self.islinked = FALSE;
1217 self.isshielded = TRUE;
1218 self.enemy.solid = SOLID_NOT;
1219 self.enemy.colormap = self.colormap;
1220 self.think = self.enemy.think = SUB_Null;
1221 self.nextthink = 0; // don't like SUB_Null :P
1222 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1223 //setsize(self, '-32 -32 0', '32 32 8');
1225 onslaught_updatelinks();
1228 SUB_UseTargets(); // to reset the structures, playerspawns etc.
1231 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
1232 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
1234 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
1237 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
1238 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
1239 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
1241 void spawnfunc_onslaught_controlpoint()
1249 precache_model("models/onslaught/controlpoint_pad.md3");
1250 precache_model("models/onslaught/controlpoint_pad2.md3");
1251 precache_model("models/onslaught/controlpoint_shield.md3");
1252 precache_model("models/onslaught/controlpoint_icon.md3");
1253 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
1254 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
1255 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
1256 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
1257 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
1258 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
1259 precache_sound("onslaught/controlpoint_build.wav");
1260 precache_sound("onslaught/controlpoint_built.wav");
1261 precache_sound("weapons/grenade_impact.wav");
1262 precache_sound("onslaught/damageblockedbyshield.wav");
1263 precache_sound("onslaught/controlpoint_underattack.wav");
1264 precache_sound("onslaught/ons_spark1.wav");
1265 precache_sound("onslaught/ons_spark2.wav");
1266 self.solid = SOLID_BBOX;
1267 self.movetype = MOVETYPE_NONE;
1268 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1269 //setsize(self, '-32 -32 0', '32 32 8');
1270 setorigin(self, self.origin);
1271 self.touch = onslaught_controlpoint_touch;
1273 self.colormap = 1024;
1274 self.iscaptured = FALSE;
1275 self.islinked = FALSE;
1276 self.isshielded = TRUE;
1277 // spawn shield model which indicates whether this can be damaged
1278 self.enemy = e = spawn();
1279 e.classname = "onslaught_controlpoint_shield";
1280 e.solid = SOLID_NOT;
1281 e.movetype = MOVETYPE_NONE;
1282 e.effects = EF_ADDITIVE;
1283 setmodel(e, "models/onslaught/controlpoint_shield.md3");
1284 //setsize(e, '-32 -32 0', '32 32 128');
1285 setorigin(e, self.origin);
1286 e.colormap = self.colormap;
1288 waypoint_spawnforitem(self);
1290 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
1291 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
1293 onslaught_updatelinks();
1295 self.reset = onslaught_controlpoint_reset;
1298 float onslaught_link_send(entity to, float sendflags)
1300 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1301 WriteByte(MSG_ENTITY, sendflags);
1304 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
1305 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
1306 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1310 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1311 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1312 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1316 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1321 void onslaught_link_checkupdate()
1323 // TODO check if the two sides have moved (currently they won't move anyway)
1324 float redpower, bluepower;
1326 redpower = bluepower = 0;
1327 if(self.goalentity.islinked)
1329 if(self.goalentity.team == COLOR_TEAM1)
1331 else if(self.goalentity.team == COLOR_TEAM2)
1334 if(self.enemy.islinked)
1336 if(self.enemy.team == COLOR_TEAM1)
1338 else if(self.enemy.team == COLOR_TEAM2)
1343 if(redpower == 1 && bluepower == 2)
1344 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1345 else if(redpower == 2 && bluepower == 1)
1346 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1348 cc = (COLOR_TEAM1 - 1) * 0x11;
1350 cc = (COLOR_TEAM2 - 1) * 0x11;
1354 if(cc != self.clientcolors)
1356 self.clientcolors = cc;
1357 self.SendFlags |= 4;
1360 self.nextthink = time;
1363 void onslaught_link_delayed()
1365 self.goalentity = find(world, targetname, self.target);
1366 self.enemy = find(world, targetname, self.target2);
1367 if (!self.goalentity)
1368 objerror("can not find target\n");
1370 objerror("can not find target2\n");
1371 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1372 self.SendFlags |= 3;
1373 self.think = onslaught_link_checkupdate;
1374 self.nextthink = time;
1377 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1378 Link between control points.
1380 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.
1383 "target" - first control point.
1384 "target2" - second control point.
1386 void spawnfunc_onslaught_link()
1393 if (self.target == "" || self.target2 == "")
1394 objerror("target and target2 must be set\n");
1395 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1396 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);