(gameplay): Restore some dvars
This commit is contained in:
parent
8d1ff02a5a
commit
4b270384c0
@ -13,15 +13,15 @@ namespace gameplay
|
||||
utils::hook::detour pm_player_trace_hook;
|
||||
utils::hook::detour pm_crashland_hook;
|
||||
|
||||
void pm_player_trace_stub(game::pmove_t* pm, game::trace_t* trace, const float* f3,
|
||||
const float* f4, const game::Bounds* bounds, int a6, int a7)
|
||||
void pm_player_trace_stub(game::pmove_t* pm, game::trace_t* results, const float* start,
|
||||
const float* end, const game::Bounds* bounds, int passEntityNum, int contentMask)
|
||||
{
|
||||
pm_player_trace_hook.invoke<void>(pm, trace, f3, f4, bounds, a6, a7);
|
||||
pm_player_trace_hook.invoke<void>(pm, results, start, end, bounds, passEntityNum, contentMask);
|
||||
|
||||
// By setting startsolid to false we allow the player to clip through solid objects above their head
|
||||
if (dvars::g_enableElevators->current.enabled)
|
||||
{
|
||||
trace->startsolid = false;
|
||||
results->startsolid = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,34 @@ namespace gameplay
|
||||
pm_crashland_hook.invoke<void>(ps, pm);
|
||||
}
|
||||
}
|
||||
|
||||
void jump_pushoffladder_stub(utils::hook::assembler& a)
|
||||
{
|
||||
a.push(rax);
|
||||
|
||||
a.mov(rax, qword_ptr(reinterpret_cast<int64_t>(&dvars::jump_ladderPushVel)));
|
||||
a.mulss(xmm7, dword_ptr(rax, 0x10));
|
||||
a.mulss(xmm6, dword_ptr(rax, 0x10));
|
||||
|
||||
a.pop(rax);
|
||||
|
||||
a.jmp(0x14067AC7C);
|
||||
}
|
||||
|
||||
void jump_start_stub(utils::hook::assembler& a)
|
||||
{
|
||||
// Game code hook skipped
|
||||
a.movss(xmm0, dword_ptr(rbx, 0x3D4));
|
||||
a.and_(dword_ptr(rbx, 0x54), ~(game::PMF_TIME_HARDLANDING | game::PMF_TIME_KNOCKBACK));
|
||||
|
||||
a.push(rax);
|
||||
a.mov(rax, qword_ptr(reinterpret_cast<int64_t>(&dvars::jump_spreadAdd)));
|
||||
a.addss(xmm0, dword_ptr(rax, 0x10));
|
||||
a.pop(rax);
|
||||
|
||||
a.jmp(0x14067AE1A);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
@ -68,6 +96,8 @@ namespace gameplay
|
||||
{
|
||||
dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DvarFlags::DVAR_FLAG_NONE);
|
||||
dvars::jump_enableFallDamage = dvars::register_bool("jump_enableFallDamage", true, game::DVAR_FLAG_REPLICATED);
|
||||
dvars::jump_ladderPushVel = dvars::register_float("jump_ladderPushVel", 128.0f, 0.0f, 1024.0f, game::DVAR_FLAG_REPLICATED);
|
||||
dvars::jump_spreadAdd = dvars::register_float("jump_spreadAdd", 64.0f, 0.0f, 512.0f, game::DVAR_FLAG_REPLICATED);
|
||||
|
||||
// Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored'
|
||||
pm_player_trace_hook.create(0x14068F0A0, &pm_player_trace_stub);
|
||||
@ -75,10 +105,18 @@ namespace gameplay
|
||||
// If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state
|
||||
utils::hook::jump(0x1406878C1, utils::hook::assemble(pm_trace_stub), true);
|
||||
|
||||
pm_crashland_hook.create(0x140688A20, pm_crashland_stub);
|
||||
pm_crashland_hook.create(0x140688A20, &pm_crashland_stub);
|
||||
|
||||
dvars::register_float("jump_height", 39, 0, 1000, game::DVAR_FLAG_REPLICATED);
|
||||
dvars::register_float("g_gravity", 800, 1, 1000, game::DVAR_FLAG_REPLICATED);
|
||||
utils::hook::jump(0x14067AC6C, utils::hook::assemble(jump_pushoffladder_stub), true);
|
||||
utils::hook::nop(0x14067AC78, 4);
|
||||
|
||||
utils::hook::jump(0x14067AE03, utils::hook::assemble(jump_start_stub), true);
|
||||
utils::hook::nop(0x14067AE0F, 4);
|
||||
|
||||
// Dvars already present in-game
|
||||
dvars::register_float("jump_height", 39.0f, 0.0f, 1000.0f, game::DVAR_FLAG_REPLICATED);
|
||||
dvars::register_float("jump_stepSize", 18.0f, 0.0f, 64.0f, game::DVAR_FLAG_REPLICATED);
|
||||
dvars::register_float("g_gravity", 800.0f, 1.0f, 1000.0f, game::DVAR_FLAG_REPLICATED);
|
||||
dvars::register_int("g_speed", 190, 0, 1000, game::DVAR_FLAG_REPLICATED);
|
||||
}
|
||||
};
|
||||
|
@ -16,6 +16,8 @@ namespace dvars
|
||||
game::dvar_t* con_inputCmdMatchColor = nullptr;
|
||||
|
||||
game::dvar_t* jump_enableFallDamage;
|
||||
game::dvar_t* jump_ladderPushVel;
|
||||
game::dvar_t* jump_spreadAdd;
|
||||
|
||||
game::dvar_t* r_fullbright;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "game.hpp"
|
||||
#include "structs.hpp"
|
||||
#include <string>
|
||||
|
||||
@ -17,6 +16,8 @@ namespace dvars
|
||||
extern game::dvar_t* con_inputCmdMatchColor;
|
||||
|
||||
extern game::dvar_t* jump_enableFallDamage;
|
||||
extern game::dvar_t* jump_ladderPushVel;
|
||||
extern game::dvar_t* jump_spreadAdd;
|
||||
|
||||
extern game::dvar_t* r_fullbright;
|
||||
|
||||
|
@ -51,6 +51,12 @@ namespace game
|
||||
FL_BADPLACE_VOLUME = 0x80000000,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PMF_TIME_HARDLANDING = 1 << 7,
|
||||
PMF_TIME_KNOCKBACK = 1 << 8,
|
||||
};
|
||||
|
||||
struct EntityState
|
||||
{
|
||||
char entityNum;
|
||||
|
Loading…
Reference in New Issue
Block a user