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_deaththink()
388 self.nextthink = time + 0.1;
389 self.count = self.count - 1;
390 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
391 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
392 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
397 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
398 sound(self, CHAN_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
402 void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
406 if (attacker != self)
410 // this is protected by a shield, so ignore the damage
411 if (time > self.pain_finished)
412 if (attacker.classname == "player")
414 play2(attacker, "onslaught/damageblockedbyshield.wav");
415 self.pain_finished = time + 1;
419 if (time > self.pain_finished)
421 self.pain_finished = time + 5;
422 bprint(ColoredTeamName(self.team), " generator under attack!\n");
423 play2team(self.team, "onslaught/generator_underattack.wav");
426 self.health = self.health - damage;
427 // choose an animation frame based on health
428 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
429 // see if the generator is still functional, or dying
433 lh = ceil(self.lasthealth / 100) * 100;
434 h = ceil(self.health / 100) * 100;
436 bprint(ColoredTeamName(self.team), " generator has less than ", ftos(h), " health remaining\n");
437 self.lasthealth = self.health;
441 if (attacker == self)
442 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
446 t = ColoredTeamName(attacker.team);
447 bprint(ColoredTeamName(self.team), " generator destroyed by ", t, "!\n");
449 self.iscaptured = FALSE;
450 self.islinked = FALSE;
451 self.isshielded = FALSE;
452 self.takedamage = DAMAGE_NO; // can't be hurt anymore
453 self.event_damage = SUB_Null; // won't do anything if hurt
454 self.count = 30; // 30 explosions
455 self.think = onslaught_generator_deaththink; // explosion sequence
456 self.nextthink = time; // start exploding immediately
457 self.think(); // do the first explosion now
458 onslaught_updatelinks();
460 if(self.health < cvar("g_onslaught_gen_health") * 0.90)
461 setmodel(self, "models/onslaught/generator_dmg1.md3");
462 if(self.health < cvar("g_onslaught_gen_health") * 0.80)
463 setmodel(self, "models/onslaught/generator_dmg2.md3");
464 if(self.health < cvar("g_onslaught_gen_health") * 0.70)
465 setmodel(self, "models/onslaught/generator_dmg3.md3");
466 if(self.health < cvar("g_onslaught_gen_health") * 0.60)
467 setmodel(self, "models/onslaught/generator_dmg4.md3");
468 if(self.health < cvar("g_onslaught_gen_health") * 0.50)
469 setmodel(self, "models/onslaught/generator_dmg5.md3");
470 if(self.health < cvar("g_onslaught_gen_health") * 0.40)
471 setmodel(self, "models/onslaught/generator_dmg6.md3");
472 if(self.health < cvar("g_onslaught_gen_health") * 0.30)
473 setmodel(self, "models/onslaught/generator_dmg7.md3");
474 if(self.health < cvar("g_onslaught_gen_health") * 0.20)
475 setmodel(self, "models/onslaught/generator_dmg8.md3");
476 if(self.health < cvar("g_onslaught_gen_health") * 0.10)
477 setmodel(self, "models/onslaught/generator_dmg9.md3");
479 setmodel(self, "models/onslaught/generator_dead.md3");
482 // update links after a delay
483 void onslaught_generator_delayed()
485 onslaught_updatelinks();
486 // now begin normal thinking
487 self.think = onslaught_generator_think;
488 self.nextthink = time;
491 string onslaught_generator_waypointsprite_for_team(entity e, float t)
495 if(e.team == COLOR_TEAM1)
496 return "ons-gen-red";
497 else if(e.team == COLOR_TEAM2)
498 return "ons-gen-blue";
501 return "ons-gen-shielded";
502 if(e.team == COLOR_TEAM1)
503 return "ons-gen-red";
504 else if(e.team == COLOR_TEAM2)
505 return "ons-gen-blue";
509 void onslaught_generator_updatesprite(entity e)
512 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
513 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
514 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
515 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
517 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
519 e.lastteam = e.team + 2;
520 e.lastshielded = e.isshielded;
523 if(e.team == COLOR_TEAM1)
524 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0 0');
525 else if(e.team == COLOR_TEAM2)
526 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 0.5');
528 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
532 if(e.team == COLOR_TEAM1)
533 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '1 0 0');
534 else if(e.team == COLOR_TEAM2)
535 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 1');
537 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
539 WaypointSprite_Ping(e.sprite);
543 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
548 a = onslaught_controlpoint_attackable(e, t);
549 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
551 if(e.team == COLOR_TEAM1)
552 return "ons-cp-atck-red";
553 else if(e.team == COLOR_TEAM2)
554 return "ons-cp-atck-blue";
556 return "ons-cp-atck-neut";
558 else if(a == -2) // DEFEND THIS ONE NOW
560 if(e.team == COLOR_TEAM1)
561 return "ons-cp-dfnd-red";
562 else if(e.team == COLOR_TEAM2)
563 return "ons-cp-dfnd-blue";
565 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
567 if(e.team == COLOR_TEAM1)
569 else if(e.team == COLOR_TEAM2)
570 return "ons-cp-blue";
572 else if(a == 2) // touch it
573 return "ons-cp-neut";
577 if(e.team == COLOR_TEAM1)
579 else if(e.team == COLOR_TEAM2)
580 return "ons-cp-blue";
582 return "ons-cp-neut";
587 void onslaught_controlpoint_updatesprite(entity e)
590 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
591 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
592 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
593 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
596 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
598 if(e.lastteam != e.team + 2 || e.lastshielded != sh)
600 e.lastteam = e.team + 2;
604 if(e.team == COLOR_TEAM1)
605 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0 0');
606 else if(e.team == COLOR_TEAM2)
607 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 0.5');
609 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
613 if(e.team == COLOR_TEAM1)
614 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '1 0 0');
615 else if(e.team == COLOR_TEAM2)
616 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 1');
618 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
620 WaypointSprite_Ping(e.sprite);
624 void onslaught_generator_reset()
626 self.team = self.team_saved;
627 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
628 self.takedamage = DAMAGE_AIM;
629 self.bot_attack = TRUE;
630 self.iscaptured = TRUE;
631 self.islinked = TRUE;
632 self.isshielded = TRUE;
633 self.enemy.solid = SOLID_NOT;
634 self.think = onslaught_generator_delayed;
635 self.nextthink = time + 0.2;
638 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
641 spawnfunc_onslaught_link entities can target this.
644 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
645 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
647 void spawnfunc_onslaught_generator()
656 precache_model("models/onslaught/generator.md3");
657 precache_model("models/onslaught/generator_shield.md3");
658 precache_model("models/onslaught/generator_dmg1.md3");
659 precache_model("models/onslaught/generator_dmg2.md3");
660 precache_model("models/onslaught/generator_dmg3.md3");
661 precache_model("models/onslaught/generator_dmg4.md3");
662 precache_model("models/onslaught/generator_dmg5.md3");
663 precache_model("models/onslaught/generator_dmg6.md3");
664 precache_model("models/onslaught/generator_dmg7.md3");
665 precache_model("models/onslaught/generator_dmg8.md3");
666 precache_model("models/onslaught/generator_dmg9.md3");
667 precache_model("models/onslaught/generator_dead.md3");
668 precache_sound("onslaught/generator_decay.wav");
669 precache_sound("weapons/grenade_impact.wav");
670 precache_sound("weapons/rocket_impact.wav");
671 precache_sound("onslaught/generator_underattack.wav");
673 objerror("team must be set");
674 self.team_saved = self.team;
675 self.colormap = 1024 + (self.team - 1) * 17;
676 self.solid = SOLID_BSP;
677 self.movetype = MOVETYPE_NONE;
678 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
679 setmodel(self, "models/onslaught/generator.md3");
680 //setsize(self, '-32 -32 -24', '32 32 64');
681 setorigin(self, self.origin);
682 self.takedamage = DAMAGE_AIM;
683 self.bot_attack = TRUE;
684 self.event_damage = onslaught_generator_damage;
685 self.iscaptured = TRUE;
686 self.islinked = TRUE;
687 self.isshielded = TRUE;
688 // spawn shield model which indicates whether this can be damaged
689 self.enemy = e = spawn();
690 e.classname = "onslaught_generator_shield";
692 e.movetype = MOVETYPE_NONE;
693 e.effects = EF_ADDITIVE;
694 setmodel(e, "models/onslaught/generator_shield.md3");
695 //setsize(e, '-32 -32 0', '32 32 128');
696 setorigin(e, self.origin);
697 e.colormap = self.colormap;
699 self.think = onslaught_generator_delayed;
700 self.nextthink = time + 0.2;
701 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
703 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
704 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
706 onslaught_updatelinks();
708 self.reset = onslaught_generator_reset;
713 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
714 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
719 if (self.owner.isshielded)
721 // this is protected by a shield, so ignore the damage
722 if (time > self.pain_finished)
723 if (attacker.classname == "player")
725 play2(attacker, "onslaught/damageblockedbyshield.wav");
726 self.pain_finished = time + 1;
730 if (time > self.pain_finished)
731 if (attacker.classname == "player")
733 play2team(self.team, "onslaught/controlpoint_underattack.wav");
734 self.pain_finished = time + 5;
736 self.health = self.health - damage;
737 self.pain_finished = time + 1;
738 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
739 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
740 // colormod flash when shot
741 self.colormod = '2 2 2';
744 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
745 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
748 t = ColoredTeamName(attacker.team);
749 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
750 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 25,'1 1 1',"models/onslaught/controlpoint_icon_gib1.md3",5,1,1);
751 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 45,'1 1 1',"models/onslaught/controlpoint_icon_gib2.md3",5,1,1);
752 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 45,'1 1 1',"models/onslaught/controlpoint_icon_gib2.md3",5,1,1);
753 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
754 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
755 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
756 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
758 self.owner.goalentity = world;
759 self.owner.islinked = FALSE;
760 self.owner.iscaptured = FALSE;
762 self.owner.colormap = 1024;
763 onslaught_updatelinks();
765 // Use targets now (somebody make sure this is in the right place..)
772 self.owner.waslinked = self.owner.islinked;
773 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
774 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
780 void onslaught_controlpoint_icon_think()
783 self.nextthink = time + 0.05;
784 if (time > self.pain_finished + 5)
786 self.health = self.health + self.count;
787 if (self.health >= self.max_health)
788 self.health = self.max_health;
790 if (self.health < self.max_health * 0.90)
791 setmodel(self, "models/onslaught/controlpoint_icon.md3");
792 if (self.health < self.max_health * 0.75)
793 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
794 if (self.health < self.max_health * 0.50)
795 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
796 if (self.health < self.max_health * 0.25)
797 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
798 // colormod flash when shot
799 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
801 if(self.owner.islinked != self.owner.waslinked)
803 // unteam the spawnpoint if needed
806 if(!self.owner.islinked)
817 self.owner.waslinked = self.owner.islinked;
819 if (self.punchangle_x > 2)
820 self.punchangle_x = self.punchangle_x - 2;
821 else if (self.punchangle_x < -2)
822 self.punchangle_x = self.punchangle_x + 2;
824 self.punchangle_x = 0;
825 if (self.punchangle_y > 2)
826 self.punchangle_y = self.punchangle_y - 2;
827 else if (self.punchangle_y < -2)
828 self.punchangle_y = self.punchangle_y + 2;
830 self.punchangle_y = 0;
831 if (self.punchangle_z > 2)
832 self.punchangle_z = self.punchangle_z - 2;
833 else if (self.punchangle_z < -2)
834 self.punchangle_z = self.punchangle_z + 2;
836 self.punchangle_z = 0;
837 self.angles_x = self.punchangle_x;
838 self.angles_y = self.angles_y + self.punchangle_y + 2;
839 self.angles_z = self.punchangle_z;
841 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd / 8));
842 self.cp_bob_spd = self.cp_bob_spd + 0.5;
843 if(self.cp_bob_dmg_z > 0)
844 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 0.1;
846 self.cp_bob_dmg_z = 0;
847 self.origin = self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg;
850 void onslaught_controlpoint_icon_buildthink()
855 self.nextthink = time + 0.05;
857 // only do this if there is power
858 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
862 self.health = self.health + (self.count / 2);
864 if (self.health >= self.max_health)
866 self.health = self.max_health;
867 self.count = self.count * 0.1; // slow repair rate from now on
868 self.think = onslaught_controlpoint_icon_think;
869 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
870 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
871 self.owner.iscaptured = TRUE;
872 onslaught_updatelinks();
874 // Use targets now (somebody make sure this is in the right place..)
880 self.cp_origin = self.origin;
881 self.cp_bob_origin = '0 0 0.1';
884 self.alpha = self.health / self.max_health;
885 // colormod flash when shot
886 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
887 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
888 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
891 void onslaught_controlpoint_touch()
895 if (other.classname != "player")
897 a = onslaught_controlpoint_attackable(self, other.team);
900 // we've verified that this player has a legitimate claim to this point,
901 // so start building the captured point icon (which only captures this
902 // point if it successfully builds without being destroyed first)
903 self.goalentity = e = spawn();
904 e.classname = "onslaught_controlpoint_icon";
906 e.max_health = cvar("g_onslaught_cp_health");
907 e.health = e.max_health * 0.1;
908 e.solid = SOLID_BBOX;
909 e.movetype = MOVETYPE_NONE;
910 setmodel(e, "models/onslaught/controlpoint_icon.md3");
911 setsize(e, '-32 -32 -32', '32 32 32');
912 setorigin(e, self.origin + '0 0 96');
913 e.takedamage = DAMAGE_AIM;
915 e.event_damage = onslaught_controlpoint_icon_damage;
917 e.colormap = 1024 + (e.team - 1) * 17;
918 e.think = onslaught_controlpoint_icon_buildthink;
919 e.nextthink = time + 0.1;
920 e.count = e.max_health / 50; // how long it takes to build
921 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
923 self.colormap = e.colormap;
926 void onslaught_controlpoint_reset()
928 if(self.goalentity && self.goalentity != world)
929 remove(self.goalentity);
930 self.goalentity = world;
932 self.colormap = 1024;
933 self.iscaptured = FALSE;
934 self.islinked = FALSE;
935 self.isshielded = TRUE;
936 self.enemy.solid = SOLID_NOT;
937 self.enemy.colormap = self.colormap;
938 self.think = self.enemy.think = SUB_Null;
939 self.nextthink = 0; // don't like SUB_Null :P
941 onslaught_updatelinks();
944 SUB_UseTargets(); // to reset the structures, playerspawns etc.
947 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
948 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
950 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
953 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
954 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
955 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
957 void spawnfunc_onslaught_controlpoint()
965 precache_model("models/onslaught/controlpoint_pad.md3");
966 precache_model("models/onslaught/controlpoint_pad2.md3");
967 precache_model("models/onslaught/controlpoint_shield.md3");
968 precache_model("models/onslaught/controlpoint_icon.md3");
969 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
970 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
971 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
972 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
973 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
974 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
975 precache_sound("onslaught/controlpoint_build.wav");
976 precache_sound("onslaught/controlpoint_built.wav");
977 precache_sound("weapons/grenade_impact.wav");
978 precache_sound("onslaught/damageblockedbyshield.wav");
979 precache_sound("onslaught/controlpoint_underattack.wav");
980 self.solid = SOLID_BSP;
981 self.movetype = MOVETYPE_NONE;
982 setmodel(self, "models/onslaught/controlpoint_pad.md3");
983 //setsize(self, '-32 -32 0', '32 32 8');
984 setorigin(self, self.origin);
985 self.touch = onslaught_controlpoint_touch;
987 self.colormap = 1024;
988 self.iscaptured = FALSE;
989 self.islinked = FALSE;
990 self.isshielded = TRUE;
991 // spawn shield model which indicates whether this can be damaged
992 self.enemy = e = spawn();
993 e.classname = "onslaught_controlpoint_shield";
995 e.movetype = MOVETYPE_NONE;
996 e.effects = EF_ADDITIVE;
997 setmodel(e, "models/onslaught/controlpoint_shield.md3");
998 //setsize(e, '-32 -32 0', '32 32 128');
999 setorigin(e, self.origin);
1000 e.colormap = self.colormap;
1002 waypoint_spawnforitem(self);
1004 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
1005 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
1007 onslaught_updatelinks();
1009 self.reset = onslaught_controlpoint_reset;
1012 float onslaught_link_send(entity to, float sendflags)
1014 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
1015 WriteByte(MSG_ENTITY, sendflags);
1018 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
1019 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
1020 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1024 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1025 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1026 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1030 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1035 void onslaught_link_checkupdate()
1037 // TODO check if the two sides have moved (currently they won't move anyway)
1038 float redpower, bluepower;
1040 redpower = bluepower = 0;
1041 if(self.goalentity.islinked)
1043 if(self.goalentity.team == COLOR_TEAM1)
1045 else if(self.goalentity.team == COLOR_TEAM2)
1048 if(self.enemy.islinked)
1050 if(self.enemy.team == COLOR_TEAM1)
1052 else if(self.enemy.team == COLOR_TEAM2)
1057 if(redpower == 1 && bluepower == 2)
1058 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1059 else if(redpower == 2 && bluepower == 1)
1060 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1062 cc = (COLOR_TEAM1 - 1) * 0x11;
1064 cc = (COLOR_TEAM2 - 1) * 0x11;
1068 if(cc != self.clientcolors)
1070 self.clientcolors = cc;
1071 self.SendFlags |= 4;
1074 self.nextthink = time;
1077 void onslaught_link_delayed()
1079 self.goalentity = find(world, targetname, self.target);
1080 self.enemy = find(world, targetname, self.target2);
1081 if (!self.goalentity)
1082 objerror("can not find target\n");
1084 objerror("can not find target2\n");
1085 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1087 self.SendFlags |= 3;
1088 self.think = onslaught_link_checkupdate;
1089 self.nextthink = time;
1092 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1093 Link between control points.
1095 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.
1098 "target" - first control point.
1099 "target2" - second control point.
1101 void spawnfunc_onslaught_link()
1108 if (self.target == "" || self.target2 == "")
1109 objerror("target and target2 must be set\n");
1110 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1111 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);