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;
19 .string model1, model2, model3;
22 void onslaught_generator_boom_think()
24 self.nextthink = time + 0.05;
27 self.think = SUB_Remove;
33 void onslaught_generator_boom_spawn(vector org, float fscale)
37 setmodel(e, "models/onslaught/boom.md3");
41 setsize(e, e.mins * e.scale, e.maxs * e.scale);
42 e.angles = randomvec() * 360;
44 e.effects = EF_NOSHADOW;
46 e.think = onslaught_generator_boom_think;
47 e.nextthink = time + 0.05;
50 void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
52 self.velocity = self.velocity + vforce;
56 void ons_throwgib_think()
60 self.nextthink = time + 0.05;
61 if(self.count > self.giblifetime)
63 self.think = SUB_Remove;
66 if(self.count > self.giblifetime-10)
68 org = self.origin + 20 * randomvec();
69 onslaught_generator_boom_spawn(org, random()*0.5+0.3);
73 void ons_throwgib(vector v_from, vector v_to, string smodel, float f_lifetime, float f_fadetime, float b_burn)
79 setmodel(gib, smodel);
80 setorigin(gib, v_from);
81 gib.solid = SOLID_BBOX;
82 gib.movetype = MOVETYPE_BOUNCE;
83 gib.takedamage = DAMAGE_YES;
84 gib.event_damage = ons_gib_damage;
86 gib.effects = EF_LOWPRECISION;
87 gib.flags = FL_NOTARGET;
89 gib.giblifetime = f_lifetime;
93 gib.think = ons_throwgib_think;
94 gib.nextthink = time + 0.05;
97 SUB_SetFade(gib, time + f_lifetime, 2);
100 void onslaught_updatelinks()
102 local entity l, links;
103 local float stop, t1, t2, t3, t4;
104 // first check if the game has ended
105 dprint("--- updatelinks ---\n");
106 links = findchain(classname, "onslaught_link");
107 // mark generators as being shielded and networked
108 l = findchain(classname, "onslaught_generator");
112 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
114 dprint(etos(l), " (generator) is destroyed\n");
115 l.islinked = l.iscaptured;
116 l.isshielded = l.iscaptured;
119 // mark points as shielded and not networked
120 l = findchain(classname, "onslaught_controlpoint");
125 l.isgenneighbor_red = FALSE;
126 l.isgenneighbor_blue = FALSE;
127 l.iscpneighbor_red = FALSE;
128 l.iscpneighbor_blue = FALSE;
129 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
132 // flow power outward from the generators through the network
136 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
146 // if both points are captured by the same team, and only one of
147 // them is powered, mark the other one as powered as well
148 if (l.enemy.iscaptured && l.goalentity.iscaptured)
149 if (l.enemy.islinked != l.goalentity.islinked)
150 if (l.enemy.team == l.goalentity.team)
152 if (!l.goalentity.islinked)
155 l.goalentity.islinked = TRUE;
156 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
158 else if (!l.enemy.islinked)
161 l.enemy.islinked = TRUE;
162 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
168 // now that we know which points are powered we can mark their neighbors
169 // as unshielded if team differs
173 if (l.goalentity.islinked)
175 if (l.goalentity.team != l.enemy.team)
177 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
178 l.enemy.isshielded = FALSE;
180 if(l.goalentity.classname == "onslaught_generator")
182 if(l.goalentity.team == COLOR_TEAM1)
183 l.enemy.isgenneighbor_red = TRUE;
184 else if(l.goalentity.team == COLOR_TEAM2)
185 l.enemy.isgenneighbor_blue = TRUE;
189 if(l.goalentity.team == COLOR_TEAM1)
190 l.enemy.iscpneighbor_red = TRUE;
191 else if(l.goalentity.team == COLOR_TEAM2)
192 l.enemy.iscpneighbor_blue = TRUE;
195 if (l.enemy.islinked)
197 if (l.goalentity.team != l.enemy.team)
199 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
200 l.goalentity.isshielded = FALSE;
202 if(l.enemy.classname == "onslaught_generator")
204 if(l.enemy.team == COLOR_TEAM1)
205 l.goalentity.isgenneighbor_red = TRUE;
206 else if(l.enemy.team == COLOR_TEAM2)
207 l.goalentity.isgenneighbor_blue = TRUE;
211 if(l.enemy.team == COLOR_TEAM1)
212 l.goalentity.iscpneighbor_red = TRUE;
213 else if(l.enemy.team == COLOR_TEAM2)
214 l.goalentity.iscpneighbor_blue = TRUE;
219 // now update the takedamage and alpha variables on generator shields
220 l = findchain(classname, "onslaught_generator");
225 dprint(etos(l), " (generator) is shielded\n");
227 l.takedamage = DAMAGE_NO;
228 l.bot_attack = FALSE;
232 dprint(etos(l), " (generator) is not shielded\n");
234 l.takedamage = DAMAGE_AIM;
239 // now update the takedamage and alpha variables on control point icons
240 l = findchain(classname, "onslaught_controlpoint");
245 dprint(etos(l), " (point) is shielded\n");
249 l.goalentity.takedamage = DAMAGE_NO;
250 l.goalentity.bot_attack = FALSE;
255 dprint(etos(l), " (point) is not shielded\n");
259 l.goalentity.takedamage = DAMAGE_AIM;
260 l.goalentity.bot_attack = TRUE;
263 onslaught_controlpoint_updatesprite(l);
266 // count generators owned by each team
267 t1 = t2 = t3 = t4 = 0;
268 l = findchain(classname, "onslaught_generator");
273 if (l.team == COLOR_TEAM1) t1 = 1;
274 if (l.team == COLOR_TEAM2) t2 = 1;
275 if (l.team == COLOR_TEAM3) t3 = 1;
276 if (l.team == COLOR_TEAM4) t4 = 1;
278 onslaught_generator_updatesprite(l);
281 // see if multiple teams remain (if not, it's game over)
282 if (t1 + t2 + t3 + t4 < 2)
283 dprint("--- game over ---\n");
285 dprint("--- done updating links ---\n");
288 float onslaught_controlpoint_can_be_linked(entity cp, float t)
292 if(cp.isgenneighbor_red)
294 if(cp.iscpneighbor_red)
297 else if(t == COLOR_TEAM2)
299 if(cp.isgenneighbor_blue)
301 if(cp.iscpneighbor_blue)
307 // check to see if this player has a legitimate claim to capture this
308 // control point - more specifically that there is a captured path of
309 // points leading back to the team generator
310 e = findchain(classname, "onslaught_link");
313 if (e.goalentity == cp)
315 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
316 if (e.enemy.islinked)
318 dprint(" which is linked");
319 if (e.enemy.team == t)
321 dprint(" and has the correct team!\n");
325 dprint(" but has the wrong team\n");
330 else if (e.enemy == cp)
332 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
333 if (e.goalentity.islinked)
335 dprint(" which is linked");
336 if (e.goalentity.team == t)
338 dprint(" and has a team!\n");
342 dprint(" but has the wrong team\n");
353 float onslaught_controlpoint_attackable(entity cp, float t)
354 // -2: SAME TEAM, attackable by enemy!
359 // 3: attack it (HIGH PRIO)
360 // 4: touch it (HIGH PRIO)
368 else if(cp.goalentity)
370 // if there's already an icon built, nothing happens
373 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
374 if(a) // attackable by enemy?
375 return -2; // EMERGENCY!
378 // we know it can be linked, so no need to check
380 a = onslaught_controlpoint_can_be_linked(cp, t);
381 if(a == 2) // near our generator?
382 return 3; // EMERGENCY!
388 if(onslaught_controlpoint_can_be_linked(cp, t))
390 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
392 return 4; // GET THIS ONE NOW!
394 return 2; // TOUCH ME
400 void onslaught_generator_think()
404 self.nextthink = ceil(time + 1);
405 if (cvar("timelimit"))
406 if (time > cvar("timelimit") * 60 - 60)
408 // self.max_health / 300 gives 5 minutes of overtime.
409 // control points reduce the overtime duration.
410 sound(self, CHAN_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTN_NORM);
412 e = findchain(classname, "onslaught_controlpoint");
415 if (e.team != self.team)
420 d = d * self.max_health / 300;
421 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
426 void onslaught_generator_ring_think()
428 self.nextthink = time + 0.05;
431 self.think = SUB_Remove;
435 self.scale = self.count * 4;
437 self.frame = self.count;
443 void onslaught_generator_ring_spawn(vector org)
447 setmodel(e, "models/onslaught/shockwavetransring.md3");
453 e.think = onslaught_generator_ring_think;
454 e.nextthink = time + 0.05;
456 void onslaught_generator_ray_think()
458 self.nextthink = time + 0.05;
461 self.think = SUB_Remove;
474 void onslaught_generator_ray_spawn(vector org)
478 setmodel(e, "models/onslaught/ons_ray.md3");
480 e.angles = randomvec() * 360;
482 e.scale = random() * 5 + 8;
483 e.think = onslaught_generator_ray_think;
484 e.nextthink = time + 0.05;
487 void onslaught_generator_shockwave_think()
489 self.nextthink = time + 0.05;
492 self.think = SUB_Remove;
501 self.scale = self.count * 4;
502 setsize(self, self.mins * self.scale, self.maxs * self.scale);
503 self.frame = self.count;
508 void onslaught_generator_shockwave_spawn(vector org)
512 setmodel(e, "models/onslaught/shockwave.md3");
520 e.think = onslaught_generator_shockwave_think;
521 e.nextthink = time + 0.05;
524 void onslaught_generator_damage_think()
526 if(self.owner.health < 0)
528 self.think = SUB_Remove;
531 self.nextthink = time+0.1;
533 // damaged fx (less probable the more damaged is the generator)
534 if(random() < 0.9 - self.owner.health / self.owner.max_health)
537 pointparticles(particleeffectnum("electro_ballexplode"), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
538 sound(self, CHAN_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM);
541 pointparticles(particleeffectnum("torch_small"), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
544 void onslaught_generator_damage_spawn(entity gd_owner)
549 e.health = self.owner.health;
550 setorigin(e, gd_owner.origin);
551 e.think = onslaught_generator_damage_think;
552 e.nextthink = time+1;
555 void onslaught_generator_deaththink()
564 if(self.count==40||self.count==20)
566 onslaught_generator_ring_spawn(self.origin);
567 sound(self, CHAN_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTN_NORM);
575 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 25, 1, 1);
577 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 20, 1, 1);
579 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 15, 1, 1);
585 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
586 onslaught_generator_boom_spawn(org, (6-i)/5+0.3);
589 // Short explosion sound + small explosion
592 te_explosion(self.origin);
593 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
597 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
598 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
603 onslaught_generator_ray_spawn(self.origin);
611 onslaught_generator_shockwave_spawn(org);
612 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
613 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
616 self.nextthink = time + 0.05;
618 self.count = self.count - 1;
621 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
626 if (attacker != self)
630 // this is protected by a shield, so ignore the damage
631 if (time > self.pain_finished)
632 if (attacker.classname == "player")
634 play2(attacker, "onslaught/damageblockedbyshield.wav");
635 self.pain_finished = time + 1;
639 if (time > self.pain_finished)
641 self.pain_finished = time + 10;
642 bprint(ColoredTeamName(self.team), " generator under attack!\n");
643 play2team(self.team, "onslaught/generator_underattack.wav");
646 self.health = self.health - damage;
647 WaypointSprite_UpdateHealth(self.sprite, self.health);
648 // choose an animation frame based on health
649 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
650 // see if the generator is still functional, or dying
653 #ifdef ONSLAUGHT_SPAM
655 lh = ceil(self.lasthealth / 100) * 100;
656 h = ceil(self.health / 100) * 100;
658 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
660 self.lasthealth = self.health;
664 if (attacker == self)
665 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
669 t = ColoredTeamName(attacker.team);
670 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
672 self.iscaptured = FALSE;
673 self.islinked = FALSE;
674 self.isshielded = FALSE;
675 self.takedamage = DAMAGE_NO; // can't be hurt anymore
676 self.event_damage = SUB_Null; // won't do anything if hurt
677 self.count = 0; // reset counter
678 self.think = onslaught_generator_deaththink; // explosion sequence
679 self.nextthink = time; // start exploding immediately
680 self.think(); // do the first explosion now
682 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
684 onslaught_updatelinks();
687 setmodel(self, "models/onslaught/generator_dead.md3");
688 else if(self.health < self.max_health * 0.10)
689 setmodel(self, "models/onslaught/generator_dmg9.md3");
690 else if(self.health < self.max_health * 0.20)
691 setmodel(self, "models/onslaught/generator_dmg8.md3");
692 else if(self.health < self.max_health * 0.30)
693 setmodel(self, "models/onslaught/generator_dmg7.md3");
694 else if(self.health < self.max_health * 0.40)
695 setmodel(self, "models/onslaught/generator_dmg6.md3");
696 else if(self.health < self.max_health * 0.50)
697 setmodel(self, "models/onslaught/generator_dmg5.md3");
698 else if(self.health < self.max_health * 0.60)
699 setmodel(self, "models/onslaught/generator_dmg4.md3");
700 else if(self.health < self.max_health * 0.70)
701 setmodel(self, "models/onslaught/generator_dmg3.md3");
702 else if(self.health < self.max_health * 0.80)
703 setmodel(self, "models/onslaught/generator_dmg2.md3");
704 else if(self.health < self.max_health * 0.90)
705 setmodel(self, "models/onslaught/generator_dmg1.md3");
706 setsize(self, '-52 -52 -14', '52 52 75');
708 // Throw some flaming gibs on damage, more damage = more chance for gib
709 if(random() < damage/220)
711 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
714 ons_throwgib(hitloc, (force * -1) + '0 0 40', "models/onslaught/gen_gib1.md3", 7, 1, 1);
716 ons_throwgib(hitloc, (force * -1)+ '0 0 40', "models/onslaught/gen_gib2.md3", 6, 1, 1);
718 ons_throwgib(hitloc, (force * -1)+ '0 0 40', "models/onslaught/gen_gib3.md3", 5, 1, 1);
722 // particles on every hit
723 pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
727 sound(self, CHAN_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTN_NORM);
729 sound(self, CHAN_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM);
732 //throw some gibs on damage
733 if(random() < damage/200+0.2)
735 ons_throwgib(hitloc, randomvec()*360, "models/onslaught/gen_gib1.md3", 1, 1, 0);
738 // update links after a delay
739 void onslaught_generator_delayed()
741 onslaught_updatelinks();
742 // now begin normal thinking
743 self.think = onslaught_generator_think;
744 self.nextthink = time;
747 string onslaught_generator_waypointsprite_for_team(entity e, float t)
751 if(e.team == COLOR_TEAM1)
752 return "ons-gen-red";
753 else if(e.team == COLOR_TEAM2)
754 return "ons-gen-blue";
757 return "ons-gen-shielded";
758 if(e.team == COLOR_TEAM1)
759 return "ons-gen-red";
760 else if(e.team == COLOR_TEAM2)
761 return "ons-gen-blue";
765 void onslaught_generator_updatesprite(entity e)
768 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
769 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
770 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
771 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
773 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
775 e.lastteam = e.team + 2;
776 e.lastshielded = e.isshielded;
779 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
780 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
782 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
786 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
787 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, FALSE));
789 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
791 WaypointSprite_Ping(e.sprite);
795 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
800 a = onslaught_controlpoint_attackable(e, t);
801 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
803 if(e.team == COLOR_TEAM1)
804 return "ons-cp-atck-red";
805 else if(e.team == COLOR_TEAM2)
806 return "ons-cp-atck-blue";
808 return "ons-cp-atck-neut";
810 else if(a == -2) // DEFEND THIS ONE NOW
812 if(e.team == COLOR_TEAM1)
813 return "ons-cp-dfnd-red";
814 else if(e.team == COLOR_TEAM2)
815 return "ons-cp-dfnd-blue";
817 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
819 if(e.team == COLOR_TEAM1)
821 else if(e.team == COLOR_TEAM2)
822 return "ons-cp-blue";
824 else if(a == 2) // touch it
825 return "ons-cp-neut";
829 if(e.team == COLOR_TEAM1)
831 else if(e.team == COLOR_TEAM2)
832 return "ons-cp-blue";
834 return "ons-cp-neut";
839 void onslaught_controlpoint_updatesprite(entity e)
842 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
843 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
844 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
845 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
848 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
850 if(e.lastteam != e.team + 2 || e.lastshielded != sh || e.iscaptured != e.lastcaptured)
852 if(e.iscaptured) // don't mess up build bars!
856 WaypointSprite_UpdateMaxHealth(e.sprite, 0);
860 WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
861 WaypointSprite_UpdateHealth(e.sprite, e.goalentity.health);
866 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
867 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
869 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
873 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
874 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, FALSE));
876 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
878 WaypointSprite_Ping(e.sprite);
880 e.lastteam = e.team + 2;
882 e.lastcaptured = e.iscaptured;
886 void onslaught_generator_reset()
888 self.team = self.team_saved;
889 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
890 self.takedamage = DAMAGE_AIM;
891 self.bot_attack = TRUE;
892 self.iscaptured = TRUE;
893 self.islinked = TRUE;
894 self.isshielded = TRUE;
895 self.enemy.solid = SOLID_NOT;
896 self.think = onslaught_generator_delayed;
897 self.nextthink = time + 0.2;
898 setmodel(self, "models/onslaught/generator.md3");
900 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
901 WaypointSprite_UpdateHealth(self.sprite, self.health);
904 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
907 spawnfunc_onslaught_link entities can target this.
910 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
911 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
913 void spawnfunc_onslaught_generator()
922 precache_model("models/onslaught/generator.md3");
923 precache_model("models/onslaught/generator_shield.md3");
924 precache_model("models/onslaught/generator_dmg1.md3");
925 precache_model("models/onslaught/generator_dmg2.md3");
926 precache_model("models/onslaught/generator_dmg3.md3");
927 precache_model("models/onslaught/generator_dmg4.md3");
928 precache_model("models/onslaught/generator_dmg5.md3");
929 precache_model("models/onslaught/generator_dmg6.md3");
930 precache_model("models/onslaught/generator_dmg7.md3");
931 precache_model("models/onslaught/generator_dmg8.md3");
932 precache_model("models/onslaught/generator_dmg9.md3");
933 precache_model("models/onslaught/generator_dead.md3");
934 precache_model("models/onslaught/boom.md3");
935 precache_model("models/onslaught/shockwave.md3");
936 precache_model("models/onslaught/shockwavetransring.md3");
937 precache_model("models/onslaught/gen_gib1.md3");
938 precache_model("models/onslaught/gen_gib2.md3");
939 precache_model("models/onslaught/gen_gib3.md3");
940 precache_model("models/onslaught/ons_ray.md3");
941 precache_sound("onslaught/generator_decay.wav");
942 precache_sound("weapons/grenade_impact.wav");
943 precache_sound("weapons/rocket_impact.wav");
944 precache_sound("onslaught/generator_underattack.wav");
945 precache_sound("onslaught/shockwave.wav");
946 precache_sound("onslaught/ons_hit1.wav");
947 precache_sound("onslaught/ons_hit2.wav");
948 precache_sound("onslaught/electricity_explode.wav");
950 objerror("team must be set");
951 self.team_saved = self.team;
952 self.colormap = 1024 + (self.team - 1) * 17;
953 self.solid = SOLID_BBOX;
954 self.movetype = MOVETYPE_NONE;
955 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
956 setmodel(self, "models/onslaught/generator.md3");
957 setsize(self, '-52 -52 -14', '52 52 75');
958 setorigin(self, self.origin);
959 self.takedamage = DAMAGE_AIM;
960 self.bot_attack = TRUE;
961 self.event_damage = onslaught_generator_damage;
962 self.iscaptured = TRUE;
963 self.islinked = TRUE;
964 self.isshielded = TRUE;
965 // helper entity that create fx when generator is damaged
966 onslaught_generator_damage_spawn(self);
967 // spawn shield model which indicates whether this can be damaged
968 self.enemy = e = spawn();
969 e.classname = "onslaught_generator_shield";
971 e.movetype = MOVETYPE_NONE;
972 e.effects = EF_ADDITIVE;
973 setmodel(e, "models/onslaught/generator_shield.md3");
974 setorigin(e, self.origin);
975 e.colormap = self.colormap;
977 self.think = onslaught_generator_delayed;
978 self.nextthink = time + 0.2;
979 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
981 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
982 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
983 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
984 WaypointSprite_UpdateHealth(self.sprite, self.health);
986 waypoint_spawnforitem(self);
988 onslaught_updatelinks();
990 self.reset = onslaught_generator_reset;
995 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
996 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
1001 if (self.owner.isshielded)
1003 // this is protected by a shield, so ignore the damage
1004 if (time > self.pain_finished)
1005 if (attacker.classname == "player")
1007 play2(attacker, "onslaught/damageblockedbyshield.wav");
1008 self.pain_finished = time + 1;
1012 if (time > self.pain_finished)
1013 if (attacker.classname == "player")
1015 play2team(self.team, "onslaught/controlpoint_underattack.wav");
1016 self.pain_finished = time + 10;
1018 self.health = self.health - damage;
1019 if(self.owner.iscaptured)
1020 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1022 WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / sys_ticrate));
1023 self.pain_finished = time + 1;
1024 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
1025 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
1026 // colormod flash when shot
1027 self.colormod = '2 2 2';
1028 // particles on every hit
1029 pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
1030 //sound on every hit
1032 sound(self, CHAN_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTN_NORM);
1034 sound(self, CHAN_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTN_NORM);
1036 if (self.health < 0)
1038 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
1039 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
1042 t = ColoredTeamName(attacker.team);
1043 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
1044 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 5, 1, 0);
1045 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 5, 1, 0);
1046 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 5, 1, 0);
1047 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1048 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1049 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1050 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1052 self.owner.goalentity = world;
1053 self.owner.islinked = FALSE;
1054 self.owner.iscaptured = FALSE;
1055 self.owner.team = 0;
1056 self.owner.colormap = 1024;
1058 WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
1060 onslaught_updatelinks();
1062 // Use targets now (somebody make sure this is in the right place..)
1070 self.owner.waslinked = self.owner.islinked;
1071 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
1072 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
1073 //setsize(self, '-32 -32 0', '32 32 8');
1079 void onslaught_controlpoint_icon_think()
1082 self.nextthink = time + sys_ticrate;
1083 if (time > self.pain_finished + 5)
1085 if(self.health < self.max_health)
1087 self.health = self.health + self.count;
1088 if (self.health >= self.max_health)
1089 self.health = self.max_health;
1090 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1093 if (self.health < self.max_health * 0.25)
1094 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
1095 else if (self.health < self.max_health * 0.50)
1096 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
1097 else if (self.health < self.max_health * 0.75)
1098 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
1099 else if (self.health < self.max_health * 0.90)
1100 setmodel(self, "models/onslaught/controlpoint_icon.md3");
1101 // colormod flash when shot
1102 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1104 if(self.owner.islinked != self.owner.waslinked)
1106 // unteam the spawnpoint if needed
1108 t = self.owner.team;
1109 if(!self.owner.islinked)
1110 self.owner.team = 0;
1118 self.owner.team = t;
1120 self.owner.waslinked = self.owner.islinked;
1122 if (self.punchangle_x > 2)
1123 self.punchangle_x = self.punchangle_x - 2;
1124 else if (self.punchangle_x < -2)
1125 self.punchangle_x = self.punchangle_x + 2;
1127 self.punchangle_x = 0;
1128 if (self.punchangle_y > 2)
1129 self.punchangle_y = self.punchangle_y - 2;
1130 else if (self.punchangle_y < -2)
1131 self.punchangle_y = self.punchangle_y + 2;
1133 self.punchangle_y = 0;
1134 if (self.punchangle_z > 2)
1135 self.punchangle_z = self.punchangle_z - 2;
1136 else if (self.punchangle_z < -2)
1137 self.punchangle_z = self.punchangle_z + 2;
1139 self.punchangle_z = 0;
1140 self.angles_x = self.punchangle_x;
1141 self.angles_y = self.punchangle_y + self.mangle_y;
1142 self.angles_z = self.punchangle_z;
1143 self.mangle_y = self.mangle_y + 1.5;
1145 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd / 8));
1146 self.cp_bob_spd = self.cp_bob_spd + 0.5;
1147 if(self.cp_bob_dmg_z > 0)
1148 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 0.1;
1150 self.cp_bob_dmg_z = 0;
1151 self.origin = self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg;
1154 if(random() < 0.6 - self.health / self.max_health)
1156 pointparticles(particleeffectnum("electricity_sparks"), self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
1159 sound(self, CHAN_PAIN, "onslaught/ons_spark1.wav", VOL_BASE, ATTN_NORM);
1160 else if (random() > 0.5)
1161 sound(self, CHAN_PAIN, "onslaught/ons_spark2.wav", VOL_BASE, ATTN_NORM);
1165 void onslaught_controlpoint_icon_buildthink()
1170 self.nextthink = time + sys_ticrate;
1172 // only do this if there is power
1173 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
1177 self.health = self.health + self.count;
1179 if (self.health >= self.max_health)
1181 self.health = self.max_health;
1182 self.count = cvar("g_onslaught_cp_regen") * sys_ticrate; // slow repair rate from now on
1183 self.think = onslaught_controlpoint_icon_think;
1184 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
1185 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
1186 self.owner.iscaptured = TRUE;
1188 WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
1189 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1191 onslaught_updatelinks();
1193 // Use targets now (somebody make sure this is in the right place..)
1199 self.cp_origin = self.origin;
1200 self.cp_bob_origin = '0 0 0.1';
1201 self.cp_bob_spd = 0;
1203 self.alpha = self.health / self.max_health;
1204 // colormod flash when shot
1205 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1206 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
1207 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
1208 //setsize(self, '-32 -32 0', '32 32 8');
1210 if(random() < 0.9 - self.health / self.max_health)
1211 pointparticles(particleeffectnum("rage"), self.origin + 10 * randomvec(), '0 0 -1', 1);
1217 void onslaught_controlpoint_touch()
1221 if (other.classname != "player")
1223 a = onslaught_controlpoint_attackable(self, other.team);
1224 if(a != 2 && a != 4)
1226 // we've verified that this player has a legitimate claim to this point,
1227 // so start building the captured point icon (which only captures this
1228 // point if it successfully builds without being destroyed first)
1229 self.goalentity = e = spawn();
1230 e.classname = "onslaught_controlpoint_icon";
1232 e.max_health = cvar("g_onslaught_cp_health");
1233 e.health = cvar("g_onslaught_cp_buildhealth");
1234 e.solid = SOLID_BBOX;
1235 e.movetype = MOVETYPE_NONE;
1236 setmodel(e, "models/onslaught/controlpoint_icon.md3");
1237 setsize(e, '-32 -32 -32', '32 32 32');
1238 setorigin(e, self.origin + '0 0 96');
1239 e.takedamage = DAMAGE_AIM;
1240 e.bot_attack = TRUE;
1241 e.event_damage = onslaught_controlpoint_icon_damage;
1242 e.team = other.team;
1243 e.colormap = 1024 + (e.team - 1) * 17;
1244 e.think = onslaught_controlpoint_icon_buildthink;
1245 e.nextthink = time + sys_ticrate;
1246 e.count = (e.max_health - e.health) * sys_ticrate / cvar("g_onslaught_cp_buildtime"); // how long it takes to build
1247 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
1249 self.colormap = e.colormap;
1250 WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / sys_ticrate));
1251 onslaught_updatelinks();
1254 void onslaught_controlpoint_reset()
1256 if(self.goalentity && self.goalentity != world)
1257 remove(self.goalentity);
1258 self.goalentity = world;
1260 self.colormap = 1024;
1261 self.iscaptured = FALSE;
1262 self.islinked = FALSE;
1263 self.isshielded = TRUE;
1264 self.enemy.solid = SOLID_NOT;
1265 self.enemy.colormap = self.colormap;
1266 self.think = self.enemy.think = SUB_Null;
1267 self.nextthink = 0; // don't like SUB_Null :P
1268 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1269 //setsize(self, '-32 -32 0', '32 32 8');
1271 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
1273 onslaught_updatelinks();
1276 SUB_UseTargets(); // to reset the structures, playerspawns etc.
1279 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
1280 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
1282 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
1285 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
1286 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
1287 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
1289 void spawnfunc_onslaught_controlpoint()
1297 precache_model("models/onslaught/controlpoint_pad.md3");
1298 precache_model("models/onslaught/controlpoint_pad2.md3");
1299 precache_model("models/onslaught/controlpoint_shield.md3");
1300 precache_model("models/onslaught/controlpoint_icon.md3");
1301 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
1302 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
1303 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
1304 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
1305 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
1306 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
1307 precache_sound("onslaught/controlpoint_build.wav");
1308 precache_sound("onslaught/controlpoint_built.wav");
1309 precache_sound("weapons/grenade_impact.wav");
1310 precache_sound("onslaught/damageblockedbyshield.wav");
1311 precache_sound("onslaught/controlpoint_underattack.wav");
1312 precache_sound("onslaught/ons_spark1.wav");
1313 precache_sound("onslaught/ons_spark2.wav");
1314 self.solid = SOLID_BBOX;
1315 self.movetype = MOVETYPE_NONE;
1316 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1317 //setsize(self, '-32 -32 0', '32 32 8');
1318 setorigin(self, self.origin);
1319 self.touch = onslaught_controlpoint_touch;
1321 self.colormap = 1024;
1322 self.iscaptured = FALSE;
1323 self.islinked = FALSE;
1324 self.isshielded = TRUE;
1325 // spawn shield model which indicates whether this can be damaged
1326 self.enemy = e = spawn();
1327 e.classname = "onslaught_controlpoint_shield";
1328 e.solid = SOLID_NOT;
1329 e.movetype = MOVETYPE_NONE;
1330 e.effects = EF_ADDITIVE;
1331 setmodel(e, "models/onslaught/controlpoint_shield.md3");
1332 //setsize(e, '-32 -32 0', '32 32 128');
1333 setorigin(e, self.origin);
1334 e.colormap = self.colormap;
1336 waypoint_spawnforitem(self);
1338 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
1339 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
1341 onslaught_updatelinks();
1343 self.reset = onslaught_controlpoint_reset;
1346 float onslaught_link_send(entity to, float sendflags)
1348 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1349 WriteByte(MSG_ENTITY, sendflags);
1352 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
1353 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
1354 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1358 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1359 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1360 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1364 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1369 void onslaught_link_checkupdate()
1371 // TODO check if the two sides have moved (currently they won't move anyway)
1372 float redpower, bluepower;
1374 redpower = bluepower = 0;
1375 if(self.goalentity.islinked)
1377 if(self.goalentity.team == COLOR_TEAM1)
1379 else if(self.goalentity.team == COLOR_TEAM2)
1382 if(self.enemy.islinked)
1384 if(self.enemy.team == COLOR_TEAM1)
1386 else if(self.enemy.team == COLOR_TEAM2)
1391 if(redpower == 1 && bluepower == 2)
1392 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1393 else if(redpower == 2 && bluepower == 1)
1394 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1396 cc = (COLOR_TEAM1 - 1) * 0x11;
1398 cc = (COLOR_TEAM2 - 1) * 0x11;
1402 //print(etos(self), " rp=", ftos(redpower), " bp=", ftos(bluepower), " ");
1403 //print("cc=", ftos(cc), "\n");
1405 if(cc != self.clientcolors)
1407 self.clientcolors = cc;
1408 self.SendFlags |= 4;
1411 self.nextthink = time;
1414 void onslaught_link_delayed()
1416 self.goalentity = find(world, targetname, self.target);
1417 self.enemy = find(world, targetname, self.target2);
1418 if (!self.goalentity)
1419 objerror("can not find target\n");
1421 objerror("can not find target2\n");
1422 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1423 self.SendFlags |= 3;
1424 self.think = onslaught_link_checkupdate;
1425 self.nextthink = time;
1428 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1429 Link between control points.
1431 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.
1434 "target" - first control point.
1435 "target2" - second control point.
1437 void spawnfunc_onslaught_link()
1444 if (self.target == "" || self.target2 == "")
1445 objerror("target and target2 must be set\n");
1446 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1447 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);