
SWEP.HoldType               = "knife"

if CLIENT then
   SWEP.PrintName          = "knife2"
   SWEP.Slot               = 1

   SWEP.ViewModelFOV       = 50
   SWEP.ViewModelFlip      = false

   SWEP.Icon               = "vgui/ttt/icon_knife"
end

SWEP.PrintName = "Sacrificial Knife"
    
SWEP.Author = "weapon_knife"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = ""

SWEP.Spawnable= true
SWEP.AdminSpawnable= true
SWEP.AdminOnly = false

SWEP.DrawAmmo = true

SWEP.Slot = 1
SWEP.SlotPos = 1

SWEP.Base                   = "weapon_tttbase"

SWEP.UseHands               = true
SWEP.ViewModel = "models/weapons/cstrike/c_knife_t.mdl"
SWEP.WorldModel = "models/weapons/w_knife_t.mdl"


SWEP.Primary.ClipSize       = -1
SWEP.Primary.DefaultClip    = -1
SWEP.Primary.Automatic      = false
SWEP.Primary.Ammo           = "none"
SWEP.Primary.Delay          = 0.3
SWEP.Primary.Force          = 5
SWEP.AllowDelete             = true -- never removed for weapon reduction
SWEP.AllowDrop               = false


SWEP.NoSights                = true
SWEP.IsSilent                = false


SWEP.Secondary.ClipSize     = -1
SWEP.Secondary.DefaultClip  = -1
SWEP.Secondary.Automatic    = false
SWEP.Secondary.Ammo         = "none"

function SWEP:PrimaryAttack()
	self.Owner:SetAnimation( PLAYER_ATTACK1	)
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
	self.Weapon:SetNextPrimaryFire(CurTime() + 0.6)
	self.Weapon:EmitSound("NPC_FastZombie.Attack")
	self.Owner:ViewPunch( Angle( -5,5, 1) ) 
	timer.Simple(0.1, function()	
		self.Owner:ViewPunch( Angle( 7,-20, 1) ) 
		local trace = self.Owner:GetEyeTrace()
			if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 90 then
				bullet = {}
				bullet.Num    = 1
				bullet.Src    = self.Owner:GetShootPos()
				bullet.Dir    = self.Owner:GetAimVector()
				bullet.Spread = Vector(0, 0, 0)
				bullet.Tracer = 0
				bullet.Force  = 3
				bullet.Damage = 40
				self.Owner:FireBullets(bullet)
					if trace.Entity:IsPlayer() then
						self.Owner:SetHealth( self.Owner:Health() + 5 )
						self.Owner:ScreenFade( SCREENFADE.IN, Color( 100, 0, 0, 110 ), 0.5, 0 )
						self.Weapon:EmitSound("Weapon_Knife.Hit")
					end
		end
	end)
end

function SWEP:Deploy()
	local colRed = Color( 0, 0, 0, 240 )
	self:SendWeaponAnim( ACT_VM_DRAW )
	self:SetNextPrimaryFire( CurTime() + self:SequenceDuration() )
	self.Owner:SetRenderMode( RENDERMODE_TRANSALPHA )
	self.Owner:SetColor(colRed)
	self.Owner:SetModel([[models/player/zombie_fast.mdl]])
	self.Owner:SetWalkSpeed( 310 )
	return true
end 


function SWEP:SecondaryAttack()
	self.Weapon:EmitSound( "npc/stalker/breathing3.wav", 140, 70, 0.7, CHAN_AUTO )
end

function SWEP:Initialize()
	self:SetHoldType("knife")
end

function SWEP:Reload()
	if SERVER then
	self.Owner:Ignite(5)
	end
	self.Owner:SetWalkSpeed( 400 )
			timer.Create( "delay" .. self:EntIndex(), 5, 1, function()
				if IsValid(self.Owner) then
					self.Owner:SetWalkSpeed( 310 )
				end
			end)
end

function SWEP:Holster()
	return false
end

function SWEP:OnDrop()
	self.Weapon:Remove()
end