6 void() onslaught_updatelinks =
\r
8 local entity l, links;
\r
9 local float stop, t1, t2, t3, t4;
\r
10 // first check if the game has ended
\r
11 dprint("--- updatelinks ---\n");
\r
12 links = findchain(classname, "onslaught_link");
\r
13 // mark generators as being shielded and networked
\r
14 l = findchain(classname, "onslaught_generator");
\r
18 dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
\r
20 dprint(etos(l), " (generator) is destroyed\n");
\r
21 l.islinked = l.iscaptured;
\r
22 l.isshielded = l.iscaptured;
\r
25 // mark points as shielded and not networked
\r
26 l = findchain(classname, "onslaught_controlpoint");
\r
30 l.isshielded = TRUE;
\r
31 dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
\r
34 // flow power outward from the generators through the network
\r
38 dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
\r
48 // if both points are captured by the same team, and only one of
\r
49 // them is powered, mark the other one as powered as well
\r
50 if (l.enemy.iscaptured && l.goalentity.iscaptured)
\r
51 if (l.enemy.islinked != l.goalentity.islinked)
\r
52 if (l.enemy.team == l.goalentity.team)
\r
54 if (!l.goalentity.islinked)
\r
57 l.goalentity.islinked = TRUE;
\r
58 dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
\r
60 else if (!l.enemy.islinked)
\r
63 l.enemy.islinked = TRUE;
\r
64 dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
\r
70 // now that we know which points are powered we can mark their neighbors
\r
71 // as unshielded if team differs
\r
75 if (l.goalentity.team != l.enemy.team)
\r
77 if (l.goalentity.islinked)
\r
79 dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
\r
80 l.enemy.isshielded = FALSE;
\r
82 if (l.enemy.islinked)
\r
84 dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
\r
85 l.goalentity.isshielded = FALSE;
\r
90 // now update the takedamage and alpha variables on generator shields
\r
91 l = findchain(classname, "onslaught_generator");
\r
96 dprint(etos(l), " (generator) is shielded\n");
\r
98 l.takedamage = DAMAGE_NO;
\r
99 l.bot_attack = FALSE;
\r
103 dprint(etos(l), " (generator) is not shielded\n");
\r
104 l.enemy.alpha = -1;
\r
105 l.takedamage = DAMAGE_AIM;
\r
106 l.bot_attack = TRUE;
\r
110 // now update the takedamage and alpha variables on control point icons
\r
111 l = findchain(classname, "onslaught_controlpoint");
\r
116 dprint(etos(l), " (point) is shielded\n");
\r
120 l.goalentity.takedamage = DAMAGE_NO;
\r
121 l.goalentity.bot_attack = FALSE;
\r
126 dprint(etos(l), " (point) is not shielded\n");
\r
127 l.enemy.alpha = -1;
\r
130 l.goalentity.takedamage = DAMAGE_AIM;
\r
131 l.goalentity.bot_attack = TRUE;
\r
136 // count generators owned by each team
\r
137 t1 = t2 = t3 = t4 = 0;
\r
138 l = findchain(classname, "onslaught_generator");
\r
143 if (l.team == COLOR_TEAM1) t1 = 1;
\r
144 if (l.team == COLOR_TEAM2) t2 = 1;
\r
145 if (l.team == COLOR_TEAM3) t3 = 1;
\r
146 if (l.team == COLOR_TEAM4) t4 = 1;
\r
150 // see if multiple teams remain (if not, it's game over)
\r
151 if (t1 + t2 + t3 + t4 < 2)
\r
152 dprint("--- game over ---\n");
\r
154 dprint("--- done updating links ---\n");
\r
157 void() onslaught_generator_think =
\r
161 self.nextthink = ceil(time + 1);
\r
162 if (cvar("timelimit"))
\r
163 if (time > cvar("timelimit") * 60 - 60)
\r
165 // self.max_health / 300 gives 5 minutes of overtime.
\r
166 // control points reduce the overtime duration.
\r
167 sound(self, CHAN_AUTO, "sound/onslaught/generator_decay.wav", 1, ATTN_NORM);
\r
169 e = findchain(classname, "onslaught_controlpoint");
\r
172 if (e.team != self.team)
\r
177 d = d * self.max_health / 300;
\r
178 Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
\r
182 void() onslaught_generator_deaththink =
\r
185 if (self.count > 0)
\r
187 self.nextthink = time + 0.1;
\r
188 self.count = self.count - 1;
\r
189 org = randompos(self.origin + self.mins + '8 8 8', self.origin + self.maxs + '-8 -8 -8');
\r
190 pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
\r
191 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
\r
196 pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
\r
197 sound(self, CHAN_AUTO, "sound/weapons/rocket_impact.wav", 1, ATTN_NORM);
\r
201 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_generator_damage =
\r
205 if (attacker != self)
\r
207 if (self.isshielded)
\r
209 // this is protected by a shield, so ignore the damage
\r
210 if (time > self.pain_finished)
\r
211 if (attacker.classname == "player")
\r
213 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
\r
214 self.pain_finished = time + 1;
\r
218 if (time > self.pain_finished)
\r
220 self.pain_finished = time + 5;
\r
221 bprint(ColoredTeamName(self.team), " generator under attack!\n");
\r
222 play2team(self.team, "sound/onslaught/generator_underattack.wav");
\r
225 self.health = self.health - damage;
\r
226 // choose an animation frame based on health
\r
227 self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
\r
228 // see if the generator is still functional, or dying
\r
229 if (self.health > 0)
\r
230 bprint(ColoredTeamName(self.team), " generator has ", ftos(floor(self.health)), " health remaining\n");
\r
233 if (attacker == self)
\r
234 bprint(ColoredTeamName(self.team), " generator spontaneously exploded due to overtime!\n");
\r
236 bprint(ColoredTeamName(self.team), " generator destroyed by ", ColoredTeamName(attacker.team), "!\n");
\r
237 self.iscaptured = FALSE;
\r
238 self.islinked = FALSE;
\r
239 self.isshielded = FALSE;
\r
240 self.takedamage = DAMAGE_NO; // can't be hurt anymore
\r
241 self.event_damage = SUB_Null; // won't do anything if hurt
\r
242 self.count = 30; // 30 explosions
\r
243 self.think = onslaught_generator_deaththink; // explosion sequence
\r
244 self.nextthink = time; // start exploding immediately
\r
245 self.think(); // do the first explosion now
\r
246 onslaught_updatelinks();
\r
250 // update links after a delay
\r
251 void() onslaught_generator_delayed =
\r
253 onslaught_updatelinks();
\r
254 // now begin normal thinking
\r
255 self.think = onslaught_generator_think;
\r
256 self.nextthink = time;
\r
259 /*QUAKED onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
\r
262 onslaught_link entities can target this.
\r
265 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
\r
266 "targetname" - name that onslaught_link entities will use to target this.
\r
268 void() onslaught_generator =
\r
276 precache_model("models/onslaught/generator.md3");
\r
277 precache_model("models/onslaught/generator_shield.md3");
\r
278 precache_sound("sound/onslaught/generator_decay.wav");
\r
279 precache_sound("sound/weapons/grenade_impact.wav");
\r
280 precache_sound("sound/weapons/rocket_impact.wav");
\r
281 precache_sound("sound/onslaught/generator_underattack.wav");
\r
283 objerror("team must be set");
\r
284 self.colormap = 1024 + (self.team - 1) * 17;
\r
285 self.solid = SOLID_BSP;
\r
286 self.movetype = MOVETYPE_NONE;
\r
287 self.max_health = self.health = 3000;
\r
288 setmodel(self, "models/onslaught/generator.md3");
\r
289 //setsize(self, '-32 -32 -24', '32 32 64');
\r
290 setorigin(self, self.origin);
\r
291 self.takedamage = DAMAGE_AIM;
\r
292 self.bot_attack = TRUE;
\r
293 self.event_damage = onslaught_generator_damage;
\r
294 self.iscaptured = TRUE;
\r
295 self.islinked = TRUE;
\r
296 self.isshielded = TRUE;
\r
297 // spawn shield model which indicates whether this can be damaged
\r
298 self.enemy = e = spawn();
\r
299 e.solid = SOLID_NOT;
\r
300 e.movetype = MOVETYPE_NONE;
\r
301 e.effects = EF_ADDITIVE;
\r
302 setmodel(e, "models/onslaught/generator_shield.md3");
\r
303 //setsize(e, '-32 -32 0', '32 32 128');
\r
304 setorigin(e, self.origin);
\r
305 e.colormap = self.colormap;
\r
306 e.team = self.team;
\r
307 self.think = onslaught_generator_delayed;
\r
308 self.nextthink = time + 0.2;
\r
311 void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) onslaught_controlpoint_icon_damage =
\r
315 if (self.owner.isshielded)
\r
317 // this is protected by a shield, so ignore the damage
\r
318 if (time > self.pain_finished)
\r
319 if (attacker.classname == "player")
\r
321 play2(attacker, "sound/onslaught/damageblockedbyshield.wav");
\r
322 self.pain_finished = time + 1;
\r
326 if (time > self.pain_finished)
\r
327 if (attacker.classname == "player")
\r
329 play2team(self.team, "sound/onslaught/controlpoint_underattack.wav");
\r
330 self.pain_finished = time + 5;
\r
332 self.health = self.health - damage;
\r
333 self.alpha = self.health / self.max_health;
\r
334 self.pain_finished = time + 1;
\r
335 // colormod flash when shot
\r
336 self.colormod = '2 2 2';
\r
337 if (self.health < 0)
\r
339 sound(self, CHAN_AUTO, "sound/weapons/grenade_impact.wav", 1, ATTN_NORM);
\r
340 pointparticles(particleeffectnum("onslaught_controlpoint_explosion"), self.origin, '0 0 0', 1);
\r
341 bprint(ColoredTeamName(self.team), " ", self.message, " control point destroyed by ", ColoredTeamName(attacker.team), "\n");
\r
342 self.owner.goalentity = world;
\r
343 self.owner.islinked = FALSE;
\r
344 self.owner.iscaptured = FALSE;
\r
345 self.owner.team = 0;
\r
346 self.owner.colormap = 1024;
\r
347 onslaught_updatelinks();
\r
352 void() onslaught_controlpoint_icon_think =
\r
354 self.nextthink = time + 0.1;
\r
355 if (time > self.pain_finished + 1)
\r
357 self.health = self.health + self.count;
\r
358 if (self.health >= self.max_health)
\r
359 self.health = self.max_health;
\r
361 self.alpha = self.health / self.max_health;
\r
362 // colormod flash when shot
\r
363 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
\r
366 void() onslaught_controlpoint_icon_buildthink =
\r
368 local entity oself;
\r
371 self.nextthink = time + 0.1;
\r
372 self.health = self.health + self.count;
\r
373 if (self.health >= self.max_health)
\r
375 self.health = self.max_health;
\r
376 self.count = self.count * 0.2; // slow repair rate from now on
\r
377 self.think = onslaught_controlpoint_icon_think;
\r
378 sound(self, CHAN_BODY, "sound/onslaught/controlpoint_built.wav", 1, ATTN_NORM);
\r
379 bprint(ColoredTeamName(self.team), " captured ", self.owner.message, " control point\n");
\r
380 self.owner.iscaptured = TRUE;
\r
381 onslaught_updatelinks();
\r
383 // Use targets now (somebody make sure this is in the right place..)
\r
389 self.alpha = self.health / self.max_health;
\r
390 // colormod flash when shot
\r
391 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
\r
394 void() onslaught_controlpoint_touch =
\r
397 if (other.classname != "player")
\r
399 // if there's already an icon built, nothing happens
\r
400 if (self.goalentity)
\r
405 // shielded points are definitely off-limits
\r
406 if (self.isshielded)
\r
411 // check to see if this player has a legitimate claim to capture this
\r
412 // control point - more specifically that there is a captured path of
\r
413 // points leading back to the team generator
\r
414 e = findchain(classname, "onslaught_link");
\r
417 if (e.goalentity == self)
\r
419 dprint(etos(e), " (link) connects to ", etos(e.enemy), " (point)");
\r
420 if (e.enemy.islinked)
\r
422 dprint(" which is linked");
\r
423 if (e.enemy.team == other.team)
\r
425 dprint(" and has the correct team!\n");
\r
429 dprint(" but has the wrong team\n");
\r
434 else if (e.enemy == self)
\r
436 dprint(etos(e), " (link) connects to ", etos(e.goalentity), " (point)");
\r
437 if (e.goalentity.islinked)
\r
439 dprint(" which is linked");
\r
440 if (e.goalentity.team == other.team)
\r
442 dprint(" and has a team!\n");
\r
446 dprint(" but has the wrong team\n");
\r
458 // we've verified that this player has a legitimate claim to this point,
\r
459 // so start building the captured point icon (which only captures this
\r
460 // point if it successfully builds without being destroyed first)
\r
461 self.goalentity = e = spawn();
\r
463 e.max_health = 1000;
\r
464 e.health = e.max_health * 0.1;
\r
465 e.alpha = e.health / e.max_health;
\r
466 e.solid = SOLID_BBOX;
\r
467 e.movetype = MOVETYPE_NONE;
\r
468 setmodel(e, "models/onslaught/controlpoint_icon.md3");
\r
469 setsize(e, '-32 -32 -32', '32 32 32');
\r
470 setorigin(e, self.origin + '0 0 96');
\r
471 e.takedamage = DAMAGE_AIM;
\r
472 e.bot_attack = TRUE;
\r
473 e.event_damage = onslaught_controlpoint_icon_damage;
\r
474 e.team = other.team;
\r
475 e.colormap = 1024 + (e.team - 1) * 17;
\r
476 e.think = onslaught_controlpoint_icon_buildthink;
\r
477 e.nextthink = time + 0.1;
\r
478 e.count = e.max_health / 50; // how long it takes to build
\r
479 sound(e, CHAN_BODY, "sound/onslaught/controlpoint_build.wav", 1, ATTN_NORM);
\r
480 self.team = e.team;
\r
481 self.colormap = e.colormap;
\r
484 /*QUAKED onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
\r
485 Control point. Be sure to give this enough clearance so that the shootable part has room to exist
\r
487 This should link to an onslaught_controlpoint entity or onslaught_generator entity.
\r
490 "targetname" - name that onslaught_link entities will use to target this.
\r
491 "target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
\r
492 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
\r
494 void() onslaught_controlpoint =
\r
502 precache_model("models/onslaught/controlpoint_pad.md3");
\r
503 precache_model("models/onslaught/controlpoint_shield.md3");
\r
504 precache_model("models/onslaught/controlpoint_icon.md3");
\r
505 precache_sound("sound/onslaught/controlpoint_build.wav");
\r
506 precache_sound("sound/onslaught/controlpoint_built.wav");
\r
507 precache_sound("sound/weapons/grenade_impact.wav");
\r
508 precache_sound("sound/onslaught/damageblockedbyshield.wav");
\r
509 precache_sound("sound/onslaught/controlpoint_underattack.wav");
\r
510 self.solid = SOLID_BSP;
\r
511 self.movetype = MOVETYPE_NONE;
\r
512 setmodel(self, "models/onslaught/controlpoint_pad.md3");
\r
513 //setsize(self, '-32 -32 0', '32 32 8');
\r
514 setorigin(self, self.origin);
\r
515 self.touch = onslaught_controlpoint_touch;
\r
517 self.colormap = 1024;
\r
518 self.iscaptured = FALSE;
\r
519 self.islinked = FALSE;
\r
520 self.isshielded = TRUE;
\r
521 // spawn shield model which indicates whether this can be damaged
\r
522 self.enemy = e = spawn();
\r
523 e.solid = SOLID_NOT;
\r
524 e.movetype = MOVETYPE_NONE;
\r
525 e.effects = EF_ADDITIVE;
\r
526 setmodel(e, "models/onslaught/controlpoint_shield.md3");
\r
527 //setsize(e, '-32 -32 0', '32 32 128');
\r
528 setorigin(e, self.origin);
\r
529 e.colormap = self.colormap;
\r
530 onslaught_updatelinks();
\r
533 void() onslaught_link_delayed =
\r
535 self.goalentity = find(world, targetname, self.target);
\r
536 self.enemy = find(world, targetname, self.target2);
\r
537 if (!self.goalentity)
\r
538 objerror("can not find target\n");
\r
540 objerror("can not find target2\n");
\r
541 dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
\r
544 /*QUAKED onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
\r
545 Link between control points.
\r
547 This entity targets two different onslaught_controlpoint or onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
\r
550 "target" - first control point.
\r
551 "target2" - second control point.
\r
553 void() onslaught_link =
\r
560 if (self.target == "" || self.target2 == "")
\r
561 objerror("target and target2 must be set\n");
\r
562 self.think = onslaught_link_delayed;
\r
563 self.nextthink = time + 0.1;
\r
566 void() onslaught_spawnpoint_use =
\r
568 self.team = activator.team;
\r