Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float MaxDelta(C_BaseEntity* pEnt) {
- auto animstate = uintptr_t(pEnt->AnimState());
- float duckammount = *(float*)(animstate + 0xA4);
- float speedfraction = max(0, min(*reinterpret_cast<float*>(animstate + 0xF8), 1));
- float speedfactor = max(0, min(1, *reinterpret_cast<float*> (animstate + 0xFC)));
- float unk1 = ((*reinterpret_cast<float*> (animstate + 0x11C) * -0.30000001f) - 0.19999999f)* speedfraction;
- float unk2 = unk1 + 1.f;
- float unk3;
- if (duckammount > 0) {
- unk2 += ((duckammount * speedfactor) * (0.5f - unk2));
- }
- unk3 = *(float*)(animstate + 0x334) * unk2;
- return unk3;
- }
- void Resolver::AnimationFix(C_BaseEntity* pEnt)
- {
- //who needs structs or classes not me lol
- static float oldSimtime[65];
- static float storedSimtime[65];
- static float ShotTime[65];
- static float SideTime[65][3];
- static int LastDesyncSide[65];
- static bool Delaying[65];
- static AnimationLayer StoredLayers[64][15];
- static C_AnimState * StoredAnimState[65];
- static float StoredPosParams[65][24];
- static Vector oldEyeAngles[65];
- static float oldGoalfeetYaw[65];
- float* PosParams = (float*)((uintptr_t)pEnt + 0x2774);
- bool update = false;
- bool shot = false;
- static bool jittering[65];
- auto* AnimState = pEnt->AnimState();
- if (!AnimState || !pEnt->AnimOverlays() || !PosParams)
- return;
- auto RemapVal = [](float val, float A, float B, float C, float D) -> float
- {
- if (A == B)
- return val >= B ? D : C;
- return C + (D - C) * (val - A) / (B - A);
- };
- if (storedSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
- {
- jittering[pEnt->EntIndex()] = false;
- pEnt->ClientAnimations(true);
- pEnt->UpdateClientAnimation();
- memcpy(StoredPosParams[pEnt->EntIndex()], PosParams, sizeof(float) * 24);
- memcpy(StoredLayers[pEnt->EntIndex()], pEnt->AnimOverlays(), (sizeof(AnimationLayer) * pEnt->NumOverlays()));
- 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;
- }
- float angToLocal = g_Math.NormalizeYaw(g_Math.CalcAngle(Globals::pLocalEntity->GetOrigin(), pEnt->GetOrigin()).y);
- float Back = g_Math.NormalizeYaw(angToLocal);
- float DesyncFix = 0;
- float Resim = g_Math.NormalizeYaw((0.24f / (pEnt->GetSimulationTime() - oldSimtime[pEnt->EntIndex()]))*(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y));
- if (Resim > MaxDelta(pEnt))
- Resim = MaxDelta(pEnt);
- if (Resim < -MaxDelta(pEnt))
- Resim = -MaxDelta(pEnt);
- if (pEnt->GetVelocity().Length2D() > 0.5f && !shot)
- {
- float Delta = g_Math.NormalizeYaw(g_Math.NormalizeYaw(g_Math.CalcAngle(Vector(0, 0, 0), pEnt->GetVelocity()).y) - g_Math.NormalizeYaw(g_Math.NormalizeYaw(AnimState->m_flGoalFeetYaw + RemapVal(PosParams[11], 0, 1, -60, 60)) + Resim));
- int CurrentSide = 0;
- if (Delta < 0)
- {
- CurrentSide = 1;
- SideTime[pEnt->EntIndex()][1] = g_pGlobalVars->curtime;
- }
- else if (Delta > 0)
- {
- CurrentSide = 2;
- SideTime[pEnt->EntIndex()][2] = g_pGlobalVars->curtime;
- }
- if (LastDesyncSide[pEnt->EntIndex()] == 1)
- {
- Resim += (MaxDelta(pEnt) - Resim);
- DesyncFix += (MaxDelta(pEnt) - Resim);
- }
- if (LastDesyncSide[pEnt->EntIndex()] == 2)
- {
- Resim += (-MaxDelta(pEnt) - Resim);
- DesyncFix += (-MaxDelta(pEnt) - Resim);
- }
- if (LastDesyncSide[pEnt->EntIndex()] != CurrentSide)
- {
- Delaying[pEnt->EntIndex()] = true;
- if (.5f < (g_pGlobalVars->curtime - SideTime[pEnt->EntIndex()][LastDesyncSide[pEnt->EntIndex()]]))
- {
- LastDesyncSide[pEnt->EntIndex()] = CurrentSide;
- Delaying[pEnt->EntIndex()] = false;
- }
- }
- if (!Delaying[pEnt->EntIndex()])
- LastDesyncSide[pEnt->EntIndex()] = CurrentSide;
- }
- else if (!shot)
- {
- float Brute = UseFreestandAngle[pEnt->EntIndex()] ? g_Math.NormalizeYaw(Back + FreestandAngle[pEnt->EntIndex()]) : pEnt->GetLowerBodyYaw();
- float Delta = g_Math.NormalizeYaw(g_Math.NormalizeYaw(Brute - g_Math.NormalizeYaw(g_Math.NormalizeYaw(AnimState->m_flGoalFeetYaw + RemapVal(PosParams[11], 0, 1, -60, 60))) + Resim));
- if (Delta > MaxDelta(pEnt))
- Delta = MaxDelta(pEnt);
- if (Delta < -MaxDelta(pEnt))
- Delta = -MaxDelta(pEnt);
- Resim += Delta;
- DesyncFix += Delta;
- if (Resim > MaxDelta(pEnt))
- Resim = MaxDelta(pEnt);
- if (Resim < -MaxDelta(pEnt))
- Resim = -MaxDelta(pEnt);
- }
- float Equalized = g_Math.NormalizeYaw(g_Math.NormalizeYaw(AnimState->m_flGoalFeetYaw + RemapVal(PosParams[11], 0, 1, -60, 60)) + Resim);
- float JitterDelta = fabs(g_Math.NormalizeYaw(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y));
- if (JitterDelta >= 70.f && !shot)
- jittering[pEnt->EntIndex()] = true;
- if (pEnt != Globals::pLocalEntity && pEnt->GetTeam() != Globals::pLocalEntity->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND) && g_Menu.Config.Resolver)
- {
- if (jittering[pEnt->EntIndex()])
- AnimState->m_flGoalFeetYaw = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y + DesyncFix);
- else
- AnimState->m_flGoalFeetYaw = Equalized;
- pEnt->SetLowerBodyYaw(AnimState->m_flGoalFeetYaw);
- }
- StoredAnimState[pEnt->EntIndex()] = AnimState;
- oldEyeAngles[pEnt->EntIndex()] = pEnt->GetEyeAngles();
- oldSimtime[pEnt->EntIndex()] = storedSimtime[pEnt->EntIndex()];
- storedSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
- update = true;
- }
- pEnt->ClientAnimations(false);
- /*if (pEnt != Globals::pLocalEntity && pEnt->GetTeam() != Globals::pLocalEntity->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND) && g_Menu.Config.Resolver)
- pEnt->SetLowerBodyYaw(AnimState->m_flGoalFeetYaw);*/
- AnimState = StoredAnimState[pEnt->EntIndex()];
- memcpy((void*)PosParams, &StoredPosParams[pEnt->EntIndex()], (sizeof(float) * 24));
- memcpy(pEnt->AnimOverlays(), StoredLayers[pEnt->EntIndex()], (sizeof(AnimationLayer) * pEnt->NumOverlays()));
- if (pEnt != Globals::pLocalEntity && pEnt->GetTeam() != Globals::pLocalEntity->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND) && g_Menu.Config.Resolver && jittering[pEnt->EntIndex()])
- pEnt->SetAbsAngles(Vector(0, pEnt->GetEyeAngles().y, 0));
- else
- pEnt->SetAbsAngles(Vector(0, oldGoalfeetYaw[pEnt->EntIndex()], 0));
- /*if (pEnt == Globals::pLocalEntity && pEnt->GetVelocity().Length2D() < 45.f && !(Globals::IsSlowwalking || Globals::IsFakewalking))
- {
- AnimState->m_flUnknownFraction = 0.f;
- AnimState->m_flLeanAmount = 0.f;
- Globals::pLocalEntity->SetSequence(0);
- if (g_Menu.Config.ShowAccurateLby)
- pEnt->SetLowerBodyYaw(pEnt->GetEyeAngles().y);
- pEnt->ClientAnimations(false);
- }*/
- *reinterpret_cast<int*>(uintptr_t(pEnt) + 0xA30) = g_pGlobalVars->framecount;
- *reinterpret_cast<int*>(uintptr_t(pEnt) + 0xA28) = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement