Solved Assault Cube Aimbot Math Help

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

insaneFTW

Newbie
Jun 8, 2013
2
299
1
I have been trying to make a AssaultCube aimbot for about 2 days now, and for some reason it won't point in the correct direction. At first I tried to make it look neat and organized but I scrapped that and attempted to make the most barebones aimbot to make debugging it easier. Now going onto the 3 day of debugging and trying new forumlas to get the angle I have come here for some help.

I will admit the code is cluttered and a mess from trying different things, in fact I restarted it just to make it more barebones.


Source File
C++:
#include "AimbotMath.h"
#include <Windows.h>
#include <iostream>
#include <cmath>
#include <algorithm>



using namespace std;


float PI = 3.14;



int main()
{
	HWND gamewindow = FindWindowA(NULL, "AssaultCube");
	if (!gamewindow)
	{
		cout << "_Window_\n";
		Sleep(3000);
		return NULL;
	}

	DWORD ProcId;
	GetWindowThreadProcessId(gamewindow, &ProcId);
	if (!ProcId)
	{
		cout << "_ProcId_\n";
		Sleep(3000);
		return NULL;
	}

	HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, NULL, ProcId);
	if (!handle)
	{
		cout << "_Handle_\n";
		Sleep(3000);
		return NULL;
	}


	//Varuables
	DWORD PlayerBase = 0x509B74;

	DWORD Health = 0xF8;

	DWORD XCoord = 0x38;
	DWORD YCoord = 0x3C;
	DWORD ZCoord = 0x34;

	DWORD XMouseAngle = 0x40;
	DWORD YMouseAngle = 0x44;

	DWORD EnemyPlayerBase = 0x510D90;

	Vec3Pos PlayerPosition;
	Vec3Angle PlayerAngle;

	Vec3Pos EnemyPosition;
	Vec3Angle NewAngles;

	int health;
	bool Cheat = false;

	while (1)
	{

		if (!handle)
		{
			cout << "Couldn't Get handle anymore!\n";
			Sleep(3000);
			return NULL;
		}



		//Toggles cheat
		if (GetAsyncKeyState(VK_NUMPAD1) && 1)
		{
			if (!Cheat)
			{
				Cheat = true;
				cout << "On!\n";
				Sleep(300);
			}
			else
				if (Cheat)
				{
					Cheat = false;
					cout << "Off!\n";
					Sleep(300);
				}
		}

		//Turns App off
		if (GetAsyncKeyState(VK_NUMPAD9) && 1)
		{
			break;
		}


		//If cheat is on, activate cheat
		if (Cheat == true)
		{

			DWORD EnemyLocalBase;
			DWORD GetEntity;

			DWORD PlayerLocalBase;

			float EnemyX, EnemyY, EnemyZ;
			float AngleX, AngleY;
			float PlayerX, PlayerY, PlayerZ;

			//PlayerBase
			ReadProcessMemory(handle, (LPVOID)(PlayerBase), &PlayerLocalBase, sizeof(DWORD), NULL);

			//Player Angle
			ReadProcessMemory(handle, (LPVOID)(PlayerLocalBase + XMouseAngle), &AngleX, sizeof(float), NULL);
			ReadProcessMemory(handle, (LPVOID)(PlayerLocalBase + YMouseAngle), &AngleY, sizeof(float), NULL);

			//PlayerCoords
			ReadProcessMemory(handle, (LPVOID)(PlayerLocalBase + XCoord), &PlayerX, sizeof(float), NULL);
			ReadProcessMemory(handle, (LPVOID)(PlayerLocalBase + YCoord), &PlayerY, sizeof(float), NULL);
			ReadProcessMemory(handle, (LPVOID)(PlayerLocalBase + ZCoord), &PlayerZ, sizeof(float), NULL);


			PlayerPosition.x = PlayerX;
			PlayerPosition.y = PlayerY;
			PlayerPosition.z = PlayerZ;
			PlayerAngle.yaw = AngleX;
			PlayerAngle.pitch = AngleY;
			
			
			ReadProcessMemory(handle, (LPCVOID)(EnemyPlayerBase), &EnemyLocalBase, sizeof(DWORD), NULL);
			ReadProcessMemory(handle, (LPCVOID)(EnemyLocalBase + (0 * 0x4)), &GetEntity, sizeof(DWORD), NULL);
			//Enemy Health
			ReadProcessMemory(handle, (LPCVOID)(GetEntity + Health), &health, sizeof(int), NULL);

			//Enemy Coords
			ReadProcessMemory(handle, (LPCVOID)(GetEntity + XCoord), &EnemyX, sizeof(float), NULL);
			ReadProcessMemory(handle, (LPCVOID)(GetEntity + YCoord), &EnemyY, sizeof(float), NULL);
			ReadProcessMemory(handle, (LPCVOID)(GetEntity + ZCoord), &EnemyZ, sizeof(float), NULL);

			EnemyPosition.x = EnemyX;
			EnemyPosition.y = EnemyY;
			EnemyPosition.z = EnemyZ;

				
			NewAngles = CalcAngle(EnemyPosition, PlayerPosition);

			DifferenceOfAngles(NewAngles, PlayerAngle);
		
			cout << "Target: " << NewAngles.pitch << endl;
			cout << "Mouse X: " << PlayerAngle.pitch << endl;

			
			//This below is currently being commented out for debugging reasons


			//ReadProcessMemory(handle, (LPVOID)(PlayerBase), &PlayerLocalBase, sizeof(DWORD), NULL);
			
			//WriteProcessMemory(handle, (LPVOID)(PlayerLocalBase + 0x40), &NewAngles,sizeof(8), NULL);
			
			//WriteProcessMemory(handle, (LPVOID)(PlayerLocalBase + YMouseAngle), &PitchY, sizeof(float), NULL);
			Sleep(150);
		}//End of Cheat area





	}//End of While loop
	CloseHandle(handle);
	return 0;
}


