Solved Calculating angle to enemy

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,061
78,998
2,370
I'm having a problem calculating angle from my local player to the enemy. I have spent 3 weeks on this and am losing my mind. I have re-written the entire aimbot 12 times, applied it to 2 different games and I get the same shitty result each time. It will aim correctly 20% of the time and other times it does not. This is one of the 12 source codes I have. I have tried with vectors, I have tried with arrays of floats, I have tried with about 15 different functions I have found on the internet and I've even tried GingerBreadMan's function that works perfectly for him. Someone save me from this hell, I've seriously spent like 30-50 hours on this. I turn on the aimbot with Numpad1 and it sets the aimangle to the target when I press Numpad2.

VectorAimbotIncludes.h
C++:
#include <Windows.h>
#include <iostream>
#include <string>
#include <ctime>
#include <tlhelp32.h>
#include <tchar.h>
#include <math.h>
using namespace std;
typedef DWORD OFFSET;

#define PI 					(3.1415926535897932f);
#define SMALL_NUMBER		(1.e-8f);
#define M_RADPI				(57.295779513082f);
HANDLE hProcHandle = NULL;


LPCSTR LGameWindow = "AssaultCube";
string sGameStatus = "Game Not Found";
bool bGameAvail;
bool bUpdateDisplay;

bool bAimbotStatus;
string sAimbotStatus = "OFF";

UINT_PTR NumOfPlayersAddress;
int NumOfPlayers;
UINT_PTR LocalPlayerPointer = 0x509B74;
UINT_PTR OtherPlayerArrayPointer = 0x510D90;
UINT_PTR OtherPlayerArrayAddress;
UINT_PTR OtherPlayerArray[31];//?


void PrintToConsole();
UINT_PTR dwGetModuleBaseAddress(UINT_PTR dwProcID, TCHAR *szModuleName);
UINT_PTR CalculatePointer(HANDLE hProcHandle, int PointerLevel, UINT_PTR Offsets[], UINT_PTR BaseAddress);
void UpdateAddresses(HANDLE hProcHandle, DWORD dwProcId);


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

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

float Get3dDistance(Vec3_AC_POS to, Vec3_AC_POS from);

DWORD_PTR dwGetModuleBaseAddress(DWORD dwProcID, TCHAR *szModuleName)
{
	DWORD_PTR dwModuleBaseAddress = 0;
	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwProcID);
	if (hSnapshot != INVALID_HANDLE_VALUE)
	{
		MODULEENTRY32 ModuleEntry32;
		ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
		if (Module32First(hSnapshot, &ModuleEntry32))
		{
			do
			{
				if (_tcsicmp(ModuleEntry32.szModule, szModuleName) == 0)
				{
					dwModuleBaseAddress = (DWORD_PTR)ModuleEntry32.modBaseAddr;
					break;
				}
			} while (Module32Next(hSnapshot, &ModuleEntry32));
		}
		CloseHandle(hSnapshot);
	}
	return dwModuleBaseAddress;
}

DWORD CalculatePointer(HANDLE hProcHandle, int PointerLevel, DWORD Offsets[], DWORD BaseAddress)
{
	DWORD Pointer = BaseAddress;
	DWORD TempBuffer;

	DWORD PointerAddress;
	for (int i = 0; i < PointerLevel; i++)
	{
		if (i == 0)
		{
			ReadProcessMemory(hProcHandle, (LPCVOID)Pointer, &TempBuffer, 4, NULL);
		}

		PointerAddress = TempBuffer + Offsets[i];
		ReadProcessMemory(hProcHandle, (LPCVOID)PointerAddress, &TempBuffer, 4, NULL);
	}
	return PointerAddress;
}

float Get3dDistance(Vec3_AC_POS to, Vec3_AC_POS 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))
		));
}

