Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.58 KB | None | 0 0
  1.  
  2. CESP* g_ESP = new CESP;
  3.  
  4. #define TICK_INTERVAL ( g_pGlobals->interval_per_tick )
  5. #define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
  6. #define TICKS_TO_TIME( t ) ( TICK_INTERVAL *( t ) )
  7.  
  8. char* GetWeaponName(CBaseCombatWeapon *pWeapon)
  9. {
  10. int ID = pWeapon->WeaponID();
  11.  
  12. switch (ID) {
  13. case 4:
  14. return "Glock";
  15. case 2:
  16. return "Berretas";
  17. case 36:
  18. return "P250";
  19. case 30:
  20. return "TEC9";
  21. case 1:
  22. return "Deagle";
  23. case 32:
  24. return "P2000";
  25. case 3:
  26. return "Fiveseven";
  27. case 64:
  28. return "R8";
  29. case 63:
  30. return "CZ75";
  31. case 61:
  32. return "USP";
  33. case 35:
  34. return "Nova";
  35. case 25:
  36. return "XM1014";
  37. case 29:
  38. return "Sawed Off";
  39. case 14:
  40. return "M249";
  41. case 28:
  42. return "Negev";
  43. case 27:
  44. return "MAG7";
  45. case 17:
  46. return "MAC10";
  47. case 33:
  48. return "MP7";
  49. case 24:
  50. return "UMP45";
  51. case 19:
  52. return "P90";
  53. case 26:
  54. return "Bizon";
  55. case 34:
  56. return "MP9";
  57. case 10:
  58. return "Famas";
  59. case 16:
  60. return "M4A4";
  61. case 40:
  62. return "SSG08";
  63. case 8:
  64. return "AUG";
  65. case 9:
  66. return "AWP";
  67. case 38:
  68. return "SCAR20";
  69. case 13:
  70. return "Galil";
  71. case 7:
  72. return "AK7";
  73. case 39:
  74. return "SG553";
  75. case 11:
  76. return "G3SG1";
  77. case 60:
  78. return "M4A1S";
  79. case 46:
  80. case 48:
  81. return "Molotov";
  82. case 44:
  83. return "Grenade";
  84. case 43:
  85. return "Flashbang";
  86. case 45:
  87. return "Smoke";
  88. case 47:
  89. return "Decoy";
  90. case 31:
  91. return "Taser";
  92. default:
  93. return "Knife";
  94. }
  95. }
  96.  
  97.  
  98. template<class T, class U>
  99. inline T clamp(T in, U low, U high)
  100. {
  101. if (in <= low)
  102. return low;
  103. else if (in >= high)
  104. return high;
  105. else
  106. return in;
  107. }
  108.  
  109. bool GetCBaseEntityBox(CBaseEntity* pBaseEntity, Vector& BotCenter, Vector& TopCenter, float& Left, float& Right, bool is_player)
  110. {
  111. if (!pBaseEntity)
  112. return false;
  113.  
  114. if (!is_player)
  115. {
  116. const VMatrix& trans = pBaseEntity->GetCollisionBoundTrans();
  117.  
  118. CollisionProperty* collision = pBaseEntity->GetCollision();
  119.  
  120. if (!collision)
  121. return false;
  122.  
  123. Vector min, max;
  124.  
  125. //pBaseEntity->GetRenderable()->GetRenderBounds(min, max);
  126. min = collision->VecMins();
  127. max = collision->VecMaxs();
  128.  
  129. Vector points[] = { Vector(min.x, min.y, min.z),
  130. Vector(min.x, max.y, min.z),
  131. Vector(max.x, max.y, min.z),
  132. Vector(max.x, min.y, min.z),
  133. Vector(max.x, max.y, max.z),
  134. Vector(min.x, max.y, max.z),
  135. Vector(min.x, min.y, max.z),
  136. Vector(max.x, min.y, max.z) };
  137.  
  138. auto vector_transform = [](const Vector in1, const VMatrix& in2)
  139. {
  140. auto dot_product = [](const Vector &v1, const float *v2)
  141. {
  142. float ret = v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
  143. return ret;
  144. };
  145.  
  146. auto out = Vector();
  147. out[0] = dot_product(in1, in2[0]) + in2[0][3];
  148. out[1] = dot_product(in1, in2[1]) + in2[1][3];
  149. out[2] = dot_product(in1, in2[2]) + in2[2][3];
  150. return out;
  151. };
  152.  
  153. Vector pointsTransformed[8];
  154. for (int i = 0; i < 8; i++)
  155. {
  156. pointsTransformed[i] = vector_transform(points[i], trans);
  157. }
  158.  
  159. Vector pos = pBaseEntity->GetAbsOrigin();
  160. Vector flb;
  161. Vector brt;
  162. Vector blb;
  163. Vector frt;
  164. Vector frb;
  165. Vector brb;
  166. Vector blt;
  167. Vector flt;
  168.  
  169.  
  170. if (!GameUtils::WorldToScreen(pointsTransformed[3], flb) || !GameUtils::WorldToScreen(pointsTransformed[5], brt)
  171. || !GameUtils::WorldToScreen(pointsTransformed[0], blb) || !GameUtils::WorldToScreen(pointsTransformed[4], frt)
  172. || !GameUtils::WorldToScreen(pointsTransformed[2], frb) || !GameUtils::WorldToScreen(pointsTransformed[1], brb)
  173. || !GameUtils::WorldToScreen(pointsTransformed[6], blt) || !GameUtils::WorldToScreen(pointsTransformed[7], flt))
  174. return false;
  175.  
  176. Vector arr[] = { flb, brt, blb, frt, frb, brb, blt, flt };
  177. //+1 for each cuz of borders at the original box
  178. float left = flb.x; // left
  179. float top = flb.y; // top
  180. float right = flb.x; // right
  181. float bottom = flb.y; // bottom
  182.  
  183. for (int i = 1; i < 8; i++)
  184. {
  185. if (left > arr[i].x)
  186. left = arr[i].x;
  187. if (top < arr[i].y)
  188. top = arr[i].y;
  189. if (right < arr[i].x)
  190. right = arr[i].x;
  191. if (bottom > arr[i].y)
  192. bottom = arr[i].y;
  193. }
  194. BotCenter = Vector(right - ((right - left) / 2), top, 0);
  195. TopCenter = Vector(right - ((right - left) / 2), bottom, 0);
  196. Left = left;
  197. Right = right;
  198. }
  199. else
  200. {
  201. Vector org = pBaseEntity->GetAbsOrigin();
  202. Vector head;
  203. if ((*pBaseEntity->GetFlags() & FL_DUCKING))
  204. head = org + Vector(0.f, 0.f, 52.f);
  205. else
  206. head = org + Vector(0.f, 0.f, 72.f);
  207.  
  208. Vector org_screen, head_screen;
  209. if (!GameUtils::WorldToScreen(org, org_screen) || !GameUtils::WorldToScreen(head, head_screen))
  210. return false;
  211.  
  212. int height = int(org_screen.y - head_screen.y);
  213. int width = int(height / 2);
  214. Left = int(head_screen.x - width / 2);
  215. Right = int(head_screen.x + width / 2);
  216. BotCenter = Vector(head_screen.x, org_screen.y);
  217. TopCenter = BotCenter; TopCenter.y = head_screen.y;
  218. }
  219. return true;
  220. }
  221.  
  222.  
  223. void CESP::DrawBones(CBaseEntity* pBaseEntity, int r, int g, int b, int a)
  224. {
  225. float Red = Clientvariables->Colors.Skeletons[0] * 255;
  226. float Green = Clientvariables->Colors.Skeletons[1] * 255;
  227. float Blue = Clientvariables->Colors.Skeletons[2] * 255;
  228.  
  229.  
  230. int index = pBaseEntity->Index();
  231. studiohdr_t* pStudioModel = g_pModelInfo->GetStudioModel((model_t*)pBaseEntity->GetModel());
  232. if (pStudioModel && g_BacktrackHelper->PlayerRecord[index].records.size() > 0)
  233. {
  234. tick_record record = g_BacktrackHelper->PlayerRecord[index].records.back();
  235.  
  236. float lerptime = g_BacktrackHelper->GetLerpTime();
  237. float desired_time = record.m_flSimulationTime + lerptime;
  238. float estimated_time = g_BacktrackHelper->GetEstimateServerTime();
  239.  
  240. float SV_MAXUNLAG = 1.0f;
  241.  
  242. float latency = g_BacktrackHelper->GetNetworkLatency();
  243. float m_flLerpTime = g_BacktrackHelper->GetLerpTime();
  244. float correct = clamp<float>(latency + m_flLerpTime, 0.0f, SV_MAXUNLAG);
  245.  
  246. float deltaTime = correct - (estimated_time + lerptime - desired_time);
  247.  
  248. if (fabs(deltaTime) <= 0.2f)
  249. {
  250.  
  251. for (int i = 0; i < pStudioModel->numbones; i++)
  252. {
  253. mstudiobone_t* pBone = pStudioModel->pBone(i);
  254.  
  255. if (!pBone || !(pBone->flags & 256) || pBone->parent == -1)
  256. continue;
  257.  
  258. Vector sBonePos1 = GameUtils::GetBonePosition(pBaseEntity, i, record.boneMatrix), vBonePos1; //.back() for nice skeleton
  259.  
  260. if (sBonePos1 == Vector(0, 0, 0))
  261. continue;
  262. if (!GameUtils::WorldToScreen(sBonePos1, vBonePos1))
  263. continue;
  264.  
  265. Vector sBonePos2 = GameUtils::GetBonePosition(pBaseEntity, pBone->parent, record.boneMatrix), vBonePos2;//.back() for nice skeleton
  266.  
  267. if (sBonePos2 == Vector(0, 0, 0))
  268. continue;
  269. if (!GameUtils::WorldToScreen(sBonePos2, vBonePos2))
  270. continue;
  271.  
  272. Color col = Color(Red, Green, Blue, 255);
  273.  
  274. if (record.needs_extrapolation)
  275. col = Color(255, 0, 0, 255);
  276.  
  277. g_Draw.LineRGBA((int)vBonePos1.x, (int)vBonePos1.y, (int)vBonePos2.x, (int)vBonePos2.y, col.r(), col.g(), col.b(), 255);
  278.  
  279. if (record.needs_extrapolation)
  280. {
  281. Vector position = record.m_vecOrigin;
  282. Vector extr_position = position;
  283. float simtime = record.m_flSimulationTime;
  284. g_BacktrackHelper->ExtrapolatePosition(pBaseEntity, extr_position, simtime, record.m_vecVelocity);
  285.  
  286. Vector sBonePos1 = GameUtils::GetBonePosition(pBaseEntity, i, record.boneMatrix), vBonePos1; //.back() for nice skeleton
  287.  
  288. if (sBonePos1 == Vector(0, 0, 0))
  289. continue;
  290.  
  291. sBonePos1 -= position;
  292. sBonePos1 += extr_position;
  293.  
  294. if (!GameUtils::WorldToScreen(sBonePos1, vBonePos1))
  295. continue;
  296.  
  297. Vector sBonePos2 = GameUtils::GetBonePosition(pBaseEntity, pBone->parent, record.boneMatrix), vBonePos2;//.back() for nice skeleton
  298.  
  299. if (sBonePos2 == Vector(0, 0, 0))
  300. continue;
  301.  
  302. sBonePos2 -= position;
  303. sBonePos2 += extr_position;
  304.  
  305. if (!GameUtils::WorldToScreen(sBonePos2, vBonePos2))
  306. continue;
  307.  
  308. Color col = Color(0, 255, 0);
  309.  
  310. g_Draw.LineRGBA((int)vBonePos1.x, (int)vBonePos1.y, (int)vBonePos2.x, (int)vBonePos2.y, col.r(), col.g(), col.b(), 255);
  311. }
  312. }
  313. }
  314. }
  315. }
  316.  
  317. RECT GetViewport()
  318. {
  319. RECT Viewport = { 0, 0, 0, 0 };
  320. int w, h;
  321. g_pEngine->GetScreenSize(w, h);
  322. Viewport.right = w; Viewport.bottom = h;
  323. return Viewport;
  324. }
  325.  
  326. void DrawTexturedPoly(int n, Vertex_t* vertice, Color col)
  327. {
  328. static int texture_id = g_pSurface->CreateNewTextureID(true);
  329. static unsigned char buf[4] = { 255, 255, 255, 255 };
  330. g_pSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1);
  331. g_pSurface->SetDrawColor(col);
  332. g_pSurface->DrawSetTexture(texture_id);
  333. g_pSurface->DrawTexturedPolygon(n, vertice);
  334. }
  335.  
  336. void DrawFilledCircle(Vector2D center, Color color, float radius, float points)
  337. {
  338. std::vector<Vertex_t> vertices;
  339. float step = (float)M_PI * 2.0f / points;
  340.  
  341. for (float a = 0; a < (M_PI * 2.0f); a += step)
  342. vertices.push_back(Vertex_t(Vector2D(radius * cosf(a) + center.x, radius * sinf(a) + center.y)));
  343.  
  344. DrawTexturedPoly((int)points, vertices.data(), color);
  345. }
  346.  
  347. void CESP::DoEnemyCircle(const Vector & vecDelta, float flRotation)
  348. {
  349. if (Clientvariables->Visuals.OutOfPOVArrows) {
  350. constexpr float radius = 360.0f;
  351. int width, height;
  352. g_pEngine->GetScreenSize(width, height);
  353.  
  354. Vector vRealAngles;
  355. g_pEngine->GetViewAngles(vRealAngles);
  356.  
  357. Vector vForward, vRight, vUp(0.0f, 0.0f, 1.0f);
  358.  
  359. Math::AngleVectors(vRealAngles, &vForward, NULL, NULL);
  360.  
  361. vForward.z = 0.0f;
  362. VectorNormalize(vForward);
  363. CrossProduct(vUp, vForward, vRight);
  364. float flFront = DotProduct(vecDelta, vForward);
  365. float flSide = DotProduct(vecDelta, vRight);
  366. float flXPosition = radius * -flSide;
  367. float flYPosition = radius * -flFront;
  368.  
  369. float rotation = G::UserCmd->viewangles.y;
  370.  
  371. rotation = atan2(flXPosition, flYPosition) + M_PI;
  372. rotation *= 180.0f / M_PI;
  373.  
  374. float flYawRadians = -(rotation)* M_PI / 180.0f;
  375. float flCosYaw = cos(flYawRadians);
  376. float flSinYaw = sin(flYawRadians);
  377.  
  378. flXPosition = (int)((width / 2.0f) + (radius * flSinYaw));
  379. flYPosition = (int)((height / 2.0f) - (radius * flCosYaw));
  380.  
  381. g_Draw.DrawRect(flXPosition, flYPosition, 10, 10, Color(255, 0, 0, 255));
  382.  
  383. }
  384. }
  385.  
  386. void CESP::Crosshair()
  387. {
  388. int width = 0;
  389. int height = 0;
  390.  
  391. if (Clientvariables->Visuals.SpreadCrosshair)
  392. {
  393. g_pEngine->GetScreenSize(width, height);
  394.  
  395. if (G::LocalPlayer && G::LocalPlayer->isAlive())
  396. {
  397. CBaseCombatWeapon* pWeapon = G::LocalPlayer->GetWeapon();
  398. float cone = pWeapon->GetSpread() + pWeapon->GetInaccuracy();
  399.  
  400. RECT View = GetViewport();
  401. int MidX = View.right / 1.9999999999999;
  402. int MidY = View.bottom / 2;
  403.  
  404. if (cone > 0.0f)
  405. {
  406. float Red, Green, Blue;
  407. Red = Clientvariables->Colors.SpreadCrosshair[0] * 255;
  408. Green = Clientvariables->Colors.SpreadCrosshair[1] * 255;
  409. Blue = Clientvariables->Colors.SpreadCrosshair[2] * 255;
  410.  
  411. if (cone < 0.01f) cone = 0.01f;
  412. float size = (cone * height) * 0.7f;
  413. Color color(Red, Green, Blue, 10);
  414.  
  415. g_pSurface->SetDrawColor(color);
  416. DrawFilledCircle(Vector2D(MidX, MidY), color, (int)size, 70);
  417. }
  418. }
  419. }
  420. }
  421.  
  422. void CESP::DrawLinesAA() {
  423.  
  424. Vector src3D, dst3D, forward, src, dst;
  425. trace_t tr;
  426. Ray_t ray;
  427. CTraceFilter filter;
  428. filter.pSkip = G::LocalPlayer;
  429.  
  430. src3D = G::LocalPlayer->GetAbsOrigin();
  431.  
  432. Math::AngleVectors(Vector(0, G::LocalPlayer->LowerBodyYaw(), 0), &forward);
  433. dst3D = src3D + (forward * 25.f); // Line Length
  434. ray.Init(src3D, dst3D);
  435. g_pEngineTrace->TraceRay(ray, 0, &filter, &tr);
  436.  
  437. if (!GameUtils::WorldToScreen(src3D, src) || !GameUtils::WorldToScreen(tr.endpos, dst)) // Lowerbody
  438. return;
  439.  
  440. g_pSurface->SetDrawColor(Color(0, 150, 0, 245));
  441. g_pSurface->DrawLine(src.x, src.y, dst.x, dst.y);
  442. //g_Draw.StringA(g_Draw.font_esp, true, dst.x, dst.y, 0, 150, 0, 255, "LBY");
  443.  
  444. }
  445.  
  446. float flPlayerAlpha[65];
  447.  
  448. void CESP::DrawPlayer(CBaseEntity* pPlayer, CBaseEntity* pLocalPlayer)
  449. {
  450. Vector m_position = pPlayer->GetAbsOrigin();
  451. Vector m_top_position = m_position;
  452.  
  453. if (*pPlayer->GetFlags() & IN_DUCK)
  454. m_top_position += Vector(0, 0, 52);
  455. else
  456. m_top_position += Vector(0, 0, 72);
  457.  
  458. Vector footpos, headpos;
  459.  
  460. if (pPlayer->IsDormant() && flPlayerAlpha[pPlayer->GetIndex()] > 0.f)
  461. flPlayerAlpha[pPlayer->GetIndex()] -= 0.5f;
  462. else if (flPlayerAlpha[pPlayer->GetIndex()] < 255.f && !pPlayer->IsDormant())
  463. flPlayerAlpha[pPlayer->GetIndex()] = 255.f;
  464.  
  465. if (pPlayer != G::LocalPlayer && !pPlayer->IsDormant() && Clientvariables->Visuals.SnapLines) // Crosshair to abs origin
  466. {
  467. RECT View = GetViewport();
  468. int MidX = View.right / 1.9999999999999;
  469. int MidY = View.bottom / 2;
  470.  
  471. Vector VecOrigin = pPlayer->GetAbsOrigin(), SecondVector;
  472.  
  473. if (GameUtils::WorldToScreen(VecOrigin, SecondVector))
  474. {
  475. g_Draw.LineRGBA(MidX, MidY, SecondVector.x, SecondVector.y, 255, 255, 255, 255);
  476. }
  477. }
  478.  
  479. if (GameUtils::WorldToScreen(m_position, footpos) && GameUtils::WorldToScreen(m_top_position, headpos))
  480. {
  481. Vector Bot, Top;
  482. float Left, Right;
  483. GetCBaseEntityBox(pPlayer, Bot, Top, Left, Right, true);
  484. int height = Bot.y - Top.y;
  485. int width = Right - Left;
  486. int x = Left;
  487. int y = Top.y;
  488.  
  489. CBaseCombatWeapon* pMainWeapon = pPlayer->GetWeapon();
  490.  
  491. if (Clientvariables->Visuals.Bones)
  492. DrawBones(pPlayer, 255, 255, 255, flPlayerAlpha[pPlayer->GetIndex()]);
  493.  
  494. if (Clientvariables->Visuals.BoundingBox)
  495. {
  496. float Red = Clientvariables->Colors.BoundingBox[0] * 255;
  497. float Green = Clientvariables->Colors.BoundingBox[1] * 255;
  498. float Blue = Clientvariables->Colors.BoundingBox[2] * 255;
  499.  
  500. if (pPlayer->IsDormant())
  501. {
  502. g_Draw.Box(x - 1, y - 1, width + 2, height + 2, 0, 0, 0, flPlayerAlpha[pPlayer->GetIndex()]);
  503. g_Draw.Box(x, y, width, height, Red, Green, Blue, flPlayerAlpha[pPlayer->GetIndex()]);
  504. g_Draw.Box(x + 1, y + 1, width - 2, height - 2, 0, 0, 0, flPlayerAlpha[pPlayer->GetIndex()]);
  505. }
  506. else
  507. {
  508. g_Draw.Box(x - 1, y - 1, width + 2, height + 2, 0, 0, 0, 255);
  509. g_Draw.Box(x, y, width, height, Red, Green, Blue, 255);
  510. g_Draw.Box(x + 1, y + 1, width - 2, height - 2, 0, 0, 0, 255);
  511. }
  512. }
  513.  
  514. if (Clientvariables->Visuals.Armor)
  515. {
  516. if (pPlayer->GetArmor() > 0)
  517. {
  518. char hp[50];
  519. sprintf_s(hp, sizeof(hp), "%i", pPlayer->GetArmor());
  520. if (pPlayer->HasHelmet())
  521. g_Draw.StringA(g_Draw.font_espinfo, false, x + width + 3, y, 255, 255, 255, flPlayerAlpha[pPlayer->GetIndex()], "HK");
  522. else
  523. g_Draw.StringA(g_Draw.font_espinfo, false, x + width + 3, y, 255, 255, 255, flPlayerAlpha[pPlayer->GetIndex()], "K");
  524. }
  525. }
  526.  
  527. if (Clientvariables->Visuals.Flags)
  528. {
  529. if (pPlayer->IsScoped())
  530. g_Draw.StringA(g_Draw.font_espinfo, false, x + width + 3, y + 20, 255, 255, 255, 255, "Scoped");
  531. }
  532.  
  533. if (Clientvariables->Visuals.Health)
  534. {
  535. int health = 100 - pPlayer->GetHealth();
  536. int w = 4;
  537. if (width < 4)
  538. w = width;
  539.  
  540. int hr, hg, hb;
  541.  
  542. hr = 255 - (pPlayer->GetHealth()*2.55);
  543. hg = pPlayer->GetHealth() * 2.55;
  544. hb = 0;
  545.  
  546. if (pPlayer->IsDormant())
  547. {
  548. g_Draw.FillRGBA(x - (5), y, w, height, 0, 0, 0, flPlayerAlpha[pPlayer->GetIndex()]);
  549. g_Draw.FillRGBA(x - (5), y + health * height / 100, w, pPlayer->GetHealth()*height / 100, 140, 140, 140, flPlayerAlpha[pPlayer->GetIndex()]);
  550. g_Draw.Box(x - (5), y, w, height, 0, 0, 0, flPlayerAlpha[pPlayer->GetIndex()]);
  551. }
  552. else
  553. {
  554. g_Draw.FillRGBA(x - (5), y, w, height, 0, 0, 0, 255);
  555. g_Draw.FillRGBA(x - (5), y + health * height / 100, w, pPlayer->GetHealth()*height / 100, hr, hg, hb, 255);
  556. g_Draw.Box(x - (5), y, w, height, 0, 0, 0, 255);
  557. }
  558. if (pPlayer->GetHealth() <= 100)
  559. {
  560. char hp[20];
  561. sprintf_s(hp, sizeof(hp), "%i", pPlayer->GetHealth());
  562.  
  563. g_Draw.StringA(g_Draw.font_esp, false, x - g_Draw.getWidht(hp, g_Draw.font_espnum), y + health * height / 100 - 6, 255, 255, 255, flPlayerAlpha[pPlayer->GetIndex()], "%i", pPlayer->GetHealth());
  564. }
  565. }
  566.  
  567.  
  568. int bot_add = 0;
  569. int top_add = 0;
  570.  
  571. if (Clientvariables->Visuals.Name)
  572. {
  573. player_info_s info;
  574. g_pEngine->GetPlayerInfo(pPlayer->Index(), &info);
  575. g_Draw.StringA(g_Draw.font_esp, true, x + width / 2, y - 12 - top_add, 255, 255, 255, flPlayerAlpha[pPlayer->GetIndex()], "%s", info.m_szPlayerName);
  576. top_add += 12;
  577. }
  578.  
  579. if (Clientvariables->Visuals.Weapon)
  580. {
  581. UINT* hWeapons = pPlayer->GetWeapons();
  582. if (hWeapons)
  583. {
  584. if (pMainWeapon)
  585. {
  586. std::string s1 = GetWeaponName(pMainWeapon);
  587. if (Clientvariables->Visuals.Ammo && pMainWeapon->Clip1() != -1 && pMainWeapon->GetWeaponType() != WEAPONCLASS::WEPCLASS_INVALID)
  588. {
  589. s1.append(XorStr(" | Ammo: [ "));
  590. s1.append(to_string(pMainWeapon->Clip1()));
  591. s1.append(XorStr(" ]"));
  592. }
  593. g_Draw.StringA(g_Draw.font_esp, true, x + width / 2, y + height + bot_add, 255, 255, 255, flPlayerAlpha[pPlayer->GetIndex()], XorStr("%s"), s1.c_str());
  594. }
  595. }
  596. }
  597. }
  598. }
  599.  
  600. void CESP::DrawC4(CBaseEntity* pBomb, bool is_planted, CBaseEntity* pLocalPlayer)
  601. {
  602. Vector Bot, Top;
  603. float Left, Right;
  604. GetCBaseEntityBox(pBomb, Bot, Top, Left, Right, false);
  605. int height = Bot.y - Top.y;
  606. int width = Right - Left;
  607.  
  608. DWORD col = is_planted ? D3DCOLOR_RGBA(250, 42, 42, 255) : D3DCOLOR_RGBA(255, 255, 0, 255);
  609.  
  610. g_Draw.StringA(g_Draw.font_esp, true, Left + width / 2, Bot.y, 255, 255, 0, 255, "%s", "[C4]");
  611.  
  612. if (is_planted)
  613. {
  614. CBomb* bomb = (CBomb*)pBomb;
  615. float flBlow = bomb->GetC4BlowTime();
  616. float TimeRemaining = flBlow - (g_pGlobals->interval_per_tick * pLocalPlayer->GetTickBase());
  617. if (TimeRemaining < 0)
  618. TimeRemaining = 0;
  619. char buffer[64];
  620.  
  621. if (bomb->IsDefused())
  622. sprintf_s(buffer, XorStr("Defused"));
  623. else
  624. sprintf_s(buffer, XorStr("%.1fs Remaining!"), TimeRemaining);
  625.  
  626.  
  627. //g_pRender->String(Left + width / 2, Bot.y + 13, centered, g_pRender->Fonts.esp, true, WHITE(255), "%s", buffer);
  628. g_Draw.StringA(g_Draw.font_esp, true, Left + width / 2, Bot.y + 13, 255, 255, 255, 255, "%s", buffer);
  629.  
  630. if (!bomb->IsDefused())
  631. {
  632. float a = 450.7f;
  633. float b = 75.68f;
  634. float c = 789.2f;
  635. float d = ((pLocalPlayer->GetAbsOrigin().DistTo(pBomb->GetOrigin()) - b) / c);
  636. float flDamage = a * expf(-d * d);
  637.  
  638. auto GetArmourHealth = [](float flDamage, int ArmorValue)
  639. {
  640. float flCurDamage = flDamage;
  641.  
  642. if (flCurDamage == 0.0f || ArmorValue == 0)
  643. return flCurDamage;
  644.  
  645. float flArmorRatio = 0.5f;
  646. float flArmorBonus = 0.5f;
  647. float flNew = flCurDamage * flArmorRatio;
  648. float flArmor = (flCurDamage - flNew) * flArmorBonus;
  649.  
  650. if (flArmor > ArmorValue)
  651. {
  652. flArmor = ArmorValue * (1.0f / flArmorBonus);
  653. flNew = flCurDamage - flArmor;
  654. }
  655.  
  656. return flNew;
  657. };
  658.  
  659. float damage = max((int)ceilf(GetArmourHealth(flDamage, pLocalPlayer->GetArmor())), 0);
  660.  
  661.  
  662. //g_pRender->String(Left + width / 2, Bot.y + 26, centered, g_pRender->Fonts.esp, true, WHITE(255), "Damage: %f", damage);
  663. g_Draw.StringA(g_Draw.font_esp, true, Left + width / 2, Bot.y + 26, 255, 255, 255, 255, "Damage: %f", damage);
  664. }
  665. }
  666. }
  667.  
  668. void CESP::DrawThrowable(CBaseEntity* pThrowable)
  669. {
  670. const model_t* nadeModel = pThrowable->GetModel();
  671.  
  672. if (!nadeModel)
  673. return;
  674.  
  675. studiohdr_t* hdr = g_pModelInfo->GetStudioModel(nadeModel);
  676.  
  677. if (!hdr)
  678. return;
  679.  
  680. if (!strstr(hdr->name, XorStr("thrown")) && !strstr(hdr->name, XorStr("dropped")))
  681. return;
  682.  
  683. std::string nadeName = XorStr("unknown");
  684.  
  685. IMaterial* mats[32];
  686. g_pModelInfo->GetModelMaterials(nadeModel, hdr->numtextures, mats);
  687.  
  688. for (int i = 0; i < hdr->numtextures; i++)
  689. {
  690. IMaterial* mat = mats[i];
  691. if (!mat)
  692. continue;
  693.  
  694. if (strstr(mat->GetName(), XorStr("flashbang")))
  695. {
  696. nadeName = XorStr("flashbang");
  697.  
  698. break;
  699. }
  700. else if (strstr(mat->GetName(), XorStr("m67_grenade")) || strstr(mat->GetName(), XorStr("hegrenade")))
  701. {
  702. nadeName = XorStr("grenade");
  703.  
  704. break;
  705. }
  706. else if (strstr(mat->GetName(), XorStr("smoke")))
  707. {
  708. nadeName = XorStr("smoke");
  709.  
  710. break;
  711. }
  712. else if (strstr(mat->GetName(), XorStr("decoy")))
  713. {
  714. nadeName = XorStr("decoy");
  715.  
  716. break;
  717. }
  718. else if (strstr(mat->GetName(), XorStr("incendiary")) || strstr(mat->GetName(), XorStr("molotov")))
  719. {
  720. nadeName = XorStr("molotov");
  721.  
  722. break;
  723. }
  724. }
  725. Vector Bot, Top;
  726. float Left, Right;
  727. GetCBaseEntityBox(pThrowable, Bot, Top, Left, Right, false);
  728. int height = Bot.y - Top.y;
  729. int width = Right - Left;
  730.  
  731. //g_pRender->Text((char*)nadeName.c_str(), Left + width / 2, Bot.y, centered, g_pRender->Fonts.esp, true, WHITE(255), BLACK(255));
  732. g_Draw.StringA(g_Draw.font_esp, true, Left + width / 2, Bot.y, 255, 255, 255, 255, nadeName.c_str());
  733. }
  734.  
  735. void CESP::DrawDroppedWeapon(CBaseCombatWeapon* pWeapon)
  736. {
  737. CBaseEntity* pCBaseEntity = (CBaseEntity*)pWeapon;
  738. CBaseCombatWeapon* Weapon = (CBaseCombatWeapon*)pWeapon;
  739.  
  740. if (!pCBaseEntity || !g_pModelInfo)
  741. return;
  742.  
  743. std::string sCurWeapon = g_pModelInfo->GetModelName(pCBaseEntity->GetModel());
  744. if (!sCurWeapon.empty() && sCurWeapon.find(XorStr("w_")) != std::string::npos)
  745. {
  746. std::string name;
  747.  
  748. if (sCurWeapon.find(XorStr("defuser")) != std::string::npos/* insert check for defuser here*/)
  749. name = XorStr("defuser");
  750. else
  751. {
  752. CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)pCBaseEntity;
  753. if (!pWeapon)return;
  754. name = GetWeaponName(pWeapon);//pWeapon->GetName(false);
  755. }
  756.  
  757. Vector Bot, Top;
  758. float Left, Right;
  759. GetCBaseEntityBox(pCBaseEntity, Bot, Top, Left, Right, false);
  760. int width = Right - Left;
  761.  
  762. float Red = Clientvariables->Colors.DroppedWeapon[0] * 255;
  763. float Green = Clientvariables->Colors.DroppedWeapon[1] * 255;
  764. float Blue = Clientvariables->Colors.DroppedWeapon[2] * 255;
  765.  
  766. g_Draw.StringA(g_Draw.font_esp, true, Left + width / 2, Bot.y, Red, Green, Blue, 255, name.c_str());
  767. }
  768. }
  769.  
  770. Vector MEME2(Vector EntityPos, Vector LocalPlayerPos, int posX, int posY, int sizeX, int sizeY, float angle, float zoom, bool * viewCheck)
  771. {
  772. float r_1, r_2;
  773. float x_1, y_1;
  774.  
  775. r_1 = -(EntityPos.y - LocalPlayerPos.y);
  776. r_2 = EntityPos.x - LocalPlayerPos.x;
  777. float Yaw = angle - 90.0f;
  778.  
  779. float yawToRadian = Yaw * (float)(M_PI / 180.0F);
  780. x_1 = (float)(r_2 * (float)cos((double)(yawToRadian)) - r_1 * sin((double)(yawToRadian))) / 20;
  781. y_1 = (float)(r_2 * (float)sin((double)(yawToRadian)) + r_1 * cos((double)(yawToRadian))) / 20;
  782.  
  783. *viewCheck = y_1 < 0;
  784.  
  785. x_1 *= zoom;
  786. y_1 *= zoom;
  787.  
  788. int sizX = sizeX / 2;
  789. int sizY = sizeY / 2;
  790.  
  791. x_1 += sizX;
  792. y_1 += sizY;
  793.  
  794. if (x_1 < 5)
  795. x_1 = 5;
  796.  
  797. if (x_1 > sizeX - 5)
  798. x_1 = sizeX - 5;
  799.  
  800. if (y_1 < 5)
  801. y_1 = 5;
  802.  
  803. if (y_1 > sizeY - 5)
  804. y_1 = sizeY - 5;
  805.  
  806.  
  807. x_1 += posX;
  808. y_1 += posY;
  809.  
  810.  
  811. return Vector(x_1, y_1, 0);
  812. }
  813.  
  814. FORCEINLINE float DotProduct64(const Vector& a, const Vector& b)
  815. {
  816. return (a.x * b.x + a.y * b.y + a.z * b.z);
  817. }
  818.  
  819. void CESP::Loop()
  820. {
  821. if (!G::LocalPlayer)
  822. return;
  823.  
  824. if (G::LocalPlayer->isAlive())
  825. Crosshair();
  826.  
  827. if (Clientvariables->Antiaim.Freestanding != 0 && G::LocalPlayer->isAlive())
  828. DrawLinesAA();
  829.  
  830. for (int i = 1; i <= g_pEntitylist->GetHighestEntityIndex(); i++)
  831. {
  832. CBaseEntity* pBaseEntity = g_pEntitylist->GetClientEntity(i);
  833.  
  834. if (!pBaseEntity)
  835. continue;
  836.  
  837. ClientClass* pClass = (ClientClass*)pBaseEntity->GetClientClass();
  838.  
  839. if (pClass->m_ClassID == int(EClassIds::CCSPlayer) && Clientvariables->Visuals.EspEnable)
  840. {
  841. if (pBaseEntity->GetHealth() < 1)
  842. continue;
  843.  
  844. bool is_friendly = pBaseEntity->GetTeamNum() == G::LocalPlayer->GetTeamNum();
  845.  
  846. if (Clientvariables->Visuals.LocalPlayer && pBaseEntity == G::LocalPlayer)
  847. g_ESP->DrawPlayer(pBaseEntity, G::LocalPlayer);
  848.  
  849. if (!is_friendly || is_friendly && !Clientvariables->Visuals.EnemyOnly)
  850. g_ESP->DrawPlayer(pBaseEntity, G::LocalPlayer);
  851. }
  852.  
  853. Vector buf, pos = pBaseEntity->GetAbsOrigin();
  854.  
  855. if (pos.x == 0 || pos.y == 0 || pos.z == 0 || !GameUtils::WorldToScreen(pos, buf))
  856. continue;
  857.  
  858. if ((pClass->m_ClassID != int(EClassIds::CBaseWeaponWorldModel) && (strstr(pClass->m_pNetworkName, XorStr("Weapon")) || pClass->m_ClassID == int(EClassIds::CDEagle) || pClass->m_ClassID == int(EClassIds::CAK47))) && Clientvariables->Visuals.DroppedWeapons == 1)
  859. DrawDroppedWeapon((CBaseCombatWeapon*)pBaseEntity);
  860.  
  861. if ((pClass->m_ClassID == int(EClassIds::CC4) || pClass->m_ClassID == int(EClassIds::CPlantedC4)))
  862. {
  863. if (Clientvariables->Visuals.Bomb)
  864. DrawC4(pBaseEntity, pClass->m_ClassID == int(EClassIds::CPlantedC4), G::LocalPlayer);
  865. }
  866.  
  867. if (strstr(pClass->m_pNetworkName, XorStr("Projectile")) && Clientvariables->Visuals.ThrownNades)
  868. DrawThrowable(pBaseEntity);
  869.  
  870. int W, H, cW, cH;
  871. g_pEngine->GetScreenSize(W, H);
  872. cW = W / 2;
  873. cH = H / 2;
  874. if (Clientvariables->Visuals.OutOfPOVArrows)
  875. {
  876. if (g_pEngine->IsInGame() && g_pEngine->IsConnected())
  877. {
  878. {
  879. constexpr float radius = 360.0f;
  880. int width, height;
  881. g_pEngine->GetScreenSize(width, height);
  882.  
  883. Vector origin = pBaseEntity->GetAbsOrigin();
  884.  
  885. Vector vRealAngles;
  886. g_pEngine->GetViewAngles(vRealAngles);
  887.  
  888. Vector vForward, vRight, vUp(0.f, 0.f, 1.f);
  889.  
  890. Math::AngleVectors(vRealAngles, vForward);
  891.  
  892. vForward.z = 0.0f;
  893. vRight = CrossProduct(vUp, vForward);
  894.  
  895. float flFront = DotProduct64(origin, vForward);
  896. float flSide = DotProduct64(origin, vRight);
  897. float flXPosition = radius * -flSide;
  898. float flYPosition = radius * -flFront;
  899.  
  900. float rotation = G::UserCmd->viewangles.y;
  901.  
  902. rotation = atan2(flXPosition, flYPosition) + M_PI;
  903. rotation *= 180.0f / M_PI;
  904.  
  905. float flYawRadians = -(rotation)* M_PI / 180.0f;
  906. float flCosYaw = cos(flYawRadians);
  907. float flSinYaw = sin(flYawRadians);
  908.  
  909. flXPosition = (int)((width / 2.0f) + (radius * flSinYaw));
  910. flYPosition = (int)((height / 2.0f) - (radius * flCosYaw));
  911.  
  912. Color Arrow_clr = pBaseEntity->GetTeamNum() == G::LocalPlayer->GetTeamNum() ?
  913. Color(0, 0, 0, 0) :
  914. Color(255, 0, 0, flPlayerAlpha[pBaseEntity->GetIndex()]);
  915. int r, g, b, a;
  916. Arrow_clr.GetColor(r, g, b, a);
  917. g_pSurface->SetDrawColor(r, g, b, a);
  918. g_pSurface->DrawTexturedRect(flXPosition - 8, flYPosition - 8, flXPosition + 8, flYPosition + 8);
  919. }
  920. }
  921. }
  922. }
  923. }
  924.  
  925. void CESP::DrawScope(CBaseEntity* pLocalPlayer)
  926. {
  927. CBaseCombatWeapon* pLocalWeapon = pLocalPlayer->GetWeapon();
  928.  
  929. if (pLocalWeapon)
  930. {
  931. if (pLocalWeapon->IsSniper())
  932. {
  933. if (pLocalPlayer->IsScoped())
  934. {
  935. int width = 0;
  936. int height = 0;
  937. g_pEngine->GetScreenSize(width, height);
  938. int centerX = static_cast<int>(width * 0.5f);
  939. int centerY = static_cast<int>(height * 0.5f);
  940. g_pSurface->SetDrawColor(Color(0, 0, 0, 255));
  941. g_pSurface->DrawLine(0, centerY, width, centerY);
  942. g_pSurface->DrawLine(centerX, 0, centerX, height);
  943. }
  944. }
  945. }
  946. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement