Internal Traceline

Posts 1–9 of 9 · Page 1 of 1
Internal Traceline
Greetings,

A few days ago I decided that spending too many hours on developing my External hack would be less good for me than trying to get into Internal development.

The reason is simply that External does not give me the speed ( example SpottedByMask ).

I am now attempting to do Traceline and I have searched around a bunch, and I've tried multiple different solutions that was given to others with similar issues like me, however all of them have resulted in instant game crash upon pressing the key I have assigned to start shooting the ray.

Hopefully there are some more experienced users here who can help me to get past this "wall"

Note: The reason why I am using "InCross" is so I can with certainty say that it's not a loop through all entities (players) that is causing the crash as I have already bugged InCross and it works perfectly fine.

Inside CreateMove
Code:
if (GetAsyncKeyState(0x05))
    {
        int cross = me->InCross();
        if (cross > 0 && cross <= 64)
        {
            CBaseEntity* target = Interfaces.ClientEntList->GetClientEntity(cross);
            if (target->isAlive() && target->GetTeamNum() != me->GetTeamNum())
            {
                Vector start, end;
                start = me->GetEyePosition();
                end = target->GetEyePosition();
                trace_t Trace;
                CTraceFilter Filter;

                Ray_t Ray;
                Ray.Init(start, end);

                IEngineTrace* eTrace = new IEngineTrace();
                eTrace->TraceRay(Ray, 0X4600400B, &Filter, &Trace);
            }
        }
}
Trace Class
Code:
#pragma once
#define  Assert( _exp ) ((void)0)
class __declspec(align(16))VectorAligned : public Vector
{
public:
    VectorAligned& operator=(const Vector &vOther)
    {
        Init(vOther.x, vOther.y, vOther.z);
        w = 0.f;
        return *this;
    }
    float w;
};
struct Ray_t
{
    VectorAligned  m_Start;
    VectorAligned  m_Delta;
    VectorAligned  m_StartOffset;
    VectorAligned  m_Extents;
    bool	m_IsRay;
    bool	m_IsSwept;

    void Init(Vector& start, Vector& end)
    {
        m_Delta = start - end;

        m_IsSwept = (m_Delta.LengthSqr() != 0);

        m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;

        m_IsRay = true;

        m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
        m_Start = start;
    }
};

struct cplane_t
{
    Vector normal;
    float dist;
    BYTE type;
    BYTE signbits;
    BYTE pad[2];
};

struct csurface_t
{
    const char* name;
    short surfaceProps;
    unsigned short  flags;
};

enum TraceType_t
{
    TRACE_EVERYTHING = 0,
    TRACE_WORLD_ONLY,				// NOTE: This does *not* test static props!!!
    TRACE_ENTITIES_ONLY,			// NOTE: This version will *not* test static props
    TRACE_EVERYTHING_FILTER_PROPS,	// NOTE: This version will pass the IHandleEntity for props through the filter, unlike all other filters
};
class ITraceFilter
{
public:
    virtual bool			ShouldHitEntity(void* pEntity, int mask) = 0;
    virtual TraceType_t            GetTraceType() const = 0;
};
class CTraceFilter : public ITraceFilter
{
public:
    bool ShouldHitEntity(void* pEntityHandle, int contentsMask)
    {
        return !(pEntityHandle == pSkip1);
    }

    TraceType_t GetTraceType() const
    {
        return TRACE_EVERYTHING;
    }

    void* pSkip1;
};
class CBaseTrace
{
public:
    bool func1();
    bool func2();
    bool func3();
    bool func4();
    bool func5();
public:
    Vector startpos;
    Vector endpos;
    cplane_t plane;
    float fraction;
    int contents;
    unsigned short dispFlags;
    bool  allsolid;
    bool startsolid;
};

class CGameTrace : public CBaseTrace
{
public:
    bool DidHitWorld();
    bool DidHitNonWorldEntity();
    int GetEntityIndex();
    bool DidHit();
public:
    float fractionleftsolid;
    csurface_t surface;
    int hitgroup;
    short physicsbone;
    unsigned short worldSurfaceIndex;
    void *m_pEnt;
    int hitbox;
};

