Advertisement
Guest User

Untitled

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