playerejection

This commit is contained in:
Skull 2022-10-11 22:22:48 +03:00
parent aaba9cbcc5
commit 5acd807356
3 changed files with 18 additions and 1 deletions

View File

@ -14,6 +14,16 @@ namespace gameplay
{ {
namespace namespace
{ {
utils::hook::detour stuck_in_client_hook;
void stuck_in_client_stub(void* entity)
{
if (dvars::g_playerEjection->current.enabled)
{
stuck_in_client_hook.invoke<void>(entity);
}
}
void* bg_bounces_stub() void* bg_bounces_stub()
{ {
return utils::hook::assemble([](utils::hook::assembler& a) return utils::hook::assemble([](utils::hook::assembler& a)
@ -63,13 +73,16 @@ namespace gameplay
void post_unpack() override void post_unpack() override
{ {
// Implement bounces // Implement bounces
dvars::bg_bounces = game::Dvar_RegisterBool("bg_bounces", false, game::DVAR_FLAG_REPLICATED, "Enables bouncing"); dvars::bg_bounces = game::Dvar_RegisterBool("bg_bounces", false, game::DVAR_FLAG_REPLICATED, "Enables bounces");
utils::hook::jump(0x70FBB7_b, bg_bounces_stub(), true); utils::hook::jump(0x70FBB7_b, bg_bounces_stub(), true);
// Implement gravity dvar // Implement gravity dvar
dvars::bg_gravity = game::Dvar_RegisterInt("bg_gravity", 800, 0, 1000, game::DVAR_FLAG_REPLICATED, "Game gravity in inches per second squared"); dvars::bg_gravity = game::Dvar_RegisterInt("bg_gravity", 800, 0, 1000, game::DVAR_FLAG_REPLICATED, "Game gravity in inches per second squared");
utils::hook::nop(0xAFA330_b, 13); utils::hook::nop(0xAFA330_b, 13);
utils::hook::jump(0xAFA330_b, bg_gravity_stub(), true); utils::hook::jump(0xAFA330_b, bg_gravity_stub(), true);
dvars::g_playerEjection = game::Dvar_RegisterBool("g_playerEjection", true, game::DVAR_FLAG_REPLICATED, "Flag whether player ejection is on or off");
stuck_in_client_hook.create(0xAFD9B0_b, stuck_in_client_stub);
} }
}; };
} }

View File

@ -28,6 +28,8 @@ namespace dvars
game::dvar_t* bg_bounces = nullptr; game::dvar_t* bg_bounces = nullptr;
game::dvar_t* bg_gravity = nullptr; game::dvar_t* bg_gravity = nullptr;
game::dvar_t* g_playerEjection = nullptr;
std::string dvar_get_vector_domain(const int components, const game::DvarLimits& domain) std::string dvar_get_vector_domain(const int components, const game::DvarLimits& domain)
{ {
if (domain.vector.min == -FLT_MAX) if (domain.vector.min == -FLT_MAX)

View File

@ -24,6 +24,8 @@ namespace dvars
extern game::dvar_t* bg_bounces; extern game::dvar_t* bg_bounces;
extern game::dvar_t* bg_gravity; extern game::dvar_t* bg_gravity;
extern game::dvar_t* g_playerEjection;
std::string dvar_get_vector_domain(const int components, const game::DvarLimits& domain); std::string dvar_get_vector_domain(const int components, const game::DvarLimits& domain);
std::string dvar_get_domain(const game::DvarType type, const game::DvarLimits& domain); std::string dvar_get_domain(const game::DvarType type, const game::DvarLimits& domain);
std::string dvar_get_name(const game::dvar_t* dvar); std::string dvar_get_name(const game::dvar_t* dvar);