2022-05-03 12:57:36 -04:00
|
|
|
#include <STDInclude.hpp>
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
Dvar::Var Bullet::BGSurfacePenetration;
|
|
|
|
Game::dvar_t* Bullet::BGBulletRange;
|
|
|
|
|
|
|
|
float Bullet::BG_GetSurfacePenetrationDepthStub(const Game::WeaponDef* weapDef, int surfaceType)
|
|
|
|
{
|
2022-08-10 17:03:26 -04:00
|
|
|
assert(weapDef);
|
|
|
|
assert(weapDef->penetrateType != Game::PENETRATE_TYPE_NONE);
|
|
|
|
AssertIn(weapDef->penetrateType, Game::PENETRATE_TYPE_COUNT);
|
|
|
|
AssertIn(surfaceType, Game::SURF_TYPE_COUNT);
|
2022-05-03 12:57:36 -04:00
|
|
|
|
|
|
|
const auto penetrationDepth = BGSurfacePenetration.get<float>();
|
|
|
|
if (penetrationDepth > 0.0f)
|
|
|
|
{
|
|
|
|
// Custom depth
|
|
|
|
return penetrationDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Game's code
|
2022-09-13 14:39:45 -04:00
|
|
|
if (surfaceType != Game::SURF_TYPE_DEFAULT)
|
2022-05-03 12:57:36 -04:00
|
|
|
{
|
|
|
|
return (*Game::penetrationDepthTable)[weapDef->penetrateType][surfaceType];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
__declspec(naked) void Bullet::Bullet_FireStub()
|
|
|
|
{
|
|
|
|
__asm
|
|
|
|
{
|
|
|
|
push eax
|
|
|
|
mov eax, BGBulletRange
|
|
|
|
fld dword ptr [eax + 0x10] // dvar_t.current.value
|
|
|
|
pop eax
|
|
|
|
|
|
|
|
push 0x440346
|
|
|
|
retn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Bullet::Bullet()
|
|
|
|
{
|
2022-05-27 06:19:28 -04:00
|
|
|
BGSurfacePenetration = Dvar::Register<float>("bg_surfacePenetration", 0.0f,
|
2022-07-02 13:52:57 -04:00
|
|
|
0.0f, std::numeric_limits<float>::max(), Game::DVAR_CODINFO,
|
2022-05-27 06:19:28 -04:00
|
|
|
"Set to a value greater than 0 to override the surface penetration depth");
|
|
|
|
BGBulletRange = Game::Dvar_RegisterFloat("bg_bulletRange", 8192.0f,
|
2022-07-02 13:52:57 -04:00
|
|
|
0.0f, std::numeric_limits<float>::max(), Game::DVAR_CODINFO,
|
2022-05-27 06:19:28 -04:00
|
|
|
"Max range used when calculating the bullet end position");
|
2022-05-03 12:57:36 -04:00
|
|
|
|
|
|
|
Utils::Hook(0x4F6980, BG_GetSurfacePenetrationDepthStub, HOOK_JUMP).install()->quick();
|
|
|
|
Utils::Hook(0x440340, Bullet_FireStub, HOOK_JUMP).install()->quick();
|
|
|
|
}
|
|
|
|
}
|