Пользователь
-
Автор темы
- #1
Animation fix and resolver.
C++:
struct CLocalData
{
bool m_bSendPacket;
bool m_bMatrix;
bool m_bUpdateFakeAnimation;
bool m_bInitFakeAnimation;
float m_flSpawnTime;
float* m_flBackupPoseParameter;
Vector m_angViewAngles;
Vector m_BackupAbsAngles;
matrix3x4_t m_pFakeMatrix[128];
C_AnimState* m_aFakeAnimationState;
AnimationLayer m_aServerLayers[13];
};
struct CResolverData
{
float m_flRightAbsYaw;
float m_flLeftAbsYaw;
float m_flFeetDelta;
float m_flDuckAmount;
float m_nSpeed;
float m_pfGuessedAngle;
int m_nChoked;
int m_iSide;
AnimationLayer m_aServerLayers[13];
AnimationLayer m_aResolverLayers[3][13];
C_AnimState* m_aAnimationState;
Vector m_angEyeAngles;
bool m_bLeftDormancy;
bool m_bInAir;
};
struct CAnimationData
{
float m_flRightAngle;
float m_flMiddleAngle;
float m_flLeftAngle;
};
struct CFeetData
{
int m_fFlags;
Vector m_angEyeAngles;
float m_flDuckAmount;
float m_flLowerBodyYawTarget;
float m_flFeetCycle;
float m_flFeetYawRate;
};
struct CMatrixes
{
matrix3x4_t* m_pMatrixRight;
matrix3x4_t* m_pMatrixMiddle;
matrix3x4_t* m_pMatrixLeft;
};
C++:
void AnimationFix::Instance(ClientFrameStage_t stage)
{
if (!Globals::LocalPlayer || !g_pEngine->IsInGame())
return;
static bool wasDormant[65];
for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
{
C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
if (!pPlayerEntity || !pPlayerEntity->IsAlive())
{
ResetRecords();
continue;
}
if (pPlayerEntity->IsDormant())
{
ResetRecords();
wasDormant[i] = true;
continue;
}
if (pPlayerEntity == Globals::LocalPlayer)
{
ResetRecords();
continue;
}
if (stage == FRAME_RENDER_START)
{
HandleHits(pPlayerEntity);
UpdateRecords(pPlayerEntity, true);
UpdateAbsYaw(pPlayerEntity);
Update(pPlayerEntity);
UpdateResolverLayer(pPlayerEntity, 0, m_pAnimationData.m_flMiddleAngle, m_pMatrixes.m_pMatrixMiddle);
UpdateResolverLayer(pPlayerEntity, 1, m_pAnimationData.m_flRightAngle, m_pMatrixes.m_pMatrixRight);
UpdateResolverLayer(pPlayerEntity, 2, m_pAnimationData.m_flLeftAngle, m_pMatrixes.m_pMatrixLeft);
UpdateRecords(pPlayerEntity, false);
UpdateAbsYaw(pPlayerEntity);
}
if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
if (Globals::MissedShots[pPlayerEntity->EntIndex()] > 1) {
Bruteforce(pPlayerEntity);
Resolver(pPlayerEntity, 0, m_pData.m_pfGuessedAngle);
}
else {
ResolveViaLayers(pPlayerEntity);
Update(pPlayerEntity);
Resolver(pPlayerEntity, m_pData.m_iSide);
}
}
wasDormant[i] = false;
}
}
void AnimationFix::Update(C_BaseEntity* pEnt)
{
float m_flSimulationTime = pEnt->GetSimulationTime();
float m_flRealtime = g_pGlobalVars->realtime;
float m_flCurtime = g_pGlobalVars->curtime;
float m_flFrametime = g_pGlobalVars->frametime;
float m_flAbsFrametime = g_pGlobalVars->absoluteframetime;
float m_flInterpolation = g_pGlobalVars->interpolationAmount;
float m_nFrames = g_pGlobalVars->framecount;
float m_nTicks = g_pGlobalVars->tickcount;
int m_iNextSimulationTick = m_flSimulationTime / g_pGlobalVars->intervalPerTick + 1;
g_pGlobalVars->realtime = m_flSimulationTime;
g_pGlobalVars->curtime = m_flSimulationTime;
g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick;
g_pGlobalVars->absoluteframetime = g_pGlobalVars->intervalPerTick;
g_pGlobalVars->framecount = m_iNextSimulationTick;
g_pGlobalVars->tickcount = m_iNextSimulationTick;
g_pGlobalVars->interpolationAmount = 0.f;
if (pEnt->AnimState()->m_iLastClientSideAnimationUpdateFramecount >= m_iNextSimulationTick)
pEnt->AnimState()->m_iLastClientSideAnimationUpdateFramecount = m_iNextSimulationTick - 1;
pEnt->ClientAnimations(true);
pEnt->UpdateClientAnimation();
g_pGlobalVars->realtime = m_flRealtime;
g_pGlobalVars->curtime = m_flCurtime;
g_pGlobalVars->frametime = m_flFrametime;
g_pGlobalVars->absoluteframetime = m_flAbsFrametime;
g_pGlobalVars->interpolationAmount = m_flInterpolation;
g_pGlobalVars->framecount = m_nFrames;
g_pGlobalVars->tickcount = m_nTicks;
}
void AnimationFix::UpdateLocal()
{
m_pLocalData.m_aFakeAnimationState = nullptr;
m_pLocalData.m_bUpdateFakeAnimation = true;
m_pLocalData.m_bInitFakeAnimation = true;
m_pLocalData.m_flSpawnTime = 0.f;
if (!g_pEngine->IsConnected() || !Globals::LocalPlayer || !Globals::LocalPlayer->IsAlive())
{
m_pLocalData.m_bUpdateFakeAnimation = true;
m_pLocalData.m_bInitFakeAnimation = true;
m_pLocalData.m_flSpawnTime = 0.f;
m_pLocalData.m_aFakeAnimationState = nullptr;
return;
}
if (m_pLocalData.m_flSpawnTime != Globals::LocalPlayer->m_flSpawnTime() || m_pLocalData.m_bUpdateFakeAnimation)
{
m_pLocalData.m_flSpawnTime = Globals::LocalPlayer->m_flSpawnTime();
m_pLocalData.m_bInitFakeAnimation = false;
m_pLocalData.m_bUpdateFakeAnimation = false;
}
if (!m_pLocalData.m_bInitFakeAnimation)
{
m_pLocalData.m_aFakeAnimationState = static_cast<C_AnimState*>(g_pMemAlloc->Alloc(sizeof(C_AnimState)));
if (m_pLocalData.m_aFakeAnimationState != nullptr)
CreateAnimationState(m_pLocalData.m_aFakeAnimationState, Globals::LocalPlayer);
m_pLocalData.m_bInitFakeAnimation = true;
}
if (m_pLocalData.m_bSendPacket)
{
std::memcpy(m_pLocalData.m_aServerLayers, Globals::LocalPlayer->AnimOverlays(), sizeof(AnimationLayer) * Globals::LocalPlayer->GetNumAnimOverlays());
m_pLocalData.m_BackupAbsAngles = Globals::LocalPlayer->GetAbsAngles();
m_pLocalData.m_flBackupPoseParameter = Globals::LocalPlayer->m_flPoseParameter();
UpdateAnimationState(m_pLocalData.m_aFakeAnimationState, m_pLocalData.m_angViewAngles);
Globals::LocalPlayer->InvalidateBoneCache();
Globals::LocalPlayer->SetAbsAngles(Vector(0.f, m_pLocalData.m_aFakeAnimationState->m_flGoalFeetYaw, 0.f));
std::memcpy(Globals::LocalPlayer->AnimOverlays(), m_pLocalData.m_aServerLayers, sizeof(AnimationLayer) * Globals::LocalPlayer->GetNumAnimOverlays());
m_pLocalData.m_bMatrix = Globals::LocalPlayer->SetupBones(m_pLocalData.m_pFakeMatrix, 128, 0x7FF00, g_pGlobalVars->curtime);
const Vector m_RenderOrigin = Globals::LocalPlayer->GetRenderOrigin();
if (m_pLocalData.m_bMatrix)
{
for (auto& i : m_pLocalData.m_pFakeMatrix)
{
i[0][3] -= m_RenderOrigin.x;
i[1][3] -= m_RenderOrigin.y;
i[2][3] -= m_RenderOrigin.z;
}
}
std::memcpy(Globals::LocalPlayer->AnimOverlays(), m_pLocalData.m_aServerLayers, sizeof(AnimationLayer) * Globals::LocalPlayer->GetNumAnimOverlays());
std::memcpy(Globals::LocalPlayer->m_flPoseParameter(), m_pLocalData.m_flBackupPoseParameter, sizeof(float) * 24);
Globals::LocalPlayer->SetAbsAngles(Vector(0.f, m_pLocalData.m_BackupAbsAngles.y, 0.f));
}
}
void AnimationFix::ResetRecords()
{
m_pAnimationData.m_flLeftAngle = 0.f;
m_pAnimationData.m_flRightAngle = 0.f;
m_pAnimationData.m_flMiddleAngle = 0.f;
m_pLastData.m_bLeftDormancy = false;
m_pLastData.m_aAnimationState = nullptr;
m_pLastData.m_flFeetDelta = 0.f;
m_pLastData.m_flDuckAmount = 0.f;
m_pLastData.m_pfGuessedAngle = 0.f;
m_pLastData.m_angEyeAngles = Vector(0.f, 0.f, 0.f);
m_pLastData.m_bInAir = false;
m_pLastData.m_nSpeed = 0.f;
m_pLastData.m_nChoked = 0;
m_pData.m_bLeftDormancy = false;
m_pData.m_aAnimationState = nullptr;
m_pData.m_flFeetDelta = 0.f;
m_pData.m_flDuckAmount = 0.f;
m_pData.m_pfGuessedAngle = 0.f;
m_pData.m_angEyeAngles = Vector(0.f, 0.f, 0.f);
m_pData.m_bInAir = false;
m_pData.m_nSpeed = 0.f;
m_pData.m_nChoked = 0;
m_bRecordsUpdated = false;
}
void AnimationFix::UpdateRecords(C_BaseEntity* pEnt, bool m_bPrevious)
{
if (!c_config::get().aimbot_resolver)
return;
m_pAnimationData.m_flLeftAngle = g_Math.AngleNormalize(pEnt->GetEyeAngles().y + 60.f);
m_pAnimationData.m_flRightAngle = g_Math.AngleNormalize(pEnt->GetEyeAngles().y - 60.f);
m_pAnimationData.m_flMiddleAngle = g_Math.AngleNormalize(pEnt->GetEyeAngles().y);
if (!m_bPrevious)
{
m_pData.m_bLeftDormancy = g_Math.AngleNormalize(pEnt->GetEyeAngles().y) > 0.f ? true : false;
m_pData.m_aAnimationState = pEnt->AnimState();
m_pData.m_flFeetDelta = g_Math.AngleDifference(pEnt->GetEyeAngles().y, pEnt->AnimState()->m_flGoalFeetYaw);
m_pData.m_flDuckAmount = pEnt->AnimState()->m_fDuckAmount;
m_pData.m_angEyeAngles = pEnt->GetEyeAngles();
m_pData.m_bInAir = ((pEnt->GetFlags() != FL_ONGROUND) || !(pEnt->GetFlags() & FL_ONGROUND));
m_pData.m_nSpeed = pEnt->GetVelocity().Length2D();
m_pData.m_nChoked = TIME_TO_TICKS(pEnt->GetSimulationTime() - pEnt->GetOldSimulationTime());
std::memcpy(m_pData.m_aServerLayers, pEnt->AnimOverlays(), sizeof(AnimationLayer) * pEnt->GetNumAnimOverlays());
}
else
{
m_pLastData.m_bLeftDormancy = g_Math.AngleNormalize(pEnt->GetEyeAngles().y) > 0.f ? true : false;
m_pLastData.m_aAnimationState = pEnt->AnimState();
m_pLastData.m_flFeetDelta = g_Math.AngleDifference(pEnt->GetEyeAngles().y, pEnt->AnimState()->m_flGoalFeetYaw);
m_pLastData.m_flDuckAmount = pEnt->AnimState()->m_fDuckAmount;
m_pLastData.m_angEyeAngles = pEnt->GetEyeAngles();
m_pLastData.m_bInAir = ((pEnt->GetFlags() != FL_ONGROUND) || !(pEnt->GetFlags() & FL_ONGROUND));
m_pLastData.m_nSpeed = pEnt->GetVelocity().Length2D();
m_pLastData.m_nChoked = TIME_TO_TICKS(pEnt->GetSimulationTime() - pEnt->GetOldSimulationTime());
std::memcpy(m_pLastData.m_aServerLayers, pEnt->AnimOverlays(), sizeof(AnimationLayer) * pEnt->GetNumAnimOverlays());
}
m_bRecordsUpdated = true;
}
void AnimationFix::UpdateResolverLayer(C_BaseEntity* pEnt, int m_iLayerSide, float m_flAngle, matrix3x4_t* m_pMatrix)
{
if (!c_config::get().aimbot_resolver)
return;
pEnt->AnimState()->m_flGoalFeetYaw = g_Math.AngleNormalize(m_flAngle);
pEnt->UpdateClientAnimation();
pEnt->SetupBones(m_pMatrix, 128, 0x0007FF00, g_pGlobalVars->curtime);
std::memcpy(m_pData.m_aResolverLayers[m_iLayerSide], pEnt->AnimOverlays(), sizeof(AnimationLayer) * pEnt->GetNumAnimOverlays());
m_bLayersUpdated = true;
}
void AnimationFix::UpdateAbsYaw(C_BaseEntity* pEnt)
{
if (!c_config::get().aimbot_resolver)
return;
if (!m_pData.m_bInAir)
{
if (m_pData.m_nSpeed > 45.f)
{
if (m_pData.m_flFeetDelta > 0.f && m_pData.m_bLeftDormancy)
m_pData.m_flLeftAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw + 30.f;
else
m_pData.m_flRightAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw - 30.f;
}
else if (m_pData.m_nSpeed <= 45.f && m_pData.m_nSpeed > 8.f)
{
if (m_pData.m_flFeetDelta > 0.f && m_pData.m_bLeftDormancy)
m_pData.m_flLeftAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw + 60.f;
else
m_pData.m_flRightAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw - 60.f;
}
else if (m_pData.m_nSpeed <= 8.f)
{
if (m_pData.m_flFeetDelta > 0.f && m_pData.m_bLeftDormancy)
m_pData.m_flLeftAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw + 60.f;
else
m_pData.m_flRightAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw - 60.f;
}
}
else if (m_pData.m_bInAir)
{
if (m_pData.m_nSpeed > 45.f)
{
if (m_pData.m_flFeetDelta > 0.f || m_pData.m_bLeftDormancy)
m_pData.m_flLeftAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw + 15.f;
else
m_pData.m_flRightAbsYaw = pEnt->AnimState()->m_flGoalFeetYaw - 15.f;
}
}
m_bAbsYawUpdated = true;
}
void AnimationFix::SaveFeetAnimations(C_BaseEntity* pEnt)
{
m_FeetData.m_fFlags = pEnt->GetFlags();
m_FeetData.m_angEyeAngles = pEnt->GetEyeAngles();
m_FeetData.m_flDuckAmount = pEnt->AnimState()->m_fDuckAmount;
m_FeetData.m_flLowerBodyYawTarget = pEnt->GetLowerBodyYaw();
m_FeetData.m_flFeetCycle = pEnt->AnimState()->m_flFeetCycle;
m_FeetData.m_flFeetYawRate = pEnt->AnimState()->m_flFeetYawRate;
}
void AnimationFix::RestoreFeetAnimations(C_BaseEntity* pEnt)
{
pEnt->SetFlags(m_FeetData.m_fFlags);
pEnt->SetEyeAngles(m_FeetData.m_angEyeAngles);
pEnt->AnimState()->m_fDuckAmount = m_FeetData.m_flDuckAmount;
pEnt->SetLowerBodyYaw(m_FeetData.m_flLowerBodyYawTarget);
pEnt->AnimState()->m_flFeetCycle = m_FeetData.m_flFeetCycle;
pEnt->AnimState()->m_flFeetYawRate = m_FeetData.m_flFeetYawRate;
}
void AnimationFix::ResolveViaLayers(C_BaseEntity* pEnt)
{
if (!c_config::get().aimbot_resolver)
return;
if (!m_pData.m_bInAir)
{
if (m_pData.m_nSpeed <= 0.1)
{
if (m_pData.m_aServerLayers[3].m_flWeight == 0.f && m_pData.m_aServerLayers[3].m_flCycle == 0.f && m_pData.m_aServerLayers[6].m_flWeight == 0.f)
{
m_pData.m_iSide = 2 * (m_pData.m_flFeetDelta <= 0.0) - 1;
}
}
else if (!(m_pData.m_aServerLayers[12].m_flWeight * 1000.f))
{
if (int(m_pData.m_aServerLayers[6].m_flWeight * 1000.f) == int(m_pLastData.m_aServerLayers[6].m_flWeight * 1000.f))
{
float DeltaFirst = abs(m_pData.m_aServerLayers[6].m_flPlaybackRate - m_pData.m_aResolverLayers[0][6].m_flPlaybackRate);
float DeltaSecond = abs(m_pData.m_aServerLayers[6].m_flPlaybackRate - m_pData.m_aResolverLayers[1][6].m_flPlaybackRate);
float DeltaThird = abs(m_pData.m_aServerLayers[6].m_flPlaybackRate - m_pData.m_aResolverLayers[2][6].m_flPlaybackRate);
if (DeltaFirst < DeltaSecond || DeltaThird <= DeltaSecond || (DeltaSecond * 1000.0))
{
if (DeltaFirst >= DeltaThird && DeltaSecond > DeltaThird && !(DeltaThird * 1000.0))
{
m_pData.m_iSide = 1;
}
}
else
{
m_pData.m_iSide = -1;
}
}
}
}
}
void AnimationFix::Resolver(C_BaseEntity* pEnt, int m_iSide, float m_pfGuessedAngle)
{
if (!c_config::get().aimbot_resolver || pEnt->GetTeam() == Globals::LocalPlayer->GetTeam() || pEnt == Globals::LocalPlayer || pEnt->IsDormant())
return;
SaveFeetAnimations(pEnt);
pEnt->SetAbsOrigin(pEnt->GetVecOrigin());
if (m_pLastData.m_bLeftDormancy)
{
std::memcpy(pEnt->AnimOverlays(), m_pData.m_aServerLayers, sizeof(AnimationLayer) * pEnt->GetNumAnimOverlays());
}
else
{
std::memcpy(pEnt->AnimOverlays(), m_pLastData.m_aServerLayers, sizeof(AnimationLayer) * pEnt->GetNumAnimOverlays());
}
float m_flBruteAngle = m_pData.m_angEyeAngles.y;
if (m_pData.m_nChoked == 1)
{
if (m_iSide)
{
if (m_iSide > 0)
{
if (m_pLastData.m_bLeftDormancy)
m_flBruteAngle -= 60.f;
else
m_flBruteAngle = m_pAnimationData.m_flLeftAngle;
}
else if (m_iSide < 0)
{
if (m_pLastData.m_bLeftDormancy)
m_flBruteAngle += 60.f;
else
m_flBruteAngle = m_pAnimationData.m_flRightAngle;
}
}
else if (m_pfGuessedAngle)
m_flBruteAngle = m_pfGuessedAngle;
}
else if (m_pData.m_nChoked)
{
m_flBruteAngle += 60 * ((m_iSide <= 0) ? -1 : 1);
}
pEnt->AnimState()->m_flGoalFeetYaw = g_Math.AngleNormalize(m_flBruteAngle);
Update(pEnt);
RestoreFeetAnimations(pEnt);
}
void AnimationFix::AntiFreestand()
{
if (!c_config::get().aimbot_resolver)
return;
if (!Globals::LocalPlayer->IsAlive())
return;
if (!Globals::LocalPlayer->GetActiveWeapon() || Globals::LocalPlayer->IsKnifeorNade())
return;
for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
{
C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
if (!pPlayerEntity
|| !pPlayerEntity->IsAlive()
|| pPlayerEntity->IsDormant()
|| pPlayerEntity == Globals::LocalPlayer
|| pPlayerEntity->GetTeam() == Globals::LocalPlayer->GetTeam())
{
UseFreestandAngle[i] = false;
continue;
}
if (abs(pPlayerEntity->GetVelocity().Length2D()) > 29.f)
UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
if (abs(pPlayerEntity->GetVelocity().Length2D()) <= 29.f && !UseFreestandAngle[pPlayerEntity->EntIndex()])
{
bool Autowalled = false, HitSide1 = false, HitSide2 = false;
float angToLocal = g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
Vector ViewPoint = Globals::LocalPlayer->GetOrigin() + Vector(0, 0, 90);
Vector2D Side1 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal))),(45 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
Vector2D Side2 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
Vector2D Side3 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal))),(50 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
Vector2D Side4 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
Vector Origin = pPlayerEntity->GetOrigin();
Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
for (int side = 0; side < 2; side++)
{
Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x, Origin.y - OriginLeftRight[side].y , Origin.z + 90 };
Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x, ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
if (g_Autowall.CanHitFloatingPoint(OriginAutowall, ViewPoint))
{
if (side == 0)
{
HitSide1 = true;
FreestandAngle[pPlayerEntity->EntIndex()] = 90;
}
else if (side == 1)
{
HitSide2 = true;
FreestandAngle[pPlayerEntity->EntIndex()] = -90;
}
Autowalled = true;
}
else
{
for (int side222 = 0; side222 < 2; side222++)
{
Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x, Origin.y - OriginLeftRight[side222].y , Origin.z + 90 };
if (g_Autowall.CanHitFloatingPoint(OriginAutowall222, OriginAutowall2))
{
if (side222 == 0)
{
HitSide1 = true;
FreestandAngle[pPlayerEntity->EntIndex()] = 90;
}
else if (side222 == 1)
{
HitSide2 = true;
FreestandAngle[pPlayerEntity->EntIndex()] = -90;
}
Autowalled = true;
}
}
}
}
if (Autowalled)
{
if (HitSide1 && HitSide2)
UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
else
UseFreestandAngle[pPlayerEntity->EntIndex()] = true;
}
}
}
}
void AnimationFix::Bruteforce(C_BaseEntity* pEnt)
{
switch (Globals::MissedShots[pEnt->EntIndex()] % 6)
{
case 0:
m_pData.m_pfGuessedAngle = m_pData.m_flLeftAbsYaw;
break;
case 1:
m_pData.m_pfGuessedAngle = m_pData.m_flRightAbsYaw;
break;
case 2:
m_pData.m_pfGuessedAngle = m_pData.m_flLeftAbsYaw;
break;
case 3:
m_pData.m_pfGuessedAngle = m_pData.m_flRightAbsYaw;
break;
case 4:
m_pData.m_pfGuessedAngle = m_pData.m_flLeftAbsYaw;
break;
case 5:
m_pData.m_pfGuessedAngle = m_pData.m_flRightAbsYaw;
break;
case 6:
m_pData.m_pfGuessedAngle = m_pData.m_flLeftAbsYaw;
break;
}
}
void AnimationFix::HandleHits(C_BaseEntity* pEnt)
{
auto NetChannel = g_pEngine->GetNetChannelInfo();
if (!NetChannel)
return;
static float predTime[65];
static bool init[65];
if (Globals::Shot[pEnt->EntIndex()])
{
if (init[pEnt->EntIndex()])
{
g_AnimationFix.pitchHit[pEnt->EntIndex()] = pEnt->GetEyeAngles().x;
predTime[pEnt->EntIndex()] = g_pGlobalVars->curtime + NetChannel->GetAvgLatency(FLOW_INCOMING) + NetChannel->GetAvgLatency(FLOW_OUTGOING) + TICKS_TO_TIME(1) + TICKS_TO_TIME(g_pEngine->GetNetChannel()->m_nChokedPackets);
init[pEnt->EntIndex()] = false;
}
if (g_pGlobalVars->curtime > predTime[pEnt->EntIndex()] && !Globals::Hit[pEnt->EntIndex()])
{
Globals::MissedShots[pEnt->EntIndex()] += 1;
Globals::Shot[pEnt->EntIndex()] = false;
}
else if (g_pGlobalVars->curtime <= predTime[pEnt->EntIndex()] && Globals::Hit[pEnt->EntIndex()])
Globals::Shot[pEnt->EntIndex()] = false;
}
else
init[pEnt->EntIndex()] = true;
Globals::Hit[pEnt->EntIndex()] = false;
}
Последнее редактирование: