From cb1818b86fa852027467fadfbfe3b3502473a206 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 29 Oct 2014 21:45:33 +0000 Subject: [PATCH] Added trigger_bossclass A new brush entity which turns the zombie who enters the volume into their chosen preferred boss: Keyvalues: enabled - Enable the brush entity. silent - If yes then then the server does not announce that a player has become the new boss. instantchange - If yes then anyone who gets swapped will instantly be changed right on the spot. Inputs: enable(void) : Enable the entity. disable(void) : Disable the entity. seton(integer) : Set Enabled keyvalue. setsilent(integer) : Set Silent keyvalue. setinstantchange(integer) : Set Change Instantly keyvalue. Outputs: OnBossTouched : Set when a boss starts touching the brush. Is not fired when a zombie becomes a boss in this volume. --- .../entities/trigger_bossclass/init.lua | 59 +++++++++++++++++++ gamemodes/zombiesurvival/zombiesurvival.fgd | 31 +++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua diff --git a/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua b/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua new file mode 100644 index 0000000..96bc077 --- /dev/null +++ b/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua @@ -0,0 +1,59 @@ +ENT.Type = "brush" + +function ENT:Initialize() + self:SetTrigger(true) + + if self.On == nil then self.On = true end + if self.Silent == nil then self.Silent = false end + if self.InstantChange == nil then self.InstantChange = true end +end + +function ENT:Think() +end + +function ENT:AcceptInput(name, activator, caller, args) + name = string.lower(name) + if string.sub(name, 1, 2) == "on" then + self:FireOutput(name, activator, caller, args) + elseif name == "seton" then + self.On = tonumber(args) == 1 + return true + elseif name == "enable" then + self.On = true + return true + elseif name == "disable" then + self.On = false + return true + elseif name == "setsilent" or name == "setinstantchange" then + self:KeyValue(string.sub(name, 4), args) + end +end + +function ENT:KeyValue(key, value) + key = string.lower(key) + if string.sub(key, 1, 2) == "on" then + self:AddOnOutput(key, value) + elseif key == "enabled" then + self.On = tonumber(value) == 1 + elseif key == "silent" then + self.Silent = tonumber(value) == 1 + elseif key == "instantchange" then + self.InstantChange = tonumber(value) == 1 + end +end + +function ENT:StartTouch(ent) + if self.On and ent:IsPlayer() and ent:Alive() and ent:Team() == TEAM_UNDEAD then + if ent:GetZombieClassTable().Boss then + self:Input("onbosstouched",ent,self,string.lower(ent:GetZombieClassTable().Name)) + else + local prevpos = ent:GetPos() + local prevang = ent:GetAngles() + GAMEMODE:SpawnBossZombie(ent, self.Silent) + if self.InstantChange then + ent:SetPos(prevpos) + ent:SetEyeAngles(prevang) + end + end + end +end diff --git a/gamemodes/zombiesurvival/zombiesurvival.fgd b/gamemodes/zombiesurvival/zombiesurvival.fgd index 36754f7..8e1b0c9 100644 --- a/gamemodes/zombiesurvival/zombiesurvival.fgd +++ b/gamemodes/zombiesurvival/zombiesurvival.fgd @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////////// -// NoXiousNet Zombie Survival FGD - Last Edit by Benjy (24th July 2014) // +// NoXiousNet Zombie Survival FGD - Last Edit by Benjy (29th October 2014) // // If there are any bugs with this file, or any additions that need to be made // // make a post at: http://www.noxiousnet.com/forums/index.php?topic=14910 // /////////////////////////////////////////////////////////////////////////////////// @@ -172,6 +172,35 @@ input setinstantchange(integer) : "Set Change Instantly keyvalue. " ] +@SolidClass base(Targetname) = trigger_bossclass : "ZS: A zombie that touches this brush" +[ + enabled(choices) : "Enabled" : 0 : "Enable the brush entity." = + [ + 1 : "Yes" + 0 : "No" + ] + + silent(choices) : "Silent" : 0 : "If yes then then the server does not announce that a player has become the new boss." = + [ + 1 : "Yes" + 0 : "No" + ] + + instantchange(choices) : "Change Instantly?" : 1 : "If yes then anyone who gets swapped will instantly be changed right on the spot." = + [ + 1 : "Yes" + 0 : "No" + ] + // Inputs + input enable(void) : "Enable the entity." + input disable(void) : "Disable the entity." + input seton(integer) : "Set Enabled keyvalue. " + input setsilent(integer) : "Set Silent keyvalue. " + input setinstantchange(integer) : "Set Change Instantly keyvalue. " + // Outputs + output OnBossTouched(void) : "Set when a boss starts touching the brush. Is not fired when a zombie becomes a boss in this volume." +] + /////////////////////////////////////////////////////////////////////////////////// // Gamemode - Point Entities ////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////