[Shmovement] Refactor other patches
This commit is contained in:
parent
50dc2f8b84
commit
222b1c945a
@ -10,6 +10,8 @@ namespace Components
|
||||
Dvar::Var Movement::CGNoclipScaler;
|
||||
Dvar::Var Movement::BGBouncesAllAngles;
|
||||
Dvar::Var Movement::BGRocketJump;
|
||||
Dvar::Var Movement::BGPlayerEjection;
|
||||
Dvar::Var Movement::BGPlayerCollision;
|
||||
Game::dvar_t* Movement::BGBounces;
|
||||
|
||||
float Movement::PM_CmdScaleForStance(const Game::pmove_s* pm)
|
||||
@ -236,6 +238,28 @@ namespace Components
|
||||
return result;
|
||||
}
|
||||
|
||||
int Movement::StuckInClient_Hk(Game::gentity_s* self)
|
||||
{
|
||||
if (Movement::BGPlayerEjection.get<bool>())
|
||||
{
|
||||
return Utils::Hook::Call<int(Game::gentity_s*)>(0x402D30)(self); // StuckInClient
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Movement::CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end,
|
||||
const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles)
|
||||
{
|
||||
if (Movement::BGPlayerCollision.get<bool>())
|
||||
{
|
||||
Utils::Hook::Call<void(Game::trace_t*, const float*, const float*,
|
||||
const Game::Bounds*, const Game::Bounds*, int, const float*, const float*)>
|
||||
(0x478300)
|
||||
(results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace
|
||||
}
|
||||
}
|
||||
|
||||
Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* name, float value,
|
||||
float min, float max, int, const char* desc)
|
||||
{
|
||||
@ -274,7 +298,7 @@ namespace Components
|
||||
0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
|
||||
"The scale applied to the player speed when crawling");
|
||||
|
||||
// 3arch naming convention
|
||||
// 3arc naming convention
|
||||
Movement::CGUfoScaler = Dvar::Register<float>("cg_ufo_scaler",
|
||||
6.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
|
||||
"The speed at which ufo camera moves");
|
||||
@ -291,6 +315,12 @@ namespace Components
|
||||
|
||||
Movement::BGRocketJump = Dvar::Register<bool>("bg_rocketJump",
|
||||
false, Game::DVAR_FLAG_REPLICATED, "Enable CoD4 rocket jumps");
|
||||
|
||||
Movement::BGPlayerEjection = Dvar::Register<bool>("bg_playerEjection",
|
||||
true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other");
|
||||
|
||||
Movement::BGPlayerCollision = Dvar::Register<bool>("bg_playerCollision",
|
||||
true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other");
|
||||
});
|
||||
|
||||
// Hook PM_CmdScaleForStance in PM_CmdScale_Walk
|
||||
@ -316,5 +346,13 @@ namespace Components
|
||||
|
||||
// Rocket jump
|
||||
Utils::Hook(0x4A4F9B, Movement::Weapon_RocketLauncher_Fire_Hk, HOOK_CALL).install()->quick(); // FireWeapon
|
||||
|
||||
// Hook StuckInClient so we can prevent intersecting players from being pushed away from each other
|
||||
Utils::Hook(0x5D8153, Movement::StuckInClient_Hk, HOOK_CALL).install()->quick();
|
||||
|
||||
// Hook StuckInClient & CM_TransformedCapsuleTrace
|
||||
// so we can prevent intersecting players from being pushed away from each other
|
||||
Utils::Hook(0x45A5BF, Movement::CM_TransformedCapsuleTrace_Hk, HOOK_CALL).install()->quick(); // SV_ClipMoveToEntity
|
||||
Utils::Hook(0x5A0CAD, Movement::CM_TransformedCapsuleTrace_Hk, HOOK_CALL).install()->quick(); // CG_ClipMoveToEntity
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ namespace Components
|
||||
static Dvar::Var CGNoclipScaler;
|
||||
static Dvar::Var BGBouncesAllAngles;
|
||||
static Dvar::Var BGRocketJump;
|
||||
static Dvar::Var BGPlayerEjection;
|
||||
static Dvar::Var BGPlayerCollision;
|
||||
// Can't use Var class inside assembly stubs
|
||||
static Game::dvar_t* BGBounces;
|
||||
|
||||
@ -34,6 +36,10 @@ namespace Components
|
||||
|
||||
static Game::gentity_s* Weapon_RocketLauncher_Fire_Hk(Game::gentity_s* ent, unsigned int weaponIndex, float spread, Game::weaponParms* wp, const float* gunVel, Game::lockonFireParms* lockParms, bool a7);
|
||||
|
||||
// Player collison
|
||||
static int StuckInClient_Hk(Game::gentity_s* self);
|
||||
static void CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end, const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles);
|
||||
|
||||
static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc);
|
||||
static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc);
|
||||
};
|
||||
|
@ -296,61 +296,6 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
Game::dvar_t* QuickPatch::g_playerCollision;
|
||||
__declspec(naked) void QuickPatch::PlayerCollisionStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
// check the value of g_playerCollision
|
||||
push eax;
|
||||
mov eax, g_playerCollision;
|
||||
cmp byte ptr[eax + 16], 0;
|
||||
pop eax;
|
||||
|
||||
// dont collide if g_playerCollision is set to 0
|
||||
je dontcollide;
|
||||
|
||||
// original code
|
||||
mov eax, dword ptr[esp + 0xa0];
|
||||
push 0x00478376;
|
||||
retn;
|
||||
|
||||
dontcollide:
|
||||
mov eax, dword ptr[esp + 0xa0];
|
||||
mov ecx, dword ptr[esp + 9ch];
|
||||
push eax;
|
||||
push ecx;
|
||||
lea edx, [esp + 48h];
|
||||
push edx;
|
||||
mov eax, esi;
|
||||
push 0x0047838b;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
Game::dvar_t* QuickPatch::g_playerEjection;
|
||||
__declspec(naked) void QuickPatch::PlayerEjectionStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
// check the value of g_playerEjection
|
||||
push eax;
|
||||
mov eax, g_playerEjection;
|
||||
cmp byte ptr[eax + 16], 0;
|
||||
pop eax;
|
||||
|
||||
// dont eject if g_playerEjection is set to 0
|
||||
je donteject;
|
||||
|
||||
push 0x005d8152;
|
||||
retn;
|
||||
|
||||
donteject:
|
||||
push 0x005d815b;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL QuickPatch::IsDynClassnameStub(char* a1)
|
||||
{
|
||||
auto version = Zones::GetEntitiesZoneVersion();
|
||||
@ -425,14 +370,6 @@ namespace Components
|
||||
// Intermission time dvar
|
||||
Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::DVAR_FLAG_REPLICATED | Game::DVAR_FLAG_DEDISAVED, "Time in seconds before match server loads the next map");
|
||||
|
||||
// Player Collision dvar
|
||||
g_playerCollision = Game::Dvar_RegisterBool("g_playerCollision", true, Game::DVAR_FLAG_REPLICATED, "Flag whether player collision is on or off");
|
||||
Utils::Hook(0x47836F, QuickPatch::PlayerCollisionStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Player Ejection dvar
|
||||
g_playerEjection = Game::Dvar_RegisterBool("g_playerEjection", true, Game::DVAR_FLAG_REPLICATED, "Flag whether player ejection is on or off");
|
||||
Utils::Hook(0x5D814A, QuickPatch::PlayerEjectionStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_FLAG_REPLICATED, "Perform antilag");
|
||||
Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMeleeStub, HOOK_JUMP).install()->quick();
|
||||
|
@ -37,10 +37,6 @@ namespace Components
|
||||
static void ClientEventsFireWeaponStub();
|
||||
static void ClientEventsFireWeaponMeleeStub();
|
||||
|
||||
static Game::dvar_t* g_playerCollision;
|
||||
static void PlayerCollisionStub();
|
||||
static Game::dvar_t* g_playerEjection;
|
||||
static void PlayerEjectionStub();
|
||||
static BOOL IsDynClassnameStub(char* a1);
|
||||
|
||||
static void CL_KeyEvent_OnEscape();
|
||||
|
Loading…
Reference in New Issue
Block a user