diff --git a/addons/sourcemod/gamedata/l4d_fix_stagger_dir.txt b/addons/sourcemod/gamedata/l4d_fix_stagger_dir.txt index 5fdbc695f..94e23046b 100644 --- a/addons/sourcemod/gamedata/l4d_fix_stagger_dir.txt +++ b/addons/sourcemod/gamedata/l4d_fix_stagger_dir.txt @@ -27,6 +27,51 @@ "left4dead" { + "Functions" + { + "CTerrorPlayer::OnShovedBySurvivor" + { + "linux" + { + "signature" "CTerrorPlayer::OnShovedBySurvivor [clone]" + "callconv" "cdecl" + } + "windows" + { + "signature" "CTerrorPlayer::OnShovedBySurvivor" + "callconv" "stdcall" + } + "return" "void" + "arguments" + { + "this" + { + "type" "cbaseentity" + "linux" + { + "register" "eax" + } + "windows" + { + "register" "ecx" + } + } + "a2" + { + "type" "cbaseentity" + "linux" + { + "register" "edx" + } + } + "a3" + { + "type" "vectorptr" + } + } + } + } + "Offsets" { "CTerrorPlayer::m_PlayerAnimState" @@ -56,11 +101,69 @@ /* 83 ? ? ? 8B ? E8 ? ? ? ? 84 ? 0F 85 ? ? ? ? 8B ? 8B */ /* Search: "Player.Shoved" */ } + + // Stolen from left4dhooks thanks to Silvers + /* + * CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer*, Vector const&) + */ + "CTerrorPlayer::OnShovedBySurvivor" + { + "library" "server" + "linux" "@_ZN13CTerrorPlayer18OnShovedBySurvivorEPS_RK6Vector" + "windows" "\x81\x2A\x2A\x2A\x2A\x2A\x56\x8B\x2A\xE8\x2A\x2A\x2A\x2A\x84\x2A\x0F\x85" + /* 81 ? ? ? ? ? 56 8B ? E8 ? ? ? ? 84 ? 0F 85 */ + } + + // Stolen from left4dhooks thanks to Silvers + /* + * CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer*, Vector const&) [clone] + */ + "CTerrorPlayer::OnShovedBySurvivor [clone]" + { + "library" "server" + "linux" "@_ZN13CTerrorPlayer18OnShovedBySurvivorEPS_RK6Vector.part.591" + } } } "left4dead2" { + "Functions" + { + "CTerrorPlayer::OnShovedBySurvivor" + { + "signature" "CTerrorPlayer::OnShovedBySurvivor" + "linux" + { + "callconv" "cdecl" + } + "windows" + { + "callconv" "stdcall" + } + "return" "void" + "arguments" + { + "this" + { + "type" "cbaseentity" + "windows" + { + "register" "ecx" + } + } + "a2" + { + "type" "cbaseentity" + } + "a3" + { + "type" "vectorptr" + } + } + } + } + "Offsets" { /* Windows offset: @@ -104,6 +207,19 @@ * Using a long local jump as the unique portion (last few bytes of sig) */ } + + // Stolen from left4dhooks thanks to Silvers + /* + * CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer*, Vector const&) - used by L4D2 on Special Infected (got melee'd) + * unique string "jockey_ride" in CTerrorPlayer::OnLeptOnSurvivor(), look up for "JockeyZombie.Ride", look up for var_14, CTerrorPlayer::OnShovedBySurvivor is call after that + */ + "CTerrorPlayer::OnShovedBySurvivor" + { + "library" "server" + "linux" "@_ZN13CTerrorPlayer18OnShovedBySurvivorEPS_RK6Vector" + "windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\xFC\x53\x8B\x5D\x2A\x56\x57\x8B\x7D\x2A\x8B\xF1" + /* 55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 53 8B 5D ? 56 57 8B 7D ? 8B F1 */ + } } } } \ No newline at end of file diff --git a/addons/sourcemod/plugins/fixes/l4d_fix_stagger_dir.smx b/addons/sourcemod/plugins/fixes/l4d_fix_stagger_dir.smx index 662881ea4..61273305c 100644 Binary files a/addons/sourcemod/plugins/fixes/l4d_fix_stagger_dir.smx and b/addons/sourcemod/plugins/fixes/l4d_fix_stagger_dir.smx differ diff --git a/addons/sourcemod/scripting/l4d_fix_stagger_dir.sp b/addons/sourcemod/scripting/l4d_fix_stagger_dir.sp index 78a3e00b1..71e2209fa 100644 --- a/addons/sourcemod/scripting/l4d_fix_stagger_dir.sp +++ b/addons/sourcemod/scripting/l4d_fix_stagger_dir.sp @@ -2,9 +2,10 @@ #pragma newdecls required #include -#include +// #include +#include -#define PLUGIN_VERSION "1.0" +#define PLUGIN_VERSION "1.2" public Plugin myinfo = { @@ -29,28 +30,29 @@ methodmap GameDataWrapper < GameData { if (offset == -1) SetFailState("Missing offset \"%s\"", key); return offset; } - public DynamicDetour CreateDetourOrFail( - const char[] name, - DHookCallback preHook = INVALID_FUNCTION, - DHookCallback postHook = INVALID_FUNCTION) { - DynamicDetour hSetup = DynamicDetour.FromConf(this, name); - if (!hSetup) - SetFailState("Missing detour setup \"%s\"", name); - if (preHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Pre, preHook)) - SetFailState("Failed to pre-detour \"%s\"", name); - if (postHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Post, postHook)) - SetFailState("Failed to post-detour \"%s\"", name); - return hSetup; - } + // public DynamicDetour CreateDetourOrFail( + // const char[] name, + // DHookCallback preHook = INVALID_FUNCTION, + // DHookCallback postHook = INVALID_FUNCTION) { + // DynamicDetour hSetup = DynamicDetour.FromConf(this, name); + // if (!hSetup) + // SetFailState("Missing detour setup \"%s\"", name); + // if (preHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Pre, preHook)) + // SetFailState("Failed to pre-detour \"%s\"", name); + // if (postHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Post, postHook)) + // SetFailState("Failed to post-detour \"%s\"", name); + // return hSetup; + // } } int g_iOffs_m_PlayerAnimState; int g_iOffs_m_flEyeYaw; methodmap Address {} -methodmap PlayerAnimState < Address { - public static PlayerAnimState FromPlayer(int client) { - return view_as(GetEntData(client, g_iOffs_m_PlayerAnimState)); +methodmap PlayerAnimStateEx < Address +{ + public static PlayerAnimStateEx FromPlayer(int client) { + return view_as(GetEntData(client, g_iOffs_m_PlayerAnimState)); } property float m_flEyeYaw { @@ -64,18 +66,57 @@ public void OnPluginStart() g_iOffs_m_PlayerAnimState = gd.GetOffset("CTerrorPlayer::m_PlayerAnimState"); g_iOffs_m_flEyeYaw = gd.GetOffset("m_flEyeYaw"); - delete gd.CreateDetourOrFail("CTerrorPlayer::OnStaggered", DTR_OnStaggered); + // https://github.com/Target5150/MoYu_Server_Stupid_Plugins/issues/70 + // delete gd.CreateDetourOrFail("CTerrorPlayer::OnShovedBySurvivor", DTR_OnShovedBySurvivor); + // delete gd.CreateDetourOrFail("CTerrorPlayer::OnStaggered", DTR_OnStaggered); delete gd; } -MRESReturn DTR_OnStaggered(int client, DHookParam hParams) +public Action L4D_OnShovedBySurvivor(int client, int victim, const float vecDir[3]) +{ + if (IsClientInGame(victim)) + { + float ang[3]; + GetClientAbsAngles(victim, ang); + PlayerAnimStateEx.FromPlayer(victim).m_flEyeYaw = ang[1]; + } + + return Plugin_Continue; +} + +public Action L4D2_OnStagger(int client, int source) { - if (IsClientInGame(client) && GetClientTeam(client) == 2) + if (IsClientInGame(client)) { float ang[3]; GetClientAbsAngles(client, ang); - PlayerAnimState.FromPlayer(client).m_flEyeYaw = ang[1]; + PlayerAnimStateEx.FromPlayer(client).m_flEyeYaw = ang[1]; } - return MRES_Ignored; -} \ No newline at end of file + return Plugin_Continue; +} + +// MRESReturn DTR_OnShovedBySurvivor(DHookParam hParams) +// { +// int client = hParams.Get(1); +// if (IsClientInGame(client)) +// { +// float ang[3]; +// GetClientAbsAngles(client, ang); +// PlayerAnimStateEx.FromPlayer(client).m_flEyeYaw = ang[1]; +// } + +// return MRES_Ignored; +// } + +// MRESReturn DTR_OnStaggered(int client, DHookParam hParams) +// { +// if (IsClientInGame(client)) +// { +// float ang[3]; +// GetClientAbsAngles(client, ang); +// PlayerAnimStateEx.FromPlayer(client).m_flEyeYaw = ang[1]; +// } + +// return MRES_Ignored; +// } \ No newline at end of file