e9da54c2f9
Too many changes to list.
83 lines
1.7 KiB
Lua
83 lines
1.7 KiB
Lua
INC_SERVER()
|
|
|
|
function SWEP:Deploy()
|
|
gamemode.Call("WeaponDeployed", self:GetOwner(), self)
|
|
|
|
self:SpawnGhost()
|
|
|
|
return true
|
|
end
|
|
|
|
function SWEP:OnRemove()
|
|
self:RemoveGhost()
|
|
end
|
|
|
|
function SWEP:Holster()
|
|
self:RemoveGhost()
|
|
return true
|
|
end
|
|
|
|
function SWEP:SpawnGhost()
|
|
local owner = self:GetOwner()
|
|
if owner and owner:IsValid() then
|
|
owner:GiveStatus("ghost_ffemitter")
|
|
end
|
|
end
|
|
|
|
function SWEP:RemoveGhost()
|
|
local owner = self:GetOwner()
|
|
if owner and owner:IsValid() then
|
|
owner:RemoveStatus("ghost_ffemitter", false, true)
|
|
end
|
|
end
|
|
|
|
function SWEP:PrimaryAttack()
|
|
if not self:CanPrimaryAttack() then return end
|
|
|
|
local owner = self:GetOwner()
|
|
|
|
local status = owner.status_ghost_ffemitter
|
|
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_ffemitter")
|
|
if ent:IsValid() then
|
|
ent:SetPos(pos)
|
|
ent:SetAngles(ang)
|
|
ent:Spawn()
|
|
|
|
ent:SetObjectOwner(owner)
|
|
ent:SetupDeployableSkillHealth()
|
|
|
|
ent:EmitSound("npc/dog/dog_servo12.wav")
|
|
|
|
self:TakePrimaryAmmo(1)
|
|
|
|
local stored = owner:PopPackedItem(ent:GetClass())
|
|
if stored then
|
|
ent:SetObjectHealth(stored[1])
|
|
end
|
|
|
|
local ammo = math.min(owner:GetAmmoCount("pulse"), 150)
|
|
ent:SetAmmo(ammo)
|
|
owner:RemoveAmmo(ammo, "pulse")
|
|
|
|
if self:GetPrimaryAmmoCount() <= 0 then
|
|
owner:StripWeapon(self:GetClass())
|
|
end
|
|
end
|
|
end
|
|
|
|
function SWEP:Think()
|
|
local count = self:GetPrimaryAmmoCount()
|
|
if count ~= self:GetReplicatedAmmo() then
|
|
self:SetReplicatedAmmo(count)
|
|
self:GetOwner():ResetSpeed()
|
|
end
|
|
end
|