Solved Aimbot Math Trigonometry

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
I've been at this for a week now, and I finally understand trigonometry enough to get a majority of the math. I've pieced together a lot of source, and learned a lot. My only issue is trying to set up the aimbot maths. A lot of them include after atan2(deltaX/deltaY) more math such as * 180 / 3.14 + 180.0f;

Aimbot Math.png
Pic Here
(My beautiful drawing)

For the piece I drew, the math would be tan YAW = O/A
From maxdd's aimbot geometry tutorial, the YAW = tan((src[0] - dst[0]) / (src[1] - dst[1]))

He uses angles[0] = 90.0f + (float)(atan2f(deltaX, deltaZ) * 57.29577513082f); for getting the YAW in AssaultCube. My issue is when I use this, if I'm left and going left of the enemy, it pushes the camera further left. Same with right and going right.

I'm not quite sure how to fix this, and I've tried just about everything I can think of. (Including different methods from maxdd's). My big question here is how do I solve for each of the sectors? I can get the first part, it's the putting it in the specific range that I'm having trouble with (0 - 90, 90 - 180, 180 - 270, 270 - 360).

The yaw goes from 0-360, and pitch from -90 to 90 (I have the pitch working).
 
Last edited:

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,098
78,998
2,372
I have know idea if this will help but I was reading about it last night
Is Assault cube based on left or right handed cartesian coordinate system?
The Unreal Engine uses a left-handed Cartesian coordinate system, so by definition the positive Y axis is on the right side. ("left-hand rule": if the index finger of your left hand points forward, the thumb upwards, then the middle finger must point to the right)
First apply the yaw component by rotating around the Z axis (the thumb) to the right for positive or left for negative values. (turn the index finger towards the middle finger for positive values)
 

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
From what that looks like, I think left. The yaw never goes negative, though. So maybe I should go from +360, to +90, to +180, to +270?

EDIT:
I was able to finally solve it. I had to change the "* 180.0f " after each atanf to a negative, then change the math for two of the sectors. Here is the working math for OpenGL aimbots (Where it's XYZ, not XZY).

Credits to a TON of sources on the internet. This is a mashup of a lot of different people works.

C++:
void CalcAngle(float *src, float *dst, float *angles)
{
	float deltaX = (src[0]) - (dst[0]);
	float deltaY = (src[1]) - (dst[1]);

	if ((dst[0]) > (src[0]) && (dst[1]) <= (src[1])) 
	{
		angles[0] = atanf(deltaX/deltaY) * -180.0f / pi;
	} 
	
	else if((dst[0]) >= (src[0]) && (dst[1]) > (src[1])) 
	{
		angles[0] = atanf(deltaX/deltaY) * -180.0f / pi + 180.0f;
	}
	
	else if((dst[0]) < (src[0]) && (dst[1]) >= (src[1])) 
	{
		angles[0] = atanf(deltaX/deltaY) * -180.0f / pi - 180.0f;
	}
	
	else if((dst[0]) <= (src[0]) && (dst[1]) < (src[1]))
	{
		angles[0] = atanf(deltaX/deltaY) * -180.0f / pi + 360.0f;
	}

	float deltaZ = (dst[2]) - (src[2]);
    float dist = sqrt(
				 pow(double(dst[0] - src[0]), 2.0) +
				 pow(double(dst[1] - src[1]), 2.0) +
				 pow(double(dst[2] - src[2]), 2.0));
	
	angles[1] = asinf(deltaZ/dist) * 180.0f / pi;
}


This has been a very amazing learning experience, and I'm glad I was finally able to solve it! I hope anyone who experiences the same issues is able to take from this code and learn.
 
Last edited:

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
In regard to viewangles
X,Y,Z = Pitch, Yaw, Roll
Angle[0] = Pitch
Angle[1] = Yaw
Angle[2] = Roll

That's how your aimbot works with assault cube correct?
I only use the first two angles, and write 8 bytes instead of 12. The last isn't really needed. angles[0] is the Yaw (Left-Right), angles[1] is the Pitch (Up-Down). The XYZ used in the calc angle are the players positions. In data, the viewangles are stored mouseX, then mouseY, then roll.
 
Attention! Before you post:

Read the How to Ask Questions Guide
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
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods