void Fakewalk(CUserCmd *usercmd)
{
if (!g_InputSystem->IsButtonDown(Settings.fw_bind))
return;
Global::flFakewalked = PredictionSystem::Get().GetOldCurTime();
Global::bSendPacket = true;
Vector velocity = Global::vecUnpredictedVel;
int32_t ticks_to_update = TIME_TO_TICKS(m_flNextBodyUpdate - TICKS_TO_TIME(AimRage::Get().GetTickbase())) - 1;
int32_t ticks_to_stop;
for (ticks_to_stop = 0; ticks_to_stop < 15; ticks_to_stop++)
{
if (velocity.Length2D() < 0.1f)
break;
if (g_LocalPlayer->m_fFlags() & FL_ONGROUND)
{
velocity[2] = 0.0f;
Friction(velocity);
WalkMove(g_LocalPlayer, velocity);
}
}
const int32_t max_ticks = std::min<int32_t>(7, ticks_to_update);
const int32_t chocked = Miscellaneous::Get().GetChocked();
int32_t ticks_left = max_ticks - chocked;
if (chocked < max_ticks || ticks_to_stop)
Global::bSendPacket = false;
else
Global::bSendPacket = true;
if (ticks_to_stop > ticks_left || !chocked || Global::bSendPacket)
{
float_t speed = velocity.Length();
if (speed > 13.f)
{
QAngle direction;
Math::VectorAngles(velocity, direction);
direction.yaw = usercmd->viewangles.yaw - direction.yaw;
Vector forward;
Math::AngleVectors(direction, forward);
Vector negated_direction = forward * -speed;
usercmd->forwardmove = negated_direction.x;
usercmd->sidemove = negated_direction.y;
}
else
{
usercmd->forwardmove = 0.f;
usercmd->sidemove = 0.f;
}
}
}