typedef CGameTrace trace_t;

class IEngineTrace
{
public:
    void TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter* filter, trace_t *trace)
    {
        typedef void(__thiscall* fn)(void*, const Ray_t&, unsigned int, ITraceFilter*, trace_t*);
        VMT.getvfunc<fn>(this, 5)(this, ray, fMask, filter, trace);
    }
};
Best Regards,
Me
you don't call the constructor of CTraceFilter.
Code:
CTraceFilter Filter(Interfaces.ClientEntList->(GetLocalPlayer()));
Also you should check if target is a valid pointer. Because if there is no one you will propbably get a nullpointer which will crash you game if you call target->isAlive()
Quote Originally Posted by Orinion77 View Post
you don't call the constructor of CTraceFilter.
Code:
CTraceFilter Filter(Interfaces.ClientEntList->(GetLocalPlayer()));
Also you should check if target is a valid pointer. Because if there is no one you will propbably get a nullpointer which will crash you game if you call target->isAlive()
Greetings,

CTraceFilter has no Constructor that takes CBaseEntity* as Argument :/
it takes a IClientEntity. CBaseEntity is a subclass of it. if you dont have it in you sdk, just typecast it.
Quote Originally Posted by Orinion77 View Post
it takes a IClientEntity. CBaseEntity is a subclass of it. if you dont have it in you sdk, just typecast it.
Greetings,

I don't have IClientEntity at all in my sdk, and also my class of CTraceFilter don't have a constructor.

- - - Updated - - -

Greetings,

I solved the issue. Thanks for the replys

Best Regards,
Me
I am assuming you are trying to do a triggerbot. Atleast thats what it would seem like. Anyways, you can do it in some simple ways this is what i used to use awhile ago.

Code:
C_BaseEntity* getTargetUnderCrosshair(CUserCmd* cmd, bool enemiesOnly, bool visibleOnly, trace_t* trOut) {

	C_BaseEntity *localPlayer = (C_BaseEntity*)m_pEntlist->GetClientEntity(m_pEngine->GetLocalPlayer());

	Vector vEnd;
	QAngle view = cmd->viewangles;

	trace_t tr;
	Ray_t ray;

	CTraceFilter filter;
	filter.pSkip = localPlayer;

	AngleVectors(view, &vEnd, NULL, NULL);

	//calculate endpoint
	vEnd = vEnd * 8192.0f + localPlayer->GetEyePos();

	//initialize raytrace
	ray.Init(localPlayer->GetEyePos(), vEnd);

	//shoot the ray
	m_pEnginetrace->TraceRay(ray, CONTENTS_SOLID | CONTENTS_GRATE | CONTENTS_HITBOX, &filter, &tr);
	if (!tr.m_pEnt)
		return NULL;
	//if we're only getting enemies, make sure the entity we hit is an enemy
	if (tr.m_pEnt->m_iTeamNum == localPlayer->m_iTeamNum && enemiesOnly)
		return NULL;

	//check that we hit a valid hitbox
	if (tr.hitgroup <= 7 && tr.hitgroup > 0) {
		if (trOut)
			*trOut = tr;
		return tr.m_pEnt;
	}
	else
		return NULL;
}
Then afterwards, you can use that say in like some sort of triggerbot function.

Code:
void Triggerbot(CUserCmd* cmd)
{

	C_BaseEntity* target;
	C_BaseEntity *localPlayer = (C_BaseEntity*)m_pEntlist->GetClientEntity(m_pEngine->GetLocalPlayer());
	C_BaseCombatWeapon* localPlayerWep = localPlayer->GetWeapon();
	int maxdist = 8192;
	if (localPlayerWep) {
		int weaponID = *(int*)((DWORD)localPlayerWep +m_pOffsets->ItemID);
		if (weaponID == WEAPON_ZEUSX27)
			maxdist = 200;
	}
	trace_t tr;
	if (target = getTargetUnderCrosshair(cmd, true, true, &tr)) {
		Vector vecToTarget = tr.endpos - localPlayer->GetEyePos();
		if (vecToTarget.Length() < maxdist)
			cmd->buttons |= IN_ATTACK;
	}
}
Finally, just call that in your createmove as such

Code:
if (GetAsyncKeyState(Console->getValue("triggerbot_key"))) // Obivously use whatever you are going to use for ur trigger key.
{
  Triggerbot(cmd);
}

- - - Updated - - -

Quote Originally Posted by Aegisreaper View Post
Greetings,

I don't have IClientEntity at all in my sdk, and also my class of CTraceFilter don't have a constructor.

- - - Updated - - -

Greetings,

I solved the issue. Thanks for the replys

Best Regards,
Me
You can use what i just posted as an alternative way to do a triggerbot even though you fixed your issue
Quote Originally Posted by 4nuoFZf9aE View Post
I am assuming you are trying to do a triggerbot. Atleast thats what it would seem like. Anyways, you can do it in some simple ways this is what i used to use awhile ago.

Code:
C_BaseEntity* getTargetUnderCrosshair(CUserCmd* cmd, bool enemiesOnly, bool visibleOnly, trace_t* trOut) {

	C_BaseEntity *localPlayer = (C_BaseEntity*)m_pEntlist->GetClientEntity(m_pEngine->GetLocalPlayer());

	Vector vEnd;
	QAngle view = cmd->viewangles;

	trace_t tr;
	Ray_t ray;

	CTraceFilter filter;
	filter.pSkip = localPlayer;

	AngleVectors(view, &vEnd, NULL, NULL);

	//calculate endpoint
	vEnd = vEnd * 8192.0f + localPlayer->GetEyePos();

	//initialize raytrace
	ray.Init(localPlayer->GetEyePos(), vEnd);

	//shoot the ray
	m_pEnginetrace->TraceRay(ray, CONTENTS_SOLID | CONTENTS_GRATE | CONTENTS_HITBOX, &filter, &tr);
	if (!tr.m_pEnt)
		return NULL;
	//if we're only getting enemies, make sure the entity we hit is an enemy
	if (tr.m_pEnt->m_iTeamNum == localPlayer->m_iTeamNum && enemiesOnly)
		return NULL;

	//check that we hit a valid hitbox
	if (tr.hitgroup <= 7 && tr.hitgroup > 0) {
		if (trOut)
			*trOut = tr;
		return tr.m_pEnt;
	}
	else
		return NULL;
}
Then afterwards, you can use that say in like some sort of triggerbot function.

Code:
void Triggerbot(CUserCmd* cmd)
{

	C_BaseEntity* target;
	C_BaseEntity *localPlayer = (C_BaseEntity*)m_pEntlist->GetClientEntity(m_pEngine->GetLocalPlayer());
	C_BaseCombatWeapon* localPlayerWep = localPlayer->GetWeapon();
	int maxdist = 8192;
	if (localPlayerWep) {
		int weaponID = *(int*)((DWORD)localPlayerWep +m_pOffsets->ItemID);
		if (weaponID == WEAPON_ZEUSX27)
			maxdist = 200;
	}
	trace_t tr;
	if (target = getTargetUnderCrosshair(cmd, true, true, &tr)) {
		Vector vecToTarget = tr.endpos - localPlayer->GetEyePos();
		if (vecToTarget.Length() < maxdist)
			cmd->buttons |= IN_ATTACK;
	}
}
Finally, just call that in your createmove as such

Code:
if (GetAsyncKeyState(Console->getValue("triggerbot_key"))) // Obivously use whatever you are going to use for ur trigger key.
{
  Triggerbot(cmd);
}

- - - Updated - - -



You can use what i just posted as an alternative way to do a triggerbot even though you fixed your issue
Thanks for taking your time to reply, and I will definitely take a look at your code and see how I can use it.

What I would want to accomplish with this is actually 'IsVisible' Check , but I can also see how it can benefit for a triggerbot!, thanks
Quote Originally Posted by Aegisreaper View Post
Thanks for taking your time to reply, and I will definitely take a look at your code and see how I can use it.

