Advertisement
Mister_Stefan

Bruh Skeet Indicator

Sep 1st, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //germany indicators boss
  2.  
  3. var menu = {};
  4. var menu_elements = {};
  5. const menu_spacer = "                                                                                  ";
  6.  
  7. /**
  8. * Concats two elements into an array without increasing the array length.
  9. * Prevents the memory leak in 2.0.0 from happening
  10. *
  11. * @param a {array}
  12. * @param b {any}
  13. */
  14. menu.concat = function(a, b)
  15. {
  16.     // Creates a new array.
  17.     var arr = [];
  18.  
  19.     // Push all items from the array 'a' into our array.
  20.     for (var c in a)
  21.     {
  22.         arr.push(a[c]);
  23.     }
  24.  
  25.     // Push the value 'b' into our array.
  26.     arr.push(b);
  27.  
  28.     // Return the new array.
  29.     return arr;
  30. }
  31.  
  32. /**
  33. * Creates a new menu label
  34. *
  35. * @param label {string}
  36. */
  37. menu.label = function(label)
  38. {
  39.     // Creates the label
  40.     UI.AddLabel(label);
  41. };
  42.  
  43. /**
  44. * Creates a new menu element
  45. *
  46. * @param func {function}
  47. * @param name {string}
  48. * @param label {string},
  49. * @param properties {array}
  50. */
  51. menu.new = function(func, name, label, properties, initial_value)
  52. {
  53.     // Fix values
  54.     properties = properties || [];
  55.     initial_value = initial_value || undefined;
  56.  
  57.     // Get properties
  58.     const final_name = name + menu_spacer + label;
  59.     var final_props = [final_name];
  60.  
  61.     const element_info_t = {
  62.         path: ["Misc", "JAVASCRIPT", "Script items", final_name],
  63.         cache: initial_value,
  64.         func: func
  65.     };
  66.  
  67.     // If our properties aren't null, then pack them together.
  68.     if (properties != null)
  69.     {
  70.         for (var i = 0; i < properties.length; i++)
  71.         {
  72.             final_props.push(properties[i]);
  73.         }
  74.     }
  75.  
  76.     // Create our menu element and return properties
  77.     func.apply(null, final_props);
  78.  
  79.     // Initialize our menu element if it has an initializer.
  80.     if (initial_value)
  81.     {
  82.         switch (func)
  83.         {
  84.             case UI.AddColorPicker:
  85.                 UI.SetColor.apply(null, this.concat(element_info_t.path, initial_value));
  86.                 break;
  87.  
  88.             case UI.AddHotkey:
  89.                 break;
  90.  
  91.             default:
  92.                 UI.SetValue.apply(this, this.concat(element_info_t.path, initial_value));
  93.                 break;
  94.         }
  95.     }
  96.  
  97.     menu_elements[label] = element_info_t;
  98.  
  99.     return element_info_t;
  100. };
  101.  
  102. /**
  103. * Creates a new menu reference
  104. *
  105. * @param path {array}
  106. */
  107. menu.reference = function(path, func)
  108. {
  109.     return {
  110.         path: path,
  111.         func: func
  112.     };
  113. };
  114.  
  115. /**
  116. * Gets the value of a menu element
  117. *
  118. * @param elem {array}
  119. * @return {*}
  120. */
  121. menu.get = function(elem)
  122. {
  123.     // If the element 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.     switch (elem.func)
  129.     {
  130.         case UI.AddColorPicker:
  131.             return UI.GetColor.apply(null, elem.path);
  132.  
  133.         case UI.AddHotkey:
  134.             return UI.IsHotkeyActive.apply(null, elem.path);
  135.  
  136.         default:
  137.             return UI.GetValue.apply(null, elem.path);
  138.     }
  139. };
  140.  
  141. /**
  142. * Sets the value of a menu element
  143. *
  144. * @param elem {array}
  145. * @param value {*}
  146. */
  147. menu.set = function(elem, value)
  148. {
  149.     // If the label doesn't exist
  150.     if (!(elem.path))
  151.         throw new Error("[Menu] This element doesn't exist!");
  152.  
  153.     // Set the element's value
  154.     switch (elem.func)
  155.     {
  156.         case UI.AddColorPicker:
  157.             UI.SetColor.apply(null, this.concat(elem.path, value));
  158.             break;
  159.  
  160.         case UI.AddHotkey:
  161.             if (menu.get(elem) !== value)
  162.                 UI.ToggleHotkey.apply(null, elem.path);
  163.             break;
  164.  
  165.         default:
  166.             UI.SetValue.apply(null, this.concat(elem.path, value));
  167.             break;
  168.     }
  169. };
  170.  
  171. /**
  172. * Changes the visibility of a menu elements
  173. *
  174. * @param elem {array}
  175. * @param visible {boolean}
  176. */
  177. menu.visibility = function(elem, visible)
  178. {
  179.     // If the label doesn't exist
  180.     if (!(elem.path))
  181.         throw new Error("[Menu] This element doesn't exist!");
  182.  
  183.     // Change the element's visibility
  184.     UI.SetEnabled.apply(null, this.concat(elem.path, visible));
  185. };
  186.  
  187. /**
  188. * Adds an event to a menu element which is triggered everytime this element's value is changed.
  189. *
  190. * @param elem {array}
  191. * @param func {function}
  192. */
  193. menu.add_event = function(elem, func)
  194. {
  195.     if (!elem.path)
  196.         throw new Error("[Menu] This element doesn't exist!");
  197.  
  198.     if (!elem.func)
  199.         throw new Errror("[Menu] This element does not have a valid type. Please, specify one.");
  200.  
  201.     elem.callback = func;
  202. }
  203.  
  204. /**
  205. * Handles the menu elements' events. Call this inside a Draw or FSN callback.
  206. */
  207. menu.handle_events = function()
  208. {
  209.     for (var label in menu_elements)
  210.     {
  211.         const elem = menu_elements[label];
  212.  
  213.         if (!elem.path || !elem.callback)
  214.             continue;
  215.  
  216.         const value = menu.get(elem);
  217.  
  218.         if (elem.cache === undefined)
  219.             elem.cache = value;
  220.  
  221.         if (elem.cache !== value)
  222.         {
  223.             elem.callback.apply(null, [elem]);
  224.             elem.cache = value;
  225.         }
  226.     }
  227. }
  228.  
  229. /**
  230. * @brief Normalizes an yaw angle.
  231. * @param angle {number}
  232. * @returns {number}
  233. */
  234. function normalize_yaw(angle)
  235. {
  236.     var adjusted_yaw = angle;
  237.  
  238.     if (adjusted_yaw < -180)
  239.         adjusted_yaw += 360;
  240.  
  241.     if (adjusted_yaw > 180)
  242.         adjusted_yaw -= 360;
  243.  
  244.     return adjusted_yaw;
  245. }
  246.  
  247. Render.Arc = function(x, y, r1, r2, s, d, col)
  248. {
  249.     for (var i = s; i < s + d; i++)
  250.     {
  251.         const rad = i * Math.PI / 180;
  252.  
  253.         Render.Line(x + Math.cos(rad) * r1, y + Math.sin(rad) * r1, x + Math.cos(rad) * r2, y + Math.sin(rad) * r2, col);
  254.     }
  255. }
  256. //endregion
  257.  
  258. //region menu
  259. const voffset = menu.new(UI.AddSliderInt, "| Indicators vertical offset", "", [0, 1000]);
  260.  
  261. const ref_antiaim_enabled = menu.reference(["Anti-Aim", "Fake angles", "Enabled"]);
  262. const ref_fakelag_enabled = menu.reference(["Anti-Aim", "Fake-Lag", "Enabled"]);
  263. const ref_doubletap = menu.reference(["Rage", "GENERAL", "Exploits", "Doubletap"]);
  264. const ref_doubletap_hk = menu.reference(["Rage", "GENERAL", "Exploits", "Doubletap"], UI.AddHotkey);
  265. const ref_hideshots_hk = menu.reference(["Rage", "GENERAL", "Exploits", "Hide shots"], UI.AddHotkey);
  266. //endregion
  267.  
  268. //region locals
  269. var last_time = 0;
  270. var planted = false;
  271. var bombsite = -1;
  272. var offset = 0;
  273.  
  274. const modules = [
  275.     {
  276.         label: "FAKE",
  277.         condition: function() {
  278.             return menu.get(ref_antiaim_enabled);
  279.         },
  280.         colors: {
  281.             dormant: [186, 0, 16, 225],
  282.             active: [154, 205, 50, 255]
  283.         },
  284.         logic: function() {
  285.             const self = modules[0];
  286.  
  287.             const real = Local.GetRealYaw(), fake = Local.GetFakeYaw();
  288.             const delta = Math.abs(normalize_yaw(real % 360 - fake % 360)) / 2;
  289.  
  290.             return delta / 60;
  291.         },
  292.         extra: function(x, y, color) {
  293.             const real = Local.GetRealYaw(), fake = Local.GetFakeYaw();
  294.             const delta = Math.abs(normalize_yaw(real % 360 - fake % 360)) / 2;
  295.  
  296.             const frac = delta / 60;
  297.  
  298.             Render.Arc(x+5, y, 6, 13, 0, 360, [10, 10, 10, 60]);
  299.             Render.Arc(x+5, y, 7, 11, 0, 360 * frac, color);
  300.         }
  301.     },
  302.     {
  303.         label: "LC",
  304.         condition: function() {
  305.             const me = Entity.GetLocalPlayer();
  306.             const on_ground = Entity.GetProp(me, "CBasePlayer", "m_fFlags") & 1;
  307.  
  308.             return menu.get(ref_fakelag_enabled) & (!on_ground || Input.IsKeyPressed(0x20)) & !menu.get(ref_doubletap_hk) & !menu.get(ref_hideshots_hk);
  309.         },
  310.         colors: {
  311.             dormant: [186, 0, 16, 225],
  312.             active: [163, 232, 44, 255]
  313.         },
  314.         logic: function() {
  315.             const self = modules[1];
  316.  
  317.             const me = Entity.GetLocalPlayer();
  318.             const vec = Entity.GetProp(me, "CBasePlayer", "m_vecVelocity[0]");
  319.             const vel = Math.sqrt(vec[0] ** 2 + vec[1] ** 2 + vec[2] ** 2);
  320.  
  321.             if (vel > 370)
  322.                 return 1;
  323.  
  324.             return 0;
  325.         }
  326.     },
  327.     {
  328.         label: "DT",
  329.         condition: function() {
  330.             return menu.get(ref_doubletap) & menu.get(ref_doubletap_hk);
  331.         },
  332.         colors: {
  333.             dormant: [235, 235, 235, 255],
  334.             active: [235, 235, 235, 255]
  335.         },
  336.         logic: function() {
  337.             const self = modules[2];
  338.  
  339.             const charge = Exploit.GetCharge();
  340.  
  341.             self.colors.active = charge === 1 ? [235, 235, 235, 255] : [186, 0, 16, 225];
  342.  
  343.             return 1;
  344.         }
  345.     },
  346.     {
  347.         label: "Bombsite A",
  348.         condition: function() {
  349.             return bombsite % 2 == 1;
  350.         },
  351.         colors: {
  352.             dormant: [240, 235, 60, 255],
  353.             active: [240, 235, 60, 255]
  354.         },
  355.         logic: function() {
  356.             return 1;
  357.         },
  358.         extra: function(x, y) {
  359.             const self = modules[3];
  360.  
  361.             const frac = (Globals.Curtime() - last_time) / 3.125;
  362.  
  363.             Render.Arc(x, y, 6, 11, 0, 360, [10, 10, 10, 25]);
  364.             Render.Arc(x, y, 7, 10, -90, 360 * frac, [232, 232, 232, 255]);
  365.         }
  366.     },
  367.     {
  368.         label: "Bombsite B",
  369.         condition: function() {
  370.             return bombsite % 2 == 0;
  371.         },
  372.         colors: {
  373.             dormant: [240, 235, 60, 255],
  374.             active: [240, 235, 60, 255]
  375.         },
  376.         logic: function() {
  377.             return 1;
  378.         },
  379.         extra: function(x, y, color) {
  380.             const self = modules[4];
  381.  
  382.             const frac = (Globals.Curtime() - last_time) / 3.125;
  383.  
  384.             Render.Arc(x, y, 6, 11, 0, 360, [10, 10, 10, 25]);
  385.             Render.Arc(x, y, 7, 10, -90, 360 * frac, [232, 232, 232, 255]);
  386.         }
  387.     },
  388.     {
  389.         label: "",
  390.         condition: function() {
  391.             return planted;
  392.         },
  393.         colors: {
  394.             dormant: [235, 235, 235, 255],
  395.             active: [235, 235, 235, 255]
  396.         },
  397.         logic: function() {
  398.             const self = modules[5];
  399.  
  400.             var c4 = Entity.GetEntitiesByClassID(128)[0];
  401.  
  402.             if (!c4)
  403.                 return 0;
  404.  
  405.             var timer = (Entity.GetProp(c4, "CPlantedC4", "m_flC4Blow") - Globals.Curtime());
  406.  
  407.  
  408.             return 1;
  409.         }
  410.     },
  411.     {
  412.         label: "",
  413.         condition: function() {
  414.             return planted;
  415.         },
  416.         colors: {
  417.             dormant: [135, 15, 15, 255],
  418.             active: [195, 255, 0, 255]
  419.         },
  420.         logic: function() {
  421.             const self = modules[6];
  422.  
  423.             const me = Entity.GetLocalPlayer();
  424.  
  425.             if (!me || !Entity.IsAlive(me))
  426.                 return 0;
  427.  
  428.             const c4 = Entity.GetEntitiesByClassID(128)[0];
  429.  
  430.             if (!c4)
  431.                 return 0;
  432.  
  433.             const armor = Entity.GetProp(me, "CCSPlayerResource", "m_iArmor");
  434.             const health = Entity.GetProp(me, "CBasePlayer", "m_iHealth");
  435.  
  436.             const origin = Entity.GetRenderOrigin(c4);
  437.             const my_origin = Entity.GetRenderOrigin(me);
  438.  
  439.             const distance = Math.sqrt((origin[0] - my_origin[0]) ** 2 + (origin[1] - my_origin[1]) ** 2 + (origin[2] - my_origin[2]) ** 2);
  440.  
  441.             // Ultranite
  442.             const a = 450.7;
  443.             const b = 75.68;
  444.             const c = 789.2;
  445.    
  446.             const d = (distance - b) / c;
  447.    
  448.             var damage = a * Math.exp(-d * d);
  449.    
  450.             if (armor > 0) {
  451.                 var newDmg = damage * 0.5;
  452.                 var armorDmg = (damage - newDmg) * 0.5;
  453.    
  454.                 if (armorDmg > armor) {
  455.                     armor = armor * (1 / .5);
  456.                     newDmg = damage - armorDmg;
  457.                 }
  458.  
  459.                 damage = Math.round(newDmg);
  460.             }
  461.  
  462.  
  463.  
  464.             return Math.max(1 -damage / health, 0);
  465.         }
  466.     }
  467. ];
  468. //endregion
  469.  
  470. //region functions
  471.  
  472. function draw_timer()
  473. {
  474.     if (!planted)
  475.         return;
  476.  
  477.     const me = Entity.GetLocalPlayer();
  478.  
  479.     if (!me)
  480.         return;
  481.  
  482.     if (!Entity.IsAlive(me))
  483.     {
  484.         if (Entity.GetProp(me, "CBasePlayer", "m_iObserverMode") < 4)
  485.             return;
  486.  
  487.         me = Entity.GetProp(me, "CBasePlayer", "m_hObserverTarget");
  488.     }
  489.  
  490.     var c4 = Entity.GetEntitiesByClassID(128)[0];
  491.  
  492.     if (!c4)
  493.         return;
  494.  
  495.     const y = Render.GetScreenSize()[1];
  496.     const color = [235, 235, 235, 255];
  497.  
  498.     var bombsite_label = bombsite % 2 == 0 ? "" : "";
  499.  
  500.     var timer = (Entity.GetProp(c4, "CPlantedC4", "m_flC4Blow") - Globals.Curtime());
  501.  
  502.  
  503.     Render.FilledRect(0, y - bar_length, 10, bar_length, color);
  504. }
  505.  
  506. function draw_indicators()
  507. {
  508.     const offset_y = menu.get(voffset);
  509.     const y = Render.GetScreenSize()[1] - offset_y;
  510.     const drawn = 0;
  511.  
  512.     for (var i = 0; i < modules.length; i++)
  513.     {
  514.         const mod = modules[i];
  515.  
  516.         if (!mod.condition()) continue;
  517.  
  518.         const result = mod.logic();
  519.         const label_width = Render.TextSize(mod.label, 4)[0];
  520.         const color = [
  521.             mod.colors.dormant[0] + (mod.colors.active[0] - mod.colors.dormant[0]) * result,
  522.             mod.colors.dormant[1] + (mod.colors.active[1] - mod.colors.dormant[1]) * result,
  523.             mod.colors.dormant[2] + (mod.colors.active[2] - mod.colors.dormant[2]) * result,
  524.             255
  525.         ];
  526.  
  527.         Render.GradientRect(15 + offset, y - 130 - 55 * drawn, label_width + 15, 45, 1, [10, 10, 10, 50], [10, 10, 10, 0]);
  528.         Render.String(25 + offset, y - 125 - 55 * drawn, 0, mod.label, color, 4);
  529.  
  530.         if (mod.extra)
  531.             mod.extra(40 + offset + label_width, y - 106 - 55 * drawn, color);
  532.  
  533.         drawn++;
  534.     }
  535. }
  536.  
  537. function on_draw() {
  538.     const me = Entity.GetLocalPlayer();
  539.  
  540.     if (!me || !Entity.IsAlive(me))
  541.         return;
  542.  
  543.     draw_indicators();
  544.     draw_timer();
  545. }
  546.  
  547. function on_bomb_beginplant()
  548. {
  549.     bombsite = Event.GetInt("site");
  550.     last_time = Globals.Curtime();
  551. }
  552.  
  553. function on_bomb_planted()
  554. {
  555.     planted = true;
  556.     bombsite = -1;
  557.     offset = 15;
  558. }
  559.  
  560. function on_bomb_abortplant()
  561. {
  562.     bombsite = -1;
  563. }
  564.  
  565. function on_bomb_exploded()
  566. {
  567.     planted = false;
  568.     offset = 0;
  569. }
  570.  
  571. function on_round_prestart()
  572. {
  573.     planted = false;
  574.     offset = 0;
  575.     bombsite = -1;
  576.     last_time = 0;
  577. }
  578.  
  579. function on_player_connect()
  580. {
  581.     var c4 = Entity.GetEntitiesByClassID(128)[0];
  582.  
  583.     last_time = 0;
  584.  
  585.     if (!c4)
  586.     {
  587.         planted = false;
  588.         offset = 0;
  589.         bombsite = -1;
  590.         return;
  591.     }
  592.  
  593.     planted = true;
  594.     offset = 15;
  595.     bombsite = Entity.GetProp(c4, "CPlantedC4", "m_nBombSite");
  596. }
  597.  
  598. Cheat.RegisterCallback("Draw", "on_draw");
  599. Cheat.RegisterCallback("bomb_beginplant", "on_bomb_beginplant");
  600. Cheat.RegisterCallback("bomb_planted", "on_bomb_planted");
  601. Cheat.RegisterCallback("bomb_abortplant", "on_bomb_abortplant");
  602. Cheat.RegisterCallback("bomb_exploded", "on_bomb_exploded");
  603. Cheat.RegisterCallback("round_prestart", "on_round_prestart");
  604. Cheat.RegisterCallback("player_connect_full", "on_player_connect");
  605. //endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement