Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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"
- #include "../Legit Aimbot/Legit Aimbot.h"
- #include <random>
- 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
- */
- #define clamp1(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
- void Resolver::Log()
- {
- for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
- {
- auto& record = arr_infos[i];
- C_BaseEntity* player = g_pEntityList->GetClientEntity(i);
- if (!player || !player->IsAlive() || player->GetTeam() == Globals::LocalPlayer->GetTeam())
- {
- record.m_bActive = false;
- continue;
- }
- if (player->IsDormant())
- continue;
- if (record.m_flSimulationTime == player->GetSimulationTime())
- continue;
- record.SaveRecord(player);
- record.m_bActive = true;
- }
- }
- void Resolver::UpdateAnimations(C_BaseEntity* player, C_AnimState* state)
- {
- state = player->AnimState();
- if (state)
- {
- // backup
- const float curtime = g_pGlobalVars->curtime;
- const float frametime = g_pGlobalVars->frametime;
- g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick;
- g_pGlobalVars->curtime = player->GetSimulationTime();
- int backup_eflags = player->m_iEFlags();
- // SetLocalVelocity
- player->m_iEFlags() &= ~0x1000; // InvalidatePhysicsRecursive(VELOCITY_CHANGED); EFL_DIRTY_ABSVELOCITY = 0x1000
- player->m_vecAbsVelocity() = player->GetVelocity();
- // invalidates prior animations
- if (state->m_iLastClientSideAnimationUpdateFramecount == g_pGlobalVars->framecount)
- state->m_iLastClientSideAnimationUpdateFramecount = g_pGlobalVars->framecount - 1;
- player->ClientAnimations(true);
- // updates local animations + poses + calculates new abs angle based on eyeangles and other stuff
- player->UpdateClientAnimation();
- player->ClientAnimations(false);
- // restore
- player->m_iEFlags() = backup_eflags;
- g_pGlobalVars->curtime = curtime;
- g_pGlobalVars->frametime = frametime;
- player->InvalidateBoneCache();
- player->SetupBones(nullptr, -1, 0x7FF00, g_pGlobalVars->curtime);
- }
- }
- float GetDesync(C_BaseEntity* target)
- {
- auto* animstate = target->AnimState();
- float flRunningSpeed = clamp1(animstate->m_flFeetSpeedForwardsOrSideWays, 0.f, 1.f);
- float flYawModifier = ((animstate->m_flStopToFullRunningFraction * -0.3f) - 0.2f) * flRunningSpeed;
- float flYawModifier2 = flYawModifier + 1.f;
- if (animstate->m_fDuckAmount > 0.f)
- {
- float maxVelocity = clamp1(animstate->m_flFeetSpeedForwardsOrSideWays, 0.f, 1.f);
- float duckSpeed = animstate->m_fDuckAmount * maxVelocity;
- flYawModifier2 += (duckSpeed * (0.5f - flYawModifier2));
- }
- return *(float*)((uintptr_t)animstate + 0x334) * flYawModifier2;
- }
- template <class T>
- constexpr const T& Max(const T& x, const T& y)
- {
- return (x < y) ? y : x;
- }
- Vector TraceToEnd(Vector start, Vector end)
- {
- C_Trace trace;
- CTraceWorldOnly* filter;
- g_pTrace->TraceRay(C_Ray(start, end), mask_all, filter, &trace);
- return trace.end;
- }
- 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;
- }
- float AngleNormalize(float angle)
- {
- angle = fmodf(angle, 360.0f);
- if (angle > 180)
- {
- angle -= 360;
- }
- if (angle < -180)
- {
- angle += 360;
- }
- return angle;
- }
- void Resolver::AnimationFix(C_BaseEntity* entity, C_BaseEntity* pEnt)
- {
- auto v3 = Globals::LocalPlayer;
- if (v3 != entity)
- {
- auto animstate = entity->AnimState();
- if (animstate)
- {
- // missed shot <= 2
- if (Globals::MissedShots[entity->EntIndex()] <= 2)
- {
- float speed;
- if (*(float*)(animstate + 0xF8) < 0.f)
- {
- speed = 0.0;
- }
- else
- {
- speed = fminf(*(DWORD*)(animstate + 0xF8), 1.0f);
- }
- float flYawModifier = (*(float*)(animstate + 0x11C) * -0.30000001 - 0.19999999) * speed;
- flYawModifier += 1.0f;
- if (*(float*)(animstate + 0xA4) > 0.0 && *(float*)(animstate + 0xFC) >= 0.0)
- flYawModifier = fminf(*(float*)(uintptr_t(animstate) + 0xFC), 1.0f);
- float m_flMaxBodyYaw = *(float*)(uintptr_t(animstate) + 0x334) * flYawModifier;
- float m_flMinBodyYaw = *(float*)(uintptr_t(animstate) + 0x330) * flYawModifier;
- Resolver(pEnt);
- entity->UpdateClientAnimation();
- float ResolvedYaw = animstate->m_flEyeYaw;
- float delta = std::abs(animstate->m_flEyeYaw - animstate->m_flGoalFeetYaw);
- if (m_flMaxBodyYaw < delta)
- {
- ResolvedYaw = animstate->m_flEyeYaw - std::abs(m_flMaxBodyYaw);
- }
- else if (m_flMinBodyYaw > delta)
- {
- ResolvedYaw = animstate->m_flEyeYaw + std::abs(m_flMinBodyYaw);
- }
- animstate->m_flGoalFeetYaw = AngleNormalize(ResolvedYaw);
- }
- else
- {
- switch (Globals::MissedShots[entity->EntIndex()] % 4)
- {
- case 0:
- animstate->m_flGoalFeetYaw += 45.0f;
- break;
- case 1:
- animstate->m_flGoalFeetYaw -= 45.0f;
- break;
- case 2:
- animstate->m_flGoalFeetYaw -= 30.0f;
- break;
- case 3:
- animstate->m_flGoalFeetYaw += 30.0f;
- break;
- default:
- break;
- }
- }
- }
- }
- }
- void Resolver::Resolve(C_BaseEntity* pEnt, C_BaseEntity* pLocalEnt)
- {
- // i rly am just to lazy pls dont judge
- 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) // sorry had to anti pasta this basically the key to nospread
- * reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x110) = 0.f;
- bool update = false;
- if (storedSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
- {
- pEnt->ClientAnimations(false);
- 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 (g_Menu.Config.Resolver && !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) // who needs clamps
- 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;
- // if (fabs(g_Math.NormalizeYaw(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y)) < 60.f) // yea basically im retarded
- Equalized = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y + Resim);
- // else
- // Equalized = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Resim);
- if (!shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND))
- AnimState->m_flGoalFeetYaw = Equalized;
- }
- if (!shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam()) // 1337 pitch resolver
- {
- switch (Globals::MissedShots[pEnt->EntIndex()] % 3) // i skip case 0 on purpose noob
- {
- 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) // ez shot pitch fix LMAO
- 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));
- }
- void HandleBackUpResolve(C_BaseEntity* pEnt) {
- if (pEnt->GetTeam() == Globals::LocalPlayer->GetTeam())
- return;
- 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 += 45; break;
- case 1: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw -= 45; break;
- case 2: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw -= 30; break;
- case 3: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw += 30; break;
- }
- }
- else {
- float m_flLastClientSideAnimationUpdateTimeDelta = fabs(player_animation_state->m_iLastClientSideAnimationUpdateFramecount - player_animation_state->m_flLastClientSideAnimationUpdateTime);
- auto v48 = 0.f;
- if (player_animation_state->m_flFeetSpeedForwardsOrSideWays >= 0.0f)
- {
- v48 = fminf(player_animation_state->m_flFeetSpeedForwardsOrSideWays, 1.0f);
- }
- else
- {
- v48 = 0.0f;
- }
- float v49 = ((player_animation_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * v48;
- 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;
- }
- }
- float flMaxYawModifier = player_animation_state->pad10[516] * flYawModifier;
- float flMinYawModifier = player_animation_state->pad10[512] * flYawModifier;
- float newFeetYaw = 0.f;
- auto eyeYaw = player_animation_state->m_flEyeYaw;
- auto lbyYaw = player_animation_state->m_flGoalFeetYaw;
- float eye_feet_delta = fabs(eyeYaw - lbyYaw);
- 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;
- }
- player_animation_state->m_flGoalFeetYaw = v136;
- }
- }
- static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
- Vector delta = a - b;
- float delta_length = delta.Length();
- if (delta_length <= min_delta) {
- Vector result;
- if (-min_delta <= delta_length) {
- return a;
- }
- else {
- float iradius = 1.0f / (delta_length + FLT_EPSILON);
- return b - ((delta * iradius) * min_delta);
- }
- }
- else {
- float iradius = 1.0f / (delta_length + FLT_EPSILON);
- return b + ((delta * iradius) * min_delta);
- }
- };
- float Resolver::SetUpVelocity_rebuild(C_BaseEntity* e)
- {
- for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
- {
- auto e = static_cast<C_BaseEntity*>(g_pEntityList->GetClientEntity(i));
- // auto e = static_cast<SDK::CBaseEntity*>(INTERFACES::ClientEntityList->GetClientEntity(i));
- uintptr_t* move_server;
- auto speed_fraction_clamped = 0.f;
- auto v3 = e->AnimState();
- auto feet = -360.0;
- *reinterpret_cast<float*>((DWORD)v3 + 0x116 + 0x10) = *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10);
- auto v47 = *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10);
- auto v146 = -360.0;
- if (v47 >= -360.0)
- {
- feet = fminf(v47, 360.0);
- v146 = feet;
- }
- auto v48 = *reinterpret_cast<float*>((DWORD)v3 + 0x104 + 0x10) - feet;
- *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10) = feet;
- auto yaw = *reinterpret_cast<float*>((DWORD)v3 + 0x104 + 0x10);
- auto v155 = fmod(v48, 360.0);
- auto yaw_feet_delta = v155;
- if (yaw <= v146)
- {
- if (v155 <= -180.0)
- yaw_feet_delta = v155 + 360.0;
- }
- else if (v155 >= 180.0)
- {
- yaw_feet_delta = v155 - 360.0;
- }
- __asm mov move_server, ebp;
- auto speed_fraction = *reinterpret_cast<float*>((DWORD)v3 + 0x232 + 0x10);
- if (speed_fraction >= 0.0)
- speed_fraction_clamped = fminf(speed_fraction, 1.0);
- else
- speed_fraction_clamped = 0.0;
- auto duck_amount = *reinterpret_cast<float*>((DWORD)v3 + 0x94 + 0x10);
- auto v54 = (float)((float)((float)(*reinterpret_cast<float*>((DWORD)v3 + 0x114 + 0x10) * -0.30000001) - 0.19999999) * speed_fraction_clamped) + 1.0;
- if (duck_amount > 0.0)
- {
- auto v56 = -1.f;
- auto v55 = *(float*)(v3 + 236);
- if (v55 >= 0.0)
- v56 = fminf(v55, 1.0);
- else
- v56 = 0.0;
- v54 = v54 + (float)((float)(v56 * duck_amount) * (float)(0.5 - v54));
- }
- auto server_moved = *(bool*)(*move_server - 0x1C);
- auto max_rotation = *reinterpret_cast<float*>((DWORD)v3 + 0x2B4 + 0x10) * v54;
- auto inverted_max_rotation = *reinterpret_cast<float*>((DWORD)v3 + 0x2B0 + 0x10) * v54;
- if (yaw_feet_delta <= max_rotation)
- {
- if (inverted_max_rotation > yaw_feet_delta)
- * reinterpret_cast<float*>((DWORD)v3 + 0x70 + 0x10) = inverted_max_rotation + yaw;
- }
- else
- {
- *reinterpret_cast<float*>((DWORD)v3 + 0x70 + 0x10) = yaw - max_rotation;
- }
- auto goal_feet_yaw = fmod(*reinterpret_cast<float*>((DWORD)v3 + 0x70 + 0x10), 360.0);
- auto goal_feet_yaw_clamped = goal_feet_yaw;
- if (goal_feet_yaw > 180.0)
- goal_feet_yaw_clamped = goal_feet_yaw - 360.0;
- if (goal_feet_yaw_clamped < -180.0)
- goal_feet_yaw_clamped = goal_feet_yaw_clamped + 360.0;
- auto v60 = *reinterpret_cast<float*>((DWORD)v3 + 0x220 + 0x10);
- if (server_moved)
- {
- return *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10) = goal_feet_yaw_clamped;
- }
- }
- }
- #define clamp3(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
- void Resolver::ifkakof_brute(C_BaseEntity* player)
- {
- for (int i = 0; i < 65; i++)
- {
- auto e = g_pEntityList->GetClientEntity(i);
- if (!e)
- continue;
- PlayerInfo_t player_info;
- g_pEngine->GetPlayerInfo(e->EntIndex(), &player_info);
- int missed[65];
- int index = e->EntIndex();
- missed[e->EntIndex()] = Globals::Shot[e->EntIndex()] - Globals::Hit[index]; // getting missed shots
- auto animState = player->AnimState();
- //auto& resolverInfo = g_ResolverData[player->EntIndex()];
- // Rebuild setup velocity to receive flMinBodyYaw and flMaxBodyYaw
- Vector velocity = player->GetVelocity();
- auto direction = velocity.Angle();
- float spd = velocity.LengthSqr();
- if (spd > std::powf(1.2f * 260.0f, 2.f)) {
- Vector velocity_normalized = velocity.Normalize();
- velocity = velocity_normalized * (1.2f * 260.0f);
- }
- float v25 = clamp3(player->m_fDuckAmount() + animState->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
- float v26 = animState->m_fDuckAmount2;
- //float v27 = m_flChokedTime * 6.0f;
- float v28;
- // clamp
- float flDuckAmount = clamp3(v28, 0.0f, 1.0f);
- // Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, animState->m_velocity);
- float speed = std::fminf(velocity.Length(), 260.0f);
- auto weapon = player->GetActiveWeapon();
- float flMaxMovementSpeed = 260.0f;
- if (weapon) {
- // flMaxMovementSpeed = std::fmaxf(weapon->GetMaxSpeed(), 0.001f);
- }
- float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
- float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);
- flRunningSpeed = clamp3(flRunningSpeed, 0.0f, 1.0f);
- float flYawModifier = (((animState->m_bOnGround * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
- if (flDuckAmount > 0.0f) {
- float flDuckingSpeed = clamp3(flDuckingSpeed, 0.0f, 1.0f);
- flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
- }
- float m_flMaxBodyYaw = *(float*)(uintptr_t(animState) + 0x334) * flYawModifier;
- float m_flMinBodyYaw = *(float*)(uintptr_t(animState) + 0x330) * flYawModifier;
- float flMinBodyYaw = std::fabsf(m_flMinBodyYaw * flYawModifier);
- float flMaxBodyYaw = std::fabsf(m_flMaxBodyYaw * flYawModifier);
- float flEyeYaw = player->GetEyeAngles().y;
- float Left = flEyeYaw + flMinBodyYaw;
- float Right = flEyeYaw + flMaxBodyYaw;
- float resolveYaw;
- switch (missed[e->EntIndex()] % 3) {
- case 0: // brute left side
- resolveYaw = Left;
- break;
- case 1: // brute fake side
- resolveYaw = 180;
- break;
- case 2: // brute right side
- resolveYaw = Right;
- break;
- default:
- break;
- }
- animState->m_flGoalFeetYaw = resolveYaw;
- }
- }
- void HandleHits(C_BaseEntity* pEnt, C_BaseEntity* pLocalEnt)
- {
- auto NetChannel = g_pEngine->GetNetChannelInfo();
- if (!NetChannel)
- return;
- static float predTime[65];
- static bool init[65];
- static float StoredSimtime[65];
- static float SimDelta[65];
- if (StoredSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
- {
- SimDelta[pEnt->EntIndex()] = fabs(pEnt->GetSimulationTime() - StoredSimtime[pEnt->EntIndex()]);
- StoredSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
- }
- 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) + pLocalEnt->FireRate(); // maybe????
- 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 (!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* pEnt = g_pEntityList->GetClientEntity(i);
- if (!pEnt
- || !pEnt->IsAlive())
- continue;
- if (pEnt->IsDormant())
- {
- wasDormant[i] = true;
- continue;
- }
- if (stage == FRAME_NET_UPDATE_END && pEnt != Globals::LocalPlayer)
- {
- auto VarMap = reinterpret_cast<uintptr_t>(pEnt) + 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;
- }
- }
- /*(void Resolver::Bruteforce(C_BaseEntity* pEnt) {
- auto animstate = pEnt->AnimState();
- const auto player_animation_state = pEnt->AnimState();
- float newFeetYaw = 1.f;
- if (!player_animation_state)
- return;
- float v136 = fmod(newFeetYaw, 360.0);
- float v6 = 0;
- for (size_t i = 0; i < pEnt->GetNumAnimOverlays(); i++) // hi polak i hacked aimware
- {
- auto animLayer = pEnt->GetAnimOverlay4(i);
- if (!animLayer)
- continue;
- if (pEnt->GetSequenceActivity(animLayer->m_nSequence) == 979);
- auto v6 = pEnt->GetLowerBodyYaw();
- }
- int v19 = Globals::MissedShots[pEnt->EntIndex()] % 2; // p2c bruteforce
- switch (v19)
- {
- case 0:
- animstate->m_flGoalFeetYaw += 45.0f;
- break;
- case 1:
- animstate->m_flGoalFeetYaw -= 45.0f;
- break;
- case 2:
- animstate->m_flGoalFeetYaw -= 29.0f;
- break;
- case 3:
- animstate->m_flGoalFeetYaw += 29.0f;
- break;
- default:
- return;
- player_animation_state->m_flGoalFeetYaw = v136;
- }
- }*/
- void Backtrack(C_BaseEntity* pEnt, BackTrack BT, CUserCmd* pCmd)
- {
- if (!c_config::get().backtrack_enabled)
- return;
- if (!c_config::get().backtrack_ticks < 1)
- return;
- if (!Globals::pCmd->buttons & IN_ATTACK)
- return;
- float time = 0;
- int ticks = 0;
- switch (c_config::get().bt_type)
- {
- case 0: ticks = c_config::get().backtrack_ticks - 1; break;
- case 1: ticks = 0; break;
- }
- for (int tick = ticks; tick < c_config::get().backtrack_ticks; tick++)
- {
- g_Resolver.Angle[pEnt->EntIndex()] = pEnt->AnimState()->m_flGoalFeetYaw;
- g_Resolver.Origin[pEnt->EntIndex()] = pEnt->GetAbsOrigin();
- g_Resolver.Pitch[pEnt->EntIndex()] = pEnt->AnimState()->m_flPitch;
- time = BT.records[tick].tick_count;
- BT.Update(g_pGlobalVars->tickcount);
- g_pGlobalVars->tickcount = time;
- pCmd->tick_count = time;
- }
- pEnt->AnimState()->m_flGoalFeetYaw = g_Resolver.Angle[pEnt->EntIndex()];
- pEnt->SetAbsAngles(Vector(g_Resolver.Pitch[pEnt->EntIndex()], g_Resolver.Angle[pEnt->EntIndex()], 0));
- pEnt->SetAbsOrigin(g_Resolver.Origin[pEnt->EntIndex()]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement