SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name                Krunker.io Skid
  3. // @namespace           https://github.com/skidlamer
  4. // @author              SkidLamer
  5. // @version             1.7.8
  6. // @description         A cheat for krunker.io
  7. // @downloadURL         https://skidlamer.github.io/js/krunker_skid.user.js
  8. // @supportURL          https://github.com/skidlamer/skidlamer.github.io
  9. // @match               *://krunker.io/*
  10. // @require https://greasyfork.org/scripts/2350-filesaver-js/code/filesaverjs.js
  11. // @run-at              document-start
  12. // @grant               none
  13. // ==/UserScript==
  14. // Please Do not copy and paste this script to greasy fork and pretend you made it its lame/r I can and will give you the hose again
  15. // Discord Krunker Heros - https://discord.gg/Emkf5by
  16. // hook - credit to @lemons - https://github.com/Lemons1337
  17. // esp - credit to @techy - https://www.gitmemory.com/Tehchy
  18. // game - credit to @sidney - https://twitter.com/sidney_de_vries?lang=en
  19. // other excellent krunker cheat script developers:
  20. // @lemons - https://github.com/Lemons1337
  21. // @funk - https://github.com/funk
  22. // @masterP - https://github.com/MasterP-kr
  23.  
  24. class Utilities {
  25.     constructor() {
  26.         this.exports;
  27.         this.ui;
  28.         this.me;
  29.         this.world;
  30.         this.inputs;
  31.         this.control;
  32.         this.socket;
  33.         this.server;
  34.         this.downKeys = new Set();
  35.         this.upKeys = new Set();
  36.         this.menus = new Map();
  37.         this.features = [];
  38.         this.colors = ['Green', 'Orange', 'DodgerBlue', 'Black', 'Red'];
  39.         this.settings = {
  40.             showMenu: true,
  41.             autoAimWalls: 0,
  42.             espMode: 4,
  43.             espColor: 0,
  44.             espFontSize: 14,
  45.             canShoot: true,
  46.             scopingOut: false,
  47.             isSliding: false,
  48.             delta:1,
  49.             deathDelay:2800,
  50.             roogyMath:false,
  51.         }
  52.         this.activeMenuIndex = 0;
  53.         this.activeLineIndex = 0;
  54.         this.canvas = null;
  55.         this.ctx = null;
  56.         let interval_ui = setInterval(() => {
  57.             if (document.getElementById("inGameUI") !== null) {
  58.                 clearInterval(interval_ui);
  59.                 this.onLoad();
  60.             }
  61.         }, 100);
  62.     }
  63.  
  64.     onLoad() {
  65.         addEventListener("keydown", e => {
  66.             if ("INPUT" == window.document.activeElement.tagName) return;
  67.             const key = e.key.toUpperCase();
  68.             const code = e.code;
  69.             if (!this.downKeys.has(code)) this.downKeys.add(code);
  70.         });
  71.         addEventListener("keyup", e => {
  72.             const key = e.key.toUpperCase();
  73.             const code = e.code;
  74.             if (this.downKeys.has(code)) this.downKeys.delete(code);
  75.             if (!this.upKeys.has(code)) this.upKeys.add(code);
  76.  
  77.             if (key === "L") {
  78.                 console.dir(self);
  79.                 console.dir(this.me);
  80.                 console.dir(this.world);
  81.                 console.dir(this.server);
  82.                 console.dir(this.socket);
  83.             }
  84.         })
  85.  
  86.         this.menus
  87.         .set('Krunker Skid', [this.newFeature('Self', []), this.newFeature('Weapon', []), this.newFeature('Visual', []), this.newFeature('Settings', [])])
  88.         .set('Self', [this.newFeature('AutoBhop', ['Off', 'Auto Jump', 'Auto Slide']), /*this.newFeature('NoDeathDelay', ['Off', 'On']),*/ this.newFeature('SkidSettings', ['Off', 'On'])])
  89.         .set('Weapon', [this.newFeature('AutoAim', ['Off', 'Aim Assist', 'Aim Bot', 'Trigger Bot']), this.newFeature('AutoReload', ['Off', 'On']), this.newFeature('Aim Through Walls', ['Off', 'On']), this.newFeature('UseDeltaForce', ['Off', 'On']), this.newFeature('AlternateAim', ['Off', 'On'])])
  90.         .set('Visual', [this.newFeature('EspMode', ['Off', 'Full', '2d', 'Walls']), this.newFeature('Tracers', ['Off', 'On'])])
  91.         .set('Settings', [this.newFeature('Reset', [], this.resetSettings), this.newFeature('Save game.js', [], _=>{self.saveAs(new Blob([self.GameScript], {type: "text/plain;charset=utf-8"}), `game.js`)})])
  92.     }
  93.  
  94.     keyDown(code) {
  95.         return this.downKeys.has(code);
  96.     }
  97.  
  98.     keyUp(code) {
  99.         if (this.upKeys.has(code)) {
  100.             this.upKeys.delete(code);
  101.             return true;
  102.         }
  103.         return false;
  104.     }
  105.  
  106.     byte2Hex(n) {
  107.         var chars = "0123456789ABCDEF";
  108.         return String(chars.substr((n >> 4) & 0x0F,1)) + chars.substr(n & 0x0F,1);
  109.     }
  110.  
  111.     rgba2hex(r,g,b,a = 255) {
  112.         return ("#").concat(this.byte2Hex(r),this.byte2Hex(g),this.byte2Hex(b),this.byte2Hex(a));
  113.     }
  114.  
  115.     onTick(me, world, inputs) {
  116.         this.me = me;
  117.         this.world = world;
  118.         this.inputs = inputs;
  119.         this.server=this.exports.c[7].exports;
  120.         for (let i = 0, sz = this.features.length; i < sz; i++) {
  121.             const feature = this.features[i];
  122.             switch (feature.name) {
  123.                 case 'AutoAim':
  124.                     this.autoAim(feature.value);
  125.                     break;
  126.                 case 'AutoReload':
  127.                     if (feature.value) this.wpnReload();
  128.                     break;
  129.                 case 'AutoBhop':
  130.                     this.autoBhop(feature.value);
  131.                     break;
  132.                 ///case 'NoDeathDelay':
  133.                     //this.settings.deathDelay = feature.value ? 0 : 2800;
  134.                     //break;
  135.                 case 'EspMode':
  136.                     this.settings.espMode = feature.value;
  137.                     break;
  138.                 case 'SkidSettings':
  139.                     if (feature.value) new Map([ ["fov", 85], ["fpsFOV", 85], ["weaponBob", 3], ["weaponLean", 6], ["weaponOffX", 2], ["weaponOffY", 2], ["weaponOffZ", 2] ]).forEach(function(value, key, map) { window.setSetting(key, value) });
  140.                     break;
  141.                 case 'UseDeltaForce':
  142.                     this.settings.delta = feature.value ? 5 : 1;
  143.                     break;
  144.                 case 'AlternateAim':
  145.                     this.settings.roogyMath = feature.value;
  146.                     break;
  147.             }
  148.         }
  149.     }
  150.  
  151.     resetSettings() {
  152.         if (confirm("Are you sure you want to reset all your skid settings? This will also refresh the page")) {
  153.             Object.keys(window.localStorage).filter(x => x.includes("utilities_")).forEach(x => window.localStorage.removeItem(x));
  154.             window.location.reload();
  155.         }
  156.     }
  157.  
  158.     newFeature(name, array, myFunction = null) {
  159.         const cStruct = (...keys) => ((...v) => keys.reduce((o, k, i) => {
  160.             o[k] = v[i];
  161.             return o
  162.         }, {}));
  163.         var item = [];
  164.         const myStruct = cStruct('name', 'value', 'valueStr', 'container', 'myFunction')
  165.         const value = parseInt(window.getSavedVal("utilities_" + name) || 0);
  166.         const feature = myStruct(name, value, array.length ? array[value] : '', array, myFunction);
  167.         if (array.length||myFunction) this.features.push(feature);
  168.         item.push(feature);
  169.         return item;
  170.     }
  171.  
  172.     getFeature(name) {
  173.         for (const feature of this.features) {
  174.             if (feature.name.toLowerCase() === name.toLowerCase()) {
  175.                 return feature;
  176.             }
  177.         }
  178.         return null;
  179.     }
  180.  
  181.     onUpdated(feature) {
  182.         if (feature.container.length) {
  183.             feature.value += 1;
  184.             if (feature.value > feature.container.length - 1) {
  185.                 feature.value = 0;
  186.             }
  187.             feature.valueStr = feature.container[feature.value];
  188.             window.saveVal("utilities_" + feature.name, feature.value);
  189.         }
  190.         if (feature.container.length == 2 && feature.container[0] == 'Off' && feature.container[1] == 'On') {
  191.             console.log(feature.name, " is now ", feature.valueStr);
  192.             switch (feature.name) {
  193.                 case 'Aim Through Walls': this.settings.autoAimWalls = feature.value;
  194.                     break;
  195.             }
  196.         }
  197.     }
  198.  
  199.     getDistance3D(fromX, fromY, fromZ, toX, toY, toZ) {
  200.         var distX = fromX - toX,
  201.             distY = fromY - toY,
  202.             distZ = fromZ - toZ;
  203.         return Math.sqrt(distX * distX + distY * distY + distZ * distZ);
  204.     }
  205.  
  206.     getDistance(player1, player2) {
  207.         return this.getDistance3D(player1.x, player1.y, player1.z, player2.x, player2.y, player2.z);
  208.     }
  209.  
  210.     getDirection(fromZ, fromX, toZ, toX) {
  211.         return Math.atan2(fromX - toX, fromZ - toZ);
  212.     }
  213.  
  214.     getXDir(fromX, fromY, fromZ, toX, toY, toZ) {
  215.         var dirY = Math.abs(fromY - toY),
  216.             dist = this.getDistance3D(fromX, fromY, fromZ, toX, toY, toZ);
  217.         return Math.asin(dirY / dist) * (fromY > toY ? -1 : 1);
  218.     }
  219.  
  220.     getAngleDist(start, end) {
  221.         return Math.atan2(Math.sin(end - start), Math.cos(start - end));
  222.     }
  223.  
  224.     camLookAt(X, Y, Z) {
  225.         const currentXDR = this.control.xDr;
  226.         const currentYDR = this.control.yDr;
  227.         var xdir = this.getXDir(this.control.object.position.x, this.control.object.position.y, this.control.object.position.z, X, Y, Z),
  228.             ydir = this.getDirection(this.control.object.position.z, this.control.object.position.x, Z, X),
  229.             camChaseDst = this.server.camChaseDst;
  230.         this.control.target = {
  231.             xD: xdir,
  232.             yD: ydir,
  233.             x: X + camChaseDst * Math.sin(ydir) * Math.cos(xdir),
  234.             y: Y - camChaseDst * Math.sin(xdir),
  235.             z: Z + camChaseDst * Math.cos(ydir) * Math.cos(xdir)
  236.         }
  237.         this.control.xDr = currentXDR;
  238.         this.control.yDr = currentYDR;
  239.     }
  240.  
  241.     lookAt(target) {
  242.         !this.settings.roogyMath ?
  243.         this.camLookAt(target.x2, target.y2 + target.height - target.headScale / 2 - this.server.crouchDst * target.crouchVal - this.me.recoilAnimY * this.server.recoilMlt * 25, target.z2):
  244.         this.camLookAt(target.x2, target.y2 + target.height - 1.5 - 2.5 * target.crouchVal - this.me.recoilAnimY * 0.3 * 25, target.z2);
  245.     }
  246.  
  247.     getStatic(s, d) {
  248.         if (typeof s == 'undefined') {
  249.             return d;
  250.         }
  251.         return s;
  252.     }
  253.  
  254.     teamColor(player) {
  255.         return player.team === null ? '#FF4444' : this.me.team === player.team ? '#44AAFF' : '#FF4444';
  256.     }
  257.  
  258.     getTarget() {
  259.         const players = this.world.players.list.filter(player => { return player.active && !player.isYou });
  260.         const targets = players.filter(player => {
  261.             return player.isSeen && (!player.team || player.team !== this.me.team)
  262.         }).sort((p1, p2) => this.getDistance(this.me, p1) - this.getDistance(this.me, p2));
  263.         return targets[0];
  264.     }
  265.  
  266.     autoAim(value) {
  267.         if (!value) return;
  268.         var lockedOn = false;
  269.         const target = this.getTarget();
  270.         if (this.me.didShoot) {
  271.             this.settings.canShoot = false;
  272.             setTimeout(() => {
  273.                 this.settings.canShoot = true;
  274.             }, this.me.weapon.rate / 1.85);
  275.         }
  276.         if (target) {
  277.             switch (value) {
  278.                 case 1:
  279.                     /*Aim Assist*/
  280.                     if (this.control.mouseDownR === 1) {
  281.                         this.world.config.deltaMlt = this.settings.delta;
  282.                         this.lookAt(target);
  283.                         this.world.config.deltaMlt = 1;
  284.                         lockedOn = true;
  285.                     } else {
  286.                         lockedOn = false;
  287.                     }
  288.                     break;
  289.                 case 2:
  290.                     /*Aim Bot*/
  291.                     if (this.control.mouseDownL === 1) {
  292.                         this.control.mouseDownL = 0;
  293.                         this.control.mouseDownR = 0;
  294.                         this.settings.scopingOut = true;
  295.                     }
  296.                     if (this.me.aimVal === 1) {
  297.                         this.settings.scopingOut = false;
  298.                     }
  299.                     if (!this.settings.scopingOut && this.settings.canShoot && this.me.recoilForce <= 0.01) {
  300.                         this.world.config.deltaMlt = this.settings.delta;
  301.                     this.lookAt(target);
  302.                         if (this.control.mouseDownR !== 2) {
  303.                         this.control.mouseDownR = 2;
  304.                         }
  305.                         lockedOn = true;
  306.                         this.world.config.deltaMlt = 1;
  307.                     }   else lockedOn = false;
  308.                     break;
  309.                 case 3:
  310.                     /*Trigger Bot*/
  311.                     lockedOn = this.quickscoper(target);
  312.                     break;
  313.                 default: break;
  314.             }
  315.         }
  316.         if (!lockedOn) {
  317.             this.world.config.deltaMlt = 1;
  318.             this.camLookAt(0, 0, 0);
  319.             this.control.target = null;
  320.             if (this.control.mouseDownR == 2) {
  321.                 this.control.mouseDownR = 0;
  322.             }
  323.         }
  324.     }
  325.  
  326.     quickscoper(target) {
  327.         if (this.control.mouseDownL === 1) {
  328.             this.control.mouseDownL = 0;
  329.             this.control.mouseDownR = 0;
  330.             this.settings.scopingOut = true;
  331.         }
  332.  
  333.         if (this.me.aimVal === 1) {
  334.             this.settings.scopingOut = false;
  335.         }
  336.  
  337.         if (this.settings.scopingOut || !this.settings.canShoot) {
  338.             return false;
  339.         }
  340.  
  341.         if (this.me.recoilForce > 0.01) {
  342.             this.world.config.deltaMlt = 1;
  343.             return false;
  344.         }
  345.  
  346.         this.world.config.deltaMlt = this.settings.delta;
  347.         this.lookAt(target);
  348.         if (this.control.mouseDownR !== 2) {
  349.             this.control.mouseDownR = 2;
  350.         }
  351.  
  352.         if (this.me.aimVal < 0.2) {
  353.             this.world.config.deltaMlt = this.settings.delta;
  354.             this.lookAt(target);
  355.             this.control.mouseDownL ^= 1;
  356.             this.world.config.deltaMlt = 1;
  357.         }
  358.  
  359.         return true;
  360.     }
  361.  
  362.     autoBhop(value) {
  363.         if (!value) return;
  364.         if (this.keyDown("Space")) {
  365.             this.control.keys[this.control.jumpKey] = !this.control.keys[this.control.jumpKey];
  366.             if (value === 2) {
  367.                 if (this.settings.isSliding) {
  368.                     this.inputs[8] = 1;
  369.                     return;
  370.                 }
  371.                 if (this.me.yVel < -0.04 && this.me.canSlide) {
  372.                     this.settings.isSliding = true;
  373.                     setTimeout(() => {
  374.                         this.settings.isSliding = false;
  375.                     }, this.me.slideTimer);
  376.                     this.inputs[8] = 1;
  377.                 }
  378.             }
  379.         }
  380.     }
  381.  
  382.     wpnReload(force = false) {
  383.         //(inputs[9] = me.ammos[me.weaponIndex] === 0);
  384.         const ammoLeft = this.me.ammos[this.me.weaponIndex];
  385.         if (force || ammoLeft === 0) {
  386.             this.world.players.reload(this.me);
  387.             if (ammoLeft) this.world.players.endReload(this.me.weapon);
  388.         }
  389.     }
  390.  
  391.      world2Screen(camera, pos3d, aY = 0) {
  392.         let pos = pos3d.clone();
  393.         pos.y += aY;
  394.         pos.project(camera);
  395.         pos.x = (pos.x + 1) / 2;
  396.         pos.y = (-pos.y + 1) / 2;
  397.         pos.x *= this.canvas.width || innerWidth;
  398.         pos.y *= this.canvas.height || innerHeight;
  399.         return pos;
  400.     }
  401.  
  402.     pixelTranslate(ctx, x, y) {
  403.         ctx.translate(~~x, ~~y);
  404.     }
  405.  
  406.     text(txt, font, color, x, y) {
  407.         this.ctx.save();
  408.         this.pixelTranslate(this.ctx, x, y);
  409.         this.ctx.fillStyle = color;
  410.         this.ctx.strokeStyle = "rgba(0, 0, 0, 0.5)";
  411.         this.ctx.font = font;
  412.         this.ctx.lineWidth = 1;
  413.         this.ctx.strokeText(txt, 0, 0);
  414.         this.ctx.fillText(txt, 0, 0);
  415.         this.ctx.restore();
  416.     }
  417.  
  418.     rect(x, y, ox, oy, w, h, color, fill) {
  419.         this.ctx.save();
  420.         this.pixelTranslate(this.ctx, x, y);
  421.         this.ctx.beginPath();
  422.         fill ? this.ctx.fillStyle = color : this.ctx.strokeStyle = color;
  423.         this.ctx.rect(ox, oy, w, h);
  424.         fill ? this.ctx.fill() : this.ctx.stroke();
  425.         this.ctx.closePath();
  426.         this.ctx.restore();
  427.     }
  428.  
  429.     line(x1, y1, x2, y2, lW, sS) {
  430.         this.ctx.save();
  431.         this.ctx.lineWidth = lW + 2;
  432.         this.ctx.beginPath();
  433.         this.ctx.moveTo(x1, y1);
  434.         this.ctx.lineTo(x2, y2);
  435.         this.ctx.strokeStyle = "rgba(0, 0, 0, 0.25)";
  436.         this.ctx.stroke();
  437.         this.ctx.lineWidth = lW;
  438.         this.ctx.strokeStyle = sS;
  439.         this.ctx.stroke();
  440.         this.ctx.restore();
  441.     }
  442.  
  443.     image(x, y, img, ox, oy, w, h) {
  444.         this.ctx.save();
  445.         this.ctx.translate(x, y);
  446.         this.ctx.beginPath();
  447.         this.ctx.drawImage(img, ox, oy, w, h);
  448.         this.ctx.closePath();
  449.         this.ctx.restore();
  450.     }
  451.  
  452.     gradient(x, y, w, h, colors) {
  453.         let grad = this.ctx.createLinearGradient(x, y, w, h);
  454.         for (let i = 0; i < colors.length; i++) {
  455.             grad.addColorStop(i, colors[i]);
  456.         }
  457.         return grad;
  458.     }
  459.  
  460.     getTextMeasurements(arr) {
  461.         for (let i = 0; i < arr.length; i++) {
  462.             arr[i] = ~~this.ctx.measureText(arr[i]).width;
  463.         }
  464.         return arr;
  465.     }
  466.  
  467.     drawEsp(ui, world, myself) {
  468.         const me = ui.camera.getWorldPosition()
  469.         for (const entity of world.players.list.filter(x => !x.isYou && x.active)) {
  470.             //if (!entity.rankIcon && entity.level > 0) {
  471.             //  let rankVar = entity.level > 0 ? Math.ceil(entity.level / 3) * 3 : entity.level < 0 ? Math.floor(entity.level / 3) * 3 : entity.level;
  472.             //  let rankId = Math.max(Math.min(100, rankVar - 2), 0);
  473.             //  entity.rankIcon = new Image();
  474.             //  entity.rankIcon.src = `./img/levels/${rankId}.png`;
  475.             //}
  476.             const target = entity.objInstances.position.clone();
  477.             if (ui.frustum.containsPoint(target)) {
  478.                 let screenR = this.world2Screen(ui.camera, entity.objInstances.position.clone());
  479.                 let screenH = this.world2Screen(ui.camera, entity.objInstances.position.clone(), entity.height);
  480.                 let hDiff = ~~(screenR.y - screenH.y);
  481.                 let bWidth = ~~(hDiff * 0.6);
  482.                 const color = this.colors[this.settings.espColor];
  483.                 if (this.settings.espMode > 0 && this.settings.espMode != 3) {
  484.                     this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, 0, 0, 4, hDiff + 2, '#000000', false);
  485.                     this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, 0, 0, 4, hDiff + 2, '#44FF44', true);
  486.                     this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, 0, 0, 4, ~~((entity.maxHealth - entity.health) / entity.maxHealth * (hDiff + 2)), '#000000', true);
  487.                     this.ctx.save();
  488.                     this.ctx.lineWidth = 4;
  489.                     this.pixelTranslate(this.ctx, screenH.x - bWidth / 2, screenH.y);
  490.                     this.ctx.beginPath();
  491.                     this.ctx.rect(0, 0, bWidth, hDiff);
  492.                     this.ctx.strokeStyle = "rgba(0, 0, 0, 0.25)";
  493.                     this.ctx.stroke();
  494.                     this.ctx.lineWidth = 2;
  495.                     this.ctx.strokeStyle = entity.team === null ? '#FF4444' : myself.team === entity.team ? '#44AAFF' : '#FF4444';
  496.                     this.ctx.stroke();
  497.                     this.ctx.closePath();
  498.                     this.ctx.restore();
  499.                     if (this.settings.espMode === 1) {
  500.                         let playerDist = parseInt(this.getDistance3D(me.x, me.y, me.z, target.x, target.y, target.z) / 10);
  501.                         this.ctx.save();
  502.                         this.ctx.font = this.settings.espFontSize + 'px GameFont';
  503.                         let meas = this.getTextMeasurements([" ", playerDist, "m ", entity.level, "©", entity.name]);
  504.                         this.ctx.restore();
  505.                         let grad2 = this.gradient(0, 0, meas[4] * 5, 0, ["rgba(0, 0, 0, 0.25)", "rgba(0, 0, 0, 0)"]);
  506.                         let padding = 2;
  507.                         //if (entity.rankIcon && entity.rankIcon.complete) {
  508.                         //  let grad = this.gradient(0, 0, (meas[4] * 2) + meas[3] + (padding * 3), 0, ["rgba(0, 0, 0, 0)", "rgba(0, 0, 0, 0.25)"]);
  509.                         //  this.rect(~~(screenH.x - bWidth / 2) - 12 - (meas[4] * 2) - meas[3] - (padding * 3), ~~screenH.y - padding, 0, 0, (meas[4] * 2) + meas[3] + (padding * 3), meas[4] + (padding * 2), grad, true);
  510.                         //  this.ctx.drawImage(entity.rankIcon, ~~(screenH.x - bWidth / 2) - 16 - (meas[4] * 2) - meas[3], ~~screenH.y - (meas[4] * 0.5), entity.rankIcon.width * ((meas[4] * 2) / entity.rankIcon.width), entity.rankIcon.height * ((meas[4] * 2) / entity.rankIcon.height));
  511.                         //  this.text(`${entity.level}`, `${this.settings.espFontSize}px GameFont`, '#FFFFFF', ~~(screenH.x - bWidth / 2) - 16 - meas[3], ~~screenH.y + meas[4] * 1);
  512.                         //}
  513.                         this.rect(~~(screenH.x + bWidth / 2) + padding, ~~screenH.y - padding, 0, 0, (meas[4] * 5), (meas[4] * 4) + (padding * 2), grad2, true);
  514.                         this.text(entity.name, this.settings.espFontSize+'px GameFont', entity.team === null ? '#FFCDB4' : myself.team === entity.team ? '#B4E6FF' : '#FFCDB4', (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 1)
  515.                         if (entity.clan) this.text('['+entity.clan+']', this.settings.espFontSize+'px GameFont', '#AAAAAA', (screenH.x + bWidth / 2) + 8 + meas[5], screenH.y + meas[4] * 1)
  516.                         this.text(entity.health+' HP', this.settings.espFontSize+'px GameFont', "#33FF33", (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 2)
  517.                         this.text(entity.weapon.name, this.settings.espFontSize+'px GameFont', "#DDDDDD", (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 3)
  518.                         this.text("[", this.settings.espFontSize+'px GameFont', "#AAAAAA", (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 4)
  519.                         this.text(playerDist, this.settings.espFontSize+'px GameFont', "#DDDDDD", (screenH.x + bWidth / 2) + 4 + meas[0], screenH.y + meas[4] * 4)
  520.                         this.text("m]", this.settings.espFontSize+'px GameFont', "#AAAAAA", (screenH.x + bWidth / 2) + 4 + meas[0] + meas[1], screenH.y + meas[4] * 4)
  521.                     }
  522.                 }
  523.                 const tracers = this.getFeature('Tracers');
  524.                 if (tracers && tracers.value) if (this.settings.espMode === 1 || this.settings.espMode === 2) this.line(innerWidth / 2, innerHeight - 1, screenR.x, screenR.y, 2, entity.team === null ? '#FF4444' : myself.team === entity.team ? '#44AAFF' : '#FF4444');
  525.             }
  526.         }
  527.     }
  528.  
  529.     drawMenuLine(item, lineWidth, lineHeight, lineTop, lineLeft, textLeft, active, title, rescaleText = true)
  530.     {
  531.         // default values
  532.         let text_col = [255, 255, 255, 255],
  533.             rect_col = [0, 0, 0, 120],
  534.             text_scale = 20,
  535.             font = 'px sans-serif';
  536.  
  537.         // active line values
  538.         if (active) {
  539.             text_col[0] = 0;
  540.             text_col[1] = 0;
  541.             text_col[2] = 0;
  542.             rect_col[0] = 231;
  543.             rect_col[1] = 231;
  544.             rect_col[2] = 231;
  545.             if (rescaleText) text_scale = 21;
  546.         }
  547.  
  548.         // title values
  549.         if (title)
  550.         {
  551.             rect_col[0] = 70;
  552.             rect_col[1] = 90;
  553.             rect_col[2] = 90;
  554.             rect_col[3] = 255;
  555.             if (rescaleText) text_scale = 20;
  556.             font = 'px GameFont';
  557.             textLeft = lineWidth / 2 - this.getTextMeasurements([item.name]);
  558.         }
  559.  
  560.         // rect
  561.         this.rect(lineLeft, lineTop, 0, 0, lineWidth, (lineHeight * 2), this.rgba2hex(rect_col[0],rect_col[1],rect_col[2],rect_col[3]), true);
  562.  
  563.         // text
  564.         this.text(item.name, text_scale+font, this.rgba2hex(text_col[0],text_col[1],text_col[2]), textLeft, lineTop + lineHeight + lineHeight/2);
  565.  
  566.         // value
  567.         this.text(item.valueStr, text_scale+font, item.valueStr == "On" ? "#B2F252" : item.valueStr == "Off" ? "#FF4444" : active ? "#333333" : "#999EA5", lineWidth - textLeft * 1.5 - this.getTextMeasurements([item.valueStr]), lineTop + lineHeight + lineHeight/2);
  568.     }
  569.  
  570.     drawMenuItem(caption) {
  571.         const top = 280;
  572.         const left = 20;
  573.         const lineWidth = 320;
  574.         const items = this.menus.get(caption);
  575.         if (!items.length) return;
  576.         if (this.activeLineIndex > items.length -1) this.activeLineIndex = 0;
  577.  
  578.         // draw menu
  579.         this.drawMenuLine({name:caption,valueStr:''}, lineWidth, 22, top + 18, left, left + 5, false, true);
  580.         for (var i = 0; i < items.length; i++) {
  581.             if (i != this.activeLineIndex) this.drawMenuLine(items[i][0], lineWidth, 19, top + 60 + i * 36, left, left + 9, false, false);
  582.             this.drawMenuLine(items[this.activeLineIndex][0], lineWidth, 19, top + 60 + this.activeLineIndex * 36, left, left + 9, true, false);
  583.         }
  584.  
  585.         // process buttons
  586.         if (this.keyUp("Numpad5")||this.keyUp("ArrowRight")) {
  587.             self.SOUND.play('tick_0',0.1)
  588.             const feature = items[this.activeLineIndex][0];
  589.             if (feature) {
  590.                 if (feature.container.length) this.onUpdated(feature);
  591.                 else if (typeof feature.myFunction === "function") feature.myFunction();
  592.                 else this.activeMenuIndex = this.activeLineIndex + 1;
  593.             }
  594.         } else if (this.keyUp("Numpad0")||this.keyUp("ArrowLeft")) {
  595.             self.SOUND.play('tick_0',0.1);
  596.             if (this.activeMenuIndex > 0) this.activeMenuIndex = 0;
  597.             else this.settings.showMenu = false;
  598.             return;
  599.         } else if (this.keyUp("Numpad8")||this.keyUp("ArrowUp")) {
  600.             self.SOUND.play('tick_0',0.1)
  601.             if (this.activeLineIndex == 0) this.activeLineIndex = items.length;
  602.                 this.activeLineIndex--;
  603.         } else if (this.keyUp("Numpad2")||this.keyUp("ArrowDown")) {
  604.             self.SOUND.play('tick_0',0.1)
  605.             this.activeLineIndex++;
  606.             if (this.activeLineIndex == items.length) this.activeLineIndex = 0;
  607.         }
  608.     }
  609.  
  610.     drawMenu() {
  611.         if (this.settings.showMenu) {
  612.             switch(this.activeMenuIndex) {
  613.                 case 0: this.drawMenuItem('Krunker Skid'); break;
  614.                 case 1: this.drawMenuItem('Self'); break;
  615.                 case 2: this.drawMenuItem('Weapon'); break;
  616.                 case 3: this.drawMenuItem('Visual'); break;
  617.                 case 4: this.drawMenuItem('Settings'); break;
  618.                 default: break;
  619.             }
  620.         }
  621.         else if (this.keyUp("Numpad0")||this.keyUp("ArrowLeft")) {
  622.             self.SOUND.play('tick_0',0.1)
  623.             this.settings.showMenu = true;
  624.         }
  625.     }
  626.  
  627.     onRender(uiConfig, scale, world, ui, me, scale2) {
  628.         if (uiConfig)
  629.         {
  630.             uiConfig.crosshairAlways = true;
  631.             this.settings.espFontSize = uiConfig.dmgScale * 0.25;
  632.             this.canvas = uiConfig.canvas || document.getElementById("game-overlay");
  633.             this.ctx = this.canvas.getContext("2d");
  634.             this.ctx.save();
  635.             this.ctx.clearRect(0, 0, this.canvas.width || innerWidth, this.canvas.height || innerHeight);
  636.             if (world && ui && me )
  637.             {
  638.                 if ('none' == self.menuHolder.style.display && 'none' == self.endUI.style.display) {
  639.                     this.drawEsp(ui, world, me);
  640.                     this.drawMenu();
  641.                 }
  642.             }
  643.             this.ctx.restore();
  644.         }
  645.     }
  646. }
  647.  
  648. function patchGame(source) {
  649.     window.GameScript = source;
  650.     source = Utilities.toString().concat(source);
  651.     const patches = new Map()
  652.     .set("exports", [/(\['__CANCEL__']=.*?\(\w+,\w+,(\w+)\){)(let)/, '$1window.utilities=new Utilities();utilities.exports=$2;$3'])
  653.     .set("controlView", [/(if\(this\['target']\){)/, '$1this.object.rotation.y=this.target.yD;this.pitchObject.rotation.x=this.target.xD;const half=Math.PI/2;this.yDr=Math.max(-half,Math.min(half,this.target.xD))%Math.PI;this.xDr=this.target.yD%Math.PI;'])
  654.     .set("control", [/(=this;this\['gamepad'])/, '=utilities.control$1'])
  655.     .set("procInputs", [/(this\['procInputs']=function\((\w+),(\w+),(\w+)\){)/, '$1utilities.onTick(this,$3,$2);'])
  656.     .set("ui", [/(this,\w+={};this\['frustum'])/, 'utilities.ui=$1'])
  657.     .set("fixHowler", [/(Howler\['orientation'](.+?)\)\),)/, ``])
  658.     .set("clearRec", [/(if\(\w+\['save']\(\),\w+\['scale']\(\w+,\w+\),)\w+\['clearRect']\(0x0,0x0,\w+,\w+\),(\w+\['showDMG']\))/, '$1$2'])
  659.     .set("onRender", [/((\w+)\['render']=function\((\w+,\w+,\w+,\w+,\w+)\){)/, '$1utilities.onRender($2,$3);'])
  660.     .set("pInfo", [/(if\()(!\w+\['isSeen']\)continue;)/, '$1utilities.settings.espMode==1||utilities.settings.espMode==0&&$2'])
  661.     .set("wallhack", [/(\(((\w+))=this\['map']\['manager']\['objects']\[(\w+)]\))(.+?)\)/, '$1.penetrable&&$2.active&&!utilities.settings.autoAimWalls)'])
  662.     .set("socket", [/(new WebSocket)/, 'utilities.socket=$1'])
  663.     //.set("deathDelay", [/\w+\['deathDelay']/, 'utilities.settings.deathDelay'])
  664.     .set("fuckingLame", [/if\(!\w+&&!\w+&&!\w+&&\w+\['isView']\(this\)&&\w+\['isView']\(\w+\)/, 'if(!1'])
  665.  
  666.     for (const [name, item] of patches) {
  667.         const patched = source.replace(item[0], item[1]);
  668.         if (source === patched) {
  669.             alert(`Failed to patch ${name}`);
  670.             continue;
  671.         } else console.log("Successfully patched ", name);
  672.         source = patched;
  673.     }
  674.  
  675.     return source;
  676. }
  677.  
  678. // Hook - Lemons1337
  679. const decode = TextDecoder.prototype.decode;
  680. TextDecoder.prototype.decode = function() {
  681.     var code = decode.apply(this, arguments);
  682.  
  683.     if (code.length > /*Lemons*/1337 && code[0] === '!') {
  684.         code = patchGame(code);
  685.         TextDecoder.prototype.decode = decode;
  686.     }
  687.  
  688.     return code;
  689. }
  690.  
  691. document.addEventListener('DOMContentLoaded', _ => {
  692.     window.saveAs = saveAs;
  693. }, false);
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