Advertisement
Guest User

adapt aa

a guest
Mar 28th, 2020
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /**
  3.  *
  4.  * Title: Advanced body freestanding
  5.  * Author: april#0001
  6.  * Description: Gives more anti-aim customization for advanced users.
  7.  *
  8.  */
  9.  
  10. //region api
  11.  
  12. // Localizing all of the functions in snake_case because why not.
  13. const global_print = Global.Print, global_print_chat = Global.PrintChat, global_print_color = Global.PrintColor, global_register_callback = Global.RegisterCallback, global_execute_command = Global.ExecuteCommand, global_frame_stage = Global.FrameStage, global_tickcount = Global.Tickcount, global_tickrate = Global.Tickrate, global_tick_interval = Global.TickInterval, global_curtime = Global.Curtime, global_realtime = Global.Realtime, global_frametime = Global.Frametime, global_latency = Global.Latency, global_get_view_angles = Global.GetViewAngles, global_set_view_angles = Global.SetViewAngles, global_get_map_name = Global.GetMapName, global_is_key_pressed = Global.IsKeyPressed, global_get_screen_size = Global.GetScreenSize, global_get_cursor_position = Global.GetCursorPosition, global_play_sound = Global.PlaySound, global_play_microphone = Global.PlayMicrophone, global_stop_microphone = Global.StopMicrophone, global_get_username = Global.GetUsername, global_set_clan_tag = Global.SetClanTag, globals_tickcount = Globals.Tickcount, globals_tickrate = Globals.Tickrate, globals_tick_interval = Globals.TickInterval, globals_curtime = Globals.Curtime, globals_realtime = Globals.Realtime, globals_frametime = Globals.Frametime, sound_play = Sound.Play, sound_play_microphone = Sound.PlayMicrophone, sound_stop_microphone = Sound.StopMicrophone, cheat_get_username = Cheat.GetUsername, cheat_register_callback = cheat_register_callback = new Proxy(Cheat.RegisterCallback, { apply: function(_, _, args) { switch(args[0]) { case 'paint': Cheat.RegisterCallback('Draw', args[1]); break; case 'create_move': Cheat.RegisterCallback('CreateMove', args[1]); break; case 'fsn': Cheat.RegisterCallback('FrameStageNotify', args[1]); break; default: Cheat.RegisterCallback(args[0], args[1]); break; } } }), cheat_execute_command = Cheat.ExecuteCommand, cheat_frame_stage = Cheat.FrameStage, cheat_print = Cheat.Print, cheat_print_chat = Cheat.PrintChat, cheat_print_color = Cheat.PrintColor, local_latency = Local.Latency, local_get_view_angles = Local.GetViewAngles, local_set_view_angles = Local.SetViewAngles, local_set_clan_tag = Local.SetClanTag, local_get_real_yaw = Local.GetRealYaw, local_get_fake_yaw = Local.GetFakeYaw, local_get_spread = Local.GetSpread, local_get_inaccuracy = Local.GetInaccuracy, world_get_map_name = World.GetMapName, world_get_server_string = World.GetServerString, input_get_cursor_position = Input.GetCursorPosition, input_is_key_pressed = Input.IsKeyPressed, render_string = Render.String, render_text_size = Render.TextSize, render_line = Render.Line, render_rect = Render.Rect, render_filled_rect = Render.FilledRect, render_gradient_rect = Render.GradientRect, render_circle = Render.Circle, render_filled_circle = Render.FilledCircle, render_polygon = Render.Polygon, render_world_to_screen = Render.WorldToScreen, render_add_font = Render.AddFont, render_find_font = Render.FindFont, render_string_custom = Render.StringCustom, render_textured_rect = Render.TexturedRect, render_add_texture = Render.AddTexture, render_text_size_custom = Render.TextSizeCustom, render_get_screen_size = Render.GetScreenSize, ui_get_value = UI.GetValue, ui_set_value = UI.SetValue, ui_add_checkbox = UI.AddCheckbox, ui_add_slider_int = UI.AddSliderInt, ui_add_slider_float = UI.AddSliderFloat, ui_add_hotkey = UI.AddHotkey, ui_add_label = UI.AddLabel, ui_add_dropdown = UI.AddDropdown, ui_add_multi_dropdown = UI.AddMultiDropdown, ui_add_color_picker = UI.AddColorPicker, ui_add_textbox = UI.AddTextbox, ui_set_enabled = UI.SetEnabled, ui_get_string = UI.GetString, ui_get_color = UI.GetColor, ui_set_color = UI.SetColor, ui_is_hotkey_active = UI.IsHotkeyActive, ui_toggle_hotkey = UI.ToggleHotkey, ui_is_menu_open = UI.IsMenuOpen, convar_get_int = Convar.GetInt, convar_set_int = Convar.SetInt, convar_get_float = Convar.GetFloat, convar_set_float = Convar.SetFloat, convar_get_string = Convar.GetString, convar_set_string = Convar.SetString, event_get_int = Event.GetInt, event_get_float = Event.GetFloat, event_get_string = Event.GetString, entity_get_entities = Entity.GetEntities, entity_get_entities_by_class_i_d = Entity.GetEntitiesByClassID, entity_get_players = Entity.GetPlayers, entity_get_enemies = Entity.GetEnemies, entity_get_teammates = Entity.GetTeammates, entity_get_local_player = Entity.GetLocalPlayer, entity_get_game_rules_proxy = Entity.GetGameRulesProxy, entity_get_entity_from_user_i_d = Entity.GetEntityFromUserID, entity_is_teammate = Entity.IsTeammate, entity_is_enemy = Entity.IsEnemy, entity_is_bot = Entity.IsBot, entity_is_local_player = Entity.IsLocalPlayer, entity_is_valid = Entity.IsValid, entity_is_alive = Entity.IsAlive, entity_is_dormant = Entity.IsDormant, entity_get_class_i_d = Entity.GetClassID, entity_get_class_name = Entity.GetClassName, entity_get_name = Entity.GetName, entity_get_weapon = Entity.GetWeapon, entity_get_weapons = Entity.GetWeapons, entity_get_render_origin = Entity.GetRenderOrigin, entity_get_prop = Entity.GetProp, entity_set_prop = Entity.SetProp, entity_get_hitbox_position = Entity.GetHitboxPosition, entity_get_eye_position = Entity.GetEyePosition, trace_line = Trace.Line, trace_bullet = Trace.Bullet, usercmd_set_movement = UserCMD.SetMovement, usercmd_get_movement = UserCMD.GetMovement, usercmd_set_angles = UserCMD.SetAngles, usercmd_force_jump = UserCMD.ForceJump, usercmd_force_crouch = UserCMD.ForceCrouch, antiaim_get_override = AntiAim.GetOverride, antiaim_set_override = AntiAim.SetOverride, antiaim_set_real_offset = AntiAim.SetRealOffset, antiaim_set_fake_offset = AntiAim.SetFakeOffset, antiaim_set_l_b_y_offset = AntiAim.SetLBYOffset, exploit_get_charge = Exploit.GetCharge, exploit_recharge = Exploit.Recharge, exploit_disable_recharge = Exploit.DisableRecharge, exploit_enable_recharge = Exploit.EnableRecharge, ragebot_override_minimum_damage = Ragebot.OverrideMinimumDamage, ragebot_override_hitchance = Ragebot.OverrideHitchance, ragebot_override_accuracy_boost = Ragebot.OverrideAccuracyBoost, ragebot_override_multipoint_scale = Ragebot.OverrideMultipointScale, ragebot_force_safety = Ragebot.ForceSafety;
  14. //endregion
  15.  
  16. //region dependencies
  17.  
  18. /**
  19.  * @title BetterUI
  20.  * @version 2.0.0
  21.  * @description A better UI system for Onetap
  22.  */
  23.  
  24. var menu = [];
  25. const menu_spacer = "                                                                                  ";
  26.  
  27. /**
  28.  * Creates a new menu label
  29.  *
  30.  * @param label {string}
  31.  */
  32. menu.label = function(label)
  33. {
  34.     // Creates the label
  35.     UI.AddLabel(label);
  36. };
  37.  
  38. /**
  39.  * Creates a new menu element
  40.  *
  41.  * @param func {function}
  42.  * @param name {string}
  43.  * @param label {string},
  44.  * @param properties {array}
  45.  */
  46. menu.call = function(func, name, label, properties)
  47. {
  48.     // Get properties
  49.     const final_name = name + menu_spacer + label;
  50.     var final_props = [final_name];
  51.     const element_info_t = {
  52.         path: ["Misc", "JAVASCRIPT", "Script Items", final_name]
  53.     };
  54.  
  55.     // If our properties aren't null, then pack them together.
  56.     if (properties != null)
  57.     {
  58.         for (var i = 0; i < properties.length; i++)
  59.         {
  60.             final_props.push(properties[i]);
  61.         }
  62.     }
  63.  
  64.     // Create our menu element and return properties
  65.     func.apply(null, final_props);
  66.     return element_info_t;
  67. };
  68.  
  69. /**
  70.  * Creates a new menu reference
  71.  *
  72.  * @param path {array}
  73.  */
  74. menu.reference = function(path)
  75. {
  76.     const element_info_t = {
  77.         path: path
  78.     };
  79.  
  80.     return element_info_t;
  81. };
  82.  
  83. /**
  84.  * Gets the value of a menu element
  85.  *
  86.  * @param elem {array}
  87.  * @return {*}
  88.  */
  89. menu.get = function(elem)
  90. {
  91.     // If the element doesn't exist
  92.     if (!(elem.path))
  93.         throw new Error("[Menu] This element doesn't exist!");
  94.  
  95.     // Returns the element's value
  96.     return UI.GetValue.apply(null, elem.path);
  97. };
  98.  
  99. /**
  100.  * Gets the value of a menu element
  101.  *
  102.  * @param elem {array}
  103.  * @return {*}
  104.  */
  105. menu.get_hotkey = function(elem)
  106. {
  107.     // If the label doesn't exist
  108.     if (!(elem.path))
  109.         throw new Error("[Menu] This element doesn't exist!");
  110.  
  111.     // Returns the element's value
  112.     return UI.IsHotkeyActive.apply(null, elem.path);
  113. };
  114.  
  115. /**
  116.  * Gets the value of a menu element
  117.  *
  118.  * @param elem {array}
  119.  * @return {*}
  120.  */
  121. menu.get_color = function(elem)
  122. {
  123.     // If the label doesn't exist
  124.     if (!(elem.path))
  125.         throw new Error("[Menu] This element doesn't exist!");
  126.  
  127.     // Returns the element's value
  128.     return UI.GetColor.apply(null, elem.path);
  129. };
  130.  
  131. /**
  132.  * Sets the value of a menu element
  133.  *
  134.  * @param elem {array}
  135.  * @param value {any}
  136.  */
  137. menu.set = function(elem, value)
  138. {
  139.     // If the label doesn't exist
  140.     if (!(elem.path))
  141.         throw new Error("[Menu] This element doesn't exist!");
  142.  
  143.     // Get properties
  144.     const properties = elem;
  145.     properties.path.push(value);
  146.  
  147.     // Set the element's value
  148.     UI.SetValue.apply(null, properties.path);
  149. };
  150.  
  151. /**
  152.  * Sets the value of a color picker
  153.  *
  154.  * @param elem {array}
  155.  * @param color {array|Color}
  156.  */
  157. menu.set_color = function(elem, color)
  158. {
  159.     // If the label doesn't exist
  160.     if (!(elem.path))
  161.         throw new Error("[Menu] This element doesn't exist!");
  162.  
  163.     // Get properties
  164.     const properties = elem;
  165.     properties.path.push(color);
  166.  
  167.     // Set the element's value
  168.     UI.SetColor.apply(null, properties.path);
  169. };
  170.  
  171. /**
  172.  * Sets the value of a color picker
  173.  *
  174.  * @param elem {array}
  175.  */
  176. menu.toggle = function(elem)
  177. {
  178.     // If the label doesn't exist
  179.     if (!(elem.path))
  180.         throw new Error("[Menu] This element doesn't exist!");
  181.  
  182.     // Set the element's value
  183.     UI.ToggleHotkey.apply(null, elem.path);
  184. };
  185.  
  186. /**
  187.  * Changes the visibility of a menu elements
  188.  *
  189.  * @param elem {array}
  190.  * @param visible {boolean}
  191.  */
  192. menu.visibility = function(elem, visible)
  193. {
  194.     // If the label doesn't exist
  195.     if (!(elem.path))
  196.         throw new Error("[Menu] This element doesn't exist!");
  197.  
  198.     // Get properties
  199.     const properties = elem;
  200.     properties.path.push(visible);
  201.  
  202.     // Change the element's visibility
  203.     UI.SetEnabled.apply(null, properties.path);
  204. };
  205.  
  206. /**
  207.  * @title Vector
  208.  * @description Simple 3d vector system
  209.  *
  210.  * @typedef Vector {x: number, y: number, z: number}
  211.  */
  212. var vector = {
  213.     _class: 'vector'
  214. };
  215.  
  216. /**
  217.  * @brief Creates a new 3d vector instance.
  218.  * @param data {array}
  219.  * @returns {Vector}
  220.  */
  221. vector.new = function(data)
  222. {
  223.     return {
  224.         x: data[0],
  225.         y: data[1],
  226.         z: data[2]
  227.     };
  228. };
  229.  
  230. /**
  231.  * @brief Realizes a mathematical operation between two vectors.
  232.  * @param vec {Vector}
  233.  * @param vec2 {Vector}
  234.  * @param operation {string}
  235.  * @returns {Vector}
  236.  */
  237. vector.operate = function(vec, vec2, operation)
  238. {
  239.   switch (operation)
  240.   {
  241.       case '+':
  242.           return {
  243.               x: vec.x + vec2.x,
  244.               y: vec.y + vec2.y,
  245.               z: vec.z + vec2.z
  246.           };
  247.  
  248.       case '-':
  249.           return {
  250.               x: vec.x - vec2.x,
  251.               y: vec.y - vec2.y,
  252.               z: vec.z - vec2.z
  253.           };
  254.  
  255.       case '*':
  256.           return {
  257.               x: vec.x * vec2.x,
  258.               y: vec.y * vec2.y,
  259.               z: vec.z * vec2.z
  260.           };
  261.  
  262.       case '/':
  263.           return {
  264.               x: vec.x / vec2.x,
  265.               y: vec.y / vec2.y,
  266.               z: vec.z / vec2.z
  267.           };
  268.  
  269.       default:
  270.           throw new Error("[Vector] Invalid operation type.");
  271.   }
  272. };
  273.  
  274. /**
  275.  * @brief Returns the 2d length of a vector.
  276.  * @param vec {Vector}
  277.  * @returns {number}
  278.  */
  279. vector.length2d = function(vec)
  280. {
  281.     return Math.sqrt(vec.x * vec.x + vec.y * vec.y);
  282. };
  283.  
  284. /**
  285.  * @brief Converts a vector to angles.
  286.  * @param vec
  287.  * @returns {Vector}
  288.  */
  289. vector.angles = function(vec)
  290. {
  291.     return {
  292.         x: -Math.atan2(vec.z, this.length2d(vec)) * 180 / Math.PI,
  293.         y: Math.atan2(vec.y, vec.x) * 180 / Math.PI,
  294.         z: 0
  295.     };
  296. };
  297.  
  298. /**
  299.  * @brief Calculates the fov delta between two points based on a specific view angles.
  300.  * @param origin {Vector}
  301.  * @param destination {Vector}
  302.  * @param view {Vector}
  303.  * @returns {number}
  304.  */
  305. vector.fov_to = function(origin, destination, view)
  306. {
  307.     const angles = this.angles(this.operate(destination, origin, '-'));
  308.  
  309.     const delta = this.new(
  310.         [
  311.             Math.abs(view.x - angles.x),
  312.             Math.abs(view.y % 360 - angles.y % 360) % 360,
  313.             0
  314.         ]
  315.     );
  316.  
  317.     if (delta.y > 180)
  318.         delta.y = 360 - delta.y;
  319.  
  320.     return this.length2d(delta);
  321. };
  322.  
  323. /**
  324.  * @brief Unpacks a vector object into an array.
  325.  * @param vec {Vector}
  326.  * @returns {[number, number, number]}
  327.  */
  328. vector.to_array = function(vec)
  329. {
  330.     return [
  331.         vec.x,
  332.         vec.y,
  333.         vec.z
  334.     ];
  335. };
  336.  
  337. /**
  338.  * @brief Normalizes an yaw angle.
  339.  * @param angle {number}
  340.  * @returns {number}
  341.  */
  342. function normalize_yaw(angle)
  343. {
  344.     var adjusted_yaw = angle;
  345.     if (adjusted_yaw < -180)
  346.         adjusted_yaw += 360;
  347.  
  348.     if (adjusted_yaw > 180)
  349.         adjusted_yaw -= 360;
  350.  
  351.     return adjusted_yaw;
  352. }
  353.  
  354. //endregion
  355.  
  356. //region main
  357.  
  358. // Create our main instance
  359. var plugin = {
  360.     _info: {
  361.         _title: "Advanced body freestanding",
  362.         _version: "1.0.0",
  363.         _author: "april#0001"
  364.     },
  365.  
  366.     last_hit_lby: []
  367. };
  368.  
  369. //endregion
  370.  
  371. //region menu
  372.  
  373. // Create our menu elements
  374. const enable = menu.call(ui_add_checkbox, "Advanced body freestanding", "lby_enable", []);
  375. const body = menu.call(ui_add_dropdown, "Body freestanding", "lby_body_mode", [["Hide real angle", "Hide fake angle"]]);
  376. const smart = menu.call(ui_add_checkbox, "Smart switch", "lby_smart", []);
  377.  
  378. // Declare our references
  379. const ref_inverter = menu.reference(["Anti-Aim", "Fake angles", "Inverter"]);
  380. const ref_inverter_legit = menu.reference(["Anti-Aim", "Legit Anti-Aim", "Direction key"]);
  381. const ref_ragebot = menu.reference(["Rage", "GENERAL", "General", "Enabled"]);
  382.  
  383. //endregion
  384.  
  385. //region functions
  386.  
  387. /**
  388.  * @brief Inverts the lower body yaw to the specified value.
  389.  * @param state {number} Whether or not to invert the lower body yaw.
  390.  */
  391. function update_anti_aim_state(state)
  392. {
  393.     // If our rage aimbot is enabled, than we should invert the
  394.     // rage anti-aim.
  395.     if (menu.get(ref_ragebot))
  396.     {
  397.         // Check if our inverter's state is the same as our desired one.
  398.         // If not, then toggle the hotkey to invert it.
  399.         if (menu.get_hotkey(ref_inverter) !== state)
  400.             menu.toggle(ref_inverter);
  401.  
  402.         // Return because we don't wanna do the same to the legit anti-aim's state.
  403.         return;
  404.     }
  405.  
  406.     // Invert the state because the legit anti-aim's inverter is different
  407.     // from the rage one.
  408.     state = (state + 1) % 2;
  409.  
  410.     // Check if our inverter's state is the same as our desired one.
  411.     // If not, then toggle the hotkey to invert it.
  412.     if (menu.get_hotkey(ref_inverter_legit) !== state)
  413.         menu.toggle(ref_inverter_legit);
  414. }
  415.  
  416. /**
  417.  * @brief Gets the closest (FOV-based) enemy and returns its entity id.
  418.  * @returns {number}
  419.  */
  420. function get_closest_target( )
  421. {
  422.     // Get our entities.
  423.     const players = entity_get_enemies( );
  424.     const me = entity_get_local_player( );
  425.  
  426.     // Initialize our data array.
  427.     const data = {id: null, fov: 180};
  428.  
  429.     // Loop for each player in the server.
  430.     for (var i = 0; i < players.length; i++)
  431.     {
  432.         // Get the current player.
  433.         const e = players[i];
  434.  
  435.         // Get our eye's position, the player's head position and our view angles.
  436.         const destination = vector.new(entity_get_hitbox_position(e, 0)), origin = vector.new(entity_get_eye_position(me));
  437.         const angles = vector.new(local_get_view_angles());
  438.  
  439.         // Calculate the FOV distance.
  440.         const fov = vector.fov_to(origin, destination, angles);
  441.  
  442.         // If our FOV distance is lower than the cached one, then it means that
  443.         // there's another player which is even closer to our crosshair.
  444.         if (fov < data.fov)
  445.         {
  446.             // Cache this entity and our current FOV distance for further
  447.             // calculations.
  448.             data.id = e;
  449.             data.fov = fov;
  450.         }
  451.     }
  452.  
  453.     // Return the closest entity to our crosshair.
  454.     return data.id;
  455. }
  456.  
  457. /**
  458.  * @brief Gets which anti-aim side matches your settings the best. Or, in other words, does freestanding.
  459.  */
  460. function get_optimal_angle( )
  461. {
  462.     // Get current lower body yaw mode
  463.     const _mode = menu.get(body);
  464.  
  465.     // Get some properties.
  466.     const me = entity_get_local_player( );
  467.  
  468.     // And more properties..
  469.     const origin = vector.new(entity_get_render_origin(me));
  470.     var yaw = local_get_view_angles( )[1];
  471.     var data = {left: 0, right: 0};
  472.  
  473.     // Loops for every angle from the left of your yaw to the right of your yaw
  474.     // in steps of 30, resulting in 3 steps per side.
  475.     for (var r = yaw - 90; r <= yaw + 90; r += 30)
  476.     {
  477.         // If our current angle is the center one then there's no need
  478.         // to do anything with it.
  479.         if (r === yaw)
  480.             continue;
  481.  
  482.         // Convert our angle to radians
  483.         const rad = r * Math.PI / 180;
  484.  
  485.         // Create our destination point based on current angle.
  486.         const point = vector.operate(
  487.             origin,
  488.             vector.new([
  489.                 256 * Math.cos(rad),
  490.                 256 * Math.sin(rad),
  491.                 0
  492.             ]),
  493.             "+"
  494.         );
  495.  
  496.         // Trace a line from our player's origin to the current point.
  497.         // Using this to check the trace's fraction (m_flFraction) until
  498.         // it hits something and then add it to our data array.
  499.         //
  500.         // This is how my 'environmental freestanding' logic is made.
  501.         // The side with lower fractions is the side which is logically
  502.         // closer to the player's head.
  503.         const line = trace_line(me, vector.to_array(origin), vector.to_array(point));
  504.  
  505.         // Get which side we're iterating on.
  506.         const side = r < yaw ? "left" : "right";
  507.  
  508.         // Update our data array.
  509.         data[side] += line[1];
  510.     }
  511.  
  512.     // Calculates an average for both sides.
  513.     data.left /= 3;
  514.     data.right /= 3;
  515.  
  516.     // If our left avg. fractions are greater than the right ones, then return
  517.     // the number 0 which corresponds to the right side, or, in the Hide fake angle mode,
  518.     // return 1 which corresponds to the left side.
  519.     if (data.left > data.right)
  520.         return _mode === 0 ? 0 : 1;
  521.  
  522.     // Does the same thing as above, except the right avg. fractions are greater than
  523.     // the left ones.
  524.     return _mode === 0 ? 1 : 0;
  525. }
  526.  
  527. /**
  528.  * @brief Updates our anti-aim based on the current freestanding mode and input.
  529.  */
  530. function update_anti_aim( )
  531. {
  532.     // Get our local player.
  533.     const me = entity_get_local_player( );
  534.  
  535.     // Check if our player is valid and alive.
  536.     if (!entity_is_valid(me) || !entity_is_alive(me))
  537.         return;
  538.  
  539.     // Get if our anti-aim is on smart mode.
  540.     const _smart = menu.get(smart);
  541.  
  542.     // If our anti-aim is set to 'Smart', then the entire logic is different.
  543.     // The smart mode does not use freestanding as input, it uses data from
  544.     // other users as input.
  545.     if (_smart)
  546.     {
  547.         // Get our FOV-based target.
  548.         const target = get_closest_target( );
  549.  
  550.         // Check if our target is valid.
  551.         // Otherwise, just return our current freestanding angle.
  552.         if (target == null)
  553.         {
  554.             update_anti_aim_state(get_optimal_angle( ));
  555.             return;
  556.         }
  557.  
  558.         // Check if our target has already hit us.
  559.         // If not, then just return current freestanding angle.
  560.         if (plugin.last_hit_lby[target] == null)
  561.         {
  562.             update_anti_aim_state(get_optimal_angle( ));
  563.             return;
  564.         }
  565.  
  566.         // Return the opposite angle to the last hit angle.
  567.         // In this case if the inverter was off, now return on.
  568.         if (plugin.last_hit_lby[target] === 0)
  569.         {
  570.             update_anti_aim_state(1);
  571.             return;
  572.         }
  573.  
  574.         // Or, if the inverter was on, return off.
  575.         update_anti_aim_state(0);
  576.         return;
  577.     }
  578.  
  579.     // If our anti-aim is not on smart mode, then we're just using regular
  580.     // freestanding. So, do freestanding.
  581.     update_anti_aim_state(get_optimal_angle( ));
  582. }
  583.  
  584. function do_indicators( )
  585. {
  586.     // Get our local player.
  587.     const me = entity_get_local_player( );
  588.  
  589.     // Check if our player is valid and alive.
  590.     if (!entity_is_valid(me) || !entity_is_alive(me))
  591.         return;
  592.  
  593.     // Get our drawing properties.
  594.     const y = render_get_screen_size( )[1];
  595.  
  596.     // Get our anti-aim info.
  597.     const yaw = local_get_real_yaw( ), fake = local_get_fake_yaw( );
  598.     var delta = Math.round(normalize_yaw(yaw - fake) / 2), abs = Math.abs(delta);
  599.  
  600.     // If we're using legit anti-aim, invert the delta.
  601.     // Doing this to fix the indicators because legit
  602.     // anti-aim inverter is different.
  603.     if (menu.get(ref_ragebot))
  604.         delta *= -1;
  605.  
  606.     // Render the 'FAKE' indicator
  607.     // Totally did not copy it from gamesense.
  608.     render_string(10, y - 99, 0, "FAKE", [10, 10, 10, 125], 4);
  609.     render_string(10, y - 100, 0, "FAKE", [192 - (abs * 71 / 60), 32 + (abs * 146 / 60), 28, 200], 4);
  610.  
  611.     // Render the bar's background
  612.     render_filled_rect(12, y - 68, 64, 4, [10, 10, 10, 125]);
  613.  
  614.     // Draw this small tile to fix a small issue that was driving me crazy.
  615.     render_filled_rect(43, y - 67, 1, 2, [232, 232, 232, 200]);
  616.  
  617.     // Render the desync's length under the bar.
  618.     render_string(41, y - 63, 1, abs.toString( ), [232, 232, 232, 200], 3);
  619.     render_circle(48, y - 61, 1, [232, 232, 232, 200]);
  620.  
  621.     // If our delta is positive, than our desync is headed to the right.
  622.     if (delta > 0)
  623.     {
  624.         // So, fill the bar from the center to the right, accounting for the desync's length.
  625.         render_filled_rect(44, y - 67, abs * 31 / 60, 2, [232, 232, 232, 200]);
  626.         return;
  627.     }
  628.  
  629.     // If our delta is not positive, than our desync is headed to the left.
  630.     // So, fill the bar from the center to the left.
  631.     render_filled_rect(44 - abs * 31 / 60, y - 67, abs * 31 / 60, 2, [232, 232, 232, 200]);
  632. }
  633.  
  634. /**
  635.  * @callback create_move
  636.  * @brief Handles our plugin's logic.
  637.  */
  638. function on_tick( )
  639. {
  640.     // Checks whether or not our script is enabled.
  641.     if (!(menu.get(enable)))
  642.         return;
  643.  
  644.     // Does the freestanding.
  645.     update_anti_aim( );
  646. }
  647.  
  648. function on_frame( )
  649. {
  650.     // Checks whether or not our script is enabled.
  651.     if (!(menu.get(enable)))
  652.         return;
  653.  
  654.     // Draws our indicators
  655.     do_indicators( );
  656. }
  657.  
  658. /**
  659.  * @callback player_hurt
  660.  * @brief Handles the last hit LBY logic.
  661.  */
  662. function on_player_hurt( )
  663. {
  664.     // Get the event's entities.
  665.     const me = entity_get_local_player( );
  666.     const attacker = entity_get_entity_from_user_i_d(event_get_int("attacker"));
  667.     const userid = entity_get_entity_from_user_i_d(event_get_int("userid"));
  668.  
  669.     // Checks if our local player was the one getting hurt and not the one attacking.
  670.     // Or, in other words, check if we got hurt.
  671.     if (me !== attacker && me === userid)
  672.     {
  673.         // Update the last hit lower body global.
  674.         plugin.last_hit_lby[attacker] = menu.get_hotkey(ref_inverter);
  675.     }
  676. }
  677.  
  678. /**
  679.  * @callback round_start, player_connect_full
  680.  * @brief Resets the last hit LBY list whenever the round ends or you switch servers.
  681.  */
  682. function reset( )
  683. {
  684.     // Reset the last lower body state.
  685.     plugin.last_hit_lby = [];
  686. }
  687.  
  688.  
  689. //endregion
  690.  
  691. //region callbacks
  692.  
  693. // Register our 'create_move' callback.
  694. cheat_register_callback(
  695.     'create_move', 'on_tick'
  696. );
  697.  
  698. // Register our 'paint' callback.
  699. cheat_register_callback(
  700.     'paint', 'on_frame'
  701. );
  702.  
  703. // Register our 'player_hurt' callback.
  704. cheat_register_callback(
  705.     'player_hurt', 'on_player_hurt'
  706. );
  707.  
  708. // Register our 'player_connect_full' callback.
  709. cheat_register_callback(
  710.     'player_connect_full', 'reset'
  711. );
  712.  
  713. //endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement