Minus Client

ressurection

  1. // ==UserScript==
  2. // @name Minus Client
  3. // @author (by wexy,dc;realwexyy)
  4. // @description ressurection
  5. // @version v1
  6. // @match *://*.moomoo.io/*
  7. // @icon http://moomoo.io/img/icons/crown.png
  8. // @run-at document_idle
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/1468818
  11. // ==/UserScript==
  12. // @downloadURL https://update.greasyfork.org/scripts/520849/MooMooio%20Script%20Unpatcher%20%28Any%20Hack%29%20%28All%20patches%2C%20fixes%20packets%29.user.js
  13. // @updateURL https://update.greasyfork.org/scripts/520849/MooMooio%20Script%20Unpatcher%20%28Any%20Hack%29%20%28All%20patches%2C%20fixes%20packets%29.meta.js
  14. // ==/UserScript==
  15.  
  16. /* How to use
  17.  
  18. Copy and paste the code below to the end of your hack.
  19. This technically will auto-fix all hacks after the first update in 2021.
  20.  
  21. If you do not have msgpack locally referencable, include the `// @require` line in your mod metadata as done above.
  22.  
  23. */
  24.  
  25. const PACKET_MAP = {
  26. // wont have all old packets, since they conflict with some of the new ones, add them yourself if you want to unpatch mods that are that old.
  27. "33": "9",
  28. // "7": "K",
  29. "ch": "6",
  30. "pp": "0",
  31. "13c": "c",
  32.  
  33. // most recent packet changes
  34. "f": "9",
  35. "a": "9",
  36. "d": "F",
  37. "G": "z"
  38. }
  39.  
  40. let originalSend = WebSocket.prototype.send;
  41.  
  42. WebSocket.prototype.send = new Proxy(originalSend, {
  43. apply: ((target, websocket, argsList) => {
  44. let decoded = msgpack.decode(new Uint8Array(argsList[0]));
  45.  
  46. if (PACKET_MAP.hasOwnProperty(decoded[0])) {
  47. decoded[0] = PACKET_MAP[decoded[0]];
  48. }
  49.  
  50. return target.apply(websocket, [msgpack.encode(decoded)]);
  51. })
  52. });
  53. let openMenu = false;
  54. let placeSpTick = false;
  55. let tdf = false;
  56. let enemies = false;
  57. let testMode = window.location.hostname == "127.0.0.1";
  58. let cantWearTankGear = false;
  59. let cantWearBullHat = false;
  60. let doSpikeRedThingmajic = false;
  61.  
  62.  
  63.  
  64.  
  65. // Retrieve the HTML content of .menuLink elements inside #linksContainer2
  66. var moomooVer = $('#linksContainer2 .menuLink').html();
  67.  
  68. // Array of selectors for elements to hide
  69. var hideSelectors = [
  70. '#mobileDownloadButtonContainer',
  71. '#followText',
  72. '#wideAdCard',
  73. '#animation_container',
  74. '#smallLinks',
  75. '#linksContainer1',
  76. '#twitterFollow',
  77. '#youtubeFollow',
  78. '#cdm-zone-02',
  79. '#youtuberOf',
  80. '#promoImg',
  81. '#downloadButtonContainer',
  82. '.menuHeader',
  83. '.menuLink',
  84. '.menuHeader:nth-child(5)',
  85. '.menuHeader:nth-child(6)',
  86. '.menuText',
  87. '.ad-choices',
  88. '.PubAPIAd'
  89. ];
  90. // CSS rule to apply
  91. var css = '#rightCardHolder {display: block!important}';
  92.  
  93. // Create and append a <style> element to the document head
  94. var head = document.head || document.getElementsByTagName('head')[0];
  95. var style = document.createElement('style');
  96. style.type = 'text/css';
  97.  
  98. if (style.styleSheet) {
  99. style.styleSheet.cssText = css;
  100. } else {
  101. style.appendChild(document.createTextNode(css));
  102. }
  103. head.appendChild(style);
  104.  
  105. // Hide elements based on the selectors
  106. for (let i = 0; i < hideSelectors.length; i++) {
  107. $(hideSelectors[i]).hide();
  108. }
  109. var styleItem = document.createElement("style");
  110. styleItem.type = "text/css";
  111. styleItem.appendChild(document.createTextNode(`
  112. #suggestBox {
  113. width: 355px;
  114. border-radius: 3px;
  115. background-color: rgba(0,0,0,0.5);
  116. margin: auto;
  117. text-align: left;
  118. z-index: 49;
  119. pointer-events: auto;
  120. position: relative;
  121. bottom: 3.5px;
  122. overflow-y: auto;
  123. }
  124. #suggestBox div {
  125. background-color: rgba(255,255,255,0);
  126. color: rgba(255,255,255,1);
  127. transition: background-color 0.3s, color 0.3s;
  128. }
  129. #suggestBox div:hover {
  130. background-color: rgba(255,255,255,0.2);
  131. color: rgba(0,0,0,1);
  132. }
  133. .suggestBoxHard {
  134. color: rgba(255,255,255,1);
  135. font-size: 18px;
  136. }
  137. .suggestBoxLight {
  138. color: rgba(255,255,255,0.7);
  139. font-size: 18px;
  140. }
  141. `));
  142.  
  143. document.addEventListener("keydown", function(event) {
  144. if (event.keyCode === 45) {
  145. const chatHolder = document.getElementById("menuChatDiv");
  146. if (chatHolder) {
  147. const currentDisplay = chatHolder.style.display;
  148. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  149. }
  150. }
  151. });
  152.  
  153.  
  154. document.addEventListener("keydown", function(event) {
  155. if (event.keyCode === 46) {
  156. const chatHolder = document.getElementById("gameUI");
  157. if (chatHolder) {
  158. const currentDisplay = chatHolder.style.display;
  159. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  160. }
  161. }
  162. });
  163.  
  164.  
  165.  
  166.  
  167. function onBoxMouseOver() {
  168. this.style.transform = 'scale(1.1)'; // Increase size by 10%
  169. this.style.borderRadius = '10px'; // Add rounded corners
  170. this.style.boxShadow = '0 0 0 1px #000'; // Add orange outline with 1px width
  171. }
  172.  
  173. // Function to handle mouse leave event for the boxes
  174. function onBoxMouseLeave() {
  175. this.style.transform = 'scale(1)'; // Restore original size
  176. this.style.borderRadius = '0'; // Remove rounded corners to make the box square again
  177. this.style.boxShadow = 'none'; // Remove the orange outline
  178. }
  179.  
  180. // Function to handle mouse enter event for the "enter game box"
  181. function onEnterGameMouseOver() {
  182. const enterGameBox = document.getElementById('leaderboard');
  183. enterGameBox.style.transform = 'scale(1.05)'; // Increase size by 5%
  184. enterGameBox.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  185. enterGameBox.style.borderRadius = '50px'; // Add more rounded corners
  186. }
  187.  
  188. // Function to handle mouse leave event for the "enter game box"
  189. function onEnterGameMouseLeave() {
  190. const enterGameBox = document.getElementById('leaderboard');
  191. enterGameBox.style.transform = 'scale(1)'; // Restore original size
  192. enterGameBox.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; // Change background color back to green
  193. enterGameBox.style.borderRadius = '0'; // Remove rounded corners to make the box square again
  194. }
  195.  
  196. // Add smooth transition for scaling effect
  197. const boxes = document.querySelectorAll('.menuCard');
  198. boxes.forEach(box => {
  199. box.style.transition = 'transform 0.5s ease'; // 0.5s duration with ease-in-out timing function
  200. box.addEventListener('mouseenter', onBoxMouseOver);
  201. box.addEventListener('mouseleave', onBoxMouseLeave);
  202. });
  203. let editMainMenu = `
  204. <style>
  205. /* Стили для меню #setupCard */
  206. #setupCard {
  207. border-radius: 10px;
  208. position: absolute;
  209. left: 770px;
  210. top: 0px;
  211. background: rgba(70, 130, 180, 0.5);
  212. box-shadow: 0px 0px 5px #fff;
  213. transition: box-shadow 0.3s ease;
  214. }
  215.  
  216. #setupCard:hover,
  217. #setupCard:active {
  218. box-shadow: 0px 0px 10px #ffffff;
  219. }
  220.  
  221. #mainMenu {
  222. background-size: cover;
  223. background-repeat: no-repeat;
  224. background-position: center;
  225.  
  226. }
  227. #enterGame {
  228. background-color: rgba(0, 0, 0, 0.5);
  229. border-radius: 15px;
  230. transition: all 0.7s ease-in-out;
  231. }
  232. /* Стили для меню #guideCard */
  233. #guideCard {
  234. border-radius: 10px;
  235. position: absolute;
  236. left: 420px;
  237. top: 0px;
  238. background: rgba(0, 0, 0, 0.5);
  239. box-shadow: 0px 0px 20px #fff;
  240. transition: box-shadow 0.3s ease;
  241. }
  242.  
  243. #guideCard:hover,
  244. #guideCard:active {
  245. box-shadow: 0px 0px 10px #ffffff;
  246. }
  247.  
  248.  
  249.  
  250. /* Прочие стили остаются без изменений */
  251. #nameInput::selection {
  252. background: #E7BDE7;
  253. }
  254.  
  255. #guideCard::-webkit-scrollbar {
  256. width: 0px;
  257. height: 0px;
  258. background-color: rgba(0, 0, 0, 0);
  259. }
  260.  
  261. #mainMenu {
  262. background-color: rgba(0, 0, 0, 0.5);
  263.  
  264. }
  265.  
  266. .menuCard {
  267. background: #bd85c9;
  268. text-align: center;
  269. box-shadow: inset 0px 0px 20px rgba(102, 51, 153, 0.5);
  270. }
  271.  
  272. })();
  273. </script>
  274.  
  275. </style>
  276.  
  277.  
  278. `
  279. $("#mainMenu").append(editMainMenu)
  280. // Add event listeners for the "enter game box"
  281. const enterGameBox = document.getElementById('leaderboard');
  282. enterGameBox.addEventListener('mouseenter', onEnterGameMouseOver);
  283. enterGameBox.addEventListener('mouseleave', onEnterGameMouseLeave);
  284. $('.menuCard').css({'white-space': 'normal',
  285. 'text-align': 'center',
  286. 'background-color': 'rgba(0, 0, 0, 0.5)',
  287. '-moz-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  288. '-webkit-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  289. 'box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  290. '-webkit-border-radius': '0px',
  291. '-moz-border-radius': '0px',
  292. 'border-radius': '0px',
  293. 'margin': '15px',
  294. 'margin-top': '15px'});
  295.  
  296. $('#menuContainer').css({'white-space': 'normal'});
  297.  
  298. $('#nativeResolution').css({'cursor': 'pointer'});
  299.  
  300. $('#playMusic').css({'cursor': 'pointer'});
  301.  
  302. $('#serverSelect').css({'margin-bottom': '30.75px'});
  303.  
  304. $('#skinColorHolder').css({'margin-bottom': '30.75px'});
  305.  
  306. $('.settingRadio').css({'margin-bottom': '30.75px'});
  307.  
  308.  
  309. $('#joinPartyButton').css({'right': '10%',
  310. 'left': '70%',
  311. 'text-align': 'center',
  312. 'bottom': '48px',
  313. 'font-size': '24px',
  314. 'top': 'unset'});
  315.  
  316. $('#linksContainer2').css({'-webkit-border-radius': '0px 0 0 0',
  317. '-moz-border-radius': '0px 0 0 0',
  318. 'border-radius': '0px 0 0 0',
  319. 'right': '44%',
  320. 'left': '44%',
  321. 'background-color': 'rgba(0, 0, 0, 0.74)',
  322. 'text-align': 'center',
  323. 'bottom': '12px'});
  324.  
  325. $('.ytLink').css({'color': '#20ace8',
  326. 'padding': '8px',
  327. 'background-color': 'rgba(0, 0, 0, 0.74)'});
  328.  
  329. $('.menuLink').css({'color': '#20ace8'});
  330.  
  331. $('#nameInput').css({'border-radius': '0px',
  332. '-moz-border-radius': '0px',
  333. '-webkit-border-radius': '0px',
  334. 'border': 'hidden'});
  335.  
  336. $('#serverSelect').css({'cursor': 'pointer',
  337. 'color': 'rgba(0, 0, 0, 0.5)',
  338. 'background-color': '#808080',
  339. 'border': 'hidden',
  340. 'font-size': '20px'});
  341.  
  342. $('.menuButton').css({'border-radius': '0px',
  343. '-moz-border-radius': '0px',
  344. '-webkit-border-radius': '0px'});
  345.  
  346. $('#promoImgHolder').css({'position': 'absolute',
  347. 'bottom': '-7%',
  348. 'left': '20px',
  349. 'width': '420px',
  350. 'height': '236.25px',
  351. 'padding-bottom': '18px',
  352. 'margin-top': '0px'});
  353.  
  354. $('#adCard').css({'position': 'absolute',
  355. 'bottom': '-7%',
  356. 'right': '20px',
  357. 'width': '420px',
  358. 'height': '236.25px',
  359. 'padding-bottom': '18px'});
  360.  
  361. $('#mapDisplay').css({'-webkit-border-radius': '0px',
  362. '-moz-border-radius': '0px',
  363. 'border-radius': '20px'});
  364. //wolfi-chan was here
  365. $('.menuHeader').css({'color': 'rgba(0, 0, 0, 0,5)'});
  366.  
  367. $('#killCounter').css({'color': '#ededed'});
  368.  
  369. $('#diedText').css({'background-color': 'rgb(255, 255, 255)'});
  370.  
  371. $('#gameCanvas').css({'background-color': '#f4f4f4'});
  372.  
  373.  
  374.  
  375. $('#leaderboard').css({'-webkit-border-radius': '0px',
  376. '-moz-border-radius': '0px',
  377. 'border-radius': '0px',
  378. 'background-color': 'rgb((255,240,245))',
  379. 'text-align': 'center'});
  380.  
  381. $('#storeTab').css({'-webkit-border-radius': '0px',
  382. '-moz-border-radius': '0px',
  383. 'border-radius': '0px',
  384. 'background-color': 'rgba(0, 0, 0, 0.4)'});
  385.  
  386. $('#storeHolder').css({'-webkit-border-radius': '0px',
  387. '-moz-border-radius': '0px',
  388. 'border-radius': '0px',
  389. 'background-color': 'rgba(0, 0, 0, 0.4)'});
  390. document.getElementById("storeHolder").style = "height: 1500px; width: 450px;"
  391.  
  392. $('#allianceHolder').css({'-webkit-border-radius': '0px',
  393. '-moz-border-radius': '0px',
  394. 'border-radius': '0px',
  395. 'background-color': 'rgba(0, 0, 0, 0.4)'});
  396.  
  397. $('.actionBarItem').css({'-webkit-border-radius': '0px',
  398. 'border-radius': '0px',
  399. 'background-color': 'rgba(0, 0, 0, 0.4)'})
  400. // Update the HTML content of #linksContainer2
  401. $('#linksContainer2').html('<a href="./docs/versions.txt" target="_blank" class="menuLink">2</a>');
  402. document.getElementById("partyButton").remove();
  403. document.getElementById("joinPartyButton").remove();
  404.  
  405. document.getElementById("linksContainer2").remove();
  406.  
  407. document.getElementById("gameName").style.font = "80px zamruds";
  408. document.getElementById("mainMenu").style.backgroundImage = "url('')";
  409. document.getElementById("gameName").style.textShadow = "#fff"; // Используем rgba для задания прозрачного голубого цвета
  410. document.getElementById('gameName').style.marginTop = '-200px';
  411. document.getElementById('gameName').innerHTML = '';
  412.  
  413.  
  414. let founda = false;
  415.  
  416. let scriptTags = document.getElementsByTagName("script");
  417. for (let i = 0; i < scriptTags.length; i++) {
  418. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  419. scriptTags[i].remove();
  420. founda = true;
  421. break;
  422. }
  423. }
  424.  
  425.  
  426. document.addEventListener("keydown", function(event) {
  427. if (event.keyCode === 192) {
  428. const chatHolder = document.getElementById("gameUI");
  429. if (chatHolder) {
  430. const currentDisplay = chatHolder.style.display;
  431. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  432. }
  433. }
  434. });
  435. var styleItem = document.createElement("style");
  436. styleItem.type = "text/css";
  437. styleItem.appendChild(document.createTextNode(`
  438. #suggestBox {
  439. width: 355px;
  440. border-radius: 3px;
  441. background-color: rgba(2,5,6,0.5);
  442. margin: auto;
  443. text-align: left;
  444. z-index: 49;
  445. pointer-events: auto;
  446. position: relative;
  447. bottom: 3.5px;
  448. overflow-y: auto;
  449. }
  450. #suggestBox div {
  451. background-color: rgba(255, 0, 0, 0.5);
  452. color: rgba(255, 255, 255, 0.12);
  453. transition: background-color 0.3s, color 0.3s;
  454. }
  455. #suggestBox div:hover {
  456. background-color: rgba(255, 0, 0, 0.5);
  457. color: rgba(255, 255, 255, 0.12);
  458. }
  459. .suggestBoxHard {
  460. color: rgba(255, 255, 255, 0.12);
  461. font-size: 12px;
  462. }
  463. .suggestBoxLight {
  464. color: rgba(255,255,255,0.7);
  465. font-size: 18px;
  466. }
  467. `));
  468. document.head.appendChild(styleItem);
  469.  
  470. window.addEventListener('load', function() {
  471. var allianceButton = document.getElementById('allianceButton');
  472. var storeButton = document.getElementById('storeButton');
  473. if (storeButton) {
  474. storeButton.style.right = '26px';
  475. storeButton.style.top = '420px';
  476. }
  477. if (allianceButton) {
  478. allianceButton.style.right = '26px';
  479. allianceButton.style.top = '479px';
  480. }
  481. });
  482.  
  483. function getEl(id) {
  484. return document.getElementById(id);
  485. }
  486.  
  487.  
  488.  
  489. let newFont = document.createElement("link");
  490. newFont.rel = "stylesheet";
  491. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  492. newFont.type = "text/css";
  493. document.body.append(newFont);
  494.  
  495. let min = document.createElement("script");
  496. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  497. document.body.append(min);
  498. window.oncontextmenu = function() {
  499. return false;
  500. };
  501.  
  502. let config = window.config;
  503.  
  504. // CLIENT:
  505. config.clientSendRate = 9; // Aim Packet Send Rate
  506. config.serverUpdateRate = 9;
  507.  
  508. // UI:
  509. config.deathFadeout = 0;
  510.  
  511. config.playerCapacity = 9999;
  512.  
  513. // CHECK IN SANDBOX:
  514. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  515.  
  516. // CUSTOMIZATION:
  517. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  518. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  519. "#8bc373", "#91b2db"
  520. ];
  521. config.weaponVariants = [{
  522. id: 0,
  523. src: "",
  524. xp: 0,
  525. val: 1,
  526. }, {
  527. id: 1,
  528. src: "_g",
  529. xp: 3000,
  530. val: 1.1,
  531. }, {
  532. id: 2,
  533. src: "_d",
  534. xp: 7000,
  535. val: 1.18,
  536. }, {
  537. id: 3,
  538. src: "_r",
  539. poison: true,
  540. xp: 12000,
  541. val: 1.18,
  542. }, {
  543. id: 4,
  544. src: "_e",
  545. poison: true,
  546. heal: true,
  547. xp: 24000,
  548. val: 1.18,
  549. }];
  550.  
  551. // VISUAL:
  552. config.anotherVisual = true;
  553. config.useWebGl = false;
  554. config.resetRender = true;
  555.  
  556. function waitTime(timeout) {
  557. return new Promise((done) => {
  558. setTimeout(() => {
  559. done();
  560. }, timeout);
  561. });
  562. }
  563.  
  564. let botSkts = [];
  565.  
  566. // STORAGE:
  567. let canStore;
  568. if (typeof(Storage) !== "undefined") {
  569. canStore = true;
  570. }
  571.  
  572. function saveVal(name, val) {
  573. if (canStore)
  574. localStorage.setItem(name, val);
  575. }
  576.  
  577. function deleteVal(name) {
  578. if (canStore)
  579. localStorage.removeItem(name);
  580. }
  581.  
  582. function getSavedVal(name) {
  583. if (canStore)
  584. return localStorage.getItem(name);
  585. return null;
  586. }
  587.  
  588. // CONFIGS:
  589. let gC = function(a, b) {
  590. try {
  591. let res = JSON.parse(getSavedVal(a));
  592. if (typeof res === "object") {
  593. return b;
  594. } else {
  595. return res;
  596. }
  597. } catch (e) {
  598. alert("dieskid");
  599. return b;
  600. }
  601. };
  602.  
  603. function setCommands() {
  604. return {
  605. "help": {
  606. desc: "Show Commands",
  607. action: function(message) {
  608. for (let cmds in commands) {
  609. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  610. }
  611. }
  612. },
  613. "clear": {
  614. desc: "Clear Chats",
  615. action: function(message) {
  616. resetMenuChText();
  617. }
  618. },
  619. "debug": {
  620. desc: "Debug Mod For Development",
  621. action: function(message) {
  622. addDeadPlayer(player);
  623. addMenuChText("Debug", "Done", "#99ee99", 1);
  624. }
  625. },
  626. "play": {
  627. desc: "Play Music ( /play [link] )",
  628. action: function(message) {
  629. let link = message.split(" ");
  630. if (link[1]) {
  631. let audio = new Audio(link[1]);
  632. audio.play();
  633. } else {
  634. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  635. }
  636. }
  637. },
  638. "bye": {
  639. desc: "Leave Game",
  640. action: function(message) {
  641. window.leave();
  642. }
  643. },
  644. };
  645. }
  646.  
  647. function setConfigs() {
  648. return {
  649. killChat: true,
  650. autoBuy: true,
  651. autoBuyEquip: true,
  652. autoPush: true,
  653. revTick: true,
  654. spikeTick: true,
  655. predictTick: true,
  656. autoPlace: true,
  657. autoReplace: true,
  658. antiTrap: true,
  659. slowOT: false,
  660. attackDir: false,
  661. showDir: false,
  662. autoRespawn: false
  663. };
  664. }
  665.  
  666. let commands = setCommands();
  667. let configs = setConfigs();
  668.  
  669. window.removeConfigs = function() {
  670. for (let cF in configs) {
  671. deleteVal(cF, configs[cF]);
  672. }
  673. };
  674.  
  675. for (let cF in configs) {
  676. configs[cF] = gC(cF, configs[cF]);
  677. }
  678.  
  679. // MENU FUNCTIONS:
  680. window.changeMenu = function() {};
  681. window.debug = function() {};
  682. window.wasdMode = function() {};
  683.  
  684. // PAGE 1:
  685. window.startGrind = function() {};
  686.  
  687. // PAGE 3:
  688. window.connectFillBots = function() {};
  689. window.destroyFillBots = function() {};
  690. window.tryConnectBots = function() {};
  691. window.destroyBots = function() {};
  692. window.resBuild = function() {};
  693. window.toggleBotsCircle = function() {};
  694. window.toggleVisual = function() {};
  695.  
  696. // SOME FUNCTIONS:
  697. window.prepareUI = function() {};
  698. window.leave = function() {};
  699.  
  700. // nah hahahahahhh why good ping
  701. window.ping = 0;
  702.  
  703. class deadfuturechickenmodrevival {
  704. constructor(flarez, lore) {
  705. this.inGame = false;
  706. this.lover = flarez + lore;
  707. this.baby = "ae86";
  708. this.isBlack = 0;
  709. this.webSocket = undefined;
  710. this.checkBaby = function() {
  711. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  712. if (this.isBlack >= 1) return "bl4cky";
  713. return "noting for you";
  714. };
  715. this.x2 = 0;
  716. this.y2 = 0;
  717. this.chat = "Imagine playing this badass game XDDDDD";
  718. this.summon = function(tmpObj) {
  719. this.x2 = tmpObj.x;
  720. this.y2 = tmpObj.y;
  721. this.chat = tmpObj.name + " ur so bad XDDDD";
  722. };
  723. this.commands = function(cmd) {
  724. cmd == "rv3link" && window.open("https://florr.io/");
  725. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  726. return cmd;
  727. };
  728. this.dayte = "11yearold";
  729. this.memeganoob = "69yearold";
  730. this.startDayteSpawn = function(tmpObj) {
  731. let ratio = setInterval(() => {
  732. this.x2 = tmpObj.x + 20;
  733. this.y2 = tmpObj.y - 20;
  734. this.chat = "UR SO BAD LOL";
  735. if (tmpObj.name == "ae86") {
  736. this.chat = "omg ae86 go run";
  737. setTimeout(() => {
  738. this.inGame = false;
  739. clearInterval(ratio);
  740. }, 1000);
  741. }
  742. }, 1234);
  743. };
  744. this.AntiChickenModV69420 = function(tmpObj) {
  745. return "!c!dc user " + tmpObj.name;
  746. };
  747. }
  748. };
  749. class HtmlAction {
  750. constructor(element) {
  751. this.element = element;
  752. };
  753. add(code) {
  754. if (!this.element) return undefined;
  755. this.element.innerHTML += code;
  756. };
  757. newLine(amount) {
  758. let result = `<br>`;
  759. if (amount > 0) {
  760. result = ``;
  761. for (let i = 0; i < amount; i++) {
  762. result += `<br>`;
  763. }
  764. }
  765. this.add(result);
  766. };
  767. checkBox(setting) {
  768. let newCheck = `<input type = "checkbox"`;
  769. setting.id && (newCheck += ` id = ${setting.id}`);
  770. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  771. setting.class && (newCheck += ` class = ${setting.class}`);
  772. setting.checked && (newCheck += ` checked`);
  773. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  774. newCheck += `>`;
  775. this.add(newCheck);
  776. };
  777. text(setting) {
  778. let newText = `<input type = "text"`;
  779. setting.id && (newText += ` id = ${setting.id}`);
  780. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  781. setting.class && (newText += ` class = ${setting.class}`);
  782. setting.size && (newText += ` size = ${setting.size}`);
  783. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  784. setting.value && (newText += ` value = ${setting.value}`);
  785. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  786. newText += `>`;
  787. this.add(newText);
  788. };
  789. select(setting) {
  790. let newSelect = `<select`;
  791. setting.id && (newSelect += ` id = ${setting.id}`);
  792. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  793. setting.class && (newSelect += ` class = ${setting.class}`);
  794. newSelect += `>`;
  795. for (let options in setting.option) {
  796. newSelect += `<option value = ${setting.option[options].id}`
  797. setting.option[options].selected && (newSelect += ` selected`);
  798. newSelect += `>${options}</option>`;
  799. }
  800. newSelect += `</select>`;
  801. this.add(newSelect);
  802. };
  803. button(setting) {
  804. let newButton = `<button`;
  805. setting.id && (newButton += ` id = ${setting.id}`);
  806. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  807. setting.class && (newButton += ` class = ${setting.class}`);
  808. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  809. newButton += `>`;
  810. setting.innerHTML && (newButton += setting.innerHTML);
  811. newButton += `</button>`;
  812. this.add(newButton);
  813. };
  814. selectMenu(setting) {
  815. let newSelect = `<select`;
  816. if (!setting.id) {
  817. alert("please put id skid");
  818. return;
  819. }
  820. window[setting.id + "Func"] = function() {};
  821. setting.id && (newSelect += ` id = ${setting.id}`);
  822. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  823. setting.class && (newSelect += ` class = ${setting.class}`);
  824. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  825. newSelect += `>`;
  826. let last;
  827. let i = 0;
  828. for (let options in setting.menu) {
  829. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  830. setting.menu[options] && (newSelect += ` checked`);
  831. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#d4af37"}; background: ${setting.menu[options] ? "#d4af37" : "#d4af37"};">${options}</option>`;
  832. i++;
  833. }
  834. newSelect += `</select>`;
  835.  
  836. this.add(newSelect);
  837.  
  838. i = 0;
  839. for (let options in setting.menu) {
  840. window[options + "Func"] = function() {
  841. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  842. saveVal(options, setting.menu[options]);
  843.  
  844. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  845. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  846.  
  847. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  848.  
  849. };
  850. this.checkBox({
  851. id: "check_" + options,
  852. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  853. class: "checkB",
  854. onclick: `window.${options + "Func"}()`,
  855. checked: setting.menu[options]
  856. });
  857. i++;
  858. }
  859.  
  860. last = "check_" + getEl(setting.id).value.split("_")[1];
  861. window[setting.id + "Func"] = function() {
  862. getEl(last).style.display = "none";
  863. last = "check_" + getEl(setting.id).value.split("_")[1];
  864. getEl(last).style.display = "inline-block";
  865.  
  866. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  867.  
  868. };
  869. };
  870. };
  871. class Html {
  872. constructor() {
  873. this.element = null;
  874. this.action = null;
  875. this.divElement = null;
  876. this.startDiv = function(setting, func) {
  877.  
  878. let newDiv = document.createElement("div");
  879. setting.id && (newDiv.id = setting.id);
  880. setting.style && (newDiv.style = setting.style);
  881. setting.class && (newDiv.className = setting.class);
  882. this.element.appendChild(newDiv);
  883. this.divElement = newDiv;
  884.  
  885. let addRes = new HtmlAction(newDiv);
  886. typeof func == "function" && func(addRes);
  887.  
  888. };
  889. this.addDiv = function(setting, func) {
  890.  
  891. let newDiv = document.createElement("div");
  892. setting.id && (newDiv.id = setting.id);
  893. setting.style && (newDiv.style = setting.style);
  894. setting.class && (newDiv.className = setting.class);
  895. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  896. this.divElement = newDiv;
  897.  
  898. let addRes = new HtmlAction(newDiv);
  899. typeof func == "function" && func(addRes);
  900.  
  901. };
  902. };
  903. set(id) {
  904. this.element = getEl(id);
  905. this.action = new HtmlAction(this.element);
  906. };
  907. resetHTML(text) {
  908. if (text) {
  909. this.element.innerHTML = ``;
  910. } else {
  911. this.element.innerHTML = ``;
  912. }
  913. };
  914. setStyle(style) {
  915. this.element.style = style;
  916. };
  917. setCSS(style) {
  918. this.action.add(`<style>` + style + `</style>`);
  919. };
  920. };
  921.  
  922.  
  923.  
  924. let HTML = new Html();
  925. let PrePlaceCount = 0;
  926. let menuDiv = document.createElement("div");
  927. menuDiv.id = "menuDiv";
  928. menuDiv.draggable = true;
  929.  
  930. menuDiv.addEventListener("dragstart", function (e) {
  931. e.dataTransfer.setData("text/plain", "");
  932. });
  933.  
  934. document.addEventListener("dragover", function (e) {
  935. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  936. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  937. });
  938.  
  939. document.body.appendChild(menuDiv);
  940. HTML.set("menuDiv");
  941. HTML.setStyle(`
  942. display: none;
  943. position: absolute;
  944. left: 430px;
  945. top: 20px;
  946. `);
  947. HTML.resetHTML();
  948. HTML.setCSS(`
  949. body {
  950. background-color: #d4af37; /* Черный цвет фона */
  951. color: #fff; /* Белый цвет текста */
  952. font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; /* Более роскошный шрифт */
  953. }
  954.  
  955. .menuClass {
  956. color: #fff;
  957. font-size: 22px; /* Increased font size */
  958. text-align: left;
  959. padding: 20px; /* Increased padding */
  960. width: 300px; /* Increased width */
  961. background-color: rgba(0, 0, 0, 0.3); /* Dark gray background */
  962. border: 2px solid #555; /* Dark border color */
  963. border-radius: 12px; /* More rounded corners */
  964. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); /* Shadow for emphasis */
  965. transition: transform 0.3s ease; /* Smooth transition for transform */
  966. }
  967.  
  968. .menuClass:hover {
  969. transform: scale(1.05); /* Scale up to 105% on hover */
  970. }
  971.  
  972.  
  973. .menuC {
  974. display: none;
  975. font-size: 14px; /* Уменьшенный размер шрифта */
  976. max-height: 200px; /* Увеличенная максимальная высота */
  977. overflow-y: auto;
  978. }
  979.  
  980. .menuB {
  981. text-align: center;
  982. background-color: rgba(0, 0, 0, 0.3);
  983. color: #fff;
  984. border: none;
  985. border-radius: 4px;
  986. padding: 4 4px; /* Увеличенный внутренний отступ */
  987. cursor: pointer;
  988. transition: background-color 0.3s ease;
  989. }
  990.  
  991. .menuB:hover {
  992. background-color: #444444;
  993. }
  994.  
  995. superGAY
  996.  
  997. .menuB:active {
  998. transform: translateY(1px);
  999. }
  1000.  
  1001. .customText {
  1002. color: #fff;
  1003. border: 1px solid #555;
  1004. border-radius: 5px;
  1005. padding: 2px;
  1006. transition: background-color 0.3s ease;
  1007. }
  1008.  
  1009. .customText:focus {
  1010. background-color: #444; /* Темно-серый цвет фона при фокусировке */
  1011. }
  1012.  
  1013. .checkB {
  1014. cursor: pointer;
  1015. }
  1016.  
  1017. .Cselect {
  1018. text-align: center;
  1019. background-color: rgba(0, 0, 0, 0.3);
  1020. color: #fff;
  1021. border: none;
  1022. border-radius: 4px;
  1023. padding: 4 4px; /* Увеличенный внутренний отступ */
  1024. cursor: pointer;
  1025. transition: background-color 0.3s ease;
  1026. }
  1027.  
  1028. .Cselect:hover {
  1029. background-color: #444444;
  1030. }
  1031.  
  1032. .Cselect:active {
  1033. transform: translateY(1px);
  1034. }
  1035.  
  1036. #menuChanger {
  1037. position: absolute;
  1038. right: 20px; /* Увеличенный отступ справа */
  1039. top: 20px; /* Увеличенный отступ сверху */
  1040. background-color: transparent;
  1041. color: #fff;
  1042. border: none;
  1043. cursor: pointer;
  1044. }
  1045.  
  1046. #menuChanger:hover {
  1047. color: #; /* Светло-серый цвет при наведении */
  1048. }
  1049.  
  1050. /* Скроллбары */
  1051. ::-webkit-scrollbar {
  1052. width: 8px;
  1053. }
  1054.  
  1055. ::-webkit-scrollbar-track {
  1056. background: #; /* Темно-серый цвет фона */
  1057. }
  1058.  
  1059. ::-webkit-scrollbar-thumb {
  1060. background: # /* Светло-серый цвет скроллбара */
  1061. border-radius: 4px;
  1062. }
  1063.  
  1064. ::-webkit-scrollbar-thumb:hover {
  1065. background: #; /* Более светлый цвет при наведении */
  1066. }
  1067.  
  1068. /* Добавление узоров на задний фон */
  1069. body {
  1070. }
  1071.  
  1072. `);
  1073. HTML.startDiv({
  1074. id: "menuHeadLine",
  1075. class: "menuClass"
  1076. }, (html) => {
  1077. HTML.addDiv({
  1078. id: "menuButtons",
  1079. style: "display: block; overflow-y: visible;",
  1080. class: "menuC",
  1081. appendID: "menuHeadLine"
  1082. }, (html) => {
  1083. html.button({
  1084. class: "menuB",
  1085. innerHTML: "Debug",
  1086. onclick: "window.debug()"
  1087. });
  1088. });
  1089. HTML.addDiv({
  1090. id: "menuMain",
  1091. style: "display: block",
  1092. class: "menuC",
  1093. appendID: "menuHeadLine"
  1094. }, (html) => {
  1095. html.button({
  1096. class: "menuB",
  1097. innerHTML: "Wasd Mode",
  1098. onclick: "window.wasdMode()"
  1099. });
  1100. html.newLine(2);
  1101. HTML.addDiv({
  1102. style: "font-size: 30px; color: #fff;",
  1103. appendID: "menuMain"
  1104. }, (html) => {
  1105. html.add(`Other Menu:`);
  1106. });
  1107. html.add(`Configs: `);
  1108. html.selectMenu({
  1109. id: "configsChanger",
  1110. class: "Cselect",
  1111. menu: configs
  1112. });
  1113. html.newLine();
  1114. html.add(`Placer: `);
  1115. html.select({
  1116. id: "placetype",
  1117. class: "Cselect",
  1118. option: {
  1119. Minusplacer: {
  1120. id: "tamper",
  1121. selected: true
  1122. },
  1123. Inevebibility: {
  1124. id: "kindver"
  1125. }
  1126. }
  1127. });
  1128. html.newLine();
  1129. html.add(`Turret Gear Combat Assistance: `);
  1130. html.checkBox({
  1131. id: "turretCombat",
  1132. class: "checkB"
  1133. });
  1134. });
  1135. });
  1136. (function() {
  1137. 'use strict';
  1138.  
  1139. // Create the menu container
  1140. const menuContainer = document.createElement('div');
  1141. menuContainer.id = 'customMenu';
  1142. document.body.appendChild(menuContainer);
  1143.  
  1144. // Add menu content
  1145. menuContainer.innerHTML = `
  1146. <div class="menu-header">
  1147. <span class="menu-title">Menu:</span>
  1148. </div>
  1149. <div class="menu-tabs">
  1150. <button class="tab-button active" data-tab="main">Main</button>
  1151. <button class="tab-button" data-tab="visuals">Visuals</button>
  1152. <button class="tab-button" data-tab="configs">Combat</button>
  1153. </div>
  1154. <div class="menu-content">
  1155. <div class="tab-content" id="main-content">
  1156. <label class="menu-option">
  1157. Weapon Grind <input type="checkbox" class="option-toggle" id="weaponGrind">
  1158. </label>
  1159. <label class="menu-option">
  1160. Predict Type
  1161. <select class="option-toggle" id="windMillType">
  1162. <option value="random">Random</option>
  1163. <option value="fast">Fast</option>
  1164. <option value="cool">Cool</option>
  1165. <option value="cool2" selected>Cool2</option>
  1166. </select>
  1167. </div>
  1168. <div class="tab-content" id="visuals-content" style="display: none;">
  1169. <label class="menu-option">
  1170. Render Placers <input type="checkbox" class="option-toggle" id="placeVis" checked>
  1171. </label>
  1172. <label class="menu-option">
  1173. Map Grid <input type="checkbox" class="option-toggle" id="renderGrid">
  1174. </label>
  1175. </label>
  1176. <label class="menu-option">
  1177. Building Health <input type="checkbox" class="option-toggle" id="buildingHealth" checked>
  1178. </label>
  1179. <label class="menu-option">
  1180. Predict Type
  1181. <select class="option-toggle" id="predictType">
  1182. <option value="disableRender" selected>Disable</option>
  1183. <option value="pre2">x/y and 2</option>
  1184. <option value="pre3">x/y and 3</option>
  1185. </select>
  1186. </label>
  1187. </div>
  1188. <div class="tab-content" id="configs-content" style="display: none;">
  1189. <label class="menu-option">
  1190. Placement Tick: <input type="number" value="2" id="autoPlaceTick" size="2em" placeholder="Enter tick rate" class="customText">
  1191. </label>
  1192. <label class="menu-option">
  1193. Healer <input type="checkbox" id="healingBeta" class="option-toggle" checked>
  1194. </label>
  1195. <label class="menu-option">
  1196. AntiSpikeTick <input type="checkbox" id="safeAntiSpikeTick" class="option-toggle" checked>
  1197. </label>
  1198. <label class="menu-option">
  1199. Nobull Insta <input type="checkbox" id="backupNobull" class="option-toggle">
  1200. </label>
  1201. <label class="menu-option">
  1202. Anti Push <input type="checkbox" class="option-toggle" id="antipush" checked>
  1203. </label>
  1204. <label class="menu-option">
  1205. Insta Type
  1206. <select class="option-toggle" id="instaType">
  1207. <option value="oneShot">One Shot</option>
  1208. <option value="normal" selected>Normal</option>
  1209. </select>
  1210. </label>
  1211. <label class="menu-option">
  1212. AntiBull Type
  1213. <select class="option-toggle" id="antiBullType">
  1214. <option value="noab" selected>Disable</option>
  1215. <option value="abreload">When Reloaded</option>
  1216. <option value="abalway">Primary Reloaded</option>
  1217. </select>
  1218. </label>
  1219. </div>
  1220. </div>
  1221. `;
  1222. // Add styles
  1223. const style = document.createElement('style');
  1224. style.textContent = `
  1225. @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap');
  1226.  
  1227. #customMenu {
  1228. position: fixed;
  1229. top: 20px;
  1230. left: 20px;
  1231. width: 350px;
  1232. max-height: 400px;
  1233. background: rgba(0, 0, 0, 0.25);
  1234. border: 3px solid #444444;
  1235. border-radius: 15px;
  1236. font-family: 'Poppins', sans-serif;
  1237. display: flex;
  1238. flex-direction: column;
  1239. align-items: center;
  1240. justify-content: center;
  1241. color: #ffffff;
  1242. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  1243. visibility: hidden; /* Initially hidden */
  1244. opacity: 0; /* Initially transparent */
  1245. transition: visibility 0.3s ease, opacity 0.3s ease, transform 0.3s ease; /* Added transform to transition */
  1246. overflow-y: auto;
  1247. padding: 15px;
  1248. z-index: 1000;
  1249. }
  1250.  
  1251. #customMenu.show {
  1252. visibility: visible; /* Make visible when class is added */
  1253. opacity: 1; /* Fully opaque */
  1254. }
  1255.  
  1256. #customMenu:hover {
  1257. transform: scale(1.05); /* Scale up to 105% */
  1258. }
  1259.  
  1260. .menu-option {
  1261. display: flex; /* Use flex to align items */
  1262. align-items: center; /* Center items vertically */
  1263. padding: 5px 10px; /* Padding for the menu item */
  1264. }
  1265.  
  1266. input[type="checkbox"] {
  1267. position: relative;
  1268. background: #d3d3d3;
  1269. appearance: none;
  1270. width: 27px;
  1271. height: 15px;
  1272. border-radius: 50px;
  1273. box-shadow: inset 0 0 5px rgba(200, 200, 200, 0.1);
  1274. cursor: pointer;
  1275. margin-right: 10px; /* Add some space between checkbox and text */
  1276. transition: 0.7s;
  1277. }
  1278.  
  1279. input:checked[type="checkbox"] {
  1280. background: #444444;
  1281. }
  1282.  
  1283. input[type="checkbox"]::after {
  1284. position: absolute;
  1285. content: "";
  1286. width: 15px;
  1287. height: 15px;
  1288. top: 0;
  1289. left: 0;
  1290. background: #fff;
  1291. border-radius: 50%;
  1292. box-shadow: 0 0 5px rgba(200, 200, 200, 0.3);
  1293. transform: scale(1.1);
  1294. transition: 0.7s;
  1295. }
  1296.  
  1297. input:checked[type="checkbox"]::after {
  1298. left: 50%;
  1299. }
  1300.  
  1301. #customMenu::-webkit-scrollbar {
  1302. width: 12px; /* Custom width for the scrollbar */
  1303. }
  1304.  
  1305. #customMenu::-webkit-scrollbar-track {
  1306. background: rgba(0, 0, 0, 0); /* Light grey background for the track */
  1307. border-radius: 10px; /* Rounded corners for the track */
  1308. }
  1309.  
  1310. #customMenu::-webkit-scrollbar-thumb {
  1311. background: rgba(0, 0, 0, 0);
  1312. border-radius: 10px;
  1313. }
  1314.  
  1315. #customMenu::-webkit-scrollbar-thumb:hover {
  1316. background: rgba(0, 0, 0, 0);
  1317. }
  1318.  
  1319. .menu-header {
  1320. font-size: 22px; /* Adjusted font size */
  1321. margin-bottom: 10px;
  1322. color: #ffffff;
  1323. display: flex;
  1324. align-items: center;
  1325. gap: 10px; /* Space between icons and text */
  1326. text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5); /* Enhanced text shadow */
  1327. width: 100%;
  1328. justify-content: center;
  1329. }
  1330. .menu-title {
  1331. font-size: 22px; /* Adjusted font size for title */
  1332. color: #ffffff;
  1333. }
  1334.  
  1335. .menu-tabs {
  1336. display: flex;
  1337. width: auto;
  1338. justify-content: space-between;
  1339. margin-bottom: 10px;
  1340. gap: 5px;
  1341. }
  1342.  
  1343. .tab-button {
  1344. width: 100%;
  1345. padding: 8px; /* Reduced padding */
  1346. background: rgba(0, 0, 0, 0.25); /* White background */
  1347. border: 3px solid #444444; /* Light purple border */
  1348. border-radius: 8px;
  1349. color: #fff; /* Light purple text */
  1350. font-size: 14px; /* Reduced font size */
  1351. font-family: 'Poppins', sans-serif; /* Ensure Poppins is applied */
  1352. cursor: pointer;
  1353. transition: background-color 0.3s ease, color 0.3s ease;
  1354. display: flex;
  1355. align-items: center;
  1356. gap: 8px; /* Reduced gap */
  1357. }
  1358.  
  1359. .tab-button.active {
  1360. background-color: #444444; /* Light purple background for active tab */
  1361. color: #ffffff; /* White text for active tab */
  1362. }
  1363.  
  1364. .menu-content {
  1365. width: 100%;
  1366. display: flex;
  1367. flex-direction: column;
  1368. align-items: center;
  1369. }
  1370.  
  1371. .tab-content {
  1372. display: none;
  1373. width: 100%;
  1374. text-align: center;
  1375. }
  1376.  
  1377. .tab-content:first-child {
  1378. display: block;
  1379. }
  1380.  
  1381. .menu-option {
  1382. margin: 8px 0;
  1383. background: rgba(0, 0, 0, 0.25); /* White background */
  1384. border: 3px solid #444444; /* Light purple border */
  1385. border-radius: 8px;
  1386. color: #fff; /* Light purple text */
  1387. font-size: 16px; /* Adjusted font size */
  1388. font-family: 'Poppins', sans-serif; /* Ensure Poppins is applied */
  1389. display: flex;
  1390. align-items: center;
  1391. gap: 10px;
  1392. cursor: pointer;
  1393. transition: background-color 0.3s ease, color 0.3s ease;
  1394. padding: 5px 10px;
  1395. }
  1396.  
  1397.  
  1398.  
  1399. .menu-option:hover {
  1400. background-color: #444444; /* Light purple background on hover */
  1401. color: #ffffff; /* White text on hover */
  1402. }
  1403.  
  1404. .menu-option input[type="checkbox"],
  1405. .menu-option input[type="radio"] {
  1406. margin-right: 10px; /* Space between checkbox/radio and text */
  1407. }
  1408.  
  1409. .tab-content p {
  1410. font-size: 16px; /* Adjusted font size for paragraphs */
  1411. color: #ffffff; /* White text */
  1412. }
  1413.  
  1414. #customMenu.show {
  1415. visibility: visible;
  1416. opacity: 1;
  1417. }
  1418. `;
  1419. document.head.appendChild(style);
  1420.  
  1421. // Function to toggle the menu
  1422. function toggleMenu() {
  1423. menuContainer.classList.toggle('show');
  1424. }
  1425.  
  1426. // Add event listener for ESC key to toggle the menu
  1427. document.addEventListener('keydown', function(event) {
  1428. if (event.key === 'Escape') {
  1429. toggleMenu();
  1430. }
  1431. });
  1432.  
  1433. // Hide the menu initially
  1434. menuContainer.classList.remove('show');
  1435.  
  1436. // Event listeners for tab buttons
  1437. document.querySelectorAll('.tab-button').forEach(button => {
  1438. button.addEventListener('click', () => {
  1439. document.querySelectorAll('.tab-button').forEach(btn => btn.classList.remove('active'));
  1440. button.classList.add('active');
  1441. const tab = button.getAttribute('data-tab');
  1442. document.querySelectorAll('.tab-content').forEach(content => {
  1443. content.style.display = content.id === `${tab}-content` ? 'block' : 'none';
  1444. });
  1445. });
  1446. });
  1447. })();
  1448. let menuChatDiv = document.createElement("div");
  1449. menuChatDiv.id = "menuChatDiv";
  1450. document.body.appendChild(menuChatDiv);
  1451. HTML.set("menuChatDiv");
  1452. HTML.setStyle(`
  1453. position: absolute;
  1454. display: none;
  1455. left: 0px;
  1456. top: 25px;
  1457. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1458. `);
  1459. HTML.resetHTML();
  1460. HTML.setCSS(`
  1461. .chDiv {
  1462. display: none;
  1463. color: #fff;
  1464. padding: 10px;
  1465. width: 357px;
  1466. height: 217px;
  1467. background-color: rgba(0, 0, 0, 0.2);
  1468. font-family: "HammerSmith One", monospace;
  1469. // border-radius: 15px;
  1470. // box-shadow: black 1px 2px 19px;
  1471. //backdrop-filter: blur(3px);
  1472.  
  1473. }
  1474. .chMainDiv {
  1475. display: none;
  1476. font-family: "Ubuntu";
  1477. font-size: 16px;
  1478. max-height: 215px;
  1479. overflow-y: scroll;
  1480. scrollbar-width: thin;
  1481. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1482. -webkit-touch-callout: none;
  1483. -webkit-user-select: none;
  1484. -khtml-user-select: none;
  1485. -moz-user-select: none;
  1486. -ms-user-select: none;
  1487. user-select: none;
  1488. overflow-x: hidden;
  1489. }
  1490. .chMainDiv::-webkit-scrollbar {
  1491. width: 8px;
  1492. }
  1493. .chMainDiv::-webkit-scrollbar-thumb {
  1494. background-color: rgba(0, 0, 0, 0.5);
  1495. }
  1496. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1497. background-color: rgba(0, 0, 0, 0.7);
  1498. }
  1499. .chMainBox {
  1500. display:none;
  1501. position: absolute;
  1502. left: 10px;
  1503. bottom: 10px;
  1504. width: 380px;
  1505. height: 25px;
  1506. background-color: rgba(255, 255, 255, 0.1);
  1507. border-radius: 5px;
  1508. color: rgba(255, 255, 255, 0.75);
  1509. font-family: "HammerSmith One";
  1510. font-size: 12px;
  1511. }
  1512. `);
  1513. HTML.startDiv({
  1514. id: "mChDiv",
  1515. class: "chDiv"
  1516. }, (html) => {
  1517. HTML.addDiv({
  1518. id: "mChMain",
  1519. class: "chMainDiv",
  1520. appendID: "mChDiv"
  1521. }, (html) => {});
  1522. html.text({
  1523. id: "mChBox",
  1524. class: "chMainBox",
  1525. // placeHolder: `To chat click here or press "Enter" key`
  1526. });
  1527. HTML.addDiv({
  1528. id: "menuConfig",
  1529. class: "menuC",
  1530. appendID: "menuHeadLine"
  1531. }, (html) => {
  1532. html.newLine();
  1533. });
  1534. HTML.addDiv({
  1535. id: "menuOther",
  1536. class: "menuC",
  1537. appendID: "menuHeadLine"
  1538. }, (html) => {
  1539. html.button({
  1540. class: "menuB",
  1541. innerHTML: "Connect Bots",
  1542. onclick: "window.tryConnectBots()"
  1543. });
  1544. html.button({
  1545. class: "menuB",
  1546. innerHTML: "Disconnect Bots",
  1547. onclick: "window.destroyBots()"
  1548. });
  1549. html.newLine();
  1550. html.button({
  1551. class: "menuB",
  1552. innerHTML: "Connect FBots",
  1553. onclick: "window.connectFillBots()"
  1554. });
  1555. html.button({
  1556. class: "menuB",
  1557. innerHTML: "Disconnect FBots",
  1558. onclick: "window.destroyFillBots()"
  1559. });
  1560. html.newLine();
  1561. html.button({
  1562. class: "menuB",
  1563. innerHTML: "Reset Break Objects",
  1564. onclick: "window.resBuild()"
  1565. });
  1566. html.newLine();
  1567. html.add(`Break Objects Range: `);
  1568. html.text({
  1569. id: "breakRange",
  1570. class: "customText",
  1571. value: "700",
  1572. size: "3em",
  1573. maxLength: "4"
  1574. });
  1575. html.newLine();
  1576. html.add(`Bot Mode: `);
  1577. html.select({
  1578. id: "mode",
  1579. class: "Cselect",
  1580. option: {
  1581. "Clear Building": {
  1582. id: "clear",
  1583. selected: true
  1584. },
  1585. "Sync": {
  1586. id: "zync",
  1587. },
  1588. "Search": {
  1589. id: "zearch"
  1590. },
  1591. "Clear Everything": {
  1592. id: "fuckemup"
  1593. },
  1594. "Flex": {
  1595. id: "flex"
  1596. }
  1597. }
  1598. });
  1599. html.newLine(2);
  1600. html.button({
  1601. class: "menuB",
  1602. innerHTML: "Toggle Fbots Circle",
  1603. onclick: "window.toggleBotsCircle()"
  1604. });
  1605. html.newLine();
  1606. html.add(`Circle Rad: `);
  1607. html.text({
  1608. id: "circleRad",
  1609. class: "customText",
  1610. value: "200",
  1611. size: "3em",
  1612. maxLength: "4"
  1613. });
  1614. html.newLine();
  1615. html.add(`Rad Speed: `);
  1616. html.text({
  1617. id: "radSpeed",
  1618. class: "customText",
  1619. value: "0.1",
  1620. size: "2em",
  1621. maxLength: "3"
  1622. });
  1623. html.newLine();
  1624. html.add(`Bot Zetup Type: `);
  1625. html.select({
  1626. id: "setup",
  1627. class: "Cselect",
  1628. option: {
  1629. "Dagger Musket": {
  1630. id: "dm",
  1631. selected: true
  1632. },
  1633. "Katana Hammer": {
  1634. id: "kh",
  1635. },
  1636. "Dagger Repeater-Crossbow": {
  1637. id: "dr"
  1638. },
  1639. "Zhort-Zword Muzket": {
  1640. id: "zd"
  1641. }
  1642. }
  1643. });
  1644. html.newLine(2);
  1645. html.add(`Cross World: `);
  1646. html.checkBox({
  1647. id: "funni",
  1648. class: "checkB"
  1649. });
  1650. html.newLine();
  1651. html.button({
  1652. class: "menuB",
  1653. innerHTML: "Toggle Another Visual",
  1654. onclick: "window.toggleVisual()"
  1655. });
  1656. html.newLine();
  1657. });
  1658. });
  1659.  
  1660. let menuChats = getEl("mChMain");
  1661. let menuChatBox = getEl("mChBox");
  1662. let menuCBFocus = false;
  1663. let menuChCounts = 0;
  1664.  
  1665. menuChatBox.value = "";
  1666. menuChatBox.addEventListener("focus", () => {
  1667. menuCBFocus = true;
  1668. });
  1669. menuChatBox.addEventListener("blur", () => {
  1670. menuCBFocus = false;
  1671. });
  1672.  
  1673. function addMenuChText(name, message, color, noTimer) {
  1674. HTML.set("menuChatDiv");
  1675. color = color || "white";
  1676. let time = new Date();
  1677. let min = time.getMinutes();
  1678. let hour = time.getHours();
  1679. let text = ``;
  1680. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1681. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1682. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1683. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1684. html.add(text);
  1685. });
  1686. menuChats.scrollTop = menuChats.scrollHeight;
  1687. menuChCounts++;
  1688. }
  1689. function chch(name, message, color, noTimer) {
  1690. HTML.set("menuChatDiv");
  1691. color = color || "white";
  1692. let time = new Date();
  1693. let text = ``;
  1694. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1695. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1696. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1697. html.add(text);
  1698. });
  1699. menuChats.scrollTop = menuChats.scrollHeight;
  1700. menuChCounts++;
  1701. }
  1702.  
  1703. function resetMenuChText() {
  1704. menuChats.innerHTML = ``;
  1705. menuChCounts = 0;
  1706. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1707. }
  1708. resetMenuChText();
  1709.  
  1710. let menuIndex = 0;
  1711. let menus = ["menuMain", "menuConfig", "menuOther"];
  1712. window.changeMenu = function() {
  1713. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1714. menuIndex++;
  1715. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1716. };
  1717.  
  1718. let mStatus = document.createElement("div");
  1719. mStatus.id = "status";
  1720. getEl("gameUI").appendChild(mStatus);
  1721. HTML.set("status");
  1722. HTML.setStyle(`
  1723. display: block;
  1724. position: absolute;
  1725. color: #ddd;
  1726. font: 15px Hammersmith One;
  1727. bottom: 215px;
  1728. left: 20px;
  1729. `);
  1730. HTML.resetHTML();
  1731. HTML.setCSS(`
  1732. .sizing {
  1733. font-size: 15px;
  1734. }
  1735. .mod {
  1736. font-size: 15px;
  1737. display: inline-block;
  1738. }
  1739. `);
  1740. HTML.startDiv({
  1741. id: "uehmod",
  1742. class: "sizing"
  1743. }, (html) => {
  1744. html.add(`Ping: `);
  1745. HTML.addDiv({
  1746. id: "pingFps",
  1747. class: "mod",
  1748. appendID: "uehmod"
  1749. }, (html) => {
  1750. html.add("None");
  1751. });
  1752. html.newLine();
  1753. html.add(`Packet: `);
  1754. HTML.addDiv({
  1755. id: "packetStatus",
  1756. class: "mod",
  1757. appendID: "uehmod"
  1758. }, (html) => {
  1759. html.add("None");
  1760. });
  1761. });
  1762.  
  1763. /*function modLog() {
  1764. let logs = [];
  1765. for (let i = 0; i < arguments.length; i++) {
  1766. logs.push(arguments[i]);
  1767. }
  1768. getEl("modLog").innerHTML = logs;
  1769. }*/
  1770.  
  1771. let WS = undefined;
  1772. let socketID = undefined;
  1773.  
  1774. let useWasd = false;
  1775. let secPacket = 0;
  1776. let secMax = 120;
  1777. let secTime = 1000;
  1778. let firstSend = {
  1779. sec: false
  1780. };
  1781. let game = {
  1782. tick: 0,
  1783. tickQueue: [],
  1784. tickBase: function(set, tick) {
  1785. if (this.tickQueue[this.tick + tick]) {
  1786. this.tickQueue[this.tick + tick].push(set);
  1787. } else {
  1788. this.tickQueue[this.tick + tick] = [set];
  1789. }
  1790. },
  1791. tickRate: (1000 / config.serverUpdateRate),
  1792. tickSpeed: 0,
  1793. lastTick: performance.now()
  1794. };
  1795. let modConsole = [];
  1796.  
  1797. let dontSend = false;
  1798. let fpsTimer = {
  1799. last: 0,
  1800. time: 0,
  1801. ltime: 0
  1802. }
  1803. let lastMoveDir = undefined;
  1804. let lastsp = ["cc", 1, "__proto__"];
  1805.  
  1806. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1807. WebSocket.prototype.send = function(message) {
  1808. if (!WS) {
  1809. WS = this;
  1810. WS.addEventListener("message", function(msg) {
  1811. getMessage(msg);
  1812. });
  1813. WS.addEventListener("close", (event) => {
  1814. if (event.code == 4001) {
  1815. window.location.reload();
  1816. }
  1817. });
  1818. }
  1819. if (WS == this) {
  1820. dontSend = false;
  1821.  
  1822. // EXTRACT DATA ARRAY:
  1823. let data = new Uint8Array(message);
  1824. let parsed = window.msgpack.decode(data);
  1825. let type = parsed[0];
  1826. data = parsed[1];
  1827.  
  1828. // SEND MESSAGE:
  1829. if (type == "6") {
  1830.  
  1831. if (data[0]) {
  1832. // ANTI PROFANITY:
  1833. let profanity = ["cunt", "whore", "fuck", "shit", "faggot", "nigger", "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex", "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune", "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard", ];
  1834. let tmpString;
  1835. profanity.forEach((profany) => {
  1836. if (data[0].indexOf(profany) > -1) {
  1837. tmpString = "";
  1838. for (let i = 0; i < profany.length; ++i) {
  1839. if (i == 1) {
  1840. tmpString += String.fromCharCode(0);
  1841. }
  1842. tmpString += profany[i];
  1843. }
  1844. let re = new RegExp(profany, "g");
  1845. data[0] = data[0].replace(re, tmpString);
  1846. }
  1847. });
  1848.  
  1849. // FIX CHAT:
  1850. data[0] = data[0].slice(0, 30);
  1851. }
  1852.  
  1853. } else if (type == "L") {
  1854. // MAKE SAME CLAN:
  1855. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1856. data[0] = data[0].slice(0, 7);
  1857. } else if (type == "M") {
  1858. // APPLY CYAN COLOR:
  1859. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1860. data[0].moofoll = true;
  1861. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1862. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1863. } else if (type == "D") {
  1864. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1865. dontSend = true;
  1866. } else {
  1867. my.lastDir = data[0];
  1868. }
  1869. } else if (type == "d") {
  1870. if (!data[2]) {
  1871. dontSend = true;
  1872. } else {
  1873. if (![null, undefined].includes(data[1])) {
  1874. my.lastDir = data[1];
  1875. }
  1876. }
  1877. } else if (type == "K") {
  1878. if (!data[1]) {
  1879. dontSend = true;
  1880. }
  1881. } else if (type == "S") {
  1882. instaC.wait = !instaC.wait;
  1883. dontSend = true;
  1884. } else if (type == "a") {
  1885. if (data[1]) {
  1886. if (player.moveDir == data[0]) {
  1887. dontSend = true;
  1888. }
  1889. player.moveDir = data[0];
  1890. } else {
  1891. dontSend = true;
  1892. }
  1893. }
  1894. if (!dontSend) {
  1895. let binary = window.msgpack.encode([type, data]);
  1896. this.nsend(binary);
  1897.  
  1898. // START COUNT:
  1899. if (!firstSend.sec) {
  1900. firstSend.sec = true;
  1901. setTimeout(() => {
  1902. firstSend.sec = false;
  1903. secPacket = 0;
  1904. }, secTime);
  1905. }
  1906.  
  1907. secPacket++;
  1908. }
  1909. } else {
  1910. this.nsend(message);
  1911. }
  1912. }
  1913.  
  1914. function packet(type) {
  1915. // EXTRACT DATA ARRAY:
  1916. let data = Array.prototype.slice.call(arguments, 1);
  1917.  
  1918. // SEND MESSAGE:
  1919. let binary = window.msgpack.encode([type, data]);
  1920. WS.send(binary);
  1921. }
  1922.  
  1923. function origPacket(type) {
  1924. // EXTRACT DATA ARRAY:
  1925. let data = Array.prototype.slice.call(arguments, 1);
  1926.  
  1927. // SEND MESSAGE:
  1928. let binary = window.msgpack.encode([type, data]);
  1929. WS.nsend(binary);
  1930. }
  1931.  
  1932. window.leave = function() {
  1933. origPacket("kys", {
  1934. "frvr is so bad": true,
  1935. "sidney is too good": true,
  1936. "dev are too weak": true,
  1937. });
  1938. };
  1939.  
  1940. //...lol
  1941. let io = {
  1942. send: packet
  1943. };
  1944.  
  1945. function getMessage(message) {
  1946. let data = new Uint8Array(message.data);
  1947. let parsed = window.msgpack.decode(data);
  1948. let type = parsed[0];
  1949. data = parsed[1];
  1950. let events = {
  1951. A: setInitData, // id: setInitData,
  1952. //B: disconnect,
  1953. C: setupGame, // 1: setupGame,
  1954. D: addPlayer, // 2: addPlayer,
  1955. E: removePlayer, // 4: removePlayer,
  1956. a: updatePlayers, // 33: updatePlayers,
  1957. G: updateLeaderboard, // 5: updateLeaderboard,here
  1958. H: loadGameObject, // 6: loadGameObject,
  1959. I: loadAI, // a: loadAI,
  1960. J: animateAI, // aa: animateAI,
  1961. K: gatherAnimation, // 7: gatherAnimation,
  1962. L: wiggleGameObject, // 8: wiggleGameObject,
  1963. M: shootTurret, // sp: shootTurret,
  1964. N: updatePlayerValue, // 9: updatePlayerValue,
  1965. O: updateHealth, // h: updateHealth,//here
  1966. P: killPlayer, // 11: killPlayer,
  1967. Q: killObject, // 12: killObject,
  1968. R: killObjects, // 13: killObjects,
  1969. S: updateItemCounts, // 14: updateItemCounts,
  1970. T: updateAge, // 15: updateAge,
  1971. U: updateUpgrades, // 16: updateUpgrades,
  1972. V: updateItems, // 17: updateItems,
  1973. X: addProjectile, // 18: addProjectile,
  1974. // Y: remProjectile, // 19: remProjectile,
  1975. //Z: serverShutdownNotice,
  1976. //0: addAlliance,
  1977. //1: deleteAlliance,
  1978. 2: allianceNotification, // an: allianceNotification,
  1979. 3: setPlayerTeam, // st: setPlayerTeam,
  1980. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1981. 5: updateStoreItems, // us: updateStoreItems,
  1982. 6: receiveChat, // ch: receiveChat,
  1983. 7: updateMinimap, // mm: updateMinimap,
  1984. 8: showText, // t: showText,
  1985. 9: pingMap, // p: pingMap,
  1986. 0: pingSocketResponse,
  1987. };
  1988. if (type == "io-init") {
  1989. socketID = data[0];
  1990. } else {
  1991. if (events[type]) {
  1992. events[type].apply(undefined, data);
  1993. }
  1994. }
  1995. }
  1996.  
  1997. // MATHS:
  1998. Math.lerpAngle = function(value1, value2, amount) {
  1999. let difference = Math.abs(value2 - value1);
  2000. if (difference > Math.PI) {
  2001. if (value1 > value2) {
  2002. value2 += Math.PI * 2;
  2003. } else {
  2004. value1 += Math.PI * 2;
  2005. }
  2006. }
  2007. let value = value2 + ((value1 - value2) * amount);
  2008. if (value >= 0 && value <= Math.PI * 2) return value;
  2009. return value % (Math.PI * 2);
  2010. };
  2011.  
  2012. // REOUNDED RECTANGLE:
  2013. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  2014. if (w < 2 * r) r = w / 2;
  2015. if (h < 2 * r) r = h / 2;
  2016. if (r < 0)
  2017. r = 0;
  2018. this.beginPath();
  2019. this.moveTo(x + r, y);
  2020. this.arcTo(x + w, y, x + w, y + h, r);
  2021. this.arcTo(x + w, y + h, x, y + h, r);
  2022. this.arcTo(x, y + h, x, y, r);
  2023. this.arcTo(x, y, x + w, y, r);
  2024. this.closePath();
  2025. return this;
  2026. };
  2027.  
  2028. // GLOBAL VALUES:
  2029. function resetMoveDir() {
  2030. keys = {};
  2031. io.send("e");
  2032. }
  2033.  
  2034. let allChats = [];
  2035. let ticks = {
  2036. tick: 0,
  2037. delay: 0,
  2038. time: [],
  2039. manage: [],
  2040. };
  2041. let ais = [];
  2042. let players = [];
  2043. let alliances = [];
  2044. let alliancePlayers = [];
  2045. let allianceNotifications = [];
  2046. let gameObjects = [];
  2047. let liztobj = [];
  2048. let projectiles = [];
  2049. let deadPlayers = [];
  2050.  
  2051. let breakObjects = [];
  2052.  
  2053. let player;
  2054. let playerSID;
  2055. let tmpObj;
  2056.  
  2057. let enemy = [];
  2058. let nears = [];
  2059. let near = [];
  2060.  
  2061. let my = {
  2062. reloaded: false,
  2063. waitHit: 0,
  2064. autoAim: false,
  2065. revAim: false,
  2066. ageInsta: true,
  2067. reSync: false,
  2068. bullTick: 0,
  2069. anti0Tick: 0,
  2070. antiSync: false,
  2071. safePrimary: function(tmpObj) {
  2072. return [0, 8].includes(tmpObj.primaryIndex);
  2073. },
  2074. safeSecondary: function(tmpObj) {
  2075. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  2076. },
  2077. lastDir: 0,
  2078. autoPush: false,
  2079. pushData: {}
  2080. }
  2081.  
  2082. // FIND OBJECTS BY ID/SID:
  2083. function findID(tmpObj, tmp) {
  2084. return tmpObj.find((THIS) => THIS.id == tmp);
  2085. }
  2086.  
  2087. function findSID(tmpObj, tmp) {
  2088. return tmpObj.find((THIS) => THIS.sid == tmp);
  2089. }
  2090.  
  2091. function findPlayerByID(id) {
  2092. return findID(players, id);
  2093. }
  2094.  
  2095. function findPlayerBySID(sid) {
  2096. return findSID(players, sid);
  2097. }
  2098.  
  2099. function findAIBySID(sid) {
  2100. return findSID(ais, sid);
  2101. }
  2102.  
  2103. function findObjectBySid(sid) {
  2104. return findSID(gameObjects, sid);
  2105. }
  2106.  
  2107. function findProjectileBySid(sid) {
  2108. return findSID(gameObjects, sid);
  2109. }
  2110.  
  2111. let adCard = getEl("adCard");
  2112. adCard.remove();
  2113. let promoImageHolder = getEl("promoImgHolder");
  2114. promoImageHolder.remove();
  2115.  
  2116. let chatButton = getEl("chatButton");
  2117. chatButton.remove();
  2118. let gameCanvas = getEl("gameCanvas");
  2119. let mainContext = gameCanvas.getContext("2d");
  2120. let mapDisplay = getEl("mapDisplay");
  2121. let mapContext = mapDisplay.getContext("2d");
  2122. mapDisplay.width = 300;
  2123. mapDisplay.height = 300;
  2124. let storeMenu = getEl("storeMenu");
  2125. let storeHolder = getEl("storeHolder");
  2126. let upgradeHolder = getEl("upgradeHolder");
  2127. let upgradeCounter = getEl("upgradeCounter");
  2128. let chatBox = getEl("chatBox");
  2129. chatBox.autocomplete = "off";
  2130. chatBox.style.textAlign = "center";
  2131. chatBox.style.width = "18em";
  2132. let chatHolder = getEl("chatHolder");
  2133. let actionBar = getEl("actionBar");
  2134. let leaderboardData = getEl("leaderboardData");
  2135. let itemInfoHolder = getEl("itemInfoHolder");
  2136. let menuCardHolder = getEl("menuCardHolder");
  2137. let mainMenu = getEl("mainMenu");
  2138. let diedText = getEl("diedText");
  2139. let screenWidth;
  2140. let screenHeight;
  2141. let maxScreenWidth = config.maxScreenWidth;
  2142. let maxScreenHeight = config.maxScreenHeight;
  2143. let pixelDensity = 1;
  2144. let delta;
  2145. let now;
  2146. let lastUpdate = performance.now();
  2147. let camX;
  2148. let camY;
  2149. let tmpDir;
  2150. let mouseX = 0;
  2151. let mouseY = 0;
  2152. let allianceMenu = getEl("allianceMenu");
  2153. let waterMult = 1;
  2154. let waterPlus = 0;
  2155.  
  2156. let outlineColor = "#525252";
  2157. let darkOutlineColor = "#3d3f42";
  2158. let outlineWidth = 5.5;
  2159.  
  2160. let firstSetup = true;
  2161. let keys = {};
  2162. let moveKeys = {
  2163. 87: [0, -1],
  2164. 38: [0, -1],
  2165. 83: [0, 1],
  2166. 40: [0, 1],
  2167. 65: [-1, 0],
  2168. 37: [-1, 0],
  2169. 68: [1, 0],
  2170. 39: [1, 0],
  2171. };
  2172. let attackState = 0;
  2173. let inGame = false;
  2174.  
  2175. let macro = {};
  2176. let mills = {
  2177. place: 0,
  2178. placeSpawnPads: 0
  2179. };
  2180. let lastDir;
  2181.  
  2182. let lastLeaderboardData = [];
  2183.  
  2184. // ON LOAD:
  2185. let inWindow = true;
  2186. window.onblur = function() {
  2187. inWindow = false;
  2188. };
  2189. window.onfocus = function() {
  2190. inWindow = true;
  2191. if (player && player.alive) {
  2192. // resetMoveDir();
  2193. }
  2194. };
  2195. let ms = {
  2196. avg: 0,
  2197. max: 0,
  2198. min: 0,
  2199. delay: 0
  2200. }
  2201. function pingSocketResponse() {
  2202. let pingTime = window.pingTime;
  2203. const pingDisplay = document.getElementById("pingDisplay")
  2204. pingDisplay.innerText = "";
  2205. if (pingTime > ms.max || isNaN(ms.max)) {
  2206. ms.max = pingTime;
  2207. }
  2208. if (pingTime < ms.min || isNaN(ms.min)) {
  2209. ms.min = pingTime;
  2210. }
  2211.  
  2212. // if (pingTime >= 90) {
  2213. // doAutoQ = true;
  2214. // } else {
  2215. // doAutoQ = false;
  2216. // }
  2217. }
  2218.  
  2219. let placeVisible = [];
  2220.  
  2221. /** CLASS CODES */
  2222.  
  2223. class Utils {
  2224. constructor() {
  2225.  
  2226. // MATH UTILS:
  2227. let mathABS = Math.abs,
  2228. mathCOS = Math.cos,
  2229. mathSIN = Math.sin,
  2230. mathPOW = Math.pow,
  2231. mathSQRT = Math.sqrt,
  2232. mathATAN2 = Math.atan2,
  2233. mathPI = Math.PI;
  2234.  
  2235. let _this = this;
  2236.  
  2237. // GLOBAL UTILS:
  2238. this.round = function(n, v) {
  2239. return Math.round(n * v) / v;
  2240. };
  2241. this.toRad = function(angle) {
  2242. return angle * (mathPI / 180);
  2243. };
  2244. this.toAng = function(radian) {
  2245. return radian / (mathPI / 180);
  2246. };
  2247. this.randInt = function(min, max) {
  2248. return Math.floor(Math.random() * (max - min + 1)) + min;
  2249. };
  2250. this.randFloat = function(min, max) {
  2251. return Math.random() * (max - min + 1) + min;
  2252. };
  2253. this.lerp = function(value1, value2, amount) {
  2254. return value1 + (value2 - value1) * amount;
  2255. };
  2256. this.decel = function(val, cel) {
  2257. if (val > 0)
  2258. val = Math.max(0, val - cel);
  2259. else if (val < 0)
  2260. val = Math.min(0, val + cel);
  2261. return val;
  2262. };
  2263. this.getDistance = function(x1, y1, x2, y2) {
  2264. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  2265. };
  2266. this.getDist = function(tmp1, tmp2, type1, type2) {
  2267. let tmpXY1 = {
  2268. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  2269. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  2270. };
  2271. let tmpXY2 = {
  2272. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  2273. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  2274. };
  2275. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  2276. };
  2277. this.getDirection = function(x1, y1, x2, y2) {
  2278. return mathATAN2(y1 - y2, x1 - x2);
  2279. };
  2280. this.getDirect = function(tmp1, tmp2, type1, type2) {
  2281. let tmpXY1 = {
  2282. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  2283. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  2284. };
  2285. let tmpXY2 = {
  2286. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  2287. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  2288. };
  2289. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  2290. };
  2291. this.getAngleDist = function(a, b) {
  2292. let p = mathABS(b - a) % (mathPI * 2);
  2293. return (p > mathPI ? (mathPI * 2) - p : p);
  2294. };
  2295. this.isNumber = function(n) {
  2296. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  2297. };
  2298. this.isString = function(s) {
  2299. return (s && typeof s == "string");
  2300. };
  2301. this.kFormat = function(num) {
  2302. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  2303. };
  2304. this.sFormat = function(num) {
  2305. let fixs = [{
  2306. num: 1e3,
  2307. string: "k"
  2308. },
  2309. {
  2310. num: 1e6,
  2311. string: "m"
  2312. },
  2313. {
  2314. num: 1e9,
  2315. string: "b"
  2316. },
  2317. {
  2318. num: 1e12,
  2319. string: "q"
  2320. }
  2321. ].reverse();
  2322. let sp = fixs.find(v => num >= v.num);
  2323. if (!sp) return num;
  2324. return (num / sp.num).toFixed(1) + sp.string;
  2325. };
  2326. this.capitalizeFirst = function(string) {
  2327. return string.charAt(0).toUpperCase() + string.slice(1);
  2328. };
  2329. this.fixTo = function(n, v) {
  2330. return parseFloat(n.toFixed(v));
  2331. };
  2332. this.sortByPoints = function(a, b) {
  2333. return parseFloat(b.points) - parseFloat(a.points);
  2334. };
  2335. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  2336. let minX = x1;
  2337. let maxX = x2;
  2338. if (x1 > x2) {
  2339. minX = x2;
  2340. maxX = x1;
  2341. }
  2342. if (maxX > recX2)
  2343. maxX = recX2;
  2344. if (minX < recX)
  2345. minX = recX;
  2346. if (minX > maxX)
  2347. return false;
  2348. let minY = y1;
  2349. let maxY = y2;
  2350. let dx = x2 - x1;
  2351. if (Math.abs(dx) > 0.0000001) {
  2352. let a = (y2 - y1) / dx;
  2353. let b = y1 - a * x1;
  2354. minY = a * minX + b;
  2355. maxY = a * maxX + b;
  2356. }
  2357. if (minY > maxY) {
  2358. let tmp = maxY;
  2359. maxY = minY;
  2360. minY = tmp;
  2361. }
  2362. if (maxY > recY2)
  2363. maxY = recY2;
  2364. if (minY < recY)
  2365. minY = recY;
  2366. if (minY > maxY)
  2367. return false;
  2368. return true;
  2369. };
  2370. this.containsPoint = function(element, x, y) {
  2371. let bounds = element.getBoundingClientRect();
  2372. let left = bounds.left + window.scrollX;
  2373. let top = bounds.top + window.scrollY;
  2374. let width = bounds.width;
  2375. let height = bounds.height;
  2376.  
  2377. let insideHorizontal = x > left && x < left + width;
  2378. let insideVertical = y > top && y < top + height;
  2379. return insideHorizontal && insideVertical;
  2380. };
  2381. this.mousifyTouchEvent = function(event) {
  2382. let touch = event.changedTouches[0];
  2383. event.screenX = touch.screenX;
  2384. event.screenY = touch.screenY;
  2385. event.clientX = touch.clientX;
  2386. event.clientY = touch.clientY;
  2387. event.pageX = touch.pageX;
  2388. event.pageY = touch.pageY;
  2389. };
  2390. this.hookTouchEvents = function(element, skipPrevent) {
  2391. let preventDefault = !skipPrevent;
  2392. let isHovering = false;
  2393. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  2394. let passive = false;
  2395. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  2396. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  2397. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  2398. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  2399. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  2400.  
  2401. function touchStart(e) {
  2402. _this.mousifyTouchEvent(e);
  2403. window.setUsingTouch(true);
  2404. if (preventDefault) {
  2405. e.preventDefault();
  2406. e.stopPropagation();
  2407. }
  2408. if (element.onmouseover)
  2409. element.onmouseover(e);
  2410. isHovering = true;
  2411. }
  2412.  
  2413. function touchMove(e) {
  2414. _this.mousifyTouchEvent(e);
  2415. window.setUsingTouch(true);
  2416. if (preventDefault) {
  2417. e.preventDefault();
  2418. e.stopPropagation();
  2419. }
  2420. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  2421. if (!isHovering) {
  2422. if (element.onmouseover)
  2423. element.onmouseover(e);
  2424. isHovering = true;
  2425. }
  2426. } else {
  2427. if (isHovering) {
  2428. if (element.onmouseout)
  2429. element.onmouseout(e);
  2430. isHovering = false;
  2431. }
  2432. }
  2433. }
  2434.  
  2435. function touchEnd(e) {
  2436. _this.mousifyTouchEvent(e);
  2437. window.setUsingTouch(true);
  2438. if (preventDefault) {
  2439. e.preventDefault();
  2440. e.stopPropagation();
  2441. }
  2442. if (isHovering) {
  2443. if (element.onclick)
  2444. element.onclick(e);
  2445. if (element.onmouseout)
  2446. element.onmouseout(e);
  2447. isHovering = false;
  2448. }
  2449. }
  2450. };
  2451. this.removeAllChildren = function(element) {
  2452. while (element.hasChildNodes()) {
  2453. element.removeChild(element.lastChild);
  2454. }
  2455. };
  2456. this.generateElement = function(config) {
  2457. let element = document.createElement(config.tag || "div");
  2458.  
  2459. function bind(configValue, elementValue) {
  2460. if (config[configValue])
  2461. element[elementValue] = config[configValue];
  2462. }
  2463. bind("text", "textContent");
  2464. bind("html", "innerHTML");
  2465. bind("class", "className");
  2466. for (let key in config) {
  2467. switch (key) {
  2468. case "tag":
  2469. case "text":
  2470. case "html":
  2471. case "class":
  2472. case "style":
  2473. case "hookTouch":
  2474. case "parent":
  2475. case "children":
  2476. continue;
  2477. default:
  2478. break;
  2479. }
  2480. element[key] = config[key];
  2481. }
  2482. if (element.onclick)
  2483. element.onclick = this.checkTrusted(element.onclick);
  2484. if (element.onmouseover)
  2485. element.onmouseover = this.checkTrusted(element.onmouseover);
  2486. if (element.onmouseout)
  2487. element.onmouseout = this.checkTrusted(element.onmouseout);
  2488. if (config.style) {
  2489. element.style.cssText = config.style;
  2490. }
  2491. if (config.hookTouch) {
  2492. this.hookTouchEvents(element);
  2493. }
  2494. if (config.parent) {
  2495. config.parent.appendChild(element);
  2496. }
  2497. if (config.children) {
  2498. for (let i = 0; i < config.children.length; i++) {
  2499. element.appendChild(config.children[i]);
  2500. }
  2501. }
  2502. return element;
  2503. };
  2504. this.checkTrusted = function(callback) {
  2505. return function(ev) {
  2506. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2507. callback(ev);
  2508. } else {
  2509. //console.error("Event is not trusted.", ev);
  2510. }
  2511. };
  2512. };
  2513. this.randomString = function(length) {
  2514. let text = "";
  2515. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2516. for (let i = 0; i < length; i++) {
  2517. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2518. }
  2519. return text;
  2520. };
  2521. this.countInArray = function(array, val) {
  2522. let count = 0;
  2523. for (let i = 0; i < array.length; i++) {
  2524. if (array[i] === val) count++;
  2525. }
  2526. return count;
  2527. };
  2528. this.hexToRgb = function(hex) {
  2529. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2530. };
  2531. this.getRgb = function(r, g, b) {
  2532. return [r / 255, g / 255, b / 255].join(", ");
  2533. };
  2534. }
  2535. };
  2536. class Animtext {
  2537. // ANIMATED TEXT:
  2538. constructor() {
  2539. // INIT:
  2540. this.init = function(x, y, scale, speed, life, text, color) {
  2541. this.x = x;
  2542. this.y = y;
  2543. this.color = color;
  2544. this.scale = scale;
  2545. this.startScale = this.scale;
  2546. this.maxScale = scale * 1.5;
  2547. this.scaleSpeed = 0.7;
  2548. this.speed = speed;
  2549. this.life = life;
  2550. this.text = text;
  2551. this.acc = 1;
  2552. this.alpha = 0;
  2553. this.maxLife = life;
  2554. this.ranX = UTILS.randFloat(-1, 1);
  2555. };
  2556.  
  2557. // UPDATE:
  2558. this.update = function(delta) {
  2559. if (this.life) {
  2560. this.life -= delta;
  2561. if (configs.anotherVisual) {
  2562. this.y -= this.speed * delta * this.acc;
  2563. this.acc -= delta / (this.maxLife / 2.5);
  2564. if (this.life <= 200) {
  2565. if (this.alpha > 0) {
  2566. this.alpha = Math.max(0, this.alpha - (delta / 300));
  2567. }
  2568. } else {
  2569. if (this.alpha < 1) {
  2570. this.alpha = Math.min(1, this.alpha + (delta / 100));
  2571. }
  2572. }
  2573. this.x += this.ranX;
  2574. } else {
  2575. this.y -= this.speed * delta;
  2576. }
  2577. this.scale += this.scaleSpeed * delta;
  2578. if (this.scale >= this.maxScale) {
  2579. this.scale = this.maxScale;
  2580. this.scaleSpeed *= -1;
  2581. } else if (this.scale <= this.startScale) {
  2582. this.scale = this.startScale;
  2583. this.scaleSpeed = 0;
  2584. }
  2585. if (this.life <= 0) {
  2586. this.life = 0;
  2587. }
  2588. }
  2589. };
  2590.  
  2591. // RENDER:
  2592. this.render = function(ctxt, xOff, yOff) {
  2593. ctxt.lineWidth = 10;
  2594. ctxt.fillStyle = this.color;
  2595. ctxt.font = this.scale + "px " + (configs.anotherVisual ? "34px Arial" : "Hammersmith One");
  2596. if (configs.anotherVisual) {
  2597. ctxt.globalAlpha = this.alpha;
  2598. ctxt.strokeStyle = darkOutlineColor;
  2599. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2600. }
  2601. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2602. ctxt.globalAlpha = 1;
  2603. };
  2604. }
  2605. };
  2606. class Textmanager {
  2607. // TEXT MANAGER:
  2608. constructor() {
  2609. this.texts = [];
  2610. this.stack = [];
  2611.  
  2612. // UPDATE:
  2613. this.update = function(delta, ctxt, xOff, yOff) {
  2614. ctxt.textBaseline = "middle";
  2615. ctxt.textAlign = "center";
  2616. for (let i = 0; i < this.texts.length; ++i) {
  2617. if (this.texts[i].life) {
  2618. this.texts[i].update(delta);
  2619. this.texts[i].render(ctxt, xOff, yOff);
  2620. }
  2621. }
  2622. };
  2623.  
  2624. // SHOW TEXT:
  2625. this.showText = function(x, y, scale, speed, life, text, color) {
  2626. let tmpText;
  2627. for (let i = 0; i < this.texts.length; ++i) {
  2628. if (!this.texts[i].life) {
  2629. tmpText = this.texts[i];
  2630. break;
  2631. }
  2632. }
  2633. if (!tmpText) {
  2634. tmpText = new Animtext();
  2635. this.texts.push(tmpText);
  2636. }
  2637. tmpText.init(x, y, scale, speed, life, text, color);
  2638. };
  2639. }
  2640. }
  2641. class GameObject {
  2642. constructor(sid) {
  2643. this.sid = sid;
  2644.  
  2645. // INIT:
  2646. this.init = function(x, y, dir, scale, type, data, owner) {
  2647. data = data || {};
  2648. this.sentTo = {};
  2649. this.gridLocations = [];
  2650. this.active = true;
  2651. this.render = true;
  2652. this.doUpdate = data.doUpdate;
  2653. this.x = x;
  2654. this.y = y;
  2655. this.dir = dir;
  2656. this.lastDir = dir;
  2657. this.xWiggle = 0;
  2658. this.yWiggle = 0;
  2659. this.visScale = scale;
  2660. this.scale = scale;
  2661. this.type = type;
  2662. this.id = data.id;
  2663. this.owner = owner;
  2664. this.name = data.name;
  2665. this.isItem = (this.id != undefined);
  2666. this.group = data.group;
  2667. this.maxHealth = data.health;
  2668. this.health = this.maxHealth;
  2669. this.layer = 2;
  2670. if (this.group != undefined) {
  2671. this.layer = this.group.layer;
  2672. } else if (this.type == 0) {
  2673. this.layer = 3;
  2674. } else if (this.type == 2) {
  2675. this.layer = 0;
  2676. } else if (this.type == 4) {
  2677. this.layer = -1;
  2678. }
  2679. this.colDiv = data.colDiv || 1;
  2680. this.blocker = data.blocker;
  2681. this.ignoreCollision = data.ignoreCollision;
  2682. this.dontGather = data.dontGather;
  2683. this.hideFromEnemy = data.hideFromEnemy;
  2684. this.friction = data.friction;
  2685. this.projDmg = data.projDmg;
  2686. this.dmg = data.dmg;
  2687. this.pDmg = data.pDmg;
  2688. this.pps = data.pps;
  2689. this.zIndex = data.zIndex || 0;
  2690. this.turnSpeed = data.turnSpeed;
  2691. this.req = data.req;
  2692. this.trap = data.trap;
  2693. this.healCol = data.healCol;
  2694. this.teleport = data.teleport;
  2695. this.boostSpeed = data.boostSpeed;
  2696. this.projectile = data.projectile;
  2697. this.shootRange = data.shootRange;
  2698. this.shootRate = data.shootRate;
  2699. this.shootCount = this.shootRate;
  2700. this.spawnPoint = data.spawnPoint;
  2701. this.onNear = 0;
  2702. this.breakObj = false;
  2703. this.alpha = data.alpha || 1;
  2704. this.maxAlpha = data.alpha || 1;
  2705. this.damaged = 0;
  2706. };
  2707.  
  2708. // GET HIT:
  2709. this.changeHealth = function(amount, doer) {
  2710. this.health += amount;
  2711. return (this.health <= 0);
  2712. };
  2713.  
  2714. // GET SCALE:
  2715. this.getScale = function(sM, ig) {
  2716. sM = sM || 1;
  2717. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2718. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2719. };
  2720.  
  2721. // VISIBLE TO PLAYER:
  2722. this.visibleToPlayer = function(player) {
  2723. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2724. (this.owner.team && player.team == this.owner.team)));
  2725. };
  2726.  
  2727. // UPDATE:
  2728. this.update = function(delta) {
  2729. if (this.active) {
  2730. if (this.xWiggle) {
  2731. this.xWiggle *= Math.pow(0.99, delta);
  2732. }
  2733. if (this.yWiggle) {
  2734. this.yWiggle *= Math.pow(0.99, delta);
  2735. }
  2736. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2737. if (d2 > 0.01) {
  2738. this.dir += d2 / 5;
  2739. } else {
  2740. this.dir = this.lastDir;
  2741. }
  2742. } else {
  2743. if (this.alive) {
  2744. this.alpha -= delta / (200 / this.maxAlpha);
  2745. this.visScale += delta / (this.scale / 2.5);
  2746. if (this.alpha <= 0) {
  2747. this.alpha = 0;
  2748. this.alive = false;
  2749. }
  2750. }
  2751. }
  2752. };
  2753.  
  2754. // CHECK TEAM:
  2755. this.isTeamObject = function(tmpObj) {
  2756. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2757. };
  2758. }
  2759. }
  2760. class Items {
  2761. constructor() {
  2762. // ITEM GROUPS:
  2763. this.groups = [{
  2764. id: 0,
  2765. name: "food",
  2766. layer: 0
  2767. }, {
  2768. id: 1,
  2769. name: "walls",
  2770. place: true,
  2771. limit: 30,
  2772. layer: 0
  2773. }, {
  2774. id: 2,
  2775. name: "spikes",
  2776. place: true,
  2777. limit: 15,
  2778. layer: 0
  2779. }, {
  2780. id: 3,
  2781. name: "mill",
  2782. place: true,
  2783. limit: 7,
  2784. layer: 1
  2785. }, {
  2786. id: 4,
  2787. name: "mine",
  2788. place: true,
  2789. limit: 1,
  2790. layer: 0
  2791. }, {
  2792. id: 5,
  2793. name: "trap",
  2794. place: true,
  2795. limit: 6,
  2796. layer: -1
  2797. }, {
  2798. id: 6,
  2799. name: "booster",
  2800. place: true,
  2801. limit: 12,
  2802. layer: -1
  2803. }, {
  2804. id: 7,
  2805. name: "turret",
  2806. place: true,
  2807. limit: 2,
  2808. layer: 1
  2809. }, {
  2810. id: 8,
  2811. name: "watchtower",
  2812. place: true,
  2813. limit: 12,
  2814. layer: 1
  2815. }, {
  2816. id: 9,
  2817. name: "buff",
  2818. place: true,
  2819. limit: 4,
  2820. layer: -1
  2821. }, {
  2822. id: 10,
  2823. name: "spawn",
  2824. place: true,
  2825. limit: 1,
  2826. layer: -1
  2827. }, {
  2828. id: 11,
  2829. name: "sapling",
  2830. place: true,
  2831. limit: 2,
  2832. layer: 0
  2833. }, {
  2834. id: 12,
  2835. name: "blocker",
  2836. place: true,
  2837. limit: 3,
  2838. layer: -1
  2839. }, {
  2840. id: 13,
  2841. name: "teleporter",
  2842. place: true,
  2843. limit: 2,
  2844. layer: -1
  2845. }];
  2846.  
  2847. // PROJECTILES:
  2848. this.projectiles = [{
  2849. indx: 0,
  2850. layer: 0,
  2851. src: "arrow_1",
  2852. dmg: 25,
  2853. speed: 1.6,
  2854. scale: 103,
  2855. range: 1000
  2856. }, {
  2857. indx: 1,
  2858. layer: 1,
  2859. dmg: 25,
  2860. scale: 20
  2861. }, {
  2862. indx: 0,
  2863. layer: 0,
  2864. src: "arrow_1",
  2865. dmg: 35,
  2866. speed: 2.5,
  2867. scale: 103,
  2868. range: 1200
  2869. }, {
  2870. indx: 0,
  2871. layer: 0,
  2872. src: "arrow_1",
  2873. dmg: 30,
  2874. speed: 2,
  2875. scale: 103,
  2876. range: 1200
  2877. }, {
  2878. indx: 1,
  2879. layer: 1,
  2880. dmg: 16,
  2881. scale: 20
  2882. }, {
  2883. indx: 0,
  2884. layer: 0,
  2885. src: "bullet_1",
  2886. dmg: 50,
  2887. speed: 3.6,
  2888. scale: 160,
  2889. range: 1400
  2890. }];
  2891.  
  2892. // WEAPONS:
  2893. this.weapons = [{
  2894. id: 0,
  2895. type: 0,
  2896. name: "tool hammer",
  2897. desc: "tool for gathering all resources",
  2898. src: "hammer_1",
  2899. length: 140,
  2900. width: 140,
  2901. xOff: -3,
  2902. yOff: 18,
  2903. dmg: 25,
  2904. range: 65,
  2905. gather: 1,
  2906. speed: 300
  2907. }, {
  2908. id: 1,
  2909. type: 0,
  2910. age: 2,
  2911. name: "hand axe",
  2912. desc: "gathers resources at a higher rate",
  2913. src: "axe_1",
  2914. length: 140,
  2915. width: 140,
  2916. xOff: 3,
  2917. yOff: 24,
  2918. dmg: 30,
  2919. spdMult: 1,
  2920. range: 70,
  2921. gather: 2,
  2922. speed: 400
  2923. }, {
  2924. id: 2,
  2925. type: 0,
  2926. age: 8,
  2927. pre: 1,
  2928. name: "great axe",
  2929. desc: "deal more damage and gather more resources",
  2930. src: "great_axe_1",
  2931. length: 140,
  2932. width: 140,
  2933. xOff: -8,
  2934. yOff: 25,
  2935. dmg: 35,
  2936. spdMult: 1,
  2937. range: 75,
  2938. gather: 4,
  2939. speed: 400
  2940. }, {
  2941. id: 3,
  2942. type: 0,
  2943. age: 2,
  2944. name: "short sword",
  2945. desc: "increased attack power but slower move speed",
  2946. src: "sword_1",
  2947. iPad: 1.3,
  2948. length: 130,
  2949. width: 210,
  2950. xOff: -8,
  2951. yOff: 46,
  2952. dmg: 35,
  2953. spdMult: 0.85,
  2954. range: 110,
  2955. gather: 1,
  2956. speed: 300
  2957. }, {
  2958. id: 4,
  2959. type: 0,
  2960. age: 8,
  2961. pre: 3,
  2962. name: "katana",
  2963. desc: "greater range and damage",
  2964. src: "samurai_1",
  2965. iPad: 1.3,
  2966. length: 130,
  2967. width: 210,
  2968. xOff: -8,
  2969. yOff: 59,
  2970. dmg: 40,
  2971. spdMult: 0.8,
  2972. range: 118,
  2973. gather: 1,
  2974. speed: 300
  2975. }, {
  2976. id: 5,
  2977. type: 0,
  2978. age: 2,
  2979. name: "polearm",
  2980. desc: "long range melee weapon",
  2981. src: "spear_1",
  2982. iPad: 1.3,
  2983. length: 130,
  2984. width: 210,
  2985. xOff: -8,
  2986. yOff: 53,
  2987. dmg: 45,
  2988. knock: 0.2,
  2989. spdMult: 0.82,
  2990. range: 142,
  2991. gather: 1,
  2992. speed: 700
  2993. }, {
  2994. id: 6,
  2995. type: 0,
  2996. age: 2,
  2997. name: "bat",
  2998. desc: "fast long range melee weapon",
  2999. src: "bat_1",
  3000. iPad: 1.3,
  3001. length: 110,
  3002. width: 180,
  3003. xOff: -8,
  3004. yOff: 53,
  3005. dmg: 20,
  3006. knock: 0.7,
  3007. range: 110,
  3008. gather: 1,
  3009. speed: 300
  3010. }, {
  3011. id: 7,
  3012. type: 0,
  3013. age: 2,
  3014. name: "daggers",
  3015. desc: "really fast short range weapon",
  3016. src: "dagger_1",
  3017. iPad: 0.8,
  3018. length: 110,
  3019. width: 110,
  3020. xOff: 18,
  3021. yOff: 0,
  3022. dmg: 20,
  3023. knock: 0.1,
  3024. range: 65,
  3025. gather: 1,
  3026. hitSlow: 0.1,
  3027. spdMult: 1.13,
  3028. speed: 100
  3029. }, {
  3030. id: 8,
  3031. type: 0,
  3032. age: 2,
  3033. name: "stick",
  3034. desc: "great for gathering but very weak",
  3035. src: "stick_1",
  3036. length: 140,
  3037. width: 140,
  3038. xOff: 3,
  3039. yOff: 24,
  3040. dmg: 1,
  3041. spdMult: 1,
  3042. range: 70,
  3043. gather: 7,
  3044. speed: 400
  3045. }, {
  3046. id: 9,
  3047. type: 1,
  3048. age: 6,
  3049. name: "hunting bow",
  3050. desc: "bow used for ranged combat and hunting",
  3051. src: "bow_1",
  3052. req: ["wood", 4],
  3053. length: 120,
  3054. width: 120,
  3055. xOff: -6,
  3056. yOff: 0,
  3057. Pdmg: 25,
  3058. projectile: 0,
  3059. spdMult: 0.75,
  3060. speed: 600
  3061. }, {
  3062. id: 10,
  3063. type: 1,
  3064. age: 6,
  3065. name: "great hammer",
  3066. desc: "hammer used for destroying structures",
  3067. src: "great_hammer_1",
  3068. length: 140,
  3069. width: 140,
  3070. xOff: -9,
  3071. yOff: 25,
  3072. dmg: 10,
  3073. Pdmg: 10,
  3074. spdMult: 0.88,
  3075. range: 75,
  3076. sDmg: 7.5,
  3077. gather: 1,
  3078. speed: 400
  3079. }, {
  3080. id: 11,
  3081. type: 1,
  3082. age: 6,
  3083. name: "wooden shield",
  3084. desc: "blocks projectiles and reduces melee damage",
  3085. src: "shield_1",
  3086. length: 120,
  3087. width: 120,
  3088. shield: 0.2,
  3089. xOff: 6,
  3090. yOff: 0,
  3091. Pdmg: 0,
  3092. spdMult: 0.7
  3093. }, {
  3094. id: 12,
  3095. type: 1,
  3096. age: 8,
  3097. pre: 9,
  3098. name: "crossbow",
  3099. desc: "deals more damage and has greater range",
  3100. src: "crossbow_1",
  3101. req: ["wood", 5],
  3102. aboveHand: true,
  3103. armS: 0.75,
  3104. length: 120,
  3105. width: 120,
  3106. xOff: -4,
  3107. yOff: 0,
  3108. Pdmg: 35,
  3109. projectile: 2,
  3110. spdMult: 0.7,
  3111. speed: 700
  3112. }, {
  3113. id: 13,
  3114. type: 1,
  3115. age: 9,
  3116. pre: 12,
  3117. name: "repeater crossbow",
  3118. desc: "high firerate crossbow with reduced damage",
  3119. src: "crossbow_2",
  3120. req: ["wood", 10],
  3121. aboveHand: true,
  3122. armS: 0.75,
  3123. length: 120,
  3124. width: 120,
  3125. xOff: -4,
  3126. yOff: 0,
  3127. Pdmg: 30,
  3128. projectile: 3,
  3129. spdMult: 0.7,
  3130. speed: 230
  3131. }, {
  3132. id: 14,
  3133. type: 1,
  3134. age: 6,
  3135. name: "mc grabby",
  3136. desc: "steals resources from enemies",
  3137. src: "grab_1",
  3138. length: 130,
  3139. width: 210,
  3140. xOff: -8,
  3141. yOff: 53,
  3142. dmg: 0,
  3143. Pdmg: 0,
  3144. steal: 250,
  3145. knock: 0.2,
  3146. spdMult: 1.05,
  3147. range: 125,
  3148. gather: 0,
  3149. speed: 700
  3150. }, {
  3151. id: 15,
  3152. type: 1,
  3153. age: 9,
  3154. pre: 12,
  3155. name: "musket",
  3156. desc: "slow firerate but high damage and range",
  3157. src: "musket_1",
  3158. req: ["stone", 10],
  3159. aboveHand: true,
  3160. rec: 0.35,
  3161. armS: 0.6,
  3162. hndS: 0.3,
  3163. hndD: 1.6,
  3164. length: 205,
  3165. width: 205,
  3166. xOff: 25,
  3167. yOff: 0,
  3168. Pdmg: 50,
  3169. projectile: 5,
  3170. hideProjectile: true,
  3171. spdMult: 0.6,
  3172. speed: 1500
  3173. }];
  3174.  
  3175. // ITEMS:
  3176. this.list = [{
  3177. group: this.groups[0],
  3178. name: "apple",
  3179. desc: "restores 20 health when consumed",
  3180. req: ["food", 10],
  3181. consume: function(doer) {
  3182. return doer.changeHealth(20, doer);
  3183. },
  3184. scale: 22,
  3185. holdOffset: 15,
  3186. healing: 20,
  3187. itemID: 0,
  3188. itemAID: 16,
  3189. }, {
  3190. age: 3,
  3191. group: this.groups[0],
  3192. name: "cookie",
  3193. desc: "restores 40 health when consumed",
  3194. req: ["food", 15],
  3195. consume: function(doer) {
  3196. return doer.changeHealth(40, doer);
  3197. },
  3198. scale: 27,
  3199. holdOffset: 15,
  3200. healing: 40,
  3201. itemID: 1,
  3202. itemAID: 17,
  3203. }, {
  3204. age: 7,
  3205. group: this.groups[0],
  3206. name: "cheese",
  3207. desc: "restores 30 health and another 50 over 5 seconds",
  3208. req: ["food", 25],
  3209. consume: function(doer) {
  3210. if (doer.changeHealth(30, doer) || doer.health < 100) {
  3211. doer.dmgOverTime.dmg = -10;
  3212. doer.dmgOverTime.doer = doer;
  3213. doer.dmgOverTime.time = 5;
  3214. return true;
  3215. }
  3216. return false;
  3217. },
  3218. scale: 27,
  3219. holdOffset: 15,
  3220. healing: 30,
  3221. itemID: 2,
  3222. itemAID: 18,
  3223. }, {
  3224. group: this.groups[1],
  3225. name: "wood wall",
  3226. desc: "provides protection for your village",
  3227. req: ["wood", 10],
  3228. projDmg: true,
  3229. health: 380,
  3230. scale: 50,
  3231. holdOffset: 20,
  3232. placeOffset: -5,
  3233. itemID: 3,
  3234. itemAID: 19,
  3235. }, {
  3236. age: 3,
  3237. group: this.groups[1],
  3238. name: "stone wall",
  3239. desc: "provides improved protection for your village",
  3240. req: ["stone", 25],
  3241. health: 900,
  3242. scale: 50,
  3243. holdOffset: 20,
  3244. placeOffset: -5,
  3245. itemID: 4,
  3246. itemAID: 20,
  3247. }, {
  3248. age: 7,
  3249. group: this.groups[1],
  3250. name: "castle wall",
  3251. desc: "provides powerful protection for your village",
  3252. req: ["stone", 35],
  3253. health: 1500,
  3254. scale: 52,
  3255. holdOffset: 20,
  3256. placeOffset: -5,
  3257. itemID: 5,
  3258. itemAID: 21,
  3259. }, {
  3260. group: this.groups[2],
  3261. name: "spikes",
  3262. desc: "damages enemies when they touch them",
  3263. req: ["wood", 20, "stone", 5],
  3264. health: 400,
  3265. dmg: 20,
  3266. scale: 49,
  3267. spritePadding: -23,
  3268. holdOffset: 8,
  3269. placeOffset: -5,
  3270. itemID: 6,
  3271. itemAID: 22,
  3272. shadow: {
  3273. offsetX: 5, // Adjust the shadow's X offset as needed
  3274. offsetY: 5, // Adjust the shadow's Y offset as needed
  3275. blur: 20, // Adjust the shadow's blur as needed
  3276. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  3277. }
  3278.  
  3279. }, {
  3280. age: 5,
  3281. group: this.groups[2],
  3282. name: "greater spikes",
  3283. desc: "damages enemies when they touch them",
  3284. req: ["wood", 30, "stone", 10],
  3285. health: 500,
  3286. dmg: 35,
  3287. scale: 52,
  3288. spritePadding: -23,
  3289. holdOffset: 8,
  3290. placeOffset: -5,
  3291. itemID: 7,
  3292. itemAID: 23,
  3293. }, {
  3294. age: 9,
  3295. group: this.groups[2],
  3296. name: "poison spikes",
  3297. desc: "poisons enemies when they touch them",
  3298. req: ["wood", 35, "stone", 15],
  3299. health: 600,
  3300. dmg: 30,
  3301. pDmg: 5,
  3302. scale: 52,
  3303. spritePadding: -23,
  3304. holdOffset: 8,
  3305. placeOffset: -5,
  3306. itemID: 8,
  3307. itemAID: 24,
  3308. }, {
  3309. age: 9,
  3310. group: this.groups[2],
  3311. name: "spinning spikes",
  3312. desc: "damages enemies when they touch them",
  3313. req: ["wood", 30, "stone", 20],
  3314. health: 500,
  3315. dmg: 45,
  3316. turnSpeed: 0.003,
  3317. scale: 52,
  3318. spritePadding: -23,
  3319. holdOffset: 8,
  3320. placeOffset: -5,
  3321. itemID: 9,
  3322. itemAID: 25,
  3323. }, {
  3324. group: this.groups[3],
  3325. name: "windmill",
  3326. desc: "generates gold over time",
  3327. req: ["wood", 50, "stone", 10],
  3328. health: 400,
  3329. pps: 1,
  3330. turnSpeed: 0.0016,
  3331. spritePadding: 25,
  3332. iconLineMult: 12,
  3333. scale: 45,
  3334. holdOffset: 20,
  3335. placeOffset: 5,
  3336. itemID: 10,
  3337. itemAID: 26,
  3338. }, {
  3339. age: 5,
  3340. group: this.groups[3],
  3341. name: "faster windmill",
  3342. desc: "generates more gold over time",
  3343. req: ["wood", 60, "stone", 20],
  3344. health: 500,
  3345. pps: 1.5,
  3346. turnSpeed: 0.0025,
  3347. spritePadding: 25,
  3348. iconLineMult: 12,
  3349. scale: 47,
  3350. holdOffset: 20,
  3351. placeOffset: 5,
  3352. itemID: 11,
  3353. itemAID: 27,
  3354. }, {
  3355. age: 8,
  3356. group: this.groups[3],
  3357. name: "power mill",
  3358. desc: "generates more gold over time",
  3359. req: ["wood", 100, "stone", 50],
  3360. health: 800,
  3361. pps: 2,
  3362. turnSpeed: 0.005,
  3363. spritePadding: 25,
  3364. iconLineMult: 12,
  3365. scale: 47,
  3366. holdOffset: 20,
  3367. placeOffset: 5,
  3368. itemID: 12,
  3369. itemAID: 28,
  3370. }, {
  3371. age: 5,
  3372. group: this.groups[4],
  3373. type: 2,
  3374. name: "mine",
  3375. desc: "allows you to mine stone",
  3376. req: ["wood", 20, "stone", 100],
  3377. iconLineMult: 12,
  3378. scale: 65,
  3379. holdOffset: 20,
  3380. placeOffset: 0,
  3381. itemID: 13,
  3382. itemAID: 29,
  3383. }, {
  3384. age: 5,
  3385. group: this.groups[11],
  3386. type: 0,
  3387. name: "sapling",
  3388. desc: "allows you to farm wood",
  3389. req: ["wood", 150],
  3390. iconLineMult: 12,
  3391. colDiv: 0.5,
  3392. scale: 110,
  3393. holdOffset: 50,
  3394. placeOffset: -15,
  3395. itemID: 14,
  3396. itemAID: 30,
  3397. }, {
  3398. age: 4,
  3399. group: this.groups[5],
  3400. name: "pit trap",
  3401. desc: "pit that traps enemies if they walk over it",
  3402. req: ["wood", 30, "stone", 30],
  3403. trap: true,
  3404. ignoreCollision: true,
  3405. hideFromEnemy: true,
  3406. health: 500,
  3407. colDiv: 0.2,
  3408. scale: 50,
  3409. holdOffset: 20,
  3410. placeOffset: -5,
  3411. alpha: 0.6,
  3412. itemID: 15,
  3413. itemAID: 31,
  3414. }, {
  3415. age: 4,
  3416. group: this.groups[6],
  3417. name: "boost pad",
  3418. desc: "provides boost when stepped on",
  3419. req: ["stone", 20, "wood", 5],
  3420. ignoreCollision: true,
  3421. boostSpeed: 1.5,
  3422. health: 150,
  3423. colDiv: 0.7,
  3424. scale: 45,
  3425. holdOffset: 20,
  3426. placeOffset: -5,
  3427. itemID: 16,
  3428. itemAID: 32,
  3429. }, {
  3430. age: 7,
  3431. group: this.groups[7],
  3432. doUpdate: true,
  3433. name: "turret",
  3434. desc: "defensive structure that shoots at enemies",
  3435. req: ["wood", 200, "stone", 150],
  3436. health: 800,
  3437. projectile: 1,
  3438. shootRange: 700,
  3439. shootRate: 2200,
  3440. scale: 43,
  3441. holdOffset: 20,
  3442. placeOffset: -5,
  3443. itemID: 17,
  3444. itemAID: 33,
  3445. }, {
  3446. age: 7,
  3447. group: this.groups[8],
  3448. name: "platform",
  3449. desc: "platform to shoot over walls and cross over water",
  3450. req: ["wood", 20],
  3451. ignoreCollision: true,
  3452. zIndex: 1,
  3453. health: 300,
  3454. scale: 43,
  3455. holdOffset: 20,
  3456. placeOffset: -5,
  3457. itemID: 18,
  3458. itemAID: 34,
  3459. }, {
  3460. age: 7,
  3461. group: this.groups[9],
  3462. name: "healing pad",
  3463. desc: "standing on it will slowly heal you",
  3464. req: ["wood", 30, "food", 10],
  3465. ignoreCollision: true,
  3466. healCol: 15,
  3467. health: 400,
  3468. colDiv: 0.7,
  3469. scale: 45,
  3470. holdOffset: 20,
  3471. placeOffset: -5,
  3472. itemID: 19,
  3473. itemAID: 35,
  3474. }, {
  3475. age: 9,
  3476. group: this.groups[10],
  3477. name: "spawn pad",
  3478. desc: "you will spawn here when you die but it will dissapear",
  3479. req: ["wood", 100, "stone", 100],
  3480. health: 400,
  3481. ignoreCollision: true,
  3482. spawnPoint: true,
  3483. scale: 45,
  3484. holdOffset: 20,
  3485. placeOffset: -5,
  3486. itemID: 20,
  3487. itemAID: 36,
  3488. }, {
  3489. age: 7,
  3490. group: this.groups[12],
  3491. name: "blocker",
  3492. desc: "blocks building in radius",
  3493. req: ["wood", 30, "stone", 25],
  3494. ignoreCollision: true,
  3495. blocker: 300,
  3496. health: 400,
  3497. colDiv: 0.7,
  3498. scale: 45,
  3499. holdOffset: 20,
  3500. placeOffset: -5,
  3501. itemID: 21,
  3502. itemAID: 37,
  3503. }, {
  3504. age: 7,
  3505. group: this.groups[13],
  3506. name: "teleporter",
  3507. desc: "teleports you to a random point on the map",
  3508. req: ["wood", 60, "stone", 60],
  3509. ignoreCollision: true,
  3510. teleport: true,
  3511. health: 200,
  3512. colDiv: 0.7,
  3513. scale: 45,
  3514. holdOffset: 20,
  3515. placeOffset: -5,
  3516. itemID: 22,
  3517. itemAID: 38
  3518. }];
  3519.  
  3520. // CHECK ITEM ID:
  3521. this.checkItem = {
  3522. index: function(id, myItems) {
  3523. return [0, 1, 2].includes(id) ? 0 : [3, 4, 5].includes(id) ? 1 : [6, 7, 8, 9].includes(id) ? 2 : [10, 11, 12].includes(id) ? 3 : [13, 14].includes(id) ? 5 : [15, 16].includes(id) ? 4 : [17, 18, 19, 21, 22].includes(id) ? [13, 14].includes(myItems) ? 6 :
  3524. 5 :
  3525. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3526. 6 :
  3527. undefined;
  3528. }
  3529. }
  3530.  
  3531. // ASSIGN IDS:
  3532. for (let i = 0; i < this.list.length; ++i) {
  3533. this.list[i].id = i;
  3534. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3535. }
  3536.  
  3537. // TROLOLOLOL:
  3538. if (typeof window !== "undefined") {
  3539. function shuffle(a) {
  3540. for (let i = a.length - 1; i > 0; i--) {
  3541. const j = Math.floor(Math.random() * (i + 1));
  3542. [a[i], a[j]] = [a[j], a[i]];
  3543. }
  3544. return a;
  3545. }
  3546. //shuffle(this.list);
  3547. }
  3548. }
  3549. }
  3550. class Objectmanager {
  3551. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3552. let mathFloor = Math.floor,
  3553. mathABS = Math.abs,
  3554. mathCOS = Math.cos,
  3555. mathSIN = Math.sin,
  3556. mathPOW = Math.pow,
  3557. mathSQRT = Math.sqrt;
  3558.  
  3559. this.ignoreAdd = false;
  3560. this.hitObj = [];
  3561.  
  3562. // DISABLE OBJ:
  3563. this.disableObj = function(obj) {
  3564. obj.active = false;
  3565. };
  3566.  
  3567. // ADD NEW:
  3568. let tmpObj;
  3569. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3570. tmpObj = findObjectBySid(sid);
  3571. if (!tmpObj) {
  3572. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3573. if (!tmpObj) {
  3574. tmpObj = new GameObject(sid);
  3575. gameObjects.push(tmpObj);
  3576. }
  3577. }
  3578. if (setSID) {
  3579. tmpObj.sid = sid;
  3580. }
  3581. tmpObj.init(x, y, dir, s, type, data, owner);
  3582. };
  3583.  
  3584. // DISABLE BY SID:
  3585. this.disableBySid = function(sid) {
  3586. let find = findObjectBySid(sid);
  3587. if (find) {
  3588. this.disableObj(find);
  3589. }
  3590. };
  3591.  
  3592. // REMOVE ALL FROM PLAYER:
  3593. this.removeAllItems = function(sid, server) {
  3594. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3595. };
  3596.  
  3597. // CHECK IF PLACABLE:
  3598. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3599. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  3600. if (cantPlace) return false;
  3601. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3602. return true;
  3603. };
  3604.  
  3605. }
  3606. }
  3607. class Projectile {
  3608. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3609.  
  3610. // INIT:
  3611. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3612. this.active = true;
  3613. this.tickActive = true;
  3614. this.indx = indx;
  3615. this.x = x;
  3616. this.y = y;
  3617. this.x2 = x;
  3618. this.y2 = y;
  3619. this.dir = dir;
  3620. this.skipMov = true;
  3621. this.speed = spd;
  3622. this.dmg = dmg;
  3623. this.scale = scl;
  3624. this.range = rng;
  3625. this.r2 = rng;
  3626. this.owner = owner;
  3627. };
  3628.  
  3629. // UPDATE:
  3630. this.update = function(delta) {
  3631. if (this.active) {
  3632. let tmpSpeed = this.speed * delta;
  3633. if (!this.skipMov) {
  3634. this.x += tmpSpeed * Math.cos(this.dir);
  3635. this.y += tmpSpeed * Math.sin(this.dir);
  3636. this.range -= tmpSpeed;
  3637. if (this.range <= 0) {
  3638. this.x += this.range * Math.cos(this.dir);
  3639. this.y += this.range * Math.sin(this.dir);
  3640. tmpSpeed = 1;
  3641. this.range = 0;
  3642. this.active = false;
  3643. }
  3644. } else {
  3645. this.skipMov = false;
  3646. }
  3647. }
  3648. };
  3649. this.tickUpdate = function(delta) {
  3650. if (this.tickActive) {
  3651. let tmpSpeed = this.speed * delta;
  3652. if (!this.skipMov) {
  3653. this.x2 += tmpSpeed * Math.cos(this.dir);
  3654. this.y2 += tmpSpeed * Math.sin(this.dir);
  3655. this.r2 -= tmpSpeed;
  3656. if (this.r2 <= 0) {
  3657. this.x2 += this.r2 * Math.cos(this.dir);
  3658. this.y2 += this.r2 * Math.sin(this.dir);
  3659. tmpSpeed = 1;
  3660. this.r2 = 0;
  3661. this.tickActive = false;
  3662. }
  3663. } else {
  3664. this.skipMov = false;
  3665. }
  3666. }
  3667. };
  3668. }
  3669. };
  3670. class Store {
  3671. constructor() {
  3672. // STORE HATS:
  3673. this.hats = [{
  3674. id: 45,
  3675. name: "Shame!",
  3676. dontSell: true,
  3677. price: 0,
  3678. scale: 120,
  3679. desc: "hacks are for winners"
  3680. }, {
  3681. id: 51,
  3682. name: "Moo Cap",
  3683. price: 0,
  3684. scale: 120,
  3685. desc: "coolest mooer around"
  3686. }, {
  3687. id: 50,
  3688. name: "Apple Cap",
  3689. price: 0,
  3690. scale: 120,
  3691. desc: "apple farms remembers"
  3692. }, {
  3693. id: 28,
  3694. name: "Moo Head",
  3695. price: 0,
  3696. scale: 120,
  3697. desc: "no effect"
  3698. }, {
  3699. id: 29,
  3700. name: "Pig Head",
  3701. price: 0,
  3702. scale: 120,
  3703. desc: "no effect"
  3704. }, {
  3705. id: 30,
  3706. name: "Fluff Head",
  3707. price: 0,
  3708. scale: 120,
  3709. desc: "no effect"
  3710. }, {
  3711. id: 36,
  3712. name: "Pandou Head",
  3713. price: 0,
  3714. scale: 120,
  3715. desc: "no effect"
  3716. }, {
  3717. id: 37,
  3718. name: "Bear Head",
  3719. price: 0,
  3720. scale: 120,
  3721. desc: "no effect"
  3722. }, {
  3723. id: 38,
  3724. name: "Monkey Head",
  3725. price: 0,
  3726. scale: 120,
  3727. desc: "no effect"
  3728. }, {
  3729. id: 44,
  3730. name: "Polar Head",
  3731. price: 0,
  3732. scale: 120,
  3733. desc: "no effect"
  3734. }, {
  3735. id: 35,
  3736. name: "Fez Hat",
  3737. price: 0,
  3738. scale: 120,
  3739. desc: "no effect"
  3740. }, {
  3741. id: 42,
  3742. name: "Enigma Hat",
  3743. price: 0,
  3744. scale: 120,
  3745. desc: "join the enigma army"
  3746. }, {
  3747. id: 43,
  3748. name: "Blitz Hat",
  3749. price: 0,
  3750. scale: 120,
  3751. desc: "hey everybody i'm blitz"
  3752. }, {
  3753. id: 49,
  3754. name: "Bob XIII Hat",
  3755. price: 0,
  3756. scale: 120,
  3757. desc: "like and subscribe"
  3758. }, {
  3759. id: 57,
  3760. name: "Pumpkin",
  3761. price: 50,
  3762. scale: 120,
  3763. desc: "Spooooky"
  3764. }, {
  3765. id: 8,
  3766. name: "Bummle Hat",
  3767. price: 100,
  3768. scale: 120,
  3769. desc: "no effect"
  3770. }, {
  3771. id: 2,
  3772. name: "Straw Hat",
  3773. price: 500,
  3774. scale: 120,
  3775. desc: "no effect"
  3776. }, {
  3777. id: 15,
  3778. name: "Winter Cap",
  3779. price: 600,
  3780. scale: 120,
  3781. desc: "allows you to move at normal speed in snow",
  3782. coldM: 1
  3783. }, {
  3784. id: 5,
  3785. name: "Cowboy Hat",
  3786. price: 1000,
  3787. scale: 120,
  3788. desc: "no effect"
  3789. }, {
  3790. id: 4,
  3791. name: "Ranger Hat",
  3792. price: 2000,
  3793. scale: 120,
  3794. desc: "no effect"
  3795. }, {
  3796. id: 18,
  3797. name: "Explorer Hat",
  3798. price: 2000,
  3799. scale: 120,
  3800. desc: "no effect"
  3801. }, {
  3802. id: 31,
  3803. name: "Flipper Hat",
  3804. price: 2500,
  3805. scale: 120,
  3806. desc: "have more control while in water",
  3807. watrImm: true
  3808. }, {
  3809. id: 1,
  3810. name: "Marksman Cap",
  3811. price: 3000,
  3812. scale: 120,
  3813. desc: "increases arrow speed and range",
  3814. aMlt: 1.3
  3815. }, {
  3816. id: 10,
  3817. name: "Bush Gear",
  3818. price: 3000,
  3819. scale: 160,
  3820. desc: "allows you to disguise yourself as a bush"
  3821. }, {
  3822. id: 48,
  3823. name: "Halo",
  3824. price: 3000,
  3825. scale: 120,
  3826. desc: "no effect"
  3827. }, {
  3828. id: 6,
  3829. name: "Anti Insta",
  3830. price: 4000,
  3831. scale: 120,
  3832. desc: "reduces damage taken but slows movement",
  3833. spdMult: 0.94,
  3834. dmgMult: 0.75
  3835. }, {
  3836. id: 23,
  3837. name: "Anti Venom Gear",
  3838. price: 4000,
  3839. scale: 120,
  3840. desc: "makes you immune to poison",
  3841. poisonRes: 1
  3842. }, {
  3843. id: 13,
  3844. name: "Medic Gear",
  3845. price: 5000,
  3846. scale: 110,
  3847. desc: "slowly regenerates health over time",
  3848. healthRegen: 3
  3849. }, {
  3850. id: 9,
  3851. name: "Miners Helmet",
  3852. price: 5000,
  3853. scale: 120,
  3854. desc: "earn 1 extra gold per resource",
  3855. extraGold: 1
  3856. }, {
  3857. id: 32,
  3858. name: "Musketeer Hat",
  3859. price: 5000,
  3860. scale: 120,
  3861. desc: "reduces cost of projectiles",
  3862. projCost: 0.5
  3863. }, {
  3864. id: 7,
  3865. name: "Bull Helmet",
  3866. price: 6000,
  3867. scale: 120,
  3868. desc: "increases damage done but drains health",
  3869. healthRegen: -5,
  3870. dmgMultO: 1.5,
  3871. spdMult: 0.96
  3872. }, {
  3873. id: 22,
  3874. name: "Emp Helmet",
  3875. price: 6000,
  3876. scale: 120,
  3877. desc: "turrets won't attack but you move slower",
  3878. antiTurret: 1,
  3879. spdMult: 0.7
  3880. }, {
  3881. id: 12,
  3882. name: "Booster Hat",
  3883. price: 6000,
  3884. scale: 120,
  3885. desc: "increases your movement speed",
  3886. spdMult: 1.16
  3887. }, {
  3888. id: 26,
  3889. name: "Barbarian Armor",
  3890. price: 8000,
  3891. scale: 120,
  3892. desc: "knocks back enemies that attack you",
  3893. dmgK: 0.6
  3894. }, {
  3895. id: 21,
  3896. name: "Plague Mask",
  3897. price: 10000,
  3898. scale: 120,
  3899. desc: "melee attacks deal poison damage",
  3900. poisonDmg: 5,
  3901. poisonTime: 6
  3902. }, {
  3903. id: 46,
  3904. name: "Bull Mask",
  3905. price: 10000,
  3906. scale: 120,
  3907. desc: "bulls won't target you unless you attack them",
  3908. bullRepel: 1
  3909. }, {
  3910. id: 14,
  3911. name: "Windmill Hat",
  3912. topSprite: true,
  3913. price: 10000,
  3914. scale: 120,
  3915. desc: "generates points while worn",
  3916. pps: 1.5
  3917. }, {
  3918. id: 11,
  3919. name: "Spike Gear",
  3920. topSprite: true,
  3921. price: 10000,
  3922. scale: 120,
  3923. desc: "deal damage to players that damage you",
  3924. dmg: 0.45
  3925. }, {
  3926. id: 53,
  3927. name: "Turret Gear",
  3928. topSprite: true,
  3929. price: 10000,
  3930. scale: 120,
  3931. desc: "you become a walking turret",
  3932. turret: {
  3933. proj: 1,
  3934. range: 700,
  3935. rate: 2500
  3936. },
  3937. spdMult: 0.7
  3938. }, {
  3939. id: 20,
  3940. name: "Samurai Armor",
  3941. price: 12000,
  3942. scale: 120,
  3943. desc: "increased attack speed and fire rate",
  3944. atkSpd: 0.78
  3945. }, {
  3946. id: 58,
  3947. name: "Dark Knight",
  3948. price: 12000,
  3949. scale: 120,
  3950. desc: "restores health when you deal damage",
  3951. healD: 0.4
  3952. }, {
  3953. id: 27,
  3954. name: "Scavenger Gear",
  3955. price: 15000,
  3956. scale: 120,
  3957. desc: "earn double points for each kill",
  3958. kScrM: 2
  3959. }, {
  3960. id: 40,
  3961. name: "Tank Gear",
  3962. price: 15000,
  3963. scale: 120,
  3964. desc: "increased damage to buildings but slower movement",
  3965. spdMult: 0.3,
  3966. bDmg: 3.3
  3967. }, {
  3968. id: 52,
  3969. name: "Thief Gear",
  3970. price: 15000,
  3971. scale: 120,
  3972. desc: "steal half of a players gold when you kill them",
  3973. goldSteal: 0.5
  3974. }, {
  3975. id: 55,
  3976. name: "Bloodthirster",
  3977. price: 20000,
  3978. scale: 120,
  3979. desc: "Restore Health when dealing damage. And increased damage",
  3980. healD: 0.25,
  3981. dmgMultO: 1.2,
  3982. }, {
  3983. id: 56,
  3984. name: "Assassin Gear",
  3985. price: 20000,
  3986. scale: 120,
  3987. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3988. noEat: true,
  3989. spdMult: 1.1,
  3990. invisTimer: 1000
  3991. }];
  3992.  
  3993. // STORE ACCESSORIES:
  3994. this.accessories = [{
  3995. id: 12,
  3996. name: "Snowball",
  3997. price: 1000,
  3998. scale: 105,
  3999. xOff: 18,
  4000. desc: "no effect"
  4001. }, {
  4002. id: 9,
  4003. name: "Tree Cape",
  4004. price: 1000,
  4005. scale: 90,
  4006. desc: "no effect"
  4007. }, {
  4008. id: 10,
  4009. name: "Stone Cape",
  4010. price: 1000,
  4011. scale: 90,
  4012. desc: "no effect"
  4013. }, {
  4014. id: 3,
  4015. name: "Cookie Cape",
  4016. price: 1500,
  4017. scale: 90,
  4018. desc: "no effect"
  4019. }, {
  4020. id: 8,
  4021. name: "Cow Cape",
  4022. price: 2000,
  4023. scale: 90,
  4024. desc: "no effect"
  4025. }, {
  4026. id: 11,
  4027. name: "Monkey Tail",
  4028. price: 2000,
  4029. scale: 97,
  4030. xOff: 25,
  4031. desc: "Super speed but reduced damage",
  4032. spdMult: 1.35,
  4033. dmgMultO: 0.2
  4034. }, {
  4035. id: 17,
  4036. name: "Apple Basket",
  4037. price: 3000,
  4038. scale: 80,
  4039. xOff: 12,
  4040. desc: "slowly regenerates health over time",
  4041. healthRegen: 1
  4042. }, {
  4043. id: 6,
  4044. name: "Winter Cape",
  4045. price: 3000,
  4046. scale: 90,
  4047. desc: "no effect"
  4048. }, {
  4049. id: 4,
  4050. name: "Skull Cape",
  4051. price: 4000,
  4052. scale: 90,
  4053. desc: "no effect"
  4054. }, {
  4055. id: 5,
  4056. name: "Dash Cape",
  4057. price: 5000,
  4058. scale: 90,
  4059. desc: "no effect"
  4060. }, {
  4061. id: 2,
  4062. name: "Dragon Cape",
  4063. price: 6000,
  4064. scale: 90,
  4065. desc: "no effect"
  4066. }, {
  4067. id: 1,
  4068. name: "Super Cape",
  4069. price: 8000,
  4070. scale: 90,
  4071. desc: "no effect"
  4072. }, {
  4073. id: 7,
  4074. name: "Troll Cape",
  4075. price: 8000,
  4076. scale: 90,
  4077. desc: "no effect"
  4078. }, {
  4079. id: 14,
  4080. name: "Thorns",
  4081. price: 10000,
  4082. scale: 115,
  4083. xOff: 20,
  4084. desc: "no effect"
  4085. }, {
  4086. id: 15,
  4087. name: "Blockades",
  4088. price: 10000,
  4089. scale: 95,
  4090. xOff: 15,
  4091. desc: "no effect"
  4092. }, {
  4093. id: 20,
  4094. name: "Devils Tail",
  4095. price: 10000,
  4096. scale: 95,
  4097. xOff: 20,
  4098. desc: "no effect"
  4099. }, {
  4100. id: 16,
  4101. name: "Sawblade",
  4102. price: 12000,
  4103. scale: 90,
  4104. spin: true,
  4105. xOff: 0,
  4106. desc: "deal damage to players that damage you",
  4107. dmg: 0.15
  4108. }, {
  4109. id: 13,
  4110. name: "Angel Wings",
  4111. price: 15000,
  4112. scale: 138,
  4113. xOff: 22,
  4114. desc: "slowly regenerates health over time",
  4115. healthRegen: 3
  4116. }, {
  4117. id: 19,
  4118. name: "Shadow Wings",
  4119. price: 15000,
  4120. scale: 138,
  4121. xOff: 22,
  4122. desc: "increased movement speed",
  4123. spdMult: 1.1
  4124. }, {
  4125. id: 18,
  4126. name: "Blood Wings",
  4127. price: 20000,
  4128. scale: 178,
  4129. xOff: 26,
  4130. desc: "restores health when you deal damage",
  4131. healD: 0.2
  4132. }, {
  4133. id: 21,
  4134. name: "Corrupt X Wings",
  4135. price: 20000,
  4136. scale: 178,
  4137. xOff: 26,
  4138. desc: "deal damage to players that damage you",
  4139. dmg: 0.25
  4140. }];
  4141. }
  4142. };
  4143. class ProjectileManager {
  4144. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  4145. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  4146. let tmpData = items.projectiles[indx];
  4147. let tmpProj;
  4148. for (let i = 0; i < projectiles.length; ++i) {
  4149. if (!projectiles[i].active) {
  4150. tmpProj = projectiles[i];
  4151. break;
  4152. }
  4153. }
  4154. if (!tmpProj) {
  4155. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  4156. tmpProj.sid = projectiles.length;
  4157. projectiles.push(tmpProj);
  4158. }
  4159. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  4160. tmpProj.ignoreObj = ignoreObj;
  4161. tmpProj.layer = layer || tmpData.layer;
  4162. tmpProj.inWindow = inWindow;
  4163. tmpProj.src = tmpData.src;
  4164. return tmpProj;
  4165. };
  4166. }
  4167. };
  4168. class AiManager {
  4169.  
  4170. // AI MANAGER:
  4171. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  4172.  
  4173. // AI TYPES:
  4174. this.aiTypes = [{
  4175. id: 0,
  4176. src: "cow_1",
  4177. killScore: 150,
  4178. health: 500,
  4179. weightM: 0.8,
  4180. speed: 0.00095,
  4181. turnSpeed: 0.001,
  4182. scale: 72,
  4183. drop: ["food", 50]
  4184. }, {
  4185. id: 1,
  4186. src: "pig_1",
  4187. killScore: 200,
  4188. health: 800,
  4189. weightM: 0.6,
  4190. speed: 0.00085,
  4191. turnSpeed: 0.001,
  4192. scale: 72,
  4193. drop: ["food", 80]
  4194. }, {
  4195. id: 2,
  4196. name: "Bull",
  4197. src: "bull_2",
  4198. hostile: true,
  4199. dmg: 20,
  4200. killScore: 1000,
  4201. health: 1800,
  4202. weightM: 0.5,
  4203. speed: 0.00094,
  4204. turnSpeed: 0.00074,
  4205. scale: 78,
  4206. viewRange: 800,
  4207. chargePlayer: true,
  4208. drop: ["food", 100]
  4209. }, {
  4210. id: 3,
  4211. name: "Bully",
  4212. src: "bull_1",
  4213. hostile: true,
  4214. dmg: 20,
  4215. killScore: 2000,
  4216. health: 2800,
  4217. weightM: 0.45,
  4218. speed: 0.001,
  4219. turnSpeed: 0.0008,
  4220. scale: 90,
  4221. viewRange: 900,
  4222. chargePlayer: true,
  4223. drop: ["food", 400]
  4224. }, {
  4225. id: 4,
  4226. name: "Wolf",
  4227. src: "wolf_1",
  4228. hostile: true,
  4229. dmg: 8,
  4230. killScore: 500,
  4231. health: 300,
  4232. weightM: 0.45,
  4233. speed: 0.001,
  4234. turnSpeed: 0.002,
  4235. scale: 84,
  4236. viewRange: 800,
  4237. chargePlayer: true,
  4238. drop: ["food", 200]
  4239. }, {
  4240. id: 5,
  4241. name: "Quack",
  4242. src: "chicken_1",
  4243. dmg: 8,
  4244. killScore: 2000,
  4245. noTrap: true,
  4246. health: 300,
  4247. weightM: 0.2,
  4248. speed: 0.0018,
  4249. turnSpeed: 0.006,
  4250. scale: 70,
  4251. drop: ["food", 100]
  4252. }, {
  4253. id: 6,
  4254. name: "MOOSTAFA",
  4255. nameScale: 50,
  4256. src: "enemy",
  4257. hostile: true,
  4258. dontRun: true,
  4259. fixedSpawn: true,
  4260. spawnDelay: 60000,
  4261. noTrap: true,
  4262. colDmg: 100,
  4263. dmg: 40,
  4264. killScore: 8000,
  4265. health: 18000,
  4266. weightM: 0.4,
  4267. speed: 0.0007,
  4268. turnSpeed: 0.01,
  4269. scale: 80,
  4270. spriteMlt: 1.8,
  4271. leapForce: 0.9,
  4272. viewRange: 1000,
  4273. hitRange: 210,
  4274. hitDelay: 1000,
  4275. chargePlayer: true,
  4276. drop: ["food", 100]
  4277. }, {
  4278. id: 7,
  4279. name: "Treasure",
  4280. hostile: true,
  4281. nameScale: 35,
  4282. src: "crate_1",
  4283. fixedSpawn: true,
  4284. spawnDelay: 120000,
  4285. colDmg: 200,
  4286. killScore: 5000,
  4287. health: 20000,
  4288. weightM: 0.1,
  4289. speed: 0.0,
  4290. turnSpeed: 0.0,
  4291. scale: 70,
  4292. spriteMlt: 1.0
  4293. }, {
  4294. id: 8,
  4295. name: "MOOFIE",
  4296. src: "wolf_2",
  4297. hostile: true,
  4298. fixedSpawn: true,
  4299. dontRun: true,
  4300. hitScare: 4,
  4301. spawnDelay: 30000,
  4302. noTrap: true,
  4303. nameScale: 35,
  4304. dmg: 10,
  4305. colDmg: 100,
  4306. killScore: 3000,
  4307. health: 7000,
  4308. weightM: 0.45,
  4309. speed: 0.0015,
  4310. turnSpeed: 0.002,
  4311. scale: 90,
  4312. viewRange: 800,
  4313. chargePlayer: true,
  4314. drop: ["food", 1000]
  4315. }];
  4316.  
  4317. // SPAWN AI:
  4318. this.spawn = function(x, y, dir, index) {
  4319. let tmpObj = ais.find((tmp) => !tmp.active);
  4320. if (!tmpObj) {
  4321. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  4322. ais.push(tmpObj);
  4323. }
  4324. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  4325. return tmpObj;
  4326. };
  4327. }
  4328.  
  4329. };
  4330. class AI {
  4331. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  4332. this.sid = sid;
  4333. this.isAI = true;
  4334. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  4335.  
  4336. // INIT:
  4337. this.init = function(x, y, dir, index, data) {
  4338. this.x = x;
  4339. this.y = y;
  4340. this.startX = data.fixedSpawn ? x : null;
  4341. this.startY = data.fixedSpawn ? y : null;
  4342. this.xVel = 0;
  4343. this.yVel = 0;
  4344. this.zIndex = 0;
  4345. this.dir = dir;
  4346. this.dirPlus = 0;
  4347. this.showName = 'aaa';
  4348. this.index = index;
  4349. this.src = data.src;
  4350. if (data.name) this.name = data.name;
  4351. this.weightM = data.weightM;
  4352. this.speed = data.speed;
  4353. this.killScore = data.killScore;
  4354. this.turnSpeed = data.turnSpeed;
  4355. this.scale = data.scale;
  4356. this.maxHealth = data.health;
  4357. this.leapForce = data.leapForce;
  4358. this.health = this.maxHealth;
  4359. this.chargePlayer = data.chargePlayer;
  4360. this.viewRange = data.viewRange;
  4361. this.drop = data.drop;
  4362. this.dmg = data.dmg;
  4363. this.hostile = data.hostile;
  4364. this.dontRun = data.dontRun;
  4365. this.hitRange = data.hitRange;
  4366. this.hitDelay = data.hitDelay;
  4367. this.hitScare = data.hitScare;
  4368. this.spriteMlt = data.spriteMlt;
  4369. this.nameScale = data.nameScale;
  4370. this.colDmg = data.colDmg;
  4371. this.noTrap = data.noTrap;
  4372. this.spawnDelay = data.spawnDelay;
  4373. this.hitWait = 0;
  4374. this.waitCount = 1000;
  4375. this.moveCount = 0;
  4376. this.targetDir = 0;
  4377. this.active = true;
  4378. this.alive = true;
  4379. this.runFrom = null;
  4380. this.chargeTarget = null;
  4381. this.dmgOverTime = {};
  4382. };
  4383.  
  4384. let tmpRatio = 0;
  4385. let animIndex = 0;
  4386. this.animate = function(delta) {
  4387. if (this.animTime > 0) {
  4388. this.animTime -= delta;
  4389. if (this.animTime <= 0) {
  4390. this.animTime = 0;
  4391. this.dirPlus = 0;
  4392. tmpRatio = 0;
  4393. animIndex = 0;
  4394. } else {
  4395. if (animIndex == 0) {
  4396. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4397. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4398. if (tmpRatio >= 1) {
  4399. tmpRatio = 1;
  4400. animIndex = 1;
  4401. }
  4402. } else {
  4403. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4404. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4405. }
  4406. }
  4407. }
  4408. };
  4409.  
  4410. // ANIMATION:
  4411. this.startAnim = function() {
  4412. this.animTime = this.animSpeed = 600;
  4413. this.targetAngle = Math.PI * 0.8;
  4414. tmpRatio = 0;
  4415. animIndex = 0;
  4416. };
  4417.  
  4418. };
  4419.  
  4420. };
  4421. class addCh {
  4422. constructor(x, y, chat, tmpObj) {
  4423. this.x = x;
  4424. this.y = y;
  4425. this.alpha = 0;
  4426. this.active = true;
  4427. this.alive = false;
  4428. this.chat = chat;
  4429. this.owner = tmpObj;
  4430. };
  4431. };
  4432. class DeadPlayer {
  4433. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4434. this.x = x;
  4435. this.y = y;
  4436. this.lastDir = dir;
  4437. this.dir = dir + Math.PI;
  4438. this.buildIndex = buildIndex;
  4439. this.weaponIndex = weaponIndex;
  4440. this.weaponVariant = weaponVariant;
  4441. this.skinColor = skinColor;
  4442. this.scale = scale;
  4443. this.visScale = 0;
  4444. this.name = name;
  4445. this.alpha = 1;
  4446. this.active = true;
  4447. this.animate = function(delta) {
  4448. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4449. if (d2 > 0.01) {
  4450. this.dir += d2 / 20;
  4451. } else {
  4452. this.dir = this.lastDir;
  4453. }
  4454. if (this.visScale < this.scale) {
  4455. this.visScale += delta / (this.scale / 2);
  4456. if (this.visScale >= this.scale) {
  4457. this.visScale = this.scale;
  4458. }
  4459. }
  4460. this.alpha -= delta / 30000;
  4461. if (this.alpha <= 0) {
  4462. this.alpha = 0;
  4463. this.active = false;
  4464. }
  4465. }
  4466. }
  4467. };
  4468. class Player {
  4469. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4470. this.id = id;
  4471. this.sid = sid;
  4472. this.tmpScore = 0;
  4473. this.team = null;
  4474. this.latestSkin = 0;
  4475. this.oldSkinIndex = 0;
  4476. this.skinIndex = 0;
  4477. this.latestTail = 0;
  4478. this.oldTailIndex = 0;
  4479. this.tailIndex = 0;
  4480. this.hitTime = 0;
  4481. this.lastHit = 0;
  4482. this.showName = 'NOOO';
  4483. this.tails = {};
  4484. for (let i = 0; i < accessories.length; ++i) {
  4485. if (accessories[i].price <= 0)
  4486. this.tails[accessories[i].id] = 1;
  4487. }
  4488. this.skins = {};
  4489. for (let i = 0; i < hats.length; ++i) {
  4490. if (hats[i].price <= 0)
  4491. this.skins[hats[i].id] = 1;
  4492. }
  4493. this.points = 0;
  4494. this.dt = 0;
  4495. this.hidden = false;
  4496. this.itemCounts = {};
  4497. this.isPlayer = true;
  4498. this.pps = 0;
  4499. this.moveDir = undefined;
  4500. this.skinRot = 0;
  4501. this.lastPing = 0;
  4502. this.iconIndex = 0;
  4503. this.skinColor = 0;
  4504. this.dist2 = 0;
  4505. this.aim2 = 0;
  4506. this.maxSpeed = 1;
  4507. this.chat = {
  4508. message: null,
  4509. count: 0
  4510. };
  4511. this.backupNobull = true;
  4512. this.circle = false;
  4513. this.circleRad = 200;
  4514. this.circleRadSpd = 0.1;
  4515. this.cAngle = 0;
  4516. // SPAWN:
  4517. this.spawn = function(moofoll) {
  4518. this.attacked = false;
  4519. this.timeDamaged = 0;
  4520. this.timeHealed = 0;
  4521. this.pinge = 0;
  4522. this.millPlace = 'NOOO';
  4523. this.lastshamecount = 0;
  4524. this.death = false;
  4525. this.spinDir = 0;
  4526. this.sync = false;
  4527. this.antiBull = 0;
  4528. this.bullTimer = 0;
  4529. this.poisonTimer = 0;
  4530. this.active = true;
  4531. this.alive = true;
  4532. this.lockMove = false;
  4533. this.lockDir = false;
  4534. this.minimapCounter = 0;
  4535. this.chatCountdown = 0;
  4536. this.shameCount = 0;
  4537. this.shameTimer = 0;
  4538. this.sentTo = {};
  4539. this.gathering = 0;
  4540. this.gatherIndex = 0;
  4541. this.shooting = {};
  4542. this.shootIndex = 9;
  4543. this.autoGather = 0;
  4544. this.animTime = 0;
  4545. this.animSpeed = 0;
  4546. this.mouseState = 0;
  4547. this.buildIndex = -1;
  4548. this.weaponIndex = 0;
  4549. this.weaponCode = 0;
  4550. this.weaponVariant = 0;
  4551. this.primaryIndex = undefined;
  4552. this.secondaryIndex = undefined;
  4553. this.dmgOverTime = {};
  4554. this.noMovTimer = 0;
  4555. this.maxXP = 300;
  4556. this.XP = 0;
  4557. this.age = 1;
  4558. this.kills = 0;
  4559. this.upgrAge = 2;
  4560. this.upgradePoints = 0;
  4561. this.x = 0;
  4562. this.y = 0;
  4563. this.oldXY = {
  4564. x: 0,
  4565. y: 0
  4566. };
  4567. this.zIndex = 0;
  4568. this.xVel = 0;
  4569. this.yVel = 0;
  4570. this.slowMult = 1;
  4571. this.dir = 0;
  4572. this.dirPlus = 0;
  4573. this.targetDir = 0;
  4574. this.targetAngle = 0;
  4575. this.maxHealth = 100;
  4576. this.health = this.maxHealth;
  4577. this.oldHealth = this.maxHealth;
  4578. this.damaged = 0;
  4579. this.scale = config.playerScale;
  4580. this.speed = config.playerSpeed;
  4581. this.resetMoveDir();
  4582. this.resetResources(moofoll);
  4583. this.items = [0, 3, 6, 10];
  4584. this.weapons = [0];
  4585. this.shootCount = 0;
  4586. this.weaponXP = [];
  4587. this.reloads = {
  4588. 0: 0,
  4589. 1: 0,
  4590. 2: 0,
  4591. 3: 0,
  4592. 4: 0,
  4593. 5: 0,
  4594. 6: 0,
  4595. 7: 0,
  4596. 8: 0,
  4597. 9: 0,
  4598. 10: 0,
  4599. 11: 0,
  4600. 12: 0,
  4601. 13: 0,
  4602. 14: 0,
  4603. 15: 0,
  4604. 53: 0,
  4605. };
  4606. this.bowThreat = {
  4607. 9: 0,
  4608. 12: 0,
  4609. 13: 0,
  4610. 15: 0,
  4611. };
  4612. this.damageThreat = 0;
  4613. this.inTrap = false;
  4614. this.canEmpAnti = false;
  4615. this.empAnti = false;
  4616. this.soldierAnti = false;
  4617. this.poisonTick = 0;
  4618. this.bullTick = 0;
  4619. this.setPoisonTick = false;
  4620. this.setBullTick = false;
  4621. this.antiTimer = 2;
  4622. };
  4623.  
  4624. // RESET MOVE DIR:
  4625. this.resetMoveDir = function() {
  4626. this.moveDir = undefined;
  4627. };
  4628.  
  4629. // RESET RESOURCES:
  4630. this.resetResources = function(moofoll) {
  4631. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4632. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4633. }
  4634. };
  4635.  
  4636. // ADD ITEM:
  4637. this.getItemType = function(id) {
  4638. let findindx = this.items.findIndex((ids) => ids == id);
  4639. if (findindx != -1) {
  4640. return findindx;
  4641. } else {
  4642. return items.checkItem.index(id, this.items);
  4643. }
  4644. };
  4645.  
  4646. // SET DATA:
  4647. this.setData = function(data) {
  4648. this.id = data[0];
  4649. this.sid = data[1];
  4650. this.name = data[2];
  4651. this.x = data[3];
  4652. this.y = data[4];
  4653. this.dir = data[5];
  4654. this.health = data[6];
  4655. this.maxHealth = data[7];
  4656. this.scale = data[8];
  4657. this.skinColor = data[9];
  4658. };
  4659.  
  4660. // UPDATE POISON TICK:
  4661. this.updateTimer = function() {
  4662.  
  4663. this.bullTimer -= 1;
  4664. if (this.bullTimer <= 0) {
  4665. this.setBullTick = false;
  4666. this.bullTick = game.tick - 1;
  4667. this.bullTimer = config.serverUpdateRate;
  4668. }
  4669. this.poisonTimer -= 1;
  4670. if (this.poisonTimer <= 0) {
  4671. this.setPoisonTick = false;
  4672. this.poisonTick = game.tick - 1;
  4673. this.poisonTimer = config.serverUpdateRate;
  4674. }
  4675.  
  4676. };
  4677. this.update = function(delta) {
  4678. if (this.sid == playerSID) {
  4679. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4680. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4681. this.cAngle += this.circleRadSpd;
  4682. }
  4683. if (this.active) {
  4684.  
  4685. // MOVE:
  4686. let gear = {
  4687. skin: findID(hats, this.skinIndex),
  4688. tail: findID(accessories, this.tailIndex)
  4689. }
  4690. let spdMult = ((this.buildIndex >= 0) ? 0.5 : 1) * (items.weapons[this.weaponIndex].spdMult || 1) * (gear.skin ? (gear.skin.spdMult || 1) : 1) * (gear.tail ? (gear.tail.spdMult || 1) : 1) * (this.y <= config.snowBiomeTop ? ((gear.skin && gear.skin.coldM) ? 1 : config.snowSpeed) : 1) * this.slowMult;
  4691. this.maxSpeed = spdMult;
  4692.  
  4693. }
  4694. };
  4695.  
  4696. let tmpRatio = 0;
  4697. let animIndex = 0;
  4698. this.animate = function(delta) {
  4699. if (this.animTime > 0) {
  4700. this.animTime -= delta;
  4701. if (this.animTime <= 0) {
  4702. this.animTime = 0;
  4703. this.dirPlus = 0;
  4704. tmpRatio = 0;
  4705. animIndex = 0;
  4706. } else {
  4707. if (animIndex == 0) {
  4708. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4709. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4710. if (tmpRatio >= 1) {
  4711. tmpRatio = 1;
  4712. animIndex = 1;
  4713. }
  4714. } else {
  4715. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4716. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4717. }
  4718. }
  4719. }
  4720. };
  4721.  
  4722. // GATHER ANIMATION:
  4723. this.startAnim = function(didHit, index) {
  4724. this.animTime = this.animSpeed = items.weapons[index].speed;
  4725. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4726. tmpRatio = 0;
  4727. animIndex = 0;
  4728. };
  4729.  
  4730. // CAN SEE:
  4731. this.canSee = function(other) {
  4732. if (!other) return false;
  4733. let dx = Math.abs(other.x - this.x) - other.scale;
  4734. let dy = Math.abs(other.y - this.y) - other.scale;
  4735. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4736. };
  4737.  
  4738. // SHAME SYSTEM:
  4739. this.judgeShame = function() {
  4740. this.lastshamecount = this.shameCount;
  4741. if (this.oldHealth < this.health) {
  4742. if (this.hitTime) {
  4743. let timeSinceHit = game.tick - this.hitTime;
  4744. this.lastHit = game.tick;
  4745. this.hitTime = 0;
  4746. if (timeSinceHit < 2) {
  4747. this.shameCount++;
  4748. } else {
  4749. this.shameCount = Math.max(0, this.shameCount - 2);
  4750. }
  4751. }
  4752. } else if (this.oldHealth > this.health) {
  4753. this.hitTime = game.tick;
  4754. }
  4755. };
  4756. this.addShameTimer = function() {
  4757. this.shameCount = 0;
  4758. this.shameTimer = 30;
  4759. let interval = setInterval(() => {
  4760. this.shameTimer--;
  4761. if (this.shameTimer <= 0) {
  4762. clearInterval(interval);
  4763. }
  4764. }, 1000);
  4765. };
  4766.  
  4767. // CHECK TEAM:
  4768. this.isTeam = function(tmpObj) {
  4769. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4770. };
  4771.  
  4772. // FOR THE PLAYER:
  4773. this.findAllianceBySid = function(sid) {
  4774. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4775. };
  4776. this.checkCanInsta = function(nobull) {
  4777. let totally = 0;
  4778. if (this.alive && inGame) {
  4779. let primary = {
  4780. weapon: this.weapons[0],
  4781. variant: this.primaryVariant,
  4782. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4783. };
  4784. let secondary = {
  4785. weapon: this.weapons[1],
  4786. variant: this.secondaryVariant,
  4787. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4788. };
  4789. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4790. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4791. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4792. totally += primary.dmg * pV * bull;
  4793. }
  4794. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4795. totally += secondary.dmg;
  4796. }
  4797. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4798. totally += 25;
  4799. }
  4800. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4801. return totally;
  4802. }
  4803. return 0;
  4804. };
  4805.  
  4806. // UPDATE WEAPON RELOAD:
  4807. this.manageReload = function() {
  4808. if (this.shooting[53]) {
  4809. this.shooting[53] = 0;
  4810. this.reloads[53] = (2500 - game.tickRate);
  4811. } else {
  4812. if (this.reloads[53] > 0) {
  4813. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4814. }
  4815. }
  4816. // autoReplace
  4817. if (this.reloads[this.weaponIndex] <= 1/20) {//autoReplace speed
  4818. // place(2, getAttackDir());
  4819. let index = this.weaponIndex;
  4820. let nearObja = liztobj.filter((e) => (e.active || e.alive) && e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2) <= (items.weapons[player.weaponIndex].range + e.scale));
  4821. for(let i = 0; i < nearObja.length; i++) {
  4822. let aaa = nearObja[i];
  4823.  
  4824. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4825. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4826. if(aaa.health - (valaa) <= 0 && near.length) {
  4827. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4828. console.log("preplaced");
  4829. }
  4830. }
  4831. }
  4832.  
  4833. if (this.gathering || this.shooting[1]) {
  4834. if (this.gathering) {
  4835. this.gathering = 0;
  4836. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4837. this.attacked = true;
  4838. }
  4839. if (this.shooting[1]) {
  4840. this.shooting[1] = 0;
  4841. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4842. this.attacked = true;
  4843. }
  4844. } else {
  4845. this.attacked = false;
  4846. if (this.buildIndex < 0) {
  4847. if (this.reloads[this.weaponIndex] > 0) {
  4848. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  4849. if (this == player) {
  4850. if (getEl("weaponGrind").checked) {
  4851. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4852. checkPlace(player.getItemType(22), i);
  4853. }
  4854. }
  4855. }
  4856. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4857. this.antiBull++;
  4858. game.tickBase(() => {
  4859. this.antiBull = 0;
  4860. }, 1);
  4861. }
  4862. }
  4863. }
  4864. }
  4865. };
  4866. const BASE_TRAP_PLACEMENT_RADIUS = 70;
  4867. const LOW_HEALTH_THRESHOLD = 272.58;
  4868. const BASE_PLACE_DELAY = 0.001;
  4869. const SAFETY_BUFFER = 50;
  4870. const TARGET_PREDICTION_STEPS = 20;
  4871. const OPTIMIZED_SCORE_WEIGHT = 2.0;
  4872. const ANGLE_INCREMENT = 27;
  4873. const ENVIRONMENTAL_IMPACT_RADIUS = 100;
  4874. const LINE_OF_SIGHT_BLOCKAGE_PENALTY = 20;
  4875. const TEAMMATE_PROXIMITY_PENALTY = 20;
  4876. const MAX_ENVIRONMENTAL_SCORE = 100;
  4877. const HEATMAP_DECAY_RATE = 0.1;
  4878. const ENVIRONMENTAL_ADAPTATION_MULTIPLIER = 1.5;
  4879.  
  4880. let lastPlacementTime = 0;
  4881. let enemyHeatmap = {};
  4882. let enemyMovementPatterns = {};
  4883. let environmentalFactors = {};
  4884. let trapPositionCache = {};
  4885. let teamCoordination = {};
  4886. let liveCombatData = {};
  4887.  
  4888. this.autoReplace = function () {
  4889. const currentTime = Date.now();
  4890.  
  4891. if (traps.inTrap || !configs.autoReplace || (currentTime - lastPlacementTime < getPlaceDelay())) return;
  4892.  
  4893. const trapPlacementRadius = getTrapPlacementRadius();
  4894. const weaponRange = items.weapons[player.weaponIndex].range + trapPlacementRadius;
  4895. const rangeSquared = weaponRange ** 2;
  4896. const { x2: playerX, y2: playerY } = player;
  4897.  
  4898. const targetObjects = getTargetObjects(playerX, playerY, rangeSquared);
  4899.  
  4900. if (targetObjects.length === 0) return;
  4901.  
  4902. const bestPlacements = findBestTrapPlacements(targetObjects, playerX, playerY, trapPlacementRadius);
  4903.  
  4904. bestPlacements.forEach(placement => {
  4905. if (this.testCanPlace(4, placement.angle, placement.angle + Math.PI * 2, Math.PI / 72, placement.aim, trapPlacementRadius)) {
  4906. deployEnhancedTraps(placement.position);
  4907. }
  4908. });
  4909.  
  4910. lastPlacementTime = currentTime;
  4911. };
  4912.  
  4913. function getPlaceDelay() {
  4914. return BASE_PLACE_DELAY * (liveCombatData[player.teamId]?.threatLevel > 0.5 ? 0.5 : 1);
  4915. }
  4916.  
  4917. function getTrapPlacementRadius() {
  4918. return liveCombatData[player.teamId]?.threatLevel > 0.5 ? BASE_TRAP_PLACEMENT_RADIUS * 1.2 : BASE_TRAP_PLACEMENT_RADIUS;
  4919. }
  4920.  
  4921. function getTargetObjects(playerX, playerY, rangeSquared) {
  4922. return gameObjects
  4923. .filter(({ x2, y2, buildHealth, teamId }) => {
  4924. const distSquared = (x2 - playerX) ** 2 + (y2 - playerY) ** 2;
  4925. return teamId !== player.teamId && buildHealth <= LOW_HEALTH_THRESHOLD && distSquared <= rangeSquared;
  4926. })
  4927. .map(target => ({
  4928. ...target,
  4929. threatLevel: target.threatLevel,
  4930. isMoving: target.isMoving,
  4931. priorityScore: calculatePriorityScore(target),
  4932. predictedPosition: predictTargetPosition(target),
  4933. environmentalImpact: getEnvironmentalImpact(target.x2, target.y2),
  4934. lineOfSightBlocked: !isLineOfSightClear(playerX, playerY, [{ x: target.x2, y: target.y2 }])
  4935. }))
  4936. .sort((a, b) => b.priorityScore - a.priorityScore);
  4937. }
  4938.  
  4939. function calculatePriorityScore(targetObject) {
  4940. const { x2, y2, threatLevel, isMoving, buildHealth, environmentalImpact } = targetObject;
  4941. const distance = calculateDistance(player.x2, player.y2, x2, y2);
  4942.  
  4943. const baseScore = threatLevel * (isMoving ? 2 : 1);
  4944. const distanceFactor = 1 / (distance + 1);
  4945. const healthFactor = 1 - buildHealth / LOW_HEALTH_THRESHOLD;
  4946.  
  4947. const heatmapFactor = getHeatmapDensity(x2, y2);
  4948. const movementPatternScore = evaluateMovementPattern(targetObject);
  4949. const environmentalImpactFactor = environmentalImpact;
  4950. const liveCombatAdjustment = liveCombatData[x2]?.adjustment || 0;
  4951.  
  4952. return (baseScore + distanceFactor + healthFactor + heatmapFactor + movementPatternScore + environmentalImpactFactor + liveCombatAdjustment) * OPTIMIZED_SCORE_WEIGHT;
  4953. }
  4954.  
  4955. function predictTargetPosition(targetObject, predictionTime = TARGET_PREDICTION_STEPS) {
  4956. const { xVel, yVel, accX, accY, x2, y2 } = targetObject;
  4957. const predictedX = x2 + (xVel + accX * predictionTime) * predictionTime;
  4958. const predictedY = y2 + (yVel + accY * predictionTime) * predictionTime;
  4959. return { x: predictedX, y: predictedY };
  4960. }
  4961.  
  4962. function findBestTrapPlacements(targetObjects, playerX, playerY, trapPlacementRadius) {
  4963. let bestPlacements = [];
  4964.  
  4965. for (let angle = 0; angle < 360; angle += ANGLE_INCREMENT) {
  4966. const rad = UTILS.deg2rad(angle);
  4967. const trapX = playerX + Math.cos(rad) * trapPlacementRadius;
  4968. const trapY = playerY + Math.sin(rad) * trapPlacementRadius;
  4969.  
  4970. const score = evaluatePlacementScore(trapX, trapY, targetObjects, trapPlacementRadius);
  4971.  
  4972. if (score > 0) {
  4973. bestPlacements.push({ angle: rad, score, position: { x: trapX, y: trapY } });
  4974. targetObjects = targetObjects.filter(target => !isWithinPlacementRadius(target, { x: trapX, y: trapY }, trapPlacementRadius));
  4975. }
  4976. }
  4977.  
  4978. return bestPlacements;
  4979. }
  4980.  
  4981. function evaluatePlacementScore(trapX, trapY, targetObjects, trapPlacementRadius) {
  4982. let score = 0;
  4983.  
  4984. for (const target of targetObjects) {
  4985. const predictedPosition = predictTargetPosition(target, 0.5);
  4986. const distanceToTarget = calculateDistance(trapX, trapY, predictedPosition.x, predictedPosition.y);
  4987.  
  4988. score -= distanceToTarget / (target.priorityScore + 1);
  4989.  
  4990. if (target.lineOfSightBlocked) {
  4991. score -= LINE_OF_SIGHT_BLOCKAGE_PENALTY;
  4992. }
  4993. }
  4994.  
  4995. if (isLineOfSightClear(trapX, trapY, targetObjects)) {
  4996. score += 50;
  4997. }
  4998.  
  4999. for (const teammate of teamCoordination) {
  5000. const distToTeammate = calculateDistance(trapX, trapY, teammate.x2, teammate.y2);
  5001. if (distToTeammate < trapPlacementRadius + SAFETY_BUFFER) {
  5002. score -= TEAMMATE_PROXIMITY_PENALTY;
  5003. }
  5004. }
  5005.  
  5006. score += calculateEnvironmentalImpactScore(trapX, trapY);
  5007. updateHeatmap(trapX, trapY);
  5008.  
  5009. return score;
  5010. }
  5011.  
  5012. function calculateDistance(x1, y1, x2, y2) {
  5013. return Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2);
  5014. }
  5015.  
  5016. function isLineOfSightClear(startX, startY, endObjects) {
  5017. return !getObstaclesBetween(startX, startY, endObjects).length;
  5018. }
  5019.  
  5020. function getObstaclesBetween(startX, startY, endObjects) {
  5021. return endObjects.map(({ x, y }) => {
  5022. if (Math.abs(startX - x) < 10 && Math.abs(startY - y) < 10) {
  5023. return { type: 'wall', x: (startX + x) / 2, y: (startY + y) / 2 };
  5024. }
  5025. return null;
  5026. }).filter(Boolean);
  5027. }
  5028.  
  5029. function isWithinPlacementRadius(target, position, trapPlacementRadius) {
  5030. return calculateDistance(target.x2, target.y2, position.x, position.y) < trapPlacementRadius;
  5031. }
  5032.  
  5033. function deployEnhancedTraps(position) {
  5034. traps.addTrap(position.x, position.y, 'standard');
  5035. }
  5036.  
  5037. function getHeatmapDensity(x, y) {
  5038. return enemyHeatmap[`${x},${y}`] || 0;
  5039. }
  5040.  
  5041. function evaluateMovementPattern(targetObject) {
  5042. return enemyMovementPatterns[targetObject.id] || 0;
  5043. }
  5044.  
  5045. function getEnvironmentalImpact(x, y) {
  5046. return environmentalFactors[`${x},${y}`] || 0;
  5047. }
  5048.  
  5049. function calculateEnvironmentalImpactScore(trapX, trapY) {
  5050. let impactScore = 0;
  5051. for (let x = trapX - ENVIRONMENTAL_IMPACT_RADIUS; x <= trapX + ENVIRONMENTAL_IMPACT_RADIUS; x += 10) {
  5052. for (let y = trapY - ENVIRONMENTAL_IMPACT_RADIUS; y <= trapY + ENVIRONMENTAL_IMPACT_RADIUS; y += 10) {
  5053. impactScore += environmentalFactors[`${x},${y}`] || 0;
  5054. }
  5055. }
  5056. return Math.min(impactScore, MAX_ENVIRONMENTAL_SCORE);
  5057. }
  5058.  
  5059. function updateHeatmap(x, y) {
  5060. const key = `${x},${y}`;
  5061. enemyHeatmap[key] = (enemyHeatmap[key] || 0) * (1 - HEATMAP_DECAY_RATE) + 1;
  5062. }
  5063.  
  5064.  
  5065. // FOR ANTI INSTA:
  5066. this.addDamageThreat = function (tmpObj) {
  5067. const defaultPrimaryDmg = 45;
  5068. const defaultSecondaryDmg = 35;
  5069. const bullMultiplier = 1.5;
  5070. const defaultVariantVal = 1.18;
  5071. const skinIndexPenalty = 0.75;
  5072. const closeRangeThreshold = 300;
  5073. const additionalThreatReloadTickRate = game.tickRate;
  5074. const additionalThreatValue = 25;
  5075. let { primaryIndex, primaryVariant, secondaryIndex, secondaryVariant, reloads, dist2 } = this;
  5076. let { weapons } = items;
  5077. let { weaponVariants } = config;
  5078. let primary = {
  5079. weapon: primaryIndex,
  5080. variant: primaryVariant,
  5081. dmg: primaryIndex === undefined ? defaultPrimaryDmg : weapons[primaryIndex].dmg
  5082. };
  5083. let secondary = {
  5084. weapon: secondaryIndex,
  5085. variant: secondaryVariant,
  5086. dmg: secondaryIndex === undefined ? defaultSecondaryDmg : weapons[secondaryIndex].Pdmg
  5087. };
  5088. let primaryVariantValue = primary.variant !== undefined ? weaponVariants[primary.variant].val : defaultVariantVal;
  5089. let secondaryVariantValue = secondary.variant !== undefined && ![9, 12, 17, 15].includes(secondary.weapon) ? weaponVariants[secondary.variant].val : defaultVariantVal;
  5090. let damageThreat = 0;
  5091. if (primary.weapon === undefined || reloads[primary.weapon] === 0) {
  5092. damageThreat += primary.dmg * primaryVariantValue * bullMultiplier;
  5093. }
  5094. if (secondary.weapon === undefined || reloads[secondary.weapon] === 0) {
  5095. damageThreat += secondary.dmg * secondaryVariantValue;
  5096. }
  5097. if (reloads[53] <= additionalThreatReloadTickRate) {
  5098. damageThreat += additionalThreatValue;
  5099. }
  5100. damageThreat *= tmpObj.skinIndex === 6 ? skinIndexPenalty : 1;
  5101. if (!this.isTeam(tmpObj) && dist2 <= closeRangeThreshold) {
  5102. tmpObj.damageThreat += damageThreat;
  5103. }
  5104. };
  5105. // ANTI
  5106. this.addDamageProbability = function (tmpObj) {
  5107. let primary = {
  5108. weapon: this.primaryIndex,
  5109. variant: this.primaryVariant
  5110. };
  5111. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  5112. let secondary = {
  5113. weapon: this.secondaryIndex,
  5114. variant: this.secondaryVariant
  5115. };
  5116. secondary.dmg = secondary.weapon == undefined ? 50 : items.weapons[secondary.weapon].Pdmg;
  5117. let bull = 1.5;
  5118. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  5119. let sV = secondary.variant != undefined ? [9, 12, 17, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  5120. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  5121. this.damageProbably += primary.dmg * pV * bull * 0.75;
  5122. }
  5123. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  5124. this.damageProbably += secondary.dmg * sV;
  5125. }
  5126. this.damageProbably *= 0.75;
  5127. if (!this.isTeam(tmpObj)) {
  5128. if (this.dist2 <= 300) {
  5129. tmpObj.damageProbably += this.damageProbably;
  5130. }
  5131. }
  5132. };
  5133. }
  5134. };
  5135.  
  5136.  
  5137.  
  5138. // SOME CODES:
  5139. function sendUpgrade(index) {
  5140. player.reloads[index] = 0;
  5141. packet("H", index);
  5142. }
  5143.  
  5144. function storeEquip(id, index) {
  5145. packet("c", 0, id, index);
  5146. }
  5147.  
  5148. function storeBuy(id, index) {
  5149. packet("c", 1, id, index);
  5150. }
  5151.  
  5152. function buyEquip(id, index) {
  5153. let nID = player.skins[6] ? 6 : 0;
  5154. if (player.alive && inGame) {
  5155. if (index == 0) {
  5156. if (player.skins[id]) {
  5157. if (player.latestSkin != id) {
  5158. packet("c", 0, id, 0);
  5159. }
  5160. } else {
  5161. if (configs.autoBuyEquip) {
  5162. let find = findID(hats, id);
  5163. if (find) {
  5164. if (player.points >= find.price) {
  5165. packet("c", 1, id, 0);
  5166. packet("c", 0, id, 0);
  5167. } else {
  5168. if (player.latestSkin != nID) {
  5169. packet("c", 0, nID, 0);
  5170. }
  5171. }
  5172. } else {
  5173. if (player.latestSkin != nID) {
  5174. packet("c", 0, nID, 0);
  5175. }
  5176. }
  5177. } else {
  5178. if (player.latestSkin != nID) {
  5179. packet("c", 0, nID, 0);
  5180. }
  5181. }
  5182. }
  5183. } else if (index == 1) {
  5184. if (useWasd && (id != 11 && id != 0)) {
  5185. if (player.latestTail != 0) {
  5186. packet("c", 0, 0, 1);
  5187. }
  5188. return;
  5189. }
  5190. if (player.tails[id]) {
  5191. if (player.latestTail != id) {
  5192. packet("c", 0, id, 1);
  5193. }
  5194. } else {
  5195. if (configs.autoBuyEquip) {
  5196. let find = findID(accessories, id);
  5197. if (find) {
  5198. if (player.points >= find.price) {
  5199. packet("c", 1, id, 1);
  5200. packet("c", 0, id, 1);
  5201. } else {
  5202. if (player.latestTail != 0) {
  5203. packet("c", 0, 0, 1);
  5204. }
  5205. }
  5206. } else {
  5207. if (player.latestTail != 0) {
  5208. packet("c", 0, 0, 1);
  5209. }
  5210. }
  5211. } else {
  5212. if (player.latestTail != 0) {
  5213. packet("c", 0, 0, 1);
  5214. }
  5215. }
  5216. }
  5217. }
  5218. }
  5219. }
  5220.  
  5221. function selectToBuild(index, wpn) {
  5222. packet("G", index, wpn);
  5223. }
  5224.  
  5225. function selectWeapon(index, isPlace) {
  5226. if (!isPlace) {
  5227. player.weaponCode = index;
  5228. }
  5229. packet("G", index, 1);
  5230. }
  5231.  
  5232. function sendAutoGather() {
  5233. packet("K", 1, 1);
  5234. }
  5235.  
  5236. function sendAtck(id, angle) {
  5237. packet("d", id, angle, 1);
  5238. }
  5239.  
  5240. // PLACER:
  5241. function place(id, rad, rmd) {
  5242. if (getEl("placetype").value == "tamper") {
  5243. try {
  5244. if (id == undefined) return;
  5245. let item = items.list[player.items[id]];
  5246. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5247. let tmpX = player.x2 + tmpS * Math.cos(rad);
  5248. let tmpY = player.y2 + tmpS * Math.sin(rad);
  5249. if ((player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? 299 : item.group.limit ? item.group.limit : 99))) {
  5250. selectToBuild(player.items[id]);
  5251. sendAtck(1, rad);
  5252. selectWeapon(player.weaponCode, 1);
  5253. if (rmd && getEl("placeVis").checked) {
  5254. placeVisible.push({
  5255. x: tmpX,
  5256. y: tmpY,
  5257. name: item.name,
  5258. scale: item.scale,
  5259. dir: rad
  5260. });
  5261. game.tickBase(() => {
  5262. placeVisible.shift();
  5263. }, 1)
  5264. }
  5265. }
  5266. } catch (e) {}
  5267. }
  5268. if (getEl("placetype").value == "kindver") {
  5269. try {
  5270. if (id == undefined) return;
  5271. let item = items.list[player.items[id]];
  5272. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5273. let tmpX = player.x2 + tmpS * Math.cos(rad);
  5274. let tmpY = player.y2 + tmpS * Math.sin(rad);
  5275. if (id === 0 || testMode || (player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? id === 3 || id === 5 ? 299 : 99 : item.group.limit ? item.group.limit : 99))) {
  5276. selectToBuild(player.items[id]);
  5277. sendAtck(1, rad);
  5278. selectWeapon(player.weaponCode, 1);
  5279. if (rmd && getEl("placeVis").checked) {
  5280. placeVisible.push({
  5281. x: tmpX,
  5282. y: tmpY,
  5283. name: item.name,
  5284. scale: item.scale,
  5285. dir: rad
  5286. });
  5287. game.tickBase(() => {
  5288. placeVisible.shift();
  5289. }, 1)
  5290. }
  5291. }
  5292. } catch (e) { }
  5293. }
  5294. }
  5295. function checkPlace(id, rad) {
  5296. try {
  5297. if (id == undefined) return;
  5298. let item = items.list[player.items[id]];
  5299. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5300. let tmpX = player.x2 + tmpS * Math.cos(rad);
  5301. let tmpY = player.y2 + tmpS * Math.sin(rad);
  5302. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  5303. place(id, rad, 1);
  5304. }
  5305. } catch (e) {}
  5306. }
  5307.  
  5308. // HEALING:
  5309. function healingTrap() {
  5310. let maxPotential = getMaxPot();
  5311. let pingHeal = function() {
  5312. return Math.max(0, maxPotential - window.pingTime);
  5313. };
  5314. if (true) {
  5315. setTimeout(() => {
  5316. for (let i = 0; i < healthBased(); i++) {
  5317. place(0, getAttackDir());
  5318. }
  5319. }, 2);
  5320. } else {
  5321. setTimeout(() => {
  5322. for (let i = 0; i < healthBased(); i++) {
  5323. place(0, getAttackDir());
  5324. }
  5325. }, 2);
  5326. }
  5327. }
  5328. function getMaxPot() {
  5329. let dmg = 0;
  5330. enemy.forEach(tmp => {
  5331. if (getDist(player, tmp) - 63 <= items.weapons[tmp.weapons[0]].range) {
  5332. dmg += player.checkCanInsta(false);
  5333. }
  5334. });
  5335. return dmg;
  5336. }
  5337. function instaheal(e, t) {
  5338. let foodType = (player.items[0] == 0 ? 20 : player.items[0] == 1 ? 40 : 30)
  5339. let times = (e == "max" ? (100-player.health)/foodType : e == (null || undefined) ? 1 : e);
  5340. for(let i = 0; i < times; i++) {
  5341. place(0, getAttackDir());
  5342. }
  5343. }
  5344. function fastHealing(speed) {
  5345. let value = player.health;
  5346. let damaged
  5347. let attackers = getAttacker(damaged);
  5348. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  5349. let includeSpikeDmgs = !my.reSync && gearDmgs.includes(damaged);
  5350. let maxPotential = getMaxPot();
  5351. let canAntiHeal = false;
  5352.  
  5353.  
  5354. let pingHeal = function() {
  5355. return Math.max(0, maxPotential - window.pingTime);
  5356. };
  5357. let autoHeal;
  5358. let doMaxHeal = function () {
  5359. clearInterval(autoHeal);
  5360. for (let i = 0; i < Math.ceil(Math.min(100 - value, 50) / items.list[player.items[0]].consume); i++) {
  5361. place(player.items[0]);
  5362. }
  5363. };
  5364. if (speed >= 100000) {
  5365. canAntiHeal = true;
  5366. } else {
  5367. canAntiHeal = false;
  5368. }
  5369.  
  5370. // Heal:
  5371. setTimeout(()=>{
  5372. if (traps.inTrap) {
  5373. healingTrap();
  5374. } else {
  5375. setTimeout(()=>{
  5376. for (let i = 0; i < healthBased(); i++) {
  5377. if (canAntiHeal == true && value <= 80 && near.checkCanInsta(true) >= 100) {
  5378. setTimeout(()=>{
  5379. place(0, getAttackDir());
  5380. setTimeout(()=>{
  5381. place(0, getAttackDir());
  5382. setTimeout(()=>{
  5383. place(0, getAttackDir());
  5384. }, speed*5);
  5385. }, speed*4);
  5386. }, speed*3);
  5387. } else {
  5388. place(0, getAttackDir());
  5389. }
  5390. healer();
  5391. }
  5392. }, speed*2);
  5393. }
  5394. }, speed);
  5395. }
  5396. function soldierMult() {
  5397. return player.latestSkin == 6 ? 0.75 : 1;
  5398. }
  5399. function heal() {
  5400. if (player.health === 100) {
  5401. return;
  5402. }
  5403. if (player.skinIndex !== 70 && player.skinIndex !== 75) {
  5404. let value = Math.ceil(100 / items.list[player.items[0]].healing);
  5405. if (player.health === 58.75 && player.skinIndex === 6) {
  5406. value = 1;
  5407. }
  5408. for (let i = 0; i < value; i++) {
  5409. place(0, getAttackDir());
  5410. }
  5411. }
  5412. }
  5413. function healOnResourceGain() {
  5414. if (player.wood > player.woodLast || player.stone > player.stoneLast || player.food > player.foodLast) {
  5415. place(0, getAttackDir());
  5416. }
  5417. }
  5418. function findAllianceBySid(sid) {
  5419. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  5420. }
  5421. function healOnEnemySight() {
  5422. if (enemy.length > 0) {
  5423. place(0, getAttackDir());
  5424. }
  5425. }
  5426. function healOnLowHealth() {
  5427. if (player.health < 50) {
  5428. place(0, getAttackDir());
  5429. }
  5430. }
  5431. function healOnNoWeapon() {
  5432. if (player.items[0] === 0) {
  5433. place(0, getAttackDir());
  5434. }
  5435. }
  5436. function healOnLevelUp() {
  5437. if (player.level > player.levelLast) {
  5438. place(0, getAttackDir());
  5439. }
  5440. }
  5441. function getNearestEnemyDistance() {
  5442. let nearestEnemy = enemy.reduce((nearest, current) => {
  5443. return nearest.dist < current.dist ? nearest : current;
  5444. });
  5445. return nearestEnemy.dist;
  5446. }
  5447. function isBeingAttackedBy(attackerId) {
  5448. let attackers = enemy.filter(tmp => tmp.id === attackerId && tmp.attacked);
  5449. return attackers.length > 0;
  5450. }
  5451. function healOverTime() {
  5452. if (player.health < 100) {
  5453. place(0, getAttackDir());
  5454. }
  5455. }
  5456. function smartHeal() {
  5457. if (player.score > 10000) {
  5458. if (player.health < 90) {
  5459. place(0, getAttackDir());
  5460. }
  5461. } else {
  5462. if (player.health < 70) {
  5463. place(0, getAttackDir());
  5464. }
  5465. }
  5466. }
  5467. function panicHeal() {
  5468. if (player.health < 50) {
  5469. for (let i = 0; i < 10; i++) {
  5470. place(0, getAttackDir());
  5471. }
  5472. }
  5473. }
  5474. function arenaHeal() {
  5475. if (player.zone === 'arena') {
  5476. if (player.health < 90) {
  5477. place(0, getAttackDir());
  5478. }
  5479. }
  5480. }
  5481. function defensiveHeal() {
  5482. if (player.latestDamage > 0 && player.health < 100) {
  5483. place(0, getAttackDir());
  5484. }
  5485. }
  5486. function healPlayer() {
  5487. if (configs.shouldHeal) {
  5488. place(0, getAttackDir());
  5489. }
  5490. }
  5491. function getAttacker(damaged) {
  5492. let attackers = enemy.filter(tmp => {
  5493. //let damages = new Damages(items);
  5494. //let dmg = damages.weapons[tmp.weaponIndex];
  5495. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  5496. let rule = {
  5497. //one: tmp.dist2 <= 300,
  5498. //two: by.includes(damaged),
  5499. three: tmp.attacked
  5500. }
  5501. return /*rule.one && rule.two && */rule.three;
  5502. });
  5503. return attackers;
  5504. }
  5505. function healer(extra) {
  5506. if ([0, undefined].includes(extra)) {
  5507. for (let i = 0; i < healthBased(); i++) {
  5508. place(0, getAttackDir());
  5509. }
  5510. } else {
  5511. for (let i = 0; i < healthBased() + extra; i++) {
  5512. place(0, getAttackDir());
  5513. }
  5514. }
  5515. }
  5516. let resourceGainHealCooldown = false;
  5517. function healOnResourceGainAdvanced() {
  5518. if (player.wood > player.woodLast || player.stone > player.stoneLast || player.food > player.foodLast) {
  5519. if (!resourceGainHealCooldown) {
  5520. place(0, getAttackDir());
  5521. resourceGainHealCooldown = true;
  5522. setTimeout(() => {
  5523. resourceGainHealCooldown = false;
  5524. }, 1000);
  5525. }
  5526. }
  5527. }
  5528. // GLOBAL VARIABLES
  5529. let lastPlayerCount = 0;
  5530. let lastZone = "";
  5531. // FUNCTIONS
  5532. function playerCountFunction() {
  5533. return Object.keys(players).length;
  5534. }
  5535. function healOnPlayerJoin() {
  5536. if (playerCountFunction() > lastPlayerCount) {
  5537. place(0, getAttackDir());
  5538. }
  5539. lastPlayerCount = playerCountFunction();
  5540. }
  5541. function healOnAreaChange() {
  5542. if (player.zone !== lastZone) {
  5543. place(0, getAttackDir());
  5544. }
  5545. lastZone = player.zone;
  5546. }
  5547. // GAME TICK
  5548. function gameTick() {
  5549. healOnPlayerJoin();
  5550. healOnAreaChange();
  5551. }
  5552. function healOnWin() {
  5553. if (player.wins > player.winsLast) {
  5554. place(0, getAttackDir());
  5555. }
  5556. }
  5557. function healOnHealingItemPickup() {
  5558. let healingItems = [101, 102, 103, 104];
  5559. if (healingItems.includes(player.items[0])) {
  5560. place(0, getAttackDir());
  5561. }
  5562. }
  5563. function healOnFlagCapture() {
  5564. if (player.flagCaptures > player.flagCapturesLast) {
  5565. place(0, getAttackDir());
  5566. }
  5567. }
  5568. // ADVANCED:
  5569. function applCxC(value) {
  5570. if (player.health == 100) {
  5571. return 0;
  5572. }
  5573. if (player.skinIndex != 45 && player.skinIndex != 56) {
  5574. return Math.ceil(value / items.list[player.items[0]].healing);
  5575. }
  5576. return 0;
  5577. }
  5578. function healthBased() {
  5579. if (player.health == 100) {
  5580. return 0;
  5581. }
  5582. if (player.skinIndex != 45 && player.skinIndex != 56) {
  5583. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  5584. }
  5585. return 0;
  5586. }
  5587. function calcDmg(value) {
  5588. return value * player.skinIndex == 6 ? 0.75 : 1;
  5589. }
  5590. function antirev() {
  5591. if (tmpObj.isPlayer){
  5592. for (let i = 0; i < healthBased(); i++) {
  5593. place(0, getAttackDir());
  5594. if (player.health == 55 && player.shameCount < 6 && player.skinIndex == 6) {
  5595. place(0, getAttackDir());
  5596. notif("antirev");
  5597. } else if (player.health == 40 && player.shameCount < 6 && player.skinIndex != 6){
  5598. place(0, getAttackDir());
  5599. notif("antirev");
  5600. } else if (player.health == 43.75 && player.shameCount < 5 && player.skinIndex == 6){
  5601. place(0, getAttackDir());
  5602. setTimeout(()=>{
  5603. place(0, getAttackDir());
  5604. },5)
  5605. } else if(player.health == 25 && player.shameCount < 4 && player.skinIndex == 6){
  5606. place(0, getAttackDir());
  5607. setTimeout(()=>{
  5608. place(0, getAttackDir());
  5609. },5)
  5610. } else if (player.health == 58.75 && player.shameCount < 6 && player.skinIndex == 6){
  5611. place(0, getAttackDir());
  5612. setTimeout(()=>{
  5613. place(0, getAttackDir());
  5614. },5)
  5615. } else if (player.health == 45 && player.shameCount < 6 && player.skinIndex != 6){
  5616. place(0, getAttackDir());
  5617. setTimeout(()=>{
  5618. place(0, getAttackDir());
  5619. },5)
  5620. }
  5621. if (player.shameCount < 6) {
  5622. setTimeout(()=>{
  5623. place(0, getAttackDir());
  5624. },30)
  5625. }
  5626. }
  5627. }
  5628. }
  5629. let slowHeal = function(timer) {
  5630. setTimeout(() => {
  5631. healer();
  5632. }, 25);
  5633. }
  5634. let isHealing = false;
  5635. let delay = 20;
  5636. function Staryheal() {
  5637. if (!isHealing && player.health < 100) {
  5638. isHealing = true;
  5639. if (player.health < 95) {
  5640. place(0, getAttackDir());
  5641. healer();// fast heal
  5642. isHealing = false;
  5643. } else {
  5644. const healingDelay = 5;
  5645. const healingIterations = Math.ceil((100 - player.health) / 10); // making it have delay so it wont packet spam
  5646. let iterationCount = 0;
  5647. function performHealing() {
  5648. if (iterationCount < healingIterations) {
  5649. setTimeout(() => {
  5650. place(0, getAttackDir()); // slow heal
  5651. iterationCount++;
  5652. performHealing();
  5653. }, healingDelay);
  5654. } else {
  5655. isHealing = false;
  5656. }
  5657. }
  5658. performHealing();
  5659. }
  5660. }
  5661. }
  5662. // LATER:
  5663. function predictHeal(random) {
  5664. for (let Preidict in random) {
  5665. place(0, getAttackDir());
  5666. console.log("health predicted");
  5667. }
  5668. }
  5669. function antiSyncHealing(timearg) {
  5670. my.antiSync = true;
  5671. let healAnti = setInterval(() => {
  5672. if (player.shameCount < 5) {
  5673. place(0, getAttackDir());
  5674. }
  5675. }, 75);
  5676. setTimeout(() => {
  5677. clearInterval(healAnti);
  5678. setTimeout(() => {
  5679. my.antiSync = false;
  5680. }, game.tickRate);
  5681. }, game.tickRate);
  5682. }
  5683. function EmpMult() {
  5684. return player.skinIndex == 22 ? 0.75 : 1;
  5685. }
  5686. function healer33() {
  5687. for (let i = 0; i < healthBased(); i++) {
  5688. place(0, getAttackDir());
  5689. }
  5690. }
  5691. function healer1() {
  5692. place(0, getAttackDir());
  5693. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  5694. }
  5695.  
  5696.  
  5697. function noshameheal() {
  5698. place(0, getAttackDir());
  5699. if (player.shameCount >= 5) {
  5700. place(0, getAttackDir());
  5701. healer33();
  5702. } else {
  5703. if (player.shameCount <= 4 && player.skinIndex != 6 && player.skinIndex != 22) {
  5704. buyEquip(6, 0);
  5705. healer33();
  5706. } else {
  5707. if (player.shameCount >= 5 && player.skinIndex != 6 && player.skinIndex != 22) {
  5708. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  5709. }
  5710. }
  5711. }
  5712. }
  5713.  
  5714. function smartAntiInsta() {
  5715. let enemies = getNearbyEnemies();
  5716. for (let i = 0; i < enemies.length; i++) {
  5717. let e = enemies[i];
  5718. if (e.shooting && getDist(player, e) < 200 && !e.blocked) {
  5719. place(getRandomDir());
  5720. }
  5721. }
  5722. }
  5723.  
  5724. function getNearbyEnemies() {
  5725. let enemies = [];
  5726. for (let i = 0; i < enemy.length; i++) {
  5727. let e = enemy[i];
  5728. if (getDist(player, e) < 250) {
  5729. enemies.push(e);
  5730. }
  5731. }
  5732. return enemies;
  5733. }
  5734.  
  5735. function getRandomDir() {
  5736. let directions = [-1, 0, 1];
  5737. return [directions[Math.floor(Math.random() * 3)], directions[Math.floor(Math.random() * 3)]];
  5738. }
  5739. setInterval(() => {
  5740. if (configs.shouldHeal) {
  5741. smartAntiInsta();
  5742. }
  5743. }, 100);
  5744. let healSan = function() {
  5745. if (config.isSandbox) {
  5746. return 100;
  5747. } else {
  5748. return 80;
  5749. }
  5750. }
  5751. let checkHealth = function() {
  5752. return player.skinIndex != 45 && !autoQ && !my.antiSync;
  5753. }
  5754.  
  5755.  
  5756. const placedSpikePositions = new Set();
  5757. const placedTrapPositions = new Set();
  5758. function isPositionValid(position) {
  5759. const playerX = player.x2;
  5760. const playerY = player.y2;
  5761. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  5762. return distToPosition > 35;
  5763. }
  5764. function calculatePossibleTrapPositions(x, y, radius) {
  5765. const trapPositions = [];
  5766. const numPositions = 16;
  5767. for (let i = 0; i < numPositions; i++) {
  5768. const angle = (2 * Math.PI * i) / numPositions;
  5769. const offsetX = x + radius * Math.cos(angle);
  5770. const offsetY = y + radius * Math.sin(angle);
  5771. const position = [offsetX, offsetY];
  5772. if (!trapPositions.some(pos => isPositionTooClose(position, pos))) {
  5773. trapPositions.push(position);
  5774. }
  5775. }
  5776. return trapPositions;
  5777. }
  5778. function isPositionTooClose(position1, position2, minDistance = 50) {
  5779. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  5780. return dist < minDistance;
  5781. }
  5782. function biomeGear(mover, returns) {
  5783. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  5784. if (returns) return 31;
  5785. buyEquip(31, 0);
  5786. } else {
  5787. if (player.y2 <= config.snowBiomeTop) {
  5788. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  5789. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  5790. } else {
  5791. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  5792. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  5793. }
  5794. }
  5795. if (returns) return 0;
  5796. }
  5797. function woah(mover) {
  5798. buyEquip(mover && player.moveDir == undefined ? 0 : 20, 1);
  5799. }
  5800. let advHeal = [];
  5801.  
  5802. class Traps {
  5803. constructor(UTILS, items) {
  5804. this.dist = 0;
  5805. this.aim = 0;
  5806. this.inTrap = false;
  5807. this.replaced = false;
  5808. this.antiTrapped = false;
  5809. this.info = {};
  5810. this.notFast = function() {
  5811. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5812. }
  5813. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5814. try {
  5815. let item = items.list[player.items[id]];
  5816. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5817. let counts = {
  5818. attempts: 0,
  5819. placed: 0
  5820. };
  5821. let tmpObjects = [];
  5822. gameObjects.forEach((p) => {
  5823. tmpObjects.push({
  5824. x: p.x,
  5825. y: p.y,
  5826. active: p.active,
  5827. blocker: p.blocker,
  5828. scale: p.scale,
  5829. isItem: p.isItem,
  5830. type: p.type,
  5831. colDiv: p.colDiv,
  5832. getScale: function(sM, ig) {
  5833. sM = sM || 1;
  5834. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  5835. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  5836. },
  5837. });
  5838. });
  5839.  
  5840. for (let i = first; i < repeat; i += plus) {
  5841. counts.attempts++;
  5842. let relAim = radian + i;
  5843. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5844. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5845. let cantPlace = tmpObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  5846. if (cantPlace) continue;
  5847. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5848. if ((!replacer && yaboi) || useWasd) {
  5849. if (useWasd ? false : yaboi.inTrap) {
  5850. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI && player.primaryIndex != 7) {
  5851. place(2, relAim, 1);
  5852. } else {
  5853. player.items[4] == 15 && place(4, relAim, 1);
  5854. }
  5855. } else {
  5856. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5 && player.primaryIndex != 7) {
  5857. place(2, relAim, 1);
  5858. } else {
  5859. player.items[4] == 15 && place(4, relAim, 1);
  5860. }
  5861. }
  5862. } else {
  5863. place(id, relAim, 1);
  5864. }
  5865. tmpObjects.push({
  5866. x: tmpX,
  5867. y: tmpY,
  5868. active: true,
  5869. blocker: item.blocker,
  5870. scale: item.scale,
  5871. isItem: true,
  5872. type: null,
  5873. colDiv: item.colDiv,
  5874. getScale: function() {
  5875. return this.scale;
  5876. },
  5877. });
  5878. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5879. counts.placed++;
  5880. }
  5881. }
  5882. if (counts.placed > 0 && replacer && item.dmg) {
  5883. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  5884. instaC.canSpikeTick = true;
  5885. }
  5886. }
  5887. } catch (err) {}
  5888. };
  5889. /* this.checkSpikeTick = function () {
  5890. // more range for safe. also testing near.primaryIndex || 5
  5891. if (getEl("safeAntiSpikeTick").checked && this.inTrap && near.dist2 <= items.weapons[near.primaryIndex || 5].range + near.scale && [3, 4, 5].includes(near.primaryIndex) && this.info.health <= items.weapons[player.weaponIndex].dmg * (config.weaponVariants[tmpObj[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[player.weaponIndex].sDmg || 1) * 3.3) return true
  5892. }*/
  5893. this.checkSpikeTick = function() {
  5894. try {
  5895. if (this.inTrap && near.dist2 <= items.weapons[near.primaryIndex || 5].range + near.scale * 1.2 && [3, 4, 5].includes(near.primaryIndex) && this.info.health <= items.weapons[player.weaponIndex].dmg * (config.weaponVariants[player[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[player.weaponIndex].sDmg || 1) * 3.3) return true
  5896. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5897. if (getEl("safeAntiSpikeTick").checked && this.inTrap && near.dist2 <= items.weapons[near.primaryIndex || 5].range + near.scale && [3, 4, 5].includes(near.primaryIndex) && this.info.health <= items.weapons[player.weaponIndex].dmg * (config.weaponVariants[tmpObj[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[player.weaponIndex].sDmg || 1) * 3.3) return true
  5898. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5899. let item = items.list[9];
  5900. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5901. let danger = 0;
  5902. let counts = {
  5903. attempts: 0,
  5904. block: `unblocked`
  5905. };
  5906. for (let i = -1; i <= 1; i += 1/10) {
  5907. counts.attempts++;
  5908. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5909. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5910. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5911. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  5912. if (cantPlace) continue;
  5913. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5914. danger++;
  5915. counts.block = `blocked`;
  5916. break;
  5917. }
  5918. if (danger && near.dist2 <= 100 && tdf) {
  5919. my.anti0Tick = 1;
  5920. healer();
  5921. //player.chat.message = "AntiSpikeTick";
  5922. //player.chat.count = 2000;
  5923. return true;
  5924. }
  5925. }
  5926. } catch (err) {
  5927. return null;
  5928. }
  5929. return false;
  5930. }
  5931. this.protect = function(aim) {
  5932. if (!configs.antiTrap) return;
  5933. if (player.items[4]) {
  5934. checkPlace(2, (Math.PI / 2), -(Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5935. checkPlace(2, (Math.PI / 2), -(Math.PI / 2) -(Math.PI / 18), aim + Math.PI);
  5936. this.antiTrapped = true;
  5937. }
  5938. };
  5939. function calculatePerfectAngle(x1, y1, x2, y2) {
  5940. return Math.atan2(y2 - y1, x2 - x1);
  5941. }
  5942. //royal's autoplacer
  5943. this.autoPlace = function () {
  5944. if (!configs.autoPlace) return;
  5945.  
  5946. try {
  5947. if (!this.inTrap) {
  5948. if (gameObjects.length) {
  5949. let nearTrap = gameObjects
  5950. .filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5))
  5951. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))[0];
  5952.  
  5953. const isNearTrap = Boolean(nearTrap);
  5954.  
  5955. if (near.dist3 <= 450) {
  5956. if (near.dist3 <= 200) {
  5957. this.testCanPlace(4, 0, Math.PI * 2, Math.PI / 24, near.aim2, 0, { inTrap: isNearTrap });
  5958. } else if (player.items[4] === 15) {
  5959. this.testCanPlace(4, 0, Math.PI * 2, Math.PI / 24, near.aim2);
  5960. }
  5961. }
  5962. }
  5963. }
  5964. const closestTrap = gameObjects.filter(e => e.trap && e.active).sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2)).find(trap => {
  5965. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5966. return (
  5967. trap !== player &&
  5968. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5969. trapDist <= 50
  5970. );
  5971. });
  5972. } catch (e) {
  5973. console.log(e);
  5974. }
  5975. };
  5976.  
  5977. function placeSpikesAroundTrap(trapX, trapY) {
  5978. const circleRadius = 102;
  5979. const numPositions = 64;
  5980. const validPositions = [];
  5981.  
  5982. for (let i = 0; i < numPositions; i++) {
  5983. const angle = (2 * Math.PI * i) / numPositions;
  5984. const offsetX = trapX + circleRadius * Math.cos(angle);
  5985. const offsetY = trapY + circleRadius * Math.sin(angle);
  5986. const position = [offsetX, offsetY];
  5987. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5988.  
  5989. if (
  5990. !placedSpikePositions.has(JSON.stringify(position)) &&
  5991. isPositionValid(position) &&
  5992. distToPlayer <= 87
  5993. ) {
  5994. validPositions.push(position);
  5995. }
  5996. }
  5997. validPositions.sort((a, b) => {
  5998. const distA = Math.hypot(a[0] - player.x2, a[1] - player.y2);
  5999. const distB = Math.hypot(b[0] - player.x2, b[1] - player.y2);
  6000. return distA - distB;
  6001. });
  6002.  
  6003. for (const position of validPositions) {
  6004. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  6005. checkPlace(2, angleToPlace);
  6006. placedSpikePositions.add(JSON.stringify(position));
  6007. }
  6008. }
  6009.  
  6010. function placeTrapsAroundPlayer() {
  6011. const maxTrapsToPlace = 4;
  6012. const trapRadius = 50;
  6013. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  6014. let trapsPlaced = 0;
  6015.  
  6016. trapPositions.sort((a, b) => {
  6017. const distA = Math.hypot(a[0] - player.x2, a[1] - player.y2);
  6018. const distB = Math.hypot(b[0] - player.x2, b[1] - player.y2);
  6019. return distA - distB;
  6020. });
  6021.  
  6022. for (const position of trapPositions) {
  6023. if (
  6024. trapsPlaced < maxTrapsToPlace &&
  6025. !placedTrapPositions.has(JSON.stringify(position)) &&
  6026. isPositionValid(position)
  6027. ) {
  6028. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  6029. checkPlace(4, angleToPlace);
  6030. placedTrapPositions.add(JSON.stringify(position));
  6031. trapsPlaced++;
  6032. }
  6033. }
  6034. }
  6035. //codes by royal:
  6036. this.nearTrap = function () {
  6037. return gameObjects.filter(
  6038. (object) =>
  6039. object.trap &&
  6040. object.active &&
  6041. UTILS.getDist(object, player, 0, 2) <=
  6042. player.scale + object.getScale() + 5
  6043. );
  6044. };
  6045.  
  6046. this.isEnemyInTrap = function (enemy) {
  6047. let nearTraps = this.nearTrap();
  6048. return nearTraps.some(
  6049. (trap) =>
  6050. UTILS.getDist(trap, enemy, 0, 2) <= trap.getScale() + near.scale
  6051. );
  6052. };
  6053. const thing2222 = this.isEnemyInTrap();
  6054. const thing121 = !this.inTrap && thing2222 && near.dist2 <= 320;
  6055. this.doOPthing = function() {
  6056. this.testCanPlace(2, ((near.aim2 + Math.PI), Math.PI / 24));
  6057. this.testCanPlace(2, ((near.aim2 + Math.PI), Math.PI / 24));
  6058. }
  6059. this.replacer = function (findObj) {
  6060. if (!configs.autoReplace) return;
  6061. if (!findObj || !inGame) return;
  6062. const objAim = UTILS.getDirect(findObj, player, 0, 2);
  6063. const objDst = UTILS.getDist(findObj, player, 0, 2);
  6064. const weaponRange = items.weapons[player.weaponIndex].range + player.scale;
  6065. const doSpikePlace = [4, 5, 3].includes(player.weapons[0]) && near.dist2 <= 270 && player.reloads[player.weapons[0]] == 0;
  6066. const danger = this.checkSpikeTick();
  6067. const enemyDistance = UTILS.getDist(player.x, player.y, near);
  6068. const spikeDistance = UTILS.getDist(player.x, player.y, spike, 2);
  6069. const isEnemyBehindSpike = (near >= spike && near < spike);
  6070. const perfectAngle = Math.round(calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y) / (Math.PI / 2)) * (Math.PI / 2);
  6071. //let checkThing = near.primaryIndex == 7 ? 4 : 2;
  6072. if (getEl("weaponGrind").checked && objDst <= weaponRange) return;
  6073. if (thing2222 && !this.inTrap) {
  6074. if (player.primaryIndex == 7 || !instaC.canSpikeTick) {
  6075. this.testCanPlace(4, (Math.PI / 24), perfectAngle, 1);
  6076. }
  6077. }
  6078. if (thing121) {
  6079. this.doOPthing();
  6080. } else {
  6081. console.log("~wasted~ sipping on that liquid, tasted");
  6082. }
  6083. if (thing2222 && this.inTrap && near.dist2 <= 300) {
  6084. if (this.getAngleDist(near.aim2, player.angle) > Math.PI / 2) {
  6085. try {
  6086. this.testCanPlace(4, (Math.PI/ 24), (perfectAngle), 1);
  6087. } catch (e) {
  6088. console.log("your cooked");
  6089. }
  6090. }
  6091. }
  6092. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8)) {
  6093. if (isEnemyBehindSpike && enemyDistance < spikeDistance) {
  6094. UTILS.getDirect(near);
  6095. instaC.canSpikeTick = true;
  6096. } else if (spikeDistance < enemyDistance) {
  6097. UTILS.getDirect(spike);
  6098. }
  6099. }
  6100. if (!danger && near.dist2 <= 300) {
  6101. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  6102. if (thing2222) {
  6103. this.testCanPlace(4, (Math.PI / 24), perfectAngle, 1);
  6104. }
  6105. }
  6106. if (objDst <= 300 && near.dist2 <= 400) {
  6107. if (near.dist2 <= 70 && doSpikePlace) {
  6108. this.testCanPlace(2, -Math.PI / 4, Math.PI / 4, (Math.PI / 20), objAim, 1);
  6109. this.testCanPlace(4, -Math.PI / 4, Math.PI / 4, Math.PI / 12, objAim + Math.PI, 1);
  6110. } else if (player.items[4] == 15) {
  6111. this.testCanPlace(near.dist2 > 200 ? 4 : 2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  6112. }
  6113. this.replaced = true;
  6114. }
  6115. }
  6116. }
  6117. }
  6118.  
  6119. class Instakill {
  6120. constructor() {
  6121. let inantiantibull = false;
  6122. this.wait = false;
  6123. this.can = false;
  6124. this.isTrue = false;
  6125. this.nobull = false;
  6126. this.ticking = false;
  6127. this.canSpikeTick = false;
  6128. this.startTick = false;
  6129. this.readyTick = false;
  6130. this.canCounter = false;
  6131. this.revTick = false;
  6132. this.syncHit = false;
  6133. this.changeType = function(type) {
  6134. this.wait = false;
  6135. this.isTrue = true;
  6136. my.autoAim = true;
  6137. let backupNobull = near.backupNobull;
  6138. near.backupNobull = false;
  6139. setTimeout(() => {
  6140. setTimeout(() => {
  6141. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  6142. near.backupNobull = true;
  6143. }
  6144. }, 1);
  6145. }, 1);
  6146. if (type == "rev") {
  6147. selectWeapon(player.weapons[1]);
  6148. buyEquip(53, 0);
  6149. buyEquip(21, 1);
  6150. sendAutoGather();
  6151. game.tickBase(()=> {
  6152. selectWeapon(player.weapons[0]);
  6153. buyEquip(7, 0);
  6154. buyEquip(18, 1);
  6155. game.tickBase(()=> {
  6156. sendAutoGather();
  6157. this.isTrue = false;
  6158. my.autoAim = false;
  6159. }, 1);
  6160. }, 1);
  6161. } else if (type == "nobull") {
  6162. selectWeapon(player.weapons[0]);
  6163. if (getEl("backupNobull").checked && backupNobull) {
  6164. buyEquip(7, 0);
  6165. buyEquip(18, 1);
  6166. } else {
  6167. buyEquip(6, 0);
  6168. buyEquip(21, 1);
  6169. }
  6170. sendAutoGather();
  6171. setTimeout(() => {
  6172. if (near.skinIndex == 22) {
  6173. if (getEl("backupNobull").checked) {
  6174. near.backupNobull = true;
  6175. }
  6176. buyEquip(6, 0);
  6177. buyEquip(21, 1);
  6178. } else {
  6179. buyEquip(53, 0);
  6180. }
  6181. selectWeapon(player.weapons[1]);
  6182. buyEquip(21, 1);
  6183. setTimeout(() => {
  6184. sendAutoGather();
  6185. this.isTrue = false;
  6186. my.autoAim = false;
  6187. }, 255);
  6188. }, 105);
  6189. } else if (type == "normal") {
  6190. selectWeapon(player.weapons[0]);
  6191. buyEquip(7, 0);
  6192. buyEquip(18, 1);
  6193. sendAutoGather();
  6194. game.tickBase(() => {
  6195. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  6196. selectWeapon(player.weapons[1]);
  6197. buyEquip(21, 1);
  6198. setTimeout(() => {
  6199. sendAutoGather();
  6200. this.isTrue = false;
  6201. my.autoAim = false;
  6202. }, 150);
  6203. }, 1);
  6204. } else {
  6205. setTimeout(() => {
  6206. this.isTrue = false;
  6207. my.autoAim = false;
  6208. }, 50);
  6209. }
  6210. };
  6211. this.spikeTickType = function () {
  6212. this.isTrue = true;
  6213. my.autoAim = true;
  6214. selectWeapon(player.weapons[0]);
  6215. buyEquip(7, 0);
  6216. buyEquip(21, 1);
  6217. sendAutoGather();
  6218. game.tickBase(() => {
  6219. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  6220. selectWeapon(player.weapons[0]);
  6221. buyEquip(53, 0);
  6222. buyEquip(21, 1);
  6223. game.tickBase(() => {
  6224. sendAutoGather();
  6225. this.isTrue = false;
  6226. my.autoAim = false;
  6227. }, 1);
  6228. } else {
  6229. sendAutoGather();
  6230. this.isTrue = false;
  6231. my.autoAim = false;
  6232. }
  6233. }, 1);
  6234. };
  6235. this.spikeTickType = function() {
  6236. this.isTrue = true;
  6237. my.autoAim = true;
  6238. healer1();
  6239. selectWeapon(player.weapons[0]);
  6240. buyEquip(7, 0);
  6241. sendAutoGather();
  6242. game.tickBase(() => {
  6243. selectWeapon(player.weapons[0]);
  6244. buyEquip(53, 0);
  6245. game.tickBase(() => {
  6246. sendAutoGather();
  6247. this.isTrue = false;
  6248. my.autoAim = false;
  6249. }, 1);
  6250. }, 1);
  6251. };
  6252. this.counterType = function() {
  6253. this.isTrue = true;
  6254. my.autoAim = true;
  6255. buyEquip(11, 0);
  6256. selectWeapon(player.weapons[0]);
  6257. buyEquip(7, 0);
  6258. sendAutoGather();
  6259. game.tickBase(() => {
  6260. selectWeapon(player.weapons[0]);
  6261. buyEquip(53, 0);
  6262. game.tickBase(() => {
  6263. sendAutoGather();
  6264. this.isTrue = false;
  6265. my.autoAim = false;
  6266. }, 1);
  6267. }, 1);
  6268. };
  6269. this.rangeType = function(type) {
  6270. this.isTrue = true;
  6271. my.autoAim = true;
  6272. if (type == "ageInsta") {
  6273. my.ageInsta = false;
  6274. if (player.items[5] == 18) {
  6275. place(5, near.aim2);
  6276. }
  6277. packet("a", undefined, 1);
  6278. buyEquip(22, 0);
  6279. buyEquip(21, 1);
  6280. game.tickBase(() => {
  6281. selectWeapon(player.weapons[1]);
  6282. buyEquip(53, 0);
  6283. buyEquip(21, 1);
  6284. sendAutoGather();
  6285. game.tickBase(() => {
  6286. sendUpgrade(12);
  6287. selectWeapon(player.weapons[1]);
  6288. buyEquip(53, 0);
  6289. buyEquip(21, 1);
  6290. game.tickBase(() => {
  6291. sendUpgrade(15);
  6292. selectWeapon(player.weapons[1]);
  6293. buyEquip(53, 0);
  6294. buyEquip(21, 1);
  6295. game.tickBase(() => {
  6296. sendAutoGather();
  6297. this.isTrue = false;
  6298. my.autoAim = false;
  6299. }, 1);
  6300. }, 1);
  6301. }, 1);
  6302. }, 1);
  6303. } else {
  6304. selectWeapon(player.weapons[1]);
  6305. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  6306. buyEquip(53, 0);
  6307. } else {
  6308. buyEquip(20, 0);
  6309. }
  6310. buyEquip(11, 1);
  6311. sendAutoGather();
  6312. game.tickBase(() => {
  6313. sendAutoGather();
  6314. this.isTrue = false;
  6315. my.autoAim = false;
  6316. }, 1);
  6317. }
  6318. };
  6319. this.oneTickType = function() {
  6320. this.isTrue = true;
  6321. my.autoAim = true;
  6322. selectWeapon(player.weapons[1]);
  6323. buyEquip(53, 0);
  6324. buyEquip(19, 1);
  6325. packet("a", near.aim2, 1);
  6326. if (player.weapons[1] == 15) {
  6327. my.revAim = true;
  6328. sendAutoGather();
  6329. }
  6330. game.tickBase(() => {
  6331. my.revAim = false;
  6332. selectWeapon(player.weapons[0]);
  6333. buyEquip(7, 0);
  6334. buyEquip(19, 1);
  6335. packet("a", near.aim2, 1);
  6336. if (player.weapons[1] != 15) {
  6337. sendAutoGather();
  6338. }
  6339. game.tickBase(() => {
  6340. sendAutoGather();
  6341. this.isTrue = false;
  6342. my.autoAim = false;
  6343. packet("a", undefined, 1);
  6344. }, 1);
  6345. }, 1);
  6346. };
  6347. this.threeOneTickType = function() {
  6348. this.isTrue = true;
  6349. my.autoAim = true;
  6350. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6351. biomeGear();
  6352. buyEquip(11, 1);
  6353. packet("a", near.aim2, 1);
  6354. game.tickBase(() => {
  6355. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6356. buyEquip(53, 0);
  6357. buyEquip(11, 1);
  6358. packet("a", near.aim2, 1);
  6359. game.tickBase(() => {
  6360. selectWeapon(player.weapons[0]);
  6361. buyEquip(7, 0);
  6362. buyEquip(19, 1);
  6363. sendAutoGather();
  6364. packet("a", near.aim2, 1);
  6365. game.tickBase(() => {
  6366. sendAutoGather();
  6367. this.isTrue = false;
  6368. my.autoAim = false;
  6369. packet("a", undefined, 1);
  6370. }, 1);
  6371. }, 1);
  6372. }, 1);
  6373. };
  6374. this.kmTickType = function() {
  6375. this.isTrue = true;
  6376. my.autoAim = true;
  6377. my.revAim = true;
  6378. selectWeapon(player.weapons[1]);
  6379. buyEquip(53, 0);
  6380. buyEquip(11, 1);
  6381. sendAutoGather();
  6382. packet("a", near.aim2, 1);
  6383. game.tickBase(() => {
  6384. my.revAim = false;
  6385. selectWeapon(player.weapons[0]);
  6386. buyEquip(7, 0);
  6387. buyEquip(19, 1);
  6388. packet("a", near.aim2, 1);
  6389. game.tickBase(() => {
  6390. sendAutoGather();
  6391. this.isTrue = false;
  6392. my.autoAim = false;
  6393. packet("a", undefined, 1);
  6394. }, 1);
  6395. }, 1);
  6396. };
  6397. this.boostTickType = function() {
  6398. /*this.isTrue = true;
  6399. my.autoAim = true;
  6400. selectWeapon(player.weapons[0]);
  6401. buyEquip(53, 0);
  6402. buyEquip(11, 1);
  6403. packet("a", near.aim2);
  6404. game.tickBase(() => {
  6405. place(4, near.aim2);
  6406. selectWeapon(player.weapons[1]);
  6407. biomeGear();
  6408. buyEquip(11, 1);
  6409. sendAutoGather();
  6410. packet("a", near.aim2);
  6411. game.tickBase(() => {
  6412. selectWeapon(player.weapons[0]);
  6413. buyEquip(7, 0);
  6414. buyEquip(19, 1);
  6415. packet("a", near.aim2);
  6416. game.tickBase(() => {
  6417. sendAutoGather();
  6418. this.isTrue = false;
  6419. my.autoAim = false;
  6420. packet("a", undefined);
  6421. }, 1);
  6422. }, 1);
  6423. }, 1);*/
  6424. this.isTrue = true;
  6425. my.autoAim = true;
  6426. biomeGear(1);
  6427. buyEquip(11, 1);
  6428. packet("a", near.aim2, 1);
  6429. game.tickBase(() => {
  6430. if (player.weapons[1] == 15) {
  6431. my.revAim = true;
  6432. }
  6433. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  6434. buyEquip(53, 0);
  6435. buyEquip(11, 1);
  6436. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  6437. sendAutoGather();
  6438. }
  6439. packet("a", near.aim2, 1);
  6440. place(4, near.aim2);
  6441. game.tickBase(() => {
  6442. my.revAim = false;
  6443. selectWeapon(player.weapons[0]);
  6444. buyEquip(7, 0);
  6445. buyEquip(19, 1);
  6446. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  6447. sendAutoGather();
  6448. }
  6449. packet("a", near.aim2, 1);
  6450. game.tickBase(() => {
  6451. sendAutoGather();
  6452. this.isTrue = false;
  6453. my.autoAim = false;
  6454. packet("a", undefined, 1);
  6455. }, 1);
  6456. }, 1);
  6457. }, 1);
  6458. };
  6459. this.gotoGoal = function(goto, OT) {
  6460. let slowDists = (weeeee) => weeeee * config.playerScale;
  6461. let goal = {
  6462. a: goto - OT,
  6463. b: goto + OT,
  6464. c: goto - slowDists(1),
  6465. d: goto + slowDists(1),
  6466. e: goto - slowDists(2),
  6467. f: goto + slowDists(2),
  6468. g: goto - slowDists(4),
  6469. h: goto + slowDists(4)
  6470. };
  6471. let bQ = function (wwww, awwww) {
  6472. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  6473. buyEquip(31, 0);
  6474. } else {
  6475. buyEquip(wwww, awwww);
  6476. }
  6477. }
  6478. if (enemy.length) {
  6479. let dst = near.dist2;
  6480. this.ticking = true;
  6481. if (dst >= goal.a && dst <= goal.b) {
  6482. bQ(22, 0);
  6483. bQ(11, 1);
  6484. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  6485. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6486. }
  6487. return {
  6488. dir: undefined,
  6489. action: 1
  6490. };
  6491. } else {
  6492. if (dst < goal.a) {
  6493. if (dst >= goal.g) {
  6494. if (dst >= goal.e) {
  6495. if (dst >= goal.c) {
  6496. bQ(40, 0);
  6497. bQ(21, 1);
  6498. if (configs.slowOT) {
  6499. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  6500. } else {
  6501. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6502. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6503. }
  6504. }
  6505. } else {
  6506. bQ(26, 0);
  6507. bQ(21, 1);
  6508. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6509. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6510. }
  6511. }
  6512. } else {
  6513. bQ(26, 0);
  6514. bQ(12, 1);
  6515. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6516. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6517. }
  6518. }
  6519. } else {
  6520. biomeGear();
  6521. bQ(11, 1);
  6522. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6523. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6524. }
  6525. }
  6526. return {
  6527. dir: near.aim2 + Math.PI,
  6528. action: 0
  6529. };
  6530. } else if (dst > goal.b) {
  6531. if (dst <= goal.h) {
  6532. if (dst <= goal.f) {
  6533. if (dst <= goal.d) {
  6534. bQ(40, 0);
  6535. bQ(9, 1);
  6536. if (configs.slowOT) {
  6537. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  6538. } else {
  6539. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6540. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6541. }
  6542. }
  6543. } else {
  6544. bQ(22, 0);
  6545. bQ(19, 1);
  6546. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6547. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6548. }
  6549. }
  6550. } else {
  6551. bQ(6, 0);
  6552. bQ(12, 1);
  6553. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6554. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6555. }
  6556. }
  6557. } else {
  6558. biomeGear();
  6559. bQ(11, 1);
  6560. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6561. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6562. }
  6563. }
  6564. return {
  6565. dir: near.aim2,
  6566. action: 0
  6567. };
  6568. }
  6569. return {
  6570. dir: undefined,
  6571. action: 0
  6572. };
  6573. }
  6574. } else {
  6575. this.ticking = false;
  6576. return {
  6577. dir: undefined,
  6578. action: 0
  6579. };
  6580. }
  6581. }
  6582. /** wait 1 tick for better quality */
  6583. this.bowMovement = function() {
  6584. // Zkontroluj, zda je hráč připraven k útoku
  6585. if (player.reloads[53] == 0 && !this.isTrue) {
  6586. this.rangeType("ageInsta");
  6587. } else {
  6588. // Pokud není připraven, pošli paket s aktuálním směrem
  6589. packet("a", player.dir, 1);
  6590. }
  6591. }
  6592. this.tickMovement = function() {
  6593. let moveMent = this.gotoGoal(([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) ? 233 : player.weapons[1] == 15 ? 250 : player.y2 <= config.snowBiomeTop ? [10, 14].includes(player.weapons[1]) ? 227 : 235 : 250, 3);
  6594. if (moveMent.action) {
  6595. if (player.reloads[53] == 0 && !this.isTrue && this.startTick) {
  6596. this.oneTickType()
  6597. } else {
  6598. packet("a", moveMent.dir, 1);
  6599. }
  6600. } else {
  6601. packet("a", moveMent.dir, 1);
  6602. }
  6603. },
  6604. this.kmTickMovement = function() {
  6605. let moveMent = this.gotoGoal(240, 3);
  6606. if (moveMent.action) {
  6607. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  6608. this.kmTickType();
  6609. } else {
  6610. packet("a", moveMent.dir, 1);
  6611. }
  6612. } else {
  6613. packet("a", moveMent.dir, 1);
  6614. }
  6615. },
  6616. this.boostTickMovement = function() {
  6617. let dist = player.weapons[1] == 9 ? 325 : player.weapons[1] == 12 ? 355 : player.weapons[1] == 13 ? 356 : player.weapons[1] == 15 ? 340 : 326
  6618. let offset = player.weapons[1] == 9 ? 4 : player.weapons[1] == 12 ? 3 : player.weapons[1] == 13 ? 3 : player.weapons[1] == 15 ? 8 : 15
  6619. //let dist = parseInt(getEl('boosttickdistance').value)
  6620. //let offset = 3
  6621. let moveMent = this.gotoGoal(dist, offset);
  6622. if (moveMent.action) {
  6623. if (player.reloads[53] == 0 && !this.isTrue && this.readyTick) {
  6624. this.boostTickType();
  6625. } else {
  6626. packet("a", moveMent.dir, 1);
  6627. }
  6628. } else {
  6629. packet("a", moveMent.dir, 1);
  6630. }
  6631. }
  6632. /** wait 1 tick for better quality */
  6633. this.perfCheck = function(pl, nr) {
  6634. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  6635. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  6636. let pjs = {
  6637. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  6638. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  6639. };
  6640. if (UTILS.lineInRect(pl.x2 - pl.scale, pl.y2 - pl.scale, pl.x2 + pl.scale, pl.y2 + pl.scale, pjs.x, pjs.y, pjs.x, pjs.y)) {
  6641. return true;
  6642. }
  6643. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  6644. if (UTILS.lineInRect(tmp.x2 - tmp.scale, tmp.y2 - tmp.scale, tmp.x2 + tmp.scale, tmp.y2 + tmp.scale, pjs.x, pjs.y, pjs.x, pjs.y)) {
  6645. return true;
  6646. }
  6647. });
  6648. if (finds) return false;
  6649. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  6650. let tmpScale = tmp.getScale();
  6651. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, pjs.x, pjs.y, pjs.x, pjs.y)) {
  6652. return true;
  6653. }
  6654. });
  6655. if (finds) return false;
  6656. return true;
  6657. }
  6658. }
  6659. };
  6660.  
  6661. class Autobuy {
  6662. constructor(buyHat, buyAcc) {
  6663. this.hat = function() {
  6664. buyHat.forEach((id) => {
  6665. let find = findID(hats, id);
  6666. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  6667. });
  6668. };
  6669. this.acc = function() {
  6670. buyAcc.forEach((id) => {
  6671. let find = findID(accessories, id);
  6672. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  6673. });
  6674. };
  6675. }
  6676. };
  6677.  
  6678. class Autoupgrade {
  6679. constructor() {
  6680. this.sb = function(upg) {
  6681. upg(3);
  6682. upg(17);
  6683. upg(31);
  6684. upg(23);
  6685. upg(9);
  6686. upg(38);
  6687. };
  6688. this.kh = function(upg) {
  6689. upg(3);
  6690. upg(17);
  6691. upg(31);
  6692. upg(23);
  6693. upg(10);
  6694. upg(38);
  6695. upg(4);
  6696. upg(25);
  6697. };
  6698. this.pb = function(upg) {
  6699. upg(5);
  6700. upg(17);
  6701. upg(32);
  6702. upg(23);
  6703. upg(9);
  6704. upg(38);
  6705. };
  6706. this.ph = function(upg) {
  6707. upg(5);
  6708. upg(17);
  6709. upg(32);
  6710. upg(23);
  6711. upg(10);
  6712. upg(38);
  6713. upg(28);
  6714. upg(25);
  6715. };
  6716. this.db = function(upg) {
  6717. upg(7);
  6718. upg(17);
  6719. upg(31);
  6720. upg(23);
  6721. upg(9);
  6722. upg(34);
  6723. };
  6724. /* old functions */
  6725. this.km = function(upg) {
  6726. upg(7);
  6727. upg(17);
  6728. upg(31);
  6729. upg(23);
  6730. upg(10);
  6731. upg(38);
  6732. upg(4);
  6733. upg(15);
  6734. };
  6735. };
  6736. };
  6737.  
  6738. class Damages {
  6739. constructor(items) {
  6740. // 0.75 1 1.125 1.5
  6741. this.calcDmg = function(dmg, val) {
  6742. return dmg * val;
  6743. };
  6744. this.getAllDamage = function(dmg) {
  6745. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  6746. };
  6747. this.weapons = [];
  6748. for (let i = 0; i < items.weapons.length; i++) {
  6749. let wp = items.weapons[i];
  6750. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  6751. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  6752. this[name] = this.weapons[i];
  6753. }
  6754. }
  6755. }
  6756.  
  6757. /** CLASS CODES */
  6758. // jumpscare code warn
  6759. let tmpList = [];
  6760.  
  6761. // LOADING:
  6762. let UTILS = new Utils();
  6763. let items = new Items();
  6764. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6765. let store = new Store();
  6766. let hats = store.hats;
  6767. let accessories = store.accessories;
  6768. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6769. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6770. let textManager = new Textmanager();
  6771.  
  6772. let traps = new Traps(UTILS, items);
  6773. let instaC = new Instakill();
  6774. let autoBuy = new Autobuy([40, 6, 7, 22, 53, 15, 31], [11, 21, 18, 13]);
  6775. let autoUpgrade = new Autoupgrade();
  6776.  
  6777. let lastDeath;
  6778. let minimapData;
  6779. let mapMarker = {};
  6780. let mapPings = [];
  6781. let tmpPing;
  6782.  
  6783. let antiinsta = true;
  6784. let antiinsta1 = false;
  6785.  
  6786. let breakTrackers = [];
  6787.  
  6788. function sendChat(message) {
  6789. packet("6", message.slice(0, 30));
  6790. }
  6791. let runAtNextTick = [];
  6792.  
  6793. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6794. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6795. let projOffset = config.playerScale * 2;
  6796. let projXY = {
  6797. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6798. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6799. };
  6800. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6801. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6802. })[0];
  6803. if (nearPlayer) {
  6804. if (indx == 1) {
  6805. nearPlayer.shooting[53] = 1;
  6806. } else {
  6807. nearPlayer.shootIndex = weaponIndx;
  6808. nearPlayer.shooting[1] = 1;
  6809. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6810. }
  6811. }
  6812. }
  6813. let projectileCount = 0;
  6814.  
  6815. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6816. if (!tmpObj.isTeam(player)) {
  6817. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6818. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6819. tmpObj.bowThreat[weaponIndex]++;
  6820. if (index == 5) {
  6821. projectileCount++;
  6822. }
  6823. setTimeout(() => {
  6824. tmpObj.bowThreat[weaponIndex]--;
  6825. if (index == 5) {
  6826. projectileCount--;
  6827. }
  6828. }, range / speed);
  6829. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6830. place(1, tmpObj.aim2);
  6831. my.anti0Tick = 4;
  6832. if (!my.antiSync) {
  6833. antiSyncHealing(4);
  6834. }
  6835. } else {
  6836. if (projectileCount >= 2) {
  6837. place(1, tmpObj.aim2);
  6838. healer();
  6839. sendChat("");
  6840. buyEquip(22, 0);
  6841. buyEquip(13, 1);
  6842. my.anti0Tick = 4;
  6843. if (!my.antiSync) {
  6844. antiSyncHealing(4);
  6845. }
  6846. } else {
  6847. if (projectileCount === 1) { // anti reverse or anti 1 tick with reaper
  6848. buyEquip(6, 0);
  6849. buyEquip(13, 1);
  6850. }
  6851. /*} else {
  6852. if (projectileCount >= 2) { // anti sync линия обороны N1
  6853. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  6854. player.chat.message = "pSyD";
  6855. healer();
  6856. buyEquip(6, 0);
  6857. }
  6858. }*/
  6859. }
  6860. }
  6861. }
  6862. }
  6863. }
  6864.  
  6865. // SHOW ITEM INFO:
  6866. function showItemInfo(item, isWeapon, isStoreItem) {
  6867. if (player && item) {
  6868. UTILS.removeAllChildren(itemInfoHolder);
  6869. itemInfoHolder.classList.add("visible");
  6870. UTILS.generateElement({
  6871. id: "itemInfoName",
  6872. text: UTILS.capitalizeFirst(item.name),
  6873. parent: itemInfoHolder
  6874. });
  6875. UTILS.generateElement({
  6876. id: "itemInfoDesc",
  6877. text: item.desc,
  6878. parent: itemInfoHolder
  6879. });
  6880. if (isStoreItem) {
  6881.  
  6882. } else if (isWeapon) {
  6883. UTILS.generateElement({
  6884. class: "itemInfoReq",
  6885. text: !item.type ? "primary" : "secondary",
  6886. parent: itemInfoHolder
  6887. });
  6888. } else {
  6889. for (let i = 0; i < item.req.length; i += 2) {
  6890. UTILS.generateElement({
  6891. class: "itemInfoReq",
  6892. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6893. parent: itemInfoHolder
  6894. });
  6895. }
  6896. if (item.group.limit) {
  6897. UTILS.generateElement({
  6898. class: "itemInfoLmt",
  6899. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6900. parent: itemInfoHolder
  6901. });
  6902. }
  6903. }
  6904. } else {
  6905. itemInfoHolder.classList.remove("visible");
  6906. }
  6907. }
  6908.  
  6909. // RESIZE:
  6910. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6911.  
  6912. function resize() {
  6913. screenWidth = window.innerWidth;
  6914. screenHeight = window.innerHeight;
  6915. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6916. gameCanvas.width = screenWidth * pixelDensity;
  6917. gameCanvas.height = screenHeight * pixelDensity;
  6918. gameCanvas.style.width = screenWidth + "px";
  6919. gameCanvas.style.height = screenHeight + "px";
  6920. mainContext.setTransform(
  6921. scaleFillNative, 0,
  6922. 0, scaleFillNative,
  6923. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  6924. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  6925. );
  6926. }
  6927. resize();
  6928.  
  6929. // MOUSE INPUT:
  6930. var usingTouch;
  6931. const mals = document.getElementById('touch-controls-fullscreen');
  6932. mals.style.display = 'block';
  6933. mals.addEventListener("mousemove", gameInput, false);
  6934.  
  6935. function gameInput(e) {
  6936. mouseX = e.clientX;
  6937. mouseY = e.clientY;
  6938. }
  6939. let clicks = {
  6940. left: false,
  6941. middle: false,
  6942. right: false,
  6943. };
  6944. mals.addEventListener("mousedown", mouseDown, false);
  6945.  
  6946. function mouseDown(e) {
  6947. if (attackState != 1) {
  6948. attackState = 1;
  6949. if (e.button == 0) {
  6950. clicks.left = true;
  6951. } else if (e.button == 1) {
  6952. clicks.middle = true;
  6953. } else if (e.button == 2) {
  6954. clicks.right = true;
  6955. }
  6956. }
  6957. }
  6958. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6959.  
  6960. function mouseUp(e) {
  6961. if (attackState != 0) {
  6962. attackState = 0;
  6963. if (e.button == 0) {
  6964. clicks.left = false;
  6965. } else if (e.button == 1) {
  6966. clicks.middle = false;
  6967. } else if (e.button == 2) {
  6968. clicks.right = false;
  6969. }
  6970. }
  6971. }
  6972. mals.addEventListener("wheel", wheel, false);
  6973.  
  6974. function wheel(e) {
  6975. if(player.shameCount > 1) {
  6976. buyEquip(7, 0);
  6977. } else {
  6978. buyEquip(6, 0);
  6979. }
  6980. }
  6981.  
  6982.  
  6983. // INPUT UTILS:
  6984. function getMoveDir() {
  6985. let dx = 0;
  6986. let dy = 0;
  6987. for (let key in moveKeys) {
  6988. let tmpDir = moveKeys[key];
  6989. dx += !!keys[key] * tmpDir[0];
  6990. dy += !!keys[key] * tmpDir[1];
  6991. }
  6992. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6993. }
  6994.  
  6995. function getSafeDir() {
  6996. if (!player)
  6997. return 0;
  6998. if (!player.lockDir) {
  6999. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  7000. }
  7001. return lastDir || 0;
  7002. }
  7003. function SpikeX() {
  7004. let spike;
  7005. if (near.dist2 > 270 && !my.autoPush && enemy.length) {
  7006. if (traps.inTrap) {
  7007. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7008. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7009. })[0];
  7010. }
  7011. } else {
  7012. if (traps.inTrap) {
  7013. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7014. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7015. })[0];
  7016. }
  7017. }
  7018. if (spike) {
  7019. return spike.x;
  7020. }
  7021. }
  7022. function SpikeY() {
  7023. let spike;
  7024. if (near.dist2 > 230 && !my.autoPush && enemy.length) {
  7025. if (traps.inTrap) {
  7026. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7027. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7028. })[0];
  7029. }
  7030. } else {
  7031. if (traps.inTrap) {
  7032. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7033. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7034. })[0];
  7035. }
  7036. }
  7037. if (spike) {
  7038. return spike.y;
  7039. }
  7040. }
  7041. function SpikeDir() {
  7042. let spike;
  7043. if ((near.dist2 > 350 || !enemy.length) && !my.autoPush && enemy.length) {
  7044. if (traps.inTrap) {
  7045. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7046. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7047. })[0];
  7048. }
  7049. } else {
  7050. if (traps.inTrap) {
  7051. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7052. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7053. })[0];
  7054. }
  7055. }
  7056. if (spike) {
  7057. let aim = UTILS.getDirect(spike, player, 0, 2);
  7058. return aim;
  7059. } else {
  7060. return lastDir || 0;
  7061. }
  7062. }
  7063. let plusDir = 0;
  7064. let lastSpin = Date.now();
  7065. function getAttackDir(debug) {
  7066. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  7067. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7068. })[0];
  7069. if (debug) {
  7070. if (!player)
  7071. return "0";
  7072. if (my.autoAim || ((clicks.left || (useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap)) && player.reloads[player.weapons[0]] == 0))
  7073. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  7074. else
  7075. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  7076. lastDir = "getSafeDir()";
  7077. else
  7078. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  7079. lastDir = "traps.aim";
  7080. else
  7081. if (!player.lockDir) {
  7082. if (configs.noDir) return "undefined";
  7083. lastDir = "getSafeDir()";
  7084. }
  7085. return lastDir;
  7086. } else {
  7087. if (!player)
  7088. return 0;
  7089. if (my.autoAim || ((clicks.left || (useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap)) && player.reloads[player.weapons[0]] == 0))
  7090. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  7091. else
  7092. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  7093. lastDir = getSafeDir();
  7094. else
  7095. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !spike)
  7096. lastDir = traps.aim;
  7097. else
  7098. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && spike) {
  7099. doSpikeRedThingmajic = true;
  7100. lastDir = SpikeDir();
  7101. } else
  7102. if (!player.lockDir) {
  7103. if (configs.noDir) return undefined;
  7104. lastDir = getSafeDir();
  7105. }
  7106. return lastDir || 0;
  7107. }
  7108. }
  7109.  
  7110. function getVisualDir() {
  7111. if (!player)
  7112. return 0;
  7113. lastDir = getSafeDir();
  7114. return lastDir || 0;
  7115. }
  7116.  
  7117. // KEYS:
  7118. function keysActive() {
  7119. return (allianceMenu.style.display != "block" &&
  7120. chatHolder.style.display != "block" &&
  7121. !menuCBFocus);
  7122. }
  7123.  
  7124. function toggleMenuChat() {
  7125. if (menuChatDiv.style.display != "none") {
  7126. // chatHolder.style.display = "none";
  7127. // if (menuChatBox.value != "") {
  7128. //commands[command.slice(1)]
  7129. let cmd = function(command) {
  7130. return {
  7131. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  7132. fv: commands[command.slice(1).split(" ")[0]]
  7133. }
  7134. }
  7135. let command = cmd(menuChatBox.value);
  7136. if (command.found) {
  7137. if (typeof command.fv.action === "function") {
  7138. command.fv.action(menuChatBox.value);
  7139. }
  7140. } else {
  7141. sendChat(menuChatBox.value);
  7142. }
  7143. menuChatBox.value = "";
  7144. menuChatBox.blur();
  7145. } else {
  7146. if (menuCBFocus) {
  7147. menuChatBox.blur();
  7148. } else {
  7149. menuChatBox.focus();
  7150. }
  7151. }
  7152. }
  7153.  
  7154. function keyDown(event) {
  7155. let keyNum = event.which || event.keyCode || 0;
  7156. if (player && player.alive && keysActive()) {
  7157. if (!keys[keyNum]) {
  7158. keys[keyNum] = 1;
  7159. macro[event.key] = 1;
  7160. if (event.key == "Escape") {
  7161. openMenu = openMenu;
  7162. $("#menuDiv").toggle();
  7163. $("#menuChatDiv").toggle();
  7164. } else if (keyNum == 69) {
  7165. sendAutoGather();
  7166. } else if (keyNum == 67) {
  7167. updateMapMarker();
  7168. } else if (player.weapons[keyNum - 49] != undefined) {
  7169. player.weaponCode = player.weapons[keyNum - 49];
  7170. } else if (moveKeys[keyNum]) {
  7171. sendMoveDir();
  7172. } else if (event.key == "m") {
  7173. mills.placeSpawnPads = !mills.placeSpawnPads;
  7174. } else if (event.key == "z") {
  7175. mills.place = !mills.place;
  7176. } else if (event.key == "Z") {
  7177. typeof window.debug == "function" && window.debug();
  7178. } else if (keyNum == 32) {
  7179. packet("d", 1, getSafeDir(), 1);
  7180. packet("d", 0, getSafeDir(), 1);
  7181. } else if (event.key == ",") {
  7182. io.send("6", 'syncon')
  7183. project.send(JSON.stringify(["tezt", "ratio"]));
  7184. // botSkts.push([botPlayer]);
  7185. for(let i = 0; i < botz.length; i++) {
  7186. // if(botz[i][0]) {
  7187. botz[i][0].zync(near);
  7188. console.log(botz[i][0])
  7189. }
  7190. // project.send("tezt");
  7191. // botSkts.forEach((bot) => {
  7192. // bot.zync();
  7193. // })
  7194. // io.send("S", 1)
  7195. }
  7196. }
  7197. }
  7198. }
  7199. function doOneFrame() {
  7200. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && near.skinIndex != 6) {
  7201. buyEquip(53, 0);
  7202. selectWeapon(player.weapons[0]);
  7203. game.tickBase(() => {
  7204. buyEquip(7, 0);
  7205. sendAutoGather();
  7206. }, 1);
  7207. }
  7208. }
  7209. /*function doBoostTick() {
  7210. if (near.dist2 >= 340 && near.dist2 <= 430 && [13].includes(player.secondaryIndex)) {
  7211. buyEquip(53, 0);
  7212. selectWeapon(player.weapons[1]);
  7213. sendAutoGather();
  7214. place(4, near.aim2);
  7215. game.tickBase(() => {
  7216. selectWeapon(player.weapons[0]);
  7217. sendAutoGather();
  7218. }, 1);
  7219. }
  7220. }*/
  7221. // let xx = canvaz.width/2;
  7222. // let yy = canvaz.height/2;
  7223.  
  7224. // let mouze = {
  7225. // x: xx - mouzeX,
  7226. // y: yy - mouzeY
  7227. // }
  7228.  
  7229. // let ingamecoorformodabow = {
  7230. // x: player.x + mouze.x,
  7231. // y: player.x + mouze.x
  7232. // }
  7233.  
  7234. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  7235.  
  7236. function keyUp(event) {
  7237. if (player && player.alive) {
  7238. let keyNum = event.which || event.keyCode || 0;
  7239. if (keyNum == 13) {
  7240. toggleMenuChat();
  7241. } else if (keysActive()) {
  7242. if (keys[keyNum]) {
  7243. keys[keyNum] = 0;
  7244. macro[event.key] = 0;
  7245. if (moveKeys[keyNum]) {
  7246. sendMoveDir();
  7247. } else if (event.key == ",") {
  7248. player.sync = false;
  7249. }
  7250. }
  7251. }
  7252. }
  7253. }
  7254.  
  7255.  
  7256. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  7257.  
  7258. function sendMoveDir() {
  7259. if(found) {
  7260. packet("a", undefined, 1);
  7261. } else {
  7262. let newMoveDir = getMoveDir();
  7263. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  7264. if (!my.autoPush && !found) {
  7265. packet("a", newMoveDir, 1);
  7266. }
  7267. lastMoveDir = newMoveDir;
  7268. }
  7269. }
  7270. }
  7271.  
  7272. // BUTTON EVENTS:
  7273. function bindEvents() {}
  7274. bindEvents();
  7275.  
  7276. // ITEM COUNT DISPLAY:
  7277. let isItemSetted = [];
  7278.  
  7279. function updateItemCountDisplay(index = undefined) {
  7280. for (let i = 3; i < items.list.length; ++i) {
  7281. let id = items.list[i].group.id;
  7282. let tmpI = items.weapons.length + i;
  7283. if (!isItemSetted[tmpI]) {
  7284. isItemSetted[tmpI] = document.createElement("div");
  7285. isItemSetted[tmpI].id = "itemCount" + tmpI;
  7286. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  7287. isItemSetted[tmpI].style = `
  7288. display: block;
  7289. position: absolute;
  7290. padding-left: 5px;
  7291. font-size: 2em;
  7292. color: #fff;
  7293. `;
  7294. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  7295. } else {
  7296. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  7297. }
  7298. }
  7299. }
  7300.  
  7301. // AUTOPUSH:
  7302. var retrappable = false;
  7303. function autoPush() {
  7304. retrappable = true;
  7305. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  7306. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7307. })[0];
  7308. if (nearTrap) {
  7309. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  7310. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7311. })[0];
  7312. if (spike) {
  7313. let pos = {
  7314. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  7315. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  7316. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  7317. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  7318. };
  7319. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  7320. let tmpScale = tmp.getScale();
  7321. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, player.x2, player.y2, pos.x2, pos.y2)) {
  7322. return true;
  7323. }
  7324. });
  7325. if (finds) {
  7326. if (my.autoPush) {
  7327. my.autoPush = false;
  7328. packet("a", lastMoveDir || undefined, 1);
  7329. }
  7330. } else {
  7331. my.autoPush = true;
  7332. my.pushData = {
  7333. x: spike.x,
  7334. y: spike.y,
  7335. x2: pos.x2,
  7336. y2: pos.y2
  7337. };
  7338. let scale = (player.scale / 10);
  7339. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  7340. packet("a", near.aim2, 1);
  7341. } else {
  7342. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  7343. }
  7344. }
  7345. } else {
  7346. if (my.autoPush) {
  7347. my.autoPush = false;
  7348. packet("a", lastMoveDir || undefined, 1);
  7349. }
  7350. }
  7351. } else {
  7352. if (my.autoPush) {
  7353. my.autoPush = false;
  7354. packet("a", lastMoveDir || undefined, 1);
  7355. }
  7356. }
  7357. }
  7358.  
  7359. // ADD DEAD PLAYER:
  7360. function addDeadPlayer(tmpObj) {
  7361. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  7362. }
  7363.  
  7364. /** APPLY SOCKET CODES */
  7365.  
  7366. // SET INIT DATA:
  7367. function setInitData(data) {
  7368. alliances = data.teams;
  7369. }
  7370.  
  7371. // SETUP GAME:
  7372. function setupGame(yourSID) {
  7373. keys = {};
  7374. macro = {};
  7375. playerSID = yourSID;
  7376. attackState = 0;
  7377. inGame = true;
  7378. packet("d", 0, getAttackDir(), 1);
  7379. my.ageInsta = true;
  7380. if (firstSetup) {
  7381. firstSetup = false;
  7382. gameObjects.length = 0;
  7383. liztobj.length = 0;
  7384. }
  7385. }
  7386.  
  7387. // ADD NEW PLAYER:
  7388. function addPlayer(data, isYou) {
  7389. let tmpPlayer = findPlayerByID(data[0]);
  7390. if (!tmpPlayer) {
  7391. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  7392. objectManager, players, ais, items, hats, accessories);
  7393. players.push(tmpPlayer);
  7394. if (data[1] != playerSID) {
  7395. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  7396. }
  7397. } else {
  7398. if (data[1] != playerSID) {
  7399. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  7400. }
  7401. }
  7402. tmpPlayer.spawn(isYou ? true : null);
  7403. tmpPlayer.visible = false;
  7404. tmpPlayer.oldPos = {
  7405. x2: undefined,
  7406. y2: undefined
  7407. };
  7408. tmpPlayer.x2 = undefined;
  7409. tmpPlayer.y2 = undefined;
  7410. tmpPlayer.x3 = undefined;
  7411. tmpPlayer.y3 = undefined;
  7412. tmpPlayer.setData(data);
  7413. if (isYou) {
  7414. if (!player) {
  7415. window.prepareUI(tmpPlayer);
  7416. }
  7417. player = tmpPlayer;
  7418. camX = player.x;
  7419. camY = player.y;
  7420. my.lastDir = 0;
  7421. updateItems();
  7422. updateAge();
  7423. updateItemCountDisplay();
  7424. if (player.skins[7]) {
  7425. my.reSync = true;
  7426. }
  7427. }
  7428. }
  7429.  
  7430. // REMOVE PLAYER:
  7431. function removePlayer(id) {
  7432. for (let i = 0; i < players.length; i++) {
  7433. if (players[i].id == id) {
  7434. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  7435. players.splice(i, 1);
  7436. break;
  7437. }
  7438. }
  7439. }
  7440.  
  7441. // UPDATE HEALTH:
  7442. function updateHealth(sid, value) {
  7443. tmpObj = findPlayerBySID(sid);
  7444. if (tmpObj) {
  7445. tmpObj.oldHealth = tmpObj.health;
  7446. tmpObj.health = value;
  7447. tmpObj.judgeShame();
  7448. if (tmpObj.oldHealth > tmpObj.health) {
  7449. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  7450. let damaged = tmpObj.damaged;
  7451. tmpObj = findPlayerBySID(sid);
  7452. let bullTicked = false;
  7453. if (tmpObj == player) {
  7454. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7455. if (my.reSync) {
  7456. my.reSync = false;
  7457. tmpObj.setBullTick = true;
  7458. }
  7459. bullTicked = true;
  7460. }
  7461. if (inGame) {
  7462. advHeal.push([sid, value, tmpObj.damaged]);
  7463. } else {
  7464. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7465. tmpObj.setPoisonTick = true;
  7466. }
  7467. }
  7468. } else {
  7469. if(tmpObj != player) {
  7470. if(tmpObj.maxShameCount < tmpObj.shameCount) {
  7471. tmpObj.maxShameCount = tmpObj.shameCount;
  7472. }
  7473. }
  7474. }
  7475. }
  7476. }
  7477. }
  7478.  
  7479. // KILL PLAYER:
  7480. function killPlayer() {
  7481. inGame = false;
  7482. lastDeath = {
  7483. x: player.x,
  7484. y: player.y,
  7485. };
  7486. }
  7487.  
  7488. // UPDATE PLAYER ITEM VALUES:
  7489. function updateItemCounts(index, value) {
  7490. if (player) {
  7491. player.itemCounts[index] = value;
  7492. updateItemCountDisplay(index);
  7493. }
  7494. }
  7495.  
  7496. // UPDATE AGE:
  7497. function updateAge(xp, mxp, age) {
  7498. if (xp != undefined) {
  7499. player.XP = xp;
  7500. }
  7501. if (mxp != undefined) {
  7502. player.maxXP = mxp;
  7503. }
  7504. if (age != undefined) {
  7505. player.age = age;
  7506. }
  7507. }
  7508.  
  7509. // UPDATE UPGRADES:
  7510. function updateUpgrades(points, age) {
  7511. player.upgradePoints = points;
  7512. player.upgrAge = age;
  7513. if (points > 0) {
  7514. tmpList.length = 0;
  7515. UTILS.removeAllChildren(upgradeHolder);
  7516. for (let i = 0; i < items.weapons.length; ++i) {
  7517. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  7518. let e = UTILS.generateElement({
  7519. id: "upgradeItem" + i,
  7520. class: "actionBarItem",
  7521. onmouseout: function() {
  7522. showItemInfo();
  7523. },
  7524. parent: upgradeHolder
  7525. });
  7526. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  7527. tmpList.push(i);
  7528. }
  7529. }
  7530. for (let i = 0; i < items.list.length; ++i) {
  7531. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  7532. let tmpI = (items.weapons.length + i);
  7533. let e = UTILS.generateElement({
  7534. id: "upgradeItem" + tmpI,
  7535. class: "actionBarItem",
  7536. onmouseout: function() {
  7537. showItemInfo();
  7538. },
  7539. parent: upgradeHolder
  7540. });
  7541. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  7542. tmpList.push(tmpI);
  7543. }
  7544. }
  7545. for (let i = 0; i < tmpList.length; i++) {
  7546. (function(i) {
  7547. let tmpItem = getEl('upgradeItem' + i);
  7548. // tmpItem.onmouseover = function() {
  7549. // if (items.weapons[i]) {
  7550. // showItemInfo(items.weapons[i], true);
  7551. // } else {
  7552. // showItemInfo(items.list[i - items.weapons.length]);
  7553. // }
  7554. // };
  7555. tmpItem.onclick = UTILS.checkTrusted(function() {
  7556. packet("H", i);
  7557. });
  7558. UTILS.hookTouchEvents(tmpItem);
  7559. })(tmpList[i]);
  7560. }
  7561. if (tmpList.length) {
  7562. upgradeHolder.style.display = "block";
  7563. upgradeCounter.style.display = "block";
  7564. upgradeCounter.innerHTML = "";
  7565. } else {
  7566. upgradeHolder.style.display = "none";
  7567. upgradeCounter.style.display = "none";
  7568. showItemInfo();
  7569. }
  7570. } else {
  7571. upgradeHolder.style.display = "none";
  7572. upgradeCounter.style.display = "none";
  7573. showItemInfo();
  7574. }
  7575. }
  7576. function toR(e) {
  7577. var n = ((e * Math.PI) / 180) % (2 * Math.PI);
  7578. return n > Math.PI ? Math.PI - n : n;
  7579. }
  7580. function getDist(e, t) {
  7581. try {
  7582. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7583. } catch (e) {
  7584. return Infinity;
  7585. }
  7586. }
  7587. // GET DIRECTION
  7588. function getDir(e, t) {
  7589. try {
  7590. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7591. } catch (e) {
  7592. return 0;
  7593. }
  7594. }
  7595. function cdf(e, t) {
  7596. try {
  7597. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7598. } catch (e) {
  7599. return Infinity;
  7600. }
  7601. }
  7602. function caf(e, t) {
  7603. try {
  7604. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7605. } catch (e) {
  7606. return 0;
  7607. }
  7608. }
  7609. function toD(e) {
  7610. var n = (e / Math.PI * 360) % 360;
  7611. return n >= 360 ? n - 360 : n;
  7612. }
  7613.  
  7614.  
  7615. /* function caf(e, t) {
  7616. try {
  7617. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7618. } catch (e) {
  7619. return 0;
  7620. }
  7621. }
  7622. */
  7623.  
  7624. // KILL OBJECT:
  7625. function killObject(sid) {
  7626. let findObj = findObjectBySid(sid);
  7627. objectManager.disableBySid(sid);
  7628. if (player) {
  7629. for (let i = 0; i < breakObjects.length; i++) {
  7630. if (breakObjects[i].sid == sid) {
  7631. breakObjects.splice(i, 1);
  7632. break;
  7633. }
  7634. }
  7635. if (!player.canSee(findObj)) {
  7636. breakTrackers.push({
  7637. x: findObj.x,
  7638. y: findObj.y
  7639. });
  7640. }
  7641. if (breakTrackers.length > 8) {
  7642. breakTrackers.shift();
  7643. }
  7644. for (let position of placedSpikePositions) {
  7645. let storedPosition = JSON.parse(position);
  7646. let distToStoredPosition = Math.hypot(storedPosition[0] - findObj.x, storedPosition[1] - findObj.y);
  7647. if (distToStoredPosition <= 80) {
  7648. placedSpikePositions.delete(position);
  7649. break;
  7650. }
  7651. }
  7652. traps.replacer(findObj);
  7653. }
  7654. }
  7655.  
  7656. // KILL ALL OBJECTS BY A PLAYER:
  7657. function killObjects(sid) {
  7658. if (player) objectManager.removeAllItems(sid);
  7659. }
  7660. function setTickout(doo, timeout) {
  7661. if (!ticks.manage[ticks.tick + timeout]) {
  7662. ticks.manage[ticks.tick + timeout] = [doo];
  7663. } else {
  7664. ticks.manage[ticks.tick + timeout].push(doo);
  7665. }
  7666. }
  7667.  
  7668. // GAME TICKOUT:
  7669. function doNextTick(doo) {
  7670. waitTicks.push(doo);
  7671. }
  7672. let waitTicks = [];
  7673. let placeableSpikes = [];
  7674. let placeableTraps = [];
  7675. let placeableSpikesPREDICTS = [];
  7676. let spike = gameObjects.filter(obj => (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "spinning spikes" || obj.name == "poison spikes") && fgdo(player, obj) < player.scale + obj.scale + 22 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  7677.  
  7678. let reset = false
  7679. function fgdo(a, b) {
  7680. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  7681. }
  7682. /* function addFunction(action, tick) {//setTimeout per tick
  7683. if (typeof action != "function") {
  7684. return;
  7685. }
  7686. if (typeof queueTick[tC + tick] != "object") {
  7687. queueTick[tC + tick] = [action];
  7688. } else {
  7689. queueTick[tC + tick].push(action);
  7690. }
  7691. }
  7692. function addPunction(action, tick) {//setTimeout per tick
  7693. if (typeof action != "function") {
  7694. return;
  7695. }
  7696. if (typeof queuePackets[tC + tick] != "object") {
  7697. queuePackets[tC + tick] = [action];
  7698. } else {
  7699. queuePackets[tC + tick].push(action);
  7700. }
  7701. }*/
  7702.  
  7703.  
  7704. let found = false;
  7705. let autoQ = false;
  7706.  
  7707. let autos = {
  7708. insta: {
  7709. todo: false,
  7710. wait: false,
  7711. count: 4,
  7712. shame: 5
  7713. },
  7714. bull: false,
  7715. antibull: 0,
  7716. reloaded: false,
  7717. stopspin: true
  7718. }
  7719.  
  7720. // UPDATE PLAYER DATA:
  7721. function updatePlayers(data) {
  7722.  
  7723. if (player.shameCount > 0) {
  7724. my.reSync = true;
  7725. } else {
  7726. my.reSync = false;
  7727. }
  7728.  
  7729.  
  7730. // let movementPrediction = {
  7731. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7732. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7733. // }
  7734.  
  7735. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  7736.  
  7737. // potentialzpiketick.forEach((obj) => {
  7738. // if(cdf(obj, player) <= 200) {
  7739. // packet('a', undefined);
  7740. // }
  7741. // })
  7742.  
  7743. // let newPos = {
  7744. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  7745. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  7746. // }
  7747.  
  7748. function getAngleDifference(angle1, angle2) {
  7749. // Normalize the angles to be between 0 and 2π
  7750. angle1 = angle1 % (2 * Math.PI);
  7751. angle2 = angle2 % (2 * Math.PI);
  7752.  
  7753. // Calculate the absolute difference between the angles
  7754. let diff = Math.abs(angle1 - angle2);
  7755.  
  7756. // Adjust the difference to be between 0 and π
  7757. if (diff > Math.PI) {
  7758. diff = (2 * Math.PI) - diff;
  7759. }
  7760.  
  7761. return diff;
  7762. }
  7763.  
  7764. // function smartMove(oneTickMove) {
  7765. // let dir = player.moveDir;
  7766.  
  7767. // let found = false
  7768. // let buildings = liztobj.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x))
  7769. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  7770.  
  7771. // let newPos = {
  7772. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  7773. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  7774. // }
  7775.  
  7776. // for (let i = 0; i < spikes.length; i++) {
  7777. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  7778. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  7779. // }
  7780. // }
  7781.  
  7782.  
  7783.  
  7784.  
  7785.  
  7786. // if (found != false && !traps.inTrap) {
  7787. // packet("f", undefined);
  7788. // } else {
  7789. // packet("f", dir);
  7790. // }
  7791. // player.oldPos.x2 = player.x2;
  7792. // player.oldPos.y2 = player.y2;
  7793. // }
  7794. // function detectEnemySpikeCollisions(tmpObj) {
  7795. // let buildings = liztobj.sort((a, b) => Math.hypot(tmpObj.y - a.y, tmpObj.x - a.x) - Math.hypot(tmpObj.y - b.y, tmpObj.x - b.x));
  7796. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  7797. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  7798. // let enemy = {
  7799. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  7800. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  7801. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7802. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7803. // }
  7804. // let found = false;
  7805. // for (let i = 0; i < spikes.length; i++) {
  7806. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  7807. // found = true;
  7808. // }
  7809. // }
  7810.  
  7811. // // player.oldPos.x2 = tmpObj.x2;
  7812. // // player.oldPos.y2 = tmpObj.y2;
  7813. // }
  7814.  
  7815. game.tick++;
  7816. enemy = [];
  7817. nears = [];
  7818. near = [];
  7819. game.tickSpeed = performance.now() - game.lastTick;
  7820. game.lastTick = performance.now();
  7821. players.forEach((tmp) => {
  7822. tmp.forcePos = !tmp.visible;
  7823. tmp.visible = false;
  7824. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  7825. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  7826. });
  7827. for (let i = 0; i < data.length;) {
  7828. tmpObj = findPlayerBySID(data[i]);
  7829. if (tmpObj) {
  7830. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7831. tmpObj.t2 = game.lastTick;
  7832. tmpObj.oldPos.x2 = tmpObj.x2;
  7833. tmpObj.oldPos.y2 = tmpObj.y2;
  7834. tmpObj.x1 = tmpObj.x;
  7835. tmpObj.y1 = tmpObj.y;
  7836. tmpObj.x2 = data[i + 1];
  7837. tmpObj.y2 = data[i + 2];
  7838. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7839. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7840. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7841. tmpObj.d2 = data[i + 3];
  7842. tmpObj.dt = 0;
  7843. tmpObj.buildIndex = data[i + 4];
  7844. tmpObj.weaponIndex = data[i + 5];
  7845. tmpObj.weaponVariant = data[i + 6];
  7846. tmpObj.team = data[i + 7];
  7847. tmpObj.isLeader = data[i + 8];
  7848. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7849. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7850. tmpObj.skinIndex = data[i + 9];
  7851. tmpObj.tailIndex = data[i + 10];
  7852. tmpObj.iconIndex = data[i + 11];
  7853. tmpObj.zIndex = data[i + 12];
  7854. tmpObj.visible = true;
  7855. tmpObj.update(game.tickSpeed);
  7856. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7857. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7858. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7859. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7860. tmpObj.damageThreat = 0;
  7861. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7862. tmpObj.addShameTimer();
  7863. }
  7864. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7865. tmpObj.shameTimer = 0;
  7866. tmpObj.shameCount = 0;
  7867. if (tmpObj == player) {
  7868. healer();
  7869. }
  7870. }
  7871.  
  7872. botSkts.forEach((bot) => {
  7873. bot.showName = 'YEAHHH'
  7874. })
  7875.  
  7876. for(let i = 0; i < players.length; i++) {
  7877. for(let aa = 0; aa < botSkts.length; aa++) {
  7878. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  7879.  
  7880. }
  7881. }
  7882.  
  7883. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  7884. autoQ = true;
  7885. healer();
  7886. } else {
  7887. if (autoQ) {
  7888. healer();
  7889. }
  7890. autoQ = false;
  7891. }
  7892.  
  7893.  
  7894. if (tmpObj == player) {
  7895. if (liztobj.length) {
  7896. liztobj.forEach((tmp) => {
  7897. tmp.onNear = false;
  7898. if (tmp.active) {
  7899. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7900. tmp.onNear = true;
  7901. }
  7902. if (tmp.isItem && tmp.owner) {
  7903. if (!tmp.pps && tmpObj.sid == tmp.owner.sid && UTILS.getDist(tmp, tmpObj, 0, 2) > (parseInt(getEl("breakRange").value) || 0) && !tmp.breakObj && ![13, 14, 20].includes(tmp.id)) {
  7904. tmp.breakObj = true;
  7905. breakObjects.push({
  7906. x: tmp.x,
  7907. y: tmp.y,
  7908. sid: tmp.sid
  7909. });
  7910. }
  7911. }
  7912. }
  7913. });
  7914. let nearTrap = liztobj.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 25) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  7915. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7916. })[0];
  7917. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) <= (items.weapons[player.weapons[0]].range + (player.scale * 1.15))).sort(function(a, b) {
  7918. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7919. })[0];
  7920. if (player.secondaryIndex === 0) {
  7921. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) <= (items.weapons[player.weapons[1]].range + (player.scale * 1.4))).sort(function(a, b) {
  7922. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  7923. })[0];
  7924. }
  7925. if (nearTrap) {
  7926. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7927. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  7928. if (traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2)) {
  7929. my.reSync = false;
  7930. }
  7931. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7932. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7933. traps.protect(traps.aim);
  7934. traps.inTrap = true;
  7935. traps.info = nearTrap;
  7936. } else {
  7937. traps.inTrap = false;
  7938. traps.info = {};
  7939. }
  7940. } else {
  7941. traps.inTrap = false;
  7942. }
  7943. }
  7944. if (tmpObj.weaponIndex < 9) {
  7945. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7946. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7947. } else if (tmpObj.weaponIndex > 8) {
  7948. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7949. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7950. }
  7951. }
  7952. i += 13;
  7953. }
  7954. if (textManager.stack.length) {
  7955. let stacks = [];
  7956. let notstacks = [];
  7957. let num = 0;
  7958. let num2 = 0;
  7959. let pos = {
  7960. x: null,
  7961. y: null
  7962. };
  7963. let pos2 = {
  7964. x: null,
  7965. y: null
  7966. }
  7967. textManager.stack.forEach((text) => {
  7968. if (text.value >= 0) {
  7969. if (num == 0) pos = {
  7970. x: text.x,
  7971. y: text.y
  7972. };
  7973. num += Math.abs(text.value);
  7974. } else {
  7975. if (num2 == 0) pos2 = {
  7976. x: text.x,
  7977. y: text.y
  7978. };
  7979. num2 += Math.abs(text.value);
  7980. }
  7981. });
  7982. if (num2 > 0) {
  7983. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  7984. }
  7985. if (num > 0) {
  7986. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  7987. }
  7988. textManager.stack = [];
  7989. }
  7990. if (runAtNextTick.length) {
  7991. runAtNextTick.forEach((tmp) => {
  7992. checkProjectileHolder(...tmp);
  7993. });
  7994. runAtNextTick = [];
  7995. }
  7996. for (let i = 0; i < data.length;) {
  7997. tmpObj = findPlayerBySID(data[i]);
  7998. if (tmpObj) {
  7999. if (!tmpObj.isTeam(player)) {
  8000. enemy.push(tmpObj);
  8001. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  8002. nears.push(tmpObj);
  8003. }
  8004. }
  8005. tmpObj.manageReload();
  8006. if (tmpObj != player) {
  8007. tmpObj.addDamageThreat(player);
  8008. }
  8009. }
  8010. i += 13;
  8011. }
  8012. /*projectiles.forEach((proj) => {
  8013. tmpObj = proj;
  8014. if (tmpObj.active) {
  8015. tmpObj.tickUpdate(game.tickSpeed);
  8016. }
  8017. });*/
  8018. if (player && player.alive) {
  8019. if (enemy.length) {
  8020. near = enemy.sort(function(tmp1, tmp2) {
  8021. return tmp1.dist2 - tmp2.dist2;
  8022. })[0];
  8023. } else {
  8024. // console.log("no enemy");
  8025. }
  8026. if (game.tickQueue[game.tick]) {
  8027. game.tickQueue[game.tick].forEach((action) => {
  8028. action();
  8029. });
  8030. game.tickQueue[game.tick] = null;
  8031. }
  8032. if (advHeal.length) {
  8033. advHeal.forEach(updHealth => {
  8034. if (window.pingTime < 150) {
  8035. let sid = updHealth[0];
  8036. let value = updHealth[1];
  8037. let totalDamage = 100 - value;
  8038. let damaged = updHealth[2];
  8039. tmpObj = findPlayerBySID(sid);
  8040. let bullTicked = false;
  8041. if (tmpObj == player) {
  8042. if (tmpObj.skinIndex == 7 && (damaged == 5 || tmpObj.latestTail == 13 && damaged == 2)) {
  8043. if (my.reSync) {
  8044. my.reSync = false;
  8045. tmpObj.setBullTick = true;
  8046. }
  8047. bullTicked = true;
  8048. }
  8049. if (inGame) {
  8050. let attackers = getAttacker(damaged);
  8051. let gearDmgs = [0.25, 0.45].map(val => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  8052. let includeSpikeDmgs = enemy.length ? !bullTicked && gearDmgs.includes(damaged) && near.skinIndex == 11 : false;
  8053. let healTimeout = 140 - window.pingTime;
  8054. let dmg = 100 - player.health;
  8055. let slowHeal = function (timer, tickBase) {
  8056. if (!tickBase) {
  8057. setTimeout(() => {
  8058. healer();
  8059. }, timer);
  8060. } else {
  8061. game.tickBase(() => {
  8062. healer();
  8063. }, 2);
  8064. }
  8065. };
  8066. if (getEl("healingBeta").checked) {
  8067. if (enemy.length) {
  8068. if ([0, 7, 8].includes(near.primaryIndex)) {
  8069. if (damaged < 75) {
  8070. slowHeal(healTimeout);
  8071. } else {
  8072. healer();
  8073. }
  8074. }
  8075. if ([1, 2, 6].includes(near.primaryIndex)) {
  8076. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  8077. healer();
  8078. } else {
  8079. slowHeal(healTimeout);
  8080. }
  8081. }
  8082. if (near.primaryIndex == 3) {
  8083. if (near.secondaryIndex == 15) {
  8084. if (near.primaryVariant < 2) {
  8085. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  8086. tmpObj.canEmpAnti = true;
  8087. tmpObj.antiTimer = game.tick;
  8088. healer();
  8089. } else {
  8090. slowHeal(healTimeout);
  8091. }
  8092. } else if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  8093. tmpObj.canEmpAnti = true;
  8094. tmpObj.antiTimer = game.tick;
  8095. healer();
  8096. } else {
  8097. slowHeal(healTimeout);
  8098. }
  8099. } else if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  8100. healer();
  8101. } else {
  8102. slowHeal(healTimeout);
  8103. }
  8104. }
  8105. if (near.primaryIndex == 4) {
  8106. if (near.primaryVariant >= 1) {
  8107. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  8108. healer();
  8109. } else {
  8110. slowHeal(healTimeout);
  8111. }
  8112. } else if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  8113. healer();
  8114. } else {
  8115. slowHeal(healTimeout);
  8116. }
  8117. }
  8118. if ([undefined, 5].includes(near.primaryIndex)) {
  8119. if (near.secondaryIndex == 10) {
  8120. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  8121. healer();
  8122. } else {
  8123. slowHeal(healTimeout);
  8124. }
  8125. } else if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  8126. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  8127. healer();
  8128. } else {
  8129. slowHeal(healTimeout);
  8130. }
  8131. } else if ([undefined || 15].includes(near.secondaryIndex)) {
  8132. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && game.tick - player.antiTimer > 1) {
  8133. if (tmpObj.shameCount < 5) {
  8134. healer();
  8135. } else {
  8136. slowHeal(healTimeout);
  8137. }
  8138. } else {
  8139. slowHeal(healTimeout);
  8140. }
  8141. } else if ([9, 12, 13].includes(near.secondaryIndex)) {
  8142. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  8143. healer();
  8144. } else {
  8145. slowHeal(healTimeout);
  8146. }
  8147. } else if (damaged > 25 && player.damageThreat + dmg >= 95) {
  8148. healer();
  8149. } else {
  8150. slowHeal(healTimeout);
  8151. }
  8152. }
  8153. if (near.primaryIndex == 6) {
  8154. if (near.secondaryIndex == 15) {
  8155. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  8156. healer();
  8157. } else {
  8158. slowHeal(healTimeout);
  8159. }
  8160. } else if (damaged >= 70 && tmpObj.shameCount < 4) {
  8161. healer();
  8162. } else {
  8163. slowHeal(healTimeout);
  8164. }
  8165. }
  8166. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) {
  8167. instaC.canCounter = true;
  8168. }
  8169. } else if (damaged >= 70) {
  8170. healer();
  8171. } else {
  8172. slowHeal(healTimeout);
  8173. }
  8174. } else {
  8175. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && game.tick - player.antiTimer > 1) {
  8176. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  8177. tmpObj.canEmpAnti = true;
  8178. } else {
  8179. player.soldierAnti = true;
  8180. }
  8181. tmpObj.antiTimer = game.tick;
  8182. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  8183. if (tmpObj.shameCount < shame) {
  8184. healer();
  8185. } else if (near.primaryIndex == 7 || player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) {
  8186. slowHeal(healTimeout);
  8187. } else {
  8188. slowHeal(healTimeout, 1);
  8189. }
  8190. } else if (near.primaryIndex == 7 || player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) {
  8191. slowHeal(healTimeout);
  8192. } else {
  8193. slowHeal(healTimeout, 1);
  8194. }
  8195. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) {
  8196. instaC.canCounter = true;
  8197. }
  8198. }
  8199. } else if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || tmpObj.latestTail == 13 && tmpObj.damaged == 2)) {
  8200. tmpObj.setPoisonTick = true;
  8201. }
  8202. }
  8203. } else {
  8204. let [sid, value, damaged] = updHealth;
  8205. let totalDamage = 100 - value;
  8206. let tmpObj = findPlayerBySID(sid);
  8207. let bullTicked = false;
  8208. if (tmpObj == player) {
  8209. if (tmpObj.skinIndex == 7 && (damaged == 5 || tmpObj.latestTail == 13 && damaged == 2)) {
  8210. if (my.reSync) {
  8211. my.reSync = false;
  8212. tmpObj.setBullTick = true;
  8213. bullTicked = true;
  8214. }
  8215. }
  8216. if (inGame) {
  8217. let attackers = getAttacker(damaged);
  8218. let gearDmgs = [0.25, 0.45].map(
  8219. (val) =>
  8220. val * items.weapons[player.weapons[0]].dmg * soldierMult()
  8221. );
  8222. let includeSpikeDmgs = enemy.length
  8223. ? !bullTicked &&
  8224. gearDmgs.includes(damaged) &&
  8225. near.skinIndex == 11
  8226. : false;
  8227. let healTimeout = 60;
  8228. let dmg = 100 - player.health;
  8229. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  8230. let slowHeal = function (timer, tickBase) {
  8231. if (!tickBase) {
  8232. setTimeout(() => healer(), timer);
  8233. } else {
  8234. game.tickBase(() => healer(), 2);
  8235. }
  8236. };
  8237. if (getEl("healingBeta").checked) {
  8238. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 : [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 : [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 : near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 : near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 : damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 : near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 : damaged >= 25 && player.damageThreat + dmg >= 95;
  8239. if (canHealFast) {
  8240. healer();
  8241. } else {
  8242. slowHeal(healTimeout);
  8243. }
  8244. } else {
  8245. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && game.tick - player.antiTimer > 1;
  8246. if (canHealFast) {
  8247. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  8248. tmpObj.canEmpAnti = true;
  8249. } else {
  8250. player.soldierAnti = true;
  8251. }
  8252. tmpObj.antiTimer = game.tick;
  8253. if (tmpObj.shameCount < shameCountThreshold) {
  8254. healer();
  8255. } else {
  8256. slowHeal(healTimeout, near.primaryIndex == 7 || player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21) ? 0 : 1);
  8257. }
  8258. } else {
  8259. slowHeal(healTimeout, near.primaryIndex == 7 || player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21) ? 0 : 1);
  8260. }
  8261. }
  8262. } else if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || tmpObj.latestTail == 13 && tmpObj.damaged == 2)) {
  8263. tmpObj.setPoisonTick = true;
  8264. }
  8265. }
  8266. }
  8267. });
  8268. advHeal = [];
  8269. }
  8270. players.forEach((tmp) => {
  8271. if (!tmp.visible && player != tmp) {
  8272. tmp.reloads = {
  8273. 0: 0,
  8274. 1: 0,
  8275. 2: 0,
  8276. 3: 0,
  8277. 4: 0,
  8278. 5: 0,
  8279. 6: 0,
  8280. 7: 0,
  8281. 8: 0,
  8282. 9: 0,
  8283. 10: 0,
  8284. 11: 0,
  8285. 12: 0,
  8286. 13: 0,
  8287. 14: 0,
  8288. 15: 0,
  8289. 53: 0,
  8290. };
  8291. }
  8292. if (tmp.setBullTick) {
  8293. tmp.bullTimer = 0;
  8294. }
  8295. if (tmp.setPoisonTick) {
  8296. tmp.poisonTimer = 0;
  8297. }
  8298. tmp.updateTimer();
  8299. });
  8300. if (inGame) {
  8301. if (enemy.length) {
  8302. if (player.canEmpAnti) {
  8303. player.canEmpAnti = false;
  8304. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  8305. if (near.reloads[53] == 0) {
  8306. player.empAnti = true;
  8307. player.soldierAnti = false;
  8308. //modLog("EmpAnti");
  8309. } else {
  8310. player.empAnti = false;
  8311. player.soldierAnti = true;
  8312. //modLog("SoldierAnti");
  8313. }
  8314. }
  8315. }
  8316. let prehit = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function(a, b) {
  8317. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  8318. })[0];
  8319. if (prehit) {
  8320. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  8321. instaC.canSpikeTick = true;
  8322. instaC.syncHit = true;
  8323. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  8324. instaC.revTick = true;
  8325. }
  8326. }
  8327. }
  8328. const cSPPdt = [5].includes(near.primaryIndex) && tmpObj.damaged >= 45 || ([5].includes(near.primaryIndex) && tmpObj.damaged >= 60 && player.skinIndex != 6) || ([4].includes(near.primaryIndex) && tmpObj.damaged >= 40) || ([4].includes(near.primaryIndex) && tmpObj.damaged >= 60 && player.skinIndex != 6) || ([3].includes(near.primaryIndex) && tmpObj.damaged >= 35) || ([3].includes(near.primaryIndex) && tmpObj.damaged >= 40 && player.skinIndex != 6);
  8329. let antiSpikeTick = liztobj.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + player.scale)).sort(function(a, b) {
  8330. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  8331. })[0];
  8332. if (antiSpikeTick && !traps.inTrap) {
  8333. if (near.dist2 <= 300 && cSPPdt) {
  8334. my.anti0Tick = 2;
  8335. packet("6", "");
  8336. dothing = true;
  8337. if (my.reSync) {
  8338. my.reSync = false;
  8339. }
  8340. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  8341. //player.chat.count = 2000;
  8342. }
  8343. }
  8344. }
  8345. if ((useWasd ? true : ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : getEl("instaType").value == "normal" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) && instaC.perfCheck(player, near)) {
  8346. if (player.checkCanInsta(true) >= 100) {
  8347. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  8348. } else {
  8349. instaC.nobull = false;
  8350. }
  8351. instaC.can = true;
  8352. } else {
  8353. instaC.can = false;
  8354. }
  8355. let dothing = false;
  8356. //mostly all near.dist2 <= 300 and not if in range of weapon cuz gays spam 1 frame like x18k and weapon range thing not reliable
  8357. async function antiSpikeTickop() {
  8358. const thinga = near.dist2 <= 300 && [3, 4, 5].includes(near.primaryIndex) && traps.info.health <= items.weapons[near.weaponIndex].dmg * (config.weaponVariants[near[(near.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[near.weaponIndex].sDmg || 1) * 3.3;
  8359. const thingaa = near.dist2 <= 300 && [3, 4, 5].includes(near.primaryIndex) && traps.info.health <= items.weapons[player.weaponIndex].dmg * (config.weaponVariants[player[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val);
  8360. if ([5].includes(near.primaryIndex) && near.dist2 <= 300 && traps.inTrap) {
  8361. await new Promise(resolve => setTimeout(resolve, 10));
  8362. if ([0].includes(near.secondaryIndex) && traps.inTrap) {
  8363. dothing = true;
  8364. my.anti0Tick = 2;
  8365. if (my.reSync) {
  8366. my.reSync = false;
  8367. }
  8368. }
  8369. }
  8370. if (traps.inTrap && thingaa && thinga) {
  8371. buyEquip(6, 0);
  8372. dothing = true;
  8373. if (my.reSync) {
  8374. my.reSync = false;
  8375. }
  8376. if ([5, 4, 3].includes(near.primaryIndex)) {
  8377. if (traps.inTrap) {
  8378. while (traps.inTrap) {
  8379. await new Promise(resolve => setTimeout(resolve, 10));
  8380. if (!traps.inTrap) {
  8381. my.anti0Tick = 2;
  8382. dothing = true;
  8383. if (my.reSync) {
  8384. my.reSync = false;
  8385. }
  8386. }
  8387. }
  8388. }
  8389. }
  8390. }
  8391. }
  8392. if (dothing) {
  8393. cantWearTankGear = true;
  8394. cantWearBullHat = true;
  8395. } else {
  8396. cantWearTankGear = false;
  8397. cantWearBullHat = false;
  8398. }
  8399. if (traps.inTrap && near.dist2 <= 300) {
  8400. antiSpikeTickop();
  8401. }
  8402. if (near.dist2 <= 300) {
  8403. intint();
  8404. }
  8405. async function intint() {
  8406. const doingInsta = instaC.can && player.skinIndex != 6 && !my.reSync;
  8407. const instaThing = !instaC.canCounter && tmpObj.damageThreat;
  8408. const cSPPdt = [5].includes(near.primaryIndex) && tmpObj.damaged >= 45 || ([5].includes(near.primaryIndex) && tmpObj.damaged >= 60 && player.skinIndex != 6) || ([4].includes(near.primaryIndex) && tmpObj.damaged >= 40) || ([4].includes(near.primaryIndex) && tmpObj.damaged >= 60 && player.skinIndex != 6) || ([3].includes(near.primaryIndex) && tmpObj.damaged >= 35) || ([3].includes(near.primaryIndex) && tmpObj.damaged >= 40 && player.skinIndex != 6);
  8409. const cswold = clicks.left && player.skinIndex == 7 || clicks.right && player.skinIndex == 45;
  8410. const instaThing2 = [5, 4, 3].includes(near.primaryIndex) || [5, 4, 3].includes(near.primaryIndex) && near.skinIndex == 7 || [9, 12, 13, 15, 0].includes(near.secondaryIndex) || ([9, 12, 13, 15, 0].includes(near.secondaryIndex) && near.skinIndex == 53);
  8411. if (near.dist2 <= 300) {
  8412. if (instaThing) {
  8413. if (instaThing2) {
  8414. await new Promise(resolve => setTimeout(resolve, 10));
  8415. if (instaThing2 && near.skinIndex == 53 && player.skinIndex != 6) {
  8416. packet("6", "");
  8417. my.anti0Tick = 2;
  8418. dothing = true;
  8419. if (my.reSync) {
  8420. my.reSync = false;
  8421. }
  8422. }
  8423. }
  8424. }
  8425. if (doingInsta && near.dist2 <= 300) {
  8426. while (doingInsta) {
  8427. await new Promise(resolve => setTimeout(resolve, 10));
  8428. if (cSPPdt && player.skinIndex != 6) {
  8429. packet("6", "");
  8430. my.anti0Tick = 2;
  8431. dothing = true;
  8432. if (my.reSync) {
  8433. my.reSync = false;
  8434. }
  8435. }
  8436. }
  8437. }
  8438. if (cswold) {
  8439. if (player.skinIndex != 6 && !instaC.canCounter && near.skinIndex == 53) {
  8440. packet("6", "");
  8441. my.anti0Tick = 2;
  8442. dothing = true;
  8443. if (my.reSync) {
  8444. my.reSync = false;
  8445. }
  8446. }
  8447. }
  8448. if (player.skinIndex == 45 && near.skinIndex == 53) {
  8449. packet("6", "");
  8450. my.anti0Tick = 2;
  8451. if (my.reSync) {
  8452. my.reSync = false;
  8453. }
  8454. }
  8455. if (my.reSync && near.skinIndex == 53 && player.skinIndex != 6) {
  8456. packet("6", "");
  8457. my.anti0Tick = 2;
  8458. dothing = true;
  8459. if (my.reSync) {
  8460. my.reSync = false;
  8461. }
  8462. }
  8463. if (!traps.inTrap && spike && player.skinIndex != 6) {
  8464. packet("6", "");
  8465. my.anti0Tick = 2;
  8466. dothing = true;
  8467. if (my.reSync) {
  8468. my.reSync = false;
  8469. }
  8470. }
  8471. if (player.skinIndex == 6 && tmpObj.damaged >= 70) {
  8472. place(0, getAttackDir);
  8473. dothing = true;
  8474. if (my.reSync) {
  8475. my.reSync = false;
  8476. }
  8477. }
  8478. }
  8479. }
  8480. let plcAng;
  8481.  
  8482. function chooseRandomWindmillType() {
  8483. const options = [1.2828283922, 1.133232455373737775];
  8484. const randomIndex = Math.floor(Math.random() * options.length);
  8485. plcAng = options[randomIndex];
  8486. return plcAng;
  8487. }
  8488.  
  8489.  
  8490. macro.q && place(0, getAttackDir());
  8491. macro.f && place(4, getSafeDir());
  8492. macro.v && place(2, getSafeDir());
  8493. macro.y && place(5, getSafeDir());
  8494. macro.h && place(player.getItemType(22), getSafeDir());
  8495. macro.n && place(3, getSafeDir());
  8496. if (game.tick % 1.5 == 0) {
  8497. if (mills.place) {
  8498. if (getEl("windMillType").value == "random") {
  8499. chooseRandomWindmillType();
  8500. }
  8501. if (getEl("windMillType").value == "fast") {
  8502. plcAng = 1.4;
  8503. }
  8504. if (getEl("windMillType").value == "cool") {
  8505. plcAng = 1.747474774747474747439328472347928374923847239489910101011010;
  8506. }
  8507. if (getEl("windMillType").value == "cool2") {
  8508. plcAng = 1.33;
  8509. if (player.primaryIndex == 7) {
  8510. plcAng = 1.5;
  8511. }
  8512. }
  8513. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  8514. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  8515. }
  8516. } else {
  8517. if (mills.placeSpawnPads) {
  8518. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  8519. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  8520. }
  8521. }
  8522. }
  8523. }
  8524. if (instaC.can) {
  8525. instaC.changeType(getEl("instaType").value);
  8526. }
  8527. if (instaC.canCounter && !tdf) {
  8528. instaC.canCounter = false;
  8529. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  8530. instaC.counterType();
  8531. io.send('6', 'Countered');
  8532. }
  8533. }
  8534. if (instaC.canSpikeTick) {
  8535. instaC.canSpikeTick = false;
  8536. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  8537. instaC.spikeTickType();
  8538. }
  8539. }
  8540. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  8541. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  8542. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  8543. }
  8544. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8545. sendAutoGather();
  8546. my.waitHit = 1;
  8547. game.tickBase(() => {
  8548. sendAutoGather();
  8549. my.waitHit = 0;
  8550. }, 1);
  8551. }
  8552. }
  8553. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  8554. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  8555. selectWeapon(player.weapons[0]);
  8556. }
  8557. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  8558. sendAutoGather();
  8559. my.waitHit = 1;
  8560. game.tickBase(() => {
  8561. sendAutoGather();
  8562. my.waitHit = 0;
  8563. }, 1);
  8564. }
  8565. }
  8566. if (traps.inTrap) {
  8567. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  8568. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  8569. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  8570. }
  8571. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8572. sendAutoGather();
  8573. my.waitHit = 1;
  8574. game.tickBase(() => {
  8575. sendAutoGather();
  8576. my.waitHit = 0;
  8577. }, 1);
  8578. }
  8579. }
  8580. }
  8581. if (clicks.middle && !traps.inTrap) {
  8582. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  8583. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  8584. instaC.bowMovement();
  8585. } else {
  8586. instaC.rangeType();
  8587. }
  8588. }
  8589. }
  8590. if (macro.t && !traps.inTrap) {
  8591. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && (player.weapons[1] == 15 ? (player.reloads[player.weapons[1]] == 0) : true) && (player.weapons[0] == 5 || (player.weapons[0] == 4 && player.weapons[1] == 15))) {
  8592. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  8593. }
  8594. }
  8595. if (macro["."] && !traps.inTrap) {
  8596. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  8597. instaC.boostTickMovement();
  8598. }
  8599. }
  8600. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue && !(useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8)) {
  8601. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  8602. if (!my.reloaded) {
  8603. my.reloaded = true;
  8604. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  8605. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  8606. selectWeapon(player.weapons[fastSpeed]);
  8607. }
  8608. }
  8609. // if(useWasd) {
  8610. // if (!autos.stopspin) {
  8611. // setTimeout(()=>{
  8612. // autos.stopspin = true;
  8613. // }, 375);
  8614. // }
  8615. // }
  8616. } else {
  8617. my.reloaded = false;
  8618. if(useWasd) {
  8619. autos.stopspin = false;
  8620. }
  8621. if (player.reloads[player.weapons[0]] > 0) {
  8622. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  8623. selectWeapon(player.weapons[0]);
  8624. }
  8625. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  8626. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  8627. selectWeapon(player.weapons[1]);
  8628. }
  8629. if(useWasd) {
  8630. if (!autos.stopspin) {
  8631. setTimeout(()=>{
  8632. autos.stopspin = true;
  8633. }, 750);
  8634. }
  8635. }
  8636. }
  8637. }
  8638. }
  8639. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  8640. traps.autoPlace();
  8641. }
  8642. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  8643. packet("D", getAttackDir());
  8644. }
  8645. let hatChanger = function () {
  8646. if (my.anti0Tick > 0) {
  8647. buyEquip(6, 0);
  8648. } else {
  8649. if (clicks.left || clicks.right) {
  8650. if (((!enemy.length || near.dist2 >= 100) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8651. if (!cantWearBullHat) {
  8652. buyEquip(7, 0);
  8653. buyEquip(13, 1);
  8654. }
  8655. } else if (clicks.left) {
  8656. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : near.dist2 <= 300 ? getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6 : buyEquip(21, 1), 0);
  8657. } else if (clicks.right) {
  8658. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 6 : player.soldierAnti ? 6 : getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : near.dist2 <= 300 ? getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6 : buyEquip(21, 1), 0);
  8659. }
  8660. } else if (traps.inTrap) {
  8661. if ((traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) && my.anti0Tick == 0 && !cantWearTankGear) {
  8662. buyEquip(40, 0);
  8663.  
  8664. } else if (traps.inTrap) {
  8665. if ((player.shameCount < 3 && (game.tick - player.bullTick) % config.serverUpdateRate === 0) || my.reSync) {
  8666. buyEquip(6, 0);
  8667. buyEquip(18, 1)
  8668. } else {
  8669. if (((!enemy.length || near.dist2 >= 100) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8670. buyEquip(7, 0);
  8671. } else {
  8672. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 22 : 6, 0);
  8673. }
  8674. }
  8675. }
  8676. } else {
  8677. if (player.empAnti || player.soldierAnti) {
  8678. buyEquip(player.empAnti ? 22 : 6, 0);
  8679. } else {
  8680. if (((!enemy.length || near.dist2 >= 100) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8681. buyEquip(7, 0);
  8682. buyEquip(13, 1);
  8683. } else {
  8684. if (player.y2 >= config.mapScale / 5 - config.riverWidth / 5 && player.y2 <= config.mapScale / 5 + config.riverWidth / 5) {
  8685. if (!configs.alwaysFlipper) {
  8686. if (near.dist2 <= 300) {
  8687. buyEquip(getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6, 0);
  8688. } else {
  8689. biomeGear(1);
  8690. }
  8691. } else {
  8692. biomeGear(1);
  8693. }
  8694. } else if (near.dist2 <= 300) {
  8695. buyEquip(getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6, 0);
  8696. } else {
  8697. biomeGear(1);
  8698. }
  8699. }
  8700. }
  8701. }
  8702. }
  8703. }
  8704.  
  8705. let SmartAntiSpiketick = function() {
  8706. if (traps.inTrap) {
  8707. if (near.dist2 <= 150) {
  8708. buyEquip(6, 0);
  8709. }
  8710. }
  8711. }
  8712.  
  8713. let accChanger = function() {
  8714. if (instaC.can && player.checkCanInsta(true) >= 100) {
  8715. buyEquip(21, 1);
  8716. } else if (clicks.left) {
  8717. buyEquip(21, 1);
  8718. } else if (clicks.right) {
  8719. buyEquip(21, 1);
  8720. } else if (near.dist2 <= 300 && !traps.inTrap && !clicks.left && !clicks.right) {
  8721. buyEquip(19, 1);
  8722. } else {
  8723. traps.inTrap ? buyEquip(13, 1) : buyEquip(11, 1);
  8724. }
  8725. };
  8726. if (my.anti0Tick > 0) {
  8727. buyEquip(6, 0);
  8728. }
  8729. let wasdGears = function() {
  8730. if (my.anti0Tick > 0) {
  8731. buyEquip(6, 0);
  8732. } else {
  8733. if (clicks.left || clicks.right) {
  8734. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  8735. buyEquip(7, 0);
  8736. } else {
  8737. if (clicks.left) {
  8738. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  8739. } else if (clicks.right) {
  8740. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  8741. }
  8742. }
  8743. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  8744. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  8745. buyEquip(7, 0);
  8746. } else {
  8747. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  8748. }
  8749. } else if (traps.inTrap) {
  8750. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  8751. buyEquip(40, 0);
  8752. } else {
  8753. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  8754. buyEquip(7, 0);
  8755. } else {
  8756. buyEquip(player.empAnti ? 22 : 6, 0);
  8757. }
  8758. }
  8759. } else {
  8760. if (player.empAnti) {
  8761. buyEquip(22, 0);
  8762. } else {
  8763. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  8764. buyEquip(7, 0);
  8765. } else {
  8766. buyEquip(6, 0);
  8767. }
  8768. }
  8769. }
  8770. }
  8771. if (clicks.left || clicks.right) {
  8772. if (clicks.left) {
  8773. buyEquip(0, 1);
  8774. } else if (clicks.right) {
  8775. buyEquip(11, 1);
  8776. }
  8777. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  8778. buyEquip(0, 1);
  8779. } else if (traps.inTrap) {
  8780. buyEquip(0, 1);
  8781. } else {
  8782. buyEquip(11, 1);
  8783. }
  8784. }
  8785. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  8786. if (useWasd) {
  8787. wasdGears();
  8788. } else {
  8789. hatChanger();
  8790. SmartAntiSpiketick();
  8791. accChanger();
  8792. }
  8793. }
  8794. //lastMoveDir = getSafeDir();
  8795. //packet("f", lastMoveDir, 1);
  8796. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  8797. autoPush();
  8798. } else {
  8799. if (my.autoPush) {
  8800. my.autoPush = false;
  8801. packet("f", lastMoveDir || undefined, 1);
  8802. }
  8803. }
  8804. if (instaC.ticking) {
  8805. instaC.ticking = false;
  8806. }
  8807. if (instaC.syncHit) {
  8808. instaC.syncHit = false;
  8809. }
  8810. if (player.empAnti) {
  8811. player.empAnti = false;
  8812. }
  8813. if (player.soldierAnti) {
  8814. player.soldierAnti = false;
  8815. }
  8816. if (my.anti0Tick > 0) {
  8817. my.anti0Tick--;
  8818. }
  8819. if (traps.replaced) {
  8820. traps.replaced = false;
  8821. }
  8822. if (traps.antiTrapped) {
  8823. traps.antiTrapped = false;
  8824. }
  8825.  
  8826. const getPotentialDamage = (build, user) => {
  8827. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  8828. const weap = user.weapons[weapIndex];
  8829. if (player.reloads[weap]) return 0;
  8830. const weapon = items.weapons[weap];
  8831. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  8832. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  8833. };
  8834.  
  8835. const AutoReplace = () => {
  8836. const replaceable = [];
  8837. const playerX = player.x;
  8838. const playerY = player.y;
  8839. const gameObjectCount = gameObjects.length;
  8840.  
  8841. for (let i = 0; i < gameObjectCount; i++) {
  8842. const build = gameObjects[i];
  8843. if (build.isItem && build.active && build.health > 0) {
  8844. const item = items.list[build.id];
  8845. const posDist = 35 + item.scale + (item.placeOffset || 0);
  8846. const inDistance = cdf(build, player) <= posDist * 2;
  8847. if (inDistance) {
  8848. let canDeal = 0;
  8849. const playersCount = players.length;
  8850. for (let j = 0; j < playersCount; j++) {
  8851. canDeal += getPotentialDamage(build, players[j]);
  8852. }
  8853. if (build.health <= canDeal) {
  8854. replaceable.push(build);
  8855. }
  8856. }
  8857. }
  8858. }
  8859.  
  8860. const findPlacementAngle = (player, itemId, build) => {
  8861. if (!build) return null;
  8862. const MAX_ANGLE = 2 * Math.PI;
  8863. const ANGLE_STEP = Math.PI / 360;
  8864. const item = items.list[player.items[itemId]];
  8865. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  8866. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  8867.  
  8868. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  8869. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  8870. for (let angle of angles) {
  8871. return angle;
  8872. }
  8873. }
  8874. return null;
  8875. };
  8876.  
  8877. const replace = (() => {
  8878. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  8879. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  8880. const buildId = spike ? 4 : 2;
  8881.  
  8882. replaceable.forEach(build => {
  8883. let angle = findPlacementAngle(player, buildId, build);
  8884. if (angle !== null) {
  8885. place(buildId, angle);
  8886. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  8887. }
  8888. });
  8889. });
  8890.  
  8891. if (near && near.dist3 <= 360) {
  8892. replace();
  8893. }
  8894. replace;
  8895. }
  8896. }
  8897. }
  8898. if (botSkts.length) {
  8899. botSkts.forEach((bots) => {
  8900. if (true) {
  8901. bots[0].showName = 'YEAHHH';
  8902. }
  8903. });
  8904. }
  8905. }
  8906. function ez(context, x, y) {
  8907. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  8908. context.beginPath();
  8909. context.arc(x, y, 55, 0, Math.PI * 2);
  8910. context.fill();
  8911. context.closePath();
  8912. context.globalAlpha = 1;
  8913. }
  8914. // UPDATE LEADERBOARD:
  8915. function updateLeaderboard(data) {
  8916. lastLeaderboardData = data;
  8917. return;
  8918. UTILS.removeAllChildren(leaderboardData);
  8919. let tmpC = 1;
  8920. for (let i = 0; i < data.length; i += 3) {
  8921. (function(i) {
  8922. UTILS.generateElement({
  8923. class: "leaderHolder",
  8924. parent: leaderboardData,
  8925. children: [
  8926. UTILS.generateElement({
  8927. class: "leaderboardItem",
  8928. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  8929. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  8930. }),
  8931. UTILS.generateElement({
  8932. class: "leaderScore",
  8933. text: UTILS.sFormat(data[i + 2]) || "0"
  8934. })
  8935. ]
  8936. });
  8937. })(i);
  8938. tmpC++;
  8939. }
  8940. }
  8941.  
  8942. // LOAD GAME OBJECT:
  8943. function loadGameObject(data) {
  8944. for (let i = 0; i < data.length;) {
  8945. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  8946. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  8947. sid: data[i + 7]
  8948. } : null));
  8949. // sid, x, y, dir, s, type, data, setSID, owner
  8950. /*let dist = UTILS.getDist({
  8951. x: data[i + 1],
  8952. y: data[i + 2]
  8953. }, player, 0, 2);
  8954. let aim = UTILS.getDirect({
  8955. x: data[i + 1],
  8956. y: data[i + 2]
  8957. }, player, 0, 2);
  8958. find = findObjectBySid(data[i]);
  8959. if (data[i + 6] == 15) {
  8960. if (find && !find.isTeamObject(player)) {
  8961. if (dist <= 100) {
  8962. traps.dist = dist;
  8963. traps.aim = aim;
  8964. traps.protect(aim);
  8965. }
  8966. }
  8967. }*/
  8968. i += 8;
  8969. }
  8970. }
  8971.  
  8972. // ADD AI:
  8973. function loadAI(data) {
  8974. for (let i = 0; i < ais.length; ++i) {
  8975. ais[i].forcePos = !ais[i].visible;
  8976. ais[i].visible = false;
  8977. }
  8978. if (data) {
  8979. let tmpTime = performance.now();
  8980. for (let i = 0; i < data.length;) {
  8981. tmpObj = findAIBySID(data[i]);
  8982. if (tmpObj) {
  8983. tmpObj.index = data[i + 1];
  8984. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  8985. tmpObj.t2 = tmpTime;
  8986. tmpObj.x1 = tmpObj.x;
  8987. tmpObj.y1 = tmpObj.y;
  8988. tmpObj.x2 = data[i + 2];
  8989. tmpObj.y2 = data[i + 3];
  8990. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  8991. tmpObj.d2 = data[i + 4];
  8992. tmpObj.health = data[i + 5];
  8993. tmpObj.dt = 0;
  8994. tmpObj.visible = true;
  8995. } else {
  8996. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  8997. tmpObj.x2 = tmpObj.x;
  8998. tmpObj.y2 = tmpObj.y;
  8999. tmpObj.d2 = tmpObj.dir;
  9000. tmpObj.health = data[i + 5];
  9001. if (!aiManager.aiTypes[data[i + 1]].name)
  9002. tmpObj.name = config.cowNames[data[i + 6]];
  9003. tmpObj.forcePos = true;
  9004. tmpObj.sid = data[i];
  9005. tmpObj.visible = true;
  9006. }
  9007. i += 7;
  9008. }
  9009. }
  9010. }
  9011.  
  9012. // ANIMATE AI:
  9013. function animateAI(sid) {
  9014. tmpObj = findAIBySID(sid);
  9015. if (tmpObj) tmpObj.startAnim();
  9016. }
  9017.  
  9018. // GATHER ANIMATION:
  9019. function gatherAnimation(sid, didHit, index) {
  9020. tmpObj = findPlayerBySID(sid);
  9021. if (tmpObj) {
  9022. tmpObj.startAnim(didHit, index);
  9023. tmpObj.gatherIndex = index;
  9024. tmpObj.gathering = 1;
  9025.  
  9026. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  9027. // healer();
  9028.  
  9029. if (didHit) {
  9030. let tmpObjects = objectManager.hitObj;
  9031. objectManager.hitObj = [];
  9032. game.tickBase(() => {
  9033. // refind
  9034. tmpObj = findPlayerBySID(sid);
  9035. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * (tmpObj.skinIndex == 40 ? 3.3 : 1);
  9036. tmpObjects.forEach((healthy) => {
  9037. healthy.health -= val;
  9038. });
  9039. }, 1);
  9040. }
  9041. }
  9042. }
  9043. if(nears.filter(near => near.gathering).length>1) {
  9044. player.chat.message = "pSyD";
  9045. healer();
  9046. }
  9047.  
  9048.  
  9049. // WIGGLE GAME OBJECT:
  9050. function wiggleGameObject(dir, sid) {
  9051. tmpObj = findObjectBySid(sid);
  9052. if (tmpObj) {
  9053. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  9054. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  9055. if (tmpObj.health) {
  9056. objectManager.hitObj.push(tmpObj);
  9057. }
  9058. }
  9059. }
  9060.  
  9061. // SHOOT TURRET:
  9062. function shootTurret(sid, dir) {
  9063. tmpObj = findObjectBySid(sid);
  9064. if (tmpObj) {
  9065. if (config.anotherVisual) {
  9066. tmpObj.lastDir = dir;
  9067. } else {
  9068. tmpObj.dir = dir;
  9069. }
  9070. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  9071. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  9072. }
  9073. }
  9074. function randomthing() {
  9075. const options = [];
  9076. for (let i = 0; i < 100; i++) {
  9077. const randomNum = Math.floor(1000 + Math.random() * 9000);
  9078. options.push(randomNum);
  9079. }
  9080. const randomIndex = Math.floor(Math.random() * options.length);
  9081. thing = options[randomIndex];
  9082. return thing;
  9083. }
  9084. function randomthing2() {
  9085. const options2 = [];
  9086. for (let i = 0; i < 100; i++) {
  9087. const randomNum2 = Math.floor(1000 + Math.random() * 9000);
  9088. options2.push(randomNum2);
  9089. }
  9090. const randomIndex2 = Math.floor(Math.random() * options2.length);
  9091. thing2 = options2[randomIndex2];
  9092. return thing2;
  9093. }
  9094. let thing;
  9095. let thing2;
  9096. // UPDATE PLAYER VALUE:
  9097. function updatePlayerValue(index, value, updateView) {
  9098. if (player) {
  9099. player[index] = value;
  9100. if (index == "points") {
  9101. if (configs.autoBuy) {
  9102. autoBuy.hat();
  9103. autoBuy.acc();
  9104. }
  9105. } else if (index == "kills") {
  9106. if (configs.killChat) {
  9107. randomthing();
  9108. sendChat("Minus Client | GG ");
  9109. }
  9110. }
  9111. }
  9112. }
  9113.  
  9114.  
  9115. // ACTION BAR:
  9116. function updateItems(data, wpn) {
  9117. if (data) {
  9118. if (wpn) {
  9119. player.weapons = data;
  9120. player.primaryIndex = player.weapons[0];
  9121. player.secondaryIndex = player.weapons[1];
  9122. if (!instaC.isTrue) {
  9123. selectWeapon(player.weapons[0]);
  9124. }
  9125. } else {
  9126. player.items = data;
  9127. }
  9128. }
  9129.  
  9130. for (let i = 0; i < items.list.length; i++) {
  9131. let tmpI = items.weapons.length + i;
  9132. let actionBarItem = getEl("actionBarItem" + tmpI);
  9133. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  9134. // Add shadow to the element
  9135. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9136. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9137.  
  9138. }
  9139.  
  9140. for (let i = 0; i < items.weapons.length; i++) {
  9141. let actionBarItem = getEl("actionBarItem" + i);
  9142. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  9143. // Add shadow to the element
  9144. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9145. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9146. }
  9147.  
  9148. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  9149. if (kms) {
  9150. getEl("actionBarItem3").style.display = "none";
  9151. getEl("actionBarItem4").style.display = "inline-block";
  9152. }
  9153. }
  9154.  
  9155. // ADD PROJECTILE:
  9156. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  9157. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  9158. runAtNextTick.push(Array.prototype.slice.call(arguments));
  9159. }
  9160.  
  9161. // REMOVE PROJECTILE:
  9162. function remProjectile(sid, range) {
  9163. for (let i = 0; i < projectiles.length; ++i) {
  9164. if (projectiles[i].sid == sid) {
  9165. projectiles[i].range = range;
  9166. let tmpObjects = objectManager.hitObj;
  9167. objectManager.hitObj = [];
  9168. game.tickBase(() => {
  9169. let val = projectiles[i].dmg;
  9170. tmpObjects.forEach((healthy) => {
  9171. if (healthy.projDmg) {
  9172. healthy.health -= val;
  9173. }
  9174. });
  9175. }, 1);
  9176. }
  9177. }
  9178. }
  9179.  
  9180. // lol this useless,,, fr
  9181. let noob = false;
  9182. let serverReady = true;
  9183. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  9184. let wssws = isProd ? "wss" : "ws";
  9185. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  9186. let withSync = false;
  9187. project.binaryType = "arraybuffer";
  9188. project.onmessage = function(msg) {
  9189. let data = msg.data;
  9190. if (data == "isready") {
  9191. serverReady = true;
  9192. }
  9193. if (data == "fine") {
  9194. noob = false;
  9195. }
  9196.  
  9197. if (data == "tezt") {
  9198. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  9199. }
  9200. if (data == "yeswearesyncer") {
  9201. // let delay = Date.now() - wsDelay;
  9202. withSync = true;
  9203. if (player) {
  9204. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  9205. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  9206. }
  9207. }
  9208. };
  9209.  
  9210. // SHOW ALLIANCE MENU:
  9211. function allianceNotification(sid, name) {
  9212. let findBotSID = findSID(bots, sid);
  9213. if (findBotSID) {}
  9214. }
  9215.  
  9216. function setPlayerTeam(team, isOwner) {
  9217. if (player) {
  9218. player.team = team;
  9219. player.isOwner = isOwner;
  9220. if (team == null)
  9221. alliancePlayers = [];
  9222. }
  9223. }
  9224.  
  9225. function setAlliancePlayers(data) {
  9226. alliancePlayers = data;
  9227. }
  9228.  
  9229. // STORE MENU:
  9230. function updateStoreItems(type, id, index) {
  9231. if (index) {
  9232. if (!type)
  9233. player.tails[id] = 1;
  9234. else {
  9235. player.latestTail = id;
  9236. }
  9237. } else {
  9238. if (!type)
  9239. player.skins[id] = 1,
  9240. id == 7 && (my.reSync = true); // testing perfect bulltick...
  9241. else {
  9242. player.latestSkin = id;
  9243. }
  9244. }
  9245. }
  9246.  
  9247. // SEND MESSAGE:
  9248. function receiveChat(sid, message) {
  9249. let kawaii = false;
  9250. let tmpPlayer = findPlayerBySID(sid);
  9251. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  9252. tmpPlayer.chatMessage = message;
  9253. tmpPlayer.chatCountdown = config.chatCountdown;
  9254. }
  9255.  
  9256. // MINIMAP:
  9257. function updateMinimap(data) {
  9258. minimapData = data;
  9259. }
  9260.  
  9261. // SHOW ANIM TEXT:
  9262. function showText(x, y, value, type) {
  9263. textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value>=0)?"#fff":"#8ecc51");
  9264. }
  9265.  
  9266. /** APPLY SOCKET CODES */
  9267.  
  9268. // BOT:
  9269. let bots = [];
  9270. let ranLocation = {
  9271. x: UTILS.randInt(35, 14365),
  9272. y: UTILS.randInt(35, 14365)
  9273. };
  9274. setInterval(() => {
  9275. ranLocation = {
  9276. x: UTILS.randInt(35, 14365),
  9277. y: UTILS.randInt(35, 14365)
  9278. };
  9279. }, 60000);
  9280. class Bot {
  9281. constructor(id, sid, hats, accessories) {
  9282. this.millPlace = true;
  9283. this.id = id;
  9284. this.sid = sid;
  9285. this.team = null;
  9286. this.skinIndex = 0;
  9287. this.tailIndex = 0;
  9288. this.hitTime = 0;
  9289. this.iconIndex = 0;
  9290. this.enemy = [];
  9291. this.near = [];
  9292. this.dist2 = 0;
  9293. this.aim2 = 0;
  9294. this.tick = 0;
  9295. this.itemCounts = {};
  9296. this.latestSkin = 0;
  9297. this.latestTail = 0;
  9298. this.points = 0;
  9299. this.tails = {};
  9300. for (let i = 0; i < accessories.length; ++i) {
  9301. if (accessories[i].price <= 0)
  9302. this.tails[accessories[i].id] = 1;
  9303. }
  9304. this.skins = {};
  9305. for (let i = 0; i < hats.length; ++i) {
  9306. if (hats[i].price <= 0)
  9307. this.skins[hats[i].id] = 1;
  9308. }
  9309. this.spawn = function(moofoll) {
  9310. this.upgraded = 0;
  9311. this.enemy = [];
  9312. this.near = [];
  9313. this.active = true;
  9314. this.alive = true;
  9315. this.lockMove = false;
  9316. this.lockDir = false;
  9317. this.minimapCounter = 0;
  9318. this.chatCountdown = 0;
  9319. this.shameCount = 0;
  9320. this.shameTimer = 0;
  9321. this.sentTo = {};
  9322. this.gathering = 0;
  9323. this.autoGather = 0;
  9324. this.animTime = 0;
  9325. this.animSpeed = 0;
  9326. this.mouseState = 0;
  9327. this.buildIndex = -1;
  9328. this.weaponIndex = 0;
  9329. this.dmgOverTime = {};
  9330. this.noMovTimer = 0;
  9331. this.maxXP = 300;
  9332. this.XP = 0;
  9333. this.age = 1;
  9334. this.kills = 0;
  9335. this.upgrAge = 2;
  9336. this.upgradePoints = 0;
  9337. this.x = 0;
  9338. this.y = 0;
  9339. this.zIndex = 0;
  9340. this.xVel = 0;
  9341. this.yVel = 0;
  9342. this.slowMult = 1;
  9343. this.dir = 0;
  9344. this.nDir = 0;
  9345. this.dirPlus = 0;
  9346. this.targetDir = 0;
  9347. this.targetAngle = 0;
  9348. this.maxHealth = 100;
  9349. this.health = this.maxHealth;
  9350. this.oldHealth = this.maxHealth;
  9351. this.scale = config.playerScale;
  9352. this.speed = config.playerSpeed;
  9353. this.resetMoveDir();
  9354. this.resetResources(moofoll);
  9355. this.items = [0, 3, 6, 10];
  9356. this.weapons = [0];
  9357. this.shootCount = 0;
  9358. this.weaponXP = [];
  9359. this.isBot = false;
  9360. this.reloads = {
  9361. 0: 0,
  9362. 1: 0,
  9363. 2: 0,
  9364. 3: 0,
  9365. 4: 0,
  9366. 5: 0,
  9367. 6: 0,
  9368. 7: 0,
  9369. 8: 0,
  9370. 9: 0,
  9371. 10: 0,
  9372. 11: 0,
  9373. 12: 0,
  9374. 13: 0,
  9375. 14: 0,
  9376. 15: 0,
  9377. 53: 0,
  9378. };
  9379. this.timeZinceZpawn = 0;
  9380. this.whyDie = "";
  9381. this.clearRadius = false;
  9382. this.circlee = 0;
  9383. };
  9384.  
  9385. // RESET MOVE DIR:
  9386. this.resetMoveDir = function() {
  9387. this.moveDir = undefined;
  9388. };
  9389.  
  9390. // RESET RESOURCES:
  9391. this.resetResources = function(moofoll) {
  9392. for (let i = 0; i < config.resourceTypes.length; ++i) {
  9393. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  9394. }
  9395. };
  9396.  
  9397. // SET DATA:
  9398. this.setData = function(data) {
  9399. this.id = data[0];
  9400. this.sid = data[1];
  9401. this.name = data[2];
  9402. this.x = data[3];
  9403. this.y = data[4];
  9404. this.dir = data[5];
  9405. this.health = data[6];
  9406. this.maxHealth = data[7];
  9407. this.scale = data[8];
  9408. this.skinColor = data[9];
  9409. };
  9410.  
  9411.  
  9412. // SHAME SYSTEM:
  9413. this.judgeShame = function() {
  9414. if (this.oldHealth < this.health) {
  9415. if (this.hitTime) {
  9416. let timeSinceHit = this.tick - this.hitTime;
  9417. this.hitTime = 0;
  9418. if (timeSinceHit < 2) {
  9419. this.lastshamecount = this.shameCount;
  9420. this.shameCount++;
  9421. } else {
  9422. this.lastshamecount = this.shameCount;
  9423. this.shameCount = Math.max(0, this.shameCount - 2);
  9424. }
  9425. }
  9426. } else if (this.oldHealth > this.health) {
  9427. this.hitTime = this.tick;
  9428. }
  9429. };
  9430.  
  9431. // UPDATE WEAPON RELOAD:
  9432. this.manageReloadaa = function() {
  9433. if (this.shooting[53]) {
  9434. this.shooting[53] = 0;
  9435. this.reloads[53] = (2500 - 1000/9);
  9436. } else {
  9437. if (this.reloads[53] > 0) {
  9438. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  9439. }
  9440. }
  9441. if (this.gathering || this.shooting[1]) {
  9442. if (this.gathering) {
  9443. this.gathering = 0;
  9444. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  9445. this.attacked = true;
  9446. }
  9447. if (this.shooting[1]) {
  9448. this.shooting[1] = 0;
  9449. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  9450. this.attacked = true;
  9451. }
  9452. } else {
  9453. this.attacked = false;
  9454. if (this.buildIndex < 0) {
  9455. if (this.reloads[this.weaponIndex] > 0) {
  9456. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  9457. }
  9458. }
  9459. }
  9460. };
  9461.  
  9462. this.closeSockets = function(websc) {
  9463. websc.close();
  9464. };
  9465.  
  9466. this.whyDieChat = function(websc, whydie) {
  9467. websc.sendWS("6", "why die XDDD " + whydie);
  9468. };
  9469. }
  9470. };
  9471.  
  9472. class BotObject {
  9473. constructor(sid) {
  9474. this.sid = sid;
  9475. // INIT:
  9476. this.init = function(x, y, dir, scale, type, data, owner) {
  9477. data = data || {};
  9478. this.active = true;
  9479. this.x = x;
  9480. this.y = y;
  9481. this.scale = scale;
  9482. this.owner = owner;
  9483. this.id = data.id;
  9484. this.dmg = data.dmg;
  9485. this.trap = data.trap;
  9486. this.teleport = data.teleport;
  9487. this.isItem = this.id != undefined;
  9488. };
  9489.  
  9490. }
  9491. };
  9492. class BotObjManager {
  9493. constructor(botObj, fOS) {
  9494. // DISABLE OBJ:
  9495. this.disableObj = function(obj) {
  9496. obj.active = false;
  9497. if (config.anotherVisual) {} else {
  9498. obj.alive = false;
  9499. }
  9500. };
  9501.  
  9502. // ADD NEW:
  9503. let tmpObj;
  9504. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  9505. tmpObj = fOS(sid);
  9506. if (!tmpObj) {
  9507. tmpObj = botObj.find((tmp) => !tmp.active);
  9508. if (!tmpObj) {
  9509. tmpObj = new BotObject(sid);
  9510. botObj.push(tmpObj);
  9511. }
  9512. }
  9513. if (setSID) {
  9514. tmpObj.sid = sid;
  9515. }
  9516. tmpObj.init(x, y, dir, s, type, data, owner);
  9517. };
  9518.  
  9519. // DISABLE BY SID:
  9520. this.disableBySid = function(sid) {
  9521. let find = fOS(sid);
  9522. if (find) {
  9523. this.disableObj(find);
  9524. }
  9525. };
  9526.  
  9527. // REMOVE ALL FROM PLAYER:
  9528. this.removeAllItems = function(sid, server) {
  9529. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  9530. };
  9531. }
  9532. };
  9533.  
  9534. let botz = [];
  9535.  
  9536. function botSpawn(id) {
  9537. let bot;
  9538. console.log(WS);
  9539. let t = WS.url.split("wss://")[1].split("?")[0];
  9540. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  9541. let botPlayer = new Map();
  9542. botSkts.push([botPlayer]);
  9543. botz.push([bot]);
  9544. let botSID;
  9545. let botObj = [];
  9546. let nearObj = [];
  9547. let bD = {
  9548. x: 0,
  9549. y: 0,
  9550. inGame: false,
  9551. closeSocket: false,
  9552. whyDie: ""
  9553. };
  9554. let oldXY = {
  9555. x: 0,
  9556. y: 0,
  9557. };
  9558. let izauto = 0;
  9559. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  9560. bot.binaryType = "arraybuffer";
  9561. bot.first = true;
  9562. bot.sendWS = function(type) {
  9563. // EXTRACT DATA ARRAY:
  9564. let data = Array.prototype.slice.call(arguments, 1);
  9565. // SEND MESSAGE:
  9566. let binary = window.msgpack.encode([type, data]);
  9567. bot.send(binary);
  9568. };
  9569. bot.spawn = function() {
  9570. bot.sendWS("M", {
  9571. name: "unknown1l",
  9572. moofoll: 1,
  9573. skin: "__proto__"
  9574. });
  9575. };
  9576. bot.sendUpgrade = function(index) {
  9577. bot.sendWS("H", index);
  9578. };
  9579. bot.place = function(id, a) {
  9580. try {
  9581. let item = items.list[botPlayer.items[id]];
  9582. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  9583. bot.sendWS("G", botPlayer.items[id]);
  9584. bot.sendWS("d", 1, a);
  9585. bot.sendWS("G", botPlayer.weaponIndex, true);
  9586. }
  9587. } catch (e) {
  9588. }
  9589. };
  9590. bot.buye = function(id, index) {
  9591. let nID = 0;
  9592. if (botPlayer.alive && botPlayer.inGame) {
  9593. if (index == 0) {
  9594. if (botPlayer.skins[id]) {
  9595. if (botPlayer.latestSkin != id) {
  9596. bot.sendWS("c", 0, id, 0);
  9597. }
  9598. } else {
  9599. let find = findID(hats, id);
  9600. if (find) {
  9601. if (botPlayer.points >= find.price) {
  9602. bot.sendWS("c", 1, id, 0);
  9603. bot.sendWS("c", 0, id, 0);
  9604. } else {
  9605. if (botPlayer.latestSkin != nID) {
  9606. bot.sendWS("c", 0, nID, 0);
  9607. }
  9608. }
  9609. } else {
  9610. if (botPlayer.latestSkin != nID) {
  9611. bot.sendWS("c", 0, nID, 0);
  9612. }
  9613. }
  9614. }
  9615. } else if (index == 1) {
  9616. if (botPlayer.tails[id]) {
  9617. if (botPlayer.latestTail != id) {
  9618. bot.sendWS("c", 0, id, 1);
  9619. }
  9620. } else {
  9621. let find = findID(accessories, id);
  9622. if (find) {
  9623. if (botPlayer.points >= find.price) {
  9624. bot.sendWS("c", 1, id, 1);
  9625. bot.sendWS("c", 0, id, 1);
  9626. } else {
  9627. if (botPlayer.latestTail != 0) {
  9628. bot.sendWS("c", 0, 0, 1);
  9629. }
  9630. }
  9631. } else {
  9632. if (botPlayer.latestTail != 0) {
  9633. bot.sendWS("c", 0, 0, 1);
  9634. }
  9635. }
  9636. }
  9637. }
  9638. }
  9639. };
  9640. bot.fastGear = function () {
  9641. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  9642. bot.buye(31, 0);
  9643. } else {
  9644. if (botPlayer.moveDir == undefined) {
  9645. bot.buye(22, 0);
  9646. } else {
  9647. if (botPlayer.y2 <= config.snowBiomeTop) {
  9648. bot.buye(15, 0);
  9649. } else {
  9650. bot.buye(12, 0);
  9651. }
  9652. }
  9653. }
  9654. };
  9655. bot.selectWeapon = function(a) {
  9656. packet("G", a, 1);
  9657. }
  9658. function caf(e, t) {
  9659. try {
  9660. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  9661. } catch (e) {
  9662. return 0;
  9663. }
  9664. }
  9665. bot.heal = function() {
  9666. if (botPlayer.health < 100) {
  9667. bot.place(0, 0)
  9668. }
  9669. }
  9670. function cdf (e, t){
  9671. try {
  9672. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9673. } catch(e){
  9674. return Infinity;
  9675. }
  9676. }
  9677. let zoon = 'no';
  9678. bot.zync = function(a) {
  9679. if (!botPlayer.millPlace) {
  9680. zoon = 'yeah';
  9681. bot.place(5, caf(botPlayer, a));
  9682. let NextTickLocation = {
  9683. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9684. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9685. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9686. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9687. };
  9688.  
  9689. function calculateDistance(x1, y1, x2, y2) {
  9690. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  9691. return distance;
  9692. }
  9693. function dotherezt() {
  9694. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9695. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  9696. }
  9697.  
  9698. let aa = setInterval(() => {
  9699. bot.sendWS("G", botPlayer.weapons[1], true);
  9700. if (izauto == 0) {
  9701. bot.sendWS("K", 1);
  9702. izauto = 1;
  9703. }
  9704. setTimeout(() => {
  9705. bot.sendWS("G", botPlayer.weapons[0], true);
  9706. }, 2000);
  9707. bot.buye(53, 0);
  9708. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  9709. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  9710. } else {
  9711. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9712. zoon = 'no';
  9713. bot.sendWS("a", undefined);
  9714. dotherezt();
  9715. clearInterval(aa);
  9716. }
  9717. }, 150);
  9718.  
  9719. setTimeout(() => {
  9720. zoon = 'no';
  9721. clearInterval(aa);
  9722. }, 500);
  9723. }
  9724. };
  9725. bot.onmessage = function(message) {
  9726. let data = new Uint8Array(message.data);
  9727. let parsed = window.msgpack.decode(data);
  9728. let type = parsed[0];
  9729. data = parsed[1];
  9730. if (type == "io-init") {
  9731. bot.spawn();
  9732. }
  9733. if (type == "1") {
  9734. botSID = data[0];
  9735. console.log(botSID)
  9736. }
  9737. if (type == "D") {
  9738. if (data[1]) {
  9739. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  9740. botPlayer.setData(data[0]);
  9741. botPlayer.inGame = true;
  9742. botPlayer.alive = true;
  9743. botPlayer.x2 = undefined;
  9744. botPlayer.y2 = undefined;
  9745. botPlayer.spawn(1);
  9746. botPlayer.oldHealth = 100;
  9747. botPlayer.health = 100;
  9748. botPlayer.showName = 'YEAHHH';
  9749. oldXY = {
  9750. x: data[0][3],
  9751. y: data[0][4]
  9752. }
  9753. bD.inGame = true;
  9754. if (bot.first) {
  9755. bot.first = false;
  9756. bots.push(bD);
  9757. }
  9758. }
  9759. }
  9760. if (type == "P") {
  9761. bot.spawn();
  9762. botPlayer.inGame = false;
  9763. bD.inGame = false;
  9764. }
  9765. if (type == "a") {
  9766. let tmpData = data[0];
  9767. botPlayer.tick++;
  9768. botPlayer.enemy = [];
  9769. botPlayer.near = [];
  9770. bot.showName = 'YEAHHH';
  9771. nearObj = [];
  9772. for (let i = 0; i < tmpData.length;) {
  9773. if (tmpData[i] == botPlayer.sid) {
  9774. botPlayer.x2 = tmpData[i + 1];
  9775. botPlayer.y2 = tmpData[i + 2];
  9776. botPlayer.d2 = tmpData[i + 3];
  9777. botPlayer.buildIndex = tmpData[i + 4];
  9778. botPlayer.weaponIndex = tmpData[i + 5];
  9779. botPlayer.weaponVariant = tmpData[i + 6];
  9780. botPlayer.team = tmpData[i + 7];
  9781. botPlayer.isLeader = tmpData[i + 8];
  9782. botPlayer.skinIndex = tmpData[i + 9];
  9783. botPlayer.tailIndex = tmpData[i + 10];
  9784. botPlayer.iconIndex = tmpData[i + 11];
  9785. botPlayer.zIndex = tmpData[i + 12];
  9786. botPlayer.visible = true;
  9787. bD.x2 = botPlayer.x2;
  9788. bD.y2 = botPlayer.y2;
  9789. }
  9790. i += 13;
  9791. }
  9792.  
  9793. for (let i = 0; i < tmpData.length;) {
  9794. tmpObj = findPlayerBySID(tmpData[i]);
  9795. if (tmpObj) {
  9796. if (!tmpObj.isTeam(botPlayer)) {
  9797. enemy.push(tmpObj);
  9798. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  9799. nears.push(tmpObj);
  9800. }
  9801. }
  9802. }
  9803. i += 13;
  9804. }
  9805.  
  9806. if (enemy.length) {
  9807. //console.log(enemy)
  9808. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  9809. return tmp1.dist2 - tmp2.dist2;
  9810. })[0];
  9811. }
  9812.  
  9813. if (izauto == 1) {
  9814. bot.sendWS("K", 1);
  9815. izauto = 0;
  9816. }
  9817.  
  9818. if (bD.closeSocket) {
  9819. botPlayer.closeSockets(bot);
  9820. }
  9821. if (bD.whyDie != "") {
  9822. botPlayer.whyDieChat(bot, bD.whyDie);
  9823. bD.whyDie = "";
  9824. }
  9825. if (botPlayer.alive) {
  9826. if (player.team) {
  9827. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  9828. botPlayer.team && (bot.sendWS("N"));
  9829. bot.sendWS("b", player.team);
  9830. }
  9831. }
  9832.  
  9833. let item = items.list[botPlayer.items[3]];
  9834. let a = botPlayer.itemCounts[item.group.id]
  9835. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  9836. if (botPlayer.inGame) {
  9837. bot.sendWS("D", botPlayer.moveDir);
  9838. if (izauto == 0) {
  9839. bot.sendWS("K", 1);
  9840. izauto = 1;
  9841. }
  9842. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9843. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9844. bot.place(3, aim + 7.7);
  9845. bot.place(3, aim - 7.7);
  9846. bot.place(3, aim);
  9847. oldXY = {
  9848. x: botPlayer.x2,
  9849. y: botPlayer.y2
  9850. };
  9851. }
  9852.  
  9853. if (botPlayer.tick % 90 === 0) {
  9854. let rand = Math.random() * Math.PI * 2;
  9855. botPlayer.moveDir = rand;
  9856. bot.sendWS("a", botPlayer.moveDir);
  9857. }
  9858. }
  9859. bot.fastGear();
  9860. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  9861. botPlayer.millPlace = false;
  9862. // bot.sendWS("K", 1);
  9863. bot.fastGear();
  9864. } else {
  9865. if (botPlayer.inGame) {
  9866. if (botObj.length > 0) {
  9867. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  9868. if (getEl("mode").value == 'fuckemup') {
  9869. // if (getEl("mode").value == "clear") {
  9870. bot.selectWeapon(botPlayer.weapons[1]);
  9871. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  9872. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  9873. nearObj = botObj.filter((e) => e.active && (findSID(buldingtoawdoin, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale + 10)).sort(function(a, b) {
  9874. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9875. })[0];
  9876. if (nearObj) {
  9877. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  9878. if ((gotoDist - isPassed) > 0) {
  9879. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9880. if (botPlayer.moveDir != undefined) {
  9881. botPlayer.moveDir = undefined;
  9882. bot.sendWS("a", botPlayer.moveDir);
  9883. bot.sendWS("D", botPlayer.nDir);
  9884. }
  9885. } else {
  9886. botPlayer.moveDir = gotoAim;
  9887. bot.sendWS("a", botPlayer.moveDir);
  9888. bot.sendWS("D", botPlayer.nDir);
  9889. }
  9890. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9891. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9892. bot.sendWS("D", botPlayer.nDir);
  9893. }
  9894. if (izauto == 0) {
  9895. bot.sendWS("K", 1);
  9896. izauto = 1;
  9897. }
  9898. bot.buye(40, 0);
  9899. } else {
  9900. botPlayer.moveDir = gotoAim;
  9901. bot.sendWS("a", botPlayer.moveDir);
  9902. bot.sendWS("D", botPlayer.nDir);
  9903. bot.fastGear();
  9904. }
  9905. } else {
  9906. botPlayer.moveDir = gotoAim;
  9907. bot.sendWS("a", botPlayer.moveDir);
  9908. bot.sendWS("D", botPlayer.nDir);
  9909. bot.fastGear();
  9910. }
  9911. }
  9912. }
  9913.  
  9914.  
  9915.  
  9916. if (botObj.length > 0) {
  9917. if (getEl("mode").value == 'flex') {
  9918. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  9919. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  9920. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  9921.  
  9922. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  9923.  
  9924. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  9925. if (dist > 22) // 22 is player speed without booster hat
  9926. return;
  9927. }
  9928. }
  9929.  
  9930.  
  9931. if (botObj.length > 0) {
  9932. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  9933. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9934. })[0];
  9935.  
  9936. if (nearObj) {
  9937. if (izauto == 0) {
  9938. bot.sendWS("K", 1);
  9939. izauto = 1;
  9940. }
  9941. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9942. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9943. bot.sendWS("D", botPlayer.nDir);
  9944. }
  9945. bot.buye(40, 0);
  9946. bot.buye(11, 1);
  9947. } else {
  9948. bot.fastGear();
  9949. bot.buye(11, 1);
  9950. }
  9951. bot.buye(11, 1);
  9952. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9953. // if (getEl("mode").value == "clear") {
  9954. bot.selectWeapon(botPlayer.weapons[1]);
  9955. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9956. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9957. nearObj = botObj.filter((e) => e.active && (findSID(breakObjects, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  9958. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9959. })[0];
  9960. if (nearObj) {
  9961. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9962. if ((gotoDist - isPassed) > 0) {
  9963. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9964. if (botPlayer.moveDir != undefined) {
  9965. botPlayer.moveDir = undefined;
  9966. bot.sendWS("a", botPlayer.moveDir);
  9967. bot.sendWS("D", botPlayer.nDir);
  9968. }
  9969. } else {
  9970. botPlayer.moveDir = gotoAim;
  9971. bot.sendWS("a", botPlayer.moveDir);
  9972. bot.sendWS("D", botPlayer.nDir);
  9973. }
  9974. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9975. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9976. bot.sendWS("D", botPlayer.nDir);
  9977. }
  9978. if (izauto == 0) {
  9979. bot.sendWS("K", 1);
  9980. izauto = 1;
  9981. }
  9982. bot.buye(40, 0);
  9983. bot.fastGear();
  9984. } else {
  9985. botPlayer.moveDir = gotoAim;
  9986. bot.sendWS("a", botPlayer.moveDir);
  9987. bot.sendWS("D", botPlayer.nDir);
  9988. bot.fastGear();
  9989. }
  9990. } else {
  9991. botPlayer.moveDir = gotoAim;
  9992. bot.sendWS("a", botPlayer.moveDir);
  9993. bot.sendWS("D", botPlayer.nDir);
  9994. bot.fastGear();
  9995. }
  9996. if (gotoDist > 300) {
  9997. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9998. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9999. bot.place(3, aim + 7.7);
  10000. bot.place(3, aim - 7.7);
  10001. bot.place(3, aim);
  10002. oldXY = {
  10003. x: botPlayer.x2,
  10004. y: botPlayer.y2
  10005. };
  10006. }
  10007. }
  10008. }
  10009. }
  10010.  
  10011. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  10012. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  10013.  
  10014. if(!wdaawdwad.length) {
  10015. if(zoon == 'no')
  10016. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  10017. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  10018. }
  10019.  
  10020. if(wdaawdwad.length) {
  10021. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  10022. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  10023. nearObj = botObj.filter((e) => e.active && (findSID(wdaawdwad, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  10024. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  10025. })[0];
  10026. if (nearObj) {
  10027. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  10028. if ((gotoDist - isPassed) > 0) {
  10029. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  10030. if (botPlayer.moveDir != undefined) {
  10031. botPlayer.moveDir = undefined;
  10032. bot.sendWS("a", botPlayer.moveDir);
  10033. bot.sendWS("D", botPlayer.nDir);
  10034. }
  10035. } else {
  10036. bot.sendWS("D", botPlayer.nDir);
  10037. }
  10038. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  10039. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  10040. bot.sendWS("D", botPlayer.nDir);
  10041. }
  10042. if (izauto == 0) {
  10043. bot.sendWS("K", 1);
  10044. izauto = 1;
  10045. }
  10046. bot.buye(40, 0);
  10047. bot.fastGear();
  10048. } else {
  10049. if(zoon == 'no')
  10050. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  10051. if(cdf(player, botPlayer) <= 110)
  10052. bot.sendWS("a", undefined);
  10053. else
  10054. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  10055. }
  10056. } else {
  10057. if(wdaawdwad.length) {
  10058. if(zoon == 'no')
  10059. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  10060. if(cdf(player, botPlayer) <= 110)
  10061. bot.sendWS("a", undefined);
  10062. else
  10063. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  10064. } else {
  10065. if(zoon == 'no')
  10066. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  10067. if(cdf(player, botPlayer) <= 110)
  10068. bot.sendWS("a", undefined);
  10069. else
  10070. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  10071. }
  10072. }
  10073. }
  10074. }
  10075. }
  10076. }
  10077. }
  10078. }
  10079. if (type == "H") {
  10080. let tmpData = data[0];
  10081. for (let i = 0; i < tmpData.length;) {
  10082. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  10083. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  10084. sid: tmpData[i + 7]
  10085. } : null));
  10086. i += 8;
  10087. }
  10088. }
  10089. if (type == "N") {
  10090. let index = data[0];
  10091. let value = data[1];
  10092. if (botPlayer) {
  10093. botPlayer[index] = value;
  10094. }
  10095. }
  10096. if (type == "O") {
  10097. if (data[0] == botPlayer.sid) {
  10098. botPlayer.oldHealth = botPlayer.health;
  10099. botPlayer.health = data[1];
  10100. botPlayer.judgeShame();
  10101. if (botPlayer.oldHealth > botPlayer.health) {
  10102. if (botPlayer.shameCount < 5) {
  10103. for (let i = 0; i < 2; i++) {
  10104. bot.place(0, botPlayer.nDir);
  10105. }
  10106.  
  10107. } else {
  10108. setTimeout(() => {
  10109. for (let i = 0; i < 2; i++) {
  10110. bot.place(0, botPlayer.nDir);
  10111. }
  10112. }, 95);
  10113. }
  10114. }
  10115. }
  10116. }
  10117. if (type == "Q") {
  10118. let sid = data[0];
  10119. botObjManager.disableBySid(sid);
  10120. }
  10121. if (type == "R") {
  10122. let sid = data[0];
  10123. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  10124. }
  10125. if (type == "S") {
  10126. let index = data[0];
  10127. let value = data[1];
  10128. if (botPlayer) {
  10129. botPlayer.itemCounts[index] = value;
  10130. }
  10131. }
  10132. if (type == "U") {
  10133. if (data[0] > 0) {
  10134. if(getEl("setup").value == 'dm') {
  10135. if (botPlayer.upgraded == 0) {
  10136. bot.sendUpgrade(7);
  10137. } else if (botPlayer.upgraded == 1) {
  10138. bot.sendUpgrade(17);
  10139. } else if (botPlayer.upgraded == 2) {
  10140. bot.sendUpgrade(31);
  10141. } else if (botPlayer.upgraded == 3) {
  10142. bot.sendUpgrade(23);
  10143. } else if (botPlayer.upgraded == 4) {
  10144. bot.sendUpgrade(9);
  10145. } else if (botPlayer.upgraded == 5) {
  10146. bot.sendUpgrade(34);
  10147. } else if (botPlayer.upgraded == 6) {
  10148. bot.sendUpgrade(12);
  10149. } else if (botPlayer.upgraded == 7) {
  10150. bot.sendUpgrade(15);
  10151. }
  10152. } else if(getEl("setup").value == 'dr') {
  10153. if (botPlayer.upgraded == 0) {
  10154. bot.sendUpgrade(7);
  10155. } else if (botPlayer.upgraded == 1) {
  10156. bot.sendUpgrade(17);
  10157. } else if (botPlayer.upgraded == 2) {
  10158. bot.sendUpgrade(31);
  10159. } else if (botPlayer.upgraded == 3) {
  10160. bot.sendUpgrade(23);
  10161. } else if (botPlayer.upgraded == 4) {
  10162. bot.sendUpgrade(9);
  10163. } else if (botPlayer.upgraded == 5) {
  10164. bot.sendUpgrade(34);
  10165. } else if (botPlayer.upgraded == 6) {
  10166. bot.sendUpgrade(12);
  10167. } else if (botPlayer.upgraded == 7) {
  10168. bot.sendUpgrade(13);
  10169. }
  10170. } else if(getEl("setup").value == 'kh') {
  10171. if (botPlayer.upgraded == 0) {
  10172. bot.sendUpgrade(3);
  10173. } else if (botPlayer.upgraded == 1) {
  10174. bot.sendUpgrade(17);
  10175. } else if (botPlayer.upgraded == 2) {
  10176. bot.sendUpgrade(31);
  10177. } else if (botPlayer.upgraded == 3) {
  10178. bot.sendUpgrade(27);
  10179. } else if (botPlayer.upgraded == 4) {
  10180. bot.sendUpgrade(10);
  10181. } else if (botPlayer.upgraded == 5) {
  10182. bot.sendUpgrade(34);
  10183. } else if (botPlayer.upgraded == 6) {
  10184. bot.sendUpgrade(4);
  10185. } else if (botPlayer.upgraded == 7) {
  10186. bot.sendUpgrade(25);
  10187. }
  10188. } else if(getEl("setup").value == 'zd') {
  10189. if (botPlayer.upgraded == 0) {
  10190. bot.sendUpgrade(3);
  10191. } else if (botPlayer.upgraded == 1) {
  10192. bot.sendUpgrade(17);
  10193. } else if (botPlayer.upgraded == 2) {
  10194. bot.sendUpgrade(31);
  10195. } else if (botPlayer.upgraded == 3) {
  10196. bot.sendUpgrade(27);
  10197. } else if (botPlayer.upgraded == 4) {
  10198. bot.sendUpgrade(9);
  10199. } else if (botPlayer.upgraded == 5) {
  10200. bot.sendUpgrade(34);
  10201. } else if (botPlayer.upgraded == 6) {
  10202. bot.sendUpgrade(12);
  10203. } else if (botPlayer.upgraded == 7) {
  10204. bot.sendUpgrade(15);
  10205. }
  10206. }
  10207. botPlayer.upgraded++;
  10208. }
  10209. }
  10210. if (type == "V") {
  10211. let tmpData = data[0];
  10212. let wpn = data[1];
  10213. if (tmpData) {
  10214. if (wpn) botPlayer.weapons = tmpData;
  10215. else botPlayer.items = tmpData;
  10216. }
  10217.  
  10218. }
  10219. if (type == "5") {
  10220. let type = data[0];
  10221. let id = data[1];
  10222. let index = data[2];
  10223. if (index) {
  10224. if (!type)
  10225. botPlayer.tails[id] = 1;
  10226. else
  10227. botPlayer.latestTail = id;
  10228. } else {
  10229. if (!type)
  10230. botPlayer.skins[id] = 1;
  10231. else
  10232. botPlayer.latestSkin = id;
  10233. }
  10234. }
  10235.  
  10236. if (type == "6") {
  10237. let id = data[0];
  10238. let mzg = data[1]+'';
  10239. if(id == player.sid && mzg.includes("syncon")) {
  10240. bot.zync(botPlayer.near);
  10241. }
  10242. }
  10243. };
  10244. bot.onclose = function() {
  10245. botPlayer.inGame = false;
  10246. bD.inGame = false;
  10247. };
  10248. }
  10249.  
  10250. // RENDER LEAF:
  10251. function renderLeaf(x, y, l, r, ctxt) {
  10252. let endX = x + (l * Math.cos(r));
  10253. let endY = y + (l * Math.sin(r));
  10254. let width = l * 0.4;
  10255. ctxt.moveTo(x, y);
  10256. ctxt.beginPath();
  10257. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  10258. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  10259. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  10260. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  10261. ctxt.closePath();
  10262. ctxt.fill();
  10263. ctxt.stroke();
  10264. }
  10265.  
  10266. // RENDER CIRCLE:
  10267. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  10268. tmpContext = tmpContext || mainContext;
  10269. tmpContext.beginPath();
  10270. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  10271. if (!dontFill) tmpContext.fill();
  10272. if (!dontStroke) tmpContext.stroke();
  10273. }
  10274.  
  10275. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  10276. tmpContext = tmpContext || mainContext;
  10277. tmpContext.beginPath();
  10278. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  10279. if (!dontFill) tmpContext.fill();
  10280. if (!dontStroke) tmpContext.stroke();
  10281. }
  10282.  
  10283. // RENDER STAR SHAPE:
  10284. function renderStar(ctxt, spikes, outer, inner) {
  10285. let rot = Math.PI / 2 * 3;
  10286. let x, y;
  10287. let step = Math.PI / spikes;
  10288. ctxt.beginPath();
  10289. ctxt.moveTo(0, -outer);
  10290. for (let i = 0; i < spikes; i++) {
  10291. x = Math.cos(rot) * outer;
  10292. y = Math.sin(rot) * outer;
  10293. ctxt.lineTo(x, y);
  10294. rot += step;
  10295. x = Math.cos(rot) * inner;
  10296. y = Math.sin(rot) * inner;
  10297. ctxt.lineTo(x, y);
  10298. rot += step;
  10299. }
  10300. ctxt.lineTo(0, -outer);
  10301. ctxt.closePath();
  10302. }
  10303.  
  10304. function renderHealthStar(ctxt, spikes, outer, inner) {
  10305. let rot = Math.PI / 2 * 3;
  10306. let x, y;
  10307. let step = Math.PI / spikes;
  10308. ctxt.beginPath();
  10309. ctxt.moveTo(0, -outer);
  10310. for (let i = 0; i < spikes; i++) {
  10311. x = Math.cos(rot) * outer;
  10312. y = Math.sin(rot) * outer;
  10313. ctxt.lineTo(x, y);
  10314. rot += step;
  10315. x = Math.cos(rot) * inner;
  10316. y = Math.sin(rot) * inner;
  10317. ctxt.lineTo(x, y);
  10318. rot += step;
  10319. }
  10320. ctxt.lineTo(0, -outer);
  10321. ctxt.closePath();
  10322. }
  10323.  
  10324. // RENDER RECTANGLE:
  10325. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  10326. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  10327. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  10328. }
  10329.  
  10330. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  10331. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  10332. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  10333. }
  10334.  
  10335. // RENDER RECTCIRCLE:
  10336. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  10337. ctxt.save();
  10338. ctxt.translate(x, y);
  10339. seg = Math.ceil(seg / 2);
  10340. for (let i = 0; i < seg; i++) {
  10341. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  10342. ctxt.rotate(Math.PI / seg);
  10343. }
  10344. ctxt.restore();
  10345. }
  10346.  
  10347. // RENDER BLOB:
  10348. function renderBlob(ctxt, spikes, outer, inner) {
  10349. let rot = Math.PI / 2 * 3;
  10350. let x, y;
  10351. let step = Math.PI / spikes;
  10352. let tmpOuter;
  10353. ctxt.beginPath();
  10354. ctxt.moveTo(0, -inner);
  10355. for (let i = 0; i < spikes; i++) {
  10356. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  10357. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  10358. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  10359. rot += step * 2;
  10360. }
  10361. ctxt.lineTo(0, -inner);
  10362. ctxt.closePath();
  10363. }
  10364.  
  10365. // RENDER TRIANGLE:
  10366. function renderTriangle(s, ctx) {
  10367. ctx = ctx || mainContext;
  10368. let h = s * (Math.sqrt(3) / 2);
  10369. ctx.beginPath();
  10370. ctx.moveTo(0, -h / 2);
  10371. ctx.lineTo(-s / 2, h / 2);
  10372. ctx.lineTo(s / 2, h / 2);
  10373. ctx.lineTo(0, -h / 2);
  10374. ctx.fill();
  10375. ctx.closePath();
  10376. }
  10377.  
  10378. // PREPARE MENU BACKGROUND:
  10379. function prepareMenuBackground() {
  10380. // let tmpMid = config.mapScale / 2;
  10381. // let attempts = 0;
  10382. // for (let i = 0; i < items.list.length * 3;) {
  10383. // if (attempts >= 1000) break;
  10384. // attempts++;
  10385. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  10386. // let data = {
  10387. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  10388. // y: tmpMid + UTILS.randFloat(-600, 600),
  10389. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  10390. // };
  10391. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  10392. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  10393. // } else {
  10394. // continue;
  10395. // }
  10396. // i++;
  10397. // }
  10398. }
  10399.  
  10400. const speed = 1;
  10401. // RENDER PLAYERS:
  10402. function renderDeadPlayers(xOffset, yOffset) {
  10403. mainContext.fillStyle = "#91b2db";
  10404. const currentTime = Date.now();
  10405. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  10406. if (!dead.startTime) {
  10407. dead.startTime = currentTime;
  10408. dead.angle = 0;
  10409. dead.radius = 0.1;
  10410. }
  10411. const timeElapsed = currentTime - dead.startTime;
  10412. const maxAlpha = 1;
  10413. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  10414. dead.animate(delta);
  10415. mainContext.globalAlpha = dead.alpha;
  10416. mainContext.strokeStyle = outlineColor;
  10417. mainContext.save();
  10418. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  10419. dead.radius -= 0.001;
  10420. dead.angle += 0.0174533;
  10421. const moveSpeed = 1;
  10422. const x = dead.radius * Math.cos(dead.angle);
  10423. const y = dead.radius * Math.sin(dead.angle);
  10424. dead.x += x * moveSpeed;
  10425. dead.y += y * moveSpeed;
  10426. mainContext.rotate(dead.angle);
  10427. renderDeadPlayer(dead, mainContext);
  10428. mainContext.restore();
  10429. mainContext.fillStyle = "#91b2db";
  10430. if (timeElapsed >= 3000) {
  10431. dead.active = false;
  10432. dead.startTime = null;
  10433. }
  10434. });
  10435. }
  10436. // RENDER PLAYERS:
  10437. function renderPlayers(xOffset, yOffset, zIndex) {
  10438. mainContext.globalAlpha = 1;
  10439. mainContext.fillStyle = "#91b2db";
  10440. for (var i = 0; i < players.length; ++i) {
  10441. tmpObj = players[i];
  10442. if (tmpObj.zIndex == zIndex) {
  10443. tmpObj.animate(delta);
  10444. if (tmpObj.visible) {
  10445. tmpObj.skinRot += (0.002 * delta);
  10446. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  10447. mainContext.save();
  10448. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10449. // RENDER PLAYER:
  10450. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  10451. renderPlayer(tmpObj, mainContext);
  10452. mainContext.restore();
  10453. }
  10454. }
  10455. }
  10456. }
  10457. // RENDER DEAD PLAYER:
  10458. function renderDeadPlayer(obj, ctxt) {
  10459. ctxt = ctxt || mainContext;
  10460. ctxt.lineWidth = outlineWidth;
  10461. ctxt.lineJoin = "miter";
  10462. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  10463. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  10464. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  10465. // TAIL/CAPE:
  10466. renderTail2(13, ctxt, obj);
  10467. // WEAPON BELLOW HANDS:
  10468. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  10469. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  10470. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10471. renderProjectile(obj.scale, 0,
  10472. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10473. }
  10474. }
  10475. // HANDS:
  10476. ctxt.fillStyle = "#ececec";
  10477. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  10478. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  10479. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  10480. // WEAPON ABOVE HANDS:
  10481. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  10482. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  10483. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10484. renderProjectile(obj.scale, 0,
  10485. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10486. }
  10487. }
  10488. // BUILD ITEM:
  10489. if (obj.buildIndex >= 0) {
  10490. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  10491. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  10492. }
  10493. // BODY:
  10494. renderCircle(0, 0, obj.scale, ctxt);
  10495. // SKIN
  10496. renderSkin2(48, ctxt, null, obj)
  10497. }
  10498.  
  10499. // RENDER PLAYER:
  10500. function renderPlayer(obj, ctxt) {
  10501. ctxt = ctxt || mainContext;
  10502. ctxt.lineWidth = outlineWidth;
  10503. ctxt.lineJoin = "miter";
  10504. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  10505. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  10506. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  10507.  
  10508. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  10509.  
  10510. // TAIL/CAPE:
  10511. if (obj.tailIndex > 0) {
  10512. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  10513. }
  10514.  
  10515. // WEAPON BELLOW HANDS:
  10516. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  10517. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  10518. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10519. renderProjectile(obj.scale, 0,
  10520. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10521. }
  10522. }
  10523.  
  10524. // HANDS:
  10525. ctxt.fillStyle = config.skinColors[obj.skinColor];
  10526. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  10527. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  10528. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  10529.  
  10530. // WEAPON ABOVE HANDS:
  10531. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  10532. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  10533. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10534. renderProjectile(obj.scale, 0,
  10535. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10536. }
  10537. }
  10538.  
  10539. // BUILD ITEM:
  10540. if (obj.buildIndex >= 0) {
  10541. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  10542. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  10543. }
  10544.  
  10545. // BODY:
  10546. renderCircle(0, 0, obj.scale, ctxt);
  10547.  
  10548. // SKIN:
  10549. if (obj.skinIndex > 0) {
  10550. ctxt.rotate(Math.PI / 2);
  10551. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  10552. }
  10553.  
  10554. }
  10555.  
  10556. // RENDER NORMAL SKIN
  10557. var skinSprites2 = {};
  10558. var skinPointers2 = {};
  10559. function renderSkin2(index, ctxt, parentSkin, owner) {
  10560. tmpSkin = skinSprites2[index];
  10561. if (!tmpSkin) {
  10562. var tmpImage = new Image();
  10563. tmpImage.onload = function() {
  10564. this.isLoaded = true;
  10565. this.onload = null;
  10566. };
  10567. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10568. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10569. skinSprites2[index] = tmpImage;
  10570. tmpSkin = tmpImage;
  10571. }
  10572. var tmpObj = parentSkin||skinPointers2[index];
  10573. if (!tmpObj) {
  10574. for (var i = 0; i < hats.length; ++i) {
  10575. if (hats[i].id == index) {
  10576. tmpObj = hats[i];
  10577. break;
  10578. }
  10579. }
  10580. skinPointers2[index] = tmpObj;
  10581. }
  10582. if (tmpSkin.isLoaded)
  10583. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10584. if (!parentSkin && tmpObj.topSprite) {
  10585. ctxt.save();
  10586. ctxt.rotate(owner.skinRot);
  10587. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  10588. ctxt.restore();
  10589. }
  10590. }
  10591.  
  10592. // RENDER SKIN:
  10593. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  10594. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  10595. var tmpImage = new Image();
  10596. tmpImage.onload = function() {
  10597. this.isLoaded = true,
  10598. this.onload = null
  10599. }
  10600. ,
  10601. tmpImage.src = setSkinTextureImage(index, "hat", index),
  10602. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10603. tmpSkin = tmpImage
  10604. }
  10605. var tmpObj = parentSkin||skinPointers[index];
  10606. if (!tmpObj) {
  10607. for (var i = 0; i < hats.length; ++i) {
  10608. if (hats[i].id == index) {
  10609. tmpObj = hats[i];
  10610. break;
  10611. }
  10612. }
  10613. skinPointers[index] = tmpObj;
  10614. }
  10615. if (tmpSkin.isLoaded)
  10616. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10617. if (!parentSkin && tmpObj.topSprite) {
  10618. ctxt.save();
  10619. ctxt.rotate(owner.skinRot);
  10620. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10621. ctxt.restore();
  10622. }
  10623. }
  10624.  
  10625. var FlareZHat = {
  10626. 7: "https://i.imgur.com/vAOzlyY.png",
  10627. 15: "https://i.imgur.com/YRQ8Ybq.png",
  10628. 40: "https://i.imgur.com/Xzmg27N.png",
  10629. 26: "https://i.imgur.com/I0xGtyZ.png",
  10630. 55: "https://i.imgur.com/uYgDtcZ.png",
  10631. 20: "https://i.imgur.com/f5uhWCk.png",
  10632. };
  10633.  
  10634. function setSkinTextureImage(id, type, id2) {
  10635. if (true) {
  10636. if(FlareZHat[id] && type == "hat") {
  10637. return FlareZHat[id];
  10638. } else {
  10639. if(type == "acc") {
  10640. return ".././img/accessories/access_" + id + ".png";
  10641. } else if(type == "hat") {
  10642. return ".././img/hats/hat_" + id + ".png";
  10643. } else {
  10644. return ".././img/weapons/" + id + ".png";
  10645. }
  10646. }
  10647. } else {
  10648. if(type == "acc") {
  10649. return ".././img/accessories/access_" + id + ".png";
  10650. } else if(type == "hat") {
  10651. return ".././img/hats/hat_" + id + ".png";
  10652. } else {
  10653. return ".././img/weapons/" + id + ".png";
  10654. }
  10655. }
  10656. }
  10657. // RENDER SKINS:
  10658. let skinSprites = {};
  10659. let skinPointers = {};
  10660. let tmpSkin;
  10661.  
  10662. function renderSkin(index, ctxt, parentSkin, owner) {
  10663. tmpSkin = skinSprites[index];
  10664. if (!tmpSkin) {
  10665. let tmpImage = new Image();
  10666. tmpImage.onload = function() {
  10667. this.isLoaded = true;
  10668. this.onload = null;
  10669. };
  10670. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10671. skinSprites[index] = tmpImage;
  10672. tmpSkin = tmpImage;
  10673. }
  10674. let tmpObj = parentSkin || skinPointers[index];
  10675. if (!tmpObj) {
  10676. for (let i = 0; i < hats.length; ++i) {
  10677. if (hats[i].id == index) {
  10678. tmpObj = hats[i];
  10679. break;
  10680. }
  10681. }
  10682. skinPointers[index] = tmpObj;
  10683. }
  10684. if (tmpSkin.isLoaded)
  10685. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  10686. if (!parentSkin && tmpObj.topSprite) {
  10687. ctxt.save();
  10688. ctxt.rotate(owner.skinRot);
  10689. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10690. ctxt.restore();
  10691. }
  10692. }
  10693.  
  10694. // RENDER TAIL:
  10695. var FlareZAcc = {
  10696. 21: "https://i.imgur.com/4ddZert.png",
  10697. 19: "https://i.imgur.com/sULkUZT.png",
  10698. };
  10699. function setTailTextureImage(id, type, id2) {
  10700. if (true) {
  10701. if(FlareZAcc[id] && type == "acc") {
  10702. return FlareZAcc[id];
  10703. } else {
  10704. if(type == "acc") {
  10705. return ".././img/accessories/access_" + id + ".png";
  10706. } else if(type == "hat") {
  10707. return ".././img/hats/hat_" + id + ".png";
  10708. } else {
  10709. return ".././img/weapons/" + id + ".png";
  10710. }
  10711. }
  10712. } else {
  10713. if(type == "acc") {
  10714. return ".././img/accessories/access_" + id + ".png";
  10715. } else if(type == "hat") {
  10716. return ".././img/hats/hat_" + id + ".png";
  10717. } else {
  10718. return ".././img/weapons/" + id + ".png";
  10719. }
  10720. }
  10721. }
  10722. function renderTailTextureImage(index, ctxt, owner) {
  10723. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  10724. var tmpImage = new Image();
  10725. tmpImage.onload = function() {
  10726. this.isLoaded = true,
  10727. this.onload = null
  10728. }
  10729. ,
  10730. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  10731. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10732. tmpSkin = tmpImage;
  10733. }
  10734. var tmpObj = accessPointers[index];
  10735. if (!tmpObj) {
  10736. for (var i = 0; i < accessories.length; ++i) {
  10737. if (accessories[i].id == index) {
  10738. tmpObj = accessories[i];
  10739. break;
  10740. }
  10741. }
  10742. accessPointers[index] = tmpObj;
  10743. }
  10744. if (tmpSkin.isLoaded) {
  10745. ctxt.save();
  10746. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10747. if (tmpObj.spin)
  10748. ctxt.rotate(owner.skinRot);
  10749. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10750. ctxt.restore();
  10751. }
  10752. }
  10753.  
  10754. let accessSprites = {};
  10755. let accessPointers = {};
  10756. var txt = true;
  10757.  
  10758. function renderTail(index, ctxt, owner) {
  10759. tmpSkin = accessSprites[index];
  10760. if (!tmpSkin) {
  10761. let tmpImage = new Image();
  10762. tmpImage.onload = function() {
  10763. this.isLoaded = true;
  10764. this.onload = null;
  10765. };
  10766. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10767. accessSprites[index] = tmpImage;
  10768. tmpSkin = tmpImage;
  10769. }
  10770. let tmpObj = accessPointers[index];
  10771. if (!tmpObj) {
  10772. for (let i = 0; i < accessories.length; ++i) {
  10773. if (accessories[i].id == index) {
  10774. tmpObj = accessories[i];
  10775. break;
  10776. }
  10777. }
  10778. accessPointers[index] = tmpObj;
  10779. }
  10780. if (tmpSkin.isLoaded) {
  10781. ctxt.save();
  10782. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  10783. if (tmpObj.spin)
  10784. ctxt.rotate(owner.skinRot);
  10785. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  10786. ctxt.restore();
  10787. }
  10788. }
  10789.  
  10790. var accessSprites2 = {};
  10791. var accessPointers2 = {};
  10792. function renderTail2(index, ctxt, owner) {
  10793. tmpSkin = accessSprites2[index];
  10794. if (!tmpSkin) {
  10795. var tmpImage = new Image();
  10796. tmpImage.onload = function() {
  10797. this.isLoaded = true;
  10798. this.onload = null;
  10799. };
  10800. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10801. accessSprites2[index] = tmpImage;
  10802. tmpSkin = tmpImage;
  10803. }
  10804. var tmpObj = accessPointers2[index];
  10805. if (!tmpObj) {
  10806. for (var i = 0; i < accessories.length; ++i) {
  10807. if (accessories[i].id == index) {
  10808. tmpObj = accessories[i];
  10809. break;
  10810. }
  10811. }
  10812. accessPointers2[index] = tmpObj;
  10813. }
  10814. if (tmpSkin.isLoaded) {
  10815. ctxt.save();
  10816. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10817. if (tmpObj.spin)
  10818. ctxt.rotate(owner.skinRot);
  10819. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10820. ctxt.restore();
  10821. }
  10822. }
  10823.  
  10824. // RENDER TOOL:
  10825. let toolSprites = {};
  10826. function renderTool(obj, variant, x, y, ctxt) {
  10827. let tmpSrc = obj.src + (variant || "");
  10828. let tmpSprite = toolSprites[tmpSrc];
  10829. if (!tmpSprite) {
  10830. tmpSprite = new Image();
  10831. tmpSprite.onload = function() {
  10832. this.isLoaded = true;
  10833. }
  10834. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10835. toolSprites[tmpSrc] = tmpSprite;
  10836. }
  10837. if (tmpSprite.isLoaded)
  10838. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  10839. }
  10840.  
  10841. // RENDER PROJECTILES:
  10842. function renderProjectiles(layer, xOffset, yOffset) {
  10843. for (let i = 0; i < projectiles.length; i++) {
  10844. tmpObj = projectiles[i];
  10845. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  10846. tmpObj.update(delta);
  10847. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  10848. mainContext.save();
  10849. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10850. mainContext.rotate(tmpObj.dir);
  10851. renderProjectile(0, 0, tmpObj, mainContext, 1);
  10852. mainContext.restore();
  10853. }
  10854. }
  10855. };
  10856. }
  10857.  
  10858. // RENDER PROJECTILE:
  10859. let projectileSprites = {};//fz iz zexy
  10860.  
  10861. function renderProjectile(x, y, obj, ctxt, debug) {
  10862. if (obj.src) {
  10863. let tmpSrc = items.projectiles[obj.indx].src;
  10864. let tmpSprite = projectileSprites[tmpSrc];
  10865. if (!tmpSprite) {
  10866. tmpSprite = new Image();
  10867. tmpSprite.onload = function() {
  10868. this.isLoaded = true;
  10869. }
  10870. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10871. projectileSprites[tmpSrc] = tmpSprite;
  10872. }
  10873. if (tmpSprite.isLoaded)
  10874. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  10875. } else if (obj.indx == 1) {
  10876. ctxt.fillStyle = "#939393";
  10877. renderCircle(x, y, obj.scale, ctxt);
  10878. }
  10879. }
  10880.  
  10881. // RENDER AI:
  10882. let aiSprites = {};
  10883.  
  10884. function renderAI(obj, ctxt) {
  10885. let tmpIndx = obj.index;
  10886. let tmpSprite = aiSprites[tmpIndx];
  10887. if (!tmpSprite) {
  10888. let tmpImg = new Image();
  10889. tmpImg.onload = function() {
  10890. this.isLoaded = true;
  10891. this.onload = null;
  10892. };
  10893. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  10894. tmpSprite = tmpImg;
  10895. aiSprites[tmpIndx] = tmpSprite;
  10896. }
  10897. if (tmpSprite.isLoaded) {
  10898. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  10899. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  10900. }
  10901. }
  10902.  
  10903. // RENDER WATER BODIES:
  10904. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  10905.  
  10906. // MIDDLE RIVER:
  10907. let tmpW = config.riverWidth + padding;
  10908. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  10909. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  10910. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  10911. }
  10912. }
  10913.  
  10914. // RENDER GAME OBJECTS:
  10915. let gameObjectSprites = {};
  10916.  
  10917. function getResSprite(obj) {
  10918. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  10919. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  10920. let tmpSprite = gameObjectSprites[tmpIndex];
  10921. if (!tmpSprite) {
  10922. let blurScale = 6;
  10923. let tmpCanvas = document.createElement("canvas");
  10924. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  10925. let tmpContext = tmpCanvas.getContext('2d');
  10926. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10927. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  10928. tmpContext.strokeStyle = outlineColor;
  10929. tmpContext.lineWidth = outlineWidth;
  10930. // if (isNight) {
  10931. // tmpContext.shadowBlur = blurScale;
  10932. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  10933. // }
  10934. if (obj.type == 0) {
  10935. let tmpScale;
  10936. let tmpCount = 8;
  10937. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  10938. for (let i = 0; i < 2; ++i) {
  10939. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  10940. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  10941. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  10942. tmpContext.fill();
  10943. if (!i) {
  10944. tmpContext.stroke();
  10945. tmpContext.shadowBlur = null;
  10946. tmpContext.shadowColor = null;
  10947. tmpContext.globalAlpha = 1;
  10948. }
  10949. }
  10950. } else if (obj.type == 1) {
  10951. if (biomeID == 2) {
  10952. tmpContext.fillStyle = "#606060";
  10953. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  10954. tmpContext.fill();
  10955. tmpContext.stroke();
  10956.  
  10957. //tmpContext.shadowBlur = null;
  10958. //tmpContext.shadowColor = null;
  10959.  
  10960. tmpContext.fillStyle = "#89a54c";
  10961. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  10962. tmpContext.fillStyle = "#a5c65b";
  10963. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  10964. } else {
  10965. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  10966. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  10967. tmpContext.fill();
  10968. tmpContext.stroke();
  10969.  
  10970. //tmpContext.shadowBlur = null;
  10971. //tmpContext.shadowColor = null;
  10972.  
  10973. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  10974. let tmpRange;
  10975. let berries = 4;
  10976. let rotVal = (Math.PI * 2) / berries;
  10977. for (let i = 0; i < berries; ++i) {
  10978. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  10979. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10980. UTILS.randInt(10, 12), tmpContext);
  10981. }
  10982. }
  10983. } else if (obj.type == 2 || obj.type == 3) {
  10984. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  10985. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10986. tmpContext.fill();
  10987. tmpContext.stroke();
  10988.  
  10989. tmpContext.shadowBlur = null;
  10990. tmpContext.shadowColor = null;
  10991.  
  10992. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  10993. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10994. tmpContext.fill();
  10995. }
  10996. tmpSprite = tmpCanvas;
  10997. gameObjectSprites[tmpIndex] = tmpSprite;
  10998. }
  10999. return tmpSprite;
  11000. }
  11001.  
  11002. // GET ITEM SPRITE:
  11003. let itemSprites = [];
  11004.  
  11005. function getItemSprite(obj, asIcon) {
  11006. let tmpSprite = itemSprites[obj.id];
  11007. if (!tmpSprite || asIcon) {
  11008. let blurScale = !asIcon ? 20 : 5;
  11009. let tmpCanvas = document.createElement("canvas");
  11010. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  11011. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  11012.  
  11013. let tmpContext = tmpCanvas.getContext("2d");
  11014. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11015. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  11016. tmpContext.strokeStyle = outlineColor;
  11017. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  11018. if (!asIcon) {
  11019. tmpContext.shadowBlur = 8;
  11020. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  11021. }
  11022.  
  11023. if (obj.name == "apple") {
  11024. tmpContext.fillStyle = "#c15555";
  11025. renderCircle(0, 0, obj.scale, tmpContext);
  11026. tmpContext.fillStyle = "#89a54c";
  11027. let leafDir = -(Math.PI / 2);
  11028. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  11029. 25, leafDir + Math.PI / 2, tmpContext);
  11030. } else if (obj.name == "cookie") {
  11031. tmpContext.fillStyle = "#cca861";
  11032. renderCircle(0, 0, obj.scale, tmpContext);
  11033. tmpContext.fillStyle = "#937c4b";
  11034. let chips = 4;
  11035. let rotVal = (Math.PI * 2) / chips;
  11036. let tmpRange;
  11037. for (let i = 0; i < chips; ++i) {
  11038. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11039. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11040. UTILS.randInt(4, 5), tmpContext, true);
  11041. }
  11042. } else if (obj.name == "cheese") {
  11043. tmpContext.fillStyle = "#f4f3ac";
  11044. renderCircle(0, 0, obj.scale, tmpContext);
  11045. tmpContext.fillStyle = "#c3c28b";
  11046. let chips = 4;
  11047. let rotVal = (Math.PI * 2) / chips;
  11048. let tmpRange;
  11049. for (let i = 0; i < chips; ++i) {
  11050. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11051. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11052. UTILS.randInt(4, 5), tmpContext, true);
  11053. }
  11054. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  11055. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  11056. "#a5974c" : "#939393";
  11057. let sides = (obj.name == "castle wall") ? 4 : 3;
  11058. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  11059. tmpContext.fill();
  11060. tmpContext.stroke();
  11061. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  11062. "#c9b758" : "#bcbcbc";
  11063. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  11064. tmpContext.fill();
  11065. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  11066. obj.name == "spinning spikes") {
  11067. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  11068. let tmpScale = (obj.scale * 0.6);
  11069. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  11070. tmpContext.fill();
  11071. tmpContext.stroke();
  11072. tmpContext.fillStyle = "#a5974c";
  11073. renderCircle(0, 0, tmpScale, tmpContext);
  11074. tmpContext.fillStyle = "#c9b758";
  11075. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11076. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11077. tmpContext.fillStyle = "#a5974c";
  11078. renderCircle(0, 0, reScale, tmpContext);
  11079. tmpContext.fillStyle = "#c9b758";
  11080. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  11081. tmpContext.fillStyle = "#a5974c";
  11082. renderCircle(0, 0, reScale * 0.5, tmpContext);
  11083. } else if (obj.name == "mine") {
  11084. tmpContext.fillStyle = "#939393";
  11085. renderStar(tmpContext, 3, obj.scale, obj.scale);
  11086. tmpContext.fill();
  11087. tmpContext.stroke();
  11088. tmpContext.fillStyle = "#bcbcbc";
  11089. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  11090. tmpContext.fill();
  11091. } else if (obj.name == "sapling") {
  11092. for (let i = 0; i < 2; ++i) {
  11093. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  11094. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  11095. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  11096. tmpContext.fill();
  11097. if (!i) tmpContext.stroke();
  11098. }
  11099. } else if (obj.name == "pit trap") {
  11100. tmpContext.fillStyle = "#a5974c";
  11101. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11102. tmpContext.fill();
  11103. tmpContext.stroke();
  11104. tmpContext.fillStyle = outlineColor;
  11105. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11106. tmpContext.fill();
  11107. } else if (obj.name == "boost pad") {
  11108. tmpContext.fillStyle = "#7e7f82";
  11109. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11110. tmpContext.fill();
  11111. tmpContext.stroke();
  11112. tmpContext.fillStyle = "#dbd97d";
  11113. renderTriangle(obj.scale * 1, tmpContext);
  11114. } else if (obj.name == "turret") {
  11115. tmpContext.fillStyle = "#a5974c";
  11116. renderCircle(0, 0, obj.scale, tmpContext);
  11117. tmpContext.fill();
  11118. tmpContext.stroke();
  11119. tmpContext.fillStyle = "#939393";
  11120. let tmpLen = 50;
  11121. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11122. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11123. tmpContext.fill();
  11124. tmpContext.stroke();
  11125. } else if (obj.name == "platform") {
  11126. tmpContext.fillStyle = "#cebd5f";
  11127. let tmpCount = 4;
  11128. let tmpS = obj.scale * 2;
  11129. let tmpW = tmpS / tmpCount;
  11130. let tmpX = -(obj.scale / 2);
  11131. for (let i = 0; i < tmpCount; ++i) {
  11132. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11133. tmpContext.fill();
  11134. tmpContext.stroke();
  11135. tmpX += tmpS / tmpCount;
  11136. }
  11137. } else if (obj.name == "healing pad") {
  11138. tmpContext.fillStyle = "#7e7f82";
  11139. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11140. tmpContext.fill();
  11141. tmpContext.stroke();
  11142. tmpContext.fillStyle = "#db6e6e";
  11143. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11144. } else if (obj.name == "spawn pad") {
  11145. tmpContext.fillStyle = "#7e7f82";
  11146. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11147. tmpContext.fill();
  11148. tmpContext.stroke();
  11149. tmpContext.fillStyle = "#71aad6";
  11150. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11151. } else if (obj.name == "blocker") {
  11152. tmpContext.fillStyle = "#7e7f82";
  11153. renderCircle(0, 0, obj.scale, tmpContext);
  11154. tmpContext.fill();
  11155. tmpContext.stroke();
  11156. tmpContext.rotate(Math.PI / 4);
  11157. tmpContext.fillStyle = "#db6e6e";
  11158. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11159. } else if (obj.name == "teleporter") {
  11160. tmpContext.fillStyle = "#7e7f82";
  11161. renderCircle(0, 0, obj.scale, tmpContext);
  11162. tmpContext.fill();
  11163. tmpContext.stroke();
  11164. tmpContext.rotate(Math.PI / 4);
  11165. tmpContext.fillStyle = "#d76edb";
  11166. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11167. }
  11168. tmpSprite = tmpCanvas;
  11169. if (!asIcon)
  11170. itemSprites[obj.id] = tmpSprite;
  11171. }
  11172. return tmpSprite;
  11173. }
  11174.  
  11175. function getItemSprite2(obj, tmpX, tmpY) {
  11176. let tmpContext = mainContext;
  11177. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  11178. tmpContext.save();
  11179. tmpContext.translate(tmpX, tmpY);
  11180. tmpContext.rotate(obj.dir);
  11181. tmpContext.strokeStyle = outlineColor;
  11182. tmpContext.lineWidth = outlineWidth;
  11183. if (obj.name == "apple") {
  11184. tmpContext.fillStyle = "#c15555";
  11185. renderCircle(0, 0, obj.scale, tmpContext);
  11186. tmpContext.fillStyle = "#89a54c";
  11187. let leafDir = -(Math.PI / 2);
  11188. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  11189. 25, leafDir + Math.PI / 2, tmpContext);
  11190. } else if (obj.name == "cookie") {
  11191. tmpContext.fillStyle = "#cca861";
  11192. renderCircle(0, 0, obj.scale, tmpContext);
  11193. tmpContext.fillStyle = "#937c4b";
  11194. let chips = 4;
  11195. let rotVal = (Math.PI * 2) / chips;
  11196. let tmpRange;
  11197. for (let i = 0; i < chips; ++i) {
  11198. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11199. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11200. UTILS.randInt(4, 5), tmpContext, true);
  11201. }
  11202. } else if (obj.name == "cheese") {
  11203. tmpContext.fillStyle = "#f4f3ac";
  11204. renderCircle(0, 0, obj.scale, tmpContext);
  11205. tmpContext.fillStyle = "#c3c28b";
  11206. let chips = 4;
  11207. let rotVal = (Math.PI * 2) / chips;
  11208. let tmpRange;
  11209. for (let i = 0; i < chips; ++i) {
  11210. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11211. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11212. UTILS.randInt(4, 5), tmpContext, true);
  11213. }
  11214. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  11215. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  11216. "#a5974c" : "#939393";
  11217. let sides = (obj.name == "castle wall") ? 4 : 3;
  11218. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  11219. tmpContext.fill();
  11220. tmpContext.stroke();
  11221. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  11222. "#c9b758" : "#bcbcbc";
  11223. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  11224. tmpContext.fill();
  11225. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  11226. obj.name == "spinning spikes") {
  11227. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  11228. let tmpScale = (obj.scale * 0.6);
  11229. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  11230. tmpContext.fill();
  11231. tmpContext.stroke();
  11232. tmpContext.fillStyle = "#a5974c";
  11233. renderCircle(0, 0, tmpScale, tmpContext);
  11234. tmpContext.fillStyle = "#c9b758";
  11235. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11236. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11237. tmpContext.fillStyle = "#a5974c";
  11238. renderCircle(0, 0, reScale, tmpContext);
  11239. tmpContext.fillStyle = "#c9b758";
  11240. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  11241. tmpContext.fillStyle = "#a5974c";
  11242. renderCircle(0, 0, reScale * 0.5, tmpContext);
  11243. } else if (obj.name == "mine") {
  11244. tmpContext.fillStyle = "#939393";
  11245. renderStar(tmpContext, 3, obj.scale, obj.scale);
  11246. tmpContext.fill();
  11247. tmpContext.stroke();
  11248. tmpContext.fillStyle = "#bcbcbc";
  11249. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  11250. tmpContext.fill();
  11251. } else if (obj.name == "sapling") {
  11252. for (let i = 0; i < 2; ++i) {
  11253. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  11254. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  11255. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  11256. tmpContext.fill();
  11257. if (!i) tmpContext.stroke();
  11258. }
  11259. } else if (obj.name == "pit trap") {
  11260. tmpContext.fillStyle = "#a5974c";
  11261. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11262. tmpContext.fill();
  11263. tmpContext.stroke();
  11264. tmpContext.fillStyle = outlineColor;
  11265. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11266. tmpContext.fill();
  11267. } else if (obj.name == "boost pad") {
  11268. tmpContext.fillStyle = "#7e7f82";
  11269. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11270. tmpContext.fill();
  11271. tmpContext.stroke();
  11272. tmpContext.fillStyle = "#dbd97d";
  11273. renderTriangle(obj.scale * 1, tmpContext);
  11274. } else if (obj.name == "turret") {
  11275. tmpContext.fillStyle = "#a5974c";
  11276. renderCircle(0, 0, obj.scale, tmpContext);
  11277. tmpContext.fill();
  11278. tmpContext.stroke();
  11279. tmpContext.fillStyle = "#939393";
  11280. let tmpLen = 50;
  11281. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11282. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11283. tmpContext.fill();
  11284. tmpContext.stroke();
  11285. } else if (obj.name == "platform") {
  11286. tmpContext.fillStyle = "#cebd5f";
  11287. let tmpCount = 4;
  11288. let tmpS = obj.scale * 2;
  11289. let tmpW = tmpS / tmpCount;
  11290. let tmpX = -(obj.scale / 2);
  11291. for (let i = 0; i < tmpCount; ++i) {
  11292. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11293. tmpContext.fill();
  11294. tmpContext.stroke();
  11295. tmpX += tmpS / tmpCount;
  11296. }
  11297. } else if (obj.name == "healing pad") {
  11298. tmpContext.fillStyle = "#7e7f82";
  11299. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11300. tmpContext.fill();
  11301. tmpContext.stroke();
  11302. tmpContext.fillStyle = "#db6e6e";
  11303. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11304. } else if (obj.name == "spawn pad") {
  11305. tmpContext.fillStyle = "#7e7f82";
  11306. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11307. tmpContext.fill();
  11308. tmpContext.stroke();
  11309. tmpContext.fillStyle = "#71aad6";
  11310. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11311. } else if (obj.name == "blocker") {
  11312. tmpContext.fillStyle = "#7e7f82";
  11313. renderCircle(0, 0, obj.scale, tmpContext);
  11314. tmpContext.fill();
  11315. tmpContext.stroke();
  11316. tmpContext.rotate(Math.PI / 4);
  11317. tmpContext.fillStyle = "#db6e6e";
  11318. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11319. } else if (obj.name == "teleporter") {
  11320. tmpContext.fillStyle = "#7e7f82";
  11321. renderCircle(0, 0, obj.scale, tmpContext);
  11322. tmpContext.fill();
  11323. tmpContext.stroke();
  11324. tmpContext.rotate(Math.PI / 4);
  11325. tmpContext.fillStyle = "#d76edb";
  11326. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11327. }
  11328. tmpContext.restore();
  11329. }
  11330.  
  11331. let objSprites = [];
  11332.  
  11333. function getObjSprite(obj) {
  11334. let tmpSprite = objSprites[obj.id];
  11335. if (!tmpSprite) {
  11336. // let blurScale = isNight ? 20 : 0;
  11337. let tmpCanvas = document.createElement("canvas");
  11338. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  11339. let tmpContext = tmpCanvas.getContext("2d");
  11340. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  11341. tmpContext.rotate(Math.PI / 2);
  11342. tmpContext.strokeStyle = outlineColor;
  11343. tmpContext.lineWidth = outlineWidth;
  11344. // if (isNight) {
  11345. // tmpContext.shadowBlur = 20;
  11346. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  11347. // }
  11348. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  11349. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  11350. let tmpScale = obj.scale * 0.6;
  11351. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  11352. tmpContext.fill();
  11353. tmpContext.stroke();
  11354. tmpContext.fillStyle = "#a5974c";
  11355. renderCircle(0, 0, tmpScale, tmpContext);
  11356. tmpContext.fillStyle = "#cc5151";
  11357. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11358. } else if (obj.name == "pit trap") {
  11359. tmpContext.fillStyle = "#a5974c";
  11360. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11361. tmpContext.fill();
  11362. tmpContext.stroke();
  11363. tmpContext.fillStyle = "#cc5151";
  11364. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11365. tmpContext.fill();
  11366. }
  11367. tmpSprite = tmpCanvas;
  11368. objSprites[obj.id] = tmpSprite;
  11369. }
  11370. return tmpSprite;
  11371. }
  11372.  
  11373. // GET MARK SPRITE:
  11374. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  11375. let center = {
  11376. x: screenWidth / 2,
  11377. y: screenHeight / 2,
  11378. };
  11379. tmpContext.lineWidth = outlineWidth;
  11380. mainContext.globalAlpha = 0.2;
  11381. tmpContext.strokeStyle = outlineColor;
  11382. tmpContext.save();
  11383. tmpContext.translate(tmpX, tmpY);
  11384. tmpContext.rotate(90**10);
  11385. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  11386. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  11387. var tmpScale = (obj.scale);
  11388. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  11389. tmpContext.fill();
  11390. tmpContext.stroke();
  11391. tmpContext.fillStyle = "#a5974c";
  11392. renderCircle(0, 0, tmpScale, tmpContext);
  11393. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  11394. tmpContext.fillStyle = "#a34040";
  11395. } else {
  11396. tmpContext.fillStyle = "#c9b758";
  11397. }
  11398. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  11399. } else if (obj.name == "turret") {
  11400. renderCircle(0, 0, obj.scale, tmpContext);
  11401. tmpContext.fill();
  11402. tmpContext.stroke();
  11403. tmpContext.fillStyle = "#939393";
  11404. let tmpLen = 50;
  11405. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11406. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11407. tmpContext.fill();
  11408. tmpContext.stroke();
  11409. } else if (obj.name == "teleporter") {
  11410. tmpContext.fillStyle = "#7e7f82";
  11411. renderCircle(0, 0, obj.scale, tmpContext);
  11412. tmpContext.fill();
  11413. tmpContext.stroke();
  11414. tmpContext.rotate(Math.PI / 4);
  11415. tmpContext.fillStyle = "#d76edb";
  11416. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11417. } else if (obj.name == "platform") {
  11418. tmpContext.fillStyle = "#cebd5f";
  11419. let tmpCount = 4;
  11420. let tmpS = obj.scale * 2;
  11421. let tmpW = tmpS / tmpCount;
  11422. let tmpX = -(obj.scale / 2);
  11423. for (let i = 0; i < tmpCount; ++i) {
  11424. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11425. tmpContext.fill();
  11426. tmpContext.stroke();
  11427. tmpX += tmpS / tmpCount;
  11428. }
  11429. } else if (obj.name == "healing pad") {
  11430. tmpContext.fillStyle = "#7e7f82";
  11431. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11432. tmpContext.fill();
  11433. tmpContext.stroke();
  11434. tmpContext.fillStyle = "#db6e6e";
  11435. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11436. } else if (obj.name == "spawn pad") {
  11437. tmpContext.fillStyle = "#7e7f82";
  11438. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11439. tmpContext.fill();
  11440. tmpContext.stroke();
  11441. tmpContext.fillStyle = "#71aad6";
  11442. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11443. } else if (obj.name == "blocker") {
  11444. tmpContext.fillStyle = "#7e7f82";
  11445. renderCircle(0, 0, obj.scale, tmpContext);
  11446. tmpContext.fill();
  11447. tmpContext.stroke();
  11448. tmpContext.rotate(Math.PI / 4);
  11449. tmpContext.fillStyle = "#db6e6e";
  11450. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11451. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11452. tmpContext.fillStyle = "#a5974c";
  11453. renderCircle(0, 0, obj.scale, tmpContext);
  11454. tmpContext.fillStyle = "#c9b758";
  11455. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  11456. tmpContext.fillStyle = "#a5974c";
  11457. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  11458.  
  11459. } else if (obj.name == "pit trap") {
  11460. tmpContext.fillStyle = "#a5974c";
  11461. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11462. tmpContext.fill();
  11463. tmpContext.stroke();
  11464. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  11465. tmpContext.fillStyle = "#a34040";
  11466. } else {
  11467. tmpContext.fillStyle = outlineColor;
  11468. }
  11469. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11470. tmpContext.fill();
  11471. }
  11472. tmpContext.restore();
  11473. }
  11474.  
  11475. // OBJECT ON SCREEN:
  11476. function isOnScreen(x, y, s) {
  11477. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  11478. s,
  11479. maxScreenHeight));
  11480. }
  11481.  
  11482. // RENDER GAME OBJECTS:
  11483. function renderGameObjects(layer, xOffset, yOffset) {
  11484. let tmpSprite;
  11485. let tmpX;
  11486. let tmpY;
  11487. liztobj.forEach((tmp) => {
  11488. tmpObj = tmp;
  11489. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  11490. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  11491. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  11492. if (layer == 0) {
  11493. tmpObj.update(delta);
  11494. }
  11495. mainContext.globalAlpha = tmpObj.alpha;
  11496. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  11497. if (tmpObj.isItem) {
  11498. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  11499. tmpSprite = getObjSprite(tmpObj);
  11500. } else {
  11501. tmpSprite = getItemSprite(tmpObj);
  11502. }
  11503.  
  11504. mainContext.save();
  11505. mainContext.translate(tmpX, tmpY);
  11506. mainContext.rotate(tmpObj.dir);
  11507. if (!tmpObj.active) {
  11508. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  11509. }
  11510. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  11511.  
  11512. if (tmpObj.blocker) {
  11513. mainContext.strokeStyle = "#db6e6e";
  11514. mainContext.globalAlpha = 0.3;
  11515. mainContext.lineWidth = 6;
  11516. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  11517. }
  11518. mainContext.restore();
  11519. } else {
  11520. tmpSprite = getResSprite(tmpObj);
  11521. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  11522. }
  11523. }
  11524. if (getEl("buildingHealth").checked) {
  11525. if (layer == 3) {
  11526. if (tmpObj.health < tmpObj.maxHealth) {
  11527. const endAngle = ((tmpObj.health / tmpObj.maxHealth) * 360) * (Math.PI / 180);
  11528. const radius = 14;
  11529. const scale = 22;
  11530. mainContext.save();
  11531. mainContext.strokeStyle = "";
  11532. mainContext.lineWidth = 16;
  11533. mainContext.lineCap = "round";
  11534. mainContext.shadowColor = "";
  11535. mainContext.translate(tmpX, tmpY);
  11536. mainContext.beginPath();
  11537. mainContext.arc(0, 0, scale, 0, endAngle);
  11538. mainContext.stroke();
  11539. mainContext.restore();
  11540.  
  11541. mainContext.save();
  11542. mainContext.strokeStyle = tmpObj.isTeamObject(player) ? "#0091ff" : "#FF0000";
  11543. mainContext.shadowColor = tmpObj.isTeamObject(player) ? "" : "rgb(200, 50, 50)";
  11544. mainContext.shadowBlur = 50;
  11545. mainContext.lineWidth = 14 / 2.5;
  11546. mainContext.lineCap = "round";
  11547. mainContext.shadowColor = "";
  11548. mainContext.translate(tmpX, tmpY);
  11549. mainContext.beginPath();
  11550. mainContext.arc(0, 0, scale, 0, endAngle);
  11551. mainContext.stroke();
  11552. mainContext.restore();
  11553. }
  11554. }
  11555. }
  11556. }
  11557. });
  11558.  
  11559.  
  11560. // PLACE VISIBLE:
  11561. if (layer == 0) {
  11562. if (placeVisible.length) {
  11563. placeVisible.forEach((places) => {
  11564. tmpX = places.x - xOffset;
  11565. tmpY = places.y - yOffset;
  11566. markObject(places, tmpX, tmpY);
  11567. });
  11568. }
  11569. }
  11570. }
  11571.  
  11572. function markObject(tmpObj, tmpX, tmpY) {
  11573. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  11574. }
  11575.  
  11576. // RENDER MINIMAP:
  11577. class MapPing {
  11578. constructor(color, scale) {
  11579. this.init = function(x, y) {
  11580. this.scale = 0;
  11581. this.x = x;
  11582. this.y = y;
  11583. this.active = true;
  11584. };
  11585. this.update = function(ctxt, delta) {
  11586. if (this.active) {
  11587. this.scale += 0.05 * delta;
  11588. if (this.scale >= scale) {
  11589. this.active = false;
  11590. } else {
  11591. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  11592. ctxt.beginPath();
  11593. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  11594. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  11595. ctxt.stroke();
  11596. }
  11597. }
  11598. };
  11599. this.color = color;
  11600. }
  11601. }
  11602.  
  11603. function pingMap(x, y) {
  11604. tmpPing = mapPings.find(pings => !pings.active);
  11605. if (!tmpPing) {
  11606. tmpPing = new MapPing("#fff", config.mapPingScale);
  11607. mapPings.push(tmpPing);
  11608. }
  11609. tmpPing.init(x, y);
  11610. }
  11611.  
  11612. function updateMapMarker() {
  11613. mapMarker.x = player.x;
  11614. mapMarker.y = player.y;
  11615. }
  11616.  
  11617. function renderMinimap(delta) {
  11618. if (player && player.alive) {
  11619. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  11620.  
  11621. // RENDER PINGS:
  11622. mapContext.lineWidth = 4;
  11623. for (let i = 0; i < mapPings.length; ++i) {
  11624. tmpPing = mapPings[i];
  11625. mapContext.strokeStyle = tmpPing.color;
  11626. tmpPing.update(mapContext, delta);
  11627. }
  11628.  
  11629. // RENDER BREAK TRACKS:
  11630. mapContext.globalAlpha = 1;
  11631. mapContext.fillStyle = "#ff0000";
  11632. if (breakTrackers.length) {
  11633. mapContext.fillStyle = "#abcdef";
  11634. mapContext.font = "34px Hammersmith One";
  11635. mapContext.textBaseline = "middle";
  11636. mapContext.textAlign = "center";
  11637. for (let i = 0; i < breakTrackers.length;) {
  11638. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  11639. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  11640. i += 2;
  11641. }
  11642. }
  11643.  
  11644. // RENDER PLAYERS:
  11645. mapContext.globalAlpha = 1;
  11646. mapContext.fillStyle = "#fff";
  11647. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  11648. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11649. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  11650. if (player.team && minimapData) {
  11651. for (let i = 0; i < minimapData.length;) {
  11652. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  11653. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11654. i += 2;
  11655. }
  11656. }
  11657.  
  11658. // RENDER BOTS:
  11659. if (bots.length) {
  11660. bots.forEach((tmp) => {
  11661. if (tmp.inGame) {
  11662. mapContext.globalAlpha = 1;
  11663. mapContext.strokeStyle = "#cc5151";
  11664. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  11665. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  11666. }
  11667. });
  11668. }
  11669.  
  11670. // DEATH LOCATION:
  11671. if (lastDeath) {
  11672. mapContext.fillStyle = "#fc5553";
  11673. mapContext.font = "34px Hammersmith One";
  11674. mapContext.textBaseline = "middle";
  11675. mapContext.textAlign = "center";
  11676. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  11677. (lastDeath.y / config.mapScale) * mapDisplay.height);
  11678. }
  11679.  
  11680. // MAP MARKER:
  11681. if (mapMarker) {
  11682. mapContext.fillStyle = "#fff";
  11683. mapContext.font = "34px Hammersmith One";
  11684. mapContext.textBaseline = "middle";
  11685. mapContext.textAlign = "center";
  11686. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  11687. (mapMarker.y / config.mapScale) * mapDisplay.height);
  11688. }
  11689. }
  11690. }
  11691.  
  11692. // ICONS:
  11693. let crossHairs = ["https://static-00.iconduck.com/assets.00/crosshair-icon-512x512-s3bxro8r.png", "https://static-00.iconduck.com/assets.00/crosshair-icon-512x512-s3bxro8r.png"];
  11694. let crossHairSprites = {};
  11695. let iconSprites = {};
  11696. let icons = ["crown", "skull"];
  11697.  
  11698. function loadIcons() {
  11699. for (let i = 0; i < icons.length; ++i) {
  11700. let tmpSprite = new Image();
  11701. tmpSprite.onload = function() {
  11702. this.isLoaded = true;
  11703. };
  11704. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  11705. iconSprites[icons[i]] = tmpSprite;
  11706. }
  11707. for (let i = 0; i < crossHairs.length; ++i) {
  11708. let tmpSprite = new Image();
  11709. tmpSprite.onload = function () {
  11710. this.isLoaded = true;
  11711. };
  11712. tmpSprite.src = crossHairs[i];
  11713. crossHairSprites[i] = tmpSprite;
  11714. }
  11715. }
  11716. loadIcons();
  11717.  
  11718. function cdf (e, t){
  11719. try {
  11720. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  11721. } catch(e){
  11722. return Infinity;
  11723. }
  11724. }
  11725.  
  11726. // UPDATE GAME:
  11727. function updateGame() {
  11728. if(gameObjects.length && inGame) {
  11729. gameObjects.forEach((tmp) => {
  11730. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  11731. if(!liztobj.includes(tmp)) {
  11732. liztobj.push(tmp);
  11733. tmp.render = true;
  11734. }
  11735. } else {
  11736. if(liztobj.includes(tmp)) {
  11737. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11738. tmp.render = false;
  11739. const index = liztobj.indexOf(tmp);
  11740. if (index > -1) { // only splice array when item is found
  11741. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11742. }
  11743. }
  11744. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11745. tmp.render = false;
  11746. const index = liztobj.indexOf(tmp);
  11747. if (index > -1) { // only splice array when item is found
  11748. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11749. }
  11750. } else {
  11751. tmp.render = false;
  11752. const index = liztobj.indexOf(tmp);
  11753. if (index > -1) { // only splice array when item is found
  11754. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11755. }
  11756. }
  11757. }
  11758. })
  11759. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  11760. }
  11761.  
  11762. // if (config.resetRender) {
  11763. mainContext.beginPath();
  11764. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  11765. // }
  11766. mainContext.globalAlpha = 1;
  11767.  
  11768. // MOVE CAMERA:
  11769. if (player) {
  11770. if (false) {
  11771. camX = player.x;
  11772. camY = player.y;
  11773. } else {
  11774. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  11775. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  11776. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  11777. if (tmpDist > 0.05) {
  11778. camX += camSpd * Math.cos(tmpDir);
  11779. camY += camSpd * Math.sin(tmpDir);
  11780. } else {
  11781. camX = player.x;
  11782. camY = player.y;
  11783. }
  11784. }
  11785. } else {
  11786. camX = config.mapScale / 2 + config.riverWidth;
  11787. camY = config.mapScale / 2;
  11788. }
  11789.  
  11790. // INTERPOLATE PLAYERS AND AI:
  11791. let lastTime = now - (1000 / config.serverUpdateRate);
  11792. let tmpDiff;
  11793. for (let i = 0; i < players.length + ais.length; ++i) {
  11794. tmpObj = players[i] || ais[i - players.length];
  11795. if (tmpObj && tmpObj.visible) {
  11796. if (tmpObj.forcePos) {
  11797. tmpObj.x = tmpObj.x2;
  11798. tmpObj.y = tmpObj.y2;
  11799. tmpObj.dir = tmpObj.d2;
  11800. } else {
  11801. let total = tmpObj.t2 - tmpObj.t1;
  11802. let fraction = lastTime - tmpObj.t1;
  11803. let ratio = (fraction / total);
  11804. let rate = 170;
  11805. tmpObj.dt += delta;
  11806. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  11807. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  11808. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  11809. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  11810. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  11811. if (config.anotherVisual) {
  11812. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11813. } else {
  11814. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11815. }
  11816. }
  11817. }
  11818. }
  11819.  
  11820. // RENDER CORDS:
  11821. let xOffset = camX - (maxScreenWidth / 2);
  11822. let yOffset = camY - (maxScreenHeight / 2);
  11823.  
  11824. // RENDER BACKGROUND:
  11825. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11826. mainContext.fillStyle = "#b6db66";
  11827. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11828. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  11829. mainContext.fillStyle = "#dbc666";
  11830. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11831. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11832. mainContext.fillStyle = "#fff";
  11833. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11834. } else if (config.snowBiomeTop - yOffset >= 0) {
  11835. mainContext.fillStyle = "#fff";
  11836. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  11837. mainContext.fillStyle = "#b6db66";
  11838. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  11839. maxScreenHeight - (config.snowBiomeTop - yOffset));
  11840. } else {
  11841. mainContext.fillStyle = "#b6db66";
  11842. mainContext.fillRect(0, 0, maxScreenWidth,
  11843. (config.mapScale - config.snowBiomeTop - yOffset));
  11844. mainContext.fillStyle = "#dbc666";
  11845. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  11846. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  11847. }
  11848.  
  11849. // RENDER WATER AREAS:
  11850. if (!firstSetup) {
  11851. waterMult += waterPlus * config.waveSpeed * delta;
  11852. if (waterMult >= config.waveMax) {
  11853. waterMult = config.waveMax;
  11854. waterPlus = -1;
  11855. } else if (waterMult <= 1) {
  11856. waterMult = waterPlus = 1;
  11857. }
  11858. mainContext.globalAlpha = 1;
  11859. mainContext.fillStyle = "#dbc666";
  11860. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  11861. mainContext.fillStyle = "#91b2db";
  11862. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  11863. }
  11864. if (getEl("renderGrid").checked) {
  11865. mainContext.lineWidth = 3;
  11866. mainContext.strokeStyle = "#000";
  11867. mainContext.globalAlpha = 0.05;
  11868. mainContext.beginPath();
  11869. let ratfrr = 60;
  11870. for (var x = -xOffset % ratfrr; x < maxScreenWidth; x += ratfrr) {
  11871. if (x > 0) {
  11872. mainContext.moveTo(x, 0);
  11873. mainContext.lineTo(x, maxScreenHeight);
  11874. }
  11875. }
  11876. for (var y = -yOffset % ratfrr; y < maxScreenHeight; y += ratfrr) {
  11877. if (y > 0) {
  11878. mainContext.moveTo(0, y);
  11879. mainContext.lineTo(maxScreenWidth, y);
  11880. }
  11881. }
  11882. mainContext.stroke();
  11883. }
  11884.  
  11885. // RENDER DEAD PLAYERS:
  11886. mainContext.globalAlpha = 1;
  11887. mainContext.strokeStyle = outlineColor;
  11888. renderDeadPlayers(xOffset, yOffset);
  11889.  
  11890. // RENDER BOTTOM LAYER:
  11891. mainContext.globalAlpha = 1;
  11892. mainContext.strokeStyle = outlineColor;
  11893. renderGameObjects(-1, xOffset, yOffset);
  11894.  
  11895. // RENDER PROJECTILES:
  11896. mainContext.globalAlpha = 1;
  11897. mainContext.lineWidth = outlineWidth;
  11898. renderProjectiles(0, xOffset, yOffset);
  11899.  
  11900. // RENDER PLAYERS:
  11901. renderPlayers(xOffset, yOffset, 0);
  11902.  
  11903. // RENDER AI:
  11904. mainContext.globalAlpha = 1;
  11905. for (let i = 0; i < ais.length; ++i) {
  11906. tmpObj = ais[i];
  11907. if (tmpObj.active && tmpObj.visible) {
  11908. tmpObj.animate(delta);
  11909. mainContext.save();
  11910. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11911. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  11912. renderAI(tmpObj, mainContext);
  11913. mainContext.restore();
  11914. }
  11915. }
  11916.  
  11917. // RENDER GAME OBJECTS (LAYERED):
  11918. renderGameObjects(0, xOffset, yOffset);
  11919. renderProjectiles(1, xOffset, yOffset);
  11920. renderGameObjects(1, xOffset, yOffset);
  11921. renderPlayers(xOffset, yOffset, 1);
  11922. renderGameObjects(2, xOffset, yOffset);
  11923. renderGameObjects(3, xOffset, yOffset);
  11924.  
  11925. // MAP BOUNDARIES:
  11926. mainContext.fillStyle = "#000";
  11927. mainContext.globalAlpha = 0.09;
  11928. if (xOffset <= 0) {
  11929. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  11930. }
  11931. if (config.mapScale - xOffset <= maxScreenWidth) {
  11932. let tmpY = Math.max(0, -yOffset);
  11933. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  11934. }
  11935. if (yOffset <= 0) {
  11936. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  11937. }
  11938. if (config.mapScale - yOffset <= maxScreenHeight) {
  11939. let tmpX = Math.max(0, -xOffset);
  11940. let tmpMin = 0;
  11941. if (config.mapScale - xOffset <= maxScreenWidth)
  11942. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  11943. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  11944. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  11945. }
  11946.  
  11947. // RENDER DAY/NIGHT TIME:
  11948. mainContext.globalAlpha = 1;
  11949. mainContext.fillStyle = "rgba(0, 5, 80, 0.35)";
  11950. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11951.  
  11952. // RENDER PLAYER AND AI UI:
  11953. mainContext.strokeStyle = darkOutlineColor;
  11954. mainContext.globalAlpha = 1;
  11955.  
  11956. for (let i = 0; i < players.length + ais.length; ++i) {
  11957. tmpObj = players[i] || ais[i - players.length];
  11958. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  11959. mainContext.strokeStyle = darkOutlineColor;
  11960.  
  11961. // NAME AND HEALTH:
  11962.  
  11963. // let izbot = false;
  11964.  
  11965. // bots.forEach((bot) => {
  11966. // if (tmpObj.sid == bot.sid) izbot = true
  11967. // else izbot = false;
  11968. // });
  11969.  
  11970. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  11971. if (tmpText != "" && tmpObj.name != "unknown1l") {
  11972. // bots.forEach((bot) => {
  11973. // if (tmpObj.sid == bot.sid) return;
  11974. // });
  11975.  
  11976. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  11977. mainContext.fillStyle = "#fff";
  11978. mainContext.textBaseline = "middle";
  11979. mainContext.textAlign = "center";
  11980. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11981. mainContext.lineJoin = "round";
  11982. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11983. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11984. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  11985. let tmpS = config.crownIconScale;
  11986. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  11987. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11988. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11989. }
  11990. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  11991. let tmpS = config.crownIconScale;
  11992. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  11993. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11994. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11995. }
  11996. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length) {
  11997. let tmpS = tmpObj.scale * 2.2;
  11998. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11999. }
  12000. // izbot = false;
  12001. // HEALTH HOLDER:
  12002. mainContext.fillStyle = darkOutlineColor;
  12003. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  12004. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  12005. (config.healthBarPad * 2), 17, 8);
  12006. mainContext.fill();
  12007.  
  12008. // HEALTH BAR:
  12009. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  12010. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  12011. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  12012. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  12013. mainContext.fill();
  12014. }
  12015.  
  12016. if (tmpObj.isPlayer) {
  12017. mainContext.globalAlpha = 1;
  12018. let targetReloads = {
  12019. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  12020. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  12021. turret: (2500 - tmpObj.reloads[53]) / 2500
  12022. };
  12023.  
  12024.  
  12025.  
  12026. if (!tmpObj.currentReloads) {
  12027. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  12028. primary: targetReloads.primary,
  12029. secondary: targetReloads.secondary,
  12030. turret: targetReloads.turret
  12031. };
  12032. }
  12033. let lerpFactor = 0.3;
  12034. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  12035. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  12036. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  12037. let be = mainContext;
  12038. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  12039. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  12040. const centerX = tmpObj.x - xOffset;
  12041. const centerY = tmpObj.y - yOffset;
  12042. const barRadius = 35;
  12043. const barWidth = 15;
  12044. const totalAngle = (Math.PI*2)/3; // Half circle
  12045. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  12046. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  12047. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  12048. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  12049.  
  12050. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  12051. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  12052. function returncoolcolor(RainbowCycle) {
  12053. return "#d6d6d6";
  12054. }
  12055. if (player.reloads[player.weapons[1]] != 0 && player.weapons[1]) {
  12056. be.fillStyle = darkOutlineColor;
  12057. be.fillStyle = darkOutlineColor;
  12058. be.roundRect(tmpObj.x - xOffset - config.healthBarPad,
  12059. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13, config.healthBarWidth +
  12060. (config.healthBarPad * 2), 17, 8);
  12061. be.fill();
  12062. be.fillStyle = `hsl(${50 * Math.ceil(tmpObj.reloads[tmpObj.secondaryIndex] / 100)}, 50%, 60%)`;
  12063. be.roundRect(tmpObj.x - xOffset,
  12064. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13 + config.healthBarPad,
  12065. (config.healthBarWidth * tmpObj.currentReloads.secondary), 17 - config.healthBarPad * 2, 7);
  12066. be.fill();
  12067. }
  12068. if (player.reloads[player.weapons[0]] != 0) {
  12069. be.fillStyle = darkOutlineColor;
  12070. be.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  12071. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13, config.healthBarWidth +
  12072. (config.healthBarPad * 2), 17, 8);
  12073. be.fill();
  12074. be.fillStyle = `hsl(${50 * Math.ceil(tmpObj.reloads[tmpObj.primaryIndex] / 100)}, 50%, 60%)`;
  12075. be.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  12076. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13 + config.healthBarPad,
  12077. (config.healthBarWidth * tmpObj.currentReloads.primary), 17 - config.healthBarPad * 2, 7);
  12078. be.fill();
  12079. be.restore();
  12080. }
  12081. if (tmpObj.currentReloads.turret < 0.999) {
  12082. mainContext.beginPath();
  12083. mainContext.lineCap = 'round';
  12084. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  12085. mainContext.lineWidth = 4;
  12086. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  12087. mainContext.stroke();
  12088. }
  12089. mainContext.restore();
  12090. // SHAME COUNT:
  12091. mainContext.globalAlpha = 1;
  12092. mainContext.font = "30px Hammersmith One";
  12093. mainContext.fillStyle = "red";
  12094. mainContext.strokeStyle = darkOutlineColor;
  12095. mainContext.textBaseline = "middle";
  12096. mainContext.textAlign = "center";
  12097. mainContext.lineWidth = 8;
  12098. mainContext.lineJoin = "round";
  12099. let tmpS = config.crownIconScale;
  12100. let tmpX = tmpObj.x - xOffset - tmpS / 2 + mainContext.measureText(tmpText).width / 2 + config.crownPad + (tmpObj.iconIndex == 1 ? 30 * 2.75 : 30);
  12101. mainContext.strokeText(tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount, tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY);
  12102. mainContext.fillText(tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount, tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY);
  12103.  
  12104. // PLAYER TRACER:
  12105. if (!tmpObj.isTeam(player)) {
  12106. let center = {
  12107. x: screenWidth / 2,
  12108. y: screenHeight / 2,
  12109. };
  12110. let alpha = Math.min(1, (UTILS.getDistance(0, 0, player.x - tmpObj.x, (player.y - tmpObj.y) * (16 / 9)) * 100) / (config.maxScreenHeight / 2) / center.y);
  12111. let dist = center.y * alpha / 2;
  12112. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  12113. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  12114. mainContext.save();
  12115. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  12116. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  12117. let by = 255 - (tmpObj.sid * 2);
  12118. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  12119. mainContext.globalAlpha = alpha;
  12120. let renderTracer = function(s, ctx) {
  12121. ctx = ctx || mainContext;
  12122. let h = s * (Math.sqrt(3) / 2);
  12123. ctx.beginPath();
  12124. ctx.moveTo(0, -h / 1.5);
  12125. ctx.lineTo(-s / 2, h / 2);
  12126. ctx.lineTo(s / 2, h / 2);
  12127. ctx.lineTo(0, -h / 1.5);
  12128. ctx.fill();
  12129. ctx.closePath();
  12130. }
  12131. renderTracer(25, mainContext);
  12132. mainContext.restore();
  12133. }
  12134.  
  12135. if (getEl("predictType").value == "pre2") {
  12136. mainContext.lineWidth = 3;
  12137. mainContext.strokeStyle = "#fff";
  12138. mainContext.globalAlpha = 1;
  12139. mainContext.beginPath();
  12140. let render = {
  12141. x: tmpObj.x2 - xOffset,
  12142. y: tmpObj.y2 - yOffset
  12143. };
  12144. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  12145. mainContext.lineTo(render.x, render.y);
  12146. mainContext.stroke();
  12147. } else if (getEl("predictType").value == "pre3") {
  12148. mainContext.lineWidth = 3;
  12149. mainContext.strokeStyle = "#cc5151";
  12150. mainContext.globalAlpha = 1;
  12151. mainContext.beginPath();
  12152. let render = {
  12153. x: tmpObj.x3 - xOffset,
  12154. y: tmpObj.y3 - yOffset
  12155. };
  12156. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  12157. mainContext.lineTo(render.x, render.y);
  12158. mainContext.stroke();
  12159. }
  12160.  
  12161. }
  12162. }
  12163. }
  12164.  
  12165. if (player) {
  12166. // AUTOPUSH LINE:
  12167. if (my.autoPush) {
  12168. mainContext.lineWidth = 14;
  12169. mainContext.strokeStyle = "rgba(50, 205, 50, 0.3)"; // HPBarColor (Outline color)
  12170. mainContext.beginPath();
  12171. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  12172. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  12173. mainContext.stroke(); // Draw the outline
  12174. }
  12175. if (doSpikeRedThingmajic) {
  12176. mainContext.globalAlpha = 0.25;
  12177. mainContext.beginPath();
  12178.  
  12179. mainContext.fillStyle = "rgba(255, 0, 0)";
  12180. const spikeX = SpikeX() - xOffset;
  12181. const spikeY = SpikeY() - yOffset;
  12182. const radius = 50;
  12183. mainContext.arc(spikeX, spikeY, radius, 0, Math.PI * 2);
  12184. mainContext.fill();
  12185.  
  12186. }
  12187. }
  12188. mainContext.globalAlpha = 1;
  12189.  
  12190. // RENDER ANIM TEXTS:
  12191. textManager.update(delta, mainContext, xOffset, yOffset);
  12192.  
  12193. // RENDER CHAT MESSAGES:
  12194. for (let i = 0; i < players.length; ++i) {
  12195. tmpObj = players[i];
  12196. if (tmpObj.visible) {
  12197. if (tmpObj.chatCountdown > 0) {
  12198. tmpObj.chatCountdown -= delta;
  12199. if (tmpObj.chatCountdown <= 0)
  12200. tmpObj.chatCountdown = 0;
  12201. mainContext.font = "32px Hammersmith One";
  12202. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  12203. mainContext.textBaseline = "middle";
  12204. mainContext.textAlign = "center";
  12205. let tmpX = tmpObj.x - xOffset;
  12206. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  12207. let tmpH = 47;
  12208. let tmpW = tmpSize.width + 17;
  12209. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  12210. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12211. mainContext.fill();
  12212. mainContext.fillStyle = "#fff";
  12213. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  12214. }
  12215. if (tmpObj.chat.count > 0) {
  12216. tmpObj.chat.count -= delta;
  12217. if (tmpObj.chat.count <= 0)
  12218. tmpObj.chat.count = 0;
  12219. mainContext.font = "32px Hammersmith One";
  12220. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  12221. mainContext.textBaseline = "middle";
  12222. mainContext.textAlign = "center";
  12223. let tmpX = tmpObj.x - xOffset;
  12224. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  12225. let tmpH = 47;
  12226. let tmpW = tmpSize.width + 17;
  12227. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  12228. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12229. mainContext.fill();
  12230. mainContext.fillStyle = "#ffffff99";
  12231. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  12232. } else {
  12233. tmpObj.chat.count = 0;
  12234.  
  12235. }
  12236. }
  12237. }
  12238.  
  12239. if (allChats.length) {
  12240. allChats.filter(ch => ch.active).forEach((ch) => {
  12241. if (!ch.alive) {
  12242. if (ch.alpha <= 1) {
  12243. ch.alpha += delta / 250;
  12244. if (ch.alpha >= 1) {
  12245. ch.alpha = 1;
  12246. ch.alive = true;
  12247. }
  12248. }
  12249. } else {
  12250. ch.alpha -= delta / 5000;
  12251. if (ch.alpha <= 0) {
  12252. ch.alpha = 0;
  12253. ch.active = false;
  12254. }
  12255. }
  12256. if (ch.active) {
  12257. mainContext.font = "20px Ubuntu";
  12258. let tmpSize = mainContext.measureText(ch.chat);
  12259. mainContext.textBaseline = "middle";
  12260. mainContext.textAlign = "center";
  12261. let tmpX = ch.x - xOffset;
  12262. let tmpY = ch.y - yOffset - 90;
  12263. let tmpH = 40;
  12264. let tmpW = tmpSize.width + 15;
  12265.  
  12266. mainContext.globalAlpha = ch.alpha;
  12267.  
  12268. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  12269. mainContext.strokeStyle = "rgb(25, 25, 25)";
  12270. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  12271. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  12272.  
  12273. mainContext.lineWidth = 5;
  12274. mainContext.fillStyle = "#ccc";
  12275. mainContext.strokeStyle = "rgb(25, 25, 25)";
  12276.  
  12277. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12278. mainContext.stroke();
  12279. mainContext.fill();
  12280.  
  12281. mainContext.fillStyle = "#fff";
  12282. mainContext.strokeStyle = "#000";
  12283. mainContext.strokeText(ch.chat, tmpX, tmpY);
  12284. mainContext.fillText(ch.chat, tmpX, tmpY);
  12285. ch.y -= delta / 100;
  12286. }
  12287. });
  12288. }
  12289.  
  12290. mainContext.globalAlpha = 1;
  12291.  
  12292. // RENDER MINIMAP:
  12293. renderMinimap(delta);
  12294. }
  12295.  
  12296. // UPDATE & ANIMATE:
  12297. window.requestAnimFrame = function() {
  12298. return null;
  12299. }
  12300. window.rAF = (function() {
  12301. return window.requestAnimationFrame ||
  12302. window.webkitRequestAnimationFrame ||
  12303. window.mozRequestAnimationFrame ||
  12304. function(callback) {
  12305. window.setTimeout(callback, 1000/9);
  12306. };
  12307. })();
  12308.  
  12309. function doUpdate() {
  12310. //rape modulus
  12311. now = performance.now();
  12312. delta = now - lastUpdate;
  12313. lastUpdate = now;
  12314. let timer = performance.now();
  12315. let diff = timer - fpsTimer.last;
  12316. if (diff >= 1000) {
  12317.  
  12318. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  12319.  
  12320. fpsTimer.last = timer;
  12321. fpsTimer.time = 0;
  12322. }
  12323. fpsTimer.time++;
  12324.  
  12325. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  12326. getEl("packetStatus").innerHTML = secPacket;
  12327. updateGame();
  12328. rAF(doUpdate);
  12329. ms.avg = Math.round((ms.min+ms.max)/2);
  12330. }
  12331.  
  12332. prepareMenuBackground();
  12333. doUpdate();
  12334.  
  12335. function toggleUseless(boolean) {
  12336. getEl("instaType").disabled = boolean;
  12337. getEl("antiBullType").disabled = boolean;
  12338. getEl("predictType").disabled = boolean;
  12339. }
  12340. toggleUseless(useWasd);
  12341.  
  12342. let changeDays = {};
  12343. window.debug = function() {
  12344. my.waitHit = 0;
  12345. my.autoAim = false;
  12346. instaC.isTrue = false;
  12347. traps.inTrap = false;
  12348. itemSprites = [];
  12349. objSprites = [];
  12350. gameObjectSprites = [];
  12351. };
  12352. window.wasdMode = function() {
  12353. useWasd = !useWasd;
  12354. toggleUseless(useWasd);
  12355. };
  12356. window.startGrind = function() {
  12357. if (getEl("weaponGrind").checked) {
  12358. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  12359. checkPlace(player.getItemType(22), i);
  12360. }
  12361. }
  12362. };
  12363. // REMOVED!!! so they cant abuse :)
  12364. let projects = [
  12365. "adorable-eight-guppy",
  12366. "galvanized-bittersweet-windshield"
  12367. ];
  12368. let botIDS = 0;
  12369. window.connectFillBots = function() {
  12370. botSkts = [];
  12371. botIDS = 0;
  12372. for (let i = 0; i < projects.length; i++) {
  12373. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  12374. test.binaryType = "arraybuffer";
  12375.  
  12376. test.onopen = function() {
  12377. test.ssend = function(type) {
  12378. let data = Array.prototype.slice.call(arguments, 1);
  12379. let binary = window.msgpack.encode([type, data]);
  12380. test.send(binary);
  12381. };
  12382. for (let i = 0; i < 4; i++) {
  12383. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  12384. action: "homepage"
  12385. }).then(function(token) {
  12386. let t = WS.url.split("wss://")[1].split("?")[0];
  12387. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  12388. botSkts.push([test]);
  12389. botIDS++;
  12390. });
  12391. }
  12392. };
  12393. test.onmessage = function(message) {
  12394. let data = new Uint8Array(message.data);
  12395. let parsed = window.msgpack.decode(data);
  12396. let type = parsed[0];
  12397. data = parsed[1];
  12398. };
  12399. }
  12400. };
  12401. window.destroyFillBots = function() {
  12402. botSkts.forEach((socket) => {
  12403. socket[0].close();
  12404. });
  12405. botSkts = [];
  12406. };
  12407. window.tryConnectBots = function() {
  12408. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  12409. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  12410. action: "homepage"
  12411. }).then(function(token) {
  12412. // CONNECT SOCKET:
  12413. botSpawn(token);
  12414. });
  12415. }
  12416. };
  12417. window.destroyBots = function() {
  12418. bots.forEach((botyyyyy) => {
  12419. botyyyyy.closeSocket = true;
  12420. });
  12421. bots = [];
  12422. };
  12423. window.resBuild = function() {
  12424. if (gameObjects.length) {
  12425. gameObjects.forEach((tmp) => {
  12426. tmp.breakObj = false;
  12427. });
  12428. breakObjects = [];
  12429. }
  12430. };
  12431. window.toggleBotsCircle = function() {
  12432. player.circle = !player.circle;
  12433. };
  12434. window.toggleVisual = function() {
  12435. config.anotherVisual = !config.anotherVisual;
  12436. gameObjects.forEach((tmp) => {
  12437. if (tmp.active) {
  12438. tmp.dir = tmp.lastDir;
  12439. }
  12440. });
  12441. };
  12442. window.prepareUI = function(tmpObj) {
  12443. resize();
  12444. // CHAT STUFF:
  12445. var chatBox = document.getElementById("chatBox");
  12446. var chatHolder = document.getElementById("chatHolder");
  12447. var suggestBox = document.createElement("div");
  12448. suggestBox.id = "suggestBox";
  12449.  
  12450. var prevChats = [];
  12451. var prevChatsIndex = 0;
  12452.  
  12453. function toggleChat() {
  12454. if (!usingTouch) {
  12455. if (chatHolder.style.display == "block") {
  12456. if (chatBox.value) {
  12457. sendChat(chatBox.value);
  12458. }
  12459. closeChat();
  12460. } else {
  12461. storeMenu.style.display = "none";
  12462. allianceMenu.style.display = "none";
  12463. chatHolder.style.display = "block";
  12464. chatBox.focus();
  12465. resetMoveDir();
  12466. }
  12467. } else {
  12468. setTimeout(function () {
  12469. var chatMessage = prompt("chat message");
  12470. if (chatMessage) {
  12471. sendChat(chatMessage);
  12472. }
  12473. }, 1);
  12474. }
  12475. chatBox.value = "";
  12476. (() => {
  12477. prevChatsIndex = 0;
  12478. })();
  12479. }
  12480.  
  12481. function closeChat() {
  12482. chatBox.value = "";
  12483. chatHolder.style.display = "none";
  12484. }
  12485.  
  12486. // ACTION BAR:
  12487. UTILS.removeAllChildren(actionBar);
  12488.  
  12489. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  12490. (function (i) {
  12491. UTILS.generateElement({
  12492. id: "actionBarItem" + i,
  12493. class: "actionBarItem",
  12494. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  12495. onmouseout: function () {
  12496. showItemInfo();
  12497. },
  12498. parent: actionBar
  12499. });
  12500. })(i);
  12501. }
  12502.  
  12503. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  12504. (function (i) {
  12505. let tmpCanvas = document.createElement("canvas");
  12506. tmpCanvas.width = tmpCanvas.height = 66;
  12507. let tmpContext = tmpCanvas.getContext("2d");
  12508. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  12509. tmpContext.imageSmoothingEnabled = false;
  12510. tmpContext.webkitImageSmoothingEnabled = false;
  12511. tmpContext.mozImageSmoothingEnabled = false;
  12512.  
  12513. if (items.weapons[i]) {
  12514. tmpContext.rotate((Math.PI));
  12515. let tmpSprite = new Image();
  12516. toolSprites[items.weapons[i].src] = tmpSprite;
  12517. tmpSprite.onload = function () {
  12518. this.isLoaded = true;
  12519. let tmpPad = 1 / (this.height / this.width);
  12520. let tmpMlt = (items.weapons[i].iPad || 1);
  12521. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  12522. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  12523. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  12524. tmpContext.globalCompositeOperation = "source-atop";
  12525. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  12526. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  12527. };
  12528. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  12529. let tmpUnit = getEl('actionBarItem' + i);
  12530. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  12531. // showItemInfo(items.weapons[i], true);
  12532. // });
  12533. tmpUnit.onclick = UTILS.checkTrusted(function () {
  12534. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  12535. });
  12536. UTILS.hookTouchEvents(tmpUnit);
  12537. } else {
  12538. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  12539. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  12540. tmpContext.globalAlpha = 1;
  12541. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  12542. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  12543. tmpContext.globalCompositeOperation = "source-atop";
  12544. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  12545. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  12546. let tmpUnit = getEl('actionBarItem' + i);
  12547. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  12548. // showItemInfo(items.list[i - items.weapons.length]);
  12549. // });
  12550. tmpUnit.onclick = UTILS.checkTrusted(function () {
  12551. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  12552. });
  12553. UTILS.hookTouchEvents(tmpUnit);
  12554. }
  12555. })(i);
  12556. }
  12557. };
  12558. window.profineTest = function(data) {
  12559. if (data) {
  12560. // VALIDATE NAME:
  12561. let name = data + "";
  12562. name = name.slice(0, config.maxNameLength);
  12563.  
  12564. return name;
  12565. }
  12566. };