Advertisement
Guest User

Cheats or Krunker

a guest
Sep 23rd, 2019
1,168
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.90 KB | None | 0 1
  1. // ==UserScript==
  2. // @name Stone
  3. // @description Whater
  4. // @version 9.0.1
  5. // @author hacker
  6. // @include /^(https?:\/\/)?(www\.)?(.+)krunker\.io(|\/|\/\?.+)$/
  7. // @grant none
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11. const cStruct = (...keys) => ((...v) => keys.reduce((o, k, i) => {
  12. o[k] = v[i];
  13. return o
  14. }, {}))
  15. const Vector3 = (x, y, z) => {
  16. this.x = x || 0;
  17. this.y = y || 0;
  18. this.z = z || 0;
  19. return this;
  20. }
  21. const fmt = (format, ...args) => {
  22. return format
  23. .split("%%")
  24. .reduce((aggregate, chunk, i) => aggregate + chunk + (args[i] || ""), "");
  25. }
  26. class Utilities {
  27. constructor() {
  28. this.inputs;
  29. this.exports;
  30. this.control;
  31. this.functions;
  32. this.weapons;
  33. this.wpnClasses;
  34. this.self;
  35. this.ui;
  36. this.settings = {
  37. scopingOut: false,
  38. canShoot: true,
  39. targetCoolDown: 500,
  40. weaponIndex: 0,
  41. isSliding: false,
  42. dirtyCanvas: false,
  43. espMode: 0,
  44. espFontMlt: 10,
  45. };
  46. this.playerInfo = false;
  47. this.canvas;
  48. this.ctx;
  49. this.spinTimer = 1800;
  50. this.features = [];
  51. this.onLoad();
  52. this.colors = {
  53. aqua: '#7fdbff',
  54. blue: '#0074d9',
  55. lime: '#01ff70',
  56. navy: '#001f3f',
  57. teal: '#39cccc',
  58. olive: '#3d9970',
  59. green: '#2ecc40',
  60. red: '#ff4136',
  61. maroon: '#85144b',
  62. orange: '#ff851b',
  63. purple: '#b10dc9',
  64. yellow: '#ffdc00',
  65. fuchsia: '#f012be',
  66. greyDark: '#808080',
  67. greyMed: '#A9A9A9',
  68. greyLight: '#D3D3D3',
  69. white: '#ffffff',
  70. black: '#111111',
  71. silver: '#dddddd',
  72. hostile: '#EB5656',
  73. friendly: '#9EEB56',
  74. };
  75. }
  76.  
  77. onLoad() {
  78. this.newFeature('AutoAim', "1", ['Off', 'Silent Aim', 'Trigger Bot']);
  79. this.newFeature('BestAimbot', "2", ['Off', 'On']);
  80. this.newFeature('AutoBhop', "3", ['Off', 'Auto Jump', 'Auto SlideJump']);
  81. this.newFeature('AutoReload', "4", []);
  82. this.newFeature('SpinBot', '5', []);
  83. this.newFeature('Hide Menu', 'M', []);
  84. window.addEventListener("keydown", event => this.onKeyDown(event));
  85. const interval = setInterval(() => {
  86. if (document.querySelector('#leaderDisplay') !== null) {
  87. clearInterval(interval);
  88. this.createInfoBox();
  89. this.createCanvas();
  90. }
  91. }, 100);
  92. }
  93.  
  94. onTick() {
  95. for (let i = 0, sz = this.features.length; i < sz; i++) {
  96. const feature = this.features[i];
  97. switch (feature.name) {
  98. case 'AutoAim':
  99. if (feature.value) this.AutoAim(feature.value);
  100. break;
  101. case 'AutoReload':
  102. if (feature.value) this.wpnReload();
  103. break;
  104. case 'AutoBhop':
  105. if (feature.value) this.AutoBhop(feature.value);
  106. break;
  107. case 'EspMode':this.settings.espMode = feature.value;break;
  108. break;
  109. case 'BestAimbot':
  110. if (feature.value) this.BestAimbot(feature.value);
  111. break;
  112. }
  113. }
  114. this.playerInfo = (this.settings.espMode == 0 || this.settings.espMode == 4) ? false : true;
  115. if (this.settings.espMode) {
  116. window.requestAnimationFrame(() => {
  117. this.ctx.clearRect(0, 0, innerWidth, innerHeight);
  118. this.drawESP();
  119. });
  120. } else if (this.settings.dirtyCanvas) {
  121. this.ctx.clearRect(0, 0, innerWidth, innerHeight);
  122. this.settings.dirtyCanvas = false;
  123. }
  124. }
  125. // Ui
  126. line(x1, y1, x2, y2, lW, sS) {
  127. this.ctx.save();
  128. this.ctx.lineWidth = lW + 2;
  129. this.ctx.beginPath();
  130. this.ctx.moveTo(x1, y1);
  131. this.ctx.lineTo(x2, y2);
  132. this.ctx.strokeStyle = "rgba(23,67,88,0.5)";
  133. this.ctx.stroke();
  134. this.ctx.lineWidth = lW;
  135. this.ctx.strokeStyle = sS;
  136. this.ctx.stroke();
  137. this.ctx.restore();
  138. }
  139.  
  140. rect(x, y, ox, oy, w, h, color, fill) {
  141. this.ctx.save();
  142. this.pixelTranslate(this.ctx, x, y);
  143. this.ctx.beginPath();
  144. fill ? this.ctx.fillStyle = color : this.ctx.strokeStyle = color;
  145. this.ctx.rect(ox, oy, w, h);
  146. fill ? this.ctx.fill() : this.ctx.stroke();
  147. this.ctx.closePath();
  148. this.ctx.restore();
  149. }
  150.  
  151. circle(x, y, r, w, color, fill = false) {
  152. this.ctx.save();
  153. this.ctx.beginPath();
  154. this.ctx.lineWidth = w;
  155. fill ? this.ctx.fillStyle = color : this.ctx.strokeStyle = color;
  156. this.ctx.arc(x, y, r, 0, 2 * Math.PI);
  157. fill ? this.ctx.fill() : this.ctx.stroke();
  158. this.ctx.closePath();
  159. this.ctx.restore();
  160. }
  161.  
  162. text(txt, font, color, x, y) {
  163. this.ctx.save();
  164. this.pixelTranslate(this.ctx, x, y);
  165. this.ctx.fillStyle = color;
  166. this.ctx.strokeStyle = "rgba(23,67,88,0.5)";
  167. this.ctx.font = font;
  168. this.ctx.lineWidth = 1;
  169. this.ctx.strokeText(txt, 0, 0);
  170. this.ctx.fillText(txt, 0, 0);
  171. this.ctx.restore();
  172. }
  173.  
  174. image(x, y, img, ox, oy) {
  175. this.ctx.save();
  176. this.ctx.translate(x, y);
  177. this.ctx.beginPath();
  178. this.ctx.drawImage(img, ox, oy);
  179. this.ctx.closePath();
  180. this.ctx.restore();
  181. this.drawn = true;
  182. }
  183.  
  184. pixelTranslate(ctx, x, y) {
  185. ctx.translate(~~x, ~~y);
  186. }
  187.  
  188. gradient(x, y, w, h, colors) {
  189. let grad = this.ctx.createLinearGradient(x, y, w, h);
  190. for (let i = 0; i < colors.length; i++) {
  191. grad.addColorStop(i, colors[i]);
  192. }
  193. return grad;
  194. }
  195.  
  196. getTextMeasurements(arr) {
  197. for (let i = 0; i < arr.length; i++) {
  198. arr[i] = ~~this.ctx.measureText(arr[i]).width;
  199. }
  200. return arr;
  201. }
  202.  
  203. world2Screen(pos3d, camera) {
  204. // this.canvas.width / window.innerWidth
  205. // this.canvas.height / window.innerHeight
  206. let pos = pos3d.clone();
  207. let width = this.canvas.width,
  208. height = this.canvas.height;
  209. let widthHalf = width / 2,
  210. heightHalf = height / 2;
  211. pos.project(camera);
  212. pos.x = (pos.x * widthHalf) + widthHalf;
  213. pos.y = -(pos.y * heightHalf) + heightHalf;
  214. return pos;
  215. }
  216.  
  217. teamCol(player, secondary) {
  218. return player.team === null ? secondary ? this.colors.red : this.colors.hostile : this.self.team === player.team ? secondary ? this.colors.green : this.colors.friendly : secondary ? this.colors.red : this.colors.hostile;
  219. }
  220.  
  221. drawESP() {
  222. const players = this.world.players.list.filter(x => !x.isYou).filter(x => x.active).filter(x => this.ui.frustum.containsPoint(x)).sort((a, b) => this.getDistance(this.self, a) - this.getDistance(this.self, b));
  223. for (const player of players) {
  224. let offset = Vector3(0, this.server.playerHeight + this.server.nameOffsetHat - player.crouchVal * this.server.crouchDst, 0);
  225. let screenG = this.world2Screen(player.objInstances.position.clone(), this.ui.camera);
  226. let screenH = this.world2Screen(player.objInstances.position.clone().add(offset), this.ui.camera);
  227. let hDiff = ~~(screenG.y - screenH.y);
  228. let bWidth = ~~(hDiff * 0.6);
  229.  
  230. if (this.settings.espMode > 1) this.line(innerWidth / 2, innerHeight - 1, screenG.x, screenG.y, 2, this.teamCol(player, 0));
  231. if (this.settings.espMode > 2) {
  232. if (this.settings.espMode > 3) {
  233. let health = this.getPercentage(player.health, player.maxHealth);
  234. this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, -3, 0, 6, hDiff + 2, this.colors.black, false);
  235. this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, -3, 0, 6, hDiff + 2, health > 75 ? this.colors.green : health > 50 ? this.colors.orange : this.colors.red, true);
  236. this.rect((screenH.x - bWidth / 2) - 7, ~~screenH.y - 1, -3, 0, 6, ~~((player.maxHealth - player.health) / player.maxHealth * (hDiff + 2)), this.colors.black, true);
  237. }
  238. this.ctx.save();
  239. this.ctx.lineWidth = 4;
  240. this.pixelTranslate(this.ctx, screenH.x - bWidth / 2, screenH.y);
  241. this.ctx.beginPath();
  242. this.ctx.rect(0, 0, bWidth, hDiff);
  243. this.ctx.strokeStyle = "rgba(0, 0, 0, 0.25)";
  244. this.ctx.stroke();
  245. this.ctx.lineWidth = 2;
  246. this.ctx.strokeStyle = this.teamCol(player, 0);
  247. this.ctx.stroke();
  248. this.ctx.closePath();
  249. this.ctx.restore();
  250. if (this.settings.espMode > 3) {
  251. let playerDist = (Math.round(this.getDistance(this.ui.camera.getWorldPosition(), player)) / 10).toFixed(0);
  252. let FontSize = this.settings.espFontMlt*(Math.max(0.3,1.0-playerDist/600));
  253. this.ctx.save();
  254. let meas = this.getTextMeasurements(["[", playerDist, "]", player.level, '000', player.name, player.weapon.name+'0000']);
  255. this.ctx.restore();
  256. let padding = 2;
  257. let grad2 = this.gradient(0, 0, meas[4] * 5, 0, ["rgba(0, 0, 0, 0.25)", "rgba(0, 0, 0, 0)"]);
  258. this.rect(~~(screenH.x + bWidth / 2) + padding, ~~screenH.y - padding, 0, 0, (meas[4] * 5), (meas[4] * 4) + (padding * 2), grad2, true);
  259.  
  260. this.text(player.name, (FontSize + 2) + 'px GameFont', this.colors.white, (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 1)
  261. if (player.clan) this.text("["+player.clan+"]", FontSize + 'px GameFont', "#AAAAAA", (screenH.x + bWidth / 2) + 8 + meas[5], screenH.y + meas[4] * 1)
  262.  
  263. this.text(fmt("Level:%%", player.level ? player.level : 0), FontSize + 'px GameFont', this.colors.yellow, (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 2)
  264.  
  265. this.text(player.weapon.name, FontSize + 'px GameFont', this.colors.greyMed, (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 3)
  266. this.text(fmt("[%%/%%]", player.weapon.ammo ? player.ammos[player.weaponIndex] : 0, player.weapon.ammo ? player.weapon.ammo : 0), FontSize + 'px GameFont', this.colors.greyDark, (screenH.x + bWidth / 2) + 8 + meas[6], screenH.y + meas[4] * 3)
  267.  
  268. this.text("[", FontSize + 'px GameFont', this.colors.greyMed, (screenH.x + bWidth / 2) + 4, screenH.y + meas[4] * 4)
  269. this.text(playerDist, FontSize + 'px GameFont', this.colors.white, (screenH.x + bWidth / 2) + 4 + meas[0], screenH.y + meas[4] * 4)
  270. this.text("mt", FontSize + 'px GameFont', this.colors.white, (screenH.x + bWidth / 2) + 4 + meas[0] + meas[1], screenH.y + meas[4] * 4)
  271. }
  272. }
  273. }
  274.  
  275. this.settings.canvasNeedsClean = true;
  276. }
  277.  
  278. onRender() {
  279. window.requestAnimationFrame(() => {
  280. this.onRender()
  281. })
  282. }
  283.  
  284. createCanvas() {
  285. const hookedCanvas = window.document.createElement("canvas");
  286. hookedCanvas.id = "canvas_overlay";
  287. hookedCanvas.width = innerWidth;
  288. hookedCanvas.height = innerHeight;
  289.  
  290. function resize() {
  291. const ws = innerWidth / 1700;
  292. const hs = innerHeight / 900;
  293. hookedCanvas.width = innerWidth;
  294. hookedCanvas.height = innerHeight;
  295. hookedCanvas.style.width = (hs < ws ? (innerWidth / hs).toFixed(3) : 1700) + "px";
  296. hookedCanvas.style.height = (ws < hs ? (innerHeight / ws).toFixed(3) : 900) + "px";
  297. }
  298. window.addEventListener('resize', resize);
  299. resize();
  300. this.canvas = hookedCanvas;
  301. this.ctx = hookedCanvas.getContext("2d");
  302. const hookedUI = window.inGameUI;
  303. hookedUI.insertAdjacentElement("beforeend", hookedCanvas);
  304. window.requestAnimationFrame(() => {
  305. this.onRender()
  306. })
  307. }
  308.  
  309. onUpdated(feature) {
  310. if (feature.container.length) {
  311. feature.value += 1;
  312. if (feature.value > feature.container.length - 1) {
  313. feature.value = 0;
  314. }
  315. feature.valueStr = feature.container[feature.value];
  316. } else {
  317. feature.value ^= 1;
  318. feature.valueStr = feature.value ? "true" : "false";
  319. }
  320. switch (feature.name) {
  321. case 'ForceScope':
  322. feature.value || this.self.weapon.name === "Sniper Rifle" || this.self.weapon.name === "Semi Auto" ? this.self.weapon.scope = 1 : delete this.self.weapon.scope;
  323. break;
  324. case 'EspMode':
  325. this.settings.dirtyCanvas = true;
  326. break;
  327. }
  328. window.saveVal("utilities_" + feature.name, feature.value);
  329. this.updateInfoBox();
  330. }
  331.  
  332. getStatic(s, d) {
  333. if (typeof s == 'undefined') {
  334. return d;
  335. }
  336. return s;
  337. }
  338.  
  339. newFeature(name, key, array) {
  340. const feature = cStruct('name', 'hotkey', 'value', 'valueStr', 'container')
  341. const value = parseInt(window.getSavedVal("utilities_" + name) || 0);
  342. this.features.push(feature(name, key, value, array.length ? array[value] : value ? "true" : "false", array));
  343. }
  344.  
  345. getFeature(name) {
  346. for (const feature of this.features) {
  347. if (feature.name.toLowerCase() === name.toLowerCase()) {
  348. return feature;
  349. }
  350. }
  351. return cStruct('name', 'hotkey', 'value', 'valueStr', 'container');
  352. }
  353.  
  354. createInfoBox() {
  355. const leaderDisplay = document.querySelector('#leaderDisplay');
  356. if (leaderDisplay) {
  357. let infoBox = document.createElement('div');
  358. if (infoBox) infoBox.innerHTML = '<div> <style> #InfoBox { text-align: left; width: 310px; z-index: 3; padding: 10px; padding-left: 20px; padding-right: 20px; color: rgba(255, 255, 255, 0.7); line-height: 25px; margin-top: 0px; background-color: rgba(0, 0, 0, 0.3); } #InfoBox .utilitiesTitle { font-size: 16px; font-weight: bold; text-align: center; color: #1A72B8; margin-top: 5px; margin-bottom: 5px; } #InfoBox .leaderItem { font-size: 14px; } </style> <div id="InfoBox"></div> </div>'.trim();
  359. leaderDisplay.parentNode.insertBefore(infoBox.firstChild, leaderDisplay.nextSibling);
  360. this.updateInfoBox();
  361. }
  362. }
  363.  
  364. upperCase(str) {
  365. return str.toUpperCase();
  366. }
  367.  
  368. toProperCase(str) {
  369. str = str.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, '$1 $2');
  370. str = str.replace(/\s[a-z]/g, this.upperCase)
  371. return str;
  372. }
  373.  
  374. updateInfoBox() {
  375. const infoBox = document.querySelector('#InfoBox');
  376. if (infoBox) {
  377. const lines = this.features.map(feature => {
  378. return '<div class="leaderItem"> <div class="leaderNameF">[' + feature.hotkey.toUpperCase() + '] ' + this.toProperCase(feature.name) + '</div> <div class="leaderScore">' + feature.valueStr + '</div> </div>';
  379. });
  380. infoBox.innerHTML = '<div><span style="color:#ff0000;">F</span><span style="color:#ff7f00;">a</span><span style="color:#ffff00;">d</span><span style="color:#00ff00;">e</span><span style="color:#00ffff;"> </span><span style="color:#0000ff;">B</span><span style="color:#8b00ff;">1</span></div>' + lines.join('').trim();
  381. }
  382. }
  383.  
  384. onKeyDown(event) {
  385. if (document.activeElement.tagName === "INPUT") return;
  386. const key = event.key.toUpperCase();
  387. switch (key) {
  388. case 'M': {
  389. const infoBox = document.querySelector('#InfoBox');
  390. if (infoBox) infoBox.style.display = !infoBox.style.display || infoBox.style.display === "inline-block" ? "none" : "inline-block";
  391. }
  392. break;
  393. case 'DELETE':
  394. this.resetSettings();
  395. break;
  396. default:
  397. for (const feature of this.features) {
  398. if (feature.hotkey.toUpperCase() === key) {
  399. this.onUpdated(feature);
  400. }
  401. }
  402. break;
  403. }
  404. }
  405.  
  406. getPercentage(a, b) {
  407. return Math.round((a / b) * 100);
  408. }
  409.  
  410. getDistance3D(fromX, fromY, fromZ, toX, toY, toZ) {
  411. var distX = fromX - toX,
  412. distY = fromY - toY,
  413. distZ = fromZ - toZ;
  414. return Math.sqrt(distX * distX + distY * distY + distZ * distZ)
  415. }
  416.  
  417. getDistance(player1, player2) {
  418. return this.getDistance3D(player1.x, player1.y, player1.z, player2.x, player2.y, player2.z);
  419. }
  420.  
  421. getDirection(fromZ, fromX, toZ, toX) {
  422. return Math.atan2(fromX - toX, fromZ - toZ)
  423. }
  424.  
  425. getXDir(fromX, fromY, fromZ, toX, toY, toZ) {
  426. var dirY = Math.abs(fromY - toY),
  427. dist = this.getDistance3D(fromX, fromY, fromZ, toX, toY, toZ);
  428. return Math.asin(dirY / dist) * (fromY > toY ? -1 : 1)
  429. }
  430.  
  431. getAngleDist(start, end) {
  432. return Math.atan2(Math.sin(end - start), Math.cos(start - end));
  433. }
  434.  
  435. camLookAt(X, Y, Z) {
  436. var xdir = this.getXDir(this.control.object.position.x, this.control.object.position.y, this.control.object.position.z, X, Y, Z),
  437. ydir = this.getDirection(this.control.object.position.z, this.control.object.position.x, Z, X),
  438. camChaseDst = this.server.camChaseDst;
  439. this.control.target = {
  440. xD: xdir,
  441. yD: ydir,
  442. x: X + this.server.camChaseDst * Math.sin(ydir) * Math.cos(xdir),
  443. y: Y - this.server.camChaseDst * Math.sin(xdir),
  444. z: Z + this.server.camChaseDst * Math.cos(ydir) * Math.cos(xdir)
  445. }
  446. }
  447.  
  448. AutoAim(value) {
  449. if (this.self.didShoot) {
  450. if (this.control.mouseDownL === 1) {
  451. this.control.mouseDownL = 0;
  452. this.control.mouseDownR = 0;
  453. }
  454. setTimeout(() => {
  455. this.settings.canShoot = true;
  456. this.settings.forceScope || this.self.weapon.name === "Sniper Rifle" || this.self.weapon.name === "Semi Auto" ? this.self.weapon.scope = 1 : delete this.self.weapon.scope;
  457. }, this.self.weapon.rate / 1.75);
  458. }
  459. const target = this.getTarget();
  460. if (target) {
  461. switch (value) {
  462. case 1:
  463. /*Aim Assist*/
  464. if (this.control.mouseDownR === 1) {
  465. this.lookAtHead(target);
  466. }
  467. break;
  468. case 2:
  469. }
  470. } else {
  471. this.wpnReload(this.getFeature('AutoReload').value && this.self.ammos[this.self.weaponIndex] < ((this.self.weapon.ammo / 2) + 1));
  472. this.control.target = null;
  473. if (this.control.mouseDownR === 2) {
  474. setTimeout(() => {
  475. this.control.mouseDownR = 0;
  476. this.self.aimVal = 1;
  477. this.settings.scopingOut = false;
  478. this.settings.canShoot = true;
  479. }, this.settings.targetCoolDown);
  480. }
  481. }
  482. }
  483.  
  484. AutoBhop(value) {
  485. if (this.control['keys'][this.control['moveKeys'][0x0]] && value) {
  486. this.control.keys[this.control.jumpKey] = this.self.onGround;
  487. if (value === 2) {
  488. if (this.settings.isSliding) {
  489. this.inputs[8] = 1;
  490. return;
  491. }
  492. if (this.self.yVel < -0.04 && this.self.canSlide) {
  493. this.settings.isSliding = true;
  494. setTimeout(() => {
  495. this.settings.isSliding = false;
  496. }, this.self.slideTimer);
  497. this.inputs[8] = 1;
  498. }
  499. }
  500. }
  501. }
  502.  
  503. BestAimbot(value) {
  504. if (value == 0) return;
  505. let isLockedOn = false;
  506. const target = this.getTarget();
  507. if (target) {
  508. switch (value) {
  509. case 1:
  510. if (this.control.mouseDownR === 1) {
  511. this.lookAtHead(target);
  512. isLockedOn = true;
  513. }
  514. break;
  515. }
  516. }
  517. if (!isLockedOn) {
  518. this.control.target = null;
  519. if (value !== 1 && this.control.mouseDownR === 1)
  520. this.timeoutHandle = setTimeout(() => {
  521. clearTimeout(this.timeoutHandle);
  522. this.timeoutHandle = null;
  523. this.control.mouseDownR = 0;
  524. }, this.settings.targetCoolDown);
  525. }
  526. }
  527. wpnReload(force = false) {
  528. const ammoLeft = this.self.ammos[this.self.weaponIndex];
  529. if (force || ammoLeft === 0) this.world.players.reload(this.self);
  530. }
  531.  
  532. resetSettings() {
  533. if (confirm("Are you sure you want to reset all your hero settings? This will also refresh the page")) {
  534. Object.keys(window.localStorage).filter(x => x.includes("utilities_")).forEach(x => window.localStorage.removeItem(x));
  535. location.reload();
  536. }
  537. }
  538.  
  539. getTarget() {
  540. const enemies = this.world.players.list
  541. .filter(player => {
  542. return player.active && (player.inView || this.self.dmgReceived[player.id]) && !player.isYou && (!player.team || player.team !== this.self.team);
  543. })
  544. .sort((p1, p2) => this.getDistance(this.self, p1) - this.getDistance(this.self, p2));
  545. return enemies.length ? enemies[0] : null;
  546. }
  547.  
  548. lookAtHead(target) {
  549. if (this.getFeature("SpinBot").value) this.spinTick();
  550. this.camLookAt(target.x2, target.y2 + target.height - target.headScale * 0.75 - this.server.crouchDst * target.crouchVal - this.self.recoilAnimY * this.server.recoilMlt, target.z2);
  551. }
  552.  
  553. spinTick() {
  554. if (this.control.mouseDownL === 1) return;
  555. //this.world.players.getSpin(this.self);
  556. //this.world.players.saveSpin(this.self, angle);
  557. const last = this.inputs[2];
  558. const angle = this.getAngleDist(this.inputs[2], this.self.xDire);
  559. this.spins = this.getStatic(this.spins, new Array());
  560. this.spinTimer = this.getStatic(this.spinTimer, this.server.spinTimer);
  561. this.serverTickRate = this.getStatic(this.serverTickRate, this.server.serverTickRate);
  562. (this.spins.unshift(angle), this.spins.length > this.spinTimer / this.serverTickRate && (this.spins.length = Math.round(this.spinTimer / this.serverTickRate)))
  563. for (var e = 0, i = 0; i < this.spins.length; ++i) e += this.spins[i];
  564. const count = Math.abs(e * (180 / Math.PI));
  565. if (count < 360) {
  566. this.inputs[2] = this.self.xDire + Math.PI;
  567. } else console.log('count', count);
  568. }
  569.  
  570. inputsTick(self, inputs, world) {
  571. //Hooked
  572. if (this.control && this.exports && self && inputs && world) {
  573. this.inputs = inputs;
  574. this.world = world;
  575. this.self = self;
  576. if(!this.server){
  577. console.dir(this.exports.c[7].exports)
  578. }
  579. this.server = this.exports.c[7].exports;
  580. this.functions = this.exports.c[8].exports;
  581. this.weapons = this.exports.c[22].exports;
  582. this.wpnClasses = this.exports.c[69].exports;
  583. this.onTick();
  584. }
  585. }
  586.  
  587. controlTick(control) {
  588. //Hooked
  589. if (control) {
  590. this.control = control;
  591. const half = Math.PI / 2;
  592. if (control.target) {
  593. control.yDr = control.target.xD % Math.PI;
  594. control.xDr = control.target.yD % Math.PI;
  595. }
  596. }
  597. }
  598. drawESP() {
  599. //Hooked
  600. const players = this.world.players.list.filter(x => !x.isYou).filter(x => x.active).filter(x => this.ui.frustum.containsPoint(x)).sort((a, b) => this.getDistance(this.self, a) - this.getDistance(this.self, b));
  601. for (const player of players) {
  602. let offset = Vector3(0, this.server.playerHeight + this.server.nameOffsetHat - player.crouchVal * this.server.crouchDst, 0);
  603. let screenG = this.world2Screen(player.objInstances.position.clone(), this.ui.camera);
  604. let screenH = this.world2Screen(player.objInstances.position.clone().add(offset), this.ui.camera);
  605. let hDiff = ~~(screenG.y - screenH.y);
  606. let bWidth = ~~(hDiff * 0.6);
  607.  
  608. }
  609. }
  610. }
  611.  
  612. function read(url) {
  613. return new Promise(resolve => {
  614. fetch(url).then(res => res.text()).then(res => {
  615. return resolve(res);
  616. });
  617. });
  618. }
  619.  
  620. function patch(source, method, regex, replacer) {
  621. const patched = source.replace(regex, replacer);
  622. if (source === patched) {
  623. alert(`Failed to patch ${method}`);
  624. } else console.log("Successfully patched ", method);
  625. return patched;
  626. }
  627.  
  628. function patchedIndex(html) {
  629. html = patch(html, "html_scriptBlock", /(<script src=".*?game.*?")(><\/script>)/, '$1 type="javascript/blocked" $2');
  630. html = patch(html, "html_payPal", /<script src=".*?paypal.*?"><\/script>/, '');
  631. return html;
  632. }
  633.  
  634. function patchedScript(script) {
  635. script = patch(script, 'WallHack', /if\(!tmpObj\['inView']\)continue;/, ``);
  636. script = patch(script, "Exports", /\['__CANCEL__']=!(\w+),(\w+)\['exports']=(\w+);},function\((\w+),(\w+),(\w+)\){let/, `['__CANCEL__']=!$1,$2['exports']=$3;},function($4,$5,$6){window.utilities=new Utilities();window.utilities.exports=$6;let`);
  637. script = patch(script, 'ProcInput', /this\['procInputs']=function\((\w+),(\w+),(\w+)\){/, `this['procInputs']=function($1,$2,$3){window.utilities.inputsTick(this,$1,$2);`);
  638. script = patch(script, 'ControlTick', /{if\(this\['target']\){(.+?)}},this\['(\w+)']=/, `{window.utilities.controlTick(this);},this['$2']=`);
  639. script = patch(script, 'ControlFix', /&&\((\w+)\[('\w+')]\((\w+)\['x'],(\w+)\['y']\+(\w+)\['height']-(\w+)\['cameraHeight'],(\w+)\['z']\)/, `&&(utilities.camLookAt($3['x'],$3['y']+$3['height']-$6['cameraHeight'],$3['z'])`);
  640. return script;
  641. }
  642.  
  643. (async function () {
  644. const index = await read(document.location.href);
  645. const build = index.match(/(?<=build=)[^"]+/)[0];
  646. const patch = index.match(/"SOUND.play\(.+\)">v(.+)</)[1];
  647. const script = await read(`/js/game.${build}.js`);
  648. //window.stop();
  649. document.open();
  650. document.write(patchedIndex(index));
  651. document.close();
  652. try {
  653. eval(patchedScript(script));
  654. } catch (err) {
  655. location.reload();
  656. }
  657. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement