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
|
|
|
gamemode.Call("WeaponDeployed", self:GetOwner(), self)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
self.IdleAnimation = CurTime() + self:SequenceDuration()
|
|
|
|
|
|
|
|
self:SpawnGhost()
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:OnRemove()
|
|
|
|
self:RemoveGhost()
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Holster()
|
|
|
|
self:RemoveGhost()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:SpawnGhost()
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2014-10-02 08:49:54 +08:00
|
|
|
if owner and owner:IsValid() then
|
|
|
|
owner:GiveStatus("ghost_barricadekit")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:RemoveGhost()
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2014-10-02 08:49:54 +08:00
|
|
|
if owner and owner:IsValid() then
|
|
|
|
owner:RemoveStatus("ghost_barricadekit", false, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Think()
|
|
|
|
if self.IdleAnimation and self.IdleAnimation <= CurTime() then
|
|
|
|
self.IdleAnimation = nil
|
|
|
|
self:SendWeaponAnim(ACT_VM_IDLE)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PrimaryAttack()
|
|
|
|
if not self:CanPrimaryAttack() then return end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
|
|
|
if not gamemode.Call("CanPlaceNail", owner) then return false end
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
local status = owner.status_ghost_barricadekit
|
|
|
|
if not (status and status:IsValid()) then return end
|
|
|
|
status:RecalculateValidity()
|
|
|
|
if not status:GetValidPlacement() then return end
|
|
|
|
|
|
|
|
local pos, ang = status:RecalculateValidity()
|
|
|
|
if not pos or not ang then return end
|
|
|
|
|
|
|
|
self:SetNextPrimaryAttack(CurTime() + self.Primary.Delay)
|
|
|
|
|
|
|
|
local ent = ents.Create("prop_aegisboard")
|
|
|
|
if ent:IsValid() then
|
|
|
|
ent:SetPos(pos)
|
|
|
|
ent:SetAngles(ang)
|
|
|
|
ent:Spawn()
|
|
|
|
|
|
|
|
ent:EmitSound("npc/dog/dog_servo12.wav")
|
|
|
|
|
|
|
|
ent:GhostAllPlayersInMe(5)
|
|
|
|
|
|
|
|
ent:SetObjectOwner(owner)
|
|
|
|
|
|
|
|
local stored = owner:PopPackedItem(ent:GetClass())
|
|
|
|
if stored then
|
|
|
|
ent:SetObjectHealth(stored[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
self:TakePrimaryAmmo(1)
|
|
|
|
end
|
|
|
|
end
|