1 // increments sprite frame, loops when end is hit.. simple
2 void(float startframe, float frame_count) animate_sprite =
4 if (self.frame >= (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_lazer.zym";
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)
188 // AK Let it test only every possible weapon then kick it out of the loop
193 // AK Sombody messed up the sequence (please undo if it was extra made so)
194 if (self.weapon == IT_ROCKET_LAUNCHER)
195 self.weapon = IT_LASER;
196 else if (self.weapon == IT_LASER)
198 self.weapon = IT_UZI;
199 if (!self.ammo_nails)
202 else if (self.weapon == IT_UZI)
204 self.weapon = IT_SHOTGUN;
205 if (!self.ammo_shells)
208 else if (self.weapon == IT_SHOTGUN)
210 self.weapon = IT_GRENADE_LAUNCHER;
211 if (!self.ammo_rockets)
214 else if (self.weapon == IT_GRENADE_LAUNCHER)
216 self.weapon = IT_ELECTRO;
217 if (!self.ammo_cells)
220 else if (self.weapon == IT_ELECTRO)
222 self.weapon = IT_CRYLINK;
223 if (!self.ammo_cells)
226 else if (self.weapon == IT_CRYLINK)
228 self.weapon = IT_NEX;
229 if (!self.ammo_cells)
232 else if (self.weapon == IT_NEX)
234 self.weapon = IT_HAGAR;
235 if (!self.ammo_rockets)
238 else if (self.weapon == IT_HAGAR)
240 self.weapon = IT_ROCKET_LAUNCHER;
241 if (!self.ammo_rockets)
245 if ((self.items & self.weapon) && !noammo)
256 void W_PreviousWeapon (void)
262 // AK the same as above
267 if (self.weapon == IT_UZI)
268 self.weapon = IT_LASER;
269 else if (self.weapon == IT_SHOTGUN)
271 self.weapon = IT_UZI;
272 if (!self.ammo_nails)
275 else if (self.weapon == IT_GRENADE_LAUNCHER)
277 self.weapon = IT_SHOTGUN;
278 if (!self.ammo_shells)
281 else if (self.weapon == IT_ELECTRO)
283 self.weapon = IT_GRENADE_LAUNCHER;
284 if (!self.ammo_rockets)
287 else if (self.weapon == IT_CRYLINK)
289 self.weapon = IT_ELECTRO;
290 if (!self.ammo_cells)
293 else if (self.weapon == IT_NEX)
295 self.weapon = IT_CRYLINK;
296 if (!self.ammo_cells)
299 else if (self.weapon == IT_HAGAR)
301 self.weapon = IT_NEX;
302 if (!self.ammo_cells)
305 else if (self.weapon == IT_ROCKET_LAUNCHER)
307 self.weapon = IT_HAGAR;
308 if (!self.ammo_rockets)
311 else if (self.weapon == IT_LASER)
313 self.weapon = IT_ROCKET_LAUNCHER;
314 if (!self.ammo_rockets)
318 if ((self.items & self.weapon) && !noammo)
329 float W_CheckAmmo (void)
332 if (self.weapon == IT_LASER)
334 else if (self.currentammo)
337 self.weapon = W_GetBestWeapon ();
343 void(vector src, float bdamage, vector dir) FireRailgunBullet =
345 local vector v, lastpos;
346 local entity saveself, last;
356 traceline (lastpos + dir * 2, lastpos + dir*8192, FALSE, last);
358 lastpos = trace_endpos;
359 if (trace_fraction != 1.0)
361 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
364 if (trace_ent.takedamage)
366 Damage (self, trace_endpos, trace_ent, 0, bdamage);
369 if (last.solid == SOLID_BSP)
374 void fireBullet (vector dir, float spread, float damage, float dtype)
378 makevectors (self.v_angle);
380 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
381 org = self.origin + self.view_ofs;
382 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
384 // FIXME - causes excessive 'tinking'. Hopefully remove "tink1.wav" from the ricochets with csqc
385 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
387 if (trace_ent == world)
388 te_spike (trace_endpos);
389 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
391 Damage (self, trace_endpos, trace_ent, 0, damage);
393 sound (trace_ent, CHAN_IMPACT, "misc/BodyImpact1.wav", 1, ATTN_NORM);
395 sound (trace_ent, CHAN_IMPACT, "misc/BodyImpact2.wav", 1, ATTN_NORM);
400 void W_Laser_Touch (void)
404 if (other == self.owner)
406 else if (pointcontents (self.origin) == CONTENT_SKY)
412 dir = normalize (self.owner.origin - self.origin);
414 sound (self, CHAN_BODY, "weapons/NexImpact.wav", 1, ATTN_NORM);
416 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
417 WriteByte (MSG_BROADCAST, 79);
418 WriteCoord (MSG_BROADCAST, self.origin_x);
419 WriteCoord (MSG_BROADCAST, self.origin_y);
420 WriteCoord (MSG_BROADCAST, self.origin_z);
421 WriteCoord (MSG_BROADCAST, dir_x);
422 WriteCoord (MSG_BROADCAST, dir_y);
423 WriteCoord (MSG_BROADCAST, dir_z);
424 WriteByte (MSG_BROADCAST, 155);
429 void W_Laser_Attack (void)
433 sound (self, CHAN_WEAPON, "weapons/Electro_fire.wav", 1, ATTN_NORM);
436 missile.owner = self;
437 missile.classname = "laser";
439 missile.movetype = MOVETYPE_FLY;
440 missile.solid = SOLID_BBOX;
442 setmodel (missile, "models/bullet.mdl");
443 setsize (missile, '-4 -4 -4', '4 4 4');
444 setorigin (missile, self.origin + self.view_ofs);
446 makevectors (self.v_angle);
447 missile.velocity = v_forward * 2000;
448 missile.angles = vectoangles (missile.velocity);
449 missile.glow_color = 250; // 244, 250
450 missile.glow_size = 1020;
451 missile.glow_trail = 1; // ??? 256
452 missile.touch = W_Laser_Touch;
453 missile.think = SUB_Remove;
454 missile.nextthink = time + 2;
456 self.punchangle_x = random () - 0.5;
457 self.punchangle_y = random () - 0.5;
458 self.punchangle_z = random () - 0.5;
460 self.attack_finished = time + 0.3;
463 void W_Laser_Attack2 (void)
468 void W_Uzi_Attack (void)
470 sound (self, CHAN_WEAPON, "weapons/Uzi_Fire.wav", 1, ATTN_NORM);
472 fireBullet (v_forward, 300, 8, IT_SHOTGUN);
474 self.punchangle_x = random () * -2;
475 self.punchangle_y = crandom () * 0.5;
476 self.punchangle_z = crandom () * 0.5;
478 self.attack_finished = time + 0.075;
479 self.ammo_nails = self.ammo_nails - 1;
481 vector org; // casing code
482 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
483 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
485 self.effects = self.effects | EF_MUZZLEFLASH;
488 void W_Uzi_Attack2 (void)
490 sound (self, CHAN_WEAPON, "weapons/Uzi_Fire.wav", 1, ATTN_NORM);
492 fireBullet (v_forward, 3, 10, IT_SHOTGUN);
494 self.punchangle = '-0.5 0 0';
496 self.attack_finished = time + 0.3;
497 self.ammo_nails = self.ammo_nails - 1;
500 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
501 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2);
504 void W_Shotgun_Attack (void)
506 sound (self, CHAN_WEAPON, "weapons/Shotgun_fire.wav", 1, ATTN_NORM);
512 fireBullet (v_forward, 300, 8, IT_SHOTGUN);
516 self.punchangle_x = -2;
518 self.ammo_shells = self.ammo_shells - 1;
519 self.attack_finished = time + 0.8;
521 vector org; // casing code
522 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
523 SpawnCasing (org, v_forward, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 1);
526 void W_Shotgun_Attack2 (void)
531 void W_Grenade_Explode (entity ignore)
533 ImpactEffect (self, IT_GRENADE_LAUNCHER);
535 RadiusDamage (self.owner, self, 0, 100, world);
540 void W_Grenade_FuseExplode (void)
542 W_Grenade_Explode (world);
545 void W_Grenade_Touch (void)
547 if (other.classname == "player" || other.classname == "corpse")
549 Damage (self.owner, self.origin, other, 0, 100);
550 W_Grenade_Explode (other);
553 sound (self, CHAN_BODY, "weapons/Grenade_Bounce.wav", 1, ATTN_NORM);
556 void W_Grenade_Attack (void)
560 sound (self, CHAN_WEAPON, "weapons/Grenade_fire.wav", 1, ATTN_NORM);
562 self.punchangle_x = -4;
566 gren.classname = "grenade";
568 gren.movetype = MOVETYPE_BOUNCE;
569 gren.solid = SOLID_BBOX;
571 gren.takedamage = DAMAGE_YES;
573 gren.event_hurt = W_Grenade_Explode;
575 setmodel (gren, "models/grenademodel.md3");
576 setsize (gren, '0 0 0', '0 0 0');
578 makevectors (self.v_angle);
579 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
581 gren.velocity = v_forward * 900 + v_up * 200;
582 gren.angles = vectoangles (gren.velocity);
583 gren.avelocity = '150 1500 150';
585 gren.touch = W_Grenade_Touch;
586 gren.think = W_Grenade_FuseExplode;
587 gren.nextthink = time + 2;
589 self.attack_finished = time + 1;
590 self.ammo_rockets = self.ammo_rockets - 1;
593 void W_Grenade_Attack2 (void)
597 sound (self, CHAN_WEAPON, "weapons/Grenade_fire.wav", 1, ATTN_NORM);
599 self.punchangle_x = -4;
603 gren.classname = "grenade";
605 gren.movetype = MOVETYPE_TOSS;
606 gren.solid = SOLID_BBOX;
608 gren.takedamage = DAMAGE_YES;
610 gren.event_hurt = W_Grenade_Explode;
612 setmodel (gren, "models/grenademodel.md3");
613 setsize (gren, '0 0 0', '0 0 0');
615 makevectors (self.v_angle);
616 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
618 gren.velocity = v_forward * 1400 + v_up * 100;
619 gren.angles = vectoangles (gren.velocity);
620 gren.avelocity = '150 1500 150';
622 gren.touch = W_Grenade_Explode;
623 gren.think = W_Grenade_FuseExplode;
624 gren.nextthink = time + 5;
626 self.attack_finished = time + 1;
627 self.ammo_rockets = self.ammo_rockets - 1;
630 void W_Electro_Touch (void)
632 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
633 WriteByte (MSG_BROADCAST, 79);
634 WriteCoord (MSG_BROADCAST, self.origin_x);
635 WriteCoord (MSG_BROADCAST, self.origin_y);
636 WriteCoord (MSG_BROADCAST, self.origin_z);
637 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
638 WriteCoord (MSG_BROADCAST, 0);
639 WriteCoord (MSG_BROADCAST, 0);
640 WriteByte (MSG_BROADCAST, 155);
642 if (other.classname == "player" || other.classname == "corpse" || other.classname == "gib")
644 Damage (self.owner, self.origin, other, 0, 40);
645 // SeienAbunae: the impact sound doesn't seem to play when the victim dies instead of being hurt
646 // Maybe it's not that big of a deal
648 sound (other, CHAN_IMPACT, "misc/BodyImpact1.wav", 1, ATTN_NORM);
650 sound (other, CHAN_IMPACT, "misc/BodyImpact2.wav", 1, ATTN_NORM);
656 void W_Electro_Attack (void)
660 sound (self, CHAN_WEAPON, "weapons/Electro_fire.wav", 1, ATTN_NORM);
664 proj.classname = "elec";
666 proj.movetype = MOVETYPE_FLY;
667 proj.solid = SOLID_BBOX;
670 makevectors (self.v_angle);
672 setmodel (proj, "models/bullet.mdl");
673 setsize (proj, '0 0 0', '0 0 0');
674 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
676 proj.velocity = v_forward * 3000;
677 proj.touch = W_Electro_Touch;
678 proj.think = SUB_Remove;
679 proj.nextthink = time + 3;
681 self.attack_finished = time + 0.6;
682 self.ammo_cells = self.ammo_cells - 1;
685 void W_Plasma_Touch (void)
687 if (other.classname == "player" || other.classname == "corpse" || other.classname == "gib")
688 Damage (self.owner, self.origin, other, 0, 15);
690 ImpactEffect (self, IT_ELECTRO);
697 void() W_Plasma_Think =
699 if (self.animthink < time)
701 animate_sprite(0, 5);
702 self.animthink = time + 0.05; // 20fps?
704 self.nextthink = time;
705 self.think = W_Plasma_Think;
706 if (self.lifetime < time) // time is up
710 void W_Electro_Attack2 (void)
714 sound (self, CHAN_WEAPON, "weapons/LazerGun_Fire.wav", 1, ATTN_NORM);
718 proj.classname = "plasma";
720 proj.movetype = MOVETYPE_FLY;
721 proj.solid = SOLID_BBOX;
722 proj.effects = EF_DIMLIGHT;
724 makevectors (self.v_angle);
726 setmodel (proj, "models/sprites/plasmashot.spr32");
727 setsize (proj, '0 0 0', '0 0 0');
728 setorigin (proj, self.origin + self.view_ofs + v_forward * 5 + v_right * 5 + v_up * -12);
730 proj.velocity = v_forward * 5000;
731 proj.touch = W_Plasma_Touch;
732 proj.think = W_Plasma_Think;
733 proj.nextthink = time;
734 proj.lifetime = time + 1.5;
736 self.attack_finished = time + 0.175;
737 self.ammo_cells = self.ammo_cells - 1;
740 void W_Crylink_Attack (void)
744 sound (self, CHAN_WEAPON, "weapons/crylink.wav", 1, ATTN_NORM);
745 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
746 makevectors (self.v_angle);
748 // FIXME: make it accurate!
750 FireRailgunBullet (org, 25, v_forward);
752 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
754 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
755 WriteByte (MSG_BROADCAST, 76);
756 WriteCoord (MSG_BROADCAST, org_x);
757 WriteCoord (MSG_BROADCAST, org_y);
758 WriteCoord (MSG_BROADCAST, org_z);
759 WriteCoord (MSG_BROADCAST, trace_endpos_x);
760 WriteCoord (MSG_BROADCAST, trace_endpos_y);
761 WriteCoord (MSG_BROADCAST, trace_endpos_z);
762 WriteCoord (MSG_BROADCAST, self.v_angle_x);
763 WriteCoord (MSG_BROADCAST, self.v_angle_y);
764 WriteCoord (MSG_BROADCAST, self.v_angle_z);
766 te_spike (trace_endpos);
768 self.ammo_cells = self.ammo_cells - 0.25;
769 self.attack_finished = time + 0.165;
772 void W_Crylink_Attack2 (void)
777 makevectors (self.v_angle);
779 org = self.origin + self.view_ofs + v_forward * 19 + v_right * 5 + v_up * -7;
781 traceline (org, self.origin + self.view_ofs + v_forward * 4096 + v_right * (random () * 100 - 50) + v_up * (random () * 100 - 50), FALSE, self);
783 Damage (self, trace_endpos, trace_ent, 0, 20);
785 te_lightning1 (self, org, trace_endpos);
787 self.ammo_cells = self.ammo_cells - 0.25;
788 self.attack_finished = time + 0.075;
791 void W_Nex_Attack (void)
796 sound (self, CHAN_WEAPON, "weapons/NexFire.wav", 1, ATTN_NORM);
797 //self.effects = EF_MUZZLEFLASH;
798 self.punchangle_x = -4;
800 makevectors (self.v_angle);
802 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 8 + v_up * -5;
804 // FIXME: iterate to hit multiple guys
805 // FIXME: make it accurate!
807 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
809 FireRailgunBullet (org, 90, v_forward);
811 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
812 WriteByte (MSG_BROADCAST, 76);
813 WriteCoord (MSG_BROADCAST, org_x);
814 WriteCoord (MSG_BROADCAST, org_y);
815 WriteCoord (MSG_BROADCAST, org_z);
816 WriteCoord (MSG_BROADCAST, trace_endpos_x);
817 WriteCoord (MSG_BROADCAST, trace_endpos_y);
818 WriteCoord (MSG_BROADCAST, trace_endpos_z);
819 WriteCoord (MSG_BROADCAST, self.v_angle_x);
820 WriteCoord (MSG_BROADCAST, self.v_angle_y);
821 WriteCoord (MSG_BROADCAST, self.v_angle_z);
823 te_plasmaburn (trace_endpos);
825 dir = trace_plane_normal * 100;
826 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
827 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
828 WriteCoord (MSG_BROADCAST, trace_endpos_x);
829 WriteCoord (MSG_BROADCAST, trace_endpos_y);
830 WriteCoord (MSG_BROADCAST, trace_endpos_z);
831 WriteCoord (MSG_BROADCAST, dir_x);
832 WriteCoord (MSG_BROADCAST, dir_y);
833 WriteCoord (MSG_BROADCAST, dir_z);
834 WriteByte (MSG_BROADCAST, 255);
836 PointSound (trace_endpos, "weapons/NexImpact.wav", 1, ATTN_NORM);
838 self.attack_finished = time + 1;
839 self.ammo_cells = self.ammo_cells - 1;
842 void W_Nex_Attack2 (void)
847 void W_Hagar_Explode (void)
849 ImpactEffect (self, IT_HAGAR);
851 RadiusDamage (self.owner, self, 0, 100, world);
856 void W_Hagar_Touch (void)
858 if (other == self.owner)
860 else if (pointcontents (self.origin) == CONTENT_SKY)
869 void W_Hagar_Attack (void)
874 sound (self, CHAN_WEAPON, "weapons/Hagar_Fire.wav", 1, ATTN_NORM);
877 missile.owner = self;
878 missile.classname = "rocket";
880 missile.takedamage = DAMAGE_YES;
882 missile.event_hurt = W_Hagar_Explode;
884 missile.movetype = MOVETYPE_FLY;
885 missile.solid = SOLID_BBOX;
886 setmodel (missile, "models/hagarmissile.mdl");
887 setsize (missile, '0 0 0', '0 0 0');
889 makevectors (self.v_angle);
891 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
893 setorigin (missile, org);
894 missile.velocity = v_forward * 2000;
895 missile.angles = vectoangles (missile.velocity);
897 missile.touch = W_Hagar_Touch;
898 missile.think = SUB_Remove;
899 missile.nextthink = time + 1;
901 self.attack_finished = time + 0.2;
902 self.ammo_rockets = self.ammo_rockets - 0.25;
905 void W_Hagar_Attack2 (void)
910 sound (self, CHAN_WEAPON, "weapons/Hagar_Fire.wav", 1, ATTN_NORM);
913 missile.owner = self;
914 missile.classname = "rocket";
916 missile.takedamage = DAMAGE_YES;
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 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
929 setorigin (missile, org);
930 missile.velocity = v_forward * 15000;
931 missile.angles = vectoangles (missile.velocity);
933 missile.touch = W_Hagar_Touch;
934 missile.think = SUB_Remove;
935 missile.nextthink = time + 1;
937 self.attack_finished = time + 0.7;
938 self.ammo_rockets = self.ammo_rockets - 0.25;
941 void W_Rocket_Explode (entity ignore)
943 ImpactEffect (self, IT_ROCKET_LAUNCHER);
945 RadiusDamage (self.owner, self, 0, 100, ignore);
950 void W_Rocket_Touch (void)
952 if (other == self.owner)
954 else if (pointcontents (self.origin) == CONTENT_SKY)
959 else if (other.classname == "player" || other.classname == "corpse")
961 Damage (self.owner, self.origin, other, 0, 100);
962 W_Rocket_Explode (other);
965 W_Rocket_Explode (world);
968 void W_Rocket_Attack (void)
973 sound (self, CHAN_WEAPON, "weapons/Rocket_Fire.wav", 1, ATTN_NORM);
976 missile.owner = self;
977 missile.classname = "rocket";
979 missile.takedamage = DAMAGE_YES;
981 missile.event_hurt = W_Rocket_Explode;
983 missile.movetype = MOVETYPE_FLY;
984 missile.solid = SOLID_BBOX;
985 setmodel (missile, "models/rocketmissile.mdl");
986 setsize (missile, '0 0 0', '0 0 0');
988 makevectors (self.v_angle);
990 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
992 setorigin (missile, org);
993 missile.velocity = v_forward * 2500;
994 missile.angles = vectoangles (missile.velocity);
996 missile.touch = W_Rocket_Touch;
997 missile.think = SUB_Remove;
998 missile.nextthink = time + 1;
1000 self.attack_finished = time + 0.5;
1001 self.ammo_rockets = self.ammo_rockets - 1;
1005 void W_Rocket_Attack2 (void)
1010 void W_Attack (void)
1012 if (self.deadflag != DEAD_NO)
1014 if (self.death_time < time)
1015 PutClientInServer();
1020 if (!W_CheckAmmo ())
1023 if (self.weapon == IT_LASER)
1025 else if (self.weapon == IT_UZI)
1027 else if (self.weapon == IT_SHOTGUN)
1028 W_Shotgun_Attack ();
1029 else if (self.weapon == IT_GRENADE_LAUNCHER)
1030 W_Grenade_Attack ();
1031 else if (self.weapon == IT_ELECTRO)
1032 W_Electro_Attack ();
1033 else if (self.weapon == IT_CRYLINK)
1034 W_Crylink_Attack ();
1035 else if (self.weapon == IT_NEX)
1037 else if (self.weapon == IT_HAGAR)
1039 else if (self.weapon == IT_ROCKET_LAUNCHER)
1045 void W_SecondaryAttack (void)
1047 if (self.deadflag != DEAD_NO)
1049 if (self.death_time < time)
1050 PutClientInServer();
1055 if (!W_CheckAmmo ())
1058 if (self.weapon == IT_LASER)
1060 else if (self.weapon == IT_UZI)
1062 else if (self.weapon == IT_SHOTGUN)
1063 W_Shotgun_Attack2 ();
1064 else if (self.weapon == IT_GRENADE_LAUNCHER)
1065 W_Grenade_Attack2 ();
1066 else if (self.weapon == IT_ELECTRO)
1067 W_Electro_Attack2 ();
1068 else if (self.weapon == IT_CRYLINK)
1069 W_Crylink_Attack2 ();
1070 else if (self.weapon == IT_NEX)
1072 else if (self.weapon == IT_HAGAR)
1074 else if (self.weapon == IT_ROCKET_LAUNCHER)
1075 W_Rocket_Attack2 ();