Skip to content

Commit 83464e9

Browse files
authored
[Experimental] Fix LOS through thin/small props (#962)
* Add plugin `l4d_fix_prop_los` * Add compiled `l4d_fix_prop_los` * Add `l4d_fix_prop_los` to generalfixes * Fix missing definition
1 parent 2857d14 commit 83464e9

4 files changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"Games"
2+
{
3+
"#default"
4+
{
5+
"Functions"
6+
{
7+
"l4d_fix_prop_los::CBaseProp::CalculateBlockLOS"
8+
{
9+
"signature" "CBaseProp::CalculateBlockLOS"
10+
"callconv" "thiscall"
11+
"return" "void"
12+
"this" "entity"
13+
}
14+
}
15+
}
16+
17+
"left4dead"
18+
{
19+
"Signatures"
20+
{
21+
"CBaseProp::CalculateBlockLOS"
22+
{
23+
"library" "server"
24+
"linux" "@_ZN9CBaseProp17CalculateBlockLOSEv"
25+
"windows" "\x83\xEC\x0C\x53\x55\x8B\xE9\x8B\x85\x2A\x2A\x2A\x2A\x8B"
26+
// 83 EC 0C 53 55 8B E9 8B 85 ? ? ? ? 8B
27+
}
28+
}
29+
}
30+
31+
"left4dead2"
32+
{
33+
"Signatures"
34+
{
35+
"CBaseProp::CalculateBlockLOS"
36+
{
37+
"library" "server"
38+
"linux" "@_ZN9CBaseProp17CalculateBlockLOSEv"
39+
"windows" "\x55\x8B\xEC\x83\xEC\x10\x53\x8B\xD9\x8B\x83\x2A\x2A\x2A\x2A\x8B"
40+
// 55 8B EC 83 EC 10 53 8B D9 8B 83 ? ? ? ? 8B
41+
// Search string "ai_addon_thrownprojectile"
42+
// Called inside
43+
}
44+
}
45+
}
46+
}
3.55 KB
Binary file not shown.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#pragma semicolon 1
2+
#pragma newdecls required
3+
4+
#include <sourcemod>
5+
#include <dhooks>
6+
7+
#define PLUGIN_VERSION "1.0"
8+
9+
public Plugin myinfo =
10+
{
11+
name = "[L4D & 2] Fix Prop LOS",
12+
author = "Forgetest",
13+
description = "Fix thin/small 'prop_*' entity not blocking LOS.",
14+
version = PLUGIN_VERSION,
15+
url = "https://github.com/Target5150/MoYu_Server_Stupid_Plugins",
16+
}
17+
18+
methodmap GameDataWrapper < GameData {
19+
public GameDataWrapper(const char[] file) {
20+
GameData gd = new GameData(file);
21+
if (!gd) SetFailState("Missing gamedata \"%s\"", file);
22+
return view_as<GameDataWrapper>(gd);
23+
}
24+
public DynamicDetour CreateDetourOrFail(
25+
const char[] name,
26+
DHookCallback preHook = INVALID_FUNCTION,
27+
DHookCallback postHook = INVALID_FUNCTION) {
28+
DynamicDetour hSetup = DynamicDetour.FromConf(this, name);
29+
if (!hSetup)
30+
SetFailState("Missing detour setup \"%s\"", name);
31+
if (preHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Pre, preHook))
32+
SetFailState("Failed to pre-detour \"%s\"", name);
33+
if (postHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Post, postHook))
34+
SetFailState("Failed to post-detour \"%s\"", name);
35+
return hSetup;
36+
}
37+
}
38+
39+
public void OnPluginStart()
40+
{
41+
GameDataWrapper gd = new GameDataWrapper("l4d_fix_prop_los");
42+
delete gd.CreateDetourOrFail("l4d_fix_prop_los::CBaseProp::CalculateBlockLOS", DTR_CalculateBlockLOS);
43+
delete gd;
44+
}
45+
46+
MRESReturn DTR_CalculateBlockLOS(int entity)
47+
{
48+
return MRES_Supercede;
49+
}

cfg/generalfixes.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ sm plugins load fixes/l4d2_fix_rocket_pull.smx
7171
sm plugins load optional/l4d_return_thrown_items.smx
7272
sm plugins load fixes/l4d_prop_touching_rules.smx
7373
sm plugins load fixes/l4d2_fix_tank_rock_handoff.smx
74+
sm plugins load fixes/l4d_fix_prop_los.smx
7475

7576
// Anti-Cheat.
7677
sm plugins load optional/l4d2_block_autoaim.smx // Sort of a cheat..?

0 commit comments

Comments
 (0)