void PrintToConsole()
{
	{
		system("cls");
		cout << "----------------------------------------------------" << endl;
		cout << "                GuidedHacking.com                   " << endl;
		cout << "        AnomanderRake's Assault Cube Aimbot         " << endl;
		cout << "----------------------------------------------------" << endl << endl;
		cout << "GAME STATUS: " << sGameStatus << "   " << endl << endl;
		cout << "[NUMPAD1] Aimbot             -> " << sAimbotStatus << " <-" << endl << endl;
		cout << "[INSERT] Exit" << endl << endl;
		cout << "---------------------------------------------------" << endl;

		bUpdateDisplay = false;
	}
}
main.cpp
C++:
#include "VectorAimbotIncludes.h"

Vec3_AC_ANGLE CalcAngle(Vec3_AC_POS src, Vec3_AC_POS dst);

struct BestTarget_struct
{
	UINT_PTR PlayerAddress;
	char Name[16];
	BYTE Team;
	int Health;
	float fLocation[3];//
	float fAimbotAngles[3];//
	Vec3_AC_POS vLocation;
	Vec3_AC_ANGLE vAimbotAngles;
	float DistanceFromMe;

}BestTarget;


struct LocalPlayer_struct
{
	UINT_PTR PlayerAddress;
	char Name[16];
	BYTE Team;
	int Health;
	float fLocation[3];//
	float fAimbotAngles[3];//
	Vec3_AC_POS vLocation;
	Vec3_AC_ANGLE vAimbotAngles;

	void ReadInformation()
	{
		ReadProcessMemory(hProcHandle, (LPCVOID)(LocalPlayerPointer), &PlayerAddress, 4, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x225), &Name, 16, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x32c), &Team, 1, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0xF8), &Health, 4, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &vLocation, 12, NULL);//vector
		//ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &fLocation, 12, NULL);//float
	}

}LocalPlayer;

struct OtherPlayers_struct
{
	UINT_PTR PlayerAddress;
	char Name[16];
	BYTE Team;
	int Health;
	float fLocation[3];//
	float fAimbotAngles[3];//
	Vec3_AC_POS vLocation;
	Vec3_AC_ANGLE vAimbotAngles;
	float DistanceFromMe;

	void ReadInformation(int i)
	{
		ReadProcessMemory(hProcHandle, (LPCVOID)OtherPlayerArrayPointer, &OtherPlayerArrayAddress, 4, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(OtherPlayerArrayAddress + (i * 4)), &PlayerAddress, 4, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x225), &Name, 16, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x32c), &Team, 1, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0xF8), &Health, 4, NULL);
		ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &vLocation, 12, NULL);//vector
		//ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &fLocation, 12, NULL);//float

		if (bAimbotStatus && Health > 1)
		{
			vAimbotAngles = CalcAngle(LocalPlayer.vLocation, OtherPlayer[i].vLocation);

			//For debugging purposes I'm only calculating the angle for the first enemy.
			if (i == 0)
			{
				BestTarget.vAimbotAngles = OtherPlayer[i].vAimbotAngles;
			}

		}


	}

}OtherPlayer[31];



int main()
{
	SetConsoleTitle("AnomanderRake's AssaultCube Aimbot");
	system("mode 53, 30");

	HWND hGameWindow = NULL;
	DWORD dwProcId = NULL;

	int timeSinceLastUpdate = clock();
	int GameAvailTMR = clock();
	int KeyPressTimer = clock();
	bUpdateDisplay = true;

	while (!GetAsyncKeyState(VK_INSERT)) //Main program loop
	{

		if (clock() - GameAvailTMR > 300)
		{
			GameAvailTMR = clock();
			bGameAvail = false;
			hGameWindow = FindWindow(NULL, LGameWindow);
			if (hGameWindow)
			{
				GetWindowThreadProcessId(hGameWindow, &dwProcId);

				if (dwProcId)
				{

					hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcId);
					if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
					{
						sGameStatus = "Can't open process";
					}
					else
					{
						sGameStatus = "Process ID Found ac_client.exe Running";
						bGameAvail = true;
					}
				}
				else sGameStatus = "Failed to get procid";
			}
			else sGameStatus = "Assault Cube not running";

			if (bUpdateDisplay || clock() - timeSinceLastUpdate > 3000)
			{
				PrintToConsole();
				timeSinceLastUpdate = clock();
			}

			if (bGameAvail)
			{
				UpdateAddresses(hProcHandle, dwProcId);
			}
		}

		if (clock() - KeyPressTimer > 200)
		{
			if (bGameAvail)
			{

				//Turn aimbot on key
				if (GetAsyncKeyState(VK_NUMPAD1))
				{
					KeyPressTimer = clock();
					bAimbotStatus = !bAimbotStatus;
					bUpdateDisplay = true;
					if (bAimbotStatus)
					{
						sAimbotStatus = "ON";

					}
					else
					{
						sAimbotStatus = "OFF";
					}
				}

				//AimWhenPressedHotkey
				if (GetAsyncKeyState(VK_NUMPAD2))
				{
					KeyPressTimer = clock();
					//bAimStatus = !bAimStatus;
					bUpdateDisplay = true;
					if (bAimbotStatus)
					{

						
						WriteProcessMemory(hProcHandle, (PBYTE*)(LocalPlayer.PlayerAddress + 0x40), &BestTarget.vAimbotAngles, 8, 0);
					}
				}



			}
		}
	}//end of main program loop

	CloseHandle(hProcHandle);
	CloseHandle(hGameWindow);

	return ERROR_SUCCESS;
}




void UpdateAddresses(HANDLE hProcHandle, DWORD dwProcId)
{
	NumOfPlayersAddress = (dwGetModuleBaseAddress(dwProcId, _T("ac_client.exe"))) + 0x10F500;
	ReadProcessMemory(hProcHandle, (LPCVOID)NumOfPlayersAddress, &NumOfPlayers, 4, NULL);
	LocalPlayer.ReadInformation();

	for (int i = 0; i < NumOfPlayers; i++)
	{
		OtherPlayer[i].ReadInformation(i);
	}
}



Vec3_AC_ANGLE CalcAngle(Vec3_AC_POS src, Vec3_AC_POS dst)
{
	Vec3_AC_ANGLE angles;
	double delta[3] = { (src.x - dst.x), (src.y - dst.y), (src.z - dst.z) };
	double hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
	angles.pitch = (float)(asinf(delta[2] / hyp) * 57.295779513082f);
	angles.yaw = (float)(atanf(delta[1] / delta[0]) * 57.295779513082f);
	angles.roll = 0.0f;

	if (delta[0] >= 0.0)
	{
		angles.yaw += 180.0f;
	}
	
	return angles;
}
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,061
78,998
2,370
The game designer can choose what X Y and Z mean in his code. I thought these equaled the same thing in every game and that it was only the order they were listed in that could change. But reality from what we learned from this example is that X Y and Z can be any direction that the developer chooses. The developer chooses a cartesian coordinate system by defining the directions.

So here is an updated picture for Assault Cube:


Updated Coordinates Offset
+034 = LocationX - Move left and right
+038 = LocationY - Move forward and backwards
+03C = LocationZ - Move vertically up and down

And the definition straight from AC source code:

C++:
short x, y, z;  //position
2 Cool related links:

https://gamedev.stackexchange.com/questions/46225/why-is-y-up-in-many-games
https://gamedev.stackexchange.com/questions/13414/x-y-z-coordinate-standards

Thank you x100 GBM
 
Last edited:

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
C++:
struct Vec3_AC_POS
{
    float x, z, y;
};
AssaultCube has the Coords stored as X Y Z. You have it as X Z Y. That is part of the problem there :p. I'm not sure if the calcangle you're using is part of the problem or not. When I tried to use one that didn't have math for each separate sector, it caused issues.

