void () ProxExplode;
void () GrenadeExplode;
void () GrenadeTouch;
void (vector org, vector vec) LaunchLaser;
void () Laser_Touch;
void () player_run;
void (vector org, vector vel, float damage) SpawnBlood;
void () SuperDamageSound;

void () W_Precache = {

	//you must precache any sounds and models you are going to use for a new weapon
	//here

   precache_sound ("weapons/r_exp3.wav");
   precache_sound ("weapons/rocket1i.wav");
   precache_sound ("weapons/sgun1.wav");
   precache_sound ("weapons/guncock.wav");
   precache_sound ("weapons/ric1.wav");
   precache_sound ("weapons/ric2.wav");
   precache_sound ("weapons/ric3.wav");
   precache_sound ("weapons/spike2.wav");
   precache_sound ("weapons/tink1.wav");
   precache_sound ("weapons/grenade.wav");
   precache_sound ("weapons/bounce.wav");
   precache_sound ("weapons/shotgn2.wav");

   precache_sound ("catfire.wav");
   precache_sound ("catch.wav");
   precache_sound ("machine.wav");
   precache_sound ("beep.wav");
   precache_model ("progs/v_shot2.mdl");
   precache_sound ("enforcer/enfire.wav");
   precache_sound ("enforcer/enfstop.wav");
   precache_model ("progs/laser.mdl");
   precache_sound ("explo.wav"); //for nuke
   precache_model ("progs/nuke.mdl");
  
   //precache_model ("progs/sm_expld.spr");
   precache_model ("progs/throwaxe.mdl");
   precache_sound ("weapons/whoosh1.wav");
   precache_sound ("weapons/whoosh2.wav");
   precache_sound ("weapons/whoosh3.wav");


	//for dropping weapons instead of backpacks
   precache_model ("progs/g_nail.mdl");
   precache_model ("progs/g_agun.mdl");
   precache_model ("progs/g_nail2.mdl");
   precache_model ("progs/g_rock2.mdl");
   precache_model ("progs/g_rock.mdl");
   precache_model ("progs/g_light.mdl");
   precache_model ("progs/g_shot.mdl");
   //end
	
	radar_precache();
   er_precache();
   hcg_precache();
   PM_PrecacheFire();
   PlasmaPrecache();
	BlazePrecache();
	DevastatorPrecache();
mk23_precache();
moss_precache();
   HomerPrecache();
   DarkPrecache();
   ProtonPrecache();
   precache_model ("progs/s_bubble.spr"); //for chasecam
};

/*void () ThrowSound = {

   local float rsnd;
   
   rsnd = ceil(random() * 4);   
   if (rsnd == 1.0)
      sound (self,CHAN_VOICE,"player/land.wav",TRUE,ATTN_NORM);
   else if (rsnd == 2.0)
      sound (self,CHAN_VOICE,"player/land2.wav",TRUE,ATTN_NORM);
   else if (rsnd == 3.0)
      sound (self,CHAN_VOICE,"player/lburn1.wav",TRUE,ATTN_NORM);
   else 
      sound (self,CHAN_VOICE,"player/pain5.wav",TRUE,ATTN_NORM);

};
*/

float () crandom = {

   return ( (FL_SWIM * (random () - 0.500)) );

};


void () W_FireAxe = {

   local vector source;
   local vector org;
	local float damg; //added

   makevectors (self.v_angle);
   source = (self.origin + '0.000 0.000 16.000');
   traceline (source,(source + (v_forward * 64)),FALSE,self);
   if ( (trace_fraction == TRUE) ) {

      return ;

   }
   org = (trace_endpos - (v_forward * MOVETYPE_STEP));

   damg = 10 + (random() * 15.0); //added. i wanted this to always gib the soldier and doggies, sometimes first whack, sometimes second

	if (random() < 0.20) //20% chance of double damage
		damg = damg * 2;
	

   if ( trace_ent.takedamage ) {

      trace_ent.axhitme = TRUE;
	if (trace_ent.classname != "player")
		SpawnAlienBlood(org,VEC_ORIGIN,20.000);
	else
	        SpawnBlood (org,VEC_ORIGIN,20.000);

      T_Damage (trace_ent,self,self,damg);

   } else {

      sound (self,CHAN_WEAPON,"weapons/tink1.wav",TRUE,ATTN_NORM);
      WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
      WriteByte (MSG_BROADCAST,TE_GUNSHOT);
      WriteCoord (MSG_BROADCAST,org_x);
      WriteCoord (MSG_BROADCAST,org_y);
      WriteCoord (MSG_BROADCAST,org_z);

   }

};
vector () wall_velocity = {

   local vector vel;

   vel = normalize (self.velocity);
   vel = normalize (((vel + (v_up * (random () - 0.500))) + (v_right * (random () - 0.500))));
   vel = (vel + (FL_SWIM * trace_plane_normal));
   vel = (vel * 200.000);
   return ( vel );

};

