From 1e6db505d76edcb4f4d6cfd9ca7b1aa3022f1b3a Mon Sep 17 00:00:00 2001 From: Zyntex Date: Sat, 28 Oct 2023 14:26:43 +0200 Subject: [PATCH] feat: force viewmodel fov --- src/Features/FovChanger.cpp | 25 ++++++++++++++++++++++++- src/Features/FovChanger.hpp | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Features/FovChanger.cpp b/src/Features/FovChanger.cpp index d8bce2cb6..931796b75 100644 --- a/src/Features/FovChanger.cpp +++ b/src/Features/FovChanger.cpp @@ -11,17 +11,25 @@ FovChanger *fovChanger; FovChanger::FovChanger() - : defaultFov(0) { + : defaultFov(0), + viewmodelFov(0) { this->hasLoaded = true; } void FovChanger::SetFov(const int fov) { this->defaultFov = fov; this->Force(); } +void FovChanger::SetViewmodelFov(const int fov) { + this->viewmodelFov = fov; + this->Force(); +} void FovChanger::Force() { if (this->defaultFov != 0) { cl_fov.SetValue(this->defaultFov); } + if (this->viewmodelFov != 0) { + cl_viewmodelfov.SetValue(this->viewmodelFov); + } } ON_EVENT(SESSION_START) { @@ -55,3 +63,18 @@ CON_COMMAND_COMPLETION(sar_force_fov, "sar_force_fov - forces player FOV\n fovChanger->SetFov(fov); console->Print("Enabled forcing FOV: %i\n", fov); } + +CON_COMMAND(sar_force_viewmodel_fov, "sar_force_viewmodel_fov - forces viewmodel FOV\n") { + if (args.ArgC() != 2) { + return console->Print(sar_force_fov.ThisPtr()->m_pszHelpString); + } + + auto fov = std::atoi(args[1]); + if (fov == 0) { + fovChanger->SetViewmodelFov(fov); + return console->Print("Disabled forcing viewmodel FOV!\n"); + } + + fovChanger->SetViewmodelFov(fov); + console->Print("Enabled forcing viewmodel FOV: %i\n", fov); +} diff --git a/src/Features/FovChanger.hpp b/src/Features/FovChanger.hpp index 198f9aa08..bb9d170c7 100644 --- a/src/Features/FovChanger.hpp +++ b/src/Features/FovChanger.hpp @@ -5,10 +5,12 @@ class FovChanger : public Feature { private: int defaultFov; + int viewmodelFov; public: FovChanger(); void SetFov(const int fov); + void SetViewmodelFov(const int fov); void Force(); bool needToUpdate = false;