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;