Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Commit d6b308a

Browse files
committed
feat: add aimbot fov
1 parent e33e66c commit d6b308a

20 files changed

+133
-18
lines changed

src/Destiny.ut.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<ClCompile Include="features\rcs.cpp" />
4040
<ClCompile Include="features\triggerbot.cpp" />
4141
<ClCompile Include="helpers\Console.cpp" />
42+
<ClCompile Include="helpers\math.cpp" />
4243
<ClCompile Include="helpers\Memory.cpp" />
4344
<ClCompile Include="helpers\offsets.cpp" />
4445
<ClCompile Include="helpers\utils.cpp" />
@@ -68,6 +69,7 @@
6869
<ClInclude Include="..\res\resource.h" />
6970
<ClInclude Include="features\Features.hpp" />
7071
<ClInclude Include="helpers\Console.hpp" />
72+
<ClInclude Include="helpers\math.hpp" />
7173
<ClInclude Include="helpers\Memory.hpp" />
7274
<ClInclude Include="helpers\offsets.hpp" />
7375
<ClInclude Include="helpers\utils.hpp" />

src/Destiny.ut.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
<ClCompile Include="helpers\Console.cpp">
136136
<Filter>src\helpers</Filter>
137137
</ClCompile>
138+
<ClCompile Include="helpers\math.cpp">
139+
<Filter>src\helpers</Filter>
140+
</ClCompile>
138141
</ItemGroup>
139142
<ItemGroup>
140143
<ClInclude Include="menu.hpp">
@@ -230,6 +233,9 @@
230233
<ClInclude Include="..\res\resource.h">
231234
<Filter>res</Filter>
232235
</ClInclude>
236+
<ClInclude Include="helpers\math.hpp">
237+
<Filter>src\helpers</Filter>
238+
</ClInclude>
233239
</ItemGroup>
234240
<ItemGroup>
235241
<Library Include="..\lib\glfw\lib\glfw3.lib">

src/features/aimbot.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#include "features.hpp"
2+
#include "../helpers/math.hpp"
3+
#include "../helpers/utils.hpp"
24
#include "../settings/globals.hpp"
35
#include "../sdk/Vector.hpp"
46
#include "../sdk/CEntity.hpp"
57

6-
#define M_PI 3.14159265358979323846f
78
#define KEY_DOWN 0x8000
89

