Skip to content

Commit 98f366a

Browse files
committed
Add l4d_fix_shove_duration
- Fix the game not respecting the value of z_gun_swing_duration.
1 parent ce6ed17 commit 98f366a

4 files changed

Lines changed: 215 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"Games"
2+
{
3+
"left4dead"
4+
{
5+
"Functions"
6+
{
7+
"CTerrorPlayer::OnShovedByLunge"
8+
{
9+
"signature" "CTerrorPlayer::OnShovedByLunge"
10+
"linux"
11+
{
12+
"callconv" "cdecl"
13+
}
14+
"windows"
15+
{
16+
"callconv" "stdcall"
17+
}
18+
"return" "int"
19+
"this" "ignore"
20+
"arguments"
21+
{
22+
"pVictim"
23+
{
24+
"type" "cbaseentity"
25+
"linux"
26+
{
27+
"register" "eax"
28+
}
29+
"windows"
30+
{
31+
"register" "ecx"
32+
}
33+
}
34+
"pAttacker"
35+
{
36+
"type" "cbaseentity"
37+
"linux"
38+
{
39+
"register" "edx"
40+
}
41+
}
42+
"bLungePush"
43+
{
44+
"type" "bool"
45+
}
46+
}
47+
}
48+
}
49+
50+
"Signatures"
51+
{
52+
"CTerrorPlayer::OnShovedByLunge"
53+
{
54+
"library" "server"
55+
"linux" "@_ZN13CTerrorPlayer15OnShovedByLungeEPS_b.part.825"
56+
"windows" "\x83\xEC\x2A\x56\x8B\xF1\xE8\x2A\x2A\x2A\x2A\x84\xC0\x0F\x85\x2A\x2A\x2A\x2A\x55\x8B"
57+
/* 83 EC ? 56 8B F1 E8 ? ? ? ? 84 C0 0F 85 ? ? ? ? 55 8B */
58+
}
59+
}
60+
}
61+
62+
"left4dead2"
63+
{
64+
"Functions"
65+
{
66+
"CTerrorPlayer::OnShovedByLunge"
67+
{
68+
"signature" "CTerrorPlayer::OnShovedByLunge"
69+
"callconv" "cdecl"
70+
"return" "int"
71+
"this" "ignore"
72+
"arguments"
73+
{
74+
"pVictim"
75+
{
76+
"type" "cbaseentity"
77+
"windows"
78+
{
79+
"register" "ecx"
80+
}
81+
}
82+
"pAttacker"
83+
{
84+
"type" "cbaseentity"
85+
}
86+
"bLungePush"
87+
{
88+
"type" "bool"
89+
}
90+
}
91+
}
92+
}
93+
94+
"Signatures"
95+
{
96+
"CTerrorPlayer::OnShovedByLunge"
97+
{
98+
"library" "server"
99+
"linux" "@_ZN13CTerrorPlayer15OnShovedByLungeEPS_b"
100+
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x38\x56\x57\x8B\xF1"
101+
/* 53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 83 EC 38 56 57 8B F1 */
102+
}
103+
}
104+
}
105+
}
5.42 KB
Binary file not shown.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#pragma semicolon 1
2+
#pragma newdecls required
3+
4+
#include <sourcemod>
5+
#include <dhooks>
6+
#include <left4dhooks>
7+
8+
#define PLUGIN_VERSION "1.0"
9+
10+
public Plugin myinfo =
11+
{
12+
name = "[L4D & 2] Fix Shove Duration",
13+
author = "Forgetest",
14+
description = "Fix SI getting shoved by \"nothing\".",
15+
version = PLUGIN_VERSION,
16+
url = "https://github.com/Target5150/MoYu_Server_Stupid_Plugins"
17+
};
18+
19+
#define GAMEDATA_FILE "l4d_fix_shove_duration"
20+
#define KEY_FUNCTION "CTerrorPlayer::OnShovedByLunge"
21+
22+
ConVar z_gun_swing_duration;
23+
24+
public void OnPluginStart()
25+
{
26+
GameData conf = new GameData(GAMEDATA_FILE);
27+
if ( !conf )
28+
SetFailState("Missing gamedata \""...GAMEDATA_FILE..."\"");
29+
30+
DynamicDetour hDetour = DynamicDetour.FromConf(conf, KEY_FUNCTION);
31+
if ( !hDetour )
32+
SetFailState("Missing detour setup \""...KEY_FUNCTION..."\"");
33+
if ( !hDetour.Enable(Hook_Pre, DTR_OnShovedByLunge) || !hDetour.Enable(Hook_Post, DTR_OnShovedByLunge_Post) )
34+
SetFailState("Failed to detour \""...KEY_FUNCTION..."\"");
35+
36+
delete hDetour;
37+
delete conf;
38+
39+
z_gun_swing_duration = FindConVar("z_gun_swing_duration");
40+
}
41+
42+
/*
43+
bool CTerrorPlayer::IsShoving()
44+
{
45+
if ( !m_shovingTimer.HasStarted() )
46+
return false;
47+
48+
return m_shovingTimer.IsLessThen( 1.0 );
49+
}
50+
*/
51+
52+
MRESReturn DTR_OnShovedByLunge(DHookReturn hReturn, DHookParam hParams)
53+
{
54+
int client = hParams.Get(1);
55+
ITimer_OffsetTimestamp(GetShovingTimer(client), z_gun_swing_duration.FloatValue - 1.0);
56+
57+
return MRES_Ignored;
58+
}
59+
60+
MRESReturn DTR_OnShovedByLunge_Post(DHookReturn hReturn, DHookParam hParams)
61+
{
62+
int client = hParams.Get(1);
63+
ITimer_OffsetTimestamp(GetShovingTimer(client), 1.0 - z_gun_swing_duration.FloatValue);
64+
65+
return MRES_Ignored;
66+
}
67+
68+
public Action L4D2_OnJockeyRide(int victim, int attacker)
69+
{
70+
ITimer_OffsetTimestamp(GetShovingTimer(victim), z_gun_swing_duration.FloatValue - 1.0);
71+
72+
return Plugin_Continue;
73+
}
74+
75+
public void L4D2_OnJockeyRide_Post(int victim, int attacker)
76+
{
77+
ITimer_OffsetTimestamp(GetShovingTimer(victim), 1.0 - z_gun_swing_duration.FloatValue);
78+
}
79+
80+
void ITimer_OffsetTimestamp(IntervalTimer timer, float offset)
81+
{
82+
if ( ITimer_HasStarted(timer) )
83+
{
84+
float timestamp = __ITimer_GetTimestamp(timer);
85+
ITimer_SetTimestamp(timer, timestamp + offset);
86+
}
87+
}
88+
89+
// wait for left4dhooks update to fix this one
90+
/*
91+
any Direct_ITimer_GetTimestamp(Handle plugin, int numParams) // Native "ITimer_GetTimestamp"
92+
{
93+
CountdownTimer timer = GetNativeCell(1); // CountdownTimer
94+
return Stock_CTimer_GetTimestamp(timer); // ctimer
95+
}
96+
*/
97+
float __ITimer_GetTimestamp(IntervalTimer timer)
98+
{
99+
return LoadFromAddress(view_as<Address>(timer) + view_as<Address>(4), NumberType_Int32);
100+
}
101+
102+
IntervalTimer GetShovingTimer(int client)
103+
{
104+
static int s_iOffs_ShovingTimer = -1;
105+
if ( s_iOffs_ShovingTimer == -1 )
106+
s_iOffs_ShovingTimer = FindSendPropInfo("CTerrorPlayer", "m_customAbility") + 164;
107+
108+
return view_as<IntervalTimer>(GetEntityAddress(client) + view_as<Address>(s_iOffs_ShovingTimer));
109+
}

cfg/generalfixes.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ sm plugins load fixes/l4d2_fix_firsthit.smx
4949
sm plugins load fixes/l4d2_rock_trace_unblock.smx
5050
sm plugins load fixes/l4d_static_punch_getup.smx
5151
sm plugins load fixes/annoyance_exploit_fixes.smx
52+
sm plugins load fixes/l4d_fix_shove_duration.smx
5253

5354
// Anti-Cheat.
5455
sm plugins load anticheat/l4d2_noghostcheat.smx

0 commit comments

Comments
 (0)