From 95422d5a54611a42b1367e722d2dbf4e9c65b237 Mon Sep 17 00:00:00 2001 From: JetBoom Date: Sun, 19 Apr 2015 06:15:54 -0400 Subject: [PATCH] Giga Gore Child now cannot throw while feigning Addresses https://github.com/JetBoom/zombiesurvival/issues/122 --- .../entities/weapons/weapon_zs_gigagorechild.lua | 14 ++++++++------ gamemodes/zombiesurvival/gamemode/sv_profiling.lua | 10 ++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gigagorechild.lua b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gigagorechild.lua index 23ab85b..dc3db17 100644 --- a/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gigagorechild.lua +++ b/gamemodes/zombiesurvival/entities/weapons/weapon_zs_gigagorechild.lua @@ -42,7 +42,7 @@ function SWEP:PrimaryAttack() end function SWEP:SecondaryAttack() - if self:IsSwinging() or CurTime() <= self:GetNextSecondaryAttack() then return end + if self:IsSwinging() or CurTime() <= self:GetNextSecondaryAttack() or IsValid(self.Owner.FeignDeath) then return end self:SetThrowTime(CurTime() + self.ThrowDelay) self.Owner:DoReloadEvent() -- Handled in the class file. Fires the throwing anim. @@ -54,23 +54,25 @@ function SWEP:CheckThrow() if self:GetThrowing() and CurTime() >= self:GetThrowTime() then self:SetThrowTime(0) - self.Owner:EmitSound("weapons/slam/throw.wav", 70, math.random(78, 82)) + local owner = self.Owner + + owner:EmitSound("weapons/slam/throw.wav", 70, math.random(78, 82)) if SERVER then local ent = ents.Create("prop_thrownbaby") if ent:IsValid() then - ent:SetPos(self.Owner:GetShootPos()) + ent:SetPos(owner:GetShootPos()) ent:SetAngles(AngleRand()) - ent:SetOwner(self.Owner) + ent:SetOwner(owner) ent:Spawn() local phys = ent:GetPhysicsObject() if phys:IsValid() then phys:Wake() - phys:SetVelocityInstantaneous(self.Owner:GetAimVector() * 500) + phys:SetVelocityInstantaneous(owner:GetAimVector() * 500) phys:AddAngleVelocity(VectorRand() * math.Rand(200, 300)) - ent:SetPhysicsAttacker(self.Owner) + ent:SetPhysicsAttacker(owner) end end end diff --git a/gamemodes/zombiesurvival/gamemode/sv_profiling.lua b/gamemodes/zombiesurvival/gamemode/sv_profiling.lua index f499c8c..ac12984 100644 --- a/gamemodes/zombiesurvival/gamemode/sv_profiling.lua +++ b/gamemodes/zombiesurvival/gamemode/sv_profiling.lua @@ -3,6 +3,7 @@ GM.ProfilerNodes = {} GM.ProfilerFolder = "zsprofiler" GM.ProfilerFolderPreMade = "profiler_premade" +GM.ProfilerVersion = 0 GM.MaxProfilerNodes = 128 hook.Add("Initialize", "ZSProfiler", function() @@ -39,7 +40,7 @@ end function GM:SaveProfiler() if not self:ProfilerEnabled() or self.ProfilerIsPreMade then return end - file.Write(self:GetProfilerFile(), Serialize(self.ProfilerNodes)) + file.Write(self:GetProfilerFile(), Serialize({Nodes = self.ProfilerNodes, Version = self.ProfilerVersion})) end function GM:LoadProfiler() @@ -47,7 +48,12 @@ function GM:LoadProfiler() local filename = self:GetProfilerFile() if file.Exists(filename, "DATA") then - self.ProfilerNodes = Deserialize(file.Read(filename, "DATA")) + local data = Deserialize(file.Read(filename, "DATA")) + if not data.Version and self.ProfilerVersion == 0 then -- old, versionless format + self.ProfilerNodes = data + elseif data.Nodes and data.Version >= self.ProfilerVersion then + self.ProfilerNodes = data.Nodes + end end end