Fixed class switching bug in trigger_zombieclass
The entity no longer gets stuck in a loop when changing to "large" class.
This commit is contained in:
parent
9664c13a56
commit
82c66bbd90
1 changed files with 12 additions and 10 deletions
|
@ -66,13 +66,14 @@ end
|
||||||
|
|
||||||
function ENT:DoTouch(ent, class_name, death_class_name)
|
function ENT:DoTouch(ent, class_name, death_class_name)
|
||||||
if self.On and ent:IsPlayer() and ent:Alive() and ent:Team() == TEAM_UNDEAD then
|
if self.On and ent:IsPlayer() and ent:Alive() and ent:Team() == TEAM_UNDEAD then
|
||||||
|
local prev = ent:GetZombieClass()
|
||||||
|
if table.HasValue( self.OnlyWhenClass, prev ) or self.OnlyWhenClass[1] == -1 then
|
||||||
if class_name and class_name ~= string.lower(ent:GetZombieClassTable().Name) then
|
if class_name and class_name ~= string.lower(ent:GetZombieClassTable().Name) then
|
||||||
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()
|
|
||||||
if table.HasValue( self.OnlyWhenClass, prev ) or self.OnlyWhenClass[1] == -1 then
|
|
||||||
local prevpos = ent:GetPos()
|
local prevpos = ent:GetPos()
|
||||||
local prevang = ent:EyeAngles()
|
local prevang = ent:EyeAngles()
|
||||||
|
ent:KillSilent()
|
||||||
ent:SetZombieClass(k)
|
ent:SetZombieClass(k)
|
||||||
ent.DidntSpawnOnSpawnPoint = true
|
ent.DidntSpawnOnSpawnPoint = true
|
||||||
ent:UnSpectateAndSpawn()
|
ent:UnSpectateAndSpawn()
|
||||||
|
@ -83,11 +84,11 @@ 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
|
||||||
elseif death_class_name and death_class_name ~= string.lower(ent:GetZombieClassTable().Name) then
|
end
|
||||||
|
if death_class_name and death_class_name ~= string.lower(ent:GetZombieClassTable().Name) then
|
||||||
for k, v in ipairs(GAMEMODE.ZombieClasses) do
|
for k, v in ipairs(GAMEMODE.ZombieClasses) do
|
||||||
if string.lower(v.Name) == death_class_name then
|
if string.lower(v.Name) == death_class_name then
|
||||||
ent.DeathClass = k
|
ent.DeathClass = k
|
||||||
|
@ -96,6 +97,7 @@ function ENT:DoTouch(ent, class_name, death_class_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ENT:Touch(ent)
|
function ENT:Touch(ent)
|
||||||
|
|
Loading…
Reference in a new issue