2014-10-02 08:49:54 +08:00
|
|
|
AddCSLuaFile()
|
|
|
|
|
|
|
|
SWEP.Base = "weapon_zs_zombie"
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.PrintName = "Giga Gore Child"
|
|
|
|
|
|
|
|
SWEP.ViewModel = "models/weapons/c_arms_citizen.mdl"
|
|
|
|
SWEP.WorldModel = ""
|
|
|
|
|
|
|
|
if CLIENT then
|
|
|
|
SWEP.UseHands = true
|
|
|
|
SWEP.ViewModelFOV = 40
|
|
|
|
SWEP.BobScale = 2
|
|
|
|
end
|
|
|
|
|
|
|
|
SWEP.MeleeReach = 90
|
|
|
|
SWEP.MeleeDamage = 32
|
2014-10-02 08:49:54 +08:00
|
|
|
SWEP.MeleeForceScale = 2
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.MeleeSize = 5 --3
|
2014-10-02 08:49:54 +08:00
|
|
|
SWEP.MeleeDamageType = DMG_SLASH
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.Primary.Delay = 1.35
|
|
|
|
SWEP.Secondary.Delay = 2.5
|
2014-10-02 08:49:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
SWEP.CryDelay = 8
|
|
|
|
SWEP.CryImpactDelay = 1
|
2014-10-02 08:49:54 +08:00
|
|
|
SWEP.ThrowDelay = 1
|
|
|
|
|
|
|
|
AccessorFuncDT(SWEP, "ThrowTime", "Float", 3)
|
2018-05-02 06:32:59 +08:00
|
|
|
AccessorFuncDT(SWEP, "CryTime", "Float", 4)
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
function SWEP:Think()
|
|
|
|
self:CheckMeleeAttack()
|
|
|
|
self:CheckThrow()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:CheckCry()
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:ApplyMeleeDamage(ent, trace, damage)
|
2018-05-02 06:32:59 +08:00
|
|
|
if ent:IsValidPlayer() then
|
|
|
|
local vel = ent:GetPos() - self:GetOwner():GetPos()
|
2014-10-02 08:49:54 +08:00
|
|
|
vel.z = 0
|
|
|
|
vel:Normalize()
|
|
|
|
vel = vel * 400
|
|
|
|
vel.z = 200
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
if CurTime() >= (ent.NextKnockdown or 0) then
|
|
|
|
ent:KnockDown()
|
|
|
|
ent.NextKnockdown = CurTime() + 4
|
|
|
|
end
|
2014-10-02 08:49:54 +08:00
|
|
|
ent:SetGroundEntity(NULL)
|
|
|
|
ent:SetVelocity(vel)
|
|
|
|
end
|
|
|
|
|
|
|
|
self.BaseClass.ApplyMeleeDamage(self, ent, trace, damage)
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PrimaryAttack()
|
|
|
|
if self:IsThrowing() then return end
|
|
|
|
|
|
|
|
self.BaseClass.PrimaryAttack(self)
|
|
|
|
end
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
function SWEP:Deploy()
|
|
|
|
local vm = self:GetOwner():GetViewModel()
|
|
|
|
vm:SendViewModelMatchingSequence(vm:LookupSequence("fists_draw"))
|
|
|
|
|
|
|
|
return self.BaseClass.Deploy(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
local anims = {"fists_uppercut", "fists_right", "fists_left"}
|
|
|
|
function SWEP:StartSwinging()
|
|
|
|
self.BaseClass.StartSwinging(self)
|
|
|
|
|
|
|
|
local vm = self:GetOwner():GetViewModel()
|
|
|
|
vm:SendViewModelMatchingSequence(vm:LookupSequence(anims[math.random(#anims)]))
|
|
|
|
vm:SetPlaybackRate(0.32)
|
|
|
|
end
|
|
|
|
|
2014-10-02 08:49:54 +08:00
|
|
|
function SWEP:SecondaryAttack()
|
2018-05-02 06:32:59 +08:00
|
|
|
if self:IsSwinging() or CurTime() <= self:GetNextSecondaryAttack() or IsValid(self:GetOwner().FeignDeath) then return end
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
self:SetThrowTime(CurTime() + self.ThrowDelay)
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner():DoReloadEvent() -- Handled in the class file. Fires the throwing anim.
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
self:SetNextSecondaryAttack(CurTime() + self.Secondary.Delay)
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:CheckThrow()
|
|
|
|
if self:GetThrowing() and CurTime() >= self:GetThrowTime() then
|
|
|
|
self:SetThrowTime(0)
|
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
local owner = self:GetOwner()
|
2015-04-19 18:15:54 +08:00
|
|
|
|
2018-05-02 06:32:59 +08:00
|
|
|
owner.LastRangedAttack = CurTime()
|
2015-04-19 18:15:54 +08:00
|
|
|
owner:EmitSound("weapons/slam/throw.wav", 70, math.random(78, 82))
|
2014-10-02 08:49:54 +08:00
|
|
|
|
|
|
|
if SERVER then
|
|
|
|
local ent = ents.Create("prop_thrownbaby")
|
|
|
|
if ent:IsValid() then
|
2015-04-19 18:15:54 +08:00
|
|
|
ent:SetPos(owner:GetShootPos())
|
2014-10-02 08:49:54 +08:00
|
|
|
ent:SetAngles(AngleRand())
|
2015-04-19 18:15:54 +08:00
|
|
|
ent:SetOwner(owner)
|
2014-10-02 08:49:54 +08:00
|
|
|
ent:Spawn()
|
|
|
|
|
|
|
|
local phys = ent:GetPhysicsObject()
|
|
|
|
if phys:IsValid() then
|
|
|
|
phys:Wake()
|
2018-05-02 06:32:59 +08:00
|
|
|
phys:SetVelocityInstantaneous(owner:GetAimVector() * 650)
|
2014-10-02 08:49:54 +08:00
|
|
|
phys:AddAngleVelocity(VectorRand() * math.Rand(200, 300))
|
|
|
|
|
2015-04-19 18:15:54 +08:00
|
|
|
ent:SetPhysicsAttacker(owner)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:IsThrowing()
|
|
|
|
return self:GetThrowTime() > 0
|
|
|
|
end
|
|
|
|
SWEP.GetThrowing = SWEP.IsThrowing
|
|
|
|
|
|
|
|
function SWEP:Reload()
|
2018-05-02 06:32:59 +08:00
|
|
|
if self:IsSwinging() or CurTime() <= self:GetNextSecondaryAttack() or IsValid(self:GetOwner().FeignDeath) then return end
|
|
|
|
|
|
|
|
self:PlayAlertSound()
|
|
|
|
self:GetOwner():AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GMOD_GESTURE_TAUNT_ZOMBIE, true)
|
|
|
|
|
|
|
|
self:SetCryTime(CurTime() + self.CryImpactDelay)
|
|
|
|
self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
|
|
|
|
self:SetNextSecondaryAttack(CurTime() + self.CryDelay)
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:CheckCry()
|
|
|
|
if self:IsCrying() and CurTime() >= self:GetCryTime() then
|
|
|
|
self:SetCryTime(0)
|
|
|
|
|
|
|
|
local owner = self:GetOwner()
|
|
|
|
local worldspace = owner:WorldSpaceCenter()
|
|
|
|
|
|
|
|
util.ScreenShake(worldspace, 5, 5, 2, 400)
|
|
|
|
owner:EmitSound("physics/concrete/concrete_break2.wav", 77, 50)
|
|
|
|
|
|
|
|
for k, ent in pairs(ents.FindInSphere(worldspace, 150)) do
|
|
|
|
if ent:IsValid() and ent:IsValidLivingHuman() and WorldVisible(ent:GetPos(), worldspace) then
|
|
|
|
if CurTime() >= (ent.NextKnockdown or 0) then
|
|
|
|
ent:KnockDown()
|
|
|
|
ent.NextKnockdown = CurTime() + 4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:IsCrying()
|
|
|
|
return self:GetCryTime() > 0
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayAlertSound()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner():EmitSound("ambient/creatures/town_child_scream1.wav", 82, 60)
|
|
|
|
self:GetOwner():EmitSound("npc/stalker/go_alert2a.wav", 82, 45, 0.25)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayIdleSound()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:GetOwner():EmitSound("ambient/creatures/teddy.wav", 77, 60)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayAttackSound()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:EmitSound("ambient/creatures/teddy.wav", 77, 60)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayHitSound()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:EmitSound("physics/body/body_medium_impact_hard"..math.random(6)..".wav", 77, math.random(60, 70), nil, CHAN_AUTO)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function SWEP:PlayMissSound()
|
2018-05-02 06:32:59 +08:00
|
|
|
self:EmitSound("npc/zombie/claw_miss"..math.random(2)..".wav", 77, math.random(60, 70), nil, CHAN_AUTO)
|
2014-10-02 08:49:54 +08:00
|
|
|
end
|