2018-05-02 06:32:59 +08:00
|
|
|
INC_SERVER()
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
function SWEP:Deploy()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner().SkipCrow = true
|
2014-10-02 08:49:54 +08:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Holster()
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2014-10-02 08:49:54 +08:00
|
|
|
if owner:IsValid() then
|
|
|
|
owner:StopSound("NPC_Crow.Flap")
|
|
|
|
owner:SetAllowFullRotation(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
SWEP.OnRemove = SWEP.Holster
|
|
|
|
|
|
|
|
function SWEP:Think()
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
local fullrot = not owner:OnGround()
|
|
|
|
if owner:GetAllowFullRotation() ~= fullrot then
|
|
|
|
owner:SetAllowFullRotation(fullrot)
|
|
|
|
end
|
|
|
|
|
|
|
|
if owner:IsOnGround() or not owner:KeyDown(IN_JUMP) or not owner:KeyDown(IN_FORWARD) then
|
|
|
|
if self.PlayFlap then
|
|
|
|
owner:StopSound("NPC_Crow.Flap")
|
|
|
|
self.PlayFlap = nil
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if not self.PlayFlap then
|
|
|
|
owner:EmitSound("NPC_Crow.Flap")
|
|
|
|
self.PlayFlap = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local peckend = self:GetPeckEndTime()
|
|
|
|
if peckend == 0 or CurTime() < peckend then return end
|
|
|
|
self:SetPeckEndTime(0)
|
|
|
|
|
|
|
|
local trace = owner:TraceLine(14, MASK_SOLID)
|
|
|
|
local ent = NULL
|
|
|
|
if trace.Entity then
|
|
|
|
ent = trace.Entity
|
|
|
|
end
|
|
|
|
|
|
|
|
owner:ResetSpeed()
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
if ent:IsValidLivingZombie() and ent:GetZombieClassTable().Name == "Crow" then -- Crows can team kill other crows as something to do.
|
2014-10-02 08:49:54 +08:00
|
|
|
ent:TakeSpecialDamage(2, DMG_SLASH, owner, self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PrimaryAttack()
|
2018-05-02 06:32:59 +08:00
|
|
|
if CurTime() < self:GetNextPrimaryFire() or not self:GetOwner():IsOnGround() then return end
|
2014-10-02 08:49:54 +08:00
|
|
|
self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner():EmitSound("NPC_Crow.Squawk")
|
|
|
|
self:GetOwner().EatAnim = CurTime() + 2
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
self:SetPeckEndTime(CurTime() + 1)
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner():SetSpeed(1)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:SecondaryAttack()
|
|
|
|
if CurTime() < self:GetNextSecondaryFire() then return end
|
|
|
|
self:SetNextSecondaryFire(CurTime() + 1.6)
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner():EmitSound("NPC_Crow.Alert")
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Reload()
|
|
|
|
self:SecondaryAttack()
|
|
|
|
return false
|
|
|
|
end
|