Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.08 KB | None | 0 0
  1. #include "Aimbot.h"
  2. #include "Autowall.h"
  3. #include "Backtrack.h"
  4. #include "..\..\csgo_sdk\IVModelInfo.h"
  5. #include "..\..\csgo_utilities\Utils.h"
  6. #include "..\..\csgo_sdk\IVEngineClient.h"
  7. #include "..\..\csgo_features\csgo_anti_aim\AntiAim.h"
  8. #include "..\..\csgo_sdk\PlayerInfo.h"
  9. #include "..\..\csgo_sdk\ICvar.h"
  10. #include "..\..\csgo_utilities\Math.h"
  11. #include "..\..\csgo_sdk\Hitboxes.h"
  12. #include "..\..\csgo_menu\Menu.h"
  13. #include "..\..\csgo_sdk\ISurface.h"
  14. #include "..\..\csgo_sdk\Definitions.h"
  15.  
  16. Aimbot g_Aimbot;
  17.  
  18. void Aimbot::Autostop()
  19. {
  20. if (!g_Menu.Config.Autostop)
  21. return;
  22.  
  23. Vector Velocity = g::pLocalEntity->GetVelocity();
  24. static float Speed = 450.f;
  25.  
  26. Vector Direction;
  27. Vector RealView;
  28. g_Math.VectorAngles(Velocity, Direction);
  29. g_pEngine->GetViewAngles(RealView);
  30. Direction.y = RealView.y - Direction.y;
  31.  
  32. Vector Forward;
  33. g_Math.AngleVectors(Direction, &Forward);
  34. Vector NegativeDirection = Forward * -Speed;
  35.  
  36. g::pCmd->forwardmove = NegativeDirection.x;
  37. g::pCmd->sidemove = NegativeDirection.y;
  38.  
  39. }
  40. /*void CAimbot::Autostop()
  41. {
  42. if (!g_Menu.Config.Autostop)
  43. return;
  44.  
  45. Vector Velocity = g::pLocalEntity->GetVelocity();
  46. static float Speed = 450.f;
  47.  
  48. Vector Direction;
  49. Vector RealView;
  50. g_Math.VectorAngles(Velocity, Direction);
  51. g_pEngine->GetViewAngles(RealView);
  52. Direction.y = RealView.y - Direction.y;
  53.  
  54. Vector Forward;
  55. g_Math.AngleVectors(Direction, &Forward);
  56. Vector NegativeDirection = Forward * -Speed;
  57.  
  58. g::pCmd->forwardmove = NegativeDirection.x;
  59. g::pCmd->sidemove = NegativeDirection.y;
  60.  
  61. }*/
  62.  
  63.  
  64. float Aimbot::accepted_inaccuracy(C_BaseCombatWeapon* weapon)
  65. {
  66. if (!g::pLocalEntity) return 0;
  67.  
  68. if (weapon->GetName() == "weapon_taser") return 0;
  69. if (!weapon) return false;
  70. float inaccuracy = weapon->GetInaccuracy();
  71. return inaccuracy < (float)15 / 1000.f;
  72.  
  73. }
  74.  
  75. bool Aimbot::HitChance(C_BaseEntity* pEnt, C_BaseCombatWeapon* pWeapon, Vector Angle, Vector Point, int chance)
  76. {
  77. if (chance == 0 || g_Menu.Config.Hitchance == 0)
  78. return true;
  79.  
  80. if (Backtrack[pEnt->EntIndex()] || ShotBacktrack[pEnt->EntIndex()]) // doing this bec im lazy
  81. {
  82. float Velocity = g::pLocalEntity->GetVelocity().Length();
  83.  
  84. if (Velocity <= (g::pLocalEntity->GetActiveWeapon()->GetCSWpnData()->max_speed_alt * .34f))
  85. Velocity = 0.0f;
  86.  
  87. float SpreadCone = pWeapon->GetAccuracyPenalty() * 256.0f / M_PI + pWeapon->GetCSWpnData()->max_speed * Velocity / 3000.0f; // kmeth https://github.com/DankPaster/kmethdude
  88. float a = (Point - g::pLocalEntity->GetEyePosition()).Length();
  89. float b = sqrt(tan(SpreadCone * M_PI / 180.0f) * a);
  90. if (2.2f > b) return true;
  91. return (chance <= ((2.2f / fmax(b, 2.2f)) * 100.0f));
  92. }
  93.  
  94. if (g_Menu.Config.Hitchance == 1 || g_Menu.Config.Hitchance == 2)
  95. {
  96. float Seeds = (g_Menu.Config.Hitchance == 1) ? 356.f : 256.f;
  97.  
  98. Angle -= (g::pLocalEntity->GetAimPunchAngle() * g_pCvar->FindVar("weapon_recoil_scale")->GetFloat());
  99.  
  100. Vector forward, right, up;
  101.  
  102. g_Math.AngleVectors(Angle, &forward, &right, &up);
  103.  
  104. int Hits = 0, neededHits = (Seeds * (chance / 100.f));
  105.  
  106. float weapSpread = pWeapon->GetSpread(), weapInaccuracy = pWeapon->GetInaccuracy();
  107.  
  108. for (int i = 0; i < Seeds; i++)
  109. {
  110. float Inaccuracy = g_Math.RandomFloat(0.f, 1.f) * weapInaccuracy;
  111. float Spread = g_Math.RandomFloat(0.f, 1.f) * weapSpread;
  112.  
  113. Vector spreadView((cos(g_Math.RandomFloat(0.f, 2.f * M_PI)) * Inaccuracy) + (cos(g_Math.RandomFloat(0.f, 2.f * M_PI)) * Spread), (sin(g_Math.RandomFloat(0.f, 2.f * M_PI)) * Inaccuracy) + (sin(g_Math.RandomFloat(0.f, 2.f * M_PI)) * Spread), 0), direction;
  114. direction = Vector(forward.x + (spreadView.x * right.x) + (spreadView.y * up.x), forward.y + (spreadView.x * right.y) + (spreadView.y * up.y), forward.z + (spreadView.x * right.z) + (spreadView.y * up.z)).Normalize();
  115.  
  116. Vector viewanglesSpread, viewForward;
  117.  
  118. g_Math.VectorAngles(direction, up, viewanglesSpread);
  119. g_Math.NormalizeAngles(viewanglesSpread);
  120.  
  121. g_Math.AngleVectors(viewanglesSpread, &viewForward);
  122. viewForward.NormalizeInPlace();
  123.  
  124. viewForward = g::pLocalEntity->GetEyePosition() + (viewForward * pWeapon->GetCSWpnData()->range);
  125.  
  126. CGameTrace Trace;
  127.  
  128. g_pEngineTrace->ClipRayToEntity(Ray_t(g::pLocalEntity->GetEyePosition(), viewForward), MASK_SHOT | CONTENTS_GRATE, pEnt, &Trace);
  129.  
  130. if (Trace.hit_entity == pEnt)
  131. Hits++;
  132.  
  133. if (((Hits / Seeds) * 100.f) >= chance)
  134. return true;
  135.  
  136. if ((Seeds - i + Hits) < neededHits)
  137. return false;
  138. }
  139. }
  140.  
  141. if (g_Menu.Config.Hitchance == 3)
  142. {
  143. if (accepted_inaccuracy(pWeapon) >= g_Menu.Config.HitchanceValue)
  144. return true;
  145. }
  146.  
  147. return false;
  148. }
  149.  
  150. bool ShouldBaim(C_BaseEntity* pEnt) // probably dosnt make sense
  151. {
  152. static float oldSimtime[65];
  153. static float storedSimtime[65];
  154.  
  155. static float ShotTime[65];
  156. static float NextShotTime[65];
  157. static bool BaimShot[65];
  158.  
  159. if (storedSimtime[pEnt->EntIndex()] != pEnt->GetSimulationTime())
  160. {
  161. oldSimtime[pEnt->EntIndex()] = storedSimtime[pEnt->EntIndex()];
  162. storedSimtime[pEnt->EntIndex()] = pEnt->GetSimulationTime();
  163. }
  164.  
  165. float simDelta = storedSimtime[pEnt->EntIndex()] - oldSimtime[pEnt->EntIndex()];
  166.  
  167. bool Shot = false;
  168.  
  169. if (pEnt->GetActiveWeapon() && !pEnt->IsKnifeorNade())
  170. {
  171. if (ShotTime[pEnt->EntIndex()] != pEnt->GetActiveWeapon()->GetLastShotTime())
  172. {
  173. Shot = true;
  174. BaimShot[pEnt->EntIndex()] = false;
  175. ShotTime[pEnt->EntIndex()] = pEnt->GetActiveWeapon()->GetLastShotTime();
  176. }
  177. else
  178. Shot = false;
  179. }
  180. else
  181. {
  182. Shot = false;
  183. ShotTime[pEnt->EntIndex()] = 0.f;
  184. }
  185.  
  186. if (Shot)
  187. {
  188. NextShotTime[pEnt->EntIndex()] = pEnt->GetSimulationTime() + pEnt->FireRate();
  189.  
  190. if (simDelta >= pEnt->FireRate())
  191. BaimShot[pEnt->EntIndex()] = true;
  192. }
  193.  
  194. if (BaimShot[pEnt->EntIndex()])
  195. {
  196. if (pEnt->GetSimulationTime() >= NextShotTime[pEnt->EntIndex()])
  197. BaimShot[pEnt->EntIndex()] = false;
  198. }
  199.  
  200. if (g_Menu.Config.BaimPitch && BaimShot[pEnt->EntIndex()] && !(pEnt->GetFlags() & FL_ONGROUND))
  201. return true;
  202.  
  203. if (g_Menu.Config.BaimInAir && !(pEnt->GetFlags() & FL_ONGROUND))
  204. return true;
  205.  
  206. return false;
  207. }
  208.  
  209. Vector Aimbot::Hitscan(C_BaseEntity* pEnt)
  210. {
  211.  
  212. Vector local_position = g::pLocalEntity->GetOrigin() + g::pLocalEntity->GetViewOffset();
  213. float DamageArray[27];
  214. float tempDmg = 0.f;
  215. Vector tempHitbox = { 0,0,0 };
  216. static int HitboxForMuti[] = { 2,2,4,4,6,6 };
  217.  
  218. float angToLocal = g_Math.CalcAngle(g::pLocalEntity->GetOrigin(), pEnt->GetOrigin()).y;
  219.  
  220. Vector2D MutipointXY = { (sin(g_Math.GRD_TO_BOG(angToLocal))),(cos(g_Math.GRD_TO_BOG(angToLocal))) };
  221. Vector2D MutipointXY180 = { (sin(g_Math.GRD_TO_BOG(angToLocal + 180))) ,(cos(g_Math.GRD_TO_BOG(angToLocal + 180))) };
  222. Vector2D Mutipoint[] = { Vector2D(MutipointXY.x, MutipointXY.y), Vector2D(MutipointXY180.x, MutipointXY180.y) };
  223.  
  224. float Velocity = abs(pEnt->GetVelocity().Length2D());
  225.  
  226. if (!g_Menu.Config.DelayShot && Velocity > 29.f)
  227. Velocity = 30.f;
  228.  
  229. std::vector<int> Scan;
  230.  
  231. int HeadHeight = 50;
  232.  
  233. bool Baim = ShouldBaim(pEnt);
  234.  
  235. if (!Baim)
  236. Scan.push_back(HITBOX_HEAD);
  237.  
  238. if (Velocity <= 215.f || Baim)
  239. {
  240. Scan.push_back(HITBOX_PELVIS);
  241. Scan.push_back(HITBOX_THORAX);
  242. Scan.push_back(HITBOX_LOWER_CHEST);
  243. Scan.push_back(HITBOX_UPPER_CHEST);
  244.  
  245. if (g_Menu.Config.MultiPoint)
  246. {
  247. Scan.push_back(19);//pelvis
  248. Scan.push_back(20);
  249.  
  250. Scan.push_back(21);//thorax
  251. Scan.push_back(22);
  252.  
  253. Scan.push_back(23);//upperchest
  254. Scan.push_back(24);
  255.  
  256. if (Velocity <= 80.f && !Baim)
  257. {
  258. Scan.push_back(25);//head
  259. Scan.push_back(26);
  260. }
  261.  
  262. HeadHeight = g_Menu.Config.HeadScale;
  263. }
  264.  
  265. if (!g_Menu.Config.IgnoreLimbs)
  266. Velocity = 0.f;
  267.  
  268. if (Velocity <= 29.f)
  269. {
  270. Scan.push_back(HITBOX_LEFT_FOOT);
  271. Scan.push_back(HITBOX_RIGHT_FOOT);
  272. Scan.push_back(HITBOX_LEFT_UPPER_ARM);
  273. Scan.push_back(HITBOX_RIGHT_UPPER_ARM);
  274. Scan.push_back(HITBOX_LEFT_THIGH);
  275. Scan.push_back(HITBOX_RIGHT_THIGH);
  276. }
  277. }
  278.  
  279. Vector Hitbox;
  280. int bestHitboxint = 0;
  281.  
  282. for (int hitbox : Scan)
  283. {
  284. if (hitbox < 19)
  285. Hitbox = pEnt->GetHitboxPosition(hitbox, Matrix[pEnt->EntIndex()]) + Vector(0, 0, (hitbox == 0) ? -5 + (HeadHeight / 10.f) : 0);
  286. else if (hitbox > 18 && hitbox < 25)
  287. {
  288. float Radius = 0;
  289. Hitbox = pEnt->GetHitboxPosition(HitboxForMuti[hitbox - 19], Matrix[pEnt->EntIndex()], &Radius);
  290. Radius *= (g_Menu.Config.BodyScale / 100.f);
  291. Hitbox = Vector(Hitbox.x + (Radius * Mutipoint[((hitbox - 19) % 2)].x), Hitbox.y - (Radius * Mutipoint[((hitbox - 19) % 2)].y), Hitbox.z);
  292. }
  293. else if (hitbox > 24 && hitbox < 27)
  294. {
  295. float Radius = 0;
  296. Hitbox = pEnt->GetHitboxPosition(0, Matrix[pEnt->EntIndex()], &Radius);
  297. Radius *= (HeadHeight / 100.f);
  298. Hitbox = Vector(Hitbox.x + (Radius * Mutipoint[((hitbox - 25) % 2)].x), Hitbox.y - (Radius * Mutipoint[((hitbox - 25) % 2)].y), Hitbox.z);
  299. }
  300.  
  301. float Damage = g_AutoWall.CanHit(Hitbox);
  302.  
  303. if (Damage > 0.f)
  304. DamageArray[hitbox] = Damage;
  305. else
  306. DamageArray[hitbox] = 0;
  307.  
  308. if (g_Menu.Config.BaimLethal && hitbox != 0 && hitbox != 25 && hitbox != 26 && Damage >= (pEnt->GetHealth() + 10))
  309. {
  310. DamageArray[hitbox] = 400;
  311. }
  312.  
  313. if (DamageArray[hitbox] > tempDmg)
  314. {
  315. tempHitbox = Hitbox;
  316. bestHitboxint = hitbox;
  317. tempDmg = DamageArray[hitbox];
  318. }
  319.  
  320. g::AimbotHitbox[pEnt->EntIndex()][hitbox] = Hitbox;
  321. }
  322.  
  323. PlayerRecords pPlayerEntityRecord = g_LagComp.PlayerRecord[pEnt->EntIndex()].at(0);
  324.  
  325. Backtrack[pEnt->EntIndex()] = false;
  326. ShotBacktrack[pEnt->EntIndex()] = false;
  327.  
  328. if (g_Menu.Config.ShotBacktrack && g_LagComp.ShotTick[pEnt->EntIndex()] != -1 && g_AutoWall.CanHitFloatingPoint(pEnt->GetHitboxPosition(HITBOX_HEAD, g_LagComp.PlayerRecord[pEnt->EntIndex()].at(g_LagComp.ShotTick[pEnt->EntIndex()]).Matrix) + Vector(0, 0, 1), g::pLocalEntity->GetEyePosition()) && !Baim)
  329. {
  330. bestEntDmg = (1000000.f - fabs(g_Math.Distance(Vector2D(g::pLocalEntity->GetOrigin().x, g::pLocalEntity->GetOrigin().y), Vector2D(pEnt->GetOrigin().x, pEnt->GetOrigin().y)))); // just doing this to get the closest player im backtracking
  331. ShotBacktrack[pEnt->EntIndex()] = true;
  332. return pEnt->GetHitboxPosition(HITBOX_HEAD, g_LagComp.PlayerRecord[pEnt->EntIndex()].at(g_LagComp.ShotTick[pEnt->EntIndex()]).Matrix) + Vector(0, 0, 1);
  333. }
  334. else if (tempDmg >= g_Menu.Config.Mindmg)
  335. {
  336. bestEntDmg = tempDmg;
  337.  
  338. if ((bestHitboxint == 25 || bestHitboxint == 26 || bestHitboxint == 27) && abs(DamageArray[HITBOX_HEAD] - DamageArray[bestHitboxint]) <= 10.f)
  339. return pEnt->GetHitboxPosition(HITBOX_HEAD, Matrix[pEnt->EntIndex()]);
  340. else if ((bestHitboxint == 19 || bestHitboxint == 20) && DamageArray[HITBOX_PELVIS] > 30)
  341. return pEnt->GetHitboxPosition(HITBOX_PELVIS, Matrix[pEnt->EntIndex()]);
  342. else if ((bestHitboxint == 21 || bestHitboxint == 22) && DamageArray[HITBOX_THORAX] > 30)
  343. return pEnt->GetHitboxPosition(HITBOX_THORAX, Matrix[pEnt->EntIndex()]);
  344. else if ((bestHitboxint == 23 || bestHitboxint == 24) && DamageArray[HITBOX_UPPER_CHEST] > 30)
  345. return pEnt->GetHitboxPosition(HITBOX_UPPER_CHEST, Matrix[pEnt->EntIndex()]);
  346.  
  347. return tempHitbox;
  348. }
  349. else if (g_Menu.Config.PosBacktrack && pPlayerEntityRecord.Velocity >= 29.f && g_AutoWall.CanHitFloatingPoint(pEnt->GetHitboxPosition(HITBOX_HEAD, pPlayerEntityRecord.Matrix), g::pLocalEntity->GetEyePosition()))
  350. {
  351. bestEntDmg = (100000.f - fabs(g_Math.Distance(Vector2D(g::pLocalEntity->GetOrigin().x, g::pLocalEntity->GetOrigin().y), Vector2D(pEnt->GetOrigin().x, pEnt->GetOrigin().y))));
  352. Backtrack[pEnt->EntIndex()] = true;
  353. return pEnt->GetHitboxPosition(HITBOX_HEAD, pPlayerEntityRecord.Matrix);
  354. }
  355.  
  356. return Vector(0, 0, 0);
  357. }
  358.  
  359. void Aimbot::OnCreateMove()
  360. {
  361. if (!g::pLocalEntity || !g_pEngine->IsInGame())
  362. return;
  363.  
  364. Vector Aimpoint = { 0,0,0 };
  365. C_BaseEntity* Target = nullptr;
  366.  
  367. int targetID = 0;
  368. int tempDmg = 0;
  369. static bool shot = false;
  370.  
  371. for (int i = 0; i <= g_pEngine->GetMaxClients(); ++i)
  372. {
  373. C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
  374.  
  375. if (!pPlayerEntity
  376. || !pPlayerEntity->IsAlive()
  377. || pPlayerEntity->IsDormant()
  378. || pPlayerEntity == g::pLocalEntity
  379. || pPlayerEntity->GetTeam() == g::pLocalEntity->GetTeam())
  380. {
  381. g_LagComp.ClearRecords(i);
  382. continue;
  383. }
  384.  
  385. g_LagComp.StoreRecord(pPlayerEntity);
  386.  
  387. if (pPlayerEntity == g::pLocalEntity || pPlayerEntity->GetTeam() == g::pLocalEntity->GetTeam())
  388. continue;
  389.  
  390. g::EnemyEyeAngs[i] = pPlayerEntity->GetEyeAngles();
  391.  
  392. if (g_LagComp.PlayerRecord[i].size() == 0 || !g::pLocalEntity->IsAlive() || !g_Menu.Config.Aimbot)
  393. continue;
  394.  
  395. if (!g::pLocalEntity->IsAlive() || !g::pLocalEntity->GetActiveWeapon() || g::pLocalEntity->IsKnifeorNade())
  396. continue;
  397.  
  398. bestEntDmg = 0;
  399. Vector Hitbox = Hitscan(pPlayerEntity);
  400.  
  401. if (Hitbox != Vector(0, 0, 0) && tempDmg <= bestEntDmg)
  402. {
  403. Aimpoint = Hitbox;
  404. Target = pPlayerEntity;
  405. targetID = Target->EntIndex();
  406. tempDmg = bestEntDmg;
  407. }
  408. }
  409.  
  410. if (!g::pLocalEntity->IsAlive())
  411. {
  412. shot = false;
  413. return;
  414. }
  415.  
  416. if (shot)
  417. {
  418. if (g_Menu.Config.FixShotPitch) // ik it dosnt realy fix much just makes ur pitch go down faster
  419. {
  420. g::bSendPacket = true;
  421. g_AntiAim.OnCreateMove();
  422. }
  423. shot = false;
  424. }
  425.  
  426. float flServerTime = g::pLocalEntity->GetTickBase() * g_pGlobalVars->intervalPerTick;
  427. bool canShoot = (g::pLocalEntity->GetActiveWeapon()->GetNextPrimaryAttack() <= flServerTime);
  428.  
  429. if (Target)
  430. {
  431. g::TargetIndex = targetID;
  432.  
  433. float SimulationTime = 0.f;
  434.  
  435. if (Backtrack[targetID])
  436. SimulationTime = g_LagComp.PlayerRecord[targetID].at(0).SimTime;
  437. else
  438. SimulationTime = g_LagComp.PlayerRecord[targetID].at(g_LagComp.PlayerRecord[targetID].size() - 1).SimTime;
  439.  
  440. if (ShotBacktrack[targetID])
  441. SimulationTime = g_LagComp.PlayerRecord[targetID].at(g_LagComp.ShotTick[targetID]).SimTime;
  442.  
  443. bool validbSendPacket = true;
  444.  
  445. if (g_Menu.Config.OneTickChoke && g::bSendPacket && g_Menu.Config.Fakelag != 0)
  446. validbSendPacket = false;
  447.  
  448. Vector Angle = g_Math.CalcAngle(g::pLocalEntity->GetEyePosition(), Aimpoint);
  449.  
  450. if (g::pLocalEntity->GetVelocity().Length() >= (g::pLocalEntity->GetActiveWeapon()->GetCSWpnData()->max_speed_alt * .34f) - 5 && !GetAsyncKeyState(VK_SPACE))
  451. Autostop();
  452.  
  453. if (!(g::pCmd->buttons & IN_ATTACK) && canShoot && HitChance(Target, g::pLocalEntity->GetActiveWeapon(), Angle, Aimpoint, g_Menu.Config.HitchanceValue) && validbSendPacket)
  454. {
  455.  
  456. if (!Backtrack[targetID] && !ShotBacktrack[targetID])
  457. g::Shot[targetID] = true;
  458.  
  459. g::Shot[g::TargetIndex] = true;
  460.  
  461. g::bSendPacket = true;
  462.  
  463. if (g_Menu.Config.ChokeShotOnPeek && g::LagPeek && !g_Menu.Config.OneTickChoke)
  464. g::bSendPacket = false;
  465.  
  466. if (g_Menu.Config.OneTickChoke)
  467. {
  468. shot = true;
  469. g::bSendPacket = false;
  470. }
  471.  
  472. g::bSendPacket = true;
  473. shot = true;
  474.  
  475. g::pCmd->viewangles = Angle - (g::pLocalEntity->GetAimPunchAngle() * g_pCvar->FindVar("weapon_recoil_scale")->GetFloat());
  476. g::pCmd->buttons |= IN_ATTACK;
  477. g::pCmd->tick_count = TIME_TO_TICKS(Target->GetSimulationTime() + g_LagComp.LerpTime());
  478. }
  479. }
  480. }
  481.  
  482. template<class T, class U>
  483. T Aimbot::clamp(T in, U low, U high)
  484. {
  485. if (in <= low)
  486. return low;
  487.  
  488. if (in >= high)
  489. return high;
  490.  
  491. return in;
  492. }
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500. /*int bestHitbox = -1, mostDamage;
  501. Vector multipoints[128];
  502. int multipointCount = 0;
  503. bool lag_comp;
  504. #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
  505.  
  506. float CAimbot::seedchance(Vector Point)//what do you mean
  507. {
  508.  
  509. if (!g::pLocalEntity)
  510. return 0;
  511.  
  512. C_BaseCombatWeapon *weapon = (C_BaseCombatWeapon*)g::pLocalEntity->GetActiveWeapon();
  513.  
  514. if (!weapon)
  515. return 0;
  516.  
  517. float SpreadCone = weapon->GetAccuracyPenalty() * 256.0f / M_PI + weapon->GetCSWpnData()->max_speed * g::pLocalEntity->GetVelocity().Length() / 3000.0f;
  518.  
  519. Vector local_position = g::pLocalEntity->GetOrigin() + g::pLocalEntity->GetViewOffset();
  520.  
  521. float a = (Point - local_position).Length();
  522. float b = sqrt(tan(SpreadCone * M_PI / 180.0f) * a);
  523. if (2.2f > b) return 100.0f;
  524. return (2.2f / fmax(b, 2.2f)) * 100.0f;
  525. }
  526.  
  527. void CAimbot::run_aimbot()
  528. {
  529. Entities.clear();
  530. SelectTarget();
  531. shoot_enemy();
  532.  
  533. }
  534.  
  535. void CAimbot::SelectTarget()
  536. {
  537. if (!g::pLocalEntity) return;
  538.  
  539. for (int index = 1; index <= 65; index++)
  540. {
  541. auto entity = g_pEntityList->GetClientEntity(index);
  542. if (!entity) continue;
  543. if (entity->GetTeam() == g::pLocalEntity->GetTeam()) continue;
  544. if (entity->GetHealth() <= 0) continue;
  545. if (entity->GetClientClass()->ClassID != 38) continue;
  546. if (entity->GetOrigin() == Vector(0, 0, 0)) continue;
  547. if (entity->IsImmune()) continue;
  548. if (entity->GetIsDormant()) continue;
  549. AimbotData_t data = AimbotData_t(entity, index);
  550. Entities.push_back(data);
  551. }
  552. }
  553.  
  554. void CAimbot::auto_revolver()
  555. {
  556. if (!g::pLocalEntity && g::pLocalEntity->GetHealth() <= 0) return;
  557.  
  558. C_BaseCombatWeapon *weapon = (C_BaseCombatWeapon*)g::pLocalEntity->GetActiveWeapon();
  559.  
  560. if (!weapon || weapon->GetAmmo() == 0) return;
  561.  
  562. if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_REVOLVER) {
  563. g::pCmd->buttons |= IN_ATTACK;
  564. float flPostponeFireReady = weapon->GetPostponeFireReadyTime();
  565. if (flPostponeFireReady > 0 && flPostponeFireReady < g_pGlobalVars->curtime) {
  566. g::pCmd->buttons &= ~IN_ATTACK;
  567. }
  568. }
  569. }
  570.  
  571. void CAimbot::shoot_enemy()
  572. {
  573. if (!g::pLocalEntity || g::pLocalEntity->GetHealth() <= 0) return;
  574.  
  575. C_BaseCombatWeapon *weapon = (C_BaseCombatWeapon*)g::pLocalEntity->GetActiveWeapon();
  576.  
  577. if (!weapon || weapon->GetAmmo() == 0) return;
  578. if (weapon->GetCSWpnData()->type == 9) return;
  579.  
  580. float flServerTime = g::pLocalEntity->GetTickBase() * g_pGlobalVars->intervalPerTick;
  581. bool canShoot = (g::pLocalEntity->GetActiveWeapon()->GetNextPrimaryAttack() <= flServerTime);
  582.  
  583. if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_C4 || g::pLocalEntity->IsKnifeorNade()) return;
  584. if (!canShoot) { g::pCmd->buttons &= ~IN_ATTACK; return; }
  585. if (GetAsyncKeyState(VK_LBUTTON)) return;
  586. Vector aim_angles;
  587. for (auto players : Entities)
  588. {
  589. auto entity = players.pPlayer;
  590. auto class_id = entity->GetClientClass()->ClassID;
  591.  
  592. if (!entity)
  593. continue;
  594.  
  595. if (entity->GetTeam() == g::pLocalEntity->GetTeam())
  596. continue;
  597.  
  598. if (entity->GetHealth() <= 0)
  599. continue;
  600.  
  601. if (class_id != 38)
  602. continue;
  603.  
  604. if (entity->GetOrigin() == Vector(0, 0, 0))
  605. continue;
  606.  
  607. if (entity->IsImmune())
  608. continue;
  609.  
  610. if (entity->GetIsDormant())
  611. continue;
  612.  
  613. Vector where2Shoot;
  614.  
  615. if (g_Menu.Config.MultiPoint) where2Shoot = aimbot->full_multipoint(entity);
  616. else where2Shoot = aimbot->full_point(entity);
  617. if (where2Shoot == Vector(0, 0, 0)) continue;
  618.  
  619. if (g::pLocalEntity->GetVelocity().Length() >= (g::pLocalEntity->GetActiveWeapon()->GetCSWpnData()->max_speed_alt * .34f) - 5 && !GetAsyncKeyState(VK_SPACE))
  620. Autostop();
  621.  
  622. aim_angles = g_Math.NormalizeAngle(g_Math.CalcAngle(g::pLocalEntity->GetEyePosition(), where2Shoot));
  623. if (aim_angles == Vector(0, 0, 0)) continue;
  624.  
  625. if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_AWP || weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SSG08 ||
  626. weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SCAR20 || weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_G3SG1 ||
  627. weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_AUG || weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SG556)
  628. if (!g::pLocalEntity->IsScoped())
  629. g::pCmd->buttons |= IN_ATTACK2;
  630.  
  631. auto_revolver();
  632.  
  633. Vector vec_position[65], origin_delta[65];
  634. if (entity->GetOrigin() != vec_position[entity->GetIndex()])
  635. {
  636. origin_delta[entity->GetIndex()] = entity->GetOrigin() - vec_position[entity->GetIndex()];
  637. vec_position[entity->GetIndex()] = entity->GetOrigin();
  638.  
  639. lag_comp = fabs(origin_delta[entity->GetIndex()].Length()) > 64;
  640. }
  641.  
  642. if (lag_comp && entity->GetVelocity().Length2D() > 300 && g_Menu.Config.DelayShot1 == 1) return;
  643.  
  644. if (accepted_inaccuracy(weapon) < g_Menu.Config.HitchanceValue1) continue;
  645.  
  646. if (g_LagComp.ValidTick(TIME_TO_TICKS(entity->GetSimulationTime() + g_LagComp.LerpTime())))
  647. g::pCmd->tick_count = TIME_TO_TICKS(entity->GetSimulationTime() + g_LagComp.LerpTime());
  648.  
  649. g::pCmd->buttons |= IN_ATTACK;
  650. break;
  651. }
  652.  
  653. if (g::pCmd->buttons & IN_ATTACK)
  654. {
  655. float recoil_scale = g_pCvar->FindVar("weapon_recoil_scale")->GetFloat(); g::bSendPacket = true;
  656. aim_angles -= g::pLocalEntity->GetAimPunchAngle() * recoil_scale; g::pCmd->viewangles = aim_angles;
  657. }
  658. }
  659.  
  660.  
  661. float CAimbot::accepted_inaccuracy(C_BaseCombatWeapon* weapon) //ayyyyyywareeee
  662. {
  663. if (!g::pLocalEntity) return 0;
  664.  
  665. if (!weapon) return 0;
  666. if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_TASER) return 0;
  667.  
  668. float inaccuracy = weapon->GetInaccuracy();
  669.  
  670. if (inaccuracy == 0) inaccuracy = 0.0000001;
  671. inaccuracy = 1 / inaccuracy;
  672. return inaccuracy;
  673. }
  674.  
  675. bool CAimbot::meets_requirements(C_BaseEntity* entity)
  676. {
  677. //is the aimbot targeted on this enemy
  678. return true;
  679. }
  680.  
  681. int CAimbot::select_target()
  682. {
  683. //finds a target based on distance
  684. return 0;
  685. }
  686.  
  687. std::vector<Vector> CAimbot::GetMultiplePointsForHitbox(C_BaseEntity* local, C_BaseEntity* entity, int iHitbox, matrix3x4_t BoneMatrix[128])
  688. {
  689. auto VectorTransform_Wrapper = [](const Vector& in1, const matrix3x4_t &in2, Vector &out)
  690. {
  691. auto VectorTransform = [](const float *in1, const matrix3x4_t& in2, float *out)
  692. {
  693. auto DotProducts = [](const float *v1, const float *v2)
  694. {
  695. return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
  696. };
  697. out[0] = DotProducts(in1, in2[0]) + in2[0][3];
  698. out[1] = DotProducts(in1, in2[1]) + in2[1][3];
  699. out[2] = DotProducts(in1, in2[2]) + in2[2][3];
  700. };
  701. VectorTransform(&in1.x, in2, &out.x);
  702. };
  703.  
  704. studiohdr_t* pStudioModel = g_pModelInfo->GetStudiomodel(entity->GetModel());
  705. mstudiohitboxset_t* set = pStudioModel->GetHitboxSet(0);
  706. mstudiobbox_t *hitbox = set->GetHitbox(iHitbox);
  707.  
  708. std::vector<Vector> vecArray;
  709.  
  710. Vector max;
  711. Vector min;
  712. VectorTransform_Wrapper(hitbox->max, BoneMatrix[hitbox->bone], max);
  713. VectorTransform_Wrapper(hitbox->min, BoneMatrix[hitbox->bone], min);
  714.  
  715. auto center = (min + max) * 0.5f;
  716.  
  717. Vector CurrentAngles = g_Math.CalcAngle(center, local->GetEyePosition());
  718.  
  719. Vector Forward;
  720. g_Math.AngleVectors(CurrentAngles, &Forward);
  721.  
  722. Vector Right = Forward.Cross(Vector(0, 0, 1));
  723. Vector Left = Vector(-Right.x, -Right.y, Right.z);
  724.  
  725. Vector Top = Vector(0, 0, 1);
  726. Vector Bot = Vector(0, 0, -1);
  727.  
  728. switch (iHitbox) {
  729. case 0:
  730. for (auto i = 0; i < 4; ++i)
  731. {
  732. vecArray.emplace_back(center);
  733. }
  734. vecArray[1] += Top * (hitbox->radius * g_Menu.Config.HeadScale1);
  735. vecArray[2] += Right * (hitbox->radius * g_Menu.Config.HeadScale1);
  736. vecArray[3] += Left * (hitbox->radius * g_Menu.Config.HeadScale1);
  737. break;
  738.  
  739. default:
  740.  
  741. for (auto i = 0; i < 3; ++i)
  742. {
  743. vecArray.emplace_back(center);
  744. }
  745. vecArray[1] += Right * (hitbox->radius * g_Menu.Config.BodyScale1);
  746. vecArray[2] += Left * (hitbox->radius * g_Menu.Config.BodyScale1);
  747. break;
  748. }
  749. return vecArray;
  750. }
  751.  
  752. Vector CAimbot::full_multipoint(C_BaseEntity* entity)
  753. {
  754. C_BaseCombatWeapon *weapon = (C_BaseCombatWeapon*)g::pLocalEntity->GetActiveWeapon();
  755.  
  756. if (!g::pLocalEntity)
  757. return Vector(0, 0, 0);
  758.  
  759. Vector local_position = g::pLocalEntity->GetOrigin() + g::pLocalEntity->GetViewOffset();
  760.  
  761. Vector vector_best_point = Vector(0, 0, 0);
  762.  
  763. float damage_val;
  764.  
  765. if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SSG08)
  766. {
  767. damage_val = g_Menu.Config.MinDmgScout; //lol idk why, its pasted anyway so w/e
  768. }
  769. else if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SCAR20 || weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_G3SG1)
  770. {
  771. damage_val = g_Menu.Config.MinDmgAuto; //lol idk why, its pasted anyway so w/e
  772. }
  773. else
  774. {
  775. damage_val = g_Menu.Config.MinDmgOther; //lol idk why, its pasted anyway so w/e
  776. }
  777.  
  778. mostDamage = damage_val;
  779.  
  780. matrix3x4_t matrix[128];
  781.  
  782. if (!entity->SetupBones(matrix, 128, 256, 0))
  783. return Vector(0, 0, 0);
  784.  
  785. int hitboxes[] =
  786. {
  787. HITBOX_HEAD,
  788. HITBOX_NECK,
  789. HITBOX_PELVIS,
  790. HITBOX_BELLY,
  791. HITBOX_THORAX,
  792. HITBOX_UPPER_CHEST,
  793. HITBOX_RIGHT_CALF,
  794. HITBOX_LEFT_CALF,
  795. HITBOX_RIGHT_FOOT,
  796. HITBOX_LEFT_FOOT,
  797. HITBOX_RIGHT_HAND,
  798. HITBOX_LEFT_HAND,
  799. HITBOX_RIGHT_THIGH,
  800. HITBOX_LEFT_THIGH,
  801. };
  802.  
  803. for (int i = 0; i < ARRAYSIZE(hitboxes); i++)
  804. {
  805. for (auto point : GetMultiplePointsForHitbox(g::pLocalEntity, entity, hitboxes[i], matrix))
  806. {
  807. CGameTrace trace;
  808. int damage = g_AutoWall.CanHit(point);
  809.  
  810. if (damage > mostDamage)
  811. {
  812. bestHitbox = hitboxes[i];
  813. mostDamage = damage;
  814. vector_best_point = point;
  815.  
  816. if (mostDamage >= entity->GetHealth())
  817. return vector_best_point;
  818. }
  819.  
  820. }
  821. }
  822. return vector_best_point;
  823. }
  824.  
  825. Vector CAimbot::get_hitbox_pos(C_BaseEntity* entity, int hitbox_id)
  826. {
  827. auto getHitbox = [](C_BaseEntity* entity, int hitboxIndex) -> mstudiobbox_t*
  828. {
  829. if (entity->GetIsDormant() || entity->GetHealth() <= 0) return NULL;
  830.  
  831. const auto pModel = entity->GetModel();
  832. if (!pModel) return NULL;
  833.  
  834. auto pStudioHdr = g_pModelInfo->GetStudiomodel(pModel);
  835. if (!pStudioHdr) return NULL;
  836.  
  837. auto pSet = pStudioHdr->GetHitboxSet(0);
  838. if (!pSet) return NULL;
  839.  
  840. if (hitboxIndex >= pSet->numhitboxes || hitboxIndex < 0) return NULL;
  841.  
  842. return pSet->GetHitbox(hitboxIndex);
  843. };
  844.  
  845. auto hitbox = getHitbox(entity, hitbox_id);
  846. if (!hitbox) return Vector(0, 0, 0);
  847.  
  848. auto bone_matrix = entity->GetBoneMatrix(hitbox->bone);
  849.  
  850. Vector bbmin, bbmax;
  851. g_Math.VectorTransform(hitbox->min, bone_matrix, bbmin);
  852. g_Math.VectorTransform(hitbox->max, bone_matrix, bbmax);
  853.  
  854. return (bbmin + bbmax) * 0.5f;
  855. }
  856.  
  857. Vector CAimbot::full_point(C_BaseEntity* entity)
  858. {
  859. C_BaseCombatWeapon *weapon = (C_BaseCombatWeapon*)g::pLocalEntity->GetActiveWeapon();
  860.  
  861. if (!g::pLocalEntity)
  862. return Vector(0, 0, 0);
  863.  
  864. Vector local_position = g::pLocalEntity->GetOrigin() + g::pLocalEntity->GetViewOffset();
  865.  
  866. Vector vector_best_point = Vector(0, 0, 0);
  867.  
  868. int hitboxes[] =
  869. {
  870. HITBOX_HEAD,
  871. HITBOX_PELVIS,
  872. HITBOX_BELLY,
  873. HITBOX_THORAX,
  874. HITBOX_PELVIS,
  875. HITBOX_UPPER_CHEST,
  876. HITBOX_LEFT_FOOT,
  877. HITBOX_RIGHT_FOOT
  878. };
  879.  
  880. float damage_val;
  881.  
  882. if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SSG08)
  883. {
  884. damage_val = g_Menu.Config.MinDmgScout; //lol idk why, its pasted anyway so w/e
  885. }
  886. else if (weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_SCAR20 || weapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_G3SG1)
  887. {
  888. damage_val = g_Menu.Config.MinDmgAuto; //lol idk why, its pasted anyway so w/e
  889. }
  890. else
  891. {
  892. damage_val = g_Menu.Config.MinDmgOther; //lol idk why, its pasted anyway so w/e
  893. }
  894.  
  895. mostDamage = damage_val;
  896.  
  897. for (int i = 0; i < ARRAYSIZE(hitboxes); i++)
  898. {
  899. int damage = g_AutoWall.CanHit(entity->GetBonePosition(hitboxes[i]));
  900.  
  901. if (damage > mostDamage)
  902. {
  903. bestHitbox = hitboxes[i];
  904. mostDamage = damage;
  905. vector_best_point = get_hitbox_pos(entity, bestHitbox);
  906.  
  907. if (mostDamage >= entity->GetHealth())
  908. return vector_best_point;
  909. }
  910. }
  911.  
  912. return vector_best_point;
  913. }
  914.  
  915. CAimbot* aimbot = new CAimbot();*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement