Error Mod

~

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/497947/1394381/Error%20Mod.js

  1. // ==UserScript==
  2. // @name Error Mod
  3. // @version 5
  4. // @author Erro?r
  5. // @description ~
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @icon https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/ab0c1e57515093.59d8c6eb16d19.gif
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // Test Auto Reply
  13. let founda = false;
  14. let scriptTags = document.getElementsByTagName("script");
  15. for (let i = 0; i < scriptTags.length; i++) {
  16. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  17. scriptTags[i].remove();
  18. founda = true;
  19. break;
  20. }
  21. }
  22. document.addEventListener("keydown", function(event) {
  23. if (event.keyCode === 45) {
  24. const chatHolder = document.getElementById("gameUI");
  25. if (chatHolder) {
  26. const currentDisplay = chatHolder.style.display;
  27. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  28. }
  29. }
  30. });
  31. var styleItem = document.createElement("style");
  32. styleItem.type = "text/css";
  33. styleItem.appendChild(document.createTextNode(`
  34. #suggestBox {
  35. width: 355px;
  36. border-radius: 3px;
  37. background-color: rgba(0,0,0,0.5);
  38. margin: auto;
  39. text-align: left;
  40. z-index: 49;
  41. pointer-events: auto;
  42. position: relative;
  43. bottom: 3.5px;
  44. overflow-y: auto;
  45. }
  46. #suggestBox div {
  47. background-color: rgba(255,255,255,0);
  48. color: rgba(255,255,255,1);
  49. transition: background-color 0.3s, color 0.3s;
  50. }
  51. #suggestBox div:hover {
  52. background-color: rgba(255,255,255,0.2);
  53. color: rgba(0,0,0,1);
  54. }
  55. .suggestBoxHard {
  56. color: rgba(255,255,255,1);
  57. font-size: 18px;
  58. }
  59. .suggestBoxLight {
  60. color: rgba(255,255,255,0.7);
  61. font-size: 18px;
  62. }
  63. `));
  64. document.head.appendChild(styleItem);
  65.  
  66. window.addEventListener('load', function() {
  67. var allianceButton = document.getElementById('allianceButton');
  68. var storeButton = document.getElementById('storeButton');
  69. if (storeButton) {
  70. storeButton.style.right = '26px';
  71. storeButton.style.top = '420px';
  72. }
  73. if (allianceButton) {
  74. allianceButton.style.right = '26px';
  75. allianceButton.style.top = '479px';
  76. }
  77. });
  78.  
  79. function getEl(id) {
  80. return document.getElementById(id);
  81. }
  82.  
  83. !function(run) {
  84.  
  85. let newFont = document.createElement("link");
  86. newFont.rel = "stylesheet";
  87. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  88. newFont.type = "text/css";
  89. document.body.append(newFont);
  90.  
  91. let min = document.createElement("script");
  92. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  93. document.body.append(min);
  94. window.oncontextmenu = function() {
  95. return false;
  96. };
  97.  
  98. let config = window.config;
  99.  
  100. // CLIENT:
  101. config.clientSendRate = 9; // Aim Packet Send Rate
  102. config.serverUpdateRate = 9;
  103.  
  104. // UI:
  105. config.deathFadeout = 0;
  106.  
  107. config.playerCapacity = 9999;
  108.  
  109. // CHECK IN SANDBOX:
  110. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  111.  
  112. // CUSTOMIZATION:
  113. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  114. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  115. "#8bc373", "#91b2db"
  116. ];
  117. config.weaponVariants = [{
  118. id: 0,
  119. src: "",
  120. xp: 0,
  121. val: 1,
  122. }, {
  123. id: 1,
  124. src: "_g",
  125. xp: 3000,
  126. val: 1.1,
  127. }, {
  128. id: 2,
  129. src: "_d",
  130. xp: 7000,
  131. val: 1.18,
  132. }, {
  133. id: 3,
  134. src: "_r",
  135. poison: true,
  136. xp: 12000,
  137. val: 1.18,
  138. }, {
  139. id: 4,
  140. src: "_e",
  141. poison: true,
  142. heal: true,
  143. xp: 24000,
  144. val: 1.18,
  145. }];
  146.  
  147. // VISUAL:
  148. config.anotherVisual = true;
  149. config.useWebGl = false;
  150. config.resetRender = true;
  151.  
  152. function waitTime(timeout) {
  153. return new Promise((done) => {
  154. setTimeout(() => {
  155. done();
  156. }, timeout);
  157. });
  158. }
  159.  
  160. let botSkts = [];
  161.  
  162. // STORAGE:
  163. let canStore;
  164. if (typeof(Storage) !== "undefined") {
  165. canStore = true;
  166. }
  167.  
  168. function saveVal(name, val) {
  169. if (canStore)
  170. localStorage.setItem(name, val);
  171. }
  172.  
  173. function deleteVal(name) {
  174. if (canStore)
  175. localStorage.removeItem(name);
  176. }
  177.  
  178. function getSavedVal(name) {
  179. if (canStore)
  180. return localStorage.getItem(name);
  181. return null;
  182. }
  183.  
  184. // CONFIGS:
  185. let gC = function(a, b) {
  186. try {
  187. let res = JSON.parse(getSavedVal(a));
  188. if (typeof res === "object") {
  189. return b;
  190. } else {
  191. return res;
  192. }
  193. } catch (e) {
  194. alert("dieskid");
  195. return b;
  196. }
  197. };
  198.  
  199. function setCommands() {
  200. return {
  201. "help": {
  202. desc: "Show Commands",
  203. action: function(message) {
  204. for (let cmds in commands) {
  205. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  206. }
  207. }
  208. },
  209. "clear": {
  210. desc: "Clear Chats",
  211. action: function(message) {
  212. resetMenuChText();
  213. }
  214. },
  215. "debug": {
  216. desc: "Debug Mod For Development",
  217. action: function(message) {
  218. addDeadPlayer(player);
  219. addMenuChText("Debug", "Done", "#99ee99", 1);
  220. }
  221. },
  222. "play": {
  223. desc: "Play Music ( /play [link] )",
  224. action: function(message) {
  225. let link = message.split(" ");
  226. if (link[1]) {
  227. let audio = new Audio(link[1]);
  228. audio.play();
  229. } else {
  230. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  231. }
  232. }
  233. },
  234. "bye": {
  235. desc: "Leave Game",
  236. action: function(message) {
  237. window.leave();
  238. }
  239. },
  240. };
  241. }
  242.  
  243. function setConfigs() {
  244. return {
  245. errorpicininistedigisey: true,
  246. killChat: false,
  247. alwaysRev: true,
  248. autoBuy: true,
  249. autoBuyEquip: true,
  250. autoPush: true,
  251. revTick: true,
  252. spikeTick: true,
  253. predictTick: true,
  254. autoPlace: true,
  255. autoReplace: true,
  256. antiTrap: true,
  257. slowOT: false,
  258. attackDir: false,
  259. showDir: false,
  260. noDir: false,
  261. autoRespawn: false
  262. };
  263. };
  264.  
  265. let commands = setCommands();
  266. let configs = setConfigs();
  267. window.removeConfigs = function() {
  268. for (let cF in configs) {
  269. deleteVal(cF, configs[cF]);
  270. }
  271. };
  272.  
  273. for (let cF in configs) {
  274. configs[cF] = gC(cF, configs[cF]);
  275. }
  276.  
  277. // MENU FUNCTIONS:
  278. window.changeMenu = function() {};
  279. window.debug = function() {};
  280. window.wasdMode = function() {};
  281.  
  282. // PAGE 1:
  283. window.startGrind = function() {};
  284.  
  285. // PAGE 3:
  286. window.connectFillBots = function() {};
  287. window.destroyFillBots = function() {};
  288. window.tryConnectBots = function() {};
  289. window.destroyBots = function() {};
  290. window.resBuild = function() {};
  291. window.toggleBotsCircle = function() {};
  292. window.toggleVisual = function() {};
  293.  
  294. // SOME FUNCTIONS:
  295. window.prepareUI = function() {};
  296. window.leave = function() {};
  297.  
  298. // nah hahahahahhh why good ping
  299. window.ping = 0;
  300.  
  301. class deadfuturechickenmodrevival {
  302. constructor(flarez, lore) {
  303. this.inGame = false;
  304. this.lover = flarez + lore;
  305. this.baby = "ae86";
  306. this.isBlack = 0;
  307. this.webSocket = undefined;
  308. this.checkBaby = function() {
  309. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  310. if (this.isBlack >= 1) return "bl4cky";
  311. return "noting for you";
  312. };
  313. this.x2 = 0;
  314. this.y2 = 0;
  315. this.chat = "Imagine playing this badass game XDDDDD";
  316. this.summon = function(tmpObj) {
  317. this.x2 = tmpObj.x;
  318. this.y2 = tmpObj.y;
  319. this.chat = tmpObj.name + " ur so bad XDDDD";
  320. };
  321. this.commands = function(cmd) {
  322. cmd == "rv3link" && window.open("https://florr.io/");
  323. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  324. return cmd;
  325. };
  326. this.dayte = "11yearold";
  327. this.memeganoob = "69yearold";
  328. this.startDayteSpawn = function(tmpObj) {
  329. let ratio = setInterval(() => {
  330. this.x2 = tmpObj.x + 20;
  331. this.y2 = tmpObj.y - 20;
  332. this.chat = "UR SO BAD LOL";
  333. if (tmpObj.name == "ae86") {
  334. this.chat = "omg ae86 go run";
  335. setTimeout(() => {
  336. this.inGame = false;
  337. clearInterval(ratio);
  338. }, 1000);
  339. }
  340. }, 1234);
  341. };
  342. this.AntiChickenModV69420 = function(tmpObj) {
  343. return "!c!dc user " + tmpObj.name;
  344. };
  345. }
  346. };
  347. class HtmlAction {
  348. constructor(element) {
  349. this.element = element;
  350. };
  351. add(code) {
  352. if (!this.element) return undefined;
  353. this.element.innerHTML += code;
  354. };
  355. newLine(amount) {
  356. let result = `<br>`;
  357. if (amount > 0) {
  358. result = ``;
  359. for (let i = 0; i < amount; i++) {
  360. result += `<br>`;
  361. }
  362. }
  363. this.add(result);
  364. };
  365. checkBox(setting) {
  366. let newCheck = `<input type = "checkbox"`;
  367. setting.id && (newCheck += ` id = ${setting.id}`);
  368. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  369. setting.class && (newCheck += ` class = ${setting.class}`);
  370. setting.checked && (newCheck += ` checked`);
  371. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  372. newCheck += `>`;
  373. this.add(newCheck);
  374. };
  375. text(setting) {
  376. let newText = `<input type = "text"`;
  377. setting.id && (newText += ` id = ${setting.id}`);
  378. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  379. setting.class && (newText += ` class = ${setting.class}`);
  380. setting.size && (newText += ` size = ${setting.size}`);
  381. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  382. setting.value && (newText += ` value = ${setting.value}`);
  383. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  384. newText += `>`;
  385. this.add(newText);
  386. };
  387. select(setting) {
  388. let newSelect = `<select`;
  389. setting.id && (newSelect += ` id = ${setting.id}`);
  390. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  391. setting.class && (newSelect += ` class = ${setting.class}`);
  392. newSelect += `>`;
  393. for (let options in setting.option) {
  394. newSelect += `<option value = ${setting.option[options].id}`
  395. setting.option[options].selected && (newSelect += ` selected`);
  396. newSelect += `>${options}</option>`;
  397. }
  398. newSelect += `</select>`;
  399. this.add(newSelect);
  400. };
  401. button(setting) {
  402. let newButton = `<button`;
  403. setting.id && (newButton += ` id = ${setting.id}`);
  404. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  405. setting.class && (newButton += ` class = ${setting.class}`);
  406. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  407. newButton += `>`;
  408. setting.innerHTML && (newButton += setting.innerHTML);
  409. newButton += `</button>`;
  410. this.add(newButton);
  411. };
  412. selectMenu(setting) {
  413. let newSelect = `<select`;
  414. if (!setting.id) {
  415. alert("please put id skid");
  416. return;
  417. }
  418. window[setting.id + "Func"] = function() {};
  419. setting.id && (newSelect += ` id = ${setting.id}`);
  420. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  421. setting.class && (newSelect += ` class = ${setting.class}`);
  422. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  423. newSelect += `>`;
  424. let last;
  425. let i = 0;
  426. for (let options in setting.menu) {
  427. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  428. setting.menu[options] && (newSelect += ` checked`);
  429. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  430. i++;
  431. }
  432. newSelect += `</select>`;
  433.  
  434. this.add(newSelect);
  435.  
  436. i = 0;
  437. for (let options in setting.menu) {
  438. window[options + "Func"] = function() {
  439. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  440. saveVal(options, setting.menu[options]);
  441.  
  442. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  443. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  444.  
  445. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  446.  
  447. };
  448. this.checkBox({
  449. id: "check_" + options,
  450. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  451. class: "checkB",
  452. onclick: `window.${options + "Func"}()`,
  453. checked: setting.menu[options]
  454. });
  455. i++;
  456. }
  457.  
  458. last = "check_" + getEl(setting.id).value.split("_")[1];
  459. window[setting.id + "Func"] = function() {
  460. getEl(last).style.display = "none";
  461. last = "check_" + getEl(setting.id).value.split("_")[1];
  462. getEl(last).style.display = "inline-block";
  463.  
  464. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  465.  
  466. };
  467. };
  468. };
  469. class Html {
  470. constructor() {
  471. this.element = null;
  472. this.action = null;
  473. this.divElement = null;
  474. this.startDiv = function(setting, func) {
  475.  
  476. let newDiv = document.createElement("div");
  477. setting.id && (newDiv.id = setting.id);
  478. setting.style && (newDiv.style = setting.style);
  479. setting.class && (newDiv.className = setting.class);
  480. this.element.appendChild(newDiv);
  481. this.divElement = newDiv;
  482.  
  483. let addRes = new HtmlAction(newDiv);
  484. typeof func == "function" && func(addRes);
  485.  
  486. };
  487. this.addDiv = function(setting, func) {
  488.  
  489. let newDiv = document.createElement("div");
  490. setting.id && (newDiv.id = setting.id);
  491. setting.style && (newDiv.style = setting.style);
  492. setting.class && (newDiv.className = setting.class);
  493. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  494. this.divElement = newDiv;
  495.  
  496. let addRes = new HtmlAction(newDiv);
  497. typeof func == "function" && func(addRes);
  498.  
  499. };
  500. };
  501. set(id) {
  502. this.element = getEl(id);
  503. this.action = new HtmlAction(this.element);
  504. };
  505. resetHTML(text) {
  506. if (text) {
  507. this.element.innerHTML = ``;
  508. } else {
  509. this.element.innerHTML = ``;
  510. }
  511. };
  512. setStyle(style) {
  513. this.element.style = style;
  514. };
  515. setCSS(style) {
  516. this.action.add(`<style>` + style + `</style>`);
  517. };
  518. };
  519.  
  520. let HTML = new Html();
  521.  
  522. let menuDiv = document.createElement("div");
  523. menuDiv.id = "menuDiv";
  524. menuDiv.draggable = true;
  525.  
  526. menuDiv.addEventListener("dragstart", function (e) {
  527. e.dataTransfer.setData("text/plain", "");
  528. });
  529.  
  530. document.addEventListener("dragover", function (e) {
  531. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  532. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  533. });
  534.  
  535. document.body.appendChild(menuDiv);
  536. HTML.set("menuDiv");
  537. HTML.setStyle(`
  538. position: absolute;
  539. left: 20px;
  540. top: 20px;
  541. `);
  542. HTML.resetHTML();
  543. HTML.setCSS(`
  544. .menuClass{
  545. color: #fff;
  546. font-size: 31px;
  547. text-align: left;
  548. padding: 10px;
  549. padding-top: 7px;
  550. padding-bottom: 5px;
  551. width: 300px;
  552. background-color: rgba(0, 0, 0, 0.25);
  553. -webkit-border-radius: 4px;
  554. -moz-border-radius: 4px;
  555. border-radius: 4px;
  556. }
  557. .menuC {
  558. display: none;
  559. font-family: "HammerSmith One";
  560. font-size: 12px;
  561. max-height: 180px;
  562. overflow-y: scroll;
  563. -webkit-touch-callout: none;
  564. -webkit-user-select: none;
  565. -khtml-user-select: none;
  566. -moz-user-select: none;
  567. -ms-user-select: none;
  568. user-select: none;
  569. }
  570. .menuB {
  571. text-align: center;
  572. background-color: rgb(25, 25, 25);
  573. color: #fff;
  574. -webkit-border-radius: 4px;
  575. -moz-border-radius: 4px;
  576. border-radius: 4px;
  577. border: 2px solid #000;
  578. cursor: pointer;
  579. }
  580. .menuB:hover {
  581. border: 2px solid #fff;
  582. }
  583. .menuB:active {
  584. color: rgb(25, 25, 25);
  585. background-color: rgb(200, 200, 200);
  586. }
  587. .customText {
  588. color: #000;
  589. -webkit-border-radius: 4px;
  590. -moz-border-radius: 4px;
  591. border-radius: 4px;
  592. border: 2px solid #000;
  593. }
  594. .customText:focus {
  595. background-color: yellow;
  596. }
  597. .checkB {
  598. position: relative;
  599. top: 2px;
  600. accent-color: #888;
  601. cursor: pointer;
  602. }
  603. .Cselect {
  604. -webkit-border-radius: 4px;
  605. -moz-border-radius: 4px;
  606. border-radius: 4px;
  607. background-color: rgb(75, 75, 75);
  608. color: #fff;
  609. border: 1px solid #000;
  610. }
  611. #menuChanger {
  612. position: absolute;
  613. right: 10px;
  614. top: 10px;
  615. background-color: rgba(0, 0, 0, 0);
  616. color: #fff;
  617. border: none;
  618. cursor: pointer;
  619. }
  620. #menuChanger:hover {
  621. color: #000;
  622. }
  623. ::-webkit-scrollbar {
  624. width: 10px;
  625. }
  626. ::-webkit-scrollbar-track {
  627. opacity: 0;
  628. }
  629. ::-webkit-scrollbar-thumb {
  630. background-color: rgb(25, 25, 25);
  631. -webkit-border-radius: 4px;
  632. -moz-border-radius: 4px;
  633. border-radius: 4px;
  634. }
  635. ::-webkit-scrollbar-thumb:active {
  636. background-color: rgb(230, 230, 230);
  637. }
  638. `);
  639. HTML.startDiv({
  640. id: "menuHeadLine",
  641. class: "menuClass"
  642. }, (html) => {
  643. html.add(`Mod:`);
  644. html.button({
  645. id: "menuChanger",
  646. class: "material-icons",
  647. innerHTML: `sync`,
  648. onclick: "window.changeMenu()"
  649. });
  650. HTML.addDiv({
  651. id: "menuButtons",
  652. style: "display: block; overflow-y: visible;",
  653. class: "menuC",
  654. appendID: "menuHeadLine"
  655. }, (html) => {
  656. html.button({
  657. class: "menuB",
  658. innerHTML: "Debug",
  659. onclick: "window.debug()"
  660. });
  661. });
  662. HTML.addDiv({
  663. id: "menuMain",
  664. style: "display: block",
  665. class: "menuC",
  666. appendID: "menuHeadLine"
  667. }, (html) => {
  668. html.button({
  669. class: "menuB",
  670. innerHTML: "Toggle Wasd Mode",
  671. onclick: "window.wasdMode()"
  672. });
  673. html.newLine();
  674. html.add(`Weapon Grinder: `);
  675. html.checkBox({
  676. id: "weaponGrind",
  677. class: "checkB",
  678. onclick: "window.startGrind()"
  679. });
  680. html.newLine(2);
  681. HTML.addDiv({
  682. style: "font-size: 20px; color: #99ee99;",
  683. appendID: "menuMain"
  684. }, (html) => {
  685. html.add(`Developing Settings:`);
  686. });
  687. html.add(`AntiPush:`);
  688. html.checkBox({
  689. id: "antipush",
  690. class: "checkB",
  691. checked: true
  692. });
  693. html.newLine();
  694. html.add(`Beta Heal:`);
  695. html.checkBox({
  696. id: "healingBeta",
  697. class: "checkB",
  698. checked: true
  699. });
  700. html.newLine();
  701. });
  702. HTML.addDiv({
  703. id: "menuConfig",
  704. class: "menuC",
  705. appendID: "menuHeadLine"
  706. }, (html) => {
  707. html.add(`Placement Tick: `);
  708. html.text({
  709. id: "autoPlaceTick",
  710. class: "customText",
  711. value: "2",
  712. size: "2em",
  713. maxLength: "1"
  714. });
  715. html.newLine();
  716. html.add(`Options: `);
  717. html.selectMenu({
  718. id: "configsChanger",
  719. class: "Cselect",
  720. menu: configs
  721. });
  722. html.newLine();
  723. html.add(`AntiBull: `);
  724. html.select({
  725. id: "antiBullType",
  726. class: "Cselect",
  727. option: {
  728. "Disable": {
  729. id: "noab",
  730. selected: true,
  731. },
  732. "When Reloaded": {
  733. id: "abreload",
  734. },
  735. "Always": {
  736. id: "abalway",
  737. }
  738. }
  739. });
  740. });
  741. HTML.addDiv({
  742. id: "menuOther",
  743. class: "menuC",
  744. appendID: "menuHeadLine"
  745. }, (html) => {
  746. html.button({
  747. class: "menuB",
  748. innerHTML: "Connect Bots",
  749. onclick: "window.tryConnectBots()"
  750. });
  751. html.button({
  752. class: "menuB",
  753. innerHTML: "Disconnect Bots",
  754. onclick: "window.destroyBots()"
  755. });
  756. html.newLine();
  757. html.add(`Break Objects Range: `);
  758. html.text({
  759. id: "breakRange",
  760. class: "customText",
  761. value: "700",
  762. size: "3em",
  763. maxLength: "4"
  764. });
  765. html.newLine();
  766. html.add(`Render Movement: `);
  767. html.select({
  768. id: "predictType",
  769. class: "Cselect",
  770. option: {
  771. "Disable Render": {
  772. id: "disableRender",
  773. selected: true
  774. },
  775. "X/Y and 2": {
  776. id: "pre2",
  777. },
  778. "X/Y and 3": {
  779. id: "pre3"
  780. }
  781. }
  782. });
  783. html.newLine();
  784. html.add(`Render Placers: `);
  785. html.checkBox({
  786. id: "placeVis",
  787. class: "checkB",
  788. });
  789. html.newLine();
  790. html.add(`Bot Mode: `);
  791. html.select({
  792. id: "mode",
  793. class: "Cselect",
  794. option: {
  795. "Clear Building": {
  796. id: "clear",
  797. selected: true
  798. },
  799. "Sync": {
  800. id: "zync",
  801. },
  802. "Search": {
  803. id: "zearch"
  804. },
  805. "Clear Everything": {
  806. id: "fuckemup"
  807. },
  808. "Flex": {
  809. id: "flex"
  810. }
  811. }
  812. });
  813. html.newLine();
  814. html.add(`Bot Setup: `);
  815. html.select({
  816. id: "setup",
  817. class: "Cselect",
  818. option: {
  819. "Dagger Musket": {
  820. id: "dm",
  821. selected: true
  822. },
  823. "Katana Hammer": {
  824. id: "kh",
  825. },
  826. "Dagger Repeater-Crossbow": {
  827. id: "dr"
  828. },
  829. "Sword Muzket": {
  830. id: "zd"
  831. }
  832. }
  833. });
  834. html.newLine();
  835. html.button({
  836. class: "menuB",
  837. innerHTML: "Toggle Another Visual",
  838. onclick: "window.toggleVisual()"
  839. });
  840. html.newLine();
  841. });
  842. });
  843.  
  844. let menuChatDiv = document.createElement("div");
  845. menuChatDiv.id = "menuChatDiv";
  846. document.body.appendChild(menuChatDiv);
  847. HTML.set("menuChatDiv");
  848. HTML.setStyle(`
  849. position: absolute;
  850. display: none;
  851. left: 0px;
  852. top: 25px;
  853. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  854. `);
  855. HTML.resetHTML();
  856. HTML.setCSS(`
  857. .chDiv {
  858. color: #fff;
  859. padding: 10px;
  860. width: 357px;
  861. height: 217px;
  862. background-color: rgba(0, 0, 0, 0.2);
  863. font-family: "HammerSmith One", monospace;
  864. // border-radius: 15px;
  865. // box-shadow: black 1px 2px 19px;
  866. //backdrop-filter: blur(3px);
  867.  
  868. }
  869. .chMainDiv {
  870. font-family: "Ubuntu";
  871. font-size: 16px;
  872. max-height: 215px;
  873. overflow-y: scroll;
  874. scrollbar-width: thin;
  875. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  876. -webkit-touch-callout: none;
  877. -webkit-user-select: none;
  878. -khtml-user-select: none;
  879. -moz-user-select: none;
  880. -ms-user-select: none;
  881. user-select: none;
  882. overflow-x: hidden;
  883. }
  884. .chMainDiv::-webkit-scrollbar {
  885. width: 8px;
  886. }
  887. .chMainDiv::-webkit-scrollbar-thumb {
  888. background-color: rgba(0, 0, 0, 0.5);
  889. }
  890. .chMainDiv::-webkit-scrollbar-thumb:hover {
  891. background-color: rgba(0, 0, 0, 0.7);
  892. }
  893. .chMainBox {
  894. display:none;
  895. position: absolute;
  896. left: 10px;
  897. bottom: 10px;
  898. width: 380px;
  899. height: 25px;
  900. background-color: rgba(255, 255, 255, 0.1);
  901. border-radius: 5px;
  902. color: rgba(255, 255, 255, 0.75);
  903. font-family: "HammerSmith One";
  904. font-size: 12px;
  905. }
  906. `);
  907. HTML.startDiv({
  908. id: "mChDiv",
  909. class: "chDiv"
  910. }, (html) => {
  911. HTML.addDiv({
  912. id: "mChMain",
  913. class: "chMainDiv",
  914. appendID: "mChDiv"
  915. }, (html) => {});
  916. html.text({
  917. id: "mChBox",
  918. class: "chMainBox",
  919. // placeHolder: `To chat click here or press "Enter" key`
  920. });
  921. });
  922.  
  923. let menuChats = getEl("mChMain");
  924. let menuChatBox = getEl("mChBox");
  925. let menuCBFocus = false;
  926. let menuChCounts = 0;
  927.  
  928. menuChatBox.value = "";
  929. menuChatBox.addEventListener("focus", () => {
  930. menuCBFocus = true;
  931. });
  932. menuChatBox.addEventListener("blur", () => {
  933. menuCBFocus = false;
  934. });
  935.  
  936. function addMenuChText(name, message, color, noTimer) {
  937. HTML.set("menuChatDiv");
  938. color = color || "white";
  939. let time = new Date();
  940. let min = time.getMinutes();
  941. let hour = time.getHours();
  942. let text = ``;
  943. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  944. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  945. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  946. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  947. html.add(text);
  948. });
  949. menuChats.scrollTop = menuChats.scrollHeight;
  950. menuChCounts++;
  951. }
  952. function chch(name, message, color, noTimer) {
  953. HTML.set("menuChatDiv");
  954. color = color || "white";
  955. let time = new Date();
  956. let text = ``;
  957. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  958. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  959. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  960. html.add(text);
  961. });
  962. menuChats.scrollTop = menuChats.scrollHeight;
  963. menuChCounts++;
  964. }
  965.  
  966. function resetMenuChText() {
  967. menuChats.innerHTML = ``;
  968. menuChCounts = 0;
  969. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  970. }
  971. resetMenuChText();
  972.  
  973. let menuIndex = 0;
  974. let menus = ["menuMain", "menuConfig", "menuOther"];
  975. window.changeMenu = function() {
  976. getEl(menus[menuIndex % menus.length]).style.display = "none";
  977. menuIndex++;
  978. getEl(menus[menuIndex % menus.length]).style.display = "block";
  979. };
  980.  
  981. let mStatus = document.createElement("div");
  982. mStatus.id = "status";
  983. getEl("gameUI").appendChild(mStatus);
  984. HTML.set("status");
  985. HTML.setStyle(`
  986. display: block;
  987. position: absolute;
  988. color: #ddd;
  989. font: 15px HammerSmith One;
  990. bottom: 215px;
  991. left: 20px;
  992. `);
  993. HTML.resetHTML();
  994. HTML.setCSS(`
  995. .sizing {
  996. font-size: 15px;
  997. }
  998. .mod {
  999. font-size: 15px;
  1000. display: inline-block;
  1001. }
  1002. `);
  1003. HTML.startDiv({
  1004. id: "uehmod",
  1005. class: "sizing"
  1006. }, (html) => {
  1007. html.add(`Ping: `);
  1008. HTML.addDiv({
  1009. id: "pingFps",
  1010. class: "mod",
  1011. appendID: "uehmod"
  1012. }, (html) => {
  1013. html.add("None");
  1014. });
  1015. html.newLine();
  1016. html.add(`Packet: `);
  1017. HTML.addDiv({
  1018. id: "packetStatus",
  1019. class: "mod",
  1020. appendID: "uehmod"
  1021. }, (html) => {
  1022. html.add("None");
  1023. });
  1024. });
  1025.  
  1026. /*function modLog() {
  1027. let logs = [];
  1028. for (let i = 0; i < arguments.length; i++) {
  1029. logs.push(arguments[i]);
  1030. }
  1031. getEl("modLog").innerHTML = logs;
  1032. }*/
  1033.  
  1034. let openMenu = false;
  1035.  
  1036. let WS = undefined;
  1037. let socketID = undefined;
  1038.  
  1039. let useWasd = false;
  1040. let secPacket = 0;
  1041. let secMax = 120;
  1042. let secTime = 1000;
  1043. let firstSend = {
  1044. sec: false
  1045. };
  1046. let game = {
  1047. tick: 0,
  1048. tickQueue: [],
  1049. tickBase: function(set, tick) {
  1050. if (this.tickQueue[this.tick + tick]) {
  1051. this.tickQueue[this.tick + tick].push(set);
  1052. } else {
  1053. this.tickQueue[this.tick + tick] = [set];
  1054. }
  1055. },
  1056. tickRate: (1000 / config.serverUpdateRate),
  1057. tickSpeed: 0,
  1058. lastTick: performance.now()
  1059. };
  1060. let modConsole = [];
  1061.  
  1062. let dontSend = false;
  1063. let fpsTimer = {
  1064. last: 0,
  1065. time: 0,
  1066. ltime: 0
  1067. }
  1068. let lastMoveDir = undefined;
  1069. let lastsp = ["cc", 1, "__proto__"];
  1070.  
  1071. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1072. WebSocket.prototype.send = function(message) {
  1073. if (!WS) {
  1074. WS = this;
  1075. WS.addEventListener("message", function(msg) {
  1076. getMessage(msg);
  1077. });
  1078. WS.addEventListener("close", (event) => {
  1079. if (event.code == 4001) {
  1080. window.location.reload();
  1081. }
  1082. });
  1083. }
  1084. if (WS == this) {
  1085. dontSend = false;
  1086.  
  1087. // EXTRACT DATA ARRAY:
  1088. let data = new Uint8Array(message);
  1089. let parsed = window.msgpack.decode(data);
  1090. let type = parsed[0];
  1091. data = parsed[1];
  1092.  
  1093. // SEND MESSAGE:
  1094. if (type == "6") {
  1095.  
  1096. if (data[0]) {
  1097. // ANTI PROFANITY:
  1098. 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", ];
  1099. let tmpString;
  1100. profanity.forEach((profany) => {
  1101. if (data[0].indexOf(profany) > -1) {
  1102. tmpString = "";
  1103. for (let i = 0; i < profany.length; ++i) {
  1104. if (i == 1) {
  1105. tmpString += String.fromCharCode(0);
  1106. }
  1107. tmpString += profany[i];
  1108. }
  1109. let re = new RegExp(profany, "g");
  1110. data[0] = data[0].replace(re, tmpString);
  1111. }
  1112. });
  1113.  
  1114. // FIX CHAT:
  1115. data[0] = data[0].slice(0, 30);
  1116. }
  1117.  
  1118. } else if (type == "L") {
  1119. // MAKE SAME CLAN:
  1120. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1121. data[0] = data[0].slice(0, 7);
  1122. } else if (type == "M") {
  1123. // APPLY CYAN COLOR:
  1124. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1125. data[0].moofoll = true;
  1126. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1127. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1128. } else if (type == "D") {
  1129. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1130. dontSend = true;
  1131. } else {
  1132. my.lastDir = data[0];
  1133. }
  1134. } else if (type == "d") {
  1135. if (!data[2]) {
  1136. dontSend = true;
  1137. } else {
  1138. if (![null, undefined].includes(data[1])) {
  1139. my.lastDir = data[1];
  1140. }
  1141. }
  1142. } else if (type == "K") {
  1143. if (!data[1]) {
  1144. dontSend = true;
  1145. }
  1146. } else if (type == "S") {
  1147. instaC.wait = !instaC.wait;
  1148. dontSend = true;
  1149. } else if (type == "a") {
  1150. if (data[1]) {
  1151. if (player.moveDir == data[0]) {
  1152. dontSend = true;
  1153. }
  1154. player.moveDir = data[0];
  1155. } else {
  1156. dontSend = true;
  1157. }
  1158. }
  1159. if (!dontSend) {
  1160. let binary = window.msgpack.encode([type, data]);
  1161. this.nsend(binary);
  1162.  
  1163. // START COUNT:
  1164. if (!firstSend.sec) {
  1165. firstSend.sec = true;
  1166. setTimeout(() => {
  1167. firstSend.sec = false;
  1168. secPacket = 0;
  1169. }, secTime);
  1170. }
  1171.  
  1172. secPacket++;
  1173. }
  1174. } else {
  1175. this.nsend(message);
  1176. }
  1177. }
  1178.  
  1179. function packet(type) {
  1180. // EXTRACT DATA ARRAY:
  1181. let data = Array.prototype.slice.call(arguments, 1);
  1182.  
  1183. // SEND MESSAGE:
  1184. let binary = window.msgpack.encode([type, data]);
  1185. WS.send(binary);
  1186. }
  1187.  
  1188. function origPacket(type) {
  1189. // EXTRACT DATA ARRAY:
  1190. let data = Array.prototype.slice.call(arguments, 1);
  1191.  
  1192. // SEND MESSAGE:
  1193. let binary = window.msgpack.encode([type, data]);
  1194. WS.nsend(binary);
  1195. }
  1196.  
  1197. window.leave = function() {
  1198. origPacket("kys", {
  1199. "frvr is so bad": true,
  1200. "sidney is too good": true,
  1201. "dev are too weak": true,
  1202. });
  1203. };
  1204.  
  1205. //...lol
  1206. let io = {
  1207. send: packet
  1208. };
  1209.  
  1210. function getMessage(message) {
  1211. let data = new Uint8Array(message.data);
  1212. let parsed = window.msgpack.decode(data);
  1213. let type = parsed[0];
  1214. data = parsed[1];
  1215. let events = {
  1216. A: setInitData, // id: setInitData,
  1217. //B: disconnect,
  1218. C: setupGame, // 1: setupGame,
  1219. D: addPlayer, // 2: addPlayer,
  1220. E: removePlayer, // 4: removePlayer,
  1221. a: updatePlayers, // 33: updatePlayers,
  1222. G: updateLeaderboard, // 5: updateLeaderboard,here
  1223. H: loadGameObject, // 6: loadGameObject,
  1224. I: loadAI, // a: loadAI,
  1225. J: animateAI, // aa: animateAI,
  1226. K: gatherAnimation, // 7: gatherAnimation,
  1227. L: wiggleGameObject, // 8: wiggleGameObject,
  1228. M: shootTurret, // sp: shootTurret,
  1229. N: updatePlayerValue, // 9: updatePlayerValue,
  1230. O: updateHealth, // h: updateHealth,//here
  1231. P: killPlayer, // 11: killPlayer,
  1232. Q: killObject, // 12: killObject,
  1233. R: killObjects, // 13: killObjects,
  1234. S: updateItemCounts, // 14: updateItemCounts,
  1235. T: updateAge, // 15: updateAge,
  1236. U: updateUpgrades, // 16: updateUpgrades,
  1237. V: updateItems, // 17: updateItems,
  1238. X: addProjectile, // 18: addProjectile,
  1239. Y: remProjectile, // 19: remProjectile,
  1240. //Z: serverShutdownNotice,
  1241. //0: addAlliance,
  1242. //1: deleteAlliance,
  1243. 2: allianceNotification, // an: allianceNotification,
  1244. 3: setPlayerTeam, // st: setPlayerTeam,
  1245. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1246. 5: updateStoreItems, // us: updateStoreItems,
  1247. 6: receiveChat, // ch: receiveChat,
  1248. 7: updateMinimap, // mm: updateMinimap,
  1249. 8: showText, // t: showText,
  1250. 9: pingMap, // p: pingMap,
  1251. 0: pingSocketResponse,
  1252. };
  1253. if (type == "io-init") {
  1254. socketID = data[0];
  1255. } else {
  1256. if (events[type]) {
  1257. events[type].apply(undefined, data);
  1258. }
  1259. }
  1260. }
  1261.  
  1262. // MATHS:
  1263. Math.lerpAngle = function(value1, value2, amount) {
  1264. let difference = Math.abs(value2 - value1);
  1265. if (difference > Math.PI) {
  1266. if (value1 > value2) {
  1267. value2 += Math.PI * 2;
  1268. } else {
  1269. value1 += Math.PI * 2;
  1270. }
  1271. }
  1272. let value = value2 + ((value1 - value2) * amount);
  1273. if (value >= 0 && value <= Math.PI * 2) return value;
  1274. return value % (Math.PI * 2);
  1275. };
  1276.  
  1277. // REOUNDED RECTANGLE:
  1278. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1279. if (w < 2 * r) r = w / 2;
  1280. if (h < 2 * r) r = h / 2;
  1281. if (r < 0)
  1282. r = 0;
  1283. this.beginPath();
  1284. this.moveTo(x + r, y);
  1285. this.arcTo(x + w, y, x + w, y + h, r);
  1286. this.arcTo(x + w, y + h, x, y + h, r);
  1287. this.arcTo(x, y + h, x, y, r);
  1288. this.arcTo(x, y, x + w, y, r);
  1289. this.closePath();
  1290. return this;
  1291. };
  1292.  
  1293. // GLOBAL VALUES:
  1294. function resetMoveDir() {
  1295. keys = {};
  1296. io.send("e");
  1297. }
  1298.  
  1299. let allChats = [];
  1300. let ticks = {
  1301. tick: 0,
  1302. delay: 0,
  1303. time: [],
  1304. manage: [],
  1305. };
  1306. let ais = [];
  1307. let players = [];
  1308. let alliances = [];
  1309. let alliancePlayers = [];
  1310. let allianceNotifications = [];
  1311. let gameObjects = [];
  1312. let liztobj = [];
  1313. let projectiles = [];
  1314. let deadPlayers = [];
  1315.  
  1316. let breakObjects = [];
  1317.  
  1318. let player;
  1319. let playerSID;
  1320. let tmpObj;
  1321.  
  1322. let enemy = [];
  1323. let nears = [];
  1324. let near = [];
  1325.  
  1326. let my = {
  1327. reloaded: false,
  1328. waitHit: 0,
  1329. autoAim: false,
  1330. revAim: false,
  1331. ageInsta: true,
  1332. reSync: false,
  1333. bullTick: 0,
  1334. anti0Tick: 0,
  1335. antiSync: false,
  1336. safePrimary: function(tmpObj) {
  1337. return [0, 8].includes(tmpObj.primaryIndex);
  1338. },
  1339. safeSecondary: function(tmpObj) {
  1340. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1341. },
  1342. lastDir: 0,
  1343. autoPush: false,
  1344. pushData: {}
  1345. }
  1346.  
  1347. // FIND OBJECTS BY ID/SID:
  1348. function findID(tmpObj, tmp) {
  1349. return tmpObj.find((THIS) => THIS.id == tmp);
  1350. }
  1351.  
  1352. function findSID(tmpObj, tmp) {
  1353. return tmpObj.find((THIS) => THIS.sid == tmp);
  1354. }
  1355.  
  1356. function findPlayerByID(id) {
  1357. return findID(players, id);
  1358. }
  1359.  
  1360. function findPlayerBySID(sid) {
  1361. return findSID(players, sid);
  1362. }
  1363.  
  1364. function findAIBySID(sid) {
  1365. return findSID(ais, sid);
  1366. }
  1367.  
  1368. function findObjectBySid(sid) {
  1369. return findSID(gameObjects, sid);
  1370. }
  1371.  
  1372. function findProjectileBySid(sid) {
  1373. return findSID(gameObjects, sid);
  1374. }
  1375.  
  1376. let adCard = getEl("adCard");
  1377. adCard.remove();
  1378. let promoImageHolder = getEl("promoImgHolder");
  1379. promoImageHolder.remove();
  1380.  
  1381. let chatButton = getEl("chatButton");
  1382. chatButton.remove();
  1383. let gameCanvas = getEl("gameCanvas");
  1384. let mainContext = gameCanvas.getContext("2d");
  1385. let mapDisplay = getEl("mapDisplay");
  1386. let mapContext = mapDisplay.getContext("2d");
  1387. mapDisplay.width = 300;
  1388. mapDisplay.height = 300;
  1389. let storeMenu = getEl("storeMenu");
  1390. let storeHolder = getEl("storeHolder");
  1391. let upgradeHolder = getEl("upgradeHolder");
  1392. let upgradeCounter = getEl("upgradeCounter");
  1393. let chatBox = getEl("chatBox");
  1394. chatBox.autocomplete = "off";
  1395. chatBox.style.textAlign = "center";
  1396. chatBox.style.width = "18em";
  1397. let chatHolder = getEl("chatHolder");
  1398. let actionBar = getEl("actionBar");
  1399. let leaderboardData = getEl("leaderboardData");
  1400. let itemInfoHolder = getEl("itemInfoHolder");
  1401. let menuCardHolder = getEl("menuCardHolder");
  1402. let mainMenu = getEl("mainMenu");
  1403. getEl("mainMenu").style.backgroundImage = "url('https://cdn.discordapp.com/attachments/1198742281755316317/1202991399532896347/wallpaper.jpg?ex=65cf780c&is=65bd030c&hm=c6311b336f8438208363736b853fa27c7508a0f76a67834df50dc176812cb14c&')";
  1404. let diedText = getEl("diedText");
  1405. let screenWidth;
  1406. let screenHeight;
  1407. let maxScreenWidth = config.maxScreenWidth;
  1408. let maxScreenHeight = config.maxScreenHeight;
  1409. let pixelDensity = 1;
  1410. let delta;
  1411. let now;
  1412. let lastUpdate = performance.now();
  1413. let camX;
  1414. let camY;
  1415. let tmpDir;
  1416. let mouseX = 0;
  1417. let mouseY = 0;
  1418. let allianceMenu = getEl("allianceMenu");
  1419. let waterMult = 1;
  1420. let waterPlus = 0;
  1421.  
  1422. let outlineColor = "#525252";
  1423. let darkOutlineColor = "#3d3f42";
  1424. let outlineWidth = 5.5;
  1425.  
  1426. let firstSetup = true;
  1427. let keys = {};
  1428. let moveKeys = {
  1429. 87: [0, -1],
  1430. 38: [0, -1],
  1431. 83: [0, 1],
  1432. 40: [0, 1],
  1433. 65: [-1, 0],
  1434. 37: [-1, 0],
  1435. 68: [1, 0],
  1436. 39: [1, 0],
  1437. };
  1438. let attackState = 0;
  1439. let inGame = false;
  1440.  
  1441. let macro = {};
  1442. let mills = {
  1443. place: 0,
  1444. placeSpawnPads: 0
  1445. };
  1446. let lastDir;
  1447.  
  1448. let lastLeaderboardData = [];
  1449.  
  1450. // ON LOAD:
  1451. let inWindow = true;
  1452. window.onblur = function() {
  1453. inWindow = false;
  1454. };
  1455. window.onfocus = function() {
  1456. inWindow = true;
  1457. if (player && player.alive) {
  1458. // resetMoveDir();
  1459. }
  1460. };
  1461. let ms = {
  1462. avg: 0,
  1463. max: 0,
  1464. min: 0,
  1465. delay: 0
  1466. }
  1467. function pingSocketResponse() {
  1468. let pingTime = window.pingTime;
  1469. const pingDisplay = document.getElementById("pingDisplay")
  1470. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1471. if (pingTime > ms.max || isNaN(ms.max)) {
  1472. ms.max = pingTime;
  1473. }
  1474. if (pingTime < ms.min || isNaN(ms.min)) {
  1475. ms.min = pingTime;
  1476. }
  1477.  
  1478. // if (pingTime >= 90) {
  1479. // doAutoQ = true;
  1480. // } else {
  1481. // doAutoQ = false;
  1482. // }
  1483. }
  1484.  
  1485. let placeVisible = [];
  1486.  
  1487. /** CLASS CODES */
  1488.  
  1489. class Utils {
  1490. constructor() {
  1491.  
  1492. // MATH UTILS:
  1493. let mathABS = Math.abs,
  1494. mathCOS = Math.cos,
  1495. mathSIN = Math.sin,
  1496. mathPOW = Math.pow,
  1497. mathSQRT = Math.sqrt,
  1498. mathATAN2 = Math.atan2,
  1499. mathPI = Math.PI;
  1500.  
  1501. let _this = this;
  1502.  
  1503. // GLOBAL UTILS:
  1504. this.round = function(n, v) {
  1505. return Math.round(n * v) / v;
  1506. };
  1507. this.toRad = function(angle) {
  1508. return angle * (mathPI / 180);
  1509. };
  1510. this.toAng = function(radian) {
  1511. return radian / (mathPI / 180);
  1512. };
  1513. this.randInt = function(min, max) {
  1514. return Math.floor(Math.random() * (max - min + 1)) + min;
  1515. };
  1516. this.randFloat = function(min, max) {
  1517. return Math.random() * (max - min + 1) + min;
  1518. };
  1519. this.lerp = function(value1, value2, amount) {
  1520. return value1 + (value2 - value1) * amount;
  1521. };
  1522. this.decel = function(val, cel) {
  1523. if (val > 0)
  1524. val = Math.max(0, val - cel);
  1525. else if (val < 0)
  1526. val = Math.min(0, val + cel);
  1527. return val;
  1528. };
  1529. this.getDistance = function(x1, y1, x2, y2) {
  1530. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1531. };
  1532. this.getDist = function(tmp1, tmp2, type1, type2) {
  1533. let tmpXY1 = {
  1534. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1535. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1536. };
  1537. let tmpXY2 = {
  1538. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1539. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1540. };
  1541. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1542. };
  1543. this.getDirection = function(x1, y1, x2, y2) {
  1544. return mathATAN2(y1 - y2, x1 - x2);
  1545. };
  1546. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1547. let tmpXY1 = {
  1548. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1549. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1550. };
  1551. let tmpXY2 = {
  1552. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1553. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1554. };
  1555. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1556. };
  1557. this.getAngleDist = function(a, b) {
  1558. let p = mathABS(b - a) % (mathPI * 2);
  1559. return (p > mathPI ? (mathPI * 2) - p : p);
  1560. };
  1561. this.isNumber = function(n) {
  1562. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1563. };
  1564. this.isString = function(s) {
  1565. return (s && typeof s == "string");
  1566. };
  1567. this.kFormat = function(num) {
  1568. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1569. };
  1570. this.sFormat = function(num) {
  1571. let fixs = [{
  1572. num: 1e3,
  1573. string: "k"
  1574. },
  1575. {
  1576. num: 1e6,
  1577. string: "m"
  1578. },
  1579. {
  1580. num: 1e9,
  1581. string: "b"
  1582. },
  1583. {
  1584. num: 1e12,
  1585. string: "q"
  1586. }
  1587. ].reverse();
  1588. let sp = fixs.find(v => num >= v.num);
  1589. if (!sp) return num;
  1590. return (num / sp.num).toFixed(1) + sp.string;
  1591. };
  1592. this.capitalizeFirst = function(string) {
  1593. return string.charAt(0).toUpperCase() + string.slice(1);
  1594. };
  1595. this.fixTo = function(n, v) {
  1596. return parseFloat(n.toFixed(v));
  1597. };
  1598. this.sortByPoints = function(a, b) {
  1599. return parseFloat(b.points) - parseFloat(a.points);
  1600. };
  1601. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1602. let minX = x1;
  1603. let maxX = x2;
  1604. if (x1 > x2) {
  1605. minX = x2;
  1606. maxX = x1;
  1607. }
  1608. if (maxX > recX2)
  1609. maxX = recX2;
  1610. if (minX < recX)
  1611. minX = recX;
  1612. if (minX > maxX)
  1613. return false;
  1614. let minY = y1;
  1615. let maxY = y2;
  1616. let dx = x2 - x1;
  1617. if (Math.abs(dx) > 0.0000001) {
  1618. let a = (y2 - y1) / dx;
  1619. let b = y1 - a * x1;
  1620. minY = a * minX + b;
  1621. maxY = a * maxX + b;
  1622. }
  1623. if (minY > maxY) {
  1624. let tmp = maxY;
  1625. maxY = minY;
  1626. minY = tmp;
  1627. }
  1628. if (maxY > recY2)
  1629. maxY = recY2;
  1630. if (minY < recY)
  1631. minY = recY;
  1632. if (minY > maxY)
  1633. return false;
  1634. return true;
  1635. };
  1636. this.containsPoint = function(element, x, y) {
  1637. let bounds = element.getBoundingClientRect();
  1638. let left = bounds.left + window.scrollX;
  1639. let top = bounds.top + window.scrollY;
  1640. let width = bounds.width;
  1641. let height = bounds.height;
  1642.  
  1643. let insideHorizontal = x > left && x < left + width;
  1644. let insideVertical = y > top && y < top + height;
  1645. return insideHorizontal && insideVertical;
  1646. };
  1647. this.mousifyTouchEvent = function(event) {
  1648. let touch = event.changedTouches[0];
  1649. event.screenX = touch.screenX;
  1650. event.screenY = touch.screenY;
  1651. event.clientX = touch.clientX;
  1652. event.clientY = touch.clientY;
  1653. event.pageX = touch.pageX;
  1654. event.pageY = touch.pageY;
  1655. };
  1656. this.hookTouchEvents = function(element, skipPrevent) {
  1657. let preventDefault = !skipPrevent;
  1658. let isHovering = false;
  1659. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1660. let passive = false;
  1661. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1662. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1663. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1664. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1665. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1666.  
  1667. function touchStart(e) {
  1668. _this.mousifyTouchEvent(e);
  1669. window.setUsingTouch(true);
  1670. if (preventDefault) {
  1671. e.preventDefault();
  1672. e.stopPropagation();
  1673. }
  1674. if (element.onmouseover)
  1675. element.onmouseover(e);
  1676. isHovering = true;
  1677. }
  1678.  
  1679. function touchMove(e) {
  1680. _this.mousifyTouchEvent(e);
  1681. window.setUsingTouch(true);
  1682. if (preventDefault) {
  1683. e.preventDefault();
  1684. e.stopPropagation();
  1685. }
  1686. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1687. if (!isHovering) {
  1688. if (element.onmouseover)
  1689. element.onmouseover(e);
  1690. isHovering = true;
  1691. }
  1692. } else {
  1693. if (isHovering) {
  1694. if (element.onmouseout)
  1695. element.onmouseout(e);
  1696. isHovering = false;
  1697. }
  1698. }
  1699. }
  1700.  
  1701. function touchEnd(e) {
  1702. _this.mousifyTouchEvent(e);
  1703. window.setUsingTouch(true);
  1704. if (preventDefault) {
  1705. e.preventDefault();
  1706. e.stopPropagation();
  1707. }
  1708. if (isHovering) {
  1709. if (element.onclick)
  1710. element.onclick(e);
  1711. if (element.onmouseout)
  1712. element.onmouseout(e);
  1713. isHovering = false;
  1714. }
  1715. }
  1716. };
  1717. this.removeAllChildren = function(element) {
  1718. while (element.hasChildNodes()) {
  1719. element.removeChild(element.lastChild);
  1720. }
  1721. };
  1722. this.generateElement = function(config) {
  1723. let element = document.createElement(config.tag || "div");
  1724.  
  1725. function bind(configValue, elementValue) {
  1726. if (config[configValue])
  1727. element[elementValue] = config[configValue];
  1728. }
  1729. bind("text", "textContent");
  1730. bind("html", "innerHTML");
  1731. bind("class", "className");
  1732. for (let key in config) {
  1733. switch (key) {
  1734. case "tag":
  1735. case "text":
  1736. case "html":
  1737. case "class":
  1738. case "style":
  1739. case "hookTouch":
  1740. case "parent":
  1741. case "children":
  1742. continue;
  1743. default:
  1744. break;
  1745. }
  1746. element[key] = config[key];
  1747. }
  1748. if (element.onclick)
  1749. element.onclick = this.checkTrusted(element.onclick);
  1750. if (element.onmouseover)
  1751. element.onmouseover = this.checkTrusted(element.onmouseover);
  1752. if (element.onmouseout)
  1753. element.onmouseout = this.checkTrusted(element.onmouseout);
  1754. if (config.style) {
  1755. element.style.cssText = config.style;
  1756. }
  1757. if (config.hookTouch) {
  1758. this.hookTouchEvents(element);
  1759. }
  1760. if (config.parent) {
  1761. config.parent.appendChild(element);
  1762. }
  1763. if (config.children) {
  1764. for (let i = 0; i < config.children.length; i++) {
  1765. element.appendChild(config.children[i]);
  1766. }
  1767. }
  1768. return element;
  1769. };
  1770. this.checkTrusted = function(callback) {
  1771. return function(ev) {
  1772. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1773. callback(ev);
  1774. } else {
  1775. //console.error("Event is not trusted.", ev);
  1776. }
  1777. };
  1778. };
  1779. this.randomString = function(length) {
  1780. let text = "";
  1781. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1782. for (let i = 0; i < length; i++) {
  1783. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1784. }
  1785. return text;
  1786. };
  1787. this.countInArray = function(array, val) {
  1788. let count = 0;
  1789. for (let i = 0; i < array.length; i++) {
  1790. if (array[i] === val) count++;
  1791. }
  1792. return count;
  1793. };
  1794. this.hexToRgb = function(hex) {
  1795. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1796. };
  1797. this.getRgb = function(r, g, b) {
  1798. return [r / 255, g / 255, b / 255].join(", ");
  1799. };
  1800. }
  1801. };
  1802. class Animtext {
  1803. // ANIMATED TEXT:
  1804. constructor() {
  1805. // INIT:
  1806. this.init = function(x, y, scale, speed, life, text, color) {
  1807. (this.x = x),
  1808. (this.y = y),
  1809. (this.color = color),
  1810. (this.scale = scale*3.5),
  1811. (this.weight = 50);
  1812. (this.startScale = this.scale * 1.2),
  1813. (this.maxScale = 1.5 * scale),
  1814. (this.minScale = 0.5 * scale),
  1815. (this.scaleSpeed = 0.7),
  1816. (this.speed = speed),
  1817. (this.speedMax = speed),
  1818. (this.life = life),
  1819. (this.maxLife = life),
  1820. (this.text = text),
  1821. this.movSpeed = speed;
  1822. };
  1823.  
  1824. // UPDATE:
  1825. this.update = function(delta) {
  1826. if(this.life){
  1827. this.life -= delta;
  1828. if(this.scaleSpeed != -0.35){
  1829. this.y -= this.speed * delta;
  1830. // (this.x += this.speed * delta);
  1831. } else {
  1832. this.y -= this.speed * delta;
  1833. }
  1834. this.scale -= .8;
  1835. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  1836. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  1837. if(this.scale >= this.maxScale){
  1838. this.scale = this.maxScale;
  1839. this.scaleSpeed *= -.5;
  1840. this.speed = this.speed * .75;
  1841. };
  1842. this.life <= 0 && (this.life = 0)
  1843. };
  1844. };
  1845.  
  1846. // RENDER:
  1847. this.render = function(ctxt, xOff, yOff) {
  1848. ctxt.lineWidth = 10;
  1849. ctxt.strokeStyle = darkOutlineColor; //"black";
  1850. ctxt.fillStyle = this.color;
  1851. ctxt.globalAlpha = 1;
  1852. ctxt.font = this.scale + "px HammerSmith One";
  1853. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1854. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1855. ctxt.globalAlpha = 1;
  1856. };
  1857. }
  1858. };
  1859. class Textmanager {
  1860. // TEXT MANAGER:
  1861. constructor() {
  1862. this.texts = [];
  1863. this.stack = [];
  1864.  
  1865. // UPDATE:
  1866. this.update = function(delta, ctxt, xOff, yOff) {
  1867. ctxt.textBaseline = "middle";
  1868. ctxt.textAlign = "center";
  1869. for (let i = 0; i < this.texts.length; ++i) {
  1870. if (this.texts[i].life) {
  1871. this.texts[i].update(delta);
  1872. this.texts[i].render(ctxt, xOff, yOff);
  1873. }
  1874. }
  1875. };
  1876.  
  1877. // SHOW TEXT:
  1878. this.showText = function(x, y, scale, speed, life, text, color) {
  1879. let tmpText;
  1880. for (let i = 0; i < this.texts.length; ++i) {
  1881. if (!this.texts[i].life) {
  1882. tmpText = this.texts[i];
  1883. break;
  1884. }
  1885. }
  1886. if (!tmpText) {
  1887. tmpText = new Animtext();
  1888. this.texts.push(tmpText);
  1889. }
  1890. tmpText.init(x, y, scale, speed, life, text, color);
  1891. };
  1892. }
  1893. }
  1894.  
  1895. class GameObject {
  1896. constructor(sid) {
  1897. this.sid = sid;
  1898.  
  1899. // INIT:
  1900. this.init = function(x, y, dir, scale, type, data, owner) {
  1901. data = data || {};
  1902. this.sentTo = {};
  1903. this.gridLocations = [];
  1904. this.active = true;
  1905. this.render = true;
  1906. this.doUpdate = data.doUpdate;
  1907. this.x = x;
  1908. this.y = y;
  1909. this.dir = dir;
  1910. this.lastDir = dir;
  1911. this.xWiggle = 0;
  1912. this.yWiggle = 0;
  1913. this.visScale = scale;
  1914. this.scale = scale;
  1915. this.type = type;
  1916. this.id = data.id;
  1917. this.owner = owner;
  1918. this.name = data.name;
  1919. this.isItem = (this.id != undefined);
  1920. this.group = data.group;
  1921. this.maxHealth = data.health;
  1922. this.health = this.maxHealth;
  1923. this.layer = 2;
  1924. if (this.group != undefined) {
  1925. this.layer = this.group.layer;
  1926. } else if (this.type == 0) {
  1927. this.layer = 3;
  1928. } else if (this.type == 2) {
  1929. this.layer = 0;
  1930. } else if (this.type == 4) {
  1931. this.layer = -1;
  1932. }
  1933. this.colDiv = data.colDiv || 1;
  1934. this.blocker = data.blocker;
  1935. this.ignoreCollision = data.ignoreCollision;
  1936. this.dontGather = data.dontGather;
  1937. this.hideFromEnemy = data.hideFromEnemy;
  1938. this.friction = data.friction;
  1939. this.projDmg = data.projDmg;
  1940. this.dmg = data.dmg;
  1941. this.pDmg = data.pDmg;
  1942. this.pps = data.pps;
  1943. this.zIndex = data.zIndex || 0;
  1944. this.turnSpeed = data.turnSpeed;
  1945. this.req = data.req;
  1946. this.trap = data.trap;
  1947. this.healCol = data.healCol;
  1948. this.teleport = data.teleport;
  1949. this.boostSpeed = data.boostSpeed;
  1950. this.projectile = data.projectile;
  1951. this.shootRange = data.shootRange;
  1952. this.shootRate = data.shootRate;
  1953. this.shootCount = this.shootRate;
  1954. this.spawnPoint = data.spawnPoint;
  1955. this.onNear = 0;
  1956. this.breakObj = false;
  1957. this.alpha = data.alpha || 1;
  1958. this.maxAlpha = data.alpha || 1;
  1959. this.damaged = 0;
  1960. };
  1961.  
  1962. // GET HIT:
  1963. this.changeHealth = function(amount, doer) {
  1964. this.health += amount;
  1965. return (this.health <= 0);
  1966. };
  1967.  
  1968. // GET SCALE:
  1969. this.getScale = function(sM, ig) {
  1970. sM = sM || 1;
  1971. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1972. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1973. };
  1974.  
  1975. // VISIBLE TO PLAYER:
  1976. this.visibleToPlayer = function(player) {
  1977. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1978. (this.owner.team && player.team == this.owner.team)));
  1979. };
  1980.  
  1981. // UPDATE:
  1982. this.update = function(delta) {
  1983. if (this.active) {
  1984. if (this.xWiggle) {
  1985. this.xWiggle *= Math.pow(0.99, delta);
  1986. }
  1987. if (this.yWiggle) {
  1988. this.yWiggle *= Math.pow(0.99, delta);
  1989. }
  1990. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  1991. if (d2 > 0.01) {
  1992. this.dir += d2 / 5;
  1993. } else {
  1994. this.dir = this.lastDir;
  1995. }
  1996. } else {
  1997. if (this.alive) {
  1998. this.alpha -= delta / (200 / this.maxAlpha);
  1999. this.visScale += delta / (this.scale / 2.5);
  2000. if (this.alpha <= 0) {
  2001. this.alpha = 0;
  2002. this.alive = false;
  2003. }
  2004. }
  2005. }
  2006. };
  2007.  
  2008. // CHECK TEAM:
  2009. this.isTeamObject = function(tmpObj) {
  2010. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2011. };
  2012. }
  2013. }
  2014. class Items {
  2015. constructor() {
  2016. // ITEM GROUPS:
  2017. this.groups = [{
  2018. id: 0,
  2019. name: "food",
  2020. layer: 0
  2021. }, {
  2022. id: 1,
  2023. name: "walls",
  2024. place: true,
  2025. limit: 30,
  2026. layer: 0
  2027. }, {
  2028. id: 2,
  2029. name: "spikes",
  2030. place: true,
  2031. limit: 15,
  2032. layer: 0
  2033. }, {
  2034. id: 3,
  2035. name: "mill",
  2036. place: true,
  2037. limit: 7,
  2038. layer: 1
  2039. }, {
  2040. id: 4,
  2041. name: "mine",
  2042. place: true,
  2043. limit: 1,
  2044. layer: 0
  2045. }, {
  2046. id: 5,
  2047. name: "trap",
  2048. place: true,
  2049. limit: 6,
  2050. layer: -1
  2051. }, {
  2052. id: 6,
  2053. name: "booster",
  2054. place: true,
  2055. limit: 12,
  2056. layer: -1
  2057. }, {
  2058. id: 7,
  2059. name: "turret",
  2060. place: true,
  2061. limit: 2,
  2062. layer: 1
  2063. }, {
  2064. id: 8,
  2065. name: "watchtower",
  2066. place: true,
  2067. limit: 12,
  2068. layer: 1
  2069. }, {
  2070. id: 9,
  2071. name: "buff",
  2072. place: true,
  2073. limit: 4,
  2074. layer: -1
  2075. }, {
  2076. id: 10,
  2077. name: "spawn",
  2078. place: true,
  2079. limit: 1,
  2080. layer: -1
  2081. }, {
  2082. id: 11,
  2083. name: "sapling",
  2084. place: true,
  2085. limit: 2,
  2086. layer: 0
  2087. }, {
  2088. id: 12,
  2089. name: "blocker",
  2090. place: true,
  2091. limit: 3,
  2092. layer: -1
  2093. }, {
  2094. id: 13,
  2095. name: "teleporter",
  2096. place: true,
  2097. limit: 2,
  2098. layer: -1
  2099. }];
  2100.  
  2101. // PROJECTILES:
  2102. this.projectiles = [{
  2103. indx: 0,
  2104. layer: 0,
  2105. src: "arrow_1",
  2106. dmg: 25,
  2107. speed: 1.6,
  2108. scale: 103,
  2109. range: 1000
  2110. }, {
  2111. indx: 1,
  2112. layer: 1,
  2113. dmg: 25,
  2114. scale: 20
  2115. }, {
  2116. indx: 0,
  2117. layer: 0,
  2118. src: "arrow_1",
  2119. dmg: 35,
  2120. speed: 2.5,
  2121. scale: 103,
  2122. range: 1200
  2123. }, {
  2124. indx: 0,
  2125. layer: 0,
  2126. src: "arrow_1",
  2127. dmg: 30,
  2128. speed: 2,
  2129. scale: 103,
  2130. range: 1200
  2131. }, {
  2132. indx: 1,
  2133. layer: 1,
  2134. dmg: 16,
  2135. scale: 20
  2136. }, {
  2137. indx: 0,
  2138. layer: 0,
  2139. src: "bullet_1",
  2140. dmg: 50,
  2141. speed: 3.6,
  2142. scale: 160,
  2143. range: 1400
  2144. }];
  2145.  
  2146. // WEAPONS:
  2147. this.weapons = [{
  2148. id: 0,
  2149. type: 0,
  2150. name: "tool hammer",
  2151. desc: "tool for gathering all resources",
  2152. src: "hammer_1",
  2153. length: 140,
  2154. width: 140,
  2155. xOff: -3,
  2156. yOff: 18,
  2157. dmg: 25,
  2158. range: 65,
  2159. gather: 1,
  2160. speed: 300
  2161. }, {
  2162. id: 1,
  2163. type: 0,
  2164. age: 2,
  2165. name: "hand axe",
  2166. desc: "gathers resources at a higher rate",
  2167. src: "axe_1",
  2168. length: 140,
  2169. width: 140,
  2170. xOff: 3,
  2171. yOff: 24,
  2172. dmg: 30,
  2173. spdMult: 1,
  2174. range: 70,
  2175. gather: 2,
  2176. speed: 400
  2177. }, {
  2178. id: 2,
  2179. type: 0,
  2180. age: 8,
  2181. pre: 1,
  2182. name: "great axe",
  2183. desc: "deal more damage and gather more resources",
  2184. src: "great_axe_1",
  2185. length: 140,
  2186. width: 140,
  2187. xOff: -8,
  2188. yOff: 25,
  2189. dmg: 35,
  2190. spdMult: 1,
  2191. range: 75,
  2192. gather: 4,
  2193. speed: 400
  2194. }, {
  2195. id: 3,
  2196. type: 0,
  2197. age: 2,
  2198. name: "short sword",
  2199. desc: "increased attack power but slower move speed",
  2200. src: "sword_1",
  2201. iPad: 1.3,
  2202. length: 130,
  2203. width: 210,
  2204. xOff: -8,
  2205. yOff: 46,
  2206. dmg: 35,
  2207. spdMult: 0.85,
  2208. range: 110,
  2209. gather: 1,
  2210. speed: 300
  2211. }, {
  2212. id: 4,
  2213. type: 0,
  2214. age: 8,
  2215. pre: 3,
  2216. name: "katana",
  2217. desc: "greater range and damage",
  2218. src: "samurai_1",
  2219. iPad: 1.3,
  2220. length: 130,
  2221. width: 210,
  2222. xOff: -8,
  2223. yOff: 59,
  2224. dmg: 40,
  2225. spdMult: 0.8,
  2226. range: 118,
  2227. gather: 1,
  2228. speed: 300
  2229. }, {
  2230. id: 5,
  2231. type: 0,
  2232. age: 2,
  2233. name: "polearm",
  2234. desc: "long range melee weapon",
  2235. src: "spear_1",
  2236. iPad: 1.3,
  2237. length: 130,
  2238. width: 210,
  2239. xOff: -8,
  2240. yOff: 53,
  2241. dmg: 45,
  2242. knock: 0.2,
  2243. spdMult: 0.82,
  2244. range: 142,
  2245. gather: 1,
  2246. speed: 700
  2247. }, {
  2248. id: 6,
  2249. type: 0,
  2250. age: 2,
  2251. name: "bat",
  2252. desc: "fast long range melee weapon",
  2253. src: "bat_1",
  2254. iPad: 1.3,
  2255. length: 110,
  2256. width: 180,
  2257. xOff: -8,
  2258. yOff: 53,
  2259. dmg: 20,
  2260. knock: 0.7,
  2261. range: 110,
  2262. gather: 1,
  2263. speed: 300
  2264. }, {
  2265. id: 7,
  2266. type: 0,
  2267. age: 2,
  2268. name: "daggers",
  2269. desc: "really fast short range weapon",
  2270. src: "dagger_1",
  2271. iPad: 0.8,
  2272. length: 110,
  2273. width: 110,
  2274. xOff: 18,
  2275. yOff: 0,
  2276. dmg: 20,
  2277. knock: 0.1,
  2278. range: 65,
  2279. gather: 1,
  2280. hitSlow: 0.1,
  2281. spdMult: 1.13,
  2282. speed: 100
  2283. }, {
  2284. id: 8,
  2285. type: 0,
  2286. age: 2,
  2287. name: "stick",
  2288. desc: "great for gathering but very weak",
  2289. src: "stick_1",
  2290. length: 140,
  2291. width: 140,
  2292. xOff: 3,
  2293. yOff: 24,
  2294. dmg: 1,
  2295. spdMult: 1,
  2296. range: 70,
  2297. gather: 7,
  2298. speed: 400
  2299. }, {
  2300. id: 9,
  2301. type: 1,
  2302. age: 6,
  2303. name: "hunting bow",
  2304. desc: "bow used for ranged combat and hunting",
  2305. src: "bow_1",
  2306. req: ["wood", 4],
  2307. length: 120,
  2308. width: 120,
  2309. xOff: -6,
  2310. yOff: 0,
  2311. Pdmg: 25,
  2312. projectile: 0,
  2313. spdMult: 0.75,
  2314. speed: 600
  2315. }, {
  2316. id: 10,
  2317. type: 1,
  2318. age: 6,
  2319. name: "great hammer",
  2320. desc: "hammer used for destroying structures",
  2321. src: "great_hammer_1",
  2322. length: 140,
  2323. width: 140,
  2324. xOff: -9,
  2325. yOff: 25,
  2326. dmg: 10,
  2327. Pdmg: 10,
  2328. spdMult: 0.88,
  2329. range: 75,
  2330. sDmg: 7.5,
  2331. gather: 1,
  2332. speed: 400
  2333. }, {
  2334. id: 11,
  2335. type: 1,
  2336. age: 6,
  2337. name: "wooden shield",
  2338. desc: "blocks projectiles and reduces melee damage",
  2339. src: "shield_1",
  2340. length: 120,
  2341. width: 120,
  2342. shield: 0.2,
  2343. xOff: 6,
  2344. yOff: 0,
  2345. Pdmg: 0,
  2346. spdMult: 0.7
  2347. }, {
  2348. id: 12,
  2349. type: 1,
  2350. age: 8,
  2351. pre: 9,
  2352. name: "crossbow",
  2353. desc: "deals more damage and has greater range",
  2354. src: "crossbow_1",
  2355. req: ["wood", 5],
  2356. aboveHand: true,
  2357. armS: 0.75,
  2358. length: 120,
  2359. width: 120,
  2360. xOff: -4,
  2361. yOff: 0,
  2362. Pdmg: 35,
  2363. projectile: 2,
  2364. spdMult: 0.7,
  2365. speed: 700
  2366. }, {
  2367. id: 13,
  2368. type: 1,
  2369. age: 9,
  2370. pre: 12,
  2371. name: "repeater crossbow",
  2372. desc: "high firerate crossbow with reduced damage",
  2373. src: "crossbow_2",
  2374. req: ["wood", 10],
  2375. aboveHand: true,
  2376. armS: 0.75,
  2377. length: 120,
  2378. width: 120,
  2379. xOff: -4,
  2380. yOff: 0,
  2381. Pdmg: 30,
  2382. projectile: 3,
  2383. spdMult: 0.7,
  2384. speed: 230
  2385. }, {
  2386. id: 14,
  2387. type: 1,
  2388. age: 6,
  2389. name: "mc grabby",
  2390. desc: "steals resources from enemies",
  2391. src: "grab_1",
  2392. length: 130,
  2393. width: 210,
  2394. xOff: -8,
  2395. yOff: 53,
  2396. dmg: 0,
  2397. Pdmg: 0,
  2398. steal: 250,
  2399. knock: 0.2,
  2400. spdMult: 1.05,
  2401. range: 125,
  2402. gather: 0,
  2403. speed: 700
  2404. }, {
  2405. id: 15,
  2406. type: 1,
  2407. age: 9,
  2408. pre: 12,
  2409. name: "musket",
  2410. desc: "slow firerate but high damage and range",
  2411. src: "musket_1",
  2412. req: ["stone", 10],
  2413. aboveHand: true,
  2414. rec: 0.35,
  2415. armS: 0.6,
  2416. hndS: 0.3,
  2417. hndD: 1.6,
  2418. length: 205,
  2419. width: 205,
  2420. xOff: 25,
  2421. yOff: 0,
  2422. Pdmg: 50,
  2423. projectile: 5,
  2424. hideProjectile: true,
  2425. spdMult: 0.6,
  2426. speed: 1500
  2427. }];
  2428.  
  2429. // ITEMS:
  2430. this.list = [{
  2431. group: this.groups[0],
  2432. name: "apple",
  2433. desc: "restores 20 health when consumed",
  2434. req: ["food", 10],
  2435. consume: function(doer) {
  2436. return doer.changeHealth(20, doer);
  2437. },
  2438. scale: 22,
  2439. holdOffset: 15,
  2440. healing: 20,
  2441. itemID: 0,
  2442. itemAID: 16,
  2443. }, {
  2444. age: 3,
  2445. group: this.groups[0],
  2446. name: "cookie",
  2447. desc: "restores 40 health when consumed",
  2448. req: ["food", 15],
  2449. consume: function(doer) {
  2450. return doer.changeHealth(40, doer);
  2451. },
  2452. scale: 27,
  2453. holdOffset: 15,
  2454. healing: 40,
  2455. itemID: 1,
  2456. itemAID: 17,
  2457. }, {
  2458. age: 7,
  2459. group: this.groups[0],
  2460. name: "cheese",
  2461. desc: "restores 30 health and another 50 over 5 seconds",
  2462. req: ["food", 25],
  2463. consume: function(doer) {
  2464. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2465. doer.dmgOverTime.dmg = -10;
  2466. doer.dmgOverTime.doer = doer;
  2467. doer.dmgOverTime.time = 5;
  2468. return true;
  2469. }
  2470. return false;
  2471. },
  2472. scale: 27,
  2473. holdOffset: 15,
  2474. healing: 30,
  2475. itemID: 2,
  2476. itemAID: 18,
  2477. }, {
  2478. group: this.groups[1],
  2479. name: "wood wall",
  2480. desc: "provides protection for your village",
  2481. req: ["wood", 10],
  2482. projDmg: true,
  2483. health: 380,
  2484. scale: 50,
  2485. holdOffset: 20,
  2486. placeOffset: -5,
  2487. itemID: 3,
  2488. itemAID: 19,
  2489. }, {
  2490. age: 3,
  2491. group: this.groups[1],
  2492. name: "stone wall",
  2493. desc: "provides improved protection for your village",
  2494. req: ["stone", 25],
  2495. health: 900,
  2496. scale: 50,
  2497. holdOffset: 20,
  2498. placeOffset: -5,
  2499. itemID: 4,
  2500. itemAID: 20,
  2501. }, {
  2502. age: 7,
  2503. group: this.groups[1],
  2504. name: "castle wall",
  2505. desc: "provides powerful protection for your village",
  2506. req: ["stone", 35],
  2507. health: 1500,
  2508. scale: 52,
  2509. holdOffset: 20,
  2510. placeOffset: -5,
  2511. itemID: 5,
  2512. itemAID: 21,
  2513. }, {
  2514. group: this.groups[2],
  2515. name: "spikes",
  2516. desc: "damages enemies when they touch them",
  2517. req: ["wood", 20, "stone", 5],
  2518. health: 400,
  2519. dmg: 20,
  2520. scale: 49,
  2521. spritePadding: -23,
  2522. holdOffset: 8,
  2523. placeOffset: -5,
  2524. itemID: 6,
  2525. itemAID: 22,
  2526. shadow: {
  2527. offsetX: 5, // Adjust the shadow's X offset as needed
  2528. offsetY: 5, // Adjust the shadow's Y offset as needed
  2529. blur: 20, // Adjust the shadow's blur as needed
  2530. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2531. }
  2532.  
  2533. }, {
  2534. age: 5,
  2535. group: this.groups[2],
  2536. name: "greater spikes",
  2537. desc: "damages enemies when they touch them",
  2538. req: ["wood", 30, "stone", 10],
  2539. health: 500,
  2540. dmg: 35,
  2541. scale: 52,
  2542. spritePadding: -23,
  2543. holdOffset: 8,
  2544. placeOffset: -5,
  2545. itemID: 7,
  2546. itemAID: 23,
  2547. }, {
  2548. age: 9,
  2549. group: this.groups[2],
  2550. name: "poison spikes",
  2551. desc: "poisons enemies when they touch them",
  2552. req: ["wood", 35, "stone", 15],
  2553. health: 600,
  2554. dmg: 30,
  2555. pDmg: 5,
  2556. scale: 52,
  2557. spritePadding: -23,
  2558. holdOffset: 8,
  2559. placeOffset: -5,
  2560. itemID: 8,
  2561. itemAID: 24,
  2562. }, {
  2563. age: 9,
  2564. group: this.groups[2],
  2565. name: "spinning spikes",
  2566. desc: "damages enemies when they touch them",
  2567. req: ["wood", 30, "stone", 20],
  2568. health: 500,
  2569. dmg: 45,
  2570. turnSpeed: 0.003,
  2571. scale: 52,
  2572. spritePadding: -23,
  2573. holdOffset: 8,
  2574. placeOffset: -5,
  2575. itemID: 9,
  2576. itemAID: 25,
  2577. }, {
  2578. group: this.groups[3],
  2579. name: "windmill",
  2580. desc: "generates gold over time",
  2581. req: ["wood", 50, "stone", 10],
  2582. health: 400,
  2583. pps: 1,
  2584. turnSpeed: 0.0016,
  2585. spritePadding: 25,
  2586. iconLineMult: 12,
  2587. scale: 45,
  2588. holdOffset: 20,
  2589. placeOffset: 5,
  2590. itemID: 10,
  2591. itemAID: 26,
  2592. }, {
  2593. age: 5,
  2594. group: this.groups[3],
  2595. name: "faster windmill",
  2596. desc: "generates more gold over time",
  2597. req: ["wood", 60, "stone", 20],
  2598. health: 500,
  2599. pps: 1.5,
  2600. turnSpeed: 0.0025,
  2601. spritePadding: 25,
  2602. iconLineMult: 12,
  2603. scale: 47,
  2604. holdOffset: 20,
  2605. placeOffset: 5,
  2606. itemID: 11,
  2607. itemAID: 27,
  2608. }, {
  2609. age: 8,
  2610. group: this.groups[3],
  2611. name: "power mill",
  2612. desc: "generates more gold over time",
  2613. req: ["wood", 100, "stone", 50],
  2614. health: 800,
  2615. pps: 2,
  2616. turnSpeed: 0.005,
  2617. spritePadding: 25,
  2618. iconLineMult: 12,
  2619. scale: 47,
  2620. holdOffset: 20,
  2621. placeOffset: 5,
  2622. itemID: 12,
  2623. itemAID: 28,
  2624. }, {
  2625. age: 5,
  2626. group: this.groups[4],
  2627. type: 2,
  2628. name: "mine",
  2629. desc: "allows you to mine stone",
  2630. req: ["wood", 20, "stone", 100],
  2631. iconLineMult: 12,
  2632. scale: 65,
  2633. holdOffset: 20,
  2634. placeOffset: 0,
  2635. itemID: 13,
  2636. itemAID: 29,
  2637. }, {
  2638. age: 5,
  2639. group: this.groups[11],
  2640. type: 0,
  2641. name: "sapling",
  2642. desc: "allows you to farm wood",
  2643. req: ["wood", 150],
  2644. iconLineMult: 12,
  2645. colDiv: 0.5,
  2646. scale: 110,
  2647. holdOffset: 50,
  2648. placeOffset: -15,
  2649. itemID: 14,
  2650. itemAID: 30,
  2651. }, {
  2652. age: 4,
  2653. group: this.groups[5],
  2654. name: "pit trap",
  2655. desc: "pit that traps enemies if they walk over it",
  2656. req: ["wood", 30, "stone", 30],
  2657. trap: true,
  2658. ignoreCollision: true,
  2659. hideFromEnemy: true,
  2660. health: 500,
  2661. colDiv: 0.2,
  2662. scale: 50,
  2663. holdOffset: 20,
  2664. placeOffset: -5,
  2665. alpha: 0.6,
  2666. itemID: 15,
  2667. itemAID: 31,
  2668. }, {
  2669. age: 4,
  2670. group: this.groups[6],
  2671. name: "boost pad",
  2672. desc: "provides boost when stepped on",
  2673. req: ["stone", 20, "wood", 5],
  2674. ignoreCollision: true,
  2675. boostSpeed: 1.5,
  2676. health: 150,
  2677. colDiv: 0.7,
  2678. scale: 45,
  2679. holdOffset: 20,
  2680. placeOffset: -5,
  2681. itemID: 16,
  2682. itemAID: 32,
  2683. }, {
  2684. age: 7,
  2685. group: this.groups[7],
  2686. doUpdate: true,
  2687. name: "turret",
  2688. desc: "defensive structure that shoots at enemies",
  2689. req: ["wood", 200, "stone", 150],
  2690. health: 800,
  2691. projectile: 1,
  2692. shootRange: 700,
  2693. shootRate: 2200,
  2694. scale: 43,
  2695. holdOffset: 20,
  2696. placeOffset: -5,
  2697. itemID: 17,
  2698. itemAID: 33,
  2699. }, {
  2700. age: 7,
  2701. group: this.groups[8],
  2702. name: "platform",
  2703. desc: "platform to shoot over walls and cross over water",
  2704. req: ["wood", 20],
  2705. ignoreCollision: true,
  2706. zIndex: 1,
  2707. health: 300,
  2708. scale: 43,
  2709. holdOffset: 20,
  2710. placeOffset: -5,
  2711. itemID: 18,
  2712. itemAID: 34,
  2713. }, {
  2714. age: 7,
  2715. group: this.groups[9],
  2716. name: "healing pad",
  2717. desc: "standing on it will slowly heal you",
  2718. req: ["wood", 30, "food", 10],
  2719. ignoreCollision: true,
  2720. healCol: 15,
  2721. health: 400,
  2722. colDiv: 0.7,
  2723. scale: 45,
  2724. holdOffset: 20,
  2725. placeOffset: -5,
  2726. itemID: 19,
  2727. itemAID: 35,
  2728. }, {
  2729. age: 9,
  2730. group: this.groups[10],
  2731. name: "spawn pad",
  2732. desc: "you will spawn here when you die but it will dissapear",
  2733. req: ["wood", 100, "stone", 100],
  2734. health: 400,
  2735. ignoreCollision: true,
  2736. spawnPoint: true,
  2737. scale: 45,
  2738. holdOffset: 20,
  2739. placeOffset: -5,
  2740. itemID: 20,
  2741. itemAID: 36,
  2742. }, {
  2743. age: 7,
  2744. group: this.groups[12],
  2745. name: "blocker",
  2746. desc: "blocks building in radius",
  2747. req: ["wood", 30, "stone", 25],
  2748. ignoreCollision: true,
  2749. blocker: 300,
  2750. health: 400,
  2751. colDiv: 0.7,
  2752. scale: 45,
  2753. holdOffset: 20,
  2754. placeOffset: -5,
  2755. itemID: 21,
  2756. itemAID: 37,
  2757. }, {
  2758. age: 7,
  2759. group: this.groups[13],
  2760. name: "teleporter",
  2761. desc: "teleports you to a random point on the map",
  2762. req: ["wood", 60, "stone", 60],
  2763. ignoreCollision: true,
  2764. teleport: true,
  2765. health: 200,
  2766. colDiv: 0.7,
  2767. scale: 45,
  2768. holdOffset: 20,
  2769. placeOffset: -5,
  2770. itemID: 22,
  2771. itemAID: 38
  2772. }];
  2773.  
  2774. // CHECK ITEM ID:
  2775. this.checkItem = {
  2776. index: function(id, myItems) {
  2777. 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 :
  2778. 5 :
  2779. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2780. 6 :
  2781. undefined;
  2782. }
  2783. }
  2784.  
  2785. // ASSIGN IDS:
  2786. for (let i = 0; i < this.list.length; ++i) {
  2787. this.list[i].id = i;
  2788. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2789. }
  2790.  
  2791. // TROLOLOLOL:
  2792. if (typeof window !== "undefined") {
  2793. function shuffle(a) {
  2794. for (let i = a.length - 1; i > 0; i--) {
  2795. const j = Math.floor(Math.random() * (i + 1));
  2796. [a[i], a[j]] = [a[j], a[i]];
  2797. }
  2798. return a;
  2799. }
  2800. //shuffle(this.list);
  2801. }
  2802. }
  2803. }
  2804. class Objectmanager {
  2805. constructor(GameObject, liztobj, UTILS, config, players, server) {
  2806. let mathFloor = Math.floor,
  2807. mathABS = Math.abs,
  2808. mathCOS = Math.cos,
  2809. mathSIN = Math.sin,
  2810. mathPOW = Math.pow,
  2811. mathSQRT = Math.sqrt;
  2812.  
  2813. this.ignoreAdd = false;
  2814. this.hitObj = [];
  2815.  
  2816. // DISABLE OBJ:
  2817. this.disableObj = function(obj) {
  2818. obj.active = false;
  2819. };
  2820.  
  2821. // ADD NEW:
  2822. let tmpObj;
  2823. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2824. tmpObj = findObjectBySid(sid);
  2825. if (!tmpObj) {
  2826. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2827. if (!tmpObj) {
  2828. tmpObj = new GameObject(sid);
  2829. gameObjects.push(tmpObj);
  2830. }
  2831. }
  2832. if (setSID) {
  2833. tmpObj.sid = sid;
  2834. }
  2835. tmpObj.init(x, y, dir, s, type, data, owner);
  2836. };
  2837.  
  2838. // DISABLE BY SID:
  2839. this.disableBySid = function(sid) {
  2840. let find = findObjectBySid(sid);
  2841. if (find) {
  2842. this.disableObj(find);
  2843. }
  2844. };
  2845.  
  2846. // REMOVE ALL FROM PLAYER:
  2847. this.removeAllItems = function(sid, server) {
  2848. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2849. };
  2850.  
  2851. // CHECK IF PLACABLE:
  2852. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2853. 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)));
  2854. if (cantPlace) return false;
  2855. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2856. return true;
  2857. };
  2858.  
  2859. }
  2860. }
  2861. class Projectile {
  2862. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2863.  
  2864. // INIT:
  2865. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2866. this.active = true;
  2867. this.tickActive = true;
  2868. this.indx = indx;
  2869. this.x = x;
  2870. this.y = y;
  2871. this.x2 = x;
  2872. this.y2 = y;
  2873. this.dir = dir;
  2874. this.skipMov = true;
  2875. this.speed = spd;
  2876. this.dmg = dmg;
  2877. this.scale = scl;
  2878. this.range = rng;
  2879. this.r2 = rng;
  2880. this.owner = owner;
  2881. };
  2882.  
  2883. // UPDATE:
  2884. this.update = function(delta) {
  2885. if (this.active) {
  2886. let tmpSpeed = this.speed * delta;
  2887. if (!this.skipMov) {
  2888. this.x += tmpSpeed * Math.cos(this.dir);
  2889. this.y += tmpSpeed * Math.sin(this.dir);
  2890. this.range -= tmpSpeed;
  2891. if (this.range <= 0) {
  2892. this.x += this.range * Math.cos(this.dir);
  2893. this.y += this.range * Math.sin(this.dir);
  2894. tmpSpeed = 1;
  2895. this.range = 0;
  2896. this.active = false;
  2897. }
  2898. } else {
  2899. this.skipMov = false;
  2900. }
  2901. }
  2902. };
  2903. this.tickUpdate = function(delta) {
  2904. if (this.tickActive) {
  2905. let tmpSpeed = this.speed * delta;
  2906. if (!this.skipMov) {
  2907. this.x2 += tmpSpeed * Math.cos(this.dir);
  2908. this.y2 += tmpSpeed * Math.sin(this.dir);
  2909. this.r2 -= tmpSpeed;
  2910. if (this.r2 <= 0) {
  2911. this.x2 += this.r2 * Math.cos(this.dir);
  2912. this.y2 += this.r2 * Math.sin(this.dir);
  2913. tmpSpeed = 1;
  2914. this.r2 = 0;
  2915. this.tickActive = false;
  2916. }
  2917. } else {
  2918. this.skipMov = false;
  2919. }
  2920. }
  2921. };
  2922. }
  2923. };
  2924. class Store {
  2925. constructor() {
  2926. // STORE HATS:
  2927. this.hats = [{
  2928. id: 45,
  2929. name: "Shame!",
  2930. dontSell: true,
  2931. price: 0,
  2932. scale: 120,
  2933. desc: "hacks are for winners"
  2934. }, {
  2935. id: 51,
  2936. name: "Moo Cap",
  2937. price: 0,
  2938. scale: 120,
  2939. desc: "coolest mooer around"
  2940. }, {
  2941. id: 50,
  2942. name: "Apple Cap",
  2943. price: 0,
  2944. scale: 120,
  2945. desc: "apple farms remembers"
  2946. }, {
  2947. id: 28,
  2948. name: "Moo Head",
  2949. price: 0,
  2950. scale: 120,
  2951. desc: "no effect"
  2952. }, {
  2953. id: 29,
  2954. name: "Pig Head",
  2955. price: 0,
  2956. scale: 120,
  2957. desc: "no effect"
  2958. }, {
  2959. id: 30,
  2960. name: "Fluff Head",
  2961. price: 0,
  2962. scale: 120,
  2963. desc: "no effect"
  2964. }, {
  2965. id: 36,
  2966. name: "Pandou Head",
  2967. price: 0,
  2968. scale: 120,
  2969. desc: "no effect"
  2970. }, {
  2971. id: 37,
  2972. name: "Bear Head",
  2973. price: 0,
  2974. scale: 120,
  2975. desc: "no effect"
  2976. }, {
  2977. id: 38,
  2978. name: "Monkey Head",
  2979. price: 0,
  2980. scale: 120,
  2981. desc: "no effect"
  2982. }, {
  2983. id: 44,
  2984. name: "Polar Head",
  2985. price: 0,
  2986. scale: 120,
  2987. desc: "no effect"
  2988. }, {
  2989. id: 35,
  2990. name: "Fez Hat",
  2991. price: 0,
  2992. scale: 120,
  2993. desc: "no effect"
  2994. }, {
  2995. id: 42,
  2996. name: "Enigma Hat",
  2997. price: 0,
  2998. scale: 120,
  2999. desc: "join the enigma army"
  3000. }, {
  3001. id: 43,
  3002. name: "Blitz Hat",
  3003. price: 0,
  3004. scale: 120,
  3005. desc: "hey everybody i'm blitz"
  3006. }, {
  3007. id: 49,
  3008. name: "Bob XIII Hat",
  3009. price: 0,
  3010. scale: 120,
  3011. desc: "like and subscribe"
  3012. }, {
  3013. id: 57,
  3014. name: "Pumpkin",
  3015. price: 50,
  3016. scale: 120,
  3017. desc: "Spooooky"
  3018. }, {
  3019. id: 8,
  3020. name: "Bummle Hat",
  3021. price: 100,
  3022. scale: 120,
  3023. desc: "no effect"
  3024. }, {
  3025. id: 2,
  3026. name: "Straw Hat",
  3027. price: 500,
  3028. scale: 120,
  3029. desc: "no effect"
  3030. }, {
  3031. id: 15,
  3032. name: "Winter Cap",
  3033. price: 600,
  3034. scale: 120,
  3035. desc: "allows you to move at normal speed in snow",
  3036. coldM: 1
  3037. }, {
  3038. id: 5,
  3039. name: "Cowboy Hat",
  3040. price: 1000,
  3041. scale: 120,
  3042. desc: "no effect"
  3043. }, {
  3044. id: 4,
  3045. name: "Ranger Hat",
  3046. price: 2000,
  3047. scale: 120,
  3048. desc: "no effect"
  3049. }, {
  3050. id: 18,
  3051. name: "Explorer Hat",
  3052. price: 2000,
  3053. scale: 120,
  3054. desc: "no effect"
  3055. }, {
  3056. id: 31,
  3057. name: "Flipper Hat",
  3058. price: 2500,
  3059. scale: 120,
  3060. desc: "have more control while in water",
  3061. watrImm: true
  3062. }, {
  3063. id: 1,
  3064. name: "Marksman Cap",
  3065. price: 3000,
  3066. scale: 120,
  3067. desc: "increases arrow speed and range",
  3068. aMlt: 1.3
  3069. }, {
  3070. id: 10,
  3071. name: "Bush Gear",
  3072. price: 3000,
  3073. scale: 160,
  3074. desc: "allows you to disguise yourself as a bush"
  3075. }, {
  3076. id: 48,
  3077. name: "Halo",
  3078. price: 3000,
  3079. scale: 120,
  3080. desc: "no effect"
  3081. }, {
  3082. id: 6,
  3083. name: "Soldier Helmet",
  3084. price: 4000,
  3085. scale: 120,
  3086. desc: "reduces damage taken but slows movement",
  3087. spdMult: 0.94,
  3088. dmgMult: 0.75
  3089. }, {
  3090. id: 23,
  3091. name: "Anti Venom Gear",
  3092. price: 4000,
  3093. scale: 120,
  3094. desc: "makes you immune to poison",
  3095. poisonRes: 1
  3096. }, {
  3097. id: 13,
  3098. name: "Medic Gear",
  3099. price: 5000,
  3100. scale: 110,
  3101. desc: "slowly regenerates health over time",
  3102. healthRegen: 3
  3103. }, {
  3104. id: 9,
  3105. name: "Miners Helmet",
  3106. price: 5000,
  3107. scale: 120,
  3108. desc: "earn 1 extra gold per resource",
  3109. extraGold: 1
  3110. }, {
  3111. id: 32,
  3112. name: "Musketeer Hat",
  3113. price: 5000,
  3114. scale: 120,
  3115. desc: "reduces cost of projectiles",
  3116. projCost: 0.5
  3117. }, {
  3118. id: 7,
  3119. name: "Bull Helmet",
  3120. price: 6000,
  3121. scale: 120,
  3122. desc: "increases damage done but drains health",
  3123. healthRegen: -5,
  3124. dmgMultO: 1.5,
  3125. spdMult: 0.96
  3126. }, {
  3127. id: 22,
  3128. name: "Emp Helmet",
  3129. price: 6000,
  3130. scale: 120,
  3131. desc: "turrets won't attack but you move slower",
  3132. antiTurret: 1,
  3133. spdMult: 0.7
  3134. }, {
  3135. id: 12,
  3136. name: "Booster Hat",
  3137. price: 6000,
  3138. scale: 120,
  3139. desc: "increases your movement speed",
  3140. spdMult: 1.16
  3141. }, {
  3142. id: 26,
  3143. name: "Barbarian Armor",
  3144. price: 8000,
  3145. scale: 120,
  3146. desc: "knocks back enemies that attack you",
  3147. dmgK: 0.6
  3148. }, {
  3149. id: 21,
  3150. name: "Plague Mask",
  3151. price: 10000,
  3152. scale: 120,
  3153. desc: "melee attacks deal poison damage",
  3154. poisonDmg: 5,
  3155. poisonTime: 6
  3156. }, {
  3157. id: 46,
  3158. name: "Bull Mask",
  3159. price: 10000,
  3160. scale: 120,
  3161. desc: "bulls won't target you unless you attack them",
  3162. bullRepel: 1
  3163. }, {
  3164. id: 14,
  3165. name: "Windmill Hat",
  3166. topSprite: true,
  3167. price: 10000,
  3168. scale: 120,
  3169. desc: "generates points while worn",
  3170. pps: 1.5
  3171. }, {
  3172. id: 11,
  3173. name: "Spike Gear",
  3174. topSprite: true,
  3175. price: 10000,
  3176. scale: 120,
  3177. desc: "deal damage to players that damage you",
  3178. dmg: 0.45
  3179. }, {
  3180. id: 53,
  3181. name: "Turret Gear",
  3182. topSprite: true,
  3183. price: 10000,
  3184. scale: 120,
  3185. desc: "you become a walking turret",
  3186. turret: {
  3187. proj: 1,
  3188. range: 700,
  3189. rate: 2500
  3190. },
  3191. spdMult: 0.7
  3192. }, {
  3193. id: 20,
  3194. name: "Samurai Armor",
  3195. price: 12000,
  3196. scale: 120,
  3197. desc: "increased attack speed and fire rate",
  3198. atkSpd: 0.78
  3199. }, {
  3200. id: 58,
  3201. name: "Dark Knight",
  3202. price: 12000,
  3203. scale: 120,
  3204. desc: "restores health when you deal damage",
  3205. healD: 0.4
  3206. }, {
  3207. id: 27,
  3208. name: "Scavenger Gear",
  3209. price: 15000,
  3210. scale: 120,
  3211. desc: "earn double points for each kill",
  3212. kScrM: 2
  3213. }, {
  3214. id: 40,
  3215. name: "Tank Gear",
  3216. price: 15000,
  3217. scale: 120,
  3218. desc: "increased damage to buildings but slower movement",
  3219. spdMult: 0.3,
  3220. bDmg: 3.3
  3221. }, {
  3222. id: 52,
  3223. name: "Thief Gear",
  3224. price: 15000,
  3225. scale: 120,
  3226. desc: "steal half of a players gold when you kill them",
  3227. goldSteal: 0.5
  3228. }, {
  3229. id: 55,
  3230. name: "Bloodthirster",
  3231. price: 20000,
  3232. scale: 120,
  3233. desc: "Restore Health when dealing damage. And increased damage",
  3234. healD: 0.25,
  3235. dmgMultO: 1.2,
  3236. }, {
  3237. id: 56,
  3238. name: "Assassin Gear",
  3239. price: 20000,
  3240. scale: 120,
  3241. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3242. noEat: true,
  3243. spdMult: 1.1,
  3244. invisTimer: 1000
  3245. }];
  3246.  
  3247. // STORE ACCESSORIES:
  3248. this.accessories = [{
  3249. id: 12,
  3250. name: "Snowball",
  3251. price: 1000,
  3252. scale: 105,
  3253. xOff: 18,
  3254. desc: "no effect"
  3255. }, {
  3256. id: 9,
  3257. name: "Tree Cape",
  3258. price: 1000,
  3259. scale: 90,
  3260. desc: "no effect"
  3261. }, {
  3262. id: 10,
  3263. name: "Stone Cape",
  3264. price: 1000,
  3265. scale: 90,
  3266. desc: "no effect"
  3267. }, {
  3268. id: 3,
  3269. name: "Cookie Cape",
  3270. price: 1500,
  3271. scale: 90,
  3272. desc: "no effect"
  3273. }, {
  3274. id: 8,
  3275. name: "Cow Cape",
  3276. price: 2000,
  3277. scale: 90,
  3278. desc: "no effect"
  3279. }, {
  3280. id: 11,
  3281. name: "Monkey Tail",
  3282. price: 2000,
  3283. scale: 97,
  3284. xOff: 25,
  3285. desc: "Super speed but reduced damage",
  3286. spdMult: 1.35,
  3287. dmgMultO: 0.2
  3288. }, {
  3289. id: 17,
  3290. name: "Apple Basket",
  3291. price: 3000,
  3292. scale: 80,
  3293. xOff: 12,
  3294. desc: "slowly regenerates health over time",
  3295. healthRegen: 1
  3296. }, {
  3297. id: 6,
  3298. name: "Winter Cape",
  3299. price: 3000,
  3300. scale: 90,
  3301. desc: "no effect"
  3302. }, {
  3303. id: 4,
  3304. name: "Skull Cape",
  3305. price: 4000,
  3306. scale: 90,
  3307. desc: "no effect"
  3308. }, {
  3309. id: 5,
  3310. name: "Dash Cape",
  3311. price: 5000,
  3312. scale: 90,
  3313. desc: "no effect"
  3314. }, {
  3315. id: 2,
  3316. name: "Dragon Cape",
  3317. price: 6000,
  3318. scale: 90,
  3319. desc: "no effect"
  3320. }, {
  3321. id: 1,
  3322. name: "Super Cape",
  3323. price: 8000,
  3324. scale: 90,
  3325. desc: "no effect"
  3326. }, {
  3327. id: 7,
  3328. name: "Troll Cape",
  3329. price: 8000,
  3330. scale: 90,
  3331. desc: "no effect"
  3332. }, {
  3333. id: 14,
  3334. name: "Thorns",
  3335. price: 10000,
  3336. scale: 115,
  3337. xOff: 20,
  3338. desc: "no effect"
  3339. }, {
  3340. id: 15,
  3341. name: "Blockades",
  3342. price: 10000,
  3343. scale: 95,
  3344. xOff: 15,
  3345. desc: "no effect"
  3346. }, {
  3347. id: 20,
  3348. name: "Devils Tail",
  3349. price: 10000,
  3350. scale: 95,
  3351. xOff: 20,
  3352. desc: "no effect"
  3353. }, {
  3354. id: 16,
  3355. name: "Sawblade",
  3356. price: 12000,
  3357. scale: 90,
  3358. spin: true,
  3359. xOff: 0,
  3360. desc: "deal damage to players that damage you",
  3361. dmg: 0.15
  3362. }, {
  3363. id: 13,
  3364. name: "Angel Wings",
  3365. price: 15000,
  3366. scale: 138,
  3367. xOff: 22,
  3368. desc: "slowly regenerates health over time",
  3369. healthRegen: 3
  3370. }, {
  3371. id: 19,
  3372. name: "Shadow Wings",
  3373. price: 15000,
  3374. scale: 138,
  3375. xOff: 22,
  3376. desc: "increased movement speed",
  3377. spdMult: 1.1
  3378. }, {
  3379. id: 18,
  3380. name: "Blood Wings",
  3381. price: 20000,
  3382. scale: 178,
  3383. xOff: 26,
  3384. desc: "restores health when you deal damage",
  3385. healD: 0.2
  3386. }, {
  3387. id: 21,
  3388. name: "Corrupt X Wings",
  3389. price: 20000,
  3390. scale: 178,
  3391. xOff: 26,
  3392. desc: "deal damage to players that damage you",
  3393. dmg: 0.25
  3394. }];
  3395. }
  3396. };
  3397. class ProjectileManager {
  3398. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3399. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3400. let tmpData = items.projectiles[indx];
  3401. let tmpProj;
  3402. for (let i = 0; i < projectiles.length; ++i) {
  3403. if (!projectiles[i].active) {
  3404. tmpProj = projectiles[i];
  3405. break;
  3406. }
  3407. }
  3408. if (!tmpProj) {
  3409. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3410. tmpProj.sid = projectiles.length;
  3411. projectiles.push(tmpProj);
  3412. }
  3413. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3414. tmpProj.ignoreObj = ignoreObj;
  3415. tmpProj.layer = layer || tmpData.layer;
  3416. tmpProj.inWindow = inWindow;
  3417. tmpProj.src = tmpData.src;
  3418. return tmpProj;
  3419. };
  3420. }
  3421. };
  3422. class AiManager {
  3423.  
  3424. // AI MANAGER:
  3425. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3426.  
  3427. // AI TYPES:
  3428. this.aiTypes = [{
  3429. id: 0,
  3430. src: "cow_1",
  3431. killScore: 150,
  3432. health: 500,
  3433. weightM: 0.8,
  3434. speed: 0.00095,
  3435. turnSpeed: 0.001,
  3436. scale: 72,
  3437. drop: ["food", 50]
  3438. }, {
  3439. id: 1,
  3440. src: "pig_1",
  3441. killScore: 200,
  3442. health: 800,
  3443. weightM: 0.6,
  3444. speed: 0.00085,
  3445. turnSpeed: 0.001,
  3446. scale: 72,
  3447. drop: ["food", 80]
  3448. }, {
  3449. id: 2,
  3450. name: "Bull",
  3451. src: "bull_2",
  3452. hostile: true,
  3453. dmg: 20,
  3454. killScore: 1000,
  3455. health: 1800,
  3456. weightM: 0.5,
  3457. speed: 0.00094,
  3458. turnSpeed: 0.00074,
  3459. scale: 78,
  3460. viewRange: 800,
  3461. chargePlayer: true,
  3462. drop: ["food", 100]
  3463. }, {
  3464. id: 3,
  3465. name: "Bully",
  3466. src: "bull_1",
  3467. hostile: true,
  3468. dmg: 20,
  3469. killScore: 2000,
  3470. health: 2800,
  3471. weightM: 0.45,
  3472. speed: 0.001,
  3473. turnSpeed: 0.0008,
  3474. scale: 90,
  3475. viewRange: 900,
  3476. chargePlayer: true,
  3477. drop: ["food", 400]
  3478. }, {
  3479. id: 4,
  3480. name: "Wolf",
  3481. src: "wolf_1",
  3482. hostile: true,
  3483. dmg: 8,
  3484. killScore: 500,
  3485. health: 300,
  3486. weightM: 0.45,
  3487. speed: 0.001,
  3488. turnSpeed: 0.002,
  3489. scale: 84,
  3490. viewRange: 800,
  3491. chargePlayer: true,
  3492. drop: ["food", 200]
  3493. }, {
  3494. id: 5,
  3495. name: "Quack",
  3496. src: "chicken_1",
  3497. dmg: 8,
  3498. killScore: 2000,
  3499. noTrap: true,
  3500. health: 300,
  3501. weightM: 0.2,
  3502. speed: 0.0018,
  3503. turnSpeed: 0.006,
  3504. scale: 70,
  3505. drop: ["food", 100]
  3506. }, {
  3507. id: 6,
  3508. name: "MOOSTAFA",
  3509. nameScale: 50,
  3510. src: "enemy",
  3511. hostile: true,
  3512. dontRun: true,
  3513. fixedSpawn: true,
  3514. spawnDelay: 60000,
  3515. noTrap: true,
  3516. colDmg: 100,
  3517. dmg: 40,
  3518. killScore: 8000,
  3519. health: 18000,
  3520. weightM: 0.4,
  3521. speed: 0.0007,
  3522. turnSpeed: 0.01,
  3523. scale: 80,
  3524. spriteMlt: 1.8,
  3525. leapForce: 0.9,
  3526. viewRange: 1000,
  3527. hitRange: 210,
  3528. hitDelay: 1000,
  3529. chargePlayer: true,
  3530. drop: ["food", 100]
  3531. }, {
  3532. id: 7,
  3533. name: "Treasure",
  3534. hostile: true,
  3535. nameScale: 35,
  3536. src: "crate_1",
  3537. fixedSpawn: true,
  3538. spawnDelay: 120000,
  3539. colDmg: 200,
  3540. killScore: 5000,
  3541. health: 20000,
  3542. weightM: 0.1,
  3543. speed: 0.0,
  3544. turnSpeed: 0.0,
  3545. scale: 70,
  3546. spriteMlt: 1.0
  3547. }, {
  3548. id: 8,
  3549. name: "MOOFIE",
  3550. src: "wolf_2",
  3551. hostile: true,
  3552. fixedSpawn: true,
  3553. dontRun: true,
  3554. hitScare: 4,
  3555. spawnDelay: 30000,
  3556. noTrap: true,
  3557. nameScale: 35,
  3558. dmg: 10,
  3559. colDmg: 100,
  3560. killScore: 3000,
  3561. health: 7000,
  3562. weightM: 0.45,
  3563. speed: 0.0015,
  3564. turnSpeed: 0.002,
  3565. scale: 90,
  3566. viewRange: 800,
  3567. chargePlayer: true,
  3568. drop: ["food", 1000]
  3569. }];
  3570.  
  3571. // SPAWN AI:
  3572. this.spawn = function(x, y, dir, index) {
  3573. let tmpObj = ais.find((tmp) => !tmp.active);
  3574. if (!tmpObj) {
  3575. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3576. ais.push(tmpObj);
  3577. }
  3578. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3579. return tmpObj;
  3580. };
  3581. }
  3582.  
  3583. };
  3584. class AI {
  3585. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3586. this.sid = sid;
  3587. this.isAI = true;
  3588. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3589.  
  3590. // INIT:
  3591. this.init = function(x, y, dir, index, data) {
  3592. this.x = x;
  3593. this.y = y;
  3594. this.startX = data.fixedSpawn ? x : null;
  3595. this.startY = data.fixedSpawn ? y : null;
  3596. this.xVel = 0;
  3597. this.yVel = 0;
  3598. this.zIndex = 0;
  3599. this.dir = dir;
  3600. this.dirPlus = 0;
  3601. this.showName = 'aaa';
  3602. this.index = index;
  3603. this.src = data.src;
  3604. if (data.name) this.name = data.name;
  3605. this.weightM = data.weightM;
  3606. this.speed = data.speed;
  3607. this.killScore = data.killScore;
  3608. this.turnSpeed = data.turnSpeed;
  3609. this.scale = data.scale;
  3610. this.maxHealth = data.health;
  3611. this.leapForce = data.leapForce;
  3612. this.health = this.maxHealth;
  3613. this.chargePlayer = data.chargePlayer;
  3614. this.viewRange = data.viewRange;
  3615. this.drop = data.drop;
  3616. this.dmg = data.dmg;
  3617. this.hostile = data.hostile;
  3618. this.dontRun = data.dontRun;
  3619. this.hitRange = data.hitRange;
  3620. this.hitDelay = data.hitDelay;
  3621. this.hitScare = data.hitScare;
  3622. this.spriteMlt = data.spriteMlt;
  3623. this.nameScale = data.nameScale;
  3624. this.colDmg = data.colDmg;
  3625. this.noTrap = data.noTrap;
  3626. this.spawnDelay = data.spawnDelay;
  3627. this.hitWait = 0;
  3628. this.waitCount = 1000;
  3629. this.moveCount = 0;
  3630. this.targetDir = 0;
  3631. this.active = true;
  3632. this.alive = true;
  3633. this.runFrom = null;
  3634. this.chargeTarget = null;
  3635. this.dmgOverTime = {};
  3636. };
  3637.  
  3638. let tmpRatio = 0;
  3639. let animIndex = 0;
  3640. this.animate = function(delta) {
  3641. if (this.animTime > 0) {
  3642. this.animTime -= delta;
  3643. if (this.animTime <= 0) {
  3644. this.animTime = 0;
  3645. this.dirPlus = 0;
  3646. tmpRatio = 0;
  3647. animIndex = 0;
  3648. } else {
  3649. if (animIndex == 0) {
  3650. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3651. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3652. if (tmpRatio >= 1) {
  3653. tmpRatio = 1;
  3654. animIndex = 1;
  3655. }
  3656. } else {
  3657. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3658. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3659. }
  3660. }
  3661. }
  3662. };
  3663.  
  3664. // ANIMATION:
  3665. this.startAnim = function() {
  3666. this.animTime = this.animSpeed = 600;
  3667. this.targetAngle = Math.PI * 0.8;
  3668. tmpRatio = 0;
  3669. animIndex = 0;
  3670. };
  3671.  
  3672. };
  3673.  
  3674. };
  3675. class addCh {
  3676. constructor(x, y, chat, tmpObj) {
  3677. this.x = x;
  3678. this.y = y;
  3679. this.alpha = 0;
  3680. this.active = true;
  3681. this.alive = false;
  3682. this.chat = chat;
  3683. this.owner = tmpObj;
  3684. };
  3685. };
  3686. class DeadPlayer {
  3687. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3688. this.x = x;
  3689. this.y = y;
  3690. this.lastDir = dir;
  3691. this.dir = dir + Math.PI;
  3692. this.buildIndex = buildIndex;
  3693. this.weaponIndex = weaponIndex;
  3694. this.weaponVariant = weaponVariant;
  3695. this.skinColor = skinColor;
  3696. this.scale = scale;
  3697. this.visScale = 0;
  3698. this.name = name;
  3699. this.alpha = 1;
  3700. this.active = true;
  3701. this.animate = function(delta) {
  3702. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3703. if (d2 > 0.01) {
  3704. this.dir += d2 / 20;
  3705. } else {
  3706. this.dir = this.lastDir;
  3707. }
  3708. if (this.visScale < this.scale) {
  3709. this.visScale += delta / (this.scale / 2);
  3710. if (this.visScale >= this.scale) {
  3711. this.visScale = this.scale;
  3712. }
  3713. }
  3714. this.alpha -= delta / 30000;
  3715. if (this.alpha <= 0) {
  3716. this.alpha = 0;
  3717. this.active = false;
  3718. }
  3719. }
  3720. }
  3721. };
  3722. class Player {
  3723. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3724. this.id = id;
  3725. this.sid = sid;
  3726. this.tmpScore = 0;
  3727. this.team = null;
  3728. this.latestSkin = 0;
  3729. this.oldSkinIndex = 0;
  3730. this.skinIndex = 0;
  3731. this.latestTail = 0;
  3732. this.oldTailIndex = 0;
  3733. this.tailIndex = 0;
  3734. this.hitTime = 0;
  3735. this.lastHit = 0;
  3736. this.showName = 'NOOO';
  3737. this.tails = {};
  3738. for (let i = 0; i < accessories.length; ++i) {
  3739. if (accessories[i].price <= 0)
  3740. this.tails[accessories[i].id] = 1;
  3741. }
  3742. this.skins = {};
  3743. for (let i = 0; i < hats.length; ++i) {
  3744. if (hats[i].price <= 0)
  3745. this.skins[hats[i].id] = 1;
  3746. }
  3747. this.points = 0;
  3748. this.dt = 0;
  3749. this.hidden = false;
  3750. this.itemCounts = {};
  3751. this.isPlayer = true;
  3752. this.pps = 0;
  3753. this.moveDir = undefined;
  3754. this.skinRot = 0;
  3755. this.lastPing = 0;
  3756. this.iconIndex = 0;
  3757. this.skinColor = 0;
  3758. this.dist2 = 0;
  3759. this.aim2 = 0;
  3760. this.maxSpeed = 1;
  3761. this.chat = {
  3762. message: null,
  3763. count: 0
  3764. };
  3765. this.circle = false;
  3766. this.cAngle = 0;
  3767. // SPAWN:
  3768. this.spawn = function(moofoll) {
  3769. this.attacked = false;
  3770. this.timeDamaged = 0;
  3771. this.timeHealed = 0;
  3772. this.pinge = 0;
  3773. this.millPlace = 'NOOO';
  3774. this.lastshamecount = 0;
  3775. this.death = false;
  3776. this.spinDir = 0;
  3777. this.sync = false;
  3778. this.antiBull = 0;
  3779. this.bullTimer = 0;
  3780. this.poisonTimer = 0;
  3781. this.active = true;
  3782. this.alive = true;
  3783. this.lockMove = false;
  3784. this.lockDir = false;
  3785. this.minimapCounter = 0;
  3786. this.chatCountdown = 0;
  3787. this.shameCount = 0;
  3788. this.shameTimer = 0;
  3789. this.sentTo = {};
  3790. this.gathering = 0;
  3791. this.gatherIndex = 0;
  3792. this.shooting = {};
  3793. this.shootIndex = 9;
  3794. this.autoGather = 0;
  3795. this.animTime = 0;
  3796. this.animSpeed = 0;
  3797. this.mouseState = 0;
  3798. this.buildIndex = -1;
  3799. this.weaponIndex = 0;
  3800. this.weaponCode = 0;
  3801. this.weaponVariant = 0;
  3802. this.primaryIndex = undefined;
  3803. this.secondaryIndex = undefined;
  3804. this.dmgOverTime = {};
  3805. this.noMovTimer = 0;
  3806. this.maxXP = 300;
  3807. this.XP = 0;
  3808. this.age = 1;
  3809. this.kills = 0;
  3810. this.upgrAge = 2;
  3811. this.upgradePoints = 0;
  3812. this.x = 0;
  3813. this.y = 0;
  3814. this.oldXY = {
  3815. x: 0,
  3816. y: 0
  3817. };
  3818. this.zIndex = 0;
  3819. this.xVel = 0;
  3820. this.yVel = 0;
  3821. this.slowMult = 1;
  3822. this.dir = 0;
  3823. this.dirPlus = 0;
  3824. this.targetDir = 0;
  3825. this.targetAngle = 0;
  3826. this.maxHealth = 100;
  3827. this.health = this.maxHealth;
  3828. this.oldHealth = this.maxHealth;
  3829. this.damaged = 0;
  3830. this.scale = config.playerScale;
  3831. this.speed = config.playerSpeed;
  3832. this.resetMoveDir();
  3833. this.resetResources(moofoll);
  3834. this.items = [0, 3, 6, 10];
  3835. this.weapons = [0];
  3836. this.shootCount = 0;
  3837. this.weaponXP = [];
  3838. this.reloads = {
  3839. 0: 0,
  3840. 1: 0,
  3841. 2: 0,
  3842. 3: 0,
  3843. 4: 0,
  3844. 5: 0,
  3845. 6: 0,
  3846. 7: 0,
  3847. 8: 0,
  3848. 9: 0,
  3849. 10: 0,
  3850. 11: 0,
  3851. 12: 0,
  3852. 13: 0,
  3853. 14: 0,
  3854. 15: 0,
  3855. 53: 0,
  3856. };
  3857. this.bowThreat = {
  3858. 9: 0,
  3859. 12: 0,
  3860. 13: 0,
  3861. 15: 0,
  3862. };
  3863. this.damageThreat = 0;
  3864. this.inTrap = false;
  3865. this.canEmpAnti = false;
  3866. this.empAnti = false;
  3867. this.soldierAnti = false;
  3868. this.poisonTick = 0;
  3869. this.bullTick = 0;
  3870. this.setPoisonTick = false;
  3871. this.setBullTick = false;
  3872. this.antiTimer = 2;
  3873. };
  3874.  
  3875. // RESET MOVE DIR:
  3876. this.resetMoveDir = function() {
  3877. this.moveDir = undefined;
  3878. };
  3879.  
  3880. // RESET RESOURCES:
  3881. this.resetResources = function(moofoll) {
  3882. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3883. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3884. }
  3885. };
  3886.  
  3887. // ADD ITEM:
  3888. this.getItemType = function(id) {
  3889. let findindx = this.items.findIndex((ids) => ids == id);
  3890. if (findindx != -1) {
  3891. return findindx;
  3892. } else {
  3893. return items.checkItem.index(id, this.items);
  3894. }
  3895. };
  3896.  
  3897. // SET DATA:
  3898. this.setData = function(data) {
  3899. this.id = data[0];
  3900. this.sid = data[1];
  3901. this.name = data[2];
  3902. this.x = data[3];
  3903. this.y = data[4];
  3904. this.dir = data[5];
  3905. this.health = data[6];
  3906. this.maxHealth = data[7];
  3907. this.scale = data[8];
  3908. this.skinColor = data[9];
  3909. };
  3910.  
  3911. // UPDATE POISON TICK:
  3912. this.updateTimer = function() {
  3913.  
  3914. this.bullTimer -= 1;
  3915. if (this.bullTimer <= 0) {
  3916. this.setBullTick = false;
  3917. this.bullTick = game.tick - 1;
  3918. this.bullTimer = config.serverUpdateRate;
  3919. }
  3920. this.poisonTimer -= 1;
  3921. if (this.poisonTimer <= 0) {
  3922. this.setPoisonTick = false;
  3923. this.poisonTick = game.tick - 1;
  3924. this.poisonTimer = config.serverUpdateRate;
  3925. }
  3926.  
  3927. };
  3928. this.update = function(delta) {
  3929. if (this.active) {
  3930.  
  3931. // MOVE:
  3932. let gear = {
  3933. skin: findID(hats, this.skinIndex),
  3934. tail: findID(accessories, this.tailIndex)
  3935. }
  3936. 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;
  3937. this.maxSpeed = spdMult;
  3938.  
  3939. }
  3940. };
  3941.  
  3942. let tmpRatio = 0;
  3943. let animIndex = 0;
  3944. this.animate = function(delta) {
  3945. if (this.animTime > 0) {
  3946. this.animTime -= delta;
  3947. if (this.animTime <= 0) {
  3948. this.animTime = 0;
  3949. this.dirPlus = 0;
  3950. tmpRatio = 0;
  3951. animIndex = 0;
  3952. } else {
  3953. if (animIndex == 0) {
  3954. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3955. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3956. if (tmpRatio >= 1) {
  3957. tmpRatio = 1;
  3958. animIndex = 1;
  3959. }
  3960. } else {
  3961. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3962. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3963. }
  3964. }
  3965. }
  3966. };
  3967.  
  3968. // GATHER ANIMATION:
  3969. this.startAnim = function(didHit, index) {
  3970. this.animTime = this.animSpeed = items.weapons[index].speed;
  3971. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3972. tmpRatio = 0;
  3973. animIndex = 0;
  3974. };
  3975.  
  3976. // CAN SEE:
  3977. this.canSee = function(other) {
  3978. if (!other) return false;
  3979. let dx = Math.abs(other.x - this.x) - other.scale;
  3980. let dy = Math.abs(other.y - this.y) - other.scale;
  3981. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3982. };
  3983.  
  3984. // SHAME SYSTEM:
  3985. this.judgeShame = function() {
  3986. this.lastshamecount = this.shameCount;
  3987. if (this.oldHealth < this.health) {
  3988. if (this.hitTime) {
  3989. let timeSinceHit = game.tick - this.hitTime;
  3990. this.lastHit = game.tick;
  3991. this.hitTime = 0;
  3992. if (timeSinceHit < 2) {
  3993. this.shameCount++;
  3994. } else {
  3995. this.shameCount = Math.max(0, this.shameCount - 2);
  3996. }
  3997. }
  3998. } else if (this.oldHealth > this.health) {
  3999. this.hitTime = game.tick;
  4000. }
  4001. };
  4002. this.addShameTimer = function() {
  4003. this.shameCount = 0;
  4004. this.shameTimer = 30;
  4005. let interval = setInterval(() => {
  4006. this.shameTimer--;
  4007. if (this.shameTimer <= 0) {
  4008. clearInterval(interval);
  4009. }
  4010. }, 1000);
  4011. };
  4012.  
  4013. // CHECK TEAM:
  4014. this.isTeam = function(tmpObj) {
  4015. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4016. };
  4017.  
  4018. // FOR THE PLAYER:
  4019. this.findAllianceBySid = function(sid) {
  4020. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4021. };
  4022. this.checkCanInsta = function(nobull) {
  4023. let totally = 0;
  4024. if (this.alive && inGame) {
  4025. let primary = {
  4026. weapon: this.weapons[0],
  4027. variant: this.primaryVariant,
  4028. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4029. };
  4030. let secondary = {
  4031. weapon: this.weapons[1],
  4032. variant: this.secondaryVariant,
  4033. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4034. };
  4035. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4036. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4037. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4038. totally += primary.dmg * pV * bull;
  4039. }
  4040. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4041. totally += secondary.dmg;
  4042. }
  4043. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4044. totally += 25;
  4045. }
  4046. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4047. return totally;
  4048. }
  4049. return 0;
  4050. };
  4051.  
  4052. // UPDATE WEAPON RELOAD:
  4053. this.manageReload = function() {
  4054. if (this.shooting[53]) {
  4055. this.shooting[53] = 0;
  4056. this.reloads[53] = (2500 - game.tickRate);
  4057. } else {
  4058. if (this.reloads[53] > 0) {
  4059. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4060. }
  4061. }
  4062.  
  4063. // PREPLACER
  4064. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4065. // place(2, getAttackDir());
  4066. let index = this.weaponIndex;
  4067. let nearObja = liztobj.filter((e) => (e.active || e.alive) && e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2) <= (items.weapons[player.weaponIndex].range + e.scale));
  4068. for(let i = 0; i < nearObja.length; i++) {
  4069. let aaa = nearObja[i];
  4070.  
  4071. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4072. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4073. if(aaa.health - (valaa) <= 0 && near.length) {
  4074. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4075. console.log("preplaced");
  4076. }
  4077. }
  4078. }
  4079.  
  4080. if (this.gathering || this.shooting[1]) {
  4081. if (this.gathering) {
  4082. this.gathering = 0;
  4083. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4084. this.attacked = true;
  4085. }
  4086. if (this.shooting[1]) {
  4087. this.shooting[1] = 0;
  4088. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4089. this.attacked = true;
  4090. }
  4091. } else {
  4092. this.attacked = false;
  4093. if (this.buildIndex < 0) {
  4094. if (this.reloads[this.weaponIndex] > 0) {
  4095. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4096. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4097. if (this == player) {
  4098. if (getEl("weaponGrind").checked) {
  4099. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4100. checkPlace(player.getItemType(22), i);
  4101. }
  4102. }
  4103. }
  4104. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4105. this.antiBull++;
  4106. game.tickBase(() => {
  4107. this.antiBull = 0;
  4108. }, 1);
  4109. }
  4110. }
  4111. }
  4112. }
  4113. };
  4114.  
  4115. // FOR ANTI INSTA:
  4116. this.addDamageThreat = function(tmpObj) {
  4117. let primary = {
  4118. weapon: this.primaryIndex,
  4119. variant: this.primaryVariant
  4120. };
  4121. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4122. let secondary = {
  4123. weapon: this.secondaryIndex,
  4124. variant: this.secondaryVariant
  4125. };
  4126. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4127. let bull = 1.5;
  4128. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4129. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4130. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4131. this.damageThreat += primary.dmg * pV * bull;
  4132. }
  4133. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4134. this.damageThreat += secondary.dmg * sV;
  4135. }
  4136. if (this.reloads[53] <= game.tickRate) {
  4137. this.damageThreat += 25;
  4138. }
  4139. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4140. if (!this.isTeam(tmpObj)) {
  4141. if (this.dist2 <= 300) {
  4142. tmpObj.damageThreat += this.damageThreat;
  4143. }
  4144. }
  4145. };
  4146.  
  4147. }
  4148. };
  4149.  
  4150. // SOME CODES:
  4151. function sendUpgrade(index) {
  4152. player.reloads[index] = 0;
  4153. packet("H", index);
  4154. }
  4155.  
  4156. function storeEquip(id, index) {
  4157. packet("c", 0, id, index);
  4158. }
  4159.  
  4160. function storeBuy(id, index) {
  4161. packet("c", 1, id, index);
  4162. }
  4163.  
  4164. function buyEquip(id, index) {
  4165. let nID = player.skins[6] ? 6 : 0;
  4166. if (player.alive && inGame) {
  4167. if (index == 0) {
  4168. if (player.skins[id]) {
  4169. if (player.latestSkin != id) {
  4170. packet("c", 0, id, 0);
  4171. }
  4172. } else {
  4173. if (configs.autoBuyEquip) {
  4174. let find = findID(hats, id);
  4175. if (find) {
  4176. if (player.points >= find.price) {
  4177. packet("c", 1, id, 0);
  4178. packet("c", 0, id, 0);
  4179. } else {
  4180. if (player.latestSkin != nID) {
  4181. packet("c", 0, nID, 0);
  4182. }
  4183. }
  4184. } else {
  4185. if (player.latestSkin != nID) {
  4186. packet("c", 0, nID, 0);
  4187. }
  4188. }
  4189. } else {
  4190. if (player.latestSkin != nID) {
  4191. packet("c", 0, nID, 0);
  4192. }
  4193. }
  4194. }
  4195. } else if (index == 1) {
  4196. if (useWasd && (id != 11 && id != 0)) {
  4197. if (player.latestTail != 0) {
  4198. packet("c", 0, 0, 1);
  4199. }
  4200. return;
  4201. }
  4202. if (player.tails[id]) {
  4203. if (player.latestTail != id) {
  4204. packet("c", 0, id, 1);
  4205. }
  4206. } else {
  4207. if (configs.autoBuyEquip) {
  4208. let find = findID(accessories, id);
  4209. if (find) {
  4210. if (player.points >= find.price) {
  4211. packet("c", 1, id, 1);
  4212. packet("c", 0, id, 1);
  4213. } else {
  4214. if (player.latestTail != 0) {
  4215. packet("c", 0, 0, 1);
  4216. }
  4217. }
  4218. } else {
  4219. if (player.latestTail != 0) {
  4220. packet("c", 0, 0, 1);
  4221. }
  4222. }
  4223. } else {
  4224. if (player.latestTail != 0) {
  4225. packet("c", 0, 0, 1);
  4226. }
  4227. }
  4228. }
  4229. }
  4230. }
  4231. }
  4232.  
  4233. function selectToBuild(index, wpn) {
  4234. packet("G", index, wpn);
  4235. }
  4236.  
  4237. function selectWeapon(index, isPlace) {
  4238. if (!isPlace) {
  4239. player.weaponCode = index;
  4240. }
  4241. packet("G", index, 1);
  4242. }
  4243.  
  4244. function sendAutoGather() {
  4245. packet("K", 1, 1);
  4246. }
  4247.  
  4248. function sendAtck(id, angle) {
  4249. packet("d", id, angle, 1);
  4250. }
  4251.  
  4252. // PLACER:
  4253. function place(id, rad, rmd) {
  4254. try {
  4255. if (id == undefined) return;
  4256. let item = items.list[player.items[id]];
  4257. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4258. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4259. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4260. if ((player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? 299 : item.group.limit ? item.group.limit : 99))) {
  4261. selectToBuild(player.items[id]);
  4262. sendAtck(1, rad);
  4263. selectWeapon(player.weaponCode, 1);
  4264. if (rmd && getEl("placeVis").checked) {
  4265. placeVisible.push({
  4266. x: tmpX,
  4267. y: tmpY,
  4268. name: item.name,
  4269. scale: item.scale,
  4270. dir: rad
  4271. });
  4272. game.tickBase(() => {
  4273. placeVisible.shift();
  4274. }, 1)
  4275. }
  4276. }
  4277. } catch (e) {}
  4278. }
  4279.  
  4280. function checkPlace(id, rad) {
  4281. try {
  4282. if (id == undefined) return;
  4283. let item = items.list[player.items[id]];
  4284. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4285. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4286. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4287. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4288. place(id, rad, 1);
  4289. }
  4290. } catch (e) {}
  4291. }
  4292.  
  4293. // HEALING:
  4294. function soldierMult() {
  4295. return player.latestSkin == 6 ? 0.75 : 1;
  4296. }
  4297.  
  4298. function healthBased() {
  4299. if (player.health == 100)
  4300. return 0;
  4301. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4302. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4303. }
  4304. return 0;
  4305. }
  4306.  
  4307. function getAttacker(damaged) {
  4308. let attackers = enemy.filter(tmp => {
  4309. //let damages = new Damages(items);
  4310. //let dmg = damages.weapons[tmp.weaponIndex];
  4311. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4312. let rule = {
  4313. //one: tmp.dist2 <= 300,
  4314. //two: by.includes(damaged),
  4315. three: tmp.attacked
  4316. }
  4317. return /*rule.one && rule.two && */ rule.three;
  4318. });
  4319. return attackers;
  4320. }
  4321.  
  4322. function healer() {
  4323. for (let i = 0; i < healthBased(); i++) {
  4324. place(0, getAttackDir());
  4325. }
  4326. }
  4327.  
  4328. function antiSyncHealing(timearg) {
  4329. my.antiSync = true;
  4330. let healAnti = setInterval(() => {
  4331. if (player.shameCount < 5) {
  4332. place(0, getAttackDir());
  4333. }
  4334. }, 75);
  4335. setTimeout(() => {
  4336. clearInterval(healAnti);
  4337. setTimeout(() => {
  4338. my.antiSync = false;
  4339. }, game.tickRate);
  4340. }, game.tickRate);
  4341. }
  4342. function applCxC(value) {
  4343. if (player.health == 100)
  4344. return 0;
  4345. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4346. return Math.ceil(value / items.list[player.items[0]].healing);
  4347. }
  4348. return 0;
  4349. }
  4350. function calcDmg(value) {
  4351. return value * player.skinIndex == 6 ? 0.75 : 1;
  4352. }
  4353. function biomeGear(mover, returns) {
  4354. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4355. if (returns) return 31;
  4356. buyEquip(31, 0);
  4357. } else {
  4358. if (player.y2 <= config.snowBiomeTop) {
  4359. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4360. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4361. } else {
  4362. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4363. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4364. }
  4365. }
  4366. if (returns) return 0;
  4367. }
  4368. let advHeal = [];
  4369. class Traps {
  4370. constructor(UTILS, items) {
  4371. this.dist = 0;
  4372. this.aim = 0;
  4373. this.inTrap = false;
  4374. this.replaced = false;
  4375. this.antiTrapped = false;
  4376. this.info = {};
  4377. this.notFast = function() {
  4378. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4379. }
  4380. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4381. try {
  4382. let item = items.list[player.items[id]];
  4383. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4384. let counts = {
  4385. attempts: 0,
  4386. placed: 0
  4387. };
  4388. let tmpObjects = [];
  4389. liztobj.forEach((p) => {
  4390. tmpObjects.push({
  4391. x: p.x,
  4392. y: p.y,
  4393. active: p.active,
  4394. blocker: p.blocker,
  4395. scale: p.scale,
  4396. isItem: p.isItem,
  4397. type: p.type,
  4398. colDiv: p.colDiv,
  4399. getScale: function(sM, ig) {
  4400. sM = sM || 1;
  4401. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4402. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4403. },
  4404. });
  4405. });
  4406. for (let i = first; i < repeat; i += plus) {
  4407. counts.attempts++;
  4408. let relAim = radian + i;
  4409. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4410. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4411. 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)));
  4412. if (cantPlace) continue;
  4413. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4414. if ((!replacer && yaboi)) {
  4415. if (yaboi.inTrap) {
  4416. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI*1.3) {
  4417. place(2, relAim, 1);
  4418. } else {
  4419. player.items[4] == 15 && place(4, relAim, 1);
  4420. }
  4421. } else {
  4422. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 2.6) {
  4423. place(2, relAim, 1);
  4424. } else {
  4425. player.items[4] == 15 && place(4, relAim, 1);
  4426. }
  4427. }
  4428. } else {
  4429. place(id, relAim, 1);
  4430. }
  4431. tmpObjects.push({
  4432. x: tmpX,
  4433. y: tmpY,
  4434. active: true,
  4435. blocker: item.blocker,
  4436. scale: item.scale,
  4437. isItem: true,
  4438. type: null,
  4439. colDiv: item.colDiv,
  4440. getScale: function() {
  4441. return this.scale;
  4442. },
  4443. });
  4444. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4445. counts.placed++;
  4446. }
  4447. }
  4448. if (counts.placed > 0 && replacer && item.dmg) {
  4449. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4450. instaC.canSpikeTick = true;
  4451. }
  4452. }
  4453. } catch (err) {
  4454. }
  4455. };
  4456. this.checkSpikeTick = function() {
  4457. try {
  4458. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4459. if ((my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4460. // more range for safe. also testing near.primaryIndex || 5
  4461. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4462. let item = items.list[9];
  4463. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4464. let danger = 0;
  4465. let counts = {
  4466. attempts: 0,
  4467. block: `unblocked`
  4468. };
  4469. for (let i = -1; i <= 1; i += 1 / 10) {
  4470. counts.attempts++;
  4471. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4472. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4473. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4474. 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)));
  4475. if (cantPlace) continue;
  4476. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4477. danger++;
  4478. counts.block = `blocked`;
  4479. break;
  4480. }
  4481. if (danger) {
  4482. my.anti0Tick = 1;
  4483. // player.chat.message = "Anti SpikeTick " + near.sid;
  4484. //player.chat.count = 2000;
  4485. return true;
  4486. }
  4487. }
  4488. } catch (err) {
  4489. return null;
  4490. }
  4491. return false;
  4492. }
  4493.  
  4494. function getDist(e, t) {
  4495. try {
  4496. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4497. } catch (e) {
  4498. return Infinity;
  4499. }
  4500. }
  4501.  
  4502. this.protect = function(aim) {
  4503. if (!configs.antiTrap) return;
  4504. if(getDist(near, player) > getDist(near, traps.info)) {
  4505. //behind u
  4506. for(let i=-(Math.PI / 2);i<(Math.PI / 2);i+=(Math.PI / 18)) {
  4507. checkPlace(2, near.aim2 + i);
  4508. }
  4509. } else if(getDist(near, traps.info) > getDist(near, player)) {
  4510. //infront of u
  4511. for(let i=-(Math.PI / 2);i<(Math.PI / 2);i+=(Math.PI / 18)) {
  4512. checkPlace(4, near.aim2 + i);
  4513. }
  4514. }
  4515.  
  4516. // if (player.items[4]) {
  4517. // this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4518. // this.antiTrapped = true;
  4519. // }
  4520. };
  4521. this.autoPlace = function() {
  4522. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4523. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4524. if (liztobj.length) {
  4525. let near2 = {
  4526. inTrap: false,
  4527. };
  4528. 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) {
  4529. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4530. })[0];
  4531. if (nearTrap) {
  4532. near2.inTrap = true;
  4533. sendChat("Errorrr../rr!");
  4534. } else {
  4535. near2.inTrap = false;
  4536. }
  4537. if (near.dist3 <= 450) {
  4538. if (near.dist2 <= 200) {
  4539. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4540. } else {
  4541. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4542. }
  4543. }
  4544. } else {
  4545. if (near.dist3 <= 450) {
  4546. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4547. }
  4548. }
  4549. }
  4550. }
  4551. };
  4552. this.replacer = function(findObj) {
  4553. if (!findObj || !configs.autoReplace) return;
  4554. if (!inGame) return;
  4555. if (this.antiTrapped) return;
  4556. game.tickBase(() => {
  4557. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4558. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4559. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4560. if (objDst <= 400 && near.dist2 <= 400) {
  4561. let danger = this.checkSpikeTick();
  4562. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4563. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4564. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4565. } else {
  4566. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4567. }
  4568. this.replaced = true;
  4569. }
  4570. }, 1);
  4571. };
  4572. }
  4573. };
  4574.  
  4575. class Instakill {
  4576. constructor() {
  4577. this.wait = false;
  4578. this.can = false;
  4579. this.isTrue = false;
  4580. this.nobull = false;
  4581. this.ticking = false;
  4582. this.canSpikeTick = false;
  4583. this.startTick = false;
  4584. this.readyTick = false;
  4585. this.canCounter = false;
  4586. this.revTick = false;
  4587. this.syncHit = false;
  4588. this.changeType = function(type) {
  4589. this.wait = false;
  4590. this.isTrue = true;
  4591. my.autoAim = true;
  4592. let instaLog = [type];
  4593. if (type == "rev") {
  4594. selectWeapon(player.weapons[1]);
  4595. buyEquip(53, 0);
  4596. sendAutoGather();
  4597. setTimeout(() => {
  4598. selectWeapon(player.weapons[0]);
  4599. buyEquip(7, 0);
  4600. setTimeout(() => {
  4601. sendAutoGather();
  4602. this.isTrue = false;
  4603. my.autoAim = false;
  4604. }, 225);
  4605. }, 100);
  4606. } else if (type == "nobull") {
  4607. selectWeapon(player.weapons[0]);
  4608. buyEquip(7, 0);
  4609. sendAutoGather();
  4610. setTimeout(() => {
  4611. selectWeapon(player.weapons[1]);
  4612. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4613. setTimeout(() => {
  4614. sendAutoGather();
  4615. this.isTrue = false;
  4616. my.autoAim = false;
  4617. }, 255);
  4618. }, 105);
  4619. } else if (type == "normal") {
  4620. selectWeapon(player.weapons[0]);
  4621. buyEquip(7, 0);
  4622. sendAutoGather();
  4623. setTimeout(() => {
  4624. selectWeapon(player.weapons[1]);
  4625. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4626. setTimeout(() => {
  4627. sendAutoGather();
  4628. this.isTrue = false;
  4629. my.autoAim = false;
  4630. }, 255);
  4631. }, 100);
  4632. } else {
  4633. setTimeout(() => {
  4634. this.isTrue = false;
  4635. my.autoAim = false;
  4636. }, 50);
  4637. }
  4638. };
  4639. this.spikeTickType = function() {
  4640. this.isTrue = true;
  4641. my.autoAim = true;
  4642. selectWeapon(player.weapons[0]);
  4643. buyEquip(7, 0);
  4644. sendAutoGather();
  4645. game.tickBase(() => {
  4646. selectWeapon(player.weapons[0]);
  4647. buyEquip(53, 0);
  4648. game.tickBase(() => {
  4649. sendAutoGather();
  4650. this.isTrue = false;
  4651. my.autoAim = false;
  4652. }, 1);
  4653. }, 1);
  4654. };
  4655. this.counterType = function() {
  4656. this.isTrue = true;
  4657. my.autoAim = true;
  4658. selectWeapon(player.weapons[0]);
  4659. buyEquip(7, 0);
  4660. sendAutoGather();
  4661. game.tickBase(() => {
  4662. selectWeapon(player.weapons[0]);
  4663. buyEquip(53, 0);
  4664. game.tickBase(() => {
  4665. sendAutoGather();
  4666. this.isTrue = false;
  4667. my.autoAim = false;
  4668. }, 1);
  4669. }, 1);
  4670. };
  4671. this.rangeType = function(type) {
  4672. this.isTrue = true;
  4673. my.autoAim = true;
  4674. if (type == "ageInsta") {
  4675. sendChat("Detected?");
  4676. my.ageInsta = false;
  4677. if (player.items[5] == 18) {
  4678. place(5, near.aim2);
  4679. }
  4680. packet("a", undefined, 1);
  4681. buyEquip(22, 0);
  4682. buyEquip(21, 1);
  4683. game.tickBase(() => {
  4684. selectWeapon(player.weapons[1]);
  4685. buyEquip(53, 0);
  4686. buyEquip(21, 1);
  4687. sendAutoGather();
  4688. game.tickBase(() => {
  4689. sendUpgrade(12);
  4690. selectWeapon(player.weapons[1]);
  4691. buyEquip(53, 0);
  4692. buyEquip(21, 1);
  4693. game.tickBase(() => {
  4694. sendUpgrade(15);
  4695. selectWeapon(player.weapons[1]);
  4696. buyEquip(53, 0);
  4697. buyEquip(21, 1);
  4698. game.tickBase(() => {
  4699. sendAutoGather();
  4700. this.isTrue = false;
  4701. my.autoAim = false;
  4702. }, 1);
  4703. }, 1);
  4704. }, 1);
  4705. }, 1);
  4706. } else {
  4707. selectWeapon(player.weapons[1]);
  4708. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4709. buyEquip(53, 0);
  4710. } else {
  4711. buyEquip(20, 0);
  4712. }
  4713. buyEquip(11, 1);
  4714. sendAutoGather();
  4715. game.tickBase(() => {
  4716. sendAutoGather();
  4717. this.isTrue = false;
  4718. my.autoAim = false;
  4719. }, 1);
  4720. }
  4721. };
  4722. this.oneTickType = function() {
  4723. this.isTrue = true;
  4724. my.autoAim = true;
  4725. selectWeapon(player.weapons[1]);
  4726. buyEquip(53, 0);
  4727. buyEquip(11, 1);
  4728. packet("a", near.aim2, 1);
  4729. if (player.weapons[1] == 15) {
  4730. my.revAim = true;
  4731. sendAutoGather();
  4732. }
  4733. game.tickBase(() => {
  4734. my.revAim = false;
  4735. selectWeapon(player.weapons[0]);
  4736. buyEquip(7, 0);
  4737. buyEquip(19, 1);
  4738. packet("a", near.aim2, 1);
  4739. if (player.weapons[1] != 15) {
  4740. sendAutoGather();
  4741. }
  4742. game.tickBase(() => {
  4743. sendAutoGather();
  4744. this.isTrue = false;
  4745. my.autoAim = false;
  4746. packet("a", undefined, 1);
  4747. }, 2);
  4748. }, 2);
  4749. };
  4750. this.threeOneTickType = function () {
  4751. this.isTrue = true;
  4752. my.autoAim = true;
  4753. selectWeapon(player.weapons[0]);
  4754. buyEquip(11, 1);
  4755. packet("a", near.aim2, 1);
  4756. game.tickBase(() => {
  4757. selectWeapon(player.weapons[0]);
  4758. buyEquip(53, 0);
  4759. buyEquip(11, 1);
  4760. packet("a", near.aim2, 1);
  4761. game.tickBase(() => {
  4762. selectWeapon(player.weapons[0]);
  4763. buyEquip(7, 0);
  4764. buyEquip(19, 1);
  4765. sendAutoGather();
  4766. packet("a", near.aim2, 1);
  4767. game.tickBase(() => {
  4768. sendAutoGather();
  4769. this.isTrue = false;
  4770. my.autoAim = false;
  4771. packet("a", undefined, 1);
  4772. }, 1);
  4773. }, 1);
  4774. }, 1);
  4775. };
  4776. this.kmTickType = function() {
  4777. this.isTrue = true;
  4778. my.autoAim = true;
  4779. my.revAim = true;
  4780. selectWeapon(player.weapons[1]);
  4781. buyEquip(53, 0);
  4782. buyEquip(11, 1);
  4783. sendAutoGather();
  4784. packet("a", near.aim2, 1);
  4785. game.tickBase(() => {
  4786. my.revAim = false;
  4787. selectWeapon(player.weapons[0]);
  4788. buyEquip(7, 0);
  4789. buyEquip(19, 1);
  4790. packet("a", near.aim2, 1);
  4791. game.tickBase(() => {
  4792. sendAutoGather();
  4793. this.isTrue = false;
  4794. my.autoAim = false;
  4795. packet("a", undefined, 1);
  4796. }, 2);
  4797. }, 2);
  4798. };
  4799. this.boostTickType = function() {
  4800. /*this.isTrue = true;
  4801. my.autoAim = true;
  4802. selectWeapon(player.weapons[0]);
  4803. buyEquip(53, 0);
  4804. buyEquip(11, 1);
  4805. packet("a", near.aim2);
  4806. game.tickBase(() => {
  4807. place(4, near.aim2);
  4808. selectWeapon(player.weapons[1]);
  4809. biomeGear();
  4810. buyEquip(11, 1);
  4811. sendAutoGather();
  4812. packet("a", near.aim2);
  4813. game.tickBase(() => {
  4814. selectWeapon(player.weapons[0]);
  4815. buyEquip(7, 0);
  4816. buyEquip(19, 1);
  4817. packet("a", near.aim2);
  4818. game.tickBase(() => {
  4819. sendAutoGather();
  4820. this.isTrue = false;
  4821. my.autoAim = false;
  4822. packet("a", undefined);
  4823. }, 1);
  4824. }, 1);
  4825. }, 1);*/
  4826. this.isTrue = true;
  4827. my.autoAim = true;
  4828. biomeGear();
  4829. buyEquip(11, 1);
  4830. packet("a", near.aim2, 1);
  4831. game.tickBase(() => {
  4832. if (player.weapons[1] == 15) {
  4833. my.revAim = true;
  4834. }
  4835. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  4836. buyEquip(53, 0);
  4837. buyEquip(11, 1);
  4838. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  4839. sendAutoGather();
  4840. }
  4841. packet("a", near.aim2, 1);
  4842. place(4, near.aim2);
  4843. game.tickBase(() => {
  4844. my.revAim = false;
  4845. selectWeapon(player.weapons[0]);
  4846. buyEquip(7, 0);
  4847. buyEquip(19, 1);
  4848. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  4849. sendAutoGather();
  4850. }
  4851. packet("a", near.aim2, 1);
  4852. game.tickBase(() => {
  4853. sendAutoGather();
  4854. this.isTrue = false;
  4855. my.autoAim = false;
  4856. packet("a", undefined, 1);
  4857. }, 1);
  4858. }, 1);
  4859. }, 1);
  4860. };
  4861. this.gotoGoal = function (goto, OT) {
  4862. let slowDists = (weeeee) => weeeee * config.playerScale;
  4863. let goal = {
  4864. a: goto - OT,
  4865. b: goto + OT,
  4866. c: goto - slowDists(1),
  4867. d: goto + slowDists(1),
  4868. e: goto - slowDists(2),
  4869. f: goto + slowDists(2),
  4870. g: goto - slowDists(4),
  4871. h: goto + slowDists(4)
  4872. };
  4873. let bQ = function(wwww, awwww) {
  4874. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  4875. buyEquip(31, 0);
  4876. } else {
  4877. buyEquip(wwww, awwww);
  4878. }
  4879. }
  4880. if (enemy.length) {
  4881. let dst = near.dist2;
  4882. this.ticking = true;
  4883. if (dst >= goal.a && dst <= goal.b) {
  4884. bQ(22, 0);
  4885. bQ(11, 1);
  4886. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  4887. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4888. }
  4889. return {
  4890. dir: undefined,
  4891. action: 1
  4892. };
  4893. } else {
  4894. if (dst < goal.a) {
  4895. if (dst >= goal.g) {
  4896. if (dst >= goal.e) {
  4897. if (dst >= goal.c) {
  4898. bQ(40, 0);
  4899. bQ(10, 1);
  4900. if (configs.slowOT) {
  4901. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  4902. } else {
  4903. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4904. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4905. }
  4906. }
  4907. } else {
  4908. bQ(22, 0);
  4909. bQ(19, 1);
  4910. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4911. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4912. }
  4913. }
  4914. } else {
  4915. bQ(6, 0);
  4916. bQ(12, 1);
  4917. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4918. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4919. }
  4920. }
  4921. } else {
  4922. biomeGear();
  4923. bQ(11, 1);
  4924. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4925. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4926. }
  4927. }
  4928. return {
  4929. dir: near.aim2 + Math.PI,
  4930. action: 0
  4931. };
  4932. } else if (dst > goal.b) {
  4933. if (dst <= goal.h) {
  4934. if (dst <= goal.f) {
  4935. if (dst <= goal.d) {
  4936. bQ(40, 0);
  4937. bQ(9, 1);
  4938. if (configs.slowOT) {
  4939. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  4940. } else {
  4941. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4942. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4943. }
  4944. }
  4945. } else {
  4946. bQ(22, 0);
  4947. bQ(19, 1);
  4948. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4949. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4950. }
  4951. }
  4952. } else {
  4953. bQ(6, 0);
  4954. bQ(12, 1);
  4955. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4956. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4957. }
  4958. }
  4959. } else {
  4960. biomeGear();
  4961. bQ(11, 1);
  4962. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4963. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4964. }
  4965. }
  4966. return {
  4967. dir: near.aim2,
  4968. action: 0
  4969. };
  4970. }
  4971. return {
  4972. dir: undefined,
  4973. action: 0
  4974. };
  4975. }
  4976. } else {
  4977. this.ticking = false;
  4978. return {
  4979. dir: undefined,
  4980. action: 0
  4981. };
  4982. }
  4983. }
  4984. /** wait 1 tick for better quality */
  4985. this.bowMovement = function() {
  4986. let moveMent = this.gotoGoal(685, 3);
  4987. if (moveMent.action) {
  4988. if (player.reloads[53] == 0 && !this.isTrue) {
  4989. this.rangeType("ageInsta");
  4990. } else {
  4991. packet("a", moveMent.dir, 1);
  4992. }
  4993. } else {
  4994. packet("a", moveMent.dir, 1);
  4995. }
  4996. }
  4997. this.tickMovement = function () {
  4998. 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]) ? 230 : 225 : 235, 3);
  4999. if (moveMent.action) {
  5000. if (![6, 22].includes(near.skinIndex) && player.reloads[53] == 0 && !this.isTrue) {
  5001. ([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) || (player.weapons[1] == 15) ? this.oneTickType() : this.threeOneTickType();
  5002. } else {
  5003. packet("a", moveMent.dir, 1);
  5004. }
  5005. } else {
  5006. packet("a", moveMent.dir, 1);
  5007. }
  5008. }
  5009. this.kmTickMovement = function() {
  5010. let moveMent = this.gotoGoal(240, 3);
  5011. if (moveMent.action) {
  5012. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue) {
  5013. this.kmTickType();
  5014. } else {
  5015. packet("a", moveMent.dir, 1);
  5016. }
  5017. } else {
  5018. packet("a", moveMent.dir, 1);
  5019. }
  5020. }
  5021. this.boostTickMovement = function() {
  5022. setTimeout(() => {
  5023. sendChat("p_OT [1/3]");
  5024. }, 60);
  5025. setTimeout(() => {
  5026. sendChat("p_OT [2/3]");
  5027. }, 580);
  5028. setTimeout(() => {
  5029. sendChat("[p_OT Starting..]");
  5030. })
  5031. let dist = player.weapons[1] == 9 ? 325 : player.weapons[1] == 12 ? 340 : player.weapons[1] == 13 ? 350 : player.weapons[1] == 15 ? 365 : 370;
  5032. 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;
  5033. let moveMent = this.gotoGoal(dist, actionDist);
  5034. if (moveMent.action) {
  5035. if (player.reloads[53] == 0 && !this.isTrue) {
  5036. this.boostTickType();
  5037. } else {
  5038. packet("a", moveMent.dir, 1);
  5039. }
  5040. } else {
  5041. packet("a", moveMent.dir, 1);
  5042. }
  5043. }
  5044. /** wait 1 tick for better quality */
  5045. this.perfCheck = function(pl, nr) {
  5046. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5047. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5048. let pjs = {
  5049. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5050. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5051. };
  5052. 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)) {
  5053. return true;
  5054. }
  5055. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5056. 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)) {
  5057. return true;
  5058. }
  5059. });
  5060. if (finds) return false;
  5061. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5062. let tmpScale = tmp.getScale();
  5063. 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)) {
  5064. return true;
  5065. }
  5066. });
  5067. if (finds) return false;
  5068. return true;
  5069. }
  5070. }
  5071. };
  5072. class Autobuy {
  5073. constructor(buyHat, buyAcc) {
  5074. this.hat = function() {
  5075. buyHat.forEach((id) => {
  5076. let find = findID(hats, id);
  5077. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5078. });
  5079. };
  5080. this.acc = function() {
  5081. buyAcc.forEach((id) => {
  5082. let find = findID(accessories, id);
  5083. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5084. });
  5085. };
  5086. }
  5087. };
  5088.  
  5089. class Autoupgrade {
  5090. constructor() {
  5091. this.sb = function(upg) {
  5092. upg(3);
  5093. upg(17);
  5094. upg(31);
  5095. upg(23);
  5096. upg(9);
  5097. upg(38);
  5098. };
  5099. this.kh = function(upg) {
  5100. upg(3);
  5101. upg(17);
  5102. upg(31);
  5103. upg(23);
  5104. upg(10);
  5105. upg(38);
  5106. upg(4);
  5107. upg(25);
  5108. };
  5109. this.pb = function(upg) {
  5110. upg(5);
  5111. upg(17);
  5112. upg(32);
  5113. upg(23);
  5114. upg(9);
  5115. upg(38);
  5116. };
  5117. this.ph = function(upg) {
  5118. upg(5);
  5119. upg(17);
  5120. upg(32);
  5121. upg(23);
  5122. upg(10);
  5123. upg(38);
  5124. upg(28);
  5125. upg(25);
  5126. };
  5127. this.db = function(upg) {
  5128. upg(7);
  5129. upg(17);
  5130. upg(31);
  5131. upg(23);
  5132. upg(9);
  5133. upg(34);
  5134. };
  5135. };
  5136. };
  5137.  
  5138. class Damages {
  5139. constructor(items) {
  5140. // 0.75 1 1.125 1.5
  5141. this.calcDmg = function(dmg, val) {
  5142. return dmg * val;
  5143. };
  5144. this.getAllDamage = function(dmg) {
  5145. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5146. };
  5147. this.weapons = [];
  5148. for (let i = 0; i < items.weapons.length; i++) {
  5149. let wp = items.weapons[i];
  5150. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5151. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5152. this[name] = this.weapons[i];
  5153. }
  5154. }
  5155. }
  5156.  
  5157. /** CLASS CODES */
  5158. // jumpscare code warn
  5159. let tmpList = [];
  5160.  
  5161. // LOADING:
  5162. let UTILS = new Utils();
  5163. let items = new Items();
  5164. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5165. let store = new Store();
  5166. let hats = store.hats;
  5167. let accessories = store.accessories;
  5168. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5169. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5170. let textManager = new Textmanager();
  5171.  
  5172. let traps = new Traps(UTILS, items);
  5173. let instaC = new Instakill();
  5174. let autoBuy = new Autobuy([6, 26, 7, 22, 12, 53, 40, 15, 31, 20], [11, 13, 19, 18, 21]);
  5175. let autoUpgrade = new Autoupgrade();
  5176.  
  5177. let lastDeath;
  5178. let minimapData;
  5179. let mapMarker = {};
  5180. let mapPings = [];
  5181. let tmpPing;
  5182.  
  5183. let breakTrackers = [];
  5184.  
  5185. let pathFindTest = 0;
  5186. let grid = [];
  5187. let pathFind = {
  5188. active: false,
  5189. grid: 40,
  5190. scale: 1440,
  5191. x: 14400,
  5192. y: 14400,
  5193. chaseNear: false,
  5194. array: [],
  5195. lastX: this.grid / 2,
  5196. lastY: this.grid / 2
  5197. };
  5198.  
  5199. function sendChat(message) {
  5200. packet("6", message.slice(0, 30));
  5201. }
  5202.  
  5203. let runAtNextTick = [];
  5204.  
  5205. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5206. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5207. let projOffset = config.playerScale * 2;
  5208. let projXY = {
  5209. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5210. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5211. };
  5212. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5213. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5214. })[0];
  5215. if (nearPlayer) {
  5216. if (indx == 1) {
  5217. nearPlayer.shooting[53] = 1;
  5218. } else {
  5219. nearPlayer.shootIndex = weaponIndx;
  5220. nearPlayer.shooting[1] = 1;
  5221. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5222. }
  5223. }
  5224. }
  5225. let projectileCount = 0;
  5226.  
  5227. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5228. if (!tmpObj.isTeam(player)) {
  5229. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5230. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5231. tmpObj.bowThreat[weaponIndex]++;
  5232. if (index == 5) {
  5233. projectileCount++;
  5234. }
  5235. setTimeout(() => {
  5236. tmpObj.bowThreat[weaponIndex]--;
  5237. if (index == 5) {
  5238. projectileCount--;
  5239. }
  5240. }, range / speed);
  5241. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5242. place(1, tmpObj.aim2);
  5243. my.anti0Tick = 4;
  5244. if (!my.antiSync) {
  5245. antiSyncHealing(4);
  5246. }
  5247. } else {
  5248. if (projectileCount >= 2) {
  5249. place(1, tmpObj.aim2);
  5250. my.anti0Tick = 4;
  5251. if (!my.antiSync) {
  5252. antiSyncHealing(4);
  5253. }
  5254. }
  5255. }
  5256. }
  5257. }
  5258. }
  5259.  
  5260. // SHOW ITEM INFO:
  5261. function showItemInfo(item, isWeapon, isStoreItem) {
  5262. if (player && item) {
  5263. UTILS.removeAllChildren(itemInfoHolder);
  5264. itemInfoHolder.classList.add("visible");
  5265. UTILS.generateElement({
  5266. id: "itemInfoName",
  5267. text: UTILS.capitalizeFirst(item.name),
  5268. parent: itemInfoHolder
  5269. });
  5270. UTILS.generateElement({
  5271. id: "itemInfoDesc",
  5272. text: item.desc,
  5273. parent: itemInfoHolder
  5274. });
  5275. if (isStoreItem) {
  5276.  
  5277. } else if (isWeapon) {
  5278. UTILS.generateElement({
  5279. class: "itemInfoReq",
  5280. text: !item.type ? "primary" : "secondary",
  5281. parent: itemInfoHolder
  5282. });
  5283. } else {
  5284. for (let i = 0; i < item.req.length; i += 2) {
  5285. UTILS.generateElement({
  5286. class: "itemInfoReq",
  5287. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5288. parent: itemInfoHolder
  5289. });
  5290. }
  5291. if (item.group.limit) {
  5292. UTILS.generateElement({
  5293. class: "itemInfoLmt",
  5294. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5295. parent: itemInfoHolder
  5296. });
  5297. }
  5298. }
  5299. } else {
  5300. itemInfoHolder.classList.remove("visible");
  5301. }
  5302. }
  5303.  
  5304. // RESIZE:
  5305. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5306.  
  5307. function resize() {
  5308. screenWidth = window.innerWidth;
  5309. screenHeight = window.innerHeight;
  5310. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5311. gameCanvas.width = screenWidth * pixelDensity;
  5312. gameCanvas.height = screenHeight * pixelDensity;
  5313. gameCanvas.style.width = screenWidth + "px";
  5314. gameCanvas.style.height = screenHeight + "px";
  5315. mainContext.setTransform(
  5316. scaleFillNative, 0,
  5317. 0, scaleFillNative,
  5318. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5319. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5320. );
  5321. }
  5322. resize();
  5323.  
  5324. // MOUSE INPUT:
  5325. var usingTouch;
  5326. const mals = document.getElementById('touch-controls-fullscreen');
  5327. mals.style.display = 'block';
  5328. mals.addEventListener("mousemove", gameInput, false);
  5329.  
  5330. function gameInput(e) {
  5331. mouseX = e.clientX;
  5332. mouseY = e.clientY;
  5333. }
  5334. let clicks = {
  5335. left: false,
  5336. middle: false,
  5337. right: false,
  5338. };
  5339. let clicked = {
  5340. g: false
  5341. }
  5342. mals.addEventListener("mousedown", mouseDown, false);
  5343.  
  5344. function mouseDown(e) {
  5345. if (attackState != 1) {
  5346. attackState = 1;
  5347. if (e.button == 0) {
  5348. clicks.left = true;
  5349. } else if (e.button == 2) {
  5350. clicks.right = true;
  5351. }
  5352. }
  5353. }
  5354. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5355.  
  5356. function mouseUp(e) {
  5357. if (attackState != 0) {
  5358. attackState = 0;
  5359. if (e.button == 0) {
  5360. clicks.left = false;
  5361. } else if (e.button == 2) {
  5362. clicks.right = false;
  5363. }
  5364. }
  5365. }
  5366. mals.addEventListener("wheel", wheel, false);
  5367.  
  5368. function wheel(e) {
  5369. if (e.deltaY < 0) {
  5370. wbe += 0.005
  5371. maxScreenWidth = config.maxScreenWidth * wbe;
  5372. maxScreenHeight = config.maxScreenHeight * wbe;
  5373. resize()
  5374. } else {
  5375. wbe -= 0.005
  5376. maxScreenWidth = config.maxScreenWidth * wbe;
  5377. maxScreenHeight = config.maxScreenHeight * wbe;
  5378. resize()
  5379. }
  5380. }
  5381.  
  5382. // INPUT UTILS:
  5383. function getMoveDir() {
  5384. let dx = 0;
  5385. let dy = 0;
  5386. for (let key in moveKeys) {
  5387. let tmpDir = moveKeys[key];
  5388. dx += !!keys[key] * tmpDir[0];
  5389. dy += !!keys[key] * tmpDir[1];
  5390. }
  5391. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5392. }
  5393.  
  5394. function getSafeDir() {
  5395. if (!player)
  5396. return 0;
  5397. if (!player.lockDir) {
  5398. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5399. }
  5400. return lastDir || 0;
  5401. }
  5402. let plusDir = 0;
  5403. let lastSpin = Date.now();
  5404. function getAttackDir(debug) {
  5405. if (debug) {
  5406. if (!player)
  5407. return "0";
  5408. 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))
  5409. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  5410. else
  5411. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5412. lastDir = "getSafeDir()";
  5413. else
  5414. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5415. lastDir = "traps.aim";
  5416. else
  5417. if (!player.lockDir) {
  5418. if (configs.noDir) return "undefined";
  5419. lastDir = "getSafeDir()";
  5420. }
  5421. return lastDir;
  5422. } else {
  5423. if (!player)
  5424. return 0;
  5425. 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))
  5426. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5427. else
  5428. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5429. lastDir = getSafeDir();
  5430. else
  5431. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5432. lastDir = traps.aim;
  5433. else
  5434. if (!player.lockDir) {
  5435. if (configs.noDir) return undefined;
  5436. lastDir = getSafeDir();
  5437. }
  5438. return lastDir || 0;
  5439. }
  5440. }
  5441.  
  5442. function getVisualDir() {
  5443. if (!player)
  5444. return 0;
  5445. lastDir = getSafeDir();
  5446. return lastDir || 0;
  5447. }
  5448.  
  5449. // KEYS:
  5450. function keysActive() {
  5451. return (allianceMenu.style.display != "block" &&
  5452. chatHolder.style.display != "block" &&
  5453. !menuCBFocus);
  5454. }
  5455.  
  5456. function toggleMenuChat() {
  5457. if (menuChatDiv.style.display != "none") {
  5458. // chatHolder.style.display = "none";
  5459. // if (menuChatBox.value != "") {
  5460. //commands[command.slice(1)]
  5461. let cmd = function(command) {
  5462. return {
  5463. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5464. fv: commands[command.slice(1).split(" ")[0]]
  5465. }
  5466. }
  5467. let command = cmd(menuChatBox.value);
  5468. if (command.found) {
  5469. if (typeof command.fv.action === "function") {
  5470. command.fv.action(menuChatBox.value);
  5471. }
  5472. } else {
  5473. sendChat(menuChatBox.value);
  5474. }
  5475. menuChatBox.value = "";
  5476. menuChatBox.blur();
  5477. } else {
  5478. if (menuCBFocus) {
  5479. menuChatBox.blur();
  5480. } else {
  5481. menuChatBox.focus();
  5482. }
  5483. }
  5484. }
  5485.  
  5486. function keyDown(event) {
  5487. let keyNum = event.which || event.keyCode || 0;
  5488. if (player && player.alive && keysActive()) {
  5489. if (!keys[keyNum]) {
  5490. keys[keyNum] = 1;
  5491. macro[event.key] = 1;
  5492. if (keyNum == 27) {
  5493. openMenu = !openMenu;
  5494. $("#menuDiv").toggle();
  5495. $("#menuChatDiv").toggle();
  5496. } else if (keyNum == 69) {
  5497. sendAutoGather();
  5498. } else if (keyNum == 66) {
  5499. instaC.syncTry();
  5500. } else if (keyNum == 66) {
  5501. instaC.syncTry();
  5502. } else if (keyNum == 71) {
  5503. clicked.g = !clicked.g
  5504. } else if (player.weapons[keyNum - 49] != undefined) {
  5505. player.weaponCode = player.weapons[keyNum - 49];
  5506. } else if (moveKeys[keyNum]) {
  5507. sendMoveDir();
  5508. } else if (event.key == "C") {
  5509. syncChat(getEl("songs").value);
  5510. } else if (event.key == "m") {
  5511. mills.placeSpawnPads = !mills.placeSpawnPads;
  5512. } else if (event.key == "z") {
  5513. mills.place = !mills.place;
  5514. } else if (event.key == "Z") {
  5515. typeof window.debug == "function" && window.debug();
  5516. } else if (keyNum == 32) {
  5517. packet("d", 1, getSafeDir(), 1);
  5518. packet("d", 0, getSafeDir(), 1);
  5519. }
  5520. }
  5521. }
  5522. }
  5523.  
  5524. // let xx = canvaz.width/2;
  5525. // let yy = canvaz.height/2;
  5526.  
  5527. // let mouze = {
  5528. // x: xx - mouzeX,
  5529. // y: yy - mouzeY
  5530. // }
  5531.  
  5532. // let ingamecoorformodabow = {
  5533. // x: player.x + mouze.x,
  5534. // y: player.x + mouze.x
  5535. // }
  5536.  
  5537. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5538.  
  5539. function keyUp(event) {
  5540. if (player && player.alive) {
  5541. let keyNum = event.which || event.keyCode || 0;
  5542. if (keyNum == 13) {
  5543. toggleMenuChat();
  5544. } else if (keysActive()) {
  5545. if (keys[keyNum]) {
  5546. keys[keyNum] = 0;
  5547. macro[event.key] = 0;
  5548. if (moveKeys[keyNum]) {
  5549. sendMoveDir();
  5550. }
  5551. }
  5552. }
  5553. }
  5554. }
  5555. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5556.  
  5557. function sendMoveDir() {
  5558. if(found) {
  5559. packet("a", undefined, 1);
  5560. } else {
  5561. let newMoveDir = getMoveDir();
  5562. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5563. if (!my.autoPush && !found) {
  5564. packet("a", newMoveDir, 1);
  5565. }
  5566. lastMoveDir = newMoveDir;
  5567. }
  5568. }
  5569. }
  5570.  
  5571. // BUTTON EVENTS:
  5572. function bindEvents() {}
  5573. bindEvents();
  5574.  
  5575. /** PATHFIND TEST */
  5576. function chechPathColl(tmp) {
  5577. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  5578. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  5579. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  5580. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  5581. }
  5582.  
  5583. function checkObject() {
  5584. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  5585. for (let y = 0; y < pathFind.grid; y++) {
  5586. grid[y] = [];
  5587. for (let x = 0; x < pathFind.grid; x++) {
  5588. let tmpXY = {
  5589. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  5590. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  5591. }
  5592. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  5593. pathFind.lastX = x;
  5594. pathFind.lastY = y;
  5595. grid[y][x] = 0;
  5596. continue;
  5597. }
  5598. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  5599. if (find) {
  5600. if (find.trap) {
  5601. grid[y][x] = 0;
  5602. continue;
  5603. }
  5604. grid[y][x] = 1;
  5605. } else {
  5606. grid[y][x] = 0;
  5607. }
  5608. }
  5609. }
  5610. }
  5611.  
  5612. function createPath() {
  5613. grid = [];
  5614. checkObject();
  5615. }
  5616.  
  5617. function Pathfinder() {
  5618. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  5619. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  5620. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5621. packet("a", undefined, 1);
  5622. } else {
  5623. createPath();
  5624. easystar.setGrid(grid);
  5625. easystar.setAcceptableTiles([0]);
  5626. easystar.enableDiagonals();
  5627. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  5628. if (path === null) {
  5629. pathFind.array = [];
  5630. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5631. packet("a", undefined, 1);
  5632. } else {
  5633. packet("a", near.aim2, 1);
  5634. }
  5635. } else {
  5636. pathFind.array = path;
  5637. if (pathFind.array.length > 1) {
  5638. let tmpXY = {
  5639. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  5640. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  5641. }
  5642. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  5643. }
  5644. }
  5645. });
  5646. easystar.calculate();
  5647. }
  5648. }
  5649. }
  5650. /** PATHFIND TEST */
  5651.  
  5652. // ITEM COUNT DISPLAY:
  5653. let isItemSetted = [];
  5654.  
  5655. function updateItemCountDisplay(index = undefined) {
  5656. for (let i = 3; i < items.list.length; ++i) {
  5657. let id = items.list[i].group.id;
  5658. let tmpI = items.weapons.length + i;
  5659. if (!isItemSetted[tmpI]) {
  5660. isItemSetted[tmpI] = document.createElement("div");
  5661. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5662. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5663. isItemSetted[tmpI].style = `
  5664. display: block;
  5665. position: absolute;
  5666. padding-left: 5px;
  5667. font-size: 2em;
  5668. color: #fff;
  5669. `;
  5670. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5671. } else {
  5672. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5673. }
  5674. }
  5675. }
  5676.  
  5677. // AUTOPUSH:
  5678. function autoPush() {
  5679. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function (a, b) {
  5680. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5681. })[0];
  5682. if (nearTrap) {
  5683. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function (a, b) {
  5684. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5685. })[0];
  5686. if (spike) {
  5687. let pos = {
  5688. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5689. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5690. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5691. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  5692. };
  5693. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  5694. let tmpScale = tmp.getScale();
  5695. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, player.x2, player.y2, pos.x2, pos.y2)) {
  5696. return true;
  5697. }
  5698. });
  5699. if (finds) {
  5700. if (my.autoPush) {
  5701. my.autoPush = false;
  5702. packet("a", lastMoveDir||undefined, 1);
  5703. }
  5704. } else {
  5705. my.autoPush = true;
  5706. my.pushData = {
  5707. x: spike.x,
  5708. y: spike.y,
  5709. x2: pos.x2,
  5710. y2: pos.y2
  5711. };
  5712. let scale = (player.scale / 10);
  5713. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5714. packet("a", near.aim2, 1);
  5715. } else {
  5716. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  5717. }
  5718. }
  5719. } else {
  5720. if (my.autoPush) {
  5721. my.autoPush = false;
  5722. packet("a", lastMoveDir||undefined, 1);
  5723. }
  5724. }
  5725. } else {
  5726. if (my.autoPush) {
  5727. my.autoPush = false;
  5728. packet("a", lastMoveDir||undefined, 1);
  5729. }
  5730. }
  5731. }
  5732.  
  5733. // ADD DEAD PLAYER:
  5734. function addDeadPlayer(tmpObj) {
  5735. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  5736. }
  5737.  
  5738. /** APPLY SOCKET CODES */
  5739.  
  5740. // SET INIT DATA:
  5741. function setInitData(data) {
  5742. alliances = data.teams;
  5743. }
  5744.  
  5745. // SETUP GAME:
  5746. function setupGame(yourSID) {
  5747. keys = {};
  5748. macro = {};
  5749. playerSID = yourSID;
  5750. attackState = 0;
  5751. inGame = true;
  5752. packet("d", 0, getAttackDir(), 1);
  5753. my.ageInsta = true;
  5754. if (firstSetup) {
  5755. firstSetup = false;
  5756. gameObjects.length = 0;
  5757. liztobj.length = 0;
  5758. }
  5759. }
  5760.  
  5761. // ADD NEW PLAYER:
  5762. function addPlayer(data, isYou) {
  5763. let tmpPlayer = findPlayerByID(data[0]);
  5764. if (!tmpPlayer) {
  5765. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  5766. objectManager, players, ais, items, hats, accessories);
  5767. players.push(tmpPlayer);
  5768. if (data[1] != playerSID) {
  5769. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5770. }
  5771. } else {
  5772. if (data[1] != playerSID) {
  5773. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5774. }
  5775. }
  5776. tmpPlayer.spawn(isYou ? true : null);
  5777. tmpPlayer.visible = false;
  5778. tmpPlayer.oldPos = {
  5779. x2: undefined,
  5780. y2: undefined
  5781. };
  5782. tmpPlayer.x2 = undefined;
  5783. tmpPlayer.y2 = undefined;
  5784. tmpPlayer.x3 = undefined;
  5785. tmpPlayer.y3 = undefined;
  5786. tmpPlayer.setData(data);
  5787. if (isYou) {
  5788. if (!player) {
  5789. window.prepareUI(tmpPlayer);
  5790. }
  5791. player = tmpPlayer;
  5792. camX = player.x;
  5793. camY = player.y;
  5794. my.lastDir = 0;
  5795. updateItems();
  5796. updateAge();
  5797. updateItemCountDisplay();
  5798. if (player.skins[7]) {
  5799. my.reSync = true;
  5800. }
  5801. }
  5802. }
  5803.  
  5804. // REMOVE PLAYER:
  5805. function removePlayer(id) {
  5806. for (let i = 0; i < players.length; i++) {
  5807. if (players[i].id == id) {
  5808. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  5809. players.splice(i, 1);
  5810. break;
  5811. }
  5812. }
  5813. }
  5814.  
  5815. // UPDATE HEALTH:
  5816. function updateHealth(sid, value) {
  5817. tmpObj = findPlayerBySID(sid);
  5818. if (tmpObj) {
  5819. tmpObj.oldHealth = tmpObj.health;
  5820. tmpObj.health = value;
  5821. tmpObj.judgeShame();
  5822. if (tmpObj.oldHealth > tmpObj.health) {
  5823. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  5824. advHeal.push([sid, value, tmpObj.damaged]);
  5825. } else {
  5826. }
  5827. if (tmpObj.health <= 0) {
  5828. bots.forEach((hmm) => {
  5829. hmm.whyDie = tmpObj.name;
  5830. });
  5831. }
  5832. }
  5833. }
  5834.  
  5835. // KILL PLAYER:
  5836. function killPlayer() {
  5837. inGame = false;
  5838. lastDeath = {
  5839. x: player.x,
  5840. y: player.y,
  5841. };
  5842. if (configs.autoRespawn) {
  5843. getEl("diedText").style.display = "none";
  5844. packet("M", {
  5845. name: lastsp[0],
  5846. moofoll: lastsp[1],
  5847. skin: lastsp[2]
  5848. });
  5849. }
  5850. }
  5851.  
  5852. // UPDATE PLAYER ITEM VALUES:
  5853. function updateItemCounts(index, value) {
  5854. if (player) {
  5855. player.itemCounts[index] = value;
  5856. updateItemCountDisplay(index);
  5857. }
  5858. }
  5859.  
  5860. // UPDATE AGE:
  5861. function updateAge(xp, mxp, age) {
  5862. if (xp != undefined)
  5863. player.XP = xp;
  5864. if (mxp != undefined)
  5865. player.maxXP = mxp;
  5866. if (age != undefined)
  5867. player.age = age;
  5868. }
  5869.  
  5870. // UPDATE UPGRADES:
  5871. function updateUpgrades(points, age) {
  5872. player.upgradePoints = points;
  5873. player.upgrAge = age;
  5874. if (points > 0) {
  5875. tmpList.length = 0;
  5876. UTILS.removeAllChildren(upgradeHolder);
  5877. for (let i = 0; i < items.weapons.length; ++i) {
  5878. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  5879. let e = UTILS.generateElement({
  5880. id: "upgradeItem" + i,
  5881. class: "actionBarItem",
  5882. onmouseout: function() {
  5883. showItemInfo();
  5884. },
  5885. parent: upgradeHolder
  5886. });
  5887. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  5888. tmpList.push(i);
  5889. }
  5890. }
  5891. for (let i = 0; i < items.list.length; ++i) {
  5892. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  5893. let tmpI = (items.weapons.length + i);
  5894. let e = UTILS.generateElement({
  5895. id: "upgradeItem" + tmpI,
  5896. class: "actionBarItem",
  5897. onmouseout: function() {
  5898. showItemInfo();
  5899. },
  5900. parent: upgradeHolder
  5901. });
  5902. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  5903. tmpList.push(tmpI);
  5904. }
  5905. }
  5906. for (let i = 0; i < tmpList.length; i++) {
  5907. (function(i) {
  5908. let tmpItem = getEl('upgradeItem' + i);
  5909. // tmpItem.onmouseover = function() {
  5910. // if (items.weapons[i]) {
  5911. // showItemInfo(items.weapons[i], true);
  5912. // } else {
  5913. // showItemInfo(items.list[i - items.weapons.length]);
  5914. // }
  5915. // };
  5916. tmpItem.onclick = UTILS.checkTrusted(function() {
  5917. packet("H", i);
  5918. });
  5919. UTILS.hookTouchEvents(tmpItem);
  5920. })(tmpList[i]);
  5921. }
  5922. if (tmpList.length) {
  5923. upgradeHolder.style.display = "block";
  5924. upgradeCounter.style.display = "block";
  5925. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  5926. } else {
  5927. upgradeHolder.style.display = "none";
  5928. upgradeCounter.style.display = "none";
  5929. showItemInfo();
  5930. }
  5931. } else {
  5932. upgradeHolder.style.display = "none";
  5933. upgradeCounter.style.display = "none";
  5934. showItemInfo();
  5935. }
  5936. }
  5937.  
  5938. // KILL OBJECT:
  5939. function killObject(sid) {
  5940. let findObj = findObjectBySid(sid);
  5941. objectManager.disableBySid(sid);
  5942. if (player) {
  5943. for (let i = 0; i < breakObjects.length; i++) {
  5944. if (breakObjects[i].sid == sid) {
  5945. breakObjects.splice(i, 1);
  5946. break;
  5947. }
  5948. }
  5949. if (!player.canSee(findObj)) {
  5950. breakTrackers.push({
  5951. x: findObj.x,
  5952. y: findObj.y
  5953. });
  5954. }
  5955. if (breakTrackers.length > 8) {
  5956. breakTrackers.shift();
  5957. }
  5958. traps.replacer(findObj);
  5959. }
  5960. }
  5961.  
  5962. // KILL ALL OBJECTS BY A PLAYER:
  5963. function killObjects(sid) {
  5964. if (player) objectManager.removeAllItems(sid);
  5965. }
  5966. function setTickout(doo, timeout) {
  5967. if (!ticks.manage[ticks.tick + timeout]) {
  5968. ticks.manage[ticks.tick + timeout] = [doo];
  5969. } else {
  5970. ticks.manage[ticks.tick + timeout].push(doo);
  5971. }
  5972. }
  5973.  
  5974. function caf(e, t) {
  5975. try {
  5976. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  5977. } catch (e) {
  5978. return 0;
  5979. }
  5980. }
  5981.  
  5982. let found = false;
  5983. let autoQ = false;
  5984.  
  5985. let autos = {
  5986. insta: {
  5987. todo: false,
  5988. wait: false,
  5989. count: 4,
  5990. shame: 5
  5991. },
  5992. bull: false,
  5993. antibull: 0,
  5994. reloaded: false,
  5995. stopspin: true
  5996. }
  5997.  
  5998. // UPDATE PLAYER DATA:
  5999. function updatePlayers(data) {
  6000. // if(player.shameCount > 0) {
  6001. // my.reSync = true;
  6002. // } else {
  6003. // my.reSync = false;
  6004. // }
  6005.  
  6006. // let movementPrediction = {
  6007. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6008. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6009. // }
  6010.  
  6011. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6012.  
  6013. // potentialzpiketick.forEach((obj) => {
  6014. // if(cdf(obj, player) <= 200) {
  6015. // packet('a', undefined);
  6016. // }
  6017. // })
  6018.  
  6019. // let newPos = {
  6020. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6021. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6022. // }
  6023.  
  6024. function getAngleDifference(angle1, angle2) {
  6025. // Normalize the angles to be between 0 and 2π
  6026. angle1 = angle1 % (2 * Math.PI);
  6027. angle2 = angle2 % (2 * Math.PI);
  6028.  
  6029. // Calculate the absolute difference between the angles
  6030. let diff = Math.abs(angle1 - angle2);
  6031.  
  6032. // Adjust the difference to be between 0 and π
  6033. if (diff > Math.PI) {
  6034. diff = (2 * Math.PI) - diff;
  6035. }
  6036.  
  6037. return diff;
  6038. }
  6039.  
  6040. // function smartMove(oneTickMove) {
  6041. // let dir = player.moveDir;
  6042.  
  6043. // let found = false
  6044. // 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))
  6045. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6046.  
  6047. // let newPos = {
  6048. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6049. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6050. // }
  6051.  
  6052. // for (let i = 0; i < spikes.length; i++) {
  6053. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6054. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6055. // }
  6056. // }
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062. // if (found != false && !traps.inTrap) {
  6063. // packet("a", undefined);
  6064. // } else {
  6065. // packet("a", dir);
  6066. // }
  6067. // player.oldPos.x2 = player.x2;
  6068. // player.oldPos.y2 = player.y2;
  6069. // }
  6070. // function detectEnemySpikeCollisions(tmpObj) {
  6071. // 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));
  6072. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6073. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6074. // let enemy = {
  6075. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6076. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6077. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6078. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6079. // }
  6080. // let found = false;
  6081. // for (let i = 0; i < spikes.length; i++) {
  6082. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6083. // found = true;
  6084. // }
  6085. // }
  6086.  
  6087. // // player.oldPos.x2 = tmpObj.x2;
  6088. // // player.oldPos.y2 = tmpObj.y2;
  6089. // }
  6090.  
  6091. game.tick++;
  6092. enemy = [];
  6093. nears = [];
  6094. near = [];
  6095. game.tickSpeed = performance.now() - game.lastTick;
  6096. game.lastTick = performance.now();
  6097. players.forEach((tmp) => {
  6098. tmp.forcePos = !tmp.visible;
  6099. tmp.visible = false;
  6100. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6101. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6102. });
  6103. for (let i = 0; i < data.length;) {
  6104. tmpObj = findPlayerBySID(data[i]);
  6105. if (tmpObj) {
  6106. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6107. tmpObj.t2 = game.lastTick;
  6108. tmpObj.oldPos.x2 = tmpObj.x2;
  6109. tmpObj.oldPos.y2 = tmpObj.y2;
  6110. tmpObj.x1 = tmpObj.x;
  6111. tmpObj.y1 = tmpObj.y;
  6112. tmpObj.x2 = data[i + 1];
  6113. tmpObj.y2 = data[i + 2];
  6114. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6115. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6116. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6117. tmpObj.d2 = data[i + 3];
  6118. tmpObj.dt = 0;
  6119. tmpObj.buildIndex = data[i + 4];
  6120. tmpObj.weaponIndex = data[i + 5];
  6121. tmpObj.weaponVariant = data[i + 6];
  6122. tmpObj.team = data[i + 7];
  6123. tmpObj.isLeader = data[i + 8];
  6124. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6125. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6126. tmpObj.skinIndex = data[i + 9];
  6127. tmpObj.tailIndex = data[i + 10];
  6128. tmpObj.iconIndex = data[i + 11];
  6129. tmpObj.zIndex = data[i + 12];
  6130. tmpObj.visible = true;
  6131. tmpObj.update(game.tickSpeed);
  6132. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6133. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6134. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6135. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6136. tmpObj.damageThreat = 0;
  6137. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6138. tmpObj.addShameTimer();
  6139. }
  6140. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6141. tmpObj.shameTimer = 0;
  6142. tmpObj.shameCount = 0;
  6143. if (tmpObj == player) {
  6144. healer();
  6145. }
  6146. }
  6147.  
  6148. botSkts.forEach((bot) => {
  6149. bot.showName = 'YEAHHH'
  6150. })
  6151.  
  6152. for(let i = 0; i < players.length; i++) {
  6153. for(let aa = 0; aa < botSkts.length; aa++) {
  6154. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6155.  
  6156. }
  6157. }
  6158.  
  6159. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6160. autoQ = true;
  6161. healer();
  6162. } else {
  6163. if (autoQ) {
  6164. healer();
  6165. }
  6166. autoQ = false;
  6167. }
  6168.  
  6169.  
  6170. if (tmpObj == player) {
  6171. if (liztobj.length) {
  6172. liztobj.forEach((tmp) => {
  6173. tmp.onNear = false;
  6174. if (tmp.active) {
  6175. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6176. tmp.onNear = true;
  6177. }
  6178. if (tmp.isItem && tmp.owner) {
  6179. if (!tmp.pps && tmpObj.sid == tmp.owner.sid && UTILS.getDist(tmp, tmpObj, 0, 2) > (parseInt(getEl("breakRange").value) || 0) && !tmp.breakObj && ![13, 14, 20].includes(tmp.id)) {
  6180. tmp.breakObj = true;
  6181. breakObjects.push({
  6182. x: tmp.x,
  6183. y: tmp.y,
  6184. sid: tmp.sid
  6185. });
  6186. }
  6187. }
  6188. }
  6189. });
  6190. let nearTrap = liztobj.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 25) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  6191. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6192. })[0];
  6193. if (nearTrap) {
  6194. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6195. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6196. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6197.  
  6198. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6199. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6200. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6201. traps.inTrap = true;
  6202. traps.info = nearTrap;
  6203. } else {
  6204. traps.inTrap = false;
  6205. traps.info = {};
  6206. }
  6207. } else {
  6208. traps.inTrap = false;
  6209. }
  6210. }
  6211. if (tmpObj.weaponIndex < 9) {
  6212. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6213. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6214. } else if (tmpObj.weaponIndex > 8) {
  6215. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6216. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6217. }
  6218. }
  6219. i += 13;
  6220. }
  6221. if (textManager.stack.length) {
  6222. let stacks = [];
  6223. let notstacks = [];
  6224. let num = 0;
  6225. let num2 = 0;
  6226. let pos = {
  6227. x: null,
  6228. y: null
  6229. };
  6230. let pos2 = {
  6231. x: null,
  6232. y: null
  6233. }
  6234. textManager.stack.forEach((text) => {
  6235. if (text.value >= 0) {
  6236. if (num == 0) pos = {
  6237. x: text.x,
  6238. y: text.y
  6239. };
  6240. num += Math.abs(text.value);
  6241. } else {
  6242. if (num2 == 0) pos2 = {
  6243. x: text.x,
  6244. y: text.y
  6245. };
  6246. num2 += Math.abs(text.value);
  6247. }
  6248. });
  6249. if (num2 > 0) {
  6250. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  6251. }
  6252. if (num > 0) {
  6253. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6254. }
  6255. textManager.stack = [];
  6256. }
  6257. if (runAtNextTick.length) {
  6258. runAtNextTick.forEach((tmp) => {
  6259. checkProjectileHolder(...tmp);
  6260. });
  6261. runAtNextTick = [];
  6262. }
  6263. for (let i = 0; i < data.length;) {
  6264. tmpObj = findPlayerBySID(data[i]);
  6265. if (tmpObj) {
  6266. if (!tmpObj.isTeam(player)) {
  6267. enemy.push(tmpObj);
  6268. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6269. nears.push(tmpObj);
  6270. }
  6271. }
  6272. tmpObj.manageReload();
  6273. if (tmpObj != player) {
  6274. tmpObj.addDamageThreat(player);
  6275. }
  6276. }
  6277. i += 13;
  6278. }
  6279. /*projectiles.forEach((proj) => {
  6280. tmpObj = proj;
  6281. if (tmpObj.active) {
  6282. tmpObj.tickUpdate(game.tickSpeed);
  6283. }
  6284. });*/
  6285. if (player && player.alive) {
  6286. if (enemy.length) {
  6287. near = enemy.sort(function(tmp1, tmp2) {
  6288. return tmp1.dist2 - tmp2.dist2;
  6289. })[0];
  6290. } else {
  6291. // console.log("no enemy");
  6292. }
  6293. if (game.tickQueue[game.tick]) {
  6294. game.tickQueue[game.tick].forEach((action) => {
  6295. action();
  6296. });
  6297. game.tickQueue[game.tick] = null;
  6298. }
  6299. if (advHeal.length) {
  6300. advHeal.forEach((updHealth) => {
  6301. let sid = updHealth[0];
  6302. let value = updHealth[1];
  6303. let damaged = updHealth[2];
  6304. tmpObj = findPlayerBySID(sid);
  6305.  
  6306. let bullTicked = false;
  6307.  
  6308. if (tmpObj.health <= 0) {
  6309. if (!tmpObj.death) {
  6310. tmpObj.death = true;
  6311. if (tmpObj != player) {
  6312. addMenuChText("", `${tmpObj.name} {${tmpObj.sid}} has died.`, "red");
  6313. }
  6314. addDeadPlayer(tmpObj);
  6315. }
  6316. }
  6317. if (tmpObj == player) {
  6318. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6319. if (my.reSync) {
  6320. my.reSync = false;
  6321. tmpObj.setBullTick = true;
  6322. }
  6323. bullTicked = true;
  6324. }
  6325. if (inGame) {
  6326. let attackers = getAttacker(damaged);
  6327. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6328. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  6329. let healTimeout = 140 - window.ping;
  6330. let slowHeal = function(timer) {
  6331. setTimeout(() => {
  6332. healer();
  6333. }, timer);
  6334. }
  6335. if (damaged >= (includeSpikeDmgs ? 8 : 20) && tmpObj.damageThreat >= 25 && (game.tick - tmpObj.antiTimer) > 1) {
  6336. tmpObj.canEmpAnti = true;
  6337. tmpObj.antiTimer = game.tick;
  6338. let shame = 4;
  6339. if (tmpObj.shameCount < shame) {
  6340. healer();
  6341. } else {
  6342. slowHeal(healTimeout);
  6343. }
  6344. } else {
  6345. slowHeal(healTimeout);
  6346. }
  6347. if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  6348. }
  6349. } else {
  6350. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6351. tmpObj.setPoisonTick = true;
  6352. }
  6353. }
  6354. });
  6355. advHeal = [];
  6356. }
  6357. players.forEach((tmp) => {
  6358. if (!tmp.visible && player != tmp) {
  6359. tmp.reloads = {
  6360. 0: 0,
  6361. 1: 0,
  6362. 2: 0,
  6363. 3: 0,
  6364. 4: 0,
  6365. 5: 0,
  6366. 6: 0,
  6367. 7: 0,
  6368. 8: 0,
  6369. 9: 0,
  6370. 10: 0,
  6371. 11: 0,
  6372. 12: 0,
  6373. 13: 0,
  6374. 14: 0,
  6375. 15: 0,
  6376. 53: 0,
  6377. };
  6378. }
  6379. if (tmp.setBullTick) {
  6380. tmp.bullTimer = 0;
  6381. }
  6382. if (tmp.setPoisonTick) {
  6383. tmp.poisonTimer = 0;
  6384. }
  6385. tmp.updateTimer();
  6386. });
  6387. if (inGame) {
  6388. if (enemy.length) {
  6389. if (player.canEmpAnti) {
  6390. player.canEmpAnti = false;
  6391. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6392. if (near.reloads[53] == 0) {
  6393. player.empAnti = true;
  6394. player.soldierAnti = false;
  6395. //modLog("EmpAnti");
  6396. } else {
  6397. player.empAnti = false;
  6398. player.soldierAnti = true;
  6399. //modLog("SoldierAnti");
  6400. }
  6401. }
  6402. }
  6403. 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) {
  6404. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6405. })[0];
  6406. if (prehit) {
  6407. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6408. instaC.canSpikeTick = true;
  6409. instaC.syncHit = true;
  6410. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6411. instaC.revTick = true;
  6412. }
  6413. }
  6414. }
  6415. 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) {
  6416. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6417. })[0];
  6418. if (antiSpikeTick && !traps.inTrap) {
  6419. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  6420. my.anti0Tick = 1;
  6421. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  6422. //player.chat.count = 2000;
  6423. }
  6424. }
  6425. }
  6426. 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 : (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate))) && instaC.perfCheck(player, near)) {
  6427. if (player.checkCanInsta(true) >= 100) {
  6428. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6429. } else {
  6430. instaC.nobull = false;
  6431. }
  6432. instaC.can = true;
  6433. } else {
  6434. instaC.can = false;
  6435. }
  6436. macro.q && place(0, getAttackDir());
  6437. macro.f && place(4, getSafeDir());
  6438. macro.v && place(2, getSafeDir());
  6439. macro.y && place(5, getSafeDir());
  6440. macro.h && place(player.getItemType(22), getSafeDir());
  6441. macro.n && place(3, getSafeDir());
  6442. if (game.tick % 1 == 0) {
  6443. if (mills.place) {
  6444. let plcAng = 7.7;
  6445. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6446. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6447. }
  6448. } else {
  6449. if (mills.placeSpawnPads) {
  6450. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6451. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6452. }
  6453. }
  6454. }
  6455. }
  6456. if (instaC.can) {
  6457. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  6458. }
  6459. if (instaC.canCounter) {
  6460. instaC.canCounter = false;
  6461. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6462. instaC.counterType();
  6463. }
  6464. }
  6465. if (instaC.canSpikeTick) {
  6466. instaC.canSpikeTick = false;
  6467. if (instaC.revTick) {
  6468. instaC.revTick = false;
  6469. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6470. instaC.changeType("rev");
  6471. chch(null, "[RevSyncHit]", "yellow");
  6472. }
  6473. } else {
  6474. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6475. instaC.spikeTickType();
  6476. if (instaC.syncHit) {
  6477. chch(null, "[SyncHit]", "yellow");
  6478. }
  6479. }
  6480. }
  6481. }
  6482. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6483. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6484. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6485. }
  6486. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6487. sendAutoGather();
  6488. my.waitHit = 1;
  6489. game.tickBase(() => {
  6490. sendAutoGather();
  6491. my.waitHit = 0;
  6492. }, 1);
  6493. }
  6494. }
  6495. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6496. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6497. selectWeapon(player.weapons[0]);
  6498. }
  6499. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6500. sendAutoGather();
  6501. my.waitHit = 1;
  6502. game.tickBase(() => {
  6503. sendAutoGather();
  6504. my.waitHit = 0;
  6505. }, 1);
  6506. }
  6507. }
  6508. if (traps.inTrap) {
  6509. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6510. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6511. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6512. }
  6513. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6514. sendAutoGather();
  6515. my.waitHit = 1;
  6516. game.tickBase(() => {
  6517. sendAutoGather();
  6518. my.waitHit = 0;
  6519. }, 1);
  6520. }
  6521. }
  6522. }
  6523. if (clicked.g && !traps.inTrap) {
  6524. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6525. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6526. instaC.bowMovement();
  6527. } else {
  6528. instaC.rangeType();
  6529. }
  6530. }
  6531. }
  6532. if (macro.t && !traps.inTrap) {
  6533. 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))) {
  6534. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6535. }
  6536. }
  6537. if (macro["."] && !traps.inTrap) {
  6538. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6539. instaC.boostTickMovement();
  6540. }
  6541. }
  6542. 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)) {
  6543. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6544. if (!my.reloaded) {
  6545. my.reloaded = true;
  6546. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6547. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6548. selectWeapon(player.weapons[fastSpeed]);
  6549. }
  6550. }
  6551. // if(useWasd) {
  6552. // if (!autos.stopspin) {
  6553. // setTimeout(()=>{
  6554. // autos.stopspin = true;
  6555. // }, 375);
  6556. // }
  6557. // }
  6558. } else {
  6559. my.reloaded = false;
  6560. if(useWasd) {
  6561. autos.stopspin = false;
  6562. }
  6563. if (player.reloads[player.weapons[0]] > 0) {
  6564. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6565. selectWeapon(player.weapons[0]);
  6566. }
  6567. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6568. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6569. selectWeapon(player.weapons[1]);
  6570. }
  6571. if(useWasd) {
  6572. if (!autos.stopspin) {
  6573. setTimeout(()=>{
  6574. autos.stopspin = true;
  6575. }, 750);
  6576. }
  6577. }
  6578. }
  6579. }
  6580. }
  6581. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6582. traps.autoPlace();
  6583. }
  6584. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6585. packet("D", getAttackDir());
  6586. }
  6587. let hatChanger = function() {
  6588. if (my.anti0Tick > 0) {
  6589. buyEquip(6, 0);
  6590. } else {
  6591. if (clicks.left || clicks.right) {
  6592. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6593. buyEquip(7, 0);
  6594. buyEquip(18, 1);
  6595. } else {
  6596. if (clicks.left) {
  6597. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6598. } else if (clicks.right) {
  6599. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6600. }
  6601. }
  6602. } else if (traps.inTrap) {
  6603. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6604. buyEquip(40, 0);
  6605. } else {
  6606. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6607. buyEquip(7, 0);
  6608. buyEquip(13, 1);
  6609. } else {
  6610. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 22 : (configs.errorpicininistedigisey) ? 26: 6, 0);
  6611. }
  6612. }
  6613. } else {
  6614. if (player.empAnti || player.soldierAnti) {
  6615. buyEquip(player.empAnti ? 22 : 6, 0);
  6616. buyEquip(21, 1);
  6617. } else {
  6618. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6619. buyEquip(7, 0);
  6620. buyEquip(13, 1);
  6621. } else {
  6622. if (near.dist2 <= 300) {
  6623. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  6624. } else {
  6625. biomeGear(1);
  6626. }
  6627. }
  6628. }
  6629. }
  6630. }
  6631. }
  6632. let accChanger = function () {
  6633. if (near.dist2 <= 270) {
  6634. if (clicks.left) {
  6635. buyEquip(18, 1);
  6636. } else if (!clicks.left){
  6637. buyEquip(21, 1);
  6638. }
  6639. }
  6640. else if (clicks.left) {
  6641. buyEquip(18, 1);
  6642. }
  6643. else {
  6644. buyEquip(11, 1);
  6645. }
  6646. }
  6647. let wasdGears = function() {
  6648. if (my.anti0Tick > 0) {
  6649. buyEquip(12, 0);
  6650. } else {
  6651. if (clicks.left || clicks.right) {
  6652. if (clicks.left) {
  6653. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  6654. } else if (clicks.right) {
  6655. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  6656. }
  6657. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  6658. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  6659. } else if (traps.inTrap) {
  6660. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6661. buyEquip(40, 0);
  6662. } else {
  6663. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  6664. buyEquip(7, 0);
  6665. } else {
  6666. buyEquip(player.empAnti ? 22 : 6, 0);
  6667. }
  6668. }
  6669. } else {
  6670. if (player.empAnti) {
  6671. buyEquip(22, 0);
  6672. } else {
  6673. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  6674. buyEquip(7, 0);
  6675. } else {
  6676. buyEquip(6, 0);
  6677. }
  6678. }
  6679. }
  6680. }
  6681. if (clicks.left || clicks.right) {
  6682. if (clicks.left) {
  6683. buyEquip(0, 1);
  6684. }
  6685. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  6686. buyEquip(13, 1);
  6687. } else if (traps.inTrap) {
  6688. buyEquip(13, 1);
  6689. } else {
  6690. buyEquip(11, 1);
  6691. }
  6692. }
  6693. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  6694. if (useWasd) {
  6695. wasdGears();
  6696. } else {
  6697. hatChanger();
  6698. accChanger();
  6699. }
  6700. }
  6701. //lastMoveDir = getSafeDir();
  6702. //packet("a", lastMoveDir, 1);
  6703. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  6704. autoPush();
  6705. } else {
  6706. if (my.autoPush) {
  6707. my.autoPush = false;
  6708. packet("a", lastMoveDir || undefined, 1);
  6709. }
  6710. }
  6711. if (!my.autoPush && pathFind.active) {
  6712. Pathfinder();
  6713. }
  6714. if (instaC.ticking) {
  6715. instaC.ticking = false;
  6716. }
  6717. if (instaC.syncHit) {
  6718. instaC.syncHit = false;
  6719. }
  6720. if (player.empAnti) {
  6721. player.empAnti = false;
  6722. }
  6723. if (player.soldierAnti) {
  6724. player.soldierAnti = false;
  6725. }
  6726. if (my.anti0Tick > 0) {
  6727. my.anti0Tick--;
  6728. }
  6729. if (traps.replaced) {
  6730. traps.replaced = false;
  6731. }
  6732. if (traps.antiTrapped) {
  6733. traps.antiTrapped = false;
  6734. }
  6735. const getPotentialDamage = (build, user) => {
  6736. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  6737. const weap = user.weapons[weapIndex];
  6738. if (player.reloads[weap]) return 0;
  6739. const weapon = items.weapons[weap];
  6740. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  6741. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  6742. };
  6743.  
  6744. const AutoReplace = () => {
  6745. const replaceable = [];
  6746. const playerX = player.x;
  6747. const playerY = player.y;
  6748. const gameObjectCount = gameObjects.length;
  6749.  
  6750. for (let i = 0; i < gameObjectCount; i++) {
  6751. const build = gameObjects[i];
  6752. if (build.isItem && build.active && build.health > 0) {
  6753. const item = items.list[build.id];
  6754. const posDist = 35 + item.scale + (item.placeOffset || 0);
  6755. const inDistance = cdf(build, player) <= posDist * 2;
  6756. if (inDistance) {
  6757. let canDeal = 0;
  6758. const playersCount = players.length;
  6759. for (let j = 0; j < playersCount; j++) {
  6760. canDeal += getPotentialDamage(build, players[j]);
  6761. }
  6762. if (build.health <= canDeal) {
  6763. replaceable.push(build);
  6764. }
  6765. }
  6766. }
  6767. }
  6768.  
  6769. const findPlacementAngle = (player, itemId, build) => {
  6770. if (!build) return null;
  6771. const MAX_ANGLE = 2 * Math.PI;
  6772. const ANGLE_STEP = Math.PI / 360;
  6773. const item = items.list[player.items[itemId]];
  6774. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  6775. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  6776.  
  6777. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  6778. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  6779. for (let angle of angles) {
  6780. return angle;
  6781. }
  6782. }
  6783. return null;
  6784. };
  6785.  
  6786. const replace = (() => {
  6787. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  6788. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  6789. const buildId = spike ? 4 : 2;
  6790.  
  6791. replaceable.forEach(build => {
  6792. let angle = findPlacementAngle(player, buildId, build);
  6793. if (angle !== null) {
  6794. place(buildId, angle);
  6795. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  6796. }
  6797. });
  6798. });
  6799.  
  6800. if (near && near.dist3 <= 360) {
  6801. replace();
  6802. }
  6803. replace;
  6804. }
  6805. }
  6806. }
  6807. if (botSkts.length) {
  6808. botSkts.forEach((bots) => {
  6809. if (true) {
  6810. bots[0].showName = 'YEAHHH';
  6811. }
  6812. });
  6813. }
  6814. }
  6815. for(var i1 = 0; i1 < liztobj.length; i1++) {
  6816. if (liztobj[i1].active && liztobj[i1].health > 0 && UTILS.getDist(liztobj[i1], player, 0, 2) < 150 && getEl("antipush").checked) { // || liztobj[i1].buildHealth <= items.weapons[nearEnemy.weaponIndex].dmg)
  6817.  
  6818. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  6819. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  6820. selectWeapon(player.weapons[1])
  6821. buyEquip(40, 0);
  6822. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  6823. setTickout( () => {
  6824. buyEquip(6, 0)
  6825. }, 1);
  6826. }
  6827. }
  6828. }
  6829. }
  6830. function ez(context, x, y) {
  6831. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  6832. context.beginPath();
  6833. context.fill();
  6834. context.closePath();
  6835. context.globalAlpha = 1;
  6836. }
  6837. // UPDATE LEADERBOARD:
  6838. function updateLeaderboard(data) {
  6839. lastLeaderboardData = data;
  6840. return;
  6841. UTILS.removeAllChildren(leaderboardData);
  6842. let tmpC = 1;
  6843. for (let i = 0; i < data.length; i += 3) {
  6844. (function(i) {
  6845. UTILS.generateElement({
  6846. class: "leaderHolder",
  6847. parent: leaderboardData,
  6848. children: [
  6849. UTILS.generateElement({
  6850. class: "leaderboardItem",
  6851. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  6852. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  6853. }),
  6854. UTILS.generateElement({
  6855. class: "leaderScore",
  6856. text: UTILS.sFormat(data[i + 2]) || "0"
  6857. })
  6858. ]
  6859. });
  6860. })(i);
  6861. tmpC++;
  6862. }
  6863. }
  6864.  
  6865. // LOAD GAME OBJECT:
  6866. function loadGameObject(data) {
  6867. for (let i = 0; i < data.length;) {
  6868. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  6869. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  6870. sid: data[i + 7]
  6871. } : null));
  6872. // sid, x, y, dir, s, type, data, setSID, owner
  6873. /*let dist = UTILS.getDist({
  6874. x: data[i + 1],
  6875. y: data[i + 2]
  6876. }, player, 0, 2);
  6877. let aim = UTILS.getDirect({
  6878. x: data[i + 1],
  6879. y: data[i + 2]
  6880. }, player, 0, 2);
  6881. find = findObjectBySid(data[i]);
  6882. if (data[i + 6] == 15) {
  6883. if (find && !find.isTeamObject(player)) {
  6884. if (dist <= 100) {
  6885. traps.dist = dist;
  6886. traps.aim = aim;
  6887. traps.protect(aim);
  6888. }
  6889. }
  6890. }*/
  6891. i += 8;
  6892. }
  6893. }
  6894.  
  6895. // ADD AI:
  6896. function loadAI(data) {
  6897. for (let i = 0; i < ais.length; ++i) {
  6898. ais[i].forcePos = !ais[i].visible;
  6899. ais[i].visible = false;
  6900. }
  6901. if (data) {
  6902. let tmpTime = performance.now();
  6903. for (let i = 0; i < data.length;) {
  6904. tmpObj = findAIBySID(data[i]);
  6905. if (tmpObj) {
  6906. tmpObj.index = data[i + 1];
  6907. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  6908. tmpObj.t2 = tmpTime;
  6909. tmpObj.x1 = tmpObj.x;
  6910. tmpObj.y1 = tmpObj.y;
  6911. tmpObj.x2 = data[i + 2];
  6912. tmpObj.y2 = data[i + 3];
  6913. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  6914. tmpObj.d2 = data[i + 4];
  6915. tmpObj.health = data[i + 5];
  6916. tmpObj.dt = 0;
  6917. tmpObj.visible = true;
  6918. } else {
  6919. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  6920. tmpObj.x2 = tmpObj.x;
  6921. tmpObj.y2 = tmpObj.y;
  6922. tmpObj.d2 = tmpObj.dir;
  6923. tmpObj.health = data[i + 5];
  6924. if (!aiManager.aiTypes[data[i + 1]].name)
  6925. tmpObj.name = config.cowNames[data[i + 6]];
  6926. tmpObj.forcePos = true;
  6927. tmpObj.sid = data[i];
  6928. tmpObj.visible = true;
  6929. }
  6930. i += 7;
  6931. }
  6932. }
  6933. }
  6934.  
  6935. // ANIMATE AI:
  6936. function animateAI(sid) {
  6937. tmpObj = findAIBySID(sid);
  6938. if (tmpObj) tmpObj.startAnim();
  6939. }
  6940.  
  6941. // GATHER ANIMATION:
  6942. function gatherAnimation(sid, didHit, index) {
  6943. tmpObj = findPlayerBySID(sid);
  6944. if (tmpObj) {
  6945. tmpObj.startAnim(didHit, index);
  6946. tmpObj.gatherIndex = index;
  6947. tmpObj.gathering = 1;
  6948.  
  6949. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  6950. // healer();
  6951.  
  6952. if (didHit) {
  6953. let tmpObjects = objectManager.hitObj;
  6954. objectManager.hitObj = [];
  6955. game.tickBase(() => {
  6956. // refind
  6957. tmpObj = findPlayerBySID(sid);
  6958. 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);
  6959. tmpObjects.forEach((healthy) => {
  6960. healthy.health -= val;
  6961. });
  6962. }, 1);
  6963. }
  6964. }
  6965. }
  6966.  
  6967. // WIGGLE GAME OBJECT:
  6968. function wiggleGameObject(dir, sid) {
  6969. tmpObj = findObjectBySid(sid);
  6970. if (tmpObj) {
  6971. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  6972. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  6973. if (tmpObj.health) {
  6974. objectManager.hitObj.push(tmpObj);
  6975. }
  6976. }
  6977. }
  6978.  
  6979. // SHOOT TURRET:
  6980. function shootTurret(sid, dir) {
  6981. tmpObj = findObjectBySid(sid);
  6982. if (tmpObj) {
  6983. if (config.anotherVisual) {
  6984. tmpObj.lastDir = dir;
  6985. } else {
  6986. tmpObj.dir = dir;
  6987. }
  6988. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  6989. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  6990. }
  6991. }
  6992.  
  6993. // UPDATE PLAYER VALUE:
  6994. function updatePlayerValue(index, value, updateView) {
  6995. if (player) {
  6996. player[index] = value;
  6997. if (index == "points") {
  6998. if (configs.autoBuy) {
  6999. autoBuy.hat();
  7000. autoBuy.acc();
  7001. }
  7002. } else if (index == "kills") {
  7003. if (configs.killChat) {
  7004. }
  7005. setTimeout(() => {
  7006. sendChat("~$:!#;Noobie-Dead;!#$~");
  7007. },850);
  7008. }
  7009. }
  7010. }
  7011. // ACTION BAR:
  7012. function updateItems(data, wpn) {
  7013. if (data) {
  7014. if (wpn) {
  7015. player.weapons = data;
  7016. player.primaryIndex = player.weapons[0];
  7017. player.secondaryIndex = player.weapons[1];
  7018. if (!instaC.isTrue) {
  7019. selectWeapon(player.weapons[0]);
  7020. }
  7021. } else {
  7022. player.items = data;
  7023. }
  7024. }
  7025.  
  7026. for (let i = 0; i < items.list.length; i++) {
  7027. let tmpI = items.weapons.length + i;
  7028. let actionBarItem = getEl("actionBarItem" + tmpI);
  7029. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7030. // Add shadow to the element
  7031. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7032. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7033.  
  7034. }
  7035.  
  7036. for (let i = 0; i < items.weapons.length; i++) {
  7037. let actionBarItem = getEl("actionBarItem" + i);
  7038. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7039. // Add shadow to the element
  7040. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7041. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7042. }
  7043.  
  7044. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7045. if (kms) {
  7046. getEl("actionBarItem3").style.display = "none";
  7047. getEl("actionBarItem4").style.display = "inline-block";
  7048. }
  7049. }
  7050.  
  7051. // ADD PROJECTILE:
  7052. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7053. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7054. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7055. }
  7056.  
  7057. // REMOVE PROJECTILE:
  7058. function remProjectile(sid, range) {
  7059. for (let i = 0; i < projectiles.length; ++i) {
  7060. if (projectiles[i].sid == sid) {
  7061. projectiles[i].range = range;
  7062. let tmpObjects = objectManager.hitObj;
  7063. objectManager.hitObj = [];
  7064. game.tickBase(() => {
  7065. let val = projectiles[i].dmg;
  7066. tmpObjects.forEach((healthy) => {
  7067. if (healthy.projDmg) {
  7068. healthy.health -= val;
  7069. }
  7070. });
  7071. }, 1);
  7072. }
  7073. }
  7074. }
  7075.  
  7076. // lol this useless,,, fr
  7077. let noob = false;
  7078. let serverReady = true;
  7079. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7080. let wssws = isProd ? "wss" : "ws";
  7081. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7082. let withSync = false;
  7083. project.binaryType = "arraybuffer";
  7084. project.onmessage = function(msg) {
  7085. let data = msg.data;
  7086. if (data == "isready") {
  7087. serverReady = true;
  7088. }
  7089. if (data == "fine") {
  7090. noob = false;
  7091. }
  7092.  
  7093. if (data == "tezt") {
  7094. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7095. }
  7096. if (data == "yeswearesyncer") {
  7097. // let delay = Date.now() - wsDelay;
  7098. withSync = true;
  7099. if (player) {
  7100. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7101. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7102. }
  7103. }
  7104. };
  7105. project.onopen = function() {
  7106. var gameTitle = getEl("gameName");
  7107. gameTitle.innerText = "Moo Moo";
  7108. };
  7109.  
  7110. // SHOW ALLIANCE MENU:
  7111. function allianceNotification(sid, name) {
  7112. let findBotSID = findSID(bots, sid);
  7113. if (findBotSID) {}
  7114. }
  7115.  
  7116. function setPlayerTeam(team, isOwner) {
  7117. if (player) {
  7118. player.team = team;
  7119. player.isOwner = isOwner;
  7120. if (team == null)
  7121. alliancePlayers = [];
  7122. }
  7123. }
  7124.  
  7125. function setAlliancePlayers(data) {
  7126. alliancePlayers = data;
  7127. }
  7128.  
  7129. // STORE MENU:
  7130. function updateStoreItems(type, id, index) {
  7131. if (index) {
  7132. if (!type)
  7133. player.tails[id] = 1;
  7134. else {
  7135. player.latestTail = id;
  7136. }
  7137. } else {
  7138. if (!type)
  7139. player.skins[id] = 1,
  7140. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7141. else {
  7142. player.latestSkin = id;
  7143. }
  7144. }
  7145. }
  7146. function isTeam (tmpObj) {
  7147. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  7148. };
  7149. // SEND MESSAGE:
  7150. function receiveChat(sid, message) {
  7151. let kawaii = false;
  7152. let tmpPlayer = findPlayerBySID(sid);
  7153. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7154. tmpPlayer.chatMessage = message;
  7155. tmpPlayer.chatCountdown = config.chatCountdown;
  7156. if (message.includes("mod")) {
  7157. packet("6", "Error Mod v5")
  7158. }
  7159. }
  7160.  
  7161. // MINIMAP:
  7162. function updateMinimap(data) {
  7163. minimapData = data;
  7164. }
  7165.  
  7166. // SHOW ANIM TEXT:
  7167. function showText(x, y, value, type) {
  7168. // if (config.anotherVisual) {
  7169. textManager.stack.push({
  7170. x: x,
  7171. y: y,
  7172. value: value
  7173. });
  7174. // } else {
  7175. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7176. // }
  7177. }
  7178.  
  7179. /** APPLY SOCKET CODES */
  7180.  
  7181. // BOT:
  7182. let bots = [];
  7183. let ranLocation = {
  7184. x: UTILS.randInt(35, 14365),
  7185. y: UTILS.randInt(35, 14365)
  7186. };
  7187. setInterval(() => {
  7188. ranLocation = {
  7189. x: UTILS.randInt(35, 14365),
  7190. y: UTILS.randInt(35, 14365)
  7191. };
  7192. }, 60000);
  7193. class Bot {
  7194. constructor(id, sid, hats, accessories) {
  7195. this.millPlace = true;
  7196. this.id = id;
  7197. this.sid = sid;
  7198. this.team = null;
  7199. this.skinIndex = 0;
  7200. this.tailIndex = 0;
  7201. this.hitTime = 0;
  7202. this.iconIndex = 0;
  7203. this.enemy = [];
  7204. this.near = [];
  7205. this.dist2 = 0;
  7206. this.aim2 = 0;
  7207. this.tick = 0;
  7208. this.itemCounts = {};
  7209. this.latestSkin = 0;
  7210. this.latestTail = 0;
  7211. this.points = 0;
  7212. this.tails = {};
  7213. for (let i = 0; i < accessories.length; ++i) {
  7214. if (accessories[i].price <= 0)
  7215. this.tails[accessories[i].id] = 1;
  7216. }
  7217. this.skins = {};
  7218. for (let i = 0; i < hats.length; ++i) {
  7219. if (hats[i].price <= 0)
  7220. this.skins[hats[i].id] = 1;
  7221. }
  7222. this.spawn = function(moofoll) {
  7223. this.upgraded = 0;
  7224. this.enemy = [];
  7225. this.near = [];
  7226. this.active = true;
  7227. this.alive = true;
  7228. this.lockMove = false;
  7229. this.lockDir = false;
  7230. this.minimapCounter = 0;
  7231. this.chatCountdown = 0;
  7232. this.shameCount = 0;
  7233. this.shameTimer = 0;
  7234. this.sentTo = {};
  7235. this.gathering = 0;
  7236. this.autoGather = 0;
  7237. this.animTime = 0;
  7238. this.animSpeed = 0;
  7239. this.mouseState = 0;
  7240. this.buildIndex = -1;
  7241. this.weaponIndex = 0;
  7242. this.dmgOverTime = {};
  7243. this.noMovTimer = 0;
  7244. this.maxXP = 300;
  7245. this.XP = 0;
  7246. this.age = 1;
  7247. this.kills = 0;
  7248. this.upgrAge = 2;
  7249. this.upgradePoints = 0;
  7250. this.x = 0;
  7251. this.y = 0;
  7252. this.zIndex = 0;
  7253. this.xVel = 0;
  7254. this.yVel = 0;
  7255. this.slowMult = 1;
  7256. this.dir = 0;
  7257. this.nDir = 0;
  7258. this.dirPlus = 0;
  7259. this.targetDir = 0;
  7260. this.targetAngle = 0;
  7261. this.maxHealth = 100;
  7262. this.health = this.maxHealth;
  7263. this.oldHealth = this.maxHealth;
  7264. this.scale = config.playerScale;
  7265. this.speed = config.playerSpeed;
  7266. this.resetMoveDir();
  7267. this.resetResources(moofoll);
  7268. this.items = [0, 3, 6, 10];
  7269. this.weapons = [0];
  7270. this.shootCount = 0;
  7271. this.weaponXP = [];
  7272. this.isBot = false;
  7273. this.reloads = {
  7274. 0: 0,
  7275. 1: 0,
  7276. 2: 0,
  7277. 3: 0,
  7278. 4: 0,
  7279. 5: 0,
  7280. 6: 0,
  7281. 7: 0,
  7282. 8: 0,
  7283. 9: 0,
  7284. 10: 0,
  7285. 11: 0,
  7286. 12: 0,
  7287. 13: 0,
  7288. 14: 0,
  7289. 15: 0,
  7290. 53: 0,
  7291. };
  7292. this.timeZinceZpawn = 0;
  7293. this.whyDie = "";
  7294. this.clearRadius = false;
  7295. this.circlee = 0;
  7296. };
  7297.  
  7298. // RESET MOVE DIR:
  7299. this.resetMoveDir = function() {
  7300. this.moveDir = undefined;
  7301. };
  7302.  
  7303. // RESET RESOURCES:
  7304. this.resetResources = function(moofoll) {
  7305. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7306. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7307. }
  7308. };
  7309.  
  7310. // SET DATA:
  7311. this.setData = function(data) {
  7312. this.id = data[0];
  7313. this.sid = data[1];
  7314. this.name = data[2];
  7315. this.x = data[3];
  7316. this.y = data[4];
  7317. this.dir = data[5];
  7318. this.health = data[6];
  7319. this.maxHealth = data[7];
  7320. this.scale = data[8];
  7321. this.skinColor = data[9];
  7322. };
  7323.  
  7324.  
  7325. // SHAME SYSTEM:
  7326. this.judgeShame = function() {
  7327. if (this.oldHealth < this.health) {
  7328. if (this.hitTime) {
  7329. let timeSinceHit = this.tick - this.hitTime;
  7330. this.hitTime = 0;
  7331. if (timeSinceHit < 2) {
  7332. this.lastshamecount = this.shameCount;
  7333. this.shameCount++;
  7334. } else {
  7335. this.lastshamecount = this.shameCount;
  7336. this.shameCount = Math.max(0, this.shameCount - 2);
  7337. }
  7338. }
  7339. } else if (this.oldHealth > this.health) {
  7340. this.hitTime = this.tick;
  7341. }
  7342. };
  7343.  
  7344. // CHECK TEAM
  7345. this.isTeam = function (tmpObj) {
  7346. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  7347.  
  7348. };
  7349. // UPDATE WEAPON RELOAD:
  7350. this.manageReloadaa = function() {
  7351. if (this.shooting[53]) {
  7352. this.shooting[53] = 0;
  7353. this.reloads[53] = (2500 - 1000/9);
  7354. } else {
  7355. if (this.reloads[53] > 0) {
  7356. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7357. }
  7358. }
  7359. if (this.gathering || this.shooting[1]) {
  7360. if (this.gathering) {
  7361. this.gathering = 0;
  7362. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7363. this.attacked = true;
  7364. }
  7365. if (this.shooting[1]) {
  7366. this.shooting[1] = 0;
  7367. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7368. this.attacked = true;
  7369. }
  7370. } else {
  7371. this.attacked = false;
  7372. if (this.buildIndex < 0) {
  7373. if (this.reloads[this.weaponIndex] > 0) {
  7374. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7375. }
  7376. }
  7377. }
  7378. };
  7379.  
  7380. this.closeSockets = function(websc) {
  7381. websc.close();
  7382. };
  7383.  
  7384. this.whyDieChat = function(websc, whydie) {
  7385. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  7386. };
  7387. }
  7388. };
  7389.  
  7390. class BotObject {
  7391. constructor(sid) {
  7392. this.sid = sid;
  7393. // INIT:
  7394. this.init = function(x, y, dir, scale, type, data, owner) {
  7395. data = data || {};
  7396. this.active = true;
  7397. this.x = x;
  7398. this.y = y;
  7399. this.scale = scale;
  7400. this.owner = owner;
  7401. this.id = data.id;
  7402. this.dmg = data.dmg;
  7403. this.trap = data.trap;
  7404. this.teleport = data.teleport;
  7405. this.isItem = this.id != undefined;
  7406. };
  7407.  
  7408. }
  7409. };
  7410. class BotObjManager {
  7411. constructor(botObj, fOS) {
  7412. // DISABLE OBJ:
  7413. this.disableObj = function(obj) {
  7414. obj.active = false;
  7415. if (config.anotherVisual) {} else {
  7416. obj.alive = false;
  7417. }
  7418. };
  7419.  
  7420. // ADD NEW:
  7421. let tmpObj;
  7422. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7423. tmpObj = fOS(sid);
  7424. if (!tmpObj) {
  7425. tmpObj = botObj.find((tmp) => !tmp.active);
  7426. if (!tmpObj) {
  7427. tmpObj = new BotObject(sid);
  7428. botObj.push(tmpObj);
  7429. }
  7430. }
  7431. if (setSID) {
  7432. tmpObj.sid = sid;
  7433. }
  7434. tmpObj.init(x, y, dir, s, type, data, owner);
  7435. };
  7436.  
  7437. // DISABLE BY SID:
  7438. this.disableBySid = function(sid) {
  7439. let find = fOS(sid);
  7440. if (find) {
  7441. this.disableObj(find);
  7442. }
  7443. };
  7444.  
  7445. // REMOVE ALL FROM PLAYER:
  7446. this.removeAllItems = function(sid, server) {
  7447. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7448. };
  7449. }
  7450. };
  7451.  
  7452. let botz = [];
  7453.  
  7454. function botSpawn(id) {
  7455. let bot;
  7456. console.log(WS);
  7457. let t = WS.url.split("wss://")[1].split("?")[0];
  7458. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7459. let botPlayer = new Map();
  7460. botSkts.push([botPlayer]);
  7461. botz.push([bot]);
  7462. let botSID;
  7463. let botObj = [];
  7464. let nearObj = [];
  7465. let bD = {
  7466. x: 0,
  7467. y: 0,
  7468. inGame: false,
  7469. closeSocket: false,
  7470. whyDie: ""
  7471. };
  7472. let oldXY = {
  7473. x: 0,
  7474. y: 0,
  7475. };
  7476. let izauto = 0;
  7477. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7478. bot.binaryType = "arraybuffer";
  7479. bot.first = true;
  7480. bot.sendWS = function(type) {
  7481. // EXTRACT DATA ARRAY:
  7482. let data = Array.prototype.slice.call(arguments, 1);
  7483. // SEND MESSAGE:
  7484. let binary = window.msgpack.encode([type, data]);
  7485. bot.send(binary);
  7486. };
  7487. bot.spawn = function() {
  7488. bot.sendWS("M", {
  7489. name: "Trash Slave",
  7490. moofoll: 1,
  7491. skin: "__proto__"
  7492. });
  7493. };
  7494. bot.sendUpgrade = function(index) {
  7495. bot.sendWS("H", index);
  7496. };
  7497. bot.place = function(id, a) {
  7498. try {
  7499. let item = items.list[botPlayer.items[id]];
  7500. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7501. bot.sendWS("G", botPlayer.items[id]);
  7502. bot.sendWS("d", 1, a);
  7503. bot.sendWS("G", botPlayer.weaponIndex, true);
  7504. }
  7505. } catch (e) {
  7506. }
  7507. };
  7508. bot.buye = function(id, index) {
  7509. let nID = 0;
  7510. if (botPlayer.alive && botPlayer.inGame) {
  7511. if (index == 0) {
  7512. if (botPlayer.skins[id]) {
  7513. if (botPlayer.latestSkin != id) {
  7514. bot.sendWS("c", 0, id, 0);
  7515. }
  7516. } else {
  7517. let find = findID(hats, id);
  7518. if (find) {
  7519. if (botPlayer.points >= find.price) {
  7520. bot.sendWS("c", 1, id, 0);
  7521. bot.sendWS("c", 0, id, 0);
  7522. } else {
  7523. if (botPlayer.latestSkin != nID) {
  7524. bot.sendWS("c", 0, nID, 0);
  7525. }
  7526. }
  7527. } else {
  7528. if (botPlayer.latestSkin != nID) {
  7529. bot.sendWS("c", 0, nID, 0);
  7530. }
  7531. }
  7532. }
  7533. } else if (index == 1) {
  7534. if (botPlayer.tails[id]) {
  7535. if (botPlayer.latestTail != id) {
  7536. bot.sendWS("c", 0, id, 1);
  7537. }
  7538. } else {
  7539. let find = findID(accessories, id);
  7540. if (find) {
  7541. if (botPlayer.points >= find.price) {
  7542. bot.sendWS("c", 1, id, 1);
  7543. bot.sendWS("c", 0, id, 1);
  7544. } else {
  7545. if (botPlayer.latestTail != 0) {
  7546. bot.sendWS("c", 0, 0, 1);
  7547. }
  7548. }
  7549. } else {
  7550. if (botPlayer.latestTail != 0) {
  7551. bot.sendWS("c", 0, 0, 1);
  7552. }
  7553. }
  7554. }
  7555. }
  7556. }
  7557. };
  7558. bot.fastGear = function() {
  7559. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7560. bot.buye(31, 0);
  7561. } else {
  7562. if (botPlayer.y2 <= config.snowBiomeTop) {
  7563. bot.buye(15, 0);
  7564. } else {
  7565. bot.buye(12, 0);
  7566. }
  7567. }
  7568. };
  7569. bot.selectWeapon = function(a) {
  7570. packet("G", a, 1);
  7571. }
  7572. function caf(e, t) {
  7573. try {
  7574. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7575. } catch (e) {
  7576. return 0;
  7577. }
  7578. }
  7579. bot.heal = function() {
  7580. if (botPlayer.health < 100) {
  7581. bot.place(0, 0)
  7582. }
  7583. }
  7584. function cdf (e, t){
  7585. try {
  7586. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  7587. } catch(e){
  7588. return Infinity;
  7589. }
  7590. }
  7591. let zoon = 'no';
  7592. bot.zync = function(a) {
  7593. if (!botPlayer.millPlace) {
  7594. zoon = 'yeah';
  7595. bot.place(5, caf(botPlayer, a));
  7596. let NextTickLocation = {
  7597. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7598. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7599. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7600. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7601. };
  7602.  
  7603. function calculateDistance(x1, y1, x2, y2) {
  7604. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  7605. return distance;
  7606. }
  7607. function dotherezt() {
  7608. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7609. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  7610. }
  7611.  
  7612. let aa = setInterval(() => {
  7613. bot.sendWS("G", botPlayer.weapons[1], true);
  7614. if (izauto == 0) {
  7615. bot.sendWS("K", 1);
  7616. izauto = 1;
  7617. }
  7618. setTimeout(() => {
  7619. bot.sendWS("G", botPlayer.weapons[0], true);
  7620. }, 2000);
  7621. bot.buye(53, 0);
  7622. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  7623. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  7624. } else {
  7625. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7626. zoon = 'no';
  7627. bot.sendWS("a", undefined);
  7628. dotherezt();
  7629. clearInterval(aa);
  7630. }
  7631. }, 150);
  7632.  
  7633. setTimeout(() => {
  7634. zoon = 'no';
  7635. clearInterval(aa);
  7636. }, 500);
  7637. }
  7638. };
  7639. bot.onmessage = function(message) {
  7640. let data = new Uint8Array(message.data);
  7641. let parsed = window.msgpack.decode(data);
  7642. let type = parsed[0];
  7643. data = parsed[1];
  7644. if (type == "io-init") {
  7645. bot.spawn();
  7646. }
  7647. if (type == "1") {
  7648. botSID = data[0];
  7649. console.log(botSID)
  7650. }
  7651. if (type == "D") {
  7652. if (data[1]) {
  7653. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  7654. botPlayer.setData(data[0]);
  7655. botPlayer.inGame = true;
  7656. botPlayer.alive = true;
  7657. botPlayer.x2 = undefined;
  7658. botPlayer.y2 = undefined;
  7659. botPlayer.spawn(1);
  7660. botPlayer.oldHealth = 100;
  7661. botPlayer.health = 100;
  7662. botPlayer.showName = 'YEAHHH';
  7663. oldXY = {
  7664. x: data[0][3],
  7665. y: data[0][4]
  7666. }
  7667. bD.inGame = true;
  7668. if (bot.first) {
  7669. bot.first = false;
  7670. bots.push(bD);
  7671. }
  7672. }
  7673. }
  7674. if (type == "P") {
  7675. bot.spawn();
  7676. botPlayer.inGame = false;
  7677. bD.inGame = false;
  7678. }
  7679. if (type == "a") {
  7680. let tmpData = data[0];
  7681. botPlayer.tick++;
  7682. botPlayer.enemy = [];
  7683. botPlayer.near = [];
  7684. bot.showName = 'YEAHHH';
  7685. nearObj = [];
  7686. for (let i = 0; i < tmpData.length;) {
  7687. if (tmpData[i] == botPlayer.sid) {
  7688. botPlayer.x2 = tmpData[i + 1];
  7689. botPlayer.y2 = tmpData[i + 2];
  7690. botPlayer.d2 = tmpData[i + 3];
  7691. botPlayer.buildIndex = tmpData[i + 4];
  7692. botPlayer.weaponIndex = tmpData[i + 5];
  7693. botPlayer.weaponVariant = tmpData[i + 6];
  7694. botPlayer.team = tmpData[i + 7];
  7695. botPlayer.isLeader = tmpData[i + 8];
  7696. botPlayer.skinIndex = tmpData[i + 9];
  7697. botPlayer.tailIndex = tmpData[i + 10];
  7698. botPlayer.iconIndex = tmpData[i + 11];
  7699. botPlayer.zIndex = tmpData[i + 12];
  7700. botPlayer.visible = true;
  7701. bD.x2 = botPlayer.x2;
  7702. bD.y2 = botPlayer.y2;
  7703. }
  7704. i += 13;
  7705. }
  7706.  
  7707. for (let i = 0; i < tmpData.length;) {
  7708. tmpObj = findPlayerBySID(tmpData[i]);
  7709. if (tmpObj) {
  7710. if (!tmpObj.isTeam(botPlayer)) {
  7711. enemy.push(tmpObj);
  7712. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  7713. nears.push(tmpObj);
  7714. }
  7715. }
  7716. }
  7717. i += 13;
  7718. }
  7719.  
  7720. if (enemy.length) {
  7721. //console.log(enemy)
  7722. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  7723. return tmp1.dist2 - tmp2.dist2;
  7724. })[0];
  7725. }
  7726.  
  7727. if (izauto == 1) {
  7728. bot.sendWS("K", 1);
  7729. izauto = 0;
  7730. }
  7731.  
  7732. if (bD.closeSocket) {
  7733. botPlayer.closeSockets(bot);
  7734. }
  7735. if (bD.whyDie != "") {
  7736. botPlayer.whyDieChat(bot, bD.whyDie);
  7737. bD.whyDie = "";
  7738. }
  7739. if (botPlayer.alive) {
  7740. if (player.team) {
  7741. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  7742. botPlayer.team && (bot.sendWS("N"));
  7743. bot.sendWS("b", player.team);
  7744. }
  7745. }
  7746.  
  7747. let item = items.list[botPlayer.items[3]];
  7748. let a = botPlayer.itemCounts[item.group.id]
  7749. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  7750. if (botPlayer.inGame) {
  7751. bot.sendWS("D", botPlayer.moveDir);
  7752. if (izauto == 0) {
  7753. bot.sendWS("K", 1);
  7754. izauto = 1;
  7755. }
  7756. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  7757. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  7758. bot.place(3, aim + 7.7);
  7759. bot.place(3, aim - 7.7);
  7760. bot.place(3, aim);
  7761. oldXY = {
  7762. x: botPlayer.x2,
  7763. y: botPlayer.y2
  7764. };
  7765. }
  7766.  
  7767. if (botPlayer.tick % 90 === 0) {
  7768. let rand = Math.random() * Math.PI * 2;
  7769. botPlayer.moveDir = rand;
  7770. bot.sendWS("a", botPlayer.moveDir);
  7771. }
  7772. }
  7773. bot.fastGear();
  7774. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  7775. botPlayer.millPlace = false;
  7776. // bot.sendWS("K", 1);
  7777. bot.fastGear();
  7778. } else {
  7779. if (botPlayer.inGame) {
  7780. if (botObj.length > 0) {
  7781. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  7782. if (getEl("mode").value == 'fuckemup') {
  7783. // if (getEl("mode").value == "clear") {
  7784. bot.selectWeapon(botPlayer.weapons[1]);
  7785. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  7786. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  7787. 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) {
  7788. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7789. })[0];
  7790. if (nearObj) {
  7791. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  7792. if ((gotoDist - isPassed) > 0) {
  7793. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7794. if (botPlayer.moveDir != undefined) {
  7795. botPlayer.moveDir = undefined;
  7796. bot.sendWS("a", botPlayer.moveDir);
  7797. bot.sendWS("D", botPlayer.nDir);
  7798. }
  7799. } else {
  7800. botPlayer.moveDir = gotoAim;
  7801. bot.sendWS("a", botPlayer.moveDir);
  7802. bot.sendWS("D", botPlayer.nDir);
  7803. }
  7804. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7805. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7806. bot.sendWS("D", botPlayer.nDir);
  7807. }
  7808. if (izauto == 0) {
  7809. bot.sendWS("K", 1);
  7810. izauto = 1;
  7811. }
  7812. bot.buye(40, 0);
  7813. } else {
  7814. botPlayer.moveDir = gotoAim;
  7815. bot.sendWS("a", botPlayer.moveDir);
  7816. bot.sendWS("D", botPlayer.nDir);
  7817. bot.fastGear();
  7818. }
  7819. } else {
  7820. botPlayer.moveDir = gotoAim;
  7821. bot.sendWS("a", botPlayer.moveDir);
  7822. bot.sendWS("D", botPlayer.nDir);
  7823. bot.fastGear();
  7824. }
  7825. }
  7826. }
  7827.  
  7828.  
  7829.  
  7830. if (botObj.length > 0) {
  7831. if (getEl("mode").value == 'flex') {
  7832. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  7833. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  7834. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  7835.  
  7836. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  7837.  
  7838. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  7839. if (dist > 22) // 22 is player speed without booster hat
  7840. return;
  7841. }
  7842. }
  7843.  
  7844.  
  7845. if (botObj.length > 0) {
  7846. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  7847. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7848. })[0];
  7849.  
  7850. if (nearObj) {
  7851. if (izauto == 0) {
  7852. bot.sendWS("K", 1);
  7853. izauto = 1;
  7854. }
  7855. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7856. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7857. bot.sendWS("D", botPlayer.nDir);
  7858. }
  7859. bot.buye(40, 0);
  7860. bot.buye(11, 1);
  7861. } else {
  7862. bot.fastGear();
  7863. bot.buye(11, 1);
  7864. }
  7865. bot.buye(11, 1);
  7866. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  7867. // if (getEl("mode").value == "clear") {
  7868. bot.selectWeapon(botPlayer.weapons[1]);
  7869. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  7870. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  7871. 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) {
  7872. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7873. })[0];
  7874. if (nearObj) {
  7875. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  7876. if ((gotoDist - isPassed) > 0) {
  7877. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7878. if (botPlayer.moveDir != undefined) {
  7879. botPlayer.moveDir = undefined;
  7880. bot.sendWS("a", botPlayer.moveDir);
  7881. bot.sendWS("D", botPlayer.nDir);
  7882. }
  7883. } else {
  7884. botPlayer.moveDir = gotoAim;
  7885. bot.sendWS("a", botPlayer.moveDir);
  7886. bot.sendWS("D", botPlayer.nDir);
  7887. }
  7888. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7889. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7890. bot.sendWS("D", botPlayer.nDir);
  7891. }
  7892. if (izauto == 0) {
  7893. bot.sendWS("K", 1);
  7894. izauto = 1;
  7895. }
  7896. bot.buye(40, 0);
  7897. bot.fastGear();
  7898. } else {
  7899. botPlayer.moveDir = gotoAim;
  7900. bot.sendWS("a", botPlayer.moveDir);
  7901. bot.sendWS("D", botPlayer.nDir);
  7902. bot.fastGear();
  7903. }
  7904. } else {
  7905. botPlayer.moveDir = gotoAim;
  7906. bot.sendWS("a", botPlayer.moveDir);
  7907. bot.sendWS("D", botPlayer.nDir);
  7908. bot.fastGear();
  7909. }
  7910. if (gotoDist > 300) {
  7911. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  7912. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  7913. bot.place(3, aim + 7.7);
  7914. bot.place(3, aim - 7.7);
  7915. bot.place(3, aim);
  7916. oldXY = {
  7917. x: botPlayer.x2,
  7918. y: botPlayer.y2
  7919. };
  7920. }
  7921. }
  7922. }
  7923. }
  7924.  
  7925. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  7926. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  7927.  
  7928. if(!wdaawdwad.length) {
  7929. if(zoon == 'no')
  7930. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  7931. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7932. }
  7933.  
  7934. if(wdaawdwad.length) {
  7935. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  7936. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  7937. 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) {
  7938. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7939. })[0];
  7940. if (nearObj) {
  7941. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  7942. if ((gotoDist - isPassed) > 0) {
  7943. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7944. if (botPlayer.moveDir != undefined) {
  7945. botPlayer.moveDir = undefined;
  7946. bot.sendWS("a", botPlayer.moveDir);
  7947. bot.sendWS("D", botPlayer.nDir);
  7948. }
  7949. } else {
  7950. bot.sendWS("D", botPlayer.nDir);
  7951. }
  7952. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7953. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7954. bot.sendWS("D", botPlayer.nDir);
  7955. }
  7956. if (izauto == 0) {
  7957. bot.sendWS("K", 1);
  7958. izauto = 1;
  7959. }
  7960. bot.buye(40, 0);
  7961. bot.fastGear();
  7962. } else {
  7963. if(zoon == 'no')
  7964. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  7965. if(cdf(player, botPlayer) <= 110)
  7966. bot.sendWS("a", undefined);
  7967. else
  7968. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7969. }
  7970. } else {
  7971. if(wdaawdwad.length) {
  7972. if(zoon == 'no')
  7973. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  7974. if(cdf(player, botPlayer) <= 110)
  7975. bot.sendWS("a", undefined);
  7976. else
  7977. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7978. } else {
  7979. if(zoon == 'no')
  7980. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  7981. if(cdf(player, botPlayer) <= 110)
  7982. bot.sendWS("a", undefined);
  7983. else
  7984. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7985. }
  7986. }
  7987. }
  7988. }
  7989. }
  7990. }
  7991. }
  7992. }
  7993. if (type == "H") {
  7994. let tmpData = data[0];
  7995. for (let i = 0; i < tmpData.length;) {
  7996. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  7997. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  7998. sid: tmpData[i + 7]
  7999. } : null));
  8000. i += 8;
  8001. }
  8002. }
  8003. if (type == "N") {
  8004. let index = data[0];
  8005. let value = data[1];
  8006. if (botPlayer) {
  8007. botPlayer[index] = value;
  8008. }
  8009. }
  8010. if (type == "O") {
  8011. if (data[0] == botPlayer.sid) {
  8012. botPlayer.oldHealth = botPlayer.health;
  8013. botPlayer.health = data[1];
  8014. botPlayer.judgeShame();
  8015. if (botPlayer.oldHealth > botPlayer.health) {
  8016. if (botPlayer.shameCount < 5) {
  8017. for (let i = 0; i < 2; i++) {
  8018. bot.place(0, botPlayer.nDir);
  8019. }
  8020.  
  8021. } else {
  8022. setTimeout(() => {
  8023. for (let i = 0; i < 2; i++) {
  8024. bot.place(0, botPlayer.nDir);
  8025. }
  8026. }, 95);
  8027. }
  8028. }
  8029. }
  8030. }
  8031. if (type == "Q") {
  8032. let sid = data[0];
  8033. botObjManager.disableBySid(sid);
  8034. }
  8035. if (type == "R") {
  8036. let sid = data[0];
  8037. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8038. }
  8039. if (type == "S") {
  8040. let index = data[0];
  8041. let value = data[1];
  8042. if (botPlayer) {
  8043. botPlayer.itemCounts[index] = value;
  8044. }
  8045. }
  8046. if (type == "U") {
  8047. if (data[0] > 0) {
  8048. if(getEl("setup").value == 'dm') {
  8049. if (botPlayer.upgraded == 0) {
  8050. bot.sendUpgrade(7);
  8051. } else if (botPlayer.upgraded == 1) {
  8052. bot.sendUpgrade(17);
  8053. } else if (botPlayer.upgraded == 2) {
  8054. bot.sendUpgrade(31);
  8055. } else if (botPlayer.upgraded == 3) {
  8056. bot.sendUpgrade(23);
  8057. } else if (botPlayer.upgraded == 4) {
  8058. bot.sendUpgrade(9);
  8059. } else if (botPlayer.upgraded == 5) {
  8060. bot.sendUpgrade(34);
  8061. } else if (botPlayer.upgraded == 6) {
  8062. bot.sendUpgrade(12);
  8063. } else if (botPlayer.upgraded == 7) {
  8064. bot.sendUpgrade(15);
  8065. }
  8066. } else if(getEl("setup").value == 'dr') {
  8067. if (botPlayer.upgraded == 0) {
  8068. bot.sendUpgrade(7);
  8069. } else if (botPlayer.upgraded == 1) {
  8070. bot.sendUpgrade(17);
  8071. } else if (botPlayer.upgraded == 2) {
  8072. bot.sendUpgrade(31);
  8073. } else if (botPlayer.upgraded == 3) {
  8074. bot.sendUpgrade(23);
  8075. } else if (botPlayer.upgraded == 4) {
  8076. bot.sendUpgrade(9);
  8077. } else if (botPlayer.upgraded == 5) {
  8078. bot.sendUpgrade(34);
  8079. } else if (botPlayer.upgraded == 6) {
  8080. bot.sendUpgrade(12);
  8081. } else if (botPlayer.upgraded == 7) {
  8082. bot.sendUpgrade(13);
  8083. }
  8084. } else if(getEl("setup").value == 'kh') {
  8085. if (botPlayer.upgraded == 0) {
  8086. bot.sendUpgrade(3);
  8087. } else if (botPlayer.upgraded == 1) {
  8088. bot.sendUpgrade(17);
  8089. } else if (botPlayer.upgraded == 2) {
  8090. bot.sendUpgrade(31);
  8091. } else if (botPlayer.upgraded == 3) {
  8092. bot.sendUpgrade(27);
  8093. } else if (botPlayer.upgraded == 4) {
  8094. bot.sendUpgrade(10);
  8095. } else if (botPlayer.upgraded == 5) {
  8096. bot.sendUpgrade(34);
  8097. } else if (botPlayer.upgraded == 6) {
  8098. bot.sendUpgrade(4);
  8099. } else if (botPlayer.upgraded == 7) {
  8100. bot.sendUpgrade(25);
  8101. }
  8102. } else if(getEl("setup").value == 'zd') {
  8103. if (botPlayer.upgraded == 0) {
  8104. bot.sendUpgrade(3);
  8105. } else if (botPlayer.upgraded == 1) {
  8106. bot.sendUpgrade(17);
  8107. } else if (botPlayer.upgraded == 2) {
  8108. bot.sendUpgrade(31);
  8109. } else if (botPlayer.upgraded == 3) {
  8110. bot.sendUpgrade(27);
  8111. } else if (botPlayer.upgraded == 4) {
  8112. bot.sendUpgrade(9);
  8113. } else if (botPlayer.upgraded == 5) {
  8114. bot.sendUpgrade(34);
  8115. } else if (botPlayer.upgraded == 6) {
  8116. bot.sendUpgrade(12);
  8117. } else if (botPlayer.upgraded == 7) {
  8118. bot.sendUpgrade(15);
  8119. }
  8120. }
  8121. botPlayer.upgraded++;
  8122. }
  8123. }
  8124. if (type == "V") {
  8125. let tmpData = data[0];
  8126. let wpn = data[1];
  8127. if (tmpData) {
  8128. if (wpn) botPlayer.weapons = tmpData;
  8129. else botPlayer.items = tmpData;
  8130. }
  8131.  
  8132. }
  8133. if (type == "5") {
  8134. let type = data[0];
  8135. let id = data[1];
  8136. let index = data[2];
  8137. if (index) {
  8138. if (!type)
  8139. botPlayer.tails[id] = 1;
  8140. else
  8141. botPlayer.latestTail = id;
  8142. } else {
  8143. if (!type)
  8144. botPlayer.skins[id] = 1;
  8145. else
  8146. botPlayer.latestSkin = id;
  8147. }
  8148. }
  8149.  
  8150. if (type == "6") {
  8151. let id = data[0];
  8152. let mzg = data[1]+'';
  8153. if(id == player.sid && mzg.includes("Sync")) {
  8154. bot.zync(botPlayer.near);
  8155. }
  8156. }
  8157. };
  8158. bot.onclose = function() {
  8159. botPlayer.inGame = false;
  8160. bD.inGame = false;
  8161. };
  8162. }
  8163.  
  8164. // RENDER LEAF:
  8165. function renderLeaf(x, y, l, r, ctxt) {
  8166. let endX = x + (l * Math.cos(r));
  8167. let endY = y + (l * Math.sin(r));
  8168. let width = l * 0.4;
  8169. ctxt.moveTo(x, y);
  8170. ctxt.beginPath();
  8171. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8172. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8173. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8174. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8175. ctxt.closePath();
  8176. ctxt.fill();
  8177. ctxt.stroke();
  8178. }
  8179.  
  8180. // RENDER CIRCLE:
  8181. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8182. tmpContext = tmpContext || mainContext;
  8183. tmpContext.beginPath();
  8184. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8185. if (!dontFill) tmpContext.fill();
  8186. if (!dontStroke) tmpContext.stroke();
  8187. }
  8188.  
  8189. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8190. tmpContext = tmpContext || mainContext;
  8191. tmpContext.beginPath();
  8192. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8193. if (!dontFill) tmpContext.fill();
  8194. if (!dontStroke) tmpContext.stroke();
  8195. }
  8196.  
  8197. // RENDER STAR SHAPE:
  8198. function renderStar(ctxt, spikes, outer, inner) {
  8199. let rot = Math.PI / 2 * 3;
  8200. let x, y;
  8201. let step = Math.PI / spikes;
  8202. ctxt.beginPath();
  8203. ctxt.moveTo(0, -outer);
  8204. for (let i = 0; i < spikes; i++) {
  8205. x = Math.cos(rot) * outer;
  8206. y = Math.sin(rot) * outer;
  8207. ctxt.lineTo(x, y);
  8208. rot += step;
  8209. x = Math.cos(rot) * inner;
  8210. y = Math.sin(rot) * inner;
  8211. ctxt.lineTo(x, y);
  8212. rot += step;
  8213. }
  8214. ctxt.lineTo(0, -outer);
  8215. ctxt.closePath();
  8216. }
  8217.  
  8218. function renderHealthStar(ctxt, spikes, outer, inner) {
  8219. let rot = Math.PI / 2 * 3;
  8220. let x, y;
  8221. let step = Math.PI / spikes;
  8222. ctxt.beginPath();
  8223. ctxt.moveTo(0, -outer);
  8224. for (let i = 0; i < spikes; i++) {
  8225. x = Math.cos(rot) * outer;
  8226. y = Math.sin(rot) * outer;
  8227. ctxt.lineTo(x, y);
  8228. rot += step;
  8229. x = Math.cos(rot) * inner;
  8230. y = Math.sin(rot) * inner;
  8231. ctxt.lineTo(x, y);
  8232. rot += step;
  8233. }
  8234. ctxt.lineTo(0, -outer);
  8235. ctxt.closePath();
  8236. }
  8237.  
  8238. // RENDER RECTANGLE:
  8239. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8240. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8241. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8242. }
  8243.  
  8244. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8245. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8246. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8247. }
  8248.  
  8249. // RENDER RECTCIRCLE:
  8250. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8251. ctxt.save();
  8252. ctxt.translate(x, y);
  8253. seg = Math.ceil(seg / 2);
  8254. for (let i = 0; i < seg; i++) {
  8255. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8256. ctxt.rotate(Math.PI / seg);
  8257. }
  8258. ctxt.restore();
  8259. }
  8260.  
  8261. // RENDER BLOB:
  8262. function renderBlob(ctxt, spikes, outer, inner) {
  8263. let rot = Math.PI / 2 * 3;
  8264. let x, y;
  8265. let step = Math.PI / spikes;
  8266. let tmpOuter;
  8267. ctxt.beginPath();
  8268. ctxt.moveTo(0, -inner);
  8269. for (let i = 0; i < spikes; i++) {
  8270. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8271. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8272. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8273. rot += step * 2;
  8274. }
  8275. ctxt.lineTo(0, -inner);
  8276. ctxt.closePath();
  8277. }
  8278.  
  8279. // RENDER TRIANGLE:
  8280. function renderTriangle(s, ctx) {
  8281. ctx = ctx || mainContext;
  8282. let h = s * (Math.sqrt(3) / 2);
  8283. ctx.beginPath();
  8284. ctx.moveTo(0, -h / 2);
  8285. ctx.lineTo(-s / 2, h / 2);
  8286. ctx.lineTo(s / 2, h / 2);
  8287. ctx.lineTo(0, -h / 2);
  8288. ctx.fill();
  8289. ctx.closePath();
  8290. }
  8291.  
  8292. // PREPARE MENU BACKGROUND:
  8293. function prepareMenuBackground() {
  8294. // let tmpMid = config.mapScale / 2;
  8295. // let attempts = 0;
  8296. // for (let i = 0; i < items.list.length * 3;) {
  8297. // if (attempts >= 1000) break;
  8298. // attempts++;
  8299. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8300. // let data = {
  8301. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  8302. // y: tmpMid + UTILS.randFloat(-600, 600),
  8303. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8304. // };
  8305. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8306. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8307. // } else {
  8308. // continue;
  8309. // }
  8310. // i++;
  8311. // }
  8312. }
  8313.  
  8314. const speed = 1;
  8315. // RENDER PLAYERS:
  8316. function renderDeadPlayers(xOffset, yOffset) {
  8317. mainContext.fillStyle = "#91b2db";
  8318. const currentTime = Date.now();
  8319. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8320. if (!dead.startTime) {
  8321. dead.startTime = currentTime;
  8322. dead.angle = 0;
  8323. dead.radius = 0.1;
  8324. }
  8325. const timeElapsed = currentTime - dead.startTime;
  8326. const maxAlpha = 1;
  8327. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8328. dead.animate(delta);
  8329. mainContext.globalAlpha = dead.alpha;
  8330. mainContext.strokeStyle = outlineColor;
  8331. mainContext.save();
  8332. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8333. dead.radius -= 0.001;
  8334. dead.angle += 0.0174533;
  8335. const moveSpeed = 1;
  8336. const x = dead.radius * Math.cos(dead.angle);
  8337. const y = dead.radius * Math.sin(dead.angle);
  8338. dead.x += x * moveSpeed;
  8339. dead.y += y * moveSpeed;
  8340. mainContext.rotate(dead.angle);
  8341. renderDeadPlayer(dead, mainContext);
  8342. mainContext.restore();
  8343. mainContext.fillStyle = "#91b2db";
  8344. if (timeElapsed >= 3000) {
  8345. dead.active = false;
  8346. dead.startTime = null;
  8347. }
  8348. });
  8349. }
  8350. // RENDER PLAYERS:
  8351. function renderPlayers(xOffset, yOffset, zIndex) {
  8352. mainContext.globalAlpha = 1;
  8353. mainContext.fillStyle = "#91b2db";
  8354. for (var i = 0; i < players.length; ++i) {
  8355. tmpObj = players[i];
  8356. if (tmpObj.zIndex == zIndex) {
  8357. tmpObj.animate(delta);
  8358. if (tmpObj.visible) {
  8359. tmpObj.skinRot += (0.002 * delta);
  8360. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  8361. mainContext.save();
  8362. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8363. // RENDER PLAYER:
  8364. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8365. renderPlayer(tmpObj, mainContext);
  8366. mainContext.restore();
  8367.  
  8368. }
  8369. }
  8370. }
  8371. }
  8372. // RENDER DEAD PLAYER:
  8373. function renderDeadPlayer(obj, ctxt) {
  8374. ctxt = ctxt || mainContext;
  8375. ctxt.lineWidth = outlineWidth;
  8376. ctxt.lineJoin = "miter";
  8377. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8378. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8379. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8380. // TAIL/CAPE:
  8381. renderTail2(13, ctxt, obj);
  8382. // WEAPON BELLOW HANDS:
  8383. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8384. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8385. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8386. renderProjectile(obj.scale, 0,
  8387. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8388. }
  8389. }
  8390. // HANDS:
  8391. ctxt.fillStyle = "#ececec";
  8392. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8393. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8394. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8395. // WEAPON ABOVE HANDS:
  8396. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8397. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8398. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8399. renderProjectile(obj.scale, 0,
  8400. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8401. }
  8402. }
  8403. // BUILD ITEM:
  8404. if (obj.buildIndex >= 0) {
  8405. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8406. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8407. }
  8408. // BODY:
  8409. renderCircle(0, 0, obj.scale, ctxt);
  8410. // SKIN
  8411. renderSkin2(48, ctxt, null, obj)
  8412. }
  8413.  
  8414. // RENDER PLAYER:
  8415. function renderPlayer(obj, ctxt) {
  8416. ctxt = ctxt || mainContext;
  8417. ctxt.lineWidth = outlineWidth;
  8418. ctxt.lineJoin = "miter";
  8419. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8420. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8421. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8422.  
  8423. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8424.  
  8425. // TAIL/CAPE:
  8426. if (obj.tailIndex > 0) {
  8427. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8428. }
  8429.  
  8430. // WEAPON BELLOW HANDS:
  8431. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8432. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8433. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8434. renderProjectile(obj.scale, 0,
  8435. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8436. }
  8437. }
  8438.  
  8439. // HANDS:
  8440. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8441. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8442. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8443. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8444.  
  8445. // WEAPON ABOVE HANDS:
  8446. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8447. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8448. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8449. renderProjectile(obj.scale, 0,
  8450. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8451. }
  8452. }
  8453.  
  8454. // BUILD ITEM:
  8455. if (obj.buildIndex >= 0) {
  8456. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8457. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8458. }
  8459.  
  8460. // BODY:
  8461. renderCircle(0, 0, obj.scale, ctxt);
  8462.  
  8463. // SKIN:
  8464. if (obj.skinIndex > 0) {
  8465. ctxt.rotate(Math.PI / 2);
  8466. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8467. }
  8468.  
  8469. }
  8470.  
  8471. // RENDER NORMAL SKIN
  8472. var skinSprites2 = {};
  8473. var skinPointers2 = {};
  8474. function renderSkin2(index, ctxt, parentSkin, owner) {
  8475. tmpSkin = skinSprites2[index];
  8476. if (!tmpSkin) {
  8477. var tmpImage = new Image();
  8478. tmpImage.onload = function() {
  8479. this.isLoaded = true;
  8480. this.onload = null;
  8481. };
  8482. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8483. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8484. skinSprites2[index] = tmpImage;
  8485. tmpSkin = tmpImage;
  8486. }
  8487. var tmpObj = parentSkin||skinPointers2[index];
  8488. if (!tmpObj) {
  8489. for (var i = 0; i < hats.length; ++i) {
  8490. if (hats[i].id == index) {
  8491. tmpObj = hats[i];
  8492. break;
  8493. }
  8494. }
  8495. skinPointers2[index] = tmpObj;
  8496. }
  8497. if (tmpSkin.isLoaded)
  8498. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8499. if (!parentSkin && tmpObj.topSprite) {
  8500. ctxt.save();
  8501. ctxt.rotate(owner.skinRot);
  8502. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8503. ctxt.restore();
  8504. }
  8505. }
  8506.  
  8507. // RENDER SKIN:
  8508. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8509. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8510. var tmpImage = new Image();
  8511. tmpImage.onload = function() {
  8512. this.isLoaded = true,
  8513. this.onload = null
  8514. }
  8515. ,
  8516. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8517. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8518. tmpSkin = tmpImage
  8519. }
  8520. var tmpObj = parentSkin||skinPointers[index];
  8521. if (!tmpObj) {
  8522. for (var i = 0; i < hats.length; ++i) {
  8523. if (hats[i].id == index) {
  8524. tmpObj = hats[i];
  8525. break;
  8526. }
  8527. }
  8528. skinPointers[index] = tmpObj;
  8529. }
  8530. if (tmpSkin.isLoaded)
  8531. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8532. if (!parentSkin && tmpObj.topSprite) {
  8533. ctxt.save();
  8534. ctxt.rotate(owner.skinRot);
  8535. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8536. ctxt.restore();
  8537. }
  8538. }
  8539.  
  8540. var FlareZHat = {
  8541. 7: "https://i.imgur.com/vAOzlyY.png",
  8542. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8543. 40: "https://i.imgur.com/Xzmg27N.png",
  8544. 26: "https://i.imgur.com/I0xGtyZ.png",
  8545. 55: "https://i.imgur.com/uYgDtcZ.png",
  8546. 20: "https://i.imgur.com/f5uhWCk.png",
  8547. };
  8548.  
  8549. function setSkinTextureImage(id, type, id2) {
  8550. if (true) {
  8551. if(FlareZHat[id] && type == "hat") {
  8552. return FlareZHat[id];
  8553. } else {
  8554. if(type == "acc") {
  8555. return ".././img/accessories/access_" + id + ".png";
  8556. } else if(type == "hat") {
  8557. return ".././img/hats/hat_" + id + ".png";
  8558. } else {
  8559. return ".././img/weapons/" + id + ".png";
  8560. }
  8561. }
  8562. } else {
  8563. if(type == "acc") {
  8564. return ".././img/accessories/access_" + id + ".png";
  8565. } else if(type == "hat") {
  8566. return ".././img/hats/hat_" + id + ".png";
  8567. } else {
  8568. return ".././img/weapons/" + id + ".png";
  8569. }
  8570. }
  8571. }
  8572. // RENDER SKINS:
  8573. let skinSprites = {};
  8574. let skinPointers = {};
  8575. let tmpSkin;
  8576.  
  8577. function renderSkin(index, ctxt, parentSkin, owner) {
  8578. tmpSkin = skinSprites[index];
  8579. if (!tmpSkin) {
  8580. let tmpImage = new Image();
  8581. tmpImage.onload = function() {
  8582. this.isLoaded = true;
  8583. this.onload = null;
  8584. };
  8585. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8586. skinSprites[index] = tmpImage;
  8587. tmpSkin = tmpImage;
  8588. }
  8589. let tmpObj = parentSkin || skinPointers[index];
  8590. if (!tmpObj) {
  8591. for (let i = 0; i < hats.length; ++i) {
  8592. if (hats[i].id == index) {
  8593. tmpObj = hats[i];
  8594. break;
  8595. }
  8596. }
  8597. skinPointers[index] = tmpObj;
  8598. }
  8599. if (tmpSkin.isLoaded)
  8600. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8601. if (!parentSkin && tmpObj.topSprite) {
  8602. ctxt.save();
  8603. ctxt.rotate(owner.skinRot);
  8604. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8605. ctxt.restore();
  8606. }
  8607. }
  8608.  
  8609. // RENDER TAIL:
  8610. var FlareZAcc = {
  8611. 21: "https://i.imgur.com/4ddZert.png",
  8612. 19: "https://i.imgur.com/sULkUZT.png",
  8613. };
  8614. function setTailTextureImage(id, type, id2) {
  8615. if (true) {
  8616. if(FlareZAcc[id] && type == "acc") {
  8617. return FlareZAcc[id];
  8618. } else {
  8619. if(type == "acc") {
  8620. return ".././img/accessories/access_" + id + ".png";
  8621. } else if(type == "hat") {
  8622. return ".././img/hats/hat_" + id + ".png";
  8623. } else {
  8624. return ".././img/weapons/" + id + ".png";
  8625. }
  8626. }
  8627. } else {
  8628. if(type == "acc") {
  8629. return ".././img/accessories/access_" + id + ".png";
  8630. } else if(type == "hat") {
  8631. return ".././img/hats/hat_" + id + ".png";
  8632. } else {
  8633. return ".././img/weapons/" + id + ".png";
  8634. }
  8635. }
  8636. }
  8637. function renderTailTextureImage(index, ctxt, owner) {
  8638. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  8639. var tmpImage = new Image();
  8640. tmpImage.onload = function() {
  8641. this.isLoaded = true,
  8642. this.onload = null
  8643. }
  8644. ,
  8645. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  8646. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8647. tmpSkin = tmpImage;
  8648. }
  8649. var tmpObj = accessPointers[index];
  8650. if (!tmpObj) {
  8651. for (var i = 0; i < accessories.length; ++i) {
  8652. if (accessories[i].id == index) {
  8653. tmpObj = accessories[i];
  8654. break;
  8655. }
  8656. }
  8657. accessPointers[index] = tmpObj;
  8658. }
  8659. if (tmpSkin.isLoaded) {
  8660. ctxt.save();
  8661. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8662. if (tmpObj.spin)
  8663. ctxt.rotate(owner.skinRot);
  8664. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8665. ctxt.restore();
  8666. }
  8667. }
  8668.  
  8669. let accessSprites = {};
  8670. let accessPointers = {};
  8671. var txt = true;
  8672.  
  8673. function renderTail(index, ctxt, owner) {
  8674. tmpSkin = accessSprites[index];
  8675. if (!tmpSkin) {
  8676. let tmpImage = new Image();
  8677. tmpImage.onload = function() {
  8678. this.isLoaded = true;
  8679. this.onload = null;
  8680. };
  8681. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8682. accessSprites[index] = tmpImage;
  8683. tmpSkin = tmpImage;
  8684. }
  8685. let tmpObj = accessPointers[index];
  8686. if (!tmpObj) {
  8687. for (let i = 0; i < accessories.length; ++i) {
  8688. if (accessories[i].id == index) {
  8689. tmpObj = accessories[i];
  8690. break;
  8691. }
  8692. }
  8693. accessPointers[index] = tmpObj;
  8694. }
  8695. if (tmpSkin.isLoaded) {
  8696. ctxt.save();
  8697. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  8698. if (tmpObj.spin)
  8699. ctxt.rotate(owner.skinRot);
  8700. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  8701. ctxt.restore();
  8702. }
  8703. }
  8704.  
  8705. var accessSprites2 = {};
  8706. var accessPointers2 = {};
  8707. function renderTail2(index, ctxt, owner) {
  8708. tmpSkin = accessSprites2[index];
  8709. if (!tmpSkin) {
  8710. var tmpImage = new Image();
  8711. tmpImage.onload = function() {
  8712. this.isLoaded = true;
  8713. this.onload = null;
  8714. };
  8715. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8716. accessSprites2[index] = tmpImage;
  8717. tmpSkin = tmpImage;
  8718. }
  8719. var tmpObj = accessPointers2[index];
  8720. if (!tmpObj) {
  8721. for (var i = 0; i < accessories.length; ++i) {
  8722. if (accessories[i].id == index) {
  8723. tmpObj = accessories[i];
  8724. break;
  8725. }
  8726. }
  8727. accessPointers2[index] = tmpObj;
  8728. }
  8729. if (tmpSkin.isLoaded) {
  8730. ctxt.save();
  8731. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8732. if (tmpObj.spin)
  8733. ctxt.rotate(owner.skinRot);
  8734. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8735. ctxt.restore();
  8736. }
  8737. }
  8738.  
  8739. // RENDER TOOL:
  8740. let toolSprites = {};
  8741. function renderTool(obj, variant, x, y, ctxt) {
  8742. let tmpSrc = obj.src + (variant || "");
  8743. let tmpSprite = toolSprites[tmpSrc];
  8744. if (!tmpSprite) {
  8745. tmpSprite = new Image();
  8746. tmpSprite.onload = function() {
  8747. this.isLoaded = true;
  8748. }
  8749. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8750. toolSprites[tmpSrc] = tmpSprite;
  8751. }
  8752. if (tmpSprite.isLoaded)
  8753. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  8754. }
  8755.  
  8756. // RENDER PROJECTILES:
  8757. function renderProjectiles(layer, xOffset, yOffset) {
  8758. for (let i = 0; i < projectiles.length; i++) {
  8759. tmpObj = projectiles[i];
  8760. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  8761. tmpObj.update(delta);
  8762. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  8763. mainContext.save();
  8764. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8765. mainContext.rotate(tmpObj.dir);
  8766. renderProjectile(0, 0, tmpObj, mainContext, 1);
  8767. mainContext.restore();
  8768. }
  8769. }
  8770. };
  8771. }
  8772.  
  8773. // RENDER PROJECTILE:
  8774. let projectileSprites = {};//fz iz zexy
  8775.  
  8776. function renderProjectile(x, y, obj, ctxt, debug) {
  8777. if (obj.src) {
  8778. let tmpSrc = items.projectiles[obj.indx].src;
  8779. let tmpSprite = projectileSprites[tmpSrc];
  8780. if (!tmpSprite) {
  8781. tmpSprite = new Image();
  8782. tmpSprite.onload = function() {
  8783. this.isLoaded = true;
  8784. }
  8785. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8786. projectileSprites[tmpSrc] = tmpSprite;
  8787. }
  8788. if (tmpSprite.isLoaded)
  8789. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  8790. } else if (obj.indx == 1) {
  8791. ctxt.fillStyle = "#939393";
  8792. renderCircle(x, y, obj.scale, ctxt);
  8793. }
  8794. }
  8795.  
  8796. // RENDER AI:
  8797. let aiSprites = {};
  8798.  
  8799. function renderAI(obj, ctxt) {
  8800. let tmpIndx = obj.index;
  8801. let tmpSprite = aiSprites[tmpIndx];
  8802. if (!tmpSprite) {
  8803. let tmpImg = new Image();
  8804. tmpImg.onload = function() {
  8805. this.isLoaded = true;
  8806. this.onload = null;
  8807. };
  8808. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  8809. tmpSprite = tmpImg;
  8810. aiSprites[tmpIndx] = tmpSprite;
  8811. }
  8812. if (tmpSprite.isLoaded) {
  8813. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  8814. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  8815. }
  8816. }
  8817.  
  8818. // RENDER WATER BODIES:
  8819. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  8820.  
  8821. // MIDDLE RIVER:
  8822. let tmpW = config.riverWidth + padding;
  8823. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  8824. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  8825. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  8826. }
  8827. }
  8828.  
  8829. // RENDER GAME OBJECTS:
  8830. let gameObjectSprites = {};
  8831.  
  8832. function getResSprite(obj) {
  8833. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  8834. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  8835. let tmpSprite = gameObjectSprites[tmpIndex];
  8836. if (!tmpSprite) {
  8837. let blurScale = 6;
  8838. let tmpCanvas = document.createElement("canvas");
  8839. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  8840. let tmpContext = tmpCanvas.getContext('2d');
  8841. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8842. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  8843. tmpContext.strokeStyle = outlineColor;
  8844. tmpContext.lineWidth = outlineWidth;
  8845. // if (isNight) {
  8846. // tmpContext.shadowBlur = blurScale;
  8847. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  8848. // }
  8849. if (obj.type == 0) {
  8850. let tmpScale;
  8851. let tmpCount = 8;
  8852. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  8853. for (let i = 0; i < 2; ++i) {
  8854. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  8855. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  8856. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  8857. tmpContext.fill();
  8858. if (!i) {
  8859. tmpContext.stroke();
  8860. tmpContext.shadowBlur = null;
  8861. tmpContext.shadowColor = null;
  8862. tmpContext.globalAlpha = 1;
  8863. }
  8864. }
  8865. } else if (obj.type == 1) {
  8866. if (biomeID == 2) {
  8867. tmpContext.fillStyle = "#606060";
  8868. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  8869. tmpContext.fill();
  8870. tmpContext.stroke();
  8871.  
  8872. //tmpContext.shadowBlur = null;
  8873. //tmpContext.shadowColor = null;
  8874.  
  8875. tmpContext.fillStyle = "#89a54c";
  8876. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  8877. tmpContext.fillStyle = "#a5c65b";
  8878. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  8879. } else {
  8880. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  8881. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  8882. tmpContext.fill();
  8883. tmpContext.stroke();
  8884.  
  8885. //tmpContext.shadowBlur = null;
  8886. //tmpContext.shadowColor = null;
  8887.  
  8888. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  8889. let tmpRange;
  8890. let berries = 4;
  8891. let rotVal = (Math.PI * 2) / berries;
  8892. for (let i = 0; i < berries; ++i) {
  8893. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  8894. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8895. UTILS.randInt(10, 12), tmpContext);
  8896. }
  8897. }
  8898. } else if (obj.type == 2 || obj.type == 3) {
  8899. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  8900. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8901. tmpContext.fill();
  8902. tmpContext.stroke();
  8903.  
  8904. tmpContext.shadowBlur = null;
  8905. tmpContext.shadowColor = null;
  8906.  
  8907. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  8908. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8909. tmpContext.fill();
  8910. }
  8911. tmpSprite = tmpCanvas;
  8912. gameObjectSprites[tmpIndex] = tmpSprite;
  8913. }
  8914. return tmpSprite;
  8915. }
  8916.  
  8917. // GET ITEM SPRITE:
  8918. let itemSprites = [];
  8919.  
  8920. function getItemSprite(obj, asIcon) {
  8921. let tmpSprite = itemSprites[obj.id];
  8922. if (!tmpSprite || asIcon) {
  8923. let blurScale = !asIcon ? 20 : 5;
  8924. let tmpCanvas = document.createElement("canvas");
  8925. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  8926. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  8927.  
  8928. let tmpContext = tmpCanvas.getContext("2d");
  8929. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8930. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  8931. tmpContext.strokeStyle = outlineColor;
  8932. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  8933. if (!asIcon) {
  8934. tmpContext.shadowBlur = 8;
  8935. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  8936. }
  8937.  
  8938. if (obj.name == "apple") {
  8939. tmpContext.fillStyle = "#c15555";
  8940. renderCircle(0, 0, obj.scale, tmpContext);
  8941. tmpContext.fillStyle = "#89a54c";
  8942. let leafDir = -(Math.PI / 2);
  8943. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  8944. 25, leafDir + Math.PI / 2, tmpContext);
  8945. } else if (obj.name == "cookie") {
  8946. tmpContext.fillStyle = "#cca861";
  8947. renderCircle(0, 0, obj.scale, tmpContext);
  8948. tmpContext.fillStyle = "#937c4b";
  8949. let chips = 4;
  8950. let rotVal = (Math.PI * 2) / chips;
  8951. let tmpRange;
  8952. for (let i = 0; i < chips; ++i) {
  8953. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8954. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8955. UTILS.randInt(4, 5), tmpContext, true);
  8956. }
  8957. } else if (obj.name == "cheese") {
  8958. tmpContext.fillStyle = "#f4f3ac";
  8959. renderCircle(0, 0, obj.scale, tmpContext);
  8960. tmpContext.fillStyle = "#c3c28b";
  8961. let chips = 4;
  8962. let rotVal = (Math.PI * 2) / chips;
  8963. let tmpRange;
  8964. for (let i = 0; i < chips; ++i) {
  8965. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8966. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8967. UTILS.randInt(4, 5), tmpContext, true);
  8968. }
  8969. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  8970. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  8971. "#a5974c" : "#939393";
  8972. let sides = (obj.name == "castle wall") ? 4 : 3;
  8973. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  8974. tmpContext.fill();
  8975. tmpContext.stroke();
  8976. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  8977. "#c9b758" : "#bcbcbc";
  8978. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  8979. tmpContext.fill();
  8980. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  8981. obj.name == "spinning spikes") {
  8982. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  8983. let tmpScale = (obj.scale * 0.6);
  8984. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  8985. tmpContext.fill();
  8986. tmpContext.stroke();
  8987. tmpContext.fillStyle = "#a5974c";
  8988. renderCircle(0, 0, tmpScale, tmpContext);
  8989. tmpContext.fillStyle = "#c9b758";
  8990. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8991. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8992. tmpContext.fillStyle = "#a5974c";
  8993. renderCircle(0, 0, reScale, tmpContext);
  8994. tmpContext.fillStyle = "#c9b758";
  8995. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  8996. tmpContext.fillStyle = "#a5974c";
  8997. renderCircle(0, 0, reScale * 0.5, tmpContext);
  8998. } else if (obj.name == "mine") {
  8999. tmpContext.fillStyle = "#939393";
  9000. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9001. tmpContext.fill();
  9002. tmpContext.stroke();
  9003. tmpContext.fillStyle = "#bcbcbc";
  9004. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9005. tmpContext.fill();
  9006. } else if (obj.name == "sapling") {
  9007. for (let i = 0; i < 2; ++i) {
  9008. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9009. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9010. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9011. tmpContext.fill();
  9012. if (!i) tmpContext.stroke();
  9013. }
  9014. } else if (obj.name == "pit trap") {
  9015. tmpContext.fillStyle = "#a5974c";
  9016. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9017. tmpContext.fill();
  9018. tmpContext.stroke();
  9019. tmpContext.fillStyle = outlineColor;
  9020. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9021. tmpContext.fill();
  9022. } else if (obj.name == "boost pad") {
  9023. tmpContext.fillStyle = "#7e7f82";
  9024. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9025. tmpContext.fill();
  9026. tmpContext.stroke();
  9027. tmpContext.fillStyle = "#dbd97d";
  9028. renderTriangle(obj.scale * 1, tmpContext);
  9029. } else if (obj.name == "turret") {
  9030. tmpContext.fillStyle = "#a5974c";
  9031. renderCircle(0, 0, obj.scale, tmpContext);
  9032. tmpContext.fill();
  9033. tmpContext.stroke();
  9034. tmpContext.fillStyle = "#939393";
  9035. let tmpLen = 50;
  9036. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9037. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9038. tmpContext.fill();
  9039. tmpContext.stroke();
  9040. } else if (obj.name == "platform") {
  9041. tmpContext.fillStyle = "#cebd5f";
  9042. let tmpCount = 4;
  9043. let tmpS = obj.scale * 2;
  9044. let tmpW = tmpS / tmpCount;
  9045. let tmpX = -(obj.scale / 2);
  9046. for (let i = 0; i < tmpCount; ++i) {
  9047. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9048. tmpContext.fill();
  9049. tmpContext.stroke();
  9050. tmpX += tmpS / tmpCount;
  9051. }
  9052. } else if (obj.name == "healing pad") {
  9053. tmpContext.fillStyle = "#7e7f82";
  9054. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9055. tmpContext.fill();
  9056. tmpContext.stroke();
  9057. tmpContext.fillStyle = "#db6e6e";
  9058. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9059. } else if (obj.name == "spawn pad") {
  9060. tmpContext.fillStyle = "#7e7f82";
  9061. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9062. tmpContext.fill();
  9063. tmpContext.stroke();
  9064. tmpContext.fillStyle = "#71aad6";
  9065. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9066. } else if (obj.name == "blocker") {
  9067. tmpContext.fillStyle = "#7e7f82";
  9068. renderCircle(0, 0, obj.scale, tmpContext);
  9069. tmpContext.fill();
  9070. tmpContext.stroke();
  9071. tmpContext.rotate(Math.PI / 4);
  9072. tmpContext.fillStyle = "#db6e6e";
  9073. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9074. } else if (obj.name == "teleporter") {
  9075. tmpContext.fillStyle = "#7e7f82";
  9076. renderCircle(0, 0, obj.scale, tmpContext);
  9077. tmpContext.fill();
  9078. tmpContext.stroke();
  9079. tmpContext.rotate(Math.PI / 4);
  9080. tmpContext.fillStyle = "#d76edb";
  9081. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9082. }
  9083. tmpSprite = tmpCanvas;
  9084. if (!asIcon)
  9085. itemSprites[obj.id] = tmpSprite;
  9086. }
  9087. return tmpSprite;
  9088. }
  9089.  
  9090. function getItemSprite2(obj, tmpX, tmpY) {
  9091. let tmpContext = mainContext;
  9092. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9093. tmpContext.save();
  9094. tmpContext.translate(tmpX, tmpY);
  9095. tmpContext.rotate(obj.dir);
  9096. tmpContext.strokeStyle = outlineColor;
  9097. tmpContext.lineWidth = outlineWidth;
  9098. if (obj.name == "apple") {
  9099. tmpContext.fillStyle = "#c15555";
  9100. renderCircle(0, 0, obj.scale, tmpContext);
  9101. tmpContext.fillStyle = "#89a54c";
  9102. let leafDir = -(Math.PI / 2);
  9103. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9104. 25, leafDir + Math.PI / 2, tmpContext);
  9105. } else if (obj.name == "cookie") {
  9106. tmpContext.fillStyle = "#cca861";
  9107. renderCircle(0, 0, obj.scale, tmpContext);
  9108. tmpContext.fillStyle = "#937c4b";
  9109. let chips = 4;
  9110. let rotVal = (Math.PI * 2) / chips;
  9111. let tmpRange;
  9112. for (let i = 0; i < chips; ++i) {
  9113. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9114. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9115. UTILS.randInt(4, 5), tmpContext, true);
  9116. }
  9117. } else if (obj.name == "cheese") {
  9118. tmpContext.fillStyle = "#f4f3ac";
  9119. renderCircle(0, 0, obj.scale, tmpContext);
  9120. tmpContext.fillStyle = "#c3c28b";
  9121. let chips = 4;
  9122. let rotVal = (Math.PI * 2) / chips;
  9123. let tmpRange;
  9124. for (let i = 0; i < chips; ++i) {
  9125. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9126. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9127. UTILS.randInt(4, 5), tmpContext, true);
  9128. }
  9129. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9130. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9131. "#a5974c" : "#939393";
  9132. let sides = (obj.name == "castle wall") ? 4 : 3;
  9133. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9134. tmpContext.fill();
  9135. tmpContext.stroke();
  9136. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9137. "#c9b758" : "#bcbcbc";
  9138. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9139. tmpContext.fill();
  9140. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9141. obj.name == "spinning spikes") {
  9142. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9143. let tmpScale = (obj.scale * 0.6);
  9144. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9145. tmpContext.fill();
  9146. tmpContext.stroke();
  9147. tmpContext.fillStyle = "#a5974c";
  9148. renderCircle(0, 0, tmpScale, tmpContext);
  9149. tmpContext.fillStyle = "#c9b758";
  9150. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9151. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9152. tmpContext.fillStyle = "#a5974c";
  9153. renderCircle(0, 0, reScale, tmpContext);
  9154. tmpContext.fillStyle = "#c9b758";
  9155. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9156. tmpContext.fillStyle = "#a5974c";
  9157. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9158. } else if (obj.name == "mine") {
  9159. tmpContext.fillStyle = "#939393";
  9160. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9161. tmpContext.fill();
  9162. tmpContext.stroke();
  9163. tmpContext.fillStyle = "#bcbcbc";
  9164. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9165. tmpContext.fill();
  9166. } else if (obj.name == "sapling") {
  9167. for (let i = 0; i < 2; ++i) {
  9168. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9169. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9170. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9171. tmpContext.fill();
  9172. if (!i) tmpContext.stroke();
  9173. }
  9174. } else if (obj.name == "pit trap") {
  9175. tmpContext.fillStyle = "#a5974c";
  9176. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9177. tmpContext.fill();
  9178. tmpContext.stroke();
  9179. tmpContext.fillStyle = outlineColor;
  9180. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9181. tmpContext.fill();
  9182. } else if (obj.name == "boost pad") {
  9183. tmpContext.fillStyle = "#7e7f82";
  9184. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9185. tmpContext.fill();
  9186. tmpContext.stroke();
  9187. tmpContext.fillStyle = "#dbd97d";
  9188. renderTriangle(obj.scale * 1, tmpContext);
  9189. } else if (obj.name == "turret") {
  9190. tmpContext.fillStyle = "#a5974c";
  9191. renderCircle(0, 0, obj.scale, tmpContext);
  9192. tmpContext.fill();
  9193. tmpContext.stroke();
  9194. tmpContext.fillStyle = "#939393";
  9195. let tmpLen = 50;
  9196. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9197. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9198. tmpContext.fill();
  9199. tmpContext.stroke();
  9200. } else if (obj.name == "platform") {
  9201. tmpContext.fillStyle = "#cebd5f";
  9202. let tmpCount = 4;
  9203. let tmpS = obj.scale * 2;
  9204. let tmpW = tmpS / tmpCount;
  9205. let tmpX = -(obj.scale / 2);
  9206. for (let i = 0; i < tmpCount; ++i) {
  9207. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9208. tmpContext.fill();
  9209. tmpContext.stroke();
  9210. tmpX += tmpS / tmpCount;
  9211. }
  9212. } else if (obj.name == "healing pad") {
  9213. tmpContext.fillStyle = "#7e7f82";
  9214. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9215. tmpContext.fill();
  9216. tmpContext.stroke();
  9217. tmpContext.fillStyle = "#db6e6e";
  9218. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9219. } else if (obj.name == "spawn pad") {
  9220. tmpContext.fillStyle = "#7e7f82";
  9221. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9222. tmpContext.fill();
  9223. tmpContext.stroke();
  9224. tmpContext.fillStyle = "#71aad6";
  9225. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9226. } else if (obj.name == "blocker") {
  9227. tmpContext.fillStyle = "#7e7f82";
  9228. renderCircle(0, 0, obj.scale, tmpContext);
  9229. tmpContext.fill();
  9230. tmpContext.stroke();
  9231. tmpContext.rotate(Math.PI / 4);
  9232. tmpContext.fillStyle = "#db6e6e";
  9233. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9234. } else if (obj.name == "teleporter") {
  9235. tmpContext.fillStyle = "#7e7f82";
  9236. renderCircle(0, 0, obj.scale, tmpContext);
  9237. tmpContext.fill();
  9238. tmpContext.stroke();
  9239. tmpContext.rotate(Math.PI / 4);
  9240. tmpContext.fillStyle = "#d76edb";
  9241. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9242. }
  9243. tmpContext.restore();
  9244. }
  9245.  
  9246. let objSprites = [];
  9247.  
  9248. function getObjSprite(obj) {
  9249. let tmpSprite = objSprites[obj.id];
  9250. if (!tmpSprite) {
  9251. // let blurScale = isNight ? 20 : 0;
  9252. let tmpCanvas = document.createElement("canvas");
  9253. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  9254. let tmpContext = tmpCanvas.getContext("2d");
  9255. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9256. tmpContext.rotate(Math.PI / 2);
  9257. tmpContext.strokeStyle = outlineColor;
  9258. tmpContext.lineWidth = outlineWidth;
  9259. // if (isNight) {
  9260. // tmpContext.shadowBlur = 20;
  9261. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9262. // }
  9263. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9264. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9265. let tmpScale = obj.scale * 0.6;
  9266. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9267. tmpContext.fill();
  9268. tmpContext.stroke();
  9269. tmpContext.fillStyle = "#a5974c";
  9270. renderCircle(0, 0, tmpScale, tmpContext);
  9271. tmpContext.fillStyle = "#cc5151";
  9272. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9273. } else if (obj.name == "pit trap") {
  9274. tmpContext.fillStyle = "#a5974c";
  9275. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9276. tmpContext.fill();
  9277. tmpContext.stroke();
  9278. tmpContext.fillStyle = "#cc5151";
  9279. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9280. tmpContext.fill();
  9281. }
  9282. tmpSprite = tmpCanvas;
  9283. objSprites[obj.id] = tmpSprite;
  9284. }
  9285. return tmpSprite;
  9286. }
  9287.  
  9288. // GET MARK SPRITE:
  9289. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9290. let center = {
  9291. x: screenWidth / 2,
  9292. y: screenHeight / 2,
  9293. };
  9294. tmpContext.lineWidth = outlineWidth;
  9295. mainContext.globalAlpha = 0.2;
  9296. tmpContext.strokeStyle = outlineColor;
  9297. tmpContext.save();
  9298. tmpContext.translate(tmpX, tmpY);
  9299. tmpContext.rotate(90**10);
  9300. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9301. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9302. var tmpScale = (obj.scale);
  9303. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9304. tmpContext.fill();
  9305. tmpContext.stroke();
  9306. tmpContext.fillStyle = "#a5974c";
  9307. renderCircle(0, 0, tmpScale, tmpContext);
  9308. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9309. tmpContext.fillStyle = "#a34040";
  9310. } else {
  9311. tmpContext.fillStyle = "#c9b758";
  9312. }
  9313. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9314. } else if (obj.name == "turret") {
  9315. renderCircle(0, 0, obj.scale, tmpContext);
  9316. tmpContext.fill();
  9317. tmpContext.stroke();
  9318. tmpContext.fillStyle = "#939393";
  9319. let tmpLen = 50;
  9320. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9321. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9322. tmpContext.fill();
  9323. tmpContext.stroke();
  9324. } else if (obj.name == "teleporter") {
  9325. tmpContext.fillStyle = "#7e7f82";
  9326. renderCircle(0, 0, obj.scale, tmpContext);
  9327. tmpContext.fill();
  9328. tmpContext.stroke();
  9329. tmpContext.rotate(Math.PI / 4);
  9330. tmpContext.fillStyle = "#d76edb";
  9331. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9332. } else if (obj.name == "platform") {
  9333. tmpContext.fillStyle = "#cebd5f";
  9334. let tmpCount = 4;
  9335. let tmpS = obj.scale * 2;
  9336. let tmpW = tmpS / tmpCount;
  9337. let tmpX = -(obj.scale / 2);
  9338. for (let i = 0; i < tmpCount; ++i) {
  9339. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9340. tmpContext.fill();
  9341. tmpContext.stroke();
  9342. tmpX += tmpS / tmpCount;
  9343. }
  9344. } else if (obj.name == "healing pad") {
  9345. tmpContext.fillStyle = "#7e7f82";
  9346. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9347. tmpContext.fill();
  9348. tmpContext.stroke();
  9349. tmpContext.fillStyle = "#db6e6e";
  9350. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9351. } else if (obj.name == "spawn pad") {
  9352. tmpContext.fillStyle = "#7e7f82";
  9353. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9354. tmpContext.fill();
  9355. tmpContext.stroke();
  9356. tmpContext.fillStyle = "#71aad6";
  9357. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9358. } else if (obj.name == "blocker") {
  9359. tmpContext.fillStyle = "#7e7f82";
  9360. renderCircle(0, 0, obj.scale, tmpContext);
  9361. tmpContext.fill();
  9362. tmpContext.stroke();
  9363. tmpContext.rotate(Math.PI / 4);
  9364. tmpContext.fillStyle = "#db6e6e";
  9365. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9366. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9367. tmpContext.fillStyle = "#a5974c";
  9368. renderCircle(0, 0, obj.scale, tmpContext);
  9369. tmpContext.fillStyle = "#c9b758";
  9370. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9371. tmpContext.fillStyle = "#a5974c";
  9372. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9373.  
  9374. } else if (obj.name == "pit trap") {
  9375. tmpContext.fillStyle = "#a5974c";
  9376. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9377. tmpContext.fill();
  9378. tmpContext.stroke();
  9379. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9380. tmpContext.fillStyle = "#a34040";
  9381. } else {
  9382. tmpContext.fillStyle = outlineColor;
  9383. }
  9384. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9385. tmpContext.fill();
  9386. }
  9387. tmpContext.restore();
  9388. }
  9389.  
  9390. // OBJECT ON SCREEN:
  9391. function isOnScreen(x, y, s) {
  9392. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9393. s,
  9394. maxScreenHeight));
  9395. }
  9396.  
  9397. // RENDER GAME OBJECTS:
  9398. function renderGameObjects(layer, xOffset, yOffset) {
  9399. let tmpSprite;
  9400. let tmpX;
  9401. let tmpY;
  9402. liztobj.forEach((tmp) => {
  9403. tmpObj = tmp;
  9404. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9405. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9406. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9407. if (layer == 0) {
  9408. tmpObj.update(delta);
  9409. }
  9410. mainContext.globalAlpha = tmpObj.alpha;
  9411. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9412. if (tmpObj.isItem) {
  9413. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9414. tmpSprite = getObjSprite(tmpObj);
  9415. } else {
  9416. tmpSprite = getItemSprite(tmpObj);
  9417. }
  9418.  
  9419. mainContext.save();
  9420. mainContext.translate(tmpX, tmpY);
  9421. mainContext.rotate(tmpObj.dir);
  9422. if (!tmpObj.active) {
  9423. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9424. }
  9425. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9426.  
  9427. if (tmpObj.blocker) {
  9428. mainContext.strokeStyle = "#db6e6e";
  9429. mainContext.globalAlpha = 0.3;
  9430. mainContext.lineWidth = 6;
  9431. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9432. }
  9433. mainContext.restore();
  9434. } else {
  9435. tmpSprite = getResSprite(tmpObj);
  9436. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9437. }
  9438. }
  9439. if (layer == 3 && !useWasd) {
  9440. if (tmpObj.health < tmpObj.maxHealth) {
  9441. // HEALTH HOLDER:
  9442. mainContext.fillStyle = darkOutlineColor;
  9443. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9444. mainContext.fill();
  9445.  
  9446. // HEALTH BAR:
  9447. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  9448. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9449. mainContext.fill();
  9450. }
  9451. }
  9452. }
  9453. });
  9454.  
  9455. // PLACE VISIBLE:
  9456. if (layer == 0) {
  9457. if (placeVisible.length) {
  9458. placeVisible.forEach((places) => {
  9459. tmpX = places.x - xOffset;
  9460. tmpY = places.y - yOffset;
  9461. markObject(places, tmpX, tmpY);
  9462. });
  9463. }
  9464. }
  9465. }
  9466.  
  9467. function markObject(tmpObj, tmpX, tmpY) {
  9468. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9469. }
  9470.  
  9471. // RENDER MINIMAP:
  9472. class MapPing {
  9473. constructor(color, scale) {
  9474. this.init = function(x, y) {
  9475. this.scale = 0;
  9476. this.x = x;
  9477. this.y = y;
  9478. this.active = true;
  9479. };
  9480. this.update = function(ctxt, delta) {
  9481. if (this.active) {
  9482. this.scale += 0.05 * delta;
  9483. if (this.scale >= scale) {
  9484. this.active = false;
  9485. } else {
  9486. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9487. ctxt.beginPath();
  9488. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9489. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9490. ctxt.stroke();
  9491. }
  9492. }
  9493. };
  9494. this.color = color;
  9495. }
  9496. }
  9497.  
  9498. function pingMap(x, y) {
  9499. tmpPing = mapPings.find(pings => !pings.active);
  9500. if (!tmpPing) {
  9501. tmpPing = new MapPing("#fff", config.mapPingScale);
  9502. mapPings.push(tmpPing);
  9503. }
  9504. tmpPing.init(x, y);
  9505. }
  9506.  
  9507. function updateMapMarker() {
  9508. mapMarker.x = player.x;
  9509. mapMarker.y = player.y;
  9510. }
  9511.  
  9512. function renderMinimap(delta) {
  9513. if (player && player.alive) {
  9514. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9515.  
  9516. // RENDER PINGS:
  9517. mapContext.lineWidth = 4;
  9518. for (let i = 0; i < mapPings.length; ++i) {
  9519. tmpPing = mapPings[i];
  9520. mapContext.strokeStyle = tmpPing.color;
  9521. tmpPing.update(mapContext, delta);
  9522. }
  9523.  
  9524. // RENDER BREAK TRACKS:
  9525. mapContext.globalAlpha = 1;
  9526. mapContext.fillStyle = "#ff0000";
  9527. if (breakTrackers.length) {
  9528. mapContext.fillStyle = "#abcdef";
  9529. mapContext.font = "34px HammerSmith One";
  9530. mapContext.textBaseline = "middle";
  9531. mapContext.textAlign = "center";
  9532. for (let i = 0; i < breakTrackers.length;) {
  9533. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9534. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9535. i += 2;
  9536. }
  9537. }
  9538.  
  9539. // RENDER PLAYERS:
  9540. mapContext.globalAlpha = 1;
  9541. mapContext.fillStyle = "#fff";
  9542. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9543. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9544. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9545. if (player.team && minimapData) {
  9546. for (let i = 0; i < minimapData.length;) {
  9547. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9548. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9549. i += 2;
  9550. }
  9551. }
  9552.  
  9553. // RENDER BOTS:
  9554. if (bots.length) {
  9555. bots.forEach((tmp) => {
  9556. if (tmp.inGame) {
  9557. mapContext.globalAlpha = 1;
  9558. mapContext.strokeStyle = "#cc5151";
  9559. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9560. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9561. }
  9562. });
  9563. }
  9564.  
  9565. // DEATH LOCATION:
  9566. if (lastDeath) {
  9567. mapContext.fillStyle = "#fc5553";
  9568. mapContext.font = "34px HammerSmith One";
  9569. mapContext.textBaseline = "middle";
  9570. mapContext.textAlign = "center";
  9571. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9572. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9573. }
  9574.  
  9575. // MAP MARKER:
  9576. if (mapMarker) {
  9577. mapContext.fillStyle = "#fff";
  9578. mapContext.font = "34px HammerSmith One";
  9579. mapContext.textBaseline = "middle";
  9580. mapContext.textAlign = "center";
  9581. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9582. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9583. }
  9584. }
  9585. }
  9586.  
  9587. // ICONS:
  9588. let crossHairs = ["https://cdn.discordapp.com/attachments/1201476000756793404/1217482478001066066/crosshair-icon-2048x2048-5h6w9rqc.png?ex=66042fea&is=65f1baea&hm=ff2ca80a938e24d18852cb8a6a5566f01fa698f2519bd551f03c295e9fee66df&", "https://cdn.discordapp.com/attachments/1201476000756793404/1217482478001066066/crosshair-icon-2048x2048-5h6w9rqc.png?ex=66042fea&is=65f1baea&hm=ff2ca80a938e24d18852cb8a6a5566f01fa698f2519bd551f03c295e9fee66df&"];
  9589. let crossHairSprites = {};
  9590. let iconSprites = {};
  9591. let icons = ["crown", "skull"];
  9592.  
  9593. function loadIcons() {
  9594. for (let i = 0; i < icons.length; ++i) {
  9595. let tmpSprite = new Image();
  9596. tmpSprite.onload = function() {
  9597. this.isLoaded = true;
  9598. };
  9599. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9600. iconSprites[icons[i]] = tmpSprite;
  9601. }
  9602. for (let i = 0; i < crossHairs.length; ++i) {
  9603. let tmpSprite = new Image();
  9604. tmpSprite.onload = function() {
  9605. this.isLoaded = true;
  9606. };
  9607. tmpSprite.src = crossHairs[i];
  9608. crossHairSprites[i] = tmpSprite;
  9609. }
  9610. }
  9611. loadIcons();
  9612.  
  9613. function cdf (e, t){
  9614. try {
  9615. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9616. } catch(e){
  9617. return Infinity;
  9618. }
  9619. }
  9620.  
  9621. // UPDATE GAME:
  9622. function updateGame() {
  9623. if(gameObjects.length && inGame) {
  9624. gameObjects.forEach((tmp) => {
  9625. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  9626. if(!liztobj.includes(tmp)) {
  9627. liztobj.push(tmp);
  9628. tmp.render = true;
  9629. }
  9630. } else {
  9631. if(liztobj.includes(tmp)) {
  9632. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9633. tmp.render = false;
  9634. const index = liztobj.indexOf(tmp);
  9635. if (index > -1) { // only splice array when item is found
  9636. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9637. }
  9638. }
  9639. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9640. tmp.render = false;
  9641. const index = liztobj.indexOf(tmp);
  9642. if (index > -1) { // only splice array when item is found
  9643. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9644. }
  9645. } else {
  9646. tmp.render = false;
  9647. const index = liztobj.indexOf(tmp);
  9648. if (index > -1) { // only splice array when item is found
  9649. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9650. }
  9651. }
  9652. }
  9653. })
  9654. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  9655. }
  9656.  
  9657. // if (config.resetRender) {
  9658. mainContext.beginPath();
  9659. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  9660. // }
  9661. mainContext.globalAlpha = 1;
  9662.  
  9663. // MOVE CAMERA:
  9664. if (player) {
  9665. if (false) {
  9666. camX = player.x;
  9667. camY = player.y;
  9668. } else {
  9669. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  9670. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  9671. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  9672. if (tmpDist > 0.05) {
  9673. camX += camSpd * Math.cos(tmpDir);
  9674. camY += camSpd * Math.sin(tmpDir);
  9675. } else {
  9676. camX = player.x;
  9677. camY = player.y;
  9678. }
  9679. }
  9680. } else {
  9681. camX = config.mapScale / 2 + config.riverWidth;
  9682. camY = config.mapScale / 2;
  9683. }
  9684. // PATHFINDER LINE
  9685. if (pathFind.active) {
  9686. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  9687. mainContext.lineWidth = player.scale / 5;
  9688. mainContext.globalAlpha = 1;
  9689. mainContext.strokeStyle = "red";
  9690. mainContext.beginPath();
  9691. pathFind.array.forEach((path, i) => {
  9692. let pathXY = {
  9693. x: (pathFind.scale / pathFind.grid) * path.x,
  9694. y: (pathFind.scale / pathFind.grid) * path.y
  9695. }
  9696. let render = {
  9697. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  9698. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  9699. }
  9700. if (i == 0) {
  9701. mainContext.moveTo(render.x, render.y);
  9702. } else {
  9703. mainContext.lineTo(render.x, render.y);
  9704. }
  9705. });
  9706. mainContext.stroke();
  9707. }
  9708. }
  9709. // INTERPOLATE PLAYERS AND AI:
  9710. let lastTime = now - (1000 / config.serverUpdateRate);
  9711. let tmpDiff;
  9712. for (let i = 0; i < players.length + ais.length; ++i) {
  9713. tmpObj = players[i] || ais[i - players.length];
  9714. if (tmpObj && tmpObj.visible) {
  9715. if (tmpObj.forcePos) {
  9716. tmpObj.x = tmpObj.x2;
  9717. tmpObj.y = tmpObj.y2;
  9718. tmpObj.dir = tmpObj.d2;
  9719. } else {
  9720. let total = tmpObj.t2 - tmpObj.t1;
  9721. let fraction = lastTime - tmpObj.t1;
  9722. let ratio = (fraction / total);
  9723. let rate = 170;
  9724. tmpObj.dt += delta;
  9725. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  9726. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  9727. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  9728. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  9729. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  9730. if (config.anotherVisual) {
  9731. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9732. } else {
  9733. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9734. }
  9735. }
  9736. }
  9737. }
  9738.  
  9739. // RENDER CORDS:
  9740. let xOffset = camX - (maxScreenWidth / 2);
  9741. let yOffset = camY - (maxScreenHeight / 2);
  9742.  
  9743. // RENDER BACKGROUND:
  9744. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9745. mainContext.fillStyle = "#b6db66";
  9746. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9747. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  9748. mainContext.fillStyle = "#dbc666";
  9749. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9750. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9751. mainContext.fillStyle = "#fff";
  9752. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9753. } else if (config.snowBiomeTop - yOffset >= 0) {
  9754. mainContext.fillStyle = "#fff";
  9755. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  9756. mainContext.fillStyle = "#b6db66";
  9757. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  9758. maxScreenHeight - (config.snowBiomeTop - yOffset));
  9759. } else {
  9760. mainContext.fillStyle = "#b6db66";
  9761. mainContext.fillRect(0, 0, maxScreenWidth,
  9762. (config.mapScale - config.snowBiomeTop - yOffset));
  9763. mainContext.fillStyle = "#dbc666";
  9764. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  9765. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  9766. }
  9767.  
  9768. // RENDER WATER AREAS:
  9769. if (!firstSetup) {
  9770. waterMult += waterPlus * config.waveSpeed * delta;
  9771. if (waterMult >= config.waveMax) {
  9772. waterMult = config.waveMax;
  9773. waterPlus = -1;
  9774. } else if (waterMult <= 1) {
  9775. waterMult = waterPlus = 1;
  9776. }
  9777. mainContext.globalAlpha = 1;
  9778. mainContext.fillStyle = "#dbc666";
  9779. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  9780. mainContext.fillStyle = "#91b2db";
  9781. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  9782. }
  9783.  
  9784. // RENDER DEAD PLAYERS:
  9785. mainContext.globalAlpha = 1;
  9786. mainContext.strokeStyle = outlineColor;
  9787. renderDeadPlayers(xOffset, yOffset);
  9788.  
  9789. // RENDER BOTTOM LAYER:
  9790. mainContext.globalAlpha = 1;
  9791. mainContext.strokeStyle = outlineColor;
  9792. renderGameObjects(-1, xOffset, yOffset);
  9793.  
  9794. // RENDER PROJECTILES:
  9795. mainContext.globalAlpha = 1;
  9796. mainContext.lineWidth = outlineWidth;
  9797. renderProjectiles(0, xOffset, yOffset);
  9798.  
  9799. // RENDER PLAYERS:
  9800. renderPlayers(xOffset, yOffset, 0);
  9801.  
  9802. // RENDER AI:
  9803. mainContext.globalAlpha = 1;
  9804. for (let i = 0; i < ais.length; ++i) {
  9805. tmpObj = ais[i];
  9806. if (tmpObj.active && tmpObj.visible) {
  9807. tmpObj.animate(delta);
  9808. mainContext.save();
  9809. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9810. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  9811. renderAI(tmpObj, mainContext);
  9812. mainContext.restore();
  9813. }
  9814. }
  9815.  
  9816. // RENDER GAME OBJECTS (LAYERED):
  9817. renderGameObjects(0, xOffset, yOffset);
  9818. renderProjectiles(1, xOffset, yOffset);
  9819. renderGameObjects(1, xOffset, yOffset);
  9820. renderPlayers(xOffset, yOffset, 1);
  9821. renderGameObjects(2, xOffset, yOffset);
  9822. renderGameObjects(3, xOffset, yOffset);
  9823.  
  9824. // MAP BOUNDARIES:
  9825. mainContext.fillStyle = "#000";
  9826. mainContext.globalAlpha = 0.09;
  9827. if (xOffset <= 0) {
  9828. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  9829. }
  9830. if (config.mapScale - xOffset <= maxScreenWidth) {
  9831. let tmpY = Math.max(0, -yOffset);
  9832. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  9833. }
  9834. if (yOffset <= 0) {
  9835. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  9836. }
  9837. if (config.mapScale - yOffset <= maxScreenHeight) {
  9838. let tmpX = Math.max(0, -xOffset);
  9839. let tmpMin = 0;
  9840. if (config.mapScale - xOffset <= maxScreenWidth)
  9841. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  9842. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  9843. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  9844. }
  9845.  
  9846. // RENDER DAY/NIGHT TIME:
  9847. mainContext.globalAlpha = 1;
  9848. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  9849. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9850.  
  9851. // RENDER PLAYER AND AI UI:
  9852. mainContext.strokeStyle = darkOutlineColor;
  9853. mainContext.globalAlpha = 1;
  9854.  
  9855. for (let i = 0; i < players.length + ais.length; ++i) {
  9856. tmpObj = players[i] || ais[i - players.length];
  9857. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  9858. mainContext.strokeStyle = darkOutlineColor;
  9859.  
  9860. // NAME AND HEALTH:
  9861.  
  9862. // let izbot = false;
  9863.  
  9864. // bots.forEach((bot) => {
  9865. // if (tmpObj.sid == bot.sid) izbot = true
  9866. // else izbot = false;
  9867. // });
  9868.  
  9869. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  9870. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  9871. // bots.forEach((bot) => {
  9872. // if (tmpObj.sid == bot.sid) return;
  9873. // });
  9874.  
  9875. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  9876. mainContext.fillStyle = "#fff";
  9877. mainContext.textBaseline = "middle";
  9878. mainContext.textAlign = "center";
  9879. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  9880. mainContext.lineJoin = "round";
  9881. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9882. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9883. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  9884. let tmpS = config.crownIconScale;
  9885. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  9886. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9887. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9888. }
  9889. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  9890. let tmpS = config.crownIconScale;
  9891. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  9892. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9893. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9894. }
  9895. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  9896. let tmpS = tmpObj.scale * 2.2;
  9897. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  9898. }
  9899. // izbot = false;
  9900. }
  9901. if (tmpObj.health > 0) {
  9902.  
  9903. if(tmpObj.name != "Trash Slave") {
  9904. // HEALTH HOLDER:
  9905. mainContext.fillStyle = darkOutlineColor;
  9906. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  9907. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  9908. (config.healthBarPad * 2), 17, 8);
  9909. mainContext.fill();
  9910.  
  9911. // HEALTH BAR:
  9912. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  9913. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  9914. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  9915. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  9916. mainContext.fill();
  9917. }
  9918.  
  9919. if (tmpObj.isPlayer) {
  9920. mainContext.globalAlpha = 1;
  9921. let targetReloads = {
  9922. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  9923. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  9924. turret: (2500 - tmpObj.reloads[53]) / 2500
  9925. };
  9926. if (!tmpObj.currentReloads) {
  9927. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  9928. primary: targetReloads.primary,
  9929. secondary: targetReloads.secondary,
  9930. turret: targetReloads.turret
  9931. };
  9932. }
  9933. const lerpFactor = 0.3;
  9934. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  9935. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  9936. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  9937.  
  9938. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  9939. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  9940. const centerX = tmpObj.x - xOffset;
  9941. const centerY = tmpObj.y - yOffset;
  9942. const barRadius = 35;
  9943. const barWidth = 15;
  9944. const totalAngle = (Math.PI*2)/3; // Half circle
  9945. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  9946. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  9947. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  9948. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  9949.  
  9950. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  9951. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  9952. function returncoolcolor(RainbowCycle) {
  9953. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  9954. }
  9955.  
  9956. mainContext.save();
  9957. if (tmpObj.currentReloads.primary < 0.999) {
  9958. mainContext.beginPath();
  9959. mainContext.lineCap = 'round';
  9960. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  9961. mainContext.lineWidth = 4;
  9962. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  9963. mainContext.stroke();
  9964. }
  9965. if (tmpObj.currentReloads.secondary < 0.999) {
  9966. mainContext.beginPath();
  9967. mainContext.lineCap = 'round';
  9968. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  9969. mainContext.lineWidth = 4;
  9970. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  9971. mainContext.stroke();
  9972. }
  9973. if (tmpObj.currentReloads.turret < 0.999) {
  9974. mainContext.beginPath();
  9975. mainContext.lineCap = 'round';
  9976. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  9977. mainContext.lineWidth = 4;
  9978. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  9979. mainContext.stroke();
  9980. }
  9981. mainContext.restore();
  9982.  
  9983. if(tmpObj.name != "Trash Slave") {
  9984. // SHAME COUNT:
  9985. mainContext.globalAlpha = 1;
  9986. mainContext.font = "24px HammerSmith One";
  9987. mainContext.fillStyle = "#fff";
  9988. mainContext.strokeStyle = darkOutlineColor;
  9989. mainContext.textBaseline = "middle";
  9990. mainContext.textAlign = "center";
  9991. mainContext.lineWidth = 8;
  9992. mainContext.lineJoin = "round";
  9993. let tmpS = config.crownIconScale;
  9994. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  9995. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  9996. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  9997. }
  9998.  
  9999. // PLAYER TRACER:
  10000. if (!tmpObj.isTeam(player)) {
  10001. let center = {
  10002. x: screenWidth / 2,
  10003. y: screenHeight / 2,
  10004. };
  10005. 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);
  10006. let dist = center.y * alpha / 2;
  10007. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10008. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10009. mainContext.save();
  10010. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10011. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10012. let by = 255 - (tmpObj.sid * 2);
  10013. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10014. mainContext.globalAlpha = alpha;
  10015. let renderTracer = function(s, ctx) {
  10016. ctx = ctx || mainContext;
  10017. let h = s * (Math.sqrt(3) / 2);
  10018. ctx.beginPath();
  10019. ctx.moveTo(0, -h / 1.5);
  10020. ctx.lineTo(-s / 2, h / 2);
  10021. ctx.lineTo(s / 2, h / 2);
  10022. ctx.lineTo(0, -h / 1.5);
  10023. ctx.fill();
  10024. ctx.closePath();
  10025. }
  10026. renderTracer(25, mainContext);
  10027. mainContext.restore();
  10028. }
  10029.  
  10030. if (getEl("predictType").value == "pre2") {
  10031. mainContext.lineWidth = 3;
  10032. mainContext.strokeStyle = "#fff";
  10033. mainContext.globalAlpha = 1;
  10034. mainContext.beginPath();
  10035. let render = {
  10036. x: tmpObj.x2 - xOffset,
  10037. y: tmpObj.y2 - yOffset
  10038. };
  10039. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10040. mainContext.lineTo(render.x, render.y);
  10041. mainContext.stroke();
  10042. } else if (getEl("predictType").value == "pre3") {
  10043. mainContext.lineWidth = 3;
  10044. mainContext.strokeStyle = "#cc5151";
  10045. mainContext.globalAlpha = 1;
  10046. mainContext.beginPath();
  10047. let render = {
  10048. x: tmpObj.x3 - xOffset,
  10049. y: tmpObj.y3 - yOffset
  10050. };
  10051. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10052. mainContext.lineTo(render.x, render.y);
  10053. mainContext.stroke();
  10054. }
  10055.  
  10056. }
  10057. }
  10058. }
  10059. }
  10060.  
  10061. if (player) {
  10062.  
  10063. // AUTOPUSH LINE:
  10064. if (my.autoPush && my.pushData) {
  10065. mainContext.lineWidth = 5;
  10066. mainContext.globalAlpha = 1;
  10067. mainContext.beginPath();
  10068. var x1 = player.x - xOffset;
  10069. var y1 = player.y - yOffset;
  10070. var x2 = my.pushData.x2 - xOffset;
  10071. var y2 = my.pushData.y2 - yOffset;
  10072. var x3 = my.pushData.x - xOffset;
  10073. var y3 = my.pushData.y - yOffset;
  10074.  
  10075. mainContext.moveTo(x1, y1);
  10076. mainContext.lineTo(x2, y2);
  10077. mainContext.lineTo(x3, y3);
  10078. mainContext.stroke();
  10079.  
  10080. var deltaX = x3 - x1;
  10081. var deltaY = y3 - y1;
  10082. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  10083.  
  10084. var maxDistance = 100;
  10085. var percentage = (distance / maxDistance) * 100;
  10086.  
  10087. percentage = Math.min(100, Math.max(0, percentage));
  10088. let spike;
  10089. mainContext.fillStyle = "white";
  10090. mainContext.strokeStyle = "black";
  10091. mainContext.lineWidth = 5;
  10092. mainContext.font = "27px Times New Roman";
  10093. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  10094. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10095. })[0];
  10096. if(nearTrap)
  10097. spike = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  10098. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10099. })[0];
  10100.  
  10101. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  10102. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  10103.  
  10104. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10105. mainContext.strokeText(near.aim2, xx, yy);
  10106. mainContext.fillText(near.aim2, xx, yy);
  10107. }
  10108. }
  10109.  
  10110. mainContext.globalAlpha = 1;
  10111.  
  10112. // RENDER ANIM TEXTS:
  10113. textManager.update(delta, mainContext, xOffset, yOffset);
  10114.  
  10115. // RENDER CHAT MESSAGES:
  10116. for (let i = 0; i < players.length; ++i) {
  10117. tmpObj = players[i];
  10118. if (tmpObj.visible) {
  10119. if (tmpObj.chatCountdown > 0) {
  10120. tmpObj.chatCountdown -= delta;
  10121. if (tmpObj.chatCountdown <= 0)
  10122. tmpObj.chatCountdown = 0;
  10123. mainContext.font = "32px HammerSmith One";
  10124. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10125. mainContext.textBaseline = "middle";
  10126. mainContext.textAlign = "center";
  10127. let tmpX = tmpObj.x - xOffset;
  10128. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10129. let tmpH = 47;
  10130. let tmpW = tmpSize.width + 17;
  10131. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10132. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10133. mainContext.fill();
  10134. mainContext.fillStyle = "#fff";
  10135. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10136. }
  10137. if (tmpObj.chat.count > 0) {
  10138. if (!useWasd) {
  10139. tmpObj.chat.count -= delta;
  10140. if (tmpObj.chat.count <= 0)
  10141. tmpObj.chat.count = 0;
  10142. mainContext.font = "32px HammerSmith One";
  10143. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10144. mainContext.textBaseline = "middle";
  10145. mainContext.textAlign = "center";
  10146. let tmpX = tmpObj.x - xOffset;
  10147. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10148. let tmpH = 47;
  10149. let tmpW = tmpSize.width + 17;
  10150. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10151. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10152. mainContext.fill();
  10153. mainContext.fillStyle = "#ffffff99";
  10154. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10155. } else {
  10156. tmpObj.chat.count = 0;
  10157. }
  10158. }
  10159. }
  10160. }
  10161.  
  10162. if (allChats.length) {
  10163. allChats.filter(ch => ch.active).forEach((ch) => {
  10164. if (!ch.alive) {
  10165. if (ch.alpha <= 1) {
  10166. ch.alpha += delta / 250;
  10167. if (ch.alpha >= 1) {
  10168. ch.alpha = 1;
  10169. ch.alive = true;
  10170. }
  10171. }
  10172. } else {
  10173. ch.alpha -= delta / 5000;
  10174. if (ch.alpha <= 0) {
  10175. ch.alpha = 0;
  10176. ch.active = false;
  10177. }
  10178. }
  10179. if (ch.active) {
  10180. mainContext.font = "20px Ubuntu";
  10181. let tmpSize = mainContext.measureText(ch.chat);
  10182. mainContext.textBaseline = "middle";
  10183. mainContext.textAlign = "center";
  10184. let tmpX = ch.x - xOffset;
  10185. let tmpY = ch.y - yOffset - 90;
  10186. let tmpH = 40;
  10187. let tmpW = tmpSize.width + 15;
  10188.  
  10189. mainContext.globalAlpha = ch.alpha;
  10190.  
  10191. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10192. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10193. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10194. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  10195.  
  10196. mainContext.lineWidth = 5;
  10197. mainContext.fillStyle = "#ccc";
  10198. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10199.  
  10200. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10201. mainContext.stroke();
  10202. mainContext.fill();
  10203.  
  10204. mainContext.fillStyle = "#fff";
  10205. mainContext.strokeStyle = "#000";
  10206. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10207. mainContext.fillText(ch.chat, tmpX, tmpY);
  10208. ch.y -= delta / 100;
  10209. }
  10210. });
  10211. }
  10212.  
  10213. mainContext.globalAlpha = 1;
  10214.  
  10215. // RENDER MINIMAP:
  10216. renderMinimap(delta);
  10217. }
  10218.  
  10219. // UPDATE & ANIMATE:
  10220. window.requestAnimFrame = function() {
  10221. return null;
  10222. }
  10223. window.rAF = (function() {
  10224. return window.requestAnimationFrame ||
  10225. window.webkitRequestAnimationFrame ||
  10226. window.mozRequestAnimationFrame ||
  10227. function(callback) {
  10228. window.setTimeout(callback, 1000/9);
  10229. };
  10230. })();
  10231.  
  10232. function doUpdate() {
  10233. //rape modulus
  10234. now = performance.now();
  10235. delta = now - lastUpdate;
  10236. lastUpdate = now;
  10237. let timer = performance.now();
  10238. let diff = timer - fpsTimer.last;
  10239. if (diff >= 1000) {
  10240.  
  10241. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10242.  
  10243. fpsTimer.last = timer;
  10244. fpsTimer.time = 0;
  10245. }
  10246. fpsTimer.time++;
  10247.  
  10248. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  10249. getEl("packetStatus").innerHTML = secPacket;
  10250. updateGame();
  10251. rAF(doUpdate);
  10252. ms.avg = Math.round((ms.min+ms.max)/2);
  10253. }
  10254.  
  10255. prepareMenuBackground();
  10256. doUpdate();
  10257.  
  10258. function toggleUseless(boolean) {
  10259. getEl("instaType").disabled = boolean;
  10260. getEl("antiBullType").disabled = boolean;
  10261. getEl("predictType").disabled = boolean;
  10262. }
  10263. toggleUseless(useWasd);
  10264.  
  10265. let changeDays = {};
  10266. window.debug = function() {
  10267. my.waitHit = 0;
  10268. my.autoAim = false;
  10269. instaC.isTrue = false;
  10270. traps.inTrap = false;
  10271. itemSprites = [];
  10272. objSprites = [];
  10273. gameObjectSprites = [];
  10274. };
  10275. window.wasdMode = function() {
  10276. useWasd = !useWasd;
  10277. toggleUseless(useWasd);
  10278. };
  10279. window.startGrind = function() {
  10280. if (getEl("weaponGrind").checked) {
  10281. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10282. checkPlace(player.getItemType(22), i);
  10283. }
  10284. }
  10285. };
  10286. // REMOVED!!! so they cant abuse :)
  10287. let projects = [
  10288. "adorable-eight-guppy",
  10289. "galvanized-bittersweet-windshield"
  10290. ];
  10291. let botIDS = 0;
  10292. window.connectFillBots = function() {
  10293. botSkts = [];
  10294. botIDS = 0;
  10295. for (let i = 0; i < projects.length; i++) {
  10296. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10297. test.binaryType = "arraybuffer";
  10298.  
  10299. test.onopen = function() {
  10300. test.ssend = function(type) {
  10301. let data = Array.prototype.slice.call(arguments, 1);
  10302. let binary = window.msgpack.encode([type, data]);
  10303. test.send(binary);
  10304. };
  10305. for (let i = 0; i < 4; i++) {
  10306. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10307. action: "homepage"
  10308. }).then(function(token) {
  10309. let t = WS.url.split("wss://")[1].split("?")[0];
  10310. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10311. botSkts.push([test]);
  10312. botIDS++;
  10313. });
  10314. }
  10315. };
  10316. test.onmessage = function(message) {
  10317. let data = new Uint8Array(message.data);
  10318. let parsed = window.msgpack.decode(data);
  10319. let type = parsed[0];
  10320. data = parsed[1];
  10321. };
  10322. }
  10323. };
  10324. window.destroyFillBots = function() {
  10325. botSkts.forEach((socket) => {
  10326. socket[0].close();
  10327. });
  10328. botSkts = [];
  10329. };
  10330. window.tryConnectBots = function() {
  10331. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10332. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10333. action: "homepage"
  10334. }).then(function(token) {
  10335. // CONNECT SOCKET:
  10336. botSpawn(token);
  10337. });
  10338. }
  10339. };
  10340. window.destroyBots = function() {
  10341. bots.forEach((botyyyyy) => {
  10342. botyyyyy.closeSocket = true;
  10343. });
  10344. bots = [];
  10345. };
  10346. window.resBuild = function() {
  10347. if (gameObjects.length) {
  10348. gameObjects.forEach((tmp) => {
  10349. tmp.breakObj = false;
  10350. });
  10351. breakObjects = [];
  10352. }
  10353. };
  10354. window.toggleBotsCircle = function() {
  10355. player.circle = !player.circle;
  10356. };
  10357. window.toggleVisual = function() {
  10358. config.anotherVisual = !config.anotherVisual;
  10359. gameObjects.forEach((tmp) => {
  10360. if (tmp.active) {
  10361. tmp.dir = tmp.lastDir;
  10362. }
  10363. });
  10364. };
  10365. window.prepareUI = function(tmpObj) {
  10366. resize();
  10367. // CHAT STUFF:
  10368. var chatBox = document.getElementById("chatBox");
  10369. var chatHolder = document.getElementById("chatHolder");
  10370. var suggestBox = document.createElement("div");
  10371. suggestBox.id = "suggestBox";
  10372.  
  10373. var prevChats = [];
  10374. var prevChatsIndex = 0;
  10375.  
  10376. function toggleChat() {
  10377. if (!usingTouch) {
  10378. if (chatHolder.style.display == "block") {
  10379. if (chatBox.value) {
  10380. sendChat(chatBox.value);
  10381. }
  10382. closeChat();
  10383. } else {
  10384. storeMenu.style.display = "none";
  10385. allianceMenu.style.display = "none";
  10386. chatHolder.style.display = "block";
  10387. chatBox.focus();
  10388. resetMoveDir();
  10389. }
  10390. } else {
  10391. setTimeout(function () {
  10392. var chatMessage = prompt("chat message");
  10393. if (chatMessage) {
  10394. sendChat(chatMessage);
  10395. }
  10396. }, 1);
  10397. }
  10398. chatBox.value = "";
  10399. (() => {
  10400. prevChatsIndex = 0;
  10401. })();
  10402. }
  10403.  
  10404. function closeChat() {
  10405. chatBox.value = "";
  10406. chatHolder.style.display = "none";
  10407. }
  10408.  
  10409. // ACTION BAR:
  10410. UTILS.removeAllChildren(actionBar);
  10411.  
  10412. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10413. (function (i) {
  10414. UTILS.generateElement({
  10415. id: "actionBarItem" + i,
  10416. class: "actionBarItem",
  10417. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10418. onmouseout: function () {
  10419. showItemInfo();
  10420. },
  10421. parent: actionBar
  10422. });
  10423. })(i);
  10424. }
  10425.  
  10426. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10427. (function (i) {
  10428. let tmpCanvas = document.createElement("canvas");
  10429. tmpCanvas.width = tmpCanvas.height = 66;
  10430. let tmpContext = tmpCanvas.getContext("2d");
  10431. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10432. tmpContext.imageSmoothingEnabled = false;
  10433. tmpContext.webkitImageSmoothingEnabled = false;
  10434. tmpContext.mozImageSmoothingEnabled = false;
  10435.  
  10436. if (items.weapons[i]) {
  10437. tmpContext.rotate((Math.PI));
  10438. let tmpSprite = new Image();
  10439. toolSprites[items.weapons[i].src] = tmpSprite;
  10440. tmpSprite.onload = function () {
  10441. this.isLoaded = true;
  10442. let tmpPad = 1 / (this.height / this.width);
  10443. let tmpMlt = (items.weapons[i].iPad || 1);
  10444. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10445. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10446. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10447. tmpContext.globalCompositeOperation = "source-atop";
  10448. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10449. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10450. };
  10451. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10452. let tmpUnit = getEl('actionBarItem' + i);
  10453. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10454. // showItemInfo(items.weapons[i], true);
  10455. // });
  10456. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10457. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10458. });
  10459. UTILS.hookTouchEvents(tmpUnit);
  10460. } else {
  10461. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10462. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10463. tmpContext.globalAlpha = 1;
  10464. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10465. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10466. tmpContext.globalCompositeOperation = "source-atop";
  10467. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10468. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10469. let tmpUnit = getEl('actionBarItem' + i);
  10470. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10471. // showItemInfo(items.list[i - items.weapons.length]);
  10472. // });
  10473. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10474. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10475. });
  10476. UTILS.hookTouchEvents(tmpUnit);
  10477. }
  10478. })(i);
  10479. }
  10480. };
  10481. window.profineTest = function(data) {
  10482. if (data) {
  10483. // VALIDATE NAME:
  10484. let name = data + "";
  10485. name = name.slice(0, config.maxNameLength);
  10486.  
  10487. return name;
  10488. }
  10489. }
  10490. }(1)

QingJ © 2025

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