Aimbot locking on ground

Posts 16–23 of 23 · Page 2 of 2
Quote Originally Posted by WasserEsser View Post
Post your entire code.
Code:
//AIMBOT CODE
int bonePosition = 6;

float flAngleNormalize(float angle)
{
	while (angle < -180)    angle += 360;
	while (angle > 180)    angle -= 360;
	return angle;
}
void ClampAngle(Vec3 &angles){
	angles.y = flAngleNormalize(angles.y);
	angles.x = flAngleNormalize(angles.x);
	if (angles.x > 89.0f)
		angles.x = 89.0f;
	if (angles.x < -89.0f)
		angles.x = -89.0f;

	angles.z = 0;

}

Vec3 BonePos(DWORD target, DWORD address, int boneId)
{
	DWORD boneBase = Mem.Read<DWORD>(target + address);
	Vec3 vBone;
	vBone.x = Mem.Read<float>(boneBase + 0x30 * boneId + 0x0C);
	vBone.y = Mem.Read<float>(boneBase + 0x30 * boneId + 0x1C);
	vBone.z = Mem.Read<float>(boneBase + 0x30 * boneId + 0x2C);
	return vBone;
}

void ClampAngles(Vec3 &angles)
{
	if (angles.x != angles.x)
	{
		angles.x = 0.0f;
	}
	if (angles.y != angles.y)
	{
		angles.y = 0.0f;
	}
	if (angles.x > 89.0f)
	{
		angles.x = 89.0f;
	}
	if (angles.x < -89.0f)
	{
		angles.x = -89.0f;
	}
	if (angles.y > 180.0f)
	{
		angles.y -= 360.0f;
	}
	if (angles.y < -180.0f)
	{
		angles.y += 180.0f;
	}
	angles.z = 0.0f;
}

void CalcAngle(Vec3 src, Vec3 dst, Vec3 &angles)
{
	Vec3 delta;
	delta.x = src.x - dst.x;
	delta.y = src.y - dst.y;
	delta.z = src.z - dst.z;
	double hyp = sqrt(delta.x * delta.x + delta.y * delta.y);

	angles.x = (float)(atan(delta.z / hyp) * 57.295779513082f);
	angles.y = (float)(atan(delta.y / delta.x) * 57.295779513082f);
	angles.z = 0.0f;

	if (delta.x >= 0.0)
		angles.y += 180.0f;
}


float Get3dDistance(float mycoordsX, float mycoordsZ, float mycoordsY, float enemycoordsX, float enemycoordsZ, float enemycoordsY)
{
	return sqrt(pow(double(enemycoordsX - mycoordsX), 2.0) +
		pow(double(enemycoordsY - mycoordsY), 2.0) +
		pow(double(enemycoordsZ - mycoordsZ), 2.0));
}

const double M_PI = 3.14159265358979323846; //  float: -3.4 × 1038 to +3.4 × 1038

void MakeVector(Vec3 pfin, Vec3& vector)
{
	float pitch = (float)(pfin.x * M_PI / 180);
	float yaw = (float)(pfin.y * M_PI / 180);
	float tmp = (float)(cos(pitch));

	vector.x = (float)(-tmp * -cos(yaw));
	vector.y = (float)(sin(yaw)*tmp);
	vector.z = (float)(-sin(pitch));
}

float GetFOV(Vec3 Angles, Vec3 Source, Vec3 Dst)
{
	Vec3 ang, aim;
	float fov;
	CalcAngle(Source, Dst, ang);
	MakeVector(Angles, aim);
	MakeVector(ang, ang);

	float mag_s = sqrt((aim.x * aim.x) + (aim.y * aim.y) + (aim.z * aim.z));
	float mag_d = sqrt((aim.x * aim.x) + (aim.y * aim.y) + (aim.z * aim.z));

	float u_dot_v = aim.x * ang.x + aim.y * ang.y + aim.z * ang.z;
	fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0f / M_PI);
	return fov;
}

int aimbone;
Vec3 position;
int index;
int ClosestEnemyToCrosshair(float maxfov)
{
	DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504);
	int LocalTeam = Mem.Read<int>(LocalPlayer + m_iTeamNum);
	for (int i = 0; i < 64; i++)
	{
		DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (i * 0x10));
		if (!entitybase) continue;
		if (entitybase == LocalPlayer)
			continue;
		bool entitydormant = Mem.Read<bool>(entitybase + isDormant);
		if (entitydormant)
			continue;
		int entityteam = Mem.Read<int>(entitybase + m_iTeamNum);

		if (entityteam == LocalTeam)
			continue;


		int entitylifestate = Mem.Read<byte>(entitybase + 0x25B); //is lifestate
		if (entitylifestate != 0)
			continue;

		DWORD Engine = Mem.Module("engine.dll");
		DWORD clientstate = Mem.Read<DWORD>(Engine + clientState);
		Vec3 currentangles = Mem.Read<Vec3>(clientstate + viewAngle);
		Vec3 pos = BonePos(entitybase, 0x2698, aimbone); //bonematrix
		float entitydistance = GetFOV(currentangles, position, pos);
		if (entitydistance < maxfov)
		{
			maxfov = entitydistance;
			index = i;
		}
	}
	return index;
}


void Aimbot()
{
	while (true)
	{
		for (int i = 0; i<48; i++)
		{
			DWORD Client = Mem.Module("client.dll");
			DWORD CurrentWeaponIndex = Mem.Read<DWORD>(LocalPlayer + m_hMyWeapons + ((i - 1) * 0x4)) & 0xFFF;
			DWORD CurrentWeaponEntity = Mem.Read<DWORD>(Client + EntityList + (CurrentWeaponIndex - 1) * 0x10);
			int CurrentWeaponId = Mem.Read<int>(CurrentWeaponEntity + m_iItemDefinitionIndex);
			int MyXuid = Mem.Read<int>(CurrentWeaponEntity + m_OriginalOwnerXuidLow);
			Mem.Write<int>(CurrentWeaponEntity + m_iItemIDHigh, -1); //When iItemIDHigh is set to non zero value, fallback values will be used.

			Mem.Write<int>(CurrentWeaponEntity + m_nFallbackPaintKit, 180);
			Mem.Write<int>(CurrentWeaponEntity + m_nFallbackSeed, 0);
			Mem.Write<int>(CurrentWeaponEntity + m_nFallbackStatTrak, 1337);
			Mem.Write<int>(CurrentWeaponEntity + m_iEntityQuality, 1);
			Mem.Write<float>(CurrentWeaponEntity + m_flFallbackWear, 0.001000);
			Mem.Write<int>(CurrentWeaponEntity + m_iAccountID, MyXuid);
		}
		while (GetAsyncKeyState(VK_MENU))
		{
			int entindex = ClosestEnemyToCrosshair(90.f);

			if (entindex == 0)
				continue;
			DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504);
			Vec3 origin = Mem.Read<Vec3>(LocalPlayer + 0x134);
			Vec3 vecview = Mem.Read<Vec3>(LocalPlayer + 0x104);
			position.x = origin.x + vecview.x;
			position.y = origin.y + vecview.y;
			position.z = origin.z + vecview.z;

			Vec3 punch = Mem.Read<Vec3>(LocalPlayer + 0x3018);
			Vec3 angles;

			DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (entindex * 0x10));
			Vec3 pos = BonePos(entitybase, 0x2698, bonePosition);

			CalcAngle(position, pos, angles);
			angles.x = angles.x - punch.x * 2.f;
			angles.y = angles.y - punch.y * 2.f;
			ClampAngles(angles);
			if (angles.x == 0 && angles.y == 0)
				continue;
			DWORD Engine = Mem.Module("engine.dll");
			DWORD clientstate = Mem.Read<DWORD>(Engine + clientState);
			Mem.Write<Vec3>(clientstate + 0x4D0C, angles);
		}
		Sleep(1);
	}
}
First of all, take a look at my answer over here, i see that you use the same code:

http://www.mpgh.net/forum/showthread...1#post11850527

You have two ClampAngle functions for no reason.

DWORD Engine = Mem.Module("engine.dll"); within a loop, this will slow everything down. Why would you iterate a snapshot of modules of your process each time you iterate through the loop? This is completely unnecessary since the base address of the module doesn't change unless you restart the game.

maxfov seems to be defined in global space, which means it's not being reset when the function is getting called again. Fix that by declaring it inside the function with a high default value.

if (entindex == 0)

In your case, entindex 0 is the very first player. Doing that will basically ignore the very first player every time which is not what you want.

DWORD Engine = Mem.Module("engine.dll"); within another loop. This will just slow everything down. Use it once at the start of your main and use that value throughout your code.

My post here and the other thread should be enough to fix your issues. You have mistakes in your code that the guy over in the other thread had aswell, i didn't mention them here, you can look at the other thread for that.
Quote Originally Posted by WasserEsser View Post
First of all, take a look at my answer over here, i see that you use the same code:

http://www.mpgh.net/forum/showthread...1#post11850527

You have two ClampAngle functions for no reason.

DWORD Engine = Mem.Module("engine.dll"); within a loop, this will slow everything down. Why would you iterate a snapshot of modules of your process each time you iterate through the loop? This is completely unnecessary since the base address of the module doesn't change unless you restart the game.

maxfov seems to be defined in global space, which means it's not being reset when the function is getting called again. Fix that by declaring it inside the function with a high default value.

if (entindex == 0)

In your case, entindex 0 is the very first player. Doing that will basically ignore the very first player every time which is not what you want.

DWORD Engine = Mem.Module("engine.dll"); within another loop. This will just slow everything down. Use it once at the start of your main and use that value throughout your code.

My post here and the other thread should be enough to fix your issues. You have mistakes in your code that the guy over in the other thread had aswell, i didn't mention them here, you can look at the other thread for that.
Thanks for your help, I'm adjusting the code right now. How would you stop the aimbot from snapping the the map origin point? I had this problem before, and that is why I added the 'if (entindex == 0)' code.
Quote Originally Posted by F4DE View Post
Thanks for your help, I'm adjusting the code right now. How would you stop the aimbot from snapping the the map origin point? I had this problem before, and that is why I added the 'if (entindex == 0)' code.
By checking if the entitybase is valid.

if ( !entitybase ) continue;
Quote Originally Posted by WasserEsser View Post
By checking if the entitybase is valid.

if ( !entitybase ) continue;
Hmm, I have this right now;

Code:
int ClosestEnemyToCrosshair()
{
	float maxfov = 99999.f;
	DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504);
	int LocalTeam = Mem.Read<int>(LocalPlayer + m_iTeamNum);
	DWORD Engine = Mem.Module("engine.dll");
	for (int i = 0; i < 64; i++)
	{
		DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (i * 0x10));
		if (!entitybase) continue;
		if (entitybase == LocalPlayer)
			continue;
		bool entitydormant = Mem.Read<bool>(entitybase + isDormant);
		if (entitydormant)
			continue;
		int entityteam = Mem.Read<int>(entitybase + m_iTeamNum);

		if (entityteam == LocalTeam)
			continue;


		int entitylifestate = Mem.Read<byte>(entitybase + 0x25B); //is lifestate
		if (entitylifestate != 0)
			continue;

		DWORD clientstate = Mem.Read<DWORD>(Engine + clientState);
		Vec3 currentangles = Mem.Read<Vec3>(clientstate + viewAngle);
		Vec3 pos = BonePos(entitybase, 0x2698, aimbone); //bonematrix
		float entitydistance = GetFOV(currentangles, position, pos);
		if (entitydistance < maxfov)
		{
			maxfov = entitydistance;
			index = i;
		}
	}
	return index;
}


