Merge pull request #232 from diamante0018/fix-movement-patch
[Movement] Fix bug
This commit is contained in:
commit
7933424b34
@ -2,355 +2,289 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Dvar::Var Movement::PlayerDuckedSpeedScale;
|
Dvar::Var Movement::PlayerSpectateSpeedScale;
|
||||||
Dvar::Var Movement::PlayerLastStandCrawlSpeedScale;
|
Dvar::Var Movement::CGUfoScaler;
|
||||||
Dvar::Var Movement::PlayerProneSpeedScale;
|
Dvar::Var Movement::CGNoclipScaler;
|
||||||
Dvar::Var Movement::PlayerSpectateSpeedScale;
|
Dvar::Var Movement::BGBouncesAllAngles;
|
||||||
Dvar::Var Movement::CGUfoScaler;
|
Dvar::Var Movement::BGRocketJump;
|
||||||
Dvar::Var Movement::CGNoclipScaler;
|
Dvar::Var Movement::BGPlayerEjection;
|
||||||
Dvar::Var Movement::BGBouncesAllAngles;
|
Dvar::Var Movement::BGPlayerCollision;
|
||||||
Dvar::Var Movement::BGRocketJump;
|
Game::dvar_t* Movement::BGBounces;
|
||||||
Dvar::Var Movement::BGPlayerEjection;
|
Game::dvar_t* Movement::PlayerDuckedSpeedScale;
|
||||||
Dvar::Var Movement::BGPlayerCollision;
|
Game::dvar_t* Movement::PlayerProneSpeedScale;
|
||||||
Game::dvar_t* Movement::BGBounces;
|
|
||||||
|
__declspec(naked) void Movement::PM_PlayerDuckedSpeedScaleStub()
|
||||||
float Movement::PM_CmdScaleForStance(const Game::pmove_s* pm)
|
{
|
||||||
{
|
__asm
|
||||||
assert(pm->ps != nullptr);
|
{
|
||||||
|
push eax
|
||||||
const auto* playerState = pm->ps;
|
mov eax, Movement::PlayerDuckedSpeedScale
|
||||||
float scale;
|
fld dword ptr [eax + 0x10] // dvar_t.current.value
|
||||||
|
pop eax
|
||||||
if (playerState->viewHeightLerpTime != 0 && playerState->viewHeightLerpTarget == 0xB)
|
|
||||||
{
|
// Game's code
|
||||||
scale = pm->cmd.serverTime - playerState->viewHeightLerpTime / 400.0f;
|
pop ecx
|
||||||
|
ret
|
||||||
if (0.0f <= scale)
|
}
|
||||||
{
|
}
|
||||||
if (scale > 1.0f)
|
|
||||||
{
|
__declspec(naked) void Movement::PM_PlayerProneSpeedScaleStub()
|
||||||
scale = 1.0f;
|
{
|
||||||
return scale * 0.15f + (1.0f - scale) * 0.65f;
|
__asm
|
||||||
}
|
{
|
||||||
|
push eax
|
||||||
if (scale != 0.0f)
|
mov eax, Movement::PlayerProneSpeedScale
|
||||||
{
|
fld dword ptr [eax + 0x10] // dvar_t.current.value
|
||||||
return scale * 0.15f + (1.0f - scale) * 0.65f;
|
pop eax
|
||||||
}
|
|
||||||
}
|
// Game's code
|
||||||
}
|
pop ecx
|
||||||
|
ret
|
||||||
if ((playerState->viewHeightLerpTime != 0 && playerState->viewHeightLerpTarget == 0x28) &&
|
}
|
||||||
playerState->viewHeightLerpDown == 0)
|
}
|
||||||
{
|
|
||||||
scale = 400.0f / pm->cmd.serverTime - playerState->viewHeightLerpTime;
|
float Movement::PM_MoveScale(Game::playerState_s* ps, float fmove,
|
||||||
|
float rmove, float umove)
|
||||||
if (0.0f <= scale)
|
{
|
||||||
{
|
assert(ps != nullptr);
|
||||||
if (scale > 1.0f)
|
|
||||||
{
|
auto max = std::fabsf(fmove) < std::fabsf(rmove)
|
||||||
scale = 1.0f;
|
? std::fabsf(rmove) : std::fabsf(fmove);
|
||||||
}
|
|
||||||
else if (scale != 0.0f)
|
if (std::fabsf(umove) > max)
|
||||||
{
|
{
|
||||||
return scale * 0.65f + (1.0f - scale) * 0.15f;
|
max = std::fabsf(umove);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (max == 0.0f)
|
||||||
|
{
|
||||||
scale = 1.0f;
|
return 0.0f;
|
||||||
const auto stance = Game::PM_GetEffectiveStance(playerState);
|
}
|
||||||
|
|
||||||
if (stance == Game::PM_EFF_STANCE_PRONE)
|
auto total = std::sqrtf(fmove * fmove
|
||||||
{
|
+ rmove * rmove + umove * umove);
|
||||||
scale = Movement::PlayerProneSpeedScale.get<float>();
|
auto scale = (static_cast<float>(ps->speed) * max) / (127.0f * total);
|
||||||
}
|
|
||||||
|
if (ps->pm_flags & Game::PMF_WALKING || ps->leanf != 0.0f)
|
||||||
else if (stance == Game::PM_EFF_STANCE_DUCKED)
|
{
|
||||||
{
|
scale *= 0.4f;
|
||||||
scale = Movement::PlayerDuckedSpeedScale.get<float>();
|
}
|
||||||
}
|
|
||||||
|
switch (ps->pm_type)
|
||||||
else if (stance == Game::PM_EFF_STANCE_LASTSTANDCRAWL)
|
{
|
||||||
{
|
case Game::pmtype_t::PM_NOCLIP:
|
||||||
scale = Movement::PlayerLastStandCrawlSpeedScale.get<float>();
|
scale *= Movement::CGNoclipScaler.get<float>();
|
||||||
}
|
break;
|
||||||
|
case Game::pmtype_t::PM_UFO:
|
||||||
return scale;
|
scale *= Movement::CGUfoScaler.get<float>();
|
||||||
}
|
break;
|
||||||
|
case Game::pmtype_t::PM_SPECTATOR:
|
||||||
__declspec(naked) void Movement::PM_CmdScaleForStanceStub()
|
scale *= Movement::PlayerSpectateSpeedScale.get<float>();
|
||||||
{
|
break;
|
||||||
__asm
|
default:
|
||||||
{
|
break;
|
||||||
pushad
|
}
|
||||||
|
|
||||||
push edx
|
return scale;
|
||||||
call Movement::PM_CmdScaleForStance // pm
|
}
|
||||||
add esp, 4
|
|
||||||
|
__declspec(naked) void Movement::PM_MoveScaleStub()
|
||||||
popad
|
{
|
||||||
ret
|
__asm
|
||||||
}
|
{
|
||||||
}
|
pushad
|
||||||
|
|
||||||
float Movement::PM_MoveScale(Game::playerState_s* ps, float forwardmove,
|
push [esp + 0xC + 0x20] // umove
|
||||||
float rightmove, float upmove)
|
push [esp + 0xC + 0x20] // rmove
|
||||||
{
|
push [esp + 0xC + 0x20] // fmove
|
||||||
assert(ps != nullptr);
|
push esi // ps
|
||||||
|
call Movement::PM_MoveScale
|
||||||
auto max = (std::fabsf(forwardmove) < std::fabsf(rightmove))
|
add esp, 0x10
|
||||||
? std::fabsf(rightmove)
|
|
||||||
: std::fabsf(forwardmove);
|
popad
|
||||||
|
ret
|
||||||
if (std::fabsf(upmove) > max)
|
}
|
||||||
{
|
}
|
||||||
max = std::fabsf(upmove);
|
|
||||||
}
|
__declspec(naked) void Movement::PM_StepSlideMoveStub()
|
||||||
|
{
|
||||||
if (max == 0.0f)
|
__asm
|
||||||
{
|
{
|
||||||
return 0.0f;
|
// Check the value of BGBounces
|
||||||
}
|
push ecx
|
||||||
|
push eax
|
||||||
auto total = std::sqrtf(forwardmove * forwardmove
|
|
||||||
+ rightmove * rightmove + upmove * upmove);
|
mov eax, Movement::BGBounces
|
||||||
auto scale = (ps->speed * max) / (127.0f * total);
|
mov ecx, dword ptr [eax + 0x10]
|
||||||
|
test ecx, ecx
|
||||||
if (ps->pm_flags & Game::PMF_WALKING || ps->leanf != 0.0f)
|
|
||||||
{
|
pop eax
|
||||||
scale *= 0.4f;
|
pop ecx
|
||||||
}
|
|
||||||
|
// Do not bounce if BGBounces is 0
|
||||||
if (ps->pm_type == Game::PM_NOCLIP)
|
jle noBounce
|
||||||
{
|
|
||||||
return scale * Movement::CGNoclipScaler.get<float>();
|
// Bounce
|
||||||
}
|
push 0x4B1B34
|
||||||
|
retn
|
||||||
if (ps->pm_type == Game::PM_UFO)
|
|
||||||
{
|
noBounce:
|
||||||
return scale * Movement::CGUfoScaler.get<float>();
|
// Original game code
|
||||||
}
|
cmp dword ptr [esp + 0x24], 0
|
||||||
|
push 0x4B1B48
|
||||||
if (ps->pm_type == Game::PM_SPECTATOR)
|
retn
|
||||||
{
|
}
|
||||||
return scale * Movement::PlayerSpectateSpeedScale.get<float>();
|
}
|
||||||
}
|
|
||||||
|
void Movement::PM_ProjectVelocityStub(const float* velIn, const float* normal, float* velOut)
|
||||||
return scale;
|
{
|
||||||
}
|
const auto lengthSquared2D = velIn[0] * velIn[0] + velIn[1] * velIn[1];
|
||||||
|
|
||||||
__declspec(naked) void Movement::PM_MoveScaleStub()
|
if (std::fabsf(normal[2]) < 0.001f || lengthSquared2D == 0.0)
|
||||||
{
|
{
|
||||||
__asm
|
velOut[0] = velIn[0];
|
||||||
{
|
velOut[1] = velIn[1];
|
||||||
pushad
|
velOut[2] = velIn[2];
|
||||||
|
return;
|
||||||
push [esp + 0xC + 0x20] // upmove
|
}
|
||||||
push [esp + 0xC + 0x20] // rightmove
|
|
||||||
push [esp + 0xC + 0x20] // forwardmove
|
auto newZ = velIn[0] * normal[0] + velIn[1] * normal[1];
|
||||||
push esi // ps
|
newZ = -newZ / normal[2];
|
||||||
call Movement::PM_MoveScale
|
const auto lengthScale = std::sqrtf((velIn[2] * velIn[2] + lengthSquared2D)
|
||||||
add esp, 0x10
|
/ (newZ * newZ + lengthSquared2D));
|
||||||
|
|
||||||
popad
|
if (Movement::BGBouncesAllAngles.get<bool>()
|
||||||
ret
|
|| (lengthScale < 1.f || newZ < 0.f || velIn[2] > 0.f))
|
||||||
}
|
{
|
||||||
}
|
velOut[0] = velIn[0] * lengthScale;
|
||||||
|
velOut[1] = velIn[1] * lengthScale;
|
||||||
__declspec(naked) void Movement::PM_StepSlideMoveStub()
|
velOut[2] = newZ * lengthScale;
|
||||||
{
|
}
|
||||||
__asm
|
}
|
||||||
{
|
|
||||||
// Check the value of BGBounces
|
// Double bounces
|
||||||
push ecx
|
void Movement::Jump_ClearState_Hk(Game::playerState_s* ps)
|
||||||
push eax
|
{
|
||||||
|
if (Movement::BGBounces->current.integer != Movement::DOUBLE)
|
||||||
mov eax, Movement::BGBounces
|
{
|
||||||
mov ecx, dword ptr [eax + 0x10]
|
Game::Jump_ClearState(ps);
|
||||||
test ecx, ecx
|
}
|
||||||
|
}
|
||||||
pop eax
|
|
||||||
pop ecx
|
Game::gentity_s* Movement::Weapon_RocketLauncher_Fire_Hk(Game::gentity_s* ent, unsigned int weaponIndex,
|
||||||
|
float spread, Game::weaponParms* wp, const float* gunVel, Game::lockonFireParms* lockParms, bool a7)
|
||||||
// Do not bounce if BGBounces is 0
|
{
|
||||||
jle noBounce
|
auto* result = Game::Weapon_RocketLauncher_Fire(ent, weaponIndex, spread, wp, gunVel, lockParms, a7);
|
||||||
|
|
||||||
// Bounce
|
if (ent->client != nullptr && BGRocketJump.get<bool>())
|
||||||
push 0x4B1B34
|
{
|
||||||
retn
|
ent->client->ps.velocity[0] += (0.0f - wp->forward[0]) * 64.0f;
|
||||||
|
ent->client->ps.velocity[1] += (0.0f - wp->forward[1]) * 64.0f;
|
||||||
noBounce:
|
ent->client->ps.velocity[2] += (0.0f - wp->forward[2]) * 64.0f;
|
||||||
// Original game code
|
}
|
||||||
cmp dword ptr [esp + 0x24], 0
|
|
||||||
push 0x4B1B48
|
return result;
|
||||||
retn
|
}
|
||||||
}
|
|
||||||
}
|
int Movement::StuckInClient_Hk(Game::gentity_s* self)
|
||||||
|
{
|
||||||
void Movement::PM_ProjectVelocityStub(const float* velIn, const float* normal, float* velOut)
|
if (Movement::BGPlayerEjection.get<bool>())
|
||||||
{
|
{
|
||||||
const auto lengthSquared2D = velIn[0] * velIn[0] + velIn[1] * velIn[1];
|
return Utils::Hook::Call<int(Game::gentity_s*)>(0x402D30)(self); // StuckInClient
|
||||||
|
}
|
||||||
if (std::fabsf(normal[2]) < 0.001f || lengthSquared2D == 0.0)
|
|
||||||
{
|
return 0;
|
||||||
velOut[0] = velIn[0];
|
}
|
||||||
velOut[1] = velIn[1];
|
|
||||||
velOut[2] = velIn[2];
|
void Movement::CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end,
|
||||||
return;
|
const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles)
|
||||||
}
|
{
|
||||||
|
if (Movement::BGPlayerCollision.get<bool>())
|
||||||
auto newZ = velIn[0] * normal[0] + velIn[1] * normal[1];
|
{
|
||||||
newZ = -newZ / normal[2];
|
Utils::Hook::Call<void(Game::trace_t*, const float*, const float*,
|
||||||
const auto lengthScale = std::sqrtf((velIn[2] * velIn[2] + lengthSquared2D)
|
const Game::Bounds*, const Game::Bounds*, int, const float*, const float*)>
|
||||||
/ (newZ * newZ + lengthSquared2D));
|
(0x478300)
|
||||||
|
(results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace
|
||||||
if (Movement::BGBouncesAllAngles.get<bool>()
|
}
|
||||||
|| (lengthScale < 1.f || newZ < 0.f || velIn[2] > 0.f))
|
}
|
||||||
{
|
|
||||||
velOut[0] = velIn[0] * lengthScale;
|
Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value,
|
||||||
velOut[1] = velIn[1] * lengthScale;
|
float min, float max, unsigned __int16 /*flags*/, const char* description)
|
||||||
velOut[2] = newZ * lengthScale;
|
{
|
||||||
}
|
Movement::PlayerSpectateSpeedScale = Dvar::Register<float>(dvarName, value,
|
||||||
}
|
min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description);
|
||||||
|
|
||||||
// Double bounces
|
return Movement::PlayerSpectateSpeedScale.get<Game::dvar_t*>();
|
||||||
void Movement::Jump_ClearState_Hk(Game::playerState_s* ps)
|
}
|
||||||
{
|
|
||||||
if (Movement::BGBounces->current.integer != Movement::DOUBLE)
|
Movement::Movement()
|
||||||
{
|
{
|
||||||
Game::Jump_ClearState(ps);
|
Dvar::OnInit([]
|
||||||
}
|
{
|
||||||
}
|
static const char* bg_bouncesValues[] =
|
||||||
|
{
|
||||||
Game::gentity_s* Movement::Weapon_RocketLauncher_Fire_Hk(Game::gentity_s* ent, unsigned int weaponIndex,
|
"disabled",
|
||||||
float spread, Game::weaponParms* wp, const float* gunVel, Game::lockonFireParms* lockParms, bool a7)
|
"enabled",
|
||||||
{
|
"double",
|
||||||
auto* result = Game::Weapon_RocketLauncher_Fire(ent, weaponIndex, spread, wp, gunVel, lockParms, a7);
|
nullptr
|
||||||
|
};
|
||||||
if (ent->client != nullptr && BGRocketJump.get<bool>())
|
|
||||||
{
|
Movement::PlayerDuckedSpeedScale = Game::Dvar_RegisterFloat("player_duckedSpeedScale",
|
||||||
ent->client->ps.velocity[0] += (0 - wp->forward[0]) * 64.0f;
|
0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
||||||
ent->client->ps.velocity[1] += (0 - wp->forward[1]) * 64.0f;
|
"The scale applied to the player speed when ducking");
|
||||||
ent->client->ps.velocity[2] += (0 - wp->forward[2]) * 64.0f;
|
|
||||||
}
|
Movement::PlayerProneSpeedScale = Game::Dvar_RegisterFloat("player_proneSpeedScale",
|
||||||
|
0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
||||||
return result;
|
"The scale applied to the player speed when crawling");
|
||||||
}
|
|
||||||
|
// 3arc naming convention
|
||||||
int Movement::StuckInClient_Hk(Game::gentity_s* self)
|
Movement::CGUfoScaler = Dvar::Register<float>("cg_ufo_scaler",
|
||||||
{
|
6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
||||||
if (Movement::BGPlayerEjection.get<bool>())
|
"The speed at which ufo camera moves");
|
||||||
{
|
|
||||||
return Utils::Hook::Call<int(Game::gentity_s*)>(0x402D30)(self); // StuckInClient
|
Movement::CGNoclipScaler = Dvar::Register<float>("cg_noclip_scaler",
|
||||||
}
|
3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
||||||
|
"The speed at which noclip camera moves");
|
||||||
return 0;
|
|
||||||
}
|
Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces",
|
||||||
|
bg_bouncesValues, Movement::DISABLED, Game::DVAR_CODINFO, "Bounce glitch settings");
|
||||||
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)
|
Movement::BGBouncesAllAngles = Dvar::Register<bool>("bg_bouncesAllAngles",
|
||||||
{
|
false, Game::DVAR_CODINFO, "Force bounce from all angles");
|
||||||
if (Movement::BGPlayerCollision.get<bool>())
|
|
||||||
{
|
Movement::BGRocketJump = Dvar::Register<bool>("bg_rocketJump",
|
||||||
Utils::Hook::Call<void(Game::trace_t*, const float*, const float*,
|
false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps");
|
||||||
const Game::Bounds*, const Game::Bounds*, int, const float*, const float*)>
|
|
||||||
(0x478300)
|
Movement::BGPlayerEjection = Dvar::Register<bool>("bg_playerEjection",
|
||||||
(results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace
|
true, Game::DVAR_CODINFO, "Push intersecting players away from each other");
|
||||||
}
|
|
||||||
}
|
Movement::BGPlayerCollision = Dvar::Register<bool>("bg_playerCollision",
|
||||||
|
true, Game::DVAR_CODINFO, "Push intersecting players away from each other");
|
||||||
Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value,
|
});
|
||||||
float min, float max, unsigned __int16 /*flags*/, const char* description)
|
|
||||||
{
|
// Hook Dvar_RegisterFloat. Only thing that's changed is that the 0x80 flag is not used.
|
||||||
Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register<float>(dvarName, value,
|
Utils::Hook(0x448990, Movement::Dvar_RegisterSpectateSpeedScale, HOOK_CALL).install()->quick();
|
||||||
min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description);
|
|
||||||
|
// PM_CmdScaleForStance
|
||||||
return Movement::PlayerLastStandCrawlSpeedScale.get<Game::dvar_t*>();
|
Utils::Hook(0x572D9B, Movement::PM_PlayerDuckedSpeedScaleStub, HOOK_JUMP).install()->quick();
|
||||||
}
|
Utils::Hook(0x572DA5, Movement::PM_PlayerProneSpeedScaleStub, HOOK_JUMP).install()->quick();
|
||||||
|
|
||||||
Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value,
|
// Hook PM_MoveScale so we can add custom speed scale for Ufo and Noclip
|
||||||
float min, float max, unsigned __int16 /*flags*/, const char* description)
|
Utils::Hook(0x56F845, Movement::PM_MoveScaleStub, HOOK_CALL).install()->quick();
|
||||||
{
|
Utils::Hook(0x56FABD, Movement::PM_MoveScaleStub, HOOK_CALL).install()->quick();
|
||||||
Movement::PlayerSpectateSpeedScale = Dvar::Register<float>(dvarName, value,
|
|
||||||
min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description);
|
// Bounce logic
|
||||||
|
Utils::Hook(0x4B1B2D, Movement::PM_StepSlideMoveStub, HOOK_JUMP).install()->quick();
|
||||||
return Movement::PlayerSpectateSpeedScale.get<Game::dvar_t*>();
|
Utils::Hook(0x57383E, Movement::Jump_ClearState_Hk, HOOK_CALL).install()->quick();
|
||||||
}
|
Utils::Hook(0x4B1B97, Movement::PM_ProjectVelocityStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
Movement::Movement()
|
// Rocket jump
|
||||||
{
|
Utils::Hook(0x4A4F9B, Movement::Weapon_RocketLauncher_Fire_Hk, HOOK_CALL).install()->quick(); // FireWeapon
|
||||||
Dvar::OnInit([]
|
|
||||||
{
|
// Hook StuckInClient & CM_TransformedCapsuleTrace
|
||||||
static const char* bg_bouncesValues[] =
|
// so we can prevent intersecting players from being pushed away from each other
|
||||||
{
|
Utils::Hook(0x5D8153, Movement::StuckInClient_Hk, HOOK_CALL).install()->quick();
|
||||||
"disabled",
|
Utils::Hook(0x45A5BF, Movement::CM_TransformedCapsuleTrace_Hk, HOOK_CALL).install()->quick(); // SV_ClipMoveToEntity
|
||||||
"enabled",
|
Utils::Hook(0x5A0CAD, Movement::CM_TransformedCapsuleTrace_Hk, HOOK_CALL).install()->quick(); // CG_ClipMoveToEntity
|
||||||
"double",
|
}
|
||||||
nullptr
|
|
||||||
};
|
|
||||||
|
|
||||||
Movement::PlayerDuckedSpeedScale = Dvar::Register<float>("player_duckedSpeedScale",
|
|
||||||
0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
|
||||||
"The scale applied to the player speed when ducking");
|
|
||||||
|
|
||||||
Movement::PlayerProneSpeedScale = Dvar::Register<float>("player_proneSpeedScale",
|
|
||||||
0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
|
||||||
"The scale applied to the player speed when crawling");
|
|
||||||
|
|
||||||
// 3arc naming convention
|
|
||||||
Movement::CGUfoScaler = Dvar::Register<float>("cg_ufo_scaler",
|
|
||||||
6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
|
||||||
"The speed at which ufo camera moves");
|
|
||||||
|
|
||||||
Movement::CGNoclipScaler = Dvar::Register<float>("cg_noclip_scaler",
|
|
||||||
3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
|
|
||||||
"The speed at which noclip camera moves");
|
|
||||||
|
|
||||||
Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces",
|
|
||||||
bg_bouncesValues, Movement::DISABLED, Game::DVAR_CODINFO, "Bounce glitch settings");
|
|
||||||
|
|
||||||
Movement::BGBouncesAllAngles = Dvar::Register<bool>("bg_bouncesAllAngles",
|
|
||||||
false, Game::DVAR_CODINFO, "Force bounce from all angles");
|
|
||||||
|
|
||||||
Movement::BGRocketJump = Dvar::Register<bool>("bg_rocketJump",
|
|
||||||
false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps");
|
|
||||||
|
|
||||||
Movement::BGPlayerEjection = Dvar::Register<bool>("bg_playerEjection",
|
|
||||||
true, Game::DVAR_CODINFO, "Push intersecting players away from each other");
|
|
||||||
|
|
||||||
Movement::BGPlayerCollision = Dvar::Register<bool>("bg_playerCollision",
|
|
||||||
true, Game::DVAR_CODINFO, "Push intersecting players away from each other");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Hook PM_CmdScaleForStance in PM_CmdScale_Walk
|
|
||||||
Utils::Hook(0x572F34, Movement::PM_CmdScaleForStanceStub, HOOK_CALL).install()->quick();
|
|
||||||
|
|
||||||
//Hook PM_CmdScaleForStance in PM_GetMaxSpeed
|
|
||||||
Utils::Hook(0x57395F, Movement::PM_CmdScaleForStanceStub, HOOK_CALL).install()->quick();
|
|
||||||
|
|
||||||
// Hook Dvar_RegisterFloat. Only thing that's changed is that the 0x80 flag is not used.
|
|
||||||
Utils::Hook(0x448B66, Movement::Dvar_RegisterLastStandSpeedScale, HOOK_CALL).install()->quick();
|
|
||||||
|
|
||||||
// Hook Dvar_RegisterFloat. Only thing that's changed is that the 0x80 flag is not used.
|
|
||||||
Utils::Hook(0x448990, Movement::Dvar_RegisterSpectateSpeedScale, HOOK_CALL).install()->quick();
|
|
||||||
|
|
||||||
// Hook PM_MoveScale so we can add custom speed scale for Ufo and Noclip
|
|
||||||
Utils::Hook(0x56F845, Movement::PM_MoveScaleStub, HOOK_CALL).install()->quick();
|
|
||||||
Utils::Hook(0x56FABD, Movement::PM_MoveScaleStub, HOOK_CALL).install()->quick();
|
|
||||||
|
|
||||||
// Bounce logic
|
|
||||||
Utils::Hook(0x4B1B2D, Movement::PM_StepSlideMoveStub, HOOK_JUMP).install()->quick();
|
|
||||||
Utils::Hook(0x57383E, Movement::Jump_ClearState_Hk, HOOK_CALL).install()->quick();
|
|
||||||
Utils::Hook(0x4B1B97, Movement::PM_ProjectVelocityStub, HOOK_CALL).install()->quick();
|
|
||||||
|
|
||||||
// Rocket jump
|
|
||||||
Utils::Hook(0x4A4F9B, Movement::Weapon_RocketLauncher_Fire_Hk, HOOK_CALL).install()->quick(); // FireWeapon
|
|
||||||
|
|
||||||
// Hook StuckInClient & CM_TransformedCapsuleTrace
|
|
||||||
// so we can prevent intersecting players from being pushed away from each other
|
|
||||||
Utils::Hook(0x5D8153, Movement::StuckInClient_Hk, HOOK_CALL).install()->quick();
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,45 +2,43 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
class Movement : public Component
|
class Movement : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Movement();
|
Movement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum BouncesSettings { DISABLED, ENABLED, DOUBLE };
|
enum BouncesSettings { DISABLED, ENABLED, DOUBLE };
|
||||||
|
|
||||||
static Dvar::Var PlayerDuckedSpeedScale;
|
static Dvar::Var PlayerSpectateSpeedScale;
|
||||||
static Dvar::Var PlayerLastStandCrawlSpeedScale;
|
static Dvar::Var CGUfoScaler;
|
||||||
static Dvar::Var PlayerProneSpeedScale;
|
static Dvar::Var CGNoclipScaler;
|
||||||
static Dvar::Var PlayerSpectateSpeedScale;
|
static Dvar::Var BGBouncesAllAngles;
|
||||||
static Dvar::Var CGUfoScaler;
|
static Dvar::Var BGRocketJump;
|
||||||
static Dvar::Var CGNoclipScaler;
|
static Dvar::Var BGPlayerEjection;
|
||||||
static Dvar::Var BGBouncesAllAngles;
|
static Dvar::Var BGPlayerCollision;
|
||||||
static Dvar::Var BGRocketJump;
|
// Can't use Var class inside assembly stubs
|
||||||
static Dvar::Var BGPlayerEjection;
|
static Game::dvar_t* BGBounces;
|
||||||
static Dvar::Var BGPlayerCollision;
|
static Game::dvar_t* PlayerDuckedSpeedScale;
|
||||||
// Can't use Var class inside assembly stubs
|
static Game::dvar_t* PlayerProneSpeedScale;
|
||||||
static Game::dvar_t* BGBounces;
|
|
||||||
|
|
||||||
static float PM_CmdScaleForStance(const Game::pmove_s* move);
|
static void PM_PlayerDuckedSpeedScaleStub();
|
||||||
static void PM_CmdScaleForStanceStub();
|
static void PM_PlayerProneSpeedScaleStub();
|
||||||
|
|
||||||
static float PM_MoveScale(Game::playerState_s* ps, float forwardmove, float rightmove, float upmove);
|
static float PM_MoveScale(Game::playerState_s* ps, float fmove, float rmove, float umove);
|
||||||
static void PM_MoveScaleStub();
|
static void PM_MoveScaleStub();
|
||||||
|
|
||||||
// Bounce logic
|
// Bounce logic
|
||||||
static void PM_StepSlideMoveStub();
|
static void PM_StepSlideMoveStub();
|
||||||
static void PM_ProjectVelocityStub(const float* velIn, const float* normal, float* velOut);
|
static void PM_ProjectVelocityStub(const float* velIn, const float* normal, float* velOut);
|
||||||
static void Jump_ClearState_Hk(Game::playerState_s* ps);
|
static void Jump_ClearState_Hk(Game::playerState_s* ps);
|
||||||
|
|
||||||
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);
|
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
|
// Player collison
|
||||||
static int StuckInClient_Hk(Game::gentity_s* self);
|
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 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* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
|
static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
|
||||||
static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user