SHARE
TWEET

faygo.baims

a guest Nov 15th, 2019 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Resolver.h"
  2. #include "..\Aimbot\Aimbot.h"
  3. #include "..\Aimbot\Autowall.h"
  4. #include "..\Aimbot\LagComp.h"
  5. #include "..\..\Utils\Utils.h"
  6. #include "..\..\SDK\IVEngineClient.h"
  7. #include "..\..\SDK\Hitboxes.h"
  8. #include "..\..\SDK\PlayerInfo.h"
  9. #include "..\..\Utils\Math.h"
  10. #include "..\..\Menu\Menu.h"
  11. #include "..\..\Menu\config.h"
  12. #include "../Legit Aimbot/Legit Aimbot.h"
  13. #include <random>
  14. Resolver g_Resolver;
  15.  
  16. /*
  17. my attempt at fixing desync and i was pretty successful
  18. it can resolve static desync pretty perfectly
  19. and can resolve some jitter desync but
  20. it still gets rekt by other things
  21. */
  22. #define clamp1(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
  23.  
  24. void Resolver::Log()
  25. {
  26.     for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  27.     {
  28.  
  29.         auto& record = arr_infos[i];
  30.  
  31.         C_BaseEntity* player = g_pEntityList->GetClientEntity(i);
  32.         if (!player || !player->IsAlive() || player->GetTeam() == Globals::LocalPlayer->GetTeam())
  33.         {
  34.             record.m_bActive = false;
  35.             continue;
  36.         }
  37.  
  38.         if (player->IsDormant())
  39.             continue;
  40.  
  41.         if (record.m_flSimulationTime == player->GetSimulationTime())
  42.             continue;
  43.  
  44.         record.SaveRecord(player);
  45.         record.m_bActive = true;
  46.     }
  47. }
  48.  
  49. void Resolver::UpdateAnimations(C_BaseEntity* player, C_AnimState* state)
  50. {
  51.     state = player->AnimState();
  52.     if (state)
  53.     {
  54.         // backup
  55.         const float curtime = g_pGlobalVars->curtime;
  56.         const float frametime = g_pGlobalVars->frametime;
  57.  
  58.         g_pGlobalVars->frametime = g_pGlobalVars->intervalPerTick;
  59.         g_pGlobalVars->curtime = player->GetSimulationTime();
  60.  
  61.         int backup_eflags = player->m_iEFlags();
  62.  
  63.         // SetLocalVelocity
  64.         player->m_iEFlags() &= ~0x1000; // InvalidatePhysicsRecursive(VELOCITY_CHANGED); EFL_DIRTY_ABSVELOCITY = 0x1000
  65.         player->m_vecAbsVelocity() = player->GetVelocity();
  66.  
  67.         // invalidates prior animations
  68.         if (state->m_iLastClientSideAnimationUpdateFramecount == g_pGlobalVars->framecount)
  69.             state->m_iLastClientSideAnimationUpdateFramecount = g_pGlobalVars->framecount - 1;
  70.  
  71.         player->ClientAnimations(true);
  72.  
  73.         // updates local animations + poses + calculates new abs angle based on eyeangles and other stuff
  74.         player->UpdateClientAnimation();
  75.  
  76.         player->ClientAnimations(false);
  77.  
  78.         // restore
  79.         player->m_iEFlags() = backup_eflags;
  80.  
  81.         g_pGlobalVars->curtime = curtime;
  82.         g_pGlobalVars->frametime = frametime;
  83.  
  84.         player->InvalidateBoneCache();
  85.         player->SetupBones(nullptr, -1, 0x7FF00, g_pGlobalVars->curtime);
  86.     }
  87. }
  88.  
  89. float GetDesync(C_BaseEntity* target)
  90. {
  91.  
  92.     auto* animstate = target->AnimState();
  93.     float flRunningSpeed = clamp1(animstate->m_flFeetSpeedForwardsOrSideWays, 0.f, 1.f);
  94.     float flYawModifier = ((animstate->m_flStopToFullRunningFraction * -0.3f) - 0.2f) * flRunningSpeed;
  95.     float flYawModifier2 = flYawModifier + 1.f;
  96.  
  97.     if (animstate->m_fDuckAmount > 0.f)
  98.     {
  99.         float maxVelocity = clamp1(animstate->m_flFeetSpeedForwardsOrSideWays, 0.f, 1.f);
  100.         float duckSpeed = animstate->m_fDuckAmount * maxVelocity;
  101.         flYawModifier2 += (duckSpeed * (0.5f - flYawModifier2));
  102.     }
  103.  
  104.     return *(float*)((uintptr_t)animstate + 0x334) * flYawModifier2;
  105. }
  106.  
  107.  
  108. template <class T>
  109. constexpr const T& Max(const T& x, const T& y)
  110. {
  111.     return (x < y) ? y : x;
  112. }
  113.  
  114. Vector TraceToEnd(Vector start, Vector end)
  115. {
  116.     C_Trace trace;
  117.     CTraceWorldOnly* filter;
  118.  
  119.     g_pTrace->TraceRay(C_Ray(start, end), mask_all, filter, &trace);
  120.  
  121.     return trace.end;
  122. }
  123.  
  124. float flAngleMod(float flAngle)
  125. {
  126.     return((360.0f / 65536.0f) * ((int32_t)(flAngle * (65536.0f / 360.0f)) & 65535));
  127. }
  128.  
  129. float ApproachAngle(float target, float value, float speed)
  130. {
  131.     target = flAngleMod(target);
  132.     value = flAngleMod(value);
  133.  
  134.     float delta = target - value;
  135.  
  136.     // Speed is assumed to be positive
  137.     if (speed < 0)
  138.         speed = -speed;
  139.  
  140.     if (delta < -180)
  141.         delta += 360;
  142.     else if (delta > 180)
  143.         delta -= 360;
  144.  
  145.     if (delta > speed)
  146.         value += speed;
  147.     else if (delta < -speed)
  148.         value -= speed;
  149.     else
  150.         value = target;
  151.  
  152.     return value;
  153. }
  154.  
  155. float AngleNormalize(float angle)
  156. {
  157.     angle = fmodf(angle, 360.0f);
  158.     if (angle > 180)
  159.     {
  160.         angle -= 360;
  161.     }
  162.     if (angle < -180)
  163.     {
  164.         angle += 360;
  165.     }
  166.     return angle;
  167. }
  168.  
  169. void Resolver::AnimationFix(C_BaseEntity* entity, C_BaseEntity* pEnt)
  170. {
  171.     auto v3 = Globals::LocalPlayer;
  172.     if (v3 != entity)
  173.     {
  174.         auto animstate = entity->AnimState();
  175.         if (animstate)
  176.         {
  177.             // missed shot <= 2
  178.             if (Globals::MissedShots[entity->EntIndex()] <= 2)
  179.             {
  180.                 float speed;
  181.                 if (*(float*)(animstate + 0xF8) < 0.f)
  182.                 {
  183.                     speed = 0.0;
  184.                 }
  185.                 else
  186.                 {
  187.                     speed = fminf(*(DWORD*)(animstate + 0xF8), 1.0f);
  188.                 }
  189.  
  190.                 float flYawModifier = (*(float*)(animstate + 0x11C) * -0.30000001 - 0.19999999) * speed;
  191.                 flYawModifier += 1.0f;
  192.  
  193.                 if (*(float*)(animstate + 0xA4) > 0.0 && *(float*)(animstate + 0xFC) >= 0.0)
  194.                     flYawModifier = fminf(*(float*)(uintptr_t(animstate) + 0xFC), 1.0f);
  195.  
  196.                 float m_flMaxBodyYaw = *(float*)(uintptr_t(animstate) + 0x334) * flYawModifier;
  197.                 float m_flMinBodyYaw = *(float*)(uintptr_t(animstate) + 0x330) * flYawModifier;
  198.                 Resolver(pEnt);
  199.                 entity->UpdateClientAnimation();
  200.                 float ResolvedYaw = animstate->m_flEyeYaw;
  201.                 float delta = std::abs(animstate->m_flEyeYaw - animstate->m_flGoalFeetYaw);
  202.                 if (m_flMaxBodyYaw < delta)
  203.                 {
  204.                     ResolvedYaw = animstate->m_flEyeYaw - std::abs(m_flMaxBodyYaw);
  205.                 }
  206.                 else if (m_flMinBodyYaw > delta)
  207.                 {
  208.                     ResolvedYaw = animstate->m_flEyeYaw + std::abs(m_flMinBodyYaw);
  209.                 }
  210.                 animstate->m_flGoalFeetYaw = AngleNormalize(ResolvedYaw);
  211.             }
  212.             else
  213.             {
  214.                 switch (Globals::MissedShots[entity->EntIndex()] % 4)
  215.                 {
  216.                 case 0:
  217.                     animstate->m_flGoalFeetYaw += 45.0f;
  218.                     break;
  219.                 case 1:
  220.                     animstate->m_flGoalFeetYaw -= 45.0f;
  221.                     break;
  222.                 case 2:
  223.                     animstate->m_flGoalFeetYaw -= 30.0f;
  224.                     break;
  225.                 case 3:
  226.                     animstate->m_flGoalFeetYaw += 30.0f;
  227.                     break;
  228.                 default:
  229.                     break;
  230.                 }
  231.             }
  232.         }
  233.     }
  234. }
  235.  
  236. void Resolver::Resolve(C_BaseEntity* pEnt, C_BaseEntity* pLocalEnt)
  237. {
  238.  
  239.     // i rly am just to lazy pls dont judge
  240.     static float ShotTime[65];
  241.  
  242.     static float oldSimtime[65];
  243.     static float storedSimtime[65];
  244.  
  245.     static Vector oldEyeAngles[65];
  246.     static float oldGoalfeetYaw[65];
  247.     static Vector oldOrigin[65];
  248.  
  249.     float* PosParams = reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(pEnt) + 0x2774);
  250.     bool shot = false;
  251.  
  252.     auto* AnimState = pEnt->AnimState();
  253.     if (!AnimState || !pEnt->AnimOverlays() || !PosParams)
  254.         return;
  255.  
  256.     if (*reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x164) < 0) // sorry had to anti pasta this basically the key to nospread
  257.         * reinterpret_cast<float*>(reinterpret_cast<uintptr_t>(AnimState) + 0x110) = 0.f;
  258.  
  259.     bool update = false;
  260.  
  261.     if (storedSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
  262.     {
  263.         pEnt->ClientAnimations(false);
  264.         pEnt->UpdateClientAnimation();
  265.         pEnt->ClientAnimations(false);
  266.  
  267.         update = true;
  268.     }
  269.  
  270.     oldGoalfeetYaw[pEnt->EntIndex()] = AnimState->m_flGoalFeetYaw;
  271.  
  272.     if (pEnt->GetActiveWeapon() && !pEnt->IsKnifeorNade())
  273.     {
  274.         if (ShotTime[pEnt->EntIndex()] != pEnt->GetActiveWeapon()->GetLastShotTime())
  275.         {
  276.             shot = true;
  277.             ShotTime[pEnt->EntIndex()] = pEnt->GetActiveWeapon()->GetLastShotTime();
  278.         }
  279.         else
  280.             shot = false;
  281.     }
  282.     else
  283.     {
  284.         shot = false;
  285.         ShotTime[pEnt->EntIndex()] = 0.f;
  286.     }
  287.  
  288.     if (pLocalEnt && pLocalEnt->IsAlive())
  289.     {
  290.         float angToLocal = g_Math.NormalizeYaw(g_Math.CalcAngle(pLocalEnt->GetOrigin(), pEnt->GetOrigin()).y);
  291.  
  292.         float Back = g_Math.NormalizeYaw(angToLocal);
  293.         float DesyncFix = 0;
  294.  
  295.         float Resim = g_Math.NormalizeYaw((TICKS_TO_TIME(16) / (pEnt->GetSimulationTime() - oldSimtime[pEnt->EntIndex()])) * g_Math.NormalizeYaw(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y));
  296.  
  297.         if (Resim > 60.f)
  298.             Resim = 60.f;
  299.         if (Resim < -60.f)
  300.             Resim = -60.f;
  301.  
  302.         if (g_Menu.Config.Resolver && !shot && !isnan(angToLocal) && !isinf(angToLocal) && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam())
  303.         {
  304.             float AntiSide = 0.f;
  305.  
  306.             if (Globals::MissedShots[pEnt->EntIndex()] % 2)
  307.             {
  308.                 if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Back) > 0.f)
  309.                     AntiSide = -90.f;
  310.                 else if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Back) < 0.f)
  311.                     AntiSide = 90.f;
  312.             }
  313.             else
  314.             {
  315.                 if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - g_Math.NormalizeYaw(Back + 90)) > 0.f)
  316.                     AntiSide = 180.f;
  317.                 else if (g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - g_Math.NormalizeYaw(Back + 90)) < 0.f)
  318.                     AntiSide = 0.f;
  319.             }
  320.  
  321.             float Brute = g_Math.NormalizeYaw(Back + AntiSide);
  322.             float Delta = g_Math.NormalizeYaw(g_Math.NormalizeYaw(Brute - pEnt->GetEyeAngles().y) + Resim);
  323.  
  324.             if (Delta > 60.f) // who needs clamps
  325.                 Delta = 60.f;
  326.             if (Delta < -60.f)
  327.                 Delta = -60.f;
  328.  
  329.             Resim += Delta;
  330.             DesyncFix += Delta;
  331.  
  332.             if (Resim > 60.f)
  333.                 Resim = 60.f;
  334.             if (Resim < -60.f)
  335.                 Resim = -60.f;
  336.         }
  337.  
  338.         float Equalized;
  339.  
  340.         //  if (fabs(g_Math.NormalizeYaw(oldEyeAngles[pEnt->EntIndex()].y - pEnt->GetEyeAngles().y)) < 60.f) // yea basically im retarded
  341.         Equalized = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y + Resim);
  342.         //  else
  343.         //      Equalized = g_Math.NormalizeYaw(pEnt->GetEyeAngles().y - Resim);
  344.  
  345.         if (!shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && (pEnt->GetFlags() & FL_ONGROUND))
  346.             AnimState->m_flGoalFeetYaw = Equalized;
  347.     }
  348.  
  349.     if (!shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam()) // 1337 pitch resolver
  350.     {
  351.         switch (Globals::MissedShots[pEnt->EntIndex()] % 3) // i skip case 0 on purpose noob
  352.         {
  353.         case 1:PosParams[12] = 89.f; break;
  354.         case 2:PosParams[12] = -89.f; break;
  355.         }
  356.     }
  357.  
  358.     if (shot && pEnt != pLocalEnt && pEnt->GetTeam() != pLocalEnt->GetTeam() && PosParams[12] <= -80) // ez shot pitch fix LMAO
  359.         PosParams[12] = 89.f;
  360.  
  361.     if (update)
  362.     {
  363.         oldEyeAngles[pEnt->EntIndex()] = pEnt->GetEyeAngles();
  364.         oldSimtime[pEnt->EntIndex()] = storedSimtime[pEnt->EntIndex()];
  365.         storedSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
  366.         oldOrigin[pEnt->EntIndex()] = pEnt->GetOrigin();
  367.     }
  368.  
  369.     pEnt->SetAbsAngles(Vector(0, oldGoalfeetYaw[pEnt->EntIndex()], 0));
  370. }
  371.  
  372.  
  373. void HandleBackUpResolve(C_BaseEntity* pEnt) {
  374.  
  375.     if (pEnt->GetTeam() == Globals::LocalPlayer->GetTeam())
  376.         return;
  377.  
  378.     const auto player_animation_state = pEnt->AnimState();
  379.  
  380.     if (!player_animation_state)
  381.         return;
  382.  
  383.     if (Globals::MissedShots[pEnt->EntIndex()] > 2) {
  384.         switch (Globals::MissedShots[pEnt->EntIndex()] % 4) {
  385.         case 0: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw += 45; break;
  386.         case 1: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw -= 45; break;
  387.         case 2: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw -= 30; break;
  388.         case 3: player_animation_state->m_flGoalFeetYaw = player_animation_state->m_flGoalFeetYaw += 30; break;
  389.         }
  390.     }
  391.     else {
  392.  
  393.         float m_flLastClientSideAnimationUpdateTimeDelta = fabs(player_animation_state->m_iLastClientSideAnimationUpdateFramecount - player_animation_state->m_flLastClientSideAnimationUpdateTime);
  394.  
  395.         auto v48 = 0.f;
  396.  
  397.         if (player_animation_state->m_flFeetSpeedForwardsOrSideWays >= 0.0f)
  398.         {
  399.             v48 = fminf(player_animation_state->m_flFeetSpeedForwardsOrSideWays, 1.0f);
  400.         }
  401.         else
  402.         {
  403.             v48 = 0.0f;
  404.         }
  405.  
  406.         float v49 = ((player_animation_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * v48;
  407.  
  408.         float flYawModifier = v49 + 1.0;
  409.  
  410.         if (player_animation_state->m_fDuckAmount > 0.0)
  411.         {
  412.             float v53 = 0.0f;
  413.  
  414.             if (player_animation_state->m_flFeetSpeedUnknownForwardOrSideways >= 0.0)
  415.             {
  416.                 v53 = fminf(player_animation_state->m_flFeetSpeedUnknownForwardOrSideways, 1.0);
  417.             }
  418.             else
  419.             {
  420.                 v53 = 0.0f;
  421.             }
  422.         }
  423.  
  424.         float flMaxYawModifier = player_animation_state->pad10[516] * flYawModifier;
  425.         float flMinYawModifier = player_animation_state->pad10[512] * flYawModifier;
  426.  
  427.         float newFeetYaw = 0.f;
  428.  
  429.         auto eyeYaw = player_animation_state->m_flEyeYaw;
  430.  
  431.         auto lbyYaw = player_animation_state->m_flGoalFeetYaw;
  432.  
  433.         float eye_feet_delta = fabs(eyeYaw - lbyYaw);
  434.  
  435.         if (eye_feet_delta <= flMaxYawModifier)
  436.         {
  437.             if (flMinYawModifier > eye_feet_delta)
  438.             {
  439.                 newFeetYaw = fabs(flMinYawModifier) + eyeYaw;
  440.             }
  441.         }
  442.         else
  443.         {
  444.             newFeetYaw = eyeYaw - fabs(flMaxYawModifier);
  445.         }
  446.  
  447.         float v136 = fmod(newFeetYaw, 360.0);
  448.  
  449.         if (v136 > 180.0)
  450.         {
  451.             v136 = v136 - 360.0;
  452.         }
  453.  
  454.         if (v136 < 180.0)
  455.         {
  456.             v136 = v136 + 360.0;
  457.         }
  458.  
  459.         player_animation_state->m_flGoalFeetYaw = v136;
  460.     }
  461. }
  462.  
  463. static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
  464.     Vector delta = a - b;
  465.     float delta_length = delta.Length();
  466.  
  467.     if (delta_length <= min_delta) {
  468.         Vector result;
  469.         if (-min_delta <= delta_length) {
  470.             return a;
  471.         }
  472.         else {
  473.             float iradius = 1.0f / (delta_length + FLT_EPSILON);
  474.             return b - ((delta * iradius) * min_delta);
  475.         }
  476.     }
  477.     else {
  478.         float iradius = 1.0f / (delta_length + FLT_EPSILON);
  479.         return b + ((delta * iradius) * min_delta);
  480.     }
  481. };
  482.  
  483. float Resolver::SetUpVelocity_rebuild(C_BaseEntity* e)
  484. {
  485.     for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  486.     {
  487.         auto e = static_cast<C_BaseEntity*>(g_pEntityList->GetClientEntity(i));
  488.         //  auto e = static_cast<SDK::CBaseEntity*>(INTERFACES::ClientEntityList->GetClientEntity(i));
  489.         uintptr_t* move_server;
  490.         auto speed_fraction_clamped = 0.f;
  491.         auto v3 = e->AnimState();
  492.         auto feet = -360.0;
  493.         *reinterpret_cast<float*>((DWORD)v3 + 0x116 + 0x10) = *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10);
  494.         auto v47 = *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10);
  495.         auto v146 = -360.0;
  496.         if (v47 >= -360.0)
  497.         {
  498.             feet = fminf(v47, 360.0);
  499.             v146 = feet;
  500.         }
  501.         auto v48 = *reinterpret_cast<float*>((DWORD)v3 + 0x104 + 0x10) - feet;
  502.         *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10) = feet;
  503.         auto yaw = *reinterpret_cast<float*>((DWORD)v3 + 0x104 + 0x10);
  504.         auto v155 = fmod(v48, 360.0);
  505.         auto yaw_feet_delta = v155;
  506.         if (yaw <= v146)
  507.         {
  508.             if (v155 <= -180.0)
  509.                 yaw_feet_delta = v155 + 360.0;
  510.         }
  511.         else if (v155 >= 180.0)
  512.         {
  513.             yaw_feet_delta = v155 - 360.0;
  514.         }
  515.         __asm mov move_server, ebp;
  516.         auto speed_fraction = *reinterpret_cast<float*>((DWORD)v3 + 0x232 + 0x10);
  517.         if (speed_fraction >= 0.0)
  518.             speed_fraction_clamped = fminf(speed_fraction, 1.0);
  519.         else
  520.             speed_fraction_clamped = 0.0;
  521.         auto duck_amount = *reinterpret_cast<float*>((DWORD)v3 + 0x94 + 0x10);
  522.         auto v54 = (float)((float)((float)(*reinterpret_cast<float*>((DWORD)v3 + 0x114 + 0x10) * -0.30000001) - 0.19999999) * speed_fraction_clamped) + 1.0;
  523.         if (duck_amount > 0.0)
  524.         {
  525.             auto v56 = -1.f;
  526.             auto v55 = *(float*)(v3 + 236);
  527.             if (v55 >= 0.0)
  528.                 v56 = fminf(v55, 1.0);
  529.             else
  530.                 v56 = 0.0;
  531.             v54 = v54 + (float)((float)(v56 * duck_amount) * (float)(0.5 - v54));
  532.         }
  533.         auto server_moved = *(bool*)(*move_server - 0x1C);
  534.         auto max_rotation = *reinterpret_cast<float*>((DWORD)v3 + 0x2B4 + 0x10) * v54;
  535.         auto inverted_max_rotation = *reinterpret_cast<float*>((DWORD)v3 + 0x2B0 + 0x10) * v54;
  536.         if (yaw_feet_delta <= max_rotation)
  537.         {
  538.             if (inverted_max_rotation > yaw_feet_delta)
  539.                 * reinterpret_cast<float*>((DWORD)v3 + 0x70 + 0x10) = inverted_max_rotation + yaw;
  540.         }
  541.         else
  542.         {
  543.             *reinterpret_cast<float*>((DWORD)v3 + 0x70 + 0x10) = yaw - max_rotation;
  544.         }
  545.         auto goal_feet_yaw = fmod(*reinterpret_cast<float*>((DWORD)v3 + 0x70 + 0x10), 360.0);
  546.         auto goal_feet_yaw_clamped = goal_feet_yaw;
  547.         if (goal_feet_yaw > 180.0)
  548.             goal_feet_yaw_clamped = goal_feet_yaw - 360.0;
  549.         if (goal_feet_yaw_clamped < -180.0)
  550.             goal_feet_yaw_clamped = goal_feet_yaw_clamped + 360.0;
  551.         auto v60 = *reinterpret_cast<float*>((DWORD)v3 + 0x220 + 0x10);
  552.         if (server_moved)
  553.         {
  554.             return  *reinterpret_cast<float*>((DWORD)v3 + 0x112 + 0x10) = goal_feet_yaw_clamped;
  555.         }
  556.     }
  557. }
  558. #define clamp3(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
  559.  
  560. void Resolver::ifkakof_brute(C_BaseEntity* player)
  561. {
  562.     for (int i = 0; i < 65; i++)
  563.     {
  564.         auto e = g_pEntityList->GetClientEntity(i);
  565.  
  566.         if (!e)
  567.             continue;
  568.  
  569.         PlayerInfo_t player_info;
  570.         g_pEngine->GetPlayerInfo(e->EntIndex(), &player_info);
  571.         int missed[65];
  572.         int index = e->EntIndex();
  573.         missed[e->EntIndex()] = Globals::Shot[e->EntIndex()] - Globals::Hit[index]; // getting missed shots
  574.  
  575.         auto animState = player->AnimState();
  576.         //auto& resolverInfo = g_ResolverData[player->EntIndex()];
  577.         // Rebuild setup velocity to receive flMinBodyYaw and flMaxBodyYaw
  578.         Vector velocity = player->GetVelocity();
  579.         auto direction = velocity.Angle();
  580.         float spd = velocity.LengthSqr();
  581.         if (spd > std::powf(1.2f * 260.0f, 2.f)) {
  582.             Vector velocity_normalized = velocity.Normalize();
  583.             velocity = velocity_normalized * (1.2f * 260.0f);
  584.         }
  585.  
  586.         float v25 = clamp3(player->m_fDuckAmount() + animState->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
  587.         float v26 = animState->m_fDuckAmount2;
  588.         //float v27 = m_flChokedTime * 6.0f;
  589.         float v28;
  590.  
  591.         // clamp
  592.  
  593.  
  594.         float flDuckAmount = clamp3(v28, 0.0f, 1.0f);
  595.  
  596.         //  Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, animState->m_velocity);
  597.         float speed = std::fminf(velocity.Length(), 260.0f);
  598.  
  599.         auto weapon = player->GetActiveWeapon();
  600.  
  601.         float flMaxMovementSpeed = 260.0f;
  602.         if (weapon) {
  603.             //  flMaxMovementSpeed = std::fmaxf(weapon->GetMaxSpeed(), 0.001f);
  604.         }
  605.  
  606.         float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
  607.         float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);
  608.  
  609.         flRunningSpeed = clamp3(flRunningSpeed, 0.0f, 1.0f);
  610.  
  611.         float flYawModifier = (((animState->m_bOnGround * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
  612.         if (flDuckAmount > 0.0f) {
  613.             float flDuckingSpeed = clamp3(flDuckingSpeed, 0.0f, 1.0f);
  614.             flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
  615.         }
  616.  
  617.         float m_flMaxBodyYaw = *(float*)(uintptr_t(animState) + 0x334) * flYawModifier;
  618.         float m_flMinBodyYaw = *(float*)(uintptr_t(animState) + 0x330) * flYawModifier;
  619.  
  620.         float flMinBodyYaw = std::fabsf(m_flMinBodyYaw * flYawModifier);
  621.         float flMaxBodyYaw = std::fabsf(m_flMaxBodyYaw * flYawModifier);
  622.  
  623.         float flEyeYaw = player->GetEyeAngles().y;
  624.  
  625.         float Left = flEyeYaw + flMinBodyYaw;
  626.         float Right = flEyeYaw + flMaxBodyYaw;
  627.  
  628.         float resolveYaw;
  629.  
  630.         switch (missed[e->EntIndex()] % 3) {
  631.         case 0: // brute left side
  632.             resolveYaw = Left;
  633.             break;
  634.         case 1: // brute fake side
  635.             resolveYaw = 180;
  636.             break;
  637.         case 2: // brute right side
  638.             resolveYaw = Right;
  639.             break;
  640.         default:
  641.             break;
  642.         }
  643.  
  644.         animState->m_flGoalFeetYaw = resolveYaw;
  645.     }
  646. }
  647.  
  648. void HandleHits(C_BaseEntity* pEnt, C_BaseEntity* pLocalEnt)
  649. {
  650.  
  651.     auto NetChannel = g_pEngine->GetNetChannelInfo();
  652.  
  653.     if (!NetChannel)
  654.         return;
  655.  
  656.     static float predTime[65];
  657.     static bool init[65];
  658.  
  659.     static float StoredSimtime[65];
  660.     static float SimDelta[65];
  661.  
  662.     if (StoredSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
  663.     {
  664.         SimDelta[pEnt->EntIndex()] = fabs(pEnt->GetSimulationTime() - StoredSimtime[pEnt->EntIndex()]);
  665.         StoredSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
  666.     }
  667.  
  668.     if (Globals::Shot[pEnt->EntIndex()])
  669.     {
  670.         if (init[pEnt->EntIndex()])
  671.         {
  672.             g_Resolver.pitchHit[pEnt->EntIndex()] = pEnt->GetEyeAngles().x;
  673.             predTime[pEnt->EntIndex()] = g_pGlobalVars->curtime + NetChannel->GetAvgLatency(FLOW_INCOMING) + pLocalEnt->FireRate();  // maybe????
  674.             init[pEnt->EntIndex()] = false;
  675.         }
  676.  
  677.         if (g_pGlobalVars->curtime > predTime[pEnt->EntIndex()] && !Globals::Hit[pEnt->EntIndex()])
  678.         {
  679.             Globals::MissedShots[pEnt->EntIndex()] += 1;
  680.             Globals::Shot[pEnt->EntIndex()] = false;
  681.         }
  682.         else if (g_pGlobalVars->curtime <= predTime[pEnt->EntIndex()] && Globals::Hit[pEnt->EntIndex()])
  683.             Globals::Shot[pEnt->EntIndex()] = false;
  684.  
  685.     }
  686.     else
  687.         init[pEnt->EntIndex()] = true;
  688.  
  689.     Globals::Hit[pEnt->EntIndex()] = false;
  690. }
  691.  
  692. void Resolver::OnCreateMove() // cancer v2
  693. {
  694.     if (!Globals::LocalPlayer->IsAlive())
  695.         return;
  696.  
  697.     if (!Globals::LocalPlayer->GetActiveWeapon() || Globals::LocalPlayer->IsKnifeorNade())
  698.         return;
  699.  
  700.  
  701.     for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  702.     {
  703.         C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  704.  
  705.         if (!pPlayerEntity
  706.             || !pPlayerEntity->IsAlive()
  707.             || pPlayerEntity->IsDormant()
  708.             || pPlayerEntity == Globals::LocalPlayer
  709.             || pPlayerEntity->GetTeam() == Globals::LocalPlayer->GetTeam())
  710.         {
  711.             UseFreestandAngle[i] = false;
  712.             continue;
  713.         }
  714.  
  715.         if (abs(pPlayerEntity->GetVelocity().Length2D()) > 29.f)
  716.             UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
  717.  
  718.         if (abs(pPlayerEntity->GetVelocity().Length2D()) <= 29.f && !UseFreestandAngle[pPlayerEntity->EntIndex()])
  719.         {
  720.             bool Autowalled = false, HitSide1 = false, HitSide2 = false;
  721.  
  722.             float angToLocal = g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
  723.             Vector ViewPoint = Globals::LocalPlayer->GetOrigin() + Vector(0, 0, 90);
  724.  
  725.             Vector2D Side1 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal))),(45 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  726.             Vector2D Side2 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  727.  
  728.             Vector2D Side3 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal))),(50 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  729.             Vector2D Side4 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  730.  
  731.             Vector Origin = pPlayerEntity->GetOrigin();
  732.  
  733.             Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
  734.  
  735.             Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
  736.  
  737.             for (int side = 0; side < 2; side++)
  738.             {
  739.                 Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x,  Origin.y - OriginLeftRight[side].y , Origin.z + 90 };
  740.                 Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x,  ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
  741.  
  742.                 if (g_Autowall.CanHitFloatingPoint(OriginAutowall, ViewPoint))
  743.                 {
  744.                     if (side == 0)
  745.                     {
  746.                         HitSide1 = true;
  747.                         FreestandAngle[pPlayerEntity->EntIndex()] = 90;
  748.                     }
  749.                     else if (side == 1)
  750.                     {
  751.                         HitSide2 = true;
  752.                         FreestandAngle[pPlayerEntity->EntIndex()] = -90;
  753.                     }
  754.  
  755.                     Autowalled = true;
  756.                 }
  757.                 else
  758.                 {
  759.                     for (int side222 = 0; side222 < 2; side222++)
  760.                     {
  761.                         Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x,  Origin.y - OriginLeftRight[side222].y , Origin.z + 90 };
  762.  
  763.                         if (g_Autowall.CanHitFloatingPoint(OriginAutowall222, OriginAutowall2))
  764.                         {
  765.                             if (side222 == 0)
  766.                             {
  767.                                 HitSide1 = true;
  768.                                 FreestandAngle[pPlayerEntity->EntIndex()] = 90;
  769.                             }
  770.                             else if (side222 == 1)
  771.                             {
  772.                                 HitSide2 = true;
  773.                                 FreestandAngle[pPlayerEntity->EntIndex()] = -90;
  774.                             }
  775.  
  776.                             Autowalled = true;
  777.                         }
  778.                     }
  779.                 }
  780.             }
  781.  
  782.             if (Autowalled)
  783.             {
  784.                 if (HitSide1 && HitSide2)
  785.                     UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
  786.                 else
  787.                     UseFreestandAngle[pPlayerEntity->EntIndex()] = true;
  788.             }
  789.         }
  790.     }
  791. }
  792.  
  793.  
  794. void Resolver::FrameStage(ClientFrameStage_t stage)
  795. {
  796.     if (!Globals::LocalPlayer || !g_pEngine->IsInGame())
  797.         return;
  798.  
  799.     static bool  wasDormant[65];
  800.  
  801.     for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  802.     {
  803.         C_BaseEntity* pEnt = g_pEntityList->GetClientEntity(i);
  804.  
  805.         if (!pEnt
  806.             || !pEnt->IsAlive())
  807.             continue;
  808.         if (pEnt->IsDormant())
  809.         {
  810.             wasDormant[i] = true;
  811.             continue;
  812.         }
  813.  
  814.         if (stage == FRAME_NET_UPDATE_END && pEnt != Globals::LocalPlayer)
  815.         {
  816.             auto VarMap = reinterpret_cast<uintptr_t>(pEnt) + 36;
  817.             auto VarMapSize = *reinterpret_cast<int*>(VarMap + 20);
  818.  
  819.             for (auto index = 0; index < VarMapSize; index++)
  820.                 * reinterpret_cast<uintptr_t*>(*reinterpret_cast<uintptr_t*>(VarMap) + index * 12) = 0;
  821.         }
  822.  
  823.         wasDormant[i] = false;
  824.     }
  825. }
  826.  
  827. /*(void Resolver::Bruteforce(C_BaseEntity* pEnt) {
  828.  
  829.     auto animstate = pEnt->AnimState();
  830.  
  831.     const auto player_animation_state = pEnt->AnimState();
  832.  
  833.     float newFeetYaw = 1.f;
  834.  
  835.  
  836.     if (!player_animation_state)
  837.         return;
  838.  
  839.  
  840.     float v136 = fmod(newFeetYaw, 360.0);
  841.  
  842.  
  843.     float v6 = 0;
  844.     for (size_t i = 0; i < pEnt->GetNumAnimOverlays(); i++) // hi polak i hacked aimware
  845.     {
  846.         auto animLayer = pEnt->GetAnimOverlay4(i);
  847.         if (!animLayer)
  848.             continue;
  849.         if (pEnt->GetSequenceActivity(animLayer->m_nSequence) == 979);
  850.         auto v6 = pEnt->GetLowerBodyYaw();
  851.     }
  852.  
  853.     int v19 = Globals::MissedShots[pEnt->EntIndex()] % 2; // p2c bruteforce
  854.     switch (v19)
  855.     {
  856.     case 0:
  857.         animstate->m_flGoalFeetYaw += 45.0f;
  858.         break;
  859.     case 1:
  860.         animstate->m_flGoalFeetYaw -= 45.0f;
  861.         break;
  862.     case 2:
  863.         animstate->m_flGoalFeetYaw -= 29.0f;
  864.         break;
  865.     case 3:
  866.         animstate->m_flGoalFeetYaw += 29.0f;
  867.         break;
  868.     default:
  869.         return;
  870.  
  871.         player_animation_state->m_flGoalFeetYaw = v136;
  872.     }
  873. }*/
  874.  
  875. void Backtrack(C_BaseEntity* pEnt, BackTrack BT, CUserCmd* pCmd)
  876. {
  877.     if (!c_config::get().backtrack_enabled)
  878.         return;
  879.  
  880.     if (!c_config::get().backtrack_ticks < 1)
  881.         return;
  882.  
  883.     if (!Globals::pCmd->buttons & IN_ATTACK)
  884.         return;
  885.  
  886.     float time = 0;
  887.     int ticks = 0;
  888.     switch (c_config::get().bt_type)
  889.     {
  890.     case 0: ticks = c_config::get().backtrack_ticks - 1; break;
  891.     case 1: ticks = 0; break;
  892.     }
  893.     for (int tick = ticks; tick < c_config::get().backtrack_ticks; tick++)
  894.     {
  895.         g_Resolver.Angle[pEnt->EntIndex()] = pEnt->AnimState()->m_flGoalFeetYaw;
  896.         g_Resolver.Origin[pEnt->EntIndex()] = pEnt->GetAbsOrigin();
  897.         g_Resolver.Pitch[pEnt->EntIndex()] = pEnt->AnimState()->m_flPitch;
  898.         time = BT.records[tick].tick_count;
  899.         BT.Update(g_pGlobalVars->tickcount);
  900.         g_pGlobalVars->tickcount = time;
  901.         pCmd->tick_count = time;
  902.     }
  903.     pEnt->AnimState()->m_flGoalFeetYaw = g_Resolver.Angle[pEnt->EntIndex()];
  904.     pEnt->SetAbsAngles(Vector(g_Resolver.Pitch[pEnt->EntIndex()], g_Resolver.Angle[pEnt->EntIndex()], 0));
  905.     pEnt->SetAbsOrigin(g_Resolver.Origin[pEnt->EntIndex()]);
  906. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top