SHARE
TWEET

Untitled

Ultranite Dec 8th, 2019 330 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Global Variables */
  2. var local = Entity.GetLocalPlayer();
  3. var targetIndex = -1;
  4. var target = -1;
  5. var distance;
  6. var rageTarget = 0;
  7. var rbotShots = 0;
  8. var target = -1;
  9. var lastShot;
  10. var waiting;
  11. var wepList = {
  12.     0: "Auto",
  13.     1: "AWP",
  14.     2: "Scout",
  15.     3: "Rifle",
  16.     4: "SMG",
  17.     5: "Heavy Pistol",
  18.     6: "Pistol"
  19. };
  20. /* ---------------- */
  21. setup();
  22. /* Functions */
  23. function calcDist(local, target) {
  24.     lx = local[0];
  25.     ly = local[1];
  26.     lz = local[2];
  27.     tx = target[0];
  28.     ty = target[1];
  29.     tz = target[2];
  30.     dx = lx - tx;
  31.     dy = ly - ty;
  32.     dz = lz - tz;
  33.     return Math.sqrt(dx * dx + dy * dy + dz * dz);
  34. }
  35.  
  36. function pickTarget() {
  37.     if (!UI.GetValue("Script Items", "[AHC] Enable Adaptive Hitchance") || !Entity.IsAlive(local))
  38.         return;
  39.     if (target == undefined || target == -1 || !Entity.IsValid(target) || !Entity.IsAlive(target)) {
  40.         if (rageTarget == 1) {
  41.             waiting = 1;
  42.         }
  43.     }
  44.     if (secondsElapsed >= 5) {
  45.         rageTarget = 0;
  46.         secondsElapsed = 0;
  47.         waiting = 0;
  48.     }
  49.     var enemies = Entity.GetEnemies();
  50.     var tempGuess = -1;
  51.     var localPos = Entity.GetHitboxPosition(local, 5);
  52.     for (var i = 0; i < enemies.length; i++) {
  53.         if (!Entity.IsValid(enemies[i]) || !Entity.IsAlive(enemies[i])) {
  54.             continue;
  55.         }
  56.         if (tempGuess == undefined || !Entity.IsValid(tempGuess) || !Entity.IsAlive(tempGuess) || Entity.IsDormant(
  57.                 tempGuess)) {
  58.             tempGuess = enemies[i];
  59.             continue;
  60.         }
  61.         targetPos = Entity.GetHitboxPosition(tempGuess, 5);
  62.         enemyPos = Entity.GetHitboxPosition(enemies[i], 5);
  63.         if (calcDist(localPos, enemyPos) < calcDist(localPos, targetPos)) {
  64.             tempGuess = enemies[i];
  65.             continue;
  66.         }
  67.     }
  68.     targetIndex = tempGuess;
  69.     targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  70.     if (rageTarget == 0)
  71.         adjustHitchance(calcDist(localPos, targetPos));
  72. }
  73.  
  74. function onShot() {
  75.     if (!UI.GetValue("Script Items", "[AHC] Enable Adaptive Hitchance"))
  76.         return;
  77.     target = Event.GetInt("target_index");
  78.     if (!Entity.IsValid(targetIndex) || !Entity.IsAlive(targetIndex) || !Entity.IsDormant(targetIndex)) {
  79.         waiting = 1;
  80.         target = -1;
  81.         return;
  82.     }
  83.     targetIndex = target;
  84.     rageTarget = 1;
  85.     secondsElapsed = 0;
  86.     targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  87.     localPos = Entity.GetHitboxPosition(local, 5);
  88.     adjustHitchance(calcDist(localPos, targetPos));
  89. }
  90.  
  91. function drawIndicator() {
  92.     if (!UI.GetValue("Script items", "[AHC] Show Indicators"))
  93.         return;
  94.     if (!Entity.IsAlive(local))
  95.         return;
  96.     if (targetIndex == -1 || targetIndex == undefined) {
  97.         return;
  98.     }
  99.     if (!Entity.IsValid(targetIndex) || !Entity.IsAlive(targetIndex)) {
  100.         return;
  101.     }
  102.     targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  103.     localPos = Entity.GetHitboxPosition(local, 5);
  104.     if (calcDist(localPos, targetPos) >= 2000)
  105.         return;
  106.     var worldPos = Entity.GetRenderOrigin(targetIndex);
  107.     var loc = Render.WorldToScreen(worldPos);
  108.     var color = UI.GetColor("Script items", "[AHC] Target Indicator");
  109.     Render.Circle(loc[0], loc[1] - 142, 20, color);
  110.     Render.String(loc[0] - 7, loc[1] - 160, 0, "!", color, 24);
  111. }
  112.  
  113. function drawInMenu() {
  114.     var opts = UI.GetString("[AHC] Weapon Config");
  115.     var dt = UI.GetValue("[AHC] Adaptive Doubletap");
  116.     var inAir = UI.GetValue("[AHC] In-Air HC");
  117.     for (var weapon in wepList) {
  118.         UI.SetEnabled("Script items", wepList[weapon] + " Max HC", opts == wepList[weapon]);
  119.         UI.SetEnabled("Script items", wepList[weapon] + " Min HC", opts == wepList[weapon]);
  120.         UI.SetEnabled("Script items", wepList[weapon] + " Playstyle", opts == wepList[weapon]);
  121.     }
  122.     UI.SetEnabled("Script items", "SMG In-Air HC", opts == "SMG" && inAir);
  123.     UI.SetEnabled("Script items", "Scout In-Air HC", opts == "Scout" && inAir);
  124.     UI.SetEnabled("Script items", "Heavy Pistol In-Air HC", opts == "Heavy Pistol" && inAir);
  125.     UI.SetEnabled("Script items", "Doubletap Max HC", dt);
  126.     UI.SetEnabled("Script items", "Doubletap Min HC", dt);
  127. }
  128.  
  129. function weaponType() {
  130.     var weapon = Entity.GetName(Entity.GetWeapon(local));
  131.     var weapons = {
  132.         "usp s": "Pistol",
  133.         "glock 18": "Pistol",
  134.         "p2000": "Pistol",
  135.         "dual berettas": "Pistol",
  136.         "r8 revolver": "Heavy Pistol",
  137.         "desert eagle": "Heavy Pistol",
  138.         "p250": "Pistol",
  139.         "tec9": "Pistol",
  140.         "mp9": "SMG",
  141.         "mac 10": "SMG",
  142.         "ump 45": "SMG",
  143.         "ak 47": "Rifle",
  144.         "sg 553": "Rifle",
  145.         "aug": "Rifle",
  146.         "m4a1 s": "Rifle",
  147.         "m4a4": "Rifle",
  148.         "ssg 08": "Scout",
  149.         "awp": "AWP",
  150.         "g3sg1": "Auto",
  151.         "scar 20": "Auto"
  152.     };
  153.     return weapons[weapon];
  154. }
  155.  
  156. function adjustHitchance(distance) {
  157.     if (weaponType() == undefined)
  158.         return;
  159.     maxHC = UI.GetValue("Script items", weaponType() + " Max HC", "Integer");
  160.     minHC = UI.GetValue("Script items", weaponType() + " Min HC", "Integer");
  161.     dtMaxHC = UI.GetValue("Script items", "Doubletap Max HC");
  162.     dtMinHC = UI.GetValue("Script items", "Doubletap Min HC");
  163.     fv = Entity.GetProp(local, "CBasePlayer", "m_flFallVelocity");
  164.     inAir = false;
  165.     if (fv < -1 || fv > 1)
  166.         inAir = true;
  167.     else
  168.         inAir = false;
  169.     if (weaponType() == undefined)
  170.         return;
  171.     playstyle = UI.GetString("Script items", weaponType() + " Playstyle");
  172.     mode = UI.GetString("Script items", "[AHC] Mode");
  173.  
  174.     if (UI.GetValue("[AHC] Adaptive Doubletap")) {
  175.         dtVal = playstyle == "Agressive" ? dtEquation(dtMinHC, dtMaxHC) - 30 : dtEquation(dtMinHC, dtMaxHC);
  176.         UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap hitchance", dtVal);
  177.     }
  178.     inAirHC = UI.GetValue("Script items", weaponType() + " In-Air HC", "Integer");
  179.     hcVal = playstyle == "Agressive" ? hcEquation(minHC, maxHC) - 15 : hcEquation(minHC, maxHC);
  180.     inAirVal = playstyle == "Agressive" ? inAirHC - 15 : inAirHC;
  181.  
  182.     if(hcVal == undefined || hcVal < 0)
  183.         hcVal = minHC;
  184.  
  185.     if (weaponType() == "SMG" || weaponType() == "Rifle")
  186.         UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  187.     else
  188.         UI.SetValue("Rage", weaponType().toUpperCase(), "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  189.  
  190.     function hcEquation(min, max) {
  191.         if (mode == "Decreasing")
  192.             return Math.round(Math.min(Math.max((1 / 250) * (100 * (distance / 20)) + min, min), max));
  193.         else
  194.         if (mode == "Increasing")
  195.             return Math.round(Math.min(Math.max((-1 / 250) * (100 * (distance / 20)) + max, min), max));
  196.     }
  197.  
  198.     function dtEquation(min, max) {
  199.         if (mode == "Decreasing")
  200.             return Math.round(Math.min(Math.max((1 / 125) * (100 * (distance / 20)) + min, min), max));
  201.         else
  202.         if (mode == "Increasing")
  203.             return Math.round(Math.min(Math.max((-1 / 125) * (100 * (distance / 20)) + max, min), max));
  204.     }
  205. }
  206.  
  207. function setup() {
  208.     UI.AddCheckbox("[AHC] Enable Adaptive Hitchance");
  209.     UI.AddCheckbox("[AHC] Show Indicators");
  210.     UI.AddColorPicker("[AHC] Target Indicator");
  211.     UI.SetColor("Script items", "[AHC] Target Indicator", [255, 0, 255, 255]);
  212.     UI.AddDropdown("[AHC] Mode", ["Increasing", "Decreasing"]);
  213.     UI.AddCheckbox("[AHC] In-Air HC");
  214.     UI.AddCheckbox("[AHC] Adaptive Doubletap");
  215.     UI.AddSliderInt("Doubletap Max HC", 0, 100);
  216.     UI.AddSliderInt("Doubletap Min HC", 0, 100);
  217.     UI.AddDropdown("[AHC] Weapon Config", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"]);
  218.     for (weapon in wepList) {
  219.         UI.AddDropdown(wepList[weapon] + " Playstyle", ["Agressive", "Passive"]);
  220.         UI.AddSliderInt(wepList[weapon] + " Max HC", 0, 100);
  221.         UI.AddSliderInt(wepList[weapon] + " Min HC", 0, 100);
  222.     }
  223.     UI.AddSliderInt("Scout In-Air HC", 0, 100);
  224.     UI.AddSliderInt("SMG In-Air HC", 0, 100);
  225.     UI.AddSliderInt("Heavy Pistol In-Air HC", 0, 100);
  226.     Global.PrintColor([255, 75, 100, 25],
  227.         "\n------------------------\n[AHC] v1.0 by Ultranite\n------------------------\n");
  228.  
  229.     /*
  230.     *            HOW TO CONFIG SETTINGS
  231.     *  You can set a default value by doing the following: 
  232.     *  UI.SetValue("Script items", "name of option/slider", value);
  233.     *
  234.     *  In order to pick a mode or playstyle, simply set 0 for increasing/agressive (accordingly)
  235.     *  and 1 for decreasing/passive.
  236.     *
  237.     *  Checkboxes are set as true/false.
  238.     *
  239.     *  Colors can be set in the format of [r,g,b,alpha]
  240.     *
  241.     *  If you ever wonder how to use something, check the forums:
  242.     *  https://onetap.su/resources/
  243.     *
  244.     *  Add me on discord @Ultranite#9259 for help.
  245.     *
  246.     */
  247.  
  248.     // MAIN SETTINGS
  249.     UI.SetValue("Script items", "[AHC] Enable Adaptive Hitchance", false);
  250.     UI.SetValue("Script items", "[AHC] Show Indicators", false);
  251.     UI.SetValue("Script items", "[AHC] Mode", 0);
  252.     UI.SetValue("Script items", "[AHC] In-Air HC", false);
  253.     UI.SetValue("Script items", "[AHC] Adaptive Doubletap", false);
  254.     UI.SetValue("Script items", "Doubletap Max HC", 0);
  255.     UI.SetValue("Script items", "Doubletap Min HC", 0);
  256.  
  257.     // PER WEAPON
  258.     UI.SetValue("Script items", "Auto Playstyle", 0);
  259.     UI.SetValue("Script items", "Auto Max HC", 0);
  260.     UI.SetValue("Script items", "Auto Min HC", 0);
  261.  
  262.     UI.SetValue("Script items", "Scout Playstyle", 0);
  263.     UI.SetValue("Script items", "Scout Max HC", 0);
  264.     UI.SetValue("Script items", "Scout Min HC", 0);
  265.     UI.SetValue("Script items", "Scout In-Air HC", 0);
  266.  
  267.     UI.SetValue("Script items", "Rifle Playstyle", 0);
  268.     UI.SetValue("Script items", "Rifle Max HC", 0);
  269.     UI.SetValue("Script items", "Rifle Min HC", 0);
  270.  
  271.     UI.SetValue("Script items", "SMG Playstyle", 0);
  272.     UI.SetValue("Script items", "SMG Max HC", 0);
  273.     UI.SetValue("Script items", "SMG Min HC", 0);
  274.     UI.SetValue("Script items", "SMG In-Air HC", 0);
  275.  
  276.     UI.SetValue("Script items", "Pistol Playstyle", 0);
  277.     UI.SetValue("Script items", "Pistol Max HC", 0);
  278.     UI.SetValue("Script items", "Pistol Min HC", 0);
  279.  
  280.     UI.SetValue("Script items", "Heavy Pistol Playstyle", 0);
  281.     UI.SetValue("Script items", "Heavy Pistol Max HC", 0);
  282.     UI.SetValue("Script items", "Heavy Pistol Min HC", 0);
  283.     UI.SetValue("Script items", "Heavy Pistol In-Air HC", 0);
  284.  
  285.  
  286.  
  287.  
  288. }
  289. runTime = Global.Curtime();
  290. var secondsElapsed = 0;
  291.  
  292. function check() {
  293.     if (waiting == 1) {
  294.         if (Global.Curtime() - runTime > 1) {
  295.             secondsElapsed += 1;
  296.             runTime = Global.Curtime();
  297.         }
  298.     }
  299. }
  300.  
  301. /* --------- */
  302. /* Callbacks */
  303. Global.RegisterCallback("Draw", "pickTarget");
  304. Global.RegisterCallback('Draw', 'check');
  305. Global.RegisterCallback("Draw", "drawIndicator");
  306. Global.RegisterCallback("Draw", "drawInMenu");
  307. Global.RegisterCallback("ragebot_fire", "onShot");
  308. /* --------- */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top