Add g_speed

This commit is contained in:
FutureRave 2022-05-10 12:44:43 +01:00
parent bdd3b8a688
commit 16034e7584
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
3 changed files with 25 additions and 0 deletions

View File

@ -81,6 +81,23 @@ namespace gameplay
a.jmp(0x1402D5A6A);
});
const auto client_think_real_stub = utils::hook::assemble([](utils::hook::assembler& a)
{
a.push(rax);
a.mov(rax, qword_ptr(reinterpret_cast<int64_t>(&dvars::g_speed)));
a.mov(eax, dword_ptr(rax, 0x10));
a.mov(word_ptr(rbx, 0x38), ax);
a.pop(rax);
// Game code hook skipped
a.movzx(eax, word_ptr(rbx, 0x3C));
a.add(eax, dword_ptr(rbx, 0x48));
a.jmp(0x1402D6A9C);
});
void pm_player_trace_stub(void* pm, game::trace_t* results, const float* start,
const float* end, const game::Bounds* bounds, int pass_entity_num, int content_mask)
{
@ -140,6 +157,12 @@ namespace gameplay
utils::hook::jump(0x1402D5A5D, client_end_frame_stub, true);
utils::hook::nop(0x1402D5A69, 1); // Nop skipped opcode
// Choosing the following min/max because the game would truncate larger values
dvars::g_speed = game::Dvar_RegisterInt("g_speed", 190,
std::numeric_limits<short>::min(), std::numeric_limits<short>::max(), game::DVAR_FLAG_REPLICATED, "Player speed");
utils::hook::jump(0x1402D6A8C, client_think_real_stub, true);
utils::hook::nop(0x1402D6A98, 4); // Nop skipped opcode
dvars::g_elevators = game::Dvar_RegisterBool("g_elevators", false,
game::DVAR_FLAG_REPLICATED, "Enable elevators");
utils::hook::call(0x140146134, pm_player_trace_stub);

View File

@ -22,6 +22,7 @@ namespace dvars
game::dvar_t* pm_bouncing = nullptr;
game::dvar_t* g_gravity = nullptr;
game::dvar_t* g_speed = nullptr;
game::dvar_t* g_elevators = nullptr;
game::dvar_t* player_sustainAmmo = nullptr;

View File

@ -21,6 +21,7 @@ namespace dvars
extern game::dvar_t* pm_bouncing;
extern game::dvar_t* g_gravity;
extern game::dvar_t* g_speed;
extern game::dvar_t* g_elevators;
extern game::dvar_t* player_sustainAmmo;