Advertisement
Guest User

Untitled

a guest
Mar 20th, 2015
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Vector3
  2. {
  3.     float X;
  4.     float Y;
  5.     float Z;
  6. };
  7.  
  8. void aimbot()
  9. {
  10.     if (GetKeyState(VK_LBUTTON) & 0x80)
  11.     {
  12.         getClosestEntity();
  13.  
  14.         if (AimbotVictim.ID > -1 && AimbotVictim.ID <= 64)
  15.         {
  16.             std::cout << endl;
  17.             std::cout << "VICTIM :\t" << AimbotVictim.ID << endl;
  18.             std::cout << "FOV    :\t" << aimbotBestFOV << endl;
  19.             std::cout << "Health :\t" << EntityList[AimbotVictim.ID].health << endl;
  20.             std::cout << "Team   :\t" << EntityList[AimbotVictim.ID].team << endl;
  21.             std::system("cls");
  22.  
  23.             // Write ViewAngle
  24.             DWORD enginePointer = mem.Read<DWORD>(engineDLL + enginePointerOffset);
  25.             mem.Write<float>(enginePointer + setViewAngle, AimbotVictim.pitch);
  26.             mem.Write<float>(enginePointer + (setViewAngle + 4), AimbotVictim.yaw);
  27.         }
  28.     }
  29. }
  30.  
  31. void getClosestEntity()
  32. {
  33.     aimbotBestFOV = 360.0f;
  34.     AimbotVictim.ID = -1;
  35.  
  36.     for (int i = 0; i < 64; i++)
  37.     {
  38.         if (EntityList[i].health > 0 && EntityList[i].team != LocalPlayer.team)
  39.         {
  40.             Vector3 localPlayerEyes;
  41.             localPlayerEyes.X = LocalPlayer.vecOrigin[0] + LocalPlayer.vecViewOffset[0];
  42.             localPlayerEyes.Y = LocalPlayer.vecOrigin[1] + LocalPlayer.vecViewOffset[1];
  43.             localPlayerEyes.Z = LocalPlayer.vecOrigin[2] + LocalPlayer.vecViewOffset[2];
  44.  
  45.             Vector3 targetAngles;
  46.             calcAngle(localPlayerEyes, EntityList[i].headBoneXYZ, targetAngles);
  47.  
  48.             AimbotVictim.pitch = targetAngles.X;
  49.             AimbotVictim.yaw = targetAngles.Y;
  50.  
  51.             float fov = getFOV(LocalPlayer.viewAngle, localPlayerEyes, targetAngles);
  52.  
  53.             if (fov < aimbotBestFOV)
  54.             {
  55.                 aimbotBestFOV = fov;
  56.                 AimbotVictim.ID = i;
  57.             }
  58.         }
  59.     }
  60. }
  61.  
  62. void makeVector(Vector3 angle, Vector3 &vector)
  63. {
  64.     float pitch;
  65.     float yaw;
  66.     float tmp;
  67.     pitch = (float)(angle.X * M_PI / 180);
  68.     yaw = (float)(angle.Y * M_PI / 180);
  69.     tmp = (float)cos(pitch);
  70.     vector.X = (float)(-tmp * -cos(yaw));
  71.     vector.Y = (float)(sin(yaw)*tmp);
  72.     vector.Z = (float)-sin(pitch);
  73. }
  74.  
  75. void calcAngle(Vector3 &src, Vector3 &dst, Vector3 &angles)
  76. {
  77.     double delta[3] = { (src.X - dst.X), (src.Y - dst.Y), (src.Z - dst.Z) };
  78.     double hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
  79.     angles.X = (float)(atan(delta[2] / hyp) * M_RADPI);
  80.     angles.Y = (float)(atan(delta[1] / delta[0]) * M_RADPI);
  81.     angles.Z = 0.0f;
  82.  
  83.     if (delta[0] >= 0.0) {
  84.         angles.Y += 180.0f;
  85.     }
  86. }
  87.  
  88. float getFOV(Vector3 angle, Vector3 src, Vector3 dst)
  89. {
  90.     Vector3 ang, aim;
  91.     float fov;
  92.     calcAngle(src, dst, ang);
  93.     makeVector(angle, aim);
  94.     makeVector(ang, ang);
  95.     float mag_s = sqrt((aim.X * aim.X) + (aim.Y * aim.Y) + (aim.Z * aim.Z));
  96.     float mag_d = sqrt((aim.X * aim.X) + (aim.Y * aim.Y) + (aim.Z * aim.Z));
  97.     float u_dot_v = aim.X * ang.X + aim.Y * ang.Y + aim.Z * ang.Z;
  98.     fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0 / M_PI);
  99.     return fov;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement