Hello folks, this tutorial is a follow up of @Kibble18's aimbot tutorial, and takes into account that you have already read his tutorial and already have a way to get player{XYZ}, your {XYZ}, players names, and bone locations in respect to the base XYZ of the player, and your Pitch/Yaw. So lets say for this tutorial the head bone is +50 Y and the chest bone is +25 Y so you adjust your aiming angle accordingly. Now to get into the good stuff
This section will give you the rundown on how exactly an aimbot works.
Here we have the XYZ Coordinate plane. The orientation of the axis may or may not be different, it depends on your game. Now lets pretend we have 2 dots on the plane, one on the origion ({0,0,0} X,Y,Z, respectively). the other is positioned at (10, 5, 2). Your pitch is the aim angle left/right on your screen. Pitch/yaw is illustrated by my lovely drawing:
So how do we exactly aim at the guy? Well we simply have to change our guys Pitch/Yaw to point the center of our screen directly at the enemy. But how is the big question. There is a very big answer. So we look back to our guy and the enemy we set up at (0,0,0) and (10, 5, 2), respectively. So the guy is 10 X units away from us, and 5 Y units away from us. Now we can set up the shell of our Aimbot function. The aimbot function will become more and more complex as we go along. So here is the shell of our aimbot function:
Code:
bool isAimed, pStatus, enStatus;
float enXCoor, enYCoor, enZCoor;
int eBone;
bool Aimbot(enXCoor, enYCoor, enZCoor, enStatus, eBone){
//Do our aiming in here
return enStatus;
}
isAimed tells us if we are currently aiming at someone, pStatus tells us if we are dead/alive, and enStatus is the enemy we are aimed at's Dead or Alive status. The eBone integer is the bone we want to aim at of the enemy. 1 = Chest, 2 = Head. Now we need to actually aim at the enemy. First, we'll derive the Pitch with some trigonometry.
This triangle leaves out the Y values and forms a 2 dimensional plane with X and Z. Now imagine that you are the corner of Opposite and Hypotenuse, and the enemy is the corner of Adjacent and Hypotenuse. We have two of the values which should be the length of side A and side O. The length of side A is found by subtracting the smaller value from the bigger value, so 10-0 = 10, so side A = 10, side O will be found the same way, bigger minus smaller, so 2-0 = 2. The third side H is computed using the distance formula
So we input our values and find out the side length H is 10.2 long.
So now that we have our side lengths, computing the angle is easy.
Using this handy dandy picture and sin explanation we find out that:
Great so the Sin of the Pitch is O/H, but that gives us
Code:
Sin(Pitch) = 10/10.2
But thanks to the asin C++ Function (Must include cmath header), we can change our old maths to *Drumroll*
Code:
Pitch = asin(10/10.2)
and Voilà, we have the perfect pitch, but now we need to generalize that so that it will trace the enemy, not just aim at some random spot so without further ado, our updated Aimbot function that aims at the perfect pitch
Stopping here for now feel free to read over this, it's taken me lots of work to get this far and I WILL FINISH IT LATER TONIGHT AND TOMMOROW AND THE FOLLOWING FEW DAYS
Bravo. Looks like you took some time on this. Thanked.
Edit: Don't take too much time (if you're gonna do it at all) to make the Yaw portion since its the same steps but with cosine.
Originally Posted by FailHacker
Bravo. Looks like you took some time on this. Thanked.
Edit: Don't take too much time (if you're gonna do it at all) to make the Yaw portion since its the same steps but with cosine.
Yaw isn't cosine at all. Yaw is the X, Y coordinates, you cannot find yaw with X and Z. Yaw is the exact same way to find except instead of Z you use Y
show me the code at the end.. i mean how it looks if finished
Originally Posted by Coder[Vb10e]
show me the code at the end.. i mean how it looks if finished
I'm working on righting the end of the tutorial you selfish bastard.
thanks for the follow up
Originally Posted by kibbles18
thanks for the follow up
Oh no worries at all. Just trying to help out around here
outstanding! can't wait for the rest very many thanks
You don't need to use Sin you know, tan works just as well and you don't need to calculate the length of the hypotenuse.
Let PointA be your (0,0,0) point (as in the diagram) and PointB be your (10,5,2) then to easy calculate pitch: