Advertisement
Guest User

Untitled

a guest
May 24th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. Vector3 BonePos(DWORD target, DWORD address, int boneId)
  2. {
  3. DWORD boneBase = Read<DWORD>(target + address);
  4. Vector3 vBone;
  5. vBone.x = Read<float>(boneBase + 0x30 * boneId + 0x0C);
  6. vBone.y = Read<float>(boneBase + 0x30 * boneId + 0x1C);
  7. vBone.z = Read<float>(boneBase + 0x30 * boneId + 0x2C);
  8. return vBone;
  9. }
  10.  
  11. float flAngleNormalize(float angle)
  12. {
  13. while (angle < -180) angle += 360;
  14. while (angle > 180) angle -= 360;
  15. return angle;
  16. }
  17.  
  18. Vector3 ClampAngle(Vector3 angles) {
  19. angles.y = flAngleNormalize(angles.y);
  20. angles.x = flAngleNormalize(angles.x);
  21. if (angles.x > 89.0f)
  22. angles.x = 89.0f;
  23. if (angles.x < -89.0f)
  24. angles.x = -89.0f;
  25.  
  26. angles.z = 0;
  27. return angles;
  28.  
  29. }
  30.  
  31. void CalcAngle(Vector3 src, Vector3 dst, Vector3 &angles)
  32. {
  33. Vector3 delta;
  34. delta.x = src.x - dst.x;
  35. delta.y = src.y - dst.y;
  36. delta.z = src.z - dst.z;
  37. double hyp = sqrt(delta.x * delta.x + delta.y * delta.y);
  38.  
  39. angles.x = (float)(atan(delta.z / hyp) * 57.295779513082f);
  40. angles.y = (float)(atan(delta.y / delta.x) * 57.295779513082f);
  41. angles.z = 0.0f;
  42.  
  43. if (delta.x >= 0.0)
  44. angles.y += 180.0f;
  45. }
  46.  
  47.  
  48. float Get3dDistance(float mycoordsX, float mycoordsZ, float mycoordsY, float enemycoordsX, float enemycoordsZ, float enemycoordsY)
  49. {
  50. return sqrt(pow(double(enemycoordsX - mycoordsX), 2.0) +
  51. pow(double(enemycoordsY - mycoordsY), 2.0) +
  52. pow(double(enemycoordsZ - mycoordsZ), 2.0));
  53. }
  54.  
  55. void MakeVector(Vector3 pfin, Vector3& vector)
  56. {
  57. float pitch = (float)(pfin.x * M_PI / 180);
  58. float yaw = (float)(pfin.y * M_PI / 180);
  59. float tmp = (float)(cos(pitch));
  60.  
  61. vector.x = (float)(-tmp * -cos(yaw));
  62. vector.y = (float)(sin(yaw)*tmp);
  63. vector.z = (float)(-sin(pitch));
  64. }
  65.  
  66. float GetFOV(Vector3 Angles, Vector3 Source, Vector3 Dst)
  67. {
  68. Vector3 ang, aim;
  69. float fov;
  70. CalcAngle(Source, Dst, ang);
  71. MakeVector(Angles, aim);
  72. MakeVector(ang, ang);
  73.  
  74. float mag_s = sqrt((aim.x * aim.x) + (aim.y * aim.y) + (aim.z * aim.z));
  75. float mag_d = sqrt((aim.x * aim.x) + (aim.y * aim.y) + (aim.z * aim.z));
  76.  
  77. float u_dot_v = aim.x * ang.x + aim.y * ang.y + aim.z * ang.z;
  78. fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0f / M_PI);
  79. return fov;
  80. }
  81.  
  82. int ClosestEnemyToCrosshair(float maxfov)
  83. {
  84. Sleep(1);
  85. int index;
  86. for (int i = 0; i < 64; i++)
  87. {
  88. DWORD LocalPlayer = Read <DWORD>(clientDLL + dwlocalplayer);
  89. DWORD entitybase = Read<DWORD>(clientDLL + dwentitylist + (i * 0x10));
  90. if (entitybase == LocalPlayer)
  91. continue;
  92. bool entitydormant = Read<bool>(entitybase + dormantoffset);
  93. if (entitydormant)
  94. continue;
  95.  
  96. int entityteam = Read<int>(entitybase + intteamnum);
  97.  
  98. uint LocalTeam = Read <uint>(LocalPlayer + intteamnum);
  99. if (entityteam == LocalTeam)
  100. continue;
  101.  
  102. int entitylifestate = Read<byte>(entitybase + m_lifestate);
  103. if (entitylifestate != 0)
  104. continue;
  105. DWORD clientstate = Read<DWORD>(engineDLL + dwClientState);
  106. Vector3 currentangles = Read<Vector3>(clientstate + m_dwViewAngles);
  107. Vector3 pos = BonePos(entitybase, bonematrixoffset, 6);
  108. float entitydistance = GetFOV(currentangles, position, pos);
  109. if (entitydistance < maxfov)
  110. {
  111. maxfov = entitydistance;
  112. index = i;
  113. }
  114. }
  115. return index;
  116. }
  117.  
  118. /* Cheat Functions */
  119.  
  120. int Aimbot(void)
  121. {
  122. if (FindCS)
  123. {
  124. Log("Aimbot thread started successfully.\n");
  125. }
  126. else
  127. {
  128. Log("Cannot start aimbot thread. The game is not running.\n");
  129. }
  130. cout << "Aimbot thread started." << endl;
  131. while (true) {
  132. Sleep(1);
  133. {
  134.  
  135. int entindex = ClosestEnemyToCrosshair(90.f);
  136. DWORD LocalPlayer = Read <DWORD>(clientDLL + dwlocalplayer);
  137. Vector3 origin = Read<Vector3>(LocalPlayer + m_vecOrigin);
  138. Vector3 vecview = Read<Vector3>(LocalPlayer + m_vecViewOffset);
  139. position.x = origin.x + vecview.x;
  140. position.y = origin.y + vecview.y;
  141. position.z = origin.z + vecview.z;
  142. while (GetAsyncKeyState(VK_MENU))
  143. {
  144.  
  145. Vector3 punch = Read<Vector3>(dwlocalplayer + m_vecPunch);
  146. Vector3 angles;
  147.  
  148. DWORD entitybase = Read<DWORD>(clientDLL + dwentitylist + (entindex * 0x10));
  149. Vector3 pos = BonePos(entitybase, bonematrixoffset, 6);
  150.  
  151. CalcAngle(position, pos, angles);
  152. angles.x = angles.x - punch.x * 2.f;
  153. angles.y = angles.y - punch.y * 2.f;
  154. ClampAngle(angles);
  155. if (angles.x == 0 && angles.y == 0)
  156. continue;
  157.  
  158. DWORD clientstate = Read<DWORD>(engineDLL + dwClientState);
  159. Write<Vector3>(clientstate + m_dwViewAngles, angles);
  160.  
  161. }
  162. Sleep(1);
  163. }
  164. }
  165. return 0;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement