feat: add increased bullet penetration dvar (#704)

Co-authored-by: FutureRave <edoardo.sanguineti222@gmail.com>
This commit is contained in:
joey 2023-05-15 11:33:20 -04:00 committed by GitHub
parent 96ff5add75
commit 75aff9d860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,44 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/hook.hpp>
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<float>(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<float>::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)

View File

@ -20,6 +20,8 @@ namespace dvars
game::dvar_t* g_playerEjection = nullptr; game::dvar_t* g_playerEjection = nullptr;
game::dvar_t* g_playerCollision = nullptr; game::dvar_t* g_playerCollision = nullptr;
game::dvar_t* bg_surfacePenetration = nullptr;
game::dvar_t* pm_bouncing = nullptr; game::dvar_t* pm_bouncing = nullptr;
game::dvar_t* g_dump_scripts = nullptr; game::dvar_t* g_dump_scripts = nullptr;
game::dvar_t* g_gravity = nullptr; game::dvar_t* g_gravity = nullptr;

View File

@ -19,6 +19,8 @@ namespace dvars
extern game::dvar_t* g_playerCollision; extern game::dvar_t* g_playerCollision;
extern game::dvar_t* g_playerEjection; extern game::dvar_t* g_playerEjection;
extern game::dvar_t* bg_surfacePenetration;
extern game::dvar_t* pm_bouncing; extern game::dvar_t* pm_bouncing;
extern game::dvar_t* g_dump_scripts; extern game::dvar_t* g_dump_scripts;
extern game::dvar_t* g_gravity; extern game::dvar_t* g_gravity;