Fixing UndisguiseSilent (how did I not notice that?) and 3rd person crashing game on death.

master
Icedream 2013-12-24 04:07:08 +01:00
parent dde7e30d6d
commit 6c636543ad
2 changed files with 33 additions and 31 deletions

View File

@ -30,6 +30,8 @@
hook.Add("CalcView", "Disguiser.ThirdPersonCalcView", function(player, pos, angles, fov) hook.Add("CalcView", "Disguiser.ThirdPersonCalcView", function(player, pos, angles, fov)
local smoothscale = 1 local smoothscale = 1
if !IsValid(player) then return end
if player:GetNetworkedBool("thirdperson") then if player:GetNetworkedBool("thirdperson") then
angles = player:GetAimVector():Angle() angles = player:GetAimVector():Angle()
@ -54,7 +56,6 @@ hook.Add("CalcView", "Disguiser.ThirdPersonCalcView", function(player, pos, angl
end end
// smoothing - approaches a bit more slowly to the actual target position // smoothing - approaches a bit more slowly to the actual target position
pos = targetpos
pos = Vector( pos = Vector(
math.Approach(pos.x, targetpos.x, math.abs(targetpos.x - pos.x) * smoothscale), math.Approach(pos.x, targetpos.x, math.abs(targetpos.x - pos.x) * smoothscale),
math.Approach(pos.y, targetpos.y, math.abs(targetpos.y - pos.y) * smoothscale), math.Approach(pos.y, targetpos.y, math.abs(targetpos.y - pos.y) * smoothscale),
@ -92,10 +93,11 @@ end)
hook.Add("HUDPaint", "Disguiser.ThirdPersonHUDPaint", function() hook.Add("HUDPaint", "Disguiser.ThirdPersonHUDPaint", function()
local player = LocalPlayer() local player = LocalPlayer()
if !player:GetNetworkedBool("thirdperson") then if !IsValid(player) then
return return
end end
if player:GetNetworkedBool("thirdperson") && player:Alive() then
// trace from muzzle to hit pos // trace from muzzle to hit pos
local t = {} local t = {}
t.start = player:GetShootPos() t.start = player:GetShootPos()
@ -126,6 +128,7 @@ hook.Add("HUDPaint", "Disguiser.ThirdPersonHUDPaint", function()
surface.DrawLine(pos.x, pos.y + offset, pos.x, pos.y + offset2) surface.DrawLine(pos.x, pos.y + offset, pos.x, pos.y + offset2)
surface.DrawLine(pos.x - 1, pos.y, pos.x + 1, pos.y) surface.DrawLine(pos.x - 1, pos.y, pos.x + 1, pos.y)
surface.DrawLine(pos.x, pos.y - 1, pos.x, pos.y + 1) surface.DrawLine(pos.x, pos.y - 1, pos.x, pos.y + 1)
end
end) end)
hook.Add("HUDShouldDraw", "Disguiser.ThirdPersonHUDShouldDraw", function(name) hook.Add("HUDShouldDraw", "Disguiser.ThirdPersonHUDShouldDraw", function(name)

View File

@ -227,7 +227,6 @@ function SWEP:Undisguise()
umsg.End() umsg.End()
// Pop! // Pop!
UndisguiseSilent()
owner:EmitSound("Disguiser.Undisguise") owner:EmitSound("Disguiser.Undisguise")
// We're no longer disguised // We're no longer disguised