From 5741869abd84b8c318e2cfe5d70b36ba04c86c52 Mon Sep 17 00:00:00 2001 From: mjkzy Date: Sat, 28 May 2022 14:38:00 -0500 Subject: [PATCH] bullet penetration override --- src/client/component/bullet.cpp | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 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 00000000..d58e42b1 --- /dev/null +++ b/src/client/component/bullet.cpp @@ -0,0 +1,46 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include + +namespace bullet +{ + namespace + { + game::dvar_t* bg_surface_penetration = nullptr; + utils::hook::detour bg_get_surface_penetration_depth_hook; + + float bg_get_surface_penetration_depth_stub(game::Weapon weapon, bool is_alternate, int surface_type) + { + if (bg_surface_penetration->current.value > 0.0f) + { + return bg_surface_penetration->current.value; + } + + return bg_get_surface_penetration_depth_hook.invoke(weapon, is_alternate, surface_type); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + if (game::environment::is_sp()) + { + return; + } + + bg_surface_penetration = dvars::register_float("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(0x2E1110_b, &bg_get_surface_penetration_depth_stub); + } + }; +} + +REGISTER_COMPONENT(bullet::component)