-
Notifications
You must be signed in to change notification settings - Fork 2
/
prestrafe.sp
51 lines (42 loc) · 1.47 KB
/
prestrafe.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
#include <sourcemod>
#include <sdktools_functions>
#include <shavit>
#define PRE_VELMOD_MAX 1.104404 // Calculated 276/250
#define PRE_VELMOD_INCREMENT 0.0014 // Per tick when prestrafing
#define PRE_VELMOD_DECREMENT 0.0021 // Per tick when not prestrafing
float preVelMod[MAXPLAYERS+1] = {1.0, ...};
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, int mouse[2])
{
if(stylesettings[bEasybhop])
return Plugin_Continue;
if(stylesettings[bAutobhop])
return Plugin_Continue;
if (GetEntityFlags(client) & FL_ONGROUND == FL_ONGROUND)
CalcPrestrafeVelMod(client, buttons, mouse);
else
preVelMod[client] = 1.0;
return Plugin_Continue;
}
void CalcPrestrafeVelMod(int client, int &buttons, int mouse[2])
{
if ((mouse[0] != 0)
&& ((buttons & IN_FORWARD && !(buttons & IN_BACK)) || (!(buttons & IN_FORWARD) && buttons & IN_BACK))
&& ((buttons & IN_MOVELEFT && !(buttons & IN_MOVERIGHT)) || (!(buttons & IN_MOVELEFT) && buttons & IN_MOVERIGHT)))
{
preVelMod[client] += PRE_VELMOD_INCREMENT;
}
else
{
preVelMod[client] -= PRE_VELMOD_DECREMENT;
}
// Keep prestrafe velocity modifier within range
if (preVelMod[client] < 1.0)
{
preVelMod[client] = 1.0;
}
else if (preVelMod[client] > PRE_VELMOD_MAX)
{
preVelMod[client] = PRE_VELMOD_MAX;
}
SetEntPropFloat(client, Prop_Send, "m_flVelocityModifier", preVelMod[client]);
}