Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pphard::NewNewAnimationFix(C_BaseEntity* pEnt, C_BaseEntity* pLocalEnt)
- {
- static float ShotTime[65];
- static float oldSimtime[65];
- static float storedSimtime[65];
- static Vector oldEyeAngles[65];
- static float oldGoalfeetYaw[65];
- static Vector oldOrigin[65];
- float* PosParams = reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(pEnt) + 0x2774);
- bool shot = false;
- auto* AnimState = pEnt->AnimState();
- if (!AnimState || !pEnt->AnimOverlays() || !PosParams)
- return;
- if (*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x164) < 0)
- * reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x110) = 0.f;
- bool update = false;
- if (storedSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
- {
- pEnt->ClientAnimations(true);
- pEnt->UpdateClientAnimation();
- pEnt->ClientAnimations(false);
- update = true;
- }
- oldGoalfeetYaw[pEnt->EntIndex()] = AnimState->m_flGoalFeetYaw;
- if (pEnt->GetActiveWeapon() && !pEnt->IsKnifeorNade())
- {
- if (ShotTime[pEnt->EntIndex()] != pEnt->GetActiveWeapon()->GetLastShotTime())
- {
- shot = true;
- ShotTime[pEnt->EntIndex()] = pEnt->GetActiveWeapon()->GetLastShotTime();
- }
- else
- shot = false;
- }
- else
- {
- shot = false;
- ShotTime[pEnt->EntIndex()] = 0.f;
- }
- if (pLocalEnt && pLocalEnt->IsAlive())
- {
- float angToLocal = g_Math.NormalizeYaw(g_Math.CalcAngle(pLocalEnt->GetOrigin(), pEnt->GetOrigin()).y);
- float Back = g_Math.NormalizeYaw(angToLocal);
- float DesyncFix = 0;
- float Resim = g_Math.NormalizeYaw((TICKS_TO_TIME(16) / (pEnt->GetSimulationTime() - oldSimtime[pEnt->EntIndex()])) * g_Math.NormalizeYaw(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y));
- if (Resim > 60.f)
- Resim = 60.f;
- if (Resim < -60.f)
- Resim = -60.f;
- if (c_config::get().ResolverType == 0 && !shot && !isnan(angToLocal) && !isinf(angToLocal) && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam())
- {
- float AntiSide = 0.f;
- if (Globals::MissedShots[pEnt->EntIndex()] % 2)
- {
- if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Back) > 0.f)
- AntiSide = -90.f;
- else if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Back) < 0.f)
- AntiSide = 90.f;
- }
- else
- {
- if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - g_Math.NormalizeYaw(Back + 90)) > 0.f)
- AntiSide = 180.f;
- else if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - g_Math.NormalizeYaw(Back + 90)) < 0.f)
- AntiSide = 0.f;
- }
- float Brute = g_Math.NormalizeYaw(Back + AntiSide);
- float Delta = g_Math.NormalizeYaw(g_Math.NormalizeYaw(Brute - pEnt->GetEyeAngles().y) + Resim);
- if (Delta > 60.f)
- Delta = 60.f;
- if (Delta < -60.f)
- Delta = -60.f;
- Resim += Delta;
- DesyncFix += Delta;
- if (Resim > 60.f)
- Resim = 60.f;
- if (Resim < -60.f)
- Resim = -60.f;
- }
- float Equalized;
- Equalized = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y + Resim);
- if (c_config::get().ResolverType == 0 && !shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND))
- AnimState->m_flGoalFeetYaw = Equalized;
- }
- if (c_config::get().ResolverType == 0 && !shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam())
- {
- switch (Globals::MissedShots[pEnt->EntIndex()] % 3)
- {
- case 1:PosParams[12] = 89.f; break;
- case 2:PosParams[12] = -89.f; break;
- }
- }
- if (shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && PosParams[12] <= -80)
- PosParams[12] = 89.f;
- if (update)
- {
- oldEyeAngles[pEnt->EntIndex()] = pEnt->GetEyeAngles();
- oldSimtime[pEnt->EntIndex()] = storedSimtime[pEnt->EntIndex()];
- storedSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
- oldOrigin[pEnt->EntIndex()] = pEnt->GetOrigin();
- }
- pEnt->SetAbsAngles(Vector(0, oldGoalfeetYaw[pEnt->EntIndex()], 0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement