From 75aff9d86068be4ef4d82d1f7fb32aedca256ca7 Mon Sep 17 00:00:00 2001 From: joey <91229708+j-oey@users.noreply.github.com> Date: Mon, 15 May 2023 11:33:20 -0400 Subject: [PATCH] feat: add increased bullet penetration dvar (#704) Co-authored-by: FutureRave --- src/client/component/bullet.cpp | 44 +++++++++++++++++++++++++++++++++ src/client/game/dvars.cpp | 2 ++ src/client/game/dvars.hpp | 2 ++ 3 files changed, 48 insertions(+) create mode 100644 src/client/component/bullet.cpp diff --git a/src/client/component/bullet.cpp b/src/client/component/bullet.cpp new file mode 100644 index 0000000..6b25a3e --- /dev/null +++ b/src/client/component/bullet.cpp @@ -0,0 +1,44 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include + +namespace bullet +{ + namespace + { + utils::hook::detour bg_get_surface_penetration_depth_hook; + + float bg_get_surface_penetration_depth_stub(game::Weapon weapon, bool is_alternate, int surfaceType) + { + if (dvars::bg_surfacePenetration->current.value > 0.0f) + { + return dvars::bg_surfacePenetration->current.value; + } + + return bg_get_surface_penetration_depth_hook.invoke(weapon, is_alternate, surfaceType); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + if (game::environment::is_sp()) + { + return; + } + + dvars::bg_surfacePenetration = game::Dvar_RegisterFloat("bg_surfacePenetration", 0.0f, + 0.0f, std::numeric_limits::max(), game::DVAR_FLAG_SAVED, + "Set to a value greater than 0 to override the surface penetration depth"); + bg_get_surface_penetration_depth_hook.create(0x1401641A0, &bg_get_surface_penetration_depth_stub); + } + }; +} + +REGISTER_COMPONENT(bullet::component) diff --git a/src/client/game/dvars.cpp b/src/client/game/dvars.cpp index 8bc3766..7423c2f 100644 --- a/src/client/game/dvars.cpp +++ b/src/client/game/dvars.cpp @@ -20,6 +20,8 @@ namespace dvars game::dvar_t* g_playerEjection = nullptr; game::dvar_t* g_playerCollision = nullptr; + game::dvar_t* bg_surfacePenetration = nullptr; + game::dvar_t* pm_bouncing = nullptr; game::dvar_t* g_dump_scripts = nullptr; game::dvar_t* g_gravity = nullptr; diff --git a/src/client/game/dvars.hpp b/src/client/game/dvars.hpp index ecf645f..fe3e7aa 100644 --- a/src/client/game/dvars.hpp +++ b/src/client/game/dvars.hpp @@ -19,6 +19,8 @@ namespace dvars extern game::dvar_t* g_playerCollision; extern game::dvar_t* g_playerEjection; + extern game::dvar_t* bg_surfacePenetration; + extern game::dvar_t* pm_bouncing; extern game::dvar_t* g_dump_scripts; extern game::dvar_t* g_gravity;