From 54185c8464198e0386bb0b12d7024f28eacf3eb0 Mon Sep 17 00:00:00 2001 From: Skull Merlin <86374920+skkuull@users.noreply.github.com> Date: Thu, 5 May 2022 16:58:36 +0300 Subject: [PATCH] collision & ejection --- src/client/component/gameplay.cpp | 30 ++++++++++++++++++++++++++++++ src/client/game/dvars.cpp | 2 ++ src/client/game/dvars.hpp | 2 ++ src/client/game/structs.hpp | 10 ++++++++++ 4 files changed, 44 insertions(+) diff --git a/src/client/component/gameplay.cpp b/src/client/component/gameplay.cpp index c02bd004..061a9c19 100644 --- a/src/client/component/gameplay.cpp +++ b/src/client/component/gameplay.cpp @@ -25,6 +25,26 @@ namespace gameplay } } + int stuck_in_client_stub(void* entity) + { + if (dvars::g_playerEjection->current.enabled) + { + return utils::hook::invoke(0x140326CE0, entity); // StuckInClient + } + + return 0; + } + + void cm_transformed_capsule_trace_stub(game::trace_t* results, const float* start, const float* end, + game::Bounds* bounds, game::Bounds* capsule, int contents, const float* origin, const float* angles) + { + if (dvars::g_playerCollision->current.enabled) + { + utils::hook::invoke(0x1403FF860, + results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace + } + } + void pm_crashland_stub(game::mp::playerState_s* ps, void* pml) { if (jump_enableFallDamage->current.enabled) @@ -91,6 +111,16 @@ namespace gameplay utils::hook::call(0x1401E490F, pm_crashland_stub); jump_enableFallDamage = dvars::register_bool("jump_enableFallDamage", true, game::DVAR_FLAG_REPLICATED, "Enable fall damage"); + dvars::g_playerEjection = dvars::register_bool("g_playerEjection", true, game::DVAR_FLAG_REPLICATED, + "Flag whether player ejection is on or off"); + utils::hook::call(0x140323333, stuck_in_client_stub); + + // Implement player collision dvar + dvars::g_playerCollision = dvars::register_bool("g_playerCollision", true, game::DVAR_FLAG_REPLICATED, + "Flag whether player collision is on or off"); + utils::hook::call(0x14049D7CF, cm_transformed_capsule_trace_stub); // SV_ClipMoveToEntity + utils::hook::call(0x140240BC3, cm_transformed_capsule_trace_stub); // CG_ClipMoveToEntity + // Implement bouncing dvar dvars::pm_bouncing = dvars::register_bool("pm_bouncing", false, game::DVAR_FLAG_REPLICATED, "Enable bouncing"); diff --git a/src/client/game/dvars.cpp b/src/client/game/dvars.cpp index 4834bd64..8f0c5dba 100644 --- a/src/client/game/dvars.cpp +++ b/src/client/game/dvars.cpp @@ -21,6 +21,8 @@ namespace dvars game::dvar_t* con_inputDvarValueColor = nullptr; game::dvar_t* con_inputDvarInactiveValueColor = nullptr; game::dvar_t* con_inputCmdMatchColor = nullptr; + game::dvar_t* g_playerEjection = nullptr; + game::dvar_t* g_playerCollision = nullptr; game::dvar_t* jump_enableFallDamage; diff --git a/src/client/game/dvars.hpp b/src/client/game/dvars.hpp index 87154b5e..34f6d714 100644 --- a/src/client/game/dvars.hpp +++ b/src/client/game/dvars.hpp @@ -24,6 +24,8 @@ namespace dvars extern game::dvar_t* con_inputDvarValueColor; extern game::dvar_t* con_inputDvarInactiveValueColor; extern game::dvar_t* con_inputCmdMatchColor; + extern game::dvar_t* g_playerEjection; + extern game::dvar_t* g_playerCollision; extern game::dvar_t* jump_enableFallDamage; diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 4d6b3405..9d1907c8 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1428,6 +1428,16 @@ namespace game SV_LIVE_DROP_DISCONNECT = 0x1, }; + struct trace_t + { + }; + + struct Bounds + { + float midPoint[3]; + float halfSize[3]; + }; + namespace mp { struct cachedSnapshot_t