Player collision
This commit is contained in:
parent
0f614c06de
commit
72ff015aa3
@ -63,6 +63,8 @@ namespace game
|
||||
|
||||
PM_WeaponUseAmmo_t PM_WeaponUseAmmo;
|
||||
|
||||
CM_TransformedCapsuleTrace_t CM_TransformedCapsuleTrace;
|
||||
|
||||
Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand;
|
||||
|
||||
decltype(longjmp)* _longjmp;
|
||||
@ -664,6 +666,9 @@ namespace game
|
||||
|
||||
native::PM_WeaponUseAmmo = native::PM_WeaponUseAmmo_t(SELECT_VALUE(0x463F80, 0x42E930, 0x0));
|
||||
|
||||
native::CM_TransformedCapsuleTrace = native::CM_TransformedCapsuleTrace_t(
|
||||
SELECT_VALUE(0x4F9B80, 0x541340, 0x0));
|
||||
|
||||
native::Cmd_ExecuteSingleCommand = native::Cmd_ExecuteSingleCommand_t(
|
||||
SELECT_VALUE(0x4D6960, 0x5462B0, 0x4CC360));
|
||||
|
||||
|
@ -100,6 +100,11 @@ namespace game
|
||||
typedef void (*PM_WeaponUseAmmo_t)(playerState_s* ps, const Weapon weapon, bool isAlternate, int amount, PlayerHandIndex hand);
|
||||
extern PM_WeaponUseAmmo_t PM_WeaponUseAmmo;
|
||||
|
||||
typedef void (*CM_TransformedCapsuleTrace_t)(game::native::trace_t* results, const float* start, const float* end,
|
||||
const game::native::Bounds* bounds, const game::native::Bounds* capsule, int contents,
|
||||
const float* origin, const float* angles);
|
||||
extern CM_TransformedCapsuleTrace_t CM_TransformedCapsuleTrace;
|
||||
|
||||
typedef void (*Cmd_ExecuteSingleCommand_t)(LocalClientNum_t localClientNum, int controllerIndex, const char* text);
|
||||
extern Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand;
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
const game::native::dvar_t* player_movement::player_sustainAmmo;
|
||||
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_playerCollision;
|
||||
|
||||
void player_movement::pm_weapon_use_ammo(game::native::playerState_s* ps, const game::native::Weapon weapon,
|
||||
bool is_alternate, int amount, game::native::PlayerHandIndex hand)
|
||||
@ -69,6 +71,27 @@ __declspec(naked) void player_movement::pm_step_slide_move_stub_sp()
|
||||
}
|
||||
}
|
||||
|
||||
int player_movement::stuck_in_client_stub(game::native::gentity_s* self)
|
||||
{
|
||||
if (player_movement::pm_playerEjection->current.enabled)
|
||||
{
|
||||
return reinterpret_cast<int(*)(game::native::gentity_s*)>(0x4F8930)(self);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void player_movement::cm_transformed_capsule_trace_stub(game::native::trace_t* results, const float* start,
|
||||
const float* end, const game::native::Bounds* bounds, const game::native::Bounds* capsule, int contents,
|
||||
const float* origin, const float* angles)
|
||||
{
|
||||
if (player_movement::pm_playerCollision->current.enabled)
|
||||
{
|
||||
game::native::CM_TransformedCapsuleTrace(results, start, end,
|
||||
bounds, capsule, contents, origin, angles);
|
||||
}
|
||||
}
|
||||
|
||||
const game::native::dvar_t* player_movement::dvar_register_player_sustain_ammo(const char* dvar_name,
|
||||
bool value, unsigned __int16 /*flags*/, const char* description)
|
||||
{
|
||||
@ -80,6 +103,9 @@ const game::native::dvar_t* player_movement::dvar_register_player_sustain_ammo(c
|
||||
|
||||
void player_movement::patch_mp()
|
||||
{
|
||||
player_movement::pm_playerEjection = game::native::Dvar_RegisterBool("pm_playerEjection",
|
||||
true, game::native::DVAR_CODINFO, "Push intersecting players away from each other");
|
||||
|
||||
utils::hook(0x418D9C, &player_movement::dvar_register_player_sustain_ammo, HOOK_CALL).install()->quick();
|
||||
|
||||
utils::hook(0x42B5DA, &player_movement::pm_weapon_use_ammo, HOOK_CALL).install()->quick();
|
||||
@ -87,6 +113,10 @@ void player_movement::patch_mp()
|
||||
utils::hook(0x42AE95, &player_movement::pm_weapon_use_ammo, HOOK_CALL).install()->quick();
|
||||
|
||||
utils::hook(0x424D51, &player_movement::pm_step_slide_move_stub_mp, HOOK_JUMP).install()->quick();
|
||||
|
||||
utils::hook(0x4F9EFB, &player_movement::stuck_in_client_stub, HOOK_CALL).install()->quick(); // ClientEndFrame
|
||||
utils::hook(0x57CF45, &player_movement::cm_transformed_capsule_trace_stub, HOOK_CALL).install()->quick(); // SV_ClipMoveToEntity
|
||||
utils::hook(0x482C1B, &player_movement::cm_transformed_capsule_trace_stub, HOOK_CALL).install()->quick(); // CG_ClipMoveToEntity
|
||||
}
|
||||
|
||||
void player_movement::patch_sp()
|
||||
@ -99,6 +129,9 @@ void player_movement::patch_sp()
|
||||
utils::hook(0x6484E2, &player_movement::pm_weapon_use_ammo, HOOK_CALL).install()->quick();
|
||||
|
||||
utils::hook(0x43D918, &player_movement::pm_step_slide_move_stub_sp, HOOK_JUMP).install()->quick();
|
||||
|
||||
utils::hook(0x41F9A6, &player_movement::cm_transformed_capsule_trace_stub, HOOK_CALL).install()->quick(); // SV_ClipMoveToEntity
|
||||
utils::hook(0x57B14F, &player_movement::cm_transformed_capsule_trace_stub, HOOK_CALL).install()->quick(); // CG_ClipMoveToEntity
|
||||
}
|
||||
|
||||
void player_movement::post_load()
|
||||
@ -110,6 +143,8 @@ void player_movement::post_load()
|
||||
|
||||
player_movement::pm_bounces = game::native::Dvar_RegisterBool("pm_bounces", false,
|
||||
game::native::dvar_flags::DVAR_CODINFO, "CoD4 Bounces");
|
||||
player_movement::pm_playerCollision = game::native::Dvar_RegisterBool("pm_playerCollision",
|
||||
true, game::native::DVAR_CODINFO, "Push intersecting players away from each other");
|
||||
|
||||
if (game::is_mp()) this->patch_mp();
|
||||
else if (game::is_sp()) this->patch_sp();
|
||||
|
@ -10,6 +10,8 @@ public:
|
||||
private:
|
||||
static const game::native::dvar_t* player_sustainAmmo;
|
||||
static const game::native::dvar_t* pm_bounces;
|
||||
static const game::native::dvar_t* pm_playerEjection;
|
||||
static const game::native::dvar_t* pm_playerCollision;
|
||||
|
||||
static void pm_weapon_use_ammo(game::native::playerState_s* ps, const game::native::Weapon weapon,
|
||||
bool isAlternate, int amount, game::native::PlayerHandIndex hand);
|
||||
@ -20,6 +22,11 @@ private:
|
||||
static void pm_step_slide_move_stub_mp();
|
||||
static void pm_step_slide_move_stub_sp();
|
||||
|
||||
static int stuck_in_client_stub(game::native::gentity_s* self);
|
||||
static void cm_transformed_capsule_trace_stub(game::native::trace_t* results, const float* start,
|
||||
const float* end, const game::native::Bounds* bounds, const game::native::Bounds* capsule,
|
||||
int contents, const float* origin, const float* angles);
|
||||
|
||||
static void patch_mp();
|
||||
static void patch_sp();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user