2014-10-02 08:49:54 +08:00
|
|
|
AddCSLuaFile()
|
|
|
|
|
|
|
|
SWEP.Base = "weapon_zs_zombie"
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.PrintName = "Shade"
|
|
|
|
|
2014-10-02 08:49:54 +08:00
|
|
|
SWEP.ViewModel = Model("models/weapons/v_fza.mdl")
|
|
|
|
SWEP.WorldModel = Model("models/weapons/w_crowbar.mdl")
|
|
|
|
|
|
|
|
if CLIENT then
|
|
|
|
SWEP.ViewModelFOV = 70
|
|
|
|
end
|
|
|
|
|
|
|
|
SWEP.Primary.Automatic = false
|
|
|
|
SWEP.Secondary.Automatic = false
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.ShadeControl = "env_shadecontrol"
|
|
|
|
SWEP.ShadeProjectile = "projectile_shaderock"
|
|
|
|
|
2014-10-02 08:49:54 +08:00
|
|
|
function SWEP:Initialize()
|
|
|
|
self:HideWorldModel()
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Think()
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PrimaryAttack()
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
|
|
|
if CurTime() <= self:GetNextPrimaryFire() or (owner.ShadeShield and owner.ShadeShield:IsValid()) then return end
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
for _, ent in pairs(ents.FindByClass(self.ShadeControl)) do
|
|
|
|
if ent:IsValid() and ent:GetOwner() == owner then
|
2014-10-02 08:49:54 +08:00
|
|
|
local obj = ent:GetParent()
|
|
|
|
if obj:IsValid() then
|
2018-05-02 06:32:59 +08:00
|
|
|
self:SetNextSecondaryFire(CurTime() + 0.65)
|
|
|
|
|
|
|
|
owner:DoAttackEvent()
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
if CLIENT then return end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local vel = owner:GetAimVector() * 1000
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
local phys = obj:GetPhysicsObject()
|
|
|
|
if phys:IsValid() and phys:IsMoveable() and phys:GetMass() <= 300 then
|
|
|
|
phys:Wake()
|
|
|
|
phys:SetVelocity(vel)
|
2018-05-02 06:32:59 +08:00
|
|
|
obj:SetPhysicsAttacker(owner)
|
2014-10-02 08:49:54 +08:00
|
|
|
phys:AddGameFlag(FVPHYSICS_WAS_THROWN)
|
|
|
|
|
|
|
|
obj:EmitSound(")weapons/physcannon/superphys_launch"..math.random(4)..".wav")
|
2018-05-02 06:32:59 +08:00
|
|
|
obj.LastShadeLaunch = CurTime()
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ent:Remove()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
function SWEP:CanGrab()
|
|
|
|
local owner = self:GetOwner()
|
|
|
|
if CurTime() <= self:GetNextSecondaryFire() or (owner.ShadeShield and owner.ShadeShield:IsValid()) then return end
|
|
|
|
self:SetNextSecondaryFire(CurTime() + 0.1)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
if SERVER then
|
|
|
|
for _, ent in pairs(ents.FindByClass(self.ShadeControl)) do
|
|
|
|
if ent:IsValid() and ent:GetOwner() == owner then
|
|
|
|
ent:Remove()
|
|
|
|
return
|
|
|
|
end
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:SecondaryAttack()
|
|
|
|
if not self:CanGrab() then return end
|
|
|
|
|
|
|
|
local owner = self:GetOwner()
|
|
|
|
local ent = owner:CompensatedMeleeTrace(400, 4).Entity
|
|
|
|
if ent:IsValid() and (ent:IsPhysicsModel() or ent.IsShadeGrabbable or ent.IsPhysbox) then
|
|
|
|
self:SetNextPrimaryFire(CurTime() + 0.25)
|
|
|
|
self:SetNextSecondaryFire(CurTime() + 0.4)
|
|
|
|
|
|
|
|
if SERVER then
|
2014-10-02 08:49:54 +08:00
|
|
|
local phys = ent:GetPhysicsObject()
|
|
|
|
if phys:IsValid() and phys:IsMoveable() and phys:GetMass() <= 300 then
|
2018-05-02 06:32:59 +08:00
|
|
|
for _, ent2 in pairs(ents.FindByClass(self.ShadeControl)) do
|
2014-10-02 08:49:54 +08:00
|
|
|
if ent2:IsValid() and ent2:GetParent() == ent then
|
|
|
|
ent2:Remove()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
for _, status in pairs(ents.FindByClass("status_human_holding")) do
|
|
|
|
if status:IsValid() and status:GetObject() == ent then
|
|
|
|
status:Remove()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local con = ents.Create(self.ShadeControl)
|
2014-10-02 08:49:54 +08:00
|
|
|
if con:IsValid() then
|
|
|
|
con:Spawn()
|
2018-05-02 06:32:59 +08:00
|
|
|
con:SetOwner(owner)
|
2014-10-02 08:49:54 +08:00
|
|
|
con:AttachTo(ent)
|
|
|
|
|
|
|
|
ent:EmitSound(")weapons/physcannon/physcannon_claws_close.wav")
|
|
|
|
end
|
|
|
|
end
|
2018-05-02 06:32:59 +08:00
|
|
|
end
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Reload()
|
2018-05-02 06:32:59 +08:00
|
|
|
if not self:CanGrab() then return end
|
|
|
|
|
|
|
|
local owner = self:GetOwner()
|
|
|
|
|
|
|
|
local vStart = owner:GetShootPos()
|
|
|
|
local vEnd = vStart + owner:GetForward() * 40
|
|
|
|
|
|
|
|
local tr = util.TraceHull({start=vStart, endpos=vEnd, filter=owner, mins=owner:OBBMins()/2, maxs=owner:OBBMaxs()/2})
|
|
|
|
self:SetNextPrimaryFire(CurTime() + 0.9)
|
|
|
|
self:SetNextSecondaryFire(CurTime() + 0.9)
|
|
|
|
|
|
|
|
if SERVER then
|
|
|
|
local rock = ents.Create(self.ShadeProjectile)
|
|
|
|
if rock:IsValid() then
|
|
|
|
local pos = owner:GetPos() - owner:GetForward() * 5
|
|
|
|
if not tr.Hit then
|
|
|
|
pos = pos + owner:GetForward() * 30
|
|
|
|
end
|
|
|
|
|
|
|
|
rock:SetPos(pos)
|
|
|
|
rock:SetOwner(owner)
|
|
|
|
rock:Spawn()
|
|
|
|
local con = ents.Create(self.ShadeControl)
|
|
|
|
if con:IsValid() then
|
|
|
|
con:Spawn()
|
|
|
|
con:SetOwner(owner)
|
|
|
|
con:AttachTo(rock)
|
|
|
|
rock.Control = con
|
|
|
|
|
|
|
|
util.ScreenShake(owner:GetPos(), 3, 1, 0.75, 400)
|
|
|
|
|
|
|
|
con:EmitSound("physics/concrete/concrete_break3.wav", 85, 60)
|
|
|
|
rock:EmitSound(")weapons/physcannon/physcannon_claws_close.wav")
|
|
|
|
|
|
|
|
owner.LastRangedAttack = CurTime()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:OnRemove()
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:Holster()
|
|
|
|
end
|
|
|
|
|
|
|
|
if not CLIENT then return end
|
|
|
|
|
|
|
|
function SWEP:PreDrawViewModel(vm)
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2014-10-02 08:49:54 +08:00
|
|
|
if owner:IsValid() then
|
2018-05-02 06:32:59 +08:00
|
|
|
owner:CallZombieFunction1("PreRenderEffects", vm)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PostDrawViewModel(vm)
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2014-10-02 08:49:54 +08:00
|
|
|
if owner:IsValid() then
|
2018-05-02 06:32:59 +08:00
|
|
|
owner:CallZombieFunction1("PostRenderEffects", vm)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|