- Game Name
- N/A

- Anticheat
- N/A

- Tutorial Link:
- N/A

- How long you been coding/hacking?
- 5 years

- Coding Language
- N/A

**What is an Aimbot?**

An aimbot is a hack feature which makes your player aim at the enemies automatically.

**Required Experience**

You must have completed the Start Here Guide and the Reverse Engineering Guide. This is not a joke, do the guides or I will ban your ass.

**Stop Pasting**

Guide - Stop Pasting - Focus on the Basics

**Most Important Aimbot Tutorial**

Our most important aimbot tutorial is from @BDKPlayer

**How does an aimbot work?**

An aimbot works like most hacks, by accessing the game memory then it:

- Parses the games entitylist, a list of players which contain the enemy objects
- Checks if the enemies are alive, visible & valid targets using a GetBestTarget() function
- GetBestTarget() will sort the targets by angle or distance by using the Distance formula or CalcAngle
- When the BestTarget is found it will set the view angles to aim at the enemy.

**Entity List**

You need to know how to find and parse entitylists, do our guide:

Guide - Getting Started How to find the Entity List

**CalcAngle**

CalcAngle is a function that takes your current position and the target's position and calculates the angle from your current position to the target position. There are 3 or 4 methods of doing CalcAngle depending on how the game works. You will typically use the same 2 functions in every game with minor modifications

**Learn about angles**

Tutorial - How to Find View Angles with Cheat Engine

There are many ways to represent angles and coordinate systems in 3D game programming, these are called Rotation formalisms in three dimensions. The most common are

Rotation Matrix, Eular angles, Quaternions. Angles can be expresses as radians or degrees.

The most common is Eular Angles, you will see them express as a vec3, yaw and pitch are often swapped

C++:

```
struct vec3
{
float x; //yaw
float y; //pitch
float z; //roll
}
```

**CalcAngle Functions**

We have lots of functions available

Source Code - Ultimate CalcAngle Thread - How to Calculate Angle Functions

Source Code - CSGO and Source Engine CalcAngle Function for aimbot

The most common looks like this:

C++:

```
vec CalcAngle(vec3 src, vec3 dst)
{
vec3 angle;
angle.x = -atan2f(dst.x - src.x, dst.y - src.y) / PI * 180.0f + 180.0f;
angle.y = asinf((dst.z - src.z) / Distance(src, dst)) * 180.0f / PI;
angle.z = 0.0f;
return angle;
}
```

**Radians & Degrees Conversions**

C++:

```
float RadianToDegree(float radian)
{
return radian * (180 / PI);
}
float DegreeToRadian(float degree)
{
return degree * (PI / 180);
}
vec3 RadianToDegree(vec3 radians)
{
vec3 degrees;
degrees.x = radians.x * (180 / PI);
degrees.y = radians.y * (180 / PI);
degrees.z = radians.z * (180 / PI);
return degrees;
}
vec3 DegreeToRadian(vec3 degrees)
{
vec3 radians;
radians.x = degrees.x * (PI / 180);
radians.y = degrees.y * (PI / 180);
radians.z = degrees.z * (PI / 180);
return radians;
}
```

**Trigonometry**

It's not mandatory to learn trigonometry but you should at least understand the basics of Pythagorean theorem, sine, cosine and tangent and their arc variants. Once you know the basics you can get by with pasting the CalcAngle functions that we have generously provided. If you want to be a PRO, learn it!

**You will learn some trig stuff and how CalcAngle works from these threads**

- Video Tutorial - CSGO Aimbot Tutorial + CalcAngle Explained in Detail
- Tutorial - Aimbot Math Explained
- Rotation formalisms in three dimensions - Wikipedia

**Normalizing & Clamping Angles**

There are 4 quadrants when looking at a 2D plane, depending which quadrant you are in, X and Y have different signs, positive or negative

Yaw and Pitch for example are between -90 and +90, -180 or +180 or any other conceivable format a developer can come up with. Normalizing and clamping makes sure the angles you're writing are correct. These functions are not always required and not always identical, sometime requiring minor modification

C++:

```
void ClampAngle(vec3& angle) {
if (angle.x > 89.0f) angle.x = 89.f;
if (angle.x < -89.0f) angle.x = -89.f;
if (angle.y > 180.f) angle.y = 180.f;
if (angle.y < -180.f) angle.y = -180.f;
angle.z = 0.0f;
}
void Normalise(vec3& angle) {
if (angle.x > 89.0f) angle.x -= 180.0f;
if (angle.x < -89.0f) angle.x += 180.0f;
while (angle.y > 180) angle.y -= 360.f;
while (angle.y < -180) angle.y += 360.f;
}
```

**GetBestTarget & Sorting Entities**

The simplest GetBestTarget() function looks like this:

C++:

```
Ent* GetBestTarget(Ent* localPlayer, EntList* entList)
{
float oldDistance = FLT_MAX;
float newDistance = 0;
Ent* target = nullptr;
for (auto ent : entList)
{
if (ent && ent->clientId != localPlayer->clientId && ent->lifeState == 0)
{
vec3 angleTo = CalcAngle(localPlayer->pos, ent->pos);
newDistance = Distance(localPlayer->angles, angleTo);
if (newDistance < oldDistance)
{
oldDistance = newDistance;
target = ent;
}
}
}
return target;
}
```

You can also use a coefficient to make your GetBestTarget() take into account angle and 3d distance. Assign a percentage weight to distance and angle, lets say 30% distance and 70% angle.

coefficient = distance * 0.3 + angle * 0.7;

Then sort by lowest coefficient.

**FOV Aimbot**

Source Code - Correct angle comparison for FOV aimbot

Tutorial - How to make an FOV aimbot

**TargetLock**

If your aimbot is aiming at an enemy, but another enemy passes in front of your current target, your aimbot will probably switch to them. In some cases this is a good thing, but most people want to disable that. To stop it, you must implement a target lock mechanism. This is incredibly easy. If you can't figure out how to do it using logic then you're a dirty disgusting paster.

PsuedoCode:

C++:

```
if (IsGoodTarget(currTarget))
{
//don't change targets
}
```

**Aimbot Smoothing**

A regular aimbot will snap right onto the target, which is very obvious. To make it more natural you use smoothing. You get the delta angle (the difference between) current angle and the angle to the enemy. You divide by a predefined increment, and then you add that incrementally to your current view angles.

Smoothing = linear interpolation

To make a smooth aimbot you use something called linear interpolation, here is the basic idea:

C++:

```
int increments = 10;
vec3 dst = CalcAngle(mypos, enemypos);
vec3 diff = dst - src;
SetAngles(src + diff / increments);
```

It will move towards the target, you will probably need to normalize the angles.

Here's a few code examples:

C++:

```
float smoothing = 4.0f;
// Get the view angles we need to aim at
Vec3D aimbotAngle = calcAngles(Vec3D(pLocal->o.x, pLocal->o.y, pLocal->o.z), Vec3D(ent->o.x, ent->o.y, ent->o.z ));
// Get the difference between the angles we need, and our current ones for smoothing
Vec3D diffs = aimbotAngle - Vec3D(pLocal->yaw, pLocal->pitch, pLocal->roll);
pLocal->yaw += diffs.x / smoothing;
pLocal->pitch += diffs.y / smoothing;
```

C++:

```
POINT nextMousePosition, currMousePosition;
GetCursorPos(&currMousePosition);
nextMousePosition.x = currMousePosition.x + (Target.x - currMousePosition.x) / 10;
nextMousePosition.y = currMousePosition.y + (Target.y - currMousePosition.y) / 10;
mouse_event(MOUSEEVENTF_MOVE, nextMousePosition.x, nextMousePosition.y, 0, NULL);
```

C++:

```
int smoothing = 5;
if (toShoot){
// Calculate the needed angles
Vec3D result = calcAngles(Vec3D(pLocal->o.x, pLocal->o.y, pLocal->o.z), Vec3D(toShoot->o.x, toShoot->o.y, toShoot->o.z));
if (smoothing){
// Get the difference between our wanted angles and our current angles
Vec3D diffs = result - Vec3D(pLocal->yaw, pLocal->pitch, pLocal->roll);
// Prevent 360 spins
if (diffs.x > 180)
diffs.x -= 360;
if (diffs.x < -180)
diffs.x += 360;
// Smewth
pLocal->yaw += diffs.x / smoothing;
pLocal->pitch += diffs.y / smoothing;
}
else{
// Snap to them without any smoothing
pLocal->yaw = result.x;
pLocal->pitch = result.y;
}
}
}
```

**Human Aim**

How to make it seem more human, there are many ways

- Use bezier curves
- Add some randomness
- Don't make every shot hit the enemy, miss a couple before and after locking on
- Start shooting 0.25 seconds before you're aiming at enemy and stop shooting 0.5 seconds after

**SilentAim**

Silent aim shoots targets without visibly showing spectators you're aiming at them

Tutorial - How to do Silent Aim in CS:GO

**How to set / write View Angles**

Internally or externally the best thing to do is just overwrite the view angles. If you're external just use WriteProcessMemory, if you're internal just set them. Sometimes you need to use external methods to avoid anticheat such as SendInput or if the view angles aren't easily writeable.

If you can't overwrite the angles then you can use something like these functions, which don't use view angles but use WorldToScreen 2D screen coordinates of the enemy

C++:

```
void MoveMouse(vec3 point)
{
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE;
Input.mi.dx = point.x - WINDOWWIDTH / 2;
Input.mi.dy = point.y - WINDOWHEIGHT / 2;
SendInput(1, &Input, sizeof(INPUT));
}
```

C++:

```
void AimAt(vec3* point)
{
float aX, aY;
vec2 screen[2];
if (!WorldToScreen(pRefdef, point, &screen))
return;
float centerX = pRefdef->width / 2.f;
float centerY = pRefdef->height / 2.f;
float enemyX = screen.x;
float enemyY = screen.y;
aX = enemyX - centerX;
aY = enemyY - centerY;
if (bSmoothAim)
{
aX /= fSmoothAmount;
aY /= fSmoothAmount;
}
mouse_event(MOUSEEVENTF_MOVE, aX, aY, 0, 0);
}
```

C++:

```
void MoveMouse(float X, float Y, float Interval)
{
POINT CurrPos;
GetCursorPos(&CurrPos);
X = (X - CurrPos.x) / Interval + CurrPos.x;
Y = (Y - CurrPos.y) / Interval + CurrPos.y;
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, static_cast<DWORD>(X) * 65535 / ScreenWidth, static_cast<DWORD>(Y) * 65535 / ScreenHeight, 0, 0);
}
//Use it like dis:
for (UINT i = 30; i; --i) //Stepcount
{
MoveMouse(x, y, i);
Sleep(SomeAimDelay);
}
```

**Good Examples to Learn**

**How to Make an Aimbot**

Last edited: