From 0904f2d0721c017d949c6228a8696f84fdd0132a Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Wed, 5 Jun 2024 21:06:02 +0700 Subject: [PATCH 1/7] Fix in-course timer HUD It's just some SetFont() calls come on. --- beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua b/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua index cb7b810..f7bf809 100644 --- a/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua +++ b/beatrun/gamemodes/beatrun/gamemode/sh/Checkpoints.lua @@ -236,6 +236,7 @@ function CourseHUD() if incourse then local text = string.FormattedTime(totaltime, "%02i:%02i:%02i") local w, _ = surface.GetTextSize(text) + surface.SetFont("BeatrunHUD") surface.SetTextPos(ScrW() * 0.85 - w * 0.5 + vpx, ScrH() * 0.075 + vpz) surface.DrawText(text) end @@ -265,6 +266,7 @@ function CourseHUD() local text = string.FormattedTime(pbtotal, "%02i:%02i:%02i") local w, h = surface.GetTextSize(text) + surface.SetFont("BeatrunHUD") surface.SetTextPos(ScrW() * 0.85 - w * 0.5 + vpx, ScrH() * 0.075 + h + vpz) surface.SetTextColor(255, 255, 255, 125) surface.DrawText(text) @@ -277,6 +279,7 @@ function CourseHUD() timealpha = math.max(0, timealpha - FrameTime() * 250) timecolor.a = math.min(255, timealpha) + surface.SetFont("BeatrunHUD") surface.SetTextPos(ScrW() * 0.5 - w * 0.5 + vpx, ScrH() * 0.3 + vpz) surface.SetTextColor(timecolor) surface.DrawText(timetext) From fdb3d703bf50ba931a294a31e95ff1138865bbc9 Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 00:11:31 +0700 Subject: [PATCH 2/7] Hacky fix for FOV behavior. For real (I think). --- .../gamemode/player_class/player_beatrun.lua | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 8865ca7..f36cf39 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -19,6 +19,8 @@ PLAYER.TauntCam = TauntCamera() PLAYER.WalkSpeed = 200 PLAYER.RunSpeed = 400 +local FOVModifierBlock = false -- trust me this is important -losttrackpad + function PLAYER:SetupDataTables() BaseClass.SetupDataTables(self) self.Player:NetworkVar("Float", 0, "MEMoveLimit") @@ -368,9 +370,15 @@ end function PLAYER:CalcView(view) local fov = GetConVar("Beatrun_FOV"):GetInt() local mult = (self.Player:InOverdrive() and 1.1) or 1 + local fixfovmult = 1 if CLIENT then - view.fov = fov * mult + if !LocalPlayer():GetActiveWeapon().ARC9 and !FOVModifierBlock then + fixfovmult = view.fov / fov + else + fixfovmult = 1 + end + view.fov = fov * mult * fixfovmult end if self.TauntCam:CalcView(view, self.Player, self.Player:IsPlayingTaunt()) then return true end @@ -528,4 +536,17 @@ hook.Add("PlayerSpawn", "ResetStateTransition", function(ply, transition) end) end) +hook.Add("PlayerSwitchWeapon", "BeatrunSwitchFOVFix", function(ply, oldwep) + -- This ENTIRE hook is for dealing with ARC9's stupid FOV reset + -- behavior after switching away from an ARC9 SWEP. + + -- Yes this is hacky as hell. + FOVModifierBlock = true + ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) + timer.Simple(0, function() + ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) + end) + timer.Simple(0.8, function() FOVModifierBlock = false end) +end) + player_manager.RegisterClass("player_beatrun", PLAYER, "player_default") From f626a1d1a70fea645397406e0bf77b9b738026d3 Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 12:46:16 +0700 Subject: [PATCH 3/7] Further polish up the FOV fix --- .../gamemode/player_class/player_beatrun.lua | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index f36cf39..7b879f3 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -7,6 +7,11 @@ if CLIENT then CreateConVar("cl_weaponcolor", "0.30 1.80 2.10", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The value is a Vector - so between 0-1 - not between 0-255") 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("Beatrun_Debug_FOVFix", "0", {FCVAR_DONTRECORD, FCVAR_UNREGISTERED}, "DEBUG: Toggles the FOV fix on or off.") + -- 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 "" end local PLAYER = {} @@ -373,12 +378,25 @@ function PLAYER:CalcView(view) local fixfovmult = 1 if CLIENT then - if !LocalPlayer():GetActiveWeapon().ARC9 and !FOVModifierBlock then - fixfovmult = view.fov / fov + if GetConVar("Beatrun_Debug_FOVFix"):GetBool() then + -- VERY hacky and dirty code and I apologize in advance + + if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then + -- SP weapon swap detection, proper hook isn't called in SP + FOVModifierBlock = true + timer.Simple(1, function() FOVModifierBlock = false end) + end + + if !FOVModifierBlock and !LocalPlayer():GetActiveWeapon().ARC9 then + fixfovmult = view.fov / fov + else + fixfovmult = 1 + end + view.fov = fov * mult * fixfovmult + lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass() else - fixfovmult = 1 + view.fov = fov * mult end - view.fov = fov * mult * fixfovmult end if self.TauntCam:CalcView(view, self.Player, self.Player:IsPlayingTaunt()) then return true end @@ -541,12 +559,12 @@ hook.Add("PlayerSwitchWeapon", "BeatrunSwitchFOVFix", function(ply, oldwep) -- behavior after switching away from an ARC9 SWEP. -- Yes this is hacky as hell. - FOVModifierBlock = true - ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) - timer.Simple(0, function() + if ply:GetInfoNum("Beatrun_Debug_FOVFix", 1) == 1 then ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) - end) - timer.Simple(0.8, function() FOVModifierBlock = false end) + timer.Simple(0, function() + ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) + end) + end end) player_manager.RegisterClass("player_beatrun", PLAYER, "player_default") From 5a3edb21f8631d61a92070a8d8b1a55fdf48efed Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 13:26:48 +0700 Subject: [PATCH 4/7] Properly squash FOV bugs --- .../gamemode/player_class/player_beatrun.lua | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 7b879f3..6029c6c 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -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_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. local lframeswepclass = lframeswepclass or "" @@ -373,30 +374,28 @@ function PLAYER:CreateMove(cmd) end function PLAYER:CalcView(view) - local fov = GetConVar("Beatrun_FOV"):GetInt() local mult = (self.Player:InOverdrive() and 1.1) or 1 local fixfovmult = 1 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 - if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then - -- SP weapon swap detection, proper hook isn't called in SP - FOVModifierBlock = true - timer.Simple(1, function() FOVModifierBlock = false end) - end + local fov = GetConVar("Beatrun_FOV"):GetInt() - if !FOVModifierBlock and !LocalPlayer():GetActiveWeapon().ARC9 then - fixfovmult = view.fov / fov - else - fixfovmult = 1 - end - view.fov = fov * mult * fixfovmult - lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass() - else - view.fov = fov * mult + if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then + -- SP clientside weapon swap detection + FOVModifierBlock = true + timer.Simple(1, function() FOVModifierBlock = false end) end + + if !FOVModifierBlock and !LocalPlayer():GetActiveWeapon().ARC9 then + fixfovmult = view.fov / fov + else + fixfovmult = 1 + end + + view.fov = GetConVar("Beatrun_FOV"):GetInt() * mult * fixfovmult + lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass() 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) -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 -- behavior after switching away from an ARC9 SWEP. -- Yes this is hacky as hell. - if ply:GetInfoNum("Beatrun_Debug_FOVFix", 1) == 1 then + ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) + timer.Simple(0, function() ply:SetFOV(ply:GetInfoNum("Beatrun_FOV", 120)) - timer.Simple(0, function() - 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) From 5723dbed1088bd2f705008007f596451d9f42aa2 Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 13:29:07 +0700 Subject: [PATCH 5/7] Remove some unused stuff --- .../beatrun/gamemode/player_class/player_beatrun.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 6029c6c..774cf5a 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -8,10 +8,6 @@ if CLIENT then 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("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. - local lframeswepclass = lframeswepclass or "" end From cfdf6fedac5216e8deb746037b8d9aef42879237 Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 13:34:34 +0700 Subject: [PATCH 6/7] Fix invalid (S)WEP causing issues --- .../gamemode/player_class/player_beatrun.lua | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 774cf5a..5687aa4 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -378,20 +378,24 @@ function PLAYER:CalcView(view) local fov = GetConVar("Beatrun_FOV"):GetInt() - if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then - -- SP clientside weapon swap detection - FOVModifierBlock = true - timer.Simple(1, function() FOVModifierBlock = false end) - end + if IsValid(LocalPlayer():GetActiveWeapon()) then + if lframeswepclass != LocalPlayer():GetActiveWeapon():GetClass() then + -- SP clientside weapon swap detection + FOVModifierBlock = true + timer.Simple(1, function() FOVModifierBlock = false end) + end - if !FOVModifierBlock and !LocalPlayer():GetActiveWeapon().ARC9 then - fixfovmult = view.fov / fov + if !FOVModifierBlock and !LocalPlayer():GetActiveWeapon().ARC9 then + fixfovmult = view.fov / fov + else + fixfovmult = 1 + end + + view.fov = fov * mult * fixfovmult + lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass() else - fixfovmult = 1 + view.fov = fov * mult end - - view.fov = GetConVar("Beatrun_FOV"):GetInt() * mult * fixfovmult - lframeswepclass = LocalPlayer():GetActiveWeapon():GetClass() end if self.TauntCam:CalcView(view, self.Player, self.Player:IsPlayingTaunt()) then return true end From 3907207dc98cd0e1e59d6e3079e6b37308e2581f Mon Sep 17 00:00:00 2001 From: LostTrackpad Date: Thu, 6 Jun 2024 19:09:37 +0700 Subject: [PATCH 7/7] Hopefully fix FOV changing --- .../gamemode/player_class/player_beatrun.lua | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua index 5687aa4..dc54e13 100644 --- a/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua +++ b/beatrun/gamemodes/beatrun/gamemode/player_class/player_beatrun.lua @@ -9,6 +9,11 @@ if CLIENT then CreateConVar("cl_playerbodygroups", "0", {FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD}, "The bodygroups to use, if the model has any") local lframeswepclass = lframeswepclass or "" + local fovdelaytoggle = false +end + +if SERVER then + util.AddNetworkString("Beatrun_ClientFOVChange") end local PLAYER = {} @@ -565,10 +570,27 @@ hook.Add("PlayerSwitchWeapon", "BeatrunSwitchFOVFix", function(ply) end) cvars.AddChangeCallback("Beatrun_FOV", function(convar, oldval, newval) - -- Fixes live FOV changes. I'm not kidding. - if CLIENT then + -- Live FOV change in SP, needs work for MP + if CLIENT and game.SinglePlayer() then LocalPlayer():SetFOV(newval) + elseif CLIENT then + FOVModifierBlock = true + timer.Create("beatrunfovdelay", 0.16, 1, function() + FOVModifierBlock = false + if !FOVModifierBlock then + net.Start("Beatrun_ClientFOVChange") + net.WriteInt(newval, 16) + net.SendToServer() + FOVModifierBlock = true + end + end) end end) +if SERVER then + net.Receive("Beatrun_ClientFOVChange", function(len, ply) + ply:SetFOV((net.ReadInt(16))) + end) +end + player_manager.RegisterClass("player_beatrun", PLAYER, "player_default")