void proper_brute(C_BaseEntity* ent) // edited by Solpadoin
{
if (!g::pLocalEntity->IsAlive())
return;
auto animState = ent->AnimState();
if (!animState)
return;
// Rebuild setup velocity to receive flMinBodyYaw and flMaxBodyYaw
Vector velocity = ent->GetVelocity();
float spd = velocity.LengthSqr();
if (spd > std::powf(1.2f * 260.0f, 2.f)) {
Vector velocity_normalized = velocity.Normalize();
velocity = velocity_normalized * (1.2f * 260.0f);
}
float choked_time = fabs(ent->GetSimulationTime() - ent->GetOldSimulationTime());
float v25 = clamp(ent->m_fDuckSpeed() + animState->m_landing_duck_additive, 0.0f, 1.0f);
float v26 = animState->m_duck_amount;
float v27 = choked_time * 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 = clamp(v28, 0.0f, 1.0f);
Vector animationVelocity = GetSmoothedVelocity(choked_time * 2000.0f, velocity, ent->GetVelocity());
float speed = std::fminf(animationVelocity.Length(), 260.0f);
auto weapon = ent->GetActiveWeapon();
float flMaxMovementSpeed = 260.0f;
if (weapon) {
flMaxMovementSpeed = std::fmaxf(weapon->GetCSWpnData()->max_speed, 0.001f);
}
float m_flGroundFraction = *(float*)(animState + 0x11C);
float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);
flRunningSpeed = clamp(flRunningSpeed, 0.0f, 1.0f);
float flYawModifier = (((m_flGroundFraction * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
if (flDuckAmount > 0.0f) {
float flDuckingSpeed = clamp(flDuckingSpeed, 0.0f, 1.0f);
flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
}
float flMinBodyYaw = std::fabsf(((float)(uintptr_t(animState) + 0x330)) * flYawModifier);
float flMaxBodyYaw = std::fabsf(((float)(uintptr_t(animState) + 0x334)) * flYawModifier);
float flEyeYaw = ent->GetEyeAngles().y;
float flEyeDiff = std::remainderf(flEyeYaw - animState->m_flGoalFeetYaw, 360.f);
if (flEyeDiff <= flMaxBodyYaw) {
if (flMinBodyYaw > flEyeDiff)
animState->m_flGoalFeetYaw = fabs(flMinBodyYaw) + flEyeYaw;
}
else {
animState->m_flGoalFeetYaw = flEyeYaw - fabs(flMaxBodyYaw);
}
animState->m_flGoalFeetYaw = std::remainderf(animState->m_flGoalFeetYaw, 360.f);
if (speed > 0.1f || fabs(velocity.z) > 100.0f) {
animState->m_flGoalFeetYaw = ApproachAngle(
flEyeYaw,
animState->m_flGoalFeetYaw,
((m_flGroundFraction * 20.0f) + 30.0f)
* choked_time);
}
else {
animState->m_flGoalFeetYaw = ApproachAngle(
ent->GetLowerBodyYaw(),
animState->m_flGoalFeetYaw,
choked_time * 100.0f);
}
float Left = flEyeYaw + flMinBodyYaw;
float Right = flEyeYaw + flMaxBodyYaw;
float resolveYaw = animState->m_goalfeet_yaw;
switch (g::MissedShots[ent->EntIndex()] % 3)
{
case 1:
resolveYaw = Left;
break;
case 1:
resolveYaw = Right;
break;
default:
break;
}
animState->m_goalfeet_yaw = std::remainderf(resolveYaw, 360.f);
}