金币14064
积分7460
注册时间2018-11-17
最后登录2025-1-23
|
楼主 |
发表于 2022-5-26 11:01
|
显示全部楼层
内存自瞄:
- #pragma once
- namespace Aimbot
- {
- Vector3 CalcAngle(Vector3 src, Vector3 dst)
- {
- Vector3 angle = Vector3();
- Vector3 delta = (src - dst);
- double hyp = sqrt(delta.x * delta.x + delta.y * delta.y);
- angle.x = atan(delta.z / hyp) * (180.0f / M_PI);
- angle.y = atan(delta.y / delta.x) * (180.0f / M_PI);
- angle.z = 0;
- if (delta.x >= 0.0) angle.y += 180.0f;
- return angle;
- }
- void NormalizeAngles(Vector3& angle)
- {
- while (angle.x > 89.0f)
- angle.x -= 180.f;
- while (angle.x < -89.0f)
- angle.x += 180.f;
- while (angle.y > 180.f)
- angle.y -= 360.f;
- while (angle.y < -180.f)
- angle.y += 360.f;
- }
- double GetFov(Vector3 viewAngle, Vector3 aimAngle)
- {
- Vector3 delta = aimAngle - viewAngle;
- NormalizeAngles(delta);
- return sqrt(pow(delta.x, 2.0f) + pow(delta.y, 2.0f));
- }
- float CalculateFov(DWORD_PTR localEntity, DWORD_PTR targetEntity)
- {
- Vector3 ViewAngles = Util::GetViewAngles(localEntity);
- Vector3 LocalCamera = kernelHandler.readmem<Vector3>(localEntity + Offset::camera_origin);
- Vector3 EntityPosition = Util::GetEntityBasePosition(targetEntity);
- Vector3 Angle = CalcAngle(LocalCamera, EntityPosition);
- return GetFov(ViewAngles, Angle);
- }
- Vector3 CalculateBestBoneAim(DWORD_PTR localEntity, DWORD_PTR target, float max_fov)
- {
- Vector3 LocalCamera = kernelHandler.readmem<Vector3>(localEntity + Offset::camera_origin);
- Vector3 BonePosition = Util::GetEntityBonePosition(target, Config::AimbotPosition_Code[Config::AimbotPosition]);
- Vector3 CalculatedAngles = CalcAngle(LocalCamera, BonePosition);
- Vector3 ViewAngles = Util::GetViewAngles(localEntity);
- Vector3 Delta = CalculatedAngles - ViewAngles;
- double fov = GetFov(ViewAngles, CalculatedAngles);
- if (fov > max_fov)
- {
- return Vector3{ 0, 0, 0 };
- }
- Vector3 RecoilVec = Util::GetRecoil(localEntity);
- if (RecoilVec.x != 0 || RecoilVec.y != 0)
- {
- Delta.x -= RecoilVec.x;
- Delta.y -= RecoilVec.y;
- }
- float smooth = Config::AimbotSmooth;
- NormalizeAngles(Delta);
- if (true)
- {
- if (Delta.x > 0.0f)
- {
- Delta.x /= smooth;
- }
- else
- {
- Delta.x = ((Delta.x * -1L) / smooth) * -1;
- }
- if (Delta.y > 0.0f)
- {
- Delta.y /= smooth;
- }
- else
- {
- Delta.y = ((Delta.y * -1L) / smooth) * -1;
- }
- }
- Vector3 SmoothedAngles = ViewAngles + Delta;
- NormalizeAngles(SmoothedAngles);
- return SmoothedAngles;
- }
- void Run()
- {
- while (true)
- {
- if (!Offset::localEntity) continue;
- bool isAimbotActive = Config::EnableAimbot && GetAsyncKeyState(Config::AimbotKey_Code[Config::AimbotKey]);
- if (isAimbotActive)
- {
- float target_dist = FLT_MAX;
- DWORD_PTR target_player = {};
- auto playerList_Copy = Offset::playerList;
- for (int i = 0; i < playerList_Copy.size(); i++)
- {
- auto playerEntity = playerList_Copy[i];
- if (!playerEntity) continue;
- //判断是否被击倒
- int bleedoutState = kernelHandler.readmem<int>(playerEntity + Offset::m_bleedoutState);
- if (Config::AimbotIgnoreDowned && bleedoutState > 0)
- {
- continue;
- }
- //判断是否是不可视
- bool isVisible = Util::IsVisible(playerEntity, i);
- if (!isVisible) continue;
- float fov = CalculateFov(Offset::localEntity, playerEntity);
- if (fov < target_dist)
- {
- target_dist = fov;
- target_player = playerEntity;
- }
- }
- if (target_player)
- {
- Vector3 Angles = CalculateBestBoneAim(Offset::localEntity, target_player, Config::AimbotFOV / 10);
- if (Angles.x == 0 && Angles.y == 0)
- {
- continue;
- }
- Util::SetViewAngles(Offset::localEntity, Angles);
- }
- }
- Sleep(10);
- }
- }
- }
复制代码
|
|