· 6 years ago · Oct 27, 2019, 04:54 AM
1---
2--- Title: Crimsync
3--- Author: april#0001
4--- Description: Recreates onetap's anti-aimbot system, originally made by Salvatore#0850
5---
6
7--region main
8local main_c = {}
9local main_mt = {__index = main_c}
10
11--- Instantiate a main object.
12--- @return table
13function main_c.new()
14 local properties = {
15 menu = true,
16
17 modes = {"Desync", "Twist", "Anti-balance adjust"},
18
19 manual_antiaiming = false,
20 inverted = false
21 }
22
23 return properties
24end
25
26-- Create our main class
27local main = main_c.new()
28--endregion
29
30--region Menu
31
32-- Create menu elements
33local window = gui.Window("crimsync", "Crimsync settings", 1000, 500, 1015, 350)
34local standing = gui.Groupbox(window, "Standing", 15, 15, 235, 285)
35local running = gui.Groupbox(window, "Running", 265, 15, 235, 285)
36local slowwalk = gui.Groupbox(window, "Slow-walking", 515, 15, 235, 285)
37local manualaa = gui.Groupbox(window, "Manual anti-aiming", 765, 15, 235, 285)
38
39local static_vars = gui.Groupbox(window, "static_vars", 0, 1020, 0, 0)
40
41local body_lean = {
42 [1] = gui.Slider(standing, "standing_lean", "Body lean", 55, 0, 100),
43 [2] = gui.Slider(running, "running_lean", "Body lean", 55, 0, 100),
44 [3] = gui.Slider(slowwalk, "slowwalk_lean", "Body lean", 55, 0, 100),
45 [4] = gui.Slider(manualaa, "manual_lean", "Body lean", 55, 0, 100)
46}
47
48local inverted_body_lean = {
49 [1] = gui.Slider(standing, "standing_lean_inv", "Inverted body lean", 55, 0, 100),
50 [2] = gui.Slider(running, "running_lean_inv", "Inverted body lean", 55, 0, 100),
51 [3] = gui.Slider(slowwalk, "slowwalk_lean_inv", "Inverted body lean", 55, 0, 100),
52 [4] = gui.Slider(manualaa, "manual_lean_inv", "Inverted body lean", 55, 0, 100)
53}
54
55local desync_boxes = {
56 [1] = gui.Multibox(standing, "Crooked modes"),
57 [2] = gui.Multibox(running, "Crooked modes"),
58 [3] = gui.Multibox(slowwalk, "Crooked modes"),
59 [4] = gui.Multibox(manualaa, "Crooked modes")
60}
61
62local choke_limit = {
63 [1] = gui.Slider(standing, "standing_choke", "Choke limit", 1, 1, 4),
64 [2] = gui.Slider(running, "running_choke", "Choke limit", 15, 1, 16),
65 [3] = gui.Slider(slowwalk, "slowwalk_choke", "Choke limit", 10, 1, 16)
66}
67
68local manual_hotkeys = {
69 [1] = gui.Keybox( manualaa, "manual_left", "Override left", 0x5A ),
70 [2] = gui.Keybox( manualaa, "manual_right", "Override right", 0x43 ),
71 [3] = gui.Keybox( manualaa, "manual_back", "Override back", 0x58 ),
72 [4] = gui.Keybox( manualaa, "manual_inv", "Invert", 0x56 )
73}
74
75local desync_modes = {
76 [1] = {
77 [1] = gui.Checkbox(desync_boxes[1], "standing_desync", "Desync", 0),
78 [2] = gui.Checkbox(desync_boxes[1], "standing_twist", "Twist", 0),
79 --[3] = gui.Checkbox(desync_boxes[1], "standing_anti", "Anti-balance adjust", 0)
80 },
81
82 [2] = {
83 [1] = gui.Checkbox(desync_boxes[2], "running_desync", "Desync", 0),
84 [2] = gui.Checkbox(desync_boxes[2], "running_twist", "Twist", 0)
85 },
86
87 [3] = {
88 [1] = gui.Checkbox(desync_boxes[3], "slowwalk_desync", "Desync", 0),
89 [2] = gui.Checkbox(desync_boxes[3], "slowwalk_twist", "Twist", 0)
90 },
91
92 [4] = {
93 [1] = gui.Checkbox(desync_boxes[4], "manual_desync", "Desync", 0),
94 [2] = gui.Checkbox(desync_boxes[4], "manual_twist", "Twist", 0)
95 }
96}
97
98
99--endregion
100
101--region Functions
102
103--region Locals
104
105--- Calculates the local_player velocity
106--- @return number
107local function velocity()
108
109 local local_player = entities.GetLocalPlayer()
110
111 local x, y, z = local_player:GetPropVector("localdata", "m_vecVelocity[0]")
112
113 return math.sqrt(x*x + y*y)
114
115end
116
117--- Checks if a UI element exists
118--- @param var
119--- @param complement
120local function get_value(var, complement)
121
122 if gui.GetValue( var .. complement ) ~= nil then
123 return var .. complement
124 end
125
126 return nil
127
128end
129
130--- Renders a triangle
131--- @param x
132--- @param y
133--- @param size
134--- @param narrowness
135local function custom_triangle(x, y, size, narrowness, dir)
136
137 for i=0, size do
138
139 if dir == 1 then -- left
140
141 draw.Color(2, 2, 2, 155)
142 draw.Line(x + i + 1 - size / 2, y - i / narrowness + 1, x + i + 1 - size / 2, y + i / narrowness + 1)
143 draw.Color(255, 255, 255, 155)
144 draw.Line(x + i - size / 2, y - i / narrowness, x + i - size / 2, y + i / narrowness)
145
146 elseif dir == 2 then -- right
147
148 draw.Color(2, 2, 2, 155)
149 draw.Line(x - i - 1 + size / 2, y - i / narrowness + 1, x - i - 1 + size / 2, y + i / narrowness + 1)
150 draw.Color(255, 255, 255, 155)
151 draw.Line(x - i + size / 2, y - i / narrowness, x - i + size / 2, y + i / narrowness)
152
153 elseif dir == 3 then -- down
154
155 draw.Color(2, 2, 2, 155)
156 draw.Line(x + i / narrowness + 1, y - i - 1, x - i / narrowness + 1, y - i - 1)
157 draw.Color(255, 255, 255, 155)
158 draw.Line(x + i / narrowness, y - i, x - i / narrowness, y - i)
159
160 elseif dir == 4 then -- up
161
162 draw.Color(2, 2, 2, 155)
163 draw.Line(x + i / narrowness + 1, y + i - 1, x - i / narrowness + 1, y + i - 1)
164 draw.Color(255, 255, 255, 155)
165 draw.Line(x + i / narrowness, y + i, x - i / narrowness, y + i)
166
167 end
168
169 end
170
171end
172--endregion
173
174--- Updates the antiaim type
175--- @return string
176function main.update_state()
177
178 local local_player = entities.GetLocalPlayer()
179
180 if not local_player or not local_player:IsAlive() then
181 return
182 end
183
184 local vel = velocity()
185
186 if main.manual_antiaiming then
187 return "manual"
188 end
189
190 if gui.GetValue( "msc_slowwalk" ) ~= 0 and input.IsButtonDown( gui.GetValue( "msc_slowwalk" ) ) then
191 return "slowwalk"
192 end
193
194 if vel > 0.01 then
195 return "running"
196 end
197
198 return "standing"
199
200end
201
202
203local states = {left = false, right = false, back = false, inv = false}
204local m_state = gui.Slider(static_vars, "m_state", "m_state", 0, 0, 3)
205
206--- Handles the input system for the manual anti-aim binds
207function main.do_manualaa()
208
209 if gui.GetValue("manual_left") == 0 or
210 gui.GetValue("manual_right") == 0 or
211 gui.GetValue("manual_back") == 0 or
212 gui.GetValue("manual_inv") == 0 then
213 return
214 end
215
216 local input_left, input_right, input_back, input_inv, state =
217 input.IsButtonDown( gui.GetValue("manual_left") ),
218 input.IsButtonDown( gui.GetValue("manual_right") ),
219 input.IsButtonDown( gui.GetValue("manual_back") ),
220 input.IsButtonDown( gui.GetValue("manual_inv") ),
221 gui.GetValue( "m_state" )
222
223
224 if input_left == states.left and
225 input_right == states.right and
226 input_back == states.back and
227 input_inv == states.inv then
228 return
229 end
230
231 states.left = input_left
232 states.right = input_right
233 states.back = input_back
234 states.inv = input_inv
235
236 if (input_inv) then
237 main.inverted = not main.inverted
238 end
239
240 if (input_left and state == 1) or (input_right and state == 2) or (input_back and state == 3) then
241 gui.SetValue( "m_state", 0 )
242 main.manual_antiaiming = false
243 return
244 end
245
246 if (input_left and state ~= 1) then
247 gui.SetValue( "m_state", 1 )
248 main.manual_antiaiming = true
249 end
250
251 if (input_right and state ~= 2) then
252 gui.SetValue( "m_state", 2 )
253 main.manual_antiaiming = true
254 end
255
256 if (input_back and state ~= 3) then
257 gui.SetValue( "m_state", 3 )
258 main.manual_antiaiming = true
259 end
260
261end
262
263--- Handles your menu
264function main.menu_handle()
265 if input.IsButtonPressed( gui.GetValue( "msc_menutoggle" ) ) then
266 main.menu = not main.menu
267 end
268 window:SetActive(main.menu)
269end
270
271--- Updates your anti-aim
272function main.do_antiaim()
273
274 local local_player = entities.GetLocalPlayer()
275
276 if not local_player or not local_player:IsAlive() then
277 return
278 end
279
280 local current_type = main.update_state()
281 local label_lean = main.inverted and get_value(current_type, "_lean_inv") or get_value(current_type, "_lean")
282 local m_state = gui.GetValue("m_state")
283
284 local lean = 59 - (0.59 * gui.GetValue(label_lean))
285
286 local directions = {
287 [0] = lean,
288 [1] = -90 + lean,
289 [2] = 90 + lean,
290 [3] = 0 + lean
291 }
292
293 -- Set anti-aim values
294 gui.SetValue("rbot_antiaim_stand_real_add", directions[m_state])
295 gui.SetValue("rbot_antiaim_move_real_add", directions[m_state])
296 gui.SetValue("rbot_antiaim_edge_real_add", directions[m_state])
297
298 -- Do choking
299 -- Manual anti-aim doesn't have its own choke slider, so use current type's choke.
300 local velocity = velocity()
301 local choke_type = current_type == "manual" and ( ( gui.GetValue( "msc_slowwalk" ) ~= 0 and input.IsButtonDown( gui.GetValue( "msc_slowwalk" ) ) ) and "slowwalk" or (velocity > 0.01 and "running" or "standing") ) or current_type
302
303 local twist_label = get_value(current_type, "_twist")
304 local choke_label = get_value(choke_type, "_choke")
305
306 gui.SetValue("msc_fakelag_value", gui.GetValue(twist_label) and 4 or gui.GetValue(choke_label))
307
308end
309
310--- Updates your body desync
311function main.do_desync()
312
313 local local_player = entities.GetLocalPlayer()
314
315 if not local_player or not local_player:IsAlive() then
316 return
317 end
318
319 -- Invert desync
320 gui.SetValue("rbot_antiaim_stand_desync", main.inverted and 2 or 3)
321 gui.SetValue("rbot_antiaim_move_desync", main.inverted and 2 or 3)
322 gui.SetValue("rbot_antiaim_edge_desync", main.inverted and 2 or 3)
323
324 -- Fix lower body target
325 local current_type = main.update_state()
326 local desync_label = get_value(current_type, "_desync")
327
328 local target_angles = gui.GetValue(desync_label) and local_player:GetProp("m_angEyeAngles[1]") + (main.inverted and 120 or -120) or local_player:GetProp("m_angEyeAngles[1]")
329
330 local_player:SetProp("m_flLowerBodyYawTarget", target_angles)
331
332end
333
334--endregion
335
336--region Callbacks
337
338callbacks.Register( "Draw", function()
339
340 -- Do functions
341 main.menu_handle()
342 main.do_manualaa()
343 main.do_antiaim()
344 main.do_desync()
345
346 local x, y = draw.GetScreenSize()
347 local m_state = gui.GetValue("m_state")
348
349 -- Draw our manual anti-aimbot indicators
350 custom_triangle(x / 2, y / 2 + 55, 15, 2, m_state)
351
352end
353)
354
355--endregion