Advertisement
Guest User

DesyncAA

a guest
Mar 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.46 KB | None | 0 0
  1. ----------------------------------------
  2. ----------- Update log -----------
  3. ----------------------------------------
  4. -- Update (20 Mar, 2019)
  5. -- Improved freestanding for "No fake" anti-aim mode
  6.  
  7. -- Update (19 Mar, 2019)
  8. -- Freestanding is now a separate option and works with all anti-aim modes (still requires Vector3.lua)
  9. -- Now using one key to switch sides instead of two (put hotkey style to "Toggle" to make manual anti-aim work properly)
  10. -- Implemented "Static body yaw" to work with "Static" and "Jitter" anti-aim modes (all credits go to abbie)
  11. -- Code improvements
  12.  
  13. -- Update (16 Mar, 2019)
  14. -- Removed "Experimental" anti-aim style
  15. -- Added "No fake" anti-aim style
  16. -- Added "Freestanding" anti-aim style, based on "Static" anti-aim style (requires Vector3.lua - all credits go to Horse)
  17.  
  18. -- Update (13 Mar, 2019)
  19. -- Changed behavior of "Experimental" anti-aim style (now works similar to Jitter)
  20. -- Changed combobox to multiselect for indicators (they now show your fake for both anti-aim styles)
  21.  
  22. -- Recode (04 Mar, 2019)
  23. -- Added "Experimental" anti-aim style (most useful with scout)
  24. -- Removed two features: "On shot anti-aim fix", "Reposition indicators"
  25. -- Now using two different hotkeys to change sides of the anti-aim (if you want to use one key for both sides, set the first hotkey type to "On hotkey" and the second one to "Toggle")
  26. -- Indicators for "Static" anti-aim style show your fake angle; indicators for "Experimental" anti-aim style show your real angle
  27.  
  28. -- Update (01 Mar, 2019)
  29. -- No longer using edge yaw in anti-aim list
  30. -- You are able to use "fake duck" by default, but enabling "on shot anti-aim" and "on shot fix" will cause automatic deactivation of this feature
  31.  
  32. -- Credits: Horse, abbie, italian, duk
  33. ----------------------------------------
  34. ----------------------------------------
  35. ----------------------------------------
  36.  
  37. require "Vector3"
  38.  
  39. -- Local variables
  40. local client, ui, client_set_event_callback, client_get_cvar, client_draw_indicator, client_draw_text, client_screensize = client, ui, client.set_event_callback, client.get_cvar, client.draw_indicator, client.draw_text, client.screen_size
  41. local ui_get, ui_set, ui_set_visible, ui_ref = ui.get, ui.set, ui.set_visible, ui.reference
  42. local entity_get_local_player, entity_get_prop, entity_is_alive = entity.get_local_player, entity.get_prop, entity.is_alive
  43. enemyclosesttocrosshair = nil
  44. lowestfov = math.huge
  45. lowestdmg = math.huge
  46.  
  47. -- Anti-aim references
  48. local pitch = ui_ref("AA", "Anti-aimbot angles", "Pitch")
  49. local base = ui_ref("AA", "Anti-aimbot angles", "Yaw base")
  50. local yaw, yaw_slider = ui_ref("AA", "Anti-aimbot angles", "Yaw")
  51. local yawjitter, yawjitter_slider = ui_ref("AA", "Anti-aimbot angles", "Yaw jitter")
  52. local bodyyaw, bodyyaw_slider = ui_ref("AA", "Anti-aimbot angles", "Body yaw")
  53. local limit = ui_ref("AA", "Anti-aimbot angles", "Fake yaw limit")
  54. local edgeyaw = ui_ref("AA", "Anti-aimbot angles", "Edge yaw")
  55. local freestanding = ui_ref("AA", "Anti-aimbot angles", "Freestanding")
  56. local twist = ui_ref("AA", "Anti-aimbot angles", "Twist")
  57. local lby = ui_ref("AA", "Anti-aimbot angles", "Lower body yaw")
  58.  
  59. -- New UI elements
  60. local desync = ui.new_checkbox("AA", "Other", "Desync anti-aim")
  61. local color = ui.new_color_picker("AA", "Other", "Arrow color", 124, 195, 13, 220)
  62. local desyncstyle = ui.new_combobox("AA", "Other", "Desync mode", "Off", "Static", "Jitter", "No fake")
  63. local desynckey = ui.new_hotkey("AA", "Other", "Switch key")
  64. local indmulti = ui.new_multiselect("AA", "Other", "Anti-aim angle indicator", "Text", "Arrows")
  65. local autod = ui.new_checkbox("AA", "Other", "Freestanding")
  66. ui_set_visible(desynckey, false)
  67. ui_set_visible(indmulti, false)
  68. ui_set(yaw, "180")
  69. -- End of local variables
  70.  
  71. -----------------------------------
  72. ---- Freestanding calculations ----
  73. -----------------------------------
  74. function Angle_Vector(angle_x, angle_y)
  75. sp, sy, cp, cy = nil
  76. sy = math.sin(math.rad(angle_y));
  77. cy = math.cos(math.rad(angle_y));
  78. sp = math.sin(math.rad(angle_x));
  79. cp = math.cos(math.rad(angle_x));
  80. return cp * cy, cp * sy, -sp;
  81. end
  82.  
  83. function EnemyToCrosshair(index)
  84. fov = get_FOV(Vector3(client.camera_angles()), Vector3(client.eye_position()), Vector3(entity.hitbox_position(index, 0)))
  85. if(fov < lowestfov) then
  86. lowestfov = fov
  87. enemyclosesttocrosshair = index
  88. end
  89. end
  90.  
  91. function CalcAngle(localplayerxpos, localplayerypos, enemyxpos, enemyypos)
  92. relativeyaw = math.atan( (localplayerypos - enemyypos) / (localplayerxpos - enemyxpos) )
  93. return relativeyaw * 180 / math.pi
  94. end
  95.  
  96. function calculateBestAngle(enemy, ...)
  97. lx, ly, lz = entity_get_prop(entity_get_local_player(), "m_vecOrigin")
  98. viewangle_x, viewangle_y, roll = client.camera_angles()
  99. headx, heady, headz = entity.hitbox_position(entity_get_local_player(), 0)
  100. enemyx, enemyy, enemyz = entity_get_prop(enemy, "m_vecOrigin")
  101. mypos = Vector3(client.eye_position())
  102. bestangle = nil
  103.  
  104. if(entity.is_alive(enemy)) then
  105. yaw = CalcAngle(lx, ly, enemyx, enemyy)
  106. for i,v in pairs({...}) do
  107.  
  108. dir_x, dir_y, dir_z = Angle_Vector(0, (yaw + v))
  109. end_x = lx + dir_x * 55
  110. end_y = ly + dir_y * 55
  111. end_z = lz + 80
  112.  
  113. index, damage = client.trace_bullet(enemy, enemyx, enemyy, enemyz + 70, end_x, end_y, end_z)
  114.  
  115. index2, damage2 = client.trace_bullet(enemy, enemyx, enemyy, enemyz + 70, end_x + 12, end_y, end_z)
  116.  
  117. index3, damage3 = client.trace_bullet(enemy, enemyx, enemyy, enemyz + 70, end_x - 12, end_y, end_z)
  118.  
  119. if(damage < lowestdmg) then
  120. lowestdmg = damage
  121. if(damage2 > damage) then
  122. lowestdmg = damage2
  123. end
  124. if(damage3 > damage) then
  125. lowestdamage = damage3
  126. end
  127. if(lx - enemyx > 0) then
  128. bestangle = v
  129. else
  130. bestangle = v * -1
  131. end
  132. else if(damage == lowestdmg) then
  133. return 0
  134. end
  135. end
  136. end
  137. end
  138.  
  139. return bestangle
  140. end
  141. -----------------------------------
  142. -----------------------------------
  143.  
  144. -- UI elements on "Static" or "No fake" or "Jitter"
  145. local function combo()
  146. local enabled = ui_get(desync) and ui_get(desyncstyle) == "Static" or ui_get(desync) and ui_get(desyncstyle) == "No fake" or ui_get(desync) and ui_get(desyncstyle) == "Jitter"
  147. ui_set_visible(desynckey, enabled)
  148. ui_set_visible(indmulti, enabled)
  149. ui_set_visible(color, enabled)
  150. if ui_get(desyncstyle) == "Off" then
  151. ui_set(indmulti, "-")
  152. end
  153. end
  154. ui.set_callback(desyncstyle, combo)
  155.  
  156. -- Multiselect table
  157. local function contains(table, val)
  158. for i=1, #table do
  159. if table[i] == val then
  160. return true
  161. end
  162. end
  163. return false
  164. end
  165.  
  166. -- Manual anti-aims
  167. client_set_event_callback("paint", function()
  168. if not ui_get(desync) or ui_get(desyncstyle) == "Off" or entity_get_local_player() == nil or not entity_is_alive(entity_get_local_player()) then
  169. return
  170. end
  171.  
  172. local value = ui_get(indmulti)
  173. if #value == 0 then
  174. return
  175. end
  176.  
  177. local scrsize_x, scrsize_y = client_screensize()
  178. local center_x, center_y = scrsize_x / 2, scrsize_y / 2
  179. local ind_r, ind_g, ind_b, ind_a = ui_get(color)
  180.  
  181. if ui_get(desyncstyle) == "Static" then
  182. if ui_get(desynckey) then
  183. ui_set(pitch, "Minimal")
  184. ui_set(base, "Local view")
  185. ui_set(yaw_slider, "-30")
  186. ui_set(yawjitter, "Offset")
  187. ui_set(yawjitter_slider, "0")
  188. ui_set(bodyyaw, "Static")
  189. ui_set(bodyyaw_slider, "-180")
  190. ui_set(limit, "60")
  191. ui_set(edgeyaw, "Off")
  192. ui_set(freestanding, "-")
  193. ui_set(twist, true)
  194. ui_set(lby, false)
  195. if contains(value, "Text") then
  196. client_draw_indicator(ctx, 124, 195, 13, 237, "LEFT")
  197. end
  198. if contains(value, "Arrows") then
  199. client_draw_text(c, center_x - 40, center_y, ind_r, ind_g, ind_b, ind_a, "c+", 0, "◄")
  200. client_draw_text(c, center_x + 40, center_y, 255, 255, 255, 220, "c+", 0, "►")
  201. end
  202. else
  203. ui_set(pitch, "Minimal")
  204. ui_set(base, "Local view")
  205. ui_set(yaw_slider, "8")
  206. ui_set(yawjitter, "Offset")
  207. ui_set(yawjitter_slider, "0")
  208. ui_set(bodyyaw, "Static")
  209. ui_set(bodyyaw_slider, "180")
  210. ui_set(limit, "60")
  211. ui_set(edgeyaw, "Off")
  212. ui_set(freestanding, "-")
  213. ui_set(twist, true)
  214. ui_set(lby, false)
  215. if contains(value, "Text") then
  216. client_draw_indicator(ctx, 124, 195, 13, 237, "RIGHT")
  217. end
  218. if contains(value, "Arrows") then
  219. client_draw_text(c, center_x + 40, center_y, ind_r, ind_g, ind_b, ind_a, "c+", 0, "►")
  220. client_draw_text(c, center_x - 40, center_y, 255, 255, 255, 220, "c+", 0, "◄")
  221. end
  222. end
  223. end
  224. if ui_get(desyncstyle) == "Jitter" then
  225. if ui_get(desynckey) then
  226. ui_set(pitch, "Minimal")
  227. ui_set(base, "Local view")
  228. ui_set(yaw_slider, "-33")
  229. ui_set(yawjitter, "Center")
  230. ui_set(yawjitter_slider, "3")
  231. ui_set(bodyyaw, "Static")
  232. ui_set(bodyyaw_slider, "-180")
  233. ui_set(limit, "60")
  234. ui_set(edgeyaw, "Off")
  235. ui_set(freestanding, "-")
  236. ui_set(twist, true)
  237. ui_set(lby, false)
  238. if contains(value, "Text") then
  239. client_draw_indicator(ctx, 124, 195, 13, 237, "LEFT")
  240. end
  241. if contains(value, "Arrows") then
  242. client_draw_text(c, center_x - 40, center_y, ind_r, ind_g, ind_b, ind_a, "c+", 0, "◄")
  243. client_draw_text(c, center_x + 40, center_y, 255, 255, 255, 220, "c+", 0, "►")
  244. end
  245. else
  246. ui_set(pitch, "Minimal")
  247. ui_set(base, "Local view")
  248. ui_set(yaw_slider, "8")
  249. ui_set(yawjitter, "Center")
  250. ui_set(yawjitter_slider, "-3")
  251. ui_set(bodyyaw, "Static")
  252. ui_set(bodyyaw_slider, "180")
  253. ui_set(limit, "60")
  254. ui_set(edgeyaw, "Off")
  255. ui_set(freestanding, "-")
  256. ui_set(twist, true)
  257. ui_set(lby, false)
  258. if contains(value, "Text") then
  259. client_draw_indicator(ctx, 124, 195, 13, 237, "RIGHT")
  260. end
  261. if contains(value, "Arrows") then
  262. client_draw_text(c, center_x + 40, center_y, ind_r, ind_g, ind_b, ind_a, "c+", 0, "►")
  263. client_draw_text(c, center_x - 40, center_y, 255, 255, 255, 220, "c+", 0, "◄")
  264. end
  265. end
  266. end
  267. if ui_get(desyncstyle) == "No fake" then
  268. if ui_get(desynckey) then
  269. ui_set(pitch, "Minimal")
  270. ui_set(base, "Local view")
  271. ui_set(yaw_slider, "-90")
  272. ui_set(yawjitter, "Off")
  273. ui_set(bodyyaw, "Off")
  274. ui_set(edgeyaw, "Off")
  275. ui_set(freestanding, "-")
  276. ui_set(twist, false)
  277. ui_set(lby, false)
  278. if contains(value, "Text") then
  279. client_draw_indicator(ctx, 124, 195, 13, 237, "LEFT")
  280. end
  281. if contains(value, "Arrows") then
  282. client_draw_text(c, center_x - 40, center_y, ind_r, ind_g, ind_b, ind_a, "c+", 0, "◄")
  283. client_draw_text(c, center_x + 40, center_y, 255, 255, 255, 220, "c+", 0, "►")
  284. end
  285. else
  286. ui_set(pitch, "Minimal")
  287. ui_set(base, "Local view")
  288. ui_set(yaw_slider, "90")
  289. ui_set(yawjitter, "Off")
  290. ui_set(bodyyaw, "Off")
  291. ui_set(edgeyaw, "Off")
  292. ui_set(freestanding, "-")
  293. ui_set(twist, false)
  294. ui_set(lby, false)
  295. if contains(value, "Text") then
  296. client_draw_indicator(ctx, 124, 195, 13, 237, "RIGHT")
  297. end
  298. if contains(value, "Arrows") then
  299. client_draw_text(c, center_x + 40, center_y, ind_r, ind_g, ind_b, ind_a, "c+", 0, "►")
  300. client_draw_text(c, center_x - 40, center_y, 255, 255, 255, 220, "c+", 0, "◄")
  301. end
  302. end
  303. end
  304. end)
  305.  
  306. -- Freestanding anti-aims
  307. client_set_event_callback("run_command", function()
  308. if not ui_get(desync) or ui_get(desyncstyle) == "Off" or entity_get_local_player() == nil or not entity_is_alive(entity_get_local_player()) then
  309. return
  310. end
  311.  
  312. for i,v in pairs(entity.get_players(true)) do
  313. EnemyToCrosshair(v)
  314. end
  315.  
  316. if ui_get(autod) then
  317. ui_set(indmulti, "-")
  318. ui_set_visible(desynckey, false)
  319. ui_set_visible(indmulti, false)
  320. ui_set_visible(color, false)
  321. if ui_get(desyncstyle) == "Static" then
  322. if (enemyclosesttocrosshair ~= nil) then
  323. yaw = calculateBestAngle(enemyclosesttocrosshair, -90, 90)
  324. if (yaw == -90) then
  325. ui_set(pitch, "Minimal")
  326. ui_set(base, "Local view")
  327. ui_set(yaw_slider, "8")
  328. ui_set(yawjitter, "Offset")
  329. ui_set(yawjitter_slider, "0")
  330. ui_set(bodyyaw, "Static")
  331. ui_set(bodyyaw_slider, "180")
  332. ui_set(limit, "60")
  333. ui_set(edgeyaw, "Off")
  334. ui_set(freestanding, "-")
  335. ui_set(twist, true)
  336. ui_set(lby, false)
  337. else if (yaw == 90) then
  338. ui_set(pitch, "Minimal")
  339. ui_set(base, "Local view")
  340. ui_set(yaw_slider, "-33")
  341. ui_set(yawjitter, "Offset")
  342. ui_set(yawjitter_slider, "0")
  343. ui_set(bodyyaw, "Static")
  344. ui_set(bodyyaw_slider, "-180")
  345. ui_set(limit, "60")
  346. ui_set(edgeyaw, "Off")
  347. ui_set(freestanding, "-")
  348. ui_set(twist, true)
  349. ui_set(lby, false)
  350. end
  351. end
  352. end
  353. end
  354. if ui_get(desyncstyle) == "Jitter" then
  355. if (enemyclosesttocrosshair ~= nil) then
  356. yaw = calculateBestAngle(enemyclosesttocrosshair, -90, 90)
  357. if (yaw == -90) then
  358. ui_set(pitch, "Minimal")
  359. ui_set(base, "Local view")
  360. ui_set(yaw_slider, "8")
  361. ui_set(yawjitter, "Center")
  362. ui_set(yawjitter_slider, "-3")
  363. ui_set(bodyyaw, "Static")
  364. ui_set(bodyyaw_slider, "180")
  365. ui_set(limit, "60")
  366. ui_set(edgeyaw, "Off")
  367. ui_set(freestanding, "-")
  368. ui_set(twist, true)
  369. ui_set(lby, false)
  370. else if (yaw == 90) then
  371. ui_set(pitch, "Minimal")
  372. ui_set(base, "Local view")
  373. ui_set(yaw_slider, "-47")
  374. ui_set(yawjitter, "Center")
  375. ui_set(yawjitter_slider, "3")
  376. ui_set(bodyyaw, "Static")
  377. ui_set(bodyyaw_slider, "-180")
  378. ui_set(limit, "60")
  379. ui_set(edgeyaw, "Off")
  380. ui_set(freestanding, "-")
  381. ui_set(twist, true)
  382. ui_set(lby, false)
  383. end
  384. end
  385. end
  386. end
  387. if ui_get(desyncstyle) == "No fake" then
  388. if (enemyclosesttocrosshair ~= nil) then
  389. yaw = calculateBestAngle(enemyclosesttocrosshair, -90, 90)
  390. if (yaw == -90) then
  391. ui_set(pitch, "Minimal")
  392. ui_set(base, "Local view")
  393. ui_set(yaw_slider, "-90")
  394. ui_set(yawjitter, "Off")
  395. ui_set(bodyyaw, "Off")
  396. ui_set(edgeyaw, "Off")
  397. ui_set(freestanding, "-")
  398. ui_set(twist, false)
  399. ui_set(lby, false)
  400. else if (yaw == 90) then
  401. ui_set(pitch, "Minimal")
  402. ui_set(base, "Local view")
  403. ui_set(yaw_slider, "90")
  404. ui_set(yawjitter, "Off")
  405. ui_set(bodyyaw, "Off")
  406. ui_set(edgeyaw, "Off")
  407. ui_set(freestanding, "-")
  408. ui_set(twist, false)
  409. ui_set(lby, false)
  410. else if not (yaw == 90) and not (yaw == -90) then
  411. ui_set(pitch, "Minimal")
  412. ui_set(base, "Local view")
  413. ui_set(yaw_slider, "0")
  414. ui_set(yawjitter, "Off")
  415. ui_set(bodyyaw, "Off")
  416. ui_set(edgeyaw, "Off")
  417. ui_set(freestanding, "-")
  418. ui_set(twist, false)
  419. ui_set(lby, false)
  420. end
  421. end
  422. end
  423. end
  424. end
  425. else
  426. ui_set_visible(desynckey, true)
  427. ui_set_visible(indmulti, true)
  428. ui_set_visible(color, true)
  429. end
  430. lowestfov = 999
  431. lowestdmg = 999
  432. end)
  433.  
  434. -- Static body yaw
  435. client_set_event_callback("setup_command", function(cmd)
  436. if not ui_get(desync) or ui_get(desyncstyle) == "Off" or ui_get(desyncstyle) == "No fake" or entity_get_local_player() == nil or not entity_is_alive(entity_get_local_player()) then
  437. return
  438. end
  439. if cmd.in_jump ~= 0 then return end
  440. local sm = cmd.in_duck ~= 0 and 2.941177 or 1.000001
  441. sm = cmd.command_number % 4 < 2 and -sm or sm
  442. cmd.sidemove = cmd.sidemove ~= 0 and cmd.sidemove or sm
  443. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement