make prespeed_ez_vel work with just angles too

This commit is contained in:
rtldg 2022-02-21 18:31:15 +00:00
parent 525b62753b
commit 98ee179927

View File

@ -1297,15 +1297,23 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed);
float fSpeedXY = (SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0)));
if (fSpeedXY < prespeed_ez_vel)
{
float theta;
if (fSpeedXY >= 1.0)
{
float direction[3];
GetVectorAngles(fSpeed, direction);
theta = DegToRad(direction[1]);
}
else
{
theta = DegToRad(angles[1]);
}
float yaw = DegToRad(direction[1]);
fSpeed[0] = prespeed_ez_vel * Cosine(yaw);
fSpeed[1] = prespeed_ez_vel * Sine(yaw);
fSpeed[0] = prespeed_ez_vel * Cosine(theta);
fSpeed[1] = prespeed_ez_vel * Sine(theta);
DumbSetVelocity(client, fSpeed);
}
}