-
Notifications
You must be signed in to change notification settings - Fork 2
/
l4d2_boss_rush.sp
172 lines (146 loc) · 3.82 KB
/
l4d2_boss_rush.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
Source is Copyright (C) Valve Corporation.
All trademarks are property of their respective owners.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <left4downtown>
new iDistance;
new witchIndex;
new bool:bTankPointsFrozen;
new bool:bWitchPointsFrozen;
public Plugin:myinfo =
{
name = "L4D2 No Boss Rush",
author = "Visor; originally by Jahze, vintik",
version = "2.1",
description = "Stops distance points accumulating whilst the Tank or Witch are alive",
url = "https://github.com/Attano/Equilibrium"
};
public OnPluginStart()
{
HookEvent("round_start", EventHook:OnRoundStart, EventHookMode_PostNoCopy);
HookEvent("tank_spawn", EventHook:OnTankSpawn, EventHookMode_PostNoCopy);
HookEvent("player_death", OnPlayerDeath);
HookEvent("witch_spawn", OnWitchSpawn);
HookEvent("witch_killed", EventHook:OnWitchKilled, EventHookMode_PostNoCopy);
}
public OnRoundStart()
{
if (InSecondHalfOfRound())
{
UnFreezePoints();
}
}
/* Tank */
public OnTankSpawn()
{
if (!bTankPointsFrozen && !bWitchPointsFrozen)
{
PrintToChatAll("\x01[\x04NoBossRush\x01] Tank spawned. Freezing distance points!");
bTankPointsFrozen = true;
FreezePoints();
}
}
public Action:OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsTank(client))
{
CreateTimer(0.1, CheckForTanksDelay, TIMER_FLAG_NO_MAPCHANGE);
}
}
public OnClientDisconnect(client)
{
if (IsTank(client))
{
CreateTimer(0.1, CheckForTanksDelay, TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action:CheckForTanksDelay(Handle:timer)
{
if (FindTank() == -1)
{
if (bTankPointsFrozen)
{
PrintToChatAll("\x01[\x04NoBossRush\x01] Tank is dead. Unfreezing distance points!");
bTankPointsFrozen = false;
UnFreezePoints();
}
}
}
/* Witch */
public Action:OnWitchSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!bTankPointsFrozen && !bWitchPointsFrozen)
{
witchIndex = GetEventInt(event, "witchid");
PrintToChatAll("\x01[\x04NoBossRush\x01] Witch spawned. Freezing distance points!");
bWitchPointsFrozen = true;
FreezePoints();
}
}
public OnWitchKilled()
{
if (bWitchPointsFrozen)
{
PrintToChatAll("\x01[\x04NoBossRush\x01] Witch is dead. Unfreezing distance points!");
bWitchPointsFrozen = false;
UnFreezePoints();
witchIndex = -1;
}
}
public OnEntityDestroyed(entity)
{
if (entity == witchIndex)
{
OnWitchKilled();
}
}
/* Shared */
FreezePoints()
{
iDistance = L4D_GetVersusMaxCompletionScore();
L4D_SetVersusMaxCompletionScore(0);
}
UnFreezePoints()
{
L4D_SetVersusMaxCompletionScore(iDistance);
}
FindTank()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsTank(i) && IsPlayerAlive(i))
{
return i;
}
}
return -1;
}
bool:IsTank(client)
{
if (client <= 0 || !IsClientInGame(client) || GetClientTeam(client) != 3)
return false;
if (GetEntProp(client, Prop_Send, "m_zombieClass") != 8)
return false;
return true;
}
InSecondHalfOfRound()
{
return GameRules_GetProp("m_bInSecondHalfOfRound");
}