From 3e40769454c65a425f6847d40e63100901a765a1 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 18 Dec 2014 02:00:45 +0000 Subject: [PATCH] Added nail functions previously described in FGD +NailUnremovable +SetHealth +HealthOveride +HealthMultiplier --- .../entities/entities/prop_nail/init.lua | 22 +++++++++++++++++-- gamemodes/zombiesurvival/gamemode/shared.lua | 6 ++++- gamemodes/zombiesurvival/zombiesurvival.fgd | 18 +++++++-------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/entities/prop_nail/init.lua b/gamemodes/zombiesurvival/entities/entities/prop_nail/init.lua index 1f4f9a6..4542e68 100644 --- a/gamemodes/zombiesurvival/entities/entities/prop_nail/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/prop_nail/init.lua @@ -17,6 +17,9 @@ end) function ENT:Initialize() self:SetModel("models/crossbow_bolt.mdl") + self.m_NailUnremovable = self.m_NailUnremovable or false + self.HealthOveride = self.HealthOveride or -1 + self.HealthMultiplier = self.HealthMultiplier or 1 end function ENT:OnDamaged(damage, attacker, inflictor, dmginfo) @@ -48,6 +51,8 @@ function ENT:AttachTo(baseent, attachent, physbone, physbone2) if baseent:GetBarricadeHealth() == 0 then local health = baseent:GetDefaultBarricadeHealth() + if self.HealthOveride > 0 then health = self.HealthOveride end + health = health * self.HealthMultiplier baseent:SetMaxBarricadeHealth(health) baseent:SetBarricadeHealth(health) baseent:SetBarricadeRepairs(baseent:GetMaxBarricadeRepairs()) @@ -84,6 +89,11 @@ function ENT:SetDeployer(pl) end end +function ENT:SetNewHealth(health) + baseent = self:GetBaseEntity() + baseent:SetBarricadeHealth(health) +end + function ENT:AcceptInput(name, activator, caller, args) name = string.lower(name) if name == "attachto" then @@ -105,13 +115,17 @@ function ENT:AcceptInput(name, activator, caller, args) elseif name == "setname" or name == "setdeployer" then self:SetDeployer(args) + return true + elseif name == "sethealth" then + self:SetNewHealth(args) + return true elseif name == "setunremoveable" or name == "setunremovable" then self.m_NailUnremovable = tonumber(args) == 1 return true elseif name == "toggleunremoveable" or name == "toggleunremovable" then - self.m_NailUnremovable = not self.m_NailRemovable + self.m_NailUnremovable = not self.m_NailUnremovable return true end @@ -133,6 +147,10 @@ end function ENT:KeyValue(key, value) key = string.lower(key) if key == "unremoveable" or key == "unremovable" then - self.m_NailUnremoveable = tonumber(value) == 1 + self.m_NailUnremovable = tonumber(value) == 1 + elseif key == "healthoverride" then + self.HealthOveride = tonumber(value) + elseif key == "healthmultiplier" then + self.HealthMultiplier = tonumber(value) end end diff --git a/gamemodes/zombiesurvival/gamemode/shared.lua b/gamemodes/zombiesurvival/gamemode/shared.lua index 08def39..c145928 100644 --- a/gamemodes/zombiesurvival/gamemode/shared.lua +++ b/gamemodes/zombiesurvival/gamemode/shared.lua @@ -470,7 +470,11 @@ function GM:CanPlaceNail(pl, tr) end function GM:CanRemoveNail(pl, nail) - return true + if nail.m_NailUnremovable then + return false + else + return true + end end function GM:GetDamageResistance(fearpower) diff --git a/gamemodes/zombiesurvival/zombiesurvival.fgd b/gamemodes/zombiesurvival/zombiesurvival.fgd index 36d0955..58aa7f4 100644 --- a/gamemodes/zombiesurvival/zombiesurvival.fgd +++ b/gamemodes/zombiesurvival/zombiesurvival.fgd @@ -407,21 +407,21 @@ @PointClass studio("models/crossbow_bolt.mdl") base(Targetname,Angles) = prop_nail : "ZS: Allows you to manually place nails." [ // Keys - healthoverride(integer) : "Health Override" : 210 : "Sets the nail's maximum health to a specific number." - healthmultiplier(float) : "Health Multiply" : 1 : "Multiply the nail's default maximum health by this number." - unremovable(choices) : "Unremovable" : 0 : "Set to yes to make this nail unremovable by players." = + healthoverride(integer) : "Health Override" : -1 : "Sets the nail's maximum health to a specific number. Set to -1 or 0 to disable override" + healthmultiplier(float) : "Health Multiply" : 1 : "Multiply the nail's default maximum health by this number." + unremovable(choices) : "Unremovable" : 0 : "Set to yes to make this nail unremovable by players." = [ 1 : "Yes" 0 : "No" ] // Inputs - input sethealth(integer) : "Sets the nail's remaining health." - input attachto(string) : "Parent to this entity." - input nailto(string) : "Nail to this entity. Use attachto first and then this to weld the two. Use 'worldspawn' here to weld to the world." - input setname(string) : "Display this text as the owner name." - input setunremovable(integer) : "Set if this nail is unremovable." - input toggleunremovable(integer) : "Toggle unremovable state." + input sethealth(integer) : "Sets the nail's remaining health." + input attachto(target_destination) : "Parent to this entity." + input nailto(target_destination) : "Nail to this entity. Use attachto first and then this to weld the two. Use 'worldspawn' here to weld to the world." + input setname(string) : "Display this text as the owner name." + input setunremovable(integer) : "Set if this nail is unremovable." + input toggleunremovable(integer) : "Toggle unremovable state." ] @PointClass studio("models/Items/BoxMRounds.mdl") base(Targetname, Parentname, Angles) = prop_ammo : "ZS: Game Specific Ammo."