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
910CEntity 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
5160void 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 );
0 commit comments