0% found this document useful (0 votes)
13 views6 pages

Message

The document contains code for an aimbot feature in a game, allowing players to automatically aim at nearby enemies. It includes functions to find nearby pedestrians, calculate screen coordinates, and aim at targets based on various parameters such as distance and visibility. Additionally, it defines key mappings for activating the aimbot and handles the aiming logic based on user input.

Uploaded by

vnpecinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Message

The document contains code for an aimbot feature in a game, allowing players to automatically aim at nearby enemies. It includes functions to find nearby pedestrians, calculate screen coordinates, and aim at targets based on various parameters such as distance and visibility. Additionally, it defines key mappings for activating the aimbot and handles the aiming logic based on user input.

Uploaded by

vnpecinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

#include "game_sa/CWorld.

h"
#include "game_sa/CPools.h"
#include "CWeapon.h"
#include "CDraw.h"
#include "game_sa/CCamera.h"
#include <cmath>
#include <algorithm>
#include <CWeaponInfo.h>
#include <CWeaponModelInfo.h>
#include "common.h"
#include "game_sa/ePedBones.h"

bool normal_aimbot = true;


float aimbot_smooth = 2.0f;
int aimbot_bone = 8;
float aimbot_fov = 50;
bool aimbot_fov_enabled = false;
int aimbot_probability = 99999;
bool smooth_aimbot = false;
bool player_flower = false;
float aimbot_move_speed = 1;
bool AimbotPlayerProximo = false;
float aimbot_max_distance = 100.0f;
bool aimbot_player_death = false;
bool aimbot_check_visibility = false;
std::vector<CPed*> GetAllPeds() {
std::vector<CPed*> peds;
CPool<CPed, CCopPed>* pedPool = CPools::ms_pPedPool;
if (pedPool) {
for (int i = 0; i < pedPool->m_nSize; i++) {
if (!pedPool->IsFreeSlotAtIndex(i)) {
CPed* ped = pedPool->GetAt(i);
if (ped) {
peds.push_back(ped);
}
}
}
}
return peds;
}

void CalcScreenCoors(CVector* vecWorld, CVector* vecScreen) {


D3DXMATRIX m((float*)(0xB6FA2C));

DWORD* dwLenX = (DWORD*)(0xC17044);


DWORD* dwLenY = (DWORD*)(0xC17048);

vecScreen->x = (vecWorld->z * m._31) + (vecWorld->y * m._21) + (vecWorld->x *


m._11) + m._41;
vecScreen->y = (vecWorld->z * m._32) + (vecWorld->y * m._22) + (vecWorld->x *
m._12) + m._42;
vecScreen->z = (vecWorld->z * m._33) + (vecWorld->y * m._23) + (vecWorld->x *
m._13) + m._43;

double fRecip = (double)1.0 / vecScreen->z;


vecScreen->x *= (float)(fRecip * (*dwLenX));
vecScreen->y *= (float)(fRecip * (*dwLenY));
}
CVector* getBonePosition(CPed* pPed, int bone, CVector* vecPosition) {
pPed->GetBonePosition(*(RwV3d*)vecPosition, (ePedBones)bone, true);
return vecPosition;
}

WORD GetCurrentWeaponID(CPed* ped, BYTE slot) {


if (ped == nullptr) return 0;
return (WORD)ped->m_aWeapons[slot].m_eWeaponType;
}

CPed* FindClosestPed()
{
float closestDistance = FLT_MAX;
CPed* closestPed = nullptr;
CVector playerPos = FindPlayerPed()->GetPosition();
CPed* playerPed = FindPlayerPed();

for (CPed* pPed : GetAllPeds())


{
if (pPed == playerPed)
continue;

if (pPed->m_nPedType == PED_TYPE_CIVMALE || pPed->m_nPedType ==


PED_TYPE_CIVFEMALE)
continue;

if (!aimbot_player_death && !pPed->IsAlive())


continue;

if (aimbot_check_visibility) {
if (!CWorld::GetIsLineOfSightClear(playerPos, pPed-
>GetPosition(), true, false, false, true, true, false, false))
continue;
}
CVector pedPos = pPed->GetPosition();
float distance = (pedPos - playerPos).Magnitude();

if (aimbot_fov_enabled)
{
CVector screenPos;
CalcScreenCoors(&pedPos, &screenPos);

float screenCenterX = *reinterpret_cast<DWORD*>(0xC17044) / 2;


float screenCenterY = *reinterpret_cast<DWORD*>(0xC17048) / 2;
float deltaX = screenPos.x - screenCenterX;
float deltaY = screenPos.y - screenCenterY;
float fovDistance = sqrt(deltaX * deltaX + deltaY * deltaY);

if (fovDistance > aimbot_fov)


continue;
}

if (distance < closestDistance)


{
closestDistance = distance;
closestPed = pPed;
}
}
return closestPed;
}

CPed* FindPedInView() {
CVector playerPos = FindPlayerPed()->GetPosition();

int screenCenterX, screenCenterY;


Esp::cumfov(&screenCenterX, &screenCenterY);
for (CPed* pPed : GetAllPeds()) {
if (pPed == nullptr || pPed == FindPlayerPed())
continue;

if (pPed->m_nPedType == PED_TYPE_CIVMALE || pPed->m_nPedType ==


PED_TYPE_CIVFEMALE)
continue;

CVector pedPos = pPed->GetPosition();


float distance = (pedPos - playerPos).Magnitude();

if (!bIgnoreMaxDistance) {
if (distance > aimbot_max_distance)
continue;
}

if (!aimbot_player_death && !pPed->IsAlive())


continue;

if (aimbot_fov_enabled) {
CVector screenPos;
CalcScreenCoors(&pedPos, &screenPos);
float deltaX = screenPos.x - screenCenterX;
float deltaY = screenPos.y - screenCenterY;
float fovDistance = sqrt(deltaX * deltaX + deltaY * deltaY);

if (fovDistance > aimbot_fov)


continue;
}

return pPed;
}

return nullptr;
}

