add jump_enablefalldmg dvar

This commit is contained in:
FutureRave 2022-03-21 11:06:20 +00:00
parent a3fc61e120
commit 5de913bf6c
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
2 changed files with 57 additions and 0 deletions

View File

@ -8,6 +8,7 @@
const game::native::dvar_t* player_movement::player_sustainAmmo; const game::native::dvar_t* player_movement::player_sustainAmmo;
const game::native::dvar_t* player_movement::jump_slowdownEnable; const game::native::dvar_t* player_movement::jump_slowdownEnable;
const game::native::dvar_t* player_movement::jump_ladderPushVel; const game::native::dvar_t* player_movement::jump_ladderPushVel;
const game::native::dvar_t* player_movement::jump_enableFallDamage;
const game::native::dvar_t* player_movement::jump_height; const game::native::dvar_t* player_movement::jump_height;
const game::native::dvar_t* player_movement::pm_bounces; const game::native::dvar_t* player_movement::pm_bounces;
const game::native::dvar_t* player_movement::pm_playerEjection; const game::native::dvar_t* player_movement::pm_playerEjection;
@ -210,6 +211,52 @@ __declspec(naked) void player_movement::jump_get_land_factor_stub()
} }
} }
__declspec(naked) void player_movement::pm_crash_land_stub_mp()
{
static DWORD func = 0x41E6B0;
__asm
{
push eax
mov eax, player_movement::jump_enableFallDamage
cmp byte ptr [eax + 0xC], 0
pop eax
// If disabled just return
jz skip_crash
// Arguments are in the registers
call func
skip_crash:
ret
}
}
__declspec(naked) void player_movement::pm_crash_land_stub_sp()
{
static DWORD func = 0x6405A0;
__asm
{
push eax
mov eax, player_movement::jump_enableFallDamage
cmp byte ptr [eax + 0xC], 0
pop eax
// If disabled just return
jz skip_crash
// ps is in the esi register
push [esp + 0x4] // pml
call func
add esp, 4
skip_crash:
ret
}
}
const game::native::dvar_t* player_movement::dvar_register_player_sustain_ammo(const char* dvar_name, const game::native::dvar_t* player_movement::dvar_register_player_sustain_ammo(const char* dvar_name,
bool value, unsigned __int16 /*flags*/, const char* description) bool value, unsigned __int16 /*flags*/, const char* description)
{ {
@ -286,6 +333,8 @@ void player_movement::patch_mp()
utils::hook(0x4225CA, &player_movement::jump_apply_slowdown_stub, HOOK_CALL).install()->quick(); // PM_WalkMove utils::hook(0x4225CA, &player_movement::jump_apply_slowdown_stub, HOOK_CALL).install()->quick(); // PM_WalkMove
utils::hook(0x41669B, &player_movement::jump_get_land_factor_stub, HOOK_CALL).install()->quick(); // Jump_Start utils::hook(0x41669B, &player_movement::jump_get_land_factor_stub, HOOK_CALL).install()->quick(); // Jump_Start
utils::hook(0x422BE0, &player_movement::pm_crash_land_stub_mp, HOOK_CALL).install()->quick(); // PM_GroundTrace
} }
void player_movement::patch_sp() void player_movement::patch_sp()
@ -313,6 +362,8 @@ void player_movement::patch_sp()
utils::hook(0x63EA46, player_movement::jump_push_off_ladder_stub, HOOK_JUMP).install()->quick(); // Jump_Check utils::hook(0x63EA46, player_movement::jump_push_off_ladder_stub, HOOK_JUMP).install()->quick(); // Jump_Check
utils::hook::nop(0x63EA4B, 1); // Nop skipped opcode utils::hook::nop(0x63EA4B, 1); // Nop skipped opcode
utils::hook(0x6442DF, &player_movement::pm_crash_land_stub_sp, HOOK_CALL).install()->quick(); // PM_GroundTrace
} }
void player_movement::post_load() void player_movement::post_load()
@ -335,6 +386,8 @@ void player_movement::post_load()
true, game::native::DVAR_CODINFO, "Push intersecting players away from each other"); true, game::native::DVAR_CODINFO, "Push intersecting players away from each other");
player_movement::pm_elevators = game::native::Dvar_RegisterBool("pm_elevators", player_movement::pm_elevators = game::native::Dvar_RegisterBool("pm_elevators",
false, game::native::DVAR_CODINFO, "CoD4 Elevators"); false, game::native::DVAR_CODINFO, "CoD4 Elevators");
player_movement::jump_enableFallDamage = game::native::Dvar_RegisterBool("jump_enableFallDamage",
true, game::native::dvar_flags::DVAR_CODINFO, "Enable fall damage");
if (game::is_mp()) this->patch_mp(); if (game::is_mp()) this->patch_mp();
else if (game::is_sp()) this->patch_sp(); else if (game::is_sp()) this->patch_sp();

View File

@ -10,6 +10,7 @@ private:
static const game::native::dvar_t* player_sustainAmmo; static const game::native::dvar_t* player_sustainAmmo;
static const game::native::dvar_t* jump_slowdownEnable; static const game::native::dvar_t* jump_slowdownEnable;
static const game::native::dvar_t* jump_ladderPushVel; static const game::native::dvar_t* jump_ladderPushVel;
static const game::native::dvar_t* jump_enableFallDamage;
static const game::native::dvar_t* jump_height; static const game::native::dvar_t* jump_height;
static const game::native::dvar_t* pm_bounces; static const game::native::dvar_t* pm_bounces;
static const game::native::dvar_t* pm_playerEjection; static const game::native::dvar_t* pm_playerEjection;
@ -59,6 +60,9 @@ private:
static float jump_get_land_factor(game::native::playerState_s* ps); static float jump_get_land_factor(game::native::playerState_s* ps);
static void jump_get_land_factor_stub(); static void jump_get_land_factor_stub();
static void pm_crash_land_stub_mp();
static void pm_crash_land_stub_sp();
static void patch_mp(); static void patch_mp();
static void patch_sp(); static void patch_sp();
}; };