🏠 Home 

Greasy Fork is available in English.

Diamond Hacker

Join our Discord — dsc.gg/moo-moo


Installer dette script?
  1. // ==UserScript==
  2. // @name Diamond Hacker
  3. // @match *://*.moomoo.io/*
  4. // @namespace Join our Discord — dsc.gg/moo-moo
  5. // @version 1.0
  6. // @description Join our Discord — dsc.gg/moo-moo
  7. // @run-at document_idle
  8. // @grant none
  9. // @author Pashka
  10. // @icon https://r2.e-z.host/b178d1da-d695-49e8-a6c1-9a15c1ddf697/lfsn1c1t.png
  11. // ==/UserScript==
  12. let founda = false;
  13. let scriptTags = document.getElementsByTagName("script");
  14. for (let i = 0; i < scriptTags.length; i++) {
  15. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  16. scriptTags[i].remove();
  17. founda = true;
  18. break;
  19. }
  20. }
  21. document.addEventListener("keydown", function(event) {
  22. if (event.keyCode === 45) {
  23. const chatHolder = document.getElementById("gameUI");
  24. if (chatHolder) {
  25. const currentDisplay = chatHolder.style.display;
  26. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  27. }
  28. }
  29. });
  30. var styleItem = document.createElement("style");
  31. styleItem.type = "text/css";
  32. styleItem.appendChild(document.createTextNode(`
  33. #suggestBox {
  34. width: 355px;
  35. border-radius: 3px;
  36. background-color: rgba(0,0,0,0.5);
  37. margin: auto;
  38. text-align: left;
  39. z-index: 49;
  40. pointer-events: auto;
  41. position: relative;
  42. bottom: 3.5px;
  43. overflow-y: auto;
  44. }
  45. #suggestBox div {
  46. background-color: rgba(255,255,255,0);
  47. color: rgba(255,255,255,1);
  48. transition: background-color 0.3s, color 0.3s;
  49. }
  50. #suggestBox div:hover {
  51. background-color: rgba(255,255,255,0.2);
  52. color: rgba(0,0,0,1);
  53. }
  54. .suggestBoxHard {
  55. color: rgba(255,255,255,1);
  56. font-size: 18px;
  57. }
  58. .suggestBoxLight {
  59. color: rgba(255,255,255,0.7);
  60. font-size: 18px;
  61. }
  62. `));
  63. document.head.appendChild(styleItem);
  64. window.addEventListener('load', function() {
  65. var allianceButton = document.getElementById('allianceButton');
  66. var storeButton = document.getElementById('storeButton');
  67. if (storeButton) {
  68. storeButton.style.right = '26px';
  69. storeButton.style.top = '420px';
  70. }
  71. if (allianceButton) {
  72. allianceButton.style.right = '26px';
  73. allianceButton.style.top = '479px';
  74. }
  75. });
  76. function getEl(id) {
  77. return document.getElementById(id);
  78. }
  79. let newFont = document.createElement("link");
  80. newFont.rel = "stylesheet";
  81. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  82. newFont.type = "text/css";
  83. document.body.append(newFont);
  84. let min = document.createElement("script");
  85. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  86. document.body.append(min);
  87. window.oncontextmenu = function() {
  88. return false;
  89. };
  90. let config = window.config;
  91. // CLIENT:
  92. config.clientSendRate = 9; // Aim Packet Send Rate
  93. config.serverUpdateRate = 9;
  94. // UI:
  95. config.deathFadeout = 0;
  96. config.playerCapacity = 9999;
  97. // CHECK IN SANDBOX:
  98. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  99. // CUSTOMIZATION:
  100. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  101. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  102. "#8bc373", "#91b2db"
  103. ];
  104. config.weaponVariants = [{
  105. id: 0,
  106. src: "",
  107. xp: 0,
  108. val: 1,
  109. }, {
  110. id: 1,
  111. src: "_g",
  112. xp: 3000,
  113. val: 1.1,
  114. }, {
  115. id: 2,
  116. src: "_d",
  117. xp: 7000,
  118. val: 1.18,
  119. }, {
  120. id: 3,
  121. src: "_r",
  122. poison: true,
  123. xp: 12000,
  124. val: 1.18,
  125. }, {
  126. id: 4,
  127. src: "_e",
  128. poison: true,
  129. heal: true,
  130. xp: 24000,
  131. val: 1.18,
  132. }];
  133. // VISUAL:
  134. config.anotherVisual = true;
  135. config.useWebGl = false;
  136. config.resetRender = true;
  137. function waitTime(timeout) {
  138. return new Promise((done) => {
  139. setTimeout(() => {
  140. done();
  141. }, timeout);
  142. });
  143. }
  144. let botSkts = [];
  145. // STORAGE:
  146. let canStore;
  147. if (typeof(Storage) !== "undefined") {
  148. canStore = true;
  149. }
  150. function saveVal(name, val) {
  151. if (canStore)
  152. localStorage.setItem(name, val);
  153. }
  154. function deleteVal(name) {
  155. if (canStore)
  156. localStorage.removeItem(name);
  157. }
  158. function getSavedVal(name) {
  159. if (canStore)
  160. return localStorage.getItem(name);
  161. return null;
  162. }
  163. // CONFIGS:
  164. let gC = function(a, b) {
  165. try {
  166. let res = JSON.parse(getSavedVal(a));
  167. if (typeof res === "object") {
  168. return b;
  169. } else {
  170. return res;
  171. }
  172. } catch (e) {
  173. alert("dieskid");
  174. return b;
  175. }
  176. };
  177. function setCommands() {
  178. return {
  179. "help": {
  180. desc: "Show Commands",
  181. action: function(message) {
  182. for (let cmds in commands) {
  183. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  184. }
  185. }
  186. },
  187. "clear": {
  188. desc: "Clear Chats",
  189. action: function(message) {
  190. resetMenuChText();
  191. }
  192. },
  193. "debug": {
  194. desc: "Debug Mod For Development",
  195. action: function(message) {
  196. addDeadPlayer(player);
  197. addMenuChText("Debug", "Done", "#99ee99", 1);
  198. }
  199. },
  200. "play": {
  201. desc: "Play Music ( /play [link] )",
  202. action: function(message) {
  203. let link = message.split(" ");
  204. if (link[1]) {
  205. let audio = new Audio(link[1]);
  206. audio.play();
  207. } else {
  208. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  209. }
  210. }
  211. },
  212. "bye": {
  213. desc: "Leave Game",
  214. action: function(message) {
  215. window.leave();
  216. }
  217. },
  218. };
  219. }
  220. function setConfigs() {
  221. return {
  222. killChat: false,
  223. autoBuy: true,
  224. autoBuyEquip: true,
  225. autoPush: true,
  226. revTick: true,
  227. spikeTick: true,
  228. predictTick: true,
  229. autoPlace: true,
  230. autoReplace: true,
  231. antiTrap: true,
  232. slowOT: false,
  233. attackDir: false,
  234. showDir: false,
  235. autoRespawn: false
  236. };
  237. }
  238. let commands = setCommands();
  239. let configs = setConfigs();
  240. window.removeConfigs = function() {
  241. for (let cF in configs) {
  242. deleteVal(cF, configs[cF]);
  243. }
  244. };
  245. for (let cF in configs) {
  246. configs[cF] = gC(cF, configs[cF]);
  247. }
  248. // MENU FUNCTIONS:
  249. window.changeMenu = function() {};
  250. window.debug = function() {};
  251. window.wasdMode = function() {};
  252. // PAGE 1:
  253. window.startGrind = function() {};
  254. // PAGE 3:
  255. window.connectFillBots = function() {};
  256. window.destroyFillBots = function() {};
  257. window.tryConnectBots = function() {};
  258. window.destroyBots = function() {};
  259. window.resBuild = function() {};
  260. window.toggleBotsCircle = function() {};
  261. window.toggleVisual = function() {};
  262. // SOME FUNCTIONS:
  263. window.prepareUI = function() {};
  264. window.leave = function() {};
  265. // nah hahahahahhh why good ping
  266. window.ping = 0;
  267. class deadfuturechickenmodrevival {
  268. constructor(flarez, lore) {
  269. this.inGame = false;
  270. this.lover = flarez + lore;
  271. this.baby = "ae86";
  272. this.isBlack = 0;
  273. this.webSocket = undefined;
  274. this.checkBaby = function() {
  275. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  276. if (this.isBlack >= 1) return "bl4cky";
  277. return "noting for you";
  278. };
  279. this.x2 = 0;
  280. this.y2 = 0;
  281. this.chat = "Imagine playing this badass game XDDDDD";
  282. this.summon = function(tmpObj) {
  283. this.x2 = tmpObj.x;
  284. this.y2 = tmpObj.y;
  285. this.chat = tmpObj.name + " ur so bad XDDDD";
  286. };
  287. this.commands = function(cmd) {
  288. cmd == "rv3link" && window.open("https://florr.io/");
  289. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  290. return cmd;
  291. };
  292. this.dayte = "11yearold";
  293. this.memeganoob = "69yearold";
  294. this.startDayteSpawn = function(tmpObj) {
  295. let ratio = setInterval(() => {
  296. this.x2 = tmpObj.x + 20;
  297. this.y2 = tmpObj.y - 20;
  298. this.chat = "UR SO BAD LOL";
  299. if (tmpObj.name == "ae86") {
  300. this.chat = "omg ae86 go run";
  301. setTimeout(() => {
  302. this.inGame = false;
  303. clearInterval(ratio);
  304. }, 1000);
  305. }
  306. }, 1234);
  307. };
  308. this.AntiChickenModV69420 = function(tmpObj) {
  309. return "!c!dc user " + tmpObj.name;
  310. };
  311. }
  312. };
  313. class HtmlAction {
  314. constructor(element) {
  315. this.element = element;
  316. };
  317. add(code) {
  318. if (!this.element) return undefined;
  319. this.element.innerHTML += code;
  320. };
  321. newLine(amount) {
  322. let r###lt = `<br>`;
  323. if (amount > 0) {
  324. r###lt = ``;
  325. for (let i = 0; i < amount; i++) {
  326. r###lt += `<br>`;
  327. }
  328. }
  329. this.add(r###lt);
  330. };
  331. checkBox(setting) {
  332. let newCheck = `<input type = "checkbox"`;
  333. setting.id && (newCheck += ` id = ${setting.id}`);
  334. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  335. setting.class && (newCheck += ` class = ${setting.class}`);
  336. setting.checked && (newCheck += ` checked`);
  337. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  338. newCheck += `>`;
  339. this.add(newCheck);
  340. };
  341. text(setting) {
  342. let newText = `<input type = "text"`;
  343. setting.id && (newText += ` id = ${setting.id}`);
  344. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  345. setting.class && (newText += ` class = ${setting.class}`);
  346. setting.size && (newText += ` size = ${setting.size}`);
  347. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  348. setting.value && (newText += ` value = ${setting.value}`);
  349. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  350. newText += `>`;
  351. this.add(newText);
  352. };
  353. select(setting) {
  354. let newSelect = `<select`;
  355. setting.id && (newSelect += ` id = ${setting.id}`);
  356. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  357. setting.class && (newSelect += ` class = ${setting.class}`);
  358. newSelect += `>`;
  359. for (let options in setting.option) {
  360. newSelect += `<option value = ${setting.option[options].id}`
  361. setting.option[options].selected && (newSelect += ` selected`);
  362. newSelect += `>${options}</option>`;
  363. }
  364. newSelect += `</select>`;
  365. this.add(newSelect);
  366. };
  367. button(setting) {
  368. let newButton = `<button`;
  369. setting.id && (newButton += ` id = ${setting.id}`);
  370. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  371. setting.class && (newButton += ` class = ${setting.class}`);
  372. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  373. newButton += `>`;
  374. setting.innerHTML && (newButton += setting.innerHTML);
  375. newButton += `</button>`;
  376. this.add(newButton);
  377. };
  378. selectMenu(setting) {
  379. let newSelect = `<select`;
  380. if (!setting.id) {
  381. alert("please put id skid");
  382. return;
  383. }
  384. window[setting.id + "Func"] = function() {};
  385. setting.id && (newSelect += ` id = ${setting.id}`);
  386. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  387. setting.class && (newSelect += ` class = ${setting.class}`);
  388. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  389. newSelect += `>`;
  390. let last;
  391. let i = 0;
  392. for (let options in setting.menu) {
  393. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  394. setting.menu[options] && (newSelect += ` checked`);
  395. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  396. i++;
  397. }
  398. newSelect += `</select>`;
  399. this.add(newSelect);
  400. i = 0;
  401. for (let options in setting.menu) {
  402. window[options + "Func"] = function() {
  403. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  404. saveVal(options, setting.menu[options]);
  405. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  406. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  407. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  408. };
  409. this.checkBox({
  410. id: "check_" + options,
  411. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  412. class: "checkB",
  413. onclick: `window.${options + "Func"}()`,
  414. checked: setting.menu[options]
  415. });
  416. i++;
  417. }
  418. last = "check_" + getEl(setting.id).value.split("_")[1];
  419. window[setting.id + "Func"] = function() {
  420. getEl(last).style.display = "none";
  421. last = "check_" + getEl(setting.id).value.split("_")[1];
  422. getEl(last).style.display = "inline-block";
  423. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  424. };
  425. };
  426. };
  427. class Html {
  428. constructor() {
  429. this.element = null;
  430. this.action = null;
  431. this.divElement = null;
  432. this.startDiv = function(setting, func) {
  433. let newDiv = document.createElement("div");
  434. setting.id && (newDiv.id = setting.id);
  435. setting.style && (newDiv.style = setting.style);
  436. setting.class && (newDiv.className = setting.class);
  437. this.element.appendChild(newDiv);
  438. this.divElement = newDiv;
  439. let addRes = new HtmlAction(newDiv);
  440. typeof func == "function" && func(addRes);
  441. };
  442. this.addDiv = function(setting, func) {
  443. let newDiv = document.createElement("div");
  444. setting.id && (newDiv.id = setting.id);
  445. setting.style && (newDiv.style = setting.style);
  446. setting.class && (newDiv.className = setting.class);
  447. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  448. this.divElement = newDiv;
  449. let addRes = new HtmlAction(newDiv);
  450. typeof func == "function" && func(addRes);
  451. };
  452. };
  453. set(id) {
  454. this.element = getEl(id);
  455. this.action = new HtmlAction(this.element);
  456. };
  457. resetHTML(text) {
  458. if (text) {
  459. this.element.innerHTML = ``;
  460. } else {
  461. this.element.innerHTML = ``;
  462. }
  463. };
  464. setStyle(style) {
  465. this.element.style = style;
  466. };
  467. setCSS(style) {
  468. this.action.add(`<style>` + style + `</style>`);
  469. };
  470. };
  471. let HTML = new Html();
  472. let menuDiv = document.createElement("div");
  473. menuDiv.id = "menuDiv";
  474. menuDiv.draggable = true;
  475. menuDiv.addEventListener("dragstart", function (e) {
  476. e.dataTransfer.setData("text/plain", "");
  477. });
  478. document.addEventListener("dragover", function (e) {
  479. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  480. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  481. });
  482. document.body.appendChild(menuDiv);
  483. HTML.set("menuDiv");
  484. HTML.setStyle(`
  485. position: absolute;
  486. left: 20px;
  487. top: 20px;
  488. `);
  489. HTML.resetHTML();
  490. HTML.setCSS(`
  491. .menuClass{
  492. color: #fff;
  493. font-size: 31px;
  494. text-align: left;
  495. padding: 10px;
  496. padding-top: 7px;
  497. padding-bottom: 5px;
  498. width: 300px;
  499. background-color: rgba(0, 0, 0, 0.25);
  500. -webkit-border-radius: 4px;
  501. -moz-border-radius: 4px;
  502. border-radius: 4px;
  503. }
  504. .menuC {
  505. display: none;
  506. font-family: "Hammersmith One";
  507. font-size: 12px;
  508. max-height: 180px;
  509. overflow-y: scroll;
  510. -webkit-touch-callout: none;
  511. -webkit-user-select: none;
  512. -khtml-user-select: none;
  513. -moz-user-select: none;
  514. -ms-user-select: none;
  515. user-select: none;
  516. }
  517. .menuB {
  518. text-align: center;
  519. background-color: rgb(25, 25, 25);
  520. color: #fff;
  521. -webkit-border-radius: 4px;
  522. -moz-border-radius: 4px;
  523. border-radius: 4px;
  524. border: 2px solid #000;
  525. cursor: pointer;
  526. }
  527. .menuB:hover {
  528. border: 2px solid #fff;
  529. }
  530. .menuB:active {
  531. color: rgb(25, 25, 25);
  532. background-color: rgb(200, 200, 200);
  533. }
  534. .customText {
  535. color: #000;
  536. -webkit-border-radius: 4px;
  537. -moz-border-radius: 4px;
  538. border-radius: 4px;
  539. border: 2px solid #000;
  540. }
  541. .customText:focus {
  542. background-color: yellow;
  543. }
  544. .checkB {
  545. position: relative;
  546. top: 2px;
  547. accent-color: #888;
  548. cursor: pointer;
  549. }
  550. .Cselect {
  551. -webkit-border-radius: 4px;
  552. -moz-border-radius: 4px;
  553. border-radius: 4px;
  554. background-color: rgb(75, 75, 75);
  555. color: #fff;
  556. border: 1px solid #000;
  557. }
  558. #menuChanger {
  559. position: absolute;
  560. right: 10px;
  561. top: 10px;
  562. background-color: rgba(0, 0, 0, 0);
  563. color: #fff;
  564. border: none;
  565. cursor: pointer;
  566. }
  567. #menuChanger:hover {
  568. color: #000;
  569. }
  570. ::-webkit-scrollbar {
  571. width: 10px;
  572. }
  573. ::-webkit-scrollbar-track {
  574. opacity: 0;
  575. }
  576. ::-webkit-scrollbar-thumb {
  577. background-color: rgb(25, 25, 25);
  578. -webkit-border-radius: 4px;
  579. -moz-border-radius: 4px;
  580. border-radius: 4px;
  581. }
  582. ::-webkit-scrollbar-thumb:active {
  583. background-color: rgb(230, 230, 230);
  584. }
  585. `);
  586. HTML.startDiv({
  587. id: "menuHeadLine",
  588. class: "menuClass"
  589. }, (html) => {
  590. html.add(`DiaMonD HAckEr mod:`);
  591. html.button({
  592. id: "menuChanger",
  593. class: "material-icons",
  594. innerHTML: `sync(do not)`,
  595. onclick: "window.changeMenu()"
  596. });
  597. HTML.addDiv({
  598. id: "menuButtons",
  599. style: "display: block; overflow-y: visible;",
  600. class: "menuC",
  601. appendID: "menuHeadLine"
  602. }, (html) => {
  603. html.button({
  604. class: "menuB",
  605. innerHTML: "Debug",
  606. onclick: "window.debug()"
  607. });
  608. });
  609. HTML.addDiv({
  610. id: "menuMain",
  611. style: "display: block",
  612. class: "menuC",
  613. appendID: "menuHeadLine"
  614. }, (html) => {
  615. html.button({
  616. class: "menuB",
  617. innerHTML: "Toggle Wasd Mode",
  618. onclick: "window.wasdMode()"
  619. });
  620. html.newLine();
  621. html.add(`Auto Grind: `);
  622. html.checkBox({
  623. id: "weaponGrind",
  624. class: "checkB",
  625. onclick: "window.startGrind()"
  626. });
  627. html.newLine(2);
  628. HTML.addDiv({
  629. style: "font-size: 20px; color: #99ee99;",
  630. appendID: "menuMain"
  631. }, (html) => {
  632. html.add(`Developing Settings:`);
  633. });
  634. html.add(`AntiPushing xd:`);
  635. html.checkBox({
  636. id: "antipush",
  637. class: "checkB",
  638. checked: true
  639. });
  640. html.newLine();
  641. html.add(`New BETA heal:`);
  642. html.checkBox({
  643. id: "healingBeta",
  644. class: "checkB",
  645. checked: true
  646. });
  647. html.newLine();
  648. });
  649. HTML.addDiv({
  650. id: "menuConfig",
  651. class: "menuC",
  652. appendID: "menuHeadLine"
  653. }, (html) => {
  654. html.add(`AutoPlacer Placement Tick: `);
  655. html.text({
  656. id: "autoPlaceTick",
  657. class: "customText",
  658. value: "2",
  659. size: "2em",
  660. maxLength: "1"
  661. });
  662. html.newLine();
  663. html.add(`Configs: `);
  664. html.selectMenu({
  665. id: "configsChanger",
  666. class: "Cselect",
  667. menu: configs
  668. });
  669. html.newLine();
  670. html.add(`InstaKill Type: `);
  671. html.select({
  672. id: "instaType",
  673. class: "Cselect",
  674. option: {
  675. OneShot: {
  676. id: "oneShot",
  677. selected: true
  678. },
  679. Spammer: {
  680. id: "spammer"
  681. }
  682. }
  683. });
  684. html.newLine();
  685. html.add(`AntiDiaX Type: `);
  686. html.select({
  687. id: "antiBullType",
  688. class: "Cselect",
  689. option: {
  690. "Disable AntiBull": {
  691. id: "noab",
  692. },
  693. "When Reloaded": {
  694. id: "abreload",
  695. selected: true
  696. },
  697. "Primary Reloaded": {
  698. id: "abalway"
  699. }
  700. }
  701. });
  702. html.newLine();
  703. html.add(`Backup Nobull Insta: `);
  704. html.checkBox({
  705. id: "backupNobull",
  706. class: "checkB",
  707. checked: true
  708. });
  709. html.newLine();
  710. html.add(`Turret Gear Combat Assistance: `);
  711. html.checkBox({
  712. id: "turretCombat",
  713. class: "checkB",
  714. checked: true
  715. });
  716. html.newLine();
  717. html.add(`Safe AntiSpikeTick: `);
  718. html.checkBox({
  719. id: "safeAntiSpikeTick",
  720. class: "checkB",
  721. checked: true
  722. });
  723. html.newLine();
  724. });
  725. HTML.addDiv({
  726. id: "menuOther",
  727. class: "menuC",
  728. appendID: "menuHeadLine"
  729. }, (html) => {
  730. html.button({
  731. class: "menuB",
  732. innerHTML: "Connect Bots",
  733. onclick: "window.tryConnectBots()"
  734. });
  735. html.button({
  736. class: "menuB",
  737. innerHTML: "Disconnect Bots",
  738. onclick: "window.destroyBots()"
  739. });
  740. html.newLine();
  741. html.button({
  742. class: "menuB",
  743. innerHTML: "Connect FBots",
  744. onclick: "window.connectFillBots()"
  745. });
  746. html.button({
  747. class: "menuB",
  748. innerHTML: "Disconnect FBots",
  749. onclick: "window.destroyFillBots()"
  750. });
  751. html.newLine();
  752. html.button({
  753. class: "menuB",
  754. innerHTML: "Reset Break Objects",
  755. onclick: "window.resBuild()"
  756. });
  757. html.newLine();
  758. html.add(`Break Objects Range: `);
  759. html.text({
  760. id: "breakRange",
  761. class: "customText",
  762. value: "700",
  763. size: "3em",
  764. maxLength: "4"
  765. });
  766. html.newLine();
  767. html.add(`Predict Movement Type: `);
  768. html.select({
  769. id: "predictType",
  770. class: "Cselect",
  771. option: {
  772. "Disable Render": {
  773. id: "disableRender",
  774. selected: true
  775. },
  776. "X/Y and 2": {
  777. id: "pre2",
  778. },
  779. "X/Y and 3": {
  780. id: "pre3"
  781. }
  782. }
  783. });
  784. html.newLine();
  785. html.add(`Render Placers: `);
  786. html.checkBox({
  787. id: "placeVis",
  788. class: "checkB",
  789. });
  790. html.newLine();
  791. html.add(`Bot Mode: `);
  792. html.select({
  793. id: "mode",
  794. class: "Cselect",
  795. option: {
  796. "Clear Building": {
  797. id: "clear",
  798. },
  799. "Sync": {
  800. id: "zync",
  801. selected: true
  802. },
  803. "Search": {
  804. id: "zearch"
  805. },
  806. "Clear Everything": {
  807. id: "####emup"
  808. },
  809. "Flex": {
  810. id: "flex"
  811. }
  812. }
  813. });
  814. html.newLine(2);
  815. html.button({
  816. class: "menuB",
  817. innerHTML: "Toggle Fbots Circle",
  818. onclick: "window.toggleBotsCircle()"
  819. });
  820. html.newLine();
  821. html.add(`Circle Rad: `);
  822. html.text({
  823. id: "circleRad",
  824. class: "customText",
  825. value: "200",
  826. size: "3em",
  827. maxLength: "4"
  828. });
  829. html.newLine();
  830. html.add(`Rad Speed: `);
  831. html.text({
  832. id: "radSpeed",
  833. class: "customText",
  834. value: "0.1",
  835. size: "2em",
  836. maxLength: "3"
  837. });
  838. html.newLine();
  839. html.add(`Bot Zetup Type: `);
  840. html.select({
  841. id: "setup",
  842. class: "Cselect",
  843. option: {
  844. "Dagger Musket": {
  845. id: "dm",
  846. selected: true
  847. },
  848. "Katana Hammer": {
  849. id: "kh",
  850. },
  851. "Dagger Repeater-Crossbow": {
  852. id: "dr"
  853. },
  854. "Zhort-Zword Muzket": {
  855. id: "zd"
  856. }
  857. }
  858. });
  859. html.newLine(2);
  860. html.add(`Cross World: `);
  861. html.checkBox({
  862. id: "funni",
  863. class: "checkB"
  864. });
  865. html.newLine();
  866. html.button({
  867. class: "menuB",
  868. innerHTML: "Toggle Another Visual",
  869. onclick: "window.toggleVisual()"
  870. });
  871. html.newLine();
  872. });
  873. });
  874. let menuChatDiv = document.createElement("div");
  875. menuChatDiv.id = "menuChatDiv";
  876. document.body.appendChild(menuChatDiv);
  877. HTML.set("menuChatDiv");
  878. HTML.setStyle(`
  879. position: absolute;
  880. display: none;
  881. left: 0px;
  882. top: 25px;
  883. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  884. `);
  885. HTML.resetHTML();
  886. HTML.setCSS(`
  887. .chDiv {
  888. color: #fff;
  889. padding: 10px;
  890. width: 357px;
  891. height: 217px;
  892. background-color: rgba(0, 0, 0, 0.2);
  893. font-family: "HammerSmith One", monospace;
  894. // border-radius: 15px;
  895. // box-shadow: black 1px 2px 19px;
  896. //backdrop-filter: blur(3px);
  897. }
  898. .chMainDiv {
  899. font-family: "Ubuntu";
  900. font-size: 16px;
  901. max-height: 215px;
  902. overflow-y: scroll;
  903. scrollbar-width: thin;
  904. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  905. -webkit-touch-callout: none;
  906. -webkit-user-select: none;
  907. -khtml-user-select: none;
  908. -moz-user-select: none;
  909. -ms-user-select: none;
  910. user-select: none;
  911. overflow-x: hidden;
  912. }
  913. .chMainDiv::-webkit-scrollbar {
  914. width: 8px;
  915. }
  916. .chMainDiv::-webkit-scrollbar-thumb {
  917. background-color: rgba(0, 0, 0, 0.5);
  918. }
  919. .chMainDiv::-webkit-scrollbar-thumb:hover {
  920. background-color: rgba(0, 0, 0, 0.7);
  921. }
  922. .chMainBox {
  923. display:none;
  924. position: absolute;
  925. left: 10px;
  926. bottom: 10px;
  927. width: 380px;
  928. height: 25px;
  929. background-color: rgba(255, 255, 255, 0.1);
  930. border-radius: 5px;
  931. color: rgba(255, 255, 255, 0.75);
  932. font-family: "HammerSmith One";
  933. font-size: 12px;
  934. }
  935. `);
  936. HTML.startDiv({
  937. id: "mChDiv",
  938. class: "chDiv"
  939. }, (html) => {
  940. HTML.addDiv({
  941. id: "mChMain",
  942. class: "chMainDiv",
  943. appendID: "mChDiv"
  944. }, (html) => {});
  945. html.text({
  946. id: "mChBox",
  947. class: "chMainBox",
  948. // placeHolder: `To chat click here or press "Enter" key`
  949. });
  950. });
  951. let menuChats = getEl("mChMain");
  952. let menuChatBox = getEl("mChBox");
  953. let menuCBFocus = false;
  954. let menuChCounts = 0;
  955. menuChatBox.value = "";
  956. menuChatBox.addEventListener("focus", () => {
  957. menuCBFocus = true;
  958. });
  959. menuChatBox.addEventListener("blur", () => {
  960. menuCBFocus = false;
  961. });
  962. function addMenuChText(name, message, color, noTimer) {
  963. HTML.set("menuChatDiv");
  964. color = color || "white";
  965. let time = new Date();
  966. let min = time.getMinutes();
  967. let hour = time.getHours();
  968. let text = ``;
  969. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  970. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  971. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  972. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  973. html.add(text);
  974. });
  975. menuChats.scrollTop = menuChats.scrollHeight;
  976. menuChCounts++;
  977. }
  978. function chch(name, message, color, noTimer) {
  979. HTML.set("menuChatDiv");
  980. color = color || "white";
  981. let time = new Date();
  982. let text = ``;
  983. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  984. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  985. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  986. html.add(text);
  987. });
  988. menuChats.scrollTop = menuChats.scrollHeight;
  989. menuChCounts++;
  990. }
  991. function resetMenuChText() {
  992. menuChats.innerHTML = ``;
  993. menuChCounts = 0;
  994. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  995. }
  996. resetMenuChText();
  997. let menuIndex = 0;
  998. let menus = ["menuMain", "menuConfig", "menuOther"];
  999. window.changeMenu = function() {
  1000. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1001. menuIndex++;
  1002. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1003. };
  1004. let mStatus = document.createElement("div");
  1005. mStatus.id = "status";
  1006. getEl("gameUI").appendChild(mStatus);
  1007. HTML.set("status");
  1008. HTML.setStyle(`
  1009. display: block;
  1010. position: absolute;
  1011. color: #ddd;
  1012. font: 15px Hammersmith One;
  1013. bottom: 215px;
  1014. left: 20px;
  1015. `);
  1016. HTML.resetHTML();
  1017. HTML.setCSS(`
  1018. .sizing {
  1019. font-size: 15px;
  1020. }
  1021. .mod {
  1022. font-size: 15px;
  1023. display: inline-block;
  1024. }
  1025. `);
  1026. HTML.startDiv({
  1027. id: "uehmod",
  1028. class: "sizing"
  1029. }, (html) => {
  1030. html.add(`Ping: `);
  1031. HTML.addDiv({
  1032. id: "pingFps",
  1033. class: "mod",
  1034. appendID: "uehmod"
  1035. }, (html) => {
  1036. html.add("None");
  1037. });
  1038. html.newLine();
  1039. html.add(`Packet: `);
  1040. HTML.addDiv({
  1041. id: "packetStatus",
  1042. class: "mod",
  1043. appendID: "uehmod"
  1044. }, (html) => {
  1045. html.add("None");
  1046. });
  1047. });
  1048. /*function modLog() {
  1049. let logs = [];
  1050. for (let i = 0; i < arguments.length; i++) {
  1051. logs.push(arguments[i]);
  1052. }
  1053. getEl("modLog").innerHTML = logs;
  1054. }*/
  1055. let openMenu = false;
  1056. let WS = undefined;
  1057. let socketID = undefined;
  1058. let useWasd = false;
  1059. let secPacket = 0;
  1060. let secMax = 120;
  1061. let secTime = 1000;
  1062. let firstSend = {
  1063. sec: false
  1064. };
  1065. let game = {
  1066. tick: 0,
  1067. tickQueue: [],
  1068. tickBase: function(set, tick) {
  1069. if (this.tickQueue[this.tick + tick]) {
  1070. this.tickQueue[this.tick + tick].push(set);
  1071. } else {
  1072. this.tickQueue[this.tick + tick] = [set];
  1073. }
  1074. },
  1075. tickRate: (1000 / config.serverUpdateRate),
  1076. tickSpeed: 0,
  1077. lastTick: performance.now()
  1078. };
  1079. let modConsole = [];
  1080. let dontSend = false;
  1081. let fpsTimer = {
  1082. last: 0,
  1083. time: 0,
  1084. ltime: 0
  1085. }
  1086. let lastMoveDir = undefined;
  1087. let lastsp = ["cc", 1, "__proto__"];
  1088. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1089. WebSocket.prototype.send = function(message) {
  1090. if (!WS) {
  1091. WS = this;
  1092. WS.addEventListener("message", function(msg) {
  1093. getMessage(msg);
  1094. });
  1095. WS.addEventListener("close", (event) => {
  1096. if (event.code == 4001) {
  1097. window.location.reload();
  1098. }
  1099. });
  1100. }
  1101. if (WS == this) {
  1102. dontSend = false;
  1103. // EXTRACT DATA ARRAY:
  1104. let data = new Uint8Array(message);
  1105. let parsed = window.msgpack.decode(data);
  1106. let type = parsed[0];
  1107. data = parsed[1];
  1108. // SEND MESSAGE:
  1109. if (type == "6") {
  1110. if (data[0]) {
  1111. // ANTI PROFANITY:
  1112. let profanity = ["cunt", "whore", "####", "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", ];
  1113. let tmpString;
  1114. profanity.forEach((profany) => {
  1115. if (data[0].indexOf(profany) > -1) {
  1116. tmpString = "";
  1117. for (let i = 0; i < profany.length; ++i) {
  1118. if (i == 1) {
  1119. tmpString += String.fromCharCode(0);
  1120. }
  1121. tmpString += profany[i];
  1122. }
  1123. let re = new RegExp(profany, "g");
  1124. data[0] = data[0].replace(re, tmpString);
  1125. }
  1126. });
  1127. // FIX CHAT:
  1128. data[0] = data[0].slice(0, 30);
  1129. }
  1130. } else if (type == "L") {
  1131. // MAKE SAME CLAN:
  1132. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1133. data[0] = data[0].slice(0, 7);
  1134. } else if (type == "M") {
  1135. // APPLY CYAN COLOR:
  1136. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1137. data[0].moofoll = true;
  1138. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1139. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1140. } else if (type == "D") {
  1141. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1142. dontSend = true;
  1143. } else {
  1144. my.lastDir = data[0];
  1145. }
  1146. } else if (type == "d") {
  1147. if (!data[2]) {
  1148. dontSend = true;
  1149. } else {
  1150. if (![null, undefined].includes(data[1])) {
  1151. my.lastDir = data[1];
  1152. }
  1153. }
  1154. } else if (type == "K") {
  1155. if (!data[1]) {
  1156. dontSend = true;
  1157. }
  1158. } else if (type == "S") {
  1159. instaC.wait = !instaC.wait;
  1160. dontSend = true;
  1161. } else if (type == "a") {
  1162. if (data[1]) {
  1163. if (player.moveDir == data[0]) {
  1164. dontSend = true;
  1165. }
  1166. player.moveDir = data[0];
  1167. } else {
  1168. dontSend = true;
  1169. }
  1170. }
  1171. if (!dontSend) {
  1172. let binary = window.msgpack.encode([type, data]);
  1173. this.nsend(binary);
  1174. // START COUNT:
  1175. if (!firstSend.sec) {
  1176. firstSend.sec = true;
  1177. setTimeout(() => {
  1178. firstSend.sec = false;
  1179. secPacket = 0;
  1180. }, secTime);
  1181. }
  1182. secPacket++;
  1183. }
  1184. } else {
  1185. this.nsend(message);
  1186. }
  1187. }
  1188. function packet(type) {
  1189. // EXTRACT DATA ARRAY:
  1190. let data = Array.prototype.slice.call(arguments, 1);
  1191. // SEND MESSAGE:
  1192. let binary = window.msgpack.encode([type, data]);
  1193. WS.send(binary);
  1194. }
  1195. function origPacket(type) {
  1196. // EXTRACT DATA ARRAY:
  1197. let data = Array.prototype.slice.call(arguments, 1);
  1198. // SEND MESSAGE:
  1199. let binary = window.msgpack.encode([type, data]);
  1200. WS.nsend(binary);
  1201. }
  1202. window.leave = function() {
  1203. origPacket("kys", {
  1204. "frvr is so bad": true,
  1205. "sidney is too good": true,
  1206. "dev are too weak": true,
  1207. });
  1208. };
  1209. //...lol
  1210. let io = {
  1211. send: packet
  1212. };
  1213. function getMessage(message) {
  1214. let data = new Uint8Array(message.data);
  1215. let parsed = window.msgpack.decode(data);
  1216. let type = parsed[0];
  1217. data = parsed[1];
  1218. let events = {
  1219. A: setInitData, // id: setInitData,
  1220. //B: disconnect,
  1221. C: setupGame, // 1: setupGame,
  1222. D: addPlayer, // 2: addPlayer,
  1223. E: removePlayer, // 4: removePlayer,
  1224. a: updatePlayers, // 33: updatePlayers,
  1225. G: updateLeaderboard, // 5: updateLeaderboard,here
  1226. H: loadGameObject, // 6: loadGameObject,
  1227. I: loadAI, // a: loadAI,
  1228. J: animateAI, // aa: animateAI,
  1229. K: gatherAnimation, // 7: gatherAnimation,
  1230. L: wiggleGameObject, // 8: wiggleGameObject,
  1231. M: shootTurret, // sp: shootTurret,
  1232. N: updatePlayerValue, // 9: updatePlayerValue,
  1233. O: updateHealth, // h: updateHealth,//here
  1234. P: killPlayer, // 11: killPlayer,
  1235. Q: killObject, // 12: killObject,
  1236. R: killObjects, // 13: killObjects,
  1237. S: updateItemCounts, // 14: updateItemCounts,
  1238. T: updateAge, // 15: updateAge,
  1239. U: updateUpgrades, // 16: updateUpgrades,
  1240. V: updateItems, // 17: updateItems,
  1241. X: addProjectile, // 18: addProjectile,
  1242. // Y: remProjectile, // 19: remProjectile,
  1243. //Z: serverShutdownNotice,
  1244. //0: addAlliance,
  1245. //1: deleteAlliance,
  1246. 2: allianceNotification, // an: allianceNotification,
  1247. 3: setPlayerTeam, // st: setPlayerTeam,
  1248. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1249. 5: updateStoreItems, // us: updateStoreItems,
  1250. 6: receiveChat, // ch: receiveChat,
  1251. 7: updateMinimap, // mm: updateMinimap,
  1252. 8: showText, // t: showText,
  1253. 9: pingMap, // p: pingMap,
  1254. 0: pingSocketResponse,
  1255. };
  1256. if (type == "io-init") {
  1257. socketID = data[0];
  1258. } else {
  1259. if (events[type]) {
  1260. events[type].apply(undefined, data);
  1261. }
  1262. }
  1263. }
  1264. // MATHS:
  1265. Math.lerpAngle = function(value1, value2, amount) {
  1266. let difference = Math.abs(value2 - value1);
  1267. if (difference > Math.PI) {
  1268. if (value1 > value2) {
  1269. value2 += Math.PI * 2;
  1270. } else {
  1271. value1 += Math.PI * 2;
  1272. }
  1273. }
  1274. let value = value2 + ((value1 - value2) * amount);
  1275. if (value >= 0 && value <= Math.PI * 2) return value;
  1276. return value % (Math.PI * 2);
  1277. };
  1278. // REOUNDED RECTANGLE:
  1279. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1280. if (w < 2 * r) r = w / 2;
  1281. if (h < 2 * r) r = h / 2;
  1282. if (r < 0)
  1283. r = 0;
  1284. this.beginPath();
  1285. this.moveTo(x + r, y);
  1286. this.arcTo(x + w, y, x + w, y + h, r);
  1287. this.arcTo(x + w, y + h, x, y + h, r);
  1288. this.arcTo(x, y + h, x, y, r);
  1289. this.arcTo(x, y, x + w, y, r);
  1290. this.closePath();
  1291. return this;
  1292. };
  1293. // GLOBAL VALUES:
  1294. function resetMoveDir() {
  1295. keys = {};
  1296. io.send("e");
  1297. }
  1298. let allChats = [];
  1299. let ticks = {
  1300. tick: 0,
  1301. delay: 0,
  1302. time: [],
  1303. manage: [],
  1304. };
  1305. let ais = [];
  1306. let players = [];
  1307. let alliances = [];
  1308. let alliancePlayers = [];
  1309. let allianceNotifications = [];
  1310. let gameObjects = [];
  1311. let liztobj = [];
  1312. let projectiles = [];
  1313. let deadPlayers = [];
  1314. let breakObjects = [];
  1315. let player;
  1316. let playerSID;
  1317. let tmpObj;
  1318. let enemy = [];
  1319. let nears = [];
  1320. let near = [];
  1321. let my = {
  1322. reloaded: false,
  1323. waitHit: 0,
  1324. autoAim: false,
  1325. revAim: false,
  1326. ageInsta: true,
  1327. reSync: false,
  1328. bullTick: 0,
  1329. anti0Tick: 0,
  1330. antiSync: false,
  1331. safePrimary: function(tmpObj) {
  1332. return [0, 8].includes(tmpObj.primaryIndex);
  1333. },
  1334. safeSecondary: function(tmpObj) {
  1335. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1336. },
  1337. lastDir: 0,
  1338. autoPush: false,
  1339. pushData: {}
  1340. }
  1341. // FIND OBJECTS BY ID/SID:
  1342. function findID(tmpObj, tmp) {
  1343. return tmpObj.find((THIS) => THIS.id == tmp);
  1344. }
  1345. function findSID(tmpObj, tmp) {
  1346. return tmpObj.find((THIS) => THIS.sid == tmp);
  1347. }
  1348. function findPlayerByID(id) {
  1349. return findID(players, id);
  1350. }
  1351. function findPlayerBySID(sid) {
  1352. return findSID(players, sid);
  1353. }
  1354. function findAIBySID(sid) {
  1355. return findSID(ais, sid);
  1356. }
  1357. function findObjectBySid(sid) {
  1358. return findSID(gameObjects, sid);
  1359. }
  1360. function findProjectileBySid(sid) {
  1361. return findSID(gameObjects, sid);
  1362. }
  1363. let adCard = getEl("adCard");
  1364. adCard.remove();
  1365. let promoImageHolder = getEl("promoImgHolder");
  1366. promoImageHolder.remove();
  1367. let chatButton = getEl("chatButton");
  1368. chatButton.remove();
  1369. let gameCanvas = getEl("gameCanvas");
  1370. let mainContext = gameCanvas.getContext("2d");
  1371. let mapDisplay = getEl("mapDisplay");
  1372. let mapContext = mapDisplay.getContext("2d");
  1373. mapDisplay.width = 300;
  1374. mapDisplay.height = 300;
  1375. let storeMenu = getEl("storeMenu");
  1376. let storeHolder = getEl("storeHolder");
  1377. let upgradeHolder = getEl("upgradeHolder");
  1378. let upgradeCounter = getEl("upgradeCounter");
  1379. let chatBox = getEl("chatBox");
  1380. chatBox.autocomplete = "off";
  1381. chatBox.style.textAlign = "center";
  1382. chatBox.style.width = "18em";
  1383. let chatHolder = getEl("chatHolder");
  1384. let actionBar = getEl("actionBar");
  1385. let leaderboardData = getEl("leaderboardData");
  1386. let itemInfoHolder = getEl("itemInfoHolder");
  1387. let menuCardHolder = getEl("menuCardHolder");
  1388. let mainMenu = getEl("mainMenu");
  1389. let diedText = getEl("diedText");
  1390. let screenWidth;
  1391. let screenHeight;
  1392. let maxScreenWidth = config.maxScreenWidth;
  1393. let maxScreenHeight = config.maxScreenHeight;
  1394. let pixelDensity = 1;
  1395. let delta;
  1396. let now;
  1397. let lastUpdate = performance.now();
  1398. let camX;
  1399. let camY;
  1400. let tmpDir;
  1401. let mouseX = 0;
  1402. let mouseY = 0;
  1403. let allianceMenu = getEl("allianceMenu");
  1404. let waterMult = 1;
  1405. let waterPlus = 0;
  1406. let outlineColor = "#525252";
  1407. let darkOutlineColor = "#3d3f42";
  1408. let outlineWidth = 5.5;
  1409. let firstSetup = true;
  1410. let keys = {};
  1411. let moveKeys = {
  1412. 87: [0, -1],
  1413. 38: [0, -1],
  1414. 83: [0, 1],
  1415. 40: [0, 1],
  1416. 65: [-1, 0],
  1417. 37: [-1, 0],
  1418. 68: [1, 0],
  1419. 39: [1, 0],
  1420. };
  1421. let attackState = 0;
  1422. let inGame = false;
  1423. let macro = {};
  1424. let mills = {
  1425. place: 0,
  1426. placeSpawnPads: 0
  1427. };
  1428. let lastDir;
  1429. let lastLeaderboardData = [];
  1430. // ON LOAD:
  1431. let inWindow = true;
  1432. window.onblur = function() {
  1433. inWindow = false;
  1434. };
  1435. window.onfocus = function() {
  1436. inWindow = true;
  1437. if (player && player.alive) {
  1438. // resetMoveDir();
  1439. }
  1440. };
  1441. let ms = {
  1442. avg: 0,
  1443. max: 0,
  1444. min: 0,
  1445. delay: 0
  1446. }
  1447. function pingSocketResponse() {
  1448. let pingTime = window.pingTime;
  1449. const pingDisplay = document.getElementById("pingDisplay")
  1450. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1451. if (pingTime > ms.max || isNaN(ms.max)) {
  1452. ms.max = pingTime;
  1453. }
  1454. if (pingTime < ms.min || isNaN(ms.min)) {
  1455. ms.min = pingTime;
  1456. }
  1457. // if (pingTime >= 90) {
  1458. // doAutoQ = true;
  1459. // } else {
  1460. // doAutoQ = false;
  1461. // }
  1462. }
  1463. let placeVisible = [];
  1464. /** CLASS CODES */
  1465. class Utils {
  1466. constructor() {
  1467. // MATH UTILS:
  1468. let mathABS = Math.abs,
  1469. mathCOS = Math.cos,
  1470. mathSIN = Math.sin,
  1471. mathPOW = Math.pow,
  1472. mathSQRT = Math.sqrt,
  1473. mathATAN2 = Math.atan2,
  1474. mathPI = Math.PI;
  1475. let _this = this;
  1476. // GLOBAL UTILS:
  1477. this.round = function(n, v) {
  1478. return Math.round(n * v) / v;
  1479. };
  1480. this.toRad = function(angle) {
  1481. return angle * (mathPI / 180);
  1482. };
  1483. this.toAng = function(radian) {
  1484. return radian / (mathPI / 180);
  1485. };
  1486. this.randInt = function(min, max) {
  1487. return Math.floor(Math.random() * (max - min + 1)) + min;
  1488. };
  1489. this.randFloat = function(min, max) {
  1490. return Math.random() * (max - min + 1) + min;
  1491. };
  1492. this.lerp = function(value1, value2, amount) {
  1493. return value1 + (value2 - value1) * amount;
  1494. };
  1495. this.decel = function(val, cel) {
  1496. if (val > 0)
  1497. val = Math.max(0, val - cel);
  1498. else if (val < 0)
  1499. val = Math.min(0, val + cel);
  1500. return val;
  1501. };
  1502. this.getDistance = function(x1, y1, x2, y2) {
  1503. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1504. };
  1505. this.getDist = function(tmp1, tmp2, type1, type2) {
  1506. let tmpXY1 = {
  1507. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1508. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1509. };
  1510. let tmpXY2 = {
  1511. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1512. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1513. };
  1514. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1515. };
  1516. this.getDirection = function(x1, y1, x2, y2) {
  1517. return mathATAN2(y1 - y2, x1 - x2);
  1518. };
  1519. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1520. let tmpXY1 = {
  1521. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1522. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1523. };
  1524. let tmpXY2 = {
  1525. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1526. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1527. };
  1528. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1529. };
  1530. this.getAngleDist = function(a, b) {
  1531. let p = mathABS(b - a) % (mathPI * 2);
  1532. return (p > mathPI ? (mathPI * 2) - p : p);
  1533. };
  1534. this.isNumber = function(n) {
  1535. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1536. };
  1537. this.isString = function(s) {
  1538. return (s && typeof s == "string");
  1539. };
  1540. this.kFormat = function(num) {
  1541. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1542. };
  1543. this.sFormat = function(num) {
  1544. let fixs = [{
  1545. num: 1e3,
  1546. string: "k"
  1547. },
  1548. {
  1549. num: 1e6,
  1550. string: "m"
  1551. },
  1552. {
  1553. num: 1e9,
  1554. string: "b"
  1555. },
  1556. {
  1557. num: 1e12,
  1558. string: "q"
  1559. }
  1560. ].reverse();
  1561. let sp = fixs.find(v => num >= v.num);
  1562. if (!sp) return num;
  1563. return (num / sp.num).toFixed(1) + sp.string;
  1564. };
  1565. this.capitalizeFirst = function(string) {
  1566. return string.charAt(0).toUpperCase() + string.slice(1);
  1567. };
  1568. this.fixTo = function(n, v) {
  1569. return parseFloat(n.toFixed(v));
  1570. };
  1571. this.sortByPoints = function(a, b) {
  1572. return parseFloat(b.points) - parseFloat(a.points);
  1573. };
  1574. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1575. let minX = x1;
  1576. let maxX = x2;
  1577. if (x1 > x2) {
  1578. minX = x2;
  1579. maxX = x1;
  1580. }
  1581. if (maxX > recX2)
  1582. maxX = recX2;
  1583. if (minX < recX)
  1584. minX = recX;
  1585. if (minX > maxX)
  1586. return false;
  1587. let minY = y1;
  1588. let maxY = y2;
  1589. let dx = x2 - x1;
  1590. if (Math.abs(dx) > 0.0000001) {
  1591. let a = (y2 - y1) / dx;
  1592. let b = y1 - a * x1;
  1593. minY = a * minX + b;
  1594. maxY = a * maxX + b;
  1595. }
  1596. if (minY > maxY) {
  1597. let tmp = maxY;
  1598. maxY = minY;
  1599. minY = tmp;
  1600. }
  1601. if (maxY > recY2)
  1602. maxY = recY2;
  1603. if (minY < recY)
  1604. minY = recY;
  1605. if (minY > maxY)
  1606. return false;
  1607. return true;
  1608. };
  1609. this.containsPoint = function(element, x, y) {
  1610. let bounds = element.getBoundingClientRect();
  1611. let left = bounds.left + window.scrollX;
  1612. let top = bounds.top + window.scrollY;
  1613. let width = bounds.width;
  1614. let height = bounds.height;
  1615. let insideHorizontal = x > left && x < left + width;
  1616. let insideVertical = y > top && y < top + height;
  1617. return insideHorizontal && insideVertical;
  1618. };
  1619. this.mousifyTouchEvent = function(event) {
  1620. let touch = event.changedTouches[0];
  1621. event.screenX = touch.screenX;
  1622. event.screenY = touch.screenY;
  1623. event.clientX = touch.clientX;
  1624. event.clientY = touch.clientY;
  1625. event.pageX = touch.pageX;
  1626. event.pageY = touch.pageY;
  1627. };
  1628. this.hookTouchEvents = function(element, skipPrevent) {
  1629. let preventDefault = !skipPrevent;
  1630. let isHovering = false;
  1631. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1632. let passive = false;
  1633. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1634. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1635. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1636. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1637. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1638. function touchStart(e) {
  1639. _this.mousifyTouchEvent(e);
  1640. window.setUsingTouch(true);
  1641. if (preventDefault) {
  1642. e.preventDefault();
  1643. e.stopPropagation();
  1644. }
  1645. if (element.onmouseover)
  1646. element.onmouseover(e);
  1647. isHovering = true;
  1648. }
  1649. function touchMove(e) {
  1650. _this.mousifyTouchEvent(e);
  1651. window.setUsingTouch(true);
  1652. if (preventDefault) {
  1653. e.preventDefault();
  1654. e.stopPropagation();
  1655. }
  1656. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1657. if (!isHovering) {
  1658. if (element.onmouseover)
  1659. element.onmouseover(e);
  1660. isHovering = true;
  1661. }
  1662. } else {
  1663. if (isHovering) {
  1664. if (element.onmouseout)
  1665. element.onmouseout(e);
  1666. isHovering = false;
  1667. }
  1668. }
  1669. }
  1670. function touchEnd(e) {
  1671. _this.mousifyTouchEvent(e);
  1672. window.setUsingTouch(true);
  1673. if (preventDefault) {
  1674. e.preventDefault();
  1675. e.stopPropagation();
  1676. }
  1677. if (isHovering) {
  1678. if (element.onclick)
  1679. element.onclick(e);
  1680. if (element.onmouseout)
  1681. element.onmouseout(e);
  1682. isHovering = false;
  1683. }
  1684. }
  1685. };
  1686. this.removeAllChildren = function(element) {
  1687. while (element.hasChildNodes()) {
  1688. element.removeChild(element.lastChild);
  1689. }
  1690. };
  1691. this.generateElement = function(config) {
  1692. let element = document.createElement(config.tag || "div");
  1693. function bind(configValue, elementValue) {
  1694. if (config[configValue])
  1695. element[elementValue] = config[configValue];
  1696. }
  1697. bind("text", "textContent");
  1698. bind("html", "innerHTML");
  1699. bind("class", "className");
  1700. for (let key in config) {
  1701. switch (key) {
  1702. case "tag":
  1703. case "text":
  1704. case "html":
  1705. case "class":
  1706. case "style":
  1707. case "hookTouch":
  1708. case "parent":
  1709. case "children":
  1710. continue;
  1711. default:
  1712. break;
  1713. }
  1714. element[key] = config[key];
  1715. }
  1716. if (element.onclick)
  1717. element.onclick = this.checkTrusted(element.onclick);
  1718. if (element.onmouseover)
  1719. element.onmouseover = this.checkTrusted(element.onmouseover);
  1720. if (element.onmouseout)
  1721. element.onmouseout = this.checkTrusted(element.onmouseout);
  1722. if (config.style) {
  1723. element.style.cssText = config.style;
  1724. }
  1725. if (config.hookTouch) {
  1726. this.hookTouchEvents(element);
  1727. }
  1728. if (config.parent) {
  1729. config.parent.appendChild(element);
  1730. }
  1731. if (config.children) {
  1732. for (let i = 0; i < config.children.length; i++) {
  1733. element.appendChild(config.children[i]);
  1734. }
  1735. }
  1736. return element;
  1737. };
  1738. this.checkTrusted = function(callback) {
  1739. return function(ev) {
  1740. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1741. callback(ev);
  1742. } else {
  1743. //console.error("Event is not trusted.", ev);
  1744. }
  1745. };
  1746. };
  1747. this.randomString = function(length) {
  1748. let text = "";
  1749. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1750. for (let i = 0; i < length; i++) {
  1751. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1752. }
  1753. return text;
  1754. };
  1755. this.countInArray = function(array, val) {
  1756. let count = 0;
  1757. for (let i = 0; i < array.length; i++) {
  1758. if (array[i] === val) count++;
  1759. }
  1760. return count;
  1761. };
  1762. this.hexToRgb = function(hex) {
  1763. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1764. };
  1765. this.getRgb = function(r, g, b) {
  1766. return [r / 255, g / 255, b / 255].join(", ");
  1767. };
  1768. }
  1769. };
  1770. class Animtext {
  1771. // ANIMATED TEXT:
  1772. constructor() {
  1773. // INIT:
  1774. this.init = function(x, y, scale, speed, life, text, color) {
  1775. (this.x = x),
  1776. (this.y = y),
  1777. (this.color = color),
  1778. (this.scale = scale*3.5),
  1779. (this.weight = 50);
  1780. (this.startScale = this.scale * 1.2),
  1781. (this.maxScale = 1.5 * scale),
  1782. (this.minScale = 0.5 * scale),
  1783. (this.scaleSpeed = 0.7),
  1784. (this.speed = speed),
  1785. (this.speedMax = speed),
  1786. (this.life = life),
  1787. (this.maxLife = life),
  1788. (this.text = text),
  1789. this.movSpeed = speed;
  1790. };
  1791. // UPDATE:
  1792. this.update = function(delta) {
  1793. if(this.life){
  1794. this.life -= delta;
  1795. if(this.scaleSpeed != -0.35){
  1796. this.y -= this.speed * delta;
  1797. // (this.x += this.speed * delta);
  1798. } else {
  1799. this.y -= this.speed * delta;
  1800. }
  1801. this.scale -= .8;
  1802. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  1803. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  1804. if(this.scale >= this.maxScale){
  1805. this.scale = this.maxScale;
  1806. this.scaleSpeed *= -.5;
  1807. this.speed = this.speed * .75;
  1808. };
  1809. this.life <= 0 && (this.life = 0)
  1810. };
  1811. };
  1812. // RENDER:
  1813. this.render = function(ctxt, xOff, yOff) {
  1814. ctxt.lineWidth = 10;
  1815. ctxt.strokeStyle = darkOutlineColor; //"black";
  1816. ctxt.fillStyle = this.color;
  1817. ctxt.globalAlpha = 1;
  1818. ctxt.font = this.scale + "px Hammersmith One";
  1819. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1820. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1821. ctxt.globalAlpha = 1;
  1822. };
  1823. }
  1824. };
  1825. class Textmanager {
  1826. // TEXT MANAGER:
  1827. constructor() {
  1828. this.texts = [];
  1829. this.stack = [];
  1830. // UPDATE:
  1831. this.update = function(delta, ctxt, xOff, yOff) {
  1832. ctxt.textBaseline = "middle";
  1833. ctxt.textAlign = "center";
  1834. for (let i = 0; i < this.texts.length; ++i) {
  1835. if (this.texts[i].life) {
  1836. this.texts[i].update(delta);
  1837. this.texts[i].render(ctxt, xOff, yOff);
  1838. }
  1839. }
  1840. };
  1841. // SHOW TEXT:
  1842. this.showText = function(x, y, scale, speed, life, text, color) {
  1843. let tmpText;
  1844. for (let i = 0; i < this.texts.length; ++i) {
  1845. if (!this.texts[i].life) {
  1846. tmpText = this.texts[i];
  1847. break;
  1848. }
  1849. }
  1850. if (!tmpText) {
  1851. tmpText = new Animtext();
  1852. this.texts.push(tmpText);
  1853. }
  1854. tmpText.init(x, y, scale, speed, life, text, color);
  1855. };
  1856. }
  1857. }
  1858. class GameObject {
  1859. constructor(sid) {
  1860. this.sid = sid;
  1861. // INIT:
  1862. this.init = function(x, y, dir, scale, type, data, owner) {
  1863. data = data || {};
  1864. this.sentTo = {};
  1865. this.gridLocations = [];
  1866. this.active = true;
  1867. this.render = true;
  1868. this.doUpdate = data.doUpdate;
  1869. this.x = x;
  1870. this.y = y;
  1871. this.dir = dir;
  1872. this.lastDir = dir;
  1873. this.xWiggle = 0;
  1874. this.yWiggle = 0;
  1875. this.visScale = scale;
  1876. this.scale = scale;
  1877. this.type = type;
  1878. this.id = data.id;
  1879. this.owner = owner;
  1880. this.name = data.name;
  1881. this.isItem = (this.id != undefined);
  1882. this.group = data.group;
  1883. this.maxHealth = data.health;
  1884. this.health = this.maxHealth;
  1885. this.layer = 2;
  1886. if (this.group != undefined) {
  1887. this.layer = this.group.layer;
  1888. } else if (this.type == 0) {
  1889. this.layer = 3;
  1890. } else if (this.type == 2) {
  1891. this.layer = 0;
  1892. } else if (this.type == 4) {
  1893. this.layer = -1;
  1894. }
  1895. this.colDiv = data.colDiv || 1;
  1896. this.blocker = data.blocker;
  1897. this.ignoreCollision = data.ignoreCollision;
  1898. this.dontGather = data.dontGather;
  1899. this.hideFromEnemy = data.hideFromEnemy;
  1900. this.friction = data.friction;
  1901. this.projDmg = data.projDmg;
  1902. this.dmg = data.dmg;
  1903. this.pDmg = data.pDmg;
  1904. this.pps = data.pps;
  1905. this.zIndex = data.zIndex || 0;
  1906. this.turnSpeed = data.turnSpeed;
  1907. this.req = data.req;
  1908. this.trap = data.trap;
  1909. this.healCol = data.healCol;
  1910. this.teleport = data.teleport;
  1911. this.boostSpeed = data.boostSpeed;
  1912. this.projectile = data.projectile;
  1913. this.shootRange = data.shootRange;
  1914. this.shootRate = data.shootRate;
  1915. this.shootCount = this.shootRate;
  1916. this.spawnPoint = data.spawnPoint;
  1917. this.onNear = 0;
  1918. this.breakObj = false;
  1919. this.alpha = data.alpha || 1;
  1920. this.maxAlpha = data.alpha || 1;
  1921. this.damaged = 0;
  1922. };
  1923. // GET HIT:
  1924. this.changeHealth = function(amount, doer) {
  1925. this.health += amount;
  1926. return (this.health <= 0);
  1927. };
  1928. // GET SCALE:
  1929. this.getScale = function(sM, ig) {
  1930. sM = sM || 1;
  1931. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1932. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1933. };
  1934. // VISIBLE TO PLAYER:
  1935. this.visibleToPlayer = function(player) {
  1936. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1937. (this.owner.team && player.team == this.owner.team)));
  1938. };
  1939. // UPDATE:
  1940. this.update = function(delta) {
  1941. if (this.active) {
  1942. if (this.xWiggle) {
  1943. this.xWiggle *= Math.pow(0.99, delta);
  1944. }
  1945. if (this.yWiggle) {
  1946. this.yWiggle *= Math.pow(0.99, delta);
  1947. }
  1948. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  1949. if (d2 > 0.01) {
  1950. this.dir += d2 / 5;
  1951. } else {
  1952. this.dir = this.lastDir;
  1953. }
  1954. } else {
  1955. if (this.alive) {
  1956. this.alpha -= delta / (200 / this.maxAlpha);
  1957. this.visScale += delta / (this.scale / 2.5);
  1958. if (this.alpha <= 0) {
  1959. this.alpha = 0;
  1960. this.alive = false;
  1961. }
  1962. }
  1963. }
  1964. };
  1965. // CHECK TEAM:
  1966. this.isTeamObject = function(tmpObj) {
  1967. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  1968. };
  1969. }
  1970. }
  1971. class Items {
  1972. constructor() {
  1973. // ITEM GROUPS:
  1974. this.groups = [{
  1975. id: 0,
  1976. name: "food",
  1977. layer: 0
  1978. }, {
  1979. id: 1,
  1980. name: "walls",
  1981. place: true,
  1982. limit: 30,
  1983. layer: 0
  1984. }, {
  1985. id: 2,
  1986. name: "spikes",
  1987. place: true,
  1988. limit: 15,
  1989. layer: 0
  1990. }, {
  1991. id: 3,
  1992. name: "mill",
  1993. place: true,
  1994. limit: 7,
  1995. layer: 1
  1996. }, {
  1997. id: 4,
  1998. name: "mine",
  1999. place: true,
  2000. limit: 1,
  2001. layer: 0
  2002. }, {
  2003. id: 5,
  2004. name: "trap",
  2005. place: true,
  2006. limit: 6,
  2007. layer: -1
  2008. }, {
  2009. id: 6,
  2010. name: "booster",
  2011. place: true,
  2012. limit: 12,
  2013. layer: -1
  2014. }, {
  2015. id: 7,
  2016. name: "turret",
  2017. place: true,
  2018. limit: 2,
  2019. layer: 1
  2020. }, {
  2021. id: 8,
  2022. name: "watchtower",
  2023. place: true,
  2024. limit: 12,
  2025. layer: 1
  2026. }, {
  2027. id: 9,
  2028. name: "buff",
  2029. place: true,
  2030. limit: 4,
  2031. layer: -1
  2032. }, {
  2033. id: 10,
  2034. name: "spawn",
  2035. place: true,
  2036. limit: 1,
  2037. layer: -1
  2038. }, {
  2039. id: 11,
  2040. name: "sapling",
  2041. place: true,
  2042. limit: 2,
  2043. layer: 0
  2044. }, {
  2045. id: 12,
  2046. name: "blocker",
  2047. place: true,
  2048. limit: 3,
  2049. layer: -1
  2050. }, {
  2051. id: 13,
  2052. name: "teleporter",
  2053. place: true,
  2054. limit: 2,
  2055. layer: -1
  2056. }];
  2057. // PROJECTILES:
  2058. this.projectiles = [{
  2059. indx: 0,
  2060. layer: 0,
  2061. src: "arrow_1",
  2062. dmg: 25,
  2063. speed: 1.6,
  2064. scale: 103,
  2065. range: 1000
  2066. }, {
  2067. indx: 1,
  2068. layer: 1,
  2069. dmg: 25,
  2070. scale: 20
  2071. }, {
  2072. indx: 0,
  2073. layer: 0,
  2074. src: "arrow_1",
  2075. dmg: 35,
  2076. speed: 2.5,
  2077. scale: 103,
  2078. range: 1200
  2079. }, {
  2080. indx: 0,
  2081. layer: 0,
  2082. src: "arrow_1",
  2083. dmg: 30,
  2084. speed: 2,
  2085. scale: 103,
  2086. range: 1200
  2087. }, {
  2088. indx: 1,
  2089. layer: 1,
  2090. dmg: 16,
  2091. scale: 20
  2092. }, {
  2093. indx: 0,
  2094. layer: 0,
  2095. src: "bullet_1",
  2096. dmg: 50,
  2097. speed: 3.6,
  2098. scale: 160,
  2099. range: 1400
  2100. }];
  2101. // WEAPONS:
  2102. this.weapons = [{
  2103. id: 0,
  2104. type: 0,
  2105. name: "tool hammer",
  2106. desc: "tool for gathering all resources",
  2107. src: "hammer_1",
  2108. length: 140,
  2109. width: 140,
  2110. xOff: -3,
  2111. yOff: 18,
  2112. dmg: 25,
  2113. range: 65,
  2114. gather: 1,
  2115. speed: 300
  2116. }, {
  2117. id: 1,
  2118. type: 0,
  2119. age: 2,
  2120. name: "hand axe",
  2121. desc: "gathers resources at a higher rate",
  2122. src: "axe_1",
  2123. length: 140,
  2124. width: 140,
  2125. xOff: 3,
  2126. yOff: 24,
  2127. dmg: 30,
  2128. spdMult: 1,
  2129. range: 70,
  2130. gather: 2,
  2131. speed: 400
  2132. }, {
  2133. id: 2,
  2134. type: 0,
  2135. age: 8,
  2136. pre: 1,
  2137. name: "great axe",
  2138. desc: "deal more damage and gather more resources",
  2139. src: "great_axe_1",
  2140. length: 140,
  2141. width: 140,
  2142. xOff: -8,
  2143. yOff: 25,
  2144. dmg: 35,
  2145. spdMult: 1,
  2146. range: 75,
  2147. gather: 4,
  2148. speed: 400
  2149. }, {
  2150. id: 3,
  2151. type: 0,
  2152. age: 2,
  2153. name: "short sword",
  2154. desc: "increased attack power but slower move speed",
  2155. src: "sword_1",
  2156. iPad: 1.3,
  2157. length: 130,
  2158. width: 210,
  2159. xOff: -8,
  2160. yOff: 46,
  2161. dmg: 35,
  2162. spdMult: 0.85,
  2163. range: 110,
  2164. gather: 1,
  2165. speed: 300
  2166. }, {
  2167. id: 4,
  2168. type: 0,
  2169. age: 8,
  2170. pre: 3,
  2171. name: "katana",
  2172. desc: "greater range and damage",
  2173. src: "samurai_1",
  2174. iPad: 1.3,
  2175. length: 130,
  2176. width: 210,
  2177. xOff: -8,
  2178. yOff: 59,
  2179. dmg: 40,
  2180. spdMult: 0.8,
  2181. range: 118,
  2182. gather: 1,
  2183. speed: 300
  2184. }, {
  2185. id: 5,
  2186. type: 0,
  2187. age: 2,
  2188. name: "polearm",
  2189. desc: "long range melee weapon",
  2190. src: "spear_1",
  2191. iPad: 1.3,
  2192. length: 130,
  2193. width: 210,
  2194. xOff: -8,
  2195. yOff: 53,
  2196. dmg: 45,
  2197. knock: 0.2,
  2198. spdMult: 0.82,
  2199. range: 142,
  2200. gather: 1,
  2201. speed: 700
  2202. }, {
  2203. id: 6,
  2204. type: 0,
  2205. age: 2,
  2206. name: "bat",
  2207. desc: "fast long range melee weapon",
  2208. src: "bat_1",
  2209. iPad: 1.3,
  2210. length: 110,
  2211. width: 180,
  2212. xOff: -8,
  2213. yOff: 53,
  2214. dmg: 20,
  2215. knock: 0.7,
  2216. range: 110,
  2217. gather: 1,
  2218. speed: 300
  2219. }, {
  2220. id: 7,
  2221. type: 0,
  2222. age: 2,
  2223. name: "daggers",
  2224. desc: "really fast short range weapon",
  2225. src: "dagger_1",
  2226. iPad: 0.8,
  2227. length: 110,
  2228. width: 110,
  2229. xOff: 18,
  2230. yOff: 0,
  2231. dmg: 20,
  2232. knock: 0.1,
  2233. range: 65,
  2234. gather: 1,
  2235. hitSlow: 0.1,
  2236. spdMult: 1.13,
  2237. speed: 100
  2238. }, {
  2239. id: 8,
  2240. type: 0,
  2241. age: 2,
  2242. name: "stick",
  2243. desc: "great for gathering but very weak",
  2244. src: "stick_1",
  2245. length: 140,
  2246. width: 140,
  2247. xOff: 3,
  2248. yOff: 24,
  2249. dmg: 1,
  2250. spdMult: 1,
  2251. range: 70,
  2252. gather: 7,
  2253. speed: 400
  2254. }, {
  2255. id: 9,
  2256. type: 1,
  2257. age: 6,
  2258. name: "hunting bow",
  2259. desc: "bow used for ranged combat and hunting",
  2260. src: "bow_1",
  2261. req: ["wood", 4],
  2262. length: 120,
  2263. width: 120,
  2264. xOff: -6,
  2265. yOff: 0,
  2266. Pdmg: 25,
  2267. projectile: 0,
  2268. spdMult: 0.75,
  2269. speed: 600
  2270. }, {
  2271. id: 10,
  2272. type: 1,
  2273. age: 6,
  2274. name: "great hammer",
  2275. desc: "hammer used for destroying structures",
  2276. src: "great_hammer_1",
  2277. length: 140,
  2278. width: 140,
  2279. xOff: -9,
  2280. yOff: 25,
  2281. dmg: 10,
  2282. Pdmg: 10,
  2283. spdMult: 0.88,
  2284. range: 75,
  2285. sDmg: 7.5,
  2286. gather: 1,
  2287. speed: 400
  2288. }, {
  2289. id: 11,
  2290. type: 1,
  2291. age: 6,
  2292. name: "wooden shield",
  2293. desc: "blocks projectiles and reduces melee damage",
  2294. src: "shield_1",
  2295. length: 120,
  2296. width: 120,
  2297. shield: 0.2,
  2298. xOff: 6,
  2299. yOff: 0,
  2300. Pdmg: 0,
  2301. spdMult: 0.7
  2302. }, {
  2303. id: 12,
  2304. type: 1,
  2305. age: 8,
  2306. pre: 9,
  2307. name: "crossbow",
  2308. desc: "deals more damage and has greater range",
  2309. src: "crossbow_1",
  2310. req: ["wood", 5],
  2311. aboveHand: true,
  2312. armS: 0.75,
  2313. length: 120,
  2314. width: 120,
  2315. xOff: -4,
  2316. yOff: 0,
  2317. Pdmg: 35,
  2318. projectile: 2,
  2319. spdMult: 0.7,
  2320. speed: 700
  2321. }, {
  2322. id: 13,
  2323. type: 1,
  2324. age: 9,
  2325. pre: 12,
  2326. name: "repeater crossbow",
  2327. desc: "high firerate crossbow with reduced damage",
  2328. src: "crossbow_2",
  2329. req: ["wood", 10],
  2330. aboveHand: true,
  2331. armS: 0.75,
  2332. length: 120,
  2333. width: 120,
  2334. xOff: -4,
  2335. yOff: 0,
  2336. Pdmg: 30,
  2337. projectile: 3,
  2338. spdMult: 0.7,
  2339. speed: 230
  2340. }, {
  2341. id: 14,
  2342. type: 1,
  2343. age: 6,
  2344. name: "mc grabby",
  2345. desc: "steals resources from enemies",
  2346. src: "grab_1",
  2347. length: 130,
  2348. width: 210,
  2349. xOff: -8,
  2350. yOff: 53,
  2351. dmg: 0,
  2352. Pdmg: 0,
  2353. steal: 250,
  2354. knock: 0.2,
  2355. spdMult: 1.05,
  2356. range: 125,
  2357. gather: 0,
  2358. speed: 700
  2359. }, {
  2360. id: 15,
  2361. type: 1,
  2362. age: 9,
  2363. pre: 12,
  2364. name: "musket",
  2365. desc: "slow firerate but high damage and range",
  2366. src: "musket_1",
  2367. req: ["stone", 10],
  2368. aboveHand: true,
  2369. rec: 0.35,
  2370. armS: 0.6,
  2371. hndS: 0.3,
  2372. hndD: 1.6,
  2373. length: 205,
  2374. width: 205,
  2375. xOff: 25,
  2376. yOff: 0,
  2377. Pdmg: 50,
  2378. projectile: 5,
  2379. hideProjectile: true,
  2380. spdMult: 0.6,
  2381. speed: 1500
  2382. }];
  2383. // ITEMS:
  2384. this.list = [{
  2385. group: this.groups[0],
  2386. name: "apple",
  2387. desc: "restores 20 health when consumed",
  2388. req: ["food", 10],
  2389. consume: function(doer) {
  2390. return doer.changeHealth(20, doer);
  2391. },
  2392. scale: 22,
  2393. holdOffset: 15,
  2394. healing: 20,
  2395. itemID: 0,
  2396. itemAID: 16,
  2397. }, {
  2398. age: 3,
  2399. group: this.groups[0],
  2400. name: "cookie",
  2401. desc: "restores 40 health when consumed",
  2402. req: ["food", 15],
  2403. consume: function(doer) {
  2404. return doer.changeHealth(40, doer);
  2405. },
  2406. scale: 27,
  2407. holdOffset: 15,
  2408. healing: 40,
  2409. itemID: 1,
  2410. itemAID: 17,
  2411. }, {
  2412. age: 7,
  2413. group: this.groups[0],
  2414. name: "cheese",
  2415. desc: "restores 30 health and another 50 over 5 seconds",
  2416. req: ["food", 25],
  2417. consume: function(doer) {
  2418. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2419. doer.dmgOverTime.dmg = -10;
  2420. doer.dmgOverTime.doer = doer;
  2421. doer.dmgOverTime.time = 5;
  2422. return true;
  2423. }
  2424. return false;
  2425. },
  2426. scale: 27,
  2427. holdOffset: 15,
  2428. healing: 30,
  2429. itemID: 2,
  2430. itemAID: 18,
  2431. }, {
  2432. group: this.groups[1],
  2433. name: "wood wall",
  2434. desc: "provides protection for your village",
  2435. req: ["wood", 10],
  2436. projDmg: true,
  2437. health: 380,
  2438. scale: 50,
  2439. holdOffset: 20,
  2440. placeOffset: -5,
  2441. itemID: 3,
  2442. itemAID: 19,
  2443. }, {
  2444. age: 3,
  2445. group: this.groups[1],
  2446. name: "stone wall",
  2447. desc: "provides improved protection for your village",
  2448. req: ["stone", 25],
  2449. health: 900,
  2450. scale: 50,
  2451. holdOffset: 20,
  2452. placeOffset: -5,
  2453. itemID: 4,
  2454. itemAID: 20,
  2455. }, {
  2456. age: 7,
  2457. group: this.groups[1],
  2458. name: "castle wall",
  2459. desc: "provides powerful protection for your village",
  2460. req: ["stone", 35],
  2461. health: 1500,
  2462. scale: 52,
  2463. holdOffset: 20,
  2464. placeOffset: -5,
  2465. itemID: 5,
  2466. itemAID: 21,
  2467. }, {
  2468. group: this.groups[2],
  2469. name: "spikes",
  2470. desc: "damages enemies when they touch them",
  2471. req: ["wood", 20, "stone", 5],
  2472. health: 400,
  2473. dmg: 20,
  2474. scale: 49,
  2475. spritePadding: -23,
  2476. holdOffset: 8,
  2477. placeOffset: -5,
  2478. itemID: 6,
  2479. itemAID: 22,
  2480. shadow: {
  2481. offsetX: 5, // Adjust the shadow's X offset as needed
  2482. offsetY: 5, // Adjust the shadow's Y offset as needed
  2483. blur: 20, // Adjust the shadow's blur as needed
  2484. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2485. }
  2486. }, {
  2487. age: 5,
  2488. group: this.groups[2],
  2489. name: "greater spikes",
  2490. desc: "damages enemies when they touch them",
  2491. req: ["wood", 30, "stone", 10],
  2492. health: 500,
  2493. dmg: 35,
  2494. scale: 52,
  2495. spritePadding: -23,
  2496. holdOffset: 8,
  2497. placeOffset: -5,
  2498. itemID: 7,
  2499. itemAID: 23,
  2500. }, {
  2501. age: 9,
  2502. group: this.groups[2],
  2503. name: "poison spikes",
  2504. desc: "poisons enemies when they touch them",
  2505. req: ["wood", 35, "stone", 15],
  2506. health: 600,
  2507. dmg: 30,
  2508. pDmg: 5,
  2509. scale: 52,
  2510. spritePadding: -23,
  2511. holdOffset: 8,
  2512. placeOffset: -5,
  2513. itemID: 8,
  2514. itemAID: 24,
  2515. }, {
  2516. age: 9,
  2517. group: this.groups[2],
  2518. name: "spinning spikes",
  2519. desc: "damages enemies when they touch them",
  2520. req: ["wood", 30, "stone", 20],
  2521. health: 500,
  2522. dmg: 45,
  2523. turnSpeed: 0.003,
  2524. scale: 52,
  2525. spritePadding: -23,
  2526. holdOffset: 8,
  2527. placeOffset: -5,
  2528. itemID: 9,
  2529. itemAID: 25,
  2530. }, {
  2531. group: this.groups[3],
  2532. name: "windmill",
  2533. desc: "generates gold over time",
  2534. req: ["wood", 50, "stone", 10],
  2535. health: 400,
  2536. pps: 1,
  2537. turnSpeed: 0.0016,
  2538. spritePadding: 25,
  2539. iconLineMult: 12,
  2540. scale: 45,
  2541. holdOffset: 20,
  2542. placeOffset: 5,
  2543. itemID: 10,
  2544. itemAID: 26,
  2545. }, {
  2546. age: 5,
  2547. group: this.groups[3],
  2548. name: "faster windmill",
  2549. desc: "generates more gold over time",
  2550. req: ["wood", 60, "stone", 20],
  2551. health: 500,
  2552. pps: 1.5,
  2553. turnSpeed: 0.0025,
  2554. spritePadding: 25,
  2555. iconLineMult: 12,
  2556. scale: 47,
  2557. holdOffset: 20,
  2558. placeOffset: 5,
  2559. itemID: 11,
  2560. itemAID: 27,
  2561. }, {
  2562. age: 8,
  2563. group: this.groups[3],
  2564. name: "power mill",
  2565. desc: "generates more gold over time",
  2566. req: ["wood", 100, "stone", 50],
  2567. health: 800,
  2568. pps: 2,
  2569. turnSpeed: 0.005,
  2570. spritePadding: 25,
  2571. iconLineMult: 12,
  2572. scale: 47,
  2573. holdOffset: 20,
  2574. placeOffset: 5,
  2575. itemID: 12,
  2576. itemAID: 28,
  2577. }, {
  2578. age: 5,
  2579. group: this.groups[4],
  2580. type: 2,
  2581. name: "mine",
  2582. desc: "allows you to mine stone",
  2583. req: ["wood", 20, "stone", 100],
  2584. iconLineMult: 12,
  2585. scale: 65,
  2586. holdOffset: 20,
  2587. placeOffset: 0,
  2588. itemID: 13,
  2589. itemAID: 29,
  2590. }, {
  2591. age: 5,
  2592. group: this.groups[11],
  2593. type: 0,
  2594. name: "sapling",
  2595. desc: "allows you to farm wood",
  2596. req: ["wood", 150],
  2597. iconLineMult: 12,
  2598. colDiv: 0.5,
  2599. scale: 110,
  2600. holdOffset: 50,
  2601. placeOffset: -15,
  2602. itemID: 14,
  2603. itemAID: 30,
  2604. }, {
  2605. age: 4,
  2606. group: this.groups[5],
  2607. name: "pit trap",
  2608. desc: "pit that traps enemies if they walk over it",
  2609. req: ["wood", 30, "stone", 30],
  2610. trap: true,
  2611. ignoreCollision: true,
  2612. hideFromEnemy: true,
  2613. health: 500,
  2614. colDiv: 0.2,
  2615. scale: 50,
  2616. holdOffset: 20,
  2617. placeOffset: -5,
  2618. alpha: 0.6,
  2619. itemID: 15,
  2620. itemAID: 31,
  2621. }, {
  2622. age: 4,
  2623. group: this.groups[6],
  2624. name: "boost pad",
  2625. desc: "provides boost when stepped on",
  2626. req: ["stone", 20, "wood", 5],
  2627. ignoreCollision: true,
  2628. boostSpeed: 1.5,
  2629. health: 150,
  2630. colDiv: 0.7,
  2631. scale: 45,
  2632. holdOffset: 20,
  2633. placeOffset: -5,
  2634. itemID: 16,
  2635. itemAID: 32,
  2636. }, {
  2637. age: 7,
  2638. group: this.groups[7],
  2639. doUpdate: true,
  2640. name: "turret",
  2641. desc: "defensive structure that shoots at enemies",
  2642. req: ["wood", 200, "stone", 150],
  2643. health: 800,
  2644. projectile: 1,
  2645. shootRange: 700,
  2646. shootRate: 2200,
  2647. scale: 43,
  2648. holdOffset: 20,
  2649. placeOffset: -5,
  2650. itemID: 17,
  2651. itemAID: 33,
  2652. }, {
  2653. age: 7,
  2654. group: this.groups[8],
  2655. name: "platform",
  2656. desc: "platform to shoot over walls and cross over water",
  2657. req: ["wood", 20],
  2658. ignoreCollision: true,
  2659. zIndex: 1,
  2660. health: 300,
  2661. scale: 43,
  2662. holdOffset: 20,
  2663. placeOffset: -5,
  2664. itemID: 18,
  2665. itemAID: 34,
  2666. }, {
  2667. age: 7,
  2668. group: this.groups[9],
  2669. name: "healing pad",
  2670. desc: "standing on it will slowly heal you",
  2671. req: ["wood", 30, "food", 10],
  2672. ignoreCollision: true,
  2673. healCol: 15,
  2674. health: 400,
  2675. colDiv: 0.7,
  2676. scale: 45,
  2677. holdOffset: 20,
  2678. placeOffset: -5,
  2679. itemID: 19,
  2680. itemAID: 35,
  2681. }, {
  2682. age: 9,
  2683. group: this.groups[10],
  2684. name: "spawn pad",
  2685. desc: "you will spawn here when you die but it will dissapear",
  2686. req: ["wood", 100, "stone", 100],
  2687. health: 400,
  2688. ignoreCollision: true,
  2689. spawnPoint: true,
  2690. scale: 45,
  2691. holdOffset: 20,
  2692. placeOffset: -5,
  2693. itemID: 20,
  2694. itemAID: 36,
  2695. }, {
  2696. age: 7,
  2697. group: this.groups[12],
  2698. name: "blocker",
  2699. desc: "blocks building in radius",
  2700. req: ["wood", 30, "stone", 25],
  2701. ignoreCollision: true,
  2702. blocker: 300,
  2703. health: 400,
  2704. colDiv: 0.7,
  2705. scale: 45,
  2706. holdOffset: 20,
  2707. placeOffset: -5,
  2708. itemID: 21,
  2709. itemAID: 37,
  2710. }, {
  2711. age: 7,
  2712. group: this.groups[13],
  2713. name: "teleporter",
  2714. desc: "teleports you to a random point on the map",
  2715. req: ["wood", 60, "stone", 60],
  2716. ignoreCollision: true,
  2717. teleport: true,
  2718. health: 200,
  2719. colDiv: 0.7,
  2720. scale: 45,
  2721. holdOffset: 20,
  2722. placeOffset: -5,
  2723. itemID: 22,
  2724. itemAID: 38
  2725. }];
  2726. // CHECK ITEM ID:
  2727. this.checkItem = {
  2728. index: function(id, myItems) {
  2729. 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 :
  2730. 5 :
  2731. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2732. 6 :
  2733. undefined;
  2734. }
  2735. }
  2736. // ASSIGN IDS:
  2737. for (let i = 0; i < this.list.length; ++i) {
  2738. this.list[i].id = i;
  2739. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2740. }
  2741. // TROLOLOLOL:
  2742. if (typeof window !== "undefined") {
  2743. function shuffle(a) {
  2744. for (let i = a.length - 1; i > 0; i--) {
  2745. const j = Math.floor(Math.random() * (i + 1));
  2746. [a[i], a[j]] = [a[j], a[i]];
  2747. }
  2748. return a;
  2749. }
  2750. //shuffle(this.list);
  2751. }
  2752. }
  2753. }
  2754. class Objectmanager {
  2755. constructor(GameObject, liztobj, UTILS, config, players, server) {
  2756. let mathFloor = Math.floor,
  2757. mathABS = Math.abs,
  2758. mathCOS = Math.cos,
  2759. mathSIN = Math.sin,
  2760. mathPOW = Math.pow,
  2761. mathSQRT = Math.sqrt;
  2762. this.ignoreAdd = false;
  2763. this.hitObj = [];
  2764. // DISABLE OBJ:
  2765. this.disableObj = function(obj) {
  2766. obj.active = false;
  2767. };
  2768. // ADD NEW:
  2769. let tmpObj;
  2770. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2771. tmpObj = findObjectBySid(sid);
  2772. if (!tmpObj) {
  2773. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2774. if (!tmpObj) {
  2775. tmpObj = new GameObject(sid);
  2776. gameObjects.push(tmpObj);
  2777. }
  2778. }
  2779. if (setSID) {
  2780. tmpObj.sid = sid;
  2781. }
  2782. tmpObj.init(x, y, dir, s, type, data, owner);
  2783. };
  2784. // DISABLE BY SID:
  2785. this.disableBySid = function(sid) {
  2786. let find = findObjectBySid(sid);
  2787. if (find) {
  2788. this.disableObj(find);
  2789. }
  2790. };
  2791. // REMOVE ALL FROM PLAYER:
  2792. this.removeAllItems = function(sid, server) {
  2793. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2794. };
  2795. // CHECK IF PLACABLE:
  2796. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2797. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  2798. if (cantPlace) return false;
  2799. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2800. return true;
  2801. };
  2802. }
  2803. }
  2804. class Projectile {
  2805. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2806. // INIT:
  2807. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2808. this.active = true;
  2809. this.tickActive = true;
  2810. this.indx = indx;
  2811. this.x = x;
  2812. this.y = y;
  2813. this.x2 = x;
  2814. this.y2 = y;
  2815. this.dir = dir;
  2816. this.skipMov = true;
  2817. this.speed = spd;
  2818. this.dmg = dmg;
  2819. this.scale = scl;
  2820. this.range = rng;
  2821. this.r2 = rng;
  2822. this.owner = owner;
  2823. };
  2824. // UPDATE:
  2825. this.update = function(delta) {
  2826. if (this.active) {
  2827. let tmpSpeed = this.speed * delta;
  2828. if (!this.skipMov) {
  2829. this.x += tmpSpeed * Math.cos(this.dir);
  2830. this.y += tmpSpeed * Math.sin(this.dir);
  2831. this.range -= tmpSpeed;
  2832. if (this.range <= 0) {
  2833. this.x += this.range * Math.cos(this.dir);
  2834. this.y += this.range * Math.sin(this.dir);
  2835. tmpSpeed = 1;
  2836. this.range = 0;
  2837. this.active = false;
  2838. }
  2839. } else {
  2840. this.skipMov = false;
  2841. }
  2842. }
  2843. };
  2844. this.tickUpdate = function(delta) {
  2845. if (this.tickActive) {
  2846. let tmpSpeed = this.speed * delta;
  2847. if (!this.skipMov) {
  2848. this.x2 += tmpSpeed * Math.cos(this.dir);
  2849. this.y2 += tmpSpeed * Math.sin(this.dir);
  2850. this.r2 -= tmpSpeed;
  2851. if (this.r2 <= 0) {
  2852. this.x2 += this.r2 * Math.cos(this.dir);
  2853. this.y2 += this.r2 * Math.sin(this.dir);
  2854. tmpSpeed = 1;
  2855. this.r2 = 0;
  2856. this.tickActive = false;
  2857. }
  2858. } else {
  2859. this.skipMov = false;
  2860. }
  2861. }
  2862. };
  2863. }
  2864. };
  2865. class Store {
  2866. constructor() {
  2867. // STORE HATS:
  2868. this.hats = [{
  2869. id: 45,
  2870. name: "Shame!",
  2871. dontSell: true,
  2872. price: 0,
  2873. scale: 120,
  2874. desc: "hacks are for winners"
  2875. }, {
  2876. id: 51,
  2877. name: "Moo Cap",
  2878. price: 0,
  2879. scale: 120,
  2880. desc: "coolest mooer around"
  2881. }, {
  2882. id: 50,
  2883. name: "Apple Cap",
  2884. price: 0,
  2885. scale: 120,
  2886. desc: "apple farms remembers"
  2887. }, {
  2888. id: 28,
  2889. name: "Moo Head",
  2890. price: 0,
  2891. scale: 120,
  2892. desc: "no effect"
  2893. }, {
  2894. id: 29,
  2895. name: "Pig Head",
  2896. price: 0,
  2897. scale: 120,
  2898. desc: "no effect"
  2899. }, {
  2900. id: 30,
  2901. name: "Fluff Head",
  2902. price: 0,
  2903. scale: 120,
  2904. desc: "no effect"
  2905. }, {
  2906. id: 36,
  2907. name: "Pandou Head",
  2908. price: 0,
  2909. scale: 120,
  2910. desc: "no effect"
  2911. }, {
  2912. id: 37,
  2913. name: "Bear Head",
  2914. price: 0,
  2915. scale: 120,
  2916. desc: "no effect"
  2917. }, {
  2918. id: 38,
  2919. name: "Monkey Head",
  2920. price: 0,
  2921. scale: 120,
  2922. desc: "no effect"
  2923. }, {
  2924. id: 44,
  2925. name: "Polar Head",
  2926. price: 0,
  2927. scale: 120,
  2928. desc: "no effect"
  2929. }, {
  2930. id: 35,
  2931. name: "Fez Hat",
  2932. price: 0,
  2933. scale: 120,
  2934. desc: "no effect"
  2935. }, {
  2936. id: 42,
  2937. name: "Enigma Hat",
  2938. price: 0,
  2939. scale: 120,
  2940. desc: "join the enigma army"
  2941. }, {
  2942. id: 43,
  2943. name: "Blitz Hat",
  2944. price: 0,
  2945. scale: 120,
  2946. desc: "hey everybody i'm blitz"
  2947. }, {
  2948. id: 49,
  2949. name: "Bob XIII Hat",
  2950. price: 0,
  2951. scale: 120,
  2952. desc: "like and subscribe"
  2953. }, {
  2954. id: 57,
  2955. name: "Pumpkin",
  2956. price: 50,
  2957. scale: 120,
  2958. desc: "Spooooky"
  2959. }, {
  2960. id: 8,
  2961. name: "Bummle Hat",
  2962. price: 100,
  2963. scale: 120,
  2964. desc: "no effect"
  2965. }, {
  2966. id: 2,
  2967. name: "Straw Hat",
  2968. price: 500,
  2969. scale: 120,
  2970. desc: "no effect"
  2971. }, {
  2972. id: 15,
  2973. name: "Winter Cap",
  2974. price: 600,
  2975. scale: 120,
  2976. desc: "allows you to move at normal speed in snow",
  2977. coldM: 1
  2978. }, {
  2979. id: 5,
  2980. name: "Cowboy Hat",
  2981. price: 1000,
  2982. scale: 120,
  2983. desc: "no effect"
  2984. }, {
  2985. id: 4,
  2986. name: "Ranger Hat",
  2987. price: 2000,
  2988. scale: 120,
  2989. desc: "no effect"
  2990. }, {
  2991. id: 18,
  2992. name: "Explorer Hat",
  2993. price: 2000,
  2994. scale: 120,
  2995. desc: "no effect"
  2996. }, {
  2997. id: 31,
  2998. name: "Flipper Hat",
  2999. price: 2500,
  3000. scale: 120,
  3001. desc: "have more control while in water",
  3002. watrImm: true
  3003. }, {
  3004. id: 1,
  3005. name: "Marksman Cap",
  3006. price: 3000,
  3007. scale: 120,
  3008. desc: "increases arrow speed and range",
  3009. aMlt: 1.3
  3010. }, {
  3011. id: 10,
  3012. name: "Bush Gear",
  3013. price: 3000,
  3014. scale: 160,
  3015. desc: "allows you to disguise yourself as a bush"
  3016. }, {
  3017. id: 48,
  3018. name: "Halo",
  3019. price: 3000,
  3020. scale: 120,
  3021. desc: "no effect"
  3022. }, {
  3023. id: 6,
  3024. name: "Soldier Helmet",
  3025. price: 4000,
  3026. scale: 120,
  3027. desc: "reduces damage taken but slows movement",
  3028. spdMult: 0.94,
  3029. dmgMult: 0.75
  3030. }, {
  3031. id: 23,
  3032. name: "Anti Venom Gear",
  3033. price: 4000,
  3034. scale: 120,
  3035. desc: "makes you immune to poison",
  3036. poisonRes: 1
  3037. }, {
  3038. id: 13,
  3039. name: "Medic Gear",
  3040. price: 5000,
  3041. scale: 110,
  3042. desc: "slowly regenerates health over time",
  3043. healthRegen: 3
  3044. }, {
  3045. id: 9,
  3046. name: "Miners Helmet",
  3047. price: 5000,
  3048. scale: 120,
  3049. desc: "earn 1 extra gold per resource",
  3050. extraGold: 1
  3051. }, {
  3052. id: 32,
  3053. name: "Musketeer Hat",
  3054. price: 5000,
  3055. scale: 120,
  3056. desc: "reduces cost of projectiles",
  3057. projCost: 0.5
  3058. }, {
  3059. id: 7,
  3060. name: "Bull Helmet",
  3061. price: 6000,
  3062. scale: 120,
  3063. desc: "increases damage done but drains health",
  3064. healthRegen: -5,
  3065. dmgMultO: 1.5,
  3066. spdMult: 0.96
  3067. }, {
  3068. id: 22,
  3069. name: "Emp Helmet",
  3070. price: 6000,
  3071. scale: 120,
  3072. desc: "turrets won't attack but you move slower",
  3073. antiTurret: 1,
  3074. spdMult: 0.7
  3075. }, {
  3076. id: 12,
  3077. name: "Booster Hat",
  3078. price: 6000,
  3079. scale: 120,
  3080. desc: "increases your movement speed",
  3081. spdMult: 1.16
  3082. }, {
  3083. id: 26,
  3084. name: "Barbarian Armor",
  3085. price: 8000,
  3086. scale: 120,
  3087. desc: "knocks back enemies that attack you",
  3088. dmgK: 0.6
  3089. }, {
  3090. id: 21,
  3091. name: "Plague Mask",
  3092. price: 10000,
  3093. scale: 120,
  3094. desc: "melee attacks deal poison damage",
  3095. poisonDmg: 5,
  3096. poisonTime: 6
  3097. }, {
  3098. id: 46,
  3099. name: "Bull Mask",
  3100. price: 10000,
  3101. scale: 120,
  3102. desc: "bulls won't target you unless you attack them",
  3103. bullRepel: 1
  3104. }, {
  3105. id: 14,
  3106. name: "Windmill Hat",
  3107. topSprite: true,
  3108. price: 10000,
  3109. scale: 120,
  3110. desc: "generates points while worn",
  3111. pps: 1.5
  3112. }, {
  3113. id: 11,
  3114. name: "Spike Gear",
  3115. topSprite: true,
  3116. price: 10000,
  3117. scale: 120,
  3118. desc: "deal damage to players that damage you",
  3119. dmg: 0.45
  3120. }, {
  3121. id: 53,
  3122. name: "Turret Gear",
  3123. topSprite: true,
  3124. price: 10000,
  3125. scale: 120,
  3126. desc: "you become a walking turret",
  3127. turret: {
  3128. proj: 1,
  3129. range: 700,
  3130. rate: 2500
  3131. },
  3132. spdMult: 0.7
  3133. }, {
  3134. id: 20,
  3135. name: "Samurai Armor",
  3136. price: 12000,
  3137. scale: 120,
  3138. desc: "increased attack speed and fire rate",
  3139. atkSpd: 0.78
  3140. }, {
  3141. id: 58,
  3142. name: "Dark Knight",
  3143. price: 12000,
  3144. scale: 120,
  3145. desc: "restores health when you deal damage",
  3146. healD: 0.4
  3147. }, {
  3148. id: 27,
  3149. name: "Scavenger Gear",
  3150. price: 15000,
  3151. scale: 120,
  3152. desc: "earn double points for each kill",
  3153. kScrM: 2
  3154. }, {
  3155. id: 40,
  3156. name: "#### Gear",
  3157. price: 15000,
  3158. scale: 120,
  3159. desc: "increased damage to buildings but slower movement",
  3160. spdMult: 0.3,
  3161. bDmg: 3.3
  3162. }, {
  3163. id: 52,
  3164. name: "Thief Gear",
  3165. price: 15000,
  3166. scale: 120,
  3167. desc: "steal half of a players gold when you kill them",
  3168. goldSteal: 0.5
  3169. }, {
  3170. id: 55,
  3171. name: "Bloodthirster",
  3172. price: 20000,
  3173. scale: 120,
  3174. desc: "Restore Health when dealing damage. And increased damage",
  3175. healD: 0.25,
  3176. dmgMultO: 1.2,
  3177. }, {
  3178. id: 56,
  3179. name: "Assassin Gear",
  3180. price: 20000,
  3181. scale: 120,
  3182. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3183. noEat: true,
  3184. spdMult: 1.1,
  3185. invisTimer: 1000
  3186. }];
  3187. // STORE ACCESSORIES:
  3188. this.accessories = [{
  3189. id: 12,
  3190. name: "Snowball",
  3191. price: 1000,
  3192. scale: 105,
  3193. xOff: 18,
  3194. desc: "no effect"
  3195. }, {
  3196. id: 9,
  3197. name: "Tree Cape",
  3198. price: 1000,
  3199. scale: 90,
  3200. desc: "no effect"
  3201. }, {
  3202. id: 10,
  3203. name: "Stone Cape",
  3204. price: 1000,
  3205. scale: 90,
  3206. desc: "no effect"
  3207. }, {
  3208. id: 3,
  3209. name: "Cookie Cape",
  3210. price: 1500,
  3211. scale: 90,
  3212. desc: "no effect"
  3213. }, {
  3214. id: 8,
  3215. name: "Cow Cape",
  3216. price: 2000,
  3217. scale: 90,
  3218. desc: "no effect"
  3219. }, {
  3220. id: 11,
  3221. name: "Monkey Tail",
  3222. price: 2000,
  3223. scale: 97,
  3224. xOff: 25,
  3225. desc: "Super speed but reduced damage",
  3226. spdMult: 1.35,
  3227. dmgMultO: 0.2
  3228. }, {
  3229. id: 17,
  3230. name: "Apple Basket",
  3231. price: 3000,
  3232. scale: 80,
  3233. xOff: 12,
  3234. desc: "slowly regenerates health over time",
  3235. healthRegen: 1
  3236. }, {
  3237. id: 6,
  3238. name: "Winter Cape",
  3239. price: 3000,
  3240. scale: 90,
  3241. desc: "no effect"
  3242. }, {
  3243. id: 4,
  3244. name: "Skull Cape",
  3245. price: 4000,
  3246. scale: 90,
  3247. desc: "no effect"
  3248. }, {
  3249. id: 5,
  3250. name: "Dash Cape",
  3251. price: 5000,
  3252. scale: 90,
  3253. desc: "no effect"
  3254. }, {
  3255. id: 2,
  3256. name: "Dragon Cape",
  3257. price: 6000,
  3258. scale: 90,
  3259. desc: "no effect"
  3260. }, {
  3261. id: 1,
  3262. name: "Super Cape",
  3263. price: 8000,
  3264. scale: 90,
  3265. desc: "no effect"
  3266. }, {
  3267. id: 7,
  3268. name: "Troll Cape",
  3269. price: 8000,
  3270. scale: 90,
  3271. desc: "no effect"
  3272. }, {
  3273. id: 14,
  3274. name: "Thorns",
  3275. price: 10000,
  3276. scale: 115,
  3277. xOff: 20,
  3278. desc: "no effect"
  3279. }, {
  3280. id: 15,
  3281. name: "Blockades",
  3282. price: 10000,
  3283. scale: 95,
  3284. xOff: 15,
  3285. desc: "no effect"
  3286. }, {
  3287. id: 20,
  3288. name: "Devils Tail",
  3289. price: 10000,
  3290. scale: 95,
  3291. xOff: 20,
  3292. desc: "no effect"
  3293. }, {
  3294. id: 16,
  3295. name: "Sawblade",
  3296. price: 12000,
  3297. scale: 90,
  3298. spin: true,
  3299. xOff: 0,
  3300. desc: "deal damage to players that damage you",
  3301. dmg: 0.15
  3302. }, {
  3303. id: 13,
  3304. name: "Angel Wings",
  3305. price: 15000,
  3306. scale: 138,
  3307. xOff: 22,
  3308. desc: "slowly regenerates health over time",
  3309. healthRegen: 3
  3310. }, {
  3311. id: 19,
  3312. name: "Shadow Wings",
  3313. price: 15000,
  3314. scale: 138,
  3315. xOff: 22,
  3316. desc: "increased movement speed",
  3317. spdMult: 1.1
  3318. }, {
  3319. id: 18,
  3320. name: "Blood Wings",
  3321. price: 20000,
  3322. scale: 178,
  3323. xOff: 26,
  3324. desc: "restores health when you deal damage",
  3325. healD: 0.2
  3326. }, {
  3327. id: 21,
  3328. name: "Corrupt X Wings",
  3329. price: 20000,
  3330. scale: 178,
  3331. xOff: 26,
  3332. desc: "deal damage to players that damage you",
  3333. dmg: 0.25
  3334. }];
  3335. }
  3336. };
  3337. class ProjectileManager {
  3338. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3339. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3340. let tmpData = items.projectiles[indx];
  3341. let tmpProj;
  3342. for (let i = 0; i < projectiles.length; ++i) {
  3343. if (!projectiles[i].active) {
  3344. tmpProj = projectiles[i];
  3345. break;
  3346. }
  3347. }
  3348. if (!tmpProj) {
  3349. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3350. tmpProj.sid = projectiles.length;
  3351. projectiles.push(tmpProj);
  3352. }
  3353. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3354. tmpProj.ignoreObj = ignoreObj;
  3355. tmpProj.layer = layer || tmpData.layer;
  3356. tmpProj.inWindow = inWindow;
  3357. tmpProj.src = tmpData.src;
  3358. return tmpProj;
  3359. };
  3360. }
  3361. };
  3362. class AiManager {
  3363. // AI MANAGER:
  3364. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3365. // AI TYPES:
  3366. this.aiTypes = [{
  3367. id: 0,
  3368. src: "cow_1",
  3369. killScore: 150,
  3370. health: 500,
  3371. weightM: 0.8,
  3372. speed: 0.00095,
  3373. turnSpeed: 0.001,
  3374. scale: 72,
  3375. drop: ["food", 50]
  3376. }, {
  3377. id: 1,
  3378. src: "pig_1",
  3379. killScore: 200,
  3380. health: 800,
  3381. weightM: 0.6,
  3382. speed: 0.00085,
  3383. turnSpeed: 0.001,
  3384. scale: 72,
  3385. drop: ["food", 80]
  3386. }, {
  3387. id: 2,
  3388. name: "Bull",
  3389. src: "bull_2",
  3390. hostile: true,
  3391. dmg: 20,
  3392. killScore: 1000,
  3393. health: 1800,
  3394. weightM: 0.5,
  3395. speed: 0.00094,
  3396. turnSpeed: 0.00074,
  3397. scale: 78,
  3398. viewRange: 800,
  3399. chargePlayer: true,
  3400. drop: ["food", 100]
  3401. }, {
  3402. id: 3,
  3403. name: "Bully",
  3404. src: "bull_1",
  3405. hostile: true,
  3406. dmg: 20,
  3407. killScore: 2000,
  3408. health: 2800,
  3409. weightM: 0.45,
  3410. speed: 0.001,
  3411. turnSpeed: 0.0008,
  3412. scale: 90,
  3413. viewRange: 900,
  3414. chargePlayer: true,
  3415. drop: ["food", 400]
  3416. }, {
  3417. id: 4,
  3418. name: "Wolf",
  3419. src: "wolf_1",
  3420. hostile: true,
  3421. dmg: 8,
  3422. killScore: 500,
  3423. health: 300,
  3424. weightM: 0.45,
  3425. speed: 0.001,
  3426. turnSpeed: 0.002,
  3427. scale: 84,
  3428. viewRange: 800,
  3429. chargePlayer: true,
  3430. drop: ["food", 200]
  3431. }, {
  3432. id: 5,
  3433. name: "Quack",
  3434. src: "chicken_1",
  3435. dmg: 8,
  3436. killScore: 2000,
  3437. noTrap: true,
  3438. health: 300,
  3439. weightM: 0.2,
  3440. speed: 0.0018,
  3441. turnSpeed: 0.006,
  3442. scale: 70,
  3443. drop: ["food", 100]
  3444. }, {
  3445. id: 6,
  3446. name: "MOOSTAFA",
  3447. nameScale: 50,
  3448. src: "enemy",
  3449. hostile: true,
  3450. dontRun: true,
  3451. fixedSpawn: true,
  3452. spawnDelay: 60000,
  3453. noTrap: true,
  3454. colDmg: 100,
  3455. dmg: 40,
  3456. killScore: 8000,
  3457. health: 18000,
  3458. weightM: 0.4,
  3459. speed: 0.0007,
  3460. turnSpeed: 0.01,
  3461. scale: 80,
  3462. spriteMlt: 1.8,
  3463. leapForce: 0.9,
  3464. viewRange: 1000,
  3465. hitRange: 210,
  3466. hitDelay: 1000,
  3467. chargePlayer: true,
  3468. drop: ["food", 100]
  3469. }, {
  3470. id: 7,
  3471. name: "Treasure",
  3472. hostile: true,
  3473. nameScale: 35,
  3474. src: "crate_1",
  3475. fixedSpawn: true,
  3476. spawnDelay: 120000,
  3477. colDmg: 200,
  3478. killScore: 5000,
  3479. health: 20000,
  3480. weightM: 0.1,
  3481. speed: 0.0,
  3482. turnSpeed: 0.0,
  3483. scale: 70,
  3484. spriteMlt: 1.0
  3485. }, {
  3486. id: 8,
  3487. name: "MOOFIE",
  3488. src: "wolf_2",
  3489. hostile: true,
  3490. fixedSpawn: true,
  3491. dontRun: true,
  3492. hitScare: 4,
  3493. spawnDelay: 30000,
  3494. noTrap: true,
  3495. nameScale: 35,
  3496. dmg: 10,
  3497. colDmg: 100,
  3498. killScore: 3000,
  3499. health: 7000,
  3500. weightM: 0.45,
  3501. speed: 0.0015,
  3502. turnSpeed: 0.002,
  3503. scale: 90,
  3504. viewRange: 800,
  3505. chargePlayer: true,
  3506. drop: ["food", 1000]
  3507. }];
  3508. // SPAWN AI:
  3509. this.spawn = function(x, y, dir, index) {
  3510. let tmpObj = ais.find((tmp) => !tmp.active);
  3511. if (!tmpObj) {
  3512. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3513. ais.push(tmpObj);
  3514. }
  3515. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3516. return tmpObj;
  3517. };
  3518. }
  3519. };
  3520. class AI {
  3521. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3522. this.sid = sid;
  3523. this.isAI = true;
  3524. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3525. // INIT:
  3526. this.init = function(x, y, dir, index, data) {
  3527. this.x = x;
  3528. this.y = y;
  3529. this.startX = data.fixedSpawn ? x : null;
  3530. this.startY = data.fixedSpawn ? y : null;
  3531. this.xVel = 0;
  3532. this.yVel = 0;
  3533. this.zIndex = 0;
  3534. this.dir = dir;
  3535. this.dirPlus = 0;
  3536. this.showName = 'aaa';
  3537. this.index = index;
  3538. this.src = data.src;
  3539. if (data.name) this.name = data.name;
  3540. this.weightM = data.weightM;
  3541. this.speed = data.speed;
  3542. this.killScore = data.killScore;
  3543. this.turnSpeed = data.turnSpeed;
  3544. this.scale = data.scale;
  3545. this.maxHealth = data.health;
  3546. this.leapForce = data.leapForce;
  3547. this.health = this.maxHealth;
  3548. this.chargePlayer = data.chargePlayer;
  3549. this.viewRange = data.viewRange;
  3550. this.drop = data.drop;
  3551. this.dmg = data.dmg;
  3552. this.hostile = data.hostile;
  3553. this.dontRun = data.dontRun;
  3554. this.hitRange = data.hitRange;
  3555. this.hitDelay = data.hitDelay;
  3556. this.hitScare = data.hitScare;
  3557. this.spriteMlt = data.spriteMlt;
  3558. this.nameScale = data.nameScale;
  3559. this.colDmg = data.colDmg;
  3560. this.noTrap = data.noTrap;
  3561. this.spawnDelay = data.spawnDelay;
  3562. this.hitWait = 0;
  3563. this.waitCount = 1000;
  3564. this.moveCount = 0;
  3565. this.targetDir = 0;
  3566. this.active = true;
  3567. this.alive = true;
  3568. this.runFrom = null;
  3569. this.chargeTarget = null;
  3570. this.dmgOverTime = {};
  3571. };
  3572. let tmpRatio = 0;
  3573. let animIndex = 0;
  3574. this.animate = function(delta) {
  3575. if (this.animTime > 0) {
  3576. this.animTime -= delta;
  3577. if (this.animTime <= 0) {
  3578. this.animTime = 0;
  3579. this.dirPlus = 0;
  3580. tmpRatio = 0;
  3581. animIndex = 0;
  3582. } else {
  3583. if (animIndex == 0) {
  3584. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3585. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3586. if (tmpRatio >= 1) {
  3587. tmpRatio = 1;
  3588. animIndex = 1;
  3589. }
  3590. } else {
  3591. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3592. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3593. }
  3594. }
  3595. }
  3596. };
  3597. // ANIMATION:
  3598. this.startAnim = function() {
  3599. this.animTime = this.animSpeed = 600;
  3600. this.targetAngle = Math.PI * 0.8;
  3601. tmpRatio = 0;
  3602. animIndex = 0;
  3603. };
  3604. };
  3605. };
  3606. class addCh {
  3607. constructor(x, y, chat, tmpObj) {
  3608. this.x = x;
  3609. this.y = y;
  3610. this.alpha = 0;
  3611. this.active = true;
  3612. this.alive = false;
  3613. this.chat = chat;
  3614. this.owner = tmpObj;
  3615. };
  3616. };
  3617. class DeadPlayer {
  3618. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3619. this.x = x;
  3620. this.y = y;
  3621. this.lastDir = dir;
  3622. this.dir = dir + Math.PI;
  3623. this.buildIndex = buildIndex;
  3624. this.weaponIndex = weaponIndex;
  3625. this.weaponVariant = weaponVariant;
  3626. this.skinColor = skinColor;
  3627. this.scale = scale;
  3628. this.visScale = 0;
  3629. this.name = name;
  3630. this.alpha = 1;
  3631. this.active = true;
  3632. this.animate = function(delta) {
  3633. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3634. if (d2 > 0.01) {
  3635. this.dir += d2 / 20;
  3636. } else {
  3637. this.dir = this.lastDir;
  3638. }
  3639. if (this.visScale < this.scale) {
  3640. this.visScale += delta / (this.scale / 2);
  3641. if (this.visScale >= this.scale) {
  3642. this.visScale = this.scale;
  3643. }
  3644. }
  3645. this.alpha -= delta / 30000;
  3646. if (this.alpha <= 0) {
  3647. this.alpha = 0;
  3648. this.active = false;
  3649. }
  3650. }
  3651. }
  3652. };
  3653. class Player {
  3654. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3655. this.id = id;
  3656. this.sid = sid;
  3657. this.tmpScore = 0;
  3658. this.team = null;
  3659. this.latestSkin = 0;
  3660. this.oldSkinIndex = 0;
  3661. this.skinIndex = 0;
  3662. this.latestTail = 0;
  3663. this.oldTailIndex = 0;
  3664. this.tailIndex = 0;
  3665. this.hitTime = 0;
  3666. this.lastHit = 0;
  3667. this.showName = 'NOOO';
  3668. this.tails = {};
  3669. for (let i = 0; i < accessories.length; ++i) {
  3670. if (accessories[i].price <= 0)
  3671. this.tails[accessories[i].id] = 1;
  3672. }
  3673. this.skins = {};
  3674. for (let i = 0; i < hats.length; ++i) {
  3675. if (hats[i].price <= 0)
  3676. this.skins[hats[i].id] = 1;
  3677. }
  3678. this.points = 0;
  3679. this.dt = 0;
  3680. this.hidden = false;
  3681. this.itemCounts = {};
  3682. this.isPlayer = true;
  3683. this.pps = 0;
  3684. this.moveDir = undefined;
  3685. this.skinRot = 0;
  3686. this.lastPing = 0;
  3687. this.iconIndex = 0;
  3688. this.skinColor = 0;
  3689. this.dist2 = 0;
  3690. this.aim2 = 0;
  3691. this.maxSpeed = 1;
  3692. this.chat = {
  3693. message: null,
  3694. count: 0
  3695. };
  3696. this.backupNobull = true;
  3697. this.circle = false;
  3698. this.circleRad = 200;
  3699. this.circleRadSpd = 0.1;
  3700. this.cAngle = 0;
  3701. // SPAWN:
  3702. this.spawn = function(moofoll) {
  3703. this.attacked = false;
  3704. this.timeDamaged = 0;
  3705. this.timeHealed = 0;
  3706. this.pinge = 0;
  3707. this.millPlace = 'NOOO';
  3708. this.lastshamecount = 0;
  3709. this.death = false;
  3710. this.spinDir = 0;
  3711. this.sync = false;
  3712. this.antiBull = 0;
  3713. this.bullTimer = 0;
  3714. this.poisonTimer = 0;
  3715. this.active = true;
  3716. this.alive = true;
  3717. this.lockMove = false;
  3718. this.lockDir = false;
  3719. this.minimapCounter = 0;
  3720. this.chatCountdown = 0;
  3721. this.shameCount = 0;
  3722. this.shameTimer = 0;
  3723. this.sentTo = {};
  3724. this.gathering = 0;
  3725. this.gatherIndex = 0;
  3726. this.shooting = {};
  3727. this.shootIndex = 9;
  3728. this.autoGather = 0;
  3729. this.animTime = 0;
  3730. this.animSpeed = 0;
  3731. this.mouseState = 0;
  3732. this.buildIndex = -1;
  3733. this.weaponIndex = 0;
  3734. this.weaponCode = 0;
  3735. this.weaponVariant = 0;
  3736. this.primaryIndex = undefined;
  3737. this.secondaryIndex = undefined;
  3738. this.dmgOverTime = {};
  3739. this.noMovTimer = 0;
  3740. this.maxXP = 300;
  3741. this.XP = 0;
  3742. this.age = 1;
  3743. this.kills = 0;
  3744. this.upgrAge = 2;
  3745. this.upgradePoints = 0;
  3746. this.x = 0;
  3747. this.y = 0;
  3748. this.oldXY = {
  3749. x: 0,
  3750. y: 0
  3751. };
  3752. this.zIndex = 0;
  3753. this.xVel = 0;
  3754. this.yVel = 0;
  3755. this.slowMult = 1;
  3756. this.dir = 0;
  3757. this.dirPlus = 0;
  3758. this.targetDir = 0;
  3759. this.targetAngle = 0;
  3760. this.maxHealth = 100;
  3761. this.health = this.maxHealth;
  3762. this.oldHealth = this.maxHealth;
  3763. this.damaged = 0;
  3764. this.scale = config.playerScale;
  3765. this.speed = config.playerSpeed;
  3766. this.resetMoveDir();
  3767. this.resetResources(moofoll);
  3768. this.items = [0, 3, 6, 10];
  3769. this.weapons = [0];
  3770. this.shootCount = 0;
  3771. this.weaponXP = [];
  3772. this.reloads = {
  3773. 0: 0,
  3774. 1: 0,
  3775. 2: 0,
  3776. 3: 0,
  3777. 4: 0,
  3778. 5: 0,
  3779. 6: 0,
  3780. 7: 0,
  3781. 8: 0,
  3782. 9: 0,
  3783. 10: 0,
  3784. 11: 0,
  3785. 12: 0,
  3786. 13: 0,
  3787. 14: 0,
  3788. 15: 0,
  3789. 53: 0,
  3790. };
  3791. this.bowThreat = {
  3792. 9: 0,
  3793. 12: 0,
  3794. 13: 0,
  3795. 15: 0,
  3796. };
  3797. this.damageThreat = 0;
  3798. this.inTrap = false;
  3799. this.canEmpAnti = false;
  3800. this.empAnti = false;
  3801. this.soldierAnti = false;
  3802. this.poisonTick = 0;
  3803. this.bullTick = 0;
  3804. this.setPoisonTick = false;
  3805. this.setBullTick = false;
  3806. this.antiTimer = 2;
  3807. };
  3808. // RESET MOVE DIR:
  3809. this.resetMoveDir = function() {
  3810. this.moveDir = undefined;
  3811. };
  3812. // RESET RESOURCES:
  3813. this.resetResources = function(moofoll) {
  3814. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3815. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3816. }
  3817. };
  3818. // ADD ITEM:
  3819. this.getItemType = function(id) {
  3820. let findindx = this.items.findIndex((ids) => ids == id);
  3821. if (findindx != -1) {
  3822. return findindx;
  3823. } else {
  3824. return items.checkItem.index(id, this.items);
  3825. }
  3826. };
  3827. // SET DATA:
  3828. this.setData = function(data) {
  3829. this.id = data[0];
  3830. this.sid = data[1];
  3831. this.name = data[2];
  3832. this.x = data[3];
  3833. this.y = data[4];
  3834. this.dir = data[5];
  3835. this.health = data[6];
  3836. this.maxHealth = data[7];
  3837. this.scale = data[8];
  3838. this.skinColor = data[9];
  3839. };
  3840. // UPDATE POISON TICK:
  3841. this.updateTimer = function() {
  3842. this.bullTimer -= 1;
  3843. if (this.bullTimer <= 0) {
  3844. this.setBullTick = false;
  3845. this.bullTick = game.tick - 1;
  3846. this.bullTimer = config.serverUpdateRate;
  3847. }
  3848. this.poisonTimer -= 1;
  3849. if (this.poisonTimer <= 0) {
  3850. this.setPoisonTick = false;
  3851. this.poisonTick = game.tick - 1;
  3852. this.poisonTimer = config.serverUpdateRate;
  3853. }
  3854. };
  3855. this.update = function(delta) {
  3856. if (this.sid == playerSID) {
  3857. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  3858. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  3859. this.cAngle += this.circleRadSpd;
  3860. }
  3861. if (this.active) {
  3862. // MOVE:
  3863. let gear = {
  3864. skin: findID(hats, this.skinIndex),
  3865. tail: findID(accessories, this.tailIndex)
  3866. }
  3867. 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;
  3868. this.maxSpeed = spdMult;
  3869. }
  3870. };
  3871. let tmpRatio = 0;
  3872. let animIndex = 0;
  3873. this.animate = function(delta) {
  3874. if (this.animTime > 0) {
  3875. this.animTime -= delta;
  3876. if (this.animTime <= 0) {
  3877. this.animTime = 0;
  3878. this.dirPlus = 0;
  3879. tmpRatio = 0;
  3880. animIndex = 0;
  3881. } else {
  3882. if (animIndex == 0) {
  3883. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3884. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3885. if (tmpRatio >= 1) {
  3886. tmpRatio = 1;
  3887. animIndex = 1;
  3888. }
  3889. } else {
  3890. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3891. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3892. }
  3893. }
  3894. }
  3895. };
  3896. // GATHER ANIMATION:
  3897. this.startAnim = function(didHit, index) {
  3898. this.animTime = this.animSpeed = items.weapons[index].speed;
  3899. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3900. tmpRatio = 0;
  3901. animIndex = 0;
  3902. };
  3903. // CAN SEE:
  3904. this.canSee = function(other) {
  3905. if (!other) return false;
  3906. let dx = Math.abs(other.x - this.x) - other.scale;
  3907. let dy = Math.abs(other.y - this.y) - other.scale;
  3908. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3909. };
  3910. // SHAME SYSTEM:
  3911. this.judgeShame = function() {
  3912. this.lastshamecount = this.shameCount;
  3913. if (this.oldHealth < this.health) {
  3914. if (this.hitTime) {
  3915. let timeSinceHit = game.tick - this.hitTime;
  3916. this.lastHit = game.tick;
  3917. this.hitTime = 0;
  3918. if (timeSinceHit < 2) {
  3919. this.shameCount++;
  3920. } else {
  3921. this.shameCount = Math.max(0, this.shameCount - 2);
  3922. }
  3923. }
  3924. } else if (this.oldHealth > this.health) {
  3925. this.hitTime = game.tick;
  3926. }
  3927. };
  3928. this.addShameTimer = function() {
  3929. this.shameCount = 0;
  3930. this.shameTimer = 30;
  3931. let interval = setInterval(() => {
  3932. this.shameTimer--;
  3933. if (this.shameTimer <= 0) {
  3934. clearInterval(interval);
  3935. }
  3936. }, 1000);
  3937. };
  3938. // CHECK TEAM:
  3939. this.isTeam = function(tmpObj) {
  3940. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  3941. };
  3942. // FOR THE PLAYER:
  3943. this.findAllianceBySid = function(sid) {
  3944. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  3945. };
  3946. this.checkCanInsta = function(nobull) {
  3947. let totally = 0;
  3948. if (this.alive && inGame) {
  3949. let primary = {
  3950. weapon: this.weapons[0],
  3951. variant: this.primaryVariant,
  3952. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  3953. };
  3954. let secondary = {
  3955. weapon: this.weapons[1],
  3956. variant: this.secondaryVariant,
  3957. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  3958. };
  3959. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  3960. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  3961. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  3962. totally += primary.dmg * pV * bull;
  3963. }
  3964. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  3965. totally += secondary.dmg;
  3966. }
  3967. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  3968. totally += 25;
  3969. }
  3970. totally *= near.skinIndex == 6 ? 0.75 : 1;
  3971. return totally;
  3972. }
  3973. return 0;
  3974. };
  3975. // UPDATE WEAPON RELOAD:
  3976. this.manageReload = function() {
  3977. if (this.shooting[53]) {
  3978. this.shooting[53] = 0;
  3979. this.reloads[53] = (2500 - game.tickRate);
  3980. } else {
  3981. if (this.reloads[53] > 0) {
  3982. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  3983. }
  3984. }
  3985. //preplacer
  3986. if (this.reloads[this.weaponIndex] <= 1000/9) {
  3987. // place(2, getAttackDir());
  3988. let index = this.weaponIndex;
  3989. let nearObja = liztobj.filter((e) => (e.active || e.alive) && e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2) <= (items.weapons[player.weaponIndex].range + e.scale));
  3990. for(let i = 0; i < nearObja.length; i++) {
  3991. let aaa = nearObja[i];
  3992. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  3993. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  3994. if(aaa.health - (valaa) <= 0 && near.length) {
  3995. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI);
  3996. }
  3997. }
  3998. }
  3999. if (this.gathering || this.shooting[1]) {
  4000. if (this.gathering) {
  4001. this.gathering = 0;
  4002. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4003. this.attacked = true;
  4004. }
  4005. if (this.shooting[1]) {
  4006. this.shooting[1] = 0;
  4007. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4008. this.attacked = true;
  4009. }
  4010. } else {
  4011. this.attacked = false;
  4012. if (this.buildIndex < 0) {
  4013. if (this.reloads[this.weaponIndex] > 0) {
  4014. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4015. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4016. if (this == player) {
  4017. if (getEl("weaponGrind").checked) {
  4018. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4019. checkPlace(player.getItemType(22), i);
  4020. }
  4021. }
  4022. }
  4023. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4024. this.antiBull++;
  4025. game.tickBase(() => {
  4026. this.antiBull = 0;
  4027. }, 1);
  4028. }
  4029. }
  4030. }
  4031. }
  4032. };
  4033. // FOR ANTI INSTA:
  4034. this.addDamageThreat = function(tmpObj) {
  4035. let primary = {
  4036. weapon: this.primaryIndex,
  4037. variant: this.primaryVariant
  4038. };
  4039. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4040. let secondary = {
  4041. weapon: this.secondaryIndex,
  4042. variant: this.secondaryVariant
  4043. };
  4044. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4045. let bull = 1.5;
  4046. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4047. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4048. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4049. this.damageThreat += primary.dmg * pV * bull;
  4050. }
  4051. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4052. this.damageThreat += secondary.dmg * sV;
  4053. }
  4054. if (this.reloads[53] <= game.tickRate) {
  4055. this.damageThreat += 25;
  4056. }
  4057. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4058. if (!this.isTeam(tmpObj)) {
  4059. if (this.dist2 <= 300) {
  4060. tmpObj.damageThreat += this.damageThreat;
  4061. }
  4062. }
  4063. };
  4064. }
  4065. };
  4066. // SOME CODES:
  4067. function sendUpgrade(index) {
  4068. player.reloads[index] = 0;
  4069. packet("H", index);
  4070. }
  4071. function storeEquip(id, index) {
  4072. packet("c", 0, id, index);
  4073. }
  4074. function storeBuy(id, index) {
  4075. packet("c", 1, id, index);
  4076. }
  4077. function buyEquip(id, index) {
  4078. let nID = player.skins[6] ? 6 : 0;
  4079. if (player.alive && inGame) {
  4080. if (index == 0) {
  4081. if (player.skins[id]) {
  4082. if (player.latestSkin != id) {
  4083. packet("c", 0, id, 0);
  4084. }
  4085. } else {
  4086. if (configs.autoBuyEquip) {
  4087. let find = findID(hats, id);
  4088. if (find) {
  4089. if (player.points >= find.price) {
  4090. packet("c", 1, id, 0);
  4091. packet("c", 0, id, 0);
  4092. } else {
  4093. if (player.latestSkin != nID) {
  4094. packet("c", 0, nID, 0);
  4095. }
  4096. }
  4097. } else {
  4098. if (player.latestSkin != nID) {
  4099. packet("c", 0, nID, 0);
  4100. }
  4101. }
  4102. } else {
  4103. if (player.latestSkin != nID) {
  4104. packet("c", 0, nID, 0);
  4105. }
  4106. }
  4107. }
  4108. } else if (index == 1) {
  4109. if (useWasd && (id != 11 && id != 0)) {
  4110. if (player.latestTail != 0) {
  4111. packet("c", 0, 0, 1);
  4112. }
  4113. return;
  4114. }
  4115. if (player.tails[id]) {
  4116. if (player.latestTail != id) {
  4117. packet("c", 0, id, 1);
  4118. }
  4119. } else {
  4120. if (configs.autoBuyEquip) {
  4121. let find = findID(accessories, id);
  4122. if (find) {
  4123. if (player.points >= find.price) {
  4124. packet("c", 1, id, 1);
  4125. packet("c", 0, id, 1);
  4126. } else {
  4127. if (player.latestTail != 0) {
  4128. packet("c", 0, 0, 1);
  4129. }
  4130. }
  4131. } else {
  4132. if (player.latestTail != 0) {
  4133. packet("c", 0, 0, 1);
  4134. }
  4135. }
  4136. } else {
  4137. if (player.latestTail != 0) {
  4138. packet("c", 0, 0, 1);
  4139. }
  4140. }
  4141. }
  4142. }
  4143. }
  4144. }
  4145. function selectToBuild(index, wpn) {
  4146. packet("z", index, wpn);
  4147. }
  4148. function selectWeapon(index, isPlace) {
  4149. if (!isPlace) {
  4150. player.weaponCode = index;
  4151. }
  4152. packet("z", index, 1);
  4153. }
  4154. function sendAutoGather() {
  4155. packet("K", 1, 1);
  4156. }
  4157. function sendAtck(id, angle) {
  4158. packet("F", id, angle, 1);
  4159. }
  4160. // PLACER:
  4161. function place(id, rad, rmd) {
  4162. try {
  4163. if (id == undefined) return;
  4164. let item = items.list[player.items[id]];
  4165. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4166. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4167. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4168. 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))) {
  4169. selectToBuild(player.items[id]);
  4170. sendAtck(1, rad);
  4171. selectWeapon(player.weaponCode, 1);
  4172. if (rmd && getEl("placeVis").checked) {
  4173. placeVisible.push({
  4174. x: tmpX,
  4175. y: tmpY,
  4176. name: item.name,
  4177. scale: item.scale,
  4178. dir: rad
  4179. });
  4180. game.tickBase(() => {
  4181. placeVisible.shift();
  4182. }, 1)
  4183. }
  4184. }
  4185. } catch (e) {}
  4186. }
  4187. function checkPlace(id, rad) {
  4188. try {
  4189. if (id == undefined) return;
  4190. let item = items.list[player.items[id]];
  4191. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4192. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4193. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4194. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4195. place(id, rad, 1);
  4196. }
  4197. } catch (e) {}
  4198. }
  4199. // HEALING:
  4200. function soldierMult() {
  4201. return player.latestSkin == 6 ? 0.75 : 1;
  4202. }
  4203. function healthBased() {
  4204. if (player.health == 100)
  4205. return 0;
  4206. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4207. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4208. }
  4209. return 0;
  4210. }
  4211. function getAttacker(damaged) {
  4212. let attackers = enemy.filter(tmp => {
  4213. //let damages = new Damages(items);
  4214. //let dmg = damages.weapons[tmp.weaponIndex];
  4215. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4216. let rule = {
  4217. //one: tmp.dist2 <= 300,
  4218. //two: by.includes(damaged),
  4219. three: tmp.attacked
  4220. }
  4221. return /*rule.one && rule.two && */ rule.three;
  4222. });
  4223. return attackers;
  4224. }
  4225. function healer() {
  4226. for (let i = 0; i < healthBased(); i++) {
  4227. place(0, getAttackDir());
  4228. }
  4229. }
  4230. function antiSyncHealing(timearg) {
  4231. my.antiSync = true;
  4232. let healAnti = setInterval(() => {
  4233. if (player.shameCount < 5) {
  4234. place(0, getAttackDir());
  4235. }
  4236. }, 75);
  4237. setTimeout(() => {
  4238. clearInterval(healAnti);
  4239. setTimeout(() => {
  4240. my.antiSync = false;
  4241. }, game.tickRate);
  4242. }, game.tickRate);
  4243. }
  4244. function biomeGear(mover, returns) {
  4245. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4246. if (returns) return 31;
  4247. buyEquip(31, 0);
  4248. } else {
  4249. if (player.y2 <= config.snowBiomeTop) {
  4250. if (returns) return 6;
  4251. buyEquip(6, 0);
  4252. } else {
  4253. if (returns) return 6;
  4254. buyEquip(6, 0);
  4255. }
  4256. }
  4257. if (returns) return 0;
  4258. }
  4259. class Traps {
  4260. constructor(UTILS, items) {
  4261. this.dist = 0;
  4262. this.aim = 0;
  4263. this.inTrap = false;
  4264. this.replaced = false;
  4265. this.antiTrapped = false;
  4266. this.info = {};
  4267. this.notFast = function() {
  4268. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4269. }
  4270. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4271. try {
  4272. let item = items.list[player.items[id]];
  4273. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4274. let counts = {
  4275. attempts: 0,
  4276. placed: 0
  4277. };
  4278. let tmpObjects = [];
  4279. liztobj.forEach((p) => {
  4280. tmpObjects.push({
  4281. x: p.x,
  4282. y: p.y,
  4283. active: p.active,
  4284. blocker: p.blocker,
  4285. scale: p.scale,
  4286. isItem: p.isItem,
  4287. type: p.type,
  4288. colDiv: p.colDiv,
  4289. getScale: function(sM, ig) {
  4290. sM = sM || 1;
  4291. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4292. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4293. },
  4294. });
  4295. });
  4296. for (let i = first; i < repeat; i += plus) {
  4297. counts.attempts++;
  4298. let relAim = radian + i;
  4299. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4300. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4301. 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)));
  4302. if (cantPlace) continue;
  4303. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4304. if ((!replacer && yaboi)) {
  4305. if (yaboi.inTrap) {
  4306. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI*1.3) {
  4307. place(2, relAim, 1);
  4308. } else {
  4309. player.items[4] == 15 && place(4, relAim, 1);
  4310. }
  4311. } else {
  4312. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 2.6) {
  4313. place(2, relAim, 1);
  4314. } else {
  4315. player.items[4] == 15 && place(4, relAim, 1);
  4316. }
  4317. }
  4318. } else {
  4319. place(id, relAim, 1);
  4320. }
  4321. tmpObjects.push({
  4322. x: tmpX,
  4323. y: tmpY,
  4324. active: true,
  4325. blocker: item.blocker,
  4326. scale: item.scale,
  4327. isItem: true,
  4328. type: null,
  4329. colDiv: item.colDiv,
  4330. getScale: function() {
  4331. return this.scale;
  4332. },
  4333. });
  4334. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4335. counts.placed++;
  4336. }
  4337. }
  4338. if (counts.placed > 0 && replacer && item.dmg) {
  4339. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4340. instaC.canSpikeTick = true;
  4341. }
  4342. }
  4343. } catch (err) {
  4344. }
  4345. };
  4346. this.checkSpikeTick = function() {
  4347. try {
  4348. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4349. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4350. // more range for safe. also testing near.primaryIndex || 5
  4351. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4352. let item = items.list[9];
  4353. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4354. let danger = 0;
  4355. let counts = {
  4356. attempts: 0,
  4357. block: `unblocked`
  4358. };
  4359. for (let i = -1; i <= 1; i += 1 / 10) {
  4360. counts.attempts++;
  4361. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4362. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4363. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4364. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4365. if (cantPlace) continue;
  4366. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4367. danger++;
  4368. counts.block = `blocked`;
  4369. break;
  4370. }
  4371. if (danger) {
  4372. my.anti0Tick = 1;
  4373. // player.chat.message = "Anti SpikeTick " + near.sid;
  4374. //player.chat.count = 2000;
  4375. return true;
  4376. }
  4377. }
  4378. } catch (err) {
  4379. return null;
  4380. }
  4381. return false;
  4382. }
  4383. function getDist(e, t) {
  4384. try {
  4385. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4386. } catch (e) {
  4387. return Infinity;
  4388. }
  4389. }
  4390. this.protect = function(aim) {
  4391. if (!configs.antiTrap) return;
  4392. if(getDist(near, player) > getDist(near, traps.info)) {
  4393. //behind u
  4394. for(let i=-(Math.PI / 2);i<(Math.PI / 2);i+=(Math.PI / 18)) {
  4395. checkPlace(2, near.aim2 + i);
  4396. }
  4397. } else if(getDist(near, traps.info) > getDist(near, player)) {
  4398. //infront of u
  4399. for(let i=-(Math.PI / 2);i<(Math.PI / 2);i+=(Math.PI / 18)) {
  4400. checkPlace(4, near.aim2 + i);
  4401. }
  4402. }
  4403. // if (player.items[4]) {
  4404. // this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4405. // this.antiTrapped = true;
  4406. // }
  4407. };
  4408. this.autoPlace = function() {
  4409. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4410. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4411. if (liztobj.length) {
  4412. let near2 = {
  4413. inTrap: false,
  4414. };
  4415. let nearTrap = liztobj.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function(a, b) {
  4416. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4417. })[0];
  4418. if (nearTrap) {
  4419. near2.inTrap = true;
  4420. } else {
  4421. near2.inTrap = false;
  4422. }
  4423. if (near.dist3 <= 450) {
  4424. if (near.dist3 <= 200) {
  4425. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4426. inTrap: near2.inTrap
  4427. });
  4428. } else {
  4429. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4430. }
  4431. }
  4432. } else {
  4433. if (near.dist3 <= 450) {
  4434. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4435. }
  4436. }
  4437. }
  4438. }
  4439. };
  4440. this.replacer = function(findObj) {
  4441. if (!findObj || !configs.autoReplace) return;
  4442. if (!inGame) return;
  4443. if (this.antiTrapped) return;
  4444. game.tickBase(() => {
  4445. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4446. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4447. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4448. if (objDst <= 400 && near.dist2 <= 400) {
  4449. let danger = this.checkSpikeTick();
  4450. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4451. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4452. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4453. } else {
  4454. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4455. }
  4456. this.replaced = true;
  4457. }
  4458. }, 1);
  4459. };
  4460. }
  4461. };
  4462. class Instakill {
  4463. constructor() {
  4464. this.wait = false;
  4465. this.can = false;
  4466. this.isTrue = false;
  4467. this.nobull = false;
  4468. this.ticking = false;
  4469. this.canSpikeTick = false;
  4470. this.startTick = false;
  4471. this.readyTick = false;
  4472. this.canCounter = false;
  4473. this.revTick = false;
  4474. this.syncHit = false;
  4475. this.changeType = function(type) {
  4476. this.wait = false;
  4477. this.isTrue = true;
  4478. my.autoAim = true;
  4479. let instaLog = [type];
  4480. let backupNobull = near.backupNobull;
  4481. near.backupNobull = false;
  4482. if (type == "rev") {
  4483. selectWeapon(player.weapons[1]);
  4484. buyEquip(53, 0);
  4485. sendAutoGather();
  4486. setTimeout(() => {
  4487. selectWeapon(player.weapons[0]);
  4488. buyEquip(7, 0);
  4489. setTimeout(() => {
  4490. sendAutoGather();
  4491. this.isTrue = false;
  4492. my.autoAim = false;
  4493. }, 225);
  4494. }, 100);
  4495. } else if (type == "nobull") {
  4496. selectWeapon(player.weapons[0]);
  4497. buyEquip(7, 0);
  4498. sendAutoGather();
  4499. setTimeout(() => {
  4500. selectWeapon(player.weapons[1]);
  4501. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4502. setTimeout(() => {
  4503. sendAutoGather();
  4504. this.isTrue = false;
  4505. my.autoAim = false;
  4506. }, 255);
  4507. }, 105);
  4508. } else if (type == "normal") {
  4509. selectWeapon(player.weapons[0]);
  4510. buyEquip(7, 0);
  4511. sendAutoGather();
  4512. setTimeout(() => {
  4513. selectWeapon(player.weapons[1]);
  4514. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4515. setTimeout(() => {
  4516. sendAutoGather();
  4517. this.isTrue = false;
  4518. my.autoAim = false;
  4519. }, 255);
  4520. }, 100);
  4521. } else {
  4522. setTimeout(() => {
  4523. this.isTrue = false;
  4524. my.autoAim = false;
  4525. }, 50);
  4526. }
  4527. };
  4528. this.spikeTickType = function() {
  4529. this.isTrue = true;
  4530. my.autoAim = true;
  4531. selectWeapon(player.weapons[0]);
  4532. buyEquip(7, 0);
  4533. sendAutoGather();
  4534. game.tickBase(() => {
  4535. selectWeapon(player.weapons[0]);
  4536. buyEquip(53, 0);
  4537. game.tickBase(() => {
  4538. sendAutoGather();
  4539. this.isTrue = false;
  4540. my.autoAim = false;
  4541. }, 1);
  4542. }, 1);
  4543. };
  4544. this.counterType = function() {
  4545. this.isTrue = true;
  4546. my.autoAim = true;
  4547. selectWeapon(player.weapons[0]);
  4548. buyEquip(7, 0);
  4549. sendAutoGather();
  4550. game.tickBase(() => {
  4551. selectWeapon(player.weapons[0]);
  4552. buyEquip(53, 0);
  4553. game.tickBase(() => {
  4554. sendAutoGather();
  4555. this.isTrue = false;
  4556. my.autoAim = false;
  4557. }, 1);
  4558. }, 1);
  4559. };
  4560. this.rangeType = function(type) {
  4561. this.isTrue = true;
  4562. my.autoAim = true;
  4563. if (type == "ageInsta") {
  4564. my.ageInsta = false;
  4565. if (player.items[5] == 18) {
  4566. place(5, near.aim2);
  4567. }
  4568. packet("9", undefined, 1);
  4569. buyEquip(22, 0);
  4570. buyEquip(21, 1);
  4571. game.tickBase(() => {
  4572. selectWeapon(player.weapons[1]);
  4573. buyEquip(53, 0);
  4574. buyEquip(21, 1);
  4575. sendAutoGather();
  4576. game.tickBase(() => {
  4577. sendUpgrade(12);
  4578. selectWeapon(player.weapons[1]);
  4579. buyEquip(53, 0);
  4580. buyEquip(21, 1);
  4581. game.tickBase(() => {
  4582. sendUpgrade(15);
  4583. selectWeapon(player.weapons[1]);
  4584. buyEquip(53, 0);
  4585. buyEquip(21, 1);
  4586. game.tickBase(() => {
  4587. sendAutoGather();
  4588. this.isTrue = false;
  4589. my.autoAim = false;
  4590. }, 1);
  4591. }, 1);
  4592. }, 1);
  4593. }, 1);
  4594. } else {
  4595. selectWeapon(player.weapons[1]);
  4596. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4597. buyEquip(53, 0);
  4598. } else {
  4599. buyEquip(20, 0);
  4600. }
  4601. buyEquip(11, 1);
  4602. sendAutoGather();
  4603. game.tickBase(() => {
  4604. sendAutoGather();
  4605. this.isTrue = false;
  4606. my.autoAim = false;
  4607. }, 1);
  4608. }
  4609. };
  4610. this.oneTickType = function() {
  4611. this.isTrue = true;
  4612. my.autoAim = true;
  4613. selectWeapon(player.weapons[1]);
  4614. buyEquip(53, 0);
  4615. buyEquip(11, 1);
  4616. packet("9", near.aim2, 1);
  4617. if (player.weapons[1] == 15) {
  4618. my.revAim = true;
  4619. sendAutoGather();
  4620. }
  4621. game.tickBase(() => {
  4622. my.revAim = false;
  4623. selectWeapon(player.weapons[0]);
  4624. buyEquip(7, 0);
  4625. buyEquip(19, 1);
  4626. packet("9", near.aim2, 1);
  4627. if (player.weapons[1] != 15) {
  4628. sendAutoGather();
  4629. }
  4630. game.tickBase(() => {
  4631. sendAutoGather();
  4632. this.isTrue = false;
  4633. my.autoAim = false;
  4634. packet("9", undefined, 1);
  4635. }, 1);
  4636. }, 1);
  4637. };
  4638. this.threeOneTickType = function() {
  4639. this.isTrue = true;
  4640. my.autoAim = true;
  4641. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4642. biomeGear();
  4643. buyEquip(11, 1);
  4644. packet("9", near.aim2, 1);
  4645. game.tickBase(() => {
  4646. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4647. buyEquip(53, 0);
  4648. buyEquip(11, 1);
  4649. packet("9", near.aim2, 1);
  4650. game.tickBase(() => {
  4651. selectWeapon(player.weapons[0]);
  4652. buyEquip(7, 0);
  4653. buyEquip(19, 1);
  4654. sendAutoGather();
  4655. packet("9", near.aim2, 1);
  4656. game.tickBase(() => {
  4657. sendAutoGather();
  4658. this.isTrue = false;
  4659. my.autoAim = false;
  4660. packet("9", undefined, 1);
  4661. }, 1);
  4662. }, 1);
  4663. }, 1);
  4664. };
  4665. this.kmTickType = function() {
  4666. this.isTrue = true;
  4667. my.autoAim = true;
  4668. my.revAim = true;
  4669. selectWeapon(player.weapons[1]);
  4670. buyEquip(53, 0);
  4671. buyEquip(11, 1);
  4672. sendAutoGather();
  4673. packet("9", near.aim2, 1);
  4674. game.tickBase(() => {
  4675. my.revAim = false;
  4676. selectWeapon(player.weapons[0]);
  4677. buyEquip(7, 0);
  4678. buyEquip(19, 1);
  4679. packet("9", near.aim2, 1);
  4680. game.tickBase(() => {
  4681. sendAutoGather();
  4682. this.isTrue = false;
  4683. my.autoAim = false;
  4684. packet("9", undefined, 1);
  4685. }, 1);
  4686. }, 1);
  4687. };
  4688. this.boostTickType = function() {
  4689. /*this.isTrue = true;
  4690. my.autoAim = true;
  4691. selectWeapon(player.weapons[0]);
  4692. buyEquip(53, 0);
  4693. buyEquip(11, 1);
  4694. packet("9", near.aim2);
  4695. game.tickBase(() => {
  4696. place(4, near.aim2);
  4697. selectWeapon(player.weapons[1]);
  4698. biomeGear();
  4699. buyEquip(11, 1);
  4700. sendAutoGather();
  4701. packet("9", near.aim2);
  4702. game.tickBase(() => {
  4703. selectWeapon(player.weapons[0]);
  4704. buyEquip(7, 0);
  4705. buyEquip(19, 1);
  4706. packet("9", near.aim2);
  4707. game.tickBase(() => {
  4708. sendAutoGather();
  4709. this.isTrue = false;
  4710. my.autoAim = false;
  4711. packet("9", undefined);
  4712. }, 1);
  4713. }, 1);
  4714. }, 1);*/
  4715. this.isTrue = true;
  4716. my.autoAim = true;
  4717. biomeGear();
  4718. buyEquip(11, 1);
  4719. packet("9", near.aim2, 1);
  4720. game.tickBase(() => {
  4721. if (player.weapons[1] == 15) {
  4722. my.revAim = true;
  4723. }
  4724. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  4725. buyEquip(53, 0);
  4726. buyEquip(11, 1);
  4727. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  4728. sendAutoGather();
  4729. }
  4730. packet("9", near.aim2, 1);
  4731. place(4, near.aim2);
  4732. game.tickBase(() => {
  4733. my.revAim = false;
  4734. selectWeapon(player.weapons[0]);
  4735. buyEquip(7, 0);
  4736. buyEquip(19, 1);
  4737. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  4738. sendAutoGather();
  4739. }
  4740. packet("9", near.aim2, 1);
  4741. game.tickBase(() => {
  4742. sendAutoGather();
  4743. this.isTrue = false;
  4744. my.autoAim = false;
  4745. packet("9", undefined, 1);
  4746. }, 1);
  4747. }, 1);
  4748. }, 1);
  4749. };
  4750. this.gotoGoal = function(goto, OT) {
  4751. let slowDists = (weeeee) => weeeee * config.playerScale;
  4752. let goal = {
  4753. a: goto - OT,
  4754. b: goto + OT,
  4755. c: goto - slowDists(1),
  4756. d: goto + slowDists(1),
  4757. e: goto - slowDists(2),
  4758. f: goto + slowDists(2),
  4759. g: goto - slowDists(4),
  4760. h: goto + slowDists(4)
  4761. };
  4762. let bQ = function(wwww, awwww) {
  4763. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  4764. buyEquip(31, 0);
  4765. } else {
  4766. buyEquip(wwww, awwww);
  4767. }
  4768. }
  4769. if (enemy.length) {
  4770. let dst = near.dist2;
  4771. this.ticking = true;
  4772. if (dst >= goal.a && dst <= goal.b) {
  4773. bQ(22, 0);
  4774. bQ(11, 1);
  4775. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  4776. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4777. }
  4778. return {
  4779. dir: undefined,
  4780. action: 1
  4781. };
  4782. } else {
  4783. if (dst < goal.a) {
  4784. if (dst >= goal.g) {
  4785. if (dst >= goal.e) {
  4786. if (dst >= goal.c) {
  4787. bQ(40, 0);
  4788. bQ(10, 1);
  4789. if (configs.slowOT) {
  4790. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  4791. } else {
  4792. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4793. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4794. }
  4795. }
  4796. } else {
  4797. bQ(22, 0);
  4798. bQ(19, 1);
  4799. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4800. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4801. }
  4802. }
  4803. } else {
  4804. bQ(6, 0);
  4805. bQ(12, 1);
  4806. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4807. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4808. }
  4809. }
  4810. } else {
  4811. biomeGear();
  4812. bQ(11, 1);
  4813. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4814. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4815. }
  4816. }
  4817. return {
  4818. dir: near.aim2 + Math.PI,
  4819. action: 0
  4820. };
  4821. } else if (dst > goal.b) {
  4822. if (dst <= goal.h) {
  4823. if (dst <= goal.f) {
  4824. if (dst <= goal.d) {
  4825. bQ(40, 0);
  4826. bQ(9, 1);
  4827. if (configs.slowOT) {
  4828. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  4829. } else {
  4830. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4831. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4832. }
  4833. }
  4834. } else {
  4835. bQ(22, 0);
  4836. bQ(19, 1);
  4837. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4838. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4839. }
  4840. }
  4841. } else {
  4842. bQ(6, 0);
  4843. bQ(12, 1);
  4844. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4845. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4846. }
  4847. }
  4848. } else {
  4849. biomeGear();
  4850. bQ(11, 1);
  4851. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4852. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4853. }
  4854. }
  4855. return {
  4856. dir: near.aim2,
  4857. action: 0
  4858. };
  4859. }
  4860. return {
  4861. dir: undefined,
  4862. action: 0
  4863. };
  4864. }
  4865. } else {
  4866. this.ticking = false;
  4867. return {
  4868. dir: undefined,
  4869. action: 0
  4870. };
  4871. }
  4872. }
  4873. /** wait 1 tick for better quality */
  4874. this.bowMovement = function() {
  4875. let moveMent = this.gotoGoal(685, 3);
  4876. if (moveMent.action) {
  4877. if (player.reloads[53] == 0 && !this.isTrue) {
  4878. this.rangeType("ageInsta");
  4879. } else {
  4880. packet("9", moveMent.dir, 1);
  4881. }
  4882. } else {
  4883. packet("9", moveMent.dir, 1);
  4884. }
  4885. },
  4886. this.tickMovement = function() {
  4887. let moveMent = this.gotoGoal(([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) ? 240 : player.weapons[1] == 15 ? 250 : player.y2 <= config.snowBiomeTop ? [10, 14].includes(player.weapons[1]) ? 270 : 265 : 275, 3);
  4888. if (moveMent.action) {
  4889. if (![6, 22].includes(near.skinIndex) && player.reloads[53] == 0 && !this.isTrue) {
  4890. ([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) || (player.weapons[1] == 15) ? this.oneTickType(): this.threeOneTickType();
  4891. } else {
  4892. packet("9", moveMent.dir, 1);
  4893. }
  4894. } else {
  4895. packet("9", moveMent.dir, 1);
  4896. }
  4897. },
  4898. this.kmTickMovement = function() {
  4899. let moveMent = this.gotoGoal(240, 3);
  4900. if (moveMent.action) {
  4901. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  4902. this.kmTickType();
  4903. } else {
  4904. packet("9", moveMent.dir, 1);
  4905. }
  4906. } else {
  4907. packet("9", moveMent.dir, 1);
  4908. }
  4909. },
  4910. this.boostTickMovement = function() {
  4911. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 390 : player.weapons[1] == 15 ? 365 : 370;
  4912. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1.5 : player.weapons[1] == 15 ? 2 : 3;
  4913. let moveMent = this.gotoGoal(dist, actionDist);
  4914. if (moveMent.action) {
  4915. if (player.reloads[53] == 0 && !this.isTrue) {
  4916. this.boostTickType();
  4917. } else {
  4918. packet("9", moveMent.dir, 1);
  4919. }
  4920. } else {
  4921. packet("9", moveMent.dir, 1);
  4922. }
  4923. }
  4924. /** wait 1 tick for better quality */
  4925. this.perfCheck = function(pl, nr) {
  4926. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  4927. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  4928. let pjs = {
  4929. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  4930. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  4931. };
  4932. 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)) {
  4933. return true;
  4934. }
  4935. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  4936. 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)) {
  4937. return true;
  4938. }
  4939. });
  4940. if (finds) return false;
  4941. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  4942. let tmpScale = tmp.getScale();
  4943. 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)) {
  4944. return true;
  4945. }
  4946. });
  4947. if (finds) return false;
  4948. return true;
  4949. }
  4950. }
  4951. };
  4952. class Autobuy {
  4953. constructor(buyHat, buyAcc) {
  4954. this.hat = function() {
  4955. buyHat.forEach((id) => {
  4956. let find = findID(hats, id);
  4957. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  4958. });
  4959. };
  4960. this.acc = function() {
  4961. buyAcc.forEach((id) => {
  4962. let find = findID(accessories, id);
  4963. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  4964. });
  4965. };
  4966. }
  4967. };
  4968. class Autoupgrade {
  4969. constructor() {
  4970. this.sb = function(upg) {
  4971. upg(3);
  4972. upg(17);
  4973. upg(31);
  4974. upg(23);
  4975. upg(9);
  4976. upg(38);
  4977. };
  4978. this.kh = function(upg) {
  4979. upg(3);
  4980. upg(17);
  4981. upg(31);
  4982. upg(23);
  4983. upg(10);
  4984. upg(38);
  4985. upg(4);
  4986. upg(25);
  4987. };
  4988. this.pb = function(upg) {
  4989. upg(5);
  4990. upg(17);
  4991. upg(32);
  4992. upg(23);
  4993. upg(9);
  4994. upg(38);
  4995. };
  4996. this.ph = function(upg) {
  4997. upg(5);
  4998. upg(17);
  4999. upg(32);
  5000. upg(23);
  5001. upg(10);
  5002. upg(38);
  5003. upg(28);
  5004. upg(25);
  5005. };
  5006. this.db = function(upg) {
  5007. upg(7);
  5008. upg(17);
  5009. upg(31);
  5010. upg(23);
  5011. upg(9);
  5012. upg(34);
  5013. };
  5014. /* old functions */
  5015. this.km = function(upg) {
  5016. upg(7);
  5017. upg(17);
  5018. upg(31);
  5019. upg(23);
  5020. upg(10);
  5021. upg(38);
  5022. upg(4);
  5023. upg(15);
  5024. };
  5025. };
  5026. };
  5027. class Damages {
  5028. constructor(items) {
  5029. // 0.75 1 1.125 1.5
  5030. this.calcDmg = function(dmg, val) {
  5031. return dmg * val;
  5032. };
  5033. this.getAllDamage = function(dmg) {
  5034. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5035. };
  5036. this.weapons = [];
  5037. for (let i = 0; i < items.weapons.length; i++) {
  5038. let wp = items.weapons[i];
  5039. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5040. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5041. this[name] = this.weapons[i];
  5042. }
  5043. }
  5044. }
  5045. /** CLASS CODES */
  5046. // jumpscare code warn
  5047. let tmpList = [];
  5048. // LOADING:
  5049. let UTILS = new Utils();
  5050. let items = new Items();
  5051. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5052. let store = new Store();
  5053. let hats = store.hats;
  5054. let accessories = store.accessories;
  5055. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5056. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5057. let textManager = new Textmanager();
  5058. let traps = new Traps(UTILS, items);
  5059. let instaC = new Instakill();
  5060. let autoBuy = new Autobuy([6, 7, 22, 12, 53, 40, 15, 31, 20], [11, 13, 19, 18, 21]);
  5061. let autoUpgrade = new Autoupgrade();
  5062. let lastDeath;
  5063. let minimapData;
  5064. let mapMarker = {};
  5065. let mapPings = [];
  5066. let tmpPing;
  5067. let breakTrackers = [];
  5068. function sendChat(message) {
  5069. packet("6", message.slice(0, 30));
  5070. }
  5071. let runAtNextTick = [];
  5072. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5073. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5074. let projOffset = config.playerScale * 2;
  5075. let projXY = {
  5076. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5077. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5078. };
  5079. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5080. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5081. })[0];
  5082. if (nearPlayer) {
  5083. if (indx == 1) {
  5084. nearPlayer.shooting[53] = 1;
  5085. } else {
  5086. nearPlayer.shootIndex = weaponIndx;
  5087. nearPlayer.shooting[1] = 1;
  5088. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5089. }
  5090. }
  5091. }
  5092. let projectileCount = 0;
  5093. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5094. if (!tmpObj.isTeam(player)) {
  5095. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5096. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5097. tmpObj.bowThreat[weaponIndex]++;
  5098. if (index == 5) {
  5099. projectileCount++;
  5100. }
  5101. setTimeout(() => {
  5102. tmpObj.bowThreat[weaponIndex]--;
  5103. if (index == 5) {
  5104. projectileCount--;
  5105. }
  5106. }, range / speed);
  5107. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5108. place(1, tmpObj.aim2);
  5109. my.anti0Tick = 4;
  5110. if (!my.antiSync) {
  5111. antiSyncHealing(4);
  5112. }
  5113. } else {
  5114. if (projectileCount >= 2) {
  5115. place(1, tmpObj.aim2);
  5116. my.anti0Tick = 4;
  5117. if (!my.antiSync) {
  5118. antiSyncHealing(4);
  5119. }
  5120. }
  5121. }
  5122. }
  5123. }
  5124. }
  5125. // SHOW ITEM INFO:
  5126. function showItemInfo(item, isWeapon, isStoreItem) {
  5127. if (player && item) {
  5128. UTILS.removeAllChildren(itemInfoHolder);
  5129. itemInfoHolder.classList.add("visible");
  5130. UTILS.generateElement({
  5131. id: "itemInfoName",
  5132. text: UTILS.capitalizeFirst(item.name),
  5133. parent: itemInfoHolder
  5134. });
  5135. UTILS.generateElement({
  5136. id: "itemInfoDesc",
  5137. text: item.desc,
  5138. parent: itemInfoHolder
  5139. });
  5140. if (isStoreItem) {
  5141. } else if (isWeapon) {
  5142. UTILS.generateElement({
  5143. class: "itemInfoReq",
  5144. text: !item.type ? "primary" : "secondary",
  5145. parent: itemInfoHolder
  5146. });
  5147. } else {
  5148. for (let i = 0; i < item.req.length; i += 2) {
  5149. UTILS.generateElement({
  5150. class: "itemInfoReq",
  5151. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5152. parent: itemInfoHolder
  5153. });
  5154. }
  5155. if (item.group.limit) {
  5156. UTILS.generateElement({
  5157. class: "itemInfoLmt",
  5158. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5159. parent: itemInfoHolder
  5160. });
  5161. }
  5162. }
  5163. } else {
  5164. itemInfoHolder.classList.remove("visible");
  5165. }
  5166. }
  5167. // RESIZE:
  5168. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5169. function resize() {
  5170. screenWidth = window.innerWidth;
  5171. screenHeight = window.innerHeight;
  5172. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5173. gameCanvas.width = screenWidth * pixelDensity;
  5174. gameCanvas.height = screenHeight * pixelDensity;
  5175. gameCanvas.style.width = screenWidth + "px";
  5176. gameCanvas.style.height = screenHeight + "px";
  5177. mainContext.setTransform(
  5178. scaleFillNative, 0,
  5179. 0, scaleFillNative,
  5180. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5181. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5182. );
  5183. }
  5184. resize();
  5185. // MOUSE INPUT:
  5186. var usingTouch;
  5187. const mals = document.getElementById('touch-controls-fullscreen');
  5188. mals.style.display = 'block';
  5189. mals.addEventListener("mousemove", gameInput, false);
  5190. function gameInput(e) {
  5191. mouseX = e.clientX;
  5192. mouseY = e.clientY;
  5193. }
  5194. let clicks = {
  5195. left: false,
  5196. middle: false,
  5197. right: false,
  5198. };
  5199. mals.addEventListener("mousedown", mouseDown, false);
  5200. function mouseDown(e) {
  5201. if (attackState != 1) {
  5202. attackState = 1;
  5203. if (e.button == 0) {
  5204. clicks.left = true;
  5205. } else if (e.button == 1) {
  5206. clicks.middle = true;
  5207. } else if (e.button == 2) {
  5208. clicks.right = true;
  5209. }
  5210. }
  5211. }
  5212. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5213. function mouseUp(e) {
  5214. if (attackState != 0) {
  5215. attackState = 0;
  5216. if (e.button == 0) {
  5217. clicks.left = false;
  5218. } else if (e.button == 1) {
  5219. clicks.middle = false;
  5220. } else if (e.button == 2) {
  5221. clicks.right = false;
  5222. }
  5223. }
  5224. }
  5225. mals.addEventListener("wheel", wheel, false);
  5226. function wheel(e) {
  5227. if (e.deltaY < 0) {
  5228. wbe += 0.005
  5229. maxScreenWidth = config.maxScreenWidth * wbe;
  5230. maxScreenHeight = config.maxScreenHeight * wbe;
  5231. resize()
  5232. } else {
  5233. wbe -= 0.005
  5234. maxScreenWidth = config.maxScreenWidth * wbe;
  5235. maxScreenHeight = config.maxScreenHeight * wbe;
  5236. resize()
  5237. }
  5238. }
  5239. // INPUT UTILS:
  5240. function getMoveDir() {
  5241. let dx = 0;
  5242. let dy = 0;
  5243. for (let key in moveKeys) {
  5244. let tmpDir = moveKeys[key];
  5245. dx += !!keys[key] * tmpDir[0];
  5246. dy += !!keys[key] * tmpDir[1];
  5247. }
  5248. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5249. }
  5250. function getSafeDir() {
  5251. if (!player)
  5252. return 0;
  5253. if (!player.lockDir) {
  5254. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5255. }
  5256. return lastDir || 0;
  5257. }
  5258. let plusDir = 0;
  5259. let lastSpin = Date.now();
  5260. function getAttackDir() {
  5261. if(player && Date.now() - lastSpin >= 235 && !(clicks.right || clicks.left)) {
  5262. plusDir += Math.random()*(Math.PI*2);
  5263. lastSpin = Date.now();
  5264. }
  5265. if (!player)
  5266. return "0";
  5267. 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))
  5268. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? near.aim2 : getSafeDir();
  5269. else
  5270. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5271. lastDir = getSafeDir();
  5272. else
  5273. if (traps.inTrap) {
  5274. lastDir = traps.aim;
  5275. } else
  5276. if (!player.lockDir) {
  5277. if (!player.lockDir && autos.stopspin) {
  5278. if(useWasd) {
  5279. lastDir = lastDir;
  5280. } else {
  5281. lastDir = getSafeDir();
  5282. }
  5283. }
  5284. }
  5285. return lastDir;
  5286. }
  5287. function getVisualDir() {
  5288. if (!player)
  5289. return 0;
  5290. lastDir = getSafeDir();
  5291. return lastDir || 0;
  5292. }
  5293. // KEYS:
  5294. function keysActive() {
  5295. return (allianceMenu.style.display != "block" &&
  5296. chatHolder.style.display != "block" &&
  5297. !menuCBFocus);
  5298. }
  5299. function toggleMenuChat() {
  5300. if (menuChatDiv.style.display != "none") {
  5301. // chatHolder.style.display = "none";
  5302. // if (menuChatBox.value != "") {
  5303. //commands[command.slice(1)]
  5304. let cmd = function(command) {
  5305. return {
  5306. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5307. fv: commands[command.slice(1).split(" ")[0]]
  5308. }
  5309. }
  5310. let command = cmd(menuChatBox.value);
  5311. if (command.found) {
  5312. if (typeof command.fv.action === "function") {
  5313. command.fv.action(menuChatBox.value);
  5314. }
  5315. } else {
  5316. sendChat(menuChatBox.value);
  5317. }
  5318. menuChatBox.value = "";
  5319. menuChatBox.blur();
  5320. } else {
  5321. if (menuCBFocus) {
  5322. menuChatBox.blur();
  5323. } else {
  5324. menuChatBox.focus();
  5325. }
  5326. }
  5327. }
  5328. function keyDown(event) {
  5329. let keyNum = event.which || event.keyCode || 0;
  5330. if (player && player.alive && keysActive()) {
  5331. if (!keys[keyNum]) {
  5332. keys[keyNum] = 1;
  5333. macro[event.key] = 1;
  5334. if (keyNum == 27) {
  5335. openMenu = !openMenu;
  5336. $("#menuDiv").toggle();
  5337. $("#menuChatDiv").toggle();
  5338. } else if (keyNum == 69) {
  5339. sendAutoGather();
  5340. } else if (keyNum == 67) {
  5341. updateMapMarker();
  5342. } else if (player.weapons[keyNum - 49] != undefined) {
  5343. player.weaponCode = player.weapons[keyNum - 49];
  5344. } else if (moveKeys[keyNum]) {
  5345. sendMoveDir();
  5346. } else if (event.key == "m") {
  5347. mills.placeSpawnPads = !mills.placeSpawnPads;
  5348. } else if (event.key == "z") {
  5349. mills.place = !mills.place;
  5350. } else if (event.key == "Z") {
  5351. typeof window.debug == "function" && window.debug();
  5352. } else if (keyNum == 32) {
  5353. packet("F", 1, getSafeDir(), 1);
  5354. packet("F", 0, getSafeDir(), 1);
  5355. } else if (event.key == ",") {
  5356. io.send("6", 'get synced')
  5357. project.send(JSON.stringify(["tezt", "ratio"]));
  5358. // botSkts.push([botPlayer]);
  5359. for(let i = 0; i < botz.length; i++) {
  5360. // if(botz[i][0]) {
  5361. botz[i][0].zync(near);
  5362. console.log(botz[i][0])
  5363. }
  5364. // project.send("tezt");
  5365. // botSkts.forEach((bot) => {
  5366. // bot.zync();
  5367. // })
  5368. // io.send("S", 1)
  5369. }
  5370. }
  5371. }
  5372. }
  5373. // let xx = canvaz.width/2;
  5374. // let yy = canvaz.height/2;
  5375. // let mouze = {
  5376. // x: xx - mouzeX,
  5377. // y: yy - mouzeY
  5378. // }
  5379. // let ingamecoorformodabow = {
  5380. // x: player.x + mouze.x,
  5381. // y: player.x + mouze.x
  5382. // }
  5383. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5384. function keyUp(event) {
  5385. if (player && player.alive) {
  5386. let keyNum = event.which || event.keyCode || 0;
  5387. if (keyNum == 13) {
  5388. toggleMenuChat();
  5389. } else if (keysActive()) {
  5390. if (keys[keyNum]) {
  5391. keys[keyNum] = 0;
  5392. macro[event.key] = 0;
  5393. if (moveKeys[keyNum]) {
  5394. sendMoveDir();
  5395. } else if (event.key == ",") {
  5396. player.sync = false;
  5397. }
  5398. }
  5399. }
  5400. }
  5401. }
  5402. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5403. function sendMoveDir() {
  5404. if(found) {
  5405. packet("9", undefined, 1);
  5406. } else {
  5407. let newMoveDir = getMoveDir();
  5408. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5409. if (!my.autoPush && !found) {
  5410. packet("9", newMoveDir, 1);
  5411. }
  5412. lastMoveDir = newMoveDir;
  5413. }
  5414. }
  5415. }
  5416. // BUTTON EVENTS:
  5417. function bindEvents() {}
  5418. bindEvents();
  5419. // ITEM COUNT DISPLAY:
  5420. let isItemSetted = [];
  5421. function updateItemCountDisplay(index = undefined) {
  5422. for (let i = 3; i < items.list.length; ++i) {
  5423. let id = items.list[i].group.id;
  5424. let tmpI = items.weapons.length + i;
  5425. if (!isItemSetted[tmpI]) {
  5426. isItemSetted[tmpI] = document.createElement("div");
  5427. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5428. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5429. isItemSetted[tmpI].style = `
  5430. display: block;
  5431. position: absolute;
  5432. padding-left: 5px;
  5433. font-size: 2em;
  5434. color: #fff;
  5435. `;
  5436. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5437. } else {
  5438. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5439. }
  5440. }
  5441. }
  5442. // AUTOPUSH:
  5443. function autoPush() {
  5444. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  5445. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5446. })[0];
  5447. if (nearTrap) {
  5448. let spike = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  5449. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5450. })[0];
  5451. if (spike) {
  5452. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  5453. /*let pos = {
  5454. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5455. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5456. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  5457. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  5458. };
  5459. let finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5460. let tmpScale = tmp.getScale();
  5461. 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)) {
  5462. return true;
  5463. }
  5464. });
  5465. if (finds) {
  5466. if (my.autoPush) {
  5467. my.autoPush = false;
  5468. packet("9", lastMoveDir || undefined, 1);
  5469. }
  5470. } else {*/
  5471. my.autoPush = true;
  5472. my.pushData = {
  5473. x: spike.x + Math.cos(pushAngle),
  5474. y: spike.y + Math.sin(pushAngle),
  5475. x2: player.x2+30,
  5476. y2: player.y2+30
  5477. };
  5478. let point = {
  5479. x: near.x2 + Math.cos(pushAngle) * 30,
  5480. y: near.y2 + Math.sin(pushAngle) * 60,
  5481. }
  5482. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  5483. packet("9", dir, 1)
  5484. /*let scale = (player.scale / 10);
  5485. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5486. packet("9", near.aim2, 1);
  5487. } else {
  5488. packet("9", UTILS.getDirect(pos, player, 2, 2), 1);
  5489. }*/
  5490. //}
  5491. } else {
  5492. if (my.autoPush) {
  5493. my.autoPush = false;
  5494. packet("9", lastMoveDir || undefined, 1);
  5495. }
  5496. }
  5497. } else {
  5498. if (my.autoPush) {
  5499. my.autoPush = false;
  5500. packet("9", lastMoveDir || undefined, 1);
  5501. }
  5502. }
  5503. }
  5504. // ADD DEAD PLAYER:
  5505. function addDeadPlayer(tmpObj) {
  5506. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  5507. }
  5508. /** APPLY SOCKET CODES */
  5509. // SET INIT DATA:
  5510. function setInitData(data) {
  5511. alliances = data.teams;
  5512. }
  5513. // SETUP GAME:
  5514. function setupGame(yourSID) {
  5515. keys = {};
  5516. macro = {};
  5517. playerSID = yourSID;
  5518. attackState = 0;
  5519. inGame = true;
  5520. packet("F", 0, getAttackDir(), 1);
  5521. my.ageInsta = true;
  5522. if (firstSetup) {
  5523. firstSetup = false;
  5524. gameObjects.length = 0;
  5525. liztobj.length = 0;
  5526. }
  5527. }
  5528. // ADD NEW PLAYER:
  5529. function addPlayer(data, isYou) {
  5530. let tmpPlayer = findPlayerByID(data[0]);
  5531. if (!tmpPlayer) {
  5532. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  5533. objectManager, players, ais, items, hats, accessories);
  5534. players.push(tmpPlayer);
  5535. if (data[1] != playerSID) {
  5536. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5537. }
  5538. } else {
  5539. if (data[1] != playerSID) {
  5540. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5541. }
  5542. }
  5543. tmpPlayer.spawn(isYou ? true : null);
  5544. tmpPlayer.visible = false;
  5545. tmpPlayer.oldPos = {
  5546. x2: undefined,
  5547. y2: undefined
  5548. };
  5549. tmpPlayer.x2 = undefined;
  5550. tmpPlayer.y2 = undefined;
  5551. tmpPlayer.x3 = undefined;
  5552. tmpPlayer.y3 = undefined;
  5553. tmpPlayer.setData(data);
  5554. if (isYou) {
  5555. if (!player) {
  5556. window.prepareUI(tmpPlayer);
  5557. }
  5558. player = tmpPlayer;
  5559. camX = player.x;
  5560. camY = player.y;
  5561. my.lastDir = 0;
  5562. updateItems();
  5563. updateAge();
  5564. updateItemCountDisplay();
  5565. if (player.skins[7]) {
  5566. my.reSync = true;
  5567. }
  5568. }
  5569. }
  5570. // REMOVE PLAYER:
  5571. function removePlayer(id) {
  5572. for (let i = 0; i < players.length; i++) {
  5573. if (players[i].id == id) {
  5574. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  5575. players.splice(i, 1);
  5576. break;
  5577. }
  5578. }
  5579. }
  5580. // UPDATE HEALTH:
  5581. function updateHealth(sid, value) {
  5582. tmpObj = findPlayerBySID(sid);
  5583. if (tmpObj) {
  5584. // tmpObj.lastshamecount = tmpObj.shameCount;
  5585. tmpObj.oldHealth = tmpObj.health;
  5586. tmpObj.health = value;
  5587. tmpObj.judgeShame();
  5588. if (tmpObj.oldHealth > tmpObj.health) {
  5589. tmpObj.timeDamaged = Date.now(); //here'
  5590. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  5591. let damaged = tmpObj.damaged;
  5592. tmpObj = findPlayerBySID(sid);
  5593. let bullTicked = false;
  5594. if (tmpObj.health <= 0) {
  5595. if (!tmpObj.death) {
  5596. tmpObj.death = true;
  5597. if (tmpObj != player) {
  5598. if(tmpObj.skinIndex == 45) {
  5599. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to clown`, "red");
  5600. } else if(tmpObj.shameCount >= 5) {
  5601. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to high shame`, "red");
  5602. } else {
  5603. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died`, "red");
  5604. }
  5605. textManager.showText(tmpObj.x, tmpObj.y, 20, 0.15, 1850, '', 2);
  5606. }
  5607. addDeadPlayer(tmpObj);
  5608. }
  5609. }
  5610. if (tmpObj == player) {
  5611. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  5612. if (my.reSync) {
  5613. my.reSync = false;
  5614. tmpObj.setBullTick = true;
  5615. }
  5616. bullTicked = true;
  5617. }
  5618. if (inGame) {
  5619. let attackers = getAttacker(damaged);
  5620. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  5621. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  5622. let healTimeout = 95;
  5623. let slowHeal = function(timer) {
  5624. setTimeout(() => {
  5625. healer();
  5626. }, timer);
  5627. }
  5628. if (near.length && near.damageThreat(player) - (player.canEmpAnti || player.empAnti ? 25 : 0) >= 85) {
  5629. player.canEmpAnti = true;
  5630. player.antiTimer = game.tick;
  5631. let shame = 4;
  5632. if (player.shameCount < shame) {
  5633. healer();
  5634. } else {
  5635. slowHeal(healTimeout);
  5636. }
  5637. } else {
  5638. slowHeal(healTimeout);
  5639. }
  5640. }
  5641. // if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  5642. } else {
  5643. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  5644. tmpObj.setPoisonTick = true;
  5645. }
  5646. }
  5647. } else {
  5648. tmpObj.timeHealed = Date.now(); //
  5649. // game.tickBase(() => {
  5650. // }, 2)
  5651. }
  5652. if (tmpObj.health <= 0) {
  5653. bots.forEach((hmm) => {
  5654. hmm.whyDie = tmpObj.name;
  5655. });
  5656. }
  5657. }
  5658. }
  5659. // KILL PLAYER:
  5660. function killPlayer() {
  5661. inGame = false;
  5662. lastDeath = {
  5663. x: player.x,
  5664. y: player.y,
  5665. };
  5666. }
  5667. // UPDATE PLAYER ITEM VALUES:
  5668. function updateItemCounts(index, value) {
  5669. if (player) {
  5670. player.itemCounts[index] = value;
  5671. updateItemCountDisplay(index);
  5672. }
  5673. }
  5674. // UPDATE AGE:
  5675. function updateAge(xp, mxp, age) {
  5676. if (xp != undefined)
  5677. player.XP = xp;
  5678. if (mxp != undefined)
  5679. player.maxXP = mxp;
  5680. if (age != undefined)
  5681. player.age = age;
  5682. }
  5683. // UPDATE UPGRADES:
  5684. function updateUpgrades(points, age) {
  5685. player.upgradePoints = points;
  5686. player.upgrAge = age;
  5687. if (points > 0) {
  5688. tmpList.length = 0;
  5689. UTILS.removeAllChildren(upgradeHolder);
  5690. for (let i = 0; i < items.weapons.length; ++i) {
  5691. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  5692. let e = UTILS.generateElement({
  5693. id: "upgradeItem" + i,
  5694. class: "actionBarItem",
  5695. onmouseout: function() {
  5696. showItemInfo();
  5697. },
  5698. parent: upgradeHolder
  5699. });
  5700. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  5701. tmpList.push(i);
  5702. }
  5703. }
  5704. for (let i = 0; i < items.list.length; ++i) {
  5705. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  5706. let tmpI = (items.weapons.length + i);
  5707. let e = UTILS.generateElement({
  5708. id: "upgradeItem" + tmpI,
  5709. class: "actionBarItem",
  5710. onmouseout: function() {
  5711. showItemInfo();
  5712. },
  5713. parent: upgradeHolder
  5714. });
  5715. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  5716. tmpList.push(tmpI);
  5717. }
  5718. }
  5719. for (let i = 0; i < tmpList.length; i++) {
  5720. (function(i) {
  5721. let tmpItem = getEl('upgradeItem' + i);
  5722. // tmpItem.onmouseover = function() {
  5723. // if (items.weapons[i]) {
  5724. // showItemInfo(items.weapons[i], true);
  5725. // } else {
  5726. // showItemInfo(items.list[i - items.weapons.length]);
  5727. // }
  5728. // };
  5729. tmpItem.onclick = UTILS.checkTrusted(function() {
  5730. packet("H", i);
  5731. });
  5732. UTILS.hookTouchEvents(tmpItem);
  5733. })(tmpList[i]);
  5734. }
  5735. if (tmpList.length) {
  5736. upgradeHolder.style.display = "block";
  5737. upgradeCounter.style.display = "block";
  5738. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  5739. } else {
  5740. upgradeHolder.style.display = "none";
  5741. upgradeCounter.style.display = "none";
  5742. showItemInfo();
  5743. }
  5744. } else {
  5745. upgradeHolder.style.display = "none";
  5746. upgradeCounter.style.display = "none";
  5747. showItemInfo();
  5748. }
  5749. }
  5750. // KILL OBJECT:
  5751. function killObject(sid) {
  5752. let findObj = findObjectBySid(sid);
  5753. objectManager.disableBySid(sid);
  5754. if (player) {
  5755. for (let i = 0; i < breakObjects.length; i++) {
  5756. if (breakObjects[i].sid == sid) {
  5757. breakObjects.splice(i, 1);
  5758. break;
  5759. }
  5760. }
  5761. if (!player.canSee(findObj)) {
  5762. breakTrackers.push({
  5763. x: findObj.x,
  5764. y: findObj.y
  5765. });
  5766. }
  5767. if (breakTrackers.length > 8) {
  5768. breakTrackers.shift();
  5769. }
  5770. traps.replacer(findObj);
  5771. }
  5772. }
  5773. // KILL ALL OBJECTS BY A PLAYER:
  5774. function killObjects(sid) {
  5775. if (player) objectManager.removeAllItems(sid);
  5776. }
  5777. function setTickout(doo, timeout) {
  5778. if (!ticks.manage[ticks.tick + timeout]) {
  5779. ticks.manage[ticks.tick + timeout] = [doo];
  5780. } else {
  5781. ticks.manage[ticks.tick + timeout].push(doo);
  5782. }
  5783. }
  5784. function caf(e, t) {
  5785. try {
  5786. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  5787. } catch (e) {
  5788. return 0;
  5789. }
  5790. }
  5791. let found = false;
  5792. let autoQ = false;
  5793. let autos = {
  5794. insta: {
  5795. todo: false,
  5796. wait: false,
  5797. count: 4,
  5798. shame: 5
  5799. },
  5800. bull: false,
  5801. antibull: 0,
  5802. reloaded: false,
  5803. stopspin: true
  5804. }
  5805. // UPDATE PLAYER DATA:
  5806. function updatePlayers(data) {
  5807. // if(player.shameCount > 0) {
  5808. // my.reSync = true;
  5809. // } else {
  5810. // my.reSync = false;
  5811. // }
  5812. // let movementPrediction = {
  5813. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  5814. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  5815. // }
  5816. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  5817. // potentialzpiketick.forEach((obj) => {
  5818. // if(cdf(obj, player) <= 200) {
  5819. // packet('a', undefined);
  5820. // }
  5821. // })
  5822. // let newPos = {
  5823. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  5824. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  5825. // }
  5826. function getAngleDifference(angle1, angle2) {
  5827. // Normalize the angles to be between 0 and 2Ï€
  5828. angle1 = angle1 % (2 * Math.PI);
  5829. angle2 = angle2 % (2 * Math.PI);
  5830. // Calculate the absolute difference between the angles
  5831. let diff = Math.abs(angle1 - angle2);
  5832. // Adjust the difference to be between 0 and π
  5833. if (diff > Math.PI) {
  5834. diff = (2 * Math.PI) - diff;
  5835. }
  5836. return diff;
  5837. }
  5838. // function smartMove(oneTickMove) {
  5839. // let dir = player.moveDir;
  5840. // let found = false
  5841. // let buildings = liztobj.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x))
  5842. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  5843. // let newPos = {
  5844. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  5845. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  5846. // }
  5847. // for (let i = 0; i < spikes.length; i++) {
  5848. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  5849. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  5850. // }
  5851. // }
  5852. // if (found != false && !traps.inTrap) {
  5853. // packet("9", undefined);
  5854. // } else {
  5855. // packet("9", dir);
  5856. // }
  5857. // player.oldPos.x2 = player.x2;
  5858. // player.oldPos.y2 = player.y2;
  5859. // }
  5860. // function detectEnemySpikeCollisions(tmpObj) {
  5861. // let buildings = liztobj.sort((a, b) => Math.hypot(tmpObj.y - a.y, tmpObj.x - a.x) - Math.hypot(tmpObj.y - b.y, tmpObj.x - b.x));
  5862. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  5863. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  5864. // let enemy = {
  5865. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  5866. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  5867. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  5868. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  5869. // }
  5870. // let found = false;
  5871. // for (let i = 0; i < spikes.length; i++) {
  5872. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  5873. // found = true;
  5874. // }
  5875. // }
  5876. // // player.oldPos.x2 = tmpObj.x2;
  5877. // // player.oldPos.y2 = tmpObj.y2;
  5878. // }
  5879. game.tick++;
  5880. enemy = [];
  5881. nears = [];
  5882. near = [];
  5883. game.tickSpeed = performance.now() - game.lastTick;
  5884. game.lastTick = performance.now();
  5885. players.forEach((tmp) => {
  5886. tmp.forcePos = !tmp.visible;
  5887. tmp.visible = false;
  5888. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  5889. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  5890. });
  5891. for (let i = 0; i < data.length;) {
  5892. tmpObj = findPlayerBySID(data[i]);
  5893. if (tmpObj) {
  5894. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  5895. tmpObj.t2 = game.lastTick;
  5896. tmpObj.oldPos.x2 = tmpObj.x2;
  5897. tmpObj.oldPos.y2 = tmpObj.y2;
  5898. tmpObj.x1 = tmpObj.x;
  5899. tmpObj.y1 = tmpObj.y;
  5900. tmpObj.x2 = data[i + 1];
  5901. tmpObj.y2 = data[i + 2];
  5902. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  5903. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  5904. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  5905. tmpObj.d2 = data[i + 3];
  5906. tmpObj.dt = 0;
  5907. tmpObj.buildIndex = data[i + 4];
  5908. tmpObj.weaponIndex = data[i + 5];
  5909. tmpObj.weaponVariant = data[i + 6];
  5910. tmpObj.team = data[i + 7];
  5911. tmpObj.isLeader = data[i + 8];
  5912. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  5913. tmpObj.oldTailIndex = tmpObj.tailIndex;
  5914. tmpObj.skinIndex = data[i + 9];
  5915. tmpObj.tailIndex = data[i + 10];
  5916. tmpObj.iconIndex = data[i + 11];
  5917. tmpObj.zIndex = data[i + 12];
  5918. tmpObj.visible = true;
  5919. tmpObj.update(game.tickSpeed);
  5920. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  5921. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  5922. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  5923. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  5924. tmpObj.damageThreat = 0;
  5925. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  5926. tmpObj.addShameTimer();
  5927. }
  5928. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  5929. tmpObj.shameTimer = 0;
  5930. tmpObj.shameCount = 0;
  5931. if (tmpObj == player) {
  5932. healer();
  5933. }
  5934. }
  5935. botSkts.forEach((bot) => {
  5936. bot.showName = 'YEAHHH'
  5937. })
  5938. for(let i = 0; i < players.length; i++) {
  5939. for(let aa = 0; aa < botSkts.length; aa++) {
  5940. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  5941. }
  5942. }
  5943. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  5944. autoQ = true;
  5945. healer();
  5946. } else {
  5947. if (autoQ) {
  5948. healer();
  5949. }
  5950. autoQ = false;
  5951. }
  5952. if (tmpObj == player) {
  5953. if (liztobj.length) {
  5954. liztobj.forEach((tmp) => {
  5955. tmp.onNear = false;
  5956. if (tmp.active) {
  5957. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  5958. tmp.onNear = true;
  5959. }
  5960. if (tmp.isItem && tmp.owner) {
  5961. 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)) {
  5962. tmp.breakObj = true;
  5963. breakObjects.push({
  5964. x: tmp.x,
  5965. y: tmp.y,
  5966. sid: tmp.sid
  5967. });
  5968. }
  5969. }
  5970. }
  5971. });
  5972. 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) {
  5973. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  5974. })[0];
  5975. if (nearTrap) {
  5976. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  5977. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  5978. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  5979. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  5980. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  5981. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  5982. traps.inTrap = true;
  5983. traps.info = nearTrap;
  5984. } else {
  5985. traps.inTrap = false;
  5986. traps.info = {};
  5987. }
  5988. } else {
  5989. traps.inTrap = false;
  5990. }
  5991. }
  5992. if (tmpObj.weaponIndex < 9) {
  5993. tmpObj.primaryIndex = tmpObj.weaponIndex;
  5994. tmpObj.primaryVariant = tmpObj.weaponVariant;
  5995. } else if (tmpObj.weaponIndex > 8) {
  5996. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  5997. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  5998. }
  5999. }
  6000. i += 13;
  6001. }
  6002. if (textManager.stack.length) {
  6003. let stacks = [];
  6004. let notstacks = [];
  6005. let num = 0;
  6006. let num2 = 0;
  6007. let pos = {
  6008. x: null,
  6009. y: null
  6010. };
  6011. let pos2 = {
  6012. x: null,
  6013. y: null
  6014. }
  6015. textManager.stack.forEach((text) => {
  6016. if (text.value >= 0) {
  6017. if (num == 0) pos = {
  6018. x: text.x,
  6019. y: text.y
  6020. };
  6021. num += Math.abs(text.value);
  6022. } else {
  6023. if (num2 == 0) pos2 = {
  6024. x: text.x,
  6025. y: text.y
  6026. };
  6027. num2 += Math.abs(text.value);
  6028. }
  6029. });
  6030. if (num2 > 0) {
  6031. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  6032. }
  6033. if (num > 0) {
  6034. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6035. }
  6036. textManager.stack = [];
  6037. }
  6038. if (runAtNextTick.length) {
  6039. runAtNextTick.forEach((tmp) => {
  6040. checkProjectileHolder(...tmp);
  6041. });
  6042. runAtNextTick = [];
  6043. }
  6044. for (let i = 0; i < data.length;) {
  6045. tmpObj = findPlayerBySID(data[i]);
  6046. if (tmpObj) {
  6047. if (!tmpObj.isTeam(player)) {
  6048. enemy.push(tmpObj);
  6049. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6050. nears.push(tmpObj);
  6051. }
  6052. }
  6053. tmpObj.manageReload();
  6054. if (tmpObj != player) {
  6055. tmpObj.addDamageThreat(player);
  6056. }
  6057. }
  6058. i += 13;
  6059. }
  6060. /*projectiles.forEach((proj) => {
  6061. tmpObj = proj;
  6062. if (tmpObj.active) {
  6063. tmpObj.tickUpdate(game.tickSpeed);
  6064. }
  6065. });*/
  6066. if (player && player.alive) {
  6067. if (enemy.length) {
  6068. near = enemy.sort(function(tmp1, tmp2) {
  6069. return tmp1.dist2 - tmp2.dist2;
  6070. })[0];
  6071. } else {
  6072. // console.log("no enemy");
  6073. }
  6074. if (game.tickQueue[game.tick]) {
  6075. game.tickQueue[game.tick].forEach((action) => {
  6076. action();
  6077. });
  6078. game.tickQueue[game.tick] = null;
  6079. }
  6080. players.forEach((tmp) => {
  6081. if (!tmp.visible && player != tmp) {
  6082. tmp.reloads = {
  6083. 0: 0,
  6084. 1: 0,
  6085. 2: 0,
  6086. 3: 0,
  6087. 4: 0,
  6088. 5: 0,
  6089. 6: 0,
  6090. 7: 0,
  6091. 8: 0,
  6092. 9: 0,
  6093. 10: 0,
  6094. 11: 0,
  6095. 12: 0,
  6096. 13: 0,
  6097. 14: 0,
  6098. 15: 0,
  6099. 53: 0,
  6100. };
  6101. }
  6102. if (tmp.setBullTick) {
  6103. tmp.bullTimer = 0;
  6104. }
  6105. if (tmp.setPoisonTick) {
  6106. tmp.poisonTimer = 0;
  6107. }
  6108. tmp.updateTimer();
  6109. });
  6110. if (inGame) {
  6111. if (enemy.length) {
  6112. if (player.canEmpAnti) {
  6113. player.canEmpAnti = false;
  6114. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6115. if (near.reloads[53] == 0) {
  6116. player.empAnti = true;
  6117. player.soldierAnti = false;
  6118. //modLog("EmpAnti");
  6119. } else {
  6120. player.empAnti = false;
  6121. player.soldierAnti = true;
  6122. //modLog("SoldierAnti");
  6123. }
  6124. }
  6125. }
  6126. 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) {
  6127. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6128. })[0];
  6129. if (prehit) {
  6130. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6131. instaC.canSpikeTick = true;
  6132. instaC.syncHit = true;
  6133. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6134. instaC.revTick = true;
  6135. }
  6136. }
  6137. }
  6138. let antiSpikeTick = liztobj.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + player.scale)).sort(function(a, b) {
  6139. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6140. })[0];
  6141. if (antiSpikeTick && !traps.inTrap) {
  6142. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  6143. my.anti0Tick = 1;
  6144. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  6145. //player.chat.count = 2000;
  6146. }
  6147. }
  6148. }
  6149. if ((useWasd ? true : ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) && instaC.perfCheck(player, near)) {
  6150. if (player.checkCanInsta(true) >= 100) {
  6151. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6152. } else {
  6153. instaC.nobull = false;
  6154. }
  6155. instaC.can = true;
  6156. } else {
  6157. instaC.can = false;
  6158. }
  6159. macro.q && place(0, getAttackDir());
  6160. macro.f && place(4, getSafeDir());
  6161. macro.v && place(2, getSafeDir());
  6162. macro.y && place(5, getSafeDir());
  6163. macro.h && place(player.getItemType(22), getSafeDir());
  6164. macro.n && place(3, getSafeDir());
  6165. if (game.tick % 1 == 0) {
  6166. if (mills.place) {
  6167. let plcAng = 7.7;
  6168. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6169. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6170. }
  6171. } else {
  6172. if (mills.placeSpawnPads) {
  6173. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6174. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6175. }
  6176. }
  6177. }
  6178. }
  6179. if (instaC.can) {
  6180. instaC.changeType(player.weapons[1] == 10 ? "rev" : "normal");
  6181. }
  6182. if (instaC.canCounter) {
  6183. instaC.canCounter = false;
  6184. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6185. instaC.counterType();
  6186. }
  6187. }
  6188. if (instaC.canSpikeTick) {
  6189. instaC.canSpikeTick = false;
  6190. if (instaC.revTick) {
  6191. instaC.revTick = false;
  6192. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6193. instaC.changeType("rev");
  6194. chch(null, "[RevSyncHit]", "yellow");
  6195. }
  6196. } else {
  6197. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6198. instaC.spikeTickType();
  6199. if (instaC.syncHit) {
  6200. chch(null, "[SyncHit]", "yellow");
  6201. }
  6202. }
  6203. }
  6204. }
  6205. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6206. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6207. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6208. }
  6209. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6210. sendAutoGather();
  6211. my.waitHit = 1;
  6212. game.tickBase(() => {
  6213. sendAutoGather();
  6214. my.waitHit = 0;
  6215. }, 1);
  6216. }
  6217. }
  6218. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6219. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6220. selectWeapon(player.weapons[0]);
  6221. }
  6222. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6223. sendAutoGather();
  6224. my.waitHit = 1;
  6225. game.tickBase(() => {
  6226. sendAutoGather();
  6227. my.waitHit = 0;
  6228. }, 1);
  6229. }
  6230. }
  6231. if (traps.inTrap) {
  6232. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6233. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6234. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6235. }
  6236. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6237. sendAutoGather();
  6238. my.waitHit = 1;
  6239. game.tickBase(() => {
  6240. sendAutoGather();
  6241. my.waitHit = 0;
  6242. }, 1);
  6243. }
  6244. }
  6245. }
  6246. if (clicks.middle && !traps.inTrap) {
  6247. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6248. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6249. instaC.bowMovement();
  6250. } else {
  6251. instaC.rangeType();
  6252. }
  6253. }
  6254. }
  6255. if (macro.t && !traps.inTrap) {
  6256. 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))) {
  6257. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6258. }
  6259. }
  6260. if (macro["."] && !traps.inTrap) {
  6261. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6262. instaC.boostTickMovement();
  6263. }
  6264. }
  6265. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue && !(useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8)) {
  6266. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6267. if (!my.reloaded) {
  6268. my.reloaded = true;
  6269. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6270. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6271. selectWeapon(player.weapons[fastSpeed]);
  6272. }
  6273. }
  6274. // if(useWasd) {
  6275. // if (!autos.stopspin) {
  6276. // setTimeout(()=>{
  6277. // autos.stopspin = true;
  6278. // }, 375);
  6279. // }
  6280. // }
  6281. } else {
  6282. my.reloaded = false;
  6283. if(useWasd) {
  6284. autos.stopspin = false;
  6285. }
  6286. if (player.reloads[player.weapons[0]] > 0) {
  6287. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6288. selectWeapon(player.weapons[0]);
  6289. }
  6290. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6291. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6292. selectWeapon(player.weapons[1]);
  6293. }
  6294. if(useWasd) {
  6295. if (!autos.stopspin) {
  6296. setTimeout(()=>{
  6297. autos.stopspin = true;
  6298. }, 750);
  6299. }
  6300. }
  6301. }
  6302. }
  6303. }
  6304. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6305. traps.autoPlace();
  6306. }
  6307. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6308. packet("F", getAttackDir());
  6309. }
  6310. let hatChanger = function() {
  6311. if (my.anti0Tick > 0) {
  6312. buyEquip(6, 0);
  6313. } else {
  6314. if (clicks.left || clicks.right) {
  6315. if (clicks.left) {
  6316. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6317. } else if (clicks.right) {
  6318. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6319. }
  6320. } else if (traps.inTrap) {
  6321. // let zpikez = liztobj.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  6322. // return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6323. // })[0];
  6324. // if (near.dist3 <= 300 && traps.info.health <= 300) {
  6325. // if (!zpikez.length)
  6326. // buyEquip(6, 0);
  6327. // else if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0))
  6328. // buyEquip(40, 0);
  6329. // } else if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)) {
  6330. // buyEquip(40, 0);
  6331. // } else {
  6332. // buyEquip((player.empAnti) ? 22 : 6, 0);
  6333. // }
  6334. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6335. if (near.dist3 <= 300 && traps.info.health <= 300 && items.weapons[near.weapons[0]] == 0) {
  6336. buyEquip(6, 0);
  6337. } else {
  6338. buyEquip(40, 0);
  6339. }
  6340. } else {
  6341. buyEquip(6, 0);
  6342. }
  6343. } else {
  6344. if (player.empAnti) {
  6345. buyEquip(player.empAnti ? 22 : 6, 0);
  6346. } else {
  6347. buyEquip(6, 0);
  6348. }
  6349. }
  6350. }
  6351. }
  6352. let accChanger = function() {
  6353. if(near.dist2 <= 300){
  6354. buyEquip(0, 1);
  6355. }
  6356. else if(clicks.left){
  6357. buyEquip(0, 1);
  6358. }
  6359. else {
  6360. buyEquip(11, 1);
  6361. }
  6362. }
  6363. let wasdGears = function() {
  6364. if (my.anti0Tick > 0) {
  6365. buyEquip(6, 0);
  6366. } else {
  6367. if (clicks.left || clicks.right) {
  6368. if (clicks.left) {
  6369. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  6370. } else if (clicks.right) {
  6371. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  6372. }
  6373. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  6374. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  6375. } else if (traps.inTrap) {
  6376. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6377. buyEquip(40, 0);
  6378. } else {
  6379. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6380. buyEquip(7, 0);
  6381. } else {
  6382. buyEquip(player.empAnti ? 22 : 6, 0);
  6383. }
  6384. }
  6385. } else {
  6386. if (player.empAnti) {
  6387. buyEquip(22, 0);
  6388. } else {
  6389. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6390. buyEquip(7, 0);
  6391. } else {
  6392. buyEquip(6, 0);
  6393. }
  6394. }
  6395. }
  6396. }
  6397. if (clicks.left || clicks.right) {
  6398. if (clicks.left) {
  6399. buyEquip(0, 1);
  6400. }
  6401. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  6402. buyEquip(0, 1);
  6403. } else if (traps.inTrap) {
  6404. buyEquip(0, 1);
  6405. } else {
  6406. buyEquip(11, 1);
  6407. }
  6408. }
  6409. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  6410. if (useWasd) {
  6411. wasdGears();
  6412. } else {
  6413. hatChanger();
  6414. accChanger();
  6415. }
  6416. }
  6417. //lastMoveDir = getSafeDir();
  6418. //packet("9", lastMoveDir, 1);
  6419. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  6420. autoPush();
  6421. } else {
  6422. if (my.autoPush) {
  6423. my.autoPush = false;
  6424. packet("9", lastMoveDir || undefined, 1);
  6425. }
  6426. }
  6427. if (instaC.ticking) {
  6428. instaC.ticking = false;
  6429. }
  6430. if (instaC.syncHit) {
  6431. instaC.syncHit = false;
  6432. }
  6433. if (player.empAnti) {
  6434. player.empAnti = false;
  6435. }
  6436. if (player.soldierAnti) {
  6437. player.soldierAnti = false;
  6438. }
  6439. if (my.anti0Tick > 0) {
  6440. my.anti0Tick--;
  6441. }
  6442. if (traps.replaced) {
  6443. traps.replaced = false;
  6444. }
  6445. if (traps.antiTrapped) {
  6446. traps.antiTrapped = false;
  6447. }
  6448. const getPotentialDamage = (build, user) => {
  6449. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  6450. const weap = user.weapons[weapIndex];
  6451. if (player.reloads[weap]) return 0;
  6452. const weapon = items.weapons[weap];
  6453. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  6454. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  6455. };
  6456. const AutoReplace = () => {
  6457. const replaceable = [];
  6458. const playerX = player.x;
  6459. const playerY = player.y;
  6460. const gameObjectCount = gameObjects.length;
  6461. for (let i = 0; i < gameObjectCount; i++) {
  6462. const build = gameObjects[i];
  6463. if (build.isItem && build.active && build.health > 0) {
  6464. const item = items.list[build.id];
  6465. const posDist = 35 + item.scale + (item.placeOffset || 0);
  6466. const inDistance = cdf(build, player) <= posDist * 2;
  6467. if (inDistance) {
  6468. let canDeal = 0;
  6469. const playersCount = players.length;
  6470. for (let j = 0; j < playersCount; j++) {
  6471. canDeal += getPotentialDamage(build, players[j]);
  6472. }
  6473. if (build.health <= canDeal) {
  6474. replaceable.push(build);
  6475. }
  6476. }
  6477. }
  6478. }
  6479. const findPlacementAngle = (player, itemId, build) => {
  6480. if (!build) return null;
  6481. const MAX_ANGLE = 2 * Math.PI;
  6482. const ANGLE_STEP = Math.PI / 360;
  6483. const item = items.list[player.items[itemId]];
  6484. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  6485. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  6486. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  6487. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  6488. for (let angle of angles) {
  6489. return angle;
  6490. }
  6491. }
  6492. return null;
  6493. };
  6494. const replace = (() => {
  6495. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  6496. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  6497. const buildId = spike ? 4 : 2;
  6498. replaceable.forEach(build => {
  6499. let angle = findPlacementAngle(player, buildId, build);
  6500. if (angle !== null) {
  6501. place(buildId, angle);
  6502. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  6503. }
  6504. });
  6505. });
  6506. if (near && near.dist3 <= 360) {
  6507. replace();
  6508. }
  6509. replace;
  6510. }
  6511. }
  6512. }
  6513. if (botSkts.length) {
  6514. botSkts.forEach((bots) => {
  6515. if (true) {
  6516. bots[0].showName = 'YEAHHH';
  6517. }
  6518. });
  6519. }
  6520. }
  6521. for(var i1 = 0; i1 < liztobj.length; i1++) {
  6522. 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)
  6523. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  6524. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  6525. selectWeapon(player.weapons[1])
  6526. buyEquip(40, 0);
  6527. packet("F", UTILS.getDirect(liztobj[i1], player, 0, 2))
  6528. setTickout( () => {
  6529. buyEquip(6, 0)
  6530. }, 1);
  6531. }
  6532. }
  6533. }
  6534. }
  6535. function ez(context, x, y) {
  6536. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  6537. context.beginPath();
  6538. context.arc(x, y, 55, 0, Math.PI * 2);
  6539. context.fill();
  6540. context.closePath();
  6541. context.globalAlpha = 1;
  6542. }
  6543. // UPDATE LEADERBOARD:
  6544. function updateLeaderboard(data) {
  6545. lastLeaderboardData = data;
  6546. return;
  6547. UTILS.removeAllChildren(leaderboardData);
  6548. let tmpC = 1;
  6549. for (let i = 0; i < data.length; i += 3) {
  6550. (function(i) {
  6551. UTILS.generateElement({
  6552. class: "leaderHolder",
  6553. parent: leaderboardData,
  6554. children: [
  6555. UTILS.generateElement({
  6556. class: "leaderboardItem",
  6557. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  6558. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  6559. }),
  6560. UTILS.generateElement({
  6561. class: "leaderScore",
  6562. text: UTILS.sFormat(data[i + 2]) || "0"
  6563. })
  6564. ]
  6565. });
  6566. })(i);
  6567. tmpC++;
  6568. }
  6569. }
  6570. // LOAD GAME OBJECT:
  6571. function loadGameObject(data) {
  6572. for (let i = 0; i < data.length;) {
  6573. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  6574. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  6575. sid: data[i + 7]
  6576. } : null));
  6577. // sid, x, y, dir, s, type, data, setSID, owner
  6578. /*let dist = UTILS.getDist({
  6579. x: data[i + 1],
  6580. y: data[i + 2]
  6581. }, player, 0, 2);
  6582. let aim = UTILS.getDirect({
  6583. x: data[i + 1],
  6584. y: data[i + 2]
  6585. }, player, 0, 2);
  6586. find = findObjectBySid(data[i]);
  6587. if (data[i + 6] == 15) {
  6588. if (find && !find.isTeamObject(player)) {
  6589. if (dist <= 100) {
  6590. traps.dist = dist;
  6591. traps.aim = aim;
  6592. traps.protect(aim);
  6593. }
  6594. }
  6595. }*/
  6596. i += 8;
  6597. }
  6598. }
  6599. // ADD AI:
  6600. function loadAI(data) {
  6601. for (let i = 0; i < ais.length; ++i) {
  6602. ais[i].forcePos = !ais[i].visible;
  6603. ais[i].visible = false;
  6604. }
  6605. if (data) {
  6606. let tmpTime = performance.now();
  6607. for (let i = 0; i < data.length;) {
  6608. tmpObj = findAIBySID(data[i]);
  6609. if (tmpObj) {
  6610. tmpObj.index = data[i + 1];
  6611. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  6612. tmpObj.t2 = tmpTime;
  6613. tmpObj.x1 = tmpObj.x;
  6614. tmpObj.y1 = tmpObj.y;
  6615. tmpObj.x2 = data[i + 2];
  6616. tmpObj.y2 = data[i + 3];
  6617. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  6618. tmpObj.d2 = data[i + 4];
  6619. tmpObj.health = data[i + 5];
  6620. tmpObj.dt = 0;
  6621. tmpObj.visible = true;
  6622. } else {
  6623. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  6624. tmpObj.x2 = tmpObj.x;
  6625. tmpObj.y2 = tmpObj.y;
  6626. tmpObj.d2 = tmpObj.dir;
  6627. tmpObj.health = data[i + 5];
  6628. if (!aiManager.aiTypes[data[i + 1]].name)
  6629. tmpObj.name = config.cowNames[data[i + 6]];
  6630. tmpObj.forcePos = true;
  6631. tmpObj.sid = data[i];
  6632. tmpObj.visible = true;
  6633. }
  6634. i += 7;
  6635. }
  6636. }
  6637. }
  6638. // ANIMATE AI:
  6639. function animateAI(sid) {
  6640. tmpObj = findAIBySID(sid);
  6641. if (tmpObj) tmpObj.startAnim();
  6642. }
  6643. // GATHER ANIMATION:
  6644. function gatherAnimation(sid, didHit, index) {
  6645. tmpObj = findPlayerBySID(sid);
  6646. if (tmpObj) {
  6647. tmpObj.startAnim(didHit, index);
  6648. tmpObj.gatherIndex = index;
  6649. tmpObj.gathering = 1;
  6650. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  6651. // healer();
  6652. if (didHit) {
  6653. let tmpObjects = objectManager.hitObj;
  6654. objectManager.hitObj = [];
  6655. game.tickBase(() => {
  6656. // refind
  6657. tmpObj = findPlayerBySID(sid);
  6658. 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);
  6659. tmpObjects.forEach((healthy) => {
  6660. healthy.health -= val;
  6661. });
  6662. }, 1);
  6663. }
  6664. }
  6665. }
  6666. // WIGGLE GAME OBJECT:
  6667. function wiggleGameObject(dir, sid) {
  6668. tmpObj = findObjectBySid(sid);
  6669. if (tmpObj) {
  6670. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  6671. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  6672. if (tmpObj.health) {
  6673. objectManager.hitObj.push(tmpObj);
  6674. }
  6675. }
  6676. }
  6677. // SHOOT TURRET:
  6678. function shootTurret(sid, dir) {
  6679. tmpObj = findObjectBySid(sid);
  6680. if (tmpObj) {
  6681. if (config.anotherVisual) {
  6682. tmpObj.lastDir = dir;
  6683. } else {
  6684. tmpObj.dir = dir;
  6685. }
  6686. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  6687. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  6688. }
  6689. }
  6690. // UPDATE PLAYER VALUE:
  6691. function updatePlayerValue(index, value, updateView) {
  6692. if (player) {
  6693. player[index] = value;
  6694. if (index == "points") {
  6695. if (configs.autoBuy) {
  6696. autoBuy.hat();
  6697. autoBuy.acc();
  6698. }
  6699. } else if (index == "kills") {
  6700. // Woah Credits To Zod324Myers https://www.youtube.com/@Zod324myers
  6701. if (configs.killChat) {
  6702. sendChat("Dumbasses Down: " + value);
  6703. setTimeout(() => {
  6704. sendChat("I am super pro!");
  6705. }, 600);
  6706. }
  6707. }
  6708. }
  6709. }
  6710. // ACTION BAR:
  6711. function updateItems(data, wpn) {
  6712. if (data) {
  6713. if (wpn) {
  6714. player.weapons = data;
  6715. player.primaryIndex = player.weapons[0];
  6716. player.secondaryIndex = player.weapons[1];
  6717. if (!instaC.isTrue) {
  6718. selectWeapon(player.weapons[0]);
  6719. }
  6720. } else {
  6721. player.items = data;
  6722. }
  6723. }
  6724. for (let i = 0; i < items.list.length; i++) {
  6725. let tmpI = items.weapons.length + i;
  6726. let actionBarItem = getEl("actionBarItem" + tmpI);
  6727. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  6728. // Add shadow to the element
  6729. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  6730. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  6731. }
  6732. for (let i = 0; i < items.weapons.length; i++) {
  6733. let actionBarItem = getEl("actionBarItem" + i);
  6734. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  6735. // Add shadow to the element
  6736. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  6737. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  6738. }
  6739. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  6740. if (kms) {
  6741. getEl("actionBarItem3").style.display = "none";
  6742. getEl("actionBarItem4").style.display = "inline-block";
  6743. }
  6744. }
  6745. // ADD PROJECTILE:
  6746. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  6747. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  6748. runAtNextTick.push(Array.prototype.slice.call(arguments));
  6749. }
  6750. // REMOVE PROJECTILE:
  6751. function remProjectile(sid, range) {
  6752. for (let i = 0; i < projectiles.length; ++i) {
  6753. if (projectiles[i].sid == sid) {
  6754. projectiles[i].range = range;
  6755. let tmpObjects = objectManager.hitObj;
  6756. objectManager.hitObj = [];
  6757. game.tickBase(() => {
  6758. let val = projectiles[i].dmg;
  6759. tmpObjects.forEach((healthy) => {
  6760. if (healthy.projDmg) {
  6761. healthy.health -= val;
  6762. }
  6763. });
  6764. }, 1);
  6765. }
  6766. }
  6767. }
  6768. // lol this useless,,, fr
  6769. let noob = false;
  6770. let serverReady = true;
  6771. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  6772. let wssws = isProd ? "wss" : "ws";
  6773. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  6774. let withSync = false;
  6775. project.binaryType = "arraybuffer";
  6776. project.onmessage = function(msg) {
  6777. let data = msg.data;
  6778. if (data == "isready") {
  6779. serverReady = true;
  6780. }
  6781. if (data == "fine") {
  6782. noob = false;
  6783. }
  6784. if (data == "tezt") {
  6785. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  6786. }
  6787. if (data == "yeswearesyncer") {
  6788. // let delay = Date.now() - wsDelay;
  6789. withSync = true;
  6790. if (player) {
  6791. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  6792. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  6793. }
  6794. }
  6795. };
  6796. project.onopen = function() {
  6797. var gameTitle = getEl("gameName");
  6798. gameTitle.innerText = "DiaMonD HAckErs";
  6799. };
  6800. // SHOW ALLIANCE MENU:
  6801. function allianceNotification(sid, name) {
  6802. let findBotSID = findSID(bots, sid);
  6803. if (findBotSID) {}
  6804. }
  6805. function setPlayerTeam(team, isOwner) {
  6806. if (player) {
  6807. player.team = team;
  6808. player.isOwner = isOwner;
  6809. if (team == null)
  6810. alliancePlayers = [];
  6811. }
  6812. }
  6813. function setAlliancePlayers(data) {
  6814. alliancePlayers = data;
  6815. }
  6816. // STORE MENU:
  6817. function updateStoreItems(type, id, index) {
  6818. if (index) {
  6819. if (!type)
  6820. player.tails[id] = 1;
  6821. else {
  6822. player.latestTail = id;
  6823. }
  6824. } else {
  6825. if (!type)
  6826. player.skins[id] = 1,
  6827. id == 7 && (my.reSync = true); // testing perfect bulltick...
  6828. else {
  6829. player.latestSkin = id;
  6830. }
  6831. }
  6832. }
  6833. // SEND MESSAGE:
  6834. function receiveChat(sid, message) {
  6835. let kawaii = false;
  6836. let tmpPlayer = findPlayerBySID(sid);
  6837. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  6838. tmpPlayer.chatMessage = message;
  6839. tmpPlayer.chatCountdown = config.chatCountdown;
  6840. }
  6841. // MINIMAP:
  6842. function updateMinimap(data) {
  6843. minimapData = data;
  6844. }
  6845. // SHOW ANIM TEXT:
  6846. function showText(x, y, value, type) {
  6847. // if (config.anotherVisual) {
  6848. textManager.stack.push({
  6849. x: x,
  6850. y: y,
  6851. value: value
  6852. });
  6853. // } else {
  6854. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  6855. // }
  6856. }
  6857. /** APPLY SOCKET CODES */
  6858. // BOT:
  6859. let bots = [];
  6860. let ranLocation = {
  6861. x: UTILS.randInt(35, 14365),
  6862. y: UTILS.randInt(35, 14365)
  6863. };
  6864. setInterval(() => {
  6865. ranLocation = {
  6866. x: UTILS.randInt(35, 14365),
  6867. y: UTILS.randInt(35, 14365)
  6868. };
  6869. }, 60000);
  6870. class Bot {
  6871. constructor(id, sid, hats, accessories) {
  6872. this.millPlace = true;
  6873. this.id = id;
  6874. this.sid = sid;
  6875. this.team = null;
  6876. this.skinIndex = 0;
  6877. this.tailIndex = 0;
  6878. this.hitTime = 0;
  6879. this.iconIndex = 0;
  6880. this.enemy = [];
  6881. this.near = [];
  6882. this.dist2 = 0;
  6883. this.aim2 = 0;
  6884. this.tick = 0;
  6885. this.itemCounts = {};
  6886. this.latestSkin = 0;
  6887. this.latestTail = 0;
  6888. this.points = 0;
  6889. this.tails = {};
  6890. for (let i = 0; i < accessories.length; ++i) {
  6891. if (accessories[i].price <= 0)
  6892. this.tails[accessories[i].id] = 1;
  6893. }
  6894. this.skins = {};
  6895. for (let i = 0; i < hats.length; ++i) {
  6896. if (hats[i].price <= 0)
  6897. this.skins[hats[i].id] = 1;
  6898. }
  6899. this.spawn = function(moofoll) {
  6900. this.upgraded = 0;
  6901. this.enemy = [];
  6902. this.near = [];
  6903. this.active = true;
  6904. this.alive = true;
  6905. this.lockMove = false;
  6906. this.lockDir = false;
  6907. this.minimapCounter = 0;
  6908. this.chatCountdown = 0;
  6909. this.shameCount = 0;
  6910. this.shameTimer = 0;
  6911. this.sentTo = {};
  6912. this.gathering = 0;
  6913. this.autoGather = 0;
  6914. this.animTime = 0;
  6915. this.animSpeed = 0;
  6916. this.mouseState = 0;
  6917. this.buildIndex = -1;
  6918. this.weaponIndex = 0;
  6919. this.dmgOverTime = {};
  6920. this.noMovTimer = 0;
  6921. this.maxXP = 300;
  6922. this.XP = 0;
  6923. this.age = 1;
  6924. this.kills = 0;
  6925. this.upgrAge = 2;
  6926. this.upgradePoints = 0;
  6927. this.x = 0;
  6928. this.y = 0;
  6929. this.zIndex = 0;
  6930. this.xVel = 0;
  6931. this.yVel = 0;
  6932. this.slowMult = 1;
  6933. this.dir = 0;
  6934. this.nDir = 0;
  6935. this.dirPlus = 0;
  6936. this.targetDir = 0;
  6937. this.targetAngle = 0;
  6938. this.maxHealth = 100;
  6939. this.health = this.maxHealth;
  6940. this.oldHealth = this.maxHealth;
  6941. this.scale = config.playerScale;
  6942. this.speed = config.playerSpeed;
  6943. this.resetMoveDir();
  6944. this.resetResources(moofoll);
  6945. this.items = [0, 3, 6, 10];
  6946. this.weapons = [0];
  6947. this.shootCount = 0;
  6948. this.weaponXP = [];
  6949. this.isBot = false;
  6950. this.reloads = {
  6951. 0: 0,
  6952. 1: 0,
  6953. 2: 0,
  6954. 3: 0,
  6955. 4: 0,
  6956. 5: 0,
  6957. 6: 0,
  6958. 7: 0,
  6959. 8: 0,
  6960. 9: 0,
  6961. 10: 0,
  6962. 11: 0,
  6963. 12: 0,
  6964. 13: 0,
  6965. 14: 0,
  6966. 15: 0,
  6967. 53: 0,
  6968. };
  6969. this.timeZinceZpawn = 0;
  6970. this.whyDie = "";
  6971. this.clearRadius = false;
  6972. this.circlee = 0;
  6973. };
  6974. // RESET MOVE DIR:
  6975. this.resetMoveDir = function() {
  6976. this.moveDir = undefined;
  6977. };
  6978. // RESET RESOURCES:
  6979. this.resetResources = function(moofoll) {
  6980. for (let i = 0; i < config.resourceTypes.length; ++i) {
  6981. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  6982. }
  6983. };
  6984. // SET DATA:
  6985. this.setData = function(data) {
  6986. this.id = data[0];
  6987. this.sid = data[1];
  6988. this.name = data[2];
  6989. this.x = data[3];
  6990. this.y = data[4];
  6991. this.dir = data[5];
  6992. this.health = data[6];
  6993. this.maxHealth = data[7];
  6994. this.scale = data[8];
  6995. this.skinColor = data[9];
  6996. };
  6997. // SHAME SYSTEM:
  6998. this.judgeShame = function() {
  6999. if (this.oldHealth < this.health) {
  7000. if (this.hitTime) {
  7001. let timeSinceHit = this.tick - this.hitTime;
  7002. this.hitTime = 0;
  7003. if (timeSinceHit < 2) {
  7004. this.lastshamecount = this.shameCount;
  7005. this.shameCount++;
  7006. } else {
  7007. this.lastshamecount = this.shameCount;
  7008. this.shameCount = Math.max(0, this.shameCount - 2);
  7009. }
  7010. }
  7011. } else if (this.oldHealth > this.health) {
  7012. this.hitTime = this.tick;
  7013. }
  7014. };
  7015. // UPDATE WEAPON RELOAD:
  7016. this.manageReloadaa = function() {
  7017. if (this.shooting[53]) {
  7018. this.shooting[53] = 0;
  7019. this.reloads[53] = (2500 - 1000/9);
  7020. } else {
  7021. if (this.reloads[53] > 0) {
  7022. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7023. }
  7024. }
  7025. if (this.gathering || this.shooting[1]) {
  7026. if (this.gathering) {
  7027. this.gathering = 0;
  7028. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7029. this.attacked = true;
  7030. }
  7031. if (this.shooting[1]) {
  7032. this.shooting[1] = 0;
  7033. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7034. this.attacked = true;
  7035. }
  7036. } else {
  7037. this.attacked = false;
  7038. if (this.buildIndex < 0) {
  7039. if (this.reloads[this.weaponIndex] > 0) {
  7040. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7041. }
  7042. }
  7043. }
  7044. };
  7045. this.closeSockets = function(websc) {
  7046. websc.close();
  7047. };
  7048. this.whyDieChat = function(websc, whydie) {
  7049. websc.sendWS("6", "don't die " + whydie);
  7050. };
  7051. }
  7052. };
  7053. class BotObject {
  7054. constructor(sid) {
  7055. this.sid = sid;
  7056. // INIT:
  7057. this.init = function(x, y, dir, scale, type, data, owner) {
  7058. data = data || {};
  7059. this.active = true;
  7060. this.x = x;
  7061. this.y = y;
  7062. this.scale = scale;
  7063. this.owner = owner;
  7064. this.id = data.id;
  7065. this.dmg = data.dmg;
  7066. this.trap = data.trap;
  7067. this.teleport = data.teleport;
  7068. this.isItem = this.id != undefined;
  7069. };
  7070. }
  7071. };
  7072. class BotObjManager {
  7073. constructor(botObj, fOS) {
  7074. // DISABLE OBJ:
  7075. this.disableObj = function(obj) {
  7076. obj.active = false;
  7077. if (config.anotherVisual) {} else {
  7078. obj.alive = false;
  7079. }
  7080. };
  7081. // ADD NEW:
  7082. let tmpObj;
  7083. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7084. tmpObj = fOS(sid);
  7085. if (!tmpObj) {
  7086. tmpObj = botObj.find((tmp) => !tmp.active);
  7087. if (!tmpObj) {
  7088. tmpObj = new BotObject(sid);
  7089. botObj.push(tmpObj);
  7090. }
  7091. }
  7092. if (setSID) {
  7093. tmpObj.sid = sid;
  7094. }
  7095. tmpObj.init(x, y, dir, s, type, data, owner);
  7096. };
  7097. // DISABLE BY SID:
  7098. this.disableBySid = function(sid) {
  7099. let find = fOS(sid);
  7100. if (find) {
  7101. this.disableObj(find);
  7102. }
  7103. };
  7104. // REMOVE ALL FROM PLAYER:
  7105. this.removeAllItems = function(sid, server) {
  7106. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7107. };
  7108. }
  7109. };
  7110. let botz = [];
  7111. function botSpawn(id) {
  7112. let bot;
  7113. console.log(WS);
  7114. let t = WS.url.split("wss://")[1].split("?")[0];
  7115. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7116. let botPlayer = new Map();
  7117. botSkts.push([botPlayer]);
  7118. botz.push([bot]);
  7119. let botSID;
  7120. let botObj = [];
  7121. let nearObj = [];
  7122. let bD = {
  7123. x: 0,
  7124. y: 0,
  7125. inGame: false,
  7126. closeSocket: false,
  7127. whyDie: ""
  7128. };
  7129. let oldXY = {
  7130. x: 0,
  7131. y: 0,
  7132. };
  7133. let izauto = 0;
  7134. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7135. bot.binaryType = "arraybuffer";
  7136. bot.first = true;
  7137. bot.sendWS = function(type) {
  7138. // EXTRACT DATA ARRAY:
  7139. let data = Array.prototype.slice.call(arguments, 1);
  7140. // SEND MESSAGE:
  7141. let binary = window.msgpack.encode([type, data]);
  7142. bot.send(binary);
  7143. };
  7144. bot.spawn = function() {
  7145. bot.sendWS("M", {
  7146. name: "unknown1l",
  7147. moofoll: 1,
  7148. skin: "__proto__"
  7149. });
  7150. };
  7151. bot.sendUpgrade = function(index) {
  7152. bot.sendWS("H", index);
  7153. };
  7154. bot.place = function(id, a) {
  7155. try {
  7156. let item = items.list[botPlayer.items[id]];
  7157. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7158. bot.sendWS("G", botPlayer.items[id]);
  7159. bot.sendWS("d", 1, a);
  7160. bot.sendWS("G", botPlayer.weaponIndex, true);
  7161. }
  7162. } catch (e) {
  7163. }
  7164. };
  7165. bot.buye = function(id, index) {
  7166. let nID = 0;
  7167. if (botPlayer.alive && botPlayer.inGame) {
  7168. if (index == 0) {
  7169. if (botPlayer.skins[id]) {
  7170. if (botPlayer.latestSkin != id) {
  7171. bot.sendWS("c", 0, id, 0);
  7172. }
  7173. } else {
  7174. let find = findID(hats, id);
  7175. if (find) {
  7176. if (botPlayer.points >= find.price) {
  7177. bot.sendWS("c", 1, id, 0);
  7178. bot.sendWS("c", 0, id, 0);
  7179. } else {
  7180. if (botPlayer.latestSkin != nID) {
  7181. bot.sendWS("c", 0, nID, 0);
  7182. }
  7183. }
  7184. } else {
  7185. if (botPlayer.latestSkin != nID) {
  7186. bot.sendWS("c", 0, nID, 0);
  7187. }
  7188. }
  7189. }
  7190. } else if (index == 1) {
  7191. if (botPlayer.tails[id]) {
  7192. if (botPlayer.latestTail != id) {
  7193. bot.sendWS("c", 0, id, 1);
  7194. }
  7195. } else {
  7196. let find = findID(accessories, id);
  7197. if (find) {
  7198. if (botPlayer.points >= find.price) {
  7199. bot.sendWS("c", 1, id, 1);
  7200. bot.sendWS("c", 0, id, 1);
  7201. } else {
  7202. if (botPlayer.latestTail != 0) {
  7203. bot.sendWS("c", 0, 0, 1);
  7204. }
  7205. }
  7206. } else {
  7207. if (botPlayer.latestTail != 0) {
  7208. bot.sendWS("c", 0, 0, 1);
  7209. }
  7210. }
  7211. }
  7212. }
  7213. }
  7214. };
  7215. bot.fastGear = function() {
  7216. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7217. bot.buye(31, 0);
  7218. } else {
  7219. if (botPlayer.y2 <= config.snowBiomeTop) {
  7220. bot.buye(15, 0);
  7221. } else {
  7222. bot.buye(12, 0);
  7223. }
  7224. }
  7225. };
  7226. bot.selectWeapon = function(a) {
  7227. packet("z", a, 1);
  7228. }
  7229. function caf(e, t) {
  7230. try {
  7231. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7232. } catch (e) {
  7233. return 0;
  7234. }
  7235. }
  7236. bot.heal = function() {
  7237. if (botPlayer.health < 100) {
  7238. bot.place(0, 0)
  7239. }
  7240. }
  7241. function cdf (e, t){
  7242. try {
  7243. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  7244. } catch(e){
  7245. return Infinity;
  7246. }
  7247. }
  7248. let zoon = 'no';
  7249. bot.zync = function(a) {
  7250. if (!botPlayer.millPlace) {
  7251. zoon = 'yeah';
  7252. bot.place(5, caf(botPlayer, a));
  7253. let NextTickLocation = {
  7254. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7255. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7256. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7257. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7258. };
  7259. function calculateDistance(x1, y1, x2, y2) {
  7260. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  7261. return distance;
  7262. }
  7263. function dotherezt() {
  7264. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7265. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  7266. }
  7267. let aa = setInterval(() => {
  7268. bot.sendWS("G", botPlayer.weapons[1], true);
  7269. if (izauto == 0) {
  7270. bot.sendWS("K", 1);
  7271. izauto = 1;
  7272. }
  7273. setTimeout(() => {
  7274. bot.sendWS("G", botPlayer.weapons[0], true);
  7275. }, 2000);
  7276. bot.buye(53, 0);
  7277. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  7278. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  7279. } else {
  7280. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7281. zoon = 'no';
  7282. bot.sendWS("a", undefined);
  7283. dotherezt();
  7284. clearInterval(aa);
  7285. }
  7286. }, 150);
  7287. setTimeout(() => {
  7288. zoon = 'no';
  7289. clearInterval(aa);
  7290. }, 500);
  7291. }
  7292. };
  7293. bot.onmessage = function(message) {
  7294. let data = new Uint8Array(message.data);
  7295. let parsed = window.msgpack.decode(data);
  7296. let type = parsed[0];
  7297. data = parsed[1];
  7298. if (type == "io-init") {
  7299. bot.spawn();
  7300. }
  7301. if (type == "1") {
  7302. botSID = data[0];
  7303. console.log(botSID)
  7304. }
  7305. if (type == "D") {
  7306. if (data[1]) {
  7307. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  7308. botPlayer.setData(data[0]);
  7309. botPlayer.inGame = true;
  7310. botPlayer.alive = true;
  7311. botPlayer.x2 = undefined;
  7312. botPlayer.y2 = undefined;
  7313. botPlayer.spawn(1);
  7314. botPlayer.oldHealth = 100;
  7315. botPlayer.health = 100;
  7316. botPlayer.showName = 'YEAHHH';
  7317. oldXY = {
  7318. x: data[0][3],
  7319. y: data[0][4]
  7320. }
  7321. bD.inGame = true;
  7322. if (bot.first) {
  7323. bot.first = false;
  7324. bots.push(bD);
  7325. }
  7326. }
  7327. }
  7328. if (type == "P") {
  7329. bot.spawn();
  7330. botPlayer.inGame = false;
  7331. bD.inGame = false;
  7332. }
  7333. if (type == "a") {
  7334. let tmpData = data[0];
  7335. botPlayer.tick++;
  7336. botPlayer.enemy = [];
  7337. botPlayer.near = [];
  7338. bot.showName = 'YEAHHH';
  7339. nearObj = [];
  7340. for (let i = 0; i < tmpData.length;) {
  7341. if (tmpData[i] == botPlayer.sid) {
  7342. botPlayer.x2 = tmpData[i + 1];
  7343. botPlayer.y2 = tmpData[i + 2];
  7344. botPlayer.d2 = tmpData[i + 3];
  7345. botPlayer.buildIndex = tmpData[i + 4];
  7346. botPlayer.weaponIndex = tmpData[i + 5];
  7347. botPlayer.weaponVariant = tmpData[i + 6];
  7348. botPlayer.team = tmpData[i + 7];
  7349. botPlayer.isLeader = tmpData[i + 8];
  7350. botPlayer.skinIndex = tmpData[i + 9];
  7351. botPlayer.tailIndex = tmpData[i + 10];
  7352. botPlayer.iconIndex = tmpData[i + 11];
  7353. botPlayer.zIndex = tmpData[i + 12];
  7354. botPlayer.visible = true;
  7355. bD.x2 = botPlayer.x2;
  7356. bD.y2 = botPlayer.y2;
  7357. }
  7358. i += 13;
  7359. }
  7360. for (let i = 0; i < tmpData.length;) {
  7361. tmpObj = findPlayerBySID(tmpData[i]);
  7362. if (tmpObj) {
  7363. if (!tmpObj.isTeam(botPlayer)) {
  7364. enemy.push(tmpObj);
  7365. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  7366. nears.push(tmpObj);
  7367. }
  7368. }
  7369. }
  7370. i += 13;
  7371. }
  7372. if (enemy.length) {
  7373. //console.log(enemy)
  7374. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  7375. return tmp1.dist2 - tmp2.dist2;
  7376. })[0];
  7377. }
  7378. if (izauto == 1) {
  7379. bot.sendWS("K", 1);
  7380. izauto = 0;
  7381. }
  7382. if (bD.closeSocket) {
  7383. botPlayer.closeSockets(bot);
  7384. }
  7385. if (bD.whyDie != "") {
  7386. botPlayer.whyDieChat(bot, bD.whyDie);
  7387. bD.whyDie = "";
  7388. }
  7389. if (botPlayer.alive) {
  7390. if (player.team) {
  7391. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  7392. botPlayer.team && (bot.sendWS("N"));
  7393. bot.sendWS("b", player.team);
  7394. }
  7395. }
  7396. let item = items.list[botPlayer.items[3]];
  7397. let a = botPlayer.itemCounts[item.group.id]
  7398. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  7399. if (botPlayer.inGame) {
  7400. bot.sendWS("D", botPlayer.moveDir);
  7401. if (izauto == 0) {
  7402. bot.sendWS("K", 1);
  7403. izauto = 1;
  7404. }
  7405. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  7406. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  7407. bot.place(3, aim + 7.7);
  7408. bot.place(3, aim - 7.7);
  7409. bot.place(3, aim);
  7410. oldXY = {
  7411. x: botPlayer.x2,
  7412. y: botPlayer.y2
  7413. };
  7414. }
  7415. if (botPlayer.tick % 90 === 0) {
  7416. let rand = Math.random() * Math.PI * 2;
  7417. botPlayer.moveDir = rand;
  7418. bot.sendWS("a", botPlayer.moveDir);
  7419. }
  7420. }
  7421. bot.fastGear();
  7422. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  7423. botPlayer.millPlace = false;
  7424. // bot.sendWS("K", 1);
  7425. bot.fastGear();
  7426. } else {
  7427. if (botPlayer.inGame) {
  7428. if (botObj.length > 0) {
  7429. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  7430. if (getEl("mode").value == '####emup') {
  7431. // if (getEl("mode").value == "clear") {
  7432. bot.selectWeapon(botPlayer.weapons[1]);
  7433. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  7434. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  7435. 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) {
  7436. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7437. })[0];
  7438. if (nearObj) {
  7439. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  7440. if ((gotoDist - isPassed) > 0) {
  7441. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7442. if (botPlayer.moveDir != undefined) {
  7443. botPlayer.moveDir = undefined;
  7444. bot.sendWS("a", botPlayer.moveDir);
  7445. bot.sendWS("D", botPlayer.nDir);
  7446. }
  7447. } else {
  7448. botPlayer.moveDir = gotoAim;
  7449. bot.sendWS("a", botPlayer.moveDir);
  7450. bot.sendWS("D", botPlayer.nDir);
  7451. }
  7452. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7453. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7454. bot.sendWS("D", botPlayer.nDir);
  7455. }
  7456. if (izauto == 0) {
  7457. bot.sendWS("K", 1);
  7458. izauto = 1;
  7459. }
  7460. bot.buye(40, 0);
  7461. } else {
  7462. botPlayer.moveDir = gotoAim;
  7463. bot.sendWS("a", botPlayer.moveDir);
  7464. bot.sendWS("D", botPlayer.nDir);
  7465. bot.fastGear();
  7466. }
  7467. } else {
  7468. botPlayer.moveDir = gotoAim;
  7469. bot.sendWS("a", botPlayer.moveDir);
  7470. bot.sendWS("D", botPlayer.nDir);
  7471. bot.fastGear();
  7472. }
  7473. }
  7474. }
  7475. if (botObj.length > 0) {
  7476. if (getEl("mode").value == 'flex') {
  7477. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  7478. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  7479. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  7480. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  7481. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  7482. if (dist > 22) // 22 is player speed without booster hat
  7483. return;
  7484. }
  7485. }
  7486. if (botObj.length > 0) {
  7487. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  7488. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7489. })[0];
  7490. if (nearObj) {
  7491. if (izauto == 0) {
  7492. bot.sendWS("K", 1);
  7493. izauto = 1;
  7494. }
  7495. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7496. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7497. bot.sendWS("D", botPlayer.nDir);
  7498. }
  7499. bot.buye(40, 0);
  7500. bot.buye(11, 1);
  7501. } else {
  7502. bot.fastGear();
  7503. bot.buye(11, 1);
  7504. }
  7505. bot.buye(11, 1);
  7506. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  7507. // if (getEl("mode").value == "clear") {
  7508. bot.selectWeapon(botPlayer.weapons[1]);
  7509. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  7510. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  7511. 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) {
  7512. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7513. })[0];
  7514. if (nearObj) {
  7515. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  7516. if ((gotoDist - isPassed) > 0) {
  7517. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7518. if (botPlayer.moveDir != undefined) {
  7519. botPlayer.moveDir = undefined;
  7520. bot.sendWS("a", botPlayer.moveDir);
  7521. bot.sendWS("D", botPlayer.nDir);
  7522. }
  7523. } else {
  7524. botPlayer.moveDir = gotoAim;
  7525. bot.sendWS("a", botPlayer.moveDir);
  7526. bot.sendWS("D", botPlayer.nDir);
  7527. }
  7528. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7529. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7530. bot.sendWS("D", botPlayer.nDir);
  7531. }
  7532. if (izauto == 0) {
  7533. bot.sendWS("K", 1);
  7534. izauto = 1;
  7535. }
  7536. bot.buye(40, 0);
  7537. bot.fastGear();
  7538. } else {
  7539. botPlayer.moveDir = gotoAim;
  7540. bot.sendWS("a", botPlayer.moveDir);
  7541. bot.sendWS("D", botPlayer.nDir);
  7542. bot.fastGear();
  7543. }
  7544. } else {
  7545. botPlayer.moveDir = gotoAim;
  7546. bot.sendWS("a", botPlayer.moveDir);
  7547. bot.sendWS("D", botPlayer.nDir);
  7548. bot.fastGear();
  7549. }
  7550. if (gotoDist > 300) {
  7551. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  7552. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  7553. bot.place(3, aim + 7.7);
  7554. bot.place(3, aim - 7.7);
  7555. bot.place(3, aim);
  7556. oldXY = {
  7557. x: botPlayer.x2,
  7558. y: botPlayer.y2
  7559. };
  7560. }
  7561. }
  7562. }
  7563. }
  7564. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  7565. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  7566. if(!wdaawdwad.length) {
  7567. if(zoon == 'no')
  7568. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  7569. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7570. }
  7571. if(wdaawdwad.length) {
  7572. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  7573. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  7574. 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) {
  7575. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7576. })[0];
  7577. if (nearObj) {
  7578. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  7579. if ((gotoDist - isPassed) > 0) {
  7580. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7581. if (botPlayer.moveDir != undefined) {
  7582. botPlayer.moveDir = undefined;
  7583. bot.sendWS("a", botPlayer.moveDir);
  7584. bot.sendWS("D", botPlayer.nDir);
  7585. }
  7586. } else {
  7587. bot.sendWS("D", botPlayer.nDir);
  7588. }
  7589. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7590. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7591. bot.sendWS("D", botPlayer.nDir);
  7592. }
  7593. if (izauto == 0) {
  7594. bot.sendWS("K", 1);
  7595. izauto = 1;
  7596. }
  7597. bot.buye(40, 0);
  7598. bot.fastGear();
  7599. } else {
  7600. if(zoon == 'no')
  7601. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  7602. if(cdf(player, botPlayer) <= 110)
  7603. bot.sendWS("a", undefined);
  7604. else
  7605. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7606. }
  7607. } else {
  7608. if(wdaawdwad.length) {
  7609. if(zoon == 'no')
  7610. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  7611. if(cdf(player, botPlayer) <= 110)
  7612. bot.sendWS("a", undefined);
  7613. else
  7614. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7615. } else {
  7616. if(zoon == 'no')
  7617. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  7618. if(cdf(player, botPlayer) <= 110)
  7619. bot.sendWS("a", undefined);
  7620. else
  7621. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7622. }
  7623. }
  7624. }
  7625. }
  7626. }
  7627. }
  7628. }
  7629. }
  7630. if (type == "H") {
  7631. let tmpData = data[0];
  7632. for (let i = 0; i < tmpData.length;) {
  7633. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  7634. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  7635. sid: tmpData[i + 7]
  7636. } : null));
  7637. i += 8;
  7638. }
  7639. }
  7640. if (type == "N") {
  7641. let index = data[0];
  7642. let value = data[1];
  7643. if (botPlayer) {
  7644. botPlayer[index] = value;
  7645. }
  7646. }
  7647. if (type == "O") {
  7648. if (data[0] == botPlayer.sid) {
  7649. botPlayer.oldHealth = botPlayer.health;
  7650. botPlayer.health = data[1];
  7651. botPlayer.judgeShame();
  7652. if (botPlayer.oldHealth > botPlayer.health) {
  7653. if (botPlayer.shameCount < 5) {
  7654. for (let i = 0; i < 2; i++) {
  7655. bot.place(0, botPlayer.nDir);
  7656. }
  7657. } else {
  7658. setTimeout(() => {
  7659. for (let i = 0; i < 2; i++) {
  7660. bot.place(0, botPlayer.nDir);
  7661. }
  7662. }, 95);
  7663. }
  7664. }
  7665. }
  7666. }
  7667. if (type == "Q") {
  7668. let sid = data[0];
  7669. botObjManager.disableBySid(sid);
  7670. }
  7671. if (type == "R") {
  7672. let sid = data[0];
  7673. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  7674. }
  7675. if (type == "S") {
  7676. let index = data[0];
  7677. let value = data[1];
  7678. if (botPlayer) {
  7679. botPlayer.itemCounts[index] = value;
  7680. }
  7681. }
  7682. if (type == "U") {
  7683. if (data[0] > 0) {
  7684. if(getEl("setup").value == 'dm') {
  7685. if (botPlayer.upgraded == 0) {
  7686. bot.sendUpgrade(7);
  7687. } else if (botPlayer.upgraded == 1) {
  7688. bot.sendUpgrade(17);
  7689. } else if (botPlayer.upgraded == 2) {
  7690. bot.sendUpgrade(31);
  7691. } else if (botPlayer.upgraded == 3) {
  7692. bot.sendUpgrade(23);
  7693. } else if (botPlayer.upgraded == 4) {
  7694. bot.sendUpgrade(9);
  7695. } else if (botPlayer.upgraded == 5) {
  7696. bot.sendUpgrade(34);
  7697. } else if (botPlayer.upgraded == 6) {
  7698. bot.sendUpgrade(12);
  7699. } else if (botPlayer.upgraded == 7) {
  7700. bot.sendUpgrade(15);
  7701. }
  7702. } else if(getEl("setup").value == 'dr') {
  7703. if (botPlayer.upgraded == 0) {
  7704. bot.sendUpgrade(7);
  7705. } else if (botPlayer.upgraded == 1) {
  7706. bot.sendUpgrade(17);
  7707. } else if (botPlayer.upgraded == 2) {
  7708. bot.sendUpgrade(31);
  7709. } else if (botPlayer.upgraded == 3) {
  7710. bot.sendUpgrade(23);
  7711. } else if (botPlayer.upgraded == 4) {
  7712. bot.sendUpgrade(9);
  7713. } else if (botPlayer.upgraded == 5) {
  7714. bot.sendUpgrade(34);
  7715. } else if (botPlayer.upgraded == 6) {
  7716. bot.sendUpgrade(12);
  7717. } else if (botPlayer.upgraded == 7) {
  7718. bot.sendUpgrade(13);
  7719. }
  7720. } else if(getEl("setup").value == 'kh') {
  7721. if (botPlayer.upgraded == 0) {
  7722. bot.sendUpgrade(3);
  7723. } else if (botPlayer.upgraded == 1) {
  7724. bot.sendUpgrade(17);
  7725. } else if (botPlayer.upgraded == 2) {
  7726. bot.sendUpgrade(31);
  7727. } else if (botPlayer.upgraded == 3) {
  7728. bot.sendUpgrade(27);
  7729. } else if (botPlayer.upgraded == 4) {
  7730. bot.sendUpgrade(10);
  7731. } else if (botPlayer.upgraded == 5) {
  7732. bot.sendUpgrade(34);
  7733. } else if (botPlayer.upgraded == 6) {
  7734. bot.sendUpgrade(4);
  7735. } else if (botPlayer.upgraded == 7) {
  7736. bot.sendUpgrade(25);
  7737. }
  7738. } else if(getEl("setup").value == 'zd') {
  7739. if (botPlayer.upgraded == 0) {
  7740. bot.sendUpgrade(3);
  7741. } else if (botPlayer.upgraded == 1) {
  7742. bot.sendUpgrade(17);
  7743. } else if (botPlayer.upgraded == 2) {
  7744. bot.sendUpgrade(31);
  7745. } else if (botPlayer.upgraded == 3) {
  7746. bot.sendUpgrade(27);
  7747. } else if (botPlayer.upgraded == 4) {
  7748. bot.sendUpgrade(9);
  7749. } else if (botPlayer.upgraded == 5) {
  7750. bot.sendUpgrade(34);
  7751. } else if (botPlayer.upgraded == 6) {
  7752. bot.sendUpgrade(12);
  7753. } else if (botPlayer.upgraded == 7) {
  7754. bot.sendUpgrade(15);
  7755. }
  7756. }
  7757. botPlayer.upgraded++;
  7758. }
  7759. }
  7760. if (type == "V") {
  7761. let tmpData = data[0];
  7762. let wpn = data[1];
  7763. if (tmpData) {
  7764. if (wpn) botPlayer.weapons = tmpData;
  7765. else botPlayer.items = tmpData;
  7766. }
  7767. }
  7768. if (type == "5") {
  7769. let type = data[0];
  7770. let id = data[1];
  7771. let index = data[2];
  7772. if (index) {
  7773. if (!type)
  7774. botPlayer.tails[id] = 1;
  7775. else
  7776. botPlayer.latestTail = id;
  7777. } else {
  7778. if (!type)
  7779. botPlayer.skins[id] = 1;
  7780. else
  7781. botPlayer.latestSkin = id;
  7782. }
  7783. }
  7784. if (type == "6") {
  7785. let id = data[0];
  7786. let mzg = data[1]+'';
  7787. if(id == player.sid && mzg.includes("get synced")) {
  7788. bot.zync(botPlayer.near);
  7789. }
  7790. }
  7791. };
  7792. bot.onclose = function() {
  7793. botPlayer.inGame = false;
  7794. bD.inGame = false;
  7795. };
  7796. }
  7797. // RENDER LEAF:
  7798. function renderLeaf(x, y, l, r, ctxt) {
  7799. let endX = x + (l * Math.cos(r));
  7800. let endY = y + (l * Math.sin(r));
  7801. let width = l * 0.4;
  7802. ctxt.moveTo(x, y);
  7803. ctxt.beginPath();
  7804. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  7805. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  7806. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  7807. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  7808. ctxt.closePath();
  7809. ctxt.fill();
  7810. ctxt.stroke();
  7811. }
  7812. // RENDER CIRCLE:
  7813. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  7814. tmpContext = tmpContext || mainContext;
  7815. tmpContext.beginPath();
  7816. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  7817. if (!dontFill) tmpContext.fill();
  7818. if (!dontStroke) tmpContext.stroke();
  7819. }
  7820. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  7821. tmpContext = tmpContext || mainContext;
  7822. tmpContext.beginPath();
  7823. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  7824. if (!dontFill) tmpContext.fill();
  7825. if (!dontStroke) tmpContext.stroke();
  7826. }
  7827. // RENDER STAR SHAPE:
  7828. function renderStar(ctxt, spikes, outer, inner) {
  7829. let rot = Math.PI / 2 * 3;
  7830. let x, y;
  7831. let step = Math.PI / spikes;
  7832. ctxt.beginPath();
  7833. ctxt.moveTo(0, -outer);
  7834. for (let i = 0; i < spikes; i++) {
  7835. x = Math.cos(rot) * outer;
  7836. y = Math.sin(rot) * outer;
  7837. ctxt.lineTo(x, y);
  7838. rot += step;
  7839. x = Math.cos(rot) * inner;
  7840. y = Math.sin(rot) * inner;
  7841. ctxt.lineTo(x, y);
  7842. rot += step;
  7843. }
  7844. ctxt.lineTo(0, -outer);
  7845. ctxt.closePath();
  7846. }
  7847. function renderHealthStar(ctxt, spikes, outer, inner) {
  7848. let rot = Math.PI / 2 * 3;
  7849. let x, y;
  7850. let step = Math.PI / spikes;
  7851. ctxt.beginPath();
  7852. ctxt.moveTo(0, -outer);
  7853. for (let i = 0; i < spikes; i++) {
  7854. x = Math.cos(rot) * outer;
  7855. y = Math.sin(rot) * outer;
  7856. ctxt.lineTo(x, y);
  7857. rot += step;
  7858. x = Math.cos(rot) * inner;
  7859. y = Math.sin(rot) * inner;
  7860. ctxt.lineTo(x, y);
  7861. rot += step;
  7862. }
  7863. ctxt.lineTo(0, -outer);
  7864. ctxt.closePath();
  7865. }
  7866. // RENDER RECTANGLE:
  7867. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  7868. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  7869. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  7870. }
  7871. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  7872. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  7873. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  7874. }
  7875. // RENDER RECTCIRCLE:
  7876. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  7877. ctxt.save();
  7878. ctxt.translate(x, y);
  7879. seg = Math.ceil(seg / 2);
  7880. for (let i = 0; i < seg; i++) {
  7881. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  7882. ctxt.rotate(Math.PI / seg);
  7883. }
  7884. ctxt.restore();
  7885. }
  7886. // RENDER BLOB:
  7887. function renderBlob(ctxt, spikes, outer, inner) {
  7888. let rot = Math.PI / 2 * 3;
  7889. let x, y;
  7890. let step = Math.PI / spikes;
  7891. let tmpOuter;
  7892. ctxt.beginPath();
  7893. ctxt.moveTo(0, -inner);
  7894. for (let i = 0; i < spikes; i++) {
  7895. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  7896. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  7897. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  7898. rot += step * 2;
  7899. }
  7900. ctxt.lineTo(0, -inner);
  7901. ctxt.closePath();
  7902. }
  7903. // RENDER TRIANGLE:
  7904. function renderTriangle(s, ctx) {
  7905. ctx = ctx || mainContext;
  7906. let h = s * (Math.sqrt(3) / 2);
  7907. ctx.beginPath();
  7908. ctx.moveTo(0, -h / 2);
  7909. ctx.lineTo(-s / 2, h / 2);
  7910. ctx.lineTo(s / 2, h / 2);
  7911. ctx.lineTo(0, -h / 2);
  7912. ctx.fill();
  7913. ctx.closePath();
  7914. }
  7915. // PREPARE MENU BACKGROUND:
  7916. function prepareMenuBackground() {
  7917. // let tmpMid = config.mapScale / 2;
  7918. // let attempts = 0;
  7919. // for (let i = 0; i < items.list.length * 3;) {
  7920. // if (attempts >= 1000) break;
  7921. // attempts++;
  7922. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  7923. // let data = {
  7924. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  7925. // y: tmpMid + UTILS.randFloat(-600, 600),
  7926. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  7927. // };
  7928. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  7929. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  7930. // } else {
  7931. // continue;
  7932. // }
  7933. // i++;
  7934. // }
  7935. }
  7936. const speed = 1;
  7937. // RENDER PLAYERS:
  7938. function renderDeadPlayers(xOffset, yOffset) {
  7939. mainContext.fillStyle = "#91b2db";
  7940. const currentTime = Date.now();
  7941. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  7942. if (!dead.startTime) {
  7943. dead.startTime = currentTime;
  7944. dead.angle = 0;
  7945. dead.radius = 0.1;
  7946. }
  7947. const timeElapsed = currentTime - dead.startTime;
  7948. const maxAlpha = 1;
  7949. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  7950. dead.animate(delta);
  7951. mainContext.globalAlpha = dead.alpha;
  7952. mainContext.strokeStyle = outlineColor;
  7953. mainContext.save();
  7954. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  7955. dead.radius -= 0.001;
  7956. dead.angle += 0.0174533;
  7957. const moveSpeed = 1;
  7958. const x = dead.radius * Math.cos(dead.angle);
  7959. const y = dead.radius * Math.sin(dead.angle);
  7960. dead.x += x * moveSpeed;
  7961. dead.y += y * moveSpeed;
  7962. mainContext.rotate(dead.angle);
  7963. renderDeadPlayer(dead, mainContext);
  7964. mainContext.restore();
  7965. mainContext.fillStyle = "#91b2db";
  7966. if (timeElapsed >= 3000) {
  7967. dead.active = false;
  7968. dead.startTime = null;
  7969. }
  7970. });
  7971. }
  7972. // RENDER PLAYERS:
  7973. function renderPlayers(xOffset, yOffset, zIndex) {
  7974. mainContext.globalAlpha = 1;
  7975. mainContext.fillStyle = "#91b2db";
  7976. for (var i = 0; i < players.length; ++i) {
  7977. tmpObj = players[i];
  7978. if (tmpObj.zIndex == zIndex) {
  7979. tmpObj.animate(delta);
  7980. if (tmpObj.visible) {
  7981. tmpObj.skinRot += (0.002 * delta);
  7982. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  7983. mainContext.save();
  7984. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  7985. // RENDER PLAYER:
  7986. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  7987. renderPlayer(tmpObj, mainContext);
  7988. mainContext.restore();
  7989. }
  7990. }
  7991. }
  7992. }
  7993. // RENDER DEAD PLAYER:
  7994. function renderDeadPlayer(obj, ctxt) {
  7995. ctxt = ctxt || mainContext;
  7996. ctxt.lineWidth = outlineWidth;
  7997. ctxt.lineJoin = "miter";
  7998. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  7999. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8000. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8001. // TAIL/CAPE:
  8002. renderTail2(13, ctxt, obj);
  8003. // WEAPON BELLOW HANDS:
  8004. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8005. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8006. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8007. renderProjectile(obj.scale, 0,
  8008. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8009. }
  8010. }
  8011. // HANDS:
  8012. ctxt.fillStyle = "#ececec";
  8013. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8014. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8015. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8016. // WEAPON ABOVE HANDS:
  8017. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8018. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8019. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8020. renderProjectile(obj.scale, 0,
  8021. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8022. }
  8023. }
  8024. // BUILD ITEM:
  8025. if (obj.buildIndex >= 0) {
  8026. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8027. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8028. }
  8029. // BODY:
  8030. renderCircle(0, 0, obj.scale, ctxt);
  8031. // SKIN
  8032. renderSkin2(48, ctxt, null, obj)
  8033. }
  8034. // RENDER PLAYER:
  8035. function renderPlayer(obj, ctxt) {
  8036. ctxt = ctxt || mainContext;
  8037. ctxt.lineWidth = outlineWidth;
  8038. ctxt.lineJoin = "miter";
  8039. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8040. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8041. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8042. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8043. // TAIL/CAPE:
  8044. if (obj.tailIndex > 0) {
  8045. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8046. }
  8047. // WEAPON BELLOW HANDS:
  8048. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8049. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8050. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8051. renderProjectile(obj.scale, 0,
  8052. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8053. }
  8054. }
  8055. // HANDS:
  8056. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8057. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8058. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8059. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8060. // WEAPON ABOVE HANDS:
  8061. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8062. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8063. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8064. renderProjectile(obj.scale, 0,
  8065. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8066. }
  8067. }
  8068. // BUILD ITEM:
  8069. if (obj.buildIndex >= 0) {
  8070. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8071. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8072. }
  8073. // BODY:
  8074. renderCircle(0, 0, obj.scale, ctxt);
  8075. // SKIN:
  8076. if (obj.skinIndex > 0) {
  8077. ctxt.rotate(Math.PI / 2);
  8078. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8079. }
  8080. }
  8081. // RENDER NORMAL SKIN
  8082. var skinSprites2 = {};
  8083. var skinPointers2 = {};
  8084. function renderSkin2(index, ctxt, parentSkin, owner) {
  8085. tmpSkin = skinSprites2[index];
  8086. if (!tmpSkin) {
  8087. var tmpImage = new Image();
  8088. tmpImage.onload = function() {
  8089. this.isLoaded = true;
  8090. this.onload = null;
  8091. };
  8092. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8093. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8094. skinSprites2[index] = tmpImage;
  8095. tmpSkin = tmpImage;
  8096. }
  8097. var tmpObj = parentSkin||skinPointers2[index];
  8098. if (!tmpObj) {
  8099. for (var i = 0; i < hats.length; ++i) {
  8100. if (hats[i].id == index) {
  8101. tmpObj = hats[i];
  8102. break;
  8103. }
  8104. }
  8105. skinPointers2[index] = tmpObj;
  8106. }
  8107. if (tmpSkin.isLoaded)
  8108. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8109. if (!parentSkin && tmpObj.topSprite) {
  8110. ctxt.save();
  8111. ctxt.rotate(owner.skinRot);
  8112. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8113. ctxt.restore();
  8114. }
  8115. }
  8116. // RENDER SKIN:
  8117. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8118. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8119. var tmpImage = new Image();
  8120. tmpImage.onload = function() {
  8121. this.isLoaded = true,
  8122. this.onload = null
  8123. }
  8124. ,
  8125. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8126. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8127. tmpSkin = tmpImage
  8128. }
  8129. var tmpObj = parentSkin||skinPointers[index];
  8130. if (!tmpObj) {
  8131. for (var i = 0; i < hats.length; ++i) {
  8132. if (hats[i].id == index) {
  8133. tmpObj = hats[i];
  8134. break;
  8135. }
  8136. }
  8137. skinPointers[index] = tmpObj;
  8138. }
  8139. if (tmpSkin.isLoaded)
  8140. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8141. if (!parentSkin && tmpObj.topSprite) {
  8142. ctxt.save();
  8143. ctxt.rotate(owner.skinRot);
  8144. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8145. ctxt.restore();
  8146. }
  8147. }
  8148. var FlareZHat = {
  8149. 7: "https://i.imgur.com/vAOzlyY.png",
  8150. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8151. 40: "https://i.imgur.com/Xzmg27N.png",
  8152. 26: "https://i.imgur.com/I0xGtyZ.png",
  8153. 55: "https://i.imgur.com/uYgDtcZ.png",
  8154. 20: "https://i.imgur.com/f5uhWCk.png",
  8155. };
  8156. function setSkinTextureImage(id, type, id2) {
  8157. if (true) {
  8158. if(FlareZHat[id] && type == "hat") {
  8159. return FlareZHat[id];
  8160. } else {
  8161. if(type == "acc") {
  8162. return ".././img/accessories/access_" + id + ".png";
  8163. } else if(type == "hat") {
  8164. return ".././img/hats/hat_" + id + ".png";
  8165. } else {
  8166. return ".././img/weapons/" + id + ".png";
  8167. }
  8168. }
  8169. } else {
  8170. if(type == "acc") {
  8171. return ".././img/accessories/access_" + id + ".png";
  8172. } else if(type == "hat") {
  8173. return ".././img/hats/hat_" + id + ".png";
  8174. } else {
  8175. return ".././img/weapons/" + id + ".png";
  8176. }
  8177. }
  8178. }
  8179. // RENDER SKINS:
  8180. let skinSprites = {};
  8181. let skinPointers = {};
  8182. let tmpSkin;
  8183. function renderSkin(index, ctxt, parentSkin, owner) {
  8184. tmpSkin = skinSprites[index];
  8185. if (!tmpSkin) {
  8186. let tmpImage = new Image();
  8187. tmpImage.onload = function() {
  8188. this.isLoaded = true;
  8189. this.onload = null;
  8190. };
  8191. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8192. skinSprites[index] = tmpImage;
  8193. tmpSkin = tmpImage;
  8194. }
  8195. let tmpObj = parentSkin || skinPointers[index];
  8196. if (!tmpObj) {
  8197. for (let i = 0; i < hats.length; ++i) {
  8198. if (hats[i].id == index) {
  8199. tmpObj = hats[i];
  8200. break;
  8201. }
  8202. }
  8203. skinPointers[index] = tmpObj;
  8204. }
  8205. if (tmpSkin.isLoaded)
  8206. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8207. if (!parentSkin && tmpObj.topSprite) {
  8208. ctxt.save();
  8209. ctxt.rotate(owner.skinRot);
  8210. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8211. ctxt.restore();
  8212. }
  8213. }
  8214. // RENDER TAIL:
  8215. var FlareZAcc = {
  8216. 21: "https://i.imgur.com/4ddZert.png",
  8217. 19: "https://i.imgur.com/sULkUZT.png",
  8218. };
  8219. function setTailTextureImage(id, type, id2) {
  8220. if (true) {
  8221. if(FlareZAcc[id] && type == "acc") {
  8222. return FlareZAcc[id];
  8223. } else {
  8224. if(type == "acc") {
  8225. return ".././img/accessories/access_" + id + ".png";
  8226. } else if(type == "hat") {
  8227. return ".././img/hats/hat_" + id + ".png";
  8228. } else {
  8229. return ".././img/weapons/" + id + ".png";
  8230. }
  8231. }
  8232. } else {
  8233. if(type == "acc") {
  8234. return ".././img/accessories/access_" + id + ".png";
  8235. } else if(type == "hat") {
  8236. return ".././img/hats/hat_" + id + ".png";
  8237. } else {
  8238. return ".././img/weapons/" + id + ".png";
  8239. }
  8240. }
  8241. }
  8242. function renderTailTextureImage(index, ctxt, owner) {
  8243. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  8244. var tmpImage = new Image();
  8245. tmpImage.onload = function() {
  8246. this.isLoaded = true,
  8247. this.onload = null
  8248. }
  8249. ,
  8250. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  8251. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8252. tmpSkin = tmpImage;
  8253. }
  8254. var tmpObj = accessPointers[index];
  8255. if (!tmpObj) {
  8256. for (var i = 0; i < accessories.length; ++i) {
  8257. if (accessories[i].id == index) {
  8258. tmpObj = accessories[i];
  8259. break;
  8260. }
  8261. }
  8262. accessPointers[index] = tmpObj;
  8263. }
  8264. if (tmpSkin.isLoaded) {
  8265. ctxt.save();
  8266. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8267. if (tmpObj.spin)
  8268. ctxt.rotate(owner.skinRot);
  8269. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8270. ctxt.restore();
  8271. }
  8272. }
  8273. let accessSprites = {};
  8274. let accessPointers = {};
  8275. var txt = true;
  8276. function renderTail(index, ctxt, owner) {
  8277. tmpSkin = accessSprites[index];
  8278. if (!tmpSkin) {
  8279. let tmpImage = new Image();
  8280. tmpImage.onload = function() {
  8281. this.isLoaded = true;
  8282. this.onload = null;
  8283. };
  8284. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8285. accessSprites[index] = tmpImage;
  8286. tmpSkin = tmpImage;
  8287. }
  8288. let tmpObj = accessPointers[index];
  8289. if (!tmpObj) {
  8290. for (let i = 0; i < accessories.length; ++i) {
  8291. if (accessories[i].id == index) {
  8292. tmpObj = accessories[i];
  8293. break;
  8294. }
  8295. }
  8296. accessPointers[index] = tmpObj;
  8297. }
  8298. if (tmpSkin.isLoaded) {
  8299. ctxt.save();
  8300. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  8301. if (tmpObj.spin)
  8302. ctxt.rotate(owner.skinRot);
  8303. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  8304. ctxt.restore();
  8305. }
  8306. }
  8307. var accessSprites2 = {};
  8308. var accessPointers2 = {};
  8309. function renderTail2(index, ctxt, owner) {
  8310. tmpSkin = accessSprites2[index];
  8311. if (!tmpSkin) {
  8312. var tmpImage = new Image();
  8313. tmpImage.onload = function() {
  8314. this.isLoaded = true;
  8315. this.onload = null;
  8316. };
  8317. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8318. accessSprites2[index] = tmpImage;
  8319. tmpSkin = tmpImage;
  8320. }
  8321. var tmpObj = accessPointers2[index];
  8322. if (!tmpObj) {
  8323. for (var i = 0; i < accessories.length; ++i) {
  8324. if (accessories[i].id == index) {
  8325. tmpObj = accessories[i];
  8326. break;
  8327. }
  8328. }
  8329. accessPointers2[index] = tmpObj;
  8330. }
  8331. if (tmpSkin.isLoaded) {
  8332. ctxt.save();
  8333. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8334. if (tmpObj.spin)
  8335. ctxt.rotate(owner.skinRot);
  8336. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8337. ctxt.restore();
  8338. }
  8339. }
  8340. // RENDER TOOL:
  8341. let toolSprites = {};
  8342. function renderTool(obj, variant, x, y, ctxt) {
  8343. let tmpSrc = obj.src + (variant || "");
  8344. let tmpSprite = toolSprites[tmpSrc];
  8345. if (!tmpSprite) {
  8346. tmpSprite = new Image();
  8347. tmpSprite.onload = function() {
  8348. this.isLoaded = true;
  8349. }
  8350. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8351. toolSprites[tmpSrc] = tmpSprite;
  8352. }
  8353. if (tmpSprite.isLoaded)
  8354. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  8355. }
  8356. // RENDER PROJECTILES:
  8357. function renderProjectiles(layer, xOffset, yOffset) {
  8358. for (let i = 0; i < projectiles.length; i++) {
  8359. tmpObj = projectiles[i];
  8360. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  8361. tmpObj.update(delta);
  8362. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  8363. mainContext.save();
  8364. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8365. mainContext.rotate(tmpObj.dir);
  8366. renderProjectile(0, 0, tmpObj, mainContext, 1);
  8367. mainContext.restore();
  8368. }
  8369. }
  8370. };
  8371. }
  8372. // RENDER PROJECTILE:
  8373. let projectileSprites = {};//fz iz zexy
  8374. function renderProjectile(x, y, obj, ctxt, debug) {
  8375. if (obj.src) {
  8376. let tmpSrc = items.projectiles[obj.indx].src;
  8377. let tmpSprite = projectileSprites[tmpSrc];
  8378. if (!tmpSprite) {
  8379. tmpSprite = new Image();
  8380. tmpSprite.onload = function() {
  8381. this.isLoaded = true;
  8382. }
  8383. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8384. projectileSprites[tmpSrc] = tmpSprite;
  8385. }
  8386. if (tmpSprite.isLoaded)
  8387. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  8388. } else if (obj.indx == 1) {
  8389. ctxt.fillStyle = "#939393";
  8390. renderCircle(x, y, obj.scale, ctxt);
  8391. }
  8392. }
  8393. // RENDER AI:
  8394. let aiSprites = {};
  8395. function renderAI(obj, ctxt) {
  8396. let tmpIndx = obj.index;
  8397. let tmpSprite = aiSprites[tmpIndx];
  8398. if (!tmpSprite) {
  8399. let tmpImg = new Image();
  8400. tmpImg.onload = function() {
  8401. this.isLoaded = true;
  8402. this.onload = null;
  8403. };
  8404. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  8405. tmpSprite = tmpImg;
  8406. aiSprites[tmpIndx] = tmpSprite;
  8407. }
  8408. if (tmpSprite.isLoaded) {
  8409. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  8410. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  8411. }
  8412. }
  8413. // RENDER WATER BODIES:
  8414. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  8415. // MIDDLE RIVER:
  8416. let tmpW = config.riverWidth + padding;
  8417. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  8418. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  8419. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  8420. }
  8421. }
  8422. // RENDER GAME OBJECTS:
  8423. let gameObjectSprites = {};
  8424. function getResSprite(obj) {
  8425. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  8426. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  8427. let tmpSprite = gameObjectSprites[tmpIndex];
  8428. if (!tmpSprite) {
  8429. let blurScale = 6;
  8430. let tmpCanvas = document.createElement("canvas");
  8431. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  8432. let tmpContext = tmpCanvas.getContext('2d');
  8433. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8434. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  8435. tmpContext.strokeStyle = outlineColor;
  8436. tmpContext.lineWidth = outlineWidth;
  8437. // if (isNight) {
  8438. // tmpContext.shadowBlur = blurScale;
  8439. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  8440. // }
  8441. if (obj.type == 0) {
  8442. let tmpScale;
  8443. let tmpCount = 8;
  8444. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  8445. for (let i = 0; i < 2; ++i) {
  8446. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  8447. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  8448. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  8449. tmpContext.fill();
  8450. if (!i) {
  8451. tmpContext.stroke();
  8452. tmpContext.shadowBlur = null;
  8453. tmpContext.shadowColor = null;
  8454. tmpContext.globalAlpha = 1;
  8455. }
  8456. }
  8457. } else if (obj.type == 1) {
  8458. if (biomeID == 2) {
  8459. tmpContext.fillStyle = "#606060";
  8460. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  8461. tmpContext.fill();
  8462. tmpContext.stroke();
  8463. //tmpContext.shadowBlur = null;
  8464. //tmpContext.shadowColor = null;
  8465. tmpContext.fillStyle = "#89a54c";
  8466. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  8467. tmpContext.fillStyle = "#a5c65b";
  8468. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  8469. } else {
  8470. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  8471. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  8472. tmpContext.fill();
  8473. tmpContext.stroke();
  8474. //tmpContext.shadowBlur = null;
  8475. //tmpContext.shadowColor = null;
  8476. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  8477. let tmpRange;
  8478. let berries = 4;
  8479. let rotVal = (Math.PI * 2) / berries;
  8480. for (let i = 0; i < berries; ++i) {
  8481. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  8482. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8483. UTILS.randInt(10, 12), tmpContext);
  8484. }
  8485. }
  8486. } else if (obj.type == 2 || obj.type == 3) {
  8487. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  8488. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8489. tmpContext.fill();
  8490. tmpContext.stroke();
  8491. tmpContext.shadowBlur = null;
  8492. tmpContext.shadowColor = null;
  8493. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  8494. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8495. tmpContext.fill();
  8496. }
  8497. tmpSprite = tmpCanvas;
  8498. gameObjectSprites[tmpIndex] = tmpSprite;
  8499. }
  8500. return tmpSprite;
  8501. }
  8502. // GET ITEM SPRITE:
  8503. let itemSprites = [];
  8504. function getItemSprite(obj, asIcon) {
  8505. let tmpSprite = itemSprites[obj.id];
  8506. if (!tmpSprite || asIcon) {
  8507. let blurScale = !asIcon ? 20 : 5;
  8508. let tmpCanvas = document.createElement("canvas");
  8509. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  8510. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  8511. let tmpContext = tmpCanvas.getContext("2d");
  8512. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8513. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  8514. tmpContext.strokeStyle = outlineColor;
  8515. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  8516. if (!asIcon) {
  8517. tmpContext.shadowBlur = 8;
  8518. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  8519. }
  8520. if (obj.name == "apple") {
  8521. tmpContext.fillStyle = "#c15555";
  8522. renderCircle(0, 0, obj.scale, tmpContext);
  8523. tmpContext.fillStyle = "#89a54c";
  8524. let leafDir = -(Math.PI / 2);
  8525. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  8526. 25, leafDir + Math.PI / 2, tmpContext);
  8527. } else if (obj.name == "cookie") {
  8528. tmpContext.fillStyle = "#cca861";
  8529. renderCircle(0, 0, obj.scale, tmpContext);
  8530. tmpContext.fillStyle = "#937c4b";
  8531. let chips = 4;
  8532. let rotVal = (Math.PI * 2) / chips;
  8533. let tmpRange;
  8534. for (let i = 0; i < chips; ++i) {
  8535. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8536. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8537. UTILS.randInt(4, 5), tmpContext, true);
  8538. }
  8539. } else if (obj.name == "cheese") {
  8540. tmpContext.fillStyle = "#f4f3ac";
  8541. renderCircle(0, 0, obj.scale, tmpContext);
  8542. tmpContext.fillStyle = "#c3c28b";
  8543. let chips = 4;
  8544. let rotVal = (Math.PI * 2) / chips;
  8545. let tmpRange;
  8546. for (let i = 0; i < chips; ++i) {
  8547. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8548. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8549. UTILS.randInt(4, 5), tmpContext, true);
  8550. }
  8551. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  8552. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  8553. "#a5974c" : "#939393";
  8554. let sides = (obj.name == "castle wall") ? 4 : 3;
  8555. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  8556. tmpContext.fill();
  8557. tmpContext.stroke();
  8558. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  8559. "#c9b758" : "#bcbcbc";
  8560. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  8561. tmpContext.fill();
  8562. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  8563. obj.name == "spinning spikes") {
  8564. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#72B2F4" : "#939393";
  8565. let tmpScale = (obj.scale * 0.6);
  8566. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  8567. tmpContext.fill();
  8568. tmpContext.stroke();
  8569. tmpContext.fillStyle = "#72B2F4";
  8570. renderCircle(0, 0, tmpScale, tmpContext);
  8571. tmpContext.fillStyle = "#72B2F4";
  8572. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8573. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8574. tmpContext.fillStyle = "#a5974c";
  8575. renderCircle(0, 0, reScale, tmpContext);
  8576. tmpContext.fillStyle = "#c9b758";
  8577. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  8578. tmpContext.fillStyle = "#a5974c";
  8579. renderCircle(0, 0, reScale * 0.5, tmpContext);
  8580. } else if (obj.name == "mine") {
  8581. tmpContext.fillStyle = "#939393";
  8582. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8583. tmpContext.fill();
  8584. tmpContext.stroke();
  8585. tmpContext.fillStyle = "#bcbcbc";
  8586. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8587. tmpContext.fill();
  8588. } else if (obj.name == "sapling") {
  8589. for (let i = 0; i < 2; ++i) {
  8590. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  8591. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  8592. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  8593. tmpContext.fill();
  8594. if (!i) tmpContext.stroke();
  8595. }
  8596. } else if (obj.name == "pit trap") {
  8597. tmpContext.fillStyle = "#e06666";
  8598. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  8599. tmpContext.fill();
  8600. tmpContext.stroke();
  8601. tmpContext.fillStyle = outlineColor;
  8602. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  8603. tmpContext.fill();
  8604. } else if (obj.name == "boost pad") {
  8605. tmpContext.fillStyle = "#7e7f82";
  8606. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8607. tmpContext.fill();
  8608. tmpContext.stroke();
  8609. tmpContext.fillStyle = "#dbd97d";
  8610. renderTriangle(obj.scale * 1, tmpContext);
  8611. } else if (obj.name == "turret") {
  8612. tmpContext.fillStyle = "#a5974c";
  8613. renderCircle(0, 0, obj.scale, tmpContext);
  8614. tmpContext.fill();
  8615. tmpContext.stroke();
  8616. tmpContext.fillStyle = "#939393";
  8617. let tmpLen = 50;
  8618. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  8619. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8620. tmpContext.fill();
  8621. tmpContext.stroke();
  8622. } else if (obj.name == "platform") {
  8623. tmpContext.fillStyle = "#cebd5f";
  8624. let tmpCount = 4;
  8625. let tmpS = obj.scale * 2;
  8626. let tmpW = tmpS / tmpCount;
  8627. let tmpX = -(obj.scale / 2);
  8628. for (let i = 0; i < tmpCount; ++i) {
  8629. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  8630. tmpContext.fill();
  8631. tmpContext.stroke();
  8632. tmpX += tmpS / tmpCount;
  8633. }
  8634. } else if (obj.name == "healing pad") {
  8635. tmpContext.fillStyle = "#7e7f82";
  8636. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8637. tmpContext.fill();
  8638. tmpContext.stroke();
  8639. tmpContext.fillStyle = "#db6e6e";
  8640. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8641. } else if (obj.name == "spawn pad") {
  8642. tmpContext.fillStyle = "#7e7f82";
  8643. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8644. tmpContext.fill();
  8645. tmpContext.stroke();
  8646. tmpContext.fillStyle = "#71aad6";
  8647. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8648. } else if (obj.name == "blocker") {
  8649. tmpContext.fillStyle = "#7e7f82";
  8650. renderCircle(0, 0, obj.scale, tmpContext);
  8651. tmpContext.fill();
  8652. tmpContext.stroke();
  8653. tmpContext.rotate(Math.PI / 4);
  8654. tmpContext.fillStyle = "#db6e6e";
  8655. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8656. } else if (obj.name == "teleporter") {
  8657. tmpContext.fillStyle = "#7e7f82";
  8658. renderCircle(0, 0, obj.scale, tmpContext);
  8659. tmpContext.fill();
  8660. tmpContext.stroke();
  8661. tmpContext.rotate(Math.PI / 4);
  8662. tmpContext.fillStyle = "#d76edb";
  8663. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  8664. }
  8665. tmpSprite = tmpCanvas;
  8666. if (!asIcon)
  8667. itemSprites[obj.id] = tmpSprite;
  8668. }
  8669. return tmpSprite;
  8670. }
  8671. function getItemSprite2(obj, tmpX, tmpY) {
  8672. let tmpContext = mainContext;
  8673. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  8674. tmpContext.save();
  8675. tmpContext.translate(tmpX, tmpY);
  8676. tmpContext.rotate(obj.dir);
  8677. tmpContext.strokeStyle = outlineColor;
  8678. tmpContext.lineWidth = outlineWidth;
  8679. if (obj.name == "apple") {
  8680. tmpContext.fillStyle = "#c15555";
  8681. renderCircle(0, 0, obj.scale, tmpContext);
  8682. tmpContext.fillStyle = "#89a54c";
  8683. let leafDir = -(Math.PI / 2);
  8684. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  8685. 25, leafDir + Math.PI / 2, tmpContext);
  8686. } else if (obj.name == "cookie") {
  8687. tmpContext.fillStyle = "#cca861";
  8688. renderCircle(0, 0, obj.scale, tmpContext);
  8689. tmpContext.fillStyle = "#937c4b";
  8690. let chips = 4;
  8691. let rotVal = (Math.PI * 2) / chips;
  8692. let tmpRange;
  8693. for (let i = 0; i < chips; ++i) {
  8694. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8695. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8696. UTILS.randInt(4, 5), tmpContext, true);
  8697. }
  8698. } else if (obj.name == "cheese") {
  8699. tmpContext.fillStyle = "#f4f3ac";
  8700. renderCircle(0, 0, obj.scale, tmpContext);
  8701. tmpContext.fillStyle = "#c3c28b";
  8702. let chips = 4;
  8703. let rotVal = (Math.PI * 2) / chips;
  8704. let tmpRange;
  8705. for (let i = 0; i < chips; ++i) {
  8706. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8707. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8708. UTILS.randInt(4, 5), tmpContext, true);
  8709. }
  8710. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  8711. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  8712. "#a5974c" : "#939393";
  8713. let sides = (obj.name == "castle wall") ? 4 : 3;
  8714. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  8715. tmpContext.fill();
  8716. tmpContext.stroke();
  8717. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  8718. "#c9b758" : "#bcbcbc";
  8719. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  8720. tmpContext.fill();
  8721. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  8722. obj.name == "spinning spikes") {
  8723. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#72b2f4" : "#845320";
  8724. let tmpScale = (obj.scale * 0.6);
  8725. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  8726. tmpContext.fill();
  8727. tmpContext.stroke();
  8728. tmpContext.fillStyle = "#72b2f4";
  8729. renderCircle(0, 0, tmpScale, tmpContext);
  8730. tmpContext.fillStyle = "#72b2f4";
  8731. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8732. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8733. tmpContext.fillStyle = "#a5974c";
  8734. renderCircle(0, 0, reScale, tmpContext);
  8735. tmpContext.fillStyle = "#c9b758";
  8736. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  8737. tmpContext.fillStyle = "#a5974c";
  8738. renderCircle(0, 0, reScale * 0.5, tmpContext);
  8739. } else if (obj.name == "mine") {
  8740. tmpContext.fillStyle = "#939393";
  8741. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8742. tmpContext.fill();
  8743. tmpContext.stroke();
  8744. tmpContext.fillStyle = "#bcbcbc";
  8745. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8746. tmpContext.fill();
  8747. } else if (obj.name == "sapling") {
  8748. for (let i = 0; i < 2; ++i) {
  8749. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  8750. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  8751. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  8752. tmpContext.fill();
  8753. if (!i) tmpContext.stroke();
  8754. }
  8755. } else if (obj.name == "pit trap") {
  8756. tmpContext.fillStyle = "#72b2f4";
  8757. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  8758. tmpContext.fill();
  8759. tmpContext.stroke();
  8760. tmpContext.fillStyle = outlineColor;
  8761. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  8762. tmpContext.fill();
  8763. } else if (obj.name == "boost pad") {
  8764. tmpContext.fillStyle = "#7e7f82";
  8765. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8766. tmpContext.fill();
  8767. tmpContext.stroke();
  8768. tmpContext.fillStyle = "#dbd97d";
  8769. renderTriangle(obj.scale * 1, tmpContext);
  8770. } else if (obj.name == "turret") {
  8771. tmpContext.fillStyle = "#a5974c";
  8772. renderCircle(0, 0, obj.scale, tmpContext);
  8773. tmpContext.fill();
  8774. tmpContext.stroke();
  8775. tmpContext.fillStyle = "#939393";
  8776. let tmpLen = 50;
  8777. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  8778. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8779. tmpContext.fill();
  8780. tmpContext.stroke();
  8781. } else if (obj.name == "platform") {
  8782. tmpContext.fillStyle = "#cebd5f";
  8783. let tmpCount = 4;
  8784. let tmpS = obj.scale * 2;
  8785. let tmpW = tmpS / tmpCount;
  8786. let tmpX = -(obj.scale / 2);
  8787. for (let i = 0; i < tmpCount; ++i) {
  8788. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  8789. tmpContext.fill();
  8790. tmpContext.stroke();
  8791. tmpX += tmpS / tmpCount;
  8792. }
  8793. } else if (obj.name == "healing pad") {
  8794. tmpContext.fillStyle = "#7e7f82";
  8795. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8796. tmpContext.fill();
  8797. tmpContext.stroke();
  8798. tmpContext.fillStyle = "#db6e6e";
  8799. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8800. } else if (obj.name == "spawn pad") {
  8801. tmpContext.fillStyle = "#7e7f82";
  8802. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8803. tmpContext.fill();
  8804. tmpContext.stroke();
  8805. tmpContext.fillStyle = "#71aad6";
  8806. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8807. } else if (obj.name == "blocker") {
  8808. tmpContext.fillStyle = "#7e7f82";
  8809. renderCircle(0, 0, obj.scale, tmpContext);
  8810. tmpContext.fill();
  8811. tmpContext.stroke();
  8812. tmpContext.rotate(Math.PI / 4);
  8813. tmpContext.fillStyle = "#db6e6e";
  8814. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8815. } else if (obj.name == "teleporter") {
  8816. tmpContext.fillStyle = "#7e7f82";
  8817. renderCircle(0, 0, obj.scale, tmpContext);
  8818. tmpContext.fill();
  8819. tmpContext.stroke();
  8820. tmpContext.rotate(Math.PI / 4);
  8821. tmpContext.fillStyle = "#d76edb";
  8822. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  8823. }
  8824. tmpContext.restore();
  8825. }
  8826. let objSprites = [];
  8827. function getObjSprite(obj) {
  8828. let tmpSprite = objSprites[obj.id];
  8829. if (!tmpSprite) {
  8830. // let blurScale = isNight ? 20 : 0;
  8831. let tmpCanvas = document.createElement("canvas");
  8832. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  8833. let tmpContext = tmpCanvas.getContext("2d");
  8834. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  8835. tmpContext.rotate(Math.PI / 2);
  8836. tmpContext.strokeStyle = outlineColor;
  8837. tmpContext.lineWidth = outlineWidth;
  8838. // if (isNight) {
  8839. // tmpContext.shadowBlur = 20;
  8840. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  8841. // }
  8842. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  8843. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#2986cc";
  8844. let tmpScale = obj.scale * 0.6;
  8845. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  8846. tmpContext.fill();
  8847. tmpContext.stroke();
  8848. tmpContext.fillStyle = "#f44336";
  8849. renderCircle(0, 0, tmpScale, tmpContext);
  8850. tmpContext.fillStyle = "#3d85c6";
  8851. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8852. } else if (obj.name == "pit trap") {
  8853. tmpContext.fillStyle = "#f44336";
  8854. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  8855. tmpContext.fill();
  8856. tmpContext.stroke();
  8857. tmpContext.fillStyle = "#45818e";
  8858. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  8859. tmpContext.fill();
  8860. }
  8861. tmpSprite = tmpCanvas;
  8862. objSprites[obj.id] = tmpSprite;
  8863. }
  8864. return tmpSprite;
  8865. }
  8866. // GET MARK SPRITE:
  8867. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  8868. let center = {
  8869. x: screenWidth / 2,
  8870. y: screenHeight / 2,
  8871. };
  8872. tmpContext.lineWidth = outlineWidth;
  8873. mainContext.globalAlpha = 0.2;
  8874. tmpContext.strokeStyle = outlineColor;
  8875. tmpContext.save();
  8876. tmpContext.translate(tmpX, tmpY);
  8877. tmpContext.rotate(90**10);
  8878. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  8879. tmpContext.fillStyle = (obj.name == "poison spikes")?"#a0d2db":"#6fa8dc";
  8880. var tmpScale = (obj.scale);
  8881. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  8882. tmpContext.fill();
  8883. tmpContext.stroke();
  8884. tmpContext.fillStyle = "#6fa8dc";
  8885. renderCircle(0, 0, tmpScale, tmpContext);
  8886. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  8887. tmpContext.fillStyle = "#a34040";
  8888. } else {
  8889. tmpContext.fillStyle = "#9fc5e8";
  8890. }
  8891. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  8892. } else if (obj.name == "turret") {
  8893. renderCircle(0, 0, obj.scale, tmpContext);
  8894. tmpContext.fill();
  8895. tmpContext.stroke();
  8896. tmpContext.fillStyle = "#939393";
  8897. let tmpLen = 50;
  8898. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  8899. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8900. tmpContext.fill();
  8901. tmpContext.stroke();
  8902. } else if (obj.name == "teleporter") {
  8903. tmpContext.fillStyle = "#7e7f82";
  8904. renderCircle(0, 0, obj.scale, tmpContext);
  8905. tmpContext.fill();
  8906. tmpContext.stroke();
  8907. tmpContext.rotate(Math.PI / 4);
  8908. tmpContext.fillStyle = "#d76edb";
  8909. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  8910. } else if (obj.name == "platform") {
  8911. tmpContext.fillStyle = "#cebd5f";
  8912. let tmpCount = 4;
  8913. let tmpS = obj.scale * 2;
  8914. let tmpW = tmpS / tmpCount;
  8915. let tmpX = -(obj.scale / 2);
  8916. for (let i = 0; i < tmpCount; ++i) {
  8917. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  8918. tmpContext.fill();
  8919. tmpContext.stroke();
  8920. tmpX += tmpS / tmpCount;
  8921. }
  8922. } else if (obj.name == "healing pad") {
  8923. tmpContext.fillStyle = "#7e7f82";
  8924. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8925. tmpContext.fill();
  8926. tmpContext.stroke();
  8927. tmpContext.fillStyle = "#db6e6e";
  8928. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8929. } else if (obj.name == "spawn pad") {
  8930. tmpContext.fillStyle = "#7e7f82";
  8931. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8932. tmpContext.fill();
  8933. tmpContext.stroke();
  8934. tmpContext.fillStyle = "#71aad6";
  8935. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8936. } else if (obj.name == "blocker") {
  8937. tmpContext.fillStyle = "#7e7f82";
  8938. renderCircle(0, 0, obj.scale, tmpContext);
  8939. tmpContext.fill();
  8940. tmpContext.stroke();
  8941. tmpContext.rotate(Math.PI / 4);
  8942. tmpContext.fillStyle = "#db6e6e";
  8943. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8944. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8945. tmpContext.fillStyle = "#a5974c";
  8946. renderCircle(0, 0, obj.scale, tmpContext);
  8947. tmpContext.fillStyle = "#c9b758";
  8948. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  8949. tmpContext.fillStyle = "#a5974c";
  8950. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  8951. } else if (obj.name == "pit trap") {
  8952. tmpContext.fillStyle = "#a5974c";
  8953. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  8954. tmpContext.fill();
  8955. tmpContext.stroke();
  8956. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  8957. tmpContext.fillStyle = "#a34040";
  8958. } else {
  8959. tmpContext.fillStyle = outlineColor;
  8960. }
  8961. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  8962. tmpContext.fill();
  8963. }
  8964. tmpContext.restore();
  8965. }
  8966. // OBJECT ON SCREEN:
  8967. function isOnScreen(x, y, s) {
  8968. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  8969. s,
  8970. maxScreenHeight));
  8971. }
  8972. // RENDER GAME OBJECTS:
  8973. function renderGameObjects(layer, xOffset, yOffset) {
  8974. let tmpSprite;
  8975. let tmpX;
  8976. let tmpY;
  8977. liztobj.forEach((tmp) => {
  8978. tmpObj = tmp;
  8979. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  8980. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  8981. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  8982. if (layer == 0) {
  8983. tmpObj.update(delta);
  8984. }
  8985. mainContext.globalAlpha = tmpObj.alpha;
  8986. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  8987. if (tmpObj.isItem) {
  8988. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  8989. tmpSprite = getObjSprite(tmpObj);
  8990. } else {
  8991. tmpSprite = getItemSprite(tmpObj);
  8992. }
  8993. mainContext.save();
  8994. mainContext.translate(tmpX, tmpY);
  8995. mainContext.rotate(tmpObj.dir);
  8996. if (!tmpObj.active) {
  8997. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  8998. }
  8999. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9000. if (tmpObj.blocker) {
  9001. mainContext.strokeStyle = "#db6e6e";
  9002. mainContext.globalAlpha = 0.3;
  9003. mainContext.lineWidth = 6;
  9004. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9005. }
  9006. mainContext.restore();
  9007. } else {
  9008. tmpSprite = getResSprite(tmpObj);
  9009. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9010. }
  9011. }
  9012. if (layer == 3 && !useWasd) {
  9013. if (tmpObj.health < tmpObj.maxHealth) {
  9014. // HEALTH HOLDER:
  9015. mainContext.fillStyle = darkOutlineColor;
  9016. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9017. mainContext.fill();
  9018. // HEALTH BAR:
  9019. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  9020. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9021. mainContext.fill();
  9022. }
  9023. }
  9024. }
  9025. });
  9026. // PLACE VISIBLE:
  9027. if (layer == 0) {
  9028. if (placeVisible.length) {
  9029. placeVisible.forEach((places) => {
  9030. tmpX = places.x - xOffset;
  9031. tmpY = places.y - yOffset;
  9032. markObject(places, tmpX, tmpY);
  9033. });
  9034. }
  9035. }
  9036. }
  9037. function markObject(tmpObj, tmpX, tmpY) {
  9038. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9039. }
  9040. // RENDER MINIMAP:
  9041. class MapPing {
  9042. constructor(color, scale) {
  9043. this.init = function(x, y) {
  9044. this.scale = 0;
  9045. this.x = x;
  9046. this.y = y;
  9047. this.active = true;
  9048. };
  9049. this.update = function(ctxt, delta) {
  9050. if (this.active) {
  9051. this.scale += 0.05 * delta;
  9052. if (this.scale >= scale) {
  9053. this.active = false;
  9054. } else {
  9055. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9056. ctxt.beginPath();
  9057. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9058. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9059. ctxt.stroke();
  9060. }
  9061. }
  9062. };
  9063. this.color = color;
  9064. }
  9065. }
  9066. function pingMap(x, y) {
  9067. tmpPing = mapPings.find(pings => !pings.active);
  9068. if (!tmpPing) {
  9069. tmpPing = new MapPing("#fff", config.mapPingScale);
  9070. mapPings.push(tmpPing);
  9071. }
  9072. tmpPing.init(x, y);
  9073. }
  9074. function updateMapMarker() {
  9075. mapMarker.x = player.x;
  9076. mapMarker.y = player.y;
  9077. }
  9078. function renderMinimap(delta) {
  9079. if (player && player.alive) {
  9080. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9081. // RENDER PINGS:
  9082. mapContext.lineWidth = 4;
  9083. for (let i = 0; i < mapPings.length; ++i) {
  9084. tmpPing = mapPings[i];
  9085. mapContext.strokeStyle = tmpPing.color;
  9086. tmpPing.update(mapContext, delta);
  9087. }
  9088. // RENDER BREAK TRACKS:
  9089. mapContext.globalAlpha = 1;
  9090. mapContext.fillStyle = "#ff0000";
  9091. if (breakTrackers.length) {
  9092. mapContext.fillStyle = "#abcdef";
  9093. mapContext.font = "34px Hammersmith One";
  9094. mapContext.textBaseline = "middle";
  9095. mapContext.textAlign = "center";
  9096. for (let i = 0; i < breakTrackers.length;) {
  9097. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9098. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9099. i += 2;
  9100. }
  9101. }
  9102. // RENDER PLAYERS:
  9103. mapContext.globalAlpha = 1;
  9104. mapContext.fillStyle = "#fff";
  9105. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9106. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9107. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9108. if (player.team && minimapData) {
  9109. for (let i = 0; i < minimapData.length;) {
  9110. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9111. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9112. i += 2;
  9113. }
  9114. }
  9115. // RENDER BOTS:
  9116. if (bots.length) {
  9117. bots.forEach((tmp) => {
  9118. if (tmp.inGame) {
  9119. mapContext.globalAlpha = 1;
  9120. mapContext.strokeStyle = "#cc5151";
  9121. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9122. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9123. }
  9124. });
  9125. }
  9126. // DEATH LOCATION:
  9127. if (lastDeath) {
  9128. mapContext.fillStyle = "#fc5553";
  9129. mapContext.font = "34px Hammersmith One";
  9130. mapContext.textBaseline = "middle";
  9131. mapContext.textAlign = "center";
  9132. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9133. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9134. }
  9135. // MAP MARKER:
  9136. if (mapMarker) {
  9137. mapContext.fillStyle = "#fff";
  9138. mapContext.font = "34px Hammersmith One";
  9139. mapContext.textBaseline = "middle";
  9140. mapContext.textAlign = "center";
  9141. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9142. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9143. }
  9144. }
  9145. }
  9146. // ICONS:
  9147. let crossHairs = ["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/newawwddd.png", "https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100px-Crosshairs_Red.png"];
  9148. let crossHairSprites = {};
  9149. let iconSprites = {};
  9150. let icons = ["crown", "skull"];
  9151. function loadIcons() {
  9152. for (let i = 0; i < icons.length; ++i) {
  9153. let tmpSprite = new Image();
  9154. tmpSprite.onload = function() {
  9155. this.isLoaded = true;
  9156. };
  9157. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9158. iconSprites[icons[i]] = tmpSprite;
  9159. }
  9160. for (let i = 0; i < crossHairs.length; ++i) {
  9161. let tmpSprite = new Image();
  9162. tmpSprite.onload = function() {
  9163. this.isLoaded = true;
  9164. };
  9165. tmpSprite.src = crossHairs[i];
  9166. crossHairSprites[i] = tmpSprite;
  9167. }
  9168. }
  9169. loadIcons();
  9170. function cdf (e, t){
  9171. try {
  9172. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9173. } catch(e){
  9174. return Infinity;
  9175. }
  9176. }
  9177. // UPDATE GAME:
  9178. function updateGame() {
  9179. if(gameObjects.length && inGame) {
  9180. gameObjects.forEach((tmp) => {
  9181. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  9182. if(!liztobj.includes(tmp)) {
  9183. liztobj.push(tmp);
  9184. tmp.render = true;
  9185. }
  9186. } else {
  9187. if(liztobj.includes(tmp)) {
  9188. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9189. tmp.render = false;
  9190. const index = liztobj.indexOf(tmp);
  9191. if (index > -1) { // only splice array when item is found
  9192. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9193. }
  9194. }
  9195. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9196. tmp.render = false;
  9197. const index = liztobj.indexOf(tmp);
  9198. if (index > -1) { // only splice array when item is found
  9199. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9200. }
  9201. } else {
  9202. tmp.render = false;
  9203. const index = liztobj.indexOf(tmp);
  9204. if (index > -1) { // only splice array when item is found
  9205. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9206. }
  9207. }
  9208. }
  9209. })
  9210. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  9211. }
  9212. // if (config.resetRender) {
  9213. mainContext.beginPath();
  9214. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  9215. // }
  9216. mainContext.globalAlpha = 1;
  9217. // MOVE CAMERA:
  9218. if (player) {
  9219. if (false) {
  9220. camX = player.x;
  9221. camY = player.y;
  9222. } else {
  9223. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  9224. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  9225. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  9226. if (tmpDist > 0.05) {
  9227. camX += camSpd * Math.cos(tmpDir);
  9228. camY += camSpd * Math.sin(tmpDir);
  9229. } else {
  9230. camX = player.x;
  9231. camY = player.y;
  9232. }
  9233. }
  9234. } else {
  9235. camX = config.mapScale / 2 + config.riverWidth;
  9236. camY = config.mapScale / 2;
  9237. }
  9238. // INTERPOLATE PLAYERS AND AI:
  9239. let lastTime = now - (1000 / config.serverUpdateRate);
  9240. let tmpDiff;
  9241. for (let i = 0; i < players.length + ais.length; ++i) {
  9242. tmpObj = players[i] || ais[i - players.length];
  9243. if (tmpObj && tmpObj.visible) {
  9244. if (tmpObj.forcePos) {
  9245. tmpObj.x = tmpObj.x2;
  9246. tmpObj.y = tmpObj.y2;
  9247. tmpObj.dir = tmpObj.d2;
  9248. } else {
  9249. let total = tmpObj.t2 - tmpObj.t1;
  9250. let fraction = lastTime - tmpObj.t1;
  9251. let ratio = (fraction / total);
  9252. let rate = 170;
  9253. tmpObj.dt += delta;
  9254. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  9255. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  9256. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  9257. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  9258. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  9259. if (config.anotherVisual) {
  9260. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9261. } else {
  9262. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9263. }
  9264. }
  9265. }
  9266. }
  9267. // RENDER CORDS:
  9268. let xOffset = camX - (maxScreenWidth / 2);
  9269. let yOffset = camY - (maxScreenHeight / 2);
  9270. // RENDER BACKGROUND:
  9271. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9272. mainContext.fillStyle = "#b6db66";
  9273. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9274. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  9275. mainContext.fillStyle = "#dbc666";
  9276. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9277. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9278. mainContext.fillStyle = "#fff";
  9279. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9280. } else if (config.snowBiomeTop - yOffset >= 0) {
  9281. mainContext.fillStyle = "#fff";
  9282. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  9283. mainContext.fillStyle = "#b6db66";
  9284. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  9285. maxScreenHeight - (config.snowBiomeTop - yOffset));
  9286. } else {
  9287. mainContext.fillStyle = "#b6db66";
  9288. mainContext.fillRect(0, 0, maxScreenWidth,
  9289. (config.mapScale - config.snowBiomeTop - yOffset));
  9290. mainContext.fillStyle = "#dbc666";
  9291. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  9292. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  9293. }
  9294. // RENDER WATER AREAS:
  9295. if (!firstSetup) {
  9296. waterMult += waterPlus * config.waveSpeed * delta;
  9297. if (waterMult >= config.waveMax) {
  9298. waterMult = config.waveMax;
  9299. waterPlus = -1;
  9300. } else if (waterMult <= 1) {
  9301. waterMult = waterPlus = 1;
  9302. }
  9303. mainContext.globalAlpha = 1;
  9304. mainContext.fillStyle = "#dbc666";
  9305. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  9306. mainContext.fillStyle = "#91b2db";
  9307. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  9308. }
  9309. // RENDER DEAD PLAYERS:
  9310. mainContext.globalAlpha = 1;
  9311. mainContext.strokeStyle = outlineColor;
  9312. renderDeadPlayers(xOffset, yOffset);
  9313. // RENDER BOTTOM LAYER:
  9314. mainContext.globalAlpha = 1;
  9315. mainContext.strokeStyle = outlineColor;
  9316. renderGameObjects(-1, xOffset, yOffset);
  9317. // RENDER PROJECTILES:
  9318. mainContext.globalAlpha = 1;
  9319. mainContext.lineWidth = outlineWidth;
  9320. renderProjectiles(0, xOffset, yOffset);
  9321. // RENDER PLAYERS:
  9322. renderPlayers(xOffset, yOffset, 0);
  9323. // RENDER AI:
  9324. mainContext.globalAlpha = 1;
  9325. for (let i = 0; i < ais.length; ++i) {
  9326. tmpObj = ais[i];
  9327. if (tmpObj.active && tmpObj.visible) {
  9328. tmpObj.animate(delta);
  9329. mainContext.save();
  9330. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9331. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  9332. renderAI(tmpObj, mainContext);
  9333. mainContext.restore();
  9334. }
  9335. }
  9336. // RENDER GAME OBJECTS (LAYERED):
  9337. renderGameObjects(0, xOffset, yOffset);
  9338. renderProjectiles(1, xOffset, yOffset);
  9339. renderGameObjects(1, xOffset, yOffset);
  9340. renderPlayers(xOffset, yOffset, 1);
  9341. renderGameObjects(2, xOffset, yOffset);
  9342. renderGameObjects(3, xOffset, yOffset);
  9343. // MAP BOUNDARIES:
  9344. mainContext.fillStyle = "#000";
  9345. mainContext.globalAlpha = 0.09;
  9346. if (xOffset <= 0) {
  9347. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  9348. }
  9349. if (config.mapScale - xOffset <= maxScreenWidth) {
  9350. let tmpY = Math.max(0, -yOffset);
  9351. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  9352. }
  9353. if (yOffset <= 0) {
  9354. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  9355. }
  9356. if (config.mapScale - yOffset <= maxScreenHeight) {
  9357. let tmpX = Math.max(0, -xOffset);
  9358. let tmpMin = 0;
  9359. if (config.mapScale - xOffset <= maxScreenWidth)
  9360. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  9361. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  9362. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  9363. }
  9364. // RENDER DAY/NIGHT TIME:
  9365. mainContext.globalAlpha = 1;
  9366. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  9367. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9368. // RENDER PLAYER AND AI UI:
  9369. mainContext.strokeStyle = darkOutlineColor;
  9370. mainContext.globalAlpha = 1;
  9371. for (let i = 0; i < players.length + ais.length; ++i) {
  9372. tmpObj = players[i] || ais[i - players.length];
  9373. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  9374. mainContext.strokeStyle = darkOutlineColor;
  9375. // NAME AND HEALTH:
  9376. // let izbot = false;
  9377. // bots.forEach((bot) => {
  9378. // if (tmpObj.sid == bot.sid) izbot = true
  9379. // else izbot = false;
  9380. // });
  9381. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  9382. if (tmpText != "" && tmpObj.name != "unknown1l") {
  9383. // bots.forEach((bot) => {
  9384. // if (tmpObj.sid == bot.sid) return;
  9385. // });
  9386. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  9387. mainContext.fillStyle = "#fff";
  9388. mainContext.textBaseline = "middle";
  9389. mainContext.textAlign = "center";
  9390. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  9391. mainContext.lineJoin = "round";
  9392. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9393. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9394. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  9395. let tmpS = config.crownIconScale;
  9396. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  9397. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9398. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9399. }
  9400. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  9401. let tmpS = config.crownIconScale;
  9402. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  9403. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9404. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9405. }
  9406. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length && !useWasd) {
  9407. let tmpS = tmpObj.scale * 2.2;
  9408. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  9409. }
  9410. // izbot = false;
  9411. }
  9412. if (tmpObj.health > 0) {
  9413. if(tmpObj.name != "unknown1l") {
  9414. // HEALTH HOLDER:
  9415. mainContext.fillStyle = darkOutlineColor;
  9416. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  9417. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  9418. (config.healthBarPad * 2), 17, 8);
  9419. mainContext.fill();
  9420. // HEALTH BAR:
  9421. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  9422. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  9423. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  9424. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  9425. mainContext.fill();
  9426. }
  9427. if (tmpObj.isPlayer) {
  9428. mainContext.globalAlpha = 1;
  9429. let targetReloads = {
  9430. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  9431. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  9432. turret: (2500 - tmpObj.reloads[53]) / 2500
  9433. };
  9434. if (!tmpObj.currentReloads) {
  9435. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  9436. primary: targetReloads.primary,
  9437. secondary: targetReloads.secondary,
  9438. turret: targetReloads.turret
  9439. };
  9440. }
  9441. const lerpFactor = 0.3;
  9442. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  9443. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  9444. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  9445. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  9446. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  9447. const centerX = tmpObj.x - xOffset;
  9448. const centerY = tmpObj.y - yOffset;
  9449. const barRadius = 35;
  9450. const barWidth = 15;
  9451. const totalAngle = (Math.PI*2)/3; // Half circle
  9452. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  9453. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  9454. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  9455. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  9456. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  9457. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  9458. function returncoolcolor(RainbowCycle) {
  9459. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  9460. }
  9461. mainContext.save();
  9462. if (tmpObj.currentReloads.primary < 0.999) {
  9463. mainContext.beginPath();
  9464. mainContext.lineCap = 'round';
  9465. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  9466. mainContext.lineWidth = 4;
  9467. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  9468. mainContext.stroke();
  9469. }
  9470. if (tmpObj.currentReloads.secondary < 0.999) {
  9471. mainContext.beginPath();
  9472. mainContext.lineCap = 'round';
  9473. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  9474. mainContext.lineWidth = 4;
  9475. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  9476. mainContext.stroke();
  9477. }
  9478. if (tmpObj.currentReloads.turret < 0.999) {
  9479. mainContext.beginPath();
  9480. mainContext.lineCap = 'round';
  9481. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  9482. mainContext.lineWidth = 4;
  9483. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  9484. mainContext.stroke();
  9485. }
  9486. mainContext.restore();
  9487. if(tmpObj.name != "unknown1l") {
  9488. // SHAME COUNT:
  9489. mainContext.globalAlpha = 1;
  9490. mainContext.font = "24px Hammersmith One";
  9491. mainContext.fillStyle = "#fff";
  9492. mainContext.strokeStyle = darkOutlineColor;
  9493. mainContext.textBaseline = "middle";
  9494. mainContext.textAlign = "center";
  9495. mainContext.lineWidth = 8;
  9496. mainContext.lineJoin = "round";
  9497. let tmpS = config.crownIconScale;
  9498. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  9499. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  9500. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  9501. }
  9502. // PLAYER TRACER:
  9503. if (!tmpObj.isTeam(player)) {
  9504. let center = {
  9505. x: screenWidth / 2,
  9506. y: screenHeight / 2,
  9507. };
  9508. 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);
  9509. let dist = center.y * alpha / 2;
  9510. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  9511. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  9512. mainContext.save();
  9513. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  9514. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  9515. let by = 255 - (tmpObj.sid * 2);
  9516. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  9517. mainContext.globalAlpha = alpha;
  9518. let renderTracer = function(s, ctx) {
  9519. ctx = ctx || mainContext;
  9520. let h = s * (Math.sqrt(3) / 2);
  9521. ctx.beginPath();
  9522. ctx.moveTo(0, -h / 1.5);
  9523. ctx.lineTo(-s / 2, h / 2);
  9524. ctx.lineTo(s / 2, h / 2);
  9525. ctx.lineTo(0, -h / 1.5);
  9526. ctx.fill();
  9527. ctx.closePath();
  9528. }
  9529. renderTracer(25, mainContext);
  9530. mainContext.restore();
  9531. }
  9532. if (getEl("predictType").value == "pre2") {
  9533. mainContext.lineWidth = 3;
  9534. mainContext.strokeStyle = "#fff";
  9535. mainContext.globalAlpha = 1;
  9536. mainContext.beginPath();
  9537. let render = {
  9538. x: tmpObj.x2 - xOffset,
  9539. y: tmpObj.y2 - yOffset
  9540. };
  9541. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9542. mainContext.lineTo(render.x, render.y);
  9543. mainContext.stroke();
  9544. } else if (getEl("predictType").value == "pre3") {
  9545. mainContext.lineWidth = 3;
  9546. mainContext.strokeStyle = "#cc5151";
  9547. mainContext.globalAlpha = 1;
  9548. mainContext.beginPath();
  9549. let render = {
  9550. x: tmpObj.x3 - xOffset,
  9551. y: tmpObj.y3 - yOffset
  9552. };
  9553. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9554. mainContext.lineTo(render.x, render.y);
  9555. mainContext.stroke();
  9556. }
  9557. }
  9558. }
  9559. }
  9560. }
  9561. if (player) {
  9562. // AUTOPUSH LINE:
  9563. if (my.autoPush && my.pushData) {
  9564. mainContext.lineWidth = 5;
  9565. mainContext.globalAlpha = 1;
  9566. mainContext.beginPath();
  9567. mainContext.strokeStyle = "white";
  9568. var x1 = player.x - xOffset;
  9569. var y1 = player.y - yOffset;
  9570. var x2 = my.pushData.x2 - xOffset;
  9571. var y2 = my.pushData.y2 - yOffset;
  9572. var x3 = my.pushData.x - xOffset;
  9573. var y3 = my.pushData.y - yOffset;
  9574. mainContext.moveTo(x1, y1);
  9575. mainContext.lineTo(x2, y2);
  9576. mainContext.lineTo(x3, y3);
  9577. mainContext.stroke();
  9578. var deltaX = x3 - x1;
  9579. var deltaY = y3 - y1;
  9580. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  9581. var maxDistance = 100;
  9582. var percentage = (distance / maxDistance) * 100;
  9583. percentage = Math.min(100, Math.max(0, percentage));
  9584. let spike;
  9585. mainContext.fillStyle = "white";
  9586. mainContext.strokeStyle = "black";
  9587. mainContext.lineWidth = 5;
  9588. mainContext.font = "30px Hammersmith One";
  9589. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  9590. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  9591. })[0];
  9592. if(nearTrap)
  9593. spike = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  9594. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  9595. })[0];
  9596. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  9597. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  9598. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  9599. mainContext.strokeText(near.aim2, xx, yy);
  9600. mainContext.fillText(near.aim2, xx, yy);
  9601. }
  9602. }
  9603. mainContext.globalAlpha = 1;
  9604. // RENDER ANIM TEXTS:
  9605. textManager.update(delta, mainContext, xOffset, yOffset);
  9606. // RENDER CHAT MESSAGES:
  9607. for (let i = 0; i < players.length; ++i) {
  9608. tmpObj = players[i];
  9609. if (tmpObj.visible) {
  9610. if (tmpObj.chatCountdown > 0) {
  9611. tmpObj.chatCountdown -= delta;
  9612. if (tmpObj.chatCountdown <= 0)
  9613. tmpObj.chatCountdown = 0;
  9614. mainContext.font = "32px Hammersmith One";
  9615. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  9616. mainContext.textBaseline = "middle";
  9617. mainContext.textAlign = "center";
  9618. let tmpX = tmpObj.x - xOffset;
  9619. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  9620. let tmpH = 47;
  9621. let tmpW = tmpSize.width + 17;
  9622. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  9623. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  9624. mainContext.fill();
  9625. mainContext.fillStyle = "#fff";
  9626. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  9627. }
  9628. if (tmpObj.chat.count > 0) {
  9629. if (!useWasd) {
  9630. tmpObj.chat.count -= delta;
  9631. if (tmpObj.chat.count <= 0)
  9632. tmpObj.chat.count = 0;
  9633. mainContext.font = "32px Hammersmith One";
  9634. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  9635. mainContext.textBaseline = "middle";
  9636. mainContext.textAlign = "center";
  9637. let tmpX = tmpObj.x - xOffset;
  9638. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  9639. let tmpH = 47;
  9640. let tmpW = tmpSize.width + 17;
  9641. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  9642. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  9643. mainContext.fill();
  9644. mainContext.fillStyle = "#ffffff99";
  9645. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  9646. } else {
  9647. tmpObj.chat.count = 0;
  9648. }
  9649. }
  9650. }
  9651. }
  9652. if (allChats.length) {
  9653. allChats.filter(ch => ch.active).forEach((ch) => {
  9654. if (!ch.alive) {
  9655. if (ch.alpha <= 1) {
  9656. ch.alpha += delta / 250;
  9657. if (ch.alpha >= 1) {
  9658. ch.alpha = 1;
  9659. ch.alive = true;
  9660. }
  9661. }
  9662. } else {
  9663. ch.alpha -= delta / 5000;
  9664. if (ch.alpha <= 0) {
  9665. ch.alpha = 0;
  9666. ch.active = false;
  9667. }
  9668. }
  9669. if (ch.active) {
  9670. mainContext.font = "20px Ubuntu";
  9671. let tmpSize = mainContext.measureText(ch.chat);
  9672. mainContext.textBaseline = "middle";
  9673. mainContext.textAlign = "center";
  9674. let tmpX = ch.x - xOffset;
  9675. let tmpY = ch.y - yOffset - 90;
  9676. let tmpH = 40;
  9677. let tmpW = tmpSize.width + 15;
  9678. mainContext.globalAlpha = ch.alpha;
  9679. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  9680. mainContext.strokeStyle = "rgb(25, 25, 25)";
  9681. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  9682. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  9683. mainContext.lineWidth = 5;
  9684. mainContext.fillStyle = "#ccc";
  9685. mainContext.strokeStyle = "rgb(25, 25, 25)";
  9686. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  9687. mainContext.stroke();
  9688. mainContext.fill();
  9689. mainContext.fillStyle = "#fff";
  9690. mainContext.strokeStyle = "#000";
  9691. mainContext.strokeText(ch.chat, tmpX, tmpY);
  9692. mainContext.fillText(ch.chat, tmpX, tmpY);
  9693. ch.y -= delta / 100;
  9694. }
  9695. });
  9696. }
  9697. mainContext.globalAlpha = 1;
  9698. // RENDER MINIMAP:
  9699. renderMinimap(delta);
  9700. }
  9701. // UPDATE & ANIMATE:
  9702. window.requestAnimFrame = function() {
  9703. return null;
  9704. }
  9705. window.rAF = (function() {
  9706. return window.requestAnimationFrame ||
  9707. window.webkitRequestAnimationFrame ||
  9708. window.mozRequestAnimationFrame ||
  9709. function(callback) {
  9710. window.setTimeout(callback, 1000/9);
  9711. };
  9712. })();
  9713. function doUpdate() {
  9714. //rape modulus
  9715. now = performance.now();
  9716. delta = now - lastUpdate;
  9717. lastUpdate = now;
  9718. let timer = performance.now();
  9719. let diff = timer - fpsTimer.last;
  9720. if (diff >= 1000) {
  9721. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  9722. fpsTimer.last = timer;
  9723. fpsTimer.time = 0;
  9724. }
  9725. fpsTimer.time++;
  9726. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  9727. getEl("packetStatus").innerHTML = secPacket;
  9728. updateGame();
  9729. rAF(doUpdate);
  9730. ms.avg = Math.round((ms.min+ms.max)/2);
  9731. }
  9732. prepareMenuBackground();
  9733. doUpdate();
  9734. function toggleUseless(boolean) {
  9735. getEl("instaType").disabled = boolean;
  9736. getEl("antiBullType").disabled = boolean;
  9737. getEl("predictType").disabled = boolean;
  9738. }
  9739. toggleUseless(useWasd);
  9740. let changeDays = {};
  9741. window.debug = function() {
  9742. my.waitHit = 0;
  9743. my.autoAim = false;
  9744. instaC.isTrue = false;
  9745. traps.inTrap = false;
  9746. itemSprites = [];
  9747. objSprites = [];
  9748. gameObjectSprites = [];
  9749. };
  9750. window.wasdMode = function() {
  9751. useWasd = !useWasd;
  9752. toggleUseless(useWasd);
  9753. };
  9754. window.startGrind = function() {
  9755. if (getEl("weaponGrind").checked) {
  9756. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  9757. checkPlace(player.getItemType(22), i);
  9758. }
  9759. }
  9760. };
  9761. // REMOVED!!! so they cant abuse :)
  9762. let projects = [
  9763. "adorable-eight-guppy",
  9764. "galvanized-bittersweet-windshield"
  9765. ];
  9766. let botIDS = 0;
  9767. window.connectFillBots = function() {
  9768. botSkts = [];
  9769. botIDS = 0;
  9770. for (let i = 0; i < projects.length; i++) {
  9771. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  9772. test.binaryType = "arraybuffer";
  9773. test.onopen = function() {
  9774. test.ssend = function(type) {
  9775. let data = Array.prototype.slice.call(arguments, 1);
  9776. let binary = window.msgpack.encode([type, data]);
  9777. test.send(binary);
  9778. };
  9779. for (let i = 0; i < 4; i++) {
  9780. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  9781. action: "homepage"
  9782. }).then(function(token) {
  9783. let t = WS.url.split("wss://")[1].split("?")[0];
  9784. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  9785. botSkts.push([test]);
  9786. botIDS++;
  9787. });
  9788. }
  9789. };
  9790. test.onmessage = function(message) {
  9791. let data = new Uint8Array(message.data);
  9792. let parsed = window.msgpack.decode(data);
  9793. let type = parsed[0];
  9794. data = parsed[1];
  9795. };
  9796. }
  9797. };
  9798. window.destroyFillBots = function() {
  9799. botSkts.forEach((socket) => {
  9800. socket[0].close();
  9801. });
  9802. botSkts = [];
  9803. };
  9804. window.tryConnectBots = function() {
  9805. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  9806. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  9807. action: "homepage"
  9808. }).then(function(token) {
  9809. // CONNECT SOCKET:
  9810. botSpawn(token);
  9811. });
  9812. }
  9813. };
  9814. window.destroyBots = function() {
  9815. bots.forEach((botyyyyy) => {
  9816. botyyyyy.closeSocket = true;
  9817. });
  9818. bots = [];
  9819. };
  9820. window.resBuild = function() {
  9821. if (gameObjects.length) {
  9822. gameObjects.forEach((tmp) => {
  9823. tmp.breakObj = false;
  9824. });
  9825. breakObjects = [];
  9826. }
  9827. };
  9828. window.toggleBotsCircle = function() {
  9829. player.circle = !player.circle;
  9830. };
  9831. window.toggleVisual = function() {
  9832. config.anotherVisual = !config.anotherVisual;
  9833. gameObjects.forEach((tmp) => {
  9834. if (tmp.active) {
  9835. tmp.dir = tmp.lastDir;
  9836. }
  9837. });
  9838. };
  9839. window.prepareUI = function(tmpObj) {
  9840. resize();
  9841. // CHAT STUFF:
  9842. var chatBox = document.getElementById("chatBox");
  9843. var chatHolder = document.getElementById("chatHolder");
  9844. var suggestBox = document.createElement("div");
  9845. suggestBox.id = "suggestBox";
  9846. var prevChats = [];
  9847. var prevChatsIndex = 0;
  9848. function toggleChat() {
  9849. if (!usingTouch) {
  9850. if (chatHolder.style.display == "block") {
  9851. if (chatBox.value) {
  9852. sendChat(chatBox.value);
  9853. }
  9854. closeChat();
  9855. } else {
  9856. storeMenu.style.display = "none";
  9857. allianceMenu.style.display = "none";
  9858. chatHolder.style.display = "block";
  9859. chatBox.focus();
  9860. resetMoveDir();
  9861. }
  9862. } else {
  9863. setTimeout(function () {
  9864. var chatMessage = prompt("chat message");
  9865. if (chatMessage) {
  9866. sendChat(chatMessage);
  9867. }
  9868. }, 1);
  9869. }
  9870. chatBox.value = "";
  9871. (() => {
  9872. prevChatsIndex = 0;
  9873. })();
  9874. }
  9875. function closeChat() {
  9876. chatBox.value = "";
  9877. chatHolder.style.display = "none";
  9878. }
  9879. // ACTION BAR:
  9880. UTILS.removeAllChildren(actionBar);
  9881. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  9882. (function (i) {
  9883. UTILS.generateElement({
  9884. id: "actionBarItem" + i,
  9885. class: "actionBarItem",
  9886. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  9887. onmouseout: function () {
  9888. showItemInfo();
  9889. },
  9890. parent: actionBar
  9891. });
  9892. })(i);
  9893. }
  9894. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  9895. (function (i) {
  9896. let tmpCanvas = document.createElement("canvas");
  9897. tmpCanvas.width = tmpCanvas.height = 66;
  9898. let tmpContext = tmpCanvas.getContext("2d");
  9899. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9900. tmpContext.imageSmoothingEnabled = false;
  9901. tmpContext.webkitImageSmoothingEnabled = false;
  9902. tmpContext.mozImageSmoothingEnabled = false;
  9903. if (items.weapons[i]) {
  9904. tmpContext.rotate((Math.PI));
  9905. let tmpSprite = new Image();
  9906. toolSprites[items.weapons[i].src] = tmpSprite;
  9907. tmpSprite.onload = function () {
  9908. this.isLoaded = true;
  9909. let tmpPad = 1 / (this.height / this.width);
  9910. let tmpMlt = (items.weapons[i].iPad || 1);
  9911. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  9912. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  9913. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  9914. tmpContext.globalCompositeOperation = "source-atop";
  9915. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  9916. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  9917. };
  9918. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  9919. let tmpUnit = getEl('actionBarItem' + i);
  9920. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  9921. // showItemInfo(items.weapons[i], true);
  9922. // });
  9923. tmpUnit.onclick = UTILS.checkTrusted(function () {
  9924. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  9925. });
  9926. UTILS.hookTouchEvents(tmpUnit);
  9927. } else {
  9928. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  9929. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  9930. tmpContext.globalAlpha = 1;
  9931. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  9932. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  9933. tmpContext.globalCompositeOperation = "source-atop";
  9934. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  9935. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  9936. let tmpUnit = getEl('actionBarItem' + i);
  9937. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  9938. // showItemInfo(items.list[i - items.weapons.length]);
  9939. // });
  9940. tmpUnit.onclick = UTILS.checkTrusted(function () {
  9941. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  9942. });
  9943. UTILS.hookTouchEvents(tmpUnit);
  9944. }
  9945. })(i);
  9946. }
  9947. };
  9948. window.profineTest = function(data) {
  9949. if (data) {
  9950. // VALIDATE NAME:
  9951. let name = data + "";
  9952. name = name.slice(0, config.maxNameLength);
  9953. return name;
  9954. }
  9955. };
  9956. this.slice(0, this.maxNameLength).replace(/[^\w:()/? -]+/gim, " ").replace(/[^\x00-\x7F]/g, " ").trim().toLowerCase().replace(/\s/g, "").replace(/1/g, "i").replace(/0/g, "o").replace(/5/g, "s".replace(/[^\w:()/? -]+/gim, " ")).replace(/[^\x00-\x7F]/g, " ").replace(/[^\w:()/? -]+/gim, " ").replace(/[^\x00-\x7F]/g, " ").trim().toLowerCase().replace(/\s/g, "").replace(/1/g, "i").replace(/0/g, "o").replace(/5/g, "s".replace(/[^\w:()/? -]+/gim, " ")).replace(/[^\x00-\x7F]/g, " ")