Main

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

constexpr Vector3 CalculateAngle(const Vector3&localPosition, const Vector3&

enemyPosition, const Vector3& viewAngles) noexcept


{
return((enemyPosition - localPosition).ToAngle() - viewAngles);
}

int aim()
{

auto targetBone = 8;
auto aimFov = 5.f;
auto smoothing = 0.f;

while (true)
{
if (!master) continue;
if (!canRead) continue;
if (!inGame) continue;

if (!GetAsyncKeyState(VK_RBUTTON)) continue;

const auto& localEyePosition = mem.Read<Vector3>(localPlayer +


offsets::m_vecOrigin) + mem.Read<Vector3>(localPlayer + offsets::m_vecViewOffset);
const auto& clientState = mem.Read<uintptr_t>(engine +
offsets::dwClientState);
const auto& viewAngles = mem.Read<Vector3>(clientState +
offsets::dwClientState_ViewAngles);
const auto& aimPunch = mem.Read<Vector3>(localPlayer +
offsets::m_aimPunchAngle) * 2;

auto aimAngle = Vector3{ };

for (auto n = 1; n <= 32; n++)


{
const auto player = mem.Read<uintptr_t>(client +
offsets::dwEntityList + n * 0x10);

if (mem.Read<int32_t>(player + offsets::m_iTeamNum) == localTeam)


continue;
if (mem.Read<bool>(player + offsets::m_bDormant)) continue;
if (!mem.Read<int32_t>(player + offsets::m_iHealth)) continue;
if (!mem.Read<bool>(player + offsets::m_bSpottedByMask))
continue;

const auto boneMatrix = mem.Read<uintptr_t>(player +


offsets::m_dwBoneMatrix);
const auto playerHeadPosition = Vector3{
mem.Read<float>(boneMatrix + 0x30 * targetBone + 0x0c),
mem.Read<float>(boneMatrix + 0x30 * targetBone + 0x1c),
mem.Read<float>(boneMatrix + 0x30 * targetBone + 0x2c)
};
const auto angle = CalculateAngle(
localEyePosition,
playerHeadPosition,
viewAngles + aimPunch
);

const auto fov = std::hypot(angle.x, angle.y);


if (fov < aimFov)
{
aimFov = fov;
aimAngle = angle;
}

if (!aimAngle.IsZero()) { mem.Write<Vector3>(clientState +
offsets::dwClientState_ViewAngles, viewAngles + aimAngle / smoothing); }

std::this_thread::sleep_for(std::chrono::milliseconds(10));
}

return 0;
}

You might also like