void (vector org, vector vel) SpawnMeatSpray = {

   local entity missile;
   local entity mpuff;

   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_BOUNCE;
   missile.solid = SOLID_TRIGGER;
   makevectors (self.angles);
   missile.velocity = vel;
   missile.velocity_z = ((missile.velocity_z + 250.000) + (50.000 * random ()));
   missile.avelocity = '3000.000 1000.000 2000.000';
   missile.nextthink = (time + TRUE);
   missile.think = SUB_Remove;
   setmodel (missile,"progs/zom_gib.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,org);

};
/*
void (vector org, vector vel) SpawnExplodingMeat = {

   local entity missile;
   local entity mpuff;

   missile = spawn ();
   missile.owner = self.owner;
   missile.movetype = MOVETYPE_BOUNCE;
   missile.solid = SOLID_NOT;
   makevectors (self.angles);
   missile.velocity = vel;
   missile.velocity_z = ((missile.velocity_z + 250.000) + (50.000 * random ()));
   missile.avelocity = '3000.000 1000.000 2000.000';
   missile.nextthink = (time + 2.000); //explode in two seconds
   missile.think = ProxExplode;
   missile.touch = ProxExplode;			//explode on impact
   missile.classname = "meat";
   setmodel (missile,"progs/gib2.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,org);

};
*/

void (vector org, vector vel, float damage) SpawnBlood = {

	   particle (org,(vel * 0.100),73.000,(damage * FL_SWIM));
   	particle (org,(vel * -0.100),73.000,(damage * FL_SWIM));
   particle (org,(vel * 0.100),73.000,(damage * FL_SWIM));
  	particle (org,(vel * -0.100),73.000,(damage * FL_SWIM));



};


void (vector org, vector vel, float damage) SpawnAlienBlood = {

	   particle (org,(vel * 0.100),190.000,(damage * FL_SWIM));
   	particle (org,(vel * -0.100),184.000,(damage * FL_SWIM));
   particle (org,(vel * 0.100),190.000,(damage * FL_SWIM));
  	particle (org,(vel * -0.100),190.000,(damage * FL_SWIM));

};
void (float damage) spawn_touchblood = {

   local vector vel;

	if (random() < 0.5)
	   vel = (wall_velocity () * 0.200);
	else
	   vel = (wall_velocity () * -0.200);
	   
   SpawnBlood ((self.origin + (vel * 0.010)),vel,damage);

};

void (vector org, vector vel) SpawnChunk = {

   particle (org,(vel * 0.020),FALSE,MOVETYPE_BOUNCE);
   particle (org,(vel * 0.020),FALSE,MOVETYPE_BOUNCE);
   particle (org,(vel * 0.020),FALSE,MOVETYPE_BOUNCE);

};
entity multi_ent;
float multi_damage /* = 0.000 */;

void () ClearMultiDamage = {

   multi_ent = world;
   multi_damage = FALSE;

};

void () ApplyMultiDamage = {

   if ( !multi_ent ) {

      return ;

   }
   T_Damage (multi_ent,self,self,multi_damage);

};

void (entity hit, float damage) AddMultiDamage = {

   if ( !hit ) {

      return ;

   }
   if ( (hit != multi_ent) ) {

      ApplyMultiDamage ();
      multi_damage = damage;
      multi_ent = hit;

   } else {

      multi_damage = (multi_damage + damage);

   }

};

void () s_explode1;
/*
void () sm_expld =
{
   setmodel (self,"progs/s_explod.spr");
	particle (self.origin, self.oldorigin*0.05, 235, 16);
	sound (self, CHAN_BODY, "weapons/r_exp3.wav", 0.5, ATTN_NORM);
	s_explode1 ();
};
*/
void (vector org, vector vel) ChaingunExplode =
{
	local entity expld;
	expld = spawn();
	setorigin (expld, org);
	setsize (expld, '0 0 0', '0 0 0');
	expld.oldorigin = vel;
	expld.movetype = MOVETYPE_NONE;
	expld.solid = SOLID_NOT;
	expld.classname = "expbullet";
	//expld.think = sm_expld;
	expld.think = GrenadeExplode;
	expld.nextthink = time + random()*0.4;
	//T_RadiusDamage (expld, self, 50, world);

};

void (vector org, vector vel) ShotgunExplode =
{
	local entity expld;
	expld = spawn();
	setorigin (expld, org);
	setsize (expld, '0 0 0', '0 0 0');
	expld.oldorigin = vel;
	expld.movetype = MOVETYPE_NONE;
	expld.solid = SOLID_NOT;
	expld.classname = "expbullet";
	//expld.think = sm_expld;
	//expld.think = GrenadeExplode; //changed
	setmodel(expld,"progs/s_explod.spr");
	expld.think = s_explode1; //new
	expld.nextthink = time + random()*0.4;

	T_RadiusDamage (expld, self, 60, world);
};

void (float damage, vector dir) TraceAttack = {

   local vector vel;
   local vector org;

   vel = normalize (((dir + (v_up * crandom ())) + (v_right * crandom ())));
   vel = (vel + (FL_SWIM * trace_plane_normal));
   vel = (vel * 200.000);
   org = (trace_endpos - (dir * MOVETYPE_STEP));

	//gib the enemies with chaingun
	if ((self.weapon == IT_SUPER_NAILGUN))
	{
		//damage = damage * 1.5;

		if ((trace_ent.health < 10) || (trace_ent.classname == "monster_zombie"))
			damage = damage * 10;
   }

		
//	if (trace_ent.classname == "monster_shambler")
//		damage = damage * 0.5;

   if ((self.weapon == IT_SUPER_NAILGUN) && (self.supernailguntype == 0))
   {
      ricsound ();
		particle (org,(vel * 0.020),0.000,10.000);
      particle (trace_endpos,'0.000 0.000 0.000',481.000,1.000);
      particle (trace_endpos,'0.000 0.000 0.000',489.000,1.000);
      particle (trace_endpos,(vel * 0.020),0.000,10.000);
   }
	
	//elephant rifle damage
	if ((self.weapon == IT_SUPER_SHOTGUN) && (self.supershotguntype < 2))
			damage = damage * 5;
	else
			damage = damage * 3;

		
	//bondo: exploding chaingun and shotgun
	if ((self.weapon == IT_SUPER_NAILGUN) && (self.supernailguntype == 1))
		ShotgunExplode (org, vel*0.2);
	else //bondo: end exploding guns
	
   if ( trace_ent.takedamage ) {

	if (trace_ent.classname != "player")
      SpawnAlienBlood (org,(vel * 0.200),damage);
	else
      SpawnBlood (org,(vel * 0.200),damage);

      AddMultiDamage (trace_ent,damage);

   } else {

      WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
      WriteByte (MSG_BROADCAST,TE_GUNSHOT);
      WriteCoord (MSG_BROADCAST,org_x);
      WriteCoord (MSG_BROADCAST,org_y);
      WriteCoord (MSG_BROADCAST,org_z);

   }

};

void (float shotcount, vector dir, vector spread) FireBullets = {

   local vector direction;
   local vector src;

   makevectors (self.v_angle);
   src = (self.origin + (v_forward * MOVETYPE_BOUNCE));
   src_z = (self.absmin_z + (self.size_z * 0.700));
   ClearMultiDamage ();
   while ( (shotcount > FALSE) ) {

      direction = ((dir + ((crandom () * spread_x) * v_right)) + ((crandom () * spread_y) * v_up));
      traceline (src,(src + (direction * FL_WATERJUMP)),FALSE,self);
      if ( (trace_fraction != TRUE) )
         TraceAttack (4,direction); //normal shotgun damage is four times the shotcount
      
      
      shotcount = (shotcount - TRUE);

   }
   ApplyMultiDamage ();

};

void () W_FireShotgun = {

   local vector dir;

	      sound (self,CHAN_WEAPON,"weapons/guncock.wav",TRUE,ATTN_NORM);

   self.punchangle_x = CONTENT_SOLID;
   
   self.ammo_shells = (self.ammo_shells - 1);
   self.currentammo = (self.ammo_shells - 1);
   dir = aim (self,100000.000);


	   FireBullets (2,dir,'0.020 0.020 0.000');

	if (!(deathmatch) && !(coop))
	   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(v_right * 32.000));

		self.bondo = self.bondo + 1; //added for reload time


};

void () W_FireSuperShotgun = {

   local vector dir;

		if (self.currentammo < 2)
	      W_FireShotgun ();

	   self.ammo_shells = (self.ammo_shells - FL_SWIM);
   	self.currentammo = (self.ammo_shells - FL_SWIM);

   sound (self,CHAN_WEAPON,"weapons/shotgn2.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SLIME;
   
   dir = aim (self,100000.000);
	   FireBullets (5.000,dir,'0.080 0.080 0.000');
	self.bondo = self.bondo + 1; //added for reload time
   	      	


	if (!(deathmatch) && !(coop))
	{
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(v_right * 32.000));
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * -6.000)),(v_right * -32.000));
   }

};

void () W_FireSuperDuperShotgun = {

   local vector dir;

   if ( (self.currentammo < 4.0) ) {

      W_FireSuperShotgun ();
      return ;

   }

      sound (self,CHAN_WEAPON,"weapons/shotgn2.wav",TRUE,ATTN_NORM);
      sound (self,CHAN_WEAPON,"weapons/shotgn2.wav",TRUE,ATTN_NORM);

   self.punchangle_x = CONTENT_SLIME;
   self.ammo_shells = (self.ammo_shells - 4.0);
   self.currentammo = (self.ammo_shells - 4.0);
   dir = aim (self,100000.000);

   FireBullets (10.000,dir,'0.140 0.080 0.000');

	if (!(deathmatch) && !(coop)) {
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(v_right * 32.000));
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * -6.000)),(v_right * -32.000));
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(v_right * 32.000));
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * -6.000)),(v_right * -32.000));
   }

};

void () s_explode1 = [ 0.000, s_explode2 ] {


};


void () s_explode2 = [ 1.000, s_explode3 ] {


};

void () s_explode3 = [ 2.000, s_explode4 ] {


};

void () s_explode4 = [ 3.000, s_explode5 ] {


};

void () s_explode5 = [ 4.000, s_explode6 ] {


};

void () s_explode6 = [ 5.000, SUB_Remove ] {


};

void () BecomeExplosion = {

   self.movetype = MOVETYPE_NONE;
   self.velocity = VEC_ORIGIN;
   self.touch = SUB_Null;
   setmodel (self,"progs/s_explod.spr");
   self.solid = SOLID_NOT;
   s_explode1 ();

};

void () AcidExplosion = {

   self.movetype = MOVETYPE_NONE;
   self.velocity = VEC_ORIGIN;
   self.touch = SUB_Null;
   setmodel (self,"progs/s_explod.spr");
   self.solid = SOLID_NOT;
   s_explode1 ();
   spawn_touchblood (50.000);

};

void () T_MissileTouch = {

   local float damg;

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   damg = (100.000 + (random () * 20.000));
   if ( other.health ) {

      //if ( (other.classname == "monster_shambler") ) {

        // damg = (damg * 1.300);

      //}
//      damg = damg * 2; //double damage from explosive weapons
	T_Damage (other,self,self.owner,damg);

   }
   T_RadiusDamage (self,self.owner,120.000,other);
   self.origin = (self.origin - (FL_CLIENT * normalize (self.velocity)));
   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_EXPLOSION);
   WriteCoord (MSG_BROADCAST,self.origin_x);
   WriteCoord (MSG_BROADCAST,self.origin_y);
   WriteCoord (MSG_BROADCAST,self.origin_z);
   BecomeExplosion ();

};

void () T_MissileTouch2 = {

   local float damg;

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   damg = (70.000 + (random () * 20.000));
   if ( other.health ) {

/*
      if ( (other.classname == "monster_shambler") || (other == self.owner)) {

         damg = (damg * 1.200);

      }
	damg = damg * 2;
*/
      T_Damage (other,self,self.owner,damg);

   }
   T_RadiusDamage (self,self.owner,90.000,other);
   self.origin = (self.origin - (FL_CLIENT * normalize (self.velocity)));
   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_EXPLOSION);
   WriteCoord (MSG_BROADCAST,self.origin_x);
   WriteCoord (MSG_BROADCAST,self.origin_y);
   WriteCoord (MSG_BROADCAST,self.origin_z);
   BecomeExplosion ();

};


void () MNExplosion;

void () W_FireRocket = {

   local entity missile;
   local entity mpuff;

   self.ammo_rockets = (self.ammo_rockets - TRUE);
   self.currentammo = (self.ammo_rockets - TRUE);
      sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   missile.classname = "missile";
   makevectors (self.v_angle);
   missile.velocity = aim (self,1000.000);
   missile.velocity = (missile.velocity * 1000.000);
   missile.angles = vectoangles (missile.velocity);

  	missile.touch = T_MissileTouch;

   missile.nextthink = (time + MOVETYPE_FLY);
   missile.think = SUB_Remove;
   setmodel (missile,"progs/missile.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * FL_CLIENT)) + '0.000 0.000 16.000'));

};

void () W_FireDualRockets;

void () W_FireDukeNuke2 = {

   local entity missile;
   local entity mpuff;

	if (self.ammo_rockets < 10)
		W_FireDualRockets();
		
   self.ammo_rockets = (self.ammo_rockets - 10);
   self.currentammo = (self.ammo_rockets - 10);
      sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   missile.classname = "missile";
   makevectors (self.v_angle);
   missile.velocity = aim (self,1000.000);
   missile.velocity = (missile.velocity * 1000.000);
   missile.angles = vectoangles (missile.velocity);
	missile.touch = MNExplosion;
   missile.nextthink = (time + MOVETYPE_FLY);
   missile.think = SUB_Remove;
   setmodel (missile,"progs/missile.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * FL_CLIENT)) + '0.000 0.000 16.000'));

};


void () W_FireDualRockets = {

   local entity missile1,missile2;
   local entity mpuff;

   if (self.ammo_rockets < 2.0)
   {
   W_FireRocket();
   return;
   }


   self.ammo_rockets = (self.ammo_rockets - 2.0);
   self.currentammo = (self.ammo_rockets - 2.0);
	sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile1 = spawn ();
   missile2 = spawn ();

   missile1.owner = self;
   missile1.movetype = MOVETYPE_FLYMISSILE;
   missile1.solid = SOLID_BBOX;
   missile1.classname = "qmissile";
   makevectors (self.v_angle);
   missile1.velocity = aim (self,1000.000);
   missile1.velocity = (missile1.velocity * 1000.000);
   missile1.angles = vectoangles (missile1.velocity);
   missile1.touch = T_MissileTouch;
   missile1.nextthink = (time + MOVETYPE_FLY);
   missile1.think = SUB_Remove;
   setmodel (missile1,"progs/missile.mdl");
   setsize (missile1,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile1,(self.origin + '0.000 0.000 16.000' + (v_right * 16.0)));

   missile2.owner = self;
   missile2.movetype = MOVETYPE_FLYMISSILE;
   missile2.solid = SOLID_BBOX;
   missile2.classname = "qmissile";
   missile2.velocity = aim (self,1000.000);
   missile2.velocity = (missile2.velocity * 1000.000);
   missile2.angles = vectoangles (missile2.velocity);
   missile2.touch = T_MissileTouch;
   missile2.nextthink = (time + MOVETYPE_FLY);
   missile2.think = SUB_Remove;
   setmodel (missile2,"progs/missile.mdl");
   setsize (missile2,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile2,(self.origin + '0.000 0.000 16.000' + (v_right * -16.0)));

};

void()   HomeThink;
entity() HomeFindTarget;
float(entity targ) visible;
float(entity targ) infront;

entity() HomeFindTarget = 
{
	local entity head, selected;
	local float dist;
	dist = 100000;
	selected = world;
	head = findradius(self.origin, 100000);
	while(head)
	{
		if( (head.health > 1) && (head != self) && (head != self.owner) )
		{
			traceline(self.origin,head.origin,TRUE,self);
			if ( (trace_fraction >= 1) && (vlen(head.origin - self.origin) < dist) )
			{
				selected = head;
				dist = vlen(head.origin - self.origin);
			}
		}		
		head = head.chain;
	}
//don't need homing messages for alien quake
/*
	if ((selected != world) && (self.classname != "super_laser"))
	{
		sprint (self.owner,"Homing->");
		if (selected.classname == "player")
		{
			sprint (self.owner,selected.netname);
			sprint (selected,self.owner.netname);
			sprint (selected," has a bogey on you!\n");
		}
		else
			sprint (self.owner,selected.classname);
		sprint (self.owner,"\n");
	}
	*/
	return selected;
};

void() HomeThink =
{
	local vector dir; //, vtemp;

	if ( !(self.enemy) || (self.enemy == world) || (self.enemy.health < 1))
		self.enemy = HomeFindTarget();

	if ((self.enemy != world))// Arr.. don't be taken on da World!
	{
		//vtemp = self.enemy.origin + '0 0 10';
		//dir = normalize(vtemp - self.origin);
		dir = normalize(self.enemy.origin - self.origin);
                self.velocity = dir * 1000;
		self.angles = vectoangles(self.velocity);
	}

//      if (self.classname == "superlaser")
      	self.nextthink = time + 0.3;
  //    else
    //  	self.nextthink = time + 0.1;
      	
	self.think=HomeThink;
   
};

void() W_FireHomingRocket =
{
	local	entity missile, mpuff;

    if (deathmatch)
    {
      if (self.ammo_rockets < 5.0)
      {
         W_FireDualRockets();
         return;
      }
      self.currentammo = self.ammo_rockets = self.ammo_rockets - 5.0;
    }
    else
       self.currentammo = self.ammo_rockets = self.ammo_rockets - 1.0;

   sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
   self.punchangle_x = -2;

	missile = spawn ();
	missile.owner = self;
	missile.movetype = MOVETYPE_FLYMISSILE;
	missile.solid = SOLID_BBOX;
		
   // set missile speed	
   makevectors (self.v_angle);
   missile.velocity = aim(self, 1000);
   missile.classname = "hmissile";
   missile.velocity = missile.velocity * 1000;
   missile.angles = vectoangles(missile.velocity);
   missile.touch = T_MissileTouch;
   // set missile duration
   //        missile.nextthink = time + 150;
   //        missile.think = SUB_Remove;
   missile.nextthink = time + 0.2;
   missile.think = HomeThink;
   missile.enemy = world;
   setmodel (missile, "progs/missile.mdl");
   setsize (missile, '0 0 0', '0 0 0');	
	setorigin (missile, self.origin + v_forward*8 + '0 0 16');

};



void (vector p1, vector p2, entity from, float damage) LightningDamage = {

   local entity e1;
   local entity e2;
   local vector f;

   f = (p2 - p1);
   normalize (f);
   f_x = (FALSE - f_y);
   f_y = f_x;
   f_z = FALSE;
   f = (f * FL_INWATER);
   e2 = world;
   e1 = world;
   traceline (p1,p2,FALSE,self);
   if ( trace_ent.takedamage ) {

      particle (trace_endpos,'0.000 0.000 100.000',225.000,(damage * MOVETYPE_STEP));
      T_Damage (trace_ent,from,from,damage);
      if ( (self.classname == "player") ) {

         if ( (other.classname == "player") ) {

            trace_ent.velocity_z = (trace_ent.velocity_z + 400.000);

         }

      }

   }
   e1 = trace_ent;
   traceline ((p1 + f),(p2 + f),FALSE,self);
   if ( ((trace_ent != e1) && trace_ent.takedamage) ) {

      particle (trace_endpos,'0.000 0.000 100.000',225.000,(damage * MOVETYPE_STEP));
      T_Damage (trace_ent,from,from,damage);

   }
   e2 = trace_ent;
   traceline ((p1 - f),(p2 - f),FALSE,self);
   if ( (((trace_ent != e1) && (trace_ent != e2)) && trace_ent.takedamage) ) {

      particle (trace_endpos,'0.000 0.000 100.000',225.000,(damage * MOVETYPE_STEP));
      T_Damage (trace_ent,from,from,damage);

   }

};

void () W_FireLightning = {

   local vector org;
   local float cells;

   if ( (self.ammo_cells < TRUE) ) {

      self.weapon = W_BestWeapon ();
      W_SetCurrentAmmo ();
      return ;

   }
   if ( (self.waterlevel > TRUE) ) {

		if (self.classname == "monster_enforcer")
		{
	      T_RadiusDamage (self,self,(350),world);
	      return;
		}
		
      cells = self.ammo_cells;
      self.ammo_cells = FALSE;
      W_SetCurrentAmmo ();
      T_RadiusDamage (self,self,(35.000 * cells),world);
      return ;

   }
   if ( (self.t_width < time) ) {

         sound (self,CHAN_WEAPON,"weapons/lhit.wav",TRUE,ATTN_NORM);
      self.t_width = (time + 0.600);

   }
   self.punchangle_x = CONTENT_SOLID;
   self.ammo_cells = (self.ammo_cells - TRUE);
   self.currentammo = (self.ammo_cells - TRUE);
   org = (self.origin + '0.000 0.000 16.000');

      traceline (org,(org + (v_forward * 600.000)),TRUE,self);

   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_LIGHTNING2);
   WriteEntity (MSG_BROADCAST,self);
   WriteCoord (MSG_BROADCAST,org_x);
   WriteCoord (MSG_BROADCAST,org_y);
   WriteCoord (MSG_BROADCAST,org_z);
   WriteCoord (MSG_BROADCAST,trace_endpos_x);
   WriteCoord (MSG_BROADCAST,trace_endpos_y);
   WriteCoord (MSG_BROADCAST,trace_endpos_z);
   LightningDamage (self.origin,(trace_endpos + (v_forward * MOVETYPE_STEP)),self,30);

};

void () GrenadeExplode = {

   T_RadiusDamage (self,self.owner,120.000,world);
   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_EXPLOSION);
   WriteCoord (MSG_BROADCAST,self.origin_x);
   WriteCoord (MSG_BROADCAST,self.origin_y);
   WriteCoord (MSG_BROADCAST,self.origin_z);
   BecomeExplosion ();

};

