-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathability_free_healer_medic_drcrossbowcop_ability.sp
195 lines (144 loc) · 4.56 KB
/
ability_free_healer_medic_drcrossbowcop_ability.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#pragma semicolon 1
#include <tf2_stocks>
#include <berobot_constants>
#include <berobot>
#include <sourcemod>
#include <tf2>
#define PLUGIN_VERSION "1.0"
#define ROBOT_NAME "Dr. Crossbow Cop"
bool g_isSetup = true;
public Plugin:myinfo =
{
name = "[TF2] Dr. Crossbow Cop Ability",
author = "HiGPS | Bmod.TF",
description = "Crossbowcop Ability",
version = PLUGIN_VERSION,
url = "www.sourcemod.com"
}
public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("post_inventory_application", Event_PlayerSpawn);
HookEvent("crossbow_heal", Event_Crossbow_Heal, EventHookMode_Post);
HookEvent("teamplay_setup_finished", Event_teamplay_setup_finished, EventHookMode_Post);
g_isSetup = true;
}
bool g_button_held[MAXPLAYERS + 1] = {false, ...};
float g_Recharge[MAXPLAYERS + 1] = {0.0, ...};
int g_Heal_Bolts_Hits_Needed = 30;
int g_healcount = 0;
float g_duration = 10.0;
public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsRobot(client, ROBOT_NAME))
{
g_healcount = !g_isSetup ? 0 : g_Heal_Bolts_Hits_Needed;
}
return Plugin_Continue;
}
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
{
if (IsRobot(client, ROBOT_NAME))
{
if( GetEntProp(client, Prop_Data, "m_afButtonPressed" ) & (IN_ATTACK3|IN_USE|IN_ATTACK2) )
{
g_button_held[client] = true;
}
if( GetEntProp(client, Prop_Data, "m_afButtonReleased" ) & (IN_ATTACK3|IN_USE|IN_ATTACK2) )
{
g_button_held[client] = false;
}
DrawHUD(client);
}
return Plugin_Continue;
}
bool isready;
#define CHAR_FULL "■"
#define CHAR_EMPTY "□"
void DrawHUD(int client)
{
char sHUDText[128];
char sProgress[32];
// int iPercents = RoundToCeil((GetEngineTime() / g_Recharge[client]) * 100.0);
int iCountDown = g_Heal_Bolts_Hits_Needed - g_healcount;
int iCountDownActive = RoundToCeil(g_Recharge[client] - (GetEngineTime()));
int iPercents = RoundToCeil(iCountDownActive / g_duration * 100.0);
for (int j = 1; j <= 10; j++)
{
if (iPercents >= j * 10)StrCat(sProgress, sizeof(sProgress), CHAR_FULL);
else StrCat(sProgress, sizeof(sProgress), CHAR_EMPTY);
}
if (TF2_IsPlayerInCondition(client, TFCond_CritHype))
{
Format(sHUDText, sizeof(sHUDText), "Strength Bolts Active!\n %s", sProgress);
SetHudTextParams(1.0, 0.8, 0.5, 255, 69, 0, 255);
}
else if(iCountDown <= 0)
{
Format(sHUDText, sizeof(sHUDText), "Strength Bolts Ready!");
SetHudTextParams(1.0, 0.8, 0.5, 0, 255, 0, 255);
}else
{
Format(sHUDText, sizeof(sHUDText), "Strength Bolts: %i", iCountDown);
SetHudTextParams(1.0, 0.8, 0.5, 255, 255, 255, 255);
}
ShowHudText(client, -2, sHUDText);
if (!isready && iCountDown <= 0)
{
TF2_AddCondition(client, TFCond_InHealRadius, 0.5);
// PrintToChatAll("Ready!");
isready = true;
}
if (g_button_held[client] && iCountDown <= 0 || IsFakeClient(client))
{
isready = false;
TF2_AddCondition(client, TFCond_CritHype, g_duration);
TF2_AddCondition(client, TFCond_RuneStrength, g_duration);
g_healcount = 0;
g_Recharge[client] = GetEngineTime() + g_duration;
}
}
public bool IsKritzed(int client){
if (TF2_IsPlayerInCondition(client, (TFCond_Kritzkrieged)) || TF2_IsPlayerInCondition(client, (TFCond_Buffed)) || TF2_IsPlayerInCondition(client, (TFCond_CritCanteen)))
{
return true;
}else
{
return false;
}
}
public Action Event_teamplay_setup_finished(Event event, const char[] name, bool dontBroadcast)
{
g_isSetup = false;
return Plugin_Continue;
}
public Action Event_Crossbow_Heal(Event event, const char[] name, bool dontBroadcast)
{
int healer = GetClientOfUserId(GetEventInt(event, "healer"));
int target = GetClientOfUserId(GetEventInt(event, "target"));
if (IsRobot(healer, ROBOT_NAME))
{
if(!TF2_IsPlayerInCondition(healer, TFCond_CritHype))g_healcount++;
//PrintToChatAll("%N Healed %N, healcount was %i ", healer, target, g_healcount);
if (TF2_IsPlayerInCondition(healer, TFCond_CritHype))
{
float reduced_duration = (g_duration / 2.0) + 1.0;
if (IsRobot(target, "Pancop"))
{
TF2_AddCondition(target, TFCond_RuneHaste, reduced_duration);
}else if (IsRobot(target, "Riotcop"))
{
TF2_AddCondition(target, TFCond_RuneHaste, reduced_duration);
}else
{
TF2_AddCondition(target, TFCond_RuneStrength, reduced_duration);
}
if (IsKritzed(healer))
{
TF2_AddCondition(target, TFCond_CritCanteen, reduced_duration);
}
}
}
return Plugin_Continue;
}