# Aimbot angles

#### NTvalk

##### Hacker
Hey im currently using this function

C++:
``````void CMaths::CalcAngles(const vec3_t &source, const vec3_t &dest, vec3_t &ang)
{
double delta[3] = { (source[0] - dest[0]), (source[1] - dest[1]), (source[2] - dest[2]) };
double hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
ang[0] = (float)(atan(delta[2] / hyp) * RADPI);
ang[1] = (float)(atan(delta[1] / delta[0]) * RADPI);
ang[2] = 0.0f;
if (delta[0] >= 0.0f)
ang[0] += 180.0f;

}``````
to calulate the angles between 2 players, but it doesnt give me the right angles, any ideas?

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
What values does this give for you, tried outputting those? Sure you are writing those values to the right location?

#### NTvalk

##### Hacker
What values does this give for you, tried outputting those? Sure you are writing those values to the right location?
I'm not writing yet, just outputting it:

EDIT: the output of the X-angles gives me the distance between me and the enemy..

Last edited:

#### NTvalk

##### Hacker
also when i use

C++:
``````void CMaths::GetAngleToTarget(vec3_t vTarget, vec3_t source, vec3_t vAngles)
{
vec3_t deltaVec;
deltaVec[0] = vTarget[0] - source[0];
deltaVec[1] = vTarget[1] - source[1];
deltaVec[2] = vTarget[2] - source[2];

VectorAngles(deltaVec, vAngles);

if (vAngles[0] > 180.0f)
vAngles[0] -= 360.0f;
else if (vAngles[0] <-180.0f)
vAngles[0] += 360.0f;

if (vAngles[1] > 180.0f)
vAngles[1] -= 360.0f;
else if (vAngles[1] < -180.0f)
vAngles[1] += 360.0f;
}``````
i get vAngles[0] as the distance between me and the enemy :O there must be something wrong with my input...

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
also when i use

C++:
``````void CMaths::GetAngleToTarget(vec3_t vTarget, vec3_t source, vec3_t vAngles)
{
vec3_t deltaVec;
deltaVec[0] = vTarget[0] - source[0];
deltaVec[1] = vTarget[1] - source[1];
deltaVec[2] = vTarget[2] - source[2];

VectorAngles(deltaVec, vAngles);

if (vAngles[0] > 180.0f)
vAngles[0] -= 360.0f;
else if (vAngles[0] <-180.0f)
vAngles[0] += 360.0f;

if (vAngles[1] > 180.0f)
vAngles[1] -= 360.0f;
else if (vAngles[1] < -180.0f)
vAngles[1] += 360.0f;
}``````
i get vAngles[0] as the distance between me and the enemy :O there must be something wrong with my input...

#### NTvalk

##### Hacker
C++:
``````vec3_t, aimAngles;
...
if(enemy...){
esp.fenemydistance = maths.SubVectorDist(esp.validClients[i], esp.myInfo) / 47;        // this gives the distance well
maths.GetAngleToTarget (esp.myInfo.vpos,esp.validClients[i].vpos, aimAngles);         // this gives me the wrong x angle
printf("aim x : %f\n", aimAngles[0]);
}``````
and this is my vpos
C++:
``````        myInfo.posx = *(float*)(0x797618);
myInfo.posy = *(float*)(0x79761C);
myInfo.posz = *(float*)(0x797620);

...

myInfo.vpos[0] = myInfo.posx;
myInfo.vpos[1] = myInfo.posy;
myInfo.vpos[2] = myInfo.posz;``````

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
C++:
``````esp.fenemydistance =[B] maths.SubVectorDist(esp.validClients[i], esp.myInfo) / 47;[/B]        // this gives the distance well
maths.GetAngleToTarget (esp.myInfo.vpos,esp.validClients[i].vpos, aimAngles);         // this gives me the wrong x angle``````
I have no idea what you are doing.

#### NTvalk

##### Hacker
I have no idea what you are doing.
C++:
`` esp.validClients[i].vpos``
is a vec3_t of the coordinates of the enemy
and

C++:
`` esp.myInfo.vpos``
are my coordinates

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
C++:
`` esp.validClients[i].vpos``
is a vec3_t of the coordinates of the enemy
and

C++:
`` esp.myInfo.vpos``
are my coordinates
Obviously, got that part, but this:

C++:
``````esp.fenemydistance = maths.SubVectorDist(esp.validClients[i], esp.myInfo) / 47;        // this gives the distance well
maths.GetAngleToTarget (esp.myInfo.vpos,esp.validClients[i].vpos, aimAngles);         // this gives me the wrong x angle``````

#### NTvalk

##### Hacker
Obviously, got that part, but this:

Ohh i see sorry, you mean this function?
C++:
``````void CMaths::VectorAngles(const vec3_t value1, vec3_t angles) {
float flTmp, flYaw, flPitch;
if (value1[2] == 0 && value1[0] == 0)
{
flYaw = 0;
flPitch = 270;
}
else
{
flYaw = (atan2(value1[2], -value1[0]) * 180.f / 3.14159265358979323846) - 180.f;
if (flYaw < 0)
{
flYaw += 360.f;
}

flTmp = sqrt(value1[0] * value1[0] + value1[2] * value1[2]);
flPitch = (atan2(value1[1], flTmp) * 180.f / 3.14159265358979323846);

if (flPitch < 0)
{
flPitch += 360.f;
}
}
angles[0] = flPitch;
angles[1] = flYaw;
angles[2] = 0;
}``````

#### TastyHorror

##### Coder
Legacy Donator
After looking at this my brain is in pain. Why not debug and see which part does not calculate properly? Assuming everything else is correct but your math. Nonetheless, I am sure c5 will respond.

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
Your vectorangles looks ok from here, but don't count on that. I'd rewrite the whole thing with using magnitude or dot product. See if that results the same things, so you know your positions or seomthing else is off.

#### NTvalk

##### Hacker
allright so when i use this w2s function

C++:
``````bool CMaths::WorldToScreen(vec3_t WorldLocation, vec3_t mypos, vec3_t viewAngles, vec3_t oaim, int screencenter[2], float fov[2])
{
Vect3d vLocal;
Vect3d vTransForm;
vec3_t aimAngles,vector3;

v3Right = new Vect3d;
v3Forward = new Vect3d;
v3Upward = new Vect3d;

AngleVectors1(viewAngles);
vLocal = SubVectorDistV(WorldLocation, mypos);

vTransForm.x = vLocal.dotproduct(*v3Right);
vTransForm.y = vLocal.dotproduct(*v3Upward);
vTransForm.z = vLocal.dotproduct(*v3Forward);

if (vTransForm.z < 0.01)
return false;

// how do i calculate the aim angle? :S
oaim[0] = vTransForm.x / 5.1;

printf("aim x : %f\n", oaim[0]);
system("cls");

// these work good and give me the screen (2d) coordinates
screenX = screencenter[0] + (screencenter[0] / vTransForm.z * (1 / fov[0])) * vTransForm.x;
screenY = screencenter[1] - (screencenter[1] / vTransForm.z * (1 / fov[1])) * vTransForm.y;

return true;
}``````
When i do
C++:
``oaim[0] = vTransForm.x / 5.1;``
It almost works, but ofc i dont want this, but i dont know what else i can do...
this is actually making me crazy...

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
What the hell are you doing, I suggest reading up on some trigonomtery and vectors. Calculating screen position won't help you much in finding the angle to aim at, nor will randomly dividing by 5.1 help (made me chuckle tbh).

Aimbot math isn't that difficult, since you only need 2 angles you can do calculations on just 2 planes. If you are actually up to learning: Try doing an X axis based aimbot first and later add Y axis, that way it should be easier to comprehend the whole math that has to be done. So draw a vector from you to enemy on X plane, then add directional vector, normalize and get an angle between them (many ways to do so). Test and debug along the way so you'll get a better idea of what's going on, what I just said isn't exactly 100% accuratr but mh it's a start for you.

S

#### SomeGuy

##### Guest
What the hell are you doing, I suggest reading up on some trigonomtery and vectors. Calculating screen position won't help you much in finding the angle to aim at, nor will randomly dividing by 5.1 help (made me chuckle tbh).

Aimbot math isn't that difficult, since you only need 2 angles you can do calculations on just 2 planes. If you are actually up to learning: Try doing an X axis based aimbot first and later add Y axis, that way it should be easier to comprehend the whole math that has to be done. So draw a vector from you to enemy on X plane, then add directional vector, normalize and get an angle between them (many ways to do so). Test and debug along the way so you'll get a better idea of what's going on, what I just said isn't exactly 100% accuratr but mh it's a start for you.
+1

#### NTvalk

##### Hacker
What the hell are you doing, I suggest reading up on some trigonomtery and vectors. Calculating screen position won't help you much in finding the angle to aim at, nor will randomly dividing by 5.1 help (made me chuckle tbh).

Aimbot math isn't that difficult, since you only need 2 angles you can do calculations on just 2 planes. If you are actually up to learning: Try doing an X axis based aimbot first and later add Y axis, that way it should be easier to comprehend the whole math that has to be done. So draw a vector from you to enemy on X plane, then add directional vector, normalize and get an angle between them (many ways to do so). Test and debug along the way so you'll get a better idea of what's going on, what I just said isn't exactly 100% accuratr but mh it's a start for you.
allright... i will start all over. i think its way easier than i think it is.

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
allright... i will start all over. i think its way easier than i think it is.
Just cool head and patience, where people go wrong is they start overthinking things: "ermahgerd ermahgerd i have 2xXYZ and radians wat to do", when it actually can be super easy (arc tan and a few other calculations - done). Progress step by step, don't take too big jumps and if necessarity draw stuff out on paper.

My 2 cents

#### Liduen

##### Hacker
Dank Tier VIP
I use these maths for my aimbot and they work fine.
C#:
``````//x view angle
a = xPlayer - xEnemy;
b = yPlayer - yEnemy;
angle = Math.Atan(b / a) / Math.PI * 180;
if (a > 0) angle = angle - 180;

//y view angle
c = Math.Sqrt(a * a + b * b);
a = zPlayer - (zEnemy + ((predict[target, 2] - predict[eigenePlayerNummer, 2]) * ausgleich));
angle = Math.Atan(a / c) / Math.PI * 180;``````
idk if this helps, if it doesn't just ignore it, I'm still a newbie ^^

Last edited:

#### NTvalk

##### Hacker
I use these maths for my aimbot and they work fine.
C#:
``````//x view angle
xangle = Math.Atan((yPlayer - yEnemy) / (xPlayer - xEnemy)) / Math.PI * 180;
if (a > 0) angle - 180;

//y view angle
yangle = Math.Atan((zPlayer - zEnemy) / (Math.Sqrt(a * a + b * b))) / Math.PI * 180;``````
idk if this helps, if it doesn't just ignore it, I'm a still a newbie ^^
Yes it try'd this too, but it doesn't give me the angle compared to where i am looking at. I mean, when i move to the left from him my angle gets bigger, which is good but when i just look to the left it doesnt get bigger.
Appreciate ur help.

#### TastyHorror

##### Coder
Legacy Donator
Maybe you should either post full source or go back to the basics.