//void(float shotcount, vector dir, vector spread) PM_FirePellets;
void (float shotcount, vector dir, vector spread) FireBullets;
float () W_BestWeapon;
float () crandom;
void (float shotcount, vector dir, vector spread) FireMossberg;
void () W_SetCurrentAmmo;


void () er_precache = {

   precache_sound ("erifle/load1.wav");
   precache_sound ("erifle/load2.wav");
   precache_sound ("erifle/load3.wav");
   precache_sound ("erifle/fire.wav");
   precache_sound ("erifle/reload.wav");
   precache_model ("progs/bultcase.mdl");
   precache_model ("progs/v_erifle.mdl");
   precache_model ("progs/g_erifle.mdl");

};

/*
void (vector org, vector vel) BultCase = {

   local entity shell;
   local entity mpuff;

   shell = spawn ();
   shell.owner = self;
   shell.movetype = MOVETYPE_BOUNCE;
   shell.solid = SOLID_BBOX;
   makevectors (self.angles);
   shell.velocity = vel;
   shell.velocity_z = ((shell.velocity_z + 180.000) + (40.000 * random ()));
   shell.avelocity = '1000.000 1000.000 1000.000';
   shell.touch = ShellTouch;
   shell.nextthink = (time + 2.000);
   shell.think = SUB_Remove;
   setmodel (shell,"progs/bultcase.mdl");
   setsize (shell,'0.000 0.000 0.000','0.000 0.000 0.000');
   setorigin (shell,org);

};
*/

void () W_FireErifle = {

   local vector dir;

	   sound (self,CHAN_AUTO,"erifle/fire.wav",1.000,ATTN_NORM);
   self.ammo_shells = (self.ammo_shells - 2.000);
   self.currentammo = (self.ammo_shells - 2.000);
   dir = aim (self,100000.000);
   //FireBullets2 (6.000,dir);
	//FireBullets (4.000,dir,'0.04 0.04 0');
  	FireMossberg (8, dir, '0.07 0.05 0');
   self.velocity = aim (self,200.000);
   self.velocity = (self.velocity * -200.000);
   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () W_FireErifle2 = {

   local vector dir;

   self.attack_finished = (time + 0.100);
	{
	   sound (self,CHAN_AUTO,"erifle/fire.wav",1.000,ATTN_NORM);
	   sound (self,CHAN_AUTO,"erifle/fire.wav",1.000,ATTN_NORM);
   }
   self.ammo_shells = (self.ammo_shells - 4.000);
   self.currentammo = (self.ammo_shells - 4.000);
   dir = aim (self,100000.000);
   //FireBullets2 (15.000,dir);
	//FireBullets (8.000,dir,'0.08 0.05 0');
  	FireMossberg (12, dir, '0.12 0.08 0');
   self.velocity = aim (self,400.000);
   self.velocity = (self.velocity * -400.000);
   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () player_shotd0 = [ 12.000, player_shotd1 ] {

   self.weaponframe = 59.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd1 = [ 12.000, player_shotd2 ] {

   self.weaponframe = 60.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd2 = [ 13.000, player_shotd3 ] {

   self.weaponframe = 61.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd3 = [ 13.000, player_shotd4 ] {

   self.weaponframe = 62.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd4 = [ 14.000, player_shotd5 ] {

   self.weaponframe = 63.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd5 = [ 14.000, player_shotd6 ] {

   self.weaponframe = 64.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd6 = [ 15.000, player_shotd7 ] {

   self.weaponframe = 65.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd7 = [ 15.000, player_shotd8 ] {

   self.weaponframe = 66.000;
   self.nextthink = (time + 0.050);

};

void () player_shotd8 = [ 16.000, player_run ] {

   self.weaponframe = 67.000;
   self.nextthink = (time + 0.050);
   if ( (self.ammo_shells < 2.000) ) {

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

   }

};

//double shot
void () player_shote1 = [ 113.000, player_shote2 ] {

   self.weaponframe = 67.000;
   W_FireErifle2 ();
   self.nextthink = (time + 0.050);
   self.punchangle_x = -12.000;
   self.attack_finished = (time + 0.050);

};

void () player_shote2 = [ 113.000, player_shote3 ] {

   self.weaponframe = 68.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -8.000;
   self.attack_finished = (time + 0.050);
   //self.shotgun = FALSE;

};

void () player_shote3 = [ 114.000, player_shote4 ] {

   self.weaponframe = 69.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -6.000;
   self.attack_finished = (time + 0.050);

};

void () player_shote4 = [ 114.000, player_shote5 ] {

   self.weaponframe = 70.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -4.000;
   self.attack_finished = (time + 0.050);

};

void () player_shote5 = [ 115.000, player_shote6 ] {

   self.weaponframe = 71.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -3.000;
   self.attack_finished = (time + 0.050);

};

void () player_shote6 = [ 115.000, player_shote7 ] {

   self.weaponframe = 72.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -2.000;
   self.attack_finished = (time + 0.050);

};

void () player_shote7 = [ 116.000, player_shote8 ] {

   self.weaponframe = 73.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -1.000;
   self.attack_finished = (time + 0.050);

};

void () player_shote8 = [ 116.000, player_shote9 ] {

   self.weaponframe = 74.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 0.050);

};

void () player_shote9 = [ 117.000, player_shote10 ] {

   self.weaponframe = 75.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 0.050);

};

void () player_shote10 = [ 117.000, player_shote11 ] {

   self.weaponframe = 76.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 0.050);

};

void () player_shote11 = [ 118.000, player_shote12 ] {

   self.weaponframe = 77.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 0.050);

};

void () player_shote12 = [ 118.000, player_shote13 ] {

   self.weaponframe = 78.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 0.050);

};

void () player_shote13 = [ 118.000, player_shotb7 ] {

   self.weaponframe = 79.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 0.050);
   if ( (self.ammo_shells < 5.000) ) {

      player_shotd0 ();
      return ;

   }
   self.attack_finished = (time + 0.050);

};

void () player_shotb7;

void () player_shota1 = [ 113.000, player_shota2 ] {

   self.weaponframe = 1.000;
   W_FireErifle ();
   self.nextthink = (time + 0.050);
   self.punchangle_x = -10.000;
   self.attack_finished = (time + 0.400);

};

void () player_shota2 = [ 114.000, player_shota3 ] {

   self.weaponframe = 2.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -6.000;
   //self.shotgun = FL_SWIM;
	//self.bondoflag = self.bondoflag | B_ERIFLEUNLOADED;

};

void () player_shota3 = [ 115.000, player_shota4 ] {

   self.weaponframe = 3.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -4.000;

};

void () player_shota4 = [ 116.000, player_shota5 ] {

   self.weaponframe = 4.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -3.000;

};

void () player_shota5 = [ 117.000, player_shota6 ] {

   self.weaponframe = 5.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -2.000;

};

void () player_shota6 = [ 118.000, player_run ] {

   self.weaponframe = 6.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -1.000;
   if ( (self.ammo_shells < 2.000) ) {

      player_shotd0 ();
      return ;

   }

};

void () player_shotb1 = [ 113.000, player_shotb2 ] {

   self.weaponframe = 7.000;
   W_FireErifle ();
   self.nextthink = (time + 0.050);
   self.punchangle_x = -10.000;
   self.attack_finished = (time + 0.400);

};

void () player_shotb2 = [ 114.000, player_shotb3 ] {

   self.weaponframe = 8.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -6.000;
   //self.shotgun = FALSE;

};

void () player_shotb3 = [ 115.000, player_shotb4 ] {

   self.weaponframe = 9.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -4.000;

};

void () player_shotb4 = [ 116.000, player_shotb5 ] {

   self.weaponframe = 10.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -3.000;

};

void () player_shotb5 = [ 117.000, player_shotb6 ] {

   self.weaponframe = 11.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -2.000;

};

void () player_shotb6 = [ 118.000, player_shotb7 ] {

   self.weaponframe = 12.000;
   self.nextthink = (time + 0.050);
   self.punchangle_x = -1.000;
   if ( (self.ammo_shells < 2.000) ) {

      player_shotd0 ();
      return ;

   }

};

void () player_shotb7 = [ 12.000, player_shotb8 ] {

   self.weaponframe = 13.000;
   self.nextthink = (time + 0.050);
   self.attack_finished = (time + 1.900);
   //self.bondoflag = self.bondoflag - B_ERIFLEUNLOADED;
   //BultCase (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(((v_right * -48.000) + (v_up * 16.000)) + ((crandom () * 20.000) * v_right)));
   //BultCase (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(((v_right * -48.000) + (v_up * 16.000)) + ((crandom () * 20.000) * v_right)));
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(((v_right * -48.000) + (v_up * 16.000)) + ((crandom () * 20.000) * v_right)));
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(((v_right * -48.000) + (v_up * 16.000)) + ((crandom () * 20.000) * v_right)));
	   sound (self,CHAN_BODY,"erifle/load1.wav",1.000,ATTN_NORM);

};

void () player_shotb8 = [ 12.000, player_shotb9 ] {

   self.weaponframe = 14.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb9 = [ 13.000, player_shotb10 ] {

   self.weaponframe = 15.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb10 = [ 13.000, player_shotb11 ] {

   self.weaponframe = 16.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb11 = [ 14.000, player_shotb12 ] {

   self.weaponframe = 17.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb12 = [ 14.000, player_shotb13 ] {

   self.weaponframe = 18.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb13 = [ 15.000, player_shotb14 ] {

   self.weaponframe = 19.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb14 = [ 15.000, player_shotb15 ] {

   self.weaponframe = 20.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb15 = [ 16.000, player_shotb16 ] {

   self.weaponframe = 21.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb16 = [ 16.000, player_shotb17 ] {

   self.weaponframe = 22.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb17 = [ 12.000, player_shotb18 ] {

   self.weaponframe = 23.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb18 = [ 12.000, player_shotb19 ] {

   self.weaponframe = 24.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb19 = [ 13.000, player_shotb20 ] {

   self.weaponframe = 25.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb20 = [ 13.000, player_shotb21 ] {

   self.weaponframe = 26.000;
   self.nextthink = (time + 0.050);
	   sound (self,CHAN_BODY,"erifle/load2.wav",1.000,ATTN_NORM);

};

void () player_shotb21 = [ 14.000, player_shotb22 ] {

   self.weaponframe = 27.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb22 = [ 14.000, player_shotb23 ] {

   self.weaponframe = 28.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb23 = [ 15.000, player_shotb24 ] {

   self.weaponframe = 29.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb24 = [ 15.000, player_shotb25 ] {

   self.weaponframe = 30.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb25 = [ 16.000, player_shotb26 ] {

   self.weaponframe = 31.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb26 = [ 16.000, player_shotb27 ] {

   self.weaponframe = 32.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb27 = [ 12.000, player_shotb28 ] {

   self.weaponframe = 33.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb28 = [ 12.000, player_shotb29 ] {

   self.weaponframe = 34.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb29 = [ 13.000, player_shotb30 ] {

   self.weaponframe = 35.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb30 = [ 13.000, player_shotb31 ] {

   self.weaponframe = 36.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb31 = [ 14.000, player_shotb32 ] {

   self.weaponframe = 37.000;
   self.nextthink = (time + 0.050);
	   sound (self,CHAN_BODY,"erifle/load2.wav",1.000,ATTN_NORM);

};

void () player_shotb32 = [ 14.000, player_shotb33 ] {

   self.weaponframe = 38.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb33 = [ 15.000, player_shotb34 ] {

   self.weaponframe = 39.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb34 = [ 15.000, player_shotb35 ] {

   self.weaponframe = 40.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb35 = [ 16.000, player_shotb36 ] {

   self.weaponframe = 41.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb36 = [ 16.000, player_shotb37 ] {

   self.weaponframe = 42.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb37 = [ 12.000, player_shotb38 ] {

   self.weaponframe = 43.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb38 = [ 12.000, player_shotb39 ] {

   self.weaponframe = 44.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb39 = [ 13.000, player_shotb40 ] {

   self.weaponframe = 45.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb40 = [ 13.000, player_shotb41 ] {

   self.weaponframe = 46.000;
   self.nextthink = (time + 0.050);
	   sound (self,CHAN_BODY,"erifle/load3.wav",1.000,ATTN_NORM);

};

void () player_shotb41 = [ 14.000, player_shotb42 ] {

   self.weaponframe = 47.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb42 = [ 14.000, player_shotb43 ] {

   self.weaponframe = 48.000;
   self.nextthink = (time + 0.050);

};

void () player_shotb43 = [ 15.000, player_run ] {

   self.weaponframe = 49.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc0 = [ 12.000, player_shotc1 ] {

   self.weaponframe = 50.000;
   self.nextthink = (time + 0.050);
	   sound (self,CHAN_BODY,"erifle/reload.wav",1.000,ATTN_NORM);
   self.attack_finished = (time + 0.400);

};

void () player_shotc1 = [ 12.000, player_shotc2 ] {

   self.weaponframe = 51.000;
   self.nextthink = (time + 0.050);
   //self.weapon3 = 1.000;

};

void () player_shotc2 = [ 13.000, player_shotc3 ] {

   self.weaponframe = 52.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc3 = [ 13.000, player_shotc4 ] {

   self.weaponframe = 53.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc4 = [ 14.000, player_shotc5 ] {

   self.weaponframe = 54.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc5 = [ 14.000, player_shotc6 ] {

   self.weaponframe = 55.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc6 = [ 15.000, player_shotc7 ] {

   self.weaponframe = 56.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc7 = [ 15.000, player_shotc8 ] {

   self.weaponframe = 57.000;
   self.nextthink = (time + 0.050);

};

void () player_shotc8 = [ 16.000, player_run ] {

   self.weaponframe = 58.000;
   self.nextthink = (time + 0.050);

};
