-
Автор темы
- #1
2.15. Запрещено редактировать название темы или своё сообщение на «/del» во всех случаях (продажа аккаунта, получение ответа на свой вопрос и так далее), кроме флуда.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
inline float ClampYaw(float yaw)
{
while (yaw > 180.f)
yaw -= 360.f;
while (yaw < -180.f)
yaw += 360.f;
return yaw;
}
static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b)
{
Vector delta = a - b;
float delta_length = delta.Length();
if (delta_length <= min_delta)
{
Vector result;
if (-min_delta <= delta_length)
{
return a;
}
else
{
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b - ((delta * iradius) * min_delta);
}
}
else
{
float iradius = 1.0f / (delta_length + FLT_EPSILON);
return b + ((delta * iradius) * min_delta);
}
};
float server_abs_yaw(player_t* m_player, float m_flEyeYaw, float m_flGoalFeetYaw)
{
Vector velocity = m_player->m_vecVelocity();
auto anim_state = m_player->get_animation_state();
m_flGoalFeetYaw = anim_state->m_flGoalFeetYaw;
float eye_feet_delta = math::AngleDiff(m_flEyeYaw, m_flGoalFeetYaw);
float spd = velocity.LengthSqr();
if (spd > std::powf(1.2f * 260.0f, 2.f))
{
Vector velocity_normalized = velocity.Normalized();
velocity = velocity_normalized * (1.2f * 260.0f);
}
float m_flChokedTime = anim_state->m_flLastClientSideAnimationUpdateTime;
float v25 = std::clamp(m_player->m_flDuckAmount() + anim_state->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
float v26 = anim_state->m_fDuckAmount;
float v27 = m_flChokedTime * 6.0f;
float v28;
if ((v25 - v26) <= v27)
{
if (-v27 <= (v25 - v26))
v28 = v25;
else
v28 = v26 - v27;
}
else
{
v28 = v26 + v27;
}
float flDuckAmount = std::clamp(v28, 0.0f, 1.0f);
Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, m_player->m_vecVelocity());
float speed = std::fminf(animationVelocity.Length(), 260.0f);
float flMaxMovementSpeed = 260.0f;
auto pWeapon = m_player->m_hActiveWeapon();
if (pWeapon && pWeapon->get_csweapon_info())
flMaxMovementSpeed = std::fmaxf(pWeapon->get_csweapon_info()->flMaxPlayerSpeedAlt, 0.001f);
float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);
flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);
float flYawModifier = (((anim_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * flRunningSpeed) + 1.0f;
if (flDuckAmount > 0.0f)
{
float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
}
const float v60 = -58.f;
const float v61 = 58.f;
float flMinYawModifier = v60 * flYawModifier;
float flMaxYawModifier = v61 * flYawModifier;
if (eye_feet_delta <= flMaxYawModifier)
{
if (flMinYawModifier > eye_feet_delta)
m_flGoalFeetYaw = fabs(flMinYawModifier) + m_flEyeYaw;
}
else
{
m_flGoalFeetYaw = m_flEyeYaw - fabs(flMaxYawModifier);
}
math::normalize_yaw(m_flGoalFeetYaw);
if (speed > 0.1f || fabs(velocity.z) > 100.0f)
{
m_flGoalFeetYaw = math::ApproachAngle(
m_flEyeYaw,
m_flGoalFeetYaw,
((anim_state->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
* m_flChokedTime);
}
else
{
m_flGoalFeetYaw = math::ApproachAngle(
m_player->m_flLowerBodyYawTarget(),
m_flGoalFeetYaw,
m_flChokedTime * 100.0f);
}
return m_flGoalFeetYaw;
}
void resolver::resolve_yaw()
{
auto animstate = player->get_animation_state();
float m_abs_yaw = animstate->m_flGoalFeetYaw;
float lby = player->m_angEyeAngles().y;
auto idx = player->EntIndex();
auto missed_shots = g_ctx.globals.missed_shots[idx];
float EyeDelta = lby - m_abs_yaw;
int Side = (EyeDelta > 0.f) ? -1 : 1;
float flEyeYaw = animstate->m_flEyeYaw;
float flMaxBodyYaw = [id385327540|*reinterpret_cast]<float*>(&animstate->pad10[512]);
float flMinBodyYaw = [id385327540|*reinterpret_cast]<float*>(&animstate->pad10[516]);
float left_side = flEyeYaw + flMinBodyYaw;
float right_side = flEyeYaw + flMaxBodyYaw;
float goal_feet_yaw = animstate->m_flGoalFeetYaw;
float desync_delta =
server_abs_yaw(player, animstate->m_flEyeYaw, side);
float low_desync_delta = server_abs_yaw(player, animstate->m_flGoalFeetYaw, side);
static float LBYADD[64];
static int ticks;
int hit = !g_ctx.local() & player->EntIndex()& /2;
switch (missed_shots % 4 && side /2)
{
case 0: m_abs_yaw = LBYADD[idx] = (lby + (desync_delta * Side));
math::normalize_yaw(goal_feet_yaw);
break;
case 1: m_abs_yaw = LBYADD[idx] = (lby + (low_desync_delta * Side));
math::normalize_yaw(goal_feet_yaw);
break;
case 2: m_abs_yaw = LBYADD[idx] = (lby + (left_side * Side));
math::normalize_yaw(goal_feet_yaw);
break;
case 3: m_abs_yaw = LBYADD[idx] = (lby + (right_side * Side));
math::normalize_yaw(goal_feet_yaw);
break;
}
if (LBYADD[idx] != 0.f && !g_ctx.local())
{
if (ticks <= GetTickCount64())
LBYADD[idx] = 0.f;
}
else
ticks = GetTickCount64() + 50000;
if (hit)
{
m_abs_yaw = (lby + (desync_delta * Side)) + LBYADD[idx];
}
}
Последнее редактирование: