-
Автор темы
- #1
переделал
Пожалуйста, авторизуйтесь для просмотра ссылки.
под лв.если что-то неправильно, то исправьте в теме
Код:
void movement_fix(Vector& wish_angle, CUserCmd* m_pcmd)
{
if (m_pcmd->m_viewangles.z != 0.f
&& !(g_ctx.local()->m_fFlags() & FL_ONGROUND)) {
m_pcmd->m_sidemove = 0.f;
}
auto move_2d = Vector(m_pcmd->m_forwardmove, m_pcmd->m_sidemove, m_pcmd->m_upmove);
if (const auto speed_2d = move_2d.Length()) {
const auto delta = m_pcmd->m_viewangles.y - wish_angle.y;
Vector v1;
math::sin_cos(
DEG2RAD(
remainderf(RAD2DEG(math::atan2(move_2d.y / speed_2d, move_2d.x / speed_2d)) + delta, 360.f)
), v1.x, v1.y
);
const auto cos_x = math::cos(
DEG2RAD(remainderf(RAD2DEG(math::atan2(0.f, speed_2d)), 360.f))
);
move_2d.x = cos_x * v1.y * speed_2d;
move_2d.y = cos_x * v1.x * speed_2d;
if (g_ctx.local()->get_move_type() == MOVETYPE_LADDER) {
if (wish_angle.x < 45.f
&& std::fabsf(delta) <= 65.f
&& m_pcmd->m_viewangles.x >= 45.f) {
move_2d.x *= -1.f;
}
}
else if (std::fabsf(m_pcmd->m_viewangles.x) > 90.f) {
move_2d.x *= -1.f;
}
}
static auto cl_forwardspeed = m_cvar()->FindVar(crypt_str("cl_forwardspeed"));
static auto cl_sidespeed = m_cvar()->FindVar(crypt_str("cl_sidespeed"));
static auto cl_upspeed = m_cvar()->FindVar(crypt_str("cl_upspeed"));
const auto max_forward_speed = cl_forwardspeed->GetFloat();
const auto max_side_speed = cl_sidespeed->GetFloat();
const auto max_up_speed = cl_upspeed->GetFloat();
m_pcmd->m_forwardmove = math::clamp(move_2d.x, -max_forward_speed, max_forward_speed);
m_pcmd->m_sidemove = math::clamp(move_2d.y, -max_side_speed, max_side_speed);
m_pcmd->m_upmove = math::clamp(move_2d.z, -max_up_speed, max_up_speed);
}