
if( SERVER ) then

	AddCSLuaFile( "shared.lua" );
	
	SWEP.HoldType = "ar2";

end

SWEP.PrintName = "Morita Mk II + Shotgun attachment";
SWEP.Author				= "Acey Cock"

if( CLIENT ) then

	
	SWEP.Slot = 2;
	SWEP.SlotPos = 2;
	SWEP.CSMuzzleFlashes	= true
	SWEP.ViewModelFOV		= 83;	
	
	SWEP.DrawCrosshair = false;
	
end

SWEP.Base = "weapon_ts_base";
SWEP.Category = "Starship Troopers";

SWEP.ViewModel			= "models/weapons/v_morita.mdl"
SWEP.WorldModel			= "models/weapons/w_morita.mdl"
SWEP.Primary.Sound			= Sound( "Weapon_MP5Navy.Single" )

SWEP.ViewModelFOV		= 40;

SWEP.InvSize = 2;
SWEP.InvWeight = 1;

SWEP.Primary.ClipSize = 160;
SWEP.Primary.DefaultClip = 1600;
SWEP.Primary.Ammo = "smg1";
SWEP.Primary.Delay = 0.07; --0.07;
SWEP.Primary.Damage = 3;
SWEP.Primary.Force = 1;
SWEP.Primary.RunCone = Vector( .07, .07, 0 );
SWEP.Primary.SpreadCone = Vector( .047, .047, 0 );
SWEP.Primary.CrouchSpreadCone = Vector( .03, .03, 0 );
SWEP.Primary.ViewPunch = Angle( -0.5, 0.0, 0 );
SWEP.Primary.Automatic = true;

SWEP.Secondary.ClipSize		= 6				// Size of a clip
SWEP.Secondary.DefaultClip	= 12				// Default number of bullets in a clip
SWEP.Secondary.Automatic	= false				// Automatic/Semi Auto
SWEP.Secondary.Ammo			= "smg1"



--SWEP.IronSightPos = Vector( 0, 0, 0 );
--SWEP.IronSightAng = Vector( 0, 0, 0 );

function SWEP:Reload() -- for delay

		if( self.IsSilenced ) then
				self.Weapon:DefaultReload( ACT_VM_RELOAD_SILENCED );
		else
				self.Weapon:DefaultReload( ACT_VM_RELOAD ); // View model animation
		end
	self.Weapon:SetNWBool( "ironsights", false );
	
	if( self.NoDrawOnIronSights ) then
	
		if( SERVER ) then
			self.Owner:DrawViewModel( true );
		end
	
	end
	
	self.ViewPunchOffset = Vector( 0, 0, 0 );
	
	if( SERVER ) then
		self.Owner:SetFOV( self.FOV, .6 );
	end
	
	self.Weapon:SetNextSecondaryFire( CurTime() + 1.53 );
	self.Weapon:SetNextPrimaryFire( CurTime() + 1.53 );

end

function SWEP:SecondaryAttack()
	
	if( not self:CanPrimaryAttack() ) then return false; end

	if( not self.Weapon:GetNWBool( "NPCAimed" ) ) then
		return false;
	end
	
	if( self.Owner:GetNWInt( "tiedup" ) == 1 ) then 
		return; 
	end

	if( self.Weapon:GetNWBool( "ironsights" ) and self.NoIronSightAttack ) then return; end
	if( self.Owner:KeyDown( IN_SPEED ) and self.Owner:GetVelocity():Length() >= 140 ) then return; end
	
	if( self.Weapon:Clip1() < 9 ) then return end
	
	bullet = {};
	bullet.Num    = 9;
	bullet.Src    = self.Owner:GetShootPos();
	bullet.Dir    = self.Owner:GetAimVector();
	bullet.Spread = Vector( .1, .1, 0 );
	bullet.Tracer = 1;
	bullet.Force  = 10;
	bullet.Damage = 10;
	self.Owner:FireBullets( bullet );

	self.Owner:ViewPunch( Angle( -3, math.random( -1, 1 ), 0 ) );

	self.Weapon:SetNextSecondaryFire( CurTime() + 0.5666 );
	self.Weapon:SetNextPrimaryFire( CurTime() + 0.5666 );
	
	if( math.random( 1, 2 ) == 1 ) then
		self.Weapon:EmitSound( "weapons/shotgun/shotgun_fire6.wav" );
	else
		self.Weapon:EmitSound( "weapons/shotgun/shotgun_fire7.wav" );
	end
	
	self:TakePrimaryAmmo( 9 );
	
	self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK );
	self.Owner:MuzzleFlash();
	self.Owner:SetAnimation( PLAYER_ATTACK1 );
	
end