void () GrenadeTouch = {

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (other.takedamage == DAMAGE_AIM) ) {

      GrenadeExplode ();
      return ;

   }
   sound (self,CHAN_WEAPON,"weapons/bounce.wav",TRUE,ATTN_NORM);
   if ( (self.velocity == VEC_ORIGIN) ) {

      self.avelocity = VEC_ORIGIN;

   }

};

void () W_FireGrenade = {

   local entity missile;
   local entity mpuff;

   self.ammo_rockets = (self.ammo_rockets - TRUE);
   self.currentammo = (self.ammo_rockets - TRUE);
      sound (self,CHAN_WEAPON,"weapons/grenade.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   //missile.movetype = MOVETYPE_BOUNCE;
   missile.movetype = MOVETYPE_TOSS;
   missile.solid = SOLID_BBOX;
   missile.classname = "grenade";
   makevectors (self.v_angle);
/*
   if ( self.v_angle_x ) {

      missile.velocity = ((((v_forward * 600.000) + (v_up * 200.000)) + ((crandom () * v_right) * MOVETYPE_BOUNCE)) + ((crandom () * v_up) * MOVETYPE_BOUNCE));

   } else {

      missile.velocity = aim (self,10000.000);
      missile.velocity = (missile.velocity * 600.000);
      missile.velocity_z = 200.000;

   }
*/
//   if ( self.v_angle_x ) {

      missile.velocity = ((((v_forward * 800.000) + (v_up * 200.000)) + ((crandom () * v_right) * MOVETYPE_BOUNCE)) + ((crandom () * v_up) * MOVETYPE_BOUNCE));

  /*
 } else {

      missile.velocity = aim (self,10000.000);
      missile.velocity = (missile.velocity * 600.000);
      missile.velocity_z = 200.000;

   }
*/
   missile.avelocity = '300.000 300.000 300.000';
   missile.angles = vectoangles (missile.velocity);
   missile.touch = GrenadeTouch;
   missile.nextthink = (time + 2.500);
   missile.think = GrenadeExplode;
   setmodel (missile,"progs/grenade.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,self.origin);

};




void () W_FireDoubleGrenade = {

   local entity missile1,missile2;
   local entity mpuff;
   
   if (self.ammo_rockets < 2)
   {
   W_FireGrenade ();
   return;
   }

   self.ammo_rockets = (self.ammo_rockets - 2.0);
   self.currentammo = (self.ammo_rockets - 2.0);
      sound (self,CHAN_WEAPON,"weapons/grenade.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile1 = spawn ();
   missile2 = spawn ();
   missile1.owner = self;
   missile2.owner = self;
   
   missile1.movetype = MOVETYPE_BOUNCE;
   missile1.solid = SOLID_BBOX;
   missile1.classname = "grenade";
   
   missile2.movetype = MOVETYPE_BOUNCE;
   missile2.solid = SOLID_BBOX;
   missile2.classname = "grenade";
   makevectors (self.v_angle);
   if ( self.v_angle_x ) {

      missile1.velocity = ((((v_forward * 600.000) + (v_up * 200.000)) + ((crandom () * v_right) * MOVETYPE_BOUNCE)) + ((crandom () * v_up) * MOVETYPE_BOUNCE));
      missile2.velocity = ((((v_forward * 600.000) + (v_up * 200.000)) + ((crandom () * v_right) * MOVETYPE_BOUNCE)) + ((crandom () * v_up) * MOVETYPE_BOUNCE));


   } else {

      missile1.velocity = aim (self,10000.000);
      missile1.velocity = (missile1.velocity * 600.000);
      missile1.velocity_z = 200.000;
      
      missile2.velocity = aim (self,10000.000);
      missile2.velocity = (missile2.velocity * 600.000);
      missile2.velocity_z = 200.000;

   }
   missile1.avelocity = '300.000 300.000 300.000';
   missile1.angles = vectoangles (missile1.velocity);
   missile1.touch = GrenadeTouch;
   missile1.nextthink = (time + 2.500);
   missile1.think = GrenadeExplode;

   missile2.avelocity = '300.000 300.000 300.000';
   missile2.angles = vectoangles (missile2.velocity);
   missile2.touch = GrenadeTouch;
   missile2.nextthink = (time + 2.500);
   missile2.think = GrenadeExplode;
   setmodel (missile1,"progs/grenade.mdl");
   setsize (missile1,VEC_ORIGIN,VEC_ORIGIN);
   setorigin(missile1,( (self.origin + '0.000 0.000 16.000') + (v_right * 8.0) ) );

   setmodel (missile2,"progs/grenade.mdl");
   setsize (missile2,VEC_ORIGIN,VEC_ORIGIN);
   setorigin(missile2,( (self.origin + '0.000 0.000 16.000') + (v_right * -8.0) ) );

};

void () ProxExplode = {

   local float damg;

   damg = (100.000 + (random () * 20.000));
   if ( other.health ) {

      if ( (other.classname == "monster_shambler") ) {

         damg = (damg * 1.200);

      }
      T_Damage (other,self,self.owner,damg);

   }
	if (self.classname == "proxmine") //keep track of the total number of proxmines
		totalprox = totalprox - 1;
   T_RadiusDamage (self,self.owner,120,world);
   self.origin = (self.origin - (FL_CLIENT * normalize (self.velocity)));
   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_EXPLOSION);
   WriteCoord (MSG_BROADCAST,self.origin_x);
   WriteCoord (MSG_BROADCAST,self.origin_y);
   WriteCoord (MSG_BROADCAST,self.origin_z);
   BecomeExplosion ();

};

void () ProxThink = {

   local entity rtarget;

   self.nextthink = (time + 0.100);
   self.think = ProxThink;
   rtarget = findradius (self.origin,150.000);
   while ( rtarget )
   {

      if (rtarget != self)
      {

         if (rtarget.classname == "proxmine")
         {
            sound (self,CHAN_AUTO,"beep.wav",WEAPON_SHOTGUN,ATTN_NORM);
            ProxExplode ();
            return ;
         }
			
			
         if (rtarget.takedamage)
         {
            sound (self,CHAN_AUTO,"beep.wav",WEAPON_SHOTGUN,ATTN_NORM);
            ProxExplode ();
            return ;
         }

      }
      rtarget = rtarget.chain;

   }
   
};

void () ProxTouch = {

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   if (other.takedamage == DAMAGE_AIM) {

      ProxExplode ();
      return ;

   }

   sound (self,CHAN_WEAPON,"catch.wav",WEAPON_SHOTGUN,ATTN_NORM);
   self.velocity = VEC_ORIGIN;
   self.avelocity = VEC_ORIGIN;
   self.think = ProxThink;
   self.nextthink = time;
   self.touch = SUB_Null;
   self.health = TE_LAVASPLASH;
   self.takedamage = DAMAGE_AIM;
   self.th_die = ProxExplode;

};

void () W_FireProx = {

   local entity missile;
   local entity mpuff;

	if (totalprox > 9) //can't have too many of these things around
	{
		centerprint(self,"too many active\nproximinity mines.\nfiring grenade\n");
		W_FireGrenade();
		totalprox = 0;
		return;
	}

	totalprox = totalprox + 1;

	if (self.ammo_rockets < 2)
		W_FireGrenade();
		
   self.ammo_rockets = (self.ammo_rockets - 2.0);
   self.currentammo = (self.ammo_rockets - 2.0);
      sound (self,CHAN_WEAPON,"weapons/sgun1.wav",WEAPON_SHOTGUN,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.classname = "proxmine";
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   makevectors (self.v_angle);
   missile.velocity = aim (self,1000.000);
   missile.velocity = (missile.velocity * 1000.000);
   missile.angles = vectoangles (missile.velocity);
   missile.touch = ProxTouch;
   missile.nextthink = (time + WEAPON_SHOTGUN);
   missile.think = ProxExplode;
   setmodel (missile,"progs/grenade.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * WEAPON_BIG)) + '0.000 0.000 16.000'));

};


void () FlareTouch = {

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   sound (self,CHAN_WEAPON,"catch.wav",WEAPON_SHOTGUN,ATTN_NORM);
   self.velocity = VEC_ORIGIN;
   self.avelocity = VEC_ORIGIN;
   self.think = SUB_Remove;
   self.nextthink = time + 15;	//they last 15 seconds
   self.touch = SUB_Null;
   self.health = TE_LAVASPLASH;
   self.takedamage = DAMAGE_AIM;
   self.th_die = SUB_Remove;

};


void () FireFlare = {

   local entity missile;
   local entity mpuff;

   sound (self,CHAN_WEAPON,"weapons/spike2.wav",WEAPON_SHOTGUN,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.classname = "flare";
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   missile.effects = missile.effects | EF_BRIGHTLIGHT;
   makevectors (self.v_angle);
   missile.velocity = aim (self,1000.000);
   missile.velocity = (missile.velocity * 1000.000);
   missile.angles = vectoangles (missile.velocity);
   missile.touch = FlareTouch;
   missile.nextthink = (time + 15);
   missile.think = SUB_Remove;
   setmodel (missile,"progs/laser.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * WEAPON_BIG)) + '0.000 0.000 16.000'));

};

void () spike_touch;

void () superspike_touch;

void (vector org, vector dir) launch_spike = {

   newmis = spawn ();
   newmis.owner = self;
   newmis.movetype = MOVETYPE_FLYMISSILE;
   newmis.solid = SOLID_BBOX;
   newmis.angles = vectoangles (dir);
   newmis.touch = spike_touch;
   newmis.classname = "spike";
   setmodel (newmis,"progs/spike.mdl");
   newmis.think = SUB_Remove;
   newmis.nextthink = (time + MOVETYPE_TOSS);
   setsize (newmis,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (newmis,org);
   newmis.velocity = (dir * 1000.000);

};

void () W_FireSuperSpikes = {

   local vector dir;
   local entity old;

      sound (self,CHAN_WEAPON,"weapons/spike2.wav",TRUE,ATTN_NORM);
   self.attack_finished = (time + 0.200);
   self.ammo_nails = (self.ammo_nails - 1.0);
   self.currentammo = (self.ammo_nails - 1.0);
   dir = aim (self,1000.000);
   launch_spike ((self.origin + '0.000 0.000 16.000'),dir);
   newmis.touch = superspike_touch;
   setmodel (newmis,"progs/s_spike.mdl");
   setsize (newmis,VEC_ORIGIN,VEC_ORIGIN);
   self.punchangle_x = CONTENT_SOLID;

};

void () SuperLaserTouch = {

   local vector org;

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   sound (self,CHAN_WEAPON,"enforcer/enfstop.wav",TRUE,ATTN_STATIC);
   org = (self.origin - (FL_CLIENT * normalize (self.velocity)));
   if ( other.health ) {

	if (trace_ent.classname != "player")
      SpawnAlienBlood (org,(self.velocity * 0.200),15.000);
	else
      SpawnBlood (org,(self.velocity * 0.200),15.000);

	if (other.health < 20)
      T_Damage (other,self,self.owner,90.000);
	else
      T_Damage (other,self,self.owner,18.000);

   } else {

      WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
      WriteByte (MSG_BROADCAST,TE_GUNSHOT);
      WriteCoord (MSG_BROADCAST,org_x);
      WriteCoord (MSG_BROADCAST,org_y);
      WriteCoord (MSG_BROADCAST,org_z);

   }
   remove (self);

};

void () W_FireSuperLaser = {

   local vector dir;
   local entity old;

   sound (self,CHAN_WEAPON,"enforcer/enfire.wav",TRUE,ATTN_NORM);
   self.attack_finished = (time + 0.200);
   self.ammo_nails = (self.ammo_nails - 2);
   self.currentammo = (self.ammo_nails - 2);
   dir = aim (self,1000.000);
   launch_spike ((self.origin + '0.000 0.000 16.000'),dir);
   newmis.touch = SuperLaserTouch;
   newmis.classname = "superlaser";
   newmis.effects = EF_DIMLIGHT;
   setmodel (newmis,"progs/laser.mdl");
   setsize (newmis,VEC_ORIGIN,VEC_ORIGIN);
   self.punchangle_x = CONTENT_SOLID;
   newmis.angles = vectoangles(newmis.velocity);
   newmis.nextthink = time + 0.2;
   newmis.think = HomeThink;
   newmis.enemy = world;

};

void (float ox) W_FireSpikes = {

   local vector dir;
   local entity old;

   makevectors (self.v_angle);
   if ( ((self.ammo_nails >= FL_SWIM) && (self.weapon == IT_SUPER_NAILGUN)) ) {

         W_FireSuperLaser ();
         return ;
   }
   
   if ( (self.ammo_nails < TRUE) ) {

      self.weapon = W_BestWeapon ();
      W_SetCurrentAmmo ();
      return ;

   }
   self.attack_finished = (time + 0.200);
   dir = aim (self,1000.000);
      launch_spike (((self.origin + '0.000 0.000 16.000') + (v_right * ox)),dir);
      self.ammo_nails = (self.ammo_nails - 0.25);
      self.currentammo = (self.ammo_nails - 0.25);
      sound (self,CHAN_WEAPON,"weapons/rocket1i.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;

};

//.float hit_z;

void () spike_touch = {

   local float rand;

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (other.solid == SOLID_TRIGGER) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   if ( other.takedamage ) {

      spawn_touchblood (MOVETYPE_FLYMISSILE);
      T_Damage (other,self,self.owner,MOVETYPE_FLYMISSILE);

   } else {

      WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
      if ( (self.classname == "wizspike") ) {

         WriteByte (MSG_BROADCAST,TE_WIZSPIKE);

      } else {

         if ( (self.classname == "knightspike") ) {

            WriteByte (MSG_BROADCAST,TE_KNIGHTSPIKE);

         } else {

            WriteByte (MSG_BROADCAST,TE_SPIKE);

         }

      }
      WriteCoord (MSG_BROADCAST,self.origin_x);
      WriteCoord (MSG_BROADCAST,self.origin_y);
      WriteCoord (MSG_BROADCAST,self.origin_z);

   }
   remove (self);

};

void () superspike_touch = {

   local float rand;

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (other.solid == SOLID_TRIGGER) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   if ( other.takedamage ) {

      spawn_touchblood (18.000);
      T_Damage (other,self,self.owner,18.000);

   } else {

      WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
      WriteByte (MSG_BROADCAST,TE_SUPERSPIKE);
      WriteCoord (MSG_BROADCAST,self.origin_x);
      WriteCoord (MSG_BROADCAST,self.origin_y);
      WriteCoord (MSG_BROADCAST,self.origin_z);

   }
   remove (self);

};

void () W_SetCurrentAmmo = {

	//here is where you determine what model you see when you select your
	//new weapon

   player_run ();
   self.items = (self.items - (self.items & (((IT_SHELLS | IT_NAILS) | IT_ROCKETS) | IT_CELLS)));
   if ( (self.weapon == IT_AXE) ) {

      	self.currentammo = FALSE;
	      self.weaponmodel = "progs/v_axe.mdl";
   	   self.weaponframe = FALSE;

   } else {

      if ( (self.weapon == IT_SHOTGUN) ) {

   	      //self.weaponmodel = "progs/v_shot.mdl";
         self.weaponmodel = "progs/v_mk23.mdl";

         self.currentammo = self.ammo_shells;
     	   self.weaponframe = FALSE;
        	self.items = (self.items | IT_SHELLS);

      } else {

         if ( (self.weapon == IT_SUPER_SHOTGUN) ) {
				if (self.supershotguntype == 2)
	            self.weaponmodel = "progs/v_shot2.mdl";
	         else if(self.supershotguntype == 0)
	         	self.weaponmodel = "progs/v_nshot.mdl";
	         else
   	         self.weaponmodel = "progs/v_erifle.mdl";

				self.currentammo = self.ammo_shells;
            self.weaponframe = 0.000;
            self.items = (self.items | IT_SHELLS);

         } else {

            if ( (self.weapon == IT_NAILGUN) ) {

		if (self.nailguntype == 0)
	               self.weaponmodel = "progs/v_nail2.mdl";
		else
	               self.weaponmodel = "progs/v_rock.mdl";

               self.currentammo = self.ammo_nails;
               self.weaponframe = FALSE;
               self.items = (self.items | IT_NAILS);

            } else {

               if ( (self.weapon == IT_SUPER_NAILGUN) ) {

                  if ((self.supernailguntype == 0) || (self.supernailguntype == 1))
                     self.weaponmodel = "progs/v_hcg.mdl";
                  else
	                  self.weaponmodel = "progs/v_nail2.mdl";

                  self.currentammo = self.ammo_nails;
                  self.weaponframe = FALSE;
                  self.items = (self.items | IT_NAILS);

               } else {

                  if ( (self.weapon == IT_GRENADE_LAUNCHER) ) {

                     self.weaponmodel = "progs/v_rock.mdl";
                     self.currentammo = self.ammo_rockets;
                     self.weaponframe = FALSE;
                     self.items = (self.items | IT_ROCKETS);


                  } else {

                     if ( (self.weapon == IT_ROCKET_LAUNCHER) ) {
                        self.weaponmodel = "progs/v_rock2.mdl";
                        self.currentammo = self.ammo_rockets;
                        self.weaponframe = FALSE;
                        self.items = (self.items | IT_ROCKETS);

                     } else {

                        if ( (self.weapon == IT_LIGHTNING) )
                        {
                           if (self.cellguntype == 0)
	                           self.weaponmodel = "progs/v_plasma.mdl";
                           else
	                           self.weaponmodel = "progs/v_pstorm.mdl";

                           self.currentammo = self.ammo_cells;
                           self.weaponframe = FALSE;
                           self.items = (self.items | IT_CELLS);

                        } else {

                           self.currentammo = FALSE;
                           self.weaponmodel = "";
                           self.weaponframe = FALSE;

                        }

                     }

                  }

               }

            }

         }

      }

   }
	// disable model in chase view
	if ((self.dest2_x & CHSCAM_ON))
		self.weaponmodel = "";

	/*
	if ((self.weapon == IT_SUPER_SHOTGUN) && (self.supershotguntype == 3))
		self.view_ofs = '0.000 0.000 22.000';
	else
		self.view_ofs = '0.000 0.000 22.000';
	*/
	

};

float () W_BestWeapon = {

   local float it;

   it = self.items;
   
   
   if ( (((self.waterlevel <= TRUE) && (self.ammo_cells >= TRUE)) && (it & IT_LIGHTNING)) ) {

      return ( IT_LIGHTNING );

   }
   if ( ((self.ammo_nails >= FL_SWIM) && (it & IT_SUPER_NAILGUN)) ) {

      return ( IT_SUPER_NAILGUN );

   }
   if ( ((self.ammo_shells >= FL_SWIM) && (it & IT_SUPER_SHOTGUN)) ) {

      return ( IT_SUPER_SHOTGUN );

   }
   if ( ((self.ammo_nails >= TRUE) && (it & IT_NAILGUN)) ) {

      return ( IT_NAILGUN );

   }
   if ( ((self.ammo_shells >= TRUE) && (it & IT_SHOTGUN)) ) {

      return ( IT_SHOTGUN );

   }
   return ( IT_AXE );

};

float () W_CheckNoAmmo = {

   if ( (self.currentammo > FALSE) ) {

      return ( TRUE );

   }
   if ( (self.weapon == IT_AXE) ) {

      return ( TRUE );

   }

   if ((self.weapon == IT_SUPER_NAILGUN) && (self.supernailguntype == 0)) {

      return ( TRUE );

   }

   self.weapon = W_BestWeapon ();
   W_SetCurrentAmmo ();
   return ( FALSE );

};

/*
if the animations or new weapon firing code is declared after this file is compiled
(check progs.src) you must declare the function here so Quake knows its here somewhere
*/

void () player_axe1;

void () player_axeb1;

void () player_axec1;

void () player_axed1;

void () player_shot1;

void () player_nail1;
void () player_flame1;

void () player_light1;

void () player_rocket1;

void () W_FireDukeNuke;
void () mk23_reload;

void () W_Attack = {


	/*
	this function is where you add the code that fires the new weapon
	*/

   local float r;

   if ( !W_CheckNoAmmo () ) {

      return ;

   }
   makevectors (self.v_angle);
   self.show_hostile = (time + TRUE);
   if ( (self.weapon == IT_AXE) ) {
   
   if (self.axetype == 0)
   {
      sound (self,CHAN_WEAPON,"weapons/ax1.wav",TRUE,ATTN_NORM);
      self.attack_finished = (time + 0.300);
   }
   else
   {
		W_ThrowAxe();
		self.attack_finished = time + 0.6;
	}



      r = random ();
      if (r < 0.250)
			player_axe1 ();
		else if (r < 0.500)
         player_axeb1 ();
		else	if (r < 0.750)
			player_axec1 ();
		else
      	player_axed1 ();

   } else {

      if (self.weapon == IT_SHOTGUN)
      {
					//player_shot1 ();
					//W_FireShotgun ();
					if (self.bondo == 12)
					{
						self.attack_finished = time + 1.5;
						sprint(self,"reloading...\n");
						mk23_reload();
						self.bondo = 0;
					}
					else{
					player_mk23a ();
						self.attack_finished = time + 0.3;
					}
         self.currentammo = self.ammo_shells;

      } else {

         if ( (self.weapon == IT_SUPER_SHOTGUN) ) {
			{         
				if ((self.supershotguntype == 0))
				{

            player_mossberg ();
            self.attack_finished = time + 0.6;

/*

	             if (self.bondoflag & B_ERIFLEUNLOADED)
	             {
	                  player_shotb1 ();
	                  self.bondoflag = self.bondoflag - B_ERIFLEUNLOADED;
	             }
	             else
	             {
                  	player_shota1 ();
	                  self.bondoflag = self.bondoflag | B_ERIFLEUNLOADED;
	             }
*/
				}
				else if (self.supershotguntype == 1)
				{
					if ((self.bondoflag & B_ERIFLEUNLOADED))
					{
						player_shotb1();
                  self.bondoflag = self.bondoflag - B_ERIFLEUNLOADED;
					}
					else
					{
						player_shote1();
					}
				}
				else
				{
	            player_shot1 ();
   	         W_FireSuperShotgun ();
					if (self.bondo == 8)
					{
						self.attack_finished = time + 1.5;
						self.bondo = 0;
					}
					else
						self.attack_finished = time + 0.3;
	      	}


			}
            self.currentammo = self.ammo_shells;
         } else {

            if ( (self.weapon == IT_NAILGUN) ) {

      	             if (self.nailguntype == 0)
			player_nail1();
			else
			player_flame1 ();


            } else {

               if ( (self.weapon == IT_SUPER_NAILGUN) ) {

					{
						if ((self.supernailguntype == 0) || (self.supernailguntype == 1))
                  {
                  
                  if ( (self.ammo_nails < 2.000) )
                  {

                     if ( !(self.bondoflag & B_CHAINGUN) )
                     {

                        player_cgunb1 ();

                     }
                     else
                     {

                        if ( (self.bondoflag & B_CHAINGUN) )
                        {

                           player_cgunc1 ();
                           if ( (self.t_width < time) )
                           {

                              sound (self,CHAN_WEAPON,"chaingun/engine2.wav",1.000,ATTN_NORM);
                              self.t_width = (time + 1.000);

                           }

                        }

                     }

                  } 
                  else
                  {

                     if ( !(self.bondoflag & B_CHAINGUN) ) {

                        player_cgun1 ();

                     } else {

                        if ( (self.bondoflag & B_CHAINGUN) ) {

                           player_cguna1 ();
                           if ( (self.t_width < time) ) {

                              sound (self,CHAN_WEAPON,"chaingun/engine2.wav",1.000,ATTN_NORM);
                              self.t_width = (time + 1.000);

                           }

                        }

                     }

                  }
                  }
                  else
							player_nail1 ();
			
					}
                  
               } else {

                  if ( (self.weapon == IT_GRENADE_LAUNCHER) ) {

						if (self.grenadetype == 0)
                     {
	                     player_rocket1 ();					//this is the animation the player will use when
	                     											//when he fires the rocket. this is used for nearly all 
	                     											//the rocket weapons. if you don't call this, the player will
	                     											//stand still while a projectile mysteriously comes out
	                     											//his gut
   	                  W_FireGrenade ();						//this is the function declared somewhere else that
   	                  											//actually creates the rocket and fires it. or fires the
   	                  											//shotgun or whatever
      	               self.attack_finished = (time + 0.600);	//you must enter attack_finished time. higher numbers
      	               													//mean longer reload times
                     }
                     else if (self.grenadetype == 1)
                     {
                        player_rocket1 ();
                        W_FireProx ();
                        self.attack_finished = (time + 0.900);
                     }
                     else
                     {
                        player_rocket1 ();
                        W_FirePDS ();
                        self.attack_finished = (time + 1.800);
                     }
						
                     self.currentammo = self.ammo_rockets;

                  } else {
                     if ( (self.weapon == IT_ROCKET_LAUNCHER) ) {
							{
                        if (self.rockettype == 0) 
                        {
         	               player_rocket1 ();
            	            W_FireRocket ();
               	         self.attack_finished = (time + 0.600);
                        }
                        else
                        {
         	               player_rocket1 ();
                           W_FireDukeNuke2();
                           self.attack_finished = (time + 1.800);
                        }
					       }
                        self.currentammo = self.ammo_rockets;


                     } else {

                        if ( (self.weapon == IT_LIGHTNING) )
                        {
		{
                           if (self.cellguntype == 0)
                           {
	                           player_shot1();
   	                        W_FirePlasma();
      	                     self.attack_finished = (time + 0.050);
                           }
                           else
                           {
	                           W_Fire_Storm ();
                           }

                    			self.currentammo = self.ammo_cells;     




                        }

                     }

                  }

               }

            }

         }

      }
}}

};

void () W_ChangeWeapon = {


/*
here is where you determine how to select the new weapon
*/

   local float it;
   local float am;
   local float fl;
   local string msg;

   it = self.items;
   am = FALSE;
	

{
{
{
   if ( (self.impulse == TRUE) ) {

      fl = IT_AXE;
	if (self.weapon == IT_AXE)
	{
		if (self.axetype == 0)
			self.axetype = 1;
		else
			self.axetype = 0;

	}
            if (self.axetype == 0)
               msg = "axe\n";
            else if (self.axetype == 1)
	            msg = "throwing axe\n";


   } else {

      if ( (self.impulse == FL_SWIM) ) {

         fl = IT_SHOTGUN;
         if ( (self.ammo_shells < TRUE) ) {

            am = TRUE;

         }
               msg = "MK23\n";



      } else {

         if ( (self.impulse == MOVETYPE_WALK) ) {

            fl = IT_SUPER_SHOTGUN;
            if ( (self.ammo_shells < FL_SWIM) ) {

               am = TRUE;

            }

            if (self.weapon == IT_SUPER_SHOTGUN)
            {
	               if (self.supershotguntype == 2)
   	               self.supershotguntype = 0;
      	         else
         	         self.supershotguntype = self.supershotguntype + 1;
            }
               if (self.supershotguntype < 2)
               	msg = "the Jedediah\n";
               else
                  msg = "superduper shotgun\n";


         } else {

            if ( (self.impulse == MOVETYPE_STEP) ) {

               fl = IT_NAILGUN;
               if ( (self.ammo_nails < TRUE) ) {

                  am = TRUE;

               }

            if (self.weapon == IT_NAILGUN)
            {
	               if (self.nailguntype == 1)
   	               self.nailguntype = 0;
      	         else
         	         self.nailguntype = 1;
            }
               if (self.nailguntype == 0)
               	msg = "blazegun\n";
               else
                  msg = "flamethrower\n";

            } else {

               if ( (self.impulse == MOVETYPE_FLY) ) {

                  fl = IT_SUPER_NAILGUN;
                  if ( (self.ammo_nails < 1) ) {

                     am = TRUE;
                     //self.supernailguntype = 0;

                  }
                  
               if (self.weapon == IT_SUPER_NAILGUN)
               {
	                  if (self.supernailguntype == 2)
   	                  self.supernailguntype = 0;
      	            else
         	            self.supernailguntype = self.supernailguntype + 1;
               }
               
               if (self.supernailguntype == 0)
                  msg = "heavy chaingun\n";
               else if (self.supernailguntype == 1)
                  msg = "explosive shells\n";
               else
                  msg = "smartgun\n";
                  
                  if (self.ammo_nails < 2)
                  {
                  	self.supernailguntype = 0; //switch to heavy chaingun if no ammo
                  	msg = "heavy chaingun\n";
                  	W_SetCurrentAmmo();
                  	return;
                  }
                  

               } else {

                  if ( (self.impulse == MOVETYPE_TOSS) ) {

                     fl = IT_GRENADE_LAUNCHER;
                     if ( (self.ammo_rockets < TRUE) ) {

                        am = TRUE;

                     }
            if (self.weapon == IT_GRENADE_LAUNCHER)
            {
                  if (self.grenadetype == 2)
                     self.grenadetype = 0;
                  else
                     self.grenadetype = self.grenadetype + 1;
            }

               if (self.grenadetype == 0)
                  msg = "grenade launcher\n";
               else if (self.grenadetype == 1)
                  msg = "proximity mine\n";
               else
                  msg = "point defense system\n";

                     

                  } else {

                     if ( (self.impulse == MOVETYPE_PUSH) ) {

                        fl = IT_ROCKET_LAUNCHER;
                        if ( (self.ammo_rockets < TRUE) ) {

                           am = TRUE;

                        }
                        
            if (self.weapon == IT_ROCKET_LAUNCHER)
            {
	               if (self.rockettype == 0)
   	               self.rockettype = 1;
      	         else
         	         self.rockettype = 0;
            }

               if (self.rockettype == 0)
                  msg = "rocket launcher\n";
               else
                  msg = "thermonuclear missile\n";
                        

                     } else {

                        if ( (self.impulse == FL_CLIENT) ) {

                           fl = IT_LIGHTNING;
                           if ( (self.ammo_cells < TRUE) )
                           {

                              am = TRUE;

                           }
 
                           if (self.weapon == IT_LIGHTNING)
                           {
                                 if (self.cellguntype == 0)
                                    self.cellguntype = 1;
                                 else
                                    self.cellguntype = 0;
                           }

                           if (self.cellguntype == 0)
                              msg = "plasma cannon\n";
                           else
                              msg = "proton storm\n";
                           

                        }

                     }

                  }

               }

            }

         }

      }

   }
}
}
}
   self.impulse = FALSE;
   if ( !(self.items & fl) ) {

      sprint (self,"no weapon.\n");
      return ;

   }
   if ( am ) {

      sprint (self,"not enough ammo.\n");
      return ;

   }
   self.weapon = fl;
   W_SetCurrentAmmo ();
	sprint(self,msg);
   //WeaponSelect ();

	
};

void () CheatCommand = {

   if ( (deathmatch)) {

      return ;

   }
   self.ammo_rockets = 200.000;
   self.ammo_nails = 200.000;
   self.ammo_shells = 200.000;
   self.items = ((((((((self.items | IT_AXE) | IT_SHOTGUN) | IT_SUPER_SHOTGUN) | IT_NAILGUN) | IT_SUPER_NAILGUN) | IT_GRENADE_LAUNCHER) | IT_ROCKET_LAUNCHER) | IT_ARMOR3);
   self.ammo_cells = 200.000;
   self.items = (self.items | IT_LIGHTNING);
   //self.weapon = IT_LIGHTNING;
   self.impulse = FALSE;
   self.armortype = 0.8;
   self.armorvalue = 200.0;
   self.health = 999.0;
   W_SetCurrentAmmo ();
   
};

void () CycleWeaponCommand = {

   local float it;
   local float am;
   local string msg;

   it = self.items;
   self.impulse = FALSE;
   while ( TRUE ) {

      am = FALSE;

{

      if ( (self.weapon == IT_LIGHTNING) ) {

         self.weapon = IT_AXE;
         
			if (self.axetype == 0)
	         msg = "axe\n";
	      else if (self.axetype == 1)
	         msg = "throwing axe\n";

      } else {

         if ( (self.weapon == IT_AXE) ) {

            self.weapon = IT_SHOTGUN;

               msg = "MK23\n";

            if ( (self.ammo_shells < TRUE) ) {

               am = TRUE;

            }

         } else {

            if ( (self.weapon == IT_SHOTGUN) ) {

               self.weapon = IT_SUPER_SHOTGUN;

               if (self.supershotguntype < 2)
               	msg = "the Jedediah\n";
               else
                  msg = "superduper shotgun\n";
                  
               if ( (self.ammo_shells < FL_SWIM) ) {

                  am = TRUE;

               }

            } else {

               if ( (self.weapon == IT_SUPER_SHOTGUN) ) {

                  self.weapon = IT_NAILGUN;

               if (self.nailguntype == 0)
               	msg = "blazegun\n";
               else
                  msg = "flamethrower\n";

                  if ( (self.ammo_nails < TRUE) ) {

                     am = TRUE;

                  }

               } else {

                  if ( (self.weapon == IT_NAILGUN) ) {

                     self.weapon = IT_SUPER_NAILGUN;

               if (self.supernailguntype == 0)
                  msg = "heavy chaingun\n";
               else if (self.supernailguntype == 1)
                  msg = "explosive shells\n";
               else
                  msg = "smartgun\n";

                     if ( (self.ammo_nails < FL_SWIM) ) {

                        am = TRUE;

                     }


                  } else {

                     if ( (self.weapon == IT_SUPER_NAILGUN) ) {

                        self.weapon = IT_GRENADE_LAUNCHER;

               if (self.grenadetype == 0)
                  msg = "grenade launcher\n";
               else if (self.grenadetype == 1)
                  msg = "proximity mine\n";
               else
                  msg = "point defense system\n";

                        if ( (self.ammo_rockets < TRUE) ) {

                           am = TRUE;

                        }

                     } else {

                        if ( (self.weapon == IT_GRENADE_LAUNCHER) ) {

                           self.weapon = IT_ROCKET_LAUNCHER;

               if (self.rockettype == 0)
                  msg = "rocket launcher\n";
               else
                  msg = "thermonuclear missile\n";

                           if ( (self.ammo_rockets < TRUE) ) {

                              am = TRUE;

                           }

                        } else {

                           if ( (self.weapon == IT_ROCKET_LAUNCHER) ) {

                              self.weapon = IT_LIGHTNING;

                           if (self.cellguntype == 0)
                              msg = "plasma cannon\n";
                           else
                              msg = "proton storm\n";


                              if ( (self.ammo_cells < TRUE) ) {

                                 am = TRUE;

                              }

                           }

                        }

                     }

                  }

               }

            }

         }

      }
 }
      if ( ((it & self.weapon) && (am == FALSE)) ) {

         W_SetCurrentAmmo ();
         //WeaponSelect();
         sprint(self,msg);
         return ;

      }

   }

};

void () CycleWeaponType = {

	local string msg;

{

if (self.weapon == IT_AXE)
{
	if (self.axetype == 0)
		self.axetype = 1;
	else
		self.axetype = 0;

	if (self.axetype == 0)
		msg = "axe\n";
	else if (self.axetype == 1)
		msg = "throwing axe\n";

}
else
if (self.weapon == IT_SHOTGUN)
{

               msg = "\n";



}
else if (self.weapon == IT_SUPER_SHOTGUN)
{

	               if (self.supershotguntype == 2)
   	               self.supershotguntype = 0;
      	         else
         	         self.supershotguntype = self.supershotguntype + 1;

               if (self.supershotguntype < 2)
               	msg = "the Jedediah\n";
               else
                  msg = "superduper shotgun\n";

}
else if (self.weapon == IT_NAILGUN)
{

	               if (self.nailguntype == 1)
   	               self.nailguntype = 0;
      	         else
         	         self.nailguntype = 1;
               if (self.nailguntype == 0)
               	msg = "blazegun\n";
               else
                  msg = "flamethrower\n";
		}
else if (self.weapon == IT_SUPER_NAILGUN)
{


	                  if (self.supernailguntype == 2)
   	                  self.supernailguntype = 0;
      	            else
         	            self.supernailguntype = self.supernailguntype + 1;

               if (self.supernailguntype == 0)
                  msg = "heavy chaingun\n";
               else if (self.supernailguntype == 1)
                  msg = "explosive shells\n";
               else
                  msg = "smartgun\n";


}
else if (self.weapon == IT_GRENADE_LAUNCHER)
{

                  if (self.grenadetype == 2)
                     self.grenadetype = 0;
                  else
                     self.grenadetype = self.grenadetype + 1;

               if (self.grenadetype == 0)
                  msg = "grenade launcher\n";
               else if (self.grenadetype == 1)
                  msg = "proximity mine\n";
               else
                  msg = "point defense system\n";

}
else if (self.weapon == IT_ROCKET_LAUNCHER)
{

	               if (self.rockettype == 0)
   	               self.rockettype = 1;
      	         else
         	         self.rockettype = 0;

               if (self.rockettype == 0)
                  msg = "rocket launcher\n";
               else
                  msg = "thermonuclear missile\n";

}
else
{
                           if (self.weapon == IT_LIGHTNING)
                           {
                                 if (self.cellguntype == 0)
                                    self.cellguntype = 1;
                                 else
                                    self.cellguntype = 0;
                           }

                           if (self.cellguntype == 0)
                              msg = "plasma cannon\n";
                           else
                              msg = "proton storm\n";
                   }
}
	sprint(self,msg);
	W_SetCurrentAmmo();
	//WeaponSelect();

};

void () CycleWeaponReverseCommand = {

   local float it;
   local float am;

   it = self.items;
   self.impulse = FALSE;
   while ( TRUE ) {

      am = FALSE;
      if ( (self.weapon == IT_LIGHTNING) ) {

         self.weapon = IT_ROCKET_LAUNCHER;
         if ( (self.ammo_rockets < TRUE) ) {

            am = TRUE;

         }

      } else {

         if ( (self.weapon == IT_ROCKET_LAUNCHER) ) {

            self.weapon = IT_GRENADE_LAUNCHER;
            if ( (self.ammo_rockets < TRUE) ) {

               am = TRUE;

            }

         } else {

            if ( (self.weapon == IT_GRENADE_LAUNCHER) ) {

               self.weapon = IT_SUPER_NAILGUN;
               if ( (self.ammo_nails < FL_SWIM) ) {

                  am = TRUE;

               }

            } else {

               if ( (self.weapon == IT_SUPER_NAILGUN) ) {

                  self.weapon = IT_NAILGUN;
                  if ( (self.ammo_nails < TRUE) ) {

                     am = TRUE;

                  }

               } else {

                  if ( (self.weapon == IT_NAILGUN) ) {

                     self.weapon = IT_SUPER_SHOTGUN;
                     if ( (self.ammo_shells < FL_SWIM) ) {

                        am = TRUE;

                     }

                  } else {

                     if ( (self.weapon == IT_SUPER_SHOTGUN) ) {

                        self.weapon = IT_SHOTGUN;
                        if ( (self.ammo_shells < TRUE) ) {

                           am = TRUE;

                        }

                     } else {

                        if ( (self.weapon == IT_SHOTGUN) ) {

                           self.weapon = IT_AXE;

                        } else {

                           if ( (self.weapon == IT_AXE) ) {

                              self.weapon = IT_LIGHTNING;
                              if ( (self.ammo_cells < TRUE) ) {

                                 am = TRUE;

                              }

                           }

                        }

                     }

                  }

               }

            }

         }

      }
      if ( ((it & self.weapon) && (am == FALSE)) ) {

         W_SetCurrentAmmo ();
         return ;

      }

   }

};

void () ServerflagsCommand = {

   serverflags = ((serverflags * FL_SWIM) + TRUE);

};

void () QuadCheat = {

   if ( (deathmatch || coop) ) {

      return ;

   }
   self.super_time = TRUE;
   self.super_damage_finished = (time + SVC_INTERMISSION);
   self.items = (self.items | IT_QUAD);
   dprint ("quad cheat\n");

};

void() MOTD;

void () ImpulseCommands = {

   if (self.impulse == 95)
      HomerTaunt(self);
   
   if (self.impulse == 96)
      FireFlare();

	//radar
   if ( (self.impulse == 110.000) ) {

      ToggleRadar ();

   }


	if (skill < 4)
	{
		if (self.impulse == 87)
			self.items = self.items | IT_KEY1 | IT_KEY2;

		if (self.impulse == 9)
      	CheatCommand ();

		if (self.impulse == 255.000) 
      	QuadCheat ();

	}

	
	   if ((self.impulse >= 1) && (self.impulse <= 8)) 
   	   W_ChangeWeapon ();
   	   
		if (self.impulse == 13.0)
			CycleWeaponType();
		
	   if (self.impulse == MOVETYPE_BOUNCE)
	      CycleWeaponCommand ();

   

	// Rob's chasecam
	if (self.impulse == 30) Toggle_chase_cam();
	if (self.impulse == 31) LaserTargeterToggle( self );

	else if (self.impulse == 32) Chase_cam_change_zmult(0); // minus
	else if (self.impulse == 33) Chase_cam_change_zmult(1); // plus
	else if (self.impulse == 34) Chase_cam_change_dist(0); // minus
	else if (self.impulse == 35) Chase_cam_change_dist(1); // plus

	else if (self.impulse == 38) Chase_cam_read_temp1(0); // read cvar temp1 into player.dest2_y (cam distance)
	else if (self.impulse == 39) Chase_cam_read_temp1(1); // read cvar temp1 into player.dest2_z (cam height)

   if ( (self.impulse == MOVETYPE_BOUNCEMISSILE) ) {

      ServerflagsCommand ();

   }
   if ( (self.impulse == 12.000) ) {

      CycleWeaponReverseCommand ();

   }

       //What's this server?
        if (self.impulse == 97)
        {
           self.motd_time = time;
           self.motd_count = 0;
        }
   
   self.impulse = FALSE;

};

void () W_WeaponFrame = {

	//radar
   if ( (self.impulse == 110.000) ) {

      ImpulseCommands ();

   }

	if ( (time < self.attack_finished) ) {

      return ;

   }

	ImpulseCommands ();
   if ( self.button0 ) {

      SuperDamageSound ();
      W_Attack ();

   }

};

void () SuperDamageSound = {

   if ( (self.super_damage_finished > time) ) {

      if ( (self.super_sound < time) ) {

         self.super_sound = (time + TRUE);
         sound (self,CHAN_BODY,"items/damage3.wav",TRUE,ATTN_NORM);

      }

   }
   return ;

};
