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+ }
0 commit comments