zombiesurvival-evolved/gamemodes/zombiesurvival/entities/weapons/weapon_zs_crow/init.lua

77 lines
1.8 KiB
Lua
Raw Normal View History

INC_SERVER()
2014-10-02 08:49:54 +08:00
function SWEP:Deploy()
self:GetOwner().SkipCrow = true
2014-10-02 08:49:54 +08:00
return true
end
function SWEP:Holster()
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()
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()
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()
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)
self:GetOwner():EmitSound("NPC_Crow.Squawk")
self:GetOwner().EatAnim = CurTime() + 2
2014-10-02 08:49:54 +08:00
self:SetPeckEndTime(CurTime() + 1)
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)
self:GetOwner():EmitSound("NPC_Crow.Alert")
2014-10-02 08:49:54 +08:00
end
function SWEP:Reload()
self:SecondaryAttack()
return false
end