BG_WeaponRecoilMultiplier

This commit is contained in:
Louvenarde 2023-08-19 18:09:20 +02:00
parent 353c36cf46
commit 1800341b95
2 changed files with 39 additions and 0 deletions

View File

@ -12,6 +12,7 @@ namespace Components
const Game::dvar_t* PlayerMovement::BGPlayerEjection;
const Game::dvar_t* PlayerMovement::BGPlayerCollision;
const Game::dvar_t* PlayerMovement::BGClimbAnything;
const Game::dvar_t* PlayerMovement::BGRecoilMultiplier;
const Game::dvar_t* PlayerMovement::CGNoclipScaler;
const Game::dvar_t* PlayerMovement::CGUfoScaler;
const Game::dvar_t* PlayerMovement::PlayerSpectateSpeedScale;
@ -273,6 +274,33 @@ namespace Components
return PlayerSpectateSpeedScale;
}
void PlayerMovement::BG_WeaponFireRecoil_Stub(
void* ps,
float* recoilSpeed,
float* kickAVel,
unsigned int* holdrand,
Game::PlayerHandIndex hand
)
{
float adjustedRecoilSpeed[3]{};
float adjustedKick[3]{};
Utils::Hook::Call<void(void*, float*, float*, unsigned int*, Game::PlayerHandIndex)>(0x4A5FE0)(
ps,
adjustedRecoilSpeed,
adjustedKick,
holdrand,
hand
);
for (size_t axis = 0; axis < 3; axis++)
{
recoilSpeed [axis] = adjustedRecoilSpeed[axis] * BGRecoilMultiplier->current.value;
kickAVel [axis] = adjustedKick[axis] * BGRecoilMultiplier->current.value;
}
}
void PlayerMovement::RegisterMovementDvars()
{
PlayerDuckedSpeedScale = Game::Dvar_RegisterFloat("player_duckedSpeedScale",
@ -313,8 +341,13 @@ namespace Components
BGClimbAnything = Game::Dvar_RegisterBool("bg_climbAnything",
false, Game::DVAR_CODINFO, "Treat any surface as a ladder");
BGRecoilMultiplier = Game::Dvar_RegisterFloat("bg_recoilMultiplier",
1.0f, 0.0f, 1000.0f, Game::DVAR_CODINFO,
"The scale applied to the player recoil when firing");
}
PlayerMovement::PlayerMovement()
{
AssertOffset(Game::playerState_s, eFlags, 0xB0);
@ -374,6 +407,9 @@ namespace Components
Utils::Hook(0x570020, PM_CrashLand_Stub, HOOK_CALL).install()->quick(); // Vec3Scale
Utils::Hook(0x4E9889, Jump_Check_Stub, HOOK_JUMP).install()->quick();
Utils::Hook(0x44D90B, BG_WeaponFireRecoil_Stub, HOOK_CALL).install()->quick();
Utils::Hook(0x4FB2D7, BG_WeaponFireRecoil_Stub, HOOK_CALL).install()->quick();
GSC::Script::AddMethod("IsSprinting", GScr_IsSprinting);
RegisterMovementDvars();

View File

@ -17,6 +17,7 @@ namespace Components
static const Game::dvar_t* BGPlayerEjection;
static const Game::dvar_t* BGPlayerCollision;
static const Game::dvar_t* BGClimbAnything;
static const Game::dvar_t* BGRecoilMultiplier;
static const Game::dvar_t* CGNoclipScaler;
static const Game::dvar_t* CGUfoScaler;
static const Game::dvar_t* PlayerSpectateSpeedScale;
@ -53,6 +54,8 @@ namespace Components
static const Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
static void BG_WeaponFireRecoil_Stub(void* ps, float* recoilSpeed, float* kickAVel, unsigned int* holdrand, Game::PlayerHandIndex hand);
static void RegisterMovementDvars();
};
}