GuideStart Here Aimbot Tutorial Guide - How to Make an Aimbot

Rake

Game Name
N/A
Anticheat
N/A
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:
1. Parses the games entitylist, a list of players which contain the enemy objects
2. Checks if the enemies are alive, visible & valid targets using a GetBestTarget() function
3. GetBestTarget() will sort the targets by angle or distance by using the Distance formula or CalcAngle
4. 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

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;
}``````
C++:
``````float RadianToDegree(float radian)
{
return radian * (180 / PI);
}

{
return degree * (PI / 180);

}

{
vec3 degrees;
degrees.x = radians.x * (180 / PI);
degrees.y = radians.y * (180 / PI);
degrees.z = radians.z * (180 / PI);
return degrees;
}

{
radians.x = degrees.x * (PI / 180);
radians.y = degrees.y * (PI / 180);
radians.z = degrees.z * (PI / 180);
}``````
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
If you're writing your own CalcAngle from scratch using trig you will need to resolve these types of issues:

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;
}``````
The above function sorts by angle, so it will return the entity which is closest to your crosshair, meaning the lowest difference in angle from current angle to the enemy. It does this by using the Distance() function on the currentAngles and the aimbotangles. It makes sure the entity is valid also, it is common to make a separate function called "IsValidEnt()" also.

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);``````
src = current angles

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
• 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:

Blackvz

Newbie
Full Member
Hello all

So can someone explain me how to make an aimbot?

I've found the (x|y) coordinates of me and the enemy. And I have my cursor position. I want to make an Aimbot for a simple 2D game.
But how to combine the player-coordinates and the mouse coordinates ?
How to calculate it ?
I dont get , how I can set my mouse position on the enemy (x|y) :/

Please explain and help me a little

Thanks and sorry for my english :/

Last edited by a moderator:

Szaka

Coder
Full Member
Nobleman
So if its a 2D game u see everything from top. Get your screen position by moving cursor on your char and caling GetCursorPos. Then do the same for one enemy. Count distance with pythagoran (i dont know english version but u knwo what i mean). Then count the distance with ingame coords and count proportion. Thats all, this is just a basic math, so you know the screen distance using ingame coords. Then get angle and ur done

Btw game name?

Blackvz

Newbie
Full Member
Game name is Counter Strike 2D. I dont want to ruin the game so I won't release it or play with it online...just btw.
Yea I know what you mean . I used the GetCursorPos in C++. I wrote down my Pos but how I do it with the enemy Pos ? I mean it changes everytime he moves and I cant read it from the client mhhh

Szaka

Coder
Full Member
Nobleman
I understand you got memory addresses with actual, live X Y of enemies in the game. Then its just math

Blackvz

Newbie
Full Member
Mh it's still not clear to me.
I can calculate the Ingame-distance with pytagoras. Okay
But even if i have the distance , I still dont know which direction he is ?

What I got is :

Mouse Position in client (got it with C++ GetCursorPos)
Player and Enemy (XY) Coordinates Ingame.

Maybe you can do an example or something. Im still new to this sorry :/

Szaka

Coder
Full Member
Nobleman
You have your world XY and enemy XY. Count angle and ur done

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
You don't need to get your mouse position, it's totally irrelevant.

Szaka

Coder
Full Member
Nobleman
i cound distance between pixels and between world coords and divided it

Icyvel

Newbie
Full Member
i cound distance between pixels and between world coords and divided it
Yeah i figured that 27 is the result of 135 divided by 5. I guess my real question is, where did you get the 5 from.

As looking at all 3 points, none of them are in fact 5 in distance.

Let me demonstrate:

// A +5
7 + 5 = 12
5 + 5 = 10

// B + 5
11 + 5 = 16
2 + 5 = 7

// C + 5
13 + 5 = 18
13 + 5 = 18

And tryed with your paint, you said 135 distance on screen, i can't see any of the points having 135 distance to each other either.

You gotta be more specific, I'm worried if it's just a typo of you that you actually ment 4 in game, as the distance between A & B seems to be 4, 7 + 4 = 11

Szaka

Coder
Full Member
Nobleman
lol maybe i made a typo but its so damn easy, just try to calcualte it on a paper and everything is clear..

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
2nd grade math can get overwhelming sometimes lol

Icyvel

Newbie
Full Member
2nd grade math can get overwhelming sometimes lol
It's not overhelming but when it's a new concept, typos can make it seem unclear.

Szaka

Coder
Full Member
Nobleman
Just start coding and if it wont work let us know

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
I remember for Fruit Ninja (2D..) it was like ScreenWidth/2 +- (ScreenWidth/2)*(X/285) or sth similar for the X coord.. (I created an aimbot for the game once...)

Szaka

Coder
Full Member
Nobleman
yea! Thats it... its simple linear function. Get 2 points ingame with same X, count proprtion and same with Y, then u get function y=ax+b for both coords

Jaimy

Newbie
Full Member
hi guys i'm playing a game called Microvolts i have an aimbot called "MVX" i have the code
my request is can someone change this code to a dll file ?

1st code
Code:
C++:
``````"aim on" - turns on aimbot
"aim off" - turns off aimbot
"aim rifle on" - turns on rifle aimbot
"aim rifle off" - turns off rifle aimbot
"aim shotgun on" - turns on shotgun aimbot
"aim shotgun off" - turns off shotgun aimbot
"aim sniper on" - turns on sniper aimbot
"aim sniper off" - turns off sniper aimbot
"aim gatling on" - turns on gatling aimbot
"aim gatling off" - turns off gatling aimbot
"esp on" - turns on esp(radar)
"esp off" - turns off esp(radar)
"aim rangetotarget 1337" - puts your range - to - target to a specific value, in this case 1337. You can replace the number as you want.
Its the circle size you see while "esp" is on. If your enemy is in that circle, it will be shooted. You can also see the line going from you croshair, to the closest enemy.
"aim aimnext_interval 1000" - just experiment with this value(1000) and rifle aimbot on. You will see, that the less value is, the faster you gona aim to next person.
"aim sniper head 100" - sets sniper headshot posibility to 100%. You can edit the value as you want.
"jump 1" - sets jump set
"speed 1" - sets speed set
"ua" - turn unlimited ammo ON / OFF
"uar" - turn unlimited ammo recharges ON / OFF``````
2nd Code:
its long https://pastebin.com/7UjYWWF0
C++:
``````-- WINDOWS MESSAGES CONSTANTS
WM_ACTIVATEAPP = 0x001C
WM_KEYDOWN     = 0x0100
WM_KEYUP       = 0x0101

-- VIRTUAL KEYS CONSTANTS
VK_CTRL   = 17
VK_A      = 65
VK_B      = 66
VK_C      = 67
VK_S      = 83
VK_V      = 86
--
VK_F1     = 112
VK_F2     = 113
VK_F3     = 114
VK_F4     = 115
---------------

-- global variables
local isControlPressed = false
---------------

function onKeyDown(key)
MVXPrint(string.format("key down: %d.", key))

if key == VK_CTRL then
isControlPressed = true
end

if isControlPressed and key == VK_C then -- turn off esp
MVXProcessCommand("esp off")
return 1
end

if isControlPressed and key == VK_V then -- turn off aim
MVXProcessCommand("aim off")
return 1
end

if isControlPressed and key == VK_B then -- toggle unlimited ammo and ammo recharges on/off
MVXProcessCommand("ua")
MVXProcessCommand("uar")
return 1
end

if key == VK_F3 then
MVXProcessCommand("aim default")
return 1
elseif key == VK_F2 then

--  The following settings are usually used by experienced
--  players. If you can play using those settings rarely
--  another will call you "aimbotter", lol.

--  If you are a beginner on playing shooting games you'd suck using those settings.

MVXProcessCommand("aim default")
MVXChatPrint("MVX PRO Player settings\n")
MVXProcessCommand("aim rangetotarget 50")
--  reduces the aimbot range to 50 pixels, the aim range is shown by a yellow circle during the game.

MVXProcessCommand("aim aimnext_interval 1000")
--  after the index target get killed the next will be targeted only after 1 second (1000 milliseconds)
--  this does avoid "jolt" movements
MVXProcessCommand("aim sniper on")
--  40% of the shots are aimed to the enemy's head,
--  if you use 100% headshots people will cry a lot calling you "aimbotter".
--  btw, pro players miss headshots also ;P
MVXProcessCommand("aim shotgun on")
MVXProcessCommand("aim rifle off")      -- MVX Rifle's aimbot is fuckin' op (overpowered) and people may percept or cry a lot if you use it.
MVXProcessCommand("aim gatling off") -- MVX the same than rifle.
MVXChatPrint("\n---")
return 1
elseif key == VK_F4 then
--  The following settings are for players that wants to mess around
MVXProcessCommand("aim default")
MVXChatPrint("MVX aggressive player settings\n")
MVXProcessCommand("aim aimnext_interval 0")
MVXProcessCommand("aim rangetotarget 350")
MVXProcessCommand("ua on")
MVXProcessCommand("uar on")
MVXProcessCommand("acs")
MVXProcessCommand("speed 2")
MVXProcessCommand("jump 1")
MVXChatPrint("\n---")
return 1
end
end

function onKeyUp(key)
-- disables the isControlPressed flag if any other key goes up
isControlPressed = false
end

function wndProc(message,wParam,hiLParam,loLParam)
local ret = 0  -- if ret is set MVX does NOT allow the message to be processed by the game.
if message == WM_KEYUP then
ret = onKeyUp(wParam)
elseif message == WM_KEYDOWN then
ret = onKeyDown(wParam)
elseif message == WM_ACTIVATEAPP then
if not wParam then
isControlPressed = false
end
end
return ret
end

MVXPrint("MVX LUA Script 1.1")``````

Rake

This is not a full source code, this won't help you do shit, sorry

Obsta

Jr.Hacker
Meme Tier VIP
Nobody could compile this because of theres no reference to MVXProcessCommand, MVXChatPrint and god knows what else.

project21124

Newbie
Full Member
If you actually wrote your own aimbot, then doing 15 seconds of research would show you how to make your own dll.

Here's a source:

https://www.mingw.org/wiki/sampledll

Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language