Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.30 KB | None | 0 0
  1. // i got the wrong reso last time lol
  2.  
  3. void Hits(C_BaseEntity* pEnt)
  4. {
  5.     auto NetChannel = g_pEngine->GetNetChannelInfo();
  6.  
  7.     if (!NetChannel)
  8.         return;
  9.  
  10.     static float predTime[65];
  11.     static bool init[65];
  12.  
  13.  
  14.     if (Globals::Shot[pEnt->EntIndex()])
  15.     {
  16.         if (init[pEnt->EntIndex()])
  17.         {
  18.             g_Resolver.pitchHit[pEnt->EntIndex()] = pEnt->GetEyeAngles().x;
  19.             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);
  20.             init[pEnt->EntIndex()] = false;
  21.         }
  22.  
  23.         if (g_pGlobalVars->curtime > predTime[pEnt->EntIndex()] && !Globals::Hit[pEnt->EntIndex()])
  24.         {
  25.             Globals::MissedShots[pEnt->EntIndex()] += 1;
  26.             Globals::Shot[pEnt->EntIndex()] = false;
  27.         }
  28.         else if (g_pGlobalVars->curtime <= predTime[pEnt->EntIndex()] && Globals::Hit[pEnt->EntIndex()])
  29.             Globals::Shot[pEnt->EntIndex()] = false;
  30.  
  31.     }
  32.     else
  33.         init[pEnt->EntIndex()] = true;
  34.  
  35.     Globals::Hit[pEnt->EntIndex()] = false;
  36. }
  37.  
  38. void Resolver::Main()
  39. {
  40.     if (!CFG.Resolver);
  41.         return;
  42.  
  43.     if (!Globals::LocalPlayer->IsAlive())
  44.         return;
  45.  
  46.     if (!Globals::LocalPlayer->GetActiveWeapon() || Globals::LocalPlayer->IsKnifeorNade())
  47.         return;
  48.  
  49.  
  50.     for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  51.     {
  52.         C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  53.  
  54.         if (!pPlayerEntity
  55.             || !pPlayerEntity->IsAlive()
  56.             || pPlayerEntity->IsDormant()
  57.             || pPlayerEntity == Globals::LocalPlayer
  58.             || pPlayerEntity->GetTeam() == Globals::LocalPlayer->GetTeam())
  59.         {
  60.             UseFreestandAngle[i] = false;
  61.             continue;
  62.         }
  63.  
  64.         if (abs(pPlayerEntity->GetVelocity().Length2D()) > 29.f)
  65.             UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
  66.  
  67.         if (abs(pPlayerEntity->GetVelocity().Length2D()) <= 29.f && !UseFreestandAngle[pPlayerEntity->EntIndex()])
  68.         {
  69.             bool Autowalled = false, HitSide1 = false, HitSide2 = false;
  70.  
  71.             float angToLocal = g_Math.CalcAngle(Globals::LocalPlayer->GetOrigin(), pPlayerEntity->GetOrigin()).y;
  72.             Vector ViewPoint = Globals::LocalPlayer->GetOrigin() + Vector(0, 0, 90);
  73.  
  74.             Vector2D Side1 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal))),(45 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  75.             Vector2D Side2 = { (45 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(45 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  76.  
  77.             Vector2D Side3 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal))),(50 * cos(g_Math.GRD_TO_BOG(angToLocal))) };
  78.             Vector2D Side4 = { (50 * sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(50 * cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  79.  
  80.             Vector Origin = pPlayerEntity->GetOrigin();
  81.  
  82.             Vector2D OriginLeftRight[] = { Vector2D(Side1.x, Side1.y), Vector2D(Side2.x, Side2.y) };
  83.  
  84.             Vector2D OriginLeftRightLocal[] = { Vector2D(Side3.x, Side3.y), Vector2D(Side4.x, Side4.y) };
  85.  
  86.             for (int side = 0; side < 2; side++)
  87.             {
  88.                 Vector OriginAutowall = { Origin.x + OriginLeftRight[side].x,  Origin.y - OriginLeftRight[side].y , Origin.z + 90 };
  89.                 Vector OriginAutowall2 = { ViewPoint.x + OriginLeftRightLocal[side].x,  ViewPoint.y - OriginLeftRightLocal[side].y , ViewPoint.z };
  90.  
  91.                 if (g_Autowall.CanHitFloatingPoint(OriginAutowall, ViewPoint))
  92.                 {
  93.                     switch (side)
  94.                     {
  95.                     case 0:
  96.                         HitSide1 = true;
  97.                         FreestandAngle[pPlayerEntity->EntIndex()] = 90;
  98.                         break;
  99.                     case 1:
  100.                     {
  101.                         HitSide2 = true;
  102.                         FreestandAngle[pPlayerEntity->EntIndex()] = -90;
  103.                     }
  104.  
  105.                     Autowalled = true;
  106.                 }
  107.                 else
  108.                 {
  109.                     for (int side = 0; side< 2; side++)
  110.                     {
  111.                         Vector OriginAutowall222 = { Origin.x + OriginLeftRight[side222].x,  Origin.y - OriginLeftRight[side222].y , Origin.z + 90 };
  112.  
  113.                         if (g_Autowall.CanHitFloatingPoint(OriginAutowall222, OriginAutowall2))
  114.                         {
  115.                             switch (side)
  116.                             {
  117.                             case 0:
  118.                                 HitSide1 = true;
  119.                                 FreestandAngle[pPlayerEntity->EntIndex()] = 90;
  120.                                 break;
  121.                             case 1:
  122.                                 HitSide2 = true;
  123.                                 FreestandAngle[pPlayerEntity->EntIndex()] = -90;
  124.                                 break;
  125.                             }
  126.  
  127.                             Autowalled = true;
  128.                         }
  129.                     }
  130.                 }
  131.             }
  132.  
  133.             if (Autowalled)
  134.             {
  135.                 if (HitSide1 && HitSide2)
  136.                     UseFreestandAngle[pPlayerEntity->EntIndex()] = false;
  137.                 else
  138.                     UseFreestandAngle[pPlayerEntity->EntIndex()] = true;
  139.             }
  140.         }
  141.     }
  142. }
  143.  
  144. void Resolver::FS(ClientFrameStage_t stage)
  145. {
  146.     if (!Globals::LocalPlayer || !g_pEngine->IsInGame())
  147.         return;
  148.  
  149.     static bool  wasDormant[65];
  150.  
  151.     for (int i = 1; i < g_pEngine->GetMaxClients(); ++i)
  152.     {
  153.         C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  154.  
  155.         if (!pPlayerEntity
  156.             || !pPlayerEntity->IsAlive())
  157.             continue;
  158.         if (pPlayerEntity->IsDormant())
  159.         {
  160.             wasDormant[i] = true;
  161.             continue;
  162.         }
  163.  
  164.         if (stage == FRAME_RENDER_START)
  165.         {
  166.             HandleHits(pPlayerEntity);
  167.             AnimationFix(pPlayerEntity);
  168.         }
  169.  
  170.         if (stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
  171.             HandleBackUpResolve(pPlayerEntity);
  172.         }
  173.  
  174.         if (stage == FRAME_NET_UPDATE_END && pPlayerEntity != Globals::LocalPlayer)
  175.         {
  176.             auto VarMap = reinterpret_cast<uintptr_t>(pPlayerEntity) + 36;
  177.             auto VarMapSize = *reinterpret_cast<int*>(VarMap + 20);
  178.  
  179.             for (auto index = 0; index < VarMapSize; index++)
  180.                 *reinterpret_cast<uintptr_t*>(*reinterpret_cast<uintptr_t*>(VarMap) + index * 12) = 0;
  181.         }
  182.  
  183.         wasDormant[i] = false;
  184.     }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement