2 void (vector vec) WriteVec =
4 WriteCoord (MSG_BROADCAST, vec_x);
5 WriteCoord (MSG_BROADCAST, vec_y);
6 WriteCoord (MSG_BROADCAST, vec_z);
8 void (vector org, vector dir, float counts) W_Smoke =
10 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
11 WriteByte (MSG_BROADCAST, TE_SMOKE);
14 WriteByte (MSG_BROADCAST, counts);
17 // increments sprite frame, loops when end is hit.. simple
18 void animate_sprite (float startframe, float frame_count)
20 if ((self.frame - startframe) >= (frame_count - 1 ))
21 self.frame = startframe;
23 self.frame = self.frame + 1;
26 void W_UpdateAmmo (void)
28 self.items = self.items - (self.items & (IT_NAILS | IT_SHELLS | IT_ROCKETS | IT_CELLS));
30 if (self.weapon == IT_LASER)
32 else if (self.weapon == IT_UZI)
34 self.currentammo = self.ammo_nails;
35 self.items = self.items | IT_NAILS;
37 else if (self.weapon == IT_SHOTGUN)
39 self.currentammo = self.ammo_shells;
40 self.items = self.items | IT_SHELLS;
42 else if (self.weapon == IT_GRENADE_LAUNCHER || self.weapon == IT_HAGAR || self.weapon == IT_ROCKET_LAUNCHER)
44 self.currentammo = self.ammo_rockets;
45 self.items = self.items | IT_ROCKETS;
47 else if (self.weapon == IT_ELECTRO || self.weapon == IT_NEX || self.weapon == IT_CRYLINK)
49 self.currentammo = self.ammo_cells;
50 self.items = self.items | IT_CELLS;
54 void W_UpdateWeapon (void)
56 if (self.weapon == IT_LASER)
57 self.weaponmodel = "models/weapons/w_laser.zym";
58 else if (self.weapon == IT_UZI)
59 self.weaponmodel = "models/weapons/w_uzi.zym";
60 else if (self.weapon == IT_SHOTGUN)
61 self.weaponmodel = "models/weapons/w_shotgun.zym";
62 else if (self.weapon == IT_GRENADE_LAUNCHER)
63 self.weaponmodel = "models/weapons/w_gl.zym";
64 else if (self.weapon == IT_ELECTRO)
65 self.weaponmodel = "models/weapons/w_electro.zym";
66 else if (self.weapon == IT_CRYLINK)
67 self.weaponmodel = "models/weapons/w_crylink.zym";
68 else if (self.weapon == IT_NEX)
69 self.weaponmodel = "models/weapons/w_nex.zym";
70 else if (self.weapon == IT_HAGAR)
71 self.weaponmodel = "models/weapons/w_hagar.zym";
72 else if (self.weapon == IT_ROCKET_LAUNCHER)
73 self.weaponmodel = "models/weapons/w_rl.zym";
75 objerror ("Illegal weapon - please register your guns please!");
78 float W_GetBestWeapon (void)
80 if ((self.items & IT_ROCKET_LAUNCHER) && self.ammo_rockets)
81 return IT_ROCKET_LAUNCHER;
82 else if ((self.items & IT_HAGAR) && self.ammo_rockets)
84 else if ((self.items & IT_NEX) && self.ammo_cells)
86 else if ((self.items & IT_CRYLINK) && self.ammo_cells)
88 else if ((self.items & IT_ELECTRO) && self.ammo_cells)
90 else if ((self.items & IT_GRENADE_LAUNCHER) && self.ammo_rockets)
91 return IT_GRENADE_LAUNCHER;
92 else if ((self.items & IT_SHOTGUN) && self.ammo_shells)
94 else if ((self.items & IT_UZI) && self.ammo_nails)
100 void W_GiveWeapon (entity e, float wep) // FIXME - make it 'smarter'
107 if (!(e.items & wep))
109 e.items = e.items | wep;
122 void W_SwitchWeapon (float wep)
125 var float noammo = FALSE;
132 if (!self.ammo_nails)
137 nextwep = IT_SHOTGUN;
138 if (!self.ammo_shells)
143 nextwep = IT_GRENADE_LAUNCHER;
144 if (!self.ammo_rockets)
149 nextwep = IT_ELECTRO;
150 if (!self.ammo_cells)
155 nextwep = IT_CRYLINK;
156 if (!self.ammo_cells)
162 if (!self.ammo_cells)
168 if (!self.ammo_rockets)
173 nextwep = IT_ROCKET_LAUNCHER;
174 if (!self.ammo_rockets)
179 if (!(self.items & nextwep))
181 sprint (self, "You don't own that weapon\n");
186 sprint (self, "You don't have any ammo for that weapon\n");
190 sound (self, CHAN_WEAPON, "weapons/gunswitch.wav", 1, ATTN_NORM);
192 self.weapon = nextwep;
195 self.attack_finished = time + 0.2;
196 if (self.viewzoom != 1)
200 void W_NextWeapon (void)
208 if (self.weapon == IT_ROCKET_LAUNCHER)
209 self.weapon = IT_LASER;
210 else if (self.weapon == IT_LASER)
212 self.weapon = IT_UZI;
213 if (!self.ammo_nails)
216 else if (self.weapon == IT_UZI)
218 self.weapon = IT_SHOTGUN;
219 if (!self.ammo_shells)
222 else if (self.weapon == IT_SHOTGUN)
224 self.weapon = IT_GRENADE_LAUNCHER;
225 if (!self.ammo_rockets)
228 else if (self.weapon == IT_GRENADE_LAUNCHER)
230 self.weapon = IT_ELECTRO;
231 if (!self.ammo_cells)
234 else if (self.weapon == IT_ELECTRO)
236 self.weapon = IT_CRYLINK;
237 if (!self.ammo_cells)
240 else if (self.weapon == IT_CRYLINK)
242 self.weapon = IT_NEX;
243 if (!self.ammo_cells)
246 else if (self.weapon == IT_NEX)
248 self.weapon = IT_HAGAR;
249 if (!self.ammo_rockets)
252 else if (self.weapon == IT_HAGAR)
254 self.weapon = IT_ROCKET_LAUNCHER;
255 if (!self.ammo_rockets)
259 if ((self.items & self.weapon) && !noammo)
266 sound (self, CHAN_WEAPON, "weapons/gunswitch.wav", 1, ATTN_NORM);
269 void W_PreviousWeapon (void)
277 if (self.weapon == IT_UZI)
278 self.weapon = IT_LASER;
279 else if (self.weapon == IT_SHOTGUN)
281 self.weapon = IT_UZI;
282 if (!self.ammo_nails)
285 else if (self.weapon == IT_GRENADE_LAUNCHER)
287 self.weapon = IT_SHOTGUN;
288 if (!self.ammo_shells)
291 else if (self.weapon == IT_ELECTRO)
293 self.weapon = IT_GRENADE_LAUNCHER;
294 if (!self.ammo_rockets)
297 else if (self.weapon == IT_CRYLINK)
299 self.weapon = IT_ELECTRO;
300 if (!self.ammo_cells)
303 else if (self.weapon == IT_NEX)
305 self.weapon = IT_CRYLINK;
306 if (!self.ammo_cells)
309 else if (self.weapon == IT_HAGAR)
311 self.weapon = IT_NEX;
312 if (!self.ammo_cells)
315 else if (self.weapon == IT_ROCKET_LAUNCHER)
317 self.weapon = IT_HAGAR;
318 if (!self.ammo_rockets)
321 else if (self.weapon == IT_LASER)
323 self.weapon = IT_ROCKET_LAUNCHER;
324 if (!self.ammo_rockets)
328 if ((self.items & self.weapon) && !noammo)
335 sound (self, CHAN_WEAPON, "weapons/gunswitch.wav", 1, ATTN_NORM);
338 float W_CheckAmmo (void)
341 if (self.weapon == IT_LASER)
343 else if (self.currentammo)
346 self.weapon = W_GetBestWeapon ();
353 void FireRailgunBullet (vector src, float bdamage, vector dir, float spread, float deathtype)
356 entity saveself, last;
358 org = self.origin + self.view_ofs;
367 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
369 lastpos = trace_endpos;
370 if (trace_fraction != 1.0)
372 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
375 if (trace_ent.takedamage || trace_ent.classname == "case")
377 if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
378 te_blood (trace_endpos, dir * bdamage * 16, bdamage);
379 Damage (trace_ent, self, self, bdamage, deathtype, trace_endpos, dir * bdamage);
382 if (last.solid == SOLID_BSP)
388 void FireRailgunBullet (vector src, float damage, vector dir, float dtype)
392 makevectors (self.v_angle);
394 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
395 org = self.origin + self.view_ofs;
396 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right + v_up, FALSE, self);
398 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
400 if (trace_ent.classname == "case")
402 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
404 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
406 te_blood (trace_endpos, dir * damage * 16, damage);
407 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
413 void fireBullet (vector dir, float spread, float damage, float dtype)
417 makevectors (self.v_angle);
419 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
420 org = self.origin + self.view_ofs;
421 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
423 // FIXME - causes excessive 'tinking'. Hopefully remove "tink1.wav" from the ricochets with csqc
424 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
426 if (trace_ent == world)
427 te_gunshot (trace_endpos);
428 else if (trace_ent.classname == "case")
430 // te_gunshot (trace_endpos);
431 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
433 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
435 te_blood (trace_endpos, dir * damage * 16, damage);
436 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
438 sound (trace_ent, CHAN_IMPACT, "misc/bodyimpact1.wav", 1, ATTN_NORM);
440 sound (trace_ent, CHAN_IMPACT, "misc/bodyimpact2.wav", 1, ATTN_NORM);
445 void W_Laser_Touch (void)
449 if (other == self.owner)
451 else if (pointcontents (self.origin) == CONTENT_SKY)
457 dir = normalize (self.owner.origin - self.origin);
459 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
460 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
461 WriteCoord (MSG_BROADCAST, self.origin_x);
462 WriteCoord (MSG_BROADCAST, self.origin_y);
463 WriteCoord (MSG_BROADCAST, self.origin_z);
464 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
465 WriteCoord (MSG_BROADCAST, 0);
466 WriteCoord (MSG_BROADCAST, 0);
467 WriteByte (MSG_BROADCAST, 155);
469 self.event_damage = SUB_Null;
470 RadiusDamage (self, self.owner, 15, 7, 50, world, 200, IT_LASER);
475 void W_Laser_Attack (void)
479 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
482 missile.owner = self;
483 missile.classname = "spike";
485 missile.movetype = MOVETYPE_FLY;
486 missile.solid = SOLID_BBOX;
488 setmodel (missile, "models/beam.mdl");
489 setsize (missile, '0 0 0', '0 0 0');
490 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
492 makevectors (self.v_angle);
493 missile.velocity = v_forward * 1000;
494 missile.velocity = missile.velocity + v_right * ( crandom() * 25 );
495 missile.velocity = missile.velocity + v_up * ( crandom() * 25 );
496 missile.angles = vectoangles (missile.velocity);
497 missile.glow_color = 250; // 244, 250
498 missile.glow_size = 30;
499 missile.touch = W_Laser_Touch;
500 missile.think = SUB_Remove;
501 missile.nextthink = time + 2;
503 self.punchangle_x = random () - 0.5;
504 self.punchangle_y = random () - 0.5;
505 self.punchangle_z = random () - 0.5;
507 self.attack_finished = time + 0.2;
510 void W_Laser_Attack2 (void)
514 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
517 missile.owner = self;
518 missile.classname = "spike";
520 missile.movetype = MOVETYPE_FLY;
521 missile.solid = SOLID_BBOX;
523 setmodel (missile, "models/beam.mdl");
524 setsize (missile, '0 0 0', '0 0 0');
525 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
527 makevectors (self.v_angle);
528 missile.velocity = v_forward * 4000;
529 missile.angles = vectoangles (missile.velocity);
530 missile.glow_color = 250; // 244, 250
531 missile.glow_size = 30;
532 missile.touch = W_Laser_Touch;
533 missile.think = SUB_Remove;
534 missile.nextthink = time + 2;
536 self.punchangle_x = random () - 0.5;
537 self.punchangle_y = random () - 0.5;
538 self.punchangle_z = random () - 0.5;
540 self.attack_finished = time + 0.4;
543 void W_Uzi_Attack (void)
545 sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
547 fireBullet (v_forward, 100, 6, IT_UZI);
549 //self.punchangle = (randomvec() + '-1 0 0') * 2;
550 //self.punchangle_z = 0; // don't want roll
552 self.attack_finished = time + 0.075;
553 self.ammo_nails = self.ammo_nails - 1;
555 vector org; // casing code
556 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
557 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 1);
558 //W_Smoke(org, v_forward, 12);
561 void W_Uzi_Attack2 (void)
566 sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);
569 if (bullets > self.ammo_nails)
570 bullets = self.ammo_nails;
572 for (sc = bullets; sc > 0; sc = sc - 1)
573 fireBullet (v_forward, 400, 8, IT_SHOTGUN);
575 //self.punchangle_x = -2;
577 self.ammo_nails = self.ammo_nails - bullets;
578 self.attack_finished = time + 0.4;
580 vector org; // casing code
581 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
582 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
585 void W_Shotgun_Attack (void)
590 sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);
594 for (sc = bullets; sc > 0; sc = sc - 1)
595 fireBullet (v_forward, 150, 8, IT_SHOTGUN);
597 self.ammo_shells = self.ammo_shells - 1;
598 self.attack_finished = time + 0.7;
600 vector org; // casing code
601 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
602 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
605 void W_Shotgun_Attack2 (void)
610 void W_Grenade_Explode (entity ignore)
612 ImpactEffect (self, IT_GRENADE_LAUNCHER);
614 self.event_damage = SUB_Null;
615 RadiusDamage (self, self.owner, 65, 35, 140, world, 400, IT_GRENADE_LAUNCHER);
620 void W_Grenade_FuseExplode (void)
622 W_Grenade_Explode (world);
625 void W_Grenade_Touch (void)
627 // I decided to take this out to add more skill to using the grenade launcher, so the user always has to trigger it.
628 // I increased the power of the grenade launcher because of this.
629 //if (other.classname == "player" || other.classname == "corpse")
630 // W_Grenade_Explode (other);
632 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
635 void W_Grenade_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
637 self.health = self.health - damage;
638 if (self.health <= 0)
639 W_Grenade_FuseExplode();
642 void W_Grenade_Attack (void)
646 sound (self, CHAN_WEAPON, "weapons/grenade_fire.wav", 1, ATTN_NORM);
648 self.punchangle_x = -4;
652 gren.classname = "grenade";
654 gren.movetype = MOVETYPE_BOUNCE;
655 gren.solid = SOLID_BBOX;
657 gren.takedamage = DAMAGE_YES;
658 gren.damageforcescale = 4;
660 gren.event_damage = W_Grenade_Damage;
662 setmodel (gren, "models/grenademodel.md3");
663 setsize (gren, '-6 -6 -3', '6 6 3');
665 makevectors (self.v_angle);
666 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
668 gren.velocity = v_forward * 900 + v_up * 200;
669 gren.angles = vectoangles (gren.velocity);
670 gren.avelocity = '150 1500 150';
672 gren.touch = W_Grenade_Touch;
673 gren.think = W_Grenade_FuseExplode;
674 gren.nextthink = time + 5;
676 self.attack_finished = time + 0.8;
677 self.ammo_rockets = self.ammo_rockets - 1;
680 void W_Grenade_Attack2 (void)
683 proj = findradius (self.origin, 50000);
686 if (proj.classname == "grenade" && proj.owner == self)
688 proj.nextthink = time;
693 self.attack_finished = time;
696 void W_Electro_Touch (void)
699 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
700 WriteByte (MSG_BROADCAST, 79);
701 WriteCoord (MSG_BROADCAST, self.origin_x);
702 WriteCoord (MSG_BROADCAST, self.origin_y);
703 WriteCoord (MSG_BROADCAST, self.origin_z);
704 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
705 WriteCoord (MSG_BROADCAST, 0);
706 WriteCoord (MSG_BROADCAST, 0);
707 WriteByte (MSG_BROADCAST, 155);
708 self.event_damage = SUB_Null;
709 RadiusDamage (self, self.owner, 50, 10, 70, world, 50, IT_ELECTRO);
713 void W_Electro_Attack (float postion)
717 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
721 proj.classname = "spike";
723 proj.movetype = MOVETYPE_FLY;
724 proj.solid = SOLID_BBOX;
727 makevectors (self.v_angle);
730 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
733 setmodel (proj, "models/bullet.mdl");
734 setsize (proj, '0 0 0', '0 0 0');
736 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -14);
738 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
740 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 15 + v_up * -14);
742 proj.velocity = v_forward * 2500;
743 proj.touch = W_Electro_Touch;
744 proj.think = SUB_Remove;
745 proj.nextthink = time + 9;
747 proj.effects = proj.effects | EF_ADDITIVE;
749 self.attack_finished = time + 0.4;
750 self.ammo_cells = self.ammo_cells - 1;
753 void W_Plasma_Explode (entity ignore)
755 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
756 WriteByte (MSG_BROADCAST, 79);
757 WriteCoord (MSG_BROADCAST, self.origin_x);
758 WriteCoord (MSG_BROADCAST, self.origin_y);
759 WriteCoord (MSG_BROADCAST, self.origin_z);
760 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
761 WriteCoord (MSG_BROADCAST, 0);
762 WriteCoord (MSG_BROADCAST, 0);
763 WriteByte (MSG_BROADCAST, 155);
765 te_customflash (self.origin, 5000, 10, '0 0 1');
767 self.event_damage = SUB_Null;
768 RadiusDamage (self, self.owner, 100, 50, 100, world, 50, IT_ELECTRO);
773 void W_Plasma_FuseExplode (void)
775 W_Plasma_Explode (world);
778 void W_Plasma_Touch (void)
780 if (other.classname == "player" || other.classname == "corpse")
781 W_Plasma_Explode (other);
783 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
786 void W_Plasma_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
788 self.health = self.health - damage;
789 if (self.health <= 0)
790 W_Plasma_FuseExplode ();
793 void W_Electro_Attack2 (float postion)
797 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
799 self.punchangle_x = -4;
803 Plasma.classname = "grenade";
806 Plasma.movetype = MOVETYPE_BOUNCE;
807 Plasma.solid = SOLID_BBOX;
810 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
813 Plasma.takedamage = DAMAGE_YES;
814 Plasma.damageforcescale = 4;
816 Plasma.event_damage = W_Plasma_Damage;
818 setmodel (Plasma, "models/bullet.mdl");
819 setsize (Plasma, '-6 -6 -3', '6 6 3');
821 makevectors (self.v_angle);
824 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 0 + v_up * -14);
826 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
828 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 20 + v_up * -14);
830 Plasma.velocity = v_forward * 900 + v_up * 200;
831 Plasma.angles = vectoangles (Plasma.velocity);
832 Plasma.avelocity = '150 1500 150';
834 Plasma.touch = W_Plasma_Touch;
835 Plasma.think = W_Plasma_FuseExplode;
836 Plasma.nextthink = time + 2;
838 Plasma.effects = Plasma.effects | EF_ADDITIVE;
840 self.attack_finished = time + 1;
841 self.ammo_cells = self.ammo_cells - 2;
845 void W_Crylink_Touch (void)
848 self.event_damage = SUB_Null;
849 te_smallflash(self.origin);
850 RadiusDamage (self, self.owner, 20, 0, 3, world, 50, IT_CRYLINK);
854 void W_Crylink_Attack (void)
859 //sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
863 proj.classname = "spike";
865 proj.movetype = MOVETYPE_FLY;
866 proj.solid = SOLID_BBOX;
868 makevectors (self.v_angle);
870 setmodel (proj, "progs/s_bubble.spr");
871 setsize (proj, '0 0 0', '0 0 0');
872 setorigin (proj, self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14);
874 proj.velocity = v_forward * 1000;
875 proj.velocity = proj.velocity + v_right * ( crandom() * 50 );
876 proj.velocity = proj.velocity + v_up * ( crandom() * 50 );
877 proj.touch = W_Crylink_Touch;
878 proj.think = SUB_Remove;
879 proj.nextthink = time + 9;
881 proj.glow_color = 10;
884 self.attack_finished = time + 0.080;
885 self.ammo_cells = self.ammo_cells - 0.2;
889 void W_Crylink_Attack2 (void)
893 sound (self, CHAN_WEAPON, "weapons/crylink.wav", 1, ATTN_NORM);
894 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
895 makevectors (self.v_angle);
897 FireRailgunBullet (org, 25, v_forward, IT_CRYLINK);
899 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
901 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
902 WriteByte (MSG_BROADCAST, 76);
903 WriteCoord (MSG_BROADCAST, org_x);
904 WriteCoord (MSG_BROADCAST, org_y);
905 WriteCoord (MSG_BROADCAST, org_z);
906 WriteCoord (MSG_BROADCAST, trace_endpos_x);
907 WriteCoord (MSG_BROADCAST, trace_endpos_y);
908 WriteCoord (MSG_BROADCAST, trace_endpos_z);
909 WriteCoord (MSG_BROADCAST, self.v_angle_x);
910 WriteCoord (MSG_BROADCAST, self.v_angle_y);
911 WriteCoord (MSG_BROADCAST, self.v_angle_z);
913 te_gunshot (trace_endpos);
915 self.ammo_cells = self.ammo_cells - 0.25;
916 self.attack_finished = time + 0.165;
919 void W_Nex_Attack (void)
924 sound (self, CHAN_WEAPON, "weapons/nexfire.wav", 1, ATTN_NORM);
925 //self.effects = EF_MUZZLEFLASH;
926 self.punchangle_x = -4;
928 makevectors (self.v_angle);
930 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 8 + v_up * -5;
932 // FIXME: make it accurate!
934 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
938 FireRailgunBullet (org, 99, v_forward, IT_NEX);
940 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
941 WriteByte (MSG_BROADCAST, 76);
942 WriteCoord (MSG_BROADCAST, org_x);
943 WriteCoord (MSG_BROADCAST, org_y);
944 WriteCoord (MSG_BROADCAST, org_z);
945 WriteCoord (MSG_BROADCAST, trace_endpos_x);
946 WriteCoord (MSG_BROADCAST, trace_endpos_y);
947 WriteCoord (MSG_BROADCAST, trace_endpos_z);
948 WriteCoord (MSG_BROADCAST, self.v_angle_x);
949 WriteCoord (MSG_BROADCAST, self.v_angle_y);
950 WriteCoord (MSG_BROADCAST, self.v_angle_z);
952 te_plasmaburn (trace_endpos);
954 dir = trace_plane_normal * 100;
955 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
956 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
957 WriteCoord (MSG_BROADCAST, trace_endpos_x);
958 WriteCoord (MSG_BROADCAST, trace_endpos_y);
959 WriteCoord (MSG_BROADCAST, trace_endpos_z);
960 WriteCoord (MSG_BROADCAST, dir_x);
961 WriteCoord (MSG_BROADCAST, dir_y);
962 WriteCoord (MSG_BROADCAST, dir_z);
963 WriteByte (MSG_BROADCAST, 255);
965 PointSound (trace_endpos, "weapons/NexImpact.wav", 1, ATTN_NORM);
967 self.attack_finished = time + 1;
968 self.ammo_cells = self.ammo_cells - 1;
971 void W_Nex_Attack2 (void)
976 void W_Hagar_Explode (void)
978 ImpactEffect (self, IT_HAGAR);
980 self.event_damage = SUB_Null;
981 RadiusDamage (self, self.owner, 20, 10, 50, world, 90, IT_HAGAR);
986 void W_Hagar_Touch (void)
988 if (other == self.owner)
990 else if (pointcontents (self.origin) == CONTENT_SKY)
999 void W_Hagar_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
1001 self.health = self.health - damage;
1002 if (self.health <= 0)
1006 void W_Hagar_Fireball (void)
1008 self.effects = self.effects | EF_FLAME;
1011 void W_Hagar_Attack (void)
1016 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
1019 missile.owner = self;
1020 missile.classname = "missile";
1022 missile.takedamage = DAMAGE_YES;
1023 missile.damageforcescale = 4;
1024 missile.health = 10;
1025 missile.event_damage = W_Hagar_Damage;
1027 missile.movetype = MOVETYPE_FLY;
1028 missile.solid = SOLID_BBOX;
1029 setmodel (missile, "models/bullet.mdl");
1030 setsize (missile, '0 0 0', '0 0 0');
1032 makevectors (self.v_angle);
1034 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1036 missile.velocity = v_forward * 2000;
1037 missile.velocity = missile.velocity + v_right * ( crandom() * 50 );
1038 missile.velocity = missile.velocity + v_up * ( crandom() * 50 );
1039 missile.angles = vectoangles (missile.velocity);
1040 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1042 missile.touch = W_Hagar_Touch;
1043 missile.think = W_Hagar_Fireball;
1044 missile.nextthink = time + 0.05;
1046 self.attack_finished = time + 0.2;
1047 self.ammo_rockets = self.ammo_rockets - 0.25;
1050 void W_Hagar_Attack2 (void)
1054 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
1057 missile.owner = self;
1058 missile.classname = "missile";
1060 missile.movetype = MOVETYPE_TOSS;
1061 missile.solid = SOLID_BBOX;
1063 missile.takedamage = DAMAGE_YES;
1064 missile.damageforcescale = 4;
1066 missile.event_damage = W_Hagar_Damage;
1068 setmodel (missile, "models/bullet.mdl");
1069 setsize (missile, '-6 -6 -3', '6 6 3');
1071 makevectors (self.v_angle);
1072 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1074 missile.velocity = v_forward * 1400 + v_up * 100;
1075 missile.angles = vectoangles (missile.velocity);
1076 missile.avelocity = '150 1500 150';
1078 missile.touch = W_Hagar_Touch;
1079 missile.think = W_Hagar_Fireball;
1080 missile.nextthink = time + 0.05;
1082 self.attack_finished = time + 0.2;
1083 self.ammo_rockets = self.ammo_rockets - 0.25;
1086 void W_Rocket_Explode (entity ignore)
1088 ImpactEffect (self, IT_ROCKET_LAUNCHER);
1090 self.event_damage = SUB_Null;
1091 RadiusDamage (self, self.owner, 130, 50, 170, ignore, 600, IT_ROCKET_LAUNCHER);
1096 void W_Rocket_Think (void)
1098 W_Rocket_Explode (world);
1101 void W_Rocket_Touch (void)
1103 if (other == self.owner)
1105 else if (pointcontents (self.origin) == CONTENT_SKY)
1111 W_Rocket_Explode (world);
1114 void W_Rocket_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
1116 self.health = self.health - damage;
1117 if (self.health <= 0)
1118 W_Rocket_Explode(world);
1121 void W_Rocket_Attack (void)
1126 sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", 1, ATTN_NORM);
1129 missile.owner = self;
1130 missile.classname = "missile";
1132 missile.takedamage = DAMAGE_YES;
1133 missile.damageforcescale = 4;
1134 missile.health = 10;
1135 missile.event_damage = W_Rocket_Damage;
1137 missile.movetype = MOVETYPE_FLY;
1138 missile.solid = SOLID_BBOX;
1139 setmodel (missile, "models/rocketmissile.mdl");
1140 setsize (missile, '0 0 0', '0 0 0');
1142 makevectors (self.v_angle);
1144 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
1146 setorigin (missile, org);
1147 missile.velocity = v_forward * 1200;
1148 missile.angles = vectoangles (missile.velocity);
1150 missile.touch = W_Rocket_Touch ;
1151 missile.think = W_Rocket_Think;
1152 missile.nextthink = time + 9;
1154 self.attack_finished = time + 1.5;
1155 self.ammo_rockets = self.ammo_rockets - 1;
1159 void W_Rocket_Attack2 (void)
1162 proj = findradius (self.origin, 50000);
1165 if (proj.classname == "missile" && proj.owner == self)
1167 proj.nextthink = time;
1172 self.attack_finished = time;
1175 void W_Attack (void)
1177 if (self.deadflag != DEAD_NO)
1179 if (self.death_time < time)
1180 PutClientInServer();
1185 if (!W_CheckAmmo ())
1188 if (self.weapon == IT_LASER)
1190 else if (self.weapon == IT_UZI)
1192 else if (self.weapon == IT_SHOTGUN)
1193 W_Shotgun_Attack ();
1194 else if (self.weapon == IT_GRENADE_LAUNCHER)
1195 W_Grenade_Attack ();
1196 else if (self.weapon == IT_ELECTRO)
1198 W_Electro_Attack (self.electrocount);
1199 self.electrocount = self.electrocount + 1;
1200 if (self.electrocount == 3)
1201 self.electrocount = 0;
1203 else if (self.weapon == IT_CRYLINK)
1204 W_Crylink_Attack ();
1205 else if (self.weapon == IT_NEX)
1207 else if (self.weapon == IT_HAGAR)
1209 else if (self.weapon == IT_ROCKET_LAUNCHER)
1215 void W_SecondaryAttack (void)
1217 if (self.deadflag != DEAD_NO)
1219 if (self.death_time < time)
1220 PutClientInServer();
1225 if (!W_CheckAmmo ())
1228 if (self.weapon == IT_LASER)
1230 else if (self.weapon == IT_UZI)
1232 else if (self.weapon == IT_SHOTGUN)
1233 W_Shotgun_Attack2 ();
1234 else if (self.weapon == IT_GRENADE_LAUNCHER)
1235 W_Grenade_Attack2 ();
1236 else if (self.weapon == IT_ELECTRO) {
1237 W_Electro_Attack2 (self.electrocount);
1238 self.electrocount = self.electrocount + 1;
1239 if (self.electrocount == 3)
1240 self.electrocount = 0;
1242 else if (self.weapon == IT_CRYLINK)
1243 W_Crylink_Attack2 ();
1244 else if (self.weapon == IT_NEX)
1246 else if (self.weapon == IT_HAGAR)
1248 else if (self.weapon == IT_ROCKET_LAUNCHER)
1249 W_Rocket_Attack2 ();