910
CEntity getClosestEnemy()
1011
{
11-
CEntity entity{};
1212
float closest = FLT_MAX;
1313
int closestIndex = -1;
1414

1515
for (int i = 0; i < 64; ++i)
1616
{
17-
entity = g_Client.getEntityFromList(i);
17+
CEntity entity = g_Client.getEntityFromList(i);
1818

19-
if ((!entity) || (entity == g_LocalPlayer))
19+
if ((entity == NULL) || (entity == g_LocalPlayer))
2020
continue;
2121

2222
if ((!entity.isAlive()) || (entity.isDormant()))
@@ -37,7 +37,16 @@ CEntity getClosestEnemy()
3737
if ((!g_LocalPlayer.getFlags()) && (g_Options.Legit.Aimbot.InAir))
3838
continue;
3939

40-
const float distance = g_LocalPlayer.getOrigin().to(entity.getOrigin()).mag();
40+
Vector2 angles = math::CalculateAngle(g_LocalPlayer.getEyeLocation(), entity.getOrigin());
41+
Vector2 enemyPos{};
42+
if (!math::WorldToScreen(entity.getOrigin(), enemyPos))
43+
continue;
44+
45+
const SIZE windowSize = utils::getTargetSize();
46+
const float distance = std::sqrtf(std::powf(enemyPos.x - (windowSize.cx / 2.f), 2) + std::powf(enemyPos.y - (windowSize.cy / 2.f), 2));
47+
if (distance > g_Options.Legit.Aimbot.Fov)
48+
continue;
49+
4150
if (distance < closest)
4251
{
4352
closest = distance;
@@ -50,13 +59,8 @@ CEntity getClosestEnemy()
5059

5160
void aimAt(Vector3& target)
5261
{
53-
Vector3 myPos = g_LocalPlayer.getOrigin() + g_LocalPlayer.getViewOffset();
54-
Vector3 deltaVec = myPos.to(target);
55-
Vector2 newAngles{};
56-
5762
// Calculate new view angles
58-
newAngles.x = -std::asin(deltaVec.z / deltaVec.mag()) * (180.f / M_PI);
59-
newAngles.y = std::atan2(deltaVec.y, deltaVec.x) * (180.f / M_PI);
63+
Vector2 newAngles = math::CalculateAngle(g_LocalPlayer.getEyeLocation(), target);
6064

6165
// Add RCS if requested
6266
if (g_Options.Legit.RCS.Enable)
@@ -86,11 +90,11 @@ void features::legit::aimbot()
8690
return;
8791

8892
CWeaponEntity weapon = g_LocalPlayer.getActiveWeapon();
89-
if ((!weapon) || (!weapon.isGun()))
93+
if ((weapon == NULL) || (!weapon.isGun()))
9094
return;
9195

9296
CEntity entity = getClosestEnemy();
93-
if (!entity)
97+
if (entity == NULL)
9498
return;
9599

96100
Vector3 targetPos = entity.getBoneById(g_Options.Legit.Aimbot.TargetBone + 3);

src/helpers/math.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "math.hpp"
2+
#include "../settings/globals.hpp"
3+
#include "../sdk/Structs.hpp"
4+
#include "../helpers/utils.hpp"
5+
6+
#define M_PI 3.14159265358979323846f
7+
8+
Vector2 math::CalculateAngle(Vector3 src, Vector3 dest)
9+
{
10+
Vector3 deltaVec = src.to(dest);
11+
Vector2 angles{};
12+
13+
angles.x = -std::asin(deltaVec.z / deltaVec.mag()) * (180.f / M_PI);
14+
angles.y = std::atan2(deltaVec.y, deltaVec.x) * (180.f / M_PI);
15+
16+
return angles;
17+
}
18+
19+
bool math::WorldToScreen(Vector3 pos, Vector2& screen)
20+
{
21+
const SIZE windowSize = utils::getTargetSize();
22+
ViewMatrix_t matrix = g_Client.getViewMatrix();
23+
24+
Vector4 clipCoords{};
25+
clipCoords.x = pos.x * matrix.at(0, 0) + pos.y * matrix.at(0, 1) + pos.z * matrix.at(0, 2) + matrix.at(0, 3);
26+
clipCoords.y = pos.x * matrix.at(1, 0) + pos.y * matrix.at(1, 1) + pos.z * matrix.at(1, 2) + matrix.at(1, 3);
27+
clipCoords.z = pos.x * matrix.at(2, 0) + pos.y * matrix.at(2, 1) + pos.z * matrix.at(2, 2) + matrix.at(2, 3);
28+
clipCoords.w = pos.x * matrix.at(3, 0) + pos.y * matrix.at(3, 1) + pos.z * matrix.at(3, 2) + matrix.at(3, 3);
29+
30+
if (clipCoords.w < 0.1f)
31+
return false;
32+
33+
Vector3 normalized{};
34+
normalized.x = clipCoords.x / clipCoords.w;
35+
normalized.y = clipCoords.y / clipCoords.w;
36+
normalized.z = clipCoords.z / clipCoords.w;
37+
38+
screen.x = (windowSize.cx / 2.f * normalized.x) + (normalized.x + windowSize.cx / 2.f);
39+
screen.y = -(windowSize.cy / 2.f * normalized.y) + (normalized.y + windowSize.cy / 2.f);
40+
41+
return true;
42+
}
43+
44+

src/helpers/math.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include "../sdk/Vector.hpp"
4+
5+
namespace math
6+
{
7+
Vector2 CalculateAngle(Vector3 src, Vector3 dest);
8+
bool WorldToScreen(Vector3 pos, Vector2& screen);
9+
}

src/helpers/offsets.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void offsets::initialize()
3636
readValue(json["signatures"]["dwClientState_ViewAngles"], offsets::signatures::dwClientState_ViewAngles);
3737
readValue(json["signatures"]["dwClientState_MapDirectory"], offsets::signatures::dwClientState_MapDirectory);
3838
readValue(json["signatures"]["m_bDormant"], offsets::signatures::m_bDormant);
39+
readValue(json["signatures"]["dwViewMatrix"], offsets::signatures::dwViewMatrix);
3940

4041
readValue(json["netvars"]["m_bIsDefusing"], offsets::netvars::m_bIsDefusing);
4142
readValue(json["netvars"]["m_bIsScoped"], offsets::netvars::m_bIsScoped);

src/helpers/offsets.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace offsets
2121
inline std::uintptr_t dwClientState_ViewAngles;
2222
inline std::uintptr_t dwClientState_MapDirectory;
2323
inline std::uintptr_t m_bDormant;
24+
inline std::uintptr_t dwViewMatrix;
2425
}
2526
namespace netvars
2627
{

src/helpers/utils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ std::string utils::randomString(std::size_t length)
2727
return str;
2828
}
2929

30+
SIZE utils::getTargetSize()
31+
{
32+
RECT rect{};
33+
34+
const HWND csgo = FindWindowA("Valve001", nullptr);
35+
GetClientRect(csgo, &rect);
36+
37+
return SIZE{ rect.right, rect.bottom };
38+
}
39+
3040
bool utils::isTargetRunning()
3141
{
3242
const HWND csgo = FindWindowA("Valve001", nullptr);

src/helpers/utils.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ namespace utils
66
{
77
std::string randomString(std::size_t length);
88

9+
SIZE getTargetSize();
10+
911
bool isTargetRunning();
12+
1013
void saveDefaultValues();
1114
void unload();
1215
}

src/menu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void gui::render()
148148
ImGui::Checkbox("In Air###AimbotInAir", &g_Options.Legit.Aimbot.InAir);
149149
ImGui::Combo("Target Bone###TargetBone", &g_Options.Legit.Aimbot.TargetBone, bones, IM_ARRAYSIZE(bones));
150150
ImGui::SliderInt("Smoothing###AimbotSmoothing", &g_Options.Legit.Aimbot.Smoothing, 1, 25);
151+
ImGui::SliderInt("FOV###AimbotFov", &g_Options.Legit.Aimbot.Fov, 1, 1000);
151152
}
152153
ImGui::EndChild();
153154

0 commit comments

Comments
 (0)