1 // increments sprite frame, loops when end is hit.. simple
2 void animate_sprite (float startframe, float frame_count)
4 if ((self.frame - startframe) >= (frame_count - 1 ))
5 self.frame = startframe;
7 self.frame = self.frame + 1;
10 void W_UpdateAmmo (void)
12 self.items = self.items - (self.items & (IT_NAILS | IT_SHELLS | IT_ROCKETS | IT_CELLS));
14 if (self.weapon == IT_LASER)
16 else if (self.weapon == IT_UZI)
18 self.currentammo = self.ammo_nails;
19 self.items = self.items | IT_NAILS;
21 else if (self.weapon == IT_SHOTGUN)
23 self.currentammo = self.ammo_shells;
24 self.items = self.items | IT_SHELLS;
26 else if (self.weapon == IT_GRENADE_LAUNCHER || self.weapon == IT_HAGAR || self.weapon == IT_ROCKET_LAUNCHER)
28 self.currentammo = self.ammo_rockets;
29 self.items = self.items | IT_ROCKETS;
31 else if (self.weapon == IT_ELECTRO || self.weapon == IT_NEX || self.weapon == IT_CRYLINK)
33 self.currentammo = self.ammo_cells;
34 self.items = self.items | IT_CELLS;
38 void W_UpdateWeapon (void)
40 if (self.weapon == IT_LASER)
41 self.weaponmodel = "models/weapons/w_laser.md3";
42 else if (self.weapon == IT_UZI)
43 self.weaponmodel = "models/weapons/w_uzi.md3";
44 else if (self.weapon == IT_SHOTGUN)
45 self.weaponmodel = "models/weapons/w_shotgun.md3";
46 else if (self.weapon == IT_GRENADE_LAUNCHER)
47 self.weaponmodel = "models/weapons/w_gl.md3";
48 else if (self.weapon == IT_ELECTRO)
49 self.weaponmodel = "models/weapons/w_electro.md3";
50 else if (self.weapon == IT_CRYLINK)
51 self.weaponmodel = "models/weapons/w_crylink.md3";
52 else if (self.weapon == IT_NEX)
53 self.weaponmodel = "models/weapons/w_nex.md3";
54 else if (self.weapon == IT_HAGAR)
55 self.weaponmodel = "models/weapons/w_hagar.md3";
56 else if (self.weapon == IT_ROCKET_LAUNCHER)
57 self.weaponmodel = "models/weapons/w_rl.md3";
59 objerror ("Illegal weapon - please register your guns please!");
62 float W_GetBestWeapon (void)
64 if ((self.items & IT_ROCKET_LAUNCHER) && self.ammo_rockets)
65 return IT_ROCKET_LAUNCHER;
66 else if ((self.items & IT_HAGAR) && self.ammo_rockets)
68 else if ((self.items & IT_NEX) && self.ammo_cells)
70 else if ((self.items & IT_CRYLINK) && self.ammo_cells)
72 else if ((self.items & IT_ELECTRO) && self.ammo_cells)
74 else if ((self.items & IT_GRENADE_LAUNCHER) && self.ammo_rockets)
75 return IT_GRENADE_LAUNCHER;
76 else if ((self.items & IT_SHOTGUN) && self.ammo_shells)
78 else if ((self.items & IT_UZI) && self.ammo_nails)
84 void W_GiveWeapon (entity e, float wep) // FIXME - make it 'smarter'
93 e.items = e.items | wep;
106 void W_SwitchWeapon (float wep)
109 var float noammo = FALSE;
116 if (!self.ammo_nails)
121 nextwep = IT_SHOTGUN;
122 if (!self.ammo_shells)
127 nextwep = IT_GRENADE_LAUNCHER;
128 if (!self.ammo_rockets)
133 nextwep = IT_ELECTRO;
134 if (!self.ammo_cells)
139 nextwep = IT_CRYLINK;
140 if (!self.ammo_cells)
146 if (!self.ammo_cells)
152 if (!self.ammo_rockets)
157 nextwep = IT_ROCKET_LAUNCHER;
158 if (!self.ammo_rockets)
163 if (!(self.items & nextwep))
165 sprint (self, "You don't own that weapon\n");
170 sprint (self, "You don't have any ammo for that weapon\n");
174 self.weapon = nextwep;
177 self.attack_finished = time + 0.2;
178 if (self.viewzoom != 1)
182 void W_NextWeapon (void)
190 if (self.weapon == IT_ROCKET_LAUNCHER)
191 self.weapon = IT_LASER;
192 else if (self.weapon == IT_LASER)
194 self.weapon = IT_UZI;
195 if (!self.ammo_nails)
198 else if (self.weapon == IT_UZI)
200 self.weapon = IT_SHOTGUN;
201 if (!self.ammo_shells)
204 else if (self.weapon == IT_SHOTGUN)
206 self.weapon = IT_GRENADE_LAUNCHER;
207 if (!self.ammo_rockets)
210 else if (self.weapon == IT_GRENADE_LAUNCHER)
212 self.weapon = IT_ELECTRO;
213 if (!self.ammo_cells)
216 else if (self.weapon == IT_ELECTRO)
218 self.weapon = IT_CRYLINK;
219 if (!self.ammo_cells)
222 else if (self.weapon == IT_CRYLINK)
224 self.weapon = IT_NEX;
225 if (!self.ammo_cells)
228 else if (self.weapon == IT_NEX)
230 self.weapon = IT_HAGAR;
231 if (!self.ammo_rockets)
234 else if (self.weapon == IT_HAGAR)
236 self.weapon = IT_ROCKET_LAUNCHER;
237 if (!self.ammo_rockets)
241 if ((self.items & self.weapon) && !noammo)
250 void W_PreviousWeapon (void)
258 if (self.weapon == IT_UZI)
259 self.weapon = IT_LASER;
260 else if (self.weapon == IT_SHOTGUN)
262 self.weapon = IT_UZI;
263 if (!self.ammo_nails)
266 else if (self.weapon == IT_GRENADE_LAUNCHER)
268 self.weapon = IT_SHOTGUN;
269 if (!self.ammo_shells)
272 else if (self.weapon == IT_ELECTRO)
274 self.weapon = IT_GRENADE_LAUNCHER;
275 if (!self.ammo_rockets)
278 else if (self.weapon == IT_CRYLINK)
280 self.weapon = IT_ELECTRO;
281 if (!self.ammo_cells)
284 else if (self.weapon == IT_NEX)
286 self.weapon = IT_CRYLINK;
287 if (!self.ammo_cells)
290 else if (self.weapon == IT_HAGAR)
292 self.weapon = IT_NEX;
293 if (!self.ammo_cells)
296 else if (self.weapon == IT_ROCKET_LAUNCHER)
298 self.weapon = IT_HAGAR;
299 if (!self.ammo_rockets)
302 else if (self.weapon == IT_LASER)
304 self.weapon = IT_ROCKET_LAUNCHER;
305 if (!self.ammo_rockets)
309 if ((self.items & self.weapon) && !noammo)
318 float W_CheckAmmo (void)
321 if (self.weapon == IT_LASER)
323 else if (self.currentammo)
326 self.weapon = W_GetBestWeapon ();
332 void FireRailgunBullet (vector src, float bdamage, vector dir)
335 entity saveself, last;
345 traceline_hitcorpse (self, lastpos + dir * 2, lastpos + dir*8192, FALSE, last);
347 lastpos = trace_endpos;
348 if (trace_fraction != 1.0)
350 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
353 if (trace_ent.takedamage || trace_ent.classname == "case")
355 if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
356 te_blood (trace_endpos, dir * bdamage * 16, bdamage);
357 Damage (self, trace_endpos, trace_ent, 0, bdamage, dir * bdamage);
360 if (last.solid == SOLID_BSP)
365 void fireBullet (vector dir, float spread, float damage, float dtype)
369 makevectors (self.v_angle);
371 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
372 org = self.origin + self.view_ofs;
373 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
375 // FIXME - causes excessive 'tinking'. Hopefully remove "tink1.wav" from the ricochets with csqc
376 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
378 if (trace_ent == world)
379 te_spike (trace_endpos);
380 else if (trace_ent.classname == "case")
382 // te_spike (trace_endpos);
383 Damage (self, trace_endpos, trace_ent, 0, damage, dir * damage);
385 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
387 te_blood (trace_endpos, dir * damage * 16, damage);
388 Damage (self, trace_endpos, trace_ent, 0, damage, dir * damage);
390 sound (trace_ent, CHAN_IMPACT, "misc/BodyImpact1.wav", 1, ATTN_NORM);
392 sound (trace_ent, CHAN_IMPACT, "misc/BodyImpact2.wav", 1, ATTN_NORM);
397 void W_Laser_Touch (void)
401 if (other == self.owner)
403 else if (pointcontents (self.origin) == CONTENT_SKY)
409 dir = normalize (self.owner.origin - self.origin);
411 sound (self, CHAN_BODY, "weapons/NexImpact.wav", 1, ATTN_NORM);
413 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
414 WriteByte (MSG_BROADCAST, 79);
415 WriteCoord (MSG_BROADCAST, self.origin_x);
416 WriteCoord (MSG_BROADCAST, self.origin_y);
417 WriteCoord (MSG_BROADCAST, self.origin_z);
418 WriteCoord (MSG_BROADCAST, dir_x);
419 WriteCoord (MSG_BROADCAST, dir_y);
420 WriteCoord (MSG_BROADCAST, dir_z);
421 WriteByte (MSG_BROADCAST, 155);
423 Damage(self.owner, self.origin, other, 0, 20, dir * 40);
428 void W_Laser_Attack (void)
432 sound (self, CHAN_WEAPON, "weapons/Electro_fire.wav", 1, ATTN_NORM);
435 missile.owner = self;
436 missile.classname = "laser";
438 missile.movetype = MOVETYPE_FLY;
439 missile.solid = SOLID_BBOX;
441 setmodel (missile, "models/bullet.mdl");
442 setsize (missile, '0 0 0', '0 0 0');
443 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
445 makevectors (self.v_angle);
446 missile.velocity = v_forward * 2000;
447 missile.angles = vectoangles (missile.velocity);
448 missile.glow_color = 250; // 244, 250
449 missile.glow_size = 1020;
450 missile.glow_trail = 1; // ??? 256
451 missile.touch = W_Laser_Touch;
452 missile.think = SUB_Remove;
453 missile.nextthink = time + 2;
455 self.punchangle_x = random () - 0.5;
456 self.punchangle_y = random () - 0.5;
457 self.punchangle_z = random () - 0.5;
459 self.attack_finished = time + 0.3;
462 void W_Laser_Attack2 (void)
467 void W_Uzi_Attack (void)
469 sound (self, CHAN_WEAPON, "weapons/Uzi_Fire.wav", 1, ATTN_NORM);
471 fireBullet (v_forward, 300, 8, IT_SHOTGUN);
473 self.punchangle_x = random () * -2;
474 self.punchangle_y = crandom () * 0.5;
475 self.punchangle_z = crandom () * 0.5;
477 self.attack_finished = time + 0.075;
478 self.ammo_nails = self.ammo_nails - 1;
480 vector org; // casing code
481 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
482 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 1);
484 self.effects = self.effects | EF_MUZZLEFLASH;
487 void W_Uzi_Attack2 (void)
489 sound (self, CHAN_WEAPON, "weapons/Uzi_Fire.wav", 1, ATTN_NORM);
491 fireBullet (v_forward, 3, 10, IT_SHOTGUN);
493 self.punchangle = '-0.5 0 0';
495 self.attack_finished = time + 0.3;
496 self.ammo_nails = self.ammo_nails - 1;
499 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
500 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 1);
503 void W_Shotgun_Attack (void)
507 sound (self, CHAN_WEAPON, "weapons/Shotgun_fire.wav", 1, ATTN_NORM);
509 for (sc = 7; sc > 0; sc = sc - 1)
510 fireBullet (v_forward, 300, 8, IT_SHOTGUN);
512 self.punchangle_x = -2;
514 self.ammo_shells = self.ammo_shells - 1;
515 self.attack_finished = time + 0.8;
517 vector org; // casing code
518 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
519 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
522 void W_Shotgun_Attack2 (void)
527 void W_Grenade_Explode (entity ignore)
529 ImpactEffect (self, IT_GRENADE_LAUNCHER);
531 RadiusDamage (self.owner, self, 0, 100, 50, 100, world, 400);
536 void W_Grenade_FuseExplode (void)
538 W_Grenade_Explode (world);
541 void W_Grenade_Touch (void)
543 if (other.classname == "player" || other.classname == "corpse")
544 W_Grenade_Explode (other);
546 sound (self, CHAN_BODY, "weapons/Grenade_Bounce.wav", 1, ATTN_NORM);
549 void W_Grenade_Attack (void)
553 sound (self, CHAN_WEAPON, "weapons/Grenade_fire.wav", 1, ATTN_NORM);
555 self.punchangle_x = -4;
559 gren.classname = "grenade";
561 gren.movetype = MOVETYPE_BOUNCE;
562 gren.solid = SOLID_BBOX;
564 gren.takedamage = DAMAGE_YES;
565 gren.damageforcescale = 4;
567 gren.event_hurt = W_Grenade_Explode;
569 setmodel (gren, "models/grenademodel.md3");
570 setsize (gren, '-6 -6 -3', '6 6 3');
572 makevectors (self.v_angle);
573 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
575 gren.velocity = v_forward * 900 + v_up * 200;
576 gren.angles = vectoangles (gren.velocity);
577 gren.avelocity = '150 1500 150';
579 gren.touch = W_Grenade_Touch;
580 gren.think = W_Grenade_FuseExplode;
581 gren.nextthink = time + 2;
583 self.attack_finished = time + 1;
584 self.ammo_rockets = self.ammo_rockets - 1;
587 void W_Grenade_Attack2 (void)
591 sound (self, CHAN_WEAPON, "weapons/Grenade_fire.wav", 1, ATTN_NORM);
593 self.punchangle_x = -4;
597 gren.classname = "grenade";
599 gren.movetype = MOVETYPE_TOSS;
600 gren.solid = SOLID_BBOX;
602 gren.takedamage = DAMAGE_YES;
603 gren.damageforcescale = 4;
605 gren.event_hurt = W_Grenade_Explode;
607 setmodel (gren, "models/grenademodel.md3");
608 setsize (gren, '-6 -6 -3', '6 6 3');
610 makevectors (self.v_angle);
611 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
613 gren.velocity = v_forward * 1400 + v_up * 100;
614 gren.angles = vectoangles (gren.velocity);
615 gren.avelocity = '150 1500 150';
617 gren.touch = W_Grenade_Explode;
618 gren.think = W_Grenade_FuseExplode;
619 gren.nextthink = time + 5;
621 self.attack_finished = time + 1;
622 self.ammo_rockets = self.ammo_rockets - 1;
625 void W_Electro_Touch (void)
628 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
629 WriteByte (MSG_BROADCAST, 79);
630 WriteCoord (MSG_BROADCAST, self.origin_x);
631 WriteCoord (MSG_BROADCAST, self.origin_y);
632 WriteCoord (MSG_BROADCAST, self.origin_z);
633 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
634 WriteCoord (MSG_BROADCAST, 0);
635 WriteCoord (MSG_BROADCAST, 0);
636 WriteByte (MSG_BROADCAST, 155);
638 // LordHavoc: why damage only flesh?
639 //if (other.classname == "player" || other.classname == "corpse" || other.classname == "gib")
642 sound (other, CHAN_IMPACT, "misc/BodyImpact1.wav", 1, ATTN_NORM);
644 sound (other, CHAN_IMPACT, "misc/BodyImpact2.wav", 1, ATTN_NORM);
645 dir = normalize(self.velocity);
646 Damage (self.owner, self.origin, other, 0, 40, dir * 80);
652 void W_Electro_Attack (void)
656 sound (self, CHAN_WEAPON, "weapons/Electro_fire.wav", 1, ATTN_NORM);
660 proj.classname = "elec";
662 proj.movetype = MOVETYPE_FLY;
663 proj.solid = SOLID_BBOX;
666 makevectors (self.v_angle);
668 setmodel (proj, "models/bullet.mdl");
669 setsize (proj, '0 0 0', '0 0 0');
670 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
672 proj.velocity = v_forward * 3000;
673 proj.touch = W_Electro_Touch;
674 proj.think = SUB_Remove;
675 proj.nextthink = time + 3;
677 self.attack_finished = time + 0.6;
678 self.ammo_cells = self.ammo_cells - 1;
681 void W_Plasma_Touch (void)
684 dir = normalize(self.velocity);
685 // LordHavoc: why damage only flesh?
686 //if (other.classname == "player" || other.classname == "corpse" || other.classname == "gib")
687 Damage (self.owner, self.origin, other, 0, 15, dir * 30);
689 ImpactEffect (self, IT_ELECTRO);
694 const float w_plasma_anim_interval = 0.05;
696 void W_Plasma_Think (void)
701 animate_sprite(a, 5);
703 self.nextthink = time + w_plasma_anim_interval;
705 if (self.lifetime < time) // time is up
709 void W_Electro_Attack2 (void)
713 sound (self, CHAN_WEAPON, "weapons/LazerGun_Fire.wav", 1, ATTN_NORM);
717 proj.classname = "plasma";
719 proj.movetype = MOVETYPE_FLY;
720 proj.solid = SOLID_BBOX;
721 proj.effects = EF_DIMLIGHT;
723 makevectors (self.v_angle);
725 setmodel (proj, "models/sprites/plasmashot.spr32");
726 setsize (proj, '0 0 0', '0 0 0');
727 setorigin (proj, self.origin + self.view_ofs + v_forward * 5 + v_right * 5 + v_up * -12);
729 proj.velocity = v_forward * 5000;
730 proj.touch = W_Plasma_Touch;
731 proj.think = W_Plasma_Think;
732 proj.nextthink = time + w_plasma_anim_interval;
733 proj.lifetime = time + 1.5;
735 self.attack_finished = time + 0.175;
736 self.ammo_cells = self.ammo_cells - 1;
739 void W_Crylink_Attack (void)
743 sound (self, CHAN_WEAPON, "weapons/crylink.wav", 1, ATTN_NORM);
744 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
745 makevectors (self.v_angle);
747 // FIXME: make it accurate!
749 FireRailgunBullet (org, 25, v_forward);
751 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
753 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
754 WriteByte (MSG_BROADCAST, 76);
755 WriteCoord (MSG_BROADCAST, org_x);
756 WriteCoord (MSG_BROADCAST, org_y);
757 WriteCoord (MSG_BROADCAST, org_z);
758 WriteCoord (MSG_BROADCAST, trace_endpos_x);
759 WriteCoord (MSG_BROADCAST, trace_endpos_y);
760 WriteCoord (MSG_BROADCAST, trace_endpos_z);
761 WriteCoord (MSG_BROADCAST, self.v_angle_x);
762 WriteCoord (MSG_BROADCAST, self.v_angle_y);
763 WriteCoord (MSG_BROADCAST, self.v_angle_z);
765 te_spike (trace_endpos);
767 self.ammo_cells = self.ammo_cells - 0.25;
768 self.attack_finished = time + 0.165;
771 void W_Crylink_Attack2 (void)
776 makevectors (self.v_angle);
778 org = self.origin + self.view_ofs + v_forward * 19 + v_right * 5 + v_up * -7;
780 traceline (org, self.origin + self.view_ofs + v_forward * 4096 + v_right * (random () * 100 - 50) + v_up * (random () * 100 - 50), FALSE, self);
782 Damage (self, trace_endpos, trace_ent, 0, 20, v_forward * 10);
784 te_lightning1 (self, org, trace_endpos);
786 self.ammo_cells = self.ammo_cells - 0.25;
787 self.attack_finished = time + 0.075;
790 void W_Nex_Attack (void)
795 sound (self, CHAN_WEAPON, "weapons/NexFire.wav", 1, ATTN_NORM);
796 //self.effects = EF_MUZZLEFLASH;
797 self.punchangle_x = -4;
799 makevectors (self.v_angle);
801 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 8 + v_up * -5;
803 // FIXME: make it accurate!
805 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
807 FireRailgunBullet (org, 90, v_forward);
809 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
810 WriteByte (MSG_BROADCAST, 76);
811 WriteCoord (MSG_BROADCAST, org_x);
812 WriteCoord (MSG_BROADCAST, org_y);
813 WriteCoord (MSG_BROADCAST, org_z);
814 WriteCoord (MSG_BROADCAST, trace_endpos_x);
815 WriteCoord (MSG_BROADCAST, trace_endpos_y);
816 WriteCoord (MSG_BROADCAST, trace_endpos_z);
817 WriteCoord (MSG_BROADCAST, self.v_angle_x);
818 WriteCoord (MSG_BROADCAST, self.v_angle_y);
819 WriteCoord (MSG_BROADCAST, self.v_angle_z);
821 te_plasmaburn (trace_endpos);
823 dir = trace_plane_normal * 100;
824 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
825 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
826 WriteCoord (MSG_BROADCAST, trace_endpos_x);
827 WriteCoord (MSG_BROADCAST, trace_endpos_y);
828 WriteCoord (MSG_BROADCAST, trace_endpos_z);
829 WriteCoord (MSG_BROADCAST, dir_x);
830 WriteCoord (MSG_BROADCAST, dir_y);
831 WriteCoord (MSG_BROADCAST, dir_z);
832 WriteByte (MSG_BROADCAST, 255);
834 PointSound (trace_endpos, "weapons/NexImpact.wav", 1, ATTN_NORM);
836 self.attack_finished = time + 1;
837 self.ammo_cells = self.ammo_cells - 1;
840 void W_Nex_Attack2 (void)
845 void W_Hagar_Explode (void)
847 ImpactEffect (self, IT_HAGAR);
849 RadiusDamage (self.owner, self, 0, 100, 50, 100, world, 150);
854 void W_Hagar_Touch (void)
856 if (other == self.owner)
858 else if (pointcontents (self.origin) == CONTENT_SKY)
867 void W_Hagar_Attack (void)
872 sound (self, CHAN_WEAPON, "weapons/Hagar_Fire.wav", 1, ATTN_NORM);
875 missile.owner = self;
876 missile.classname = "rocket";
878 missile.takedamage = DAMAGE_YES;
879 missile.damageforcescale = 4;
881 missile.event_hurt = W_Hagar_Explode;
883 missile.movetype = MOVETYPE_FLY;
884 missile.solid = SOLID_BBOX;
885 setmodel (missile, "models/hagarmissile.mdl");
886 setsize (missile, '0 0 0', '0 0 0');
888 makevectors (self.v_angle);
890 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
892 missile.velocity = v_forward * 2000;
893 missile.angles = vectoangles (missile.velocity);
894 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
896 missile.touch = W_Hagar_Touch;
897 missile.think = SUB_Remove;
898 missile.nextthink = time + 1;
900 self.attack_finished = time + 0.2;
901 self.ammo_rockets = self.ammo_rockets - 0.25;
904 void W_Hagar_Attack2 (void)
909 sound (self, CHAN_WEAPON, "weapons/Hagar_Fire.wav", 1, ATTN_NORM);
912 missile.owner = self;
913 missile.classname = "rocket";
915 missile.takedamage = DAMAGE_YES;
916 missile.damageforcescale = 4;
918 missile.event_hurt = W_Hagar_Explode;
920 missile.movetype = MOVETYPE_FLY;
921 missile.solid = SOLID_BBOX;
922 setmodel (missile, "models/hagarmissile.mdl");
923 setsize (missile, '0 0 0', '0 0 0');
925 makevectors (self.v_angle);
927 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
929 missile.velocity = v_forward * 15000;
930 missile.angles = vectoangles (missile.velocity);
932 missile.touch = W_Hagar_Touch;
933 missile.think = SUB_Remove;
934 missile.nextthink = time + 1;
936 self.attack_finished = time + 0.7;
937 self.ammo_rockets = self.ammo_rockets - 0.25;
940 void W_Rocket_Explode (entity ignore)
942 ImpactEffect (self, IT_ROCKET_LAUNCHER);
944 RadiusDamage (self.owner, self, 0, 100, 50, 100, ignore, 600);
949 void W_Rocket_Touch (void)
951 if (other == self.owner)
953 else if (pointcontents (self.origin) == CONTENT_SKY)
959 W_Rocket_Explode (world);
962 void W_Rocket_Attack (void)
967 sound (self, CHAN_WEAPON, "weapons/Rocket_Fire.wav", 1, ATTN_NORM);
970 missile.owner = self;
971 missile.classname = "rocket";
973 missile.takedamage = DAMAGE_YES;
974 missile.damageforcescale = 4;
976 missile.event_hurt = W_Rocket_Explode;
978 missile.movetype = MOVETYPE_FLY;
979 missile.solid = SOLID_BBOX;
980 setmodel (missile, "models/rocketmissile.mdl");
981 setsize (missile, '0 0 0', '0 0 0');
983 makevectors (self.v_angle);
985 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
987 setorigin (missile, org);
988 missile.velocity = v_forward * 2500;
989 missile.angles = vectoangles (missile.velocity);
991 missile.touch = W_Rocket_Touch ;
992 missile.think = SUB_Remove;
993 missile.nextthink = time + 1;
995 self.attack_finished = time + 1.5;
996 self.ammo_rockets = self.ammo_rockets - 1;
1000 void W_Rocket2_Explode (entity ignore)
1002 ImpactEffect (self, IT_ROCKET_LAUNCHER);
1004 RadiusDamage (self.owner, self, 0, 15, 5, 200, ignore, 400);
1009 void W_Rocket2_Touch (void)
1011 if (other == self.owner)
1013 else if (pointcontents (self.origin) == CONTENT_SKY)
1019 W_Rocket2_Explode (world);
1022 void W_Rocket_Attack2 (void)
1027 //sound (self, CHAN_WEAPON, "weapons/Rocket_Fire.wav", 1, ATTN_NORM);
1030 missile.owner = self;
1031 missile.classname = "rocket";
1033 missile.takedamage = DAMAGE_YES;
1034 missile.damageforcescale = 4;
1036 missile.event_hurt = W_Rocket2_Explode;
1038 missile.movetype = MOVETYPE_FLY;
1039 missile.solid = SOLID_BBOX;
1040 setmodel (missile, "models/rocketmissile.mdl");
1041 setsize (missile, '0 0 0', '0 0 0');
1043 makevectors (self.v_angle);
1045 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
1047 setorigin (missile, org);
1048 missile.velocity = v_forward * 1500;
1049 missile.angles = vectoangles (missile.velocity);
1051 missile.touch = W_Rocket2_Touch;
1052 missile.think = SUB_Remove;
1053 missile.nextthink = time + 1;
1055 self.attack_finished = time + 1;
1056 self.ammo_rockets = self.ammo_rockets - 1;
1059 void W_Attack (void)
1061 if (self.deadflag != DEAD_NO)
1063 if (self.death_time < time)
1064 PutClientInServer();
1069 if (!W_CheckAmmo ())
1072 if (self.weapon == IT_LASER)
1074 else if (self.weapon == IT_UZI)
1076 else if (self.weapon == IT_SHOTGUN)
1077 W_Shotgun_Attack ();
1078 else if (self.weapon == IT_GRENADE_LAUNCHER)
1079 W_Grenade_Attack ();
1080 else if (self.weapon == IT_ELECTRO)
1081 W_Electro_Attack ();
1082 else if (self.weapon == IT_CRYLINK)
1083 W_Crylink_Attack ();
1084 else if (self.weapon == IT_NEX)
1086 else if (self.weapon == IT_HAGAR)
1088 else if (self.weapon == IT_ROCKET_LAUNCHER)
1094 void W_SecondaryAttack (void)
1096 if (self.deadflag != DEAD_NO)
1098 if (self.death_time < time)
1099 PutClientInServer();
1104 if (!W_CheckAmmo ())
1107 if (self.weapon == IT_LASER)
1109 else if (self.weapon == IT_UZI)
1111 else if (self.weapon == IT_SHOTGUN)
1112 W_Shotgun_Attack2 ();
1113 else if (self.weapon == IT_GRENADE_LAUNCHER)
1114 W_Grenade_Attack2 ();
1115 else if (self.weapon == IT_ELECTRO)
1116 W_Electro_Attack2 ();
1117 else if (self.weapon == IT_CRYLINK)
1118 W_Crylink_Attack2 ();
1119 else if (self.weapon == IT_NEX)
1121 else if (self.weapon == IT_HAGAR)
1123 else if (self.weapon == IT_ROCKET_LAUNCHER)
1124 W_Rocket_Attack2 ();