-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy patheq_finale_tanks.sp
109 lines (89 loc) · 2.35 KB
/
eq_finale_tanks.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <l4d2_direct>
#define FINALE_STAGE_TANK 8
enum TankSpawningScheme
{
Skip,
FlowAndSecondOnEvent,
FirstOnEvent
};
new Handle:hFirstTankSpawningScheme;
new Handle:hSecondTankSpawningScheme;
new TankSpawningScheme:spawnScheme;
new tankCount;
public Plugin:myinfo =
{
name = "EQ2 Finale Tank Manager",
author = "Visor",
description = "Either two event tanks or one flow and one (second) event tank",
version = "2.4",
url = "/~https://github.com/Attano/Equilibrium"
};
public OnPluginStart()
{
HookEvent("round_start", EventHook:OnRoundStart, EventHookMode_PostNoCopy);
hFirstTankSpawningScheme = CreateTrie();
hSecondTankSpawningScheme = CreateTrie();
RegServerCmd("tank_map_flow_and_second_event", SetMapFirstTankSpawningScheme);
RegServerCmd("tank_map_only_first_event", SetMapSecondTankSpawningScheme);
}
public Action:SetMapFirstTankSpawningScheme(args)
{
decl String:mapname[64];
GetCmdArg(1, mapname, sizeof(mapname));
SetTrieValue(hFirstTankSpawningScheme, mapname, true);
}
public Action:SetMapSecondTankSpawningScheme(args)
{
decl String:mapname[64];
GetCmdArg(1, mapname, sizeof(mapname));
SetTrieValue(hSecondTankSpawningScheme, mapname, true);
}
public OnRoundStart()
{
CreateTimer(8.0, ProcessTankSpawn);
}
public Action:ProcessTankSpawn(Handle:timer)
{
spawnScheme = Skip;
tankCount = 0;
decl String:mapname[64];
GetCurrentMap(mapname, sizeof(mapname));
new bool:dummy;
if (GetTrieValue(hFirstTankSpawningScheme, mapname, dummy))
{
spawnScheme = FlowAndSecondOnEvent;
}
if (GetTrieValue(hSecondTankSpawningScheme, mapname, dummy))
{
spawnScheme = FirstOnEvent;
}
if (IsTankAllowed() && spawnScheme != Skip)
{
L4D2Direct_SetVSTankToSpawnThisRound(InSecondHalfOfRound(), (spawnScheme == FlowAndSecondOnEvent));
}
}
public Action:L4D2_OnChangeFinaleStage(&finaleType, const String:arg[])
{
// PrintToChatAll("Finale type %i has commenced", finaleType);
if (finaleType == FINALE_STAGE_TANK)
{
tankCount++;
if ((spawnScheme == FlowAndSecondOnEvent && tankCount != 2)
|| (spawnScheme == FirstOnEvent && tankCount != 1))
{
return Plugin_Handled;
}
}
return Plugin_Continue;
}
InSecondHalfOfRound()
{
return GameRules_GetProp("m_bInSecondHalfOfRound");
}
bool:IsTankAllowed()
{
return GetConVarFloat(FindConVar("versus_tank_chance_finale")) > 0.0;
}