ljstats.inc

  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
#if defined _ljstats_included
#endinput
#endif
#define _ljstats_included
#pragma semicolon 1
#define FL_ONGROUND2 (FL_ONGROUND|FL_PARTIALGROUND)
stock CalculateLandOrigin(bool:ducking, Float:gravity,
Float:current_origin[3], Float:frame_origin[2][3],
Float:frame_velocity[2][3], Float:land_origin[3])
{
static Float:airtime;
static Float:distancex, Float:distancey;
airtime = FloatDiv(((SquareRoot(Pow(frame_velocity[0][2], 2.0) +
(2 * gravity * (frame_origin[0][2] - current_origin[2]))) * -1) -
frame_velocity[1][2]), (gravity * -1));
frame_velocity[1][0] = FloatAbs(frame_velocity[1][0]);
frame_velocity[1][1] = FloatAbs(frame_velocity[1][1]);
distancex = airtime * frame_velocity[1][0];
distancey = airtime * frame_velocity[1][1];
if (frame_origin[1][0] < current_origin[0]) land_origin[0] =
frame_origin[1][0] + distancex;
else land_origin[0] =
frame_origin[1][0] - distancex;
if (frame_origin[1][1] < current_origin[1]) land_origin[1] =
frame_origin[1][1] + distancey;
else land_origin[1] =
frame_origin[1][1] - distancey;
if (ducking) current_origin[2] += 17.0;
land_origin[2] = current_origin[2];
}
stock Float:AngleBetweenVectors(Float:vector1[3], Float:vector2[3])
{
new Float:v1[3], Float:v2[3];
for (new i=0; i < 3; i++)
{
v1[i] = vector1[i];
}
for (new i=0; i < 3; i++)
{
v2[i] = vector2[i];
}
v1[2] = v2[2] = 0.0;
new Float:lengths = GetVectorLength(v1) * GetVectorLength(v2);
if( lengths == 0.0 )
{
lengths = 1.0;
}
return RadToDeg(ArcCosine(GetVectorDotProduct(v1, v2) /
lengths));
}
stock bool:IsDucking(client)
{
new Float:abs_min[3], Float:abs_max[3];
GetClientMaxs(client, abs_max);
GetClientMins(client, abs_min);
return ((abs_min[2] + 64.0) < abs_max[2]);
}
stock GetDirection(client)
{
new Float:angles[3], Float:fwdA[3];
GetClientAbsAngles(client, angles);
GetAngleVectors(angles, fwdA, NULL_VECTOR, NULL_VECTOR);
fwdA[2] = 0.0;
NormalizeVector(fwdA, fwdA);
ScaleVector(fwdA, 250.0);
new Float:velocity[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity);
new Float:angle = AngleBetweenVectors(fwdA, velocity);
if( 45.5 <= angle < 120.0 )
{
return 1;
}
else if( 134.5 <= angle <= 180.0 )
{
return 2;
}
return 0;
}
stock bool:IsUserOnGround(client)
{
return !!(GetEntityFlags(client) & FL_ONGROUND2);
}