Advertisement
Guest User

desync

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