super mod v5

Press ` if u need smooth, also im coming out im super gay, slight edit from hax this is wats mod not mine, that him not me

  1. // ==UserScript==
  2. // @name super mod v5
  3. // @match *://*.moomoo.io/*
  4. // @run-at -1
  5. // @grant none
  6. // @icon file:///C:/Users/cgranger9/Downloads/Hax.png
  7. // @namespace -
  8. // @version v5
  9. // @description Press ` if u need smooth, also im coming out im super gay, slight edit from hax this is wats mod not mine, that him not me
  10. // @author wat
  11. // ==/UserScript==
  12. /*
  13. Hey everyone wat here just wanted to let you know I'm gay
  14. */
  15. const PACKET_MAP = {
  16.  
  17. "33": "9",
  18. // "7": "K",
  19. "ch": "6",
  20. "pp": "0",
  21. "13c": "c",
  22.  
  23.  
  24. "f": "9",
  25. "a": "9",
  26. "d": "F",
  27. "G": "z"
  28. }
  29.  
  30. let originalSend = WebSocket.prototype.send;
  31.  
  32. WebSocket.prototype.send = new Proxy(originalSend, {
  33. apply: ((target, websocket, argsList) => {
  34. let decoded = msgpack.decode(new Uint8Array(argsList[0]));
  35.  
  36. if (PACKET_MAP.hasOwnProperty(decoded[0])) {
  37. decoded[0] = PACKET_MAP[decoded[0]];
  38. }
  39.  
  40. return target.apply(websocket, [msgpack.encode(decoded)]);
  41. })
  42. });
  43.  
  44.  
  45. (function() {
  46. 'use strict';
  47.  
  48.  
  49. const firemenu = document.createElement('div');
  50. firemenu.style.position = 'absolute';
  51. firemenu.style.textAlign = 'left';
  52. firemenu.style.display = 'none';
  53. firemenu.style.width = '330px';
  54. firemenu.style.height = '191px';
  55. firemenu.style.top = '30%';
  56. firemenu.style.left = '35%';
  57. firemenu.style.background = 'rgba(0,0,0,0.5)';
  58. firemenu.style.borderRadius = '4px';
  59. firemenu.style.color = '#D8D8D8';
  60. firemenu.style.zIndex = '9999';
  61. firemenu.innerHTML = `
  62.  
  63. `;
  64.  
  65. document.body.prepend(firemenu);
  66.  
  67. const tabs = document.querySelectorAll('.buttons');
  68. const contentContainers = document.querySelectorAll('[id^="con"]');
  69.  
  70. tabs.forEach(function(tab) {
  71. tab.addEventListener('click', function() {
  72. tabs.forEach(function(tab) {
  73. tab.classList.remove('active');
  74. });
  75.  
  76. this.classList.add('active');
  77.  
  78. const tabId = this.id.replace('tab', 'con');
  79. contentContainers.forEach(function(contentContainer) {
  80. contentContainer.style.display = 'none';
  81. });
  82.  
  83. const contentContainer = document.getElementById(tabId);
  84. contentContainer.style.display = 'block';
  85. });
  86. });
  87.  
  88. document.addEventListener('keydown', function(event) {
  89. if (event.key === '=') {
  90. firemenu.style.display = firemenu.style.display === 'none' ? 'block' : 'none';
  91. }
  92. });
  93. })();
  94.  
  95.  
  96. setTimeout(() => {
  97. document.getElementById('loadingText').innerHTML = `<!DOCTYPE html>
  98.  
  99. `;
  100. }, 20);
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107. let editMainMenu = `
  108.  
  109.  
  110.  
  111. `
  112. let founda = false;
  113.  
  114. let scriptTags = document.getElementsByTagName("script");
  115. for (let i = 0; i < scriptTags.length; i++) {
  116. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  117. scriptTags[i].remove();
  118. founda = true;
  119. break;
  120. }
  121. }
  122.  
  123.  
  124. document.addEventListener("keydown", function(event) {
  125. if (event.keyCode === 192) {
  126. const chatHolder = document.getElementById("gameUI");
  127. if (chatHolder) {
  128. const currentDisplay = chatHolder.style.display;
  129. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  130. }
  131. }
  132. });
  133. var styleItem = document.createElement("style");
  134. styleItem.type = "text/css";
  135. styleItem.appendChild(document.createTextNode(`
  136.  
  137. `));
  138. document.head.appendChild(styleItem);
  139.  
  140. window.addEventListener('load', function() {
  141. var allianceButton = document.getElementById('allianceButton');
  142. var storeButton = document.getElementById('storeButton');
  143. if (storeButton) {
  144. storeButton.style.right = '26px';
  145. storeButton.style.top = '420px';
  146. }
  147. if (allianceButton) {
  148. allianceButton.style.right = '26px';
  149. allianceButton.style.top = '479px';
  150. }
  151. });
  152.  
  153. function getEl(id) {
  154. return document.getElementById(id);
  155. }
  156.  
  157.  
  158.  
  159. let newFont = document.createElement("link");
  160. newFont.rel = "stylesheet";
  161. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  162. newFont.type = "text/css";
  163. document.body.append(newFont);
  164.  
  165. let min = document.createElement("script");
  166. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  167. document.body.append(min);
  168. window.oncontextmenu = function() {
  169. return false;
  170. };
  171.  
  172. let config = window.config;
  173.  
  174. // CLIENT:
  175. config.clientSendRate = 9; // Aim Packet Send Rate
  176. config.serverUpdateRate = 9;
  177.  
  178. // UI:
  179. config.deathFadeout = 0;
  180.  
  181. config.playerCapacity = 9999;
  182.  
  183. // CHECK IN SANDBOX:
  184. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  185.  
  186.  
  187. // CUSTOMIZATION:
  188. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  189. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  190. "#8bc373", "#91b2db"
  191. ];
  192. config.weaponVariants = [{
  193. id: 0,
  194. src: "",
  195. xp: 0,
  196. val: 1,
  197. }, {
  198. id: 1,
  199. src: "_g",
  200. xp: 3000,
  201. val: 1.1,
  202. }, {
  203. id: 2,
  204. src: "_d",
  205. xp: 7000,
  206. val: 1.18,
  207. }, {
  208. id: 3,
  209. src: "_r",
  210. poison: true,
  211. xp: 12000,
  212. val: 1.18,
  213. }, {
  214. id: 4,
  215. src: "_e",
  216. poison: true,
  217. heal: true,
  218. xp: 24000,
  219. val: 1.18,
  220. }];
  221.  
  222.  
  223.  
  224.  
  225.  
  226. // VISUAL:
  227. config.anotherVisual = true;
  228. config.useWebGl = false;
  229. config.resetRender = true;
  230.  
  231. function waitTime(timeout) {
  232. return new Promise((done) => {
  233. setTimeout(() => {
  234. done();
  235. }, timeout);
  236. });
  237. }
  238.  
  239. let botSkts = [];
  240.  
  241. // STORAGE:
  242. let canStore;
  243. if (typeof(Storage) !== "undefined") {
  244. canStore = true;
  245. }
  246.  
  247. function saveVal(name, val) {
  248. if (canStore)
  249. localStorage.setItem(name, val);
  250. }
  251.  
  252. function deleteVal(name) {
  253. if (canStore)
  254. localStorage.removeItem(name);
  255. }
  256.  
  257. function getSavedVal(name) {
  258. if (canStore)
  259. return localStorage.getItem(name);
  260. return null;
  261. }
  262.  
  263. // CONFIGS:
  264. let gC = function(a, b) {
  265. try {
  266. let res = JSON.parse(getSavedVal(a));
  267. if (typeof res === "object") {
  268. return b;
  269. } else {
  270. return res;
  271. }
  272. } catch (e) {
  273.  
  274. return b;
  275. }
  276. };
  277.  
  278. function setCommands() {
  279. return {
  280. "help": {
  281. desc: "Show Commands",
  282. action: function(message) {
  283. for (let cmds in commands) {
  284. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  285. }
  286. }
  287. },
  288. "clear": {
  289. desc: "Clear Chats",
  290. action: function(message) {
  291. resetMenuChText();
  292. }
  293. },
  294. "debug": {
  295. desc: "Debug Mod For Development",
  296. action: function(message) {
  297. addDeadPlayer(player);
  298. addMenuChText("Debug", "Done", "#99ee99", 1);
  299. }
  300. },
  301. "play": {
  302. desc: "Play Music ( /play [link] )",
  303. action: function(message) {
  304. let link = message.split(" ");
  305. if (link[1]) {
  306. let audio = new Audio(link[1]);
  307. audio.play();
  308. } else {
  309. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  310. }
  311. }
  312. },
  313. "bye": {
  314. desc: "Leave Game",
  315. action: function(message) {
  316. window.leave();
  317. }
  318. },
  319. };
  320. }
  321.  
  322. function setConfigs() {
  323. return {
  324. killChat: true,
  325. autoBuy: true,
  326. autoBuyEquip: true,
  327. autoPush: true,
  328. revTick: true,
  329. spikeTick: true,
  330. predictTick: true,
  331. smartMove: true,
  332. treealpha:true,
  333. arrayList: true,
  334. alwayinstaspikes: false,
  335. followsync: false,
  336. autoPlace: true,
  337. autoReplace: true,
  338. antiTrap: true,
  339. slowOT: false,
  340. attackDir: false,
  341. showDir: false,
  342. autoRespawn: true
  343. };
  344. }
  345. function arrayList() {
  346. if (!configs.arraylist) {
  347. const verticalMenu = document.getElementById('verticalMenu');
  348. if (verticalMenu) {
  349. verticalMenu.classList.remove('visible');
  350. }
  351. return;
  352. }
  353. }
  354. let commands = setCommands();
  355. let configs = setConfigs();
  356.  
  357. window.removeConfigs = function() {
  358. for (let cF in configs) {
  359. deleteVal(cF, configs[cF]);
  360. }
  361. };
  362.  
  363. for (let cF in configs) {
  364. configs[cF] = gC(cF, configs[cF]);
  365. }
  366.  
  367. // MENU FUNCTIONS:
  368. window.changeMenu = function() {};
  369. window.debug = function() {};
  370. window.wasdMode = function() {};
  371.  
  372. // PAGE 1:
  373. window.startGrind = function() {};
  374.  
  375. // PAGE 3:
  376. window.connectFillBots = function() {};
  377. window.destroyFillBots = function() {};
  378. window.tryConnectBots = function() {};
  379. window.destroyBots = function() {};
  380. window.resBuild = function() {};
  381. window.toggleBotsCircle = function() {};
  382. window.toggleVisual = function() {};
  383.  
  384. // SOME FUNCTIONS:
  385. window.prepareUI = function() {};
  386. window.leave = function() {};
  387.  
  388. class menu {
  389. static init() {
  390. // Create the menu container
  391. const menuContainer = document.createElement("div");
  392. menuContainer.style = `
  393. position: fixed;
  394. top: 20px;
  395. left: 20px;
  396. background-color: rgba(0, 114, 187, 0.5);
  397. border-radius: 10px;
  398. padding: 10px;
  399. width: 600px;
  400. height: 400px;
  401. overflow-y: auto;
  402. box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.5);
  403. `;
  404.  
  405. // Create the menu header
  406. const menuHeader = document.createElement("div");
  407. menuHeader.style = `
  408. font-size: 18px;
  409. font-weight: bold;
  410. color: #fff;
  411. padding: 10px;
  412. border-bottom: 1px solid #444;
  413. `;
  414. menuHeader.innerHTML = "Menu";
  415.  
  416. // Create the menu pages
  417. const menuPages = [];
  418. let currentPage = 0;
  419.  
  420. function addPage() {
  421. const page = document.createElement("div");
  422. page.style = `
  423. padding: 10px;
  424. font-size: 14px;
  425. color: #fff;
  426. `;
  427. menuPages.push(page);
  428. menuContainer.appendChild(page);
  429. }
  430.  
  431. // Add the menu pages
  432. addPage();
  433. addPage();
  434. addPage();
  435.  
  436. // Add the menu items
  437. this.add = function(malformed) {
  438. const menuItem = document.createElement("div");
  439. menuItem.style = `
  440. padding: 10px;
  441. border-bottom: 1px solid #444;
  442. cursor: pointer;
  443. `;
  444. menuItem.innerHTML = malformed.innerHTML;
  445. menuPages[currentPage].appendChild(menuItem);
  446. return menuItem;
  447. };
  448.  
  449. // Add the menu toggle button
  450. const menuToggle = document.createElement("button");
  451. menuToggle.style = `
  452. position: absolute;
  453. top: 10px;
  454. right: 10px;
  455. background-color: #444;
  456. color: #fff;
  457. border: none;
  458. padding: 10px;
  459. font-size: 18px;
  460. cursor: pointer;
  461. `;
  462. menuToggle.innerHTML = "Toggle Menu";
  463. menuToggle.addEventListener("click", () => {
  464. menuContainer.style.left = menuContainer.style.left === "20px"? "-250px" : "20px";
  465. });
  466.  
  467. // Add the menu to the page
  468. document.body.appendChild(menuContainer);
  469. menuContainer.appendChild(menuHeader);
  470. menuContainer.appendChild(menuToggle);
  471. }
  472. }
  473.  
  474. class deadfuturechickenmodrevival {
  475. constructor(flarez, lore) {
  476. this.inGame = false;
  477. this.lover = flarez + lore;
  478. this.baby = "ae86";
  479. this.isBlack = 0;
  480. this.webSocket = undefined;
  481. this.checkBaby = function() {
  482. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  483. if (this.isBlack >= 1) return "bl4cky";
  484. return "noting for you";
  485. };
  486. this.x2 = 0;
  487. this.y2 = 0;
  488. this.chat = "Imagine playing this badass game XDDDDD";
  489. this.summon = function(tmpObj) {
  490. this.x2 = tmpObj.x;
  491. this.y2 = tmpObj.y;
  492. this.chat = tmpObj.name + " ur so bad XDDDD";
  493. };
  494. this.commands = function(cmd) {
  495. cmd == "rv3link" && window.open("https://florr.io/");
  496. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  497. return cmd;
  498. };
  499. this.dayte = "11yearold";
  500. this.memeganoob = "69yearold";
  501. this.startDayteSpawn = function(tmpObj) {
  502. let ratio = setInterval(() => {
  503. this.x2 = tmpObj.x + 20;
  504. this.y2 = tmpObj.y - 20;
  505. this.chat = "UR SO BAD LOL";
  506. if (tmpObj.name == "ae86") {
  507. this.chat = "omg ae86 go run";
  508. setTimeout(() => {
  509. this.inGame = false;
  510. clearInterval(ratio);
  511. }, 1000);
  512. }
  513. }, 1234);
  514. };
  515. this.AntiChickenModV69420 = function(tmpObj) {
  516. return "!c!dc user " + tmpObj.name;
  517. };
  518. }
  519. };
  520. class HtmlAction {
  521. constructor(element) {
  522. this.element = element;
  523. };
  524. add(code) {
  525. if (!this.element) return undefined;
  526. this.element.innerHTML += code;
  527. };
  528. newLine(amount) {
  529. let result = `<br>`;
  530. if (amount > 0) {
  531. result = ``;
  532. for (let i = 0; i < amount; i++) {
  533. result += `<br>`;
  534. }
  535. }
  536. this.add(result);
  537. };
  538. checkBox(setting) {
  539. let newCheck = `<input type = "checkbox"`;
  540. setting.id && (newCheck += ` id = ${setting.id}`);
  541. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  542. setting.class && (newCheck += ` class = ${setting.class}`);
  543. setting.checked && (newCheck += ` checked`);
  544. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  545. newCheck += `>`;
  546. this.add(newCheck);
  547. };
  548. text(setting) {
  549. let newText = `<input type = "text"`;
  550. setting.id && (newText += ` id = ${setting.id}`);
  551. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  552. setting.class && (newText += ` class = ${setting.class}`);
  553. setting.size && (newText += ` size = ${setting.size}`);
  554. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  555. setting.value && (newText += ` value = ${setting.value}`);
  556. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  557. newText += `>`;
  558. this.add(newText);
  559. };
  560. select(setting) {
  561. let newSelect = `<select`;
  562. setting.id && (newSelect += ` id = ${setting.id}`);
  563. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  564. setting.class && (newSelect += ` class = ${setting.class}`);
  565. newSelect += `>`;
  566. for (let options in setting.option) {
  567. newSelect += `<option value = ${setting.option[options].id}`
  568. setting.option[options].selected && (newSelect += ` selected`);
  569. newSelect += `>${options}</option>`;
  570. }
  571. newSelect += `</select>`;
  572. this.add(newSelect);
  573. };
  574. button(setting) {
  575. let newButton = `<button`;
  576. setting.id && (newButton += ` id = ${setting.id}`);
  577. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  578. setting.class && (newButton += ` class = ${setting.class}`);
  579. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  580. newButton += `>`;
  581. setting.innerHTML && (newButton += setting.innerHTML);
  582. newButton += `</button>`;
  583. this.add(newButton);
  584. };
  585. selectMenu(setting) {
  586. let newSelect = `<select`;
  587. if (!setting.id) {
  588. alert("please put id skid");
  589. return;
  590. }
  591. window[setting.id + "Func"] = function() {};
  592. setting.id && (newSelect += ` id = ${setting.id}`);
  593. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  594. setting.class && (newSelect += ` class = ${setting.class}`);
  595. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  596. newSelect += `>`;
  597. let last;
  598. let i = 0;
  599. for (let options in setting.menu) {
  600. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  601. setting.menu[options] && (newSelect += ` checked`);
  602. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  603. i++;
  604. }
  605. newSelect += `</select>`;
  606.  
  607. this.add(newSelect);
  608.  
  609. i = 0;
  610. for (let options in setting.menu) {
  611. window[options + "Func"] = function() {
  612. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  613. saveVal(options, setting.menu[options]);
  614.  
  615. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  616. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  617.  
  618. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  619.  
  620. };
  621. this.checkBox({
  622. id: "check_" + options,
  623. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  624. class: "checkB",
  625. onclick: `window.${options + "Func"}()`,
  626. checked: setting.menu[options]
  627. });
  628. i++;
  629. }
  630.  
  631. last = "check_" + getEl(setting.id).value.split("_")[1];
  632. window[setting.id + "Func"] = function() {
  633. getEl(last).style.display = "none";
  634. last = "check_" + getEl(setting.id).value.split("_")[1];
  635. getEl(last).style.display = "inline-block";
  636.  
  637. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  638.  
  639. };
  640. };
  641. };
  642. class Html {
  643. constructor() {
  644. this.element = null;
  645. this.action = null;
  646. this.divElement = null;
  647. this.startDiv = function(setting, func) {
  648.  
  649. let newDiv = document.createElement("div");
  650. setting.id && (newDiv.id = setting.id);
  651. setting.style && (newDiv.style = setting.style);
  652. setting.class && (newDiv.className = setting.class);
  653. this.element.appendChild(newDiv);
  654. this.divElement = newDiv;
  655.  
  656. let addRes = new HtmlAction(newDiv);
  657. typeof func == "function" && func(addRes);
  658.  
  659. };
  660. this.addDiv = function(setting, func) {
  661.  
  662. let newDiv = document.createElement("div");
  663. setting.id && (newDiv.id = setting.id);
  664. setting.style && (newDiv.style = setting.style);
  665. setting.class && (newDiv.className = setting.class);
  666. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  667. this.divElement = newDiv;
  668.  
  669. let addRes = new HtmlAction(newDiv);
  670. typeof func == "function" && func(addRes);
  671.  
  672. };
  673. };
  674. set(id) {
  675. this.element = getEl(id);
  676. this.action = new HtmlAction(this.element);
  677. };
  678. resetHTML(text) {
  679. if (text) {
  680. this.element.innerHTML = ``;
  681. } else {
  682. this.element.innerHTML = ``;
  683. }
  684. };
  685. setStyle(style) {
  686. this.element.style = style;
  687. };
  688. setCSS(style) {
  689. this.action.add(`<style>` + style + `</style>`);
  690. };
  691. };
  692.  
  693.  
  694.  
  695. let HTML = new Html();
  696.  
  697. let menuDiv = document.createElement("div");
  698. menuDiv.id = "menuDiv";
  699. menuDiv.draggable = true;
  700.  
  701. menuDiv.addEventListener("dragstart", function (e) {
  702. e.dataTransfer.setData("text/plain", "");
  703. });
  704.  
  705. document.addEventListener("dragover", function (e) {
  706. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  707. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  708. });
  709.  
  710. document.body.appendChild(menuDiv);
  711. HTML.set("menuDiv");
  712. HTML.setStyle(`
  713. position: absolute;
  714. left: 700px;
  715. top: 50px;
  716.  
  717. `);
  718. HTML.resetHTML();
  719. HTML.setCSS(`
  720. body {
  721. background-color: rgba(0, 114, 187, 0.5); /* Черный цвет фона */
  722. color: #fff; /* Белый цвет текста */
  723. font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; /* Более роскошный шрифт */
  724. }
  725.  
  726. .menuClass {
  727. color: #fff;
  728. font-size: 22px; /* Увеличенный размер шрифта */
  729. text-align: left;
  730. padding: 20px; /* Увеличенный внутренний отступ */
  731. width: 300px; /* Увеличенная ширина меню */
  732. background-color: #333; /* Темно-серый цвет фона */
  733. border: 2px solid #555; /* Черный цвет рамки */
  734. border-radius: 12px; /* Более сильно скругленные углы */
  735. box-shadow: 0 4px 8px rgba(0,0,0,0.4); /* Тень для выделения */
  736. }
  737.  
  738. .menuC {
  739. display: none;
  740. font-size: 14px; /* Уменьшенный размер шрифта */
  741. max-height: 200px; /* Увеличенная максимальная высота */
  742. overflow-y: auto;
  743. }
  744.  
  745. .menuB {
  746. text-align: center;
  747. background-color: #265f80;
  748. color: #fff;
  749. border: none;
  750. border-radius: 4px;
  751. padding: 4 4px; /* Увеличенный внутренний отступ */
  752. cursor: pointer;
  753. transition: background-color 0.3s ease;
  754. }
  755.  
  756. .menuB:hover {
  757. background-color: #0056b3;
  758. }
  759.  
  760.  
  761.  
  762. .menuB:active {
  763. transform: translateY(1px);
  764. }
  765.  
  766. .customText {
  767. color: #fff;
  768. border: 1px solid #555;
  769. border-radius: 5px;
  770. padding: 2px;
  771. transition: background-color 0.3s ease;
  772. }
  773.  
  774. .customText:focus {
  775. background-color: #444; /* Темно-серый цвет фона при фокусировке */
  776. }
  777.  
  778. .checkB {
  779. cursor: pointer;
  780. }
  781.  
  782. .Cselect {
  783. background-color: #444; /* Темно-серый цвет фона */
  784. color: #fff;
  785. border: 1px solid #555;
  786. border-radius: 66px;
  787. padding: 2px;
  788. }
  789.  
  790. #menuChanger {
  791. position: absolute;
  792. right: 20px; /* Увеличенный отступ справа */
  793. top: 20px; /* Увеличенный отступ сверху */
  794. background-color: transparent;
  795. color: #fff;
  796. border: none;
  797. cursor: pointer;
  798. }
  799.  
  800. #menuChanger:hover {
  801. color: #ccc; /* Светло-серый цвет при наведении */
  802. }
  803.  
  804. /* Скроллбары */
  805. ::-webkit-scrollbar {
  806. width: 8px;
  807. }
  808.  
  809. ::-webkit-scrollbar-track {
  810. background: #333; /* Темно-серый цвет фона */
  811. }
  812.  
  813. ::-webkit-scrollbar-thumb {
  814. background: #666; /* Светло-серый цвет скроллбара */
  815. border-radius: 4px;
  816. }
  817.  
  818. ::-webkit-scrollbar-thumb:hover {
  819. background: #999; /* Более светлый цвет при наведении */
  820. }
  821.  
  822. /* Добавление узоров на задний фон */
  823. body {
  824. background-image: url('https://www.transparenttextures.com/patterns/asfalt-dark.png'); /* Использование узора */
  825. }
  826.  
  827. `);
  828. HTML.startDiv({
  829. id: "menuHeadLine",
  830. class: "menuClass"
  831. }, (html) => {
  832. html.add(`:3`);
  833. html.button({
  834. id: "menuChanger",
  835. class: "material-icons",
  836. innerHTML: `sync`,
  837. onclick: "window.changeMenu()"
  838. });
  839. HTML.addDiv({
  840. id: "menuButtons",
  841. style: "display: block; overflow-y: visible;",
  842. class: "menuC",
  843. appendID: "menuHeadLine"
  844. }, (html) => {
  845. html.button({
  846. class: "menuB",
  847. innerHTML: "Debug",
  848. onclick: "window.debug()"
  849. });
  850. });
  851. HTML.addDiv({
  852. id: "menuMain",
  853. style: "display: block",
  854. class: "menuC",
  855. appendID: "menuHeadLine"
  856. }, (html) => {
  857. html.button({
  858. class: "menuB",
  859. innerHTML: "Dagger Optimisation",
  860. onclick: "window.wasdMode()"
  861. });
  862.  
  863. html.newLine();
  864. html.add(`Auto-Grinder: `);
  865. html.checkBox({
  866. id: "weaponGrind",
  867. class: "checkB",
  868. onclick: "window.startGrind()"
  869. });
  870. html.newLine(2);
  871. HTML.addDiv({
  872. style: "font-size: 30px; color: #4f4f4f;",
  873. appendID: "menuMain"
  874. }, (html) => {
  875. html.add(`_______________`);
  876. });
  877. html.add(`Anti-Push:`);
  878. html.checkBox({
  879. id: "antipush",
  880. class: "checkB",
  881. checked: true
  882. });
  883. html.newLine();
  884. html.add(`Smart AntiPush(Beta):`);
  885. html.checkBox({
  886. id: "antipush2",
  887. class: "checkB",
  888. checked: true
  889. });
  890. html.newLine();
  891. html.add(`Killchat (beta): `);
  892. html.text({ id: "killchat", class: "customText", value: "ez", size: "20em", maxLength: "30" });
  893. html.newLine();
  894. html.add(`Auto-Heal:`);
  895. html.checkBox({
  896. id: "healingBeta",
  897. class: "checkB",
  898. checked: true
  899. });
  900. html.newLine();
  901. });
  902. HTML.addDiv({
  903. id: "menuConfig",
  904. class: "menuC",
  905. appendID: "menuHeadLine"
  906. }, (html) => {
  907. html.add(`AutoPlacer Placement Tick: `);
  908. html.text({
  909. id: "autoPlaceTick",
  910. class: "customText",
  911. value: "2",
  912. size: "2em",
  913. maxLength: "1"
  914. });
  915. html.newLine();
  916. html.add(`Configs: `);
  917. html.selectMenu({
  918. id: "configsChanger",
  919. class: "Cselect",
  920. menu: configs
  921. });
  922. html.newLine();
  923. html.add('CameraType: ');
  924. html.select({
  925. id: "visualType",
  926. class: "Cselect",
  927. option: {
  928. 'FreeCamera': {
  929. id: 'Cam+',
  930. },
  931. 'Cam 0': {
  932. id: 'Cam0',
  933. selected: true
  934. },
  935. 'Cam 1': {
  936. id: 'Cam1',
  937.  
  938. },
  939. 'Cam 2': {
  940. id: 'Cam2',
  941.  
  942. },
  943. 'Cam 3': {
  944. id: 'Cam3',
  945. },
  946. 'Cam 4': {
  947. id: 'Cam4',
  948. }
  949. }
  950. });
  951.  
  952. html.newLine();
  953. html.add(`InstaKill Type: `);
  954. html.select({
  955. id: "instaType",
  956. class: "Cselect",
  957. option: {
  958. OneShot: {
  959. id: "oneShot",
  960. selected: true
  961. },
  962. Spammer: {
  963. id: "spammer"
  964. }
  965. }
  966. });
  967. html.newLine();
  968. html.add(`Kill sound effect (beta): `);
  969. html.select({
  970. id: "killsounds", class: "Cselect", option: {
  971. "None": {
  972. id: "killsoundnone",
  973. selected: true
  974. },
  975. "Skibidi dom dom": {
  976. id: "killsoundskibidi",
  977. },
  978. "eZ": {
  979. id: "killsoundez",
  980. },
  981. "Veorra": {
  982. id: "killsoundveorra",
  983. },
  984.  
  985. }
  986. });
  987. html.newLine();
  988. html.add(`AntiBull Type: `);
  989. html.select({
  990. id: "antiBullType",
  991. class: "Cselect",
  992. option: {
  993. "Disable AntiBull": {
  994. id: "noab",
  995. selected: true
  996. },
  997. "When Reloaded": {
  998. id: "abreload",
  999. },
  1000. "Primary Reloaded": {
  1001. id: "abalway"
  1002. }
  1003. }
  1004. });
  1005. html.newLine();
  1006. html.add(`Backup Nobull Insta: `);
  1007. html.checkBox({
  1008. id: "backupNobull",
  1009. class: "checkB",
  1010. checked: true
  1011. });
  1012. html.newLine();
  1013. html.add(`Turret Gear Combat Assistance: `);
  1014. html.checkBox({
  1015. id: "turretCombat",
  1016. class: "checkB"
  1017. });
  1018. html.newLine();
  1019. html.add(`Safe AntiSpikeTick: `);
  1020. html.checkBox({
  1021. id: "safeAntiSpikeTick",
  1022. class: "checkB",
  1023. checked: true
  1024. });
  1025. html.newLine();
  1026. html.add(`Pre placer Type (beta): `);
  1027. html.select({
  1028. id: "preplacerType", class: "Cselect", option: {
  1029. Spike: {
  1030. id: "preplacerspike",
  1031. selected: true
  1032. },
  1033. Trap: {
  1034. id: "preplacertrap"
  1035. }
  1036. }
  1037. });
  1038. html.newLine();
  1039. html.add(`FPS Boost: `);
  1040. html.checkBox({
  1041. id: "FPSBoostBeta",
  1042. class: "checkB",
  1043. checked: true
  1044. });
  1045. html.newLine();
  1046. html.add(`pvpMode:`);
  1047. html.checkBox({
  1048. id: "avoidSpikes",
  1049. class: "checkB",
  1050. checked: true
  1051. });
  1052. html.newLine();
  1053. html.add(`Sync:`);
  1054. html.checkBox({
  1055. id: "sync",
  1056. class: "checkB",
  1057. checked: true
  1058. });
  1059. html.newLine();
  1060. html.add(`Auto Insta:`);
  1061. html.checkBox({
  1062. id: "autoInsta",
  1063. class: "checkB",
  1064. checked: true
  1065. });
  1066. html.newLine();
  1067. html.add(`AutoChat(New):`);
  1068. html.checkBox({
  1069. id: "autochat",
  1070. class: "checkB",
  1071. checked: true
  1072. });
  1073. html.newLine();
  1074. html.add(`Weird visual:`);
  1075. html.checkBox({
  1076. id: "novisu",
  1077. class: "checkB",
  1078. });
  1079.  
  1080. html.newLine();
  1081. html.add(`antikisspike:`);
  1082. html.checkBox({
  1083. id: "antikisspike",
  1084. class: "checkB",
  1085. checked: true
  1086. });
  1087. html.newLine();
  1088. html.add(`Heal Buffed:`);
  1089. html.checkBox({
  1090. id: "chkv1",
  1091. class: "checkB",
  1092.  
  1093. });
  1094.  
  1095. html.newLine();
  1096. html.add(`autochat2:`);
  1097. html.checkBox({
  1098. id: "autochats",
  1099. class: "checkB",
  1100. checked: true
  1101. });
  1102. html.newLine();
  1103. html.add(`Show/Hide LeaderBoard(New):`);
  1104. html.checkBox({
  1105. id: "hideleaderboard",
  1106. class: "checkB",
  1107. checked: true
  1108. });
  1109. html.newLine();
  1110. html.add(`boost tick distance`);
  1111. html.text({ id: "boosttickdistance", class: "customText", value: "200", size: "4em", maxLength: "3" });
  1112.  
  1113.  
  1114. html.newLine();
  1115. });
  1116. HTML.addDiv({
  1117. id: "menuOther",
  1118. class: "menuC",
  1119. appendID: "menuHeadLine"
  1120. }, (html) => {
  1121. html.button({
  1122. class: "menuB",
  1123. innerHTML: "Connect Bots",
  1124. onclick: "window.tryConnectBots()"
  1125. });
  1126. html.button({
  1127. class: "menuB",
  1128. innerHTML: "Disconnect Bots",
  1129. onclick: "window.destroyBots()"
  1130. });
  1131. html.newLine();
  1132. html.button({
  1133. class: "menuB",
  1134. innerHTML: "Connect FBots",
  1135. onclick: "window.connectFillBots()"
  1136. });
  1137. html.button({
  1138. class: "menuB",
  1139. innerHTML: "Disconnect FBots",
  1140. onclick: "window.destroyFillBots()"
  1141. });
  1142. html.newLine();
  1143. html.button({
  1144. class: "menuB",
  1145. innerHTML: "Reset Break Objects",
  1146. onclick: "window.resBuild()"
  1147. });
  1148. html.newLine();
  1149. html.add(`Break Objects Range: `);
  1150. html.text({
  1151. id: "breakRange",
  1152. class: "customText",
  1153. value: "700",
  1154. size: "3em",
  1155. maxLength: "4"
  1156. });
  1157. html.newLine();
  1158. html.add(`Predict Movement Type: `);
  1159. html.select({
  1160. id: "predictType",
  1161. class: "Cselect",
  1162. option: {
  1163. "Disable Render": {
  1164. id: "disableRender",
  1165. selected: true
  1166. },
  1167. "X/Y and 2": {
  1168. id: "pre2",
  1169. },
  1170. "X/Y and 3": {
  1171. id: "pre3"
  1172. }
  1173. }
  1174. });
  1175. html.newLine();
  1176. html.add(`Render Placers: `);
  1177. html.checkBox({
  1178. id: "placeVis",
  1179. class: "checkB",
  1180. checked: true
  1181.  
  1182. });
  1183. html.newLine();
  1184. html.add(`Bot Mode: `);
  1185. html.select({
  1186. id: "mode",
  1187. class: "Cselect",
  1188. option: {
  1189. "Clear Building": {
  1190. id: "clear",
  1191. selected: true
  1192. },
  1193. "Sync": {
  1194. id: "zync",
  1195. },
  1196. "Search": {
  1197. id: "zearch"
  1198. },
  1199. "Clear Everything": {
  1200. id: "fuckemup"
  1201. },
  1202. "Flex": {
  1203. id: "flex"
  1204. }
  1205. }
  1206. });
  1207. html.newLine(2);
  1208. html.button({
  1209. class: "menuB",
  1210. innerHTML: "Toggle Fbots Circle",
  1211. onclick: "window.toggleBotsCircle()"
  1212. });
  1213. html.newLine();
  1214. html.add(`Circle Rad: `);
  1215. html.text({
  1216. id: "circleRad",
  1217. class: "customText",
  1218. value: "200",
  1219. size: "3em",
  1220. maxLength: "4"
  1221. });
  1222. html.newLine();
  1223. html.add(`Rad Speed: `);
  1224. html.text({
  1225. id: "radSpeed",
  1226. class: "customText",
  1227. value: "0.1",
  1228. size: "2em",
  1229. maxLength: "3"
  1230. });
  1231. html.newLine();
  1232. html.add(`Bot Zetup Type: `);
  1233. html.select({
  1234. id: "setup",
  1235. class: "Cselect",
  1236. option: {
  1237. "Dagger Musket": {
  1238. id: "dm",
  1239. selected: true
  1240. },
  1241. "Katana Hammer": {
  1242. id: "kh",
  1243. },
  1244. "Dagger Repeater-Crossbow": {
  1245. id: "dr"
  1246. },
  1247. "Zhort-Zword Muzket": {
  1248. id: "zd"
  1249. }
  1250. }
  1251. });
  1252. html.newLine(2);
  1253. html.add(`Cross World: `);
  1254. html.checkBox({
  1255. id: "funni",
  1256. class: "checkB"
  1257. });
  1258. html.newLine();
  1259. html.button({
  1260. class: "menuB",
  1261. innerHTML: "Toggle Another Visual",
  1262. onclick: "window.toggleVisual()"
  1263. });
  1264. html.newLine();
  1265. });
  1266. });
  1267.  
  1268. let menuChatDiv = document.createElement("div");
  1269. menuChatDiv.id = "menuChatDiv";
  1270. document.body.appendChild(menuChatDiv);
  1271. HTML.set("menuChatDiv");
  1272. HTML.setStyle(`
  1273. position: absolute;
  1274. display: none;
  1275. left: 0px;
  1276. top: 0px;
  1277. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0); //0.65
  1278. `);
  1279. HTML.resetHTML();
  1280. HTML.setCSS(`
  1281. .chDiv {
  1282. color: #fff;
  1283. padding: 10px;
  1284. width: 400px;
  1285. height: 250px;
  1286. background-color: rgba(34, 34, 34, 0.7);
  1287. font-family: "Courier New", monospace;
  1288. backdrop-filter: blur(2px);
  1289. border-radius: 0 0 4px 0;
  1290. }
  1291.  
  1292. .chMainDiv {
  1293. font-family: Ubuntu;
  1294. font-size: 16px;
  1295. max-height: 215px;
  1296. overflow-y: scroll;
  1297. -webkit-touch-callout: none;
  1298. -webkit-user-select: none;
  1299. -khtml-user-select: none;
  1300. -moz-user-select: none;
  1301. -ms-user-select: none;
  1302. user-select: none;
  1303. overflow-x: hidden;
  1304. scrollbar-width: thin;
  1305. scrollbar-color: rgba(255, 255, 255, 0.5) rgba(255, 255, 255, 0.1);
  1306. }
  1307.  
  1308. .chMainDiv::-webkit-scrollbar {
  1309. width: 8px;
  1310. }
  1311.  
  1312. /* Handle */
  1313. .chMainDiv::-webkit-scrollbar-thumb {
  1314. background-color: rgba(255, 255, 255, 0.5);
  1315. border-radius: 10px;
  1316. }
  1317.  
  1318. /* Handle on hover */
  1319. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1320. background-color: rgba(255, 255, 255, 0.7);
  1321. }
  1322.  
  1323. .chMainBox {
  1324. position: absolute;
  1325. left: 5px;
  1326. bottom: 10px;
  1327. width: 400px;
  1328. height: 25px;
  1329. background-color: rgba(255, 255, 255, 0.1);
  1330. -webkit-border-radius: 4px;
  1331. -moz-border-radius: 4px;
  1332. border-radius: 4px;
  1333. color: rgba(255, 255, 255, 0.75);
  1334. font-family: Arial;
  1335. font-size: 12px;
  1336. border: none;
  1337. outline: none;
  1338. }
  1339. `);
  1340. HTML.startDiv({id: "mChDiv", class: "chDiv"}, (html) => {
  1341. HTML.addDiv({id: "mChMain", class: "chMainDiv", appendID: "mChDiv"}, (html) => {
  1342. });
  1343. html.text({id: "mChBox", class: "chMainBox", placeHolder: `To chat click here or press / key`});
  1344. });
  1345.  
  1346.  
  1347. let menuChats = getEl("mChMain");
  1348. let menuChatBox = getEl("mChBox");
  1349. let menuCBFocus = false;
  1350. let menuChCounts = 0;
  1351.  
  1352. menuChatBox.value = "";
  1353. menuChatBox.addEventListener("focus", () => {
  1354. menuCBFocus = true;
  1355. });
  1356. menuChatBox.addEventListener("blur", () => {
  1357. menuCBFocus = false;
  1358. });
  1359.  
  1360. function addMenuChText(name, message, color, noTimer) {
  1361. HTML.set("menuChatDiv");
  1362. color = color || "white";
  1363. let time = new Date();
  1364. let min = time.getMinutes();
  1365. let hour = time.getHours();
  1366. let text = ``;
  1367. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1368. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1369. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1370. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1371. html.add(text);
  1372. });
  1373. menuChats.scrollTop = menuChats.scrollHeight;
  1374. menuChCounts++;
  1375. }
  1376. function chch(name, message, color, noTimer) {
  1377. HTML.set("menuChatDiv");
  1378. color = color || "white";
  1379. let time = new Date();
  1380. let text = ``;
  1381. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1382. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1383. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1384. html.add(text);
  1385. });
  1386. menuChats.scrollTop = menuChats.scrollHeight;
  1387. menuChCounts++;
  1388. }
  1389.  
  1390. function resetMenuChText() {
  1391. menuChats.innerHTML = ``;
  1392. menuChCounts = 0;
  1393. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1394. }
  1395. resetMenuChText();
  1396. let menuIndex = 0;
  1397. let menus = ["menuMain", "menuConfig", "menuOther"];
  1398. window.changeMenu = function() {
  1399. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1400. menuIndex++;
  1401. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1402. };
  1403. let mStatus = document.createElement("div");
  1404. mStatus.id = "status";
  1405. getEl("gameUI").appendChild(mStatus);
  1406. HTML.set("status");
  1407. HTML.setStyle(`
  1408. display: ;
  1409. position: absolute;
  1410. color: #ddd;
  1411. font: 15px Hammersmith One;
  1412. top: 300px;
  1413. left: 5px; /* Thay đổi giá trị từ 'right' thành 'left' */
  1414. width: 180px;
  1415. border: 2px solid #0000;
  1416. padding: 10px;
  1417. background-color: rgba(0, 0, 0, 0.2);
  1418. border-radius: 10px; /* Giá trị này có thể được điều chỉnh tùy thuộc vào mức độ bo tròn mong muốn */
  1419.  
  1420. `);
  1421. HTML.resetHTML();
  1422. HTML.setCSS(`
  1423. .sizing {
  1424. font-size: 15px;
  1425. }
  1426. .mod {
  1427. font-size: 15px;
  1428. display: inline-block;
  1429. margin-bottom: 5px;
  1430. }
  1431. #status div {
  1432. margin-bottom: 5px;
  1433. }
  1434. `);
  1435. HTML.startDiv({
  1436. id: "uehmod",
  1437. class: "sizing"
  1438. }, (html) => {
  1439. html.add(`Ping: `);
  1440. HTML.addDiv({
  1441. id: "pingFps",
  1442. class: "mod",
  1443. appendID: "uehmod"
  1444. }, (html) => {
  1445. html.add("None");
  1446. });
  1447.  
  1448. });
  1449.  
  1450. /*function modLog() {
  1451. let logs = [];
  1452. for (let i = 0; i < arguments.length; i++) {
  1453. logs.push(arguments[i]);
  1454. }
  1455. getEl("modLog").innerHTML = logs;
  1456. }*/
  1457.  
  1458. let openMenu = false;
  1459.  
  1460. let WS = undefined;
  1461. let socketID = undefined;
  1462.  
  1463. let useWasd = false;
  1464. let secPacket = 0;
  1465. let secMax = 120;
  1466. let secTime = 1000;
  1467. let firstSend = {
  1468. sec: false
  1469. };
  1470. let game = {
  1471. tick: 0,
  1472. tickQueue: [],
  1473. tickBase: function(set, tick) {
  1474. if (this.tickQueue[this.tick + tick]) {
  1475. this.tickQueue[this.tick + tick].push(set);
  1476. } else {
  1477. this.tickQueue[this.tick + tick] = [set];
  1478. }
  1479. },
  1480. tickRate: (1000 / config.serverUpdateRate),
  1481. tickSpeed: 0,
  1482. lastTick: performance.now()
  1483. };
  1484. let modConsole = [];
  1485.  
  1486. let dontSend = false;
  1487. let fpsTimer = {
  1488. last: 0,
  1489. time: 0,
  1490. ltime: 0
  1491. }
  1492. let lastMoveDir = undefined;
  1493. let lastsp = ["cc", 1, "__proto__"];
  1494. WebSocket.prototype.max
  1495. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1496. WebSocket.prototype.send = function(message) {
  1497. if (!WS) {
  1498. WS = this;
  1499. WS.addEventListener("message", function(msg) {
  1500. getMessage(msg);
  1501. });
  1502. WS.addEventListener("close", (event) => {
  1503. if (event.code == 4001) {
  1504. window.location.reload();
  1505. }
  1506. });
  1507. }
  1508. if (WS == this) {
  1509. dontSend = false;
  1510.  
  1511. // EXTRACT DATA ARRAY:
  1512. let data = new Uint8Array(message);
  1513. let parsed = window.msgpack.decode(data);
  1514. let type = parsed[0];
  1515. data = parsed[1];
  1516.  
  1517. // SEND MESSAGE:
  1518. if (type == "6") {
  1519.  
  1520. if (data[0]) {
  1521. // ANTI PROFANITY:
  1522. 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", ];
  1523. let tmpString;
  1524. profanity.forEach((profany) => {
  1525. if (data[0].indexOf(profany) > -1) {
  1526. tmpString = "";
  1527. for (let i = 0; i < profany.length; ++i) {
  1528. if (i == 1) {
  1529. tmpString += String.fromCharCode(0);
  1530. }
  1531. tmpString += profany[i];
  1532. }
  1533. let re = new RegExp(profany, "g");
  1534. data[0] = data[0].replace(re, tmpString);
  1535. }
  1536. });
  1537.  
  1538. // FIX CHAT:
  1539. data[0] = data[0].slice(0, 30);
  1540. }
  1541.  
  1542. } else if (type == "L") {
  1543. // MAKE SAME CLAN:
  1544. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1545. data[0] = data[0].slice(0, 7);
  1546. } else if (type == "M") {
  1547. // APPLY CYAN COLOR:
  1548. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1549. data[0].moofoll = true;
  1550. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1551. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1552. } else if (type == "D") {
  1553. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1554. dontSend = true;
  1555. } else {
  1556. my.lastDir = data[0];
  1557. }
  1558. } else if (type == "d") {
  1559. if (!data[2]) {
  1560. dontSend = true;
  1561. } else {
  1562. if (![null, undefined].includes(data[1])) {
  1563. my.lastDir = data[1];
  1564. }
  1565. }
  1566. } else if (type == "K") {
  1567. if (!data[1]) {
  1568. dontSend = true;
  1569. }
  1570. } else if (type == "S") {
  1571. instaC.wait = !instaC.wait;
  1572. dontSend = true;
  1573. } else if (type == "a") {
  1574. if (data[1]) {
  1575. if (player.moveDir == data[0]) {
  1576. dontSend = true;
  1577. }
  1578. player.moveDir = data[0];
  1579. } else {
  1580. dontSend = true;
  1581. }
  1582. }
  1583. if (!dontSend) {
  1584. let binary = window.msgpack.encode([type, data]);
  1585. this.nsend(binary);
  1586.  
  1587. // START COUNT:
  1588. if (!firstSend.sec) {
  1589. firstSend.sec = true;
  1590. setTimeout(() => {
  1591. firstSend.sec = false;
  1592. secPacket = 0;
  1593. }, secTime);
  1594. }
  1595.  
  1596. secPacket++;
  1597. }
  1598. } else {
  1599. this.nsend(message);
  1600. }
  1601. }
  1602.  
  1603. var modules = {};
  1604. var mode = true;
  1605. var Bots = [];
  1606. var BotSids = [];
  1607.  
  1608. var initialWebSocket = new WebSocket("wss://hulking-zippy-paneer.glitch.me");
  1609. // Define an array of server socket names
  1610. var serversockets = [
  1611. "alike-longing-dessert",
  1612.  
  1613. ];
  1614. var webSockets = [];
  1615. for(var i = 0; i < serversockets.length; ++i) {
  1616. var wss = new WebSocket("wss://" + serversockets[i] + ".glitch.me");
  1617. webSockets.push(wss);
  1618.  
  1619. wss.addEventListener("message", function(data) {
  1620. data = data.data;
  1621. data = JSON.parse(data);
  1622.  
  1623. if(data[0] == "update_bots_location") {
  1624. Bots = data[1];
  1625. BotSids = [];
  1626.  
  1627. Bots.forEach((bot) => {
  1628. BotSids.push(bot.sid);
  1629. })
  1630. console.log(Bots);
  1631. }
  1632. });
  1633. }
  1634. function sendMessage(message) {
  1635. webSockets.forEach((ws) => {
  1636. if(ws.readyState === WebSocket.OPEN) {
  1637. ws.send(JSON.stringify(message));
  1638. }
  1639. });
  1640. }
  1641. var lala;
  1642. var websocketInfo, uril;
  1643.  
  1644.  
  1645.  
  1646. function spawnBots() {
  1647. (lala = async function () {
  1648. return await new Promise((t) => {
  1649. window.grecaptcha
  1650. .execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  1651. action: "homepage",
  1652. })
  1653. .then(function (n) {
  1654. t(encodeURIComponent(n));
  1655. });
  1656. });
  1657. });
  1658. io.send([
  1659. "allahuakbarmotherfucker",
  1660. "spawn_bots",
  1661. "wss://" + websocketInfo + "?token=re:" + lala,
  1662. ]);
  1663. }
  1664.  
  1665. function packet(type) {
  1666. // EXTRACT DATA ARRAY:
  1667. let data = Array.prototype.slice.call(arguments, 1);
  1668.  
  1669. // SEND MESSAGE:
  1670. let binary = window.msgpack.encode([type, data]);
  1671. WS.send(binary);
  1672. }
  1673.  
  1674. function origPacket(type) {
  1675. // EXTRACT DATA ARRAY:
  1676. let data = Array.prototype.slice.call(arguments, 1);
  1677.  
  1678. // SEND MESSAGE:
  1679. let binary = window.msgpack.encode([type, data]);
  1680. WS.nsend(binary);
  1681. }
  1682.  
  1683. window.leave = function() {
  1684. origPacket("kys", {
  1685. "frvr is so bad": true,
  1686. "sidney is too good": true,
  1687. "dev are too weak": true,
  1688. });
  1689. };
  1690. //...lol
  1691. let io = {
  1692. send: packet
  1693. };
  1694.  
  1695. function getMessage(message) {
  1696. let data = new Uint8Array(message.data);
  1697. let parsed = window.msgpack.decode(data);
  1698. let type = parsed[0];
  1699. data = parsed[1];
  1700. let events = {
  1701. A: setInitData, // id: setInitData,
  1702. //B: disconnect,
  1703. C: setupGame, // 1: setupGame,
  1704. D: addPlayer, // 2: addPlayer,
  1705. E: removePlayer, // 4: removePlayer,
  1706. a: updatePlayers, // 33: updatePlayers,
  1707. G: updateLeaderboard, // 5: updateLeaderboard,here
  1708. H: loadGameObject, // 6: loadGameObject,
  1709. I: loadAI, // a: loadAI,
  1710. J: animateAI, // aa: animateAI,
  1711. K: gatherAnimation, // 7: gatherAnimation,
  1712. L: wiggleGameObject, // 8: wiggleGameObject,
  1713. M: shootTurret, // sp: shootTurret,
  1714. N: updatePlayerValue, // 9: updatePlayerValue,
  1715. O: updateHealth, // h: updateHealth,//here
  1716. P: killPlayer, // 11: killPlayer,
  1717. Q: killObject, // 12: killObject,
  1718. R: killObjects, // 13: killObjects,
  1719. S: updateItemCounts, // 14: updateItemCounts,
  1720. T: updateAge, // 15: updateAge,
  1721. U: updateUpgrades, // 16: updateUpgrades,
  1722. V: updateItems, // 17: updateItems,
  1723. X: addProjectile, // 18: addProjectile,
  1724. // Y: remProjectile, // 19: remProjectile,
  1725. //Z: serverShutdownNotice,
  1726. //0: addAlliance,
  1727. //1: deleteAlliance,
  1728. 2: allianceNotification, // an: allianceNotification,
  1729. 3: setPlayerTeam, // st: setPlayerTeam,
  1730. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1731. 5: updateStoreItems, // us: updateStoreItems,
  1732. 6: receiveChat, // ch: receiveChat,
  1733. 7: updateMinimap, // mm: updateMinimap,
  1734. 8: showText, // t: showText,
  1735. 9: pingMap, // p: pingMap,
  1736. 0: pingSocketResponse,
  1737. };
  1738. if (type == "io-init") {
  1739. socketID = data[0];
  1740. } else {
  1741. if (events[type]) {
  1742. events[type].apply(undefined, data);
  1743. }
  1744. }
  1745. }
  1746.  
  1747. // MATHS:
  1748. Math.lerpAngle = function(value1, value2, amount) {
  1749. let difference = Math.abs(value2 - value1);
  1750. if (difference > Math.PI) {
  1751. if (value1 > value2) {
  1752. value2 += Math.PI * 2;
  1753. } else {
  1754. value1 += Math.PI * 2;
  1755. }
  1756. }
  1757. let value = value2 + ((value1 - value2) * amount);
  1758. if (value >= 0 && value <= Math.PI * 2) return value;
  1759. return value % (Math.PI * 2);
  1760. };
  1761.  
  1762. // REOUNDED RECTANGLE:
  1763. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1764. if (w < 2 * r) r = w / 2;
  1765. if (h < 2 * r) r = h / 2;
  1766. if (r < 0)
  1767. r = 0;
  1768. this.beginPath();
  1769. this.moveTo(x + r, y);
  1770. this.arcTo(x + w, y, x + w, y + h, r);
  1771. this.arcTo(x + w, y + h, x, y + h, r);
  1772. this.arcTo(x, y + h, x, y, r);
  1773. this.arcTo(x, y, x + w, y, r);
  1774. this.closePath();
  1775. return this;
  1776. };
  1777.  
  1778. // GLOBAL VALUES:
  1779. function resetMoveDir() {
  1780. keys = {};
  1781. io.send("e");
  1782. }
  1783.  
  1784. let allChats = [];
  1785. let ticks = {
  1786. tick: 0,
  1787. delay: 0,
  1788. time: [],
  1789. manage: [],
  1790. };
  1791. let ais = [];
  1792. let players = [];
  1793. let alliances = [];
  1794. let alliancePlayers = [];
  1795. let allianceNotifications = [];
  1796. let gameObjects = [];
  1797. let liztobj = [];
  1798. let projectiles = [];
  1799. let deadPlayers = [];
  1800.  
  1801. let breakObjects = [];
  1802.  
  1803. let player;
  1804. let playerSID;
  1805. let tmpObj;
  1806.  
  1807. let enemy = [];
  1808. let nears = [];
  1809. let near = [];
  1810.  
  1811. let my = {
  1812. reloaded: false,
  1813. waitHit: 0,
  1814. autoAim: false,
  1815. revAim: false,
  1816. ageInsta: true,
  1817. reSync: false,
  1818. bullTick: 0,
  1819. anti0Tick: 0,
  1820. antiSync: false,
  1821. safePrimary: function(tmpObj) {
  1822. return [0, 8].includes(tmpObj.primaryIndex);
  1823. },
  1824. safeSecondary: function(tmpObj) {
  1825. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1826. },
  1827. lastDir: 0,
  1828. autoPush: false,
  1829. pushData: {}
  1830. }
  1831.  
  1832. // FIND OBJECTS BY ID/SID:
  1833. function findID(tmpObj, tmp) {
  1834. return tmpObj.find((THIS) => THIS.id == tmp);
  1835. }
  1836.  
  1837. function findSID(tmpObj, tmp) {
  1838. return tmpObj.find((THIS) => THIS.sid == tmp);
  1839. }
  1840.  
  1841. function findPlayerByID(id) {
  1842. return findID(players, id);
  1843. }
  1844.  
  1845. function findPlayerBySID(sid) {
  1846. return findSID(players, sid);
  1847. }
  1848.  
  1849. function findAIBySID(sid) {
  1850. return findSID(ais, sid);
  1851. }
  1852.  
  1853. function findObjectBySid(sid) {
  1854. return findSID(gameObjects, sid);
  1855. }
  1856.  
  1857. function findProjectileBySid(sid) {
  1858. return findSID(gameObjects, sid);
  1859. }
  1860.  
  1861. let adCard = getEl("adCard");
  1862. adCard.remove();
  1863. let promoImageHolder = getEl("promoImgHolder");
  1864. promoImageHolder.remove();
  1865.  
  1866. let chatButton = getEl("chatButton");
  1867. chatButton.remove();
  1868. let gameCanvas = getEl("gameCanvas");
  1869. let mainContext = gameCanvas.getContext("2d");
  1870. let mapDisplay = getEl("mapDisplay");
  1871. let mapContext = mapDisplay.getContext("2d");
  1872. mapDisplay.width = 300;
  1873. mapDisplay.height = 300;
  1874. let storeMenu = getEl("storeMenu");
  1875. let storeHolder = getEl("storeHolder");
  1876. let upgradeHolder = getEl("upgradeHolder");
  1877. let upgradeCounter = getEl("upgradeCounter");
  1878. let chatBox = getEl("chatBox");
  1879. chatBox.autocomplete = "off";
  1880. chatBox.style.textAlign = "center";
  1881. chatBox.style.width = "18em";
  1882. let chatHolder = getEl("chatHolder");
  1883. let actionBar = getEl("actionBar");
  1884. let leaderboardData = getEl("leaderboardData");
  1885. let itemInfoHolder = getEl("itemInfoHolder");
  1886. let menuCardHolder = getEl("menuCardHolder");
  1887. let mainMenu = getEl("mainMenu");
  1888. let diedText = getEl("diedText");
  1889. let screenWidth;
  1890. let screenHeight;
  1891. let maxScreenWidth = config.maxScreenWidth;
  1892. let maxScreenHeight = config.maxScreenHeight;
  1893. let pixelDensity = 1;
  1894. let delta;
  1895. let now;
  1896. let lastUpdate = performance.now();
  1897. let camX;
  1898. let camY;
  1899. let tmpDir;
  1900. let mouseX = 0;
  1901. let mouseY = 0;
  1902. let allianceMenu = getEl("allianceMenu");
  1903. let waterMult = 1;
  1904. let waterPlus = 0;
  1905.  
  1906. let outlineColor = "#525252";
  1907. let darkOutlineColor = "#3d3f42";
  1908. let outlineWidth = 5.5;
  1909.  
  1910. let firstSetup = true;
  1911. let keys = {};
  1912. let moveKeys = {
  1913. 87: [0, -1],
  1914. 38: [0, -1],
  1915. 83: [0, 1],
  1916. 40: [0, 1],
  1917. 65: [-1, 0],
  1918. 37: [-1, 0],
  1919. 68: [1, 0],
  1920. 39: [1, 0],
  1921. };
  1922. let attackState = 0;
  1923. let inGame = false;
  1924.  
  1925. let macro = {};
  1926. let mills = {
  1927. place: 0,
  1928. placeSpawnPads: 0
  1929. };
  1930. let lastDir;
  1931.  
  1932. let lastLeaderboardData = [];
  1933. // ON LOAD:
  1934. let inWindow = true;
  1935. window.onblur = function() {
  1936. inWindow = false;
  1937. };
  1938. window.onfocus = function() {
  1939. inWindow = true;
  1940. if (player && player.alive) {
  1941. // resetMoveDir();
  1942. }
  1943. };
  1944. let ms = {
  1945. avg: 0,
  1946. max: 0,
  1947. min: 0,
  1948. delay: 0
  1949. }
  1950. function pingSocketResponse() {
  1951. let pingTime = window.pingTime;
  1952. const pingDisplay = document.getElementById("pingDisplay")
  1953. pingDisplay.innerText = "";
  1954. if (pingTime > ms.max || isNaN(ms.max)) {
  1955. ms.max = pingTime;
  1956. }
  1957. if (pingTime < ms.min || isNaN(ms.min)) {
  1958. ms.min = pingTime;
  1959. }
  1960.  
  1961. // if (pingTime >= 90) {
  1962. // doAutoQ = true;
  1963. // } else {
  1964. // doAutoQ = false;
  1965. // }
  1966. }
  1967.  
  1968. let placeVisible = [];
  1969.  
  1970. /** CLASS CODES */
  1971.  
  1972. class Utils {
  1973. constructor() {
  1974.  
  1975. // MATH UTILS:
  1976. let mathABS = Math.abs,
  1977. mathCOS = Math.cos,
  1978. mathSIN = Math.sin,
  1979. mathPOW = Math.pow,
  1980. mathSQRT = Math.sqrt,
  1981. mathATAN2 = Math.atan2,
  1982. mathPI = Math.PI;
  1983.  
  1984. let _this = this;
  1985.  
  1986. // GLOBAL UTILS:
  1987. this.round = function(n, v) {
  1988. return Math.round(n * v) / v;
  1989. };
  1990. this.toRad = function(angle) {
  1991. return angle * (mathPI / 180);
  1992. };
  1993. this.toAng = function(radian) {
  1994. return radian / (mathPI / 180);
  1995. };
  1996. this.randInt = function(min, max) {
  1997. return Math.floor(Math.random() * (max - min + 1)) + min;
  1998. };
  1999. this.randFloat = function(min, max) {
  2000. return Math.random() * (max - min + 1) + min;
  2001. };
  2002. this.lerp = function(value1, value2, amount) {
  2003. return value1 + (value2 - value1) * amount;
  2004. };
  2005. this.decel = function(val, cel) {
  2006. if (val > 0)
  2007. val = Math.max(0, val - cel);
  2008. else if (val < 0)
  2009. val = Math.min(0, val + cel);
  2010. return val;
  2011. };
  2012. this.getDistance = function(x1, y1, x2, y2) {
  2013. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  2014. };
  2015. this.getDist = function(tmp1, tmp2, type1, type2) {
  2016. let tmpXY1 = {
  2017. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  2018. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  2019. };
  2020. let tmpXY2 = {
  2021. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  2022. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  2023. };
  2024. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  2025. };
  2026. this.getDirection = function(x1, y1, x2, y2) {
  2027. return mathATAN2(y1 - y2, x1 - x2);
  2028. };
  2029. this.getDirect = function(tmp1, tmp2, type1, type2) {
  2030. let tmpXY1 = {
  2031. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  2032. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  2033. };
  2034. let tmpXY2 = {
  2035. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  2036. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  2037. };
  2038. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  2039. };
  2040. this.getAngleDist = function(a, b) {
  2041. let p = mathABS(b - a) % (mathPI * 2);
  2042. return (p > mathPI ? (mathPI * 2) - p : p);
  2043. };
  2044. this.isNumber = function(n) {
  2045. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  2046. };
  2047. this.isString = function(s) {
  2048. return (s && typeof s == "string");
  2049. };
  2050. this.kFormat = function(num) {
  2051. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  2052. };
  2053. this.sFormat = function(num) {
  2054. let fixs = [{
  2055. num: 1e3,
  2056. string: "k"
  2057. },
  2058. {
  2059. num: 1e6,
  2060. string: "m"
  2061. },
  2062. {
  2063. num: 1e9,
  2064. string: "b"
  2065. },
  2066. {
  2067. num: 1e12,
  2068. string: "q"
  2069. }
  2070. ].reverse();
  2071. let sp = fixs.find(v => num >= v.num);
  2072. if (!sp) return num;
  2073. return (num / sp.num).toFixed(1) + sp.string;
  2074. };
  2075. this.capitalizeFirst = function(string) {
  2076. return string.charAt(0).toUpperCase() + string.slice(1);
  2077. };
  2078. this.fixTo = function(n, v) {
  2079. return parseFloat(n.toFixed(v));
  2080. };
  2081. this.sortByPoints = function(a, b) {
  2082. return parseFloat(b.points) - parseFloat(a.points);
  2083. };
  2084. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  2085. let minX = x1;
  2086. let maxX = x2;
  2087. if (x1 > x2) {
  2088. minX = x2;
  2089. maxX = x1;
  2090. }
  2091. if (maxX > recX2)
  2092. maxX = recX2;
  2093. if (minX < recX)
  2094. minX = recX;
  2095. if (minX > maxX)
  2096. return false;
  2097. let minY = y1;
  2098. let maxY = y2;
  2099. let dx = x2 - x1;
  2100. if (Math.abs(dx) > 0.0000001) {
  2101. let a = (y2 - y1) / dx;
  2102. let b = y1 - a * x1;
  2103. minY = a * minX + b;
  2104. maxY = a * maxX + b;
  2105. }
  2106. if (minY > maxY) {
  2107. let tmp = maxY;
  2108. maxY = minY;
  2109. minY = tmp;
  2110. }
  2111. if (maxY > recY2)
  2112. maxY = recY2;
  2113. if (minY < recY)
  2114. minY = recY;
  2115. if (minY > maxY)
  2116. return false;
  2117. return true;
  2118. };
  2119. this.containsPoint = function(element, x, y) {
  2120. let bounds = element.getBoundingClientRect();
  2121. let left = bounds.left + window.scrollX;
  2122. let top = bounds.top + window.scrollY;
  2123. let width = bounds.width;
  2124. let height = bounds.height;
  2125.  
  2126. let insideHorizontal = x > left && x < left + width;
  2127. let insideVertical = y > top && y < top + height;
  2128. return insideHorizontal && insideVertical;
  2129. };
  2130. this.mousifyTouchEvent = function(event) {
  2131. let touch = event.changedTouches[0];
  2132. event.screenX = touch.screenX;
  2133. event.screenY = touch.screenY;
  2134. event.clientX = touch.clientX;
  2135. event.clientY = touch.clientY;
  2136. event.pageX = touch.pageX;
  2137. event.pageY = touch.pageY;
  2138. };
  2139. this.hookTouchEvents = function(element, skipPrevent) {
  2140. let preventDefault = !skipPrevent;
  2141. let isHovering = false;
  2142. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  2143. let passive = false;
  2144. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  2145. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  2146. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  2147. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  2148. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  2149.  
  2150. function touchStart(e) {
  2151. _this.mousifyTouchEvent(e);
  2152. window.setUsingTouch(true);
  2153. if (preventDefault) {
  2154. e.preventDefault();
  2155. e.stopPropagation();
  2156. }
  2157. if (element.onmouseover)
  2158. element.onmouseover(e);
  2159. isHovering = true;
  2160. }
  2161.  
  2162. function touchMove(e) {
  2163. _this.mousifyTouchEvent(e);
  2164. window.setUsingTouch(true);
  2165. if (preventDefault) {
  2166. e.preventDefault();
  2167. e.stopPropagation();
  2168. }
  2169. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  2170. if (!isHovering) {
  2171. if (element.onmouseover)
  2172. element.onmouseover(e);
  2173. isHovering = true;
  2174. }
  2175. } else {
  2176. if (isHovering) {
  2177. if (element.onmouseout)
  2178. element.onmouseout(e);
  2179. isHovering = false;
  2180. }
  2181. }
  2182. }
  2183.  
  2184. function touchEnd(e) {
  2185. _this.mousifyTouchEvent(e);
  2186. window.setUsingTouch(true);
  2187. if (preventDefault) {
  2188. e.preventDefault();
  2189. e.stopPropagation();
  2190. }
  2191. if (isHovering) {
  2192. if (element.onclick)
  2193. element.onclick(e);
  2194. if (element.onmouseout)
  2195. element.onmouseout(e);
  2196. isHovering = false;
  2197. }
  2198. }
  2199. };
  2200. this.removeAllChildren = function(element) {
  2201. while (element.hasChildNodes()) {
  2202. element.removeChild(element.lastChild);
  2203. }
  2204. };
  2205. this.generateElement = function(config) {
  2206. let element = document.createElement(config.tag || "div");
  2207.  
  2208. function bind(configValue, elementValue) {
  2209. if (config[configValue])
  2210. element[elementValue] = config[configValue];
  2211. }
  2212. bind("text", "textContent");
  2213. bind("html", "innerHTML");
  2214. bind("class", "className");
  2215. for (let key in config) {
  2216. switch (key) {
  2217. case "tag":
  2218. case "text":
  2219. case "html":
  2220. case "class":
  2221. case "style":
  2222. case "hookTouch":
  2223. case "parent":
  2224. case "children":
  2225. continue;
  2226. default:
  2227. break;
  2228. }
  2229. element[key] = config[key];
  2230. }
  2231. if (element.onclick)
  2232. element.onclick = this.checkTrusted(element.onclick);
  2233. if (element.onmouseover)
  2234. element.onmouseover = this.checkTrusted(element.onmouseover);
  2235. if (element.onmouseout)
  2236. element.onmouseout = this.checkTrusted(element.onmouseout);
  2237. if (config.style) {
  2238. element.style.cssText = config.style;
  2239. }
  2240. if (config.hookTouch) {
  2241. this.hookTouchEvents(element);
  2242. }
  2243. if (config.parent) {
  2244. config.parent.appendChild(element);
  2245. }
  2246. if (config.children) {
  2247. for (let i = 0; i < config.children.length; i++) {
  2248. element.appendChild(config.children[i]);
  2249. }
  2250. }
  2251. return element;
  2252. };
  2253. this.checkTrusted = function(callback) {
  2254. return function(ev) {
  2255. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2256. callback(ev);
  2257. } else {
  2258. //console.error("Event is not trusted.", ev);
  2259. }
  2260. };
  2261. };
  2262. this.randomString = function(length) {
  2263. let text = "";
  2264. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2265. for (let i = 0; i < length; i++) {
  2266. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2267. }
  2268. return text;
  2269. };
  2270. this.countInArray = function(array, val) {
  2271. let count = 0;
  2272. for (let i = 0; i < array.length; i++) {
  2273. if (array[i] === val) count++;
  2274. }
  2275. return count;
  2276. };
  2277. this.hexToRgb = function(hex) {
  2278. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2279. };
  2280. this.getRgb = function(r, g, b) {
  2281. return [r / 255, g / 255, b / 255].join(", ");
  2282. };
  2283. }
  2284. };
  2285. class Animtext {
  2286. // ANIMATED TEXT:
  2287. constructor() {
  2288. // INIT:
  2289. this.init = function(x, y, scale, speed, life, text, color) {
  2290. (this.x = x),
  2291. (this.y = y),
  2292. (this.color = color),
  2293. (this.scale = scale*3.5),
  2294. (this.weight = 50);
  2295. (this.startScale = this.scale * 1.2),
  2296. (this.maxScale = 1.5 * scale),
  2297. (this.minScale = 0.5 * scale),
  2298. (this.scaleSpeed = 0.7),
  2299. (this.speed = speed),
  2300. (this.speedMax = speed),
  2301. (this.life = life),
  2302. (this.maxLife = life),
  2303. (this.text = text),
  2304. this.movSpeed = speed;
  2305. };
  2306.  
  2307. // UPDATE:
  2308. this.update = function(delta) {
  2309. if(this.life){
  2310. this.life -= delta;
  2311. if(this.scaleSpeed != -0.35){
  2312. this.y -= this.speed * delta;
  2313. // (this.x += this.speed * delta);
  2314. } else {
  2315. this.y -= this.speed * delta;
  2316. }
  2317. this.scale -= .8;
  2318. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2319. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2320. if(this.scale >= this.maxScale){
  2321. this.scale = this.maxScale;
  2322. this.scaleSpeed *= -.5;
  2323. this.speed = this.speed * .75;
  2324. };
  2325. this.life <= 0 && (this.life = 0)
  2326. };
  2327. };
  2328.  
  2329. // RENDER:
  2330. this.render = function(ctxt, xOff, yOff) {
  2331. ctxt.lineWidth = 10;
  2332. ctxt.strokeStyle = darkOutlineColor; //"black";
  2333. ctxt.fillStyle = this.color;
  2334. ctxt.globalAlpha = 1;
  2335. ctxt.font = this.scale + "px Hammersmith One";
  2336. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2337. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2338. ctxt.globalAlpha = 1;
  2339. };
  2340. }
  2341. };
  2342. class Textmanager {
  2343. // TEXT MANAGER:
  2344. constructor() {
  2345. this.texts = [];
  2346. this.stack = [];
  2347.  
  2348. // UPDATE:
  2349. this.update = function(delta, ctxt, xOff, yOff) {
  2350. ctxt.textBaseline = "middle";
  2351. ctxt.textAlign = "center";
  2352. for (let i = 0; i < this.texts.length; ++i) {
  2353. if (this.texts[i].life) {
  2354. this.texts[i].update(delta);
  2355. this.texts[i].render(ctxt, xOff, yOff);
  2356. }
  2357. }
  2358. };
  2359.  
  2360. // SHOW TEXT:
  2361. this.showText = function(x, y, scale, speed, life, text, color) {
  2362. let tmpText;
  2363. for (let i = 0; i < this.texts.length; ++i) {
  2364. if (!this.texts[i].life) {
  2365. tmpText = this.texts[i];
  2366. break;
  2367. }
  2368. }
  2369. if (!tmpText) {
  2370. tmpText = new Animtext();
  2371. this.texts.push(tmpText);
  2372. }
  2373. tmpText.init(x, y, scale, speed, life, text, color);
  2374. };
  2375. }
  2376. }
  2377.  
  2378. class GameObject {
  2379. constructor(sid) {
  2380. this.sid = sid;
  2381.  
  2382. // INIT:
  2383. this.init = function(x, y, dir, scale, type, data, owner) {
  2384. data = data || {};
  2385. this.sentTo = {};
  2386. this.gridLocations = [];
  2387. this.active = true;
  2388. this.render = true;
  2389. this.doUpdate = data.doUpdate;
  2390. this.x = x;
  2391. this.y = y;
  2392. this.dir = dir;
  2393. this.lastDir = dir;
  2394. this.xWiggle = 0;
  2395. this.yWiggle = 0;
  2396. this.visScale = scale;
  2397. this.scale = scale;
  2398. this.type = type;
  2399. this.id = data.id;
  2400. this.owner = owner;
  2401. this.name = data.name;
  2402. this.isItem = (this.id != undefined);
  2403. this.group = data.group;
  2404. this.maxHealth = data.health;
  2405. this.health = this.maxHealth;
  2406. this.layer = 2;
  2407. if (this.group != undefined) {
  2408. this.layer = this.group.layer;
  2409. } else if (this.type == 0) {
  2410. this.layer = 3;
  2411. } else if (this.type == 2) {
  2412. this.layer = 0;
  2413. } else if (this.type == 4) {
  2414. this.layer = -1;
  2415. }
  2416. this.colDiv = data.colDiv || 1;
  2417. this.blocker = data.blocker;
  2418. this.ignoreCollision = data.ignoreCollision;
  2419. this.dontGather = data.dontGather;
  2420. this.hideFromEnemy = data.hideFromEnemy;
  2421. this.friction = data.friction;
  2422. this.projDmg = data.projDmg;
  2423. this.dmg = data.dmg;
  2424. this.pDmg = data.pDmg;
  2425. this.pps = data.pps;
  2426. this.zIndex = data.zIndex || 0;
  2427. this.turnSpeed = data.turnSpeed;
  2428. this.req = data.req;
  2429. this.trap = data.trap;
  2430. this.healCol = data.healCol;
  2431. this.teleport = data.teleport;
  2432. this.boostSpeed = data.boostSpeed;
  2433. this.projectile = data.projectile;
  2434. this.shootRange = data.shootRange;
  2435. this.shootRate = data.shootRate;
  2436. this.shootCount = this.shootRate;
  2437. this.spawnPoint = data.spawnPoint;
  2438. this.onNear = 0;
  2439. this.breakObj = false;
  2440. this.alpha = data.alpha || 1;
  2441. this.maxAlpha = data.alpha || 1;
  2442. this.damaged = 0;
  2443. };
  2444.  
  2445. // GET HIT:
  2446. this.changeHealth = function(amount, doer) {
  2447. this.health += amount;
  2448. return (this.health <= 0);
  2449. };
  2450.  
  2451. // GET SCALE:
  2452. this.getScale = function(sM, ig) {
  2453. sM = sM || 1;
  2454. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2455. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2456. };
  2457.  
  2458. // VISIBLE TO PLAYER:
  2459. this.visibleToPlayer = function(player) {
  2460. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2461. (this.owner.team && player.team == this.owner.team)));
  2462. };
  2463.  
  2464. // UPDATE:
  2465. this.update = function(delta) {
  2466. if (this.active) {
  2467. if (this.xWiggle) {
  2468. this.xWiggle *= Math.pow(0.99, delta);
  2469. }
  2470. if (this.yWiggle) {
  2471. this.yWiggle *= Math.pow(0.99, delta);
  2472. }
  2473. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2474. if (d2 > 0.01) {
  2475. this.dir += d2 / 5;
  2476. } else {
  2477. this.dir = this.lastDir;
  2478. }
  2479. } else {
  2480. if (this.alive) {
  2481. this.alpha -= delta / (200 / this.maxAlpha);
  2482. this.visScale += delta / (this.scale / 2.5);
  2483. if (this.alpha <= 0) {
  2484. this.alpha = 0;
  2485. this.alive = false;
  2486. }
  2487. }
  2488. }
  2489. };
  2490.  
  2491. // CHECK TEAM:
  2492. this.isTeamObject = function(tmpObj) {
  2493. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2494. };
  2495. }
  2496. }
  2497. class Items {
  2498. constructor() {
  2499. // ITEM GROUPS:
  2500. this.groups = [{
  2501. id: 0,
  2502. name: "food",
  2503. layer: 0
  2504. }, {
  2505. id: 1,
  2506. name: "walls",
  2507. place: true,
  2508. limit: 30,
  2509. layer: 0
  2510. }, {
  2511. id: 2,
  2512. name: "spikes",
  2513. place: true,
  2514. limit: 15,
  2515. layer: 0
  2516. }, {
  2517. id: 3,
  2518. name: "mill",
  2519. place: true,
  2520. limit: 7,
  2521. layer: 1
  2522. }, {
  2523. id: 4,
  2524. name: "mine",
  2525. place: true,
  2526. limit: 1,
  2527. layer: 0
  2528. }, {
  2529. id: 5,
  2530. name: "trap",
  2531. place: true,
  2532. limit: 6,
  2533. layer: -1
  2534. }, {
  2535. id: 6,
  2536. name: "booster",
  2537. place: true,
  2538. limit: 12,
  2539. layer: -1
  2540. }, {
  2541. id: 7,
  2542. name: "turret",
  2543. place: true,
  2544. limit: 2,
  2545. layer: 1
  2546. }, {
  2547. id: 8,
  2548. name: "watchtower",
  2549. place: true,
  2550. limit: 12,
  2551. layer: 1
  2552. }, {
  2553. id: 9,
  2554. name: "buff",
  2555. place: true,
  2556. limit: 4,
  2557. layer: -1
  2558. }, {
  2559. id: 10,
  2560. name: "spawn",
  2561. place: true,
  2562. limit: 1,
  2563. layer: -1
  2564. }, {
  2565. id: 11,
  2566. name: "sapling",
  2567. place: true,
  2568. limit: 2,
  2569. layer: 0
  2570. }, {
  2571. id: 12,
  2572. name: "blocker",
  2573. place: true,
  2574. limit: 3,
  2575. layer: -1
  2576. }, {
  2577. id: 13,
  2578. name: "teleporter",
  2579. place: true,
  2580. limit: 2,
  2581. layer: -1
  2582. }];
  2583.  
  2584. // PROJECTILES:
  2585. this.projectiles = [{
  2586. indx: 0,
  2587. layer: 0,
  2588. src: "arrow_1",
  2589. dmg: 25,
  2590. speed: 1.6,
  2591. scale: 103,
  2592. range: 1000
  2593. }, {
  2594. indx: 1,
  2595. layer: 1,
  2596. dmg: 25,
  2597. scale: 20
  2598. }, {
  2599. indx: 0,
  2600. layer: 0,
  2601. src: "arrow_1",
  2602. dmg: 35,
  2603. speed: 2.5,
  2604. scale: 103,
  2605. range: 1200
  2606. }, {
  2607. indx: 0,
  2608. layer: 0,
  2609. src: "arrow_1",
  2610. dmg: 30,
  2611. speed: 2,
  2612. scale: 103,
  2613. range: 1200
  2614. }, {
  2615. indx: 1,
  2616. layer: 1,
  2617. dmg: 16,
  2618. scale: 20
  2619. }, {
  2620. indx: 0,
  2621. layer: 0,
  2622. src: "bullet_1",
  2623. dmg: 50,
  2624. speed: 3.6,
  2625. scale: 160,
  2626. range: 1400
  2627. }];
  2628.  
  2629. // WEAPONS:
  2630. this.weapons = [{
  2631. id: 0,
  2632. type: 0,
  2633. name: "tool hammer",
  2634. desc: "tool for gathering all resources",
  2635. src: "hammer_1",
  2636. length: 140,
  2637. width: 140,
  2638. xOff: -3,
  2639. yOff: 18,
  2640. dmg: 25,
  2641. range: 65,
  2642. gather: 1,
  2643. speed: 300
  2644. }, {
  2645. id: 1,
  2646. type: 0,
  2647. age: 2,
  2648. name: "hand axe",
  2649. desc: "gathers resources at a higher rate",
  2650. src: "axe_1",
  2651. length: 140,
  2652. width: 140,
  2653. xOff: 3,
  2654. yOff: 24,
  2655. dmg: 30,
  2656. spdMult: 1,
  2657. range: 70,
  2658. gather: 2,
  2659. speed: 400
  2660. }, {
  2661. id: 2,
  2662. type: 0,
  2663. age: 8,
  2664. pre: 1,
  2665. name: "great axe",
  2666. desc: "deal more damage and gather more resources",
  2667. src: "great_axe_1",
  2668. length: 140,
  2669. width: 140,
  2670. xOff: -8,
  2671. yOff: 25,
  2672. dmg: 35,
  2673. spdMult: 1,
  2674. range: 75,
  2675. gather: 4,
  2676. speed: 400
  2677. }, {
  2678. id: 3,
  2679. type: 0,
  2680. age: 2,
  2681. name: "short sword",
  2682. desc: "increased attack power but slower move speed",
  2683. src: "sword_1",
  2684. iPad: 1.3,
  2685. length: 130,
  2686. width: 210,
  2687. xOff: -8,
  2688. yOff: 46,
  2689. dmg: 35,
  2690. spdMult: 0.85,
  2691. range: 110,
  2692. gather: 1,
  2693. speed: 300
  2694. }, {
  2695. id: 4,
  2696. type: 0,
  2697. age: 8,
  2698. pre: 3,
  2699. name: "katana",
  2700. desc: "greater range and damage",
  2701. src: "samurai_1",
  2702. iPad: 1.3,
  2703. length: 130,
  2704. width: 210,
  2705. xOff: -8,
  2706. yOff: 59,
  2707. dmg: 40,
  2708. spdMult: 0.8,
  2709. range: 118,
  2710. gather: 1,
  2711. speed: 300
  2712. }, {
  2713. id: 5,
  2714. type: 0,
  2715. age: 2,
  2716. name: "polearm",
  2717. desc: "long range melee weapon",
  2718. src: "spear_1",
  2719. iPad: 1.3,
  2720. length: 130,
  2721. width: 210,
  2722. xOff: -8,
  2723. yOff: 53,
  2724. dmg: 45,
  2725. knock: 0.2,
  2726. spdMult: 0.82,
  2727. range: 142,
  2728. gather: 1,
  2729. speed: 700
  2730. }, {
  2731. id: 6,
  2732. type: 0,
  2733. age: 2,
  2734. name: "bat",
  2735. desc: "fast long range melee weapon",
  2736. src: "bat_1",
  2737. iPad: 1.3,
  2738. length: 110,
  2739. width: 180,
  2740. xOff: -8,
  2741. yOff: 53,
  2742. dmg: 20,
  2743. knock: 0.7,
  2744. range: 110,
  2745. gather: 1,
  2746. speed: 300
  2747. }, {
  2748. id: 7,
  2749. type: 0,
  2750. age: 2,
  2751. name: "daggers",
  2752. desc: "really fast short range weapon",
  2753. src: "dagger_1",
  2754. iPad: 0.8,
  2755. length: 110,
  2756. width: 110,
  2757. xOff: 18,
  2758. yOff: 0,
  2759. dmg: 20,
  2760. knock: 0.1,
  2761. range: 65,
  2762. gather: 1,
  2763. hitSlow: 0.1,
  2764. spdMult: 1.13,
  2765. speed: 100
  2766. }, {
  2767. id: 8,
  2768. type: 0,
  2769. age: 2,
  2770. name: "stick",
  2771. desc: "great for gathering but very weak",
  2772. src: "stick_1",
  2773. length: 140,
  2774. width: 140,
  2775. xOff: 3,
  2776. yOff: 24,
  2777. dmg: 1,
  2778. spdMult: 1,
  2779. range: 70,
  2780. gather: 7,
  2781. speed: 400
  2782. }, {
  2783. id: 9,
  2784. type: 1,
  2785. age: 6,
  2786. name: "hunting bow",
  2787. desc: "bow used for ranged combat and hunting",
  2788. src: "bow_1",
  2789. req: ["wood", 4],
  2790. length: 120,
  2791. width: 120,
  2792. xOff: -6,
  2793. yOff: 0,
  2794. Pdmg: 25,
  2795. projectile: 0,
  2796. spdMult: 0.75,
  2797. speed: 600
  2798. }, {
  2799. id: 10,
  2800. type: 1,
  2801. age: 6,
  2802. name: "great hammer",
  2803. desc: "hammer used for destroying structures",
  2804. src: "great_hammer_1",
  2805. length: 140,
  2806. width: 140,
  2807. xOff: -9,
  2808. yOff: 25,
  2809. dmg: 10,
  2810. Pdmg: 10,
  2811. spdMult: 0.88,
  2812. range: 75,
  2813. sDmg: 7.5,
  2814. gather: 1,
  2815. speed: 400
  2816. }, {
  2817. id: 11,
  2818. type: 1,
  2819. age: 6,
  2820. name: "wooden shield",
  2821. desc: "blocks projectiles and reduces melee damage",
  2822. src: "shield_1",
  2823. length: 120,
  2824. width: 120,
  2825. shield: 0.2,
  2826. xOff: 6,
  2827. yOff: 0,
  2828. Pdmg: 0,
  2829. spdMult: 0.7
  2830. }, {
  2831. id: 12,
  2832. type: 1,
  2833. age: 8,
  2834. pre: 9,
  2835. name: "crossbow",
  2836. desc: "deals more damage and has greater range",
  2837. src: "crossbow_1",
  2838. req: ["wood", 5],
  2839. aboveHand: true,
  2840. armS: 0.75,
  2841. length: 120,
  2842. width: 120,
  2843. xOff: -4,
  2844. yOff: 0,
  2845. Pdmg: 35,
  2846. projectile: 2,
  2847. spdMult: 0.7,
  2848. speed: 700
  2849. }, {
  2850. id: 13,
  2851. type: 1,
  2852. age: 9,
  2853. pre: 12,
  2854. name: "repeater crossbow",
  2855. desc: "high firerate crossbow with reduced damage",
  2856. src: "crossbow_2",
  2857. req: ["wood", 10],
  2858. aboveHand: true,
  2859. armS: 0.75,
  2860. length: 120,
  2861. width: 120,
  2862. xOff: -4,
  2863. yOff: 0,
  2864. Pdmg: 30,
  2865. projectile: 3,
  2866. spdMult: 0.7,
  2867. speed: 230
  2868. }, {
  2869. id: 14,
  2870. type: 1,
  2871. age: 6,
  2872. name: "mc grabby",
  2873. desc: "steals resources from enemies",
  2874. src: "grab_1",
  2875. length: 130,
  2876. width: 210,
  2877. xOff: -8,
  2878. yOff: 53,
  2879. dmg: 0,
  2880. Pdmg: 0,
  2881. steal: 250,
  2882. knock: 0.2,
  2883. spdMult: 1.05,
  2884. range: 125,
  2885. gather: 0,
  2886. speed: 700
  2887. }, {
  2888. id: 15,
  2889. type: 1,
  2890. age: 9,
  2891. pre: 12,
  2892. name: "musket",
  2893. desc: "slow firerate but high damage and range",
  2894. src: "musket_1",
  2895. req: ["stone", 10],
  2896. aboveHand: true,
  2897. rec: 0.35,
  2898. armS: 0.6,
  2899. hndS: 0.3,
  2900. hndD: 1.6,
  2901. length: 205,
  2902. width: 205,
  2903. xOff: 25,
  2904. yOff: 0,
  2905. Pdmg: 50,
  2906. projectile: 5,
  2907. hideProjectile: true,
  2908. spdMult: 0.6,
  2909. speed: 1500
  2910. }];
  2911.  
  2912. // ITEMS:
  2913. this.list = [{
  2914. group: this.groups[0],
  2915. name: "apple",
  2916. desc: "restores 20 health when consumed",
  2917. req: ["food", 10],
  2918. consume: function(doer) {
  2919. return doer.changeHealth(20, doer);
  2920. },
  2921. scale: 22,
  2922. holdOffset: 15,
  2923. healing: 20,
  2924. itemID: 0,
  2925. itemAID: 16,
  2926. }, {
  2927. age: 3,
  2928. group: this.groups[0],
  2929. name: "cookie",
  2930. desc: "restores 40 health when consumed",
  2931. req: ["food", 15],
  2932. consume: function(doer) {
  2933. return doer.changeHealth(40, doer);
  2934. },
  2935. scale: 27,
  2936. holdOffset: 15,
  2937. healing: 40,
  2938. itemID: 1,
  2939. itemAID: 17,
  2940. }, {
  2941. age: 7,
  2942. group: this.groups[0],
  2943. name: "cheese",
  2944. desc: "restores 30 health and another 50 over 5 seconds",
  2945. req: ["food", 25],
  2946. consume: function(doer) {
  2947. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2948. doer.dmgOverTime.dmg = -10;
  2949. doer.dmgOverTime.doer = doer;
  2950. doer.dmgOverTime.time = 5;
  2951. return true;
  2952. }
  2953. return false;
  2954. },
  2955. scale: 27,
  2956. holdOffset: 15,
  2957. healing: 30,
  2958. itemID: 2,
  2959. itemAID: 18,
  2960. }, {
  2961. group: this.groups[1],
  2962. name: "wood wall",
  2963. desc: "provides protection for your village",
  2964. req: ["wood", 10],
  2965. projDmg: true,
  2966. health: 380,
  2967. scale: 50,
  2968. holdOffset: 20,
  2969. placeOffset: -5,
  2970. itemID: 3,
  2971. itemAID: 19,
  2972. }, {
  2973. age: 3,
  2974. group: this.groups[1],
  2975. name: "stone wall",
  2976. desc: "provides improved protection for your village",
  2977. req: ["stone", 25],
  2978. health: 900,
  2979. scale: 50,
  2980. holdOffset: 20,
  2981. placeOffset: -5,
  2982. itemID: 4,
  2983. itemAID: 20,
  2984. }, {
  2985. age: 7,
  2986. group: this.groups[1],
  2987. name: "castle wall",
  2988. desc: "provides powerful protection for your village",
  2989. req: ["stone", 35],
  2990. health: 1500,
  2991. scale: 52,
  2992. holdOffset: 20,
  2993. placeOffset: -5,
  2994. itemID: 5,
  2995. itemAID: 21,
  2996. }, {
  2997. group: this.groups[2],
  2998. name: "spikes",
  2999. desc: "damages enemies when they touch them",
  3000. req: ["wood", 20, "stone", 5],
  3001. health: 400,
  3002. dmg: 20,
  3003. scale: 49,
  3004. spritePadding: -23,
  3005. holdOffset: 8,
  3006. placeOffset: -5,
  3007. itemID: 6,
  3008. itemAID: 22,
  3009.  
  3010.  
  3011. }, {
  3012. age: 5,
  3013. group: this.groups[2],
  3014. name: "greater spikes",
  3015. desc: "damages enemies when they touch them",
  3016. req: ["wood", 30, "stone", 10],
  3017. health: 500,
  3018. dmg: 35,
  3019. scale: 52,
  3020. spritePadding: -23,
  3021. holdOffset: 8,
  3022. placeOffset: -5,
  3023. itemID: 7,
  3024. itemAID: 23,
  3025. }, {
  3026. age: 9,
  3027. group: this.groups[2],
  3028. name: "poison spikes",
  3029. desc: "poisons enemies when they touch them",
  3030. req: ["wood", 35, "stone", 15],
  3031. health: 600,
  3032. dmg: 30,
  3033. pDmg: 5,
  3034. scale: 52,
  3035. spritePadding: -23,
  3036. holdOffset: 8,
  3037. placeOffset: -5,
  3038. itemID: 8,
  3039. itemAID: 24,
  3040. }, {
  3041. age: 9,
  3042. group: this.groups[2],
  3043. name: "spinning spikes",
  3044. desc: "damages enemies when they touch them",
  3045. req: ["wood", 30, "stone", 20],
  3046. health: 500,
  3047. dmg: 45,
  3048. turnSpeed: 0.003,
  3049. scale: 52,
  3050. spritePadding: -23,
  3051. holdOffset: 8,
  3052. placeOffset: -5,
  3053. itemID: 9,
  3054. itemAID: 25,
  3055. }, {
  3056. group: this.groups[3],
  3057. name: "windmill",
  3058. desc: "generates gold over time",
  3059. req: ["wood", 50, "stone", 10],
  3060. health: 400,
  3061. pps: 1,
  3062. turnSpeed: 0.0016,
  3063. spritePadding: 25,
  3064. iconLineMult: 12,
  3065. scale: 45,
  3066. holdOffset: 20,
  3067. placeOffset: 5,
  3068. itemID: 10,
  3069. itemAID: 26,
  3070. }, {
  3071. age: 5,
  3072. group: this.groups[3],
  3073. name: "faster windmill",
  3074. desc: "generates more gold over time",
  3075. req: ["wood", 60, "stone", 20],
  3076. health: 500,
  3077. pps: 1.5,
  3078. turnSpeed: 0.0025,
  3079. spritePadding: 25,
  3080. iconLineMult: 12,
  3081. scale: 47,
  3082. holdOffset: 20,
  3083. placeOffset: 5,
  3084. itemID: 11,
  3085. itemAID: 27,
  3086. }, {
  3087. age: 8,
  3088. group: this.groups[3],
  3089. name: "power mill",
  3090. desc: "generates more gold over time",
  3091. req: ["wood", 100, "stone", 50],
  3092. health: 800,
  3093. pps: 2,
  3094. turnSpeed: 0.005,
  3095. spritePadding: 25,
  3096. iconLineMult: 12,
  3097. scale: 47,
  3098. holdOffset: 20,
  3099. placeOffset: 5,
  3100. itemID: 12,
  3101. itemAID: 28,
  3102. }, {
  3103. age: 5,
  3104. group: this.groups[4],
  3105. type: 2,
  3106. name: "mine",
  3107. desc: "allows you to mine stone",
  3108. req: ["wood", 20, "stone", 100],
  3109. iconLineMult: 12,
  3110. scale: 65,
  3111. holdOffset: 20,
  3112. placeOffset: 0,
  3113. itemID: 13,
  3114. itemAID: 29,
  3115. }, {
  3116. age: 5,
  3117. group: this.groups[11],
  3118. type: 0,
  3119. name: "sapling",
  3120. desc: "allows you to farm wood",
  3121. req: ["wood", 150],
  3122. iconLineMult: 12,
  3123. colDiv: 0.5,
  3124. scale: 110,
  3125. holdOffset: 50,
  3126. placeOffset: -15,
  3127. itemID: 14,
  3128. itemAID: 30,
  3129. }, {
  3130. age: 4,
  3131. group: this.groups[5],
  3132. name: "pit trap",
  3133. desc: "pit that traps enemies if they walk over it",
  3134. req: ["wood", 30, "stone", 30],
  3135. trap: true,
  3136. ignoreCollision: true,
  3137. hideFromEnemy: true,
  3138. health: 500,
  3139. colDiv: 0.2,
  3140. scale: 50,
  3141. holdOffset: 20,
  3142. placeOffset: -5,
  3143. alpha: 0.6,
  3144. itemID: 15,
  3145. itemAID: 31,
  3146. }, {
  3147. age: 4,
  3148. group: this.groups[6],
  3149. name: "boost pad",
  3150. desc: "provides boost when stepped on",
  3151. req: ["stone", 20, "wood", 5],
  3152. ignoreCollision: true,
  3153. boostSpeed: 1.5,
  3154. health: 150,
  3155. colDiv: 0.7,
  3156. scale: 45,
  3157. holdOffset: 20,
  3158. placeOffset: -5,
  3159. itemID: 16,
  3160. itemAID: 32,
  3161. }, {
  3162. age: 7,
  3163. group: this.groups[7],
  3164. doUpdate: true,
  3165. name: "turret",
  3166. desc: "defensive structure that shoots at enemies",
  3167. req: ["wood", 200, "stone", 150],
  3168. health: 800,
  3169. projectile: 1,
  3170. shootRange: 700,
  3171. shootRate: 2200,
  3172. scale: 43,
  3173. holdOffset: 20,
  3174. placeOffset: -5,
  3175. itemID: 17,
  3176. itemAID: 33,
  3177. }, {
  3178. age: 7,
  3179. group: this.groups[8],
  3180. name: "platform",
  3181. desc: "platform to shoot over walls and cross over water",
  3182. req: ["wood", 20],
  3183. ignoreCollision: true,
  3184. zIndex: 1,
  3185. health: 300,
  3186. scale: 43,
  3187. holdOffset: 20,
  3188. placeOffset: -5,
  3189. itemID: 18,
  3190. itemAID: 34,
  3191. }, {
  3192. age: 7,
  3193. group: this.groups[9],
  3194. name: "healing pad",
  3195. desc: "standing on it will slowly heal you",
  3196. req: ["wood", 30, "food", 10],
  3197. ignoreCollision: true,
  3198. healCol: 15,
  3199. health: 400,
  3200. colDiv: 0.7,
  3201. scale: 45,
  3202. holdOffset: 20,
  3203. placeOffset: -5,
  3204. itemID: 19,
  3205. itemAID: 35,
  3206. }, {
  3207. age: 9,
  3208. group: this.groups[10],
  3209. name: "spawn pad",
  3210. desc: "you will spawn here when you die but it will dissapear",
  3211. req: ["wood", 100, "stone", 100],
  3212. health: 400,
  3213. ignoreCollision: true,
  3214. spawnPoint: true,
  3215. scale: 45,
  3216. holdOffset: 20,
  3217. placeOffset: -5,
  3218. itemID: 20,
  3219. itemAID: 36,
  3220. }, {
  3221. age: 7,
  3222. group: this.groups[12],
  3223. name: "blocker",
  3224. desc: "blocks building in radius",
  3225. req: ["wood", 30, "stone", 25],
  3226. ignoreCollision: true,
  3227. blocker: 300,
  3228. health: 400,
  3229. colDiv: 0.7,
  3230. scale: 45,
  3231. holdOffset: 20,
  3232. placeOffset: -5,
  3233. itemID: 21,
  3234. itemAID: 37,
  3235. }, {
  3236. age: 7,
  3237. group: this.groups[13],
  3238. name: "teleporter",
  3239. desc: "teleports you to a random point on the map",
  3240. req: ["wood", 60, "stone", 60],
  3241. ignoreCollision: true,
  3242. teleport: true,
  3243. health: 200,
  3244. colDiv: 0.7,
  3245. scale: 45,
  3246. holdOffset: 20,
  3247. placeOffset: -5,
  3248. itemID: 22,
  3249. itemAID: 38
  3250. }];
  3251.  
  3252. // CHECK ITEM ID:
  3253. this.checkItem = {
  3254. index: function(id, myItems) {
  3255. 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 :
  3256. 5 :
  3257. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3258. 6 :
  3259. undefined;
  3260. }
  3261. }
  3262.  
  3263. // ASSIGN IDS:
  3264. for (let i = 0; i < this.list.length; ++i) {
  3265. this.list[i].id = i;
  3266. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3267. }
  3268.  
  3269. // TROLOLOLOL:
  3270. if (typeof window !== "undefined") {
  3271. function shuffle(a) {
  3272. for (let i = a.length - 1; i > 0; i--) {
  3273. const j = Math.floor(Math.random() * (i + 1));
  3274. [a[i], a[j]] = [a[j], a[i]];
  3275. }
  3276. return a;
  3277. }
  3278. //shuffle(this.list);
  3279. }
  3280. }
  3281. }
  3282. class Objectmanager {
  3283. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3284. let mathFloor = Math.floor,
  3285. mathABS = Math.abs,
  3286. mathCOS = Math.cos,
  3287. mathSIN = Math.sin,
  3288. mathPOW = Math.pow,
  3289. mathSQRT = Math.sqrt;
  3290.  
  3291. this.ignoreAdd = false;
  3292. this.hitObj = [];
  3293.  
  3294. // DISABLE OBJ:
  3295. this.disableObj = function(obj) {
  3296. obj.active = false;
  3297. };
  3298.  
  3299. // ADD NEW:
  3300. let tmpObj;
  3301. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3302. tmpObj = findObjectBySid(sid);
  3303. if (!tmpObj) {
  3304. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3305. if (!tmpObj) {
  3306. tmpObj = new GameObject(sid);
  3307. gameObjects.push(tmpObj);
  3308. }
  3309. }
  3310. if (setSID) {
  3311. tmpObj.sid = sid;
  3312. }
  3313. tmpObj.init(x, y, dir, s, type, data, owner);
  3314. };
  3315.  
  3316. // DISABLE BY SID:
  3317. this.disableBySid = function(sid) {
  3318. let find = findObjectBySid(sid);
  3319. if (find) {
  3320. this.disableObj(find);
  3321. }
  3322. };
  3323.  
  3324. // REMOVE ALL FROM PLAYER:
  3325. this.removeAllItems = function(sid, server) {
  3326. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3327. };
  3328.  
  3329. // CHECK IF PLACABLE:
  3330. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3331. 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)));
  3332. if (cantPlace) return false;
  3333. if (!ignoreWater && indx != 21 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3334. return true;
  3335. };
  3336.  
  3337. }
  3338. }
  3339. class Projectile {
  3340. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3341.  
  3342. // INIT:
  3343. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3344. this.active = true;
  3345. this.tickActive = true;
  3346. this.indx = indx;
  3347. this.x = x;
  3348. this.y = y;
  3349. this.x2 = x;
  3350. this.y2 = y;
  3351. this.dir = dir;
  3352. this.skipMov = true;
  3353. this.speed = spd;
  3354. this.dmg = dmg;
  3355. this.scale = scl;
  3356. this.range = rng;
  3357. this.r2 = rng;
  3358. this.owner = owner;
  3359. };
  3360.  
  3361. // UPDATE:
  3362. this.update = function(delta) {
  3363. if (this.active) {
  3364. let tmpSpeed = this.speed * delta;
  3365. if (!this.skipMov) {
  3366. this.x += tmpSpeed * Math.cos(this.dir);
  3367. this.y += tmpSpeed * Math.sin(this.dir);
  3368. this.range -= tmpSpeed;
  3369. if (this.range <= 0) {
  3370. this.x += this.range * Math.cos(this.dir);
  3371. this.y += this.range * Math.sin(this.dir);
  3372. tmpSpeed = 1;
  3373. this.range = 0;
  3374. this.active = false;
  3375. }
  3376. } else {
  3377. this.skipMov = false;
  3378. }
  3379. }
  3380. };
  3381. this.tickUpdate = function(delta) {
  3382. if (this.tickActive) {
  3383. let tmpSpeed = this.speed * delta;
  3384. if (!this.skipMov) {
  3385. this.x2 += tmpSpeed * Math.cos(this.dir);
  3386. this.y2 += tmpSpeed * Math.sin(this.dir);
  3387. this.r2 -= tmpSpeed;
  3388. if (this.r2 <= 0) {
  3389. this.x2 += this.r2 * Math.cos(this.dir);
  3390. this.y2 += this.r2 * Math.sin(this.dir);
  3391. tmpSpeed = 1;
  3392. this.r2 = 0;
  3393. this.tickActive = false;
  3394. }
  3395. } else {
  3396. this.skipMov = false;
  3397. }
  3398. }
  3399. };
  3400. }
  3401. };
  3402. class Store {
  3403. constructor() {
  3404. // STORE HATS:
  3405. this.hats = [{
  3406. id: 45,
  3407. name: "Shame!",
  3408. dontSell: true,
  3409. price: 0,
  3410. scale: 120,
  3411. desc: "hacks are for winners"
  3412. }, {
  3413. id: 51,
  3414. name: "Moo Cap",
  3415. price: 0,
  3416. scale: 120,
  3417. desc: "coolest mooer around"
  3418. }, {
  3419. id: 50,
  3420. name: "Apple Cap",
  3421. price: 0,
  3422. scale: 120,
  3423. desc: "apple farms remembers"
  3424. }, {
  3425. id: 28,
  3426. name: "Moo Head",
  3427. price: 0,
  3428. scale: 120,
  3429. desc: "no effect"
  3430. }, {
  3431. id: 29,
  3432. name: "Pig Head",
  3433. price: 0,
  3434. scale: 120,
  3435. desc: "no effect"
  3436. }, {
  3437. id: 30,
  3438. name: "Fluff Head",
  3439. price: 0,
  3440. scale: 120,
  3441. desc: "no effect"
  3442. }, {
  3443. id: 36,
  3444. name: "Pandou Head",
  3445. price: 0,
  3446. scale: 120,
  3447. desc: "no effect"
  3448. }, {
  3449. id: 37,
  3450. name: "Bear Head",
  3451. price: 0,
  3452. scale: 120,
  3453. desc: "no effect"
  3454. }, {
  3455. id: 38,
  3456. name: "Monkey Head",
  3457. price: 0,
  3458. scale: 120,
  3459. desc: "no effect"
  3460. }, {
  3461. id: 44,
  3462. name: "Polar Head",
  3463. price: 0,
  3464. scale: 120,
  3465. desc: "no effect"
  3466. }, {
  3467. id: 35,
  3468. name: "Fez Hat",
  3469. price: 0,
  3470. scale: 120,
  3471. desc: "no effect"
  3472. }, {
  3473. id: 42,
  3474. name: "Enigma Hat",
  3475. price: 0,
  3476. scale: 120,
  3477. desc: "join the enigma army"
  3478. }, {
  3479. id: 43,
  3480. name: "Blitz Hat",
  3481. price: 0,
  3482. scale: 120,
  3483. desc: "hey everybody i'm blitz"
  3484. }, {
  3485. id: 49,
  3486. name: "Bob XIII Hat",
  3487. price: 0,
  3488. scale: 120,
  3489. desc: "like and subscribe"
  3490. }, {
  3491. id: 57,
  3492. name: "Pumpkin",
  3493. price: 50,
  3494. scale: 120,
  3495. desc: "Spooooky"
  3496. }, {
  3497. id: 8,
  3498. name: "Bummle Hat",
  3499. price: 100,
  3500. scale: 120,
  3501. desc: "no effect"
  3502. }, {
  3503. id: 2,
  3504. name: "Straw Hat",
  3505. price: 500,
  3506. scale: 120,
  3507. desc: "no effect"
  3508. }, {
  3509. id: 15,
  3510. name: "Winter Cap",
  3511. price: 600,
  3512. scale: 120,
  3513. desc: "allows you to move at normal speed in snow",
  3514. coldM: 1
  3515. }, {
  3516. id: 5,
  3517. name: "Cowboy Hat",
  3518. price: 1000,
  3519. scale: 120,
  3520. desc: "no effect"
  3521. }, {
  3522. id: 4,
  3523. name: "Ranger Hat",
  3524. price: 2000,
  3525. scale: 120,
  3526. desc: "no effect"
  3527. }, {
  3528. id: 18,
  3529. name: "Explorer Hat",
  3530. price: 2000,
  3531. scale: 120,
  3532. desc: "no effect"
  3533. }, {
  3534. id: 31,
  3535. name: "Flipper Hat",
  3536. price: 2500,
  3537. scale: 120,
  3538. desc: "have more control while in water",
  3539. watrImm: true
  3540. }, {
  3541. id: 1,
  3542. name: "Marksman Cap",
  3543. price: 3000,
  3544. scale: 120,
  3545. desc: "increases arrow speed and range",
  3546. aMlt: 1.3
  3547. }, {
  3548. id: 10,
  3549. name: "Bush Gear",
  3550. price: 3000,
  3551. scale: 160,
  3552. desc: "allows you to disguise yourself as a bush"
  3553. }, {
  3554. id: 48,
  3555. name: "Halo",
  3556. price: 3000,
  3557. scale: 120,
  3558. desc: "no effect"
  3559. }, {
  3560. id: 6,
  3561. name: "Soldier Helmet",
  3562. price: 4000,
  3563. scale: 120,
  3564. desc: "reduces damage taken but slows movement",
  3565. spdMult: 0.94,
  3566. dmgMult: 0.75,
  3567. visuals: {
  3568. width: 50,
  3569. height: 50,
  3570. backgroundColor: "#666",
  3571. borderRadius: 10,
  3572. border: "2px solid #333",
  3573. boxShadow: "0 0 10px rgba(0, 0, 0, 0.5)"
  3574. }
  3575.  
  3576. }, {
  3577. id: 23,
  3578. name: "Anti Venom Gear",
  3579. price: 4000,
  3580. scale: 120,
  3581. desc: "makes you immune to poison",
  3582. poisonRes: 1
  3583. }, {
  3584. id: 13,
  3585. name: "Medic Gear",
  3586. price: 5000,
  3587. scale: 110,
  3588. desc: "slowly regenerates health over time",
  3589. healthRegen: 3
  3590. }, {
  3591. id: 9,
  3592. name: "Miners Helmet",
  3593. price: 5000,
  3594. scale: 120,
  3595. desc: "earn 1 extra gold per resource",
  3596. extraGold: 1
  3597. }, {
  3598. id: 32,
  3599. name: "Musketeer Hat",
  3600. price: 5000,
  3601. scale: 120,
  3602. desc: "reduces cost of projectiles",
  3603. projCost: 0.5
  3604. }, {
  3605. id: 7,
  3606. name: "Bull Helmet",
  3607. price: 6000,
  3608. scale: 120,
  3609. desc: "increases damage done but drains health",
  3610. healthRegen: -5,
  3611. dmgMultO: 1.5,
  3612. spdMult: 0.96
  3613. }, {
  3614. id: 22,
  3615. name: "Emp Helmet",
  3616. price: 6000,
  3617. scale: 120,
  3618. desc: "turrets won't attack but you move slower",
  3619. antiTurret: 1,
  3620. spdMult: 0.7
  3621. }, {
  3622. id: 12,
  3623. name: "Booster Hat",
  3624. price: 6000,
  3625. scale: 120,
  3626. desc: "increases your movement speed",
  3627. spdMult: 1.16
  3628. }, {
  3629. id: 26,
  3630. name: "Barbarian Armor",
  3631. price: 8000,
  3632. scale: 120,
  3633. desc: "knocks back enemies that attack you",
  3634. dmgK: 0.6
  3635. }, {
  3636. id: 21,
  3637. name: "Plague Mask",
  3638. price: 10000,
  3639. scale: 120,
  3640. desc: "melee attacks deal poison damage",
  3641. poisonDmg: 5,
  3642. poisonTime: 6
  3643. }, {
  3644. id: 46,
  3645. name: "Bull Mask",
  3646. price: 10000,
  3647. scale: 120,
  3648. desc: "bulls won't target you unless you attack them",
  3649. bullRepel: 1
  3650. }, {
  3651. id: 14,
  3652. name: "Windmill Hat",
  3653. topSprite: true,
  3654. price: 10000,
  3655. scale: 120,
  3656. desc: "generates points while worn",
  3657. pps: 1.5
  3658. }, {
  3659. id: 11,
  3660. name: "Spike Gear",
  3661. topSprite: true,
  3662. price: 10000,
  3663. scale: 120,
  3664. desc: "deal damage to players that damage you",
  3665. dmg: 0.45
  3666. }, {
  3667. id: 53,
  3668. name: "Turret Gear",
  3669. topSprite: true,
  3670. price: 10000,
  3671. scale: 120,
  3672. desc: "you become a walking turret",
  3673. turret: {
  3674. proj: 1,
  3675. range: 700,
  3676. rate: 2500
  3677. },
  3678. spdMult: 0.7
  3679. }, {
  3680. id: 20,
  3681. name: "Samurai Armor",
  3682. price: 12000,
  3683. scale: 120,
  3684. desc: "increased attack speed and fire rate",
  3685. atkSpd: 0.78
  3686. }, {
  3687. id: 58,
  3688. name: "Dark Knight",
  3689. price: 12000,
  3690. scale: 120,
  3691. desc: "restores health when you deal damage",
  3692. healD: 0.4
  3693. }, {
  3694. id: 27,
  3695. name: "Scavenger Gear",
  3696. price: 15000,
  3697. scale: 120,
  3698. desc: "earn double points for each kill",
  3699. kScrM: 2
  3700. }, {
  3701. id: 40,
  3702. name: "Tank Gear",
  3703. price: 15000,
  3704. scale: 120,
  3705. desc: "increased damage to buildings but slower movement",
  3706. spdMult: 0.3,
  3707. bDmg: 3.3
  3708. }, {
  3709. id: 52,
  3710. name: "Thief Gear",
  3711. price: 15000,
  3712. scale: 120,
  3713. desc: "steal half of a players gold when you kill them",
  3714. goldSteal: 0.5
  3715. }, {
  3716. id: 55,
  3717. name: "Bloodthirster",
  3718. price: 20000,
  3719. scale: 120,
  3720. desc: "Restore Health when dealing damage. And increased damage",
  3721. healD: 0.25,
  3722. dmgMultO: 1.2,
  3723. }, {
  3724. id: 56,
  3725. name: "Assassin Gear",
  3726. price: 20000,
  3727. scale: 120,
  3728. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3729. noEat: true,
  3730. spdMult: 1.1,
  3731. invisTimer: 1000
  3732. }];
  3733.  
  3734.  
  3735. // STORE ACCESSORIES:
  3736. this.accessories = [{
  3737. id: 12,
  3738. name: "Snowball",
  3739. price: 1000,
  3740. scale: 105,
  3741. xOff: 18,
  3742. desc: "no effect"
  3743. }, {
  3744. id: 9,
  3745. name: "Tree Cape",
  3746. price: 1000,
  3747. scale: 90,
  3748. desc: "no effect"
  3749. }, {
  3750. id: 10,
  3751. name: "Stone Cape",
  3752. price: 1000,
  3753. scale: 90,
  3754. desc: "no effect"
  3755. }, {
  3756. id: 3,
  3757. name: "Cookie Cape",
  3758. price: 1500,
  3759. scale: 90,
  3760. desc: "no effect"
  3761. }, {
  3762. id: 8,
  3763. name: "Cow Cape",
  3764. price: 2000,
  3765. scale: 90,
  3766. desc: "no effect"
  3767. }, {
  3768. id: 11,
  3769. name: "Monkey Tail",
  3770. price: 2000,
  3771. scale: 97,
  3772. xOff: 25,
  3773. desc: "Super speed but reduced damage",
  3774. spdMult: 1.35,
  3775. dmgMultO: 0.2
  3776. }, {
  3777. id: 17,
  3778. name: "Apple Basket",
  3779. price: 3000,
  3780. scale: 80,
  3781. xOff: 12,
  3782. desc: "slowly regenerates health over time",
  3783. healthRegen: 1
  3784. }, {
  3785. id: 6,
  3786. name: "Winter Cape",
  3787. price: 3000,
  3788. scale: 90,
  3789. desc: "no effect"
  3790. }, {
  3791. id: 4,
  3792. name: "Skull Cape",
  3793. price: 4000,
  3794. scale: 90,
  3795. desc: "no effect"
  3796. }, {
  3797. id: 5,
  3798. name: "Dash Cape",
  3799. price: 5000,
  3800. scale: 90,
  3801. desc: "no effect"
  3802. }, {
  3803. id: 2,
  3804. name: "Dragon Cape",
  3805. price: 6000,
  3806. scale: 90,
  3807. desc: "no effect"
  3808. }, {
  3809. id: 1,
  3810. name: "Super Cape",
  3811. price: 8000,
  3812. scale: 90,
  3813. desc: "no effect"
  3814. }, {
  3815. id: 7,
  3816. name: "Troll Cape",
  3817. price: 8000,
  3818. scale: 90,
  3819. desc: "no effect"
  3820. }, {
  3821. id: 14,
  3822. name: "Thorns",
  3823. price: 10000,
  3824. scale: 115,
  3825. xOff: 20,
  3826. desc: "no effect"
  3827. }, {
  3828. id: 15,
  3829. name: "Blockades",
  3830. price: 10000,
  3831. scale: 95,
  3832. xOff: 15,
  3833. desc: "no effect"
  3834. }, {
  3835. id: 20,
  3836. name: "Devils Tail",
  3837. price: 10000,
  3838. scale: 95,
  3839. xOff: 20,
  3840. desc: "no effect"
  3841. }, {
  3842. id: 16,
  3843. name: "Sawblade",
  3844. price: 12000,
  3845. scale: 90,
  3846. spin: true,
  3847. xOff: 0,
  3848. desc: "deal damage to players that damage you",
  3849. dmg: 0.15
  3850. }, {
  3851. id: 13,
  3852. name: "Angel Wings",
  3853. price: 15000,
  3854. scale: 138,
  3855. xOff: 22,
  3856. desc: "slowly regenerates health over time",
  3857. healthRegen: 3
  3858. }, {
  3859. id: 19,
  3860. name: "Shadow Wings",
  3861. price: 15000,
  3862. scale: 138,
  3863. xOff: 22,
  3864. desc: "increased movement speed",
  3865. spdMult: 1.1
  3866. }, {
  3867. id: 18,
  3868. name: "Blood Wings",
  3869. price: 20000,
  3870. scale: 178,
  3871. xOff: 26,
  3872. desc: "restores health when you deal damage",
  3873. healD: 0.2
  3874. }, {
  3875. id: 21,
  3876. name: "Corrupt X Wings",
  3877. price: 20000,
  3878. scale: 178,
  3879. xOff: 26,
  3880. desc: "deal damage to players that damage you",
  3881. dmg: 0.25
  3882. }];
  3883. }
  3884. };
  3885. class ProjectileManager {
  3886. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3887. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3888. let tmpData = items.projectiles[indx];
  3889. let tmpProj;
  3890. for (let i = 0; i < projectiles.length; ++i) {
  3891. if (!projectiles[i].active) {
  3892. tmpProj = projectiles[i];
  3893. break;
  3894. }
  3895. }
  3896. if (!tmpProj) {
  3897. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3898. tmpProj.sid = projectiles.length;
  3899. projectiles.push(tmpProj);
  3900. }
  3901. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3902. tmpProj.ignoreObj = ignoreObj;
  3903. tmpProj.layer = layer || tmpData.layer;
  3904. tmpProj.inWindow = inWindow;
  3905. tmpProj.src = tmpData.src;
  3906. return tmpProj;
  3907. };
  3908. }
  3909. };
  3910. class AiManager {
  3911.  
  3912. // AI MANAGER:
  3913. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3914.  
  3915. // AI TYPES:
  3916. this.aiTypes = [{
  3917. id: 0,
  3918. src: "cow_1",
  3919. killScore: 150,
  3920. health: 500,
  3921. weightM: 0.8,
  3922. speed: 0.00095,
  3923. turnSpeed: 0.001,
  3924. scale: 72,
  3925. drop: ["food", 50]
  3926. }, {
  3927. id: 1,
  3928. src: "pig_1",
  3929. killScore: 200,
  3930. health: 800,
  3931. weightM: 0.6,
  3932. speed: 0.00085,
  3933. turnSpeed: 0.001,
  3934. scale: 72,
  3935. drop: ["food", 80]
  3936. }, {
  3937. id: 2,
  3938. name: "Bull",
  3939. src: "bull_2",
  3940. hostile: true,
  3941. dmg: 20,
  3942. killScore: 1000,
  3943. health: 1800,
  3944. weightM: 0.5,
  3945. speed: 0.00094,
  3946. turnSpeed: 0.00074,
  3947. scale: 78,
  3948. viewRange: 800,
  3949. chargePlayer: true,
  3950. drop: ["food", 100]
  3951. }, {
  3952. id: 3,
  3953. name: "Bully",
  3954. src: "bull_1",
  3955. hostile: true,
  3956. dmg: 20,
  3957. killScore: 2000,
  3958. health: 2800,
  3959. weightM: 0.45,
  3960. speed: 0.001,
  3961. turnSpeed: 0.0008,
  3962. scale: 90,
  3963. viewRange: 900,
  3964. chargePlayer: true,
  3965. drop: ["food", 400]
  3966. }, {
  3967. id: 4,
  3968. name: "Wolf",
  3969. src: "wolf_1",
  3970. hostile: true,
  3971. dmg: 8,
  3972. killScore: 500,
  3973. health: 300,
  3974. weightM: 0.45,
  3975. speed: 0.001,
  3976. turnSpeed: 0.002,
  3977. scale: 84,
  3978. viewRange: 800,
  3979. chargePlayer: true,
  3980. drop: ["food", 200]
  3981. }, {
  3982. id: 5,
  3983. name: "Quack",
  3984. src: "chicken_1",
  3985. dmg: 8,
  3986. killScore: 2000,
  3987. noTrap: true,
  3988. health: 300,
  3989. weightM: 0.2,
  3990. speed: 0.0018,
  3991. turnSpeed: 0.006,
  3992. scale: 70,
  3993. drop: ["food", 100]
  3994. }, {
  3995. id: 6,
  3996. name: "MOOSTAFA",
  3997. nameScale: 50,
  3998. src: "enemy",
  3999. hostile: true,
  4000. dontRun: true,
  4001. fixedSpawn: true,
  4002. spawnDelay: 60000,
  4003. noTrap: true,
  4004. colDmg: 100,
  4005. dmg: 40,
  4006. killScore: 8000,
  4007. health: 18000,
  4008. weightM: 0.4,
  4009. speed: 0.0007,
  4010. turnSpeed: 0.01,
  4011. scale: 80,
  4012. spriteMlt: 1.8,
  4013. leapForce: 0.9,
  4014. viewRange: 1000,
  4015. hitRange: 210,
  4016. hitDelay: 1000,
  4017. chargePlayer: true,
  4018. drop: ["food", 100]
  4019. }, {
  4020. id: 7,
  4021. name: "Treasure",
  4022. hostile: true,
  4023. nameScale: 35,
  4024. src: "crate_1",
  4025. fixedSpawn: true,
  4026. spawnDelay: 120000,
  4027. colDmg: 200,
  4028. killScore: 5000,
  4029. health: 20000,
  4030. weightM: 0.1,
  4031. speed: 0.0,
  4032. turnSpeed: 0.0,
  4033. scale: 70,
  4034. spriteMlt: 1.0
  4035. }, {
  4036. id: 8,
  4037. name: "MOOFIE",
  4038. src: "wolf_2",
  4039. hostile: true,
  4040. fixedSpawn: true,
  4041. dontRun: true,
  4042. hitScare: 4,
  4043. spawnDelay: 30000,
  4044. noTrap: true,
  4045. nameScale: 35,
  4046. dmg: 10,
  4047. colDmg: 100,
  4048. killScore: 3000,
  4049. health: 7000,
  4050. weightM: 0.45,
  4051. speed: 0.0015,
  4052. turnSpeed: 0.002,
  4053. scale: 90,
  4054. viewRange: 800,
  4055. chargePlayer: true,
  4056. drop: ["food", 1000]
  4057. }];
  4058.  
  4059. // SPAWN AI:
  4060. this.spawn = function(x, y, dir, index) {
  4061. let tmpObj = ais.find((tmp) => !tmp.active);
  4062. if (!tmpObj) {
  4063. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  4064. ais.push(tmpObj);
  4065. }
  4066. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  4067. return tmpObj;
  4068. };
  4069. }
  4070.  
  4071. };
  4072. class AI {
  4073. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  4074. this.sid = sid;
  4075. this.isAI = true;
  4076. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  4077.  
  4078. // INIT:
  4079. this.init = function(x, y, dir, index, data) {
  4080. this.x = x;
  4081. this.y = y;
  4082. this.startX = data.fixedSpawn ? x : null;
  4083. this.startY = data.fixedSpawn ? y : null;
  4084. this.xVel = 0;
  4085. this.yVel = 0;
  4086. this.zIndex = 0;
  4087. this.dir = dir;
  4088. this.dirPlus = 0;
  4089. this.showName = 'aaa';
  4090. this.index = index;
  4091. this.src = data.src;
  4092. if (data.name) this.name = data.name;
  4093. this.weightM = data.weightM;
  4094. this.speed = data.speed;
  4095. this.killScore = data.killScore;
  4096. this.turnSpeed = data.turnSpeed;
  4097. this.scale = data.scale;
  4098. this.maxHealth = data.health;
  4099. this.leapForce = data.leapForce;
  4100. this.health = this.maxHealth;
  4101. this.chargePlayer = data.chargePlayer;
  4102. this.viewRange = data.viewRange;
  4103. this.drop = data.drop;
  4104. this.dmg = data.dmg;
  4105. this.hostile = data.hostile;
  4106. this.dontRun = data.dontRun;
  4107. this.hitRange = data.hitRange;
  4108. this.hitDelay = data.hitDelay;
  4109. this.hitScare = data.hitScare;
  4110. this.spriteMlt = data.spriteMlt;
  4111. this.nameScale = data.nameScale;
  4112. this.colDmg = data.colDmg;
  4113. this.noTrap = data.noTrap;
  4114. this.spawnDelay = data.spawnDelay;
  4115. this.hitWait = 0;
  4116. this.waitCount = 1000;
  4117. this.moveCount = 0;
  4118. this.targetDir = 0;
  4119. this.active = true;
  4120. this.alive = true;
  4121. this.runFrom = null;
  4122. this.chargeTarget = null;
  4123. this.dmgOverTime = {};
  4124. };
  4125.  
  4126. let tmpRatio = 0;
  4127. let animIndex = 0;
  4128. this.animate = function(delta) {
  4129. if (this.animTime > 0) {
  4130. this.animTime -= delta;
  4131. if (this.animTime <= 0) {
  4132. this.animTime = 0;
  4133. this.dirPlus = 0;
  4134. tmpRatio = 0;
  4135. animIndex = 0;
  4136. } else {
  4137. if (animIndex == 0) {
  4138. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4139. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4140. if (tmpRatio >= 1) {
  4141. tmpRatio = 1;
  4142. animIndex = 1;
  4143. }
  4144. } else {
  4145. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4146. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4147. }
  4148. }
  4149. }
  4150. };
  4151.  
  4152. // ANIMATION:
  4153. this.startAnim = function() {
  4154. this.animTime = this.animSpeed = 600;
  4155. this.targetAngle = Math.PI * 0.8;
  4156. tmpRatio = 0;
  4157. animIndex = 0;
  4158. };
  4159.  
  4160. };
  4161.  
  4162. };
  4163. class addCh {
  4164. constructor(x, y, chat, tmpObj) {
  4165. this.x = x;
  4166. this.y = y;
  4167. this.alpha = 0;
  4168. this.active = true;
  4169. this.alive = false;
  4170. this.chat = chat;
  4171. this.owner = tmpObj;
  4172. };
  4173. };
  4174. class DeadPlayer {
  4175. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4176. this.x = x;
  4177. this.y = y;
  4178. this.lastDir = dir;
  4179. this.dir = dir + Math.PI;
  4180. this.buildIndex = buildIndex;
  4181. this.weaponIndex = weaponIndex;
  4182. this.weaponVariant = weaponVariant;
  4183. this.skinColor = skinColor;
  4184. this.scale = scale;
  4185. this.visScale = 0;
  4186. this.name = name;
  4187. this.alpha = 1;
  4188. this.active = true;
  4189. this.animate = function(delta) {
  4190. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4191. if (d2 > 0.01) {
  4192. this.dir += d2 / 20;
  4193. } else {
  4194. this.dir = this.lastDir;
  4195. }
  4196. if (this.visScale < this.scale) {
  4197. this.visScale += delta / (this.scale / 2);
  4198. if (this.visScale >= this.scale) {
  4199. this.visScale = this.scale;
  4200. }
  4201. }
  4202. this.alpha -= delta / 30000;
  4203. if (this.alpha <= 0) {
  4204. this.alpha = 0;
  4205. this.active = false;
  4206. }
  4207. }
  4208. }
  4209. };
  4210. class Player {
  4211. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4212. this.id = id;
  4213. this.sid = sid;
  4214. this.tmpScore = 0;
  4215. this.team = null;
  4216. this.latestSkin = 0;
  4217. this.oldSkinIndex = 0;
  4218. this.skinIndex = 0;
  4219. this.latestTail = 0;
  4220. this.oldTailIndex = 0;
  4221. this.tailIndex = 0;
  4222. this.hitTime = 0;
  4223. this.lastHit = 0;
  4224. this.showName = 'NOOO';
  4225. this.tails = {};
  4226. for (let i = 0; i < accessories.length; ++i) {
  4227. if (accessories[i].price <= 0)
  4228. this.tails[accessories[i].id] = 1;
  4229. }
  4230. this.skins = {};
  4231. for (let i = 0; i < hats.length; ++i) {
  4232. if (hats[i].price <= 0)
  4233. this.skins[hats[i].id] = 1;
  4234. }
  4235. this.points = 0;
  4236. this.dt = 0;
  4237. this.hidden = false;
  4238. this.itemCounts = {};
  4239. this.isPlayer = true;
  4240. this.pps = 0;
  4241. this.moveDir = undefined;
  4242. this.skinRot = 0;
  4243. this.lastPing = 0;
  4244. this.iconIndex = 0;
  4245. this.skinColor = 0;
  4246. this.dist2 = 0;
  4247. this.aim2 = 0;
  4248. this.maxSpeed = 1;
  4249. this.chat = {
  4250. message: null,
  4251. count: 0
  4252. };
  4253. this.backupNobull = true;
  4254. this.circle = false;
  4255. this.circleRad = 200;
  4256. this.circleRadSpd = 0.1;
  4257. this.cAngle = 0;
  4258. // SPAWN:
  4259. this.spawn = function (moofoll) {
  4260. (this.dmgColor = sid ? "#fff": `#${Math.floor(16777215 * Math.random()).toString(16).padStart(6, "0")}`);
  4261. this.attacked = false;
  4262. this.death = false;
  4263. this.spinDir = 0;
  4264. this.sync = false;
  4265. this.antiBull = 0;
  4266. this.bullTimer = 0;
  4267. this.poisonTimer = 0;
  4268. this.active = true;
  4269. this.alive = true;
  4270. this.lockMove = false;
  4271. this.lockDir = false;
  4272. this.minimapCounter = 0;
  4273. this.chatCountdown = 0;
  4274. this.shameCount = 0;
  4275. this.shameTimer = 0;
  4276. this.sentTo = {};
  4277. this.gathering = 0;
  4278. this.gatherIndex = 0;
  4279. this.shooting = {};
  4280. this.shootIndex = 9;
  4281. this.autoGather = 0;
  4282. this.animTime = 0;
  4283. this.animSpeed = 0;
  4284. this.mouseState = 0;
  4285. this.buildIndex = -1;
  4286. this.weaponIndex = 0;
  4287. this.weaponCode = 0;
  4288. this.weaponVariant = 0;
  4289. this.primaryIndex = undefined;
  4290. this.secondaryIndex = undefined;
  4291. this.dmgOverTime = {};
  4292. this.noMovTimer = 0;
  4293. this.maxXP = 300;
  4294. this.XP = 0;
  4295. this.age = 1;
  4296. this.kills = 0;
  4297. this.upgrAge = 2;
  4298. this.upgradePoints = 0;
  4299. this.x = 0;
  4300. this.y = 0;
  4301. this.oldXY = {
  4302. x: 0,
  4303. y: 0
  4304. };
  4305. this.zIndex = 0;
  4306. this.xVel = 0;
  4307. this.yVel = 0;
  4308. this.slowMult = 1;
  4309. this.dir = 0;
  4310. this.dirPlus = 0;
  4311. this.targetDir = 0;
  4312. this.targetAngle = 0;
  4313. this.maxHealth = 100;
  4314. this.health = this.maxHealth;
  4315. this.oldHealth = this.maxHealth;
  4316. this.damaged = 0;
  4317. this.scale = config.playerScale;
  4318. this.speed = config.playerSpeed;
  4319. this.resetMoveDir();
  4320.  
  4321. this.resetResources(moofoll);
  4322. this.items = [0, 3, 6, 10];
  4323. this.weapons = [0];
  4324. this.shootCount = 0;
  4325. this.weaponXP = [];
  4326. this.reloads = {
  4327. 0: 0,
  4328. 1: 0,
  4329. 2: 0,
  4330. 3: 0,
  4331. 4: 0,
  4332. 5: 0,
  4333. 6: 0,
  4334. 7: 0,
  4335. 8: 0,
  4336. 9: 0,
  4337. 10: 0,
  4338. 11: 0,
  4339. 12: 0,
  4340. 13: 0,
  4341. 14: 0,
  4342. 15: 0,
  4343. 53: 0,
  4344. };
  4345. this.bowThreat = {
  4346. 9: 0,
  4347. 12: 0,
  4348. 13: 0,
  4349. 15: 0,
  4350. };
  4351. this.damageThreat = 0;
  4352. this.inTrap = false;
  4353. this.canEmpAnti = false;
  4354. this.empAnti = false;
  4355. this.soldierAnti = false;
  4356. this.poisonTick = 0;
  4357. this.bullTick = 0;
  4358. this.setPoisonTick = false;
  4359. this.setBullTick = false;
  4360. this.antiTimer = 2;
  4361. };
  4362.  
  4363. // RESET MOVE DIR:
  4364. this.resetMoveDir = function() {
  4365. this.moveDir = undefined;
  4366. };
  4367. // RESET RESOURCES:
  4368. this.resetResources = function(moofoll) {
  4369. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4370. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4371. }
  4372. };
  4373. // ADD ITEM:
  4374. this.getItemType = function(id) {
  4375. let findindx = this.items.findIndex((ids) => ids == id);
  4376. if (findindx != -1) {
  4377. return findindx;
  4378. } else {
  4379. return items.checkItem.index(id, this.items);
  4380. }
  4381. };
  4382. // SET DATA:
  4383. this.setData = function(data) {
  4384. this.id = data[0];
  4385. this.sid = data[1];
  4386. this.name = data[2];
  4387. this.x = data[3];
  4388. this.y = data[4];
  4389. this.dir = data[5];
  4390. this.health = data[6];
  4391. this.maxHealth = data[7];
  4392. this.scale = data[8];
  4393. this.skinColor = data[9];
  4394. };
  4395. // UPDATE POISON TICK:
  4396. this.updateTimer = function() {
  4397. this.bullTimer -= 1;
  4398. if (this.bullTimer <= 0) {
  4399. this.setBullTick = false;
  4400. this.bullTick = game.tick - 1;
  4401. this.bullTimer = config.serverUpdateRate;
  4402. }
  4403. this.poisonTimer -= 1;
  4404. if (this.poisonTimer <= 0) {
  4405. this.setPoisonTick = false;
  4406. this.poisonTick = game.tick - 1;
  4407. this.poisonTimer = config.serverUpdateRate;
  4408. }
  4409. };
  4410. this.update = function(delta) {
  4411. if (this.alive) {
  4412. if (this.health != this.healthMov) {
  4413. this.health < this.healthMov ? (this.healthMov -= 2) : (this.healthMov += 2);
  4414. if (Math.abs(this.health - this.healthMov) < 2) this.healthMov = this.health;
  4415. };
  4416. if (this.shameCount != this.shameMov) this.shameCount < this.shameMov ? (this.shameMov -= .1) : (this.shameMov += .1), Math.abs(this.shameCount - this.shameMov) < .1 && (this.shameMov = this.shameCount);
  4417. }
  4418. if (this.sid == playerSID) {
  4419. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4420. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4421. this.cAngle += this.circleRadSpd;
  4422. }
  4423. if (this.active) {
  4424. // MOVE:
  4425. let gear = {
  4426. skin: findID(hats, this.skinIndex),
  4427. tail: findID(accessories, this.tailIndex)
  4428. }
  4429. 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;
  4430. this.maxSpeed = spdMult;
  4431. }
  4432. };
  4433. let tmpRatio = 0;
  4434. let animIndex = 0;
  4435. this.animate = function(delta) {
  4436. if (this.animTime > 0) {
  4437. this.animTime -= delta;
  4438. if (this.animTime <= 0) {
  4439. this.animTime = 0;
  4440. this.dirPlus = 0;
  4441. tmpRatio = 0;
  4442. animIndex = 0;
  4443. } else {
  4444. if (animIndex == 0) {
  4445. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4446. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4447. if (tmpRatio >= 1) {
  4448. tmpRatio = 1;
  4449. animIndex = 1;
  4450. }
  4451. } else {
  4452. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4453. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4454. }
  4455. }
  4456. }
  4457. };
  4458. // GATHER ANIMATION:
  4459. this.startAnim = function(didHit, index) {
  4460. this.animTime = this.animSpeed = items.weapons[index].speed;
  4461. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4462. tmpRatio = 0;
  4463. animIndex = 0;
  4464. };
  4465. // CAN SEE:
  4466. this.canSee = function(other) {
  4467. if (!other) return false;
  4468. let dx = Math.abs(other.x - this.x) - other.scale;
  4469. let dy = Math.abs(other.y - this.y) - other.scale;
  4470. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4471. };
  4472. // SHAME SYSTEM:
  4473. this.judgeShame = function() {
  4474. if (this.oldHealth < this.health) {
  4475. if (this.hitTime) {
  4476. let timeSinceHit = Date.now() - this.hitTime;
  4477. this.lastHit = game.tick;
  4478. this.hitTime = 0;
  4479. if (timeSinceHit < 120) {
  4480. this.shameCount++;
  4481. } else {
  4482. this.shameCount = Math.max(0, this.shameCount - 2);
  4483. }
  4484. }
  4485. } else if (this.oldHealth > this.health) {
  4486. this.hitTime = Date.now();
  4487. }
  4488. };
  4489. this.addShameTimer = function() {
  4490. this.shameCount = 0;
  4491. this.shameTimer = 30;
  4492. let interval = setInterval(() => {
  4493. this.shameTimer--;
  4494. if (this.shameTimer <= 0) {
  4495. clearInterval(interval);
  4496. }
  4497. }, 1000);
  4498. };
  4499. // CHECK TEAM:
  4500. this.isTeam = function(tmpObj) {
  4501. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4502. };
  4503. // FOR THE PLAYER:
  4504. this.findAllianceBySid = function(sid) {
  4505. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4506. };
  4507. this.checkCanInsta = function(nobull) {
  4508. let totally = 0;
  4509. if (this.alive && inGame) {
  4510. let primary = {
  4511. weapon: this.weapons[0],
  4512. variant: this.primaryVariant,
  4513. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4514. };
  4515. let secondary = {
  4516. weapon: this.weapons[1],
  4517. variant: this.secondaryVariant,
  4518. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4519. };
  4520. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4521. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4522. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4523. totally += primary.dmg * pV * bull;
  4524. }
  4525. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4526. totally += secondary.dmg;
  4527. }
  4528. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4529. totally += 25;
  4530. }
  4531. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4532. return totally;
  4533. }
  4534. return 0;
  4535. };
  4536. // UPDATE WEAPON RELOAD:
  4537. this.manageReload = function() {
  4538. if (this.shooting[53]) {
  4539. this.shooting[53] = 0;
  4540. this.reloads[53] = (2500 - game.tickRate);
  4541. } else {
  4542. if (this.reloads[53] > 0) {
  4543. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4544. }
  4545. }
  4546. if (this.gathering || this.shooting[1]) {
  4547. if (this.gathering) {
  4548. this.gathering = 0;
  4549. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4550. this.attacked = true;
  4551. }
  4552. if (this.shooting[1]) {
  4553. this.shooting[1] = 0;
  4554. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4555. this.attacked = true;
  4556. }
  4557. } else {
  4558. this.attacked = false;
  4559. if (this.buildIndex < 0) {
  4560. if (this.reloads[this.weaponIndex] > 0) {
  4561. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  4562. if (this == player) {
  4563. if (getEl("weaponGrind").checked) {
  4564. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4565. checkPlace(player.getItemType(22), i);
  4566. }
  4567. }
  4568. }
  4569. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4570. this.antiBull++;
  4571. game.tickBase(() => {
  4572. this.antiBull = 0;
  4573. }, 1);
  4574. }
  4575. }
  4576. }
  4577. }
  4578. };
  4579.  
  4580.  
  4581. // FOR ANTI INSTA:
  4582. this.addDamageThreat = function(tmpObj) {
  4583. let primary = {
  4584. weapon: this.primaryIndex,
  4585. variant: this.primaryVariant
  4586. };
  4587. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4588. let secondary = {
  4589. weapon: this.secondaryIndex,
  4590. variant: this.secondaryVariant
  4591. };
  4592. secondary.dmg = secondary.weapon == undefined ? 35 : items.weapons[secondary.weapon].Pdmg;
  4593. let bull = 1.5;
  4594. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4595. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4596. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4597. this.damageThreat += primary.dmg * pV * bull;
  4598. }
  4599. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4600. this.damageThreat += secondary.dmg * sV;
  4601. }
  4602. if (this.reloads[53] <= game.tickRate) {
  4603. this.damageThreat += 25;
  4604. }
  4605. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4606. if (!this.isTeam(tmpObj)) {
  4607. if (this.dist2 <= 300) {
  4608. tmpObj.damageThreat += this.damageThreat;
  4609. }
  4610. }
  4611. };
  4612. // ANTI
  4613. this.addDamageProbability = function(tmpObj) {
  4614. let primary = {
  4615. weapon: this.primaryIndex,
  4616. variant: this.primaryVariant
  4617. };
  4618. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4619. let secondary = {
  4620. weapon: this.secondaryIndex,
  4621. variant: this.secondaryVariant
  4622. };
  4623. secondary.dmg = secondary.weapon == undefined ? 50 : items.weapons[secondary.weapon].Pdmg;
  4624. let bull = 1.5;
  4625. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4626. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4627. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4628. this.damageProbably += primary.dmg * pV * bull * 0.75;
  4629. }
  4630. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4631. this.damageProbably += secondary.dmg * sV;
  4632. }
  4633. this.damageProbably *= 0.75;
  4634. if (!this.isTeam(tmpObj)) {
  4635. if (this.dist2 <= 300) {
  4636. tmpObj.damageProbably += this.damageProbably;
  4637. }
  4638. }
  4639. };
  4640. }
  4641. };
  4642.  
  4643.  
  4644. // SOME CODES:
  4645. function sendUpgrade(index) {
  4646. player.reloads[index] = 0;
  4647. packet("H", index);
  4648. }
  4649. function storeEquip(id, index) {
  4650. packet("c", 0, id, index);
  4651. }
  4652. function storeBuy(id, index) {
  4653. packet("c", 1, id, index);
  4654. }
  4655. function buyEquip(id, index) {
  4656. let nID = player.skins[6] ? 6 : 0;
  4657. if (player.alive && inGame) {
  4658. if (index == 0) {
  4659. if (player.skins[id]) {
  4660. if (player.latestSkin != id) {
  4661. packet("c", 0, id, 0);
  4662. }
  4663. } else {
  4664. if (configs.autoBuyEquip) {
  4665. let find = findID(hats, id);
  4666. if (find) {
  4667. if (player.points >= find.price) {
  4668. //setTimeout(()=>{
  4669. packet("c", 1, id, 0);
  4670. //setTimeout(()=>{
  4671. packet("c", 0, id, 0);
  4672. //}, 120);
  4673. //}, 120);
  4674. } else {
  4675. if (player.latestSkin != nID) {
  4676. packet("c", 0, nID, 0);
  4677. }
  4678. }
  4679. } else {
  4680. if (player.latestSkin != nID) {
  4681. packet("c", 0, nID, 0);
  4682. }
  4683. }
  4684. } else {
  4685. if (player.latestSkin != nID) {
  4686. packet("c", 0, nID, 0);
  4687. }
  4688. }
  4689. }
  4690. } else if (index == 1) {
  4691. if (useWasd && (id != 11 && id != 0)) {
  4692. if (player.latestTail != 0) {
  4693. packet("c", 0, 0, 1);
  4694. }
  4695. return;
  4696. }
  4697. if (player.tails[id]) {
  4698. if (player.latestTail != id) {
  4699. packet("c", 0, id, 1);
  4700. }
  4701. } else {
  4702. if (configs.autoBuyEquip) {
  4703. let find = findID(accessories, id);
  4704. if (find) {
  4705. if (player.points >= find.price) {
  4706. packet("c", 1, id, 1);
  4707. // setTimeout(()=>{
  4708. packet("c", 0, id, 1);
  4709. //}, 120);
  4710. } else {
  4711. if (player.latestTail != 0) {
  4712. packet("c", 0, 0, 1);
  4713. }
  4714. }
  4715. } else {
  4716. if (player.latestTail != 0) {
  4717. packet("c", 0, 0, 1);
  4718. }
  4719. }
  4720. } else {
  4721. if (player.latestTail != 0) {
  4722. packet("c", 0, 0, 1);
  4723. }
  4724. }
  4725. }
  4726. }
  4727. }
  4728. }
  4729. function selectToBuild(index, wpn) {
  4730. packet("G", index, wpn);
  4731. }
  4732. function selectWeapon(index, isPlace) {
  4733. if (!isPlace) {
  4734. player.weaponCode = index;
  4735. }
  4736. packet("G", index, 1);
  4737. }
  4738. function sendAutoGather() {
  4739. packet("K", 1, 1);
  4740. }
  4741. function sendAtck(id, angle) {
  4742. packet("d", id, angle, 1);
  4743. }
  4744. function toRadian(angle) {
  4745. let fixedAngle = (angle % 360) * (Math.PI / 180);
  4746. return fixedAngle < 0 ? (2 * Math.PI + fixedAngle) : fixedAngle;
  4747. }
  4748.  
  4749. // PLACER:
  4750. function place(id, rad, rmd) {
  4751. try {
  4752. if (id == undefined) return;
  4753. let item = items.list[player.items[id]];
  4754. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4755. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4756. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4757. if ((player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? 297 : item.group.limit ? item.group.limit : 99))) {
  4758. selectToBuild(player.items[id]);
  4759. sendAtck(1, rad);
  4760. selectWeapon(player.weaponCode, 1);
  4761. if (rmd && getEl("placeVis").checked) {
  4762. placeVisible.push({
  4763. x: tmpX,
  4764. y: tmpY,
  4765. name: item.name,
  4766. scale: item.scale,
  4767. dir: rad
  4768. });
  4769. game.tickBase(() => {
  4770. placeVisible.shift();
  4771. }, 1)
  4772. }
  4773. }
  4774. } catch (e) {}
  4775. }
  4776.  
  4777. function checkPlace(id, rad) {
  4778. try {
  4779. if (id == undefined) return;
  4780. let item = items.list[player.items[id]];
  4781. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4782. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4783. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4784. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4785. place(id, rad, 1);
  4786. }
  4787. } catch (e) {}
  4788. }
  4789.  
  4790. // HEALING:
  4791. function soldierMult() {
  4792. return player.latestSkin == 6 ? 0.75 : 1;
  4793. }
  4794.  
  4795. function healthBased() {
  4796. if (player.health == 100)
  4797. return 0;
  4798. if ((player.skinIndex != 70 && player.skinIndex != 74)) {
  4799. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4800. }
  4801. return 0;
  4802. }
  4803.  
  4804. function getAttacker(damaged) {
  4805. let attackers = enemy.filter(tmp => {
  4806. //let damages = new Damages(items);
  4807. //let dmg = damages.weapons[tmp.weaponIndex];
  4808. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4809. let rule = {
  4810. //one: tmp.dist2 <= 300,
  4811. //two: by.includes(damaged),
  4812. three: tmp.attacked
  4813. }
  4814. return /*rule.one && rule.two && */ rule.three;
  4815. });
  4816. return attackers;
  4817. }
  4818.  
  4819. function getHealthItemsNeeded() {
  4820. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4821. }
  4822.  
  4823. function healer() {
  4824. let numItemsNeeded = getHealthItemsNeeded();
  4825. for (let i = 0; i < numItemsNeeded; i++) {
  4826. place(0, getAttackDir());
  4827. }
  4828. }
  4829.  
  4830. function healer33() {
  4831. let numItemsNeeded = getHealthItemsNeeded();
  4832. for (let i = 0; i < numItemsNeeded; i++) {
  4833. place(0, getAttackDir());
  4834. }
  4835. }
  4836.  
  4837. function healer1() {
  4838. let numItemsNeeded = Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4839. place(0, getAttackDir());
  4840. return numItemsNeeded;
  4841. }
  4842.  
  4843.  
  4844. function noshameheal() {
  4845. place(0, getAttackDir());
  4846. if (player.shameCount >= 5) {
  4847. place(0, getAttackDir());
  4848. healer33();
  4849. }else{
  4850. if (player.shameCount <= 4 && player.skinIndex != 6 && player.skinIndex != 22) {
  4851. healer33();
  4852. buyEquip(6, 0);
  4853. }else{
  4854. if (player.shameCount >= 5 && player.skinIndex != 6 && player.skinIndex != 22) {
  4855. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4856. healer33();
  4857.  
  4858. /*}else{
  4859. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4860. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4861. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);*/
  4862. }
  4863. }
  4864. }
  4865. }
  4866.  
  4867.  
  4868. function antiSyncHealing(timearg) {
  4869. my.antiSync = true;
  4870. let healAnti = setInterval(() => {
  4871. if (player.shameCount < 5) {
  4872. place(0, getAttackDir());
  4873. }
  4874. }, 75);
  4875. setTimeout(() => {
  4876. clearInterval(healAnti);
  4877. setTimeout(() => {
  4878. my.antiSync = false;
  4879. }, game.tickRate);
  4880. }, game.tickRate);
  4881. }
  4882.  
  4883. function biomeGear(mover, returns) {
  4884. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4885. if (returns) return 31;
  4886. buyEquip(31, 0);
  4887. } else {
  4888. if (player.y2 <= config.snowBiomeTop) {
  4889. if (returns) return mover && player.moveDir == undefined ? 6 : 15;
  4890. buyEquip(mover && player.moveDir == undefined ? 6 : 15, 0);
  4891. } else {
  4892. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  4893. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  4894. }
  4895. }
  4896. if (returns) return 0;
  4897. }
  4898. function woah(mover) {
  4899. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4900. }
  4901.  
  4902. class Traps {
  4903. constructor(UTILS, items) {
  4904. this.dist = 0;
  4905. this.aim = 0;
  4906. this.inTrap = false;
  4907. this.replaced = false;
  4908. this.antiTrapped = false;
  4909. this.info = {};
  4910. this.notFast = function() {
  4911. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4912. }
  4913. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 21), radian, replacer, yaboi) {
  4914. try {
  4915. let item = items.list[player.items[id]];
  4916. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4917. let counts = {
  4918. attempts: 0,
  4919. placed: 0
  4920. };
  4921. let tmpObjects = [];
  4922. liztobj.forEach((p) => {
  4923. tmpObjects.push({
  4924. x: p.x,
  4925. y: p.y,
  4926. active: p.active,
  4927. blocker: p.blocker,
  4928. scale: p.scale,
  4929. isItem: p.isItem,
  4930. type: p.type,
  4931. colDiv: p.colDiv,
  4932. getScale: function(sM, ig) {
  4933. sM = sM || 1;
  4934. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4935. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4936. },
  4937. });
  4938. });
  4939. for (let i = first; i < repeat; i += plus) {
  4940. counts.attempts++;
  4941. let relAim = radian + i;
  4942. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4943. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4944. 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)));
  4945. if (cantPlace) continue;
  4946. if (item.id != 21 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4947. if ((!replacer && yaboi)) {
  4948. if (yaboi.inTrap) {
  4949. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI*1.3) {
  4950. place(2, relAim, 1);
  4951. } else {
  4952. player.items[4] == 15 && place(4, relAim, 1);
  4953. }
  4954. } else {
  4955. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 2.6) {
  4956. place(2, relAim, 1);
  4957. } else {
  4958. player.items[4] == 15 && place(4, relAim, 1);
  4959. }
  4960. }
  4961. } else {
  4962. place(id, relAim, 1);
  4963. }
  4964. tmpObjects.push({
  4965. x: tmpX,
  4966. y: tmpY,
  4967. active: true,
  4968. blocker: item.blocker,
  4969. scale: item.scale,
  4970. isItem: true,
  4971. type: null,
  4972. colDiv: item.colDiv,
  4973. getScale: function() {
  4974. return this.scale;
  4975. },
  4976. });
  4977. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4978. counts.placed++;
  4979. }
  4980. }
  4981. if (counts.placed > 0 && replacer && item.dmg) {
  4982. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4983. instaC.canSpikeTick = true;
  4984. }
  4985. }
  4986. } catch (err) {
  4987. }
  4988. };
  4989. this.checkSpikeTick = function() {
  4990. try {
  4991. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4992. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4993. // more range for safe. also testing near.primaryIndex || 5
  4994. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4995. let item = items.list[9];
  4996. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4997. let danger = 0;
  4998. let counts = {
  4999. attempts: 0,
  5000. block: `unblocked`
  5001. };
  5002. for (let i = -1; i <= 1; i += 1 / 10) {
  5003. counts.attempts++;
  5004. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5005. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5006. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5007. 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)));
  5008. if (cantPlace) continue;
  5009. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5010. danger++;
  5011. counts.block = `blocked`;
  5012. break;
  5013. }
  5014. if (danger) {
  5015. my.anti0Tick = 1;
  5016. // player.chat.message = "Anti SpikeTick " + near.sid;
  5017. //player.chat.count = 2000;
  5018. return true;
  5019. }
  5020. }
  5021. } catch (err) {
  5022. return null;
  5023. }
  5024. return false;
  5025. }
  5026.  
  5027. function getDist(e, t) {
  5028. try {
  5029. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  5030. } catch (e) {
  5031. return Infinity;
  5032. }
  5033. }
  5034.  
  5035. this.protect = function(aim) {
  5036. if (!configs.antiTrap) return;
  5037. if (player.items[4]) {
  5038. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 21), aim + Math.PI);
  5039. this.antiTrapped = true;
  5040. }
  5041. };
  5042.  
  5043. let trappling = false;
  5044. let spikeplacer = false;
  5045.  
  5046. this.autoPlace = function () {
  5047. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5048. if (gameObjects.length) {
  5049. let near2 = {
  5050. inTrap: true,
  5051. };
  5052. 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) {
  5053. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5054. })[0];
  5055. if (nearTrap) {
  5056. near2.inTrap = true;
  5057. } else {
  5058. near2.inTrap = true;
  5059. }
  5060. if (this.testMode ? enemy.length : (near.dist2 <= 375)) {
  5061. if (near.dist2 <= 160) {
  5062. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 180), near.aim2, 0, {inTrap: near2.inTrap});
  5063. } else {
  5064. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 180), near.aim2);
  5065. }
  5066. }
  5067. } else {
  5068. if (this.testMode ? enemy.length : (near.dist2 <= 1000)) {
  5069. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 180), near.aim2);
  5070. }
  5071. }
  5072. }
  5073. };
  5074.  
  5075. function FastPlace(id, rad) {
  5076. try {
  5077. place(id, rad, 1);
  5078. } catch (e) {}
  5079. }
  5080. function TrapDir() {
  5081. let trap;
  5082. trap = gameObjects.filter(tmp => tmp.trap && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + checkDist + player.scale)).sort(function(a, b) {
  5083. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  5084. })[0];
  5085.  
  5086. if (trap && !traps.inTrap && !clicks.middle) {
  5087. let aim = UTILS.getDirect(trap, player, 0, 2);
  5088. return aim;
  5089. } else {
  5090. return lastDir || 0;
  5091. }
  5092. }
  5093. function SpikeDir() {
  5094. let spike;
  5095. if (near.dist2 > 230 && config.autobot && !my.autoPush && enemy.length) {
  5096. if (traps.inTrap) {
  5097. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  5098. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  5099. })[0];
  5100. } else {
  5101. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + neardist + player.scale)).sort(function(a, b) {
  5102. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  5103. })[0];
  5104. }
  5105. } else {
  5106. if (traps.inTrap) {
  5107. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (items.weapons[player.weapons[0]].range + player.scale * 1.5)).sort(function(a, b) {
  5108. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  5109. })[0];
  5110. } else {
  5111. spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + checkDist + player.scale)).sort(function(a, b) {
  5112. return UTILS.getDist(a, player, 0, 5) - UTILS.getDist(b, player, 0, 5);
  5113. })[0];
  5114. }
  5115. }
  5116.  
  5117. if (spike) {
  5118. let aim = UTILS.getDirect(spike, player, 0, 2);
  5119. return aim;
  5120. } else {
  5121. return lastDir || 0;
  5122. }
  5123. }
  5124. this.prePlace = function() {
  5125. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5126. let nearestObj = null;
  5127. let nearestDist = Infinity;
  5128. for (let i = 0; i < gameObjects.length; i++) {
  5129. let obj = gameObjects[i];
  5130. if (obj.trap && obj.active && obj.isTeamObject(player)) {
  5131. let dist = UTILS.getDist(obj, player, 0, 2);
  5132. if (dist < nearestDist) {
  5133. nearestDist = dist;
  5134. nearestObj = obj;
  5135. }
  5136. }
  5137. }
  5138. if (nearestObj) {
  5139. let perfectAngle = UTILS.getDirect(nearestObj, player, 0, 2);
  5140. if (my.SpikeAim) {
  5141. if (spikePlace) {
  5142. FastPlace(2, SpikeDir());
  5143. } else {
  5144. player.items[4] == 15 && FastPlace(4, SpikeDir());
  5145. }
  5146. } else if (my.TrapAim) {
  5147. if (spikePlace) {
  5148. FastPlace(2, TrapDir());
  5149. } else {
  5150. player.items[4] == 15 && FastPlace(4, TrapDir());
  5151. }
  5152. } else {
  5153. if (spikePlace) {
  5154. FastPlace(2, perfectAngle);
  5155. } else {
  5156. player.items[4] == 15 && FastPlace(4, perfectAngle);
  5157. }
  5158. }
  5159. }
  5160. }
  5161. };
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167. /*
  5168. this.autoPlace = function() {
  5169. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5170. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5171. if (liztobj.length) {
  5172. let near2 = {
  5173. inTrap: false,
  5174. };
  5175. 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) {
  5176. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5177.  
  5178. })[0];
  5179. if (nearTrap) {
  5180. near2.inTrap = true;
  5181. } else {
  5182. near2.inTrap = false;
  5183. }
  5184. if (near.dist3 <= 276 && !spikeplacer) {
  5185. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5186. inTrap: near2.inTrap
  5187. });
  5188. } else {
  5189. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5190. }
  5191. }
  5192. }
  5193. }
  5194. };*/
  5195.  
  5196. let spikePlaced = false;
  5197. let spikSync = false;
  5198.  
  5199.  
  5200. this.replacer = function(findObj,) {
  5201. if (!findObj || !configs.autoReplace) return;
  5202. if (!inGame) return;
  5203. if (this.antiTrapped) return;
  5204. game.tickBase(() => {
  5205. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5206. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5207. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5208.  
  5209. if(spikePlaced){
  5210. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5211. spikePlaced = false;
  5212. }
  5213. if (near.dist2 <= 250 && !spikSync) {
  5214. for (let i = 0; i < 24; i++) {
  5215. let angle = (Math.PI * 2) * i / 24;
  5216. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1);
  5217. spikePlaced = true;
  5218. }
  5219. }
  5220. if (objDst <= 250 && near.dist2 <= 250) {
  5221. let danger = this.checkSpikeTick();
  5222. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5223.  
  5224. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1)
  5225. for (let i = 0; i < 24; i++) { // Цикл для создания спайков в разных направлениях
  5226. let angle = (Math.PI * 2) * i / 24;
  5227. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1); // / Ставим спайк в текущем направлении
  5228. this.testCanPlace(2, (Math.PI / 2), (Math.PI / 2), (Math.PI / 2), near, objAim, 1)
  5229. spikSync = true;
  5230.  
  5231. }
  5232. } else {
  5233. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5234. }
  5235.  
  5236. this.replaced = true;
  5237. }
  5238. }, 1);
  5239. };
  5240. }
  5241. };
  5242. this.preplacer = function(findObj) {
  5243. if (!findObj || !configs.autoReplace) return;
  5244. if (!inGame) return;
  5245. if (this.antiTrapped) return;
  5246.  
  5247. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5248. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5249.  
  5250. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5251.  
  5252. let placerQueue = [];
  5253.  
  5254. for (let i = 0; i < 24; i++) {
  5255. let angle = (Math.PI * 2) * i / 24;
  5256. placerQueue.push({ type: 2, angle: angle, aim: objAim }); // spike
  5257. placerQueue.push({ type: 4, angle: angle, aim: objAim }); // trap
  5258. }
  5259.  
  5260. let placerInterval = setInterval(() => {
  5261. if (placerQueue.length === 0) {
  5262. clearInterval(placerInterval);
  5263. return;
  5264. }
  5265.  
  5266. let placerData = placerQueue.shift();
  5267. this.testCanPlace(placerData.type, placerData.angle, placerData.angle + (Math.PI / 24), (Math.PI / 24), placerData.aim, 1);
  5268. }, 1); // adjust the interval to your liking (lower values = faster placement)
  5269. };
  5270. class Instakill {
  5271. constructor() {
  5272. this.canSpikeTick = false;
  5273. this.canCounter = false;
  5274. this.isTrue = false;
  5275. this.wait = false;
  5276. this.can = false;
  5277. this.changeType = function(type) {
  5278. this.wait = false;
  5279. this.isTrue = true;
  5280. my.InstaAim = true;
  5281. if (player.tailIndex == 11) {
  5282. buyEquip(Wings, 1);
  5283. game.tickBase(() => {
  5284. if (type == "rev") {
  5285. selectWeapon(player.weapons[1]);
  5286. buyEquip(53, 0);
  5287. sendAutoGather();
  5288. game.tickBase(() => {
  5289. selectWeapon(player.weapons[0]);
  5290. buyEquip(7, 0);
  5291. game.tickBase(() => {
  5292. sendAutoGather();
  5293. this.isTrue = false;
  5294. my.InstaAim = false;
  5295. }, 1);
  5296. }, 1);
  5297. } else if (type == "normal") {
  5298. selectWeapon(player.weapons[0]);
  5299. buyEquip(7, 0);
  5300. sendAutoGather();
  5301. game.tickBase(() => {
  5302. selectWeapon(player.weapons[1]);
  5303. buyEquip(53, 0);
  5304. game.tickBase(() => {
  5305. detectHat(6);
  5306. sendAutoGather();
  5307. this.isTrue = false;
  5308. game.tickBase(() => {
  5309. my.InstaAim = false;
  5310. }, 1);
  5311. }, 1);
  5312. }, 1);
  5313. } else {
  5314. setTimeout(() => {
  5315. this.isTrue = false;
  5316. my.InstaAim = false;
  5317. }, 150);
  5318. }
  5319. }, 1);
  5320. } else {
  5321. if (type == "rev") {
  5322. selectWeapon(player.weapons[1]);
  5323. buyEquip(53, 0);
  5324. sendAutoGather();
  5325. game.tickBase(() => {
  5326. selectWeapon(player.weapons[0]);
  5327. buyEquip(7, 0);
  5328. game.tickBase(() => {
  5329. sendAutoGather();
  5330. this.isTrue = false;
  5331. game.tickBase(() => {
  5332. my.InstaAim = false;
  5333. }, 1);
  5334. }, 1);
  5335. }, 1);
  5336. } else if (type == "normal") {
  5337. selectWeapon(player.weapons[0]);
  5338. buyEquip(7, 0);
  5339. sendAutoGather();
  5340. game.tickBase(() => {
  5341. selectWeapon(player.weapons[1]);
  5342. buyEquip(53, 0);
  5343. game.tickBase(() => {
  5344. detectHat(6);
  5345. sendAutoGather();
  5346. my.InstaAim = false;
  5347. this.isTrue = false;
  5348. }, 1);
  5349. }, 1);
  5350. } else {
  5351. setTimeout(() => {
  5352. this.isTrue = false;
  5353. my.InstaAim = false;
  5354. }, 50);
  5355. }
  5356. }
  5357. };
  5358. this.syncTry = function() {
  5359. buyEquip(53, 0);
  5360. game.tickBase(() => {
  5361. this.isTrue = true;
  5362. my.autoAim = true;
  5363. selectWeapon(player.weapons[1]);
  5364. sendAutoGather();
  5365. game.tickBase(() => {
  5366. my.autoAim = false;
  5367. this.isTrue = false;
  5368. sendAutoGather();
  5369. }, 1);
  5370. }, 2);
  5371. };
  5372. this.MapSync = function() {
  5373. let nearDistCheck;
  5374. nearDistCheck = (near.dist2 <= 300) ? 1 : 2
  5375. buyEquip(53, 0);
  5376. game.tickBase(() => {
  5377. selectWeapon(player.weapons[1]);
  5378. sendAutoGather();
  5379. this.isTrue = true;
  5380. my.autoAim = true;
  5381. game.tickBase(() => {
  5382. my.autoAim = false;
  5383. this.isTrue = false;
  5384. sendAutoGather();
  5385. }, 1);
  5386. }, nearDistCheck);
  5387. };
  5388. this.counterType = function () {
  5389. this.isTrue = true;
  5390. my.autoAim = true;
  5391. selectWeapon(player.weapons[0]);
  5392. buyEquip(7, 0);
  5393. buyEquip(Wings, 1);
  5394. sendAutoGather();
  5395. game.tickBase(() => {
  5396. if (player.reloads[53] == 0 && player.weapons[1] == 10) {
  5397. selectWeapon(player.weapons[0]);
  5398. buyEquip(53, 0);
  5399. buyEquip(Wings, 1);
  5400. game.tickBase(() => {
  5401. sendAutoGather();
  5402. this.isTrue = false;
  5403. my.autoAim = false;
  5404. }, 1);
  5405. } else {
  5406. sendAutoGather();
  5407. this.isTrue = false;
  5408. my.autoAim = false;
  5409. }
  5410. }, 1);
  5411. };
  5412. this.bowInstaCheck = function() {
  5413. let stop = setInterval(() => {
  5414. if (!enemy.length || traps.inTrap || player.reloads[53] != 0) {
  5415. clearInterval(stop);
  5416. }
  5417. stopUp = false;
  5418. if (near.dist2 < 590) {
  5419. buyEquip(12, 0);
  5420. packet("a", near.aim2 + Math.PI, 1);
  5421. } else {
  5422. if (near.skinIndex != 22) {
  5423. packet("a", undefined, 1);
  5424. clearInterval(stop);
  5425. game.tickBase(() => {
  5426. buyEquip(53, 0);
  5427. this.isTrue = true;
  5428. my.autoAim = true;
  5429. selectWeapon(player.weapons[1]);
  5430. sendAutoGather();
  5431. if (player.upgrAge === 7) {
  5432. sendUpgrade(38);
  5433. }
  5434. buyEquip(53, 0);
  5435. game.tickBase(() => {
  5436. if (player.upgrAge === 8) {
  5437. sendUpgrade(12);
  5438. }
  5439. selectWeapon(player.weapons[1]);
  5440. game.tickBase(() => {
  5441. if (player.upgrAge === 9) {
  5442. sendUpgrade(15);
  5443. }
  5444. selectWeapon(player.weapons[1]);
  5445. buyEquip(53, 0);
  5446. game.tickBase(() => {
  5447. sendAutoGather();
  5448. this.isTrue = false;
  5449. my.autoAim = false;
  5450. stopUp = true
  5451. }, 1);
  5452. }, 1);
  5453. }, 1);
  5454. }, 1);
  5455. } else {
  5456. if (near.dist2 >= 630) {
  5457. packet("a", near.aim2, 1);
  5458. } else {
  5459. packet("a", undefined, 1);
  5460. }
  5461. }
  5462. }
  5463. }, 0);
  5464. };
  5465. this.CheckSoldier = function () {
  5466. if ((near.skinIndex != 6 && traps.canHit()) || (traps.cantHit() && near.reloads[near.weaponIndex] != 0)) {
  5467. return true;
  5468. } else {
  5469. return false;
  5470. }
  5471. };
  5472. this.OneFrameType = function () {
  5473. let Frame = setInterval(() => {
  5474. if (!checkOneFrame || secPacket >= 85 || (traps.inTrap && near.dist2 <= 300) || !enemy.length) {
  5475. checkOneFrame = false;
  5476. clearInterval(Frame);
  5477. game.tickBase(() => {
  5478. packet("a", undefined, 1);
  5479. instaC.isTrue = false;
  5480. }, 1);
  5481. };
  5482. if (!clicks.left && !clicks.right) {
  5483. if (this.CheckSoldier() && player.reloads[53] == 0 && near.skinIndex != 22 && near.dist2 >= items.weapons[player.weapons[0]].range + near.scale * 2.25 && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 2.45) {
  5484. clearInterval(Frame);
  5485. buyEquip(53, 0);
  5486. packet("a", near.aim2, 1);
  5487. game.tickBase(() => {
  5488. packet("a", near.aim2, 1);
  5489. this.isTrue = true;
  5490. my.InstaAim = true;
  5491. sendAutoGather();
  5492. selectWeapon(player.weapons[0]);
  5493. buyEquip(7, 0);
  5494. game.tickBase(() => {
  5495. packet("a", near.aim2, 1);
  5496. sendAutoGather();
  5497. this.isTrue = false;
  5498. my.InstaAim = false;
  5499. game.tickBase(() => {
  5500. checkOneFrame = false;
  5501. packet("a", undefined, 1);
  5502. }, 1);
  5503. }, 1);
  5504. }, 1);
  5505. } else {
  5506. let niglet = pathFind;
  5507. niglet.scale = (config.maxScreenWidth / 2) * 1.3;
  5508. if (enemy.length) {
  5509. if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 5) {
  5510. if (!my.SpikeAim && !my.MillAim && !my.TeleAim && !my.TrapAim) {
  5511. this.isTrue = near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 3 ? true : false;
  5512. this.isTrue && buyEquip(Wings, 1);
  5513. if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 2.22) {
  5514. packet("a", near.aim2 + Math.PI, 1);
  5515. this.isTrue && buyEquip(6, 0);
  5516. } else {
  5517. packet("a", near.aim2, 1);
  5518. this.isTrue && buyEquip(40, 0);
  5519. }
  5520. } else {
  5521. this.isTrue = false;
  5522. }
  5523. } else {
  5524. createPath();
  5525. easystar.setGrid(grid);
  5526. easystar.setAcceptableTiles([0]);
  5527. easystar.enableDiagonals();
  5528. easystar.findPath((grid[0].length / 2), (grid.length / 2), niglet.lastX, niglet.lastY, function(path) {
  5529. if (path === null) {
  5530. niglet.array = [];
  5531. if (!traps.inTrap && !my.SpikeAim && !my.MillAim && !my.TeleAim && !my.TrapAim) {
  5532. this.isTrue = near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 3 ? true : false;
  5533. this.isTrue && buyEquip(Wings, 1);
  5534. if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 2.22) {
  5535. packet("a", near.aim2 + Math.PI, 1);
  5536. this.isTrue && buyEquip(6, 0);
  5537. } else {
  5538. packet("a", near.aim2, 1);
  5539. this.isTrue && buyEquip(40, 0);
  5540. }
  5541. } else {
  5542. this.isTrue = false;
  5543. }
  5544. } else {
  5545. niglet.array = path;
  5546. if (niglet.array.length > 1) {
  5547. let tmpXY = {
  5548. x: (player.x2 - (niglet.scale / 2)) + ((niglet.scale / niglet.grid) * path[1].x),
  5549. y: (player.y2 - (niglet.scale / 2)) + ((niglet.scale / niglet.grid) * path[1].y)
  5550. }
  5551. io.send("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  5552. }
  5553. }
  5554. });
  5555. easystar.calculate();
  5556. }
  5557. }
  5558. }
  5559. }
  5560. }, 0);
  5561. }
  5562. this.spikeTickType = function () {
  5563. this.isTrue = true;
  5564. my.autoAim = true;
  5565. selectWeapon(player.weapons[0]);
  5566. buyEquip(7, 0);
  5567. buyEquip(19, 1);
  5568. sendAutoGather();
  5569. game.tickBase(() => {
  5570. if (player.reloads[53] == 0 && player.weapons[1] == 10) {
  5571. selectWeapon(player.weapons[0]);
  5572. buyEquip(53, 0);
  5573. game.tickBase(() => {
  5574. sendAutoGather();
  5575. this.isTrue = false;
  5576. my.autoAim = false;
  5577. }, 1);
  5578. } else {
  5579. sendAutoGather();
  5580. this.isTrue = false;
  5581. my.autoAim = false;
  5582. }
  5583. }, 1);
  5584. };
  5585.  
  5586. this.gotoGoal = function(goto, OT) {
  5587. let slowDists = (weeeee) => weeeee * config.playerScale;
  5588. let goal = {
  5589. a: goto - OT,
  5590. b: goto + OT,
  5591. c: goto - slowDists(1),
  5592. d: goto + slowDists(1),
  5593. e: goto - slowDists(2),
  5594. f: goto + slowDists(2),
  5595. g: goto - slowDists(4),
  5596. h: goto + slowDists(4)
  5597. };
  5598. let bQ = function (wwww, awwww) {
  5599. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5600. buyEquip(31, 0);
  5601. } else {
  5602. buyEquip(wwww, awwww);
  5603. }
  5604. }
  5605. if (enemy.length) {
  5606. let dst = near.dist2;
  5607. this.ticking = true;
  5608. if (dst >= goal.a && dst <= goal.b) {
  5609. bQ(22, 0);
  5610. bQ(19, 1);
  5611. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5612. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5613. }
  5614. return {
  5615. dir: undefined,
  5616. action: 1
  5617. };
  5618. } else {
  5619. if (dst < goal.a) {
  5620. if (dst >= goal.g) {
  5621. if (dst >= goal.e) {
  5622. if (dst >= goal.c) {
  5623. bQ(40, 0);
  5624. bQ(21, 1);
  5625. if (configs.slowOT) {
  5626. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5627. } else {
  5628. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5629. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5630. }
  5631. }
  5632. } else {
  5633. bQ(26, 0);
  5634. bQ(21, 1);
  5635. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5636. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5637. }
  5638. }
  5639. } else {
  5640. bQ(26, 0);
  5641. bQ(12, 1);
  5642. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5643. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5644. }
  5645. }
  5646. } else {
  5647. biomeGear();
  5648. bQ(19, 1);
  5649. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5650. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5651. }
  5652. }
  5653. return {
  5654. dir: near.aim2 + Math.PI,
  5655. action: 0
  5656. };
  5657. } else if (dst > goal.b) {
  5658. if (dst <= goal.h) {
  5659. if (dst <= goal.f) {
  5660. if (dst <= goal.d) {
  5661. bQ(40, 0);
  5662. bQ(9, 1);
  5663. if (configs.slowOT) {
  5664. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5665. } else {
  5666. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5667. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5668. }
  5669. }
  5670. } else {
  5671. bQ(22, 0);
  5672. bQ(19, 1);
  5673. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5674. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5675. }
  5676. }
  5677. } else {
  5678. bQ(6, 0);
  5679. bQ(12, 1);
  5680. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5681. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5682. }
  5683. }
  5684. } else {
  5685. biomeGear();
  5686. bQ(19, 1);
  5687. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5688. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5689. }
  5690. }
  5691. return {
  5692. dir: near.aim2,
  5693. action: 0
  5694. };
  5695. }
  5696. return {
  5697. dir: undefined,
  5698. action: 0
  5699. };
  5700. }
  5701. } else {
  5702. this.ticking = false;
  5703. return {
  5704. dir: undefined,
  5705. action: 0
  5706. };
  5707. }
  5708. }
  5709. /** wait 1 tick for better quality */
  5710. this.bowMovement = function() {
  5711. let moveMent = this.gotoGoal(685, 3);
  5712. if (moveMent.action) {
  5713. if (player.reloads[53] == 0 && !this.isTrue) {
  5714. this.rangeType("ageInsta");
  5715. } else {
  5716. packet("a", moveMent.dir, 1);
  5717. }
  5718. } else {
  5719. packet("a", moveMent.dir, 1);
  5720. }
  5721. },
  5722. this.tickMovement = function() {
  5723. 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);
  5724. if (moveMent.action) {
  5725. if (![6, 22].includes(near.skinIndex) && player.reloads[53] == 0 && !this.isTrue) {
  5726. ([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) || (player.weapons[1] == 15) ? this.oneTickType(): this.threeOneTickType();
  5727. } else {
  5728. packet("a", moveMent.dir, 1);
  5729. }
  5730. } else {
  5731. packet("a", moveMent.dir, 1);
  5732. }
  5733. },
  5734. this.kmTickMovement = function() {
  5735. let moveMent = this.gotoGoal(240, 3);
  5736. if (moveMent.action) {
  5737. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5738. this.kmTickType();
  5739. } else {
  5740. packet("a", moveMent.dir, 1);
  5741. }
  5742. } else {
  5743. packet("a", moveMent.dir, 1);
  5744. }
  5745. },
  5746. this.boostTickMovement = function() {
  5747. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 390 : player.weapons[1] == 15 ? 365 : 370;
  5748. 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;
  5749. let moveMent = this.gotoGoal(dist, actionDist);
  5750. if (moveMent.action) {
  5751. if (player.reloads[53] == 0 && !this.isTrue) {
  5752. this.boostTickType();
  5753. } else {
  5754. packet("a", moveMent.dir, 1);
  5755. }
  5756. } else {
  5757. packet("a", moveMent.dir, 1);
  5758. }
  5759. }
  5760. this.boostTickMovement = function() {
  5761. //let dist = player.weapons[1] == 9 ? 334 : player.weapons[1] == 12 ? 355 : player.weapons[1] == 13 ? 357 : player.weapons[1] == 15 ? 325 : 350
  5762. //let offset = player.weapons[1] == 9 ? 3 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 2 : player.weapons[1] == 15 ? 10 : 3
  5763. let dist = parseInt(getEl('boosttickdistance').value)
  5764. let offset = 1
  5765. let moveMent = this.gotoGoal(dist, offset);
  5766. if (moveMent.action) {
  5767. if (player.reloads[53] == 0 && !this.isTrue) {
  5768. this.boostTickType();
  5769. } else {
  5770. packet("a", moveMent.dir, 1);
  5771. }
  5772. } else {
  5773. packet("a", moveMent.dir, 1);
  5774. }
  5775. }
  5776. /** wait 1 tick for better quality */
  5777. this.perfCheck = function(pl, nr) {
  5778. if (nr.weaponIndex == 19 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5779. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5780. let pjs = {
  5781. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5782. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5783. };
  5784. 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)) {
  5785. return true;
  5786. }
  5787. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5788. 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)) {
  5789. return true;
  5790. }
  5791. });
  5792. if (finds) return false;
  5793. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5794. let tmpScale = tmp.getScale();
  5795. 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)) {
  5796. return true;
  5797. }
  5798. });
  5799. if (finds) return false;
  5800. return true;
  5801. }
  5802. }
  5803. };
  5804.  
  5805. class Autobuy {
  5806. constructor(buyHat, buyAcc) {
  5807. this.hat = function() {
  5808. buyHat.forEach((id) => {
  5809. let find = findID(hats, id);
  5810. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5811. });
  5812. };
  5813. this.acc = function() {
  5814. buyAcc.forEach((id) => {
  5815. let find = findID(accessories, id);
  5816. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5817. });
  5818. };
  5819. }
  5820. };
  5821.  
  5822. class Autoupgrade {
  5823. constructor() {
  5824. this.sb = function(upg) {
  5825. upg(3);
  5826. upg(17);
  5827. upg(31);
  5828. upg(23);
  5829. upg(9);
  5830. upg(38);
  5831. };
  5832. this.kh = function(upg) {
  5833. upg(3);
  5834. upg(17);
  5835. upg(31);
  5836. upg(23);
  5837. upg(10);
  5838. upg(38);
  5839. upg(4);
  5840. upg(25);
  5841. };
  5842. this.pb = function(upg) {
  5843. upg(5);
  5844. upg(17);
  5845. upg(32);
  5846. upg(23);
  5847. upg(9);
  5848. upg(38);
  5849. };
  5850. this.ph = function(upg) {
  5851. upg(5);
  5852. upg(17);
  5853. upg(32);
  5854. upg(23);
  5855. upg(10);
  5856. upg(38);
  5857. upg(28);
  5858. upg(25);
  5859. };
  5860. this.db = function(upg) {
  5861. upg(7);
  5862. upg(17);
  5863. upg(31);
  5864. upg(23);
  5865. upg(9);
  5866. upg(34);
  5867. };
  5868. /* old functions */
  5869. this.km = function(upg) {
  5870. upg(7);
  5871. upg(17);
  5872. upg(31);
  5873. upg(23);
  5874. upg(10);
  5875. upg(38);
  5876. upg(4);
  5877. upg(15);
  5878. };
  5879. };
  5880. };
  5881.  
  5882. class Damages {
  5883. constructor(items) {
  5884. // 0.75 1 1.125 1.5
  5885. this.calcDmg = function(dmg, val) {
  5886. return dmg * val;
  5887. };
  5888. this.getAllDamage = function(dmg) {
  5889. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5890. };
  5891. this.weapons = [];
  5892. for (let i = 0; i < items.weapons.length; i++) {
  5893. let wp = items.weapons[i];
  5894. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5895. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5896. this[name] = this.weapons[i];
  5897. }
  5898. }
  5899. }
  5900. // it skid XDDDDDDDDDDDDDDDDDDDDDDD
  5901.  
  5902. let hasDisplayedWarning = false;
  5903. function shameWarn() {
  5904. if (player.shameCount > 4 && !hasDisplayedWarning) {
  5905. hasDisplayedWarning = true;
  5906. const frameMsg = Object.assign(document.createElement("div"), {
  5907. innerHTML: `Warning: High Shame Detected`,
  5908. style: `
  5909. position: fixed;
  5910. top: 8%;
  5911. left: 50%;
  5912. transform: translate(-50%, -50%);
  5913. font-size: 1.5rem;
  5914. color: #a12a22;
  5915. text-shadow: -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, 1px 1px 0 #333;
  5916. z-index: 9999;
  5917. opacity: 0;
  5918. transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
  5919. padding: 10px;
  5920. background-color: rgba(0, 0, 0, 0.2); /* Changed background color */
  5921. border: 2px solid #a12a22;
  5922. border-radius: 5px;
  5923. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  5924. `
  5925. });
  5926. document.body.appendChild(frameMsg);
  5927. setTimeout(function() {
  5928. frameMsg.style.opacity = "1";
  5929. frameMsg.style.transform = "translate(-50%, 0)";
  5930. setTimeout(function() {
  5931. frameMsg.style.opacity = "0";
  5932. frameMsg.style.transform = "translate(-50%, -50%)";
  5933. setTimeout(function() {
  5934. frameMsg.remove();
  5935. hasDisplayedWarning = false;
  5936. }, 500);
  5937. }, 2000);
  5938. }, 100);
  5939. }
  5940. }
  5941. setInterval(shameWarn, 100);
  5942. let greetings = false;
  5943.  
  5944. function getGreeting() {
  5945. const hour = new Date().getHours();
  5946. if (hour < 12) {
  5947. return "Good Morning!";
  5948. } else if (hour < 18) {
  5949. return "Good Afternoon!";
  5950. } else {
  5951. return "Good Evening!";
  5952. }
  5953. }
  5954.  
  5955. function greeting() {
  5956. if (!greetings) {
  5957. greetings = true;
  5958. const frameMsg = Object.assign(document.createElement("div"), {
  5959. innerHTML: `${getGreeting()}`,
  5960. style: `
  5961. position: fixed;
  5962. top: -100px;
  5963. left: 50%;
  5964. transform: translateX(-50%);
  5965. font-size: 2rem;
  5966. color: white;
  5967. z-index: 9999;
  5968. opacity: 3;
  5969. transition: top 0.5s ease-in-out, opacity 0.5s ease-in-out;
  5970. padding: 10px;
  5971. background-color: rgba(0, 0, 0, 0.2);
  5972. border: 2px solid #0000;
  5973. border-radius: 5px;
  5974. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  5975. `
  5976. });
  5977. document.body.appendChild(frameMsg);
  5978. setTimeout(function() {
  5979. frameMsg.style.top = "7%";
  5980. frameMsg.style.opacity = "1";
  5981. }, 100);
  5982. setTimeout(function() {
  5983. frameMsg.style.top = "-100px";
  5984. frameMsg.style.opacity = "0";
  5985. setTimeout(function() {
  5986. frameMsg.remove();
  5987. greetings = false;
  5988. }, 500);
  5989. }, 3000);
  5990. }
  5991. }
  5992. greeting();
  5993.  
  5994.  
  5995. /** CLASS CODES */
  5996. // jumpscare code warn
  5997. let tmpList = [];
  5998.  
  5999. // LOADING:
  6000. let UTILS = new Utils();
  6001. let items = new Items();
  6002. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6003. let store = new Store();
  6004. let hats = store.hats;
  6005. let accessories = store.accessories;
  6006. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6007. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6008. let textManager = new Textmanager();
  6009.  
  6010. let traps = new Traps(UTILS, items);
  6011. let instaC = new Instakill();
  6012. let autoBuy = new Autobuy([40, 6, 7, 22, 53, 15, 31], [11, 21, 18, 13, 19]);
  6013. let autoUpgrade = new Autoupgrade();
  6014.  
  6015. let lastDeath;
  6016. let minimapData;
  6017. let mapMarker = {};
  6018. let mapPings = [];
  6019. let tmpPing;
  6020.  
  6021. let antiinsta = true;
  6022. let antiinsta1 = false;
  6023.  
  6024. let breakTrackers = [];
  6025.  
  6026. function sendChat(message) {
  6027. packet("6", message.slice(0, 30));
  6028. }
  6029.  
  6030. let runAtNextTick = [];
  6031.  
  6032. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6033. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6034. let projOffset = config.playerScale * 2;
  6035. let projXY = {
  6036. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6037. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6038. };
  6039. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6040. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6041. })[0];
  6042. if (nearPlayer) {
  6043. if (indx == 1) {
  6044. nearPlayer.shooting[53] = 1;
  6045. } else {
  6046. nearPlayer.shootIndex = weaponIndx;
  6047. nearPlayer.shooting[1] = 1;
  6048. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6049. }
  6050. }
  6051. }
  6052. let projectileCount = 0;
  6053.  
  6054. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6055. if (!tmpObj.isTeam(player)) {
  6056. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6057. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6058. tmpObj.bowThreat[weaponIndex]++;
  6059. if (index == 5) {
  6060. projectileCount++;
  6061. }
  6062. setTimeout(() => {
  6063. tmpObj.bowThreat[weaponIndex]--;
  6064. if (index == 5) {
  6065. projectileCount--;
  6066. }
  6067. }, range / speed);
  6068. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6069. place(1, tmpObj.aim2);
  6070. my.anti0Tick = 4;
  6071. if (!my.antiSync) {
  6072. antiSyncHealing(4);
  6073. }
  6074. } else {
  6075. if (projectileCount >= 2) {
  6076. place(1, tmpObj.aim2);
  6077. healer();
  6078. buyEquip(22, 0);
  6079. buyEquip(13, 1);
  6080. my.anti0Tick = 4;
  6081. if (!my.antiSync) {
  6082. antiSyncHealing(4);
  6083. }
  6084. } else {
  6085. if (projectileCount === 1) { // anti reverse or anti 1 tick with reaper
  6086. buyEquip(6, 0);
  6087. buyEquip(13, 1);
  6088. }
  6089. /*} else {
  6090. if (projectileCount >= 2) { // anti sync линия обороны N1
  6091. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  6092. player.chat.message = "pSyD";
  6093. healer();
  6094. buyEquip(6, 0);
  6095. }
  6096. }*/
  6097. }
  6098. }
  6099. }
  6100. }
  6101. }
  6102.  
  6103. // SHOW ITEM INFO:
  6104. function showItemInfo(item, isWeapon, isStoreItem) {
  6105. if (player && item) {
  6106. UTILS.removeAllChildren(itemInfoHolder);
  6107. itemInfoHolder.classList.add("visible");
  6108. UTILS.generateElement({
  6109. id: "itemInfoName",
  6110. text: UTILS.capitalizeFirst(item.name),
  6111. parent: itemInfoHolder
  6112. });
  6113. UTILS.generateElement({
  6114. id: "itemInfoDesc",
  6115. text: item.desc,
  6116. parent: itemInfoHolder
  6117. });
  6118. if (isStoreItem) {
  6119.  
  6120. } else if (isWeapon) {
  6121. UTILS.generateElement({
  6122. class: "itemInfoReq",
  6123. text: !item.type ? "primary" : "secondary",
  6124. parent: itemInfoHolder
  6125. });
  6126. } else {
  6127. for (let i = 0; i < item.req.length; i += 2) {
  6128. UTILS.generateElement({
  6129. class: "itemInfoReq",
  6130. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6131. parent: itemInfoHolder
  6132. });
  6133. }
  6134. if (item.group.limit) {
  6135. UTILS.generateElement({
  6136. class: "itemInfoLmt",
  6137. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6138. parent: itemInfoHolder
  6139. });
  6140. }
  6141. }
  6142. } else {
  6143. itemInfoHolder.classList.remove("visible");
  6144. }
  6145. }
  6146.  
  6147. // RESIZE:
  6148. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6149.  
  6150. function resize() {
  6151. screenWidth = window.innerWidth;
  6152. screenHeight = window.innerHeight;
  6153. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6154. gameCanvas.width = screenWidth * pixelDensity;
  6155. gameCanvas.height = screenHeight * pixelDensity;
  6156. gameCanvas.style.width = screenWidth + "px";
  6157. gameCanvas.style.height = screenHeight + "px";
  6158. mainContext.setTransform(
  6159. scaleFillNative, 0,
  6160. 0, scaleFillNative,
  6161. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  6162. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  6163. );
  6164. }
  6165. resize();
  6166.  
  6167.  
  6168. // MOUSE INPUT:
  6169. var usingTouch;
  6170. const mals = document.getElementById('touch-controls-fullscreen');
  6171. mals.style.display = 'block';
  6172. mals.addEventListener("mousemove", gameInput, false);
  6173.  
  6174. function gameInput(e) {
  6175. mouseX = e.clientX;
  6176. mouseY = e.clientY;
  6177. }
  6178. let clicks = {
  6179. left: false,
  6180. middle: false,
  6181. right: false,
  6182. };
  6183. mals.addEventListener("mousedown", mouseDown, false);
  6184.  
  6185. function mouseDown(e) {
  6186. if (attackState != 1) {
  6187. attackState = 1;
  6188. if (e.button == 0) {
  6189. clicks.left = true;
  6190. } else if (e.button == 1) {
  6191. clicks.middle = true;
  6192. } else if (e.button == 2) {
  6193. clicks.right = true;
  6194. }
  6195. }
  6196. }
  6197. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6198.  
  6199. function mouseUp(e) {
  6200. if (attackState != 0) {
  6201. attackState = 0;
  6202. if (e.button == 0) {
  6203. clicks.left = false;
  6204. } else if (e.button == 1) {
  6205. clicks.middle = false;
  6206. } else if (e.button == 2) {
  6207. clicks.right = false;
  6208. }
  6209. }
  6210. }
  6211. mals.addEventListener("wheel", wheela, false);
  6212.  
  6213. function wheela(e) {
  6214. if(player.shameCount > 1) {
  6215. buyEquip(7, 0);
  6216. } else {
  6217. buyEquip(6, 0);
  6218. }
  6219. }
  6220.  
  6221.  
  6222.  
  6223. document.getElementById("touch-controls-fullscreen").addEventListener("wheel", wheel, false);
  6224. let T = config;
  6225. let wbe = 1;
  6226. function wheel(e) {
  6227. if (e.deltaY < 0) {
  6228. wbe -= 0.05;
  6229. wbe = Math.max(0.4, wbe);
  6230. maxScreenWidth = T.maxScreenWidth * wbe;
  6231. maxScreenHeight = T.maxScreenHeight * wbe;
  6232. resize()
  6233. } else {
  6234. wbe += 0.05;
  6235. maxScreenWidth = T.maxScreenWidth * wbe;
  6236. maxScreenHeight = T.maxScreenHeight * wbe;
  6237. resize()
  6238. }
  6239. }
  6240.  
  6241. // INPUT UTILS:
  6242. function getMoveDir() {
  6243. let dx = 0;
  6244. let dy = 0;
  6245. for (let key in moveKeys) {
  6246. let tmpDir = moveKeys[key];
  6247. dx += !!keys[key] * tmpDir[0];
  6248. dy += !!keys[key] * tmpDir[1];
  6249. }
  6250. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6251. }
  6252.  
  6253. function getSafeDir() {
  6254. if (!player)
  6255. return 0;
  6256. if (!player.lockDir) {
  6257. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6258. }
  6259. return lastDir || 0;
  6260. }
  6261. let plusDir = 0;
  6262. let lastSpin = Date.now();
  6263.  
  6264. function getAttackDir() {
  6265. if(player && Date.now() - lastSpin >= 235 && !(clicks.right || clicks.left)) {
  6266. plusDir += Math.random()*(Math.PI*2);
  6267. lastSpin = Date.now();
  6268. }
  6269. if (!player)
  6270. return "0";
  6271. 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))
  6272. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? near.aim2 : getSafeDir();
  6273. else
  6274. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6275. lastDir = getSafeDir();
  6276. else
  6277. if (traps.inTrap) {
  6278. lastDir = traps.aim;
  6279. } else
  6280. if (!player.lockDir) {
  6281. if (!player.lockDir && autos.stopspin) {
  6282. if(useWasd) {
  6283. lastDir = lastDir;
  6284. } else {
  6285. lastDir = getSafeDir();
  6286. }
  6287. }
  6288. }
  6289. return lastDir;
  6290. }
  6291.  
  6292. function getVisualDir() {
  6293. if (!player)
  6294. return 0;
  6295. lastDir = getSafeDir();
  6296. return lastDir || 0;
  6297. }
  6298.  
  6299. // KEYS:
  6300. function keysActive() {
  6301. return (allianceMenu.style.display != "block" &&
  6302. chatHolder.style.display != "block" &&
  6303. !menuCBFocus);
  6304. }
  6305. function toggleMenuChat() {
  6306. if (menuChatDiv.style.display != "none") {
  6307. chatHolder.style.display = "none";
  6308. if (menuChatBox.value != "") {
  6309. //commands[command.slice(1)]
  6310. let cmd = function (command) {
  6311. return {
  6312. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6313. fv: commands[command.slice(1).split(" ")[0]]
  6314. }
  6315. }
  6316. let command = cmd(menuChatBox.value);
  6317. if (command.found) {
  6318. if (typeof command.fv.action === "function") {
  6319. command.fv.action(menuChatBox.value);
  6320. }
  6321. } else {
  6322. sendChat(menuChatBox.value);
  6323. }
  6324. menuChatBox.value = "";
  6325. menuChatBox.blur();
  6326. } else {
  6327. if (menuCBFocus) {
  6328. menuChatBox.blur();
  6329. } else {
  6330. menuChatBox.focus();
  6331. }
  6332. }
  6333. }
  6334. }
  6335. function keyDown(event) {
  6336. let keyNum = event.which || event.keyCode || 0;
  6337. if (player && player.alive && keysActive()) {
  6338. if (!keys[keyNum]) {
  6339. keys[keyNum] = 1;
  6340. macro[event.key] = 1;
  6341. if (keyNum == 27) {
  6342. openMenu = !openMenu;
  6343. $("#menuDiv").toggle();
  6344. $("#menuChatDiv").toggle();
  6345. } else if (keyNum == 69) {
  6346. sendAutoGather();
  6347. } else if (keyNum == 67) {
  6348. AC(document.getElementById("autochats").value);
  6349. document.getElementById("mscVolume").value = autochats[autochats.current].audio.volume * 100;
  6350. updateMapMarker();
  6351. } else if (player.weapons[keyNum - 49] != undefined) {
  6352. player.weaponCode = player.weapons[keyNum - 49];
  6353. } else if (moveKeys[keyNum]) {
  6354. sendMoveDir();
  6355. } else if (event.key == "m") {
  6356. mills.placeSpawnPads = !mills.placeSpawnPads;
  6357. } else if (event.key == "z") {
  6358. mills.place = !mills.place;
  6359. notif("Automill", mills.place ? "Enabled" : "Disabled");
  6360. } else if (event.key == "Z") {
  6361. typeof window.debug == "function" && window.debug();
  6362. } else if (keyNum == 32) {
  6363. packet("d", 1, getSafeDir(), 1);
  6364. packet("d", 0, getSafeDir(), 1);
  6365. } else if (event.key == ",") {
  6366. player.sync = false;
  6367. } else if (event.key == "r") {
  6368. if (!main.autoInsta.enabled) { instaQ = !instaQ; }
  6369. }
  6370. }
  6371. }
  6372. }
  6373. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6374. function keyUp(event) {
  6375. if (player && player.alive) {
  6376. let keyNum = event.which || event.keyCode || 0;
  6377. if (keyNum == 13) {
  6378. // toggleMenuChat();
  6379. } else if (keysActive()) {
  6380. if (keys[keyNum]) {
  6381. keys[keyNum] = 0;
  6382. macro[event.key] = 0;
  6383. if (moveKeys[keyNum]) {
  6384. sendMoveDir();
  6385. } else if (event.key == ",") {
  6386. player.sync = false;
  6387. }
  6388. }
  6389. }
  6390. }
  6391. }
  6392. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6393. function sendMoveDir() {
  6394. if(found) {
  6395. packet("a", undefined, 1);
  6396. } else {
  6397. let newMoveDir = getMoveDir();
  6398. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6399. if (!my.autoPush && !found) {
  6400. packet("a", newMoveDir, 1);
  6401. }
  6402. lastMoveDir = newMoveDir;
  6403. }
  6404. }
  6405. }
  6406. // BUTTON EVENTS:
  6407. function bindEvents() { }
  6408. bindEvents();
  6409. /** PATHFIND TEST */
  6410.  
  6411. function toFancyTimeFormat(time) {
  6412. let minutes = ~~((time % 3600) / 60);
  6413. let seconds = ~~time % 60;
  6414. if (seconds <= 9) seconds = `0${seconds}`;
  6415. return `${minutes}:${seconds}`;
  6416. }
  6417. let song = {
  6418. sync: {
  6419. "16:852": "Ah",
  6420. "20:9": "gas, gas, gas, gas",
  6421. "23:124": "Ah",
  6422. "28:271": "Do you like..",
  6423. "29:853": "my car",
  6424. "31:468": "m y c a r",
  6425. "33:132": "m y c a r",
  6426. "53:109": "Guess you're ready",
  6427. "54:291": "'cause I'm waiting for you",
  6428. "56:129": "It's gonna be so exciting",
  6429. "59:290": "Got this feeling",
  6430. "1:0:499": "really deep in my soul",
  6431. "1:2:281": "Let's get out",
  6432. "1:3:135": "I wanna go",
  6433. "1:4:48": "come along",
  6434. "1:4:855": "get it on",
  6435. "1:5:993": "Gonna take my car",
  6436. "1:7:562": "gonna sit in",
  6437. "1:9:35": "Gonna drive along",
  6438. "1:10:474": "'til I get you",
  6439. "1:11:823": "'Cause I'm crazy",
  6440. "1:12:562": "hot and ready",
  6441. "1:13:541": "but you like it",
  6442. "1:15:10": "I wanna race for you",
  6443. "1:16:610": "(Shall I go now?)",
  6444. "1:18:109": "Gas, gas, gas",
  6445. "1:19:810": "I'm gonna step on the gas",
  6446. "1:21:642": "Tonight, I'll fly",
  6447. "1:22:962": "(and be your lover)",
  6448. "1:24:370": "Yeah, yeah, yeah",
  6449. "1:26:101": "I'll be so quick as a flash",
  6450. "1:27:884": "And I'll be your hero",
  6451. "1:30:651": "Gas, gas, gas",
  6452. "1:32:379": "I'm gonna run as a flash",
  6453. "1:34:59": "Tonight, I'll fight",
  6454. "1:35:507": "(to be the winner)",
  6455. "1:36:707": "Yeah, yeah, yeah",
  6456. "1:38:547": "I'm gonna step on the gas",
  6457. "1:40:286": "And you'll see the big show",
  6458. "1:55:520": "Don't be lazy",
  6459. "1:56:751": "'cause I'm burning for you",
  6460. "1:58:340": "It's like a hot sensation",
  6461. "2:1:733": "Got this power",
  6462. "2:2:913": "that is taking me out",
  6463. "2:4:681": "Yes, I've got a crush on you",
  6464. "2:6:347": "ready, now",
  6465. "2:7:174": "ready, go",
  6466. "2:8:335": "Gonna take my car",
  6467. "2:9:935": "gonna sit in",
  6468. "2:11:481": "Gonna drive alone",
  6469. "2:12:775": "'til I get you",
  6470. "2:14:244": "'Cause I'm crazy",
  6471. "2:14:975": "hot and ready",
  6472. "2:15:999": "but you like it",
  6473. "2:17:279": "I wanna race for you",
  6474. "2:18:938": "(Shall I go now?)",
  6475. "2:20:455": "Gas, gas, gas",
  6476. "2:22:178": "I'm gonna step on the gas",
  6477. "2:23:999": "Tonight, I'll fly",
  6478. "2:25:311": "(and be your lover)",
  6479. "2:26:738": "Yeah, yeah, yeah",
  6480. "2:28:512": "I'll be so quick as a flash",
  6481. "2:29:975": "And I'll be your hero",
  6482. "2:32:978": "Gas, gas, gas",
  6483. "2:34:668": "I'm gonna run as a flash",
  6484. "2:36:447": "Tonight, I'll fight",
  6485. "2:37:809": "(to be the winner)",
  6486. "2:39:81": "Yeah, yeah, yeah",
  6487. "2:40:931": "I'm gonna step on the gas",
  6488. "2:42:463": "And you'll see the big show",
  6489. "3:10:277": "Guess you're ready",
  6490. "3:11:426": "'cause I'm waiting for you",
  6491. "3:13:215": "It's gonna be so exciting",
  6492. "3:16:471": "Got this feeling",
  6493. "3:17:789": "really deep in my soul",
  6494. "3:19:408": "Let's get out",
  6495. "3:20:224": "I wanna go",
  6496. "3:21:197": "come along",
  6497. "3:22:34": "get it on",
  6498. "3:23:234": "Gonna take my car",
  6499. "3:25:986": "do you like",
  6500. "3:27:605": "my car?",
  6501. "3:29:5": "'Cause I'm crazy",
  6502. "3:29:685": "hot and ready",
  6503. "3:30:823": "but you like it",
  6504. "3:32:133": "I wanna race for you",
  6505. "3:33:653": "(Shall I go now?)",
  6506. "3:36:813": "Gas, gas, gas",
  6507. "3:38:514": "I'm gonna step on the gas",
  6508. "3:40:185": "Tonight, I'll fly",
  6509. "3:41:665": "(and be your lover)",
  6510. "3:43:46": "Yeah, yeah, yeah",
  6511. "3:44:756": "I'll be so quick as a flash",
  6512. "3:46:354": "And I'll be your hero",
  6513. "3:49:245": "Gas, gas, gas",
  6514. "3:51:130": "I'm gonna run as a flash",
  6515. "3:52:840": "Tonight, I'll fight",
  6516. "3:54:90": "(to be the winner)",
  6517. "3:55:448": "Yeah, yeah, yeah",
  6518. "3:57:389": "I'm gonna step on the gas",
  6519. "3:58:866": "And you'll see the big show",
  6520. "4:1:797": "Gas, gas, gas",
  6521. "4:4:805": "Yeah, yeah, yeah",
  6522. "4:7:975": "Gas, gas, gas",
  6523. "4:11:293": "And you'll see the big show",
  6524. "4:28:89": "Ah"
  6525. },
  6526. };
  6527.  
  6528.  
  6529. var converToJSDelay = (time) => {
  6530. let newTime = time.split(":").reverse();
  6531. time = 0;
  6532. let convert = [6e4 * 60, 6e4, 1000, 1].reverse();
  6533. newTime.forEach((b, c) => {
  6534. time += b * convert[c];
  6535. });
  6536. return time;
  6537. };
  6538. let e = song;
  6539. let oldDatas = e.sync;
  6540. e.sync = {};
  6541. for (let time in oldDatas) {
  6542. e.sync[converToJSDelay(time)] = oldDatas[time];
  6543. }
  6544.  
  6545. const songchat1 = new Audio("https://cdn.discordapp.com/attachments/976188754417025144/1074417409303269478/Manuel_-_Gas_Gas_Gas_1.mp3");
  6546. let isPlaying = false;
  6547. let singing = {
  6548. timeouts: []
  6549. }
  6550. function createPath() {
  6551. var grid =
  6552. grid = [];
  6553. checkObject();
  6554. }
  6555. // ITEM COUNT DISPLAY:
  6556. let isItemSetted = [];
  6557.  
  6558. function updateItemCountDisplay(index = undefined) {
  6559. for (let i = 3; i < items.list.length; ++i) {
  6560. let id = items.list[i].group.id;
  6561. let tmpI = items.weapons.length + i;
  6562. if (!isItemSetted[tmpI]) {
  6563. isItemSetted[tmpI] = document.createElement("div");
  6564. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6565. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6566. isItemSetted[tmpI].style = `
  6567. display: block;
  6568. position: absolute;
  6569. padding-left: 5px;
  6570. font-size: 2em;
  6571. color: #fff;
  6572. `;
  6573. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6574. } else {
  6575. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6576. }
  6577. }
  6578. }
  6579.  
  6580.  
  6581.  
  6582. function autoPush() {
  6583. let aif = liztobj.filter(aig => aig.trap && aig.active && aig.isTeamObject(player) && UTILS.getDist(aig, near, 0, 2) <= near.scale + aig.getScale() + 5).sort(function(aih, aii) {
  6584. return UTILS.getDist(aih, near, 0, 2) - UTILS.getDist(aii, near, 0, 2);
  6585. })[0];
  6586. if (aif) {
  6587. let aij = liztobj.filter(aik => aik.dmg && aik.active && aik.isTeamObject(player) && UTILS.getDist(aik, aif, 0, 0) <= near.scale + aif.scale + aik.scale).sort(function(ail, aio) {
  6588. return UTILS.getDist(ail, near, 0, 2) - UTILS.getDist(aio, near, 0, 2);
  6589. })[0];
  6590. if (aij) {
  6591. let aip = Math.atan2(near.y2 - aij.y, near.x2 - aij.x);
  6592. let pushDistance = 86;
  6593. let currentDistance = UTILS.getDist(aij, near, 0, 2);
  6594. if (currentDistance <= pushDistance) {
  6595. my.autoPush = false;
  6596. packet("a", lastMoveDir || undefined, 1);
  6597. } else {
  6598. my.autoPush = true;
  6599. my.pushData = {
  6600. x: aij.x + Math.cos(aip) * (pushDistance - currentDistance),
  6601. y: aij.y + Math.sin(aip) * (pushDistance - currentDistance),
  6602. x2: player.x2 + 55,
  6603. y2: player.y2 + 55
  6604. };
  6605. let aiq = {
  6606. x: near.x2 + Math.cos(aip) * 55,
  6607. y: near.y2 + Math.sin(aip) * 55
  6608. };
  6609. let air = Math.atan2(aiq.y - player.y2, aiq.x - player.x2);
  6610. packet("a", air, 1);
  6611. }
  6612. } else if (my.autoPush) {
  6613. my.autoPush = false;
  6614. packet("a", lastMoveDir || undefined, 1);
  6615. }
  6616. } else if (my.autoPush) {
  6617. my.autoPush = false;
  6618. packet("a", lastMoveDir || undefined, 1);
  6619. }
  6620. }
  6621.  
  6622.  
  6623. // ADD DEAD PLAYER:
  6624. function addDeadPlayer(tmpObj) {
  6625. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6626. }
  6627.  
  6628. /** APPLY SOCKET CODES */
  6629.  
  6630. // SET INIT DATA:
  6631. function setInitData(data) {
  6632. alliances = data.teams;
  6633. }
  6634.  
  6635. // SETUP GAME:
  6636. function setupGame(yourSID) {
  6637. keys = {};
  6638. macro = {};
  6639. playerSID = yourSID;
  6640. attackState = 0;
  6641. inGame = true;
  6642. packet("d", 0, getAttackDir(), 1);
  6643. my.ageInsta = true;
  6644. if (firstSetup) {
  6645. firstSetup = false;
  6646. gameObjects.length = 0;
  6647. liztobj.length = 0;
  6648. }
  6649. }
  6650.  
  6651. // ADD NEW PLAYER:
  6652. function addPlayer(data, isYou) {
  6653. let tmpPlayer = findPlayerByID(data[0]);
  6654. if (!tmpPlayer) {
  6655. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6656. objectManager, players, ais, items, hats, accessories);
  6657. players.push(tmpPlayer);
  6658. if (data[1] != playerSID) {
  6659. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6660. }
  6661. } else {
  6662. if (data[1] != playerSID) {
  6663. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6664. }
  6665. }
  6666. tmpPlayer.spawn(isYou ? true : null);
  6667. tmpPlayer.visible = false;
  6668. tmpPlayer.oldPos = {
  6669. x2: undefined,
  6670. y2: undefined
  6671. };
  6672. tmpPlayer.x2 = undefined;
  6673. tmpPlayer.y2 = undefined;
  6674. tmpPlayer.x3 = undefined;
  6675. tmpPlayer.y3 = undefined;
  6676. tmpPlayer.setData(data);
  6677. if (isYou) {
  6678. if (!player) {
  6679. window.prepareUI(tmpPlayer);
  6680. }
  6681. player = tmpPlayer;
  6682. camX = player.x;
  6683. camY = player.y;
  6684. my.lastDir = 0;
  6685. updateItems();
  6686. updateAge();
  6687. updateItemCountDisplay();
  6688. if (player.skins[7]) {
  6689. my.reSync = true;
  6690. }
  6691. }
  6692. }
  6693.  
  6694.  
  6695. // REMOVE PLAYER:
  6696. function removePlayer(id) {
  6697. for (let i = 0; i < players.length; i++) {
  6698. if (players[i].id == id) {
  6699. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6700. players.splice(i, 1);
  6701. break;
  6702. }
  6703. }
  6704. }
  6705.  
  6706. // UPDATE HEALTH:
  6707. function updateHealth(sid, value) {
  6708. tmpObj = findPlayerBySID(sid);
  6709. if (tmpObj) {
  6710. // tmpObj.lastshamecount = tmpObj.shameCount;
  6711. tmpObj.oldHealth = tmpObj.health;
  6712. tmpObj.health = value;
  6713. tmpObj.judgeShame();
  6714. if (tmpObj.oldHealth > tmpObj.health) {
  6715. tmpObj.timeDamaged = Date.now(); //here'
  6716. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6717. let damaged = tmpObj.damaged;
  6718. tmpObj = findPlayerBySID(sid);
  6719.  
  6720. let bullTicked = false;
  6721.  
  6722. if (tmpObj.health <= 0) {
  6723. if (!tmpObj.death) {
  6724. tmpObj.death = true;
  6725. if (tmpObj != player) {
  6726. if(tmpObj.skinIndex == 45) {
  6727. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to clown`, "red");
  6728. } else if(tmpObj.shameCount >= 5) {
  6729. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to high shame`, "red");
  6730. } else {
  6731. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died`, "red");
  6732. }
  6733. }
  6734. addDeadPlayer(tmpObj);
  6735. }
  6736. }
  6737. if (tmpObj == player) {
  6738. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) { // bull ticker
  6739. }
  6740.  
  6741.  
  6742.  
  6743. let antiinsta3 = true;
  6744. let autoheal = false;
  6745. let antiinsta4 = true;
  6746.  
  6747.  
  6748.  
  6749. if (inGame) {
  6750. let attackers = getAttacker(damaged);
  6751. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg);
  6752. let includeSpikeDmgs = near.length ? !bullTicked && (gearDmgs.includes(damaged) && near[0].skinIndex == 19 && near[0].tailIndex == 21) : false;
  6753. let healTimeout = 140 - window.ping;
  6754. let slowHeal = function (timer) {
  6755. setTimeout(() => {
  6756. healer();
  6757. }, timer);
  6758. }
  6759. if (damaged >= 0 && damaged <= 66 && player.shameCount === 4 && player.shameCount === 4 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6760. autoheal = true;
  6761. antiinsta = false;
  6762. antiinsta1 = false;
  6763. antiinsta4 = false;
  6764. }else{
  6765. if(player.shameCount !== 4){
  6766. autoheal = false;
  6767. antiinsta = true;
  6768. antiinsta4 = true;
  6769. }
  6770. }
  6771.  
  6772. if (damaged <= 66 && player.shameCount === 3 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6773. antiinsta = false;
  6774. }else{
  6775. if(player.shameCount !== 3){
  6776. antiinsta = true;
  6777. }
  6778. }
  6779. if (damaged <= 66 && player.shameCount === 4 && tmpObj.primaryIndex !== "4"){ // наносится удар который хилиться а на 3 шеймах выключается (из за чего шейм уменьшается)
  6780. antiinsta1 = true;
  6781. }else{
  6782. if(player.shameCount !== 4){
  6783. antiinsta1 = false;
  6784. }
  6785. }
  6786. if (damaged >= 0 && damaged <= 90 && player.shameCount === 2){ // попытка сделать невозможным довести до 3 шеймов через буллспам
  6787. antiinsta4 = false;
  6788. }else{
  6789. if(player.shameCount !== 3){
  6790. antiinsta4 = true;
  6791. }
  6792. }
  6793. if (damaged >= 0 && damaged <= 90 && !antiinsta){
  6794. if(player.shameCount === 3){
  6795. antiinsta1 = true;
  6796. }else{
  6797. antiinsta1 = false;
  6798. }
  6799. }
  6800.  
  6801. if (damaged <= 66 && player.skinIndex != 6 && enemy.weaponIndex === 4){
  6802. game.tickBase(() => {
  6803. healer1();
  6804. }, 2);
  6805. }
  6806.  
  6807.  
  6808. let dmg = 100 - player.health;
  6809. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && antiinsta4 && (game.tick - tmpObj.antiTimer) > 1) {
  6810. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6811. tmpObj.canEmpAnti = true;
  6812. } else {
  6813. player.soldierAnti = true;
  6814. }
  6815. tmpObj.antiTimer = game.tick;
  6816. let shame = tmpObj.weapons[0] == 4 ? 2 : 5;
  6817. if (tmpObj.shameCount < shame) {
  6818. healer();
  6819. } else {
  6820. game.tickBase(() => {
  6821. healer();
  6822. }, 2);
  6823. }
  6824. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && autoheal) {
  6825. setTimeout(() => {
  6826. healer();
  6827. }, 120);
  6828. }
  6829. let dmg = 100 - player.health;
  6830. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 20 && antiinsta && tmpObj.primaryIndex !== "4" && (game.tick - tmpObj.antiTimer) > 1) {
  6831. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6832. tmpObj.canEmpAnti = true;
  6833. } else {
  6834. player.soldierAnti = true;
  6835. }
  6836. tmpObj.antiTimer = game.tick;
  6837. let shame = tmpObj.weapons[0] == 4 ? 2 : 5;
  6838. if (tmpObj.shameCount < shame) {
  6839. healer();
  6840. } else {
  6841. game.tickBase(() => {
  6842. healer();
  6843. }, 2);
  6844. }
  6845. }
  6846. if (damaged >= 20 && player.skinIndex == 19 && player.shameCount <= 3) instaC.canCounter = true;
  6847. } else {
  6848. game.tickBase(() => {
  6849. healer();
  6850. }, 2);
  6851. }
  6852. //if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6853. }
  6854. // if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6855. } else {
  6856. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6857. tmpObj.setPoisonTick = true;
  6858. }
  6859. }
  6860. }
  6861. }
  6862. }
  6863.  
  6864. // KILL PLAYER:
  6865. function killPlayer() {
  6866. inGame = false;
  6867. lastDeath = {
  6868. x: player.x,
  6869. y: player.y,
  6870. };
  6871. }
  6872.  
  6873. // UPDATE PLAYER ITEM VALUES:
  6874. function updateItemCounts(index, value) {
  6875. if (player) {
  6876. player.itemCounts[index] = value;
  6877. updateItemCountDisplay(index);
  6878. }
  6879. }
  6880.  
  6881. // UPDATE AGE:
  6882. function updateAge(xp, mxp, age) {
  6883. if (xp != undefined)
  6884. player.XP = xp;
  6885. if (mxp != undefined)
  6886. player.maxXP = mxp;
  6887. if (age != undefined)
  6888. player.age = age;
  6889. }
  6890.  
  6891. // UPDATE UPGRADES:
  6892. function updateUpgrades(points, age) {
  6893. player.upgradePoints = points;
  6894. player.upgrAge = age;
  6895. if (points > 0) {
  6896. tmpList.length = 0;
  6897. UTILS.removeAllChildren(upgradeHolder);
  6898. for (let i = 0; i < items.weapons.length; ++i) {
  6899. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6900. let e = UTILS.generateElement({
  6901. id: "upgradeItem" + i,
  6902. class: "actionBarItem",
  6903. onmouseout: function() {
  6904. showItemInfo();
  6905. },
  6906. parent: upgradeHolder
  6907. });
  6908. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6909. tmpList.push(i);
  6910. }
  6911. }
  6912. for (let i = 0; i < items.list.length; ++i) {
  6913. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6914. let tmpI = (items.weapons.length + i);
  6915. let e = UTILS.generateElement({
  6916. id: "upgradeItem" + tmpI,
  6917. class: "actionBarItem",
  6918. onmouseout: function() {
  6919. showItemInfo();
  6920. },
  6921. parent: upgradeHolder
  6922. });
  6923. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6924. tmpList.push(tmpI);
  6925. }
  6926. }
  6927. for (let i = 0; i < tmpList.length; i++) {
  6928. (function(i) {
  6929. let tmpItem = getEl('upgradeItem' + i);
  6930. // tmpItem.onmouseover = function() {
  6931. // if (items.weapons[i]) {
  6932. // showItemInfo(items.weapons[i], true);
  6933. // } else {
  6934. // showItemInfo(items.list[i - items.weapons.length]);
  6935. // }
  6936. // };
  6937. tmpItem.onclick = UTILS.checkTrusted(function() {
  6938. packet("H", i);
  6939. });
  6940. UTILS.hookTouchEvents(tmpItem);
  6941. })(tmpList[i]);
  6942. }
  6943. if (tmpList.length) {
  6944. upgradeHolder.style.display = "block";
  6945. upgradeCounter.style.display = "block";
  6946. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6947. } else {
  6948. upgradeHolder.style.display = "none";
  6949. upgradeCounter.style.display = "none";
  6950. showItemInfo();
  6951. }
  6952. } else {
  6953. upgradeHolder.style.display = "none";
  6954. upgradeCounter.style.display = "none";
  6955. showItemInfo();
  6956. }
  6957. }
  6958.  
  6959. // KILL OBJECT:
  6960. function killObject(sid) {
  6961. let findObj = findObjectBySid(sid);
  6962. objectManager.disableBySid(sid);
  6963. if (player) {
  6964. for (let i = 0; i < breakObjects.length; i++) {
  6965. if (breakObjects[i].sid == sid) {
  6966. breakObjects.splice(i, 1);
  6967. break;
  6968. }
  6969. }
  6970. if (!player.canSee(findObj)) {
  6971. breakTrackers.push({
  6972. x: findObj.x,
  6973. y: findObj.y
  6974. });
  6975. }
  6976. if (breakTrackers.length > 8) {
  6977. breakTrackers.shift();
  6978. }
  6979.  
  6980. // Draw a circle on the object before replacing it
  6981. const canvas = document.getElementById('canvas');
  6982. const ctx = canvas.getContext('2d');
  6983. ctx.beginPath();
  6984. ctx.arc(findObj.x, findObj.y, 10, 0, 2 * Math.PI); // 10 is the radius
  6985. ctx.fillStyle = 'red';
  6986. ctx.fill();
  6987.  
  6988. // Replace the object
  6989. traps.replacer(findObj);
  6990. }
  6991. }
  6992.  
  6993.  
  6994.  
  6995. // KILL ALL OBJECTS BY A PLAYER:
  6996. function killObjects(sid) {
  6997. if (player) objectManager.removeAllItems(sid);
  6998. }
  6999. function setTickout(doo, timeout) {
  7000. if (!ticks.manage[ticks.tick + timeout]) {
  7001. ticks.manage[ticks.tick + timeout] = [doo];
  7002. } else {
  7003. ticks.manage[ticks.tick + timeout].push(doo);
  7004. }
  7005. }
  7006.  
  7007. function caf(e, t) {
  7008. try {
  7009. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7010. } catch (e) {
  7011. return 0;
  7012. }
  7013. }
  7014.  
  7015. var tracker = {
  7016. draw3: {
  7017. active: false,
  7018. x: 0,
  7019. y: 0,
  7020. scale: 0,
  7021. },
  7022. moveDir: undefined,
  7023. lastPos: {
  7024. x: 0,
  7025. y: 0,
  7026. }
  7027. }
  7028. let found = false;
  7029. let autoQ = false;
  7030.  
  7031. let autos = {
  7032. insta: {
  7033. todo: false,
  7034. wait: false,
  7035. count: 4,
  7036. shame: 5
  7037. },
  7038. bull: false,
  7039. antibull: 0,
  7040. reloaded: false,
  7041. stopspin: true
  7042. }
  7043. var trackerz = {
  7044. draw4: {
  7045. active: false,
  7046. x: 0,
  7047. y: 0,
  7048. scale: 0,
  7049. },
  7050. moveDir: undefined,
  7051. lastPos: {
  7052. x: 0,
  7053. y: 0,
  7054. }
  7055. }
  7056. let isNight = false;
  7057. // adjust daycycle brightness
  7058. let dayCycle = 0.35;
  7059. // UPDATE PLAYER DATA:
  7060.  
  7061. function updatePlayers(data) { //bulltick
  7062. if(player.shameCount > 1) {
  7063. buyEquip(6, 0);
  7064. buyEquip(6, 0);
  7065. } else {
  7066. if(player.lastshamecount != 1 || player.lastshamecount != 2 || player.lastshamecount != 3 || player.lastshamecount != 4 || player.lastshamecount != 5 || player.lastshamecount != 6 || player.lastshamecount == 0) {
  7067. buyEquip(6, 0);
  7068. }
  7069. }
  7070.  
  7071.  
  7072.  
  7073. let movementPrediction = {
  7074. x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7075. y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7076. }
  7077.  
  7078. let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  7079.  
  7080. potentialzpiketick.forEach((obj) => {
  7081. if(cdf(obj, player) <= 200) {
  7082. packet('a', undefined);
  7083. }
  7084. })
  7085.  
  7086. let newPos = {
  7087. x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  7088. y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  7089. }
  7090.  
  7091. function getAngleDifference(angle1, angle2) {
  7092. // Normalize the angles to be between 0 and 2π
  7093. angle1 = angle1 % (2 * Math.PI);
  7094. angle2 = angle2 % (2 * Math.PI);
  7095.  
  7096. // Calculate the absolute difference between the angles
  7097. let diff = Math.abs(angle1 - angle2);
  7098.  
  7099. // Adjust the difference to be between 0 and π
  7100. if (diff > Math.PI) {
  7101. diff = (2 * Math.PI) - diff;
  7102. }
  7103.  
  7104. return diff;
  7105. }
  7106.  
  7107.  
  7108. /*
  7109. function smartMove(oneTickMove) {
  7110. let dir = player.moveDir;
  7111.  
  7112. let found = false
  7113. 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))
  7114. let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  7115.  
  7116. let newPos = {
  7117. x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  7118. y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  7119. }
  7120.  
  7121. for (let i = 0; i < spikes.length; i++) {
  7122. if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  7123. found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  7124. }
  7125. }
  7126.  
  7127.  
  7128.  
  7129.  
  7130.  
  7131. if (found != false && !traps.inTrap) {
  7132. packet("a", undefined);
  7133. } else {
  7134. packet("a", dir);
  7135. }
  7136. player.oldPos.x2 = player.x2;
  7137. player.oldPos.y2 = player.y2;
  7138. }
  7139. function detectEnemySpikeCollisions(tmpObj) {
  7140. 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));
  7141. let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  7142. //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  7143. let enemy = {
  7144. // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  7145. // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  7146. x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7147. y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7148. }
  7149. let found = false;
  7150. for (let i = 0; i < spikes.length; i++) {
  7151. if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  7152. found = true;
  7153. }
  7154. }
  7155.  
  7156. // player.oldPos.x2 = tmpObj.x2;
  7157. // player.oldPos.y2 = tmpObj.y2;
  7158. }*/
  7159.  
  7160.  
  7161. game.tick++;
  7162. enemy = [];
  7163. nears = [];
  7164. near = [];
  7165. game.tickSpeed = performance.now() - game.lastTick;
  7166. game.lastTick = performance.now();
  7167. players.forEach((tmp) => {
  7168. tmp.forcePos = !tmp.visible;
  7169. tmp.visible = false;
  7170. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  7171. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  7172. });
  7173. for (let i = 0; i < data.length;) {
  7174. tmpObj = findPlayerBySID(data[i]);
  7175. if (tmpObj) {
  7176. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7177. tmpObj.t2 = game.lastTick;
  7178. tmpObj.oldPos.x2 = tmpObj.x2;
  7179. tmpObj.oldPos.y2 = tmpObj.y2;
  7180. tmpObj.x1 = tmpObj.x;
  7181. tmpObj.y1 = tmpObj.y;
  7182. tmpObj.x2 = data[i + 1];
  7183. tmpObj.y2 = data[i + 2];
  7184. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7185. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7186. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7187. tmpObj.d2 = data[i + 3];
  7188. tmpObj.dt = 0;
  7189. tmpObj.buildIndex = data[i + 4];
  7190. tmpObj.weaponIndex = data[i + 5];
  7191. tmpObj.weaponVariant = data[i + 6];
  7192. tmpObj.team = data[i + 7];
  7193. tmpObj.isLeader = data[i + 8];
  7194. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7195. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7196. tmpObj.skinIndex = data[i + 9];
  7197. tmpObj.tailIndex = data[i + 10];
  7198. tmpObj.iconIndex = data[i + 11];
  7199. tmpObj.zIndex = data[i + 12];
  7200. tmpObj.visible = true;
  7201. tmpObj.update(game.tickSpeed);
  7202. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7203. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7204. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7205. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7206. tmpObj.damageThreat = 0;
  7207. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7208. tmpObj.addShameTimer();
  7209. }
  7210. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7211. tmpObj.shameTimer = 0;
  7212. tmpObj.shameCount = 0;
  7213. if (tmpObj == player) {
  7214. healer();
  7215. }
  7216. }
  7217.  
  7218.  
  7219. botSkts.forEach((bot) => {
  7220. bot.showName = 'YEAHHH'
  7221. })
  7222.  
  7223. for(let i = 0; i < players.length; i++) {
  7224. for(let aa = 0; aa < botSkts.length; aa++) {
  7225. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  7226.  
  7227. }
  7228. }
  7229. if (!isNight) {
  7230. dayCycle += 0.0001;
  7231. } else if (isNight) {
  7232. if (dayCycle < 0.35) {
  7233. isNight = false;
  7234. }
  7235. dayCycle -= 0.0001; // Aumente este valor para tornar a noite mais escura rapidamente
  7236. }
  7237. if (dayCycle > 0.55) {
  7238. isNight = true;
  7239. }
  7240.  
  7241. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  7242. autoQ = true;
  7243. healer();
  7244. } else {
  7245. if (autoQ) {
  7246. healer();
  7247. }
  7248. autoQ = false;
  7249. }
  7250.  
  7251.  
  7252. if (tmpObj == player) {
  7253. if (liztobj.length) {
  7254.  
  7255. for(var ggz=0; ggz < liztobj.length; ggz++){
  7256. let tmp = liztobj[ggz];
  7257. //if(tmp.active && tmp.dmg)console.log(tmp);
  7258. if(my.waitHit == 0 && !tmp.isTeamObject(player) &&tmp.active && tmp.dmg && player.secondaryIndex == 10 && /*UTILS.getDist(tmp, player, 0, 2)*/UTILS.getDistance(tmp.x, tmp.y, player.x2 + (player.oldPos.x2 - player.x2) * -1, player.y2 + (player.oldPos.y2 - player.y2) * -1) <= (tmp.scale + items.weapons[player.weapons[1]].range) && /*player.reloads[player.weapons[0]] == 0*/ (player.reloads[player.secondaryIndex] == 0) /* && player.reloads[player.primaryIndex] >= 0.90*/){
  7259. traps.antiPush = true
  7260. selectWeapon(player.weapons[1])
  7261. let old = getSafeDir;
  7262. getSafeDir = ()=>{return UTILS.getDirect(tmp, player, 0, 2)}
  7263. lastDir = UTILS.getDirect(tmp, player, 0, 2);
  7264. if(player.skins[40])buyEquip(40, 0);
  7265. traps.aim = UTILS.getDirect(tmp, player, 0, 2);
  7266. my.waitHit = 1;
  7267. sendAutoGather();
  7268. game.tickBase(() => {
  7269. traps.aim = UTILS.getDirect(tmp, player, 0, 2);
  7270. buyEquip(6, 0);
  7271. sendAutoGather();
  7272. lastDir = UTILS.getDirect(tmp, player, 0, 2);
  7273. my.waitHit = 0;
  7274. traps.antiPush = false
  7275. getSafeDir = old;
  7276. }, 1);
  7277. }
  7278. }
  7279.  
  7280. liztobj.forEach(ala => {
  7281. ala.onNear = false;
  7282. if (ala.active) {
  7283. if (!ala.onNear && UTILS.getDist(ala, tmpObj, 0, 2) <= ala.scale + items.weapons[tmpObj.weapons[0]].range) {
  7284. ala.onNear = true;
  7285. }
  7286. if (ala.isItem && ala.owner) {
  7287. if (!ala.pps && tmpObj.sid == ala.owner.sid && UTILS.getDist(ala, tmpObj, 0, 2) > (parseInt(getEl("breakRange").value) || 0) && !ala.breakObj && ![13, 14, 20].includes(ala.id)) {
  7288. ala.breakObj = true;
  7289. breakObjects.push({
  7290. x: ala.x,
  7291. y: ala.y,
  7292. sid: ala.sid
  7293. });
  7294. }
  7295. }
  7296. }
  7297. });
  7298.  
  7299.  
  7300.  
  7301.  
  7302.  
  7303. let nearTrap = gameObjects.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 5) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  7304. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7305. })[0];
  7306. let nearSpike = gameObjects.filter(e => ["spikes", "greater spikes", "poison spikes", "spinning spikes"].includes(e.name) && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= 125 && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  7307. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7308. })[0];
  7309. if (nearTrap && !nearSpike) {
  7310. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7311. traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7312. if (!traps.inTrap) {
  7313. traps.protect(traps.aim);
  7314. }
  7315. traps.inTrap = true;
  7316. traps.info = nearTrap;
  7317. } else {
  7318. traps.inTrap = false;
  7319. traps.info = {};
  7320. }
  7321. if (nearSpike && nearTrap) {
  7322. traps.dist = UTILS.getDist(nearSpike, tmpObj, 0, 2);
  7323. traps.aim = UTILS.getDirect(nearSpike, tmpObj, 0, 2);
  7324.  
  7325. trackerz.draw4.active = true;
  7326. trackerz.draw4.x = nearSpike.x;
  7327. trackerz.draw4.y = nearSpike.y;
  7328. trackerz.draw4.scale = nearSpike.scale
  7329. if (!traps.inTrap) {
  7330. traps.protect(traps.aim);
  7331. }
  7332. traps.inTrap = true;
  7333. traps.info = nearTrap;
  7334. }
  7335.  
  7336.  
  7337. } else {
  7338. traps.inTrap = false;
  7339. trackerz.draw4.active = false;
  7340. }
  7341. }
  7342. if (tmpObj.weaponIndex < 9) {
  7343. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7344. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7345. } else if (tmpObj.weaponIndex > 8) {
  7346. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7347. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7348. }
  7349. }
  7350. i += 13;
  7351. }
  7352.  
  7353.  
  7354. if (textManager.stack.length) {
  7355. let stacks = [];
  7356. let notstacks = [];
  7357. let num = 0;
  7358. let num2 = 0;
  7359. let pos = {
  7360. x: null,
  7361. y: null
  7362. };
  7363. let pos2 = {
  7364. x: null,
  7365. y: null
  7366. }
  7367. textManager.stack.forEach((text) => {
  7368. if (text.value >= 0) {
  7369. if (num == 0) pos = {
  7370. x: text.x,
  7371. y: text.y
  7372. };
  7373. num += Math.abs(text.value);
  7374. } else {
  7375. if (num2 == 0) pos2 = {
  7376. x: text.x,
  7377. y: text.y
  7378. };
  7379. num2 += Math.abs(text.value);
  7380. }
  7381. });
  7382. if (num2 > 0) {
  7383. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.21, 500, num2, "#8ecc51");
  7384. }
  7385. if (num > 0) {
  7386. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.21, 500, num, tmpObj.dmgColor);
  7387. }
  7388. textManager.stack = [];
  7389. }
  7390. if (runAtNextTick.length) {
  7391. runAtNextTick.forEach((tmp) => {
  7392. checkProjectileHolder(...tmp);
  7393. });
  7394. runAtNextTick = [];
  7395. }
  7396. for (let i = 0; i < data.length;) {
  7397. tmpObj = findPlayerBySID(data[i]);
  7398. if (tmpObj) {
  7399. if (!tmpObj.isTeam(player)) {
  7400. enemy.push(tmpObj);
  7401. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7402. nears.push(tmpObj);
  7403. }
  7404. }
  7405. tmpObj.manageReload();
  7406. if (tmpObj != player) {
  7407. tmpObj.addDamageThreat(player);
  7408. }
  7409. }
  7410. i += 13;
  7411. }
  7412.  
  7413. /*projectiles.forEach((proj) => {
  7414. tmpObj = proj;
  7415. if (tmpObj.active) {
  7416. tmpObj.tickUpdate(game.tickSpeed);
  7417. }
  7418. });*/
  7419. if (player && player.alive) {
  7420. if (enemy.length) {
  7421. near = enemy.sort(function(tmp1, tmp2) {
  7422. return tmp1.dist2 - tmp2.dist2;
  7423. })[0];
  7424. } else {
  7425. // console.log("no enemy");
  7426. }
  7427. //buffed high ms interval per heal
  7428. if (document.getElementById("chkv1").checked && near.dist2 <= 255 && player.shameCount == 0 && tmpObj.skinIndex == 7 == false) {
  7429. for(let i = 0; i < 1; i++) {
  7430. place(0, getAttackDir());
  7431. }
  7432. }
  7433. if (document.getElementById("chkv1").checked && near.dist2 <= 255 && player.shameCount == 1 && tmpObj.skinIndex == 7 == false) {
  7434. for(let i = 0; i < 1; i++) {
  7435. place(0, getAttackDir());
  7436. }
  7437. }
  7438. if (document.getElementById("chkv1").checked && near.dist2 <= 255 && player.shameCount == 3 && tmpObj.skinIndex == 7 == false) {
  7439. for(let i = 0; i < 1; i++) {
  7440. place(0, getAttackDir());
  7441. }
  7442. }
  7443. if (document.getElementById("chkv1").checked && near.dist2 <= 255 && player.shameCount == 5 && tmpObj.skinIndex == 7 == false) {
  7444. for(let i = 0; i < 1; i++) {
  7445. place(0, getAttackDir());
  7446. }
  7447. }
  7448. if (game.tickQueue[game.tick]) {
  7449. game.tickQueue[game.tick].forEach((action) => {
  7450. action();
  7451. });
  7452. game.tickQueue[game.tick] = null;
  7453. }
  7454. players.forEach((tmp) => {
  7455. if (!tmp.visible && player != tmp) {
  7456. tmp.reloads = {
  7457. 0: 0,
  7458. 1: 0,
  7459. 2: 0,
  7460. 3: 0,
  7461. 4: 0,
  7462. 5: 0,
  7463. 6: 0,
  7464. 7: 0,
  7465. 8: 0,
  7466. 9: 0,
  7467. 10: 0,
  7468. 11: 0,
  7469. 12: 0,
  7470. 13: 0,
  7471. 14: 0,
  7472. 15: 0,
  7473. 53: 0,
  7474. };
  7475. }
  7476. if (tmp.setBullTick) {
  7477. tmp.bullTimer = 0;
  7478. }
  7479. if (tmp.setPoisonTick) {
  7480. tmp.poisonTimer = 0;
  7481. }
  7482. tmp.updateTimer();
  7483. });
  7484. if (inGame) {
  7485. if (enemy.length) {
  7486. if (player.canEmpAnti) {
  7487. player.canEmpAnti = false;
  7488. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7489. if (near.reloads[53] == 0) {
  7490. player.empAnti = true;
  7491. player.soldierAnti = false;
  7492. //modLog("EmpAnti");
  7493. } else {
  7494. player.empAnti = false;
  7495. player.soldierAnti = true;
  7496. //modLog("SoldierAnti");
  7497. }
  7498. }
  7499. }
  7500. // In your game update loop
  7501. if (enemy.inTrap) {
  7502. // Deal damage with the equipped weapon
  7503. enemy.takeDamage(player.equippedWeapon.dmg);
  7504.  
  7505. // Get the equipped spike item
  7506. const equippedSpikeItem = player.equippedItems.find(item => item.group === this.groups[2]);
  7507. if (equippedSpikeItem) {
  7508. // Deal damage with the equipped spike item
  7509. enemy.takeDamage(equippedSpikeItem.dmg);
  7510. }
  7511. }
  7512. 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) {
  7513. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7514. })[0];
  7515. if (prehit) {
  7516. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  7517. instaC.canSpikeTick = true;
  7518. instaC.syncHit = true;
  7519. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7520. instaC.revTick = true;
  7521. }
  7522. }
  7523. }
  7524. 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) {
  7525. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7526. })[0];
  7527. if (antiSpikeTick && !traps.inTrap) {
  7528. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  7529. my.anti0Tick = 1;
  7530. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  7531. //player.chat.count = 2000;
  7532. }
  7533. }
  7534. }
  7535. 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)) {
  7536. if (player.checkCanInsta(true) >= 100) {
  7537. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  7538. } else {
  7539. instaC.nobull = false;
  7540. }
  7541. instaC.can = true;
  7542. } else {
  7543. instaC.can = false;
  7544. }
  7545. macro.q && place(0, getAttackDir());
  7546. macro.f && place(4, getSafeDir());
  7547. macro.v && place(2, getSafeDir());
  7548. macro.y && place(5, getSafeDir());
  7549. macro.h && place(player.getItemType(22), getSafeDir());
  7550. macro.n && place(3, getSafeDir());
  7551. if (game.tick % 1 == 0) {
  7552. if (mills.place) {
  7553. let plcAng = 7.7;
  7554. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7555. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7556. }
  7557. } else {
  7558. if (mills.placeSpawnPads) {
  7559. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7560. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7561. }
  7562. }
  7563. }
  7564. }
  7565. if (instaC.can) {
  7566. instaC.changeType(player.weapons[1] == 10 ? "rev" : "normal");
  7567. }
  7568. if (instaC.canCounter) {
  7569. instaC.canCounter = false;
  7570. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7571. instaC.counterType();
  7572. }
  7573. }
  7574. if (instaC.canSpikeTick) {
  7575. instaC.canSpikeTick = false;
  7576. if (instaC.revTick) {
  7577. instaC.revTick = false;
  7578. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7579. instaC.changeType("rev");
  7580. chch(null, "[RevSyncHit]", "yellow");
  7581. }
  7582. } else {
  7583. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7584. instaC.spikeTickType();
  7585. if (instaC.syncHit) {
  7586. chch(null, "[SyncHit]", "yellow");
  7587. }
  7588. }
  7589. }
  7590. }
  7591. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7592. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7593. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7594. }
  7595. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7596. sendAutoGather();
  7597. my.waitHit = 1;
  7598. game.tickBase(() => {
  7599. sendAutoGather();
  7600. my.waitHit = 0;
  7601. }, 1);
  7602. }
  7603. }
  7604. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  7605. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  7606. selectWeapon(player.weapons[0]);
  7607. }
  7608. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  7609. sendAutoGather();
  7610. my.waitHit = 1;
  7611. game.tickBase(() => {
  7612. sendAutoGather();
  7613. my.waitHit = 0;
  7614. }, 1);
  7615. }
  7616. }
  7617. if (traps.inTrap) {
  7618. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7619. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7620. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7621. }
  7622. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7623. sendAutoGather();
  7624. my.waitHit = 1;
  7625. game.tickBase(() => {
  7626. sendAutoGather();
  7627. my.waitHit = 0;
  7628. }, 1);
  7629. }
  7630. }
  7631. }
  7632. if (clicks.middle && !traps.inTrap) {
  7633. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7634. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7635. instaC.bowMovement();
  7636. } else {
  7637. instaC.rangeType();
  7638. }
  7639. }
  7640. }
  7641.  
  7642.  
  7643. if (macro.t && !traps.inTrap) {
  7644. 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))) {
  7645. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7646. }
  7647. }
  7648. if (macro["."] && !traps.inTrap) {
  7649. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7650. instaC.boostTickMovement();
  7651. }
  7652. }
  7653. 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)) {
  7654. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7655. if (!my.reloaded) {
  7656. my.reloaded = true;
  7657. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7658. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7659. selectWeapon(player.weapons[fastSpeed]);
  7660. }
  7661. }
  7662. // if(useWasd) {
  7663. // if (!autos.stopspin) {
  7664. // setTimeout(()=>{
  7665. // autos.stopspin = true;
  7666. // }, 375);
  7667. // }
  7668. // }
  7669. } else {
  7670. my.reloaded = false;
  7671. if(useWasd) {
  7672. autos.stopspin = false;
  7673. }
  7674. if (player.reloads[player.weapons[0]] > 0) {
  7675. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7676. selectWeapon(player.weapons[0]);
  7677. }
  7678. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7679. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7680. selectWeapon(player.weapons[1]);
  7681. }
  7682. if(useWasd) {
  7683. if (!autos.stopspin) {
  7684. setTimeout(()=>{
  7685. autos.stopspin = true;
  7686. }, 750);
  7687. }
  7688. }
  7689. }
  7690. }
  7691. }
  7692. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  7693. traps.autoPlace();
  7694. }
  7695. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7696. packet("D", getAttackDir());
  7697. }
  7698. let hatChanger = function () {
  7699. if (clicks.left || clicks.right) {
  7700. if (clicks.left) {
  7701. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7702. } else if (clicks.right) {
  7703. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7704. }
  7705. } else {
  7706. if (clicks.left || clicks.right) {
  7707. if (
  7708. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7709. ((near && near.dist2 > 120) || !near)
  7710. ) {
  7711. } else {
  7712. if (clicks.left) {
  7713. buyEquip(
  7714. player.reloads[player.weapons[0]] == 0
  7715. ? getEl('weaponGrind').checked
  7716. ? 40
  7717. : 7
  7718. : player.empAnti
  7719. ? 22
  7720. : player.soldierAnti
  7721. ? 6
  7722. : getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7723. ? 19
  7724. : near.dist2 <= 300
  7725. ? getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7726. ? 19
  7727. : 6
  7728. : biomeGear(1, 1),
  7729. 0
  7730. );
  7731. } else if (clicks.right) {
  7732. buyEquip(
  7733. player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0
  7734. ? 40
  7735. : player.empAnti
  7736. ? 22
  7737. : player.soldierAnti
  7738. ? 6
  7739. : getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7740. ? 19
  7741. : near.dist2 <= 300
  7742. ? getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7743. ? 19
  7744. : 6
  7745. : biomeGear(1, 1),
  7746. 0
  7747. );
  7748. }
  7749. }
  7750. } else if (traps.inTrap) {
  7751. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) { //autobreaker
  7752. buyEquip(40, 0);
  7753. buyEquip(21, 1);
  7754. } else {
  7755. if (
  7756. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7757. ((near && near.dist2 > 140) || !near)
  7758. ) {
  7759. }
  7760. }
  7761. } else {
  7762. if (
  7763. ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) &&
  7764. ((near && near.dist2 > 140) || !near)
  7765. ) {
  7766. } else {
  7767. if (near.dist2 <= 300) {
  7768. buyEquip(
  7769. getEl('antiBullType').value == 'abreload' && near.antiBull > 0
  7770. ? 19
  7771. : getEl('antiBullType').value == 'abalway' && near.reloads[near.primaryIndex] == 0
  7772. ? 19
  7773. : 6,
  7774. 0
  7775. );
  7776. } else {
  7777. biomeGear(1);
  7778. }
  7779. }
  7780. }
  7781. }
  7782. };
  7783.  
  7784. if (clicks.left) {
  7785. buyEquip(19, 1);
  7786. } else if (clicks.right) {
  7787. buyEquip(11, 1);
  7788. } else {
  7789. const weaponId = player.weapons[0];
  7790. if (weaponId === 5) {
  7791. if (near.dist2 <= 300) {
  7792. buyEquip(19, 1);
  7793. } else {
  7794. buyEquip(11, 1);
  7795. }
  7796. } else if (weaponId === 7) {
  7797. buyEquip(11, 1);
  7798. }
  7799.  
  7800.  
  7801. }
  7802. let accChanger = function() {
  7803.  
  7804.  
  7805. };
  7806.  
  7807.  
  7808. let wasdGears = function() {
  7809. if (my.anti0Tick > 0) {
  7810. buyEquip(6, 0);
  7811. } else {
  7812. if (clicks.left || clicks.right) {
  7813. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7814. buyEquip(6, 0);
  7815. } else {
  7816. if (clicks.left) {
  7817. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 6 : player.empAnti ? 22 : 6, 0);
  7818. } else if (clicks.right) {
  7819. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7820. }
  7821. }
  7822. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7823. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7824. buyEquip(7, 0);
  7825. } else {
  7826. buyEquip(player.reloads[player.weapons[0]] == 0 ? 6 : player.empAnti ? 22 : 6, 0);
  7827. }
  7828. } else if (traps.inTrap) {
  7829. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7830. buyEquip(40, 0);
  7831. } else {
  7832. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7833. buyEquip(6, 0);
  7834. } else {
  7835. buyEquip(player.empAnti ? 22 : 6, 0);
  7836. }
  7837. }
  7838. } else {
  7839. if (player.empAnti) {
  7840. buyEquip(22, 0);
  7841. } else {
  7842. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7843. buyEquip(6, 0);
  7844. } else {
  7845. buyEquip(6, 0);
  7846. }
  7847. }
  7848. }
  7849. }
  7850. if (clicks.left || clicks.right) {
  7851. if (clicks.left) {
  7852. buyEquip(0, 1);
  7853. } else if (clicks.right) {
  7854. buyEquip(19, 1);
  7855. }
  7856. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7857. buyEquip(0, 1);
  7858. } else if (traps.inTrap) {
  7859. buyEquip(0, 1);
  7860. } else {
  7861. buyEquip(19, 1);
  7862. }
  7863. }
  7864. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7865. if (useWasd) {
  7866. wasdGears();
  7867. } else {
  7868. hatChanger();
  7869. accChanger();
  7870. }
  7871. }
  7872. //lastMoveDir = getSafeDir();
  7873. //packet("a", lastMoveDir, 1);
  7874. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7875. autoPush();
  7876. } else {
  7877. if (my.autoPush) {
  7878. my.autoPush = false;
  7879. packet("a", lastMoveDir || undefined, 1);
  7880. }
  7881. }
  7882. if (instaC.ticking) {
  7883. instaC.ticking = false;
  7884. }
  7885. if (instaC.syncHit) {
  7886. instaC.syncHit = false;
  7887. }
  7888. if (player.empAnti) {
  7889. player.empAnti = false;
  7890. }
  7891. if (player.soldierAnti) {
  7892. player.soldierAnti = false;
  7893. }
  7894. if (my.anti0Tick > 0) {
  7895. my.anti0Tick--;
  7896. }
  7897. if (traps.replaced) {
  7898. traps.replaced = false;
  7899. }
  7900. if (traps.antiTrapped) {
  7901. traps.antiTrapped = false;
  7902. }
  7903.  
  7904. const getPotentialDamage = (build, user) => {
  7905. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7906. const weap = user.weapons[weapIndex];
  7907. if (player.reloads[weap]) return 0;
  7908. const weapon = items.weapons[weap];
  7909. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7910. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7911. };
  7912.  
  7913. const AutoReplace = () => {
  7914. const replaceable = [];
  7915. const playerX = player.x;
  7916. const playerY = player.y;
  7917. const gameObjectCount = gameObjects.length;
  7918.  
  7919. for (let i = 0; i < gameObjectCount; i++) {
  7920. const build = gameObjects[i];
  7921. if (build.isItem && build.active && build.health > 0) {
  7922. const item = items.list[build.id];
  7923. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7924. const inDistance = cdf(build, player) <= posDist * 2;
  7925. if (inDistance) {
  7926. let canDeal = 0;
  7927. const playersCount = players.length;
  7928. for (let j = 0; j < playersCount; j++) {
  7929. canDeal += getPotentialDamage(build, players[j]);
  7930. }
  7931. if (build.health <= canDeal) {
  7932. replaceable.push(build);
  7933. }
  7934. }
  7935. }
  7936. }
  7937.  
  7938. const findPlacementAngle = (player, itemId, build) => {
  7939. if (!build) return null;
  7940. const MAX_ANGLE = 4* Math.PI;
  7941. const ANGLE_STEP = Math.PI / 560
  7942. const item = items.list[player.items[itemId]];
  7943. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7944. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7945.  
  7946. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7947. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7948. for (let angle of angles) {
  7949. return angle;
  7950. }
  7951. }
  7952. return null;
  7953. };
  7954.  
  7955. const replace = (() => {
  7956. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7957. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7958. const buildId = spike ? 4 : 2;
  7959.  
  7960. replaceable.forEach(build => {
  7961. let angle = findPlacementAngle(player, buildId, build);
  7962. if (angle !== null) {
  7963. place(buildId, angle);
  7964. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7965. }
  7966. });
  7967. });
  7968.  
  7969. if (near && near.dist3 <= 360) {
  7970. replace();
  7971. }
  7972. replace;
  7973. }
  7974. }
  7975. }
  7976. if (botSkts.length) {
  7977. botSkts.forEach((bots) => {
  7978. if (true) {
  7979. bots[0].showName = 'YEAHHH';
  7980. }
  7981. });
  7982. }
  7983. }
  7984.  
  7985. function detectHat(index) {
  7986. if (player.skins[26]) {
  7987. if (near.weaponIndex == 7 && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && traps.canHit()) {
  7988. buyEquip(26, 0);
  7989. } else {
  7990. if (getEl("mainHat").value == "spikegear") {
  7991. buyEquip(11, 0);
  7992. } else if (getEl("mainHat").value == "empgear") {
  7993. buyEquip(22, 0);
  7994. } else {
  7995. buyEquip(index, 0);
  7996. }
  7997. }
  7998.  
  7999. if (near.weaponIndex == 7 && !player.skins[26]) {
  8000. if (player.points >= 8000) {
  8001. storeBuy(26, 0);
  8002. }
  8003. }
  8004. }
  8005. }
  8006.  
  8007. function ez(context, x, y) {
  8008. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  8009. context.beginPath();
  8010. context.arc(x, y, 55, 0, Math.PI * 2);
  8011. context.fill();
  8012. context.closePath();
  8013. context.globalAlpha = 1;
  8014. }
  8015.  
  8016.  
  8017. // UPDATE LEADERBOARD:
  8018. function updateLeaderboard(data) {
  8019. lastLeaderboardData = data;
  8020. UTILS.removeAllChildren(leaderboardData);
  8021. let tmpC = 1;
  8022. if (getEl("hideleaderboard").checked) {
  8023. for (let i = 0; i < data.length; i += 3) {
  8024. (function(i) {
  8025. UTILS.generateElement({
  8026. class: "leaderHolder",
  8027. parent: leaderboardData,
  8028. children: [
  8029. UTILS.generateElement({
  8030. class: "leaderboardItem",
  8031. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  8032. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  8033. }),
  8034. UTILS.generateElement({
  8035. class: "leaderScore",
  8036. text: UTILS.sFormat(data[i + 2]) || "0"
  8037. })
  8038. ]
  8039. });
  8040. })(i);
  8041. tmpC++;
  8042. }
  8043. }
  8044. }
  8045. //AVOID SPIKES JJAJJJA
  8046. function avoidSpike(liztobj, i1, nearDist, player) {
  8047. if (liztobj[i1] && liztobj[i1].name.includes("spike") && nearDist <= 100) {
  8048. // Make the player stop
  8049. player.velocity.x = 0;
  8050. player.velocity.y = 0;
  8051. }
  8052. }
  8053. // LOAD GAME OBJECT:
  8054. function loadGameObject(data) {
  8055. for (let i = 0; i < data.length;) {
  8056. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  8057. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  8058. sid: data[i + 7]
  8059. } : null));
  8060. // sid, x, y, dir, s, type, data, setSID, owner
  8061. /*let dist = UTILS.getDist({
  8062. x: data[i + 1],
  8063. y: data[i + 2]
  8064. }, player, 0, 2);
  8065. let aim = UTILS.getDirect({
  8066. x: data[i + 1],
  8067. y: data[i + 2]
  8068. }, player, 0, 2);
  8069. find = findObjectBySid(data[i]);
  8070. if (data[i + 6] == 15) {
  8071. if (find && !find.isTeamObject(player)) {
  8072. if (dist <= 100) {
  8073. traps.dist = dist;
  8074. traps.aim = aim;
  8075. traps.protect(aim);
  8076. }
  8077. }
  8078. }*/
  8079. i += 8;
  8080. }
  8081. }
  8082.  
  8083. // ADD AI:
  8084. function loadAI(data) {
  8085. for (let i = 0; i < ais.length; ++i) {
  8086. ais[i].forcePos = !ais[i].visible;
  8087. ais[i].visible = false;
  8088. }
  8089. if (data) {
  8090. let tmpTime = performance.now();
  8091. for (let i = 0; i < data.length;) {
  8092. tmpObj = findAIBySID(data[i]);
  8093. if (tmpObj) {
  8094. tmpObj.index = data[i + 1];
  8095. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  8096. tmpObj.t2 = tmpTime;
  8097. tmpObj.x1 = tmpObj.x;
  8098. tmpObj.y1 = tmpObj.y;
  8099. tmpObj.x2 = data[i + 2];
  8100. tmpObj.y2 = data[i + 3];
  8101. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  8102. tmpObj.d2 = data[i + 4];
  8103. tmpObj.health = data[i + 5];
  8104. tmpObj.dt = 0;
  8105. tmpObj.visible = true;
  8106. } else {
  8107. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  8108. tmpObj.x2 = tmpObj.x;
  8109. tmpObj.y2 = tmpObj.y;
  8110. tmpObj.d2 = tmpObj.dir;
  8111. tmpObj.health = data[i + 5];
  8112. if (!aiManager.aiTypes[data[i + 1]].name)
  8113. tmpObj.name = config.cowNames[data[i + 6]];
  8114.  
  8115. tmpObj.forcePos = true;
  8116. tmpObj.sid = data[i];
  8117. tmpObj.visible = true;
  8118. }
  8119. i += 7;
  8120. }
  8121. }
  8122. }
  8123.  
  8124.  
  8125. // ANIMATE AI:
  8126. function animateAI(sid) {
  8127. tmpObj = findAIBySID(sid);
  8128. if (tmpObj) tmpObj.startAnim();
  8129. }
  8130. function fgdo(a, b) {
  8131. if (a == player) {
  8132. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  8133. } else if (b == player) {
  8134. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  8135. } else {
  8136. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  8137. }
  8138. }
  8139. // GATHER ANIMATION:
  8140. function gatherAnimation(sid, didHit, index) {
  8141. tmpObj = findPlayerBySID(sid);
  8142. if (tmpObj) {
  8143. tmpObj.startAnim(didHit, index);
  8144. tmpObj.gatherIndex = index;
  8145. tmpObj.gathering = 1;
  8146.  
  8147. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  8148. // healer();
  8149.  
  8150. if (didHit) {
  8151. let tmpObjects = objectManager.hitObj;
  8152. objectManager.hitObj = [];
  8153. game.tickBase(() => {
  8154. // refind
  8155. tmpObj = findPlayerBySID(sid);
  8156. 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);
  8157. tmpObjects.forEach((healthy) => {
  8158. healthy.health -= val;
  8159. });
  8160. }, 1);
  8161. }
  8162. }
  8163. }
  8164. if(nears.filter(near => near.gathering).length>1) {
  8165. player.chat.message = "pSyD";
  8166. healer();
  8167. }
  8168.  
  8169.  
  8170. // WIGGLE GAME OBJECT:
  8171. function wiggleGameObject(dir, sid) {
  8172. tmpObj = findObjectBySid(sid);
  8173. if (tmpObj) {
  8174. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  8175. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  8176. if (tmpObj.health) {
  8177. objectManager.hitObj.push(tmpObj);
  8178. }
  8179. }
  8180. }
  8181.  
  8182.  
  8183.  
  8184. // SHOOT TURRET:
  8185. function shootTurret(sid, dir) {
  8186. tmpObj = findObjectBySid(sid);
  8187. if (tmpObj) {
  8188. if (config.anotherVisual) {
  8189. tmpObj.lastDir = dir;
  8190. } else {
  8191. tmpObj.dir = dir;
  8192. }
  8193. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  8194. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  8195. }
  8196. }
  8197.  
  8198. // UPDATE PLAYER VALUE:
  8199. function updatePlayerValue(index, value, updateView) {
  8200. if (player) {
  8201. player[index] = value;
  8202.  
  8203. if (index == "points") {
  8204. if (configs.autoBuy) {
  8205. autoBuy.hat();
  8206. autoBuy.acc();
  8207. }
  8208. } else if (index == "kills") {
  8209. const skibididomdom = new Audio("https://cdn.discordapp.com/attachments/1210312187965607948/1216044756841529384/yt1s.com_-_recep_Ivedikdom_dom_yes_yes.mp3?ex=65fef4ef&is=65ec7fef&hm=71d45d1934b9d96b68b57f1f339f989a13bf87f5da5cbda31bb638de7139bb75&");
  8210. const ezsound = new Audio("https://cdn.discordapp.com/attachments/1210312187965607948/1216044764823031848/yt1s.com_-_EZ_easy_Sound_Effect.mp3?ex=65fef4f0&is=65ec7ff0&hm=49aa97cff4d37701d59232b19bfbaacd9d88e7d408f8cadb47cccc0dba2a2ecd&")
  8211. const verrora = new Audio("https://cdn.discordapp.com/attachments/1118998446830014537/1216094638092325004/Veorra_-_Run.mp3?ex=65ff2363&is=65ecae63&hm=93dcc947418c97355b1696d96e72804b16e64334918d28b687c430847cc95044&")
  8212. if (configs.killChat) {
  8213. var mykillchat = getEl('killchat').value;
  8214. sendChat(mykillchat);
  8215. if (getEl("killsounds").value === "killsoundskibidi") {
  8216. skibididomdom.play();
  8217. } else if (getEl("killsounds").value === "killsoundez") {
  8218. ezsound.play();
  8219. } else if (getEl("killsounds").value === "killsoundveorra") {
  8220. verrora.play();
  8221. } else {
  8222. return
  8223. }
  8224. }
  8225. }
  8226. }
  8227. }
  8228. // ACTION BAR:
  8229. function updateItems(data, wpn) {
  8230. if (data) {
  8231. if (wpn) {
  8232. player.weapons = data;
  8233. player.primaryIndex = player.weapons[0];
  8234. player.secondaryIndex = player.weapons[1];
  8235. if (!instaC.isTrue) {
  8236. selectWeapon(player.weapons[0]);
  8237. }
  8238. } else {
  8239. player.items = data;
  8240. }
  8241. }
  8242. for (let i = 0; i < items.list.length; i++) {
  8243. let tmpI = items.weapons.length + i;
  8244. getEl("actionBarItem" + tmpI).style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8245. }
  8246. for (let i = 0; i < items.weapons.length; i++) {
  8247. getEl("actionBarItem" + i).style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8248. }
  8249. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8250. if (kms) {
  8251. getEl("actionBarItem3").style.display = "none";
  8252. getEl("actionBarItem4").style.display = "inline-block";
  8253. }
  8254. }
  8255. // ADD PROJECTILE:
  8256. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8257. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8258. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8259. }
  8260. // REMOVE PROJECTILE:
  8261. function remProjectile(sid, range) {
  8262. for (let i = 0; i < projectiles.length; ++i) {
  8263. if (projectiles[i].sid == sid) {
  8264. projectiles[i].range = range;
  8265. let tmpObjects = objectManager.hitObj;
  8266. objectManager.hitObj = [];
  8267. game.tickBase(() => {
  8268. let val = projectiles[i].dmg;
  8269. tmpObjects.forEach((healthy) => {
  8270. if (healthy.projDmg) {
  8271. healthy.health -= val;
  8272. }
  8273. });
  8274. }, 1);
  8275. }
  8276. }
  8277. }
  8278. // lol this useless,,, fr
  8279. let noob = false;
  8280. let serverReady = true;
  8281. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  8282. let wssws = isProd ? "wss" : "ws";
  8283. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  8284. let withSync = false;
  8285. project.binaryType = "arraybuffer";
  8286. project.onmessage = function(msg) {
  8287. let data = msg.data;
  8288. if (data == "isready") {
  8289. serverReady = true;
  8290. }
  8291. if (data == "fine") {
  8292. noob = false;
  8293. }
  8294.  
  8295. if (data == "tezt") {
  8296. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  8297. }
  8298. if (data == "yeswearesyncer") {
  8299. // let delay = Date.now() - wsDelay;
  8300. withSync = true;
  8301. if (player) {
  8302. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  8303. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  8304. }
  8305. }
  8306. };
  8307.  
  8308. // SHOW ALLIANCE MENU:
  8309. function allianceNotification(sid, name) {
  8310. let findBotSID = findSID(bots, sid);
  8311. if (findBotSID) {}
  8312. }
  8313.  
  8314. function setPlayerTeam(team, isOwner) {
  8315. if (player) {
  8316. player.team = team;
  8317. player.isOwner = isOwner;
  8318. if (team == null)
  8319. alliancePlayers = [];
  8320. }
  8321. }
  8322.  
  8323. function setAlliancePlayers(data) {
  8324. alliancePlayers = data;
  8325. }
  8326.  
  8327. // STORE MENU:
  8328. function updateStoreItems(type, id, index) {
  8329. if (index) {
  8330. if (!type)
  8331. player.tails[id] = 1;
  8332. else {
  8333. player.latestTail = id;
  8334. }
  8335. } else {
  8336. if (!type)
  8337. player.skins[id] = 1,
  8338. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8339. else {
  8340. player.latestSkin = id;
  8341. }
  8342. }
  8343. }
  8344. // SEND MESSAGE:
  8345. function receiveChat(sid, message) {
  8346. if (message.indexOf('<') !== -1) {
  8347. sendChat("");
  8348. return;
  8349. }
  8350. if (message === 'zatuzatu -o-' && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  8351. packet("6", "");
  8352. my.autoAim = true;
  8353. selectWeapon(player.weapons[0]);
  8354. buyEquip(7, 0);
  8355. sendAutoGather();
  8356. game.tickBase(() => {
  8357. selectWeapon(player.weapons[1]);
  8358. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  8359. game.tickBase(() => {
  8360. sendAutoGather();
  8361. this.isTrue = false;
  8362. my.autoAim = false;
  8363. }, 1);
  8364. }, 1);
  8365. }
  8366.  
  8367.  
  8368.  
  8369. // SEND MESSAGE:
  8370. let tmpPlayer = findPlayerBySID(sid);
  8371. if (tmpPlayer) {
  8372. addMenuChText(`${tmpPlayer.name} {${tmpPlayer.sid}}`, message, "white");
  8373. if (config.anotherVisual) {
  8374. allChats.push(new addCh(tmpPlayer.x, tmpPlayer.y, message, tmpPlayer));
  8375. } else {
  8376. tmpPlayer.chatMessage = ((text) => {
  8377. let tmpString;
  8378. profanityList.forEach((list) => {
  8379. if (text.indexOf(list) > -1) {
  8380. tmpString = "";
  8381. for (var y = 0; y < list.length; ++y) {
  8382. tmpString += tmpString.length ? "o" : "M";
  8383. }
  8384. var re = new RegExp(list, 'g');
  8385. text = text.replace(re, tmpString);
  8386. }
  8387. });
  8388. return text;
  8389. })(message);
  8390. tmpPlayer.chatCountdown = config.chatCountdown;
  8391. }
  8392. } else {
  8393. addMenuChText(`${"Anonymous"} {null}`, message, "white");
  8394. }
  8395. }
  8396.  
  8397.  
  8398. // MINIMAP:
  8399. function updateMinimap(data) {
  8400. minimapData = data;
  8401. }
  8402.  
  8403. // SHOW ANIM TEXT:
  8404. function showText(x, y, value, type) {
  8405. // if (config.anotherVisual) {
  8406.  
  8407.  
  8408. textManager.showText(x, y, 50, 0.18, 500, Math.abs(value), (value>=0)?tmpObj.dmgColor:"#8ecc51");
  8409. // }
  8410. }
  8411.  
  8412. /** APPLY SOCKET CODES */
  8413.  
  8414. // BOT:
  8415. let bots = [];
  8416. let ranLocation = {
  8417. x: UTILS.randInt(35, 14365),
  8418. y: UTILS.randInt(35, 14365)
  8419. };
  8420. setInterval(() => {
  8421. ranLocation = {
  8422. x: UTILS.randInt(35, 14365),
  8423. y: UTILS.randInt(35, 14365)
  8424. };
  8425. }, 60000);
  8426. class Bot {
  8427. constructor(id, sid, hats, accessories) {
  8428. this.millPlace = true;
  8429. this.id = id;
  8430. this.sid = sid;
  8431. this.team = null;
  8432. this.skinIndex = 0;
  8433. this.tailIndex = 0;
  8434. this.hitTime = 0;
  8435. this.iconIndex = 0;
  8436. this.enemy = [];
  8437. this.near = [];
  8438. this.dist2 = 0;
  8439. this.aim2 = 0;
  8440. this.tick = 0;
  8441. this.itemCounts = {};
  8442. this.latestSkin = 0;
  8443. this.latestTail = 0;
  8444. this.points = 0;
  8445. this.tails = {};
  8446. for (let i = 0; i < accessories.length; ++i) {
  8447. if (accessories[i].price <= 0)
  8448. this.tails[accessories[i].id] = 1;
  8449. }
  8450. this.skins = {};
  8451. for (let i = 0; i < hats.length; ++i) {
  8452. if (hats[i].price <= 0)
  8453. this.skins[hats[i].id] = 1;
  8454. }
  8455. this.spawn = function(moofoll) {
  8456. this.upgraded = 0;
  8457. this.enemy = [];
  8458. this.near = [];
  8459. this.active = true;
  8460. this.alive = true;
  8461. this.lockMove = false;
  8462. this.lockDir = false;
  8463. this.minimapCounter = 0;
  8464. this.chatCountdown = 0;
  8465. this.shameCount = 0;
  8466. this.shameTimer = 0;
  8467. this.sentTo = {};
  8468. this.gathering = 0;
  8469. this.autoGather = 0;
  8470. this.animTime = 0;
  8471. this.animSpeed = 0;
  8472. this.mouseState = 0;
  8473. this.buildIndex = -1;
  8474. this.weaponIndex = 0;
  8475. this.dmgOverTime = {};
  8476. this.noMovTimer = 0;
  8477. this.maxXP = 300;
  8478. this.XP = 0;
  8479. this.age = 1;
  8480. this.kills = 0;
  8481. this.upgrAge = 2;
  8482. this.upgradePoints = 0;
  8483. this.x = 0;
  8484. this.y = 0;
  8485. this.zIndex = 0;
  8486. this.xVel = 0;
  8487. this.yVel = 0;
  8488. this.slowMult = 1;
  8489. this.dir = 0;
  8490. this.nDir = 0;
  8491. this.dirPlus = 0;
  8492. this.targetDir = 0;
  8493. this.targetAngle = 0;
  8494. this.maxHealth = 100;
  8495. this.health = this.maxHealth;
  8496. this.oldHealth = this.maxHealth;
  8497. this.scale = config.playerScale;
  8498. this.speed = config.playerSpeed;
  8499. this.resetMoveDir();
  8500. this.resetResources(moofoll);
  8501.  
  8502. this.items = [0, 3, 6, 10];
  8503. this.weapons = [0];
  8504. this.shootCount = 0;
  8505. this.weaponXP = [];
  8506. this.isBot = false;
  8507. this.reloads = {
  8508. 0: 0,
  8509. 1: 0,
  8510. 2: 0,
  8511. 3: 0,
  8512. 4: 0,
  8513. 5: 0,
  8514. 6: 0,
  8515. 7: 0,
  8516. 8: 0,
  8517. 9: 0,
  8518. 10: 0,
  8519. 11: 0,
  8520. 12: 0,
  8521. 13: 0,
  8522. 14: 0,
  8523. 15: 0,
  8524. 53: 0,
  8525. };
  8526. this.timeZinceZpawn = 0;
  8527. this.whyDie = "";
  8528. this.clearRadius = false;
  8529. this.circlee = 0;
  8530. };
  8531.  
  8532. // RESET MOVE DIR:
  8533. this.resetMoveDir = function() {
  8534. this.moveDir = undefined;
  8535. };
  8536.  
  8537. // RESET RESOURCES:
  8538. this.resetResources = function(moofoll) {
  8539. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8540. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8541. }
  8542. };
  8543.  
  8544. // SET DATA:
  8545. this.setData = function(data) {
  8546. this.id = data[0];
  8547. this.sid = data[1];
  8548. this.name = data[2];
  8549. this.x = data[3];
  8550. this.y = data[4];
  8551. this.dir = data[5];
  8552. this.health = data[6];
  8553. this.maxHealth = data[7];
  8554. this.scale = data[8];
  8555. this.skinColor = data[9];
  8556. };
  8557.  
  8558.  
  8559. // SHAME SYSTEM:
  8560. this.judgeShame = function() {
  8561. if (this.oldHealth < this.health) {
  8562. if (this.hitTime) {
  8563. let timeSinceHit = this.tick - this.hitTime;
  8564. this.hitTime = 0;
  8565. if (timeSinceHit < 2) {
  8566. this.lastshamecount = this.shameCount;
  8567. this.shameCount++;
  8568. } else {
  8569. this.lastshamecount = this.shameCount;
  8570. this.shameCount = Math.max(0, this.shameCount - 2);
  8571. }
  8572. }
  8573. } else if (this.oldHealth > this.health) {
  8574. this.hitTime = this.tick;
  8575. }
  8576. };
  8577.  
  8578. // UPDATE WEAPON RELOAD:
  8579. this.manageReloadaa = function() {
  8580. if (this.shooting[53]) {
  8581. this.shooting[53] = 0;
  8582. this.reloads[53] = (2500 - 1000/9);
  8583. } else {
  8584. if (this.reloads[53] > 0) {
  8585. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8586. }
  8587. }
  8588. if (this.gathering || this.shooting[1]) {
  8589. if (this.gathering) {
  8590. this.gathering = 0;
  8591. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8592. this.attacked = true;
  8593. }
  8594. if (this.shooting[1]) {
  8595. this.shooting[1] = 0;
  8596. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8597. this.attacked = true;
  8598. }
  8599. } else {
  8600. this.attacked = false;
  8601. if (this.buildIndex < 0) {
  8602. if (this.reloads[this.weaponIndex] > 0) {
  8603. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8604. }
  8605. }
  8606. }
  8607. };
  8608.  
  8609. this.closeSockets = function(websc) {
  8610. websc.close();
  8611. };
  8612.  
  8613. this.whyDieChat = function(websc, whydie) {
  8614. websc.sendWS("6", "why die XDDD " + whydie);
  8615. };
  8616. }
  8617. };
  8618.  
  8619. class BotObject {
  8620. constructor(sid) {
  8621. this.sid = sid;
  8622. // INIT:
  8623. this.init = function(x, y, dir, scale, type, data, owner) {
  8624. data = data || {};
  8625. this.active = true;
  8626. this.x = x;
  8627. this.y = y;
  8628. this.scale = scale;
  8629. this.owner = owner;
  8630. this.id = data.id;
  8631. this.dmg = data.dmg;
  8632. this.trap = data.trap;
  8633. this.teleport = data.teleport;
  8634. this.isItem = this.id != undefined;
  8635. };
  8636.  
  8637. }
  8638. };
  8639. class BotObjManager {
  8640. constructor(botObj, fOS) {
  8641. // DISABLE OBJ:
  8642. this.disableObj = function(obj) {
  8643. obj.active = false;
  8644. if (config.anotherVisual) {} else {
  8645. obj.alive = false;
  8646. }
  8647. };
  8648.  
  8649. // ADD NEW:
  8650. let tmpObj;
  8651. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8652. tmpObj = fOS(sid);
  8653. if (!tmpObj) {
  8654. tmpObj = botObj.find((tmp) => !tmp.active);
  8655. if (!tmpObj) {
  8656. tmpObj = new BotObject(sid);
  8657. botObj.push(tmpObj);
  8658. }
  8659. }
  8660. if (setSID) {
  8661. tmpObj.sid = sid;
  8662. }
  8663. tmpObj.init(x, y, dir, s, type, data, owner);
  8664. };
  8665.  
  8666. // DISABLE BY SID:
  8667. this.disableBySid = function(sid) {
  8668. let find = fOS(sid);
  8669. if (find) {
  8670. this.disableObj(find);
  8671. }
  8672. };
  8673.  
  8674. // REMOVE ALL FROM PLAYER:
  8675. this.removeAllItems = function(sid, server) {
  8676. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8677. };
  8678. }
  8679. };
  8680.  
  8681. let botz = [];
  8682.  
  8683. function botSpawn(id) {
  8684. let bot;
  8685. console.log(WS);
  8686. let t = WS.url.split("wss://")[1].split("?")[0];
  8687. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8688. let botPlayer = new Map();
  8689. botSkts.push([botPlayer]);
  8690. botz.push([bot]);
  8691. let botSID;
  8692. let botObj = [];
  8693. let nearObj = [];
  8694. let bD = {
  8695. x: 0,
  8696. y: 0,
  8697. inGame: false,
  8698. closeSocket: false,
  8699. whyDie: ""
  8700. };
  8701. let oldXY = {
  8702. x: 0,
  8703. y: 0,
  8704. };
  8705. let izauto = 0;
  8706. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8707. bot.binaryType = "arraybuffer";
  8708. bot.first = true;
  8709. bot.sendWS = function(type) {
  8710. // EXTRACT DATA ARRAY:
  8711. let data = Array.prototype.slice.call(arguments, 1);
  8712. // SEND MESSAGE:
  8713. let binary = window.msgpack.encode([type, data]);
  8714. bot.send(binary);
  8715. };
  8716.  
  8717. bot.spawn = function() {
  8718. bot.sendWS("M", {
  8719. name: "Onichan :3",
  8720. moofoll: 1,
  8721. skin: "__proto__"
  8722. });
  8723. };
  8724. bot.sendUpgrade = function(index) {
  8725. bot.sendWS("H", index);
  8726. };
  8727. bot.place = function(id, a) {
  8728. try {
  8729. let item = items.list[botPlayer.items[id]];
  8730. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  8731. bot.sendWS("G", botPlayer.items[id]);
  8732. bot.sendWS("d", 1, a);
  8733. bot.sendWS("G", botPlayer.weaponIndex, true);
  8734. }
  8735. } catch (e) {
  8736. }
  8737. };
  8738. bot.buye = function(id, index) {
  8739. let nID = 0;
  8740. if (botPlayer.alive && botPlayer.inGame) {
  8741. if (index == 0) {
  8742. if (botPlayer.skins[id]) {
  8743. if (botPlayer.latestSkin != id) {
  8744. bot.sendWS("c", 0, id, 0);
  8745. }
  8746. } else {
  8747. let find = findID(hats, id);
  8748. if (find) {
  8749. if (botPlayer.points >= find.price) {
  8750. bot.sendWS("c", 1, id, 0);
  8751. bot.sendWS("c", 0, id, 0);
  8752. } else {
  8753. if (botPlayer.latestSkin != nID) {
  8754. bot.sendWS("c", 0, nID, 0);
  8755. }
  8756. }
  8757. } else {
  8758. if (botPlayer.latestSkin != nID) {
  8759. bot.sendWS("c", 0, nID, 0);
  8760. }
  8761. }
  8762. }
  8763. } else if (index == 1) {
  8764. if (botPlayer.tails[id]) {
  8765. if (botPlayer.latestTail != id) {
  8766. bot.sendWS("c", 0, id, 1);
  8767. }
  8768. } else {
  8769. let find = findID(accessories, id);
  8770. if (find) {
  8771. if (botPlayer.points >= find.price) {
  8772. bot.sendWS("c", 1, id, 1);
  8773. bot.sendWS("c", 0, id, 1);
  8774. } else {
  8775. if (botPlayer.latestTail != 0) {
  8776. bot.sendWS("c", 0, 0, 1);
  8777. }
  8778. }
  8779. } else {
  8780. if (botPlayer.latestTail != 0) {
  8781. bot.sendWS("c", 0, 0, 1);
  8782. }
  8783. }
  8784. }
  8785. }
  8786. }
  8787. };
  8788. bot.fastGear = function () {
  8789. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8790. bot.buye(31, 0);
  8791. } else {
  8792. if (botPlayer.moveDir == undefined) {
  8793. bot.buye(22, 0);
  8794. } else {
  8795. if (botPlayer.y2 <= config.snowBiomeTop) {
  8796. bot.buye(15, 0);
  8797. } else {
  8798. bot.buye(12, 0);
  8799. }
  8800. }
  8801. }
  8802. };
  8803. bot.selectWeapon = function(a) {
  8804. packet("G", a, 1);
  8805. }
  8806. function caf(e, t) {
  8807. try {
  8808. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8809. } catch (e) {
  8810. return 0;
  8811. }
  8812. }
  8813. bot.heal = function() {
  8814. if (botPlayer.health < 100) {
  8815. bot.place(0, 0)
  8816. }
  8817. }
  8818. function cdf (e, t){
  8819. try {
  8820. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8821. } catch(e){
  8822. return Infinity;
  8823. }
  8824. }
  8825. let zoon = 'no';
  8826. bot.zync = function(a) {
  8827. if (!botPlayer.millPlace) {
  8828. zoon = 'yeah';
  8829. bot.place(5, caf(botPlayer, a));
  8830. let NextTickLocation = {
  8831. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8832. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8833. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8834. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8835. };
  8836.  
  8837. function calculateDistance(x1, y1, x2, y2) {
  8838. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8839. return distance;
  8840. }
  8841. function dotherezt() {
  8842. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8843. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8844. }
  8845.  
  8846. let aa = setInterval(() => {
  8847. bot.sendWS("G", botPlayer.weapons[1], true);
  8848. if (izauto == 0) {
  8849. bot.sendWS("K", 1);
  8850. izauto = 1;
  8851. }
  8852. setTimeout(() => {
  8853. bot.sendWS("G", botPlayer.weapons[0], true);
  8854. }, 2000);
  8855. bot.buye(53, 0);
  8856. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  8857. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  8858. } else {
  8859. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8860. zoon = 'no';
  8861. bot.sendWS("a", undefined);
  8862. dotherezt();
  8863. clearInterval(aa);
  8864. }
  8865. }, 150);
  8866.  
  8867. setTimeout(() => {
  8868. zoon = 'no';
  8869. clearInterval(aa);
  8870. }, 500);
  8871. }
  8872. };
  8873. bot.onmessage = function(message) {
  8874. let data = new Uint8Array(message.data);
  8875. let parsed = window.msgpack.decode(data);
  8876. let type = parsed[0];
  8877. data = parsed[1];
  8878. if (type == "io-init") {
  8879. bot.spawn();
  8880. }
  8881. if (type == "1") {
  8882. botSID = data[0];
  8883. console.log(botSID)
  8884. }
  8885. if (type == "D") {
  8886. if (data[1]) {
  8887. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8888. botPlayer.setData(data[0]);
  8889. botPlayer.inGame = true;
  8890. botPlayer.alive = true;
  8891. botPlayer.x2 = undefined;
  8892. botPlayer.y2 = undefined;
  8893. botPlayer.spawn(1);
  8894. botPlayer.oldHealth = 100;
  8895. botPlayer.health = 100;
  8896. botPlayer.showName = 'YEAHHH';
  8897. oldXY = {
  8898. x: data[0][3],
  8899. y: data[0][4]
  8900. }
  8901. bD.inGame = true;
  8902. if (bot.first) {
  8903. bot.first = false;
  8904. bots.push(bD);
  8905. }
  8906. }
  8907. }
  8908. if (type == "P") {
  8909. bot.spawn();
  8910. botPlayer.inGame = false;
  8911. bD.inGame = false;
  8912. }
  8913. if (type == "a") {
  8914. let tmpData = data[0];
  8915. botPlayer.tick++;
  8916. botPlayer.enemy = [];
  8917. botPlayer.near = [];
  8918. bot.showName = 'YEAHHH';
  8919. nearObj = [];
  8920. for (let i = 0; i < tmpData.length;) {
  8921. if (tmpData[i] == botPlayer.sid) {
  8922. botPlayer.x2 = tmpData[i + 1];
  8923. botPlayer.y2 = tmpData[i + 2];
  8924. botPlayer.d2 = tmpData[i + 3];
  8925. botPlayer.buildIndex = tmpData[i + 4];
  8926. botPlayer.weaponIndex = tmpData[i + 5];
  8927. botPlayer.weaponVariant = tmpData[i + 6];
  8928. botPlayer.team = tmpData[i + 7];
  8929. botPlayer.isLeader = tmpData[i + 8];
  8930. botPlayer.skinIndex = tmpData[i + 9];
  8931. botPlayer.tailIndex = tmpData[i + 10];
  8932. botPlayer.iconIndex = tmpData[i + 11];
  8933. botPlayer.zIndex = tmpData[i + 12];
  8934. botPlayer.visible = true;
  8935. bD.x2 = botPlayer.x2;
  8936. bD.y2 = botPlayer.y2;
  8937. }
  8938. i += 13;
  8939. }
  8940.  
  8941. for (let i = 0; i < tmpData.length;) {
  8942. tmpObj = findPlayerBySID(tmpData[i]);
  8943. if (tmpObj) {
  8944. if (!tmpObj.isTeam(botPlayer)) {
  8945. enemy.push(tmpObj);
  8946. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8947. nears.push(tmpObj);
  8948. }
  8949. }
  8950. }
  8951. i += 13;
  8952. }
  8953.  
  8954. if (enemy.length) {
  8955. //console.log(enemy)
  8956. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8957. return tmp1.dist2 - tmp2.dist2;
  8958. })[0];
  8959. }
  8960.  
  8961. if (izauto == 1) {
  8962. bot.sendWS("K", 1);
  8963. izauto = 0;
  8964. }
  8965.  
  8966. if (bD.closeSocket) {
  8967. botPlayer.closeSockets(bot);
  8968. }
  8969. if (bD.whyDie != "") {
  8970. botPlayer.whyDieChat(bot, bD.whyDie);
  8971. bD.whyDie = "";
  8972. }
  8973. if (botPlayer.alive) {
  8974. if (player.team) {
  8975. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8976. botPlayer.team && (bot.sendWS("N"));
  8977. bot.sendWS("b", player.team);
  8978. }
  8979. }
  8980.  
  8981. let item = items.list[botPlayer.items[3]];
  8982. let a = botPlayer.itemCounts[item.group.id]
  8983. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8984. if (botPlayer.inGame) {
  8985. bot.sendWS("D", botPlayer.moveDir);
  8986. if (izauto == 0) {
  8987. bot.sendWS("K", 1);
  8988. izauto = 1;
  8989. }
  8990. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8991. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8992. bot.place(3, aim + 7.7);
  8993. bot.place(3, aim - 7.7);
  8994. bot.place(3, aim);
  8995. oldXY = {
  8996. x: botPlayer.x2,
  8997. y: botPlayer.y2
  8998. };
  8999. }
  9000.  
  9001. if (botPlayer.tick % 90 === 0) {
  9002. let rand = Math.random() * Math.PI * 2;
  9003. botPlayer.moveDir = rand;
  9004. bot.sendWS("a", botPlayer.moveDir);
  9005. }
  9006. }
  9007. bot.fastGear();
  9008. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  9009. botPlayer.millPlace = false;
  9010. // bot.sendWS("K", 1);
  9011. bot.fastGear();
  9012. } else {
  9013. if (botPlayer.inGame) {
  9014. if (botObj.length > 0) {
  9015. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  9016. if (getEl("mode").value == 'fuckemup') {
  9017. // if (getEl("mode").value == "clear") {
  9018. bot.selectWeapon(botPlayer.weapons[1]);
  9019. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  9020. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  9021. 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) {
  9022. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9023. })[0];
  9024. if (nearObj) {
  9025. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  9026. if ((gotoDist - isPassed) > 0) {
  9027. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9028. if (botPlayer.moveDir != undefined) {
  9029. botPlayer.moveDir = undefined;
  9030. bot.sendWS("a", botPlayer.moveDir);
  9031. bot.sendWS("D", botPlayer.nDir);
  9032. }
  9033. } else {
  9034. botPlayer.moveDir = gotoAim;
  9035. bot.sendWS("a", botPlayer.moveDir);
  9036. bot.sendWS("D", botPlayer.nDir);
  9037. }
  9038. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9039. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9040. bot.sendWS("D", botPlayer.nDir);
  9041. }
  9042. if (izauto == 0) {
  9043. bot.sendWS("K", 1);
  9044. izauto = 1;
  9045. }
  9046. bot.buye(40, 0);
  9047. } else {
  9048. botPlayer.moveDir = gotoAim;
  9049. bot.sendWS("a", botPlayer.moveDir);
  9050. bot.sendWS("D", botPlayer.nDir);
  9051. bot.fastGear();
  9052. }
  9053. } else {
  9054. botPlayer.moveDir = gotoAim;
  9055. bot.sendWS("a", botPlayer.moveDir);
  9056. bot.sendWS("D", botPlayer.nDir);
  9057. bot.fastGear();
  9058. }
  9059. }
  9060. }
  9061.  
  9062.  
  9063.  
  9064. if (botObj.length > 0) {
  9065. if (getEl("mode").value == 'flex') {
  9066. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  9067. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  9068. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  9069.  
  9070. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  9071.  
  9072. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  9073. if (dist > 22) // 22 is player speed without booster hat
  9074. return;
  9075. }
  9076. }
  9077.  
  9078.  
  9079. if (botObj.length > 0) {
  9080. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  9081. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9082. })[0];
  9083.  
  9084. if (nearObj) {
  9085. if (izauto == 0) {
  9086. bot.sendWS("K", 1);
  9087. izauto = 1;
  9088. }
  9089. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9090. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9091. bot.sendWS("D", botPlayer.nDir);
  9092. }
  9093. bot.buye(40, 0);
  9094. bot.buye(19, 1);
  9095. } else {
  9096. bot.fastGear();
  9097. bot.buye(19, 1);
  9098. }
  9099. bot.buye(19, 1);
  9100. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9101. // if (getEl("mode").value == "clear") {
  9102. bot.selectWeapon(botPlayer.weapons[1]);
  9103. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9104. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9105. 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) {
  9106. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9107. })[0];
  9108. if (nearObj) {
  9109. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9110. if ((gotoDist - isPassed) > 0) {
  9111. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9112. if (botPlayer.moveDir != undefined) {
  9113. botPlayer.moveDir = undefined;
  9114. bot.sendWS("a", botPlayer.moveDir);
  9115. bot.sendWS("D", botPlayer.nDir);
  9116. }
  9117. } else {
  9118. botPlayer.moveDir = gotoAim;
  9119. bot.sendWS("a", botPlayer.moveDir);
  9120. bot.sendWS("D", botPlayer.nDir);
  9121. }
  9122. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9123. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9124. bot.sendWS("D", botPlayer.nDir);
  9125. }
  9126. if (izauto == 0) {
  9127. bot.sendWS("K", 1);
  9128. izauto = 1;
  9129. }
  9130. bot.buye(40, 0);
  9131. bot.fastGear();
  9132. } else {
  9133. botPlayer.moveDir = gotoAim;
  9134. bot.sendWS("a", botPlayer.moveDir);
  9135. bot.sendWS("D", botPlayer.nDir);
  9136. bot.fastGear();
  9137. }
  9138. } else {
  9139. botPlayer.moveDir = gotoAim;
  9140. bot.sendWS("a", botPlayer.moveDir);
  9141. bot.sendWS("D", botPlayer.nDir);
  9142. bot.fastGear();
  9143. }
  9144. if (gotoDist > 300) {
  9145. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9146. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9147. bot.place(3, aim + 7.7);
  9148. bot.place(3, aim - 7.7);
  9149. bot.place(3, aim);
  9150. oldXY = {
  9151. x: botPlayer.x2,
  9152. y: botPlayer.y2
  9153. };
  9154. }
  9155. }
  9156. }
  9157. }
  9158.  
  9159. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9160. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  9161.  
  9162. if(!wdaawdwad.length) {
  9163. if(zoon == 'no')
  9164. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9165. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9166. }
  9167.  
  9168. if(wdaawdwad.length) {
  9169. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9170. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9171. 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) {
  9172. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9173. })[0];
  9174. if (nearObj) {
  9175. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9176. if ((gotoDist - isPassed) > 0) {
  9177. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9178. if (botPlayer.moveDir != undefined) {
  9179. botPlayer.moveDir = undefined;
  9180. bot.sendWS("a", botPlayer.moveDir);
  9181. bot.sendWS("D", botPlayer.nDir);
  9182. }
  9183. } else {
  9184. bot.sendWS("D", botPlayer.nDir);
  9185. }
  9186. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9187. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9188. bot.sendWS("D", botPlayer.nDir);
  9189. }
  9190. if (izauto == 0) {
  9191. bot.sendWS("K", 1);
  9192. izauto = 1;
  9193. }
  9194. bot.buye(40, 0);
  9195. bot.fastGear();
  9196. } else {
  9197. if(zoon == 'no')
  9198. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  9199. if(cdf(player, botPlayer) <= 110)
  9200. bot.sendWS("a", undefined);
  9201. else
  9202. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9203. }
  9204. } else {
  9205. if(wdaawdwad.length) {
  9206. if(zoon == 'no')
  9207. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  9208. if(cdf(player, botPlayer) <= 110)
  9209. bot.sendWS("a", undefined);
  9210. else
  9211. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9212. } else {
  9213. if(zoon == 'no')
  9214. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9215. if(cdf(player, botPlayer) <= 110)
  9216. bot.sendWS("a", undefined);
  9217. else
  9218. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9219. }
  9220. }
  9221. }
  9222. }
  9223. }
  9224. }
  9225. }
  9226. }
  9227. if (type == "H") {
  9228. let tmpData = data[0];
  9229. for (let i = 0; i < tmpData.length;) {
  9230. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9231. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9232. sid: tmpData[i + 7]
  9233. } : null));
  9234. i += 8;
  9235. }
  9236. }
  9237. if (type == "N") {
  9238. let index = data[0];
  9239. let value = data[1];
  9240. if (botPlayer) {
  9241. botPlayer[index] = value;
  9242. }
  9243. }
  9244. if (type == "O") {
  9245. if (data[0] == botPlayer.sid) {
  9246. botPlayer.oldHealth = botPlayer.health;
  9247. botPlayer.health = data[1];
  9248. botPlayer.judgeShame();
  9249. if (botPlayer.oldHealth > botPlayer.health) {
  9250. if (botPlayer.shameCount < 5) {
  9251. for (let i = 0; i < 2; i++) {
  9252. bot.place(0, botPlayer.nDir);
  9253. }
  9254.  
  9255. } else {
  9256. setTimeout(() => {
  9257. for (let i = 0; i < 2; i++) {
  9258. bot.place(0, botPlayer.nDir);
  9259. }
  9260. }, 95);
  9261. }
  9262. }
  9263. }
  9264. }
  9265. if (type == "Q") {
  9266. let sid = data[0];
  9267. botObjManager.disableBySid(sid);
  9268. }
  9269. if (type == "R") {
  9270. let sid = data[0];
  9271. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9272. }
  9273. if (type == "S") {
  9274. let index = data[0];
  9275. let value = data[1];
  9276. if (botPlayer) {
  9277. botPlayer.itemCounts[index] = value;
  9278. }
  9279. }
  9280. if (type == "U") {
  9281. if (data[0] > 0) {
  9282. if(getEl("setup").value == 'dm') {
  9283. if (botPlayer.upgraded == 0) {
  9284. bot.sendUpgrade(7);
  9285. } else if (botPlayer.upgraded == 1) {
  9286. bot.sendUpgrade(17);
  9287. } else if (botPlayer.upgraded == 2) {
  9288. bot.sendUpgrade(31);
  9289. } else if (botPlayer.upgraded == 3) {
  9290. bot.sendUpgrade(23);
  9291. } else if (botPlayer.upgraded == 4) {
  9292. bot.sendUpgrade(9);
  9293. } else if (botPlayer.upgraded == 5) {
  9294. bot.sendUpgrade(34);
  9295. } else if (botPlayer.upgraded == 6) {
  9296. bot.sendUpgrade(12);
  9297. } else if (botPlayer.upgraded == 7) {
  9298. bot.sendUpgrade(15);
  9299. }
  9300. } else if(getEl("setup").value == 'dr') {
  9301. if (botPlayer.upgraded == 0) {
  9302. bot.sendUpgrade(7);
  9303. } else if (botPlayer.upgraded == 1) {
  9304. bot.sendUpgrade(17);
  9305. } else if (botPlayer.upgraded == 2) {
  9306. bot.sendUpgrade(31);
  9307. } else if (botPlayer.upgraded == 3) {
  9308. bot.sendUpgrade(23);
  9309. } else if (botPlayer.upgraded == 4) {
  9310. bot.sendUpgrade(9);
  9311. } else if (botPlayer.upgraded == 5) {
  9312. bot.sendUpgrade(34);
  9313. } else if (botPlayer.upgraded == 6) {
  9314. bot.sendUpgrade(12);
  9315. } else if (botPlayer.upgraded == 7) {
  9316. bot.sendUpgrade(13);
  9317. }
  9318. } else if(getEl("setup").value == 'kh') {
  9319. if (botPlayer.upgraded == 0) {
  9320. bot.sendUpgrade(3);
  9321. } else if (botPlayer.upgraded == 1) {
  9322. bot.sendUpgrade(17);
  9323. } else if (botPlayer.upgraded == 2) {
  9324. bot.sendUpgrade(31);
  9325. } else if (botPlayer.upgraded == 3) {
  9326. bot.sendUpgrade(27);
  9327. } else if (botPlayer.upgraded == 4) {
  9328. bot.sendUpgrade(10);
  9329. } else if (botPlayer.upgraded == 5) {
  9330. bot.sendUpgrade(34);
  9331. } else if (botPlayer.upgraded == 6) {
  9332. bot.sendUpgrade(4);
  9333. } else if (botPlayer.upgraded == 7) {
  9334. bot.sendUpgrade(25);
  9335. }
  9336. } else if(getEl("setup").value == 'zd') {
  9337. if (botPlayer.upgraded == 0) {
  9338. bot.sendUpgrade(3);
  9339. } else if (botPlayer.upgraded == 1) {
  9340. bot.sendUpgrade(17);
  9341. } else if (botPlayer.upgraded == 2) {
  9342. bot.sendUpgrade(31);
  9343. } else if (botPlayer.upgraded == 3) {
  9344. bot.sendUpgrade(27);
  9345. } else if (botPlayer.upgraded == 4) {
  9346. bot.sendUpgrade(9);
  9347. } else if (botPlayer.upgraded == 5) {
  9348. bot.sendUpgrade(34);
  9349. } else if (botPlayer.upgraded == 6) {
  9350. bot.sendUpgrade(12);
  9351. } else if (botPlayer.upgraded == 7) {
  9352. bot.sendUpgrade(15);
  9353. }
  9354. }
  9355. botPlayer.upgraded++;
  9356. }
  9357. }
  9358. if (type == "V") {
  9359. let tmpData = data[0];
  9360. let wpn = data[1];
  9361. if (tmpData) {
  9362. if (wpn) botPlayer.weapons = tmpData;
  9363. else botPlayer.items = tmpData;
  9364. }
  9365.  
  9366. }
  9367. if (type == "5") {
  9368. let type = data[0];
  9369. let id = data[1];
  9370. let index = data[2];
  9371. if (index) {
  9372. if (!type)
  9373. botPlayer.tails[id] = 1;
  9374. else
  9375. botPlayer.latestTail = id;
  9376. } else {
  9377. if (!type)
  9378. botPlayer.skins[id] = 1;
  9379. else
  9380. botPlayer.latestSkin = id;
  9381. }
  9382. }
  9383.  
  9384. if (type == "6") {
  9385. let id = data[0];
  9386. let mzg = data[1]+'';
  9387. if(id == player.sid && mzg.includes("syncon")) {
  9388. bot.zync(botPlayer.near);
  9389. }
  9390. }
  9391. };
  9392. bot.onclose = function() {
  9393. botPlayer.inGame = false;
  9394. bD.inGame = false;
  9395. };
  9396. }
  9397. // RENDER LEAF:
  9398. function renderLeaf(x, y, l, r, ctxt) {
  9399. let endX = x + (l * Math.cos(r));
  9400. let endY = y + (l * Math.sin(r));
  9401. let width = l * 0.4;
  9402. ctxt.moveTo(x, y);
  9403. ctxt.beginPath();
  9404. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  9405. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  9406. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  9407. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  9408. ctxt.closePath();
  9409. ctxt.fill();
  9410. ctxt.stroke();
  9411. }
  9412.  
  9413. // RENDER CIRCLE:
  9414. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9415. tmpContext = tmpContext || mainContext;
  9416. tmpContext.beginPath();
  9417. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9418. if (!dontFill) tmpContext.fill();
  9419. if (!dontStroke) tmpContext.stroke();
  9420. }
  9421.  
  9422. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9423. tmpContext = tmpContext || mainContext;
  9424. tmpContext.beginPath();
  9425. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9426. if (!dontFill) tmpContext.fill();
  9427. if (!dontStroke) tmpContext.stroke();
  9428. }
  9429.  
  9430. // RENDER STAR SHAPE:
  9431. function renderStar(ctxt, spikes, outer, inner) {
  9432. let rot = Math.PI / 2 * 3;
  9433. let x, y;
  9434. let step = Math.PI / spikes;
  9435. ctxt.beginPath();
  9436. ctxt.moveTo(0, -outer);
  9437. for (let i = 0; i < spikes; i++) {
  9438. x = Math.cos(rot) * outer;
  9439. y = Math.sin(rot) * outer;
  9440. ctxt.lineTo(x, y);
  9441. rot += step;
  9442. x = Math.cos(rot) * inner;
  9443. y = Math.sin(rot) * inner;
  9444. ctxt.lineTo(x, y);
  9445. rot += step;
  9446. }
  9447. ctxt.lineTo(0, -outer);
  9448. ctxt.closePath();
  9449. }
  9450.  
  9451. function renderHealthStar(ctxt, spikes, outer, inner) {
  9452. let rot = Math.PI / 2 * 3;
  9453. let x, y;
  9454. let step = Math.PI / spikes;
  9455. ctxt.beginPath();
  9456. ctxt.moveTo(0, -outer);
  9457. for (let i = 0; i < spikes; i++) {
  9458. x = Math.cos(rot) * outer;
  9459. y = Math.sin(rot) * outer;
  9460. ctxt.lineTo(x, y);
  9461. rot += step;
  9462. x = Math.cos(rot) * inner;
  9463. y = Math.sin(rot) * inner;
  9464. ctxt.lineTo(x, y);
  9465. rot += step;
  9466. }
  9467. ctxt.lineTo(0, -outer);
  9468. ctxt.closePath();
  9469. }
  9470.  
  9471. // RENDER RECTANGLE:
  9472. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9473. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9474. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9475. }
  9476.  
  9477. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9478. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9479. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9480. }
  9481.  
  9482. // RENDER RECTCIRCLE:
  9483. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9484. ctxt.save();
  9485. ctxt.translate(x, y);
  9486. seg = Math.ceil(seg / 2);
  9487. for (let i = 0; i < seg; i++) {
  9488. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9489. ctxt.rotate(Math.PI / seg);
  9490. }
  9491. ctxt.restore();
  9492. }
  9493.  
  9494. // RENDER BLOB:
  9495. function renderBlob(ctxt, spikes, outer, inner) {
  9496. let rot = Math.PI / 2 * 3;
  9497. let x, y;
  9498. let step = Math.PI / spikes;
  9499. let tmpOuter;
  9500. ctxt.beginPath();
  9501. ctxt.moveTo(0, -inner);
  9502. for (let i = 0; i < spikes; i++) {
  9503. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9504. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9505. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9506. rot += step * 2;
  9507. }
  9508. ctxt.lineTo(0, -inner);
  9509. ctxt.closePath();
  9510. }
  9511.  
  9512. // RENDER TRIANGLE:
  9513. function renderTriangle(s, ctx) {
  9514. ctx = ctx || mainContext;
  9515. let h = s * (Math.sqrt(3) / 2);
  9516. ctx.beginPath();
  9517. ctx.moveTo(0, -h / 2);
  9518. ctx.lineTo(-s / 2, h / 2);
  9519. ctx.lineTo(s / 2, h / 2);
  9520. ctx.lineTo(0, -h / 2);
  9521. ctx.fill();
  9522. ctx.closePath();
  9523. }
  9524.  
  9525. // PREPARE MENU BACKGROUND:
  9526. function prepareMenuBackground() {
  9527. // let tmpMid = config.mapScale / 2;
  9528. // let attempts = 0;
  9529. // for (let i = 0; i < items.list.length * 3;) {
  9530. // if (attempts >= 1000) break;
  9531. // attempts++;
  9532. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  9533. // let data = {
  9534. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  9535. // y: tmpMid + UTILS.randFloat(-600, 600),
  9536. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9537. // };
  9538. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  9539. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  9540. // } else {
  9541. // continue;
  9542. // }
  9543. // i++;
  9544. // }
  9545. }
  9546.  
  9547.  
  9548. const speed = 1;
  9549. const zZagAmplitude = 10;
  9550. const zZigFrequency = 0.5;
  9551.  
  9552. // RENDER PLAYERS:
  9553. function renderDeadPlayers(xOffset, yOffset) {
  9554. mainContext.fillStyle = "";
  9555. const currentTime = Date.now();
  9556. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9557. if (!dead.startTime) {
  9558. dead.startTime = currentTime;
  9559. dead.angle = 0;
  9560. dead.radius = 0.1;
  9561. }
  9562. const timeElapsed = currentTime - dead.startTime;
  9563. const maxAlpha = 1;
  9564. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9565. dead.animate(delta);
  9566. mainContext.globalAlpha = dead.alpha;
  9567. mainContext.strokeStyle = outlineColor;
  9568. mainContext.save();
  9569. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9570. dead.radius -= 0.001;
  9571. dead.angle += 0.0174533;
  9572. const moveSpeed = speed;
  9573. const zigZagX = zZagAmplitude * Math.sin(timeElapsed * zZigFrequency);
  9574. const zigZagY = zZagAmplitude * Math.cos(timeElapsed * zZigFrequency);
  9575. const x = (dead.radius * Math.cos(dead.angle)) + zigZagX;
  9576. const y = (dead.radius * Math.sin(dead.angle)) + zigZagY;
  9577. dead.x += x * moveSpeed;
  9578. dead.y += y * moveSpeed;
  9579. mainContext.rotate(dead.angle);
  9580. renderDeadPlayer(dead, mainContext);
  9581. mainContext.restore();
  9582. mainContext.fillStyle = "";
  9583. if (timeElapsed >= 3000) {
  9584. dead.active = false;
  9585. dead.startTime = null;
  9586. }
  9587. });
  9588. }
  9589.  
  9590.  
  9591. function renderPlayers(xOffset, yOffset, zIndex) {
  9592. mainContext.globalAlpha = 1;
  9593. mainContext.fillStyle = "";
  9594.  
  9595. mainContext.shadowBlur = 10; // Add this line to enable blur
  9596. mainContext.shadowColor = "rgba(0, 0, 0, 0.9)"; // Optional: set the shadow color
  9597. for (var i = 0; i < players.length; ++i) {
  9598. tmpObj = players[i];
  9599. if (tmpObj.zIndex == zIndex) {
  9600. tmpObj.animate(delta);
  9601. if (tmpObj.visible) {
  9602. tmpObj.skinRot += (0.002 * delta);
  9603. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  9604. mainContext.save();
  9605. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9606. // RENDER PLAYER:
  9607. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9608. renderPlayer(tmpObj, mainContext);
  9609. mainContext.restore();
  9610. }
  9611. }
  9612. }
  9613. mainContext.shadowBlur = 0; // Reset the blur effect
  9614. }
  9615.  
  9616. function renderPlayer(player, context) {
  9617. context.fillStyle = "rgba(145, 178, 219, 0.5)"; // Set the fill color with 50% transparency
  9618. context.fillRect(-player.width / 2, -player.height / 2, player.width, player.height);
  9619. }
  9620. // RENDER DEAD PLAYER:
  9621. function renderDeadPlayer(obj, ctxt) {
  9622. ctxt = ctxt || mainContext;
  9623. ctxt.lineWidth = outlineWidth;
  9624. ctxt.lineJoin = "miter";
  9625. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9626. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9627. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9628.  
  9629. renderTail(obj.tailIndex, ctxt, obj);
  9630. // WEAPON BELLOW HANDS:
  9631. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9632. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9633. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9634. renderProjectile(obj.scale, 0,
  9635. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9636. }
  9637. }
  9638.  
  9639. // HANDS:
  9640. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9641. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9642. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9643. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9644.  
  9645. // WEAPON ABOVE HANDS:
  9646. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9647. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9648. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9649. renderProjectile(obj.scale, 0,
  9650. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9651. }
  9652. }
  9653.  
  9654. // BUILD ITEM:
  9655. if (obj.buildIndex >= 0) {
  9656. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9657. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9658. }
  9659.  
  9660. // BODY:
  9661. renderCircle(0, 0, obj.scale, ctxt);
  9662. ctxt.lineWidth = 2;
  9663. ctxt.fillStyle = "#555";
  9664. ctxt.font = "35px Hammersmith One";
  9665. ctxt.textBaseline = "middle";
  9666. ctxt.textAlign = "center";
  9667.  
  9668. // HATS:
  9669. if (obj.skinIndex > 0 || obj.skinIndex <= 0) {
  9670. ctxt.rotate(Math.PI / 2);
  9671. renderSkin(obj.skinIndex, ctxt, null, obj);
  9672. }
  9673.  
  9674. }
  9675.  
  9676. // RENDER PLAYER:
  9677. function renderPlayer(obj, ctxt) {
  9678. ctxt = ctxt || mainContext;
  9679. ctxt.lineWidth = outlineWidth;
  9680. ctxt.lineJoin = "miter";
  9681. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9682. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9683. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9684.  
  9685. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9686.  
  9687. // TAIL/CAPE:
  9688. if (obj.tailIndex > 0) {
  9689. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  9690. }
  9691.  
  9692. // WEAPON BELLOW HANDS:
  9693. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9694. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9695. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9696. renderProjectile(obj.scale, 0,
  9697. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9698. }
  9699. }
  9700.  
  9701. // HANDS:
  9702. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9703. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9704. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9705. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9706.  
  9707. // WEAPON ABOVE HANDS:
  9708. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9709. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9710. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9711. renderProjectile(obj.scale, 0,
  9712. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9713. }
  9714. }
  9715.  
  9716. // BUILD ITEM:
  9717. if (obj.buildIndex >= 0) {
  9718. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9719. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9720. }
  9721.  
  9722. // BODY:
  9723. renderCircle(0, 0, obj.scale, ctxt);
  9724.  
  9725. // SKIN:
  9726. if (obj.skinIndex > 0) {
  9727. ctxt.rotate(Math.PI / 2);
  9728. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  9729. }
  9730.  
  9731. }
  9732.  
  9733. // RENDER NORMAL SKIN
  9734. var skinSprites2 = {};
  9735. var skinPointers2 = {};
  9736. function renderSkin2(index, ctxt, parentSkin, owner) {
  9737. tmpSkin = skinSprites2[index];
  9738. if (!tmpSkin) {
  9739. var tmpImage = new Image();
  9740. tmpImage.onload = function() {
  9741. this.isLoaded = true;
  9742. this.onload = null;
  9743. };
  9744. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9745. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9746. skinSprites2[index] = tmpImage;
  9747. tmpSkin = tmpImage;
  9748. }
  9749. var tmpObj = parentSkin||skinPointers2[index];
  9750. if (!tmpObj) {
  9751. for (var i = 0; i < hats.length; ++i) {
  9752. if (hats[i].id == index) {
  9753. tmpObj = hats[i];
  9754. break;
  9755. }
  9756. }
  9757. skinPointers2[index] = tmpObj;
  9758. }
  9759. if (tmpSkin.isLoaded)
  9760. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9761. if (!parentSkin && tmpObj.topSprite) {
  9762. ctxt.save();
  9763. ctxt.rotate(owner.skinRot);
  9764. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9765. ctxt.restore();
  9766. }
  9767. }
  9768.  
  9769. // RENDER SKIN:
  9770. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  9771. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  9772. var tmpImage = new Image();
  9773. tmpImage.onload = function() {
  9774. this.isLoaded = true,
  9775. this.onload = null
  9776. }
  9777. ,
  9778. tmpImage.src = setSkinTextureImage(index, "hat", index),
  9779. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9780. tmpSkin = tmpImage
  9781. }
  9782. var tmpObj = parentSkin||skinPointers[index];
  9783. if (!tmpObj) {
  9784. for (var i = 0; i < hats.length; ++i) {
  9785. if (hats[i].id == index) {
  9786. tmpObj = hats[i];
  9787. break;
  9788. }
  9789. }
  9790. skinPointers[index] = tmpObj;
  9791. }
  9792. if (tmpSkin.isLoaded)
  9793. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9794. if (!parentSkin && tmpObj.topSprite) {
  9795. ctxt.save();
  9796. ctxt.rotate(owner.skinRot);
  9797. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9798. ctxt.restore();
  9799. }
  9800. }
  9801.  
  9802. var FlareZHat = {
  9803. 7: "https://i.imgur.com/vAOzlyY.png",
  9804. 15: "https://i.imgur.com/YRQ8Ybq.png",
  9805. 40: "https://i.imgur.com/Xzmg27N.png",
  9806. 26: "https://i.imgur.com/I0xGtyZ.png",
  9807. 55: "https://i.imgur.com/uYgDtcZ.png",
  9808. 20: "https://i.imgur.com/f5uhWCk.png",
  9809. };
  9810.  
  9811. function setSkinTextureImage(id, type, id2) {
  9812. if (true) {
  9813. if(FlareZHat[id] && type == "hat") {
  9814. return FlareZHat[id];
  9815. } else {
  9816. if(type == "acc") {
  9817. return ".././img/accessories/access_" + id + ".png";
  9818. } else if(type == "hat") {
  9819. return ".././img/hats/hat_" + id + ".png";
  9820. } else {
  9821. return ".././img/weapons/" + id + ".png";
  9822. }
  9823. }
  9824. } else {
  9825. if(type == "acc") {
  9826. return ".././img/accessories/access_" + id + ".png";
  9827. } else if(type == "hat") {
  9828. return ".././img/hats/hat_" + id + ".png";
  9829. } else {
  9830. return ".././img/weapons/" + id + ".png";
  9831. }
  9832. }
  9833. }
  9834. // RENDER SKINS:
  9835. let skinSprites = {};
  9836. let skinPointers = {};
  9837. let tmpSkin;
  9838.  
  9839. function renderSkin(index, ctxt, parentSkin, owner) {
  9840. tmpSkin = skinSprites[index];
  9841. if (!tmpSkin) {
  9842. let tmpImage = new Image();
  9843. tmpImage.onload = function() {
  9844. this.isLoaded = true;
  9845. this.onload = null;
  9846. };
  9847. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9848. skinSprites[index] = tmpImage;
  9849. tmpSkin = tmpImage;
  9850. }
  9851. let tmpObj = parentSkin || skinPointers[index];
  9852. if (!tmpObj) {
  9853. for (let i = 0; i < hats.length; ++i) {
  9854. if (hats[i].id == index) {
  9855. tmpObj = hats[i];
  9856. break;
  9857. }
  9858. }
  9859. skinPointers[index] = tmpObj;
  9860. }
  9861. if (tmpSkin.isLoaded)
  9862. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9863. if (!parentSkin && tmpObj.topSprite) {
  9864. ctxt.save();
  9865. ctxt.rotate(owner.skinRot);
  9866. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9867. ctxt.restore();
  9868. }
  9869. }
  9870.  
  9871. // RENDER TAIL:
  9872. var FlareZAcc = {
  9873. 21: "https://i.imgur.com/4ddZert.png",
  9874. 19: "https://i.imgur.com/sULkUZT.png",
  9875. };
  9876. function setTailTextureImage(id, type, id2) {
  9877. if (true) {
  9878. if(FlareZAcc[id] && type == "acc") {
  9879. return FlareZAcc[id];
  9880. } else {
  9881. if(type == "acc") {
  9882. return ".././img/accessories/access_" + id + ".png";
  9883. } else if(type == "hat") {
  9884. return ".././img/hats/hat_" + id + ".png";
  9885. } else {
  9886. return ".././img/weapons/" + id + ".png";
  9887. }
  9888. }
  9889. } else {
  9890. if(type == "acc") {
  9891. return ".././img/accessories/access_" + id + ".png";
  9892. } else if(type == "hat") {
  9893. return ".././img/hats/hat_" + id + ".png";
  9894. } else {
  9895. return ".././img/weapons/" + id + ".png";
  9896. }
  9897. }
  9898. }
  9899. function renderTailTextureImage(index, ctxt, owner) {
  9900. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  9901. var tmpImage = new Image();
  9902. tmpImage.onload = function() {
  9903. this.isLoaded = true,
  9904. this.onload = null
  9905. }
  9906. ,
  9907. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  9908. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9909. tmpSkin = tmpImage;
  9910. }
  9911. var tmpObj = accessPointers[index];
  9912. if (!tmpObj) {
  9913. for (var i = 0; i < accessories.length; ++i) {
  9914. if (accessories[i].id == index) {
  9915. tmpObj = accessories[i];
  9916. break;
  9917. }
  9918. }
  9919. accessPointers[index] = tmpObj;
  9920. }
  9921. if (tmpSkin.isLoaded) {
  9922. ctxt.save();
  9923. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9924. if (tmpObj.spin)
  9925. ctxt.rotate(owner.skinRot);
  9926. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9927. ctxt.restore();
  9928. }
  9929. }
  9930.  
  9931. let accessSprites = {};
  9932. let accessPointers = {};
  9933. var txt = true;
  9934.  
  9935. function renderTail(index, ctxt, owner) {
  9936. tmpSkin = accessSprites[index];
  9937. if (!tmpSkin) {
  9938. let tmpImage = new Image();
  9939. tmpImage.onload = function() {
  9940. this.isLoaded = true;
  9941. this.onload = null;
  9942. };
  9943. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9944. accessSprites[index] = tmpImage;
  9945. tmpSkin = tmpImage;
  9946. }
  9947. let tmpObj = accessPointers[index];
  9948. if (!tmpObj) {
  9949. for (let i = 0; i < accessories.length; ++i) {
  9950. if (accessories[i].id == index) {
  9951. tmpObj = accessories[i];
  9952. break;
  9953. }
  9954. }
  9955. accessPointers[index] = tmpObj;
  9956. }
  9957. if (tmpSkin.isLoaded) {
  9958. ctxt.save();
  9959. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9960. if (tmpObj.spin)
  9961. ctxt.rotate(owner.skinRot);
  9962. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9963. ctxt.restore();
  9964. }
  9965. }
  9966.  
  9967. var accessSprites2 = {};
  9968. var accessPointers2 = {};
  9969. function renderTail2(index, ctxt, owner) {
  9970. tmpSkin = accessSprites2[index];
  9971. if (!tmpSkin) {
  9972. var tmpImage = new Image();
  9973. tmpImage.onload = function() {
  9974. this.isLoaded = true;
  9975. this.onload = null;
  9976. };
  9977. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9978. accessSprites2[index] = tmpImage;
  9979. tmpSkin = tmpImage;
  9980. }
  9981. var tmpObj = accessPointers2[index];
  9982. if (!tmpObj) {
  9983. for (var i = 0; i < accessories.length; ++i) {
  9984. if (accessories[i].id == index) {
  9985. tmpObj = accessories[i];
  9986. break;
  9987. }
  9988. }
  9989. accessPointers2[index] = tmpObj;
  9990. }
  9991. if (tmpSkin.isLoaded) {
  9992. ctxt.save();
  9993. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9994. if (tmpObj.spin)
  9995. ctxt.rotate(owner.skinRot);
  9996. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9997. ctxt.restore();
  9998. }
  9999. }
  10000.  
  10001. // RENDER TOOL:
  10002. let toolSprites = {};
  10003. function renderTool(obj, variant, x, y, ctxt) {
  10004. let tmpSrc = obj.src + (variant || "");
  10005. let tmpSprite = toolSprites[tmpSrc];
  10006. if (!tmpSprite) {
  10007. tmpSprite = new Image();
  10008. tmpSprite.onload = function() {
  10009. this.isLoaded = true;
  10010. }
  10011. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10012. toolSprites[tmpSrc] = tmpSprite;
  10013. }
  10014. if (tmpSprite.isLoaded)
  10015. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  10016. }
  10017.  
  10018. // RENDER PROJECTILES:
  10019. function renderProjectiles(layer, xOffset, yOffset) {
  10020. for (let i = 0; i < projectiles.length; i++) {
  10021. tmpObj = projectiles[i];
  10022. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  10023. tmpObj.update(delta);
  10024. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  10025. mainContext.save();
  10026. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10027. mainContext.rotate(tmpObj.dir);
  10028. renderProjectile(0, 0, tmpObj, mainContext, 1);
  10029. mainContext.restore();
  10030. }
  10031. }
  10032. };
  10033. }
  10034.  
  10035. // RENDER PROJECTILE:
  10036. let projectileSprites = {};//fz iz zexy
  10037.  
  10038. function renderProjectile(x, y, obj, ctxt, debug) {
  10039. if (obj.src) {
  10040. let tmpSrc = items.projectiles[obj.indx].src;
  10041. let tmpSprite = projectileSprites[tmpSrc];
  10042. if (!tmpSprite) {
  10043. tmpSprite = new Image();
  10044. tmpSprite.onload = function() {
  10045. this.isLoaded = true;
  10046. }
  10047. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10048. projectileSprites[tmpSrc] = tmpSprite;
  10049. }
  10050. if (tmpSprite.isLoaded) {
  10051. ctxt.save(); // save the current context state
  10052. ctxt.translate(x, y); // move the origin to the center of the image
  10053. ctxt.rotate(obj.rotation); // rotate the context by the object's rotation
  10054. ctxt.drawImage(tmpSprite, -obj.scale / 2, -obj.scale / 2, obj.scale, obj.scale);
  10055. ctxt.restore(); // restore the original context state
  10056. }
  10057. } else if (obj.indx == 1) {
  10058. ctxt.fillStyle = "#939393";
  10059. renderCircle(x, y, obj.scale, ctxt);
  10060. }
  10061. }
  10062.  
  10063. // RENDER AI:
  10064. let aiSprites = {};
  10065.  
  10066. function renderAI(obj, ctxt) {
  10067. let tmpIndx = obj.index;
  10068. let tmpSprite = aiSprites[tmpIndx];
  10069. if (!tmpSprite) {
  10070. let tmpImg = new Image();
  10071. tmpImg.onload = function() {
  10072. this.isLoaded = true;
  10073. this.onload = null;
  10074. };
  10075. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  10076. tmpSprite = tmpImg;
  10077. aiSprites[tmpIndx] = tmpSprite;
  10078. }
  10079. if (tmpSprite.isLoaded) {
  10080. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  10081. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  10082. }
  10083. }
  10084.  
  10085. // RENDER WATER BODIES:
  10086. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  10087.  
  10088. // MIDDLE RIVER:
  10089. let tmpW = config.riverWidth + padding;
  10090. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  10091. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  10092. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  10093. }
  10094. }
  10095.  
  10096. // RENDER GAME OBJECTS:
  10097. let gameObjectSprites = {};
  10098.  
  10099. function getResSprite(obj) {
  10100. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  10101. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  10102. let tmpSprite = gameObjectSprites[tmpIndex];
  10103. if (!tmpSprite) {
  10104. let blurScale = 6;
  10105. let tmpCanvas = document.createElement("canvas");
  10106. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  10107. let tmpContext = tmpCanvas.getContext('2d');
  10108. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10109. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  10110. tmpContext.strokeStyle = outlineColor;
  10111. tmpContext.lineWidth = outlineWidth;
  10112. tmpContext.shadowBlur = 15; // add this line to enable shadow blur
  10113. tmpContext.shadowColor = outlineColor; // add this line to set the shadow color
  10114. // if (isNight) {
  10115. // tmpContext.shadowBlur = blurScale;
  10116. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  10117. // }
  10118. if (obj.type == 0) {
  10119. let tmpScale;
  10120. let tmpCount = 5;
  10121. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  10122. for (let i = 0; i < 2; ++i) {
  10123. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  10124. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  10125. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  10126. tmpContext.fill();
  10127. if (!i) {
  10128. tmpContext.stroke();
  10129. tmpContext.shadowBlur = null;
  10130. tmpContext.shadowColor = null;
  10131. tmpContext.globalAlpha = 1;
  10132. }
  10133. }
  10134. } else if (obj.type == 1) {
  10135. if (biomeID == 2) {
  10136. tmpContext.fillStyle = "#606060";
  10137. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  10138. tmpContext.fill();
  10139. tmpContext.stroke();
  10140.  
  10141. //tmpContext.shadowBlur = null;
  10142. //tmpContext.shadowColor = null;
  10143.  
  10144. tmpContext.fillStyle = "#89a54c";
  10145. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  10146. tmpContext.fillStyle = "#a5c65b";
  10147. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  10148. } else {
  10149. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  10150. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  10151. tmpContext.fill();
  10152. tmpContext.stroke();
  10153.  
  10154. //tmpContext.shadowBlur = null;
  10155. //tmpContext.shadowColor = null;
  10156.  
  10157. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  10158. let tmpRange;
  10159. let berries = 4;
  10160. let rotVal = (Math.PI * 2) / berries;
  10161. for (let i = 0; i < berries; ++i) {
  10162. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  10163. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10164. UTILS.randInt(10, 12), tmpContext);
  10165. }
  10166. }
  10167. } else if (obj.type == 2 || obj.type == 3) {
  10168. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  10169. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10170. tmpContext.fill();
  10171. tmpContext.stroke();
  10172.  
  10173. tmpContext.shadowBlur = null;
  10174. tmpContext.shadowColor = null;
  10175.  
  10176. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  10177. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10178. tmpContext.fill();
  10179. }
  10180. tmpSprite = tmpCanvas;
  10181. gameObjectSprites[tmpIndex] = tmpSprite;
  10182. }
  10183. return tmpSprite;
  10184. }
  10185. // GET ITEM SPRITE:
  10186. let itemSprites = [];
  10187.  
  10188. function getItemSprite(obj, asIcon) {
  10189. let tmpSprite = itemSprites[obj.id];
  10190. if (!tmpSprite || asIcon) {
  10191. let blurScale = !asIcon ? 20 : 5;
  10192. let tmpCanvas = document.createElement("canvas");
  10193. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  10194. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10195.  
  10196. let tmpContext = tmpCanvas.getContext("2d");
  10197. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10198. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  10199. tmpContext.strokeStyle = outlineColor;
  10200. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  10201. if (!asIcon) {
  10202. tmpContext.shadowBlur = 8;
  10203. tmpContext.shadowColor = "rgba(0, 0, 0, 0.8)";
  10204. }
  10205.  
  10206. if (obj.name == "apple") {
  10207. tmpContext.fillStyle = "#c15555";
  10208. renderCircle(0, 0, obj.scale, tmpContext);
  10209. tmpContext.fillStyle = "#89a54c";
  10210. let leafDir = -(Math.PI / 2);
  10211. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10212. 25, leafDir + Math.PI / 2, tmpContext);
  10213. } else if (obj.name == "cookie") {
  10214. tmpContext.fillStyle = "#cca861";
  10215. renderCircle(0, 0, obj.scale, tmpContext);
  10216. tmpContext.fillStyle = "#937c4b";
  10217. let chips = 4;
  10218. let rotVal = (Math.PI * 2) / chips;
  10219. let tmpRange;
  10220. for (let i = 0; i < chips; ++i) {
  10221. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10222. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10223. UTILS.randInt(4, 5), tmpContext, true);
  10224. }
  10225. } else if (obj.name == "cheese") {
  10226. tmpContext.fillStyle = "#f4f3ac";
  10227. renderCircle(0, 0, obj.scale, tmpContext);
  10228. tmpContext.fillStyle = "#c3c28b";
  10229. let chips = 4;
  10230. let rotVal = (Math.PI * 2) / chips;
  10231. let tmpRange;
  10232. for (let i = 0; i < chips; ++i) {
  10233. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10234. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10235. UTILS.randInt(4, 5), tmpContext, true);
  10236. }
  10237. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10238. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10239. "#a5974c" : "#939393";
  10240. let sides = (obj.name == "castle wall") ? 4 : 3;
  10241. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10242. tmpContext.fill();
  10243. tmpContext.stroke();
  10244. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10245. "#c9b758" : "#bcbcbc";
  10246. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10247. tmpContext.fill();
  10248. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10249. obj.name == "spinning spikes") {
  10250. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10251. let tmpScale = (obj.scale * 0.6);
  10252. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10253. tmpContext.fill();
  10254. tmpContext.stroke();
  10255. tmpContext.fillStyle = "#a5974c";
  10256. renderCircle(0, 0, tmpScale, tmpContext);
  10257. tmpContext.fillStyle = "#c9b758";
  10258. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10259. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10260. tmpContext.fillStyle = "#a5974c";
  10261. renderCircle(0, 0, reScale, tmpContext);
  10262. tmpContext.fillStyle = "#c9b758";
  10263. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10264. tmpContext.fillStyle = "#a5974c";
  10265. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10266. } else if (obj.name == "mine") {
  10267. tmpContext.fillStyle = "#939393";
  10268. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10269. tmpContext.fill();
  10270. tmpContext.stroke();
  10271. tmpContext.fillStyle = "#bcbcbc";
  10272. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10273. tmpContext.fill();
  10274. } else if (obj.name == "sapling") {
  10275. for (let i = 0; i < 2; ++i) {
  10276. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10277. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10278. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10279. tmpContext.fill();
  10280. if (!i) tmpContext.stroke();
  10281. }
  10282. } else if (obj.name == "pit trap") {
  10283. tmpContext.fillStyle = "#a5974c";
  10284. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10285. tmpContext.fill();
  10286. tmpContext.stroke();
  10287. tmpContext.fillStyle = outlineColor;
  10288. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10289. tmpContext.fill();
  10290. } else if (obj.name == "boost pad") {
  10291. tmpContext.fillStyle = "#7e7f82";
  10292. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10293. tmpContext.fill();
  10294. tmpContext.stroke();
  10295. tmpContext.fillStyle = "#dbd97d";
  10296. renderTriangle(obj.scale * 1, tmpContext);
  10297. } else if (obj.name == "turret") {
  10298. tmpContext.fillStyle = "#a5974c";
  10299. renderCircle(0, 0, obj.scale, tmpContext);
  10300. tmpContext.fill();
  10301. tmpContext.stroke();
  10302. tmpContext.fillStyle = "#939393";
  10303. let tmpLen = 50;
  10304. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10305. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10306. tmpContext.fill();
  10307. tmpContext.stroke();
  10308. } else if (obj.name == "platform") {
  10309. tmpContext.fillStyle = "#cebd5f";
  10310. let tmpCount = 4;
  10311. let tmpS = obj.scale * 2;
  10312. let tmpW = tmpS / tmpCount;
  10313. let tmpX = -(obj.scale / 2);
  10314. for (let i = 0; i < tmpCount; ++i) {
  10315. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10316. tmpContext.fill();
  10317. tmpContext.stroke();
  10318. tmpX += tmpS / tmpCount;
  10319. }
  10320. } else if (obj.name == "healing pad") {
  10321. tmpContext.fillStyle = "#7e7f82";
  10322. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10323. tmpContext.fill();
  10324. tmpContext.stroke();
  10325. tmpContext.fillStyle = "#db6e6e";
  10326. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10327. } else if (obj.name == "spawn pad") {
  10328. tmpContext.fillStyle = "#7e7f82";
  10329. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10330. tmpContext.fill();
  10331. tmpContext.stroke();
  10332. tmpContext.fillStyle = "#71aad6";
  10333. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10334. } else if (obj.name == "blocker") {
  10335. tmpContext.fillStyle = "#7e7f82";
  10336. renderCircle(0, 0, obj.scale, tmpContext);
  10337. tmpContext.fill();
  10338. tmpContext.stroke();
  10339. tmpContext.rotate(Math.PI / 4);
  10340. tmpContext.fillStyle = "#db6e6e";
  10341. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10342. } else if (obj.name == "teleporter") {
  10343. tmpContext.fillStyle = "#7e7f82";
  10344. renderCircle(0, 0, obj.scale, tmpContext);
  10345. tmpContext.fill();
  10346. tmpContext.stroke();
  10347. tmpContext.rotate(Math.PI / 4);
  10348. tmpContext.fillStyle = "#d76edb";
  10349. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10350. }
  10351. tmpSprite = tmpCanvas;
  10352. if (!asIcon)
  10353. itemSprites[obj.id] = tmpSprite;
  10354. }
  10355. return tmpSprite;
  10356. }
  10357.  
  10358.  
  10359. function getItemSprite2(obj, tmpX, tmpY) {
  10360. let tmpContext = mainContext;
  10361. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  10362. tmpContext.save();
  10363. tmpContext.translate(tmpX, tmpY);
  10364. tmpContext.rotate(obj.dir);
  10365. tmpContext.strokeStyle = outlineColor;
  10366. tmpContext.lineWidth = outlineWidth;
  10367.  
  10368. // Add blur effect
  10369. tmpContext.shadowBlur = 8;
  10370. tmpContext.shadowColor = "rgba(0, 0, 0, 0.5)";
  10371.  
  10372. if (obj.name == "apple") {
  10373. tmpContext.fillStyle = "#c15555";
  10374. renderCircle(0, 0, obj.scale, tmpContext);
  10375. tmpContext.fillStyle = "#89a54c";
  10376. let leafDir = -(Math.PI / 2);
  10377. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10378. 25, leafDir + Math.PI / 2, tmpContext);
  10379. } else if (obj.name == "cookie") {
  10380. tmpContext.fillStyle = "#cca861";
  10381. renderCircle(0, 0, obj.scale, tmpContext);
  10382. tmpContext.fillStyle = "#937c4b";
  10383. let chips = 4;
  10384. let rotVal = (Math.PI * 2) / chips;
  10385. let tmpRange;
  10386. for (let i = 0; i < chips; ++i) {
  10387. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10388. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10389. UTILS.randInt(4, 5), tmpContext, true);
  10390. }
  10391. } else if (obj.name == "cheese") {
  10392. tmpContext.fillStyle = "#f4f3ac";
  10393. renderCircle(0, 0, obj.scale, tmpContext);
  10394. tmpContext.fillStyle = "#c3c28b";
  10395. let chips = 4;
  10396. let rotVal = (Math.PI * 2) / chips;
  10397. let tmpRange;
  10398. for (let i = 0; i < chips; ++i) {
  10399. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10400. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10401. UTILS.randInt(4, 5), tmpContext, true);
  10402. }
  10403. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10404. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10405. "#a5974c" : "#939393";
  10406. let sides = (obj.name == "castle wall") ? 4 : 3;
  10407. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10408. tmpContext.fill();
  10409. tmpContext.stroke();
  10410. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10411. "#c9b758" : "#bcbcbc";
  10412. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10413. tmpContext.fill();
  10414. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10415. obj.name == "spinning spikes") {
  10416. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10417. let tmpScale = (obj.scale * 0.6);
  10418. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10419. tmpContext.fill();
  10420. tmpContext.stroke();
  10421. tmpContext.fillStyle = "#a5974c";
  10422. renderCircle(0, 0, tmpScale, tmpContext);
  10423. tmpContext.fillStyle = "#c9b758";
  10424. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10425. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10426. tmpContext.fillStyle = "#a5974c";
  10427. renderCircle(0, 0, reScale, tmpContext);
  10428. tmpContext.fillStyle = "#c9b758";
  10429. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10430. tmpContext.fillStyle = "#a5974c";
  10431. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10432. } else if (obj.name == "mine") {
  10433. tmpContext.fillStyle = "#939393";
  10434. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10435. tmpContext.fill();
  10436. tmpContext.stroke();
  10437. tmpContext.fillStyle = "#bcbcbc";
  10438. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10439. tmpContext.fill();
  10440. } else if (obj.name == "sapling") {
  10441. for (let i = 0; i < 2; ++i) {
  10442. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10443. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10444. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10445. tmpContext.fill();
  10446. if (!i) tmpContext.stroke();
  10447. }
  10448. } else if (obj.name == "pit trap") {
  10449. tmpContext.fillStyle = "#a5974c";
  10450. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10451. tmpContext.fill();
  10452. tmpContext.stroke();
  10453. tmpContext.fillStyle = outlineColor;
  10454. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10455. tmpContext.fill();
  10456. } else if (obj.name == "boost pad") {
  10457. tmpContext.fillStyle = "#7e7f82";
  10458. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10459. tmpContext.fill();
  10460. tmpContext.stroke();
  10461. tmpContext.fillStyle = "#dbd97d";
  10462. renderTriangle(obj.scale * 1, tmpContext);
  10463. } else if (obj.name == "turret") {
  10464. tmpContext.fillStyle = "#a5974c";
  10465. renderCircle(0, 0, obj.scale, tmpContext);
  10466. tmpContext.fill();
  10467. tmpContext.stroke();
  10468. tmpContext.fillStyle = "#939393";
  10469. let tmpLen = 50;
  10470. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10471. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10472. tmpContext.fill();
  10473. tmpContext.stroke();
  10474. } else if (obj.name == "platform") {
  10475. tmpContext.fillStyle = "#cebd5f";
  10476. let tmpCount = 4;
  10477. let tmpS = obj.scale * 2;
  10478. let tmpW = tmpS / tmpCount;
  10479. let tmpX = -(obj.scale / 2);
  10480. for (let i = 0; i < tmpCount; ++i) {
  10481. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10482. tmpContext.fill();
  10483. tmpContext.stroke();
  10484. tmpX += tmpS / tmpCount;
  10485. }
  10486. } else if (obj.name == "healing pad") {
  10487. tmpContext.fillStyle = "#7e7f82";
  10488. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10489. tmpContext.fill();
  10490. tmpContext.stroke();
  10491. tmpContext.fillStyle = "#db6e6e";
  10492. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10493. } else if (obj.name == "spawn pad") {
  10494. tmpContext.fillStyle = "#7e7f82";
  10495. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10496. tmpContext.fill();
  10497. tmpContext.stroke();
  10498. tmpContext.fillStyle = "#71aad6";
  10499. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10500. } else if (obj.name == "blocker") {
  10501. tmpContext.fillStyle = "#7e7f82";
  10502. renderCircle(0, 0, obj.scale, tmpContext);
  10503. tmpContext.fill();
  10504. tmpContext.stroke();
  10505. tmpContext.rotate(Math.PI / 4);
  10506. tmpContext.fillStyle = "#db6e6e";
  10507. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10508. } else if (obj.name == "teleporter") {
  10509. tmpContext.fillStyle = "#7e7f82";
  10510. renderCircle(0, 0, obj.scale, tmpContext);
  10511. tmpContext.fill();
  10512. tmpContext.stroke();
  10513. tmpContext.rotate(Math.PI / 4);
  10514. tmpContext.fillStyle = "#d76edb";
  10515. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10516. }
  10517. tmpContext.restore();
  10518. }
  10519.  
  10520. let objSprites = [];
  10521.  
  10522. function getObjSprite(obj) {
  10523. let tmpSprite = objSprites[obj.id];
  10524. if (!tmpSprite) {
  10525. // let blurScale = isNight ? 20 : 0;
  10526. let tmpCanvas = document.createElement("canvas");
  10527. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  10528. let tmpContext = tmpCanvas.getContext("2d");
  10529. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10530. tmpContext.rotate(Math.PI / 2);
  10531. tmpContext.strokeStyle = outlineColor;
  10532. tmpContext.lineWidth = outlineWidth;
  10533. // if (isNight) {
  10534. // tmpContext.shadowBlur = 20;
  10535. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10536. // }
  10537. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10538. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  10539. let tmpScale = obj.scale * 0.6;
  10540. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10541. tmpContext.fill();
  10542. tmpContext.stroke();
  10543. tmpContext.fillStyle = "#a5974c";
  10544. renderCircle(0, 0, tmpScale, tmpContext);
  10545. tmpContext.fillStyle = "#cc5151";
  10546. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10547. } else if (obj.name == "pit trap") {
  10548. tmpContext.fillStyle = "#a5974c";
  10549. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10550. tmpContext.fill();
  10551. tmpContext.stroke();
  10552. tmpContext.fillStyle = "#cc5151";
  10553. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10554. tmpContext.fill();
  10555. }
  10556. tmpSprite = tmpCanvas;
  10557. objSprites[obj.id] = tmpSprite;
  10558. }
  10559. return tmpSprite;
  10560. }
  10561.  
  10562.  
  10563.  
  10564. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10565. tmpContext.lineWidth = 0.9;
  10566. tmpContext.globalAlpha = 2;
  10567. tmpContext.strokeStyle = "black";
  10568. tmpContext.save();
  10569. tmpContext.translate(tmpX, tmpY);
  10570. tmpContext.rotate(obj.dir);
  10571.  
  10572. if (obj.name === "wood wall" || obj.name === "stone wall" || obj.name === "castle wall") {
  10573. let sides = obj.name === "castle wall"? 4 : 3;
  10574. renderHealthStar(tmpContext, sides, obj.scale, obj.scale);
  10575. tmpContext.stroke();
  10576. } else if (obj.name === "spikes" || obj.name === "greater spikes" || obj.name === "poison spikes" || obj.name === "spinning spikes") {
  10577. // Flashy spike sprite
  10578. let flashTime = Date.now() % 200; // faster flash
  10579. let flashAlpha = Math.sin(flashTime / 20) * 0.5 + 0.5; // increased amplitude for more dramatic flash
  10580.  
  10581. tmpContext.fillStyle = "rgba(255, 0, 0, ${0.7 + flashAlpha})"; // red fill with 50% transparency
  10582.  
  10583. tmpContext.beginPath();
  10584. tmpContext.arc(0, 0, obj.scale * 1.05, 0, 2 * Math.PI);
  10585. tmpContext.fill();
  10586. tmpContext.stroke();
  10587.  
  10588.  
  10589. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10590. tmpContext.fillStyle = "#a5974c";
  10591. renderCircle(0, 0, obj.scale, tmpContext);
  10592. tmpContext.fillStyle = "#c9b758";
  10593. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10594. tmpContext.fillStyle = "#a5974c";
  10595. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10596. } else if (obj.name === "mine" || obj.name === "pit trap") {
  10597. tmpContext.fillStyle = "rgba(137, 207, 240, 0.5)";
  10598. tmpContext.beginPath();
  10599. tmpContext.arc(0, 0, obj.scale * 1.05, 0, 2 * Math.PI);
  10600. tmpContext.fill();
  10601. tmpContext.stroke();
  10602. } else if (obj.name === "sapling") {
  10603. let tmpScale = obj.scale * 0.7;
  10604. renderHealthStar(tmpContext, 7, obj.scale, tmpScale);
  10605. tmpContext.stroke();
  10606. } else if (obj.name === "boost pad") {
  10607. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10608. } else if (obj.name === "turret") {
  10609. tmpContext.fillStyle = "rgba(0, 0, 255, 0.5)";
  10610. tmpContext.beginPath();
  10611. tmpContext.arc(0, 0, obj.scale * 1.05, 0, 2 * Math.PI);
  10612. tmpContext.fill();
  10613. tmpContext.stroke();
  10614. } else if (obj.name === "platform") {
  10615. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10616. } else if (obj.name === "healing pad") {
  10617. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10618. } else if (obj.name === "spawn pad") {
  10619. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10620. } else if (obj.name === "blocker") {
  10621. tmpContext.fillStyle = "rgba(0, 0, 255, 0.5)";
  10622. tmpContext.beginPath();
  10623. tmpContext.arc(0, 0, obj.scale * 1.05, 0, 2 * Math.PI);
  10624. tmpContext.fill();
  10625. tmpContext.stroke();
  10626. } else if (obj.name === "teleporter") {
  10627. tmpContext.fillStyle = "rgba(0, 0, 255, 0.5)";
  10628. tmpContext.beginPath();
  10629. tmpContext.arc(0, 0, obj.scale * 1.05, 0, 2 * Math.PI);
  10630. tmpContext.fill(); // Fill the circle
  10631. tmpContext.stroke(); // Draw very thin black outline
  10632. } else {
  10633. tmpContext.fillStyle = "rgba(255, 255, 255, 0.5)";
  10634. tmpContext.beginPath();
  10635. tmpContext.arc(0, 0, obj.scale * 1.05, 0, 2 * Math.PI); // Increase circle radius by 5%
  10636. tmpContext.fill(); // Fill the circle
  10637. tmpContext.stroke(); // Draw very thin black outline
  10638. }
  10639. tmpContext.restore();
  10640. }
  10641.  
  10642. // OBJECT ON SCREEN:
  10643. function isOnScreen(x, y, s) {
  10644. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10645. s,
  10646. maxScreenHeight));
  10647. }
  10648.  
  10649. // RENDER GAME OBJECTS:
  10650. function renderGameObjects(layer, xOffset, yOffset) {
  10651. let tmpSprite;
  10652. let tmpX;
  10653. let tmpY;
  10654. liztobj.forEach((tmp) => {
  10655. tmpObj = tmp;
  10656. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  10657. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  10658. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  10659. if (layer == 0) {
  10660. tmpObj.update(delta);
  10661. }
  10662. if (getEl("mode").value == 'radiusclear' && cdf(tmpObj, player) <= 600 && tmpObj.isItem) {
  10663. mainContext.globalAlpha = tmpObj.alpha/2;
  10664. } else {
  10665. mainContext.globalAlpha = tmpObj.alpha;
  10666. }
  10667. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  10668. if (tmpObj.isItem) {
  10669. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  10670. tmpSprite = getObjSprite(tmpObj);
  10671. } else {
  10672. tmpSprite = getItemSprite(tmpObj);
  10673. }
  10674.  
  10675. mainContext.save();
  10676. mainContext.translate(tmpX, tmpY);
  10677. mainContext.rotate(tmpObj.dir);
  10678. if (!tmpObj.active) {
  10679. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  10680. }
  10681. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  10682.  
  10683. if (tmpObj.blocker) {
  10684. mainContext.strokeStyle = "#db6e6e";
  10685. mainContext.globalAlpha = 0.3;
  10686. mainContext.lineWidth = 6;
  10687. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  10688. }
  10689. mainContext.restore();
  10690. } else {
  10691. renderResTest(tmpObj, tmpX, tmpY)
  10692. tmpSprite = getResSprite(tmpObj);
  10693. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  10694. }
  10695. }
  10696. if (layer == 3 && player && tmpObj.active && tmpObj.health > 0) {
  10697. if (cdf(player, tmpObj) < 200) {
  10698. // HEALTH HOLDER:
  10699. mainContext.fillStyle = darkOutlineColor;
  10700. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  10701. mainContext.fill();
  10702.  
  10703. // HEALTH BAR:
  10704. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#3992bf" : "#993d3d";
  10705. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  10706. mainContext.fill();
  10707.  
  10708. mainContext.shadowBlur = 0;
  10709. mainContext.shadowOffsetY = 0;
  10710. }
  10711. // PLAYER SID OWNER
  10712. mainContext.globalAlpha = 1;
  10713. mainContext.font = `700 ${tmpObj.IsPlayer ? 15 : 14}px Neuton`;
  10714. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#cfd6ff" : "#C12D5F";
  10715. mainContext.textBaseline = "middle";
  10716. mainContext.textAlign = "center";
  10717. mainContext.strokeStyle = "#000";
  10718. mainContext.lineWidth = 5;
  10719. mainContext.lineJoin = "round";
  10720. mainContext.strokeText(tmpObj.owner.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset + 20));
  10721. mainContext.fillText(tmpObj.owner.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset + 20));
  10722.  
  10723. }
  10724.  
  10725. }
  10726. });
  10727.  
  10728.  
  10729. // PLACE VISIBLE:
  10730. if (layer == 0) {
  10731. if (placeVisible.length) {
  10732. placeVisible.forEach((places) => {
  10733. tmpX = places.x - xOffset;
  10734. tmpY = places.y - yOffset;
  10735. markObject(places, tmpX, tmpY);
  10736. });
  10737. }
  10738. }
  10739. }
  10740.  
  10741. let treeAlphaState = [];
  10742. function renderResTest(y, n, r, offsets) {
  10743. let s = getResSprite(y);
  10744. let easeScale = 0.06, lowestAlpha = 0.2;
  10745. if (player && y.type === 0 && configs.treealpha) {
  10746. if (!treeAlphaState[y.sid]) treeAlphaState[y.sid] = 1;
  10747. if (Math.hypot(y.y - player.y2, y.x - player.x2) <= y.scale + player.scale) {
  10748. treeAlphaState[y.sid] = Math.max(lowestAlpha, (treeAlphaState[y.sid] - easeScale));
  10749. mainContext.globalAlpha = treeAlphaState[y.sid];
  10750. } else {
  10751. treeAlphaState[y.sid] = Math.min(1, (treeAlphaState[y.sid] + easeScale));
  10752. mainContext.globalAlpha = treeAlphaState[y.sid];
  10753. };
  10754. }
  10755. mainContext.drawImage(s, n - s.width / 2, r - s.height / 2);
  10756. }
  10757.  
  10758. function markObject(tmpObj, tmpX, tmpY) {
  10759. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10760. }
  10761.  
  10762.  
  10763. // RENDER MINIMAP:
  10764. class MapPing {
  10765. constructor(color, scale) {
  10766. this.init = function(x, y) {
  10767. this.scale = 0;
  10768. this.x = x;
  10769. this.y = y;
  10770. this.active = true;
  10771. };
  10772. this.update = function(ctxt, delta) {
  10773. if (this.active) {
  10774. this.scale += 0.05 * delta;
  10775. if (this.scale >= scale) {
  10776. this.active = false;
  10777. } else {
  10778. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10779. ctxt.beginPath();
  10780. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  10781. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10782. ctxt.stroke();
  10783. }
  10784. }
  10785. };
  10786. this.color = color;
  10787. }
  10788. }
  10789.  
  10790. function pingMap(x, y) {
  10791. tmpPing = mapPings.find(pings => !pings.active);
  10792. if (!tmpPing) {
  10793. tmpPing = new MapPing("#fff", config.mapPingScale);
  10794. mapPings.push(tmpPing);
  10795. }
  10796. tmpPing.init(x, y);
  10797. }
  10798.  
  10799. function updateMapMarker() {
  10800. mapMarker.x = player.x;
  10801. mapMarker.y = player.y;
  10802. }
  10803.  
  10804. function renderMinimap(delta) {
  10805. if (player && player.alive) {
  10806. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10807.  
  10808. // RENDER PINGS:
  10809. mapContext.lineWidth = 4;
  10810. for (let i = 0; i < mapPings.length; ++i) {
  10811. tmpPing = mapPings[i];
  10812. mapContext.strokeStyle = tmpPing.color;
  10813. tmpPing.update(mapContext, delta);
  10814. }
  10815.  
  10816.  
  10817.  
  10818. // RENDER PLAYERS:
  10819. mapContext.globalAlpha = 1;
  10820. mapContext.fillStyle = "#fff";
  10821. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10822. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10823. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10824. if (player.team && minimapData) {
  10825. for (let i = 0; i < minimapData.length;) {
  10826. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10827. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10828. i += 2;
  10829. }
  10830. }
  10831.  
  10832. // RENDER BOTS:
  10833. if (bots.length) {
  10834. bots.forEach((tmp) => {
  10835. if (tmp.inGame) {
  10836. mapContext.globalAlpha = 1;
  10837. mapContext.strokeStyle = "#cc5151";
  10838. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10839. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10840. }
  10841. });
  10842. }
  10843.  
  10844.  
  10845.  
  10846.  
  10847.  
  10848.  
  10849. // DEATH LOCATION:
  10850. if (lastDeath) {
  10851. mapContext.fillStyle = "#fc5553";
  10852. mapContext.font = "34px Hammersmith One";
  10853. mapContext.textBaseline = "middle";
  10854. mapContext.textAlign = "center";
  10855. mapContext.fillText(":(", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10856. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10857. }
  10858.  
  10859. // MAP MARKER:
  10860. if (mapMarker) {
  10861. mapContext.fillStyle = "#fff";
  10862. mapContext.font = "34px Hammersmith One";
  10863. mapContext.textBaseline = "middle";
  10864. mapContext.textAlign = "center";
  10865. mapContext.fillText("o", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10866. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10867. }
  10868. }
  10869. }
  10870.  
  10871. // ICONS:
  10872. let crossHairs = ["https://media.discordapp.net/attachments/996705078083866664/1109850802895458334/crosshairinev.png?ex=66b0e21b&is=66af909b&hm=f7dea51f9a11bb8f415e05b97a42568418af18426d13d73d3f421354cbb92f61&=&format=webp&quality=lossless&width=411&height=411", "https://media.discordapp.net/attachments/996705078083866664/1109850802895458334/crosshairinev.png?ex=66b0e21b&is=66af909b&hm=f7dea51f9a11bb8f415e05b97a42568418af18426d13d73d3f421354cbb92f61&=&format=webp&quality=lossless&width=411&height=411"];
  10873.  
  10874. let crossHairSprites = {};
  10875. let iconSprites = {};
  10876. let icons = ["crown", "skull"];
  10877.  
  10878. function loadIcons() {
  10879. for (let i = 0; i < icons.length; ++i) {
  10880. let tmpSprite = new Image();
  10881. tmpSprite.onload = function() {
  10882. this.isLoaded = true;
  10883. };
  10884. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10885. iconSprites[icons[i]] = tmpSprite;
  10886. }
  10887. for (let i = 0; i < crossHairs.length; ++i) {
  10888. let tmpSprite = new Image();
  10889. tmpSprite.onload = function() {
  10890. this.isLoaded = true;
  10891. };
  10892. tmpSprite.src = crossHairs[i];
  10893. crossHairSprites[i] = tmpSprite;
  10894. }
  10895. }
  10896. loadIcons();
  10897.  
  10898. function cdf (e, t){
  10899. try {
  10900. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  10901. } catch(e){
  10902. return Infinity;
  10903. }
  10904. }
  10905.  
  10906.  
  10907. // UPDATE GAME:
  10908. function updateGame() {
  10909. if(gameObjects.length && inGame) {
  10910. gameObjects.forEach((tmp) => {
  10911. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  10912. if(!liztobj.includes(tmp)) {
  10913. liztobj.push(tmp);
  10914. tmp.render = true;
  10915. }
  10916. } else {
  10917. if(liztobj.includes(tmp)) {
  10918. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10919. tmp.render = false;
  10920. const index = liztobj.indexOf(tmp);
  10921. if (index > -1) { // only splice array when item is found
  10922. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10923. }
  10924. }
  10925. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10926. tmp.render = false;
  10927. const index = liztobj.indexOf(tmp);
  10928. if (index > -1) { // only splice array when item is found
  10929. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10930. }
  10931. } else {
  10932. tmp.render = false;
  10933. const index = liztobj.indexOf(tmp);
  10934. if (index > -1) { // only splice array when item is found
  10935. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10936. }
  10937. }
  10938. }
  10939. })
  10940. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10941. }
  10942.  
  10943. // if (config.resetRender) {
  10944. mainContext.beginPath();
  10945. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10946. // }
  10947. mainContext.globalAlpha = 1;
  10948.  
  10949. // MOVE CAMERA:
  10950. if (player) {
  10951. if (false) {
  10952. camX = player.x;
  10953. camY = player.y;
  10954. } else {
  10955. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10956. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10957. let camSpd = Math.min(tmpDist * 5 * delta, tmpDist);
  10958. if (tmpDist > 5) {
  10959. camX += camSpd * Math.cos(tmpDir);
  10960. camY += camSpd * Math.sin(tmpDir);
  10961. } else {
  10962. camX = player.x;
  10963. camY = player.y;
  10964. }
  10965. }
  10966. } else {
  10967. camX = config.mapScale / 2 + config.riverWidth;
  10968. camY = config.mapScale / 2;
  10969. }
  10970.  
  10971. // INTERPOLATE PLAYERS AND AI:
  10972. let lastTime = now - (1000 / config.serverUpdateRate);
  10973. let tmpDiff;
  10974. for (let i = 0; i < players.length + ais.length; ++i) {
  10975. tmpObj = players[i] || ais[i - players.length];
  10976. if (tmpObj && tmpObj.visible) {
  10977. if (tmpObj.forcePos) {
  10978. tmpObj.x = tmpObj.x2;
  10979. tmpObj.y = tmpObj.y2;
  10980. tmpObj.dir = tmpObj.d2;
  10981. } else {
  10982. let total = tmpObj.t2 - tmpObj.t1;
  10983. let fraction = lastTime - tmpObj.t1;
  10984. let ratio = (fraction / total);
  10985. let rate = 170;
  10986. tmpObj.dt += delta;
  10987. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10988. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10989. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10990. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10991. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10992. if (config.anotherVisual) {
  10993. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10994. } else {
  10995. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10996. }
  10997. }
  10998. }
  10999. }
  11000.  
  11001. // RENDER CORDS:
  11002. let xOffset = camX - (maxScreenWidth / 2);
  11003. let yOffset = camY - (maxScreenHeight / 2);
  11004.  
  11005. // RENDER BACKGROUND:
  11006. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11007. mainContext.fillStyle = "#b6db66";
  11008. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11009. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  11010. mainContext.fillStyle = "#dbc666";
  11011. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11012. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11013. mainContext.fillStyle = "#fff";
  11014. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11015. } else if (config.snowBiomeTop - yOffset >= 0) {
  11016. mainContext.fillStyle = "#fff";
  11017. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  11018. mainContext.fillStyle = "#b6db66";
  11019. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  11020. maxScreenHeight - (config.snowBiomeTop - yOffset));
  11021. } else {
  11022. mainContext.fillStyle = "#b6db66";
  11023. mainContext.fillRect(0, 0, maxScreenWidth,
  11024. (config.mapScale - config.snowBiomeTop - yOffset));
  11025. mainContext.fillStyle = "#dbc666";
  11026. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  11027. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  11028. }
  11029. if (getEl("visualType").value != "ueh1") {
  11030. // RENDER GRID:
  11031. mainContext.lineWidth = 4;
  11032. mainContext.strokeStyle = "#000";
  11033. mainContext.globalAlpha = 0.06;
  11034. mainContext.beginPath();
  11035. for (let x = -camX; x < maxScreenWidth; x += getEl("visualType").value === "ueh" ? 30 : 60) {
  11036. if (x > 0) {
  11037. mainContext.moveTo(x, 0);
  11038. mainContext.lineTo(x, maxScreenHeight);
  11039. }
  11040. }
  11041. for (let y = -camY; y < maxScreenHeight; y += getEl("visualType").value === "ueh" ? 30 : 60) {
  11042. if (y > 0) {
  11043. mainContext.moveTo(0, y);
  11044. mainContext.lineTo(maxScreenWidth, y);
  11045. }
  11046. }
  11047. mainContext.stroke();
  11048.  
  11049. }
  11050. // RENDER WATER AREAS:
  11051. if (!firstSetup) {
  11052. waterMult += waterPlus * config.waveSpeed * delta;
  11053. if (waterMult >= config.waveMax) {
  11054. waterMult = config.waveMax;
  11055. waterPlus = -1;
  11056. } else if (waterMult <= 1) {
  11057. waterMult = waterPlus = 1;
  11058. }
  11059. mainContext.globalAlpha = 1;
  11060. mainContext.fillStyle = "#dbc666";
  11061. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  11062. mainContext.fillStyle = "#91b2db";
  11063. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  11064. }
  11065.  
  11066. // RENDER DEAD PLAYERS:
  11067. mainContext.globalAlpha = 1;
  11068. mainContext.strokeStyle = outlineColor;
  11069. renderDeadPlayers(xOffset, yOffset);
  11070.  
  11071. // RENDER BOTTOM LAYER:
  11072. mainContext.globalAlpha = 1;
  11073. mainContext.strokeStyle = outlineColor;
  11074. renderGameObjects(-1, xOffset, yOffset);
  11075.  
  11076. // RENDER PROJECTILES:
  11077. mainContext.globalAlpha = 1;
  11078. mainContext.lineWidth = outlineWidth;
  11079. renderProjectiles(0, xOffset, yOffset);
  11080.  
  11081. // RENDER PLAYERS:
  11082. renderPlayers(xOffset, yOffset, 0);
  11083.  
  11084. // RENDER AI:
  11085. mainContext.globalAlpha = 1;
  11086. for (let i = 0; i < ais.length; ++i) {
  11087. tmpObj = ais[i];
  11088. if (tmpObj.active && tmpObj.visible) {
  11089. tmpObj.animate(delta);
  11090. mainContext.save();
  11091. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11092. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  11093. renderAI(tmpObj, mainContext);
  11094. mainContext.restore();
  11095. }
  11096. }
  11097.  
  11098.  
  11099. // RENDER GAME OBJECTS (LAYERED):
  11100. renderGameObjects(0, xOffset, yOffset);
  11101. renderProjectiles(1, xOffset, yOffset);
  11102. renderGameObjects(1, xOffset, yOffset);
  11103. renderPlayers(xOffset, yOffset, 1);
  11104. renderGameObjects(2, xOffset, yOffset);
  11105. renderGameObjects(3, xOffset, yOffset);
  11106.  
  11107. // MAP BOUNDARIES:
  11108. mainContext.fillStyle = "#000";
  11109. mainContext.globalAlpha = 0.09;
  11110. if (xOffset <= 0) {
  11111. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  11112. }
  11113. if (config.mapScale - xOffset <= maxScreenWidth) {
  11114. let tmpY = Math.max(0, -yOffset);
  11115. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  11116. }
  11117. if (yOffset <= 0) {
  11118. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  11119. }
  11120. if (config.mapScale - yOffset <= maxScreenHeight) {
  11121. let tmpX = Math.max(0, -xOffset);
  11122. let tmpMin = 0;
  11123. if (config.mapScale - xOffset <= maxScreenWidth)
  11124. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  11125. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  11126. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  11127. }
  11128.  
  11129. // RENDER DAY/NIGHT TIME:
  11130. mainContext.globalAlpha = 1;
  11131. if (!getEl("novisu").checked) {
  11132. mainContext.fillStyle = "rgba(0, 0, 139, 0.4)";
  11133. } else {
  11134. mainContext.fillStyle = "rgba(0, 0, 70, " + dayCycle + ")";
  11135.  
  11136. }
  11137. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11138.  
  11139. // RENDER PLAYER AND AI UI:
  11140. mainContext.strokeStyle = darkOutlineColor;
  11141. mainContext.globalAlpha = 1;
  11142. let crossHair = true;
  11143. for (let i = 0; i < players.length + ais.length; ++i) {
  11144. tmpObj = players[i] || ais[i - players.length];
  11145. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  11146. mainContext.strokeStyle = darkOutlineColor;
  11147.  
  11148. // NAME AND HEALTH:
  11149.  
  11150. // let izbot = false;
  11151.  
  11152. // bots.forEach((bot) => {
  11153. // if (tmpObj.sid == bot.sid) izbot = true
  11154. // else izbot = false;
  11155. // });
  11156.  
  11157.  
  11158.  
  11159. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") +(tmpObj.name || "") + (getEl("novisu").checked ? " <" + tmpObj.shameCount + "/8" + ">" : "");
  11160.  
  11161.  
  11162. if (tmpText != "" && tmpObj.name != "onichan :3") {
  11163. // bots.forEach((bot) => {
  11164. // if (tmpObj.sid == bot.sid) return;
  11165. // });
  11166.  
  11167. mainContext.font = (getEl("novisu").checked ? (tmpObj.nameScale || 30) + "px Arial Sans Serif" : (tmpObj.nameScale || 15) + "px Hammersmith");
  11168. mainContext.fillStyle = "#fff";
  11169. mainContext.textBaseline = "middle";
  11170. mainContext.textAlign = "under";
  11171. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11172. mainContext.lineJoin = "round";
  11173. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11174. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11175. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  11176. let tmpS = config.crownIconScale;
  11177. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  11178. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11179. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11180. }
  11181. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  11182. let tmpS = config.crownIconScale;
  11183. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  11184. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11185. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11186. }
  11187. if (tmpObj.isPlayer && instaC.wait && crossHair && near == tmpObj && (crossHair ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length) {
  11188. let tmpS = tmpObj.scale * 2.2;
  11189. mainContext.drawImage((crossHair ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11190. }
  11191.  
  11192.  
  11193. // izbot = false;
  11194. }
  11195. // PLAYER TARGET WEAPON:
  11196. if (tmpObj.isPlayer) {
  11197. if(getEl("novisu").checked) {
  11198. mainContext.save();
  11199. mainContext.beginPath();
  11200. mainContext.lineWidth = 6;
  11201. mainContext.lineCap = "round";
  11202. mainContext.globalAlpha = 0.1;
  11203. mainContext.fillStyle = (tmpObj.reloads[tmpObj.weaponIndex] == 0 ? "#fff" : "#ff0000");
  11204. mainContext.strokeStyle = (tmpObj.reloads[tmpObj.weapons] == 0 ? "#fff" : "#ff0000");
  11205. if(tmpObj.weaponIndex == 11) {
  11206. mainContext.arc(tmpObj.x - xOffset, tmpObj.y - yOffset, 250, tmpObj.dir - config.shieldAngle, tmpObj.dir + config.shieldAngle);
  11207. } else if ((tmpObj.weaponIndex > 11 || tmpObj.weaponIndex == 9) && tmpObj.weaponIndex != 14) {
  11208. var weaponXY = {
  11209. x: tmpObj.x + 1111 * Math.cos(tmpObj.dir),
  11210. y: tmpObj.y + 1111 * Math.sin(tmpObj.dir)
  11211. };
  11212. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11213. mainContext.lineTo(weaponXY.x - xOffset, weaponXY.y - yOffset);
  11214. } else if (tmpObj.weaponIndex == 14) {
  11215. mainContext.arc(tmpObj.x - xOffset, tmpObj.y - yOffset, 115, tmpObj.dir - Math.PI/2.6, tmpObj.dir + Math.PI/2.6);
  11216. } else {
  11217. mainContext.arc(tmpObj.x - xOffset, tmpObj.y - yOffset, items.weapons[tmpObj.weaponIndex].range + 35, tmpObj.dir - Math.PI/2.6, tmpObj.dir + Math.PI/2.6);
  11218. }
  11219. mainContext.stroke();
  11220. mainContext.restore();
  11221. }
  11222. }
  11223. if (tmpObj.isPlayer) {
  11224. if (getEl("novisu").checked) {
  11225. var tmpWidth = config.healthBarWidth;
  11226. mainContext.fillStyle = darkOutlineColor;
  11227. mainContext.roundRect(tmpObj.x - xOffset - 50.5 - config.healthBarPad, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13, 1.3 * 24.9 + 2 * config.healthBarPad, 12, 10); // Altura reduzida de 17 para 12
  11228. mainContext.fill();
  11229. mainContext.fillStyle = (tmpObj.team == player.team) ? "#85b853" : "#cc5151";
  11230. mainContext.roundRect(tmpObj.x - xOffset - 50.5, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13 + config.healthBarPad, 1.3 * 25 * (tmpObj.reloads[tmpObj.primaryIndex] == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)), 12 - 2 * config.healthBarPad, 10); // Altura reduzida de 17 para 12
  11231. mainContext.fill();
  11232. mainContext.fillStyle = darkOutlineColor;
  11233. mainContext.roundRect(tmpObj.x - xOffset + 17.6 - config.healthBarPad, tmpObj.y - yOffset + 0.2 + tmpObj.scale + config.nameY - 13, 1.3 * 24.9 + 2 * config.healthBarPad, 12, 10); // Altura reduzida de 16 para 12
  11234. mainContext.fill();
  11235. mainContext.fillStyle = (tmpObj.team == player.team) ? "#85b853" : "#cc5151";
  11236. mainContext.roundRect(tmpObj.x - xOffset + 17.6, tmpObj.y - yOffset + 0.2 + tmpObj.scale + config.nameY - 13 + config.healthBarPad, 1.3 * 25 * (tmpObj.reloads[tmpObj.secondaryIndex] == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)), 12 - 2 * config.healthBarPad, 9); // Altura reduzida de 17 para 12, altura interna para 9
  11237. mainContext.fill();
  11238. mainContext.fillStyle = darkOutlineColor;
  11239. mainContext.roundRect(tmpObj.x - xOffset - 15.1 - config.healthBarPad, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13, 1.2 * 24.9 + 2 * config.healthBarPad, 12, 10); // Altura reduzida de 16 para 12
  11240. mainContext.fill();
  11241. mainContext.fillStyle = (tmpObj.team == player.team) ? "#85b853" : "#cc5151";
  11242. mainContext.roundRect(tmpObj.x - xOffset - 15.1, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13 + config.healthBarPad, 1.2 * 25 * (!tmpObj.reloads[53] ? 1 : ((2500 - tmpObj.reloads[53]) / 2500)), 12 - 2 * config.healthBarPad, 9); // Altura reduzida de 17 para 12, altura interna para 9
  11243. mainContext.fill();
  11244. }
  11245. }
  11246.  
  11247. if (tmpObj.health > 0) {
  11248.  
  11249. if(tmpObj.name != "onichan :3") {
  11250. // HEALTH HOLDER:
  11251. mainContext.fillStyle = darkOutlineColor;
  11252. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  11253. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  11254. (config.healthBarPad * 2), 17, 8);
  11255. mainContext.fill();
  11256. // HEALTH HOLDER:
  11257. mainContext.fillStyle = darkOutlineColor;
  11258. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  11259. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  11260. (config.healthBarPad * 2), 17, 8);
  11261. mainContext.fill();
  11262.  
  11263. // HEALTH BAR:
  11264. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  11265. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  11266. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  11267. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  11268. mainContext.fill();
  11269. }
  11270. if(getEl("novisu").checked) {
  11271. let AStatus = (tmpObj == player ? secPacket : "");
  11272.  
  11273. if (AStatus !== "") {
  11274. mainContext.font = (tmpObj.nameScale || 15) + "px Neuton";
  11275. mainContext.fillStyle = tmpObj.isPlayer && tmpObj != player ? "#fff" :"#fff" ;
  11276. mainContext.textBaseline = "middle";
  11277.  
  11278. mainContext.textAlign = "center";
  11279. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11280. mainContext.strokeText(AStatus, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 35);
  11281. mainContext.fillText(AStatus, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 35);
  11282. }
  11283. }
  11284. if(!getEl("novisu").checked) {
  11285. let publicStatus = (tmpObj.isPlayer ? tmpObj.sid : "");
  11286.  
  11287. if (publicStatus !== "") {
  11288. mainContext.font = (tmpObj.nameScale || 25) + "px Neuton";
  11289. mainContext.fillStyle = tmpObj.isPlayer && tmpObj != player ? "#41736e" :"#735d41" ;
  11290. mainContext.textBaseline = "middle";
  11291.  
  11292. mainContext.textAlign = "center";
  11293. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11294. mainContext.strokeText(publicStatus, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 35);
  11295. mainContext.fillText(publicStatus, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 35);
  11296. }
  11297. }
  11298. if (trackerz.draw4.active) {
  11299.  
  11300. let obj = {
  11301. x: trackerz.draw4.x - xOffset,
  11302. y: trackerz.draw4.y - yOffset,
  11303. scale: trackerz.draw4.scale * 1,
  11304. dir: trackerz.draw4.dir // assuming trackerz.draw4 has a dir property
  11305. }
  11306.  
  11307. mainContext.lineWidth = 0.4;
  11308. mainContext.globalAlpha = 1;
  11309. mainContext.strokeStyle = "black";
  11310. mainContext.save();
  11311. mainContext.translate(obj.x, obj.y); // translate to the object's position
  11312. mainContext.rotate(obj.dir); // rotate by the object's direction
  11313. mainContext.fillStyle = "rgba(137, 207, 240, 0.5)";
  11314. mainContext.beginPath();
  11315. mainContext.arc(0, 0, obj.scale, 0, 2 * Math.PI); // draw the circle at the origin (0, 0)
  11316. mainContext.fill();
  11317. mainContext.lineWidth = 2;
  11318. mainContext.stroke();
  11319. mainContext.restore();
  11320. }
  11321.  
  11322. if(!getEl("novisu").checked) {
  11323. let sidViewer = (tmpObj.isPlayer && tmpObj == player ? secPacket : "");
  11324.  
  11325. mainContext.font = (tmpObj.nameScale || 25) + "px Comic Neue";
  11326. mainContext.fillStyle = "#fff";
  11327. mainContext.textBaseline = "middle";
  11328. mainContext.textAlign = "center";
  11329. mainContext.strokeStyle = "black";
  11330. mainContext.lineWIdth = (tmpObj.nameScale ? 11 : 8);
  11331. mainContext.strokeText(sidViewer, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale)-65);
  11332. mainContext.fillText(sidViewer, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale)-65);
  11333. }
  11334. if(!getEl("novisu").checked) {
  11335.  
  11336. if (tmpObj.isPlayer) {
  11337. // PLAYER TRACER:
  11338. if (!tmpObj.isTeam(player)) {
  11339. let center = {
  11340. x: screenWidth / 2,
  11341. y: screenHeight / 2,
  11342. };
  11343. 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);
  11344. let dist = center.y * alpha / 2;
  11345. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  11346. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  11347. mainContext.save();
  11348. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  11349. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  11350. let by = 255 - (tmpObj.sid * 2);
  11351. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  11352. mainContext.globalAlpha = alpha;
  11353. let renderTracer = function(s, ctx) {
  11354. ctx = ctx || mainContext;
  11355. let h = s * (Math.sqrt(3) / 2);
  11356. ctx.beginPath();
  11357. ctx.moveTo(0, -h / 1.5);
  11358. ctx.lineTo(-s / 2, h / 2);
  11359. ctx.lineTo(s / 2, h / 2);
  11360. ctx.lineTo(0, -h / 1.5);
  11361. ctx.fill();
  11362. ctx.closePath();
  11363. }
  11364. renderTracer(25, mainContext);
  11365. mainContext.restore();
  11366. }
  11367.  
  11368. if (getEl("predictType").value == "pre2") {
  11369. mainContext.lineWidth = 3;
  11370. mainContext.strokeStyle = "#fff";
  11371. mainContext.globalAlpha = 1;
  11372. mainContext.beginPath();
  11373. let render = {
  11374. x: tmpObj.x2 - xOffset,
  11375. y: tmpObj.y2 - yOffset
  11376. };
  11377. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11378. mainContext.lineTo(render.x, render.y);
  11379. mainContext.stroke();
  11380. } else if (getEl("predictType").value == "pre3") {
  11381. mainContext.lineWidth = 3;
  11382. mainContext.strokeStyle = "#cc5151";
  11383. mainContext.globalAlpha = 1;
  11384. mainContext.beginPath();
  11385. let render = {
  11386. x: tmpObj.x3 - xOffset,
  11387. y: tmpObj.y3 - yOffset
  11388. };
  11389. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11390. mainContext.lineTo(render.x, render.y);
  11391. mainContext.stroke();
  11392. }
  11393.  
  11394. }
  11395. }
  11396. }
  11397. }
  11398. }
  11399.  
  11400. if (player) {
  11401. // AUTOPUSH visual:
  11402. if (my.autoPush) {
  11403. mainContext.globalAlpha = 0.5;
  11404. mainContext.fillStyle = "rgba(137, 207, 240, 1)";
  11405. mainContext.beginPath();
  11406. mainContext.arc(my.pushData.x - xOffset, my.pushData.y - yOffset, 35, 0, 2 * Math.PI); // Draw a circle with radius 10
  11407. mainContext.fill(); // Fill the circle
  11408. }
  11409. mainContext.globalAlpha = 1; // Set globalAlpha back to 1
  11410. mainContext.fillStyle = "rgba(255, 0, 0, 0.5)";
  11411. mainContext.beginPath();
  11412. mainContext.arc(my.pushData.x - xOffset + 60, my.pushData.y - yOffset, 35, 0, 2 * Math.PI); // Draw a circle with radius 10, 60px to the right
  11413. mainContext.fill(); // Fill the circle
  11414. }
  11415. // RENDER ANIM TEXTS:
  11416. textManager.update(delta, mainContext, xOffset, yOffset);
  11417. // RENDER CHAT MESSAGES:
  11418. for (let i = 0; i < players.length; ++i) {
  11419. tmpObj = players[i];
  11420. if (tmpObj.visible) {
  11421. if (tmpObj.chatCountdown > 0) {
  11422. tmpObj.chatCountdown -= delta;
  11423. if (tmpObj.chatCountdown <= 0)
  11424. tmpObj.chatCountdown = 0;
  11425. mainContext.font = "32px Hammersmith One";
  11426. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11427. mainContext.textBaseline = "middle";
  11428. mainContext.textAlign = "center";
  11429. let tmpX = tmpObj.x - xOffset;
  11430. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11431. let tmpH = 47;
  11432. let tmpW = tmpSize.width + 17;
  11433. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11434. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11435. mainContext.fill();
  11436. mainContext.fillStyle = "#fff";
  11437. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11438. }
  11439. if (tmpObj.chat.count > 0) {
  11440. if (!useWasd) {
  11441. tmpObj.chat.count -= delta;
  11442. if (tmpObj.chat.count <= 0)
  11443. tmpObj.chat.count = 0;
  11444. mainContext.font = "32px Hammersmith One";
  11445. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11446. mainContext.textBaseline = "middle";
  11447. mainContext.textAlign = "center";
  11448. let tmpX = tmpObj.x - xOffset;
  11449. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11450. let tmpH = 47;
  11451. let tmpW = tmpSize.width + 17;
  11452. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11453. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11454. mainContext.fill();
  11455. mainContext.fillStyle = "#ffffff99";
  11456. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11457. } else {
  11458. tmpObj.chat.count = 0;
  11459. }
  11460. }
  11461. }
  11462. }
  11463.  
  11464. if (allChats.length) {
  11465. allChats.filter(ch => ch.active).forEach((ch) => {
  11466. if (!ch.alive) {
  11467. if (ch.alpha <= 1) {
  11468. ch.alpha += delta / 250;
  11469. if (ch.alpha >= 1) {
  11470. ch.alpha = 1;
  11471. ch.alive = true;
  11472. }
  11473. }
  11474. } else {
  11475. ch.alpha -= delta / 5000;
  11476. if (ch.alpha <= 0) {
  11477. ch.alpha = 0;
  11478. ch.active = false;
  11479. }
  11480. }
  11481. if (ch.active) {
  11482.  
  11483. if (tmpObj.chatCountdown <= 0)
  11484. tmpObj.chatCountdown = 0;
  11485. mainContext.font = "25px Ubuntu";
  11486. let tmpSize = mainContext.measureText(ch.chat);
  11487. mainContext.textBaseline = "middle";
  11488. mainContext.textAlign = "center";
  11489. let tmpX = ch.x - xOffset;
  11490. let tmpY = ch.y - yOffset - 110;
  11491. let tmpH = 40;
  11492. let tmpW = tmpSize.width + 35;
  11493.  
  11494. mainContext.globalAlpha = ch.alpha;
  11495. mainContext.fillStyle = "#ffffff";
  11496.  
  11497. mainContext.strokeStyle = "rgb(0, 0, 0)";
  11498. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11499. mainContext.fillRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH);
  11500.  
  11501.  
  11502.  
  11503.  
  11504. mainContext.fillStyle = "#ffffff";
  11505. mainContext.strokeStyle = "#000000";
  11506. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11507. mainContext.fillText(ch.chat, tmpX, tmpY);
  11508. }
  11509.  
  11510. });
  11511. }
  11512.  
  11513. mainContext.globalAlpha = 1;
  11514.  
  11515.  
  11516. // RENDER MINIMAP:
  11517. renderMinimap(delta);
  11518. }
  11519.  
  11520. // UPDATE & ANIMATE:
  11521. window.requestAnimFrame = function() {
  11522. return null;
  11523. }
  11524. window.rAF = (function() {
  11525. return window.requestAnimationFrame ||
  11526. window.webkitRequestAnimationFrame ||
  11527. window.mozRequestAnimationFrame ||
  11528. function(callback) {
  11529. window.setTimeout(callback, 1000/9);
  11530. };
  11531. })();
  11532.  
  11533. function doUpdate() {
  11534. //rape modulus
  11535. now = performance.now();
  11536. delta = now - lastUpdate;
  11537. lastUpdate = now;
  11538. let timer = performance.now();
  11539. let diff = timer - fpsTimer.last;
  11540. if (diff >= 1000) {
  11541.  
  11542. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11543.  
  11544. fpsTimer.last = timer;
  11545. fpsTimer.time = 0;
  11546. }
  11547. fpsTimer.time++;
  11548.  
  11549. getEl("pingFps").innerHTML = `${window.pingTime}ms | Frames: ${Math.round(fpsTimer.ltime)}`;
  11550.  
  11551. updateGame();
  11552. rAF(doUpdate);
  11553. ms.avg = Math.round((ms.min+ms.max)/2);
  11554. }
  11555.  
  11556. prepareMenuBackground();
  11557. doUpdate();
  11558.  
  11559. function toggleUseless(boolean) {
  11560. getEl("instaType").disabled = boolean;
  11561. getEl("antiBullType").disabled = boolean;
  11562. getEl("predictType").disabled = boolean;
  11563. }
  11564. toggleUseless(useWasd);
  11565.  
  11566. let changeDays = {};
  11567. window.debug = function() {
  11568. my.waitHit = 0;
  11569. my.autoAim = false;
  11570. instaC.isTrue = false;
  11571. traps.inTrap = false;
  11572. itemSprites = [];
  11573. objSprites = [];
  11574. gameObjectSprites = [];
  11575. };
  11576. window.wasdMode = function() {
  11577. useWasd = !useWasd;
  11578. toggleUseless(useWasd);
  11579. };
  11580. window.startGrind = function() {
  11581. if (getEl("weaponGrind").checked) {
  11582. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11583. checkPlace(player.getItemType(22), i);
  11584. }
  11585. }
  11586. };
  11587. // REMOVED!!! so they cant abuse :)
  11588. let projects = [
  11589. "adorable-eight-guppy",
  11590. "galvanized-bittersweet-windshield"
  11591. ];
  11592. let botIDS = 0;
  11593. window.connectFillBots = function() {
  11594. botSkts = [];
  11595. botIDS = 0;
  11596. for (let i = 0; i < projects.length; i++) {
  11597. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11598. test.binaryType = "arraybuffer";
  11599.  
  11600. test.onopen = function() {
  11601. test.ssend = function(type) {
  11602. let data = Array.prototype.slice.call(arguments, 1);
  11603. let binary = window.msgpack.encode([type, data]);
  11604. test.send(binary);
  11605. };
  11606. for (let i = 0; i < 4; i++) {
  11607. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11608. action: "homepage"
  11609. }).then(function(token) {
  11610. let t = WS.url.split("wss://")[1].split("?")[0];
  11611. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  11612. botSkts.push([test]);
  11613. botIDS++;
  11614. });
  11615. }
  11616. };
  11617. test.onmessage = function(message) {
  11618. let data = new Uint8Array(message.data);
  11619. let parsed = window.msgpack.decode(data);
  11620. let type = parsed[0];
  11621. data = parsed[1];
  11622. };
  11623. }
  11624. };
  11625. window.destroyFillBots = function() {
  11626. botSkts.forEach((socket) => {
  11627. socket[0].close();
  11628. });
  11629. botSkts = [];
  11630. };
  11631. window.tryConnectBots = function() {
  11632. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  11633. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11634. action: "homepage"
  11635. }).then(function(token) {
  11636. // CONNECT SOCKET:
  11637. botSpawn(token);
  11638. });
  11639. }
  11640. };
  11641. window.destroyBots = function() {
  11642. bots.forEach((botyyyyy) => {
  11643. botyyyyy.closeSocket = true;
  11644. });
  11645. bots = [];
  11646. };
  11647. window.resBuild = function() {
  11648. if (gameObjects.length) {
  11649. gameObjects.forEach((tmp) => {
  11650. tmp.breakObj = false;
  11651. });
  11652. breakObjects = [];
  11653. }
  11654. };
  11655. window.toggleBotsCircle = function() {
  11656. player.circle = !player.circle;
  11657. };
  11658. window.toggleVisual = function() {
  11659. config.anotherVisual = !config.anotherVisual;
  11660. gameObjects.forEach((tmp) => {
  11661. if (tmp.active) {
  11662. tmp.dir = tmp.lastDir;
  11663. }
  11664. });
  11665. };
  11666. window.prepareUI = function(tmpObj) {
  11667. resize();
  11668.  
  11669. // CHAT STUFF:
  11670. var chatBox = document.getElementById("chatBox");
  11671. var chatHolder = document.getElementById("chatHolder");
  11672. var suggestBox = document.createElement("div");
  11673. suggestBox.id = "suggestBox";
  11674.  
  11675. var prevChats = [];
  11676. var prevChatsIndex = 0;
  11677.  
  11678. function toggleChat() {
  11679. if (!usingTouch) {
  11680. if (chatHolder.style.display == "block") {
  11681. if (chatBox.value) {
  11682. sendChat(chatBox.value);
  11683. }
  11684. closeChat();
  11685. } else {
  11686. storeMenu.style.display = "none";
  11687. allianceMenu.style.display = "none";
  11688. chatHolder.style.display = "block";
  11689. chatBox.focus();
  11690. resetMoveDir();
  11691. }
  11692. } else {
  11693. setTimeout(function () {
  11694. var chatMessage = prompt("chat message");
  11695. if (chatMessage) {
  11696. sendChat(chatMessage);
  11697. }
  11698. }, 1);
  11699. }
  11700. chatBox.value = "";
  11701. (() => {
  11702. prevChatsIndex = 0;
  11703. })();
  11704. }
  11705.  
  11706. function closeChat() {
  11707. chatBox.value = "";
  11708. chatHolder.style.display = "none";
  11709. }
  11710.  
  11711. // ACTION BAR:
  11712. UTILS.removeAllChildren(actionBar);
  11713.  
  11714. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11715. (function (i) {
  11716. UTILS.generateElement({
  11717. id: "actionBarItem" + i,
  11718. class: "actionBarItem",
  11719. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  11720. onmouseout: function () {
  11721. showItemInfo();
  11722. },
  11723. parent: actionBar
  11724. });
  11725. })(i);
  11726. }
  11727.  
  11728. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11729. (function (i) {
  11730. let tmpCanvas = document.createElement("canvas");
  11731. tmpCanvas.width = tmpCanvas.height = 66;
  11732. let tmpContext = tmpCanvas.getContext("2d");
  11733. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11734. tmpContext.imageSmoothingEnabled = false;
  11735. tmpContext.webkitImageSmoothingEnabled = false;
  11736. tmpContext.mozImageSmoothingEnabled = false;
  11737.  
  11738. if (items.weapons[i]) {
  11739. tmpContext.rotate((Math.PI));
  11740. let tmpSprite = new Image();
  11741. toolSprites[items.weapons[i].src] = tmpSprite;
  11742. tmpSprite.onload = function () {
  11743. this.isLoaded = true;
  11744. let tmpPad = 1 / (this.height / this.width);
  11745. let tmpMlt = (items.weapons[i].iPad || 1);
  11746. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11747. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11748. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  11749. tmpContext.globalCompositeOperation = "source-atop";
  11750. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11751. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11752. };
  11753. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11754. let tmpUnit = getEl('actionBarItem' + i);
  11755. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11756. // showItemInfo(items.weapons[i], true);
  11757. // });
  11758. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11759. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11760. });
  11761. UTILS.hookTouchEvents(tmpUnit);
  11762. } else {
  11763. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11764. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11765. tmpContext.globalAlpha = 1;
  11766. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11767. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11768. tmpContext.globalCompositeOperation = "source-atop";
  11769. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11770. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11771. let tmpUnit = getEl('actionBarItem' + i);
  11772. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11773. // showItemInfo(items.list[i - items.weapons.length]);
  11774. // });
  11775. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11776. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11777. });
  11778. UTILS.hookTouchEvents(tmpUnit);
  11779. }
  11780. })(i);
  11781. }
  11782. };
  11783. window.profineTest = function(data) {
  11784. if (data) {
  11785. // VALIDATE NAME:
  11786. let name = data + "";
  11787. name = name.slice(0, config.maxNameLength);
  11788.  
  11789. return name;
  11790. }
  11791. };