- Game Name
- CSGO and assaultcube for this example

- Anticheat
- N/A

- Tutorial Link
- N/A

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

- Coding Language
- C++

In my experience I have used 5-6 different CalcAngle functions, every time you start a new game it's annoying to figure it out.

I'm working on creating a "universal" CalcAngle mechanism, or a CalcAngle generator. It would generate the correct CalcAngle function and the correct Normalize function for your game.

Basically you input the address of your view angles, it will bruteforce the min and max values and then generate the correct CalcAngle based on the min and max values.

To start this process I am working with CSGO and AssaultCube.

This is the current data and the correct CalcAngle functions for each game:

pitch = x [0] = -89.0 to 89.0 up is -89.0, down is +89.0 total of 180

yaw = y [1] = -179.99 to 179.9 increases as your rotate left, total of 360

pitch = y [1] = -90 to +90 down is -90, total of 180

yaw = x [0] = 0 to 360 increases as you rotate right, total of 360

Obvious difference:

pitch and yaw and swapped positions in the vec3

What's interesting is the range for pitch in both games includes negative and positive numbers, but one game requires you to change the sign of the resulting pitch value which I thought was really wierd. Any ideas here?

Similarly the Yaw, you have to change the sign of one but not the other, they both have a total range of 360 degress, but one includes a range of negative and positive numbers and the other includes only positive numbers.

So I have to figure out how to figure out when to negate the result based on the ranges (the min & max values for each angle)

Lastly, when you get the difference between your current angle and the aimbot angle to do a comparison, for the purpose of finding the closest enemy to your crosshair you need to normalize the results. I have already come up with a function which works on both games:

I am curious if you guys have any tips or advice

I'm working on creating a "universal" CalcAngle mechanism, or a CalcAngle generator. It would generate the correct CalcAngle function and the correct Normalize function for your game.

Basically you input the address of your view angles, it will bruteforce the min and max values and then generate the correct CalcAngle based on the min and max values.

To start this process I am working with CSGO and AssaultCube.

This is the current data and the correct CalcAngle functions for each game:

**CSGO**pitch = x [0] = -89.0 to 89.0 up is -89.0, down is +89.0 total of 180

yaw = y [1] = -179.99 to 179.9 increases as your rotate left, total of 360

C++:

```
vec3 CalcAngle(vec3 src, vec3 dst)
{
vec3 angles;
vec3 delta = dst - src;
float hyp = delta.Length();
angles.v[PITCH] = -RadToDeg(asinf(delta.v[ROLL] / hyp));
angles.v[YAW] = RadToDeg(atan2f(delta.v[YAW], delta.v[PITCH]));
angles.v[ROLL] = 0.0f;
return angles;
}
```

**AssaultCube**pitch = y [1] = -90 to +90 down is -90, total of 180

yaw = x [0] = 0 to 360 increases as you rotate right, total of 360

C++:

```
vec CalcAngle(vec src, vec dst)
{
vec angles;
vec delta = Subtract(src, dst);
float hyp = delta.Length();
//AC
angles.v[PITCH] = RadToDeg(asinf(delta.v[ROLL] / hyp));
angles.v[YAW] = -RadToDeg(atan2f(delta.v[YAW], delta.v[PITCH])) + 180.0f;
angles.v[ROLL] = 0.0f;
return angles;
}
```

pitch and yaw and swapped positions in the vec3

What's interesting is the range for pitch in both games includes negative and positive numbers, but one game requires you to change the sign of the resulting pitch value which I thought was really wierd. Any ideas here?

Similarly the Yaw, you have to change the sign of one but not the other, they both have a total range of 360 degress, but one includes a range of negative and positive numbers and the other includes only positive numbers.

So I have to figure out how to figure out when to negate the result based on the ranges (the min & max values for each angle)

Lastly, when you get the difference between your current angle and the aimbot angle to do a comparison, for the purpose of finding the closest enemy to your crosshair you need to normalize the results. I have already come up with a function which works on both games:

C++:

```
vec3 NormalizeDiff(vec3 src, vec3 dst, float xmin, float xmax, float ymin, float ymax)
{
vec3 diff = dst - src;
if (diff.x > xmax)
diff.x -= 360;
if (diff.x < xmin)
diff.x += 360;
if (diff.y > ymax)
diff.y -= 360;
if (diff.y < ymin)
diff.y += 360;
return diff;
}
```