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.md3";
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 self.weapon = nextwep;
193 self.attack_finished = time + 0.2;
194 if (self.viewzoom != 1)
198 void W_NextWeapon (void)
206 if (self.weapon == IT_ROCKET_LAUNCHER)
207 self.weapon = IT_LASER;
208 else if (self.weapon == IT_LASER)
210 self.weapon = IT_UZI;
211 if (!self.ammo_nails)
214 else if (self.weapon == IT_UZI)
216 self.weapon = IT_SHOTGUN;
217 if (!self.ammo_shells)
220 else if (self.weapon == IT_SHOTGUN)
222 self.weapon = IT_GRENADE_LAUNCHER;
223 if (!self.ammo_rockets)
226 else if (self.weapon == IT_GRENADE_LAUNCHER)
228 self.weapon = IT_ELECTRO;
229 if (!self.ammo_cells)
232 else if (self.weapon == IT_ELECTRO)
234 self.weapon = IT_CRYLINK;
235 if (!self.ammo_cells)
238 else if (self.weapon == IT_CRYLINK)
240 self.weapon = IT_NEX;
241 if (!self.ammo_cells)
244 else if (self.weapon == IT_NEX)
246 self.weapon = IT_HAGAR;
247 if (!self.ammo_rockets)
250 else if (self.weapon == IT_HAGAR)
252 self.weapon = IT_ROCKET_LAUNCHER;
253 if (!self.ammo_rockets)
257 if ((self.items & self.weapon) && !noammo)
266 void W_PreviousWeapon (void)
274 if (self.weapon == IT_UZI)
275 self.weapon = IT_LASER;
276 else if (self.weapon == IT_SHOTGUN)
278 self.weapon = IT_UZI;
279 if (!self.ammo_nails)
282 else if (self.weapon == IT_GRENADE_LAUNCHER)
284 self.weapon = IT_SHOTGUN;
285 if (!self.ammo_shells)
288 else if (self.weapon == IT_ELECTRO)
290 self.weapon = IT_GRENADE_LAUNCHER;
291 if (!self.ammo_rockets)
294 else if (self.weapon == IT_CRYLINK)
296 self.weapon = IT_ELECTRO;
297 if (!self.ammo_cells)
300 else if (self.weapon == IT_NEX)
302 self.weapon = IT_CRYLINK;
303 if (!self.ammo_cells)
306 else if (self.weapon == IT_HAGAR)
308 self.weapon = IT_NEX;
309 if (!self.ammo_cells)
312 else if (self.weapon == IT_ROCKET_LAUNCHER)
314 self.weapon = IT_HAGAR;
315 if (!self.ammo_rockets)
318 else if (self.weapon == IT_LASER)
320 self.weapon = IT_ROCKET_LAUNCHER;
321 if (!self.ammo_rockets)
325 if ((self.items & self.weapon) && !noammo)
334 float W_CheckAmmo (void)
337 if (self.weapon == IT_LASER)
339 else if (self.currentammo)
342 self.weapon = W_GetBestWeapon ();
349 void FireRailgunBullet (vector src, float bdamage, vector dir, float spread, float deathtype)
352 entity saveself, last;
354 org = self.origin + self.view_ofs;
363 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
365 lastpos = trace_endpos;
366 if (trace_fraction != 1.0)
368 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
371 if (trace_ent.takedamage || trace_ent.classname == "case")
373 if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
374 te_blood (trace_endpos, dir * bdamage * 16, bdamage);
375 Damage (trace_ent, self, self, bdamage, deathtype, trace_endpos, dir * bdamage);
378 if (last.solid == SOLID_BSP)
384 void FireRailgunBullet (vector src, float damage, vector dir, float dtype)
388 makevectors (self.v_angle);
390 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
391 org = self.origin + self.view_ofs;
392 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right + v_up, FALSE, self);
394 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
396 if (trace_ent.classname == "case")
398 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
400 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
402 te_blood (trace_endpos, dir * damage * 16, damage);
403 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
409 void fireBullet (vector dir, float spread, float damage, float dtype)
413 makevectors (self.v_angle);
415 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
416 org = self.origin + self.view_ofs;
417 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
419 // FIXME - causes excessive 'tinking'. Hopefully remove "tink1.wav" from the ricochets with csqc
420 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
422 if (trace_ent == world)
423 te_gunshot (trace_endpos);
424 else if (trace_ent.classname == "case")
426 // te_gunshot (trace_endpos);
427 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
429 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
431 te_blood (trace_endpos, dir * damage * 16, damage);
432 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
433 sound (trace_ent, CHAN_IMPACT, "misc/enemyimpact.wav", 1, ATTN_NORM);
438 void W_Laser_Touch (void)
442 if (other == self.owner)
444 else if (pointcontents (self.origin) == CONTENT_SKY)
450 dir = normalize (self.owner.origin - self.origin);
452 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
453 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
454 WriteCoord (MSG_BROADCAST, self.origin_x);
455 WriteCoord (MSG_BROADCAST, self.origin_y);
456 WriteCoord (MSG_BROADCAST, self.origin_z);
457 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
458 WriteCoord (MSG_BROADCAST, 0);
459 WriteCoord (MSG_BROADCAST, 0);
460 WriteByte (MSG_BROADCAST, 155);
462 self.event_damage = SUB_Null;
463 RadiusDamage (self, self.owner, 15, 7, 50, world, 200, IT_LASER);
464 sound (self, CHAN_IMPACT, "weapons/laserimpact.wav", 1, ATTN_NORM);
469 void W_Laser_Attack (void)
473 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
476 missile.owner = self;
477 missile.classname = "spike";
479 missile.movetype = MOVETYPE_FLY;
480 missile.solid = SOLID_BBOX;
482 setmodel (missile, "models/bullet.mdl");
483 setsize (missile, '0 0 0', '0 0 0');
484 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
486 makevectors (self.v_angle);
487 missile.velocity = v_forward * 1000;
488 missile.velocity = missile.velocity + v_right * ( crandom() * 45 );
489 missile.velocity = missile.velocity + v_up * ( crandom() * 25 );
490 missile.angles = vectoangles (missile.velocity);
491 missile.glow_color = 250; // 244, 250
492 missile.glow_size = 30;
493 missile.touch = W_Laser_Touch;
494 missile.think = SUB_Remove;
495 missile.nextthink = time + 9;
497 self.punchangle_x = random () - 0.5;
498 self.punchangle_y = random () - 0.5;
499 self.punchangle_z = random () - 0.5;
501 self.attack_finished = time + 0.2;
504 void W_Laser_Attack2 (void)
508 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
511 missile.owner = self;
512 missile.classname = "spike";
514 missile.movetype = MOVETYPE_FLY;
515 missile.solid = SOLID_BBOX;
517 setmodel (missile, "models/bullet.mdl");
518 setsize (missile, '0 0 0', '0 0 0');
519 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
521 makevectors (self.v_angle);
522 missile.velocity = v_forward * 4000;
523 missile.angles = vectoangles (missile.velocity);
524 missile.glow_color = 250; // 244, 250
525 missile.glow_size = 30;
526 missile.touch = W_Laser_Touch;
527 missile.think = SUB_Remove;
528 missile.nextthink = time + 2;
530 self.punchangle_x = random () - 0.5;
531 self.punchangle_y = random () - 0.5;
532 self.punchangle_z = random () - 0.5;
534 self.attack_finished = time + 0.4;
537 void W_Uzi_Attack (void)
539 sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
541 fireBullet (v_forward, 100, 6, IT_UZI);
543 //self.punchangle = (randomvec() + '-1 0 0') * 2;
544 //self.punchangle_z = 0; // don't want roll
546 self.attack_finished = time + 0.075;
547 self.ammo_nails = self.ammo_nails - 1;
549 vector org; // casing code
550 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
551 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 1);
552 //W_Smoke(org, v_forward, 12);
555 void W_Uzi_Attack2 (void)
560 sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);
563 if (bullets > self.ammo_nails)
564 bullets = self.ammo_nails;
566 for (sc = bullets; sc > 0; sc = sc - 1)
567 fireBullet (v_forward, 400, 8, IT_SHOTGUN);
569 //self.punchangle_x = -2;
571 self.ammo_nails = self.ammo_nails - bullets;
572 self.attack_finished = time + 0.4;
574 vector org; // casing code
575 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
576 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
579 void W_Shotgun_Attack (void)
584 sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);
588 for (sc = bullets; sc > 0; sc = sc - 1)
589 fireBullet (v_forward, 150, 8, IT_SHOTGUN);
591 self.ammo_shells = self.ammo_shells - 1;
592 self.attack_finished = time + 0.7;
594 vector org; // casing code
595 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
596 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
599 void W_Shotgun_Attack2 (void)
604 void W_Grenade_Explode (entity ignore)
606 ImpactEffect (self, IT_GRENADE_LAUNCHER);
608 self.event_damage = SUB_Null;
609 RadiusDamage (self, self.owner, 65, 35, 140, world, 400, IT_GRENADE_LAUNCHER);
614 void W_Grenade_FuseExplode (void)
616 W_Grenade_Explode (world);
619 void W_Grenade_Touch (void)
621 // I decided to take this out to add more skill to using the grenade launcher, so the user always has to trigger it.
622 // I increased the power of the grenade launcher because of this.
623 //if (other.classname == "player" || other.classname == "corpse")
624 // W_Grenade_Explode (other);
626 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
629 void W_Grenade_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
631 self.health = self.health - damage;
632 if (self.health <= 0)
633 W_Grenade_FuseExplode();
636 void W_Grenade_Attack (void)
640 sound (self, CHAN_WEAPON, "weapons/grenade_fire.wav", 1, ATTN_NORM);
642 self.punchangle_x = -4;
646 gren.classname = "grenade";
648 gren.movetype = MOVETYPE_BOUNCE;
649 gren.solid = SOLID_BBOX;
651 gren.takedamage = DAMAGE_YES;
652 gren.damageforcescale = 4;
654 gren.event_damage = W_Grenade_Damage;
656 setmodel (gren, "models/grenademodel.md3");
657 setsize (gren, '-6 -6 -3', '6 6 3');
659 makevectors (self.v_angle);
660 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
662 gren.velocity = v_forward * 900 + v_up * 200;
663 gren.angles = vectoangles (gren.velocity);
664 gren.avelocity = '150 1500 150';
666 gren.touch = W_Grenade_Touch;
667 gren.think = W_Grenade_FuseExplode;
668 gren.nextthink = time + 5;
670 self.attack_finished = time + 0.8;
671 self.ammo_rockets = self.ammo_rockets - 1;
674 void W_Grenade_Attack2 (void)
677 proj = findradius (self.origin, 50000);
680 if (proj.classname == "grenade" && proj.owner == self)
682 proj.nextthink = time;
687 self.attack_finished = time;
690 void W_Electro_Touch (void)
693 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
694 WriteByte (MSG_BROADCAST, 79);
695 WriteCoord (MSG_BROADCAST, self.origin_x);
696 WriteCoord (MSG_BROADCAST, self.origin_y);
697 WriteCoord (MSG_BROADCAST, self.origin_z);
698 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
699 WriteCoord (MSG_BROADCAST, 0);
700 WriteCoord (MSG_BROADCAST, 0);
701 WriteByte (MSG_BROADCAST, 155);
702 self.event_damage = SUB_Null;
703 RadiusDamage (self, self.owner, 50, 10, 70, world, 50, IT_ELECTRO);
704 sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
708 void W_Electro_Attack (float postion)
712 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
716 proj.classname = "spike";
718 proj.movetype = MOVETYPE_FLY;
719 proj.solid = SOLID_BBOX;
722 makevectors (self.v_angle);
725 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
728 setmodel (proj, "models/bullet.mdl");
729 setsize (proj, '0 0 0', '0 0 0');
731 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -14);
733 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
735 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 15 + v_up * -14);
737 proj.velocity = v_forward * 2500;
738 proj.touch = W_Electro_Touch;
739 proj.think = SUB_Remove;
740 proj.nextthink = time + 9;
742 proj.effects = proj.effects | EF_ADDITIVE;
744 self.attack_finished = time + 0.4;
745 self.ammo_cells = self.ammo_cells - 1;
748 void W_Plasma_Explode (entity ignore)
750 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
751 WriteByte (MSG_BROADCAST, 79);
752 WriteCoord (MSG_BROADCAST, self.origin_x);
753 WriteCoord (MSG_BROADCAST, self.origin_y);
754 WriteCoord (MSG_BROADCAST, self.origin_z);
755 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
756 WriteCoord (MSG_BROADCAST, 0);
757 WriteCoord (MSG_BROADCAST, 0);
758 WriteByte (MSG_BROADCAST, 155);
760 te_customflash (self.origin, 5000, 10, '0 0 1');
762 self.event_damage = SUB_Null;
763 RadiusDamage (self, self.owner, 100, 50, 100, world, 50, IT_ELECTRO);
764 sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
769 void W_Plasma_FuseExplode (void)
771 W_Plasma_Explode (world);
774 void W_Plasma_Touch (void)
776 if (other.classname == "player" || other.classname == "corpse")
777 W_Plasma_Explode (other);
779 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
782 void W_Plasma_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
784 self.health = self.health - damage;
785 if (self.health <= 0)
786 W_Plasma_FuseExplode ();
789 void W_Electro_Attack2 (float postion)
793 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
795 self.punchangle_x = -4;
799 Plasma.classname = "grenade";
802 Plasma.movetype = MOVETYPE_BOUNCE;
803 Plasma.solid = SOLID_BBOX;
806 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
809 Plasma.takedamage = DAMAGE_YES;
810 Plasma.damageforcescale = 4;
812 Plasma.event_damage = W_Plasma_Damage;
814 setmodel (Plasma, "models/bullet.mdl");
815 setsize (Plasma, '-6 -6 -3', '6 6 3');
817 makevectors (self.v_angle);
820 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 0 + v_up * -14);
822 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
824 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 20 + v_up * -14);
826 Plasma.velocity = v_forward * 900 + v_up * 200;
827 Plasma.angles = vectoangles (Plasma.velocity);
828 Plasma.avelocity = '150 1500 150';
830 Plasma.touch = W_Plasma_Touch;
831 Plasma.think = W_Plasma_FuseExplode;
832 Plasma.nextthink = time + 2;
834 Plasma.effects = Plasma.effects | EF_ADDITIVE;
836 self.attack_finished = time + 1;
837 self.ammo_cells = self.ammo_cells - 2;
841 void W_Crylink_Touch (void)
844 self.event_damage = SUB_Null;
845 te_smallflash(self.origin);
846 RadiusDamage (self, self.owner, 20, 0, 3, world, 50, IT_CRYLINK);
850 void W_Crylink_Attack (void)
854 sound (self, CHAN_WEAPON, "weapons/crylink.wav", 1, ATTN_NORM);
855 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
856 makevectors (self.v_angle);
858 FireRailgunBullet (org, 25, v_forward, IT_CRYLINK);
860 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
862 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
863 WriteByte (MSG_BROADCAST, 76);
864 WriteCoord (MSG_BROADCAST, org_x);
865 WriteCoord (MSG_BROADCAST, org_y);
866 WriteCoord (MSG_BROADCAST, org_z);
867 WriteCoord (MSG_BROADCAST, trace_endpos_x);
868 WriteCoord (MSG_BROADCAST, trace_endpos_y);
869 WriteCoord (MSG_BROADCAST, trace_endpos_z);
870 WriteCoord (MSG_BROADCAST, self.v_angle_x);
871 WriteCoord (MSG_BROADCAST, self.v_angle_y);
872 WriteCoord (MSG_BROADCAST, self.v_angle_z);
874 te_gunshot (trace_endpos);
876 self.ammo_cells = self.ammo_cells - 0.25;
877 self.attack_finished = time + 0.165;
880 void W_Crylink_Attack2 (void)
885 //sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
889 proj.classname = "spike";
891 proj.movetype = MOVETYPE_FLY;
892 proj.solid = SOLID_BBOX;
894 makevectors (self.v_angle);
896 setmodel (proj, "models/sprites/bubbles.spr");
897 setsize (proj, '0 0 0', '0 0 0');
898 setorigin (proj, self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14);
900 proj.velocity = v_forward * 1000;
901 proj.velocity = proj.velocity + v_right * ( crandom() * 50 );
902 proj.velocity = proj.velocity + v_up * ( crandom() * 50 );
903 proj.touch = W_Crylink_Touch;
904 proj.think = SUB_Remove;
905 proj.nextthink = time + 9;
907 proj.glow_color = 10;
910 self.attack_finished = time + 0.20;
911 self.ammo_cells = self.ammo_cells - 0.2;
914 void W_Nex_Attack (void)
920 sound (self, CHAN_WEAPON, "weapons/nexfire.wav", 1, ATTN_NORM);
921 //self.effects = EF_MUZZLEFLASH;
922 self.punchangle_x = -4;
924 makevectors (self.v_angle);
926 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 8 + v_up * -5;
928 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
932 FireRailgunBullet (org, 80, v_forward, IT_NEX);
934 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
935 WriteByte (MSG_BROADCAST, 76);
936 WriteCoord (MSG_BROADCAST, org_x);
937 WriteCoord (MSG_BROADCAST, org_y);
938 WriteCoord (MSG_BROADCAST, org_z);
939 WriteCoord (MSG_BROADCAST, trace_endpos_x);
940 WriteCoord (MSG_BROADCAST, trace_endpos_y);
941 WriteCoord (MSG_BROADCAST, trace_endpos_z);
942 WriteCoord (MSG_BROADCAST, self.v_angle_x);
943 WriteCoord (MSG_BROADCAST, self.v_angle_y);
944 WriteCoord (MSG_BROADCAST, self.v_angle_z);
946 te_plasmaburn (trace_endpos);
948 dir = trace_plane_normal * 100;
949 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
950 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
951 WriteCoord (MSG_BROADCAST, trace_endpos_x);
952 WriteCoord (MSG_BROADCAST, trace_endpos_y);
953 WriteCoord (MSG_BROADCAST, trace_endpos_z);
954 WriteCoord (MSG_BROADCAST, dir_x);
955 WriteCoord (MSG_BROADCAST, dir_y);
956 WriteCoord (MSG_BROADCAST, dir_z);
957 WriteByte (MSG_BROADCAST, 255);
959 explosion = spawn ();
960 setorigin (explosion, trace_endpos);
961 RadiusDamage (explosion, self, 10, 0, 50, world, 300, IT_ROCKET_LAUNCHER);
964 PointSound (trace_endpos, "weapons/neximpact.wav", 1, ATTN_NORM);
966 self.attack_finished = time + 1;
967 self.ammo_cells = self.ammo_cells - 1;
970 void W_Nex_Attack2 (void)
975 void() W_Drunkmissile =
977 self.velocity = ((self.velocity + ((v_right * 61.000) * crandom ())) + ((v_up * 61.000) * crandom ()));
978 self.nextthink = time + 0.1;
979 self.think = W_Drunkmissile;
983 void W_Hagar_Explode (void)
985 ImpactEffect (self, IT_HAGAR);
987 self.event_damage = SUB_Null;
988 RadiusDamage (self, self.owner, 20, 10, 50, world, 90, IT_HAGAR);
993 void W_Hagar_Fireball (void)
995 self.effects = self.effects | EF_FLAME;
998 void W_Hagar_Touch (void)
1000 if (other == self.owner)
1002 else if (pointcontents (self.origin) == CONTENT_SKY)
1011 void W_Hagar_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
1013 self.health = self.health - damage;
1014 if (self.health <= 0)
1018 void W_Hagar_Attack (void)
1023 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
1026 missile.owner = self;
1027 missile.classname = "missile";
1029 missile.takedamage = DAMAGE_YES;
1030 missile.damageforcescale = 4;
1031 missile.health = 10;
1032 missile.event_damage = W_Hagar_Damage;
1034 missile.movetype = MOVETYPE_FLY;
1035 missile.solid = SOLID_BBOX;
1036 setmodel (missile, "models/hagarmissile.mdl");
1037 setsize (missile, '0 0 0', '0 0 0');
1039 makevectors (self.v_angle);
1041 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1043 missile.velocity = v_forward * 2000;
1044 missile.velocity = missile.velocity + v_right * ( crandom() * 70 );
1045 missile.velocity = missile.velocity + v_up * ( crandom() * 30 );
1046 missile.angles = vectoangles (missile.velocity);
1047 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1049 missile.touch = W_Hagar_Touch;
1050 missile.think = W_Hagar_Explode;
1051 missile.nextthink = time + 10;
1053 self.attack_finished = time + 0.2;
1054 self.ammo_rockets = self.ammo_rockets - 0.25;
1057 void W_Hagar_Attack2 (void)
1061 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
1064 missile.owner = self;
1065 missile.classname = "missile";
1067 missile.movetype = MOVETYPE_TOSS;
1068 missile.solid = SOLID_BBOX;
1070 missile.takedamage = DAMAGE_YES;
1071 missile.damageforcescale = 4;
1073 missile.event_damage = W_Hagar_Damage;
1075 setmodel (missile, "models/bullet.mdl");
1076 setsize (missile, '-6 -6 -3', '6 6 3');
1078 makevectors (self.v_angle);
1079 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1081 missile.velocity = v_forward * 1400 + v_up * 100;
1082 missile.angles = vectoangles (missile.velocity);
1083 missile.avelocity = '150 1500 150';
1085 missile.touch = W_Hagar_Touch;
1086 missile.think = W_Hagar_Fireball;
1087 missile.nextthink = time + 0.05;
1089 self.attack_finished = time + 0.2;
1090 self.ammo_rockets = self.ammo_rockets - 0.25;
1093 void W_Hagar_Attack3 (void)
1098 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
1101 missile.owner = self;
1102 missile.classname = "missile";
1104 missile.takedamage = DAMAGE_YES;
1105 missile.damageforcescale = 4;
1106 missile.health = 10;
1107 missile.event_damage = W_Hagar_Damage;
1109 missile.movetype = MOVETYPE_FLY;
1110 missile.solid = SOLID_BBOX;
1111 setmodel (missile, "models/hagarmissile.mdl");
1112 setsize (missile, '0 0 0', '0 0 0');
1114 makevectors (self.v_angle);
1116 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1118 missile.velocity = v_forward * 1000;
1119 missile.angles = vectoangles (missile.velocity);
1120 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1122 missile.touch = W_Hagar_Touch;
1123 missile.think = W_Drunkmissile;
1124 missile.nextthink = time + 0.01;
1126 self.attack_finished = time + 0.2;
1127 self.ammo_rockets = self.ammo_rockets - 0.25;
1130 void W_Rocket_Explode (entity ignore)
1132 ImpactEffect (self, IT_ROCKET_LAUNCHER);
1134 self.event_damage = SUB_Null;
1135 RadiusDamage (self, self.owner, 130, 50, 170, ignore, 600, IT_ROCKET_LAUNCHER);
1140 void W_Rocket_Think (void)
1142 W_Rocket_Explode (world);
1145 void W_Rocket_Touch (void)
1147 if (other == self.owner)
1149 else if (pointcontents (self.origin) == CONTENT_SKY)
1155 W_Rocket_Explode (world);
1158 void W_Rocket_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
1160 self.health = self.health - damage;
1161 if (self.health <= 0)
1162 W_Rocket_Explode(world);
1165 void W_Rocket_Attack (void)
1170 sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", 1, ATTN_NORM);
1173 missile.owner = self;
1174 missile.classname = "missile";
1176 missile.takedamage = DAMAGE_YES;
1177 missile.damageforcescale = 4;
1178 missile.health = 10;
1179 missile.event_damage = W_Rocket_Damage;
1181 missile.movetype = MOVETYPE_FLY;
1182 missile.solid = SOLID_BBOX;
1183 setmodel (missile, "models/rocketmissile.mdl");
1184 setsize (missile, '0 0 0', '0 0 0');
1186 makevectors (self.v_angle);
1188 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
1190 setorigin (missile, org);
1191 missile.velocity = v_forward * 1200;
1192 missile.angles = vectoangles (missile.velocity);
1194 missile.touch = W_Rocket_Touch ;
1195 missile.think = W_Rocket_Think;
1196 missile.nextthink = time + 9;
1198 self.attack_finished = time + 1.5;
1199 self.ammo_rockets = self.ammo_rockets - 1;
1203 void W_Rocket_Attack2 (void)
1206 proj = findradius (self.origin, 50000);
1209 if (proj.classname == "missile" && proj.owner == self)
1211 proj.nextthink = time;
1216 self.attack_finished = time;
1220 void W_Attack (void)
1222 if (self.deadflag != DEAD_NO)
1224 if (self.death_time < time)
1225 PutClientInServer();
1230 if (!W_CheckAmmo ())
1233 if (self.weapon == IT_LASER)
1235 else if (self.weapon == IT_UZI)
1237 else if (self.weapon == IT_SHOTGUN)
1238 W_Shotgun_Attack ();
1239 else if (self.weapon == IT_GRENADE_LAUNCHER)
1240 W_Grenade_Attack ();
1241 else if (self.weapon == IT_ELECTRO)
1243 W_Electro_Attack (self.electrocount);
1244 self.electrocount = self.electrocount + 1;
1245 if (self.electrocount == 3)
1246 self.electrocount = 0;
1248 else if (self.weapon == IT_CRYLINK)
1249 W_Crylink_Attack ();
1250 else if (self.weapon == IT_NEX)
1252 else if (self.weapon == IT_HAGAR)
1254 else if (self.weapon == IT_ROCKET_LAUNCHER)
1260 void W_SecondaryAttack (void)
1262 if (self.deadflag != DEAD_NO)
1264 if (self.death_time < time)
1265 PutClientInServer();
1270 if (!W_CheckAmmo ())
1273 if (self.weapon == IT_LASER)
1275 else if (self.weapon == IT_UZI)
1277 else if (self.weapon == IT_SHOTGUN)
1278 W_Shotgun_Attack2 ();
1279 else if (self.weapon == IT_GRENADE_LAUNCHER)
1280 W_Grenade_Attack2 ();
1281 else if (self.weapon == IT_ELECTRO) {
1282 W_Electro_Attack2 (self.electrocount);
1283 self.electrocount = self.electrocount + 1;
1284 if (self.electrocount == 3)
1285 self.electrocount = 0;
1287 else if (self.weapon == IT_CRYLINK)
1288 W_Crylink_Attack2 ();
1289 else if (self.weapon == IT_NEX)
1291 else if (self.weapon == IT_HAGAR)
1293 else if (self.weapon == IT_ROCKET_LAUNCHER)
1294 W_Rocket_Attack2 ();
1299 void W_ThirdAttack (void)
1301 if (self.deadflag != DEAD_NO)
1303 if (self.death_time < time)
1304 PutClientInServer();
1309 if (!W_CheckAmmo ())
1312 if (self.weapon == IT_HAGAR)