mirror of
https://github.com/JonnyBro/beatrun.git
synced 2024-12-29 21:33:02 +05:00
Properly squash FOV bugs
This commit is contained in:
parent
f626a1d1a7
commit
5a3edb21f8
1 changed files with 27 additions and 23 deletions
|
@ -8,7 +8,8 @@ if CLIENT then
|
||||||
CreateConVar("cl_playerskin", "0", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The skin to use, if the model has any")
|
CreateConVar("cl_playerskin", "0", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The skin to use, if the model has any")
|
||||||
CreateConVar("cl_playerbodygroups", "0", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The bodygroups to use, if the model has any")
|
CreateConVar("cl_playerbodygroups", "0", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The bodygroups to use, if the model has any")
|
||||||
|
|
||||||
CreateConVar("Beatrun_Debug_FOVFix", "0", {FCVAR_DONTRECORD, FCVAR_UNREGISTERED}, "DEBUG: Toggles the FOV fix on or off.")
|
--CreateConVar("Beatrun_Debug_FOVFix", 0, {FCVAR_DONTRECORD, FCVAR_UNREGISTERED, FCVAR_USERINFO}, "DEBUG: Toggles the FOV fix on or off.", 0, 1)
|
||||||
|
CreateClientConVar("Beatrun_Debug_FOVFix", 1, false, true, "debugging", 0, 1)
|
||||||
-- Don't record this CVar's value. Don't want players wondering how they broke FOV behavior even after restarting GMod.
|
-- Don't record this CVar's value. Don't want players wondering how they broke FOV behavior even after restarting GMod.
|
||||||
|
|
||||||
local lframeswepclass = lframeswepclass or ""
|
local lframeswepclass = lframeswepclass or ""
|
||||||
|
@ -373,16 +374,16 @@ function PLAYER:CreateMove(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PLAYER:CalcView(view)
|
function PLAYER:CalcView(view)
|
||||||
local fov = GetConVar("Beatrun_FOV"):GetInt()
|
|
||||||
local mult = (self.Player:InOverdrive() and 1.1) or 1
|
local mult = (self.Player:InOverdrive() and 1.1) or 1
|
||||||
local fixfovmult = 1
|
local fixfovmult = 1
|
||||||
|
|
||||||
if CLIENT then
|
if CLIENT then
|
||||||
if GetConVar("Beatrun_Debug_FOVFix"):GetBool() then
|
|
||||||
-- VERY hacky and dirty code and I apologize in advance
|
-- VERY hacky and dirty code and I apologize in advance
|
||||||
|
|
||||||
|
local fov = GetConVar("Beatrun_FOV"):GetInt()
|
||||||
|
|
||||||
if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then
|
if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then
|
||||||
-- SP weapon swap detection, proper hook isn't called in SP
|
-- SP clientside weapon swap detection
|
||||||
FOVModifierBlock = true
|
FOVModifierBlock = true
|
||||||
timer.Simple(1, function() FOVModifierBlock = false end)
|
timer.Simple(1, function() FOVModifierBlock = false end)
|
||||||
end
|
end
|
||||||
|
@ -392,11 +393,9 @@ function PLAYER:CalcView(view)
|
||||||
else
|
else
|
||||||
fixfovmult = 1
|
fixfovmult = 1
|
||||||
end
|
end
|
||||||
view.fov = fov * mult * fixfovmult
|
|
||||||
|
view.fov = GetConVar("Beatrun_FOV"):GetInt() * mult * fixfovmult
|
||||||
lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass()
|
lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass()
|
||||||
else
|
|
||||||
view.fov = fov * mult
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.TauntCam:CalcView(view, self.Player, self.Player:IsPlayingTaunt()) then return true end
|
if self.TauntCam:CalcView(view, self.Player, self.Player:IsPlayingTaunt()) then return true end
|
||||||
|
@ -554,16 +553,21 @@ hook.Add("PlayerSpawn", "ResetStateTransition", function(ply, transition)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
hook.Add("PlayerSwitchWeapon", "BeatrunSwitchFOVFix", function(ply, oldwep)
|
hook.Add("PlayerSwitchWeapon", "BeatrunSwitchFOVFix", function(ply)
|
||||||
-- This ENTIRE hook is for dealing with ARC9's stupid FOV reset
|
-- This ENTIRE hook is for dealing with ARC9's stupid FOV reset
|
||||||
-- behavior after switching away from an ARC9 SWEP.
|
-- behavior after switching away from an ARC9 SWEP.
|
||||||
|
|
||||||
-- Yes this is hacky as hell.
|
-- Yes this is hacky as hell.
|
||||||
if ply:GetInfoNum("Beatrun_Debug_FOVFix", 1) == 1 then
|
|
||||||
ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120))
|
ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120))
|
||||||
timer.Simple(0, function()
|
timer.Simple(0, function()
|
||||||
ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120))
|
ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120))
|
||||||
end)
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
cvars.AddChangeCallback("Beatrun_FOV", function(convar, oldval, newval)
|
||||||
|
-- Fixes live FOV changes. I'm not kidding.
|
||||||
|
if CLIENT then
|
||||||
|
LocalPlayer():SetFOV(newval)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue