Skip to content

Commit

Permalink
feat: force viewmodel fov
Browse files Browse the repository at this point in the history
  • Loading branch information
hero622 authored and NeKzor committed Nov 6, 2023
1 parent 9b2a01e commit 1e6db50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Features/FovChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -55,3 +63,18 @@ CON_COMMAND_COMPLETION(sar_force_fov, "sar_force_fov <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 <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);
}
2 changes: 2 additions & 0 deletions src/Features/FovChanger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1e6db50

Please sign in to comment.