-
Notifications
You must be signed in to change notification settings - Fork 125
/
current.sp
58 lines (47 loc) · 1.42 KB
/
current.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
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <left4dhooks>
#define TEAM_SURVIVORS 2
ConVar g_hVsBossBuffer;
public Plugin myinfo =
{
name = "L4D2 Survivor Progress",
author = "CanadaRox, Visor",
description = "Print survivor progress in flow percents ",
version = "2.0.3",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
};
public void OnPluginStart()
{
g_hVsBossBuffer = FindConVar("versus_boss_buffer");
RegConsoleCmd("sm_cur", CurrentCmd);
RegConsoleCmd("sm_current", CurrentCmd);
}
Action CurrentCmd(int client, int args)
{
int boss_proximity = RoundToNearest(GetBossProximity() * 100.0);
PrintToChat(client, "\x01Current: \x04%d%%", boss_proximity);
return Plugin_Handled;
}
float GetBossProximity()
{
float proximity = GetMaxSurvivorCompletion() + g_hVsBossBuffer.FloatValue / L4D2Direct_GetMapMaxFlowDistance();
return (proximity > 1.0) ? 1.0 : proximity;
}
float GetMaxSurvivorCompletion()
{
float flow = 0.0, tmp_flow = 0.0, origin[3];
Address pNavArea;
for (int i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i) && GetClientTeam(i) == TEAM_SURVIVORS && IsPlayerAlive(i)) {
GetClientAbsOrigin(i, origin);
pNavArea = L4D2Direct_GetTerrorNavArea(origin);
if (pNavArea != Address_Null) {
tmp_flow = L4D2Direct_GetTerrorNavAreaFlow(pNavArea);
flow = (flow > tmp_flow) ? flow : tmp_flow;
}
}
}
return (flow / L4D2Direct_GetMapMaxFlowDistance());
}