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.75)
461 setmodel(self, "models/onslaught/generator_dmg1.md3");
462 if(self.health < cvar("g_onslaught_gen_health") * 0.35)
463 setmodel(self, "models/onslaught/generator_dmg2.md3");
465 setmodel(self, "models/onslaught/generator_dead.md3");
468 // update links after a delay
469 void onslaught_generator_delayed()
471 onslaught_updatelinks();
472 // now begin normal thinking
473 self.think = onslaught_generator_think;
474 self.nextthink = time;
477 string onslaught_generator_waypointsprite_for_team(entity e, float t)
481 if(e.team == COLOR_TEAM1)
482 return "ons-gen-red";
483 else if(e.team == COLOR_TEAM2)
484 return "ons-gen-blue";
487 return "ons-gen-shielded";
488 if(e.team == COLOR_TEAM1)
489 return "ons-gen-red";
490 else if(e.team == COLOR_TEAM2)
491 return "ons-gen-blue";
495 void onslaught_generator_updatesprite(entity e)
498 s1 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM1);
499 s2 = onslaught_generator_waypointsprite_for_team(e, COLOR_TEAM2);
500 s3 = onslaught_generator_waypointsprite_for_team(e, -1);
501 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
503 if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
505 e.lastteam = e.team + 2;
506 e.lastshielded = e.isshielded;
509 if(e.team == COLOR_TEAM1)
510 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0 0');
511 else if(e.team == COLOR_TEAM2)
512 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 0.5');
514 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
518 if(e.team == COLOR_TEAM1)
519 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '1 0 0');
520 else if(e.team == COLOR_TEAM2)
521 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0 0 1');
523 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
525 WaypointSprite_Ping(e.sprite);
529 string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
534 a = onslaught_controlpoint_attackable(e, t);
535 if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
537 if(e.team == COLOR_TEAM1)
538 return "ons-cp-atck-red";
539 else if(e.team == COLOR_TEAM2)
540 return "ons-cp-atck-blue";
542 return "ons-cp-atck-neut";
544 else if(a == -2) // DEFEND THIS ONE NOW
546 if(e.team == COLOR_TEAM1)
547 return "ons-cp-dfnd-red";
548 else if(e.team == COLOR_TEAM2)
549 return "ons-cp-dfnd-blue";
551 else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
553 if(e.team == COLOR_TEAM1)
555 else if(e.team == COLOR_TEAM2)
556 return "ons-cp-blue";
558 else if(a == 2) // touch it
559 return "ons-cp-neut";
563 if(e.team == COLOR_TEAM1)
565 else if(e.team == COLOR_TEAM2)
566 return "ons-cp-blue";
568 return "ons-cp-neut";
573 void onslaught_controlpoint_updatesprite(entity e)
576 s1 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM1);
577 s2 = onslaught_controlpoint_waypointsprite_for_team(e, COLOR_TEAM2);
578 s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
579 WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
582 sh = !(onslaught_controlpoint_can_be_linked(e, COLOR_TEAM1) || onslaught_controlpoint_can_be_linked(e, COLOR_TEAM2));
584 if(e.lastteam != e.team + 2 || e.lastshielded != sh)
586 e.lastteam = e.team + 2;
590 if(e.team == COLOR_TEAM1)
591 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0 0');
592 else if(e.team == COLOR_TEAM2)
593 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 0.5');
595 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
599 if(e.team == COLOR_TEAM1)
600 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '1 0 0');
601 else if(e.team == COLOR_TEAM2)
602 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0 0 1');
604 WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
606 WaypointSprite_Ping(e.sprite);
610 void onslaught_generator_reset()
612 self.team = self.team_saved;
613 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
614 self.takedamage = DAMAGE_AIM;
615 self.bot_attack = TRUE;
616 self.iscaptured = TRUE;
617 self.islinked = TRUE;
618 self.isshielded = TRUE;
619 self.enemy.solid = SOLID_NOT;
620 self.think = onslaught_generator_delayed;
621 self.nextthink = time + 0.2;
624 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
627 spawnfunc_onslaught_link entities can target this.
630 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
631 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
633 void spawnfunc_onslaught_generator()
642 precache_model("models/onslaught/generator.md3");
643 precache_model("models/onslaught/generator_shield.md3");
644 precache_model("models/onslaught/generator_dmg1.md3");
645 precache_model("models/onslaught/generator_dmg2.md3");
646 precache_model("models/onslaught/generator_dead.md3");
647 precache_sound("onslaught/generator_decay.wav");
648 precache_sound("weapons/grenade_impact.wav");
649 precache_sound("weapons/rocket_impact.wav");
650 precache_sound("onslaught/generator_underattack.wav");
652 objerror("team must be set");
653 self.team_saved = self.team;
654 self.colormap = 1024 + (self.team - 1) * 17;
655 self.solid = SOLID_BSP;
656 self.movetype = MOVETYPE_NONE;
657 self.lasthealth = self.max_health = self.health = cvar("g_onslaught_gen_health");
658 setmodel(self, "models/onslaught/generator.md3");
659 //setsize(self, '-32 -32 -24', '32 32 64');
660 setorigin(self, self.origin);
661 self.takedamage = DAMAGE_AIM;
662 self.bot_attack = TRUE;
663 self.event_damage = onslaught_generator_damage;
664 self.iscaptured = TRUE;
665 self.islinked = TRUE;
666 self.isshielded = TRUE;
667 // spawn shield model which indicates whether this can be damaged
668 self.enemy = e = spawn();
669 e.classname = "onslaught_generator_shield";
671 e.movetype = MOVETYPE_NONE;
672 e.effects = EF_ADDITIVE;
673 setmodel(e, "models/onslaught/generator_shield.md3");
674 //setsize(e, '-32 -32 0', '32 32 128');
675 setorigin(e, self.origin);
676 e.colormap = self.colormap;
678 self.think = onslaught_generator_delayed;
679 self.nextthink = time + 0.2;
680 InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
682 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
683 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
685 onslaught_updatelinks();
687 self.reset = onslaught_generator_reset;
692 .vector cp_origin, cp_bob_origin, cp_bob_dmg;
693 void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
698 if (self.owner.isshielded)
700 // this is protected by a shield, so ignore the damage
701 if (time > self.pain_finished)
702 if (attacker.classname == "player")
704 play2(attacker, "onslaught/damageblockedbyshield.wav");
705 self.pain_finished = time + 1;
709 if (time > self.pain_finished)
710 if (attacker.classname == "player")
712 play2team(self.team, "onslaught/controlpoint_underattack.wav");
713 self.pain_finished = time + 5;
715 self.health = self.health - damage;
716 self.pain_finished = time + 1;
717 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
718 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
719 // colormod flash when shot
720 self.colormod = '2 2 2';
723 sound(self, CHAN_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
724 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
727 t = ColoredTeamName(attacker.team);
728 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", t, "\n");
729 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 25,'1 1 1',"models/onslaught/controlpoint_icon_gib1.md3",5,1,1);
730 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 45,'1 1 1',"models/onslaught/controlpoint_icon_gib2.md3",5,1,1);
731 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 45,'1 1 1',"models/onslaught/controlpoint_icon_gib2.md3",5,1,1);
732 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
733 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
734 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
735 ons_trowgib(self.origin, (2 * randomvec() - '1 1 1') * 75,'1 1 1',"models/onslaught/controlpoint_icon_gib4.md3",5,1,1);
737 self.owner.goalentity = world;
738 self.owner.islinked = FALSE;
739 self.owner.iscaptured = FALSE;
741 self.owner.colormap = 1024;
742 onslaught_updatelinks();
744 // Use targets now (somebody make sure this is in the right place..)
751 self.owner.waslinked = self.owner.islinked;
752 if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
753 setmodel(self.owner, "models/onslaught/controlpoint_pad.md3");
759 void onslaught_controlpoint_icon_think()
762 self.nextthink = time + 0.05;
763 if (time > self.pain_finished + 5)
765 self.health = self.health + self.count;
766 if (self.health >= self.max_health)
767 self.health = self.max_health;
769 if (self.health < self.max_health * 0.90)
770 setmodel(self, "models/onslaught/controlpoint_icon.md3");
771 if (self.health < self.max_health * 0.75)
772 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
773 if (self.health < self.max_health * 0.50)
774 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
775 if (self.health < self.max_health * 0.25)
776 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
777 // colormod flash when shot
778 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
780 if(self.owner.islinked != self.owner.waslinked)
782 // unteam the spawnpoint if needed
785 if(!self.owner.islinked)
796 self.owner.waslinked = self.owner.islinked;
798 if (self.punchangle_x > 2)
799 self.punchangle_x = self.punchangle_x - 2;
800 else if (self.punchangle_x < -2)
801 self.punchangle_x = self.punchangle_x + 2;
803 self.punchangle_x = 0;
804 if (self.punchangle_y > 2)
805 self.punchangle_y = self.punchangle_y - 2;
806 else if (self.punchangle_y < -2)
807 self.punchangle_y = self.punchangle_y + 2;
809 self.punchangle_y = 0;
810 if (self.punchangle_z > 2)
811 self.punchangle_z = self.punchangle_z - 2;
812 else if (self.punchangle_z < -2)
813 self.punchangle_z = self.punchangle_z + 2;
815 self.punchangle_z = 0;
816 self.angles_x = self.punchangle_x;
817 self.angles_y = self.angles_y + self.punchangle_y + 2;
818 self.angles_z = self.punchangle_z;
820 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd / 8));
821 self.cp_bob_spd = self.cp_bob_spd + 0.5;
822 if(self.cp_bob_dmg_z > 0)
823 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 0.1;
825 self.cp_bob_dmg_z = 0;
826 self.origin = self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg;
829 void onslaught_controlpoint_icon_buildthink()
834 self.nextthink = time + 0.05;
836 // only do this if there is power
837 a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
841 self.health = self.health + (self.count / 2);
843 if (self.health >= self.max_health)
845 self.health = self.max_health;
846 self.count = self.count * 0.1; // slow repair rate from now on
847 self.think = onslaught_controlpoint_icon_think;
848 sound(self, CHAN_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTN_NORM);
849 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
850 self.owner.iscaptured = TRUE;
851 onslaught_updatelinks();
853 // Use targets now (somebody make sure this is in the right place..)
859 self.cp_origin = self.origin;
860 self.cp_bob_origin = '0 0 0.1';
863 self.alpha = self.health / self.max_health;
864 // colormod flash when shot
865 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
866 if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
867 setmodel(self.owner, "models/onslaught/controlpoint_pad2.md3");
870 void onslaught_controlpoint_touch()
874 if (other.classname != "player")
876 a = onslaught_controlpoint_attackable(self, other.team);
879 // we've verified that this player has a legitimate claim to this point,
880 // so start building the captured point icon (which only captures this
881 // point if it successfully builds without being destroyed first)
882 self.goalentity = e = spawn();
883 e.classname = "onslaught_controlpoint_icon";
885 e.max_health = cvar("g_onslaught_cp_health");
886 e.health = e.max_health * 0.1;
887 e.solid = SOLID_BBOX;
888 e.movetype = MOVETYPE_NONE;
889 setmodel(e, "models/onslaught/controlpoint_icon.md3");
890 setsize(e, '-32 -32 -32', '32 32 32');
891 setorigin(e, self.origin + '0 0 96');
892 e.takedamage = DAMAGE_AIM;
894 e.event_damage = onslaught_controlpoint_icon_damage;
896 e.colormap = 1024 + (e.team - 1) * 17;
897 e.think = onslaught_controlpoint_icon_buildthink;
898 e.nextthink = time + 0.1;
899 e.count = e.max_health / 50; // how long it takes to build
900 sound(e, CHAN_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTN_NORM);
902 self.colormap = e.colormap;
905 void onslaught_controlpoint_reset()
907 if(self.goalentity && self.goalentity != world)
908 remove(self.goalentity);
909 self.goalentity = world;
911 self.colormap = 1024;
912 self.iscaptured = FALSE;
913 self.islinked = FALSE;
914 self.isshielded = TRUE;
915 self.enemy.solid = SOLID_NOT;
916 self.enemy.colormap = self.colormap;
917 self.think = self.enemy.think = SUB_Null;
918 self.nextthink = 0; // don't like SUB_Null :P
920 onslaught_updatelinks();
923 SUB_UseTargets(); // to reset the structures, playerspawns etc.
926 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
927 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
929 This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
932 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
933 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
934 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
936 void spawnfunc_onslaught_controlpoint()
944 precache_model("models/onslaught/controlpoint_pad.md3");
945 precache_model("models/onslaught/controlpoint_pad2.md3");
946 precache_model("models/onslaught/controlpoint_shield.md3");
947 precache_model("models/onslaught/controlpoint_icon.md3");
948 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
949 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
950 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
951 precache_model("models/onslaught/controlpoint_icon_gib1.md3");
952 precache_model("models/onslaught/controlpoint_icon_gib2.md3");
953 precache_model("models/onslaught/controlpoint_icon_gib4.md3");
954 precache_sound("onslaught/controlpoint_build.wav");
955 precache_sound("onslaught/controlpoint_built.wav");
956 precache_sound("weapons/grenade_impact.wav");
957 precache_sound("onslaught/damageblockedbyshield.wav");
958 precache_sound("onslaught/controlpoint_underattack.wav");
959 self.solid = SOLID_BSP;
960 self.movetype = MOVETYPE_NONE;
961 setmodel(self, "models/onslaught/controlpoint_pad.md3");
962 //setsize(self, '-32 -32 0', '32 32 8');
963 setorigin(self, self.origin);
964 self.touch = onslaught_controlpoint_touch;
966 self.colormap = 1024;
967 self.iscaptured = FALSE;
968 self.islinked = FALSE;
969 self.isshielded = TRUE;
970 // spawn shield model which indicates whether this can be damaged
971 self.enemy = e = spawn();
972 e.classname = "onslaught_controlpoint_shield";
974 e.movetype = MOVETYPE_NONE;
975 e.effects = EF_ADDITIVE;
976 setmodel(e, "models/onslaught/controlpoint_shield.md3");
977 //setsize(e, '-32 -32 0', '32 32 128');
978 setorigin(e, self.origin);
979 e.colormap = self.colormap;
981 waypoint_spawnforitem(self);
983 WaypointSprite_SpawnFixed(string_null, e.origin + '0 0 1' * e.maxs_z, self, sprite);
984 WaypointSprite_UpdateRule(self.sprite, COLOR_TEAM2, SPRITERULE_TEAMPLAY);
986 onslaught_updatelinks();
988 self.reset = onslaught_controlpoint_reset;
991 float onslaught_link_send(entity to, float sendflags)
993 WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
994 WriteByte(MSG_ENTITY, sendflags);
997 WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
998 WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
999 WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
1003 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
1004 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
1005 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
1009 WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
1014 void onslaught_link_checkupdate()
1016 // TODO check if the two sides have moved (currently they won't move anyway)
1017 float redpower, bluepower;
1019 redpower = bluepower = 0;
1020 if(self.goalentity.islinked)
1022 if(self.goalentity.team == COLOR_TEAM1)
1024 else if(self.goalentity.team == COLOR_TEAM2)
1027 if(self.enemy.islinked)
1029 if(self.enemy.team == COLOR_TEAM1)
1031 else if(self.enemy.team == COLOR_TEAM2)
1036 if(redpower == 1 && bluepower == 2)
1037 cc = (COLOR_TEAM1 - 1) * 0x01 + (COLOR_TEAM2 - 1) * 0x10;
1038 else if(redpower == 2 && bluepower == 1)
1039 cc = (COLOR_TEAM1 - 1) * 0x10 + (COLOR_TEAM2 - 1) * 0x01;
1041 cc = (COLOR_TEAM1 - 1) * 0x11;
1043 cc = (COLOR_TEAM2 - 1) * 0x11;
1047 if(cc != self.clientcolors)
1049 self.clientcolors = cc;
1050 self.SendFlags |= 4;
1053 self.nextthink = time;
1056 void onslaught_link_delayed()
1058 self.goalentity = find(world, targetname, self.target);
1059 self.enemy = find(world, targetname, self.target2);
1060 if (!self.goalentity)
1061 objerror("can not find target\n");
1063 objerror("can not find target2\n");
1064 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
1066 self.SendFlags |= 3;
1067 self.think = onslaught_link_checkupdate;
1068 self.nextthink = time;
1071 /*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
1072 Link between control points.
1074 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.
1077 "target" - first control point.
1078 "target2" - second control point.
1080 void spawnfunc_onslaught_link()
1087 if (self.target == "" || self.target2 == "")
1088 objerror("target and target2 must be set\n");
1089 InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
1090 Net_LinkEntity(self, FALSE, 0, onslaught_link_send);