Ray Tracing Based Triggerbot

Posts 111 of 11 · Page 1 of 1
Ray Tracing Based Triggerbot
Hello!
Recently I have seen some ray tracing functions and I wanted to implement it to update my triggerbot. I have used Merccys ray tracing functions:
tiioN's hitboxes for head:
Code:
Hitbox[ 11 ].Setup( BONE_HEAD, Vector( -2.7713f, -2.8783f, -3.103f ), Vector( 6.955f, 3.5203f, 3.0067f ) );
The triggerbot compiles nicely with no errors but it does not shoot when I aim for an entity head.
If anyone could point out what is the problem here or have some pointers plez post

ray.h:
Code:
#ifndef RAY_H 
#define RAY_H 

typedef struct Vector3d_
{
	float x, y, z;
}Vector3d;

class Ray {

public:
	Vector3d origin, direction, directionInverse;

	Ray(Vector3d _origin, Vector3d _direction);

	bool Trace(Vector3d leftBottom, Vector3d rightTop, float &distance);

};

#endif
Ray.cpp:
Code:
#include "Ray.h" 
#include <algorithm>

Ray::Ray(Vector3d _origin, Vector3d _direction) {
	origin = _origin;
	direction = _direction;

	directionInverse.x = 1.0f / direction.x;
	directionInverse.y = 1.0f / direction.y;
	directionInverse.z = 1.0f / direction.z;
}


bool Ray::Trace(Vector3d leftBottom, Vector3d rightTop, float &distance) {

	// If line is parallel and outsite the box it is not possible to intersect  
	if (direction.x == 0.0f && (origin.x < std::min(leftBottom.x, rightTop.x) || origin.x > std::max(leftBottom.x, rightTop.x)))
		return false;

	if (direction.y == 0.0f && (origin.y < std::min(leftBottom.y, rightTop.y) || origin.y > std::max(leftBottom.y, rightTop.y)))
		return false;

	if (direction.z == 0.0f && (origin.z < std::min(leftBottom.z, rightTop.z) || origin.z > std::max(leftBottom.z, rightTop.z)))
		return false;

	float t1 = (leftBottom.x - origin.x) * directionInverse.x;
	float t2 = (rightTop.x - origin.x) * directionInverse.x;
	float t3 = (leftBottom.y - origin.y) * directionInverse.y;
	float t4 = (rightTop.y - origin.y) * directionInverse.y;
	float t5 = (leftBottom.z - origin.z) * directionInverse.z;
	float t6 = (rightTop.z - origin.z) * directionInverse.z;

	float tmin = std::max(std::max(std::min(t1, t2), std::min(t3, t4)), std::min(t5, t6));
	float tmax = std::min(std::min(std::max(t1, t2), std::max(t3, t4)), std::max(t5, t6));

	if (tmax < 0) {
		distance = tmax;
		return false;
	}

	if (tmin > tmax) {
		distance = tmax;
		return false;
	}

	distance = tmin;
	return true;
}
main:
Code:
int main()
{
	DWORD pId;
	HWND hwnd = FindWindow(NULL, "Counter-Strike: Global Offensive");
	GetWindowThreadProcessId(hwnd, &pId);
	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, NULL, pId);
	DWORD clientDll = getDll("client.dll", pId);
	DWORD engineDll = getDll("engine.dll", pId);

	while (true) {

			Vector3d viewAngle = Player.getViewAngle(hProc, engineDll);
			Vector3d eyePos = Player.getEyePos(hProc, clientDll);

			float distance;
			Vector3d viewDirection = AngleToDirection(viewAngle);
			Ray viewRay(eyePos, viewDirection);
			for (int i = 0; i < 64; ++i)
			{
				Vector3d bottomHitboxHead = Entity.getBonePosition(clientDll, hProc, i);
				bottomHitboxHead.x += -2.771300f;
				bottomHitboxHead.y += -2.878300f;
				bottomHitboxHead.z += -3.103000f;

				Vector3d topHitboxHead = Entity.getBonePosition(clientDll, hProc, i);
				topHitboxHead.x += 6.955000f;
				topHitboxHead.y += 4.020300f;
				topHitboxHead.z += 5.006700f;

				if (viewRay.Trace(bottomHitboxHead, topHitboxHead, distance) && (GetAsyncKeyState(0x02) & (1 << 15)));
				{
					Mem.Write<int>(hProc, (clientDll + DwAttack), shoot);
					Sleep(5);
					Mem.Write<int>(hProc, (clientDll + DwAttack), dontShoot);
					Sleep(10);
				}

			}
			Sleep(1);
		}
	return 0;
	}
This might be a little off topic but why is ray tracing better? Normal triggerbots work just fine
Quote Originally Posted by ImWhacky View Post
This might be a little off topic but why is ray tracing better? Normal triggerbots work just fine
normal InCross triggerbots does not work on faceit servers
Quote Originally Posted by ImWhacky View Post
This might be a little off topic but why is ray tracing better? Normal triggerbots work just fine
Your usual triggerbot isn't working if you want to target out specific bones / hitboxes nor is your normal triggerbot working at long distances such as the almighty dust 2 middle. If servers choose to disable the the crosshair id, your trigger aint working either.
Quote Originally Posted by ImWhacky View Post
snip~
I've looked at your code, Your AngleToDirection function should use 2 vectors, your viewangles, and a forward vector. Multiply the forward vector by the range of the current weapon you're holding, or just use a certain number ( i use 10000.f )

