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