Привет, сегодня напишем простой аимбот на SF.
Алгоритм:- найти id игрока
- получить координаты игрока
- рассчитать угол поворота
- повернуть камеру на этот угол
Получаем id и координаты игрока по зеленому треугольнику:
C++:
Cvector enpos;
int enid = SF->getSAMP()->getPlayers()->pLocalPlayer->sAimingAtPid;
if (enid != 65535)
{
enpos.fX = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[0];
enpos.fY = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[1];
enpos.fZ = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[2];
}
C++:
int enid = GetPlayerTarget(50);
if (enid != -1)
{
enpos.fX = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[0];
enpos.fY = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[1];
enpos.fZ = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[2];
}
C++:
CCamera *pCamera = GAME->GetCamera();
mypos = *pCamera->GetCam(pCamera->GetActiveCam())->GetSource();
vector = mypos - enpos;
float AngleX = atan2f(vector.fY, -vector.fX) - M_PI / 2;
C++:
*(float*)0xB6F258 = -(AngleX - M_PI / 2);
C++:
float *crosshairOffset = (float *)0xB6EC10;
float mult = tan(pCamera->GetCam(pCamera->GetActiveCam())->GetFOV() * 0.5f * 0.017453292f);
float fx = M_PI - atan2(1.0f, mult * (crosshairOffset[1] - 0.5f + crosshairOffset[1] - 0.5f));
C++:
*(float*)0xB6F258 = -(AngleX - fx );
полный листинг:
C++:
void Aimbot()
{
CVector mypos;
CVector enpos;
CVector vector;
int enid = SF->getSAMP()->getPlayers()->pLocalPlayer->sAimingAtPid;
if (enid != 65535)
{
enpos.fX = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[0];
enpos.fY = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[1];
enpos.fZ = SF->getSAMP()->getPlayers()->pRemotePlayer[enid]->pPlayerData->onFootData.fPosition[2];
CCamera *pCamera = GAME->GetCamera();
mypos = *pCamera->GetCam(pCamera->GetActiveCam())->GetSource();
vector = mypos - enpos;
float *crosshairOffset = (float *)0xB6EC10;
float mult = tan(pCamera->GetCam(pCamera->GetActiveCam())->GetFOV() * 0.5f * 0.017453292f);
float fx = M_PI - atan2(1.0f, mult * (crosshairOffset[1] - 0.5f + crosshairOffset[1] - 0.5f));
float AngleX = atan2f(vector.fY, -vector.fX) - M_PI / 2;
*(float*)0xB6F258 = -(AngleX - fx);
}
}