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);
407 if (cvar("timelimit"))
408 if (time > game_starttime + cvar("timelimit") * 60)
410 // self.max_health / 300 gives 5 minutes of overtime.
411 // control points reduce the overtime duration.
412 sound(self, CHAN_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTN_NORM);
414 e = findchain(classname, "onslaught_controlpoint");
417 if (e.team != self.team)
422 d = d * self.max_health / 300;
423 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
428 void onslaught_generator_ring_think()
430 self.nextthink = time + 0.05;
433 self.think = SUB_Remove;
437 self.scale = self.count * 4;
439 self.frame = self.count;
445 void onslaught_generator_ring_spawn(vector org)
449 setmodel(e, "models/onslaught/shockwavetransring.md3");
455 e.think = onslaught_generator_ring_think;
456 e.nextthink = time + 0.05;
458 void onslaught_generator_ray_think()
460 self.nextthink = time + 0.05;
463 self.think = SUB_Remove;
476 void onslaught_generator_ray_spawn(vector org)
480 setmodel(e, "models/onslaught/ons_ray.md3");
482 e.angles = randomvec() * 360;
484 e.scale = random() * 5 + 8;
485 e.think = onslaught_generator_ray_think;
486 e.nextthink = time + 0.05;
489 void onslaught_generator_shockwave_think()
491 self.nextthink = time + 0.05;
494 self.think = SUB_Remove;
503 self.scale = self.count * 4;
504 setsize(self, self.mins * self.scale, self.maxs * self.scale);
505 self.frame = self.count;
510 void onslaught_generator_shockwave_spawn(vector org)
514 setmodel(e, "models/onslaught/shockwave.md3");
522 e.think = onslaught_generator_shockwave_think;
523 e.nextthink = time + 0.05;
526 void onslaught_generator_damage_think()
528 if(self.owner.health < 0)
530 self.think = SUB_Remove;
533 self.nextthink = time+0.1;
535 // damaged fx (less probable the more damaged is the generator)
536 if(random() < 0.9 - self.owner.health / self.owner.max_health)
539 pointparticles(particleeffectnum("electro_ballexplode"), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
540 sound(self, CHAN_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM);
543 pointparticles(particleeffectnum("torch_small"), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
546 void onslaught_generator_damage_spawn(entity gd_owner)
551 e.health = self.owner.health;
552 setorigin(e, gd_owner.origin);
553 e.think = onslaught_generator_damage_think;
554 e.nextthink = time+1;
557 void onslaught_generator_deaththink()
566 if(self.count==40||self.count==20)
568 onslaught_generator_ring_spawn(self.origin);
569 sound(self, CHAN_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTN_NORM);
577 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 25, 1, 1);
579 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 20, 1, 1);
581 ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 15, 1, 1);
587 org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
588 onslaught_generator_boom_spawn(org, (6-i)/5+0.3);
591 // Short explosion sound + small explosion
594 te_explosion(self.origin);
595 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
599 org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
600 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
605 onslaught_generator_ray_spawn(self.origin);
613 onslaught_generator_shockwave_spawn(org);
614 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
615 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
618 self.nextthink = time + 0.05;
620 self.count = self.count - 1;
623 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
630 if (attacker != self)
634 // this is protected by a shield, so ignore the damage
635 if (time > self.pain_finished)
636 if (attacker.classname == "player")
638 play2(attacker, "onslaught/damageblockedbyshield.wav");
639 self.pain_finished = time + 1;
643 if (time > self.pain_finished)
645 self.pain_finished = time + 10;
646 bprint(ColoredTeamName(self.team), " generator under attack!\n");
647 play2team(self.team, "onslaught/generator_underattack.wav");
650 self.health = self.health - damage;
651 WaypointSprite_UpdateHealth(self.sprite, self.health);
652 // choose an animation frame based on health
653 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
654 // see if the generator is still functional, or dying
657 #ifdef ONSLAUGHT_SPAM
659 lh = ceil(self.lasthealth / 100) * 100;
660 h = ceil(self.health / 100) * 100;
662 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
664 self.lasthealth = self.health;
666 else if not(inWarmupStage)
668 if (attacker == self)
669 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
673 t = ColoredTeamName(attacker.team);
674 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
676 self.iscaptured = FALSE;
677 self.islinked = FALSE;
678 self.isshielded = FALSE;
679 self.takedamage = DAMAGE_NO; // can't be hurt anymore
680 self.event_damage = SUB_Null; // won't do anything if hurt
681 self.count = 0; // reset counter
682 self.think = onslaught_generator_deaththink; // explosion sequence
683 self.nextthink = time; // start exploding immediately
684 self.think(); // do the first explosion now
686 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
688 onslaught_updatelinks();
692 setmodel(self, "models/onslaught/generator_dead.md3");
693 else if(self.health < self.max_health * 0.10)
694 setmodel(self, "models/onslaught/generator_dmg9.md3");
695 else if(self.health < self.max_health * 0.20)
696 setmodel(self, "models/onslaught/generator_dmg8.md3");
697 else if(self.health < self.max_health * 0.30)
698 setmodel(self, "models/onslaught/generator_dmg7.md3");
699 else if(self.health < self.max_health * 0.40)
700 setmodel(self, "models/onslaught/generator_dmg6.md3");
701 else if(self.health < self.max_health * 0.50)
702 setmodel(self, "models/onslaught/generator_dmg5.md3");
703 else if(self.health < self.max_health * 0.60)
704 setmodel(self, "models/onslaught/generator_dmg4.md3");
705 else if(self.health < self.max_health * 0.70)
706 setmodel(self, "models/onslaught/generator_dmg3.md3");
707 else if(self.health < self.max_health * 0.80)
708 setmodel(self, "models/onslaught/generator_dmg2.md3");
709 else if(self.health < self.max_health * 0.90)
710 setmodel(self, "models/onslaught/generator_dmg1.md3");
711 setsize(self, '-52 -52 -14', '52 52 75');
713 // Throw some flaming gibs on damage, more damage = more chance for gib
714 if(random() < damage/220)
716 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
719 ons_throwgib(hitloc, (force * -1) + '0 0 40', "models/onslaught/gen_gib1.md3", 7, 1, 1);
721 ons_throwgib(hitloc, (force * -1)+ '0 0 40', "models/onslaught/gen_gib2.md3", 6, 1, 1);
723 ons_throwgib(hitloc, (force * -1)+ '0 0 40', "models/onslaught/gen_gib3.md3", 5, 1, 1);
727 // particles on every hit
728 pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
732 sound(self, CHAN_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTN_NORM);
734 sound(self, CHAN_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM);
737 //throw some gibs on damage
738 if(random() < damage/200+0.2)
740 ons_throwgib(hitloc, randomvec()*360, "models/onslaught/gen_gib1.md3", 1, 1, 0);
743 // update links after a delay
744 void onslaught_generator_delayed()
746 onslaught_updatelinks();
747 // now begin normal thinking
748 self.think = onslaught_generator_think;
749 self.nextthink = time;
752 string onslaught_generator_waypointsprite_for_team(entity e, float t)
756 if(e.team == COLOR_TEAM1)
757 return "ons-gen-red";
758 else if(e.team == COLOR_TEAM2)
759 return "ons-gen-blue";
762 return "ons-gen-shielded";
763 if(e.team == COLOR_TEAM1)
764 return "ons-gen-red";
765 else if(e.team == COLOR_TEAM2)
766 return "ons-gen-blue";
770 void onslaught_generator_updatesprite(entity e)
773 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
774 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
775 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
776 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
778 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
780 e.lastteam = e.team + 2;
781 e.lastshielded = e.isshielded;
784 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
785 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
787 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
791 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
792 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, FALSE));
794 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
796 WaypointSprite_Ping(e.sprite);
800 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
805 a = onslaught_controlpoint_attackable(e, t);
806 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
808 if(e.team == COLOR_TEAM1)
809 return "ons-cp-atck-red";
810 else if(e.team == COLOR_TEAM2)
811 return "ons-cp-atck-blue";
813 return "ons-cp-atck-neut";
815 else if(a == -2) // DEFEND THIS ONE NOW
817 if(e.team == COLOR_TEAM1)
818 return "ons-cp-dfnd-red";
819 else if(e.team == COLOR_TEAM2)
820 return "ons-cp-dfnd-blue";
822 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
824 if(e.team == COLOR_TEAM1)
826 else if(e.team == COLOR_TEAM2)
827 return "ons-cp-blue";
829 else if(a == 2) // touch it
830 return "ons-cp-neut";
834 if(e.team == COLOR_TEAM1)
836 else if(e.team == COLOR_TEAM2)
837 return "ons-cp-blue";
839 return "ons-cp-neut";
844 void onslaught_controlpoint_updatesprite(entity e)
847 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
848 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
849 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
850 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
853 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
855 if(e.lastteam != e.team + 2 || e.lastshielded != sh || e.iscaptured != e.lastcaptured)
857 if(e.iscaptured) // don't mess up build bars!
861 WaypointSprite_UpdateMaxHealth(e.sprite, 0);
865 WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
866 WaypointSprite_UpdateHealth(e.sprite, e.goalentity.health);
871 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
872 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
874 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
878 if(e.team == COLOR_TEAM1 || e.team == COLOR_TEAM2)
879 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, FALSE));
881 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
883 WaypointSprite_Ping(e.sprite);
885 e.lastteam = e.team + 2;
887 e.lastcaptured = e.iscaptured;
891 void onslaught_generator_reset()
893 self.team = self.team_saved;
894 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
895 self.takedamage = DAMAGE_AIM;
896 self.bot_attack = TRUE;
897 self.iscaptured = TRUE;
898 self.islinked = TRUE;
899 self.isshielded = TRUE;
900 self.enemy.solid = SOLID_NOT;
901 self.think = onslaught_generator_delayed;
902 self.nextthink = time + 0.2;
903 setmodel(self, "models/onslaught/generator.md3");
905 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
906 WaypointSprite_UpdateHealth(self.sprite, self.health);
909 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
912 spawnfunc_onslaught_link entities can target this.
915 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
916 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
918 void spawnfunc_onslaught_generator()
927 precache_model("models/onslaught/generator.md3");
928 precache_model("models/onslaught/generator_shield.md3");
929 precache_model("models/onslaught/generator_dmg1.md3");
930 precache_model("models/onslaught/generator_dmg2.md3");
931 precache_model("models/onslaught/generator_dmg3.md3");
932 precache_model("models/onslaught/generator_dmg4.md3");
933 precache_model("models/onslaught/generator_dmg5.md3");
934 precache_model("models/onslaught/generator_dmg6.md3");
935 precache_model("models/onslaught/generator_dmg7.md3");
936 precache_model("models/onslaught/generator_dmg8.md3");
937 precache_model("models/onslaught/generator_dmg9.md3");
938 precache_model("models/onslaught/generator_dead.md3");
939 precache_model("models/onslaught/boom.md3");
940 precache_model("models/onslaught/shockwave.md3");
941 precache_model("models/onslaught/shockwavetransring.md3");
942 precache_model("models/onslaught/gen_gib1.md3");
943 precache_model("models/onslaught/gen_gib2.md3");
944 precache_model("models/onslaught/gen_gib3.md3");
945 precache_model("models/onslaught/ons_ray.md3");
946 precache_sound("onslaught/generator_decay.wav");
947 precache_sound("weapons/grenade_impact.wav");
948 precache_sound("weapons/rocket_impact.wav");
949 precache_sound("onslaught/generator_underattack.wav");
950 precache_sound("onslaught/shockwave.wav");
951 precache_sound("onslaught/ons_hit1.wav");
952 precache_sound("onslaught/ons_hit2.wav");
953 precache_sound("onslaught/electricity_explode.wav");
955 objerror("team must be set");
956 self.team_saved = self.team;
957 self.colormap = 1024 + (self.team - 1) * 17;
958 self.solid = SOLID_BBOX;
959 self.movetype = MOVETYPE_NONE;
960 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
961 setmodel(self, "models/onslaught/generator.md3");
962 setsize(self, '-52 -52 -14', '52 52 75');
963 setorigin(self, self.origin);
964 self.takedamage = DAMAGE_AIM;
965 self.bot_attack = TRUE;
966 self.event_damage = onslaught_generator_damage;
967 self.iscaptured = TRUE;
968 self.islinked = TRUE;
969 self.isshielded = TRUE;
970 // helper entity that create fx when generator is damaged
971 onslaught_generator_damage_spawn(self);
972 // spawn shield model which indicates whether this can be damaged
973 self.enemy = e = spawn();
974 e.classname = "onslaught_generator_shield";
976 e.movetype = MOVETYPE_NONE;
977 e.effects = EF_ADDITIVE;
978 setmodel(e, "models/onslaught/generator_shield.md3");
979 setorigin(e, self.origin);
980 e.colormap = self.colormap;
982 self.think = onslaught_generator_delayed;
983 self.nextthink = time + 0.2;
984 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
986 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
987 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
988 WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
989 WaypointSprite_UpdateHealth(self.sprite, self.health);
991 waypoint_spawnforitem(self);
993 onslaught_updatelinks();
995 self.reset = onslaught_generator_reset;
1000 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
1002 float ons_notification_time_team1;
1003 float ons_notification_time_team2;
1005 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
1012 if (self.owner.isshielded)
1014 // this is protected by a shield, so ignore the damage
1015 if (time > self.pain_finished)
1016 if (attacker.classname == "player")
1018 play2(attacker, "onslaught/damageblockedbyshield.wav");
1019 self.pain_finished = time + 1;
1024 if (attacker.classname == "player")
1026 if(self.team == COLOR_TEAM1)
1028 if(time - ons_notification_time_team1 > 10)
1031 ons_notification_time_team1 = time;
1034 else if(self.team == COLOR_TEAM2)
1036 if(time - ons_notification_time_team2 > 10)
1039 ons_notification_time_team2 = time;
1046 play2team(self.team, "onslaught/controlpoint_underattack.wav");
1049 self.health = self.health - damage;
1050 if(self.owner.iscaptured)
1051 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1053 WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / sys_ticrate));
1054 self.pain_finished = time + 1;
1055 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
1056 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
1057 // colormod flash when shot
1058 self.colormod = '2 2 2';
1059 // particles on every hit
1060 pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
1061 //sound on every hit
1063 sound(self, CHAN_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTN_NORM);
1065 sound(self, CHAN_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTN_NORM);
1067 if (self.health < 0)
1069 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
1070 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
1073 t = ColoredTeamName(attacker.team);
1074 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
1075 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 5, 1, 0);
1076 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 5, 1, 0);
1077 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 5, 1, 0);
1078 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1079 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1080 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1081 ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 5, 1, 0);
1083 self.owner.goalentity = world;
1084 self.owner.islinked = FALSE;
1085 self.owner.iscaptured = FALSE;
1086 self.owner.team = 0;
1087 self.owner.colormap = 1024;
1089 WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
1091 onslaught_updatelinks();
1093 // Use targets now (somebody make sure this is in the right place..)
1101 self.owner.waslinked = self.owner.islinked;
1102 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
1103 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
1104 //setsize(self, '-32 -32 0', '32 32 8');
1110 void onslaught_controlpoint_icon_think()
1113 self.nextthink = time + sys_ticrate;
1114 if (time > self.pain_finished + 5)
1116 if(self.health < self.max_health)
1118 self.health = self.health + self.count;
1119 if (self.health >= self.max_health)
1120 self.health = self.max_health;
1121 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1124 if (self.health < self.max_health * 0.25)
1125 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
1126 else if (self.health < self.max_health * 0.50)
1127 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
1128 else if (self.health < self.max_health * 0.75)
1129 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
1130 else if (self.health < self.max_health * 0.90)
1131 setmodel(self, "models/onslaught/controlpoint_icon.md3");
1132 // colormod flash when shot
1133 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1135 if(self.owner.islinked != self.owner.waslinked)
1137 // unteam the spawnpoint if needed
1139 t = self.owner.team;
1140 if(!self.owner.islinked)
1141 self.owner.team = 0;
1149 self.owner.team = t;
1151 self.owner.waslinked = self.owner.islinked;
1153 if (self.punchangle_x > 2)
1154 self.punchangle_x = self.punchangle_x - 2;
1155 else if (self.punchangle_x < -2)
1156 self.punchangle_x = self.punchangle_x + 2;
1158 self.punchangle_x = 0;
1159 if (self.punchangle_y > 2)
1160 self.punchangle_y = self.punchangle_y - 2;
1161 else if (self.punchangle_y < -2)
1162 self.punchangle_y = self.punchangle_y + 2;
1164 self.punchangle_y = 0;
1165 if (self.punchangle_z > 2)
1166 self.punchangle_z = self.punchangle_z - 2;
1167 else if (self.punchangle_z < -2)
1168 self.punchangle_z = self.punchangle_z + 2;
1170 self.punchangle_z = 0;
1171 self.angles_x = self.punchangle_x;
1172 self.angles_y = self.punchangle_y + self.mangle_y;
1173 self.angles_z = self.punchangle_z;
1174 self.mangle_y = self.mangle_y + 1.5;
1176 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd / 8));
1177 self.cp_bob_spd = self.cp_bob_spd + 0.5;
1178 if(self.cp_bob_dmg_z > 0)
1179 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 0.1;
1181 self.cp_bob_dmg_z = 0;
1182 self.origin = self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg;
1185 if(random() < 0.6 - self.health / self.max_health)
1187 pointparticles(particleeffectnum("electricity_sparks"), self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
1190 sound(self, CHAN_PAIN, "onslaught/ons_spark1.wav", VOL_BASE, ATTN_NORM);
1191 else if (random() > 0.5)
1192 sound(self, CHAN_PAIN, "onslaught/ons_spark2.wav", VOL_BASE, ATTN_NORM);
1196 void onslaught_controlpoint_icon_buildthink()
1201 self.nextthink = time + sys_ticrate;
1203 // only do this if there is power
1204 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
1208 self.health = self.health + self.count;
1210 if (self.health >= self.max_health)
1212 self.health = self.max_health;
1213 self.count = cvar("g_onslaught_cp_regen") * sys_ticrate; // slow repair rate from now on
1214 self.think = onslaught_controlpoint_icon_think;
1215 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
1216 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
1217 self.owner.iscaptured = TRUE;
1219 WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
1220 WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
1222 onslaught_updatelinks();
1224 // Use targets now (somebody make sure this is in the right place..)
1230 self.cp_origin = self.origin;
1231 self.cp_bob_origin = '0 0 0.1';
1232 self.cp_bob_spd = 0;
1234 self.alpha = self.health / self.max_health;
1235 // colormod flash when shot
1236 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1237 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
1238 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
1239 //setsize(self, '-32 -32 0', '32 32 8');
1241 if(random() < 0.9 - self.health / self.max_health)
1242 pointparticles(particleeffectnum("rage"), self.origin + 10 * randomvec(), '0 0 -1', 1);
1248 void onslaught_controlpoint_touch()
1252 if (other.classname != "player")
1254 a = onslaught_controlpoint_attackable(self, other.team);
1255 if(a != 2 && a != 4)
1257 // we've verified that this player has a legitimate claim to this point,
1258 // so start building the captured point icon (which only captures this
1259 // point if it successfully builds without being destroyed first)
1260 self.goalentity = e = spawn();
1261 e.classname = "onslaught_controlpoint_icon";
1263 e.max_health = cvar("g_onslaught_cp_health");
1264 e.health = cvar("g_onslaught_cp_buildhealth");
1265 e.solid = SOLID_BBOX;
1266 e.movetype = MOVETYPE_NONE;
1267 setmodel(e, "models/onslaught/controlpoint_icon.md3");
1268 setsize(e, '-32 -32 -32', '32 32 32');
1269 setorigin(e, self.origin + '0 0 96');
1270 e.takedamage = DAMAGE_AIM;
1271 e.bot_attack = TRUE;
1272 e.event_damage = onslaught_controlpoint_icon_damage;
1273 e.team = other.team;
1274 e.colormap = 1024 + (e.team - 1) * 17;
1275 e.think = onslaught_controlpoint_icon_buildthink;
1276 e.nextthink = time + sys_ticrate;
1277 e.count = (e.max_health - e.health) * sys_ticrate / cvar("g_onslaught_cp_buildtime"); // how long it takes to build
1278 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
1280 self.colormap = e.colormap;
1281 WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / sys_ticrate));
1282 onslaught_updatelinks();
1285 void onslaught_controlpoint_reset()
1287 if(self.goalentity && self.goalentity != world)
1288 remove(self.goalentity);
1289 self.goalentity = world;
1291 self.colormap = 1024;
1292 self.iscaptured = FALSE;
1293 self.islinked = FALSE;
1294 self.isshielded = TRUE;
1295 self.enemy.solid = SOLID_NOT;
1296 self.enemy.colormap = self.colormap;
1297 self.think = self.enemy.think = SUB_Null;
1298 self.nextthink = 0; // don't like SUB_Null :P
1299 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1300 //setsize(self, '-32 -32 0', '32 32 8');
1302 WaypointSprite_UpdateMaxHealth(self.sprite, 0);
1304 onslaught_updatelinks();
1307 SUB_UseTargets(); // to reset the structures, playerspawns etc.
1310 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
1311 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
1313 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
1316 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
1317 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
1318 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
1320 void spawnfunc_onslaught_controlpoint()
1328 precache_model("models/onslaught/controlpoint_pad.md3");
1329 precache_model("models/onslaught/controlpoint_pad2.md3");
1330 precache_model("models/onslaught/controlpoint_shield.md3");
1331 precache_model("models/onslaught/controlpoint_icon.md3");
1332 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
1333 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
1334 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
1335 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
1336 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
1337 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
1338 precache_sound("onslaught/controlpoint_build.wav");
1339 precache_sound("onslaught/controlpoint_built.wav");
1340 precache_sound("weapons/grenade_impact.wav");
1341 precache_sound("onslaught/damageblockedbyshield.wav");
1342 precache_sound("onslaught/controlpoint_underattack.wav");
1343 precache_sound("onslaught/ons_spark1.wav");
1344 precache_sound("onslaught/ons_spark2.wav");
1345 self.solid = SOLID_BBOX;
1346 self.movetype = MOVETYPE_NONE;
1347 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1348 //setsize(self, '-32 -32 0', '32 32 8');
1349 setorigin(self, self.origin);
1350 self.touch = onslaught_controlpoint_touch;
1352 self.colormap = 1024;
1353 self.iscaptured = FALSE;
1354 self.islinked = FALSE;
1355 self.isshielded = TRUE;
1356 // spawn shield model which indicates whether this can be damaged
1357 self.enemy = e = spawn();
1358 e.classname = "onslaught_controlpoint_shield";
1359 e.solid = SOLID_NOT;
1360 e.movetype = MOVETYPE_NONE;
1361 e.effects = EF_ADDITIVE;
1362 setmodel(e, "models/onslaught/controlpoint_shield.md3");
1363 //setsize(e, '-32 -32 0', '32 32 128');
1364 setorigin(e, self.origin);
1365 e.colormap = self.colormap;
1367 waypoint_spawnforitem(self);
1369 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
1370 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
1372 onslaught_updatelinks();
1374 self.reset = onslaught_controlpoint_reset;
1377 float onslaught_link_send(entity to, float sendflags)
1379 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1380 WriteByte(MSG_ENTITY, sendflags);
1383 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
1384 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
1385 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1389 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1390 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1391 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1395 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1400 void onslaught_link_checkupdate()
1402 // TODO check if the two sides have moved (currently they won't move anyway)
1403 float redpower, bluepower;
1405 redpower = bluepower = 0;
1406 if(self.goalentity.islinked)
1408 if(self.goalentity.team == COLOR_TEAM1)
1410 else if(self.goalentity.team == COLOR_TEAM2)
1413 if(self.enemy.islinked)
1415 if(self.enemy.team == COLOR_TEAM1)
1417 else if(self.enemy.team == COLOR_TEAM2)
1422 if(redpower == 1 && bluepower == 2)
1423 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1424 else if(redpower == 2 && bluepower == 1)
1425 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1427 cc = (COLOR_TEAM1 - 1) * 0x11;
1429 cc = (COLOR_TEAM2 - 1) * 0x11;
1433 //print(etos(self), " rp=", ftos(redpower), " bp=", ftos(bluepower), " ");
1434 //print("cc=", ftos(cc), "\n");
1436 if(cc != self.clientcolors)
1438 self.clientcolors = cc;
1439 self.SendFlags |= 4;
1442 self.nextthink = time;
1445 void onslaught_link_delayed()
1447 self.goalentity = find(world, targetname, self.target);
1448 self.enemy = find(world, targetname, self.target2);
1449 if (!self.goalentity)
1450 objerror("can not find target\n");
1452 objerror("can not find target2\n");
1453 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1454 self.SendFlags |= 3;
1455 self.think = onslaught_link_checkupdate;
1456 self.nextthink = time;
1459 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1460 Link between control points.
1462 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.
1465 "target" - first control point.
1466 "target2" - second control point.
1468 void spawnfunc_onslaught_link()
1475 if (self.target == "" || self.target2 == "")
1476 objerror("target and target2 must be set\n");
1477 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1478 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);