Added nail functions previously described in FGD

+NailUnremovable
+SetHealth
+HealthOveride
+HealthMultiplier
This commit is contained in:
Ben 2014-12-18 02:00:45 +00:00
parent 2678e83ef9
commit 3e40769454
3 changed files with 34 additions and 12 deletions

View file

@ -17,6 +17,9 @@ end)
function ENT:Initialize() function ENT:Initialize()
self:SetModel("models/crossbow_bolt.mdl") 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 end
function ENT:OnDamaged(damage, attacker, inflictor, dmginfo) function ENT:OnDamaged(damage, attacker, inflictor, dmginfo)
@ -48,6 +51,8 @@ function ENT:AttachTo(baseent, attachent, physbone, physbone2)
if baseent:GetBarricadeHealth() == 0 then if baseent:GetBarricadeHealth() == 0 then
local health = baseent:GetDefaultBarricadeHealth() local health = baseent:GetDefaultBarricadeHealth()
if self.HealthOveride > 0 then health = self.HealthOveride end
health = health * self.HealthMultiplier
baseent:SetMaxBarricadeHealth(health) baseent:SetMaxBarricadeHealth(health)
baseent:SetBarricadeHealth(health) baseent:SetBarricadeHealth(health)
baseent:SetBarricadeRepairs(baseent:GetMaxBarricadeRepairs()) baseent:SetBarricadeRepairs(baseent:GetMaxBarricadeRepairs())
@ -84,6 +89,11 @@ function ENT:SetDeployer(pl)
end end
end end
function ENT:SetNewHealth(health)
baseent = self:GetBaseEntity()
baseent:SetBarricadeHealth(health)
end
function ENT:AcceptInput(name, activator, caller, args) function ENT:AcceptInput(name, activator, caller, args)
name = string.lower(name) name = string.lower(name)
if name == "attachto" then if name == "attachto" then
@ -105,13 +115,17 @@ function ENT:AcceptInput(name, activator, caller, args)
elseif name == "setname" or name == "setdeployer" then elseif name == "setname" or name == "setdeployer" then
self:SetDeployer(args) self:SetDeployer(args)
return true
elseif name == "sethealth" then
self:SetNewHealth(args)
return true return true
elseif name == "setunremoveable" or name == "setunremovable" then elseif name == "setunremoveable" or name == "setunremovable" then
self.m_NailUnremovable = tonumber(args) == 1 self.m_NailUnremovable = tonumber(args) == 1
return true return true
elseif name == "toggleunremoveable" or name == "toggleunremovable" then elseif name == "toggleunremoveable" or name == "toggleunremovable" then
self.m_NailUnremovable = not self.m_NailRemovable self.m_NailUnremovable = not self.m_NailUnremovable
return true return true
end end
@ -133,6 +147,10 @@ end
function ENT:KeyValue(key, value) function ENT:KeyValue(key, value)
key = string.lower(key) key = string.lower(key)
if key == "unremoveable" or key == "unremovable" then 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
end end

View file

@ -470,8 +470,12 @@ function GM:CanPlaceNail(pl, tr)
end end
function GM:CanRemoveNail(pl, nail) function GM:CanRemoveNail(pl, nail)
if nail.m_NailUnremovable then
return false
else
return true return true
end end
end
function GM:GetDamageResistance(fearpower) function GM:GetDamageResistance(fearpower)
return fearpower * 0.35 return fearpower * 0.35

View file

@ -407,7 +407,7 @@
@PointClass studio("models/crossbow_bolt.mdl") base(Targetname,Angles) = prop_nail : "ZS: Allows you to manually place nails." @PointClass studio("models/crossbow_bolt.mdl") base(Targetname,Angles) = prop_nail : "ZS: Allows you to manually place nails."
[ [
// Keys // Keys
healthoverride(integer) : "Health Override" : 210 : "Sets the nail's maximum health to a specific number." 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." 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." = unremovable(choices) : "Unremovable" : 0 : "Set to yes to make this nail unremovable by players." =
[ [
@ -417,8 +417,8 @@
// Inputs // Inputs
input sethealth(integer) : "Sets the nail's remaining health." input sethealth(integer) : "Sets the nail's remaining health."
input attachto(string) : "Parent to this entity." input attachto(target_destination) : "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 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 setname(string) : "Display this text as the owner name."
input setunremovable(integer) : "Set if this nail is unremovable." input setunremovable(integer) : "Set if this nail is unremovable."
input toggleunremovable(integer) : "Toggle unremovable state." input toggleunremovable(integer) : "Toggle unremovable state."