void AimAtPed(CPed* pPed, float smooth) {


if (pPed == nullptr) return;

CPed* playerPed = FindPlayerPed();


if (playerPed == nullptr) return;

CVector bonePos;
getBonePosition(pPed, aimbot_bone, &bonePos);

CVector playerPos = playerPed->GetPosition();


CVector direction = bonePos - playerPos;
direction.Normalise();

CVector camPos = *TheCamera.GetGameCamPosition();


CVector targetPos = CVector(bonePos.x, bonePos.y, bonePos.z);
CVector vecVector = camPos - targetPos;

float fFix = 0.f, fVecX = 0.f, fZ = 0.f, fX = 0.f;

if (TheCamera.m_aCams[0].m_nMode == 53 || TheCamera.m_aCams[0].m_nMode == 55)


{
float fMult = tan(TheCamera.FindCamFOV() / 2.0f * 0.017453292f);
fZ = M_PI - atan2(1.0f, fMult * ((1.0f -
CCamera::m_f3rdPersonCHairMultY * 2.0f) * (1.0f / CDraw::ms_fAspectRatio)));
fX = M_PI - atan2(1.0f, fMult * (CCamera::m_f3rdPersonCHairMultX * 2.0f
- 1.0f));
}
else {
fX = fZ = M_PI / 2;
}

BYTE slot = playerPed->m_nActiveWeaponSlot;


BYTE byteWeapon = GetCurrentWeaponID(playerPed, slot);
if (byteWeapon >= 22 && byteWeapon <= 29 || byteWeapon == 32) fFix =
0.04253f;
else if (byteWeapon == 30 || byteWeapon == 31) fFix = 0.028f;
else if (byteWeapon == 33) fFix = 0.01897f;

float fDistX = sqrt(vecVector.x * vecVector.x + vecVector.y * vecVector.y);


if (vecVector.x <= 0.0 && vecVector.y >= 0.0 || vecVector.x >= 0.0 &&
vecVector.y >= 0.0)
fVecX = (acosf(vecVector.x / fDistX) + fFix) -
TheCamera.m_aCams[0].m_fHorizontalAngle;
if (vecVector.x >= 0.0 && vecVector.y <= 0.0 || vecVector.x <= 0.0 &&
vecVector.y <= 0.0)
fVecX = (-acosf(vecVector.x / fDistX) + fFix) -
TheCamera.m_aCams[0].m_fHorizontalAngle;

float fSmoothX = fVecX / smooth;


if (fSmoothX > -1.0 && fSmoothX < 0.5 && fVecX > -2.0 && fVecX < 2.0)
TheCamera.m_aCams[0].m_fHorizontalAngle += fSmoothX;

float fDistZ = sqrt(vecVector.x * vecVector.x + vecVector.y * vecVector.y);


float fSmoothZ = (atan2f(fDistZ, vecVector.z) - fZ -
TheCamera.m_aCams[0].m_fVerticalAngle) / smooth;
TheCamera.m_aCams[0].m_fVerticalAngle += fSmoothZ;
}

enum AimbotKey {
KEY_MOUSE1,
KEY_MOUSE2,
KEY_F1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
KEY_F11,
KEY_F12,
KEY_NUM1,
KEY_NUM2,
KEY_NUM3,
KEY_NUM4,
KEY_NUM5,
KEY_NUM6,
KEY_NUM7,
KEY_NUM8,
KEY_NUM9,
KEY_NUM0,
KEY_COUNT
};

int GetKeyFromAimbotKey(AimbotKey key) {


switch (key) {
case KEY_MOUSE1: return VK_LBUTTON;
case KEY_MOUSE2: return VK_RBUTTON;
case KEY_F1: return VK_F1;
case KEY_F2: return VK_F2;
case KEY_F3: return VK_F3;
case KEY_F4: return VK_F4;
case KEY_F5: return VK_F5;
case KEY_F6: return VK_F6;
case KEY_F7: return VK_F7;
case KEY_F8: return VK_F8;
case KEY_F9: return VK_F9;
case KEY_F10: return VK_F10;
case KEY_F11: return VK_F11;
case KEY_F12: return VK_F12;
case KEY_NUM1: return VK_NUMPAD1;
case KEY_NUM2: return VK_NUMPAD2;
case KEY_NUM3: return VK_NUMPAD3;
case KEY_NUM4: return VK_NUMPAD4;
case KEY_NUM5: return VK_NUMPAD5;
case KEY_NUM6: return VK_NUMPAD6;
case KEY_NUM7: return VK_NUMPAD7;
case KEY_NUM8: return VK_NUMPAD8;
case KEY_NUM9: return VK_NUMPAD9;
case KEY_NUM0: return VK_NUMPAD0;
default: return VK_F1;
}
}

AimbotKey selectedAimbotKey = KEY_MOUSE2;

void HandleAimbot() {
if (GetAsyncKeyState(GetKeyFromAimbotKey(selectedAimbotKey)) & 0x8000) {
CPed* targetPed = nullptr;

if (AimbotPlayerProximo == true && AimbotPlayer) {


targetPed = FindClosestPed();
}
else {
if (AimbotPlayer) {
targetPed = FindPedInView();
}
}

if (targetPed != nullptr && AimbotPlayer) {


AimAtPed(targetPed, aimbot_smooth);
}
}
}

You might also like