
if( SERVER ) then

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

end

SWEP.PrintName = "HE Grenade";
SWEP.Author				= "Disseminate"

if( CLIENT ) then

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

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

SWEP.ViewModel			= "models/weapons/v_eq_fraggrenade.mdl"
SWEP.WorldModel			= "models/weapons/w_eq_fraggrenade.mdl"

SWEP.ViewModelFOV		= 40;

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

SWEP.Primary.ClipSize = 1;
SWEP.Primary.DefaultClip = 1;
SWEP.Primary.Automatic = false;

SWEP.NoIronsights = true;

function SWEP:PrimaryAttack()

	if( self.Owner:GetNWInt( "tiedup" ) == 1 ) then 
		return; 
	end

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

	if( not self.Weapon:GetNWBool( "NPCAimed" ) ) then
		return false;
	end
	
	if( self.Owner:KeyDown( IN_SPEED ) and self.Owner:GetVelocity():Length() >= 140 ) then return; end
	
	self.Weapon:SetNextPrimaryFire( CurTime() + 99999 );
	
	if( SERVER ) then
		
		local nade = ents.Create( "sent_henade" );
			nade:SetPos( self.Owner:GetShootPos() + self.Owner:GetForward() * 30 );
			nade:Spawn();
		
		local phy = nade:GetPhysicsObject();
		if( phy:IsValid() ) then
			
			phy:SetVelocity( self.Owner:GetAimVector() * 1200 );
			phy:AddAngleVelocity( Angle( math.random( 0, 360 ), math.random( 0, 360 ), math.random( 0, 360 ) ) );
			
		end
		
		self.Owner:StripWeapon( "weapon_sst_grenade" );
		
	end
	
end
