-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflashboost.sp
212 lines (162 loc) · 6.16 KB
/
flashboost.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
new Float:g_ClientVel[MAXPLAYERS+1][3];
new bool:g_bClientShouldBoost[MAXPLAYERS+1];
new bool:g_bClientDoBoost[MAXPLAYERS+1];
new bool:g_bClientEnabled[MAXPLAYERS+1];
new Float:g_ArrVictimVel[MAXPLAYERS+1][128][3];
new g_ClientTicker[MAXPLAYERS+1];
new Handle:g_hEnable = INVALID_HANDLE;
new Handle:g_hDudXYSpeed = INVALID_HANDLE;
new Handle:g_hDudZSpeed = INVALID_HANDLE;
new Handle:g_hDudDelayTicks = INVALID_HANDLE;
new bool:g_bEnabled = true;
new Float:g_fDudXSpeed = 0.892;
new Float:g_fDudZSpeed = 1.0;
new g_iDudDelayTicks = 1;
new Handle:g_hRemoveTimer[2048];
public Plugin:myinfo =
{
name = "Flashboost Fix",
author = "mev, zipcore, m_bNightstalker",
description = "Fixes flashboost for trikz & removes flashbangs on hit and before detonate",
version = "1.1",
url = ""
}
public OnPluginStart()
{
RegConsoleCmd("sm_bug", Cmd_ClientEnabled, "Toggle the flashboost bugfix");
g_hEnable = CreateConVar("flashbooster_enabled", "1", "Sets whether flashboost fix is enabled or not", _, true, 0.0, true, 1.0);
g_hDudXYSpeed = CreateConVar("flashbooster_xyspeed", "0.892", "Sets boost gained in X axis on a flashboost (Tested by snow - he recommended 0.892 for X & Y axis)");
g_hDudZSpeed = CreateConVar("flashbooster_zspeed", "1.0", "Sets boost gained in Z axis on a flashboost (Tested by snow - he recommended 1.0 for Z axis)");
g_hDudDelayTicks = CreateConVar("flashbooster_delayticks", "1", "Picks the speed from X ticks ago and then apply boost to that speed (0 is buggy)");
HookConVarChange(g_hEnable, ConVarChanged_Enable);
HookConVarChange(g_hDudXYSpeed, ConVarChanged_XSpeed);
HookConVarChange(g_hDudZSpeed, ConVarChanged_ZSpeed);
HookConVarChange(g_hDudDelayTicks, ConVarChanged_DelayTicks);
AutoExecConfig(true, "flashboost_fix");
}
public ConVarChanged_Enable(Handle:cvar, const String:oldVal[], const String:newVal[])
g_bEnabled = GetConVarBool(g_hEnable);
public ConVarChanged_XSpeed(Handle:cvar, const String:oldVal[], const String:newVal[])
g_fDudXSpeed = GetConVarFloat(g_hDudXYSpeed);
public ConVarChanged_ZSpeed(Handle:cvar, const String:oldVal[], const String:newVal[])
g_fDudZSpeed = GetConVarFloat(g_hDudZSpeed);
public ConVarChanged_DelayTicks(Handle:cvar, const String:oldVal[], const String:newVal[])
g_iDudDelayTicks = GetConVarInt(g_hDudDelayTicks);
public OnClientPutInServer(iClient)
{
g_bClientEnabled[iClient] = true;
SDKHook(iClient, SDKHook_TraceAttack, OnTraceAttack);
}
public OnClientDisconnect(iClient)
{
g_bClientEnabled[iClient] = false;
SDKUnhook(iClient, SDKHook_TraceAttack, OnTraceAttack);
}
public Action:Cmd_ClientEnabled(client, args)
{
if (g_bClientEnabled[client] == true)
{
g_bClientEnabled[client] = false;
PrintToChat(client, "Flashboost fix disabled");
}
else if (g_bClientEnabled[client] == false)
{
g_bClientEnabled[client] = true;
PrintToChat(client, "Flashboost fix enabled");
}
return Plugin_Handled;
}
/* Boost player */
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if(IsValidClient(client))
{
decl Float:vClientVel[3];
if(g_bEnabled)
{
if(g_ClientTicker[client] >= 128)
g_ClientTicker[client] = 0;
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", vClientVel);
g_ArrVictimVel[client][g_ClientTicker[client]] = vClientVel;
}
if(g_bClientShouldBoost[client] && g_bEnabled)
{
g_bClientDoBoost[client] = true;
g_bClientShouldBoost[client] = false;
}
else if(g_bClientDoBoost[client] && g_bEnabled)
{
if(g_bClientEnabled[client])
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, g_ClientVel[client]);
g_bClientDoBoost[client] = false;
}
g_ClientTicker[client]++;
}
}
/* Check for flashboost */
public Action:OnTraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
new String:sWeapon[32];
GetEdictClassname(inflictor, sWeapon, 32);
if(StrContains(sWeapon, "flashbang", false) == -1)
return Plugin_Continue;
if(victim == attacker)
return Plugin_Continue;
if(!IsValidClient(victim) || !IsValidClient(victim) || !g_bEnabled)
return Plugin_Continue;
if (damagetype & DMG_FALL)
return Plugin_Handled;
new iFlashbang = EntRefToEntIndex(inflictor);
if (IsValidEntity(iFlashbang))
CheckFlashboost(iFlashbang, victim);
return Plugin_Continue;
}
/* Remove flashbangs before detonate */
public OnEntityCreated(entity, const String:classname[])
{
if (StrContains(classname, "flashbang_projectile") != -1)
SDKHook(entity, SDKHook_SpawnPost, OnSpawnPost);
}
public OnSpawnPost(entity)
{
g_hRemoveTimer[entity] = CreateTimer(1.45, Timer_KillFlashbang2, entity);
}
public Action:Timer_KillFlashbang2(Handle:Timer, any:entity)
{
g_hRemoveTimer[entity] = INVALID_HANDLE;
}
stock CheckFlashboost(flashbang, client)
{
decl Float:flashOri[3], Float:victimOri[3], Float:victimVel[3];
GetEntPropVector(flashbang, Prop_Data, "m_vecAbsOrigin", flashOri);
GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", victimOri);
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", victimVel);
if(GetEngineVersion() == Engine_CSGO)
victimOri[2] += 32.0;
if(victimOri[2] >= flashOri[2] && victimVel[2] != 0)
{
decl Float:vBoost[3], Float:vVelFlash[3];
decl iTick;
iTick = g_ClientTicker[client] - g_iDudDelayTicks;
if(iTick < 0)
iTick += 128;
GetEntPropVector(flashbang, Prop_Data, "m_vecAbsVelocity", vVelFlash);
vBoost[0] = g_ArrVictimVel[client][iTick][0] - vVelFlash[0] * g_fDudXSpeed;
vBoost[1] = g_ArrVictimVel[client][iTick][1] - vVelFlash[1] * g_fDudXSpeed;
vBoost[2] = FloatAbs(vVelFlash[2] * g_fDudZSpeed);
g_bClientShouldBoost[client] = true;
g_ClientVel[client] = vBoost;
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, g_ClientVel[client]);
}
}
/* Stocks */
stock bool:IsValidClient(iClient)
{
if (iClient < 1 || iClient > MaxClients || !IsClientConnected(iClient))
return false;
return true;
}