From cb1818b86fa852027467fadfbfe3b3502473a206 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 29 Oct 2014 21:45:33 +0000 Subject: [PATCH 1/3] 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 ////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// From e42753beae24588dbf699d7ad497ec1e705fa454 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 29 Oct 2014 21:50:21 +0000 Subject: [PATCH 2/3] Fixed angles-snap to (0,0,0) on forced classchange Edited trigger_zombieclass so that it saves the original view angle of the player --- .../entities/entities/trigger_zombieclass/init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua b/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua index 99d7088..2de4653 100644 --- a/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua @@ -52,6 +52,7 @@ function ENT:Touch(ent) if string.lower(v.Name) == self.TouchClass then local prev = ent:GetZombieClass() local prevpos = ent:GetPos() + local prevang = ent:GetAngles() ent:SetZombieClass(k) ent:UnSpectateAndSpawn() if self.OneTime then @@ -59,6 +60,7 @@ function ENT:Touch(ent) end if self.InstantChange then ent:SetPos(prevpos) + ent:SetEyeAngles(prevang) end break @@ -83,6 +85,7 @@ function ENT:EndTouch(ent) if string.lower(v.Name) == self.EndTouchClass then local prev = ent:GetZombieClass() local prevpos = ent:GetPos() + local prevang = ent:GetAngles() ent:SetZombieClass(k) ent:UnSpectateAndSpawn() if self.OneTime then @@ -90,6 +93,7 @@ function ENT:EndTouch(ent) end if self.InstantChange then ent:SetPos(prevpos) + ent:SetEyeAngles(prevang) end break From f2bb74219a7488ad48fa0730860b6e9e8da3a5f6 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 30 Oct 2014 13:39:01 +0000 Subject: [PATCH 3/3] Replaced GetAngles() with EyeAngles() --- .../zombiesurvival/entities/entities/trigger_bossclass/init.lua | 2 +- .../entities/entities/trigger_zombieclass/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua b/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua index 96bc077..d55206b 100644 --- a/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/trigger_bossclass/init.lua @@ -48,7 +48,7 @@ function ENT:StartTouch(ent) self:Input("onbosstouched",ent,self,string.lower(ent:GetZombieClassTable().Name)) else local prevpos = ent:GetPos() - local prevang = ent:GetAngles() + local prevang = ent:EyeAngles() GAMEMODE:SpawnBossZombie(ent, self.Silent) if self.InstantChange then ent:SetPos(prevpos) diff --git a/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua b/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua index 2de4653..29ab897 100644 --- a/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua +++ b/gamemodes/zombiesurvival/entities/entities/trigger_zombieclass/init.lua @@ -52,7 +52,7 @@ function ENT:Touch(ent) if string.lower(v.Name) == self.TouchClass then local prev = ent:GetZombieClass() local prevpos = ent:GetPos() - local prevang = ent:GetAngles() + local prevang = ent:EyeAngles() ent:SetZombieClass(k) ent:UnSpectateAndSpawn() if self.OneTime then