From c4520b7ab826ea5cfe395fc91c4607a81c0f39bb Mon Sep 17 00:00:00 2001 From: rtldg <55846624+rtldg@users.noreply.github.com> Date: Fri, 30 Apr 2021 22:21:59 +0000 Subject: [PATCH] add jank replay bot footstep sounds --- addons/sourcemod/gamedata/shavit.games.txt | 4 +++ addons/sourcemod/scripting/shavit-misc.sp | 39 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/addons/sourcemod/gamedata/shavit.games.txt b/addons/sourcemod/gamedata/shavit.games.txt index 7b7cea3c..33233345 100644 --- a/addons/sourcemod/gamedata/shavit.games.txt +++ b/addons/sourcemod/gamedata/shavit.games.txt @@ -61,6 +61,10 @@ "linux" "1" "mac" "1" } + "CBasePlayer::UpdateStepSound" + { + "windows" "408" + } } "Addresses" diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 602c6326..3a8485dd 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -149,6 +149,7 @@ Handle gH_Forwards_OnCheckpointMenuSelect = null; // dhooks Handle gH_GetPlayerMaxSpeed = null; +DynamicHook gH_UpdateStepSound = null; DynamicHook gH_IsSpawnPointValid = null; // modules @@ -353,6 +354,18 @@ public void OnPluginStart() SetFailState("Couldn't get the offset for \"CCSPlayer::GetPlayerMaxSpeed\" - make sure your gamedata is updated!"); } + if ((iOffset = GameConfGetOffset(hGameData, "CBasePlayer::UpdateStepSound")) != -1) + { + gH_UpdateStepSound = new DynamicHook(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity); + gH_UpdateStepSound.AddParam(HookParamType_Unknown); + gH_UpdateStepSound.AddParam(HookParamType_Unknown); + gH_UpdateStepSound.AddParam(HookParamType_Unknown); + } + else + { + SetFailState("Couldn't get the offset for \"CBasePlayer::UpdateStepSound\" - make sure your gamedata is updated!"); + } + if ((iOffset = GameConfGetOffset(hGameData, "CGameRules::IsSpawnPointValid")) != -1) { gH_IsSpawnPointValid = new DynamicHook(iOffset, HookType_GameRules, ReturnType_Bool, ThisPointer_Ignore); @@ -840,6 +853,30 @@ public MRESReturn CCSPlayer__GetPlayerMaxSpeed(int pThis, Handle hReturn) return MRES_Override; } +public MRESReturn Hook_UpdateStepSound_Pre(int pThis, Handle hReturn) +{ + if (GetEntityMoveType(pThis) == MOVETYPE_NOCLIP) + { + SetEntityMoveType(pThis, MOVETYPE_WALK); + } + + SetEntityFlags(pThis, GetEntityFlags(pThis) & ~FL_ATCONTROLS); + + return MRES_Ignored; +} + +public MRESReturn Hook_UpdateStepSound_Post(int pThis, Handle hReturn) +{ + if (GetEntityMoveType(pThis) == MOVETYPE_WALK) + { + SetEntityMoveType(pThis, MOVETYPE_NOCLIP); + } + + SetEntityFlags(pThis, GetEntityFlags(pThis) | FL_ATCONTROLS); + + return MRES_Ignored; +} + public Action Timer_Cron(Handle timer) { if(gCV_HideRadar.BoolValue && gEV_Type == Engine_CSS) @@ -1188,6 +1225,8 @@ public void OnClientPutInServer(int client) if(IsFakeClient(client)) { + gH_UpdateStepSound.HookEntity(Hook_Pre, client, Hook_UpdateStepSound_Pre); + gH_UpdateStepSound.HookEntity(Hook_Post, client, Hook_UpdateStepSound_Post); return; }