From d3eaebcf83cbda8f86e0414a19fc63df732def3a Mon Sep 17 00:00:00 2001 From: SirPlease Date: Fri, 23 Aug 2024 11:14:52 +0200 Subject: [PATCH] Add back firebulletsfix Simply fixes the issue where the bullet is misplaced by a single tick, the issue gets less noticable the higher the tickrate, but might as well include it. Notes: - This plugin can easily be improved, but I'm honestly too tired atm to work it out (Basically detect when a client is trying to shoot and is able to, fire the SDKCall, and then use the weapon_fire event to call it again and reset the Vec to the previous tick) - Take the note above with a grain of salt as it's likely to make it even simpler and accurate than that. - Right now, it will "correct" every time a player's weapon is drawn out, when they're shooting, when they're shoving and when they're melee-ing. I am not sure about the possible issues this could cause. --- .../gamedata/firebulletsfix.games.txt | 117 ++++++++++++++++++ .../plugins/fixes/firebulletsfix.smx | Bin 0 -> 4441 bytes addons/sourcemod/scripting/firebulletsfix.sp | 103 +++++++++++++++ cfg/generalfixes.cfg | 1 + 4 files changed, 221 insertions(+) create mode 100644 addons/sourcemod/gamedata/firebulletsfix.games.txt create mode 100644 addons/sourcemod/plugins/fixes/firebulletsfix.smx create mode 100644 addons/sourcemod/scripting/firebulletsfix.sp diff --git a/addons/sourcemod/gamedata/firebulletsfix.games.txt b/addons/sourcemod/gamedata/firebulletsfix.games.txt new file mode 100644 index 000000000..4a2186e87 --- /dev/null +++ b/addons/sourcemod/gamedata/firebulletsfix.games.txt @@ -0,0 +1,117 @@ +"Games" +{ + "cstrike" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "265" + "linux" "266" + "mac" "266" + } + } + } + + "csgo" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "290" + "linux" "291" + "mac" "291" + } + } + } + + "left4dead2" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "285" + "linux" "286" + "mac" "286" + } + } + } + + "tf" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "272" + "linux" "273" + "mac" "273" + } + } + } + + "left4dead" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "264" + "linux" "265" + "mac" "265" + } + } + } + + "dod" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "265" + "linux" "266" + "mac" "266" + } + } + } + + "nucleardawn" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "296" + "linux" "297" + "mac" "297" + } + } + } + + "hl2mp" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "265" + "linux" "266" + "mac" "266" + } + } + } + + "NeotokyoSource" + { + "Offsets" + { + "Weapon_ShootPosition" + { + "windows" "221" + } + } + } +} diff --git a/addons/sourcemod/plugins/fixes/firebulletsfix.smx b/addons/sourcemod/plugins/fixes/firebulletsfix.smx new file mode 100644 index 0000000000000000000000000000000000000000..25386f2a8b329b2a0a1539d1668bb3ac3a5e5b47 GIT binary patch literal 4441 zcmYk6c|6qn_s7R*C`)9^E(+O3S+geDL&=tAEF)sFO&I$+*%Cw67=tWXu3a&9lY~ax zaI?n5h%vS++2i}^-tOb~`#c`6$Lo2{`+Uwh@6R6}1A{x3U^+Uxb0CnHG6=+Vnhpe- z2lVUtP-+yy3z>IPrkQ3ku zfZPDa0-gcr2f*xr7XX3)15pqVs1jhb;=lRV0LKChv;q+U)dMU9%o+lCNa^4Apbvap zTtQG5gg*iVMWLNNkq`X-fdGUr0Nx0HWPs~G;02hkzd!Qd+JDH))!*I6<#+nO(tl1| zz0qF3^ZvmoR~OfZ|1a`$_5U3`@I?6e{omn3q^l>;4(j6U27QS1{5AI%dLq65L!|dZ zpMR78&Hkst&C|yj;rU;=&x2naG_`i$3uR@?ryUq*$1!mUm)i8YG{D31KtJ2;G*{~V zi5Pa-7-i$=&({XTL(^C5Cfim!rX|i^uTrMH+ z3jI={s(balS<=>(<@ds7LuU``aTL?TE{*T&enW>dq1vyr2Zd@}ENT40j!bJsIL*`(DmXbe9 z6Ou3jcTr84>0q8fM|aQWy=M>RN@{8$-aY0v2n=OxKdnN)d{g)(IGmmt=Dpf*;d*8iv#F;S!HDfd`U(7v;eP zZ^qDUQ8$^Owd4R9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u_~#jk5t3}63r?z#~0u{D+tPt}w~fG6~SnimU3mqmTq z)^awed!F(|q$q?ww0w^4;qswp+C?`tZn2aP=+wUT%vH?P#%h(c#RHE&5k+tk-6 z49VOpiww-%=%c89tMcg>Z}eTG$wp``B3e)ZHbW8XABQAquZ{0ep~UdTa@nFrkmN{s z+Wn7h`?@Ce7k;R;#4Hr#`%Y#o1P-ZxiR|cA9D=J@?P={KzBEuv3^wtNwMw@dS>s4P zVBBivd|XlDp~8>mczo@Loy~|nZ*nL6z}G0pJ?j;Vn=(~GO2Itz!bMx-+7l539r)yb DY#=Vy literal 0 HcmV?d00001 diff --git a/addons/sourcemod/scripting/firebulletsfix.sp b/addons/sourcemod/scripting/firebulletsfix.sp new file mode 100644 index 000000000..dc06c69cc --- /dev/null +++ b/addons/sourcemod/scripting/firebulletsfix.sp @@ -0,0 +1,103 @@ +#include +#include +#pragma semicolon 1 +#pragma newdecls required + +DynamicHook g_hWeapon_ShootPosition; +Handle g_hWeapon_ShootPosition_SDKCall; +float g_vecOldWeaponShootPos[MAXPLAYERS + 1][3]; +bool g_bCallingWeapon_ShootPosition; +EngineVersion g_EngineVersion; + +public Plugin myinfo = +{ + name = "Bullet position fix", + author = "xutaxkamay", /* With some slight changes based on reports/suggestions by Krevik/HarryPotter from the same Alliedmodders thread */ + description = "Fixes shoot position", + version = "1.0.3", + url = "https://forums.alliedmods.net/showthread.php?p=2646571" +}; + +public void OnPluginStart() +{ + GameData gameData = new GameData("firebulletsfix.games"); + g_EngineVersion = GetEngineVersion(); + + if (!gameData) + SetFailState("[FireBullets Fix] No game data present"); + + int offset = gameData.GetOffset("Weapon_ShootPosition"); + + if (offset == -1) + SetFailState("[FireBullets Fix] failed to find offset"); + + LogMessage("Found offset for Weapon_ShootPosition %d", offset); + + + StartPrepSDKCall(SDKCall_Player); + + if (!PrepSDKCall_SetFromConf(gameData, SDKConf_Virtual, "Weapon_ShootPosition")) + SetFailState("[FireBullets Fix] couldn't read config for preparing Weapon_ShootPosition SDKCall"); + + PrepSDKCall_SetReturnInfo(SDKType_Vector, SDKPass_ByValue); + g_hWeapon_ShootPosition_SDKCall = EndPrepSDKCall(); + + if (g_hWeapon_ShootPosition_SDKCall == INVALID_HANDLE) + SetFailState("[FireBullets Fix] couldn't prepare Weapon_ShootPosition SDKCall"); + + g_hWeapon_ShootPosition = new DynamicHook(offset, HookType_Entity, ReturnType_Vector, ThisPointer_CBaseEntity); + + if (!g_hWeapon_ShootPosition) + SetFailState("[FireBullets Fix] couldn't hook Weapon_ShootPosition"); + + delete gameData; + + for (int i = 1; i <= MaxClients; i++) + { + if (IsClientInGame(i)) + OnClientPutInServer(i); + } +} + +public void OnClientPutInServer(int client) +{ + if (!IsFakeClient(client)) + g_hWeapon_ShootPosition.HookEntity(Hook_Post, client, Weapon_ShootPosition_Post); +} + +public Action OnPlayerRunCmd(int client) +{ + if (IsPlayerAlive(client) && !IsFakeClient(client)) + { + g_bCallingWeapon_ShootPosition = true; + SDKCall(g_hWeapon_ShootPosition_SDKCall, client, g_vecOldWeaponShootPos[client]); + g_bCallingWeapon_ShootPosition = false; + } + return Plugin_Continue; +} + +public MRESReturn Weapon_ShootPosition_Post(int client, DHookReturn hReturn) +{ + if (!g_bCallingWeapon_ShootPosition) + { + switch(g_EngineVersion) + { + // Only care about Survivors in Left 4 Dead series due to issues with props hit by Tanks. + case Engine_Left4Dead, Engine_Left4Dead2: + { + if (GetClientTeam(client) != 2) + return MRES_Ignored; + } + default: { /* Nothing? */ } + } + #if defined DEBUG + float g_vecWeaponShootPos[3]; + hReturn.GetVector(g_vecWeaponShootPos); + PrintToConsoleAll("[FireBullets Fix] Old Weapon_ShootPosition: %.2f, %.2f, %.2f", g_vecOldWeaponShootPos[client][0], g_vecOldWeaponShootPos[client][1], g_vecOldWeaponShootPos[client][2]); + PrintToConsoleAll("[FireBullets Fix] New Weapon_ShootPosition: %.2f, %.2f, %.2f", g_vecWeaponShootPos[0], g_vecWeaponShootPos[1], g_vecWeaponShootPos[2]); + #endif + hReturn.SetVector(g_vecOldWeaponShootPos[client]); + return MRES_Supercede; + } + return MRES_Ignored; +} \ No newline at end of file diff --git a/cfg/generalfixes.cfg b/cfg/generalfixes.cfg index 0e70aa9fe..a75da925e 100644 --- a/cfg/generalfixes.cfg +++ b/cfg/generalfixes.cfg @@ -66,6 +66,7 @@ sm plugins load fixes/l4d2_null_cusercmd_fix.smx sm plugins load fixes/l4d2_tank_flying_incap.smx sm plugins load fixes/l4d2_tank_spawn_antirock_protect.smx sm plugins load fixes/l4d_fix_rotated_physblocker.smx +sm plugins load fixes/firebulletsfix.smx // Anti-Cheat. sm plugins load anticheat/l4d2_noghostcheat.smx