#include "Resolver.h"
#include "..\Aimbot\Aimbot.h"
#include "..\Aimbot\Autowall.h"
#include "..\Aimbot\LagComp.h"
#include "..\..\Utils\Utils.h"
#include "..\..\SDK\IVEngineClient.h"
#include "..\..\SDK\Hitboxes.h"
#include "..\..\SDK\PlayerInfo.h"
#include "..\..\Utils\Math.h"
#include "..\..\Menu\Menu.h"
#include "..\..\Menu\config.h"
Resolver g_Resolver;
/*
my attempt at fixing desync and i was pretty successful
it can resolve static desync pretty perfectly
and can resolve some jitter desync but
it still gets rekt by other things
*/
void Resolver::AnimationFix(C_BaseEntity* pEnt)
{
const auto player_animation_state = pEnt->AnimState();
if (!player_animation_state)
return;
if (Globals::MissedShots[pEnt->EntIndex()] > 2) {
switch (Globals::MissedShots[pEnt->EntIndex()] % 4) {
case 0: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw + 60; break;
case 1: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw - 60; break;
case 2: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw - 60; break;
case 3: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw + 60; break;
}
float m_flLastClientSideAnimationUpdateTimeDelta = fabs(player_animation_state->m_iLastClientSideAnimationUpdateFramecount - player_animation_state->m_flLastClientSideAnimationUpdateTime);
pEnt->UpdateClientAnimation();
auto old_curtime = g_pGlobalVars->curtime;
auto old_frametime = g_pGlobalVars->frametime;
auto curtime = g_pGlobalVars->curtime;
auto frametime = g_pGlobalVars->frametime;
auto frametimne = (g_pGlobalVars->frametime);
auto absoluteframtime = (g_pGlobalVars->absoluteframetime);
auto interp_amount = (g_pGlobalVars->interpolationAmount);
auto framecount = g_pGlobalVars->framecount;
auto tickcount = g_pGlobalVars->tickcount;
g_pGlobalVars->realtime = pEnt->GetSimulationTime();
g_pGlobalVars->curtime = pEnt->GetSimulationTime();
g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick;
g_pGlobalVars->absoluteframetime = g_pGlobalVars->intervalPerTick;
g_pGlobalVars->framecount = pEnt->GetSimulationTime();
g_pGlobalVars->tickcount = pEnt->GetSimulationTime();
g_pGlobalVars->interpolationAmount = 0.0f;
g_pGlobalVars->curtime = pEnt->GetSimulationTime();
g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick;
player_animation_state->m_iLastClientSideAnimationUpdateFramecount >= pEnt->GetSimulationTime();
player_animation_state->m_iLastClientSideAnimationUpdateFramecount = pEnt->GetSimulationTime() - 1;
pEnt->UpdateClientAnimation();
g_pGlobalVars->curtime = old_curtime;
g_pGlobalVars->frametime = old_frametime;
(g_pGlobalVars->realtime) = g_pGlobalVars->realtime;
(g_pGlobalVars->curtime) = curtime;
(g_pGlobalVars->frametime) = frametimne;
(g_pGlobalVars->absoluteframetime) = absoluteframtime;
g_pGlobalVars->framecount = framecount;
g_pGlobalVars->tickcount = tickcount;
}
}
float flAngleMod(float flAngle)
{
return((360.0f / 65536.0f) * ((int32_t)(flAngle * (65536.0f / 360.0f)) & 65535));
}
float ApproachAngle(float target, float value, float speed)
{
target = flAngleMod(target);
value = flAngleMod(value);
float delta = target - value;
// Speed is assumed to be positive
if (speed < 0)
speed = -speed;
if (delta < -180)
delta += 360;
else if (delta > 180)
delta -= 360;
if (delta > speed)
value += speed;
else if (delta < -speed)
value -= speed;
else
value = target;
return value;
}
/*
*/
void update_state(C_AnimState* state, Vector angles) {
using Fn = void(__vectorcall*)(void*, void*, float, float, float, void*);
static auto fn = reinterpret_cast<Fn>(Utils::FindSignature("client_panorama.dll", "55 8B EC 83 E4 F8 83 EC 18 56 57 8B F9 F3 0F 11 54 24"));
fn(state, nullptr, 0.0f, angles[1], angles[0], nullptr);
}
void HandleBackUpResolve(C_BaseEntity* pEnt) {
if (!c_config::get().aimbot_resolver)
return;
if (pEnt->GetTeam() == Globals::LocalPlayer->GetTeam())
return;
auto animstate = pEnt->AnimState();
const auto player_animation_state = pEnt->AnimState();
float flMaxYawModifier = player_animation_state->pad10[516] * flMaxYawModifier;
float flMinYawModifier = player_animation_state->pad10[512] * flMaxYawModifier;
float newFeetYaw = 1.f;
auto eyeYaw = player_animation_state->m_flEyeYaw;
auto lbyYaw = player_animation_state->m_flGoalFeetYaw;
float eye_feet_delta = fabs(eyeYaw - lbyYaw);
if (!player_animation_state)
return;
float m_flLastClientSideAnimationUpdateTimeDelta = fabs(player_animation_state->m_iLastClientSideAnimationUpdateFramecount - player_animation_state->m_flLastClientSideAnimationUpdateTime);
auto v28 = 0.f;
if (player_animation_state->m_flFeetSpeedForwardsOrSideWays >= 0.0f)
{
v28 = fminf(player_animation_state->m_flFeetSpeedForwardsOrSideWays, 0.0f);
}
else
{
v28 = 0x3F800000;
}
float v49 = ((player_animation_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * v49;
float flYawModifier = v49 + 1.0;
if (player_animation_state->m_fDuckAmount > 0.0)
{
float v53 = 0.0f;
if (player_animation_state->m_flFeetSpeedUnknownForwardOrSideways >= 0.0)
{
v53 = fminf(player_animation_state->m_flFeetSpeedUnknownForwardOrSideways, 1.0);
}
else
{
v53 = 0.0f;
}
}
if (eye_feet_delta <= flMaxYawModifier)
{
if (flMinYawModifier > eye_feet_delta)
{
newFeetYaw = fabs(flMinYawModifier) + eyeYaw;
}
}
else
{
newFeetYaw = eyeYaw - fabs(flMaxYawModifier);
}
float v136 = fmod(newFeetYaw, 360.0);
if (v136 > 180.0)
{
v136 = v136 - 360.0;
}
if (v136 < 180.0)
{
v136 = v136 + 360.0;
}
v28 = v49++;
{ // inlined max_desync_delta
float v9 = fabs(animstate->m_iLastClientSideAnimationUpdateFramecount - animstate->m_flLastClientSideAnimationUpdateTime);
float speedfraction = 0.0;
if (animstate->m_flFeetSpeedForwardsOrSideWays < 0.0)
speedfraction = 0.0;
else
speedfraction = animstate->m_flFeetSpeedForwardsOrSideWays;
float v2 = (animstate->m_flStopToFullRunningFraction * -0.30000001 - 0.19999999) * speedfraction;
float v18 = v2;
float v3 = v2 + 1.0;
float v23 = v3;
if (animstate->m_fDuckAmount > 0.0)
{
float v29 = 0.0;
if (animstate->m_flFeetSpeedUnknownForwardOrSideways < 0.0)
v29 = 0.0;
else
v29 = fminf((animstate->m_flFeetSpeedUnknownForwardOrSideways), 0x3F800000);
}
if (Globals::LocalPlayer)
{
for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
{
if (pEnt)// dormant
{
float v28 = pEnt->GetEyeAngles().y == 0.0 ? -58 : 58;
if (v28)
return;
float v27 = pEnt->GetEyeAngles().y == 0.0 ? -89 : 89;
if (v27)
return;
float v26 = pEnt->GetEyeAngles().y == 0.0 ? -79 : 79;
if (v26)
return;
float v25 = pEnt->GetEyeAngles().y == 0.0 ? -125 : 125;
if (v25)
return;
float v24 = pEnt->GetEyeAngles().y == 0.0 ? -78 : 78;
if (v24)
return;
}
float v8 = 0;
float v7 = 0;
float v6 = 0;
for (size_t i = 0; i < pEnt->GetNumAnimOverlays(); i++)
{
auto animLayer = pEnt->GetAnimOverlay4(i);
if (!animLayer)
continue;
if (pEnt->GetSequenceActivity(animLayer->m_nSequence) == 979);
auto v6 = pEnt->GetLowerBodyYaw();
}
float v20 = (animstate->m_vVelocityX) * v23;
float a1 = (animstate->m_vVelocityY) * v23;
float v30 = 0.0;
float eye_angles_y = animstate->m_flEyeYaw;
float goal_feet_yaw = animstate->m_flGoalFeetYaw;
float v22 = fabs(eye_angles_y - goal_feet_yaw);
if (v20 < v22)
{
float v11 = fabs(v20);
v30 = eye_angles_y - v11;
}
else if (a1 > v22)
{
float v12 = fabs(a1);
v30 = v12 + eye_angles_y;
}
float v36 = std::fmodf((v30), 360.0);
if (v36 > 180.0)
v36 = v36 - 360.0;
if (v36 < 180.0)
v36 = v36 + 360.0;
animstate->m_flGoalFeetYaw = v36;
if (Globals::MissedShots[pEnt->EntIndex()] > 2)
{
int v19 = Globals::MissedShots[pEnt->EntIndex()] % 4;
switch (v19)
{
case 0:
animstate->m_flGoalFeetYaw = animstate->m_flGoalFeetYaw + 45.0;
break;
case 1:
animstate->m_flGoalFeetYaw = animstate->m_flGoalFeetYaw - 45.0;
break;
case 2:
animstate->m_flGoalFeetYaw = animstate->m_flGoalFeetYaw - 30.0;
break;
case 3:
animstate->m_flGoalFeetYaw = animstate->m_flGoalFeetYaw + 30.0;
break;
default:
return;
player_animation_state->m_flGoalFeetYaw = v136;
}
}
}
}
}
}
void 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_Resolver.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;
}
void Resolver::OnCreateMove() // cancer v2
{
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 Resolver::FrameStage(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())
continue;
if (pPlayerEntity->IsDormant())
{
wasDormant[i] = true;
continue;
}
if (stage == FRAME_RENDER_START)
{
HandleHits(pPlayerEntity);
AnimationFix(pPlayerEntity);
}
if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
HandleBackUpResolve(pPlayerEntity);
}
if (stage == FRAME_NET_UPDATE_END && pPlayerEntity != Globals::LocalPlayer)
{
auto VarMap = reinterpret_cast<uintptr_t>(pPlayerEntity) + 36;
auto VarMapSize = *reinterpret_cast<int*>(VarMap + 20);
for (auto index = 0; index < VarMapSize; index++)
*reinterpret_cast<uintptr_t*>(*reinterpret_cast<uintptr_t*>(VarMap) + index * 12) = 0;
}
wasDormant[i] = false;
}
}