EDIT:
Yep, that pretty much solved it. The only other thing I had to do was add 90 to the yaw and it works. One thing that I recommend; remove the "update screen" thing. It doesn't work with the aimbot because it updates constantly while the aimbot is turned on, causing it to be uselessly slow.

Here's the fixed code with comments where I changed something:
VectorAimbotIncludes.h
C++:
#include <Windows.h>
#include <iostream>
#include <string>
#include <ctime>
#include <tlhelp32.h>
#include <tchar.h>
#include <math.h>
using namespace std;
typedef DWORD OFFSET;
 
#define PI                  (3.1415926535897932f);
#define SMALL_NUMBER        (1.e-8f);
#define M_RADPI             (57.295779513082f);
HANDLE hProcHandle = NULL;
 
 
LPCSTR LGameWindow = "AssaultCube";
string sGameStatus = "Game Not Found";
bool bGameAvail;
bool bUpdateDisplay;
 
bool bAimbotStatus;
string sAimbotStatus = "OFF";
 
UINT_PTR NumOfPlayersAddress;
int NumOfPlayers;
UINT_PTR LocalPlayerPointer = 0x509B74;
UINT_PTR OtherPlayerArrayPointer = 0x510D90;
UINT_PTR OtherPlayerArrayAddress;
UINT_PTR OtherPlayerArray[31];//?
 
 
void PrintToConsole();
UINT_PTR dwGetModuleBaseAddress(UINT_PTR dwProcID, TCHAR *szModuleName);
UINT_PTR CalculatePointer(HANDLE hProcHandle, int PointerLevel, UINT_PTR Offsets[], UINT_PTR BaseAddress);
void UpdateAddresses(HANDLE hProcHandle, DWORD dwProcId);
 
 
struct Vec3_AC_POS
{
    float x, y, z;//XYZ, not XZY
};
 
struct Vec3_AC_ANGLE
{
    float yaw, pitch, roll;
};
 
float Get3dDistance(Vec3_AC_POS to, Vec3_AC_POS from);
 
DWORD_PTR dwGetModuleBaseAddress(DWORD dwProcID, TCHAR *szModuleName)
{
    DWORD_PTR dwModuleBaseAddress = 0;
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwProcID);
    if (hSnapshot != INVALID_HANDLE_VALUE)
    {
        MODULEENTRY32 ModuleEntry32;
        ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
        if (Module32First(hSnapshot, &ModuleEntry32))
        {
            do
            {
                if (_tcsicmp(ModuleEntry32.szModule, szModuleName) == 0)
                {
                    dwModuleBaseAddress = (DWORD_PTR)ModuleEntry32.modBaseAddr;
                    break;
                }
            } while (Module32Next(hSnapshot, &ModuleEntry32));
        }
        CloseHandle(hSnapshot);
    }
    return dwModuleBaseAddress;
}
 
DWORD CalculatePointer(HANDLE hProcHandle, int PointerLevel, DWORD Offsets[], DWORD BaseAddress)
{
    DWORD Pointer = BaseAddress;
    DWORD TempBuffer;
 
    DWORD PointerAddress;
    for (int i = 0; i < PointerLevel; i++)
    {
        if (i == 0)
        {
            ReadProcessMemory(hProcHandle, (LPCVOID)Pointer, &TempBuffer, 4, NULL);
        }
 
        PointerAddress = TempBuffer + Offsets[i];
        ReadProcessMemory(hProcHandle, (LPCVOID)PointerAddress, &TempBuffer, 4, NULL);
    }
    return PointerAddress;
}
 
float Get3dDistance(Vec3_AC_POS to, Vec3_AC_POS 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))
        ));
}
 
