Hook dvar register func

This commit is contained in:
FutureRave 2021-11-11 13:38:51 +00:00
parent 7664a773e7
commit 37e79f7c3a
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
3 changed files with 16 additions and 7 deletions

View File

@ -299,9 +299,6 @@ namespace Components
// Uncheat ui_debugMode // Uncheat ui_debugMode
Utils::Hook::Xor<BYTE>(0x6312DE, Game::dvar_flag::DVAR_FLAG_CHEAT); Utils::Hook::Xor<BYTE>(0x6312DE, Game::dvar_flag::DVAR_FLAG_CHEAT);
// Remove unknown flag from player_lastStandCrawlSpeedScale (prevent unknown behaviour)
Utils::Hook::Xor<BYTE>(0x448B42, Game::dvar_flag::DVAR_FLAG_UNKNOWN80);
// Hook dvar 'name' registration // Hook dvar 'name' registration
Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick(); Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick();

View File

@ -124,6 +124,14 @@ namespace Components
} }
} }
Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* name, float defaultVal, float min, float max, int, const char*)
{
Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register<float>(name, defaultVal,
min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, "TEST DESC");
return Movement::PlayerLastStandCrawlSpeedScale.get<Game::dvar_t*>();
}
Movement::Movement() Movement::Movement()
{ {
Dvar::OnInit([] Dvar::OnInit([]
@ -132,17 +140,19 @@ namespace Components
0.65f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, 0.65f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
"The scale applied to the player speed when ducking"); "The scale applied to the player speed when ducking");
Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register<float>("player_lastStandCrawlSpeedScale",
0.2f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
"The scale applied to the player speed when crawling in last stand");
Movement::PlayerProneSpeedScale = Dvar::Register<float>("player_proneSpeedScale", Movement::PlayerProneSpeedScale = Dvar::Register<float>("player_proneSpeedScale",
0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, 0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
"The scale applied to the player speed when crawling"); "The scale applied to the player speed when crawling");
}); });
// Hook PM_CmdScaleForStance in PM_CmdScale_Walk
Utils::Hook(0x572F34, Movement::PMCmdScaleForStanceStub, HOOK_CALL).install()->quick(); Utils::Hook(0x572F34, Movement::PMCmdScaleForStanceStub, HOOK_CALL).install()->quick();
//Hook PM_CmdScaleForStance in PM_GetMaxSpeed
Utils::Hook(0x57395F, Movement::PMCmdScaleForStanceStub, HOOK_CALL).install()->quick(); Utils::Hook(0x57395F, Movement::PMCmdScaleForStanceStub, 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();
} }
Movement::~Movement() Movement::~Movement()

View File

@ -16,5 +16,7 @@ namespace Components
static int PMGetEffectiveStance(Game::playerState_s* ps); static int PMGetEffectiveStance(Game::playerState_s* ps);
static float PMCmdScaleForStance(Game::pmove_s* move); static float PMCmdScaleForStance(Game::pmove_s* move);
static void PMCmdScaleForStanceStub(); static void PMCmdScaleForStanceStub();
static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* name, float defaultVal, float min, float max, int flags, const char* desc);
}; };
} }