edit : also looking at your video, that's the problem i had when i didn't do what i said above ^
Quote Originally Posted by nexcat View Post
I've looked at your code, Your AngleToDirection function should use 2 vectors, your viewangles, and a forward vector. Multiply the forward vector by the range of the current weapon you're holding, or just use a certain number ( i use 10000.f )

edit : also looking at your video, that's the problem i had when i didn't do what i said above ^
How do I get the forward vector and how would I implement it in the func?
Quote Originally Posted by samlarenskoog View Post
How do I get the forward vector and how would I implement it in the func?
For forward vector look in the CSGO SDK, theres is a function called AngleVectors which gets your current angels and returns a forward vector.
Quote Originally Posted by nexcat View Post
I've looked at your code, Your AngleToDirection function should use 2 vectors, your viewangles, and a forward vector. Multiply the forward vector by the range of the current weapon you're holding, or just use a certain number ( i use 10000.f )

edit : also looking at your video, that's the problem i had when i didn't do what i said above ^
I found this function:
Code:
void AngleVectors (const QAngle &angles, Vector *forward)
{
	Assert( s_bMathlibInitialized );
	Assert( forward );
	
	float	sp, sy, cp, cy;
	
	SinCos( DEG2RAD( angles[YAW] ), &sy, &cy );
	SinCos( DEG2RAD( angles[PITCH] ), &sp, &cp );
	
	forward->x = cp*cy;
	forward->y = cp*sy;
	forward->z = -sp;
}
And that function is the same as my angleDirection function, except it outputs in parameter? So if I scale this vector up with 1000.f in viewDirection it should work?

There might be a problem with how I get my eyePos, it only shows the z-value to 64.0626. I cant find any examples of how to get eyePos.
Code:
	Vector3d getEyePos(HANDLE hProc, DWORD clientDll)
	{
		DWORD localPlayer = Mem.Read<DWORD>(hProc, (clientDll + dwLocalPlayer));
		if (localPlayer)
		{
			Vector3d eyePos{};
			eyePos.x = Mem.Read<float>(hProc, (localPlayer + 0x104));
			eyePos.y = Mem.Read<float>(hProc, (localPlayer + 0x108));
			eyePos.z = Mem.Read<float>(hProc, (localPlayer + 0x10C));
			return eyePos;
		}
	}
Hello just taking a look at when Mercy uploaded the original it was in January 2015. This happened in September 2015: -Link to large image-

Unfortunately this code is not going to work without a decent amount of modification.
One place to start is that they changed the bone ID's. The head is 6 now I think.
Good luck.
Quote Originally Posted by goochguy View Post
Hello just taking a look at when Mercy uploaded the original it was in January 2015. This happened in September 2015: -Link to large image-

Unfortunately this code is not going to work without a decent amount of modification.
One place to start is that they changed the bone ID's. The head is 6 now I think.
Good luck.
Yes I know, I updated the hitbox and now I changed the head bone ID, thanks for the pointers. Now it just spams mouseclicks everywhere, outside and inside of csgo :/ I have no idea what the problem is.

EDIT:
This is how I get head bone pos:
Code:
	Vector3d getBonePosition( DWORD clientDll, HANDLE hProc, int i)
	{
		DWORD baseEntity = getEntityBase(hProc, clientDll, i);
		if (baseEntity)
		{
			DWORD boneMatrix = Mem.Read<DWORD>(hProc, (baseEntity + DwBoneMatrix));
			if (boneMatrix)
			{
				Vector3d bonePosition{};
				bonePosition.x = Mem.Read<float>(hProc, (boneMatrix + 0x30 * targetBone + 0x0C));
				bonePosition.y = Mem.Read<float>(hProc, (boneMatrix + 0x30 * targetBone + 0x1C));
				bonePosition.z = Mem.Read<float>(hProc, (boneMatrix + 0x30 * targetBone + 0x2C));
				return bonePosition;
			}
		}
	}
and this is the AngleToDirection func:
Code:
Vector3d AngleToDirection(Vector3d angle) {
	angle.x = (angle.x) * 3.14159265 / 180;
	angle.y = (angle.y) * 3.14159265 / 180;

	float sinYaw = sin(angle.y);
	float cosYaw = cos(angle.y);

	float sinPitch = sin(angle.x);
	float cosPitch = cos(angle.x);

	Vector3d direction;
	direction.x = cosPitch * cosYaw;
	direction.y = cosPitch * sinYaw;
	direction.z = -sinPitch;

	return direction;
}
Edit 2:
Currently when I try it ingame it only shoots at some angles, and it holds down mouse1 button longer when I am in the middle of the angle (as video shows, it is like a pyramid) I dont even have to hold the triggerbutton for this to happen. What is wrong? Dont mind the sound, realized it when I uploaded it.
1 week has passed and no further replies have been made by the OP. Assuming solved.

/Closed.
Posts 111 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?