Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.38 KB | None | 0 0
  1. #include "ESP.h"
  2. #include "..\..\Utils\GlobalVars.h"
  3. #include "..\Aimbot\Aimbot.h"
  4. #include "..\Aimbot\LagComp.h"
  5. #include "..\..\Utils\Utils.h"
  6. #include "..\..\SDK\IVEngineClient.h"
  7. #include "..\..\SDK\PlayerInfo.h"
  8. #include "..\..\SDK\ISurface.h"
  9. #include "..\..\SDK\Hitboxes.h"
  10. #include "..\..\Utils\Math.h"
  11. #include "..\..\Menu\Menu.h"
  12. #include "..\Misc\Misc.h"
  13. #include "..\..\Utils\Interfaces.h"
  14. #include <stdio.h>
  15. #include <ctype.h>
  16. #include <comdef.h>
  17. #include "../../SDK/vector2d.h"
  18. #include <windows.h>
  19. #include <iostream>
  20. #include <cstdint>
  21. #include <memory>
  22. #include <vector>
  23. #include <thread>
  24. #include <chrono>
  25. #include <array>
  26. #include <fstream>
  27. #include <istream>
  28. #include <unordered_map>
  29. #include <intrin.h>
  30. #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
  31. float flPlayerAlpha[1024];
  32.  
  33. std::string clean_item_name(std::string name) {
  34. std::string Name = name;
  35.  
  36. auto weapon_start = Name.find("weapon");
  37. if (weapon_start != std::string::npos)
  38. Name.erase(Name.begin() + weapon_start, Name.begin() + weapon_start + 6);
  39.  
  40. if (Name[0] == '_')
  41. Name.erase(Name.begin());
  42.  
  43. if (Name[0] == 'c') //optional for dropped weapons - designer
  44. Name.erase(Name.begin());
  45.  
  46. return Name;
  47. }
  48. bool WorldToScreen(const Vector& world, Vector& screen) {
  49. auto screen_transform = [&world, &screen]() -> bool {
  50. static auto &matrix = g_pEngine->WorldToScreenMatrix();
  51.  
  52. screen.x = matrix[0][0] * world.x + matrix[0][1] * world.y + matrix[0][2] * world.z + matrix[0][3];
  53. screen.y = matrix[1][0] * world.x + matrix[1][1] * world.y + matrix[1][2] * world.z + matrix[1][3];
  54. screen.z = 0.0f;
  55.  
  56. float w = matrix[3][0] * world.x + matrix[3][1] * world.y + matrix[3][2] * world.z + matrix[3][3];
  57.  
  58. if (w < 0.001f) {
  59. screen.x *= 100000;
  60. screen.y *= 100000;
  61. return false;
  62. }
  63.  
  64. screen.x /= w;
  65. screen.y /= w;
  66.  
  67. return true;
  68. };
  69.  
  70. if (screen_transform()) {
  71. int w, h;
  72. g_pEngine->GetScreenSize(w, h);
  73.  
  74. screen.x = (w / 2.0f) + (screen.x * w) / 2.0f;
  75. screen.y = (h / 2.0f) - (screen.y * h) / 2.0f;
  76.  
  77. return true;
  78. }
  79.  
  80. return false;
  81. }
  82.  
  83. float StoredCurtimePlayer[1024];
  84. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  85. #include <minwindef.h>
  86.  
  87.  
  88.  
  89.  
  90.  
  91. void c_visuals::BoxESP(C_BaseEntity* Entity) {
  92. Vector min, max;
  93. Entity->GetRenderBounds(min, max);
  94. Vector pos, pos3D, top, top3D;
  95. pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
  96. top3D = pos3D + Vector(0, 0, max.z + 11);
  97. Color ESP = Color(g_Menu.Config.BoxColor.red, g_Menu.Config.BoxColor.green, g_Menu.Config.BoxColor.blue, flPlayerAlpha[Entity->EntIndex()]);
  98. Color ESP2 = Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
  99.  
  100. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
  101. {
  102. int height = (pos.y - top.y);
  103. int y = top.y;
  104. int width = height / 2;
  105. int x = pos.x - ((width / 2) / 2);
  106. int x2 = pos.x - (width / 2);
  107. int h = height;
  108. int w = width / 2;
  109.  
  110. int iw = w / 3.5;
  111. int ih = (h / 3.5) - 1;
  112. bool IsTeammate = Entity->GetTeam() == g::pLocalEntity->GetTeam();
  113. bool IsEnemy = Entity->GetTeam() != g::pLocalEntity->GetTeam();
  114. bool IsLocal = Entity == g::pLocalEntity;
  115.  
  116. if (IsEnemy) {
  117.  
  118. g_pSurface->OutlinedRect(x2, y, width, height, ESP);
  119. g_pSurface->OutlinedRect(x2 - 1, y - 1, width + 2, height + 2, ESP2);
  120. g_pSurface->OutlinedRect(x2 + 1, y + 1, width - 2, height - 2, ESP2);
  121. }
  122.  
  123. }
  124. }
  125. void c_visuals::set_hitmarker_time(float time)
  126. {
  127. float flHurtTime = 0.f;
  128. flHurtTime = time;
  129. }
  130.  
  131. void set_dormant_time(float time)
  132. {
  133. float dormanttime = 0.f;
  134. dormanttime = time;
  135. }
  136. void c_visuals::spec()
  137. {
  138. auto local_player = g_pEntityList->GetClientEntity(g_pEngine->GetLocalPlayer());
  139.  
  140. if (!local_player)
  141. return;
  142.  
  143. if (local_player->GetHealth() <= 0)
  144. return;
  145.  
  146. static int lineSize = 4.25;
  147.  
  148. static float alpha = 0;
  149. float step = 255.f / 0.3f *g_pGlobalVars->frametime;
  150. float flHurtTime = 0.f;
  151. if (g_pGlobalVars->realtime - flHurtTime < .3f)
  152. alpha = 255.f;
  153. else
  154. alpha -= step;
  155.  
  156. if (alpha > 0)
  157. {
  158. int screenSizeX, screenCenterX;
  159. int screenSizeY, screenCenterY;
  160. g_pEngine->GetScreenSize(screenSizeX, screenSizeY);
  161.  
  162. screenCenterX = screenSizeX / 2;
  163. screenCenterY = screenSizeY / 2;
  164. Color col = Color(240, 240, 240, alpha);
  165. g_pSurface->Line(screenCenterX - lineSize * 2, screenCenterY - lineSize * 2, screenCenterX - (lineSize), screenCenterY - (lineSize), col);
  166. g_pSurface->Line(screenCenterX - lineSize * 2, screenCenterY + lineSize * 2, screenCenterX - (lineSize), screenCenterY + (lineSize), col);
  167. g_pSurface->Line(screenCenterX + lineSize * 2, screenCenterY + lineSize * 2, screenCenterX + (lineSize), screenCenterY + (lineSize), col);
  168. g_pSurface->Line(screenCenterX + lineSize * 2, screenCenterY - lineSize * 2, screenCenterX + (lineSize), screenCenterY - (lineSize), col);
  169. }
  170. }
  171. void c_visuals::indicators2()
  172. {
  173. }
  174.  
  175. void c_visuals::NameESP(C_BaseEntity* Entity) {
  176. Vector min, max;
  177. Entity->GetRenderBounds(min, max);
  178. Vector pos, pos3D, top, top3D;
  179. pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
  180. top3D = pos3D + Vector(0, 0, max.z + 11);
  181. PlayerInfo_s EntityInfo;
  182. g_pEngine->GetPlayerInfo(Entity->EntIndex(), &EntityInfo);
  183. Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(g_Menu.Config.NameColor.red, g_Menu.Config.NameColor.green, g_Menu.Config.NameColor.blue, flPlayerAlpha[Entity->EntIndex()]);
  184. Color ESP2 = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
  185.  
  186. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
  187. {
  188. int height = (pos.y - top.y);
  189. int y = top.y;
  190. int width = height / 2;
  191. int x = pos.x - (width / 2);
  192.  
  193. g_pSurface->DrawT(x + (width / 2), y - 14, ESP, g::EspTahoma, true, EntityInfo.szName);
  194. }
  195. }
  196.  
  197. mstudiobbox_t* get_hitbox(C_BaseEntity* entity, int hitbox_index)
  198. {
  199. if (entity->IsDormant() || entity->GetHealth() <= 0)
  200. return NULL;
  201.  
  202. const auto pModel = entity->GetModel();
  203. if (!pModel)
  204. return NULL;
  205.  
  206. auto pStudioHdr = g_pModelInfo->GetStudiomodel(pModel);
  207. if (!pStudioHdr)
  208. return NULL;
  209.  
  210. auto pSet = pStudioHdr->GetHitboxSet(0);
  211. if (!pSet)
  212. return NULL;
  213.  
  214. if (hitbox_index >= pSet->numhitboxes || hitbox_index < 0)
  215. return NULL;
  216.  
  217. return pSet->GetHitbox(hitbox_index);
  218. }
  219. Vector GetHitboxPosition(C_BaseEntity* entity, int hitbox_id)
  220. {
  221. auto hitbox = get_hitbox(entity, hitbox_id);
  222. if (!hitbox)
  223. return Vector(0, 0, 0);
  224.  
  225. auto bone_matrix = entity->GetBoneMatrix(hitbox->bone);
  226.  
  227. Vector bbmin, bbmax;
  228. g_Math.VectorTransform(hitbox->min, bone_matrix, bbmin);
  229. g_Math.VectorTransform(hitbox->max, bone_matrix, bbmax);
  230.  
  231. return (bbmin + bbmax) * 0.5f;
  232. }
  233.  
  234. void c_visuals::QuakeKillCounter()
  235. {
  236. if (!g_pEngine->IsInGame() || !g_pEngine->IsConnected()) return;
  237.  
  238. int screen_sizex, screen_sizey, cW, cH;
  239. g_pEngine->GetScreenSize(screen_sizex, screen_sizey);
  240.  
  241. cW = screen_sizex / 2;
  242. cH = screen_sizey / 2;
  243.  
  244. float animationAlpha = 0.0;
  245. int alpha = 0;
  246. float animation_speed_value = 0.6;
  247. float step = 255 / 0.6 * g_pGlobalVars->frametime;
  248.  
  249. if (g::killtime + 2 > g_pGlobalVars->realtime)
  250. {
  251. alpha = 255;
  252. }
  253. else
  254. alpha = alpha - step;
  255.  
  256. float animate = g_pGlobalVars->curtime;
  257.  
  258. float endTime = g::globalAlpha + 1.1f;
  259. float t = 1.0f - (endTime - g_pGlobalVars->curtime) / (endTime - g::globalAlpha);
  260.  
  261.  
  262. float animationStep = animation_speed_value * g_pGlobalVars->frametime;
  263.  
  264. /*if (g::killtime + 0.1 > g_pGlobalVars->realtime)
  265. {
  266. animationAlpha -= 80;
  267. }
  268. else*/
  269. animationAlpha = animationAlpha - animationStep;
  270.  
  271. int customY, customX;
  272.  
  273.  
  274.  
  275. screen_sizey = (screen_sizey / 2) - (t * (20.0f));
  276. screen_sizex = (screen_sizex / 2) - (t * (20.0f));
  277.  
  278. if (alpha > 0)
  279. {
  280.  
  281. switch (g::kills)
  282. {
  283. case 1:
  284. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(255, 0, 0, alpha), g::Indicators, true, "FIRST BLOOD");
  285. break;
  286. case 2:
  287. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(0, 0, 255, alpha), g::Indicators, true, "DOUBLE KILL");
  288. break;
  289. case 3:
  290. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(0, 255, 0, alpha), g::Indicators, true, "TRIPLE KILL");
  291. break;
  292. case 4:
  293. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(155, 200, 0, alpha), g::Indicators, true, "MULTI KILL");
  294. break;
  295. case 5:
  296. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(200, 0, 167, alpha), g::Indicators, true, "ULTRA KILL");
  297. break;
  298. case 6:
  299. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(23, 34, 255, alpha), g::Indicators, true, "KILLING SPREE");
  300. break;
  301.  
  302. default:
  303. g_pSurface->DrawT(screen_sizex, screen_sizey, Color(23, 34, 255, alpha), g::Indicators, true, "HUMILIATION");
  304. break;
  305. }
  306.  
  307. }
  308.  
  309.  
  310. }
  311.  
  312.  
  313. bool IsOnScreen(Vector origin, Vector& screen)
  314. {
  315. if (!WorldToScreen(origin, screen)) return false;
  316. int iScreenWidth, iScreenHeight;
  317. g_pEngine->GetScreenSize(iScreenWidth, iScreenHeight);
  318. bool xOk = iScreenWidth > screen.x > 0, yOk = iScreenHeight > screen.y > 0;
  319. return xOk && yOk;
  320. }
  321.  
  322. void TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color)
  323. {
  324. static int texture_id = g_pSurface->CreateNewTextureID(true); //
  325. static unsigned char buf[4] = { 255, 255, 255, 255 };
  326. g_pSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
  327. g_pSurface->DrawSetColor(color); //
  328. g_pSurface->DrawSetTexture(texture_id); //
  329. g_pSurface->DrawTexturedPolygon(n, vertice.data()); //
  330. }
  331.  
  332. #include <map>
  333.  
  334.  
  335. bool DisplayAmmo[65];
  336. void c_visuals::WeaponESP(C_BaseEntity* Entity) {
  337. Vector min, max;
  338. Entity->GetRenderBounds(min, max);
  339. Vector pos, pos3D, top, top3D;
  340. pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
  341. top3D = pos3D + Vector(0, 0, max.z + 11);
  342. //spectators();
  343. auto Weapon = Entity->GetActiveWeapon();
  344.  
  345. Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(g_Menu.Config.WeaponColor.red, g_Menu.Config.WeaponColor.green, g_Menu.Config.WeaponColor.blue, flPlayerAlpha[Entity->EntIndex()]);
  346. Color ESP2 = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
  347.  
  348. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
  349. {
  350. int height = (pos.y - top.y);;
  351. int y = top.y;
  352. int width = height / 2;
  353. int x = pos.x - (width / 2);
  354.  
  355. if (!Weapon)
  356. return;
  357.  
  358. auto weapon_data = Weapon->GetCSWpnData();
  359.  
  360. auto item_definition_index = Weapon->GetItemDefinitionIndex();
  361.  
  362. if (!weapon_data)
  363. return;
  364.  
  365.  
  366. const auto xposition = x + (width / 2);
  367. const auto yposition = y + height + 1;
  368.  
  369. bool IsTeammate = Entity->GetTeam() == g::pLocalEntity->GetTeam();
  370. bool IsEnemy = Entity->GetTeam() != g::pLocalEntity->GetTeam();
  371. bool IsLocal = Entity == g::pLocalEntity;
  372. int TypeOfEntity;
  373. if (IsLocal) {
  374.  
  375. }
  376. else if (IsEnemy) {
  377.  
  378. }
  379. else if (IsTeammate) {
  380.  
  381. }
  382. auto add = g_Menu.Config.ammo && DisplayAmmo[Entity->EntIndex()] ? 5 : 0;
  383. auto DrawWeaponIcon = [Weapon, xposition, yposition, IsLocal, IsEnemy, IsTeammate, add, ESP]() -> bool
  384. {
  385. char icon_letter = '\0';
  386.  
  387.  
  388. if (IsEnemy && !g_Menu.Config.Weapon) {
  389. return false;
  390. }
  391. switch (reinterpret_cast<C_BaseCombatWeapon*>(Weapon)->GetItemDefinitionIndex())
  392. {
  393. case ItemDefinitionIndex::WEAPON_DEAGLE:
  394. icon_letter = 'A';
  395. break;
  396. case ItemDefinitionIndex::WEAPON_KNIFE:
  397. case ItemDefinitionIndex::WEAPON_KNIFE_T:
  398. icon_letter = '[';
  399. break;
  400. case ItemDefinitionIndex::WEAPON_AUG:
  401. icon_letter = 'U';
  402. break;
  403. case ItemDefinitionIndex::WEAPON_AWP:
  404. icon_letter = 'Z';
  405. break;
  406. case ItemDefinitionIndex::WEAPON_REVOLVER:
  407. icon_letter = 'J';
  408. break;
  409. case ItemDefinitionIndex::WEAPON_G3SG1:
  410. icon_letter = 'X';
  411. break;
  412. case ItemDefinitionIndex::WEAPON_MAC10:
  413. icon_letter = 'K';
  414. break;
  415. case ItemDefinitionIndex::WEAPON_P90:
  416. icon_letter = 'P';
  417. break;
  418. case ItemDefinitionIndex::WEAPON_SSG08:
  419. icon_letter = 'a';
  420. break;
  421. case ItemDefinitionIndex::WEAPON_SCAR20:
  422. icon_letter = 'Y';
  423. break;
  424. case ItemDefinitionIndex::WEAPON_UMP45:
  425. icon_letter = 'L';
  426. break;
  427. case ItemDefinitionIndex::WEAPON_ELITE:
  428. icon_letter = 'B';
  429. break;
  430. case ItemDefinitionIndex::WEAPON_FAMAS:
  431. icon_letter = 'R';
  432. break;
  433. case ItemDefinitionIndex::WEAPON_FIVESEVEN:
  434. icon_letter = 'C';
  435. break;
  436. case ItemDefinitionIndex::WEAPON_GALILAR:
  437. icon_letter = 'Q';
  438. break;
  439. case ItemDefinitionIndex::WEAPON_M4A1:
  440. icon_letter = 'S';
  441. break;
  442. case ItemDefinitionIndex::WEAPON_P250:
  443. icon_letter = 'F';
  444. break;
  445. case ItemDefinitionIndex::WEAPON_M249:
  446. icon_letter = 'g';
  447. break;
  448. case ItemDefinitionIndex::WEAPON_XM1014:
  449. icon_letter = 'b';
  450. break;
  451. case ItemDefinitionIndex::WEAPON_C4:
  452. icon_letter = 'o';
  453. break;
  454. case ItemDefinitionIndex::WEAPON_GLOCK:
  455. icon_letter = 'D';
  456. break;
  457. case ItemDefinitionIndex::WEAPON_HKP2000:
  458. icon_letter = 'G';
  459. case ItemDefinitionIndex::WEAPON_TASER:
  460. icon_letter = 'h';
  461. case ItemDefinitionIndex::WEAPON_AK47:
  462. icon_letter = 'W';
  463. break;
  464. default:
  465. return false;
  466. }
  467.  
  468. char buffer[2] = { icon_letter, '\0' };
  469.  
  470. auto weapon_data = Weapon->GetCSWpnData();
  471.  
  472. g_pSurface->DrawT(xposition, yposition + 10 + add, ESP, g::WeaponIcons, true, buffer);
  473. std::string WeaponName = weapon_data->hud_name;
  474. WeaponName.erase(0, 13);
  475. std::transform(WeaponName.begin(), WeaponName.end(), WeaponName.begin(), ::toupper);
  476. g_pSurface->DrawT(xposition, yposition + add, ESP, g::EspTahoma, true, WeaponName.c_str());
  477.  
  478. return true;
  479. };
  480.  
  481.  
  482. if (!DrawWeaponIcon())
  483. {
  484. std::string WeaponName = weapon_data->hud_name;
  485. WeaponName.erase(0, 13);
  486. std::transform(WeaponName.begin(), WeaponName.end(), WeaponName.begin(), ::toupper);
  487. g_pSurface->DrawT(xposition, yposition + add, ESP, g::EspTahoma, true, WeaponName.c_str());
  488. }
  489.  
  490. }
  491. }
  492.  
  493. void c_visuals::Ammo(C_BaseEntity* Entity) {
  494. Vector min, max;
  495. Entity->GetRenderBounds(min, max);
  496. Vector pos, pos3D, top, top3D;
  497. pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
  498. top3D = pos3D + Vector(0, 0, max.z + 11);
  499. //spectators();
  500.  
  501. Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(81, 140, 201, flPlayerAlpha[Entity->EntIndex()]);
  502. Color ESP2 = Entity->IsDormant() ? Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
  503.  
  504. auto Weapon = Entity->GetActiveWeapon();
  505. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top) && Weapon)
  506. {
  507. int height = (pos.y - top.y);;
  508. int y = top.y;
  509. int width2 = height / 2;
  510. int x = pos.x - (width2 / 2);
  511.  
  512. float offset = (height / 4.f) + 5;
  513. UINT hp = height - (UINT)((height * 3) / 100);
  514.  
  515. auto animLayer = Entity->GetAnimOverlay4(1);
  516.  
  517. if (!animLayer)
  518. return;
  519.  
  520. auto activity = Entity->GetSequenceActivity(animLayer->m_nSequence);
  521.  
  522. if (!activity)
  523. return;
  524.  
  525. int iClip = Weapon->GetAmmo();
  526. int iClipMax = Weapon->GetCSWpnData()->max_clip;
  527.  
  528. if (!animLayer || !activity) {
  529. DisplayAmmo[Entity->EntIndex()] = false;
  530. return;
  531. }
  532.  
  533.  
  534. float box_w = (float)fabs(height / 2);
  535. float width;
  536.  
  537. DisplayAmmo[Entity->EntIndex()] = iClip > 0 || (activity == 967 && animLayer->m_flWeight != 0.f);
  538.  
  539. if (activity == 967 && animLayer->m_flWeight != 0.f)
  540. {
  541. float cycle = animLayer->m_flCycle;
  542. width = (((box_w * cycle) / 1.f));
  543. }
  544. else
  545. width = (((box_w * iClip) / iClipMax));
  546.  
  547. if (!DisplayAmmo[Entity->EntIndex()])
  548. return;
  549.  
  550. g_pSurface->FilledRect(x, y + height + 2, box_w, 4, ESP2);
  551. g_pSurface->FilledRect(x, y + height + 2, width, 4, Color(ESP));
  552. g_pSurface->OutlinedRect(x, y + height + 2, box_w, 4, ESP2);
  553. }
  554. }
  555.  
  556. void c_visuals::HealthESP(C_BaseEntity* Entity) {
  557. Vector min, max;
  558. Entity->GetRenderBounds(min, max);
  559. Vector pos, pos3D, top, top3D;
  560. pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
  561. top3D = pos3D + Vector(0, 0, max.z + 11);
  562.  
  563. Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 255, 0, flPlayerAlpha[Entity->EntIndex()]);
  564. Color ESP2 = Entity->IsDormant() ? Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
  565.  
  566.  
  567. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
  568. {
  569. int height = (pos.y - top.y);
  570. int width = height / 2;
  571. int x = pos.x - (width / 2);
  572. int y = top.y;
  573. auto health = Entity->GetHealth();
  574. int Style = g_Menu.Config.Health;
  575.  
  576. if (Style)/*Whats a switch statement?*/
  577. {
  578. int pixel_value = Entity->GetHealth() * height / 100;
  579.  
  580. g_pSurface->FilledRect(x - 6, y - 1, 4, height + 2, ESP2);
  581. g_pSurface->FilledRect(x - 5, y + height - pixel_value, 2, pixel_value, ESP);
  582.  
  583. g_pSurface->DrawT(x - 8, y + height - pixel_value, Color(255, 255, 255), g::EspTahoma, true, "%d", Entity->GetHealth());
  584. }
  585.  
  586.  
  587. }
  588. }
  589. inline void CrossProduct2(const Vector& a, const Vector& b, Vector& result)
  590.  
  591. {
  592.  
  593. CHECK_VALID(a);
  594.  
  595. CHECK_VALID(b);
  596.  
  597. Assert(&a != &result);
  598.  
  599. Assert(&b != &result);
  600.  
  601. result.x = a.y * b.z - a.z * b.y;
  602.  
  603. result.y = a.z * b.x - a.x * b.z;
  604.  
  605. result.z = a.x * b.y - a.y * b.x;
  606.  
  607. }
  608.  
  609. void CalcAngle2(Vector src, Vector dst, Vector& angles)
  610. {
  611. Vector delta = src - dst;
  612. double hyp = delta.Length2D(); //delta.Length
  613. angles.y = (atan(delta.y / delta.x) * 57.295779513082f);
  614. angles.x = (atan(delta.z / hyp) * 57.295779513082f);
  615. angles[2] = 0.00;
  616.  
  617. if (delta.x >= 0.0)
  618. angles.y += 180.0f;
  619. }
  620.  
  621.  
  622.  
  623. #include "../../SDK/vector2d.h"
  624. #include <windows.h>
  625. #include <iostream>
  626. #include <cstdint>
  627. #include <memory>
  628. #include <vector>
  629. #include <thread>
  630. #include <chrono>
  631. #include <array>
  632. #include <fstream>
  633. #include <istream>
  634. #include <unordered_map>
  635. #include <intrin.h>
  636. void rotate(std::array< vec2_t, 3 > & points, float rotation)
  637. {
  638. const auto points_center = (points.at(0) + points.at(1) + points.at(2)) / 3;
  639. for (auto& point : points) {
  640. point -= points_center;
  641.  
  642. const auto temp_x = point.x;
  643. const auto temp_y = point.y;
  644.  
  645. const auto theta = DEG2RAD(rotation);
  646. const auto c = cos(theta);
  647. const auto s = sin(theta);
  648.  
  649. point.x = temp_x * c - temp_y * s;
  650. point.y = temp_x * s + temp_y * c;
  651.  
  652. point += points_center;
  653. }
  654. }
  655. float meme = 0.f;
  656. int arrow_alpha[65];
  657. template <typename t> t clamp_value(t value, t min, t max) {
  658. if (value > max) {
  659. return max;
  660. }
  661. if (value < min) {
  662. return min;
  663. }
  664. return value;
  665. }
  666.  
  667. void arrows(C_BaseEntity* player) {
  668. auto local = g::pLocalEntity;
  669.  
  670. // another case of unnecessary float divison. gotta watch out for that guys! ~chance
  671. // const int fade = ( int )( ( ( 1 / 0.25f ) * interfaces::globals->frame_time ) * 255 );
  672. const int fade = (int)((4 * g_pGlobalVars->frametime) * 255);
  673.  
  674.  
  675.  
  676. // if (!elements::get().vis_arrows)
  677. // return;
  678.  
  679. if (!local)
  680. return;
  681.  
  682. if (!local->IsAlive())
  683. return;
  684.  
  685. if (!player)
  686. return;
  687.  
  688. if (player->IsDormant())
  689. return;
  690.  
  691. arrow_alpha[player->EntIndex()] = 255;
  692. Vector position;
  693. if (WorldToScreen(GetHitboxPosition(player, 2), position))
  694. return;
  695.  
  696. Vector viewangles;
  697. int width, height;
  698.  
  699. g_pEngine->GetViewAngles(viewangles);
  700. g_pEngine->GetScreenSize(width, height);
  701.  
  702. // more float division, i'm just gonna stop putting comments next to it at this point xD. ~chance
  703. // const auto screen_center = vec2_t( width / 2.f, height / 2.f );
  704. const auto screen_center = vec2_t(width * .5f, height * .5f);
  705.  
  706. const auto angle_yaw_rad = DEG2RAD(viewangles.y - g_Math.CalcAngle(local->GetEyePosition(), GetHitboxPosition(player, 2)).y - 90);
  707.  
  708. int radius = 20;
  709. int size = 10;
  710.  
  711. const auto new_point_x = screen_center.x + ((((width - (size * 3)) * .5f) * (radius / 100.0f)) * cos(angle_yaw_rad)) + (int)(6.0f * (((float)size - 4.f) / 16.0f));
  712. const auto new_point_y = screen_center.y + ((((height - (size * 3)) * .5f) * (radius / 100.0f)) * sin(angle_yaw_rad));
  713.  
  714. Color ESP = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()]) : Color(g_Menu.Config.FovColor.red, g_Menu.Config.FovColor.green, g_Menu.Config.FovColor.blue, flPlayerAlpha[player->EntIndex()]);
  715.  
  716. Color clr = ESP;
  717.  
  718. std::array< vec2_t, 3 >points{ vec2_t(new_point_x - size, new_point_y - size),
  719. vec2_t(new_point_x + size, new_point_y),
  720. vec2_t(new_point_x - size, new_point_y + size) };
  721.  
  722. rotate(points, viewangles.y - g_Math.CalcAngle(local->GetEyePosition(), GetHitboxPosition(player, 2)).y - 90);
  723. g_pSurface->draw_filled_triangle(points, clr);
  724. }
  725. #include "..\..\SDK\ICvar.h"
  726. enum cvar_flags {
  727. fcvar_none = 0,
  728. fcvar_unregistered = (1 << 0),
  729. fcvar_developmentonly = (1 << 1),
  730. fcvar_gamedll = (1 << 2),
  731. fcvar_clientdll = (1 << 3),
  732. fcvar_hidden = (1 << 4),
  733. fcvar_protected = (1 << 5),
  734. fcvar_sponly = (1 << 6),
  735. fcvar_archive = (1 << 7),
  736. fcvar_notify = (1 << 8),
  737. fcvar_userinfo = (1 << 9),
  738. fcvar_printableonly = (1 << 10),
  739. fcvar_unlogged = (1 << 11),
  740. fcvar_never_as_string = (1 << 12),
  741. fcvar_replicated = (1 << 13),
  742. fcvar_cheat = (1 << 14),
  743. fcvar_ss = (1 << 15),
  744. fcvar_demo = (1 << 16),
  745. fcvar_dontrecord = (1 << 17),
  746. fcvar_ss_added = (1 << 18),
  747. fcvar_release = (1 << 19),
  748. fcvar_reload_materials = (1 << 20),
  749. fcvar_reload_textures = (1 << 21),
  750. fcvar_not_connected = (1 << 22),
  751. fcvar_material_system_thread = (1 << 23),
  752. fcvar_archive_xbox = (1 << 24),
  753. fcvar_accessible_from_threads = (1 << 25),
  754. fcvar_server_can_execute = (1 << 28),
  755. fcvar_server_cannot_query = (1 << 29),
  756. fcvar_clientcmd_can_execute = (1 << 30),
  757. fcvar_meme_dll = (1 << 31),
  758. fcvar_material_thread_mask = (fcvar_reload_materials | fcvar_reload_textures | fcvar_material_system_thread)
  759. };
  760.  
  761.  
  762. void c_visuals::force_crosshair()
  763. {
  764. auto local_player = g::pLocalEntity;
  765.  
  766. static ConVar* weapon_debug_spread_show = g_pCvar->FindVar("weapon_debug_spread_show");
  767.  
  768. weapon_debug_spread_show->nFlags &= ~fcvar_cheat;
  769.  
  770. if (local_player && local_player->GetHealth() > 0)
  771. {
  772. // weapon_debug_spread_show->SetValue(local_player->IsScoped() || !g_Menu.Config.force_crosshair ? 0 : 3);
  773. }
  774. }
  775.  
  776. void c_visuals::flags(C_BaseEntity* player) {
  777.  
  778. Vector min, max;
  779. player->GetRenderBounds(min, max);
  780. Vector pos, pos3D, top, top3D;
  781. pos3D = player->GetAbsOrigin() - Vector(0, 0, 10);
  782. top3D = pos3D + Vector(0, 0, max.z + 11);
  783. Color ESP = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 255, 255, flPlayerAlpha[player->EntIndex()] / 1.3);
  784.  
  785. Color Money = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(115, 180, 25, flPlayerAlpha[player->EntIndex()] / 1.3);
  786.  
  787. Color Zoom = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(53, 166, 208, flPlayerAlpha[player->EntIndex()] / 1.3);
  788.  
  789. Color FakeDuck = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 0, 0, flPlayerAlpha[player->EntIndex()] / 1.3);
  790.  
  791. Color baim = player->IsDormant() ? Color(255, 0, 237, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 0, 0, flPlayerAlpha[player->EntIndex()] / 1.3);
  792.  
  793. Color missed2 = player->IsDormant() ? Color(255, 0, 237, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 0, 0, flPlayerAlpha[player->EntIndex()] / 1.3);
  794.  
  795. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
  796. {
  797. int height = (pos.y - top.y);
  798. int width = height / 2;
  799. int x = pos.x - (width / 2);
  800. int y = top.y;
  801.  
  802.  
  803.  
  804. if (g_Menu.Config.YawPitch)
  805. {
  806. std::vector<std::pair<std::string, Color>> flags;
  807.  
  808.  
  809. flags.push_back(std::pair<std::string, Color>("HK", ESP));
  810.  
  811.  
  812. flags.push_back(std::pair<std::string, Color>(std::string("ZOOM"), Zoom));
  813.  
  814.  
  815.  
  816. int pos = 0;
  817. for (auto text : flags) {
  818. g_pSurface->DrawT(x + width + 5, y + pos, text.second, g::EspTahoma, false, text.first.c_str());
  819. pos += 10;
  820. }
  821. }
  822. }
  823. }
  824. RECT GetViewport()
  825. {
  826. RECT Viewport = { 0, 0, 0, 0 };
  827. int w, h;
  828. g_pEngine->GetScreenSize(w, h);
  829. Viewport.right = w; Viewport.bottom = h;
  830. return Viewport;
  831. }
  832.  
  833. void DrawWeapon(C_BaseEntity* player) {
  834. Vector min, max;
  835. player->GetRenderBounds(min, max);
  836. Vector pos, pos3D, top, top3D;
  837. pos3D = player->GetAbsOrigin() - Vector(0, 0, 10);
  838. top3D = pos3D + Vector(0, 0, max.z + 11);
  839.  
  840. if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
  841. {
  842. int height = (pos.y - top.y);
  843. int y = top.y;
  844. int width = height / 2;
  845. int x = pos.x - ((width / 2) / 2);
  846. int x2 = pos.x - (width / 2);
  847. int h = height;
  848. int w = width / 2;
  849.  
  850. g_pSurface->OutlinedRect(x2, y, width, height, Color(255, 255, 255));
  851. g_pSurface->OutlinedRect(x2 - 1, y - 1, width + 2, height + 2, Color(0, 0, 0));
  852. g_pSurface->OutlinedRect(x2 + 1, y + 1, width - 2, height - 2, Color(0, 0, 0));
  853. }
  854. }
  855.  
  856. void c_visuals::DrawPlayers() {
  857.  
  858. force_crosshair();
  859. int spectator_count = 0;
  860.  
  861. for (int Index = 1; Index < g_pGlobalVars->maxClients; Index++)
  862. {
  863. auto Entity = g_pEntityList->GetClientEntity(Index);
  864. auto LocalPlayer = g::pLocalEntity;
  865.  
  866.  
  867. if (!Entity || !LocalPlayer || !Entity->IsAlive())
  868. continue;
  869.  
  870.  
  871. ClientClass* cClass = (ClientClass*)Entity->GetClientClass();
  872. if (cClass->ClassID != (int)EClassIds::CBaseWeaponWorldModel && ((strstr(cClass->pNetworkName, "Weapon") || cClass->ClassID == (int)EClassIds::CDEagle || cClass->ClassID == (int)EClassIds::CAK47))) {
  873. DrawWeapon(Entity);
  874. }
  875.  
  876. ConVar* mp_radar_showall = g_pCvar->FindVar("mp_radar_showall");
  877. *(int*)((DWORD)& mp_radar_showall->fnChangeCallback + 0xC) = 0; // ew
  878. mp_radar_showall->SetValue(1);
  879.  
  880. if (g_Menu.Config.KillCounter)
  881. QuakeKillCounter();
  882.  
  883.  
  884. bool IsTeammate = Entity->GetTeam() == LocalPlayer->GetTeam();
  885. bool IsEnemy = Entity->GetTeam() != LocalPlayer->GetTeam();
  886. bool IsLocal = Entity == LocalPlayer;
  887.  
  888. if (!Entity->IsDormant()) {
  889. StoredCurtimePlayer[Entity->EntIndex()] = g_pGlobalVars->curtime;
  890. }
  891.  
  892. if (Entity->IsDormant() && flPlayerAlpha[Entity->EntIndex()] > 0 && g_pGlobalVars->curtime - StoredCurtimePlayer[Entity->EntIndex()] > 2)
  893. {
  894. flPlayerAlpha[Entity->EntIndex()] -= 5;
  895. }
  896. else if (flPlayerAlpha[Entity->EntIndex()] < 255 && !(Entity->IsDormant()))
  897. {
  898. flPlayerAlpha[Entity->EntIndex()] += 5;
  899. }
  900.  
  901. //spectators();
  902. if (IsEnemy)
  903. {
  904.  
  905.  
  906. if (g_Menu.Config.Name) NameESP(Entity);
  907. if (g_Menu.Config.Box) BoxESP(Entity);
  908. if (g_Menu.Config.Weapon) WeaponESP(Entity);
  909. if (g_Menu.Config.ammo) Ammo(Entity);
  910. if (g_Menu.Config.Health) HealthESP(Entity);
  911. if (g_Menu.Config.FovEnable) arrows(Entity);
  912. flags(Entity);
  913. }
  914. }
  915. }
  916.  
  917.  
  918.  
  919. template<class T>
  920. constexpr const T& clampv2(const T& v, const T& lo, const T& hi)
  921. {
  922. return clampv2(v, lo, hi, std::less<>());
  923. }
  924.  
  925. template<class T, class Compare>
  926. constexpr const T& clampv2(const T& v, const T& lo, const T& hi, Compare comp)
  927. {
  928. return assert(!comp(hi, lo)),
  929. comp(v, lo) ? lo : comp(hi, v) ? hi : v;
  930. }
  931.  
  932. void c_visuals::draw_scope() {
  933.  
  934. if (!g_Menu.Config.NoScope)
  935. return;
  936.  
  937. if (!g_pEngine->IsConnected() || !g_pEngine->IsInGame())
  938. return;
  939.  
  940. auto local_player = g::pLocalEntity;
  941.  
  942. if (!local_player)
  943. return;
  944.  
  945. if (!local_player->IsAlive())
  946. return;
  947.  
  948. int width_2, height_2;
  949.  
  950. g_pEngine->GetScreenSize(width_2, height_2);
  951.  
  952. if (local_player->IsScoped()) {
  953. auto weapon = local_player->GetActiveWeapon();
  954.  
  955. if (!weapon)
  956. return;
  957.  
  958. float spread = weapon->GetInaccuracy() * 100;
  959. int height = clampv2(spread, 1.f, 30.f);
  960. int alpha = 255 - (height * 4.2f);
  961.  
  962. bool Dynamic = g_Menu.Config.NoScope;
  963.  
  964. if (Dynamic) {
  965. g_pSurface->FilledRect(0, height_2 / 2 - (height / 2), width_2, height, Color(0, 0, 0, alpha));
  966. g_pSurface->FilledRect(width_2 / 2 - (height / 2), 0, height, height_2, Color(0, 0, 0, alpha));
  967. }
  968. else {
  969. g_pSurface->Line(0, height_2 / 2, width_2, height_2 / 2, Color(0, 0, 0, 255));
  970. g_pSurface->Line(width_2 / 2, 0, width_2 / 2, height_2, Color(0, 0, 0, 255));
  971. }
  972.  
  973. }
  974. }
  975. int RadarX = 110;
  976. int RadarY = 110;
  977. int RadarSize = 100;
  978. void c_visuals::DrawRadarPoint(Vector vOriginX, Vector vOriginY, QAngle qAngle, C_BaseEntity* pBaseEntity, Color col)
  979. {
  980. auto pLocalEntity = g::pLocalEntity;
  981. if (pLocalEntity == NULL)
  982. return;
  983.  
  984. float flDeltaX = vOriginX.x - vOriginY.x;
  985. float flDeltaY = vOriginX.y - vOriginY.y;
  986.  
  987. float flAngle = qAngle.y;
  988.  
  989. float flYaw = (flAngle) * (3.14159265358979323846 / 180.0);
  990. float flMainViewAngles_CosYaw = cos(flYaw);
  991. float flMainViewAngles_SinYaw = sin(flYaw);
  992.  
  993. // rotate
  994. float x = flDeltaY * (-flMainViewAngles_CosYaw) + flDeltaX * flMainViewAngles_SinYaw;
  995. float y = flDeltaX * (-flMainViewAngles_CosYaw) - flDeltaY * flMainViewAngles_SinYaw;
  996.  
  997. float flRange = 2000;
  998.  
  999. if (fabs(x) > flRange || fabs(y) > flRange)
  1000. {
  1001. // clipping
  1002. if (y > x)
  1003. {
  1004. if (y > -x)
  1005. {
  1006. x = flRange * x / y;
  1007. y = flRange;
  1008. }
  1009. else
  1010. {
  1011. y = -flRange * y / x;
  1012. x = -flRange;
  1013. }
  1014. }
  1015. else
  1016. {
  1017. if (y > -x)
  1018. {
  1019. y = flRange * y / x;
  1020. x = flRange;
  1021. }
  1022. else
  1023. {
  1024. x = -flRange * x / y;
  1025. y = -flRange;
  1026. }
  1027. }
  1028. }
  1029.  
  1030. int iScreenX = RadarX + int(x / flRange * RadarSize);
  1031. int iScreenY = RadarY + int(y / flRange * RadarSize);
  1032.  
  1033. g_pSurface->FilledRect(iScreenX - 3, iScreenY - 3, 7, 7, Color(0, 0, 0, 255));
  1034.  
  1035.  
  1036.  
  1037. g_pSurface->FilledRect(iScreenX - 2, iScreenY - 2, 5, 5, Color(255, 255, 255));
  1038.  
  1039. }
  1040. #define M_PI 3.14159265358979323846f
  1041. Vector RotatePoint(Vector p, Vector c, float ang)
  1042. {
  1043. float angleInRadians = ang * (M_PI / 180.f);
  1044. float cosTheta = cos(angleInRadians);
  1045. float sinTheta = sin(angleInRadians);
  1046. return Vector(
  1047. (cosTheta * (p.x - c.x) -
  1048. sinTheta * (p.y - c.y) + c.x),
  1049. (sinTheta * (p.x - c.x) +
  1050. cosTheta * (p.y - c.y) + c.y),
  1051. 0);
  1052. }
  1053. void GradientV2(int x, int y, int w, int h, Color c1, Color c2)
  1054. {
  1055.  
  1056. g_pSurface->FilledRect(x, y, w, h, c1);
  1057. BYTE first = c2.red;
  1058. BYTE second = c2.green;
  1059. BYTE third = c2.blue;
  1060. for (int i = 0; i < h; i++)
  1061. {
  1062. float fi = i, fh = h;
  1063. float a = fi / fh;
  1064. DWORD ia = a * 255;
  1065. g_pSurface->FilledRect(x, y + i, w, 1, Color(first, second, third, ia));
  1066. }
  1067. }
  1068. //===================================================================================
  1069. int RadarSizeFinal = 150;
  1070. void GradientH2(int x, int y, int w, int h, Color c1, Color c2)
  1071. {
  1072.  
  1073. g_pSurface->FilledRect(x, y, w, h, c1);
  1074. BYTE first = c2.red;
  1075. BYTE second = c2.green;
  1076. BYTE third = c2.blue;
  1077. for (int i = 0; i < w; i++)
  1078. {
  1079. float fi = i, fw = w;
  1080. float a = fi / fw;
  1081. DWORD ia = a * 255;
  1082. g_pSurface->FilledRect(x + i, y, 1, h, Color(first, second, third, ia));
  1083. }
  1084.  
  1085. }
  1086. #include "../../Menu/Menu.h"
  1087. static Vector TL(110, 110, 0);
  1088.  
  1089.  
  1090. float CSGO_Armor(float flDamage, int ArmorValue)
  1091. {
  1092. float flArmorRatio = 0.5f;
  1093. float flArmorBonus = 0.5f;
  1094. if (ArmorValue > 0) {
  1095. float flNew = flDamage * flArmorRatio;
  1096. float flArmor = (flDamage - flNew) * flArmorBonus;
  1097.  
  1098. if (flArmor > static_cast<float>(ArmorValue)) {
  1099. flArmor = static_cast<float>(ArmorValue) * (1.f / flArmorBonus);
  1100. flNew = flDamage - flArmor;
  1101. }
  1102.  
  1103. flDamage = flNew;
  1104. }
  1105. return flDamage;
  1106. }
  1107.  
  1108.  
  1109. static std::string damagestring;
  1110. static bool lethal;
  1111. static int bombR = 0, bombG = 0;
  1112. static int lethaly;
  1113.  
  1114.  
  1115.  
  1116. const wchar_t* to_wchar(const char* string) {
  1117. va_list va_alist;
  1118. char buf[1024];
  1119. va_start(va_alist, string);
  1120. _vsnprintf_s(buf, sizeof(buf), string, va_alist);
  1121. va_end(va_alist);
  1122. wchar_t wbuf[1024];
  1123. MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);
  1124.  
  1125. return wbuf;
  1126. }
  1127.  
  1128.  
  1129.  
  1130.  
  1131. /*void c_visuals::SpecList() {
  1132. if (!g_Menu.Config.visual_spectator_list)
  1133. return;
  1134.  
  1135. if (g_pEngine->IsConnected() || g_pEngine->IsInGame()) {
  1136. int index = 0;
  1137. int w, h;
  1138. g_pEngine->GetScreenSize(w, h);
  1139. g_pSurface->OutlinedRect(931 + g_Menu.Config.specx, 141 + g_Menu.Config.specy, 200, 100, Color(0, 0, 0, 155));
  1140. g_pSurface->FilledRect(931, 141, 200, 100, Color(0, 0, 0, 65));
  1141. g_pSurface->FilledRect(937, 147, 188, 88, Color(0, 0, 0, 100));
  1142. g_pSurface->FilledRect(941, 172, 180, 57, Color(12, 12, 12, 255));
  1143. g_pSurface->OutlinedRect(941, 172 + g_Menu.Config.specy, 180, 57, Color(43, 43, 43, 155));
  1144. g_pSurface->FilledRect(941, 161, 180, 2, Color(g_Menu.Config.menu_color_r, g_Menu.Config.menu_color_g,
  1145. g_Menu.Config.menu_color_b, 255));
  1146. g_pSurface->FilledRect(941, 161, 180, 2, Color(g_Menu.Config.menu_color_r, g_Menu.Config.menu_color_g,
  1147. g_Menu.Config.menu_color_b, 255));
  1148. g_pSurface->DrawT(999, 148, Color(255, 255, 255, 255), g::SmallText, true, "Spectators");
  1149.  
  1150.  
  1151. for (int i = 1; i < 65; i++) {
  1152. auto p_local = g_pEntityList->GetClientEntity(g_pEngine->GetLocalPlayer()); // what's csgo::local_player???????
  1153. auto p_entity = g_pEntityList->GetClientEntity(i);
  1154. PlayerInfo_t e_info;
  1155.  
  1156. if (p_entity && p_entity != p_local) {
  1157. g_pEngine->GetPlayerInfo(i, &e_info);
  1158.  
  1159. if (!p_entity->IsAlive() && p_entity->IsDormant()) {
  1160. auto target = p_entity->observer_target();
  1161.  
  1162. if (target) {
  1163.  
  1164. auto p_target = g_pEntityList->GetClientEntityFromHandle(target);
  1165.  
  1166. if (p_target == p_local) {
  1167. int x, y;
  1168. g_pEngine->GetScreenSize(x, y);
  1169. g_pSurface->GetTextSize(g::SmallText, to_wchar(e_info.szName), x, y);
  1170. std::string player_name = e_info.szName;
  1171. PlayerInfo_t p_info;
  1172. g_pEngine->GetPlayerInfo(i, &e_info);
  1173. g_pSurface->DrawT(946 + g_Menu.Config.specx, 174 + g_Menu.Config.specy + (10 * index), Color(255, 255, 255, 255), g::SmallText, false, player_name.c_str());
  1174.  
  1175. index++;
  1176. }
  1177. }
  1178. }
  1179. }
  1180. }
  1181. }
  1182.  
  1183. }
  1184. */
  1185.  
  1186. /*void c_visuals::SpecList()
  1187. {
  1188. int specs = 0;
  1189. int modes = 0;
  1190. std::string spect = "";
  1191. std::string mode = "";
  1192.  
  1193. int screenx;
  1194. int screeny;
  1195. g_pEngine->GetScreenSize(screenx, screeny);
  1196.  
  1197. int centerx = screenx / 2;
  1198. int centery = screeny / 2;
  1199.  
  1200. if (g_pEngine->IsInGame() && g_pEngine->IsConnected())
  1201. {
  1202. int localIndex = g_pEngine->GetLocalPlayer();
  1203. if (g::pLocalEntity)
  1204. {
  1205. for (int i = 0; i < g_pEngine->GetMaxClients(); i++)
  1206. {
  1207. C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  1208. if (!pPlayerEntity)
  1209. continue;
  1210. if (pPlayerEntity->GetHealth() > 0)
  1211. continue;
  1212.  
  1213.  
  1214. auto target = pPlayerEntity->observer_target();
  1215.  
  1216.  
  1217. auto p_target = g_pEntityList->GetClientEntityFromHandle(target);
  1218.  
  1219. if (pPlayerEntity == g::pLocalEntity)
  1220. continue;
  1221. if (pPlayerEntity->IsDormant())
  1222. continue;
  1223. if (p_target != g::pLocalEntity)
  1224. continue;
  1225.  
  1226. PlayerInfo_t pInfo;
  1227. g_pEngine->GetPlayerInfo(pPlayerEntity->EntIndex(), &pInfo);
  1228. if (pInfo.ishltv)
  1229. continue;
  1230.  
  1231. spect += pInfo.szName;
  1232. spect += "\n";
  1233. specs++;
  1234. g_pSurface->DrawT(centerx, centery, Color(255, 255, 255, 255), g::SmallText, true, spect.c_str());
  1235. }
  1236. }
  1237. }
  1238. }
  1239.  
  1240. */
  1241.  
  1242.  
  1243.  
  1244. auto spectator_count = 0;
  1245. bool WorldToScreenAlpha(const Vector& origin, Vector2D& screen)
  1246. {
  1247. const auto screenTransform = [&origin, &screen]() -> bool
  1248. {
  1249. static std::uintptr_t pViewMatrix;
  1250. if (!pViewMatrix)
  1251. {
  1252. pViewMatrix = static_cast<std::uintptr_t>(Utils::FindSignature("client_panorama.dll", "0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9"));
  1253. pViewMatrix += 3;
  1254. pViewMatrix = *reinterpret_cast<std::uintptr_t*>(pViewMatrix);
  1255. pViewMatrix += 176;
  1256. }
  1257.  
  1258. const VMatrix& w2sMatrix = *reinterpret_cast<VMatrix*>(pViewMatrix);
  1259. screen.x = w2sMatrix.m[0][0] * origin.x + w2sMatrix.m[0][1] * origin.y + w2sMatrix.m[0][2] * origin.z + w2sMatrix.m[0][3];
  1260. screen.y = w2sMatrix.m[1][0] * origin.x + w2sMatrix.m[1][1] * origin.y + w2sMatrix.m[1][2] * origin.z + w2sMatrix.m[1][3];
  1261.  
  1262. float w = w2sMatrix.m[3][0] * origin.x + w2sMatrix.m[3][1] * origin.y + w2sMatrix.m[3][2] * origin.z + w2sMatrix.m[3][3];
  1263.  
  1264. if (w < 0.001f)
  1265. {
  1266. screen.x *= 100000;
  1267. screen.y *= 100000;
  1268. return true;
  1269. }
  1270.  
  1271. float invw = 1.f / w;
  1272. screen.x *= invw;
  1273. screen.y *= invw;
  1274.  
  1275. return false;
  1276. };
  1277.  
  1278. if (!screenTransform())
  1279. {
  1280. int iScreenWidth, iScreenHeight;
  1281. g_pEngine->GetScreenSize(iScreenWidth, iScreenHeight);
  1282.  
  1283. screen.x = (iScreenWidth * 0.5f) + (screen.x * iScreenWidth) * 0.5f;
  1284. screen.y = (iScreenHeight * 0.5f) - (screen.y * iScreenHeight) * 0.5f;
  1285.  
  1286. return true;
  1287. }
  1288. return false;
  1289. }
  1290. struct
  1291. {
  1292. //int left, right, top, bottom;
  1293. int x, y, w, h;
  1294. } Box;
  1295. bool boundingBox(C_BaseEntity* pEntity, Vector offset = Vector(0, 0, 0))
  1296. {
  1297. Vector min, max;
  1298. pEntity->GetRenderBounds(min, max);
  1299.  
  1300. Vector pos3D, top3D;
  1301. Vector2D pos, top;
  1302. pos3D = pEntity->GetAbsOrigin() - Vector(0, 0, 10);
  1303. top3D = pos3D + Vector(0, 0, max.z + 15);
  1304.  
  1305. if (WorldToScreenAlpha(pos3D, pos) && WorldToScreenAlpha(top3D, top))
  1306. {
  1307. int height = (pos.y - top.y);
  1308. Box.h = height; //h
  1309. int width = Box.h / 2;
  1310. Box.w = width; //w
  1311.  
  1312. Box.x = pos.x - width / 2; //x
  1313. Box.y = top.y; //y
  1314.  
  1315. return true;
  1316. }
  1317.  
  1318. return false;
  1319. }
  1320.  
  1321. enum FontRenderFlag_t
  1322. {
  1323. FONT_LEFT = 0,
  1324. FONT_RIGHT = 1,
  1325. FONT_CENTER = 2
  1326. };
  1327.  
  1328. void c_visuals::DrawString(unsigned long font, int x, int y, Color color, unsigned long alignment, const char* msg)
  1329. {
  1330. va_list va_alist;
  1331. char buf[1024];
  1332. va_start(va_alist, msg);
  1333. _vsnprintf_s(buf, sizeof(buf), msg, va_alist);
  1334. va_end(va_alist);
  1335. wchar_t wbuf[1024];
  1336. MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);
  1337.  
  1338. int r = 255, g = 255, b = 255, a = 255;
  1339. // color.GetColor(r, g, b, a);
  1340.  
  1341. int width, height;
  1342. g_pSurface->GetTextSize(font, wbuf, width, height);
  1343.  
  1344. if (alignment & FONT_RIGHT)
  1345. x -= width;
  1346. if (alignment & FONT_CENTER)
  1347. x -= width / 2;
  1348.  
  1349. g_pSurface->DrawSetTextFont(font);
  1350. g_pSurface->DrawSetTextColor(r, g, b, a);
  1351. g_pSurface->DrawSetTextPos(x, y - height / 2);
  1352. g_pSurface->DrawPrintText(wbuf, wcslen(wbuf));
  1353. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement