Advertisement
Guest User

Visuals.cpp

a guest
Jul 5th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.95 KB | None | 0 0
  1. #include "Visuals.h"
  2. #include "Entity.h"
  3. #include "RecoilControl.h"
  4. #include "MyWindow.h"
  5.  
  6.  
  7. #include "Process.h"
  8.  
  9.  
  10. #include"ObjectManager.h"
  11.  
  12.  
  13. CVisuals* Visuals = new CVisuals;
  14.  
  15.  
  16. Color CVisuals::EnemyBoxColor = Color((float)255 / (float)255, (float)255 / (float)255, (float)0 / (float)255, (float)0 / (float)255);
  17. Color CVisuals::AllyBoxColor = Color(255 / 255, 0 / 255, 0 / 255, 255 / 255);
  18.  
  19.  
  20. Color CVisuals::HealthTextColor = Color((float)255 / (float)255, (float)0 / (float)255, (float)255 / (float)255, (float)0 / (float)255);
  21. Color CVisuals::DistanceTextColor = Color(255 / 255, 255 / 255, 255 / 255, 0 / 255);
  22. Color CVisuals::WeaponTextColor = Color(255 / 255, 255 / 255, 255 / 255, 0 / 255);
  23. Color CVisuals::NameTextColor = Color(255 / 255, 255 / 255, 255 / 255, 0 / 255);
  24.  
  25.  
  26. Color CVisuals::BombBoxColor = Color(255 / 255, 255 / 255, (float)125 / (float)255, 0 / 255);
  27. Color CVisuals::BombTextColor = Color(255 / 255, 255 / 255, 255 / 255, 255 / 255);
  28.  
  29.  
  30. Color CVisuals::WeaponDropedBoxColor = Color(255 / 255, 255 / 255, (float)125 / (float)255, 0 / 255);
  31. Color CVisuals::WeaponDropedTextColor = Color(255 / 255, 255 / 255, 255 / 255, 255 / 255);
  32.  
  33.  
  34. Color CVisuals::CrosshairColor = Color(255 / 255, 0 / 255, 255 / 255, 255 / 255);
  35. Color CVisuals::RecoilCircleColor = Color(255 / 255, 255 / 255, 0 / 255, 255 / 255);
  36. float CVisuals::RecoilDrawResolution = 6.0f;
  37. int CVisuals::RecoilDrawType = 0;
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. CVisuals::CVisuals()
  45. {
  46. LastTextXPos = DistancePosX = 3;
  47. LastTextYPos = DistancePosY = CMyWindow::FontSpacing;
  48. LastTextXPos = WearingWeponPosX = 3;
  49. LastTextYPos = WearingWeponPosY = LastTextYPos + CMyWindow::FontSpacing;
  50. HealthPosX = 0;
  51. HealthPosY = CMyWindow::FontSpacing;
  52.  
  53.  
  54. bDrawCrosshair = false;
  55. bDrawRecoilCrosshair = false;
  56. bDrawESP = false;
  57. bDrawHealth = false;
  58. bDrawSnapLine = false;
  59. bDrawHead = false;
  60. bDrawBones = false;
  61. bDrawBone = false;
  62. bDrawDistance = false;
  63. bDrawWeapon = false;
  64. bDrawName = false;
  65. bDrawAlly = false;
  66. bDrawBomb = false;
  67. bDrawGranades = false;
  68. bDrawDropedWeapons = false;
  69. }
  70.  
  71.  
  72.  
  73.  
  74. CVisuals::~CVisuals()
  75. {
  76. }
  77.  
  78.  
  79. void CVisuals::InitPosiitons()
  80. {
  81. LastTextXPos = DistancePosX = 3;
  82. LastTextYPos = DistancePosY = CMyWindow::FontSpacing;
  83. LastTextXPos = WearingWeponPosX = 3;
  84. LastTextYPos = WearingWeponPosY = LastTextYPos + CMyWindow::FontSpacing;
  85. HealthPosX = 0;
  86. HealthPosY = CMyWindow::FontSpacing;
  87. }
  88.  
  89.  
  90. void CVisuals::Render()
  91. {
  92. if (CRadar::Active)
  93. Radar->Draw();
  94.  
  95.  
  96. for (int i = 0; i < GlobalVariables::MaxPlayers; i++)
  97. {
  98. if (!Entity[i].Valid)
  99. continue;
  100.  
  101.  
  102. Radar->DrawEntity(i);
  103.  
  104.  
  105. if (!Entity[i].IsOnScreen)
  106. continue;
  107.  
  108.  
  109. if (Entity[i].Dormant)
  110. continue;
  111.  
  112.  
  113. if (Entity[i].Team != LocalPlayer->Team)
  114. {
  115. if (bDrawESP)
  116. DrawESP(i, Red);
  117. if (bDrawHealth)
  118. DrawHealth(i);
  119. if (bDrawSnapLine)
  120. DrawSnapLine(i, Red);
  121. if (bDrawHead)
  122. DrawHead(i, Aqua);
  123. if (bDrawBones)
  124. DrawBones(i, Yellow);
  125. if (bDrawDistance)
  126. DrawDistance(i);
  127. if (bDrawWeapon)
  128. DrawWeapon(i);
  129. if (bDrawName)
  130. DrawName(i);
  131. }
  132. else
  133. {
  134. if (!bDrawAlly)
  135. continue;
  136.  
  137.  
  138. if (bDrawESP)
  139. DrawESP(i, Blue);
  140. if (bDrawHealth)
  141. DrawHealth(i);
  142. if (bDrawSnapLine)
  143. DrawSnapLine(i, Blue);
  144. if (bDrawHead)
  145. DrawHead(i, Green);
  146. if (bDrawBones)
  147. DrawBones(i, Green);
  148. if (bDrawDistance)
  149. DrawDistance(i);
  150. if (bDrawWeapon)
  151. DrawWeapon(i);
  152. if (bDrawName)
  153. DrawName(i);
  154. }
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161. }
  162.  
  163.  
  164. if (bDrawCrosshair)
  165. DrawCrosshair();
  166.  
  167.  
  168. if (bDrawRecoilCrosshair)
  169. DrawRecoilCrosshair();
  170.  
  171.  
  172. if (CAimBot::DrawFOV && CAimBot::Active)
  173. DrawFovAimbot();
  174.  
  175.  
  176. //ObjectManager->ReadObjects();
  177.  
  178.  
  179. if (bDrawBomb)
  180. DrawBomb();
  181.  
  182.  
  183. if (bDrawDropedWeapons)
  184. DrawDropedWeapons();
  185. }
  186.  
  187.  
  188. void CVisuals::DrawFovAimbot()
  189. {
  190. Drawings->FilledCircle(CMyWindow::CenterX, CMyWindow::CenterY, CAimBot::Radius, 20, CAimBot::FovColor);
  191. }
  192.  
  193.  
  194. void CVisuals::DrawCrosshair()
  195. {
  196. Drawings->FilledBox(CMyWindow::CenterX + 2, CMyWindow::CenterY - 1, 6, 3, CrosshairColor);
  197. Drawings->FilledBox(CMyWindow::CenterX - 1, CMyWindow::CenterY + 3, 2, 6, CrosshairColor);
  198.  
  199.  
  200. Drawings->FilledBox(CMyWindow::CenterX - 8, CMyWindow::CenterY - 1, 6, 3, CrosshairColor);
  201. Drawings->FilledBox(CMyWindow::CenterX - 1, CMyWindow::CenterY - 8, 2, 6, CrosshairColor);
  202. }
  203.  
  204.  
  205. void CVisuals::DrawRecoilCrosshair()
  206. {
  207. Vector3D Punch = LocalPlayer->ReadPunch();
  208. float Punch2ScreenX = (CMyWindow::Width / 358.f) * (Punch.x * 2);
  209. float Punch2ScreenY = (CMyWindow::Height / 178.f) * (Punch.y * 2);
  210.  
  211.  
  212. switch (RecoilDrawType)
  213. {
  214. case 0:
  215. Drawings->Circle(CMyWindow::CenterX - Punch2ScreenY, CMyWindow::CenterY + Punch2ScreenX, RecoilDrawResolution, 10, RecoilCircleColor);
  216. break;
  217. case 1:
  218. Drawings->FilledBox(CMyWindow::CenterX - Punch2ScreenY + 2, CMyWindow::CenterY + Punch2ScreenX - 1, 6, 3, RecoilCircleColor);
  219. Drawings->FilledBox(CMyWindow::CenterX - Punch2ScreenY - 1, CMyWindow::CenterY + Punch2ScreenX + 3, 2, 6, RecoilCircleColor);
  220.  
  221.  
  222. Drawings->FilledBox(CMyWindow::CenterX - Punch2ScreenY - 8, CMyWindow::CenterY + Punch2ScreenX - 1, 6, 3, RecoilCircleColor);
  223. Drawings->FilledBox(CMyWindow::CenterX - Punch2ScreenY - 1, CMyWindow::CenterY + Punch2ScreenX - 8, 2, 6, RecoilCircleColor);
  224. break;
  225. }
  226.  
  227.  
  228. }
  229.  
  230.  
  231. void CVisuals::DrawESP(int PlayerIndex, Color Color)
  232. {
  233. if (Entity[PlayerIndex].IsOnScreen)
  234. {
  235. if (Entity[PlayerIndex].PseudoHeadIsOnScreen)
  236. {
  237.  
  238.  
  239. Drawings->Box(Entity[PlayerIndex].Box.left, Entity[PlayerIndex].Box.top, Entity[PlayerIndex].BoxWidth, Entity[PlayerIndex].BoxHeight, 2, Color);
  240. }
  241. }
  242. }
  243.  
  244.  
  245. void CVisuals::DrawHealth(int PlayerIndex)
  246. {
  247. if (Entity[PlayerIndex].IsOnScreen)
  248. {
  249. char Buf[1];
  250. sprintf(Buf, "%d", Entity[PlayerIndex].Health);
  251. Drawings->ShadowCenterText(Buf, Entity[PlayerIndex].PosOnScreen.x, Entity[PlayerIndex].PosOnScreen.y + HealthPosY, HealthTextColor);
  252. }
  253. }
  254.  
  255.  
  256. void CVisuals::DrawSnapLine(int PlayerIndex, Color Color)
  257. {
  258. Drawings->Line(LocalPlayer->PositionOnScreen.x, LocalPlayer->PositionOnScreen.y, Entity[PlayerIndex].PosOnScreen.x, Entity[PlayerIndex].PosOnScreen.y, 1, Color);
  259. }
  260.  
  261.  
  262. void CVisuals::DrawHead(int PlayerIndex, Color color)
  263. {
  264. if (Entity[PlayerIndex].ValidBones == false)
  265. return;
  266.  
  267.  
  268. Vector3D HeadPosTop;
  269. Vector3D HeadPosBot;
  270.  
  271.  
  272. Vector3D HeadTop = Entity[PlayerIndex].Bone[10].PositionInGame;
  273. Vector3D HeadBot = Entity[PlayerIndex].Bone[10].PositionInGame;
  274. HeadBot.z -= 7;//5
  275. HeadTop.z += 17;//10
  276. int BoneWidth;
  277. int BoneHeight;
  278. if (WorldToScreen(HeadBot, HeadPosBot) && WorldToScreen(HeadTop, HeadPosTop))
  279. {
  280. BoneWidth = BoneHeight = HeadPosBot.y - HeadPosTop.y;
  281. Drawings->Box(HeadPosTop.x - BoneWidth / 2, HeadPosTop.y, BoneWidth, BoneHeight, 2, color);
  282. }
  283. }
  284.  
  285.  
  286. void CVisuals::DrawBones(int PlayerIndex, Color Color)
  287. {
  288. if (Entity[PlayerIndex].ValidBones == false)
  289. return;
  290.  
  291.  
  292. Entity[PlayerIndex].ReadBoneFromMatrix(0);
  293. Entity[PlayerIndex].ReadBoneFromMatrix(7);
  294. Entity[PlayerIndex].ReadBoneFromMatrix(8);
  295. Entity[PlayerIndex].ReadBoneFromMatrix(13);
  296. Entity[PlayerIndex].ReadBoneFromMatrix(14);
  297. Entity[PlayerIndex].ReadBoneFromMatrix(15);
  298. Entity[PlayerIndex].ReadBoneFromMatrix(21);
  299. Entity[PlayerIndex].ReadBoneFromMatrix(24);
  300. Entity[PlayerIndex].ReadBoneFromMatrix(25);
  301. Entity[PlayerIndex].ReadBoneFromMatrix(27);
  302. Entity[PlayerIndex].ReadBoneFromMatrix(28);
  303.  
  304.  
  305. DrawBone(0, 5, PlayerIndex, Color);
  306.  
  307.  
  308. DrawBone(5, 13, PlayerIndex, Color);
  309. DrawBone(13, 14, PlayerIndex, Color);
  310. DrawBone(14, 15, PlayerIndex, Color);
  311.  
  312.  
  313. DrawBone(5, 7, PlayerIndex, Color);
  314. DrawBone(7, 8, PlayerIndex, Color);
  315. DrawBone(8, 21, PlayerIndex, Color);
  316.  
  317.  
  318. DrawBone(28, 27, PlayerIndex, Color);
  319. DrawBone(27, 0, PlayerIndex, Color);
  320.  
  321.  
  322. DrawBone(25, 24, PlayerIndex, Color);
  323. DrawBone(24, 0, PlayerIndex, Color);
  324. }
  325.  
  326.  
  327. void CVisuals::DrawBone(int Start, int End, int PlayerIndex, Color Color)
  328. {
  329.  
  330.  
  331. if (!Entity[PlayerIndex].Bone[Start].IsOnScreen)
  332. return;
  333.  
  334.  
  335. if (!Entity[PlayerIndex].Bone[End].IsOnScreen)
  336. return;
  337.  
  338.  
  339. Drawings->Line(Entity[PlayerIndex].Bone[Start].PositionOnScreen.x, Entity[PlayerIndex].Bone[Start].PositionOnScreen.y, Entity[PlayerIndex].Bone[End].PositionOnScreen.x, Entity[PlayerIndex].Bone[End].PositionOnScreen.y, 1, Color);
  340. };
  341.  
  342.  
  343.  
  344.  
  345. void CVisuals::DrawDistance(int Index)
  346. {
  347. char Buf[32];
  348. sprintf(Buf, "%.f", Entity[Index].Distance);
  349. Drawings->ShadowText(Buf, Entity[Index].Box.right + DistancePosX, Entity[Index].Box.top + DistancePosY, DistanceTextColor);
  350.  
  351.  
  352. }
  353.  
  354.  
  355. void CVisuals::DrawWeapon(int Index)
  356. {
  357. if (Entity[Index].WeaponID > 0 && Entity[Index].WeaponID<52)
  358. Drawings->ShadowText(WeaponName[Entity[Index].WeaponID], Entity[Index].Box.right + WearingWeponPosX, Entity[Index].Box.top + WearingWeponPosY, WeaponTextColor);
  359. }
  360.  
  361.  
  362. void CVisuals::DrawName(int Index)
  363.  
  364.  
  365. {
  366.  
  367.  
  368. ReadProcessMemory(Process->hProcess, (LPCVOID*)(Offsets::RadarBaseAddress + (0x1E0 * Index) + 0x204), &Entity[Index].Name, sizeof(Entity[Index].Name), 0);
  369. Drawings->ShadowCenterText(Entity[Index].Name, Entity[Index].PosOnScreen.x, Entity[Index].Box.top - 3, NameTextColor);
  370. }
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377. void CVisuals::DrawBomb()
  378. {
  379. //if (Bomb.Owner != -1)
  380. // return;
  381.  
  382.  
  383. Vector3D PositionBot;
  384. Vector3D PositionTop;
  385. if (WorldToScreen(Bomb.Position, PositionBot))
  386. {
  387.  
  388.  
  389. Drawings->Box(PositionBot.x - 10, PositionBot.y - 10, 20, 20, 1, BombBoxColor);
  390. Drawings->ShadowText(_TempXOR("Bomb"), PositionBot.x, PositionBot.y, BombTextColor);
  391. //DrawString("Bomb", PositionBot.x - 10, PositionBot.y + 10, D3DCOLOR_ARGB(255, 255, 255, 255), m_pFontSmall);
  392. }
  393.  
  394.  
  395. }
  396.  
  397.  
  398. void CVisuals::DrawDropedWeapons()
  399. {
  400.  
  401.  
  402. for (int i = 0; i < CWeapon::Count; i++)
  403. {
  404. Vector3D PositionBot;
  405. if (WorldToScreen(Weapon[i].Position, PositionBot))
  406. {
  407.  
  408.  
  409. Drawings->Box(PositionBot.x - 10, PositionBot.y - 10, 20, 20, 1, WeaponDropedBoxColor);
  410. Drawings->ShadowText(Weapon[i].Name, PositionBot.x, PositionBot.y, WeaponDropedTextColor);
  411. //DrawString(Buf, PositionBot.x - 10, PositionBot.y + 10, D3DCOLOR_ARGB(255, 255, 255, 255), m_pFontSmall);
  412. }
  413. }
  414.  
  415.  
  416. }
  417.  
  418.  
  419. char *RecoilDrawTypes[2] = { _OnceXOR("Circle"), _OnceXOR("Cross") };
  420.  
  421.  
  422. char *WeaponName[52] =
  423. {
  424. _OnceXOR("0"),
  425. _OnceXOR("Desert Eagle"),
  426. _OnceXOR("Dual Berettas"),
  427. _OnceXOR("Five-SeveN"),
  428. _OnceXOR("Glock"),
  429. _OnceXOR("5"),
  430. _OnceXOR("6"),
  431. _OnceXOR("AK-47"),
  432. _OnceXOR("AUG"),
  433. _OnceXOR("AWP"),
  434. _OnceXOR("FAMAS"),
  435. _OnceXOR("G3SG1"),
  436. _OnceXOR("12"),
  437. _OnceXOR("Galil AR"),
  438. _OnceXOR("M249"),
  439. _OnceXOR("15"),
  440. _OnceXOR("M4A4"),
  441. _OnceXOR("MAC-10"),
  442. _OnceXOR("18"),
  443. _OnceXOR("P90"),
  444. _OnceXOR("20"),
  445. _OnceXOR("21"),
  446. _OnceXOR("22"),
  447. _OnceXOR("23"),
  448. _OnceXOR("UMP-45"),
  449. _OnceXOR("XM1014"),
  450. _OnceXOR("PP-Bizon"),
  451. _OnceXOR("MAG-7"),
  452. _OnceXOR("Negev"),
  453. _OnceXOR("Sawed-Off"),
  454. _OnceXOR("30"),
  455. _OnceXOR("Zeus x27"),
  456. _OnceXOR("P2000"),
  457. _OnceXOR("MP7"),
  458. _OnceXOR("MP9"),
  459. _OnceXOR("Nova"),
  460. _OnceXOR("CZ75-Auto"),
  461. _OnceXOR("37"),
  462. _OnceXOR("SCAR-20"),
  463. _OnceXOR("SG 553"),
  464. _OnceXOR("SSG 08"),
  465. _OnceXOR("41"),
  466. _OnceXOR("Knife"),
  467. _OnceXOR("Flashbang"),
  468. _OnceXOR("HE Granade"),
  469. _OnceXOR("Smoke Granade"),
  470. _OnceXOR("46"),
  471. _OnceXOR("Decoy Granade"),
  472. _OnceXOR("48"),
  473. _OnceXOR("C4"),
  474. _OnceXOR("50"),
  475. _OnceXOR("Tec-9"),
  476. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement