-
Автор темы
- #1
C++:
// Variables to store information about the enemy's desync
int missedShots = 0;
int freestandSide = 0;
float lastFreestandYaw = 0.f;
// Resolver function called when resolving the enemy's desync
void ResolveDesync(IClientEntity* enemy)
{
// Calculate eye delta and determine the side based on the previous methods
float eyeDelta = enemy->GetEyeAngles().y - enemy->GetAnimState()->goalfeetyaw;
int side = 0;
// Opposite Desync Resolving
float desyncDelta = (missedShots == 0) ? enemy->GetMaxDesync() : enemy->GetMaxDesync() / 2;
if (missedShots > 0)
desyncDelta *= -1;
// Anti-Freestand
if (freestandSide != 0)
{
// Adjust the desync based on the freestand side
desyncDelta *= freestandSide;
}
// Animlayers
std::memcpy(csgo->MoveLayers[0][6], enemy->GetAnimOverlay(6), 0x38 * int(enemy->GetAnimOverlays()));
enemy->SetupBones(csgo->zero, 128, 0x7FF00, interfaces.global_vars->curtime);
if (eyeDelta < 0.f)
{
std::memcpy(csgo->MoveLayers[1][6], enemy->GetAnimOverlay(6), 0x38 * int(enemy->GetAnimOverlays()));
enemy->SetupBones(csgo->positive, 128, 0x7FF00, interfaces.global_vars->curtime);
}
else
{
std::memcpy(csgo->MoveLayers[2][6], enemy->GetAnimOverlay(6), 0x38 * int(enemy->GetAnimOverlays()));
enemy->SetupBones(csgo->negative, 128, 0x7FF00, interfaces.global_vars->curtime);
}
// Tracing
Vector current = enemy->GetEyeAngles();
float distance = /* desired distance for tracing */;
float backOne = current.y - 180.f;
if (fabs(backOne) >= enemy->GetMaxDesyncDelta())
{
side=0;
}
else
{
// Perform tracing to determine the side if the enemy is not in the back position
Vector right(current.x, current.y + enemy->GetMaxDesyncDelta(), current.z);
Vector left(current.x, current.y - enemy->GetMaxDesyncDelta(), current.z);
float rightTwo = TracedDistance(current, right);
float leftTwo = TracedDistance(current, left);
if (fabs(rightTwo) >= distance)
side=1;
else if (fabs(leftTwo) >= distance)
side = -1;
}
// Update the resolver variables for future iterations
missedShots++; // Increase missed shots count
freestandside = side;
lastFreestandYaw = enemy->GetAnimState()->goalfeetyaw;
}
// Function to calculate traced distance between two vectors
float TracedDistance(Vector start, Vector end)
{
trace_ttr;
Ray_tray;
CTraceFilter filter;
filter.pSkip = enemy;
ray.init(start, end);
interfaces.trace->TraceRay(ray, MASK_SHOT, &filter, &tr);
return (tr.endpos - tr.startpos).Length2D();
}
// Usage example
void ResolveEnemyDesync(IClientEntity* enemy)
{
// Reset resolver variables if the enemy is a new target
if (enemy != previousEnemy)
{
missedShots = 0;
freestandSide = 0;
lastFreestandYaw = 0.f;
}
// Resolve the enemy's desync
ResolveDesync(enemy);
// Store the current enemy as the previous enemy for future iterations
previousEnemy = enemy;
}