Skip to main content

Aimbot

Other names: Auto-Aim

What does it do and how does it work: This module automatically aims for the user, aimbot looks at the closest entity to the user, this module works by: before the cheat can aim at the target it has to calculate the pitch and yaw, before i explain the mathematics lets go over the basics we need to figure out the viewangles that will make us aim directly at our enemy.

The first thing we need to do is get our local player's eye position in the world. This is pretty easy. You just need to get the origin vector and add that to the view offset. Then you must find the head position of the enemy, So what we need to find is the target's head relative to our player, (the vector between us and our target), We can find this vector pretty easily by subtracting our eye position from the target's hitbox. The resulting vector will be the position of our target relative to our head. You simply subtract like you would with ordered pairs. The result is the users eye pos is now the origin

Now the math, we have our vector we want to aim at. Now we just need to calculate the angle needed to aim at this vector.

From this point forward, let's say that the example player's viewangles are at (12°, 30°), which is pitch and yaw, respectively. Let's plot the viewangles on a polar coordinate plane

img

Now remember pitch is the Y of our vector, and yaw is the X of our vector. As described in the vectors section of this tutorial, the vector forms a right triangle with the magnitude as the hypotenuse. As such, we can use standard trig functions to find the angle.

The magnitude of our example vector is 10.73.

Let's graph the vector on our circles:

img

When you visualize it this way, it's very easy to see the triangle.

We have an X and Y, so we can use arctan, or inverse tangent, to find the yaw. We have Z and the hypotenuse, so we can use arccos, or inverse cosine, to find the pitch.

Code Example:

yaw = arctan(y/x) // think sin = opp/hyp, cos = adj/hyp, tan = sin/cos

Finally some clients will smooth the aim this can be done with a little more math, The first thing the cheat does is subtract our calculated angles from the player's current viewangles. Like the vector subtraction, this will give us the angle relative to our current viewangles, so you can just add this resulting angle to the current viewangles to have the same effect.

To smooth it up, simply add the result divided by some constant to the viewangles.

Detection difficulty: img

Evidence required: img