Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bullet Trace For BO2
- //Big Thanks To James And Therifboy For Their Work On Ghost!
- Read More @ http://www.nextgenupdate.com/forums/showthread.php?t=732377&p=5797696
- class Offsets
- {
- public static uint
- //G_Client
- G_Client = 0x1780F28,
- ClientOrigin = 0x28,
- ClientAngles = 0x56BC,
- //Entity
- G_Entity = 0x16B9F20,
- G_EntitySize = 0x31C,
- G_SetOrigin = 0x279698,
- Trace_GetEntityHitID = 0x306F30,
- G_GetPlayerViewOrigin = 0x1E60D0,
- G_LocationalTrace = 0x35C598;
- public class Funcs
- {
- public static uint G_Client(int clientIndex, uint Mod = 0x00)
- {
- return (Offsets.G_Client + (UInt32)Mod) + ((uint)clientIndex * 0x5808);
- }
- public static uint G_Entity(int entityIndex, uint Mod = 0x00)
- {
- return (Offsets.G_Entity + (UInt32)Mod) + ((uint)entityIndex * 0x31C);
- }
- }
- public static byte[] ReverseBytes(byte[] toReverse)
- {
- Array.Reverse(toReverse);
- return toReverse;
- }
- public static void WriteSingle(uint address, float[] input)
- {
- int length = input.Length;
- byte[] array = new byte[length * 4];
- for (int i = 0; i < length; i++)
- {
- ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int) (i * 4));
- }
- PS3.SetMemory(address, array);
- }
- public static float ReadFloat(uint offset)
- {
- byte[] bytes = PS3.GetMemory(offset, 4);
- Array.Reverse(bytes, 0, 4);
- return BitConverter.ToSingle(bytes, 0);
- }
- public static float[] ReadSingle(uint address, int length)
- {
- byte[] memory = PS3.GetMemory(address, length * 4);
- ReverseBytes(memory);
- float[] numArray = new float[length];
- for (int i = 0; i < length; i++)
- {
- numArray[i] = BitConverter.ToSingle(memory, ((length - 1) - i) * 4);
- }
- return numArray;
- }
- public static float[] PlayerAnglesToForward(int clientIndex, float Distance = 200f)
- {
- float[] Angles = ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientAngles), 3);
- float[] Position = ReadSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientOrigin), 3);
- float angle, sr, sp, sy, cr, cp, cy, PiDiv;
- PiDiv = ((float)Math.PI / 180f);
- angle = Angles[1] * PiDiv;
- sy = (float)Math.Sin(angle);
- cy = (float)Math.Cos(angle);
- angle = Angles[0] * PiDiv;
- sp = (float)Math.Sin(angle);
- cp = (float)Math.Cos(angle);
- angle = Angles[2] * PiDiv;
- sr = (float)Math.Sin(angle);
- cr = (float)Math.Cos(angle);
- float[] Forward = new float[] { (cp * cy * Distance) + Position[0], (cp * sy * Distance) + Position[1], (-sp * Distance) + Position[2] };
- return Forward;
- }
- public static void setPlayerPosition(int clientIndex, float[] Pos)
- {
- WriteSingle(Offsets.Funcs.G_Client(clientIndex, Offsets.ClientOrigin), Pos);
- }
- public static float[] G_GetPlayerViewOrigin(int clientIndex)
- {
- PS3.SetMemory(0x2600250, new byte[0xC]);
- RPC.Call(Offsets.G_GetPlayerViewOrigin, Offsets.Funcs.G_Client(clientIndex), 0x2600250);
- return ReadSingle(0x2600250, 3);
- }
- public static void G_LocationalTrace(int clientIndex, int Trace, float[] Start, float[] End)
- {
- RPC.Call(Offsets.G_LocationalTrace, Trace, Start, End, clientIndex, 0x280E8B3, 0);
- }
- public static int Trace_GetEntityHitId(int Trace)
- {
- return RPC.Call(Offsets.Trace_GetEntityHitID, Trace);
- }
- public static int TraceEntity(int clientIndex, float TracerDistance)
- {
- int Trace = 0x25D2B00;
- float[] Start = G_GetPlayerViewOrigin(clientIndex);
- float[] End = PlayerAnglesToForward(clientIndex, TracerDistance);
- G_LocationalTrace(clientIndex, Trace, Start, End);
- int Entity = Trace_GetEntityHitId(Trace) & 0xFFFF;
- if (Entity < 0x3FE)
- { Entity = (int)Offsets.Funcs.G_Entity(Entity); }
- else
- { Entity = 0; }
- return Entity;
- }
- public static float[] TraceBullet(int clientIndex, float TracerDistance)
- {
- int Trace = 0x25D2B00;
- float[] Start = G_GetPlayerViewOrigin(clientIndex);
- float[] End = PlayerAnglesToForward(clientIndex, TracerDistance);
- G_LocationalTrace(clientIndex, Trace, Start, End);
- float[] BulletTrace = new float[3];
- 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])) };
- return BulletTrace;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement