Skip to content

Commit e7f7238

Browse files
committed
Patch Aim Assist
While this significantly nerfs controller players (I'm sorry), there's been a longstanding exploit that some M&K players were abusing in order to get the same aim assist. All this plugin does is disable the functionality entirely. I've placed the plugin in the optional folder, just in case server owners don't want to autoload it in non-competitive modes, but I did place loading of it in generalfixes.cfg so that it'll get loaded by every matchmode.
1 parent d802929 commit e7f7238

4 files changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"Games"
2+
{
3+
"left4dead2"
4+
{
5+
"Functions"
6+
{
7+
"CBasePlayer::ShouldAutoaim"
8+
{
9+
"signature" "CBasePlayer::ShouldAutoaim"
10+
"callconv" "thiscall"
11+
"return" "bool"
12+
"this" "entity"
13+
}
14+
}
15+
16+
"Signatures"
17+
{
18+
"CBasePlayer::ShouldAutoaim"
19+
{
20+
"library" "server"
21+
"linux" "@_ZN11CBasePlayer13ShouldAutoaimEv"
22+
"windows" "\x56\x8B\xF1\x8B\x06\x8B\x90\x74\x07\x00\x00\xFF\xD2\x84\xC0\x74\x2A\x32\xC0"
23+
/* 56 8B F1 8B 06 8B 90 74 07 00 00 FF D2 84 C0 74 ?? 32 C0 */
24+
}
25+
}
26+
}
27+
}
3.78 KB
Binary file not shown.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#pragma semicolon 1
2+
#pragma newdecls required
3+
4+
#include <sourcemod>
5+
#include <dhooks>
6+
7+
#define PLUGIN_VERSION "1.0"
8+
#define GAMEDATA_FILE "l4d2_block_autoaim"
9+
#define FUNCTION_NAME "CBasePlayer::ShouldAutoaim"
10+
11+
public Plugin myinfo =
12+
{
13+
name = "[L4D2] Block Autoaim",
14+
author = "Sir",
15+
description = "Strips Auto-Aim from the game entirely (disables controller aim-assist + patches an exploit)",
16+
version = PLUGIN_VERSION,
17+
url = ""
18+
};
19+
20+
ConVar g_cvEnabled;
21+
DynamicDetour g_hDetour;
22+
bool g_bDetourEnabled;
23+
24+
public void OnPluginStart()
25+
{
26+
GameData gd = new GameData(GAMEDATA_FILE);
27+
if (!gd) {
28+
SetFailState("Missing gamedata \"" ... GAMEDATA_FILE ... ".txt\"");
29+
}
30+
31+
g_hDetour = DynamicDetour.FromConf(gd, FUNCTION_NAME);
32+
delete gd;
33+
34+
if (!g_hDetour) {
35+
SetFailState("Failed to set up detour for \"" ... FUNCTION_NAME ... "\"");
36+
}
37+
38+
g_cvEnabled = CreateConVar(
39+
"l4d2_block_autoaim",
40+
"1",
41+
"Disable Auto-Aim",
42+
FCVAR_NOTIFY,
43+
true, 0.0, true, 1.0
44+
);
45+
g_cvEnabled.AddChangeHook(OnEnabledChanged);
46+
47+
ApplyDetourState(g_cvEnabled.BoolValue);
48+
}
49+
50+
public void OnPluginEnd()
51+
{
52+
ApplyDetourState(false);
53+
}
54+
55+
void OnEnabledChanged(ConVar convar, const char[] oldValue, const char[] newValue)
56+
{
57+
ApplyDetourState(convar.BoolValue);
58+
}
59+
60+
void ApplyDetourState(bool enable)
61+
{
62+
if (enable == g_bDetourEnabled) {
63+
return;
64+
}
65+
66+
if (enable) {
67+
if (!g_hDetour.Enable(Hook_Pre, Detour_ShouldAutoaim)) {
68+
SetFailState("Failed to enable detour on \"" ... FUNCTION_NAME ... "\"");
69+
}
70+
g_bDetourEnabled = true;
71+
} else {
72+
g_hDetour.Disable(Hook_Pre, Detour_ShouldAutoaim);
73+
g_bDetourEnabled = false;
74+
}
75+
}
76+
77+
MRESReturn Detour_ShouldAutoaim(int pPlayer, DHookReturn hReturn)
78+
{
79+
hReturn.Value = 0;
80+
return MRES_Supercede;
81+
}

cfg/generalfixes.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ sm plugins load optional/l4d_return_thrown_items.smx
7272
sm plugins load fixes/l4d_prop_touching_rules.smx
7373

7474
// Anti-Cheat.
75+
sm plugins load optional/l4d2_block_autoaim.smx // Sort of a cheat..?
7576
sm plugins load anticheat/l4d2_noghostcheat.smx

0 commit comments

Comments
 (0)