void PrintToConsole()
{
    {
        system("cls");
        cout << "----------------------------------------------------" << endl;
        cout << "                GuidedHacking.com                   " << endl;
        cout << "        AnomanderRake's Assault Cube Aimbot         " << endl;
        cout << "----------------------------------------------------" << endl << endl;
        cout << "GAME STATUS: " << sGameStatus << "   " << endl << endl;
        cout << "[NUMPAD1] Aimbot             -> " << sAimbotStatus << " <-" << endl << endl;
        cout << "[INSERT] Exit" << endl << endl;
        cout << "---------------------------------------------------" << endl;
 
        bUpdateDisplay = false;
    }
}
main.cpp
C++:
#include "VectorAimbotIncludes.h"
 
Vec3_AC_ANGLE CalcAngle(Vec3_AC_POS src, Vec3_AC_POS dst);
 
struct BestTarget_struct
{
    UINT_PTR PlayerAddress;
    char Name[16];
    BYTE Team;
    int Health;
    float fLocation[3];//
    float fAimbotAngles[3];//
    Vec3_AC_POS vLocation;
    Vec3_AC_ANGLE vAimbotAngles;
    float DistanceFromMe;
 
}BestTarget;
 
 
struct LocalPlayer_struct
{
    UINT_PTR PlayerAddress;
    char Name[16];
    BYTE Team;
    int Health;
    float fLocation[3];//
    float fAimbotAngles[3];//
    Vec3_AC_POS vLocation;
    Vec3_AC_ANGLE vAimbotAngles;
 
    void ReadInformation()
    {
        ReadProcessMemory(hProcHandle, (LPCVOID)(LocalPlayerPointer), &PlayerAddress, 4, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x225), &Name, 16, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x32c), &Team, 1, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0xF8), &Health, 4, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &vLocation, 12, NULL);//vector
        //ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &fLocation, 12, NULL);//float
    }
 
}LocalPlayer;
 
struct OtherPlayers_struct
{
    UINT_PTR PlayerAddress;
    char Name[16];
    BYTE Team;
    int Health;
    float fLocation[3];//
    float fAimbotAngles[3];//
    Vec3_AC_POS vLocation;
    Vec3_AC_ANGLE vAimbotAngles;
    float DistanceFromMe;
 
    void ReadInformation(int i)
    {
        ReadProcessMemory(hProcHandle, (LPCVOID)OtherPlayerArrayPointer, &OtherPlayerArrayAddress, 4, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(OtherPlayerArrayAddress + (i * 4)), &PlayerAddress, 4, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x225), &Name, 16, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x32c), &Team, 1, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0xF8), &Health, 4, NULL);
        ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &vLocation, 12, NULL);//vector
        //ReadProcessMemory(hProcHandle, (LPCVOID)(PlayerAddress + 0x34), &fLocation, 12, NULL);//float
 
        if (bAimbotStatus && Health > 1)
        {
            vAimbotAngles = CalcAngle(LocalPlayer.vLocation, OtherPlayer[i].vLocation);
 
            //For debugging purposes I'm only calculating the angle for the first enemy.
            if (i == 0)
            {
                BestTarget.vAimbotAngles = OtherPlayer[i].vAimbotAngles;
            }
 
        }
 
 
    }
 
}OtherPlayer[31];
 
 
 
