Merge pull request #79 from BClark09/master

Added trigger_zombieclass class filtering
This commit is contained in:
William Moodhe / JetBoom 2014-12-23 23:06:28 -05:00
commit afc59337c2
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.InstantChange == nil then self.InstantChange = true end
if self.OnlyWhenClass == nil then self.OnlyWhenClass = -1 end
end
function ENT:Think()
@ -21,7 +22,7 @@ function ENT:AcceptInput(name, caller, activator, arg)
elseif name == "disable" then
self.On = false
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)
end
end
@ -32,6 +33,19 @@ function ENT:KeyValue(key, value)
self.On = tonumber(value) == 1
elseif key == "touchclass" then
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
self.EndTouchClass = string.lower(value)
elseif key == "touchdeathclass" then
@ -51,19 +65,20 @@ function ENT:DoTouch(ent, class_name, death_class_name)
for k, v in ipairs(GAMEMODE.ZombieClasses) do
if string.lower(v.Name) == class_name then
local prev = ent:GetZombieClass()
local prevpos = ent:GetPos()
local prevang = ent:EyeAngles()
ent:SetZombieClass(k)
ent.DidntSpawnOnSpawnPoint = true
ent:UnSpectateAndSpawn()
if self.OneTime then
ent.DeathClass = prev
if self.OnlyWhenClass == prev or self.OnlyWhenClass == -1 then
local prevpos = ent:GetPos()
local prevang = ent:EyeAngles()
ent:SetZombieClass(k)
ent.DidntSpawnOnSpawnPoint = true
ent:UnSpectateAndSpawn()
if self.OneTime then
ent.DeathClass = prev
end
if self.InstantChange then
ent:SetPos(prevpos)
ent:SetEyeAngles(prevang)
end
end
if self.InstantChange then
ent:SetPos(prevpos)
ent:SetEyeAngles(prevang)
end
break
end
end

View file

@ -154,6 +154,36 @@
"gore child" : "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." =
[
1 : "Yes"
@ -175,6 +205,7 @@
input setendtouchdeathclass(string) : "Set On Leaving Respawn Class keyvalue."
input setonetime(integer) : "Set One Time 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"