oblivion mod v1.3

e

  1. // ==UserScript==
  2. // @name oblivion mod v1.3
  3. // @match *://*.moomoo.io/*
  4. // @run-at document_idle
  5. // @grant none
  6. // @icon https://i1.sndcdn.com/artworks-IyhpQ4XC9EOtjNP6-Y9yXGg-t500x500.jpg
  7. // @namespace lol
  8. // @version v1.3
  9. // @description e
  10. // @author zf
  11. // ==/UserScript==
  12.  
  13.  
  14. setTimeout(() => {
  15. document.getElementById('loadingText').innerHTML = `<!DOCTYPE html>
  16. <html lang="en">
  17. <head>
  18. <meta charset="UTF-8">
  19. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  20. <title>Loading Screen</title>
  21. <style>
  22. body {
  23. margin: 0;
  24. padding: 0;
  25. display: flex;
  26. justify-content: center;
  27. align-items: center;
  28. height: 100vh;
  29. background-color: #000000;
  30. }
  31.  
  32. .loader {
  33. border: 8px solid black; /* Light black */
  34. border-top: 8px solid #000000; /* Blue */
  35. border-radius: 50%;
  36. width: 50px;
  37. height: 50px;
  38. animation: spin 1s linear infinite;
  39. margin-left: 905px; /* Подвигаем на 50 пикселей вправо */
  40. margin-top: 100px;
  41. transition: border 1s, border-top 1s;
  42. }
  43.  
  44. @keyframes spin {
  45. 0% { transform: rotate(0deg); }
  46. 100% { transform: rotate(360deg); }
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <div class="loader"></div>
  52. </body>
  53. </html>
  54. `;
  55. }, 20);
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. let editMainMenu = `
  63. <style>
  64. /* Стили для меню #setupCard */
  65. #setupCard {
  66. border-radius: 10px;
  67. position: absolute;
  68. left: 790px;
  69. top: 1px;
  70. background: #370b5c;
  71. box-shadow: 0px 0px 5px #fff;
  72. transition: box-shadow 0.3s ease;
  73. }
  74.  
  75. #setupCard:hover,
  76. #setupCard:active {
  77. box-shadow: 0px 0px 10px #ffffff;
  78. }
  79.  
  80. /* Стили для меню #guideCard */
  81. #guideCard {
  82. border-radius: 10px;
  83. position: absolute;
  84. left: 790px;
  85. top: 149px;
  86. background: #370b5c;
  87. box-shadow: 0px 0px 5px #ffffff;
  88. transition: box-shadow 0.3s ease;
  89. }
  90.  
  91. #guideCard:hover,
  92. #guideCard:active {
  93. box-shadow: 0px 0px 10px #ffffff;
  94. }
  95.  
  96.  
  97.  
  98. /* Прочие стили остаются без изменений */
  99. #nameInput::selection {
  100. background: #1a1919;
  101. }
  102.  
  103. #guideCard::-webkit-scrollbar {
  104. width: 0px;
  105. height: 0px;
  106. background-color: rgba(0, 0, 0, 0);
  107. }
  108.  
  109. #mainMenu {
  110. background-color: #000000;
  111.  
  112. }
  113.  
  114. .menuCard {
  115. background: #8d3beb;
  116. text-align: center;
  117. box-shadow: inset 0px 0px 0px black;
  118. }
  119. .snowflake {
  120. color: #370b5c;
  121. font-size: 3em;
  122. font-family: Arial, sans-serif;
  123. text-shadow: 0 0 0px #fff;
  124. position: fixed;
  125. top: -10%;
  126. z-index: 9999;
  127. user-select: none;
  128. cursor: default;
  129. animation: snowflakes-fall 10s linear infinite, snowflakes-shake 3s ease-in-out infinite;
  130. }
  131.  
  132. @keyframes snowflakes-fall {
  133. 0% { top: -10%; }
  134. 100% { top: 100%; }
  135. }
  136.  
  137. @keyframes snowflakes-shake {
  138. 0%, 100% { transform: translateX(0); }
  139. 50% { transform: translateX(80px); }
  140. }
  141.  
  142. /* Прочие стили остаются без изменений */
  143. #nameInput::selection {
  144. background: #000000;
  145. }
  146.  
  147.  
  148.  
  149. .menuCard {
  150. background: #000000;
  151. text-align: center;
  152. box-shadow: inset 0px 0px 0px black;
  153. }
  154. </style>
  155. </head>
  156. <body>
  157.  
  158.  
  159.  
  160. <div id="snowContainer"></div>
  161.  
  162. <script>
  163. (function() {
  164. const amount = 22;
  165. const container = document.getElementById("snowContainer");
  166.  
  167. for(let i = 0; i < amount; i++){
  168. createSnowflake();
  169. }
  170.  
  171. function createSnowflake(){
  172. const txt = ["❅","❆"]
  173. let snow = document.createElement("div");
  174. snow.innerText = txt[+(Math.random() > 5)];
  175. container.appendChild(snow);
  176. snow.classList.add('snowflake');
  177. snow.style.left = Math.random() * 100 + "%";
  178. let d = ~~(Math.random() * 20);
  179. snow.style.animationDelay = d + 's, ' + d + 's';
  180. }
  181.  
  182. })();
  183. </script>
  184.  
  185. </style>
  186.  
  187.  
  188. `
  189. $("#mainMenu").append(editMainMenu)
  190.  
  191.  
  192.  
  193.  
  194.  
  195. document.getElementById("partyButton").remove();
  196. document.getElementById("joinPartyButton").remove();
  197.  
  198. document.getElementById("linksContainer2").remove();
  199.  
  200. document.getElementById("gameName").style.font = "120px zamruds";
  201.  
  202. document.getElementById("gameName").style.textShadow = "0px 0px 10px rgba(0, 191, 255, 0.5)"; // Используем rgba для задания прозрачного голубого цвета
  203. document.getElementById('gameName').style.marginTop = '-200px';
  204. document.getElementById('gameName').innerHTML = 'oblivion';
  205.  
  206.  
  207. let founda = false;
  208.  
  209. let scriptTags = document.getElementsByTagName("script");
  210. for (let i = 0; i < scriptTags.length; i++) {
  211. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  212. scriptTags[i].remove();
  213. founda = true;
  214. break;
  215. }
  216. }
  217.  
  218.  
  219. document.addEventListener("keydown", function(event) {
  220. if (event.keyCode === 192) {
  221. const chatHolder = document.getElementById("gameUI");
  222. if (chatHolder) {
  223. const currentDisplay = chatHolder.style.display;
  224. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  225. }
  226. }
  227. });
  228. var styleItem = document.createElement("style");
  229. styleItem.type = "text/css";
  230. styleItem.appendChild(document.createTextNode(`
  231. #suggestBox {
  232. width: 355px;
  233. border-radius: 3px;
  234. background-color: rgba(0,0,0,0.5);
  235. margin: auto;
  236. text-align: left;
  237. z-index: 49;
  238. pointer-events: auto;
  239. position: relative;
  240. bottom: 3.5px;
  241. overflow-y: auto;
  242. }
  243. #suggestBox div {
  244. background-color: rgba(255,255,255,0.5);
  245. color: rgba(255,255,255,1);
  246. transition: background-color 0.3s, color 0.3s;
  247. }
  248. #suggestBox div:hover {
  249. background-color: rgba(255,255,255,0.2);
  250. color: rgba(0,0,0,1);
  251. }
  252. .suggestBoxHard {
  253. color: rgba(255,255,255,1);
  254. font-size: 18px;
  255. }
  256. .suggestBoxLight {
  257. color: rgba(255,255,255,0.7);
  258. font-size: 18px;
  259. }
  260. `));
  261. document.head.appendChild(styleItem);
  262.  
  263. window.addEventListener('load', function() {
  264. var allianceButton = document.getElementById('allianceButton');
  265. var storeButton = document.getElementById('storeButton');
  266. if (storeButton) {
  267. storeButton.style.right = '26px';
  268. storeButton.style.top = '420px';
  269. }
  270. if (allianceButton) {
  271. allianceButton.style.right = '26px';
  272. allianceButton.style.top = '479px';
  273. }
  274. });
  275.  
  276. function getEl(id) {
  277. return document.getElementById(id);
  278. }
  279.  
  280.  
  281.  
  282. let newFont = document.createElement("link");
  283. newFont.rel = "stylesheet";
  284. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  285. newFont.type = "text/css";
  286. document.body.append(newFont);
  287.  
  288. let min = document.createElement("script");
  289. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  290. document.body.append(min);
  291. window.oncontextmenu = function() {
  292. return false;
  293. };
  294.  
  295. let config = window.config;
  296.  
  297. // CLIENT:
  298. config.clientSendRate = 9; // Aim Packet Send Rate
  299. config.serverUpdateRate = 9;
  300.  
  301. // UI:
  302. config.deathFadeout = 0;
  303.  
  304. config.playerCapacity = 9999;
  305.  
  306. // CHECK IN SANDBOX:
  307. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  308.  
  309. // CUSTOMIZATION:
  310. config.skinColors = ["#ad8b57", "#000000", "#000000",
  311. "#000000", "#000000", "#000000", "#000000", "000000", "000000",
  312. "000000", "#8d3beb"
  313. ];
  314. config.weaponVariants = [{
  315. id: 0,
  316. src: "",
  317. xp: 0,
  318. val: 1,
  319. }, {
  320. id: 1,
  321. src: "_g",
  322. xp: 3000,
  323. val: 1.1,
  324. }, {
  325. id: 2,
  326. src: "_d",
  327. xp: 7000,
  328. val: 1.18,
  329. }, {
  330. id: 3,
  331. src: "_r",
  332. poison: true,
  333. xp: 12000,
  334. val: 1.18,
  335. }, {
  336. id: 4,
  337. src: "_e",
  338. poison: true,
  339. heal: true,
  340. xp: 24000,
  341. val: 1.18,
  342. }];
  343.  
  344. // VISUAL:
  345. config.anotherVisual = true;
  346. config.useWebGl = false;
  347. config.resetRender = true;
  348.  
  349. function waitTime(timeout) {
  350. return new Promise((done) => {
  351. setTimeout(() => {
  352. done();
  353. }, timeout);
  354. });
  355. }
  356.  
  357. let botSkts = [];
  358.  
  359. // STORAGE:
  360. let canStore;
  361. if (typeof(Storage) !== "undefined") {
  362. canStore = true;
  363. }
  364.  
  365. function saveVal(name, val) {
  366. if (canStore)
  367. localStorage.setItem(name, val);
  368. }
  369.  
  370. function deleteVal(name) {
  371. if (canStore)
  372. localStorage.removeItem(name);
  373. }
  374.  
  375. function getSavedVal(name) {
  376. if (canStore)
  377. return localStorage.getItem(name);
  378. return null;
  379. }
  380.  
  381. // CONFIGS:
  382. let gC = function(a, b) {
  383. try {
  384. let res = JSON.parse(getSavedVal(a));
  385. if (typeof res === "object") {
  386. return b;
  387. } else {
  388. return res;
  389. }
  390. } catch (e) {
  391. alert("dieskid");
  392. return b;
  393. }
  394. };
  395.  
  396. function setCommands() {
  397. return {
  398. "help": {
  399. desc: "Show Commands",
  400. action: function(message) {
  401. for (let cmds in commands) {
  402. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  403. }
  404. }
  405. },
  406. "clear": {
  407. desc: "Clear Chats",
  408. action: function(message) {
  409. resetMenuChText();
  410. }
  411. },
  412. "debug": {
  413. desc: "Debug Mod For Development",
  414. action: function(message) {
  415. addDeadPlayer(player);
  416. addMenuChText("Debug", "Done", "#99ee99", 1);
  417. }
  418. },
  419. "play": {
  420. desc: "Play Music ( /play [link] )",
  421. action: function(message) {
  422. let link = message.split(" ");
  423. if (link[1]) {
  424. let audio = new Audio(link[1]);
  425. audio.play();
  426. } else {
  427. addMenuChText("Warn", "Enter Link ( /play [link] )", "#471c69", 1);
  428. }
  429. }
  430. },
  431. "bye": {
  432. desc: "Leave Game",
  433. action: function(message) {
  434. window.leave();
  435. }
  436. },
  437. };
  438. }
  439.  
  440. function setConfigs() {
  441. return {
  442. killChat: true,
  443. autoBuy: true,
  444. autoBuyEquip: true,
  445. autoPush: true,
  446. revTick: true,
  447. spikeTick: true,
  448. predictTick: true,
  449. autoPlace: true,
  450. autoReplace: true,
  451. antiTrap: true,
  452. slowOT: false,
  453. attackDir: false,
  454. showDir: true,
  455. autoRespawn: false
  456. };
  457. }
  458.  
  459. let commands = setCommands();
  460. let configs = setConfigs();
  461.  
  462. window.removeConfigs = function() {
  463. for (let cF in configs) {
  464. deleteVal(cF, configs[cF]);
  465. }
  466. };
  467.  
  468. for (let cF in configs) {
  469. configs[cF] = gC(cF, configs[cF]);
  470. }
  471.  
  472. // MENU FUNCTIONS:
  473. window.changeMenu = function() {};
  474. window.debug = function() {};
  475. window.wasdMode = function() {};
  476.  
  477. // PAGE 1:
  478. window.startGrind = function() {};
  479.  
  480. // PAGE 3:
  481. window.connectFillBots = function() {};
  482. window.destroyFillBots = function() {};
  483. window.tryConnectBots = function() {};
  484. window.destroyBots = function() {};
  485. window.resBuild = function() {};
  486. window.toggleBotsCircle = function() {};
  487. window.toggleVisual = function() {};
  488.  
  489. // SOME FUNCTIONS:
  490. window.prepareUI = function() {};
  491. window.leave = function() {};
  492.  
  493. // nah hahahahahhh why good ping
  494. window.ping = 0;
  495.  
  496. class deadfuturechickenmodrevival {
  497. constructor(flarez, lore) {
  498. this.inGame = false;
  499. this.lover = flarez + lore;
  500. this.baby = "ae86";
  501. this.isBlack = 0;
  502. this.webSocket = undefined;
  503. this.checkBaby = function() {
  504. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  505. if (this.isBlack >= 1) return "bl4cky";
  506. return "noting for you";
  507. };
  508. this.x2 = 0;
  509. this.y2 = 0;
  510. this.chat = "Imagine playing this badass game XDDDDD";
  511. this.summon = function(tmpObj) {
  512. this.x2 = tmpObj.x;
  513. this.y2 = tmpObj.y;
  514. this.chat = tmpObj.name + " ur so bad XDDDD";
  515. };
  516. this.commands = function(cmd) {
  517. cmd == "rv3link" && window.open("https://florr.io/");
  518. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  519. return cmd;
  520. };
  521. this.dayte = "11yearold";
  522. this.memeganoob = "69yearold";
  523. this.startDayteSpawn = function(tmpObj) {
  524. let ratio = setInterval(() => {
  525. this.x2 = tmpObj.x + 20;
  526. this.y2 = tmpObj.y - 20;
  527. this.chat = "UR SO BAD LOL";
  528. if (tmpObj.name == "ae86") {
  529. this.chat = "omg ae86 go run";
  530. setTimeout(() => {
  531. this.inGame = false;
  532. clearInterval(ratio);
  533. }, 1000);
  534. }
  535. }, 1234);
  536. };
  537. this.AntiChickenModV69420 = function(tmpObj) {
  538. return "!c!dc user " + tmpObj.name;
  539. };
  540. }
  541. };
  542. class HtmlAction {
  543. constructor(element) {
  544. this.element = element;
  545. };
  546. add(code) {
  547. if (!this.element) return undefined;
  548. this.element.innerHTML += code;
  549. };
  550. newLine(amount) {
  551. let result = `<br>`;
  552. if (amount > 0) {
  553. result = ``;
  554. for (let i = 0; i < amount; i++) {
  555. result += `<br>`;
  556. }
  557. }
  558. this.add(result);
  559. };
  560. checkBox(setting) {
  561. let newCheck = `<input type = "checkbox"`;
  562. setting.id && (newCheck += ` id = ${setting.id}`);
  563. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  564. setting.class && (newCheck += ` class = ${setting.class}`);
  565. setting.checked && (newCheck += ` checked`);
  566. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  567. newCheck += `>`;
  568. this.add(newCheck);
  569. };
  570. text(setting) {
  571. let newText = `<input type = "text"`;
  572. setting.id && (newText += ` id = ${setting.id}`);
  573. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  574. setting.class && (newText += ` class = ${setting.class}`);
  575. setting.size && (newText += ` size = ${setting.size}`);
  576. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  577. setting.value && (newText += ` value = ${setting.value}`);
  578. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  579. newText += `>`;
  580. this.add(newText);
  581. };
  582. select(setting) {
  583. let newSelect = `<select`;
  584. setting.id && (newSelect += ` id = ${setting.id}`);
  585. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  586. setting.class && (newSelect += ` class = ${setting.class}`);
  587. newSelect += `>`;
  588. for (let options in setting.option) {
  589. newSelect += `<option value = ${setting.option[options].id}`
  590. setting.option[options].selected && (newSelect += ` selected`);
  591. newSelect += `>${options}</option>`;
  592. }
  593. newSelect += `</select>`;
  594. this.add(newSelect);
  595. };
  596. button(setting) {
  597. let newButton = `<button`;
  598. setting.id && (newButton += ` id = ${setting.id}`);
  599. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  600. setting.class && (newButton += ` class = ${setting.class}`);
  601. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  602. newButton += `>`;
  603. setting.innerHTML && (newButton += setting.innerHTML);
  604. newButton += `</button>`;
  605. this.add(newButton);
  606. };
  607. selectMenu(setting) {
  608. let newSelect = `<select`;
  609. if (!setting.id) {
  610. alert("please put id skid");
  611. return;
  612. }
  613. window[setting.id + "Func"] = function() {};
  614. setting.id && (newSelect += ` id = ${setting.id}`);
  615. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  616. setting.class && (newSelect += ` class = ${setting.class}`);
  617. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  618. newSelect += `>`;
  619. let last;
  620. let i = 0;
  621. for (let options in setting.menu) {
  622. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  623. setting.menu[options] && (newSelect += ` checked`);
  624. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  625. i++;
  626. }
  627. newSelect += `</select>`;
  628.  
  629. this.add(newSelect);
  630.  
  631. i = 0;
  632. for (let options in setting.menu) {
  633. window[options + "Func"] = function() {
  634. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  635. saveVal(options, setting.menu[options]);
  636.  
  637. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  638. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  639.  
  640. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  641.  
  642. };
  643. this.checkBox({
  644. id: "check_" + options,
  645. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  646. class: "checkB",
  647. onclick: `window.${options + "Func"}()`,
  648. checked: setting.menu[options]
  649. });
  650. i++;
  651. }
  652.  
  653. last = "check_" + getEl(setting.id).value.split("_")[1];
  654. window[setting.id + "Func"] = function() {
  655. getEl(last).style.display = "none";
  656. last = "check_" + getEl(setting.id).value.split("_")[1];
  657. getEl(last).style.display = "inline-block";
  658.  
  659. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  660.  
  661. };
  662. };
  663. };
  664. class Html {
  665. constructor() {
  666. this.element = null;
  667. this.action = null;
  668. this.divElement = null;
  669. this.startDiv = function(setting, func) {
  670.  
  671. let newDiv = document.createElement("div");
  672. setting.id && (newDiv.id = setting.id);
  673. setting.style && (newDiv.style = setting.style);
  674. setting.class && (newDiv.className = setting.class);
  675. this.element.appendChild(newDiv);
  676. this.divElement = newDiv;
  677.  
  678. let addRes = new HtmlAction(newDiv);
  679. typeof func == "function" && func(addRes);
  680.  
  681. };
  682. this.addDiv = function(setting, func) {
  683.  
  684. let newDiv = document.createElement("div");
  685. setting.id && (newDiv.id = setting.id);
  686. setting.style && (newDiv.style = setting.style);
  687. setting.class && (newDiv.className = setting.class);
  688. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  689. this.divElement = newDiv;
  690.  
  691. let addRes = new HtmlAction(newDiv);
  692. typeof func == "function" && func(addRes);
  693.  
  694. };
  695. };
  696. set(id) {
  697. this.element = getEl(id);
  698. this.action = new HtmlAction(this.element);
  699. };
  700. resetHTML(text) {
  701. if (text) {
  702. this.element.innerHTML = ``;
  703. } else {
  704. this.element.innerHTML = ``;
  705. }
  706. };
  707. setStyle(style) {
  708. this.element.style = style;
  709. };
  710. setCSS(style) {
  711. this.action.add(`<style>` + style + `</style>`);
  712. };
  713. };
  714.  
  715.  
  716.  
  717. let HTML = new Html();
  718.  
  719. let menuDiv = document.createElement("div");
  720. menuDiv.id = "menuDiv";
  721. menuDiv.draggable = true;
  722.  
  723. menuDiv.addEventListener("dragstart", function (e) {
  724. e.dataTransfer.setData("text/plain", "");
  725. });
  726.  
  727. document.addEventListener("dragover", function (e) {
  728. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  729. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  730. });
  731.  
  732. document.body.appendChild(menuDiv);
  733. HTML.set("menuDiv");
  734. HTML.setStyle(`
  735. position: absolute;
  736. left: 20px;
  737. top: 20px;
  738. `);
  739. HTML.resetHTML();
  740. HTML.setCSS(`
  741. body {
  742. background-color: #3e1b59; /* Черный цвет фона */
  743. color: #fff; /* Белый цвет текста */
  744. font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; /* Более роскошный шрифт */
  745. }
  746.  
  747. .menuClass {
  748. color: #3e1b59;
  749. font-size: 22px; /* Увеличенный размер шрифта */
  750. text-align: left;
  751. padding: 20px; /* Увеличенный внутренний отступ */
  752. width: 300px; /* Увеличенная ширина меню */
  753. background-color: #333; /* Темно-серый цвет фона */
  754. border: 2px solid #555; /* Черный цвет рамки */
  755. border-radius: 12px; /* Более сильно скругленные углы */
  756. box-shadow: 0 4px 8px rgba(0,0,0,0.4); /* Тень для выделения */
  757. }
  758.  
  759. .menuC {
  760. display: none;
  761. font-size: 14px; /* Уменьшенный размер шрифта */
  762. max-height: 200px; /* Увеличенная максимальная высота */
  763. overflow-y: auto;
  764. }
  765.  
  766. .menuB {
  767. text-align: center;
  768. background-color: #3e1b59;
  769. color: #fff;
  770. border: none;
  771. border-radius: 4px;
  772. padding: 4 4px; /* Увеличенный внутренний отступ */
  773. cursor: pointer;
  774. transition: background-color 0.3s ease;
  775. }
  776.  
  777. .menuB:hover {
  778. background-color: #3e1b59;
  779. }
  780.  
  781.  
  782.  
  783. .menuB:active {
  784. transform: translateY(1px);
  785. }
  786.  
  787. .customText {
  788. color: #0;
  789. border: 1px solid #000000;
  790. border-radius: 5px;
  791. padding: 2px;
  792. transition: background-color 0.3s ease;
  793. }
  794.  
  795. .customText:focus {
  796. background-color: #000000; /* Темно-серый цвет фона при фокусировке */
  797. }
  798.  
  799. .checkB {
  800. cursor: pointer;
  801. }
  802.  
  803. .Cselect {
  804. background-color: #3e1b59; /* Темно-серый цвет фона */
  805. color: #000000;
  806. border: 1px solid #555;
  807. border-radius: 66px;
  808. padding: 2px;
  809. }
  810.  
  811. #menuChanger {
  812. position: absolute;
  813. right: 20px; /* Увеличенный отступ справа */
  814. top: 20px; /* Увеличенный отступ сверху */
  815. background-color: transparent;
  816. color: #fff;
  817. border: none;
  818. cursor: pointer;
  819. }
  820.  
  821. #menuChanger:hover {
  822. color: #ccc; /* Светло-серый цвет при наведении */
  823. }
  824.  
  825. /* Скроллбары */
  826. ::-webkit-scrollbar {
  827. width: 8px;
  828. }
  829.  
  830. ::-webkit-scrollbar-track {
  831. background: #333; /* Темно-серый цвет фона */
  832. }
  833.  
  834. ::-webkit-scrollbar-thumb {
  835. background: #666; /* Светло-серый цвет скроллбара */
  836. border-radius: 4px;
  837. }
  838.  
  839. ::-webkit-scrollbar-thumb:hover {
  840. background: #999; /* Более светлый цвет при наведении */
  841. }
  842.  
  843. /* Добавление узоров на задний фон */
  844. body {
  845. background-image: url('https://www.transparenttextures.com/patterns/asfalt-dark.png'); /* Использование узора */
  846. }
  847.  
  848. `);
  849. HTML.startDiv({
  850. id: "menuHeadLine",
  851. class: "menuClass"
  852. }, (html) => {
  853. html.add(`oblivion`);
  854. html.button({
  855. id: "menuChanger",
  856. class: "material-icons",
  857. innerHTML: `sync`,
  858. onclick: "window.changeMenu()"
  859. });
  860. HTML.addDiv({
  861. id: "menuButtons",
  862. style: "display: block; overflow-y: visible;",
  863. class: "menuC",
  864. appendID: "menuHeadLine"
  865. }, (html) => {
  866. html.button({
  867. class: "menuB",
  868. innerHTML: "Debug",
  869. onclick: "window.debug()"
  870. });
  871. });
  872. HTML.addDiv({
  873. id: "menuMain",
  874. style: "display: block",
  875. class: "menuC",
  876. appendID: "menuHeadLine"
  877. }, (html) => {
  878. html.button({
  879. class: "menuB",
  880. innerHTML: "Dagger Optimisation",
  881. onclick: "window.wasdMode()"
  882. });
  883. html.newLine();
  884. html.add(`Auto-Grinder: `);
  885. html.checkBox({
  886. id: "weaponGrind",
  887. class: "checkB",
  888. onclick: "window.startGrind()"
  889. });
  890. html.newLine(2);
  891. HTML.addDiv({
  892. style: "font-size: 30px; color: #000000;",
  893. appendID: "menuMain"
  894. }, (html) => {
  895. html.add(`_______________`);
  896. });
  897. html.add(`Anti-Push:`);
  898. html.checkBox({
  899. id: "antipush",
  900. class: "checkB",
  901. checked: true
  902. });
  903. html.newLine();
  904. html.add(`Auto-Heal:`);
  905. html.checkBox({
  906. id: "healingBeta",
  907. class: "checkB",
  908. checked: true
  909. });
  910. html.newLine();
  911. });
  912. HTML.addDiv({
  913. id: "menuConfig",
  914. class: "menuC",
  915. appendID: "menuHeadLine"
  916. }, (html) => {
  917. html.add(`AutoPlacer Placement Tick: `);
  918. html.text({
  919. id: "autoPlaceTick",
  920. class: "customText",
  921. value: "2",
  922. size: "2em",
  923. maxLength: "1"
  924. });
  925. html.newLine();
  926. html.add(`Configs: `);
  927. html.selectMenu({
  928. id: "configsChanger",
  929. class: "Cselect",
  930. menu: configs
  931. });
  932. html.newLine();
  933. html.add(`InstaKill Type: `);
  934. html.select({
  935. id: "instaType",
  936. class: "Cselect",
  937. option: {
  938. OneShot: {
  939. id: "oneShot",
  940. selected: true
  941. },
  942. Spammer: {
  943. id: "spammer"
  944. }
  945. }
  946. });
  947. html.newLine();
  948. html.add(`AntiBull Type: `);
  949. html.select({
  950. id: "antiBullType",
  951. class: "Cselect",
  952. option: {
  953. "Disable AntiBull": {
  954. id: "noab",
  955. selected: true
  956. },
  957. "When Reloaded": {
  958. id: "abreload",
  959. },
  960. "Primary Reloaded": {
  961. id: "abalway"
  962. }
  963. }
  964. });
  965. html.newLine();
  966. html.add(`Backup Nobull Insta: `);
  967. html.checkBox({
  968. id: "backupNobull",
  969. class: "checkB",
  970. checked: true
  971. });
  972. html.newLine();
  973. html.add(`Turret Gear Combat Assistance: `);
  974. html.checkBox({
  975. id: "turretCombat",
  976. class: "checkB"
  977. });
  978. html.newLine();
  979. html.add(`Safe AntiSpikeTick: `);
  980. html.checkBox({
  981. id: "safeAntiSpikeTick",
  982. class: "checkB",
  983. checked: true
  984. });
  985. html.newLine();
  986. });
  987. HTML.addDiv({
  988. id: "menuOther",
  989. class: "menuC",
  990. appendID: "menuHeadLine"
  991. }, (html) => {
  992. html.button({
  993. class: "menuB",
  994. innerHTML: "Connect Bots",
  995. onclick: "window.tryConnectBots()"
  996. });
  997. html.button({
  998. class: "menuB",
  999. innerHTML: "Disconnect Bots",
  1000. onclick: "window.destroyBots()"
  1001. });
  1002. html.newLine();
  1003. html.button({
  1004. class: "menuB",
  1005. innerHTML: "Connect FBots",
  1006. onclick: "window.connectFillBots()"
  1007. });
  1008. html.button({
  1009. class: "menuB",
  1010. innerHTML: "Disconnect FBots",
  1011. onclick: "window.destroyFillBots()"
  1012. });
  1013. html.newLine();
  1014. html.button({
  1015. class: "menuB",
  1016. innerHTML: "Reset Break Objects",
  1017. onclick: "window.resBuild()"
  1018. });
  1019. html.newLine();
  1020. html.add(`Break Objects Range: `);
  1021. html.text({
  1022. id: "breakRange",
  1023. class: "customText",
  1024. value: "700",
  1025. size: "3em",
  1026. maxLength: "4"
  1027. });
  1028. html.newLine();
  1029. html.add(`Predict Movement Type: `);
  1030. html.select({
  1031. id: "predictType",
  1032. class: "Cselect",
  1033. option: {
  1034. "Disable Render": {
  1035. id: "disableRender",
  1036. selected: true
  1037. },
  1038. "X/Y and 2": {
  1039. id: "pre2",
  1040. },
  1041. "X/Y and 3": {
  1042. id: "pre3"
  1043. }
  1044. }
  1045. });
  1046. html.newLine();
  1047. html.add(`Render Placers: `);
  1048. html.checkBox({
  1049. id: "placeVis",
  1050. class: "checkB",
  1051. });
  1052. html.newLine();
  1053. html.add(`Bot Mode: `);
  1054. html.select({
  1055. id: "mode",
  1056. class: "Cselect",
  1057. option: {
  1058. "Clear Building": {
  1059. id: "clear",
  1060. selected: true
  1061. },
  1062. "Sync": {
  1063. id: "zync",
  1064. },
  1065. "Search": {
  1066. id: "zearch"
  1067. },
  1068. "Clear Everything": {
  1069. id: "fuckemup"
  1070. },
  1071. "Flex": {
  1072. id: "flex"
  1073. }
  1074. }
  1075. });
  1076. html.newLine(2);
  1077. html.button({
  1078. class: "menuB",
  1079. innerHTML: "Toggle Fbots Circle",
  1080. onclick: "window.toggleBotsCircle()"
  1081. });
  1082. html.newLine();
  1083. html.add(`Circle Rad: `);
  1084. html.text({
  1085. id: "circleRad",
  1086. class: "customText",
  1087. value: "200",
  1088. size: "3em",
  1089. maxLength: "4"
  1090. });
  1091. html.newLine();
  1092. html.add(`Rad Speed: `);
  1093. html.text({
  1094. id: "radSpeed",
  1095. class: "customText",
  1096. value: "0.1",
  1097. size: "2em",
  1098. maxLength: "3"
  1099. });
  1100. html.newLine();
  1101. html.add(`Bot Zetup Type: `);
  1102. html.select({
  1103. id: "setup",
  1104. class: "Cselect",
  1105. option: {
  1106. "Dagger Musket": {
  1107. id: "dm",
  1108. selected: true
  1109. },
  1110. "Katana Hammer": {
  1111. id: "kh",
  1112. },
  1113. "Dagger Repeater-Crossbow": {
  1114. id: "dr"
  1115. },
  1116. "Zhort-Zword Muzket": {
  1117. id: "zd"
  1118. }
  1119. }
  1120. });
  1121. html.newLine(2);
  1122. html.add(`Cross World: `);
  1123. html.checkBox({
  1124. id: "funni",
  1125. class: "checkB"
  1126. });
  1127. html.newLine();
  1128. html.button({
  1129. class: "menuB",
  1130. innerHTML: "Toggle Another Visual",
  1131. onclick: "window.toggleVisual()"
  1132. });
  1133. html.newLine();
  1134. });
  1135. });
  1136.  
  1137. let menuChatDiv = document.createElement("div");
  1138. menuChatDiv.id = "menuChatDiv";
  1139. document.body.appendChild(menuChatDiv);
  1140. HTML.set("menuChatDiv");
  1141. HTML.setStyle(`
  1142. position: absolute;
  1143. display: none;
  1144. left: 0px;
  1145. top: 25px;
  1146. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1147. `);
  1148. HTML.resetHTML();
  1149. HTML.setCSS(`
  1150. .chDiv {
  1151. color: #fff;
  1152. padding: 10px;
  1153. width: 357px;
  1154. height: 217px;
  1155. background-color: rgba(0, 0, 0, 0.2);
  1156. font-family: "HammerSmith One", monospace;
  1157. // border-radius: 15px;
  1158. // box-shadow: black 1px 2px 19px;
  1159. //backdrop-filter: blur(3px);
  1160.  
  1161. }
  1162. .chMainDiv {
  1163. font-family: "Ubuntu";
  1164. font-size: 16px;
  1165. max-height: 215px;
  1166. overflow-y: scroll;
  1167. scrollbar-width: thin;
  1168. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1169. -webkit-touch-callout: none;
  1170. -webkit-user-select: none;
  1171. -khtml-user-select: none;
  1172. -moz-user-select: none;
  1173. -ms-user-select: none;
  1174. user-select: none;
  1175. overflow-x: hidden;
  1176. }
  1177. .chMainDiv::-webkit-scrollbar {
  1178. width: 8px;
  1179. }
  1180. .chMainDiv::-webkit-scrollbar-thumb {
  1181. background-color: rgba(0, 0, 0, 0.5);
  1182. }
  1183. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1184. background-color: rgba(0, 0, 0, 0.7);
  1185. }
  1186. .chMainBox {
  1187. display:none;
  1188. position: absolute;
  1189. left: 10px;
  1190. bottom: 10px;
  1191. width: 380px;
  1192. height: 25px;
  1193. background-color: rgba(255, 255, 255, 0.1);
  1194. border-radius: 5px;
  1195. color: rgba(255, 255, 255, 0.75);
  1196. font-family: "HammerSmith One";
  1197. font-size: 12px;
  1198. }
  1199. `);
  1200. HTML.startDiv({
  1201. id: "mChDiv",
  1202. class: "chDiv"
  1203. }, (html) => {
  1204. HTML.addDiv({
  1205. id: "mChMain",
  1206. class: "chMainDiv",
  1207. appendID: "mChDiv"
  1208. }, (html) => {});
  1209. html.text({
  1210. id: "mChBox",
  1211. class: "chMainBox",
  1212. // placeHolder: `To chat click here or press "Enter" key`
  1213. });
  1214. });
  1215.  
  1216. let menuChats = getEl("mChMain");
  1217. let menuChatBox = getEl("mChBox");
  1218. let menuCBFocus = false;
  1219. let menuChCounts = 0;
  1220.  
  1221. menuChatBox.value = "";
  1222. menuChatBox.addEventListener("focus", () => {
  1223. menuCBFocus = true;
  1224. });
  1225. menuChatBox.addEventListener("blur", () => {
  1226. menuCBFocus = false;
  1227. });
  1228.  
  1229. function addMenuChText(name, message, color, noTimer) {
  1230. HTML.set("menuChatDiv");
  1231. color = color || "white";
  1232. let time = new Date();
  1233. let min = time.getMinutes();
  1234. let hour = time.getHours();
  1235. let text = ``;
  1236. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1237. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1238. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1239. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1240. html.add(text);
  1241. });
  1242. menuChats.scrollTop = menuChats.scrollHeight;
  1243. menuChCounts++;
  1244. }
  1245. function chch(name, message, color, noTimer) {
  1246. HTML.set("menuChatDiv");
  1247. color = color || "white";
  1248. let time = new Date();
  1249. let text = ``;
  1250. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1251. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1252. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1253. html.add(text);
  1254. });
  1255. menuChats.scrollTop = menuChats.scrollHeight;
  1256. menuChCounts++;
  1257. }
  1258.  
  1259. function resetMenuChText() {
  1260. menuChats.innerHTML = ``;
  1261. menuChCounts = 0;
  1262. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1263. }
  1264. resetMenuChText();
  1265.  
  1266. let menuIndex = 0;
  1267. let menus = ["menuMain", "menuConfig", "menuOther"];
  1268. window.changeMenu = function() {
  1269. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1270. menuIndex++;
  1271. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1272. };
  1273.  
  1274. let mStatus = document.createElement("div");
  1275. mStatus.id = "status";
  1276. getEl("gameUI").appendChild(mStatus);
  1277. HTML.set("status");
  1278. HTML.setStyle(`
  1279. display: block;
  1280. position: absolute;
  1281. color: #ddd;
  1282. font: 15px Hammersmith One;
  1283. bottom: 215px;
  1284. left: 20px;
  1285. `);
  1286. HTML.resetHTML();
  1287. HTML.setCSS(`
  1288. .sizing {
  1289. font-size: 15px;
  1290. }
  1291. .mod {
  1292. font-size: 15px;
  1293. display: inline-block;
  1294. }
  1295. `);
  1296. HTML.startDiv({
  1297. id: "uehmod",
  1298. class: "sizing"
  1299. }, (html) => {
  1300. html.add(`Ping: `);
  1301. HTML.addDiv({
  1302. id: "pingFps",
  1303. class: "mod",
  1304. appendID: "uehmod"
  1305. }, (html) => {
  1306. html.add("None");
  1307. });
  1308. html.newLine();
  1309. html.add(`Packet: `);
  1310. HTML.addDiv({
  1311. id: "packetStatus",
  1312. class: "mod",
  1313. appendID: "uehmod"
  1314. }, (html) => {
  1315. html.add("None");
  1316. });
  1317. });
  1318.  
  1319. /*function modLog() {
  1320. let logs = [];
  1321. for (let i = 0; i < arguments.length; i++) {
  1322. logs.push(arguments[i]);
  1323. }
  1324. getEl("modLog").innerHTML = logs;
  1325. }*/
  1326.  
  1327. let openMenu = false;
  1328.  
  1329. let WS = undefined;
  1330. let socketID = undefined;
  1331.  
  1332. let useWasd = true;
  1333. let secPacket = 0;
  1334. let secMax = 120;
  1335. let secTime = 1000;
  1336. let firstSend = {
  1337. sec: false
  1338. };
  1339. let game = {
  1340. tick: 0,
  1341. tickQueue: [],
  1342. tickBase: function(set, tick) {
  1343. if (this.tickQueue[this.tick + tick]) {
  1344. this.tickQueue[this.tick + tick].push(set);
  1345. } else {
  1346. this.tickQueue[this.tick + tick] = [set];
  1347. }
  1348. },
  1349. tickRate: (1000 / config.serverUpdateRate),
  1350. tickSpeed: 0,
  1351. lastTick: performance.now()
  1352. };
  1353. let modConsole = [];
  1354.  
  1355. let dontSend = false;
  1356. let fpsTimer = {
  1357. last: 0,
  1358. time: 0,
  1359. ltime: 0
  1360. }
  1361. let lastMoveDir = undefined;
  1362. let lastsp = ["cc", 1, "__proto__"];
  1363.  
  1364. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1365. WebSocket.prototype.send = function(message) {
  1366. if (!WS) {
  1367. WS = this;
  1368. WS.addEventListener("message", function(msg) {
  1369. getMessage(msg);
  1370. });
  1371. WS.addEventListener("close", (event) => {
  1372. if (event.code == 4001) {
  1373. window.location.reload();
  1374. }
  1375. });
  1376. }
  1377. if (WS == this) {
  1378. dontSend = false;
  1379.  
  1380. // EXTRACT DATA ARRAY:
  1381. let data = new Uint8Array(message);
  1382. let parsed = window.msgpack.decode(data);
  1383. let type = parsed[0];
  1384. data = parsed[1];
  1385.  
  1386. // SEND MESSAGE:
  1387. if (type == "6") {
  1388.  
  1389. if (data[0]) {
  1390. // ANTI PROFANITY:
  1391. 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", ];
  1392. let tmpString;
  1393. profanity.forEach((profany) => {
  1394. if (data[0].indexOf(profany) > -1) {
  1395. tmpString = "";
  1396. for (let i = 0; i < profany.length; ++i) {
  1397. if (i == 1) {
  1398. tmpString += String.fromCharCode(0);
  1399. }
  1400. tmpString += profany[i];
  1401. }
  1402. let re = new RegExp(profany, "g");
  1403. data[0] = data[0].replace(re, tmpString);
  1404. }
  1405. });
  1406.  
  1407. // FIX CHAT:
  1408. data[0] = data[0].slice(0, 30);
  1409. }
  1410.  
  1411. } else if (type == "L") {
  1412. // MAKE SAME CLAN:
  1413. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1414. data[0] = data[0].slice(0, 7);
  1415. } else if (type == "M") {
  1416. // APPLY CYAN COLOR:
  1417. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1418. data[0].moofoll = true;
  1419. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1420. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1421. } else if (type == "D") {
  1422. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1423. dontSend = true;
  1424. } else {
  1425. my.lastDir = data[0];
  1426. }
  1427. } else if (type == "d") {
  1428. if (!data[2]) {
  1429. dontSend = true;
  1430. } else {
  1431. if (![null, undefined].includes(data[1])) {
  1432. my.lastDir = data[1];
  1433. }
  1434. }
  1435. } else if (type == "K") {
  1436. if (!data[1]) {
  1437. dontSend = true;
  1438. }
  1439. } else if (type == "S") {
  1440. instaC.wait = !instaC.wait;
  1441. dontSend = true;
  1442. } else if (type == "a") {
  1443. if (data[1]) {
  1444. if (player.moveDir == data[0]) {
  1445. dontSend = true;
  1446. }
  1447. player.moveDir = data[0];
  1448. } else {
  1449. dontSend = true;
  1450. }
  1451. }
  1452. if (!dontSend) {
  1453. let binary = window.msgpack.encode([type, data]);
  1454. this.nsend(binary);
  1455.  
  1456. // START COUNT:
  1457. if (!firstSend.sec) {
  1458. firstSend.sec = true;
  1459. setTimeout(() => {
  1460. firstSend.sec = false;
  1461. secPacket = 0;
  1462. }, secTime);
  1463. }
  1464.  
  1465. secPacket++;
  1466. }
  1467. } else {
  1468. this.nsend(message);
  1469. }
  1470. }
  1471.  
  1472. function packet(type) {
  1473. // EXTRACT DATA ARRAY:
  1474. let data = Array.prototype.slice.call(arguments, 1);
  1475.  
  1476. // SEND MESSAGE:
  1477. let binary = window.msgpack.encode([type, data]);
  1478. WS.send(binary);
  1479. }
  1480.  
  1481. function origPacket(type) {
  1482. // EXTRACT DATA ARRAY:
  1483. let data = Array.prototype.slice.call(arguments, 1);
  1484.  
  1485. // SEND MESSAGE:
  1486. let binary = window.msgpack.encode([type, data]);
  1487. WS.nsend(binary);
  1488. }
  1489.  
  1490. window.leave = function() {
  1491. origPacket("kys", {
  1492. "frvr is so bad": true,
  1493. "sidney is too good": true,
  1494. "dev are too weak": true,
  1495. });
  1496. };
  1497.  
  1498. //...lol
  1499. let io = {
  1500. send: packet
  1501. };
  1502.  
  1503. function getMessage(message) {
  1504. let data = new Uint8Array(message.data);
  1505. let parsed = window.msgpack.decode(data);
  1506. let type = parsed[0];
  1507. data = parsed[1];
  1508. let events = {
  1509. A: setInitData, // id: setInitData,
  1510. //B: disconnect,
  1511. C: setupGame, // 1: setupGame,
  1512. D: addPlayer, // 2: addPlayer,
  1513. E: removePlayer, // 4: removePlayer,
  1514. a: updatePlayers, // 33: updatePlayers,
  1515. G: updateLeaderboard, // 5: updateLeaderboard,here
  1516. H: loadGameObject, // 6: loadGameObject,
  1517. I: loadAI, // a: loadAI,
  1518. J: animateAI, // aa: animateAI,
  1519. K: gatherAnimation, // 7: gatherAnimation,
  1520. L: wiggleGameObject, // 8: wiggleGameObject,
  1521. M: shootTurret, // sp: shootTurret,
  1522. N: updatePlayerValue, // 9: updatePlayerValue,
  1523. O: updateHealth, // h: updateHealth,//here
  1524. P: killPlayer, // 11: killPlayer,
  1525. Q: killObject, // 12: killObject,
  1526. R: killObjects, // 13: killObjects,
  1527. S: updateItemCounts, // 14: updateItemCounts,
  1528. T: updateAge, // 15: updateAge,
  1529. U: updateUpgrades, // 16: updateUpgrades,
  1530. V: updateItems, // 17: updateItems,
  1531. X: addProjectile, // 18: addProjectile,
  1532. // Y: remProjectile, // 19: remProjectile,
  1533. //Z: serverShutdownNotice,
  1534. //0: addAlliance,
  1535. //1: deleteAlliance,
  1536. 2: allianceNotification, // an: allianceNotification,
  1537. 3: setPlayerTeam, // st: setPlayerTeam,
  1538. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1539. 5: updateStoreItems, // us: updateStoreItems,
  1540. 6: receiveChat, // ch: receiveChat,
  1541. 7: updateMinimap, // mm: updateMinimap,
  1542. 8: showText, // t: showText,
  1543. 9: pingMap, // p: pingMap,
  1544. 0: pingSocketResponse,
  1545. };
  1546. if (type == "io-init") {
  1547. socketID = data[0];
  1548. } else {
  1549. if (events[type]) {
  1550. events[type].apply(undefined, data);
  1551. }
  1552. }
  1553. }
  1554.  
  1555. // MATHS:
  1556. Math.lerpAngle = function(value1, value2, amount) {
  1557. let difference = Math.abs(value2 - value1);
  1558. if (difference > Math.PI) {
  1559. if (value1 > value2) {
  1560. value2 += Math.PI * 2;
  1561. } else {
  1562. value1 += Math.PI * 2;
  1563. }
  1564. }
  1565. let value = value2 + ((value1 - value2) * amount);
  1566. if (value >= 0 && value <= Math.PI * 2) return value;
  1567. return value % (Math.PI * 2);
  1568. };
  1569.  
  1570. // REOUNDED RECTANGLE:
  1571. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1572. if (w < 2 * r) r = w / 2;
  1573. if (h < 2 * r) r = h / 2;
  1574. if (r < 0)
  1575. r = 0;
  1576. this.beginPath();
  1577. this.moveTo(x + r, y);
  1578. this.arcTo(x + w, y, x + w, y + h, r);
  1579. this.arcTo(x + w, y + h, x, y + h, r);
  1580. this.arcTo(x, y + h, x, y, r);
  1581. this.arcTo(x, y, x + w, y, r);
  1582. this.closePath();
  1583. return this;
  1584. };
  1585.  
  1586. // GLOBAL VALUES:
  1587. function resetMoveDir() {
  1588. keys = {};
  1589. io.send("e");
  1590. }
  1591.  
  1592. let allChats = [];
  1593. let ticks = {
  1594. tick: 0,
  1595. delay: 0,
  1596. time: [],
  1597. manage: [],
  1598. };
  1599. let ais = [];
  1600. let players = [];
  1601. let alliances = [];
  1602. let alliancePlayers = [];
  1603. let allianceNotifications = [];
  1604. let gameObjects = [];
  1605. let liztobj = [];
  1606. let projectiles = [];
  1607. let deadPlayers = [];
  1608.  
  1609. let breakObjects = [];
  1610.  
  1611. let player;
  1612. let playerSID;
  1613. let tmpObj;
  1614.  
  1615. let enemy = [];
  1616. let nears = [];
  1617. let near = [];
  1618.  
  1619. let my = {
  1620. reloaded: false,
  1621. waitHit: 0,
  1622. autoAim: false,
  1623. revAim: false,
  1624. ageInsta: true,
  1625. reSync: false,
  1626. bullTick: 0,
  1627. anti0Tick: 0,
  1628. antiSync: false,
  1629. safePrimary: function(tmpObj) {
  1630. return [0, 8].includes(tmpObj.primaryIndex);
  1631. },
  1632. safeSecondary: function(tmpObj) {
  1633. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1634. },
  1635. lastDir: 0,
  1636. autoPush: false,
  1637. pushData: {}
  1638. }
  1639.  
  1640. // FIND OBJECTS BY ID/SID:
  1641. function findID(tmpObj, tmp) {
  1642. return tmpObj.find((THIS) => THIS.id == tmp);
  1643. }
  1644.  
  1645. function findSID(tmpObj, tmp) {
  1646. return tmpObj.find((THIS) => THIS.sid == tmp);
  1647. }
  1648.  
  1649. function findPlayerByID(id) {
  1650. return findID(players, id);
  1651. }
  1652.  
  1653. function findPlayerBySID(sid) {
  1654. return findSID(players, sid);
  1655. }
  1656.  
  1657. function findAIBySID(sid) {
  1658. return findSID(ais, sid);
  1659. }
  1660.  
  1661. function findObjectBySid(sid) {
  1662. return findSID(gameObjects, sid);
  1663. }
  1664.  
  1665. function findProjectileBySid(sid) {
  1666. return findSID(gameObjects, sid);
  1667. }
  1668.  
  1669. let adCard = getEl("adCard");
  1670. adCard.remove();
  1671. let promoImageHolder = getEl("promoImgHolder");
  1672. promoImageHolder.remove();
  1673.  
  1674. let chatButton = getEl("chatButton");
  1675. chatButton.remove();
  1676. let gameCanvas = getEl("gameCanvas");
  1677. let mainContext = gameCanvas.getContext("2d");
  1678. let mapDisplay = getEl("mapDisplay");
  1679. let mapContext = mapDisplay.getContext("2d");
  1680. mapDisplay.width = 300;
  1681. mapDisplay.height = 300;
  1682. let storeMenu = getEl("storeMenu");
  1683. let storeHolder = getEl("storeHolder");
  1684. let upgradeHolder = getEl("upgradeHolder");
  1685. let upgradeCounter = getEl("upgradeCounter");
  1686. let chatBox = getEl("chatBox");
  1687. chatBox.autocomplete = "off";
  1688. chatBox.style.textAlign = "center";
  1689. chatBox.style.width = "18em";
  1690. let chatHolder = getEl("chatHolder");
  1691. let actionBar = getEl("actionBar");
  1692. let leaderboardData = getEl("leaderboardData");
  1693. let itemInfoHolder = getEl("itemInfoHolder");
  1694. let menuCardHolder = getEl("menuCardHolder");
  1695. let mainMenu = getEl("mainMenu");
  1696. let diedText = getEl("diedText");
  1697. let screenWidth;
  1698. let screenHeight;
  1699. let maxScreenWidth = config.maxScreenWidth;
  1700. let maxScreenHeight = config.maxScreenHeight;
  1701. let pixelDensity = 1;
  1702. let delta;
  1703. let now;
  1704. let lastUpdate = performance.now();
  1705. let camX;
  1706. let camY;
  1707. let tmpDir;
  1708. let mouseX = 0;
  1709. let mouseY = 0;
  1710. let allianceMenu = getEl("allianceMenu");
  1711. let waterMult = 1;
  1712. let waterPlus = 0;
  1713.  
  1714. let outlineColor = "#525252";
  1715. let darkOutlineColor = "#3d3f42";
  1716. let outlineWidth = 5.5;
  1717.  
  1718. let firstSetup = true;
  1719. let keys = {};
  1720. let moveKeys = {
  1721. 87: [0, -1],
  1722. 38: [0, -1],
  1723. 83: [0, 1],
  1724. 40: [0, 1],
  1725. 65: [-1, 0],
  1726. 37: [-1, 0],
  1727. 68: [1, 0],
  1728. 39: [1, 0],
  1729. };
  1730. let attackState = 0;
  1731. let inGame = false;
  1732.  
  1733. let macro = {};
  1734. let mills = {
  1735. place: 0,
  1736. placeSpawnPads: 0
  1737. };
  1738. let lastDir;
  1739.  
  1740. let lastLeaderboardData = [];
  1741.  
  1742. // ON LOAD:
  1743. let inWindow = true;
  1744. window.onblur = function() {
  1745. inWindow = false;
  1746. };
  1747. window.onfocus = function() {
  1748. inWindow = true;
  1749. if (player && player.alive) {
  1750. // resetMoveDir();
  1751. }
  1752. };
  1753. let ms = {
  1754. avg: 0,
  1755. max: 0,
  1756. min: 0,
  1757. delay: 0
  1758. }
  1759. function pingSocketResponse() {
  1760. let pingTime = window.pingTime;
  1761. const pingDisplay = document.getElementById("pingDisplay")
  1762. pingDisplay.innerText = "";
  1763. if (pingTime > ms.max || isNaN(ms.max)) {
  1764. ms.max = pingTime;
  1765. }
  1766. if (pingTime < ms.min || isNaN(ms.min)) {
  1767. ms.min = pingTime;
  1768. }
  1769.  
  1770. // if (pingTime >= 90) {
  1771. // doAutoQ = true;
  1772. // } else {
  1773. // doAutoQ = false;
  1774. // }
  1775. }
  1776.  
  1777. let placeVisible = [];
  1778.  
  1779. /** CLASS CODES */
  1780.  
  1781. class Utils {
  1782. constructor() {
  1783.  
  1784. // MATH UTILS:
  1785. let mathABS = Math.abs,
  1786. mathCOS = Math.cos,
  1787. mathSIN = Math.sin,
  1788. mathPOW = Math.pow,
  1789. mathSQRT = Math.sqrt,
  1790. mathATAN2 = Math.atan2,
  1791. mathPI = Math.PI;
  1792.  
  1793. let _this = this;
  1794.  
  1795. // GLOBAL UTILS:
  1796. this.round = function(n, v) {
  1797. return Math.round(n * v) / v;
  1798. };
  1799. this.toRad = function(angle) {
  1800. return angle * (mathPI / 180);
  1801. };
  1802. this.toAng = function(radian) {
  1803. return radian / (mathPI / 180);
  1804. };
  1805. this.randInt = function(min, max) {
  1806. return Math.floor(Math.random() * (max - min + 1)) + min;
  1807. };
  1808. this.randFloat = function(min, max) {
  1809. return Math.random() * (max - min + 1) + min;
  1810. };
  1811. this.lerp = function(value1, value2, amount) {
  1812. return value1 + (value2 - value1) * amount;
  1813. };
  1814. this.decel = function(val, cel) {
  1815. if (val > 0)
  1816. val = Math.max(0, val - cel);
  1817. else if (val < 0)
  1818. val = Math.min(0, val + cel);
  1819. return val;
  1820. };
  1821. this.getDistance = function(x1, y1, x2, y2) {
  1822. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1823. };
  1824. this.getDist = function(tmp1, tmp2, type1, type2) {
  1825. let tmpXY1 = {
  1826. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1827. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1828. };
  1829. let tmpXY2 = {
  1830. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1831. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1832. };
  1833. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1834. };
  1835. this.getDirection = function(x1, y1, x2, y2) {
  1836. return mathATAN2(y1 - y2, x1 - x2);
  1837. };
  1838. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1839. let tmpXY1 = {
  1840. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1841. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1842. };
  1843. let tmpXY2 = {
  1844. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1845. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1846. };
  1847. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1848. };
  1849. this.getAngleDist = function(a, b) {
  1850. let p = mathABS(b - a) % (mathPI * 2);
  1851. return (p > mathPI ? (mathPI * 2) - p : p);
  1852. };
  1853. this.isNumber = function(n) {
  1854. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1855. };
  1856. this.isString = function(s) {
  1857. return (s && typeof s == "string");
  1858. };
  1859. this.kFormat = function(num) {
  1860. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1861. };
  1862. this.sFormat = function(num) {
  1863. let fixs = [{
  1864. num: 1e3,
  1865. string: "k"
  1866. },
  1867. {
  1868. num: 1e6,
  1869. string: "m"
  1870. },
  1871. {
  1872. num: 1e9,
  1873. string: "b"
  1874. },
  1875. {
  1876. num: 1e12,
  1877. string: "q"
  1878. }
  1879. ].reverse();
  1880. let sp = fixs.find(v => num >= v.num);
  1881. if (!sp) return num;
  1882. return (num / sp.num).toFixed(1) + sp.string;
  1883. };
  1884. this.capitalizeFirst = function(string) {
  1885. return string.charAt(0).toUpperCase() + string.slice(1);
  1886. };
  1887. this.fixTo = function(n, v) {
  1888. return parseFloat(n.toFixed(v));
  1889. };
  1890. this.sortByPoints = function(a, b) {
  1891. return parseFloat(b.points) - parseFloat(a.points);
  1892. };
  1893. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1894. let minX = x1;
  1895. let maxX = x2;
  1896. if (x1 > x2) {
  1897. minX = x2;
  1898. maxX = x1;
  1899. }
  1900. if (maxX > recX2)
  1901. maxX = recX2;
  1902. if (minX < recX)
  1903. minX = recX;
  1904. if (minX > maxX)
  1905. return false;
  1906. let minY = y1;
  1907. let maxY = y2;
  1908. let dx = x2 - x1;
  1909. if (Math.abs(dx) > 0.0000001) {
  1910. let a = (y2 - y1) / dx;
  1911. let b = y1 - a * x1;
  1912. minY = a * minX + b;
  1913. maxY = a * maxX + b;
  1914. }
  1915. if (minY > maxY) {
  1916. let tmp = maxY;
  1917. maxY = minY;
  1918. minY = tmp;
  1919. }
  1920. if (maxY > recY2)
  1921. maxY = recY2;
  1922. if (minY < recY)
  1923. minY = recY;
  1924. if (minY > maxY)
  1925. return false;
  1926. return true;
  1927. };
  1928. this.containsPoint = function(element, x, y) {
  1929. let bounds = element.getBoundingClientRect();
  1930. let left = bounds.left + window.scrollX;
  1931. let top = bounds.top + window.scrollY;
  1932. let width = bounds.width;
  1933. let height = bounds.height;
  1934.  
  1935. let insideHorizontal = x > left && x < left + width;
  1936. let insideVertical = y > top && y < top + height;
  1937. return insideHorizontal && insideVertical;
  1938. };
  1939. this.mousifyTouchEvent = function(event) {
  1940. let touch = event.changedTouches[0];
  1941. event.screenX = touch.screenX;
  1942. event.screenY = touch.screenY;
  1943. event.clientX = touch.clientX;
  1944. event.clientY = touch.clientY;
  1945. event.pageX = touch.pageX;
  1946. event.pageY = touch.pageY;
  1947. };
  1948. this.hookTouchEvents = function(element, skipPrevent) {
  1949. let preventDefault = !skipPrevent;
  1950. let isHovering = false;
  1951. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1952. let passive = false;
  1953. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1954. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1955. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1956. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1957. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1958.  
  1959. function touchStart(e) {
  1960. _this.mousifyTouchEvent(e);
  1961. window.setUsingTouch(true);
  1962. if (preventDefault) {
  1963. e.preventDefault();
  1964. e.stopPropagation();
  1965. }
  1966. if (element.onmouseover)
  1967. element.onmouseover(e);
  1968. isHovering = true;
  1969. }
  1970.  
  1971. function touchMove(e) {
  1972. _this.mousifyTouchEvent(e);
  1973. window.setUsingTouch(true);
  1974. if (preventDefault) {
  1975. e.preventDefault();
  1976. e.stopPropagation();
  1977. }
  1978. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1979. if (!isHovering) {
  1980. if (element.onmouseover)
  1981. element.onmouseover(e);
  1982. isHovering = true;
  1983. }
  1984. } else {
  1985. if (isHovering) {
  1986. if (element.onmouseout)
  1987. element.onmouseout(e);
  1988. isHovering = false;
  1989. }
  1990. }
  1991. }
  1992.  
  1993. function touchEnd(e) {
  1994. _this.mousifyTouchEvent(e);
  1995. window.setUsingTouch(true);
  1996. if (preventDefault) {
  1997. e.preventDefault();
  1998. e.stopPropagation();
  1999. }
  2000. if (isHovering) {
  2001. if (element.onclick)
  2002. element.onclick(e);
  2003. if (element.onmouseout)
  2004. element.onmouseout(e);
  2005. isHovering = false;
  2006. }
  2007. }
  2008. };
  2009. this.removeAllChildren = function(element) {
  2010. while (element.hasChildNodes()) {
  2011. element.removeChild(element.lastChild);
  2012. }
  2013. };
  2014. this.generateElement = function(config) {
  2015. let element = document.createElement(config.tag || "div");
  2016.  
  2017. function bind(configValue, elementValue) {
  2018. if (config[configValue])
  2019. element[elementValue] = config[configValue];
  2020. }
  2021. bind("text", "textContent");
  2022. bind("html", "innerHTML");
  2023. bind("class", "className");
  2024. for (let key in config) {
  2025. switch (key) {
  2026. case "tag":
  2027. case "text":
  2028. case "html":
  2029. case "class":
  2030. case "style":
  2031. case "hookTouch":
  2032. case "parent":
  2033. case "children":
  2034. continue;
  2035. default:
  2036. break;
  2037. }
  2038. element[key] = config[key];
  2039. }
  2040. if (element.onclick)
  2041. element.onclick = this.checkTrusted(element.onclick);
  2042. if (element.onmouseover)
  2043. element.onmouseover = this.checkTrusted(element.onmouseover);
  2044. if (element.onmouseout)
  2045. element.onmouseout = this.checkTrusted(element.onmouseout);
  2046. if (config.style) {
  2047. element.style.cssText = config.style;
  2048. }
  2049. if (config.hookTouch) {
  2050. this.hookTouchEvents(element);
  2051. }
  2052. if (config.parent) {
  2053. config.parent.appendChild(element);
  2054. }
  2055. if (config.children) {
  2056. for (let i = 0; i < config.children.length; i++) {
  2057. element.appendChild(config.children[i]);
  2058. }
  2059. }
  2060. return element;
  2061. };
  2062. this.checkTrusted = function(callback) {
  2063. return function(ev) {
  2064. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2065. callback(ev);
  2066. } else {
  2067. //console.error("Event is not trusted.", ev);
  2068. }
  2069. };
  2070. };
  2071. this.randomString = function(length) {
  2072. let text = "";
  2073. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2074. for (let i = 0; i < length; i++) {
  2075. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2076. }
  2077. return text;
  2078. };
  2079. this.countInArray = function(array, val) {
  2080. let count = 0;
  2081. for (let i = 0; i < array.length; i++) {
  2082. if (array[i] === val) count++;
  2083. }
  2084. return count;
  2085. };
  2086. this.hexToRgb = function(hex) {
  2087. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2088. };
  2089. this.getRgb = function(r, g, b) {
  2090. return [r / 255, g / 255, b / 255].join(", ");
  2091. };
  2092. }
  2093. };
  2094. class Animtext {
  2095. // ANIMATED TEXT:
  2096. constructor() {
  2097. // INIT:
  2098. this.init = function(x, y, scale, speed, life, text, color) {
  2099. (this.x = x),
  2100. (this.y = y),
  2101. (this.color = color),
  2102. (this.scale = scale*3.5),
  2103. (this.weight = 50);
  2104. (this.startScale = this.scale * 1.2),
  2105. (this.maxScale = 1.5 * scale),
  2106. (this.minScale = 0.5 * scale),
  2107. (this.scaleSpeed = 0.7),
  2108. (this.speed = speed),
  2109. (this.speedMax = speed),
  2110. (this.life = life),
  2111. (this.maxLife = life),
  2112. (this.text = text),
  2113. this.movSpeed = speed;
  2114. };
  2115.  
  2116. // UPDATE:
  2117. this.update = function(delta) {
  2118. if(this.life){
  2119. this.life -= delta;
  2120. if(this.scaleSpeed != -0.35){
  2121. this.y -= this.speed * delta;
  2122. // (this.x += this.speed * delta);
  2123. } else {
  2124. this.y -= this.speed * delta;
  2125. }
  2126. this.scale -= .8;
  2127. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2128. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2129. if(this.scale >= this.maxScale){
  2130. this.scale = this.maxScale;
  2131. this.scaleSpeed *= -.5;
  2132. this.speed = this.speed * .75;
  2133. };
  2134. this.life <= 0 && (this.life = 0)
  2135. };
  2136. };
  2137.  
  2138. // RENDER:
  2139. this.render = function(ctxt, xOff, yOff) {
  2140. ctxt.lineWidth = 10;
  2141. ctxt.strokeStyle = darkOutlineColor; //"black";
  2142. ctxt.fillStyle = this.color;
  2143. ctxt.globalAlpha = 1;
  2144. ctxt.font = this.scale + "px Hammersmith One";
  2145. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2146. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2147. ctxt.globalAlpha = 1;
  2148. };
  2149. }
  2150. };
  2151. class Textmanager {
  2152. // TEXT MANAGER:
  2153. constructor() {
  2154. this.texts = [];
  2155. this.stack = [];
  2156.  
  2157. // UPDATE:
  2158. this.update = function(delta, ctxt, xOff, yOff) {
  2159. ctxt.textBaseline = "middle";
  2160. ctxt.textAlign = "center";
  2161. for (let i = 0; i < this.texts.length; ++i) {
  2162. if (this.texts[i].life) {
  2163. this.texts[i].update(delta);
  2164. this.texts[i].render(ctxt, xOff, yOff);
  2165. }
  2166. }
  2167. };
  2168.  
  2169. // SHOW TEXT:
  2170. this.showText = function(x, y, scale, speed, life, text, color) {
  2171. let tmpText;
  2172. for (let i = 0; i < this.texts.length; ++i) {
  2173. if (!this.texts[i].life) {
  2174. tmpText = this.texts[i];
  2175. break;
  2176. }
  2177. }
  2178. if (!tmpText) {
  2179. tmpText = new Animtext();
  2180. this.texts.push(tmpText);
  2181. }
  2182. tmpText.init(x, y, scale, speed, life, text, color);
  2183. };
  2184. }
  2185. }
  2186.  
  2187. class GameObject {
  2188. constructor(sid) {
  2189. this.sid = sid;
  2190.  
  2191. // INIT:
  2192. this.init = function(x, y, dir, scale, type, data, owner) {
  2193. data = data || {};
  2194. this.sentTo = {};
  2195. this.gridLocations = [];
  2196. this.active = true;
  2197. this.render = true;
  2198. this.doUpdate = data.doUpdate;
  2199. this.x = x;
  2200. this.y = y;
  2201. this.dir = dir;
  2202. this.lastDir = dir;
  2203. this.xWiggle = 0;
  2204. this.yWiggle = 0;
  2205. this.visScale = scale;
  2206. this.scale = scale;
  2207. this.type = type;
  2208. this.id = data.id;
  2209. this.owner = owner;
  2210. this.name = data.name;
  2211. this.isItem = (this.id != undefined);
  2212. this.group = data.group;
  2213. this.maxHealth = data.health;
  2214. this.health = this.maxHealth;
  2215. this.layer = 2;
  2216. if (this.group != undefined) {
  2217. this.layer = this.group.layer;
  2218. } else if (this.type == 0) {
  2219. this.layer = 3;
  2220. } else if (this.type == 2) {
  2221. this.layer = 0;
  2222. } else if (this.type == 4) {
  2223. this.layer = -1;
  2224. }
  2225. this.colDiv = data.colDiv || 1;
  2226. this.blocker = data.blocker;
  2227. this.ignoreCollision = data.ignoreCollision;
  2228. this.dontGather = data.dontGather;
  2229. this.hideFromEnemy = data.hideFromEnemy;
  2230. this.friction = data.friction;
  2231. this.projDmg = data.projDmg;
  2232. this.dmg = data.dmg;
  2233. this.pDmg = data.pDmg;
  2234. this.pps = data.pps;
  2235. this.zIndex = data.zIndex || 0;
  2236. this.turnSpeed = data.turnSpeed;
  2237. this.req = data.req;
  2238. this.trap = data.trap;
  2239. this.healCol = data.healCol;
  2240. this.teleport = data.teleport;
  2241. this.boostSpeed = data.boostSpeed;
  2242. this.projectile = data.projectile;
  2243. this.shootRange = data.shootRange;
  2244. this.shootRate = data.shootRate;
  2245. this.shootCount = this.shootRate;
  2246. this.spawnPoint = data.spawnPoint;
  2247. this.onNear = 0;
  2248. this.breakObj = false;
  2249. this.alpha = data.alpha || 1;
  2250. this.maxAlpha = data.alpha || 1;
  2251. this.damaged = 0;
  2252. };
  2253.  
  2254. // GET HIT:
  2255. this.changeHealth = function(amount, doer) {
  2256. this.health += amount;
  2257. return (this.health <= 0);
  2258. };
  2259.  
  2260. // GET SCALE:
  2261. this.getScale = function(sM, ig) {
  2262. sM = sM || 1;
  2263. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2264. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2265. };
  2266.  
  2267. // VISIBLE TO PLAYER:
  2268. this.visibleToPlayer = function(player) {
  2269. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2270. (this.owner.team && player.team == this.owner.team)));
  2271. };
  2272.  
  2273. // UPDATE:
  2274. this.update = function(delta) {
  2275. if (this.active) {
  2276. if (this.xWiggle) {
  2277. this.xWiggle *= Math.pow(0.99, delta);
  2278. }
  2279. if (this.yWiggle) {
  2280. this.yWiggle *= Math.pow(0.99, delta);
  2281. }
  2282. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2283. if (d2 > 0.01) {
  2284. this.dir += d2 / 5;
  2285. } else {
  2286. this.dir = this.lastDir;
  2287. }
  2288. } else {
  2289. if (this.alive) {
  2290. this.alpha -= delta / (200 / this.maxAlpha);
  2291. this.visScale += delta / (this.scale / 2.5);
  2292. if (this.alpha <= 0) {
  2293. this.alpha = 0;
  2294. this.alive = false;
  2295. }
  2296. }
  2297. }
  2298. };
  2299.  
  2300. // CHECK TEAM:
  2301. this.isTeamObject = function(tmpObj) {
  2302. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2303. };
  2304. }
  2305. }
  2306. class Items {
  2307. constructor() {
  2308. // ITEM GROUPS:
  2309. this.groups = [{
  2310. id: 0,
  2311. name: "food",
  2312. layer: 0
  2313. }, {
  2314. id: 1,
  2315. name: "walls",
  2316. place: true,
  2317. limit: 30,
  2318. layer: 0
  2319. }, {
  2320. id: 2,
  2321. name: "spikes",
  2322. place: true,
  2323. limit: 15,
  2324. layer: 0
  2325. }, {
  2326. id: 3,
  2327. name: "mill",
  2328. place: true,
  2329. limit: 7,
  2330. layer: 1
  2331. }, {
  2332. id: 4,
  2333. name: "mine",
  2334. place: true,
  2335. limit: 1,
  2336. layer: 0
  2337. }, {
  2338. id: 5,
  2339. name: "trap",
  2340. place: true,
  2341. limit: 6,
  2342. layer: -1
  2343. }, {
  2344. id: 6,
  2345. name: "booster",
  2346. place: true,
  2347. limit: 12,
  2348. layer: -1
  2349. }, {
  2350. id: 7,
  2351. name: "turret",
  2352. place: true,
  2353. limit: 2,
  2354. layer: 1
  2355. }, {
  2356. id: 8,
  2357. name: "watchtower",
  2358. place: true,
  2359. limit: 12,
  2360. layer: 1
  2361. }, {
  2362. id: 9,
  2363. name: "buff",
  2364. place: true,
  2365. limit: 4,
  2366. layer: -1
  2367. }, {
  2368. id: 10,
  2369. name: "spawn",
  2370. place: true,
  2371. limit: 1,
  2372. layer: -1
  2373. }, {
  2374. id: 11,
  2375. name: "sapling",
  2376. place: true,
  2377. limit: 2,
  2378. layer: 0
  2379. }, {
  2380. id: 12,
  2381. name: "blocker",
  2382. place: true,
  2383. limit: 3,
  2384. layer: -1
  2385. }, {
  2386. id: 13,
  2387. name: "teleporter",
  2388. place: true,
  2389. limit: 2,
  2390. layer: -1
  2391. }];
  2392.  
  2393. // PROJECTILES:
  2394. this.projectiles = [{
  2395. indx: 0,
  2396. layer: 0,
  2397. src: "arrow_1",
  2398. dmg: 25,
  2399. speed: 1.6,
  2400. scale: 103,
  2401. range: 1000
  2402. }, {
  2403. indx: 1,
  2404. layer: 1,
  2405. dmg: 25,
  2406. scale: 20
  2407. }, {
  2408. indx: 0,
  2409. layer: 0,
  2410. src: "arrow_1",
  2411. dmg: 35,
  2412. speed: 2.5,
  2413. scale: 103,
  2414. range: 1200
  2415. }, {
  2416. indx: 0,
  2417. layer: 0,
  2418. src: "arrow_1",
  2419. dmg: 30,
  2420. speed: 2,
  2421. scale: 103,
  2422. range: 1200
  2423. }, {
  2424. indx: 1,
  2425. layer: 1,
  2426. dmg: 16,
  2427. scale: 20
  2428. }, {
  2429. indx: 0,
  2430. layer: 0,
  2431. src: "bullet_1",
  2432. dmg: 50,
  2433. speed: 3.6,
  2434. scale: 160,
  2435. range: 1400
  2436. }];
  2437.  
  2438. // WEAPONS:
  2439. this.weapons = [{
  2440. id: 0,
  2441. type: 0,
  2442. name: "tool hammer",
  2443. desc: "tool for gathering all resources",
  2444. src: "hammer_1",
  2445. length: 140,
  2446. width: 140,
  2447. xOff: -3,
  2448. yOff: 18,
  2449. dmg: 25,
  2450. range: 65,
  2451. gather: 1,
  2452. speed: 300
  2453. }, {
  2454. id: 1,
  2455. type: 0,
  2456. age: 2,
  2457. name: "hand axe",
  2458. desc: "gathers resources at a higher rate",
  2459. src: "axe_1",
  2460. length: 140,
  2461. width: 140,
  2462. xOff: 3,
  2463. yOff: 24,
  2464. dmg: 30,
  2465. spdMult: 1,
  2466. range: 70,
  2467. gather: 2,
  2468. speed: 400
  2469. }, {
  2470. id: 2,
  2471. type: 0,
  2472. age: 8,
  2473. pre: 1,
  2474. name: "great axe",
  2475. desc: "deal more damage and gather more resources",
  2476. src: "great_axe_1",
  2477. length: 140,
  2478. width: 140,
  2479. xOff: -8,
  2480. yOff: 25,
  2481. dmg: 35,
  2482. spdMult: 1,
  2483. range: 75,
  2484. gather: 4,
  2485. speed: 400
  2486. }, {
  2487. id: 3,
  2488. type: 0,
  2489. age: 2,
  2490. name: "short sword",
  2491. desc: "increased attack power but slower move speed",
  2492. src: "sword_1",
  2493. iPad: 1.3,
  2494. length: 130,
  2495. width: 210,
  2496. xOff: -8,
  2497. yOff: 46,
  2498. dmg: 35,
  2499. spdMult: 0.85,
  2500. range: 110,
  2501. gather: 1,
  2502. speed: 300
  2503. }, {
  2504. id: 4,
  2505. type: 0,
  2506. age: 8,
  2507. pre: 3,
  2508. name: "katana",
  2509. desc: "greater range and damage",
  2510. src: "samurai_1",
  2511. iPad: 1.3,
  2512. length: 130,
  2513. width: 210,
  2514. xOff: -8,
  2515. yOff: 59,
  2516. dmg: 40,
  2517. spdMult: 0.8,
  2518. range: 118,
  2519. gather: 1,
  2520. speed: 300
  2521. }, {
  2522. id: 5,
  2523. type: 0,
  2524. age: 2,
  2525. name: "polearm",
  2526. desc: "long range melee weapon",
  2527. src: "spear_1",
  2528. iPad: 1.3,
  2529. length: 130,
  2530. width: 210,
  2531. xOff: -8,
  2532. yOff: 53,
  2533. dmg: 45,
  2534. knock: 0.2,
  2535. spdMult: 0.82,
  2536. range: 142,
  2537. gather: 1,
  2538. speed: 700
  2539. }, {
  2540. id: 6,
  2541. type: 0,
  2542. age: 2,
  2543. name: "bat",
  2544. desc: "fast long range melee weapon",
  2545. src: "bat_1",
  2546. iPad: 1.3,
  2547. length: 110,
  2548. width: 180,
  2549. xOff: -8,
  2550. yOff: 53,
  2551. dmg: 20,
  2552. knock: 0.7,
  2553. range: 110,
  2554. gather: 1,
  2555. speed: 300
  2556. }, {
  2557. id: 7,
  2558. type: 0,
  2559. age: 2,
  2560. name: "daggers",
  2561. desc: "really fast short range weapon",
  2562. src: "dagger_1",
  2563. iPad: 0.8,
  2564. length: 110,
  2565. width: 110,
  2566. xOff: 18,
  2567. yOff: 0,
  2568. dmg: 20,
  2569. knock: 0.1,
  2570. range: 65,
  2571. gather: 1,
  2572. hitSlow: 0.1,
  2573. spdMult: 1.13,
  2574. speed: 100
  2575. }, {
  2576. id: 8,
  2577. type: 0,
  2578. age: 2,
  2579. name: "stick",
  2580. desc: "great for gathering but very weak",
  2581. src: "stick_1",
  2582. length: 140,
  2583. width: 140,
  2584. xOff: 3,
  2585. yOff: 24,
  2586. dmg: 1,
  2587. spdMult: 1,
  2588. range: 70,
  2589. gather: 7,
  2590. speed: 400
  2591. }, {
  2592. id: 9,
  2593. type: 1,
  2594. age: 6,
  2595. name: "hunting bow",
  2596. desc: "bow used for ranged combat and hunting",
  2597. src: "bow_1",
  2598. req: ["wood", 4],
  2599. length: 120,
  2600. width: 120,
  2601. xOff: -6,
  2602. yOff: 0,
  2603. Pdmg: 25,
  2604. projectile: 0,
  2605. spdMult: 0.75,
  2606. speed: 600
  2607. }, {
  2608. id: 10,
  2609. type: 1,
  2610. age: 6,
  2611. name: "great hammer",
  2612. desc: "hammer used for destroying structures",
  2613. src: "great_hammer_1",
  2614. length: 140,
  2615. width: 140,
  2616. xOff: -9,
  2617. yOff: 25,
  2618. dmg: 10,
  2619. Pdmg: 10,
  2620. spdMult: 0.88,
  2621. range: 75,
  2622. sDmg: 7.5,
  2623. gather: 1,
  2624. speed: 400
  2625. }, {
  2626. id: 11,
  2627. type: 1,
  2628. age: 6,
  2629. name: "wooden shield",
  2630. desc: "blocks projectiles and reduces melee damage",
  2631. src: "shield_1",
  2632. length: 120,
  2633. width: 120,
  2634. shield: 0.2,
  2635. xOff: 6,
  2636. yOff: 0,
  2637. Pdmg: 0,
  2638. spdMult: 0.7
  2639. }, {
  2640. id: 12,
  2641. type: 1,
  2642. age: 8,
  2643. pre: 9,
  2644. name: "crossbow",
  2645. desc: "deals more damage and has greater range",
  2646. src: "crossbow_1",
  2647. req: ["wood", 5],
  2648. aboveHand: true,
  2649. armS: 0.75,
  2650. length: 120,
  2651. width: 120,
  2652. xOff: -4,
  2653. yOff: 0,
  2654. Pdmg: 35,
  2655. projectile: 2,
  2656. spdMult: 0.7,
  2657. speed: 700
  2658. }, {
  2659. id: 13,
  2660. type: 1,
  2661. age: 9,
  2662. pre: 12,
  2663. name: "repeater crossbow",
  2664. desc: "high firerate crossbow with reduced damage",
  2665. src: "crossbow_2",
  2666. req: ["wood", 10],
  2667. aboveHand: true,
  2668. armS: 0.75,
  2669. length: 120,
  2670. width: 120,
  2671. xOff: -4,
  2672. yOff: 0,
  2673. Pdmg: 30,
  2674. projectile: 3,
  2675. spdMult: 0.7,
  2676. speed: 230
  2677. }, {
  2678. id: 14,
  2679. type: 1,
  2680. age: 6,
  2681. name: "mc grabby",
  2682. desc: "steals resources from enemies",
  2683. src: "grab_1",
  2684. length: 130,
  2685. width: 210,
  2686. xOff: -8,
  2687. yOff: 53,
  2688. dmg: 0,
  2689. Pdmg: 0,
  2690. steal: 250,
  2691. knock: 0.2,
  2692. spdMult: 1.05,
  2693. range: 125,
  2694. gather: 0,
  2695. speed: 700
  2696. }, {
  2697. id: 15,
  2698. type: 1,
  2699. age: 9,
  2700. pre: 12,
  2701. name: "musket",
  2702. desc: "slow firerate but high damage and range",
  2703. src: "musket_1",
  2704. req: ["stone", 10],
  2705. aboveHand: true,
  2706. rec: 0.35,
  2707. armS: 0.6,
  2708. hndS: 0.3,
  2709. hndD: 1.6,
  2710. length: 205,
  2711. width: 205,
  2712. xOff: 25,
  2713. yOff: 0,
  2714. Pdmg: 50,
  2715. projectile: 5,
  2716. hideProjectile: true,
  2717. spdMult: 0.6,
  2718. speed: 1500
  2719. }];
  2720.  
  2721. // ITEMS:
  2722. this.list = [{
  2723. group: this.groups[0],
  2724. name: "apple",
  2725. desc: "restores 20 health when consumed",
  2726. req: ["food", 10],
  2727. consume: function(doer) {
  2728. return doer.changeHealth(20, doer);
  2729. },
  2730. scale: 22,
  2731. holdOffset: 15,
  2732. healing: 20,
  2733. itemID: 0,
  2734. itemAID: 16,
  2735. }, {
  2736. age: 3,
  2737. group: this.groups[0],
  2738. name: "cookie",
  2739. desc: "restores 40 health when consumed",
  2740. req: ["food", 15],
  2741. consume: function(doer) {
  2742. return doer.changeHealth(40, doer);
  2743. },
  2744. scale: 27,
  2745. holdOffset: 15,
  2746. healing: 40,
  2747. itemID: 1,
  2748. itemAID: 17,
  2749. }, {
  2750. age: 7,
  2751. group: this.groups[0],
  2752. name: "cheese",
  2753. desc: "restores 30 health and another 50 over 5 seconds",
  2754. req: ["food", 25],
  2755. consume: function(doer) {
  2756. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2757. doer.dmgOverTime.dmg = -10;
  2758. doer.dmgOverTime.doer = doer;
  2759. doer.dmgOverTime.time = 5;
  2760. return true;
  2761. }
  2762. return false;
  2763. },
  2764. scale: 27,
  2765. holdOffset: 15,
  2766. healing: 30,
  2767. itemID: 2,
  2768. itemAID: 18,
  2769. }, {
  2770. group: this.groups[1],
  2771. name: "wood wall",
  2772. desc: "provides protection for your village",
  2773. req: ["wood", 10],
  2774. projDmg: true,
  2775. health: 380,
  2776. scale: 50,
  2777. holdOffset: 20,
  2778. placeOffset: -5,
  2779. itemID: 3,
  2780. itemAID: 19,
  2781. }, {
  2782. age: 3,
  2783. group: this.groups[1],
  2784. name: "stone wall",
  2785. desc: "provides improved protection for your village",
  2786. req: ["stone", 25],
  2787. health: 900,
  2788. scale: 50,
  2789. holdOffset: 20,
  2790. placeOffset: -5,
  2791. itemID: 4,
  2792. itemAID: 20,
  2793. }, {
  2794. age: 7,
  2795. group: this.groups[1],
  2796. name: "castle wall",
  2797. desc: "provides powerful protection for your village",
  2798. req: ["stone", 35],
  2799. health: 1500,
  2800. scale: 52,
  2801. holdOffset: 20,
  2802. placeOffset: -5,
  2803. itemID: 5,
  2804. itemAID: 21,
  2805. }, {
  2806. group: this.groups[2],
  2807. name: "spikes",
  2808. desc: "damages enemies when they touch them",
  2809. req: ["wood", 20, "stone", 5],
  2810. health: 400,
  2811. dmg: 20,
  2812. scale: 49,
  2813. spritePadding: -23,
  2814. holdOffset: 8,
  2815. placeOffset: -5,
  2816. itemID: 6,
  2817. itemAID: 22,
  2818. shadow: {
  2819. offsetX: 5, // Adjust the shadow's X offset as needed
  2820. offsetY: 5, // Adjust the shadow's Y offset as needed
  2821. blur: 20, // Adjust the shadow's blur as needed
  2822. color: "rgba(0, 0, 0, 0.0)" // Adjust the shadow's color and transparency as needed
  2823. }
  2824.  
  2825. }, {
  2826. age: 5,
  2827. group: this.groups[2],
  2828. name: "greater spikes",
  2829. desc: "damages enemies when they touch them",
  2830. req: ["wood", 30, "stone", 10],
  2831. health: 500,
  2832. dmg: 35,
  2833. scale: 52,
  2834. spritePadding: -23,
  2835. holdOffset: 8,
  2836. placeOffset: -5,
  2837. itemID: 7,
  2838. itemAID: 23,
  2839. }, {
  2840. age: 9,
  2841. group: this.groups[2],
  2842. name: "poison spikes",
  2843. desc: "poisons enemies when they touch them",
  2844. req: ["wood", 35, "stone", 15],
  2845. health: 600,
  2846. dmg: 30,
  2847. pDmg: 5,
  2848. scale: 52,
  2849. spritePadding: -23,
  2850. holdOffset: 8,
  2851. placeOffset: -5,
  2852. itemID: 8,
  2853. itemAID: 24,
  2854. }, {
  2855. age: 9,
  2856. group: this.groups[2],
  2857. name: "spinning spikes",
  2858. desc: "damages enemies when they touch them",
  2859. req: ["wood", 30, "stone", 20],
  2860. health: 500,
  2861. dmg: 45,
  2862. turnSpeed: 0.003,
  2863. scale: 52,
  2864. spritePadding: -23,
  2865. holdOffset: 8,
  2866. placeOffset: -5,
  2867. itemID: 9,
  2868. itemAID: 25,
  2869. }, {
  2870. group: this.groups[3],
  2871. name: "windmill",
  2872. desc: "generates gold over time",
  2873. req: ["wood", 50, "stone", 10],
  2874. health: 400,
  2875. pps: 1,
  2876. turnSpeed: 0.0016,
  2877. spritePadding: 25,
  2878. iconLineMult: 12,
  2879. scale: 45,
  2880. holdOffset: 20,
  2881. placeOffset: 5,
  2882. itemID: 10,
  2883. itemAID: 26,
  2884. }, {
  2885. age: 5,
  2886. group: this.groups[3],
  2887. name: "faster windmill",
  2888. desc: "generates more gold over time",
  2889. req: ["wood", 60, "stone", 20],
  2890. health: 500,
  2891. pps: 1.5,
  2892. turnSpeed: 0.0025,
  2893. spritePadding: 25,
  2894. iconLineMult: 12,
  2895. scale: 47,
  2896. holdOffset: 20,
  2897. placeOffset: 5,
  2898. itemID: 11,
  2899. itemAID: 27,
  2900. }, {
  2901. age: 8,
  2902. group: this.groups[3],
  2903. name: "power mill",
  2904. desc: "generates more gold over time",
  2905. req: ["wood", 100, "stone", 50],
  2906. health: 800,
  2907. pps: 2,
  2908. turnSpeed: 0.005,
  2909. spritePadding: 25,
  2910. iconLineMult: 12,
  2911. scale: 47,
  2912. holdOffset: 20,
  2913. placeOffset: 5,
  2914. itemID: 12,
  2915. itemAID: 28,
  2916. }, {
  2917. age: 5,
  2918. group: this.groups[4],
  2919. type: 2,
  2920. name: "mine",
  2921. desc: "allows you to mine stone",
  2922. req: ["wood", 20, "stone", 100],
  2923. iconLineMult: 12,
  2924. scale: 65,
  2925. holdOffset: 20,
  2926. placeOffset: 0,
  2927. itemID: 13,
  2928. itemAID: 29,
  2929. }, {
  2930. age: 5,
  2931. group: this.groups[11],
  2932. type: 0,
  2933. name: "sapling",
  2934. desc: "allows you to farm wood",
  2935. req: ["wood", 150],
  2936. iconLineMult: 12,
  2937. colDiv: 0.5,
  2938. scale: 110,
  2939. holdOffset: 50,
  2940. placeOffset: -15,
  2941. itemID: 14,
  2942. itemAID: 30,
  2943. }, {
  2944. age: 4,
  2945. group: this.groups[5],
  2946. name: "pit trap",
  2947. desc: "pit that traps enemies if they walk over it",
  2948. req: ["wood", 30, "stone", 30],
  2949. trap: true,
  2950. ignoreCollision: true,
  2951. hideFromEnemy: true,
  2952. health: 500,
  2953. colDiv: 0.2,
  2954. scale: 50,
  2955. holdOffset: 20,
  2956. placeOffset: -5,
  2957. alpha: 0.6,
  2958. itemID: 15,
  2959. itemAID: 31,
  2960. }, {
  2961. age: 4,
  2962. group: this.groups[6],
  2963. name: "boost pad",
  2964. desc: "provides boost when stepped on",
  2965. req: ["stone", 20, "wood", 5],
  2966. ignoreCollision: true,
  2967. boostSpeed: 1.5,
  2968. health: 150,
  2969. colDiv: 0.7,
  2970. scale: 45,
  2971. holdOffset: 20,
  2972. placeOffset: -5,
  2973. itemID:
  2974. 16,
  2975. itemAID: 32,
  2976. }, {
  2977. age: 7,
  2978. group: this.groups[7],
  2979. doUpdate: true,
  2980. name: "turret",
  2981. desc: "defensive structure that shoots at enemies",
  2982. req: ["wood", 200, "stone", 150],
  2983. health: 800,
  2984. projectile: 1,
  2985. shootRange: 700,
  2986. shootRate: 2200,
  2987. scale: 43,
  2988. holdOffset: 20,
  2989. placeOffset: -5,
  2990. itemID: 17,
  2991. itemAID: 33,
  2992. }, {
  2993. age: 7,
  2994. group: this.groups[8],
  2995. name: "platform",
  2996. desc: "platform to shoot over walls and cross over water",
  2997. req: ["wood", 20],
  2998. ignoreCollision: true,
  2999. zIndex: 1,
  3000. health: 300,
  3001. scale: 43,
  3002. holdOffset: 20,
  3003. placeOffset: -5,
  3004. itemID: 18,
  3005. itemAID: 34,
  3006. }, {
  3007. age: 7,
  3008. group: this.groups[9],
  3009. name: "healing pad",
  3010. desc: "standing on it will slowly heal you",
  3011. req: ["wood", 30, "food", 10],
  3012. ignoreCollision: true,
  3013. healCol: 15,
  3014. health: 400,
  3015. colDiv: 0.7,
  3016. scale: 45,
  3017. holdOffset: 20,
  3018. placeOffset: -5,
  3019. itemID: 19,
  3020. itemAID: 35,
  3021. }, {
  3022. age: 9,
  3023. group: this.groups[10],
  3024. name: "spawn pad",
  3025. desc: "you will spawn here when you die but it will dissapear",
  3026. req: ["wood", 100, "stone", 100],
  3027. health: 400,
  3028. ignoreCollision: true,
  3029. spawnPoint: true,
  3030. scale: 45,
  3031. holdOffset: 20,
  3032. placeOffset: -5,
  3033. itemID: 20,
  3034. itemAID: 36,
  3035. }, {
  3036. age: 7,
  3037. group: this.groups[12],
  3038. name: "blocker",
  3039. desc: "blocks building in radius",
  3040. req: ["wood", 30, "stone", 25],
  3041. ignoreCollision: true,
  3042. blocker: 300,
  3043. health: 400,
  3044. colDiv: 0.7,
  3045. scale: 45,
  3046. holdOffset: 20,
  3047. placeOffset: -5,
  3048. itemID: 21,
  3049. itemAID: 37,
  3050. }, {
  3051. age: 7,
  3052. group: this.groups[13],
  3053. name: "teleporter",
  3054. desc: "teleports you to a random point on the map",
  3055. req: ["wood", 60, "stone", 60],
  3056. ignoreCollision: true,
  3057. teleport: true,
  3058. health: 200,
  3059. colDiv: 0.7,
  3060. scale: 45,
  3061. holdOffset: 20,
  3062. placeOffset: -5,
  3063. itemID: 22,
  3064. itemAID: 38
  3065. }];
  3066.  
  3067. // CHECK ITEM ID:
  3068. this.checkItem = {
  3069. index: function(id, myItems) {
  3070. 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 :
  3071. 5 :
  3072. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3073. 6 :
  3074. undefined;
  3075. }
  3076. }
  3077.  
  3078. // ASSIGN IDS:
  3079. for (let i = 0; i < this.list.length; ++i) {
  3080. this.list[i].id = i;
  3081. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3082. }
  3083.  
  3084. // TROLOLOLOL:
  3085. if (typeof window !== "undefined") {
  3086. function shuffle(a) {
  3087. for (let i = a.length - 1; i > 0; i--) {
  3088. const j = Math.floor(Math.random() * (i + 1));
  3089. [a[i], a[j]] = [a[j], a[i]];
  3090. }
  3091. return a;
  3092. }
  3093. //shuffle(this.list);
  3094. }
  3095. }
  3096. }
  3097. class Objectmanager {
  3098. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3099. let mathFloor = Math.floor,
  3100. mathABS = Math.abs,
  3101. mathCOS = Math.cos,
  3102. mathSIN = Math.sin,
  3103. mathPOW = Math.pow,
  3104. mathSQRT = Math.sqrt;
  3105.  
  3106. this.ignoreAdd = false;
  3107. this.hitObj = [];
  3108.  
  3109. // DISABLE OBJ:
  3110. this.disableObj = function(obj) {
  3111. obj.active = false;
  3112. };
  3113.  
  3114. // ADD NEW:
  3115. let tmpObj;
  3116. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3117. tmpObj = findObjectBySid(sid);
  3118. if (!tmpObj) {
  3119. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3120. if (!tmpObj) {
  3121. tmpObj = new GameObject(sid);
  3122. gameObjects.push(tmpObj);
  3123. }
  3124. }
  3125. if (setSID) {
  3126. tmpObj.sid = sid;
  3127. }
  3128. tmpObj.init(x, y, dir, s, type, data, owner);
  3129. };
  3130.  
  3131. // DISABLE BY SID:
  3132. this.disableBySid = function(sid) {
  3133. let find = findObjectBySid(sid);
  3134. if (find) {
  3135. this.disableObj(find);
  3136. }
  3137. };
  3138.  
  3139. // REMOVE ALL FROM PLAYER:
  3140. this.removeAllItems = function(sid, server) {
  3141. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3142. };
  3143.  
  3144. // CHECK IF PLACABLE:
  3145. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3146. 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)));
  3147. if (cantPlace) return false;
  3148. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3149. return true;
  3150. };
  3151.  
  3152. }
  3153. }
  3154. class Projectile {
  3155. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3156.  
  3157. // INIT:
  3158. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3159. this.active = true;
  3160. this.tickActive = true;
  3161. this.indx = indx;
  3162. this.x = x;
  3163. this.y = y;
  3164. this.x2 = x;
  3165. this.y2 = y;
  3166. this.dir = dir;
  3167. this.skipMov = true;
  3168. this.speed = spd;
  3169. this.dmg = dmg;
  3170. this.scale = scl;
  3171. this.range = rng;
  3172. this.r2 = rng;
  3173. this.owner = owner;
  3174. };
  3175.  
  3176. // UPDATE:
  3177. this.update = function(delta) {
  3178. if (this.active) {
  3179. let tmpSpeed = this.speed * delta;
  3180. if (!this.skipMov) {
  3181. this.x += tmpSpeed * Math.cos(this.dir);
  3182. this.y += tmpSpeed * Math.sin(this.dir);
  3183. this.range -= tmpSpeed;
  3184. if (this.range <= 0) {
  3185. this.x += this.range * Math.cos(this.dir);
  3186. this.y += this.range * Math.sin(this.dir);
  3187. tmpSpeed = 1;
  3188. this.range = 0;
  3189. this.active = false;
  3190. }
  3191. } else {
  3192. this.skipMov = false;
  3193. }
  3194. }
  3195. };
  3196. this.tickUpdate = function(delta) {
  3197. if (this.tickActive) {
  3198. let tmpSpeed = this.speed * delta;
  3199. if (!this.skipMov) {
  3200. this.x2 += tmpSpeed * Math.cos(this.dir);
  3201. this.y2 += tmpSpeed * Math.sin(this.dir);
  3202. this.r2 -= tmpSpeed;
  3203. if (this.r2 <= 0) {
  3204. this.x2 += this.r2 * Math.cos(this.dir);
  3205. this.y2 += this.r2 * Math.sin(this.dir);
  3206. tmpSpeed = 1;
  3207. this.r2 = 0;
  3208. this.tickActive = false;
  3209. }
  3210. } else {
  3211. this.skipMov = false;
  3212. }
  3213. }
  3214. };
  3215. }
  3216. };
  3217. class Store {
  3218. constructor() {
  3219. // STORE HATS:
  3220. this.hats = [{
  3221. id: 45,
  3222. name: "Shame!",
  3223. dontSell: true,
  3224. price: 0,
  3225. scale: 120,
  3226. desc: "hacks are for winners"
  3227. }, {
  3228. id: 51,
  3229. name: "Moo Cap",
  3230. price: 0,
  3231. scale: 120,
  3232. desc: "coolest mooer around"
  3233. }, {
  3234. id: 50,
  3235. name: "Apple Cap",
  3236. price: 0,
  3237. scale: 120,
  3238. desc: "apple farms remembers"
  3239. }, {
  3240. id: 28,
  3241. name: "Moo Head",
  3242. price: 0,
  3243. scale: 120,
  3244. desc: "no effect"
  3245. }, {
  3246. id: 29,
  3247. name: "Pig Head",
  3248. price: 0,
  3249. scale: 120,
  3250. desc: "no effect"
  3251. }, {
  3252. id: 30,
  3253. name: "Fluff Head",
  3254. price: 0,
  3255. scale: 120,
  3256. desc: "no effect"
  3257. }, {
  3258. id: 36,
  3259. name: "Pandou Head",
  3260. price: 0,
  3261. scale: 120,
  3262. desc: "no effect"
  3263. }, {
  3264. id: 37,
  3265. name: "Bear Head",
  3266. price: 0,
  3267. scale: 120,
  3268. desc: "no effect"
  3269. }, {
  3270. id: 38,
  3271. name: "Monkey Head",
  3272. price: 0,
  3273. scale: 120,
  3274. desc: "no effect"
  3275. }, {
  3276. id: 44,
  3277. name: "Polar Head",
  3278. price: 0,
  3279. scale: 120,
  3280. desc: "no effect"
  3281. }, {
  3282. id: 35,
  3283. name: "Fez Hat",
  3284. price: 0,
  3285. scale: 120,
  3286. desc: "no effect"
  3287. }, {
  3288. id: 42,
  3289. name: "Enigma Hat",
  3290. price: 0,
  3291. scale: 120,
  3292. desc: "join the enigma army"
  3293. }, {
  3294. id: 43,
  3295. name: "Blitz Hat",
  3296. price: 0,
  3297. scale: 120,
  3298. desc: "hey everybody i'm blitz"
  3299. }, {
  3300. id: 49,
  3301. name: "Bob XIII Hat",
  3302. price: 0,
  3303. scale: 120,
  3304. desc: "like and subscribe"
  3305. }, {
  3306. id: 57,
  3307. name: "Pumpkin",
  3308. price: 50,
  3309. scale: 120,
  3310. desc: "Spooooky"
  3311. }, {
  3312. id: 8,
  3313. name: "Bummle Hat",
  3314. price: 100,
  3315. scale: 120,
  3316. desc: "no effect"
  3317. }, {
  3318. id: 2,
  3319. name: "Straw Hat",
  3320. price: 500,
  3321. scale: 120,
  3322. desc: "no effect"
  3323. }, {
  3324. id: 15,
  3325. name: "Winter Cap",
  3326. price: 600,
  3327. scale: 120,
  3328. desc: "allows you to move at normal speed in snow",
  3329. coldM: 1
  3330. }, {
  3331. id: 5,
  3332. name: "Cowboy Hat",
  3333. price: 1000,
  3334. scale: 120,
  3335. desc: "no effect"
  3336. }, {
  3337. id: 4,
  3338. name: "Ranger Hat",
  3339. price: 2000,
  3340. scale: 120,
  3341. desc: "no effect"
  3342. }, {
  3343. id: 18,
  3344. name: "Explorer Hat",
  3345. price: 2000,
  3346. scale: 120,
  3347. desc: "no effect"
  3348. }, {
  3349. id: 31,
  3350. name: "Flipper Hat",
  3351. price: 2500,
  3352. scale: 120,
  3353. desc: "have more control while in water",
  3354. watrImm: true
  3355. }, {
  3356. id: 1,
  3357. name: "Marksman Cap",
  3358. price: 3000,
  3359. scale: 120,
  3360. desc: "increases arrow speed and range",
  3361. aMlt: 1.3
  3362. }, {
  3363. id: 10,
  3364. name: "Bush Gear",
  3365. price: 3000,
  3366. scale: 160,
  3367. desc: "allows you to disguise yourself as a bush"
  3368. }, {
  3369. id: 48,
  3370. name: "Halo",
  3371. price: 3000,
  3372. scale: 120,
  3373. desc: "no effect"
  3374. }, {
  3375. id: 6,
  3376. name: "Soldier Helmet",
  3377. price: 4000,
  3378. scale: 120,
  3379. desc: "reduces damage taken but slows movement",
  3380. spdMult: 0.94,
  3381. dmgMult: 0.75
  3382. }, {
  3383. id: 23,
  3384. name: "Anti Venom Gear",
  3385. price: 4000,
  3386. scale: 120,
  3387. desc: "makes you immune to poison",
  3388. poisonRes: 1
  3389. }, {
  3390. id: 13,
  3391. name: "Medic Gear",
  3392. price: 5000,
  3393. scale: 110,
  3394. desc: "slowly regenerates health over time",
  3395. healthRegen: 3
  3396. }, {
  3397. id: 9,
  3398. name: "Miners Helmet",
  3399. price: 5000,
  3400. scale: 120,
  3401. desc: "earn 1 extra gold per resource",
  3402. extraGold: 1
  3403. }, {
  3404. id: 32,
  3405. name: "Musketeer Hat",
  3406. price: 5000,
  3407. scale: 120,
  3408. desc: "reduces cost of projectiles",
  3409. projCost: 0.5
  3410. }, {
  3411. id: 7,
  3412. name: "Bull Helmet",
  3413. price: 6000,
  3414. scale: 120,
  3415. desc: "increases damage done but drains health",
  3416. healthRegen: -5,
  3417. dmgMultO: 1.5,
  3418. spdMult: 0.96
  3419. }, {
  3420. id: 22,
  3421. name: "Emp Helmet",
  3422. price: 6000,
  3423. scale: 120,
  3424. desc: "turrets won't attack but you move slower",
  3425. antiTurret: 1,
  3426. spdMult: 0.7
  3427. }, {
  3428. id: 12,
  3429. name: "Booster Hat",
  3430. price: 6000,
  3431. scale: 120,
  3432. desc: "increases your movement speed",
  3433. spdMult: 1.16
  3434. }, {
  3435. id: 26,
  3436. name: "Barbarian Armor",
  3437. price: 8000,
  3438. scale: 120,
  3439. desc: "knocks back enemies that attack you",
  3440. dmgK: 0.6
  3441. }, {
  3442. id: 21,
  3443. name: "Plague Mask",
  3444. price: 10000,
  3445. scale: 120,
  3446. desc: "melee attacks deal poison damage",
  3447. poisonDmg: 5,
  3448. poisonTime: 6
  3449. }, {
  3450. id: 46,
  3451. name: "Bull Mask",
  3452. price: 10000,
  3453. scale: 120,
  3454. desc: "bulls won't target you unless you attack them",
  3455. bullRepel: 1
  3456. }, {
  3457. id: 14,
  3458. name: "Windmill Hat",
  3459. topSprite: true,
  3460. price: 10000,
  3461. scale: 120,
  3462. desc: "generates points while worn",
  3463. pps: 1.5
  3464. }, {
  3465. id: 11,
  3466. name: "Spike Gear",
  3467. topSprite: true,
  3468. price: 10000,
  3469. scale: 120,
  3470. desc: "deal damage to players that damage you",
  3471. dmg: 0.45
  3472. }, {
  3473. id: 53,
  3474. name: "Turret Gear",
  3475. topSprite: true,
  3476. price: 10000,
  3477. scale: 120,
  3478. desc: "you become a walking turret",
  3479. turret: {
  3480. proj: 1,
  3481. range: 700,
  3482. rate: 2500
  3483. },
  3484. spdMult: 0.7
  3485. }, {
  3486. id: 20,
  3487. name: "Samurai Armor",
  3488. price: 12000,
  3489. scale: 120,
  3490. desc: "increased attack speed and fire rate",
  3491. atkSpd: 0.78
  3492. }, {
  3493. id: 58,
  3494. name: "Dark Knight",
  3495. price: 12000,
  3496. scale: 120,
  3497. desc: "restores health when you deal damage",
  3498. healD: 0.4
  3499. }, {
  3500. id: 27,
  3501. name: "Scavenger Gear",
  3502. price: 15000,
  3503. scale: 120,
  3504. desc: "earn double points for each kill",
  3505. kScrM: 2
  3506. }, {
  3507. id: 40,
  3508. name: "Tank Gear",
  3509. price: 15000,
  3510. scale: 120,
  3511. desc: "increased damage to buildings but slower movement",
  3512. spdMult: 0.3,
  3513. bDmg: 3.3
  3514. }, {
  3515. id: 52,
  3516. name: "Thief Gear",
  3517. price: 15000,
  3518. scale: 120,
  3519. desc: "steal half of a players gold when you kill them",
  3520. goldSteal: 0.5
  3521. }, {
  3522. id: 55,
  3523. name: "Bloodthirster",
  3524. price: 20000,
  3525. scale: 120,
  3526. desc: "Restore Health when dealing damage. And increased damage",
  3527. healD: 0.25,
  3528. dmgMultO: 1.2,
  3529. }, {
  3530. id: 56,
  3531. name: "Assassin Gear",
  3532. price: 20000,
  3533. scale: 120,
  3534. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3535. noEat: true,
  3536. spdMult: 1.1,
  3537. invisTimer: 1000
  3538. }];
  3539.  
  3540. // STORE ACCESSORIES:
  3541. this.accessories = [{
  3542. id: 12,
  3543. name: "Snowball",
  3544. price: 1000,
  3545. scale: 105,
  3546. xOff: 18,
  3547. desc: "no effect"
  3548. }, {
  3549. id: 9,
  3550. name: "Tree Cape",
  3551. price: 1000,
  3552. scale: 90,
  3553. desc: "no effect"
  3554. }, {
  3555. id: 10,
  3556. name: "Stone Cape",
  3557. price: 1000,
  3558. scale: 90,
  3559. desc: "no effect"
  3560. }, {
  3561. id: 3,
  3562. name: "Cookie Cape",
  3563. price: 1500,
  3564. scale: 90,
  3565. desc: "no effect"
  3566. }, {
  3567. id: 8,
  3568. name: "Cow Cape",
  3569. price: 2000,
  3570. scale: 90,
  3571. desc: "no effect"
  3572. }, {
  3573. id: 11,
  3574. name: "Monkey Tail",
  3575. price: 2000,
  3576. scale: 97,
  3577. xOff: 25,
  3578. desc: "Super speed but reduced damage",
  3579. spdMult: 1.35,
  3580. dmgMultO: 0.2
  3581. }, {
  3582. id: 17,
  3583. name: "Apple Basket",
  3584. price: 3000,
  3585. scale: 80,
  3586. xOff: 12,
  3587. desc: "slowly regenerates health over time",
  3588. healthRegen: 1
  3589. }, {
  3590. id: 6,
  3591. name: "Winter Cape",
  3592. price: 3000,
  3593. scale: 90,
  3594. desc: "no effect"
  3595. }, {
  3596. id: 4,
  3597. name: "Skull Cape",
  3598. price: 4000,
  3599. scale: 90,
  3600. desc: "no effect"
  3601. }, {
  3602. id: 5,
  3603. name: "Dash Cape",
  3604. price: 5000,
  3605. scale: 90,
  3606. desc: "no effect"
  3607. }, {
  3608. id: 2,
  3609. name: "Dragon Cape",
  3610. price: 6000,
  3611. scale: 90,
  3612. desc: "no effect"
  3613. }, {
  3614. id: 1,
  3615. name: "Super Cape",
  3616. price: 8000,
  3617. scale: 90,
  3618. desc: "no effect"
  3619. }, {
  3620. id: 7,
  3621. name: "Troll Cape",
  3622. price: 8000,
  3623. scale: 90,
  3624. desc: "no effect"
  3625. }, {
  3626. id: 14,
  3627. name: "Thorns",
  3628. price: 10000,
  3629. scale: 115,
  3630. xOff: 20,
  3631. desc: "no effect"
  3632. }, {
  3633. id: 15,
  3634. name: "Blockades",
  3635. price: 10000,
  3636. scale: 95,
  3637. xOff: 15,
  3638. desc: "no effect"
  3639. }, {
  3640. id: 20,
  3641. name: "Devils Tail",
  3642. price: 10000,
  3643. scale: 95,
  3644. xOff: 20,
  3645. desc: "no effect"
  3646. }, {
  3647. id: 16,
  3648. name: "Sawblade",
  3649. price: 12000,
  3650. scale: 90,
  3651. spin: true,
  3652. xOff: 0,
  3653. desc: "deal damage to players that damage you",
  3654. dmg: 0.15
  3655. }, {
  3656. id: 13,
  3657. name: "Angel Wings",
  3658. price: 15000,
  3659. scale: 138,
  3660. xOff: 22,
  3661. desc: "slowly regenerates health over time",
  3662. healthRegen: 3
  3663. }, {
  3664. id: 19,
  3665. name: "Shadow Wings",
  3666. price: 15000,
  3667. scale: 138,
  3668. xOff: 22,
  3669. desc: "increased movement speed",
  3670. spdMult: 1.1
  3671. }, {
  3672. id: 18,
  3673. name: "Blood Wings",
  3674. price: 20000,
  3675. scale: 178,
  3676. xOff: 26,
  3677. desc: "restores health when you deal damage",
  3678. healD: 0.2
  3679. }, {
  3680. id: 21,
  3681. name: "Corrupt X Wings",
  3682. price: 20000,
  3683. scale: 178,
  3684. xOff: 26,
  3685. desc: "deal damage to players that damage you",
  3686. dmg: 0.25
  3687. }];
  3688. }
  3689. };
  3690. class ProjectileManager {
  3691. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3692. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3693. let tmpData = items.projectiles[indx];
  3694. let tmpProj;
  3695. for (let i = 0; i < projectiles.length; ++i) {
  3696. if (!projectiles[i].active) {
  3697. tmpProj = projectiles[i];
  3698. break;
  3699. }
  3700. }
  3701. if (!tmpProj) {
  3702. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3703. tmpProj.sid = projectiles.length;
  3704. projectiles.push(tmpProj);
  3705. }
  3706. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3707. tmpProj.ignoreObj = ignoreObj;
  3708. tmpProj.layer = layer || tmpData.layer;
  3709. tmpProj.inWindow = inWindow;
  3710. tmpProj.src = tmpData.src;
  3711. return tmpProj;
  3712. };
  3713. }
  3714. };
  3715. class AiManager {
  3716.  
  3717. // AI MANAGER:
  3718. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3719.  
  3720. // AI TYPES:
  3721. this.aiTypes = [{
  3722. id: 0,
  3723. src: "cow_1",
  3724. killScore: 150,
  3725. health: 500,
  3726. weightM: 0.8,
  3727. speed: 0.00095,
  3728. turnSpeed: 0.001,
  3729. scale: 72,
  3730. drop: ["food", 50]
  3731. }, {
  3732. id: 1,
  3733. src: "pig_1",
  3734. killScore: 200,
  3735. health: 800,
  3736. weightM: 0.6,
  3737. speed: 0.00085,
  3738. turnSpeed: 0.001,
  3739. scale: 72,
  3740. drop: ["food", 80]
  3741. }, {
  3742. id: 2,
  3743. name: "Bull",
  3744. src: "bull_2",
  3745. hostile: true,
  3746. dmg: 20,
  3747. killScore: 1000,
  3748. health: 1800,
  3749. weightM: 0.5,
  3750. speed: 0.00094,
  3751. turnSpeed: 0.00074,
  3752. scale: 78,
  3753. viewRange: 800,
  3754. chargePlayer: true,
  3755. drop: ["food", 100]
  3756. }, {
  3757. id: 3,
  3758. name: "Bully",
  3759. src: "bull_1",
  3760. hostile: true,
  3761. dmg: 20,
  3762. killScore: 2000,
  3763. health: 2800,
  3764. weightM: 0.45,
  3765. speed: 0.001,
  3766. turnSpeed: 0.0008,
  3767. scale: 90,
  3768. viewRange: 900,
  3769. chargePlayer: true,
  3770. drop: ["food", 400]
  3771. }, {
  3772. id: 4,
  3773. name: "Wolf",
  3774. src: "wolf_1",
  3775. hostile: true,
  3776. dmg: 8,
  3777. killScore: 500,
  3778. health: 300,
  3779. weightM: 0.45,
  3780. speed: 0.001,
  3781. turnSpeed: 0.002,
  3782. scale: 84,
  3783. viewRange: 800,
  3784. chargePlayer: true,
  3785. drop: ["food", 200]
  3786. }, {
  3787. id: 5,
  3788. name: "Quack",
  3789. src: "chicken_1",
  3790. dmg: 8,
  3791. killScore: 2000,
  3792. noTrap: true,
  3793. health: 300,
  3794. weightM: 0.2,
  3795. speed: 0.0018,
  3796. turnSpeed: 0.006,
  3797. scale: 70,
  3798. drop: ["food", 100]
  3799. }, {
  3800. id: 6,
  3801. name: "MOOSTAFA",
  3802. nameScale: 50,
  3803. src: "enemy",
  3804. hostile: true,
  3805. dontRun: true,
  3806. fixedSpawn: true,
  3807. spawnDelay: 60000,
  3808. noTrap: true,
  3809. colDmg: 100,
  3810. dmg: 40,
  3811. killScore: 8000,
  3812. health: 18000,
  3813. weightM: 0.4,
  3814. speed: 0.0007,
  3815. turnSpeed: 0.01,
  3816. scale: 80,
  3817. spriteMlt: 1.8,
  3818. leapForce: 0.9,
  3819. viewRange: 1000,
  3820. hitRange: 210,
  3821. hitDelay: 1000,
  3822. chargePlayer: true,
  3823. drop: ["food", 100]
  3824. }, {
  3825. id: 7,
  3826. name: "Treasure",
  3827. hostile: true,
  3828. nameScale: 35,
  3829. src: "crate_1",
  3830. fixedSpawn: true,
  3831. spawnDelay: 120000,
  3832. colDmg: 200,
  3833. killScore: 5000,
  3834. health: 20000,
  3835. weightM: 0.1,
  3836. speed: 0.0,
  3837. turnSpeed: 0.0,
  3838. scale: 70,
  3839. spriteMlt: 1.0
  3840. }, {
  3841. id: 8,
  3842. name: "MOOFIE",
  3843. src: "wolf_2",
  3844. hostile: true,
  3845. fixedSpawn: true,
  3846. dontRun: true,
  3847. hitScare: 4,
  3848. spawnDelay: 30000,
  3849. noTrap: true,
  3850. nameScale: 35,
  3851. dmg: 10,
  3852. colDmg: 100,
  3853. killScore: 3000,
  3854. health: 7000,
  3855. weightM: 0.45,
  3856. speed: 0.0015,
  3857. turnSpeed: 0.002,
  3858. scale: 90,
  3859. viewRange: 800,
  3860. chargePlayer: true,
  3861. drop: ["food", 1000]
  3862. }];
  3863.  
  3864. // SPAWN AI:
  3865. this.spawn = function(x, y, dir, index) {
  3866. let tmpObj = ais.find((tmp) => !tmp.active);
  3867. if (!tmpObj) {
  3868. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3869. ais.push(tmpObj);
  3870. }
  3871. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3872. return tmpObj;
  3873. };
  3874. }
  3875.  
  3876. };
  3877. class AI {
  3878. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3879. this.sid = sid;
  3880. this.isAI = true;
  3881. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3882.  
  3883. // INIT:
  3884. this.init = function(x, y, dir, index, data) {
  3885. this.x = x;
  3886. this.y = y;
  3887. this.startX = data.fixedSpawn ? x : null;
  3888. this.startY = data.fixedSpawn ? y : null;
  3889. this.xVel = 0;
  3890. this.yVel = 0;
  3891. this.zIndex = 0;
  3892. this.dir = dir;
  3893. this.dirPlus = 0;
  3894. this.showName = 'aaa';
  3895. this.index = index;
  3896. this.src = data.src;
  3897. if (data.name) this.name = data.name;
  3898. this.weightM = data.weightM;
  3899. this.speed = data.speed;
  3900. this.killScore = data.killScore;
  3901. this.turnSpeed = data.turnSpeed;
  3902. this.scale = data.scale;
  3903. this.maxHealth = data.health;
  3904. this.leapForce = data.leapForce;
  3905. this.health = this.maxHealth;
  3906. this.chargePlayer = data.chargePlayer;
  3907. this.viewRange = data.viewRange;
  3908. this.drop = data.drop;
  3909. this.dmg = data.dmg;
  3910. this.hostile = data.hostile;
  3911. this.dontRun = data.dontRun;
  3912. this.hitRange = data.hitRange;
  3913. this.hitDelay = data.hitDelay;
  3914. this.hitScare = data.hitScare;
  3915. this.spriteMlt = data.spriteMlt;
  3916. this.nameScale = data.nameScale;
  3917. this.colDmg = data.colDmg;
  3918. this.noTrap = data.noTrap;
  3919. this.spawnDelay = data.spawnDelay;
  3920. this.hitWait = 0;
  3921. this.waitCount = 1000;
  3922. this.moveCount = 0;
  3923. this.targetDir = 0;
  3924. this.active = true;
  3925. this.alive = true;
  3926. this.runFrom = null;
  3927. this.chargeTarget = null;
  3928. this.dmgOverTime = {};
  3929. };
  3930.  
  3931. let tmpRatio = 0;
  3932. let animIndex = 0;
  3933. this.animate = function(delta) {
  3934. if (this.animTime > 0) {
  3935. this.animTime -= delta;
  3936. if (this.animTime <= 0) {
  3937. this.animTime = 0;
  3938. this.dirPlus = 0;
  3939. tmpRatio = 0;
  3940. animIndex = 0;
  3941. } else {
  3942. if (animIndex == 0) {
  3943. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3944. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3945. if (tmpRatio >= 1) {
  3946. tmpRatio = 1;
  3947. animIndex = 1;
  3948. }
  3949. } else {
  3950. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3951. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3952. }
  3953. }
  3954. }
  3955. };
  3956.  
  3957. // ANIMATION:
  3958. this.startAnim = function() {
  3959. this.animTime = this.animSpeed = 600;
  3960. this.targetAngle = Math.PI * 0.8;
  3961. tmpRatio = 0;
  3962. animIndex = 0;
  3963. };
  3964.  
  3965. };
  3966.  
  3967. };
  3968. class addCh {
  3969. constructor(x, y, chat, tmpObj) {
  3970. this.x = x;
  3971. this.y = y;
  3972. this.alpha = 0;
  3973. this.active = true;
  3974. this.alive = false;
  3975. this.chat = chat;
  3976. this.owner = tmpObj;
  3977. };
  3978. };
  3979. class DeadPlayer {
  3980. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3981. this.x = x;
  3982. this.y = y;
  3983. this.lastDir = dir;
  3984. this.dir = dir + Math.PI;
  3985. this.buildIndex = buildIndex;
  3986. this.weaponIndex = weaponIndex;
  3987. this.weaponVariant = weaponVariant;
  3988. this.skinColor = skinColor;
  3989. this.scale = scale;
  3990. this.visScale = 0;
  3991. this.name = name;
  3992. this.alpha = 1;
  3993. this.active = true;
  3994. this.animate = function(delta) {
  3995. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3996. if (d2 > 0.01) {
  3997. this.dir += d2 / 20;
  3998. } else {
  3999. this.dir = this.lastDir;
  4000. }
  4001. if (this.visScale < this.scale) {
  4002. this.visScale += delta / (this.scale / 2);
  4003. if (this.visScale >= this.scale) {
  4004. this.visScale = this.scale;
  4005. }
  4006. }
  4007. this.alpha -= delta / 30000;
  4008. if (this.alpha <= 0) {
  4009. this.alpha = 0;
  4010. this.active = false;
  4011. }
  4012. }
  4013. }
  4014. };
  4015. class Player {
  4016. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4017. this.id = id;
  4018. this.sid = sid;
  4019. this.tmpScore = 0;
  4020. this.team = null;
  4021. this.latestSkin = 0;
  4022. this.oldSkinIndex = 0;
  4023. this.skinIndex = 0;
  4024. this.latestTail = 0;
  4025. this.oldTailIndex = 0;
  4026. this.tailIndex = 0;
  4027. this.hitTime = 0;
  4028. this.lastHit = 0;
  4029. this.showName = 'NOOO';
  4030. this.tails = {};
  4031. for (let i = 0; i < accessories.length; ++i) {
  4032. if (accessories[i].price <= 0)
  4033. this.tails[accessories[i].id] = 1;
  4034. }
  4035. this.skins = {};
  4036. for (let i = 0; i < hats.length; ++i) {
  4037. if (hats[i].price <= 0)
  4038. this.skins[hats[i].id] = 1;
  4039. }
  4040. this.points = 0;
  4041. this.dt = 0;
  4042. this.hidden = false;
  4043. this.itemCounts = {};
  4044. this.isPlayer = true;
  4045. this.pps = 0;
  4046. this.moveDir = undefined;
  4047. this.skinRot = 0;
  4048. this.lastPing = 0;
  4049. this.iconIndex = 0;
  4050. this.skinColor = 0;
  4051. this.dist2 = 0;
  4052. this.aim2 = 0;
  4053. this.maxSpeed = 1;
  4054. this.chat = {
  4055. message: null,
  4056. count: 0
  4057. };
  4058. this.backupNobull = true;
  4059. this.circle = false;
  4060. this.circleRad = 200;
  4061. this.circleRadSpd = 0.1;
  4062. this.cAngle = 0;
  4063. // SPAWN:
  4064. this.spawn = function(moofoll) {
  4065. this.attacked = false;
  4066. this.timeDamaged = 0;
  4067. this.timeHealed = 0;
  4068. this.pinge = 0;
  4069. this.millPlace = 'NOOO';
  4070. this.lastshamecount = 0;
  4071. this.death = false;
  4072. this.spinDir = 0;
  4073. this.sync = false;
  4074. this.antiBull = 0;
  4075. this.bullTimer = 0;
  4076. this.poisonTimer = 0;
  4077. this.active = true;
  4078. this.alive = true;
  4079. this.lockMove = false;
  4080. this.lockDir = false;
  4081. this.minimapCounter = 0;
  4082. this.chatCountdown = 0;
  4083. this.shameCount = 0;
  4084. this.shameTimer = 0;
  4085. this.sentTo = {};
  4086. this.gathering = 0;
  4087. this.gatherIndex = 0;
  4088. this.shooting = {};
  4089. this.shootIndex = 9;
  4090. this.autoGather = 0;
  4091. this.animTime = 0;
  4092. this.animSpeed = 0;
  4093. this.mouseState = 0;
  4094. this.buildIndex = -1;
  4095. this.weaponIndex = 0;
  4096. this.weaponCode = 0;
  4097. this.weaponVariant = 0;
  4098. this.primaryIndex = undefined;
  4099. this.secondaryIndex = undefined;
  4100. this.dmgOverTime = {};
  4101. this.noMovTimer = 0;
  4102. this.maxXP = 300;
  4103. this.XP = 0;
  4104. this.age = 1;
  4105. this.kills = 0;
  4106. this.upgrAge = 2;
  4107. this.upgradePoints = 0;
  4108. this.x = 0;
  4109. this.y = 0;
  4110. this.oldXY = {
  4111. x: 0,
  4112. y: 0
  4113. };
  4114. this.zIndex = 0;
  4115. this.xVel = 0;
  4116. this.yVel = 0;
  4117. this.slowMult = 1;
  4118. this.dir = 0;
  4119. this.dirPlus = 0;
  4120. this.targetDir = 0;
  4121. this.targetAngle = 0;
  4122. this.maxHealth = 100;
  4123. this.health = this.maxHealth;
  4124. this.oldHealth = this.maxHealth;
  4125. this.damaged = 0;
  4126. this.scale = config.playerScale;
  4127. this.speed = config.playerSpeed;
  4128. this.resetMoveDir();
  4129. this.resetResources(moofoll);
  4130. this.items = [0, 3, 6, 10];
  4131. this.weapons = [0];
  4132. this.shootCount = 0;
  4133. this.weaponXP = [];
  4134. this.reloads = {
  4135. 0: 0,
  4136. 1: 0,
  4137. 2: 0,
  4138. 3: 0,
  4139. 4: 0,
  4140. 5: 0,
  4141. 6: 0,
  4142. 7: 0,
  4143. 8: 0,
  4144. 9: 0,
  4145. 10: 0,
  4146. 11: 0,
  4147. 12: 0,
  4148. 13: 0,
  4149. 14: 0,
  4150. 15: 0,
  4151. 53: 0,
  4152. };
  4153. this.bowThreat = {
  4154. 9: 0,
  4155. 12: 0,
  4156. 13: 0,
  4157. 15: 0,
  4158. };
  4159. this.damageThreat = 0;
  4160. this.inTrap = false;
  4161. this.canEmpAnti = false;
  4162. this.empAnti = false;
  4163. this.soldierAnti = false;
  4164. this.poisonTick = 0;
  4165. this.bullTick = 0;
  4166. this.setPoisonTick = false;
  4167. this.setBullTick = false;
  4168. this.antiTimer = 2;
  4169. };
  4170.  
  4171. // RESET MOVE DIR:
  4172. this.resetMoveDir = function() {
  4173. this.moveDir = undefined;
  4174. };
  4175.  
  4176. // RESET RESOURCES:
  4177. this.resetResources = function(moofoll) {
  4178. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4179. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4180. }
  4181. };
  4182.  
  4183. // ADD ITEM:
  4184. this.getItemType = function(id) {
  4185. let findindx = this.items.findIndex((ids) => ids == id);
  4186. if (findindx != -1) {
  4187. return findindx;
  4188. } else {
  4189. return items.checkItem.index(id, this.items);
  4190. }
  4191. };
  4192.  
  4193. // SET DATA:
  4194. this.setData = function(data) {
  4195. this.id = data[0];
  4196. this.sid = data[1];
  4197. this.name = data[2];
  4198. this.x = data[3];
  4199. this.y = data[4];
  4200. this.dir = data[5];
  4201. this.health = data[6];
  4202. this.maxHealth = data[7];
  4203. this.scale = data[8];
  4204. this.skinColor = data[9];
  4205. };
  4206.  
  4207. // UPDATE POISON TICK:
  4208. this.updateTimer = function() {
  4209.  
  4210. this.bullTimer -= 1;
  4211. if (this.bullTimer <= 0) {
  4212. this.setBullTick = false;
  4213. this.bullTick = game.tick - 1;
  4214. this.bullTimer = config.serverUpdateRate;
  4215. }
  4216. this.poisonTimer -= 1;
  4217. if (this.poisonTimer <= 0) {
  4218. this.setPoisonTick = false;
  4219. this.poisonTick = game.tick - 1;
  4220. this.poisonTimer = config.serverUpdateRate;
  4221. }
  4222.  
  4223. };
  4224. this.update = function(delta) {
  4225. if (this.sid == playerSID) {
  4226. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4227. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4228. this.cAngle += this.circleRadSpd;
  4229. }
  4230. if (this.active) {
  4231.  
  4232. // MOVE:
  4233. let gear = {
  4234. skin: findID(hats, this.skinIndex),
  4235. tail: findID(accessories, this.tailIndex)
  4236. }
  4237. 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;
  4238. this.maxSpeed = spdMult;
  4239.  
  4240. }
  4241. };
  4242.  
  4243. let tmpRatio = 0;
  4244. let animIndex = 0;
  4245. this.animate = function(delta) {
  4246. if (this.animTime > 0) {
  4247. this.animTime -= delta;
  4248. if (this.animTime <= 0) {
  4249. this.animTime = 0;
  4250. this.dirPlus = 0;
  4251. tmpRatio = 0;
  4252. animIndex = 0;
  4253. } else {
  4254. if (animIndex == 0) {
  4255. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4256. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4257. if (tmpRatio >= 1) {
  4258. tmpRatio = 1;
  4259. animIndex = 1;
  4260. }
  4261. } else {
  4262. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4263. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4264. }
  4265. }
  4266. }
  4267. };
  4268.  
  4269. // GATHER ANIMATION:
  4270. this.startAnim = function(didHit, index) {
  4271. this.animTime = this.animSpeed = items.weapons[index].speed;
  4272. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4273. tmpRatio = 0;
  4274. animIndex = 0;
  4275. };
  4276.  
  4277. // CAN SEE:
  4278. this.canSee = function(other) {
  4279. if (!other) return false;
  4280. let dx = Math.abs(other.x - this.x) - other.scale;
  4281. let dy = Math.abs(other.y - this.y) - other.scale;
  4282. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4283. };
  4284.  
  4285. // SHAME SYSTEM:
  4286. this.judgeShame = function() {
  4287. this.lastshamecount = this.shameCount;
  4288. if (this.oldHealth < this.health) {
  4289. if (this.hitTime) {
  4290. let timeSinceHit = game.tick - this.hitTime;
  4291. this.lastHit = game.tick;
  4292. this.hitTime = 0;
  4293. if (timeSinceHit < 2) {
  4294. this.shameCount++;
  4295. } else {
  4296. this.shameCount = Math.max(0, this.shameCount - 2);
  4297. }
  4298. }
  4299. } else if (this.oldHealth > this.health) {
  4300. this.hitTime = game.tick;
  4301. }
  4302. };
  4303. this.addShameTimer = function() {
  4304. this.shameCount = 0;
  4305. this.shameTimer = 30;
  4306. let interval = setInterval(() => {
  4307. this.shameTimer--;
  4308. if (this.shameTimer <= 0) {
  4309. clearInterval(interval);
  4310. }
  4311. }, 1000);
  4312. };
  4313.  
  4314. // CHECK TEAM:
  4315. this.isTeam = function(tmpObj) {
  4316. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4317. };
  4318.  
  4319. // FOR THE PLAYER:
  4320. this.findAllianceBySid = function(sid) {
  4321. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4322. };
  4323. this.checkCanInsta = function(nobull) {
  4324. let totally = 0;
  4325. if (this.alive && inGame) {
  4326. let primary = {
  4327. weapon: this.weapons[0],
  4328. variant: this.primaryVariant,
  4329. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4330. };
  4331. let secondary = {
  4332. weapon: this.weapons[1],
  4333. variant: this.secondaryVariant,
  4334. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4335. };
  4336. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4337. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4338. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4339. totally += primary.dmg * pV * bull;
  4340. }
  4341. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4342. totally += secondary.dmg;
  4343. }
  4344. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4345. totally += 25;
  4346. }
  4347. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4348. return totally;
  4349. }
  4350. return 0;
  4351. };
  4352.  
  4353. // UPDATE WEAPON RELOAD:
  4354. this.manageReload = function() {
  4355. if (this.shooting[53]) {
  4356. this.shooting[53] = 0;
  4357. this.reloads[53] = (2500 - game.tickRate);
  4358. } else {
  4359. if (this.reloads[53] > 0) {
  4360. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4361. }
  4362. }
  4363.  
  4364. //preplacer
  4365. if (this.reloads[this.weaponIndex] <= 1000/9) { //auto preplace
  4366. // place(2, getAttackDir());
  4367. let index = this.weaponIndex;
  4368. 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));
  4369. for(let i = 0; i < nearObja.length; i++) {
  4370. let aaa = nearObja[i];
  4371.  
  4372. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4373. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4374. if(aaa.health - (valaa) <= 0 && near.length) {
  4375. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI);
  4376. }
  4377. }
  4378. }
  4379.  
  4380. if (this.gathering || this.shooting[1]) {
  4381. if (this.gathering) {
  4382. this.gathering = 0;
  4383. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4384. this.attacked = true;
  4385. }
  4386. if (this.shooting[1]) {
  4387. this.shooting[1] = 0;
  4388. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4389. this.attacked = true;
  4390. }
  4391. } else {
  4392. this.attacked = false;
  4393. if (this.buildIndex < 0) {
  4394. if (this.reloads[this.weaponIndex] > 0) {
  4395. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4396. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4397. if (this == player) {
  4398. if (getEl("weaponGrind").checked) {
  4399. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4400. checkPlace(player.getItemType(22), i);
  4401. }
  4402. }
  4403. }
  4404. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4405. this.antiBull++;
  4406. game.tickBase(() => {
  4407. this.antiBull = 0;
  4408. }, 1);
  4409. }
  4410. }
  4411. }
  4412. }
  4413. };
  4414.  
  4415. // FOR ANTI INSTA:
  4416. this.addDamageThreat = function(tmpObj) {
  4417. let primary = {
  4418. weapon: this.primaryIndex,
  4419. variant: this.primaryVariant
  4420. };
  4421. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4422. let secondary = {
  4423. weapon: this.secondaryIndex,
  4424. variant: this.secondaryVariant
  4425. };
  4426. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4427. let bull = 1.5;
  4428. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4429. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4430. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4431. this.damageThreat += primary.dmg * pV * bull;
  4432. }
  4433. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4434. this.damageThreat += secondary.dmg * sV;
  4435. }
  4436. if (this.reloads[53] <= game.tickRate) {
  4437. this.damageThreat += 25;
  4438. }
  4439. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4440. if (!this.isTeam(tmpObj)) {
  4441. if (this.dist2 <= 300) {
  4442. tmpObj.damageThreat += this.damageThreat;
  4443. }
  4444. }
  4445. };
  4446.  
  4447. }
  4448. };
  4449.  
  4450. // SOME CODES:
  4451. function sendUpgrade(index) {
  4452. player.reloads[index] = 0;
  4453. packet("H", index);
  4454. }
  4455.  
  4456. function storeEquip(id, index) {
  4457. packet("c", 0, id, index);
  4458. }
  4459.  
  4460. function storeBuy(id, index) {
  4461. packet("c", 1, id, index);
  4462. }
  4463.  
  4464. function buyEquip(id, index) {
  4465. let nID = player.skins[6] ? 6 : 0;
  4466. if (player.alive && inGame) {
  4467. if (index == 0) {
  4468. if (player.skins[id]) {
  4469. if (player.latestSkin != id) {
  4470. packet("c", 0, id, 0);
  4471. }
  4472. } else {
  4473. if (configs.autoBuyEquip) {
  4474. let find = findID(hats, id);
  4475. if (find) {
  4476. if (player.points >= find.price) {
  4477. packet("c", 1, id, 0);
  4478. packet("c", 0, id, 0);
  4479. } else {
  4480. if (player.latestSkin != nID) {
  4481. packet("c", 0, nID, 0);
  4482. }
  4483. }
  4484. } else {
  4485. if (player.latestSkin != nID) {
  4486. packet("c", 0, nID, 0);
  4487. }
  4488. }
  4489. } else {
  4490. if (player.latestSkin != nID) {
  4491. packet("c", 0, nID, 0);
  4492. }
  4493. }
  4494. }
  4495. } else if (index == 1) {
  4496. if (useWasd && (id != 11 && id != 0)) {
  4497. if (player.latestTail != 0) {
  4498. packet("c", 0, 0, 1);
  4499. }
  4500. return;
  4501. }
  4502. if (player.tails[id]) {
  4503. if (player.latestTail != id) {
  4504. packet("c", 0, id, 1);
  4505. }
  4506. } else {
  4507. if (configs.autoBuyEquip) {
  4508. let find = findID(accessories, id);
  4509. if (find) {
  4510. if (player.points >= find.price) {
  4511. packet("c", 1, id, 1);
  4512. packet("c", 0, id, 1);
  4513. } else {
  4514. if (player.latestTail != 0) {
  4515. packet("c", 0, 0, 1);
  4516. }
  4517. }
  4518. } else {
  4519. if (player.latestTail != 0) {
  4520. packet("c", 0, 0, 1);
  4521. }
  4522. }
  4523. } else {
  4524. if (player.latestTail != 0) {
  4525. packet("c", 0, 0, 1);
  4526. }
  4527. }
  4528. }
  4529. }
  4530. }
  4531. }
  4532.  
  4533. function selectToBuild(index, wpn) {
  4534. packet("G", index, wpn);
  4535. }
  4536.  
  4537. function selectWeapon(index, isPlace) {
  4538. if (!isPlace) {
  4539. player.weaponCode = index;
  4540. }
  4541. packet("G", index, 1);
  4542. }
  4543.  
  4544. function sendAutoGather() {
  4545. packet("K", 1, 1);
  4546. }
  4547.  
  4548. function sendAtck(id, angle) {
  4549. packet("d", id, angle, 1);
  4550. }
  4551.  
  4552. // PLACER:
  4553. function place(id, rad, rmd) {
  4554. try {
  4555. if (id == undefined) return;
  4556. let item = items.list[player.items[id]];
  4557. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4558. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4559. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4560. 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))) {
  4561. selectToBuild(player.items[id]);
  4562. sendAtck(1, rad);
  4563. selectWeapon(player.weaponCode, 1);
  4564. if (rmd && getEl("placeVis").checked) {
  4565. placeVisible.push({
  4566. x: tmpX,
  4567. y: tmpY,
  4568. name: item.name,
  4569. scale: item.scale,
  4570. dir: rad
  4571. });
  4572. game.tickBase(() => {
  4573. placeVisible.shift();
  4574. }, 1)
  4575. }
  4576. }
  4577. } catch (e) {}
  4578. }
  4579.  
  4580. function checkPlace(id, rad) {
  4581. try {
  4582. if (id == undefined) return;
  4583. let item = items.list[player.items[id]];
  4584. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4585. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4586. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4587. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4588. place(id, rad, 1);
  4589. }
  4590. } catch (e) {}
  4591. }
  4592.  
  4593. // HEALING:
  4594. function soldierMult() {
  4595. return player.latestSkin == 6 ? 0.75 : 1;
  4596. }
  4597.  
  4598. function healthBased() {
  4599. if (player.health == 100)
  4600. return 0;
  4601. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4602. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4603. }
  4604. return 0;
  4605. }
  4606.  
  4607. function getAttacker(damaged) {
  4608. let attackers = enemy.filter(tmp => {
  4609. //let damages = new Damages(items);
  4610. //let dmg = damages.weapons[tmp.weaponIndex];
  4611. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4612. let rule = {
  4613. //one: tmp.dist2 <= 300,
  4614. //two: by.includes(damaged),
  4615. three: tmp.attacked
  4616. }
  4617. return /*rule.one && rule.two && */ rule.three;
  4618. });
  4619. return attackers;
  4620. }
  4621.  
  4622. function healer() {
  4623. for (let i = 0; i < healthBased(); i++) {
  4624. place(0, getAttackDir());
  4625. }
  4626. }
  4627. function healer33() {
  4628. for (let i = 0; i < healthBased(); i++) {
  4629. place(0, getAttackDir());
  4630. }
  4631. }
  4632. function healer1() {
  4633. place(0, getAttackDir());
  4634. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4635. }
  4636.  
  4637.  
  4638. function noshameheal() {
  4639. place(0, getAttackDir());
  4640. if (player.shameCount >= 5) {
  4641. place(0, getAttackDir());
  4642. healer33();
  4643. }else{
  4644. if (player.shameCount <= 4 && player.skinIndex != 6 && player.skinIndex != 22) {
  4645. healer33();
  4646. buyEquip(6, 0);
  4647. }else{
  4648. if (player.shameCount >= 5 && player.skinIndex != 6 && player.skinIndex != 22) {
  4649. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4650. healer33();
  4651.  
  4652. /*}else{
  4653. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  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. }
  4657. }
  4658. }
  4659. }
  4660.  
  4661.  
  4662. function antiSyncHealing(timearg) {
  4663. my.antiSync = true;
  4664. let healAnti = setInterval(() => {
  4665. if (player.shameCount < 5) {
  4666. place(0, getAttackDir());
  4667. }
  4668. }, 75);
  4669. setTimeout(() => {
  4670. clearInterval(healAnti);
  4671. setTimeout(() => {
  4672. my.antiSync = false;
  4673. }, game.tickRate);
  4674. }, game.tickRate);
  4675. }
  4676.  
  4677. function biomeGear(mover, returns) {
  4678. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4679. if (returns) return 31;
  4680. buyEquip(31, 0);
  4681. } else {
  4682. if (player.y2 <= config.snowBiomeTop) {
  4683. if (returns) return enemy && near.dist2 <= 300 ? 6 : 15;
  4684. buyEquip(15, 0);
  4685. } else {
  4686. if (returns) return enemy && near.dist2 <= 300 ? 6 : 12;
  4687. buyEquip(enemy ? 6 : 12, 0);
  4688. }
  4689. }
  4690. if (returns) return 0;
  4691. }
  4692.  
  4693. class Traps {
  4694. constructor(UTILS, items) {
  4695. this.dist = 0;
  4696. this.aim = 0;
  4697. this.inTrap = false;
  4698. this.replaced = false;
  4699. this.antiTrapped = false;
  4700. this.info = {};
  4701. this.notFast = function() {
  4702. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4703. }
  4704. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4705. try {
  4706. let item = items.list[player.items[id]];
  4707. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4708. let counts = {
  4709. attempts: 0,
  4710. placed: 0
  4711. };
  4712. let tmpObjects = [];
  4713. liztobj.forEach((p) => {
  4714. tmpObjects.push({
  4715. x: p.x,
  4716. y: p.y,
  4717. active: p.active,
  4718. blocker: p.blocker,
  4719. scale: p.scale,
  4720. isItem: p.isItem,
  4721. type: p.type,
  4722. colDiv: p.colDiv,
  4723. getScale: function(sM, ig) {
  4724. sM = sM || 1;
  4725. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4726. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4727. },
  4728. });
  4729. });
  4730. for (let i = first; i < repeat; i += plus) {
  4731. counts.attempts++;
  4732. let relAim = radian + i;
  4733. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4734. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4735. 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)));
  4736. if (cantPlace) continue;
  4737. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4738. if ((!replacer && yaboi)) {
  4739. if (yaboi.inTrap) {
  4740. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI*1.3) {
  4741. place(2, relAim, 1);
  4742. } else {
  4743. player.items[4] == 15 && place(4, relAim, 1);
  4744. }
  4745. } else {
  4746. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 2.6) {
  4747. place(2, relAim, 1);
  4748. } else {
  4749. player.items[4] == 15 && place(4, relAim, 1);
  4750. }
  4751. }
  4752. } else {
  4753. place(id, relAim, 1);
  4754. }
  4755. tmpObjects.push({
  4756. x: tmpX,
  4757. y: tmpY,
  4758. active: true,
  4759. blocker: item.blocker,
  4760. scale: item.scale,
  4761. isItem: true,
  4762. type: null,
  4763. colDiv: item.colDiv,
  4764. getScale: function() {
  4765. return this.scale;
  4766. },
  4767. });
  4768. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4769. counts.placed++;
  4770. }
  4771. }
  4772. if (counts.placed > 0 && replacer && item.dmg) {
  4773. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4774. instaC.canSpikeTick = true;
  4775. }
  4776. }
  4777. } catch (err) {
  4778. }
  4779. };
  4780. this.checkSpikeTick = function() {
  4781. try {
  4782. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4783. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4784. // more range for safe. also testing near.primaryIndex || 5
  4785. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4786. let item = items.list[9];
  4787. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4788. let danger = 0;
  4789. let counts = {
  4790. attempts: 0,
  4791. block: `unblocked`
  4792. };
  4793. for (let i = -1; i <= 1; i += 1 / 10) {
  4794. counts.attempts++;
  4795. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4796. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4797. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4798. 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)));
  4799. if (cantPlace) continue;
  4800. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4801. danger++;
  4802. counts.block = `blocked`;
  4803. break;
  4804. }
  4805. if (danger) {
  4806. my.anti0Tick = 1;
  4807. // player.chat.message = "Anti SpikeTick " + near.sid;
  4808. //player.chat.count = 2000;
  4809. return true;
  4810. }
  4811. }
  4812. } catch (err) {
  4813. return null;
  4814. }
  4815. return false;
  4816. }
  4817.  
  4818. function getDist(e, t) {
  4819. try {
  4820. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4821. } catch (e) {
  4822. return Infinity;
  4823. }
  4824. }
  4825.  
  4826. this.protect = function(aim) {
  4827. if (!configs.antiTrap) return;
  4828. if (player.items[4]) {
  4829. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4830. this.antiTrapped = true;
  4831. }
  4832. };
  4833. let trappling = false;
  4834. let spikeplacer = false;
  4835.  
  4836. this.autoPlace = function () {
  4837. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4838. if (gameObjects.length) {
  4839. let near2 = {
  4840. inTrap: true,
  4841. };
  4842. 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) {
  4843. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4844. })[0];
  4845. if (nearTrap) {
  4846. near2.inTrap = true;
  4847. } else {
  4848. near2.inTrap = true;
  4849. }
  4850. if (this.testMode ? enemy.length : (near.dist2 <= 375)) {
  4851. if (near.dist2 <= 200) {
  4852. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4853. } else {
  4854. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4855. }
  4856. }
  4857. } else {
  4858. if (this.testMode ? enemy.length : (near.dist2 <= 1000)) {
  4859. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4860. }
  4861. }
  4862. }
  4863. };
  4864.  
  4865.  
  4866.  
  4867.  
  4868. /*
  4869. this.autoPlace = function() {
  4870. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4871. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4872. if (liztobj.length) {
  4873. let near2 = {
  4874. inTrap: false,
  4875. };
  4876. 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) {
  4877. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4878.  
  4879. })[0];
  4880. if (nearTrap) {
  4881. near2.inTrap = true;
  4882. } else {
  4883. near2.inTrap = false;
  4884. }
  4885. if (near.dist3 <= 276 && !spikeplacer) {
  4886. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4887. inTrap: near2.inTrap
  4888. });
  4889. } else {
  4890. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4891. }
  4892. }
  4893. }
  4894. }
  4895. };*/
  4896.  
  4897. let spikePlaced = false;
  4898. let spikSync = false;
  4899.  
  4900.  
  4901. this.replacer = function(findObj) {
  4902. if (!findObj || !configs.autoReplace) return;
  4903. if (!inGame) return;
  4904. if (this.antiTrapped) return;
  4905. game.tickBase(() => {
  4906. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4907. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4908. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4909.  
  4910. if(spikePlaced){
  4911. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4912. spikePlaced = false;
  4913. }
  4914. if (near.dist2 <= 250 && !spikSync) {
  4915. for (let i = 0; i < 24; i++) {
  4916. let angle = (Math.PI * 2) * i / 24;
  4917. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1);
  4918. spikePlaced = true;
  4919. }
  4920. }
  4921. if (objDst <= 250 && near.dist2 <= 250) {
  4922. let danger = this.checkSpikeTick();
  4923. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4924.  
  4925. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1)
  4926. for (let i = 0; i < 24; i++) { // Цикл для создания спайков в разных направлениях
  4927. let angle = (Math.PI * 2) * i / 24;
  4928. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1); // / Ставим спайк в текущем направлении
  4929. this.testCanPlace(2, (Math.PI / 2), (Math.PI / 2), (Math.PI / 2), near, objAim, 1)
  4930. spikSync = true;
  4931.  
  4932. }
  4933. } else {
  4934. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4935. }
  4936.  
  4937. this.replaced = true;
  4938. }
  4939. }, 1);
  4940. };
  4941. }
  4942. };
  4943.  
  4944. class Instakill {
  4945. constructor() {
  4946. this.wait = false;
  4947. this.can = false;
  4948. this.isTrue = false;
  4949. this.nobull = false;
  4950. this.ticking = false;
  4951. this.canSpikeTick = false;
  4952. this.startTick = false;
  4953. this.readyTick = false;
  4954. this.canCounter = false;
  4955. this.revTick = false;
  4956. this.syncHit = false;
  4957. this.changeType = function(type) {
  4958. this.wait = false;
  4959. this.isTrue = true;
  4960. my.autoAim = true;
  4961. let instaLog = [type];
  4962. let backupNobull = near.backupNobull;
  4963. near.backupNobull = false;
  4964. if (type == "rev") {
  4965. healer1();
  4966. selectWeapon(player.weapons[1]);
  4967. buyEquip(53, 0);
  4968. sendAutoGather();
  4969. setTimeout(() => {
  4970. selectWeapon(player.weapons[0]);
  4971. buyEquip(7, 0);
  4972. setTimeout(() => {
  4973. sendAutoGather();
  4974. this.isTrue = false;
  4975. my.autoAim = false;
  4976. }, 225);
  4977. }, 100);
  4978. } else if (type == "nobull") {
  4979. selectWeapon(player.weapons[0]);
  4980. healer1();
  4981. buyEquip(7, 0);
  4982. buyEquip(21, 1);
  4983. sendAutoGather();
  4984. setTimeout(() => {
  4985. selectWeapon(player.weapons[1]);
  4986. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4987. setTimeout(() => {
  4988. sendAutoGather();
  4989. this.isTrue = false;
  4990. my.autoAim = false;
  4991. }, 255);
  4992. }, 105);
  4993. } else if (type == "normal") {
  4994. selectWeapon(player.weapons[0]);
  4995. healer1();
  4996. buyEquip(7, 0);
  4997. buyEquip(21, 1);
  4998. sendAutoGather();
  4999. setTimeout(() => {
  5000. selectWeapon(player.weapons[1]);
  5001. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5002. setTimeout(() => {
  5003. sendAutoGather();
  5004. this.isTrue = false;
  5005. my.autoAim = false;
  5006. }, 255);
  5007. }, 100);
  5008. } else {
  5009. setTimeout(() => {
  5010. this.isTrue = false;
  5011. my.autoAim = false;
  5012. }, 50);
  5013. }
  5014. };
  5015. this.spikeTickType = function() {
  5016. this.isTrue = true;
  5017. my.autoAim = true;
  5018. healer1();
  5019. selectWeapon(player.weapons[0]);
  5020. buyEquip(7, 0);
  5021. sendAutoGather();
  5022. game.tickBase(() => {
  5023. selectWeapon(player.weapons[0]);
  5024. buyEquip(53, 0);
  5025. game.tickBase(() => {
  5026. sendAutoGather();
  5027. this.isTrue = false;
  5028. my.autoAim = false;
  5029. }, 1);
  5030. }, 1);
  5031. };
  5032. this.counterType = function() {
  5033. this.isTrue = true;
  5034. my.autoAim = true;
  5035. selectWeapon(player.weapons[0]);
  5036. buyEquip(7, 0);
  5037. sendAutoGather();
  5038. game.tickBase(() => {
  5039. selectWeapon(player.weapons[0]);
  5040. buyEquip(53, 0);
  5041. game.tickBase(() => {
  5042. sendAutoGather();
  5043. this.isTrue = false;
  5044. my.autoAim = false;
  5045. }, 1);
  5046. }, 1);
  5047. };
  5048. this.rangeType = function(type) {
  5049. this.isTrue = true;
  5050. my.autoAim = true;
  5051. if (type == "ageInsta") {
  5052. my.ageInsta = false;
  5053. if (player.items[5] == 18) {
  5054. place(5, near.aim2);
  5055. }
  5056. packet("a", undefined, 1);
  5057. buyEquip(22, 0);
  5058. buyEquip(21, 1);
  5059. game.tickBase(() => {
  5060. selectWeapon(player.weapons[1]);
  5061. buyEquip(53, 0);
  5062. buyEquip(21, 1);
  5063. sendAutoGather();
  5064. game.tickBase(() => {
  5065. sendUpgrade(12);
  5066. selectWeapon(player.weapons[1]);
  5067. buyEquip(53, 0);
  5068. buyEquip(21, 1);
  5069. game.tickBase(() => {
  5070. sendUpgrade(15);
  5071. selectWeapon(player.weapons[1]);
  5072. buyEquip(53, 0);
  5073. buyEquip(21, 1);
  5074. game.tickBase(() => {
  5075. sendAutoGather();
  5076. this.isTrue = false;
  5077. my.autoAim = false;
  5078. }, 1);
  5079. }, 1);
  5080. }, 1);
  5081. }, 1);
  5082. } else {
  5083. selectWeapon(player.weapons[1]);
  5084. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5085. buyEquip(53, 0);
  5086. } else {
  5087. buyEquip(20, 0);
  5088. }
  5089. buyEquip(11, 1);
  5090. sendAutoGather();
  5091. game.tickBase(() => {
  5092. sendAutoGather();
  5093. this.isTrue = false;
  5094. my.autoAim = false;
  5095. }, 1);
  5096. }
  5097. };
  5098. this.oneTickType = function() {
  5099. this.isTrue = true;
  5100. my.autoAim = true;
  5101. selectWeapon(player.weapons[1]);
  5102. buyEquip(53, 0);
  5103. buyEquip(11, 1);
  5104. packet("a", near.aim2, 1);
  5105. if (player.weapons[1] == 15) {
  5106. my.revAim = true;
  5107. sendAutoGather();
  5108. }
  5109. game.tickBase(() => {
  5110. my.revAim = false;
  5111. selectWeapon(player.weapons[0]);
  5112. buyEquip(7, 0);
  5113. buyEquip(19, 1);
  5114. packet("a", near.aim2, 1);
  5115. if (player.weapons[1] != 15) {
  5116. sendAutoGather();
  5117. }
  5118. game.tickBase(() => {
  5119. sendAutoGather();
  5120. this.isTrue = false;
  5121. my.autoAim = false;
  5122. packet("a", undefined, 1);
  5123. }, 1);
  5124. }, 1);
  5125. };
  5126. this.threeOneTickType = function() {
  5127. this.isTrue = true;
  5128. my.autoAim = true;
  5129. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5130. biomeGear();
  5131. buyEquip(11, 1);
  5132. packet("a", near.aim2, 1);
  5133. game.tickBase(() => {
  5134. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5135. buyEquip(53, 0);
  5136. buyEquip(11, 1);
  5137. packet("a", near.aim2, 1);
  5138. game.tickBase(() => {
  5139. selectWeapon(player.weapons[0]);
  5140. buyEquip(7, 0);
  5141. buyEquip(19, 1);
  5142. sendAutoGather();
  5143. packet("a", near.aim2, 1);
  5144. game.tickBase(() => {
  5145. sendAutoGather();
  5146. this.isTrue = false;
  5147. my.autoAim = false;
  5148. packet("a", undefined, 1);
  5149. }, 1);
  5150. }, 1);
  5151. }, 1);
  5152. };
  5153. this.kmTickType = function() {
  5154. this.isTrue = true;
  5155. my.autoAim = true;
  5156. my.revAim = true;
  5157. selectWeapon(player.weapons[1]);
  5158. buyEquip(53, 0);
  5159. buyEquip(11, 1);
  5160. sendAutoGather();
  5161. packet("a", near.aim2, 1);
  5162. game.tickBase(() => {
  5163. my.revAim = false;
  5164. selectWeapon(player.weapons[0]);
  5165. buyEquip(7, 0);
  5166. buyEquip(19, 1);
  5167. packet("a", near.aim2, 1);
  5168. game.tickBase(() => {
  5169. sendAutoGather();
  5170. this.isTrue = false;
  5171. my.autoAim = false;
  5172. packet("a", undefined, 1);
  5173. }, 1);
  5174. }, 1);
  5175. };
  5176. this.boostTickType = function() {
  5177. /*this.isTrue = true;
  5178. my.autoAim = true;
  5179. selectWeapon(player.weapons[0]);
  5180. buyEquip(53, 0);
  5181. buyEquip(11, 1);
  5182. packet("a", near.aim2);
  5183. game.tickBase(() => {
  5184. place(4, near.aim2);
  5185. selectWeapon(player.weapons[1]);
  5186. biomeGear();
  5187. buyEquip(11, 1);
  5188. sendAutoGather();
  5189. packet("a", near.aim2);
  5190. game.tickBase(() => {
  5191. selectWeapon(player.weapons[0]);
  5192. buyEquip(7, 0);
  5193. buyEquip(19, 1);
  5194. packet("a", near.aim2);
  5195. game.tickBase(() => {
  5196. sendAutoGather();
  5197. this.isTrue = false;
  5198. my.autoAim = false;
  5199. packet("a", undefined);
  5200. }, 1);
  5201. }, 1);
  5202. }, 1);*/
  5203. this.isTrue = true;
  5204. my.autoAim = true;
  5205. biomeGear();
  5206. buyEquip(11, 1);
  5207. packet("a", near.aim2, 1);
  5208. game.tickBase(() => {
  5209. if (player.weapons[1] == 15) {
  5210. my.revAim = true;
  5211. }
  5212. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5213. buyEquip(53, 0);
  5214. buyEquip(11, 1);
  5215. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5216. sendAutoGather();
  5217. }
  5218. packet("a", near.aim2, 1);
  5219. place(4, near.aim2);
  5220. game.tickBase(() => {
  5221. my.revAim = false;
  5222. selectWeapon(player.weapons[0]);
  5223. buyEquip(7, 0);
  5224. buyEquip(19, 1);
  5225. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5226. sendAutoGather();
  5227. }
  5228. packet("a", near.aim2, 1);
  5229. game.tickBase(() => {
  5230. sendAutoGather();
  5231. this.isTrue = false;
  5232. my.autoAim = false;
  5233. packet("a", undefined, 1);
  5234. }, 1);
  5235. }, 1);
  5236. }, 1);
  5237. };
  5238. this.gotoGoal = function(goto, OT) {
  5239. let slowDists = (weeeee) => weeeee * config.playerScale;
  5240. let goal = {
  5241. a: goto - OT,
  5242. b: goto + OT,
  5243. c: goto - slowDists(1),
  5244. d: goto + slowDists(1),
  5245. e: goto - slowDists(2),
  5246. f: goto + slowDists(2),
  5247. g: goto - slowDists(4),
  5248. h: goto + slowDists(4)
  5249. };
  5250. let bQ = function (wwww, awwww) {
  5251. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5252. buyEquip(31, 0);
  5253. } else {
  5254. buyEquip(wwww, awwww);
  5255. }
  5256. }
  5257. if (enemy.length) {
  5258. let dst = near.dist2;
  5259. this.ticking = true;
  5260. if (dst >= goal.a && dst <= goal.b) {
  5261. bQ(22, 0);
  5262. bQ(11, 1);
  5263. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5264. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5265. }
  5266. return {
  5267. dir: undefined,
  5268. action: 1
  5269. };
  5270. } else {
  5271. if (dst < goal.a) {
  5272. if (dst >= goal.g) {
  5273. if (dst >= goal.e) {
  5274. if (dst >= goal.c) {
  5275. bQ(40, 0);
  5276. bQ(21, 1);
  5277. if (configs.slowOT) {
  5278. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5279. } else {
  5280. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5281. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5282. }
  5283. }
  5284. } else {
  5285. bQ(26, 0);
  5286. bQ(21, 1);
  5287. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5288. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5289. }
  5290. }
  5291. } else {
  5292. bQ(26, 0);
  5293. bQ(12, 1);
  5294. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5295. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5296. }
  5297. }
  5298. } else {
  5299. biomeGear();
  5300. bQ(11, 1);
  5301. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5302. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5303. }
  5304. }
  5305. return {
  5306. dir: near.aim2 + Math.PI,
  5307. action: 0
  5308. };
  5309. } else if (dst > goal.b) {
  5310. if (dst <= goal.h) {
  5311. if (dst <= goal.f) {
  5312. if (dst <= goal.d) {
  5313. bQ(40, 0);
  5314. bQ(9, 1);
  5315. if (configs.slowOT) {
  5316. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5317. } else {
  5318. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5319. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5320. }
  5321. }
  5322. } else {
  5323. bQ(22, 0);
  5324. bQ(19, 1);
  5325. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5326. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5327. }
  5328. }
  5329. } else {
  5330. bQ(6, 0);
  5331. bQ(12, 1);
  5332. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5333. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5334. }
  5335. }
  5336. } else {
  5337. biomeGear();
  5338. bQ(11, 1);
  5339. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5340. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5341. }
  5342. }
  5343. return {
  5344. dir: near.aim2,
  5345. action: 0
  5346. };
  5347. }
  5348. return {
  5349. dir: undefined,
  5350. action: 0
  5351. };
  5352. }
  5353. } else {
  5354. this.ticking = false;
  5355. return {
  5356. dir: undefined,
  5357. action: 0
  5358. };
  5359. }
  5360. }
  5361. /** wait 1 tick for better quality */
  5362. this.bowMovement = function() {
  5363. let moveMent = this.gotoGoal(685, 3);
  5364. if (moveMent.action) {
  5365. if (player.reloads[53] == 0 && !this.isTrue) {
  5366. this.rangeType("ageInsta");
  5367. } else {
  5368. packet("a", moveMent.dir, 1);
  5369. }
  5370. } else {
  5371. packet("a", moveMent.dir, 1);
  5372. }
  5373. },
  5374. this.tickMovement = function() {
  5375. 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);
  5376. if (moveMent.action) {
  5377. if (![6, 22].includes(near.skinIndex) && player.reloads[53] == 0 && !this.isTrue) {
  5378. ([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) || (player.weapons[1] == 15) ? this.oneTickType(): this.threeOneTickType();
  5379. } else {
  5380. packet("a", moveMent.dir, 1);
  5381. }
  5382. } else {
  5383. packet("a", moveMent.dir, 1);
  5384. }
  5385. },
  5386. this.kmTickMovement = function() {
  5387. let moveMent = this.gotoGoal(240, 3);
  5388. if (moveMent.action) {
  5389. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5390. this.kmTickType();
  5391. } else {
  5392. packet("a", moveMent.dir, 1);
  5393. }
  5394. } else {
  5395. packet("a", moveMent.dir, 1);
  5396. }
  5397. },
  5398. this.boostTickMovement = function() {
  5399. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 390 : player.weapons[1] == 15 ? 365 : 370;
  5400. 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;
  5401. let moveMent = this.gotoGoal(dist, actionDist);
  5402. if (moveMent.action) {
  5403. if (player.reloads[53] == 0 && !this.isTrue) {
  5404. this.boostTickType();
  5405. } else {
  5406. packet("a", moveMent.dir, 1);
  5407. }
  5408. } else {
  5409. packet("a", moveMent.dir, 1);
  5410. }
  5411. }
  5412. /** wait 1 tick for better quality */
  5413. this.perfCheck = function(pl, nr) {
  5414. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5415. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5416. let pjs = {
  5417. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5418. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5419. };
  5420. 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)) {
  5421. return true;
  5422. }
  5423. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5424. 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)) {
  5425. return true;
  5426. }
  5427. });
  5428. if (finds) return false;
  5429. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5430. let tmpScale = tmp.getScale();
  5431. 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)) {
  5432. return true;
  5433. }
  5434. });
  5435. if (finds) return false;
  5436. return true;
  5437. }
  5438. }
  5439. };
  5440.  
  5441. class Autobuy {
  5442. constructor(buyHat, buyAcc) {
  5443. this.hat = function() {
  5444. buyHat.forEach((id) => {
  5445. let find = findID(hats, id);
  5446. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5447. });
  5448. };
  5449. this.acc = function() {
  5450. buyAcc.forEach((id) => {
  5451. let find = findID(accessories, id);
  5452. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5453. });
  5454. };
  5455. }
  5456. };
  5457.  
  5458. class Autoupgrade {
  5459. constructor() {
  5460. this.sb = function(upg) {
  5461. upg(3);
  5462. upg(17);
  5463. upg(31);
  5464. upg(23);
  5465. upg(9);
  5466. upg(38);
  5467. };
  5468. this.kh = function(upg) {
  5469. upg(3);
  5470. upg(17);
  5471. upg(31);
  5472. upg(23);
  5473. upg(10);
  5474. upg(38);
  5475. upg(4);
  5476. upg(25);
  5477. };
  5478. this.pb = function(upg) {
  5479. upg(5);
  5480. upg(17);
  5481. upg(32);
  5482. upg(23);
  5483. upg(9);
  5484. upg(38);
  5485. };
  5486. this.ph = function(upg) {
  5487. upg(5);
  5488. upg(17);
  5489. upg(32);
  5490. upg(23);
  5491. upg(10);
  5492. upg(38);
  5493. upg(28);
  5494. upg(25);
  5495. };
  5496. this.db = function(upg) {
  5497. upg(7);
  5498. upg(17);
  5499. upg(31);
  5500. upg(23);
  5501. upg(9);
  5502. upg(34);
  5503. };
  5504. /* old functions */
  5505. this.km = function(upg) {
  5506. upg(7);
  5507. upg(17);
  5508. upg(31);
  5509. upg(23);
  5510. upg(10);
  5511. upg(38);
  5512. upg(4);
  5513. upg(15);
  5514. };
  5515. };
  5516. };
  5517.  
  5518. class Damages {
  5519. constructor(items) {
  5520. // 0.75 1 1.125 1.5
  5521. this.calcDmg = function(dmg, val) {
  5522. return dmg * val;
  5523. };
  5524. this.getAllDamage = function(dmg) {
  5525. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5526. };
  5527. this.weapons = [];
  5528. for (let i = 0; i < items.weapons.length; i++) {
  5529. let wp = items.weapons[i];
  5530. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5531. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5532. this[name] = this.weapons[i];
  5533. }
  5534. }
  5535. }
  5536.  
  5537. /** CLASS CODES */
  5538. // jumpscare code warn
  5539. let tmpList = [];
  5540.  
  5541. // LOADING:
  5542. let UTILS = new Utils();
  5543. let items = new Items();
  5544. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5545. let store = new Store();
  5546. let hats = store.hats;
  5547. let accessories = store.accessories;
  5548. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5549. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5550. let textManager = new Textmanager();
  5551.  
  5552. let traps = new Traps(UTILS, items);
  5553. let instaC = new Instakill();
  5554. let autoBuy = new Autobuy([40, 6, 7, 22, 53, 15, 31], [11, 19, 18 , 19]);
  5555. let autoUpgrade = new Autoupgrade();
  5556.  
  5557. let lastDeath;
  5558. let minimapData;
  5559. let mapMarker = {};
  5560. let mapPings = [];
  5561. let tmpPing;
  5562.  
  5563. let antiinsta = true;
  5564. let antiinsta1 = false;
  5565.  
  5566. let breakTrackers = [];
  5567.  
  5568. function sendChat(message) {
  5569. packet("6", message.slice(0, 30));
  5570. }
  5571.  
  5572. let runAtNextTick = [];
  5573.  
  5574. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5575. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5576. let projOffset = config.playerScale * 2;
  5577. let projXY = {
  5578. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5579. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5580. };
  5581. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5582. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5583. })[0];
  5584. if (nearPlayer) {
  5585. if (indx == 1) {
  5586. nearPlayer.shooting[53] = 1;
  5587. } else {
  5588. nearPlayer.shootIndex = weaponIndx;
  5589. nearPlayer.shooting[1] = 1;
  5590. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5591. }
  5592. }
  5593. }
  5594. let projectileCount = 0;
  5595.  
  5596. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5597. if (!tmpObj.isTeam(player)) {
  5598. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5599. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5600. tmpObj.bowThreat[weaponIndex]++;
  5601. if (index == 5) {
  5602. projectileCount++;
  5603. }
  5604. setTimeout(() => {
  5605. tmpObj.bowThreat[weaponIndex]--;
  5606. if (index == 5) {
  5607. projectileCount--;
  5608. }
  5609. }, range / speed);
  5610. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5611. place(1, tmpObj.aim2);
  5612. my.anti0Tick = 4;
  5613. if (!my.antiSync) {
  5614. antiSyncHealing(4);
  5615. }
  5616. } else {
  5617. if (projectileCount >= 2) {
  5618. place(1, tmpObj.aim2);
  5619. healer();
  5620. sendChat("prediction detect");
  5621. buyEquip(22, 0);
  5622. buyEquip(19, 1);
  5623. my.anti0Tick = 4;
  5624. if (!my.antiSync) {
  5625. antiSyncHealing(4);
  5626. }
  5627. } else {
  5628. if (projectileCount === 1) { // anti reverse or anti 1 tick with reaper
  5629. buyEquip(6, 0);
  5630. buyEquip(19, 1);
  5631. }
  5632. /*} else {
  5633. if (projectileCount >= 2) { // anti sync линия обороны N1
  5634. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  5635. player.chat.message = "pSyD";
  5636. healer();
  5637. buyEquip(6, 0);
  5638. }
  5639. }*/
  5640. }
  5641. }
  5642. }
  5643. }
  5644. }
  5645.  
  5646. // SHOW ITEM INFO:
  5647. function showItemInfo(item, isWeapon, isStoreItem) {
  5648. if (player && item) {
  5649. UTILS.removeAllChildren(itemInfoHolder);
  5650. itemInfoHolder.classList.add("visible");
  5651. UTILS.generateElement({
  5652. id: "itemInfoName",
  5653. text: UTILS.capitalizeFirst(item.name),
  5654. parent: itemInfoHolder
  5655. });
  5656. UTILS.generateElement({
  5657. id: "itemInfoDesc",
  5658. text: item.desc,
  5659. parent: itemInfoHolder
  5660. });
  5661. if (isStoreItem) {
  5662.  
  5663. } else if (isWeapon) {
  5664. UTILS.generateElement({
  5665. class: "itemInfoReq",
  5666. text: !item.type ? "primary" : "secondary",
  5667. parent: itemInfoHolder
  5668. });
  5669. } else {
  5670. for (let i = 0; i < item.req.length; i += 2) {
  5671. UTILS.generateElement({
  5672. class: "itemInfoReq",
  5673. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5674. parent: itemInfoHolder
  5675. });
  5676. }
  5677. if (item.group.limit) {
  5678. UTILS.generateElement({
  5679. class: "itemInfoLmt",
  5680. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5681. parent: itemInfoHolder
  5682. });
  5683. }
  5684. }
  5685. } else {
  5686. itemInfoHolder.classList.remove("visible");
  5687. }
  5688. }
  5689.  
  5690. // RESIZE:
  5691. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5692.  
  5693. function resize() {
  5694. screenWidth = window.innerWidth;
  5695. screenHeight = window.innerHeight;
  5696. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5697. gameCanvas.width = screenWidth * pixelDensity;
  5698. gameCanvas.height = screenHeight * pixelDensity;
  5699. gameCanvas.style.width = screenWidth + "px";
  5700. gameCanvas.style.height = screenHeight + "px";
  5701. mainContext.setTransform(
  5702. scaleFillNative, 0,
  5703. 0, scaleFillNative,
  5704. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5705. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5706. );
  5707. }
  5708. resize();
  5709.  
  5710. // MOUSE INPUT:
  5711. var usingTouch;
  5712. const mals = document.getElementById('touch-controls-fullscreen');
  5713. mals.style.display = 'block';
  5714. mals.addEventListener("mousemove", gameInput, false);
  5715.  
  5716. function gameInput(e) {
  5717. mouseX = e.clientX;
  5718. mouseY = e.clientY;
  5719. }
  5720. let clicks = {
  5721. left: false,
  5722. middle: false,
  5723. right: false,
  5724. };
  5725. mals.addEventListener("mousedown", mouseDown, false);
  5726.  
  5727. function mouseDown(e) {
  5728. if (attackState != 1) {
  5729. attackState = 1;
  5730. if (e.button == 0) {
  5731. clicks.left = true;
  5732. } else if (e.button == 1) {
  5733. clicks.middle = true;
  5734. } else if (e.button == 2) {
  5735. clicks.right = true;
  5736. }
  5737. }
  5738. }
  5739. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5740.  
  5741. function mouseUp(e) {
  5742. if (attackState != 0) {
  5743. attackState = 0;
  5744. if (e.button == 0) {
  5745. clicks.left = false;
  5746. } else if (e.button == 1) {
  5747. clicks.middle = false;
  5748. } else if (e.button == 2) {
  5749. clicks.right = false;
  5750. }
  5751. }
  5752. }
  5753. mals.addEventListener("wheel", wheel, false);
  5754.  
  5755. function wheel(e) {
  5756. if(player.shameCount > 1) {
  5757. buyEquip(7, 0);
  5758. } else {
  5759. buyEquip(6, 0);
  5760. }
  5761. }
  5762.  
  5763.  
  5764. // INPUT UTILS:
  5765. function getMoveDir() {
  5766. let dx = 0;
  5767. let dy = 0;
  5768. for (let key in moveKeys) {
  5769. let tmpDir = moveKeys[key];
  5770. dx += !!keys[key] * tmpDir[0];
  5771. dy += !!keys[key] * tmpDir[1];
  5772. }
  5773. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5774. }
  5775.  
  5776. function getSafeDir() {
  5777. if (!player)
  5778. return 0;
  5779. if (!player.lockDir) {
  5780. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5781. }
  5782. return lastDir || 0;
  5783. }
  5784. let plusDir = 0;
  5785. let lastSpin = Date.now();
  5786. function getAttackDir() {
  5787. if(player && Date.now() - lastSpin >= 235 && !(clicks.right || clicks.left)) {
  5788. plusDir += Math.random()*(Math.PI*2);
  5789. lastSpin = Date.now();
  5790. }
  5791. if (!player)
  5792. return "0";
  5793. 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))
  5794. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? near.aim2 : getSafeDir();
  5795. else
  5796. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5797. lastDir = getSafeDir();
  5798. else
  5799. if (traps.inTrap) {
  5800. lastDir = traps.aim;
  5801. } else
  5802. if (!player.lockDir) {
  5803. if (!player.lockDir && autos.stopspin) {
  5804. if(useWasd) {
  5805. lastDir = lastDir;
  5806. } else {
  5807. lastDir = getSafeDir();
  5808. }
  5809. }
  5810. }
  5811. return lastDir;
  5812. }
  5813.  
  5814. function getVisualDir() {
  5815. if (!player)
  5816. return 0;
  5817. lastDir = getSafeDir();
  5818. return lastDir || 0;
  5819. }
  5820.  
  5821. // KEYS:
  5822. function keysActive() {
  5823. return (allianceMenu.style.display != "block" &&
  5824. chatHolder.style.display != "block" &&
  5825. !menuCBFocus);
  5826. }
  5827.  
  5828. function toggleMenuChat() {
  5829. if (menuChatDiv.style.display != "none") {
  5830. // chatHolder.style.display = "none";
  5831. // if (menuChatBox.value != "") {
  5832. //commands[command.slice(1)]
  5833. let cmd = function(command) {
  5834. return {
  5835. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5836. fv: commands[command.slice(1).split(" ")[0]]
  5837. }
  5838. }
  5839. let command = cmd(menuChatBox.value);
  5840. if (command.found) {
  5841. if (typeof command.fv.action === "function") {
  5842. command.fv.action(menuChatBox.value);
  5843. }
  5844. } else {
  5845. sendChat(menuChatBox.value);
  5846. }
  5847. menuChatBox.value = "";
  5848. menuChatBox.blur();
  5849. } else {
  5850. if (menuCBFocus) {
  5851. menuChatBox.blur();
  5852. } else {
  5853. menuChatBox.focus();
  5854. }
  5855. }
  5856. }
  5857.  
  5858. function keyDown(event) {
  5859. let keyNum = event.which || event.keyCode || 0;
  5860. if (player && player.alive && keysActive()) {
  5861. if (!keys[keyNum]) {
  5862. keys[keyNum] = 1;
  5863. macro[event.key] = 1;
  5864. if (keyNum == 27) {
  5865. openMenu = !openMenu;
  5866. $("#menuDiv").toggle();
  5867. $("#menuChatDiv").toggle();
  5868. } else if (keyNum == 69) {
  5869. sendAutoGather();
  5870. } else if (keyNum == 67) {
  5871. updateMapMarker();
  5872. } else if (player.weapons[keyNum - 49] != undefined) {
  5873. player.weaponCode = player.weapons[keyNum - 49];
  5874. } else if (moveKeys[keyNum]) {
  5875. sendMoveDir();
  5876. } else if (event.key == "m") {
  5877. mills.placeSpawnPads = !mills.placeSpawnPads;
  5878. } else if (event.key == "z") {
  5879. mills.place = !mills.place;
  5880. } else if (event.key == "Z") {
  5881. typeof window.debug == "function" && window.debug();
  5882. } else if (keyNum == 32) {
  5883. packet("d", 1, getSafeDir(), 1);
  5884. packet("d", 0, getSafeDir(), 1);
  5885. } else if (event.key == ",") {
  5886. io.send("6", 'syncon')
  5887. project.send(JSON.stringify(["tezt", "ratio"]));
  5888. // botSkts.push([botPlayer]);
  5889. for(let i = 0; i < botz.length; i++) {
  5890. // if(botz[i][0]) {
  5891. botz[i][0].zync(near);
  5892. console.log(botz[i][0])
  5893. }
  5894. // project.send("tezt");
  5895. // botSkts.forEach((bot) => {
  5896. // bot.zync();
  5897. // })
  5898. // io.send("S", 1)
  5899. }
  5900. }
  5901. }
  5902. }
  5903.  
  5904. // let xx = canvaz.width/2;
  5905. // let yy = canvaz.height/2;
  5906.  
  5907. // let mouze = {
  5908. // x: xx - mouzeX,
  5909. // y: yy - mouzeY
  5910. // }
  5911.  
  5912. // let ingamecoorformodabow = {
  5913. // x: player.x + mouze.x,
  5914. // y: player.x + mouze.x
  5915. // }
  5916.  
  5917. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5918.  
  5919. function keyUp(event) {
  5920. if (player && player.alive) {
  5921. let keyNum = event.which || event.keyCode || 0;
  5922. if (keyNum == 13) {
  5923. toggleMenuChat();
  5924. } else if (keysActive()) {
  5925. if (keys[keyNum]) {
  5926. keys[keyNum] = 0;
  5927. macro[event.key] = 0;
  5928. if (moveKeys[keyNum]) {
  5929. sendMoveDir();
  5930. } else if (event.key == ",") {
  5931. player.sync = false;
  5932. }
  5933. }
  5934. }
  5935. }
  5936. }
  5937.  
  5938.  
  5939. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5940.  
  5941. function sendMoveDir() {
  5942. if(found) {
  5943. packet("a", undefined, 1);
  5944. } else {
  5945. let newMoveDir = getMoveDir();
  5946. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5947. if (!my.autoPush && !found) {
  5948. packet("a", newMoveDir, 1);
  5949. }
  5950. lastMoveDir = newMoveDir;
  5951. }
  5952. }
  5953. }
  5954.  
  5955. // BUTTON EVENTS:
  5956. function bindEvents() {}
  5957. bindEvents();
  5958.  
  5959. // ITEM COUNT DISPLAY:
  5960. let isItemSetted = [];
  5961.  
  5962. function updateItemCountDisplay(index = undefined) {
  5963. for (let i = 3; i < items.list.length; ++i) {
  5964. let id = items.list[i].group.id;
  5965. let tmpI = items.weapons.length + i;
  5966. if (!isItemSetted[tmpI]) {
  5967. isItemSetted[tmpI] = document.createElement("div");
  5968. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5969. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5970. isItemSetted[tmpI].style = `
  5971. display: block;
  5972. position: absolute;
  5973. padding-left: 5px;
  5974. font-size: 2em;
  5975. color: #fff;
  5976. `;
  5977. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5978. } else {
  5979. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5980. }
  5981. }
  5982. }
  5983.  
  5984. // AUTOPUSH:
  5985. var retrappable = false;
  5986. function autoPush() {
  5987. retrappable = true;
  5988. 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) {
  5989. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5990. })[0];
  5991. if (nearTrap) {
  5992. 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) {
  5993. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5994. })[0];
  5995. if (spike) {
  5996. let pos = {
  5997. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5998. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5999. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6000. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6001. };
  6002. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6003. let tmpScale = tmp.getScale();
  6004. 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)) {
  6005. return true;
  6006. }
  6007. });
  6008. if (finds) {
  6009. if (my.autoPush) {
  6010. my.autoPush = false;
  6011. packet("a", lastMoveDir || undefined, 1);
  6012. }
  6013. } else {
  6014. my.autoPush = true;
  6015. my.pushData = {
  6016. x: spike.x,
  6017. y: spike.y,
  6018. x2: pos.x2,
  6019. y2: pos.y2
  6020. };
  6021. let scale = (player.scale / 10);
  6022. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6023. packet("a", near.aim2, 1);
  6024. } else {
  6025. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6026. }
  6027. }
  6028. } else {
  6029. if (my.autoPush) {
  6030. my.autoPush = false;
  6031. packet("a", lastMoveDir || undefined, 1);
  6032. }
  6033. }
  6034. } else {
  6035. if (my.autoPush) {
  6036. my.autoPush = false;
  6037. packet("a", lastMoveDir || undefined, 1);
  6038. }
  6039. }
  6040. }
  6041.  
  6042. // ADD DEAD PLAYER:
  6043. function addDeadPlayer(tmpObj) {
  6044. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6045. }
  6046.  
  6047. /** APPLY SOCKET CODES */
  6048.  
  6049. // SET INIT DATA:
  6050. function setInitData(data) {
  6051. alliances = data.teams;
  6052. }
  6053.  
  6054. // SETUP GAME:
  6055. function setupGame(yourSID) {
  6056. keys = {};
  6057. macro = {};
  6058. playerSID = yourSID;
  6059. attackState = 0;
  6060. inGame = true;
  6061. packet("d", 0, getAttackDir(), 1);
  6062. my.ageInsta = true;
  6063. if (firstSetup) {
  6064. firstSetup = false;
  6065. gameObjects.length = 0;
  6066. liztobj.length = 0;
  6067. }
  6068. }
  6069.  
  6070. // ADD NEW PLAYER:
  6071. function addPlayer(data, isYou) {
  6072. let tmpPlayer = findPlayerByID(data[0]);
  6073. if (!tmpPlayer) {
  6074. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6075. objectManager, players, ais, items, hats, accessories);
  6076. players.push(tmpPlayer);
  6077. if (data[1] != playerSID) {
  6078. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6079. }
  6080. } else {
  6081. if (data[1] != playerSID) {
  6082. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6083. }
  6084. }
  6085. tmpPlayer.spawn(isYou ? true : null);
  6086. tmpPlayer.visible = false;
  6087. tmpPlayer.oldPos = {
  6088. x2: undefined,
  6089. y2: undefined
  6090. };
  6091. tmpPlayer.x2 = undefined;
  6092. tmpPlayer.y2 = undefined;
  6093. tmpPlayer.x3 = undefined;
  6094. tmpPlayer.y3 = undefined;
  6095. tmpPlayer.setData(data);
  6096. if (isYou) {
  6097. if (!player) {
  6098. window.prepareUI(tmpPlayer);
  6099. }
  6100. player = tmpPlayer;
  6101. camX = player.x;
  6102. camY = player.y;
  6103. my.lastDir = 0;
  6104. updateItems();
  6105. updateAge();
  6106. updateItemCountDisplay();
  6107. if (player.skins[7]) {
  6108. my.reSync = true;
  6109. }
  6110. }
  6111. }
  6112.  
  6113. // REMOVE PLAYER:
  6114. function removePlayer(id) {
  6115. for (let i = 0; i < players.length; i++) {
  6116. if (players[i].id == id) {
  6117. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6118. players.splice(i, 1);
  6119. break;
  6120. }
  6121. }
  6122. }
  6123.  
  6124. // UPDATE HEALTH:
  6125. function updateHealth(sid, value) {
  6126. tmpObj = findPlayerBySID(sid);
  6127. if (tmpObj) {
  6128. // tmpObj.lastshamecount = tmpObj.shameCount;
  6129. tmpObj.oldHealth = tmpObj.health;
  6130. tmpObj.health = value;
  6131. tmpObj.judgeShame();
  6132. if (tmpObj.oldHealth > tmpObj.health) {
  6133. tmpObj.timeDamaged = Date.now(); //here'
  6134. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6135. let damaged = tmpObj.damaged;
  6136. tmpObj = findPlayerBySID(sid);
  6137.  
  6138. let bullTicked = false;
  6139.  
  6140. if (tmpObj.health <= 0) {
  6141. if (!tmpObj.death) {
  6142. tmpObj.death = true;
  6143. if (tmpObj != player) {
  6144. if(tmpObj.skinIndex == 45) {
  6145. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to clown`, "red");
  6146. } else if(tmpObj.shameCount >= 5) {
  6147. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to high shame`, "red");
  6148. } else {
  6149. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died`, "red");
  6150. }
  6151. }
  6152. addDeadPlayer(tmpObj);
  6153. }
  6154. }
  6155. if (tmpObj == player) {
  6156. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 19 && damaged == 2))) { // bull ticker
  6157. }
  6158.  
  6159.  
  6160.  
  6161. let antiinsta3 = true;
  6162. let autoheal = false;
  6163. let antiinsta4 = true;
  6164.  
  6165.  
  6166.  
  6167. if (inGame) {
  6168. let attackers = getAttacker(damaged);
  6169. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg);
  6170. let includeSpikeDmgs = near.length ? !bullTicked && (gearDmgs.includes(damaged) && near[0].skinIndex == 11 && near[0].tailIndex == 21) : false;
  6171. let healTimeout = 140 - window.ping;
  6172. let slowHeal = function (timer) {
  6173. setTimeout(() => {
  6174. healer();
  6175. }, timer);
  6176. }
  6177. if (damaged >= 0 && damaged <= 66 && player.shameCount === 4 && player.shameCount === 4 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6178. autoheal = true;
  6179. antiinsta = false;
  6180. antiinsta1 = false;
  6181. antiinsta4 = false;
  6182. }else{
  6183. if(player.shameCount !== 4){
  6184. autoheal = false;
  6185. antiinsta = true;
  6186. antiinsta4 = true;
  6187. }
  6188. }
  6189.  
  6190. if (damaged <= 66 && player.shameCount === 3 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6191. antiinsta = false;
  6192. }else{
  6193. if(player.shameCount !== 3){
  6194. antiinsta = true;
  6195. }
  6196. }
  6197. if (damaged <= 66 && player.shameCount === 4 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6198. antiinsta1 = true;
  6199. }else{
  6200. if(player.shameCount !== 4){
  6201. antiinsta1 = false;
  6202. }
  6203. }
  6204. `if (damaged >= 0 && damaged <= 90 && player.shameCount === 2){ // попытка сделать невозможным довести до 3 шеймов через буллспам
  6205. antiinsta4 = false;
  6206. }else{
  6207. if(player.shameCount !== 3){
  6208. antiinsta4 = true;
  6209. }
  6210. }
  6211. if (damaged >= 0 && damaged <= 90 && !antiinsta){
  6212. if(player.shameCount === 3){
  6213. antiinsta1 = true;
  6214. }else{
  6215. antiinsta1 = false;
  6216. }
  6217. }`
  6218.  
  6219. if (damaged <= 66 && player.skinIndex != 6 && enemy.weaponIndex === 4){
  6220. game.tickBase(() => {
  6221. healer1();
  6222. }, 2);
  6223. }
  6224.  
  6225.  
  6226. let dmg = 100 - player.health;
  6227. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && antiinsta4 && (game.tick - tmpObj.antiTimer) > 1) {
  6228. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6229. tmpObj.canEmpAnti = true;
  6230. } else {
  6231. player.soldierAnti = true;
  6232. }
  6233. tmpObj.antiTimer = game.tick;
  6234. let shame = tmpObj.weapons[0] == 4 ? 2 : 5;
  6235. if (tmpObj.shameCount < shame) {
  6236. healer();
  6237. } else {
  6238. game.tickBase(() => {
  6239. healer();
  6240. }, 2);
  6241. }
  6242. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && autoheal) {
  6243. setTimeout(() => {
  6244. healer();
  6245. }, 120);
  6246. }
  6247. let dmg = 100 - player.health;
  6248. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && antiinsta && tmpObj.primaryIndex !== "4" && (game.tick - tmpObj.antiTimer) > 1) {
  6249. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6250. tmpObj.canEmpAnti = true;
  6251. } else {
  6252. player.soldierAnti = true;
  6253. }
  6254. tmpObj.antiTimer = game.tick;
  6255. let shame = tmpObj.weapons[0] == 4 ? 2 : 5;
  6256. if (tmpObj.shameCount < shame) {
  6257. healer();
  6258. } else {
  6259. game.tickBase(() => {
  6260. healer();
  6261. }, 2);
  6262. }
  6263. }
  6264. if (damaged >= 20 && player.skinIndex == 11 && player.shameCount <= 3) instaC.canCounter = true;
  6265. } else {
  6266. game.tickBase(() => {
  6267. healer();
  6268. }, 2);
  6269. }
  6270. //if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6271. }
  6272. // if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6273. } else {
  6274. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 19 && tmpObj.damaged == 2))) {
  6275. tmpObj.setPoisonTick = true;
  6276. }
  6277. }
  6278. }
  6279. }
  6280. }
  6281.  
  6282. // KILL PLAYER:
  6283. function killPlayer() {
  6284. inGame = false;
  6285. lastDeath = {
  6286. x: player.x,
  6287. y: player.y,
  6288. };
  6289. }
  6290.  
  6291. // UPDATE PLAYER ITEM VALUES:
  6292. function updateItemCounts(index, value) {
  6293. if (player) {
  6294. player.itemCounts[index] = value;
  6295. updateItemCountDisplay(index);
  6296. }
  6297. }
  6298.  
  6299. // UPDATE AGE:
  6300. function updateAge(xp, mxp, age) {
  6301. if (xp != undefined)
  6302. player.XP = xp;
  6303. if (mxp != undefined)
  6304. player.maxXP = mxp;
  6305. if (age != undefined)
  6306. player.age = age;
  6307. }
  6308.  
  6309. // UPDATE UPGRADES:
  6310. function updateUpgrades(points, age) {
  6311. player.upgradePoints = points;
  6312. player.upgrAge = age;
  6313. if (points > 0) {
  6314. tmpList.length = 0;
  6315. UTILS.removeAllChildren(upgradeHolder);
  6316. for (let i = 0; i < items.weapons.length; ++i) {
  6317. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6318. let e = UTILS.generateElement({
  6319. id: "upgradeItem" + i,
  6320. class: "actionBarItem",
  6321. onmouseout: function() {
  6322. showItemInfo();
  6323. },
  6324. parent: upgradeHolder
  6325. });
  6326. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6327. tmpList.push(i);
  6328. }
  6329. }
  6330. for (let i = 0; i < items.list.length; ++i) {
  6331. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6332. let tmpI = (items.weapons.length + i);
  6333. let e = UTILS.generateElement({
  6334. id: "upgradeItem" + tmpI,
  6335. class: "actionBarItem",
  6336. onmouseout: function() {
  6337. showItemInfo();
  6338. },
  6339. parent: upgradeHolder
  6340. });
  6341. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6342. tmpList.push(tmpI);
  6343. }
  6344. }
  6345. for (let i = 0; i < tmpList.length; i++) {
  6346. (function(i) {
  6347. let tmpItem = getEl('upgradeItem' + i);
  6348. // tmpItem.onmouseover = function() {
  6349. // if (items.weapons[i]) {
  6350. // showItemInfo(items.weapons[i], true);
  6351. // } else {
  6352. // showItemInfo(items.list[i - items.weapons.length]);
  6353. // }
  6354. // };
  6355. tmpItem.onclick = UTILS.checkTrusted(function() {
  6356. packet("H", i);
  6357. });
  6358. UTILS.hookTouchEvents(tmpItem);
  6359. })(tmpList[i]);
  6360. }
  6361. if (tmpList.length) {
  6362. upgradeHolder.style.display = "block";
  6363. upgradeCounter.style.display = "block";
  6364. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6365. } else {
  6366. upgradeHolder.style.display = "none";
  6367. upgradeCounter.style.display = "none";
  6368. showItemInfo();
  6369. }
  6370. } else {
  6371. upgradeHolder.style.display = "none";
  6372. upgradeCounter.style.display = "none";
  6373. showItemInfo();
  6374. }
  6375. }
  6376.  
  6377. // KILL OBJECT:
  6378. function killObject(sid) {
  6379. let findObj = findObjectBySid(sid);
  6380. objectManager.disableBySid(sid);
  6381. if (player) {
  6382. for (let i = 0; i < breakObjects.length; i++) {
  6383. if (breakObjects[i].sid == sid) {
  6384. breakObjects.splice(i, 1);
  6385. break;
  6386. }
  6387. }
  6388. if (!player.canSee(findObj)) {
  6389. breakTrackers.push({
  6390. x: findObj.x,
  6391. y: findObj.y
  6392. });
  6393. }
  6394. if (breakTrackers.length > 8) {
  6395. breakTrackers.shift();
  6396. }
  6397. traps.replacer(findObj);
  6398. }
  6399. }
  6400.  
  6401. // KILL ALL OBJECTS BY A PLAYER:
  6402. function killObjects(sid) {
  6403. if (player) objectManager.removeAllItems(sid);
  6404. }
  6405. function setTickout(doo, timeout) {
  6406. if (!ticks.manage[ticks.tick + timeout]) {
  6407. ticks.manage[ticks.tick + timeout] = [doo];
  6408. } else {
  6409. ticks.manage[ticks.tick + timeout].push(doo);
  6410. }
  6411. }
  6412.  
  6413. function caf(e, t) {
  6414. try {
  6415. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6416. } catch (e) {
  6417. return 0;
  6418. }
  6419. }
  6420.  
  6421. let found = false;
  6422. let autoQ = false;
  6423.  
  6424. let autos = {
  6425. insta: {
  6426. todo: false,
  6427. wait: false,
  6428. count: 4,
  6429. shame: 5
  6430. },
  6431. bull: false,
  6432. antibull: 0,
  6433. reloaded: false,
  6434. stopspin: true
  6435. }
  6436.  
  6437. // UPDATE PLAYER DATA:
  6438. function updatePlayers(data) { //bulltick
  6439. if(player.shameCount > 1) {
  6440. buyEquip(7, 0);
  6441. buyEquip(19, 1);
  6442. } else {
  6443. if(player.lastshamecount != 1 || player.lastshamecount != 2 || player.lastshamecount != 3 || player.lastshamecount != 4 || player.lastshamecount != 5 || player.lastshamecount != 6 || player.lastshamecount == 0) {
  6444. buyEquip(6, 0);
  6445. }
  6446. }
  6447.  
  6448.  
  6449. // let movementPrediction = {
  6450. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6451. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6452. // }
  6453.  
  6454. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6455.  
  6456. // potentialzpiketick.forEach((obj) => {
  6457. // if(cdf(obj, player) <= 200) {
  6458. // packet('a', undefined);
  6459. // }
  6460. // })
  6461.  
  6462. // let newPos = {
  6463. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6464. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6465. // }
  6466.  
  6467. function getAngleDifference(angle1, angle2) {
  6468. // Normalize the angles to be between 0 and 2π
  6469. angle1 = angle1 % (2 * Math.PI);
  6470. angle2 = angle2 % (2 * Math.PI);
  6471.  
  6472. // Calculate the absolute difference between the angles
  6473. let diff = Math.abs(angle1 - angle2);
  6474.  
  6475. // Adjust the difference to be between 0 and π
  6476. if (diff > Math.PI) {
  6477. diff = (2 * Math.PI) - diff;
  6478. }
  6479.  
  6480. return diff;
  6481. }
  6482.  
  6483. // function smartMove(oneTickMove) {
  6484. // let dir = player.moveDir;
  6485.  
  6486. // let found = false
  6487. // 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))
  6488. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6489.  
  6490. // let newPos = {
  6491. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6492. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6493. // }
  6494.  
  6495. // for (let i = 0; i < spikes.length; i++) {
  6496. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6497. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6498. // }
  6499. // }
  6500.  
  6501.  
  6502.  
  6503.  
  6504.  
  6505. // if (found != false && !traps.inTrap) {
  6506. // packet("a", undefined);
  6507. // } else {
  6508. // packet("a", dir);
  6509. // }
  6510. // player.oldPos.x2 = player.x2;
  6511. // player.oldPos.y2 = player.y2;
  6512. // }
  6513. // function detectEnemySpikeCollisions(tmpObj) {
  6514. // 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));
  6515. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6516. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6517. // let enemy = {
  6518. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6519. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6520. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6521. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6522. // }
  6523. // let found = false;
  6524. // for (let i = 0; i < spikes.length; i++) {
  6525. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6526. // found = true;
  6527. // }
  6528. // }
  6529.  
  6530. // // player.oldPos.x2 = tmpObj.x2;
  6531. // // player.oldPos.y2 = tmpObj.y2;
  6532. // }
  6533.  
  6534. game.tick++;
  6535. enemy = [];
  6536. nears = [];
  6537. near = [];
  6538. game.tickSpeed = performance.now() - game.lastTick;
  6539. game.lastTick = performance.now();
  6540. players.forEach((tmp) => {
  6541. tmp.forcePos = !tmp.visible;
  6542. tmp.visible = false;
  6543. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6544. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6545. });
  6546. for (let i = 0; i < data.length;) {
  6547. tmpObj = findPlayerBySID(data[i]);
  6548. if (tmpObj) {
  6549. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6550. tmpObj.t2 = game.lastTick;
  6551. tmpObj.oldPos.x2 = tmpObj.x2;
  6552. tmpObj.oldPos.y2 = tmpObj.y2;
  6553. tmpObj.x1 = tmpObj.x;
  6554. tmpObj.y1 = tmpObj.y;
  6555. tmpObj.x2 = data[i + 1];
  6556. tmpObj.y2 = data[i + 2];
  6557. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6558. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6559. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6560. tmpObj.d2 = data[i + 3];
  6561. tmpObj.dt = 0;
  6562. tmpObj.buildIndex = data[i + 4];
  6563. tmpObj.weaponIndex = data[i + 5];
  6564. tmpObj.weaponVariant = data[i + 6];
  6565. tmpObj.team = data[i + 7];
  6566. tmpObj.isLeader = data[i + 8];
  6567. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6568. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6569. tmpObj.skinIndex = data[i + 9];
  6570. tmpObj.tailIndex = data[i + 10];
  6571. tmpObj.iconIndex = data[i + 11];
  6572. tmpObj.zIndex = data[i + 12];
  6573. tmpObj.visible = true;
  6574. tmpObj.update(game.tickSpeed);
  6575. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6576. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6577. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6578. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6579. tmpObj.damageThreat = 0;
  6580. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6581. tmpObj.addShameTimer();
  6582. }
  6583. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6584. tmpObj.shameTimer = 0;
  6585. tmpObj.shameCount = 0;
  6586. if (tmpObj == player) {
  6587. healer();
  6588. }
  6589. }
  6590.  
  6591. botSkts.forEach((bot) => {
  6592. bot.showName = 'YEAHHH'
  6593. })
  6594.  
  6595. for(let i = 0; i < players.length; i++) {
  6596. for(let aa = 0; aa < botSkts.length; aa++) {
  6597. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6598.  
  6599. }
  6600. }
  6601.  
  6602. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6603. autoQ = true;
  6604. healer();
  6605. } else {
  6606. if (autoQ) {
  6607. healer();
  6608. }
  6609. autoQ = false;
  6610. }
  6611.  
  6612.  
  6613. if (tmpObj == player) {
  6614. if (liztobj.length) {
  6615. liztobj.forEach((tmp) => {
  6616. tmp.onNear = false;
  6617. if (tmp.active) {
  6618. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6619. tmp.onNear = true;
  6620. }
  6621. if (tmp.isItem && tmp.owner) {
  6622. 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)) {
  6623. tmp.breakObj = true;
  6624. breakObjects.push({
  6625. x: tmp.x,
  6626. y: tmp.y,
  6627. sid: tmp.sid
  6628. });
  6629. }
  6630. }
  6631. }
  6632. });
  6633. 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) {
  6634. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6635. })[0];
  6636. if (nearTrap) {
  6637. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6638. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6639. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6640.  
  6641. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6642. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6643. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6644. traps.inTrap = true;
  6645. traps.info = nearTrap;
  6646. } else {
  6647. traps.inTrap = false;
  6648. traps.info = {};
  6649. }
  6650. } else {
  6651. traps.inTrap = false;
  6652. }
  6653. }
  6654. if (tmpObj.weaponIndex < 9) {
  6655. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6656. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6657. } else if (tmpObj.weaponIndex > 8) {
  6658. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6659. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6660. }
  6661. }
  6662. i += 13;
  6663. }
  6664. if (textManager.stack.length) {
  6665. let stacks = [];
  6666. let notstacks = [];
  6667. let num = 0;
  6668. let num2 = 0;
  6669. let pos = {
  6670. x: null,
  6671. y: null
  6672. };
  6673. let pos2 = {
  6674. x: null,
  6675. y: null
  6676. }
  6677. textManager.stack.forEach((text) => {
  6678. if (text.value >= 0) {
  6679. if (num == 0) pos = {
  6680. x: text.x,
  6681. y: text.y
  6682. };
  6683. num += Math.abs(text.value);
  6684. } else {
  6685. if (num2 == 0) pos2 = {
  6686. x: text.x,
  6687. y: text.y
  6688. };
  6689. num2 += Math.abs(text.value);
  6690. }
  6691. });
  6692. if (num2 > 0) {
  6693. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  6694. }
  6695. if (num > 0) {
  6696. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6697. }
  6698. textManager.stack = [];
  6699. }
  6700. if (runAtNextTick.length) {
  6701. runAtNextTick.forEach((tmp) => {
  6702. checkProjectileHolder(...tmp);
  6703. });
  6704. runAtNextTick = [];
  6705. }
  6706. for (let i = 0; i < data.length;) {
  6707. tmpObj = findPlayerBySID(data[i]);
  6708. if (tmpObj) {
  6709. if (!tmpObj.isTeam(player)) {
  6710. enemy.push(tmpObj);
  6711. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6712. nears.push(tmpObj);
  6713. }
  6714. }
  6715. tmpObj.manageReload();
  6716. if (tmpObj != player) {
  6717. tmpObj.addDamageThreat(player);
  6718. }
  6719. }
  6720. i += 13;
  6721. }
  6722. /*projectiles.forEach((proj) => {
  6723. tmpObj = proj;
  6724. if (tmpObj.active) {
  6725. tmpObj.tickUpdate(game.tickSpeed);
  6726. }
  6727. });*/
  6728. if (player && player.alive) {
  6729. if (enemy.length) {
  6730. near = enemy.sort(function(tmp1, tmp2) {
  6731. return tmp1.dist2 - tmp2.dist2;
  6732. })[0];
  6733. } else {
  6734. // console.log("no enemy");
  6735. }
  6736. if (game.tickQueue[game.tick]) {
  6737. game.tickQueue[game.tick].forEach((action) => {
  6738. action();
  6739. });
  6740. game.tickQueue[game.tick] = null;
  6741. }
  6742. players.forEach((tmp) => {
  6743. if (!tmp.visible && player != tmp) {
  6744. tmp.reloads = {
  6745. 0: 0,
  6746. 1: 0,
  6747. 2: 0,
  6748. 3: 0,
  6749. 4: 0,
  6750. 5: 0,
  6751. 6: 0,
  6752. 7: 0,
  6753. 8: 0,
  6754. 9: 0,
  6755. 10: 0,
  6756. 11: 0,
  6757. 12: 0,
  6758. 13: 0,
  6759. 14: 0,
  6760. 15: 0,
  6761. 53: 0,
  6762. };
  6763. }
  6764. if (tmp.setBullTick) {
  6765. tmp.bullTimer = 0;
  6766. }
  6767. if (tmp.setPoisonTick) {
  6768. tmp.poisonTimer = 0;
  6769. }
  6770. tmp.updateTimer();
  6771. });
  6772. if (inGame) {
  6773. if (enemy.length) {
  6774. if (player.canEmpAnti) {
  6775. player.canEmpAnti = false;
  6776. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6777. if (near.reloads[53] == 0) {
  6778. player.empAnti = true;
  6779. player.soldierAnti = false;
  6780. //modLog("EmpAnti");
  6781. } else {
  6782. player.empAnti = false;
  6783. player.soldierAnti = true;
  6784. //modLog("SoldierAnti");
  6785. }
  6786. }
  6787. }
  6788. 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) {
  6789. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6790. })[0];
  6791. if (prehit) {
  6792. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6793. instaC.canSpikeTick = true;
  6794. instaC.syncHit = true;
  6795. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6796. instaC.revTick = true;
  6797. }
  6798. }
  6799. }
  6800. 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) {
  6801. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6802. })[0];
  6803. if (antiSpikeTick && !traps.inTrap) {
  6804. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  6805. my.anti0Tick = 1;
  6806. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  6807. //player.chat.count = 2000;
  6808. }
  6809. }
  6810. }
  6811. 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)) {
  6812. if (player.checkCanInsta(true) >= 100) {
  6813. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6814. } else {
  6815. instaC.nobull = false;
  6816. }
  6817. instaC.can = true;
  6818. } else {
  6819. instaC.can = false;
  6820. }
  6821. macro.q && place(0, getAttackDir());
  6822. macro.f && place(4, getSafeDir());
  6823. macro.v && place(2, getSafeDir());
  6824. macro.y && place(5, getSafeDir());
  6825. macro.h && place(player.getItemType(22), getSafeDir());
  6826. macro.n && place(3, getSafeDir());
  6827. if (game.tick % 1 == 0) {
  6828. if (mills.place) {
  6829. let plcAng = 7.7;
  6830. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6831. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6832. }
  6833. } else {
  6834. if (mills.placeSpawnPads) {
  6835. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6836. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6837. }
  6838. }
  6839. }
  6840. }
  6841. if (instaC.can) {
  6842. instaC.changeType(player.weapons[1] == 10 ? "rev" : "normal");
  6843. }
  6844. if (instaC.canCounter) {
  6845. instaC.canCounter = false;
  6846. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6847. instaC.counterType();
  6848. }
  6849. }
  6850. if (instaC.canSpikeTick) {
  6851. instaC.canSpikeTick = false;
  6852. if (instaC.revTick) {
  6853. instaC.revTick = false;
  6854. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6855. instaC.changeType("rev");
  6856. chch(null, "[RevSyncHit]", "yellow");
  6857. }
  6858. } else {
  6859. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6860. instaC.spikeTickType();
  6861. if (instaC.syncHit) {
  6862. chch(null, "[SyncHit]", "yellow");
  6863. }
  6864. }
  6865. }
  6866. }
  6867. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6868. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6869. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6870. }
  6871. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6872. sendAutoGather();
  6873. my.waitHit = 1;
  6874. game.tickBase(() => {
  6875. sendAutoGather();
  6876. my.waitHit = 0;
  6877. }, 1);
  6878. }
  6879. }
  6880. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6881. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6882. selectWeapon(player.weapons[0]);
  6883. }
  6884. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6885. sendAutoGather();
  6886. my.waitHit = 1;
  6887. game.tickBase(() => {
  6888. sendAutoGather();
  6889. my.waitHit = 0;
  6890. }, 1);
  6891. }
  6892. }
  6893. if (traps.inTrap) {
  6894. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6895. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6896. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6897. }
  6898. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6899. sendAutoGather();
  6900. my.waitHit = 1;
  6901. game.tickBase(() => {
  6902. sendAutoGather();
  6903. my.waitHit = 0;
  6904. }, 1);
  6905. }
  6906. }
  6907. }
  6908. if (clicks.middle && !traps.inTrap) {
  6909. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6910. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6911. instaC.bowMovement();
  6912. } else {
  6913. instaC.rangeType();
  6914. }
  6915. }
  6916. }
  6917. if (macro.t && !traps.inTrap) {
  6918. 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))) {
  6919. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6920. }
  6921. }
  6922. if (macro["."] && !traps.inTrap) {
  6923. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6924. instaC.boostTickMovement();
  6925. }
  6926. }
  6927. 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)) {
  6928. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6929. if (!my.reloaded) {
  6930. my.reloaded = true;
  6931. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6932. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6933. selectWeapon(player.weapons[fastSpeed]);
  6934. }
  6935. }
  6936. // if(useWasd) {
  6937. // if (!autos.stopspin) {
  6938. // setTimeout(()=>{
  6939. // autos.stopspin = true;
  6940. // }, 375);
  6941. // }
  6942. // }
  6943. } else {
  6944. my.reloaded = false;
  6945. if(useWasd) {
  6946. autos.stopspin = false;
  6947. }
  6948. if (player.reloads[player.weapons[0]] > 0) {
  6949. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6950. selectWeapon(player.weapons[0]);
  6951. }
  6952. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6953. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6954. selectWeapon(player.weapons[1]);
  6955. }
  6956. if(useWasd) {
  6957. if (!autos.stopspin) {
  6958. setTimeout(()=>{
  6959. autos.stopspin = true;
  6960. }, 750);
  6961. }
  6962. }
  6963. }
  6964. }
  6965. }
  6966. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6967. traps.autoPlace();
  6968. }
  6969. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6970. packet("D", getAttackDir());
  6971. }
  6972. let hatChanger = function () {
  6973. if (clicks.left || clicks.right) {
  6974. if (clicks.left) {
  6975. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  6976. } else if (clicks.right) {
  6977. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  6978. }
  6979. } else {
  6980.  
  6981.  
  6982. if (clicks.left || clicks.right) {
  6983. if (
  6984. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  6985. ((near && near.dist2 > 120) || !near)
  6986. ) {
  6987. } else {
  6988. if (clicks.left) {
  6989. buyEquip(
  6990. player.reloads[player.weapons[0]] == 0
  6991. ? getEl('weaponGrind').checked
  6992. ? 40
  6993. : 7
  6994. : player.empAnti
  6995. ? 22
  6996. : player.soldierAnti
  6997. ? 6
  6998. : getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  6999. ? 11
  7000. : near.dist2 <= 300
  7001. ? getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7002. ? 11
  7003. : 6
  7004. : biomeGear(1, 1),
  7005. 0
  7006. );
  7007. } else if (clicks.right) {
  7008. buyEquip(
  7009. player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0
  7010. ? 40
  7011. : player.empAnti
  7012. ? 22
  7013. : player.soldierAnti
  7014. ? 6
  7015. : getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7016. ? 11
  7017. : near.dist2 <= 300
  7018. ? getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7019. ? 11
  7020. : 6
  7021. : biomeGear(1, 1),
  7022. 0
  7023. );
  7024. }
  7025. }
  7026. } else if (traps.inTrap) {
  7027. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) { //autobreaker
  7028. buyEquip(40, 0);
  7029. buyEquip(19, 1);
  7030. } else {
  7031. if (
  7032. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7033. ((near && near.dist2 > 140) || !near)
  7034. ) {
  7035. }
  7036. }
  7037. } else {
  7038. if (
  7039. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7040. ((near && near.dist2 > 140) || !near)
  7041. ) {
  7042. } else {
  7043. if (near.dist2 <= 300) {
  7044. buyEquip(
  7045. getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7046. ? 11
  7047. : getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7048. ? 11
  7049. : 6,
  7050. 0
  7051. );
  7052. } else {
  7053. biomeGear(1);
  7054. }
  7055. }
  7056. }
  7057. }
  7058. };
  7059.  
  7060.  
  7061. let accChanger = function() {
  7062. if (instaC.can && player.checkCanInsta(true) >= 100) {
  7063. buyEquip(21, 1);
  7064. } else if (clicks.left) {
  7065. setTimeout(() => {
  7066. buyEquip(19, 1);
  7067. }, 50)
  7068. } else if (clicks.right) {
  7069. setTimeout(() => {
  7070. buyEquip(21, 1);
  7071. }, 50)
  7072. } else if (near.dist2 <= 240) {
  7073. buyEquip(19, 1);
  7074. } else {
  7075. traps.inTrap ? buyEquip(19, 1) : buyEquip(11, 1);
  7076. }
  7077. };
  7078. let wasdGears = function() {
  7079. if (my.anti0Tick > 0) {
  7080. buyEquip(6, 0);
  7081. } else {
  7082. if (clicks.left || clicks.right) {
  7083. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7084. buyEquip(7, 0);
  7085. } else {
  7086. if (clicks.left) {
  7087. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7088. } else if (clicks.right) {
  7089. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7090. }
  7091. }
  7092. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7093. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7094. buyEquip(7, 0);
  7095. } else {
  7096. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7097. }
  7098. } else if (traps.inTrap) {
  7099. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7100. buyEquip(40, 0);
  7101. } else {
  7102. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7103. buyEquip(7, 0);
  7104. } else {
  7105. buyEquip(player.empAnti ? 22 : 6, 0);
  7106. }
  7107. }
  7108. } else {
  7109. if (player.empAnti) {
  7110. buyEquip(22, 0);
  7111. } else {
  7112. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7113. buyEquip(7, 0);
  7114. } else {
  7115. buyEquip(6, 0);
  7116. }
  7117. }
  7118. }
  7119. }
  7120. if (clicks.left || clicks.right) {
  7121. if (clicks.left) {
  7122. buyEquip(0, 1);
  7123. } else if (clicks.right) {
  7124. buyEquip(11, 1);
  7125. }
  7126. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7127. buyEquip(0, 1);
  7128. } else if (traps.inTrap) {
  7129. buyEquip(0, 1);
  7130. } else {
  7131. buyEquip(11, 1);
  7132. }
  7133. }
  7134. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7135. if (useWasd) {
  7136. wasdGears();
  7137. } else {
  7138. hatChanger();
  7139. accChanger();
  7140. }
  7141. }
  7142. //lastMoveDir = getSafeDir();
  7143. //packet("a", lastMoveDir, 1);
  7144. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7145. autoPush();
  7146. } else {
  7147. if (my.autoPush) {
  7148. my.autoPush = false;
  7149. packet("a", lastMoveDir || undefined, 1);
  7150. }
  7151. }
  7152. if (instaC.ticking) {
  7153. instaC.ticking = false;
  7154. }
  7155. if (instaC.syncHit) {
  7156. instaC.syncHit = false;
  7157. }
  7158. if (player.empAnti) {
  7159. player.empAnti = false;
  7160. }
  7161. if (player.soldierAnti) {
  7162. player.soldierAnti = false;
  7163. }
  7164. if (my.anti0Tick > 0) {
  7165. my.anti0Tick--;
  7166. }
  7167. if (traps.replaced) {
  7168. traps.replaced = false;
  7169. }
  7170. if (traps.antiTrapped) {
  7171. traps.antiTrapped = false;
  7172. }
  7173.  
  7174. const getPotentialDamage = (build, user) => {
  7175. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7176. const weap = user.weapons[weapIndex];
  7177. if (player.reloads[weap]) return 0;
  7178. const weapon = items.weapons[weap];
  7179. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7180. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7181. };
  7182.  
  7183. const AutoReplace = () => {
  7184. const replaceable = [];
  7185. const playerX = player.x;
  7186. const playerY = player.y;
  7187. const gameObjectCount = gameObjects.length;
  7188.  
  7189. for (let i = 0; i < gameObjectCount; i++) {
  7190. const build = gameObjects[i];
  7191. if (build.isItem && build.active && build.health > 0) {
  7192. const item = items.list[build.id];
  7193. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7194. const inDistance = cdf(build, player) <= posDist * 2;
  7195. if (inDistance) {
  7196. let canDeal = 0;
  7197. const playersCount = players.length;
  7198. for (let j = 0; j < playersCount; j++) {
  7199. canDeal += getPotentialDamage(build, players[j]);
  7200. }
  7201. if (build.health <= canDeal) {
  7202. replaceable.push(build);
  7203. }
  7204. }
  7205. }
  7206. }
  7207.  
  7208. const findPlacementAngle = (player, itemId, build) => {
  7209. if (!build) return null;
  7210. const MAX_ANGLE = 2 * Math.PI;
  7211. const ANGLE_STEP = Math.PI / 360;
  7212. const item = items.list[player.items[itemId]];
  7213. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7214. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7215.  
  7216. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7217. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7218. for (let angle of angles) {
  7219. return angle;
  7220. }
  7221. }
  7222. return null;
  7223. };
  7224.  
  7225. const replace = (() => {
  7226. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7227. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7228. const buildId = spike ? 4 : 2;
  7229.  
  7230. replaceable.forEach(build => {
  7231. let angle = findPlacementAngle(player, buildId, build);
  7232. if (angle !== null) {
  7233. place(buildId, angle);
  7234. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7235. }
  7236. });
  7237. });
  7238.  
  7239. if (near && near.dist3 <= 360) {
  7240. replace();
  7241. }
  7242. replace;
  7243. }
  7244. }
  7245. }
  7246. if (botSkts.length) {
  7247. botSkts.forEach((bots) => {
  7248. if (true) {
  7249. bots[0].showName = 'YEAHHH';
  7250. }
  7251. });
  7252. }
  7253. }
  7254. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7255. 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)
  7256.  
  7257. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7258. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7259. selectWeapon(player.weapons[1])
  7260. buyEquip(40, 0);
  7261. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7262. setTickout( () => {
  7263. buyEquip(6, 0)
  7264. }, 1);
  7265. }
  7266. }
  7267. }
  7268. }
  7269. function ez(context, x, y) {
  7270. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7271. context.beginPath();
  7272. context.arc(x, y, 55, 0, Math.PI * 2);
  7273. context.fill();
  7274. context.closePath();
  7275. context.globalAlpha = 1;
  7276. }
  7277. // UPDATE LEADERBOARD:
  7278. function updateLeaderboard(data) {
  7279. lastLeaderboardData = data;
  7280. return;
  7281. UTILS.removeAllChildren(leaderboardData);
  7282. let tmpC = 1;
  7283. for (let i = 0; i < data.length; i += 3) {
  7284. (function(i) {
  7285. UTILS.generateElement({
  7286. class: "leaderHolder",
  7287. parent: leaderboardData,
  7288. children: [
  7289. UTILS.generateElement({
  7290. class: "leaderboardItem",
  7291. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7292. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7293. }),
  7294. UTILS.generateElement({
  7295. class: "leaderScore",
  7296. text: UTILS.sFormat(data[i + 2]) || "0"
  7297. })
  7298. ]
  7299. });
  7300. })(i);
  7301. tmpC++;
  7302. }
  7303. }
  7304.  
  7305. // LOAD GAME OBJECT:
  7306. function loadGameObject(data) {
  7307. for (let i = 0; i < data.length;) {
  7308. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7309. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7310. sid: data[i + 7]
  7311. } : null));
  7312. // sid, x, y, dir, s, type, data, setSID, owner
  7313. /*let dist = UTILS.getDist({
  7314. x: data[i + 1],
  7315. y: data[i + 2]
  7316. }, player, 0, 2);
  7317. let aim = UTILS.getDirect({
  7318. x: data[i + 1],
  7319. y: data[i + 2]
  7320. }, player, 0, 2);
  7321. find = findObjectBySid(data[i]);
  7322. if (data[i + 6] == 15) {
  7323. if (find && !find.isTeamObject(player)) {
  7324. if (dist <= 100) {
  7325. traps.dist = dist;
  7326. traps.aim = aim;
  7327. traps.protect(aim);
  7328. }
  7329. }
  7330. }*/
  7331. i += 8;
  7332. }
  7333. }
  7334.  
  7335. // ADD AI:
  7336. function loadAI(data) {
  7337. for (let i = 0; i < ais.length; ++i) {
  7338. ais[i].forcePos = !ais[i].visible;
  7339. ais[i].visible = false;
  7340. }
  7341. if (data) {
  7342. let tmpTime = performance.now();
  7343. for (let i = 0; i < data.length;) {
  7344. tmpObj = findAIBySID(data[i]);
  7345. if (tmpObj) {
  7346. tmpObj.index = data[i + 1];
  7347. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7348. tmpObj.t2 = tmpTime;
  7349. tmpObj.x1 = tmpObj.x;
  7350. tmpObj.y1 = tmpObj.y;
  7351. tmpObj.x2 = data[i + 2];
  7352. tmpObj.y2 = data[i + 3];
  7353. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7354. tmpObj.d2 = data[i + 4];
  7355. tmpObj.health = data[i + 5];
  7356. tmpObj.dt = 0;
  7357. tmpObj.visible = true;
  7358. } else {
  7359. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7360. tmpObj.x2 = tmpObj.x;
  7361. tmpObj.y2 = tmpObj.y;
  7362. tmpObj.d2 = tmpObj.dir;
  7363. tmpObj.health = data[i + 5];
  7364. if (!aiManager.aiTypes[data[i + 1]].name)
  7365. tmpObj.name = config.cowNames[data[i + 6]];
  7366. tmpObj.forcePos = true;
  7367. tmpObj.sid = data[i];
  7368. tmpObj.visible = true;
  7369. }
  7370. i += 7;
  7371. }
  7372. }
  7373. }
  7374.  
  7375. // ANIMATE AI:
  7376. function animateAI(sid) {
  7377. tmpObj = findAIBySID(sid);
  7378. if (tmpObj) tmpObj.startAnim();
  7379. }
  7380.  
  7381. // GATHER ANIMATION:
  7382. function gatherAnimation(sid, didHit, index) {
  7383. tmpObj = findPlayerBySID(sid);
  7384. if (tmpObj) {
  7385. tmpObj.startAnim(didHit, index);
  7386. tmpObj.gatherIndex = index;
  7387. tmpObj.gathering = 1;
  7388.  
  7389. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7390. // healer();
  7391.  
  7392. if (didHit) {
  7393. let tmpObjects = objectManager.hitObj;
  7394. objectManager.hitObj = [];
  7395. game.tickBase(() => {
  7396. // refind
  7397. tmpObj = findPlayerBySID(sid);
  7398. 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);
  7399. tmpObjects.forEach((healthy) => {
  7400. healthy.health -= val;
  7401. });
  7402. }, 1);
  7403. }
  7404. }
  7405. }
  7406. if(nears.filter(near => near.gathering).length>1) {
  7407. player.chat.message = "pSyD";
  7408. healer();
  7409. }
  7410.  
  7411.  
  7412. // WIGGLE GAME OBJECT:
  7413. function wiggleGameObject(dir, sid) {
  7414. tmpObj = findObjectBySid(sid);
  7415. if (tmpObj) {
  7416. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7417. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7418. if (tmpObj.health) {
  7419. objectManager.hitObj.push(tmpObj);
  7420. }
  7421. }
  7422. }
  7423.  
  7424. // SHOOT TURRET:
  7425. function shootTurret(sid, dir) {
  7426. tmpObj = findObjectBySid(sid);
  7427. if (tmpObj) {
  7428. if (config.anotherVisual) {
  7429. tmpObj.lastDir = dir;
  7430. } else {
  7431. tmpObj.dir = dir;
  7432. }
  7433. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7434. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7435. }
  7436. }
  7437.  
  7438. // UPDATE PLAYER VALUE:
  7439. function updatePlayerValue(index, value, updateView) {
  7440. if (player) {
  7441. player[index] = value;
  7442. if (index == "points") {
  7443. if (configs.autoBuy) {
  7444. autoBuy.hat();
  7445. autoBuy.acc();
  7446. }
  7447. } else if (index == "kills") {
  7448. if (configs.killChat) {
  7449. sendChat("gg- AutoGG Oblivion Mod");
  7450. }
  7451. }
  7452. }
  7453. }
  7454.  
  7455.  
  7456. // ACTION BAR:
  7457. function updateItems(data, wpn) {
  7458. if (data) {
  7459. if (wpn) {
  7460. player.weapons = data;
  7461. player.primaryIndex = player.weapons[0];
  7462. player.secondaryIndex = player.weapons[1];
  7463. if (!instaC.isTrue) {
  7464. selectWeapon(player.weapons[0]);
  7465. }
  7466. } else {
  7467. player.items = data;
  7468. }
  7469. }
  7470.  
  7471. for (let i = 0; i < items.list.length; i++) {
  7472. let tmpI = items.weapons.length + i;
  7473. let actionBarItem = getEl("actionBarItem" + tmpI);
  7474. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7475. // Add shadow to the element
  7476. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7477. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7478.  
  7479. }
  7480.  
  7481. for (let i = 0; i < items.weapons.length; i++) {
  7482. let actionBarItem = getEl("actionBarItem" + i);
  7483. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7484. // Add shadow to the element
  7485. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7486. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7487. }
  7488.  
  7489. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7490. if (kms) {
  7491. getEl("actionBarItem3").style.display = "none";
  7492. getEl("actionBarItem4").style.display = "inline-block";
  7493. }
  7494. }
  7495.  
  7496. // ADD PROJECTILE:
  7497. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7498. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7499. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7500. }
  7501.  
  7502. // REMOVE PROJECTILE:
  7503. function remProjectile(sid, range) {
  7504. for (let i = 0; i < projectiles.length; ++i) {
  7505. if (projectiles[i].sid == sid) {
  7506. projectiles[i].range = range;
  7507. let tmpObjects = objectManager.hitObj;
  7508. objectManager.hitObj = [];
  7509. game.tickBase(() => {
  7510. let val = projectiles[i].dmg;
  7511. tmpObjects.forEach((healthy) => {
  7512. if (healthy.projDmg) {
  7513. healthy.health -= val;
  7514. }
  7515. });
  7516. }, 1);
  7517. }
  7518. }
  7519. }
  7520.  
  7521. // lol this useless,,, fr
  7522. let noob = false;
  7523. let serverReady = true;
  7524. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7525. let wssws = isProd ? "wss" : "ws";
  7526. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7527. let withSync = false;
  7528. project.binaryType = "arraybuffer";
  7529. project.onmessage = function(msg) {
  7530. let data = msg.data;
  7531. if (data == "isready") {
  7532. serverReady = true;
  7533. }
  7534. if (data == "fine") {
  7535. noob = false;
  7536. }
  7537.  
  7538. if (data == "tezt") {
  7539. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7540. }
  7541. if (data == "yeswearesyncer") {
  7542. // let delay = Date.now() - wsDelay;
  7543. withSync = true;
  7544. if (player) {
  7545. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7546. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7547. }
  7548. }
  7549. };
  7550.  
  7551. // SHOW ALLIANCE MENU:
  7552. function allianceNotification(sid, name) {
  7553. let findBotSID = findSID(bots, sid);
  7554. if (findBotSID) {}
  7555. }
  7556.  
  7557. function setPlayerTeam(team, isOwner) {
  7558. if (player) {
  7559. player.team = team;
  7560. player.isOwner = isOwner;
  7561. if (team == null)
  7562. alliancePlayers = [];
  7563. }
  7564. }
  7565.  
  7566. function setAlliancePlayers(data) {
  7567. alliancePlayers = data;
  7568. }
  7569.  
  7570. // STORE MENU:
  7571. function updateStoreItems(type, id, index) {
  7572. if (index) {
  7573. if (!type)
  7574. player.tails[id] = 1;
  7575. else {
  7576. player.latestTail = id;
  7577. }
  7578. } else {
  7579. if (!type)
  7580. player.skins[id] = 1,
  7581. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7582. else {
  7583. player.latestSkin = id;
  7584. }
  7585. }
  7586. }
  7587.  
  7588. // SEND MESSAGE:
  7589. function receiveChat(sid, message) {
  7590. let kawaii = false;
  7591. let tmpPlayer = findPlayerBySID(sid);
  7592. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7593. tmpPlayer.chatMessage = message;
  7594. tmpPlayer.chatCountdown = config.chatCountdown;
  7595. }
  7596.  
  7597. // MINIMAP:
  7598. function updateMinimap(data) {
  7599. minimapData = data;
  7600. }
  7601.  
  7602. // SHOW ANIM TEXT:
  7603. function showText(x, y, value, type) {
  7604. // if (config.anotherVisual) {
  7605. textManager.stack.push({
  7606. x: x,
  7607. y: y,
  7608. value: value
  7609. });
  7610. // } else {
  7611. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7612. // }
  7613. }
  7614.  
  7615. /** APPLY SOCKET CODES */
  7616.  
  7617. // BOT:
  7618. let bots = [];
  7619. let ranLocation = {
  7620. x: UTILS.randInt(35, 14365),
  7621. y: UTILS.randInt(35, 14365)
  7622. };
  7623. setInterval(() => {
  7624. ranLocation = {
  7625. x: UTILS.randInt(35, 14365),
  7626. y: UTILS.randInt(35, 14365)
  7627. };
  7628. }, 60000);
  7629. class Bot {
  7630. constructor(id, sid, hats, accessories) {
  7631. this.millPlace = true;
  7632. this.id = id;
  7633. this.sid = sid;
  7634. this.team = null;
  7635. this.skinIndex = 0;
  7636. this.tailIndex = 0;
  7637. this.hitTime = 0;
  7638. this.iconIndex = 0;
  7639. this.enemy = [];
  7640. this.near = [];
  7641. this.dist2 = 0;
  7642. this.aim2 = 0;
  7643. this.tick = 0;
  7644. this.itemCounts = {};
  7645. this.latestSkin = 0;
  7646. this.latestTail = 0;
  7647. this.points = 0;
  7648. this.tails = {};
  7649. for (let i = 0; i < accessories.length; ++i) {
  7650. if (accessories[i].price <= 0)
  7651. this.tails[accessories[i].id] = 1;
  7652. }
  7653. this.skins = {};
  7654. for (let i = 0; i < hats.length; ++i) {
  7655. if (hats[i].price <= 0)
  7656. this.skins[hats[i].id] = 1;
  7657. }
  7658. this.spawn = function(moofoll) {
  7659. this.upgraded = 0;
  7660. this.enemy = [];
  7661. this.near = [];
  7662. this.active = true;
  7663. this.alive = true;
  7664. this.lockMove = false;
  7665. this.lockDir = false;
  7666. this.minimapCounter = 0;
  7667. this.chatCountdown = 0;
  7668. this.shameCount = 0;
  7669. this.shameTimer = 0;
  7670. this.sentTo = {};
  7671. this.gathering = 0;
  7672. this.autoGather = 0;
  7673. this.animTime = 0;
  7674. this.animSpeed = 0;
  7675. this.mouseState = 0;
  7676. this.buildIndex = -1;
  7677. this.weaponIndex = 0;
  7678. this.dmgOverTime = {};
  7679. this.noMovTimer = 0;
  7680. this.maxXP = 300;
  7681. this.XP = 0;
  7682. this.age = 1;
  7683. this.kills = 0;
  7684. this.upgrAge = 2;
  7685. this.upgradePoints = 0;
  7686. this.x = 0;
  7687. this.y = 0;
  7688. this.zIndex = 0;
  7689. this.xVel = 0;
  7690. this.yVel = 0;
  7691. this.slowMult = 1;
  7692. this.dir = 0;
  7693. this.nDir = 0;
  7694. this.dirPlus = 0;
  7695. this.targetDir = 0;
  7696. this.targetAngle = 0;
  7697. this.maxHealth = 100;
  7698. this.health = this.maxHealth;
  7699. this.oldHealth = this.maxHealth;
  7700. this.scale = config.playerScale;
  7701. this.speed = config.playerSpeed;
  7702. this.resetMoveDir();
  7703. this.resetResources(moofoll);
  7704. this.items = [0, 3, 6, 10];
  7705. this.weapons = [0];
  7706. this.shootCount = 0;
  7707. this.weaponXP = [];
  7708. this.isBot = false;
  7709. this.reloads = {
  7710. 0: 0,
  7711. 1: 0,
  7712. 2: 0,
  7713. 3: 0,
  7714. 4: 0,
  7715. 5: 0,
  7716. 6: 0,
  7717. 7: 0,
  7718. 8: 0,
  7719. 9: 0,
  7720. 10: 0,
  7721. 11: 0,
  7722. 12: 0,
  7723. 13: 0,
  7724. 14: 0,
  7725. 15: 0,
  7726. 53: 0,
  7727. };
  7728. this.timeZinceZpawn = 0;
  7729. this.whyDie = "";
  7730. this.clearRadius = false;
  7731. this.circlee = 0;
  7732. };
  7733.  
  7734. // RESET MOVE DIR:
  7735. this.resetMoveDir = function() {
  7736. this.moveDir = undefined;
  7737. };
  7738.  
  7739. // RESET RESOURCES:
  7740. this.resetResources = function(moofoll) {
  7741. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7742. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7743. }
  7744. };
  7745.  
  7746. // SET DATA:
  7747. this.setData = function(data) {
  7748. this.id = data[0];
  7749. this.sid = data[1];
  7750. this.name = data[2];
  7751. this.x = data[3];
  7752. this.y = data[4];
  7753. this.dir = data[5];
  7754. this.health = data[6];
  7755. this.maxHealth = data[7];
  7756. this.scale = data[8];
  7757. this.skinColor = data[9];
  7758. };
  7759.  
  7760.  
  7761. // SHAME SYSTEM:
  7762. this.judgeShame = function() {
  7763. if (this.oldHealth < this.health) {
  7764. if (this.hitTime) {
  7765. let timeSinceHit = this.tick - this.hitTime;
  7766. this.hitTime = 0;
  7767. if (timeSinceHit < 2) {
  7768. this.lastshamecount = this.shameCount;
  7769. this.shameCount++;
  7770. } else {
  7771. this.lastshamecount = this.shameCount;
  7772. this.shameCount = Math.max(0, this.shameCount - 2);
  7773. }
  7774. }
  7775. } else if (this.oldHealth > this.health) {
  7776. this.hitTime = this.tick;
  7777. }
  7778. };
  7779.  
  7780. // UPDATE WEAPON RELOAD:
  7781. this.manageReloadaa = function() {
  7782. if (this.shooting[53]) {
  7783. this.shooting[53] = 0;
  7784. this.reloads[53] = (2500 - 1000/9);
  7785. } else {
  7786. if (this.reloads[53] > 0) {
  7787. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7788. }
  7789. }
  7790. if (this.gathering || this.shooting[1]) {
  7791. if (this.gathering) {
  7792. this.gathering = 0;
  7793. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7794. this.attacked = true;
  7795. }
  7796. if (this.shooting[1]) {
  7797. this.shooting[1] = 0;
  7798. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7799. this.attacked = true;
  7800. }
  7801. } else {
  7802. this.attacked = false;
  7803. if (this.buildIndex < 0) {
  7804. if (this.reloads[this.weaponIndex] > 0) {
  7805. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7806. }
  7807. }
  7808. }
  7809. };
  7810.  
  7811. this.closeSockets = function(websc) {
  7812. websc.close();
  7813. };
  7814.  
  7815. this.whyDieChat = function(websc, whydie) {
  7816. websc.sendWS("6", "why die XDDD " + whydie);
  7817. };
  7818. }
  7819. };
  7820.  
  7821. class BotObject {
  7822. constructor(sid) {
  7823. this.sid = sid;
  7824. // INIT:
  7825. this.init = function(x, y, dir, scale, type, data, owner) {
  7826. data = data || {};
  7827. this.active = true;
  7828. this.x = x;
  7829. this.y = y;
  7830. this.scale = scale;
  7831. this.owner = owner;
  7832. this.id = data.id;
  7833. this.dmg = data.dmg;
  7834. this.trap = data.trap;
  7835. this.teleport = data.teleport;
  7836. this.isItem = this.id != undefined;
  7837. };
  7838.  
  7839. }
  7840. };
  7841. class BotObjManager {
  7842. constructor(botObj, fOS) {
  7843. // DISABLE OBJ:
  7844. this.disableObj = function(obj) {
  7845. obj.active = false;
  7846. if (config.anotherVisual) {} else {
  7847. obj.alive = false;
  7848. }
  7849. };
  7850.  
  7851. // ADD NEW:
  7852. let tmpObj;
  7853. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7854. tmpObj = fOS(sid);
  7855. if (!tmpObj) {
  7856. tmpObj = botObj.find((tmp) => !tmp.active);
  7857. if (!tmpObj) {
  7858. tmpObj = new BotObject(sid);
  7859. botObj.push(tmpObj);
  7860. }
  7861. }
  7862. if (setSID) {
  7863. tmpObj.sid = sid;
  7864. }
  7865. tmpObj.init(x, y, dir, s, type, data, owner);
  7866. };
  7867.  
  7868. // DISABLE BY SID:
  7869. this.disableBySid = function(sid) {
  7870. let find = fOS(sid);
  7871. if (find) {
  7872. this.disableObj(find);
  7873. }
  7874. };
  7875.  
  7876. // REMOVE ALL FROM PLAYER:
  7877. this.removeAllItems = function(sid, server) {
  7878. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7879. };
  7880. }
  7881. };
  7882.  
  7883. let botz = [];
  7884.  
  7885. function botSpawn(id) {
  7886. let bot;
  7887. console.log(WS);
  7888. let t = WS.url.split("wss://")[1].split("?")[0];
  7889. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7890. let botPlayer = new Map();
  7891. botSkts.push([botPlayer]);
  7892. botz.push([bot]);
  7893. let botSID;
  7894. let botObj = [];
  7895. let nearObj = [];
  7896. let bD = {
  7897. x: 0,
  7898. y: 0,
  7899. inGame: false,
  7900. closeSocket: false,
  7901. whyDie: ""
  7902. };
  7903. let oldXY = {
  7904. x: 0,
  7905. y: 0,
  7906. };
  7907. let izauto = 0;
  7908. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7909. bot.binaryType = "arraybuffer";
  7910. bot.first = true;
  7911. bot.sendWS = function(type) {
  7912. // EXTRACT DATA ARRAY:
  7913. let data = Array.prototype.slice.call(arguments, 1);
  7914. // SEND MESSAGE:
  7915. let binary = window.msgpack.encode([type, data]);
  7916. bot.send(binary);
  7917. };
  7918. bot.spawn = function() {
  7919. bot.sendWS("M", {
  7920. name: "unknown1l",
  7921. moofoll: 1,
  7922. skin: "__proto__"
  7923. });
  7924. };
  7925. bot.sendUpgrade = function(index) {
  7926. bot.sendWS("H", index);
  7927. };
  7928. bot.place = function(id, a) {
  7929. try {
  7930. let item = items.list[botPlayer.items[id]];
  7931. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7932. bot.sendWS("G", botPlayer.items[id]);
  7933. bot.sendWS("d", 1, a);
  7934. bot.sendWS("G", botPlayer.weaponIndex, true);
  7935. }
  7936. } catch (e) {
  7937. }
  7938. };
  7939. bot.buye = function(id, index) {
  7940. let nID = 0;
  7941. if (botPlayer.alive && botPlayer.inGame) {
  7942. if (index == 0) {
  7943. if (botPlayer.skins[id]) {
  7944. if (botPlayer.latestSkin != id) {
  7945. bot.sendWS("c", 0, id, 0);
  7946. }
  7947. } else {
  7948. let find = findID(hats, id);
  7949. if (find) {
  7950. if (botPlayer.points >= find.price) {
  7951. bot.sendWS("c", 1, id, 0);
  7952. bot.sendWS("c", 0, id, 0);
  7953. } else {
  7954. if (botPlayer.latestSkin != nID) {
  7955. bot.sendWS("c", 0, nID, 0);
  7956. }
  7957. }
  7958. } else {
  7959. if (botPlayer.latestSkin != nID) {
  7960. bot.sendWS("c", 0, nID, 0);
  7961. }
  7962. }
  7963. }
  7964. } else if (index == 1) {
  7965. if (botPlayer.tails[id]) {
  7966. if (botPlayer.latestTail != id) {
  7967. bot.sendWS("c", 0, id, 1);
  7968. }
  7969. } else {
  7970. let find = findID(accessories, id);
  7971. if (find) {
  7972. if (botPlayer.points >= find.price) {
  7973. bot.sendWS("c", 1, id, 1);
  7974. bot.sendWS("c", 0, id, 1);
  7975. } else {
  7976. if (botPlayer.latestTail != 0) {
  7977. bot.sendWS("c", 0, 0, 1);
  7978. }
  7979. }
  7980. } else {
  7981. if (botPlayer.latestTail != 0) {
  7982. bot.sendWS("c", 0, 0, 1);
  7983. }
  7984. }
  7985. }
  7986. }
  7987. }
  7988. };
  7989. bot.fastGear = function () {
  7990. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7991. bot.buye(31, 0);
  7992. } else {
  7993. if (botPlayer.moveDir == undefined) {
  7994. bot.buye(22, 0);
  7995. } else {
  7996. if (botPlayer.y2 <= config.snowBiomeTop) {
  7997. bot.buye(15, 0);
  7998. } else {
  7999. bot.buye(12, 0);
  8000. }
  8001. }
  8002. }
  8003. };
  8004. bot.selectWeapon = function(a) {
  8005. packet("G", a, 1);
  8006. }
  8007. function caf(e, t) {
  8008. try {
  8009. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8010. } catch (e) {
  8011. return 0;
  8012. }
  8013. }
  8014. bot.heal = function() {
  8015. if (botPlayer.health < 100) {
  8016. bot.place(0, 0)
  8017. }
  8018. }
  8019. function cdf (e, t){
  8020. try {
  8021. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8022. } catch(e){
  8023. return Infinity;
  8024. }
  8025. }
  8026. let zoon = 'no';
  8027. bot.zync = function(a) {
  8028. if (!botPlayer.millPlace) {
  8029. zoon = 'yeah';
  8030. bot.place(5, caf(botPlayer, a));
  8031. let NextTickLocation = {
  8032. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8033. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8034. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8035. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8036. };
  8037.  
  8038. function calculateDistance(x1, y1, x2, y2) {
  8039. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8040. return distance;
  8041. }
  8042. function dotherezt() {
  8043. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8044. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8045. }
  8046.  
  8047. let aa = setInterval(() => {
  8048. bot.sendWS("G", botPlayer.weapons[1], true);
  8049. if (izauto == 0) {
  8050. bot.sendWS("K", 1);
  8051. izauto = 1;
  8052. }
  8053. setTimeout(() => {
  8054. bot.sendWS("G", botPlayer.weapons[0], true);
  8055. }, 2000);
  8056. bot.buye(53, 0);
  8057. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  8058. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  8059. } else {
  8060. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8061. zoon = 'no';
  8062. bot.sendWS("a", undefined);
  8063. dotherezt();
  8064. clearInterval(aa);
  8065. }
  8066. }, 150);
  8067.  
  8068. setTimeout(() => {
  8069. zoon = 'no';
  8070. clearInterval(aa);
  8071. }, 500);
  8072. }
  8073. };
  8074. bot.onmessage = function(message) {
  8075. let data = new Uint8Array(message.data);
  8076. let parsed = window.msgpack.decode(data);
  8077. let type = parsed[0];
  8078. data = parsed[1];
  8079. if (type == "io-init") {
  8080. bot.spawn();
  8081. }
  8082. if (type == "1") {
  8083. botSID = data[0];
  8084. console.log(botSID)
  8085. }
  8086. if (type == "D") {
  8087. if (data[1]) {
  8088. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8089. botPlayer.setData(data[0]);
  8090. botPlayer.inGame = true;
  8091. botPlayer.alive = true;
  8092. botPlayer.x2 = undefined;
  8093. botPlayer.y2 = undefined;
  8094. botPlayer.spawn(1);
  8095. botPlayer.oldHealth = 100;
  8096. botPlayer.health = 100;
  8097. botPlayer.showName = 'YEAHHH';
  8098. oldXY = {
  8099. x: data[0][3],
  8100. y: data[0][4]
  8101. }
  8102. bD.inGame = true;
  8103. if (bot.first) {
  8104. bot.first = false;
  8105. bots.push(bD);
  8106. }
  8107. }
  8108. }
  8109. if (type == "P") {
  8110. bot.spawn();
  8111. botPlayer.inGame = false;
  8112. bD.inGame = false;
  8113. }
  8114. if (type == "a") {
  8115. let tmpData = data[0];
  8116. botPlayer.tick++;
  8117. botPlayer.enemy = [];
  8118. botPlayer.near = [];
  8119. bot.showName = 'YEAHHH';
  8120. nearObj = [];
  8121. for (let i = 0; i < tmpData.length;) {
  8122. if (tmpData[i] == botPlayer.sid) {
  8123. botPlayer.x2 = tmpData[i + 1];
  8124. botPlayer.y2 = tmpData[i + 2];
  8125. botPlayer.d2 = tmpData[i + 3];
  8126. botPlayer.buildIndex = tmpData[i + 4];
  8127. botPlayer.weaponIndex = tmpData[i + 5];
  8128. botPlayer.weaponVariant = tmpData[i + 6];
  8129. botPlayer.team = tmpData[i + 7];
  8130. botPlayer.isLeader = tmpData[i + 8];
  8131. botPlayer.skinIndex = tmpData[i + 9];
  8132. botPlayer.tailIndex = tmpData[i + 10];
  8133. botPlayer.iconIndex = tmpData[i + 11];
  8134. botPlayer.zIndex = tmpData[i + 12];
  8135. botPlayer.visible = true;
  8136. bD.x2 = botPlayer.x2;
  8137. bD.y2 = botPlayer.y2;
  8138. }
  8139. i += 13;
  8140. }
  8141.  
  8142. for (let i = 0; i < tmpData.length;) {
  8143. tmpObj = findPlayerBySID(tmpData[i]);
  8144. if (tmpObj) {
  8145. if (!tmpObj.isTeam(botPlayer)) {
  8146. enemy.push(tmpObj);
  8147. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8148. nears.push(tmpObj);
  8149. }
  8150. }
  8151. }
  8152. i += 13;
  8153. }
  8154.  
  8155. if (enemy.length) {
  8156. //console.log(enemy)
  8157. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8158. return tmp1.dist2 - tmp2.dist2;
  8159. })[0];
  8160. }
  8161.  
  8162. if (izauto == 1) {
  8163. bot.sendWS("K", 1);
  8164. izauto = 0;
  8165. }
  8166.  
  8167. if (bD.closeSocket) {
  8168. botPlayer.closeSockets(bot);
  8169. }
  8170. if (bD.whyDie != "") {
  8171. botPlayer.whyDieChat(bot, bD.whyDie);
  8172. bD.whyDie = "";
  8173. }
  8174. if (botPlayer.alive) {
  8175. if (player.team) {
  8176. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8177. botPlayer.team && (bot.sendWS("N"));
  8178. bot.sendWS("b", player.team);
  8179. }
  8180. }
  8181.  
  8182. let item = items.list[botPlayer.items[3]];
  8183. let a = botPlayer.itemCounts[item.group.id]
  8184. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8185. if (botPlayer.inGame) {
  8186. bot.sendWS("D", botPlayer.moveDir);
  8187. if (izauto == 0) {
  8188. bot.sendWS("K", 1);
  8189. izauto = 1;
  8190. }
  8191. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8192. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8193. bot.place(3, aim + 7.7);
  8194. bot.place(3, aim - 7.7);
  8195. bot.place(3, aim);
  8196. oldXY = {
  8197. x: botPlayer.x2,
  8198. y: botPlayer.y2
  8199. };
  8200. }
  8201.  
  8202. if (botPlayer.tick % 90 === 0) {
  8203. let rand = Math.random() * Math.PI * 2;
  8204. botPlayer.moveDir = rand;
  8205. bot.sendWS("a", botPlayer.moveDir);
  8206. }
  8207. }
  8208. bot.fastGear();
  8209. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  8210. botPlayer.millPlace = false;
  8211. // bot.sendWS("K", 1);
  8212. bot.fastGear();
  8213. } else {
  8214. if (botPlayer.inGame) {
  8215. if (botObj.length > 0) {
  8216. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8217. if (getEl("mode").value == 'fuckemup') {
  8218. // if (getEl("mode").value == "clear") {
  8219. bot.selectWeapon(botPlayer.weapons[1]);
  8220. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8221. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8222. 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) {
  8223. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8224. })[0];
  8225. if (nearObj) {
  8226. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8227. if ((gotoDist - isPassed) > 0) {
  8228. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8229. if (botPlayer.moveDir != undefined) {
  8230. botPlayer.moveDir = undefined;
  8231. bot.sendWS("a", botPlayer.moveDir);
  8232. bot.sendWS("D", botPlayer.nDir);
  8233. }
  8234. } else {
  8235. botPlayer.moveDir = gotoAim;
  8236. bot.sendWS("a", botPlayer.moveDir);
  8237. bot.sendWS("D", botPlayer.nDir);
  8238. }
  8239. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8240. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8241. bot.sendWS("D", botPlayer.nDir);
  8242. }
  8243. if (izauto == 0) {
  8244. bot.sendWS("K", 1);
  8245. izauto = 1;
  8246. }
  8247. bot.buye(40, 0);
  8248. } else {
  8249. botPlayer.moveDir = gotoAim;
  8250. bot.sendWS("a", botPlayer.moveDir);
  8251. bot.sendWS("D", botPlayer.nDir);
  8252. bot.fastGear();
  8253. }
  8254. } else {
  8255. botPlayer.moveDir = gotoAim;
  8256. bot.sendWS("a", botPlayer.moveDir);
  8257. bot.sendWS("D", botPlayer.nDir);
  8258. bot.fastGear();
  8259. }
  8260. }
  8261. }
  8262.  
  8263.  
  8264.  
  8265. if (botObj.length > 0) {
  8266. if (getEl("mode").value == 'flex') {
  8267. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  8268. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  8269. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  8270.  
  8271. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  8272.  
  8273. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  8274. if (dist > 22) // 22 is player speed without booster hat
  8275. return;
  8276. }
  8277. }
  8278.  
  8279.  
  8280. if (botObj.length > 0) {
  8281. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8282. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8283. })[0];
  8284.  
  8285. if (nearObj) {
  8286. if (izauto == 0) {
  8287. bot.sendWS("K", 1);
  8288. izauto = 1;
  8289. }
  8290. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8291. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8292. bot.sendWS("D", botPlayer.nDir);
  8293. }
  8294. bot.buye(40, 0);
  8295. bot.buye(11, 1);
  8296. } else {
  8297. bot.fastGear();
  8298. bot.buye(11, 1);
  8299. }
  8300. bot.buye(11, 1);
  8301. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8302. // if (getEl("mode").value == "clear") {
  8303. bot.selectWeapon(botPlayer.weapons[1]);
  8304. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8305. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8306. 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) {
  8307. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8308. })[0];
  8309. if (nearObj) {
  8310. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8311. if ((gotoDist - isPassed) > 0) {
  8312. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8313. if (botPlayer.moveDir != undefined) {
  8314. botPlayer.moveDir = undefined;
  8315. bot.sendWS("a", botPlayer.moveDir);
  8316. bot.sendWS("D", botPlayer.nDir);
  8317. }
  8318. } else {
  8319. botPlayer.moveDir = gotoAim;
  8320. bot.sendWS("a", botPlayer.moveDir);
  8321. bot.sendWS("D", botPlayer.nDir);
  8322. }
  8323. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8324. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8325. bot.sendWS("D", botPlayer.nDir);
  8326. }
  8327. if (izauto == 0) {
  8328. bot.sendWS("K", 1);
  8329. izauto = 1;
  8330. }
  8331. bot.buye(40, 0);
  8332. bot.fastGear();
  8333. } else {
  8334. botPlayer.moveDir = gotoAim;
  8335. bot.sendWS("a", botPlayer.moveDir);
  8336. bot.sendWS("D", botPlayer.nDir);
  8337. bot.fastGear();
  8338. }
  8339. } else {
  8340. botPlayer.moveDir = gotoAim;
  8341. bot.sendWS("a", botPlayer.moveDir);
  8342. bot.sendWS("D", botPlayer.nDir);
  8343. bot.fastGear();
  8344. }
  8345. if (gotoDist > 300) {
  8346. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8347. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8348. bot.place(3, aim + 7.7);
  8349. bot.place(3, aim - 7.7);
  8350. bot.place(3, aim);
  8351. oldXY = {
  8352. x: botPlayer.x2,
  8353. y: botPlayer.y2
  8354. };
  8355. }
  8356. }
  8357. }
  8358. }
  8359.  
  8360. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8361. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  8362.  
  8363. if(!wdaawdwad.length) {
  8364. if(zoon == 'no')
  8365. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8366. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8367. }
  8368.  
  8369. if(wdaawdwad.length) {
  8370. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8371. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8372. 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) {
  8373. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8374. })[0];
  8375. if (nearObj) {
  8376. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8377. if ((gotoDist - isPassed) > 0) {
  8378. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8379. if (botPlayer.moveDir != undefined) {
  8380. botPlayer.moveDir = undefined;
  8381. bot.sendWS("a", botPlayer.moveDir);
  8382. bot.sendWS("D", botPlayer.nDir);
  8383. }
  8384. } else {
  8385. bot.sendWS("D", botPlayer.nDir);
  8386. }
  8387. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8388. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8389. bot.sendWS("D", botPlayer.nDir);
  8390. }
  8391. if (izauto == 0) {
  8392. bot.sendWS("K", 1);
  8393. izauto = 1;
  8394. }
  8395. bot.buye(40, 0);
  8396. bot.fastGear();
  8397. } else {
  8398. if(zoon == 'no')
  8399. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8400. if(cdf(player, botPlayer) <= 110)
  8401. bot.sendWS("a", undefined);
  8402. else
  8403. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8404. }
  8405. } else {
  8406. if(wdaawdwad.length) {
  8407. if(zoon == 'no')
  8408. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  8409. if(cdf(player, botPlayer) <= 110)
  8410. bot.sendWS("a", undefined);
  8411. else
  8412. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8413. } else {
  8414. if(zoon == 'no')
  8415. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8416. if(cdf(player, botPlayer) <= 110)
  8417. bot.sendWS("a", undefined);
  8418. else
  8419. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8420. }
  8421. }
  8422. }
  8423. }
  8424. }
  8425. }
  8426. }
  8427. }
  8428. if (type == "H") {
  8429. let tmpData = data[0];
  8430. for (let i = 0; i < tmpData.length;) {
  8431. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8432. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8433. sid: tmpData[i + 7]
  8434. } : null));
  8435. i += 8;
  8436. }
  8437. }
  8438. if (type == "N") {
  8439. let index = data[0];
  8440. let value = data[1];
  8441. if (botPlayer) {
  8442. botPlayer[index] = value;
  8443. }
  8444. }
  8445. if (type == "O") {
  8446. if (data[0] == botPlayer.sid) {
  8447. botPlayer.oldHealth = botPlayer.health;
  8448. botPlayer.health = data[1];
  8449. botPlayer.judgeShame();
  8450. if (botPlayer.oldHealth > botPlayer.health) {
  8451. if (botPlayer.shameCount < 5) {
  8452. for (let i = 0; i < 2; i++) {
  8453. bot.place(0, botPlayer.nDir);
  8454. }
  8455.  
  8456. } else {
  8457. setTimeout(() => {
  8458. for (let i = 0; i < 2; i++) {
  8459. bot.place(0, botPlayer.nDir);
  8460. }
  8461. }, 95);
  8462. }
  8463. }
  8464. }
  8465. }
  8466. if (type == "Q") {
  8467. let sid = data[0];
  8468. botObjManager.disableBySid(sid);
  8469. }
  8470. if (type == "R") {
  8471. let sid = data[0];
  8472. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8473. }
  8474. if (type == "S") {
  8475. let index = data[0];
  8476. let value = data[1];
  8477. if (botPlayer) {
  8478. botPlayer.itemCounts[index] = value;
  8479. }
  8480. }
  8481. if (type == "U") {
  8482. if (data[0] > 0) {
  8483. if(getEl("setup").value == 'dm') {
  8484. if (botPlayer.upgraded == 0) {
  8485. bot.sendUpgrade(7);
  8486. } else if (botPlayer.upgraded == 1) {
  8487. bot.sendUpgrade(17);
  8488. } else if (botPlayer.upgraded == 2) {
  8489. bot.sendUpgrade(31);
  8490. } else if (botPlayer.upgraded == 3) {
  8491. bot.sendUpgrade(23);
  8492. } else if (botPlayer.upgraded == 4) {
  8493. bot.sendUpgrade(9);
  8494. } else if (botPlayer.upgraded == 5) {
  8495. bot.sendUpgrade(34);
  8496. } else if (botPlayer.upgraded == 6) {
  8497. bot.sendUpgrade(12);
  8498. } else if (botPlayer.upgraded == 7) {
  8499. bot.sendUpgrade(15);
  8500. }
  8501. } else if(getEl("setup").value == 'dr') {
  8502. if (botPlayer.upgraded == 0) {
  8503. bot.sendUpgrade(7);
  8504. } else if (botPlayer.upgraded == 1) {
  8505. bot.sendUpgrade(17);
  8506. } else if (botPlayer.upgraded == 2) {
  8507. bot.sendUpgrade(31);
  8508. } else if (botPlayer.upgraded == 3) {
  8509. bot.sendUpgrade(23);
  8510. } else if (botPlayer.upgraded == 4) {
  8511. bot.sendUpgrade(9);
  8512. } else if (botPlayer.upgraded == 5) {
  8513. bot.sendUpgrade(34);
  8514. } else if (botPlayer.upgraded == 6) {
  8515. bot.sendUpgrade(12);
  8516. } else if (botPlayer.upgraded == 7) {
  8517. bot.sendUpgrade(13);
  8518. }
  8519. } else if(getEl("setup").value == 'kh') {
  8520. if (botPlayer.upgraded == 0) {
  8521. bot.sendUpgrade(3);
  8522. } else if (botPlayer.upgraded == 1) {
  8523. bot.sendUpgrade(17);
  8524. } else if (botPlayer.upgraded == 2) {
  8525. bot.sendUpgrade(31);
  8526. } else if (botPlayer.upgraded == 3) {
  8527. bot.sendUpgrade(27);
  8528. } else if (botPlayer.upgraded == 4) {
  8529. bot.sendUpgrade(10);
  8530. } else if (botPlayer.upgraded == 5) {
  8531. bot.sendUpgrade(34);
  8532. } else if (botPlayer.upgraded == 6) {
  8533. bot.sendUpgrade(4);
  8534. } else if (botPlayer.upgraded == 7) {
  8535. bot.sendUpgrade(25);
  8536. }
  8537. } else if(getEl("setup").value == 'zd') {
  8538. if (botPlayer.upgraded == 0) {
  8539. bot.sendUpgrade(3);
  8540. } else if (botPlayer.upgraded == 1) {
  8541. bot.sendUpgrade(17);
  8542. } else if (botPlayer.upgraded == 2) {
  8543. bot.sendUpgrade(31);
  8544. } else if (botPlayer.upgraded == 3) {
  8545. bot.sendUpgrade(27);
  8546. } else if (botPlayer.upgraded == 4) {
  8547. bot.sendUpgrade(9);
  8548. } else if (botPlayer.upgraded == 5) {
  8549. bot.sendUpgrade(34);
  8550. } else if (botPlayer.upgraded == 6) {
  8551. bot.sendUpgrade(12);
  8552. } else if (botPlayer.upgraded == 7) {
  8553. bot.sendUpgrade(15);
  8554. }
  8555. }
  8556. botPlayer.upgraded++;
  8557. }
  8558. }
  8559. if (type == "V") {
  8560. let tmpData = data[0];
  8561. let wpn = data[1];
  8562. if (tmpData) {
  8563. if (wpn) botPlayer.weapons = tmpData;
  8564. else botPlayer.items = tmpData;
  8565. }
  8566.  
  8567. }
  8568. if (type == "5") {
  8569. let type = data[0];
  8570. let id = data[1];
  8571. let index = data[2];
  8572. if (index) {
  8573. if (!type)
  8574. botPlayer.tails[id] = 1;
  8575. else
  8576. botPlayer.latestTail = id;
  8577. } else {
  8578. if (!type)
  8579. botPlayer.skins[id] = 1;
  8580. else
  8581. botPlayer.latestSkin = id;
  8582. }
  8583. }
  8584.  
  8585. if (type == "6") {
  8586. let id = data[0];
  8587. let mzg = data[1]+'';
  8588. if(id == player.sid && mzg.includes("syncon")) {
  8589. bot.zync(botPlayer.near);
  8590. }
  8591. }
  8592. };
  8593. bot.onclose = function() {
  8594. botPlayer.inGame = false;
  8595. bD.inGame = false;
  8596. };
  8597. }
  8598.  
  8599. // RENDER LEAF:
  8600. function renderLeaf(x, y, l, r, ctxt) {
  8601. let endX = x + (l * Math.cos(r));
  8602. let endY = y + (l * Math.sin(r));
  8603. let width = l * 0.4;
  8604. ctxt.moveTo(x, y);
  8605. ctxt.beginPath();
  8606. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8607. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8608. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8609. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8610. ctxt.closePath();
  8611. ctxt.fill();
  8612. ctxt.stroke();
  8613. }
  8614.  
  8615. // RENDER CIRCLE:
  8616. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8617. tmpContext = tmpContext || mainContext;
  8618. tmpContext.beginPath();
  8619. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8620. if (!dontFill) tmpContext.fill();
  8621. if (!dontStroke) tmpContext.stroke();
  8622. }
  8623.  
  8624. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8625. tmpContext = tmpContext || mainContext;
  8626. tmpContext.beginPath();
  8627. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8628. if (!dontFill) tmpContext.fill();
  8629. if (!dontStroke) tmpContext.stroke();
  8630. }
  8631.  
  8632. // RENDER STAR SHAPE:
  8633. function renderStar(ctxt, spikes, outer, inner) {
  8634. let rot = Math.PI / 2 * 3;
  8635. let x, y;
  8636. let step = Math.PI / spikes;
  8637. ctxt.beginPath();
  8638. ctxt.moveTo(0, -outer);
  8639. for (let i = 0; i < spikes; i++) {
  8640. x = Math.cos(rot) * outer;
  8641. y = Math.sin(rot) * outer;
  8642. ctxt.lineTo(x, y);
  8643. rot += step;
  8644. x = Math.cos(rot) * inner;
  8645. y = Math.sin(rot) * inner;
  8646. ctxt.lineTo(x, y);
  8647. rot += step;
  8648. }
  8649. ctxt.lineTo(0, -outer);
  8650. ctxt.closePath();
  8651. }
  8652.  
  8653. function renderHealthStar(ctxt, spikes, outer, inner) {
  8654. let rot = Math.PI / 2 * 3;
  8655. let x, y;
  8656. let step = Math.PI / spikes;
  8657. ctxt.beginPath();
  8658. ctxt.moveTo(0, -outer);
  8659. for (let i = 0; i < spikes; i++) {
  8660. x = Math.cos(rot) * outer;
  8661. y = Math.sin(rot) * outer;
  8662. ctxt.lineTo(x, y);
  8663. rot += step;
  8664. x = Math.cos(rot) * inner;
  8665. y = Math.sin(rot) * inner;
  8666. ctxt.lineTo(x, y);
  8667. rot += step;
  8668. }
  8669. ctxt.lineTo(0, -outer);
  8670. ctxt.closePath();
  8671. }
  8672.  
  8673. // RENDER RECTANGLE:
  8674. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8675. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8676. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8677. }
  8678.  
  8679. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8680. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8681. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8682. }
  8683.  
  8684. // RENDER RECTCIRCLE:
  8685. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8686. ctxt.save();
  8687. ctxt.translate(x, y);
  8688. seg = Math.ceil(seg / 2);
  8689. for (let i = 0; i < seg; i++) {
  8690. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8691. ctxt.rotate(Math.PI / seg);
  8692. }
  8693. ctxt.restore();
  8694. }
  8695.  
  8696. // RENDER BLOB:
  8697. function renderBlob(ctxt, spikes, outer, inner) {
  8698. let rot = Math.PI / 2 * 3;
  8699. let x, y;
  8700. let step = Math.PI / spikes;
  8701. let tmpOuter;
  8702. ctxt.beginPath();
  8703. ctxt.moveTo(0, -inner);
  8704. for (let i = 0; i < spikes; i++) {
  8705. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8706. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8707. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8708. rot += step * 2;
  8709. }
  8710. ctxt.lineTo(0, -inner);
  8711. ctxt.closePath();
  8712. }
  8713.  
  8714. // RENDER TRIANGLE:
  8715. function renderTriangle(s, ctx) {
  8716. ctx = ctx || mainContext;
  8717. let h = s * (Math.sqrt(3) / 2);
  8718. ctx.beginPath();
  8719. ctx.moveTo(0, -h / 2);
  8720. ctx.lineTo(-s / 2, h / 2);
  8721. ctx.lineTo(s / 2, h / 2);
  8722. ctx.lineTo(0, -h / 2);
  8723. ctx.fill();
  8724. ctx.closePath();
  8725. }
  8726.  
  8727. // PREPARE MENU BACKGROUND:
  8728. function prepareMenuBackground() {
  8729. // let tmpMid = config.mapScale / 2;
  8730. // let attempts = 0;
  8731. // for (let i = 0; i < items.list.length * 3;) {
  8732. // if (attempts >= 1000) break;
  8733. // attempts++;
  8734. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8735. // let data = {
  8736. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  8737. // y: tmpMid + UTILS.randFloat(-600, 600),
  8738. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8739. // };
  8740. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8741. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8742. // } else {
  8743. // continue;
  8744. // }
  8745. // i++;
  8746. // }
  8747. }
  8748.  
  8749. const speed = 1;
  8750. // RENDER PLAYERS:
  8751. function renderDeadPlayers(xOffset, yOffset) {
  8752. mainContext.fillStyle = "#91b2db";
  8753. const currentTime = Date.now();
  8754. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8755. if (!dead.startTime) {
  8756. dead.startTime = currentTime;
  8757. dead.angle = 0;
  8758. dead.radius = 0.1;
  8759. }
  8760. const timeElapsed = currentTime - dead.startTime;
  8761. const maxAlpha = 1;
  8762. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8763. dead.animate(delta);
  8764. mainContext.globalAlpha = dead.alpha;
  8765. mainContext.strokeStyle = outlineColor;
  8766. mainContext.save();
  8767. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8768. dead.radius -= 0.001;
  8769. dead.angle += 0.0174533;
  8770. const moveSpeed = 1;
  8771. const x = dead.radius * Math.cos(dead.angle);
  8772. const y = dead.radius * Math.sin(dead.angle);
  8773. dead.x += x * moveSpeed;
  8774. dead.y += y * moveSpeed;
  8775. mainContext.rotate(dead.angle);
  8776. renderDeadPlayer(dead, mainContext);
  8777. mainContext.restore();
  8778. mainContext.fillStyle = "#91b2db";
  8779. if (timeElapsed >= 3000) {
  8780. dead.active = false;
  8781. dead.startTime = null;
  8782. }
  8783. });
  8784. }
  8785. // RENDER PLAYERS:
  8786. function renderPlayers(xOffset, yOffset, zIndex) {
  8787. mainContext.globalAlpha = 1;
  8788. mainContext.fillStyle = "#91b2db";
  8789. for (var i = 0; i < players.length; ++i) {
  8790. tmpObj = players[i];
  8791. if (tmpObj.zIndex == zIndex) {
  8792. tmpObj.animate(delta);
  8793. if (tmpObj.visible) {
  8794. tmpObj.skinRot += (0.002 * delta);
  8795. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  8796. mainContext.save();
  8797. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8798. // RENDER PLAYER:
  8799. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8800. renderPlayer(tmpObj, mainContext);
  8801. mainContext.restore();
  8802. }
  8803. }
  8804. }
  8805. }
  8806. // RENDER DEAD PLAYER:
  8807. function renderDeadPlayer(obj, ctxt) {
  8808. ctxt = ctxt || mainContext;
  8809. ctxt.lineWidth = outlineWidth;
  8810. ctxt.lineJoin = "miter";
  8811. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8812. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8813. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8814. // TAIL/CAPE:
  8815. renderTail2(13, ctxt, obj);
  8816. // WEAPON BELLOW HANDS:
  8817. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8818. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8819. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8820. renderProjectile(obj.scale, 0,
  8821. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8822. }
  8823. }
  8824. // HANDS:
  8825. ctxt.fillStyle = "#ececec";
  8826. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8827. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8828. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8829. // WEAPON ABOVE HANDS:
  8830. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8831. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8832. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8833. renderProjectile(obj.scale, 0,
  8834. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8835. }
  8836. }
  8837. // BUILD ITEM:
  8838. if (obj.buildIndex >= 0) {
  8839. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8840. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8841. }
  8842. // BODY:
  8843. renderCircle(0, 0, obj.scale, ctxt);
  8844. // SKIN
  8845. renderSkin2(48, ctxt, null, obj)
  8846. }
  8847.  
  8848. // RENDER PLAYER:
  8849. function renderPlayer(obj, ctxt) {
  8850. ctxt = ctxt || mainContext;
  8851. ctxt.lineWidth = outlineWidth;
  8852. ctxt.lineJoin = "miter";
  8853. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8854. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8855. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8856.  
  8857. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8858.  
  8859. // TAIL/CAPE:
  8860. if (obj.tailIndex > 0) {
  8861. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8862. }
  8863.  
  8864. // WEAPON BELLOW HANDS:
  8865. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8866. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8867. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8868. renderProjectile(obj.scale, 0,
  8869. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8870. }
  8871. }
  8872.  
  8873. // HANDS:
  8874. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8875. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8876. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8877. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8878.  
  8879. // WEAPON ABOVE HANDS:
  8880. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8881. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8882. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8883. renderProjectile(obj.scale, 0,
  8884. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8885. }
  8886. }
  8887.  
  8888. // BUILD ITEM:
  8889. if (obj.buildIndex >= 0) {
  8890. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8891. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8892. }
  8893.  
  8894. // BODY:
  8895. renderCircle(0, 0, obj.scale, ctxt);
  8896.  
  8897. // SKIN:
  8898. if (obj.skinIndex > 0) {
  8899. ctxt.rotate(Math.PI / 2);
  8900. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8901. }
  8902.  
  8903. }
  8904.  
  8905. // RENDER NORMAL SKIN
  8906. var skinSprites2 = {};
  8907. var skinPointers2 = {};
  8908. function renderSkin2(index, ctxt, parentSkin, owner) {
  8909. tmpSkin = skinSprites2[index];
  8910. if (!tmpSkin) {
  8911. var tmpImage = new Image();
  8912. tmpImage.onload = function() {
  8913. this.isLoaded = true;
  8914. this.onload = null;
  8915. };
  8916. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8917. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8918. skinSprites2[index] = tmpImage;
  8919. tmpSkin = tmpImage;
  8920. }
  8921. var tmpObj = parentSkin||skinPointers2[index];
  8922. if (!tmpObj) {
  8923. for (var i = 0; i < hats.length; ++i) {
  8924. if (hats[i].id == index) {
  8925. tmpObj = hats[i];
  8926. break;
  8927. }
  8928. }
  8929. skinPointers2[index] = tmpObj;
  8930. }
  8931. if (tmpSkin.isLoaded)
  8932. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8933. if (!parentSkin && tmpObj.topSprite) {
  8934. ctxt.save();
  8935. ctxt.rotate(owner.skinRot);
  8936. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8937. ctxt.restore();
  8938. }
  8939. }
  8940.  
  8941. // RENDER SKIN:
  8942. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8943. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8944. var tmpImage = new Image();
  8945. tmpImage.onload = function() {
  8946. this.isLoaded = true,
  8947. this.onload = null
  8948. }
  8949. ,
  8950. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8951. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8952. tmpSkin = tmpImage
  8953. }
  8954. var tmpObj = parentSkin||skinPointers[index];
  8955. if (!tmpObj) {
  8956. for (var i = 0; i < hats.length; ++i) {
  8957. if (hats[i].id == index) {
  8958. tmpObj = hats[i];
  8959. break;
  8960. }
  8961. }
  8962. skinPointers[index] = tmpObj;
  8963. }
  8964. if (tmpSkin.isLoaded)
  8965. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8966. if (!parentSkin && tmpObj.topSprite) {
  8967. ctxt.save();
  8968. ctxt.rotate(owner.skinRot);
  8969. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8970. ctxt.restore();
  8971. }
  8972. }
  8973.  
  8974. var FlareZHat = {
  8975. 7: "https://i.imgur.com/vAOzlyY.png",
  8976. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8977. 40: "https://i.imgur.com/Xzmg27N.png",
  8978. 26: "https://i.imgur.com/I0xGtyZ.png",
  8979. 55: "https://i.imgur.com/uYgDtcZ.png",
  8980. 20: "https://i.imgur.com/f5uhWCk.png",
  8981. };
  8982.  
  8983. function setSkinTextureImage(id, type, id2) {
  8984. if (true) {
  8985. if(FlareZHat[id] && type == "hat") {
  8986. return FlareZHat[id];
  8987. } else {
  8988. if(type == "acc") {
  8989. return ".././img/accessories/access_" + id + ".png";
  8990. } else if(type == "hat") {
  8991. return ".././img/hats/hat_" + id + ".png";
  8992. } else {
  8993. return ".././img/weapons/" + id + ".png";
  8994. }
  8995. }
  8996. } else {
  8997. if(type == "acc") {
  8998. return ".././img/accessories/access_" + id + ".png";
  8999. } else if(type == "hat") {
  9000. return ".././img/hats/hat_" + id + ".png";
  9001. } else {
  9002. return ".././img/weapons/" + id + ".png";
  9003. }
  9004. }
  9005. }
  9006. // RENDER SKINS:
  9007. let skinSprites = {};
  9008. let skinPointers = {};
  9009. let tmpSkin;
  9010.  
  9011. function renderSkin(index, ctxt, parentSkin, owner) {
  9012. tmpSkin = skinSprites[index];
  9013. if (!tmpSkin) {
  9014. let tmpImage = new Image();
  9015. tmpImage.onload = function() {
  9016. this.isLoaded = true;
  9017. this.onload = null;
  9018. };
  9019. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9020. skinSprites[index] = tmpImage;
  9021. tmpSkin = tmpImage;
  9022. }
  9023. let tmpObj = parentSkin || skinPointers[index];
  9024. if (!tmpObj) {
  9025. for (let i = 0; i < hats.length; ++i) {
  9026. if (hats[i].id == index) {
  9027. tmpObj = hats[i];
  9028. break;
  9029. }
  9030. }
  9031. skinPointers[index] = tmpObj;
  9032. }
  9033. if (tmpSkin.isLoaded)
  9034. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9035. if (!parentSkin && tmpObj.topSprite) {
  9036. ctxt.save();
  9037. ctxt.rotate(owner.skinRot);
  9038. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9039. ctxt.restore();
  9040. }
  9041. }
  9042.  
  9043. // RENDER TAIL:
  9044. var FlareZAcc = {
  9045. 21: "https://i.imgur.com/4ddZert.png",
  9046. 19: "https://i.imgur.com/sULkUZT.png",
  9047. };
  9048. function setTailTextureImage(id, type, id2) {
  9049. if (true) {
  9050. if(FlareZAcc[id] && type == "acc") {
  9051. return FlareZAcc[id];
  9052. } else {
  9053. if(type == "acc") {
  9054. return ".././img/accessories/access_" + id + ".png";
  9055. } else if(type == "hat") {
  9056. return ".././img/hats/hat_" + id + ".png";
  9057. } else {
  9058. return ".././img/weapons/" + id + ".png";
  9059. }
  9060. }
  9061. } else {
  9062. if(type == "acc") {
  9063. return ".././img/accessories/access_" + id + ".png";
  9064. } else if(type == "hat") {
  9065. return ".././img/hats/hat_" + id + ".png";
  9066. } else {
  9067. return ".././img/weapons/" + id + ".png";
  9068. }
  9069. }
  9070. }
  9071. function renderTailTextureImage(index, ctxt, owner) {
  9072. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  9073. var tmpImage = new Image();
  9074. tmpImage.onload = function() {
  9075. this.isLoaded = true,
  9076. this.onload = null
  9077. }
  9078. ,
  9079. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  9080. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9081. tmpSkin = tmpImage;
  9082. }
  9083. var tmpObj = accessPointers[index];
  9084. if (!tmpObj) {
  9085. for (var i = 0; i < accessories.length; ++i) {
  9086. if (accessories[i].id == index) {
  9087. tmpObj = accessories[i];
  9088. break;
  9089. }
  9090. }
  9091. accessPointers[index] = tmpObj;
  9092. }
  9093. if (tmpSkin.isLoaded) {
  9094. ctxt.save();
  9095. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9096. if (tmpObj.spin)
  9097. ctxt.rotate(owner.skinRot);
  9098. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9099. ctxt.restore();
  9100. }
  9101. }
  9102.  
  9103. let accessSprites = {};
  9104. let accessPointers = {};
  9105. var txt = true;
  9106.  
  9107. function renderTail(index, ctxt, owner) {
  9108. tmpSkin = accessSprites[index];
  9109. if (!tmpSkin) {
  9110. let tmpImage = new Image();
  9111. tmpImage.onload = function() {
  9112. this.isLoaded = true;
  9113. this.onload = null;
  9114. };
  9115. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9116. accessSprites[index] = tmpImage;
  9117. tmpSkin = tmpImage;
  9118. }
  9119. let tmpObj = accessPointers[index];
  9120. if (!tmpObj) {
  9121. for (let i = 0; i < accessories.length; ++i) {
  9122. if (accessories[i].id == index) {
  9123. tmpObj = accessories[i];
  9124. break;
  9125. }
  9126. }
  9127. accessPointers[index] = tmpObj;
  9128. }
  9129. if (tmpSkin.isLoaded) {
  9130. ctxt.save();
  9131. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9132. if (tmpObj.spin)
  9133. ctxt.rotate(owner.skinRot);
  9134. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9135. ctxt.restore();
  9136. }
  9137. }
  9138.  
  9139. var accessSprites2 = {};
  9140. var accessPointers2 = {};
  9141. function renderTail2(index, ctxt, owner) {
  9142. tmpSkin = accessSprites2[index];
  9143. if (!tmpSkin) {
  9144. var tmpImage = new Image();
  9145. tmpImage.onload = function() {
  9146. this.isLoaded = true;
  9147. this.onload = null;
  9148. };
  9149. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9150. accessSprites2[index] = tmpImage;
  9151. tmpSkin = tmpImage;
  9152. }
  9153. var tmpObj = accessPointers2[index];
  9154. if (!tmpObj) {
  9155. for (var i = 0; i < accessories.length; ++i) {
  9156. if (accessories[i].id == index) {
  9157. tmpObj = accessories[i];
  9158. break;
  9159. }
  9160. }
  9161. accessPointers2[index] = tmpObj;
  9162. }
  9163. if (tmpSkin.isLoaded) {
  9164. ctxt.save();
  9165. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9166. if (tmpObj.spin)
  9167. ctxt.rotate(owner.skinRot);
  9168. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9169. ctxt.restore();
  9170. }
  9171. }
  9172.  
  9173. // RENDER TOOL:
  9174. let toolSprites = {};
  9175. function renderTool(obj, variant, x, y, ctxt) {
  9176. let tmpSrc = obj.src + (variant || "");
  9177. let tmpSprite = toolSprites[tmpSrc];
  9178. if (!tmpSprite) {
  9179. tmpSprite = new Image();
  9180. tmpSprite.onload = function() {
  9181. this.isLoaded = true;
  9182. }
  9183. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9184. toolSprites[tmpSrc] = tmpSprite;
  9185. }
  9186. if (tmpSprite.isLoaded)
  9187. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9188. }
  9189.  
  9190. // RENDER PROJECTILES:
  9191. function renderProjectiles(layer, xOffset, yOffset) {
  9192. for (let i = 0; i < projectiles.length; i++) {
  9193. tmpObj = projectiles[i];
  9194. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9195. tmpObj.update(delta);
  9196. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9197. mainContext.save();
  9198. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9199. mainContext.rotate(tmpObj.dir);
  9200. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9201. mainContext.restore();
  9202. }
  9203. }
  9204. };
  9205. }
  9206.  
  9207. // RENDER PROJECTILE:
  9208. let projectileSprites = {};//fz iz zexy
  9209.  
  9210. function renderProjectile(x, y, obj, ctxt, debug) {
  9211. if (obj.src) {
  9212. let tmpSrc = items.projectiles[obj.indx].src;
  9213. let tmpSprite = projectileSprites[tmpSrc];
  9214. if (!tmpSprite) {
  9215. tmpSprite = new Image();
  9216. tmpSprite.onload = function() {
  9217. this.isLoaded = true;
  9218. }
  9219. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9220. projectileSprites[tmpSrc] = tmpSprite;
  9221. }
  9222. if (tmpSprite.isLoaded)
  9223. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9224. } else if (obj.indx == 1) {
  9225. ctxt.fillStyle = "#939393";
  9226. renderCircle(x, y, obj.scale, ctxt);
  9227. }
  9228. }
  9229.  
  9230. // RENDER AI:
  9231. let aiSprites = {};
  9232.  
  9233. function renderAI(obj, ctxt) {
  9234. let tmpIndx = obj.index;
  9235. let tmpSprite = aiSprites[tmpIndx];
  9236. if (!tmpSprite) {
  9237. let tmpImg = new Image();
  9238. tmpImg.onload = function() {
  9239. this.isLoaded = true;
  9240. this.onload = null;
  9241. };
  9242. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9243. tmpSprite = tmpImg;
  9244. aiSprites[tmpIndx] = tmpSprite;
  9245. }
  9246. if (tmpSprite.isLoaded) {
  9247. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9248. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9249. }
  9250. }
  9251.  
  9252. // RENDER WATER BODIES:
  9253. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9254.  
  9255. // MIDDLE RIVER:
  9256. let tmpW = config.riverWidth + padding;
  9257. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9258. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9259. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9260. }
  9261. }
  9262.  
  9263. // RENDER GAME OBJECTS:
  9264. let gameObjectSprites = {};
  9265.  
  9266. function getResSprite(obj) {
  9267. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  9268. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9269. let tmpSprite = gameObjectSprites[tmpIndex];
  9270. if (!tmpSprite) {
  9271. let blurScale = 6;
  9272. let tmpCanvas = document.createElement("canvas");
  9273. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9274. let tmpContext = tmpCanvas.getContext('2d');
  9275. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9276. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9277. tmpContext.strokeStyle = outlineColor;
  9278. tmpContext.lineWidth = outlineWidth;
  9279. // if (isNight) {
  9280. // tmpContext.shadowBlur = blurScale;
  9281. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9282. // }
  9283. if (obj.type == 0) {
  9284. let tmpScale;
  9285. let tmpCount = 8;
  9286. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  9287. for (let i = 0; i < 2; ++i) {
  9288. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  9289. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9290. tmpContext.fillStyle = !biomeID ? (!i ? "#8d3beb" : "#8d3beb") : (!i ? "#8d3beb" : "#8d3beb");
  9291. tmpContext.fill();
  9292. if (!i) {
  9293. tmpContext.stroke();
  9294. tmpContext.shadowBlur = null;
  9295. tmpContext.shadowColor = null;
  9296. tmpContext.globalAlpha = 1;
  9297. }
  9298. }
  9299. } else if (obj.type == 1) {
  9300. if (biomeID == 2) {
  9301. tmpContext.fillStyle = "#606060";
  9302. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9303. tmpContext.fill();
  9304. tmpContext.stroke();
  9305.  
  9306. //tmpContext.shadowBlur = null;
  9307. //tmpContext.shadowColor = null;
  9308.  
  9309. tmpContext.fillStyle = "#8d3beb";
  9310. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9311. tmpContext.fillStyle = "#8d3beb";
  9312. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9313. } else {
  9314. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9315. tmpContext.fillStyle = biomeID ? "#8d3beb" : "#8d3beb";
  9316. tmpContext.fill();
  9317. tmpContext.stroke();
  9318.  
  9319. //tmpContext.shadowBlur = null;
  9320. //tmpContext.shadowColor = null;
  9321.  
  9322. tmpContext.fillStyle = biomeID ? "#8d3beb" : "#8d3beb";
  9323. let tmpRange;
  9324. let berries = 4;
  9325. let rotVal = (Math.PI * 2) / berries;
  9326. for (let i = 0; i < berries; ++i) {
  9327. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  9328. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9329. UTILS.randInt(10, 12), tmpContext);
  9330. }
  9331. }
  9332. } else if (obj.type == 2 || obj.type == 3) {
  9333. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#8d3beb" : "#8d3beb") : "#8d3beb";
  9334. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9335. tmpContext.fill();
  9336. tmpContext.stroke();
  9337.  
  9338. tmpContext.shadowBlur = null;
  9339. tmpContext.shadowColor = null;
  9340.  
  9341. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#8d3beb" : "#8d3beb") : "#8d3beb";
  9342. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9343. tmpContext.fill();
  9344. }
  9345. tmpSprite = tmpCanvas;
  9346. gameObjectSprites[tmpIndex] = tmpSprite;
  9347. }
  9348. return tmpSprite;
  9349. }
  9350.  
  9351. // GET ITEM SPRITE:
  9352. let itemSprites = [];
  9353.  
  9354. function getItemSprite(obj, asIcon) {
  9355. let tmpSprite = itemSprites[obj.id];
  9356. if (!tmpSprite || asIcon) {
  9357. let blurScale = !asIcon ? 20 : 5;
  9358. let tmpCanvas = document.createElement("canvas");
  9359. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9360. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9361.  
  9362. let tmpContext = tmpCanvas.getContext("2d");
  9363. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9364. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9365. tmpContext.strokeStyle = outlineColor;
  9366. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9367. if (!asIcon) {
  9368. tmpContext.shadowBlur = 8;
  9369. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  9370. }
  9371.  
  9372. if (obj.name == "apple") {
  9373. tmpContext.fillStyle = "#8d3beb";
  9374. renderCircle(0, 0, obj.scale, tmpContext);
  9375. tmpContext.fillStyle = "#89a54c";
  9376. let leafDir = -(Math.PI / 2);
  9377. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9378. 25, leafDir + Math.PI / 2, tmpContext);
  9379. } else if (obj.name == "cookie") {
  9380. tmpContext.fillStyle = "#8d3beb";
  9381. renderCircle(0, 0, obj.scale, tmpContext);
  9382. tmpContext.fillStyle = "#8d3beb";
  9383. let chips = 4;
  9384. let rotVal = (Math.PI * 2) / chips;
  9385. let tmpRange;
  9386. for (let i = 0; i < chips; ++i) {
  9387. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9388. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9389. UTILS.randInt(4, 5), tmpContext, true);
  9390. }
  9391. } else if (obj.name == "cheese") {
  9392. tmpContext.fillStyle = "#8d3beb";
  9393. renderCircle(0, 0, obj.scale, tmpContext);
  9394. tmpContext.fillStyle = "#8d3beb";
  9395. let chips = 4;
  9396. let rotVal = (Math.PI * 2) / chips;
  9397. let tmpRange;
  9398. for (let i = 0; i < chips; ++i) {
  9399. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9400. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9401. UTILS.randInt(4, 5), tmpContext, true);
  9402. }
  9403. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9404. tmpContext.fillStyle = (obj.name == "castle wall") ? "#8d3beb" : (obj.name == "wood wall") ?
  9405. "#8d3beb" : "#8d3beb";
  9406. let sides = (obj.name == "castle wall") ? 4 : 3;
  9407. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9408. tmpContext.fill();
  9409. tmpContext.stroke();
  9410. tmpContext.fillStyle = (obj.name == "castle wall") ? "##8d3beb" : (obj.name == "wood wall") ?
  9411. "##8d3beb" : "##8d3beb";
  9412. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9413. tmpContext.fill();
  9414. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9415. obj.name == "spinning spikes") {
  9416. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#8d3beb" : "#8d3beb";
  9417. let tmpScale = (obj.scale * 0.6);
  9418. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9419. tmpContext.fill();
  9420. tmpContext.stroke();
  9421. tmpContext.fillStyle = "#8d3beb";
  9422. renderCircle(0, 0, tmpScale, tmpContext);
  9423. tmpContext.fillStyle = "#8d3beb";
  9424. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9425. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9426. tmpContext.fillStyle = "#8d3beb";
  9427. renderCircle(0, 0, reScale, tmpContext);
  9428. tmpContext.fillStyle = "#8d3beb";
  9429. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9430. tmpContext.fillStyle = "#8d3beb";
  9431. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9432. } else if (obj.name == "mine") {
  9433. tmpContext.fillStyle = "#8d3beb";
  9434. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9435. tmpContext.fill();
  9436. tmpContext.stroke();
  9437. tmpContext.fillStyle = "#8d3beb";
  9438. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9439. tmpContext.fill();
  9440. } else if (obj.name == "sapling") {
  9441. for (let i = 0; i < 2; ++i) {
  9442. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9443. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9444. tmpContext.fillStyle = (!i ? "#8d3beb" : "#8d3beb");
  9445. tmpContext.fill();
  9446. if (!i) tmpContext.stroke();
  9447. }
  9448. } else if (obj.name == "pit trap") {
  9449. tmpContext.fillStyle = "#8d3beb";
  9450. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9451. tmpContext.fill();
  9452. tmpContext.stroke();
  9453. tmpContext.fillStyle = outlineColor;
  9454. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9455. tmpContext.fill();
  9456. } else if (obj.name == "boost pad") {
  9457. tmpContext.fillStyle = "#8d3beb";
  9458. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9459. tmpContext.fill();
  9460. tmpContext.stroke();
  9461. tmpContext.fillStyle = "#dbd97d";
  9462. renderTriangle(obj.scale * 1, tmpContext);
  9463. } else if (obj.name == "turret") {
  9464. tmpContext.fillStyle = "#8d3beb";
  9465. renderCircle(0, 0, obj.scale, tmpContext);
  9466. tmpContext.fill();
  9467. tmpContext.stroke();
  9468. tmpContext.fillStyle = "#8d3beb";
  9469. let tmpLen = 50;
  9470. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9471. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9472. tmpContext.fill();
  9473. tmpContext.stroke();
  9474. } else if (obj.name == "platform") {
  9475. tmpContext.fillStyle = "#8d3beb";
  9476. let tmpCount = 4;
  9477. let tmpS = obj.scale * 2;
  9478. let tmpW = tmpS / tmpCount;
  9479. let tmpX = -(obj.scale / 2);
  9480. for (let i = 0; i < tmpCount; ++i) {
  9481. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9482. tmpContext.fill();
  9483. tmpContext.stroke();
  9484. tmpX += tmpS / tmpCount;
  9485. }
  9486. } else if (obj.name == "healing pad") {
  9487. tmpContext.fillStyle = "#8d3beb";
  9488. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9489. tmpContext.fill();
  9490. tmpContext.stroke();
  9491. tmpContext.fillStyle = "#8d3beb";
  9492. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9493. } else if (obj.name == "spawn pad") {
  9494. tmpContext.fillStyle = "#8d3beb";
  9495. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9496. tmpContext.fill();
  9497. tmpContext.stroke();
  9498. tmpContext.fillStyle = "#8d3beb";
  9499. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9500. } else if (obj.name == "blocker") {
  9501. tmpContext.fillStyle = "#8d3beb";
  9502. renderCircle(0, 0, obj.scale, tmpContext);
  9503. tmpContext.fill();
  9504. tmpContext.stroke();
  9505. tmpContext.rotate(Math.PI / 4);
  9506. tmpContext.fillStyle = "#8d3beb";
  9507. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9508. } else if (obj.name == "teleporter") {
  9509. tmpContext.fillStyle = "#8d3beb";
  9510. renderCircle(0, 0, obj.scale, tmpContext);
  9511. tmpContext.fill();
  9512. tmpContext.stroke();
  9513. tmpContext.rotate(Math.PI / 4);
  9514. tmpContext.fillStyle = "#8d3beb";
  9515. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9516. }
  9517. tmpSprite = tmpCanvas;
  9518. if (!asIcon)
  9519. itemSprites[obj.id] = tmpSprite;
  9520. }
  9521. return tmpSprite;
  9522. }
  9523.  
  9524. function getItemSprite2(obj, tmpX, tmpY) {
  9525. let tmpContext = mainContext;
  9526. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9527. tmpContext.save();
  9528. tmpContext.translate(tmpX, tmpY);
  9529. tmpContext.rotate(obj.dir);
  9530. tmpContext.strokeStyle = outlineColor;
  9531. tmpContext.lineWidth = outlineWidth;
  9532. if (obj.name == "apple") {
  9533. tmpContext.fillStyle = "#8d3beb";
  9534. renderCircle(0, 0, obj.scale, tmpContext);
  9535. tmpContext.fillStyle = "#89a54c";
  9536. let leafDir = -(Math.PI / 2);
  9537. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9538. 25, leafDir + Math.PI / 2, tmpContext);
  9539. } else if (obj.name == "cookie") {
  9540. tmpContext.fillStyle = "#cca861";
  9541. renderCircle(0, 0, obj.scale, tmpContext);
  9542. tmpContext.fillStyle = "#937c4b";
  9543. let chips = 4;
  9544. let rotVal = (Math.PI * 2) / chips;
  9545. let tmpRange;
  9546. for (let i = 0; i < chips; ++i) {
  9547. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9548. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9549. UTILS.randInt(4, 5), tmpContext, true);
  9550. }
  9551. } else if (obj.name == "cheese") {
  9552. tmpContext.fillStyle = "#f4f3ac";
  9553. renderCircle(0, 0, obj.scale, tmpContext);
  9554. tmpContext.fillStyle = "#c3c28b";
  9555. let chips = 4;
  9556. let rotVal = (Math.PI * 2) / chips;
  9557. let tmpRange;
  9558. for (let i = 0; i < chips; ++i) {
  9559. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9560. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9561. UTILS.randInt(4, 5), tmpContext, true);
  9562. }
  9563. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9564. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9565. "#a5974c" : "#939393";
  9566. let sides = (obj.name == "castle wall") ? 4 : 3;
  9567. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9568. tmpContext.fill();
  9569. tmpContext.stroke();
  9570. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9571. "#8d3beb" : "#bcbcbc";
  9572. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9573. tmpContext.fill();
  9574. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9575. obj.name == "spinning spikes") {
  9576. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#8d3beb" : "#8d3beb";
  9577. let tmpScale = (obj.scale * 0.6);
  9578. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9579. tmpContext.fill();
  9580. tmpContext.stroke();
  9581. tmpContext.fillStyle = "#8d3beb";
  9582. renderCircle(0, 0, tmpScale, tmpContext);
  9583. tmpContext.fillStyle = "#c9b758";
  9584. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9585. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9586. tmpContext.fillStyle = "#8d3beb";
  9587. renderCircle(0, 0, reScale, tmpContext);
  9588. tmpContext.fillStyle = "#8d3beb";
  9589. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9590. tmpContext.fillStyle = "#8d3beb";
  9591. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9592. } else if (obj.name == "mine") {
  9593. tmpContext.fillStyle = "#939393";
  9594. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9595. tmpContext.fill();
  9596. tmpContext.stroke();
  9597. tmpContext.fillStyle = "#bcbcbc";
  9598. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9599. tmpContext.fill();
  9600. } else if (obj.name == "sapling") {
  9601. for (let i = 0; i < 2; ++i) {
  9602. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9603. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9604. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9605. tmpContext.fill();
  9606. if (!i) tmpContext.stroke();
  9607. }
  9608. } else if (obj.name == "pit trap") {
  9609. tmpContext.fillStyle = "#8d3beb";
  9610. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9611. tmpContext.fill();
  9612. tmpContext.stroke();
  9613. tmpContext.fillStyle = outlineColor;
  9614. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9615. tmpContext.fill();
  9616. } else if (obj.name == "boost pad") {
  9617. tmpContext.fillStyle = "#7e7f82";
  9618. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9619. tmpContext.fill();
  9620. tmpContext.stroke();
  9621. tmpContext.fillStyle = "#dbd97d";
  9622. renderTriangle(obj.scale * 1, tmpContext);
  9623. } else if (obj.name == "turret") {
  9624. tmpContext.fillStyle = "#8d3beb";
  9625. renderCircle(0, 0, obj.scale, tmpContext);
  9626. tmpContext.fill();
  9627. tmpContext.stroke();
  9628. tmpContext.fillStyle = "#939393";
  9629. let tmpLen = 50;
  9630. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9631. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9632. tmpContext.fill();
  9633. tmpContext.stroke();
  9634. } else if (obj.name == "platform") {
  9635. tmpContext.fillStyle = "#cebd5f";
  9636. let tmpCount = 4;
  9637. let tmpS = obj.scale * 2;
  9638. let tmpW = tmpS / tmpCount;
  9639. let tmpX = -(obj.scale / 2);
  9640. for (let i = 0; i < tmpCount; ++i) {
  9641. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9642. tmpContext.fill();
  9643. tmpContext.stroke();
  9644. tmpX += tmpS / tmpCount;
  9645. }
  9646. } else if (obj.name == "healing pad") {
  9647. tmpContext.fillStyle = "#7e7f82";
  9648. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9649. tmpContext.fill();
  9650. tmpContext.stroke();
  9651. tmpContext.fillStyle = "#db6e6e";
  9652. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9653. } else if (obj.name == "spawn pad") {
  9654. tmpContext.fillStyle = "#7e7f82";
  9655. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9656. tmpContext.fill();
  9657. tmpContext.stroke();
  9658. tmpContext.fillStyle = "#71aad6";
  9659. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9660. } else if (obj.name == "blocker") {
  9661. tmpContext.fillStyle = "#7e7f82";
  9662. renderCircle(0, 0, obj.scale, tmpContext);
  9663. tmpContext.fill();
  9664. tmpContext.stroke();
  9665. tmpContext.rotate(Math.PI / 4);
  9666. tmpContext.fillStyle = "#db6e6e";
  9667. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9668. } else if (obj.name == "teleporter") {
  9669. tmpContext.fillStyle = "#7e7f82";
  9670. renderCircle(0, 0, obj.scale, tmpContext);
  9671. tmpContext.fill();
  9672. tmpContext.stroke();
  9673. tmpContext.rotate(Math.PI / 4);
  9674. tmpContext.fillStyle = "#d76edb";
  9675. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9676. }
  9677. tmpContext.restore();
  9678. }
  9679.  
  9680. let objSprites = [];
  9681.  
  9682. function getObjSprite(obj) {
  9683. let tmpSprite = objSprites[obj.id];
  9684. if (!tmpSprite) {
  9685. // let blurScale = isNight ? 20 : 0;
  9686. let tmpCanvas = document.createElement("canvas");
  9687. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  9688. let tmpContext = tmpCanvas.getContext("2d");
  9689. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9690. tmpContext.rotate(Math.PI / 2);
  9691. tmpContext.strokeStyle = outlineColor;
  9692. tmpContext.lineWidth = outlineWidth;
  9693. // if (isNight) {
  9694. // tmpContext.shadowBlur = 20;
  9695. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9696. // }
  9697. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9698. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9699. let tmpScale = obj.scale * 0.6;
  9700. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9701. tmpContext.fill();
  9702. tmpContext.stroke();
  9703. tmpContext.fillStyle = "#8d3beb";
  9704. renderCircle(0, 0, tmpScale, tmpContext);
  9705. tmpContext.fillStyle = "#c15555";
  9706. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9707. } else if (obj.name == "pit trap") {
  9708. tmpContext.fillStyle = "#000000";
  9709. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9710. tmpContext.fill();
  9711. tmpContext.stroke();
  9712. tmpContext.fillStyle = "#8d3beb";
  9713. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9714. tmpContext.fill();
  9715. }
  9716. tmpSprite = tmpCanvas;
  9717. objSprites[obj.id] = tmpSprite;
  9718. }
  9719. return tmpSprite;
  9720. }
  9721.  
  9722. // GET MARK SPRITE:
  9723. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9724. let center = {
  9725. x: screenWidth / 2,
  9726. y: screenHeight / 2,
  9727. };
  9728. tmpContext.lineWidth = outlineWidth;
  9729. mainContext.globalAlpha = 0.2;
  9730. tmpContext.strokeStyle = outlineColor;
  9731. tmpContext.save();
  9732. tmpContext.translate(tmpX, tmpY);
  9733. tmpContext.rotate(90**10);
  9734. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9735. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9736. var tmpScale = (obj.scale);
  9737. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9738. tmpContext.fill();
  9739. tmpContext.stroke();
  9740. tmpContext.fillStyle = "#a5974c";
  9741. renderCircle(0, 0, tmpScale, tmpContext);
  9742. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9743. tmpContext.fillStyle = "#a34040";
  9744. } else {
  9745. tmpContext.fillStyle = "#c9b758";
  9746. }
  9747. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9748. } else if (obj.name == "turret") {
  9749. renderCircle(0, 0, obj.scale, tmpContext);
  9750. tmpContext.fill();
  9751. tmpContext.stroke();
  9752. tmpContext.fillStyle = "#8d3beb";
  9753. let tmpLen = 50;
  9754. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9755. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9756. tmpContext.fill();
  9757. tmpContext.stroke();
  9758. } else if (obj.name == "teleporter") {
  9759. tmpContext.fillStyle = "#7e7f82";
  9760. renderCircle(0, 0, obj.scale, tmpContext);
  9761. tmpContext.fill();
  9762. tmpContext.stroke();
  9763. tmpContext.rotate(Math.PI / 4);
  9764. tmpContext.fillStyle = "#d76edb";
  9765. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9766. } else if (obj.name == "platform") {
  9767. tmpContext.fillStyle = "#cebd5f";
  9768. let tmpCount = 4;
  9769. let tmpS = obj.scale * 2;
  9770. let tmpW = tmpS / tmpCount;
  9771. let tmpX = -(obj.scale / 2);
  9772. for (let i = 0; i < tmpCount; ++i) {
  9773. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9774. tmpContext.fill();
  9775. tmpContext.stroke();
  9776. tmpX += tmpS / tmpCount;
  9777. }
  9778. } else if (obj.name == "healing pad") {
  9779. tmpContext.fillStyle = "#7e7f82";
  9780. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9781. tmpContext.fill();
  9782. tmpContext.stroke();
  9783. tmpContext.fillStyle = "#db6e6e";
  9784. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9785. } else if (obj.name == "spawn pad") {
  9786. tmpContext.fillStyle = "#7e7f82";
  9787. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9788. tmpContext.fill();
  9789. tmpContext.stroke();
  9790. tmpContext.fillStyle = "#71aad6";
  9791. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9792. } else if (obj.name == "blocker") {
  9793. tmpContext.fillStyle = "#7e7f82";
  9794. renderCircle(0, 0, obj.scale, tmpContext);
  9795. tmpContext.fill();
  9796. tmpContext.stroke();
  9797. tmpContext.rotate(Math.PI / 4);
  9798. tmpContext.fillStyle = "#db6e6e";
  9799. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9800. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9801. tmpContext.fillStyle = "##8d3beb";
  9802. renderCircle(0, 0, obj.scale, tmpContext);
  9803. tmpContext.fillStyle = "##8d3beb";
  9804. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9805. tmpContext.fillStyle = "##8d3beb";
  9806. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9807.  
  9808. } else if (obj.name == "pit trap") {
  9809. tmpContext.fillStyle = "#000000";
  9810. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9811. tmpContext.fill();
  9812. tmpContext.stroke();
  9813. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9814. tmpContext.fillStyle = "#8d3beb";
  9815. } else {
  9816. tmpContext.fillStyle = outlineColor;
  9817. }
  9818. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9819. tmpContext.fill();
  9820. }
  9821. tmpContext.restore();
  9822. }
  9823.  
  9824. // OBJECT ON SCREEN:
  9825. function isOnScreen(x, y, s) {
  9826. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9827. s,
  9828. maxScreenHeight));
  9829. }
  9830.  
  9831. // RENDER GAME OBJECTS:
  9832. function renderGameObjects(layer, xOffset, yOffset) {
  9833. let tmpSprite;
  9834. let tmpX;
  9835. let tmpY;
  9836. liztobj.forEach((tmp) => {
  9837. tmpObj = tmp;
  9838. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9839. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9840. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9841. if (layer == 0) {
  9842. tmpObj.update(delta);
  9843. }
  9844. mainContext.globalAlpha = tmpObj.alpha;
  9845. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9846. if (tmpObj.isItem) {
  9847. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9848. tmpSprite = getObjSprite(tmpObj);
  9849. } else {
  9850. tmpSprite = getItemSprite(tmpObj);
  9851. }
  9852.  
  9853. mainContext.save();
  9854. mainContext.translate(tmpX, tmpY);
  9855. mainContext.rotate(tmpObj.dir);
  9856. if (!tmpObj.active) {
  9857. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9858. }
  9859. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9860.  
  9861. if (tmpObj.blocker) {
  9862. mainContext.strokeStyle = "#db6e6e";
  9863. mainContext.globalAlpha = 0.3;
  9864. mainContext.lineWidth = 6;
  9865. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9866. }
  9867. mainContext.restore();
  9868. } else {
  9869. tmpSprite = getResSprite(tmpObj);
  9870. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9871. }
  9872. }
  9873. if (layer == 3) {
  9874. if (tmpObj.health < tmpObj.maxHealth) {
  9875. // HEALTH HOLDER:
  9876. mainContext.fillStyle = darkOutlineColor;
  9877. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9878. mainContext.fill();
  9879.  
  9880. // HEALTH BAR:
  9881. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#ad64ed" : "#8d3beb";
  9882. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9883. mainContext.fill();
  9884. }
  9885. }
  9886. }
  9887. });
  9888.  
  9889. // PLACE VISIBLE:
  9890. if (layer == 0) {
  9891. if (placeVisible.length) {
  9892. placeVisible.forEach((places) => {
  9893. tmpX = places.x - xOffset;
  9894. tmpY = places.y - yOffset;
  9895. markObject(places, tmpX, tmpY);
  9896. });
  9897. }
  9898. }
  9899. }
  9900.  
  9901. function markObject(tmpObj, tmpX, tmpY) {
  9902. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9903. }
  9904.  
  9905. // RENDER MINIMAP:
  9906. class MapPing {
  9907. constructor(color, scale) {
  9908. this.init = function(x, y) {
  9909. this.scale = 0;
  9910. this.x = x;
  9911. this.y = y;
  9912. this.active = true;
  9913. };
  9914. this.update = function(ctxt, delta) {
  9915. if (this.active) {
  9916. this.scale += 0.05 * delta;
  9917. if (this.scale >= scale) {
  9918. this.active = false;
  9919. } else {
  9920. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9921. ctxt.beginPath();
  9922. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9923. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9924. ctxt.stroke();
  9925. }
  9926. }
  9927. };
  9928. this.color = color;
  9929. }
  9930. }
  9931.  
  9932. function pingMap(x, y) {
  9933. tmpPing = mapPings.find(pings => !pings.active);
  9934. if (!tmpPing) {
  9935. tmpPing = new MapPing("#fff", config.mapPingScale);
  9936. mapPings.push(tmpPing);
  9937. }
  9938. tmpPing.init(x, y);
  9939. }
  9940.  
  9941. function updateMapMarker() {
  9942. mapMarker.x = player.x;
  9943. mapMarker.y = player.y;
  9944. }
  9945.  
  9946. function renderMinimap(delta) {
  9947. if (player && player.alive) {
  9948. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9949.  
  9950. // RENDER PINGS:
  9951. mapContext.lineWidth = 4;
  9952. for (let i = 0; i < mapPings.length; ++i) {
  9953. tmpPing = mapPings[i];
  9954. mapContext.strokeStyle = tmpPing.color;
  9955. tmpPing.update(mapContext, delta);
  9956. }
  9957.  
  9958. // RENDER BREAK TRACKS:
  9959. mapContext.globalAlpha = 1;
  9960. mapContext.fillStyle = "#ff0000";
  9961. if (breakTrackers.length) {
  9962. mapContext.fillStyle = "#abcdef";
  9963. mapContext.font = "34px Hammersmith One";
  9964. mapContext.textBaseline = "middle";
  9965. mapContext.textAlign = "center";
  9966. for (let i = 0; i < breakTrackers.length;) {
  9967. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9968. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9969. i += 2;
  9970. }
  9971. }
  9972.  
  9973. // RENDER PLAYERS:
  9974. mapContext.globalAlpha = 1;
  9975. mapContext.fillStyle = "#fff";
  9976. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9977. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9978. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9979. if (player.team && minimapData) {
  9980. for (let i = 0; i < minimapData.length;) {
  9981. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9982. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9983. i += 2;
  9984. }
  9985. }
  9986.  
  9987. // RENDER BOTS:
  9988. if (bots.length) {
  9989. bots.forEach((tmp) => {
  9990. if (tmp.inGame) {
  9991. mapContext.globalAlpha = 1;
  9992. mapContext.strokeStyle = "#cc5151";
  9993. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9994. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9995. }
  9996. });
  9997. }
  9998.  
  9999. // DEATH LOCATION:
  10000. if (lastDeath) {
  10001. mapContext.fillStyle = "#fc5553";
  10002. mapContext.font = "34px Hammersmith One";
  10003. mapContext.textBaseline = "middle";
  10004. mapContext.textAlign = "center";
  10005. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10006. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10007. }
  10008.  
  10009. // MAP MARKER:
  10010. if (mapMarker) {
  10011. mapContext.fillStyle = "#fff";
  10012. mapContext.font = "34px Hammersmith One";
  10013. mapContext.textBaseline = "middle";
  10014. mapContext.textAlign = "center";
  10015. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10016. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10017. }
  10018. }
  10019. }
  10020.  
  10021. // ICONS:
  10022. let crossHairs = ["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/newawwddd.png", "https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100px-Crosshairs_Red.png"];
  10023. let crossHairSprites = {};
  10024. let iconSprites = {};
  10025. let icons = ["crown", "skull"];
  10026.  
  10027. function loadIcons() {
  10028. for (let i = 0; i < icons.length; ++i) {
  10029. let tmpSprite = new Image();
  10030. tmpSprite.onload = function() {
  10031. this.isLoaded = true;
  10032. };
  10033. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10034. iconSprites[icons[i]] = tmpSprite;
  10035. }
  10036. for (let i = 0; i < crossHairs.length; ++i) {
  10037. let tmpSprite = new Image();
  10038. tmpSprite.onload = function() {
  10039. this.isLoaded = true;
  10040. };
  10041. tmpSprite.src = crossHairs[i];
  10042. crossHairSprites[i] = tmpSprite;
  10043. }
  10044. }
  10045. loadIcons();
  10046.  
  10047. function cdf (e, t){
  10048. try {
  10049. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  10050. } catch(e){
  10051. return Infinity;
  10052. }
  10053. }
  10054.  
  10055. // UPDATE GAME:
  10056. function updateGame() {
  10057. if(gameObjects.length && inGame) {
  10058. gameObjects.forEach((tmp) => {
  10059. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  10060. if(!liztobj.includes(tmp)) {
  10061. liztobj.push(tmp);
  10062. tmp.render = true;
  10063. }
  10064. } else {
  10065. if(liztobj.includes(tmp)) {
  10066. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10067. tmp.render = false;
  10068. const index = liztobj.indexOf(tmp);
  10069. if (index > -1) { // only splice array when item is found
  10070. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10071. }
  10072. }
  10073. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10074. tmp.render = false;
  10075. const index = liztobj.indexOf(tmp);
  10076. if (index > -1) { // only splice array when item is found
  10077. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10078. }
  10079. } else {
  10080. tmp.render = false;
  10081. const index = liztobj.indexOf(tmp);
  10082. if (index > -1) { // only splice array when item is found
  10083. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10084. }
  10085. }
  10086. }
  10087. })
  10088. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10089. }
  10090.  
  10091. // if (config.resetRender) {
  10092. mainContext.beginPath();
  10093. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10094. // }
  10095. mainContext.globalAlpha = 1;
  10096.  
  10097. // MOVE CAMERA:
  10098. if (player) {
  10099. if (false) {
  10100. camX = player.x;
  10101. camY = player.y;
  10102. } else {
  10103. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10104. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10105. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  10106. if (tmpDist > 0.05) {
  10107. camX += camSpd * Math.cos(tmpDir);
  10108. camY += camSpd * Math.sin(tmpDir);
  10109. } else {
  10110. camX = player.x;
  10111. camY = player.y;
  10112. }
  10113. }
  10114. } else {
  10115. camX = config.mapScale / 2 + config.riverWidth;
  10116. camY = config.mapScale / 2;
  10117. }
  10118.  
  10119. // INTERPOLATE PLAYERS AND AI:
  10120. let lastTime = now - (1000 / config.serverUpdateRate);
  10121. let tmpDiff;
  10122. for (let i = 0; i < players.length + ais.length; ++i) {
  10123. tmpObj = players[i] || ais[i - players.length];
  10124. if (tmpObj && tmpObj.visible) {
  10125. if (tmpObj.forcePos) {
  10126. tmpObj.x = tmpObj.x2;
  10127. tmpObj.y = tmpObj.y2;
  10128. tmpObj.dir = tmpObj.d2;
  10129. } else {
  10130. let total = tmpObj.t2 - tmpObj.t1;
  10131. let fraction = lastTime - tmpObj.t1;
  10132. let ratio = (fraction / total);
  10133. let rate = 170;
  10134. tmpObj.dt += delta;
  10135. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10136. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10137. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10138. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10139. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10140. if (config.anotherVisual) {
  10141. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10142. } else {
  10143. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10144. }
  10145. }
  10146. }
  10147. }
  10148.  
  10149. // RENDER CORDS:
  10150. let xOffset = camX - (maxScreenWidth / 2);
  10151. let yOffset = camY - (maxScreenHeight / 2);
  10152.  
  10153. // RENDER BACKGROUND:
  10154. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10155. mainContext.fillStyle = "#78ad57";
  10156. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10157. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10158. mainContext.fillStyle = "#787156";
  10159. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10160. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10161. mainContext.fillStyle = "#fff";
  10162. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10163. } else if (config.snowBiomeTop - yOffset >= 0) {
  10164. mainContext.fillStyle = "#fff";
  10165. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10166. mainContext.fillStyle = "#787156";
  10167. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10168. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10169. } else {
  10170. mainContext.fillStyle = "#787156";
  10171. mainContext.fillRect(0, 0, maxScreenWidth,
  10172. (config.mapScale - config.snowBiomeTop - yOffset));
  10173. mainContext.fillStyle = "#787156";
  10174. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10175. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10176. }
  10177.  
  10178. // RENDER WATER AREAS:
  10179. if (!firstSetup) {
  10180. waterMult += waterPlus * config.waveSpeed * delta;
  10181. if (waterMult >= config.waveMax) {
  10182. waterMult = config.waveMax;
  10183. waterPlus = -1;
  10184. } else if (waterMult <= 1) {
  10185. waterMult = waterPlus = 1;
  10186. }
  10187. mainContext.globalAlpha = 1;
  10188. mainContext.fillStyle = "#dbc666";
  10189. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10190. mainContext.fillStyle = "#19539c";
  10191. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10192. }
  10193.  
  10194. // RENDER DEAD PLAYERS:
  10195. mainContext.globalAlpha = 1;
  10196. mainContext.strokeStyle = outlineColor;
  10197. renderDeadPlayers(xOffset, yOffset);
  10198.  
  10199. // RENDER BOTTOM LAYER:
  10200. mainContext.globalAlpha = 1;
  10201. mainContext.strokeStyle = outlineColor;
  10202. renderGameObjects(-1, xOffset, yOffset);
  10203.  
  10204. // RENDER PROJECTILES:
  10205. mainContext.globalAlpha = 1;
  10206. mainContext.lineWidth = outlineWidth;
  10207. renderProjectiles(0, xOffset, yOffset);
  10208.  
  10209. // RENDER PLAYERS:
  10210. renderPlayers(xOffset, yOffset, 0);
  10211.  
  10212. // RENDER AI:
  10213. mainContext.globalAlpha = 1;
  10214. for (let i = 0; i < ais.length; ++i) {
  10215. tmpObj = ais[i];
  10216. if (tmpObj.active && tmpObj.visible) {
  10217. tmpObj.animate(delta);
  10218. mainContext.save();
  10219. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10220. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10221. renderAI(tmpObj, mainContext);
  10222. mainContext.restore();
  10223. }
  10224. }
  10225.  
  10226. // RENDER GAME OBJECTS (LAYERED):
  10227. renderGameObjects(0, xOffset, yOffset);
  10228. renderProjectiles(1, xOffset, yOffset);
  10229. renderGameObjects(1, xOffset, yOffset);
  10230. renderPlayers(xOffset, yOffset, 1);
  10231. renderGameObjects(2, xOffset, yOffset);
  10232. renderGameObjects(3, xOffset, yOffset);
  10233.  
  10234. // MAP BOUNDARIES:
  10235. mainContext.fillStyle = "#000";
  10236. mainContext.globalAlpha = 0.09;
  10237. if (xOffset <= 0) {
  10238. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10239. }
  10240. if (config.mapScale - xOffset <= maxScreenWidth) {
  10241. let tmpY = Math.max(0, -yOffset);
  10242. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10243. }
  10244. if (yOffset <= 0) {
  10245. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10246. }
  10247. if (config.mapScale - yOffset <= maxScreenHeight) {
  10248. let tmpX = Math.max(0, -xOffset);
  10249. let tmpMin = 0;
  10250. if (config.mapScale - xOffset <= maxScreenWidth)
  10251. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10252. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10253. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10254. }
  10255.  
  10256. // RENDER DAY/NIGHT TIME:
  10257. mainContext.globalAlpha = 1;
  10258. mainContext.fillStyle = "rgba(0, 5, 80, 0.35)";
  10259. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10260.  
  10261. // RENDER PLAYER AND AI UI:
  10262. mainContext.strokeStyle = darkOutlineColor;
  10263. mainContext.globalAlpha = 1;
  10264.  
  10265. for (let i = 0; i < players.length + ais.length; ++i) {
  10266. tmpObj = players[i] || ais[i - players.length];
  10267. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  10268. mainContext.strokeStyle = darkOutlineColor;
  10269.  
  10270. // NAME AND HEALTH:
  10271.  
  10272. // let izbot = false;
  10273.  
  10274. // bots.forEach((bot) => {
  10275. // if (tmpObj.sid == bot.sid) izbot = true
  10276. // else izbot = false;
  10277. // });
  10278.  
  10279. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  10280. if (tmpText != "" && tmpObj.name != "unknown1l") {
  10281. // bots.forEach((bot) => {
  10282. // if (tmpObj.sid == bot.sid) return;
  10283. // });
  10284.  
  10285. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10286. mainContext.fillStyle = "#fff";
  10287. mainContext.textBaseline = "middle";
  10288. mainContext.textAlign = "center";
  10289. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10290. mainContext.lineJoin = "round";
  10291. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10292. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10293. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10294. let tmpS = config.crownIconScale;
  10295. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10296. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10297. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10298. }
  10299. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10300. let tmpS = config.crownIconScale;
  10301. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10302. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10303. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10304. }
  10305. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length) {
  10306. let tmpS = tmpObj.scale * 2.2;
  10307. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10308. }
  10309. // izbot = false;
  10310. }
  10311. if (tmpObj.health > 0) {
  10312.  
  10313. if(tmpObj.name != "unknown1l") {
  10314. // HEALTH HOLDER:
  10315. mainContext.fillStyle = darkOutlineColor;
  10316. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10317. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10318. (config.healthBarPad * 2), 17, 8);
  10319. mainContext.fill();
  10320.  
  10321. // HEALTH BAR:
  10322. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#ad64ed" : "#cc5151";
  10323. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10324. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10325. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10326. mainContext.fill();
  10327. }
  10328.  
  10329. if (tmpObj.isPlayer) {
  10330. mainContext.globalAlpha = 1;
  10331. let targetReloads = {
  10332. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10333. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10334. turret: (2500 - tmpObj.reloads[53]) / 2500
  10335. };
  10336. if (!tmpObj.currentReloads) {
  10337. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10338. primary: targetReloads.primary,
  10339. secondary: targetReloads.secondary,
  10340. turret: targetReloads.turret
  10341. };
  10342. }
  10343. const lerpFactor = 0.3;
  10344. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10345. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10346. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10347.  
  10348. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10349. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10350. const centerX = tmpObj.x - xOffset;
  10351. const centerY = tmpObj.y - yOffset;
  10352. const barRadius = 35;
  10353. const barWidth = 15;
  10354. const totalAngle = (Math.PI*2)/3; // Half circle
  10355. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10356. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10357. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10358. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10359.  
  10360. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10361. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10362. function returncoolcolor(RainbowCycle) {
  10363. return "#d6d6d6";
  10364. }
  10365.  
  10366. mainContext.save();
  10367. if (tmpObj.currentReloads.primary < 0.999) {
  10368. mainContext.beginPath();
  10369. mainContext.lineCap = 'round';
  10370. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10371. mainContext.lineWidth = 4;
  10372. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10373. mainContext.stroke();
  10374. }
  10375. if (tmpObj.currentReloads.secondary < 0.999) {
  10376. mainContext.beginPath();
  10377. mainContext.lineCap = 'round';
  10378. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10379. mainContext.lineWidth = 4;
  10380. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10381. mainContext.stroke();
  10382. }
  10383. if (tmpObj.currentReloads.turret < 0.999) {
  10384. mainContext.beginPath();
  10385. mainContext.lineCap = 'round';
  10386. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10387. mainContext.lineWidth = 4;
  10388. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10389. mainContext.stroke();
  10390. }
  10391. mainContext.restore();
  10392.  
  10393. if(tmpObj.name != "unknown1l") {
  10394. // SHAME COUNT:
  10395. mainContext.globalAlpha = 1;
  10396. mainContext.font = "24px Hammersmith One";
  10397. mainContext.fillStyle = "#fff";
  10398. mainContext.strokeStyle = darkOutlineColor;
  10399. mainContext.textBaseline = "middle";
  10400. mainContext.textAlign = "center";
  10401. mainContext.lineWidth = 8;
  10402. mainContext.lineJoin = "round";
  10403. let tmpS = config.crownIconScale;
  10404. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  10405. 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);
  10406. 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);
  10407. }
  10408.  
  10409. // PLAYER TRACER:
  10410. if (!tmpObj.isTeam(player)) {
  10411. let center = {
  10412. x: screenWidth / 2,
  10413. y: screenHeight / 2,
  10414. };
  10415. 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);
  10416. let dist = center.y * alpha / 2;
  10417. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10418. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10419. mainContext.save();
  10420. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10421. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10422. let by = 255 - (tmpObj.sid * 2);
  10423. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10424. mainContext.globalAlpha = alpha;
  10425. let renderTracer = function(s, ctx) {
  10426. ctx = ctx || mainContext;
  10427. let h = s * (Math.sqrt(3) / 2);
  10428. ctx.beginPath();
  10429. ctx.moveTo(0, -h / 1.5);
  10430. ctx.lineTo(-s / 2, h / 2);
  10431. ctx.lineTo(s / 2, h / 2);
  10432. ctx.lineTo(0, -h / 1.5);
  10433. ctx.fill();
  10434. ctx.closePath();
  10435. }
  10436. renderTracer(25, mainContext);
  10437. mainContext.restore();
  10438. }
  10439.  
  10440. if (getEl("predictType").value == "pre2") {
  10441. mainContext.lineWidth = 3;
  10442. mainContext.strokeStyle = "#fff";
  10443. mainContext.globalAlpha = 1;
  10444. mainContext.beginPath();
  10445. let render = {
  10446. x: tmpObj.x2 - xOffset,
  10447. y: tmpObj.y2 - yOffset
  10448. };
  10449. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10450. mainContext.lineTo(render.x, render.y);
  10451. mainContext.stroke();
  10452. } else if (getEl("predictType").value == "pre3") {
  10453. mainContext.lineWidth = 3;
  10454. mainContext.strokeStyle = "#cc5151";
  10455. mainContext.globalAlpha = 1;
  10456. mainContext.beginPath();
  10457. let render = {
  10458. x: tmpObj.x3 - xOffset,
  10459. y: tmpObj.y3 - yOffset
  10460. };
  10461. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10462. mainContext.lineTo(render.x, render.y);
  10463. mainContext.stroke();
  10464. }
  10465.  
  10466. }
  10467. }
  10468. }
  10469. }
  10470.  
  10471. if (player) {
  10472. // AUTOPUSH LINE:
  10473. if (my.autoPush) {
  10474. mainContext.lineWidth = 14;
  10475. mainContext.strokeStyle = "rgba(160, 32, 240, 0.3)"; // HPBarColor (Outline color)
  10476. mainContext.beginPath();
  10477. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10478. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  10479. mainContext.stroke(); // Draw the outline
  10480. }
  10481. }
  10482.  
  10483.  
  10484. mainContext.globalAlpha = 1;
  10485.  
  10486. // RENDER ANIM TEXTS:
  10487. textManager.update(delta, mainContext, xOffset, yOffset);
  10488.  
  10489. // RENDER CHAT MESSAGES:
  10490. for (let i = 0; i < players.length; ++i) {
  10491. tmpObj = players[i];
  10492. if (tmpObj.visible) {
  10493. if (tmpObj.chatCountdown > 0) {
  10494. tmpObj.chatCountdown -= delta;
  10495. if (tmpObj.chatCountdown <= 0)
  10496. tmpObj.chatCountdown = 0;
  10497. mainContext.font = "32px Hammersmith One";
  10498. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10499. mainContext.textBaseline = "middle";
  10500. mainContext.textAlign = "center";
  10501. let tmpX = tmpObj.x - xOffset;
  10502. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10503. let tmpH = 47;
  10504. let tmpW = tmpSize.width + 17;
  10505. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10506. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10507. mainContext.fill();
  10508. mainContext.fillStyle = "#fff";
  10509. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10510. }
  10511. if (tmpObj.chat.count > 0) {
  10512. tmpObj.chat.count -= delta;
  10513. if (tmpObj.chat.count <= 0)
  10514. tmpObj.chat.count = 0;
  10515. mainContext.font = "32px Hammersmith One";
  10516. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10517. mainContext.textBaseline = "middle";
  10518. mainContext.textAlign = "center";
  10519. let tmpX = tmpObj.x - xOffset;
  10520. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10521. let tmpH = 47;
  10522. let tmpW = tmpSize.width + 17;
  10523. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10524. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10525. mainContext.fill();
  10526. mainContext.fillStyle = "#ffffff99";
  10527. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10528. } else {
  10529. tmpObj.chat.count = 0;
  10530.  
  10531. }
  10532. }
  10533. }
  10534.  
  10535. if (allChats.length) {
  10536. allChats.filter(ch => ch.active).forEach((ch) => {
  10537. if (!ch.alive) {
  10538. if (ch.alpha <= 1) {
  10539. ch.alpha += delta / 250;
  10540. if (ch.alpha >= 1) {
  10541. ch.alpha = 1;
  10542. ch.alive = true;
  10543. }
  10544. }
  10545. } else {
  10546. ch.alpha -= delta / 5000;
  10547. if (ch.alpha <= 0) {
  10548. ch.alpha = 0;
  10549. ch.active = false;
  10550. }
  10551. }
  10552. if (ch.active) {
  10553. mainContext.font = "20px Ubuntu";
  10554. let tmpSize = mainContext.measureText(ch.chat);
  10555. mainContext.textBaseline = "middle";
  10556. mainContext.textAlign = "center";
  10557. let tmpX = ch.x - xOffset;
  10558. let tmpY = ch.y - yOffset - 90;
  10559. let tmpH = 40;
  10560. let tmpW = tmpSize.width + 15;
  10561.  
  10562. mainContext.globalAlpha = ch.alpha;
  10563.  
  10564. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10565. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10566. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10567. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  10568.  
  10569. mainContext.lineWidth = 5;
  10570. mainContext.fillStyle = "#ccc";
  10571. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10572.  
  10573. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10574. mainContext.stroke();
  10575. mainContext.fill();
  10576.  
  10577. mainContext.fillStyle = "#fff";
  10578. mainContext.strokeStyle = "#000";
  10579. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10580. mainContext.fillText(ch.chat, tmpX, tmpY);
  10581. ch.y -= delta / 100;
  10582. }
  10583. });
  10584. }
  10585.  
  10586. mainContext.globalAlpha = 1;
  10587.  
  10588. // RENDER MINIMAP:
  10589. renderMinimap(delta);
  10590. }
  10591.  
  10592. // UPDATE & ANIMATE:
  10593. window.requestAnimFrame = function() {
  10594. return null;
  10595. }
  10596. window.rAF = (function() {
  10597. return window.requestAnimationFrame ||
  10598. window.webkitRequestAnimationFrame ||
  10599. window.mozRequestAnimationFrame ||
  10600. function(callback) {
  10601. window.setTimeout(callback, 1000/9);
  10602. };
  10603. })();
  10604.  
  10605. function doUpdate() {
  10606. //rape modulus
  10607. now = performance.now();
  10608. delta = now - lastUpdate;
  10609. lastUpdate = now;
  10610. let timer = performance.now();
  10611. let diff = timer - fpsTimer.last;
  10612. if (diff >= 1000) {
  10613.  
  10614. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10615.  
  10616. fpsTimer.last = timer;
  10617. fpsTimer.time = 0;
  10618. }
  10619. fpsTimer.time++;
  10620.  
  10621. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  10622. getEl("packetStatus").innerHTML = secPacket;
  10623. updateGame();
  10624. rAF(doUpdate);
  10625. ms.avg = Math.round((ms.min+ms.max)/2);
  10626. }
  10627.  
  10628. prepareMenuBackground();
  10629. doUpdate();
  10630.  
  10631. function toggleUseless(boolean) {
  10632. getEl("instaType").disabled = boolean;
  10633. getEl("antiBullType").disabled = boolean;
  10634. getEl("predictType").disabled = boolean;
  10635. }
  10636. toggleUseless(useWasd);
  10637.  
  10638. let changeDays = {};
  10639. window.debug = function() {
  10640. my.waitHit = 0;
  10641. my.autoAim = false;
  10642. instaC.isTrue = false;
  10643. traps.inTrap = false;
  10644. itemSprites = [];
  10645. objSprites = [];
  10646. gameObjectSprites = [];
  10647. };
  10648. window.wasdMode = function() {
  10649. useWasd = !useWasd;
  10650. toggleUseless(useWasd);
  10651. };
  10652. window.startGrind = function() {
  10653. if (getEl("weaponGrind").checked) {
  10654. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10655. checkPlace(player.getItemType(22), i);
  10656. }
  10657. }
  10658. };
  10659. // REMOVED!!! so they cant abuse :)
  10660. let projects = [
  10661. "adorable-eight-guppy",
  10662. "galvanized-bittersweet-windshield"
  10663. ];
  10664. let botIDS = 0;
  10665. window.connectFillBots = function() {
  10666. botSkts = [];
  10667. botIDS = 0;
  10668. for (let i = 0; i < projects.length; i++) {
  10669. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10670. test.binaryType = "arraybuffer";
  10671.  
  10672. test.onopen = function() {
  10673. test.ssend = function(type) {
  10674. let data = Array.prototype.slice.call(arguments, 1);
  10675. let binary = window.msgpack.encode([type, data]);
  10676. test.send(binary);
  10677. };
  10678. for (let i = 0; i < 4; i++) {
  10679. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10680. action: "homepage"
  10681. }).then(function(token) {
  10682. let t = WS.url.split("wss://")[1].split("?")[0];
  10683. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10684. botSkts.push([test]);
  10685. botIDS++;
  10686. });
  10687. }
  10688. };
  10689. test.onmessage = function(message) {
  10690. let data = new Uint8Array(message.data);
  10691. let parsed = window.msgpack.decode(data);
  10692. let type = parsed[0];
  10693. data = parsed[1];
  10694. };
  10695. }
  10696. };
  10697. window.destroyFillBots = function() {
  10698. botSkts.forEach((socket) => {
  10699. socket[0].close();
  10700. });
  10701. botSkts = [];
  10702. };
  10703. window.tryConnectBots = function() {
  10704. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10705. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10706. action: "homepage"
  10707. }).then(function(token) {
  10708. // CONNECT SOCKET:
  10709. botSpawn(token);
  10710. });
  10711. }
  10712. };
  10713. window.destroyBots = function() {
  10714. bots.forEach((botyyyyy) => {
  10715. botyyyyy.closeSocket = true;
  10716. });
  10717. bots = [];
  10718. };
  10719. window.resBuild = function() {
  10720. if (gameObjects.length) {
  10721. gameObjects.forEach((tmp) => {
  10722. tmp.breakObj = false;
  10723. });
  10724. breakObjects = [];
  10725. }
  10726. };
  10727. window.toggleBotsCircle = function() {
  10728. player.circle = !player.circle;
  10729. };
  10730. window.toggleVisual = function() {
  10731. config.anotherVisual = !config.anotherVisual;
  10732. gameObjects.forEach((tmp) => {
  10733. if (tmp.active) {
  10734. tmp.dir = tmp.lastDir;
  10735. }
  10736. });
  10737. };
  10738. window.prepareUI = function(tmpObj) {
  10739. resize();
  10740. // CHAT STUFF:
  10741. var chatBox = document.getElementById("chatBox");
  10742. var chatHolder = document.getElementById("chatHolder");
  10743. var suggestBox = document.createElement("div");
  10744. suggestBox.id = "suggestBox";
  10745.  
  10746. var prevChats = [];
  10747. var prevChatsIndex = 0;
  10748.  
  10749. function toggleChat() {
  10750. if (!usingTouch) {
  10751. if (chatHolder.style.display == "block") {
  10752. if (chatBox.value) {
  10753. sendChat(chatBox.value);
  10754. }
  10755. closeChat();
  10756. } else {
  10757. storeMenu.style.display = "none";
  10758. allianceMenu.style.display = "none";
  10759. chatHolder.style.display = "block";
  10760. chatBox.focus();
  10761. resetMoveDir();
  10762. }
  10763. } else {
  10764. setTimeout(function () {
  10765. var chatMessage = prompt("chat message");
  10766. if (chatMessage) {
  10767. sendChat(chatMessage);
  10768. }
  10769. }, 1);
  10770. }
  10771. chatBox.value = "";
  10772. (() => {
  10773. prevChatsIndex = 0;
  10774. })();
  10775. }
  10776.  
  10777. function closeChat() {
  10778. chatBox.value = "";
  10779. chatHolder.style.display = "none";
  10780. }
  10781.  
  10782. // ACTION BAR:
  10783. UTILS.removeAllChildren(actionBar);
  10784.  
  10785. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10786. (function (i) {
  10787. UTILS.generateElement({
  10788. id: "actionBarItem" + i,
  10789. class: "actionBarItem",
  10790. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10791. onmouseout: function () {
  10792. showItemInfo();
  10793. },
  10794. parent: actionBar
  10795. });
  10796. })(i);
  10797. }
  10798.  
  10799. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10800. (function (i) {
  10801. let tmpCanvas = document.createElement("canvas");
  10802. tmpCanvas.width = tmpCanvas.height = 66;
  10803. let tmpContext = tmpCanvas.getContext("2d");
  10804. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10805. tmpContext.imageSmoothingEnabled = false;
  10806. tmpContext.webkitImageSmoothingEnabled = false;
  10807. tmpContext.mozImageSmoothingEnabled = false;
  10808.  
  10809. if (items.weapons[i]) {
  10810. tmpContext.rotate((Math.PI));
  10811. let tmpSprite = new Image();
  10812. toolSprites[items.weapons[i].src] = tmpSprite;
  10813. tmpSprite.onload = function () {
  10814. this.isLoaded = true;
  10815. let tmpPad = 1 / (this.height / this.width);
  10816. let tmpMlt = (items.weapons[i].iPad || 1);
  10817. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10818. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10819. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10820. tmpContext.globalCompositeOperation = "source-atop";
  10821. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10822. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10823. };
  10824. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10825. let tmpUnit = getEl('actionBarItem' + i);
  10826. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10827. // showItemInfo(items.weapons[i], true);
  10828. // });
  10829. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10830. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10831. });
  10832. UTILS.hookTouchEvents(tmpUnit);
  10833. } else {
  10834. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10835. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10836. tmpContext.globalAlpha = 1;
  10837. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10838. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10839. tmpContext.globalCompositeOperation = "source-atop";
  10840. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10841. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10842. let tmpUnit = getEl('actionBarItem' + i);
  10843. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10844. // showItemInfo(items.list[i - items.weapons.length]);
  10845. // });
  10846. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10847. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10848. });
  10849. UTILS.hookTouchEvents(tmpUnit);
  10850. }
  10851. })(i);
  10852. }
  10853. };
  10854. window.profineTest = function(data) {
  10855. if (data) {
  10856. // VALIDATE NAME:
  10857. let name = data + "";
  10858. name = name.slice(0, config.maxNameLength);
  10859.  
  10860. return name;
  10861. }
  10862. };