oblivion mod v1.3

Fixed

  1. // ==UserScript==
  2. // @name oblivion mod v1.3
  3. // @match *://*.moomoo.io/*
  4. // @run-at document_idle
  5. // @grant none
  6. // @license GNU
  7. // @icon https://i1.sndcdn.com/artworks-IyhpQ4XC9EOtjNP6-Y9yXGg-t500x500.jpg
  8. // @namespace lol
  9. // @version v1.3
  10. // @description Fixed
  11. // @author Ultra hack
  12. // ==/UserScript==
  13.  
  14.  
  15. setTimeout(() => {
  16. document.getElementById('loadingText').innerHTML = `<!DOCTYPE html>
  17. <html lang="en">
  18. <head>
  19. <meta charset="UTF-8">
  20. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  21. <title>Loading Screen</title>
  22. <style>
  23. body {
  24. margin: 0;
  25. padding: 0;
  26. display: flex;
  27. justify-content: center;
  28. align-items: center;
  29. height: 100vh;
  30. background-color: #000000;
  31. }
  32.  
  33. .loader {
  34. border: 8px solid black; /* Light black */
  35. border-top: 8px solid #000000; /* Blue */
  36. border-radius: 50%;
  37. width: 50px;
  38. height: 50px;
  39. animation: spin 1s linear infinite;
  40. margin-left: 905px; /* Подвигаем на 50 пикселей вправо */
  41. margin-top: 100px;
  42. transition: border 1s, border-top 1s;
  43. }
  44.  
  45. @keyframes spin {
  46. 0% { transform: rotate(0deg); }
  47. 100% { transform: rotate(360deg); }
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <div class="loader"></div>
  53. </body>
  54. </html>
  55. `;
  56. }, 20);
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. let editMainMenu = `
  64. <style>
  65. /* Стили для меню #setupCard */
  66. #setupCard {
  67. border-radius: 10px;
  68. position: absolute;
  69. left: 790px;
  70. top: 1px;
  71. background: #370b5c;
  72. box-shadow: 0px 0px 5px #fff;
  73. transition: box-shadow 0.3s ease;
  74. }
  75.  
  76. #setupCard:hover,
  77. #setupCard:active {
  78. box-shadow: 0px 0px 10px #ffffff;
  79. }
  80.  
  81. /* Стили для меню #guideCard */
  82. #guideCard {
  83. border-radius: 10px;
  84. position: absolute;
  85. left: 790px;
  86. top: 149px;
  87. background: #370b5c;
  88. box-shadow: 0px 0px 5px #ffffff;
  89. transition: box-shadow 0.3s ease;
  90. }
  91.  
  92. #guideCard:hover,
  93. #guideCard:active {
  94. box-shadow: 0px 0px 10px #ffffff;
  95. }
  96.  
  97.  
  98.  
  99. /* Прочие стили остаются без изменений */
  100. #nameInput::selection {
  101. background: #1a1919;
  102. }
  103.  
  104. #guideCard::-webkit-scrollbar {
  105. width: 0px;
  106. height: 0px;
  107. background-color: rgba(0, 0, 0, 0);
  108. }
  109.  
  110. #mainMenu {
  111. background-color: #000000;
  112.  
  113. }
  114.  
  115. .menuCard {
  116. background: #8d3beb;
  117. text-align: center;
  118. box-shadow: inset 0px 0px 0px black;
  119. }
  120. .snowflake {
  121. color: #370b5c;
  122. font-size: 3em;
  123. font-family: Arial, sans-serif;
  124. text-shadow: 0 0 0px #fff;
  125. position: fixed;
  126. top: -10%;
  127. z-index: 9999;
  128. user-select: none;
  129. cursor: default;
  130. animation: snowflakes-fall 10s linear infinite, snowflakes-shake 3s ease-in-out infinite;
  131. }
  132.  
  133. @keyframes snowflakes-fall {
  134. 0% { top: -10%; }
  135. 100% { top: 100%; }
  136. }
  137.  
  138. @keyframes snowflakes-shake {
  139. 0%, 100% { transform: translateX(0); }
  140. 50% { transform: translateX(80px); }
  141. }
  142.  
  143. /* Прочие стили остаются без изменений */
  144. #nameInput::selection {
  145. background: #000000;
  146. }
  147.  
  148.  
  149.  
  150. .menuCard {
  151. background: #000000;
  152. text-align: center;
  153. box-shadow: inset 0px 0px 0px black;
  154. }
  155. </style>
  156. </head>
  157. <body>
  158.  
  159.  
  160.  
  161. <div id="snowContainer"></div>
  162.  
  163. <script>
  164. (function() {
  165. const amount = 22;
  166. const container = document.getElementById("snowContainer");
  167.  
  168. for(let i = 0; i < amount; i++){
  169. createSnowflake();
  170. }
  171.  
  172. function createSnowflake(){
  173. const txt = ["❅","❆"]
  174. let snow = document.createElement("div");
  175. snow.innerText = txt[+(Math.random() > 5)];
  176. container.appendChild(snow);
  177. snow.classList.add('snowflake');
  178. snow.style.left = Math.random() * 100 + "%";
  179. let d = ~~(Math.random() * 20);
  180. snow.style.animationDelay = d + 's, ' + d + 's';
  181. }
  182.  
  183. })();
  184. </script>
  185.  
  186. </style>
  187.  
  188.  
  189. `
  190. $("#mainMenu").append(editMainMenu)
  191.  
  192.  
  193.  
  194.  
  195.  
  196. document.getElementById("partyButton").remove();
  197. document.getElementById("joinPartyButton").remove();
  198.  
  199. document.getElementById("linksContainer2").remove();
  200.  
  201. document.getElementById("gameName").style.font = "120px zamruds";
  202.  
  203. document.getElementById("gameName").style.textShadow = "0px 0px 10px rgba(0, 191, 255, 0.5)"; // Используем rgba для задания прозрачного голубого цвета
  204. document.getElementById('gameName').style.marginTop = '-200px';
  205. document.getElementById('gameName').innerHTML = 'oblivion';
  206.  
  207.  
  208. let founda = false;
  209.  
  210. let scriptTags = document.getElementsByTagName("script");
  211. for (let i = 0; i < scriptTags.length; i++) {
  212. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  213. scriptTags[i].remove();
  214. founda = true;
  215. break;
  216. }
  217. }
  218.  
  219.  
  220. document.addEventListener("keydown", function(event) {
  221. if (event.keyCode === 192) {
  222. const chatHolder = document.getElementById("gameUI");
  223. if (chatHolder) {
  224. const currentDisplay = chatHolder.style.display;
  225. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  226. }
  227. }
  228. });
  229. var styleItem = document.createElement("style");
  230. styleItem.type = "text/css";
  231. styleItem.appendChild(document.createTextNode(`
  232. #suggestBox {
  233. width: 355px;
  234. border-radius: 3px;
  235. background-color: rgba(0,0,0,0.5);
  236. margin: auto;
  237. text-align: left;
  238. z-index: 49;
  239. pointer-events: auto;
  240. position: relative;
  241. bottom: 3.5px;
  242. overflow-y: auto;
  243. }
  244. #suggestBox div {
  245. background-color: rgba(255,255,255,0.5);
  246. color: rgba(255,255,255,1);
  247. transition: background-color 0.3s, color 0.3s;
  248. }
  249. #suggestBox div:hover {
  250. background-color: rgba(255,255,255,0.2);
  251. color: rgba(0,0,0,1);
  252. }
  253. .suggestBoxHard {
  254. color: rgba(255,255,255,1);
  255. font-size: 18px;
  256. }
  257. .suggestBoxLight {
  258. color: rgba(255,255,255,0.7);
  259. font-size: 18px;
  260. }
  261. `));
  262. document.head.appendChild(styleItem);
  263.  
  264. window.addEventListener('load', function() {
  265. var allianceButton = document.getElementById('allianceButton');
  266. var storeButton = document.getElementById('storeButton');
  267. if (storeButton) {
  268. storeButton.style.right = '26px';
  269. storeButton.style.top = '420px';
  270. }
  271. if (allianceButton) {
  272. allianceButton.style.right = '26px';
  273. allianceButton.style.top = '479px';
  274. }
  275. });
  276.  
  277. function getEl(id) {
  278. return document.getElementById(id);
  279. }
  280.  
  281.  
  282.  
  283. let newFont = document.createElement("link");
  284. newFont.rel = "stylesheet";
  285. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  286. newFont.type = "text/css";
  287. document.body.append(newFont);
  288.  
  289. let min = document.createElement("script");
  290. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  291. document.body.append(min);
  292. window.oncontextmenu = function() {
  293. return false;
  294. };
  295.  
  296. let config = window.config;
  297.  
  298. // CLIENT:
  299. config.clientSendRate = 9; // Aim Packet Send Rate
  300. config.serverUpdateRate = 9;
  301.  
  302. // UI:
  303. config.deathFadeout = 0;
  304.  
  305. config.playerCapacity = 9999;
  306.  
  307. // CHECK IN SANDBOX:
  308. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  309.  
  310. // CUSTOMIZATION:
  311. config.skinColors = ["#ad8b57", "#000000", "#000000",
  312. "#000000", "#000000", "#000000", "#000000", "000000", "000000",
  313. "000000", "#8d3beb"
  314. ];
  315. config.weaponVariants = [{
  316. id: 0,
  317. src: "",
  318. xp: 0,
  319. val: 1,
  320. }, {
  321. id: 1,
  322. src: "_g",
  323. xp: 3000,
  324. val: 1.1,
  325. }, {
  326. id: 2,
  327. src: "_d",
  328. xp: 7000,
  329. val: 1.18,
  330. }, {
  331. id: 3,
  332. src: "_r",
  333. poison: true,
  334. xp: 12000,
  335. val: 1.18,
  336. }, {
  337. id: 4,
  338. src: "_e",
  339. poison: true,
  340. heal: true,
  341. xp: 24000,
  342. val: 1.18,
  343. }];
  344.  
  345. // VISUAL:
  346. config.anotherVisual = true;
  347. config.useWebGl = false;
  348. config.resetRender = true;
  349.  
  350. function waitTime(timeout) {
  351. return new Promise((done) => {
  352. setTimeout(() => {
  353. done();
  354. }, timeout);
  355. });
  356. }
  357.  
  358. let botSkts = [];
  359.  
  360. // STORAGE:
  361. let canStore;
  362. if (typeof(Storage) !== "undefined") {
  363. canStore = true;
  364. }
  365.  
  366. function saveVal(name, val) {
  367. if (canStore)
  368. localStorage.setItem(name, val);
  369. }
  370.  
  371. function deleteVal(name) {
  372. if (canStore)
  373. localStorage.removeItem(name);
  374. }
  375.  
  376. function getSavedVal(name) {
  377. if (canStore)
  378. return localStorage.getItem(name);
  379. return null;
  380. }
  381.  
  382. // CONFIGS:
  383. let gC = function(a, b) {
  384. try {
  385. let res = JSON.parse(getSavedVal(a));
  386. if (typeof res === "object") {
  387. return b;
  388. } else {
  389. return res;
  390. }
  391. } catch (e) {
  392. alert("dieskid");
  393. return b;
  394. }
  395. };
  396.  
  397. function setCommands() {
  398. return {
  399. "help": {
  400. desc: "Show Commands",
  401. action: function(message) {
  402. for (let cmds in commands) {
  403. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  404. }
  405. }
  406. },
  407. "clear": {
  408. desc: "Clear Chats",
  409. action: function(message) {
  410. resetMenuChText();
  411. }
  412. },
  413. "debug": {
  414. desc: "Debug Mod For Development",
  415. action: function(message) {
  416. addDeadPlayer(player);
  417. addMenuChText("Debug", "Done", "#99ee99", 1);
  418. }
  419. },
  420. "play": {
  421. desc: "Play Music ( /play [link] )",
  422. action: function(message) {
  423. let link = message.split(" ");
  424. if (link[1]) {
  425. let audio = new Audio(link[1]);
  426. audio.play();
  427. } else {
  428. addMenuChText("Warn", "Enter Link ( /play [link] )", "#471c69", 1);
  429. }
  430. }
  431. },
  432. "bye": {
  433. desc: "Leave Game",
  434. action: function(message) {
  435. window.leave();
  436. }
  437. },
  438. };
  439. }
  440.  
  441. function setConfigs() {
  442. return {
  443. killChat: true,
  444. autoBuy: true,
  445. autoBuyEquip: true,
  446. autoPush: true,
  447. revTick: true,
  448. spikeTick: true,
  449. predictTick: true,
  450. autoPlace: true,
  451. autoReplace: true,
  452. antiTrap: true,
  453. slowOT: false,
  454. attackDir: false,
  455. showDir: true,
  456. autoRespawn: false
  457. };
  458. }
  459.  
  460. let commands = setCommands();
  461. let configs = setConfigs();
  462.  
  463. window.removeConfigs = function() {
  464. for (let cF in configs) {
  465. deleteVal(cF, configs[cF]);
  466. }
  467. };
  468.  
  469. for (let cF in configs) {
  470. configs[cF] = gC(cF, configs[cF]);
  471. }
  472.  
  473. // MENU FUNCTIONS:
  474. window.changeMenu = function() {};
  475. window.debug = function() {};
  476. window.wasdMode = function() {};
  477.  
  478. // PAGE 1:
  479. window.startGrind = function() {};
  480.  
  481. // PAGE 3:
  482. window.connectFillBots = function() {};
  483. window.destroyFillBots = function() {};
  484. window.tryConnectBots = function() {};
  485. window.destroyBots = function() {};
  486. window.resBuild = function() {};
  487. window.toggleBotsCircle = function() {};
  488. window.toggleVisual = function() {};
  489.  
  490. // SOME FUNCTIONS:
  491. window.prepareUI = function() {};
  492. window.leave = function() {};
  493.  
  494. // nah hahahahahhh why good ping
  495. window.ping = 0;
  496.  
  497. class deadfuturechickenmodrevival {
  498. constructor(flarez, lore) {
  499. this.inGame = false;
  500. this.lover = flarez + lore;
  501. this.baby = "ae86";
  502. this.isBlack = 0;
  503. this.webSocket = undefined;
  504. this.checkBaby = function() {
  505. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  506. if (this.isBlack >= 1) return "bl4cky";
  507. return "noting for you";
  508. };
  509. this.x2 = 0;
  510. this.y2 = 0;
  511. this.chat = "Imagine playing this badass game XDDDDD";
  512. this.summon = function(tmpObj) {
  513. this.x2 = tmpObj.x;
  514. this.y2 = tmpObj.y;
  515. this.chat = tmpObj.name + " ur so bad XDDDD";
  516. };
  517. this.commands = function(cmd) {
  518. cmd == "rv3link" && window.open("https://florr.io/");
  519. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  520. return cmd;
  521. };
  522. this.dayte = "11yearold";
  523. this.memeganoob = "69yearold";
  524. this.startDayteSpawn = function(tmpObj) {
  525. let ratio = setInterval(() => {
  526. this.x2 = tmpObj.x + 20;
  527. this.y2 = tmpObj.y - 20;
  528. this.chat = "UR SO BAD LOL";
  529. if (tmpObj.name == "ae86") {
  530. this.chat = "omg ae86 go run";
  531. setTimeout(() => {
  532. this.inGame = false;
  533. clearInterval(ratio);
  534. }, 1000);
  535. }
  536. }, 1234);
  537. };
  538. this.AntiChickenModV69420 = function(tmpObj) {
  539. return "!c!dc user " + tmpObj.name;
  540. };
  541. }
  542. };
  543. class HtmlAction {
  544. constructor(element) {
  545. this.element = element;
  546. };
  547. add(code) {
  548. if (!this.element) return undefined;
  549. this.element.innerHTML += code;
  550. };
  551. newLine(amount) {
  552. let result = `<br>`;
  553. if (amount > 0) {
  554. result = ``;
  555. for (let i = 0; i < amount; i++) {
  556. result += `<br>`;
  557. }
  558. }
  559. this.add(result);
  560. };
  561. checkBox(setting) {
  562. let newCheck = `<input type = "checkbox"`;
  563. setting.id && (newCheck += ` id = ${setting.id}`);
  564. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  565. setting.class && (newCheck += ` class = ${setting.class}`);
  566. setting.checked && (newCheck += ` checked`);
  567. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  568. newCheck += `>`;
  569. this.add(newCheck);
  570. };
  571. text(setting) {
  572. let newText = `<input type = "text"`;
  573. setting.id && (newText += ` id = ${setting.id}`);
  574. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  575. setting.class && (newText += ` class = ${setting.class}`);
  576. setting.size && (newText += ` size = ${setting.size}`);
  577. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  578. setting.value && (newText += ` value = ${setting.value}`);
  579. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  580. newText += `>`;
  581. this.add(newText);
  582. };
  583. select(setting) {
  584. let newSelect = `<select`;
  585. setting.id && (newSelect += ` id = ${setting.id}`);
  586. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  587. setting.class && (newSelect += ` class = ${setting.class}`);
  588. newSelect += `>`;
  589. for (let options in setting.option) {
  590. newSelect += `<option value = ${setting.option[options].id}`
  591. setting.option[options].selected && (newSelect += ` selected`);
  592. newSelect += `>${options}</option>`;
  593. }
  594. newSelect += `</select>`;
  595. this.add(newSelect);
  596. };
  597. button(setting) {
  598. let newButton = `<button`;
  599. setting.id && (newButton += ` id = ${setting.id}`);
  600. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  601. setting.class && (newButton += ` class = ${setting.class}`);
  602. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  603. newButton += `>`;
  604. setting.innerHTML && (newButton += setting.innerHTML);
  605. newButton += `</button>`;
  606. this.add(newButton);
  607. };
  608. selectMenu(setting) {
  609. let newSelect = `<select`;
  610. if (!setting.id) {
  611. alert("please put id skid");
  612. return;
  613. }
  614. window[setting.id + "Func"] = function() {};
  615. setting.id && (newSelect += ` id = ${setting.id}`);
  616. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  617. setting.class && (newSelect += ` class = ${setting.class}`);
  618. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  619. newSelect += `>`;
  620. let last;
  621. let i = 0;
  622. for (let options in setting.menu) {
  623. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  624. setting.menu[options] && (newSelect += ` checked`);
  625. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  626. i++;
  627. }
  628. newSelect += `</select>`;
  629.  
  630. this.add(newSelect);
  631.  
  632. i = 0;
  633. for (let options in setting.menu) {
  634. window[options + "Func"] = function() {
  635. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  636. saveVal(options, setting.menu[options]);
  637.  
  638. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  639. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  640.  
  641. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  642.  
  643. };
  644. this.checkBox({
  645. id: "check_" + options,
  646. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  647. class: "checkB",
  648. onclick: `window.${options + "Func"}()`,
  649. checked: setting.menu[options]
  650. });
  651. i++;
  652. }
  653.  
  654. last = "check_" + getEl(setting.id).value.split("_")[1];
  655. window[setting.id + "Func"] = function() {
  656. getEl(last).style.display = "none";
  657. last = "check_" + getEl(setting.id).value.split("_")[1];
  658. getEl(last).style.display = "inline-block";
  659.  
  660. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  661.  
  662. };
  663. };
  664. };
  665. class Html {
  666. constructor() {
  667. this.element = null;
  668. this.action = null;
  669. this.divElement = null;
  670. this.startDiv = function(setting, func) {
  671.  
  672. let newDiv = document.createElement("div");
  673. setting.id && (newDiv.id = setting.id);
  674. setting.style && (newDiv.style = setting.style);
  675. setting.class && (newDiv.className = setting.class);
  676. this.element.appendChild(newDiv);
  677. this.divElement = newDiv;
  678.  
  679. let addRes = new HtmlAction(newDiv);
  680. typeof func == "function" && func(addRes);
  681.  
  682. };
  683. this.addDiv = function(setting, func) {
  684.  
  685. let newDiv = document.createElement("div");
  686. setting.id && (newDiv.id = setting.id);
  687. setting.style && (newDiv.style = setting.style);
  688. setting.class && (newDiv.className = setting.class);
  689. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  690. this.divElement = newDiv;
  691.  
  692. let addRes = new HtmlAction(newDiv);
  693. typeof func == "function" && func(addRes);
  694.  
  695. };
  696. };
  697. set(id) {
  698. this.element = getEl(id);
  699. this.action = new HtmlAction(this.element);
  700. };
  701. resetHTML(text) {
  702. if (text) {
  703. this.element.innerHTML = ``;
  704. } else {
  705. this.element.innerHTML = ``;
  706. }
  707. };
  708. setStyle(style) {
  709. this.element.style = style;
  710. };
  711. setCSS(style) {
  712. this.action.add(`<style>` + style + `</style>`);
  713. };
  714. };
  715.  
  716.  
  717.  
  718. let HTML = new Html();
  719.  
  720. let menuDiv = document.createElement("div");
  721. menuDiv.id = "menuDiv";
  722. menuDiv.draggable = true;
  723.  
  724. menuDiv.addEventListener("dragstart", function (e) {
  725. e.dataTransfer.setData("text/plain", "");
  726. });
  727.  
  728. document.addEventListener("dragover", function (e) {
  729. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  730. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  731. });
  732.  
  733. document.body.appendChild(menuDiv);
  734. HTML.set("menuDiv");
  735. HTML.setStyle(`
  736. position: absolute;
  737. left: 20px;
  738. top: 20px;
  739. `);
  740. HTML.resetHTML();
  741. HTML.setCSS(`
  742. body {
  743. background-color: #3e1b59; /* Черный цвет фона */
  744. color: #fff; /* Белый цвет текста */
  745. font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; /* Более роскошный шрифт */
  746. }
  747.  
  748. .menuClass {
  749. color: #3e1b59;
  750. font-size: 22px; /* Увеличенный размер шрифта */
  751. text-align: left;
  752. padding: 20px; /* Увеличенный внутренний отступ */
  753. width: 300px; /* Увеличенная ширина меню */
  754. background-color: #333; /* Темно-серый цвет фона */
  755. border: 2px solid #555; /* Черный цвет рамки */
  756. border-radius: 12px; /* Более сильно скругленные углы */
  757. box-shadow: 0 4px 8px rgba(0,0,0,0.4); /* Тень для выделения */
  758. }
  759.  
  760. .menuC {
  761. display: none;
  762. font-size: 14px; /* Уменьшенный размер шрифта */
  763. max-height: 200px; /* Увеличенная максимальная высота */
  764. overflow-y: auto;
  765. }
  766.  
  767. .menuB {
  768. text-align: center;
  769. background-color: #3e1b59;
  770. color: #fff;
  771. border: none;
  772. border-radius: 4px;
  773. padding: 4 4px; /* Увеличенный внутренний отступ */
  774. cursor: pointer;
  775. transition: background-color 0.3s ease;
  776. }
  777.  
  778. .menuB:hover {
  779. background-color: #3e1b59;
  780. }
  781.  
  782.  
  783.  
  784. .menuB:active {
  785. transform: translateY(1px);
  786. }
  787.  
  788. .customText {
  789. color: #0;
  790. border: 1px solid #000000;
  791. border-radius: 5px;
  792. padding: 2px;
  793. transition: background-color 0.3s ease;
  794. }
  795.  
  796. .customText:focus {
  797. background-color: #000000; /* Темно-серый цвет фона при фокусировке */
  798. }
  799.  
  800. .checkB {
  801. cursor: pointer;
  802. }
  803.  
  804. .Cselect {
  805. background-color: #3e1b59; /* Темно-серый цвет фона */
  806. color: #000000;
  807. border: 1px solid #555;
  808. border-radius: 66px;
  809. padding: 2px;
  810. }
  811.  
  812. #menuChanger {
  813. position: absolute;
  814. right: 20px; /* Увеличенный отступ справа */
  815. top: 20px; /* Увеличенный отступ сверху */
  816. background-color: transparent;
  817. color: #fff;
  818. border: none;
  819. cursor: pointer;
  820. }
  821.  
  822. #menuChanger:hover {
  823. color: #ccc; /* Светло-серый цвет при наведении */
  824. }
  825.  
  826. /* Скроллбары */
  827. ::-webkit-scrollbar {
  828. width: 8px;
  829. }
  830.  
  831. ::-webkit-scrollbar-track {
  832. background: #333; /* Темно-серый цвет фона */
  833. }
  834.  
  835. ::-webkit-scrollbar-thumb {
  836. background: #666; /* Светло-серый цвет скроллбара */
  837. border-radius: 4px;
  838. }
  839.  
  840. ::-webkit-scrollbar-thumb:hover {
  841. background: #999; /* Более светлый цвет при наведении */
  842. }
  843.  
  844. /* Добавление узоров на задний фон */
  845. body {
  846. background-image: url('https://www.transparenttextures.com/patterns/asfalt-dark.png'); /* Использование узора */
  847. }
  848.  
  849. `);
  850. HTML.startDiv({
  851. id: "menuHeadLine",
  852. class: "menuClass"
  853. }, (html) => {
  854. html.add(`oblivion`);
  855. html.button({
  856. id: "menuChanger",
  857. class: "material-icons",
  858. innerHTML: `sync`,
  859. onclick: "window.changeMenu()"
  860. });
  861. HTML.addDiv({
  862. id: "menuButtons",
  863. style: "display: block; overflow-y: visible;",
  864. class: "menuC",
  865. appendID: "menuHeadLine"
  866. }, (html) => {
  867. html.button({
  868. class: "menuB",
  869. innerHTML: "Debug",
  870. onclick: "window.debug()"
  871. });
  872. });
  873. HTML.addDiv({
  874. id: "menuMain",
  875. style: "display: block",
  876. class: "menuC",
  877. appendID: "menuHeadLine"
  878. }, (html) => {
  879. html.button({
  880. class: "menuB",
  881. innerHTML: "Dagger Optimisation",
  882. onclick: "window.wasdMode()"
  883. });
  884. html.newLine();
  885. html.add(`Auto-Grinder: `);
  886. html.checkBox({
  887. id: "weaponGrind",
  888. class: "checkB",
  889. onclick: "window.startGrind()"
  890. });
  891. html.newLine(2);
  892. HTML.addDiv({
  893. style: "font-size: 30px; color: #000000;",
  894. appendID: "menuMain"
  895. }, (html) => {
  896. html.add(`_______________`);
  897. });
  898. html.add(`Anti-Push:`);
  899. html.checkBox({
  900. id: "antipush",
  901. class: "checkB",
  902. checked: true
  903. });
  904. html.newLine();
  905. html.add(`Auto-Heal:`);
  906. html.checkBox({
  907. id: "healingBeta",
  908. class: "checkB",
  909. checked: true
  910. });
  911. html.newLine();
  912. });
  913. HTML.addDiv({
  914. id: "menuConfig",
  915. class: "menuC",
  916. appendID: "menuHeadLine"
  917. }, (html) => {
  918. html.add(`AutoPlacer Placement Tick: `);
  919. html.text({
  920. id: "autoPlaceTick",
  921. class: "customText",
  922. value: "2",
  923. size: "2em",
  924. maxLength: "1"
  925. });
  926. html.newLine();
  927. html.add(`Configs: `);
  928. html.selectMenu({
  929. id: "configsChanger",
  930. class: "Cselect",
  931. menu: configs
  932. });
  933. html.newLine();
  934. html.add(`InstaKill Type: `);
  935. html.select({
  936. id: "instaType",
  937. class: "Cselect",
  938. option: {
  939. OneShot: {
  940. id: "oneShot",
  941. selected: true
  942. },
  943. Spammer: {
  944. id: "spammer"
  945. }
  946. }
  947. });
  948. html.newLine();
  949. html.add(`AntiBull Type: `);
  950. html.select({
  951. id: "antiBullType",
  952. class: "Cselect",
  953. option: {
  954. "Disable AntiBull": {
  955. id: "noab",
  956. selected: true
  957. },
  958. "When Reloaded": {
  959. id: "abreload",
  960. },
  961. "Primary Reloaded": {
  962. id: "abalway"
  963. }
  964. }
  965. });
  966. html.newLine();
  967. html.add(`Backup Nobull Insta: `);
  968. html.checkBox({
  969. id: "backupNobull",
  970. class: "checkB",
  971. checked: true
  972. });
  973. html.newLine();
  974. html.add(`Turret Gear Combat Assistance: `);
  975. html.checkBox({
  976. id: "turretCombat",
  977. class: "checkB"
  978. });
  979. html.newLine();
  980. html.add(`Safe AntiSpikeTick: `);
  981. html.checkBox({
  982. id: "safeAntiSpikeTick",
  983. class: "checkB",
  984. checked: true
  985. });
  986. html.newLine();
  987. });
  988. HTML.addDiv({
  989. id: "menuOther",
  990. class: "menuC",
  991. appendID: "menuHeadLine"
  992. }, (html) => {
  993. html.button({
  994. class: "menuB",
  995. innerHTML: "Connect Bots",
  996. onclick: "window.tryConnectBots()"
  997. });
  998. html.button({
  999. class: "menuB",
  1000. innerHTML: "Disconnect Bots",
  1001. onclick: "window.destroyBots()"
  1002. });
  1003. html.newLine();
  1004. html.button({
  1005. class: "menuB",
  1006. innerHTML: "Connect FBots",
  1007. onclick: "window.connectFillBots()"
  1008. });
  1009. html.button({
  1010. class: "menuB",
  1011. innerHTML: "Disconnect FBots",
  1012. onclick: "window.destroyFillBots()"
  1013. });
  1014. html.newLine();
  1015. html.button({
  1016. class: "menuB",
  1017. innerHTML: "Reset Break Objects",
  1018. onclick: "window.resBuild()"
  1019. });
  1020. html.newLine();
  1021. html.add(`Break Objects Range: `);
  1022. html.text({
  1023. id: "breakRange",
  1024. class: "customText",
  1025. value: "700",
  1026. size: "3em",
  1027. maxLength: "4"
  1028. });
  1029. html.newLine();
  1030. html.add(`Predict Movement Type: `);
  1031. html.select({
  1032. id: "predictType",
  1033. class: "Cselect",
  1034. option: {
  1035. "Disable Render": {
  1036. id: "disableRender",
  1037. selected: true
  1038. },
  1039. "X/Y and 2": {
  1040. id: "pre2",
  1041. },
  1042. "X/Y and 3": {
  1043. id: "pre3"
  1044. }
  1045. }
  1046. });
  1047. html.newLine();
  1048. html.add(`Render Placers: `);
  1049. html.checkBox({
  1050. id: "placeVis",
  1051. class: "checkB",
  1052. });
  1053. html.newLine();
  1054. html.add(`Bot Mode: `);
  1055. html.select({
  1056. id: "mode",
  1057. class: "Cselect",
  1058. option: {
  1059. "Clear Building": {
  1060. id: "clear",
  1061. selected: true
  1062. },
  1063. "Sync": {
  1064. id: "zync",
  1065. },
  1066. "Search": {
  1067. id: "zearch"
  1068. },
  1069. "Clear Everything": {
  1070. id: "fuckemup"
  1071. },
  1072. "Flex": {
  1073. id: "flex"
  1074. }
  1075. }
  1076. });
  1077. html.newLine(2);
  1078. html.button({
  1079. class: "menuB",
  1080. innerHTML: "Toggle Fbots Circle",
  1081. onclick: "window.toggleBotsCircle()"
  1082. });
  1083. html.newLine();
  1084. html.add(`Circle Rad: `);
  1085. html.text({
  1086. id: "circleRad",
  1087. class: "customText",
  1088. value: "200",
  1089. size: "3em",
  1090. maxLength: "4"
  1091. });
  1092. html.newLine();
  1093. html.add(`Rad Speed: `);
  1094. html.text({
  1095. id: "radSpeed",
  1096. class: "customText",
  1097. value: "0.1",
  1098. size: "2em",
  1099. maxLength: "3"
  1100. });
  1101. html.newLine();
  1102. html.add(`Bot Zetup Type: `);
  1103. html.select({
  1104. id: "setup",
  1105. class: "Cselect",
  1106. option: {
  1107. "Dagger Musket": {
  1108. id: "dm",
  1109. selected: true
  1110. },
  1111. "Katana Hammer": {
  1112. id: "kh",
  1113. },
  1114. "Dagger Repeater-Crossbow": {
  1115. id: "dr"
  1116. },
  1117. "Zhort-Zword Muzket": {
  1118. id: "zd"
  1119. }
  1120. }
  1121. });
  1122. html.newLine(2);
  1123. html.add(`Cross World: `);
  1124. html.checkBox({
  1125. id: "funni",
  1126. class: "checkB"
  1127. });
  1128. html.newLine();
  1129. html.button({
  1130. class: "menuB",
  1131. innerHTML: "Toggle Another Visual",
  1132. onclick: "window.toggleVisual()"
  1133. });
  1134. html.newLine();
  1135. });
  1136. });
  1137.  
  1138. let menuChatDiv = document.createElement("div");
  1139. menuChatDiv.id = "menuChatDiv";
  1140. document.body.appendChild(menuChatDiv);
  1141. HTML.set("menuChatDiv");
  1142. HTML.setStyle(`
  1143. position: absolute;
  1144. display: none;
  1145. left: 0px;
  1146. top: 25px;
  1147. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1148. `);
  1149. HTML.resetHTML();
  1150. HTML.setCSS(`
  1151. .chDiv {
  1152. color: #fff;
  1153. padding: 10px;
  1154. width: 357px;
  1155. height: 217px;
  1156. background-color: rgba(0, 0, 0, 0.2);
  1157. font-family: "HammerSmith One", monospace;
  1158. // border-radius: 15px;
  1159. // box-shadow: black 1px 2px 19px;
  1160. //backdrop-filter: blur(3px);
  1161.  
  1162. }
  1163. .chMainDiv {
  1164. font-family: "Ubuntu";
  1165. font-size: 16px;
  1166. max-height: 215px;
  1167. overflow-y: scroll;
  1168. scrollbar-width: thin;
  1169. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1170. -webkit-touch-callout: none;
  1171. -webkit-user-select: none;
  1172. -khtml-user-select: none;
  1173. -moz-user-select: none;
  1174. -ms-user-select: none;
  1175. user-select: none;
  1176. overflow-x: hidden;
  1177. }
  1178. .chMainDiv::-webkit-scrollbar {
  1179. width: 8px;
  1180. }
  1181. .chMainDiv::-webkit-scrollbar-thumb {
  1182. background-color: rgba(0, 0, 0, 0.5);
  1183. }
  1184. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1185. background-color: rgba(0, 0, 0, 0.7);
  1186. }
  1187. .chMainBox {
  1188. display:none;
  1189. position: absolute;
  1190. left: 10px;
  1191. bottom: 10px;
  1192. width: 380px;
  1193. height: 25px;
  1194. background-color: rgba(255, 255, 255, 0.1);
  1195. border-radius: 5px;
  1196. color: rgba(255, 255, 255, 0.75);
  1197. font-family: "HammerSmith One";
  1198. font-size: 12px;
  1199. }
  1200. `);
  1201. HTML.startDiv({
  1202. id: "mChDiv",
  1203. class: "chDiv"
  1204. }, (html) => {
  1205. HTML.addDiv({
  1206. id: "mChMain",
  1207. class: "chMainDiv",
  1208. appendID: "mChDiv"
  1209. }, (html) => {});
  1210. html.text({
  1211. id: "mChBox",
  1212. class: "chMainBox",
  1213. // placeHolder: `To chat click here or press "Enter" key`
  1214. });
  1215. });
  1216.  
  1217. let menuChats = getEl("mChMain");
  1218. let menuChatBox = getEl("mChBox");
  1219. let menuCBFocus = false;
  1220. let menuChCounts = 0;
  1221.  
  1222. menuChatBox.value = "";
  1223. menuChatBox.addEventListener("focus", () => {
  1224. menuCBFocus = true;
  1225. });
  1226. menuChatBox.addEventListener("blur", () => {
  1227. menuCBFocus = false;
  1228. });
  1229.  
  1230. function addMenuChText(name, message, color, noTimer) {
  1231. HTML.set("menuChatDiv");
  1232. color = color || "white";
  1233. let time = new Date();
  1234. let min = time.getMinutes();
  1235. let hour = time.getHours();
  1236. let text = ``;
  1237. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1238. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1239. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1240. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1241. html.add(text);
  1242. });
  1243. menuChats.scrollTop = menuChats.scrollHeight;
  1244. menuChCounts++;
  1245. }
  1246. function chch(name, message, color, noTimer) {
  1247. HTML.set("menuChatDiv");
  1248. color = color || "white";
  1249. let time = new Date();
  1250. let text = ``;
  1251. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1252. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1253. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1254. html.add(text);
  1255. });
  1256. menuChats.scrollTop = menuChats.scrollHeight;
  1257. menuChCounts++;
  1258. }
  1259.  
  1260. function resetMenuChText() {
  1261. menuChats.innerHTML = ``;
  1262. menuChCounts = 0;
  1263. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1264. }
  1265. resetMenuChText();
  1266.  
  1267. let menuIndex = 0;
  1268. let menus = ["menuMain", "menuConfig", "menuOther"];
  1269. window.changeMenu = function() {
  1270. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1271. menuIndex++;
  1272. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1273. };
  1274.  
  1275. let mStatus = document.createElement("div");
  1276. mStatus.id = "status";
  1277. getEl("gameUI").appendChild(mStatus);
  1278. HTML.set("status");
  1279. HTML.setStyle(`
  1280. display: block;
  1281. position: absolute;
  1282. color: #ddd;
  1283. font: 15px Hammersmith One;
  1284. bottom: 215px;
  1285. left: 20px;
  1286. `);
  1287. HTML.resetHTML();
  1288. HTML.setCSS(`
  1289. .sizing {
  1290. font-size: 15px;
  1291. }
  1292. .mod {
  1293. font-size: 15px;
  1294. display: inline-block;
  1295. }
  1296. `);
  1297. HTML.startDiv({
  1298. id: "uehmod",
  1299. class: "sizing"
  1300. }, (html) => {
  1301. html.add(`Ping: `);
  1302. HTML.addDiv({
  1303. id: "pingFps",
  1304. class: "mod",
  1305. appendID: "uehmod"
  1306. }, (html) => {
  1307. html.add("None");
  1308. });
  1309. html.newLine();
  1310. html.add(`Packet: `);
  1311. HTML.addDiv({
  1312. id: "packetStatus",
  1313. class: "mod",
  1314. appendID: "uehmod"
  1315. }, (html) => {
  1316. html.add("None");
  1317. });
  1318. });
  1319.  
  1320. /*function modLog() {
  1321. let logs = [];
  1322. for (let i = 0; i < arguments.length; i++) {
  1323. logs.push(arguments[i]);
  1324. }
  1325. getEl("modLog").innerHTML = logs;
  1326. }*/
  1327.  
  1328. let openMenu = false;
  1329.  
  1330. let WS = undefined;
  1331. let socketID = undefined;
  1332.  
  1333. let useWasd = true;
  1334. let secPacket = 0;
  1335. let secMax = 120;
  1336. let secTime = 1000;
  1337. let firstSend = {
  1338. sec: false
  1339. };
  1340. let game = {
  1341. tick: 0,
  1342. tickQueue: [],
  1343. tickBase: function(set, tick) {
  1344. if (this.tickQueue[this.tick + tick]) {
  1345. this.tickQueue[this.tick + tick].push(set);
  1346. } else {
  1347. this.tickQueue[this.tick + tick] = [set];
  1348. }
  1349. },
  1350. tickRate: (1000 / config.serverUpdateRate),
  1351. tickSpeed: 0,
  1352. lastTick: performance.now()
  1353. };
  1354. let modConsole = [];
  1355.  
  1356. let dontSend = false;
  1357. let fpsTimer = {
  1358. last: 0,
  1359. time: 0,
  1360. ltime: 0
  1361. }
  1362. let lastMoveDir = undefined;
  1363. let lastsp = ["cc", 1, "__proto__"];
  1364.  
  1365. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1366. WebSocket.prototype.send = function(message) {
  1367. if (!WS) {
  1368. WS = this;
  1369. WS.addEventListener("message", function(msg) {
  1370. getMessage(msg);
  1371. });
  1372. WS.addEventListener("close", (event) => {
  1373. if (event.code == 4001) {
  1374. window.location.reload();
  1375. }
  1376. });
  1377. }
  1378. if (WS == this) {
  1379. dontSend = false;
  1380.  
  1381. // EXTRACT DATA ARRAY:
  1382. let data = new Uint8Array(message);
  1383. let parsed = window.msgpack.decode(data);
  1384. let type = parsed[0];
  1385. data = parsed[1];
  1386.  
  1387. // SEND MESSAGE:
  1388. if (type == "6") {
  1389.  
  1390. if (data[0]) {
  1391. // ANTI PROFANITY:
  1392. 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", ];
  1393. let tmpString;
  1394. profanity.forEach((profany) => {
  1395. if (data[0].indexOf(profany) > -1) {
  1396. tmpString = "";
  1397. for (let i = 0; i < profany.length; ++i) {
  1398. if (i == 1) {
  1399. tmpString += String.fromCharCode(0);
  1400. }
  1401. tmpString += profany[i];
  1402. }
  1403. let re = new RegExp(profany, "g");
  1404. data[0] = data[0].replace(re, tmpString);
  1405. }
  1406. });
  1407.  
  1408. // FIX CHAT:
  1409. data[0] = data[0].slice(0, 30);
  1410. }
  1411.  
  1412. } else if (type == "L") {
  1413. // MAKE SAME CLAN:
  1414. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1415. data[0] = data[0].slice(0, 7);
  1416. } else if (type == "M") {
  1417. // APPLY CYAN COLOR:
  1418. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1419. data[0].moofoll = true;
  1420. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1421. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1422. } else if (type == "D") {
  1423. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1424. dontSend = true;
  1425. } else {
  1426. my.lastDir = data[0];
  1427. }
  1428. } else if (type == "d") {
  1429. if (!data[2]) {
  1430. dontSend = true;
  1431. } else {
  1432. if (![null, undefined].includes(data[1])) {
  1433. my.lastDir = data[1];
  1434. }
  1435. }
  1436. } else if (type == "K") {
  1437. if (!data[1]) {
  1438. dontSend = true;
  1439. }
  1440. } else if (type == "S") {
  1441. instaC.wait = !instaC.wait;
  1442. dontSend = true;
  1443. } else if (type == "a") {
  1444. if (data[1]) {
  1445. if (player.moveDir == data[0]) {
  1446. dontSend = true;
  1447. }
  1448. player.moveDir = data[0];
  1449. } else {
  1450. dontSend = true;
  1451. }
  1452. }
  1453. if (!dontSend) {
  1454. let binary = window.msgpack.encode([type, data]);
  1455. this.nsend(binary);
  1456.  
  1457. // START COUNT:
  1458. if (!firstSend.sec) {
  1459. firstSend.sec = true;
  1460. setTimeout(() => {
  1461. firstSend.sec = false;
  1462. secPacket = 0;
  1463. }, secTime);
  1464. }
  1465.  
  1466. secPacket++;
  1467. }
  1468. } else {
  1469. this.nsend(message);
  1470. }
  1471. }
  1472.  
  1473. function packet(type) {
  1474. // EXTRACT DATA ARRAY:
  1475. let data = Array.prototype.slice.call(arguments, 1);
  1476.  
  1477. // SEND MESSAGE:
  1478. let binary = window.msgpack.encode([type, data]);
  1479. WS.send(binary);
  1480. }
  1481.  
  1482. function origPacket(type) {
  1483. // EXTRACT DATA ARRAY:
  1484. let data = Array.prototype.slice.call(arguments, 1);
  1485.  
  1486. // SEND MESSAGE:
  1487. let binary = window.msgpack.encode([type, data]);
  1488. WS.nsend(binary);
  1489. }
  1490.  
  1491. window.leave = function() {
  1492. origPacket("kys", {
  1493. "frvr is so bad": true,
  1494. "sidney is too good": true,
  1495. "dev are too weak": true,
  1496. });
  1497. };
  1498.  
  1499. //...lol
  1500. let io = {
  1501. send: packet
  1502. };
  1503.  
  1504. function getMessage(message) {
  1505. let data = new Uint8Array(message.data);
  1506. let parsed = window.msgpack.decode(data);
  1507. let type = parsed[0];
  1508. data = parsed[1];
  1509. let events = {
  1510. A: setInitData, // id: setInitData,
  1511. //B: disconnect,
  1512. C: setupGame, // 1: setupGame,
  1513. D: addPlayer, // 2: addPlayer,
  1514. E: removePlayer, // 4: removePlayer,
  1515. a: updatePlayers, // 33: updatePlayers,
  1516. G: updateLeaderboard, // 5: updateLeaderboard,here
  1517. H: loadGameObject, // 6: loadGameObject,
  1518. I: loadAI, // a: loadAI,
  1519. J: animateAI, // aa: animateAI,
  1520. K: gatherAnimation, // 7: gatherAnimation,
  1521. L: wiggleGameObject, // 8: wiggleGameObject,
  1522. M: shootTurret, // sp: shootTurret,
  1523. N: updatePlayerValue, // 9: updatePlayerValue,
  1524. O: updateHealth, // h: updateHealth,//here
  1525. P: killPlayer, // 11: killPlayer,
  1526. Q: killObject, // 12: killObject,
  1527. R: killObjects, // 13: killObjects,
  1528. S: updateItemCounts, // 14: updateItemCounts,
  1529. T: updateAge, // 15: updateAge,
  1530. U: updateUpgrades, // 16: updateUpgrades,
  1531. V: updateItems, // 17: updateItems,
  1532. X: addProjectile, // 18: addProjectile,
  1533. // Y: remProjectile, // 19: remProjectile,
  1534. //Z: serverShutdownNotice,
  1535. //0: addAlliance,
  1536. //1: deleteAlliance,
  1537. 2: allianceNotification, // an: allianceNotification,
  1538. 3: setPlayerTeam, // st: setPlayerTeam,
  1539. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1540. 5: updateStoreItems, // us: updateStoreItems,
  1541. 6: receiveChat, // ch: receiveChat,
  1542. 7: updateMinimap, // mm: updateMinimap,
  1543. 8: showText, // t: showText,
  1544. 9: pingMap, // p: pingMap,
  1545. 0: pingSocketResponse,
  1546. };
  1547. if (type == "io-init") {
  1548. socketID = data[0];
  1549. } else {
  1550. if (events[type]) {
  1551. events[type].apply(undefined, data);
  1552. }
  1553. }
  1554. }
  1555.  
  1556. // MATHS:
  1557. Math.lerpAngle = function(value1, value2, amount) {
  1558. let difference = Math.abs(value2 - value1);
  1559. if (difference > Math.PI) {
  1560. if (value1 > value2) {
  1561. value2 += Math.PI * 2;
  1562. } else {
  1563. value1 += Math.PI * 2;
  1564. }
  1565. }
  1566. let value = value2 + ((value1 - value2) * amount);
  1567. if (value >= 0 && value <= Math.PI * 2) return value;
  1568. return value % (Math.PI * 2);
  1569. };
  1570.  
  1571. // REOUNDED RECTANGLE:
  1572. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1573. if (w < 2 * r) r = w / 2;
  1574. if (h < 2 * r) r = h / 2;
  1575. if (r < 0)
  1576. r = 0;
  1577. this.beginPath();
  1578. this.moveTo(x + r, y);
  1579. this.arcTo(x + w, y, x + w, y + h, r);
  1580. this.arcTo(x + w, y + h, x, y + h, r);
  1581. this.arcTo(x, y + h, x, y, r);
  1582. this.arcTo(x, y, x + w, y, r);
  1583. this.closePath();
  1584. return this;
  1585. };
  1586.  
  1587. // GLOBAL VALUES:
  1588. function resetMoveDir() {
  1589. keys = {};
  1590. io.send("e");
  1591. }
  1592.  
  1593. let allChats = [];
  1594. let ticks = {
  1595. tick: 0,
  1596. delay: 0,
  1597. time: [],
  1598. manage: [],
  1599. };
  1600. let ais = [];
  1601. let players = [];
  1602. let alliances = [];
  1603. let alliancePlayers = [];
  1604. let allianceNotifications = [];
  1605. let gameObjects = [];
  1606. let liztobj = [];
  1607. let projectiles = [];
  1608. let deadPlayers = [];
  1609.  
  1610. let breakObjects = [];
  1611.  
  1612. let player;
  1613. let playerSID;
  1614. let tmpObj;
  1615.  
  1616. let enemy = [];
  1617. let nears = [];
  1618. let near = [];
  1619.  
  1620. let my = {
  1621. reloaded: false,
  1622. waitHit: 0,
  1623. autoAim: false,
  1624. revAim: false,
  1625. ageInsta: true,
  1626. reSync: false,
  1627. bullTick: 0,
  1628. anti0Tick: 0,
  1629. antiSync: false,
  1630. safePrimary: function(tmpObj) {
  1631. return [0, 8].includes(tmpObj.primaryIndex);
  1632. },
  1633. safeSecondary: function(tmpObj) {
  1634. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1635. },
  1636. lastDir: 0,
  1637. autoPush: false,
  1638. pushData: {}
  1639. }
  1640.  
  1641. // FIND OBJECTS BY ID/SID:
  1642. function findID(tmpObj, tmp) {
  1643. return tmpObj.find((THIS) => THIS.id == tmp);
  1644. }
  1645.  
  1646. function findSID(tmpObj, tmp) {
  1647. return tmpObj.find((THIS) => THIS.sid == tmp);
  1648. }
  1649.  
  1650. function findPlayerByID(id) {
  1651. return findID(players, id);
  1652. }
  1653.  
  1654. function findPlayerBySID(sid) {
  1655. return findSID(players, sid);
  1656. }
  1657.  
  1658. function findAIBySID(sid) {
  1659. return findSID(ais, sid);
  1660. }
  1661.  
  1662. function findObjectBySid(sid) {
  1663. return findSID(gameObjects, sid);
  1664. }
  1665.  
  1666. function findProjectileBySid(sid) {
  1667. return findSID(gameObjects, sid);
  1668. }
  1669.  
  1670. let adCard = getEl("adCard");
  1671. adCard.remove();
  1672. let promoImageHolder = getEl("promoImgHolder");
  1673. promoImageHolder.remove();
  1674.  
  1675. let chatButton = getEl("chatButton");
  1676. chatButton.remove();
  1677. let gameCanvas = getEl("gameCanvas");
  1678. let mainContext = gameCanvas.getContext("2d");
  1679. let mapDisplay = getEl("mapDisplay");
  1680. let mapContext = mapDisplay.getContext("2d");
  1681. mapDisplay.width = 300;
  1682. mapDisplay.height = 300;
  1683. let storeMenu = getEl("storeMenu");
  1684. let storeHolder = getEl("storeHolder");
  1685. let upgradeHolder = getEl("upgradeHolder");
  1686. let upgradeCounter = getEl("upgradeCounter");
  1687. let chatBox = getEl("chatBox");
  1688. chatBox.autocomplete = "off";
  1689. chatBox.style.textAlign = "center";
  1690. chatBox.style.width = "18em";
  1691. let chatHolder = getEl("chatHolder");
  1692. let actionBar = getEl("actionBar");
  1693. let leaderboardData = getEl("leaderboardData");
  1694. let itemInfoHolder = getEl("itemInfoHolder");
  1695. let menuCardHolder = getEl("menuCardHolder");
  1696. let mainMenu = getEl("mainMenu");
  1697. let diedText = getEl("diedText");
  1698. let screenWidth;
  1699. let screenHeight;
  1700. let maxScreenWidth = config.maxScreenWidth;
  1701. let maxScreenHeight = config.maxScreenHeight;
  1702. let pixelDensity = 1;
  1703. let delta;
  1704. let now;
  1705. let lastUpdate = performance.now();
  1706. let camX;
  1707. let camY;
  1708. let tmpDir;
  1709. let mouseX = 0;
  1710. let mouseY = 0;
  1711. let allianceMenu = getEl("allianceMenu");
  1712. let waterMult = 1;
  1713. let waterPlus = 0;
  1714.  
  1715. let outlineColor = "#525252";
  1716. let darkOutlineColor = "#3d3f42";
  1717. let outlineWidth = 5.5;
  1718.  
  1719. let firstSetup = true;
  1720. let keys = {};
  1721. let moveKeys = {
  1722. 87: [0, -1],
  1723. 38: [0, -1],
  1724. 83: [0, 1],
  1725. 40: [0, 1],
  1726. 65: [-1, 0],
  1727. 37: [-1, 0],
  1728. 68: [1, 0],
  1729. 39: [1, 0],
  1730. };
  1731. let attackState = 0;
  1732. let inGame = false;
  1733.  
  1734. let macro = {};
  1735. let mills = {
  1736. place: 0,
  1737. placeSpawnPads: 0
  1738. };
  1739. let lastDir;
  1740.  
  1741. let lastLeaderboardData = [];
  1742.  
  1743. // ON LOAD:
  1744. let inWindow = true;
  1745. window.onblur = function() {
  1746. inWindow = false;
  1747. };
  1748. window.onfocus = function() {
  1749. inWindow = true;
  1750. if (player && player.alive) {
  1751. // resetMoveDir();
  1752. }
  1753. };
  1754. let ms = {
  1755. avg: 0,
  1756. max: 0,
  1757. min: 0,
  1758. delay: 0
  1759. }
  1760. function pingSocketResponse() {
  1761. let pingTime = window.pingTime;
  1762. const pingDisplay = document.getElementById("pingDisplay")
  1763. pingDisplay.innerText = "";
  1764. if (pingTime > ms.max || isNaN(ms.max)) {
  1765. ms.max = pingTime;
  1766. }
  1767. if (pingTime < ms.min || isNaN(ms.min)) {
  1768. ms.min = pingTime;
  1769. }
  1770.  
  1771. // if (pingTime >= 90) {
  1772. // doAutoQ = true;
  1773. // } else {
  1774. // doAutoQ = false;
  1775. // }
  1776. }
  1777.  
  1778. let placeVisible = [];
  1779.  
  1780. /** CLASS CODES */
  1781.  
  1782. class Utils {
  1783. constructor() {
  1784.  
  1785. // MATH UTILS:
  1786. let mathABS = Math.abs,
  1787. mathCOS = Math.cos,
  1788. mathSIN = Math.sin,
  1789. mathPOW = Math.pow,
  1790. mathSQRT = Math.sqrt,
  1791. mathATAN2 = Math.atan2,
  1792. mathPI = Math.PI;
  1793.  
  1794. let _this = this;
  1795.  
  1796. // GLOBAL UTILS:
  1797. this.round = function(n, v) {
  1798. return Math.round(n * v) / v;
  1799. };
  1800. this.toRad = function(angle) {
  1801. return angle * (mathPI / 180);
  1802. };
  1803. this.toAng = function(radian) {
  1804. return radian / (mathPI / 180);
  1805. };
  1806. this.randInt = function(min, max) {
  1807. return Math.floor(Math.random() * (max - min + 1)) + min;
  1808. };
  1809. this.randFloat = function(min, max) {
  1810. return Math.random() * (max - min + 1) + min;
  1811. };
  1812. this.lerp = function(value1, value2, amount) {
  1813. return value1 + (value2 - value1) * amount;
  1814. };
  1815. this.decel = function(val, cel) {
  1816. if (val > 0)
  1817. val = Math.max(0, val - cel);
  1818. else if (val < 0)
  1819. val = Math.min(0, val + cel);
  1820. return val;
  1821. };
  1822. this.getDistance = function(x1, y1, x2, y2) {
  1823. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1824. };
  1825. this.getDist = function(tmp1, tmp2, type1, type2) {
  1826. let tmpXY1 = {
  1827. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1828. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1829. };
  1830. let tmpXY2 = {
  1831. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1832. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1833. };
  1834. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1835. };
  1836. this.getDirection = function(x1, y1, x2, y2) {
  1837. return mathATAN2(y1 - y2, x1 - x2);
  1838. };
  1839. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1840. let tmpXY1 = {
  1841. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1842. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1843. };
  1844. let tmpXY2 = {
  1845. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1846. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1847. };
  1848. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1849. };
  1850. this.getAngleDist = function(a, b) {
  1851. let p = mathABS(b - a) % (mathPI * 2);
  1852. return (p > mathPI ? (mathPI * 2) - p : p);
  1853. };
  1854. this.isNumber = function(n) {
  1855. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1856. };
  1857. this.isString = function(s) {
  1858. return (s && typeof s == "string");
  1859. };
  1860. this.kFormat = function(num) {
  1861. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1862. };
  1863. this.sFormat = function(num) {
  1864. let fixs = [{
  1865. num: 1e3,
  1866. string: "k"
  1867. },
  1868. {
  1869. num: 1e6,
  1870. string: "m"
  1871. },
  1872. {
  1873. num: 1e9,
  1874. string: "b"
  1875. },
  1876. {
  1877. num: 1e12,
  1878. string: "q"
  1879. }
  1880. ].reverse();
  1881. let sp = fixs.find(v => num >= v.num);
  1882. if (!sp) return num;
  1883. return (num / sp.num).toFixed(1) + sp.string;
  1884. };
  1885. this.capitalizeFirst = function(string) {
  1886. return string.charAt(0).toUpperCase() + string.slice(1);
  1887. };
  1888. this.fixTo = function(n, v) {
  1889. return parseFloat(n.toFixed(v));
  1890. };
  1891. this.sortByPoints = function(a, b) {
  1892. return parseFloat(b.points) - parseFloat(a.points);
  1893. };
  1894. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1895. let minX = x1;
  1896. let maxX = x2;
  1897. if (x1 > x2) {
  1898. minX = x2;
  1899. maxX = x1;
  1900. }
  1901. if (maxX > recX2)
  1902. maxX = recX2;
  1903. if (minX < recX)
  1904. minX = recX;
  1905. if (minX > maxX)
  1906. return false;
  1907. let minY = y1;
  1908. let maxY = y2;
  1909. let dx = x2 - x1;
  1910. if (Math.abs(dx) > 0.0000001) {
  1911. let a = (y2 - y1) / dx;
  1912. let b = y1 - a * x1;
  1913. minY = a * minX + b;
  1914. maxY = a * maxX + b;
  1915. }
  1916. if (minY > maxY) {
  1917. let tmp = maxY;
  1918. maxY = minY;
  1919. minY = tmp;
  1920. }
  1921. if (maxY > recY2)
  1922. maxY = recY2;
  1923. if (minY < recY)
  1924. minY = recY;
  1925. if (minY > maxY)
  1926. return false;
  1927. return true;
  1928. };
  1929. this.containsPoint = function(element, x, y) {
  1930. let bounds = element.getBoundingClientRect();
  1931. let left = bounds.left + window.scrollX;
  1932. let top = bounds.top + window.scrollY;
  1933. let width = bounds.width;
  1934. let height = bounds.height;
  1935.  
  1936. let insideHorizontal = x > left && x < left + width;
  1937. let insideVertical = y > top && y < top + height;
  1938. return insideHorizontal && insideVertical;
  1939. };
  1940. this.mousifyTouchEvent = function(event) {
  1941. let touch = event.changedTouches[0];
  1942. event.screenX = touch.screenX;
  1943. event.screenY = touch.screenY;
  1944. event.clientX = touch.clientX;
  1945. event.clientY = touch.clientY;
  1946. event.pageX = touch.pageX;
  1947. event.pageY = touch.pageY;
  1948. };
  1949. this.hookTouchEvents = function(element, skipPrevent) {
  1950. let preventDefault = !skipPrevent;
  1951. let isHovering = false;
  1952. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1953. let passive = false;
  1954. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1955. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1956. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1957. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1958. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1959.  
  1960. function touchStart(e) {
  1961. _this.mousifyTouchEvent(e);
  1962. window.setUsingTouch(true);
  1963. if (preventDefault) {
  1964. e.preventDefault();
  1965. e.stopPropagation();
  1966. }
  1967. if (element.onmouseover)
  1968. element.onmouseover(e);
  1969. isHovering = true;
  1970. }
  1971.  
  1972. function touchMove(e) {
  1973. _this.mousifyTouchEvent(e);
  1974. window.setUsingTouch(true);
  1975. if (preventDefault) {
  1976. e.preventDefault();
  1977. e.stopPropagation();
  1978. }
  1979. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1980. if (!isHovering) {
  1981. if (element.onmouseover)
  1982. element.onmouseover(e);
  1983. isHovering = true;
  1984. }
  1985. } else {
  1986. if (isHovering) {
  1987. if (element.onmouseout)
  1988. element.onmouseout(e);
  1989. isHovering = false;
  1990. }
  1991. }
  1992. }
  1993.  
  1994. function touchEnd(e) {
  1995. _this.mousifyTouchEvent(e);
  1996. window.setUsingTouch(true);
  1997. if (preventDefault) {
  1998. e.preventDefault();
  1999. e.stopPropagation();
  2000. }
  2001. if (isHovering) {
  2002. if (element.onclick)
  2003. element.onclick(e);
  2004. if (element.onmouseout)
  2005. element.onmouseout(e);
  2006. isHovering = false;
  2007. }
  2008. }
  2009. };
  2010. this.removeAllChildren = function(element) {
  2011. while (element.hasChildNodes()) {
  2012. element.removeChild(element.lastChild);
  2013. }
  2014. };
  2015. this.generateElement = function(config) {
  2016. let element = document.createElement(config.tag || "div");
  2017.  
  2018. function bind(configValue, elementValue) {
  2019. if (config[configValue])
  2020. element[elementValue] = config[configValue];
  2021. }
  2022. bind("text", "textContent");
  2023. bind("html", "innerHTML");
  2024. bind("class", "className");
  2025. for (let key in config) {
  2026. switch (key) {
  2027. case "tag":
  2028. case "text":
  2029. case "html":
  2030. case "class":
  2031. case "style":
  2032. case "hookTouch":
  2033. case "parent":
  2034. case "children":
  2035. continue;
  2036. default:
  2037. break;
  2038. }
  2039. element[key] = config[key];
  2040. }
  2041. if (element.onclick)
  2042. element.onclick = this.checkTrusted(element.onclick);
  2043. if (element.onmouseover)
  2044. element.onmouseover = this.checkTrusted(element.onmouseover);
  2045. if (element.onmouseout)
  2046. element.onmouseout = this.checkTrusted(element.onmouseout);
  2047. if (config.style) {
  2048. element.style.cssText = config.style;
  2049. }
  2050. if (config.hookTouch) {
  2051. this.hookTouchEvents(element);
  2052. }
  2053. if (config.parent) {
  2054. config.parent.appendChild(element);
  2055. }
  2056. if (config.children) {
  2057. for (let i = 0; i < config.children.length; i++) {
  2058. element.appendChild(config.children[i]);
  2059. }
  2060. }
  2061. return element;
  2062. };
  2063. this.checkTrusted = function(callback) {
  2064. return function(ev) {
  2065. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2066. callback(ev);
  2067. } else {
  2068. //console.error("Event is not trusted.", ev);
  2069. }
  2070. };
  2071. };
  2072. this.randomString = function(length) {
  2073. let text = "";
  2074. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2075. for (let i = 0; i < length; i++) {
  2076. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2077. }
  2078. return text;
  2079. };
  2080. this.countInArray = function(array, val) {
  2081. let count = 0;
  2082. for (let i = 0; i < array.length; i++) {
  2083. if (array[i] === val) count++;
  2084. }
  2085. return count;
  2086. };
  2087. this.hexToRgb = function(hex) {
  2088. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2089. };
  2090. this.getRgb = function(r, g, b) {
  2091. return [r / 255, g / 255, b / 255].join(", ");
  2092. };
  2093. }
  2094. };
  2095. class Animtext {
  2096. // ANIMATED TEXT:
  2097. constructor() {
  2098. // INIT:
  2099. this.init = function(x, y, scale, speed, life, text, color) {
  2100. (this.x = x),
  2101. (this.y = y),
  2102. (this.color = color),
  2103. (this.scale = scale*3.5),
  2104. (this.weight = 50);
  2105. (this.startScale = this.scale * 1.2),
  2106. (this.maxScale = 1.5 * scale),
  2107. (this.minScale = 0.5 * scale),
  2108. (this.scaleSpeed = 0.7),
  2109. (this.speed = speed),
  2110. (this.speedMax = speed),
  2111. (this.life = life),
  2112. (this.maxLife = life),
  2113. (this.text = text),
  2114. this.movSpeed = speed;
  2115. };
  2116.  
  2117. // UPDATE:
  2118. this.update = function(delta) {
  2119. if(this.life){
  2120. this.life -= delta;
  2121. if(this.scaleSpeed != -0.35){
  2122. this.y -= this.speed * delta;
  2123. // (this.x += this.speed * delta);
  2124. } else {
  2125. this.y -= this.speed * delta;
  2126. }
  2127. this.scale -= .8;
  2128. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2129. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2130. if(this.scale >= this.maxScale){
  2131. this.scale = this.maxScale;
  2132. this.scaleSpeed *= -.5;
  2133. this.speed = this.speed * .75;
  2134. };
  2135. this.life <= 0 && (this.life = 0)
  2136. };
  2137. };
  2138.  
  2139. // RENDER:
  2140. this.render = function(ctxt, xOff, yOff) {
  2141. ctxt.lineWidth = 10;
  2142. ctxt.strokeStyle = darkOutlineColor; //"black";
  2143. ctxt.fillStyle = this.color;
  2144. ctxt.globalAlpha = 1;
  2145. ctxt.font = this.scale + "px Hammersmith One";
  2146. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2147. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2148. ctxt.globalAlpha = 1;
  2149. };
  2150. }
  2151. };
  2152. class Textmanager {
  2153. // TEXT MANAGER:
  2154. constructor() {
  2155. this.texts = [];
  2156. this.stack = [];
  2157.  
  2158. // UPDATE:
  2159. this.update = function(delta, ctxt, xOff, yOff) {
  2160. ctxt.textBaseline = "middle";
  2161. ctxt.textAlign = "center";
  2162. for (let i = 0; i < this.texts.length; ++i) {
  2163. if (this.texts[i].life) {
  2164. this.texts[i].update(delta);
  2165. this.texts[i].render(ctxt, xOff, yOff);
  2166. }
  2167. }
  2168. };
  2169.  
  2170. // SHOW TEXT:
  2171. this.showText = function(x, y, scale, speed, life, text, color) {
  2172. let tmpText;
  2173. for (let i = 0; i < this.texts.length; ++i) {
  2174. if (!this.texts[i].life) {
  2175. tmpText = this.texts[i];
  2176. break;
  2177. }
  2178. }
  2179. if (!tmpText) {
  2180. tmpText = new Animtext();
  2181. this.texts.push(tmpText);
  2182. }
  2183. tmpText.init(x, y, scale, speed, life, text, color);
  2184. };
  2185. }
  2186. }
  2187.  
  2188. class GameObject {
  2189. constructor(sid) {
  2190. this.sid = sid;
  2191.  
  2192. // INIT:
  2193. this.init = function(x, y, dir, scale, type, data, owner) {
  2194. data = data || {};
  2195. this.sentTo = {};
  2196. this.gridLocations = [];
  2197. this.active = true;
  2198. this.render = true;
  2199. this.doUpdate = data.doUpdate;
  2200. this.x = x;
  2201. this.y = y;
  2202. this.dir = dir;
  2203. this.lastDir = dir;
  2204. this.xWiggle = 0;
  2205. this.yWiggle = 0;
  2206. this.visScale = scale;
  2207. this.scale = scale;
  2208. this.type = type;
  2209. this.id = data.id;
  2210. this.owner = owner;
  2211. this.name = data.name;
  2212. this.isItem = (this.id != undefined);
  2213. this.group = data.group;
  2214. this.maxHealth = data.health;
  2215. this.health = this.maxHealth;
  2216. this.layer = 2;
  2217. if (this.group != undefined) {
  2218. this.layer = this.group.layer;
  2219. } else if (this.type == 0) {
  2220. this.layer = 3;
  2221. } else if (this.type == 2) {
  2222. this.layer = 0;
  2223. } else if (this.type == 4) {
  2224. this.layer = -1;
  2225. }
  2226. this.colDiv = data.colDiv || 1;
  2227. this.blocker = data.blocker;
  2228. this.ignoreCollision = data.ignoreCollision;
  2229. this.dontGather = data.dontGather;
  2230. this.hideFromEnemy = data.hideFromEnemy;
  2231. this.friction = data.friction;
  2232. this.projDmg = data.projDmg;
  2233. this.dmg = data.dmg;
  2234. this.pDmg = data.pDmg;
  2235. this.pps = data.pps;
  2236. this.zIndex = data.zIndex || 0;
  2237. this.turnSpeed = data.turnSpeed;
  2238. this.req = data.req;
  2239. this.trap = data.trap;
  2240. this.healCol = data.healCol;
  2241. this.teleport = data.teleport;
  2242. this.boostSpeed = data.boostSpeed;
  2243. this.projectile = data.projectile;
  2244. this.shootRange = data.shootRange;
  2245. this.shootRate = data.shootRate;
  2246. this.shootCount = this.shootRate;
  2247. this.spawnPoint = data.spawnPoint;
  2248. this.onNear = 0;
  2249. this.breakObj = false;
  2250. this.alpha = data.alpha || 1;
  2251. this.maxAlpha = data.alpha || 1;
  2252. this.damaged = 0;
  2253. };
  2254.  
  2255. // GET HIT:
  2256. this.changeHealth = function(amount, doer) {
  2257. this.health += amount;
  2258. return (this.health <= 0);
  2259. };
  2260.  
  2261. // GET SCALE:
  2262. this.getScale = function(sM, ig) {
  2263. sM = sM || 1;
  2264. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2265. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2266. };
  2267.  
  2268. // VISIBLE TO PLAYER:
  2269. this.visibleToPlayer = function(player) {
  2270. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2271. (this.owner.team && player.team == this.owner.team)));
  2272. };
  2273.  
  2274. // UPDATE:
  2275. this.update = function(delta) {
  2276. if (this.active) {
  2277. if (this.xWiggle) {
  2278. this.xWiggle *= Math.pow(0.99, delta);
  2279. }
  2280. if (this.yWiggle) {
  2281. this.yWiggle *= Math.pow(0.99, delta);
  2282. }
  2283. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2284. if (d2 > 0.01) {
  2285. this.dir += d2 / 5;
  2286. } else {
  2287. this.dir = this.lastDir;
  2288. }
  2289. } else {
  2290. if (this.alive) {
  2291. this.alpha -= delta / (200 / this.maxAlpha);
  2292. this.visScale += delta / (this.scale / 2.5);
  2293. if (this.alpha <= 0) {
  2294. this.alpha = 0;
  2295. this.alive = false;
  2296. }
  2297. }
  2298. }
  2299. };
  2300.  
  2301. // CHECK TEAM:
  2302. this.isTeamObject = function(tmpObj) {
  2303. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2304. };
  2305. }
  2306. }
  2307. class Items {
  2308. constructor() {
  2309. // ITEM GROUPS:
  2310. this.groups = [{
  2311. id: 0,
  2312. name: "food",
  2313. layer: 0
  2314. }, {
  2315. id: 1,
  2316. name: "walls",
  2317. place: true,
  2318. limit: 30,
  2319. layer: 0
  2320. }, {
  2321. id: 2,
  2322. name: "spikes",
  2323. place: true,
  2324. limit: 15,
  2325. layer: 0
  2326. }, {
  2327. id: 3,
  2328. name: "mill",
  2329. place: true,
  2330. limit: 7,
  2331. layer: 1
  2332. }, {
  2333. id: 4,
  2334. name: "mine",
  2335. place: true,
  2336. limit: 1,
  2337. layer: 0
  2338. }, {
  2339. id: 5,
  2340. name: "trap",
  2341. place: true,
  2342. limit: 6,
  2343. layer: -1
  2344. }, {
  2345. id: 6,
  2346. name: "booster",
  2347. place: true,
  2348. limit: 12,
  2349. layer: -1
  2350. }, {
  2351. id: 7,
  2352. name: "turret",
  2353. place: true,
  2354. limit: 2,
  2355. layer: 1
  2356. }, {
  2357. id: 8,
  2358. name: "watchtower",
  2359. place: true,
  2360. limit: 12,
  2361. layer: 1
  2362. }, {
  2363. id: 9,
  2364. name: "buff",
  2365. place: true,
  2366. limit: 4,
  2367. layer: -1
  2368. }, {
  2369. id: 10,
  2370. name: "spawn",
  2371. place: true,
  2372. limit: 1,
  2373. layer: -1
  2374. }, {
  2375. id: 11,
  2376. name: "sapling",
  2377. place: true,
  2378. limit: 2,
  2379. layer: 0
  2380. }, {
  2381. id: 12,
  2382. name: "blocker",
  2383. place: true,
  2384. limit: 3,
  2385. layer: -1
  2386. }, {
  2387. id: 13,
  2388. name: "teleporter",
  2389. place: true,
  2390. limit: 2,
  2391. layer: -1
  2392. }];
  2393.  
  2394. // PROJECTILES:
  2395. this.projectiles = [{
  2396. indx: 0,
  2397. layer: 0,
  2398. src: "arrow_1",
  2399. dmg: 25,
  2400. speed: 1.6,
  2401. scale: 103,
  2402. range: 1000
  2403. }, {
  2404. indx: 1,
  2405. layer: 1,
  2406. dmg: 25,
  2407. scale: 20
  2408. }, {
  2409. indx: 0,
  2410. layer: 0,
  2411. src: "arrow_1",
  2412. dmg: 35,
  2413. speed: 2.5,
  2414. scale: 103,
  2415. range: 1200
  2416. }, {
  2417. indx: 0,
  2418. layer: 0,
  2419. src: "arrow_1",
  2420. dmg: 30,
  2421. speed: 2,
  2422. scale: 103,
  2423. range: 1200
  2424. }, {
  2425. indx: 1,
  2426. layer: 1,
  2427. dmg: 16,
  2428. scale: 20
  2429. }, {
  2430. indx: 0,
  2431. layer: 0,
  2432. src: "bullet_1",
  2433. dmg: 50,
  2434. speed: 3.6,
  2435. scale: 160,
  2436. range: 1400
  2437. }];
  2438.  
  2439. // WEAPONS:
  2440. this.weapons = [{
  2441. id: 0,
  2442. type: 0,
  2443. name: "tool hammer",
  2444. desc: "tool for gathering all resources",
  2445. src: "hammer_1",
  2446. length: 140,
  2447. width: 140,
  2448. xOff: -3,
  2449. yOff: 18,
  2450. dmg: 25,
  2451. range: 65,
  2452. gather: 1,
  2453. speed: 300
  2454. }, {
  2455. id: 1,
  2456. type: 0,
  2457. age: 2,
  2458. name: "hand axe",
  2459. desc: "gathers resources at a higher rate",
  2460. src: "axe_1",
  2461. length: 140,
  2462. width: 140,
  2463. xOff: 3,
  2464. yOff: 24,
  2465. dmg: 30,
  2466. spdMult: 1,
  2467. range: 70,
  2468. gather: 2,
  2469. speed: 400
  2470. }, {
  2471. id: 2,
  2472. type: 0,
  2473. age: 8,
  2474. pre: 1,
  2475. name: "great axe",
  2476. desc: "deal more damage and gather more resources",
  2477. src: "great_axe_1",
  2478. length: 140,
  2479. width: 140,
  2480. xOff: -8,
  2481. yOff: 25,
  2482. dmg: 35,
  2483. spdMult: 1,
  2484. range: 75,
  2485. gather: 4,
  2486. speed: 400
  2487. }, {
  2488. id: 3,
  2489. type: 0,
  2490. age: 2,
  2491. name: "short sword",
  2492. desc: "increased attack power but slower move speed",
  2493. src: "sword_1",
  2494. iPad: 1.3,
  2495. length: 130,
  2496. width: 210,
  2497. xOff: -8,
  2498. yOff: 46,
  2499. dmg: 35,
  2500. spdMult: 0.85,
  2501. range: 110,
  2502. gather: 1,
  2503. speed: 300
  2504. }, {
  2505. id: 4,
  2506. type: 0,
  2507. age: 8,
  2508. pre: 3,
  2509. name: "katana",
  2510. desc: "greater range and damage",
  2511. src: "samurai_1",
  2512. iPad: 1.3,
  2513. length: 130,
  2514. width: 210,
  2515. xOff: -8,
  2516. yOff: 59,
  2517. dmg: 40,
  2518. spdMult: 0.8,
  2519. range: 118,
  2520. gather: 1,
  2521. speed: 300
  2522. }, {
  2523. id: 5,
  2524. type: 0,
  2525. age: 2,
  2526. name: "polearm",
  2527. desc: "long range melee weapon",
  2528. src: "spear_1",
  2529. iPad: 1.3,
  2530. length: 130,
  2531. width: 210,
  2532. xOff: -8,
  2533. yOff: 53,
  2534. dmg: 45,
  2535. knock: 0.2,
  2536. spdMult: 0.82,
  2537. range: 142,
  2538. gather: 1,
  2539. speed: 700
  2540. }, {
  2541. id: 6,
  2542. type: 0,
  2543. age: 2,
  2544. name: "bat",
  2545. desc: "fast long range melee weapon",
  2546. src: "bat_1",
  2547. iPad: 1.3,
  2548. length: 110,
  2549. width: 180,
  2550. xOff: -8,
  2551. yOff: 53,
  2552. dmg: 20,
  2553. knock: 0.7,
  2554. range: 110,
  2555. gather: 1,
  2556. speed: 300
  2557. }, {
  2558. id: 7,
  2559. type: 0,
  2560. age: 2,
  2561. name: "daggers",
  2562. desc: "really fast short range weapon",
  2563. src: "dagger_1",
  2564. iPad: 0.8,
  2565. length: 110,
  2566. width: 110,
  2567. xOff: 18,
  2568. yOff: 0,
  2569. dmg: 20,
  2570. knock: 0.1,
  2571. range: 65,
  2572. gather: 1,
  2573. hitSlow: 0.1,
  2574. spdMult: 1.13,
  2575. speed: 100
  2576. }, {
  2577. id: 8,
  2578. type: 0,
  2579. age: 2,
  2580. name: "stick",
  2581. desc: "great for gathering but very weak",
  2582. src: "stick_1",
  2583. length: 140,
  2584. width: 140,
  2585. xOff: 3,
  2586. yOff: 24,
  2587. dmg: 1,
  2588. spdMult: 1,
  2589. range: 70,
  2590. gather: 7,
  2591. speed: 400
  2592. }, {
  2593. id: 9,
  2594. type: 1,
  2595. age: 6,
  2596. name: "hunting bow",
  2597. desc: "bow used for ranged combat and hunting",
  2598. src: "bow_1",
  2599. req: ["wood", 4],
  2600. length: 120,
  2601. width: 120,
  2602. xOff: -6,
  2603. yOff: 0,
  2604. Pdmg: 25,
  2605. projectile: 0,
  2606. spdMult: 0.75,
  2607. speed: 600
  2608. }, {
  2609. id: 10,
  2610. type: 1,
  2611. age: 6,
  2612. name: "great hammer",
  2613. desc: "hammer used for destroying structures",
  2614. src: "great_hammer_1",
  2615. length: 140,
  2616. width: 140,
  2617. xOff: -9,
  2618. yOff: 25,
  2619. dmg: 10,
  2620. Pdmg: 10,
  2621. spdMult: 0.88,
  2622. range: 75,
  2623. sDmg: 7.5,
  2624. gather: 1,
  2625. speed: 400
  2626. }, {
  2627. id: 11,
  2628. type: 1,
  2629. age: 6,
  2630. name: "wooden shield",
  2631. desc: "blocks projectiles and reduces melee damage",
  2632. src: "shield_1",
  2633. length: 120,
  2634. width: 120,
  2635. shield: 0.2,
  2636. xOff: 6,
  2637. yOff: 0,
  2638. Pdmg: 0,
  2639. spdMult: 0.7
  2640. }, {
  2641. id: 12,
  2642. type: 1,
  2643. age: 8,
  2644. pre: 9,
  2645. name: "crossbow",
  2646. desc: "deals more damage and has greater range",
  2647. src: "crossbow_1",
  2648. req: ["wood", 5],
  2649. aboveHand: true,
  2650. armS: 0.75,
  2651. length: 120,
  2652. width: 120,
  2653. xOff: -4,
  2654. yOff: 0,
  2655. Pdmg: 35,
  2656. projectile: 2,
  2657. spdMult: 0.7,
  2658. speed: 700
  2659. }, {
  2660. id: 13,
  2661. type: 1,
  2662. age: 9,
  2663. pre: 12,
  2664. name: "repeater crossbow",
  2665. desc: "high firerate crossbow with reduced damage",
  2666. src: "crossbow_2",
  2667. req: ["wood", 10],
  2668. aboveHand: true,
  2669. armS: 0.75,
  2670. length: 120,
  2671. width: 120,
  2672. xOff: -4,
  2673. yOff: 0,
  2674. Pdmg: 30,
  2675. projectile: 3,
  2676. spdMult: 0.7,
  2677. speed: 230
  2678. }, {
  2679. id: 14,
  2680. type: 1,
  2681. age: 6,
  2682. name: "mc grabby",
  2683. desc: "steals resources from enemies",
  2684. src: "grab_1",
  2685. length: 130,
  2686. width: 210,
  2687. xOff: -8,
  2688. yOff: 53,
  2689. dmg: 0,
  2690. Pdmg: 0,
  2691. steal: 250,
  2692. knock: 0.2,
  2693. spdMult: 1.05,
  2694. range: 125,
  2695. gather: 0,
  2696. speed: 700
  2697. }, {
  2698. id: 15,
  2699. type: 1,
  2700. age: 9,
  2701. pre: 12,
  2702. name: "musket",
  2703. desc: "slow firerate but high damage and range",
  2704. src: "musket_1",
  2705. req: ["stone", 10],
  2706. aboveHand: true,
  2707. rec: 0.35,
  2708. armS: 0.6,
  2709. hndS: 0.3,
  2710. hndD: 1.6,
  2711. length: 205,
  2712. width: 205,
  2713. xOff: 25,
  2714. yOff: 0,
  2715. Pdmg: 50,
  2716. projectile: 5,
  2717. hideProjectile: true,
  2718. spdMult: 0.6,
  2719. speed: 1500
  2720. }];
  2721.  
  2722. // ITEMS:
  2723. this.list = [{
  2724. group: this.groups[0],
  2725. name: "apple",
  2726. desc: "restores 20 health when consumed",
  2727. req: ["food", 10],
  2728. consume: function(doer) {
  2729. return doer.changeHealth(20, doer);
  2730. },
  2731. scale: 22,
  2732. holdOffset: 15,
  2733. healing: 20,
  2734. itemID: 0,
  2735. itemAID: 16,
  2736. }, {
  2737. age: 3,
  2738. group: this.groups[0],
  2739. name: "cookie",
  2740. desc: "restores 40 health when consumed",
  2741. req: ["food", 15],
  2742. consume: function(doer) {
  2743. return doer.changeHealth(40, doer);
  2744. },
  2745. scale: 27,
  2746. holdOffset: 15,
  2747. healing: 40,
  2748. itemID: 1,
  2749. itemAID: 17,
  2750. }, {
  2751. age: 7,
  2752. group: this.groups[0],
  2753. name: "cheese",
  2754. desc: "restores 30 health and another 50 over 5 seconds",
  2755. req: ["food", 25],
  2756. consume: function(doer) {
  2757. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2758. doer.dmgOverTime.dmg = -10;
  2759. doer.dmgOverTime.doer = doer;
  2760. doer.dmgOverTime.time = 5;
  2761. return true;
  2762. }
  2763. return false;
  2764. },
  2765. scale: 27,
  2766. holdOffset: 15,
  2767. healing: 30,
  2768. itemID: 2,
  2769. itemAID: 18,
  2770. }, {
  2771. group: this.groups[1],
  2772. name: "wood wall",
  2773. desc: "provides protection for your village",
  2774. req: ["wood", 10],
  2775. projDmg: true,
  2776. health: 380,
  2777. scale: 50,
  2778. holdOffset: 20,
  2779. placeOffset: -5,
  2780. itemID: 3,
  2781. itemAID: 19,
  2782. }, {
  2783. age: 3,
  2784. group: this.groups[1],
  2785. name: "stone wall",
  2786. desc: "provides improved protection for your village",
  2787. req: ["stone", 25],
  2788. health: 900,
  2789. scale: 50,
  2790. holdOffset: 20,
  2791. placeOffset: -5,
  2792. itemID: 4,
  2793. itemAID: 20,
  2794. }, {
  2795. age: 7,
  2796. group: this.groups[1],
  2797. name: "castle wall",
  2798. desc: "provides powerful protection for your village",
  2799. req: ["stone", 35],
  2800. health: 1500,
  2801. scale: 52,
  2802. holdOffset: 20,
  2803. placeOffset: -5,
  2804. itemID: 5,
  2805. itemAID: 21,
  2806. }, {
  2807. group: this.groups[2],
  2808. name: "spikes",
  2809. desc: "damages enemies when they touch them",
  2810. req: ["wood", 20, "stone", 5],
  2811. health: 400,
  2812. dmg: 20,
  2813. scale: 49,
  2814. spritePadding: -23,
  2815. holdOffset: 8,
  2816. placeOffset: -5,
  2817. itemID: 6,
  2818. itemAID: 22,
  2819. shadow: {
  2820. offsetX: 5, // Adjust the shadow's X offset as needed
  2821. offsetY: 5, // Adjust the shadow's Y offset as needed
  2822. blur: 20, // Adjust the shadow's blur as needed
  2823. color: "rgba(0, 0, 0, 0.0)" // Adjust the shadow's color and transparency as needed
  2824. }
  2825.  
  2826. }, {
  2827. age: 5,
  2828. group: this.groups[2],
  2829. name: "greater spikes",
  2830. desc: "damages enemies when they touch them",
  2831. req: ["wood", 30, "stone", 10],
  2832. health: 500,
  2833. dmg: 35,
  2834. scale: 52,
  2835. spritePadding: -23,
  2836. holdOffset: 8,
  2837. placeOffset: -5,
  2838. itemID: 7,
  2839. itemAID: 23,
  2840. }, {
  2841. age: 9,
  2842. group: this.groups[2],
  2843. name: "poison spikes",
  2844. desc: "poisons enemies when they touch them",
  2845. req: ["wood", 35, "stone", 15],
  2846. health: 600,
  2847. dmg: 30,
  2848. pDmg: 5,
  2849. scale: 52,
  2850. spritePadding: -23,
  2851. holdOffset: 8,
  2852. placeOffset: -5,
  2853. itemID: 8,
  2854. itemAID: 24,
  2855. }, {
  2856. age: 9,
  2857. group: this.groups[2],
  2858. name: "spinning spikes",
  2859. desc: "damages enemies when they touch them",
  2860. req: ["wood", 30, "stone", 20],
  2861. health: 500,
  2862. dmg: 45,
  2863. turnSpeed: 0.003,
  2864. scale: 52,
  2865. spritePadding: -23,
  2866. holdOffset: 8,
  2867. placeOffset: -5,
  2868. itemID: 9,
  2869. itemAID: 25,
  2870. }, {
  2871. group: this.groups[3],
  2872. name: "windmill",
  2873. desc: "generates gold over time",
  2874. req: ["wood", 50, "stone", 10],
  2875. health: 400,
  2876. pps: 1,
  2877. turnSpeed: 0.0016,
  2878. spritePadding: 25,
  2879. iconLineMult: 12,
  2880. scale: 45,
  2881. holdOffset: 20,
  2882. placeOffset: 5,
  2883. itemID: 10,
  2884. itemAID: 26,
  2885. }, {
  2886. age: 5,
  2887. group: this.groups[3],
  2888. name: "faster windmill",
  2889. desc: "generates more gold over time",
  2890. req: ["wood", 60, "stone", 20],
  2891. health: 500,
  2892. pps: 1.5,
  2893. turnSpeed: 0.0025,
  2894. spritePadding: 25,
  2895. iconLineMult: 12,
  2896. scale: 47,
  2897. holdOffset: 20,
  2898. placeOffset: 5,
  2899. itemID: 11,
  2900. itemAID: 27,
  2901. }, {
  2902. age: 8,
  2903. group: this.groups[3],
  2904. name: "power mill",
  2905. desc: "generates more gold over time",
  2906. req: ["wood", 100, "stone", 50],
  2907. health: 800,
  2908. pps: 2,
  2909. turnSpeed: 0.005,
  2910. spritePadding: 25,
  2911. iconLineMult: 12,
  2912. scale: 47,
  2913. holdOffset: 20,
  2914. placeOffset: 5,
  2915. itemID: 12,
  2916. itemAID: 28,
  2917. }, {
  2918. age: 5,
  2919. group: this.groups[4],
  2920. type: 2,
  2921. name: "mine",
  2922. desc: "allows you to mine stone",
  2923. req: ["wood", 20, "stone", 100],
  2924. iconLineMult: 12,
  2925. scale: 65,
  2926. holdOffset: 20,
  2927. placeOffset: 0,
  2928. itemID: 13,
  2929. itemAID: 29,
  2930. }, {
  2931. age: 5,
  2932. group: this.groups[11],
  2933. type: 0,
  2934. name: "sapling",
  2935. desc: "allows you to farm wood",
  2936. req: ["wood", 150],
  2937. iconLineMult: 12,
  2938. colDiv: 0.5,
  2939. scale: 110,
  2940. holdOffset: 50,
  2941. placeOffset: -15,
  2942. itemID: 14,
  2943. itemAID: 30,
  2944. }, {
  2945. age: 4,
  2946. group: this.groups[5],
  2947. name: "pit trap",
  2948. desc: "pit that traps enemies if they walk over it",
  2949. req: ["wood", 30, "stone", 30],
  2950. trap: true,
  2951. ignoreCollision: true,
  2952. hideFromEnemy: true,
  2953. health: 500,
  2954. colDiv: 0.2,
  2955. scale: 50,
  2956. holdOffset: 20,
  2957. placeOffset: -5,
  2958. alpha: 0.6,
  2959. itemID: 15,
  2960. itemAID: 31,
  2961. }, {
  2962. age: 4,
  2963. group: this.groups[6],
  2964. name: "boost pad",
  2965. desc: "provides boost when stepped on",
  2966. req: ["stone", 20, "wood", 5],
  2967. ignoreCollision: true,
  2968. boostSpeed: 1.5,
  2969. health: 150,
  2970. colDiv: 0.7,
  2971. scale: 45,
  2972. holdOffset: 20,
  2973. placeOffset: -5,
  2974. itemID:
  2975. 16,
  2976. itemAID: 32,
  2977. }, {
  2978. age: 7,
  2979. group: this.groups[7],
  2980. doUpdate: true,
  2981. name: "turret",
  2982. desc: "defensive structure that shoots at enemies",
  2983. req: ["wood", 200, "stone", 150],
  2984. health: 800,
  2985. projectile: 1,
  2986. shootRange: 700,
  2987. shootRate: 2200,
  2988. scale: 43,
  2989. holdOffset: 20,
  2990. placeOffset: -5,
  2991. itemID: 17,
  2992. itemAID: 33,
  2993. }, {
  2994. age: 7,
  2995. group: this.groups[8],
  2996. name: "platform",
  2997. desc: "platform to shoot over walls and cross over water",
  2998. req: ["wood", 20],
  2999. ignoreCollision: true,
  3000. zIndex: 1,
  3001. health: 300,
  3002. scale: 43,
  3003. holdOffset: 20,
  3004. placeOffset: -5,
  3005. itemID: 18,
  3006. itemAID: 34,
  3007. }, {
  3008. age: 7,
  3009. group: this.groups[9],
  3010. name: "healing pad",
  3011. desc: "standing on it will slowly heal you",
  3012. req: ["wood", 30, "food", 10],
  3013. ignoreCollision: true,
  3014. healCol: 15,
  3015. health: 400,
  3016. colDiv: 0.7,
  3017. scale: 45,
  3018. holdOffset: 20,
  3019. placeOffset: -5,
  3020. itemID: 19,
  3021. itemAID: 35,
  3022. }, {
  3023. age: 9,
  3024. group: this.groups[10],
  3025. name: "spawn pad",
  3026. desc: "you will spawn here when you die but it will dissapear",
  3027. req: ["wood", 100, "stone", 100],
  3028. health: 400,
  3029. ignoreCollision: true,
  3030. spawnPoint: true,
  3031. scale: 45,
  3032. holdOffset: 20,
  3033. placeOffset: -5,
  3034. itemID: 20,
  3035. itemAID: 36,
  3036. }, {
  3037. age: 7,
  3038. group: this.groups[12],
  3039. name: "blocker",
  3040. desc: "blocks building in radius",
  3041. req: ["wood", 30, "stone", 25],
  3042. ignoreCollision: true,
  3043. blocker: 300,
  3044. health: 400,
  3045. colDiv: 0.7,
  3046. scale: 45,
  3047. holdOffset: 20,
  3048. placeOffset: -5,
  3049. itemID: 21,
  3050. itemAID: 37,
  3051. }, {
  3052. age: 7,
  3053. group: this.groups[13],
  3054. name: "teleporter",
  3055. desc: "teleports you to a random point on the map",
  3056. req: ["wood", 60, "stone", 60],
  3057. ignoreCollision: true,
  3058. teleport: true,
  3059. health: 200,
  3060. colDiv: 0.7,
  3061. scale: 45,
  3062. holdOffset: 20,
  3063. placeOffset: -5,
  3064. itemID: 22,
  3065. itemAID: 38
  3066. }];
  3067.  
  3068. // CHECK ITEM ID:
  3069. this.checkItem = {
  3070. index: function(id, myItems) {
  3071. 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 :
  3072. 5 :
  3073. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3074. 6 :
  3075. undefined;
  3076. }
  3077. }
  3078.  
  3079. // ASSIGN IDS:
  3080. for (let i = 0; i < this.list.length; ++i) {
  3081. this.list[i].id = i;
  3082. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3083. }
  3084.  
  3085. // TROLOLOLOL:
  3086. if (typeof window !== "undefined") {
  3087. function shuffle(a) {
  3088. for (let i = a.length - 1; i > 0; i--) {
  3089. const j = Math.floor(Math.random() * (i + 1));
  3090. [a[i], a[j]] = [a[j], a[i]];
  3091. }
  3092. return a;
  3093. }
  3094. //shuffle(this.list);
  3095. }
  3096. }
  3097. }
  3098. class Objectmanager {
  3099. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3100. let mathFloor = Math.floor,
  3101. mathABS = Math.abs,
  3102. mathCOS = Math.cos,
  3103. mathSIN = Math.sin,
  3104. mathPOW = Math.pow,
  3105. mathSQRT = Math.sqrt;
  3106.  
  3107. this.ignoreAdd = false;
  3108. this.hitObj = [];
  3109.  
  3110. // DISABLE OBJ:
  3111. this.disableObj = function(obj) {
  3112. obj.active = false;
  3113. };
  3114.  
  3115. // ADD NEW:
  3116. let tmpObj;
  3117. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3118. tmpObj = findObjectBySid(sid);
  3119. if (!tmpObj) {
  3120. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3121. if (!tmpObj) {
  3122. tmpObj = new GameObject(sid);
  3123. gameObjects.push(tmpObj);
  3124. }
  3125. }
  3126. if (setSID) {
  3127. tmpObj.sid = sid;
  3128. }
  3129. tmpObj.init(x, y, dir, s, type, data, owner);
  3130. };
  3131.  
  3132. // DISABLE BY SID:
  3133. this.disableBySid = function(sid) {
  3134. let find = findObjectBySid(sid);
  3135. if (find) {
  3136. this.disableObj(find);
  3137. }
  3138. };
  3139.  
  3140. // REMOVE ALL FROM PLAYER:
  3141. this.removeAllItems = function(sid, server) {
  3142. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3143. };
  3144.  
  3145. // CHECK IF PLACABLE:
  3146. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3147. 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)));
  3148. if (cantPlace) return false;
  3149. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3150. return true;
  3151. };
  3152.  
  3153. }
  3154. }
  3155. class Projectile {
  3156. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3157.  
  3158. // INIT:
  3159. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3160. this.active = true;
  3161. this.tickActive = true;
  3162. this.indx = indx;
  3163. this.x = x;
  3164. this.y = y;
  3165. this.x2 = x;
  3166. this.y2 = y;
  3167. this.dir = dir;
  3168. this.skipMov = true;
  3169. this.speed = spd;
  3170. this.dmg = dmg;
  3171. this.scale = scl;
  3172. this.range = rng;
  3173. this.r2 = rng;
  3174. this.owner = owner;
  3175. };
  3176.  
  3177. // UPDATE:
  3178. this.update = function(delta) {
  3179. if (this.active) {
  3180. let tmpSpeed = this.speed * delta;
  3181. if (!this.skipMov) {
  3182. this.x += tmpSpeed * Math.cos(this.dir);
  3183. this.y += tmpSpeed * Math.sin(this.dir);
  3184. this.range -= tmpSpeed;
  3185. if (this.range <= 0) {
  3186. this.x += this.range * Math.cos(this.dir);
  3187. this.y += this.range * Math.sin(this.dir);
  3188. tmpSpeed = 1;
  3189. this.range = 0;
  3190. this.active = false;
  3191. }
  3192. } else {
  3193. this.skipMov = false;
  3194. }
  3195. }
  3196. };
  3197. this.tickUpdate = function(delta) {
  3198. if (this.tickActive) {
  3199. let tmpSpeed = this.speed * delta;
  3200. if (!this.skipMov) {
  3201. this.x2 += tmpSpeed * Math.cos(this.dir);
  3202. this.y2 += tmpSpeed * Math.sin(this.dir);
  3203. this.r2 -= tmpSpeed;
  3204. if (this.r2 <= 0) {
  3205. this.x2 += this.r2 * Math.cos(this.dir);
  3206. this.y2 += this.r2 * Math.sin(this.dir);
  3207. tmpSpeed = 1;
  3208. this.r2 = 0;
  3209. this.tickActive = false;
  3210. }
  3211. } else {
  3212. this.skipMov = false;
  3213. }
  3214. }
  3215. };
  3216. }
  3217. };
  3218. class Store {
  3219. constructor() {
  3220. // STORE HATS:
  3221. this.hats = [{
  3222. id: 45,
  3223. name: "Shame!",
  3224. dontSell: true,
  3225. price: 0,
  3226. scale: 120,
  3227. desc: "hacks are for winners"
  3228. }, {
  3229. id: 51,
  3230. name: "Moo Cap",
  3231. price: 0,
  3232. scale: 120,
  3233. desc: "coolest mooer around"
  3234. }, {
  3235. id: 50,
  3236. name: "Apple Cap",
  3237. price: 0,
  3238. scale: 120,
  3239. desc: "apple farms remembers"
  3240. }, {
  3241. id: 28,
  3242. name: "Moo Head",
  3243. price: 0,
  3244. scale: 120,
  3245. desc: "no effect"
  3246. }, {
  3247. id: 29,
  3248. name: "Pig Head",
  3249. price: 0,
  3250. scale: 120,
  3251. desc: "no effect"
  3252. }, {
  3253. id: 30,
  3254. name: "Fluff Head",
  3255. price: 0,
  3256. scale: 120,
  3257. desc: "no effect"
  3258. }, {
  3259. id: 36,
  3260. name: "Pandou Head",
  3261. price: 0,
  3262. scale: 120,
  3263. desc: "no effect"
  3264. }, {
  3265. id: 37,
  3266. name: "Bear Head",
  3267. price: 0,
  3268. scale: 120,
  3269. desc: "no effect"
  3270. }, {
  3271. id: 38,
  3272. name: "Monkey Head",
  3273. price: 0,
  3274. scale: 120,
  3275. desc: "no effect"
  3276. }, {
  3277. id: 44,
  3278. name: "Polar Head",
  3279. price: 0,
  3280. scale: 120,
  3281. desc: "no effect"
  3282. }, {
  3283. id: 35,
  3284. name: "Fez Hat",
  3285. price: 0,
  3286. scale: 120,
  3287. desc: "no effect"
  3288. }, {
  3289. id: 42,
  3290. name: "Enigma Hat",
  3291. price: 0,
  3292. scale: 120,
  3293. desc: "join the enigma army"
  3294. }, {
  3295. id: 43,
  3296. name: "Blitz Hat",
  3297. price: 0,
  3298. scale: 120,
  3299. desc: "hey everybody i'm blitz"
  3300. }, {
  3301. id: 49,
  3302. name: "Bob XIII Hat",
  3303. price: 0,
  3304. scale: 120,
  3305. desc: "like and subscribe"
  3306. }, {
  3307. id: 57,
  3308. name: "Pumpkin",
  3309. price: 50,
  3310. scale: 120,
  3311. desc: "Spooooky"
  3312. }, {
  3313. id: 8,
  3314. name: "Bummle Hat",
  3315. price: 100,
  3316. scale: 120,
  3317. desc: "no effect"
  3318. }, {
  3319. id: 2,
  3320. name: "Straw Hat",
  3321. price: 500,
  3322. scale: 120,
  3323. desc: "no effect"
  3324. }, {
  3325. id: 15,
  3326. name: "Winter Cap",
  3327. price: 600,
  3328. scale: 120,
  3329. desc: "allows you to move at normal speed in snow",
  3330. coldM: 1
  3331. }, {
  3332. id: 5,
  3333. name: "Cowboy Hat",
  3334. price: 1000,
  3335. scale: 120,
  3336. desc: "no effect"
  3337. }, {
  3338. id: 4,
  3339. name: "Ranger Hat",
  3340. price: 2000,
  3341. scale: 120,
  3342. desc: "no effect"
  3343. }, {
  3344. id: 18,
  3345. name: "Explorer Hat",
  3346. price: 2000,
  3347. scale: 120,
  3348. desc: "no effect"
  3349. }, {
  3350. id: 31,
  3351. name: "Flipper Hat",
  3352. price: 2500,
  3353. scale: 120,
  3354. desc: "have more control while in water",
  3355. watrImm: true
  3356. }, {
  3357. id: 1,
  3358. name: "Marksman Cap",
  3359. price: 3000,
  3360. scale: 120,
  3361. desc: "increases arrow speed and range",
  3362. aMlt: 1.3
  3363. }, {
  3364. id: 10,
  3365. name: "Bush Gear",
  3366. price: 3000,
  3367. scale: 160,
  3368. desc: "allows you to disguise yourself as a bush"
  3369. }, {
  3370. id: 48,
  3371. name: "Halo",
  3372. price: 3000,
  3373. scale: 120,
  3374. desc: "no effect"
  3375. }, {
  3376. id: 6,
  3377. name: "Soldier Helmet",
  3378. price: 4000,
  3379. scale: 120,
  3380. desc: "reduces damage taken but slows movement",
  3381. spdMult: 0.94,
  3382. dmgMult: 0.75
  3383. }, {
  3384. id: 23,
  3385. name: "Anti Venom Gear",
  3386. price: 4000,
  3387. scale: 120,
  3388. desc: "makes you immune to poison",
  3389. poisonRes: 1
  3390. }, {
  3391. id: 13,
  3392. name: "Medic Gear",
  3393. price: 5000,
  3394. scale: 110,
  3395. desc: "slowly regenerates health over time",
  3396. healthRegen: 3
  3397. }, {
  3398. id: 9,
  3399. name: "Miners Helmet",
  3400. price: 5000,
  3401. scale: 120,
  3402. desc: "earn 1 extra gold per resource",
  3403. extraGold: 1
  3404. }, {
  3405. id: 32,
  3406. name: "Musketeer Hat",
  3407. price: 5000,
  3408. scale: 120,
  3409. desc: "reduces cost of projectiles",
  3410. projCost: 0.5
  3411. }, {
  3412. id: 7,
  3413. name: "Bull Helmet",
  3414. price: 6000,
  3415. scale: 120,
  3416. desc: "increases damage done but drains health",
  3417. healthRegen: -5,
  3418. dmgMultO: 1.5,
  3419. spdMult: 0.96
  3420. }, {
  3421. id: 22,
  3422. name: "Emp Helmet",
  3423. price: 6000,
  3424. scale: 120,
  3425. desc: "turrets won't attack but you move slower",
  3426. antiTurret: 1,
  3427. spdMult: 0.7
  3428. }, {
  3429. id: 12,
  3430. name: "Booster Hat",
  3431. price: 6000,
  3432. scale: 120,
  3433. desc: "increases your movement speed",
  3434. spdMult: 1.16
  3435. }, {
  3436. id: 26,
  3437. name: "Barbarian Armor",
  3438. price: 8000,
  3439. scale: 120,
  3440. desc: "knocks back enemies that attack you",
  3441. dmgK: 0.6
  3442. }, {
  3443. id: 21,
  3444. name: "Plague Mask",
  3445. price: 10000,
  3446. scale: 120,
  3447. desc: "melee attacks deal poison damage",
  3448. poisonDmg: 5,
  3449. poisonTime: 6
  3450. }, {
  3451. id: 46,
  3452. name: "Bull Mask",
  3453. price: 10000,
  3454. scale: 120,
  3455. desc: "bulls won't target you unless you attack them",
  3456. bullRepel: 1
  3457. }, {
  3458. id: 14,
  3459. name: "Windmill Hat",
  3460. topSprite: true,
  3461. price: 10000,
  3462. scale: 120,
  3463. desc: "generates points while worn",
  3464. pps: 1.5
  3465. }, {
  3466. id: 11,
  3467. name: "Spike Gear",
  3468. topSprite: true,
  3469. price: 10000,
  3470. scale: 120,
  3471. desc: "deal damage to players that damage you",
  3472. dmg: 0.45
  3473. }, {
  3474. id: 53,
  3475. name: "Turret Gear",
  3476. topSprite: true,
  3477. price: 10000,
  3478. scale: 120,
  3479. desc: "you become a walking turret",
  3480. turret: {
  3481. proj: 1,
  3482. range: 700,
  3483. rate: 2500
  3484. },
  3485. spdMult: 0.7
  3486. }, {
  3487. id: 20,
  3488. name: "Samurai Armor",
  3489. price: 12000,
  3490. scale: 120,
  3491. desc: "increased attack speed and fire rate",
  3492. atkSpd: 0.78
  3493. }, {
  3494. id: 58,
  3495. name: "Dark Knight",
  3496. price: 12000,
  3497. scale: 120,
  3498. desc: "restores health when you deal damage",
  3499. healD: 0.4
  3500. }, {
  3501. id: 27,
  3502. name: "Scavenger Gear",
  3503. price: 15000,
  3504. scale: 120,
  3505. desc: "earn double points for each kill",
  3506. kScrM: 2
  3507. }, {
  3508. id: 40,
  3509. name: "Tank Gear",
  3510. price: 15000,
  3511. scale: 120,
  3512. desc: "increased damage to buildings but slower movement",
  3513. spdMult: 0.3,
  3514. bDmg: 3.3
  3515. }, {
  3516. id: 52,
  3517. name: "Thief Gear",
  3518. price: 15000,
  3519. scale: 120,
  3520. desc: "steal half of a players gold when you kill them",
  3521. goldSteal: 0.5
  3522. }, {
  3523. id: 55,
  3524. name: "Bloodthirster",
  3525. price: 20000,
  3526. scale: 120,
  3527. desc: "Restore Health when dealing damage. And increased damage",
  3528. healD: 0.25,
  3529. dmgMultO: 1.2,
  3530. }, {
  3531. id: 56,
  3532. name: "Assassin Gear",
  3533. price: 20000,
  3534. scale: 120,
  3535. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3536. noEat: true,
  3537. spdMult: 1.1,
  3538. invisTimer: 1000
  3539. }];
  3540.  
  3541. // STORE ACCESSORIES:
  3542. this.accessories = [{
  3543. id: 12,
  3544. name: "Snowball",
  3545. price: 1000,
  3546. scale: 105,
  3547. xOff: 18,
  3548. desc: "no effect"
  3549. }, {
  3550. id: 9,
  3551. name: "Tree Cape",
  3552. price: 1000,
  3553. scale: 90,
  3554. desc: "no effect"
  3555. }, {
  3556. id: 10,
  3557. name: "Stone Cape",
  3558. price: 1000,
  3559. scale: 90,
  3560. desc: "no effect"
  3561. }, {
  3562. id: 3,
  3563. name: "Cookie Cape",
  3564. price: 1500,
  3565. scale: 90,
  3566. desc: "no effect"
  3567. }, {
  3568. id: 8,
  3569. name: "Cow Cape",
  3570. price: 2000,
  3571. scale: 90,
  3572. desc: "no effect"
  3573. }, {
  3574. id: 11,
  3575. name: "Monkey Tail",
  3576. price: 2000,
  3577. scale: 97,
  3578. xOff: 25,
  3579. desc: "Super speed but reduced damage",
  3580. spdMult: 1.35,
  3581. dmgMultO: 0.2
  3582. }, {
  3583. id: 17,
  3584. name: "Apple Basket",
  3585. price: 3000,
  3586. scale: 80,
  3587. xOff: 12,
  3588. desc: "slowly regenerates health over time",
  3589. healthRegen: 1
  3590. }, {
  3591. id: 6,
  3592. name: "Winter Cape",
  3593. price: 3000,
  3594. scale: 90,
  3595. desc: "no effect"
  3596. }, {
  3597. id: 4,
  3598. name: "Skull Cape",
  3599. price: 4000,
  3600. scale: 90,
  3601. desc: "no effect"
  3602. }, {
  3603. id: 5,
  3604. name: "Dash Cape",
  3605. price: 5000,
  3606. scale: 90,
  3607. desc: "no effect"
  3608. }, {
  3609. id: 2,
  3610. name: "Dragon Cape",
  3611. price: 6000,
  3612. scale: 90,
  3613. desc: "no effect"
  3614. }, {
  3615. id: 1,
  3616. name: "Super Cape",
  3617. price: 8000,
  3618. scale: 90,
  3619. desc: "no effect"
  3620. }, {
  3621. id: 7,
  3622. name: "Troll Cape",
  3623. price: 8000,
  3624. scale: 90,
  3625. desc: "no effect"
  3626. }, {
  3627. id: 14,
  3628. name: "Thorns",
  3629. price: 10000,
  3630. scale: 115,
  3631. xOff: 20,
  3632. desc: "no effect"
  3633. }, {
  3634. id: 15,
  3635. name: "Blockades",
  3636. price: 10000,
  3637. scale: 95,
  3638. xOff: 15,
  3639. desc: "no effect"
  3640. }, {
  3641. id: 20,
  3642. name: "Devils Tail",
  3643. price: 10000,
  3644. scale: 95,
  3645. xOff: 20,
  3646. desc: "no effect"
  3647. }, {
  3648. id: 16,
  3649. name: "Sawblade",
  3650. price: 12000,
  3651. scale: 90,
  3652. spin: true,
  3653. xOff: 0,
  3654. desc: "deal damage to players that damage you",
  3655. dmg: 0.15
  3656. }, {
  3657. id: 13,
  3658. name: "Angel Wings",
  3659. price: 15000,
  3660. scale: 138,
  3661. xOff: 22,
  3662. desc: "slowly regenerates health over time",
  3663. healthRegen: 3
  3664. }, {
  3665. id: 19,
  3666. name: "Shadow Wings",
  3667. price: 15000,
  3668. scale: 138,
  3669. xOff: 22,
  3670. desc: "increased movement speed",
  3671. spdMult: 1.1
  3672. }, {
  3673. id: 18,
  3674. name: "Blood Wings",
  3675. price: 20000,
  3676. scale: 178,
  3677. xOff: 26,
  3678. desc: "restores health when you deal damage",
  3679. healD: 0.2
  3680. }, {
  3681. id: 21,
  3682. name: "Corrupt X Wings",
  3683. price: 20000,
  3684. scale: 178,
  3685. xOff: 26,
  3686. desc: "deal damage to players that damage you",
  3687. dmg: 0.25
  3688. }];
  3689. }
  3690. };
  3691. class ProjectileManager {
  3692. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3693. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3694. let tmpData = items.projectiles[indx];
  3695. let tmpProj;
  3696. for (let i = 0; i < projectiles.length; ++i) {
  3697. if (!projectiles[i].active) {
  3698. tmpProj = projectiles[i];
  3699. break;
  3700. }
  3701. }
  3702. if (!tmpProj) {
  3703. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3704. tmpProj.sid = projectiles.length;
  3705. projectiles.push(tmpProj);
  3706. }
  3707. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3708. tmpProj.ignoreObj = ignoreObj;
  3709. tmpProj.layer = layer || tmpData.layer;
  3710. tmpProj.inWindow = inWindow;
  3711. tmpProj.src = tmpData.src;
  3712. return tmpProj;
  3713. };
  3714. }
  3715. };
  3716. class AiManager {
  3717.  
  3718. // AI MANAGER:
  3719. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3720.  
  3721. // AI TYPES:
  3722. this.aiTypes = [{
  3723. id: 0,
  3724. src: "cow_1",
  3725. killScore: 150,
  3726. health: 500,
  3727. weightM: 0.8,
  3728. speed: 0.00095,
  3729. turnSpeed: 0.001,
  3730. scale: 72,
  3731. drop: ["food", 50]
  3732. }, {
  3733. id: 1,
  3734. src: "pig_1",
  3735. killScore: 200,
  3736. health: 800,
  3737. weightM: 0.6,
  3738. speed: 0.00085,
  3739. turnSpeed: 0.001,
  3740. scale: 72,
  3741. drop: ["food", 80]
  3742. }, {
  3743. id: 2,
  3744. name: "Bull",
  3745. src: "bull_2",
  3746. hostile: true,
  3747. dmg: 20,
  3748. killScore: 1000,
  3749. health: 1800,
  3750. weightM: 0.5,
  3751. speed: 0.00094,
  3752. turnSpeed: 0.00074,
  3753. scale: 78,
  3754. viewRange: 800,
  3755. chargePlayer: true,
  3756. drop: ["food", 100]
  3757. }, {
  3758. id: 3,
  3759. name: "Bully",
  3760. src: "bull_1",
  3761. hostile: true,
  3762. dmg: 20,
  3763. killScore: 2000,
  3764. health: 2800,
  3765. weightM: 0.45,
  3766. speed: 0.001,
  3767. turnSpeed: 0.0008,
  3768. scale: 90,
  3769. viewRange: 900,
  3770. chargePlayer: true,
  3771. drop: ["food", 400]
  3772. }, {
  3773. id: 4,
  3774. name: "Wolf",
  3775. src: "wolf_1",
  3776. hostile: true,
  3777. dmg: 8,
  3778. killScore: 500,
  3779. health: 300,
  3780. weightM: 0.45,
  3781. speed: 0.001,
  3782. turnSpeed: 0.002,
  3783. scale: 84,
  3784. viewRange: 800,
  3785. chargePlayer: true,
  3786. drop: ["food", 200]
  3787. }, {
  3788. id: 5,
  3789. name: "Quack",
  3790. src: "chicken_1",
  3791. dmg: 8,
  3792. killScore: 2000,
  3793. noTrap: true,
  3794. health: 300,
  3795. weightM: 0.2,
  3796. speed: 0.0018,
  3797. turnSpeed: 0.006,
  3798. scale: 70,
  3799. drop: ["food", 100]
  3800. }, {
  3801. id: 6,
  3802. name: "MOOSTAFA",
  3803. nameScale: 50,
  3804. src: "enemy",
  3805. hostile: true,
  3806. dontRun: true,
  3807. fixedSpawn: true,
  3808. spawnDelay: 60000,
  3809. noTrap: true,
  3810. colDmg: 100,
  3811. dmg: 40,
  3812. killScore: 8000,
  3813. health: 18000,
  3814. weightM: 0.4,
  3815. speed: 0.0007,
  3816. turnSpeed: 0.01,
  3817. scale: 80,
  3818. spriteMlt: 1.8,
  3819. leapForce: 0.9,
  3820. viewRange: 1000,
  3821. hitRange: 210,
  3822. hitDelay: 1000,
  3823. chargePlayer: true,
  3824. drop: ["food", 100]
  3825. }, {
  3826. id: 7,
  3827. name: "Treasure",
  3828. hostile: true,
  3829. nameScale: 35,
  3830. src: "crate_1",
  3831. fixedSpawn: true,
  3832. spawnDelay: 120000,
  3833. colDmg: 200,
  3834. killScore: 5000,
  3835. health: 20000,
  3836. weightM: 0.1,
  3837. speed: 0.0,
  3838. turnSpeed: 0.0,
  3839. scale: 70,
  3840. spriteMlt: 1.0
  3841. }, {
  3842. id: 8,
  3843. name: "MOOFIE",
  3844. src: "wolf_2",
  3845. hostile: true,
  3846. fixedSpawn: true,
  3847. dontRun: true,
  3848. hitScare: 4,
  3849. spawnDelay: 30000,
  3850. noTrap: true,
  3851. nameScale: 35,
  3852. dmg: 10,
  3853. colDmg: 100,
  3854. killScore: 3000,
  3855. health: 7000,
  3856. weightM: 0.45,
  3857. speed: 0.0015,
  3858. turnSpeed: 0.002,
  3859. scale: 90,
  3860. viewRange: 800,
  3861. chargePlayer: true,
  3862. drop: ["food", 1000]
  3863. }];
  3864.  
  3865. // SPAWN AI:
  3866. this.spawn = function(x, y, dir, index) {
  3867. let tmpObj = ais.find((tmp) => !tmp.active);
  3868. if (!tmpObj) {
  3869. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3870. ais.push(tmpObj);
  3871. }
  3872. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3873. return tmpObj;
  3874. };
  3875. }
  3876.  
  3877. };
  3878. class AI {
  3879. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3880. this.sid = sid;
  3881. this.isAI = true;
  3882. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3883.  
  3884. // INIT:
  3885. this.init = function(x, y, dir, index, data) {
  3886. this.x = x;
  3887. this.y = y;
  3888. this.startX = data.fixedSpawn ? x : null;
  3889. this.startY = data.fixedSpawn ? y : null;
  3890. this.xVel = 0;
  3891. this.yVel = 0;
  3892. this.zIndex = 0;
  3893. this.dir = dir;
  3894. this.dirPlus = 0;
  3895. this.showName = 'aaa';
  3896. this.index = index;
  3897. this.src = data.src;
  3898. if (data.name) this.name = data.name;
  3899. this.weightM = data.weightM;
  3900. this.speed = data.speed;
  3901. this.killScore = data.killScore;
  3902. this.turnSpeed = data.turnSpeed;
  3903. this.scale = data.scale;
  3904. this.maxHealth = data.health;
  3905. this.leapForce = data.leapForce;
  3906. this.health = this.maxHealth;
  3907. this.chargePlayer = data.chargePlayer;
  3908. this.viewRange = data.viewRange;
  3909. this.drop = data.drop;
  3910. this.dmg = data.dmg;
  3911. this.hostile = data.hostile;
  3912. this.dontRun = data.dontRun;
  3913. this.hitRange = data.hitRange;
  3914. this.hitDelay = data.hitDelay;
  3915. this.hitScare = data.hitScare;
  3916. this.spriteMlt = data.spriteMlt;
  3917. this.nameScale = data.nameScale;
  3918. this.colDmg = data.colDmg;
  3919. this.noTrap = data.noTrap;
  3920. this.spawnDelay = data.spawnDelay;
  3921. this.hitWait = 0;
  3922. this.waitCount = 1000;
  3923. this.moveCount = 0;
  3924. this.targetDir = 0;
  3925. this.active = true;
  3926. this.alive = true;
  3927. this.runFrom = null;
  3928. this.chargeTarget = null;
  3929. this.dmgOverTime = {};
  3930. };
  3931.  
  3932. let tmpRatio = 0;
  3933. let animIndex = 0;
  3934. this.animate = function(delta) {
  3935. if (this.animTime > 0) {
  3936. this.animTime -= delta;
  3937. if (this.animTime <= 0) {
  3938. this.animTime = 0;
  3939. this.dirPlus = 0;
  3940. tmpRatio = 0;
  3941. animIndex = 0;
  3942. } else {
  3943. if (animIndex == 0) {
  3944. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3945. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3946. if (tmpRatio >= 1) {
  3947. tmpRatio = 1;
  3948. animIndex = 1;
  3949. }
  3950. } else {
  3951. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3952. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3953. }
  3954. }
  3955. }
  3956. };
  3957.  
  3958. // ANIMATION:
  3959. this.startAnim = function() {
  3960. this.animTime = this.animSpeed = 600;
  3961. this.targetAngle = Math.PI * 0.8;
  3962. tmpRatio = 0;
  3963. animIndex = 0;
  3964. };
  3965.  
  3966. };
  3967.  
  3968. };
  3969. class addCh {
  3970. constructor(x, y, chat, tmpObj) {
  3971. this.x = x;
  3972. this.y = y;
  3973. this.alpha = 0;
  3974. this.active = true;
  3975. this.alive = false;
  3976. this.chat = chat;
  3977. this.owner = tmpObj;
  3978. };
  3979. };
  3980. class DeadPlayer {
  3981. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3982. this.x = x;
  3983. this.y = y;
  3984. this.lastDir = dir;
  3985. this.dir = dir + Math.PI;
  3986. this.buildIndex = buildIndex;
  3987. this.weaponIndex = weaponIndex;
  3988. this.weaponVariant = weaponVariant;
  3989. this.skinColor = skinColor;
  3990. this.scale = scale;
  3991. this.visScale = 0;
  3992. this.name = name;
  3993. this.alpha = 1;
  3994. this.active = true;
  3995. this.animate = function(delta) {
  3996. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3997. if (d2 > 0.01) {
  3998. this.dir += d2 / 20;
  3999. } else {
  4000. this.dir = this.lastDir;
  4001. }
  4002. if (this.visScale < this.scale) {
  4003. this.visScale += delta / (this.scale / 2);
  4004. if (this.visScale >= this.scale) {
  4005. this.visScale = this.scale;
  4006. }
  4007. }
  4008. this.alpha -= delta / 30000;
  4009. if (this.alpha <= 0) {
  4010. this.alpha = 0;
  4011. this.active = false;
  4012. }
  4013. }
  4014. }
  4015. };
  4016. class Player {
  4017. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4018. this.id = id;
  4019. this.sid = sid;
  4020. this.tmpScore = 0;
  4021. this.team = null;
  4022. this.latestSkin = 0;
  4023. this.oldSkinIndex = 0;
  4024. this.skinIndex = 0;
  4025. this.latestTail = 0;
  4026. this.oldTailIndex = 0;
  4027. this.tailIndex = 0;
  4028. this.hitTime = 0;
  4029. this.lastHit = 0;
  4030. this.showName = 'NOOO';
  4031. this.tails = {};
  4032. for (let i = 0; i < accessories.length; ++i) {
  4033. if (accessories[i].price <= 0)
  4034. this.tails[accessories[i].id] = 1;
  4035. }
  4036. this.skins = {};
  4037. for (let i = 0; i < hats.length; ++i) {
  4038. if (hats[i].price <= 0)
  4039. this.skins[hats[i].id] = 1;
  4040. }
  4041. this.points = 0;
  4042. this.dt = 0;
  4043. this.hidden = false;
  4044. this.itemCounts = {};
  4045. this.isPlayer = true;
  4046. this.pps = 0;
  4047. this.moveDir = undefined;
  4048. this.skinRot = 0;
  4049. this.lastPing = 0;
  4050. this.iconIndex = 0;
  4051. this.skinColor = 0;
  4052. this.dist2 = 0;
  4053. this.aim2 = 0;
  4054. this.maxSpeed = 1;
  4055. this.chat = {
  4056. message: null,
  4057. count: 0
  4058. };
  4059. this.backupNobull = true;
  4060. this.circle = false;
  4061. this.circleRad = 200;
  4062. this.circleRadSpd = 0.1;
  4063. this.cAngle = 0;
  4064. // SPAWN:
  4065. this.spawn = function(moofoll) {
  4066. this.attacked = false;
  4067. this.timeDamaged = 0;
  4068. this.timeHealed = 0;
  4069. this.pinge = 0;
  4070. this.millPlace = 'NOOO';
  4071. this.lastshamecount = 0;
  4072. this.death = false;
  4073. this.spinDir = 0;
  4074. this.sync = false;
  4075. this.antiBull = 0;
  4076. this.bullTimer = 0;
  4077. this.poisonTimer = 0;
  4078. this.active = true;
  4079. this.alive = true;
  4080. this.lockMove = false;
  4081. this.lockDir = false;
  4082. this.minimapCounter = 0;
  4083. this.chatCountdown = 0;
  4084. this.shameCount = 0;
  4085. this.shameTimer = 0;
  4086. this.sentTo = {};
  4087. this.gathering = 0;
  4088. this.gatherIndex = 0;
  4089. this.shooting = {};
  4090. this.shootIndex = 9;
  4091. this.autoGather = 0;
  4092. this.animTime = 0;
  4093. this.animSpeed = 0;
  4094. this.mouseState = 0;
  4095. this.buildIndex = -1;
  4096. this.weaponIndex = 0;
  4097. this.weaponCode = 0;
  4098. this.weaponVariant = 0;
  4099. this.primaryIndex = undefined;
  4100. this.secondaryIndex = undefined;
  4101. this.dmgOverTime = {};
  4102. this.noMovTimer = 0;
  4103. this.maxXP = 300;
  4104. this.XP = 0;
  4105. this.age = 1;
  4106. this.kills = 0;
  4107. this.upgrAge = 2;
  4108. this.upgradePoints = 0;
  4109. this.x = 0;
  4110. this.y = 0;
  4111. this.oldXY = {
  4112. x: 0,
  4113. y: 0
  4114. };
  4115. this.zIndex = 0;
  4116. this.xVel = 0;
  4117. this.yVel = 0;
  4118. this.slowMult = 1;
  4119. this.dir = 0;
  4120. this.dirPlus = 0;
  4121. this.targetDir = 0;
  4122. this.targetAngle = 0;
  4123. this.maxHealth = 100;
  4124. this.health = this.maxHealth;
  4125. this.oldHealth = this.maxHealth;
  4126. this.damaged = 0;
  4127. this.scale = config.playerScale;
  4128. this.speed = config.playerSpeed;
  4129. this.resetMoveDir();
  4130. this.resetResources(moofoll);
  4131. this.items = [0, 3, 6, 10];
  4132. this.weapons = [0];
  4133. this.shootCount = 0;
  4134. this.weaponXP = [];
  4135. this.reloads = {
  4136. 0: 0,
  4137. 1: 0,
  4138. 2: 0,
  4139. 3: 0,
  4140. 4: 0,
  4141. 5: 0,
  4142. 6: 0,
  4143. 7: 0,
  4144. 8: 0,
  4145. 9: 0,
  4146. 10: 0,
  4147. 11: 0,
  4148. 12: 0,
  4149. 13: 0,
  4150. 14: 0,
  4151. 15: 0,
  4152. 53: 0,
  4153. };
  4154. this.bowThreat = {
  4155. 9: 0,
  4156. 12: 0,
  4157. 13: 0,
  4158. 15: 0,
  4159. };
  4160. this.damageThreat = 0;
  4161. this.inTrap = false;
  4162. this.canEmpAnti = false;
  4163. this.empAnti = false;
  4164. this.soldierAnti = false;
  4165. this.poisonTick = 0;
  4166. this.bullTick = 0;
  4167. this.setPoisonTick = false;
  4168. this.setBullTick = false;
  4169. this.antiTimer = 2;
  4170. };
  4171.  
  4172. // RESET MOVE DIR:
  4173. this.resetMoveDir = function() {
  4174. this.moveDir = undefined;
  4175. };
  4176.  
  4177. // RESET RESOURCES:
  4178. this.resetResources = function(moofoll) {
  4179. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4180. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4181. }
  4182. };
  4183.  
  4184. // ADD ITEM:
  4185. this.getItemType = function(id) {
  4186. let findindx = this.items.findIndex((ids) => ids == id);
  4187. if (findindx != -1) {
  4188. return findindx;
  4189. } else {
  4190. return items.checkItem.index(id, this.items);
  4191. }
  4192. };
  4193.  
  4194. // SET DATA:
  4195. this.setData = function(data) {
  4196. this.id = data[0];
  4197. this.sid = data[1];
  4198. this.name = data[2];
  4199. this.x = data[3];
  4200. this.y = data[4];
  4201. this.dir = data[5];
  4202. this.health = data[6];
  4203. this.maxHealth = data[7];
  4204. this.scale = data[8];
  4205. this.skinColor = data[9];
  4206. };
  4207.  
  4208. // UPDATE POISON TICK:
  4209. this.updateTimer = function() {
  4210.  
  4211. this.bullTimer -= 1;
  4212. if (this.bullTimer <= 0) {
  4213. this.setBullTick = false;
  4214. this.bullTick = game.tick - 1;
  4215. this.bullTimer = config.serverUpdateRate;
  4216. }
  4217. this.poisonTimer -= 1;
  4218. if (this.poisonTimer <= 0) {
  4219. this.setPoisonTick = false;
  4220. this.poisonTick = game.tick - 1;
  4221. this.poisonTimer = config.serverUpdateRate;
  4222. }
  4223.  
  4224. };
  4225. this.update = function(delta) {
  4226. if (this.sid == playerSID) {
  4227. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4228. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4229. this.cAngle += this.circleRadSpd;
  4230. }
  4231. if (this.active) {
  4232.  
  4233. // MOVE:
  4234. let gear = {
  4235. skin: findID(hats, this.skinIndex),
  4236. tail: findID(accessories, this.tailIndex)
  4237. }
  4238. 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;
  4239. this.maxSpeed = spdMult;
  4240.  
  4241. }
  4242. };
  4243.  
  4244. let tmpRatio = 0;
  4245. let animIndex = 0;
  4246. this.animate = function(delta) {
  4247. if (this.animTime > 0) {
  4248. this.animTime -= delta;
  4249. if (this.animTime <= 0) {
  4250. this.animTime = 0;
  4251. this.dirPlus = 0;
  4252. tmpRatio = 0;
  4253. animIndex = 0;
  4254. } else {
  4255. if (animIndex == 0) {
  4256. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4257. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4258. if (tmpRatio >= 1) {
  4259. tmpRatio = 1;
  4260. animIndex = 1;
  4261. }
  4262. } else {
  4263. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4264. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4265. }
  4266. }
  4267. }
  4268. };
  4269.  
  4270. // GATHER ANIMATION:
  4271. this.startAnim = function(didHit, index) {
  4272. this.animTime = this.animSpeed = items.weapons[index].speed;
  4273. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4274. tmpRatio = 0;
  4275. animIndex = 0;
  4276. };
  4277.  
  4278. // CAN SEE:
  4279. this.canSee = function(other) {
  4280. if (!other) return false;
  4281. let dx = Math.abs(other.x - this.x) - other.scale;
  4282. let dy = Math.abs(other.y - this.y) - other.scale;
  4283. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4284. };
  4285.  
  4286. // SHAME SYSTEM:
  4287. this.judgeShame = function() {
  4288. this.lastshamecount = this.shameCount;
  4289. if (this.oldHealth < this.health) {
  4290. if (this.hitTime) {
  4291. let timeSinceHit = game.tick - this.hitTime;
  4292. this.lastHit = game.tick;
  4293. this.hitTime = 0;
  4294. if (timeSinceHit < 2) {
  4295. this.shameCount++;
  4296. } else {
  4297. this.shameCount = Math.max(0, this.shameCount - 2);
  4298. }
  4299. }
  4300. } else if (this.oldHealth > this.health) {
  4301. this.hitTime = game.tick;
  4302. }
  4303. };
  4304. this.addShameTimer = function() {
  4305. this.shameCount = 0;
  4306. this.shameTimer = 30;
  4307. let interval = setInterval(() => {
  4308. this.shameTimer--;
  4309. if (this.shameTimer <= 0) {
  4310. clearInterval(interval);
  4311. }
  4312. }, 1000);
  4313. };
  4314.  
  4315. // CHECK TEAM:
  4316. this.isTeam = function(tmpObj) {
  4317. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4318. };
  4319.  
  4320. // FOR THE PLAYER:
  4321. this.findAllianceBySid = function(sid) {
  4322. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4323. };
  4324. this.checkCanInsta = function(nobull) {
  4325. let totally = 0;
  4326. if (this.alive && inGame) {
  4327. let primary = {
  4328. weapon: this.weapons[0],
  4329. variant: this.primaryVariant,
  4330. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4331. };
  4332. let secondary = {
  4333. weapon: this.weapons[1],
  4334. variant: this.secondaryVariant,
  4335. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4336. };
  4337. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4338. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4339. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4340. totally += primary.dmg * pV * bull;
  4341. }
  4342. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4343. totally += secondary.dmg;
  4344. }
  4345. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4346. totally += 25;
  4347. }
  4348. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4349. return totally;
  4350. }
  4351. return 0;
  4352. };
  4353.  
  4354. // UPDATE WEAPON RELOAD:
  4355. this.manageReload = function() {
  4356. if (this.shooting[53]) {
  4357. this.shooting[53] = 0;
  4358. this.reloads[53] = (2500 - game.tickRate);
  4359. } else {
  4360. if (this.reloads[53] > 0) {
  4361. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4362. }
  4363. }
  4364.  
  4365. //preplacer
  4366. if (this.reloads[this.weaponIndex] <= 1000/9) { //auto preplace
  4367. // place(2, getAttackDir());
  4368. let index = this.weaponIndex;
  4369. 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));
  4370. for(let i = 0; i < nearObja.length; i++) {
  4371. let aaa = nearObja[i];
  4372.  
  4373. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4374. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4375. if(aaa.health - (valaa) <= 0 && near.length) {
  4376. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI);
  4377. }
  4378. }
  4379. }
  4380.  
  4381. if (this.gathering || this.shooting[1]) {
  4382. if (this.gathering) {
  4383. this.gathering = 0;
  4384. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4385. this.attacked = true;
  4386. }
  4387. if (this.shooting[1]) {
  4388. this.shooting[1] = 0;
  4389. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4390. this.attacked = true;
  4391. }
  4392. } else {
  4393. this.attacked = false;
  4394. if (this.buildIndex < 0) {
  4395. if (this.reloads[this.weaponIndex] > 0) {
  4396. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4397. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4398. if (this == player) {
  4399. if (getEl("weaponGrind").checked) {
  4400. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4401. checkPlace(player.getItemType(22), i);
  4402. }
  4403. }
  4404. }
  4405. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4406. this.antiBull++;
  4407. game.tickBase(() => {
  4408. this.antiBull = 0;
  4409. }, 1);
  4410. }
  4411. }
  4412. }
  4413. }
  4414. };
  4415.  
  4416. // FOR ANTI INSTA:
  4417. this.addDamageThreat = function(tmpObj) {
  4418. let primary = {
  4419. weapon: this.primaryIndex,
  4420. variant: this.primaryVariant
  4421. };
  4422. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4423. let secondary = {
  4424. weapon: this.secondaryIndex,
  4425. variant: this.secondaryVariant
  4426. };
  4427. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4428. let bull = 1.5;
  4429. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4430. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4431. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4432. this.damageThreat += primary.dmg * pV * bull;
  4433. }
  4434. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4435. this.damageThreat += secondary.dmg * sV;
  4436. }
  4437. if (this.reloads[53] <= game.tickRate) {
  4438. this.damageThreat += 25;
  4439. }
  4440. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4441. if (!this.isTeam(tmpObj)) {
  4442. if (this.dist2 <= 300) {
  4443. tmpObj.damageThreat += this.damageThreat;
  4444. }
  4445. }
  4446. };
  4447.  
  4448. }
  4449. };
  4450.  
  4451. // SOME CODES:
  4452. function sendUpgrade(index) {
  4453. player.reloads[index] = 0;
  4454. packet("H", index);
  4455. }
  4456.  
  4457. function storeEquip(id, index) {
  4458. packet("c", 0, id, index);
  4459. }
  4460.  
  4461. function storeBuy(id, index) {
  4462. packet("c", 1, id, index);
  4463. }
  4464.  
  4465. function buyEquip(id, index) {
  4466. let nID = player.skins[6] ? 6 : 0;
  4467. if (player.alive && inGame) {
  4468. if (index == 0) {
  4469. if (player.skins[id]) {
  4470. if (player.latestSkin != id) {
  4471. packet("c", 0, id, 0);
  4472. }
  4473. } else {
  4474. if (configs.autoBuyEquip) {
  4475. let find = findID(hats, id);
  4476. if (find) {
  4477. if (player.points >= find.price) {
  4478. packet("c", 1, id, 0);
  4479. packet("c", 0, id, 0);
  4480. } else {
  4481. if (player.latestSkin != nID) {
  4482. packet("c", 0, nID, 0);
  4483. }
  4484. }
  4485. } else {
  4486. if (player.latestSkin != nID) {
  4487. packet("c", 0, nID, 0);
  4488. }
  4489. }
  4490. } else {
  4491. if (player.latestSkin != nID) {
  4492. packet("c", 0, nID, 0);
  4493. }
  4494. }
  4495. }
  4496. } else if (index == 1) {
  4497. if (useWasd && (id != 11 && id != 0)) {
  4498. if (player.latestTail != 0) {
  4499. packet("c", 0, 0, 1);
  4500. }
  4501. return;
  4502. }
  4503. if (player.tails[id]) {
  4504. if (player.latestTail != id) {
  4505. packet("c", 0, id, 1);
  4506. }
  4507. } else {
  4508. if (configs.autoBuyEquip) {
  4509. let find = findID(accessories, id);
  4510. if (find) {
  4511. if (player.points >= find.price) {
  4512. packet("c", 1, id, 1);
  4513. packet("c", 0, id, 1);
  4514. } else {
  4515. if (player.latestTail != 0) {
  4516. packet("c", 0, 0, 1);
  4517. }
  4518. }
  4519. } else {
  4520. if (player.latestTail != 0) {
  4521. packet("c", 0, 0, 1);
  4522. }
  4523. }
  4524. } else {
  4525. if (player.latestTail != 0) {
  4526. packet("c", 0, 0, 1);
  4527. }
  4528. }
  4529. }
  4530. }
  4531. }
  4532. }
  4533.  
  4534. function selectToBuild(index, wpn) {
  4535. packet("G", index, wpn);
  4536. }
  4537.  
  4538. function selectWeapon(index, isPlace) {
  4539. if (!isPlace) {
  4540. player.weaponCode = index;
  4541. }
  4542. packet("G", index, 1);
  4543. }
  4544.  
  4545. function sendAutoGather() {
  4546. packet("K", 1, 1);
  4547. }
  4548.  
  4549. function sendAtck(id, angle) {
  4550. packet("d", id, angle, 1);
  4551. }
  4552.  
  4553. // PLACER:
  4554. function place(id, rad, rmd) {
  4555. try {
  4556. if (id == undefined) return;
  4557. let item = items.list[player.items[id]];
  4558. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4559. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4560. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4561. 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))) {
  4562. selectToBuild(player.items[id]);
  4563. sendAtck(1, rad);
  4564. selectWeapon(player.weaponCode, 1);
  4565. if (rmd && getEl("placeVis").checked) {
  4566. placeVisible.push({
  4567. x: tmpX,
  4568. y: tmpY,
  4569. name: item.name,
  4570. scale: item.scale,
  4571. dir: rad
  4572. });
  4573. game.tickBase(() => {
  4574. placeVisible.shift();
  4575. }, 1)
  4576. }
  4577. }
  4578. } catch (e) {}
  4579. }
  4580.  
  4581. function checkPlace(id, rad) {
  4582. try {
  4583. if (id == undefined) return;
  4584. let item = items.list[player.items[id]];
  4585. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4586. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4587. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4588. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4589. place(id, rad, 1);
  4590. }
  4591. } catch (e) {}
  4592. }
  4593.  
  4594. // HEALING:
  4595. function soldierMult() {
  4596. return player.latestSkin == 6 ? 0.75 : 1;
  4597. }
  4598.  
  4599. function healthBased() {
  4600. if (player.health == 100)
  4601. return 0;
  4602. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4603. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4604. }
  4605. return 0;
  4606. }
  4607.  
  4608. function getAttacker(damaged) {
  4609. let attackers = enemy.filter(tmp => {
  4610. //let damages = new Damages(items);
  4611. //let dmg = damages.weapons[tmp.weaponIndex];
  4612. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4613. let rule = {
  4614. //one: tmp.dist2 <= 300,
  4615. //two: by.includes(damaged),
  4616. three: tmp.attacked
  4617. }
  4618. return /*rule.one && rule.two && */ rule.three;
  4619. });
  4620. return attackers;
  4621. }
  4622.  
  4623. function healer() {
  4624. for (let i = 0; i < healthBased(); i++) {
  4625. place(0, getAttackDir());
  4626. }
  4627. }
  4628. function healer33() {
  4629. for (let i = 0; i < healthBased(); i++) {
  4630. place(0, getAttackDir());
  4631. }
  4632. }
  4633. function healer1() {
  4634. place(0, getAttackDir());
  4635. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4636. }
  4637.  
  4638.  
  4639. function noshameheal() {
  4640. place(0, getAttackDir());
  4641. if (player.shameCount >= 5) {
  4642. place(0, getAttackDir());
  4643. healer33();
  4644. }else{
  4645. if (player.shameCount <= 4 && player.skinIndex != 6 && player.skinIndex != 22) {
  4646. healer33();
  4647. buyEquip(6, 0);
  4648. }else{
  4649. if (player.shameCount >= 5 && player.skinIndex != 6 && player.skinIndex != 22) {
  4650. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4651. healer33();
  4652.  
  4653. /*}else{
  4654. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4655. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4656. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);*/
  4657. }
  4658. }
  4659. }
  4660. }
  4661.  
  4662.  
  4663. function antiSyncHealing(timearg) {
  4664. my.antiSync = true;
  4665. let healAnti = setInterval(() => {
  4666. if (player.shameCount < 5) {
  4667. place(0, getAttackDir());
  4668. }
  4669. }, 75);
  4670. setTimeout(() => {
  4671. clearInterval(healAnti);
  4672. setTimeout(() => {
  4673. my.antiSync = false;
  4674. }, game.tickRate);
  4675. }, game.tickRate);
  4676. }
  4677.  
  4678. function biomeGear(mover, returns) {
  4679. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4680. if (returns) return 31;
  4681. buyEquip(31, 0);
  4682. } else {
  4683. if (player.y2 <= config.snowBiomeTop) {
  4684. if (returns) return enemy && near.dist2 <= 300 ? 6 : 15;
  4685. buyEquip(15, 0);
  4686. } else {
  4687. if (returns) return enemy && near.dist2 <= 300 ? 6 : 12;
  4688. buyEquip(enemy ? 6 : 12, 0);
  4689. }
  4690. }
  4691. if (returns) return 0;
  4692. }
  4693.  
  4694. class Traps {
  4695. constructor(UTILS, items) {
  4696. this.dist = 0;
  4697. this.aim = 0;
  4698. this.inTrap = false;
  4699. this.replaced = false;
  4700. this.antiTrapped = false;
  4701. this.info = {};
  4702. this.notFast = function() {
  4703. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4704. }
  4705. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4706. try {
  4707. let item = items.list[player.items[id]];
  4708. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4709. let counts = {
  4710. attempts: 0,
  4711. placed: 0
  4712. };
  4713. let tmpObjects = [];
  4714. liztobj.forEach((p) => {
  4715. tmpObjects.push({
  4716. x: p.x,
  4717. y: p.y,
  4718. active: p.active,
  4719. blocker: p.blocker,
  4720. scale: p.scale,
  4721. isItem: p.isItem,
  4722. type: p.type,
  4723. colDiv: p.colDiv,
  4724. getScale: function(sM, ig) {
  4725. sM = sM || 1;
  4726. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4727. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4728. },
  4729. });
  4730. });
  4731. for (let i = first; i < repeat; i += plus) {
  4732. counts.attempts++;
  4733. let relAim = radian + i;
  4734. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4735. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4736. 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)));
  4737. if (cantPlace) continue;
  4738. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4739. if ((!replacer && yaboi)) {
  4740. if (yaboi.inTrap) {
  4741. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI*1.3) {
  4742. place(2, relAim, 1);
  4743. } else {
  4744. player.items[4] == 15 && place(4, relAim, 1);
  4745. }
  4746. } else {
  4747. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 2.6) {
  4748. place(2, relAim, 1);
  4749. } else {
  4750. player.items[4] == 15 && place(4, relAim, 1);
  4751. }
  4752. }
  4753. } else {
  4754. place(id, relAim, 1);
  4755. }
  4756. tmpObjects.push({
  4757. x: tmpX,
  4758. y: tmpY,
  4759. active: true,
  4760. blocker: item.blocker,
  4761. scale: item.scale,
  4762. isItem: true,
  4763. type: null,
  4764. colDiv: item.colDiv,
  4765. getScale: function() {
  4766. return this.scale;
  4767. },
  4768. });
  4769. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4770. counts.placed++;
  4771. }
  4772. }
  4773. if (counts.placed > 0 && replacer && item.dmg) {
  4774. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4775. instaC.canSpikeTick = true;
  4776. }
  4777. }
  4778. } catch (err) {
  4779. }
  4780. };
  4781. this.checkSpikeTick = function() {
  4782. try {
  4783. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4784. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4785. // more range for safe. also testing near.primaryIndex || 5
  4786. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4787. let item = items.list[9];
  4788. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4789. let danger = 0;
  4790. let counts = {
  4791. attempts: 0,
  4792. block: `unblocked`
  4793. };
  4794. for (let i = -1; i <= 1; i += 1 / 10) {
  4795. counts.attempts++;
  4796. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4797. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4798. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4799. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4800. if (cantPlace) continue;
  4801. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4802. danger++;
  4803. counts.block = `blocked`;
  4804. break;
  4805. }
  4806. if (danger) {
  4807. my.anti0Tick = 1;
  4808. // player.chat.message = "Anti SpikeTick " + near.sid;
  4809. //player.chat.count = 2000;
  4810. return true;
  4811. }
  4812. }
  4813. } catch (err) {
  4814. return null;
  4815. }
  4816. return false;
  4817. }
  4818.  
  4819. function getDist(e, t) {
  4820. try {
  4821. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4822. } catch (e) {
  4823. return Infinity;
  4824. }
  4825. }
  4826.  
  4827. this.protect = function(aim) {
  4828. if (!configs.antiTrap) return;
  4829. if (player.items[4]) {
  4830. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4831. this.antiTrapped = true;
  4832. }
  4833. };
  4834. let trappling = false;
  4835. let spikeplacer = false;
  4836.  
  4837. this.autoPlace = function () {
  4838. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4839. if (gameObjects.length) {
  4840. let near2 = {
  4841. inTrap: true,
  4842. };
  4843. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function (a, b) {
  4844. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4845. })[0];
  4846. if (nearTrap) {
  4847. near2.inTrap = true;
  4848. } else {
  4849. near2.inTrap = true;
  4850. }
  4851. if (this.testMode ? enemy.length : (near.dist2 <= 375)) {
  4852. if (near.dist2 <= 200) {
  4853. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4854. } else {
  4855. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4856. }
  4857. }
  4858. } else {
  4859. if (this.testMode ? enemy.length : (near.dist2 <= 1000)) {
  4860. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4861. }
  4862. }
  4863. }
  4864. };
  4865.  
  4866.  
  4867.  
  4868.  
  4869. /*
  4870. this.autoPlace = function() {
  4871. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4872. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4873. if (liztobj.length) {
  4874. let near2 = {
  4875. inTrap: false,
  4876. };
  4877. let nearTrap = liztobj.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function(a, b) {
  4878. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4879.  
  4880. })[0];
  4881. if (nearTrap) {
  4882. near2.inTrap = true;
  4883. } else {
  4884. near2.inTrap = false;
  4885. }
  4886. if (near.dist3 <= 276 && !spikeplacer) {
  4887. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4888. inTrap: near2.inTrap
  4889. });
  4890. } else {
  4891. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4892. }
  4893. }
  4894. }
  4895. }
  4896. };*/
  4897.  
  4898. let spikePlaced = false;
  4899. let spikSync = false;
  4900.  
  4901.  
  4902. this.replacer = function(findObj) {
  4903. if (!findObj || !configs.autoReplace) return;
  4904. if (!inGame) return;
  4905. if (this.antiTrapped) return;
  4906. game.tickBase(() => {
  4907. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4908. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4909. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4910.  
  4911. if(spikePlaced){
  4912. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4913. spikePlaced = false;
  4914. }
  4915. if (near.dist2 <= 250 && !spikSync) {
  4916. for (let i = 0; i < 24; i++) {
  4917. let angle = (Math.PI * 2) * i / 24;
  4918. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1);
  4919. spikePlaced = true;
  4920. }
  4921. }
  4922. if (objDst <= 250 && near.dist2 <= 250) {
  4923. let danger = this.checkSpikeTick();
  4924. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4925.  
  4926. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1)
  4927. for (let i = 0; i < 24; i++) { // Цикл для создания спайков в разных направлениях
  4928. let angle = (Math.PI * 2) * i / 24;
  4929. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1); // / Ставим спайк в текущем направлении
  4930. this.testCanPlace(2, (Math.PI / 2), (Math.PI / 2), (Math.PI / 2), near, objAim, 1)
  4931. spikSync = true;
  4932.  
  4933. }
  4934. } else {
  4935. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4936. }
  4937.  
  4938. this.replaced = true;
  4939. }
  4940. }, 1);
  4941. };
  4942. }
  4943. };
  4944.  
  4945. class Instakill {
  4946. constructor() {
  4947. this.wait = false;
  4948. this.can = false;
  4949. this.isTrue = false;
  4950. this.nobull = false;
  4951. this.ticking = false;
  4952. this.canSpikeTick = false;
  4953. this.startTick = false;
  4954. this.readyTick = false;
  4955. this.canCounter = false;
  4956. this.revTick = false;
  4957. this.syncHit = false;
  4958. this.changeType = function(type) {
  4959. this.wait = false;
  4960. this.isTrue = true;
  4961. my.autoAim = true;
  4962. let instaLog = [type];
  4963. let backupNobull = near.backupNobull;
  4964. near.backupNobull = false;
  4965. if (type == "rev") {
  4966. healer1();
  4967. selectWeapon(player.weapons[1]);
  4968. buyEquip(53, 0);
  4969. sendAutoGather();
  4970. setTimeout(() => {
  4971. selectWeapon(player.weapons[0]);
  4972. buyEquip(7, 0);
  4973. setTimeout(() => {
  4974. sendAutoGather();
  4975. this.isTrue = false;
  4976. my.autoAim = false;
  4977. }, 225);
  4978. }, 100);
  4979. } else if (type == "nobull") {
  4980. selectWeapon(player.weapons[0]);
  4981. healer1();
  4982. buyEquip(7, 0);
  4983. buyEquip(21, 1);
  4984. sendAutoGather();
  4985. setTimeout(() => {
  4986. selectWeapon(player.weapons[1]);
  4987. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4988. setTimeout(() => {
  4989. sendAutoGather();
  4990. this.isTrue = false;
  4991. my.autoAim = false;
  4992. }, 255);
  4993. }, 105);
  4994. } else if (type == "normal") {
  4995. selectWeapon(player.weapons[0]);
  4996. healer1();
  4997. buyEquip(7, 0);
  4998. buyEquip(21, 1);
  4999. sendAutoGather();
  5000. setTimeout(() => {
  5001. selectWeapon(player.weapons[1]);
  5002. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5003. setTimeout(() => {
  5004. sendAutoGather();
  5005. this.isTrue = false;
  5006. my.autoAim = false;
  5007. }, 255);
  5008. }, 100);
  5009. } else {
  5010. setTimeout(() => {
  5011. this.isTrue = false;
  5012. my.autoAim = false;
  5013. }, 50);
  5014. }
  5015. };
  5016. this.spikeTickType = function() {
  5017. this.isTrue = true;
  5018. my.autoAim = true;
  5019. healer1();
  5020. selectWeapon(player.weapons[0]);
  5021. buyEquip(7, 0);
  5022. sendAutoGather();
  5023. game.tickBase(() => {
  5024. selectWeapon(player.weapons[0]);
  5025. buyEquip(53, 0);
  5026. game.tickBase(() => {
  5027. sendAutoGather();
  5028. this.isTrue = false;
  5029. my.autoAim = false;
  5030. }, 1);
  5031. }, 1);
  5032. };
  5033. this.counterType = function() {
  5034. this.isTrue = true;
  5035. my.autoAim = true;
  5036. selectWeapon(player.weapons[0]);
  5037. buyEquip(7, 0);
  5038. sendAutoGather();
  5039. game.tickBase(() => {
  5040. selectWeapon(player.weapons[0]);
  5041. buyEquip(53, 0);
  5042. game.tickBase(() => {
  5043. sendAutoGather();
  5044. this.isTrue = false;
  5045. my.autoAim = false;
  5046. }, 1);
  5047. }, 1);
  5048. };
  5049. this.rangeType = function(type) {
  5050. this.isTrue = true;
  5051. my.autoAim = true;
  5052. if (type == "ageInsta") {
  5053. my.ageInsta = false;
  5054. if (player.items[5] == 18) {
  5055. place(5, near.aim2);
  5056. }
  5057. packet("a", undefined, 1);
  5058. buyEquip(22, 0);
  5059. buyEquip(21, 1);
  5060. game.tickBase(() => {
  5061. selectWeapon(player.weapons[1]);
  5062. buyEquip(53, 0);
  5063. buyEquip(21, 1);
  5064. sendAutoGather();
  5065. game.tickBase(() => {
  5066. sendUpgrade(12);
  5067. selectWeapon(player.weapons[1]);
  5068. buyEquip(53, 0);
  5069. buyEquip(21, 1);
  5070. game.tickBase(() => {
  5071. sendUpgrade(15);
  5072. selectWeapon(player.weapons[1]);
  5073. buyEquip(53, 0);
  5074. buyEquip(21, 1);
  5075. game.tickBase(() => {
  5076. sendAutoGather();
  5077. this.isTrue = false;
  5078. my.autoAim = false;
  5079. }, 1);
  5080. }, 1);
  5081. }, 1);
  5082. }, 1);
  5083. } else {
  5084. selectWeapon(player.weapons[1]);
  5085. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5086. buyEquip(53, 0);
  5087. } else {
  5088. buyEquip(20, 0);
  5089. }
  5090. buyEquip(11, 1);
  5091. sendAutoGather();
  5092. game.tickBase(() => {
  5093. sendAutoGather();
  5094. this.isTrue = false;
  5095. my.autoAim = false;
  5096. }, 1);
  5097. }
  5098. };
  5099. this.oneTickType = function() {
  5100. this.isTrue = true;
  5101. my.autoAim = true;
  5102. selectWeapon(player.weapons[1]);
  5103. buyEquip(53, 0);
  5104. buyEquip(11, 1);
  5105. packet("a", near.aim2, 1);
  5106. if (player.weapons[1] == 15) {
  5107. my.revAim = true;
  5108. sendAutoGather();
  5109. }
  5110. game.tickBase(() => {
  5111. my.revAim = false;
  5112. selectWeapon(player.weapons[0]);
  5113. buyEquip(7, 0);
  5114. buyEquip(19, 1);
  5115. packet("a", near.aim2, 1);
  5116. if (player.weapons[1] != 15) {
  5117. sendAutoGather();
  5118. }
  5119. game.tickBase(() => {
  5120. sendAutoGather();
  5121. this.isTrue = false;
  5122. my.autoAim = false;
  5123. packet("a", undefined, 1);
  5124. }, 1);
  5125. }, 1);
  5126. };
  5127. this.threeOneTickType = function() {
  5128. this.isTrue = true;
  5129. my.autoAim = true;
  5130. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5131. biomeGear();
  5132. buyEquip(11, 1);
  5133. packet("a", near.aim2, 1);
  5134. game.tickBase(() => {
  5135. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5136. buyEquip(53, 0);
  5137. buyEquip(11, 1);
  5138. packet("a", near.aim2, 1);
  5139. game.tickBase(() => {
  5140. selectWeapon(player.weapons[0]);
  5141. buyEquip(7, 0);
  5142. buyEquip(19, 1);
  5143. sendAutoGather();
  5144. packet("a", near.aim2, 1);
  5145. game.tickBase(() => {
  5146. sendAutoGather();
  5147. this.isTrue = false;
  5148. my.autoAim = false;
  5149. packet("a", undefined, 1);
  5150. }, 1);
  5151. }, 1);
  5152. }, 1);
  5153. };
  5154. this.kmTickType = function() {
  5155. this.isTrue = true;
  5156. my.autoAim = true;
  5157. my.revAim = true;
  5158. selectWeapon(player.weapons[1]);
  5159. buyEquip(53, 0);
  5160. buyEquip(11, 1);
  5161. sendAutoGather();
  5162. packet("a", near.aim2, 1);
  5163. game.tickBase(() => {
  5164. my.revAim = false;
  5165. selectWeapon(player.weapons[0]);
  5166. buyEquip(7, 0);
  5167. buyEquip(19, 1);
  5168. packet("a", near.aim2, 1);
  5169. game.tickBase(() => {
  5170. sendAutoGather();
  5171. this.isTrue = false;
  5172. my.autoAim = false;
  5173. packet("a", undefined, 1);
  5174. }, 1);
  5175. }, 1);
  5176. };
  5177. this.boostTickType = function() {
  5178. /*this.isTrue = true;
  5179. my.autoAim = true;
  5180. selectWeapon(player.weapons[0]);
  5181. buyEquip(53, 0);
  5182. buyEquip(11, 1);
  5183. packet("a", near.aim2);
  5184. game.tickBase(() => {
  5185. place(4, near.aim2);
  5186. selectWeapon(player.weapons[1]);
  5187. biomeGear();
  5188. buyEquip(11, 1);
  5189. sendAutoGather();
  5190. packet("a", near.aim2);
  5191. game.tickBase(() => {
  5192. selectWeapon(player.weapons[0]);
  5193. buyEquip(7, 0);
  5194. buyEquip(19, 1);
  5195. packet("a", near.aim2);
  5196. game.tickBase(() => {
  5197. sendAutoGather();
  5198. this.isTrue = false;
  5199. my.autoAim = false;
  5200. packet("a", undefined);
  5201. }, 1);
  5202. }, 1);
  5203. }, 1);*/
  5204. this.isTrue = true;
  5205. my.autoAim = true;
  5206. biomeGear();
  5207. buyEquip(11, 1);
  5208. packet("a", near.aim2, 1);
  5209. game.tickBase(() => {
  5210. if (player.weapons[1] == 15) {
  5211. my.revAim = true;
  5212. }
  5213. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5214. buyEquip(53, 0);
  5215. buyEquip(11, 1);
  5216. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5217. sendAutoGather();
  5218. }
  5219. packet("a", near.aim2, 1);
  5220. place(4, near.aim2);
  5221. game.tickBase(() => {
  5222. my.revAim = false;
  5223. selectWeapon(player.weapons[0]);
  5224. buyEquip(7, 0);
  5225. buyEquip(19, 1);
  5226. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5227. sendAutoGather();
  5228. }
  5229. packet("a", near.aim2, 1);
  5230. game.tickBase(() => {
  5231. sendAutoGather();
  5232. this.isTrue = false;
  5233. my.autoAim = false;
  5234. packet("a", undefined, 1);
  5235. }, 1);
  5236. }, 1);
  5237. }, 1);
  5238. };
  5239. this.gotoGoal = function(goto, OT) {
  5240. let slowDists = (weeeee) => weeeee * config.playerScale;
  5241. let goal = {
  5242. a: goto - OT,
  5243. b: goto + OT,
  5244. c: goto - slowDists(1),
  5245. d: goto + slowDists(1),
  5246. e: goto - slowDists(2),
  5247. f: goto + slowDists(2),
  5248. g: goto - slowDists(4),
  5249. h: goto + slowDists(4)
  5250. };
  5251. let bQ = function (wwww, awwww) {
  5252. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5253. buyEquip(31, 0);
  5254. } else {
  5255. buyEquip(wwww, awwww);
  5256. }
  5257. }
  5258. if (enemy.length) {
  5259. let dst = near.dist2;
  5260. this.ticking = true;
  5261. if (dst >= goal.a && dst <= goal.b) {
  5262. bQ(22, 0);
  5263. bQ(11, 1);
  5264. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5265. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5266. }
  5267. return {
  5268. dir: undefined,
  5269. action: 1
  5270. };
  5271. } else {
  5272. if (dst < goal.a) {
  5273. if (dst >= goal.g) {
  5274. if (dst >= goal.e) {
  5275. if (dst >= goal.c) {
  5276. bQ(40, 0);
  5277. bQ(21, 1);
  5278. if (configs.slowOT) {
  5279. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5280. } else {
  5281. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5282. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5283. }
  5284. }
  5285. } else {
  5286. bQ(26, 0);
  5287. bQ(21, 1);
  5288. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5289. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5290. }
  5291. }
  5292. } else {
  5293. bQ(26, 0);
  5294. bQ(12, 1);
  5295. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5296. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5297. }
  5298. }
  5299. } else {
  5300. biomeGear();
  5301. bQ(11, 1);
  5302. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5303. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5304. }
  5305. }
  5306. return {
  5307. dir: near.aim2 + Math.PI,
  5308. action: 0
  5309. };
  5310. } else if (dst > goal.b) {
  5311. if (dst <= goal.h) {
  5312. if (dst <= goal.f) {
  5313. if (dst <= goal.d) {
  5314. bQ(40, 0);
  5315. bQ(9, 1);
  5316. if (configs.slowOT) {
  5317. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5318. } else {
  5319. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5320. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5321. }
  5322. }
  5323. } else {
  5324. bQ(22, 0);
  5325. bQ(19, 1);
  5326. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5327. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5328. }
  5329. }
  5330. } else {
  5331. bQ(6, 0);
  5332. bQ(12, 1);
  5333. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5334. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5335. }
  5336. }
  5337. } else {
  5338. biomeGear();
  5339. bQ(11, 1);
  5340. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5341. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5342. }
  5343. }
  5344. return {
  5345. dir: near.aim2,
  5346. action: 0
  5347. };
  5348. }
  5349. return {
  5350. dir: undefined,
  5351. action: 0
  5352. };
  5353. }
  5354. } else {
  5355. this.ticking = false;
  5356. return {
  5357. dir: undefined,
  5358. action: 0
  5359. };
  5360. }
  5361. }
  5362. /** wait 1 tick for better quality */
  5363. this.bowMovement = function() {
  5364. let moveMent = this.gotoGoal(685, 3);
  5365. if (moveMent.action) {
  5366. if (player.reloads[53] == 0 && !this.isTrue) {
  5367. this.rangeType("ageInsta");
  5368. } else {
  5369. packet("a", moveMent.dir, 1);
  5370. }
  5371. } else {
  5372. packet("a", moveMent.dir, 1);
  5373. }
  5374. },
  5375. this.tickMovement = function() {
  5376. let moveMent = this.gotoGoal(([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) ? 240 : player.weapons[1] == 15 ? 250 : player.y2 <= config.snowBiomeTop ? [10, 14].includes(player.weapons[1]) ? 270 : 265 : 275, 3);
  5377. if (moveMent.action) {
  5378. if (![6, 22].includes(near.skinIndex) && player.reloads[53] == 0 && !this.isTrue) {
  5379. ([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) || (player.weapons[1] == 15) ? this.oneTickType(): this.threeOneTickType();
  5380. } else {
  5381. packet("a", moveMent.dir, 1);
  5382. }
  5383. } else {
  5384. packet("a", moveMent.dir, 1);
  5385. }
  5386. },
  5387. this.kmTickMovement = function() {
  5388. let moveMent = this.gotoGoal(240, 3);
  5389. if (moveMent.action) {
  5390. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5391. this.kmTickType();
  5392. } else {
  5393. packet("a", moveMent.dir, 1);
  5394. }
  5395. } else {
  5396. packet("a", moveMent.dir, 1);
  5397. }
  5398. },
  5399. this.boostTickMovement = function() {
  5400. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 390 : player.weapons[1] == 15 ? 365 : 370;
  5401. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1.5 : player.weapons[1] == 15 ? 2 : 3;
  5402. let moveMent = this.gotoGoal(dist, actionDist);
  5403. if (moveMent.action) {
  5404. if (player.reloads[53] == 0 && !this.isTrue) {
  5405. this.boostTickType();
  5406. } else {
  5407. packet("a", moveMent.dir, 1);
  5408. }
  5409. } else {
  5410. packet("a", moveMent.dir, 1);
  5411. }
  5412. }
  5413. /** wait 1 tick for better quality */
  5414. this.perfCheck = function(pl, nr) {
  5415. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5416. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5417. let pjs = {
  5418. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5419. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5420. };
  5421. 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)) {
  5422. return true;
  5423. }
  5424. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5425. 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)) {
  5426. return true;
  5427. }
  5428. });
  5429. if (finds) return false;
  5430. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5431. let tmpScale = tmp.getScale();
  5432. 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)) {
  5433. return true;
  5434. }
  5435. });
  5436. if (finds) return false;
  5437. return true;
  5438. }
  5439. }
  5440. };
  5441.  
  5442. class Autobuy {
  5443. constructor(buyHat, buyAcc) {
  5444. this.hat = function() {
  5445. buyHat.forEach((id) => {
  5446. let find = findID(hats, id);
  5447. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5448. });
  5449. };
  5450. this.acc = function() {
  5451. buyAcc.forEach((id) => {
  5452. let find = findID(accessories, id);
  5453. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5454. });
  5455. };
  5456. }
  5457. };
  5458.  
  5459. class Autoupgrade {
  5460. constructor() {
  5461. this.sb = function(upg) {
  5462. upg(3);
  5463. upg(17);
  5464. upg(31);
  5465. upg(23);
  5466. upg(9);
  5467. upg(38);
  5468. };
  5469. this.kh = function(upg) {
  5470. upg(3);
  5471. upg(17);
  5472. upg(31);
  5473. upg(23);
  5474. upg(10);
  5475. upg(38);
  5476. upg(4);
  5477. upg(25);
  5478. };
  5479. this.pb = function(upg) {
  5480. upg(5);
  5481. upg(17);
  5482. upg(32);
  5483. upg(23);
  5484. upg(9);
  5485. upg(38);
  5486. };
  5487. this.ph = function(upg) {
  5488. upg(5);
  5489. upg(17);
  5490. upg(32);
  5491. upg(23);
  5492. upg(10);
  5493. upg(38);
  5494. upg(28);
  5495. upg(25);
  5496. };
  5497. this.db = function(upg) {
  5498. upg(7);
  5499. upg(17);
  5500. upg(31);
  5501. upg(23);
  5502. upg(9);
  5503. upg(34);
  5504. };
  5505. /* old functions */
  5506. this.km = function(upg) {
  5507. upg(7);
  5508. upg(17);
  5509. upg(31);
  5510. upg(23);
  5511. upg(10);
  5512. upg(38);
  5513. upg(4);
  5514. upg(15);
  5515. };
  5516. };
  5517. };
  5518.  
  5519. class Damages {
  5520. constructor(items) {
  5521. // 0.75 1 1.125 1.5
  5522. this.calcDmg = function(dmg, val) {
  5523. return dmg * val;
  5524. };
  5525. this.getAllDamage = function(dmg) {
  5526. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5527. };
  5528. this.weapons = [];
  5529. for (let i = 0; i < items.weapons.length; i++) {
  5530. let wp = items.weapons[i];
  5531. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5532. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5533. this[name] = this.weapons[i];
  5534. }
  5535. }
  5536. }
  5537.  
  5538. /** CLASS CODES */
  5539. // jumpscare code warn
  5540. let tmpList = [];
  5541.  
  5542. // LOADING:
  5543. let UTILS = new Utils();
  5544. let items = new Items();
  5545. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5546. let store = new Store();
  5547. let hats = store.hats;
  5548. let accessories = store.accessories;
  5549. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5550. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5551. let textManager = new Textmanager();
  5552.  
  5553. let traps = new Traps(UTILS, items);
  5554. let instaC = new Instakill();
  5555. let autoBuy = new Autobuy([40, 6, 7, 22, 53, 15, 31], [11, 19, 18 , 19]);
  5556. let autoUpgrade = new Autoupgrade();
  5557.  
  5558. let lastDeath;
  5559. let minimapData;
  5560. let mapMarker = {};
  5561. let mapPings = [];
  5562. let tmpPing;
  5563.  
  5564. let antiinsta = true;
  5565. let antiinsta1 = false;
  5566.  
  5567. let breakTrackers = [];
  5568.  
  5569. function sendChat(message) {
  5570. packet("6", message.slice(0, 30));
  5571. }
  5572.  
  5573. let runAtNextTick = [];
  5574.  
  5575. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5576. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5577. let projOffset = config.playerScale * 2;
  5578. let projXY = {
  5579. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5580. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5581. };
  5582. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5583. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5584. })[0];
  5585. if (nearPlayer) {
  5586. if (indx == 1) {
  5587. nearPlayer.shooting[53] = 1;
  5588. } else {
  5589. nearPlayer.shootIndex = weaponIndx;
  5590. nearPlayer.shooting[1] = 1;
  5591. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5592. }
  5593. }
  5594. }
  5595. let projectileCount = 0;
  5596.  
  5597. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5598. if (!tmpObj.isTeam(player)) {
  5599. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5600. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5601. tmpObj.bowThreat[weaponIndex]++;
  5602. if (index == 5) {
  5603. projectileCount++;
  5604. }
  5605. setTimeout(() => {
  5606. tmpObj.bowThreat[weaponIndex]--;
  5607. if (index == 5) {
  5608. projectileCount--;
  5609. }
  5610. }, range / speed);
  5611. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5612. place(1, tmpObj.aim2);
  5613. my.anti0Tick = 4;
  5614. if (!my.antiSync) {
  5615. antiSyncHealing(4);
  5616. }
  5617. } else {
  5618. if (projectileCount >= 2) {
  5619. place(1, tmpObj.aim2);
  5620. healer();
  5621. sendChat("prediction detect");
  5622. buyEquip(22, 0);
  5623. buyEquip(19, 1);
  5624. my.anti0Tick = 4;
  5625. if (!my.antiSync) {
  5626. antiSyncHealing(4);
  5627. }
  5628. } else {
  5629. if (projectileCount === 1) { // anti reverse or anti 1 tick with reaper
  5630. buyEquip(6, 0);
  5631. buyEquip(19, 1);
  5632. }
  5633. /*} else {
  5634. if (projectileCount >= 2) { // anti sync линия обороны N1
  5635. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  5636. player.chat.message = "pSyD";
  5637. healer();
  5638. buyEquip(6, 0);
  5639. }
  5640. }*/
  5641. }
  5642. }
  5643. }
  5644. }
  5645. }
  5646.  
  5647. // SHOW ITEM INFO:
  5648. function showItemInfo(item, isWeapon, isStoreItem) {
  5649. if (player && item) {
  5650. UTILS.removeAllChildren(itemInfoHolder);
  5651. itemInfoHolder.classList.add("visible");
  5652. UTILS.generateElement({
  5653. id: "itemInfoName",
  5654. text: UTILS.capitalizeFirst(item.name),
  5655. parent: itemInfoHolder
  5656. });
  5657. UTILS.generateElement({
  5658. id: "itemInfoDesc",
  5659. text: item.desc,
  5660. parent: itemInfoHolder
  5661. });
  5662. if (isStoreItem) {
  5663.  
  5664. } else if (isWeapon) {
  5665. UTILS.generateElement({
  5666. class: "itemInfoReq",
  5667. text: !item.type ? "primary" : "secondary",
  5668. parent: itemInfoHolder
  5669. });
  5670. } else {
  5671. for (let i = 0; i < item.req.length; i += 2) {
  5672. UTILS.generateElement({
  5673. class: "itemInfoReq",
  5674. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5675. parent: itemInfoHolder
  5676. });
  5677. }
  5678. if (item.group.limit) {
  5679. UTILS.generateElement({
  5680. class: "itemInfoLmt",
  5681. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5682. parent: itemInfoHolder
  5683. });
  5684. }
  5685. }
  5686. } else {
  5687. itemInfoHolder.classList.remove("visible");
  5688. }
  5689. }
  5690.  
  5691. // RESIZE:
  5692. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5693.  
  5694. function resize() {
  5695. screenWidth = window.innerWidth;
  5696. screenHeight = window.innerHeight;
  5697. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5698. gameCanvas.width = screenWidth * pixelDensity;
  5699. gameCanvas.height = screenHeight * pixelDensity;
  5700. gameCanvas.style.width = screenWidth + "px";
  5701. gameCanvas.style.height = screenHeight + "px";
  5702. mainContext.setTransform(
  5703. scaleFillNative, 0,
  5704. 0, scaleFillNative,
  5705. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5706. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5707. );
  5708. }
  5709. resize();
  5710.  
  5711. // MOUSE INPUT:
  5712. var usingTouch;
  5713. const mals = document.getElementById('touch-controls-fullscreen');
  5714. mals.style.display = 'block';
  5715. mals.addEventListener("mousemove", gameInput, false);
  5716.  
  5717. function gameInput(e) {
  5718. mouseX = e.clientX;
  5719. mouseY = e.clientY;
  5720. }
  5721. let clicks = {
  5722. left: false,
  5723. middle: false,
  5724. right: false,
  5725. };
  5726. mals.addEventListener("mousedown", mouseDown, false);
  5727.  
  5728. function mouseDown(e) {
  5729. if (attackState != 1) {
  5730. attackState = 1;
  5731. if (e.button == 0) {
  5732. clicks.left = true;
  5733. } else if (e.button == 1) {
  5734. clicks.middle = true;
  5735. } else if (e.button == 2) {
  5736. clicks.right = true;
  5737. }
  5738. }
  5739. }
  5740. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5741.  
  5742. function mouseUp(e) {
  5743. if (attackState != 0) {
  5744. attackState = 0;
  5745. if (e.button == 0) {
  5746. clicks.left = false;
  5747. } else if (e.button == 1) {
  5748. clicks.middle = false;
  5749. } else if (e.button == 2) {
  5750. clicks.right = false;
  5751. }
  5752. }
  5753. }
  5754. mals.addEventListener("wheel", wheel, false);
  5755.  
  5756. function wheel(e) {
  5757. if(player.shameCount > 1) {
  5758. buyEquip(7, 0);
  5759. } else {
  5760. buyEquip(6, 0);
  5761. }
  5762. }
  5763.  
  5764.  
  5765. // INPUT UTILS:
  5766. function getMoveDir() {
  5767. let dx = 0;
  5768. let dy = 0;
  5769. for (let key in moveKeys) {
  5770. let tmpDir = moveKeys[key];
  5771. dx += !!keys[key] * tmpDir[0];
  5772. dy += !!keys[key] * tmpDir[1];
  5773. }
  5774. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5775. }
  5776.  
  5777. function getSafeDir() {
  5778. if (!player)
  5779. return 0;
  5780. if (!player.lockDir) {
  5781. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5782. }
  5783. return lastDir || 0;
  5784. }
  5785. let plusDir = 0;
  5786. let lastSpin = Date.now();
  5787. function getAttackDir() {
  5788. if(player && Date.now() - lastSpin >= 235 && !(clicks.right || clicks.left)) {
  5789. plusDir += Math.random()*(Math.PI*2);
  5790. lastSpin = Date.now();
  5791. }
  5792. if (!player)
  5793. return "0";
  5794. 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))
  5795. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? near.aim2 : getSafeDir();
  5796. else
  5797. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5798. lastDir = getSafeDir();
  5799. else
  5800. if (traps.inTrap) {
  5801. lastDir = traps.aim;
  5802. } else
  5803. if (!player.lockDir) {
  5804. if (!player.lockDir && autos.stopspin) {
  5805. if(useWasd) {
  5806. lastDir = lastDir;
  5807. } else {
  5808. lastDir = getSafeDir();
  5809. }
  5810. }
  5811. }
  5812. return lastDir;
  5813. }
  5814.  
  5815. function getVisualDir() {
  5816. if (!player)
  5817. return 0;
  5818. lastDir = getSafeDir();
  5819. return lastDir || 0;
  5820. }
  5821.  
  5822. // KEYS:
  5823. function keysActive() {
  5824. return (allianceMenu.style.display != "block" &&
  5825. chatHolder.style.display != "block" &&
  5826. !menuCBFocus);
  5827. }
  5828.  
  5829. function toggleMenuChat() {
  5830. if (menuChatDiv.style.display != "none") {
  5831. // chatHolder.style.display = "none";
  5832. // if (menuChatBox.value != "") {
  5833. //commands[command.slice(1)]
  5834. let cmd = function(command) {
  5835. return {
  5836. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5837. fv: commands[command.slice(1).split(" ")[0]]
  5838. }
  5839. }
  5840. let command = cmd(menuChatBox.value);
  5841. if (command.found) {
  5842. if (typeof command.fv.action === "function") {
  5843. command.fv.action(menuChatBox.value);
  5844. }
  5845. } else {
  5846. sendChat(menuChatBox.value);
  5847. }
  5848. menuChatBox.value = "";
  5849. menuChatBox.blur();
  5850. } else {
  5851. if (menuCBFocus) {
  5852. menuChatBox.blur();
  5853. } else {
  5854. menuChatBox.focus();
  5855. }
  5856. }
  5857. }
  5858.  
  5859. function keyDown(event) {
  5860. let keyNum = event.which || event.keyCode || 0;
  5861. if (player && player.alive && keysActive()) {
  5862. if (!keys[keyNum]) {
  5863. keys[keyNum] = 1;
  5864. macro[event.key] = 1;
  5865. if (keyNum == 27) {
  5866. openMenu = !openMenu;
  5867. $("#menuDiv").toggle();
  5868. $("#menuChatDiv").toggle();
  5869. } else if (keyNum == 69) {
  5870. sendAutoGather();
  5871. } else if (keyNum == 67) {
  5872. updateMapMarker();
  5873. } else if (player.weapons[keyNum - 49] != undefined) {
  5874. player.weaponCode = player.weapons[keyNum - 49];
  5875. } else if (moveKeys[keyNum]) {
  5876. sendMoveDir();
  5877. } else if (event.key == "m") {
  5878. mills.placeSpawnPads = !mills.placeSpawnPads;
  5879. } else if (event.key == "z") {
  5880. mills.place = !mills.place;
  5881. } else if (event.key == "Z") {
  5882. typeof window.debug == "function" && window.debug();
  5883. } else if (keyNum == 32) {
  5884. packet("d", 1, getSafeDir(), 1);
  5885. packet("d", 0, getSafeDir(), 1);
  5886. } else if (event.key == ",") {
  5887. io.send("6", 'syncon')
  5888. project.send(JSON.stringify(["tezt", "ratio"]));
  5889. // botSkts.push([botPlayer]);
  5890. for(let i = 0; i < botz.length; i++) {
  5891. // if(botz[i][0]) {
  5892. botz[i][0].zync(near);
  5893. console.log(botz[i][0])
  5894. }
  5895. // project.send("tezt");
  5896. // botSkts.forEach((bot) => {
  5897. // bot.zync();
  5898. // })
  5899. // io.send("S", 1)
  5900. }
  5901. }
  5902. }
  5903. }
  5904.  
  5905. // let xx = canvaz.width/2;
  5906. // let yy = canvaz.height/2;
  5907.  
  5908. // let mouze = {
  5909. // x: xx - mouzeX,
  5910. // y: yy - mouzeY
  5911. // }
  5912.  
  5913. // let ingamecoorformodabow = {
  5914. // x: player.x + mouze.x,
  5915. // y: player.x + mouze.x
  5916. // }
  5917.  
  5918. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5919.  
  5920. function keyUp(event) {
  5921. if (player && player.alive) {
  5922. let keyNum = event.which || event.keyCode || 0;
  5923. if (keyNum == 13) {
  5924. toggleMenuChat();
  5925. } else if (keysActive()) {
  5926. if (keys[keyNum]) {
  5927. keys[keyNum] = 0;
  5928. macro[event.key] = 0;
  5929. if (moveKeys[keyNum]) {
  5930. sendMoveDir();
  5931. } else if (event.key == ",") {
  5932. player.sync = false;
  5933. }
  5934. }
  5935. }
  5936. }
  5937. }
  5938.  
  5939.  
  5940. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5941.  
  5942. function sendMoveDir() {
  5943. if(found) {
  5944. packet("a", undefined, 1);
  5945. } else {
  5946. let newMoveDir = getMoveDir();
  5947. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5948. if (!my.autoPush && !found) {
  5949. packet("a", newMoveDir, 1);
  5950. }
  5951. lastMoveDir = newMoveDir;
  5952. }
  5953. }
  5954. }
  5955.  
  5956. // BUTTON EVENTS:
  5957. function bindEvents() {}
  5958. bindEvents();
  5959.  
  5960. // ITEM COUNT DISPLAY:
  5961. let isItemSetted = [];
  5962.  
  5963. function updateItemCountDisplay(index = undefined) {
  5964. for (let i = 3; i < items.list.length; ++i) {
  5965. let id = items.list[i].group.id;
  5966. let tmpI = items.weapons.length + i;
  5967. if (!isItemSetted[tmpI]) {
  5968. isItemSetted[tmpI] = document.createElement("div");
  5969. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5970. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5971. isItemSetted[tmpI].style = `
  5972. display: block;
  5973. position: absolute;
  5974. padding-left: 5px;
  5975. font-size: 2em;
  5976. color: #fff;
  5977. `;
  5978. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5979. } else {
  5980. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5981. }
  5982. }
  5983. }
  5984.  
  5985. // AUTOPUSH:
  5986. var retrappable = false;
  5987. function autoPush() {
  5988. retrappable = true;
  5989. 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) {
  5990. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5991. })[0];
  5992. if (nearTrap) {
  5993. 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) {
  5994. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5995. })[0];
  5996. if (spike) {
  5997. let pos = {
  5998. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5999. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6000. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6001. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6002. };
  6003. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6004. let tmpScale = tmp.getScale();
  6005. 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)) {
  6006. return true;
  6007. }
  6008. });
  6009. if (finds) {
  6010. if (my.autoPush) {
  6011. my.autoPush = false;
  6012. packet("a", lastMoveDir || undefined, 1);
  6013. }
  6014. } else {
  6015. my.autoPush = true;
  6016. my.pushData = {
  6017. x: spike.x,
  6018. y: spike.y,
  6019. x2: pos.x2,
  6020. y2: pos.y2
  6021. };
  6022. let scale = (player.scale / 10);
  6023. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6024. packet("a", near.aim2, 1);
  6025. } else {
  6026. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6027. }
  6028. }
  6029. } else {
  6030. if (my.autoPush) {
  6031. my.autoPush = false;
  6032. packet("a", lastMoveDir || undefined, 1);
  6033. }
  6034. }
  6035. } else {
  6036. if (my.autoPush) {
  6037. my.autoPush = false;
  6038. packet("a", lastMoveDir || undefined, 1);
  6039. }
  6040. }
  6041. }
  6042.  
  6043. // ADD DEAD PLAYER:
  6044. function addDeadPlayer(tmpObj) {
  6045. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6046. }
  6047.  
  6048. /** APPLY SOCKET CODES */
  6049.  
  6050. // SET INIT DATA:
  6051. function setInitData(data) {
  6052. alliances = data.teams;
  6053. }
  6054.  
  6055. // SETUP GAME:
  6056. function setupGame(yourSID) {
  6057. keys = {};
  6058. macro = {};
  6059. playerSID = yourSID;
  6060. attackState = 0;
  6061. inGame = true;
  6062. packet("d", 0, getAttackDir(), 1);
  6063. my.ageInsta = true;
  6064. if (firstSetup) {
  6065. firstSetup = false;
  6066. gameObjects.length = 0;
  6067. liztobj.length = 0;
  6068. }
  6069. }
  6070.  
  6071. // ADD NEW PLAYER:
  6072. function addPlayer(data, isYou) {
  6073. let tmpPlayer = findPlayerByID(data[0]);
  6074. if (!tmpPlayer) {
  6075. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6076. objectManager, players, ais, items, hats, accessories);
  6077. players.push(tmpPlayer);
  6078. if (data[1] != playerSID) {
  6079. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6080. }
  6081. } else {
  6082. if (data[1] != playerSID) {
  6083. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6084. }
  6085. }
  6086. tmpPlayer.spawn(isYou ? true : null);
  6087. tmpPlayer.visible = false;
  6088. tmpPlayer.oldPos = {
  6089. x2: undefined,
  6090. y2: undefined
  6091. };
  6092. tmpPlayer.x2 = undefined;
  6093. tmpPlayer.y2 = undefined;
  6094. tmpPlayer.x3 = undefined;
  6095. tmpPlayer.y3 = undefined;
  6096. tmpPlayer.setData(data);
  6097. if (isYou) {
  6098. if (!player) {
  6099. window.prepareUI(tmpPlayer);
  6100. }
  6101. player = tmpPlayer;
  6102. camX = player.x;
  6103. camY = player.y;
  6104. my.lastDir = 0;
  6105. updateItems();
  6106. updateAge();
  6107. updateItemCountDisplay();
  6108. if (player.skins[7]) {
  6109. my.reSync = true;
  6110. }
  6111. }
  6112. }
  6113.  
  6114. // REMOVE PLAYER:
  6115. function removePlayer(id) {
  6116. for (let i = 0; i < players.length; i++) {
  6117. if (players[i].id == id) {
  6118. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6119. players.splice(i, 1);
  6120. break;
  6121. }
  6122. }
  6123. }
  6124.  
  6125. // UPDATE HEALTH:
  6126. function updateHealth(sid, value) {
  6127. tmpObj = findPlayerBySID(sid);
  6128. if (tmpObj) {
  6129. // tmpObj.lastshamecount = tmpObj.shameCount;
  6130. tmpObj.oldHealth = tmpObj.health;
  6131. tmpObj.health = value;
  6132. tmpObj.judgeShame();
  6133. if (tmpObj.oldHealth > tmpObj.health) {
  6134. tmpObj.timeDamaged = Date.now(); //here'
  6135. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6136. let damaged = tmpObj.damaged;
  6137. tmpObj = findPlayerBySID(sid);
  6138.  
  6139. let bullTicked = false;
  6140.  
  6141. if (tmpObj.health <= 0) {
  6142. if (!tmpObj.death) {
  6143. tmpObj.death = true;
  6144. if (tmpObj != player) {
  6145. if(tmpObj.skinIndex == 45) {
  6146. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to clown`, "red");
  6147. } else if(tmpObj.shameCount >= 5) {
  6148. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to high shame`, "red");
  6149. } else {
  6150. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died`, "red");
  6151. }
  6152. }
  6153. addDeadPlayer(tmpObj);
  6154. }
  6155. }
  6156. if (tmpObj == player) {
  6157. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 19 && damaged == 2))) { // bull ticker
  6158. }
  6159.  
  6160.  
  6161.  
  6162. let antiinsta3 = true;
  6163. let autoheal = false;
  6164. let antiinsta4 = true;
  6165.  
  6166.  
  6167.  
  6168. if (inGame) {
  6169. let attackers = getAttacker(damaged);
  6170. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg);
  6171. let includeSpikeDmgs = near.length ? !bullTicked && (gearDmgs.includes(damaged) && near[0].skinIndex == 11 && near[0].tailIndex == 21) : false;
  6172. let healTimeout = 140 - window.ping;
  6173. let slowHeal = function (timer) {
  6174. setTimeout(() => {
  6175. healer();
  6176. }, timer);
  6177. }
  6178. if (damaged >= 0 && damaged <= 66 && player.shameCount === 4 && player.shameCount === 4 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6179. autoheal = true;
  6180. antiinsta = false;
  6181. antiinsta1 = false;
  6182. antiinsta4 = false;
  6183. }else{
  6184. if(player.shameCount !== 4){
  6185. autoheal = false;
  6186. antiinsta = true;
  6187. antiinsta4 = true;
  6188. }
  6189. }
  6190.  
  6191. if (damaged <= 66 && player.shameCount === 3 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6192. antiinsta = false;
  6193. }else{
  6194. if(player.shameCount !== 3){
  6195. antiinsta = true;
  6196. }
  6197. }
  6198. if (damaged <= 66 && player.shameCount === 4 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6199. antiinsta1 = true;
  6200. }else{
  6201. if(player.shameCount !== 4){
  6202. antiinsta1 = false;
  6203. }
  6204. }
  6205. `if (damaged >= 0 && damaged <= 90 && player.shameCount === 2){ // попытка сделать невозможным довести до 3 шеймов через буллспам
  6206. antiinsta4 = false;
  6207. }else{
  6208. if(player.shameCount !== 3){
  6209. antiinsta4 = true;
  6210. }
  6211. }
  6212. if (damaged >= 0 && damaged <= 90 && !antiinsta){
  6213. if(player.shameCount === 3){
  6214. antiinsta1 = true;
  6215. }else{
  6216. antiinsta1 = false;
  6217. }
  6218. }`
  6219.  
  6220. if (damaged <= 66 && player.skinIndex != 6 && enemy.weaponIndex === 4){
  6221. game.tickBase(() => {
  6222. healer1();
  6223. }, 2);
  6224. }
  6225.  
  6226.  
  6227. let dmg = 100 - player.health;
  6228. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && antiinsta4 && (game.tick - tmpObj.antiTimer) > 1) {
  6229. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6230. tmpObj.canEmpAnti = true;
  6231. } else {
  6232. player.soldierAnti = true;
  6233. }
  6234. tmpObj.antiTimer = game.tick;
  6235. let shame = tmpObj.weapons[0] == 4 ? 2 : 5;
  6236. if (tmpObj.shameCount < shame) {
  6237. healer();
  6238. } else {
  6239. game.tickBase(() => {
  6240. healer();
  6241. }, 2);
  6242. }
  6243. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && autoheal) {
  6244. setTimeout(() => {
  6245. healer();
  6246. }, 120);
  6247. }
  6248. let dmg = 100 - player.health;
  6249. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && antiinsta && tmpObj.primaryIndex !== "4" && (game.tick - tmpObj.antiTimer) > 1) {
  6250. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6251. tmpObj.canEmpAnti = true;
  6252. } else {
  6253. player.soldierAnti = true;
  6254. }
  6255. tmpObj.antiTimer = game.tick;
  6256. let shame = tmpObj.weapons[0] == 4 ? 2 : 5;
  6257. if (tmpObj.shameCount < shame) {
  6258. healer();
  6259. } else {
  6260. game.tickBase(() => {
  6261. healer();
  6262. }, 2);
  6263. }
  6264. }
  6265. if (damaged >= 20 && player.skinIndex == 11 && player.shameCount <= 3) instaC.canCounter = true;
  6266. } else {
  6267. game.tickBase(() => {
  6268. healer();
  6269. }, 2);
  6270. }
  6271. //if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6272. }
  6273. // if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6274. } else {
  6275. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 19 && tmpObj.damaged == 2))) {
  6276. tmpObj.setPoisonTick = true;
  6277. }
  6278. }
  6279. }
  6280. }
  6281. }
  6282.  
  6283. // KILL PLAYER:
  6284. function killPlayer() {
  6285. inGame = false;
  6286. lastDeath = {
  6287. x: player.x,
  6288. y: player.y,
  6289. };
  6290. }
  6291.  
  6292. // UPDATE PLAYER ITEM VALUES:
  6293. function updateItemCounts(index, value) {
  6294. if (player) {
  6295. player.itemCounts[index] = value;
  6296. updateItemCountDisplay(index);
  6297. }
  6298. }
  6299.  
  6300. // UPDATE AGE:
  6301. function updateAge(xp, mxp, age) {
  6302. if (xp != undefined)
  6303. player.XP = xp;
  6304. if (mxp != undefined)
  6305. player.maxXP = mxp;
  6306. if (age != undefined)
  6307. player.age = age;
  6308. }
  6309.  
  6310. // UPDATE UPGRADES:
  6311. function updateUpgrades(points, age) {
  6312. player.upgradePoints = points;
  6313. player.upgrAge = age;
  6314. if (points > 0) {
  6315. tmpList.length = 0;
  6316. UTILS.removeAllChildren(upgradeHolder);
  6317. for (let i = 0; i < items.weapons.length; ++i) {
  6318. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6319. let e = UTILS.generateElement({
  6320. id: "upgradeItem" + i,
  6321. class: "actionBarItem",
  6322. onmouseout: function() {
  6323. showItemInfo();
  6324. },
  6325. parent: upgradeHolder
  6326. });
  6327. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6328. tmpList.push(i);
  6329. }
  6330. }
  6331. for (let i = 0; i < items.list.length; ++i) {
  6332. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6333. let tmpI = (items.weapons.length + i);
  6334. let e = UTILS.generateElement({
  6335. id: "upgradeItem" + tmpI,
  6336. class: "actionBarItem",
  6337. onmouseout: function() {
  6338. showItemInfo();
  6339. },
  6340. parent: upgradeHolder
  6341. });
  6342. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6343. tmpList.push(tmpI);
  6344. }
  6345. }
  6346. for (let i = 0; i < tmpList.length; i++) {
  6347. (function(i) {
  6348. let tmpItem = getEl('upgradeItem' + i);
  6349. // tmpItem.onmouseover = function() {
  6350. // if (items.weapons[i]) {
  6351. // showItemInfo(items.weapons[i], true);
  6352. // } else {
  6353. // showItemInfo(items.list[i - items.weapons.length]);
  6354. // }
  6355. // };
  6356. tmpItem.onclick = UTILS.checkTrusted(function() {
  6357. packet("H", i);
  6358. });
  6359. UTILS.hookTouchEvents(tmpItem);
  6360. })(tmpList[i]);
  6361. }
  6362. if (tmpList.length) {
  6363. upgradeHolder.style.display = "block";
  6364. upgradeCounter.style.display = "block";
  6365. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6366. } else {
  6367. upgradeHolder.style.display = "none";
  6368. upgradeCounter.style.display = "none";
  6369. showItemInfo();
  6370. }
  6371. } else {
  6372. upgradeHolder.style.display = "none";
  6373. upgradeCounter.style.display = "none";
  6374. showItemInfo();
  6375. }
  6376. }
  6377.  
  6378. // KILL OBJECT:
  6379. function killObject(sid) {
  6380. let findObj = findObjectBySid(sid);
  6381. objectManager.disableBySid(sid);
  6382. if (player) {
  6383. for (let i = 0; i < breakObjects.length; i++) {
  6384. if (breakObjects[i].sid == sid) {
  6385. breakObjects.splice(i, 1);
  6386. break;
  6387. }
  6388. }
  6389. if (!player.canSee(findObj)) {
  6390. breakTrackers.push({
  6391. x: findObj.x,
  6392. y: findObj.y
  6393. });
  6394. }
  6395. if (breakTrackers.length > 8) {
  6396. breakTrackers.shift();
  6397. }
  6398. traps.replacer(findObj);
  6399. }
  6400. }
  6401.  
  6402. // KILL ALL OBJECTS BY A PLAYER:
  6403. function killObjects(sid) {
  6404. if (player) objectManager.removeAllItems(sid);
  6405. }
  6406. function setTickout(doo, timeout) {
  6407. if (!ticks.manage[ticks.tick + timeout]) {
  6408. ticks.manage[ticks.tick + timeout] = [doo];
  6409. } else {
  6410. ticks.manage[ticks.tick + timeout].push(doo);
  6411. }
  6412. }
  6413.  
  6414. function caf(e, t) {
  6415. try {
  6416. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6417. } catch (e) {
  6418. return 0;
  6419. }
  6420. }
  6421.  
  6422. let found = false;
  6423. let autoQ = false;
  6424.  
  6425. let autos = {
  6426. insta: {
  6427. todo: false,
  6428. wait: false,
  6429. count: 4,
  6430. shame: 5
  6431. },
  6432. bull: false,
  6433. antibull: 0,
  6434. reloaded: false,
  6435. stopspin: true
  6436. }
  6437.  
  6438. // UPDATE PLAYER DATA:
  6439. function updatePlayers(data) { //bulltick
  6440. if(player.shameCount > 1) {
  6441. buyEquip(7, 0);
  6442. buyEquip(19, 1);
  6443. } else {
  6444. if(player.lastshamecount != 1 || player.lastshamecount != 2 || player.lastshamecount != 3 || player.lastshamecount != 4 || player.lastshamecount != 5 || player.lastshamecount != 6 || player.lastshamecount == 0) {
  6445. buyEquip(6, 0);
  6446. }
  6447. }
  6448.  
  6449.  
  6450. // let movementPrediction = {
  6451. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6452. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6453. // }
  6454.  
  6455. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6456.  
  6457. // potentialzpiketick.forEach((obj) => {
  6458. // if(cdf(obj, player) <= 200) {
  6459. // packet('a', undefined);
  6460. // }
  6461. // })
  6462.  
  6463. // let newPos = {
  6464. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6465. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6466. // }
  6467.  
  6468. function getAngleDifference(angle1, angle2) {
  6469. // Normalize the angles to be between 0 and 2π
  6470. angle1 = angle1 % (2 * Math.PI);
  6471. angle2 = angle2 % (2 * Math.PI);
  6472.  
  6473. // Calculate the absolute difference between the angles
  6474. let diff = Math.abs(angle1 - angle2);
  6475.  
  6476. // Adjust the difference to be between 0 and π
  6477. if (diff > Math.PI) {
  6478. diff = (2 * Math.PI) - diff;
  6479. }
  6480.  
  6481. return diff;
  6482. }
  6483.  
  6484. // function smartMove(oneTickMove) {
  6485. // let dir = player.moveDir;
  6486.  
  6487. // let found = false
  6488. // 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))
  6489. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6490.  
  6491. // let newPos = {
  6492. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6493. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6494. // }
  6495.  
  6496. // for (let i = 0; i < spikes.length; i++) {
  6497. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6498. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6499. // }
  6500. // }
  6501.  
  6502.  
  6503.  
  6504.  
  6505.  
  6506. // if (found != false && !traps.inTrap) {
  6507. // packet("a", undefined);
  6508. // } else {
  6509. // packet("a", dir);
  6510. // }
  6511. // player.oldPos.x2 = player.x2;
  6512. // player.oldPos.y2 = player.y2;
  6513. // }
  6514. // function detectEnemySpikeCollisions(tmpObj) {
  6515. // 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));
  6516. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6517. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6518. // let enemy = {
  6519. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6520. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6521. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6522. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6523. // }
  6524. // let found = false;
  6525. // for (let i = 0; i < spikes.length; i++) {
  6526. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6527. // found = true;
  6528. // }
  6529. // }
  6530.  
  6531. // // player.oldPos.x2 = tmpObj.x2;
  6532. // // player.oldPos.y2 = tmpObj.y2;
  6533. // }
  6534.  
  6535. game.tick++;
  6536. enemy = [];
  6537. nears = [];
  6538. near = [];
  6539. game.tickSpeed = performance.now() - game.lastTick;
  6540. game.lastTick = performance.now();
  6541. players.forEach((tmp) => {
  6542. tmp.forcePos = !tmp.visible;
  6543. tmp.visible = false;
  6544. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6545. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6546. });
  6547. for (let i = 0; i < data.length;) {
  6548. tmpObj = findPlayerBySID(data[i]);
  6549. if (tmpObj) {
  6550. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6551. tmpObj.t2 = game.lastTick;
  6552. tmpObj.oldPos.x2 = tmpObj.x2;
  6553. tmpObj.oldPos.y2 = tmpObj.y2;
  6554. tmpObj.x1 = tmpObj.x;
  6555. tmpObj.y1 = tmpObj.y;
  6556. tmpObj.x2 = data[i + 1];
  6557. tmpObj.y2 = data[i + 2];
  6558. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6559. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6560. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6561. tmpObj.d2 = data[i + 3];
  6562. tmpObj.dt = 0;
  6563. tmpObj.buildIndex = data[i + 4];
  6564. tmpObj.weaponIndex = data[i + 5];
  6565. tmpObj.weaponVariant = data[i + 6];
  6566. tmpObj.team = data[i + 7];
  6567. tmpObj.isLeader = data[i + 8];
  6568. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6569. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6570. tmpObj.skinIndex = data[i + 9];
  6571. tmpObj.tailIndex = data[i + 10];
  6572. tmpObj.iconIndex = data[i + 11];
  6573. tmpObj.zIndex = data[i + 12];
  6574. tmpObj.visible = true;
  6575. tmpObj.update(game.tickSpeed);
  6576. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6577. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6578. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6579. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6580. tmpObj.damageThreat = 0;
  6581. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6582. tmpObj.addShameTimer();
  6583. }
  6584. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6585. tmpObj.shameTimer = 0;
  6586. tmpObj.shameCount = 0;
  6587. if (tmpObj == player) {
  6588. healer();
  6589. }
  6590. }
  6591.  
  6592. botSkts.forEach((bot) => {
  6593. bot.showName = 'YEAHHH'
  6594. })
  6595.  
  6596. for(let i = 0; i < players.length; i++) {
  6597. for(let aa = 0; aa < botSkts.length; aa++) {
  6598. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6599.  
  6600. }
  6601. }
  6602.  
  6603. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6604. autoQ = true;
  6605. healer();
  6606. } else {
  6607. if (autoQ) {
  6608. healer();
  6609. }
  6610. autoQ = false;
  6611. }
  6612.  
  6613.  
  6614. if (tmpObj == player) {
  6615. if (liztobj.length) {
  6616. liztobj.forEach((tmp) => {
  6617. tmp.onNear = false;
  6618. if (tmp.active) {
  6619. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6620. tmp.onNear = true;
  6621. }
  6622. if (tmp.isItem && tmp.owner) {
  6623. 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)) {
  6624. tmp.breakObj = true;
  6625. breakObjects.push({
  6626. x: tmp.x,
  6627. y: tmp.y,
  6628. sid: tmp.sid
  6629. });
  6630. }
  6631. }
  6632. }
  6633. });
  6634. 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) {
  6635. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6636. })[0];
  6637. if (nearTrap) {
  6638. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6639. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6640. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6641.  
  6642. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6643. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6644. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6645. traps.inTrap = true;
  6646. traps.info = nearTrap;
  6647. } else {
  6648. traps.inTrap = false;
  6649. traps.info = {};
  6650. }
  6651. } else {
  6652. traps.inTrap = false;
  6653. }
  6654. }
  6655. if (tmpObj.weaponIndex < 9) {
  6656. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6657. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6658. } else if (tmpObj.weaponIndex > 8) {
  6659. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6660. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6661. }
  6662. }
  6663. i += 13;
  6664. }
  6665. if (textManager.stack.length) {
  6666. let stacks = [];
  6667. let notstacks = [];
  6668. let num = 0;
  6669. let num2 = 0;
  6670. let pos = {
  6671. x: null,
  6672. y: null
  6673. };
  6674. let pos2 = {
  6675. x: null,
  6676. y: null
  6677. }
  6678. textManager.stack.forEach((text) => {
  6679. if (text.value >= 0) {
  6680. if (num == 0) pos = {
  6681. x: text.x,
  6682. y: text.y
  6683. };
  6684. num += Math.abs(text.value);
  6685. } else {
  6686. if (num2 == 0) pos2 = {
  6687. x: text.x,
  6688. y: text.y
  6689. };
  6690. num2 += Math.abs(text.value);
  6691. }
  6692. });
  6693. if (num2 > 0) {
  6694. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  6695. }
  6696. if (num > 0) {
  6697. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6698. }
  6699. textManager.stack = [];
  6700. }
  6701. if (runAtNextTick.length) {
  6702. runAtNextTick.forEach((tmp) => {
  6703. checkProjectileHolder(...tmp);
  6704. });
  6705. runAtNextTick = [];
  6706. }
  6707. for (let i = 0; i < data.length;) {
  6708. tmpObj = findPlayerBySID(data[i]);
  6709. if (tmpObj) {
  6710. if (!tmpObj.isTeam(player)) {
  6711. enemy.push(tmpObj);
  6712. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6713. nears.push(tmpObj);
  6714. }
  6715. }
  6716. tmpObj.manageReload();
  6717. if (tmpObj != player) {
  6718. tmpObj.addDamageThreat(player);
  6719. }
  6720. }
  6721. i += 13;
  6722. }
  6723. /*projectiles.forEach((proj) => {
  6724. tmpObj = proj;
  6725. if (tmpObj.active) {
  6726. tmpObj.tickUpdate(game.tickSpeed);
  6727. }
  6728. });*/
  6729. if (player && player.alive) {
  6730. if (enemy.length) {
  6731. near = enemy.sort(function(tmp1, tmp2) {
  6732. return tmp1.dist2 - tmp2.dist2;
  6733. })[0];
  6734. } else {
  6735. // console.log("no enemy");
  6736. }
  6737. if (game.tickQueue[game.tick]) {
  6738. game.tickQueue[game.tick].forEach((action) => {
  6739. action();
  6740. });
  6741. game.tickQueue[game.tick] = null;
  6742. }
  6743. players.forEach((tmp) => {
  6744. if (!tmp.visible && player != tmp) {
  6745. tmp.reloads = {
  6746. 0: 0,
  6747. 1: 0,
  6748. 2: 0,
  6749. 3: 0,
  6750. 4: 0,
  6751. 5: 0,
  6752. 6: 0,
  6753. 7: 0,
  6754. 8: 0,
  6755. 9: 0,
  6756. 10: 0,
  6757. 11: 0,
  6758. 12: 0,
  6759. 13: 0,
  6760. 14: 0,
  6761. 15: 0,
  6762. 53: 0,
  6763. };
  6764. }
  6765. if (tmp.setBullTick) {
  6766. tmp.bullTimer = 0;
  6767. }
  6768. if (tmp.setPoisonTick) {
  6769. tmp.poisonTimer = 0;
  6770. }
  6771. tmp.updateTimer();
  6772. });
  6773. if (inGame) {
  6774. if (enemy.length) {
  6775. if (player.canEmpAnti) {
  6776. player.canEmpAnti = false;
  6777. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6778. if (near.reloads[53] == 0) {
  6779. player.empAnti = true;
  6780. player.soldierAnti = false;
  6781. //modLog("EmpAnti");
  6782. } else {
  6783. player.empAnti = false;
  6784. player.soldierAnti = true;
  6785. //modLog("SoldierAnti");
  6786. }
  6787. }
  6788. }
  6789. 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) {
  6790. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6791. })[0];
  6792. if (prehit) {
  6793. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6794. instaC.canSpikeTick = true;
  6795. instaC.syncHit = true;
  6796. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6797. instaC.revTick = true;
  6798. }
  6799. }
  6800. }
  6801. 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) {
  6802. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6803. })[0];
  6804. if (antiSpikeTick && !traps.inTrap) {
  6805. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  6806. my.anti0Tick = 1;
  6807. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  6808. //player.chat.count = 2000;
  6809. }
  6810. }
  6811. }
  6812. 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 == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) && instaC.perfCheck(player, near)) {
  6813. if (player.checkCanInsta(true) >= 100) {
  6814. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6815. } else {
  6816. instaC.nobull = false;
  6817. }
  6818. instaC.can = true;
  6819. } else {
  6820. instaC.can = false;
  6821. }
  6822. macro.q && place(0, getAttackDir());
  6823. macro.f && place(4, getSafeDir());
  6824. macro.v && place(2, getSafeDir());
  6825. macro.y && place(5, getSafeDir());
  6826. macro.h && place(player.getItemType(22), getSafeDir());
  6827. macro.n && place(3, getSafeDir());
  6828. if (game.tick % 1 == 0) {
  6829. if (mills.place) {
  6830. let plcAng = 7.7;
  6831. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6832. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6833. }
  6834. } else {
  6835. if (mills.placeSpawnPads) {
  6836. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6837. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6838. }
  6839. }
  6840. }
  6841. }
  6842. if (instaC.can) {
  6843. instaC.changeType(player.weapons[1] == 10 ? "rev" : "normal");
  6844. }
  6845. if (instaC.canCounter) {
  6846. instaC.canCounter = false;
  6847. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6848. instaC.counterType();
  6849. }
  6850. }
  6851. if (instaC.canSpikeTick) {
  6852. instaC.canSpikeTick = false;
  6853. if (instaC.revTick) {
  6854. instaC.revTick = false;
  6855. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6856. instaC.changeType("rev");
  6857. chch(null, "[RevSyncHit]", "yellow");
  6858. }
  6859. } else {
  6860. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6861. instaC.spikeTickType();
  6862. if (instaC.syncHit) {
  6863. chch(null, "[SyncHit]", "yellow");
  6864. }
  6865. }
  6866. }
  6867. }
  6868. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6869. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6870. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6871. }
  6872. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6873. sendAutoGather();
  6874. my.waitHit = 1;
  6875. game.tickBase(() => {
  6876. sendAutoGather();
  6877. my.waitHit = 0;
  6878. }, 1);
  6879. }
  6880. }
  6881. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6882. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6883. selectWeapon(player.weapons[0]);
  6884. }
  6885. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6886. sendAutoGather();
  6887. my.waitHit = 1;
  6888. game.tickBase(() => {
  6889. sendAutoGather();
  6890. my.waitHit = 0;
  6891. }, 1);
  6892. }
  6893. }
  6894. if (traps.inTrap) {
  6895. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6896. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6897. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6898. }
  6899. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6900. sendAutoGather();
  6901. my.waitHit = 1;
  6902. game.tickBase(() => {
  6903. sendAutoGather();
  6904. my.waitHit = 0;
  6905. }, 1);
  6906. }
  6907. }
  6908. }
  6909. if (clicks.middle && !traps.inTrap) {
  6910. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6911. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6912. instaC.bowMovement();
  6913. } else {
  6914. instaC.rangeType();
  6915. }
  6916. }
  6917. }
  6918. if (macro.t && !traps.inTrap) {
  6919. 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))) {
  6920. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6921. }
  6922. }
  6923. if (macro["."] && !traps.inTrap) {
  6924. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6925. instaC.boostTickMovement();
  6926. }
  6927. }
  6928. 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)) {
  6929. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6930. if (!my.reloaded) {
  6931. my.reloaded = true;
  6932. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6933. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6934. selectWeapon(player.weapons[fastSpeed]);
  6935. }
  6936. }
  6937. // if(useWasd) {
  6938. // if (!autos.stopspin) {
  6939. // setTimeout(()=>{
  6940. // autos.stopspin = true;
  6941. // }, 375);
  6942. // }
  6943. // }
  6944. } else {
  6945. my.reloaded = false;
  6946. if(useWasd) {
  6947. autos.stopspin = false;
  6948. }
  6949. if (player.reloads[player.weapons[0]] > 0) {
  6950. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6951. selectWeapon(player.weapons[0]);
  6952. }
  6953. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6954. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6955. selectWeapon(player.weapons[1]);
  6956. }
  6957. if(useWasd) {
  6958. if (!autos.stopspin) {
  6959. setTimeout(()=>{
  6960. autos.stopspin = true;
  6961. }, 750);
  6962. }
  6963. }
  6964. }
  6965. }
  6966. }
  6967. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6968. traps.autoPlace();
  6969. }
  6970. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6971. packet("D", getAttackDir());
  6972. }
  6973. let hatChanger = function () {
  6974. if (clicks.left || clicks.right) {
  6975. if (clicks.left) {
  6976. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  6977. } else if (clicks.right) {
  6978. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  6979. }
  6980. } else {
  6981.  
  6982.  
  6983. if (clicks.left || clicks.right) {
  6984. if (
  6985. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  6986. ((near && near.dist2 > 120) || !near)
  6987. ) {
  6988. } else {
  6989. if (clicks.left) {
  6990. buyEquip(
  6991. player.reloads[player.weapons[0]] == 0
  6992. ? getEl('weaponGrind').checked
  6993. ? 40
  6994. : 7
  6995. : player.empAnti
  6996. ? 22
  6997. : player.soldierAnti
  6998. ? 6
  6999. : getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7000. ? 11
  7001. : near.dist2 <= 300
  7002. ? getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7003. ? 11
  7004. : 6
  7005. : biomeGear(1, 1),
  7006. 0
  7007. );
  7008. } else if (clicks.right) {
  7009. buyEquip(
  7010. player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0
  7011. ? 40
  7012. : player.empAnti
  7013. ? 22
  7014. : player.soldierAnti
  7015. ? 6
  7016. : getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7017. ? 11
  7018. : near.dist2 <= 300
  7019. ? getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7020. ? 11
  7021. : 6
  7022. : biomeGear(1, 1),
  7023. 0
  7024. );
  7025. }
  7026. }
  7027. } else if (traps.inTrap) {
  7028. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) { //autobreaker
  7029. buyEquip(40, 0);
  7030. buyEquip(19, 1);
  7031. } else {
  7032. if (
  7033. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7034. ((near && near.dist2 > 140) || !near)
  7035. ) {
  7036. }
  7037. }
  7038. } else {
  7039. if (
  7040. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7041. ((near && near.dist2 > 140) || !near)
  7042. ) {
  7043. } else {
  7044. if (near.dist2 <= 300) {
  7045. buyEquip(
  7046. getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7047. ? 11
  7048. : getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7049. ? 11
  7050. : 6,
  7051. 0
  7052. );
  7053. } else {
  7054. biomeGear(1);
  7055. }
  7056. }
  7057. }
  7058. }
  7059. };
  7060.  
  7061.  
  7062. let accChanger = function() {
  7063. if (instaC.can && player.checkCanInsta(true) >= 100) {
  7064. buyEquip(21, 1);
  7065. } else if (clicks.left) {
  7066. setTimeout(() => {
  7067. buyEquip(19, 1);
  7068. }, 50)
  7069. } else if (clicks.right) {
  7070. setTimeout(() => {
  7071. buyEquip(21, 1);
  7072. }, 50)
  7073. } else if (near.dist2 <= 240) {
  7074. buyEquip(19, 1);
  7075. } else {
  7076. traps.inTrap ? buyEquip(19, 1) : buyEquip(11, 1);
  7077. }
  7078. };
  7079. let wasdGears = function() {
  7080. if (my.anti0Tick > 0) {
  7081. buyEquip(6, 0);
  7082. } else {
  7083. if (clicks.left || clicks.right) {
  7084. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7085. buyEquip(7, 0);
  7086. } else {
  7087. if (clicks.left) {
  7088. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7089. } else if (clicks.right) {
  7090. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7091. }
  7092. }
  7093. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7094. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7095. buyEquip(7, 0);
  7096. } else {
  7097. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7098. }
  7099. } else if (traps.inTrap) {
  7100. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7101. buyEquip(40, 0);
  7102. } else {
  7103. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7104. buyEquip(7, 0);
  7105. } else {
  7106. buyEquip(player.empAnti ? 22 : 6, 0);
  7107. }
  7108. }
  7109. } else {
  7110. if (player.empAnti) {
  7111. buyEquip(22, 0);
  7112. } else {
  7113. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7114. buyEquip(7, 0);
  7115. } else {
  7116. buyEquip(6, 0);
  7117. }
  7118. }
  7119. }
  7120. }
  7121. if (clicks.left || clicks.right) {
  7122. if (clicks.left) {
  7123. buyEquip(0, 1);
  7124. } else if (clicks.right) {
  7125. buyEquip(11, 1);
  7126. }
  7127. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7128. buyEquip(0, 1);
  7129. } else if (traps.inTrap) {
  7130. buyEquip(0, 1);
  7131. } else {
  7132. buyEquip(11, 1);
  7133. }
  7134. }
  7135. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7136. if (useWasd) {
  7137. wasdGears();
  7138. } else {
  7139. hatChanger();
  7140. accChanger();
  7141. }
  7142. }
  7143. //lastMoveDir = getSafeDir();
  7144. //packet("a", lastMoveDir, 1);
  7145. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7146. autoPush();
  7147. } else {
  7148. if (my.autoPush) {
  7149. my.autoPush = false;
  7150. packet("a", lastMoveDir || undefined, 1);
  7151. }
  7152. }
  7153. if (instaC.ticking) {
  7154. instaC.ticking = false;
  7155. }
  7156. if (instaC.syncHit) {
  7157. instaC.syncHit = false;
  7158. }
  7159. if (player.empAnti) {
  7160. player.empAnti = false;
  7161. }
  7162. if (player.soldierAnti) {
  7163. player.soldierAnti = false;
  7164. }
  7165. if (my.anti0Tick > 0) {
  7166. my.anti0Tick--;
  7167. }
  7168. if (traps.replaced) {
  7169. traps.replaced = false;
  7170. }
  7171. if (traps.antiTrapped) {
  7172. traps.antiTrapped = false;
  7173. }
  7174.  
  7175. const getPotentialDamage = (build, user) => {
  7176. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7177. const weap = user.weapons[weapIndex];
  7178. if (player.reloads[weap]) return 0;
  7179. const weapon = items.weapons[weap];
  7180. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7181. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7182. };
  7183.  
  7184. const AutoReplace = () => {
  7185. const replaceable = [];
  7186. const playerX = player.x;
  7187. const playerY = player.y;
  7188. const gameObjectCount = gameObjects.length;
  7189.  
  7190. for (let i = 0; i < gameObjectCount; i++) {
  7191. const build = gameObjects[i];
  7192. if (build.isItem && build.active && build.health > 0) {
  7193. const item = items.list[build.id];
  7194. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7195. const inDistance = cdf(build, player) <= posDist * 2;
  7196. if (inDistance) {
  7197. let canDeal = 0;
  7198. const playersCount = players.length;
  7199. for (let j = 0; j < playersCount; j++) {
  7200. canDeal += getPotentialDamage(build, players[j]);
  7201. }
  7202. if (build.health <= canDeal) {
  7203. replaceable.push(build);
  7204. }
  7205. }
  7206. }
  7207. }
  7208.  
  7209. const findPlacementAngle = (player, itemId, build) => {
  7210. if (!build) return null;
  7211. const MAX_ANGLE = 2 * Math.PI;
  7212. const ANGLE_STEP = Math.PI / 360;
  7213. const item = items.list[player.items[itemId]];
  7214. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7215. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7216.  
  7217. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7218. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7219. for (let angle of angles) {
  7220. return angle;
  7221. }
  7222. }
  7223. return null;
  7224. };
  7225.  
  7226. const replace = (() => {
  7227. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7228. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7229. const buildId = spike ? 4 : 2;
  7230.  
  7231. replaceable.forEach(build => {
  7232. let angle = findPlacementAngle(player, buildId, build);
  7233. if (angle !== null) {
  7234. place(buildId, angle);
  7235. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7236. }
  7237. });
  7238. });
  7239.  
  7240. if (near && near.dist3 <= 360) {
  7241. replace();
  7242. }
  7243. replace;
  7244. }
  7245. }
  7246. }
  7247. if (botSkts.length) {
  7248. botSkts.forEach((bots) => {
  7249. if (true) {
  7250. bots[0].showName = 'YEAHHH';
  7251. }
  7252. });
  7253. }
  7254. }
  7255. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7256. if (liztobj[i1].active && liztobj[i1].health > 0 && UTILS.getDist(liztobj[i1], player, 0, 2) < 150 && getEl("antipush").checked) { // || liztobj[i1].buildHealth <= items.weapons[nearEnemy.weaponIndex].dmg)
  7257.  
  7258. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7259. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7260. selectWeapon(player.weapons[1])
  7261. buyEquip(40, 0);
  7262. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7263. setTickout( () => {
  7264. buyEquip(6, 0)
  7265. }, 1);
  7266. }
  7267. }
  7268. }
  7269. }
  7270. function ez(context, x, y) {
  7271. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7272. context.beginPath();
  7273. context.arc(x, y, 55, 0, Math.PI * 2);
  7274. context.fill();
  7275. context.closePath();
  7276. context.globalAlpha = 1;
  7277. }
  7278. // UPDATE LEADERBOARD:
  7279. function updateLeaderboard(data) {
  7280. lastLeaderboardData = data;
  7281. return;
  7282. UTILS.removeAllChildren(leaderboardData);
  7283. let tmpC = 1;
  7284. for (let i = 0; i < data.length; i += 3) {
  7285. (function(i) {
  7286. UTILS.generateElement({
  7287. class: "leaderHolder",
  7288. parent: leaderboardData,
  7289. children: [
  7290. UTILS.generateElement({
  7291. class: "leaderboardItem",
  7292. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7293. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7294. }),
  7295. UTILS.generateElement({
  7296. class: "leaderScore",
  7297. text: UTILS.sFormat(data[i + 2]) || "0"
  7298. })
  7299. ]
  7300. });
  7301. })(i);
  7302. tmpC++;
  7303. }
  7304. }
  7305.  
  7306. // LOAD GAME OBJECT:
  7307. function loadGameObject(data) {
  7308. for (let i = 0; i < data.length;) {
  7309. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7310. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7311. sid: data[i + 7]
  7312. } : null));
  7313. // sid, x, y, dir, s, type, data, setSID, owner
  7314. /*let dist = UTILS.getDist({
  7315. x: data[i + 1],
  7316. y: data[i + 2]
  7317. }, player, 0, 2);
  7318. let aim = UTILS.getDirect({
  7319. x: data[i + 1],
  7320. y: data[i + 2]
  7321. }, player, 0, 2);
  7322. find = findObjectBySid(data[i]);
  7323. if (data[i + 6] == 15) {
  7324. if (find && !find.isTeamObject(player)) {
  7325. if (dist <= 100) {
  7326. traps.dist = dist;
  7327. traps.aim = aim;
  7328. traps.protect(aim);
  7329. }
  7330. }
  7331. }*/
  7332. i += 8;
  7333. }
  7334. }
  7335.  
  7336. // ADD AI:
  7337. function loadAI(data) {
  7338. for (let i = 0; i < ais.length; ++i) {
  7339. ais[i].forcePos = !ais[i].visible;
  7340. ais[i].visible = false;
  7341. }
  7342. if (data) {
  7343. let tmpTime = performance.now();
  7344. for (let i = 0; i < data.length;) {
  7345. tmpObj = findAIBySID(data[i]);
  7346. if (tmpObj) {
  7347. tmpObj.index = data[i + 1];
  7348. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7349. tmpObj.t2 = tmpTime;
  7350. tmpObj.x1 = tmpObj.x;
  7351. tmpObj.y1 = tmpObj.y;
  7352. tmpObj.x2 = data[i + 2];
  7353. tmpObj.y2 = data[i + 3];
  7354. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7355. tmpObj.d2 = data[i + 4];
  7356. tmpObj.health = data[i + 5];
  7357. tmpObj.dt = 0;
  7358. tmpObj.visible = true;
  7359. } else {
  7360. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7361. tmpObj.x2 = tmpObj.x;
  7362. tmpObj.y2 = tmpObj.y;
  7363. tmpObj.d2 = tmpObj.dir;
  7364. tmpObj.health = data[i + 5];
  7365. if (!aiManager.aiTypes[data[i + 1]].name)
  7366. tmpObj.name = config.cowNames[data[i + 6]];
  7367. tmpObj.forcePos = true;
  7368. tmpObj.sid = data[i];
  7369. tmpObj.visible = true;
  7370. }
  7371. i += 7;
  7372. }
  7373. }
  7374. }
  7375.  
  7376. // ANIMATE AI:
  7377. function animateAI(sid) {
  7378. tmpObj = findAIBySID(sid);
  7379. if (tmpObj) tmpObj.startAnim();
  7380. }
  7381.  
  7382. // GATHER ANIMATION:
  7383. function gatherAnimation(sid, didHit, index) {
  7384. tmpObj = findPlayerBySID(sid);
  7385. if (tmpObj) {
  7386. tmpObj.startAnim(didHit, index);
  7387. tmpObj.gatherIndex = index;
  7388. tmpObj.gathering = 1;
  7389.  
  7390. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7391. // healer();
  7392.  
  7393. if (didHit) {
  7394. let tmpObjects = objectManager.hitObj;
  7395. objectManager.hitObj = [];
  7396. game.tickBase(() => {
  7397. // refind
  7398. tmpObj = findPlayerBySID(sid);
  7399. 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);
  7400. tmpObjects.forEach((healthy) => {
  7401. healthy.health -= val;
  7402. });
  7403. }, 1);
  7404. }
  7405. }
  7406. }
  7407. if(nears.filter(near => near.gathering).length>1) {
  7408. player.chat.message = "pSyD";
  7409. healer();
  7410. }
  7411.  
  7412.  
  7413. // WIGGLE GAME OBJECT:
  7414. function wiggleGameObject(dir, sid) {
  7415. tmpObj = findObjectBySid(sid);
  7416. if (tmpObj) {
  7417. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7418. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7419. if (tmpObj.health) {
  7420. objectManager.hitObj.push(tmpObj);
  7421. }
  7422. }
  7423. }
  7424.  
  7425. // SHOOT TURRET:
  7426. function shootTurret(sid, dir) {
  7427. tmpObj = findObjectBySid(sid);
  7428. if (tmpObj) {
  7429. if (config.anotherVisual) {
  7430. tmpObj.lastDir = dir;
  7431. } else {
  7432. tmpObj.dir = dir;
  7433. }
  7434. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7435. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7436. }
  7437. }
  7438.  
  7439. // UPDATE PLAYER VALUE:
  7440. function updatePlayerValue(index, value, updateView) {
  7441. if (player) {
  7442. player[index] = value;
  7443. if (index == "points") {
  7444. if (configs.autoBuy) {
  7445. autoBuy.hat();
  7446. autoBuy.acc();
  7447. }
  7448. } else if (index == "kills") {
  7449. if (configs.killChat) {
  7450. sendChat("gg- AutoGG Oblivion Mod");
  7451. }
  7452. }
  7453. }
  7454. }
  7455.  
  7456.  
  7457. // ACTION BAR:
  7458. function updateItems(data, wpn) {
  7459. if (data) {
  7460. if (wpn) {
  7461. player.weapons = data;
  7462. player.primaryIndex = player.weapons[0];
  7463. player.secondaryIndex = player.weapons[1];
  7464. if (!instaC.isTrue) {
  7465. selectWeapon(player.weapons[0]);
  7466. }
  7467. } else {
  7468. player.items = data;
  7469. }
  7470. }
  7471.  
  7472. for (let i = 0; i < items.list.length; i++) {
  7473. let tmpI = items.weapons.length + i;
  7474. let actionBarItem = getEl("actionBarItem" + tmpI);
  7475. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7476. // Add shadow to the element
  7477. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7478. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7479.  
  7480. }
  7481.  
  7482. for (let i = 0; i < items.weapons.length; i++) {
  7483. let actionBarItem = getEl("actionBarItem" + i);
  7484. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7485. // Add shadow to the element
  7486. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7487. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7488. }
  7489.  
  7490. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7491. if (kms) {
  7492. getEl("actionBarItem3").style.display = "none";
  7493. getEl("actionBarItem4").style.display = "inline-block";
  7494. }
  7495. }
  7496.  
  7497. // ADD PROJECTILE:
  7498. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7499. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7500. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7501. }
  7502.  
  7503. // REMOVE PROJECTILE:
  7504. function remProjectile(sid, range) {
  7505. for (let i = 0; i < projectiles.length; ++i) {
  7506. if (projectiles[i].sid == sid) {
  7507. projectiles[i].range = range;
  7508. let tmpObjects = objectManager.hitObj;
  7509. objectManager.hitObj = [];
  7510. game.tickBase(() => {
  7511. let val = projectiles[i].dmg;
  7512. tmpObjects.forEach((healthy) => {
  7513. if (healthy.projDmg) {
  7514. healthy.health -= val;
  7515. }
  7516. });
  7517. }, 1);
  7518. }
  7519. }
  7520. }
  7521.  
  7522. // lol this useless,,, fr
  7523. let noob = false;
  7524. let serverReady = true;
  7525. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7526. let wssws = isProd ? "wss" : "ws";
  7527. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7528. let withSync = false;
  7529. project.binaryType = "arraybuffer";
  7530. project.onmessage = function(msg) {
  7531. let data = msg.data;
  7532. if (data == "isready") {
  7533. serverReady = true;
  7534. }
  7535. if (data == "fine") {
  7536. noob = false;
  7537. }
  7538.  
  7539. if (data == "tezt") {
  7540. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7541. }
  7542. if (data == "yeswearesyncer") {
  7543. // let delay = Date.now() - wsDelay;
  7544. withSync = true;
  7545. if (player) {
  7546. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7547. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7548. }
  7549. }
  7550. };
  7551.  
  7552. // SHOW ALLIANCE MENU:
  7553. function allianceNotification(sid, name) {
  7554. let findBotSID = findSID(bots, sid);
  7555. if (findBotSID) {}
  7556. }
  7557.  
  7558. function setPlayerTeam(team, isOwner) {
  7559. if (player) {
  7560. player.team = team;
  7561. player.isOwner = isOwner;
  7562. if (team == null)
  7563. alliancePlayers = [];
  7564. }
  7565. }
  7566.  
  7567. function setAlliancePlayers(data) {
  7568. alliancePlayers = data;
  7569. }
  7570.  
  7571. // STORE MENU:
  7572. function updateStoreItems(type, id, index) {
  7573. if (index) {
  7574. if (!type)
  7575. player.tails[id] = 1;
  7576. else {
  7577. player.latestTail = id;
  7578. }
  7579. } else {
  7580. if (!type)
  7581. player.skins[id] = 1,
  7582. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7583. else {
  7584. player.latestSkin = id;
  7585. }
  7586. }
  7587. }
  7588.  
  7589. // SEND MESSAGE:
  7590. function receiveChat(sid, message) {
  7591. let kawaii = false;
  7592. let tmpPlayer = findPlayerBySID(sid);
  7593. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7594. tmpPlayer.chatMessage = message;
  7595. tmpPlayer.chatCountdown = config.chatCountdown;
  7596. }
  7597.  
  7598. // MINIMAP:
  7599. function updateMinimap(data) {
  7600. minimapData = data;
  7601. }
  7602.  
  7603. // SHOW ANIM TEXT:
  7604. function showText(x, y, value, type) {
  7605. // if (config.anotherVisual) {
  7606. textManager.stack.push({
  7607. x: x,
  7608. y: y,
  7609. value: value
  7610. });
  7611. // } else {
  7612. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7613. // }
  7614. }
  7615.  
  7616. /** APPLY SOCKET CODES */
  7617.  
  7618. // BOT:
  7619. let bots = [];
  7620. let ranLocation = {
  7621. x: UTILS.randInt(35, 14365),
  7622. y: UTILS.randInt(35, 14365)
  7623. };
  7624. setInterval(() => {
  7625. ranLocation = {
  7626. x: UTILS.randInt(35, 14365),
  7627. y: UTILS.randInt(35, 14365)
  7628. };
  7629. }, 60000);
  7630. class Bot {
  7631. constructor(id, sid, hats, accessories) {
  7632. this.millPlace = true;
  7633. this.id = id;
  7634. this.sid = sid;
  7635. this.team = null;
  7636. this.skinIndex = 0;
  7637. this.tailIndex = 0;
  7638. this.hitTime = 0;
  7639. this.iconIndex = 0;
  7640. this.enemy = [];
  7641. this.near = [];
  7642. this.dist2 = 0;
  7643. this.aim2 = 0;
  7644. this.tick = 0;
  7645. this.itemCounts = {};
  7646. this.latestSkin = 0;
  7647. this.latestTail = 0;
  7648. this.points = 0;
  7649. this.tails = {};
  7650. for (let i = 0; i < accessories.length; ++i) {
  7651. if (accessories[i].price <= 0)
  7652. this.tails[accessories[i].id] = 1;
  7653. }
  7654. this.skins = {};
  7655. for (let i = 0; i < hats.length; ++i) {
  7656. if (hats[i].price <= 0)
  7657. this.skins[hats[i].id] = 1;
  7658. }
  7659. this.spawn = function(moofoll) {
  7660. this.upgraded = 0;
  7661. this.enemy = [];
  7662. this.near = [];
  7663. this.active = true;
  7664. this.alive = true;
  7665. this.lockMove = false;
  7666. this.lockDir = false;
  7667. this.minimapCounter = 0;
  7668. this.chatCountdown = 0;
  7669. this.shameCount = 0;
  7670. this.shameTimer = 0;
  7671. this.sentTo = {};
  7672. this.gathering = 0;
  7673. this.autoGather = 0;
  7674. this.animTime = 0;
  7675. this.animSpeed = 0;
  7676. this.mouseState = 0;
  7677. this.buildIndex = -1;
  7678. this.weaponIndex = 0;
  7679. this.dmgOverTime = {};
  7680. this.noMovTimer = 0;
  7681. this.maxXP = 300;
  7682. this.XP = 0;
  7683. this.age = 1;
  7684. this.kills = 0;
  7685. this.upgrAge = 2;
  7686. this.upgradePoints = 0;
  7687. this.x = 0;
  7688. this.y = 0;
  7689. this.zIndex = 0;
  7690. this.xVel = 0;
  7691. this.yVel = 0;
  7692. this.slowMult = 1;
  7693. this.dir = 0;
  7694. this.nDir = 0;
  7695. this.dirPlus = 0;
  7696. this.targetDir = 0;
  7697. this.targetAngle = 0;
  7698. this.maxHealth = 100;
  7699. this.health = this.maxHealth;
  7700. this.oldHealth = this.maxHealth;
  7701. this.scale = config.playerScale;
  7702. this.speed = config.playerSpeed;
  7703. this.resetMoveDir();
  7704. this.resetResources(moofoll);
  7705. this.items = [0, 3, 6, 10];
  7706. this.weapons = [0];
  7707. this.shootCount = 0;
  7708. this.weaponXP = [];
  7709. this.isBot = false;
  7710. this.reloads = {
  7711. 0: 0,
  7712. 1: 0,
  7713. 2: 0,
  7714. 3: 0,
  7715. 4: 0,
  7716. 5: 0,
  7717. 6: 0,
  7718. 7: 0,
  7719. 8: 0,
  7720. 9: 0,
  7721. 10: 0,
  7722. 11: 0,
  7723. 12: 0,
  7724. 13: 0,
  7725. 14: 0,
  7726. 15: 0,
  7727. 53: 0,
  7728. };
  7729. this.timeZinceZpawn = 0;
  7730. this.whyDie = "";
  7731. this.clearRadius = false;
  7732. this.circlee = 0;
  7733. };
  7734.  
  7735. // RESET MOVE DIR:
  7736. this.resetMoveDir = function() {
  7737. this.moveDir = undefined;
  7738. };
  7739.  
  7740. // RESET RESOURCES:
  7741. this.resetResources = function(moofoll) {
  7742. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7743. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7744. }
  7745. };
  7746.  
  7747. // SET DATA:
  7748. this.setData = function(data) {
  7749. this.id = data[0];
  7750. this.sid = data[1];
  7751. this.name = data[2];
  7752. this.x = data[3];
  7753. this.y = data[4];
  7754. this.dir = data[5];
  7755. this.health = data[6];
  7756. this.maxHealth = data[7];
  7757. this.scale = data[8];
  7758. this.skinColor = data[9];
  7759. };
  7760.  
  7761.  
  7762. // SHAME SYSTEM:
  7763. this.judgeShame = function() {
  7764. if (this.oldHealth < this.health) {
  7765. if (this.hitTime) {
  7766. let timeSinceHit = this.tick - this.hitTime;
  7767. this.hitTime = 0;
  7768. if (timeSinceHit < 2) {
  7769. this.lastshamecount = this.shameCount;
  7770. this.shameCount++;
  7771. } else {
  7772. this.lastshamecount = this.shameCount;
  7773. this.shameCount = Math.max(0, this.shameCount - 2);
  7774. }
  7775. }
  7776. } else if (this.oldHealth > this.health) {
  7777. this.hitTime = this.tick;
  7778. }
  7779. };
  7780.  
  7781. // UPDATE WEAPON RELOAD:
  7782. this.manageReloadaa = function() {
  7783. if (this.shooting[53]) {
  7784. this.shooting[53] = 0;
  7785. this.reloads[53] = (2500 - 1000/9);
  7786. } else {
  7787. if (this.reloads[53] > 0) {
  7788. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7789. }
  7790. }
  7791. if (this.gathering || this.shooting[1]) {
  7792. if (this.gathering) {
  7793. this.gathering = 0;
  7794. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7795. this.attacked = true;
  7796. }
  7797. if (this.shooting[1]) {
  7798. this.shooting[1] = 0;
  7799. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7800. this.attacked = true;
  7801. }
  7802. } else {
  7803. this.attacked = false;
  7804. if (this.buildIndex < 0) {
  7805. if (this.reloads[this.weaponIndex] > 0) {
  7806. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7807. }
  7808. }
  7809. }
  7810. };
  7811.  
  7812. this.closeSockets = function(websc) {
  7813. websc.close();
  7814. };
  7815.  
  7816. this.whyDieChat = function(websc, whydie) {
  7817. websc.sendWS("6", "why die XDDD " + whydie);
  7818. };
  7819. }
  7820. };
  7821.  
  7822. class BotObject {
  7823. constructor(sid) {
  7824. this.sid = sid;
  7825. // INIT:
  7826. this.init = function(x, y, dir, scale, type, data, owner) {
  7827. data = data || {};
  7828. this.active = true;
  7829. this.x = x;
  7830. this.y = y;
  7831. this.scale = scale;
  7832. this.owner = owner;
  7833. this.id = data.id;
  7834. this.dmg = data.dmg;
  7835. this.trap = data.trap;
  7836. this.teleport = data.teleport;
  7837. this.isItem = this.id != undefined;
  7838. };
  7839.  
  7840. }
  7841. };
  7842. class BotObjManager {
  7843. constructor(botObj, fOS) {
  7844. // DISABLE OBJ:
  7845. this.disableObj = function(obj) {
  7846. obj.active = false;
  7847. if (config.anotherVisual) {} else {
  7848. obj.alive = false;
  7849. }
  7850. };
  7851.  
  7852. // ADD NEW:
  7853. let tmpObj;
  7854. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7855. tmpObj = fOS(sid);
  7856. if (!tmpObj) {
  7857. tmpObj = botObj.find((tmp) => !tmp.active);
  7858. if (!tmpObj) {
  7859. tmpObj = new BotObject(sid);
  7860. botObj.push(tmpObj);
  7861. }
  7862. }
  7863. if (setSID) {
  7864. tmpObj.sid = sid;
  7865. }
  7866. tmpObj.init(x, y, dir, s, type, data, owner);
  7867. };
  7868.  
  7869. // DISABLE BY SID:
  7870. this.disableBySid = function(sid) {
  7871. let find = fOS(sid);
  7872. if (find) {
  7873. this.disableObj(find);
  7874. }
  7875. };
  7876.  
  7877. // REMOVE ALL FROM PLAYER:
  7878. this.removeAllItems = function(sid, server) {
  7879. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7880. };
  7881. }
  7882. };
  7883.  
  7884. let botz = [];
  7885.  
  7886. function botSpawn(id) {
  7887. let bot;
  7888. console.log(WS);
  7889. let t = WS.url.split("wss://")[1].split("?")[0];
  7890. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7891. let botPlayer = new Map();
  7892. botSkts.push([botPlayer]);
  7893. botz.push([bot]);
  7894. let botSID;
  7895. let botObj = [];
  7896. let nearObj = [];
  7897. let bD = {
  7898. x: 0,
  7899. y: 0,
  7900. inGame: false,
  7901. closeSocket: false,
  7902. whyDie: ""
  7903. };
  7904. let oldXY = {
  7905. x: 0,
  7906. y: 0,
  7907. };
  7908. let izauto = 0;
  7909. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7910. bot.binaryType = "arraybuffer";
  7911. bot.first = true;
  7912. bot.sendWS = function(type) {
  7913. // EXTRACT DATA ARRAY:
  7914. let data = Array.prototype.slice.call(arguments, 1);
  7915. // SEND MESSAGE:
  7916. let binary = window.msgpack.encode([type, data]);
  7917. bot.send(binary);
  7918. };
  7919. bot.spawn = function() {
  7920. bot.sendWS("M", {
  7921. name: "unknown1l",
  7922. moofoll: 1,
  7923. skin: "__proto__"
  7924. });
  7925. };
  7926. bot.sendUpgrade = function(index) {
  7927. bot.sendWS("H", index);
  7928. };
  7929. bot.place = function(id, a) {
  7930. try {
  7931. let item = items.list[botPlayer.items[id]];
  7932. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7933. bot.sendWS("G", botPlayer.items[id]);
  7934. bot.sendWS("d", 1, a);
  7935. bot.sendWS("G", botPlayer.weaponIndex, true);
  7936. }
  7937. } catch (e) {
  7938. }
  7939. };
  7940. bot.buye = function(id, index) {
  7941. let nID = 0;
  7942. if (botPlayer.alive && botPlayer.inGame) {
  7943. if (index == 0) {
  7944. if (botPlayer.skins[id]) {
  7945. if (botPlayer.latestSkin != id) {
  7946. bot.sendWS("c", 0, id, 0);
  7947. }
  7948. } else {
  7949. let find = findID(hats, id);
  7950. if (find) {
  7951. if (botPlayer.points >= find.price) {
  7952. bot.sendWS("c", 1, id, 0);
  7953. bot.sendWS("c", 0, id, 0);
  7954. } else {
  7955. if (botPlayer.latestSkin != nID) {
  7956. bot.sendWS("c", 0, nID, 0);
  7957. }
  7958. }
  7959. } else {
  7960. if (botPlayer.latestSkin != nID) {
  7961. bot.sendWS("c", 0, nID, 0);
  7962. }
  7963. }
  7964. }
  7965. } else if (index == 1) {
  7966. if (botPlayer.tails[id]) {
  7967. if (botPlayer.latestTail != id) {
  7968. bot.sendWS("c", 0, id, 1);
  7969. }
  7970. } else {
  7971. let find = findID(accessories, id);
  7972. if (find) {
  7973. if (botPlayer.points >= find.price) {
  7974. bot.sendWS("c", 1, id, 1);
  7975. bot.sendWS("c", 0, id, 1);
  7976. } else {
  7977. if (botPlayer.latestTail != 0) {
  7978. bot.sendWS("c", 0, 0, 1);
  7979. }
  7980. }
  7981. } else {
  7982. if (botPlayer.latestTail != 0) {
  7983. bot.sendWS("c", 0, 0, 1);
  7984. }
  7985. }
  7986. }
  7987. }
  7988. }
  7989. };
  7990. bot.fastGear = function () {
  7991. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7992. bot.buye(31, 0);
  7993. } else {
  7994. if (botPlayer.moveDir == undefined) {
  7995. bot.buye(22, 0);
  7996. } else {
  7997. if (botPlayer.y2 <= config.snowBiomeTop) {
  7998. bot.buye(15, 0);
  7999. } else {
  8000. bot.buye(12, 0);
  8001. }
  8002. }
  8003. }
  8004. };
  8005. bot.selectWeapon = function(a) {
  8006. packet("G", a, 1);
  8007. }
  8008. function caf(e, t) {
  8009. try {
  8010. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8011. } catch (e) {
  8012. return 0;
  8013. }
  8014. }
  8015. bot.heal = function() {
  8016. if (botPlayer.health < 100) {
  8017. bot.place(0, 0)
  8018. }
  8019. }
  8020. function cdf (e, t){
  8021. try {
  8022. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8023. } catch(e){
  8024. return Infinity;
  8025. }
  8026. }
  8027. let zoon = 'no';
  8028. bot.zync = function(a) {
  8029. if (!botPlayer.millPlace) {
  8030. zoon = 'yeah';
  8031. bot.place(5, caf(botPlayer, a));
  8032. let NextTickLocation = {
  8033. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8034. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8035. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8036. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8037. };
  8038.  
  8039. function calculateDistance(x1, y1, x2, y2) {
  8040. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8041. return distance;
  8042. }
  8043. function dotherezt() {
  8044. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8045. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8046. }
  8047.  
  8048. let aa = setInterval(() => {
  8049. bot.sendWS("G", botPlayer.weapons[1], true);
  8050. if (izauto == 0) {
  8051. bot.sendWS("K", 1);
  8052. izauto = 1;
  8053. }
  8054. setTimeout(() => {
  8055. bot.sendWS("G", botPlayer.weapons[0], true);
  8056. }, 2000);
  8057. bot.buye(53, 0);
  8058. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  8059. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  8060. } else {
  8061. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8062. zoon = 'no';
  8063. bot.sendWS("a", undefined);
  8064. dotherezt();
  8065. clearInterval(aa);
  8066. }
  8067. }, 150);
  8068.  
  8069. setTimeout(() => {
  8070. zoon = 'no';
  8071. clearInterval(aa);
  8072. }, 500);
  8073. }
  8074. };
  8075. bot.onmessage = function(message) {
  8076. let data = new Uint8Array(message.data);
  8077. let parsed = window.msgpack.decode(data);
  8078. let type = parsed[0];
  8079. data = parsed[1];
  8080. if (type == "io-init") {
  8081. bot.spawn();
  8082. }
  8083. if (type == "1") {
  8084. botSID = data[0];
  8085. console.log(botSID)
  8086. }
  8087. if (type == "D") {
  8088. if (data[1]) {
  8089. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8090. botPlayer.setData(data[0]);
  8091. botPlayer.inGame = true;
  8092. botPlayer.alive = true;
  8093. botPlayer.x2 = undefined;
  8094. botPlayer.y2 = undefined;
  8095. botPlayer.spawn(1);
  8096. botPlayer.oldHealth = 100;
  8097. botPlayer.health = 100;
  8098. botPlayer.showName = 'YEAHHH';
  8099. oldXY = {
  8100. x: data[0][3],
  8101. y: data[0][4]
  8102. }
  8103. bD.inGame = true;
  8104. if (bot.first) {
  8105. bot.first = false;
  8106. bots.push(bD);
  8107. }
  8108. }
  8109. }
  8110. if (type == "P") {
  8111. bot.spawn();
  8112. botPlayer.inGame = false;
  8113. bD.inGame = false;
  8114. }
  8115. if (type == "a") {
  8116. let tmpData = data[0];
  8117. botPlayer.tick++;
  8118. botPlayer.enemy = [];
  8119. botPlayer.near = [];
  8120. bot.showName = 'YEAHHH';
  8121. nearObj = [];
  8122. for (let i = 0; i < tmpData.length;) {
  8123. if (tmpData[i] == botPlayer.sid) {
  8124. botPlayer.x2 = tmpData[i + 1];
  8125. botPlayer.y2 = tmpData[i + 2];
  8126. botPlayer.d2 = tmpData[i + 3];
  8127. botPlayer.buildIndex = tmpData[i + 4];
  8128. botPlayer.weaponIndex = tmpData[i + 5];
  8129. botPlayer.weaponVariant = tmpData[i + 6];
  8130. botPlayer.team = tmpData[i + 7];
  8131. botPlayer.isLeader = tmpData[i + 8];
  8132. botPlayer.skinIndex = tmpData[i + 9];
  8133. botPlayer.tailIndex = tmpData[i + 10];
  8134. botPlayer.iconIndex = tmpData[i + 11];
  8135. botPlayer.zIndex = tmpData[i + 12];
  8136. botPlayer.visible = true;
  8137. bD.x2 = botPlayer.x2;
  8138. bD.y2 = botPlayer.y2;
  8139. }
  8140. i += 13;
  8141. }
  8142.  
  8143. for (let i = 0; i < tmpData.length;) {
  8144. tmpObj = findPlayerBySID(tmpData[i]);
  8145. if (tmpObj) {
  8146. if (!tmpObj.isTeam(botPlayer)) {
  8147. enemy.push(tmpObj);
  8148. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8149. nears.push(tmpObj);
  8150. }
  8151. }
  8152. }
  8153. i += 13;
  8154. }
  8155.  
  8156. if (enemy.length) {
  8157. //console.log(enemy)
  8158. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8159. return tmp1.dist2 - tmp2.dist2;
  8160. })[0];
  8161. }
  8162.  
  8163. if (izauto == 1) {
  8164. bot.sendWS("K", 1);
  8165. izauto = 0;
  8166. }
  8167.  
  8168. if (bD.closeSocket) {
  8169. botPlayer.closeSockets(bot);
  8170. }
  8171. if (bD.whyDie != "") {
  8172. botPlayer.whyDieChat(bot, bD.whyDie);
  8173. bD.whyDie = "";
  8174. }
  8175. if (botPlayer.alive) {
  8176. if (player.team) {
  8177. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8178. botPlayer.team && (bot.sendWS("N"));
  8179. bot.sendWS("b", player.team);
  8180. }
  8181. }
  8182.  
  8183. let item = items.list[botPlayer.items[3]];
  8184. let a = botPlayer.itemCounts[item.group.id]
  8185. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8186. if (botPlayer.inGame) {
  8187. bot.sendWS("D", botPlayer.moveDir);
  8188. if (izauto == 0) {
  8189. bot.sendWS("K", 1);
  8190. izauto = 1;
  8191. }
  8192. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8193. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8194. bot.place(3, aim + 7.7);
  8195. bot.place(3, aim - 7.7);
  8196. bot.place(3, aim);
  8197. oldXY = {
  8198. x: botPlayer.x2,
  8199. y: botPlayer.y2
  8200. };
  8201. }
  8202.  
  8203. if (botPlayer.tick % 90 === 0) {
  8204. let rand = Math.random() * Math.PI * 2;
  8205. botPlayer.moveDir = rand;
  8206. bot.sendWS("a", botPlayer.moveDir);
  8207. }
  8208. }
  8209. bot.fastGear();
  8210. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  8211. botPlayer.millPlace = false;
  8212. // bot.sendWS("K", 1);
  8213. bot.fastGear();
  8214. } else {
  8215. if (botPlayer.inGame) {
  8216. if (botObj.length > 0) {
  8217. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8218. if (getEl("mode").value == 'fuckemup') {
  8219. // if (getEl("mode").value == "clear") {
  8220. bot.selectWeapon(botPlayer.weapons[1]);
  8221. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8222. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8223. 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) {
  8224. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8225. })[0];
  8226. if (nearObj) {
  8227. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8228. if ((gotoDist - isPassed) > 0) {
  8229. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8230. if (botPlayer.moveDir != undefined) {
  8231. botPlayer.moveDir = undefined;
  8232. bot.sendWS("a", botPlayer.moveDir);
  8233. bot.sendWS("D", botPlayer.nDir);
  8234. }
  8235. } else {
  8236. botPlayer.moveDir = gotoAim;
  8237. bot.sendWS("a", botPlayer.moveDir);
  8238. bot.sendWS("D", botPlayer.nDir);
  8239. }
  8240. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8241. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8242. bot.sendWS("D", botPlayer.nDir);
  8243. }
  8244. if (izauto == 0) {
  8245. bot.sendWS("K", 1);
  8246. izauto = 1;
  8247. }
  8248. bot.buye(40, 0);
  8249. } else {
  8250. botPlayer.moveDir = gotoAim;
  8251. bot.sendWS("a", botPlayer.moveDir);
  8252. bot.sendWS("D", botPlayer.nDir);
  8253. bot.fastGear();
  8254. }
  8255. } else {
  8256. botPlayer.moveDir = gotoAim;
  8257. bot.sendWS("a", botPlayer.moveDir);
  8258. bot.sendWS("D", botPlayer.nDir);
  8259. bot.fastGear();
  8260. }
  8261. }
  8262. }
  8263.  
  8264.  
  8265.  
  8266. if (botObj.length > 0) {
  8267. if (getEl("mode").value == 'flex') {
  8268. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  8269. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  8270. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  8271.  
  8272. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  8273.  
  8274. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  8275. if (dist > 22) // 22 is player speed without booster hat
  8276. return;
  8277. }
  8278. }
  8279.  
  8280.  
  8281. if (botObj.length > 0) {
  8282. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8283. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8284. })[0];
  8285.  
  8286. if (nearObj) {
  8287. if (izauto == 0) {
  8288. bot.sendWS("K", 1);
  8289. izauto = 1;
  8290. }
  8291. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8292. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8293. bot.sendWS("D", botPlayer.nDir);
  8294. }
  8295. bot.buye(40, 0);
  8296. bot.buye(11, 1);
  8297. } else {
  8298. bot.fastGear();
  8299. bot.buye(11, 1);
  8300. }
  8301. bot.buye(11, 1);
  8302. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8303. // if (getEl("mode").value == "clear") {
  8304. bot.selectWeapon(botPlayer.weapons[1]);
  8305. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8306. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8307. 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) {
  8308. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8309. })[0];
  8310. if (nearObj) {
  8311. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8312. if ((gotoDist - isPassed) > 0) {
  8313. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8314. if (botPlayer.moveDir != undefined) {
  8315. botPlayer.moveDir = undefined;
  8316. bot.sendWS("a", botPlayer.moveDir);
  8317. bot.sendWS("D", botPlayer.nDir);
  8318. }
  8319. } else {
  8320. botPlayer.moveDir = gotoAim;
  8321. bot.sendWS("a", botPlayer.moveDir);
  8322. bot.sendWS("D", botPlayer.nDir);
  8323. }
  8324. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8325. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8326. bot.sendWS("D", botPlayer.nDir);
  8327. }
  8328. if (izauto == 0) {
  8329. bot.sendWS("K", 1);
  8330. izauto = 1;
  8331. }
  8332. bot.buye(40, 0);
  8333. bot.fastGear();
  8334. } else {
  8335. botPlayer.moveDir = gotoAim;
  8336. bot.sendWS("a", botPlayer.moveDir);
  8337. bot.sendWS("D", botPlayer.nDir);
  8338. bot.fastGear();
  8339. }
  8340. } else {
  8341. botPlayer.moveDir = gotoAim;
  8342. bot.sendWS("a", botPlayer.moveDir);
  8343. bot.sendWS("D", botPlayer.nDir);
  8344. bot.fastGear();
  8345. }
  8346. if (gotoDist > 300) {
  8347. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8348. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8349. bot.place(3, aim + 7.7);
  8350. bot.place(3, aim - 7.7);
  8351. bot.place(3, aim);
  8352. oldXY = {
  8353. x: botPlayer.x2,
  8354. y: botPlayer.y2
  8355. };
  8356. }
  8357. }
  8358. }
  8359. }
  8360.  
  8361. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8362. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  8363.  
  8364. if(!wdaawdwad.length) {
  8365. if(zoon == 'no')
  8366. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8367. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8368. }
  8369.  
  8370. if(wdaawdwad.length) {
  8371. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8372. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8373. 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) {
  8374. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8375. })[0];
  8376. if (nearObj) {
  8377. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8378. if ((gotoDist - isPassed) > 0) {
  8379. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8380. if (botPlayer.moveDir != undefined) {
  8381. botPlayer.moveDir = undefined;
  8382. bot.sendWS("a", botPlayer.moveDir);
  8383. bot.sendWS("D", botPlayer.nDir);
  8384. }
  8385. } else {
  8386. bot.sendWS("D", botPlayer.nDir);
  8387. }
  8388. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8389. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8390. bot.sendWS("D", botPlayer.nDir);
  8391. }
  8392. if (izauto == 0) {
  8393. bot.sendWS("K", 1);
  8394. izauto = 1;
  8395. }
  8396. bot.buye(40, 0);
  8397. bot.fastGear();
  8398. } else {
  8399. if(zoon == 'no')
  8400. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8401. if(cdf(player, botPlayer) <= 110)
  8402. bot.sendWS("a", undefined);
  8403. else
  8404. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8405. }
  8406. } else {
  8407. if(wdaawdwad.length) {
  8408. if(zoon == 'no')
  8409. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  8410. if(cdf(player, botPlayer) <= 110)
  8411. bot.sendWS("a", undefined);
  8412. else
  8413. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8414. } else {
  8415. if(zoon == 'no')
  8416. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8417. if(cdf(player, botPlayer) <= 110)
  8418. bot.sendWS("a", undefined);
  8419. else
  8420. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8421. }
  8422. }
  8423. }
  8424. }
  8425. }
  8426. }
  8427. }
  8428. }
  8429. if (type == "H") {
  8430. let tmpData = data[0];
  8431. for (let i = 0; i < tmpData.length;) {
  8432. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8433. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8434. sid: tmpData[i + 7]
  8435. } : null));
  8436. i += 8;
  8437. }
  8438. }
  8439. if (type == "N") {
  8440. let index = data[0];
  8441. let value = data[1];
  8442. if (botPlayer) {
  8443. botPlayer[index] = value;
  8444. }
  8445. }
  8446. if (type == "O") {
  8447. if (data[0] == botPlayer.sid) {
  8448. botPlayer.oldHealth = botPlayer.health;
  8449. botPlayer.health = data[1];
  8450. botPlayer.judgeShame();
  8451. if (botPlayer.oldHealth > botPlayer.health) {
  8452. if (botPlayer.shameCount < 5) {
  8453. for (let i = 0; i < 2; i++) {
  8454. bot.place(0, botPlayer.nDir);
  8455. }
  8456.  
  8457. } else {
  8458. setTimeout(() => {
  8459. for (let i = 0; i < 2; i++) {
  8460. bot.place(0, botPlayer.nDir);
  8461. }
  8462. }, 95);
  8463. }
  8464. }
  8465. }
  8466. }
  8467. if (type == "Q") {
  8468. let sid = data[0];
  8469. botObjManager.disableBySid(sid);
  8470. }
  8471. if (type == "R") {
  8472. let sid = data[0];
  8473. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8474. }
  8475. if (type == "S") {
  8476. let index = data[0];
  8477. let value = data[1];
  8478. if (botPlayer) {
  8479. botPlayer.itemCounts[index] = value;
  8480. }
  8481. }
  8482. if (type == "U") {
  8483. if (data[0] > 0) {
  8484. if(getEl("setup").value == 'dm') {
  8485. if (botPlayer.upgraded == 0) {
  8486. bot.sendUpgrade(7);
  8487. } else if (botPlayer.upgraded == 1) {
  8488. bot.sendUpgrade(17);
  8489. } else if (botPlayer.upgraded == 2) {
  8490. bot.sendUpgrade(31);
  8491. } else if (botPlayer.upgraded == 3) {
  8492. bot.sendUpgrade(23);
  8493. } else if (botPlayer.upgraded == 4) {
  8494. bot.sendUpgrade(9);
  8495. } else if (botPlayer.upgraded == 5) {
  8496. bot.sendUpgrade(34);
  8497. } else if (botPlayer.upgraded == 6) {
  8498. bot.sendUpgrade(12);
  8499. } else if (botPlayer.upgraded == 7) {
  8500. bot.sendUpgrade(15);
  8501. }
  8502. } else if(getEl("setup").value == 'dr') {
  8503. if (botPlayer.upgraded == 0) {
  8504. bot.sendUpgrade(7);
  8505. } else if (botPlayer.upgraded == 1) {
  8506. bot.sendUpgrade(17);
  8507. } else if (botPlayer.upgraded == 2) {
  8508. bot.sendUpgrade(31);
  8509. } else if (botPlayer.upgraded == 3) {
  8510. bot.sendUpgrade(23);
  8511. } else if (botPlayer.upgraded == 4) {
  8512. bot.sendUpgrade(9);
  8513. } else if (botPlayer.upgraded == 5) {
  8514. bot.sendUpgrade(34);
  8515. } else if (botPlayer.upgraded == 6) {
  8516. bot.sendUpgrade(12);
  8517. } else if (botPlayer.upgraded == 7) {
  8518. bot.sendUpgrade(13);
  8519. }
  8520. } else if(getEl("setup").value == 'kh') {
  8521. if (botPlayer.upgraded == 0) {
  8522. bot.sendUpgrade(3);
  8523. } else if (botPlayer.upgraded == 1) {
  8524. bot.sendUpgrade(17);
  8525. } else if (botPlayer.upgraded == 2) {
  8526. bot.sendUpgrade(31);
  8527. } else if (botPlayer.upgraded == 3) {
  8528. bot.sendUpgrade(27);
  8529. } else if (botPlayer.upgraded == 4) {
  8530. bot.sendUpgrade(10);
  8531. } else if (botPlayer.upgraded == 5) {
  8532. bot.sendUpgrade(34);
  8533. } else if (botPlayer.upgraded == 6) {
  8534. bot.sendUpgrade(4);
  8535. } else if (botPlayer.upgraded == 7) {
  8536. bot.sendUpgrade(25);
  8537. }
  8538. } else if(getEl("setup").value == 'zd') {
  8539. if (botPlayer.upgraded == 0) {
  8540. bot.sendUpgrade(3);
  8541. } else if (botPlayer.upgraded == 1) {
  8542. bot.sendUpgrade(17);
  8543. } else if (botPlayer.upgraded == 2) {
  8544. bot.sendUpgrade(31);
  8545. } else if (botPlayer.upgraded == 3) {
  8546. bot.sendUpgrade(27);
  8547. } else if (botPlayer.upgraded == 4) {
  8548. bot.sendUpgrade(9);
  8549. } else if (botPlayer.upgraded == 5) {
  8550. bot.sendUpgrade(34);
  8551. } else if (botPlayer.upgraded == 6) {
  8552. bot.sendUpgrade(12);
  8553. } else if (botPlayer.upgraded == 7) {
  8554. bot.sendUpgrade(15);
  8555. }
  8556. }
  8557. botPlayer.upgraded++;
  8558. }
  8559. }
  8560. if (type == "V") {
  8561. let tmpData = data[0];
  8562. let wpn = data[1];
  8563. if (tmpData) {
  8564. if (wpn) botPlayer.weapons = tmpData;
  8565. else botPlayer.items = tmpData;
  8566. }
  8567.  
  8568. }
  8569. if (type == "5") {
  8570. let type = data[0];
  8571. let id = data[1];
  8572. let index = data[2];
  8573. if (index) {
  8574. if (!type)
  8575. botPlayer.tails[id] = 1;
  8576. else
  8577. botPlayer.latestTail = id;
  8578. } else {
  8579. if (!type)
  8580. botPlayer.skins[id] = 1;
  8581. else
  8582. botPlayer.latestSkin = id;
  8583. }
  8584. }
  8585.  
  8586. if (type == "6") {
  8587. let id = data[0];
  8588. let mzg = data[1]+'';
  8589. if(id == player.sid && mzg.includes("syncon")) {
  8590. bot.zync(botPlayer.near);
  8591. }
  8592. }
  8593. };
  8594. bot.onclose = function() {
  8595. botPlayer.inGame = false;
  8596. bD.inGame = false;
  8597. };
  8598. }
  8599.  
  8600. // RENDER LEAF:
  8601. function renderLeaf(x, y, l, r, ctxt) {
  8602. let endX = x + (l * Math.cos(r));
  8603. let endY = y + (l * Math.sin(r));
  8604. let width = l * 0.4;
  8605. ctxt.moveTo(x, y);
  8606. ctxt.beginPath();
  8607. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8608. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8609. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8610. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8611. ctxt.closePath();
  8612. ctxt.fill();
  8613. ctxt.stroke();
  8614. }
  8615.  
  8616. // RENDER CIRCLE:
  8617. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8618. tmpContext = tmpContext || mainContext;
  8619. tmpContext.beginPath();
  8620. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8621. if (!dontFill) tmpContext.fill();
  8622. if (!dontStroke) tmpContext.stroke();
  8623. }
  8624.  
  8625. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8626. tmpContext = tmpContext || mainContext;
  8627. tmpContext.beginPath();
  8628. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8629. if (!dontFill) tmpContext.fill();
  8630. if (!dontStroke) tmpContext.stroke();
  8631. }
  8632.  
  8633. // RENDER STAR SHAPE:
  8634. function renderStar(ctxt, spikes, outer, inner) {
  8635. let rot = Math.PI / 2 * 3;
  8636. let x, y;
  8637. let step = Math.PI / spikes;
  8638. ctxt.beginPath();
  8639. ctxt.moveTo(0, -outer);
  8640. for (let i = 0; i < spikes; i++) {
  8641. x = Math.cos(rot) * outer;
  8642. y = Math.sin(rot) * outer;
  8643. ctxt.lineTo(x, y);
  8644. rot += step;
  8645. x = Math.cos(rot) * inner;
  8646. y = Math.sin(rot) * inner;
  8647. ctxt.lineTo(x, y);
  8648. rot += step;
  8649. }
  8650. ctxt.lineTo(0, -outer);
  8651. ctxt.closePath();
  8652. }
  8653.  
  8654. function renderHealthStar(ctxt, spikes, outer, inner) {
  8655. let rot = Math.PI / 2 * 3;
  8656. let x, y;
  8657. let step = Math.PI / spikes;
  8658. ctxt.beginPath();
  8659. ctxt.moveTo(0, -outer);
  8660. for (let i = 0; i < spikes; i++) {
  8661. x = Math.cos(rot) * outer;
  8662. y = Math.sin(rot) * outer;
  8663. ctxt.lineTo(x, y);
  8664. rot += step;
  8665. x = Math.cos(rot) * inner;
  8666. y = Math.sin(rot) * inner;
  8667. ctxt.lineTo(x, y);
  8668. rot += step;
  8669. }
  8670. ctxt.lineTo(0, -outer);
  8671. ctxt.closePath();
  8672. }
  8673.  
  8674. // RENDER RECTANGLE:
  8675. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8676. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8677. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8678. }
  8679.  
  8680. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8681. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8682. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8683. }
  8684.  
  8685. // RENDER RECTCIRCLE:
  8686. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8687. ctxt.save();
  8688. ctxt.translate(x, y);
  8689. seg = Math.ceil(seg / 2);
  8690. for (let i = 0; i < seg; i++) {
  8691. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8692. ctxt.rotate(Math.PI / seg);
  8693. }
  8694. ctxt.restore();
  8695. }
  8696.  
  8697. // RENDER BLOB:
  8698. function renderBlob(ctxt, spikes, outer, inner) {
  8699. let rot = Math.PI / 2 * 3;
  8700. let x, y;
  8701. let step = Math.PI / spikes;
  8702. let tmpOuter;
  8703. ctxt.beginPath();
  8704. ctxt.moveTo(0, -inner);
  8705. for (let i = 0; i < spikes; i++) {
  8706. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8707. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8708. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8709. rot += step * 2;
  8710. }
  8711. ctxt.lineTo(0, -inner);
  8712. ctxt.closePath();
  8713. }
  8714.  
  8715. // RENDER TRIANGLE:
  8716. function renderTriangle(s, ctx) {
  8717. ctx = ctx || mainContext;
  8718. let h = s * (Math.sqrt(3) / 2);
  8719. ctx.beginPath();
  8720. ctx.moveTo(0, -h / 2);
  8721. ctx.lineTo(-s / 2, h / 2);
  8722. ctx.lineTo(s / 2, h / 2);
  8723. ctx.lineTo(0, -h / 2);
  8724. ctx.fill();
  8725. ctx.closePath();
  8726. }
  8727.  
  8728. // PREPARE MENU BACKGROUND:
  8729. function prepareMenuBackground() {
  8730. // let tmpMid = config.mapScale / 2;
  8731. // let attempts = 0;
  8732. // for (let i = 0; i < items.list.length * 3;) {
  8733. // if (attempts >= 1000) break;
  8734. // attempts++;
  8735. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8736. // let data = {
  8737. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  8738. // y: tmpMid + UTILS.randFloat(-600, 600),
  8739. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8740. // };
  8741. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8742. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8743. // } else {
  8744. // continue;
  8745. // }
  8746. // i++;
  8747. // }
  8748. }
  8749.  
  8750. const speed = 1;
  8751. // RENDER PLAYERS:
  8752. function renderDeadPlayers(xOffset, yOffset) {
  8753. mainContext.fillStyle = "#91b2db";
  8754. const currentTime = Date.now();
  8755. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8756. if (!dead.startTime) {
  8757. dead.startTime = currentTime;
  8758. dead.angle = 0;
  8759. dead.radius = 0.1;
  8760. }
  8761. const timeElapsed = currentTime - dead.startTime;
  8762. const maxAlpha = 1;
  8763. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8764. dead.animate(delta);
  8765. mainContext.globalAlpha = dead.alpha;
  8766. mainContext.strokeStyle = outlineColor;
  8767. mainContext.save();
  8768. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8769. dead.radius -= 0.001;
  8770. dead.angle += 0.0174533;
  8771. const moveSpeed = 1;
  8772. const x = dead.radius * Math.cos(dead.angle);
  8773. const y = dead.radius * Math.sin(dead.angle);
  8774. dead.x += x * moveSpeed;
  8775. dead.y += y * moveSpeed;
  8776. mainContext.rotate(dead.angle);
  8777. renderDeadPlayer(dead, mainContext);
  8778. mainContext.restore();
  8779. mainContext.fillStyle = "#91b2db";
  8780. if (timeElapsed >= 3000) {
  8781. dead.active = false;
  8782. dead.startTime = null;
  8783. }
  8784. });
  8785. }
  8786. // RENDER PLAYERS:
  8787. function renderPlayers(xOffset, yOffset, zIndex) {
  8788. mainContext.globalAlpha = 1;
  8789. mainContext.fillStyle = "#91b2db";
  8790. for (var i = 0; i < players.length; ++i) {
  8791. tmpObj = players[i];
  8792. if (tmpObj.zIndex == zIndex) {
  8793. tmpObj.animate(delta);
  8794. if (tmpObj.visible) {
  8795. tmpObj.skinRot += (0.002 * delta);
  8796. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  8797. mainContext.save();
  8798. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8799. // RENDER PLAYER:
  8800. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8801. renderPlayer(tmpObj, mainContext);
  8802. mainContext.restore();
  8803. }
  8804. }
  8805. }
  8806. }
  8807. // RENDER DEAD PLAYER:
  8808. function renderDeadPlayer(obj, ctxt) {
  8809. ctxt = ctxt || mainContext;
  8810. ctxt.lineWidth = outlineWidth;
  8811. ctxt.lineJoin = "miter";
  8812. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8813. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8814. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8815. // TAIL/CAPE:
  8816. renderTail2(13, ctxt, obj);
  8817. // WEAPON BELLOW HANDS:
  8818. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8819. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8820. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8821. renderProjectile(obj.scale, 0,
  8822. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8823. }
  8824. }
  8825. // HANDS:
  8826. ctxt.fillStyle = "#ececec";
  8827. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8828. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8829. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8830. // WEAPON ABOVE HANDS:
  8831. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8832. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8833. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8834. renderProjectile(obj.scale, 0,
  8835. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8836. }
  8837. }
  8838. // BUILD ITEM:
  8839. if (obj.buildIndex >= 0) {
  8840. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8841. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8842. }
  8843. // BODY:
  8844. renderCircle(0, 0, obj.scale, ctxt);
  8845. // SKIN
  8846. renderSkin2(48, ctxt, null, obj)
  8847. }
  8848.  
  8849. // RENDER PLAYER:
  8850. function renderPlayer(obj, ctxt) {
  8851. ctxt = ctxt || mainContext;
  8852. ctxt.lineWidth = outlineWidth;
  8853. ctxt.lineJoin = "miter";
  8854. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8855. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8856. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8857.  
  8858. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8859.  
  8860. // TAIL/CAPE:
  8861. if (obj.tailIndex > 0) {
  8862. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8863. }
  8864.  
  8865. // WEAPON BELLOW HANDS:
  8866. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8867. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8868. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8869. renderProjectile(obj.scale, 0,
  8870. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8871. }
  8872. }
  8873.  
  8874. // HANDS:
  8875. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8876. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8877. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8878. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8879.  
  8880. // WEAPON ABOVE HANDS:
  8881. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8882. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8883. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8884. renderProjectile(obj.scale, 0,
  8885. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8886. }
  8887. }
  8888.  
  8889. // BUILD ITEM:
  8890. if (obj.buildIndex >= 0) {
  8891. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8892. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8893. }
  8894.  
  8895. // BODY:
  8896. renderCircle(0, 0, obj.scale, ctxt);
  8897.  
  8898. // SKIN:
  8899. if (obj.skinIndex > 0) {
  8900. ctxt.rotate(Math.PI / 2);
  8901. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8902. }
  8903.  
  8904. }
  8905.  
  8906. // RENDER NORMAL SKIN
  8907. var skinSprites2 = {};
  8908. var skinPointers2 = {};
  8909. function renderSkin2(index, ctxt, parentSkin, owner) {
  8910. tmpSkin = skinSprites2[index];
  8911. if (!tmpSkin) {
  8912. var tmpImage = new Image();
  8913. tmpImage.onload = function() {
  8914. this.isLoaded = true;
  8915. this.onload = null;
  8916. };
  8917. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8918. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8919. skinSprites2[index] = tmpImage;
  8920. tmpSkin = tmpImage;
  8921. }
  8922. var tmpObj = parentSkin||skinPointers2[index];
  8923. if (!tmpObj) {
  8924. for (var i = 0; i < hats.length; ++i) {
  8925. if (hats[i].id == index) {
  8926. tmpObj = hats[i];
  8927. break;
  8928. }
  8929. }
  8930. skinPointers2[index] = tmpObj;
  8931. }
  8932. if (tmpSkin.isLoaded)
  8933. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8934. if (!parentSkin && tmpObj.topSprite) {
  8935. ctxt.save();
  8936. ctxt.rotate(owner.skinRot);
  8937. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8938. ctxt.restore();
  8939. }
  8940. }
  8941.  
  8942. // RENDER SKIN:
  8943. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8944. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8945. var tmpImage = new Image();
  8946. tmpImage.onload = function() {
  8947. this.isLoaded = true,
  8948. this.onload = null
  8949. }
  8950. ,
  8951. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8952. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8953. tmpSkin = tmpImage
  8954. }
  8955. var tmpObj = parentSkin||skinPointers[index];
  8956. if (!tmpObj) {
  8957. for (var i = 0; i < hats.length; ++i) {
  8958. if (hats[i].id == index) {
  8959. tmpObj = hats[i];
  8960. break;
  8961. }
  8962. }
  8963. skinPointers[index] = tmpObj;
  8964. }
  8965. if (tmpSkin.isLoaded)
  8966. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8967. if (!parentSkin && tmpObj.topSprite) {
  8968. ctxt.save();
  8969. ctxt.rotate(owner.skinRot);
  8970. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8971. ctxt.restore();
  8972. }
  8973. }
  8974.  
  8975. var FlareZHat = {
  8976. 7: "https://i.imgur.com/vAOzlyY.png",
  8977. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8978. 40: "https://i.imgur.com/Xzmg27N.png",
  8979. 26: "https://i.imgur.com/I0xGtyZ.png",
  8980. 55: "https://i.imgur.com/uYgDtcZ.png",
  8981. 20: "https://i.imgur.com/f5uhWCk.png",
  8982. };
  8983.  
  8984. function setSkinTextureImage(id, type, id2) {
  8985. if (true) {
  8986. if(FlareZHat[id] && type == "hat") {
  8987. return FlareZHat[id];
  8988. } else {
  8989. if(type == "acc") {
  8990. return ".././img/accessories/access_" + id + ".png";
  8991. } else if(type == "hat") {
  8992. return ".././img/hats/hat_" + id + ".png";
  8993. } else {
  8994. return ".././img/weapons/" + id + ".png";
  8995. }
  8996. }
  8997. } else {
  8998. if(type == "acc") {
  8999. return ".././img/accessories/access_" + id + ".png";
  9000. } else if(type == "hat") {
  9001. return ".././img/hats/hat_" + id + ".png";
  9002. } else {
  9003. return ".././img/weapons/" + id + ".png";
  9004. }
  9005. }
  9006. }
  9007. // RENDER SKINS:
  9008. let skinSprites = {};
  9009. let skinPointers = {};
  9010. let tmpSkin;
  9011.  
  9012. function renderSkin(index, ctxt, parentSkin, owner) {
  9013. tmpSkin = skinSprites[index];
  9014. if (!tmpSkin) {
  9015. let tmpImage = new Image();
  9016. tmpImage.onload = function() {
  9017. this.isLoaded = true;
  9018. this.onload = null;
  9019. };
  9020. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9021. skinSprites[index] = tmpImage;
  9022. tmpSkin = tmpImage;
  9023. }
  9024. let tmpObj = parentSkin || skinPointers[index];
  9025. if (!tmpObj) {
  9026. for (let i = 0; i < hats.length; ++i) {
  9027. if (hats[i].id == index) {
  9028. tmpObj = hats[i];
  9029. break;
  9030. }
  9031. }
  9032. skinPointers[index] = tmpObj;
  9033. }
  9034. if (tmpSkin.isLoaded)
  9035. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9036. if (!parentSkin && tmpObj.topSprite) {
  9037. ctxt.save();
  9038. ctxt.rotate(owner.skinRot);
  9039. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9040. ctxt.restore();
  9041. }
  9042. }
  9043.  
  9044. // RENDER TAIL:
  9045. var FlareZAcc = {
  9046. 21: "https://i.imgur.com/4ddZert.png",
  9047. 19: "https://i.imgur.com/sULkUZT.png",
  9048. };
  9049. function setTailTextureImage(id, type, id2) {
  9050. if (true) {
  9051. if(FlareZAcc[id] && type == "acc") {
  9052. return FlareZAcc[id];
  9053. } else {
  9054. if(type == "acc") {
  9055. return ".././img/accessories/access_" + id + ".png";
  9056. } else if(type == "hat") {
  9057. return ".././img/hats/hat_" + id + ".png";
  9058. } else {
  9059. return ".././img/weapons/" + id + ".png";
  9060. }
  9061. }
  9062. } else {
  9063. if(type == "acc") {
  9064. return ".././img/accessories/access_" + id + ".png";
  9065. } else if(type == "hat") {
  9066. return ".././img/hats/hat_" + id + ".png";
  9067. } else {
  9068. return ".././img/weapons/" + id + ".png";
  9069. }
  9070. }
  9071. }
  9072. function renderTailTextureImage(index, ctxt, owner) {
  9073. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  9074. var tmpImage = new Image();
  9075. tmpImage.onload = function() {
  9076. this.isLoaded = true,
  9077. this.onload = null
  9078. }
  9079. ,
  9080. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  9081. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9082. tmpSkin = tmpImage;
  9083. }
  9084. var tmpObj = accessPointers[index];
  9085. if (!tmpObj) {
  9086. for (var i = 0; i < accessories.length; ++i) {
  9087. if (accessories[i].id == index) {
  9088. tmpObj = accessories[i];
  9089. break;
  9090. }
  9091. }
  9092. accessPointers[index] = tmpObj;
  9093. }
  9094. if (tmpSkin.isLoaded) {
  9095. ctxt.save();
  9096. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9097. if (tmpObj.spin)
  9098. ctxt.rotate(owner.skinRot);
  9099. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9100. ctxt.restore();
  9101. }
  9102. }
  9103.  
  9104. let accessSprites = {};
  9105. let accessPointers = {};
  9106. var txt = true;
  9107.  
  9108. function renderTail(index, ctxt, owner) {
  9109. tmpSkin = accessSprites[index];
  9110. if (!tmpSkin) {
  9111. let tmpImage = new Image();
  9112. tmpImage.onload = function() {
  9113. this.isLoaded = true;
  9114. this.onload = null;
  9115. };
  9116. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9117. accessSprites[index] = tmpImage;
  9118. tmpSkin = tmpImage;
  9119. }
  9120. let tmpObj = accessPointers[index];
  9121. if (!tmpObj) {
  9122. for (let i = 0; i < accessories.length; ++i) {
  9123. if (accessories[i].id == index) {
  9124. tmpObj = accessories[i];
  9125. break;
  9126. }
  9127. }
  9128. accessPointers[index] = tmpObj;
  9129. }
  9130. if (tmpSkin.isLoaded) {
  9131. ctxt.save();
  9132. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9133. if (tmpObj.spin)
  9134. ctxt.rotate(owner.skinRot);
  9135. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9136. ctxt.restore();
  9137. }
  9138. }
  9139.  
  9140. var accessSprites2 = {};
  9141. var accessPointers2 = {};
  9142. function renderTail2(index, ctxt, owner) {
  9143. tmpSkin = accessSprites2[index];
  9144. if (!tmpSkin) {
  9145. var tmpImage = new Image();
  9146. tmpImage.onload = function() {
  9147. this.isLoaded = true;
  9148. this.onload = null;
  9149. };
  9150. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9151. accessSprites2[index] = tmpImage;
  9152. tmpSkin = tmpImage;
  9153. }
  9154. var tmpObj = accessPointers2[index];
  9155. if (!tmpObj) {
  9156. for (var i = 0; i < accessories.length; ++i) {
  9157. if (accessories[i].id == index) {
  9158. tmpObj = accessories[i];
  9159. break;
  9160. }
  9161. }
  9162. accessPointers2[index] = tmpObj;
  9163. }
  9164. if (tmpSkin.isLoaded) {
  9165. ctxt.save();
  9166. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9167. if (tmpObj.spin)
  9168. ctxt.rotate(owner.skinRot);
  9169. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9170. ctxt.restore();
  9171. }
  9172. }
  9173.  
  9174. // RENDER TOOL:
  9175. let toolSprites = {};
  9176. function renderTool(obj, variant, x, y, ctxt) {
  9177. let tmpSrc = obj.src + (variant || "");
  9178. let tmpSprite = toolSprites[tmpSrc];
  9179. if (!tmpSprite) {
  9180. tmpSprite = new Image();
  9181. tmpSprite.onload = function() {
  9182. this.isLoaded = true;
  9183. }
  9184. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9185. toolSprites[tmpSrc] = tmpSprite;
  9186. }
  9187. if (tmpSprite.isLoaded)
  9188. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9189. }
  9190.  
  9191. // RENDER PROJECTILES:
  9192. function renderProjectiles(layer, xOffset, yOffset) {
  9193. for (let i = 0; i < projectiles.length; i++) {
  9194. tmpObj = projectiles[i];
  9195. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9196. tmpObj.update(delta);
  9197. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9198. mainContext.save();
  9199. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9200. mainContext.rotate(tmpObj.dir);
  9201. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9202. mainContext.restore();
  9203. }
  9204. }
  9205. };
  9206. }
  9207.  
  9208. // RENDER PROJECTILE:
  9209. let projectileSprites = {};//fz iz zexy
  9210.  
  9211. function renderProjectile(x, y, obj, ctxt, debug) {
  9212. if (obj.src) {
  9213. let tmpSrc = items.projectiles[obj.indx].src;
  9214. let tmpSprite = projectileSprites[tmpSrc];
  9215. if (!tmpSprite) {
  9216. tmpSprite = new Image();
  9217. tmpSprite.onload = function() {
  9218. this.isLoaded = true;
  9219. }
  9220. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9221. projectileSprites[tmpSrc] = tmpSprite;
  9222. }
  9223. if (tmpSprite.isLoaded)
  9224. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9225. } else if (obj.indx == 1) {
  9226. ctxt.fillStyle = "#939393";
  9227. renderCircle(x, y, obj.scale, ctxt);
  9228. }
  9229. }
  9230.  
  9231. // RENDER AI:
  9232. let aiSprites = {};
  9233.  
  9234. function renderAI(obj, ctxt) {
  9235. let tmpIndx = obj.index;
  9236. let tmpSprite = aiSprites[tmpIndx];
  9237. if (!tmpSprite) {
  9238. let tmpImg = new Image();
  9239. tmpImg.onload = function() {
  9240. this.isLoaded = true;
  9241. this.onload = null;
  9242. };
  9243. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9244. tmpSprite = tmpImg;
  9245. aiSprites[tmpIndx] = tmpSprite;
  9246. }
  9247. if (tmpSprite.isLoaded) {
  9248. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9249. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9250. }
  9251. }
  9252.  
  9253. // RENDER WATER BODIES:
  9254. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9255.  
  9256. // MIDDLE RIVER:
  9257. let tmpW = config.riverWidth + padding;
  9258. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9259. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9260. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9261. }
  9262. }
  9263.  
  9264. // RENDER GAME OBJECTS:
  9265. let gameObjectSprites = {};
  9266.  
  9267. function getResSprite(obj) {
  9268. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  9269. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9270. let tmpSprite = gameObjectSprites[tmpIndex];
  9271. if (!tmpSprite) {
  9272. let blurScale = 6;
  9273. let tmpCanvas = document.createElement("canvas");
  9274. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9275. let tmpContext = tmpCanvas.getContext('2d');
  9276. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9277. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9278. tmpContext.strokeStyle = outlineColor;
  9279. tmpContext.lineWidth = outlineWidth;
  9280. // if (isNight) {
  9281. // tmpContext.shadowBlur = blurScale;
  9282. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9283. // }
  9284. if (obj.type == 0) {
  9285. let tmpScale;
  9286. let tmpCount = 8;
  9287. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  9288. for (let i = 0; i < 2; ++i) {
  9289. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  9290. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9291. tmpContext.fillStyle = !biomeID ? (!i ? "#8d3beb" : "#8d3beb") : (!i ? "#8d3beb" : "#8d3beb");
  9292. tmpContext.fill();
  9293. if (!i) {
  9294. tmpContext.stroke();
  9295. tmpContext.shadowBlur = null;
  9296. tmpContext.shadowColor = null;
  9297. tmpContext.globalAlpha = 1;
  9298. }
  9299. }
  9300. } else if (obj.type == 1) {
  9301. if (biomeID == 2) {
  9302. tmpContext.fillStyle = "#606060";
  9303. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9304. tmpContext.fill();
  9305. tmpContext.stroke();
  9306.  
  9307. //tmpContext.shadowBlur = null;
  9308. //tmpContext.shadowColor = null;
  9309.  
  9310. tmpContext.fillStyle = "#8d3beb";
  9311. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9312. tmpContext.fillStyle = "#8d3beb";
  9313. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9314. } else {
  9315. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9316. tmpContext.fillStyle = biomeID ? "#8d3beb" : "#8d3beb";
  9317. tmpContext.fill();
  9318. tmpContext.stroke();
  9319.  
  9320. //tmpContext.shadowBlur = null;
  9321. //tmpContext.shadowColor = null;
  9322.  
  9323. tmpContext.fillStyle = biomeID ? "#8d3beb" : "#8d3beb";
  9324. let tmpRange;
  9325. let berries = 4;
  9326. let rotVal = (Math.PI * 2) / berries;
  9327. for (let i = 0; i < berries; ++i) {
  9328. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  9329. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9330. UTILS.randInt(10, 12), tmpContext);
  9331. }
  9332. }
  9333. } else if (obj.type == 2 || obj.type == 3) {
  9334. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#8d3beb" : "#8d3beb") : "#8d3beb";
  9335. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9336. tmpContext.fill();
  9337. tmpContext.stroke();
  9338.  
  9339. tmpContext.shadowBlur = null;
  9340. tmpContext.shadowColor = null;
  9341.  
  9342. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#8d3beb" : "#8d3beb") : "#8d3beb";
  9343. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9344. tmpContext.fill();
  9345. }
  9346. tmpSprite = tmpCanvas;
  9347. gameObjectSprites[tmpIndex] = tmpSprite;
  9348. }
  9349. return tmpSprite;
  9350. }
  9351.  
  9352. // GET ITEM SPRITE:
  9353. let itemSprites = [];
  9354.  
  9355. function getItemSprite(obj, asIcon) {
  9356. let tmpSprite = itemSprites[obj.id];
  9357. if (!tmpSprite || asIcon) {
  9358. let blurScale = !asIcon ? 20 : 5;
  9359. let tmpCanvas = document.createElement("canvas");
  9360. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9361. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9362.  
  9363. let tmpContext = tmpCanvas.getContext("2d");
  9364. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9365. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9366. tmpContext.strokeStyle = outlineColor;
  9367. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9368. if (!asIcon) {
  9369. tmpContext.shadowBlur = 8;
  9370. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  9371. }
  9372.  
  9373. if (obj.name == "apple") {
  9374. tmpContext.fillStyle = "#8d3beb";
  9375. renderCircle(0, 0, obj.scale, tmpContext);
  9376. tmpContext.fillStyle = "#89a54c";
  9377. let leafDir = -(Math.PI / 2);
  9378. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9379. 25, leafDir + Math.PI / 2, tmpContext);
  9380. } else if (obj.name == "cookie") {
  9381. tmpContext.fillStyle = "#8d3beb";
  9382. renderCircle(0, 0, obj.scale, tmpContext);
  9383. tmpContext.fillStyle = "#8d3beb";
  9384. let chips = 4;
  9385. let rotVal = (Math.PI * 2) / chips;
  9386. let tmpRange;
  9387. for (let i = 0; i < chips; ++i) {
  9388. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9389. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9390. UTILS.randInt(4, 5), tmpContext, true);
  9391. }
  9392. } else if (obj.name == "cheese") {
  9393. tmpContext.fillStyle = "#8d3beb";
  9394. renderCircle(0, 0, obj.scale, tmpContext);
  9395. tmpContext.fillStyle = "#8d3beb";
  9396. let chips = 4;
  9397. let rotVal = (Math.PI * 2) / chips;
  9398. let tmpRange;
  9399. for (let i = 0; i < chips; ++i) {
  9400. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9401. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9402. UTILS.randInt(4, 5), tmpContext, true);
  9403. }
  9404. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9405. tmpContext.fillStyle = (obj.name == "castle wall") ? "#8d3beb" : (obj.name == "wood wall") ?
  9406. "#8d3beb" : "#8d3beb";
  9407. let sides = (obj.name == "castle wall") ? 4 : 3;
  9408. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9409. tmpContext.fill();
  9410. tmpContext.stroke();
  9411. tmpContext.fillStyle = (obj.name == "castle wall") ? "##8d3beb" : (obj.name == "wood wall") ?
  9412. "##8d3beb" : "##8d3beb";
  9413. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9414. tmpContext.fill();
  9415. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9416. obj.name == "spinning spikes") {
  9417. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#8d3beb" : "#8d3beb";
  9418. let tmpScale = (obj.scale * 0.6);
  9419. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9420. tmpContext.fill();
  9421. tmpContext.stroke();
  9422. tmpContext.fillStyle = "#8d3beb";
  9423. renderCircle(0, 0, tmpScale, tmpContext);
  9424. tmpContext.fillStyle = "#8d3beb";
  9425. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9426. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9427. tmpContext.fillStyle = "#8d3beb";
  9428. renderCircle(0, 0, reScale, tmpContext);
  9429. tmpContext.fillStyle = "#8d3beb";
  9430. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9431. tmpContext.fillStyle = "#8d3beb";
  9432. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9433. } else if (obj.name == "mine") {
  9434. tmpContext.fillStyle = "#8d3beb";
  9435. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9436. tmpContext.fill();
  9437. tmpContext.stroke();
  9438. tmpContext.fillStyle = "#8d3beb";
  9439. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9440. tmpContext.fill();
  9441. } else if (obj.name == "sapling") {
  9442. for (let i = 0; i < 2; ++i) {
  9443. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9444. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9445. tmpContext.fillStyle = (!i ? "#8d3beb" : "#8d3beb");
  9446. tmpContext.fill();
  9447. if (!i) tmpContext.stroke();
  9448. }
  9449. } else if (obj.name == "pit trap") {
  9450. tmpContext.fillStyle = "#8d3beb";
  9451. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9452. tmpContext.fill();
  9453. tmpContext.stroke();
  9454. tmpContext.fillStyle = outlineColor;
  9455. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9456. tmpContext.fill();
  9457. } else if (obj.name == "boost pad") {
  9458. tmpContext.fillStyle = "#8d3beb";
  9459. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9460. tmpContext.fill();
  9461. tmpContext.stroke();
  9462. tmpContext.fillStyle = "#dbd97d";
  9463. renderTriangle(obj.scale * 1, tmpContext);
  9464. } else if (obj.name == "turret") {
  9465. tmpContext.fillStyle = "#8d3beb";
  9466. renderCircle(0, 0, obj.scale, tmpContext);
  9467. tmpContext.fill();
  9468. tmpContext.stroke();
  9469. tmpContext.fillStyle = "#8d3beb";
  9470. let tmpLen = 50;
  9471. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9472. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9473. tmpContext.fill();
  9474. tmpContext.stroke();
  9475. } else if (obj.name == "platform") {
  9476. tmpContext.fillStyle = "#8d3beb";
  9477. let tmpCount = 4;
  9478. let tmpS = obj.scale * 2;
  9479. let tmpW = tmpS / tmpCount;
  9480. let tmpX = -(obj.scale / 2);
  9481. for (let i = 0; i < tmpCount; ++i) {
  9482. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9483. tmpContext.fill();
  9484. tmpContext.stroke();
  9485. tmpX += tmpS / tmpCount;
  9486. }
  9487. } else if (obj.name == "healing pad") {
  9488. tmpContext.fillStyle = "#8d3beb";
  9489. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9490. tmpContext.fill();
  9491. tmpContext.stroke();
  9492. tmpContext.fillStyle = "#8d3beb";
  9493. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9494. } else if (obj.name == "spawn pad") {
  9495. tmpContext.fillStyle = "#8d3beb";
  9496. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9497. tmpContext.fill();
  9498. tmpContext.stroke();
  9499. tmpContext.fillStyle = "#8d3beb";
  9500. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9501. } else if (obj.name == "blocker") {
  9502. tmpContext.fillStyle = "#8d3beb";
  9503. renderCircle(0, 0, obj.scale, tmpContext);
  9504. tmpContext.fill();
  9505. tmpContext.stroke();
  9506. tmpContext.rotate(Math.PI / 4);
  9507. tmpContext.fillStyle = "#8d3beb";
  9508. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9509. } else if (obj.name == "teleporter") {
  9510. tmpContext.fillStyle = "#8d3beb";
  9511. renderCircle(0, 0, obj.scale, tmpContext);
  9512. tmpContext.fill();
  9513. tmpContext.stroke();
  9514. tmpContext.rotate(Math.PI / 4);
  9515. tmpContext.fillStyle = "#8d3beb";
  9516. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9517. }
  9518. tmpSprite = tmpCanvas;
  9519. if (!asIcon)
  9520. itemSprites[obj.id] = tmpSprite;
  9521. }
  9522. return tmpSprite;
  9523. }
  9524.  
  9525. function getItemSprite2(obj, tmpX, tmpY) {
  9526. let tmpContext = mainContext;
  9527. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9528. tmpContext.save();
  9529. tmpContext.translate(tmpX, tmpY);
  9530. tmpContext.rotate(obj.dir);
  9531. tmpContext.strokeStyle = outlineColor;
  9532. tmpContext.lineWidth = outlineWidth;
  9533. if (obj.name == "apple") {
  9534. tmpContext.fillStyle = "#8d3beb";
  9535. renderCircle(0, 0, obj.scale, tmpContext);
  9536. tmpContext.fillStyle = "#89a54c";
  9537. let leafDir = -(Math.PI / 2);
  9538. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9539. 25, leafDir + Math.PI / 2, tmpContext);
  9540. } else if (obj.name == "cookie") {
  9541. tmpContext.fillStyle = "#cca861";
  9542. renderCircle(0, 0, obj.scale, tmpContext);
  9543. tmpContext.fillStyle = "#937c4b";
  9544. let chips = 4;
  9545. let rotVal = (Math.PI * 2) / chips;
  9546. let tmpRange;
  9547. for (let i = 0; i < chips; ++i) {
  9548. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9549. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9550. UTILS.randInt(4, 5), tmpContext, true);
  9551. }
  9552. } else if (obj.name == "cheese") {
  9553. tmpContext.fillStyle = "#f4f3ac";
  9554. renderCircle(0, 0, obj.scale, tmpContext);
  9555. tmpContext.fillStyle = "#c3c28b";
  9556. let chips = 4;
  9557. let rotVal = (Math.PI * 2) / chips;
  9558. let tmpRange;
  9559. for (let i = 0; i < chips; ++i) {
  9560. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9561. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9562. UTILS.randInt(4, 5), tmpContext, true);
  9563. }
  9564. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9565. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9566. "#a5974c" : "#939393";
  9567. let sides = (obj.name == "castle wall") ? 4 : 3;
  9568. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9569. tmpContext.fill();
  9570. tmpContext.stroke();
  9571. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9572. "#8d3beb" : "#bcbcbc";
  9573. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9574. tmpContext.fill();
  9575. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9576. obj.name == "spinning spikes") {
  9577. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#8d3beb" : "#8d3beb";
  9578. let tmpScale = (obj.scale * 0.6);
  9579. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9580. tmpContext.fill();
  9581. tmpContext.stroke();
  9582. tmpContext.fillStyle = "#8d3beb";
  9583. renderCircle(0, 0, tmpScale, tmpContext);
  9584. tmpContext.fillStyle = "#c9b758";
  9585. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9586. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9587. tmpContext.fillStyle = "#8d3beb";
  9588. renderCircle(0, 0, reScale, tmpContext);
  9589. tmpContext.fillStyle = "#8d3beb";
  9590. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9591. tmpContext.fillStyle = "#8d3beb";
  9592. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9593. } else if (obj.name == "mine") {
  9594. tmpContext.fillStyle = "#939393";
  9595. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9596. tmpContext.fill();
  9597. tmpContext.stroke();
  9598. tmpContext.fillStyle = "#bcbcbc";
  9599. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9600. tmpContext.fill();
  9601. } else if (obj.name == "sapling") {
  9602. for (let i = 0; i < 2; ++i) {
  9603. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9604. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9605. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9606. tmpContext.fill();
  9607. if (!i) tmpContext.stroke();
  9608. }
  9609. } else if (obj.name == "pit trap") {
  9610. tmpContext.fillStyle = "#8d3beb";
  9611. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9612. tmpContext.fill();
  9613. tmpContext.stroke();
  9614. tmpContext.fillStyle = outlineColor;
  9615. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9616. tmpContext.fill();
  9617. } else if (obj.name == "boost pad") {
  9618. tmpContext.fillStyle = "#7e7f82";
  9619. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9620. tmpContext.fill();
  9621. tmpContext.stroke();
  9622. tmpContext.fillStyle = "#dbd97d";
  9623. renderTriangle(obj.scale * 1, tmpContext);
  9624. } else if (obj.name == "turret") {
  9625. tmpContext.fillStyle = "#8d3beb";
  9626. renderCircle(0, 0, obj.scale, tmpContext);
  9627. tmpContext.fill();
  9628. tmpContext.stroke();
  9629. tmpContext.fillStyle = "#939393";
  9630. let tmpLen = 50;
  9631. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9632. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9633. tmpContext.fill();
  9634. tmpContext.stroke();
  9635. } else if (obj.name == "platform") {
  9636. tmpContext.fillStyle = "#cebd5f";
  9637. let tmpCount = 4;
  9638. let tmpS = obj.scale * 2;
  9639. let tmpW = tmpS / tmpCount;
  9640. let tmpX = -(obj.scale / 2);
  9641. for (let i = 0; i < tmpCount; ++i) {
  9642. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9643. tmpContext.fill();
  9644. tmpContext.stroke();
  9645. tmpX += tmpS / tmpCount;
  9646. }
  9647. } else if (obj.name == "healing pad") {
  9648. tmpContext.fillStyle = "#7e7f82";
  9649. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9650. tmpContext.fill();
  9651. tmpContext.stroke();
  9652. tmpContext.fillStyle = "#db6e6e";
  9653. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9654. } else if (obj.name == "spawn pad") {
  9655. tmpContext.fillStyle = "#7e7f82";
  9656. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9657. tmpContext.fill();
  9658. tmpContext.stroke();
  9659. tmpContext.fillStyle = "#71aad6";
  9660. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9661. } else if (obj.name == "blocker") {
  9662. tmpContext.fillStyle = "#7e7f82";
  9663. renderCircle(0, 0, obj.scale, tmpContext);
  9664. tmpContext.fill();
  9665. tmpContext.stroke();
  9666. tmpContext.rotate(Math.PI / 4);
  9667. tmpContext.fillStyle = "#db6e6e";
  9668. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9669. } else if (obj.name == "teleporter") {
  9670. tmpContext.fillStyle = "#7e7f82";
  9671. renderCircle(0, 0, obj.scale, tmpContext);
  9672. tmpContext.fill();
  9673. tmpContext.stroke();
  9674. tmpContext.rotate(Math.PI / 4);
  9675. tmpContext.fillStyle = "#d76edb";
  9676. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9677. }
  9678. tmpContext.restore();
  9679. }
  9680.  
  9681. let objSprites = [];
  9682.  
  9683. function getObjSprite(obj) {
  9684. let tmpSprite = objSprites[obj.id];
  9685. if (!tmpSprite) {
  9686. // let blurScale = isNight ? 20 : 0;
  9687. let tmpCanvas = document.createElement("canvas");
  9688. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  9689. let tmpContext = tmpCanvas.getContext("2d");
  9690. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9691. tmpContext.rotate(Math.PI / 2);
  9692. tmpContext.strokeStyle = outlineColor;
  9693. tmpContext.lineWidth = outlineWidth;
  9694. // if (isNight) {
  9695. // tmpContext.shadowBlur = 20;
  9696. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9697. // }
  9698. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9699. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9700. let tmpScale = obj.scale * 0.6;
  9701. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9702. tmpContext.fill();
  9703. tmpContext.stroke();
  9704. tmpContext.fillStyle = "#8d3beb";
  9705. renderCircle(0, 0, tmpScale, tmpContext);
  9706. tmpContext.fillStyle = "#c15555";
  9707. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9708. } else if (obj.name == "pit trap") {
  9709. tmpContext.fillStyle = "#000000";
  9710. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9711. tmpContext.fill();
  9712. tmpContext.stroke();
  9713. tmpContext.fillStyle = "#8d3beb";
  9714. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9715. tmpContext.fill();
  9716. }
  9717. tmpSprite = tmpCanvas;
  9718. objSprites[obj.id] = tmpSprite;
  9719. }
  9720. return tmpSprite;
  9721. }
  9722.  
  9723. // GET MARK SPRITE:
  9724. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9725. let center = {
  9726. x: screenWidth / 2,
  9727. y: screenHeight / 2,
  9728. };
  9729. tmpContext.lineWidth = outlineWidth;
  9730. mainContext.globalAlpha = 0.2;
  9731. tmpContext.strokeStyle = outlineColor;
  9732. tmpContext.save();
  9733. tmpContext.translate(tmpX, tmpY);
  9734. tmpContext.rotate(90**10);
  9735. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9736. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9737. var tmpScale = (obj.scale);
  9738. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9739. tmpContext.fill();
  9740. tmpContext.stroke();
  9741. tmpContext.fillStyle = "#a5974c";
  9742. renderCircle(0, 0, tmpScale, tmpContext);
  9743. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9744. tmpContext.fillStyle = "#a34040";
  9745. } else {
  9746. tmpContext.fillStyle = "#c9b758";
  9747. }
  9748. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9749. } else if (obj.name == "turret") {
  9750. renderCircle(0, 0, obj.scale, tmpContext);
  9751. tmpContext.fill();
  9752. tmpContext.stroke();
  9753. tmpContext.fillStyle = "#8d3beb";
  9754. let tmpLen = 50;
  9755. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9756. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9757. tmpContext.fill();
  9758. tmpContext.stroke();
  9759. } else if (obj.name == "teleporter") {
  9760. tmpContext.fillStyle = "#7e7f82";
  9761. renderCircle(0, 0, obj.scale, tmpContext);
  9762. tmpContext.fill();
  9763. tmpContext.stroke();
  9764. tmpContext.rotate(Math.PI / 4);
  9765. tmpContext.fillStyle = "#d76edb";
  9766. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9767. } else if (obj.name == "platform") {
  9768. tmpContext.fillStyle = "#cebd5f";
  9769. let tmpCount = 4;
  9770. let tmpS = obj.scale * 2;
  9771. let tmpW = tmpS / tmpCount;
  9772. let tmpX = -(obj.scale / 2);
  9773. for (let i = 0; i < tmpCount; ++i) {
  9774. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9775. tmpContext.fill();
  9776. tmpContext.stroke();
  9777. tmpX += tmpS / tmpCount;
  9778. }
  9779. } else if (obj.name == "healing pad") {
  9780. tmpContext.fillStyle = "#7e7f82";
  9781. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9782. tmpContext.fill();
  9783. tmpContext.stroke();
  9784. tmpContext.fillStyle = "#db6e6e";
  9785. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9786. } else if (obj.name == "spawn pad") {
  9787. tmpContext.fillStyle = "#7e7f82";
  9788. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9789. tmpContext.fill();
  9790. tmpContext.stroke();
  9791. tmpContext.fillStyle = "#71aad6";
  9792. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9793. } else if (obj.name == "blocker") {
  9794. tmpContext.fillStyle = "#7e7f82";
  9795. renderCircle(0, 0, obj.scale, tmpContext);
  9796. tmpContext.fill();
  9797. tmpContext.stroke();
  9798. tmpContext.rotate(Math.PI / 4);
  9799. tmpContext.fillStyle = "#db6e6e";
  9800. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9801. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9802. tmpContext.fillStyle = "##8d3beb";
  9803. renderCircle(0, 0, obj.scale, tmpContext);
  9804. tmpContext.fillStyle = "##8d3beb";
  9805. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9806. tmpContext.fillStyle = "##8d3beb";
  9807. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9808.  
  9809. } else if (obj.name == "pit trap") {
  9810. tmpContext.fillStyle = "#000000";
  9811. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9812. tmpContext.fill();
  9813. tmpContext.stroke();
  9814. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9815. tmpContext.fillStyle = "#8d3beb";
  9816. } else {
  9817. tmpContext.fillStyle = outlineColor;
  9818. }
  9819. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9820. tmpContext.fill();
  9821. }
  9822. tmpContext.restore();
  9823. }
  9824.  
  9825. // OBJECT ON SCREEN:
  9826. function isOnScreen(x, y, s) {
  9827. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9828. s,
  9829. maxScreenHeight));
  9830. }
  9831.  
  9832. // RENDER GAME OBJECTS:
  9833. function renderGameObjects(layer, xOffset, yOffset) {
  9834. let tmpSprite;
  9835. let tmpX;
  9836. let tmpY;
  9837. liztobj.forEach((tmp) => {
  9838. tmpObj = tmp;
  9839. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9840. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9841. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9842. if (layer == 0) {
  9843. tmpObj.update(delta);
  9844. }
  9845. mainContext.globalAlpha = tmpObj.alpha;
  9846. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9847. if (tmpObj.isItem) {
  9848. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9849. tmpSprite = getObjSprite(tmpObj);
  9850. } else {
  9851. tmpSprite = getItemSprite(tmpObj);
  9852. }
  9853.  
  9854. mainContext.save();
  9855. mainContext.translate(tmpX, tmpY);
  9856. mainContext.rotate(tmpObj.dir);
  9857. if (!tmpObj.active) {
  9858. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9859. }
  9860. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9861.  
  9862. if (tmpObj.blocker) {
  9863. mainContext.strokeStyle = "#db6e6e";
  9864. mainContext.globalAlpha = 0.3;
  9865. mainContext.lineWidth = 6;
  9866. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9867. }
  9868. mainContext.restore();
  9869. } else {
  9870. tmpSprite = getResSprite(tmpObj);
  9871. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9872. }
  9873. }
  9874. if (layer == 3) {
  9875. if (tmpObj.health < tmpObj.maxHealth) {
  9876. // HEALTH HOLDER:
  9877. mainContext.fillStyle = darkOutlineColor;
  9878. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9879. mainContext.fill();
  9880.  
  9881. // HEALTH BAR:
  9882. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#ad64ed" : "#8d3beb";
  9883. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9884. mainContext.fill();
  9885. }
  9886. }
  9887. }
  9888. });
  9889.  
  9890. // PLACE VISIBLE:
  9891. if (layer == 0) {
  9892. if (placeVisible.length) {
  9893. placeVisible.forEach((places) => {
  9894. tmpX = places.x - xOffset;
  9895. tmpY = places.y - yOffset;
  9896. markObject(places, tmpX, tmpY);
  9897. });
  9898. }
  9899. }
  9900. }
  9901.  
  9902. function markObject(tmpObj, tmpX, tmpY) {
  9903. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9904. }
  9905.  
  9906. // RENDER MINIMAP:
  9907. class MapPing {
  9908. constructor(color, scale) {
  9909. this.init = function(x, y) {
  9910. this.scale = 0;
  9911. this.x = x;
  9912. this.y = y;
  9913. this.active = true;
  9914. };
  9915. this.update = function(ctxt, delta) {
  9916. if (this.active) {
  9917. this.scale += 0.05 * delta;
  9918. if (this.scale >= scale) {
  9919. this.active = false;
  9920. } else {
  9921. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9922. ctxt.beginPath();
  9923. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9924. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9925. ctxt.stroke();
  9926. }
  9927. }
  9928. };
  9929. this.color = color;
  9930. }
  9931. }
  9932.  
  9933. function pingMap(x, y) {
  9934. tmpPing = mapPings.find(pings => !pings.active);
  9935. if (!tmpPing) {
  9936. tmpPing = new MapPing("#fff", config.mapPingScale);
  9937. mapPings.push(tmpPing);
  9938. }
  9939. tmpPing.init(x, y);
  9940. }
  9941.  
  9942. function updateMapMarker() {
  9943. mapMarker.x = player.x;
  9944. mapMarker.y = player.y;
  9945. }
  9946.  
  9947. function renderMinimap(delta) {
  9948. if (player && player.alive) {
  9949. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9950.  
  9951. // RENDER PINGS:
  9952. mapContext.lineWidth = 4;
  9953. for (let i = 0; i < mapPings.length; ++i) {
  9954. tmpPing = mapPings[i];
  9955. mapContext.strokeStyle = tmpPing.color;
  9956. tmpPing.update(mapContext, delta);
  9957. }
  9958.  
  9959. // RENDER BREAK TRACKS:
  9960. mapContext.globalAlpha = 1;
  9961. mapContext.fillStyle = "#ff0000";
  9962. if (breakTrackers.length) {
  9963. mapContext.fillStyle = "#abcdef";
  9964. mapContext.font = "34px Hammersmith One";
  9965. mapContext.textBaseline = "middle";
  9966. mapContext.textAlign = "center";
  9967. for (let i = 0; i < breakTrackers.length;) {
  9968. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9969. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9970. i += 2;
  9971. }
  9972. }
  9973.  
  9974. // RENDER PLAYERS:
  9975. mapContext.globalAlpha = 1;
  9976. mapContext.fillStyle = "#fff";
  9977. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9978. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9979. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9980. if (player.team && minimapData) {
  9981. for (let i = 0; i < minimapData.length;) {
  9982. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9983. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9984. i += 2;
  9985. }
  9986. }
  9987.  
  9988. // RENDER BOTS:
  9989. if (bots.length) {
  9990. bots.forEach((tmp) => {
  9991. if (tmp.inGame) {
  9992. mapContext.globalAlpha = 1;
  9993. mapContext.strokeStyle = "#cc5151";
  9994. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9995. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9996. }
  9997. });
  9998. }
  9999.  
  10000. // DEATH LOCATION:
  10001. if (lastDeath) {
  10002. mapContext.fillStyle = "#fc5553";
  10003. mapContext.font = "34px Hammersmith One";
  10004. mapContext.textBaseline = "middle";
  10005. mapContext.textAlign = "center";
  10006. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10007. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10008. }
  10009.  
  10010. // MAP MARKER:
  10011. if (mapMarker) {
  10012. mapContext.fillStyle = "#fff";
  10013. mapContext.font = "34px Hammersmith One";
  10014. mapContext.textBaseline = "middle";
  10015. mapContext.textAlign = "center";
  10016. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10017. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10018. }
  10019. }
  10020. }
  10021.  
  10022. // ICONS:
  10023. let crossHairs = ["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/newawwddd.png", "https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100px-Crosshairs_Red.png"];
  10024. let crossHairSprites = {};
  10025. let iconSprites = {};
  10026. let icons = ["crown", "skull"];
  10027.  
  10028. function loadIcons() {
  10029. for (let i = 0; i < icons.length; ++i) {
  10030. let tmpSprite = new Image();
  10031. tmpSprite.onload = function() {
  10032. this.isLoaded = true;
  10033. };
  10034. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10035. iconSprites[icons[i]] = tmpSprite;
  10036. }
  10037. for (let i = 0; i < crossHairs.length; ++i) {
  10038. let tmpSprite = new Image();
  10039. tmpSprite.onload = function() {
  10040. this.isLoaded = true;
  10041. };
  10042. tmpSprite.src = crossHairs[i];
  10043. crossHairSprites[i] = tmpSprite;
  10044. }
  10045. }
  10046. loadIcons();
  10047.  
  10048. function cdf (e, t){
  10049. try {
  10050. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  10051. } catch(e){
  10052. return Infinity;
  10053. }
  10054. }
  10055.  
  10056. // UPDATE GAME:
  10057. function updateGame() {
  10058. if(gameObjects.length && inGame) {
  10059. gameObjects.forEach((tmp) => {
  10060. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  10061. if(!liztobj.includes(tmp)) {
  10062. liztobj.push(tmp);
  10063. tmp.render = true;
  10064. }
  10065. } else {
  10066. if(liztobj.includes(tmp)) {
  10067. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10068. tmp.render = false;
  10069. const index = liztobj.indexOf(tmp);
  10070. if (index > -1) { // only splice array when item is found
  10071. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10072. }
  10073. }
  10074. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10075. tmp.render = false;
  10076. const index = liztobj.indexOf(tmp);
  10077. if (index > -1) { // only splice array when item is found
  10078. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10079. }
  10080. } else {
  10081. tmp.render = false;
  10082. const index = liztobj.indexOf(tmp);
  10083. if (index > -1) { // only splice array when item is found
  10084. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10085. }
  10086. }
  10087. }
  10088. })
  10089. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10090. }
  10091.  
  10092. // if (config.resetRender) {
  10093. mainContext.beginPath();
  10094. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10095. // }
  10096. mainContext.globalAlpha = 1;
  10097.  
  10098. // MOVE CAMERA:
  10099. if (player) {
  10100. if (false) {
  10101. camX = player.x;
  10102. camY = player.y;
  10103. } else {
  10104. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10105. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10106. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  10107. if (tmpDist > 0.05) {
  10108. camX += camSpd * Math.cos(tmpDir);
  10109. camY += camSpd * Math.sin(tmpDir);
  10110. } else {
  10111. camX = player.x;
  10112. camY = player.y;
  10113. }
  10114. }
  10115. } else {
  10116. camX = config.mapScale / 2 + config.riverWidth;
  10117. camY = config.mapScale / 2;
  10118. }
  10119.  
  10120. // INTERPOLATE PLAYERS AND AI:
  10121. let lastTime = now - (1000 / config.serverUpdateRate);
  10122. let tmpDiff;
  10123. for (let i = 0; i < players.length + ais.length; ++i) {
  10124. tmpObj = players[i] || ais[i - players.length];
  10125. if (tmpObj && tmpObj.visible) {
  10126. if (tmpObj.forcePos) {
  10127. tmpObj.x = tmpObj.x2;
  10128. tmpObj.y = tmpObj.y2;
  10129. tmpObj.dir = tmpObj.d2;
  10130. } else {
  10131. let total = tmpObj.t2 - tmpObj.t1;
  10132. let fraction = lastTime - tmpObj.t1;
  10133. let ratio = (fraction / total);
  10134. let rate = 170;
  10135. tmpObj.dt += delta;
  10136. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10137. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10138. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10139. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10140. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10141. if (config.anotherVisual) {
  10142. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10143. } else {
  10144. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10145. }
  10146. }
  10147. }
  10148. }
  10149.  
  10150. // RENDER CORDS:
  10151. let xOffset = camX - (maxScreenWidth / 2);
  10152. let yOffset = camY - (maxScreenHeight / 2);
  10153.  
  10154. // RENDER BACKGROUND:
  10155. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10156. mainContext.fillStyle = "#78ad57";
  10157. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10158. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10159. mainContext.fillStyle = "#787156";
  10160. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10161. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10162. mainContext.fillStyle = "#fff";
  10163. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10164. } else if (config.snowBiomeTop - yOffset >= 0) {
  10165. mainContext.fillStyle = "#fff";
  10166. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10167. mainContext.fillStyle = "#787156";
  10168. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10169. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10170. } else {
  10171. mainContext.fillStyle = "#787156";
  10172. mainContext.fillRect(0, 0, maxScreenWidth,
  10173. (config.mapScale - config.snowBiomeTop - yOffset));
  10174. mainContext.fillStyle = "#787156";
  10175. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10176. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10177. }
  10178.  
  10179. // RENDER WATER AREAS:
  10180. if (!firstSetup) {
  10181. waterMult += waterPlus * config.waveSpeed * delta;
  10182. if (waterMult >= config.waveMax) {
  10183. waterMult = config.waveMax;
  10184. waterPlus = -1;
  10185. } else if (waterMult <= 1) {
  10186. waterMult = waterPlus = 1;
  10187. }
  10188. mainContext.globalAlpha = 1;
  10189. mainContext.fillStyle = "#dbc666";
  10190. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10191. mainContext.fillStyle = "#19539c";
  10192. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10193. }
  10194.  
  10195. // RENDER DEAD PLAYERS:
  10196. mainContext.globalAlpha = 1;
  10197. mainContext.strokeStyle = outlineColor;
  10198. renderDeadPlayers(xOffset, yOffset);
  10199.  
  10200. // RENDER BOTTOM LAYER:
  10201. mainContext.globalAlpha = 1;
  10202. mainContext.strokeStyle = outlineColor;
  10203. renderGameObjects(-1, xOffset, yOffset);
  10204.  
  10205. // RENDER PROJECTILES:
  10206. mainContext.globalAlpha = 1;
  10207. mainContext.lineWidth = outlineWidth;
  10208. renderProjectiles(0, xOffset, yOffset);
  10209.  
  10210. // RENDER PLAYERS:
  10211. renderPlayers(xOffset, yOffset, 0);
  10212.  
  10213. // RENDER AI:
  10214. mainContext.globalAlpha = 1;
  10215. for (let i = 0; i < ais.length; ++i) {
  10216. tmpObj = ais[i];
  10217. if (tmpObj.active && tmpObj.visible) {
  10218. tmpObj.animate(delta);
  10219. mainContext.save();
  10220. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10221. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10222. renderAI(tmpObj, mainContext);
  10223. mainContext.restore();
  10224. }
  10225. }
  10226.  
  10227. // RENDER GAME OBJECTS (LAYERED):
  10228. renderGameObjects(0, xOffset, yOffset);
  10229. renderProjectiles(1, xOffset, yOffset);
  10230. renderGameObjects(1, xOffset, yOffset);
  10231. renderPlayers(xOffset, yOffset, 1);
  10232. renderGameObjects(2, xOffset, yOffset);
  10233. renderGameObjects(3, xOffset, yOffset);
  10234.  
  10235. // MAP BOUNDARIES:
  10236. mainContext.fillStyle = "#000";
  10237. mainContext.globalAlpha = 0.09;
  10238. if (xOffset <= 0) {
  10239. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10240. }
  10241. if (config.mapScale - xOffset <= maxScreenWidth) {
  10242. let tmpY = Math.max(0, -yOffset);
  10243. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10244. }
  10245. if (yOffset <= 0) {
  10246. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10247. }
  10248. if (config.mapScale - yOffset <= maxScreenHeight) {
  10249. let tmpX = Math.max(0, -xOffset);
  10250. let tmpMin = 0;
  10251. if (config.mapScale - xOffset <= maxScreenWidth)
  10252. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10253. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10254. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10255. }
  10256.  
  10257. // RENDER DAY/NIGHT TIME:
  10258. mainContext.globalAlpha = 1;
  10259. mainContext.fillStyle = "rgba(0, 5, 80, 0.35)";
  10260. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10261.  
  10262. // RENDER PLAYER AND AI UI:
  10263. mainContext.strokeStyle = darkOutlineColor;
  10264. mainContext.globalAlpha = 1;
  10265.  
  10266. for (let i = 0; i < players.length + ais.length; ++i) {
  10267. tmpObj = players[i] || ais[i - players.length];
  10268. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  10269. mainContext.strokeStyle = darkOutlineColor;
  10270.  
  10271. // NAME AND HEALTH:
  10272.  
  10273. // let izbot = false;
  10274.  
  10275. // bots.forEach((bot) => {
  10276. // if (tmpObj.sid == bot.sid) izbot = true
  10277. // else izbot = false;
  10278. // });
  10279.  
  10280. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  10281. if (tmpText != "" && tmpObj.name != "unknown1l") {
  10282. // bots.forEach((bot) => {
  10283. // if (tmpObj.sid == bot.sid) return;
  10284. // });
  10285.  
  10286. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10287. mainContext.fillStyle = "#fff";
  10288. mainContext.textBaseline = "middle";
  10289. mainContext.textAlign = "center";
  10290. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10291. mainContext.lineJoin = "round";
  10292. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10293. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10294. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10295. let tmpS = config.crownIconScale;
  10296. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10297. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10298. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10299. }
  10300. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10301. let tmpS = config.crownIconScale;
  10302. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10303. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10304. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10305. }
  10306. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length) {
  10307. let tmpS = tmpObj.scale * 2.2;
  10308. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10309. }
  10310. // izbot = false;
  10311. }
  10312. if (tmpObj.health > 0) {
  10313.  
  10314. if(tmpObj.name != "unknown1l") {
  10315. // HEALTH HOLDER:
  10316. mainContext.fillStyle = darkOutlineColor;
  10317. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10318. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10319. (config.healthBarPad * 2), 17, 8);
  10320. mainContext.fill();
  10321.  
  10322. // HEALTH BAR:
  10323. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#ad64ed" : "#cc5151";
  10324. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10325. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10326. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10327. mainContext.fill();
  10328. }
  10329.  
  10330. if (tmpObj.isPlayer) {
  10331. mainContext.globalAlpha = 1;
  10332. let targetReloads = {
  10333. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10334. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10335. turret: (2500 - tmpObj.reloads[53]) / 2500
  10336. };
  10337. if (!tmpObj.currentReloads) {
  10338. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10339. primary: targetReloads.primary,
  10340. secondary: targetReloads.secondary,
  10341. turret: targetReloads.turret
  10342. };
  10343. }
  10344. const lerpFactor = 0.3;
  10345. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10346. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10347. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10348.  
  10349. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10350. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10351. const centerX = tmpObj.x - xOffset;
  10352. const centerY = tmpObj.y - yOffset;
  10353. const barRadius = 35;
  10354. const barWidth = 15;
  10355. const totalAngle = (Math.PI*2)/3; // Half circle
  10356. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10357. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10358. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10359. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10360.  
  10361. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10362. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10363. function returncoolcolor(RainbowCycle) {
  10364. return "#d6d6d6";
  10365. }
  10366.  
  10367. mainContext.save();
  10368. if (tmpObj.currentReloads.primary < 0.999) {
  10369. mainContext.beginPath();
  10370. mainContext.lineCap = 'round';
  10371. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10372. mainContext.lineWidth = 4;
  10373. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10374. mainContext.stroke();
  10375. }
  10376. if (tmpObj.currentReloads.secondary < 0.999) {
  10377. mainContext.beginPath();
  10378. mainContext.lineCap = 'round';
  10379. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10380. mainContext.lineWidth = 4;
  10381. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10382. mainContext.stroke();
  10383. }
  10384. if (tmpObj.currentReloads.turret < 0.999) {
  10385. mainContext.beginPath();
  10386. mainContext.lineCap = 'round';
  10387. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10388. mainContext.lineWidth = 4;
  10389. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10390. mainContext.stroke();
  10391. }
  10392. mainContext.restore();
  10393.  
  10394. if(tmpObj.name != "unknown1l") {
  10395. // SHAME COUNT:
  10396. mainContext.globalAlpha = 1;
  10397. mainContext.font = "24px Hammersmith One";
  10398. mainContext.fillStyle = "#fff";
  10399. mainContext.strokeStyle = darkOutlineColor;
  10400. mainContext.textBaseline = "middle";
  10401. mainContext.textAlign = "center";
  10402. mainContext.lineWidth = 8;
  10403. mainContext.lineJoin = "round";
  10404. let tmpS = config.crownIconScale;
  10405. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  10406. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  10407. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  10408. }
  10409.  
  10410. // PLAYER TRACER:
  10411. if (!tmpObj.isTeam(player)) {
  10412. let center = {
  10413. x: screenWidth / 2,
  10414. y: screenHeight / 2,
  10415. };
  10416. 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);
  10417. let dist = center.y * alpha / 2;
  10418. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10419. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10420. mainContext.save();
  10421. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10422. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10423. let by = 255 - (tmpObj.sid * 2);
  10424. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10425. mainContext.globalAlpha = alpha;
  10426. let renderTracer = function(s, ctx) {
  10427. ctx = ctx || mainContext;
  10428. let h = s * (Math.sqrt(3) / 2);
  10429. ctx.beginPath();
  10430. ctx.moveTo(0, -h / 1.5);
  10431. ctx.lineTo(-s / 2, h / 2);
  10432. ctx.lineTo(s / 2, h / 2);
  10433. ctx.lineTo(0, -h / 1.5);
  10434. ctx.fill();
  10435. ctx.closePath();
  10436. }
  10437. renderTracer(25, mainContext);
  10438. mainContext.restore();
  10439. }
  10440.  
  10441. if (getEl("predictType").value == "pre2") {
  10442. mainContext.lineWidth = 3;
  10443. mainContext.strokeStyle = "#fff";
  10444. mainContext.globalAlpha = 1;
  10445. mainContext.beginPath();
  10446. let render = {
  10447. x: tmpObj.x2 - xOffset,
  10448. y: tmpObj.y2 - yOffset
  10449. };
  10450. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10451. mainContext.lineTo(render.x, render.y);
  10452. mainContext.stroke();
  10453. } else if (getEl("predictType").value == "pre3") {
  10454. mainContext.lineWidth = 3;
  10455. mainContext.strokeStyle = "#cc5151";
  10456. mainContext.globalAlpha = 1;
  10457. mainContext.beginPath();
  10458. let render = {
  10459. x: tmpObj.x3 - xOffset,
  10460. y: tmpObj.y3 - yOffset
  10461. };
  10462. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10463. mainContext.lineTo(render.x, render.y);
  10464. mainContext.stroke();
  10465. }
  10466.  
  10467. }
  10468. }
  10469. }
  10470. }
  10471.  
  10472. if (player) {
  10473. // AUTOPUSH LINE:
  10474. if (my.autoPush) {
  10475. mainContext.lineWidth = 14;
  10476. mainContext.strokeStyle = "rgba(160, 32, 240, 0.3)"; // HPBarColor (Outline color)
  10477. mainContext.beginPath();
  10478. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10479. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  10480. mainContext.stroke(); // Draw the outline
  10481. }
  10482. }
  10483.  
  10484.  
  10485. mainContext.globalAlpha = 1;
  10486.  
  10487. // RENDER ANIM TEXTS:
  10488. textManager.update(delta, mainContext, xOffset, yOffset);
  10489.  
  10490. // RENDER CHAT MESSAGES:
  10491. for (let i = 0; i < players.length; ++i) {
  10492. tmpObj = players[i];
  10493. if (tmpObj.visible) {
  10494. if (tmpObj.chatCountdown > 0) {
  10495. tmpObj.chatCountdown -= delta;
  10496. if (tmpObj.chatCountdown <= 0)
  10497. tmpObj.chatCountdown = 0;
  10498. mainContext.font = "32px Hammersmith One";
  10499. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10500. mainContext.textBaseline = "middle";
  10501. mainContext.textAlign = "center";
  10502. let tmpX = tmpObj.x - xOffset;
  10503. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10504. let tmpH = 47;
  10505. let tmpW = tmpSize.width + 17;
  10506. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10507. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10508. mainContext.fill();
  10509. mainContext.fillStyle = "#fff";
  10510. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10511. }
  10512. if (tmpObj.chat.count > 0) {
  10513. tmpObj.chat.count -= delta;
  10514. if (tmpObj.chat.count <= 0)
  10515. tmpObj.chat.count = 0;
  10516. mainContext.font = "32px Hammersmith One";
  10517. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10518. mainContext.textBaseline = "middle";
  10519. mainContext.textAlign = "center";
  10520. let tmpX = tmpObj.x - xOffset;
  10521. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10522. let tmpH = 47;
  10523. let tmpW = tmpSize.width + 17;
  10524. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10525. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10526. mainContext.fill();
  10527. mainContext.fillStyle = "#ffffff99";
  10528. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10529. } else {
  10530. tmpObj.chat.count = 0;
  10531.  
  10532. }
  10533. }
  10534. }
  10535.  
  10536. if (allChats.length) {
  10537. allChats.filter(ch => ch.active).forEach((ch) => {
  10538. if (!ch.alive) {
  10539. if (ch.alpha <= 1) {
  10540. ch.alpha += delta / 250;
  10541. if (ch.alpha >= 1) {
  10542. ch.alpha = 1;
  10543. ch.alive = true;
  10544. }
  10545. }
  10546. } else {
  10547. ch.alpha -= delta / 5000;
  10548. if (ch.alpha <= 0) {
  10549. ch.alpha = 0;
  10550. ch.active = false;
  10551. }
  10552. }
  10553. if (ch.active) {
  10554. mainContext.font = "20px Ubuntu";
  10555. let tmpSize = mainContext.measureText(ch.chat);
  10556. mainContext.textBaseline = "middle";
  10557. mainContext.textAlign = "center";
  10558. let tmpX = ch.x - xOffset;
  10559. let tmpY = ch.y - yOffset - 90;
  10560. let tmpH = 40;
  10561. let tmpW = tmpSize.width + 15;
  10562.  
  10563. mainContext.globalAlpha = ch.alpha;
  10564.  
  10565. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10566. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10567. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10568. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  10569.  
  10570. mainContext.lineWidth = 5;
  10571. mainContext.fillStyle = "#ccc";
  10572. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10573.  
  10574. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10575. mainContext.stroke();
  10576. mainContext.fill();
  10577.  
  10578. mainContext.fillStyle = "#fff";
  10579. mainContext.strokeStyle = "#000";
  10580. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10581. mainContext.fillText(ch.chat, tmpX, tmpY);
  10582. ch.y -= delta / 100;
  10583. }
  10584. });
  10585. }
  10586.  
  10587. mainContext.globalAlpha = 1;
  10588.  
  10589. // RENDER MINIMAP:
  10590. renderMinimap(delta);
  10591. }
  10592.  
  10593. // UPDATE & ANIMATE:
  10594. window.requestAnimFrame = function() {
  10595. return null;
  10596. }
  10597. window.rAF = (function() {
  10598. return window.requestAnimationFrame ||
  10599. window.webkitRequestAnimationFrame ||
  10600. window.mozRequestAnimationFrame ||
  10601. function(callback) {
  10602. window.setTimeout(callback, 1000/9);
  10603. };
  10604. })();
  10605.  
  10606. function doUpdate() {
  10607. //rape modulus
  10608. now = performance.now();
  10609. delta = now - lastUpdate;
  10610. lastUpdate = now;
  10611. let timer = performance.now();
  10612. let diff = timer - fpsTimer.last;
  10613. if (diff >= 1000) {
  10614.  
  10615. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10616.  
  10617. fpsTimer.last = timer;
  10618. fpsTimer.time = 0;
  10619. }
  10620. fpsTimer.time++;
  10621.  
  10622. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  10623. getEl("packetStatus").innerHTML = secPacket;
  10624. updateGame();
  10625. rAF(doUpdate);
  10626. ms.avg = Math.round((ms.min+ms.max)/2);
  10627. }
  10628.  
  10629. prepareMenuBackground();
  10630. doUpdate();
  10631.  
  10632. function toggleUseless(boolean) {
  10633. getEl("instaType").disabled = boolean;
  10634. getEl("antiBullType").disabled = boolean;
  10635. getEl("predictType").disabled = boolean;
  10636. }
  10637. toggleUseless(useWasd);
  10638.  
  10639. let changeDays = {};
  10640. window.debug = function() {
  10641. my.waitHit = 0;
  10642. my.autoAim = false;
  10643. instaC.isTrue = false;
  10644. traps.inTrap = false;
  10645. itemSprites = [];
  10646. objSprites = [];
  10647. gameObjectSprites = [];
  10648. };
  10649. window.wasdMode = function() {
  10650. useWasd = !useWasd;
  10651. toggleUseless(useWasd);
  10652. };
  10653. window.startGrind = function() {
  10654. if (getEl("weaponGrind").checked) {
  10655. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10656. checkPlace(player.getItemType(22), i);
  10657. }
  10658. }
  10659. };
  10660. // REMOVED!!! so they cant abuse :)
  10661. let projects = [
  10662. "adorable-eight-guppy",
  10663. "galvanized-bittersweet-windshield"
  10664. ];
  10665. let botIDS = 0;
  10666. window.connectFillBots = function() {
  10667. botSkts = [];
  10668. botIDS = 0;
  10669. for (let i = 0; i < projects.length; i++) {
  10670. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10671. test.binaryType = "arraybuffer";
  10672.  
  10673. test.onopen = function() {
  10674. test.ssend = function(type) {
  10675. let data = Array.prototype.slice.call(arguments, 1);
  10676. let binary = window.msgpack.encode([type, data]);
  10677. test.send(binary);
  10678. };
  10679. for (let i = 0; i < 4; i++) {
  10680. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10681. action: "homepage"
  10682. }).then(function(token) {
  10683. let t = WS.url.split("wss://")[1].split("?")[0];
  10684. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10685. botSkts.push([test]);
  10686. botIDS++;
  10687. });
  10688. }
  10689. };
  10690. test.onmessage = function(message) {
  10691. let data = new Uint8Array(message.data);
  10692. let parsed = window.msgpack.decode(data);
  10693. let type = parsed[0];
  10694. data = parsed[1];
  10695. };
  10696. }
  10697. };
  10698. window.destroyFillBots = function() {
  10699. botSkts.forEach((socket) => {
  10700. socket[0].close();
  10701. });
  10702. botSkts = [];
  10703. };
  10704. window.tryConnectBots = function() {
  10705. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10706. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10707. action: "homepage"
  10708. }).then(function(token) {
  10709. // CONNECT SOCKET:
  10710. botSpawn(token);
  10711. });
  10712. }
  10713. };
  10714. window.destroyBots = function() {
  10715. bots.forEach((botyyyyy) => {
  10716. botyyyyy.closeSocket = true;
  10717. });
  10718. bots = [];
  10719. };
  10720. window.resBuild = function() {
  10721. if (gameObjects.length) {
  10722. gameObjects.forEach((tmp) => {
  10723. tmp.breakObj = false;
  10724. });
  10725. breakObjects = [];
  10726. }
  10727. };
  10728. window.toggleBotsCircle = function() {
  10729. player.circle = !player.circle;
  10730. };
  10731. window.toggleVisual = function() {
  10732. config.anotherVisual = !config.anotherVisual;
  10733. gameObjects.forEach((tmp) => {
  10734. if (tmp.active) {
  10735. tmp.dir = tmp.lastDir;
  10736. }
  10737. });
  10738. };
  10739. window.prepareUI = function(tmpObj) {
  10740. resize();
  10741. // CHAT STUFF:
  10742. var chatBox = document.getElementById("chatBox");
  10743. var chatHolder = document.getElementById("chatHolder");
  10744. var suggestBox = document.createElement("div");
  10745. suggestBox.id = "suggestBox";
  10746.  
  10747. var prevChats = [];
  10748. var prevChatsIndex = 0;
  10749.  
  10750. function toggleChat() {
  10751. if (!usingTouch) {
  10752. if (chatHolder.style.display == "block") {
  10753. if (chatBox.value) {
  10754. sendChat(chatBox.value);
  10755. }
  10756. closeChat();
  10757. } else {
  10758. storeMenu.style.display = "none";
  10759. allianceMenu.style.display = "none";
  10760. chatHolder.style.display = "block";
  10761. chatBox.focus();
  10762. resetMoveDir();
  10763. }
  10764. } else {
  10765. setTimeout(function () {
  10766. var chatMessage = prompt("chat message");
  10767. if (chatMessage) {
  10768. sendChat(chatMessage);
  10769. }
  10770. }, 1);
  10771. }
  10772. chatBox.value = "";
  10773. (() => {
  10774. prevChatsIndex = 0;
  10775. })();
  10776. }
  10777.  
  10778. function closeChat() {
  10779. chatBox.value = "";
  10780. chatHolder.style.display = "none";
  10781. }
  10782.  
  10783. // ACTION BAR:
  10784. UTILS.removeAllChildren(actionBar);
  10785.  
  10786. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10787. (function (i) {
  10788. UTILS.generateElement({
  10789. id: "actionBarItem" + i,
  10790. class: "actionBarItem",
  10791. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10792. onmouseout: function () {
  10793. showItemInfo();
  10794. },
  10795. parent: actionBar
  10796. });
  10797. })(i);
  10798. }
  10799.  
  10800. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10801. (function (i) {
  10802. let tmpCanvas = document.createElement("canvas");
  10803. tmpCanvas.width = tmpCanvas.height = 66;
  10804. let tmpContext = tmpCanvas.getContext("2d");
  10805. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10806. tmpContext.imageSmoothingEnabled = false;
  10807. tmpContext.webkitImageSmoothingEnabled = false;
  10808. tmpContext.mozImageSmoothingEnabled = false;
  10809.  
  10810. if (items.weapons[i]) {
  10811. tmpContext.rotate((Math.PI));
  10812. let tmpSprite = new Image();
  10813. toolSprites[items.weapons[i].src] = tmpSprite;
  10814. tmpSprite.onload = function () {
  10815. this.isLoaded = true;
  10816. let tmpPad = 1 / (this.height / this.width);
  10817. let tmpMlt = (items.weapons[i].iPad || 1);
  10818. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10819. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10820. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10821. tmpContext.globalCompositeOperation = "source-atop";
  10822. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10823. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10824. };
  10825. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10826. let tmpUnit = getEl('actionBarItem' + i);
  10827. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10828. // showItemInfo(items.weapons[i], true);
  10829. // });
  10830. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10831. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10832. });
  10833. UTILS.hookTouchEvents(tmpUnit);
  10834. } else {
  10835. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10836. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10837. tmpContext.globalAlpha = 1;
  10838. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10839. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10840. tmpContext.globalCompositeOperation = "source-atop";
  10841. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10842. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10843. let tmpUnit = getEl('actionBarItem' + i);
  10844. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10845. // showItemInfo(items.list[i - items.weapons.length]);
  10846. // });
  10847. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10848. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10849. });
  10850. UTILS.hookTouchEvents(tmpUnit);
  10851. }
  10852. })(i);
  10853. }
  10854. };
  10855. const PACKET_MAP = {
  10856. // 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.
  10857. "33": "9",
  10858. "7": "K",
  10859. "ch": "6",
  10860. "pp": "0",
  10861. "13c": "c",
  10862.  
  10863. // most recent packet changes
  10864. "f": "9",
  10865. "a": "9",
  10866. "d": "F",
  10867. "G": "z"
  10868. }
  10869.  
  10870. let originalSend = WebSocket.prototype.send;
  10871.  
  10872. WebSocket.prototype.send = new Proxy(originalSend, {
  10873. apply: ((target, websocket, argsList) => {
  10874. let decoded = msgpack.decode(new Uint8Array(argsList[0]));
  10875.  
  10876. if (PACKET_MAP.hasOwnProperty(decoded[0])) {
  10877. decoded[0] = PACKET_MAP[decoded[0]];
  10878. }
  10879.  
  10880. return target.apply(websocket, [msgpack.encode(decoded)]);
  10881. })
  10882. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址