Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. void CalcScreenCoors(D3DXVECTOR3 *vecWorld, D3DXVECTOR3 *vecScreen)
  2. {
  3.  
  4. D3DXMATRIX m((float *)(0xB6FA2C));
  5. DWORD *dwLenX = (DWORD *)(0xC17044);
  6. DWORD *dwLenY = (DWORD *)(0xC17048);
  7.  
  8. vecScreen->x = (vecWorld->z * m._31) + (vecWorld->y * m._21) + (vecWorld->x * m._11) + m._41;
  9. vecScreen->y = (vecWorld->z * m._32) + (vecWorld->y * m._22) + (vecWorld->x * m._12) + m._42;
  10. vecScreen->z = (vecWorld->z * m._33) + (vecWorld->y * m._23) + (vecWorld->x * m._13) + m._43;
  11.  
  12. double fRecip = (double)1.0 / vecScreen->z;
  13. vecScreen->x *= (float)(fRecip * (*dwLenX));
  14. vecScreen->y *= (float)(fRecip * (*dwLenY));
  15. }
  16.  
  17. int GetPlayerTarget(int radius)
  18. {
  19. static int iX;
  20. static int iY;
  21.  
  22.  
  23. for (int i = 0; i < SAMP_MAX_VEHICLES; i++)
  24. {
  25.  
  26. if (SF->getSAMP()->getVehicles()->iIsListed[i] != 1)
  27. continue;
  28. if (SF->getSAMP()->getVehicles()->pSAMP_Vehicle[i] == NULL)
  29. continue;
  30.  
  31. if (SF->getSAMP()->getVehicles()->pSAMP_Vehicle[i]->pGTA_Vehicle == NULL)
  32. continue;
  33.  
  34. struct vehicle_info *vinfo = SF->getGame()->vehicleInfoGet(i, 0);
  35.  
  36. D3DXVECTOR3 vecPos;
  37.  
  38. vecPos.x = vinfo->detachable_car->position[0];
  39. vecPos.y = vinfo->detachable_car->position[1];
  40. vecPos.z = vinfo->detachable_car->position[2];
  41.  
  42.  
  43. D3DXVECTOR3 screenPos;
  44. CalcScreenCoors(&vecPos, &screenPos);
  45. if (screenPos.z < 1.f)
  46. continue;
  47.  
  48. iX = GetSystemMetrics(SM_CXSCREEN) * 0.5299999714f;
  49. iY = GetSystemMetrics(SM_CYSCREEN) * 0.4f;
  50.  
  51.  
  52.  
  53. if ((screenPos.x > iX + (radius)) || (screenPos.y > iY + (radius)) || (screenPos.x < iX - (radius)) || (screenPos.y < iY - (radius)))
  54. continue;
  55.  
  56. return i;
  57. }
  58.  
  59. return -1;
  60. }
  61.  
  62.  
  63.  
  64. void Aimbot()
  65. {
  66. if (step == true)
  67. {
  68. CVector mypos;
  69. CVector enpos;
  70. CVector vector;
  71. int enid = GetPlayerTarget(50);
  72. if (enid != -1)
  73. {
  74. struct vehicle_info *vinfo = SF->getGame()->vehicleInfoGet(enid, 0);
  75.  
  76. enpos.fX = vinfo->detachable_car->position[0];
  77. enpos.fY = vinfo->detachable_car->position[1];
  78. enpos.fZ = vinfo->detachable_car->position[2];
  79.  
  80.  
  81. CCamera *pCamera = GAME->GetCamera();
  82. mypos = *pCamera->GetCam(pCamera->GetActiveCam())->GetSource();
  83. vector = mypos - enpos;
  84.  
  85. float *crosshairOffset = (float *)0xB6EC10;
  86. float mult = tan(pCamera->GetCam(pCamera->GetActiveCam())->GetFOV() * 0.5f * 0.017453292f);
  87. float fx = M_PI - atan2(1.0f, mult * (crosshairOffset[1] - 0.5f + crosshairOffset[1] - 0.5f));
  88.  
  89. float AngleX = atan2f(vector.fY, -vector.fX) - M_PI / 2;
  90.  
  91. *(float*)0xB6F258 = -(AngleX - fx);
  92.  
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement