Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.27 KB | None | 0 0
  1. #include "antiaim.h"
  2.  
  3. bool Settings::AntiAim::Yaw::enabled = false;
  4. bool Settings::AntiAim::Pitch::enabled = false;
  5. AntiAimType_Y Settings::AntiAim::Yaw::type = AntiAimType_Y::SPIN_FAST;
  6. AntiAimType_Y Settings::AntiAim::Yaw::typeFake = AntiAimType_Y::SPIN_FAST;
  7. bool Settings::AntiAim::Yaw::antiResolver = false;
  8. AntiAimType_X Settings::AntiAim::Pitch::type = AntiAimType_X::STATIC_DOWN;
  9. bool Settings::AntiAim::HeadEdge::enabled = false;
  10. float Settings::AntiAim::HeadEdge::distance = 25.0f;
  11. bool Settings::AntiAim::AutoDisable::noEnemy = false;
  12. bool Settings::AntiAim::AutoDisable::knifeHeld = false;
  13.  
  14. float Distance(Vector a, Vector b)
  15. {
  16. return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2) + pow(a.z - b.z, 2));
  17. }
  18.  
  19. bool AntiAim::GetBestHeadAngle(QAngle& angle)
  20. {
  21. C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
  22.  
  23. Vector position = localplayer->GetVecOrigin() + localplayer->GetVecViewOffset();
  24.  
  25. float closest_distance = 100.0f;
  26.  
  27. float radius = Settings::AntiAim::HeadEdge::distance + 0.1f;
  28. float step = M_PI * 2.0 / 8;
  29.  
  30. for (float a = 0; a < (M_PI * 2.0); a += step)
  31. {
  32. Vector location(radius * cos(a) + position.x, radius * sin(a) + position.y, position.z);
  33.  
  34. Ray_t ray;
  35. trace_t tr;
  36. ray.Init(position, location);
  37. CTraceFilter traceFilter;
  38. traceFilter.pSkip = localplayer;
  39. trace->TraceRay(ray, 0x4600400B, &traceFilter, &tr);
  40.  
  41. float distance = Distance(position, tr.endpos);
  42.  
  43. if (distance < closest_distance)
  44. {
  45. closest_distance = distance;
  46. angle.y = RAD2DEG(a);
  47. }
  48. }
  49.  
  50. return closest_distance < Settings::AntiAim::HeadEdge::distance;
  51. }
  52.  
  53. bool HasViableEnemy()
  54. {
  55. C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
  56.  
  57. for (int i = 1; i < engine->GetMaxClients(); ++i)
  58. {
  59. C_BasePlayer* entity = (C_BasePlayer*) entityList->GetClientEntity(i);
  60.  
  61. if (!entity
  62. || entity == localplayer
  63. || entity->GetDormant()
  64. || !entity->GetAlive()
  65. || entity->GetImmune())
  66. continue;
  67.  
  68. IEngineClient::player_info_t entityInformation;
  69. engine->GetPlayerInfo(i, &entityInformation);
  70.  
  71. if (std::find(Aimbot::friends.begin(), Aimbot::friends.end(), entityInformation.xuid) != Aimbot::friends.end())
  72. continue;
  73.  
  74. if (Settings::Aimbot::friendly || entity->GetTeam() != localplayer->GetTeam())
  75. return true;
  76. }
  77.  
  78. return false;
  79. }
  80.  
  81. void DoAntiAimY(QAngle& angle, int command_number, bool bFlip, bool& clamp)
  82. {
  83. AntiAimType_Y aa_type = bFlip ? Settings::AntiAim::Yaw::typeFake : Settings::AntiAim::Yaw::type;
  84.  
  85. static bool yFlip;
  86. float temp;
  87. double factor;
  88. static float trigger;
  89. QAngle temp_qangle;
  90.  
  91. if (bFlip)
  92. yFlip = !yFlip;
  93.  
  94. switch (aa_type)
  95. {
  96. case AntiAimType_Y::SPIN_FAST:
  97. factor = 360.0 / M_PHI;
  98. factor *= 25;
  99. angle.y = fmod(globalVars->curtime * factor, 360.0);
  100. break;
  101. case AntiAimType_Y::SPIN_SLOW:
  102. factor = 360.0 / M_PHI;
  103. angle.y = fmod(globalVars->curtime * factor, 360.0);
  104. break;
  105. case AntiAimType_Y::JITTER:
  106. yFlip ? angle.y -= 90.0f : angle.y -= 270.0f;
  107. break;
  108. case AntiAimType_Y::SIDE:
  109. yFlip ? angle.y += 90.f : angle.y -= 90.0f;
  110. break;
  111. case AntiAimType_Y::BACKWARDS:
  112. angle.y -= 180.0f;
  113. break;
  114. case AntiAimType_Y::BACKWARDSJITTER:
  115. yFlip ? angle.y -= 170.0f : angle.y -= 190.0f;
  116. break;
  117. case AntiAimType_Y::FORWARDS:
  118. angle.y -= 0.0f;
  119. break;
  120. case AntiAimType_Y::LEFT:
  121. angle.y += 90.0f;
  122. break;
  123. case AntiAimType_Y::RIGHT:
  124. angle.y -= 90.0f;
  125. break;
  126. case AntiAimType_Y::STATICAA:
  127. angle.y = 0.0f;
  128. break;
  129. case AntiAimType_Y::STATICJITTER:
  130. trigger += 15.0f;
  131. angle.y = trigger > 50.0f ? 150.0f : -150.0f;
  132.  
  133. if (trigger > 100.0f)
  134. trigger = 0.0f;
  135. break;
  136. case AntiAimType_Y::STATICSMALLJITTER:
  137. trigger += 15.0f;
  138. angle.y = trigger > 50.0f ? -30.0f : 30.0f;
  139.  
  140. if (trigger > 100.0f)
  141. trigger = 0.0f;
  142. break;
  143. case AntiAimType_Y::LISP:
  144. clamp = false;
  145. yFlip ? angle.y += 323210000.0f : angle.y -= 323210000.0f;
  146. break;
  147. case AntiAimType_Y::LISP_SIDE:
  148. clamp = false;
  149. temp = angle.y + 90.0f;
  150. temp_qangle = QAngle(0.0f, temp, 0.0f);
  151. Math::NormalizeAngles(temp_qangle);
  152. temp = temp_qangle.y;
  153.  
  154. if (temp > -45.0f)
  155. temp < 0.0f ? temp = -90.0f : temp < 45.0f ? temp = 90.0f : temp = temp;
  156.  
  157. temp += 1800000.0f;
  158. angle.y = temp;
  159. break;
  160. case AntiAimType_Y::LISP_JITTER:
  161. clamp = false;
  162. static int jittertimer = -1;
  163. temp = angle.y - 155.0f;
  164.  
  165. if (jittertimer == 1)
  166. {
  167. temp = angle.y + 58.0f;
  168. temp += 1800000.0f;
  169. }
  170.  
  171. if (bSendPacket)
  172. {
  173. if (jittertimer >= 1)
  174. jittertimer = -1;
  175. jittertimer++;
  176. }
  177. angle.y = temp;
  178. break;
  179. case AntiAimType_Y::ANGEL_BACKWARD:
  180. clamp = false;
  181. angle.y += 36000180.0f;
  182. break;
  183. case AntiAimType_Y::ANGEL_INVERSE:
  184. clamp = false;
  185. angle.y = 36000180.0f;
  186. break;
  187. case AntiAimType_Y::ANGEL_SPIN:
  188. clamp = false;
  189. factor = (globalVars->curtime * 5000.0f);
  190. angle.y = factor + 36000000.0f;
  191. break;
  192. default:
  193. angle.y -= 0.0f;
  194. break;
  195. }
  196. }
  197.  
  198. void DoAntiAimX(QAngle& angle, bool bFlip, bool& clamp)
  199. {
  200. static float pDance = 0.0f;
  201. AntiAimType_X aa_type = Settings::AntiAim::Pitch::type;
  202.  
  203. switch (aa_type)
  204. {
  205. case AntiAimType_X::STATIC_UP:
  206. angle.x = -89.0f;
  207. break;
  208. case AntiAimType_X::STATIC_DOWN:
  209. angle.x = 89.0f;
  210. break;
  211. case AntiAimType_X::DANCE:
  212. pDance += 45.0f;
  213. if (pDance > 100)
  214. pDance = 0.0f;
  215. else if (pDance > 75.f)
  216. angle.x = -89.f;
  217. else if (pDance < 75.f)
  218. angle.x = 89.f;
  219. break;
  220. case AntiAimType_X::FRONT:
  221. angle.x = 0.0f;
  222. break;
  223. case AntiAimType_X::STATIC_UP_FAKE:
  224. angle.x = bFlip ? 89.0f : -89.0f;
  225. break;
  226. case AntiAimType_X::STATIC_DOWN_FAKE:
  227. angle.x = bFlip ? -89.0f : 89.0f;
  228. break;
  229. case AntiAimType_X::LISP_DOWN:
  230. clamp = false;
  231. angle.x = 1800089.0f;
  232. break;
  233. case AntiAimType_X::ANGEL_DOWN:
  234. clamp = false;
  235. angle.x = 36000088.0f;
  236. break;
  237. case AntiAimType_X::ANGEL_UP:
  238. clamp = false;
  239. angle.x = 35999912.0f;
  240. break;
  241. default:
  242. angle.x -= 0.0f;
  243. break;
  244. }
  245. }
  246.  
  247. void AntiAim::CreateMove(CUserCmd* cmd)
  248. {
  249. if (!Settings::AntiAim::Yaw::enabled && !Settings::AntiAim::Pitch::enabled)
  250. return;
  251.  
  252. if (Settings::Aimbot::AimStep::enabled && Aimbot::aimStepInProgress)
  253. return;
  254.  
  255. QAngle oldAngle = cmd->viewangles;
  256. float oldForward = cmd->forwardmove;
  257. float oldSideMove = cmd->sidemove;
  258.  
  259. QAngle angle = cmd->viewangles;
  260.  
  261. C_BasePlayer* localplayer = (C_BasePlayer*) entityList->GetClientEntity(engine->GetLocalPlayer());
  262. if (!localplayer)
  263. return;
  264.  
  265. C_BaseCombatWeapon* activeWeapon = (C_BaseCombatWeapon*) entityList->GetClientEntityFromHandle(localplayer->GetActiveWeapon());
  266. if (!activeWeapon)
  267. return;
  268.  
  269. if (activeWeapon->GetCSWpnData()->GetWeaponType() == CSWeaponType::WEAPONTYPE_GRENADE)
  270. {
  271. C_BaseCSGrenade* csGrenade = (C_BaseCSGrenade*) activeWeapon;
  272.  
  273. if (csGrenade->GetThrowTime() > 0.f)
  274. return;
  275. }
  276.  
  277. if (cmd->buttons & IN_USE || cmd->buttons & IN_ATTACK || (cmd->buttons & IN_ATTACK2 && *activeWeapon->GetItemDefinitionIndex() == ItemDefinitionIndex::WEAPON_REVOLVER))
  278. return;
  279.  
  280. if (localplayer->GetMoveType() == MOVETYPE_LADDER || localplayer->GetMoveType() == MOVETYPE_NOCLIP)
  281. return;
  282.  
  283. // AutoDisable checks
  284.  
  285. // Knife
  286. if (Settings::AntiAim::AutoDisable::knifeHeld && localplayer->GetAlive() && activeWeapon->GetCSWpnData()->GetWeaponType() == CSWeaponType::WEAPONTYPE_KNIFE)
  287. return;
  288.  
  289. if (Settings::AntiAim::AutoDisable::noEnemy && localplayer->GetAlive() && !HasViableEnemy())
  290. return;
  291.  
  292. QAngle edge_angle = angle;
  293. bool edging_head = Settings::AntiAim::HeadEdge::enabled && GetBestHeadAngle(edge_angle);
  294.  
  295. static bool bFlip;
  296.  
  297. bFlip = !bFlip;
  298.  
  299. bool should_clamp = true;
  300.  
  301. if (!ValveDSCheck::forceUT && (*csGameRules) && (*csGameRules)->IsValveDS())
  302. {
  303. if (Settings::AntiAim::Yaw::type >= AntiAimType_Y::LISP)
  304. Settings::AntiAim::Yaw::type = AntiAimType_Y::SPIN_SLOW;
  305.  
  306. if (Settings::AntiAim::Yaw::typeFake >= AntiAimType_Y::LISP)
  307. Settings::AntiAim::Yaw::typeFake = AntiAimType_Y::SPIN_SLOW;
  308.  
  309. if (Settings::AntiAim::Pitch::type >= AntiAimType_X::STATIC_UP_FAKE)
  310. Settings::AntiAim::Pitch::type = AntiAimType_X::STATIC_UP;
  311. }
  312.  
  313. if (Settings::AntiAim::Yaw::enabled)
  314. {
  315. DoAntiAimY(angle, cmd->command_number, bFlip, should_clamp);
  316. Math::NormalizeAngles(angle);
  317. if (!Settings::FakeLag::enabled)
  318. CreateMove::sendPacket = bFlip;
  319. if (Settings::AntiAim::HeadEdge::enabled && edging_head && !bFlip)
  320. angle.y = edge_angle.y;
  321. }
  322.  
  323. if (Settings::AntiAim::Pitch::enabled)
  324. DoAntiAimX(angle, bFlip, should_clamp);
  325.  
  326. if (should_clamp)
  327. {
  328. Math::NormalizeAngles(angle);
  329. Math::ClampAngles(angle);
  330. }
  331.  
  332. cmd->viewangles = angle;
  333.  
  334. if (Settings::AntiAim::Yaw::antiResolver)
  335. {
  336. static bool antiResolverFlip = false;
  337. if (cmd->viewangles.y == *localplayer->GetLowerBodyYawTarget())
  338. {
  339. if (antiResolverFlip)
  340. cmd->viewangles.y += 60.f;
  341. else
  342. cmd->viewangles.y -= 60.f;
  343.  
  344. antiResolverFlip = !antiResolverFlip;
  345.  
  346. if (should_clamp)
  347. {
  348. Math::NormalizeAngles(cmd->viewangles);
  349. Math::ClampAngles(cmd->viewangles);
  350. }
  351. }
  352. }
  353.  
  354. Math::CorrectMovement(oldAngle, cmd, oldForward, oldSideMove);
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement