forked from SirPlease/L4D2-Competitive-Rework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathl4d2_fix_tank_rock_handoff.sp
More file actions
84 lines (67 loc) · 2.23 KB
/
Copy pathl4d2_fix_tank_rock_handoff.sp
File metadata and controls
84 lines (67 loc) · 2.23 KB
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
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <left4dhooks>
#define PLUGIN_VERSION "1.0"
#define GAMEDATA_FILE "l4d2_fix_tank_rock_handoff"
Handle g_hCThrow_OnStunned = null;
public Plugin myinfo =
{
name = "[L4D2] Fix Tank Rock Stuck",
author = "Sir",
description = "Cancels tank rocks that are in the middle of a throw when passing to another player/AI.",
version = PLUGIN_VERSION,
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
};
public void OnPluginStart()
{
GameData gd = new GameData(GAMEDATA_FILE);
if (!gd) SetFailState("Missing gamedata \"" ... GAMEDATA_FILE ... ".txt\"");
StartPrepSDKCall(SDKCall_Entity);
if (!PrepSDKCall_SetFromConf(gd, SDKConf_Signature, "CThrow::OnStunned"))
{
delete gd;
SetFailState("Failed to find signature \"CThrow::OnStunned\"");
}
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
g_hCThrow_OnStunned = EndPrepSDKCall();
delete gd;
if (g_hCThrow_OnStunned == null)
SetFailState("Failed to prep SDKCall for CThrow::OnStunned");
HookEvent("player_bot_replace", Event_PlayerBotReplace, EventHookMode_Post);
HookEvent("bot_player_replace", Event_BotPlayerReplace, EventHookMode_Post);
}
/* Covers Player to Player passes (including forced) */
public void L4D_OnReplaceTank(int oldTank, int newTank)
{
CancelPossibleTankThrow(newTank);
}
/* Covers Player to Bot passes */
void Event_PlayerBotReplace(Event event, const char[] name, bool dontBroadcast)
{
int bot = GetClientOfUserId(event.GetInt("bot"));
CancelPossibleTankThrow(bot);
}
/* Covers Bot to Player passes (as we do in some plugins) */
void Event_BotPlayerReplace(Event event, const char[] name, bool dontBroadcast)
{
int player = GetClientOfUserId(event.GetInt("player"));
CancelPossibleTankThrow(player);
}
void CancelPossibleTankThrow(int client)
{
if (!IsTank(client))
return;
int ability = GetEntPropEnt(client, Prop_Send, "m_customAbility");
if (ability == -1)
return;
SDKCall(g_hCThrow_OnStunned, ability, 0.0);
}
bool IsTank(int client)
{
if (client <= 0 || client > MaxClients || !IsClientInGame(client))
return false;
if (GetClientTeam(client) != L4D_TEAM_INFECTED)
return false;
return GetEntProp(client, Prop_Send, "m_zombieClass") == L4D2_ZOMBIE_CLASS_TANK;
}