-
Автор темы
- #1
Автостоп работает чуток неправильно но самую главную работу я за вас сделал дальше сами
Код:
bool aim::automatic_stop(CUserCmd* cmd)
{
static auto accel = m_cvar()->FindVar(crypt_str("sv_accelerate"));
static bool was_onground = g_ctx.local()->m_fFlags() & FL_ONGROUND;
auto weapon_info = g_ctx.globals.weapon->get_csweapon_info();
if (!g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].autostop_modifiers[AUTOSTOP_BETWEEN_SHOTS] && !g_ctx.globals.weapon->can_fire(false))
{
g_ctx.globals.did_stop_before = false;
g_ctx.globals.do_autostop = false;
return true;
}
engineprediction::get().m_autostop_velocity_to_validate = 0.f;
if (g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].autostop && FL_ONGROUND && was_onground)
{
auto v10 = cmd->m_buttons & ~(IN_MOVERIGHT | IN_MOVELEFT | IN_BACK | IN_FORWARD | IN_JUMP | IN_SPEED);
cmd->m_buttons = v10;
const auto chocked_ticks = (cmd->m_command_number % 3) == 0 ? (14 - m_clientstate()->iChokedCommands) : ((14 - m_clientstate()->iChokedCommands) / 2);
const auto max_speed = 0.33f * (g_ctx.globals.scoped ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed);
auto velocity = g_ctx.local()->m_vecVelocity();
velocity.z = 0;
auto current_speed = ((velocity.x * velocity.x) + (velocity.y * velocity.y));
current_speed = sqrtf(current_speed);
const auto cmd_speed = sqrtf((cmd->m_sidemove * cmd->m_sidemove) + (cmd->m_forwardmove * cmd->m_forwardmove));
auto new_sidemove = cmd->m_sidemove;
auto new_forwardmove = cmd->m_forwardmove;
if (current_speed >= 28.f)
{
if (current_speed <= max_speed && g_cfg.ragebot.weapon[g_ctx.globals.current_weapon].autostop_modifiers[AUTOSTOP_FORCE_ACCURACY])
{
if (current_speed > 0.0f)
{
if (current_speed <= 0.1f)
{
new_sidemove = cmd->m_forwardmove * fminf(current_speed, max_speed);
new_forwardmove = cmd->m_forwardmove * fminf(current_speed, max_speed);
}
else
{
new_forwardmove = (cmd->m_forwardmove / cmd_speed) * fminf(current_speed, max_speed);
new_sidemove = (cmd->m_sidemove / cmd_speed) * fminf(current_speed, max_speed);
}
}
}
else
{
//----------------------(*_*)----------------------//
QAngle angle;
math::VectorAnglesAutoStop(velocity, angle);
angle.y = g_ctx.globals.cmd_original_angles.y - angle.y;
Vector direction;
math::AngleVectorsAutoStop(angle, &direction);
//----------------------(*_*)----------------------//
if (current_speed > 5.f)
{
auto stop = direction * -current_speed;
new_forwardmove = stop.x;
new_sidemove = stop.y;
}
else
{
new_forwardmove = 0;
new_sidemove = 0;
}
//----------------------(*_*)----------------------//
}
}
if (g_ctx.local()->m_bDucking() || g_ctx.local()->m_fFlags() & FL_DUCKING)
{
new_forwardmove = new_forwardmove / (((g_ctx.local()->m_flDuckAmount() * 0.34f) + 1.0f) - g_ctx.local()->m_flDuckAmount());
new_sidemove = new_sidemove / (((g_ctx.local()->m_flDuckAmount() * 0.34f) + 1.0f) - g_ctx.local()->m_flDuckAmount());
}
cmd->m_sidemove = math::clamp(new_sidemove, -450.f, 450.f);
cmd->m_forwardmove = math::clamp(new_forwardmove, -450.f, 450.f);
g_ctx.globals.did_stop_before = true;
g_ctx.globals.last_autostop_tick = cmd->m_command_number;
g_ctx.globals.do_autostop = false;
}
was_onground = (g_ctx.local()->m_fFlags() & FL_ONGROUND);
}