Coding Issues with trigg bots latley :3

Posts 110 of 10 · Page 1 of 1
Coding Issues with trigg bots latley :3
The cons of a raytrace only triggerbot are:
CGameTrace::hitbox is not reliable
CGameTrace::hitgroup is reliable but only related to the studio MODEL (not hitbox!) So it is possible that you aim at the body and your Triggerbot shoots but will not hit the hitbox.

By combining the raytrace triggerbot with the rayintersection functions from the sdk we have a perfect solution and balance between fps consumption and 100% reliable results.

Code:

//SDK RIP fixed to work with d3dvector and removed useless stuff
bool IntersectRayWithOBB(const D3DXVECTOR3 &vecRayStart, const D3DXVECTOR3 &vecRayDelta,
const matrix3x4_t &matOBBToWorld, const D3DXVECTOR3 &vecOBBMins, const D3DXVECTOR3 &vecOBBMaxs)
{


// OPTIMIZE: Store this in the box instead of computing it here
// compute center in local space
D3DXVECTOR3 vecBoxExtents = (vecOBBMins + vecOBBMaxs) * 0.5;
D3DXVECTOR3 vecBoxCenter;


// transform to world space
VectorTransform(vecBoxExtents, matOBBToWorld, vecBoxCenter);


// calc extents from local center
vecBoxExtents = vecOBBMaxs - vecBoxExtents;


// OPTIMIZE: This is optimized for world space. If the transform is fast enough, it may make more
// sense to just xform and call UTIL_ClipToBox() instead. MEASURE THIS.


// save the extents of the ray along
D3DXVECTOR3 extent, uextent;
D3DXVECTOR3 segmentCenter = vecRayStart + vecRayDelta - vecBoxCenter;


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


// check box axes for separation
for (int j = 0; j < 3; j++)
{
extent[j] = vecRayDelta.x * matOBBToWorld[0][j] + vecRayDelta.y * matOBBToWorld[1][j] + vecRayDelta.z * matOBBToWorld[2][j];
uextent[j] = fabsf(extent[j]);
float coord = segmentCenter.x * matOBBToWorld[0][j] + segmentCenter.y * matOBBToWorld[1][j] + segmentCenter.z * matOBBToWorld[2][j];
coord = fabsf(coord);


if (coord >(vecBoxExtents[j] + uextent[j]))
return false;
}


// now check cross axes for separation
float tmp, cextent;
D3DXVECTOR3 cross;
D3DXVec3Cross(&cross, &vecRayDelta, &segmentCenter);// = vecRayDelta.Cross(segmentCenter);


cextent = cross.x * matOBBToWorld[0][0] + cross.y * matOBBToWorld[1][0] + cross.z * matOBBToWorld[2][0];
cextent = fabsf(cextent);
tmp = vecBoxExtents[1] * uextent[2] + vecBoxExtents[2] * uextent[1];
if (cextent > tmp)
return false;


cextent = cross.x * matOBBToWorld[0][1] + cross.y * matOBBToWorld[1][1] + cross.z * matOBBToWorld[2][1];
cextent = fabsf(cextent);
tmp = vecBoxExtents[0] * uextent[2] + vecBoxExtents[2] * uextent[0];
if (cextent > tmp)
return false;


cextent = cross.x * matOBBToWorld[0][2] + cross.y * matOBBToWorld[1][2] + cross.z * matOBBToWorld[2][2];
cextent = fabsf(cextent);
tmp = vecBoxExtents[0] * uextent[1] + vecBoxExtents[1] * uextent[0];
if (cextent > tmp)
return false;


return true;
}



The main triggerbot function:
bool Aimbot::Trigger(CUserCmd *pCommand, IClientEntity *pLocal)
{
CGameTrace tr;
D3DXVECTOR3 Src, Dst, vAngle, min, max, delta;
matrix3x4_t matrix[128];
studiohdr_t* pStudioHdr;
mstudiohitboxset_t* pHitboxSet;
mstudiobbox_t* box;
IClientEntity* pEnemy;


//Setup our "look vector"
Src = pLocal->GetEyePos();
vAngle = pCommand->viewangles;


AngleVectors(vAngle, &vAngle);


D3DXVec3Normalize(&vAngle, &vAngle);
D3DXVec3Scale(&vAngle, &vAngle, 8192.f);


Dst = Src + vAngle;


//Call traceline
_asm
{
MOV EAX, pLocal
LEA ECX, tr
PUSH ECX
PUSH 0
PUSH EAX
PUSH 0x4600400B
LEA EDX, Dst
LEA ECX, Src
CALL dwTraceLine;
ADD ESP, 0x10
}

//If we don't hit a human we return
if (!(tr.hitgroup <= 10 && tr.hitgroup > 0))
return false;

if (!tr.m_pEnt)
return false;


pEnemy = (IClientEntity*)tr.m_pEnt;


//We only want to hit enemys
if (pEnemy->GetTeamNum() == pLocal->GetTeamNum())
return false;


if (!pEnemy->SetupBones(matrix, 128, 0x00000100, engineClient->Time()))
return false;


//Get our model studio stuff
PVOID model = pEnemy->GetModelpointer();
if (!model)
return false;


pStudioHdr = modelClient->GetStudiomodel(model);
if (!pStudioHdr)
return false;


pHitboxSet = pStudioHdr->pHitboxSet(0);//0 for testing, use netvar later
if (!pHitboxSet)
return false;


//Create the delta
D3DXVec3Subtract(&delta, &Dst, &Src);


//Loop through all hitboxes and see if we can hit one
for (int i = 0; i < pHitboxSet->numhitboxes; i++)
{
box = pHitboxSet->pHitbox(i);
if (!box)
continue;


//Scale down hitboxes to ensure a hit (you can remove this, but i prefer having smaller hitboxes to be a little bit more legit )
D3DXVec3Scale(&min, &box->bbmin, 0.8f);
D3DXVec3Scale(&max, &box->bbmax, 0.8f);


//Check if we hit the box
if (IntersectRayWithOBB(Src, delta, matrix[box->bone], min, max))
return true;
}

//We didn't hit anything
return false;


}

Hope this can help ;~;
This code is super messy.
Also, why not check if they are dead as well?
Quote Originally Posted by ******* View Post
This code is super messy.
Also, why not check if they are dead as well?
good acount A+
Quote Originally Posted by ******* View Post
This code is super messy.
Also, why not check if they are dead as well?
Hello trollaux
Quote Originally Posted by ******* View Post
This code is super messy.
Also, why not check if they are dead as well?
Ayyy, Brutha you do what you need to do to the coding and make it the way you want :3
no need to say negative things like that ^-^ do what you do and keep it to yourself .-.
Quote Originally Posted by GBot! View Post

Hello trollaux
Hello skidatron 5000, I see you have quoted my post.
Quote Originally Posted by D3M0L1T10N View Post
good acount A+
D3M0L1T1ON
ONE STEP AHEAD OF THE MEMES

You must be nerve, right?
Quote Originally Posted by ******* View Post
D3M0L1T1ON
ONE STEP AHEAD OF THE MEMES

You must be nerve, right?
reported for griefing
did you copy and paste this from uc?
code is really messy, pls use tab. xd. also the only people who would be using it are ppl who know how to code c++. so the notes just make the code look 10x worse.
you have a point w/ the way you use raytrace, but anyone that's been making their own private cheat (and isnt an idiot), uses the method you specified. heck, I've been using that method for 3-4 months now after I noticed the inconsistency of my old tbot.
Posts 110 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?