From bf5ec55a6a008d5d24c7aa8b8782b9c8f5f19b00 Mon Sep 17 00:00:00 2001 From: rtldg Date: Sun, 9 Mar 2025 07:48:51 +0000 Subject: [PATCH] save m_afButtonDisabled & m_afButtonForced in checkpoints (mainly for player_speedmod) this makes kz_bhop_genkai a bit more bearable at times this also isn't perfect since restarting doesn't reset them --- addons/sourcemod/gamedata/shavit.games.txt | 9 ++++++++ .../scripting/include/shavit/checkpoints.inc | 5 +++++ .../sourcemod/scripting/shavit-checkpoints.sp | 22 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/gamedata/shavit.games.txt b/addons/sourcemod/gamedata/shavit.games.txt index a5257768..c839bff3 100644 --- a/addons/sourcemod/gamedata/shavit.games.txt +++ b/addons/sourcemod/gamedata/shavit.games.txt @@ -346,6 +346,15 @@ "linux" "\xC7\x80\x2A\x2A\x2A\x2A\x00\x00\x80\x3F\x8B\x03" "linux64" "\xC7\x80\x2A\x2A\x2A\x2A\x00\x00\x80\x3F\x48\x8B\x07" } + // search "sv_maxusrcmdprocessticks_warning at server" to find CPlayerMove::RunCommand + // then sig the the `mov REG1,dword ptr [REG2 + OFFSET_TO_BUTTON_DISABLED_HERE]` + "CBasePlayer->m_afButtonDisabled" + { + "windows" "\x8B\x87\x2A\x2A\x2A\x2A\xF7\xD0\x23\xC1" + "windows64" "\x8B\x87\x2A\x2A\x2A\x2A\xF7\xD0" + "linux" "\x8B\x93\x2A\x2A\x2A\x2A\xF7\xD2" + "linux64" "\x8B\x83\x2A\x2A\x2A\x2A\xF7\xD0\x21\xD0" + } } } diff --git a/addons/sourcemod/scripting/include/shavit/checkpoints.inc b/addons/sourcemod/scripting/include/shavit/checkpoints.inc index 9b47c8ac..e881af04 100644 --- a/addons/sourcemod/scripting/include/shavit/checkpoints.inc +++ b/addons/sourcemod/scripting/include/shavit/checkpoints.inc @@ -61,6 +61,11 @@ enum struct cp_cache_t float m_ladderSurpressionTimer[2]; // css only // 0 = duration, 1 = remaining float m_lastLadderNormal[3]; // css only float m_lastLadderPos[3]; // css only + + // used by player_speedmod + int m_afButtonDisabled; + // used by trigger_playermovement + int m_afButtonForced; } /** diff --git a/addons/sourcemod/scripting/shavit-checkpoints.sp b/addons/sourcemod/scripting/shavit-checkpoints.sp index 68b6f5c1..88ca93e2 100644 --- a/addons/sourcemod/scripting/shavit-checkpoints.sp +++ b/addons/sourcemod/scripting/shavit-checkpoints.sp @@ -111,6 +111,8 @@ int gI_Offset_m_lastStandingPos = 0; int gI_Offset_m_ladderSurpressionTimer = 0; int gI_Offset_m_lastLadderNormal = 0; int gI_Offset_m_lastLadderPos = 0; +int gI_Offset_m_afButtonDisabled = 0; +int gI_Offset_m_afButtonForced = 0; public Plugin myinfo = { @@ -227,7 +229,7 @@ public void OnPluginStart() void LoadDHooks() { - Handle hGameData = LoadGameConfigFile("shavit.games"); + GameData hGameData = new GameData("shavit.games"); if (hGameData == null) { @@ -259,6 +261,18 @@ void LoadDHooks() } } + Address buttonsSig = hGameData.GetMemSig("CBasePlayer->m_afButtonDisabled"); + if (buttonsSig == Address_Null) + { + SetFailState("Couldn't find signature of CBasePlayer->m_afButtonDisabled"); + } + + int instr = LoadFromAddress(buttonsSig, NumberType_Int32); + // The lowest two bytes are the beginning of a `mov`. + // The offset is 100% definitely totally always 16-bit. + gI_Offset_m_afButtonDisabled = instr >> 16; + gI_Offset_m_afButtonForced = gI_Offset_m_afButtonDisabled + 4; + delete hGameData; hGameData = LoadGameConfigFile("sdktools.games"); int iOffset; @@ -1584,6 +1598,9 @@ void SaveCheckpointCache(int saver, int target, cp_cache_t cpcache, int index, H cpcache.m_ignoreLadderJumpTime = GetEntPropFloat(target, Prop_Data, "m_ignoreLadderJumpTime") - GetGameTime(); } + cpcache.m_afButtonDisabled = GetEntData(target, gI_Offset_m_afButtonDisabled); + cpcache.m_afButtonForced = GetEntData(target, gI_Offset_m_afButtonForced); + cpcache.iMoveType = GetEntityMoveType(target); cpcache.fGravity = GetEntityGravity(target); cpcache.fSpeed = GetEntPropFloat(target, Prop_Send, "m_flLaggedMovementValue"); @@ -1864,6 +1881,9 @@ bool LoadCheckpointCache(int client, cp_cache_t cpcache, int index, bool force = SetEntPropFloat(client, Prop_Send, "m_flDuckSpeed", cpcache.fDuckSpeed); } + SetEntData(client, gI_Offset_m_afButtonDisabled, cpcache.m_afButtonDisabled); + SetEntData(client, gI_Offset_m_afButtonForced, cpcache.m_afButtonForced); + // this is basically the same as normal checkpoints except much less data is used if(!isPersistentData && Shavit_GetStyleSettingInt(gI_Style[client], "kzcheckpoints")) {