From d5c00a64966c19b3b014e459f9036b1b06ac1077 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 24 Dec 2014 03:16:15 +0000 Subject: [PATCH] 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. --- .../entities/trigger_zombieclass/init.lua | 41 +++++++++++++------ gamemodes/zombiesurvival/zombiesurvival.fgd | 31 ++++++++++++++ 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua b/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua index 8a5080b..3173014 100644 --- a/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua @@ -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 diff --git a/gamemodes/zombiesurvival/zombiesurvival.fgd b/gamemodes/zombiesurvival/zombiesurvival.fgd index 58aa7f4..24d7b97 100644 --- a/gamemodes/zombiesurvival/zombiesurvival.fgd +++ b/gamemodes/zombiesurvival/zombiesurvival.fgd @@ -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. " input setinstantchange(integer) : "Set Change Instantly keyvalue. " + input setonlywhenclass(string) : "Set Only When Class keyvalue." ] @SolidClass base(Targetname) = trigger_bossclass : "ZS: A zombie that touches this brush"