From 09530199e8ef14a420eb3cfcbf9c53007c29fcb4 Mon Sep 17 00:00:00 2001 From: Forgetest <33988868+jensewe@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:05:46 +0800 Subject: [PATCH] Reproduce stagger direction fix on SI (#852) Thanks to Alan on discord for suggesting and testing. --- .../gamedata/l4d_fix_stagger_dir.txt | 116 ++++++++++++++++++ .../plugins/fixes/l4d_fix_stagger_dir.smx | Bin 4278 -> 5314 bytes .../scripting/l4d_fix_stagger_dir.sp | 89 ++++++++++---- 3 files changed, 181 insertions(+), 24 deletions(-) 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 662881ea45abe1c9da7ba2ac572f8115856c09c2..61273305c7cfe96d63d607b90dc0a1075e6c47ba 100644 GIT binary patch delta 5189 zcmXYwby(A1yvN57MhQ}mo|L2@Al=;{-7z`@MuP%hCNYs3jgC$UgH8p8NJ$7vIbt+| zASEHn-S6J}$NRiq=bX=T;(5+#<-`gAT3Qdyz(hn?1`x#1Pz>Kn_Bd2+mI+A0edoK%lQTKp+uYE21M+Dfx~9lrvihw6YsJUK&jNXIRGn17~(Z9R~e zkd_d#6j53c6hzhOB$yu}X(|kI1fXwLiFHjFGwpe0IK^~zp3-NoFeD|Zuj(7PWUj>X z@T{M0o?gv6_yy}$3f5lkg!VWY8(&8*z6G9idAhZfHNSbtc)3fu5L=4{Y*vJNgH#}o zk!LrmtJ-Vh^{L~QhR+f~V> z1@Tq9_IL2(dhMfh`MVmV6U8bb`s~+W3l@8&=$Ukda`-BuppH>(ruoN`mty+yCjbJY4EMfVO=%4 zyF7XNAxAoTmV&cK)vqOOP%Sz0%4C7x@PI2)w5|y?uK6g?jdAy}StL7MXvvln~iDTJHuYpFa0AAibru zL(OzxX)tl?vF3c`Zog4S{rqMA4kXbpBD-quGwV$scdy@QPts55HS53#&iiG*5W2u| z*)O-@LojdTCVFkhB%<3i?evMTwth8+N?}^$?%`sXGbyERRGvd~iuolRC2q6|Nd?zs zp0}^%Nb1*&_S39Es0?Z9=o4z>xY#VU<2&TosOz|}a0`w6I<6`0Z?_KHS-8f(-8!J% zs6^Ob@rXPxemuSvHQ5!Rm@@~H@Brc}V&*IIeuTnLeM0TWYzw#Fv#?urSq^@C`z?v% z^;kNlT#N5zg%;oAw$><+P@`~)9@@Z?>+_i|2BG<*zisi-z zv5HlJ??y+ud-5}tj}&Gq_Y?%oTy`5o+z-4R7B+p44fd2+F-EOk@f!vCoPPnCX)hUOoVefKi%4 ziE#Kd+?s)t>UdXH*j9updA1sR;`32#ci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2Thdn#cIp!p_xRf=sQT@x z@gdXvwUePAo`LM8bSCt-x$XBJ#Uf(Z9AM|YS)-&7y%me$6l7|(#U~};`)Ny*qI@CVqDT@i0V`&T9L1l~@+l;?kzRUoML%$6eMD-mk+F(QVUa+d<7v=VHU3{<2c|DOZkmjG6xh^AGehLn8R?%V zyT`_n$Q$R4%v)lPttfzLUFM~-6l}|{H*J@v_FHd6*WQvU6y3`7P=9Ze=bp>pV``9O z?Ou1&P>uPry5QjBY1KdNAqVGWz34q1Gs+0`^(I5+(7xH+V|pliK|q4&)V z$KF?kD0lXgUf4+VubE_NGHi8Qo9n_Ua(4MnLe~@M%Ar{yvo0ehi|El^GzMAVxcI_7 zFaYc2UBH<|hz#&@6uefHW2cKBuJC{-OQJ6hbz6r$O5maI*kj9se(Sc>E-7%ObJW$v zKNk-Opt00==KH!Sul)#0e9WPAF8^FjjlJJ8-^fW(h-z0xvpFllVmbX{_D=X&XR&Wu bGzfZN9qE3 -#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