1 // increments sprite frame, loops when end is hit.. simple
2 void(float startframe, float frame_count) animate_sprite =
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)
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);
695 const float w_plasma_anim_interval = 0.05;
697 void() W_Plasma_Think =
699 animate_sprite(0, 5);
701 self.nextthink = time+ w_plasma_anim_interval;
703 if (self.lifetime < time) // time is up
707 void W_Electro_Attack2 (void)
711 sound (self, CHAN_WEAPON, "weapons/LazerGun_Fire.wav", 1, ATTN_NORM);
715 proj.classname = "plasma";
717 proj.movetype = MOVETYPE_FLY;
718 proj.solid = SOLID_BBOX;
719 proj.effects = EF_DIMLIGHT;
721 makevectors (self.v_angle);
723 setmodel (proj, "models/sprites/plasmashot.spr32");
724 setsize (proj, '0 0 0', '0 0 0');
725 setorigin (proj, self.origin + self.view_ofs + v_forward * 5 + v_right * 5 + v_up * -12);
727 proj.velocity = v_forward * 5000;
728 proj.touch = W_Plasma_Touch;
729 proj.think = W_Plasma_Think;
730 proj.nextthink = time + w_plasma_anim_interval;
731 proj.lifetime = time + 1.5;
733 self.attack_finished = time + 0.175;
734 self.ammo_cells = self.ammo_cells - 1;
737 void W_Crylink_Attack (void)
741 sound (self, CHAN_WEAPON, "weapons/crylink.wav", 1, ATTN_NORM);
742 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
743 makevectors (self.v_angle);
745 // FIXME: make it accurate!
747 FireRailgunBullet (org, 25, v_forward);
749 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
751 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
752 WriteByte (MSG_BROADCAST, 76);
753 WriteCoord (MSG_BROADCAST, org_x);
754 WriteCoord (MSG_BROADCAST, org_y);
755 WriteCoord (MSG_BROADCAST, org_z);
756 WriteCoord (MSG_BROADCAST, trace_endpos_x);
757 WriteCoord (MSG_BROADCAST, trace_endpos_y);
758 WriteCoord (MSG_BROADCAST, trace_endpos_z);
759 WriteCoord (MSG_BROADCAST, self.v_angle_x);
760 WriteCoord (MSG_BROADCAST, self.v_angle_y);
761 WriteCoord (MSG_BROADCAST, self.v_angle_z);
763 te_spike (trace_endpos);
765 self.ammo_cells = self.ammo_cells - 0.25;
766 self.attack_finished = time + 0.165;
769 void W_Crylink_Attack2 (void)
774 makevectors (self.v_angle);
776 org = self.origin + self.view_ofs + v_forward * 19 + v_right * 5 + v_up * -7;
778 traceline (org, self.origin + self.view_ofs + v_forward * 4096 + v_right * (random () * 100 - 50) + v_up * (random () * 100 - 50), FALSE, self);
780 Damage (self, trace_endpos, trace_ent, 0, 20);
782 te_lightning1 (self, org, trace_endpos);
784 self.ammo_cells = self.ammo_cells - 0.25;
785 self.attack_finished = time + 0.075;
788 void W_Nex_Attack (void)
793 sound (self, CHAN_WEAPON, "weapons/NexFire.wav", 1, ATTN_NORM);
794 //self.effects = EF_MUZZLEFLASH;
795 self.punchangle_x = -4;
797 makevectors (self.v_angle);
799 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 8 + v_up * -5;
801 // FIXME: iterate to hit multiple guys
802 // FIXME: make it accurate!
804 traceline (org, self.origin + self.view_ofs + (v_forward * 4096), FALSE, self);
806 FireRailgunBullet (org, 90, v_forward);
808 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
809 WriteByte (MSG_BROADCAST, 76);
810 WriteCoord (MSG_BROADCAST, org_x);
811 WriteCoord (MSG_BROADCAST, org_y);
812 WriteCoord (MSG_BROADCAST, org_z);
813 WriteCoord (MSG_BROADCAST, trace_endpos_x);
814 WriteCoord (MSG_BROADCAST, trace_endpos_y);
815 WriteCoord (MSG_BROADCAST, trace_endpos_z);
816 WriteCoord (MSG_BROADCAST, self.v_angle_x);
817 WriteCoord (MSG_BROADCAST, self.v_angle_y);
818 WriteCoord (MSG_BROADCAST, self.v_angle_z);
820 te_plasmaburn (trace_endpos);
822 dir = trace_plane_normal * 100;
823 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
824 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
825 WriteCoord (MSG_BROADCAST, trace_endpos_x);
826 WriteCoord (MSG_BROADCAST, trace_endpos_y);
827 WriteCoord (MSG_BROADCAST, trace_endpos_z);
828 WriteCoord (MSG_BROADCAST, dir_x);
829 WriteCoord (MSG_BROADCAST, dir_y);
830 WriteCoord (MSG_BROADCAST, dir_z);
831 WriteByte (MSG_BROADCAST, 255);
833 PointSound (trace_endpos, "weapons/NexImpact.wav", 1, ATTN_NORM);
835 self.attack_finished = time + 1;
836 self.ammo_cells = self.ammo_cells - 1;
839 void W_Nex_Attack2 (void)
844 void W_Hagar_Explode (void)
846 ImpactEffect (self, IT_HAGAR);
848 RadiusDamage (self.owner, self, 0, 100, world);
853 void W_Hagar_Touch (void)
855 if (other == self.owner)
857 else if (pointcontents (self.origin) == CONTENT_SKY)
866 void W_Hagar_Attack (void)
871 sound (self, CHAN_WEAPON, "weapons/Hagar_Fire.wav", 1, ATTN_NORM);
874 missile.owner = self;
875 missile.classname = "rocket";
877 missile.takedamage = DAMAGE_YES;
879 missile.event_hurt = W_Hagar_Explode;
881 missile.movetype = MOVETYPE_FLY;
882 missile.solid = SOLID_BBOX;
883 setmodel (missile, "models/hagarmissile.mdl");
884 setsize (missile, '0 0 0', '0 0 0');
886 makevectors (self.v_angle);
888 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
890 setorigin (missile, org);
891 missile.velocity = v_forward * 2000;
892 missile.angles = vectoangles (missile.velocity);
894 missile.touch = W_Hagar_Touch;
895 missile.think = SUB_Remove;
896 missile.nextthink = time + 1;
898 self.attack_finished = time + 0.2;
899 self.ammo_rockets = self.ammo_rockets - 0.25;
902 void W_Hagar_Attack2 (void)
907 sound (self, CHAN_WEAPON, "weapons/Hagar_Fire.wav", 1, ATTN_NORM);
910 missile.owner = self;
911 missile.classname = "rocket";
913 missile.takedamage = DAMAGE_YES;
915 missile.event_hurt = W_Hagar_Explode;
917 missile.movetype = MOVETYPE_FLY;
918 missile.solid = SOLID_BBOX;
919 setmodel (missile, "models/hagarmissile.mdl");
920 setsize (missile, '0 0 0', '0 0 0');
922 makevectors (self.v_angle);
924 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
926 setorigin (missile, org);
927 missile.velocity = v_forward * 15000;
928 missile.angles = vectoangles (missile.velocity);
930 missile.touch = W_Hagar_Touch;
931 missile.think = SUB_Remove;
932 missile.nextthink = time + 1;
934 self.attack_finished = time + 0.7;
935 self.ammo_rockets = self.ammo_rockets - 0.25;
938 void W_Rocket_Explode (entity ignore)
940 ImpactEffect (self, IT_ROCKET_LAUNCHER);
942 RadiusDamage (self.owner, self, 0, 100, ignore);
947 void W_Rocket_Touch (void)
949 if (other == self.owner)
951 else if (pointcontents (self.origin) == CONTENT_SKY)
956 else if (other.classname == "player" || other.classname == "corpse")
958 Damage (self.owner, self.origin, other, 0, 100);
959 W_Rocket_Explode (other);
962 W_Rocket_Explode (world);
965 void W_Rocket_Attack (void)
970 sound (self, CHAN_WEAPON, "weapons/Rocket_Fire.wav", 1, ATTN_NORM);
973 missile.owner = self;
974 missile.classname = "rocket";
976 missile.takedamage = DAMAGE_YES;
978 missile.event_hurt = W_Rocket_Explode;
980 missile.movetype = MOVETYPE_FLY;
981 missile.solid = SOLID_BBOX;
982 setmodel (missile, "models/rocketmissile.mdl");
983 setsize (missile, '0 0 0', '0 0 0');
985 makevectors (self.v_angle);
987 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
989 setorigin (missile, org);
990 missile.velocity = v_forward * 2500;
991 missile.angles = vectoangles (missile.velocity);
993 missile.touch = W_Rocket_Touch;
994 missile.think = SUB_Remove;
995 missile.nextthink = time + 1;
997 self.attack_finished = time + 0.5;
998 self.ammo_rockets = self.ammo_rockets - 1;
1002 void W_Rocket_Attack2 (void)
1007 void W_Attack (void)
1009 if (self.deadflag != DEAD_NO)
1011 if (self.death_time < time)
1012 PutClientInServer();
1017 if (!W_CheckAmmo ())
1020 if (self.weapon == IT_LASER)
1022 else if (self.weapon == IT_UZI)
1024 else if (self.weapon == IT_SHOTGUN)
1025 W_Shotgun_Attack ();
1026 else if (self.weapon == IT_GRENADE_LAUNCHER)
1027 W_Grenade_Attack ();
1028 else if (self.weapon == IT_ELECTRO)
1029 W_Electro_Attack ();
1030 else if (self.weapon == IT_CRYLINK)
1031 W_Crylink_Attack ();
1032 else if (self.weapon == IT_NEX)
1034 else if (self.weapon == IT_HAGAR)
1036 else if (self.weapon == IT_ROCKET_LAUNCHER)
1042 void W_SecondaryAttack (void)
1044 if (self.deadflag != DEAD_NO)
1046 if (self.death_time < time)
1047 PutClientInServer();
1052 if (!W_CheckAmmo ())
1055 if (self.weapon == IT_LASER)
1057 else if (self.weapon == IT_UZI)
1059 else if (self.weapon == IT_SHOTGUN)
1060 W_Shotgun_Attack2 ();
1061 else if (self.weapon == IT_GRENADE_LAUNCHER)
1062 W_Grenade_Attack2 ();
1063 else if (self.weapon == IT_ELECTRO)
1064 W_Electro_Attack2 ();
1065 else if (self.weapon == IT_CRYLINK)
1066 W_Crylink_Attack2 ();
1067 else if (self.weapon == IT_NEX)
1069 else if (self.weapon == IT_HAGAR)
1071 else if (self.weapon == IT_ROCKET_LAUNCHER)
1072 W_Rocket_Attack2 ();