void proper_brute(C_BaseEntity* ent) // edited by Solpadoin
{
if (!g::pLocalEntity->IsAlive())
return;
auto animState = ent->AnimState();
if (!animState)
return;
static float m_flFakeGoalFeetYaw[65] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
// 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);
if (m_flFakeGoalFeetYaw[ent->EntIndex] < 0)
m_flFakeGoalFeetYaw[ent->EntIndex] = animState->m_goalfeet_yaw;
float flEyeYaw = ent->GetEyeAngles().y;
float flEyeDiff = std::remainderf(flEyeYaw - m_flFakeGoalFeetYaw[ent->EntIndex()], 360.f);
if (flEyeDiff <= flMaxBodyYaw) {
if (flMinBodyYaw > flEyeDiff)
m_flFakeGoalFeetYaw[ent->EntIndex()] = fabs(flMinBodyYaw) + flEyeYaw;
}
else {
m_flFakeGoalFeetYaw[ent->EntIndex()] = flEyeYaw - fabs(flMaxBodyYaw);
}
m_flFakeGoalFeetYaw[ent->EntIndex()] = std::remainderf(m_flFakeGoalFeetYaw[ent->EntIndex()], 360.f);
if (speed > 0.1f || fabs(velocity.z) > 100.0f) {
m_flFakeGoalFeetYaw[ent->EntIndex()] = ApproachAngle(
flEyeYaw,
m_flFakeGoalFeetYaw[ent->EntIndex()],
((m_flGroundFraction * 20.0f) + 30.0f)
* choked_time);
}
else {
m_flFakeGoalFeetYaw[ent->EntIndex()] = ApproachAngle(
ent->GetLowerBodyYaw(),
m_flFakeGoalFeetYaw[ent->EntIndex()],
choked_time * 100.0f);
}
float Left = std::remainderf(flEyeYaw + flMinBodyYaw, 360.0);
float Right = std::remainderf(flEyeYaw + flMaxBodyYaw, 360.0);
float resolveYaw = animState->m_goalfeet_yaw;
switch (g::MissedShots[ent->EntIndex()] % 3) {
case 0: // brute left side
resolveYaw = (int)resolveYaw == (int)Left ? m_flFakeGoalFeetYaw[ent->EntIndex()] : Left; // by solpadoin
break;
case 1: // brute fake side
resolveYaw = m_flFakeGoalFeetYaw[ent->EntIndex()]; // don't change it cause it's a middle angle could be 'real' angle, not 'desync'
break;
case 2: // brute right side
resolveYaw = (int)resolveYaw == (int)Right ? m_flFakeGoalFeetYaw[ent->EntIndex()] : Right; // by solpadoin
break;
default:
break;
}
animState->m_goalfeet_yaw = std::remainderf(resolveYaw, 360.f);
}