Code:
#define STANDS 1
#define PRONES 2
#define MOVING 3
#define KNEES 4
#define RUNS 5
#define JUMPS 6
#define ROLLS 7
#define NOSTATE 8
#define PI_SQUARED2 9.869604401f
#define PI_SQUARED3 9.8696044010893586188344909998762f
#define PI_SQUARED 3.14159265f
#define PI 3.14159265f
int GetLocalPlayerIndex()
{
DWORD *dwServPtr = (DWORD*)ADR_SERVERPOINTER;
return *(int*)((*dwServPtr) + 0x160EC);
}
CPlayerInfo* GetPlayerInfoByIndex(int index)
{
if(index > 32) return NULL;
return (CPlayerInfo*)(ADR_NAMEBASE + (index * OFS_STRUCT_SIZE));
}
float GetDistanceA(CPlayer* Local, CPlayer* Player)
{
float angle[3];
angle[0] = Player->pos1 - Local->pos1;
angle[1] = Player->pos2 - Local->pos2;
angle[2] = Player->pos3 - Local->pos3;
return sqrt(angle[0]*angle[0] + angle[1]*angle[1] + angle[2]*angle[2]);
}
BYTE GetState(CPlayer* pPlayer)
{
BYTE status = pPlayer->state;
BYTE status2 = pPlayer->state2;
if(status == 0x47)
return STANDS;
if(status == 0x38 || status == 0x3b || status == 0x3b || status == 0x3e || status == 0x3c)
return PRONES;
if(status == 0x4b || status == 0x4a || status == 0x4c || status == 0x4d)
return MOVING;
if(status == 0x57 || status == 0x5d || status == 0x5c || status == 0x5e || status == 0x5f)
return KNEES;
if(status == 0x46)
return RUNS;
if(status == 0x54)
return JUMPS;
if(status == 0x25)
return ROLLS;
}
//D3D Methods
float PitchCorrection = 0.0f;
int GetNearestPlayer()
{
float Distance = 0.0f;
float minDistance = 10000000.0f;
int index;
int Local = GetLocalPlayerIndex();
for (int i = 0; i < 32; i++)
{
if (i != Local && GetPlayerInfoByIndex(i)->health > 0)
{
if (CH_Team)
{
if (GetPlayerInfoByIndex(Local)->team != GetPlayerInfoByIndex(i)->team)
{
Distance = GetDistanceA(pBase->local, pBase->player[i]);
if (Distance < minDistance)
{
minDistance = Distance;
index = i;
}
}
}
else
{
Distance = GetDistanceA(pBase->local, pBase->player[i]);
if (Distance < minDistance)
{
minDistance = Distance;
index = i;
}
}
}
}
return index;
}
float CalculateYaw(CPlayer* Local, CPlayer* Target)
{
float deltaX = Target->pos1 - Local->pos1;
float deltaY = Target->pos3 - Local->pos3;
float result;
//Calculate Yaw Aim in degrees
result = (float)((atan2(deltaY, deltaX) * 180 / PI) - 90);
return result;
}
float CalculatePitch(CPlayer* Local, CPlayer* Target)
{
float origZ = Target->pos2 /*- pLocal->pos2*/;
switch (GetState(Target))
{
case STANDS:
origZ += 26.5f;
PitchCorrection = 26.5f;
break;
case PRONES:
origZ += 0.0f;
PitchCorrection = 0.0f;
break;
case MOVING:
origZ += 27.5f;
PitchCorrection = 27.5f;
break;
case KNEES:
origZ += 19.1f;
PitchCorrection = 19.1f;
break;
case RUNS:
origZ += 26.3f;
PitchCorrection = 26.3f;
break;
case JUMPS:
origZ += 31.5f;
PitchCorrection = 31.5f;
break;
case ROLLS:
origZ += 18.1f;
PitchCorrection = 18.1f;
break;
default:
origZ += 26.5f;
PitchCorrection = 26.5f;
break;
}
bool valid = false;
float deltaX = Target->pos1 - pLocal->pos1;
float deltaY = Target->pos3 - pLocal->pos3;
float deltaZ = origZ - pLocal->pos2;
float result;
float hypotenuse = sqrt((deltaX * deltaX) + (deltaZ + deltaZ));
/*float hypotenuse = sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ + deltaZ));*/
result = (asin(deltaZ / hypotenuse)) * 180 / PI;
result *= -1;
if (result > - 60 && result < 75)
{
valid = true;
return result;
}
return 0;
}
Code:
void Aimbot(void)
{
if (pBase->local)
{
for(int i = 0; i < 32; i++)
{
int NearestPlayer = GetNearestPlayer();
CPlayerInfo *pInfo = GetPlayerInfoByIndex(i);
CPlayerInfo *pLocalInfo = GetPlayerInfoByIndex(pBase->local->index);
if (CH_Aimbot)
{
CH_NoRecoil = 1;
if (CH_AimKey == 1 )
{
if (pLocal)
{
pLocal->yaw = CalculateYaw(pBase->local, pBase->player[NearestPlayer]);
pLocal->pitch = CalculatePitch(pBase->local, pBase->player[NearestPlayer]);
}
if (telekill)
{
pBase->local->pos1 = pBase->player[NearestPlayer]->pos1;
pBase->local->pos3 = pBase->player[NearestPlayer]->pos3;
pBase->local->pos2 = pBase->player[NearestPlayer]->pos2;
}
}
if (CH_AimKey == 2 )
{
if (GetAsyncKeyState(VK_LBUTTON))
{
if (pLocal)
{
pLocal->yaw = CalculateYaw(pBase->local, pBase->player[NearestPlayer]);
pLocal->pitch = CalculatePitch(pBase->local, pBase->player[NearestPlayer]);
}
if (telekill)
{
pBase->local->pos1 = pBase->player[NearestPlayer]->pos1;
pBase->local->pos3 = pBase->player[NearestPlayer]->pos3;
pBase->local->pos2 = pBase->player[NearestPlayer]->pos2;
}
}
}
if (CH_AimKey == 3 )
{
if (GetAsyncKeyState(VK_RBUTTON))
{
if (pLocal)
{
pLocal->yaw = CalculateYaw(pBase->local, pBase->player[NearestPlayer]);
pLocal->pitch = CalculatePitch(pBase->local, pBase->player[NearestPlayer]);
}
if (telekill)
{
pBase->local->pos1 = pBase->player[NearestPlayer]->pos1;
pBase->local->pos3 = pBase->player[NearestPlayer]->pos3;
pBase->local->pos2 = pBase->player[NearestPlayer]->pos2;
}
}
}
}}}}