Super md v1

v2 is coming out!!!!! :(:)::):)):):):::)):::):)):::)::::)::)

  1. // ==UserScript==
  2. // @name Super md v1
  3. // @version v1.1
  4. // @author yurio, wat
  5. // @description v2 is coming out!!!!! :(:)::):)):):):::)):::):)):::)::::)::)
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @icon https://c1.wallpaperflare.com/preview/747/358/397/你的母亲-hart-night-view-thumbnail.jpg
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://greasyfork.org/users/1258400
  12. // ==/UserScript==
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. // Test Auto Reply
  25. let founda = false;
  26. let scriptTags = document.getElementsByTagName("script");
  27. for (let i = 0; i < scriptTags.length; i++) {
  28. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  29. scriptTags[i].remove();
  30. founda = true;
  31. break;
  32. }
  33. }
  34.  
  35. var styleItem = document.createElement("style");
  36. styleItem.type = "text/css";
  37. styleItem.appendChild(document.createTextNode(`
  38. #suggestBox {
  39. width: 355px;
  40. border-radius: 3px;
  41. background-color: rgba( 87, 235, 255);
  42. margin: auto;
  43. text-align: left;
  44. z-index: 49;
  45. pointer-events: auto;
  46. position: relative;
  47. bottom: 3.5px;
  48. overflow-y: auto;
  49. }
  50. #suggestBox div {
  51. background-color: rgba( 87, 235, 255);
  52. color: rgba( 255, 255, 87);
  53. transition: background-color 0.3s, color 0.3s;
  54. }
  55. #suggestBox div:hover {
  56. background-color: rgba( 247, 236, 14);
  57. color: rgba( 14, 247, 60);
  58. }
  59. .suggestBoxHard {
  60. color: rgba( 247, 14, 173);
  61. font-size: 18px;
  62. }
  63. .suggestBoxLight {
  64. color: rgba(255,255,255,0.7);
  65. font-size: 18px;
  66. }
  67. `));
  68. document.head.appendChild(styleItem);
  69.  
  70. window.addEventListener('load', function() {
  71. var allianceButton = document.getElementById('allianceButton');
  72. var storeButton = document.getElementById('storeButton');
  73. if (storeButton) {
  74. storeButton.style.right = '26px';
  75. storeButton.style.top = '420px';
  76. }
  77. if (allianceButton) {
  78. allianceButton.style.right = '26px';
  79. allianceButton.style.top = '479px';
  80. }
  81. });
  82.  
  83. function getEl(id) {
  84. return document.getElementById(id);
  85. }
  86.  
  87. !function(run) {
  88.  
  89. let newFont = document.createElement("link");
  90. newFont.rel = "stylesheet";
  91. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  92. newFont.type = "text/css";
  93. document.body.append(newFont);
  94.  
  95. let min = document.createElement("script");
  96. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  97. document.body.append(min);
  98. window.oncontextmenu = function() {
  99. return false;
  100. };
  101.  
  102. let config = window.config;
  103.  
  104. // CLIENT:
  105. config.clientSendRate = 9; // Aim Packet Send Rate
  106. config.serverUpdateRate = 9;
  107.  
  108. // UI:
  109. config.deathFadeout = 0;
  110.  
  111. config.playerCapacity = 9999;
  112.  
  113. // CHECK IN SANDBOX:
  114. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  115.  
  116. // CUSTOMIZATION:
  117.  
  118. config.weaponVariants = [{
  119. id: 0,
  120. src: "",
  121. xp: 0,
  122. val: 1,
  123. }, {
  124. id: 1,
  125. src: "_g",
  126. xp: 3000,
  127. val: 1.1,
  128. }, {
  129. id: 2,
  130. src: "_d",
  131. xp: 7000,
  132. val: 1.18,
  133. }, {
  134. id: 3,
  135. src: "_r",
  136. poison: true,
  137. xp: 12000,
  138. val: 1.18,
  139. }, {
  140. id: 4,
  141. src: "_e",
  142. poison: true,
  143. heal: true,
  144. xp: 24000,
  145. val: 1.18,
  146. }];
  147.  
  148. // VISUAL:
  149. config.anotherVisual = true;
  150. config.useWebGl = true;
  151. config.resetRender = true;
  152.  
  153. function waitTime(timeout) {
  154. return new Promise((done) => {
  155. setTimeout(() => {
  156. done();
  157. }, timeout);
  158. });
  159. }
  160.  
  161. let botSkts = [];
  162.  
  163. // STORAGE:
  164. let canStore;
  165. if (typeof(Storage) !== "undefined") {
  166. canStore = true;
  167. }
  168.  
  169. function saveVal(name, val) {
  170. if (canStore)
  171. localStorage.setItem(name, val);
  172. }
  173.  
  174. function deleteVal(name) {
  175. if (canStore)
  176. localStorage.removeItem(name);
  177. }
  178.  
  179. function getSavedVal(name) {
  180. if (canStore)
  181. return localStorage.getItem(name);
  182. return null;
  183. }
  184.  
  185. // CONFIGS:
  186. let gC = function(a, b) {
  187. try {
  188. let res = JSON.parse(getSavedVal(a));
  189. if (typeof res === "object") {
  190. return b;
  191. } else {
  192. return res;
  193. }
  194. } catch (e) {
  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", " #f70ead", 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] )", " #f70ead", 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. killChat: true,
  246. alwaysRev: true,
  247. autoBuy: true,
  248. autoBuyEquip: true,
  249. autoPush: false,
  250. revTick: true,
  251. spikeTick: true,
  252. predictTick: true,
  253. autoPlace: false,
  254. autoReplace: true,
  255. autoPrePlace: true,
  256. antiTrap: true,
  257. slowOT: false,
  258. attackDir: false,
  259. showDir: false,
  260. noDir: false,
  261. autoRespawn: true
  262. };
  263. };
  264. let commands = setCommands();
  265. let configs = setConfigs();
  266. window.removeConfigs = function() {
  267. for (let cF in configs) {
  268. deleteVal(cF, configs[cF]);
  269. }
  270. };
  271.  
  272. for (let cF in configs) {
  273. configs[cF] = gC(cF, configs[cF]);
  274. }
  275.  
  276. // MENU FUNCTIONS:
  277. window.changeMenu = function() {};
  278. window.debug = function() {};
  279. window.wasdMode = function() {};
  280.  
  281. // PAGE 1:
  282. window.startGrind = function() {};
  283.  
  284. // PAGE 3:
  285. window.connectFillBots = function() {};
  286. window.destroyFillBots = function() {};
  287. window.tryConnectBots = function() {};
  288. window.destroyBots = function() {};
  289. window.resBuild = function() {};
  290. window.toggleBotsCircle = function() {};
  291. window.toggleVisual = function() {};
  292.  
  293. // SOME FUNCTIONS:
  294. window.prepareUI = function() {};
  295. window.leave = function() {};
  296.  
  297. // nah hahahahahhh why good ping
  298. window.ping = 0;
  299.  
  300. class deadfuturechickenmodrevival {
  301. constructor(flarez, lore) {
  302. this.inGame = false;
  303. this.lover = flarez + lore;
  304. this.baby = "ae86";
  305. this.isBlack = 0;
  306. this.webSocket = undefined;
  307. this.checkBaby = function() {
  308. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  309. if (this.isBlack >= 1) return "bl4cky";
  310. return "noting for you";
  311. };
  312. this.x2 = 0;
  313. this.y2 = 0;
  314. this.chat = "Imagine playing this badass game XDDDDD";
  315. this.summon = function(tmpObj) {
  316. this.x2 = tmpObj.x;
  317. this.y2 = tmpObj.y;
  318. this.chat = tmpObj.name + " ur so bad XDDDD";
  319. };
  320. this.commands = function(cmd) {
  321. cmd == "rv3link" && window.open("https://florr.io/");
  322. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  323. return cmd;
  324. };
  325. this.dayte = "11yearold";
  326. this.memeganoob = "69yearold";
  327. this.startDayteSpawn = function(tmpObj) {
  328. let ratio = setInterval(() => {
  329. this.x2 = tmpObj.x + 20;
  330. this.y2 = tmpObj.y - 20;
  331. this.chat = "UR SO BAD LOL";
  332. if (tmpObj.name == "ae86") {
  333. this.chat = "omg ae86 go run";
  334. setTimeout(() => {
  335. this.inGame = false;
  336. clearInterval(ratio);
  337. }, 1000);
  338. }
  339. }, 1234);
  340. };
  341. this.AntiChickenModV69420 = function(tmpObj) {
  342. return "!c!dc user " + tmpObj.name;
  343. };
  344. }
  345. };
  346. class HtmlAction {
  347. constructor(element) {
  348. this.element = element;
  349. };
  350. add(code) {
  351. if (!this.element) return undefined;
  352. this.element.innerHTML += code;
  353. };
  354. newLine(amount) {
  355. let result = `<br>`;
  356. if (amount > 0) {
  357. result = ``;
  358. for (let i = 0; i < amount; i++) {
  359. result += `<br>`;
  360. }
  361. }
  362. this.add(result);
  363. };
  364. checkBox(setting) {
  365. let newCheck = `<input type = "checkbox"`;
  366. setting.id && (newCheck += ` id = ${setting.id}`);
  367. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  368. setting.class && (newCheck += ` class = ${setting.class}`);
  369. setting.checked && (newCheck += ` checked`);
  370. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  371. newCheck += `>`;
  372. this.add(newCheck);
  373. };
  374. text(setting) {
  375. let newText = `<input type = "text"`;
  376. setting.id && (newText += ` id = ${setting.id}`);
  377. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  378. setting.class && (newText += ` class = ${setting.class}`);
  379. setting.size && (newText += ` size = ${setting.size}`);
  380. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  381. setting.value && (newText += ` value = ${setting.value}`);
  382. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  383. newText += `>`;
  384. this.add(newText);
  385. };
  386. select(setting) {
  387. let newSelect = `<select`;
  388. setting.id && (newSelect += ` id = ${setting.id}`);
  389. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  390. setting.class && (newSelect += ` class = ${setting.class}`);
  391. newSelect += `>`;
  392. for (let options in setting.option) {
  393. newSelect += `<option value = ${setting.option[options].id}`
  394. setting.option[options].selected && (newSelect += ` selected`);
  395. newSelect += `>${options}</option>`;
  396. }
  397. newSelect += `</select>`;
  398. this.add(newSelect);
  399. };
  400. button(setting) {
  401. let newButton = `<button`;
  402. setting.id && (newButton += ` id = ${setting.id}`);
  403. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  404. setting.class && (newButton += ` class = ${setting.class}`);
  405. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  406. newButton += `>`;
  407. setting.innerHTML && (newButton += setting.innerHTML);
  408. newButton += `</button>`;
  409. this.add(newButton);
  410. };
  411. selectMenu(setting) {
  412. let newSelect = `<select`;
  413. if (!setting.id) {
  414. alert("please put id skid");
  415. return;
  416. }
  417. window[setting.id + "Func"] = function() {};
  418. setting.id && (newSelect += ` id = ${setting.id}`);
  419. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  420. setting.class && (newSelect += ` class = ${setting.class}`);
  421. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  422. newSelect += `>`;
  423. let last;
  424. let i = 0;
  425. for (let options in setting.menu) {
  426. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  427. setting.menu[options] && (newSelect += ` checked`);
  428. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? " #f70ead" : "#cc5151"};">${options}</option>`;
  429. i++;
  430. }
  431. newSelect += `</select>`;
  432.  
  433. this.add(newSelect);
  434.  
  435. i = 0;
  436. for (let options in setting.menu) {
  437. window[options + "Func"] = function() {
  438. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  439. saveVal(options, setting.menu[options]);
  440.  
  441. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  442. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  443.  
  444. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  445.  
  446. };
  447. this.checkBox({
  448. id: "check_" + options,
  449. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  450. class: "checkB",
  451. onclick: `window.${options + "Func"}()`,
  452. checked: setting.menu[options]
  453. });
  454. i++;
  455. }
  456.  
  457. last = "check_" + getEl(setting.id).value.split("_")[1];
  458. window[setting.id + "Func"] = function() {
  459. getEl(last).style.display = "none";
  460. last = "check_" + getEl(setting.id).value.split("_")[1];
  461. getEl(last).style.display = "inline-block";
  462.  
  463. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  464.  
  465. };
  466. };
  467. };
  468. class Html {
  469. constructor() {
  470. this.element = null;
  471. this.action = null;
  472. this.divElement = null;
  473. this.startDiv = function(setting, func) {
  474.  
  475. let newDiv = document.createElement("div");
  476. setting.id && (newDiv.id = setting.id);
  477. setting.style && (newDiv.style = setting.style);
  478. setting.class && (newDiv.className = setting.class);
  479. this.element.appendChild(newDiv);
  480. this.divElement = newDiv;
  481.  
  482. let addRes = new HtmlAction(newDiv);
  483. typeof func == "function" && func(addRes);
  484.  
  485. };
  486. this.addDiv = function(setting, func) {
  487.  
  488. let newDiv = document.createElement("div");
  489. setting.id && (newDiv.id = setting.id);
  490. setting.style && (newDiv.style = setting.style);
  491. setting.class && (newDiv.className = setting.class);
  492. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  493. this.divElement = newDiv;
  494.  
  495. let addRes = new HtmlAction(newDiv);
  496. typeof func == "function" && func(addRes);
  497.  
  498. };
  499. };
  500. set(id) {
  501. this.element = getEl(id);
  502. this.action = new HtmlAction(this.element);
  503. };
  504. resetHTML(text) {
  505. if (text) {
  506. this.element.innerHTML = ``;
  507. } else {
  508. this.element.innerHTML = ``;
  509. }
  510. };
  511. setStyle(style) {
  512. this.element.style = style;
  513. };
  514. setCSS(style) {
  515. this.action.add(`<style>` + style + `</style>`);
  516. };
  517. };
  518.  
  519. let HTML = new Html();
  520.  
  521. let menuDiv = document.createElement("div");
  522. menuDiv.id = "menuDiv";
  523. document.body.appendChild(menuDiv);
  524. HTML.set("menuDiv");
  525. HTML.setStyle(`
  526. position: absolute;
  527. left: 20px;
  528. top: 20px;
  529. `);
  530. HTML.resetHTML();
  531. HTML.setCSS(`
  532. .menuClass {
  533. color: #fff;
  534. background-image: url('https://urlz.fr/qBTC');
  535. background-size: cover;
  536. background-position: center;
  537. background-repeat: no-repeat;
  538. font-size: 28px;
  539. text-align: center;
  540. padding: 20px;
  541. max-height: 200px;
  542. width: 300px;
  543. background-color: #36454F;
  544. border-radius: 15px;
  545. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  546. transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out, box-shadow 0.3s ease-in-out, filter 0.4s ease-in-out, border-color 0.3s ease-in-out;
  547. overflow: auto;
  548. filter: none;
  549. border: 2px solid transparent; /* Add a border */
  550. }
  551. .menuClass:hover {
  552. border-color: #708090; /* Change border color on hover to RGB red */
  553. }
  554. .menuClass:hover .menuContent {
  555. background-color: #000; /* Change background color of menu content to darker black on hover */
  556. }
  557. .menuContent {
  558. color: #fff;
  559. }
  560. .menuC {
  561. display: none;
  562. font-family: "Hammersmith One", sans-serif;
  563. font-size: 14px;
  564. max-height: 200px;
  565. overflow-y: auto;
  566. }
  567. .menuB {
  568. text-align: center;
  569. background-color: #23394d;
  570. color: #fff;
  571. border-radius: 25px;
  572. border: 2px solid transparent;
  573. cursor: pointer;
  574. overflow-y: auto;
  575. transition: border-color 0.3s ease-in-out;
  576. }
  577. .menuB:hover {
  578. border-color: #fff;
  579. }
  580. .menuB:active {
  581. color: #fff;
  582. background-color: #adf70e;
  583. }
  584. .customText {
  585. color: #000;
  586. border-radius: 25px;
  587. border: 2px solid #000;
  588. padding: 12px;
  589. transition: background-color 0.3s ease-in-out;
  590. }
  591. .customText:focus {
  592. background-color: rgba( 247, 194, 14);
  593. }
  594. .checkB {
  595. position: relative;
  596. top: 2px;
  597. accent-color: #888;
  598. cursor: pointer;
  599. }
  600. .Cselect {
  601. border-radius: 25px;
  602. background-color: #1f1f1f;
  603. color: #fff;
  604. border: 1px solid #000;
  605. }
  606. #menuChanger {
  607. position: absolute;
  608. right: 20px;
  609. top: 20px;
  610. background-color: rgba(0, 0, 0, 0);
  611. color: #fff;
  612. border: none;
  613. cursor: pointer;
  614. transition: color 0.3s ease-in-out;
  615. }
  616. #menuChanger:hover {
  617. color: #000;
  618. }
  619.  
  620. ::-webkit-scrollbar {
  621. width: 0; /* Skryje vertikální scrollbar na WebKit prohlížečích */
  622. }
  623. `);
  624.  
  625. HTML.startDiv({
  626. id: "menuHeadLine",
  627. class: "menuClass"
  628. }, (html) => {
  629. html.add(`你的母亲 v4`);
  630. html.button({
  631. id: "menuChanger",
  632. class: "material-icons",
  633. innerHTML: `sync`,
  634. onclick: "window.changeMenu()"
  635. });
  636. HTML.addDiv({
  637. id: "menuButtons",
  638. style: "display: block; overflow-y: visible;",
  639. class: "menuC",
  640. appendID: "menuHeadLine"
  641. }, (html) => {
  642. html.button({
  643. class: "menuB",
  644. innerHTML: "Debug",
  645. onclick: "window.debug()"
  646. });
  647. });
  648. HTML.addDiv({
  649. id: "menuMain",
  650. style: "display: block",
  651. class: "menuC",
  652. appendID: "menuHeadLine"
  653. }, (html) => {
  654. html.button({
  655. class: "menuB",
  656. innerHTML: "Nothing",
  657. onclick: "window.wasdMode()"
  658. });
  659. html.newLine();
  660. html.add(`Grind`);
  661. html.checkBox({
  662. id: "weaponGrind",
  663. class: "checkB",
  664. onclick: "window.startGrind()"
  665. });
  666. html.newLine(2);
  667. HTML.addDiv({
  668. style: "font-size: 20px; color: #87C9E2;",
  669. appendID: "menuMain"
  670. }, (html) => {
  671. html.add(`Settings:`);
  672. });
  673. html.add(`AntiPush`);
  674. html.checkBox({
  675. id: "antipush",
  676. class: "checkB",
  677. checked: true
  678. });
  679. html.newLine();
  680. html.add(`Ae86 Heal`);
  681. html.checkBox({
  682. id: "healingBeta",
  683. class: "checkB",
  684. checked: true
  685. });
  686. html.newLine();
  687. html.add(`insta syncing`)
  688. html.checkBox({
  689. id: "gowogSync",
  690. class:"checkB",
  691. checked: "false"
  692. })
  693. html.newLine();
  694. });
  695. HTML.addDiv({
  696. id: "menuConfig",
  697. class: "menuC",
  698. appendID: "menuHeadLine"
  699. }, (html) => {
  700. html.add(`Placer `);
  701. html.text({
  702. id: "autoPlaceTick",
  703. class: "customText",
  704. value: "2",
  705. size: "2em",
  706. maxLength: "1"
  707. });
  708. html.newLine();
  709. html.add(`Options: `);
  710. html.selectMenu({
  711. id: "configsChanger",
  712. class: "Cselect",
  713. menu: configs
  714. });
  715. html.newLine();
  716. html.add(`Antigay(useless)`);
  717. html.select({
  718. id: "antiBullType",
  719. class: "Cselect",
  720. option: {
  721. "Disable": {
  722. id: "noab",
  723. selected: true,
  724. },
  725. "When Reloaded": {
  726. id: "abreload",
  727. },
  728. "Always": {
  729. id: "abalway",
  730. }
  731. }
  732. });
  733. });
  734. HTML.addDiv({
  735. id: "menuOther",
  736. class: "menuC",
  737. appendID: "menuHeadLine"
  738. }, (html) => {
  739. html.button({
  740. class: "menuB",
  741. innerHTML: "CBOT",
  742. onclick: "window.tryConnectBots()"
  743. });
  744. html.button({
  745. class: "menuB",
  746. innerHTML: "DBOT",
  747. onclick: "window.destroyBots()"
  748. });
  749. html.newLine();
  750. html.add(`DESTROYE object `);
  751. html.text({
  752. id: "breakRange",
  753. class: "customText",
  754. value: "700",
  755. size: "3em",
  756. maxLength: "4"
  757. });
  758. html.newLine();
  759. html.add(`Render MOOV`);
  760. html.select({
  761. id: "predictType",
  762. class: "Cselect",
  763. option: {
  764. "Disable Render": {
  765. id: "disableRender",
  766. selected: true
  767. },
  768. "X/Y and 2": {
  769. id: "pre2",
  770. },
  771. "X/Y and 3": {
  772. id: "pre3"
  773. }
  774. }
  775. });
  776. html.newLine();
  777. html.add(`Render PLACEMENT `);
  778. html.checkBox({
  779. id: "placeVis",
  780. class: "checkB",
  781. });
  782. html.newLine();
  783. html.add(`Bot Mode: `);
  784. html.select({
  785. id: "mode",
  786. class: "Cselect",
  787. option: {
  788. "Clear Building": {
  789. id: "clear",
  790. selected: true
  791. },
  792. "Sync": {
  793. id: "zync",
  794. },
  795. "Search": {
  796. id: "zearch"
  797. },
  798. "Clear Everything": {
  799. id: "fuckemup"
  800. },
  801. "Flex": {
  802. id: "flex"
  803. }
  804. }
  805. });
  806. html.newLine();
  807. html.add(`Not Working`);
  808. html.select({
  809. id: "setup",
  810. class: "Cselect",
  811. option: {
  812. "Dagger Musket": {
  813. id: "dm",
  814. selected: true
  815. },
  816. "Katana Hammer": {
  817. id: "kh",
  818. },
  819. "Dagger Repeater-Crossbow": {
  820. id: "dr"
  821. },
  822. "Sword Muzket": {
  823. id: "zd"
  824. }
  825. }
  826. });
  827. html.newLine();
  828. html.button({
  829. class: "menuB",
  830. innerHTML: "Toggle Another Visual",
  831. onclick: "window.toggleVisual()"
  832. });
  833. html.newLine();
  834. });
  835. });
  836. function toFancyTimeFormat(time) {
  837. let minutes = ~~((time % 3600) / 60);
  838. let seconds = ~~time % 60;
  839. if (seconds <= 9) seconds = `0${seconds}`;
  840. return `${minutes}:${seconds}`;
  841. }
  842. const songchat1 = new Audio("https://cdn.discordapp.com/attachments/1175772907931176991/1227645695796969492/Benzz_-_Je_Mappelle_Music_Video_GRM_Daily.mp3?ex=662fc0a6&is=662e6f26&hm=0b1c67270ba28a0298c01b1a3435bcc5e4aac496053bc3e9a73689cef70870bf&");
  843. let isPlaying = false;
  844. let currentPart = '';
  845. function toggleSong() {
  846. if (!isPlaying) {
  847. songchat1.play();
  848. songchat1.ontimeupdate = function(time) {
  849. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  850. if (part && part !== currentPart) {
  851. currentPart = part;
  852. io.send("6", part);
  853. }
  854. };
  855. songchat1.onended = function() {
  856. if (isPlaying) {
  857. songchat1.play();
  858. }
  859. };
  860. isPlaying = true;
  861. } else {
  862. songchat1.pause();
  863. isPlaying = false;
  864. }
  865. }
  866. document.addEventListener("keypress", function(e) {
  867. if (e.key === "C") {
  868. toggleSong();
  869. }
  870. });
  871. let menuChatDiv = document.createElement("div");
  872. menuChatDiv.id = "menuChatDiv";
  873. document.body.appendChild(menuChatDiv);
  874. HTML.set("menuChatDiv");
  875. HTML.setStyle(`
  876. position: absolute;
  877. display: none;
  878. left: 0px;
  879. top: 25px;
  880. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  881. `);
  882. HTML.resetHTML();
  883. HTML.setCSS(`
  884. .chDiv {
  885. color: #fff;
  886. padding: 10px;
  887. width: 357px;
  888. height: 217px;
  889. background-color: rgba(0, 0, 0, 0.2);
  890. font-family: "HammerSmith One", monospace;
  891. // border-radius: 15px;
  892. // box-shadow: black 1px 2px 19px;
  893. //backdrop-filter: blur(3px);
  894.  
  895. }
  896. .chMainDiv {
  897. font-family: "Ubuntu";
  898. font-size: 16px;
  899. max-height: 215px;
  900. overflow-y: scroll;
  901. scrollbar-width: thin;
  902. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  903. -webkit-touch-callout: none;
  904. -webkit-user-select: none;
  905. -khtml-user-select: none;
  906. -moz-user-select: none;
  907. -ms-user-select: none;
  908. user-select: none;
  909. overflow-x: hidden;
  910. }
  911. .chMainDiv::-webkit-scrollbar {
  912. width: 8px;
  913. }
  914. .chMainDiv::-webkit-scrollbar-thumb {
  915. background-color: rgba(0, 0, 0, 0.5);
  916. }
  917. .chMainDiv::-webkit-scrollbar-thumb:hover {
  918. background-color: rgba(0, 0, 0, 0.7);
  919. }
  920. .chMainBox {
  921. display:none;
  922. position: absolute;
  923. left: 10px;
  924. bottom: 10px;
  925. width: 380px;
  926. height: 25px;
  927. background-color: rgba(255, 255, 255, 0.1);
  928. border-radius: 5px;
  929. color: rgba(255, 255, 255, 0.75);
  930. font-family: "HammerSmith One";
  931. font-size: 12px;
  932. }
  933. `);
  934. HTML.startDiv({
  935. id: "mChDiv",
  936. class: "chDiv"
  937. }, (html) => {
  938. HTML.addDiv({
  939. id: "mChMain",
  940. class: "chMainDiv",
  941. appendID: "mChDiv"
  942. }, (html) => {});
  943. html.text({
  944. id: "mChBox",
  945. class: "chMainBox",
  946. // placeHolder: `Not today`
  947. });
  948. });
  949.  
  950. let menuChats = getEl("mChMain");
  951. let menuChatBox = getEl("mChBox");
  952. let menuCBFocus = false;
  953. let menuChCounts = 0;
  954.  
  955. menuChatBox.value = "";
  956. menuChatBox.addEventListener("focus", () => {
  957. menuCBFocus = true;
  958. });
  959. menuChatBox.addEventListener("blur", () => {
  960. menuCBFocus = false;
  961. });
  962.  
  963. function addMenuChText(name, message, color, noTimer) {
  964. HTML.set("menuChatDiv");
  965. color = color || "white";
  966. let time = new Date();
  967. let min = time.getMinutes();
  968. let hour = time.getHours();
  969. let text = ``;
  970. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  971. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  972. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  973. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  974. html.add(text);
  975. });
  976. menuChats.scrollTop = menuChats.scrollHeight;
  977. menuChCounts++;
  978. }
  979. function chch(name, message, color, noTimer) {
  980. HTML.set("menuChatDiv");
  981. color = color || "white";
  982. let time = new Date();
  983. let text = ``;
  984. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  985. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  986. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  987. html.add(text);
  988. });
  989. menuChats.scrollTop = menuChats.scrollHeight;
  990. menuChCounts++;
  991. }
  992.  
  993. function resetMenuChText() {
  994. menuChats.innerHTML = ``;
  995. menuChCounts = 0;
  996. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  997. }
  998. resetMenuChText();
  999.  
  1000. let menuIndex = 0;
  1001. let menus = ["menuMain", "menuConfig", "menuOther"];
  1002. window.changeMenu = function() {
  1003. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1004. menuIndex++;
  1005. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1006. };
  1007.  
  1008.  
  1009. /*function modLog() {
  1010. let logs = [];
  1011. for (let i = 0; i < arguments.length; i++) {
  1012. logs.push(arguments[i]);
  1013. }
  1014. getEl("modLog").innerHTML = logs;
  1015. }*/
  1016.  
  1017. let openMenu = false;
  1018.  
  1019. let WS = undefined;
  1020. let socketID = undefined;
  1021. //Ong u ass omg
  1022. let spikeB = {
  1023. info: undefined,
  1024. can: false,
  1025. aim: undefined,
  1026. dist: undefined,
  1027. x: undefined,
  1028. y: undefined,
  1029. }
  1030.  
  1031.  
  1032.  
  1033. let useWasd = false;
  1034. let secPacket = 0;
  1035. let secMax = 500;
  1036. let secTime = 1000;
  1037.  
  1038. let minPacket = 0;
  1039. let minMax = 150;
  1040. let minTime = 60000;
  1041.  
  1042. let firstSend = {
  1043. sec: false,
  1044. min: false
  1045. };
  1046.  
  1047. let game = {
  1048. tick: 0,
  1049. tickQueue: [],
  1050. tickBase: function(set, tick) {
  1051. if (this.tickQueue[this.tick + tick]) {
  1052. this.tickQueue[this.tick + tick].push(set);
  1053. } else {
  1054. this.tickQueue[this.tick + tick] = [set];
  1055. }
  1056. },
  1057. tickRate: (1000 / config.serverUpdateRate),
  1058. tickSpeed: 0,
  1059. lastTick: performance.now()
  1060. };
  1061.  
  1062. let modConsole = [];
  1063. let dontSend = false;
  1064.  
  1065. let fpsTimer = {
  1066. last: 0,
  1067. time: 0,
  1068. ltime: 0
  1069. };
  1070.  
  1071. let lastMoveDir = undefined;
  1072. let lastsp = ["cc", 1, "__proto__"];
  1073.  
  1074. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1075. WebSocket.prototype.send = function(message) {
  1076. if (!WS) {
  1077. WS = this;
  1078. WS.addEventListener("message", function(msg) {
  1079. getMessage(msg);
  1080. });
  1081. WS.addEventListener("close", (event) => {
  1082. if (event.code == 4001) {
  1083. window.location.reload();
  1084. }
  1085. });
  1086. }
  1087.  
  1088. if (WS == this) {
  1089. dontSend = false;
  1090.  
  1091. // EXTRACT DATA ARRAY:
  1092. let data = new Uint8Array(message);
  1093. let parsed = window.msgpack.decode(data);
  1094. let type = parsed[0];
  1095. data = parsed[1];
  1096.  
  1097. // SEND MESSAGE:
  1098. if (type == "6") {
  1099. if (data[0]) {
  1100. // ANTI PROFANITY:
  1101. 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", ];
  1102. let tmpString;
  1103. profanity.forEach((profany) => {
  1104. if (data[0].indexOf(profany) > -1) {
  1105. tmpString = "";
  1106. for (let i = 0; i < profany.length; ++i) {
  1107. if (i == 1) {
  1108. tmpString += String.fromCharCode(0);
  1109. }
  1110. tmpString += profany[i];
  1111. }
  1112. let re = new RegExp(profany, "g");
  1113. data[0] = data[0].replace(re, tmpString);
  1114. }
  1115. });
  1116.  
  1117. // FIX CHAT:
  1118. data[0] = data[0].slice(0, 30);
  1119. }
  1120. } else if (type == "L") {
  1121. // MAKE SAME CLAN:
  1122. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1123. data[0] = data[0].slice(0, 7);
  1124. } else if (type == "M") {
  1125. // APPLY CYAN COLOR:
  1126. data[0].name = data[0].name == "" ? "?" : data[0].name;
  1127. data[0].moofoll = true;
  1128. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1129. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1130. } else if (type == "D") {
  1131. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1132. dontSend = true;
  1133. } else {
  1134. my.lastDir = data[0];
  1135. }
  1136. } else if (type == "d") {
  1137. if (!data[2]) {
  1138. dontSend = true;
  1139. } else {
  1140. if (![null, undefined].includes(data[1])) {
  1141. my.lastDir = data[1];
  1142. }
  1143. }
  1144. } else if (type == "K") {
  1145. if (!data[1]) {
  1146. dontSend = true;
  1147. }
  1148. } else if (type == "S") {
  1149. instaC.wait = !instaC.wait;
  1150. dontSend = true;
  1151. } else if (type == "a") {
  1152. if (data[1]) {
  1153. if (player.moveDir == data[0]) {
  1154. dontSend = true;
  1155. }
  1156. player.moveDir = data[0];
  1157. } else {
  1158. dontSend = true;
  1159. }
  1160. }
  1161.  
  1162. if (!dontSend) {
  1163. let binary = window.msgpack.encode([type, data]);
  1164. this.nsend(binary);
  1165.  
  1166. // START SECOND COUNT:
  1167. if (!firstSend.sec) {
  1168. firstSend.sec = true;
  1169. setTimeout(() => {
  1170. firstSend.sec = false;
  1171. secPacket = 0;
  1172. }, secTime);
  1173. }
  1174.  
  1175. secPacket++;
  1176.  
  1177. // START MINUTE COUNT:
  1178. if (!firstSend.min) {
  1179. firstSend.min = true;
  1180. setTimeout(() => {
  1181. firstSend.min = false;
  1182. minPacket = 0;
  1183. }, minTime);
  1184. }
  1185. if (minPacket >= minMax) {
  1186. minPacket = 0;
  1187. }
  1188. minPacket++;
  1189. }
  1190. } else {
  1191. this.nsend(message);
  1192. }
  1193. }
  1194.  
  1195.  
  1196. function packet(type) {
  1197. // EXTRACT DATA ARRAY:
  1198. let data = Array.prototype.slice.call(arguments, 1);
  1199.  
  1200. // SEND MESSAGE:
  1201. let binary = window.msgpack.encode([type, data]);
  1202. WS.send(binary);
  1203. }
  1204.  
  1205. function origPacket(type) {
  1206. // EXTRACT DATA ARRAY:
  1207. let data = Array.prototype.slice.call(arguments, 1);
  1208.  
  1209. // SEND MESSAGE:
  1210. let binary = window.msgpack.encode([type, data]);
  1211. WS.nsend(binary);
  1212. }
  1213.  
  1214. window.leave = function() {
  1215. origPacket("kys", {
  1216. "frvr is so bad": true,
  1217. "sidney is too good": true,
  1218. "dev are too weak": true,
  1219. });
  1220. };
  1221.  
  1222. //...lol
  1223. let io = {
  1224. send: packet
  1225. };
  1226.  
  1227. function getMessage(message) {
  1228. let data = new Uint8Array(message.data);
  1229. let parsed = window.msgpack.decode(data);
  1230. let type = parsed[0];
  1231. data = parsed[1];
  1232. let events = {
  1233. A: setInitData, // id: setInitData,
  1234. //B: disconnect,
  1235. C: setupGame, // 1: setupGame,
  1236. D: addPlayer, // 2: addPlayer,
  1237. E: removePlayer, // 4: removePlayer,
  1238. a: updatePlayers, // 33: updatePlayers,
  1239. G: updateLeaderboard, // 5: updateLeaderboard,here
  1240. H: loadGameObject, // 6: loadGameObject,
  1241. I: loadAI, // a: loadAI,
  1242. J: animateAI, // aa: animateAI,
  1243. K: gatherAnimation, // 7: gatherAnimation,
  1244. L: wiggleGameObject, // 8: wiggleGameObject,
  1245. M: shootTurret, // sp: shootTurret,
  1246. N: updatePlayerValue, // 9: updatePlayerValue,
  1247. O: updateHealth, // h: updateHealth,//here
  1248. P: killPlayer, // 11: killPlayer,
  1249. Q: killObject, // 12: killObject,
  1250. R: killObjects, // 13: killObjects,
  1251. S: updateItemCounts, // 14: updateItemCounts,
  1252. T: updateAge, // 15: updateAge,
  1253. U: updateUpgrades, // 16: updateUpgrades,
  1254. V: updateItems, // 17: updateItems,
  1255. X: addProjectile, // 18: addProjectile,
  1256. Y: remProjectile, // 19: remProjectile,
  1257. //Z: serverShutdownNotice,
  1258. //0: addAlliance,
  1259. //1: deleteAlliance,
  1260. 2: allianceNotification, // an: allianceNotification,
  1261. 3: setPlayerTeam, // st: setPlayerTeam,
  1262. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1263. 5: updateStoreItems, // us: updateStoreItems,
  1264. 6: receiveChat, // ch: receiveChat,
  1265. 7: updateMinimap, // mm: updateMinimap,
  1266. 8: showText, // t: showText,
  1267. 9: pingMap, // p: pingMap,
  1268. 0: pingSocketResponse,
  1269. };
  1270. if (type == "io-init") {
  1271. socketID = data[0];
  1272. } else {
  1273. if (events[type]) {
  1274. events[type].apply(undefined, data);
  1275. }
  1276. }
  1277. }
  1278.  
  1279. // MATHS:
  1280. Math.lerpAngle = function(value1, value2, amount) {
  1281. let difference = Math.abs(value2 - value1);
  1282. if (difference > Math.PI) {
  1283. if (value1 > value2) {
  1284. value2 += Math.PI * 2;
  1285. } else {
  1286. value1 += Math.PI * 2;
  1287. }
  1288. }
  1289. let value = value2 + ((value1 - value2) * amount);
  1290. if (value >= 0 && value <= Math.PI * 2) return value;
  1291. return value % (Math.PI * 2);
  1292. };
  1293.  
  1294. // REOUNDED RECTANGLE:
  1295. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1296. if (w < 2 * r) r = w / 2;
  1297. if (h < 2 * r) r = h / 2;
  1298. if (r < 0)
  1299. r = 0;
  1300. this.beginPath();
  1301. this.moveTo(x + r, y);
  1302. this.arcTo(x + w, y, x + w, y + h, r);
  1303. this.arcTo(x + w, y + h, x, y + h, r);
  1304. this.arcTo(x, y + h, x, y, r);
  1305. this.arcTo(x, y, x + w, y, r);
  1306. this.closePath();
  1307. return this;
  1308. };
  1309.  
  1310. // GLOBAL VALUES:
  1311. function resetMoveDir() {
  1312. keys = {};
  1313. io.send("e");
  1314. }
  1315.  
  1316. let allChats = [];
  1317. let ticks = {
  1318. tick: 0,
  1319. delay: 0,
  1320. time: [],
  1321. manage: [],
  1322. };
  1323. let ais = [];
  1324. let players = [];
  1325. let alliances = [];
  1326. let alliancePlayers = [];
  1327. let allianceNotifications = [];
  1328. let gameObjects = [];
  1329. let liztobj = [];
  1330. let projectiles = [];
  1331. let deadPlayers = [];
  1332.  
  1333. let breakObjects = [];
  1334.  
  1335. let player;
  1336. let playerSID;
  1337. let tmpObj;
  1338.  
  1339. let enemy = [];
  1340. let nears = [];
  1341. let near = [];
  1342.  
  1343. let my = {
  1344. reloaded: false,
  1345. waitHit: 0,
  1346. autoAim: false,
  1347. revAim: false,
  1348. ageInsta: true,
  1349. reSync: false,
  1350. bullTick: 0,
  1351. anti0Tick: 0,
  1352. antiSync: false,
  1353. safePrimary: function(tmpObj) {
  1354. return [0, 8].includes(tmpObj.primaryIndex);
  1355. },
  1356. safeSecondary: function(tmpObj) {
  1357. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1358. },
  1359. lastDir: 0,
  1360. autoPush: false,
  1361. pushData: {}
  1362. }
  1363.  
  1364. // FIND OBJECTS BY ID/SID:
  1365. function findID(tmpObj, tmp) {
  1366. return tmpObj.find((THIS) => THIS.id == tmp);
  1367. }
  1368.  
  1369. function findSID(tmpObj, tmp) {
  1370. return tmpObj.find((THIS) => THIS.sid == tmp);
  1371. }
  1372.  
  1373. function findPlayerByID(id) {
  1374. return findID(players, id);
  1375. }
  1376.  
  1377. function findPlayerBySID(sid) {
  1378. return findSID(players, sid);
  1379. }
  1380.  
  1381. function findAIBySID(sid) {
  1382. return findSID(ais, sid);
  1383. }
  1384.  
  1385. function findObjectBySid(sid) {
  1386. return findSID(gameObjects, sid);
  1387. }
  1388.  
  1389. function findProjectileBySid(sid) {
  1390. return findSID(gameObjects, sid);
  1391. }
  1392.  
  1393. let gameName = getEl("gameName");
  1394. gameName.innerText = "Cheap CHicken";
  1395. let adCard = getEl("adCard");
  1396. adCard.remove();
  1397. let promoImageHolder = getEl("promoImgHolder");
  1398. promoImageHolder.remove();
  1399.  
  1400. let chatButton = getEl("chatButton");
  1401. chatButton.remove();
  1402. let gameCanvas = getEl("gameCanvas");
  1403. let mainContext = gameCanvas.getContext("2d");
  1404. let mapDisplay = getEl("mapDisplay");
  1405. let mapContext = mapDisplay.getContext("2d");
  1406. mapDisplay.width = 300;
  1407. mapDisplay.height = 300;
  1408. let storeMenu = getEl("storeMenu");
  1409. let storeHolder = getEl("storeHolder");
  1410. let upgradeHolder = getEl("upgradeHolder");
  1411. let upgradeCounter = getEl("upgradeCounter");
  1412. let chatBox = getEl("chatBox");
  1413. chatBox.autocomplete = "off";
  1414. chatBox.style.textAlign = "center";
  1415. chatBox.style.width = "18em";
  1416. let chatHolder = getEl("chatHolder");
  1417. let actionBar = getEl("actionBar");
  1418. let leaderboardData = getEl("leaderboardData");
  1419. let itemInfoHolder = getEl("itemInfoHolder");
  1420. let menuCardHolder = getEl("menuCardHolder");
  1421. let mainMenu = getEl("mainMenu");
  1422. getEl("mainMenu").style.backgroundImage = "url('https://c1.wallpaperflare.com/preview/747/358/397/你的母亲-hart-night-view-thumbnail.jpg')";
  1423. let diedText = getEl("diedText");
  1424. let screenWidth;
  1425. let screenHeight;
  1426. let maxScreenWidth = config.maxScreenWidth;
  1427. let maxScreenHeight = config.maxScreenHeight;
  1428. let pixelDensity = 1;
  1429. let delta;
  1430. let now;
  1431. let lastUpdate = performance.now();
  1432. let camX;
  1433. let camY;
  1434. let tmpDir;
  1435. let mouseX = 0;
  1436. let mouseY = 0;
  1437. let allianceMenu = getEl("allianceMenu");
  1438. let waterMult = 1;
  1439. let waterPlus = 0;
  1440.  
  1441. let outlineColor = "#525252";
  1442. let darkOutlineColor = "#3d3f42";
  1443. let outlineWidth = 5.5;
  1444.  
  1445. let firstSetup = true;
  1446. let keys = {};
  1447. let moveKeys = {
  1448. 87: [0, -1],
  1449. 38: [0, -1],
  1450. 83: [0, 1],
  1451. 40: [0, 1],
  1452. 65: [-1, 0],
  1453. 37: [-1, 0],
  1454. 68: [1, 0],
  1455. 39: [1, 0],
  1456. };
  1457. let attackState = 0;
  1458. let inGame = false;
  1459.  
  1460. let macro = {};
  1461. let mills = {
  1462. place: 0,
  1463. placeSpawnPads: 0
  1464. };
  1465. let lastDir;
  1466.  
  1467. let lastLeaderboardData = [];
  1468.  
  1469. // ON LOAD:
  1470. let inWindow = true;
  1471. window.onblur = function() {
  1472. inWindow = false;
  1473. };
  1474. window.onfocus = function() {
  1475. inWindow = true;
  1476. if (player && player.alive) {
  1477. // resetMoveDir();
  1478. }
  1479. };
  1480. let ms = {
  1481. avg: 0,
  1482. max: 0,
  1483. min: 0,
  1484. delay: 0
  1485. }
  1486. function pingSocketResponse() {
  1487. let pingTime = window.pingTime;
  1488. const pingDisplay = document.getElementById("pingDisplay")
  1489. pingDisplay.innerText = "Ping: " + pingTime + " ms | FPS: " + Math.round(fpsTimer.ltime);
  1490. if (pingTime > ms.max || isNaN(ms.max)) {
  1491. ms.max = pingTime;
  1492. }
  1493. if (pingTime < ms.min || isNaN(ms.min)) {
  1494. ms.min = pingTime;
  1495. }
  1496.  
  1497. // if (pingTime >= 90) {
  1498. // doAutoQ = true;
  1499. // } else {
  1500. // doAutoQ = false;
  1501. // }
  1502. }
  1503.  
  1504. let placeVisible = [];
  1505.  
  1506. /** CLASS CODES */
  1507.  
  1508.  
  1509. class Utils {
  1510. constructor() {
  1511.  
  1512. // MATH UTILS:
  1513. let mathABS = Math.abs,
  1514. mathCOS = Math.cos,
  1515. mathSIN = Math.sin,
  1516. mathPOW = Math.pow,
  1517. mathSQRT = Math.sqrt,
  1518. mathATAN2 = Math.atan2,
  1519. mathPI = Math.PI;
  1520.  
  1521. let _this = this;
  1522.  
  1523. // GLOBAL UTILS:
  1524. this.round = function(n, v) {
  1525. return Math.round(n * v) / v;
  1526. };
  1527. this.toRad = function(angle) {
  1528. return angle * (mathPI / 180);
  1529. };
  1530. this.toAng = function(radian) {
  1531. return radian / (mathPI / 180);
  1532. };
  1533. this.randInt = function(min, max) {
  1534. return Math.floor(Math.random() * (max - min + 1)) + min;
  1535. };
  1536. this.randFloat = function(min, max) {
  1537. return Math.random() * (max - min + 1) + min;
  1538. };
  1539. this.lerp = function(value1, value2, amount) {
  1540. return value1 + (value2 - value1) * amount;
  1541. };
  1542. this.decel = function(val, cel) {
  1543. if (val > 0)
  1544. val = Math.max(0, val - cel);
  1545. else if (val < 0)
  1546. val = Math.min(0, val + cel);
  1547. return val;
  1548. };
  1549. this.getDistance = function(x1, y1, x2, y2) {
  1550. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1551. };
  1552. this.getDist = function(tmp1, tmp2, type1, type2) {
  1553. let tmpXY1 = {
  1554. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1555. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1556. };
  1557. let tmpXY2 = {
  1558. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1559. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1560. };
  1561. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1562. };
  1563. this.getDirection = function(x1, y1, x2, y2) {
  1564. return mathATAN2(y1 - y2, x1 - x2);
  1565. };
  1566. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1567. let tmpXY1 = {
  1568. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1569. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1570. };
  1571. let tmpXY2 = {
  1572. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1573. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1574. };
  1575. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1576. };
  1577. this.getAngleDist = function(a, b) {
  1578. let p = mathABS(b - a) % (mathPI * 2);
  1579. return (p > mathPI ? (mathPI * 2) - p : p);
  1580. };
  1581. this.isNumber = function(n) {
  1582. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1583. };
  1584. this.isString = function(s) {
  1585. return (s && typeof s == "string");
  1586. };
  1587. this.kFormat = function(num) {
  1588. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1589. };
  1590. this.sFormat = function(num) {
  1591. let fixs = [{
  1592. num: 1e3,
  1593. string: "k"
  1594. },
  1595. {
  1596. num: 1e6,
  1597. string: "m"
  1598. },
  1599. {
  1600. num: 1e9,
  1601. string: "b"
  1602. },
  1603. {
  1604. num: 1e12,
  1605. string: "q"
  1606. }
  1607. ].reverse();
  1608. let sp = fixs.find(v => num >= v.num);
  1609. if (!sp) return num;
  1610. return (num / sp.num).toFixed(1) + sp.string;
  1611. };
  1612. this.capitalizeFirst = function(string) {
  1613. return string.charAt(0).toUpperCase() + string.slice(1);
  1614. };
  1615. this.fixTo = function(n, v) {
  1616. return parseFloat(n.toFixed(v));
  1617. };
  1618. this.sortByPoints = function(a, b) {
  1619. return parseFloat(b.points) - parseFloat(a.points);
  1620. };
  1621. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1622. let minX = x1;
  1623. let maxX = x2;
  1624. if (x1 > x2) {
  1625. minX = x2;
  1626. maxX = x1;
  1627. }
  1628. if (maxX > recX2)
  1629. maxX = recX2;
  1630. if (minX < recX)
  1631. minX = recX;
  1632. if (minX > maxX)
  1633. return false;
  1634. let minY = y1;
  1635. let maxY = y2;
  1636. let dx = x2 - x1;
  1637. if (Math.abs(dx) > 0.0000001) {
  1638. let a = (y2 - y1) / dx;
  1639. let b = y1 - a * x1;
  1640. minY = a * minX + b;
  1641. maxY = a * maxX + b;
  1642. }
  1643. if (minY > maxY) {
  1644. let tmp = maxY;
  1645. maxY = minY;
  1646. minY = tmp;
  1647. }
  1648. if (maxY > recY2)
  1649. maxY = recY2;
  1650. if (minY < recY)
  1651. minY = recY;
  1652. if (minY > maxY)
  1653. return false;
  1654. return true;
  1655. };
  1656. this.containsPoint = function(element, x, y) {
  1657. let bounds = element.getBoundingClientRect();
  1658. let left = bounds.left + window.scrollX;
  1659. let top = bounds.top + window.scrollY;
  1660. let width = bounds.width;
  1661. let height = bounds.height;
  1662.  
  1663. let insideHorizontal = x > left && x < left + width;
  1664. let insideVertical = y > top && y < top + height;
  1665. return insideHorizontal && insideVertical;
  1666. };
  1667. this.mousifyTouchEvent = function(event) {
  1668. let touch = event.changedTouches[0];
  1669. event.screenX = touch.screenX;
  1670. event.screenY = touch.screenY;
  1671. event.clientX = touch.clientX;
  1672. event.clientY = touch.clientY;
  1673. event.pageX = touch.pageX;
  1674. event.pageY = touch.pageY;
  1675. };
  1676. this.hookTouchEvents = function(element, skipPrevent) {
  1677. let preventDefault = !skipPrevent;
  1678. let isHovering = false;
  1679. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1680. let passive = false;
  1681. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1682. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1683. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1684. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1685. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1686.  
  1687. function touchStart(e) {
  1688. _this.mousifyTouchEvent(e);
  1689. window.setUsingTouch(true);
  1690. if (preventDefault) {
  1691. e.preventDefault();
  1692. e.stopPropagation();
  1693. }
  1694. if (element.onmouseover)
  1695. element.onmouseover(e);
  1696. isHovering = true;
  1697. }
  1698.  
  1699. function touchMove(e) {
  1700. _this.mousifyTouchEvent(e);
  1701. window.setUsingTouch(true);
  1702. if (preventDefault) {
  1703. e.preventDefault();
  1704. e.stopPropagation();
  1705. }
  1706. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1707. if (!isHovering) {
  1708. if (element.onmouseover)
  1709. element.onmouseover(e);
  1710. isHovering = true;
  1711. }
  1712. } else {
  1713. if (isHovering) {
  1714. if (element.onmouseout)
  1715. element.onmouseout(e);
  1716. isHovering = false;
  1717. }
  1718. }
  1719. }
  1720.  
  1721. function touchEnd(e) {
  1722. _this.mousifyTouchEvent(e);
  1723. window.setUsingTouch(true);
  1724. if (preventDefault) {
  1725. e.preventDefault();
  1726. e.stopPropagation();
  1727. }
  1728. if (isHovering) {
  1729. if (element.onclick)
  1730. element.onclick(e);
  1731. if (element.onmouseout)
  1732. element.onmouseout(e);
  1733. isHovering = false;
  1734. }
  1735. }
  1736. };
  1737. this.removeAllChildren = function(element) {
  1738. while (element.hasChildNodes()) {
  1739. element.removeChild(element.lastChild);
  1740. }
  1741. };
  1742. this.generateElement = function(config) {
  1743. let element = document.createElement(config.tag || "div");
  1744.  
  1745. function bind(configValue, elementValue) {
  1746. if (config[configValue])
  1747. element[elementValue] = config[configValue];
  1748. }
  1749. bind("text", "textContent");
  1750. bind("html", "innerHTML");
  1751. bind("class", "className");
  1752. for (let key in config) {
  1753. switch (key) {
  1754. case "tag":
  1755. case "text":
  1756. case "html":
  1757. case "class":
  1758. case "style":
  1759. case "hookTouch":
  1760. case "parent":
  1761. case "children":
  1762. continue;
  1763. default:
  1764. break;
  1765. }
  1766. element[key] = config[key];
  1767. }
  1768. if (element.onclick)
  1769. element.onclick = this.checkTrusted(element.onclick);
  1770. if (element.onmouseover)
  1771. element.onmouseover = this.checkTrusted(element.onmouseover);
  1772. if (element.onmouseout)
  1773. element.onmouseout = this.checkTrusted(element.onmouseout);
  1774. if (config.style) {
  1775. element.style.cssText = config.style;
  1776. }
  1777. if (config.hookTouch) {
  1778. this.hookTouchEvents(element);
  1779. }
  1780. if (config.parent) {
  1781. config.parent.appendChild(element);
  1782. }
  1783. if (config.children) {
  1784. for (let i = 0; i < config.children.length; i++) {
  1785. element.appendChild(config.children[i]);
  1786. }
  1787. }
  1788. return element;
  1789. };
  1790. this.checkTrusted = function(callback) {
  1791. return function(ev) {
  1792. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1793. callback(ev);
  1794. } else {
  1795. //console.error("Event is not trusted.", ev);
  1796. }
  1797. };
  1798. };
  1799. this.randomString = function(length) {
  1800. let text = "";
  1801. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1802. for (let i = 0; i < length; i++) {
  1803. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1804. }
  1805. return text;
  1806. };
  1807. this.countInArray = function(array, val) {
  1808. let count = 0;
  1809. for (let i = 0; i < array.length; i++) {
  1810. if (array[i] === val) count++;
  1811. }
  1812. return count;
  1813. };
  1814. this.hexToRgb = function(hex) {
  1815. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1816. };
  1817. this.getRgb = function(r, g, b) {
  1818. return [r / 255, g / 255, b / 255].join(", ");
  1819. };
  1820. }
  1821. };
  1822. class Animtext {
  1823. // ANIMATED TEXT:
  1824. constructor() {
  1825. // INIT:
  1826. this.init = function(x, y, scale, speed, life, text, color) {
  1827. (this.x = x),
  1828. (this.y = y),
  1829. (this.color = color),
  1830. (this.scale = scale*3.5),
  1831. (this.weight = 50);
  1832. (this.startScale = this.scale * 1.2),
  1833. (this.maxScale = 1.5 * scale),
  1834. (this.minScale = 0.5 * scale),
  1835. (this.scaleSpeed = 0.7),
  1836. (this.speed = speed),
  1837. (this.speedMax = speed),
  1838. (this.life = life),
  1839. (this.maxLife = life),
  1840. (this.text = text),
  1841. this.movSpeed = speed;
  1842. };
  1843.  
  1844. // UPDATE:
  1845. this.update = function(delta) {
  1846. if(this.life){
  1847. this.life -= delta;
  1848. if(this.scaleSpeed != -0.35){
  1849. this.y -= this.speed * delta;
  1850. // (this.x += this.speed * delta);
  1851. } else {
  1852. this.y -= this.speed * delta;
  1853. }
  1854. this.scale -= .8;
  1855. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  1856. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  1857. if(this.scale >= this.maxScale){
  1858. this.scale = this.maxScale;
  1859. this.scaleSpeed *= -.5;
  1860. this.speed = this.speed * .75;
  1861. };
  1862. this.life <= 0 && (this.life = 0)
  1863. };
  1864. };
  1865.  
  1866. // RENDER:
  1867. this.render = function(ctxt, xOff, yOff) {
  1868. ctxt.lineWidth = 10;
  1869. ctxt.strokeStyle = darkOutlineColor; //"black";
  1870. ctxt.fillStyle = this.color;
  1871. ctxt.globalAlpha = 1;
  1872. ctxt.font = this.scale + "px HammerSmith One";
  1873. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1874. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1875. ctxt.globalAlpha = 1;
  1876. };
  1877. }
  1878. };
  1879. class Textmanager {
  1880. // TEXT MANAGER:
  1881. constructor() {
  1882. this.texts = [];
  1883. this.stack = [];
  1884.  
  1885. // UPDATE:
  1886. this.update = function(delta, ctxt, xOff, yOff) {
  1887. ctxt.textBaseline = "middle";
  1888. ctxt.textAlign = "center";
  1889. for (let i = this.texts.length - 1; i >= 0; --i) {
  1890. if (this.texts[i].life > 0) {
  1891. this.texts[i].update(delta);
  1892. this.texts[i].render(ctxt, xOff, yOff);
  1893. } else {
  1894. this.texts.splice(i, 1);
  1895. }
  1896. }
  1897. };
  1898.  
  1899. // SHOW TEXT:
  1900. this.showText = function(x, y, scale, speed, life, text, color) {
  1901. let tmpText;
  1902. for (let i = 0; i < this.texts.length; ++i) {
  1903. if (!this.texts[i].life) {
  1904. tmpText = this.texts[i];
  1905. break;
  1906. }
  1907. }
  1908. if (!tmpText) {
  1909. tmpText = new Animtext();
  1910. this.texts.push(tmpText);
  1911. }
  1912. tmpText.init(x, y, scale, speed, life, text, color);
  1913. };
  1914. }
  1915. }
  1916.  
  1917. class Items {
  1918. constructor() {
  1919. // ITEM GROUPS:
  1920. this.groups = [{
  1921. id: 0,
  1922. name: "food",
  1923. layer: 0
  1924. }, {
  1925. id: 1,
  1926. name: "walls",
  1927. place: true,
  1928. limit: 30,
  1929. layer: 0
  1930. }, {
  1931. id: 2,
  1932. name: "spikes",
  1933. place: true,
  1934. limit: 15,
  1935. layer: 0
  1936. }, {
  1937. id: 3,
  1938. name: "mill",
  1939. place: true,
  1940. limit: 7,
  1941. layer: 1
  1942. }, {
  1943. id: 4,
  1944. name: "mine",
  1945. place: true,
  1946. limit: 1,
  1947. layer: 0
  1948. }, {
  1949. id: 5,
  1950. name: "trap",
  1951. place: true,
  1952. limit: 6,
  1953. layer: -1
  1954. }, {
  1955. id: 6,
  1956. name: "booster",
  1957. place: true,
  1958. limit: 12,
  1959. layer: -1
  1960. }, {
  1961. id: 7,
  1962. name: "turret",
  1963. place: true,
  1964. limit: 2,
  1965. layer: 1
  1966. }, {
  1967. id: 8,
  1968. name: "watchtower",
  1969. place: true,
  1970. limit: 12,
  1971. layer: 1
  1972. }, {
  1973. id: 9,
  1974. name: "buff",
  1975. place: true,
  1976. limit: 4,
  1977. layer: -1
  1978. }, {
  1979. id: 10,
  1980. name: "spawn",
  1981. place: true,
  1982. limit: 1,
  1983. layer: -1
  1984. }, {
  1985. id: 11,
  1986. name: "sapling",
  1987. place: true,
  1988. limit: 2,
  1989. layer: 0
  1990. }, {
  1991. id: 12,
  1992. name: "blocker",
  1993. place: true,
  1994. limit: 3,
  1995. layer: -1
  1996. }, {
  1997. id: 13,
  1998. name: "teleporter",
  1999. place: true,
  2000. limit: 2,
  2001. layer: -1
  2002. }];
  2003.  
  2004. // PROJECTILES:
  2005. this.projectiles = [{
  2006. indx: 0,
  2007. layer: 0,
  2008. src: "arrow_1",
  2009. dmg: 25,
  2010. speed: 1.6,
  2011. scale: 103,
  2012. range: 1000
  2013. }, {
  2014. indx: 1,
  2015. layer: 1,
  2016. dmg: 25,
  2017. scale: 20
  2018. }, {
  2019. indx: 0,
  2020. layer: 0,
  2021. src: "arrow_1",
  2022. dmg: 35,
  2023. speed: 2.5,
  2024. scale: 103,
  2025. range: 1200
  2026. }, {
  2027. indx: 0,
  2028. layer: 0,
  2029. src: "arrow_1",
  2030. dmg: 30,
  2031. speed: 2,
  2032. scale: 103,
  2033. range: 1200
  2034. }, {
  2035. indx: 1,
  2036. layer: 1,
  2037. dmg: 16,
  2038. scale: 20
  2039. }, {
  2040. indx: 0,
  2041. layer: 0,
  2042. src: "bullet_1",
  2043. dmg: 50,
  2044. speed: 3.6,
  2045. scale: 160,
  2046. range: 1400
  2047. }];
  2048.  
  2049. // WEAPONS:
  2050. this.weapons = [{
  2051. id: 0,
  2052. type: 0,
  2053. name: "tool hammer",
  2054. desc: "tool for gathering all resources",
  2055. src: "hammer_1",
  2056. length: 140,
  2057. width: 140,
  2058. xOff: -3,
  2059. yOff: 18,
  2060. dmg: 25,
  2061. range: 65,
  2062. gather: 1,
  2063. speed: 300
  2064. }, {
  2065. id: 1,
  2066. type: 0,
  2067. age: 2,
  2068. name: "hand axe",
  2069. desc: "gathers resources at a higher rate",
  2070. src: "axe_1",
  2071. length: 140,
  2072. width: 140,
  2073. xOff: 3,
  2074. yOff: 24,
  2075. dmg: 30,
  2076. spdMult: 1,
  2077. range: 70,
  2078. gather: 2,
  2079. speed: 400
  2080. }, {
  2081. id: 2,
  2082. type: 0,
  2083. age: 8,
  2084. pre: 1,
  2085. name: "great axe",
  2086. desc: "deal more damage and gather more resources",
  2087. src: "great_axe_1",
  2088. length: 140,
  2089. width: 140,
  2090. xOff: -8,
  2091. yOff: 25,
  2092. dmg: 35,
  2093. spdMult: 1,
  2094. range: 75,
  2095. gather: 4,
  2096. speed: 400
  2097. }, {
  2098. id: 3,
  2099. type: 0,
  2100. age: 2,
  2101. name: "short sword",
  2102. desc: "increased attack power but slower move speed",
  2103. src: "sword_1",
  2104. iPad: 1.3,
  2105. length: 130,
  2106. width: 210,
  2107. xOff: -8,
  2108. yOff: 46,
  2109. dmg: 35,
  2110. spdMult: 0.85,
  2111. range: 110,
  2112. gather: 1,
  2113. speed: 300
  2114. }, {
  2115. id: 4,
  2116. type: 0,
  2117. age: 8,
  2118. pre: 3,
  2119. name: "katana",
  2120. desc: "greater range and damage",
  2121. src: "samurai_1",
  2122. iPad: 1.3,
  2123. length: 130,
  2124. width: 210,
  2125. xOff: -8,
  2126. yOff: 59,
  2127. dmg: 40,
  2128. spdMult: 0.8,
  2129. range: 118,
  2130. gather: 1,
  2131. speed: 300
  2132. }, {
  2133. id: 5,
  2134. type: 0,
  2135. age: 2,
  2136. name: "polearm",
  2137. desc: "long range melee weapon",
  2138. src: "spear_1",
  2139. iPad: 1.3,
  2140. length: 130,
  2141. width: 210,
  2142. xOff: -8,
  2143. yOff: 53,
  2144. dmg: 45,
  2145. knock: 0.2,
  2146. spdMult: 0.82,
  2147. range: 142,
  2148. gather: 1,
  2149. speed: 700
  2150. }, {
  2151. id: 6,
  2152. type: 0,
  2153. age: 2,
  2154. name: "bat",
  2155. desc: "fast long range melee weapon",
  2156. src: "bat_1",
  2157. iPad: 1.3,
  2158. length: 110,
  2159. width: 180,
  2160. xOff: -8,
  2161. yOff: 53,
  2162. dmg: 20,
  2163. knock: 0.7,
  2164. range: 110,
  2165. gather: 1,
  2166. speed: 300
  2167. }, {
  2168. id: 7,
  2169. type: 0,
  2170. age: 2,
  2171. name: "daggers",
  2172. desc: "really fast short range weapon",
  2173. src: "dagger_1",
  2174. iPad: 0.8,
  2175. length: 110,
  2176. width: 110,
  2177. xOff: 18,
  2178. yOff: 0,
  2179. dmg: 20,
  2180. knock: 0.1,
  2181. range: 65,
  2182. gather: 1,
  2183. hitSlow: 0.1,
  2184. spdMult: 1.13,
  2185. speed: 100
  2186. }, {
  2187. id: 8,
  2188. type: 0,
  2189. age: 2,
  2190. name: "stick",
  2191. desc: "great for gathering but very weak",
  2192. src: "stick_1",
  2193. length: 140,
  2194. width: 140,
  2195. xOff: 3,
  2196. yOff: 24,
  2197. dmg: 1,
  2198. spdMult: 1,
  2199. range: 70,
  2200. gather: 7,
  2201. speed: 400
  2202. }, {
  2203. id: 9,
  2204. type: 1,
  2205. age: 6,
  2206. name: "hunting bow",
  2207. desc: "bow used for ranged combat and hunting",
  2208. src: "bow_1",
  2209. req: ["wood", 4],
  2210. length: 120,
  2211. width: 120,
  2212. xOff: -6,
  2213. yOff: 0,
  2214. Pdmg: 25,
  2215. projectile: 0,
  2216. spdMult: 0.75,
  2217. speed: 600
  2218. }, {
  2219. id: 10,
  2220. type: 1,
  2221. age: 6,
  2222. name: "great hammer",
  2223. desc: "hammer used for destroying structures",
  2224. src: "great_hammer_1",
  2225. length: 140,
  2226. width: 140,
  2227. xOff: -9,
  2228. yOff: 25,
  2229. dmg: 10,
  2230. Pdmg: 10,
  2231. spdMult: 0.88,
  2232. range: 75,
  2233. sDmg: 7.5,
  2234. gather: 1,
  2235. speed: 400
  2236. }, {
  2237. id: 11,
  2238. type: 1,
  2239. age: 6,
  2240. name: "wooden shield",
  2241. desc: "blocks projectiles and reduces melee damage",
  2242. src: "shield_1",
  2243. length: 120,
  2244. width: 120,
  2245. shield: 0.2,
  2246. xOff: 6,
  2247. yOff: 0,
  2248. Pdmg: 0,
  2249. spdMult: 0.7
  2250. }, {
  2251. id: 12,
  2252. type: 1,
  2253. age: 8,
  2254. pre: 9,
  2255. name: "crossbow",
  2256. desc: "deals more damage and has greater range",
  2257. src: "crossbow_1",
  2258. req: ["wood", 5],
  2259. aboveHand: true,
  2260. armS: 0.75,
  2261. length: 120,
  2262. width: 120,
  2263. xOff: -4,
  2264. yOff: 0,
  2265. Pdmg: 35,
  2266. projectile: 2,
  2267. spdMult: 0.7,
  2268. speed: 700
  2269. }, {
  2270. id: 13,
  2271. type: 1,
  2272. age: 9,
  2273. pre: 12,
  2274. name: "repeater crossbow",
  2275. desc: "high firerate crossbow with reduced damage",
  2276. src: "crossbow_2",
  2277. req: ["wood", 10],
  2278. aboveHand: true,
  2279. armS: 0.75,
  2280. length: 120,
  2281. width: 120,
  2282. xOff: -4,
  2283. yOff: 0,
  2284. Pdmg: 30,
  2285. projectile: 3,
  2286. spdMult: 0.7,
  2287. speed: 230
  2288. }, {
  2289. id: 14,
  2290. type: 1,
  2291. age: 6,
  2292. name: "mc grabby",
  2293. desc: "steals resources from enemies",
  2294. src: "grab_1",
  2295. length: 130,
  2296. width: 210,
  2297. xOff: -8,
  2298. yOff: 53,
  2299. dmg: 0,
  2300. Pdmg: 0,
  2301. steal: 250,
  2302. knock: 0.2,
  2303. spdMult: 1.05,
  2304. range: 125,
  2305. gather: 0,
  2306. speed: 700
  2307. }, {
  2308. id: 15,
  2309. type: 1,
  2310. age: 9,
  2311. pre: 12,
  2312. name: "musket",
  2313. desc: "slow firerate but high damage and range",
  2314. src: "musket_1",
  2315. req: ["stone", 10],
  2316. aboveHand: true,
  2317. rec: 0.35,
  2318. armS: 0.6,
  2319. hndS: 0.3,
  2320. hndD: 1.6,
  2321. length: 205,
  2322. width: 205,
  2323. xOff: 25,
  2324. yOff: 0,
  2325. Pdmg: 50,
  2326. projectile: 5,
  2327. hideProjectile: true,
  2328. spdMult: 0.6,
  2329. speed: 1500
  2330. }];
  2331.  
  2332. // ITEMS:
  2333. this.list = [{
  2334. group: this.groups[0],
  2335. name: "apple",
  2336. desc: "restores 20 health when consumed",
  2337. req: ["food", 10],
  2338. consume: function(doer) {
  2339. return doer.changeHealth(20, doer);
  2340. },
  2341. scale: 22,
  2342. holdOffset: 15,
  2343. healing: 20,
  2344. itemID: 0,
  2345. itemAID: 16,
  2346. }, {
  2347. age: 3,
  2348. group: this.groups[0],
  2349. name: "cookie",
  2350. desc: "restores 40 health when consumed",
  2351. req: ["food", 15],
  2352. consume: function(doer) {
  2353. return doer.changeHealth(40, doer);
  2354. },
  2355. scale: 27,
  2356. holdOffset: 15,
  2357. healing: 40,
  2358. itemID: 1,
  2359. itemAID: 17,
  2360. }, {
  2361. age: 7,
  2362. group: this.groups[0],
  2363. name: "cheese",
  2364. desc: "restores 30 health and another 50 over 5 seconds",
  2365. req: ["food", 25],
  2366. consume: function(doer) {
  2367. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2368. doer.dmgOverTime.dmg = -10;
  2369. doer.dmgOverTime.doer = doer;
  2370. doer.dmgOverTime.time = 5;
  2371. return true;
  2372. }
  2373. return false;
  2374. },
  2375. scale: 27,
  2376. holdOffset: 15,
  2377. healing: 30,
  2378. itemID: 2,
  2379. itemAID: 18,
  2380. }, {
  2381. group: this.groups[1],
  2382. name: "wood wall",
  2383. desc: "provides protection for your village",
  2384. req: ["wood", 10],
  2385. projDmg: true,
  2386. health: 380,
  2387. scale: 50,
  2388. holdOffset: 20,
  2389. placeOffset: -5,
  2390. itemID: 3,
  2391. itemAID: 19,
  2392. }, {
  2393. age: 3,
  2394. group: this.groups[1],
  2395. name: "stone wall",
  2396. desc: "provides improved protection for your village",
  2397. req: ["stone", 25],
  2398. health: 900,
  2399. scale: 50,
  2400. holdOffset: 20,
  2401. placeOffset: -5,
  2402. itemID: 4,
  2403. itemAID: 20,
  2404. }, {
  2405. age: 7,
  2406. group: this.groups[1],
  2407. name: "castle wall",
  2408. desc: "provides powerful protection for your village",
  2409. req: ["stone", 35],
  2410. health: 1500,
  2411. scale: 52,
  2412. holdOffset: 20,
  2413. placeOffset: -5,
  2414. itemID: 5,
  2415. itemAID: 21,
  2416. }, {
  2417. group: this.groups[2],
  2418. name: "spikes",
  2419. desc: "damages enemies when they touch them",
  2420. req: ["wood", 20, "stone", 5],
  2421. health: 400,
  2422. dmg: 20,
  2423. scale: 49,
  2424. spritePadding: -23,
  2425. holdOffset: 8,
  2426. placeOffset: -5,
  2427. itemID: 6,
  2428. itemAID: 22,
  2429. shadow: {
  2430. offsetX: 5, // Adjust the shadow's X offset as needed
  2431. offsetY: 5, // Adjust the shadow's Y offset as needed
  2432. blur: 20, // Adjust the shadow's blur as needed
  2433. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2434. }
  2435.  
  2436. }, {
  2437. age: 5,
  2438. group: this.groups[2],
  2439. name: "greater spikes",
  2440. desc: "damages enemies when they touch them",
  2441. req: ["wood", 30, "stone", 10],
  2442. health: 500,
  2443. dmg: 35,
  2444. scale: 52,
  2445. spritePadding: -23,
  2446. holdOffset: 8,
  2447. placeOffset: -5,
  2448. itemID: 7,
  2449. itemAID: 23,
  2450. }, {
  2451. age: 9,
  2452. group: this.groups[2],
  2453. name: "poison spikes",
  2454. desc: "poisons enemies when they touch them",
  2455. req: ["wood", 35, "stone", 15],
  2456. health: 600,
  2457. dmg: 30,
  2458. pDmg: 5,
  2459. scale: 52,
  2460. spritePadding: -23,
  2461. holdOffset: 8,
  2462. placeOffset: -5,
  2463. itemID: 8,
  2464. itemAID: 24,
  2465. }, {
  2466. age: 9,
  2467. group: this.groups[2],
  2468. name: "spinning spikes",
  2469. desc: "damages enemies when they touch them",
  2470. req: ["wood", 30, "stone", 20],
  2471. health: 500,
  2472. dmg: 45,
  2473. turnSpeed: 0.003,
  2474. scale: 52,
  2475. spritePadding: -23,
  2476. holdOffset: 8,
  2477. placeOffset: -5,
  2478. itemID: 9,
  2479. itemAID: 25,
  2480. }, {
  2481. group: this.groups[3],
  2482. name: "windmill",
  2483. desc: "generates gold over time",
  2484. req: ["wood", 50, "stone", 10],
  2485. health: 400,
  2486. pps: 1,
  2487. turnSpeed: 0.0016,
  2488. spritePadding: 25,
  2489. iconLineMult: 12,
  2490. scale: 45,
  2491. holdOffset: 20,
  2492. placeOffset: 5,
  2493. itemID: 10,
  2494. itemAID: 26,
  2495. }, {
  2496. age: 5,
  2497. group: this.groups[3],
  2498. name: "faster windmill",
  2499. desc: "generates more gold over time",
  2500. req: ["wood", 60, "stone", 20],
  2501. health: 500,
  2502. pps: 1.5,
  2503. turnSpeed: 0.0025,
  2504. spritePadding: 25,
  2505. iconLineMult: 12,
  2506. scale: 47,
  2507. holdOffset: 20,
  2508. placeOffset: 5,
  2509. itemID: 11,
  2510. itemAID: 27,
  2511. }, {
  2512. age: 8,
  2513. group: this.groups[3],
  2514. name: "power mill",
  2515. desc: "generates more gold over time",
  2516. req: ["wood", 100, "stone", 50],
  2517. health: 800,
  2518. pps: 2,
  2519. turnSpeed: 0.005,
  2520. spritePadding: 25,
  2521. iconLineMult: 12,
  2522. scale: 47,
  2523. holdOffset: 20,
  2524. placeOffset: 5,
  2525. itemID: 12,
  2526. itemAID: 28,
  2527. }, {
  2528. age: 5,
  2529. group: this.groups[4],
  2530. type: 2,
  2531. name: "mine",
  2532. desc: "allows you to mine stone",
  2533. req: ["wood", 20, "stone", 100],
  2534. iconLineMult: 12,
  2535. scale: 65,
  2536. holdOffset: 20,
  2537. placeOffset: 0,
  2538. itemID: 13,
  2539. itemAID: 29,
  2540. }, {
  2541. age: 5,
  2542. group: this.groups[11],
  2543. type: 0,
  2544. name: "sapling",
  2545. desc: "allows you to farm wood",
  2546. req: ["wood", 150],
  2547. iconLineMult: 12,
  2548. colDiv: 0.5,
  2549. scale: 110,
  2550. holdOffset: 50,
  2551. placeOffset: -15,
  2552. itemID: 14,
  2553. itemAID: 30,
  2554. }, {
  2555. age: 4,
  2556. group: this.groups[5],
  2557. name: "pit trap",
  2558. desc: "pit that traps enemies if they walk over it",
  2559. req: ["wood", 30, "stone", 30],
  2560. trap: true,
  2561. ignoreCollision: true,
  2562. hideFromEnemy: true,
  2563. health: 500,
  2564. colDiv: 0.2,
  2565. scale: 50,
  2566. holdOffset: 20,
  2567. placeOffset: -5,
  2568. alpha: 0.6,
  2569. itemID: 15,
  2570. itemAID: 31,
  2571. }, {
  2572. age: 4,
  2573. group: this.groups[6],
  2574. name: "boost pad",
  2575. desc: "provides boost when stepped on",
  2576. req: ["stone", 20, "wood", 5],
  2577. ignoreCollision: true,
  2578. boostSpeed: 1.5,
  2579. health: 150,
  2580. colDiv: 0.7,
  2581. scale: 45,
  2582. holdOffset: 20,
  2583. placeOffset: -5,
  2584. itemID: 16,
  2585. itemAID: 32,
  2586. }, {
  2587. age: 7,
  2588. group: this.groups[7],
  2589. doUpdate: true,
  2590. name: "turret",
  2591. desc: "defensive structure that shoots at enemies",
  2592. req: ["wood", 200, "stone", 150],
  2593. health: 800,
  2594. projectile: 1,
  2595. shootRange: 700,
  2596. shootRate: 2200,
  2597. scale: 43,
  2598. holdOffset: 20,
  2599. placeOffset: -5,
  2600. itemID: 17,
  2601. itemAID: 33,
  2602. }, {
  2603. age: 7,
  2604. group: this.groups[8],
  2605. name: "platform",
  2606. desc: "platform to shoot over walls and cross over water",
  2607. req: ["wood", 20],
  2608. ignoreCollision: true,
  2609. zIndex: 1,
  2610. health: 300,
  2611. scale: 43,
  2612. holdOffset: 20,
  2613. placeOffset: -5,
  2614. itemID: 18,
  2615. itemAID: 34,
  2616. }, {
  2617. age: 7,
  2618. group: this.groups[9],
  2619. name: "healing pad",
  2620. desc: "standing on it will slowly heal you",
  2621. req: ["wood", 30, "food", 10],
  2622. ignoreCollision: true,
  2623. healCol: 15,
  2624. health: 400,
  2625. colDiv: 0.7,
  2626. scale: 45,
  2627. holdOffset: 20,
  2628. placeOffset: -5,
  2629. itemID: 19,
  2630. itemAID: 35,
  2631. }, {
  2632. age: 9,
  2633. group: this.groups[10],
  2634. name: "spawn pad",
  2635. desc: "you will spawn here when you die but it will dissapear",
  2636. req: ["wood", 100, "stone", 100],
  2637. health: 400,
  2638. ignoreCollision: true,
  2639. spawnPoint: true,
  2640. scale: 45,
  2641. holdOffset: 20,
  2642. placeOffset: -5,
  2643. itemID: 20,
  2644. itemAID: 36,
  2645. }, {
  2646. age: 7,
  2647. group: this.groups[12],
  2648. name: "blocker",
  2649. desc: "blocks building in radius",
  2650. req: ["wood", 30, "stone", 25],
  2651. ignoreCollision: true,
  2652. blocker: 300,
  2653. health: 400,
  2654. colDiv: 0.7,
  2655. scale: 45,
  2656. holdOffset: 20,
  2657. placeOffset: -5,
  2658. itemID: 21,
  2659. itemAID: 37,
  2660. }, {
  2661. age: 7,
  2662. group: this.groups[13],
  2663. name: "teleporter",
  2664. desc: "teleports you to a random point on the map",
  2665. req: ["wood", 60, "stone", 60],
  2666. ignoreCollision: true,
  2667. teleport: true,
  2668. health: 200,
  2669. colDiv: 0.7,
  2670. scale: 45,
  2671. holdOffset: 20,
  2672. placeOffset: -5,
  2673. itemID: 22,
  2674. itemAID: 38
  2675. }];
  2676.  
  2677. // CHECK ITEM ID:
  2678. this.checkItem = {
  2679. index: function(id, myItems) {
  2680. 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 :
  2681. 5 :
  2682. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2683. 6 :
  2684. undefined;
  2685. }
  2686. }
  2687.  
  2688. // ASSIGN IDS:
  2689. for (let i = 0; i < this.list.length; ++i) {
  2690. this.list[i].id = i;
  2691. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2692. }
  2693.  
  2694. // TROLOLOLOL:
  2695. if (typeof window !== "undefined") {
  2696. function shuffle(a) {
  2697. for (let i = a.length - 1; i > 0; i--) {
  2698. const j = Math.floor(Math.random() * (i + 1));
  2699. [a[i], a[j]] = [a[j], a[i]];
  2700. }
  2701. return a;
  2702. }
  2703. //shuffle(this.list);
  2704. }
  2705. }
  2706. }
  2707.  
  2708. class GameObject {
  2709. constructor(sid) {
  2710. this.sid = sid;
  2711. this.init = function(x, y, dir, scale, type, data, owner) {
  2712. data = data || {};
  2713. this.sentTo = {};
  2714. this.gridLocations = [];
  2715. this.active = true;
  2716. this.alive = true;
  2717. this.doUpdate = data.doUpdate;
  2718. this.x = x;
  2719. this.y = y;
  2720. if (config.anotherVisual) {
  2721. this.dir = dir + Math.PI;
  2722. } else {
  2723. this.dir = dir;
  2724. }
  2725. this.lastDir = dir;
  2726. this.xWiggle = 0;
  2727. this.yWiggle = 0;
  2728. this.visScale = scale;
  2729. this.scale = scale;
  2730. this.type = type;
  2731. this.id = data.id;
  2732. this.owner = owner;
  2733. this.name = data.name;
  2734. this.isItem = (this.id != undefined);
  2735. this.group = data.group;
  2736. this.maxHealth = data.health;
  2737. this.health = this.maxHealth;
  2738. this.healthMov = 100;
  2739. this.layer = 2;
  2740. if (this.group != undefined) {
  2741. this.layer = this.group.layer;
  2742. } else if (this.type == 0) {
  2743. this.layer = 3;
  2744. } else if (this.type == 2) {
  2745. this.layer = 0;
  2746. } else if (this.type == 4) {
  2747. this.layer = -1;
  2748. }
  2749. this.colDiv = data.colDiv || 1;
  2750. this.blocker = data.blocker;
  2751. this.ignoreCollision = data.ignoreCollision;
  2752. this.dontGather = data.dontGather;
  2753. this.hideFromEnemy = data.hideFromEnemy;
  2754. this.friction = data.friction;
  2755. this.projDmg = data.projDmg;
  2756. this.dmg = data.dmg;
  2757. this.pDmg = data.pDmg;
  2758. this.pps = data.pps;
  2759. this.zIndex = data.zIndex || 0;
  2760. this.turnSpeed = data.turnSpeed;
  2761. this.req = data.req;
  2762. this.trap = data.trap;
  2763. this.healCol = data.healCol;
  2764. this.teleport = data.teleport;
  2765. this.boostSpeed = data.boostSpeed;
  2766. this.projectile = data.projectile;
  2767. this.shootRange = data.shootRange;
  2768. this.shootRate = data.shootRate;
  2769. this.shootCount = this.shootRate;
  2770. this.spawnPoint = data.spawnPoint;
  2771. this.onNear = 0;
  2772. this.breakObj = false;
  2773. this.alpha = data.alpha || 1;
  2774. this.maxAlpha = data.alpha || 1;
  2775. this.damaged = 0;
  2776. };
  2777. this.changeHealth = function(amount, doer) {
  2778. this.health += amount;
  2779. return (this.health <= 0);
  2780. };
  2781. this.getScale = function(sM, ig) {
  2782. sM = sM || 1;
  2783. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2784. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2785. };
  2786. this.visibleToPlayer = function(player) {
  2787. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2788. (this.owner.team && player.team == this.owner.team)));
  2789. };
  2790. this.update = function(delta) {
  2791. if (this.health != this.healthMov) {
  2792. this.health < this.healthMov ? (this.healthMov -= 1.9) : (this.healthMov += 1.9);
  2793. if (Math.abs(this.health - this.healthMov) < 1.9) this.healthMov = this.health;
  2794. };
  2795. if (this.active) {
  2796. if (this.xWiggle) {
  2797. this.xWiggle *= Math.pow(0.99, delta);
  2798. }
  2799. if (this.yWiggle) {
  2800. this.yWiggle *= Math.pow(0.99, delta);
  2801. }
  2802.  
  2803. if (!this.dmg) {
  2804. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2805. if (d2 > 0.01) {
  2806. this.dir += d2 / 5;
  2807. } else {
  2808. this.dir = this.lastDir;
  2809. }
  2810. } else {
  2811. if (this.turnSpeed && this.dmg) {
  2812. this.dir += this.turnSpeed * delta;
  2813. }
  2814. }
  2815.  
  2816. } else {
  2817. if (this.alive) {
  2818. this.alpha -= delta / (200 / this.maxAlpha);
  2819. this.visScale += delta / (this.scale / 2.5);
  2820. if (this.alpha <= 0) {
  2821. this.alpha = 0;
  2822. this.alive = false;
  2823. }
  2824. }
  2825. }
  2826. };
  2827. this.isTeamObject = function(tmpObj) {
  2828. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2829. };
  2830. }
  2831. }
  2832. class Objectmanager {
  2833. constructor(GameObject, gameObjects, UTILS, config, players, server) {
  2834. let mathFloor = Math.floor,
  2835. mathABS = Math.abs,
  2836. mathCOS = Math.cos,
  2837. mathSIN = Math.sin,
  2838. mathPOW = Math.pow,
  2839. mathSQRT = Math.sqrt;
  2840. this.ignoreAdd = false;
  2841. this.hitObj = [];
  2842. this.disableObj = function(obj) {
  2843. obj.active = false;
  2844. };
  2845. let tmpObj;
  2846. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2847. tmpObj = findObjectBySid(sid);
  2848. if (!tmpObj) {
  2849. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2850. if (!tmpObj) {
  2851. tmpObj = new GameObject(sid);
  2852. gameObjects.push(tmpObj);
  2853. }
  2854. }
  2855. if (setSID) {
  2856. tmpObj.sid = sid;
  2857. }
  2858. tmpObj.init(x, y, dir, s, type, data, owner);
  2859. };
  2860. this.disableBySid = function(sid) {
  2861. let find = findObjectBySid(sid);
  2862. if (find) {
  2863. this.disableObj(find);
  2864. }
  2865. };
  2866. this.removeAllItems = function(sid, server) {
  2867. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2868. };
  2869. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2870. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  2871. if (cantPlace) return false;
  2872. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2873. return true;
  2874. };
  2875. }
  2876. }
  2877. class Projectile {
  2878. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2879.  
  2880. // INIT:
  2881. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2882. this.active = true;
  2883. this.tickActive = true;
  2884. this.indx = indx;
  2885. this.x = x;
  2886. this.y = y;
  2887. this.x2 = x;
  2888. this.y2 = y;
  2889. this.dir = dir;
  2890. this.skipMov = true;
  2891. this.speed = spd;
  2892. this.dmg = dmg;
  2893. this.scale = scl;
  2894. this.range = rng;
  2895. this.r2 = rng;
  2896. this.owner = owner;
  2897. };
  2898.  
  2899. // UPDATE:
  2900. this.update = function(delta) {
  2901. if (this.active) {
  2902. let tmpSpeed = this.speed * delta;
  2903. if (!this.skipMov) {
  2904. this.x += tmpSpeed * Math.cos(this.dir);
  2905. this.y += tmpSpeed * Math.sin(this.dir);
  2906. this.range -= tmpSpeed;
  2907. if (this.range <= 0) {
  2908. this.x += this.range * Math.cos(this.dir);
  2909. this.y += this.range * Math.sin(this.dir);
  2910. tmpSpeed = 1;
  2911. this.range = 0;
  2912. this.active = false;
  2913. }
  2914. } else {
  2915. this.skipMov = false;
  2916. }
  2917. }
  2918. };
  2919. this.tickUpdate = function(delta) {
  2920. if (this.tickActive) {
  2921. let tmpSpeed = this.speed * delta;
  2922. if (!this.skipMov) {
  2923. this.x2 += tmpSpeed * Math.cos(this.dir);
  2924. this.y2 += tmpSpeed * Math.sin(this.dir);
  2925. this.r2 -= tmpSpeed;
  2926. if (this.r2 <= 0) {
  2927. this.x2 += this.r2 * Math.cos(this.dir);
  2928. this.y2 += this.r2 * Math.sin(this.dir);
  2929. tmpSpeed = 1;
  2930. this.r2 = 0;
  2931. this.tickActive = false;
  2932. }
  2933. } else {
  2934. this.skipMov = false;
  2935. }
  2936. }
  2937. };
  2938. }
  2939. };
  2940. class Store {
  2941. constructor() {
  2942. // STORE HATS:
  2943. this.hats = [{
  2944. id: 45,
  2945. name: "Shame!",
  2946. dontSell: true,
  2947. price: 0,
  2948. scale: 120,
  2949. desc: "hacks are for winners"
  2950. }, {
  2951. id: 51,
  2952. name: "Moo Cap",
  2953. price: 0,
  2954. scale: 120,
  2955. desc: "coolest mooer around"
  2956. }, {
  2957. id: 50,
  2958. name: "Apple Cap",
  2959. price: 0,
  2960. scale: 120,
  2961. desc: "apple farms remembers"
  2962. }, {
  2963. id: 28,
  2964. name: "Moo Head",
  2965. price: 0,
  2966. scale: 120,
  2967. desc: "no effect"
  2968. }, {
  2969. id: 29,
  2970. name: "Pig Head",
  2971. price: 0,
  2972. scale: 120,
  2973. desc: "no effect"
  2974. }, {
  2975. id: 30,
  2976. name: "Fluff Head",
  2977. price: 0,
  2978. scale: 120,
  2979. desc: "no effect"
  2980. }, {
  2981. id: 36,
  2982. name: "Pandou Head",
  2983. price: 0,
  2984. scale: 120,
  2985. desc: "no effect"
  2986. }, {
  2987. id: 37,
  2988. name: "Bear Head",
  2989. price: 0,
  2990. scale: 120,
  2991. desc: "no effect"
  2992. }, {
  2993. id: 38,
  2994. name: "Monkey Head",
  2995. price: 0,
  2996. scale: 120,
  2997. desc: "no effect"
  2998. }, {
  2999. id: 44,
  3000. name: "Polar Head",
  3001. price: 0,
  3002. scale: 120,
  3003. desc: "no effect"
  3004. }, {
  3005. id: 35,
  3006. name: "Fez Hat",
  3007. price: 0,
  3008. scale: 120,
  3009. desc: "no effect"
  3010. }, {
  3011. id: 42,
  3012. name: "Enigma Hat",
  3013. price: 0,
  3014. scale: 120,
  3015. desc: "join the enigma army"
  3016. }, {
  3017. id: 43,
  3018. name: "Blitz Hat",
  3019. price: 0,
  3020. scale: 120,
  3021. desc: "hey everybody i'm blitz"
  3022. }, {
  3023. id: 49,
  3024. name: "Bob XIII Hat",
  3025. price: 0,
  3026. scale: 120,
  3027. desc: "like and subscribe"
  3028. }, {
  3029. id: 57,
  3030. name: "Pumpkin",
  3031. price: 50,
  3032. scale: 120,
  3033. desc: "Spooooky"
  3034. }, {
  3035. id: 8,
  3036. name: "Bummle Hat",
  3037. price: 100,
  3038. scale: 120,
  3039. desc: "no effect"
  3040. }, {
  3041. id: 2,
  3042. name: "Straw Hat",
  3043. price: 500,
  3044. scale: 120,
  3045. desc: "no effect"
  3046. }, {
  3047. id: 15,
  3048. name: "Winter Cap",
  3049. price: 600,
  3050. scale: 120,
  3051. desc: "allows you to move at normal speed in snow",
  3052. coldM: 1
  3053. }, {
  3054. id: 5,
  3055. name: "Cowboy Hat",
  3056. price: 1000,
  3057. scale: 120,
  3058. desc: "no effect"
  3059. }, {
  3060. id: 4,
  3061. name: "Ranger Hat",
  3062. price: 2000,
  3063. scale: 120,
  3064. desc: "no effect"
  3065. }, {
  3066. id: 18,
  3067. name: "Explorer Hat",
  3068. price: 2000,
  3069. scale: 120,
  3070. desc: "no effect"
  3071. }, {
  3072. id: 31,
  3073. name: "Flipper Hat",
  3074. price: 2500,
  3075. scale: 120,
  3076. desc: "have more control while in water",
  3077. watrImm: true
  3078. }, {
  3079. id: 1,
  3080. name: "Marksman Cap",
  3081. price: 3000,
  3082. scale: 120,
  3083. desc: "increases arrow speed and range",
  3084. aMlt: 1.3
  3085. }, {
  3086. id: 10,
  3087. name: "Bush Gear",
  3088. price: 3000,
  3089. scale: 160,
  3090. desc: "allows you to disguise yourself as a bush"
  3091. }, {
  3092. id: 48,
  3093. name: "Halo",
  3094. price: 3000,
  3095. scale: 120,
  3096. desc: "no effect"
  3097. }, {
  3098. id: 6,
  3099. name: "Soldier Helmet",
  3100. price: 4000,
  3101. scale: 120,
  3102. desc: "reduces damage taken but slows movement",
  3103. spdMult: 0.94,
  3104. dmgMult: 0.75
  3105. }, {
  3106. id: 23,
  3107. name: "Anti Venom Gear",
  3108. price: 4000,
  3109. scale: 120,
  3110. desc: "makes you immune to poison",
  3111. poisonRes: 1
  3112. }, {
  3113. id: 13,
  3114. name: "Medic Gear",
  3115. price: 5000,
  3116. scale: 110,
  3117. desc: "slowly regenerates health over time",
  3118. healthRegen: 3
  3119. }, {
  3120. id: 9,
  3121. name: "Miners Helmet",
  3122. price: 5000,
  3123. scale: 120,
  3124. desc: "earn 1 extra gold per resource",
  3125. extraGold: 1
  3126. }, {
  3127. id: 32,
  3128. name: "Musketeer Hat",
  3129. price: 5000,
  3130. scale: 120,
  3131. desc: "reduces cost of projectiles",
  3132. projCost: 0.5
  3133. }, {
  3134. id: 7,
  3135. name: "Bull Helmet",
  3136. price: 6000,
  3137. scale: 120,
  3138. desc: "increases damage done but drains health",
  3139. healthRegen: -5,
  3140. dmgMultO: 1.5,
  3141. spdMult: 0.96
  3142. }, {
  3143. id: 22,
  3144. name: "Emp Helmet",
  3145. price: 6000,
  3146. scale: 120,
  3147. desc: "turrets won't attack but you move slower",
  3148. antiTurret: 1,
  3149. spdMult: 0.7
  3150. }, {
  3151. id: 12,
  3152. name: "Booster Hat",
  3153. price: 6000,
  3154. scale: 120,
  3155. desc: "increases your movement speed",
  3156. spdMult: 1.16
  3157. }, {
  3158. id: 26,
  3159. name: "Barbarian Armor",
  3160. price: 8000,
  3161. scale: 120,
  3162. desc: "knocks back enemies that attack you",
  3163. dmgK: 0.6
  3164. }, {
  3165. id: 21,
  3166. name: "Plague Mask",
  3167. price: 10000,
  3168. scale: 120,
  3169. desc: "melee attacks deal poison damage",
  3170. poisonDmg: 5,
  3171. poisonTime: 6
  3172. }, {
  3173. id: 46,
  3174. name: "Bull Mask",
  3175. price: 10000,
  3176. scale: 120,
  3177. desc: "bulls won't target you unless you attack them",
  3178. bullRepel: 1
  3179. }, {
  3180. id: 14,
  3181. name: "Windmill Hat",
  3182. topSprite: true,
  3183. price: 10000,
  3184. scale: 120,
  3185. desc: "generates points while worn",
  3186. pps: 1.5
  3187. }, {
  3188. id: 11,
  3189. name: "Spike Gear",
  3190. topSprite: true,
  3191. price: 10000,
  3192. scale: 120,
  3193. desc: "deal damage to players that damage you",
  3194. dmg: 0.45
  3195. }, {
  3196. id: 53,
  3197. name: "Turret Gear",
  3198. topSprite: true,
  3199. price: 10000,
  3200. scale: 120,
  3201. desc: "you become a walking turret",
  3202. turret: {
  3203. proj: 1,
  3204. range: 700,
  3205. rate: 2500
  3206. },
  3207. spdMult: 0.7
  3208. }, {
  3209. id: 20,
  3210. name: "Samurai Armor",
  3211. price: 12000,
  3212. scale: 120,
  3213. desc: "increased attack speed and fire rate",
  3214. atkSpd: 0.78
  3215. }, {
  3216. id: 58,
  3217. name: "Dark Knight",
  3218. price: 12000,
  3219. scale: 120,
  3220. desc: "restores health when you deal damage",
  3221. healD: 0.4
  3222. }, {
  3223. id: 27,
  3224. name: "Scavenger Gear",
  3225. price: 15000,
  3226. scale: 120,
  3227. desc: "earn double points for each kill",
  3228. kScrM: 2
  3229. }, {
  3230. id: 40,
  3231. name: "Tank Gear",
  3232. price: 15000,
  3233. scale: 120,
  3234. desc: "increased damage to buildings but slower movement",
  3235. spdMult: 0.3,
  3236. bDmg: 3.3
  3237. }, {
  3238. id: 52,
  3239. name: "Thief Gear",
  3240. price: 15000,
  3241. scale: 120,
  3242. desc: "steal half of a players gold when you kill them",
  3243. goldSteal: 0.5
  3244. }, {
  3245. id: 55,
  3246. name: "Bloodthirster",
  3247. price: 20000,
  3248. scale: 120,
  3249. desc: "Restore Health when dealing damage. And increased damage",
  3250. healD: 0.25,
  3251. dmgMultO: 1.2,
  3252. }, {
  3253. id: 56,
  3254. name: "Assassin Gear",
  3255. price: 20000,
  3256. scale: 120,
  3257. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3258. noEat: true,
  3259. spdMult: 1.1,
  3260. invisTimer: 1000
  3261. }];
  3262.  
  3263. // STORE ACCESSORIES:
  3264. this.accessories = [{
  3265. id: 12,
  3266. name: "Snowball",
  3267. price: 1000,
  3268. scale: 105,
  3269. xOff: 18,
  3270. desc: "no effect"
  3271. }, {
  3272. id: 9,
  3273. name: "Tree Cape",
  3274. price: 1000,
  3275. scale: 90,
  3276. desc: "no effect"
  3277. }, {
  3278. id: 10,
  3279. name: "Stone Cape",
  3280. price: 1000,
  3281. scale: 90,
  3282. desc: "no effect"
  3283. }, {
  3284. id: 3,
  3285. name: "Cookie Cape",
  3286. price: 1500,
  3287. scale: 90,
  3288. desc: "no effect"
  3289. }, {
  3290. id: 8,
  3291. name: "Cow Cape",
  3292. price: 2000,
  3293. scale: 90,
  3294. desc: "no effect"
  3295. }, {
  3296. id: 11,
  3297. name: "Monkey Tail",
  3298. price: 2000,
  3299. scale: 97,
  3300. xOff: 25,
  3301. desc: "Super speed but reduced damage",
  3302. spdMult: 1.35,
  3303. dmgMultO: 0.2
  3304. }, {
  3305. id: 17,
  3306. name: "Apple Basket",
  3307. price: 3000,
  3308. scale: 80,
  3309. xOff: 12,
  3310. desc: "slowly regenerates health over time",
  3311. healthRegen: 1
  3312. }, {
  3313. id: 6,
  3314. name: "Winter Cape",
  3315. price: 3000,
  3316. scale: 90,
  3317. desc: "no effect"
  3318. }, {
  3319. id: 4,
  3320. name: "Skull Cape",
  3321. price: 4000,
  3322. scale: 90,
  3323. desc: "no effect"
  3324. }, {
  3325. id: 5,
  3326. name: "Dash Cape",
  3327. price: 5000,
  3328. scale: 90,
  3329. desc: "no effect"
  3330. }, {
  3331. id: 2,
  3332. name: "Dragon Cape",
  3333. price: 6000,
  3334. scale: 90,
  3335. desc: "no effect"
  3336. }, {
  3337. id: 1,
  3338. name: "Super Cape",
  3339. price: 8000,
  3340. scale: 90,
  3341. desc: "no effect"
  3342. }, {
  3343. id: 7,
  3344. name: "Troll Cape",
  3345. price: 8000,
  3346. scale: 90,
  3347. desc: "no effect"
  3348. }, {
  3349. id: 14,
  3350. name: "Thorns",
  3351. price: 10000,
  3352. scale: 115,
  3353. xOff: 20,
  3354. desc: "no effect"
  3355. }, {
  3356. id: 15,
  3357. name: "Blockades",
  3358. price: 10000,
  3359. scale: 95,
  3360. xOff: 15,
  3361. desc: "no effect"
  3362. }, {
  3363. id: 20,
  3364. name: "Devils Tail",
  3365. price: 10000,
  3366. scale: 95,
  3367. xOff: 20,
  3368. desc: "no effect"
  3369. }, {
  3370. id: 16,
  3371. name: "Sawblade",
  3372. price: 12000,
  3373. scale: 90,
  3374. spin: true,
  3375. xOff: 0,
  3376. desc: "deal damage to players that damage you",
  3377. dmg: 0.15
  3378. }, {
  3379. id: 13,
  3380. name: "Angel Wings",
  3381. price: 15000,
  3382. scale: 138,
  3383. xOff: 22,
  3384. desc: "slowly regenerates health over time",
  3385. healthRegen: 3
  3386. }, {
  3387. id: 19,
  3388. name: "Shadow Wings",
  3389. price: 15000,
  3390. scale: 138,
  3391. xOff: 22,
  3392. desc: "increased movement speed",
  3393. spdMult: 1.1
  3394. }, {
  3395. id: 18,
  3396. name: "Blood Wings",
  3397. price: 20000,
  3398. scale: 178,
  3399. xOff: 26,
  3400. desc: "restores health when you deal damage",
  3401. healD: 0.2
  3402. }, {
  3403. id: 21,
  3404. name: "Corrupt X Wings",
  3405. price: 20000,
  3406. scale: 178,
  3407. xOff: 26,
  3408. desc: "deal damage to players that damage you",
  3409. dmg: 0.25
  3410. }];
  3411. }
  3412. };
  3413. class ProjectileManager {
  3414. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3415. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3416. let tmpData = items.projectiles[indx];
  3417. let tmpProj;
  3418. for (let i = 0; i < projectiles.length; ++i) {
  3419. if (!projectiles[i].active) {
  3420. tmpProj = projectiles[i];
  3421. break;
  3422. }
  3423. }
  3424. if (!tmpProj) {
  3425. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3426. tmpProj.sid = projectiles.length;
  3427. projectiles.push(tmpProj);
  3428. }
  3429. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3430. tmpProj.ignoreObj = ignoreObj;
  3431. tmpProj.layer = layer || tmpData.layer;
  3432. tmpProj.inWindow = inWindow;
  3433. tmpProj.src = tmpData.src;
  3434. return tmpProj;
  3435. };
  3436. }
  3437. };
  3438. class AiManager {
  3439.  
  3440. // AI MANAGER:
  3441. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3442.  
  3443. // AI TYPES:
  3444. this.aiTypes = [{
  3445. id: 0,
  3446. src: "cow_1",
  3447. killScore: 150,
  3448. health: 500,
  3449. weightM: 0.8,
  3450. speed: 0.00095,
  3451. turnSpeed: 0.001,
  3452. scale: 72,
  3453. drop: ["food", 50]
  3454. }, {
  3455. id: 1,
  3456. src: "pig_1",
  3457. killScore: 200,
  3458. health: 800,
  3459. weightM: 0.6,
  3460. speed: 0.00085,
  3461. turnSpeed: 0.001,
  3462. scale: 72,
  3463. drop: ["food", 80]
  3464. }, {
  3465. id: 2,
  3466. name: "Bull",
  3467. src: "bull_2",
  3468. hostile: true,
  3469. dmg: 20,
  3470. killScore: 1000,
  3471. health: 1800,
  3472. weightM: 0.5,
  3473. speed: 0.00094,
  3474. turnSpeed: 0.00074,
  3475. scale: 78,
  3476. viewRange: 800,
  3477. chargePlayer: true,
  3478. drop: ["food", 100]
  3479. }, {
  3480. id: 3,
  3481. name: "Bully",
  3482. src: "bull_1",
  3483. hostile: true,
  3484. dmg: 20,
  3485. killScore: 2000,
  3486. health: 2800,
  3487. weightM: 0.45,
  3488. speed: 0.001,
  3489. turnSpeed: 0.0008,
  3490. scale: 90,
  3491. viewRange: 900,
  3492. chargePlayer: true,
  3493. drop: ["food", 400]
  3494. }, {
  3495. id: 4,
  3496. name: "Wolf",
  3497. src: "wolf_1",
  3498. hostile: true,
  3499. dmg: 8,
  3500. killScore: 500,
  3501. health: 300,
  3502. weightM: 0.45,
  3503. speed: 0.001,
  3504. turnSpeed: 0.002,
  3505. scale: 84,
  3506. viewRange: 800,
  3507. chargePlayer: true,
  3508. drop: ["food", 200]
  3509. }, {
  3510. id: 5,
  3511. name: "Quack",
  3512. src: "chicken_1",
  3513. dmg: 8,
  3514. killScore: 2000,
  3515. noTrap: true,
  3516. health: 300,
  3517. weightM: 0.2,
  3518. speed: 0.0018,
  3519. turnSpeed: 0.006,
  3520. scale: 70,
  3521. drop: ["food", 100]
  3522. }, {
  3523. id: 6,
  3524. name: "MOOSTAFA",
  3525. nameScale: 50,
  3526. src: "enemy",
  3527. hostile: true,
  3528. dontRun: true,
  3529. fixedSpawn: true,
  3530. spawnDelay: 60000,
  3531. noTrap: true,
  3532. colDmg: 100,
  3533. dmg: 40,
  3534. killScore: 8000,
  3535. health: 18000,
  3536. weightM: 0.4,
  3537. speed: 0.0007,
  3538. turnSpeed: 0.01,
  3539. scale: 80,
  3540. spriteMlt: 1.8,
  3541. leapForce: 0.9,
  3542. viewRange: 1000,
  3543. hitRange: 210,
  3544. hitDelay: 1000,
  3545. chargePlayer: true,
  3546. drop: ["food", 100]
  3547. }, {
  3548. id: 7,
  3549. name: "Treasure",
  3550. hostile: true,
  3551. nameScale: 35,
  3552. src: "crate_1",
  3553. fixedSpawn: true,
  3554. spawnDelay: 120000,
  3555. colDmg: 200,
  3556. killScore: 5000,
  3557. health: 20000,
  3558. weightM: 0.1,
  3559. speed: 0.0,
  3560. turnSpeed: 0.0,
  3561. scale: 70,
  3562. spriteMlt: 1.0
  3563. }, {
  3564. id: 8,
  3565. name: "MOOFIE",
  3566. src: "wolf_2",
  3567. hostile: true,
  3568. fixedSpawn: true,
  3569. dontRun: true,
  3570. hitScare: 4,
  3571. spawnDelay: 30000,
  3572. noTrap: true,
  3573. nameScale: 35,
  3574. dmg: 10,
  3575. colDmg: 100,
  3576. killScore: 3000,
  3577. health: 7000,
  3578. weightM: 0.45,
  3579. speed: 0.0015,
  3580. turnSpeed: 0.002,
  3581. scale: 90,
  3582. viewRange: 800,
  3583. chargePlayer: true,
  3584. drop: ["food", 1000]
  3585. }];
  3586.  
  3587. // SPAWN AI:
  3588. this.spawn = function(x, y, dir, index) {
  3589. let tmpObj = ais.find((tmp) => !tmp.active);
  3590. if (!tmpObj) {
  3591. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3592. ais.push(tmpObj);
  3593. }
  3594. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3595. return tmpObj;
  3596. };
  3597. }
  3598.  
  3599. };
  3600. class AI {
  3601. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3602. this.sid = sid;
  3603. this.isAI = true;
  3604. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3605.  
  3606. // INIT:
  3607. this.init = function(x, y, dir, index, data) {
  3608. this.x = x;
  3609. this.y = y;
  3610. this.startX = data.fixedSpawn ? x : null;
  3611. this.startY = data.fixedSpawn ? y : null;
  3612. this.xVel = 0;
  3613. this.yVel = 0;
  3614. this.zIndex = 0;
  3615. this.dir = dir;
  3616. this.dirPlus = 0;
  3617. this.showName = 'aaa';
  3618. this.index = index;
  3619. this.src = data.src;
  3620. if (data.name) this.name = data.name;
  3621. this.weightM = data.weightM;
  3622. this.speed = data.speed;
  3623. this.killScore = data.killScore;
  3624. this.turnSpeed = data.turnSpeed;
  3625. this.scale = data.scale;
  3626. this.maxHealth = data.health;
  3627. this.leapForce = data.leapForce;
  3628. this.health = this.maxHealth;
  3629. this.chargePlayer = data.chargePlayer;
  3630. this.viewRange = data.viewRange;
  3631. this.drop = data.drop;
  3632. this.dmg = data.dmg;
  3633. this.hostile = data.hostile;
  3634. this.dontRun = data.dontRun;
  3635. this.hitRange = data.hitRange;
  3636. this.hitDelay = data.hitDelay;
  3637. this.hitScare = data.hitScare;
  3638. this.spriteMlt = data.spriteMlt;
  3639. this.nameScale = data.nameScale;
  3640. this.colDmg = data.colDmg;
  3641. this.noTrap = data.noTrap;
  3642. this.spawnDelay = data.spawnDelay;
  3643. this.hitWait = 0;
  3644. this.waitCount = 1000;
  3645. this.moveCount = 0;
  3646. this.targetDir = 0;
  3647. this.active = true;
  3648. this.alive = true;
  3649. this.runFrom = null;
  3650. this.chargeTarget = null;
  3651. this.dmgOverTime = {};
  3652. };
  3653.  
  3654. let tmpRatio = 0;
  3655. let animIndex = 0;
  3656. this.animate = function(delta) {
  3657. if (this.animTime > 0) {
  3658. this.animTime -= delta;
  3659. if (this.animTime <= 0) {
  3660. this.animTime = 0;
  3661. this.dirPlus = 0;
  3662. tmpRatio = 0;
  3663. animIndex = 0;
  3664. } else {
  3665. if (animIndex == 0) {
  3666. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3667. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3668. if (tmpRatio >= 1) {
  3669. tmpRatio = 1;
  3670. animIndex = 1;
  3671. }
  3672. } else {
  3673. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3674. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3675. }
  3676. }
  3677. }
  3678. };
  3679.  
  3680. // ANIMATION:
  3681. this.startAnim = function() {
  3682. this.animTime = this.animSpeed = 600;
  3683. this.targetAngle = Math.PI * 0.8;
  3684. tmpRatio = 0;
  3685. animIndex = 0;
  3686. };
  3687.  
  3688. };
  3689.  
  3690. };
  3691. class addCh {
  3692. constructor(x, y, chat, tmpObj) {
  3693. this.x = x;
  3694. this.y = y;
  3695. this.alpha = 0;
  3696. this.active = true;
  3697. this.alive = false;
  3698. this.chat = chat;
  3699. this.owner = tmpObj;
  3700. };
  3701. };
  3702. class DeadPlayer {
  3703. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3704. this.x = x;
  3705. this.y = y;
  3706. this.lastDir = dir;
  3707. this.dir = dir + Math.PI;
  3708. this.buildIndex = buildIndex;
  3709. this.weaponIndex = weaponIndex;
  3710. this.weaponVariant = weaponVariant;
  3711. this.skinColor = skinColor;
  3712. this.scale = scale;
  3713. this.visScale = 0;
  3714. this.name = name;
  3715. this.alpha = 1;
  3716. this.active = true;
  3717. this.animate = function(delta) {
  3718. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3719. if (d2 > 0.01) {
  3720. this.dir += d2 / 20;
  3721. } else {
  3722. this.dir = this.lastDir;
  3723. }
  3724. if (this.visScale < this.scale) {
  3725. this.visScale += delta / (this.scale / 2);
  3726. if (this.visScale >= this.scale) {
  3727. this.visScale = this.scale;
  3728. }
  3729. }
  3730. this.alpha -= delta / 30000;
  3731. if (this.alpha <= 0) {
  3732. this.alpha = 0;
  3733. this.active = false;
  3734. }
  3735. }
  3736. }
  3737. };
  3738. class Player {
  3739. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3740. this.id = id;
  3741. this.sid = sid;
  3742. this.tmpScore = 0;
  3743. this.team = null;
  3744. this.latestSkin = 0;
  3745. this.oldSkinIndex = 0;
  3746. this.skinIndex = 0;
  3747. this.latestTail = 0;
  3748. this.oldTailIndex = 0;
  3749. this.tailIndex = 0;
  3750. this.hitTime = 0;
  3751. this.lastHit = 0;
  3752. this.showName = 'NOOO';
  3753. this.tails = {};
  3754. for (let i = 0; i < accessories.length; ++i) {
  3755. if (accessories[i].price <= 0)
  3756. this.tails[accessories[i].id] = 1;
  3757. }
  3758. this.skins = {};
  3759. for (let i = 0; i < hats.length; ++i) {
  3760. if (hats[i].price <= 0)
  3761. this.skins[hats[i].id] = 1;
  3762. }
  3763. this.points = 0;
  3764. this.dt = 0;
  3765. this.hidden = false;
  3766. this.itemCounts = {};
  3767. this.isPlayer = true;
  3768. this.pps = 0;
  3769. this.moveDir = undefined;
  3770. this.skinRot = 0;
  3771. this.lastPing = 0;
  3772. this.iconIndex = 0;
  3773. this.skinColor = 0;
  3774. this.dist2 = 0;
  3775. this.aim2 = 0;
  3776. this.maxSpeed = 1;
  3777. this.chat = {
  3778. message: null,
  3779. count: 0
  3780. };
  3781. this.circle = false;
  3782. this.cAngle = 0;
  3783. // SPAWN:
  3784. this.spawn = function(moofoll) {
  3785. this.attacked = false;
  3786. this.timeDamaged = 0;
  3787. this.timeHealed = 0;
  3788. this.pinge = 0;
  3789. this.millPlace = 'NOOO';
  3790. this.lastshamecount = 0;
  3791. this.death = false;
  3792. this.spinDir = 0;
  3793. this.sync = false;
  3794. this.antiBull = 0;
  3795. this.bullTimer = 0;
  3796. this.poisonTimer = 0;
  3797. this.active = true;
  3798. this.alive = true;
  3799. this.lockMove = false;
  3800. this.lockDir = false;
  3801. this.minimapCounter = 0;
  3802. this.chatCountdown = 0;
  3803. this.shameCount = 0;
  3804. this.shameTimer = 0;
  3805. this.sentTo = {};
  3806. this.gathering = 0;
  3807. this.gatherIndex = 0;
  3808. this.shooting = {};
  3809. this.shootIndex = 9;
  3810. this.autoGather = 0;
  3811. this.animTime = 0;
  3812. this.animSpeed = 0;
  3813. this.mouseState = 0;
  3814. this.buildIndex = -1;
  3815. this.weaponIndex = 0;
  3816. this.weaponCode = 0;
  3817. this.weaponVariant = 0;
  3818. this.primaryIndex = undefined;
  3819. this.secondaryIndex = undefined;
  3820. this.dmgOverTime = {};
  3821. this.noMovTimer = 0;
  3822. this.maxXP = 300;
  3823. this.XP = 0;
  3824. this.age = 1;
  3825. this.kills = 0;
  3826. this.upgrAge = 2;
  3827. this.upgradePoints = 0;
  3828. this.x = 0;
  3829. this.y = 0;
  3830. this.oldXY = {
  3831. x: 0,
  3832. y: 0
  3833. };
  3834. this.zIndex = 0;
  3835. this.xVel = 0;
  3836. this.yVel = 0;
  3837. this.slowMult = 1;
  3838. this.dir = 0;
  3839. this.dirPlus = 0;
  3840. this.targetDir = 0;
  3841. this.targetAngle = 0;
  3842. this.maxHealth = 100;
  3843. this.health = this.maxHealth;
  3844. this.oldHealth = this.maxHealth;
  3845. this.damaged = 0;
  3846. this.scale = config.playerScale;
  3847. this.speed = config.playerSpeed;
  3848. this.resetMoveDir();
  3849. this.resetResources(moofoll);
  3850. this.items = [0, 3, 6, 10];
  3851. this.weapons = [0];
  3852. this.shootCount = 0;
  3853. this.weaponXP = [];
  3854. this.reloads = {
  3855. 0: 0,
  3856. 1: 0,
  3857. 2: 0,
  3858. 3: 0,
  3859. 4: 0,
  3860. 5: 0,
  3861. 6: 0,
  3862. 7: 0,
  3863. 8: 0,
  3864. 9: 0,
  3865. 10: 0,
  3866. 11: 0,
  3867. 12: 0,
  3868. 13: 0,
  3869. 14: 0,
  3870. 15: 0,
  3871. 53: 0,
  3872. };
  3873. this.bowThreat = {
  3874. 9: 0,
  3875. 12: 0,
  3876. 13: 0,
  3877. 15: 0,
  3878. };
  3879. this.damageThreat = 0;
  3880. this.inTrap = false;
  3881. this.canEmpAnti = false;
  3882. this.empAnti = false;
  3883. this.soldierAnti = false;
  3884. this.poisonTick = 0;
  3885. this.bullTick = 0;
  3886. this.setPoisonTick = false;
  3887. this.setBullTick = false;
  3888. this.antiTimer = 2;
  3889. };
  3890.  
  3891. // RESET MOVE DIR:
  3892. this.resetMoveDir = function() {
  3893. this.moveDir = undefined;
  3894. };
  3895.  
  3896. // RESET RESOURCES:
  3897. this.resetResources = function(moofoll) {
  3898. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3899. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3900. }
  3901. };
  3902.  
  3903. // ADD ITEM:
  3904. this.getItemType = function(id) {
  3905. let findindx = this.items.findIndex((ids) => ids == id);
  3906. if (findindx != -1) {
  3907. return findindx;
  3908. } else {
  3909. return items.checkItem.index(id, this.items);
  3910. }
  3911. };
  3912.  
  3913. // SET DATA:
  3914. this.setData = function(data) {
  3915. this.id = data[0];
  3916. this.sid = data[1];
  3917. this.name = data[2];
  3918. this.x = data[3];
  3919. this.y = data[4];
  3920. this.dir = data[5];
  3921. this.health = data[6];
  3922. this.maxHealth = data[7];
  3923. this.scale = data[8];
  3924. this.skinColor = data[9];
  3925. };
  3926.  
  3927. // UPDATE POISON TICK:
  3928. this.updateTimer = function() {
  3929.  
  3930. this.bullTimer -= 1;
  3931. if (this.bullTimer <= 0) {
  3932. this.setBullTick = false;
  3933. this.bullTick = game.tick - 1;
  3934. this.bullTimer = config.serverUpdateRate;
  3935. }
  3936. this.poisonTimer -= 1;
  3937. if (this.poisonTimer <= 0) {
  3938. this.setPoisonTick = false;
  3939. this.poisonTick = game.tick - 1;
  3940. this.poisonTimer = config.serverUpdateRate;
  3941. }
  3942.  
  3943. };
  3944. this.update = function(delta) {
  3945. if (this.active) {
  3946.  
  3947. // MOVE:
  3948. let gear = {
  3949. skin: findID(hats, this.skinIndex),
  3950. tail: findID(accessories, this.tailIndex)
  3951. }
  3952. 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;
  3953. this.maxSpeed = spdMult;
  3954.  
  3955. }
  3956. };
  3957.  
  3958. let tmpRatio = 0;
  3959. let animIndex = 0;
  3960. this.animate = function(delta) {
  3961. if (this.animTime > 0) {
  3962. this.animTime -= delta;
  3963. if (this.animTime <= 0) {
  3964. this.animTime = 0;
  3965. this.dirPlus = 0;
  3966. tmpRatio = 0;
  3967. animIndex = 0;
  3968. } else {
  3969. if (animIndex == 0) {
  3970. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3971. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3972. if (tmpRatio >= 1) {
  3973. tmpRatio = 1;
  3974. animIndex = 1;
  3975. }
  3976. } else {
  3977. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3978. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3979. }
  3980. }
  3981. }
  3982. };
  3983.  
  3984. // GATHER ANIMATION:
  3985. this.startAnim = function(didHit, index) {
  3986. this.animTime = this.animSpeed = items.weapons[index].speed;
  3987. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3988. tmpRatio = 0;
  3989. animIndex = 0;
  3990. };
  3991.  
  3992. // CAN SEE:
  3993. this.canSee = function(other) {
  3994. if (!other) return false;
  3995. let dx = Math.abs(other.x - this.x) - other.scale;
  3996. let dy = Math.abs(other.y - this.y) - other.scale;
  3997. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3998. };
  3999.  
  4000. // SHAME SYSTEM:
  4001. this.judgeShame = function() {
  4002. if (this.oldHealth < this.health) {
  4003. if (this.hitTime) {
  4004. let timeSinceHit = game.tick - this.hitTime;
  4005. this.lastHit = game.tick;
  4006. this.hitTime = 0;
  4007. if (timeSinceHit < 2) {
  4008. this.shameCount++;
  4009. } else {
  4010. this.shameCount = Math.max(0, this.shameCount - 2);
  4011. }
  4012. }
  4013. } else if (this.oldHealth > this.health) {
  4014. this.hitTime = game.tick;
  4015. }
  4016. };
  4017. this.addShameTimer = function() {
  4018. this.shameCount = 0;
  4019. this.shameTimer = 30;
  4020. let interval = setInterval(() => {
  4021. this.shameTimer--;
  4022. if (this.shameTimer <= 0) {
  4023. clearInterval(interval);
  4024. }
  4025. }, 1000);
  4026. };
  4027.  
  4028. // CHECK TEAM:
  4029. this.isTeam = function(tmpObj) {
  4030. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4031. };
  4032.  
  4033. // FOR THE PLAYER:
  4034. this.findAllianceBySid = function(sid) {
  4035. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4036. };
  4037. this.checkCanInsta = function(nobull) {
  4038. let totally = 0;
  4039. if (this.alive && inGame) {
  4040. let primary = {
  4041. weapon: this.weapons[0],
  4042. variant: this.primaryVariant,
  4043. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4044. };
  4045. let secondary = {
  4046. weapon: this.weapons[1],
  4047. variant: this.secondaryVariant,
  4048. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4049. };
  4050. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4051. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4052. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4053. totally += primary.dmg * pV * bull;
  4054. }
  4055. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4056. totally += secondary.dmg;
  4057. }
  4058. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4059. totally += 25;
  4060. }
  4061. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4062. return totally;
  4063. }
  4064. return 0;
  4065. };
  4066.  
  4067. // UPDATE WEAPON RELOAD:
  4068. this.manageReload = function() {
  4069. if (this.shooting[53]) {
  4070. this.shooting[53] = 0;
  4071. this.reloads[53] = (2500 - game.tickRate);
  4072. } else {
  4073. if (this.reloads[53] > 0) {
  4074. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4075. }
  4076. }
  4077.  
  4078.  
  4079. if (this.gathering || this.shooting[1]) {
  4080. if (this.gathering) {
  4081. this.gathering = 0;
  4082. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4083. this.attacked = true;
  4084. }
  4085. if (this.shooting[1]) {
  4086. this.shooting[1] = 0;
  4087. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4088. this.attacked = true;
  4089. }
  4090. } else {
  4091. this.attacked = false;
  4092. if (this.buildIndex < 0) {
  4093. if (this.reloads[this.weaponIndex] > 0) {
  4094. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4095. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4096. if (this == player) {
  4097. if (getEl("weaponGrind").checked) {
  4098. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4099. checkPlace(player.getItemType(22), i);
  4100. }
  4101. }
  4102. }
  4103. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4104. this.antiBull++;
  4105. game.tickBase(() => {
  4106. this.antiBull = 0;
  4107. }, 1);
  4108. }
  4109. }
  4110. }
  4111. }
  4112. };
  4113.  
  4114. // FOR ANTI INSTA:
  4115. this.addDamageThreat = function(tmpObj) {
  4116. let primary = {
  4117. weapon: this.primaryIndex,
  4118. variant: this.primaryVariant
  4119. };
  4120. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4121. let secondary = {
  4122. weapon: this.secondaryIndex,
  4123. variant: this.secondaryVariant
  4124. };
  4125. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4126. let bull = 1.5;
  4127. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4128. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4129. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4130. this.damageThreat += primary.dmg * pV * bull;
  4131. }
  4132. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4133. this.damageThreat += secondary.dmg * sV;
  4134. }
  4135. if (this.reloads[53] <= game.tickRate) {
  4136. this.damageThreat += 25;
  4137. }
  4138. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4139. if (!this.isTeam(tmpObj)) {
  4140. if (this.dist2 <= 300) {
  4141. tmpObj.damageThreat += this.damageThreat;
  4142. }
  4143. }
  4144. };
  4145.  
  4146. }
  4147. };
  4148.  
  4149. // SOME CODES:
  4150. function sendUpgrade(index) {
  4151. player.reloads[index] = 0;
  4152. packet("H", index);
  4153. }
  4154.  
  4155. function storeEquip(id, index) {
  4156. packet("c", 0, id, index);
  4157. }
  4158.  
  4159. function storeBuy(id, index) {
  4160. packet("c", 1, id, index);
  4161. }
  4162.  
  4163. function buyEquip(id, index) {
  4164. let nID = player.skins[6] ? 6 : 0;
  4165. if (player.alive && inGame) {
  4166. if (index == 0) {
  4167. if (player.skins[id]) {
  4168. if (player.latestSkin != id) {
  4169. packet("c", 0, id, 0);
  4170. }
  4171. } else {
  4172. if (configs.autoBuyEquip) {
  4173. let find = findID(hats, id);
  4174. if (find) {
  4175. if (player.points >= find.price) {
  4176. packet("c", 1, id, 0);
  4177. packet("c", 0, id, 0);
  4178. } else {
  4179. if (player.latestSkin != nID) {
  4180. packet("c", 0, nID, 0);
  4181. }
  4182. }
  4183. } else {
  4184. if (player.latestSkin != nID) {
  4185. packet("c", 0, nID, 0);
  4186. }
  4187. }
  4188. } else {
  4189. if (player.latestSkin != nID) {
  4190. packet("c", 0, nID, 0);
  4191. }
  4192. }
  4193. }
  4194. } else if (index == 1) {
  4195. if (useWasd && (id != 11 && id != 0)) {
  4196. if (player.latestTail != 0) {
  4197. packet("c", 0, 0, 1);
  4198. }
  4199. return;
  4200. }
  4201. if (player.tails[id]) {
  4202. if (player.latestTail != id) {
  4203. packet("c", 0, id, 1);
  4204. }
  4205. } else {
  4206. if (configs.autoBuyEquip) {
  4207. let find = findID(accessories, id);
  4208. if (find) {
  4209. if (player.points >= find.price) {
  4210. packet("c", 1, id, 1);
  4211. packet("c", 0, id, 1);
  4212. } else {
  4213. if (player.latestTail != 0) {
  4214. packet("c", 0, 0, 1);
  4215. }
  4216. }
  4217. } else {
  4218. if (player.latestTail != 0) {
  4219. packet("c", 0, 0, 1);
  4220. }
  4221. }
  4222. } else {
  4223. if (player.latestTail != 0) {
  4224. packet("c", 0, 0, 1);
  4225. }
  4226. }
  4227. }
  4228. }
  4229. }
  4230. }
  4231.  
  4232. function selectToBuild(index, wpn) {
  4233. packet("z", index, wpn);
  4234. }
  4235.  
  4236. function selectWeapon(index, isPlace) {
  4237. if (!isPlace) {
  4238. player.weaponCode = index;
  4239. }
  4240. packet("z", index, 1);
  4241. }
  4242.  
  4243. function sendAutoGather() {
  4244. packet("K", 1, 1);
  4245. }
  4246.  
  4247. function sendAtck(id, angle) {
  4248. packet("F", id, angle, 1);
  4249. }
  4250.  
  4251. // PLACER:
  4252. function place(id, rad, rmd) {
  4253. try {
  4254. if (id == undefined) return;
  4255. let item = items.list[player.items[id]];
  4256. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4257. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4258. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4259. 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))) {
  4260. selectToBuild(player.items[id]);
  4261. sendAtck(1, rad);
  4262. selectWeapon(player.weaponCode, 1);
  4263. if (rmd) {
  4264. placeVisible.push({
  4265. x: tmpX,
  4266. y: tmpY,
  4267. name: item.name,
  4268. scale: item.scale,
  4269. dir: rad
  4270. });
  4271. game.tickBase(() => {
  4272. placeVisible.shift();
  4273. }, 1)
  4274. }
  4275. }
  4276. } catch (e) {}
  4277. }
  4278.  
  4279. function checkPlace(id, rad) {
  4280. try {
  4281. if (id == undefined) return;
  4282. let item = items.list[player.items[id]];
  4283. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4284. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4285. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4286. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4287. place(id, rad);
  4288. }
  4289. } catch (e) {}
  4290. }
  4291. function Aplace(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian) {
  4292. try {
  4293. let item = items.list[player.items[id]];
  4294. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4295. let counts = {
  4296. attempts: 0,
  4297. placed: 0
  4298. };
  4299. let tmpObjects = [];
  4300. gameObjects.forEach((p) => {
  4301. tmpObjects.push({
  4302. x: p.x,
  4303. y: p.y,
  4304. active: p.active,
  4305. blocker: p.blocker,
  4306. scale: p.scale,
  4307. isItem: p.isItem,
  4308. type: p.type,
  4309. colDiv: p.colDiv,
  4310. getScale: function(sM, ig) {
  4311. sM = sM || 1;
  4312. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4313. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4314. },
  4315. });
  4316. });
  4317. for (let i = first; i < repeat; i += plus) {
  4318. counts.attempts++;
  4319. let relAim = radian + i;
  4320. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4321. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4322. 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)));
  4323. if (cantPlace) continue;
  4324. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4325.  
  4326. place(id, relAim, 1);
  4327.  
  4328. tmpObjects.push({
  4329. x: tmpX,
  4330. y: tmpY,
  4331. active: true,
  4332. blocker: item.blocker,
  4333. scale: item.scale,
  4334. isItem: true,
  4335. type: null,
  4336. colDiv: item.colDiv,
  4337. getScale: function() {
  4338. return this.scale;
  4339. },
  4340. });
  4341. }
  4342. } catch (err) {}
  4343. }
  4344. function cplace(id, rad) { // for preplacer indi
  4345. if (id == undefined) return;
  4346. let item = items.list[player.items[id]];
  4347. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4348. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4349. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4350. preIndi.push({
  4351. x: tmpX,
  4352. y: tmpY,
  4353. name: item.name,
  4354. scale: item.scale,
  4355. dir: rad
  4356. });
  4357. game.tickBase(() => {
  4358. preIndi.shift();
  4359. }, 1);
  4360. if (id === 0 || (player.alive && inGame)) {
  4361. selectToBuild(player.items[id]);
  4362. sendAtck(1, rad);
  4363. selectWeapon(player.weaponCode, 1);
  4364.  
  4365. }
  4366. }
  4367.  
  4368. // HEALING:
  4369. function soldierMult() {
  4370. return player.latestSkin == 6 ? 0.75 : 1;
  4371. }
  4372.  
  4373. function healthBased() {
  4374. if (player.health == 100)
  4375. return 0;
  4376. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4377. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4378. }
  4379. return 0;
  4380. }
  4381.  
  4382. function getAttacker(damaged) {
  4383. let attackers = enemy.filter(tmp => {
  4384. //let damages = new Damages(items);
  4385. //let dmg = damages.weapons[tmp.weaponIndex];
  4386. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4387. let rule = {
  4388. //one: tmp.dist2 <= 300,
  4389. //two: by.includes(damaged),
  4390. three: tmp.attacked
  4391. }
  4392. return /*rule.one && rule.two && */ rule.three;
  4393. });
  4394. return attackers;
  4395. }
  4396.  
  4397. function healer() {
  4398. for (let i = 0; i < healthBased(); i++) {
  4399. place(0, getAttackDir());
  4400. }
  4401. }
  4402.  
  4403. function antiSyncHealing(timearg) {
  4404. my.antiSync = true;
  4405. let healAnti = setInterval(() => {
  4406. if (player.shameCount < 5) {
  4407. place(0, getAttackDir());
  4408. }
  4409. }, 75);
  4410. setTimeout(() => {
  4411. clearInterval(healAnti);
  4412. setTimeout(() => {
  4413. my.antiSync = false;
  4414. }, game.tickRate);
  4415. }, game.tickRate);
  4416. }
  4417. function applCxC(value) {
  4418. if (player.health == 100)
  4419. return 0;
  4420. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4421. return Math.ceil(value / items.list[player.items[0]].healing);
  4422. }
  4423. return 0;
  4424. }
  4425. function calcDmg(value) {
  4426. return value * player.skinIndex == 6 ? 0.75 : 1;
  4427. }
  4428. function biomeGear(mover, returns) {
  4429. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4430. if (returns) return 31;
  4431. buyEquip(31, 0);
  4432. } else {
  4433. if (player.y2 <= config.snowBiomeTop) {
  4434. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4435. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4436. } else {
  4437. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4438. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4439. }
  4440. }
  4441. if (returns) return 0;
  4442. }
  4443. let advHeal = [];
  4444. let preIndi = [];
  4445.  
  4446. class Traps {
  4447. constructor(UTILS, items) {
  4448. this.dist = 0;
  4449. this.aim = 0;
  4450. this.inTrap = false;
  4451. this.replaced = false;
  4452. this.antiTrapped = false;
  4453. this.info = {};
  4454. this.notFast = function() {
  4455. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4456. }
  4457. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4458. try {
  4459. let item = items.list[player.items[id]];
  4460. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4461. let counts = {
  4462. attempts: 0,
  4463. placed: 0
  4464. };
  4465. let tmpObjects = [];
  4466. gameObjects.forEach((p) => {
  4467. tmpObjects.push({
  4468. x: p.x,
  4469. y: p.y,
  4470. active: p.active,
  4471. blocker: p.blocker,
  4472. scale: p.scale,
  4473. isItem: p.isItem,
  4474. type: p.type,
  4475. colDiv: p.colDiv,
  4476. getScale: function(sM, ig) {
  4477. sM = sM || 1;
  4478. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4479. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4480. },
  4481. });
  4482. });
  4483. for (let i = first; i < repeat; i += plus) {
  4484. counts.attempts++;
  4485. let relAim = radian + i;
  4486. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4487. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4488. 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)));
  4489. if (cantPlace) continue;
  4490. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4491.  
  4492. checkPlace(id, relAim, 1);
  4493.  
  4494. tmpObjects.push({
  4495. x: tmpX,
  4496. y: tmpY,
  4497. active: true,
  4498. blocker: item.blocker,
  4499. scale: item.scale,
  4500. isItem: true,
  4501. type: null,
  4502. colDiv: item.colDiv,
  4503. getScale: function() {
  4504. return this.scale;
  4505. },
  4506. });
  4507. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4508. counts.placed++;
  4509. }
  4510. }
  4511. if (counts.placed > 0 && replacer && item.dmg) {
  4512. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4513. instaC.canSpikeTick = true;
  4514. }
  4515. }
  4516. } catch (err) {
  4517. }
  4518. };
  4519.  
  4520. this.checkSpikeTick = function() {
  4521. try {
  4522. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4523. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4524. // more range for safe. also testing near.primaryIndex || 5
  4525. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4526. let item = items.list[9];
  4527. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4528. let danger = 0;
  4529. let counts = {
  4530. attempts: 0,
  4531. block: `unblocked`
  4532. };
  4533. for (let i = -1; i <= 1; i += 1 / 10) {
  4534. counts.attempts++;
  4535. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4536. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4537. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4538. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4539. if (cantPlace) continue;
  4540. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4541. danger++;
  4542. counts.block = `blocked`;
  4543. break;
  4544. }
  4545. if (danger) {
  4546. my.anti0Tick = 1;
  4547. return true;
  4548. }
  4549. }
  4550. } catch (err) {
  4551. return null;
  4552. }
  4553. return false;
  4554. }
  4555. this.protect = function(aim) {
  4556. if (!configs.antiTrap || near.dist2 > 500 || !enemy.length) return;
  4557. if (player.items[4]) {
  4558. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4559. this.antiTrapped = true;
  4560. }
  4561. };
  4562.  
  4563.  
  4564. this.autoPlace = function () {
  4565. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4566. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  4567. if (gameObjects.length) {
  4568. let near2 = {
  4569. inTrap: true,
  4570. };
  4571. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function (a, b) {
  4572. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4573. })[0];
  4574. if ((near.dist2 <= 300)) {
  4575. if (near.dist2 <= 200 && nearTrap) {
  4576. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4577. } else {
  4578. if ([4, 5].includes(player.weaponIndex) && near.dist2 <= items.weapons[player.primaryIndex || 5].range + (player.scale * 1.8)) {
  4579. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4580. } else {
  4581. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4582. }
  4583. }
  4584. }
  4585. }
  4586. }
  4587. }
  4588. };
  4589. this.replacer = function (findObj) {
  4590. if (!findObj || !configs.autoReplace) return;
  4591. if (!inGame) return;
  4592. if (this.antiTrapped) return;
  4593. game.tickBase(() => {
  4594. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4595. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4596. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4597. if (objDst <= 400 && near.dist2 <= 400) {
  4598. let danger = this.checkSpikeTick();
  4599. if (my.autoPush) {
  4600. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objDst, 1);
  4601. } else if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4602. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4603. } else {
  4604. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4605. }
  4606. this.replaced = true;
  4607. }
  4608. }, 1);
  4609. };
  4610. }
  4611. };
  4612.  
  4613. class Instakill {
  4614. constructor() {
  4615. this.wait = false;
  4616. this.can = false;
  4617. this.isTrue = false;
  4618. this.nobull = false;
  4619. this.ticking = false;
  4620. this.canSpikeTick = false;
  4621. this.startTick = false;
  4622. this.readyTick = false;
  4623. this.canCounter = false;
  4624. this.revTick = false;
  4625. this.syncHit = false;
  4626. this.changeType = function(type) {
  4627. this.wait = false;
  4628. this.isTrue = true;
  4629. my.autoAim = true;
  4630. let instaLog = [type];
  4631. if (type == "rev") {
  4632. selectWeapon(player.weapons[1]);
  4633. buyEquip(53, 0);
  4634. sendAutoGather();
  4635. setTimeout(() => {
  4636. selectWeapon(player.weapons[0]);
  4637. buyEquip(7, 0);
  4638. setTimeout(() => {
  4639. sendAutoGather();
  4640. this.isTrue = false;
  4641. my.autoAim = false;
  4642. }, 111);
  4643. }, 100);
  4644. } else if (type == "nobull") {
  4645. selectWeapon(player.weapons[0]);
  4646. buyEquip(7, 0);
  4647. sendAutoGather();
  4648. setTimeout(() => {
  4649. selectWeapon(player.weapons[1]);
  4650. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4651. setTimeout(() => {
  4652. sendAutoGather();
  4653. this.isTrue = false;
  4654. my.autoAim = false;
  4655. }, 80);
  4656. }, 105);
  4657. } else if (type == "normal") {
  4658. selectWeapon(player.weapons[0]);
  4659. buyEquip(7, 0);
  4660. sendAutoGather();
  4661. setTimeout(() => {
  4662. selectWeapon(player.weapons[1]);
  4663. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4664. setTimeout(() => {
  4665. sendAutoGather();
  4666. this.isTrue = false;
  4667. my.autoAim = false;
  4668. }, 80);
  4669. }, 100);
  4670. } else {
  4671. setTimeout(() => {
  4672. this.isTrue = false;
  4673. my.autoAim = false;
  4674. }, 50);
  4675. }
  4676. };
  4677. this.spikeTickType = function() {
  4678. this.isTrue = true;
  4679. my.autoAim = true;
  4680. selectWeapon(player.weapons[0]);
  4681. buyEquip(7, 0);
  4682. sendAutoGather();
  4683. game.tickBase(() => {
  4684. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4685. buyEquip(53, 0);
  4686. selectWeapon(player.weapons[0]);
  4687. buyEquip(53, 0);
  4688. //buyEquip(21, 1);
  4689. game.tickBase(() => {
  4690. sendAutoGather();
  4691. this.isTrue = false;
  4692. my.autoAim = false;
  4693. buyEquip(6, 0);
  4694. buyEquip(21, 1);
  4695. }, 3);
  4696. }, 1);
  4697. };
  4698. this.bowInsta = function(type) {//bow insta from four mod
  4699. this.isTrue = true;
  4700. my.autoAim = true;
  4701. selectWeapon(player.weapons[0]);
  4702. game.tickBase(() => {
  4703. selectWeapon(player.weapons[1]);
  4704. sendAutoGather();
  4705. sendUpgrade(38);
  4706. buyEquip(53, 0);
  4707. buyEquip(19, 1);
  4708. game.tickBase(() => {
  4709. sendUpgrade(12);
  4710. selectWeapon(player.weapons[1]);
  4711. buyEquip(1, 0);
  4712. buyEquip(19, 1);
  4713. game.tickBase(() => {
  4714. sendUpgrade(15);
  4715. selectWeapon(player.weapons[1]);
  4716. buyEquip(1, 0);
  4717. buyEquip(19, 1);
  4718. game.tickBase(() => {
  4719. sendAutoGather();
  4720. this.isTrue = false;
  4721. my.autoAim = false;
  4722. }, 1);
  4723. }, 1);
  4724. }, 1);
  4725. }, 1);
  4726. }
  4727. /* this.spikeTickType = function() {
  4728. this.isTrue = true;
  4729. my.autoAim = true;
  4730. selectWeapon(player.weapons[0]);
  4731. buyEquip(7, 0);
  4732. buyEquip(21, 1);
  4733. sendAutoGather();
  4734. game.tickBase(() => {
  4735. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4736. selectWeapon(player.weapons[0]);
  4737. buyEquip(53, 0);
  4738. buyEquip(21, 1);
  4739. game.tickBase(() => {
  4740. sendAutoGather();
  4741. this.isTrue = false;
  4742. my.autoAim = false;
  4743. }, 1);
  4744. } else {
  4745. sendAutoGather();
  4746. this.isTrue = false;
  4747. my.autoAim = false;
  4748. }
  4749. }, 1);
  4750. };*/
  4751. this.counterType = function() {
  4752. this.isTrue = true;
  4753. my.autoAim = true;
  4754. selectWeapon(player.weapons[0]);
  4755. buyEquip(7, 0);
  4756. buyEquip(21, 1);
  4757. sendAutoGather();
  4758. game.tickBase(() => {
  4759. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4760. selectWeapon(player.weapons[0]);
  4761. buyEquip(53, 0);
  4762. buyEquip(21, 1);
  4763. game.tickBase(() => {
  4764. sendAutoGather();
  4765. this.isTrue = false;
  4766. my.autoAim = false;
  4767. }, 1);
  4768. } else {
  4769. sendAutoGather();
  4770. this.isTrue = false;
  4771. my.autoAim = false;
  4772. }
  4773. }, 1);
  4774. };
  4775. this.antiCounterType = function() {
  4776. my.autoAim = true;
  4777. this.isTrue = true;
  4778. inantiantibull = true;
  4779. selectWeapon(player.weapons[0]);
  4780. buyEquip(6, 0);
  4781. buyEquip(21, 1);
  4782. io.send("D", near.aim2);
  4783. sendAutoGather();
  4784. game.tickBase(() => {
  4785. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  4786. buyEquip(21, 1);
  4787. game.tickBase(() => {
  4788. sendAutoGather();
  4789. this.isTrue = false;
  4790. my.autoAim = false;
  4791. inantiantibull = false;
  4792. }, 1);
  4793. }, 1)
  4794. };
  4795. this.rangeType = function(type) {
  4796. this.isTrue = true;
  4797. my.autoAim = true;
  4798. if (type == "ageInsta") {
  4799. my.ageInsta = false;
  4800. if (player.items[5] == 18) {
  4801. place(5, near.aim2);
  4802. }
  4803. packet("f", undefined, 1);
  4804. buyEquip(22, 0);
  4805. buyEquip(21, 1);
  4806. game.tickBase(() => {
  4807. selectWeapon(player.weapons[1]);
  4808. buyEquip(53, 0);
  4809. buyEquip(21, 1);
  4810. sendAutoGather();
  4811. game.tickBase(() => {
  4812. sendUpgrade(12);
  4813. selectWeapon(player.weapons[1]);
  4814. buyEquip(53, 0);
  4815. buyEquip(21, 1);
  4816. game.tickBase(() => {
  4817. sendUpgrade(15);
  4818. selectWeapon(player.weapons[1]);
  4819. buyEquip(53, 0);
  4820. buyEquip(21, 1);
  4821. game.tickBase(() => {
  4822. sendAutoGather();
  4823. this.isTrue = false;
  4824. my.autoAim = false;
  4825. }, 1);
  4826. }, 1);
  4827. }, 1);
  4828. }, 1);
  4829. } else {
  4830. selectWeapon(player.weapons[1]);
  4831. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4832. buyEquip(53, 0);
  4833. } else {
  4834. buyEquip(20, 0);
  4835. }
  4836. buyEquip(11, 1);
  4837. sendAutoGather();
  4838. game.tickBase(() => {
  4839. sendAutoGather();
  4840. this.isTrue = false;
  4841. my.autoAim = false;
  4842. }, 1);
  4843. }
  4844. };
  4845. this.oneTickType = function() {
  4846. io.send("7113213.29154");
  4847. this.isTrue = true;
  4848. my.autoAim = true;
  4849. selectWeapon(player.weapons[1]);
  4850. buyEquip(53, 0);
  4851. buyEquip(19, 1);
  4852. packet("f", near.aim2, 1);
  4853. if (player.weapons[1] == 15) {
  4854. my.revAim = true;
  4855. sendAutoGather();
  4856. }
  4857. game.tickBase(() => {
  4858. my.revAim = false;
  4859. selectWeapon(player.weapons[0]);
  4860. buyEquip(7, 0);
  4861. buyEquip(19, 1);
  4862. packet("f", near.aim2, 1);
  4863. if (player.weapons[1] != 15) {
  4864. sendAutoGather();
  4865. }
  4866. game.tickBase(() => {
  4867. sendAutoGather();
  4868. this.isTrue = false;
  4869. my.autoAim = false;
  4870. packet("f", undefined, 1);
  4871. }, 1);
  4872. }, 1);
  4873. };
  4874. this.threeOneTickType = function() {
  4875. io.send("Tick2");
  4876. this.isTrue = true;
  4877. my.autoAim = true;
  4878. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4879. biomeGear();
  4880. buyEquip(19, 1);
  4881. packet("f", near.aim2, 1);
  4882. game.tickBase(() => {
  4883. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4884. buyEquip(53, 0);
  4885. buyEquip(19, 1);
  4886. packet("f", near.aim2, 1);
  4887. game.tickBase(() => {
  4888. selectWeapon(player.weapons[0]);
  4889. buyEquip(7, 0);
  4890. buyEquip(19, 1);
  4891. sendAutoGather();
  4892. packet("f", near.aim2, 1);
  4893. game.tickBase(() => {
  4894. sendAutoGather();
  4895. this.isTrue = false;
  4896. my.autoAim = false;
  4897. packet("f", undefined, 1);
  4898. }, 1);
  4899. }, 1);
  4900. }, 1);
  4901. };
  4902. this.kmTickType = function() {
  4903. this.isTrue = true;
  4904. my.autoAim = true;
  4905. my.revAim = true;
  4906. selectWeapon(player.weapons[1]);
  4907. buyEquip(53, 0);
  4908. buyEquip(19, 1);
  4909. sendAutoGather();
  4910. packet("f", near.aim2, 1);
  4911. game.tickBase(() => {
  4912. my.revAim = false;
  4913. selectWeapon(player.weapons[0]);
  4914. buyEquip(7, 0);
  4915. buyEquip(19, 1);
  4916. packet("f", near.aim2, 1);
  4917. game.tickBase(() => {
  4918. sendAutoGather();
  4919. this.isTrue = false;
  4920. my.autoAim = false;
  4921. packet("f", undefined, 1);
  4922. }, 1);
  4923. }, 1);
  4924. };
  4925. this.boostTickType = function() {
  4926. /*this.isTrue = true;
  4927. my.autoAim = true;
  4928. selectWeapon(player.weapons[0]);
  4929. buyEquip(53, 0);
  4930. buyEquip(19, 1);
  4931. packet("f", near.aim2);
  4932. game.tickBase(() => {
  4933. place(4, near.aim2);
  4934. selectWeapon(player.weapons[1]);
  4935. biomeGear();
  4936. buyEquip(19, 1);
  4937. sendAutoGather();
  4938. packet("f", near.aim2);
  4939. game.tickBase(() => {
  4940. selectWeapon(player.weapons[0]);
  4941. buyEquip(7, 0);
  4942. buyEquip(19, 1);
  4943. packet("f", near.aim2);
  4944. game.tickBase(() => {
  4945. sendAutoGather();
  4946. this.isTrue = false;
  4947. my.autoAim = false;
  4948. packet("f", undefined);
  4949. }, 1);
  4950. }, 1);
  4951. }, 1);*/
  4952. this.isTrue = true;
  4953. my.autoAim = true;
  4954. biomeGear();
  4955. buyEquip(19, 1);
  4956. packet("f", near.aim2, 1);
  4957. game.tickBase(() => {
  4958. if (player.weapons[1] == 15) {
  4959. my.revAim = true;
  4960. }
  4961. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  4962. buyEquip(53, 0);
  4963. buyEquip(19, 1);
  4964. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  4965. sendAutoGather();
  4966. }
  4967. packet("f", near.aim2, 1);
  4968. place(4, near.aim2);
  4969. game.tickBase(() => {
  4970. my.revAim = false;
  4971. selectWeapon(player.weapons[0]);
  4972. buyEquip(7, 0);
  4973. buyEquip(19, 1);
  4974. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  4975. sendAutoGather();
  4976. }
  4977. packet("f", near.aim2, 1);
  4978. game.tickBase(() => {
  4979. sendAutoGather();
  4980. this.isTrue = false;
  4981. my.autoAim = false;
  4982. packet("f", undefined, 1);
  4983. }, 1);
  4984. }, 1);
  4985. }, 1);
  4986. };
  4987. this.gotoGoal = function(goto, OT) {
  4988. let slowDists = (weeeee) => weeeee * config.playerScale;
  4989. let goal = {
  4990. a: goto - OT,
  4991. b: goto + OT,
  4992. c: goto - slowDists(1),
  4993. d: goto + slowDists(1),
  4994. e: goto - slowDists(2),
  4995. f: goto + slowDists(2),
  4996. g: goto - slowDists(4),
  4997. h: goto + slowDists(4)
  4998. };
  4999. let bQ = function(wwww, awwww) {
  5000. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5001. buyEquip(31, 0);
  5002. } else {
  5003. buyEquip(wwww, awwww);
  5004. }
  5005. }
  5006. if (enemy.length) {
  5007. let dst = near.dist2;
  5008. this.ticking = true;
  5009. if (dst >= goal.a && dst <= goal.b) {
  5010. bQ(22, 0);
  5011. bQ(11, 1);
  5012. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5013. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5014. }
  5015. return {
  5016. dir: undefined,
  5017. action: 1
  5018. };
  5019. } else {
  5020. if (dst < goal.a) {
  5021. if (dst >= goal.g) {
  5022. if (dst >= goal.e) {
  5023. if (dst >= goal.c) {
  5024. bQ(40, 0);
  5025. bQ(10, 1);
  5026. if (configs.none) {
  5027. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5028. } else {
  5029. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5030. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5031. }
  5032. }
  5033. } else {
  5034. bQ(22, 0);
  5035. bQ(19, 1);
  5036. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5037. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5038. }
  5039. }
  5040. } else {
  5041. bQ(6, 0);
  5042. bQ(12, 1);
  5043. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5044. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5045. }
  5046. }
  5047. } else {
  5048. biomeGear();
  5049. bQ(11, 1);
  5050. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5051. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5052. }
  5053. }
  5054. return {
  5055. dir: near.aim2 + Math.PI,
  5056. action: 0
  5057. };
  5058. } else if (dst > goal.b) {
  5059. if (dst <= goal.h) {
  5060. if (dst <= goal.f) {
  5061. if (dst <= goal.d) {
  5062. bQ(40, 0);
  5063. bQ(9, 1);
  5064. if (configs.none) {
  5065. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5066. } else {
  5067. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5068. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5069. }
  5070. }
  5071. } else {
  5072. bQ(22, 0);
  5073. bQ(19, 1);
  5074. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5075. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5076. }
  5077. }
  5078. } else {
  5079. bQ(6, 0);
  5080. bQ(12, 1);
  5081. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5082. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5083. }
  5084. }
  5085. } else {
  5086. biomeGear();
  5087. bQ(11, 1);
  5088. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5089. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5090. }
  5091. }
  5092. return {
  5093. dir: near.aim2,
  5094. action: 0
  5095. };
  5096. }
  5097. return {
  5098. dir: undefined,
  5099. action: 0
  5100. };
  5101. }
  5102. } else {
  5103. this.ticking = false;
  5104. return {
  5105. dir: undefined,
  5106. action: 0
  5107. };
  5108. }
  5109. }
  5110. /** wait 1 tick for better quality */
  5111. this.bowMovement = function() {
  5112. let moveMent = this.gotoGoal(685, 3);
  5113. if (moveMent.action) {
  5114. if (player.reloads[53] == 0 && !this.isTrue) {
  5115. this.rangeType("ageInsta");
  5116. } else {
  5117. packet("f", moveMent.dir, 1);
  5118. }
  5119. } else {
  5120. packet("f", moveMent.dir, 1);
  5121. }
  5122. },
  5123. this.tickMovement = function() {
  5124. let dist = player.weapons[1] == 9 ? 240 : 240;
  5125. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5126. let moveMent = this.gotoGoal(238, 3);
  5127. if (moveMent.action) {
  5128. if (player.reloads[53] == 0 && !this.isTrue) {
  5129. this.boostTickType();
  5130. } else {
  5131. packet("f", moveMent.dir, 1);
  5132. }
  5133. } else {
  5134. packet("f", moveMent.dir, 1);
  5135. }
  5136. },
  5137. this.kmTickMovement = function() {
  5138. let moveMent = this.gotoGoal(240, 3);
  5139. if (moveMent.action) {
  5140. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5141. this.kmTickType();
  5142. } else {
  5143. packet("f", moveMent.dir, 1);
  5144. }
  5145. } else {
  5146. packet("f", moveMent.dir, 1);
  5147. }
  5148. },
  5149. this.boostTickMovement = function() {
  5150. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  5151. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5152. let moveMent = this.gotoGoal(372, 3);
  5153. if (moveMent.action) {
  5154. if (player.reloads[53] == 0 && !this.isTrue) {
  5155. this.boostTickType();
  5156. } else {
  5157. packet("f", moveMent.dir, 1);
  5158. }
  5159. } else {
  5160. packet("f", moveMent.dir, 1);
  5161. }
  5162. }
  5163. /** wait 1 tick for better quality */
  5164. this.perfCheck = function(pl, nr) {
  5165. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5166. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5167. let pjs = {
  5168. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5169. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5170. };
  5171. 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)) {
  5172. return true;
  5173. }
  5174. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5175. 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)) {
  5176. return true;
  5177. }
  5178. });
  5179. if (finds) return false;
  5180. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5181. let tmpScale = tmp.getScale();
  5182. 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)) {
  5183. return true;
  5184. }
  5185. });
  5186. if (finds) return false;
  5187. return true;
  5188. }
  5189. }
  5190. };
  5191. class Autobuy {
  5192. constructor(buyHat, buyAcc) {
  5193. this.hat = function() {
  5194. buyHat.forEach((id) => {
  5195. let find = findID(hats, id);
  5196. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5197. });
  5198. };
  5199. this.acc = function() {
  5200. buyAcc.forEach((id) => {
  5201. let find = findID(accessories, id);
  5202. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5203. });
  5204. };
  5205. }
  5206. };
  5207.  
  5208. class Autoupgrade {
  5209. constructor() {
  5210. this.sb = function(upg) {
  5211. upg(3);
  5212. upg(17);
  5213. upg(31);
  5214. upg(23);
  5215. upg(9);
  5216. upg(38);
  5217. };
  5218. this.kh = function(upg) {
  5219. upg(3);
  5220. upg(17);
  5221. upg(31);
  5222. upg(23);
  5223. upg(10);
  5224. upg(38);
  5225. upg(4);
  5226. upg(25);
  5227. };
  5228. this.pb = function(upg) {
  5229. upg(5);
  5230. upg(17);
  5231. upg(32);
  5232. upg(23);
  5233. upg(9);
  5234. upg(38);
  5235. };
  5236. this.ph = function(upg) {
  5237. upg(5);
  5238. upg(17);
  5239. upg(32);
  5240. upg(23);
  5241. upg(10);
  5242. upg(38);
  5243. upg(28);
  5244. upg(25);
  5245. };
  5246. this.db = function(upg) {
  5247. upg(7);
  5248. upg(17);
  5249. upg(31);
  5250. upg(23);
  5251. upg(9);
  5252. upg(34);
  5253. };
  5254. };
  5255. };
  5256.  
  5257. class Damages {
  5258. constructor(items) {
  5259. // 0.75 1 1.125 1.5
  5260. this.calcDmg = function(dmg, val) {
  5261. return dmg * val;
  5262. };
  5263. this.getAllDamage = function(dmg) {
  5264. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5265. };
  5266. this.weapons = [];
  5267. for (let i = 0; i < items.weapons.length; i++) {
  5268. let wp = items.weapons[i];
  5269. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5270. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5271. this[name] = this.weapons[i];
  5272. }
  5273. }
  5274. }
  5275.  
  5276. /** CLASS CODES */
  5277. // jumpscare code warn
  5278. let tmpList = [];
  5279. var bianosTick = false;
  5280.  
  5281.  
  5282. // LOADING:
  5283. let UTILS = new Utils();
  5284. let items = new Items();
  5285. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5286. let store = new Store();
  5287. let hats = store.hats;
  5288. let accessories = store.accessories;
  5289. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5290. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5291. let textManager = new Textmanager();
  5292.  
  5293. let traps = new Traps(UTILS, items);
  5294. let instaC = new Instakill();
  5295. let autoBuy = new Autobuy([6,7, 22, 12, 53, 40], [11 , 13, 18]);
  5296. let autoUpgrade = new Autoupgrade();
  5297.  
  5298. let lastDeath;
  5299. let minimapData;
  5300. let mapMarker = {};
  5301. let mapPings = [];
  5302. let tmpPing;
  5303.  
  5304. let breakTrackers = [];
  5305.  
  5306. let pathFindTest = 0;
  5307. let grid = [];
  5308. let pathFind = {
  5309. active: false,
  5310. grid: 40,
  5311. scale: 1440,
  5312. x: 14400,
  5313. y: 14400,
  5314. chaseNear: false,
  5315. array: [],
  5316. lastX: this.grid / 2,
  5317. lastY: this.grid / 2
  5318. };
  5319.  
  5320. function sendChat(message) {
  5321. packet("6", message.slice(0, 30));
  5322. }
  5323.  
  5324. let runAtNextTick = [];
  5325.  
  5326. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5327. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5328. let projOffset = config.playerScale * 2;
  5329. let projXY = {
  5330. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5331. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5332. };
  5333. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5334. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5335. })[0];
  5336. if (nearPlayer) {
  5337. if (indx == 1) {
  5338. nearPlayer.shooting[53] = 1;
  5339. } else {
  5340. nearPlayer.shootIndex = weaponIndx;
  5341. nearPlayer.shooting[1] = 1;
  5342. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5343. }
  5344. }
  5345. }
  5346. let projectileCount = 0;
  5347.  
  5348. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5349. if (!tmpObj.isTeam(player)) {
  5350. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5351. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5352. tmpObj.bowThreat[weaponIndex]++;
  5353. if (index == 5) {
  5354. projectileCount++;
  5355. }
  5356. setTimeout(() => {
  5357. tmpObj.bowThreat[weaponIndex]--;
  5358. if (index == 5) {
  5359. projectileCount--;
  5360. }
  5361. }, range / speed);
  5362. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5363. place(1, tmpObj.aim2);
  5364. my.anti0Tick = 4;
  5365. if (!my.antiSync) {
  5366. antiSyncHealing(4);
  5367. }
  5368. } else {
  5369. if (projectileCount >= 2) {
  5370. place(1, tmpObj.aim2);
  5371. my.anti0Tick = 4;
  5372. if (!my.antiSync) {
  5373. antiSyncHealing(4);
  5374. }
  5375. }
  5376. }
  5377. }
  5378. }
  5379. }
  5380.  
  5381. // SHOW ITEM INFO:
  5382. function showItemInfo(item, isWeapon, isStoreItem) {
  5383. if (player && item) {
  5384. UTILS.removeAllChildren(itemInfoHolder);
  5385. itemInfoHolder.classList.add("visible");
  5386. UTILS.generateElement({
  5387. id: "itemInfoName",
  5388. text: UTILS.capitalizeFirst(item.name),
  5389. parent: itemInfoHolder
  5390. });
  5391. UTILS.generateElement({
  5392. id: "itemInfoDesc",
  5393. text: item.desc,
  5394. parent: itemInfoHolder
  5395. });
  5396. if (isStoreItem) {
  5397.  
  5398. } else if (isWeapon) {
  5399. UTILS.generateElement({
  5400. class: "itemInfoReq",
  5401. text: !item.type ? "primary" : "secondary",
  5402. parent: itemInfoHolder
  5403. });
  5404. } else {
  5405. for (let i = 0; i < item.req.length; i += 2) {
  5406. UTILS.generateElement({
  5407. class: "itemInfoReq",
  5408. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5409. parent: itemInfoHolder
  5410. });
  5411. }
  5412. if (item.group.limit) {
  5413. UTILS.generateElement({
  5414. class: "itemInfoLmt",
  5415. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5416. parent: itemInfoHolder
  5417. });
  5418. }
  5419. }
  5420. } else {
  5421. itemInfoHolder.classList.remove("visible");
  5422. }
  5423. }
  5424.  
  5425.  
  5426. // RESIZE:
  5427. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5428.  
  5429. function resize() {
  5430. screenWidth = window.innerWidth;
  5431. screenHeight = window.innerHeight;
  5432. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5433. gameCanvas.width = screenWidth * pixelDensity;
  5434. gameCanvas.height = screenHeight * pixelDensity;
  5435. gameCanvas.style.width = screenWidth + "px";
  5436. gameCanvas.style.height = screenHeight + "px";
  5437. mainContext.setTransform(
  5438. scaleFillNative, 0,
  5439. 0, scaleFillNative,
  5440. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5441. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5442. );
  5443. }
  5444. resize();
  5445.  
  5446. // MOUSE INPUT:
  5447. var usingTouch;
  5448. const mals = document.getElementById('touch-controls-fullscreen');
  5449. mals.style.display = 'block';
  5450. mals.addEventListener("mousemove", gameInput, false);
  5451.  
  5452. function gameInput(e) {
  5453. mouseX = e.clientX;
  5454. mouseY = e.clientY;
  5455. }
  5456. let clicks = {
  5457. left: false,
  5458. middle: false,
  5459. right: false,
  5460. };
  5461. let clicked = {
  5462. g: false
  5463. }
  5464. mals.addEventListener("mousedown", mouseDown, false);
  5465.  
  5466. function mouseDown(e) {
  5467. if (attackState != 1) {
  5468. attackState = 1;
  5469. if (e.button == 0) {
  5470. clicks.left = true;
  5471. } else if (e.button == 2) {
  5472. clicks.right = true;
  5473. }
  5474. }
  5475. }
  5476. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5477.  
  5478. function mouseUp(e) {
  5479. if (attackState != 0) {
  5480. attackState = 0;
  5481. if (e.button == 0) {
  5482. clicks.left = false;
  5483. } else if (e.button == 1) {
  5484. clicks.middle = false;
  5485. } else if (e.button == 2) {
  5486. clicks.right = false;
  5487. }
  5488. }
  5489. }
  5490. mals.addEventListener("wheel", wheel, false);
  5491.  
  5492. let wbe = 1;
  5493. let mWbe = 1;
  5494. let smothAnim = null;
  5495.  
  5496. function wheel(e, t = [null, 0]) {
  5497. if (e.deltaY > 0) {
  5498. //if (maxScreenWidth < 2100) {
  5499. mWbe = Math.min(mWbe + 0.35, 10);
  5500. //}
  5501. } else {
  5502. if (maxScreenWidth > 800) {
  5503. mWbe = Math.max(mWbe - 0.35, 0.1);
  5504. }
  5505. }
  5506.  
  5507. if (smothAnim) clearInterval(smothAnim);
  5508. smothAnim = setInterval(() => {
  5509. wbe += (mWbe - wbe) * 0.1;
  5510. maxScreenWidth = config.maxScreenWidth * wbe;
  5511. maxScreenHeight = config.maxScreenHeight * wbe;
  5512. resize();
  5513. if (Math.abs(mWbe - wbe) < 0.01) {
  5514. clearInterval(smothAnim);
  5515. }
  5516. }, 15);
  5517. }
  5518. function findAllianceBySid(sid) {
  5519. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  5520. }
  5521. // INPUT UTILS:
  5522. function getMoveDir() {
  5523. let dx = 0;
  5524. let dy = 0;
  5525. for (let key in moveKeys) {
  5526. let tmpDir = moveKeys[key];
  5527. dx += !!keys[key] * tmpDir[0];
  5528. dy += !!keys[key] * tmpDir[1];
  5529. }
  5530. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5531. }
  5532.  
  5533. function getSafeDir() {
  5534. if (!player)
  5535. return 0;
  5536. if (!player.lockDir) {
  5537. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5538. }
  5539. return lastDir || 0;
  5540. }
  5541. let plusDir = 0;
  5542. let lastSpin = Date.now();
  5543. function getAttackDir(debug) {
  5544.  
  5545. if (debug) {
  5546. if (!player)
  5547. return "0";
  5548. 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))
  5549. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  5550. else
  5551. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5552. lastDir = "getSafeDir()";
  5553. else
  5554. if (traps.inTrap && player.reloads[traps.notFast(objectCheck) ? player.weapons[1] : player.weapons[0]] == 0)
  5555. lastDir = "traps.aim";
  5556. else
  5557. if (spikeB.can) {
  5558. lastDir = 'spikeB.aim';
  5559. } else
  5560. if (!player.lockDir) {
  5561. if (configs.noDir) return "undefined";
  5562. lastDir = "getSafeDir()";
  5563. }
  5564. return lastDir;
  5565. } else {
  5566. if (!player)
  5567. return 0;
  5568. 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))
  5569. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5570. else
  5571. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5572. lastDir = getSafeDir();
  5573. else
  5574. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  5575. lastDir = traps.aim;
  5576. } else
  5577. if (spikeB.can) {
  5578. lastDir = spikeB.aim;
  5579. } else
  5580. if (!player.lockDir) {
  5581. if (configs.noDir) return undefined;
  5582. lastDir = getSafeDir();
  5583. }
  5584. return lastDir || 0;
  5585. }
  5586. }
  5587.  
  5588.  
  5589. function getVisualDir() {
  5590. if (!player) return 0;
  5591.  
  5592. lastDir = getSafeDir();
  5593. return lastDir || 0;
  5594. }
  5595.  
  5596. // KEYS:
  5597. function keysActive() {
  5598. return (allianceMenu.style.display != "block" &&
  5599. chatHolder.style.display != "block" &&
  5600. !menuCBFocus);
  5601. }
  5602.  
  5603. function toggleMenuChat() {
  5604. if (menuChatDiv.style.display != "none") {
  5605. // chatHolder.style.display = "none";
  5606. // if (menuChatBox.value != "") {
  5607. //commands[command.slice(1)]
  5608. let cmd = function(command) {
  5609. return {
  5610. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5611. fv: commands[command.slice(1).split(" ")[0]]
  5612. }
  5613. }
  5614. let command = cmd(menuChatBox.value);
  5615. if (command.found) {
  5616. if (typeof command.fv.action === "function") {
  5617. command.fv.action(menuChatBox.value);
  5618. }
  5619. } else {
  5620. sendChat(menuChatBox.value);
  5621. }
  5622. menuChatBox.value = "";
  5623. menuChatBox.blur();
  5624. } else {
  5625. if (menuCBFocus) {
  5626. menuChatBox.blur();
  5627. } else {
  5628. menuChatBox.focus();
  5629. }
  5630. }
  5631. }
  5632. function instaSync () {
  5633. var instaSync = getEl("gowogSync")
  5634. if ( instaSync && instaSync.checked) {
  5635. this.isTrue = true
  5636. my.autoAim = true
  5637. selectWeapon(player.weapons[1]);
  5638. buyEquip(53, 0);
  5639. sendAutoGather();
  5640. setTimeout(() => {
  5641. selectWeapon(player.weapons[0]);
  5642. buyEquip(7, 0);
  5643. setTimeout(() => {
  5644. sendAutoGather();
  5645. this.isTrue = false;
  5646. my.autoAim = false;
  5647. }, 225);
  5648. }, 100);
  5649. }
  5650. }
  5651.  
  5652. function keyDown(event) {
  5653. let keyNum = event.which || event.keyCode || 0;
  5654. if (player && player.alive && keysActive()) {
  5655. if (!keys[keyNum]) {
  5656. keys[keyNum] = 1;
  5657. macro[event.key] = 1;
  5658. if (keyNum == 27) {
  5659. openMenu = !openMenu;
  5660. $("#menuDiv").toggle();
  5661. } else if (keyNum == 69) {
  5662. sendAutoGather();
  5663. } else if(event.key == "j" && player.reloads[53] == 0 && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  5664. instaC.bowInsta();
  5665. } else if (event.key == "b" ) {//instaSync shoot press b
  5666.  
  5667. } else if (keyNum == 71) {
  5668. clicked.g = !clicked.g
  5669. } else if (player.weapons[keyNum - 49] != undefined) {
  5670. player.weaponCode = player.weapons[keyNum - 49];
  5671. } else if (moveKeys[keyNum]) {
  5672. sendMoveDir();
  5673. } else if (event.key == "m") {
  5674. mills.placeSpawnPads = !mills.placeSpawnPads;
  5675. } else if (event.key == "z") {
  5676. mills.place = !mills.place;
  5677. } else if (event.key == "Z") {
  5678. typeof window.debug == "function" && window.debug();
  5679. } else if (keyNum == 32) {
  5680. packet("F", 1, getSafeDir(), 1);
  5681. packet("F", 0, getSafeDir(), 1);
  5682. }
  5683. }
  5684. }
  5685. }
  5686. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5687.  
  5688. function keyUp(event) {
  5689. if (player && player.alive) {
  5690. let keyNum = event.which || event.keyCode || 0;
  5691. if (keyNum == 13) {
  5692. toggleMenuChat();
  5693. } else if (keysActive()) {
  5694. if (keys[keyNum]) {
  5695. keys[keyNum] = 0;
  5696. macro[event.key] = 0;
  5697. if (moveKeys[keyNum]) {
  5698. sendMoveDir();
  5699. }
  5700. }
  5701. }
  5702. }
  5703. }
  5704. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5705.  
  5706. function sendMoveDir() {
  5707. let newMoveDir = getMoveDir();
  5708. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5709. if (!my.autoPush) {
  5710. packet("f", newMoveDir, 1);
  5711. }
  5712. lastMoveDir = newMoveDir;
  5713. }
  5714. }
  5715.  
  5716. // BUTTON EVENTS:
  5717. function bindEvents() {}
  5718. bindEvents();
  5719.  
  5720. /** PATHFIND TEST */
  5721. function chechPathColl(tmp) {
  5722. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  5723. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  5724. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  5725. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  5726. }
  5727.  
  5728. function checkObject() {
  5729. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  5730. for (let y = 0; y < pathFind.grid; y++) {
  5731. grid[y] = [];
  5732. for (let x = 0; x < pathFind.grid; x++) {
  5733. let tmpXY = {
  5734. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  5735. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  5736. }
  5737. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  5738. pathFind.lastX = x;
  5739. pathFind.lastY = y;
  5740. grid[y][x] = 0;
  5741. continue;
  5742. }
  5743. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  5744. if (find) {
  5745. if (find.trap) {
  5746. grid[y][x] = 0;
  5747. continue;
  5748. }
  5749. grid[y][x] = 1;
  5750. } else {
  5751. grid[y][x] = 0;
  5752. }
  5753. }
  5754. }
  5755. }
  5756.  
  5757. function createPath() {
  5758. grid = [];
  5759. checkObject();
  5760. }
  5761.  
  5762. function Pathfinder() {
  5763. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  5764. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  5765. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5766. packet("f", undefined, 1);
  5767. } else {
  5768. createPath();
  5769. easystar.setGrid(grid);
  5770. easystar.setAcceptableTiles([0]);
  5771. easystar.enableDiagonals();
  5772. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  5773. if (path === null) {
  5774. pathFind.array = [];
  5775. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5776. packet("f", undefined, 1);
  5777. } else {
  5778. packet("f", near.aim2, 1);
  5779. }
  5780. } else {
  5781. pathFind.array = path;
  5782. if (pathFind.array.length > 1) {
  5783. let tmpXY = {
  5784. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  5785. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  5786. }
  5787. packet("f", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  5788. }
  5789. }
  5790. });
  5791. easystar.calculate();
  5792. }
  5793. }
  5794. }
  5795. /** PATHFIND TEST */
  5796.  
  5797. // ITEM COUNT DISPLAY:
  5798. let isItemSetted = [];
  5799.  
  5800. function updateItemCountDisplay(index = undefined) {
  5801. for (let i = 3; i < items.list.length; ++i) {
  5802. let id = items.list[i].group.id;
  5803. let tmpI = items.weapons.length + i;
  5804. if (!isItemSetted[tmpI]) {
  5805. isItemSetted[tmpI] = document.createElement("div");
  5806. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5807. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5808. isItemSetted[tmpI].style = `
  5809. display: block;
  5810. position: absolute;
  5811. padding-left: 5px;
  5812. font-size: 2em;
  5813. color: #fff;
  5814. `;
  5815. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5816. } else {
  5817. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5818. }
  5819. }
  5820. }
  5821.  
  5822. // AUTOPUSH:
  5823. function autoPush() {
  5824. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 15)).sort(function(a, b) {
  5825. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5826. })[0];
  5827. if (nearTrap) {
  5828. let enemyboob = gameObjects.some(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale + 5));
  5829. if (enemyboob) {
  5830. my.autoPush = false;
  5831. pathFind.active = false;
  5832. pathFind.chaseNear = false;
  5833. return;
  5834. }
  5835. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale + 5)).sort(function(a, b) {
  5836. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5837. })[0];
  5838. if (spike && UTILS.getDist(spike, nearTrap, 0, 0)) {
  5839. let pos = {
  5840. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5841. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5842. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5843. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  5844. };
  5845. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  5846. let tmpScale = tmp.getScale();
  5847. 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)) {
  5848. return true;
  5849. }
  5850. });
  5851. if (near.dist2 >= 110) {
  5852. my.autoPush = false;
  5853. pathFind.active = true;
  5854. pathFind.chaseNear = true;
  5855. } else if (near.dist2 <= 100) {
  5856. pathFind.active = false;
  5857. pathFind.chaseNear = false;
  5858. my.autoPush = true;
  5859. my.pushData = {
  5860. x: spike.x + Math.cos(30),
  5861. y: spike.y + Math.sin(30),
  5862. x2: pos.x2 + Math.cos(60),
  5863. y2: pos.y2 + Math.sin(60)
  5864. };
  5865. let angle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x);
  5866. let point = {
  5867. x: near.x2 + Math.cos(angle) * 53,
  5868. y: near.y2 + Math.sin(angle) * 53,
  5869. };
  5870. let num = UTILS.getDist(near, spike, 2, 0);
  5871. let text = num.toString(10);
  5872. let scale = (player.scale / 10);
  5873. if (UTILS.getDist(near, spike, 2, 0) >= 105) {
  5874. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5875. io.send("a", near.aim2, 1);
  5876. } else {
  5877. io.send("a", UTILS.getDirect(pos, player, 2, 2), 1);
  5878. }
  5879. } else {
  5880. let isEnemyTouchingSpike = gameObjects.some(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, spike, 0, 0) <= (tmp.scale + spike.scale + 5));
  5881. if (isEnemyTouchingSpike) {
  5882. let enemyPos = {
  5883. x: enemy.x,
  5884. y: enemy.y
  5885. };
  5886. let angleToEnemy = Math.atan2(enemyPos.y - spike.y, enemyPos.x - spike.x);
  5887. let angleDifference = Math.abs(UTILS.getDirect(near, spike, 2, 0) - angleToEnemy);
  5888. if (angleDifference > Math.PI / 2) {
  5889. let antiOverPush = angleToEnemy + Math.PI / 2;
  5890. io.send("a", antiOverPush, 1);
  5891. } else {
  5892. io.send("a", UTILS.getDirect(near, spike, 2, 0), 1);
  5893. }
  5894. } else {
  5895. io.send("a", Math.atan2(point.y - player.y2, point.x - player.x2), 1);
  5896. }
  5897. }
  5898. }
  5899. } else {
  5900. if (my.autoPush) {
  5901. io.send("a", undefined, 1);
  5902. my.autoPush = false;
  5903. }
  5904. pathFind.active = false;
  5905. pathFind.chaseNear = false;
  5906. }
  5907. } else {
  5908. if (my.autoPush) {
  5909. io.send("a", undefined, 1);
  5910. my.autoPush = false;
  5911. }
  5912. pathFind.active = false;
  5913. pathFind.chaseNear = false;
  5914. }
  5915. }
  5916.  
  5917. // ADD DEAD PLAYER:
  5918. function addDeadPlayer(tmpObj) {
  5919. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  5920. }
  5921.  
  5922. /** APPLY SOCKET CODES */
  5923.  
  5924. // SET INIT DATA:
  5925. function setInitData(data) {
  5926. alliances = data.teams;
  5927. }
  5928.  
  5929. // SETUP GAME:
  5930. function setupGame(yourSID) {
  5931. keys = {};
  5932. macro = {};
  5933. playerSID = yourSID;
  5934. attackState = 0;
  5935. inGame = true;
  5936. packet("F", 0, getAttackDir(), 1);
  5937. my.ageInsta = true;
  5938. if (firstSetup) {
  5939. firstSetup = false;
  5940. gameObjects.length = 0;
  5941. liztobj.length = 0;
  5942. }
  5943. }
  5944.  
  5945. // ADD NEW PLAYER:
  5946. function addPlayer(data, isYou) {
  5947. let tmpPlayer = findPlayerByID(data[0]);
  5948. if (!tmpPlayer) {
  5949. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  5950. objectManager, players, ais, items, hats, accessories);
  5951. players.push(tmpPlayer);
  5952. if (data[1] != playerSID) {
  5953. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5954. }
  5955. } else {
  5956. if (data[1] != playerSID) {
  5957. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5958. }
  5959. }
  5960. tmpPlayer.spawn(isYou ? true : null);
  5961. tmpPlayer.visible = false;
  5962. tmpPlayer.oldPos = {
  5963. x2: undefined,
  5964. y2: undefined
  5965. };
  5966. tmpPlayer.x2 = undefined;
  5967. tmpPlayer.y2 = undefined;
  5968. tmpPlayer.x3 = undefined;
  5969. tmpPlayer.y3 = undefined;
  5970. tmpPlayer.setData(data);
  5971. if (isYou) {
  5972. if (!player) {
  5973. window.prepareUI(tmpPlayer);
  5974. }
  5975. player = tmpPlayer;
  5976. camX = player.x;
  5977. camY = player.y;
  5978. my.lastDir = 0;
  5979. updateItems();
  5980. updateAge();
  5981. updateItemCountDisplay();
  5982. if (player.skins[7]) {
  5983. my.reSync = true;
  5984. }
  5985. }
  5986. }
  5987.  
  5988. // REMOVE PLAYER:
  5989. function removePlayer(id) {
  5990. for (let i = 0; i < players.length; i++) {
  5991. if (players[i].id == id) {
  5992. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  5993. players.splice(i, 1);
  5994. break;
  5995. }
  5996. }
  5997. }
  5998.  
  5999. // UPDATE HEALTH:
  6000. function updateHealth(sid, value) {
  6001. tmpObj = findPlayerBySID(sid);
  6002. if (tmpObj) {
  6003. tmpObj.oldHealth = tmpObj.health;
  6004. tmpObj.health = value;
  6005. tmpObj.judgeShame();
  6006. if (tmpObj.oldHealth > tmpObj.health) {
  6007. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6008. advHeal.push([sid, value, tmpObj.damaged]);
  6009. }
  6010. }
  6011. }
  6012.  
  6013.  
  6014. // KILL PLAYER:
  6015. function killPlayer() {
  6016. inGame = false;
  6017. lastDeath = {
  6018. x: player.x,
  6019. y: player.y,
  6020. };
  6021. if (configs.autoRespawn) {
  6022. getEl("diedText").style.display = "none";
  6023. packet("M", {
  6024. name: lastsp[0],
  6025. moofoll: lastsp[1],
  6026. skin: lastsp[2]
  6027. });
  6028. }
  6029. }
  6030.  
  6031. // UPDATE PLAYER ITEM VALUES:
  6032. function updateItemCounts(index, value) {
  6033. if (player) {
  6034. player.itemCounts[index] = value;
  6035. updateItemCountDisplay(index);
  6036. }
  6037. }
  6038.  
  6039. // UPDATE AGE:
  6040. function updateAge(xp, mxp, age) {
  6041. if (xp != undefined)
  6042. player.XP = xp;
  6043. if (mxp != undefined)
  6044. player.maxXP = mxp;
  6045. if (age != undefined)
  6046. player.age = age;
  6047. }
  6048.  
  6049. // UPDATE UPGRADES:
  6050. function updateUpgrades(points, age) {
  6051. player.upgradePoints = points;
  6052. player.upgrAge = age;
  6053. if (points > 0) {
  6054. tmpList.length = 0;
  6055. UTILS.removeAllChildren(upgradeHolder);
  6056. for (let i = 0; i < items.weapons.length; ++i) {
  6057. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6058. let e = UTILS.generateElement({
  6059. id: "upgradeItem" + i,
  6060. class: "actionBarItem",
  6061. onmouseout: function() {
  6062. showItemInfo();
  6063. },
  6064. parent: upgradeHolder
  6065. });
  6066. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6067. tmpList.push(i);
  6068. }
  6069. }
  6070. for (let i = 0; i < items.list.length; ++i) {
  6071. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6072. let tmpI = (items.weapons.length + i);
  6073. let e = UTILS.generateElement({
  6074. id: "upgradeItem" + tmpI,
  6075. class: "actionBarItem",
  6076. onmouseout: function() {
  6077. showItemInfo();
  6078. },
  6079. parent: upgradeHolder
  6080. });
  6081. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6082. tmpList.push(tmpI);
  6083. }
  6084. }
  6085. for (let i = 0; i < tmpList.length; i++) {
  6086. (function(i) {
  6087. let tmpItem = getEl('upgradeItem' + i);
  6088. // tmpItem.onmouseover = function() {
  6089. // if (items.weapons[i]) {
  6090. // showItemInfo(items.weapons[i], true);
  6091. // } else {
  6092. // showItemInfo(items.list[i - items.weapons.length]);
  6093. // }
  6094. // };
  6095. tmpItem.onclick = UTILS.checkTrusted(function() {
  6096. packet("H", i);
  6097. });
  6098. UTILS.hookTouchEvents(tmpItem);
  6099. })(tmpList[i]);
  6100. }
  6101. if (tmpList.length) {
  6102. upgradeHolder.style.display = "block";
  6103. upgradeCounter.style.display = "block";
  6104. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6105. } else {
  6106. upgradeHolder.style.display = "none";
  6107. upgradeCounter.style.display = "none";
  6108. showItemInfo();
  6109. }
  6110. } else {
  6111. upgradeHolder.style.display = "none";
  6112. upgradeCounter.style.display = "none";
  6113. showItemInfo();
  6114. }
  6115. }
  6116.  
  6117. // KILL OBJECT:
  6118. function killObject(sid) {
  6119. let findObj = findObjectBySid(sid);
  6120. objectManager.disableBySid(sid);
  6121. if (player) {
  6122. for (let i = 0; i < breakObjects.length; i++) {
  6123. if (breakObjects[i].sid == sid) {
  6124. breakObjects.splice(i, 1);
  6125. break;
  6126. }
  6127. }
  6128. if (!player.canSee(findObj)) {
  6129. breakTrackers.push({
  6130. x: findObj.x,
  6131. y: findObj.y
  6132. });
  6133. }
  6134. if (breakTrackers.length > 8) {
  6135. breakTrackers.shift();
  6136. }
  6137. traps.replacer(findObj);
  6138. }
  6139. }
  6140.  
  6141. // KILL ALL OBJECTS BY A PLAYER:
  6142. function killObjects(sid) {
  6143. if (player) objectManager.removeAllItems(sid);
  6144. }
  6145. function setTickout(doo, timeout) {
  6146. if (!ticks.manage[ticks.tick + timeout]) {
  6147. ticks.manage[ticks.tick + timeout] = [doo];
  6148. } else {
  6149. ticks.manage[ticks.tick + timeout].push(doo);
  6150. }
  6151. }
  6152.  
  6153. function caf(e, t) {
  6154. try {
  6155. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6156. } catch (e) {
  6157. return 0;
  6158. }
  6159. }
  6160.  
  6161. let found = false;
  6162. let autoQ = false;
  6163.  
  6164. let autos = {
  6165. insta: {
  6166. todo: false,
  6167. wait: false,
  6168. count: 4,
  6169. shame: 5
  6170. },
  6171. bull: false,
  6172. antibull: 0,
  6173. reloaded: false,
  6174. stopspin: true
  6175. }
  6176. let omgS = {
  6177. spike: {
  6178. active: false,
  6179. x: 0,
  6180. y: 0,
  6181. scale: 0,
  6182. },
  6183. moveDir: undefined,
  6184. lastPos: {
  6185. x: 0,
  6186. y: 0,
  6187. }
  6188. }
  6189. function fgdo(a, b) {
  6190. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  6191. }
  6192. // UPDATE PLAYER DATA:
  6193. function updatePlayers(data) {
  6194. // High Ping Notif
  6195. if (window.pingTime > 200) {
  6196. textManager.showText(player.x2, player.y2, 20, 0.15, 1850, "Warning High Ping: " + window.pingTime, "red", 2);
  6197. }
  6198. // Safe walk:
  6199. let dir = lastMoveDir;
  6200. let newPos = {
  6201. x: player.x2 + (player.x2 - omgS.lastPos.x) * 1.3 + (Math.cos(dir) * 50),
  6202. y: player.y2 + (player.y2 - omgS.lastPos.y) * 1.3 + (Math.sin(dir) * 50),
  6203. };
  6204.  
  6205. let nearSpike = gameObjects
  6206. .filter(e => (e.name === "spikes" || e.name === "greater spikes" || e.name === "spinning spikes" || e.name === "poison spikes")
  6207. && e.active
  6208. && UTILS.getDist(e, tmpObj, 0, 2) <= 200
  6209. && !e.isTeamObject(player))
  6210. .sort((a, b) => UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2))[0];
  6211.  
  6212. let found = false;
  6213. let buildings = gameObjects.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x));
  6214. let spikes = buildings.filter(obj => obj.dmg && fgdo(player, obj) < 230 && !obj.isTeamObject(player) && obj.active);
  6215.  
  6216. // Safe walk logic: Check for collision with spikes
  6217. for (let i = 0; i < spikes.length; i++) {
  6218. if (fgdo(spikes[i], newPos) < spikes[i].scale + player.scale + 4.5) {
  6219. found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x);
  6220. omgS.spike.active = true;
  6221. omgS.spike.x = spikes[i].x;
  6222. omgS.spike.y = spikes[i].y;
  6223. omgS.spike.scale = spikes[i].scale;
  6224. }
  6225. }
  6226.  
  6227. if (found !== false && !my.inTrap) {
  6228. packet("f", undefined, 1);
  6229. textManager.showText(player.x2, player.y2, 20, 0.15, 1850, "block", "#fff", 2);
  6230. } else if (!instaC.isTrue) {
  6231. omgS.spike.active = false;
  6232. } else {
  6233. omgS.spike.active = false;
  6234. }
  6235.  
  6236. omgS.lastPos.x = player.x2;
  6237. omgS.lastPos.y = player.y2;
  6238. // AutoBreakSpike:
  6239. if (!spikeB.info || !spikeB.info.active || !spikes.includes(spikeB.info) && !traps.inTrap) {
  6240. buildings = gameObjects.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x));
  6241. spikes = buildings.filter(obj => (obj.name === 'spikes' || obj.name === 'greater spikes' || obj.name === 'spinning spikes' || obj.name === 'poison spikes') && !(player.sid === obj.owner.sid || findAllianceBySid(obj.owner.sid)) && fgdo(player, obj) < (player.items[1] === 10 ? 145 : 200) && obj.active);
  6242. let nearestSpike = spikes.length > 0 ? spikes[0] : null;
  6243. if (spikes.length > 1) {
  6244. nearestSpike = spikes.reduce((closest, current) => {
  6245. return Math.hypot(player.y2 - current.y, player.x2 - current.x) < Math.hypot(player.y2 - closest.y, player.x2 - closest.x) ? current : closest;
  6246. });
  6247. }
  6248. if (nearestSpike) {
  6249. spikeB.info = nearestSpike;
  6250. } else {
  6251. spikeB.info = null;
  6252. }
  6253. }
  6254. if (spikeB.info) {
  6255. let weaponRange = items.weapons[player.weapons[1] === 10 ? player.weapons[1] : player.weapons[0]].range + player.scale * 1.8;
  6256. let spikeDistance = Math.hypot(player.y2 - spikeB.info.y, player.x2 - spikeB.info.x);
  6257.  
  6258. if (spikeDistance <= weaponRange) {
  6259. spikeB.dist = spikeDistance;
  6260. spikeB.x = spikeB.info.x;
  6261. spikeB.y = spikeB.info.y;
  6262. spikeB.can = true;
  6263. spikeB.aim = UTILS.getDirect(spikeB.info, player, 0, 2);
  6264. } else {
  6265. spikeB.can = false;
  6266. }
  6267. } else {
  6268. spikeB.can = false;
  6269. }
  6270. if (spikeB.can) {
  6271. if (!clicks.right || !clicks.left || !instaC.isTrue) {
  6272. game.tickBase(() => {
  6273. if (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6274. selectWeapon(player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6275. sendAutoGather();
  6276. my.waitHit = 1;
  6277. game.tickBase(() => {
  6278. sendAutoGather();
  6279. my.waitHit = 0;
  6280. }, 1);
  6281. }
  6282. }, 1);
  6283. }
  6284. }
  6285.  
  6286.  
  6287.  
  6288.  
  6289.  
  6290. game.tick++;
  6291. enemy = [];
  6292. nears = [];
  6293. near = [];
  6294. game.tickSpeed = performance.now() - game.lastTick;
  6295. game.lastTick = performance.now();
  6296. players.forEach((tmp) => {
  6297. tmp.forcePos = !tmp.visible;
  6298. tmp.visible = false;
  6299. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6300. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6301. });
  6302. for (let i = 0; i < data.length;) {
  6303. tmpObj = findPlayerBySID(data[i]);
  6304. if (tmpObj) {
  6305. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6306. tmpObj.t2 = game.lastTick;
  6307. tmpObj.oldPos.x2 = tmpObj.x2;
  6308. tmpObj.oldPos.y2 = tmpObj.y2;
  6309. tmpObj.x1 = tmpObj.x;
  6310. tmpObj.y1 = tmpObj.y;
  6311. tmpObj.x2 = data[i + 1];
  6312. tmpObj.y2 = data[i + 2];
  6313. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6314. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6315. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6316. tmpObj.d2 = data[i + 3];
  6317. tmpObj.dt = 0;
  6318. tmpObj.buildIndex = data[i + 4];
  6319. tmpObj.weaponIndex = data[i + 5];
  6320. tmpObj.weaponVariant = data[i + 6];
  6321. tmpObj.team = data[i + 7];
  6322. tmpObj.isLeader = data[i + 8];
  6323. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6324. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6325. tmpObj.skinIndex = data[i + 9];
  6326. tmpObj.tailIndex = data[i + 10];
  6327. tmpObj.iconIndex = data[i + 11];
  6328. tmpObj.zIndex = data[i + 12];
  6329. tmpObj.visible = true;
  6330. tmpObj.update(game.tickSpeed);
  6331. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6332. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6333. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6334. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6335. tmpObj.damageThreat = 0;
  6336. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6337. tmpObj.addShameTimer();
  6338. }
  6339. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6340. tmpObj.shameTimer = 0;
  6341. tmpObj.shameCount = 0;
  6342. if (tmpObj == player) {
  6343. healer();
  6344. }
  6345. }
  6346.  
  6347. botSkts.forEach((bot) => {
  6348. bot.showName = 'YEAHHH'
  6349. })
  6350.  
  6351. for(let i = 0; i < players.length; i++) {
  6352. for(let aa = 0; aa < botSkts.length; aa++) {
  6353. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6354.  
  6355. }
  6356. }
  6357.  
  6358. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6359. autoQ = true;
  6360. healer();
  6361. } else {
  6362. if (autoQ) {
  6363. healer();
  6364. }
  6365. autoQ = false;
  6366. }
  6367.  
  6368.  
  6369. if (tmpObj == player) {
  6370. if (liztobj.length) {
  6371. liztobj.forEach((tmp) => {
  6372. tmp.onNear = false;
  6373. if (tmp.active) {
  6374. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6375. tmp.onNear = true;
  6376. }
  6377. if (tmp.isItem && tmp.owner) {
  6378. 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)) {
  6379. tmp.breakObj = true;
  6380. breakObjects.push({
  6381. x: tmp.x,
  6382. y: tmp.y,
  6383. sid: tmp.sid
  6384. });
  6385. }
  6386. }
  6387. }
  6388. });
  6389. 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) {
  6390. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6391. })[0];
  6392.  
  6393. if (nearTrap) {
  6394. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6395. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6396. traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6397. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6398. traps.inTrap = true;
  6399. traps.info = nearTrap;
  6400.  
  6401. } else {
  6402.  
  6403. traps.inTrap = false;
  6404. traps.info = {};
  6405. }
  6406. } else {
  6407. traps.inTrap = false;
  6408. }
  6409. }
  6410. if (tmpObj.weaponIndex < 9) {
  6411. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6412. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6413. } else if (tmpObj.weaponIndex > 8) {
  6414. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6415. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6416. }
  6417. }
  6418. i += 13;
  6419. }
  6420. if (textManager.stack.length) {
  6421. let stacks = [];
  6422. let notstacks = [];
  6423. let num = 0;
  6424. let num2 = 0;
  6425. let pos = {
  6426. x: null,
  6427. y: null
  6428. };
  6429. let pos2 = {
  6430. x: null,
  6431. y: null
  6432. }
  6433. textManager.stack.forEach((text) => {
  6434. if (text.value >= 0) {
  6435. if (num == 0) pos = {
  6436. x: text.x,
  6437. y: text.y
  6438. };
  6439. num += Math.abs(text.value);
  6440. } else {
  6441. if (num2 == 0) pos2 = {
  6442. x: text.x,
  6443. y: text.y
  6444. };
  6445. num2 += Math.abs(text.value);
  6446. }
  6447. });
  6448. if (num2 > 0) {
  6449. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  6450. }
  6451. if (num > 0) {
  6452. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6453. }
  6454. textManager.stack = [];
  6455. }
  6456. if (runAtNextTick.length) {
  6457. runAtNextTick.forEach((tmp) => {
  6458. checkProjectileHolder(...tmp);
  6459. });
  6460. runAtNextTick = [];
  6461. }
  6462. for (let i = 0; i < data.length;) {
  6463. tmpObj = findPlayerBySID(data[i]);
  6464. if (tmpObj) {
  6465. if (!tmpObj.isTeam(player)) {
  6466. enemy.push(tmpObj);
  6467. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6468. nears.push(tmpObj);
  6469. }
  6470. }
  6471. tmpObj.manageReload();
  6472. if (tmpObj != player) {
  6473. tmpObj.addDamageThreat(player);
  6474. }
  6475. }
  6476. i += 13;
  6477. }
  6478. /*projectiles.forEach((proj) => {
  6479. tmpObj = proj;
  6480. if (tmpObj.active) {
  6481. tmpObj.tickUpdate(game.tickSpeed);
  6482. }
  6483. });*/
  6484. if (player && player.alive) {
  6485. if (enemy.length) {
  6486. near = enemy.sort(function(tmp1, tmp2) {
  6487. return tmp1.dist2 - tmp2.dist2;
  6488. })[0];
  6489. } else {
  6490. // console.log("no enemy");
  6491. }
  6492. if (game.tickQueue[game.tick]) {
  6493. game.tickQueue[game.tick].forEach((action) => {
  6494. action();
  6495. });
  6496. game.tickQueue[game.tick] = null;
  6497. }
  6498. if (advHeal.length) {
  6499. advHeal.forEach((updHealth) => {
  6500. if (window.pingTime < 150) {
  6501. let sid = updHealth[0];
  6502. let value = updHealth[1];
  6503. let totalDamage = 100 - value
  6504. let damaged = updHealth[2];
  6505. tmpObj = findPlayerBySID(sid);
  6506. let bullTicked = false;
  6507. if (tmpObj == player) {
  6508. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6509. if (my.reSync) {
  6510. my.reSync = false;
  6511. tmpObj.setBullTick = true;
  6512. }
  6513. bullTicked = true;
  6514. }
  6515. if (inGame) {
  6516. let attackers = getAttacker(damaged);
  6517. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6518. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6519. let healTimeout = 140 - window.pingTime;
  6520. let dmg = 100 - player.health;
  6521. let slowHeal = function (timer, tickBase) {
  6522. if (!tickBase) {
  6523. setTimeout(() => {
  6524. healer();
  6525. }, timer);
  6526. } else {
  6527. game.tickBase(() => {
  6528. healer()
  6529. }, 2)
  6530. }
  6531. }
  6532. if (getEl("healingBeta").checked) {
  6533. if (enemy.length) {
  6534. if ([0, 7, 8].includes(near.primaryIndex)) {
  6535. if (damaged < 75) {
  6536. slowHeal(healTimeout)
  6537. } else {
  6538. healer()
  6539. }
  6540. }
  6541. if ([1, 2, 6].includes(near.primaryIndex)) {
  6542. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  6543. healer()
  6544. } else {
  6545. slowHeal(healTimeout)
  6546. }
  6547. }
  6548. if (near.primaryIndex == 3) {
  6549. if (near.secondaryIndex == 15) {
  6550. if (near.primaryVariant < 2) {
  6551. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6552. tmpObj.canEmpAnti = true
  6553. tmpObj.antiTimer = game.tick
  6554. healer()
  6555. } else {
  6556. slowHeal(healTimeout)
  6557. }
  6558. } else {
  6559. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6560. tmpObj.canEmpAnti = true
  6561. tmpObj.antiTimer = game.tick
  6562. healer()
  6563. } else {
  6564. slowHeal(healTimeout)
  6565. }
  6566. }
  6567. } else {
  6568. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6569. healer()
  6570. } else {
  6571. slowHeal(healTimeout)
  6572. }
  6573. }
  6574. }
  6575. if (near.primaryIndex == 4) {
  6576. if (near.primaryVariant >= 1) {
  6577. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6578. healer()
  6579. } else {
  6580. slowHeal(healTimeout)
  6581. }
  6582. } else {
  6583. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  6584. healer()
  6585. } else {
  6586. slowHeal(healTimeout)
  6587. }
  6588. }
  6589. }
  6590. if ([undefined, 5].includes(near.primaryIndex)) {
  6591. if (near.secondaryIndex == 10) {
  6592. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  6593. healer()
  6594. } else {
  6595. slowHeal(healTimeout)
  6596. }
  6597. } else
  6598. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  6599. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  6600. healer()
  6601. } else {
  6602. slowHeal(healTimeout)
  6603. }
  6604. } else
  6605. if ([undefined || 15].includes(near.secondaryIndex)) {
  6606. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  6607. if (tmpObj.shameCount < 5) {
  6608. healer()
  6609. } else {
  6610. slowHeal(healTimeout)
  6611. }
  6612. } else {
  6613. slowHeal(healTimeout)
  6614. }
  6615. } else
  6616. if ([9, 12, 13].includes(near.secondaryIndex)) {
  6617. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  6618. healer()
  6619. } else {
  6620. slowHeal(healTimeout)
  6621. }
  6622. } else {
  6623. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  6624. healer()
  6625. } else {
  6626. slowHeal(healTimeout)
  6627. }
  6628. }
  6629. }
  6630. if (near.primaryIndex == 6) {
  6631. if (near.secondaryIndex == 15) {
  6632. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6633. healer()
  6634. } else {
  6635. slowHeal(healTimeout)
  6636. }
  6637. } else {
  6638. if (damaged >= 70 && tmpObj.shameCount < 4) {
  6639. healer()
  6640. } else {
  6641. slowHeal(healTimeout)
  6642. }
  6643. }
  6644. }
  6645. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6646. } else {
  6647. if (damaged >= 70) {
  6648. healer()
  6649. } else {
  6650. slowHeal(healTimeout)
  6651. }
  6652. }
  6653. } else {
  6654. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  6655. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6656. tmpObj.canEmpAnti = true;
  6657. } else {
  6658. player.soldierAnti = true;
  6659. }
  6660. tmpObj.antiTimer = game.tick;
  6661. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  6662. if (tmpObj.shameCount < shame) {
  6663. healer();
  6664. } else {
  6665. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6666. slowHeal(healTimeout)
  6667. } else {
  6668. slowHeal(healTimeout, 1)
  6669. }
  6670. }
  6671. } else {
  6672. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6673. slowHeal(healTimeout)
  6674. } else {
  6675. slowHeal(healTimeout, 1)
  6676. }
  6677. }
  6678. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6679. }
  6680. } else {
  6681. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6682. tmpObj.setPoisonTick = true;
  6683. }
  6684. }
  6685. }
  6686. } else {
  6687. let [sid, value, damaged] = updHealth;
  6688. let totalDamage = 100 - value;
  6689. let tmpObj = findPlayerBySID(sid);
  6690. let bullTicked = false;
  6691.  
  6692. if (tmpObj == player) {
  6693. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6694. if (my.reSync) {
  6695. my.reSync = false;
  6696. tmpObj.setBullTick = true;
  6697. bullTicked = true;
  6698. }
  6699. }
  6700. if (inGame) {
  6701. let attackers = getAttacker(damaged);
  6702. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6703. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6704. let healTimeout = 60;
  6705. let dmg = 100 - player.health;
  6706. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  6707.  
  6708. let slowHeal = function (timer, tickBase) {
  6709. if (!tickBase) setTimeout(() => healer(), timer);
  6710. else game.tickBase(() => healer(), 2);
  6711. };
  6712.  
  6713. if (getEl("healingBeta").checked) {
  6714. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 :
  6715. [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 :
  6716. [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 :
  6717. near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 :
  6718. near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6719. damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 :
  6720. near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6721. damaged >= 25 && player.damageThreat + dmg >= 95;
  6722.  
  6723. canHealFast ? healer() : slowHeal(healTimeout);
  6724. } else {
  6725. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1;
  6726.  
  6727. if (canHealFast) {
  6728. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) tmpObj.canEmpAnti = true;
  6729. else player.soldierAnti = true;
  6730. tmpObj.antiTimer = game.tick;
  6731. if (tmpObj.shameCount < shameCountThreshold) healer();
  6732. else slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6733. } else {
  6734. slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6735. }
  6736. }
  6737. } else {
  6738. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6739. tmpObj.setPoisonTick = true;
  6740. }
  6741. }
  6742. }
  6743. }
  6744. });
  6745. advHeal = [];
  6746. }
  6747. if (near.dist2 <= 310) {
  6748. if ([3, 4, 5].includes(near.primaryIndex) && [10, 9, 12, 13, 15].includes(near.secondaryIndex)) {
  6749. if (near.skinIndex == 7 && near.reloads[near.primaryIndex]) {
  6750. buyEquip(6, 0);
  6751. if (near.skinIndex == 53 || near.reloads[53] == 1) {
  6752. buyEquip(6, 0);
  6753. }
  6754. }
  6755. }
  6756. }
  6757. players.forEach((tmp) => {
  6758. if (!tmp.visible && player != tmp) {
  6759. tmp.reloads = {
  6760. 0: 0,
  6761. 1: 0,
  6762. 2: 0,
  6763. 3: 0,
  6764. 4: 0,
  6765. 5: 0,
  6766. 6: 0,
  6767. 7: 0,
  6768. 8: 0,
  6769. 9: 0,
  6770. 10: 0,
  6771. 11: 0,
  6772. 12: 0,
  6773. 13: 0,
  6774. 14: 0,
  6775. 15: 0,
  6776. 53: 0,
  6777. };
  6778. }
  6779. if (tmp.setBullTick) {
  6780. tmp.bullTimer = 0;
  6781. }
  6782. if (tmp.setPoisonTick) {
  6783. tmp.poisonTimer = 0;
  6784. }
  6785. tmp.updateTimer();
  6786. });
  6787. if (inGame) {
  6788. if (enemy.length) {
  6789. if (player.canEmpAnti) {
  6790. player.canEmpAnti = false;
  6791. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6792. if (near.reloads[53] == 0) {
  6793. player.empAnti = true;
  6794. player.soldierAnti = false;
  6795. //modLog("EmpAnti");
  6796. } else {
  6797. player.empAnti = false;
  6798. player.soldierAnti = true;
  6799. //modLog("SoldierAnti");
  6800. }
  6801. }
  6802. }
  6803. 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) {
  6804. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6805. })[0];
  6806. if (prehit) {
  6807. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6808. instaC.canSpikeTick = true;
  6809. instaC.syncHit = true;
  6810. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6811. instaC.revTick = true;
  6812. }
  6813. }
  6814. }
  6815. let antiSpikeTick = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + player.scale)).sort(function(a, b) {
  6816. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6817. })[0];
  6818. if (antiSpikeTick && !traps.inTrap) {
  6819. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  6820. my.anti0Tick = 1;
  6821. }
  6822. }
  6823. }
  6824. if ((useWasd ? true : ((player.checkCanInsta(true) >= 220 ? 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)) {
  6825. if (player.checkCanInsta(true) >= 220) {
  6826. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6827. } else {
  6828. instaC.nobull = false;
  6829. }
  6830. instaC.can = true;
  6831. } else {
  6832. instaC.can = false;
  6833. }
  6834. macro.q && place(0, getAttackDir());
  6835. macro.f && place(4, getSafeDir());
  6836. macro.v && place(2, getSafeDir());
  6837. macro.y && place(5, getSafeDir());
  6838. macro.h && place(player.getItemType(22), getSafeDir());
  6839. macro.n && place(3, getSafeDir());
  6840. if (game.tick % 1 == 0) {
  6841. if (mills.place) {
  6842. let plcAng = 7.7;
  6843. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6844. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6845. }
  6846. } else {
  6847. if (mills.placeSpawnPads) {
  6848. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6849. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6850. }
  6851. }
  6852. }
  6853. }
  6854. if (instaC.can) {
  6855. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  6856. }
  6857. if (instaC.canCounter) {
  6858. instaC.canCounter = false;
  6859. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6860. instaC.counterType();
  6861. }
  6862. }
  6863. if (instaC.canSpikeTick) {
  6864. instaC.canSpikeTick = false;
  6865. if (instaC.revTick) {
  6866. instaC.revTick = false;
  6867. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6868. instaC.changeType("rev");
  6869. chch(null, "[RevSyncHit]", "yellow");
  6870. }
  6871. } else {
  6872. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6873. instaC.spikeTickType();
  6874. if (instaC.syncHit) {
  6875. chch(null, "[SyncHit]", "yellow");
  6876. }
  6877. }
  6878. }
  6879. }
  6880. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6881. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6882. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6883. }
  6884. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6885. sendAutoGather();
  6886. my.waitHit = 1;
  6887. game.tickBase(() => {
  6888. sendAutoGather();
  6889. my.waitHit = 0;
  6890. }, 1);
  6891. }
  6892. }
  6893. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6894. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6895. selectWeapon(player.weapons[0]);
  6896. }
  6897. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6898. sendAutoGather();
  6899. my.waitHit = 1;
  6900. game.tickBase(() => {
  6901. sendAutoGather();
  6902. my.waitHit = 0;
  6903. }, 1);
  6904. }
  6905. }
  6906. if (traps.inTrap) {
  6907. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6908. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6909. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6910. }
  6911. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6912. sendAutoGather();
  6913. my.waitHit = 1;
  6914. game.tickBase(() => {
  6915. sendAutoGather();
  6916. my.waitHit = 0;
  6917. }, 1);
  6918. }
  6919. }
  6920. }
  6921. if (clicked.g && !traps.inTrap) {
  6922. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6923. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6924. instaC.bowMovement();
  6925. } else {
  6926. instaC.rangeType();
  6927. }
  6928. }
  6929. }
  6930. if (macro.t && !traps.inTrap) {
  6931. 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))) {
  6932. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6933. }
  6934. }
  6935. if (macro["."] && !traps.inTrap) {
  6936. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6937. instaC.boostTickMovement();
  6938. }
  6939. }
  6940. if (player.weapons[1] && !clicks.left && !clicks.right && !spikeB.can && !traps.inTrap && !instaC.isTrue && !(useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8)) {
  6941. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6942. if (!my.reloaded) {
  6943. my.reloaded = true;
  6944. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6945. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6946. selectWeapon(player.weapons[fastSpeed]);
  6947. }
  6948. }
  6949. } else {
  6950. my.reloaded = false;
  6951. if(useWasd) {
  6952. autos.stopspin = false;
  6953. }
  6954. if (player.reloads[player.weapons[0]] > 0) {
  6955. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6956. selectWeapon(player.weapons[0]);
  6957. }
  6958. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6959. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6960. selectWeapon(player.weapons[1]);
  6961. }
  6962. if(useWasd) {
  6963. if (!autos.stopspin) {
  6964. setTimeout(()=>{
  6965. autos.stopspin = true;
  6966. }, 750);
  6967. }
  6968. }
  6969. }
  6970. }
  6971. }
  6972. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6973. traps.autoPlace();
  6974. }
  6975. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6976. packet("D", getAttackDir());
  6977. }
  6978. let hatChanger = function() {
  6979. if (my.anti0Tick > 0) {
  6980. buyEquip(6, 0);
  6981. } else {
  6982. if (clicks.left || clicks.right) {
  6983. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6984. buyEquip(7, 0);
  6985. } else {
  6986. if (clicks.left) {
  6987. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : near.dist2 <= 300 ? 6 : 6, 0);
  6988. } else if (clicks.right) {
  6989. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : player.soldierAnti ? 6 : near.dist2 <= 300 ? 6 : 6, 0);
  6990. }
  6991. }
  6992. } else if (traps.inTrap || spikeB.can) {
  6993. if (traps.inTrap ? traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6994. : spikeB.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6995. buyEquip(40, 0);
  6996. } else {
  6997. buyEquip(6, 0);
  6998. }
  6999. } else {
  7000. if (player.empAnti || player.soldierAnti) {
  7001. buyEquip(6, 0);
  7002. } else {
  7003. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7004. buyEquip(7, 0);
  7005. } else {
  7006. if (near.dist2 <= 400) {
  7007. buyEquip(6, 0);
  7008. } else {
  7009. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7010. buyEquip(31, 0);
  7011. } else if (player.y2 <= config.snowBiomeTop) {
  7012. buyEquip(15, 0);
  7013. } else {
  7014. buyEquip(12, 0);
  7015. }
  7016. }
  7017. }
  7018. }
  7019. }
  7020. }
  7021. }
  7022.  
  7023. let accChanger = function () {
  7024. if (player.weaponIndex == 7) {
  7025. if (clicks.right || my.autoPush){
  7026. buyEquip(19, 1);
  7027. } else if (clicks.left) {
  7028. buyEquip(21,1);
  7029. } else {
  7030. buyEquip(11, 1);
  7031. }
  7032. } else {
  7033. if (near.dist2 <= 270) {
  7034. if (clicks.right){
  7035. buyEquip(19, 1);
  7036. } else if (clicks.left) {
  7037. buyEquip(21,1);
  7038. } else {
  7039. buyEquip(19, 1);
  7040. }
  7041. } else {
  7042. buyEquip(11, 1);
  7043. }
  7044. }
  7045.  
  7046. }
  7047. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7048. hatChanger();
  7049. accChanger();
  7050. }
  7051. //lastMoveDir = getSafeDir();
  7052. //packet("f", lastMoveDir, 1);
  7053. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7054. autoPush();
  7055. } else {
  7056. if (my.autoPush) {
  7057. my.autoPush = false;
  7058. packet("f", lastMoveDir || undefined, 1);
  7059. }
  7060. }
  7061. if (!my.autoPush && pathFind.active) {
  7062. Pathfinder();
  7063. }
  7064. if (instaC.ticking) {
  7065. instaC.ticking = false;
  7066. }
  7067. if (instaC.syncHit) {
  7068. instaC.syncHit = false;
  7069. }
  7070. if (player.empAnti) {
  7071. player.empAnti = false;
  7072. }
  7073. if (player.soldierAnti) {
  7074. player.soldierAnti = false;
  7075. }
  7076. if (my.anti0Tick > 0) {
  7077. my.anti0Tick--;
  7078. }
  7079. if (traps.replaced) {
  7080. traps.replaced = false;
  7081. }
  7082. if (traps.antiTrapped) {
  7083. traps.antiTrapped = false;
  7084. }
  7085.  
  7086. }
  7087. }
  7088. if (botSkts.length) {
  7089. botSkts.forEach((bots) => {
  7090. if (true) {
  7091. bots[0].showName = 'YEAHHH';
  7092. }
  7093. });
  7094. }
  7095. }
  7096. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7097. 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)
  7098.  
  7099. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7100. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7101. selectWeapon(player.weapons[1])
  7102. buyEquip(40, 0);
  7103. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7104. setTickout( () => {
  7105. buyEquip(6, 0)
  7106. }, 1);
  7107. }
  7108. }
  7109. }
  7110. }
  7111. function ez(context, x, y) {
  7112. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7113. context.beginPath();
  7114. context.fill();
  7115. context.closePath();
  7116. context.globalAlpha = 1;
  7117. }
  7118. // UPDATE LEADERBOARD:
  7119. function updateLeaderboard(data) {
  7120. lastLeaderboardData = data;
  7121. return;
  7122. UTILS.removeAllChildren(leaderboardData);
  7123. let tmpC = 1;
  7124. for (let i = 0; i < data.length; i += 3) {
  7125. (function(i) {
  7126. UTILS.generateElement({
  7127. class: "leaderHolder",
  7128. parent: leaderboardData,
  7129. children: [
  7130. UTILS.generateElement({
  7131. class: "leaderboardItem",
  7132. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7133. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7134. }),
  7135. UTILS.generateElement({
  7136. class: "leaderScore",
  7137. text: UTILS.sFormat(data[i + 2]) || "0"
  7138. })
  7139. ]
  7140. });
  7141. })(i);
  7142. tmpC++;
  7143. }
  7144. }
  7145.  
  7146. // LOAD GAME OBJECT:
  7147. function loadGameObject(data) {
  7148. for (let i = 0; i < data.length;) {
  7149. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7150. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7151. sid: data[i + 7]
  7152. } : null));
  7153. // sid, x, y, dir, s, type, data, setSID, owner
  7154. /*let dist = UTILS.getDist({
  7155. x: data[i + 1],
  7156. y: data[i + 2]
  7157. }, player, 0, 2);
  7158. let aim = UTILS.getDirect({
  7159. x: data[i + 1],
  7160. y: data[i + 2]
  7161. }, player, 0, 2);
  7162. find = findObjectBySid(data[i]);
  7163. if (data[i + 6] == 15) {
  7164. if (find && !find.isTeamObject(player)) {
  7165. if (dist <= 100) {
  7166. traps.dist = dist;
  7167. traps.aim = aim;
  7168. traps.protect(aim);
  7169. }
  7170. }
  7171. }*/
  7172. i += 8;
  7173. }
  7174. }
  7175.  
  7176. // ADD AI:
  7177. function loadAI(data) {
  7178. for (let i = 0; i < ais.length; ++i) {
  7179. ais[i].forcePos = !ais[i].visible;
  7180. ais[i].visible = false;
  7181. }
  7182. if (data) {
  7183. let tmpTime = performance.now();
  7184. for (let i = 0; i < data.length;) {
  7185. tmpObj = findAIBySID(data[i]);
  7186. if (tmpObj) {
  7187. tmpObj.index = data[i + 1];
  7188. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7189. tmpObj.t2 = tmpTime;
  7190. tmpObj.x1 = tmpObj.x;
  7191. tmpObj.y1 = tmpObj.y;
  7192. tmpObj.x2 = data[i + 2];
  7193. tmpObj.y2 = data[i + 3];
  7194. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7195. tmpObj.d2 = data[i + 4];
  7196. tmpObj.health = data[i + 5];
  7197. tmpObj.dt = 0;
  7198. tmpObj.visible = true;
  7199. } else {
  7200. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7201. tmpObj.x2 = tmpObj.x;
  7202. tmpObj.y2 = tmpObj.y;
  7203. tmpObj.d2 = tmpObj.dir;
  7204. tmpObj.health = data[i + 5];
  7205. if (!aiManager.aiTypes[data[i + 1]].name)
  7206. tmpObj.name = config.cowNames[data[i + 6]];
  7207. tmpObj.forcePos = true;
  7208. tmpObj.sid = data[i];
  7209. tmpObj.visible = true;
  7210. }
  7211. i += 7;
  7212. }
  7213. }
  7214. }
  7215.  
  7216. // ANIMATE AI:
  7217. function animateAI(sid) {
  7218. tmpObj = findAIBySID(sid);
  7219. if (tmpObj) tmpObj.startAnim();
  7220. }
  7221.  
  7222. // GATHER ANIMATION:
  7223. function gatherAnimation(sid, didHit, index) {
  7224. tmpObj = findPlayerBySID(sid);
  7225. if (tmpObj) {
  7226. tmpObj.startAnim(didHit, index);
  7227. tmpObj.gatherIndex = index;
  7228. tmpObj.gathering = 1;
  7229.  
  7230. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7231. // healer();
  7232.  
  7233. if (didHit) {
  7234. let tmpObjects = objectManager.hitObj;
  7235. objectManager.hitObj = [];
  7236. game.tickBase(() => {
  7237. // refind
  7238. tmpObj = findPlayerBySID(sid);
  7239. 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);
  7240. tmpObjects.forEach((healthy) => {
  7241. healthy.health -= val;
  7242. textManager.showText(healthy.x, healthy.y, 20, 0, 500, Math.abs(val.toString().includes(".") ? UTILS.fixTo(val, 3) : val), "#f00", true);
  7243. });
  7244. }, 1);
  7245. }
  7246. }
  7247. }
  7248.  
  7249. // WIGGLE GAME OBJECT:
  7250. function wiggleGameObject(dir, sid) {
  7251. tmpObj = findObjectBySid(sid);
  7252. if (tmpObj) {
  7253. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7254. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7255. if (tmpObj.health) {
  7256. objectManager.hitObj.push(tmpObj);
  7257. }
  7258. }
  7259. }
  7260.  
  7261. // SHOOT TURRET:
  7262. function shootTurret(sid, dir) {
  7263. tmpObj = findObjectBySid(sid);
  7264. if (tmpObj) {
  7265. if (config.anotherVisual) {
  7266. tmpObj.lastDir = dir;
  7267. } else {
  7268. tmpObj.dir = dir;
  7269. }
  7270. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7271. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7272. }
  7273. }
  7274.  
  7275. // UPDATE PLAYER VALUE:
  7276. function updatePlayerValue(index, value, updateView) {
  7277. if (player) {
  7278. player[index] = value;
  7279. if (index == "points") {
  7280. if (configs.autoBuy) {
  7281. autoBuy.hat();
  7282. autoBuy.acc();
  7283. }
  7284. } else if (index == "kills") {
  7285. sendChat("Dumbasses down: " + value);
  7286. setTimeout(() => {
  7287. sendChat("I'm Super Pro");
  7288. }, 600);
  7289. }
  7290. }
  7291. }
  7292.  
  7293.  
  7294.  
  7295.  
  7296. // ACTION BAR:
  7297. function updateItems(data, wpn) {
  7298. if (data) {
  7299. if (wpn) {
  7300. player.weapons = data;
  7301. player.primaryIndex = player.weapons[0];
  7302. player.secondaryIndex = player.weapons[1];
  7303. if (!instaC.isTrue) {
  7304. selectWeapon(player.weapons[0]);
  7305. }
  7306. } else {
  7307. player.items = data;
  7308. }
  7309. }
  7310.  
  7311. for (let i = 0; i < items.list.length; i++) {
  7312. let tmpI = items.weapons.length + i;
  7313. let actionBarItem = getEl("actionBarItem" + tmpI);
  7314. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7315.  
  7316. }
  7317.  
  7318. for (let i = 0; i < items.weapons.length; i++) {
  7319. let actionBarItem = getEl("actionBarItem" + i);
  7320. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7321. }
  7322.  
  7323. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7324. if (kms) {
  7325. getEl("actionBarItem3").style.display = "none";
  7326. getEl("actionBarItem4").style.display = "inline-block";
  7327. }
  7328. }
  7329.  
  7330. // ADD PROJECTILE:
  7331. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7332. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7333. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7334. }
  7335.  
  7336. // REMOVE PROJECTILE:
  7337. function remProjectile(sid, range) {
  7338. for (let i = 0; i < projectiles.length; ++i) {
  7339. if (projectiles[i].sid == sid) {
  7340. projectiles[i].range = range;
  7341. let tmpObjects = objectManager.hitObj;
  7342. objectManager.hitObj = [];
  7343. game.tickBase(() => {
  7344. let val = projectiles[i].dmg;
  7345. tmpObjects.forEach((healthy) => {
  7346. if (healthy.projDmg) {
  7347. healthy.health -= val;
  7348. }
  7349. });
  7350. }, 1);
  7351. }
  7352. }
  7353. }
  7354.  
  7355. // lol this useless,,, fr
  7356. let noob = false;
  7357. let serverReady = true;
  7358. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7359. let wssws = isProd ? "wss" : "ws";
  7360. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7361. let withSync = false;
  7362. project.binaryType = "arraybuffer";
  7363. project.onmessage = function(msg) {
  7364. let data = msg.data;
  7365. if (data == "isready") {
  7366. serverReady = true;
  7367. }
  7368. if (data == "fine") {
  7369. noob = false;
  7370. }
  7371.  
  7372. if (data == "tezt") {
  7373. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7374. }
  7375. if (data == "yeswearesyncer") {
  7376. // let delay = Date.now() - wsDelay;
  7377. withSync = true;
  7378. if (player) {
  7379. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7380. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7381. }
  7382. }
  7383. };
  7384. project.onopen = function() {
  7385. var gameTitle = getEl("gameName");
  7386. gameTitle.innerText = "Moo Moo";
  7387. };
  7388.  
  7389. // SHOW ALLIANCE MENU:
  7390. function allianceNotification(sid, name) {
  7391. let findBotSID = findSID(bots, sid);
  7392. if (findBotSID) {}
  7393. }
  7394.  
  7395. function setPlayerTeam(team, isOwner) {
  7396. if (player) {
  7397. player.team = team;
  7398. player.isOwner = isOwner;
  7399. if (team == null)
  7400. alliancePlayers = [];
  7401. }
  7402. }
  7403.  
  7404. function setAlliancePlayers(data) {
  7405. alliancePlayers = data;
  7406. }
  7407.  
  7408. // STORE MENU:
  7409. function updateStoreItems(type, id, index) {
  7410. if (index) {
  7411. if (!type)
  7412. player.tails[id] = 1;
  7413. else {
  7414. player.latestTail = id;
  7415. }
  7416. } else {
  7417. if (!type)
  7418. player.skins[id] = 1,
  7419. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7420. else {
  7421. player.latestSkin = id;
  7422. }
  7423. }
  7424. }
  7425.  
  7426.  
  7427. // SEND MESSAGE:
  7428. function receiveChat(sid, message) {
  7429. if (/img/i.test(message)) return; // Anti img kick gowog
  7430. if (/iframe/i.test(message)) return;
  7431. let kawaii = false;
  7432. let tmpPlayer = findPlayerBySID(sid);
  7433. if (tmpPlayer) {
  7434. allChats.push(new addCh(tmpPlayer.x, tmpPlayer.y, message, tmpPlayer));
  7435. }
  7436. tmpPlayer.chatMessage = message;
  7437. tmpPlayer.chatCountdown = config.chatCountdown;
  7438.  
  7439. }
  7440.  
  7441. // MINIMAP:
  7442. function updateMinimap(data) {
  7443. minimapData = data;
  7444. }
  7445.  
  7446. // SHOW ANIM TEXT:
  7447. function showText(x, y, value, type) {
  7448. // if (config.anotherVisual) {
  7449. textManager.stack.push({
  7450. x: x,
  7451. y: y,
  7452. value: value
  7453. });
  7454. // } else {
  7455. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7456. // }
  7457. }
  7458.  
  7459. /** APPLY SOCKET CODES */
  7460.  
  7461. // BOT:
  7462. let bots = [];
  7463. let ranLocation = {
  7464. x: UTILS.randInt(35, 14365),
  7465. y: UTILS.randInt(35, 14365)
  7466. };
  7467. setInterval(() => {
  7468. ranLocation = {
  7469. x: UTILS.randInt(35, 14365),
  7470. y: UTILS.randInt(35, 14365)
  7471. };
  7472. }, 60000);
  7473. class Bot {
  7474. constructor(id, sid, hats, accessories) {
  7475. this.millPlace = true;
  7476. this.id = id;
  7477. this.sid = sid;
  7478. this.team = null;
  7479. this.skinIndex = 0;
  7480. this.tailIndex = 0;
  7481. this.hitTime = 0;
  7482. this.iconIndex = 0;
  7483. this.enemy = [];
  7484. this.near = [];
  7485. this.dist2 = 0;
  7486. this.aim2 = 0;
  7487. this.tick = 0;
  7488. this.itemCounts = {};
  7489. this.latestSkin = 0;
  7490. this.latestTail = 0;
  7491. this.points = 0;
  7492. this.tails = {};
  7493. for (let i = 0; i < accessories.length; ++i) {
  7494. if (accessories[i].price <= 0)
  7495. this.tails[accessories[i].id] = 1;
  7496. }
  7497. this.skins = {};
  7498. for (let i = 0; i < hats.length; ++i) {
  7499. if (hats[i].price <= 0)
  7500. this.skins[hats[i].id] = 1;
  7501. }
  7502. this.spawn = function(moofoll) {
  7503. this.upgraded = 0;
  7504. this.enemy = [];
  7505. this.near = [];
  7506. this.active = true;
  7507. this.alive = true;
  7508. this.lockMove = false;
  7509. this.lockDir = false;
  7510. this.minimapCounter = 0;
  7511. this.chatCountdown = 0;
  7512. this.shameCount = 0;
  7513. this.shameTimer = 0;
  7514. this.sentTo = {};
  7515. this.gathering = 0;
  7516. this.autoGather = 0;
  7517. this.animTime = 0;
  7518. this.animSpeed = 0;
  7519. this.mouseState = 0;
  7520. this.buildIndex = -1;
  7521. this.weaponIndex = 0;
  7522. this.dmgOverTime = {};
  7523. this.noMovTimer = 0;
  7524. this.maxXP = 300;
  7525. this.XP = 0;
  7526. this.age = 1;
  7527. this.kills = 0;
  7528. this.upgrAge = 2;
  7529. this.upgradePoints = 0;
  7530. this.x = 0;
  7531. this.y = 0;
  7532. this.zIndex = 0;
  7533. this.xVel = 0;
  7534. this.yVel = 0;
  7535. this.slowMult = 1;
  7536. this.dir = 0;
  7537. this.nDir = 0;
  7538. this.dirPlus = 0;
  7539. this.targetDir = 0;
  7540. this.targetAngle = 0;
  7541. this.maxHealth = 100;
  7542. this.health = this.maxHealth;
  7543. this.oldHealth = this.maxHealth;
  7544. this.scale = config.playerScale;
  7545. this.speed = config.playerSpeed;
  7546. this.resetMoveDir();
  7547. this.resetResources(moofoll);
  7548. this.items = [0, 3, 6, 10];
  7549. this.weapons = [0];
  7550. this.shootCount = 0;
  7551. this.weaponXP = [];
  7552. this.isBot = false;
  7553. this.reloads = {
  7554. 0: 0,
  7555. 1: 0,
  7556. 2: 0,
  7557. 3: 0,
  7558. 4: 0,
  7559. 5: 0,
  7560. 6: 0,
  7561. 7: 0,
  7562. 8: 0,
  7563. 9: 0,
  7564. 10: 0,
  7565. 11: 0,
  7566. 12: 0,
  7567. 13: 0,
  7568. 14: 0,
  7569. 15: 0,
  7570. 53: 0,
  7571. };
  7572. this.timeZinceZpawn = 0;
  7573. this.whyDie = "";
  7574. this.clearRadius = false;
  7575. this.circlee = 0;
  7576. };
  7577.  
  7578. // RESET MOVE DIR:
  7579. this.resetMoveDir = function() {
  7580. this.moveDir = undefined;
  7581. };
  7582.  
  7583. // RESET RESOURCES:
  7584. this.resetResources = function(moofoll) {
  7585. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7586. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7587. }
  7588. };
  7589.  
  7590. // SET DATA:
  7591. this.setData = function(data) {
  7592. this.id = data[0];
  7593. this.sid = data[1];
  7594. this.name = data[2];
  7595. this.x = data[3];
  7596. this.y = data[4];
  7597. this.dir = data[5];
  7598. this.health = data[6];
  7599. this.maxHealth = data[7];
  7600. this.scale = data[8];
  7601. this.skinColor = data[9];
  7602. };
  7603.  
  7604.  
  7605. // SHAME SYSTEM:
  7606. this.judgeShame = function() {
  7607. if (this.oldHealth < this.health) {
  7608. if (this.hitTime) {
  7609. let timeSinceHit = this.tick - this.hitTime;
  7610. this.hitTime = 0;
  7611. if (timeSinceHit < 2) {
  7612. this.lastshamecount = this.shameCount;
  7613. this.shameCount++;
  7614. } else {
  7615. this.lastshamecount = this.shameCount;
  7616. this.shameCount = Math.max(0, this.shameCount - 2);
  7617. }
  7618. }
  7619. } else if (this.oldHealth > this.health) {
  7620. this.hitTime = this.tick;
  7621. }
  7622. };
  7623.  
  7624. // CHECK TEAM
  7625. this.isTeam = function (tmpObj) {
  7626. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  7627.  
  7628. };
  7629. // UPDATE WEAPON RELOAD:
  7630. this.manageReloadaa = function() {
  7631. if (this.shooting[53]) {
  7632. this.shooting[53] = 0;
  7633. this.reloads[53] = (2500 - 1000/9);
  7634. } else {
  7635. if (this.reloads[53] > 0) {
  7636. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7637. }
  7638. }
  7639. if (this.gathering || this.shooting[1]) {
  7640. if (this.gathering) {
  7641. this.gathering = 0;
  7642. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7643. this.attacked = true;
  7644. }
  7645. if (this.shooting[1]) {
  7646. this.shooting[1] = 0;
  7647. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7648. this.attacked = true;
  7649. }
  7650. } else {
  7651. this.attacked = false;
  7652. if (this.buildIndex < 0) {
  7653. if (this.reloads[this.weaponIndex] > 0) {
  7654. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7655. }
  7656. }
  7657. }
  7658. };
  7659.  
  7660. this.closeSockets = function(websc) {
  7661. websc.close();
  7662. };
  7663.  
  7664. this.whyDieChat = function(websc, whydie) {
  7665. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  7666. };
  7667. }
  7668. };
  7669.  
  7670. class BotObject {
  7671. constructor(sid) {
  7672. this.sid = sid;
  7673. // INIT:
  7674. this.init = function(x, y, dir, scale, type, data, owner) {
  7675. data = data || {};
  7676. this.active = true;
  7677. this.x = x;
  7678. this.y = y;
  7679. this.scale = scale;
  7680. this.owner = owner;
  7681. this.id = data.id;
  7682. this.dmg = data.dmg;
  7683. this.trap = data.trap;
  7684. this.teleport = data.teleport;
  7685. this.isItem = this.id != undefined;
  7686. };
  7687.  
  7688. }
  7689. };
  7690. class BotObjManager {
  7691. constructor(botObj, fOS) {
  7692. // DISABLE OBJ:
  7693. this.disableObj = function(obj) {
  7694. obj.active = false;
  7695. if (config.anotherVisual) {} else {
  7696. obj.alive = false;
  7697. }
  7698. };
  7699.  
  7700. // ADD NEW:
  7701. let tmpObj;
  7702. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7703. tmpObj = fOS(sid);
  7704. if (!tmpObj) {
  7705. tmpObj = botObj.find((tmp) => !tmp.active);
  7706. if (!tmpObj) {
  7707. tmpObj = new BotObject(sid);
  7708. botObj.push(tmpObj);
  7709. }
  7710. }
  7711. if (setSID) {
  7712. tmpObj.sid = sid;
  7713. }
  7714. tmpObj.init(x, y, dir, s, type, data, owner);
  7715. };
  7716.  
  7717. // DISABLE BY SID:
  7718. this.disableBySid = function(sid) {
  7719. let find = fOS(sid);
  7720. if (find) {
  7721. this.disableObj(find);
  7722. }
  7723. };
  7724.  
  7725. // REMOVE ALL FROM PLAYER:
  7726. this.removeAllItems = function(sid, server) {
  7727. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7728. };
  7729. }
  7730. };
  7731.  
  7732. let botz = [];
  7733.  
  7734. function botSpawn(id) {
  7735. let bot;
  7736. console.log(WS);
  7737. let t = WS.url.split("wss://")[1].split("?")[0];
  7738. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7739. let botPlayer = new Map();
  7740. botSkts.push([botPlayer]);
  7741. botz.push([bot]);
  7742. let botSID;
  7743. let botObj = [];
  7744. let nearObj = [];
  7745. let bD = {
  7746. x: 0,
  7747. y: 0,
  7748. inGame: false,
  7749. closeSocket: false,
  7750. whyDie: ""
  7751. };
  7752. let oldXY = {
  7753. x: 0,
  7754. y: 0,
  7755. };
  7756. let izauto = 0;
  7757. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7758. bot.binaryType = "arraybuffer";
  7759. bot.first = true;
  7760. bot.sendWS = function(type) {
  7761. // EXTRACT DATA ARRAY:
  7762. let data = Array.prototype.slice.call(arguments, 1);
  7763. // SEND MESSAGE:
  7764. let binary = window.msgpack.encode([type, data]);
  7765. bot.send(binary);
  7766. };
  7767. bot.spawn = function() {
  7768. bot.sendWS("M", {
  7769. name: "Trash Slave",
  7770. moofoll: 1,
  7771. skin: "__proto__"
  7772. });
  7773. };
  7774. bot.sendUpgrade = function(index) {
  7775. bot.sendWS("H", index);
  7776. };
  7777. bot.place = function(id, a) {
  7778. try {
  7779. let item = items.list[botPlayer.items[id]];
  7780. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7781. bot.sendWS("G", botPlayer.items[id]);
  7782. bot.sendWS("d", 1, a);
  7783. bot.sendWS("G", botPlayer.weaponIndex, true);
  7784. }
  7785. } catch (e) {
  7786. }
  7787. };
  7788. bot.buye = function(id, index) {
  7789. let nID = 0;
  7790. if (botPlayer.alive && botPlayer.inGame) {
  7791. if (index == 0) {
  7792. if (botPlayer.skins[id]) {
  7793. if (botPlayer.latestSkin != id) {
  7794. bot.sendWS("c", 0, id, 0);
  7795. }
  7796. } else {
  7797. let find = findID(hats, id);
  7798. if (find) {
  7799. if (botPlayer.points >= find.price) {
  7800. bot.sendWS("c", 1, id, 0);
  7801. bot.sendWS("c", 0, id, 0);
  7802. } else {
  7803. if (botPlayer.latestSkin != nID) {
  7804. bot.sendWS("c", 0, nID, 0);
  7805. }
  7806. }
  7807. } else {
  7808. if (botPlayer.latestSkin != nID) {
  7809. bot.sendWS("c", 0, nID, 0);
  7810. }
  7811. }
  7812. }
  7813. } else if (index == 1) {
  7814. if (botPlayer.tails[id]) {
  7815. if (botPlayer.latestTail != id) {
  7816. bot.sendWS("c", 0, id, 1);
  7817. }
  7818. } else {
  7819. let find = findID(accessories, id);
  7820. if (find) {
  7821. if (botPlayer.points >= find.price) {
  7822. bot.sendWS("c", 1, id, 1);
  7823. bot.sendWS("c", 0, id, 1);
  7824. } else {
  7825. if (botPlayer.latestTail != 0) {
  7826. bot.sendWS("c", 0, 0, 1);
  7827. }
  7828. }
  7829. } else {
  7830. if (botPlayer.latestTail != 0) {
  7831. bot.sendWS("c", 0, 0, 1);
  7832. }
  7833. }
  7834. }
  7835. }
  7836. }
  7837. };
  7838. bot.fastGear = function() {
  7839. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7840. bot.buye(31, 0);
  7841. } else {
  7842. if (botPlayer.y2 <= config.snowBiomeTop) {
  7843. bot.buye(15, 0);
  7844. } else {
  7845. bot.buye(12, 0);
  7846. }
  7847. }
  7848. };
  7849. bot.selectWeapon = function(a) {
  7850. packet("z", a, 1);
  7851. }
  7852. function caf(e, t) {
  7853. try {
  7854. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7855. } catch (e) {
  7856. return 0;
  7857. }
  7858. }
  7859. bot.heal = function() {
  7860. if (botPlayer.health < 100) {
  7861. bot.place(0, 0)
  7862. }
  7863. }
  7864. function cdf (e, t){
  7865. try {
  7866. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  7867. } catch(e){
  7868. return Infinity;
  7869. }
  7870. }
  7871. let zoon = 'no';
  7872. bot.zync = function(a) {
  7873. if (!botPlayer.millPlace) {
  7874. zoon = 'yeah';
  7875. bot.place(5, caf(botPlayer, a));
  7876. let NextTickLocation = {
  7877. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7878. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7879. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7880. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7881. };
  7882.  
  7883. function calculateDistance(x1, y1, x2, y2) {
  7884. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  7885. return distance;
  7886. }
  7887. function dotherezt() {
  7888. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7889. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  7890. }
  7891.  
  7892. let aa = setInterval(() => {
  7893. bot.sendWS("G", botPlayer.weapons[1], true);
  7894. if (izauto == 0) {
  7895. bot.sendWS("K", 1);
  7896. izauto = 1;
  7897. }
  7898. setTimeout(() => {
  7899. bot.sendWS("G", botPlayer.weapons[0], true);
  7900. }, 2000);
  7901. bot.buye(53, 0);
  7902. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  7903. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  7904. } else {
  7905. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7906. zoon = 'no';
  7907. bot.sendWS("a", undefined);
  7908. dotherezt();
  7909. clearInterval(aa);
  7910. }
  7911. }, 150);
  7912.  
  7913. setTimeout(() => {
  7914. zoon = 'no';
  7915. clearInterval(aa);
  7916. }, 500);
  7917. }
  7918. };
  7919. bot.onmessage = function(message) {
  7920. let data = new Uint8Array(message.data);
  7921. let parsed = window.msgpack.decode(data);
  7922. let type = parsed[0];
  7923. data = parsed[1];
  7924. if (type == "io-init") {
  7925. bot.spawn();
  7926. }
  7927. if (type == "1") {
  7928. botSID = data[0];
  7929. console.log(botSID)
  7930. }
  7931. if (type == "D") {
  7932. if (data[1]) {
  7933. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  7934. botPlayer.setData(data[0]);
  7935. botPlayer.inGame = true;
  7936. botPlayer.alive = true;
  7937. botPlayer.x2 = undefined;
  7938. botPlayer.y2 = undefined;
  7939. botPlayer.spawn(1);
  7940. botPlayer.oldHealth = 100;
  7941. botPlayer.health = 100;
  7942. botPlayer.showName = 'YEAHHH';
  7943. oldXY = {
  7944. x: data[0][3],
  7945. y: data[0][4]
  7946. }
  7947. bD.inGame = true;
  7948. if (bot.first) {
  7949. bot.first = false;
  7950. bots.push(bD);
  7951. }
  7952. }
  7953. }
  7954. if (type == "P") {
  7955. bot.spawn();
  7956. botPlayer.inGame = false;
  7957. bD.inGame = false;
  7958. }
  7959. if (type == "a") {
  7960. let tmpData = data[0];
  7961. botPlayer.tick++;
  7962. botPlayer.enemy = [];
  7963. botPlayer.near = [];
  7964. bot.showName = 'YEAHHH';
  7965. nearObj = [];
  7966. for (let i = 0; i < tmpData.length;) {
  7967. if (tmpData[i] == botPlayer.sid) {
  7968. botPlayer.x2 = tmpData[i + 1];
  7969. botPlayer.y2 = tmpData[i + 2];
  7970. botPlayer.d2 = tmpData[i + 3];
  7971. botPlayer.buildIndex = tmpData[i + 4];
  7972. botPlayer.weaponIndex = tmpData[i + 5];
  7973. botPlayer.weaponVariant = tmpData[i + 6];
  7974. botPlayer.team = tmpData[i + 7];
  7975. botPlayer.isLeader = tmpData[i + 8];
  7976. botPlayer.skinIndex = tmpData[i + 9];
  7977. botPlayer.tailIndex = tmpData[i + 10];
  7978. botPlayer.iconIndex = tmpData[i + 11];
  7979. botPlayer.zIndex = tmpData[i + 12];
  7980. botPlayer.visible = true;
  7981. bD.x2 = botPlayer.x2;
  7982. bD.y2 = botPlayer.y2;
  7983. }
  7984. i += 13;
  7985. }
  7986.  
  7987. for (let i = 0; i < tmpData.length;) {
  7988. tmpObj = findPlayerBySID(tmpData[i]);
  7989. if (tmpObj) {
  7990. if (!tmpObj.isTeam(botPlayer)) {
  7991. enemy.push(tmpObj);
  7992. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  7993. nears.push(tmpObj);
  7994. }
  7995. }
  7996. }
  7997. i += 13;
  7998. }
  7999.  
  8000. if (enemy.length) {
  8001. //console.log(enemy)
  8002. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8003. return tmp1.dist2 - tmp2.dist2;
  8004. })[0];
  8005. }
  8006.  
  8007. if (izauto == 1) {
  8008. bot.sendWS("K", 1);
  8009. izauto = 0;
  8010. }
  8011.  
  8012. if (bD.closeSocket) {
  8013. botPlayer.closeSockets(bot);
  8014. }
  8015. if (bD.whyDie != "") {
  8016. botPlayer.whyDieChat(bot, bD.whyDie);
  8017. bD.whyDie = "";
  8018. }
  8019. if (botPlayer.alive) {
  8020. if (player.team) {
  8021. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8022. botPlayer.team && (bot.sendWS("N"));
  8023. bot.sendWS("b", player.team);
  8024. }
  8025. }
  8026.  
  8027. let item = items.list[botPlayer.items[3]];
  8028. let a = botPlayer.itemCounts[item.group.id]
  8029. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8030. if (botPlayer.inGame) {
  8031. bot.sendWS("D", botPlayer.moveDir);
  8032. if (izauto == 0) {
  8033. bot.sendWS("K", 1);
  8034. izauto = 1;
  8035. }
  8036. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8037. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8038. bot.place(3, aim + 7.7);
  8039. bot.place(3, aim - 7.7);
  8040. bot.place(3, aim);
  8041. oldXY = {
  8042. x: botPlayer.x2,
  8043. y: botPlayer.y2
  8044. };
  8045. }
  8046.  
  8047. if (botPlayer.tick % 90 === 0) {
  8048. let rand = Math.random() * Math.PI * 2;
  8049. botPlayer.moveDir = rand;
  8050. bot.sendWS("a", botPlayer.moveDir);
  8051. }
  8052. }
  8053. bot.fastGear();
  8054. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  8055. botPlayer.millPlace = false;
  8056. // bot.sendWS("K", 1);
  8057. bot.fastGear();
  8058. } else {
  8059. if (botPlayer.inGame) {
  8060. if (botObj.length > 0) {
  8061. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8062. if (getEl("mode").value == 'fuckemup') {
  8063. // if (getEl("mode").value == "clear") {
  8064. bot.selectWeapon(botPlayer.weapons[1]);
  8065. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8066. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8067. 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) {
  8068. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8069. })[0];
  8070. if (nearObj) {
  8071. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8072. if ((gotoDist - isPassed) > 0) {
  8073. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8074. if (botPlayer.moveDir != undefined) {
  8075. botPlayer.moveDir = undefined;
  8076. bot.sendWS("a", botPlayer.moveDir);
  8077. bot.sendWS("D", botPlayer.nDir);
  8078. }
  8079. } else {
  8080. botPlayer.moveDir = gotoAim;
  8081. bot.sendWS("a", botPlayer.moveDir);
  8082. bot.sendWS("D", botPlayer.nDir);
  8083. }
  8084. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8085. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8086. bot.sendWS("D", botPlayer.nDir);
  8087. }
  8088. if (izauto == 0) {
  8089. bot.sendWS("K", 1);
  8090. izauto = 1;
  8091. }
  8092. bot.buye(40, 0);
  8093. } else {
  8094. botPlayer.moveDir = gotoAim;
  8095. bot.sendWS("a", botPlayer.moveDir);
  8096. bot.sendWS("D", botPlayer.nDir);
  8097. bot.fastGear();
  8098. }
  8099. } else {
  8100. botPlayer.moveDir = gotoAim;
  8101. bot.sendWS("a", botPlayer.moveDir);
  8102. bot.sendWS("D", botPlayer.nDir);
  8103. bot.fastGear();
  8104. }
  8105. }
  8106. }
  8107.  
  8108.  
  8109.  
  8110. if (botObj.length > 0) {
  8111. if (getEl("mode").value == 'flex') {
  8112. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  8113. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  8114. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  8115.  
  8116. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  8117.  
  8118. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  8119. if (dist > 22) // 22 is player speed without booster hat
  8120. return;
  8121. }
  8122. }
  8123.  
  8124.  
  8125. if (botObj.length > 0) {
  8126. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8127. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8128. })[0];
  8129.  
  8130. if (nearObj) {
  8131. if (izauto == 0) {
  8132. bot.sendWS("K", 1);
  8133. izauto = 1;
  8134. }
  8135. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8136. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8137. bot.sendWS("D", botPlayer.nDir);
  8138. }
  8139. bot.buye(40, 0);
  8140. bot.buye(11, 1);
  8141. } else {
  8142. bot.fastGear();
  8143. bot.buye(11, 1);
  8144. }
  8145. bot.buye(11, 1);
  8146. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8147. // if (getEl("mode").value == "clear") {
  8148. bot.selectWeapon(botPlayer.weapons[1]);
  8149. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8150. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8151. 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) {
  8152. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8153. })[0];
  8154. if (nearObj) {
  8155. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8156. if ((gotoDist - isPassed) > 0) {
  8157. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8158. if (botPlayer.moveDir != undefined) {
  8159. botPlayer.moveDir = undefined;
  8160. bot.sendWS("a", botPlayer.moveDir);
  8161. bot.sendWS("D", botPlayer.nDir);
  8162. }
  8163. } else {
  8164. botPlayer.moveDir = gotoAim;
  8165. bot.sendWS("a", botPlayer.moveDir);
  8166. bot.sendWS("D", botPlayer.nDir);
  8167. }
  8168. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8169. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8170. bot.sendWS("D", botPlayer.nDir);
  8171. }
  8172. if (izauto == 0) {
  8173. bot.sendWS("K", 1);
  8174. izauto = 1;
  8175. }
  8176. bot.buye(40, 0);
  8177. bot.fastGear();
  8178. } else {
  8179. botPlayer.moveDir = gotoAim;
  8180. bot.sendWS("a", botPlayer.moveDir);
  8181. bot.sendWS("D", botPlayer.nDir);
  8182. bot.fastGear();
  8183. }
  8184. } else {
  8185. botPlayer.moveDir = gotoAim;
  8186. bot.sendWS("a", botPlayer.moveDir);
  8187. bot.sendWS("D", botPlayer.nDir);
  8188. bot.fastGear();
  8189. }
  8190. if (gotoDist > 300) {
  8191. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8192. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8193. bot.place(3, aim + 7.7);
  8194. bot.place(3, aim - 7.7);
  8195. bot.place(3, aim);
  8196. oldXY = {
  8197. x: botPlayer.x2,
  8198. y: botPlayer.y2
  8199. };
  8200. }
  8201. }
  8202. }
  8203. }
  8204.  
  8205. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8206. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  8207.  
  8208. if(!wdaawdwad.length) {
  8209. if(zoon == 'no')
  8210. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8211. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8212. }
  8213.  
  8214. if(wdaawdwad.length) {
  8215. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8216. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8217. 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) {
  8218. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8219. })[0];
  8220. if (nearObj) {
  8221. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8222. if ((gotoDist - isPassed) > 0) {
  8223. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8224. if (botPlayer.moveDir != undefined) {
  8225. botPlayer.moveDir = undefined;
  8226. bot.sendWS("a", botPlayer.moveDir);
  8227. bot.sendWS("D", botPlayer.nDir);
  8228. }
  8229. } else {
  8230. bot.sendWS("D", botPlayer.nDir);
  8231. }
  8232. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8233. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8234. bot.sendWS("D", botPlayer.nDir);
  8235. }
  8236. if (izauto == 0) {
  8237. bot.sendWS("K", 1);
  8238. izauto = 1;
  8239. }
  8240. bot.buye(40, 0);
  8241. bot.fastGear();
  8242. } else {
  8243. if(zoon == 'no')
  8244. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8245. if(cdf(player, botPlayer) <= 110)
  8246. bot.sendWS("a", undefined);
  8247. else
  8248. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8249. }
  8250. } else {
  8251. if(wdaawdwad.length) {
  8252. if(zoon == 'no')
  8253. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  8254. if(cdf(player, botPlayer) <= 110)
  8255. bot.sendWS("a", undefined);
  8256. else
  8257. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8258. } else {
  8259. if(zoon == 'no')
  8260. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8261. if(cdf(player, botPlayer) <= 110)
  8262. bot.sendWS("a", undefined);
  8263. else
  8264. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8265. }
  8266. }
  8267. }
  8268. }
  8269. }
  8270. }
  8271. }
  8272. }
  8273. if (type == "H") {
  8274. let tmpData = data[0];
  8275. for (let i = 0; i < tmpData.length;) {
  8276. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8277. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8278. sid: tmpData[i + 7]
  8279. } : null));
  8280. i += 8;
  8281. }
  8282. }
  8283. if (type == "N") {
  8284. let index = data[0];
  8285. let value = data[1];
  8286. if (botPlayer) {
  8287. botPlayer[index] = value;
  8288. }
  8289. }
  8290. if (type == "O") {
  8291. if (data[0] == botPlayer.sid) {
  8292. botPlayer.oldHealth = botPlayer.health;
  8293. botPlayer.health = data[1];
  8294. botPlayer.judgeShame();
  8295. if (botPlayer.oldHealth > botPlayer.health) {
  8296. if (botPlayer.shameCount < 5) {
  8297. for (let i = 0; i < 2; i++) {
  8298. bot.place(0, botPlayer.nDir);
  8299. }
  8300.  
  8301. } else {
  8302. setTimeout(() => {
  8303. for (let i = 0; i < 2; i++) {
  8304. bot.place(0, botPlayer.nDir);
  8305. }
  8306. }, 95);
  8307. }
  8308. }
  8309. }
  8310. }
  8311. if (type == "Q") {
  8312. let sid = data[0];
  8313. botObjManager.disableBySid(sid);
  8314. }
  8315. if (type == "R") {
  8316. let sid = data[0];
  8317. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8318. }
  8319. if (type == "S") {
  8320. let index = data[0];
  8321. let value = data[1];
  8322. if (botPlayer) {
  8323. botPlayer.itemCounts[index] = value;
  8324. }
  8325. }
  8326. if (type == "U") {
  8327. if (data[0] > 0) {
  8328. if(getEl("setup").value == 'dm') {
  8329. if (botPlayer.upgraded == 0) {
  8330. bot.sendUpgrade(7);
  8331. } else if (botPlayer.upgraded == 1) {
  8332. bot.sendUpgrade(17);
  8333. } else if (botPlayer.upgraded == 2) {
  8334. bot.sendUpgrade(31);
  8335. } else if (botPlayer.upgraded == 3) {
  8336. bot.sendUpgrade(23);
  8337. } else if (botPlayer.upgraded == 4) {
  8338. bot.sendUpgrade(9);
  8339. } else if (botPlayer.upgraded == 5) {
  8340. bot.sendUpgrade(34);
  8341. } else if (botPlayer.upgraded == 6) {
  8342. bot.sendUpgrade(12);
  8343. } else if (botPlayer.upgraded == 7) {
  8344. bot.sendUpgrade(15);
  8345. }
  8346. } else if(getEl("setup").value == 'dr') {
  8347. if (botPlayer.upgraded == 0) {
  8348. bot.sendUpgrade(7);
  8349. } else if (botPlayer.upgraded == 1) {
  8350. bot.sendUpgrade(17);
  8351. } else if (botPlayer.upgraded == 2) {
  8352. bot.sendUpgrade(31);
  8353. } else if (botPlayer.upgraded == 3) {
  8354. bot.sendUpgrade(23);
  8355. } else if (botPlayer.upgraded == 4) {
  8356. bot.sendUpgrade(9);
  8357. } else if (botPlayer.upgraded == 5) {
  8358. bot.sendUpgrade(34);
  8359. } else if (botPlayer.upgraded == 6) {
  8360. bot.sendUpgrade(12);
  8361. } else if (botPlayer.upgraded == 7) {
  8362. bot.sendUpgrade(13);
  8363. }
  8364. } else if(getEl("setup").value == 'kh') {
  8365. if (botPlayer.upgraded == 0) {
  8366. bot.sendUpgrade(3);
  8367. } else if (botPlayer.upgraded == 1) {
  8368. bot.sendUpgrade(17);
  8369. } else if (botPlayer.upgraded == 2) {
  8370. bot.sendUpgrade(31);
  8371. } else if (botPlayer.upgraded == 3) {
  8372. bot.sendUpgrade(27);
  8373. } else if (botPlayer.upgraded == 4) {
  8374. bot.sendUpgrade(10);
  8375. } else if (botPlayer.upgraded == 5) {
  8376. bot.sendUpgrade(34);
  8377. } else if (botPlayer.upgraded == 6) {
  8378. bot.sendUpgrade(4);
  8379. } else if (botPlayer.upgraded == 7) {
  8380. bot.sendUpgrade(25);
  8381. }
  8382. } else if(getEl("setup").value == 'zd') {
  8383. if (botPlayer.upgraded == 0) {
  8384. bot.sendUpgrade(3);
  8385. } else if (botPlayer.upgraded == 1) {
  8386. bot.sendUpgrade(17);
  8387. } else if (botPlayer.upgraded == 2) {
  8388. bot.sendUpgrade(31);
  8389. } else if (botPlayer.upgraded == 3) {
  8390. bot.sendUpgrade(27);
  8391. } else if (botPlayer.upgraded == 4) {
  8392. bot.sendUpgrade(9);
  8393. } else if (botPlayer.upgraded == 5) {
  8394. bot.sendUpgrade(34);
  8395. } else if (botPlayer.upgraded == 6) {
  8396. bot.sendUpgrade(12);
  8397. } else if (botPlayer.upgraded == 7) {
  8398. bot.sendUpgrade(15);
  8399. }
  8400. }
  8401. botPlayer.upgraded++;
  8402. }
  8403. }
  8404. if (type == "V") {
  8405. let tmpData = data[0];
  8406. let wpn = data[1];
  8407. if (tmpData) {
  8408. if (wpn) botPlayer.weapons = tmpData;
  8409. else botPlayer.items = tmpData;
  8410. }
  8411.  
  8412. }
  8413. if (type == "5") {
  8414. let type = data[0];
  8415. let id = data[1];
  8416. let index = data[2];
  8417. if (index) {
  8418. if (!type)
  8419. botPlayer.tails[id] = 1;
  8420. else
  8421. botPlayer.latestTail = id;
  8422. } else {
  8423. if (!type)
  8424. botPlayer.skins[id] = 1;
  8425. else
  8426. botPlayer.latestSkin = id;
  8427. }
  8428. }
  8429.  
  8430. if (type == "6") {
  8431. let id = data[0];
  8432. let mzg = data[1]+'';
  8433. if(id == player.sid && mzg.includes("Sync")) {
  8434. bot.zync(botPlayer.near);
  8435. }
  8436. }
  8437. };
  8438. bot.onclose = function() {
  8439. botPlayer.inGame = false;
  8440. bD.inGame = false;
  8441. };
  8442. }
  8443.  
  8444. // RENDER LEAF:
  8445. function renderLeaf(x, y, l, r, ctxt) {
  8446. let endX = x + (l * Math.cos(r));
  8447. let endY = y + (l * Math.sin(r));
  8448. let width = l * 0.4;
  8449. ctxt.moveTo(x, y);
  8450. ctxt.beginPath();
  8451. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8452. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8453. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8454. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8455. ctxt.closePath();
  8456. ctxt.fill();
  8457. ctxt.stroke();
  8458. }
  8459.  
  8460. // RENDER CIRCLE:
  8461. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8462. tmpContext = tmpContext || mainContext;
  8463. tmpContext.beginPath();
  8464. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8465. if (!dontFill) tmpContext.fill();
  8466. if (!dontStroke) tmpContext.stroke();
  8467. }
  8468.  
  8469. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8470. tmpContext = tmpContext || mainContext;
  8471. tmpContext.beginPath();
  8472. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8473. if (!dontFill) tmpContext.fill();
  8474. if (!dontStroke) tmpContext.stroke();
  8475. }
  8476.  
  8477. // RENDER STAR SHAPE:
  8478. function renderStar(ctxt, spikes, outer, inner) {
  8479. let rot = Math.PI / 2 * 3;
  8480. let x, y;
  8481. let step = Math.PI / spikes;
  8482. ctxt.beginPath();
  8483. ctxt.moveTo(0, -outer);
  8484. for (let i = 0; i < spikes; i++) {
  8485. x = Math.cos(rot) * outer;
  8486. y = Math.sin(rot) * outer;
  8487. ctxt.lineTo(x, y);
  8488. rot += step;
  8489. x = Math.cos(rot) * inner;
  8490. y = Math.sin(rot) * inner;
  8491. ctxt.lineTo(x, y);
  8492. rot += step;
  8493. }
  8494. ctxt.lineTo(0, -outer);
  8495. ctxt.closePath();
  8496. }
  8497.  
  8498. function renderHealthStar(ctxt, spikes, outer, inner) {
  8499. let rot = Math.PI / 2 * 3;
  8500. let x, y;
  8501. let step = Math.PI / spikes;
  8502. ctxt.beginPath();
  8503. ctxt.moveTo(0, -outer);
  8504. for (let i = 0; i < spikes; i++) {
  8505. x = Math.cos(rot) * outer;
  8506. y = Math.sin(rot) * outer;
  8507. ctxt.lineTo(x, y);
  8508. rot += step;
  8509. x = Math.cos(rot) * inner;
  8510. y = Math.sin(rot) * inner;
  8511. ctxt.lineTo(x, y);
  8512. rot += step;
  8513. }
  8514. ctxt.lineTo(0, -outer);
  8515. ctxt.closePath();
  8516. }
  8517.  
  8518. // RENDER RECTANGLE:
  8519. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8520. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8521. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8522. }
  8523.  
  8524. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8525. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8526. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8527. }
  8528.  
  8529. // RENDER RECTCIRCLE:
  8530. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8531. ctxt.save();
  8532. ctxt.translate(x, y);
  8533. seg = Math.ceil(seg / 2);
  8534. for (let i = 0; i < seg; i++) {
  8535. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8536. ctxt.rotate(Math.PI / seg);
  8537. }
  8538. ctxt.restore();
  8539. }
  8540.  
  8541. // RENDER BLOB:
  8542. function renderBlob(ctxt, spikes, outer, inner) {
  8543. let rot = Math.PI / 2 * 3;
  8544. let x, y;
  8545. let step = Math.PI / spikes;
  8546. let tmpOuter;
  8547. ctxt.beginPath();
  8548. ctxt.moveTo(0, -inner);
  8549. for (let i = 0; i < spikes; i++) {
  8550. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8551. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8552. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8553. rot += step * 2;
  8554. }
  8555. ctxt.lineTo(0, -inner);
  8556. ctxt.closePath();
  8557. }
  8558.  
  8559. // RENDER TRIANGLE:
  8560. function renderTriangle(s, ctx) {
  8561. ctx = ctx || mainContext;
  8562. let h = s * (Math.sqrt(3) / 2);
  8563. ctx.beginPath();
  8564. ctx.moveTo(0, -h / 2);
  8565. ctx.lineTo(-s / 2, h / 2);
  8566. ctx.lineTo(s / 2, h / 2);
  8567. ctx.lineTo(0, -h / 2);
  8568. ctx.fill();
  8569. ctx.closePath();
  8570. }
  8571.  
  8572. // PREPARE MENU BACKGROUND:
  8573. function prepareMenuBackground() {
  8574. let tmpMid = config.mapScale / 2;
  8575. let attempts = 0;
  8576. for (let i = 0; i < items.list.length * 3;) {
  8577. if (attempts >= 1000) break;
  8578. attempts++;
  8579. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8580. let data = {
  8581. x: tmpMid + UTILS.randFloat(-1000, 1000),
  8582. y: tmpMid + UTILS.randFloat(-600, 600),
  8583. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8584. };
  8585. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8586. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8587. } else {
  8588. continue;
  8589. }
  8590. i++;
  8591. }
  8592. }
  8593. const speed = 35;
  8594. // RENDER PLAYERS:
  8595. function renderDeadPlayers(xOffset, yOffset) {
  8596. mainContext.fillStyle = "#91b2db";
  8597. const currentTime = Date.now();
  8598. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8599. if (!dead.startTime) {
  8600. dead.startTime = currentTime;
  8601. dead.angle = 0;
  8602. dead.radius = 0.1;
  8603. }
  8604. const timeElapsed = currentTime - dead.startTime;
  8605. const maxAlpha = 1;
  8606. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8607. dead.animate(delta);
  8608. mainContext.globalAlpha = dead.alpha;
  8609. mainContext.strokeStyle = outlineColor;
  8610. mainContext.save();
  8611. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8612. dead.radius -= 0.001;
  8613. dead.angle += 0.0174533;
  8614. const moveSpeed = 1;
  8615. const x = dead.radius * Math.cos(dead.angle);
  8616. const y = dead.radius * Math.sin(dead.angle);
  8617. dead.x += x * moveSpeed;
  8618. dead.y += y * moveSpeed;
  8619. mainContext.rotate(dead.angle);
  8620. renderDeadPlayer(dead, mainContext);
  8621. mainContext.restore();
  8622. mainContext.fillStyle = "#91b2db";
  8623. if (timeElapsed >= 3000) {
  8624. dead.active = false;
  8625. dead.startTime = null;
  8626. }
  8627. });
  8628. }
  8629. // RENDER PLAYERS:
  8630. function renderPlayers(xOffset, yOffset, zIndex) {
  8631. mainContext.globalAlpha = 1;
  8632. mainContext.fillStyle = "#91b2db";
  8633. for (var i = 0; i < players.length; ++i) {
  8634. tmpObj = players[i];
  8635. if (tmpObj.zIndex == zIndex) {
  8636. tmpObj.animate(delta);
  8637. if (tmpObj.visible) {
  8638. tmpObj.skinRot += (0.002 * delta);
  8639. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  8640. mainContext.save();
  8641. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8642. // RENDER PLAYER:
  8643. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8644. renderPlayer(tmpObj, mainContext);
  8645. mainContext.restore();
  8646.  
  8647. }
  8648. }
  8649. }
  8650. }
  8651. // RENDER DEAD PLAYER:
  8652. function renderDeadPlayer(obj, ctxt) {
  8653. ctxt = ctxt || mainContext;
  8654. ctxt.lineWidth = outlineWidth;
  8655. ctxt.lineJoin = "miter";
  8656. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8657. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8658. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8659. // TAIL/CAPE:
  8660. renderTail2(13, ctxt, obj);
  8661. // WEAPON BELLOW HANDS:
  8662. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8663. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8664. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8665. renderProjectile(obj.scale, 0,
  8666. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8667. }
  8668. }
  8669. // HANDS:
  8670. ctxt.fillStyle = "#ececec";
  8671. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8672. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8673. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8674. // WEAPON ABOVE HANDS:
  8675. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8676. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8677. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8678. renderProjectile(obj.scale, 0,
  8679. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8680. }
  8681. }
  8682. // BUILD ITEM:
  8683. if (obj.buildIndex >= 0) {
  8684. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8685. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8686. }
  8687. // BODY:
  8688. renderCircle(0, 0, obj.scale, ctxt);
  8689. // SKIN
  8690. renderSkin2(48, ctxt, null, obj)
  8691. }
  8692.  
  8693. // RENDER PLAYER:
  8694. function renderPlayer(obj, ctxt) {
  8695. ctxt = ctxt || mainContext;
  8696. ctxt.lineWidth = outlineWidth;
  8697. ctxt.lineJoin = "miter";
  8698. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8699. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8700. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8701.  
  8702. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8703.  
  8704. // TAIL/CAPE:
  8705. if (obj.tailIndex > 0) {
  8706. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8707. }
  8708.  
  8709. // WEAPON BELLOW HANDS:
  8710. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8711. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8712. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8713. renderProjectile(obj.scale, 0,
  8714. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8715. }
  8716. }
  8717.  
  8718. // HANDS:
  8719. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8720. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8721. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8722. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8723.  
  8724. // WEAPON ABOVE HANDS:
  8725. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8726. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8727. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8728. renderProjectile(obj.scale, 0,
  8729. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8730. }
  8731. }
  8732.  
  8733. // BUILD ITEM:
  8734. if (obj.buildIndex >= 0) {
  8735. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8736. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8737. }
  8738.  
  8739. // BODY:
  8740. renderCircle(0, 0, obj.scale, ctxt);
  8741.  
  8742. // SKIN:
  8743. if (obj.skinIndex > 0) {
  8744. ctxt.rotate(Math.PI / 2);
  8745. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8746. }
  8747.  
  8748. }
  8749.  
  8750. // RENDER NORMAL SKIN
  8751. var skinSprites2 = {};
  8752. var skinPointers2 = {};
  8753. function renderSkin2(index, ctxt, parentSkin, owner) {
  8754. tmpSkin = skinSprites2[index];
  8755. if (!tmpSkin) {
  8756. var tmpImage = new Image();
  8757. tmpImage.onload = function() {
  8758. this.isLoaded = true;
  8759. this.onload = null;
  8760. };
  8761. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8762. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8763. skinSprites2[index] = tmpImage;
  8764. tmpSkin = tmpImage;
  8765. }
  8766. var tmpObj = parentSkin||skinPointers2[index];
  8767. if (!tmpObj) {
  8768. for (var i = 0; i < hats.length; ++i) {
  8769. if (hats[i].id == index) {
  8770. tmpObj = hats[i];
  8771. break;
  8772. }
  8773. }
  8774. skinPointers2[index] = tmpObj;
  8775. }
  8776. if (tmpSkin.isLoaded)
  8777. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8778. if (!parentSkin && tmpObj.topSprite) {
  8779. ctxt.save();
  8780. ctxt.rotate(owner.skinRot);
  8781. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8782. ctxt.restore();
  8783. }
  8784. }
  8785.  
  8786. // RENDER SKIN:
  8787. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8788. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8789. var tmpImage = new Image();
  8790. tmpImage.onload = function() {
  8791. this.isLoaded = true,
  8792. this.onload = null
  8793. }
  8794. ,
  8795. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8796. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8797. tmpSkin = tmpImage
  8798. }
  8799. var tmpObj = parentSkin||skinPointers[index];
  8800. if (!tmpObj) {
  8801. for (var i = 0; i < hats.length; ++i) {
  8802. if (hats[i].id == index) {
  8803. tmpObj = hats[i];
  8804. break;
  8805. }
  8806. }
  8807. skinPointers[index] = tmpObj;
  8808. }
  8809. if (tmpSkin.isLoaded)
  8810. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8811. if (!parentSkin && tmpObj.topSprite) {
  8812. ctxt.save();
  8813. ctxt.rotate(owner.skinRot);
  8814. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8815. ctxt.restore();
  8816. }
  8817. }
  8818.  
  8819. var FlareZHat = {
  8820. 7: "https://i.imgur.com/vAOzlyY.png",
  8821. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8822. 40: "https://i.imgur.com/Xzmg27N.png",
  8823. 26: "https://i.imgur.com/I0xGtyZ.png",
  8824. 55: "https://i.imgur.com/uYgDtcZ.png",
  8825. 20: "https://i.imgur.com/f5uhWCk.png",
  8826. };
  8827.  
  8828. function setSkinTextureImage(id, type, id2) {
  8829. if (true) {
  8830. if(FlareZHat[id] && type == "hat") {
  8831. return FlareZHat[id];
  8832. } else {
  8833. if(type == "acc") {
  8834. return ".././img/accessories/access_" + id + ".png";
  8835. } else if(type == "hat") {
  8836. return ".././img/hats/hat_" + id + ".png";
  8837. } else {
  8838. return ".././img/weapons/" + id + ".png";
  8839. }
  8840. }
  8841. } else {
  8842. if(type == "acc") {
  8843. return ".././img/accessories/access_" + id + ".png";
  8844. } else if(type == "hat") {
  8845. return ".././img/hats/hat_" + id + ".png";
  8846. } else {
  8847. return ".././img/weapons/" + id + ".png";
  8848. }
  8849. }
  8850. }
  8851. // RENDER SKINS:
  8852. let skinSprites = {};
  8853. let skinPointers = {};
  8854. let tmpSkin;
  8855.  
  8856. function renderSkin(index, ctxt, parentSkin, owner) {
  8857. tmpSkin = skinSprites[index];
  8858. if (!tmpSkin) {
  8859. let tmpImage = new Image();
  8860. tmpImage.onload = function() {
  8861. this.isLoaded = true;
  8862. this.onload = null;
  8863. };
  8864. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8865. skinSprites[index] = tmpImage;
  8866. tmpSkin = tmpImage;
  8867. }
  8868. let tmpObj = parentSkin || skinPointers[index];
  8869. if (!tmpObj) {
  8870. for (let i = 0; i < hats.length; ++i) {
  8871. if (hats[i].id == index) {
  8872. tmpObj = hats[i];
  8873. break;
  8874. }
  8875. }
  8876. skinPointers[index] = tmpObj;
  8877. }
  8878. if (tmpSkin.isLoaded)
  8879. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8880. if (!parentSkin && tmpObj.topSprite) {
  8881. ctxt.save();
  8882. ctxt.rotate(owner.skinRot);
  8883. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8884. ctxt.restore();
  8885. }
  8886. }
  8887.  
  8888. // RENDER TAIL:
  8889. var FlareZAcc = {
  8890. 21: "https://i.imgur.com/4ddZert.png",
  8891. 19: "https://i.imgur.com/sULkUZT.png",
  8892. };
  8893. function setTailTextureImage(id, type, id2) {
  8894. if (true) {
  8895. if(FlareZAcc[id] && type == "acc") {
  8896. return FlareZAcc[id];
  8897. } else {
  8898. if(type == "acc") {
  8899. return ".././img/accessories/access_" + id + ".png";
  8900. } else if(type == "hat") {
  8901. return ".././img/hats/hat_" + id + ".png";
  8902. } else {
  8903. return ".././img/weapons/" + id + ".png";
  8904. }
  8905. }
  8906. } else {
  8907. if(type == "acc") {
  8908. return ".././img/accessories/access_" + id + ".png";
  8909. } else if(type == "hat") {
  8910. return ".././img/hats/hat_" + id + ".png";
  8911. } else {
  8912. return ".././img/weapons/" + id + ".png";
  8913. }
  8914. }
  8915. }
  8916. function renderTailTextureImage(index, ctxt, owner) {
  8917. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  8918. var tmpImage = new Image();
  8919. tmpImage.onload = function() {
  8920. this.isLoaded = true,
  8921. this.onload = null
  8922. }
  8923. ,
  8924. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  8925. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8926. tmpSkin = tmpImage;
  8927. }
  8928. var tmpObj = accessPointers[index];
  8929. if (!tmpObj) {
  8930. for (var i = 0; i < accessories.length; ++i) {
  8931. if (accessories[i].id == index) {
  8932. tmpObj = accessories[i];
  8933. break;
  8934. }
  8935. }
  8936. accessPointers[index] = tmpObj;
  8937. }
  8938. if (tmpSkin.isLoaded) {
  8939. ctxt.save();
  8940. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8941. if (tmpObj.spin)
  8942. ctxt.rotate(owner.skinRot);
  8943. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8944. ctxt.restore();
  8945. }
  8946. }
  8947.  
  8948. let accessSprites = {};
  8949. let accessPointers = {};
  8950. var txt = true;
  8951.  
  8952. function renderTail(index, ctxt, owner) {
  8953. tmpSkin = accessSprites[index];
  8954. if (!tmpSkin) {
  8955. let tmpImage = new Image();
  8956. tmpImage.onload = function() {
  8957. this.isLoaded = true;
  8958. this.onload = null;
  8959. };
  8960. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8961. accessSprites[index] = tmpImage;
  8962. tmpSkin = tmpImage;
  8963. }
  8964. let tmpObj = accessPointers[index];
  8965. if (!tmpObj) {
  8966. for (let i = 0; i < accessories.length; ++i) {
  8967. if (accessories[i].id == index) {
  8968. tmpObj = accessories[i];
  8969. break;
  8970. }
  8971. }
  8972. accessPointers[index] = tmpObj;
  8973. }
  8974. if (tmpSkin.isLoaded) {
  8975. ctxt.save();
  8976. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  8977. if (tmpObj.spin)
  8978. ctxt.rotate(owner.skinRot);
  8979. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  8980. ctxt.restore();
  8981. }
  8982. }
  8983.  
  8984. var accessSprites2 = {};
  8985. var accessPointers2 = {};
  8986. function renderTail2(index, ctxt, owner) {
  8987. tmpSkin = accessSprites2[index];
  8988. if (!tmpSkin) {
  8989. var tmpImage = new Image();
  8990. tmpImage.onload = function() {
  8991. this.isLoaded = true;
  8992. this.onload = null;
  8993. };
  8994. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8995. accessSprites2[index] = tmpImage;
  8996. tmpSkin = tmpImage;
  8997. }
  8998. var tmpObj = accessPointers2[index];
  8999. if (!tmpObj) {
  9000. for (var i = 0; i < accessories.length; ++i) {
  9001. if (accessories[i].id == index) {
  9002. tmpObj = accessories[i];
  9003. break;
  9004. }
  9005. }
  9006. accessPointers2[index] = tmpObj;
  9007. }
  9008. if (tmpSkin.isLoaded) {
  9009. ctxt.save();
  9010. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9011. if (tmpObj.spin)
  9012. ctxt.rotate(owner.skinRot);
  9013. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9014. ctxt.restore();
  9015. }
  9016. }
  9017.  
  9018. // RENDER TOOL:
  9019. let toolSprites = {};
  9020. function renderTool(obj, variant, x, y, ctxt) {
  9021. let tmpSrc = obj.src + (variant || "");
  9022. let tmpSprite = toolSprites[tmpSrc];
  9023. if (!tmpSprite) {
  9024. tmpSprite = new Image();
  9025. tmpSprite.onload = function() {
  9026. this.isLoaded = true;
  9027. }
  9028. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9029. toolSprites[tmpSrc] = tmpSprite;
  9030. }
  9031. if (tmpSprite.isLoaded)
  9032. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9033. }
  9034.  
  9035. // RENDER PROJECTILES:
  9036. function renderProjectiles(layer, xOffset, yOffset) {
  9037. for (let i = 0; i < projectiles.length; i++) {
  9038. tmpObj = projectiles[i];
  9039. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9040. tmpObj.update(delta);
  9041. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9042. mainContext.save();
  9043. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9044. mainContext.rotate(tmpObj.dir);
  9045. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9046. mainContext.restore();
  9047. }
  9048. }
  9049. };
  9050. }
  9051.  
  9052. // RENDER PROJECTILE:
  9053. let projectileSprites = {};//fz iz zexy
  9054.  
  9055. function renderProjectile(x, y, obj, ctxt, debug) {
  9056. if (obj.src) {
  9057. let tmpSrc = items.projectiles[obj.indx].src;
  9058. let tmpSprite = projectileSprites[tmpSrc];
  9059. if (!tmpSprite) {
  9060. tmpSprite = new Image();
  9061. tmpSprite.onload = function() {
  9062. this.isLoaded = true;
  9063. }
  9064. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9065. projectileSprites[tmpSrc] = tmpSprite;
  9066. }
  9067. if (tmpSprite.isLoaded)
  9068. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9069. } else if (obj.indx == 1) {
  9070. ctxt.fillStyle = "#939393";
  9071. renderCircle(x, y, obj.scale, ctxt);
  9072. }
  9073. }
  9074.  
  9075. // RENDER AI:
  9076. let aiSprites = {};
  9077.  
  9078. function renderAI(obj, ctxt) {
  9079. let tmpIndx = obj.index;
  9080. let tmpSprite = aiSprites[tmpIndx];
  9081. if (!tmpSprite) {
  9082. let tmpImg = new Image();
  9083. tmpImg.onload = function() {
  9084. this.isLoaded = true;
  9085. this.onload = null;
  9086. };
  9087. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9088. tmpSprite = tmpImg;
  9089. aiSprites[tmpIndx] = tmpSprite;
  9090. }
  9091. if (tmpSprite.isLoaded) {
  9092. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9093. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9094. }
  9095. }
  9096.  
  9097. // RENDER WATER BODIES:
  9098. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9099.  
  9100. // MIDDLE RIVER:
  9101. let tmpW = config.riverWidth + padding;
  9102. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9103. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9104. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9105. }
  9106. }
  9107.  
  9108. // RENDER GAME OBJECTS:
  9109. let gameObjectSprites = {};
  9110.  
  9111. function getResSprite(obj) {
  9112. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  9113. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9114. let tmpSprite = gameObjectSprites[tmpIndex];
  9115. if (!tmpSprite) {
  9116. let blurScale = 0;
  9117. let tmpCanvas = document.createElement("canvas");
  9118. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9119. let tmpContext = tmpCanvas.getContext('2d');
  9120. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9121. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9122. tmpContext.strokeStyle = outlineColor;
  9123. tmpContext.lineWidth = outlineWidth;
  9124. tmpContext.shadowBlur = 3;
  9125. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9126. if (obj.type == 0) {
  9127. let tmpScale;
  9128. let tmpCount = UTILS.randInt(5, 6);
  9129. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  9130. for (let i = 0; i < 2; ++i) {
  9131. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  9132. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9133. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  9134. tmpContext.fill();
  9135. if (!i) {
  9136. tmpContext.stroke();
  9137. tmpContext.shadowBlur = null;
  9138. tmpContext.shadowColor = null;
  9139. tmpContext.globalAlpha = 1;
  9140. }
  9141. }
  9142. } else if (obj.type == 1) {
  9143. if (biomeID == 2) {
  9144. tmpContext.fillStyle = "#606060";
  9145. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9146. tmpContext.fill();
  9147. tmpContext.stroke();
  9148.  
  9149. //tmpContext.shadowBlur = null;
  9150. //tmpContext.shadowColor = null;
  9151.  
  9152. tmpContext.fillStyle = "#89a54c";
  9153. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9154. tmpContext.fillStyle = "#a5c65b";
  9155. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9156. } else {
  9157. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9158. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  9159. tmpContext.fill();
  9160. tmpContext.stroke();
  9161.  
  9162. //tmpContext.shadowBlur = null;
  9163. //tmpContext.shadowColor = null;
  9164.  
  9165. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  9166. let tmpRange;
  9167. let berries = 4;
  9168. let rotVal = (Math.PI * 2) / berries;
  9169. for (let i = 0; i < berries; ++i) {
  9170. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  9171. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9172. UTILS.randInt(10, 12), tmpContext);
  9173. }
  9174. }
  9175. } else if (obj.type == 2 || obj.type == 3) {
  9176. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  9177. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9178. tmpContext.fill();
  9179. tmpContext.stroke();
  9180.  
  9181. tmpContext.shadowBlur = null;
  9182. tmpContext.shadowColor = null;
  9183.  
  9184. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  9185. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9186. tmpContext.fill();
  9187. }
  9188. tmpSprite = tmpCanvas;
  9189. gameObjectSprites[tmpIndex] = tmpSprite;
  9190. }
  9191. return tmpSprite;
  9192. }
  9193.  
  9194. // GET ITEM SPRITE:
  9195. let itemSprites = [];
  9196.  
  9197. function getItemSprite(obj, asIcon) {
  9198. let tmpSprite = itemSprites[obj.id];
  9199. if (!tmpSprite || asIcon) {
  9200. let blurScale = !asIcon ? 20 : 5;
  9201. let tmpCanvas = document.createElement("canvas");
  9202. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9203. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9204.  
  9205. let tmpContext = tmpCanvas.getContext("2d");
  9206. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9207. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9208. tmpContext.strokeStyle = outlineColor;
  9209. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9210. tmpContext.shadowBlur = 2;
  9211. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9212. if (obj.name == "apple") {
  9213. tmpContext.fillStyle = "#c15555";
  9214. renderCircle(0, 0, obj.scale, tmpContext);
  9215. tmpContext.fillStyle = "#89a54c";
  9216. let leafDir = -(Math.PI / 2);
  9217. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9218. 25, leafDir + Math.PI / 2, tmpContext);
  9219. } else if (obj.name == "cookie") {
  9220. tmpContext.fillStyle = "#cca861";
  9221. renderCircle(0, 0, obj.scale, tmpContext);
  9222. tmpContext.fillStyle = "#937c4b";
  9223. let chips = 4;
  9224. let rotVal = (Math.PI * 2) / chips;
  9225. let tmpRange;
  9226. for (let i = 0; i < chips; ++i) {
  9227. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9228. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9229. UTILS.randInt(4, 5), tmpContext, true);
  9230. }
  9231. } else if (obj.name == "cheese") {
  9232. tmpContext.fillStyle = "#f4f3ac";
  9233. renderCircle(0, 0, obj.scale, tmpContext);
  9234. tmpContext.fillStyle = "#c3c28b";
  9235. let chips = 4;
  9236. let rotVal = (Math.PI * 2) / chips;
  9237. let tmpRange;
  9238. for (let i = 0; i < chips; ++i) {
  9239. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9240. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9241. UTILS.randInt(4, 5), tmpContext, true);
  9242. }
  9243. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9244. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9245. "#a5974c" : "#939393";
  9246. let sides = (obj.name == "castle wall") ? 4 : 3;
  9247. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9248. tmpContext.fill();
  9249. tmpContext.stroke();
  9250. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9251. "#c9b758" : "#bcbcbc";
  9252. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9253. tmpContext.fill();
  9254. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9255. obj.name == "spinning spikes") {
  9256. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9257. let tmpScale = (obj.scale * 0.6);
  9258. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9259. tmpContext.fill();
  9260. tmpContext.stroke();
  9261. tmpContext.fillStyle = "#a5974c";
  9262. renderCircle(0, 0, tmpScale, tmpContext);
  9263. tmpContext.fillStyle = "#c9b758";
  9264. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9265. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9266. tmpContext.fillStyle = "#a5974c";
  9267. renderCircle(0, 0, reScale, tmpContext);
  9268. tmpContext.fillStyle = "#c9b758";
  9269. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9270. tmpContext.fillStyle = "#a5974c";
  9271. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9272. } else if (obj.name == "mine") {
  9273. tmpContext.fillStyle = "#939393";
  9274. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9275. tmpContext.fill();
  9276. tmpContext.stroke();
  9277. tmpContext.fillStyle = "#bcbcbc";
  9278. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9279. tmpContext.fill();
  9280. } else if (obj.name == "sapling") {
  9281. for (let i = 0; i < 2; ++i) {
  9282. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9283. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9284. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9285. tmpContext.fill();
  9286. if (!i) tmpContext.stroke();
  9287. }
  9288. } else if (obj.name == "pit trap") {
  9289. tmpContext.fillStyle = "#a5974c";
  9290. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9291. tmpContext.fill();
  9292. tmpContext.stroke();
  9293. tmpContext.fillStyle = outlineColor;
  9294. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9295. tmpContext.fill();
  9296. } else if (obj.name == "boost pad") {
  9297. tmpContext.fillStyle = "#7e7f82";
  9298. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9299. tmpContext.fill();
  9300. tmpContext.stroke();
  9301. tmpContext.fillStyle = "#dbd97d";
  9302. renderTriangle(obj.scale * 1, tmpContext);
  9303. } else if (obj.name == "turret") {
  9304. tmpContext.fillStyle = "#a5974c";
  9305. renderCircle(0, 0, obj.scale, tmpContext);
  9306. tmpContext.fill();
  9307. tmpContext.stroke();
  9308. tmpContext.fillStyle = "#939393";
  9309. let tmpLen = 50;
  9310. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9311. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9312. tmpContext.fill();
  9313. tmpContext.stroke();
  9314. } else if (obj.name == "platform") {
  9315. tmpContext.fillStyle = "#cebd5f";
  9316. let tmpCount = 4;
  9317. let tmpS = obj.scale * 2;
  9318. let tmpW = tmpS / tmpCount;
  9319. let tmpX = -(obj.scale / 2);
  9320. for (let i = 0; i < tmpCount; ++i) {
  9321. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9322. tmpContext.fill();
  9323. tmpContext.stroke();
  9324. tmpX += tmpS / tmpCount;
  9325. }
  9326. } else if (obj.name == "healing pad") {
  9327. tmpContext.fillStyle = "#7e7f82";
  9328. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9329. tmpContext.fill();
  9330. tmpContext.stroke();
  9331. tmpContext.fillStyle = "#db6e6e";
  9332. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9333. } else if (obj.name == "spawn pad") {
  9334. tmpContext.fillStyle = "#7e7f82";
  9335. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9336. tmpContext.fill();
  9337. tmpContext.stroke();
  9338. tmpContext.fillStyle = "#71aad6";
  9339. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9340. } else if (obj.name == "blocker") {
  9341. tmpContext.fillStyle = "#7e7f82";
  9342. renderCircle(0, 0, obj.scale, tmpContext);
  9343. tmpContext.fill();
  9344. tmpContext.stroke();
  9345. tmpContext.rotate(Math.PI / 4);
  9346. tmpContext.fillStyle = "#db6e6e";
  9347. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9348. } else if (obj.name == "teleporter") {
  9349. tmpContext.fillStyle = "#7e7f82";
  9350. renderCircle(0, 0, obj.scale, tmpContext);
  9351. tmpContext.fill();
  9352. tmpContext.stroke();
  9353. tmpContext.rotate(Math.PI / 4);
  9354. tmpContext.fillStyle = "#d76edb";
  9355. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9356. }
  9357. tmpSprite = tmpCanvas;
  9358. if (!asIcon)
  9359. itemSprites[obj.id] = tmpSprite;
  9360. }
  9361. return tmpSprite;
  9362. }
  9363.  
  9364. function getItemSprite2(obj, tmpX, tmpY) {
  9365. let tmpContext = mainContext;
  9366. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9367. tmpContext.save();
  9368. tmpContext.translate(tmpX, tmpY);
  9369. tmpContext.rotate(obj.dir);
  9370. tmpContext.strokeStyle = outlineColor;
  9371. tmpContext.lineWidth = outlineWidth;
  9372. if (obj.name == "apple") {
  9373. tmpContext.fillStyle = "#c15555";
  9374. renderCircle(0, 0, obj.scale, tmpContext);
  9375. tmpContext.fillStyle = "#89a54c";
  9376. let leafDir = -(Math.PI / 2);
  9377. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9378. 25, leafDir + Math.PI / 2, tmpContext);
  9379. } else if (obj.name == "cookie") {
  9380. tmpContext.fillStyle = "#cca861";
  9381. renderCircle(0, 0, obj.scale, tmpContext);
  9382. tmpContext.fillStyle = "#937c4b";
  9383. let chips = 4;
  9384. let rotVal = (Math.PI * 2) / chips;
  9385. let tmpRange;
  9386. for (let i = 0; i < chips; ++i) {
  9387. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9388. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9389. UTILS.randInt(4, 5), tmpContext, true);
  9390. }
  9391. } else if (obj.name == "cheese") {
  9392. tmpContext.fillStyle = "#f4f3ac";
  9393. renderCircle(0, 0, obj.scale, tmpContext);
  9394. tmpContext.fillStyle = "#c3c28b";
  9395. let chips = 4;
  9396. let rotVal = (Math.PI * 2) / chips;
  9397. let tmpRange;
  9398. for (let i = 0; i < chips; ++i) {
  9399. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9400. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9401. UTILS.randInt(4, 5), tmpContext, true);
  9402. }
  9403. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9404. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9405. "#a5974c" : "#939393";
  9406. let sides = (obj.name == "castle wall") ? 4 : 3;
  9407. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9408. tmpContext.fill();
  9409. tmpContext.stroke();
  9410. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9411. "#c9b758" : "#bcbcbc";
  9412. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9413. tmpContext.fill();
  9414. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9415. obj.name == "spinning spikes") {
  9416. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9417. let tmpScale = (obj.scale * 0.6);
  9418. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9419. tmpContext.fill();
  9420. tmpContext.stroke();
  9421. tmpContext.fillStyle = "#a5974c";
  9422. renderCircle(0, 0, tmpScale, tmpContext);
  9423. tmpContext.fillStyle = "#c9b758";
  9424. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9425. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9426. tmpContext.fillStyle = "#a5974c";
  9427. renderCircle(0, 0, reScale, tmpContext);
  9428. tmpContext.fillStyle = "#c9b758";
  9429. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9430. tmpContext.fillStyle = "#a5974c";
  9431. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9432. } else if (obj.name == "mine") {
  9433. tmpContext.fillStyle = "#939393";
  9434. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9435. tmpContext.fill();
  9436. tmpContext.stroke();
  9437. tmpContext.fillStyle = "#bcbcbc";
  9438. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9439. tmpContext.fill();
  9440. } else if (obj.name == "sapling") {
  9441. for (let i = 0; i < 2; ++i) {
  9442. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9443. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9444. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9445. tmpContext.fill();
  9446. if (!i) tmpContext.stroke();
  9447. }
  9448. } else if (obj.name == "pit trap") {
  9449. tmpContext.fillStyle = "#a5974c";
  9450. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9451. tmpContext.fill();
  9452. tmpContext.stroke();
  9453. tmpContext.fillStyle = outlineColor;
  9454. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9455. tmpContext.fill();
  9456. } else if (obj.name == "boost pad") {
  9457. tmpContext.fillStyle = "#7e7f82";
  9458. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9459. tmpContext.fill();
  9460. tmpContext.stroke();
  9461. tmpContext.fillStyle = "#dbd97d";
  9462. renderTriangle(obj.scale * 1, tmpContext);
  9463. } else if (obj.name == "turret") {
  9464. tmpContext.fillStyle = "#a5974c";
  9465. renderCircle(0, 0, obj.scale, tmpContext);
  9466. tmpContext.fill();
  9467. tmpContext.stroke();
  9468. tmpContext.fillStyle = "#939393";
  9469. let tmpLen = 50;
  9470. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9471. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9472. tmpContext.fill();
  9473. tmpContext.stroke();
  9474. } else if (obj.name == "platform") {
  9475. tmpContext.fillStyle = "#cebd5f";
  9476. let tmpCount = 4;
  9477. let tmpS = obj.scale * 2;
  9478. let tmpW = tmpS / tmpCount;
  9479. let tmpX = -(obj.scale / 2);
  9480. for (let i = 0; i < tmpCount; ++i) {
  9481. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9482. tmpContext.fill();
  9483. tmpContext.stroke();
  9484. tmpX += tmpS / tmpCount;
  9485. }
  9486. } else if (obj.name == "healing pad") {
  9487. tmpContext.fillStyle = "#7e7f82";
  9488. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9489. tmpContext.fill();
  9490. tmpContext.stroke();
  9491. tmpContext.fillStyle = "#db6e6e";
  9492. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9493. } else if (obj.name == "spawn pad") {
  9494. tmpContext.fillStyle = "#7e7f82";
  9495. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9496. tmpContext.fill();
  9497. tmpContext.stroke();
  9498. tmpContext.fillStyle = "#71aad6";
  9499. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9500. } else if (obj.name == "blocker") {
  9501. tmpContext.fillStyle = "#7e7f82";
  9502. renderCircle(0, 0, obj.scale, tmpContext);
  9503. tmpContext.fill();
  9504. tmpContext.stroke();
  9505. tmpContext.rotate(Math.PI / 4);
  9506. tmpContext.fillStyle = "#db6e6e";
  9507. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9508. } else if (obj.name == "teleporter") {
  9509. tmpContext.fillStyle = "#7e7f82";
  9510. renderCircle(0, 0, obj.scale, tmpContext);
  9511. tmpContext.fill();
  9512. tmpContext.stroke();
  9513. tmpContext.rotate(Math.PI / 4);
  9514. tmpContext.fillStyle = "#d76edb";
  9515. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9516. }
  9517. tmpContext.restore();
  9518. }
  9519.  
  9520. let objSprites = [];
  9521.  
  9522. function getObjSprite(obj) {
  9523. let tmpSprite = objSprites[obj.id];
  9524. if (!tmpSprite) {
  9525. // let blurScale = isNight ? 20 : 0;
  9526. let tmpCanvas = document.createElement("canvas");
  9527. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  9528. let tmpContext = tmpCanvas.getContext("2d");
  9529. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9530. tmpContext.rotate(Math.PI / 2);
  9531. tmpContext.strokeStyle = outlineColor;
  9532. tmpContext.lineWidth = outlineWidth;
  9533. tmpContext.shadowBlur = 5;
  9534. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9535. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9536. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9537. let tmpScale = obj.scale * 0.6;
  9538. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9539. tmpContext.fill();
  9540. tmpContext.stroke();
  9541. tmpContext.fillStyle = "#a5974c";
  9542. renderCircle(0, 0, tmpScale, tmpContext);
  9543. tmpContext.fillStyle = "#cc5151";
  9544. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9545. } else if (obj.name == "pit trap") {
  9546. tmpContext.fillStyle = "#a5974c";
  9547. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9548. tmpContext.fill();
  9549. tmpContext.stroke();
  9550. tmpContext.fillStyle = "#cc5151";
  9551. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9552. tmpContext.fill();
  9553. }
  9554. tmpSprite = tmpCanvas;
  9555. objSprites[obj.id] = tmpSprite;
  9556. }
  9557. return tmpSprite;
  9558. }
  9559.  
  9560. // GET MARK SPRITE:
  9561. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9562. let center = {
  9563. x: screenWidth / 2,
  9564. y: screenHeight / 2,
  9565. };
  9566. tmpContext.lineWidth = outlineWidth;
  9567. mainContext.globalAlpha = 0.2;
  9568. tmpContext.strokeStyle = outlineColor;
  9569. tmpContext.save();
  9570. tmpContext.translate(tmpX, tmpY);
  9571. tmpContext.rotate(90**10);
  9572. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9573. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9574. var tmpScale = (obj.scale);
  9575. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9576. tmpContext.fill();
  9577. tmpContext.stroke();
  9578. tmpContext.fillStyle = "#a5974c";
  9579. renderCircle(0, 0, tmpScale, tmpContext);
  9580. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9581. tmpContext.fillStyle = "#a34040";
  9582. } else {
  9583. tmpContext.fillStyle = "#c9b758";
  9584. }
  9585. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9586. } else if (obj.name == "turret") {
  9587. renderCircle(0, 0, obj.scale, tmpContext);
  9588. tmpContext.fill();
  9589. tmpContext.stroke();
  9590. tmpContext.fillStyle = "#939393";
  9591. let tmpLen = 50;
  9592. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9593. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9594. tmpContext.fill();
  9595. tmpContext.stroke();
  9596. } else if (obj.name == "teleporter") {
  9597. tmpContext.fillStyle = "#7e7f82";
  9598. renderCircle(0, 0, obj.scale, tmpContext);
  9599. tmpContext.fill();
  9600. tmpContext.stroke();
  9601. tmpContext.rotate(Math.PI / 4);
  9602. tmpContext.fillStyle = "#d76edb";
  9603. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9604. } else if (obj.name == "platform") {
  9605. tmpContext.fillStyle = "#cebd5f";
  9606. let tmpCount = 4;
  9607. let tmpS = obj.scale * 2;
  9608. let tmpW = tmpS / tmpCount;
  9609. let tmpX = -(obj.scale / 2);
  9610. for (let i = 0; i < tmpCount; ++i) {
  9611. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9612. tmpContext.fill();
  9613. tmpContext.stroke();
  9614. tmpX += tmpS / tmpCount;
  9615. }
  9616. } else if (obj.name == "healing pad") {
  9617. tmpContext.fillStyle = "#7e7f82";
  9618. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9619. tmpContext.fill();
  9620. tmpContext.stroke();
  9621. tmpContext.fillStyle = "#db6e6e";
  9622. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9623. } else if (obj.name == "spawn pad") {
  9624. tmpContext.fillStyle = "#7e7f82";
  9625. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9626. tmpContext.fill();
  9627. tmpContext.stroke();
  9628. tmpContext.fillStyle = "#71aad6";
  9629. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9630. } else if (obj.name == "blocker") {
  9631. tmpContext.fillStyle = "#7e7f82";
  9632. renderCircle(0, 0, obj.scale, tmpContext);
  9633. tmpContext.fill();
  9634. tmpContext.stroke();
  9635. tmpContext.rotate(Math.PI / 4);
  9636. tmpContext.fillStyle = "#db6e6e";
  9637. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9638. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9639. tmpContext.fillStyle = "#a5974c";
  9640. renderCircle(0, 0, obj.scale, tmpContext);
  9641. tmpContext.fillStyle = "#c9b758";
  9642. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9643. tmpContext.fillStyle = "#a5974c";
  9644. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9645.  
  9646. } else if (obj.name == "pit trap") {
  9647. tmpContext.fillStyle = "#a5974c";
  9648. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9649. tmpContext.fill();
  9650. tmpContext.stroke();
  9651. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9652. tmpContext.fillStyle = "#a34040";
  9653. } else {
  9654. tmpContext.fillStyle = outlineColor;
  9655. }
  9656. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9657. tmpContext.fill();
  9658. }
  9659. tmpContext.restore();
  9660. }
  9661.  
  9662. // OBJECT ON SCREEN:
  9663. function isOnScreen(x, y, s) {
  9664. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9665. s,
  9666. maxScreenHeight));
  9667. }
  9668.  
  9669. // RENDER GAME OBJECTS:
  9670. function renderGameObjects(layer, xOffset, yOffset) {
  9671. let tmpSprite;
  9672. let tmpX;
  9673. let tmpY;
  9674. liztobj.forEach((tmp) => {
  9675. tmpObj = tmp;
  9676. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9677. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9678. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9679. if (layer == 0) {
  9680. tmpObj.update(delta);
  9681. }
  9682. mainContext.globalAlpha = tmpObj.alpha;
  9683. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9684. if (tmpObj.isItem) {
  9685. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9686. tmpSprite = getObjSprite(tmpObj);
  9687. } else {
  9688. tmpSprite = getItemSprite(tmpObj);
  9689. }
  9690.  
  9691. mainContext.save();
  9692. mainContext.translate(tmpX, tmpY);
  9693. mainContext.rotate(tmpObj.dir);
  9694. if (!tmpObj.active) {
  9695. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9696. }
  9697. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9698.  
  9699. if (tmpObj.blocker) {
  9700. mainContext.strokeStyle = "#db6e6e";
  9701. mainContext.globalAlpha = 0.3;
  9702. mainContext.lineWidth = 6;
  9703. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9704. }
  9705. mainContext.restore();
  9706. } else {
  9707. CHv4Tree(tmpObj, tmpX, tmpY);
  9708. tmpSprite = getResSprite(tmpObj);
  9709. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9710. }
  9711. }
  9712. if (layer == 3 && !useWasd) {
  9713. if (tmpObj.health < tmpObj.maxHealth && UTILS.getDist(tmpObj, player, 0, 2) <= 400) {
  9714. // HEALTH HOLDER:
  9715. mainContext.fillStyle = darkOutlineColor;
  9716. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9717. mainContext.fill();
  9718. let pen = tmpObj.health / tmpObj.maxHealth;
  9719. let clolor;
  9720.  
  9721. if (pen > 0.7) {
  9722. clolor = "#8ecc51";
  9723. } else if (pen > 0.45) {
  9724. clolor = "#e6d15a";
  9725. } else {
  9726. clolor = "#cc5151";
  9727. }
  9728.  
  9729. // HEALTH BAR:
  9730. mainContext.fillStyle = clolor;
  9731. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * pen, 17 - config.healthBarPad * 2, 7);
  9732. mainContext.fill();
  9733. }
  9734. }
  9735.  
  9736. }
  9737. });
  9738.  
  9739. // PLACE VISIBLE:
  9740. if (layer == 0) {
  9741. if (placeVisible.length) {
  9742. placeVisible.forEach((places) => {
  9743. tmpX = places.x - xOffset;
  9744. tmpY = places.y - yOffset;
  9745. markObject(places, tmpX, tmpY);
  9746. });
  9747. }
  9748. if (preIndi.length) {
  9749. preIndi.forEach((places) => {
  9750. tmpX = places.x - xOffset;
  9751. tmpY = places.y - yOffset;
  9752. preplaceIndi(places, tmpX, tmpY);
  9753. });
  9754. }
  9755. }
  9756. }
  9757.  
  9758. function preshit(obj, tmpContext, tmpX, tmpY) {
  9759. tmpContext.lineWidth = outlineWidth;
  9760. tmpContext.strokeStyle = outlineColor;
  9761. tmpContext.save();
  9762. tmpContext.translate(tmpX, tmpY);
  9763. tmpContext.globalAlpha = 0.3
  9764.  
  9765. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9766. tmpContext.fillStyle = "#ff0000";
  9767. renderCircle(0, 0, obj.scale, tmpContext);
  9768. tmpContext.fill();
  9769. tmpContext.stroke();
  9770. } else if (obj.name == "pit trap") {
  9771. tmpContext.fillStyle = "#00ffff";
  9772. renderCircle(0, 0, obj.scale, tmpContext);
  9773. tmpContext.fill();
  9774. tmpContext.stroke();
  9775. }
  9776.  
  9777. tmpContext.restore();
  9778. }
  9779.  
  9780. function preplaceIndi(tmpObj, tmpX, tmpY) {
  9781. preshit(tmpObj, mainContext, tmpX, tmpY);
  9782. }
  9783.  
  9784. function CHv4Tree(y, n, r, offsets) {
  9785. let trees = getResSprite(y);
  9786. let easeScale = 0.06;
  9787. let lowestAlpha = 0.5;
  9788. let fadeStartDistance = y.scale * 1.2;
  9789. let circleFadeDistance = 230;
  9790. let treeFadeDistance = 170;
  9791. if (player && y.type === 0) {
  9792. let distanceToPlayer = Math.sqrt((y.y - player.y2) ** 2 + (y.x - player.x2) ** 2);
  9793. if (distanceToPlayer <= fadeStartDistance + treeFadeDistance + player.scale) {
  9794. let alphaFactor = (distanceToPlayer / (fadeStartDistance + treeFadeDistance + player.scale)) ** 2;
  9795. mainContext.globalAlpha = Math.max(lowestAlpha, alphaFactor);
  9796. } else {
  9797. mainContext.globalAlpha = 1;
  9798. }
  9799. mainContext.drawImage(trees, n - trees.width / 2, r - trees.height / 2);
  9800. let circleAlpha = 1 - (distanceToPlayer - y.scale) / (circleFadeDistance + player.scale * 5);
  9801. if (distanceToPlayer <= y.scale + circleFadeDistance + player.scale) {
  9802. mainContext.beginPath();
  9803. mainContext.arc(n, r, y.scale * 0.6, 0, 2 * Math.PI);
  9804. mainContext.fillStyle = `rgba(0, 0, 0, ${circleAlpha})`;
  9805. mainContext.strokeStyle = "black";
  9806. mainContext.lineWidth = 5;
  9807. mainContext.fill();
  9808. mainContext.stroke();
  9809. mainContext.closePath();
  9810. }
  9811. } else {
  9812. mainContext.globalAlpha = 1;
  9813. mainContext.drawImage(trees, n - trees.width / 2, r - trees.height / 2);
  9814. }
  9815. }
  9816. function markObject(tmpObj, tmpX, tmpY) {
  9817. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9818. }
  9819.  
  9820. // RENDER MINIMAP:
  9821. class MapPing {
  9822. constructor(color, scale) {
  9823. this.init = function(x, y) {
  9824. this.scale = 0;
  9825. this.x = x;
  9826. this.y = y;
  9827. this.active = true;
  9828. };
  9829. this.update = function(ctxt, delta) {
  9830. if (this.active) {
  9831. this.scale += 0.05 * delta;
  9832. if (this.scale >= scale) {
  9833. this.active = false;
  9834. } else {
  9835. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9836. ctxt.beginPath();
  9837. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9838. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9839. ctxt.stroke();
  9840. }
  9841. }
  9842. };
  9843. this.color = color;
  9844. }
  9845. }
  9846.  
  9847. function pingMap(x, y) {
  9848. tmpPing = mapPings.find(pings => !pings.active);
  9849. if (!tmpPing) {
  9850. tmpPing = new MapPing("#fff", config.mapPingScale);
  9851. mapPings.push(tmpPing);
  9852. }
  9853. tmpPing.init(x, y);
  9854. }
  9855.  
  9856. function updateMapMarker() {
  9857. mapMarker.x = player.x;
  9858. mapMarker.y = player.y;
  9859. }
  9860.  
  9861. function renderMinimap(delta) {
  9862. if (player && player.alive) {
  9863. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9864.  
  9865. // RENDER PINGS:
  9866. mapContext.lineWidth = 4;
  9867. for (let i = 0; i < mapPings.length; ++i) {
  9868. tmpPing = mapPings[i];
  9869. mapContext.strokeStyle = tmpPing.color;
  9870. tmpPing.update(mapContext, delta);
  9871. }
  9872.  
  9873. // RENDER BREAK TRACKS:
  9874. mapContext.globalAlpha = 1;
  9875. mapContext.fillStyle = "#ff0000";
  9876. if (breakTrackers.length) {
  9877. mapContext.fillStyle = "#abcdef";
  9878. mapContext.font = "34px HammerSmith One";
  9879. mapContext.textBaseline = "middle";
  9880. mapContext.textAlign = "center";
  9881. for (let i = 0; i < breakTrackers.length;) {
  9882. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9883. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9884. i += 2;
  9885. }
  9886. }
  9887.  
  9888. // RENDER PLAYERS:
  9889. mapContext.globalAlpha = 1;
  9890. mapContext.fillStyle = "#fff";
  9891. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9892. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9893. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9894. if (player.team && minimapData) {
  9895. for (let i = 0; i < minimapData.length;) {
  9896. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9897. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9898. i += 2;
  9899. }
  9900. }
  9901.  
  9902. // RENDER BOTS:
  9903. if (bots.length) {
  9904. bots.forEach((tmp) => {
  9905. if (tmp.inGame) {
  9906. mapContext.globalAlpha = 1;
  9907. mapContext.strokeStyle = "#cc5151";
  9908. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9909. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9910. }
  9911. });
  9912. }
  9913.  
  9914. // DEATH LOCATION:
  9915. if (lastDeath) {
  9916. mapContext.fillStyle = "#fc5553";
  9917. mapContext.font = "34px HammerSmith One";
  9918. mapContext.textBaseline = "middle";
  9919. mapContext.textAlign = "center";
  9920. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9921. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9922. }
  9923.  
  9924. // MAP MARKER:
  9925. if (mapMarker) {
  9926. mapContext.fillStyle = "#fff";
  9927. mapContext.font = "34px HammerSmith One";
  9928. mapContext.textBaseline = "middle";
  9929. mapContext.textAlign = "center";
  9930. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9931. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9932. }
  9933. }
  9934. }
  9935.  
  9936. // ICONS:
  9937. let crossHairs = ["https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg", "https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg"];
  9938. let crossHairSprites = {};
  9939. let iconSprites = {};
  9940. let icons = ["crown", "skull"];
  9941. function loadIcons() {
  9942. for (let i = 0; i < icons.length; ++i) {
  9943. let tmpSprite = new Image();
  9944. tmpSprite.onload = function() {
  9945. this.isLoaded = true;
  9946. };
  9947. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9948. iconSprites[icons[i]] = tmpSprite;
  9949. }
  9950. for (let i = 0; i < crossHairs.length; ++i) {
  9951. let tmpSprite = new Image();
  9952. tmpSprite.onload = function() {
  9953. this.isLoaded = true;
  9954. };
  9955. tmpSprite.src = crossHairs[i];
  9956. crossHairSprites[i] = tmpSprite;
  9957. }
  9958. }
  9959. loadIcons();
  9960.  
  9961. function cdf (e, t){
  9962. try {
  9963. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9964. } catch(e){
  9965. return Infinity;
  9966. }
  9967. }
  9968. function preplacer() {
  9969. if (!gameObjects.length || !inGame || !enemy.length || !player) return;
  9970.  
  9971. var Pot = function(obj, user) {
  9972. let weaponIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  9973. let weapon = user.weapons[weaponIndex];
  9974. if (player.reloads[weapon]) return 0;
  9975. let itemWeapon = items.weapons[weapon];
  9976. let isNear = UTILS.getDist(obj.x, obj.y, user.x2, user.y2) <= obj.scale + itemWeapon.range;
  9977. return user.visible && isNear ? itemWeapon.dmg * (itemWeapon.sDmg || 1) * 3.3 : 0;
  9978. };
  9979.  
  9980. let lowObjHealth = [];
  9981. for (let i = 0; i < gameObjects.length; i++) {
  9982. let obj = gameObjects[i];
  9983. if (obj.active && obj.health > 0 && UTILS.getDist(obj, player, 0, 2) <= player.scale + obj.scale * 2) {
  9984. let dmg = Pot(obj, player);
  9985. //players.reduce((t, p) => t + Pot(obj, p), 0);
  9986. if (obj.health <= dmg) {
  9987. lowObjHealth.push(obj);
  9988. }
  9989. }
  9990. }
  9991. lowObjHealth.sort((a, b) => a.health - b.health);
  9992. let objectss = lowObjHealth.slice(0, Math.min(2, lowObjHealth.length));
  9993.  
  9994. if (objectss.length == 0) return;
  9995.  
  9996. for (let obj of objectss) {
  9997. let angles = Math.atan2(obj.y - player.y2, obj.x - player.x2);
  9998. let enemyTrapped = gameObjects.filter((tmp) => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, obj, 0, 2) <= obj.scale + tmp.getScale() + 15).sort((a, b) => UTILS.getDist(a, obj, 0, 2) - UTILS.getDist(b, obj, 0, 2))[0];
  9999.  
  10000. if (near.dist2 < 350 && player.items[4] == 15) {
  10001. if ([4, 5].includes(player.weaponIndex) && near.dist2 <= items.weapons[player.primaryIndex || 5].range + (player.scale * 1.8)) {
  10002. cplace(2, angles, 1);
  10003. } else {
  10004. if (traps.inTrap && near.dist2 < 300 || my.autoPush) {
  10005. cplace(4, angles);
  10006. }
  10007. if (enemyTrapped || enemyTrapped == obj) {
  10008. cplace(2, near.aim2);
  10009. }
  10010. }
  10011.  
  10012. }
  10013. }
  10014. }
  10015.  
  10016.  
  10017. let postTickTime = 0;
  10018. let frameTickRate = 1000 / 165;
  10019. let timeBetweenTicks = 1000 / 9;
  10020. function somePreStuff() {
  10021. let currentTime = Date.now();
  10022. let newTime = currentTime - postTickTime;
  10023. if (newTime + frameTickRate >= timeBetweenTicks) {
  10024. postTickTime = currentTime;
  10025. preplacer();
  10026. }
  10027. }
  10028. // UPDATE GAME:
  10029. function updateGame() {
  10030. if(gameObjects.length && inGame) {
  10031. gameObjects.forEach((tmp) => {
  10032. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  10033. if(!liztobj.includes(tmp)) {
  10034. liztobj.push(tmp);
  10035. tmp.render = true;
  10036. }
  10037. } else {
  10038. if(liztobj.includes(tmp)) {
  10039. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10040. tmp.render = false;
  10041. const index = liztobj.indexOf(tmp);
  10042. if (index > -1) { // only splice array when item is found
  10043. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10044. }
  10045. }
  10046. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10047. tmp.render = false;
  10048. const index = liztobj.indexOf(tmp);
  10049. if (index > -1) { // only splice array when item is found
  10050. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10051. }
  10052. } else {
  10053. tmp.render = false;
  10054. const index = liztobj.indexOf(tmp);
  10055. if (index > -1) { // only splice array when item is found
  10056. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10057. }
  10058. }
  10059. }
  10060. })
  10061. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10062. }
  10063.  
  10064. // if (config.resetRender) {
  10065. mainContext.beginPath();
  10066. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10067. // }
  10068. mainContext.globalAlpha = 1;
  10069.  
  10070. // MOVE CAMERA:
  10071. if (player) {
  10072. if (false) {
  10073. camX = player.x;
  10074. camY = player.y;
  10075. } else {
  10076. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10077. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10078. let camSpd = Math.min(tmpDist * 0.01 * delta, tmpDist);
  10079. if (tmpDist > 0.05) {
  10080. camX += camSpd * Math.cos(tmpDir);
  10081. camY += camSpd * Math.sin(tmpDir);
  10082. } else {
  10083. camX = player.x;
  10084. camY = player.y;
  10085. }
  10086. }
  10087. } else {
  10088. camX = config.mapScale / 2 + config.riverWidth;
  10089. camY = config.mapScale / 2;
  10090. }
  10091. // PATHFINDER LINE
  10092. if (pathFind.active) {
  10093. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10094. mainContext.lineWidth = player.scale / 5;
  10095. mainContext.globalAlpha = 1;
  10096. mainContext.strokeStyle = "red";
  10097. mainContext.beginPath();
  10098. pathFind.array.forEach((path, i) => {
  10099. let pathXY = {
  10100. x: (pathFind.scale / pathFind.grid) * path.x,
  10101. y: (pathFind.scale / pathFind.grid) * path.y
  10102. }
  10103. let render = {
  10104. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10105. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10106. }
  10107. if (i == 0) {
  10108. mainContext.moveTo(render.x, render.y);
  10109. } else {
  10110. mainContext.lineTo(render.x, render.y);
  10111. }
  10112. });
  10113. mainContext.stroke();
  10114. }
  10115. }
  10116. // INTERPOLATE PLAYERS AND AI:
  10117. let lastTime = now - (1000 / config.serverUpdateRate);
  10118. let tmpDiff;
  10119. for (let i = 0; i < players.length + ais.length; ++i) {
  10120. tmpObj = players[i] || ais[i - players.length];
  10121. if (tmpObj && tmpObj.visible) {
  10122. if (tmpObj.forcePos) {
  10123. tmpObj.x = tmpObj.x2;
  10124. tmpObj.y = tmpObj.y2;
  10125. tmpObj.dir = tmpObj.d2;
  10126. } else {
  10127. let total = tmpObj.t2 - tmpObj.t1;
  10128. let fraction = lastTime - tmpObj.t1;
  10129. let ratio = (fraction / total);
  10130. let rate = 170;
  10131. tmpObj.dt += delta;
  10132. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10133. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10134. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10135. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10136. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10137. if (config.anotherVisual) {
  10138. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10139. } else {
  10140. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10141. }
  10142. }
  10143. }
  10144. somePreStuff();
  10145. }
  10146.  
  10147. // RENDER CORDS:
  10148. let xOffset = camX - (maxScreenWidth / 2);
  10149. let yOffset = camY - (maxScreenHeight / 2);
  10150.  
  10151. // RENDER BACKGROUND:
  10152. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10153. mainContext.fillStyle = "#b6db66";
  10154. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10155. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10156. mainContext.fillStyle = "#dbc666";
  10157. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10158. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10159. mainContext.fillStyle = "#fff";
  10160. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10161. } else if (config.snowBiomeTop - yOffset >= 0) {
  10162. mainContext.fillStyle = "#fff";
  10163. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10164. mainContext.fillStyle = "#b6db66";
  10165. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10166. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10167. } else {
  10168. mainContext.fillStyle = "#b6db66";
  10169. mainContext.fillRect(0, 0, maxScreenWidth,
  10170. (config.mapScale - config.snowBiomeTop - yOffset));
  10171. mainContext.fillStyle = "#dbc666";
  10172. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10173. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10174. }
  10175.  
  10176. // RENDER WATER AREAS:
  10177. if (!firstSetup) {
  10178. waterMult += waterPlus * config.waveSpeed * delta;
  10179. if (waterMult >= config.waveMax) {
  10180. waterMult = config.waveMax;
  10181. waterPlus = -1;
  10182. } else if (waterMult <= 1) {
  10183. waterMult = waterPlus = 1;
  10184. }
  10185. mainContext.globalAlpha = 1;
  10186. mainContext.fillStyle = "#dbc666";
  10187. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10188. mainContext.fillStyle = "#91b2db";
  10189. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10190. }
  10191. // RENDER GRID:
  10192. /*mainContext.lineWidth = 4;
  10193. mainContext.strokeStyle = "#000";
  10194. mainContext.globalAlpha = 0.06;
  10195. mainContext.beginPath();
  10196. for (let x = -camX; x < maxScreenWidth; x += 200) {
  10197. if (x > 0) {
  10198. mainContext.moveTo(x, 0);
  10199. mainContext.lineTo(x, maxScreenHeight);
  10200. }
  10201. }
  10202. for (let y = -camY; y < maxScreenHeight; y += 200) {
  10203. if (y > 0) {
  10204. mainContext.moveTo(0, y);
  10205. mainContext.lineTo(maxScreenWidth, y);
  10206. }
  10207. }
  10208. mainContext.stroke();
  10209. */
  10210. // RENDER DEAD PLAYERS:
  10211. mainContext.globalAlpha = 1;
  10212. mainContext.strokeStyle = outlineColor;
  10213. renderDeadPlayers(xOffset, yOffset);
  10214.  
  10215. // RENDER BOTTOM LAYER:
  10216. mainContext.globalAlpha = 1;
  10217. mainContext.strokeStyle = outlineColor;
  10218. renderGameObjects(-1, xOffset, yOffset);
  10219.  
  10220. // RENDER PROJECTILES:
  10221. mainContext.globalAlpha = 1;
  10222. mainContext.lineWidth = outlineWidth;
  10223. renderProjectiles(0, xOffset, yOffset);
  10224.  
  10225. // RENDER PLAYERS:
  10226. renderPlayers(xOffset, yOffset, 0);
  10227.  
  10228. // RENDER AI:
  10229. mainContext.globalAlpha = 1;
  10230. for (let i = 0; i < ais.length; ++i) {
  10231. tmpObj = ais[i];
  10232. if (tmpObj.active && tmpObj.visible) {
  10233. tmpObj.animate(delta);
  10234. mainContext.save();
  10235. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10236. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10237. renderAI(tmpObj, mainContext);
  10238. mainContext.restore();
  10239. }
  10240. }
  10241.  
  10242. // RENDER GAME OBJECTS (LAYERED):
  10243. renderGameObjects(0, xOffset, yOffset);
  10244. renderProjectiles(1, xOffset, yOffset);
  10245. renderGameObjects(1, xOffset, yOffset);
  10246. renderPlayers(xOffset, yOffset, 1);
  10247. renderGameObjects(2, xOffset, yOffset);
  10248. renderGameObjects(3, xOffset, yOffset);
  10249.  
  10250. // MAP BOUNDARIES:
  10251. mainContext.fillStyle = "#000";
  10252. mainContext.globalAlpha = 0.09;
  10253. if (xOffset <= 0) {
  10254. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10255. }
  10256. if (config.mapScale - xOffset <= maxScreenWidth) {
  10257. let tmpY = Math.max(0, -yOffset);
  10258. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10259. }
  10260. if (yOffset <= 0) {
  10261. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10262. }
  10263. if (config.mapScale - yOffset <= maxScreenHeight) {
  10264. let tmpX = Math.max(0, -xOffset);
  10265. let tmpMin = 0;
  10266. if (config.mapScale - xOffset <= maxScreenWidth)
  10267. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10268. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10269. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10270. }
  10271.  
  10272. // RENDER DAY/NIGHT TIME:
  10273. mainContext.globalAlpha = 1;
  10274. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  10275. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10276.  
  10277. // RENDER PLAYER AND AI UI:
  10278. mainContext.strokeStyle = darkOutlineColor;
  10279. mainContext.globalAlpha = 1;
  10280.  
  10281. for (let i = 0; i < players.length + ais.length; ++i) {
  10282. tmpObj = players[i] || ais[i - players.length];
  10283. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  10284. mainContext.strokeStyle = darkOutlineColor;
  10285. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || "");
  10286. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  10287. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  10288. mainContext.fillStyle = "#fff";
  10289. mainContext.textBaseline = "middle";
  10290. mainContext.textAlign = "center";
  10291. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10292. mainContext.lineJoin = "round";
  10293. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10294. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10295. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10296. let tmpS = config.crownIconScale;
  10297. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10298. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10299. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10300. }
  10301. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10302. let tmpS = config.crownIconScale;
  10303. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10304. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10305. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10306. }
  10307. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  10308. let tmpS = tmpObj.scale * 2.2;
  10309. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10310. }
  10311. }
  10312. if (omgS.spike.active) {
  10313. let obj = {
  10314. x: omgS.spike.x - xOffset,
  10315. y: omgS.spike.y - yOffset,
  10316. scale: omgS.spike.scale,
  10317. }
  10318. mainContext.fillStyle = "#8B0A1A";
  10319. mainContext.strokeStyle = "#5C0303";
  10320. mainContext.lineWidth = 5;
  10321. mainContext.beginPath();
  10322. mainContext.arc(obj.x, obj.y, obj.scale, 0, 2 * Math.PI);
  10323. mainContext.globalAlpha = 0.2;
  10324. mainContext.fill();
  10325. mainContext.stroke();
  10326. mainContext.globalAlpha = 1;
  10327. }
  10328. if (tmpObj.health > 0) {
  10329.  
  10330. if(tmpObj.name != "Trash Slave") {
  10331. // HEALTH HOLDER:
  10332. mainContext.fillStyle = darkOutlineColor;
  10333. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10334. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10335. (config.healthBarPad * 2), 17, 8);
  10336. mainContext.fill();
  10337.  
  10338. // HEALTH BAR:
  10339. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10340. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10341. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10342. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10343. mainContext.fill();
  10344. }
  10345.  
  10346. if (tmpObj.isPlayer) {
  10347. mainContext.globalAlpha = 1;
  10348. //Packet thingy from chicken
  10349. if (tmpObj == player) {
  10350. mainContext.textAlign = "center";
  10351. mainContext.fillStyle = "#fff";
  10352. mainContext.lineJoin = "round";
  10353. mainContext.font = "13px Hammersmith One";
  10354. mainContext.strokeStyle = darkOutlineColor;
  10355. mainContext.lineWidth = 6;
  10356. mainContext.strokeText(secPacket + " " + minPacket, tmpObj.x - xOffset, tmpObj.y - yOffset);
  10357. mainContext.fillText(secPacket + " " + minPacket, tmpObj.x - xOffset, tmpObj.y - yOffset);
  10358. }
  10359.  
  10360. let targetReloads = {
  10361. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10362. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10363. turret: (2500 - tmpObj.reloads[53]) / 2500
  10364. };
  10365. if (!tmpObj.currentReloads) {
  10366. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10367. primary: targetReloads.primary,
  10368. secondary: targetReloads.secondary,
  10369. turret: targetReloads.turret
  10370. };
  10371. }
  10372. const lerpFactor = 0.3;
  10373. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10374. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10375. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10376. if (tmpObj.currentReloads.secondary < .999) {
  10377. let index = tmpObj.currentReloads.secondary;
  10378. mainContext.fillStyle = darkOutlineColor;
  10379. mainContext.roundRect(tmpObj.x - xOffset + 2 - config.healthBarPad, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13, 2 * 23.5 + 2 * config.healthBarPad, 17, 10);
  10380. mainContext.fill();
  10381. mainContext.fillStyle = "#a5974c";
  10382. mainContext.roundRect(tmpObj.x - xOffset + 2, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13 + config.healthBarPad, 2 * 23.5 * (index), 16 - 2 * config.healthBarPad, 10);
  10383. mainContext.fill();
  10384. }
  10385. if (tmpObj.currentReloads.primary < .999) {
  10386. let index = tmpObj.currentReloads.primary;
  10387. mainContext.fillStyle = darkOutlineColor;
  10388. mainContext.roundRect(tmpObj.x - xOffset - 50 - config.healthBarPad, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13, 2 * 23.5 + 2 * config.healthBarPad, 17, 10);
  10389. mainContext.fill();
  10390. mainContext.fillStyle = "#a5974c";
  10391. mainContext.roundRect(tmpObj.x - xOffset - 50, tmpObj.y - yOffset + tmpObj.scale + config.nameY - 13 + config.healthBarPad, 2 * 23.5 * (index), 16 - 2 * config.healthBarPad, 10);
  10392. mainContext.fill();
  10393. }
  10394. // SHAME COUNT:
  10395. if (tmpObj.isPlayer) {
  10396. let shameX = tmpObj.x - xOffset + mainContext.measureText(tmpText).width / 2 + config.crownPad;
  10397. let shameY = tmpObj.y - yOffset - tmpObj.scale - config.nameY;
  10398.  
  10399. if (tmpObj.iconIndex == 1) {
  10400. shameX = tmpObj.x - xOffset - 30 + mainContext.measureText(tmpText).width / 2 + config.crownPad * 3.5 + 5;
  10401. }
  10402. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10403. mainContext.fillStyle = "#ff0000";
  10404. mainContext.textBaseline = "middle"; // lalalalal
  10405. mainContext.textAlign = "center";
  10406. mainContext.lineWidth = tmpObj.nameScale ? 11 : 8;
  10407. mainContext.lineJoin = "round";
  10408. mainContext.strokeText(tmpObj.shameCount, shameX, shameY);
  10409. mainContext.fillText(tmpObj.shameCount, shameX, shameY);
  10410. }
  10411. if (tmpObj == player) {
  10412. mainContext.textAlign = "center";
  10413. mainContext.fillStyle = "#fff";
  10414. mainContext.lineJoin = "round";
  10415. mainContext.font = "20px Hammersmith One";
  10416. mainContext.strokeStyle = darkOutlineColor;
  10417. mainContext.lineWidth = 6;
  10418. mainContext.strokeText(instaC.wait, tmpObj.x - xOffset, tmpObj.y - yOffset + tmpObj.scale + config.nameY + 30);
  10419. mainContext.fillText(instaC.wait, tmpObj.x - xOffset, tmpObj.y - yOffset + tmpObj.scale + config.nameY + 30);
  10420. }
  10421.  
  10422.  
  10423.  
  10424. // PLAYER TRACER:
  10425. if (!tmpObj.isTeam(player)) {
  10426. let center = {
  10427. x: screenWidth / 2,
  10428. y: screenHeight / 2,
  10429. };
  10430. 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);
  10431. let dist = center.y * alpha / 2;
  10432. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10433. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10434. mainContext.save();
  10435. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10436. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10437. let by = 255 - (tmpObj.sid * 2);
  10438. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10439. mainContext.globalAlpha = alpha;
  10440. let renderTracer = function(s, ctx) {
  10441. ctx = ctx || mainContext;
  10442. let h = s * (Math.sqrt(3) / 2);
  10443. ctx.beginPath();
  10444. ctx.moveTo(0, -h / 1.5);
  10445. ctx.lineTo(-s / 2, h / 2);
  10446. ctx.lineTo(s / 2, h / 2);
  10447. ctx.lineTo(0, -h / 1.5);
  10448. ctx.fill();
  10449. ctx.closePath();
  10450. }
  10451. renderTracer(25, mainContext);
  10452. mainContext.restore();
  10453. }
  10454.  
  10455. if (getEl("predictType").value == "pre2") {
  10456. mainContext.lineWidth = 3;
  10457. mainContext.strokeStyle = "#fff";
  10458. mainContext.globalAlpha = 1;
  10459. mainContext.beginPath();
  10460. let render = {
  10461. x: tmpObj.x2 - xOffset,
  10462. y: tmpObj.y2 - yOffset
  10463. };
  10464. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10465. mainContext.lineTo(render.x, render.y);
  10466. mainContext.stroke();
  10467. } else if (getEl("predictType").value == "pre3") {
  10468. mainContext.lineWidth = 3;
  10469. mainContext.strokeStyle = "#cc5151";
  10470. mainContext.globalAlpha = 1;
  10471. mainContext.beginPath();
  10472. let render = {
  10473. x: tmpObj.x3 - xOffset,
  10474. y: tmpObj.y3 - yOffset
  10475. };
  10476. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10477. mainContext.lineTo(render.x, render.y);
  10478. mainContext.stroke();
  10479. }
  10480.  
  10481. }
  10482. }
  10483. }
  10484. }
  10485.  
  10486. if (player) {
  10487.  
  10488. // AUTOPUSH LINE:
  10489. if (my.autoPush && my.pushData) {
  10490. mainContext.lineWidth = 5;
  10491. mainContext.globalAlpha = 1;
  10492.  
  10493. var x1 = player.x - xOffset;
  10494. var y1 = player.y - yOffset;
  10495. var x2 = my.pushData.x2 - xOffset;
  10496. var y2 = my.pushData.y2 - yOffset;
  10497. var x3 = my.pushData.x - xOffset;
  10498. var y3 = my.pushData.y - yOffset;
  10499. var distance = Math.hypot(x2 - x1, y2 - y1);
  10500. if (distance > 150) {
  10501. var ratio = 150 / distance;
  10502. x2 = x1 + (x2 - x1) * ratio;
  10503. y2 = y1 + (y2 - y1) * ratio;
  10504. }
  10505.  
  10506. mainContext.beginPath();
  10507. mainContext.strokeStyle = "cyan";
  10508. for (let i = 0; i <= 10; i++) {
  10509. let t = i / 10;
  10510. let segmentX = x1 + (x2 - x1) * t;
  10511. let segmentY = y1 + (y2 - y1) * t;
  10512.  
  10513. if (i === 0) {
  10514. mainContext.moveTo(segmentX, segmentY);
  10515. } else {
  10516. mainContext.lineTo(segmentX, segmentY);
  10517. }
  10518. }
  10519. mainContext.stroke();
  10520.  
  10521. mainContext.beginPath();
  10522. mainContext.strokeStyle = "white";
  10523.  
  10524. var midX = (x2 + x3) / 2;
  10525. var midY = (y2 + y3) / 2;
  10526.  
  10527. mainContext.moveTo(x2, y2);
  10528. mainContext.quadraticCurveTo(midX, midY - 15, x3, y3);
  10529. mainContext.stroke();
  10530. }
  10531.  
  10532.  
  10533.  
  10534.  
  10535. }
  10536.  
  10537. mainContext.globalAlpha = 1;
  10538.  
  10539. // RENDER ANIM TEXTS:
  10540. textManager.update(delta, mainContext, xOffset, yOffset);
  10541.  
  10542. // RENDER CHAT MESSAGES:
  10543. for (let i = 0; i < players.length; ++i) {
  10544. tmpObj = players[i];
  10545. if (tmpObj.visible) {
  10546. if (tmpObj.chatCountdown > 0) {
  10547. tmpObj.chatCountdown -= delta;
  10548. if (tmpObj.chatCountdown <= 0)
  10549. tmpObj.chatCountdown = 0;
  10550. mainContext.font = "32px HammerSmith One";
  10551. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10552. mainContext.textBaseline = "middle";
  10553. mainContext.textAlign = "center";
  10554. let tmpX = tmpObj.x - xOffset;
  10555. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10556. let tmpH = 47;
  10557. let tmpW = tmpSize.width + 17;
  10558. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10559. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10560. mainContext.fill();
  10561. mainContext.fillStyle = "#fff";
  10562. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10563. }
  10564. if (tmpObj.chat.count > 0) {
  10565. if (!useWasd) {
  10566. tmpObj.chat.count -= delta;
  10567. if (tmpObj.chat.count <= 0)
  10568. tmpObj.chat.count = 0;
  10569. mainContext.font = "32px HammerSmith One";
  10570. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10571. mainContext.textBaseline = "middle";
  10572. mainContext.textAlign = "center";
  10573. let tmpX = tmpObj.x - xOffset;
  10574. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10575. let tmpH = 47;
  10576. let tmpW = tmpSize.width + 17;
  10577. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10578. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10579. mainContext.fill();
  10580. mainContext.fillStyle = "#ffffff99";
  10581. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10582. } else {
  10583. tmpObj.chat.count = 0;
  10584. }
  10585. }
  10586. }
  10587. }
  10588.  
  10589.  
  10590. if (allChats.length) {
  10591. const playerChatsMap = new Map();
  10592.  
  10593. // Organize chats by owner
  10594. allChats.filter(ch => ch.active).forEach(ch => {
  10595. if (!playerChatsMap.has(ch.owner)) {
  10596. playerChatsMap.set(ch.owner, []);
  10597. }
  10598. playerChatsMap.get(ch.owner).push(ch);
  10599. });
  10600.  
  10601. // Process each player's chats independently
  10602. playerChatsMap.forEach((chats, owner) => {
  10603. chats.forEach(ch => {
  10604. if (!ch.alive) {
  10605. if (ch.alpha <= 1) {
  10606. ch.alpha += delta / 50;
  10607. if (ch.alpha >= 1) {
  10608. ch.alpha = 1;
  10609. ch.alive = true;
  10610. ch.visibleTimer = 2000;
  10611. const activeChats = chats.filter(prevCh => prevCh.active && prevCh.alive);
  10612. if (activeChats.length >= 4) {
  10613. const oldestChat = activeChats.reduce((oldest, current) => (oldest.visibleTimer < current.visibleTimer ? oldest : current));
  10614. oldestChat.active = false;
  10615. }
  10616. ch.y = ch.owner.y - ch.owner.scale - yOffset - 90;
  10617. activeChats.filter(prevCh => prevCh !== ch)
  10618. .forEach((prevCh, index) => prevCh.y = ch.y - (index + 1) * 50);
  10619. }
  10620. }
  10621. } else {
  10622. if (ch.visibleTimer > 0) {
  10623. ch.visibleTimer -= delta;
  10624. } else {
  10625. ch.alpha -= delta / 1000;
  10626. if (ch.alpha <= 0) {
  10627. ch.alpha = 0;
  10628. ch.active = false;
  10629. }
  10630. }
  10631. }
  10632. if (ch.active) {
  10633. ch.x = ch.owner.x - xOffset;
  10634. ch.y = ch.owner.y - ch.owner.scale - yOffset - 90;
  10635. const activeChats = chats.filter(prevCh => prevCh.active && prevCh.alive && prevCh !== ch);
  10636. activeChats.forEach((prevCh, index) => prevCh.y = ch.y - (index + 1) * 50);
  10637. }
  10638. });
  10639. });
  10640.  
  10641. allChats.filter(ch => ch.active).forEach(ch => {
  10642. mainContext.font = "32px Hammersmith One";
  10643. let tmpSize = mainContext.measureText(ch.chat);
  10644. mainContext.textBaseline = "middle";
  10645. mainContext.textAlign = "center";
  10646. let tmpX = ch.x;
  10647. let tmpY = ch.y;
  10648. let tmpH = 47;
  10649. let tmpW = tmpSize.width + 17;
  10650. mainContext.globalAlpha = ch.alpha;
  10651. mainContext.fillStyle = ch.owner.isTeam(player) ? "rgba(255,215,0,1)" : "#cc5151";
  10652. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10653. mainContext.lineWidth = 5;
  10654. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10655. mainContext.strokeStyle = "rgba(0,0,0,0.0)";
  10656. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10657. mainContext.stroke();
  10658. mainContext.fill();
  10659. mainContext.fillStyle = "#fff";
  10660. mainContext.strokeStyle = "";
  10661. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10662. mainContext.fillText(ch.chat, tmpX, tmpY);
  10663. });
  10664. }
  10665.  
  10666. mainContext.globalAlpha = 1;
  10667.  
  10668. // RENDER MINIMAP:
  10669. renderMinimap(delta);
  10670. }
  10671.  
  10672. // UPDATE & ANIMATE:
  10673. window.requestAnimFrame = function() {
  10674. return null;
  10675. }
  10676. window.rAF = (function() {
  10677. return window.requestAnimationFrame ||
  10678. window.webkitRequestAnimationFrame ||
  10679. window.mozRequestAnimationFrame ||
  10680. function(callback) {
  10681. window.setTimeout(callback, 1000/9);
  10682. };
  10683. })();
  10684.  
  10685. function doUpdate() {
  10686. //rape modulus
  10687. now = performance.now();
  10688. delta = now - lastUpdate;
  10689. lastUpdate = now;
  10690. let timer = performance.now();
  10691. let diff = timer - fpsTimer.last;
  10692. if (diff >= 1000) {
  10693.  
  10694. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10695.  
  10696. fpsTimer.last = timer;
  10697. fpsTimer.time = 0;
  10698. }
  10699. fpsTimer.time++;
  10700. updateGame();
  10701. rAF(doUpdate);
  10702. ms.avg = Math.round((ms.min+ms.max)/2);
  10703. }
  10704.  
  10705. prepareMenuBackground();
  10706. doUpdate();
  10707.  
  10708. function toggleUseless(boolean) {
  10709. getEl("instaType").disabled = boolean;
  10710. getEl("antiBullType").disabled = boolean;
  10711. getEl("predictType").disabled = boolean;
  10712. }
  10713. toggleUseless(useWasd);
  10714.  
  10715. let changeDays = {};
  10716. window.debug = function() {
  10717. my.waitHit = 0;
  10718. my.autoAim = false;
  10719. instaC.isTrue = false;
  10720. traps.inTrap = false;
  10721. itemSprites = [];
  10722. objSprites = [];
  10723. gameObjectSprites = [];
  10724. };
  10725. window.wasdMode = function() {
  10726. useWasd = !useWasd;
  10727. toggleUseless(useWasd);
  10728. };
  10729. window.startGrind = function() {
  10730. if (getEl("weaponGrind").checked) {
  10731. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10732. checkPlace(player.getItemType(22), i);
  10733. }
  10734. }
  10735. };
  10736. // REMOVED!!! so they cant abuse :)
  10737. let projects = [
  10738. "adorable-eight-guppy",
  10739. "galvanized-bittersweet-windshield"
  10740. ];
  10741. let botIDS = 0;
  10742. window.connectFillBots = function() {
  10743. botSkts = [];
  10744. botIDS = 0;
  10745. for (let i = 0; i < projects.length; i++) {
  10746. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10747. test.binaryType = "arraybuffer";
  10748.  
  10749. test.onopen = function() {
  10750. test.ssend = function(type) {
  10751. let data = Array.prototype.slice.call(arguments, 1);
  10752. let binary = window.msgpack.encode([type, data]);
  10753. test.send(binary);
  10754. };
  10755. for (let i = 0; i < 4; i++) {
  10756. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10757. action: "homepage"
  10758. }).then(function(token) {
  10759. let t = WS.url.split("wss://")[1].split("?")[0];
  10760. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10761. botSkts.push([test]);
  10762. botIDS++;
  10763. });
  10764. }
  10765. };
  10766. test.onmessage = function(message) {
  10767. let data = new Uint8Array(message.data);
  10768. let parsed = window.msgpack.decode(data);
  10769. let type = parsed[0];
  10770. data = parsed[1];
  10771. };
  10772. }
  10773. };
  10774. window.destroyFillBots = function() {
  10775. botSkts.forEach((socket) => {
  10776. socket[0].close();
  10777. });
  10778. botSkts = [];
  10779. };
  10780. window.tryConnectBots = function() {
  10781. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10782. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10783. action: "homepage"
  10784. }).then(function(token) {
  10785. // CONNECT SOCKET:
  10786. botSpawn(token);
  10787. });
  10788. }
  10789. };
  10790. window.destroyBots = function() {
  10791. bots.forEach((botyyyyy) => {
  10792. botyyyyy.closeSocket = true;
  10793. });
  10794. bots = [];
  10795. };
  10796. window.resBuild = function() {
  10797. if (gameObjects.length) {
  10798. gameObjects.forEach((tmp) => {
  10799. tmp.breakObj = false;
  10800. });
  10801. breakObjects = [];
  10802. }
  10803. };
  10804. window.toggleBotsCircle = function() {
  10805. player.circle = !player.circle;
  10806. };
  10807. window.toggleVisual = function() {
  10808. config.anotherVisual = !config.anotherVisual;
  10809. gameObjects.forEach((tmp) => {
  10810. if (tmp.active) {
  10811. tmp.dir = tmp.lastDir;
  10812. }
  10813. });
  10814. };
  10815. window.prepareUI = function(tmpObj) {
  10816. resize();
  10817. // CHAT STUFF:
  10818. var chatBox = document.getElementById("chatBox");
  10819. var chatHolder = document.getElementById("chatHolder");
  10820. var suggestBox = document.createElement("div");
  10821. suggestBox.id = "suggestBox";
  10822.  
  10823. var prevChats = [];
  10824. var prevChatsIndex = 0;
  10825.  
  10826. function toggleChat() {
  10827. if (!usingTouch) {
  10828. if (chatHolder.style.display == "block") {
  10829. if (chatBox.value) {
  10830. sendChat(chatBox.value);
  10831. }
  10832. closeChat();
  10833. } else {
  10834. storeMenu.style.display = "none";
  10835. allianceMenu.style.display = "none";
  10836. chatHolder.style.display = "block";
  10837. chatBox.focus();
  10838. resetMoveDir();
  10839. }
  10840. } else {
  10841. setTimeout(function () {
  10842. var chatMessage = prompt("chat message");
  10843. if (chatMessage) {
  10844. sendChat(chatMessage);
  10845. }
  10846. }, 1);
  10847. }
  10848. chatBox.value = "";
  10849. (() => {
  10850. prevChatsIndex = 0;
  10851. })();
  10852. }
  10853.  
  10854. function closeChat() {
  10855. chatBox.value = "";
  10856. chatHolder.style.display = "none";
  10857. }
  10858.  
  10859. // ACTION BAR:
  10860. UTILS.removeAllChildren(actionBar);
  10861.  
  10862. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10863. (function (i) {
  10864. UTILS.generateElement({
  10865. id: "actionBarItem" + i,
  10866. class: "actionBarItem",
  10867. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10868. onmouseout: function () {
  10869. showItemInfo();
  10870. },
  10871. parent: actionBar
  10872. });
  10873. })(i);
  10874. }
  10875.  
  10876. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10877. (function (i) {
  10878. let tmpCanvas = document.createElement("canvas");
  10879. tmpCanvas.width = tmpCanvas.height = 66;
  10880. let tmpContext = tmpCanvas.getContext("2d");
  10881. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10882. tmpContext.imageSmoothingEnabled = false;
  10883. tmpContext.webkitImageSmoothingEnabled = false;
  10884. tmpContext.mozImageSmoothingEnabled = false;
  10885.  
  10886. if (items.weapons[i]) {
  10887. tmpContext.rotate((Math.PI));
  10888. let tmpSprite = new Image();
  10889. toolSprites[items.weapons[i].src] = tmpSprite;
  10890. tmpSprite.onload = function () {
  10891. this.isLoaded = true;
  10892. let tmpPad = 1 / (this.height / this.width);
  10893. let tmpMlt = (items.weapons[i].iPad || 1);
  10894. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10895. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10896. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10897. tmpContext.globalCompositeOperation = "source-atop";
  10898. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10899. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10900. };
  10901. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10902. let tmpUnit = getEl('actionBarItem' + i);
  10903. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10904. // showItemInfo(items.weapons[i], true);
  10905. // });
  10906. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10907. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10908. });
  10909. UTILS.hookTouchEvents(tmpUnit);
  10910. } else {
  10911. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10912. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10913. tmpContext.globalAlpha = 1;
  10914. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10915. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10916. tmpContext.globalCompositeOperation = "source-atop";
  10917. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10918. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10919. let tmpUnit = getEl('actionBarItem' + i);
  10920. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10921. // showItemInfo(items.list[i - items.weapons.length]);
  10922. // });
  10923. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10924. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10925. });
  10926. UTILS.hookTouchEvents(tmpUnit);
  10927. }
  10928. })(i);
  10929. }
  10930. };
  10931. window.profineTest = function(data) {
  10932. if (data) {
  10933. // VALIDATE NAME:
  10934. let name = data + "";
  10935. name = name.slice(0, config.maxNameLength);
  10936.  
  10937. return name;
  10938. }
  10939. }
  10940. }(1)