Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.81 KB | None | 0 0
  1. void aimbot(){
  2.     for (;;){
  3.         if (AimBot) {
  4.             int PlayerNumber = Other.ClosestEntity();
  5.             if (PlayerNumber > 0 && PlayerNumber <= 64 && !Entity.IsDead(PlayerNumber ) && !Entity.IsDormant(PlayerNumber ) && Local.GetTeam() != Entity.GetTeam(PlayerNumber )) {
  6.                     AimAngle = CalculateAngle(PlayerNumber, 6);
  7.                     AimAngle = Local.NormalizeAngle(AimAngle);
  8.                     CurrentAngle = Local.ViewAngle();
  9.                     CurrentAngle = Local.NormalizeAngle(CurrentAngle);
  10.  
  11.                     if (Local.Fov(Entity.Position(PlayerNumber), AimAngle, CurrentAngle) <= aimbot_pistol_fov_int) {
  12.                         SetAngle(AimAngle, CurrentAngle, Smoothness);
  13.                 }
  14.             }
  15.         }
  16.         Sleep(1);
  17.     }
  18. }
  19.  
  20. struct{
  21.     Vector NormalizeAngle(Vector angle){
  22.         if (!std::isfinite(angle.x))
  23.         {
  24.             angle.x = 0;
  25.         }
  26.         if (!std::isfinite(angle.y))
  27.         {
  28.             angle.y = 0;
  29.         }
  30.         while (angle.y < -180.0f) angle.y += 360.0f;
  31.         while (angle.y > 180.0f) angle.y -= 360.0f;
  32.         if (angle.x > 89.0f) angle.x = 89.0f;
  33.         if (angle.x < -89.0f) angle.x = -89.0f;
  34.         angle.z = 0;
  35.         return angle;
  36.     }
  37.     Vector SmoothAngle(Vector SrcAngles, Vector DestAngles, int SmoothAmount) {
  38.         Vector SmoothedAngles;
  39.         SmoothedAngles.x = SrcAngles.x + (DestAngles.x - SrcAngles.x) * SmoothAmount;
  40.         SmoothedAngles.y = SrcAngles.y + (DestAngles.y - SrcAngles.y) * SmoothAmount;
  41.         SmoothedAngles.z = SrcAngles.z + (DestAngles.z - SrcAngles.z) * SmoothAmount;
  42.  
  43.         return NormalizeAngle(SmoothedAngles);
  44.     }
  45.     bool fovCheck(DWORD EntityBase, Vector CurrentAngles, Vector AimAngles, float MaximumFov){
  46.         Vector MyPosition = Player.GetPosition();
  47.         Vector EntityPosition = Entity.GetPosition(EntityBase);
  48.         float distance = Server.GetDistance(MyPosition, EntityPosition);
  49.         float pitch = sin(DEG2RAD(CurrentAngles.x - AimAngles.x)) * distance;
  50.         float yaw = sin(DEG2RAD(CurrentAngles.y - AimAngles.y)) * distance;
  51.         float fov = sqrt(powf(pitch, 2.0) + powf(yaw, 2.0));
  52.         if (fov <= MaximumFov)
  53.             return true;
  54.         else
  55.             return false;
  56.     }
  57.     Vector compensateVelocity(DWORD EntityBase, Vector EnemyPos, float smoothAmount){
  58.         Vector EntityVelocity = Entity.GetVelocity(EntityBase);
  59.         Vector MyVelocity = Player.GetVelocity();
  60.         EnemyPos.x = EnemyPos.x + (EntityVelocity.x / 100.f) * (40.f / smoothAmount);
  61.         EnemyPos.y = EnemyPos.y + (EntityVelocity.y / 100.f) * (40.f / smoothAmount);
  62.         EnemyPos.z = EnemyPos.z + (EntityVelocity.z / 100.f) * (40.f / smoothAmount);
  63.         EnemyPos.x = EnemyPos.x - (MyVelocity.x / 100.f) * (40.f / smoothAmount);
  64.         EnemyPos.y = EnemyPos.y - (MyVelocity.y / 100.f) * (40.f / smoothAmount);
  65.         EnemyPos.z = EnemyPos.z - (MyVelocity.z / 100.f) * (40.f / smoothAmount);
  66.         return EnemyPos;
  67.     }
  68.     Vector getAimAngles(DWORD EntityBase, int TargetBone){
  69.         Vector AimAngles;
  70.         Vector myPosition = Player.GetPosition();
  71.         Vector entityPosition = Entity.GetBonePosition(EntityBase, TargetBone);
  72.         entityPosition = compensateVelocity(EntityBase, entityPosition, 40);
  73.         Vector Punch = Player.GetPunch();
  74.         Vector ViewOrigin = Player.GetViewOrigin();
  75.         float pitchreduction = Server.GetRandomFloat(2.f, 2.f);
  76.         float yawreduction = Server.GetRandomFloat(2.f, 2.f);
  77.         float delta[3] = { (myPosition.x - entityPosition.x), (myPosition.y - entityPosition.y), ((myPosition.z + ViewOrigin.z) - entityPosition.z) };
  78.         float hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
  79.         //AimAngles.x = atanf(delta[2] / hyp)* (180/M_PI) - Punch.x *pitchreduction;
  80.         //AimAngles.y = atanf(delta[1] / delta[0]) *(180/M_PI) - Punch.y *yawreduction;
  81.         AimAngles.x = atanf(delta[2] / hyp)* (180 / M_PI) - Punch.x *pitchreduction;
  82.         AimAngles.y = atanf(delta[1] / delta[0]) *(180 / M_PI) - Punch.y *yawreduction;
  83.         AimAngles.z = 0.0f;
  84.         if (delta[0] >= 0.0){
  85.             AimAngles.y += 180.0f;
  86.         }
  87.         return AimAngles;
  88.     }
  89.     double DEG2RAD(double d){
  90.         return (d*M_PI / 180);
  91.     }
  92.     int ClosestEntity()
  93.     {
  94.         float CurrentDistance = 0xFFFFFF;
  95.         int ClosestTarget = -1;
  96.         for (int i = 0; i <= 64; i++)
  97.         {
  98.             if (i > 0 && i <= 64 && !Entity.IsDead(i) && !Entity.IsDormant(i) && Local.GetTeam() != Entity.GetTeam(i))
  99.             {
  100.                 Vector AimAngles = CalculateAngle(i, 6);
  101.                 float Distance = Local.Distance(Local.ViewAngle(), AimAngles);
  102.                 if (Distance < CurrentDistance)
  103.                 {
  104.                     CurrentDistance = Distance;
  105.                     ClosestTarget = i;
  106.                 }
  107.             }
  108.         }
  109.         if (ClosestTarget != 0)
  110.             return ClosestTarget;
  111.     }
  112.     void SetAngle(Vector dest, Vector orig, float Smooth)
  113.     {
  114.         Vector SmoothAngles;
  115.         SmoothAngles.x = dest.x - orig.x;
  116.         SmoothAngles.y = dest.y - orig.y;
  117.         SmoothAngles.z = 0.0f;
  118.         SmoothAngles = Local.NormalizeAngle(SmoothAngles);
  119.         SmoothAngles.x = orig.x + SmoothAngles.x / 100.0f * (Smooth / 10);
  120.         SmoothAngles.y = orig.y + SmoothAngles.y / 100.0f * (Smooth / 10);
  121.         SmoothAngles.z = 0.0f;
  122.         SmoothAngles = Local.NormalizeAngle(SmoothAngles);
  123.         Engine->Write<Vector>(Local.EngineBase() + Utils->GetOffset("m_dwViewAngles"), SmoothAngles);
  124.     }
  125. }Other;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement