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 onslaught_updatelinks()
22 local entity l, links;
23 local float stop, t1, t2, t3, t4;
24 // first check if the game has ended
25 dprint("--- updatelinks ---\n");
26 links = findchain(classname, "onslaught_link");
27 // mark generators as being shielded and networked
28 l = findchain(classname, "onslaught_generator");
32 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
34 dprint(etos(l), " (generator) is destroyed\n");
35 l.islinked = l.iscaptured;
36 l.isshielded = l.iscaptured;
39 // mark points as shielded and not networked
40 l = findchain(classname, "onslaught_controlpoint");
45 l.isgenneighbor_red = FALSE;
46 l.isgenneighbor_blue = FALSE;
47 l.iscpneighbor_red = FALSE;
48 l.iscpneighbor_blue = FALSE;
49 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
52 // flow power outward from the generators through the network
56 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
66 // if both points are captured by the same team, and only one of
67 // them is powered, mark the other one as powered as well
68 if (l.enemy.iscaptured && l.goalentity.iscaptured)
69 if (l.enemy.islinked != l.goalentity.islinked)
70 if (l.enemy.team == l.goalentity.team)
72 if (!l.goalentity.islinked)
75 l.goalentity.islinked = TRUE;
76 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
78 else if (!l.enemy.islinked)
81 l.enemy.islinked = TRUE;
82 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
88 // now that we know which points are powered we can mark their neighbors
89 // as unshielded if team differs
93 if (l.goalentity.team != l.enemy.team)
95 if (l.goalentity.islinked)
97 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
98 l.enemy.isshielded = FALSE;
99 if(l.goalentity.classname == "onslaught_generator")
101 if(l.goalentity.team == COLOR_TEAM1)
102 l.enemy.isgenneighbor_red = TRUE;
103 else if(l.goalentity.team == COLOR_TEAM2)
104 l.enemy.isgenneighbor_blue = TRUE;
108 if(l.goalentity.team == COLOR_TEAM1)
109 l.enemy.iscpneighbor_red = TRUE;
110 else if(l.goalentity.team == COLOR_TEAM2)
111 l.enemy.iscpneighbor_blue = TRUE;
114 if (l.enemy.islinked)
116 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
117 l.goalentity.isshielded = FALSE;
118 if(l.enemy.classname == "onslaught_generator")
120 if(l.enemy.team == COLOR_TEAM1)
121 l.goalentity.isgenneighbor_red = TRUE;
122 else if(l.enemy.team == COLOR_TEAM2)
123 l.goalentity.isgenneighbor_blue = TRUE;
127 if(l.enemy.team == COLOR_TEAM1)
128 l.goalentity.iscpneighbor_red = TRUE;
129 else if(l.enemy.team == COLOR_TEAM2)
130 l.goalentity.iscpneighbor_blue = TRUE;
136 // now update the takedamage and alpha variables on generator shields
137 l = findchain(classname, "onslaught_generator");
142 dprint(etos(l), " (generator) is shielded\n");
144 l.takedamage = DAMAGE_NO;
145 l.bot_attack = FALSE;
149 dprint(etos(l), " (generator) is not shielded\n");
151 l.takedamage = DAMAGE_AIM;
156 // now update the takedamage and alpha variables on control point icons
157 l = findchain(classname, "onslaught_controlpoint");
162 dprint(etos(l), " (point) is shielded\n");
166 l.goalentity.takedamage = DAMAGE_NO;
167 l.goalentity.bot_attack = FALSE;
172 dprint(etos(l), " (point) is not shielded\n");
176 l.goalentity.takedamage = DAMAGE_AIM;
177 l.goalentity.bot_attack = TRUE;
180 onslaught_controlpoint_updatesprite(l);
183 // count generators owned by each team
184 t1 = t2 = t3 = t4 = 0;
185 l = findchain(classname, "onslaught_generator");
190 if (l.team == COLOR_TEAM1) t1 = 1;
191 if (l.team == COLOR_TEAM2) t2 = 1;
192 if (l.team == COLOR_TEAM3) t3 = 1;
193 if (l.team == COLOR_TEAM4) t4 = 1;
195 onslaught_generator_updatesprite(l);
198 // see if multiple teams remain (if not, it's game over)
199 if (t1 + t2 + t3 + t4 < 2)
200 dprint("--- game over ---\n");
202 dprint("--- done updating links ---\n");
205 float onslaught_controlpoint_can_be_linked(entity cp, float t)
209 if(cp.isgenneighbor_red)
211 if(cp.iscpneighbor_red)
214 else if(t == COLOR_TEAM2)
216 if(cp.isgenneighbor_blue)
218 if(cp.iscpneighbor_blue)
224 // check to see if this player has a legitimate claim to capture this
225 // control point - more specifically that there is a captured path of
226 // points leading back to the team generator
227 e = findchain(classname, "onslaught_link");
230 if (e.goalentity == cp)
232 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
233 if (e.enemy.islinked)
235 dprint(" which is linked");
236 if (e.enemy.team == t)
238 dprint(" and has the correct team!\n");
242 dprint(" but has the wrong team\n");
247 else if (e.enemy == cp)
249 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
250 if (e.goalentity.islinked)
252 dprint(" which is linked");
253 if (e.goalentity.team == t)
255 dprint(" and has a team!\n");
259 dprint(" but has the wrong team\n");
270 float onslaught_controlpoint_attackable(entity cp, float t)
271 // -2: SAME TEAM, attackable by enemy!
276 // 3: attack it (HIGH PRIO)
277 // 4: touch it (HIGH PRIO)
285 else if(cp.goalentity)
287 // if there's already an icon built, nothing happens
290 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
291 if(a) // attackable by enemy?
292 return -2; // EMERGENCY!
295 // we know it can be linked, so no need to check
297 a = onslaught_controlpoint_can_be_linked(cp, t);
298 if(a == 2) // near our generator?
299 return 3; // EMERGENCY!
305 if(onslaught_controlpoint_can_be_linked(cp, t))
307 a = onslaught_controlpoint_can_be_linked(cp, COLOR_TEAM1 + COLOR_TEAM2 - t);
309 return 4; // GET THIS ONE NOW!
311 return 2; // TOUCH ME
317 void onslaught_generator_think()
321 self.nextthink = ceil(time + 1);
322 if (cvar("timelimit"))
323 if (time > cvar("timelimit") * 60 - 60)
325 // self.max_health / 300 gives 5 minutes of overtime.
326 // control points reduce the overtime duration.
327 sound(self, CHAN_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTN_NORM);
329 e = findchain(classname, "onslaught_controlpoint");
332 if (e.team != self.team)
337 d = d * self.max_health / 300;
338 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
342 void onslaught_generator_deaththink()
347 self.nextthink = time + 0.1;
348 self.count = self.count - 1;
349 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
350 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
351 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
356 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
357 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
361 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
365 if (attacker != self)
369 // this is protected by a shield, so ignore the damage
370 if (time > self.pain_finished)
371 if (attacker.classname == "player")
373 play2(attacker, "onslaught/damageblockedbyshield.wav");
374 self.pain_finished = time + 1;
378 if (time > self.pain_finished)
380 self.pain_finished = time + 5;
381 bprint(ColoredTeamName(self.team), " generator under attack!\n");
382 play2team(self.team, "onslaught/generator_underattack.wav");
385 self.health = self.health - damage;
386 // choose an animation frame based on health
387 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
388 // see if the generator is still functional, or dying
392 lh = ceil(self.lasthealth / 100) * 100;
393 h = ceil(self.health / 100) * 100;
395 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
396 self.lasthealth = self.health;
400 if (attacker == self)
401 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
405 t = ColoredTeamName(attacker.team);
406 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
408 self.iscaptured = FALSE;
409 self.islinked = FALSE;
410 self.isshielded = FALSE;
411 self.takedamage = DAMAGE_NO; // can't be hurt anymore
412 self.event_damage = SUB_Null; // won't do anything if hurt
413 self.count = 30; // 30 explosions
414 self.think = onslaught_generator_deaththink; // explosion sequence
415 self.nextthink = time; // start exploding immediately
416 self.think(); // do the first explosion now
417 onslaught_updatelinks();
421 // update links after a delay
422 void onslaught_generator_delayed()
424 onslaught_updatelinks();
425 // now begin normal thinking
426 self.think = onslaught_generator_think;
427 self.nextthink = time;
430 string onslaught_generator_waypointsprite_for_team(entity e, float t)
434 if(e.team == COLOR_TEAM1)
435 return "ons-gen-red";
436 else if(e.team == COLOR_TEAM2)
437 return "ons-gen-blue";
440 return "ons-gen-shielded";
441 if(e.team == COLOR_TEAM1)
442 return "ons-gen-red";
443 else if(e.team == COLOR_TEAM2)
444 return "ons-gen-blue";
448 void onslaught_generator_updatesprite(entity e)
451 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
452 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
453 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
454 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
456 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
458 e.lastteam = e.team + 2;
459 e.lastshielded = e.isshielded;
462 if(e.team == COLOR_TEAM1)
463 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0 0');
464 else if(e.team == COLOR_TEAM2)
465 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 0.5');
467 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
471 if(e.team == COLOR_TEAM1)
472 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '1 0 0');
473 else if(e.team == COLOR_TEAM2)
474 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 1');
476 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
478 WaypointSprite_Ping(e.sprite);
482 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
487 a = onslaught_controlpoint_attackable(e, t);
488 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
490 if(e.team == COLOR_TEAM1)
491 return "ons-cp-atck-red";
492 else if(e.team == COLOR_TEAM2)
493 return "ons-cp-atck-blue";
495 return "ons-cp-atck-neut";
497 else if(a == -2) // DEFEND THIS ONE NOW
499 if(e.team == COLOR_TEAM1)
500 return "ons-cp-dfnd-red";
501 else if(e.team == COLOR_TEAM2)
502 return "ons-cp-dfnd-blue";
504 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
506 if(e.team == COLOR_TEAM1)
508 else if(e.team == COLOR_TEAM2)
509 return "ons-cp-blue";
511 else if(a == 2) // touch it
512 return "ons-cp-neut";
516 if(e.team == COLOR_TEAM1)
518 else if(e.team == COLOR_TEAM2)
519 return "ons-cp-blue";
521 return "ons-cp-neut";
526 void onslaught_controlpoint_updatesprite(entity e)
529 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
530 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
531 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
532 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
535 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
537 if(e.lastteam != e.team + 2 || e.lastshielded != sh)
539 e.lastteam = e.team + 2;
543 if(e.team == COLOR_TEAM1)
544 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0 0');
545 else if(e.team == COLOR_TEAM2)
546 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 0.5');
548 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
552 if(e.team == COLOR_TEAM1)
553 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '1 0 0');
554 else if(e.team == COLOR_TEAM2)
555 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 1');
557 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
559 WaypointSprite_Ping(e.sprite);
563 void onslaught_generator_reset()
565 self.team = self.team_saved;
566 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
567 self.takedamage = DAMAGE_AIM;
568 self.bot_attack = TRUE;
569 self.iscaptured = TRUE;
570 self.islinked = TRUE;
571 self.isshielded = TRUE;
572 self.enemy.solid = SOLID_NOT;
573 self.think = onslaught_generator_delayed;
574 self.nextthink = time + 0.2;
577 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
580 spawnfunc_onslaught_link entities can target this.
583 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
584 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
586 void spawnfunc_onslaught_generator()
595 precache_model("models/onslaught/generator.md3");
596 precache_model("models/onslaught/generator_shield.md3");
597 precache_sound("onslaught/generator_decay.wav");
598 precache_sound("weapons/grenade_impact.wav");
599 precache_sound("weapons/rocket_impact.wav");
600 precache_sound("onslaught/generator_underattack.wav");
602 objerror("team must be set");
603 self.team_saved = self.team;
604 self.colormap = 1024 + (self.team - 1) * 17;
605 self.solid = SOLID_BSP;
606 self.movetype = MOVETYPE_NONE;
607 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
608 setmodel(self, "models/onslaught/generator.md3");
609 //setsize(self, '-32 -32 -24', '32 32 64');
610 setorigin(self, self.origin);
611 self.takedamage = DAMAGE_AIM;
612 self.bot_attack = TRUE;
613 self.event_damage = onslaught_generator_damage;
614 self.iscaptured = TRUE;
615 self.islinked = TRUE;
616 self.isshielded = TRUE;
617 // spawn shield model which indicates whether this can be damaged
618 self.enemy = e = spawn();
619 e.classname = "onslaught_generator_shield";
621 e.movetype = MOVETYPE_NONE;
622 e.effects = EF_ADDITIVE;
623 setmodel(e, "models/onslaught/generator_shield.md3");
624 //setsize(e, '-32 -32 0', '32 32 128');
625 setorigin(e, self.origin);
626 e.colormap = self.colormap;
628 self.think = onslaught_generator_delayed;
629 self.nextthink = time + 0.2;
631 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
632 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
634 onslaught_updatelinks();
636 self.reset = onslaught_generator_reset;
640 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
645 if (self.owner.isshielded)
647 // this is protected by a shield, so ignore the damage
648 if (time > self.pain_finished)
649 if (attacker.classname == "player")
651 play2(attacker, "onslaught/damageblockedbyshield.wav");
652 self.pain_finished = time + 1;
656 if (time > self.pain_finished)
657 if (attacker.classname == "player")
659 play2team(self.team, "onslaught/controlpoint_underattack.wav");
660 self.pain_finished = time + 5;
662 self.health = self.health - damage;
663 self.alpha = self.health / self.max_health;
664 self.pain_finished = time + 1;
665 // colormod flash when shot
666 self.colormod = '2 2 2';
669 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
670 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
673 t = ColoredTeamName(attacker.team);
674 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
676 self.owner.goalentity = world;
677 self.owner.islinked = FALSE;
678 self.owner.iscaptured = FALSE;
680 self.owner.colormap = 1024;
681 onslaught_updatelinks();
683 // Use targets now (somebody make sure this is in the right place..)
690 self.owner.waslinked = self.owner.islinked;
696 void onslaught_controlpoint_icon_think()
699 self.nextthink = time + 0.1;
700 if (time > self.pain_finished + 1)
702 self.health = self.health + self.count;
703 if (self.health >= self.max_health)
704 self.health = self.max_health;
706 self.alpha = self.health / self.max_health;
707 // colormod flash when shot
708 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
710 if(self.owner.islinked != self.owner.waslinked)
712 // unteam the spawnpoint if needed
715 if(!self.owner.islinked)
726 self.owner.waslinked = self.owner.islinked;
730 void onslaught_controlpoint_icon_buildthink()
735 self.nextthink = time + 0.1;
737 // only do this if there is power
738 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
742 self.health = self.health + self.count;
744 if (self.health >= self.max_health)
746 self.health = self.max_health;
747 self.count = self.count * 0.2; // slow repair rate from now on
748 self.think = onslaught_controlpoint_icon_think;
749 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
750 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
751 self.owner.iscaptured = TRUE;
752 onslaught_updatelinks();
754 // Use targets now (somebody make sure this is in the right place..)
761 self.alpha = self.health / self.max_health;
762 // colormod flash when shot
763 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
766 void onslaught_controlpoint_touch()
770 if (other.classname != "player")
772 a = onslaught_controlpoint_attackable(self, other.team);
775 // we've verified that this player has a legitimate claim to this point,
776 // so start building the captured point icon (which only captures this
777 // point if it successfully builds without being destroyed first)
778 self.goalentity = e = spawn();
779 e.classname = "onslaught_controlpoint_icon";
781 e.max_health = cvar("g_onslaught_cp_health");
782 e.health = e.max_health * 0.1;
783 e.alpha = e.health / e.max_health;
784 e.solid = SOLID_BBOX;
785 e.movetype = MOVETYPE_NONE;
786 setmodel(e, "models/onslaught/controlpoint_icon.md3");
787 setsize(e, '-32 -32 -32', '32 32 32');
788 setorigin(e, self.origin + '0 0 96');
789 e.takedamage = DAMAGE_AIM;
791 e.event_damage = onslaught_controlpoint_icon_damage;
793 e.colormap = 1024 + (e.team - 1) * 17;
794 e.think = onslaught_controlpoint_icon_buildthink;
795 e.nextthink = time + 0.1;
796 e.count = e.max_health / 50; // how long it takes to build
797 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
799 self.colormap = e.colormap;
802 void onslaught_controlpoint_reset()
804 if(self.goalentity && self.goalentity != world)
805 remove(self.goalentity);
806 self.goalentity = world;
808 self.colormap = 1024;
809 self.iscaptured = FALSE;
810 self.islinked = FALSE;
811 self.isshielded = TRUE;
812 self.enemy.solid = SOLID_NOT;
813 self.enemy.colormap = self.colormap;
814 self.think = self.enemy.think = SUB_Null;
815 self.nextthink = 0; // don't like SUB_Null :P
817 onslaught_updatelinks();
820 SUB_UseTargets(); // to reset the structures, playerspawns etc.
823 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
824 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
826 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
829 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
830 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
831 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
833 void spawnfunc_onslaught_controlpoint()
841 precache_model("models/onslaught/controlpoint_pad.md3");
842 precache_model("models/onslaught/controlpoint_shield.md3");
843 precache_model("models/onslaught/controlpoint_icon.md3");
844 precache_sound("onslaught/controlpoint_build.wav");
845 precache_sound("onslaught/controlpoint_built.wav");
846 precache_sound("weapons/grenade_impact.wav");
847 precache_sound("onslaught/damageblockedbyshield.wav");
848 precache_sound("onslaught/controlpoint_underattack.wav");
849 self.solid = SOLID_BSP;
850 self.movetype = MOVETYPE_NONE;
851 setmodel(self, "models/onslaught/controlpoint_pad.md3");
852 //setsize(self, '-32 -32 0', '32 32 8');
853 setorigin(self, self.origin);
854 self.touch = onslaught_controlpoint_touch;
856 self.colormap = 1024;
857 self.iscaptured = FALSE;
858 self.islinked = FALSE;
859 self.isshielded = TRUE;
860 // spawn shield model which indicates whether this can be damaged
861 self.enemy = e = spawn();
862 e.classname = "onslaught_controlpoint_shield";
864 e.movetype = MOVETYPE_NONE;
865 e.effects = EF_ADDITIVE;
866 setmodel(e, "models/onslaught/controlpoint_shield.md3");
867 //setsize(e, '-32 -32 0', '32 32 128');
868 setorigin(e, self.origin);
869 e.colormap = self.colormap;
871 waypoint_spawnforitem(self);
873 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
874 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
876 onslaught_updatelinks();
878 self.reset = onslaught_controlpoint_reset;
881 float onslaught_link_send(entity to, float sendflags)
883 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
884 WriteByte(MSG_ENTITY, sendflags);
887 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
888 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
889 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
893 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
894 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
895 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
899 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
904 void onslaught_link_checkupdate()
906 // TODO check if the two sides have moved (currently they won't move anyway)
907 float redpower, bluepower;
909 redpower = bluepower = 0;
910 if(self.goalentity.islinked)
912 if(self.goalentity.team == COLOR_TEAM1)
914 else if(self.goalentity.team == COLOR_TEAM2)
917 if(self.enemy.islinked)
919 if(self.enemy.team == COLOR_TEAM1)
921 else if(self.enemy.team == COLOR_TEAM2)
926 if(redpower == 1 && bluepower == 2)
927 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
928 else if(redpower == 2 && bluepower == 1)
929 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
931 cc = (COLOR_TEAM1 - 1) * 0x11;
933 cc = (COLOR_TEAM2 - 1) * 0x11;
937 if(cc != self.clientcolors)
939 self.clientcolors = cc;
943 self.nextthink = time;
946 void onslaught_link_delayed()
948 self.goalentity = find(world, targetname, self.target);
949 self.enemy = find(world, targetname, self.target2);
950 if (!self.goalentity)
951 objerror("can not find target\n");
953 objerror("can not find target2\n");
954 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
957 self.think = onslaught_link_checkupdate;
958 self.nextthink = time;
961 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
962 Link between control points.
964 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.
967 "target" - first control point.
968 "target2" - second control point.
970 void spawnfunc_onslaught_link()
977 if (self.target == "" || self.target2 == "")
978 objerror("target and target2 must be set\n");
979 self.think = onslaught_link_delayed;
980 self.nextthink = time + 0.1;
981 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);