-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStaggerFix.sp
76 lines (66 loc) · 1.88 KB
/
StaggerFix.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*-----------------------------------------------------------------------------------------------
* Dependencies:
* Left4Dhooks Direct (replacement for left4downtown) - https://forums.alliedmods.net/showthread.php?t=321696
* dhooks - https://forums.alliedmods.net/showthread.php?p=2588686#post2588686
* SM 1.10
------------------------------------------------------------------------------------------------*/
#include <sourcemod>
#include <left4dhooks>
#pragma semicolon 1
#pragma newdecls required
#define DEBUG 0
Handle g_hStaggerCheck[MAXPLAYERS + 1] = null;
int g_iPreviousStagger[MAXPLAYERS + 1];
public Plugin myinfo =
{
name = "Stagger Fix",
author = "Gravity",
description = "Prevents staggering/stumbling more than 2.5 seconds.",
version = "1.0",
url = ""
};
public void OnMapStart()
{
for (int i = 1; i <= MaxClients; i++)
g_iPreviousStagger[i] = 0;
}
public Action L4D2_OnStagger(int target, int source)
{
if (target && IsClientInGame(target) && GetClientTeam(target) == 2)
{
if (g_hStaggerCheck[target] == null)
{
g_iPreviousStagger[target] = GetTime();
g_hStaggerCheck[target] = CreateTimer(2.5, Timer_CheckStagger, GetClientUserId(target), TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public Action Timer_CheckStagger(Handle timer, int UserID)
{
int client = GetClientOfUserId(UserID);
if (client && IsClientInGame(client))
{
if (IsStaggering(client))
{
// Verify we didn't get staggered again instantly by some other source
if (g_iPreviousStagger[client] > 0 && GetTime() - g_iPreviousStagger[client] >= 2.5)
{
L4D_CancelStagger(client);
}
}
}
g_iPreviousStagger[client] = 0;
g_hStaggerCheck[client] = null;
}
// from khan
bool IsStaggering(int client)
{
// Are they stumbling?
float vec[3];
GetEntPropVector(client, Prop_Send, "m_staggerStart", vec);
if (vec[0] != 0.000000 || vec[1] != 0.000000 || vec[2] != 0.000000)
{
return true;
}
return false;
}