Added trigger_zombieclass class filtering

The trigger_zombieclass entity now has a control which can enable the
class change only when the correct zombie class has entered the brush.
This commit is contained in:
Ben 2014-12-24 03:16:15 +00:00
parent 0c3d50dfad
commit d5c00a6496
2 changed files with 59 additions and 13 deletions

View file

@ -5,6 +5,7 @@ function ENT:Initialize()
if self.On == nil then self.On = true end if self.On == nil then self.On = true end
if self.InstantChange == nil then self.InstantChange = true end if self.InstantChange == nil then self.InstantChange = true end
if self.OnlyWhenClass == nil then self.OnlyWhenClass = -1 end
end end
function ENT:Think() function ENT:Think()
@ -21,7 +22,7 @@ function ENT:AcceptInput(name, caller, activator, arg)
elseif name == "disable" then elseif name == "disable" then
self.On = false self.On = false
return true return true
elseif name == "settouchclass" or name == "setendtouchclass" or name == "settouchdeathclass" or name == "setendtouchdeathclass" or name == "setonetime" or name == "setinstantchange" then elseif name == "settouchclass" or name == "setendtouchclass" or name == "settouchdeathclass" or name == "setendtouchdeathclass" or name == "setonetime" or name == "setinstantchange" or name == "setonlywhenclass" then
self:KeyValue(string.sub(name, 4), arg) self:KeyValue(string.sub(name, 4), arg)
end end
end end
@ -32,6 +33,19 @@ function ENT:KeyValue(key, value)
self.On = tonumber(value) == 1 self.On = tonumber(value) == 1
elseif key == "touchclass" then elseif key == "touchclass" then
self.TouchClass = string.lower(value) self.TouchClass = string.lower(value)
elseif key == "onlywhenclass" then
if value == "disabled" then
self.OnlyWhenClass = -1
else
for k, v in ipairs(GAMEMODE.ZombieClasses) do
if string.lower(v.Name) == value then
self.OnlyWhenClass = k
break
else
self.OnlyWhenClass = -1
end
end
end
elseif key == "endtouchclass" then elseif key == "endtouchclass" then
self.EndTouchClass = string.lower(value) self.EndTouchClass = string.lower(value)
elseif key == "touchdeathclass" then elseif key == "touchdeathclass" then
@ -51,6 +65,7 @@ function ENT:DoTouch(ent, class_name, death_class_name)
for k, v in ipairs(GAMEMODE.ZombieClasses) do for k, v in ipairs(GAMEMODE.ZombieClasses) do
if string.lower(v.Name) == class_name then if string.lower(v.Name) == class_name then
local prev = ent:GetZombieClass() local prev = ent:GetZombieClass()
if self.OnlyWhenClass == prev or self.OnlyWhenClass == -1 then
local prevpos = ent:GetPos() local prevpos = ent:GetPos()
local prevang = ent:EyeAngles() local prevang = ent:EyeAngles()
ent:SetZombieClass(k) ent:SetZombieClass(k)
@ -63,7 +78,7 @@ function ENT:DoTouch(ent, class_name, death_class_name)
ent:SetPos(prevpos) ent:SetPos(prevpos)
ent:SetEyeAngles(prevang) ent:SetEyeAngles(prevang)
end end
end
break break
end end
end end

View file

@ -154,6 +154,36 @@
"gore child" : "Gore Child" "gore child" : "Gore Child"
"giga gore child" : "Giga Gore Child" "giga gore child" : "Giga Gore Child"
] ]
onlywhenclass(choices) : "Player Must Be This Class" : "disabled" : "Set this to a specific class to change only these zombie types." =
[
"disabled" : "Disabled"
"will o' wisp" : "Will O' Wisp"
"zombie" : "Zombie"
"classic Zombie" : "Classic Zombie"
"fresh dead" : "Fresh Dead"
"zombie legs" : "Zombie Legs"
"zombie torso" : "Zombie Torso"
"flesh creeper" : "Flesh Creeper"
"headcrab" : "Headcrab"
"fast headcrab" : "Fast Headcrab"
"poison headcrab" : "Poison Headcrab"
"ghoul" : "Ghoul"
"wraith" : "Wraith"
"bloated zombie" : "Bloated Zombie"
"fast zombie" : "Fast Zombie"
"fast zombie legs" : "Fast Zombie Legs"
"poison zombie" : "Poison Zombie"
"chem zombie" : "Chem Zombie"
"nightmare" : "Nightmare"
"puke pus" : "Puke Pus"
"the tickle monster" : "The Tickle Monster"
"shade" : "Shade"
"bonemesh" : "Bonemesh"
"the butcher" : "The Butcher"
"super zombie" : "Super Zombie"
"gore child" : "Gore Child"
"giga gore child" : "Giga Gore Child"
]
onetime(choices) : "One Time?" : 0 : "If yes then anyone who gets swapped will be respawned as the last class they were before the change." = onetime(choices) : "One Time?" : 0 : "If yes then anyone who gets swapped will be respawned as the last class they were before the change." =
[ [
1 : "Yes" 1 : "Yes"
@ -175,6 +205,7 @@
input setendtouchdeathclass(string) : "Set On Leaving Respawn Class keyvalue." input setendtouchdeathclass(string) : "Set On Leaving Respawn Class keyvalue."
input setonetime(integer) : "Set One Time keyvalue. <boolean>" input setonetime(integer) : "Set One Time keyvalue. <boolean>"
input setinstantchange(integer) : "Set Change Instantly keyvalue. <boolean>" input setinstantchange(integer) : "Set Change Instantly keyvalue. <boolean>"
input setonlywhenclass(string) : "Set Only When Class keyvalue."
] ]
@SolidClass base(Targetname) = trigger_bossclass : "ZS: A zombie that touches this brush" @SolidClass base(Targetname) = trigger_bossclass : "ZS: A zombie that touches this brush"