Advertisement
Someone193

Krunker.io hacks

Feb 15th, 2021
16,641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 74.39 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Krunker SkidFest
  3. // @description A full featured Mod menu for game Krunker.io!
  4. // @version 2.28
  5. // @author SkidLamer - From The Gaming Gurus
  6. // @supportURL https://discord.gg/AJFXXACdrF
  7. // @homepage https://skidlamer.github.io/
  8. // @match *://krunker.io/*
  9. // @exclude *://krunker.io/editor*
  10. // @exclude *://krunker.io/social*
  11. // @reqire https://raw.githubusercontent.com/FireMasterK/BypassAdditions/master/script.user.js
  12. // @updateURL https://skidlamer.github.io/js/Skidfest.user.js
  13. // @run-at document-start
  14. // @grant none
  15. // @noframes
  16. // ==/UserScript==
  17.  
  18. /* eslint-env es6 */
  19. /* eslint-disable no-caller, no-undef, no-loop-func */
  20.  
  21. (function(skidStr, CRC2d, skid) {
  22.  
  23. class Skid {
  24. constructor() {
  25. skid = this;
  26. this.generated = false;
  27. this.gameJS = null;
  28. this.token = null;
  29. this.downKeys = new Set();
  30. this.settings = null;
  31. this.vars = {};
  32. this.playerMaps = [];
  33. this.skinCache = {};
  34. this.inputFrame = 0;
  35. this.renderFrame = 0;
  36. this.fps = 0;
  37. this.lists = {
  38. renderESP: {
  39. off: "Off",
  40. walls: "Walls",
  41. twoD: "2d",
  42. full: "Full"
  43. },
  44. renderChams: {
  45. off: "Off",
  46. "#FFFFFF": "White",
  47. "#000000": "Black",
  48. "#9400D3": "Purple",
  49. "#FF1493": "Pink",
  50. "#1E90FF": "Blue",
  51. "#0000FF": "DarkBlue",
  52. "#00FFFF": "Aqua",
  53. "#008000": "Green",
  54. "#7FFF00": "Lime",
  55. "#FF8C00": "Orange",
  56. "#FFFF00": "Yellow",
  57. "#FF0000": "Red",
  58. Rainbow: "Rainbow",
  59. },
  60. autoBhop: {
  61. off: "Off",
  62. autoJump: "Auto Jump",
  63. keyJump: "Key Jump",
  64. autoSlide: "Auto Slide",
  65. keySlide: "Key Slide"
  66. },
  67. autoAim: {
  68. off: "Off",
  69. correction: "Aim Correction",
  70. assist: "Legit Aim Assist",
  71. easyassist: "Easy Aim Assist",
  72. silent: "Silent Aim",
  73. trigger: "Trigger Bot",
  74. quickScope: "Quick Scope"
  75. },
  76. audioStreams: {
  77. off: 'Off',
  78. _2000s: 'General German/English',
  79. _HipHopRNB: 'Hip Hop / RNB',
  80. _Oldskool: 'Hip Hop Oldskool',
  81. _Country: 'Country',
  82. _Pop: 'Pop',
  83. _Dance: 'Dance',
  84. _Dubstep: 'DubStep',
  85. _Lowfi: 'LoFi HipHop',
  86. _Jazz: 'Jazz',
  87. _Oldies: 'Golden Oldies',
  88. _Club: 'Club',
  89. _Folk: 'Folk',
  90. _ClassicRock: 'Classic Rock',
  91. _Metal: 'Heavy Metal',
  92. _DeathMetal: 'Death Metal',
  93. _Classical: 'Classical',
  94. _Alternative: 'Alternative',
  95. },
  96. }
  97. this.consts = {
  98. twoPI: Math.PI * 2,
  99. halfPI: Math.PI / 2,
  100. playerHeight: 11,
  101. cameraHeight: 1.5,
  102. headScale: 2,
  103. armScale: 1.3,
  104. armInset: 0.1,
  105. chestWidth: 2.6,
  106. hitBoxPad: 1,
  107. crouchDst: 3,
  108. recoilMlt: 0.3,
  109. nameOffset: 0.6,
  110. nameOffsetHat: 0.8,
  111. };
  112. this.key = {
  113. frame: 0,
  114. delta: 1,
  115. xdir: 2,
  116. ydir: 3,
  117. moveDir: 4,
  118. shoot: 5,
  119. scope: 6,
  120. jump: 7,
  121. reload: 8,
  122. crouch: 9,
  123. weaponScroll: 10,
  124. weaponSwap: 11,
  125. moveLock: 12
  126. };
  127. this.css = {
  128. noTextShadows: `*, .button.small, .bigShadowT { text-shadow: none !important; }`,
  129. hideAdverts: `#aMerger, #endAMerger { display: none !important }`,
  130. hideSocials: `.headerBarRight > .verticalSeparator, .imageButton { display: none }`,
  131. cookieButton: `#onetrust-consent-sdk { display: none !important }`,
  132. newsHolder: `#newsHolder { display: none !important }`,
  133. };
  134. this.isProxy = Symbol("isProxy");
  135. this.spinTimer = 1800;
  136. try {
  137. this.onLoad();
  138. }
  139. catch(e) {
  140. console.error(e);
  141. console.trace(e.stack);
  142. }
  143. }
  144. canStore() {
  145. return this.isDefined(Storage);
  146. }
  147.  
  148. saveVal(name, val) {
  149. if (this.canStore()) localStorage.setItem("kro_utilities_"+name, val);
  150. }
  151.  
  152. deleteVal(name) {
  153. if (this.canStore()) localStorage.removeItem("kro_utilities_"+name);
  154. }
  155.  
  156. getSavedVal(name) {
  157. if (this.canStore()) return localStorage.getItem("kro_utilities_"+name);
  158. return null;
  159. }
  160.  
  161. isType(item, type) {
  162. return typeof item === type;
  163. }
  164.  
  165. isDefined(object) {
  166. return !this.isType(object, "undefined") && object !== null;
  167. }
  168.  
  169. isNative(fn) {
  170. return (/^function\s*[a-z0-9_\$]*\s*\([^)]*\)\s*\{\s*\[native code\]\s*\}/i).test('' + fn)
  171. }
  172.  
  173. getStatic(s, d) {
  174. return this.isDefined(s) ? s : d
  175. }
  176.  
  177. crossDomain(url) {
  178. return "https://crossorigin.me/" + url;
  179. }
  180.  
  181. async waitFor(test, timeout_ms = 2e4, doWhile = null) {
  182. let sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
  183. return new Promise(async (resolve, reject) => {
  184. if (typeof timeout_ms != "number") reject("Timeout argument not a number in waitFor(selector, timeout_ms)");
  185. let result, freq = 100;
  186. while (result === undefined || result === false || result === null || result.length === 0) {
  187. if (doWhile && doWhile instanceof Function) doWhile();
  188. if (timeout_ms % 1e4 < freq) console.log("waiting for: ", test);
  189. if ((timeout_ms -= freq) < 0) {
  190. console.log( "Timeout : ", test );
  191. resolve(false);
  192. return;
  193. }
  194. await sleep(freq);
  195. result = typeof test === "string" ? Function(test)() : test();
  196. }
  197. console.log("Passed : ", test);
  198. resolve(result);
  199. });
  200. };
  201.  
  202. async request(url, type, opt = {}) {
  203. return fetch(url, opt).then(response => {
  204. if (!response.ok) {
  205. throw new Error("Network response from " + url + " was not ok")
  206. }
  207. return response[type]()
  208. })
  209. }
  210.  
  211. async fetchScript() {
  212. const data = await this.request("https://krunker.io/social.html", "text");
  213. const buffer = await this.request("https://krunker.io/pkg/krunker." + /\w.exports="(\w+)"/.exec(data)[1] + ".vries", "arrayBuffer");
  214. const array = Array.from(new Uint8Array(buffer));
  215. const xor = array[0] ^ '!'.charCodeAt(0);
  216. return array.map((code) => String.fromCharCode(code ^ xor)).join('');
  217. }
  218.  
  219. createSettings() {
  220. this.displayStyle = (el, val) => {
  221. this.waitFor(_=>window[el], 5e3).then(node => {
  222. if (node) node.style.display = val ? "none" : "inherit";
  223. else console.error(el, " was not found in the window object");
  224. })
  225. }
  226. this.settings = {
  227. //Rendering
  228. showSkidBtn: {
  229. pre: "<div class='setHed'>Rendering</div>",
  230. name: "Show Skid Button",
  231. val: true,
  232. html: () => this.generateSetting("checkbox", "showSkidBtn", this),
  233. set: (value, init) => {
  234. let button = document.getElementById("mainButton");
  235. if (!this.isDefined(button)) this.createButton("5k1D", "https://i.imgur.com/1tWAEJx.gif", this.toggleMenu, value)
  236. else button.style.display = value ? "inherit" : "none";
  237. }
  238. },
  239. hideAdverts: {
  240. name: "Hide Advertisments",
  241. val: true,
  242. html: () => this.generateSetting("checkbox", "hideAdverts", this),
  243. set: (value, init) => {
  244. if (value) this.head.appendChild(this.css.hideAdverts)
  245. else if (!init) this.css.hideAdverts.remove()
  246. }
  247. },
  248. hideStreams: {
  249. name: "Hide Streams",
  250. val: false,
  251. html: () => this.generateSetting("checkbox", "hideStreams", this),
  252. set: (value) => { this.displayStyle("streamContainer", value) }
  253. },
  254. hideMerch: {
  255. name: "Hide Merch",
  256. val: false,
  257. html: () => this.generateSetting("checkbox", "hideMerch", this),
  258. set: (value) => { this.displayStyle("merchHolder", value) }
  259. },
  260. hideNewsConsole: {
  261. name: "Hide News Console",
  262. val: false,
  263. html: () => this.generateSetting("checkbox", "hideNewsConsole", this),
  264. set: (value) => { this.displayStyle("newsHolder", value) }
  265. },
  266. hideCookieButton: {
  267. name: "Hide Security Manage Button",
  268. val: false,
  269. html: () => this.generateSetting("checkbox", "hideCookieButton", this),
  270. set: (value) => { this.displayStyle("onetrust-consent-sdk", value) }
  271. },
  272. noTextShadows: {
  273. name: "Remove Text Shadows",
  274. val: false,
  275. html: () => this.generateSetting("checkbox", "noTextShadows", this),
  276. set: (value, init) => {
  277. if (value) this.head.appendChild(this.css.noTextShadows)
  278. else if (!init) this.css.noTextShadows.remove()
  279. }
  280. },
  281. customCSS: {
  282. name: "Custom CSS",
  283. val: "",
  284. html: () => this.generateSetting("url", "customCSS", "URL to CSS file"),
  285. resources: { css: document.createElement("link") },
  286. set: (value, init) => {
  287. if (value.startsWith("http")&&value.endsWith(".css")) {
  288. //let proxy = 'https://cors-anywhere.herokuapp.com/';
  289. this.settings.customCSS.resources.css.href = value
  290. }
  291. if (init) {
  292. this.settings.customCSS.resources.css.rel = "stylesheet"
  293. try {
  294. this.head.appendChild(this.settings.customCSS.resources.css)
  295. } catch(e) {
  296. alert(e)
  297. this.settings.customCSS.resources.css = null
  298. }
  299. }
  300. }
  301. },
  302. renderESP: {
  303. name: "Player ESP Type",
  304. val: "off",
  305. html: () =>
  306. this.generateSetting("select", "renderESP", this.lists.renderESP),
  307. },
  308. renderTracers: {
  309. name: "Player Tracers",
  310. val: false,
  311. html: () => this.generateSetting("checkbox", "renderTracers"),
  312. },
  313. rainbowColor: {
  314. name: "Rainbow ESP",
  315. val: false,
  316. html: () => this.generateSetting("checkbox", "rainbowColor"),
  317. },
  318. renderChams: {
  319. name: "Player Chams",
  320. val: "off",
  321. html: () =>
  322. this.generateSetting(
  323. "select",
  324. "renderChams",
  325. this.lists.renderChams
  326. ),
  327. },
  328. renderWireFrame: {
  329. name: "Player Wireframe",
  330. val: false,
  331. html: () => this.generateSetting("checkbox", "renderWireFrame"),
  332. },
  333. customBillboard: {
  334. name: "Custom Billboard Text",
  335. val: "",
  336. html: () =>
  337. this.generateSetting(
  338. "text",
  339. "customBillboard",
  340. "Custom Billboard Text"
  341. ),
  342. },
  343. //Weapon
  344. autoReload: {
  345. pre: "<br><div class='setHed'>Weapon</div>",
  346. name: "Auto Reload",
  347. val: false,
  348. html: () => this.generateSetting("checkbox", "autoReload"),
  349. },
  350. autoAim: {
  351. name: "Auto Aim Type",
  352. val: "off",
  353. html: () =>
  354. this.generateSetting("select", "autoAim", this.lists.autoAim),
  355. },
  356. frustrumCheck: {
  357. name: "Line of Sight Check",
  358. val: false,
  359. html: () => this.generateSetting("checkbox", "frustrumCheck"),
  360. },
  361. wallPenetrate: {
  362. name: "Aim through Penetratables",
  363. val: false,
  364. html: () => this.generateSetting("checkbox", "wallPenetrate"),
  365. },
  366. weaponZoom: {
  367. name: "Weapon Zoom",
  368. val: 1.0,
  369. min: 0,
  370. max: 50.0,
  371. step: 0.01,
  372. html: () => this.generateSetting("slider", "weaponZoom"),
  373. set: (value) => { if (this.renderer) this.renderer.adsFovMlt = value;}
  374. },
  375. weaponTrails: {
  376. name: "Weapon Trails",
  377. val: false,
  378. html: () => this.generateSetting("checkbox", "weaponTrails"),
  379. set: (value) => { if (this.me) this.me.weapon.trail = value;}
  380. },
  381. //Player
  382. autoBhop: {
  383. pre: "<br><div class='setHed'>Player</div>",
  384. name: "Auto Bhop Type",
  385. val: "off",
  386. html: () => this.generateSetting("select", "autoBhop", this.lists.autoBhop),
  387. },
  388. thirdPerson: {
  389. name: "Third Person",
  390. val: false,
  391. html: () => this.generateSetting("checkbox", "thirdPerson"),
  392. set: (value, init) => {
  393. if (value) this.thirdPerson = 1;
  394. else if (!init) this.thirdPerson = undefined;
  395. }
  396. },
  397. skinUnlock: {
  398. name: "Unlock Skins",
  399. val: false,
  400. html: () => this.generateSetting("checkbox", "skinUnlock", this),
  401. },
  402. //GamePlay
  403. disableWpnSnd: {
  404. pre: "<br><div class='setHed'>GamePlay</div>",
  405. name: "Disable Players Weapon Sounds",
  406. val: false,
  407. html: () => this.generateSetting("checkbox", "disableWpnSnd", this),
  408. },
  409. disableHckSnd: {
  410. name: "Disable Hacker Fart Sounds",
  411. val: false,
  412. html: () => this.generateSetting("checkbox", "disableHckSnd", this),
  413. },
  414. autoActivateNuke: {
  415. name: "Auto Activate Nuke",
  416. val: false,
  417. html: () => this.generateSetting("checkbox", "autoActivateNuke", this),
  418. },
  419. autoFindNew: {
  420. name: "New Lobby Finder",
  421. val: false,
  422. html: () => this.generateSetting("checkbox", "autoFindNew", this),
  423. },
  424. autoClick: {
  425. name: "Auto Start Game",
  426. val: false,
  427. html: () => this.generateSetting("checkbox", "autoClick", this),
  428. },
  429. inActivity: {
  430. name: "No InActivity Kick",
  431. val: true,
  432. html: () => this.generateSetting("checkbox", "autoClick", this),
  433. },
  434. //Radio Stream Player
  435. playStream: {
  436. pre: "<br><div class='setHed'>Radio Stream Player</div>",
  437. name: "Stream Select",
  438. val: "off",
  439. html: () => this.generateSetting("select", "playStream", this.lists.audioStreams),
  440. set: (value) => {
  441. if (value == "off") {
  442. if ( this.settings.playStream.audio ) {
  443. this.settings.playStream.audio.pause();
  444. this.settings.playStream.audio.currentTime = 0;
  445. this.settings.playStream.audio = null;
  446. }
  447. return;
  448. }
  449. let url = this.settings.playStream.urls[value];
  450. if (!this.settings.playStream.audio) {
  451. this.settings.playStream.audio = new Audio(url);
  452. this.settings.playStream.audio.volume = this.settings.audioVolume.val||0.5
  453. } else {
  454. this.settings.playStream.audio.src = url;
  455. }
  456. this.settings.playStream.audio.load();
  457. this.settings.playStream.audio.play();
  458. },
  459. urls: {
  460. _2000s: 'http://0n-2000s.radionetz.de/0n-2000s.aac',
  461. _HipHopRNB: 'https://stream-mixtape-geo.ntslive.net/mixtape2',
  462. _Country: 'https://live.wostreaming.net/direct/wboc-waaifmmp3-ibc2',
  463. _Dance: 'http://streaming.radionomy.com/A-RADIO-TOP-40',
  464. _Pop: 'http://bigrradio.cdnstream1.com/5106_128',
  465. _Jazz: 'http://strm112.1.fm/ajazz_mobile_mp3',
  466. _Oldies: 'http://strm112.1.fm/60s_70s_mobile_mp3',
  467. _Club: 'http://strm112.1.fm/club_mobile_mp3',
  468. _Folk: 'https://freshgrass.streamguys1.com/irish-128mp3',
  469. _ClassicRock: 'http://1a-classicrock.radionetz.de/1a-classicrock.mp3',
  470. _Metal: 'http://streams.radiobob.de/metalcore/mp3-192',
  471. _DeathMetal: 'http://stream.laut.fm/beatdownx',
  472. _Classical: 'http://live-radio01.mediahubaustralia.com/FM2W/aac/',
  473. _Alternative: 'http://bigrradio.cdnstream1.com/5187_128',
  474. _Dubstep: 'http://streaming.radionomy.com/R1Dubstep?lang=en',
  475. _Lowfi: 'http://streams.fluxfm.de/Chillhop/mp3-256',
  476. _Oldskool: 'http://streams.90s90s.de/hiphop/mp3-128/',
  477. },
  478. audio: null,
  479. },
  480. audioVolume: {
  481. name: "Radio Volume",
  482. val: 0.5,
  483. min: 0,
  484. max: 1,
  485. step: 0.01,
  486. html: () => this.generateSetting("slider", "audioVolume"),
  487. set: (value) => { if (this.settings.playStream.audio) this.settings.playStream.audio.volume = value;}
  488. },
  489. };
  490.  
  491. const menu = window.windows[11];
  492. menu.header = "Settings";
  493. menu.gen = _ => {
  494. var tmpHTML = `<div style='text-align:center'> <a onclick='window.open("https://skidlamer.github.io/")' class='menuLink'>SkidFest Settings</center></a> <hr> </div>`;
  495. for (const key in this.settings) {
  496. if (this.settings[key].pre) tmpHTML += this.settings[key].pre;
  497. tmpHTML += "<div class='settName' id='" + key + "_div' style='display:" + (this.settings[key].hide ? 'none' : 'block') + "'>" + this.settings[key].name +
  498. " " + this.settings[key].html() + "</div>";
  499. }
  500. tmpHTML += `<br><hr><a onclick='${skidStr}.resetSettings()' class='menuLink'>Reset Settings</a> | <a onclick='${skidStr}.saveScript()' class='menuLink'>Save GameScript</a>`
  501. return tmpHTML;
  502. };
  503.  
  504. // setupSettings
  505. for (const key in this.settings) {
  506. this.settings[key].def = this.settings[key].val;
  507. if (!this.settings[key].disabled) {
  508. let tmpVal = this.getSavedVal(key);
  509. this.settings[key].val = tmpVal !== null ? tmpVal : this.settings[key].val;
  510. if (this.settings[key].val == "false") this.settings[key].val = false;
  511. if (this.settings[key].val == "true") this.settings[key].val = true;
  512. if (this.settings[key].val == "undefined") this.settings[key].val = this.settings[key].def;
  513. if (this.settings[key].set) this.settings[key].set(this.settings[key].val, true);
  514. }
  515. }
  516. }
  517.  
  518. generateSetting(type, name, extra) {
  519. switch (type) {
  520. case 'checkbox':
  521. return `<label class="switch"><input type="checkbox" onclick="${skidStr}.setSetting('${name}', this.checked)" ${this.settings[name].val ? 'checked' : ''}><span class="slider"></span></label>`;
  522. case 'slider':
  523. return `<span class='sliderVal' id='slid_utilities_${name}'>${this.settings[name].val}</span><div class='slidecontainer'><input type='range' min='${this.settings[name].min}' max='${this.settings[name].max}' step='${this.settings[name].step}' value='${this.settings[name].val}' class='sliderM' oninput="${skidStr}.setSetting('${name}', this.value)"></div>`
  524. case 'select': {
  525. let temp = `<select onchange="${skidStr}.setSetting(\x27${name}\x27, this.value)" class="inputGrey2">`;
  526. for (let option in extra) {
  527. temp += '<option value="' + option + '" ' + (option == this.settings[name].val ? 'selected' : '') + '>' + extra[option] + '</option>';
  528. }
  529. temp += '</select>';
  530. return temp;
  531. }
  532. default:
  533. return `<input type="${type}" name="${type}" id="slid_utilities_${name}"\n${'color' == type ? 'style="float:right;margin-top:5px"' : `class="inputGrey2" placeholder="${extra}"`}\nvalue="${this.settings[name].val}" oninput="${skidStr}.setSetting(\x27${name}\x27, this.value)"/>`;
  534. }
  535. }
  536.  
  537. resetSettings() {
  538. if (confirm("Are you sure you want to reset all your settings? This will also refresh the page")) {
  539. Object.keys(localStorage).filter(x => x.includes("kro_utilities_")).forEach(x => localStorage.removeItem(x));
  540. location.reload();
  541. }
  542. }
  543.  
  544. setSetting(t, e) {
  545. this.settings[t].val = e;
  546. this.saveVal(t, e);
  547. if (document.getElementById(`slid_utilities_${t}`)) document.getElementById(`slid_utilities_${t}`).innerHTML = e;
  548. if (this.settings[t].set) this.settings[t].set(e);
  549. }
  550.  
  551. createObserver(elm, check, callback, onshow = true) {
  552. return new MutationObserver((mutationsList, observer) => {
  553. if (check == 'src' || onshow && mutationsList[0].target.style.display == 'block' || !onshow) {
  554. callback(mutationsList[0].target);
  555. }
  556. }).observe(elm, check == 'childList' ? {childList: true} : {attributes: true, attributeFilter: [check]});
  557. }
  558.  
  559. createListener(elm, type, callback = null) {
  560. if (!this.isDefined(elm)) {
  561. alert("Failed creating " + type + "listener");
  562. return
  563. }
  564. elm.addEventListener(type, event => callback(event));
  565. }
  566.  
  567. createElement(element, attribute, inner) {
  568. if (!this.isDefined(element)) {
  569. return null;
  570. }
  571. if (!this.isDefined(inner)) {
  572. inner = "";
  573. }
  574. let el = document.createElement(element);
  575. if (this.isType(attribute, 'object')) {
  576. for (let key in attribute) {
  577. el.setAttribute(key, attribute[key]);
  578. }
  579. }
  580. if (!Array.isArray(inner)) {
  581. inner = [inner];
  582. }
  583. for (let i = 0; i < inner.length; i++) {
  584. if (inner[i].tagName) {
  585. el.appendChild(inner[i]);
  586. } else {
  587. el.appendChild(document.createTextNode(inner[i]));
  588. }
  589. }
  590. return el;
  591. }
  592.  
  593. createButton(name, iconURL, fn, visible) {
  594. visible = visible ? "inherit":"none";
  595. this.waitFor(_=>document.querySelector("#menuItemContainer")).then(menu => {
  596. let icon = this.createElement("div",{"class":"menuItemIcon", "style":`background-image:url("${iconURL}");display:inherit;`});
  597. let title= this.createElement("div",{"class":"menuItemTitle", "style":`display:inherit;`}, name);
  598. let host = this.createElement("div",{"id":"mainButton", "class":"menuItem", "onmouseenter":"playTick()", "onclick":"showWindow(12)", "style":`display:${visible};`},[icon, title]);
  599. if (menu) menu.append(host)
  600. })
  601. }
  602.  
  603. objectHas(obj, arr) {
  604. return arr.some(prop => obj.hasOwnProperty(prop));
  605. }
  606.  
  607. getVersion() {
  608. const elems = document.getElementsByClassName('terms');
  609. const version = elems[elems.length - 1].innerText;
  610. return version;
  611. }
  612.  
  613. saveAs(name, data) {
  614. let blob = new Blob([data], {type: 'text/plain'});
  615. let el = window.document.createElement("a");
  616. el.href = window.URL.createObjectURL(blob);
  617. el.download = name;
  618. window.document.body.appendChild(el);
  619. el.click();
  620. window.document.body.removeChild(el);
  621. }
  622.  
  623. saveScript() {
  624. this.fetchScript().then(script => {
  625. this.saveAs("game_" + this.getVersion() + ".js", script)
  626. })
  627. }
  628.  
  629. isKeyDown(key) {
  630. return this.downKeys.has(key);
  631. }
  632.  
  633. simulateKey(keyCode) {
  634. var oEvent = document.createEvent('KeyboardEvent');
  635. // Chromium Hack
  636. Object.defineProperty(oEvent, 'keyCode', {
  637. get : function() {
  638. return this.keyCodeVal;
  639. }
  640. });
  641. Object.defineProperty(oEvent, 'which', {
  642. get : function() {
  643. return this.keyCodeVal;
  644. }
  645. });
  646.  
  647. if (oEvent.initKeyboardEvent) {
  648. oEvent.initKeyboardEvent("keypress", true, true, document.defaultView, keyCode, keyCode, "", "", false, "");
  649. } else {
  650. oEvent.initKeyEvent("keypress", true, true, document.defaultView, false, false, false, false, keyCode, 0);
  651. }
  652.  
  653. oEvent.keyCodeVal = keyCode;
  654.  
  655. if (oEvent.keyCode !== keyCode) {
  656. alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
  657. }
  658.  
  659. document.body.dispatchEvent(oEvent);
  660. }
  661.  
  662. toggleMenu() {
  663. let lock = document.pointerLockElement || document.mozPointerLockElement;
  664. if (lock) document.exitPointerLock();
  665. window.showWindow(12);
  666. if (this.isDefined(window.SOUND)) window.SOUND.play(`tick_0`,0.1)
  667. }
  668.  
  669. onLoad() {
  670. this.waitFor(_=>document.documentElement instanceof window.HTMLElement).then(_=>{
  671. this.iframe();
  672. })
  673. this.createObservers();
  674. this.waitFor(_=>this.head, 1e4, _=> { this.head = document.head||document.getElementsByTagName('head')[0] }).then(head => {
  675. if (!head) location.reload();
  676. Object.entries(this.css).forEach(entry => {
  677. this.css[entry[0]] = this.createElement("style", entry[1]);
  678. })
  679. this.waitFor(_=>window.windows, 3e5).then(_ => {
  680. this.createSettings();
  681. })
  682. })
  683.  
  684. this.waitFor(_=>this.token).then(_ => {
  685. if (!this.token) location.reload();
  686. const loader = new Function("WP_fetchMMToken", "Module", this.gamePatch());
  687. loader(new Promise(res=>res(this.token)), { csv: async () => 0 });
  688. })
  689. this.waitFor(_=>this.exports, 1e4).then(exports => {
  690. if (!exports) return alert("This Script needs updating");
  691. else {
  692. //console.dir(exports)
  693. let toFind = {
  694. overlay: ["render", "canvas"],
  695. config: ["accAnnounce", "availableRegions", "assetCat"],
  696. three: ["ACESFilmicToneMapping", "TextureLoader", "ObjectLoader"],
  697. ws: ["socketReady", "ingressPacketCount", "ingressPacketCount", "egressDataSize"],
  698. //utility: ["VectorAdd", "VectorAngleSign"],
  699. //colors: ["challLvl", "getChallCol"],
  700. //ui: ["showEndScreen", "toggleControlUI", "toggleEndScreen", "updatePlayInstructions"],
  701. //events: ["actions", "events"],
  702. }
  703. for (let rootKey in this.exports) {
  704. let exp = this.exports[rootKey].exports;
  705. for (let name in toFind) {
  706. if (this.objectHas(exp, toFind[name])) {
  707. console.log("Found Export ", name);
  708. delete toFind[name];
  709. this[name] = exp;
  710. }
  711. }
  712. }
  713. if (!(Object.keys(toFind).length === 0 && toFind.constructor === Object)) {
  714. for (let name in toFind) {
  715. alert("Failed To Find Export " + name);
  716. }
  717. } else {
  718. Object.defineProperty(this.config, "nameVisRate", {
  719. value: 0,
  720. writable: false,
  721. configurable: true,
  722. })
  723. this.ctx = this.overlay.canvas.getContext('2d');
  724. this.overlay.render = new Proxy(this.overlay.render, {
  725. apply: function(target, that, args) {
  726. return [target.apply(that, args), render.apply(that, args)]
  727. }
  728. })
  729. function render(scale, game, controls, renderer, me) {
  730. let width = skid.overlay.canvas.width / scale;
  731. let height = skid.overlay.canvas.height / scale;
  732. const renderArgs = [scale, game, controls, renderer, me];
  733. if (renderArgs && void 0 !== skid) {
  734. ["scale", "game", "controls", "renderer", "me"].forEach((item, index)=>{
  735. skid[item] = renderArgs[index];
  736. });
  737. if (me) {
  738. skid.ctx.save();
  739. skid.ctx.scale(scale, scale);
  740. //this.ctx.clearRect(0, 0, width, height);
  741. skid.onRender();
  742. //window.requestAnimationFrame.call(window, renderArgs.callee.caller.bind(this));
  743. skid.ctx.restore();
  744. }
  745. if(skid.settings && skid.settings.autoClick.val && window.endUI.style.display == "none" && window.windowHolder.style.display == "none") {
  746. controls.toggle(true);
  747. }
  748. }
  749. }
  750.  
  751. // Skins
  752. const $skins = Symbol("skins");
  753. Object.defineProperty(Object.prototype, "skins", {
  754. set: function(fn) {
  755. this[$skins] = fn;
  756. if (void 0 == this.localSkins || !this.localSkins.length) {
  757. this.localSkins = Array.apply(null, Array(5e3)).map((x, i) => {
  758. return {
  759. ind: i,
  760. cnt: 0x1,
  761. }
  762. })
  763. }
  764. return fn;
  765. },
  766. get: function() {
  767. return skid.settings.skinUnlock.val && this.stats ? this.localSkins : this[$skins];
  768. }
  769. })
  770.  
  771. this.waitFor(_=>this.ws.connected === true, 4e4).then(_=> {
  772. this.wsEvent = this.ws._dispatchEvent.bind(this.ws);
  773. this.wsSend = this.ws.send.bind(this.ws);
  774. this.ws.send = new Proxy(this.ws.send, {
  775. apply: function(target, that, args) {
  776. if (args[0] == "ah2") return;
  777. try {
  778. var original_fn = Function.prototype.apply.apply(target, [that, args]);
  779. } catch (e) {
  780. e.stack = e.stack = e.stack.replace(/\n.*Object\.apply.*/, '');
  781. throw e;
  782. }
  783.  
  784. if (args[0] === "en") {
  785. skid.skinCache = {
  786. main: args[1][2][0],
  787. secondary: args[1][2][1],
  788. hat: args[1][3],
  789. body: args[1][4],
  790. knife: args[1][9],
  791. dye: args[1][14],
  792. waist: args[1][17],
  793. }
  794. }
  795.  
  796. return original_fn;
  797. }
  798. })
  799.  
  800. this.ws._dispatchEvent = new Proxy(this.ws._dispatchEvent, {
  801. apply: function(target, that, [type, event]) {
  802. if (type =="init") {
  803. if(event[10] && event[10].length && event[10].bill && skid.settings.customBillboard.val.length > 1) {
  804. event[10].bill.txt = skid.settings.customBillboard.val;
  805. }
  806. }
  807.  
  808. if (skid.settings.skinUnlock.val && skid.skinCache && type === "0") {
  809. let skins = skid.skinCache;
  810. let pInfo = event[0];
  811. let pSize = 38;
  812. while (pInfo.length % pSize !== 0) pSize++;
  813. for(let i = 0; i < pInfo.length; i += pSize) {
  814. if (pInfo[i] === skid.ws.socketId||0) {
  815. pInfo[i + 12] = [skins.main, skins.secondary];
  816. pInfo[i + 13] = skins.hat;
  817. pInfo[i + 14] = skins.body;
  818. pInfo[i + 19] = skins.knife;
  819. pInfo[i + 24] = skins.dye;
  820. pInfo[i + 33] = skins.waist;
  821. }
  822. }
  823. }
  824.  
  825. return target.apply(that, arguments[2]);
  826. }
  827. })
  828. })
  829.  
  830. if (this.isDefined(window.SOUND)) {
  831. window.SOUND.play = new Proxy(window.SOUND.play, {
  832. apply: function(target, that, [src, vol, loop, rate]) {
  833. if ( src.startsWith("fart_") && skid.settings.disableHckSnd.val ) return;
  834. return target.apply(that, [src, vol, loop, rate]);
  835. }
  836. })
  837. }
  838.  
  839. AudioParam.prototype.setValueAtTime = new Proxy(AudioParam.prototype.setValueAtTime, {
  840. apply: function(target, that, [value, startTime]) {
  841. return target.apply(that, [value, 0]);
  842. }
  843. })
  844.  
  845. this.rayC = new this.three.Raycaster();
  846. this.vec2 = new this.three.Vector2(0, 0);
  847. }
  848. }
  849. })
  850. }
  851.  
  852. gamePatch() {
  853. let entries = {
  854. // Deobfu
  855. inView: { regex: /(\w+\['(\w+)']\){if\(\(\w+=\w+\['\w+']\['position']\['clone']\(\))/, index: 2 },
  856. spectating: { regex: /\['team']:window\['(\w+)']/, index: 1 },
  857. //inView: { regex: /\]\)continue;if\(!\w+\['(.+?)\']\)continue;/, index: 1 },
  858. //canSee: { regex: /\w+\['(\w+)']\(\w+,\w+\['x'],\w+\['y'],\w+\['z']\)\)&&/, index: 1 },
  859. //procInputs: { regex: /this\['(\w+)']=function\((\w+),(\w+),\w+,\w+\){(this)\['recon']/, index: 1 },
  860. aimVal: { regex: /this\['(\w+)']-=0x1\/\(this\['weapon']\['\w+']\/\w+\)/, index: 1 },
  861. pchObjc: { regex: /0x0,this\['(\w+)']=new \w+\['Object3D']\(\),this/, index: 1 },
  862. didShoot: { regex: /--,\w+\['(\w+)']=!0x0/, index: 1 },
  863. nAuto: { regex: /'Single\\x20Fire','varN':'(\w+)'/, index: 1 },
  864. crouchVal: { regex: /this\['(\w+)']\+=\w\['\w+']\*\w+,0x1<=this\['\w+']/, index: 1 },
  865. recoilAnimY: { regex: /\+\(-Math\['PI']\/0x4\*\w+\+\w+\['(\w+)']\*\w+\['\w+']\)\+/, index: 1 },
  866. //recoilAnimY: { regex: /this\['recoilAnim']=0x0,this\[(.*?\(''\))]/, index: 1 },
  867. ammos: { regex: /\['length'];for\(\w+=0x0;\w+<\w+\['(\w+)']\['length']/, index: 1 },
  868. weaponIndex: { regex: /\['weaponConfig']\[\w+]\['secondary']&&\(\w+\['(\w+)']==\w+/, index: 1 },
  869. isYou: { regex: /0x0,this\['(\w+)']=\w+,this\['\w+']=!0x0,this\['inputs']/, index: 1 },
  870. objInstances: { regex: /\w+\['\w+']\(0x0,0x0,0x0\);if\(\w+\['(\w+)']=\w+\['\w+']/, index: 1 },
  871. getWorldPosition: { regex: /{\w+=\w+\['camera']\['(\w+)']\(\);/, index: 1 },
  872. //mouseDownL: { regex: /this\['\w+'\]=function\(\){this\['(\w+)'\]=\w*0,this\['(\w+)'\]=\w*0,this\['\w+'\]={}/, index: 1 },
  873. mouseDownR: { regex: /this\['(\w+)']=0x0,this\['keys']=/, index: 1 },
  874. //reloadTimer: { regex: /this\['(\w+)']&&\(\w+\['\w+']\(this\),\w+\['\w+']\(this\)/, index: 1 },
  875. maxHealth: { regex: /this\['health']\/this\['(\w+)']\?/, index: 1 },
  876. xDire: { regex: /this\['(\w+)']=Math\['lerpAngle']\(this\['xDir2']/, index: 1 },
  877. yDire: { regex: /this\['(\w+)']=Math\['lerpAngle']\(this\['yDir2']/, index: 1 },
  878. //xVel: { regex: /this\['x']\+=this\['(\w+)']\*\w+\['map']\['config']\['speedX']/, index: 1 },
  879. yVel: { regex: /this\['y']\+=this\['(\w+)']\*\w+\['map']\['config']\['speedY']/, index: 1 },
  880. //zVel: { regex: /this\['z']\+=this\['(\w+)']\*\w+\['map']\['config']\['speedZ']/, index: 1 },
  881.  
  882. // Patches
  883. exports: {regex: /(this\['\w+']\['\w+']\(this\);};},function\(\w+,\w+,(\w+)\){)/, patch: `$1 ${skidStr}.exports=$2.c; ${skidStr}.modules=$2.m;`},
  884. inputs: {regex: /(\w+\['\w+']\[\w+\['\w+']\['\w+']\?'\w+':'push']\()(\w+)\),/, patch: `$1${skidStr}.onInput($2)),`},
  885. inView: {regex: /&&(\w+\['\w+'])\){(if\(\(\w+=\w+\['\w+']\['\w+']\['\w+'])/, patch: `){if(!$1&&void 0 !== ${skidStr}.nameTags)continue;$2`},
  886. thirdPerson:{regex: /(\w+)\[\'config\'\]\[\'thirdPerson\'\]/g, patch: `void 0 !== ${skidStr}.thirdPerson`},
  887. isHacker:{regex: /(window\['\w+']=)!0x0\)/, patch: `$1!0x1)`},
  888. fixHowler:{regex: /(Howler\['orientation'](.+?)\)\),)/, patch: ``},
  889. respawnT:{regex: /'\w+':0x3e8\*/g, patch: `'respawnT':0x0*`},
  890. anticheat1:{regex: /&&\w+\(\),window\['utilities']&&\(\w+\(null,null,null,!0x0\),\w+\(\)\)/, patch: ""},
  891. anticheat2:{regex: /(\[]instanceof Array;).*?(var)/, patch: "$1 $2"},
  892. anticheat3:{regex: /windows\['length'\]>\d+.*?0x25/, patch: `0x25`},
  893. commandline:{regex: /Object\['defineProperty']\(console.*?\),/, patch: ""},
  894. writeable:{regex: /'writeable':!0x1/g, patch: "writeable:true"},
  895. configurable:{regex: /'configurable':!0x1/g, patch: "configurable:true"},
  896. typeError:{regex: /throw new TypeError/g, patch: "console.error"},
  897. error:{regex: /throw new Error/g, patch: "console.error"},
  898. };
  899. let script = this.gameJS;
  900. for(let name in entries) {
  901. let object = entries[name];
  902. let found = object.regex.exec(script);
  903. if (object.hasOwnProperty('index')) {
  904. if (!found) {
  905. object.val = null;
  906. alert("Failed to Find " + name);
  907. } else {
  908. object.val = found[object.index];
  909. console.log ("Found ", name, ":", object.val);
  910. }
  911. Object.defineProperty(skid.vars, name, {
  912. configurable: false,
  913. value: object.val
  914. });
  915. } else if (found) {
  916. script = script.replace(object.regex, object.patch);
  917. console.log ("Patched ", name);
  918. } else alert("Failed to Patch " + name);
  919. }
  920. return script;
  921. }
  922.  
  923. iframe() {
  924. const iframe = document.createElement('iframe');
  925. iframe.setAttribute('style', 'display:none');
  926. iframe.setAttribute("id", skidStr);
  927. iframe.src = location.origin;
  928. document.documentElement.appendChild(iframe);
  929.  
  930. const ifrWin = iframe.contentWindow;
  931. const ifrDoc = iframe.contentDocument?iframe.contentDocument:iframe.contentWindow.document;
  932.  
  933. ifrWin.TextDecoder.prototype.decode = new Proxy(window.TextDecoder.prototype.decode, {
  934. apply: function(target, that, args) {
  935. let string = Reflect.apply(...arguments);
  936. if (string.length > 1e6) {
  937. if (!skid.gameJS) {
  938. skid.gameJS = string;
  939. console.log("1stSTR");
  940. } else {
  941. skid.gameJS += string;
  942. console.log("2ndSTR");
  943. }
  944. }
  945. if (string.includes("generate-token")) skid.generated = true;
  946. else if (string.length == 40||skid.generated) {
  947. skid.token = string;
  948. console.log("Token ", string);
  949. document.documentElement.removeChild(iframe);
  950. }
  951. return string;
  952. },
  953. });
  954. }
  955.  
  956. createObservers() {
  957.  
  958. let observer = new MutationObserver(mutations => {
  959. for (let mutation of mutations) {
  960. for (let node of mutation.addedNodes) {
  961. if (node.tagName === 'SCRIPT' && node.type === "text/javascript" && node.innerHTML.startsWith("*!", 1)) {
  962. node.innerHTML = "";
  963. observer.disconnect();
  964. }
  965. }
  966. }
  967. });
  968. observer.observe(document, {
  969. childList: true,
  970. subtree: true
  971. });
  972.  
  973. this.waitFor(_=>window.instructionsUpdate, 2e3).then(_ => {
  974. this.createObserver(window.instructionsUpdate, 'style', (target) => {
  975. if (this.settings.autoFindNew.val) {
  976. console.log(target)
  977. if (['Kicked', 'Banned', 'Disconnected', 'Error', 'Game is full'].some(text => target && target.innerHTML.includes(text))) {
  978. location = document.location.origin;
  979. }
  980. }
  981. });
  982. })
  983.  
  984. this.createListener(document, "keyup", event => {
  985. if (this.downKeys.has(event.code)) this.downKeys.delete(event.code)
  986. })
  987.  
  988. this.createListener(document, "keydown", event => {
  989. if (event.code == "F1") {
  990. event.preventDefault();
  991. this.toggleMenu();
  992. }
  993. if ('INPUT' == document.activeElement.tagName || !window.endUI && window.endUI.style.display) return;
  994. switch (event.code) {
  995. case 'NumpadSubtract':
  996. document.exitPointerLock();
  997. //console.log(document.exitPointerLock)
  998. console.dirxml(this)
  999. break;
  1000. default:
  1001. if (!this.downKeys.has(event.code)) this.downKeys.add(event.code);
  1002. break;
  1003. }
  1004. })
  1005.  
  1006. this.createListener(document, "mouseup", event => {
  1007. switch (event.button) {
  1008. case 1:
  1009. event.preventDefault();
  1010. this.toggleMenu();
  1011. break;
  1012. default:
  1013. break;
  1014. }
  1015. })
  1016. }
  1017.  
  1018. onRender() { /* hrt / ttap - https://github.com/hrt */
  1019. this.renderFrame ++;
  1020. if (this.renderFrame >= 100000) this.renderFrame = 0;
  1021. let scaledWidth = this.ctx.canvas.width / this.scale;
  1022. let scaledHeight = this.ctx.canvas.height / this.scale;
  1023. let playerScale = (2 * this.consts.armScale + this.consts.chestWidth + this.consts.armInset) / 2
  1024. let worldPosition = this.renderer.camera[this.vars.getWorldPosition]();
  1025. let espVal = this.settings.renderESP.val;
  1026. if (espVal ==="walls"||espVal ==="twoD") this.nameTags = undefined; else this.nameTags = true;
  1027.  
  1028. if (this.settings.autoActivateNuke.val && this.me && Object.keys(this.me.streaks).length) { /*chonker*/
  1029. this.wsSend("k", 0);
  1030. }
  1031.  
  1032. if (espVal !== "off") {
  1033. this.overlay.healthColE = this.settings.rainbowColor.val ? this.overlay.rainbow.col : "#eb5656";
  1034. }
  1035.  
  1036. for (let iter = 0, length = this.game.players.list.length; iter < length; iter++) {
  1037. let player = this.game.players.list[iter];
  1038. if (player[this.vars.isYou] || !player.active || !this.isDefined(player[this.vars.objInstances]) || this.getIsFriendly(player)) {
  1039. continue;
  1040. }
  1041.  
  1042. // the below variables correspond to the 2d box esps corners
  1043. let xmin = Infinity;
  1044. let xmax = -Infinity;
  1045. let ymin = Infinity;
  1046. let ymax = -Infinity;
  1047. let position = null;
  1048. let br = false;
  1049. for (let j = -1; !br && j < 2; j+=2) {
  1050. for (let k = -1; !br && k < 2; k+=2) {
  1051. for (let l = 0; !br && l < 2; l++) {
  1052. if (position = player[this.vars.objInstances].position.clone()) {
  1053. position.x += j * playerScale;
  1054. position.z += k * playerScale;
  1055. position.y += l * (player.height - player[this.vars.crouchVal] * this.consts.crouchDst);
  1056. if (!this.containsPoint(position)) {
  1057. br = true;
  1058. break;
  1059. }
  1060. position.project(this.renderer.camera);
  1061. xmin = Math.min(xmin, position.x);
  1062. xmax = Math.max(xmax, position.x);
  1063. ymin = Math.min(ymin, position.y);
  1064. ymax = Math.max(ymax, position.y);
  1065. }
  1066. }
  1067. }
  1068. }
  1069.  
  1070. if (br) {
  1071. continue;
  1072. }
  1073.  
  1074. xmin = (xmin + 1) / 2;
  1075. ymin = (ymin + 1) / 2;
  1076. xmax = (xmax + 1) / 2;
  1077. ymax = (ymax + 1) / 2;
  1078.  
  1079. // save and restore these variables later so they got nothing on us
  1080. const original_strokeStyle = this.ctx.strokeStyle;
  1081. const original_lineWidth = this.ctx.lineWidth;
  1082. const original_font = this.ctx.font;
  1083. const original_fillStyle = this.ctx.fillStyle;
  1084.  
  1085. //Tracers
  1086. if (this.settings.renderTracers.val) {
  1087. CRC2d.save.apply(this.ctx, []);
  1088. let screenPos = this.world2Screen(player[this.vars.objInstances].position);
  1089. this.ctx.lineWidth = 4.5;
  1090. this.ctx.beginPath();
  1091. this.ctx.moveTo(this.ctx.canvas.width/2, this.ctx.canvas.height - (this.ctx.canvas.height - scaledHeight));
  1092. this.ctx.lineTo(screenPos.x, screenPos.y);
  1093. this.ctx.strokeStyle = "rgba(0, 0, 0, 0.25)";
  1094. this.ctx.stroke();
  1095. this.ctx.lineWidth = 2.5;
  1096. this.ctx.strokeStyle = this.settings.rainbowColor.val ? this.overlay.rainbow.col : "#eb5656"
  1097. this.ctx.stroke();
  1098. CRC2d.restore.apply(this.ctx, []);
  1099. }
  1100.  
  1101. CRC2d.save.apply(this.ctx, []);
  1102. if (espVal == "twoD" || espVal == "full") {
  1103. // perfect box esp
  1104. this.ctx.lineWidth = 5;
  1105. this.ctx.strokeStyle = this.settings.rainbowColor.val ? this.overlay.rainbow.col : "#eb5656"
  1106. let distanceScale = Math.max(.3, 1 - this.getD3D(worldPosition.x, worldPosition.y, worldPosition.z, player.x, player.y, player.z) / 600);
  1107. CRC2d.scale.apply(this.ctx, [distanceScale, distanceScale]);
  1108. let xScale = scaledWidth / distanceScale;
  1109. let yScale = scaledHeight / distanceScale;
  1110. CRC2d.beginPath.apply(this.ctx, []);
  1111. ymin = yScale * (1 - ymin);
  1112. ymax = yScale * (1 - ymax);
  1113. xmin = xScale * xmin;
  1114. xmax = xScale * xmax;
  1115. CRC2d.moveTo.apply(this.ctx, [xmin, ymin]);
  1116. CRC2d.lineTo.apply(this.ctx, [xmin, ymax]);
  1117. CRC2d.lineTo.apply(this.ctx, [xmax, ymax]);
  1118. CRC2d.lineTo.apply(this.ctx, [xmax, ymin]);
  1119. CRC2d.lineTo.apply(this.ctx, [xmin, ymin]);
  1120. CRC2d.stroke.apply(this.ctx, []);
  1121.  
  1122. if (espVal == "full") {
  1123. // health bar
  1124. this.ctx.fillStyle = "#000000";
  1125. let barMaxHeight = ymax - ymin;
  1126. CRC2d.fillRect.apply(this.ctx, [xmin - 7, ymin, -10, barMaxHeight]);
  1127. this.ctx.fillStyle = player.health > 75 ? "green" : player.health > 40 ? "orange" : "red";
  1128. CRC2d.fillRect.apply(this.ctx, [xmin - 7, ymin, -10, barMaxHeight * (player.health / player[this.vars.maxHealth])]);
  1129. // info
  1130. this.ctx.font = "Bold 48px Tahoma";
  1131. this.ctx.fillStyle = "white";
  1132. this.ctx.strokeStyle='black';
  1133. this.ctx.lineWidth = 1;
  1134. let x = xmax + 7;
  1135. let y = ymax;
  1136. CRC2d.fillText.apply(this.ctx, [player.name||player.alias, x, y]);
  1137. CRC2d.strokeText.apply(this.ctx, [player.name||player.alias, x, y]);
  1138. this.ctx.font = "Bold 30px Tahoma";
  1139. this.ctx.fillStyle = "#cccccc";
  1140. y += 35;
  1141. CRC2d.fillText.apply(this.ctx, [player.weapon.name, x, y]);
  1142. CRC2d.strokeText.apply(this.ctx, [player.weapon.name, x, y]);
  1143. y += 35;
  1144. this.ctx.fillStyle = player.health > 75 ? "green" : player.health > 40 ? "orange" : "red";
  1145. CRC2d.fillText.apply(this.ctx, [player.health + ' HP', x, y]);
  1146. CRC2d.strokeText.apply(this.ctx, [player.health + ' HP', x, y]);
  1147. }
  1148. }
  1149.  
  1150. CRC2d.restore.apply(this.ctx, []);
  1151. this.ctx.strokeStyle = original_strokeStyle;
  1152. this.ctx.lineWidth = original_lineWidth;
  1153. this.ctx.font = original_font;
  1154. this.ctx.fillStyle = original_fillStyle;
  1155.  
  1156. // Chams
  1157. const obj = player[this.vars.objInstances];
  1158. if (this.isDefined(obj)) {
  1159. if (!obj.visible) {
  1160. Object.defineProperty(player[this.vars.objInstances], 'visible', {
  1161. value: true,
  1162. writable: false
  1163. });
  1164. } else {
  1165. let chamColor = this.settings.renderChams.val;
  1166. let chamsEnabled = chamColor !== "off";
  1167. //if (dog.gaybow >= 360) dog.gaybow = 0; else dog.gaybow++;
  1168. obj.traverse(child => {
  1169. if (child && child.type == "Mesh" && this.isDefined(child.material)) {
  1170. if (!child.hasOwnProperty(skidStr)) {
  1171. child[skidStr] = child.material;
  1172. } else if (child.hasOwnProperty(skidStr)) {
  1173. Object.defineProperty(child, 'material', {
  1174. get(){
  1175. return !chamsEnabled ? this[skidStr] : new skid.three.MeshBasicMaterial({
  1176. color: new skid.three.Color(chamColor == "Rainbow" ? skid.overlay.rainbow.col : chamColor),
  1177. depthTest: false,
  1178. transparent: true,
  1179. fog: false,
  1180. wireframe: skid.settings.renderWireFrame.val
  1181. })
  1182. }
  1183. });
  1184. }
  1185. }
  1186. })
  1187. }
  1188. }
  1189. }
  1190. }
  1191.  
  1192. spinTick(input) {
  1193. //this.game.players.getSpin(this.self);
  1194. //this.game.players.saveSpin(this.self, angle);
  1195. const angle = this.getAngleDst(input[2], this.me[this.vars.xDire]);
  1196. this.spins = this.getStatic(this.spins, new Array());
  1197. this.spinTimer = this.getStatic(this.spinTimer, this.config.spinTimer);
  1198. this.serverTickRate = this.getStatic(this.serverTickRate, this.config.serverTickRate);
  1199. (this.spins.unshift(angle), this.spins.length > this.spinTimer / this.serverTickRate && (this.spins.length = Math.round(this.spinTimer / this.serverTickRate)))
  1200. for (var e = 0, i = 0; i < this.spins.length; ++i) e += this.spins[i];
  1201. return Math.abs(e * (180 / Math.PI));
  1202. }
  1203.  
  1204. raidBot(input) {
  1205. let target = this.game.AI.ais.filter(enemy => {
  1206. return undefined !== enemy.mesh && enemy.mesh && enemy.mesh.children[0] && enemy.canBSeen && enemy.health > 0
  1207. }).sort((p1, p2) => this.getD3D(this.me.x, this.me.z, p1.x, p1.z) - this.getD3D(this.me.x, this.me.z, p2.x, p2.z)).shift();
  1208. if (target) {
  1209. let canSee = this.containsPoint(target.mesh.position)
  1210. let yDire = (this.getDir(this.me.z, this.me.x, target.z, target.x) || 0)
  1211. let xDire = ((this.getXDire(this.me.x, this.me.y, this.me.z, target.x, target.y + target.mesh.children[0].scale.y * 0.85, target.z) || 0) - this.consts.recoilMlt * this.me[this.vars.recoilAnimY])
  1212. if (this.me.weapon[this.vars.nAuto] && this.me[this.vars.didShoot]) { input[this.key.shoot] = 0; input[this.key.scope] = 0; this.me.inspecting = false; this.me.inspectX = 0; }
  1213. else {
  1214. if (!this.me.aimDir && canSee) {
  1215. input[this.key.scope] = 1;
  1216. if (!this.me[this.vars.aimVal]||this.me.weapon.noAim) {
  1217. input[this.key.shoot] = 1;
  1218. input[this.key.ydir] = yDire * 1e3
  1219. input[this.key.xdir] = xDire * 1e3
  1220. this.lookDir(xDire, yDire);
  1221. }
  1222. }
  1223. }
  1224. } else {
  1225. this.resetLookAt();
  1226. }
  1227. return input;
  1228. }
  1229.  
  1230. onInput(input) {
  1231. if (this.isDefined(this.config) && this.config.aimAnimMlt) this.config.aimAnimMlt = 1;
  1232. if (this.isDefined(this.controls) && this.isDefined(this.config) && this.settings.inActivity.val) {
  1233. this.controls.idleTimer = 0;
  1234. this.config.kickTimer = Infinity
  1235. }
  1236. if (this.me) {
  1237. this.inputFrame ++;
  1238. if (this.inputFrame >= 100000) this.inputFrame = 0;
  1239. if (!this.game.playerSound[this.isProxy]) {
  1240. this.game.playerSound = new Proxy(this.game.playerSound, {
  1241. apply: function(target, that, args) {
  1242. if (skid.settings.disableWpnSnd.val && args[0] && typeof args[0] == "string" && args[0].startsWith("weapon_")) return;
  1243. return target.apply(that, args);
  1244. },
  1245. get: function(target, key) {
  1246. return key === skid.isProxy ? true : Reflect.get(target, key);
  1247. },
  1248. })
  1249. }
  1250.  
  1251. let isMelee = this.isDefined(this.me.weapon.melee)&&this.me.weapon.melee||this.isDefined(this.me.weapon.canThrow)&&this.me.weapon.canThrow;
  1252. let ammoLeft = this.me[this.vars.ammos][this.me[this.vars.weaponIndex]];
  1253.  
  1254. // autoReload
  1255. if (this.settings.autoReload.val) {
  1256. //let capacity = this.me.weapon.ammo;
  1257. //if (ammoLeft < capacity)
  1258. if (isMelee) {
  1259. if (!this.me.canThrow) {
  1260. //this.me.refillKnife();
  1261. }
  1262. } else if (!ammoLeft) {
  1263. this.game.players.reload(this.me);
  1264. input[this.key.reload] = 1;
  1265. // this.me[this.vars.reloadTimer] = 1;
  1266. //this.me.resetAmmo();
  1267. }
  1268. }
  1269.  
  1270. //Auto Bhop
  1271. let autoBhop = this.settings.autoBhop.val;
  1272. if (autoBhop !== "off") {
  1273. if (this.isKeyDown("Space") || autoBhop == "autoJump" || autoBhop == "autoSlide") {
  1274. this.controls.keys[this.controls.binds.jumpKey.val] ^= 1;
  1275. if (this.controls.keys[this.controls.binds.jumpKey.val]) {
  1276. this.controls.didPressed[this.controls.binds.jumpKey.val] = 1;
  1277. }
  1278. if (this.isKeyDown("Space") || autoBhop == "autoSlide") {
  1279. if (this.me[this.vars.yVel] < -0.03 && this.me.canSlide) {
  1280. setTimeout(() => {
  1281. this.controls.keys[this.controls.binds.crouchKey.val] = 0;
  1282. }, this.me.slideTimer||325);
  1283. this.controls.keys[this.controls.binds.crouchKey.val] = 1;
  1284. this.controls.didPressed[this.controls.binds.crouchKey.val] = 1;
  1285. }
  1286. }
  1287. }
  1288. }
  1289.  
  1290. //Autoaim
  1291. if (this.settings.autoAim.val !== "off") {
  1292. this.playerMaps.length = 0;
  1293. this.rayC.setFromCamera(this.vec2, this.renderer.fpsCamera);
  1294. let target = this.game.players.list.filter(enemy => {
  1295. let hostile = undefined !== enemy[this.vars.objInstances] && enemy[this.vars.objInstances] && !enemy[this.vars.isYou] && !this.getIsFriendly(enemy) && enemy.health > 0 && this.getInView(enemy);
  1296. if (hostile) this.playerMaps.push( enemy[this.vars.objInstances] );
  1297. return hostile
  1298. }).sort((p1, p2) => this.getD3D(this.me.x, this.me.z, p1.x, p1.z) - this.getD3D(this.me.x, this.me.z, p2.x, p2.z)).shift();
  1299. if (target) {
  1300. //let count = this.spinTick(input);
  1301. //if (count < 360) {
  1302. // input[2] = this.me[this.vars.xDire] + Math.PI;
  1303. //} else console.log("spins ", count);
  1304. //target.jumpBobY * this.config.jumpVel
  1305. let canSee = this.containsPoint(target[this.vars.objInstances].position);
  1306. let inCast = this.rayC.intersectObjects(this.playerMaps, true).length;
  1307. let yDire = (this.getDir(this.me.z, this.me.x, target.z, target.x) || 0);
  1308. let xDire = ((this.getXDire(this.me.x, this.me.y, this.me.z, target.x, target.y - target[this.vars.crouchVal] * this.consts.crouchDst + this.me[this.vars.crouchVal] * this.consts.crouchDst, target.z) || 0) - this.consts.recoilMlt * this.me[this.vars.recoilAnimY])
  1309. if (this.me.weapon[this.vars.nAuto] && this.me[this.vars.didShoot]) {
  1310. input[this.key.shoot] = 0;
  1311. input[this.key.scope] = 0;
  1312. this.me.inspecting = false;
  1313. this.me.inspectX = 0;
  1314. }
  1315. else if (!canSee && this.settings.frustrumCheck.val) this.resetLookAt();
  1316. else if (ammoLeft||isMelee) {
  1317. input[this.key.scope] = this.settings.autoAim.val === "assist"||this.settings.autoAim.val === "correction"||this.settings.autoAim.val === "trigger" ? this.controls[this.vars.mouseDownR] : 0;
  1318. switch (this.settings.autoAim.val) {
  1319. case "quickScope":
  1320. input[this.key.scope] = 1;
  1321. if (!this.me[this.vars.aimVal]||this.me.weapon.noAim) {
  1322. if (!this.me.canThrow||!isMelee) input[this.key.shoot] = 1;
  1323. input[this.key.ydir] = yDire * 1e3
  1324. input[this.key.xdir] = xDire * 1e3
  1325. this.lookDir(xDire, yDire);
  1326. }
  1327. break;
  1328. case "assist": case "easyassist":
  1329. if (input[this.key.scope] || this.settings.autoAim.val === "easyassist") {
  1330. if (!this.me.aimDir && canSee || this.settings.autoAim.val === "easyassist") {
  1331. input[this.key.ydir] = yDire * 1e3
  1332. input[this.key.xdir] = xDire * 1e3
  1333. this.lookDir(xDire, yDire);
  1334. }
  1335. }
  1336. break;
  1337. case "silent":
  1338. if (!this.me[this.vars.aimVal]||this.me.weapon.noAim) {
  1339. if (!this.me.canThrow||!isMelee) input[this.key.shoot] = 1;
  1340. } else input[this.key.scope] = 1;
  1341. input[this.key.ydir] = yDire * 1e3
  1342. input[this.key.xdir] = xDire * 1e3
  1343. break;
  1344. case "trigger":
  1345. if (input[this.key.scope] && canSee && inCast) {
  1346. input[this.key.shoot] = 1;
  1347. input[this.key.ydir] = yDire * 1e3
  1348. input[this.key.xdir] = xDire * 1e3
  1349. }
  1350. break;
  1351. case "correction":
  1352. if (input[this.key.shoot] == 1) {
  1353. input[this.key.ydir] = yDire * 1e3
  1354. input[this.key.xdir] = xDire * 1e3
  1355. }
  1356. break;
  1357. default:
  1358. this.resetLookAt();
  1359. break;
  1360. }
  1361. }
  1362. } else {
  1363. this.resetLookAt();
  1364. //input = this.raidBot(input);
  1365. }
  1366. }
  1367. }
  1368.  
  1369. //else if (this.settings.autoClick.val && !this.ui.hasEndScreen) {
  1370. //this.config.deathDelay = 0;
  1371. //this.controls.toggle(true);
  1372. //}
  1373.  
  1374. //this.game.config.deltaMlt = 1
  1375. return input;
  1376. }
  1377.  
  1378. getD3D(x1, y1, z1, x2, y2, z2) {
  1379. let dx = x1 - x2;
  1380. let dy = y1 - y2;
  1381. let dz = z1 - z2;
  1382. return Math.sqrt(dx * dx + dy * dy + dz * dz);
  1383. }
  1384.  
  1385. getAngleDst(a, b) {
  1386. return Math.atan2(Math.sin(b - a), Math.cos(a - b));
  1387. }
  1388.  
  1389. getXDire(x1, y1, z1, x2, y2, z2) {
  1390. let h = Math.abs(y1 - y2);
  1391. let dst = this.getD3D(x1, y1, z1, x2, y2, z2);
  1392. return (Math.asin(h / dst) * ((y1 > y2)?-1:1));
  1393. }
  1394.  
  1395. getDir(x1, y1, x2, y2) {
  1396. return Math.atan2(y1 - y2, x1 - x2);
  1397. }
  1398.  
  1399. getDistance(x1, y1, x2, y2) {
  1400. return Math.sqrt((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1401. }
  1402.  
  1403. containsPoint(point) {
  1404. let planes = this.renderer.frustum.planes;
  1405. for (let i = 0; i < 6; i ++) {
  1406. if (planes[i].distanceToPoint(point) < 0) {
  1407. return false;
  1408. }
  1409. }
  1410. return true;
  1411. }
  1412.  
  1413. getCanSee(from, toX, toY, toZ, boxSize) {
  1414. if (!from) return 0;
  1415. boxSize = boxSize||0;
  1416. for (let obj, dist = this.getD3D(from.x, from.y, from.z, toX, toY, toZ), xDr = this.getDir(from.z, from.x, toZ, toX), yDr = this.getDir(this.getDistance(from.x, from.z, toX, toZ), toY, 0, from.y), dx = 1 / (dist * Math.sin(xDr - Math.PI) * Math.cos(yDr)), dz = 1 / (dist * Math.cos(xDr - Math.PI) * Math.cos(yDr)), dy = 1 / (dist * Math.sin(yDr)), yOffset = from.y + (from.height || 0) - this.consts.cameraHeight, aa = 0; aa < this.game.map.manager.objects.length; ++aa) {
  1417. if (!(obj = this.game.map.manager.objects[aa]).noShoot && obj.active && !obj.transparent && (!this.settings.wallPenetrate.val || (!obj.penetrable || !this.me.weapon.pierce))) {
  1418. let tmpDst = this.lineInRect(from.x, from.z, yOffset, dx, dz, dy, obj.x - Math.max(0, obj.width - boxSize), obj.z - Math.max(0, obj.length - boxSize), obj.y - Math.max(0, obj.height - boxSize), obj.x + Math.max(0, obj.width - boxSize), obj.z + Math.max(0, obj.length - boxSize), obj.y + Math.max(0, obj.height - boxSize));
  1419. if (tmpDst && 1 > tmpDst) return tmpDst;
  1420. }
  1421. }
  1422. /*
  1423. let terrain = this.game.map.terrain;
  1424. if (terrain) {
  1425. let terrainRaycast = terrain.raycast(from.x, -from.z, yOffset, 1 / dx, -1 / dz, 1 / dy);
  1426. if (terrainRaycast) return utl.getD3D(from.x, from.y, from.z, terrainRaycast.x, terrainRaycast.z, -terrainRaycast.y);
  1427. }
  1428. */
  1429. return null;
  1430. }
  1431.  
  1432. lineInRect(lx1, lz1, ly1, dx, dz, dy, x1, z1, y1, x2, z2, y2) {
  1433. let t1 = (x1 - lx1) * dx;
  1434. let t2 = (x2 - lx1) * dx;
  1435. let t3 = (y1 - ly1) * dy;
  1436. let t4 = (y2 - ly1) * dy;
  1437. let t5 = (z1 - lz1) * dz;
  1438. let t6 = (z2 - lz1) * dz;
  1439. let tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6));
  1440. let tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6));
  1441. if (tmax < 0) return false;
  1442. if (tmin > tmax) return false;
  1443. return tmin;
  1444. }
  1445.  
  1446. lookDir(xDire, yDire) {
  1447. this.controls.object.rotation.y = yDire
  1448. this.controls[this.vars.pchObjc].rotation.x = xDire;
  1449. this.controls[this.vars.pchObjc].rotation.x = Math.max(-this.consts.halfPI, Math.min(this.consts.halfPI, this.controls[this.vars.pchObjc].rotation.x));
  1450. this.controls.yDr = (this.controls[this.vars.pchObjc].rotation.x % Math.PI).round(3);
  1451. this.controls.xDr = (this.controls.object.rotation.y % Math.PI).round(3);
  1452. this.renderer.camera.updateProjectionMatrix();
  1453. this.renderer.updateFrustum();
  1454. }
  1455.  
  1456. resetLookAt() {
  1457. this.controls.yDr = this.controls[this.vars.pchObjc].rotation.x;
  1458. this.controls.xDr = this.controls.object.rotation.y;
  1459. this.renderer.camera.updateProjectionMatrix();
  1460. this.renderer.updateFrustum();
  1461. }
  1462.  
  1463. world2Screen (position) {
  1464. let pos = position.clone();
  1465. let scaledWidth = this.ctx.canvas.width / this.scale;
  1466. let scaledHeight = this.ctx.canvas.height / this.scale;
  1467. pos.project(this.renderer.camera);
  1468. pos.x = (pos.x + 1) / 2;
  1469. pos.y = (-pos.y + 1) / 2;
  1470. pos.x *= scaledWidth;
  1471. pos.y *= scaledHeight;
  1472. return pos;
  1473. }
  1474.  
  1475. getInView(entity) {
  1476. return null == this.getCanSee(this.me, entity.x, entity.y, entity.z);
  1477. }
  1478.  
  1479. getIsFriendly(entity) {
  1480. return (this.me && this.me.team ? this.me.team : this.me.spectating ? 0x1 : 0x0) == entity.team
  1481. }
  1482. }
  1483.  
  1484. window[skidStr] = new Skid();
  1485.  
  1486. })([...Array(8)].map(_ => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'[~~(Math.random()*52)]).join(''), CanvasRenderingContext2D.prototype);
  1487.  
  1488.  
  1489. //window.instructionHolder.style.display = "block";
  1490. // window.instructions.innerHTML = `<div id="settHolder"><img src="https://i.imgur.com/yzb2ZmS.gif" width="25%"></div><a href='https://skidlamer.github.io/wp/' target='_blank.'><div class="imageButton discordSocial"></div></a>`
  1491.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement