BOOL DoAimbot( void )
{__try{
CEntity * pCurTarget = NULL;
CEntity * pBestTarget = NULL;
CClientInfo * pClientInfo = NULL;
float fClosestDistance = 999.0f;
D3DXVECTOR3 vAimPos, vLocalPos,ViewOrigin, Trajectory;
int iFound = -1;
WORD HeadBone = RegisterTag_( "j_helmet", 1,7 );
int nIndex;
for (nIndex = 0; nIndex < MAX_PLAYERS; nIndex++ )
{
pCurTarget = GetEntityIndex( nIndex );
pClientInfo = GetClientIndex( nIndex );
//below we check valid target, enemy team and is target alive
if ( ! ( IsValidEntity ( pCurTarget, pClientInfo )))
continue;
if ( !IsAlive( pCurTarget ) )
continue;
bool bEnemyTarget = ( pClientInfo->iTeamID != gLocalInfo->iTeamID || gLocalInfo->iTeamID == TEAM_FREE );
if ( bEnemyTarget == FALSE )
continue;
//FFA check for aimbot
if (!memcmp(server->GameType,"dm",2))
if(nIndex == gCG->iLocalClient)
continue;
if(!GetBoneOrigin( pCurTarget, VecAimSpot, HeadBone ))
continue;
float flCurrent = CMath.GetDistance(camera->Location, pCurTarget->Location ) / 48.0f;
//we check for target visibility on our just gotten aim location
if( Trace_Target ( camera->Location, VecAimSpot ) )
{
//we check if targets is on closer distance
if (flCurrent < fClosestDistance)
{
if(cvar.autozoom==1)
{
AutoZoom(true);
}
fClosestDistance = flCurrent;
iFound = nIndex;
pBestTarget = pCurTarget;
}
}
}
if ( pBestTarget == NULL )
return 1;
float * AimAt = pBestTarget->Location;
AimAt[2] -= .5f;
float fEnemySpeed[3];
//this is my poor selfpredict method
VectorSubtract(pBestTarget->NewLocation,pBestTarget->OldLocation,fEnemySpeed);//subtract between NEW and OLD entity Location wich causes us getting the enemy speed!
// below we apply the speed to our aiming position!
AimAt[0] += fEnemySpeed[0] + fEnemySpeed[0];
AimAt[1] += fEnemySpeed[1] + fEnemySpeed[1];
AimAt[2] += fEnemySpeed[2] + fEnemySpeed[2];
if ( cvar.autoaim == 1 )
{
if(cvar.aimbot == 1)
{
//here we set our view angles to target location
CMath.GetAngleToOrigin( AimAt, &AimViewAngleX, &AimViewAngleY);
viewangles->ViewAngleX += AimViewAngleX * cvar.aimspeed / 10.f;
viewangles->ViewAngleY += AimViewAngleY * cvar.aimspeed / 10.f;
}
}
if(cvar.autofire == 1)
{
hSendCommand(1,1,"+attack");
hSendCommand(1,1,"-attack");
}
}__except(EXCEPTION_EXECUTE_HANDLER){
return FALSE;