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;
20 void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
22 self.velocity += vforce;
26 vector v_from, vector v_to, vector v_colormod,
28 float f_lifetime, float f_fadetime, float b_burn)
35 gib.classname = "turret_gib";
37 setorigin(gib,v_from);
38 SUB_SetFade(gib,time + f_lifetime,2);
40 gib.solid = SOLID_BBOX;
42 gib.movetype = MOVETYPE_BOUNCE;
43 gib.takedamage = DAMAGE_YES;
44 gib.event_damage = ons_gib_damage;
46 gib.effects = EF_LOWPRECISION;
47 gib.flags = FL_NOTARGET;
48 gib.colormod = v_colormod;
54 burn.effects = EF_LOWPRECISION;//|EF_FLAME;
55 setattachment(burn,gib,"");
56 setorigin(burn,(gib.mins + gib.maxs) * 0.5);
57 SUB_SetFade(burn,time + (f_lifetime * 0.5) ,2);
61 void onslaught_updatelinks()
63 local entity l, links;
64 local float stop, t1, t2, t3, t4;
65 // first check if the game has ended
66 dprint("--- updatelinks ---\n");
67 links = findchain(classname, "onslaught_link");
68 // mark generators as being shielded and networked
69 l = findchain(classname, "onslaught_generator");
73 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
75 dprint(etos(l), " (generator) is destroyed\n");
76 l.islinked = l.iscaptured;
77 l.isshielded = l.iscaptured;
80 // mark points as shielded and not networked
81 l = findchain(classname, "onslaught_controlpoint");
86 l.isgenneighbor_red = FALSE;
87 l.isgenneighbor_blue = FALSE;
88 l.iscpneighbor_red = FALSE;
89 l.iscpneighbor_blue = FALSE;
90 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
93 // flow power outward from the generators through the network
97 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
107 // if both points are captured by the same team, and only one of
108 // them is powered, mark the other one as powered as well
109 if (l.enemy.iscaptured && l.goalentity.iscaptured)
110 if (l.enemy.islinked != l.goalentity.islinked)
111 if (l.enemy.team == l.goalentity.team)
113 if (!l.goalentity.islinked)
116 l.goalentity.islinked = TRUE;
117 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
119 else if (!l.enemy.islinked)
122 l.enemy.islinked = TRUE;
123 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
129 // now that we know which points are powered we can mark their neighbors
130 // as unshielded if team differs
134 if (l.goalentity.team != l.enemy.team)
136 if (l.goalentity.islinked)
138 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
139 l.enemy.isshielded = FALSE;
140 if(l.goalentity.classname == "onslaught_generator")
142 if(l.goalentity.team == COLOR_TEAM1)
143 l.enemy.isgenneighbor_red = TRUE;
144 else if(l.goalentity.team == COLOR_TEAM2)
145 l.enemy.isgenneighbor_blue = TRUE;
149 if(l.goalentity.team == COLOR_TEAM1)
150 l.enemy.iscpneighbor_red = TRUE;
151 else if(l.goalentity.team == COLOR_TEAM2)
152 l.enemy.iscpneighbor_blue = TRUE;
155 if (l.enemy.islinked)
157 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
158 l.goalentity.isshielded = FALSE;
159 if(l.enemy.classname == "onslaught_generator")
161 if(l.enemy.team == COLOR_TEAM1)
162 l.goalentity.isgenneighbor_red = TRUE;
163 else if(l.enemy.team == COLOR_TEAM2)
164 l.goalentity.isgenneighbor_blue = TRUE;
168 if(l.enemy.team == COLOR_TEAM1)
169 l.goalentity.iscpneighbor_red = TRUE;
170 else if(l.enemy.team == COLOR_TEAM2)
171 l.goalentity.iscpneighbor_blue = TRUE;
177 // now update the takedamage and alpha variables on generator shields
178 l = findchain(classname, "onslaught_generator");
183 dprint(etos(l), " (generator) is shielded\n");
185 l.takedamage = DAMAGE_NO;
186 l.bot_attack = FALSE;
190 dprint(etos(l), " (generator) is not shielded\n");
192 l.takedamage = DAMAGE_AIM;
197 // now update the takedamage and alpha variables on control point icons
198 l = findchain(classname, "onslaught_controlpoint");
203 dprint(etos(l), " (point) is shielded\n");
207 l.goalentity.takedamage = DAMAGE_NO;
208 l.goalentity.bot_attack = FALSE;
213 dprint(etos(l), " (point) is not shielded\n");
217 l.goalentity.takedamage = DAMAGE_AIM;
218 l.goalentity.bot_attack = TRUE;
221 onslaught_controlpoint_updatesprite(l);
224 // count generators owned by each team
225 t1 = t2 = t3 = t4 = 0;
226 l = findchain(classname, "onslaught_generator");
231 if (l.team == COLOR_TEAM1) t1 = 1;
232 if (l.team == COLOR_TEAM2) t2 = 1;
233 if (l.team == COLOR_TEAM3) t3 = 1;
234 if (l.team == COLOR_TEAM4) t4 = 1;
236 onslaught_generator_updatesprite(l);
239 // see if multiple teams remain (if not, it's game over)
240 if (t1 + t2 + t3 + t4 < 2)
241 dprint("--- game over ---\n");
243 dprint("--- done updating links ---\n");
246 float onslaught_controlpoint_can_be_linked(entity cp, float t)
250 if(cp.isgenneighbor_red)
252 if(cp.iscpneighbor_red)
255 else if(t == COLOR_TEAM2)
257 if(cp.isgenneighbor_blue)
259 if(cp.iscpneighbor_blue)
265 // check to see if this player has a legitimate claim to capture this
266 // control point - more specifically that there is a captured path of
267 // points leading back to the team generator
268 e = findchain(classname, "onslaught_link");
271 if (e.goalentity == cp)
273 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
274 if (e.enemy.islinked)
276 dprint(" which is linked");
277 if (e.enemy.team == t)
279 dprint(" and has the correct team!\n");
283 dprint(" but has the wrong team\n");
288 else if (e.enemy == cp)
290 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
291 if (e.goalentity.islinked)
293 dprint(" which is linked");
294 if (e.goalentity.team == t)
296 dprint(" and has a team!\n");
300 dprint(" but has the wrong team\n");
311 float onslaught_controlpoint_attackable(entity cp, float t)
312 // -2: SAME TEAM, attackable by enemy!
317 // 3: attack it (HIGH PRIO)
318 // 4: touch it (HIGH PRIO)
326 else if(cp.goalentity)
328 // if there's already an icon built, nothing happens
331 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
332 if(a) // attackable by enemy?
333 return -2; // EMERGENCY!
336 // we know it can be linked, so no need to check
338 a = onslaught_controlpoint_can_be_linked(cp, t);
339 if(a == 2) // near our generator?
340 return 3; // EMERGENCY!
346 if(onslaught_controlpoint_can_be_linked(cp, t))
348 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
350 return 4; // GET THIS ONE NOW!
352 return 2; // TOUCH ME
358 void onslaught_generator_think()
362 self.nextthink = ceil(time + 1);
363 if (cvar("timelimit"))
364 if (time > cvar("timelimit") * 60 - 60)
366 // self.max_health / 300 gives 5 minutes of overtime.
367 // control points reduce the overtime duration.
368 sound(self, CHAN_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTN_NORM);
370 e = findchain(classname, "onslaught_controlpoint");
373 if (e.team != self.team)
378 d = d * self.max_health / 300;
379 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
383 void onslaught_generator_ring_think()
385 self.nextthink = time;
388 self.think = SUB_Remove;
392 self.scale = self.count * 4;
393 setsize(self, self.mins * self.scale, self.maxs * self.scale);
395 self.frame = self.count * 4;
401 void onslaught_generator_ring_spawn(vector org)
405 setmodel(e, "models/onslaught/shockwavetransring.md3");
411 e.think = onslaught_generator_ring_think;
415 void onslaught_generator_shockwave_think()
417 self.nextthink = time;
420 self.think = SUB_Remove;
429 self.scale = self.count * 4;
430 setsize(self, self.mins * self.scale, self.maxs * self.scale);
431 self.frame = self.count * 4;
436 void onslaught_generator_shockwave_spawn(vector org)
440 setmodel(e, "models/onslaught/shockwave.md3");
446 e.think = onslaught_generator_shockwave_think;
450 void onslaught_generator_boom_think()
452 self.nextthink = time;
455 self.think = SUB_Remove;
465 void onslaught_generator_boom_spawn(vector org, float fscale)
469 setmodel(e, "models/onslaught/boom.md3");
473 setsize(e, e.mins * e.scale, e.maxs * e.scale);
475 e.effects = EF_NOSHADOW;
477 e.think = onslaught_generator_boom_think;
481 void onslaught_generator_deaththink()
484 local float i, scale;
490 if(self.count==40||self.count==20)
492 onslaught_generator_ring_spawn(self.origin);
493 sound(self, CHAN_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTN_NORM);
501 ons_trowgib(self.origin, (100 * randomvec() - '1 1 1') * 25,'1 1 1',"models/onslaught/gen_gib1.md3",20,1,0);
503 ons_trowgib(self.origin, (100 * randomvec() - '1 1 1') * 25,'1 1 1',"models/onslaught/gen_gib2.md3",20,1,0);
505 ons_trowgib(self.origin, (100 * randomvec() - '1 1 1') * 25,'1 1 1',"models/onslaught/gen_gib3.md3",20,1,0);
511 org = self.origin + self.mins;
512 org_z = self.origin_z - 20;
513 org = randompos(org, self.origin + self.maxs + '0 0 20');
515 onslaught_generator_boom_spawn(org, 1);
518 // Short explosion sound + small explosion
521 te_explosion(self.origin);
522 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
526 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
527 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
534 onslaught_generator_shockwave_spawn(org);
535 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
536 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
539 self.nextthink = time;
541 self.count = self.count - 1;
544 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
548 if (attacker != self)
552 // this is protected by a shield, so ignore the damage
553 if (time > self.pain_finished)
554 if (attacker.classname == "player")
556 play2(attacker, "onslaught/damageblockedbyshield.wav");
557 self.pain_finished = time + 1;
561 if (time > self.pain_finished)
563 self.pain_finished = time + 5;
564 bprint(ColoredTeamName(self.team), " generator under attack!\n");
565 play2team(self.team, "onslaught/generator_underattack.wav");
568 self.health = self.health - damage;
569 // choose an animation frame based on health
570 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
571 // see if the generator is still functional, or dying
575 lh = ceil(self.lasthealth / 100) * 100;
576 h = ceil(self.health / 100) * 100;
578 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
579 self.lasthealth = self.health;
583 if (attacker == self)
584 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
588 t = ColoredTeamName(attacker.team);
589 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
591 self.iscaptured = FALSE;
592 self.islinked = FALSE;
593 self.isshielded = FALSE;
594 self.takedamage = DAMAGE_NO; // can't be hurt anymore
595 self.event_damage = SUB_Null; // won't do anything if hurt
596 self.count = 0; // reset counter
597 self.think = onslaught_generator_deaththink; // explosion sequence
598 self.nextthink = time; // start exploding immediately
599 self.think(); // do the first explosion now
600 onslaught_updatelinks();
602 if(self.health < cvar("g_onslaught_gen_health") * 0.90)
603 setmodel(self, "models/onslaught/generator_dmg1.md3");
604 if(self.health < cvar("g_onslaught_gen_health") * 0.80)
605 setmodel(self, "models/onslaught/generator_dmg2.md3");
606 if(self.health < cvar("g_onslaught_gen_health") * 0.70)
607 setmodel(self, "models/onslaught/generator_dmg3.md3");
608 if(self.health < cvar("g_onslaught_gen_health") * 0.60)
609 setmodel(self, "models/onslaught/generator_dmg4.md3");
610 if(self.health < cvar("g_onslaught_gen_health") * 0.50)
611 setmodel(self, "models/onslaught/generator_dmg5.md3");
612 if(self.health < cvar("g_onslaught_gen_health") * 0.40)
613 setmodel(self, "models/onslaught/generator_dmg6.md3");
614 if(self.health < cvar("g_onslaught_gen_health") * 0.30)
615 setmodel(self, "models/onslaught/generator_dmg7.md3");
616 if(self.health < cvar("g_onslaught_gen_health") * 0.20)
617 setmodel(self, "models/onslaught/generator_dmg8.md3");
618 if(self.health < cvar("g_onslaught_gen_health") * 0.10)
619 setmodel(self, "models/onslaught/generator_dmg9.md3");
621 setmodel(self, "models/onslaught/generator_dead.md3");
624 // update links after a delay
625 void onslaught_generator_delayed()
627 onslaught_updatelinks();
628 // now begin normal thinking
629 self.think = onslaught_generator_think;
630 self.nextthink = time;
633 string onslaught_generator_waypointsprite_for_team(entity e, float t)
637 if(e.team == COLOR_TEAM1)
638 return "ons-gen-red";
639 else if(e.team == COLOR_TEAM2)
640 return "ons-gen-blue";
643 return "ons-gen-shielded";
644 if(e.team == COLOR_TEAM1)
645 return "ons-gen-red";
646 else if(e.team == COLOR_TEAM2)
647 return "ons-gen-blue";
651 void onslaught_generator_updatesprite(entity e)
654 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
655 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
656 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
657 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
659 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
661 e.lastteam = e.team + 2;
662 e.lastshielded = e.isshielded;
665 if(e.team == COLOR_TEAM1)
666 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0 0');
667 else if(e.team == COLOR_TEAM2)
668 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 0.5');
670 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
674 if(e.team == COLOR_TEAM1)
675 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '1 0 0');
676 else if(e.team == COLOR_TEAM2)
677 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 1');
679 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
681 WaypointSprite_Ping(e.sprite);
685 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
690 a = onslaught_controlpoint_attackable(e, t);
691 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
693 if(e.team == COLOR_TEAM1)
694 return "ons-cp-atck-red";
695 else if(e.team == COLOR_TEAM2)
696 return "ons-cp-atck-blue";
698 return "ons-cp-atck-neut";
700 else if(a == -2) // DEFEND THIS ONE NOW
702 if(e.team == COLOR_TEAM1)
703 return "ons-cp-dfnd-red";
704 else if(e.team == COLOR_TEAM2)
705 return "ons-cp-dfnd-blue";
707 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
709 if(e.team == COLOR_TEAM1)
711 else if(e.team == COLOR_TEAM2)
712 return "ons-cp-blue";
714 else if(a == 2) // touch it
715 return "ons-cp-neut";
719 if(e.team == COLOR_TEAM1)
721 else if(e.team == COLOR_TEAM2)
722 return "ons-cp-blue";
724 return "ons-cp-neut";
729 void onslaught_controlpoint_updatesprite(entity e)
732 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
733 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
734 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
735 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
738 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
740 if(e.lastteam != e.team + 2 || e.lastshielded != sh)
742 e.lastteam = e.team + 2;
746 if(e.team == COLOR_TEAM1)
747 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0 0');
748 else if(e.team == COLOR_TEAM2)
749 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 0.5');
751 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
755 if(e.team == COLOR_TEAM1)
756 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '1 0 0');
757 else if(e.team == COLOR_TEAM2)
758 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 1');
760 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
762 WaypointSprite_Ping(e.sprite);
766 void onslaught_generator_reset()
768 self.team = self.team_saved;
769 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
770 self.takedamage = DAMAGE_AIM;
771 self.bot_attack = TRUE;
772 self.iscaptured = TRUE;
773 self.islinked = TRUE;
774 self.isshielded = TRUE;
775 self.enemy.solid = SOLID_NOT;
776 self.think = onslaught_generator_delayed;
777 self.nextthink = time + 0.2;
780 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
783 spawnfunc_onslaught_link entities can target this.
786 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
787 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
789 void spawnfunc_onslaught_generator()
798 precache_model("models/onslaught/generator.md3");
799 precache_model("models/onslaught/generator_shield.md3");
800 precache_model("models/onslaught/generator_dmg1.md3");
801 precache_model("models/onslaught/generator_dmg2.md3");
802 precache_model("models/onslaught/generator_dmg3.md3");
803 precache_model("models/onslaught/generator_dmg4.md3");
804 precache_model("models/onslaught/generator_dmg5.md3");
805 precache_model("models/onslaught/generator_dmg6.md3");
806 precache_model("models/onslaught/generator_dmg7.md3");
807 precache_model("models/onslaught/generator_dmg8.md3");
808 precache_model("models/onslaught/generator_dmg9.md3");
809 precache_model("models/onslaught/generator_dead.md3");
810 precache_model("models/onslaught/boom.md3");
811 precache_model("models/onslaught/shockwave.md3");
812 precache_model("models/onslaught/shockwavetransring.md3");
813 precache_model("models/onslaught/gen_gib1.md3");
814 precache_model("models/onslaught/gen_gib2.md3");
815 precache_model("models/onslaught/gen_gib3.md3");
816 precache_sound("onslaught/generator_decay.wav");
817 precache_sound("weapons/grenade_impact.wav");
818 precache_sound("weapons/rocket_impact.wav");
819 precache_sound("onslaught/generator_underattack.wav");
820 precache_sound("onslaught/shockwave.wav");
822 objerror("team must be set");
823 self.team_saved = self.team;
824 self.colormap = 1024 + (self.team - 1) * 17;
825 self.solid = SOLID_BSP;
826 self.movetype = MOVETYPE_NONE;
827 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
828 setmodel(self, "models/onslaught/generator.md3");
829 //setsize(self, '-32 -32 -24', '32 32 64');
830 setorigin(self, self.origin);
831 self.takedamage = DAMAGE_AIM;
832 self.bot_attack = TRUE;
833 self.event_damage = onslaught_generator_damage;
834 self.iscaptured = TRUE;
835 self.islinked = TRUE;
836 self.isshielded = TRUE;
837 // spawn shield model which indicates whether this can be damaged
838 self.enemy = e = spawn();
839 e.classname = "onslaught_generator_shield";
841 e.movetype = MOVETYPE_NONE;
842 e.effects = EF_ADDITIVE;
843 setmodel(e, "models/onslaught/generator_shield.md3");
844 //setsize(e, '-32 -32 0', '32 32 128');
845 setorigin(e, self.origin);
846 e.colormap = self.colormap;
848 self.think = onslaught_generator_delayed;
849 self.nextthink = time + 0.2;
850 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
852 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
853 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
855 onslaught_updatelinks();
857 self.reset = onslaught_generator_reset;
862 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
863 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
868 if (self.owner.isshielded)
870 // this is protected by a shield, so ignore the damage
871 if (time > self.pain_finished)
872 if (attacker.classname == "player")
874 play2(attacker, "onslaught/damageblockedbyshield.wav");
875 self.pain_finished = time + 1;
879 if (time > self.pain_finished)
880 if (attacker.classname == "player")
882 play2team(self.team, "onslaught/controlpoint_underattack.wav");
883 self.pain_finished = time + 5;
885 self.health = self.health - damage;
886 self.pain_finished = time + 1;
887 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
888 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
889 // colormod flash when shot
890 self.colormod = '2 2 2';
893 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
894 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
897 t = ColoredTeamName(attacker.team);
898 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
899 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 25,'1 1 1',"models/onslaught/controlpoint_icon_gib1.md3",5,1,1);
900 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 45,'1 1 1',"models/onslaught/controlpoint_icon_gib2.md3",5,1,1);
901 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 45,'1 1 1',"models/onslaught/controlpoint_icon_gib2.md3",5,1,1);
902 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
903 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
904 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
905 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
907 self.owner.goalentity = world;
908 self.owner.islinked = FALSE;
909 self.owner.iscaptured = FALSE;
911 self.owner.colormap = 1024;
912 onslaught_updatelinks();
914 // Use targets now (somebody make sure this is in the right place..)
921 self.owner.waslinked = self.owner.islinked;
922 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
923 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
929 void onslaught_controlpoint_icon_think()
932 self.nextthink = time + 0.05;
933 if (time > self.pain_finished + 5)
935 self.health = self.health + self.count;
936 if (self.health >= self.max_health)
937 self.health = self.max_health;
939 if (self.health < self.max_health * 0.90)
940 setmodel(self, "models/onslaught/controlpoint_icon.md3");
941 if (self.health < self.max_health * 0.75)
942 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
943 if (self.health < self.max_health * 0.50)
944 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
945 if (self.health < self.max_health * 0.25)
946 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
947 // colormod flash when shot
948 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
950 if(self.owner.islinked != self.owner.waslinked)
952 // unteam the spawnpoint if needed
955 if(!self.owner.islinked)
966 self.owner.waslinked = self.owner.islinked;
968 if (self.punchangle_x > 2)
969 self.punchangle_x = self.punchangle_x - 2;
970 else if (self.punchangle_x < -2)
971 self.punchangle_x = self.punchangle_x + 2;
973 self.punchangle_x = 0;
974 if (self.punchangle_y > 2)
975 self.punchangle_y = self.punchangle_y - 2;
976 else if (self.punchangle_y < -2)
977 self.punchangle_y = self.punchangle_y + 2;
979 self.punchangle_y = 0;
980 if (self.punchangle_z > 2)
981 self.punchangle_z = self.punchangle_z - 2;
982 else if (self.punchangle_z < -2)
983 self.punchangle_z = self.punchangle_z + 2;
985 self.punchangle_z = 0;
986 self.angles_x = self.punchangle_x;
987 self.angles_y = self.angles_y + self.punchangle_y + 2;
988 self.angles_z = self.punchangle_z;
990 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd / 8));
991 self.cp_bob_spd = self.cp_bob_spd + 0.5;
992 if(self.cp_bob_dmg_z > 0)
993 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 0.1;
995 self.cp_bob_dmg_z = 0;
996 self.origin = self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg;
999 void onslaught_controlpoint_icon_buildthink()
1004 self.nextthink = time + 0.05;
1006 // only do this if there is power
1007 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
1011 self.health = self.health + (self.count / 2);
1013 if (self.health >= self.max_health)
1015 self.health = self.max_health;
1016 self.count = self.count * 0.1; // slow repair rate from now on
1017 self.think = onslaught_controlpoint_icon_think;
1018 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
1019 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
1020 self.owner.iscaptured = TRUE;
1021 onslaught_updatelinks();
1023 // Use targets now (somebody make sure this is in the right place..)
1029 self.cp_origin = self.origin;
1030 self.cp_bob_origin = '0 0 0.1';
1031 self.cp_bob_spd = 0;
1033 self.alpha = self.health / self.max_health;
1034 // colormod flash when shot
1035 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
1036 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
1037 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
1040 void onslaught_controlpoint_touch()
1044 if (other.classname != "player")
1046 a = onslaught_controlpoint_attackable(self, other.team);
1047 if(a != 2 && a != 4)
1049 // we've verified that this player has a legitimate claim to this point,
1050 // so start building the captured point icon (which only captures this
1051 // point if it successfully builds without being destroyed first)
1052 self.goalentity = e = spawn();
1053 e.classname = "onslaught_controlpoint_icon";
1055 e.max_health = cvar("g_onslaught_cp_health");
1056 e.health = e.max_health * 0.1;
1057 e.solid = SOLID_BBOX;
1058 e.movetype = MOVETYPE_NONE;
1059 setmodel(e, "models/onslaught/controlpoint_icon.md3");
1060 setsize(e, '-32 -32 -32', '32 32 32');
1061 setorigin(e, self.origin + '0 0 96');
1062 e.takedamage = DAMAGE_AIM;
1063 e.bot_attack = TRUE;
1064 e.event_damage = onslaught_controlpoint_icon_damage;
1065 e.team = other.team;
1066 e.colormap = 1024 + (e.team - 1) * 17;
1067 e.think = onslaught_controlpoint_icon_buildthink;
1068 e.nextthink = time + 0.1;
1069 e.count = e.max_health / 50; // how long it takes to build
1070 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
1072 self.colormap = e.colormap;
1075 void onslaught_controlpoint_reset()
1077 if(self.goalentity && self.goalentity != world)
1078 remove(self.goalentity);
1079 self.goalentity = world;
1081 self.colormap = 1024;
1082 self.iscaptured = FALSE;
1083 self.islinked = FALSE;
1084 self.isshielded = TRUE;
1085 self.enemy.solid = SOLID_NOT;
1086 self.enemy.colormap = self.colormap;
1087 self.think = self.enemy.think = SUB_Null;
1088 self.nextthink = 0; // don't like SUB_Null :P
1090 onslaught_updatelinks();
1093 SUB_UseTargets(); // to reset the structures, playerspawns etc.
1096 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
1097 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
1099 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
1102 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
1103 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
1104 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
1106 void spawnfunc_onslaught_controlpoint()
1114 precache_model("models/onslaught/controlpoint_pad.md3");
1115 precache_model("models/onslaught/controlpoint_pad2.md3");
1116 precache_model("models/onslaught/controlpoint_shield.md3");
1117 precache_model("models/onslaught/controlpoint_icon.md3");
1118 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
1119 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
1120 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
1121 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
1122 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
1123 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
1124 precache_sound("onslaught/controlpoint_build.wav");
1125 precache_sound("onslaught/controlpoint_built.wav");
1126 precache_sound("weapons/grenade_impact.wav");
1127 precache_sound("onslaught/damageblockedbyshield.wav");
1128 precache_sound("onslaught/controlpoint_underattack.wav");
1129 self.solid = SOLID_BSP;
1130 self.movetype = MOVETYPE_NONE;
1131 setmodel(self, "models/onslaught/controlpoint_pad.md3");
1132 //setsize(self, '-32 -32 0', '32 32 8');
1133 setorigin(self, self.origin);
1134 self.touch = onslaught_controlpoint_touch;
1136 self.colormap = 1024;
1137 self.iscaptured = FALSE;
1138 self.islinked = FALSE;
1139 self.isshielded = TRUE;
1140 // spawn shield model which indicates whether this can be damaged
1141 self.enemy = e = spawn();
1142 e.classname = "onslaught_controlpoint_shield";
1143 e.solid = SOLID_NOT;
1144 e.movetype = MOVETYPE_NONE;
1145 e.effects = EF_ADDITIVE;
1146 setmodel(e, "models/onslaught/controlpoint_shield.md3");
1147 //setsize(e, '-32 -32 0', '32 32 128');
1148 setorigin(e, self.origin);
1149 e.colormap = self.colormap;
1151 waypoint_spawnforitem(self);
1153 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
1154 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
1156 onslaught_updatelinks();
1158 self.reset = onslaught_controlpoint_reset;
1161 float onslaught_link_send(entity to, float sendflags)
1163 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1164 WriteByte(MSG_ENTITY, sendflags);
1167 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
1168 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
1169 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1173 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1174 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1175 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1179 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1184 void onslaught_link_checkupdate()
1186 // TODO check if the two sides have moved (currently they won't move anyway)
1187 float redpower, bluepower;
1189 redpower = bluepower = 0;
1190 if(self.goalentity.islinked)
1192 if(self.goalentity.team == COLOR_TEAM1)
1194 else if(self.goalentity.team == COLOR_TEAM2)
1197 if(self.enemy.islinked)
1199 if(self.enemy.team == COLOR_TEAM1)
1201 else if(self.enemy.team == COLOR_TEAM2)
1206 if(redpower == 1 && bluepower == 2)
1207 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1208 else if(redpower == 2 && bluepower == 1)
1209 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1211 cc = (COLOR_TEAM1 - 1) * 0x11;
1213 cc = (COLOR_TEAM2 - 1) * 0x11;
1217 if(cc != self.clientcolors)
1219 self.clientcolors = cc;
1220 self.SendFlags |= 4;
1223 self.nextthink = time;
1226 void onslaught_link_delayed()
1228 self.goalentity = find(world, targetname, self.target);
1229 self.enemy = find(world, targetname, self.target2);
1230 if (!self.goalentity)
1231 objerror("can not find target\n");
1233 objerror("can not find target2\n");
1234 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1236 self.SendFlags |= 3;
1237 self.think = onslaught_link_checkupdate;
1238 self.nextthink = time;
1241 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1242 Link between control points.
1244 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.
1247 "target" - first control point.
1248 "target2" - second control point.
1250 void spawnfunc_onslaught_link()
1257 if (self.target == "" || self.target2 == "")
1258 objerror("target and target2 must be set\n");
1259 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1260 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);