-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaimbot.cpp
More file actions
118 lines (92 loc) · 2.82 KB
/
Copy pathaimbot.cpp
File metadata and controls
118 lines (92 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "ESP.h"
#include "assault_cube.h"
#include "aimbot.h"
#include <iostream>
#define OFFSET_ISVISIBLE 0x48ABD0
#define M_PI 3.141592653589793F
int getNumberOfPlayers() {
return *((int*)((UINT)GetModuleHandleW(0) + 0xE4E10));
}
void DoAimBot(Player* pLocalPlayer, Vec3 vAimPos)
{
float flYaw = 0;
float flPitch = 0;
GetAimAngles(pLocalPlayer->m_HeadPos, vAimPos, &flYaw, &flPitch);
pLocalPlayer->m_Pitch = flPitch;
pLocalPlayer->m_Yaw = flYaw;
}
void GetAimAngles(Vec3 vLocalPosition, Vec3 vTargetPosition, float* pflYaw, float* pflPitch)
{
Vec3 vDelta = (vTargetPosition - vLocalPosition);
vDelta.Normalize();
*pflYaw = -atan2(vDelta.x, vDelta.y) / M_PI * 180 + 180;
*pflPitch = atan2(vDelta.z, sqrt(vDelta.x * vDelta.x + vDelta.y * vDelta.y)) / M_PI * 180;
}
bool IsVisible(Vec3 vFrom, Vec3 vTo)
{
__asm
{
push vTo.z;
push vTo.y;
push vTo.x;
push vFrom.z;
push vFrom.y;
push vFrom.x;
xor cl, cl; //Tracer
xor eax, eax;
mov ebx, OFFSET_ISVISIBLE;
call ebx;
add esp, 0x18;
}
}
bool IsValidPtr(void* pPointer)
{
if (pPointer && HIWORD(pPointer))
{
if (!IsBadReadPtr(pPointer, sizeof(DWORD_PTR)))
return true;
}
return false;
}
Player* GetAimbotTarget(Game* pGame, Player* pLocalPlayer)
{
Player* pAimTarget = nullptr;
float flClosestDist = INFINITY;
for (int i = 0; i < pGame->m_PlayerCount; i++)
{
Player* pPlayer = pGame->GetPlayer(i);
if (!IsValidPtr(pPlayer))
continue;
if (pPlayer == pLocalPlayer)
continue;
/* (pPlayer->m_State != CS_ALIVE)
continue;*/
if (pPlayer->m_Health <= 0 || pPlayer->m_Health > 100)
continue;
if (pPlayer->m_HeadPos.x == 0 && pPlayer->m_HeadPos.y == 0 && pPlayer->m_HeadPos.z == 0)
continue;
if (&ESP::IsTeamGame )
{
if (pLocalPlayer->m_Team == pPlayer->m_Team)
continue;
}
if (!IsVisible(pLocalPlayer->m_HeadPos, pPlayer->m_HeadPos))
continue;
float flDist = pPlayer->m_HeadPos.Distance(pLocalPlayer->m_HeadPos);
if (flDist < flClosestDist)
{
flClosestDist = flDist;
pAimTarget = pPlayer;
}
}
return pAimTarget;
}
void aimbot() {
Game *game = Game::GetInstance();
Player *pLocalPlayer = game->m_LocalPlayer;
Player* pAimTarget = GetAimbotTarget(game, pLocalPlayer);
if (IsValidPtr(pAimTarget)) {
Vec3 vAimPos = Vec3(pAimTarget->m_HeadPos.x, pAimTarget->m_HeadPos.y, pAimTarget->m_HeadPos.z);
DoAimBot(pLocalPlayer, vAimPos);
}
}