Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.80 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Collections.Generic;
  4. using SlimDX;
  5.  
  6. namespace Teamspeak3
  7. {
  8. public class ENTITY
  9. {
  10. public long Base;
  11. public int Id;
  12. public int Type;
  13. public String Name;
  14. public Vector3 Position;
  15. public float Distance;
  16. public float Yaw;
  17. public float Pitch;
  18. public Vector2 Screen;
  19. public bool Alive;
  20. public int Stance;
  21. public int Health;
  22. public Color Color;
  23. public bool DrawBBox;
  24.  
  25. [Flags]
  26. private enum Read
  27. {
  28. None = 0x0,
  29. Position = 0x1,
  30. Yaw = 0x2,
  31. Pitch = 0x4,
  32. Name = 0x8,
  33. Stance = 0x10,
  34. Health = 0x20
  35. }
  36.  
  37. public ENTITY(long lbase)
  38. {
  39. Base = lbase;
  40. //Id = Main.GameMemory.ReadInt32(lbase + Offset.Id); // this in combination with type is unique identifier (for aimbot)
  41. Type = Main.GameMemory.ReadInt32(lbase + Offset.Type);
  42. // all others will be set to binary representation of 0 by compiler
  43. }
  44.  
  45. public void ReadName()
  46. {
  47. long nameOffset = Main.GameMemory.ReadInt64(Base + Offset.Name);
  48. int nameLength = Math.Min(256, Main.GameMemory.ReadInt32(Base + Offset.NameLength)); // don't read more than 256 bytes
  49. Name = Main.GameMemory.ReadString(nameOffset, nameLength);
  50. }
  51.  
  52. public void ReadPosition(bool readYaw = false)
  53. {
  54. byte[] xyz;
  55. long posOffset;
  56. switch (Type)
  57. {
  58. case 0x04: // Player
  59. case 0x05: // BoyNextDoor
  60. posOffset = Main.GameMemory.ReadInt64(Base + 0x118);
  61. xyz = Main.GameMemory.ReadBytes(posOffset + 0x6e4, 4 * 3);
  62. Position.X = BitConverter.ToSingle(xyz, 0);
  63. Position.Y = BitConverter.ToSingle(xyz, 4);
  64. Position.Z = BitConverter.ToSingle(xyz, 8);
  65. if (readYaw) Yaw = Main.GameMemory.ReadFloat(Base + 0x2D0);
  66. break;
  67. case 0x11: // OffRoad
  68. case 0x72: // Pickup
  69. case 0x76: // PoliceCar
  70. posOffset = Main.GameMemory.ReadInt64(Base + 0x118);
  71. xyz = Main.GameMemory.ReadBytes(posOffset + 0x580, 4 * 3);
  72. Position.X = BitConverter.ToSingle(xyz, 0);
  73. Position.Y = BitConverter.ToSingle(xyz, 4);
  74. Position.Z = BitConverter.ToSingle(xyz, 8);
  75. if (readYaw) Yaw = (float)Math.Atan2(Main.GameMemory.ReadFloat(posOffset + 0x550), Main.GameMemory.ReadFloat(posOffset + 0x558)) - 0.5f * (float)Math.PI;
  76. break;
  77. default:
  78. xyz = Main.GameMemory.ReadBytes(Base + 0x3C90, 4 * 3);
  79. Position.X = BitConverter.ToSingle(xyz, 0);
  80. Position.Y = BitConverter.ToSingle(xyz, 4);
  81. Position.Z = BitConverter.ToSingle(xyz, 8);
  82. if (readYaw) Yaw = Main.GameMemory.ReadFloat(Base + 0x2D0);
  83. break;
  84. }
  85. Distance = Vector3.Distance(Position, Main.Player.Position);
  86. }
  87.  
  88. public void ReadPitch() // for players only (erect penis detection)
  89. {
  90. Pitch = Main.GameMemory.ReadFloat(Base + 0x2E4);
  91. }
  92.  
  93. public void ReadStance()
  94. {
  95. Stance = Main.GameMemory.ReadInt32(Base + Offset.Stance);
  96. }
  97.  
  98. public string GetStance()
  99. {
  100. switch (Stance)
  101. {
  102. case 0: return "Standing";
  103. case 1: return "Crouched";
  104. case 2: return "Walking";
  105. case 3: return "Running";
  106. case 4: return "Jumping";
  107. case 5: return "Crouching";
  108. case 6: return "Prone";
  109. case 7: return "Crawling";
  110. default: return "unknown";
  111. }
  112. }
  113.  
  114. private void readFromMem(Read what)
  115. {
  116. if (what.HasFlag(Read.Name)) ReadName();
  117. if (what.HasFlag(Read.Position)) ReadPosition(what.HasFlag(Read.Yaw));
  118. if (what.HasFlag(Read.Pitch)) ReadPitch();
  119. if (what.HasFlag(Read.Stance)) ReadStance();
  120. }
  121.  
  122. private bool isAlive(bool animal = false)
  123. {
  124. Alive = Convert.ToBoolean(Main.GameMemory.ReadByte(Base + Offset.Alive));
  125. if (animal)
  126. {
  127. long HPoffset = Main.GameMemory.ReadInt64(Base + Offset.HPBase);
  128. if (Main.GameMemory.ReadUInt32(HPoffset + Offset.HP + 4) == 3000) Alive = false; // dirty
  129. else Alive = true;
  130. }
  131. return Alive;
  132. }
  133.  
  134. private bool isVisible() // is it in front of you and within screen area?
  135. {
  136. // call readPosition() before you call isVisible() or better call saul
  137. if (Main.WorldToScreen(Position, out Screen))
  138. return (Screen.Y > Main.GameWindowRect.Top && Screen.X > Main.GameWindowRect.Left && Screen.X < Main.GameWindowRect.Right && Screen.Y < Main.GameWindowRect.Bottom);
  139. else return false;
  140. }
  141.  
  142. // TODO: getColorByType, getColorByName
  143.  
  144. public void ParseAndRead(ref List<ENTITY> screen, ref List<ENTITY> radar, ref List<ENTITY> list)
  145. {
  146. //Read memRadar = Read.Position | Read.Yaw;
  147. Read memEsp = Read.Name | Read.Health;
  148. Read memList = Read.Name;
  149. Read mem = Read.None;
  150. switch (Type)
  151. {
  152. case 0x04: // Player
  153. case 0x05: // SUMMIIIIIIIIIIIT
  154. if (isAlive())
  155. {
  156. Color = Color.SkyBlue;
  157. DrawBBox = Main.BoxedPlayers;
  158. ReadPosition(true);
  159. if (Main.ShowESP && Main.ShowPlayers && isVisible()) { mem |= memEsp | Read.Stance | Read.Pitch; screen.Add(this); }
  160. if ((Main.ShowRadar && Main.RadarPlayers) || Main.ShowAdvancedMap) { radar.Add(this); }
  161. if (Main.ShowEntityLists) { mem |= memList; list.Add(this); }
  162. readFromMem(mem);
  163. }
  164. break;
  165.  
  166. case 0x0C: // Zombie
  167. case 0x5B: // Zombie
  168. if (isAlive(true))
  169. {
  170. Color = Color.Crimson;
  171. DrawBBox = Main.BoxedAggressive;
  172. ReadPosition(true);
  173. if (Main.ShowESP && Main.ShowAggressive && isVisible()) { mem |= memEsp | Read.Stance; screen.Add(this); }
  174. if ((Main.ShowRadar && Main.RadarAggressive) || Main.ShowAdvancedMap) { radar.Add(this); }
  175. if (Main.ShowEntityLists) { mem |= memList; list.Add(this); }
  176. readFromMem(mem);
  177. }
  178. break;
  179. case 0x14: // Wolf
  180. case 0x50: // Bear
  181. if (isAlive(true))
  182. {
  183. Color = Color.OrangeRed;
  184. DrawBBox = Main.BoxedAggressive;
  185. ReadPosition(true);
  186. if (Main.ShowESP && Main.ShowAggressive && isVisible()) { mem |= memEsp; screen.Add(this); }
  187. if ((Main.ShowRadar && Main.RadarAggressive) || Main.ShowAdvancedMap) { radar.Add(this); }
  188. if (Main.ShowEntityLists) { mem |= memList; list.Add(this); }
  189. readFromMem(mem);
  190. }
  191. break;
  192. case 0x13: // Deer
  193. case 0x55: // Rabbit
  194. if (isAlive(true))
  195. {
  196. Color = Color.OliveDrab;
  197. DrawBBox = Main.BoxedAnimals;
  198. ReadPosition(true);
  199. if (Main.ShowESP && Main.ShowAnimals && isVisible()) { mem |= memEsp; screen.Add(this); }
  200. if ((Main.ShowRadar && Main.RadarAnimals) || Main.ShowAdvancedMap) { radar.Add(this); }
  201. if (Main.ShowEntityLists) { mem |= memList; list.Add(this); }
  202. readFromMem(mem);
  203. }
  204. break;
  205. case 0x11: // OffRoad
  206. case 0x72: // Pickup
  207. case 0x76: // PoliceCar
  208. Color = Color.HotPink;
  209. DrawBBox = Main.BoxedVehicles;
  210. ReadPosition(true);
  211. if (Main.ShowESP && Main.ShowVehicles && isVisible()) { mem |= memEsp; screen.Add(this); }
  212. if ((Main.ShowRadar && Main.RadarVehicles) || Main.ShowAdvancedMap) { radar.Add(this); }
  213. if (Main.ShowEntityLists) { mem |= memList; list.Add(this); }
  214. readFromMem(mem);
  215. break;
  216. case 0x34: // Weapons
  217. ReadPosition();
  218. if (Main.ShowESP && Main.ShowWeapons && isVisible())
  219. {
  220. ReadName();
  221. if (Name.Contains(".308") || Name.Contains("Shotgun") || Name == "AR15" || Name == "M1911A1" || Name.Contains("M9") || Name == "R380" || Name.Contains("Magnum"))
  222. Color = Color.Gold;
  223. else Color = Color.BurlyWood;
  224. mem |= memEsp & ~Read.Name;
  225. screen.Add(this);
  226. }
  227. readFromMem(mem);
  228. break;
  229. case 0x15: // Ammo, Water, Bottle, Food, ...
  230. ReadPosition();
  231. if (Main.ShowESP && Main.ShowAmmo && isVisible())
  232. {
  233. ReadName();
  234. if (Name.Contains(".") || Name.Contains("Shell") || Name.Contains("mm"))
  235. Color = Color.Orange;
  236. else Color = Color.Plum;
  237. mem |= memEsp & ~Read.Name;
  238. screen.Add(this);
  239. }
  240. readFromMem(mem);
  241. break;
  242. case 0x2E: // Loot
  243. Color = Color.GreenYellow;
  244. ReadPosition();
  245. if (Main.ShowESP && Main.ShowItems && isVisible()) { mem |= memEsp; screen.Add(this); }
  246. readFromMem(mem);
  247. break;
  248. case 0x1B: // Campfire
  249. case 0x6D: // Stash
  250. case 0x9C: // Land Mine, IED
  251. Color = Color.SaddleBrown;
  252. ReadPosition();
  253. if (Main.ShowESP && Main.ShowItems && isVisible()) { mem |= memEsp; screen.Add(this); }
  254. readFromMem(mem);
  255. break;
  256. case 0x2F: // Furnace
  257. case 0x33: // Storage Container
  258. case 0x35: // Animal Trap
  259. case 0x36: // Dew Collector
  260. case 0x53: // Barbeque
  261. Color = Color.Gray;
  262. ReadPosition();
  263. if (Main.ShowESP && Main.ShowContainers && isVisible()) { mem |= memEsp; screen.Add(this); }
  264. readFromMem(mem);
  265. break;
  266. case 0x2C: // First Aid, Helmet, Backpack, Armor, Helmet, Battery, Sparkplugs, ...
  267. ReadPosition();
  268. if (Main.ShowESP && Main.ShowItems && isVisible())
  269. {
  270. ReadName();
  271. if (Name.Contains("Battery") || Name.Contains("Sparkplugs") || Name.Contains("Turbo") || Name.Contains("Headlights")) Color = Color.DeepPink;
  272. else if (Name.Contains("First")) Color = Color.LimeGreen;
  273. else Color = Color.White;
  274. mem |= memEsp & ~Read.Name;
  275. if (!Name.Contains("T-") && !Name.Contains("Duct")) screen.Add(this); // hide T-Shirts & Duct Tapes
  276. }
  277. readFromMem(mem);
  278. break;
  279. case 0x16: // Dresser
  280. case 0x17: // Armoire
  281. case 0x19: // World Doors
  282. case 0x1D: // Cabinets
  283. case 0x1E: // Cabinets
  284. case 0x21: // Cabinets
  285. case 0x22: // Cabinets
  286. case 0x23: // Cabinets
  287. case 0x25: // Refrigerator
  288. case 0x26: // Garbage Can
  289. case 0x28: // Cabinets
  290. case 0x29: // Desk
  291. case 0x27: // Dumpster
  292. case 0x30: // File Cabinet
  293. case 0x31: // Tool Cabinet
  294. case 0x37: // Recycle Bin (with fire)
  295. case 0x38: // Punji Sticks
  296. case 0x3D: // Wooded Barricade
  297. case 0x3E: // Water Well
  298. case 0x3F: // Armoire
  299. case 0x40: // Dresser
  300. case 0x42: // Chest
  301. case 0x44: // Wrecked Sedan
  302. case 0x45: // Wrecked Van
  303. case 0x46: // Wrecked Truck
  304. case 0x49: // Ottoman
  305. case 0x4A: // Ottoman
  306. case 0x4F: // Designer-placed(?) Door
  307. case 0x5D: // File Cabinet
  308. case 0x61: // Cabinets
  309. case 0x63: // Cabinets
  310. case 0x6F: // Locker
  311. case 0x70: // Weapon Locker
  312. case 0x71: // Glass Cabinet
  313. case 0x79: // Designer-placed(?) Door
  314. case 0x7A: // Resting (Bed)
  315. case 0x7B: // Designer-placed(?) Door
  316. case 0x7C: // Designer-placed(?) Door
  317. case 0x7D: // IO.FireHydrant
  318. case 0x7E: // IO.FireHydrant
  319. case 0x80: // Cabinets
  320. case 0x81: // Cabinets
  321. case 0x82: // Cabinets
  322. case 0x83: // Cabinets
  323. case 0x84: // Cabinets
  324. case 0x85: // Cabinets
  325. case 0x86: // Cabinets
  326. case 0x87: // Cabinets
  327. case 0x88: // Cabinets
  328. case 0x89: // Cabinets
  329. case 0xA1: // Washing Machine
  330. case 0xA2: // Dryer
  331. break;
  332. case 0x3B: // Ground Tamper
  333. case 0x4C: // Shed
  334. case 0x5F: // Metal Wall/Gate
  335. case 0x62: // Basic Shack Door
  336. case 0x6E: // Desk Foundation
  337. case 0x9E: // Metal Door
  338. case 0xA6: // Large Shelter
  339. case 0xA7: // Shed
  340. break;
  341. case 0x2D: // Flare
  342. case 0xA8: // Torch
  343. case 0xA0: // Corn Seeds, Wheat Seeds
  344. case 0x78: // Parachute
  345. case 0xAA: // BeeBox
  346. // 0x2A: Handcuff Key
  347. // 0xAD: Explosive Barel
  348. // 0xB5: Fuel
  349. break;
  350. default: // Other Items, append type to name
  351. ReadPosition();
  352. if (Main.ShowESP && Main.ShowItems && isVisible())
  353. {
  354. Color = Color.Teal;
  355. ReadName();
  356. Name = Name + "[" + Type.ToString("X2") + "]";
  357. mem |= memEsp & ~Read.Name;
  358. screen.Add(this);
  359. }
  360. readFromMem(mem);
  361. break;
  362. }
  363. }
  364. }
  365. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement