2 void (vector vec) WriteVec =
4 WriteCoord (MSG_BROADCAST, vec_x);
5 WriteCoord (MSG_BROADCAST, vec_y);
6 WriteCoord (MSG_BROADCAST, vec_z);
8 void (vector org, vector dir, float counts) W_Smoke =
10 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
11 WriteByte (MSG_BROADCAST, TE_SMOKE);
14 WriteByte (MSG_BROADCAST, counts);
17 // increments sprite frame, loops when end is hit.. simple
18 void animate_sprite (float startframe, float frame_count)
20 if ((self.frame - startframe) >= (frame_count - 1 ))
21 self.frame = startframe;
23 self.frame = self.frame + 1;
26 void W_UpdateAmmo (void)
28 self.items = self.items - (self.items & (IT_NAILS | IT_SHELLS | IT_ROCKETS | IT_CELLS));
30 if (self.weapon == IT_LASER)
32 else if (self.weapon == IT_UZI)
34 self.currentammo = self.ammo_nails;
35 self.items = self.items | IT_NAILS;
37 else if (self.weapon == IT_SHOTGUN)
39 self.currentammo = self.ammo_shells;
40 self.items = self.items | IT_SHELLS;
42 else if (self.weapon == IT_GRENADE_LAUNCHER || self.weapon == IT_HAGAR || self.weapon == IT_ROCKET_LAUNCHER)
44 self.currentammo = self.ammo_rockets;
45 self.items = self.items | IT_ROCKETS;
47 else if (self.weapon == IT_ELECTRO || self.weapon == IT_NEX || self.weapon == IT_CRYLINK)
49 self.currentammo = self.ammo_cells;
50 self.items = self.items | IT_CELLS;
54 void W_UpdateWeapon (void)
56 if (self.weapon == IT_LASER)
57 self.weaponmodel = "models/weapons/w_laser.zym";
58 else if (self.weapon == IT_UZI)
59 self.weaponmodel = "models/weapons/w_uzi.zym";
60 else if (self.weapon == IT_SHOTGUN)
61 self.weaponmodel = "models/weapons/w_shotgun.zym";
62 else if (self.weapon == IT_GRENADE_LAUNCHER)
63 self.weaponmodel = "models/weapons/w_gl.zym";
64 else if (self.weapon == IT_ELECTRO)
65 self.weaponmodel = "models/weapons/w_electro.zym";
66 else if (self.weapon == IT_CRYLINK)
67 self.weaponmodel = "models/weapons/w_crylink.zym";
68 else if (self.weapon == IT_NEX)
69 self.weaponmodel = "models/weapons/w_nex.zym";
70 else if (self.weapon == IT_HAGAR)
71 self.weaponmodel = "models/weapons/w_hagar.zym";
72 else if (self.weapon == IT_ROCKET_LAUNCHER)
73 self.weaponmodel = "models/weapons/w_rl.zym";
75 objerror ("Illegal weapon - please register your guns please!");
78 float W_GetBestWeapon (void)
80 if ((self.items & IT_ROCKET_LAUNCHER) && self.ammo_rockets)
81 return IT_ROCKET_LAUNCHER;
82 else if ((self.items & IT_HAGAR) && self.ammo_rockets)
84 else if ((self.items & IT_NEX) && self.ammo_cells)
86 else if ((self.items & IT_CRYLINK) && self.ammo_cells)
88 else if ((self.items & IT_ELECTRO) && self.ammo_cells)
90 else if ((self.items & IT_GRENADE_LAUNCHER) && self.ammo_rockets)
91 return IT_GRENADE_LAUNCHER;
92 else if ((self.items & IT_SHOTGUN) && self.ammo_shells)
94 else if ((self.items & IT_UZI) && self.ammo_nails)
100 void W_GiveWeapon (entity e, float wep) // FIXME - make it 'smarter'
107 if (!(e.items & wep))
109 e.items = e.items | wep;
122 void W_SwitchWeapon (float wep)
125 var float noammo = FALSE;
132 if (!self.ammo_nails)
137 nextwep = IT_SHOTGUN;
138 if (!self.ammo_shells)
143 nextwep = IT_GRENADE_LAUNCHER;
144 if (!self.ammo_rockets)
149 nextwep = IT_ELECTRO;
150 if (!self.ammo_cells)
155 nextwep = IT_CRYLINK;
156 if (!self.ammo_cells)
162 if (!self.ammo_cells)
168 if (!self.ammo_rockets)
173 nextwep = IT_ROCKET_LAUNCHER;
174 if (!self.ammo_rockets)
179 if (!(self.items & nextwep))
181 sprint (self, "You don't own that weapon\n");
186 sprint (self, "You don't have any ammo for that weapon\n");
190 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)
336 if (game & (GAME_INSTAGIB | GAME_ROCKET_ARENA))
340 if (self.weapon == IT_LASER)
342 else if (self.currentammo)
345 self.weapon = W_GetBestWeapon ();
352 void FireRailgunBullet (vector src, float bdamage, vector dir, float spread, float deathtype)
355 entity saveself, last;
357 org = self.origin + self.view_ofs;
366 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
368 lastpos = trace_endpos;
369 if (trace_fraction != 1.0)
371 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
374 if (trace_ent.takedamage || trace_ent.classname == "case")
376 if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
377 te_blood (trace_endpos, dir * bdamage * 16, bdamage);
378 Damage (trace_ent, self, self, bdamage, deathtype, trace_endpos, dir * bdamage);
381 if (last.solid == SOLID_BSP)
387 void FireRailgunBullet (vector start, vector end, float damage, float dtype)
391 dir = normalize (end - start);
392 traceline_hitcorpse (self, start, end, FALSE, self);
394 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
395 WriteByte (MSG_BROADCAST, 76);
396 WriteCoord (MSG_BROADCAST, start_x);
397 WriteCoord (MSG_BROADCAST, start_y);
398 WriteCoord (MSG_BROADCAST, start_z);
399 WriteCoord (MSG_BROADCAST, trace_endpos_x);
400 WriteCoord (MSG_BROADCAST, trace_endpos_y);
401 WriteCoord (MSG_BROADCAST, trace_endpos_z);
402 WriteCoord (MSG_BROADCAST, 0);
403 WriteCoord (MSG_BROADCAST, 0);
404 WriteCoord (MSG_BROADCAST, 0);
406 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
408 if (trace_ent.classname == "case")
410 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
412 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
414 te_blood (trace_endpos, dir * damage * 16, damage);
415 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
421 void fireBullet (vector dir, float spread, float damage, float dtype)
425 makevectors (self.v_angle);
428 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
429 org = self.origin + self.view_ofs;
430 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
432 // FIXME - causes excessive 'tinking'. Hopefully remove "tink1.wav" from the ricochets with csqc
433 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
435 if (trace_ent == world)
437 pointcontents (self.origin);
438 te_gunshot (trace_endpos);
441 sound (self, CHAN_IMPACT, "weapons/ric1.wav", 1, ATTN_NORM);
443 sound (self, CHAN_IMPACT, "weapons/ric2.wav", 1, ATTN_NORM);
445 sound (self, CHAN_IMPACT, "weapons/ric3.wav", 1, ATTN_NORM);
447 else if (trace_ent.classname == "case")
449 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
451 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
453 te_blood (trace_endpos, dir * damage * 16, damage);
454 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
455 sound (trace_ent, CHAN_IMPACT, "misc/enemyimpact.wav", 1, ATTN_NORM);
460 void W_Laser_Touch (void)
464 if (other == self.owner)
466 else if (pointcontents (self.origin) == CONTENT_SKY)
472 dir = normalize (self.owner.origin - self.origin);
475 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
476 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
477 WriteCoord (MSG_BROADCAST, self.origin_x);
478 WriteCoord (MSG_BROADCAST, self.origin_y);
479 WriteCoord (MSG_BROADCAST, self.origin_z);
480 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
481 WriteCoord (MSG_BROADCAST, 0);
482 WriteCoord (MSG_BROADCAST, 0);
483 WriteByte (MSG_BROADCAST, 155); */
487 self.event_damage = SUB_Null;
488 RadiusDamage (self, self.owner, 15, 7, 50, world, 200, IT_LASER);
489 sound (self, CHAN_IMPACT, "weapons/laserimpact.wav", 1, ATTN_NORM);
494 void W_Laser_Attack (void)
498 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
501 missile.owner = self;
502 missile.classname = "spike";
504 missile.movetype = MOVETYPE_FLY;
505 missile.solid = SOLID_BBOX;
507 setmodel (missile, "models/laser.mdl");
508 setsize (missile, '0 0 0', '0 0 0');
509 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
511 makevectors (self.v_angle);
512 missile.velocity = v_forward * 1000;
513 missile.velocity = missile.velocity + v_right * ( crandom() * 45 );
514 missile.velocity = missile.velocity + v_up * ( crandom() * 25 );
515 missile.angles = vectoangles (missile.velocity);
516 missile.glow_color = 250; // 244, 250
517 missile.glow_size = 30;
518 missile.touch = W_Laser_Touch;
519 missile.think = SUB_Remove;
520 missile.nextthink = time + 9;
522 missile.effects = missile.effects | EF_ADDITIVE;
524 self.punchangle_x = random () - 0.5;
525 self.punchangle_y = random () - 0.5;
526 self.punchangle_z = random () - 0.5;
528 self.attack_finished = time + 0.2;
531 void W_Laser_Attack2 (void)
535 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", 1, ATTN_NORM);
538 missile.owner = self;
539 missile.classname = "spike";
541 missile.movetype = MOVETYPE_FLY;
542 missile.solid = SOLID_BBOX;
544 setmodel (missile, "models/laser.mdl");
545 setsize (missile, '0 0 0', '0 0 0');
546 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
548 makevectors (self.v_angle);
549 missile.velocity = v_forward * 4000;
550 missile.angles = vectoangles (missile.velocity);
551 missile.glow_color = 250; // 244, 250
552 missile.glow_size = 30;
553 missile.touch = W_Laser_Touch;
554 missile.think = SUB_Remove;
555 missile.nextthink = time + 2;
557 missile.effects = missile.effects | EF_ADDITIVE;
559 self.punchangle_x = random () - 0.5;
560 self.punchangle_y = random () - 0.5;
561 self.punchangle_z = random () - 0.5;
563 self.attack_finished = time + 0.4;
566 void W_Uzi_Attack (void)
568 sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
570 fireBullet (v_forward, 100, 8, IT_UZI);
572 self.punchangle_x = random () - 0.5;
573 self.punchangle_y = random () - 0.5;
574 self.punchangle_z = random () - 0.5;
576 self.attack_finished = time + 0.075;
577 self.ammo_nails = self.ammo_nails - 1;
579 vector org; // casing code
580 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
581 SpawnCasing (org, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2, v_forward,'0 250 0', 100, 2);
582 //W_Smoke(org, v_forward, 12);
585 void W_Uzi_Attack2 (void)
590 sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);
593 if (bullets > self.ammo_nails)
594 bullets = self.ammo_nails;
596 sound (self, CHAN_WEAPON, "weapons/uzi_fire_secondary.wav", 1, ATTN_NORM);
598 for (sc = bullets; sc > 0; sc = sc - 1)
599 fireBullet (v_forward, 400, 10, IT_SHOTGUN);
601 self.punchangle_x = -1.5;
603 self.ammo_nails = self.ammo_nails - bullets;
604 self.attack_finished = time + 0.4;
606 vector org; // casing code
607 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
608 SpawnCasing (org, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2, v_forward,'0 250 0', 100, 3);
611 void W_Uzi_Attack3 (void)
613 sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
615 fireBullet (v_forward, 0, 10, IT_UZI);
617 self.attack_finished = time + 0.16;
618 self.ammo_nails = self.ammo_nails - 1;
620 vector org; // casing code
621 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
622 SpawnCasing (org, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2, v_forward,'0 250 0', 100, 2);
625 void W_Shotgun_Attack (void)
630 sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);
634 for (sc = bullets; sc > 0; sc = sc - 1)
635 fireBullet (v_forward, 150, 8, IT_SHOTGUN);
637 self.ammo_shells = self.ammo_shells - 1;
638 self.attack_finished = time + 0.7;
640 vector org; // casing code
641 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 4) + (v_forward * 15);
642 SpawnCasing (org, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2, v_forward,'0 250 0', 100, 1);
645 void W_Shotgun_Attack2 (void)
650 void W_Grenade_Explode (entity ignore)
652 ImpactEffect (self, IT_GRENADE_LAUNCHER);
654 self.event_damage = SUB_Null;
655 RadiusDamage (self, self.owner, 65, 35, 140, world, 400, IT_GRENADE_LAUNCHER);
660 void W_Grenade_FuseExplode (void)
662 W_Grenade_Explode (world);
665 void W_Grenade_Touch (void)
667 // I decided to take this out to add more skill to using the grenade launcher, so the user always has to trigger it.
668 // I increased the power of the grenade launcher because of this.
669 //if (other.classname == "player" || other.classname == "corpse")
670 // W_Grenade_Explode (other);
672 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
675 void W_Grenade_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
677 self.health = self.health - damage;
678 if (self.health <= 0)
679 W_Grenade_FuseExplode();
682 void W_Grenade_Attack (void)
686 sound (self, CHAN_WEAPON, "weapons/grenade_fire.wav", 1, ATTN_NORM);
688 self.punchangle_x = -4;
692 gren.classname = "grenade";
694 gren.movetype = MOVETYPE_BOUNCE;
695 gren.solid = SOLID_BBOX;
697 gren.takedamage = DAMAGE_YES;
698 gren.damageforcescale = 4;
700 gren.event_damage = W_Grenade_Damage;
702 setmodel (gren, "models/grenademodel.md3");
703 setsize (gren, '-6 -6 -3', '6 6 3');
705 makevectors (self.v_angle);
706 setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
708 gren.velocity = v_forward * 900 + v_up * 200;
709 gren.angles = vectoangles (gren.velocity);
710 gren.avelocity = '100 150 100';
712 gren.touch = W_Grenade_Touch;
713 gren.think = W_Grenade_FuseExplode;
714 gren.nextthink = time + 5;
716 self.attack_finished = time + 1;
717 self.ammo_rockets = self.ammo_rockets - 1;
720 void W_Grenade_Attack2 (void)
723 proj = findradius (self.origin, 50000);
726 if (proj.classname == "grenade" && proj.owner == self)
728 proj.nextthink = time;
733 self.attack_finished = time;
736 void W_Grenade_Attack3 (void)
738 sound (self, CHAN_WEAPON, "weapons/grenade_fire.wav", 1, ATTN_NORM);
739 self.punchangle_x = -4;
745 gren.classname = "grenade";
746 gren.movetype = MOVETYPE_BOUNCE;
747 gren.solid = SOLID_BBOX;
748 setmodel(gren, "models/grenademodel.md3");
749 setsize(gren, '-14 -5 -4', '16 4 5');
750 setorigin(gren, (self.origin + self.view_ofs));
752 gren.takedamage = DAMAGE_YES;
753 makevectors (self.v_angle);
755 gren.velocity = v_forward * (1200 + 1 * 800) + (v_up * 200) + (crandom () * v_right * 10) + (crandom () * v_up * 10);
758 gren.velocity = aim (self, 10000) * (1200 + 1 * 800);
759 gren.velocity_z = 200;
761 gren.avelocity_x = random () * -500 - 500;
762 gren.mins = normalize (gren.angles) * gren.mins;
763 gren.maxs = normalize (gren.angles) * gren.maxs;
764 setsize (gren, gren.mins, gren.maxs);
765 gren.angles = vectoangles (gren.velocity);
766 gren.touch = W_Grenade_Explode;
767 gren.think = W_Grenade_Explode;
768 gren.nextthink = time + 3;
769 self.ammo_rockets = self.ammo_rockets - 1;
772 self.attack_finished = time + 0.8;
776 void W_Electro_Touch (void)
778 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
779 WriteByte (MSG_BROADCAST, 79);
780 WriteCoord (MSG_BROADCAST, self.origin_x);
781 WriteCoord (MSG_BROADCAST, self.origin_y);
782 WriteCoord (MSG_BROADCAST, self.origin_z);
783 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
784 WriteCoord (MSG_BROADCAST, 0); // Sajt: Yeah.. I agree with him
785 WriteCoord (MSG_BROADCAST, 0);
786 WriteByte (MSG_BROADCAST, 155);
787 self.event_damage = SUB_Null;
788 RadiusDamage (self, self.owner, 50, 10, 70, world, 50, IT_ELECTRO);
789 sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
793 void W_Electro_Attack (float postion)
797 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
801 proj.classname = "spike";
803 proj.movetype = MOVETYPE_FLY;
804 proj.solid = SOLID_BBOX;
807 makevectors (self.v_angle);
810 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
816 //flash.drawonlytoclient;
817 //setorigin (flash, org);
818 //setmodel (flash, "models/flash.md3");
819 //flash.velocity = v_forward * 9;
820 //flash.angles = vectoangles (flash.velocity);
821 //SUB_SetFade (flash, time + 0 + random () * 4);
823 setmodel (proj, "models/elaser.mdl");
824 setsize (proj, '0 0 0', '0 0 0');
826 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -14);
828 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
830 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 15 + v_up * -14);
832 proj.velocity = v_forward * 9999;
833 proj.touch = W_Electro_Touch;
834 proj.think = SUB_Remove;
835 proj.nextthink = time + 1.5;
837 proj.angles = vectoangles (proj.velocity);
839 proj.effects = proj.effects | EF_ADDITIVE;
841 self.attack_finished = time + 0.4;
842 self.ammo_cells = self.ammo_cells - 1;
845 void W_Plasma_Explode (entity ignore)
847 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
848 WriteByte (MSG_BROADCAST, 79);
849 WriteCoord (MSG_BROADCAST, self.origin_x);
850 WriteCoord (MSG_BROADCAST, self.origin_y);
851 WriteCoord (MSG_BROADCAST, self.origin_z);
852 WriteCoord (MSG_BROADCAST, 0); // SeienAbunae: groan... Useless clutter
853 WriteCoord (MSG_BROADCAST, 0);
854 WriteCoord (MSG_BROADCAST, 0);
855 WriteByte (MSG_BROADCAST, 155);
857 te_customflash (self.origin, 5000, 10, '0 0 1');
859 self.event_damage = SUB_Null;
860 RadiusDamage (self, self.owner, 100, 50, 100, world, 50, IT_ELECTRO);
861 sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM);
866 void W_Plasma_FuseExplode (void)
868 W_Plasma_Explode (world);
871 void W_Plasma_Touch (void)
873 if (other.classname == "player" || other.classname == "corpse")
874 W_Plasma_Explode (other);
876 sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM);
879 void W_Plasma_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
881 self.health = self.health - damage;
882 if (self.health <= 0)
883 W_Plasma_FuseExplode ();
886 void W_Electro_Attack2 (float postion)
890 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
892 self.punchangle_x = -4;
896 Plasma.classname = "grenade";
899 Plasma.movetype = MOVETYPE_BOUNCE;
900 Plasma.solid = SOLID_BBOX;
903 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
906 Plasma.takedamage = DAMAGE_YES;
907 Plasma.damageforcescale = 4;
909 Plasma.event_damage = W_Plasma_Damage;
911 setmodel (Plasma, "models/elaser.mdl");
912 setsize (Plasma, '-6 -6 -3', '6 6 3');
914 makevectors (self.v_angle);
917 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 0 + v_up * -14);
919 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
921 setorigin (Plasma, self.origin + self.view_ofs + v_forward * 18 + v_right * 20 + v_up * -14);
923 Plasma.velocity = v_forward * 900 + v_up * 200;
924 Plasma.angles = vectoangles (Plasma.velocity);
925 Plasma.avelocity = '0 0 0';
927 Plasma.touch = W_Plasma_Touch;
928 Plasma.think = W_Plasma_FuseExplode;
929 Plasma.nextthink = time + 2;
931 Plasma.effects = Plasma.effects | EF_ADDITIVE;
933 self.attack_finished = time + 1;
934 self.ammo_cells = self.ammo_cells - 2;
938 void W_Electro_Attack3 (float postion)
943 sound (self, CHAN_WEAPON, "weapons/electro_fire.wav", 1, ATTN_NORM);
947 proj.classname = "spike";
949 proj.movetype = MOVETYPE_BOUNCEMISSILE;
950 proj.solid = SOLID_BBOX;
953 makevectors (self.v_angle);
955 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 7 + v_up * -9;
958 setmodel (proj, "models/bullet.mdl");
959 setsize (proj, '0 0 0', '0 0 0');
961 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -14);
963 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 10 + v_up * -12);
965 setorigin (proj, self.origin + self.view_ofs + v_forward * 18 + v_right * 15 + v_up * -14);
967 proj.velocity = v_forward * 9999;
968 proj.think = W_Electro_Touch;
969 proj.nextthink = time + 8;
971 proj.effects = proj.effects | EF_ADDITIVE;
973 self.attack_finished = time + 0.4;
974 self.ammo_cells = self.ammo_cells - 1;
978 void W_Crylink_Touch (void)
980 self.event_damage = SUB_Null;
981 te_smallflash(self.origin);
982 RadiusDamage (self, self.owner, 45, 0, 3, world, 55, IT_CRYLINK);
986 void W_Crylink_Attack (void) //(float postion)
990 sound (self, CHAN_WEAPON, "weapons/crylink.wav", 1, ATTN_NORM);
993 // org = self.origin + self.view_ofs + v_forward * 18 + v_right * 9 + v_up * -27;
995 // org = self.origin + self.view_ofs + v_forward * 18 + v_right * 18 + v_up * -13;
997 // org = self.origin + self.view_ofs + v_forward * 18 + v_right * 9 + v_up * -6;
999 // org = self.origin + self.view_ofs + v_forward * 18 + v_right * 0 + v_up * -13;
1001 makevectors (self.v_angle);
1002 org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
1004 FireRailgunBullet (org, self.origin + self.view_ofs + v_forward * 4096, 25, IT_CRYLINK);
1006 te_spark (trace_endpos, v_forward, 55);
1008 self.ammo_cells = self.ammo_cells - 0.25;
1009 self.attack_finished = time + 0.165;
1012 void W_Crylink_Attack2 (void)
1017 sound (self, CHAN_WEAPON, "weapons/crylink2.wav", 1, ATTN_NORM);
1021 proj.classname = "spike";
1023 proj.movetype = MOVETYPE_FLY;
1024 proj.solid = SOLID_BBOX;
1026 makevectors (self.v_angle);
1028 setmodel (proj, "models/sprites/bubbles.spr");
1029 setsize (proj, '0 0 0', '0 0 0');
1030 setorigin (proj, self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14);
1032 proj.velocity = v_forward * 5000;
1033 proj.velocity = proj.velocity + v_right * ( crandom() * 50 );
1034 proj.velocity = proj.velocity + v_up * ( crandom() * 50 );
1035 proj.touch = W_Crylink_Touch;
1036 proj.think = SUB_Remove;
1037 proj.nextthink = time + 9;
1039 proj.glow_color = 10;
1040 proj.glow_size = 30;
1042 self.attack_finished = time + 0.20;
1043 self.ammo_cells = self.ammo_cells - 0.2;
1046 void W_Nex_Attack (void)
1052 sound (self, CHAN_WEAPON, "weapons/nexfire.wav", 1, ATTN_NORM);
1053 self.punchangle_x = -4;
1055 makevectors (self.v_angle);
1057 org = self.origin + self.view_ofs + v_forward * 18 + v_right * 8 + v_up * -5;
1060 if (game & GAME_INSTAGIB)
1061 FireRailgunBullet (org, self.origin + self.view_ofs + v_forward * 4096, 800, IT_NEX);
1063 FireRailgunBullet (org, self.origin + self.view_ofs + v_forward * 4096, 80, IT_NEX);
1065 te_plasmaburn (trace_endpos);
1067 if (trace_fraction < 1.0)
1069 dir = trace_plane_normal * 100;
1070 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
1071 WriteByte (MSG_BROADCAST, TE_FLAMEJET);
1072 WriteCoord (MSG_BROADCAST, trace_endpos_x);
1073 WriteCoord (MSG_BROADCAST, trace_endpos_y);
1074 WriteCoord (MSG_BROADCAST, trace_endpos_z);
1075 WriteCoord (MSG_BROADCAST, dir_x);
1076 WriteCoord (MSG_BROADCAST, dir_y);
1077 WriteCoord (MSG_BROADCAST, dir_z);
1078 WriteByte (MSG_BROADCAST, 255);
1080 explosion = spawn ();
1081 setorigin (explosion, trace_endpos);
1082 RadiusDamage (explosion, self, 10, 0, 50, world, 300, IT_ROCKET_LAUNCHER);
1085 PointSound (trace_endpos, "weapons/neximpact.wav", 1, ATTN_NORM);
1088 self.attack_finished = time + 1;
1090 if (!(game & GAME_INSTAGIB))
1091 self.ammo_cells = self.ammo_cells - 1;
1094 void W_Nex_Attack2 (void)
1100 void W_Hagar_Explode (void)
1102 ImpactEffect (self, IT_HAGAR);
1104 self.event_damage = SUB_Null;
1105 RadiusDamage (self, self.owner, 40, 15, 70, world, 100, IT_HAGAR);
1110 void W_Hagar_Fireball (void)
1112 self.effects = self.effects | EF_FLAME;
1115 void W_Hagar_Touch (void)
1117 if (other == self.owner)
1119 else if (pointcontents (self.origin) == CONTENT_SKY)
1128 void W_Hagar_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
1130 self.health = self.health - damage;
1131 if (self.health <= 0)
1135 void W_Hagar_Attack (void)
1139 sound (self, CHAN_WEAPON, "weapons/hagar_fire.wav", 1, ATTN_NORM);
1142 missile.owner = self;
1143 missile.classname = "missile";
1145 missile.takedamage = DAMAGE_YES;
1146 missile.damageforcescale = 4;
1147 missile.health = 10;
1148 missile.event_damage = W_Hagar_Damage;
1150 missile.movetype = MOVETYPE_FLY;
1151 missile.solid = SOLID_BBOX;
1152 setmodel (missile, "models/hagarmissile.mdl");
1153 setsize (missile, '0 0 0', '0 0 0');
1155 makevectors (self.v_angle);
1157 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1159 missile.velocity = v_forward * 2000;
1160 missile.velocity = missile.velocity + v_right * ( crandom() * 70 );
1161 missile.velocity = missile.velocity + v_up * ( crandom() * 30 );
1162 missile.angles = vectoangles (missile.velocity);
1163 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1165 missile.touch = W_Hagar_Touch;
1166 missile.think = W_Hagar_Explode;
1167 missile.nextthink = time + 10;
1169 self.attack_finished = time + 0.2;
1170 self.ammo_rockets = self.ammo_rockets - 0.25;
1173 void W_Hagar_Attack2 (void)
1177 sound (self, CHAN_WEAPON, "weapons/hagar_fire2.wav", 1, ATTN_NORM);
1180 missile.owner = self;
1181 missile.classname = "missile";
1183 missile.movetype = MOVETYPE_TOSS;
1184 missile.solid = SOLID_BBOX;
1186 missile.takedamage = DAMAGE_YES;
1187 missile.damageforcescale = 4;
1189 missile.event_damage = W_Hagar_Damage;
1191 setmodel (missile, "models/fire.mdl");
1192 setsize (missile, '-6 -6 -3', '6 6 3');
1194 makevectors (self.v_angle);
1195 setorigin (missile, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12);
1197 missile.velocity = v_forward * 1400 + v_up * 100;
1198 missile.angles = vectoangles (missile.velocity);
1199 missile.avelocity = '0 0 0';
1201 missile.touch = W_Hagar_Touch;
1202 missile.think = W_Hagar_Fireball;
1203 missile.nextthink = time + 0.05;
1205 self.attack_finished = time + 0.2;
1206 self.ammo_rockets = self.ammo_rockets - 0.25;
1209 void W_Hagar_Attack3 (void)
1212 proj = findradius (self.origin, 50000);
1215 if (proj.classname == "missile" && proj.owner == self)
1217 proj.velocity = proj.velocity - v_up * 500;
1218 proj.velocity = proj.velocity - v_forward * 1000;
1223 self.attack_finished = time;
1226 void W_Rocket_Explode (entity ignore)
1228 ImpactEffect (self, IT_ROCKET_LAUNCHER);
1230 self.event_damage = SUB_Null;
1231 RadiusDamage (self, self.owner, 130, 50, 170, ignore, 600, IT_ROCKET_LAUNCHER);
1236 void W_Rocket_Think (void)
1238 W_Rocket_Explode (world);
1241 void W_Rocket_Touch (void)
1243 if (other == self.owner)
1245 else if (pointcontents (self.origin) == CONTENT_SKY)
1251 W_Rocket_Explode (world);
1254 void W_Rocket_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype)
1256 self.health = self.health - damage;
1257 if (self.health <= 0)
1258 W_Rocket_Explode(world);
1261 void W_Rocket_Attack (void)
1266 sound (self, CHAN_WEAPON, "weapons/rocket_fire.wav", 1, ATTN_NORM);
1269 missile.owner = self;
1270 missile.classname = "missile";
1272 missile.takedamage = DAMAGE_YES;
1273 missile.damageforcescale = 4;
1274 missile.health = 10;
1275 missile.event_damage = W_Rocket_Damage;
1277 missile.movetype = MOVETYPE_FLY;
1278 missile.solid = SOLID_BBOX;
1279 setmodel (missile, "models/rocketmissile.mdl");
1280 setsize (missile, '0 0 0', '0 0 0');
1282 makevectors (self.v_angle);
1284 org = self.origin + self.view_ofs + v_forward * 20 + v_right * 4 + v_up * -15;
1286 setorigin (missile, org);
1287 missile.velocity = v_forward * 2000;
1288 missile.angles = vectoangles (missile.velocity);
1290 missile.touch = W_Rocket_Touch ;
1291 missile.think = W_Rocket_Think;
1292 missile.nextthink = time + 9;
1294 self.attack_finished = time + 1.5;
1296 if (!(game & GAME_ROCKET_ARENA))
1297 self.ammo_rockets = self.ammo_rockets - 1;
1300 void W_Rocket_Attack2 (void)
1303 proj = findradius (self.origin, 50000);
1306 if (proj.classname == "missile" && proj.owner == self)
1308 proj.nextthink = time;
1313 self.attack_finished = time;
1317 void W_Rocket_Attack3 (void)
1323 void W_Attack (void)
1325 if (self.deadflag != DEAD_NO)
1327 if (self.death_time < time)
1328 PutClientInServer();
1333 if (!W_CheckAmmo ())
1336 if (self.weapon == IT_LASER)
1338 else if (self.weapon == IT_UZI)
1340 else if (self.weapon == IT_SHOTGUN)
1341 W_Shotgun_Attack ();
1342 else if (self.weapon == IT_GRENADE_LAUNCHER)
1343 W_Grenade_Attack ();
1344 else if (self.weapon == IT_ELECTRO)
1346 W_Electro_Attack (self.electrocount);
1347 self.electrocount = self.electrocount + 1;
1348 if (self.electrocount == 3)
1349 self.electrocount = 0;
1351 else if (self.weapon == IT_CRYLINK)
1352 W_Crylink_Attack ();
1353 else if (self.weapon == IT_NEX)
1355 else if (self.weapon == IT_HAGAR)
1357 else if (self.weapon == IT_ROCKET_LAUNCHER)
1363 void W_SecondaryAttack (void)
1365 if (self.deadflag != DEAD_NO)
1367 if (self.death_time < time)
1368 PutClientInServer();
1373 if (!W_CheckAmmo ())
1376 if (self.weapon == IT_LASER)
1378 else if (self.weapon == IT_UZI)
1380 else if (self.weapon == IT_SHOTGUN)
1381 W_Shotgun_Attack2 ();
1382 else if (self.weapon == IT_GRENADE_LAUNCHER)
1383 W_Grenade_Attack2 ();
1384 else if (self.weapon == IT_ELECTRO) {
1385 W_Electro_Attack2 (self.electrocount);
1386 self.electrocount = self.electrocount + 1;
1387 if (self.electrocount == 3)
1388 self.electrocount = 0;
1390 else if (self.weapon == IT_CRYLINK)
1391 W_Crylink_Attack2 ();
1392 else if (self.weapon == IT_NEX)
1394 else if (self.weapon == IT_HAGAR)
1396 else if (self.weapon == IT_ROCKET_LAUNCHER)
1397 W_Rocket_Attack2 ();
1402 void W_ThirdAttack (void)
1404 if (self.deadflag != DEAD_NO)
1406 if (self.death_time < time)
1407 PutClientInServer();
1412 if (!W_CheckAmmo ())
1415 if (self.weapon == IT_LASER)
1417 else if (self.weapon == IT_UZI)
1419 else if (self.weapon == IT_SHOTGUN)
1420 W_Shotgun_Attack2 ();
1421 else if (self.weapon == IT_GRENADE_LAUNCHER)
1422 W_Grenade_Attack3 ();
1423 else if (self.weapon == IT_ELECTRO) {
1424 W_Electro_Attack3 (self.electrocount);
1425 self.electrocount = self.electrocount + 1;
1426 if (self.electrocount == 3)
1427 self.electrocount = 0;
1429 else if (self.weapon == IT_CRYLINK)
1430 W_Crylink_Attack2 ();
1431 else if (self.weapon == IT_NEX)
1433 else if (self.weapon == IT_HAGAR)
1435 else if (self.weapon == IT_ROCKET_LAUNCHER)
1436 W_Rocket_Attack3 ();