[SA:MP] Aim Angles

ketotap

Member
Joined
Nov 25, 2018
Messages
8
Reaction score
2
Hello,

Recently i implemented this aimbot code in my - bloat free, imgui free - gta:sa internal cheat.

However it behaves alot differently than single player, its almost like the calculation is completely fucked up by sa:mp, does anyone know? video below.

https://streamable.com/jymu0

Code:
uintptr_t pLinearMatrix = *(uintptr_t*)(pTarget + 0x14);

Matrix4x4 LinearMatrix = *(Matrix4x4*)(pLinearMatrix);

uintptr_t pHead = *(uintptr_t*)(pTarget + 0x490);

Matrix4x4 HeadMatrix = *(Matrix4x4*)(pHead);

float ax, az, fz, fx;

Vector3 Camera = *(Vector3*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::Source);

Vector3 Delta = Camera - LinearMatrix.ToVector3();

short Mode = *(short*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::Mode);

if (Mode == 53 || Mode == 55)
{
    float FOV = *(float*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::FOV);

    float AspectRatio = *(float*)(0xC3EFA4);

    Vector3 crosshairOffset = *(Vector3*)(0xB6EC10);

    float mult = tan(FOV * 0.5f * 0.017453292f);
    fz = M_PI - atan2(1.0f, mult * ((0.5f - crosshairOffset[0] + 0.5f - crosshairOffset[0]) * (1.0f / AspectRatio)));
    fx = M_PI - atan2(1.0f, mult * (crosshairOffset[1] - 0.5f + crosshairOffset[1] - 0.5f));
}
else
{
    fx = fz = M_PI / 2;
}

//
// X Angle - Pitch
//

float Distance = sqrt(Delta.x * Delta.x + Delta.y * Delta.y);
az = atan2f(Distance, Delta.z);

//
// Z Angle - Yaw
//

ax = atan2f(Delta.y, -Delta.x) - M_PI / 2;

*(float*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::Alpha) = (az - fz);
*(float*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::Beta) = -(ax - fx);
*(float*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::AlphaSpeed) = 0.0f;
*(float*)(ADDR_CCAMERA + eCCamera::Cams + eCCam::BetaSpeed) = 0.0f;

p.s ^ the above code is aids right now, because i didn't rebuilt classes with the things i need.
 
Last edited:

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,493
Reaction score
236
Location
( ͡° ͜ʖ ͡°)
Hmmh..... your first step should be to make it aim at a position without removing CrosshairOffsets and
AspectRatio. How are you going to remove crosshairoffsets etc. without knowing whats getting calculated?
 

ketotap

Member
Joined
Nov 25, 2018
Messages
8
Reaction score
2
Well i know what it does, did not cross my mind to check whether or not crosshair offset, fov and aspect ratio would be the same in sa:mp, i'll check without the offset and check the adresses in reclass .. dumb me
 
Top