void Aimbot()
{
	while (true)
	{
		for (int i = 0; i<48; i++)
		{
			DWORD Client = Mem.Module("client.dll");
			DWORD CurrentWeaponIndex = Mem.Read<DWORD>(LocalPlayer + m_hMyWeapons + ((i - 1) * 0x4)) & 0xFFF;
			DWORD CurrentWeaponEntity = Mem.Read<DWORD>(Client + EntityList + (CurrentWeaponIndex - 1) * 0x10);
			int CurrentWeaponId = Mem.Read<int>(CurrentWeaponEntity + m_iItemDefinitionIndex);
			int MyXuid = Mem.Read<int>(CurrentWeaponEntity + m_OriginalOwnerXuidLow);
			Mem.Write<int>(CurrentWeaponEntity + m_iItemIDHigh, -1); //When iItemIDHigh is set to non zero value, fallback values will be used.

			Mem.Write<int>(CurrentWeaponEntity + m_nFallbackPaintKit, 180);
			Mem.Write<int>(CurrentWeaponEntity + m_nFallbackSeed, 0);
			Mem.Write<int>(CurrentWeaponEntity + m_nFallbackStatTrak, 1337);
			Mem.Write<int>(CurrentWeaponEntity + m_iEntityQuality, 1);
			Mem.Write<float>(CurrentWeaponEntity + m_flFallbackWear, 0.001000);
			Mem.Write<int>(CurrentWeaponEntity + m_iAccountID, MyXuid);
		}
		DWORD Engine = Mem.Module("engine.dll");
		while (GetAsyncKeyState(VK_MENU))
		{
			int entindex = ClosestEnemyToCrosshair();

			DWORD LocalPlayer = Mem.Read <DWORD>(Client + 0x00A31504);
			Vec3 origin = Mem.Read<Vec3>(LocalPlayer + 0x134);
			Vec3 vecview = Mem.Read<Vec3>(LocalPlayer + 0x104);
			position.x = origin.x + vecview.x;
			position.y = origin.y + vecview.y;
			position.z = origin.z + vecview.z;

			Vec3 punch = Mem.Read<Vec3>(LocalPlayer + 0x3018);
			Vec3 angles;

			DWORD entitybase = Mem.Read<DWORD>(Client + EntityList + (entindex * 0x10));
			if (!entitybase) continue;
			Vec3 pos = BonePos(entitybase, 0x2698, bonePosition);

			CalcAngle(position, pos, angles);
			angles.x = angles.x - punch.x * 2.f;
			angles.y = angles.y - punch.y * 2.f;
			ClampAngles(angles);
			if (angles.x == 0 && angles.y == 0)
				continue;
			DWORD clientstate = Mem.Read<DWORD>(Engine + clientState);
			Mem.Write<Vec3>(clientstate + 0x4D0C, angles);
		}
		Sleep(1);
	}
}
Did all of the essential things, not the extra code pieces will do those later to clean it up when it works. For some reason, it still gives me the same result as before ;l
Quote Originally Posted by WasserEsser View Post
DWORD Engine = Mem.Module("engine.dll"); within a loop, this will slow everything down. Why would you iterate a snapshot of modules of your process each time you iterate through the loop? This is completely unnecessary since the base address of the module doesn't change unless you restart the game.
Please read that sentence again and take a look at your code again. You're iterating through the snapshot list of modules 3 times per iteration.

Do it once in your main function.

If you still have problems ( the above won't fix the problem ), post your FULL code.
Quote Originally Posted by WasserEsser View Post
Please read that sentence again and take a look at your code again. You're iterating through the snapshot list of modules 3 times per iteration.

Do it once in your main function.

If you still have problems ( the above won't fix the problem ), post your FULL code.
Added it to the Main class, but now it litterly doesn't do anything ;l
Pm'ed you the full Main class.
1 week has passed and no further replies have been made by the OP. Assuming solved.

/Closed.
Posts 16–23 of 23 · Page 2 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us