i recommend you search up on sin, cos, and tan.
Simple Aimbot
Nice tutorial
Real Combat Arms aimbot.
This is the reason CA pubs have aimbots now
Credits Gellin
This is the reason CA pubs have aimbots now
Credits Gellin
Code:
#include "aimbot.h"
cAimbot* aimbot = NULL;
CTimer ctGetNextPos[26];
int cAimbot::GetNearestPlayer( int VisCheck, int AimBone, int AimAtTeam, int SpawnCheck, int Fov )
{
int iAimAt = -1;
float fNearest = (float)INT_MAX;
for( int i = 0; i <= 24; i++ )
{
if( esp->bValidObject( i ) && !esp->Players[i].bIsDead )
{
if( AimAtTeam == 0 && esp->Players[i].Charector->TeamID == esp->local.iTeam )
continue;
if( VisCheck == 1 && !esp->Players[i].bVisible )
continue;
if( Fov == 0 && !esp->Players[i].bOnScreen )
continue;
if( SpawnCheck == 1 && esp->Players[i].bSpawnShield )
continue;
if( esp->Players[i].fDistance < fNearest )
{
iAimAt = i;
fNearest = esp->Players[i].fDistance;
}
}
}
return iAimAt;
}
int cAimbot::GetNearestToCrosshair( int VisCheck, int AimBone, int AimAtTeam, int SpawnCheck )
{
int iAimAt = -1;
double fNearest = (float)INT_MAX;
for( int i = 0; i <= 24; i++ )
{
if( esp->bValidObject( i ) && esp->bValidCords( i ) && !esp->Players[i].bIsDead )
{
if( !esp->Players[i].bOnScreen )
continue;
if( AimAtTeam == 0 && esp->Players[i].Charector->TeamID == esp->local.iTeam )
continue;
if( VisCheck == 1 && !esp->Players[i].bVisible )
continue;
if( SpawnCheck == 1 && esp->Players[i].bSpawnShield )
continue;
D3DXVECTOR3 Screen( (float)main->ScreenW2, (float)main->ScreenH2, 0.0f );
D3DXVECTOR3 Pos = ( esp->Players[i].HeadScreen - Screen );
double Dist = ( ( Pos.x * Pos.x ) + ( Pos.y * Pos.y ) + ( Pos.z * Pos.z ) );
if( Dist < fNearest )
{
fNearest = Dist;
iAimAt = i;
}
}
}
return iAimAt;
}
void cAimbot::Lock( int AimType, int AimBone, int AutoAim, int AutoFire, int VisCheck, int AimAtTeam, int SpawnCheck, int AutoSwitch, int Prediction )
{
if( !esp->local.bDead )
{
if( AutoAim || GetAsyncKeyState( menu->iAimKey ) < 0 )
{
if( NearestEnemy == -1 && Ready )
{
if( AimType == 1 )
NearestEnemy = GetNearestPlayer( VisCheck, AimBone, AimAtTeam, SpawnCheck, menu->MaxFov );
else if( AimType == 2 )
NearestEnemy = GetNearestToCrosshair( VisCheck, AimBone, AimAtTeam, SpawnCheck );
}
if( NearestEnemy != -1 && Ready )
{
if( esp->bValidObject( NearestEnemy ) && !esp->Players[NearestEnemy].bIsDead )
{
D3DXVECTOR3 Angles, FinalAimSpot;
if( Prediction == 1 )
FinalAimSpot = GhettoPrediction( NearestEnemy, 55, esp->Players[NearestEnemy].AimTransform.Pos, ctGetNextPos );
else
FinalAimSpot = esp->Players[NearestEnemy].AimTransform.Pos;
if( VisCheck == 1 && !esp->Players[NearestEnemy].bVisible )
{
NearestEnemy = -1;
Ready = true;
return;
}
GetAngleToTarget( FinalAimSpot, esp->local.CameraPos, Angles );
engine->GetPlayerMgr()->Yaw = DegToRad ( Angles[YAW] );
engine->GetPlayerMgr()->Pitch = DegToRad ( Angles[PITCH] );
if( AutoFire )
{
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
}
if( AimType == 1 )
{
Ready = true;
NearestEnemy = -1;
}
}
else
{
if( AutoSwitch || AutoAim )
{
Ready = true;
NearestEnemy = -1;
}
else
{
Ready = false;
NearestEnemy = -1;
}
}
}
}
else
{
Ready = true;
NearestEnemy = -1;
}
}
}
void cAimbot::NPC_Lock( int AimType, int AimBone, int AutoAim, int AutoFire, int VisCheck, int AutoSwitch, int Prediction )
{
if( !esp->local.bDead && AutoAim || GetAsyncKeyState( menu->iAimKey ) < 0 )
{
if( engine->ValidGamePointers() )
{
if( BestNPC == -1 && Ready )
{
if( AimType == 1 )
BestNPC = GetNearestNPC( VisCheck, AimBone, menu->MaxFov );
else if( AimType == 2 )
BestNPC = GetNearestNPCToCrosshair( VisCheck, AimBone );
}
if( BestNPC != -1 && Ready )
{
D3DXVECTOR3 Angles, FinalAimSpot;
cCharacterFX* Character = (cCharacterFX*)engine->GetGameClientShell()->GetSFXMgr()->SFXList[SFX_CHARACTER].List[BestNPC];
if( engine->ValidPointer( Character ) && engine->ValidPointer( Character->Object ) )
{
Transform HeadTransform;
unsigned int AimSpot;
switch( AimBone )
{
case 1:
AimSpot = engine->GetLTModel()->GetNodeTransform( Character->Object, 8, &HeadTransform, true );
HeadTransform.Pos.y += 5.8f;
break;
case 2:
AimSpot = engine->GetLTModel()->GetNodeTransform( Character->Object, 6, &HeadTransform, true );
break;
case 3:
AimSpot = engine->GetLTModel()->GetNodeTransform( Character->Object, 7, &HeadTransform, true );
break;
case 4:
AimSpot = engine->GetLTModel()->GetNodeTransform( Character->Object, 4, &HeadTransform, true );
HeadTransform.Pos.y -= 6.0f;
break;
}
if( VisCheck == 1 && engine->IsVisible( HeadTransform.Pos ) == false )
{
BestNPC = -1;
Ready = true;
return;
}
GetAngleToTarget( HeadTransform.Pos, esp->local.CameraPos, Angles );
engine->GetPlayerMgr()->Yaw = DegToRad ( Angles[YAW] );
engine->GetPlayerMgr()->Pitch = DegToRad ( Angles[PITCH] );
if( AutoFire )
{
mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
}
if( AimType == 1 )
{
BestNPC = -1;
Ready = true;
}
}
else
{
if( AutoSwitch || AutoAim )
{
BestNPC = -1;
Ready = true;
}
else
{
BestNPC = -1;
Ready = false;
}
}
}
}
}
else
{
BestNPC = -1;
Ready = true;
}
}
int cAimbot::GetNearestNPCToCrosshair( int VisCheck, int AimBone )
{
if( !engine )
return -1;
int iAimAt = -1;
float fNearest = (float)INT_MAX;
cSFXMgr* SFXMgr = engine->GetGameClientShell()->GetSFXMgr();
if( engine->ValidPointer( SFXMgr ) )
{
for(int i = 0; i < SFXMgr->SFXList[SFX_CHARACTER].Num; i++)
{
cCharacterFX* NPC = (cCharacterFX*)SFXMgr->SFXList[SFX_CHARACTER].List[i];
if(engine->ValidPointer( NPC ) && engine->ValidPointer( NPC->Object ) )
{
if( esp->local.Object == NPC->Object )
continue;
int Type = NPC->IsPlayer;
if( Type != 0 )
continue;
Transform HeadTransform;
unsigned int AimSpot;
switch( AimBone )
{
case 1:
AimSpot = engine->GetLTModel()->GetNodeTransform ( NPC->Object, 8, &HeadTransform, true );
HeadTransform.Pos.y += 7.0f;
break;
case 2:
AimSpot = engine->GetLTModel()->GetNodeTransform ( NPC->Object, 6, &HeadTransform, true );
break;
case 3:
AimSpot = engine->GetLTModel()->GetNodeTransform ( NPC->Object, 7, &HeadTransform, true );
break;
case 4:
AimSpot = engine->GetLTModel()->GetNodeTransform ( NPC->Object, 4, &HeadTransform, true );
HeadTransform.Pos.y -= 5.0f;
break;
}
if( VisCheck == 1 && !engine->IsVisible( HeadTransform.Pos ) )
continue;
D3DXVECTOR3 Out;
if( !engine->WorldToScreen( HeadTransform.Pos, &Out ) )
continue;
Out.z = 0;
D3DXVECTOR3 Screen( (float)main->ScreenW2, (float)main->ScreenH2, 0 );
D3DXVECTOR3 Pos = ( Out - Screen );
float Dist = sqrt( (Pos.x * Pos.x ) + ( Pos.y * Pos.y ) + ( Pos.z * Pos.z ) );
if( Dist < fNearest )
{
fNearest = Dist;
iAimAt = i;
}
}
}
}
return iAimAt;
}
int cAimbot::GetNearestNPC( int VisCheck, int AimBone, int Fov )
{
if( !engine )
return -1;
int iAimAt = -1;
float fNearest = (float)INT_MAX;
cSFXMgr* SFXMgr = engine->GetGameClientShell()->GetSFXMgr();
if( engine->ValidPointer( SFXMgr ) )
{
for( int i = 0; i < SFXMgr->SFXList[SFX_CHARACTER].Num; i++ )
{
cCharacterFX* NPC = (cCharacterFX*)SFXMgr->SFXList[SFX_CHARACTER].List[i];
if( engine->ValidPointer(NPC) && engine->ValidPointer(NPC->Object) )
{
int* MyObj = engine->GetLTBase()->GetClientObject();
if( MyObj && MyObj == NPC->Object )
continue;
int Type = NPC->IsPlayer;
if( Type != 0 )
continue;
Transform HeadTransform;
unsigned int AimSpot;
switch( AimBone )
{
case 1:
AimSpot = engine->GetLTModel()->GetNodeTransform( NPC->Object, 8, &HeadTransform, true );
HeadTransform.Pos.y += 7.0f;
break;
case 2:
AimSpot = engine->GetLTModel()->GetNodeTransform( NPC->Object, 6, &HeadTransform, true );
break;
case 3:
AimSpot = engine->GetLTModel()->GetNodeTransform( NPC->Object, 7, &HeadTransform, true );
break;
case 4:
AimSpot = engine->GetLTModel()->GetNodeTransform( NPC->Object, 4, &HeadTransform, true );
HeadTransform.Pos.y -= main->fNutOff;
break;
}
if( VisCheck == 1 && !engine->IsVisible( HeadTransform.Pos ) )
continue;
D3DXVECTOR3 Dummy;
if( (int)menu->cBox[4].OnOff == 1 && Fov == 0 && !engine->WorldToScreen( HeadTransform.Pos, &Dummy ) )
continue;
float v[3];
VectorSubtract( HeadTransform.Pos, esp->local.CameraPos, v );
float fTemp = sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] ) / 48;
if( fTemp < fNearest )
{
iAimAt = i;
fNearest = fTemp;
}
}
}
}
return iAimAt;
}
void cAimbot::AngleVectors( const float* angles, float* forward, float* right, float* up )
{
float angle;
static float sr, sp, sy, cr, cp, cy, t;
angle = angles[YAW];
sy = sin(angle);
cy = cos(angle);
angle = angles[PITCH];
sp = sin(angle);
cp = cos(angle);
angle = angles[ROLL];
sr = sin(angle);
cr = cos(angle);
if( forward )
{
forward[0] = cp*cy;
forward[1] = cp*sy;
forward[2] = -sp;
}
if( right )
{
t = sr*sp;
right[0] = ( -1*t*cy+-1*cr*-sy );
right[1] = ( -1*t*sy+-1*cr*cy );
right[2] = -1*sr*cp;
}
if( up )
{
t = cr*sp;
up[0] = ( t*cy+-sr*-sy );
up[1] = ( t*sy+-sr*cy );
up[2] = cr*cp;
}
}
void cAimbot::VectorAngles( const float* forward, float* angles )
{
float tmp, yaw, pitch;
if( forward[2] == 0 && forward[0] == 0 )
{
yaw = 0;
if( forward[2] > 0 )
pitch = 90;
else
pitch = 270;
}
else
{
yaw = ( atan2( forward[2], -forward[0] ) * 180 / M_PI )-90;
if( yaw < 0 )
yaw += 360;
tmp = sqrt( forward[0] * forward[0] + forward[2] * forward[2] );
pitch = ( atan2( forward[1], tmp) * 180 / M_PI );
if( pitch < 0 )
pitch += 360;
}
angles[0] = -pitch;
angles[1] = yaw;
angles[2] = 0;
}
void cAimbot::GetAngleToTarget(D3DXVECTOR3 vTargetPos, D3DXVECTOR3 vCameraPos, D3DXVECTOR3& vAngles)
{
D3DXVECTOR3 vDelta;
vDelta.x = vTargetPos.x - vCameraPos.x;
vDelta.y = vTargetPos.y - vCameraPos.y;
vDelta.z = vTargetPos.z - vCameraPos.z;
VectorAngles( (float*)&vDelta, (float*)&vAngles );
if( vAngles.x > 180.0f )
vAngles.x -= 360.0f;
else if( vAngles.x < -180.0f )
vAngles.x += 360.0f;
if( vAngles.y > 180.0f )
vAngles.y -= 360.0f;
else if( vAngles.y < -180.0f )
vAngles.y += 360.0f;
}
float cAimbot::GetAngleDistanceFromYaw( float fYaw, D3DXVECTOR3 vPos, D3DXVECTOR3 vTarget )
{
D3DXVECTOR2 vDist( vPos.x - vTarget.x, vPos.z - vTarget.z );
float fHypot = VectToHypot( vDist ) + 0.000001f;
float fView = acos( ( vDist.y + 0.000001f ) / fHypot );
if( vDist.x < 0 && vDist.y < 0 || vDist.x < 0 && vDist.y > 0 )
fView = ( M_PI - fView );
else
fView = ( M_PI + fView );
return fabsf( fYaw - fView );
}
D3DXVECTOR3 cAimbot::GhettoPrediction( int i, int iWait, D3DXVECTOR3 Pos, CTimer* TimerList )
{
if( !TimerList[i]****nning() )
{
this->oldPos = Pos;
TimerList[i].Start( iWait );
}
if( Pos.x > this->oldPos.x )
{
this->diffPos.x = Pos.x - this->oldPos.x;
Pos.x += this->diffPos.x;
}
else //if( Pos.x < this->oldPos.x )
{
this->diffPos.x = this->oldPos.x - Pos.x;
Pos.x -= this->diffPos.x;
}
if( Pos.y > this->oldPos.y )
{
this->diffPos.y = Pos.y - this->oldPos.y;
Pos.y += this->diffPos.y;
}
else //if( Pos.y < this->oldPos.y )
{
this->diffPos.y = this->oldPos.y - Pos.y;
Pos.y -= this->diffPos.y;
}
if( Pos.z > this->oldPos.z )
{
this->diffPos.z = Pos.z - this->oldPos.z;
Pos.z += this->diffPos.z;
}
else //if( Pos.z < this->oldPos.z )
{
this->diffPos.z = this->oldPos.z - Pos.z;
Pos.z -= this->diffPos.z;
}
return Pos;
}
thank you very much for putting this thread together it will help me alot. much appreciated, many thanks
This thread is closed for replies.
Similar Threads
Battlefield Heroes HacksHow To make your own simple Aimbot
41 GeneralSimple [Aimbot]TA 8 C++/C ProgrammingBuilding a simple aimbotKI 0 Call of Duty Modern Warfare 2 Coding / Programming / Source CodeSimple aimbot source codeYU 23 Call of Duty 4 - Modern Warfare (MW) HacksSimple Draw Target in AimbotJD 1













