void resolver::resolve_yaw(player_t* player)
{
if (!player || !player->get_animation_state())
return;
auto animState = player->get_animation_state();
if (!animState)
return;
Vector velocity = player->m_vecVelocity();
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 Resolveyaw = animState->m_flGoalFeetYaw;
auto delta_time
= fmaxf(m_globals()->m_curtime - animState->m_flLastClientSideAnimationUpdateTime, 0.f);
float deltatime = fabs(delta_time);
float stop_to_full_running_fraction = 0.f;
bool is_standing = true;
float v25 = std::clamp(player->m_flDuckAmount() + animState->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
float v26 = animState->m_fDuckAmount;
float v27 = deltatime * 6.0f;
float v28;
// clamp
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 = velocity;
float speed = std::fminf(animationVelocity.Length(), 240.0f);
auto weapon = player->m_hActiveWeapon().Get();
if (!weapon)
return;
auto wpndata = weapon->get_csweapon_info();
if (!wpndata)
return;
float flMaxMovementSpeed = 260.0f;
if (weapon) {
flMaxMovementSpeed = std::fmaxf(wpndata->flMaxPlayerSpeed, 0.001f);
}
float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
float flDuckingSpeed_2 = speed / (flMaxMovementSpeed * 0.340f);
flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);
float flYawModifier = (((stop_to_full_running_fraction * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
if (flDuckAmount > 0.0f) {
float flDuckingSpeed = std::clamp(flDuckingSpeed_2, 0.0f, 1.0f);
flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
}
float flMaxBodyYaw = *reinterpret_cast<float*>(&animState->pad10[512]);
float flMinBodyYaw = *reinterpret_cast<float*>(&animState->pad10[516]);
float flEyeYaw = player->m_angEyeAngles().y;
float flEyeDiff = std::remainderf(flEyeYaw - Resolveyaw, 360.f);
if (flEyeDiff <= flMaxBodyYaw) {
if (flMinBodyYaw > flEyeDiff)
Resolveyaw = fabs(flMinBodyYaw) + flEyeYaw;
}
else {
Resolveyaw = flEyeYaw - fabs(flMaxBodyYaw);
}
if (speed > 0.1f || fabs(velocity.z) > 100.0f) {
Resolveyaw = ApproachAngle(
flEyeYaw,
Resolveyaw,
((stop_to_full_running_fraction * 20.0f) + 45.0f)
* deltatime);
}
else {
Resolveyaw = ApproachAngle(
player->m_flLowerBodyYawTarget(),
Resolveyaw,
deltatime * 100.0f);
}
if (stop_to_full_running_fraction > 0.0 && stop_to_full_running_fraction < 1.0)
{
const auto interval = m_globals()->m_intervalpertick * 2.f;
if (is_standing)
stop_to_full_running_fraction = stop_to_full_running_fraction - interval;
else
stop_to_full_running_fraction = interval + stop_to_full_running_fraction;
stop_to_full_running_fraction = std::clamp(stop_to_full_running_fraction, 0.f, 1.f);
}
if (speed > 135.2f && is_standing)
{
stop_to_full_running_fraction = fmaxf(stop_to_full_running_fraction, .0099999998f);
is_standing = false;
}
if (speed < 135.2f && !is_standing)
{
stop_to_full_running_fraction = fminf(stop_to_full_running_fraction, .99000001f);
is_standing = true;
}
float Left = flEyeYaw + flMinBodyYaw;
float Right = flEyeYaw + flMaxBodyYaw;
float brute_yaw = Resolveyaw;
brute_yaw = std::remainderf(brute_yaw, 360.f);
if (c_config::get()->auto_check(c_config::get()->i["rage_aa_over"], c_config::get()->i["rage_aa_over_style"]))
{
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 3)
{
case 0:
player->get_animation_state()->m_flGoalFeetYaw = Right;
break;
case 1:
player->get_animation_state()->m_flGoalFeetYaw = brute_yaw;
break;
case 2:
player->get_animation_state()->m_flGoalFeetYaw = Left;
break;
default:
break;
}
}
else
{
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 3)
{
case 0:
player->get_animation_state()->m_flGoalFeetYaw = Left;
break;
case 1:
player->get_animation_state()->m_flGoalFeetYaw = brute_yaw;
break;
case 2:
player->get_animation_state()->m_flGoalFeetYaw = Right;
break;
default:
break;
}
}
}