Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector3 BonePos(DWORD target, DWORD address, int boneId)
- {
- DWORD boneBase = Read<DWORD>(target + address);
- Vector3 vBone;
- vBone.x = Read<float>(boneBase + 0x30 * boneId + 0x0C);
- vBone.y = Read<float>(boneBase + 0x30 * boneId + 0x1C);
- vBone.z = Read<float>(boneBase + 0x30 * boneId + 0x2C);
- return vBone;
- }
- float flAngleNormalize(float angle)
- {
- while (angle < -180) angle += 360;
- while (angle > 180) angle -= 360;
- return angle;
- }
- Vector3 ClampAngle(Vector3 angles) {
- angles.y = flAngleNormalize(angles.y);
- angles.x = flAngleNormalize(angles.x);
- if (angles.x > 89.0f)
- angles.x = 89.0f;
- if (angles.x < -89.0f)
- angles.x = -89.0f;
- angles.z = 0;
- return angles;
- }
- void CalcAngle(Vector3 src, Vector3 dst, Vector3 &angles)
- {
- Vector3 delta;
- delta.x = src.x - dst.x;
- delta.y = src.y - dst.y;
- delta.z = src.z - dst.z;
- double hyp = sqrt(delta.x * delta.x + delta.y * delta.y);
- angles.x = (float)(atan(delta.z / hyp) * 57.295779513082f);
- angles.y = (float)(atan(delta.y / delta.x) * 57.295779513082f);
- angles.z = 0.0f;
- if (delta.x >= 0.0)
- angles.y += 180.0f;
- }
- float Get3dDistance(float mycoordsX, float mycoordsZ, float mycoordsY, float enemycoordsX, float enemycoordsZ, float enemycoordsY)
- {
- return sqrt(pow(double(enemycoordsX - mycoordsX), 2.0) +
- pow(double(enemycoordsY - mycoordsY), 2.0) +
- pow(double(enemycoordsZ - mycoordsZ), 2.0));
- }
- void MakeVector(Vector3 pfin, Vector3& vector)
- {
- float pitch = (float)(pfin.x * M_PI / 180);
- float yaw = (float)(pfin.y * M_PI / 180);
- float tmp = (float)(cos(pitch));
- vector.x = (float)(-tmp * -cos(yaw));
- vector.y = (float)(sin(yaw)*tmp);
- vector.z = (float)(-sin(pitch));
- }
- float GetFOV(Vector3 Angles, Vector3 Source, Vector3 Dst)
- {
- Vector3 ang, aim;
- float fov;
- CalcAngle(Source, Dst, ang);
- MakeVector(Angles, aim);
- MakeVector(ang, ang);
- float mag_s = sqrt((aim.x * aim.x) + (aim.y * aim.y) + (aim.z * aim.z));
- float mag_d = sqrt((aim.x * aim.x) + (aim.y * aim.y) + (aim.z * aim.z));
- float u_dot_v = aim.x * ang.x + aim.y * ang.y + aim.z * ang.z;
- fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0f / M_PI);
- return fov;
- }
- int ClosestEnemyToCrosshair(float maxfov)
- {
- Sleep(1);
- int index;
- for (int i = 0; i < 64; i++)
- {
- DWORD LocalPlayer = Read <DWORD>(clientDLL + dwlocalplayer);
- DWORD entitybase = Read<DWORD>(clientDLL + dwentitylist + (i * 0x10));
- if (entitybase == LocalPlayer)
- continue;
- bool entitydormant = Read<bool>(entitybase + dormantoffset);
- if (entitydormant)
- continue;
- int entityteam = Read<int>(entitybase + intteamnum);
- uint LocalTeam = Read <uint>(LocalPlayer + intteamnum);
- if (entityteam == LocalTeam)
- continue;
- int entitylifestate = Read<byte>(entitybase + m_lifestate);
- if (entitylifestate != 0)
- continue;
- DWORD clientstate = Read<DWORD>(engineDLL + dwClientState);
- Vector3 currentangles = Read<Vector3>(clientstate + m_dwViewAngles);
- Vector3 pos = BonePos(entitybase, bonematrixoffset, 6);
- float entitydistance = GetFOV(currentangles, position, pos);
- if (entitydistance < maxfov)
- {
- maxfov = entitydistance;
- index = i;
- }
- }
- return index;
- }
- /* Cheat Functions */
- int Aimbot(void)
- {
- if (FindCS)
- {
- Log("Aimbot thread started successfully.\n");
- }
- else
- {
- Log("Cannot start aimbot thread. The game is not running.\n");
- }
- cout << "Aimbot thread started." << endl;
- while (true) {
- Sleep(1);
- {
- int entindex = ClosestEnemyToCrosshair(90.f);
- DWORD LocalPlayer = Read <DWORD>(clientDLL + dwlocalplayer);
- Vector3 origin = Read<Vector3>(LocalPlayer + m_vecOrigin);
- Vector3 vecview = Read<Vector3>(LocalPlayer + m_vecViewOffset);
- position.x = origin.x + vecview.x;
- position.y = origin.y + vecview.y;
- position.z = origin.z + vecview.z;
- while (GetAsyncKeyState(VK_MENU))
- {
- Vector3 punch = Read<Vector3>(dwlocalplayer + m_vecPunch);
- Vector3 angles;
- DWORD entitybase = Read<DWORD>(clientDLL + dwentitylist + (entindex * 0x10));
- Vector3 pos = BonePos(entitybase, bonematrixoffset, 6);
- CalcAngle(position, pos, angles);
- angles.x = angles.x - punch.x * 2.f;
- angles.y = angles.y - punch.y * 2.f;
- ClampAngle(angles);
- if (angles.x == 0 && angles.y == 0)
- continue;
- DWORD clientstate = Read<DWORD>(engineDLL + dwClientState);
- Write<Vector3>(clientstate + m_dwViewAngles, angles);
- }
- Sleep(1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement