Advertisement
sharkbait263

[BO2] BulletTrace

May 9th, 2014
1,083
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.12 KB | None | 0 0
  1. //Bullet Trace For BO2
  2. //Big Thanks To James And Therifboy For Their Work On Ghost!
  3.  
  4. Read More @ http://www.nextgenupdate.com/forums/showthread.php?t=732377&p=5797696
  5.  
  6.     class Offsets
  7.     {
  8.         public static uint
  9.         //G_Client
  10.         G_Client = 0x1780F28,
  11.         ClientOrigin = 0x28,
  12.         ClientAngles = 0x56BC,
  13.  
  14.         //Entity
  15.         G_Entity = 0x16B9F20,
  16.         G_EntitySize = 0x31C,
  17.         G_SetOrigin = 0x279698,
  18.         Trace_GetEntityHitID = 0x306F30,
  19.         G_GetPlayerViewOrigin = 0x1E60D0,
  20.         G_LocationalTrace = 0x35C598;
  21.  
  22.  
  23.         public class Funcs
  24.         {
  25.             public static uint G_Client(int clientIndex, uint Mod = 0x00)
  26.             {
  27.                 return (Offsets.G_Client + (UInt32)Mod) + ((uint)clientIndex * 0x5808);
  28.             }
  29.             public static uint G_Entity(int entityIndex, uint Mod = 0x00)
  30.             {
  31.                 return (Offsets.G_Entity + (UInt32)Mod) + ((uint)entityIndex * 0x31C);
  32.             }
  33.         }
  34.  
  35. public static byte[] ReverseBytes(byte[] toReverse)
  36.         {
  37.             Array.Reverse(toReverse);
  38.             return toReverse;
  39.         }
  40.  
  41. public static void WriteSingle(uint address, float[] input)
  42.         {
  43.             int length = input.Length;
  44.             byte[] array = new byte[length * 4];
  45.             for (int i = 0; i < length; i++)
  46.             {
  47.                 ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int) (i * 4));
  48.             }
  49.             PS3.SetMemory(address, array);
  50.         }
  51.  
  52. public static float ReadFloat(uint offset)
  53. {
  54.     byte[] bytes = PS3.GetMemory(offset, 4);
  55.     Array.Reverse(bytes, 0, 4);
  56.     return BitConverter.ToSingle(bytes, 0);
  57. }
  58.  
  59. public static float[] ReadSingle(uint address, int length)
  60.         {
  61.             byte[] memory = PS3.GetMemory(address, length * 4);
  62.             ReverseBytes(memory);
  63.             float[] numArray = new float[length];
  64.             for (int i = 0; i < length; i++)
  65.             {
  66.                 numArray[i] = BitConverter.ToSingle(memory, ((length - 1) - i) * 4);
  67.             }
  68.             return numArray;
  69.         }
  70.  
  71. public static float[] PlayerAnglesToForward(int clientIndex, float Distance = 200f)
  72.         {
  73.             float[] Angles = ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientAngles), 3);
  74.             float[] Position = ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientOrigin), 3);
  75.             float angle, sr, sp, sy, cr, cp, cy, PiDiv;
  76.             PiDiv = ((float)Math.PI / 180f);
  77.             angle = Angles[1] * PiDiv;
  78.             sy = (float)Math.Sin(angle);
  79.             cy = (float)Math.Cos(angle);
  80.             angle = Angles[0] * PiDiv;
  81.             sp = (float)Math.Sin(angle);
  82.             cp = (float)Math.Cos(angle);
  83.             angle = Angles[2] * PiDiv;
  84.             sr = (float)Math.Sin(angle);
  85.             cr = (float)Math.Cos(angle);
  86.             float[] Forward = new float[] { (cp * cy * Distance) + Position[0], (cp * sy * Distance) + Position[1], (-sp * Distance) + Position[2] };
  87.             return Forward;
  88.         }
  89.  
  90. public static void setPlayerPosition(int clientIndex, float[] Pos)
  91.         {
  92.             WriteSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientOrigin), Pos);
  93.         }
  94.  
  95. public static float[] G_GetPlayerViewOrigin(int clientIndex)
  96.         {
  97.             PS3.SetMemory(0x2600250, new byte[0xC]);
  98.             RPC.Call(Offsets.G_GetPlayerViewOrigin, Offsets.Funcs.G_Client(clientIndex), 0x2600250);
  99.             return ReadSingle(0x2600250, 3);
  100.         }
  101.  
  102.         public static void G_LocationalTrace(int clientIndex, int Trace, float[] Start, float[] End)
  103.         {
  104.             RPC.Call(Offsets.G_LocationalTrace, Trace, Start, End, clientIndex, 0x280E8B3, 0);
  105.         }
  106.  
  107.         public static int Trace_GetEntityHitId(int Trace)
  108.         {
  109.             return RPC.Call(Offsets.Trace_GetEntityHitID, Trace);
  110.         }
  111.  
  112.         public static int TraceEntity(int clientIndex, float TracerDistance)
  113.         {
  114.             int Trace = 0x25D2B00;
  115.             float[] Start = G_GetPlayerViewOrigin(clientIndex);
  116.             float[] End = PlayerAnglesToForward(clientIndex, TracerDistance);
  117.             G_LocationalTrace(clientIndex, Trace, Start, End);
  118.             int Entity = Trace_GetEntityHitId(Trace) & 0xFFFF;
  119.             if (Entity < 0x3FE)
  120.             { Entity = (int)Offsets.Funcs.G_Entity(Entity); }
  121.             else
  122.             { Entity = 0; }
  123.             return Entity;
  124.         }
  125.  
  126.         public static float[] TraceBullet(int clientIndex, float TracerDistance)
  127.         {
  128.             int Trace = 0x25D2B00;
  129.             float[] Start = G_GetPlayerViewOrigin(clientIndex);
  130.             float[] End = PlayerAnglesToForward(clientIndex, TracerDistance);
  131.             G_LocationalTrace(clientIndex, Trace, Start, End);
  132.             float[] BulletTrace = new float[3];
  133.             BulletTrace = new float[] { (((End[0] - Start[0]) * ReadFloat((uint)Trace + 0x10) + Start[0])), (((End[1] - Start[1]) * ReadFloat((uint)Trace + 0x10) + Start[1])), (((End[2] - Start[2]) * ReadFloat((uint)Trace + 0x10) + Start[2])) };        
  134.             return BulletTrace;
  135.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement