```
struct TargetList_t
{
float Distance;
float AimbotAngle[3];
TargetList_t()
{
}
TargetList_t(float aimbotAngle[], float myCoords[], float enemyCoords[])
{
Distance = Get3dDistance(myCoords[0], myCoords[1], myCoords[2],
enemyCoords[0], enemyCoords[1], enemyCoords[2]);
AimbotAngle[0] = aimbotAngle[0];
AimbotAngle[1] = aimbotAngle[1];
AimbotAngle[2] = aimbotAngle[2];
}
float Get3dDistance(float myCoordsX, float myCoordsZ, float myCoordsY,
float enX, float enZ, float enY)
{
return sqrt(pow(double(enX - myCoordsX), 2.0) +
pow(double(enY - myCoordsY), 2.0) +
pow(double(enX - myCoordsX), 2.0));
}
};
struct CompareTargetEnArray
{
bool operator () (TargetList_t & lhs, TargetList_t & rhs)
{
return lhs.Distance < rhs.Distance;
}
};
void CalcAngle(float *src, float *dst, float *angles)
{
double delta[3] = {(src[0]-dst[0]), (src[1]-dst[1]), (src[2]-dst[2])};
double hyp = sqrt(delta[0]*delta[0] + delta[1]*delta[1]);
angles[0] = (float) (asinf(delta[2]/hyp) * 57.295779513082f);
angles[1] = (float) (atanf(delta[1]/delta[0]) * 57.295779513082f);
angles[2] = 0;
if (delta[0] >= 0.0)
{
angles[1] += 180.0f;
}
}
void Aimbot()
{
TargetList_t * TargetList = new TargetList_t[NumOfPlayers];
int targetLoop = 0;
for (int i = 0; i < NumOfPlayers; i++)
{
PlayerList[i].ReadInformation(i);
CalcAngle(MyPlayer.Position, PlayerList[i].Position, PlayerList[i].AimbotAngle);
TargetList[targetLoop] = TargetList_t(PlayerList[i].AimbotAngle, MyPlayer.Position, PlayerList[i].Position);
targetLoop++;
}
if (targetLoop > 0)
{
sort(TargetList, TargetList + targetLoop, CompareTargetEnArray());
if (!GetAsyncKeyState(0x2))
{
AddressToWritez = FindDmaAddy(3, hProcHandle, EntityPositionOffset, EntityPlayer_Base);
WriteProcessMemory(hProcHandle, (PBYTE*)AddressToWritez, TargetList[0].AimbotAngle, 12, 0);
}
}
targetLoop = 0;
delete [] TargetList;
}
```