void resolver::resolve_yaw()
{
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(), 260.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) + 30.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;
}
// lets be real this is the most p thing we ever seen
float m_flResolveValue;
int m_flResolveSide;
AnimationLayer layers[15];
AnimationLayer moveLayers[3][15];
int m_flSide;
bool m_bAnimatePlayer;
bool m_bAnimsUpdated;
bool m_bResolve;
bool m_flPreviousDelta;
// yee jarvis nanotechnology please.
// ok sir...
// fly mode activated
if (player->is_alive() && !player->is_player())
{
if (!(player->m_fFlags() & FL_ONGROUND))
{
m_flResolveSide = 0;
}
auto standing = layers[3].m_flWeight == 0.0f && layers[3].m_flCycle == 0.0f;
auto animating = layers[12].m_flWeight * 1000.f;
auto moving = !animating && (layers[6].m_flWeight * 1000.f) == (layers[6].m_flWeight * 1000.f);
float m_flSpeed = player->m_vecVelocity().Length2D();
float no_side = FLT_MAX;
auto animstate = player->get_animation_state();
AnimationLayer layers[15];
AnimationLayer moveLayers[3][15];
memcpy(moveLayers, player->get_animlayers(), sizeof(AnimationLayer) * 15);
auto speed = player->m_vecVelocity().Length2D();
int m_side;
if (speed <= 0.1f)
{
auto delta = AngleDiff(player->m_angEyeAngles().y, player->get_animation_state()->m_flGoalFeetYaw);
if (layers[3].m_flWeight == 0.0f && layers[3].m_flCycle == 0.0f)
{
int resolving_way = (AngleDiff(player->get_animation_state()->m_flEyeYaw, player->get_animation_state()->m_flGoalFeetYaw) <= 0.0) - 1;
}
}
if (int(layers[12].m_flWeight * 1000.0f) == int(layers[6].m_flWeight * 1000.0f))
{
float firstDelta = fabs(layers[6].m_flPlaybackRate - moveLayers[0][6].m_flPlaybackRate);
float secondDelta = fabs(layers[6].m_flPlaybackRate - moveLayers[2][6].m_flPlaybackRate);
float thirdDelta = fabs(layers[6].m_flPlaybackRate - moveLayers[1][6].m_flPlaybackRate);
if (firstDelta < secondDelta || thirdDelta <= secondDelta || (secondDelta * 1000.0))
{
if (firstDelta >= thirdDelta && secondDelta > thirdDelta && !(thirdDelta * 1000.0))
{
m_side = 1;
}
}
else
{
m_side = -1;
}
}
if (m_side = -1)
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 60.f);
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 60.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 30.f);
break;
case 2:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 60.f);
break;
case 3:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 30.f);
break;
}
}
else if (m_side = 1)
{
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 60.f);
switch (g_ctx.globals.missed_shots[player->EntIndex()] % 2)
{
case 0:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 60.f);
break;
case 1:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 30.f);
break;
case 2:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y + 60.f);
break;
case 3:
animstate->m_flGoalFeetYaw = math::normalize_yaw(player->m_angEyeAngles().y - 30.f);
break;
}
}
if (standing)
{
auto m_flEyeDelta = std::remainderf((player->m_angEyeAngles().y - player->m_flLowerBodyYawTarget()), 360.f) <= 0.f;
if (2 * m_flEyeDelta)
{
if (2 * m_flEyeDelta == 2)
{
m_flSide = -1;
}
}
else
{
m_flSide = 1;
}
m_bResolve = true;
m_flPreviousDelta = m_flEyeDelta;
}
m_flResolveValue = 58.f;
player->get_animation_state()->m_flGoalFeetYaw = (player->m_angEyeAngles().y + m_flResolveValue * m_flSide);
}
float Left = flEyeYaw + flMinBodyYaw;
float Right = flEyeYaw + flMaxBodyYaw;
float brute_yaw = Resolveyaw;
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;
}
}