Make thirdperson and isDisguised independent to reduce chances of PlayerDeath hook conflicts.

master v0.5-beta
Icedream 2014-03-03 01:22:59 +01:00
parent f65cc5fb03
commit 1799760eab
1 changed files with 8 additions and 7 deletions

View File

@ -149,11 +149,7 @@ function SWEP:Disguise(entity)
// Apply new hull // Apply new hull
local obbmaxs = entity:OBBMaxs() local obbmaxs = entity:OBBMaxs()
local obbmins = entity:OBBMins() local obbmins = entity:OBBMins()
/*
local obbmargin = Vector(2, 2, 0)
obbmaxs = obbmaxs + obbmargin
obbmins = obbmins - obbmargin
*/
// Look for correction values // Look for correction values
local pcfg = self:GetPropConfig(entity:GetModel()) local pcfg = self:GetPropConfig(entity:GetModel())
if !!pcfg["OBBMaxsCorrection"] then if !!pcfg["OBBMaxsCorrection"] then
@ -333,13 +329,18 @@ end
hook.Add("PlayerDeath", "Disguiser.ThirdPersonDeath", function(victim, inflictor, killer) hook.Add("PlayerDeath", "Disguiser.ThirdPersonDeath", function(victim, inflictor, killer)
// Escape third-person mode // Escape third-person mode
if victim:GetNWBool("thirdperson") || victim:GetNWBool("isDisguised") then if victim:GetNWBool("thirdperson") then
victim:SetNetworkedBool("thirdperson", false)
local ventity = victim:GetViewEntity() local ventity = victim:GetViewEntity()
if (IsValid(ventity)) then if (IsValid(ventity)) then
victim:SetViewEntity(victim) victim:SetViewEntity(victim)
ventity:Remove() ventity:Remove()
end end
victim:SetNetworkedBool("thirdperson", false) end
// Undisguise basically but with a few tweaks to avoid some bugs
if victim:GetNWBool("isDisguised") then
victim:SetNetworkedBool("isDisguised", false) victim:SetNetworkedBool("isDisguised", false)
// fake entity for spectacular death! // fake entity for spectacular death!