int main()
{
    SetConsoleTitle("AnomanderRake's AssaultCube Aimbot");
    system("mode 53, 30");
 
    HWND hGameWindow = NULL;
    DWORD dwProcId = NULL;
 
    int timeSinceLastUpdate = clock();
    int GameAvailTMR = clock();
    int KeyPressTimer = clock();
    bUpdateDisplay = true;
 
    while (!GetAsyncKeyState(VK_INSERT)) //Main program loop
    {
 
        if (clock() - GameAvailTMR > 300)
        {
            GameAvailTMR = clock();
            bGameAvail = false;
            hGameWindow = FindWindow(NULL, LGameWindow);
            if (hGameWindow)
            {
                GetWindowThreadProcessId(hGameWindow, &dwProcId);
 
                if (dwProcId)
                {
 
                    hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcId);
                    if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
                    {
                        sGameStatus = "Can't open process";
                    }
                    else
                    {
                        sGameStatus = "Process ID Found ac_client.exe Running";
                        bGameAvail = true;
                    }
                }
                else sGameStatus = "Failed to get procid";
            }
            else sGameStatus = "Assault Cube not running";
 
            if (bUpdateDisplay || clock() - timeSinceLastUpdate > 3000)
            {
                PrintToConsole();
                timeSinceLastUpdate = clock();
            }
 
            if (bGameAvail)
            {
                UpdateAddresses(hProcHandle, dwProcId);
            }
        }
 
        if (clock() - KeyPressTimer > 200)
        {
            if (bGameAvail)
            {
 
                //Turn aimbot on key
                if (GetAsyncKeyState(VK_NUMPAD1))
                {
                    KeyPressTimer = clock();
                    bAimbotStatus = !bAimbotStatus;
                    bUpdateDisplay = true;
                    if (bAimbotStatus)
                    {
                        sAimbotStatus = "ON";
 
                    }
                    else
                    {
                        sAimbotStatus = "OFF";
                    }
                }
 
                //AimWhenPressedHotkey
                if (GetAsyncKeyState(VK_NUMPAD2))
                {
                    KeyPressTimer = clock();
                    //bAimStatus = !bAimStatus;
                    bUpdateDisplay = true;
                    if (bAimbotStatus)
                    {
 
                         
                        WriteProcessMemory(hProcHandle, (PBYTE*)(LocalPlayer.PlayerAddress + 0x40), &BestTarget.vAimbotAngles, 8, 0);
                    }
                }
 
 
 
            }
        }
    }//end of main program loop
 
    CloseHandle(hProcHandle);
    CloseHandle(hGameWindow);
 
    return ERROR_SUCCESS;
}
 
 
 
 
void UpdateAddresses(HANDLE hProcHandle, DWORD dwProcId)
{
    NumOfPlayersAddress = (dwGetModuleBaseAddress(dwProcId, _T("ac_client.exe"))) + 0x10F500;
    ReadProcessMemory(hProcHandle, (LPCVOID)NumOfPlayersAddress, &NumOfPlayers, 4, NULL);
    LocalPlayer.ReadInformation();
 
    for (int i = 0; i < NumOfPlayers; i++)
    {
        OtherPlayer[i].ReadInformation(i);
    }
}
 
 
 
Vec3_AC_ANGLE CalcAngle(Vec3_AC_POS src, Vec3_AC_POS dst)
{
    Vec3_AC_ANGLE angles;
    double delta[3] = { (src.x - dst.x), (src.y - dst.y), (src.z - dst.z) };
    double hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
    angles.pitch = (float)(asinf(delta[2] / hyp) * 57.295779513082f);
    angles.yaw = (float)(atanf(delta[1] / delta[0]) * 57.295779513082f);
    angles.roll = 0.0f;
 
    if (delta[0] >= 0.0)
    {
        angles.yaw += 180.0f;
    }
     
	angles.yaw += 90;//this moves the camera on to the player, otherwise you go in a circle around them
					 //(kinda fun to do that though, if you ask me :P)

    return angles;
}
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,061
78,998
2,370
Thanks you GBM I will be trying that out right away, and I noticed the UpdateScreen thing also

In AC I have Location listed as offsets:
+034 = LocationX - Move left and right
+038 = LocationZ - Move forward and backwards
+03C = LocationY - Move vertically up and down

Because of this:


But you're telling my AC stores location as X, Y then Z.
So who is wrong the picture or you? Or am I fucking retarded
 
Last edited:

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
I believe I read somewhere that in D3D games it's stored as XZY (that would be most). In other types, such as OpenGL, it's XYZ. Where in both situations Z is the Up/Down coordinates. This is mostly a guess, but it's worked so far for me. The best way to check what type your game is, is to go into memory and look at the three floats in the data/structure dissector in Cheat Engine. Jump up and down and if the one in the middle changes it's XZY. Otherwise, it's most likely XYZ.
 
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