ScriptzMoDz

BO2 Fair Aimbot

Aug 25th, 2014
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.88 KB | None | 0 0
  1.     class Offsets
  2.     {
  3.         public static uint
  4.  
  5.         //G_Client
  6.         G_Client = 0x1780F28,
  7.         G_ClientSize = 0x5808,
  8.         ClientOrigin = 0x28,
  9.         ClientAngles = 0x56BC,
  10.         ClientTeam = 0x5504,
  11.         ClientIsAlive = 0x55D0,
  12.         ClientStance = 0xFC,
  13.  
  14.         //Entity
  15.         G_Entity = 0x16B9F20,
  16.         G_EntitySize = 0x31C,
  17.         SetClientViewAngles = 0x1E1D90;
  18.  
  19.  
  20.         public class Funcs
  21.         {
  22.             public static float[] getPlayerPosition(int clientIndex)
  23.             {
  24.                 float[] Position = Lib.ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientOrigin), 3);
  25.                 return Position;
  26.             }
  27.             public static uint G_Client(int clientIndex, uint Mod = 0x00)
  28.             {
  29.                 return (Offsets.G_Client + (UInt32)Mod) + ((uint)clientIndex * 0x5808);
  30.             }
  31.             public static uint G_Entity(int entityIndex, uint Mod = 0x00)
  32.             {
  33.                 return (Offsets.G_Entity + (UInt32)Mod) + ((uint)entityIndex * 0x31C);
  34.             }
  35.         }
  36.      }
  37.  
  38. public static bool ClientIsSameTeam(int clientIndex, int otherPlayer)
  39.         {
  40.             return (Lib.ReadInt32(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientTeam)) == Lib.ReadInt32(Offsets.Funcs.G_Client(otherPlayer, Offsets.ClientTeam)));
  41.         }
  42.         public static bool ClientIsInGame(int clientIndex)
  43.         {
  44.             return (Lib.ReadInt32(Offsets.Funcs.G_Client(clientIndex, 0x00)) != 0);
  45.         }
  46.         public static bool ClientIsAlive(int clientIndex)
  47.         {
  48.             return (Lib.ReadInt32(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientIsAlive)) == 0);
  49.         }
  50.         public static void Player_Die(int Killer, int Victim, int meansOfDeath = 18, int iWeapon = 0)
  51.         {
  52.             iWeapon = Lib.ReadInt32(Offsets.Funcs.G_Client(Killer, Offsets.ClientCurrentWeapon));
  53.             UInt32 Attacker = Offsets.Funcs.G_Entity(Killer);
  54.             UInt32 Inflictor = Offsets.Funcs.G_Entity(Victim);
  55.             RPC.Call(Offsets.Scr_PlayerKilled, Inflictor, Attacker, Attacker, 0xFF, meansOfDeath, iWeapon, 0xD0300AD4C);
  56.             Thread.Sleep(100);
  57.         }
  58.         public static float[] vectoangles(float[] Angles)
  59.         {
  60.             float forward;
  61.             float yaw, pitch;
  62.             float[] angles = new float[3];
  63.             if (Angles[1] == 0 && Angles[0] == 0)
  64.             {
  65.                 yaw = 0;
  66.                 if (Angles[2] > 0) pitch = 90f;
  67.                 else pitch = 270f;
  68.             }
  69.             else
  70.             {
  71.                 if (Angles[0] != -1) yaw = (float)(Math.Atan2((double)Angles[1], (double)Angles[0]) * 180f / Math.PI);
  72.                 else if (Angles[1] > 0) yaw = 90f;
  73.                 else yaw = 270;
  74.                 if (yaw < 0) yaw += 360f;
  75.  
  76.                 forward = (float)Math.Sqrt((double)(Angles[0] * Angles[0] + Angles[1] * Angles[1]));
  77.                 pitch = (float)(Math.Atan2((double)Angles[2], (double)forward) * 180f / Math.PI);
  78.                 if (pitch < 0) pitch += 360f;
  79.             }
  80.             angles[0] = -pitch;
  81.             angles[1] = yaw;
  82.             angles[2] = 0;
  83.  
  84.             return angles;
  85.         }
  86.         public static float[] getVector(float[] point1, float[] point2)
  87.         {
  88.             return new float[] { (point2[0] - point1[0]), (point2[1] - point1[1]), (point2[2] - point1[2]) };
  89.         }
  90.         public static float Distance3D(float[] point1, float[] point2)
  91.         {
  92.             float deltax = point2[0] - point1[0];
  93.             float deltay = point2[1] - point1[1];
  94.             float deltaz = point2[2] - point1[2];
  95.             return Convert.ToSingle(Math.Sqrt((deltax * deltax) + (deltay * deltay) + (deltaz * deltaz)));
  96.         }
  97.         public static float Distance2D(float[] point1, float[] point2)
  98.         {
  99.             float deltax = point2[0] - point1[0];
  100.             float deltaz = point2[1] - point1[1];
  101.             return Convert.ToSingle(Math.Sqrt((deltax * deltax) + (deltaz * deltaz)));
  102.         }
  103.         public static void vec_scale(float[] vec, float scale, out float[] Forward)
  104.         {
  105.             Forward = new float[] { vec[0] * scale, vec[1] * scale, vec[2] * scale };
  106.         }
  107.         public static int GetNearestPlayer(Int32 clientIndex, Boolean EnemyOnly = false)
  108.         {
  109.             int nearestClient = 0;
  110.             float nearestDistance = 99999999;
  111.             for (int i = 0; i < MenuBase.MaxClients; i++)
  112.             {
  113.                 if (i != clientIndex)
  114.                 {
  115.                     if ((ClientIsInGame(i)) && ClientIsAlive(i))
  116.                     {
  117.                         if (Lib.ReadInt32(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientTeam)) != 0 && EnemyOnly)
  118.                         {
  119.                             if (!ClientIsSameTeam(clientIndex, i))
  120.                             {
  121.                                 float Distance = Distance3D(Functions.getPlayerPosition(clientIndex), Functions.getPlayerPosition(i));
  122.                                 if (Distance < nearestDistance)
  123.                                 {
  124.                                     nearestDistance = Distance;
  125.                                     nearestClient = i;
  126.                                 }
  127.                             }
  128.                         }
  129.                         else
  130.                         {
  131.                             float Distance = Distance3D(Functions.getPlayerPosition(clientIndex), Functions.getPlayerPosition(i));
  132.                             if (Distance < nearestDistance)
  133.                             {
  134.                                 nearestDistance = Distance;
  135.                                 nearestClient = i;
  136.                             }
  137.                         }
  138.                     }
  139.                 }
  140.             }
  141.             return nearestClient;
  142.         }
  143.  
  144.         public static bool[] AimbotStatus = new bool[MenuBase.MaxClients];
  145.         public static Thread[] AimbotThread = new Thread[MenuBase.MaxClients];
  146.         public static bool[] UnfairAimbot = new bool[MenuBase.MaxClients];
  147.         public static bool[] AimingRequired = new bool[MenuBase.MaxClients];
  148.  
  149.         private static float CheckStance(int clientIndex)
  150.         {
  151.             Int32 CurrentStance = Lib.ReadByte(Functions.G_Client(clientIndex) + Offsets.ClientStance + 0x03);
  152.             if (CurrentStance == 0x08 || CurrentStance == 0x0A || CurrentStance == 0x48 || CurrentStance == 0x4A)
  153.             { return 44f; }
  154.             if (CurrentStance == 0x04 || CurrentStance == 0x06 || CurrentStance == 0x44 || CurrentStance == 0x46)
  155.             { return 14f; }
  156.             return 0f;
  157.         }
  158.         private static float CheckStanceAttacker(int clientIndex)
  159.         {
  160.             Int32 CurrentStance = Lib.ReadByte(Functions.G_Client(clientIndex) + Offsets.ClientStance + 0x03);
  161.             if (CurrentStance == 0x08 || CurrentStance == 0x0A || CurrentStance == 0x48 || CurrentStance == 0x4A)
  162.             { return 46f; }
  163.             if (CurrentStance == 0x04 || CurrentStance == 0x06 || CurrentStance == 0x44 || CurrentStance == 0x46)
  164.             { return 18f; }
  165.             return 0f;
  166.         }
  167.  
  168.         private static void InitializeAimbot(int clientIndex)
  169.         {
  170.             PS3.Reconnect();
  171.             while (AimbotStatus[clientIndex])
  172.             {
  173.                 if (MenuBase.Menu[clientIndex].isOpen == false)
  174.                 {
  175.                     int nearestPlayer = GetNearestPlayer(clientIndex);
  176.                     if (nearestPlayer != clientIndex)
  177.                     {
  178.                         if (AimingRequired[clientIndex] == true && UnfairAimbot[clientIndex] == false)
  179.                         {
  180.                             if (Buttons.Normal.DetectButton(clientIndex, Buttons.Normal.L1))
  181.                             {
  182.                                 SetClientViewAngles(clientIndex, nearestPlayer);
  183.                             }
  184.                         }
  185.                         if (UnfairAimbot[clientIndex] == true && AimingRequired[clientIndex] == true)
  186.                         {
  187.                             if (Buttons.Normal.DetectButton(clientIndex, Buttons.Normal.L1))
  188.                             {
  189.                                 SetClientViewAngles(clientIndex, nearestPlayer);
  190.                                 if (Buttons.Normal.DetectButton(clientIndex, Buttons.Normal.R1))
  191.                                 {
  192.                                     SetClientViewAngles(clientIndex, nearestPlayer);
  193.                                     Player_Die(clientIndex, nearestPlayer);
  194.                                 }
  195.                             }
  196.                         }
  197.                         if (UnfairAimbot[clientIndex] == true && AimingRequired[clientIndex] == false)
  198.                         {
  199.                             SetClientViewAngles(clientIndex, nearestPlayer);
  200.                             if (Buttons.Normal.DetectButton(clientIndex, Buttons.Normal.R1))
  201.                             {
  202.                                 Player_Die(clientIndex, nearestPlayer);
  203.                             }
  204.                         }
  205.                         if (UnfairAimbot[clientIndex] == false && AimingRequired[clientIndex] == false)
  206.                         {
  207.                             SetClientViewAngles(clientIndex, nearestPlayer);
  208.                         }
  209.                     }
  210.                 }
  211.             }
  212.         }
  213.  
  214.         public static float[] PlayerAnglesToForward(int clientIndex, float Distance = 200f)
  215.         {
  216.             float[] Angles = Lib.ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientAngles), 3);
  217.             float[] Position = Lib.ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientOrigin), 3);
  218.             float angle, sr, sp, sy, cr, cp, cy, PiDiv;
  219.             PiDiv = ((float)Math.PI / 180f);
  220.             angle = Angles[1] * PiDiv;
  221.             sy = (float)Math.Sin(angle);
  222.             cy = (float)Math.Cos(angle);
  223.             angle = Angles[0] * PiDiv;
  224.             sp = (float)Math.Sin(angle);
  225.             cp = (float)Math.Cos(angle);
  226.             angle = Angles[2] * PiDiv;
  227.             sr = (float)Math.Sin(angle);
  228.             cr = (float)Math.Cos(angle);
  229.             float[] Forward = new float[] { (cp * cy * Distance) + Position[0], (cp * sy * Distance) + Position[1], (-sp * Distance) + Position[2] };
  230.             return Forward;
  231.         }
  232.         public static float[] AnglesToForward(float[] Angles, float Distance = 200f)
  233.         {
  234.             float angle, sr, sp, sy, cr, cp, cy, PiDiv;
  235.             PiDiv = ((float)Math.PI / 180f);
  236.             angle = Angles[1] * PiDiv;
  237.             sy = (float)Math.Sin(angle);
  238.             cy = (float)Math.Cos(angle);
  239.             angle = Angles[0] * PiDiv;
  240.             sp = (float)Math.Sin(angle);
  241.             cp = (float)Math.Cos(angle);
  242.             angle = Angles[2] * PiDiv;
  243.             sr = (float)Math.Sin(angle);
  244.             cr = (float)Math.Cos(angle);
  245.             float[] Forward = new float[] { (cp * cy * Distance), (cp * sy * Distance), (-sp * Distance) };
  246.             return Forward;
  247.         }
  248.  
  249.         private static void SetClientViewAngles(int clientIndex, int Victim)
  250.         {
  251.             float[] Vec = getVector(Functions.getPlayerPosition(clientIndex), Functions.getPlayerPosition(Victim));
  252.             Vec[2] -= CheckStance(Victim);
  253.             Vec[2] += CheckStanceAttacker(clientIndex);
  254.             float[] Angles = vectoangles(Vec);
  255.             setViewAngles((UInt32)clientIndex, Angles);
  256.         }
  257.         public static void setViewAngles(UInt32 clientIndex, float[] Angles)
  258.         {
  259.             Lib.WriteSingle(0x10040000, Angles);
  260.             RPC.Call(Offsets.SetClientViewAngles, Offsets.Funcs.G_Entity((int)clientIndex), 0x10040000);
  261.         }
  262.         public static float[] getViewAngles(int clientIndex)
  263.         {
  264.             return Lib.ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientAngles), 3);
  265.         }
Add Comment
Please, Sign In to add comment