What I would want to accomplish with this is actually 'IsVisible' Check , but I can also see how it can benefit for a triggerbot!, thanks
Okay, then you can take a bit of a different approach.

Code:
bool isBoneVisible(C_BaseEntity* target, int bone) {
	C_BaseEntity *localPlayer = (C_BaseEntity*)m_pEntlist->GetClientEntity(m_pEngine->GetLocalPlayer());

	Vector vEnd;
	getBonePosition(target, vEnd, bone); // get the bone pos

	trace_t tr;
	Ray_t ray;

	CTraceFilter filter;
	filter.pSkip = localPlayer;

	//initialize raytrace
	ray.Init(localPlayer->GetEyePos(), vEnd);

	//shoot the ray
	m_pEnginetrace->TraceRay(ray, CONTENTS_SOLID | CONTENTS_GRATE | CONTENTS_HITBOX, &filter, &tr);
	if (!tr.m_pEnt)
		return false;

	//check that we hit a valid hitbox
	if (tr.hitgroup <= 7 && tr.hitgroup > 0)
		return true;
	return false;
}
Which is similar to the way i showed you above not exact but you would also need the function getboneposition

Code:
bool getBonePosition(C_BaseEntity* target, Vector& Hitbox, int Bone) {
	matrix3x4a_t MatrixArray[128];

	if (!target->SetupBones(MatrixArray, 128, 0x00000100, m_pGlobals->curtime))
		return false;

	Hitbox = Vector(MatrixArray[Bone][0][3], MatrixArray[Bone][1][3], MatrixArray[Bone][2][3]);

	return true;
}
Now that you have both of these things you could do something like this

Code:
bool isPlayerVisible(C_BaseEntity* target) {
	for (int i = 0; i < 6; i++) {
		if (isBoneVisible(target, i))
			return true;
	}
	return false;
}
Quote Originally Posted by 4nuoFZf9aE View Post
Okay, then you can take a bit of a different approach.

Code:
bool isBoneVisible(C_BaseEntity* target, int bone) {
	C_BaseEntity *localPlayer = (C_BaseEntity*)m_pEntlist->GetClientEntity(m_pEngine->GetLocalPlayer());

	Vector vEnd;
	getBonePosition(target, vEnd, bone); // get the bone pos

	trace_t tr;
	Ray_t ray;

	CTraceFilter filter;
	filter.pSkip = localPlayer;

	//initialize raytrace
	ray.Init(localPlayer->GetEyePos(), vEnd);

	//shoot the ray
	m_pEnginetrace->TraceRay(ray, CONTENTS_SOLID | CONTENTS_GRATE | CONTENTS_HITBOX, &filter, &tr);
	if (!tr.m_pEnt)
		return false;

	//check that we hit a valid hitbox
	if (tr.hitgroup <= 7 && tr.hitgroup > 0)
		return true;
	return false;
}
Which is similar to the way i showed you above not exact but you would also need the function getboneposition

Code:
bool getBonePosition(C_BaseEntity* target, Vector& Hitbox, int Bone) {
	matrix3x4a_t MatrixArray[128];

	if (!target->SetupBones(MatrixArray, 128, 0x00000100, m_pGlobals->curtime))
		return false;

	Hitbox = Vector(MatrixArray[Bone][0][3], MatrixArray[Bone][1][3], MatrixArray[Bone][2][3]);

	return true;
}
Now that you have both of these things you could do something like this

Code:
bool isPlayerVisible(C_BaseEntity* target) {
	for (int i = 0; i < 6; i++) {
		if (isBoneVisible(target, i))
			return true;
	}
	return false;
}
Thanks for the reply,

I'm currently having issues tho, it returns 'not' visible a lot of the timer, and I have to stand close to the enemy and aim at a certain angle.

Using the Bonematrix to return the 'bone' will make it work properly, I believe it's the Setup Bones that is messing up, I PMd you all the info I gathered.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us