Header
C++:
#include <algorithm>

#define Q_PI ( 3.1415927f )
#define QDegToRad(A) ( A * 180.0f / Q_PI )
#define QACUBE(A) ( A / Q_PI * 180.0f + 180.0f )


struct Vec3Pos
{
	float x, y, z;
};

struct Vec3Angle
{
	float yaw, pitch, roll;
};



float Get3dDistance(Vec3Pos to, Vec3Pos from)
{
	return (float)
		(sqrt(
		((to.x - from.x) * (to.x - from.x)) +
			((to.y - from.y) * (to.y - from.y)) +
			((to.z - from.z) * (to.z - from.z))
		));
}



Vec3Angle CalcAngle(Vec3Pos src, Vec3Pos dst)
{
	Vec3Angle angles;

	angles.yaw = QACUBE((-(float)atan2f(dst.x - src.x, dst.y - src.y)));
	angles.pitch = QDegToRad((atan2f(dst.z - src.z, Get3dDistance(src, dst))));
	angles.roll = 0.0f;

	return angles;
}


float DifferenceOfAngles(Vec3Angle vAngleToEnemy, Vec3Angle vLocalPlayerViewAngle)
{
	Vec3Angle vdifference;

	vdifference.pitch = vLocalPlayerViewAngle.pitch - vAngleToEnemy.pitch;
	vdifference.yaw = vLocalPlayerViewAngle.yaw - vAngleToEnemy.yaw;
	//vdifference.roll = 0;

	//normalize by making them positive values if they are negative
	if (vdifference.pitch < 0)
	{
		vdifference.pitch *= -1;
	}
	if (vdifference.yaw < 0)
	{
		vdifference.yaw *= -1;
	}

	//add them together and divide by 2, gives an average of the 2 angles
	float fDifference = (vdifference.pitch + vdifference.yaw) / 2;
	return fDifference;
}
I feel as tho I should mention credits to rake as I used him as a resource alot when trying to figure out what I did wrong, the header file was pretty much a copy paste although that was to save me time on making my own as what I wrote in the source file was very similar.

If more information is needed I will be on that as soon as possible, I can show screenshots.
To state the problem once again it seems the float variables that go through the calc angle are wrong although they match with cheat engine or the calc angle is giving me a weird answer for some unknown reason.

I passed trig a year ago in highschool but to be completely honest math is not my strongest point.
 

insaneFTW

Newbie
Jun 8, 2013
2
299
1
Never mind, I debugged it once again and found the answer to my problem.

Seems when using Rakes code I flipped Enemy and Player Position coords like a idiot. Found out by EVER so slowly going through the trig calc by hand
Not sure how closing a thread works so I clicked the little button (First post) if I did something wrong please notify me
 
Status
Not open for further replies.
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