Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.24 KB | None | 0 0
  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 @hrt - https://github.com/hrt/KrunkerBypass
  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. }
  51. this.activeMenuIndex = 0;
  52. this.activeLineIndex = 0;
  53. this.canvas = null;
  54. this.ctx = null;
  55. let interval_ui = setInterval(() => {
  56. if (document.getElementById("inGameUI") !== null) {
  57. clearInterval(interval_ui);
  58. this.onLoad();
  59. }
  60. }, 100);
  61. }
  62.  
  63. onLoad() {
  64. addEventListener("keydown", e => {
  65. if ("INPUT" == window.document.activeElement.tagName) return;
  66. const key = e.key.toUpperCase();
  67. const code = e.code;
  68. if (!this.downKeys.has(code)) this.downKeys.add(code);
  69. });
  70. addEventListener("keyup", e => {
  71. const key = e.key.toUpperCase();
  72. const code = e.code;
  73. if (this.downKeys.has(code)) this.downKeys.delete(code);
  74. if (!this.upKeys.has(code)) this.upKeys.add(code);
  75.  
  76. if (key === "L") {
  77. console.dir(self);
  78. console.dir(this.me);
  79. console.dir(this.world);
  80. console.dir(this.server);
  81. console.dir(this.socket);
  82. }
  83. //if(key =="DELETE" && self.GameScript !== null) saveAs(new Blob([self.GameScript], {type: "text/plain;charset=utf-8"}), `game.js`);
  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'])])
  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. }
  145. }
  146. }
  147.  
  148. resetSettings() {
  149. if (confirm("Are you sure you want to reset all your skid settings? This will also refresh the page")) {
  150. Object.keys(window.localStorage).filter(x => x.includes("utilities_")).forEach(x => window.localStorage.removeItem(x));
  151. window.location.reload();
  152. }
  153. }
  154.  
  155. newFeature(name, array, myFunction = null) {
  156. const cStruct = (...keys) => ((...v) => keys.reduce((o, k, i) => {
  157. o[k] = v[i];
  158. return o
  159. }, {}));
  160. var item = [];
  161. const myStruct = cStruct('name', 'value', 'valueStr', 'container', 'myFunction')
  162. const value = parseInt(window.getSavedVal("utilities_" + name) || 0);
  163. const feature = myStruct(name, value, array.length ? array[value] : '', array, myFunction);
  164. if (array.length||myFunction) this.features.push(feature);
  165. item.push(feature);
  166. return item;
  167. }
  168.  
  169. getFeature(name) {
  170. for (const feature of this.features) {
  171. if (feature.name.toLowerCase() === name.toLowerCase()) {
  172. return feature;
  173. }
  174. }
  175. return null;
  176. }
  177.  
  178. onUpdated(feature) {
  179. if (feature.container.length) {
  180. feature.value += 1;
  181. if (feature.value > feature.container.length - 1) {
  182. feature.value = 0;
  183. }
  184. feature.valueStr = feature.container[feature.value];
  185. window.saveVal("utilities_" + feature.name, feature.value);
  186. }
  187. if (feature.container.length == 2 && feature.container[0] == 'Off' && feature.container[1] == 'On') {
  188. console.log(feature.name, " is now ", feature.valueStr);
  189. switch (feature.name) {
  190. case 'Aim Through Walls': this.settings.autoAimWalls = feature.value;
  191. break;
  192. }
  193. }
  194. }
  195.  
  196. getDistance3D(fromX, fromY, fromZ, toX, toY, toZ) {
  197. var distX = fromX - toX,
  198. distY = fromY - toY,
  199. distZ = fromZ - toZ;
  200. return Math.sqrt(distX * distX + distY * distY + distZ * distZ);
  201. }
  202.  
  203. getDistance(player1, player2) {
  204. return this.getDistance3D(player1.x, player1.y, player1.z, player2.x, player2.y, player2.z);
  205. }
  206.  
  207. getDirection(fromZ, fromX, toZ, toX) {
  208. return Math.atan2(fromX - toX, fromZ - toZ);
  209. }
  210.  
  211. getXDir(fromX, fromY, fromZ, toX, toY, toZ) {
  212. var dirY = Math.abs(fromY - toY),
  213. dist = this.getDistance3D(fromX, fromY, fromZ, toX, toY, toZ);
  214. return Math.asin(dirY / dist) * (fromY > toY ? -1 : 1);
  215. }
  216.  
  217. getAngleDist(start, end) {
  218. return Math.atan2(Math.sin(end - start), Math.cos(start - end));
  219. }
  220.  
  221. camLookAt(X, Y, Z) {
  222. const currentXDR = this.control.xDr;
  223. const currentYDR = this.control.yDr;
  224. var xdir = this.getXDir(this.control.object.position.x, this.control.object.position.y, this.control.object.position.z, X, Y, Z),
  225. ydir = this.getDirection(this.control.object.position.z, this.control.object.position.x, Z, X),
  226. camChaseDst = this.server.camChaseDst;
  227. this.control.target = {
  228. xD: xdir,
  229. yD: ydir,
  230. x: X + camChaseDst * Math.sin(ydir) * Math.cos(xdir),
  231. y: Y - camChaseDst * Math.sin(xdir),
  232. z: Z + camChaseDst * Math.cos(ydir) * Math.cos(xdir)
  233. }
  234. this.control.xDr = currentXDR;
  235. this.control.yDr = currentYDR;
  236. }
  237.  
  238. lookAt(target) {
  239. 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);
  240. }
  241.  
  242. getStatic(s, d) {
  243. if (typeof s == 'undefined') {
  244. return d;
  245. }
  246. return s;
  247. }
  248.  
  249. teamColor(player) {
  250. return player.team === null ? '#FF4444' : this.me.team === player.team ? '#44AAFF' : '#FF4444';
  251. }
  252.  
  253. getTarget() {
  254. const players = this.world.players.list.filter(player => { return player.active && !player.isYou });
  255. const targets = players.filter(player => {
  256. return player.isSeen && (!player.team || player.team !== this.me.team)
  257. }).sort((p1, p2) => this.getDistance(this.me, p1) - this.getDistance(this.me, p2));
  258. return targets[0];
  259. }
  260.  
  261. autoAim(value) {
  262. if (!value) return;
  263. var lockedOn = false;
  264. const target = this.getTarget();
  265. if (this.me.didShoot) {
  266. this.settings.canShoot = false;
  267. setTimeout(() => {
  268. this.settings.canShoot = true;
  269. }, this.me.weapon.rate / 1.85);
  270. }
  271. if (target) {
  272. switch (value) {
  273. case 1:
  274. /*Aim Assist*/
  275. if (this.control.mouseDownR === 1) {
  276. this.world.config.deltaMlt = this.settings.delta;
  277. this.lookAt(target);
  278. this.world.config.deltaMlt = 1;
  279. lockedOn = true;
  280. } else {
  281. lockedOn = false;
  282. }
  283. break;
  284. case 2:
  285. /*Aim Bot*/
  286. if (this.control.mouseDownL === 1) {
  287. this.control.mouseDownL = 0;
  288. this.control.mouseDownR = 0;
  289. this.settings.scopingOut = true;
  290. }
  291. if (this.me.aimVal === 1) {
  292. this.settings.scopingOut = false;
  293. }
  294. if (!this.settings.scopingOut && this.settings.canShoot && this.me.recoilForce <= 0.01) {
  295. this.world.config.deltaMlt = this.settings.delta;
  296. this.lookAt(target);
  297. if (this.control.mouseDownR !== 2) {
  298. this.control.mouseDownR = 2;
  299. }
  300. lockedOn = true;
  301. this.world.config.deltaMlt = 1;
  302. } else lockedOn = false;
  303. break;
  304. case 3:
  305. /*Trigger Bot*/
  306. lockedOn = this.quickscoper(target);
  307. break;
  308. default: break;
  309. }
  310. }
  311. if (!lockedOn) {
  312. this.world.config.deltaMlt = 1;
  313. this.camLookAt(0, 0, 0);
  314. this.control.target = null;
  315. if (this.control.mouseDownR == 2) {
  316. this.control.mouseDownR = 0;
  317. }
  318. }
  319. }
  320.  
  321. quickscoper(target) {
  322. if (this.control.mouseDownL === 1) {
  323. this.control.mouseDownL = 0;
  324. this.control.mouseDownR = 0;
  325. this.settings.scopingOut = true;
  326. }
  327.  
  328. if (this.me.aimVal === 1) {
  329. this.settings.scopingOut = false;
  330. }
  331.  
  332. if (this.settings.scopingOut || !this.settings.canShoot) {
  333. return false;
  334. }
  335.  
  336. if (this.me.recoilForce > 0.01) {
  337. this.world.config.deltaMlt = 1;
  338. return false;
  339. }
  340.  
  341. this.world.config.deltaMlt = this.settings.delta;
  342. this.lookAt(target);
  343. if (this.control.mouseDownR !== 2) {
  344. this.control.mouseDownR = 2;
  345. }
  346.  
  347. if (this.me.aimVal < 0.2) {
  348. this.world.config.deltaMlt = this.settings.delta;
  349. this.lookAt(target);
  350. this.control.mouseDownL ^= 1;
  351. this.world.config.deltaMlt = 1;
  352. }
  353.  
  354. return true;
  355. }
  356.  
  357. autoBhop(value) {
  358. if (!value) return;
  359. if (this.keyDown("Space")) {
  360. this.control.keys[this.control.jumpKey] = !this.control.keys[this.control.jumpKey];
  361. if (value === 2) {
  362. if (this.settings.isSliding) {
  363. this.inputs[8] = 1;
  364. return;
  365. }
  366. if (this.me.yVel < -0.04 && this.me.canSlide) {
  367. this.settings.isSliding = true;
  368. setTimeout(() => {
  369. this.settings.isSliding = false;
  370. }, this.me.slideTimer);
  371. this.inputs[8] = 1;
  372. }
  373. }
  374. }
  375. }
  376.  
  377. wpnReload(force = false) {
  378. //(inputs[9] = me.ammos[me.weaponIndex] === 0);
  379. const ammoLeft = this.me.ammos[this.me.weaponIndex];
  380. if (force || ammoLeft === 0) {
  381. this.world.players.reload(this.me);
  382. if (ammoLeft) this.world.players.endReload(this.me.weapon);
  383. }
  384. }
  385.  
  386. world2Screen(camera, pos3d, aY = 0) {
  387. let pos = pos3d.clone();
  388. pos.y += aY;
  389. pos.project(camera);
  390. pos.x = (pos.x + 1) / 2;
  391. pos.y = (-pos.y + 1) / 2;
  392. pos.x *= this.canvas.width || innerWidth;
  393. pos.y *= this.canvas.height || innerHeight;
  394. return pos;
  395. }
  396.  
  397. pixelTranslate(ctx, x, y) {
  398. ctx.translate(~~x, ~~y);
  399. }
  400.  
  401. text(txt, font, color, x, y) {
  402. this.ctx.save();
  403. this.pixelTranslate(this.ctx, x, y);
  404. this.ctx.fillStyle = color;
  405. this.ctx.strokeStyle = "rgba(0, 0, 0, 0.5)";
  406. this.ctx.font = font;
  407. this.ctx.lineWidth = 1;
  408. this.ctx.strokeText(txt, 0, 0);
  409. this.ctx.fillText(txt, 0, 0);
  410. this.ctx.restore();
  411. }
  412.  
  413. rect(x, y, ox, oy, w, h, color, fill) {
  414. this.ctx.save();
  415. this.pixelTranslate(this.ctx, x, y);
  416. this.ctx.beginPath();
  417. fill ? this.ctx.fillStyle = color : this.ctx.strokeStyle = color;
  418. this.ctx.rect(ox, oy, w, h);
  419. fill ? this.ctx.fill() : this.ctx.stroke();
  420. this.ctx.closePath();
  421. this.ctx.restore();
  422. }
  423.  
  424. line(x1, y1, x2, y2, lW, sS) {
  425. this.ctx.save();
  426. this.ctx.lineWidth = lW + 2;
  427. this.ctx.beginPath();
  428. this.ctx.moveTo(x1, y1);
  429. this.ctx.lineTo(x2, y2);
  430. this.ctx.strokeStyle = "rgba(0, 0, 0, 0.25)";
  431. this.ctx.stroke();
  432. this.ctx.lineWidth = lW;
  433. this.ctx.strokeStyle = sS;
  434. this.ctx.stroke();
  435. this.ctx.restore();
  436. }
  437.  
  438. image(x, y, img, ox, oy, w, h) {
  439. this.ctx.save();
  440. this.ctx.translate(x, y);
  441. this.ctx.beginPath();
  442. this.ctx.drawImage(img, ox, oy, w, h);
  443. this.ctx.closePath();
  444. this.ctx.restore();
  445. }
  446.  
  447. gradient(x, y, w, h, colors) {
  448. let grad = this.ctx.createLinearGradient(x, y, w, h);
  449. for (let i = 0; i < colors.length; i++) {
  450. grad.addColorStop(i, colors[i]);
  451. }
  452. return grad;
  453. }
  454.  
  455. getTextMeasurements(arr) {
  456. for (let i = 0; i < arr.length; i++) {
  457. arr[i] = ~~this.ctx.measureText(arr[i]).width;
  458. }
  459. return arr;
  460. }
  461.  
  462. drawEsp(ui, world, myself) {
  463. const me = ui.camera.getWorldPosition()
  464. for (const entity of world.players.list.filter(x => !x.isYou && x.active)) {
  465. //if (!entity.rankIcon && entity.level > 0) {
  466. // let rankVar = entity.level > 0 ? Math.ceil(entity.level / 3) * 3 : entity.level < 0 ? Math.floor(entity.level / 3) * 3 : entity.level;
  467. // let rankId = Math.max(Math.min(100, rankVar - 2), 0);
  468. // entity.rankIcon = new Image();
  469. // entity.rankIcon.src = `./img/levels/${rankId}.png`;
  470. //}
  471. const target = entity.objInstances.position.clone();
  472. if (ui.frustum.containsPoint(target)) {
  473. let screenR = this.world2Screen(ui.camera, entity.objInstances.position.clone());
  474. let screenH = this.world2Screen(ui.camera, entity.objInstances.position.clone(), entity.height);
  475. let hDiff = ~~(screenR.y - screenH.y);
  476. let bWidth = ~~(hDiff * 0.6);
  477. const color = this.colors[this.settings.espColor];
  478. if (this.settings.espMode > 0 && this.settings.espMode != 3) {
  479. this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, 0, 0, 4, hDiff + 2, '#000000', false);
  480. this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, 0, 0, 4, hDiff + 2, '#44FF44', true);
  481. this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, 0, 0, 4, ~~((entity.maxHealth - entity.health) / entity.maxHealth * (hDiff + 2)), '#000000', true);
  482. this.ctx.save();
  483. this.ctx.lineWidth = 4;
  484. this.pixelTranslate(this.ctx, screenH.x - bWidth / 2, screenH.y);
  485. this.ctx.beginPath();
  486. this.ctx.rect(0, 0, bWidth, hDiff);
  487. this.ctx.strokeStyle = "rgba(0, 0, 0, 0.25)";
  488. this.ctx.stroke();
  489. this.ctx.lineWidth = 2;
  490. this.ctx.strokeStyle = entity.team === null ? '#FF4444' : myself.team === entity.team ? '#44AAFF' : '#FF4444';
  491. this.ctx.stroke();
  492. this.ctx.closePath();
  493. this.ctx.restore();
  494. if (this.settings.espMode === 1) {
  495. let playerDist = parseInt(this.getDistance3D(me.x, me.y, me.z, target.x, target.y, target.z) / 10);
  496. this.ctx.save();
  497. this.ctx.font = this.settings.espFontSize + 'px GameFont';
  498. let meas = this.getTextMeasurements([" ", playerDist, "m ", entity.level, "©", entity.name]);
  499. this.ctx.restore();
  500. let grad2 = this.gradient(0, 0, meas[4] * 5, 0, ["rgba(0, 0, 0, 0.25)", "rgba(0, 0, 0, 0)"]);
  501. let padding = 2;
  502. //if (entity.rankIcon && entity.rankIcon.complete) {
  503. // 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)"]);
  504. // 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);
  505. // 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));
  506. // this.text(`${entity.level}`, `${this.settings.espFontSize}px GameFont`, '#FFFFFF', ~~(screenH.x - bWidth / 2) - 16 - meas[3], ~~screenH.y + meas[4] * 1);
  507. //}
  508. this.rect(~~(screenH.x + bWidth / 2) + padding, ~~screenH.y - padding, 0, 0, (meas[4] * 5), (meas[4] * 4) + (padding * 2), grad2, true);
  509. 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)
  510. 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)
  511. this.text(entity.health+' HP', this.settings.espFontSize+'px GameFont', "#33FF33", (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 2)
  512. this.text(entity.weapon.name, this.settings.espFontSize+'px GameFont', "#DDDDDD", (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 3)
  513. this.text("[", this.settings.espFontSize+'px GameFont', "#AAAAAA", (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 4)
  514. this.text(playerDist, this.settings.espFontSize+'px GameFont', "#DDDDDD", (screenH.x + bWidth / 2) + 4 + meas[0], screenH.y + meas[4] * 4)
  515. this.text("m]", this.settings.espFontSize+'px GameFont', "#AAAAAA", (screenH.x + bWidth / 2) + 4 + meas[0] + meas[1], screenH.y + meas[4] * 4)
  516. }
  517. }
  518. const tracers = this.getFeature('Tracers');
  519. 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');
  520. }
  521. }
  522. }
  523.  
  524. drawMenuLine(item, lineWidth, lineHeight, lineTop, lineLeft, textLeft, active, title, rescaleText = true)
  525. {
  526. // default values
  527. let text_col = [255, 255, 255, 255],
  528. rect_col = [0, 0, 0, 120],
  529. text_scale = 20,
  530. font = 'px sans-serif';
  531.  
  532. // active line values
  533. if (active) {
  534. text_col[0] = 0;
  535. text_col[1] = 0;
  536. text_col[2] = 0;
  537. rect_col[0] = 231;
  538. rect_col[1] = 231;
  539. rect_col[2] = 231;
  540. if (rescaleText) text_scale = 21;
  541. }
  542.  
  543. // title values
  544. if (title)
  545. {
  546. rect_col[0] = 70;
  547. rect_col[1] = 90;
  548. rect_col[2] = 90;
  549. rect_col[3] = 255;
  550. if (rescaleText) text_scale = 20;
  551. font = 'px GameFont';
  552. textLeft = lineWidth / 2 - this.getTextMeasurements([item.name]);
  553. }
  554.  
  555. // rect
  556. this.rect(lineLeft, lineTop, 0, 0, lineWidth, (lineHeight * 2), this.rgba2hex(rect_col[0],rect_col[1],rect_col[2],rect_col[3]), true);
  557.  
  558. // text
  559. this.text(item.name, text_scale+font, this.rgba2hex(text_col[0],text_col[1],text_col[2]), textLeft, lineTop + lineHeight + lineHeight/2);
  560.  
  561. // value
  562. 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);
  563. }
  564.  
  565. drawMenuItem(caption) {
  566. const top = 280;
  567. const left = 20;
  568. const lineWidth = 320;
  569. const items = this.menus.get(caption);
  570. if (!items.length) return;
  571. if (this.activeLineIndex > items.length -1) this.activeLineIndex = 0;
  572.  
  573. // draw menu
  574. this.drawMenuLine({name:caption,valueStr:''}, lineWidth, 22, top + 18, left, left + 5, false, true);
  575. for (var i = 0; i < items.length; i++) {
  576. if (i != this.activeLineIndex) this.drawMenuLine(items[i][0], lineWidth, 19, top + 60 + i * 36, left, left + 9, false, false);
  577. this.drawMenuLine(items[this.activeLineIndex][0], lineWidth, 19, top + 60 + this.activeLineIndex * 36, left, left + 9, true, false);
  578. }
  579.  
  580. // process buttons
  581. if (this.keyUp("Numpad5")||this.keyUp("ArrowRight")) {
  582. self.SOUND.play('tick_0',0.1)
  583. const feature = items[this.activeLineIndex][0];
  584. if (feature) {
  585. if (feature.container.length) this.onUpdated(feature);
  586. else if (typeof feature.myFunction === "function") feature.myFunction();
  587. else this.activeMenuIndex = this.activeLineIndex + 1;
  588. }
  589. } else if (this.keyUp("Numpad0")||this.keyUp("ArrowLeft")) {
  590. self.SOUND.play('tick_0',0.1);
  591. if (this.activeMenuIndex > 0) this.activeMenuIndex = 0;
  592. else this.settings.showMenu = false;
  593. return;
  594. } else if (this.keyUp("Numpad8")||this.keyUp("ArrowUp")) {
  595. self.SOUND.play('tick_0',0.1)
  596. if (this.activeLineIndex == 0) this.activeLineIndex = items.length;
  597. this.activeLineIndex--;
  598. } else if (this.keyUp("Numpad2")||this.keyUp("ArrowDown")) {
  599. self.SOUND.play('tick_0',0.1)
  600. this.activeLineIndex++;
  601. if (this.activeLineIndex == items.length) this.activeLineIndex = 0;
  602. }
  603. }
  604.  
  605. drawMenu() {
  606. if (this.settings.showMenu) {
  607. switch(this.activeMenuIndex) {
  608. case 0: this.drawMenuItem('Krunker Skid'); break;
  609. case 1: this.drawMenuItem('Self'); break;
  610. case 2: this.drawMenuItem('Weapon'); break;
  611. case 3: this.drawMenuItem('Visual'); break;
  612. case 4: this.drawMenuItem('Settings'); break;
  613. default: break;
  614. }
  615. }
  616. else if (this.keyUp("Numpad0")||this.keyUp("ArrowLeft")) {
  617. self.SOUND.play('tick_0',0.1)
  618. this.settings.showMenu = true;
  619. }
  620. }
  621.  
  622. onRender(uiConfig, scale, world, ui, me, scale2) {
  623. if (uiConfig)
  624. {
  625. uiConfig.crosshairAlways = true;
  626. this.settings.espFontSize = uiConfig.dmgScale * 0.25;
  627. this.canvas = uiConfig.canvas || document.getElementById("game-overlay");
  628. this.ctx = this.canvas.getContext("2d");
  629. this.ctx.save();
  630. this.ctx.clearRect(0, 0, this.canvas.width || innerWidth, this.canvas.height || innerHeight);
  631. if (world && ui && me )
  632. {
  633. if ('none' == self.menuHolder.style.display && 'none' == self.endUI.style.display) {
  634. this.drawEsp(ui, world, me);
  635. this.drawMenu();
  636. }
  637. }
  638. this.ctx.restore();
  639. }
  640. }
  641. }
  642.  
  643. function patchGame(source) {
  644. window.GameScript = source;
  645. source = Utilities.toString().concat(source);
  646. const patches = new Map()
  647. .set("exports", [/(\['__CANCEL__']=.*?\(\w+,\w+,(\w+)\){)(let)/, '$1window.utilities=new Utilities();utilities.exports=$2;$3'])
  648. .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;'])
  649. .set("control", [/(=this;this\['gamepad'])/, '=utilities.control$1'])
  650. .set("procInputs", [/(this\['procInputs']=function\((\w+),(\w+),(\w+)\){)/, '$1utilities.onTick(this,$3,$2);'])
  651. .set("ui", [/(this,\w+={};this\['frustum'])/, 'utilities.ui=$1'])
  652. .set("fixHowler", [/(Howler\['orientation'](.+?)\)\),)/, ``])
  653. .set("clearRec", [/(if\(\w+\['save']\(\),\w+\['scale']\(\w+,\w+\),)\w+\['clearRect']\(0x0,0x0,\w+,\w+\),(\w+\['showDMG']\))/, '$1$2'])
  654. .set("onRender", [/((\w+)\['render']=function\((\w+,\w+,\w+,\w+,\w+)\){)/, '$1utilities.onRender($2,$3);'])
  655. .set("pInfo", [/(if\()(!\w+\['isSeen']\)continue;)/, '$1utilities.settings.espMode==1||utilities.settings.espMode==0&&$2'])
  656. .set("wallhack", [/(\(((\w+))=this\['map']\['manager']\['objects']\[(\w+)]\))(.+?)\)/, '$1.penetrable&&$2.active&&!utilities.settings.autoAimWalls)'])
  657. .set("socket", [/(new WebSocket)/, 'utilities.socket=$1'])
  658. //.set("deathDelay", [/\w+\['deathDelay']/, 'utilities.settings.deathDelay'])
  659. .set("fuckingLame", [/if\(!\w+&&!\w+&&!\w+&&\w+\['isView']\(this\)&&\w+\['isView']\(\w+\)/, 'if(!1'])
  660.  
  661. for (const [name, item] of patches) {
  662. const patched = source.replace(item[0], item[1]);
  663. if (source === patched) {
  664. alert(`Failed to patch ${name}`);
  665. continue;
  666. } else console.log("Successfully patched ", name);
  667. source = patched;
  668. }
  669.  
  670. return source;
  671. }
  672.  
  673. document.addEventListener('DOMContentLoaded', _ => {
  674. var hideHook = (fn, oFn) => { fn.toString = oFn.toString.bind(oFn) };
  675. const handler = { construct(target, args) { if (args.length == 2 && args[1].length >140000) { args[1] = patchGame(args[1]); } return new target(...args); } };
  676. const original = self.Function;
  677. self.Function = new Proxy(Function, handler);
  678. hideHook(Function, original);
  679. window.saveAs = saveAs;
  680. }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement