DiaMonD HAckEr Mod

Good script!

  1. // ==UserScript==
  2. // @name DiaMonD HAckEr Mod
  3. // @match *://*.moomoo.io/*
  4. // @version 3
  5. // @run-at document_idle
  6. // @grant none
  7. // @author zalupa_17431
  8. // @license MIT
  9. // @description Good script!
  10. // @namespace https://greasyfork.org/users/1256809
  11. // ==/UserScript==
  12.  
  13.  
  14. let founda = false;
  15.  
  16.  
  17. let scriptTags = document.getElementsByTagName("script");
  18. for (let i = 0; i < scriptTags.length; i++) {
  19. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  20. scriptTags[i].remove();
  21. founda = true;
  22. break;
  23. }
  24. }
  25.  
  26. document.addEventListener("keydown", function(event) {
  27. if (event.keyCode === 45) {
  28. const chatHolder = document.getElementById("gameUI");
  29. if (chatHolder) {
  30. const currentDisplay = chatHolder.style.display;
  31. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  32. }
  33. }
  34. });
  35. var styleItem = document.createElement("style");
  36. styleItem.type = "text/css";
  37. styleItem.appendChild(document.createTextNode(`
  38. #suggestBox {
  39. width: 355px;
  40. border-radius: 3px;
  41. background-color: rgba(0,0,0,0.5);
  42. margin: auto;
  43. text-align: left;
  44. z-index: 49;
  45. pointer-events: auto;
  46. position: relative;
  47. bottom: 3.5px;
  48. overflow-y: auto;
  49. }
  50. #suggestBox div {
  51. background-color: rgba(255,255,255,0);
  52. color: rgba(255,255,255,1);
  53. transition: background-color 0.3s, color 0.3s;
  54. }
  55. #suggestBox div:hover {
  56. background-color: rgba(255,255,255,0.2);
  57. color: rgba(0,0,0,1);
  58. }
  59. .suggestBoxHard {
  60. color: rgba(255,255,255,1);
  61. font-size: 18px;
  62. }
  63. .suggestBoxLight {
  64. color: rgba(255,255,255,0.7);
  65. font-size: 18px;
  66. }
  67. `));
  68. document.head.appendChild(styleItem);
  69.  
  70. window.addEventListener('load', function() {
  71. var allianceButton = document.getElementById('allianceButton');
  72. var storeButton = document.getElementById('storeButton');
  73. if (storeButton) {
  74. storeButton.style.right = '26px';
  75. storeButton.style.top = '420px';
  76. }
  77. if (allianceButton) {
  78. allianceButton.style.right = '26px';
  79. allianceButton.style.top = '479px';
  80. }
  81. });
  82.  
  83. function getEl(id) {
  84. return document.getElementById(id);
  85. }
  86.  
  87.  
  88.  
  89. let newFont = document.createElement("link");
  90. newFont.rel = "stylesheet";
  91. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  92. newFont.type = "text/css";
  93. document.body.append(newFont);
  94.  
  95. let min = document.createElement("script");
  96. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  97. document.body.append(min);
  98. window.oncontextmenu = function() {
  99. return false;
  100. };
  101.  
  102. let config = window.config;
  103.  
  104. // CLIENT:
  105. config.clientSendRate = 9; // Aim Packet Send Rate
  106. config.serverUpdateRate = 9;
  107.  
  108. // UI:
  109. config.deathFadeout = 0;
  110.  
  111. config.playerCapacity = 9999;
  112.  
  113. // CHECK IN SANDBOX:
  114. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  115.  
  116. // CUSTOMIZATION:
  117. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  118. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  119. "#8bc373", "#91b2db"
  120. ];
  121. config.weaponVariants = [{
  122. id: 0,
  123. src: "",
  124. xp: 0,
  125. val: 1,
  126. }, {
  127. id: 1,
  128. src: "_g",
  129. xp: 3000,
  130. val: 1.1,
  131. }, {
  132. id: 2,
  133. src: "_d",
  134. xp: 7000,
  135. val: 1.18,
  136. }, {
  137. id: 3,
  138. src: "_r",
  139. poison: true,
  140. xp: 12000,
  141. val: 1.18,
  142. }, {
  143. id: 4,
  144. src: "_e",
  145. poison: true,
  146. heal: true,
  147. xp: 24000,
  148. val: 1.18,
  149. }];
  150.  
  151. // VISUAL:
  152. config.anotherVisual = true;
  153. config.useWebGl = false;
  154. config.resetRender = true;
  155.  
  156. function waitTime(timeout) {
  157. return new Promise((done) => {
  158. setTimeout(() => {
  159. done();
  160. }, timeout);
  161. });
  162. }
  163.  
  164. let botSkts = [];
  165.  
  166. // STORAGE:
  167. let canStore;
  168. if (typeof(Storage) !== "undefined") {
  169. canStore = true;
  170. }
  171.  
  172. function saveVal(name, val) {
  173. if (canStore)
  174. localStorage.setItem(name, val);
  175. }
  176.  
  177. function deleteVal(name) {
  178. if (canStore)
  179. localStorage.removeItem(name);
  180. }
  181.  
  182. function getSavedVal(name) {
  183. if (canStore)
  184. return localStorage.getItem(name);
  185. return null;
  186. }
  187.  
  188. // CONFIGS:
  189. let gC = function(a, b) {
  190. try {
  191. let res = JSON.parse(getSavedVal(a));
  192. if (typeof res === "object") {
  193. return b;
  194. } else {
  195. return res;
  196. }
  197. } catch (e) {
  198. alert("dieskid");
  199. return b;
  200. }
  201. };
  202.  
  203. function setCommands() {
  204. return {
  205. "help": {
  206. desc: "Show Commands",
  207. action: function(message) {
  208. for (let cmds in commands) {
  209. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  210. }
  211. }
  212. },
  213. "clear": {
  214. desc: "Clear Chats",
  215. action: function(message) {
  216. resetMenuChText();
  217. }
  218. },
  219. "debug": {
  220. desc: "Debug Mod For Development",
  221. action: function(message) {
  222. addDeadPlayer(player);
  223. addMenuChText("Debug", "Done", "#99ee99", 1);
  224. }
  225. },
  226. "play": {
  227. desc: "Play Music ( /play [link] )",
  228. action: function(message) {
  229. let link = message.split(" ");
  230. if (link[1]) {
  231. let audio = new Audio(link[1]);
  232. audio.play();
  233. } else {
  234. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  235. }
  236. }
  237. },
  238. "bye": {
  239. desc: "Leave Game",
  240. action: function(message) {
  241. window.leave();
  242. }
  243. },
  244. };
  245. }
  246.  
  247. function setConfigs() {
  248. return {
  249. killChat: false,
  250. autoBuy: true,
  251. autoBuyEquip: true,
  252. autoPush: true,
  253. revTick: true,
  254. spikeTick: true,
  255. predictTick: true,
  256. autoPlace: true,
  257. autoReplace: true,
  258. antiTrap: true,
  259. slowOT: false,
  260. attackDir: false,
  261. showDir: false,
  262. autoRespawn: false
  263. };
  264. }
  265.  
  266. let commands = setCommands();
  267. let configs = setConfigs();
  268.  
  269. window.removeConfigs = function() {
  270. for (let cF in configs) {
  271. deleteVal(cF, configs[cF]);
  272. }
  273. };
  274.  
  275. for (let cF in configs) {
  276. configs[cF] = gC(cF, configs[cF]);
  277. }
  278.  
  279. // MENU FUNCTIONS:
  280. window.changeMenu = function() {};
  281. window.debug = function() {};
  282. window.wasdMode = function() {};
  283.  
  284. // PAGE 1:
  285. window.startGrind = function() {};
  286.  
  287. // PAGE 3:
  288. window.connectFillBots = function() {};
  289. window.destroyFillBots = function() {};
  290. window.tryConnectBots = function() {};
  291. window.destroyBots = function() {};
  292. window.resBuild = function() {};
  293. window.toggleBotsCircle = function() {};
  294. window.toggleVisual = function() {};
  295.  
  296. // SOME FUNCTIONS:
  297. window.prepareUI = function() {};
  298. window.leave = function() {};
  299.  
  300. // nah hahahahahhh why good ping
  301. window.ping = 0;
  302.  
  303. class deadfuturechickenmodrevival {
  304. constructor(flarez, lore) {
  305. this.inGame = false;
  306. this.lover = flarez + lore;
  307. this.baby = "ae86";
  308. this.isBlack = 0;
  309. this.webSocket = undefined;
  310. this.checkBaby = function() {
  311. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  312. if (this.isBlack >= 1) return "bl4cky";
  313. return "noting for you";
  314. };
  315. this.x2 = 0;
  316. this.y2 = 0;
  317. this.chat = "Imagine playing this badass game XDDDDD";
  318. this.summon = function(tmpObj) {
  319. this.x2 = tmpObj.x;
  320. this.y2 = tmpObj.y;
  321. this.chat = tmpObj.name + " ur so bad XDDDD";
  322. };
  323. this.commands = function(cmd) {
  324. cmd == "rv3link" && window.open("https://florr.io/");
  325. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  326. return cmd;
  327. };
  328. this.dayte = "11yearold";
  329. this.memeganoob = "69yearold";
  330. this.startDayteSpawn = function(tmpObj) {
  331. let ratio = setInterval(() => {
  332. this.x2 = tmpObj.x + 20;
  333. this.y2 = tmpObj.y - 20;
  334. this.chat = "UR SO BAD LOL";
  335. if (tmpObj.name == "ae86") {
  336. this.chat = "omg ae86 go run";
  337. setTimeout(() => {
  338. this.inGame = false;
  339. clearInterval(ratio);
  340. }, 1000);
  341. }
  342. }, 1234);
  343. };
  344. this.AntiChickenModV69420 = function(tmpObj) {
  345. return "!c!dc user " + tmpObj.name;
  346. };
  347. }
  348. };
  349. class HtmlAction {
  350. constructor(element) {
  351. this.element = element;
  352. };
  353. add(code) {
  354. if (!this.element) return undefined;
  355. this.element.innerHTML += code;
  356. };
  357. newLine(amount) {
  358. let result = `<br>`;
  359. if (amount > 0) {
  360. result = ``;
  361. for (let i = 0; i < amount; i++) {
  362. result += `<br>`;
  363. }
  364. }
  365. this.add(result);
  366. };
  367. checkBox(setting) {
  368. let newCheck = `<input type = "checkbox"`;
  369. setting.id && (newCheck += ` id = ${setting.id}`);
  370. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  371. setting.class && (newCheck += ` class = ${setting.class}`);
  372. setting.checked && (newCheck += ` checked`);
  373. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  374. newCheck += `>`;
  375. this.add(newCheck);
  376. };
  377. text(setting) {
  378. let newText = `<input type = "text"`;
  379. setting.id && (newText += ` id = ${setting.id}`);
  380. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  381. setting.class && (newText += ` class = ${setting.class}`);
  382. setting.size && (newText += ` size = ${setting.size}`);
  383. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  384. setting.value && (newText += ` value = ${setting.value}`);
  385. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  386. newText += `>`;
  387. this.add(newText);
  388. };
  389. select(setting) {
  390. let newSelect = `<select`;
  391. setting.id && (newSelect += ` id = ${setting.id}`);
  392. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  393. setting.class && (newSelect += ` class = ${setting.class}`);
  394. newSelect += `>`;
  395. for (let options in setting.option) {
  396. newSelect += `<option value = ${setting.option[options].id}`
  397. setting.option[options].selected && (newSelect += ` selected`);
  398. newSelect += `>${options}</option>`;
  399. }
  400. newSelect += `</select>`;
  401. this.add(newSelect);
  402. };
  403. button(setting) {
  404. let newButton = `<button`;
  405. setting.id && (newButton += ` id = ${setting.id}`);
  406. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  407. setting.class && (newButton += ` class = ${setting.class}`);
  408. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  409. newButton += `>`;
  410. setting.innerHTML && (newButton += setting.innerHTML);
  411. newButton += `</button>`;
  412. this.add(newButton);
  413. };
  414. selectMenu(setting) {
  415. let newSelect = `<select`;
  416. if (!setting.id) {
  417. alert("please put id skid");
  418. return;
  419. }
  420. window[setting.id + "Func"] = function() {};
  421. setting.id && (newSelect += ` id = ${setting.id}`);
  422. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  423. setting.class && (newSelect += ` class = ${setting.class}`);
  424. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  425. newSelect += `>`;
  426. let last;
  427. let i = 0;
  428. for (let options in setting.menu) {
  429. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  430. setting.menu[options] && (newSelect += ` checked`);
  431. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  432. i++;
  433. }
  434. newSelect += `</select>`;
  435.  
  436. this.add(newSelect);
  437.  
  438. i = 0;
  439. for (let options in setting.menu) {
  440. window[options + "Func"] = function() {
  441. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  442. saveVal(options, setting.menu[options]);
  443.  
  444. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  445. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  446.  
  447. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  448.  
  449. };
  450. this.checkBox({
  451. id: "check_" + options,
  452. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  453. class: "checkB",
  454. onclick: `window.${options + "Func"}()`,
  455. checked: setting.menu[options]
  456. });
  457. i++;
  458. }
  459.  
  460. last = "check_" + getEl(setting.id).value.split("_")[1];
  461. window[setting.id + "Func"] = function() {
  462. getEl(last).style.display = "none";
  463. last = "check_" + getEl(setting.id).value.split("_")[1];
  464. getEl(last).style.display = "inline-block";
  465.  
  466. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  467.  
  468. };
  469. };
  470. };
  471. class Html {
  472. constructor() {
  473. this.element = null;
  474. this.action = null;
  475. this.divElement = null;
  476. this.startDiv = function(setting, func) {
  477.  
  478. let newDiv = document.createElement("div");
  479. setting.id && (newDiv.id = setting.id);
  480. setting.style && (newDiv.style = setting.style);
  481. setting.class && (newDiv.className = setting.class);
  482. this.element.appendChild(newDiv);
  483. this.divElement = newDiv;
  484.  
  485. let addRes = new HtmlAction(newDiv);
  486. typeof func == "function" && func(addRes);
  487.  
  488. };
  489. this.addDiv = function(setting, func) {
  490.  
  491. let newDiv = document.createElement("div");
  492. setting.id && (newDiv.id = setting.id);
  493. setting.style && (newDiv.style = setting.style);
  494. setting.class && (newDiv.className = setting.class);
  495. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  496. this.divElement = newDiv;
  497.  
  498. let addRes = new HtmlAction(newDiv);
  499. typeof func == "function" && func(addRes);
  500.  
  501. };
  502. };
  503. set(id) {
  504. this.element = getEl(id);
  505. this.action = new HtmlAction(this.element);
  506. };
  507. resetHTML(text) {
  508. if (text) {
  509. this.element.innerHTML = ``;
  510. } else {
  511. this.element.innerHTML = ``;
  512. }
  513. };
  514. setStyle(style) {
  515. this.element.style = style;
  516. };
  517. setCSS(style) {
  518. this.action.add(`<style>` + style + `</style>`);
  519. };
  520. };
  521.  
  522. let HTML = new Html();
  523.  
  524. let menuDiv = document.createElement("div");
  525. menuDiv.id = "menuDiv";
  526. menuDiv.draggable = true;
  527.  
  528. menuDiv.addEventListener("dragstart", function (e) {
  529. e.dataTransfer.setData("text/plain", "");
  530. });
  531.  
  532. document.addEventListener("dragover", function (e) {
  533. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  534. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  535. });
  536.  
  537. document.body.appendChild(menuDiv);
  538. HTML.set("menuDiv");
  539. HTML.setStyle(`
  540. position: absolute;
  541. left: 20px;
  542. top: 20px;
  543. `);
  544. HTML.resetHTML();
  545. HTML.setCSS(`
  546. .menuClass{
  547. color: #fff;
  548. font-size: 31px;
  549. text-align: left;
  550. padding: 10px;
  551. padding-top: 7px;
  552. padding-bottom: 5px;
  553. width: 300px;
  554. background-color: rgba(0, 0, 0, 0.25);
  555. -webkit-border-radius: 4px;
  556. -moz-border-radius: 4px;
  557. border-radius: 4px;
  558. }
  559. .menuC {
  560. display: none;
  561. font-family: "Hammersmith One";
  562. font-size: 12px;
  563. max-height: 180px;
  564. overflow-y: scroll;
  565. -webkit-touch-callout: none;
  566. -webkit-user-select: none;
  567. -khtml-user-select: none;
  568. -moz-user-select: none;
  569. -ms-user-select: none;
  570. user-select: none;
  571. }
  572. .menuB {
  573. text-align: center;
  574. background-color: rgb(25, 25, 25);
  575. color: #fff;
  576. -webkit-border-radius: 4px;
  577. -moz-border-radius: 4px;
  578. border-radius: 4px;
  579. border: 2px solid #000;
  580. cursor: pointer;
  581. }
  582. .menuB:hover {
  583. border: 2px solid #fff;
  584. }
  585. .menuB:active {
  586. color: rgb(25, 25, 25);
  587. background-color: rgb(200, 200, 200);
  588. }
  589. .customText {
  590. color: #000;
  591. -webkit-border-radius: 4px;
  592. -moz-border-radius: 4px;
  593. border-radius: 4px;
  594. border: 2px solid #000;
  595. }
  596. .customText:focus {
  597. background-color: yellow;
  598. }
  599. .checkB {
  600. position: relative;
  601. top: 2px;
  602. accent-color: #888;
  603. cursor: pointer;
  604. }
  605. .Cselect {
  606. -webkit-border-radius: 4px;
  607. -moz-border-radius: 4px;
  608. border-radius: 4px;
  609. background-color: rgb(75, 75, 75);
  610. color: #fff;
  611. border: 1px solid #000;
  612. }
  613. #menuChanger {
  614. position: absolute;
  615. right: 10px;
  616. top: 10px;
  617. background-color: rgba(0, 0, 0, 0);
  618. color: #fff;
  619. border: none;
  620. cursor: pointer;
  621. }
  622. #menuChanger:hover {
  623. color: #000;
  624. }
  625. ::-webkit-scrollbar {
  626. width: 10px;
  627. }
  628. ::-webkit-scrollbar-track {
  629. opacity: 0;
  630. }
  631. ::-webkit-scrollbar-thumb {
  632. background-color: rgb(25, 25, 25);
  633. -webkit-border-radius: 4px;
  634. -moz-border-radius: 4px;
  635. border-radius: 4px;
  636. }
  637. ::-webkit-scrollbar-thumb:active {
  638. background-color: rgb(230, 230, 230);
  639. }
  640. `);
  641. HTML.startDiv({
  642. id: "menuHeadLine",
  643. class: "menuClass"
  644. }, (html) => {
  645. html.add(`DiaMonD HAckEr mod:`);
  646. html.button({
  647. id: "menuChanger",
  648. class: "material-icons",
  649. innerHTML: `sync(do not)`,
  650. onclick: "window.changeMenu()"
  651. });
  652. HTML.addDiv({
  653. id: "menuButtons",
  654. style: "display: block; overflow-y: visible;",
  655. class: "menuC",
  656. appendID: "menuHeadLine"
  657. }, (html) => {
  658. html.button({
  659. class: "menuB",
  660. innerHTML: "Debug",
  661. onclick: "window.debug()"
  662. });
  663. });
  664. HTML.addDiv({
  665. id: "menuMain",
  666. style: "display: block",
  667. class: "menuC",
  668. appendID: "menuHeadLine"
  669. }, (html) => {
  670. html.button({
  671. class: "menuB",
  672. innerHTML: "Toggle Wasd Mode",
  673. onclick: "window.wasdMode()"
  674. });
  675. html.newLine();
  676. html.add(`Auto Grind: `);
  677. html.checkBox({
  678. id: "weaponGrind",
  679. class: "checkB",
  680. onclick: "window.startGrind()"
  681. });
  682. html.newLine(2);
  683. HTML.addDiv({
  684. style: "font-size: 20px; color: #99ee99;",
  685. appendID: "menuMain"
  686. }, (html) => {
  687. html.add(`Developing Settings:`);
  688. });
  689. html.add(`AntiPushing xd:`);
  690. html.checkBox({
  691. id: "antipush",
  692. class: "checkB",
  693. checked: true
  694. });
  695. html.newLine();
  696. html.add(`New BETA heal:`);
  697. html.checkBox({
  698. id: "healingBeta",
  699. class: "checkB",
  700. checked: true
  701. });
  702. html.newLine();
  703. });
  704. HTML.addDiv({
  705. id: "menuConfig",
  706. class: "menuC",
  707. appendID: "menuHeadLine"
  708. }, (html) => {
  709. html.add(`AutoPlacer Placement Tick: `);
  710. html.text({
  711. id: "autoPlaceTick",
  712. class: "customText",
  713. value: "2",
  714. size: "2em",
  715. maxLength: "1"
  716. });
  717. html.newLine();
  718. html.add(`Configs: `);
  719. html.selectMenu({
  720. id: "configsChanger",
  721. class: "Cselect",
  722. menu: configs
  723. });
  724. html.newLine();
  725. html.add(`InstaKill Type: `);
  726. html.select({
  727. id: "instaType",
  728. class: "Cselect",
  729. option: {
  730. OneShot: {
  731. id: "oneShot",
  732. selected: true
  733. },
  734. Spammer: {
  735. id: "spammer"
  736. }
  737. }
  738. });
  739. html.newLine();
  740. html.add(`AntiDiaX Type: `);
  741. html.select({
  742. id: "antiBullType",
  743. class: "Cselect",
  744. option: {
  745. "Disable AntiBull": {
  746. id: "noab",
  747. selected: true
  748. },
  749. "When Reloaded": {
  750. id: "abreload",
  751. },
  752. "Primary Reloaded": {
  753. id: "abalway"
  754. }
  755. }
  756. });
  757. html.newLine();
  758. html.add(`Backup Nobull Insta: `);
  759. html.checkBox({
  760. id: "backupNobull",
  761. class: "checkB",
  762. checked: true
  763. });
  764. html.newLine();
  765. html.add(`Turret Gear Combat Assistance: `);
  766. html.checkBox({
  767. id: "turretCombat",
  768. class: "checkB"
  769. });
  770. html.newLine();
  771. html.add(`Safe AntiSpikeTick: `);
  772. html.checkBox({
  773. id: "safeAntiSpikeTick",
  774. class: "checkB",
  775. checked: true
  776. });
  777. html.newLine();
  778. });
  779. HTML.addDiv({
  780. id: "menuOther",
  781. class: "menuC",
  782. appendID: "menuHeadLine"
  783. }, (html) => {
  784. html.button({
  785. class: "menuB",
  786. innerHTML: "Connect Bots",
  787. onclick: "window.tryConnectBots()"
  788. });
  789. html.button({
  790. class: "menuB",
  791. innerHTML: "Disconnect Bots",
  792. onclick: "window.destroyBots()"
  793. });
  794. html.newLine();
  795. html.button({
  796. class: "menuB",
  797. innerHTML: "Connect FBots",
  798. onclick: "window.connectFillBots()"
  799. });
  800. html.button({
  801. class: "menuB",
  802. innerHTML: "Disconnect FBots",
  803. onclick: "window.destroyFillBots()"
  804. });
  805. html.newLine();
  806. html.button({
  807. class: "menuB",
  808. innerHTML: "Reset Break Objects",
  809. onclick: "window.resBuild()"
  810. });
  811. html.newLine();
  812. html.add(`Break Objects Range: `);
  813. html.text({
  814. id: "breakRange",
  815. class: "customText",
  816. value: "700",
  817. size: "3em",
  818. maxLength: "4"
  819. });
  820. html.newLine();
  821. html.add(`Predict Movement Type: `);
  822. html.select({
  823. id: "predictType",
  824. class: "Cselect",
  825. option: {
  826. "Disable Render": {
  827. id: "disableRender",
  828. selected: true
  829. },
  830. "X/Y and 2": {
  831. id: "pre2",
  832. },
  833. "X/Y and 3": {
  834. id: "pre3"
  835. }
  836. }
  837. });
  838. html.newLine();
  839. html.add(`Render Placers: `);
  840. html.checkBox({
  841. id: "placeVis",
  842. class: "checkB",
  843. });
  844. html.newLine();
  845. html.add(`Bot Mode: `);
  846. html.select({
  847. id: "mode",
  848. class: "Cselect",
  849. option: {
  850. "Clear Building": {
  851. id: "clear",
  852. selected: true
  853. },
  854. "Sync": {
  855. id: "zync",
  856. },
  857. "Search": {
  858. id: "zearch"
  859. },
  860. "Clear Everything": {
  861. id: "fuckemup"
  862. },
  863. "Flex": {
  864. id: "flex"
  865. }
  866. }
  867. });
  868. html.newLine(2);
  869. html.button({
  870. class: "menuB",
  871. innerHTML: "Toggle Fbots Circle",
  872. onclick: "window.toggleBotsCircle()"
  873. });
  874. html.newLine();
  875. html.add(`Circle Rad: `);
  876. html.text({
  877. id: "circleRad",
  878. class: "customText",
  879. value: "200",
  880. size: "3em",
  881. maxLength: "4"
  882. });
  883. html.newLine();
  884. html.add(`Rad Speed: `);
  885. html.text({
  886. id: "radSpeed",
  887. class: "customText",
  888. value: "0.1",
  889. size: "2em",
  890. maxLength: "3"
  891. });
  892. html.newLine();
  893. html.add(`Bot Zetup Type: `);
  894. html.select({
  895. id: "setup",
  896. class: "Cselect",
  897. option: {
  898. "Dagger Musket": {
  899. id: "dm",
  900. selected: true
  901. },
  902. "Katana Hammer": {
  903. id: "kh",
  904. },
  905. "Dagger Repeater-Crossbow": {
  906. id: "dr"
  907. },
  908. "Zhort-Zword Muzket": {
  909. id: "zd"
  910. }
  911. }
  912. });
  913. html.newLine(2);
  914. html.add(`Cross World: `);
  915. html.checkBox({
  916. id: "funni",
  917. class: "checkB"
  918. });
  919. html.newLine();
  920. html.button({
  921. class: "menuB",
  922. innerHTML: "Toggle Another Visual",
  923. onclick: "window.toggleVisual()"
  924. });
  925. html.newLine();
  926. });
  927. });
  928.  
  929. let menuChatDiv = document.createElement("div");
  930. menuChatDiv.id = "menuChatDiv";
  931. document.body.appendChild(menuChatDiv);
  932. HTML.set("menuChatDiv");
  933. HTML.setStyle(`
  934. position: absolute;
  935. display: none;
  936. left: 0px;
  937. top: 25px;
  938. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  939. `);
  940. HTML.resetHTML();
  941. HTML.setCSS(`
  942. .chDiv {
  943. color: #fff;
  944. padding: 10px;
  945. width: 357px;
  946. height: 217px;
  947. background-color: rgba(0, 0, 0, 0.2);
  948. font-family: "HammerSmith One", monospace;
  949. // border-radius: 15px;
  950. // box-shadow: black 1px 2px 19px;
  951. //backdrop-filter: blur(3px);
  952.  
  953. }
  954. .chMainDiv {
  955. font-family: "Ubuntu";
  956. font-size: 16px;
  957. max-height: 215px;
  958. overflow-y: scroll;
  959. scrollbar-width: thin;
  960. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  961. -webkit-touch-callout: none;
  962. -webkit-user-select: none;
  963. -khtml-user-select: none;
  964. -moz-user-select: none;
  965. -ms-user-select: none;
  966. user-select: none;
  967. overflow-x: hidden;
  968. }
  969. .chMainDiv::-webkit-scrollbar {
  970. width: 8px;
  971. }
  972. .chMainDiv::-webkit-scrollbar-thumb {
  973. background-color: rgba(0, 0, 0, 0.5);
  974. }
  975. .chMainDiv::-webkit-scrollbar-thumb:hover {
  976. background-color: rgba(0, 0, 0, 0.7);
  977. }
  978. .chMainBox {
  979. display:none;
  980. position: absolute;
  981. left: 10px;
  982. bottom: 10px;
  983. width: 380px;
  984. height: 25px;
  985. background-color: rgba(255, 255, 255, 0.1);
  986. border-radius: 5px;
  987. color: rgba(255, 255, 255, 0.75);
  988. font-family: "HammerSmith One";
  989. font-size: 12px;
  990. }
  991. `);
  992. HTML.startDiv({
  993. id: "mChDiv",
  994. class: "chDiv"
  995. }, (html) => {
  996. HTML.addDiv({
  997. id: "mChMain",
  998. class: "chMainDiv",
  999. appendID: "mChDiv"
  1000. }, (html) => {});
  1001. html.text({
  1002. id: "mChBox",
  1003. class: "chMainBox",
  1004. // placeHolder: `To chat click here or press "Enter" key`
  1005. });
  1006. });
  1007.  
  1008. let menuChats = getEl("mChMain");
  1009. let menuChatBox = getEl("mChBox");
  1010. let menuCBFocus = false;
  1011. let menuChCounts = 0;
  1012.  
  1013. menuChatBox.value = "";
  1014. menuChatBox.addEventListener("focus", () => {
  1015. menuCBFocus = true;
  1016. });
  1017. menuChatBox.addEventListener("blur", () => {
  1018. menuCBFocus = false;
  1019. });
  1020.  
  1021. function addMenuChText(name, message, color, noTimer) {
  1022. HTML.set("menuChatDiv");
  1023. color = color || "white";
  1024. let time = new Date();
  1025. let min = time.getMinutes();
  1026. let hour = time.getHours();
  1027. let text = ``;
  1028. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1029. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1030. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1031. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1032. html.add(text);
  1033. });
  1034. menuChats.scrollTop = menuChats.scrollHeight;
  1035. menuChCounts++;
  1036. }
  1037. function chch(name, message, color, noTimer) {
  1038. HTML.set("menuChatDiv");
  1039. color = color || "white";
  1040. let time = new Date();
  1041. let text = ``;
  1042. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1043. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1044. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1045. html.add(text);
  1046. });
  1047. menuChats.scrollTop = menuChats.scrollHeight;
  1048. menuChCounts++;
  1049. }
  1050.  
  1051. function resetMenuChText() {
  1052. menuChats.innerHTML = ``;
  1053. menuChCounts = 0;
  1054. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1055. }
  1056. resetMenuChText();
  1057.  
  1058. let menuIndex = 0;
  1059. let menus = ["menuMain", "menuConfig", "menuOther"];
  1060. window.changeMenu = function() {
  1061. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1062. menuIndex++;
  1063. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1064. };
  1065.  
  1066. let mStatus = document.createElement("div");
  1067. mStatus.id = "status";
  1068. getEl("gameUI").appendChild(mStatus);
  1069. HTML.set("status");
  1070. HTML.setStyle(`
  1071. display: block;
  1072. position: absolute;
  1073. color: #ddd;
  1074. font: 15px Hammersmith One;
  1075. bottom: 215px;
  1076. left: 20px;
  1077. `);
  1078. HTML.resetHTML();
  1079. HTML.setCSS(`
  1080. .sizing {
  1081. font-size: 15px;
  1082. }
  1083. .mod {
  1084. font-size: 15px;
  1085. display: inline-block;
  1086. }
  1087. `);
  1088. HTML.startDiv({
  1089. id: "uehmod",
  1090. class: "sizing"
  1091. }, (html) => {
  1092. html.add(`Ping: `);
  1093. HTML.addDiv({
  1094. id: "pingFps",
  1095. class: "mod",
  1096. appendID: "uehmod"
  1097. }, (html) => {
  1098. html.add("None");
  1099. });
  1100. html.newLine();
  1101. html.add(`Packet: `);
  1102. HTML.addDiv({
  1103. id: "packetStatus",
  1104. class: "mod",
  1105. appendID: "uehmod"
  1106. }, (html) => {
  1107. html.add("None");
  1108. });
  1109. });
  1110.  
  1111. /*function modLog() {
  1112. let logs = [];
  1113. for (let i = 0; i < arguments.length; i++) {
  1114. logs.push(arguments[i]);
  1115. }
  1116. getEl("modLog").innerHTML = logs;
  1117. }*/
  1118.  
  1119. let openMenu = false;
  1120.  
  1121. let WS = undefined;
  1122. let socketID = undefined;
  1123.  
  1124. let useWasd = false;
  1125. let secPacket = 0;
  1126. let secMax = 120;
  1127. let secTime = 1000;
  1128. let firstSend = {
  1129. sec: false
  1130. };
  1131. let game = {
  1132. tick: 0,
  1133. tickQueue: [],
  1134. tickBase: function(set, tick) {
  1135. if (this.tickQueue[this.tick + tick]) {
  1136. this.tickQueue[this.tick + tick].push(set);
  1137. } else {
  1138. this.tickQueue[this.tick + tick] = [set];
  1139. }
  1140. },
  1141. tickRate: (1000 / config.serverUpdateRate),
  1142. tickSpeed: 0,
  1143. lastTick: performance.now()
  1144. };
  1145. let modConsole = [];
  1146.  
  1147. let dontSend = false;
  1148. let fpsTimer = {
  1149. last: 0,
  1150. time: 0,
  1151. ltime: 0
  1152. }
  1153. let lastMoveDir = undefined;
  1154. let lastsp = ["cc", 1, "__proto__"];
  1155.  
  1156. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1157. WebSocket.prototype.send = function(message) {
  1158. if (!WS) {
  1159. WS = this;
  1160. WS.addEventListener("message", function(msg) {
  1161. getMessage(msg);
  1162. });
  1163. WS.addEventListener("close", (event) => {
  1164. if (event.code == 4001) {
  1165. window.location.reload();
  1166. }
  1167. });
  1168. }
  1169. if (WS == this) {
  1170. dontSend = false;
  1171.  
  1172. // EXTRACT DATA ARRAY:
  1173. let data = new Uint8Array(message);
  1174. let parsed = window.msgpack.decode(data);
  1175. let type = parsed[0];
  1176. data = parsed[1];
  1177.  
  1178. // SEND MESSAGE:
  1179. if (type == "6") {
  1180.  
  1181. if (data[0]) {
  1182. // ANTI PROFANITY:
  1183. let profanity = ["cunt", "whore", "fuck", "shit", "faggot", "nigger", "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex", "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune", "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard", ];
  1184. let tmpString;
  1185. profanity.forEach((profany) => {
  1186. if (data[0].indexOf(profany) > -1) {
  1187. tmpString = "";
  1188. for (let i = 0; i < profany.length; ++i) {
  1189. if (i == 1) {
  1190. tmpString += String.fromCharCode(0);
  1191. }
  1192. tmpString += profany[i];
  1193. }
  1194. let re = new RegExp(profany, "g");
  1195. data[0] = data[0].replace(re, tmpString);
  1196. }
  1197. });
  1198.  
  1199. // FIX CHAT:
  1200. data[0] = data[0].slice(0, 30);
  1201. }
  1202.  
  1203. } else if (type == "L") {
  1204. // MAKE SAME CLAN:
  1205. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1206. data[0] = data[0].slice(0, 7);
  1207. } else if (type == "M") {
  1208. // APPLY CYAN COLOR:
  1209. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1210. data[0].moofoll = true;
  1211. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1212. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1213. } else if (type == "D") {
  1214. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1215. dontSend = true;
  1216. } else {
  1217. my.lastDir = data[0];
  1218. }
  1219. } else if (type == "d") {
  1220. if (!data[2]) {
  1221. dontSend = true;
  1222. } else {
  1223. if (![null, undefined].includes(data[1])) {
  1224. my.lastDir = data[1];
  1225. }
  1226. }
  1227. } else if (type == "K") {
  1228. if (!data[1]) {
  1229. dontSend = true;
  1230. }
  1231. } else if (type == "S") {
  1232. instaC.wait = !instaC.wait;
  1233. dontSend = true;
  1234. } else if (type == "a") {
  1235. if (data[1]) {
  1236. if (player.moveDir == data[0]) {
  1237. dontSend = true;
  1238. }
  1239. player.moveDir = data[0];
  1240. } else {
  1241. dontSend = true;
  1242. }
  1243. }
  1244. if (!dontSend) {
  1245. let binary = window.msgpack.encode([type, data]);
  1246. this.nsend(binary);
  1247.  
  1248. // START COUNT:
  1249. if (!firstSend.sec) {
  1250. firstSend.sec = true;
  1251. setTimeout(() => {
  1252. firstSend.sec = false;
  1253. secPacket = 0;
  1254. }, secTime);
  1255. }
  1256.  
  1257. secPacket++;
  1258. }
  1259. } else {
  1260. this.nsend(message);
  1261. }
  1262. }
  1263.  
  1264. function packet(type) {
  1265. // EXTRACT DATA ARRAY:
  1266. let data = Array.prototype.slice.call(arguments, 1);
  1267.  
  1268. // SEND MESSAGE:
  1269. let binary = window.msgpack.encode([type, data]);
  1270. WS.send(binary);
  1271. }
  1272.  
  1273. function origPacket(type) {
  1274. // EXTRACT DATA ARRAY:
  1275. let data = Array.prototype.slice.call(arguments, 1);
  1276.  
  1277. // SEND MESSAGE:
  1278. let binary = window.msgpack.encode([type, data]);
  1279. WS.nsend(binary);
  1280. }
  1281.  
  1282. window.leave = function() {
  1283. origPacket("kys", {
  1284. "frvr is so bad": true,
  1285. "sidney is too good": true,
  1286. "dev are too weak": true,
  1287. });
  1288. };
  1289.  
  1290. //...lol
  1291. let io = {
  1292. send: packet
  1293. };
  1294.  
  1295. function getMessage(message) {
  1296. let data = new Uint8Array(message.data);
  1297. let parsed = window.msgpack.decode(data);
  1298. let type = parsed[0];
  1299. data = parsed[1];
  1300. let events = {
  1301. A: setInitData, // id: setInitData,
  1302. //B: disconnect,
  1303. C: setupGame, // 1: setupGame,
  1304. D: addPlayer, // 2: addPlayer,
  1305. E: removePlayer, // 4: removePlayer,
  1306. a: updatePlayers, // 33: updatePlayers,
  1307. G: updateLeaderboard, // 5: updateLeaderboard,here
  1308. H: loadGameObject, // 6: loadGameObject,
  1309. I: loadAI, // a: loadAI,
  1310. J: animateAI, // aa: animateAI,
  1311. K: gatherAnimation, // 7: gatherAnimation,
  1312. L: wiggleGameObject, // 8: wiggleGameObject,
  1313. M: shootTurret, // sp: shootTurret,
  1314. N: updatePlayerValue, // 9: updatePlayerValue,
  1315. O: updateHealth, // h: updateHealth,//here
  1316. P: killPlayer, // 11: killPlayer,
  1317. Q: killObject, // 12: killObject,
  1318. R: killObjects, // 13: killObjects,
  1319. S: updateItemCounts, // 14: updateItemCounts,
  1320. T: updateAge, // 15: updateAge,
  1321. U: updateUpgrades, // 16: updateUpgrades,
  1322. V: updateItems, // 17: updateItems,
  1323. X: addProjectile, // 18: addProjectile,
  1324. // Y: remProjectile, // 19: remProjectile,
  1325. //Z: serverShutdownNotice,
  1326. //0: addAlliance,
  1327. //1: deleteAlliance,
  1328. 2: allianceNotification, // an: allianceNotification,
  1329. 3: setPlayerTeam, // st: setPlayerTeam,
  1330. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1331. 5: updateStoreItems, // us: updateStoreItems,
  1332. 6: receiveChat, // ch: receiveChat,
  1333. 7: updateMinimap, // mm: updateMinimap,
  1334. 8: showText, // t: showText,
  1335. 9: pingMap, // p: pingMap,
  1336. 0: pingSocketResponse,
  1337. };
  1338. if (type == "io-init") {
  1339. socketID = data[0];
  1340. } else {
  1341. if (events[type]) {
  1342. events[type].apply(undefined, data);
  1343. }
  1344. }
  1345. }
  1346.  
  1347. // MATHS:
  1348. Math.lerpAngle = function(value1, value2, amount) {
  1349. let difference = Math.abs(value2 - value1);
  1350. if (difference > Math.PI) {
  1351. if (value1 > value2) {
  1352. value2 += Math.PI * 2;
  1353. } else {
  1354. value1 += Math.PI * 2;
  1355. }
  1356. }
  1357. let value = value2 + ((value1 - value2) * amount);
  1358. if (value >= 0 && value <= Math.PI * 2) return value;
  1359. return value % (Math.PI * 2);
  1360. };
  1361.  
  1362. // REOUNDED RECTANGLE:
  1363. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1364. if (w < 2 * r) r = w / 2;
  1365. if (h < 2 * r) r = h / 2;
  1366. if (r < 0)
  1367. r = 0;
  1368. this.beginPath();
  1369. this.moveTo(x + r, y);
  1370. this.arcTo(x + w, y, x + w, y + h, r);
  1371. this.arcTo(x + w, y + h, x, y + h, r);
  1372. this.arcTo(x, y + h, x, y, r);
  1373. this.arcTo(x, y, x + w, y, r);
  1374. this.closePath();
  1375. return this;
  1376. };
  1377.  
  1378. // GLOBAL VALUES:
  1379. function resetMoveDir() {
  1380. keys = {};
  1381. io.send("e");
  1382. }
  1383.  
  1384. let allChats = [];
  1385. let ticks = {
  1386. tick: 0,
  1387. delay: 0,
  1388. time: [],
  1389. manage: [],
  1390. };
  1391. let ais = [];
  1392. let players = [];
  1393. let alliances = [];
  1394. let alliancePlayers = [];
  1395. let allianceNotifications = [];
  1396. let gameObjects = [];
  1397. let liztobj = [];
  1398. let projectiles = [];
  1399. let deadPlayers = [];
  1400.  
  1401. let breakObjects = [];
  1402.  
  1403. let player;
  1404. let playerSID;
  1405. let tmpObj;
  1406.  
  1407. let enemy = [];
  1408. let nears = [];
  1409. let near = [];
  1410.  
  1411. let my = {
  1412. reloaded: false,
  1413. waitHit: 0,
  1414. autoAim: false,
  1415. revAim: false,
  1416. ageInsta: true,
  1417. reSync: false,
  1418. bullTick: 0,
  1419. anti0Tick: 0,
  1420. antiSync: false,
  1421. safePrimary: function(tmpObj) {
  1422. return [0, 8].includes(tmpObj.primaryIndex);
  1423. },
  1424. safeSecondary: function(tmpObj) {
  1425. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1426. },
  1427. lastDir: 0,
  1428. autoPush: false,
  1429. pushData: {}
  1430. }
  1431.  
  1432. // FIND OBJECTS BY ID/SID:
  1433. function findID(tmpObj, tmp) {
  1434. return tmpObj.find((THIS) => THIS.id == tmp);
  1435. }
  1436.  
  1437. function findSID(tmpObj, tmp) {
  1438. return tmpObj.find((THIS) => THIS.sid == tmp);
  1439. }
  1440.  
  1441. function findPlayerByID(id) {
  1442. return findID(players, id);
  1443. }
  1444.  
  1445. function findPlayerBySID(sid) {
  1446. return findSID(players, sid);
  1447. }
  1448.  
  1449. function findAIBySID(sid) {
  1450. return findSID(ais, sid);
  1451. }
  1452.  
  1453. function findObjectBySid(sid) {
  1454. return findSID(gameObjects, sid);
  1455. }
  1456.  
  1457. function findProjectileBySid(sid) {
  1458. return findSID(gameObjects, sid);
  1459. }
  1460.  
  1461. let adCard = getEl("adCard");
  1462. adCard.remove();
  1463. let promoImageHolder = getEl("promoImgHolder");
  1464. promoImageHolder.remove();
  1465.  
  1466. let chatButton = getEl("chatButton");
  1467. chatButton.remove();
  1468. let gameCanvas = getEl("gameCanvas");
  1469. let mainContext = gameCanvas.getContext("2d");
  1470. let mapDisplay = getEl("mapDisplay");
  1471. let mapContext = mapDisplay.getContext("2d");
  1472. mapDisplay.width = 300;
  1473. mapDisplay.height = 300;
  1474. let storeMenu = getEl("storeMenu");
  1475. let storeHolder = getEl("storeHolder");
  1476. let upgradeHolder = getEl("upgradeHolder");
  1477. let upgradeCounter = getEl("upgradeCounter");
  1478. let chatBox = getEl("chatBox");
  1479. chatBox.autocomplete = "off";
  1480. chatBox.style.textAlign = "center";
  1481. chatBox.style.width = "18em";
  1482. let chatHolder = getEl("chatHolder");
  1483. let actionBar = getEl("actionBar");
  1484. let leaderboardData = getEl("leaderboardData");
  1485. let itemInfoHolder = getEl("itemInfoHolder");
  1486. let menuCardHolder = getEl("menuCardHolder");
  1487. let mainMenu = getEl("mainMenu");
  1488. let diedText = getEl("diedText");
  1489. let screenWidth;
  1490. let screenHeight;
  1491. let maxScreenWidth = config.maxScreenWidth;
  1492. let maxScreenHeight = config.maxScreenHeight;
  1493. let pixelDensity = 1;
  1494. let delta;
  1495. let now;
  1496. let lastUpdate = performance.now();
  1497. let camX;
  1498. let camY;
  1499. let tmpDir;
  1500. let mouseX = 0;
  1501. let mouseY = 0;
  1502. let allianceMenu = getEl("allianceMenu");
  1503. let waterMult = 1;
  1504. let waterPlus = 0;
  1505.  
  1506. let outlineColor = "#525252";
  1507. let darkOutlineColor = "#3d3f42";
  1508. let outlineWidth = 5.5;
  1509.  
  1510. let firstSetup = true;
  1511. let keys = {};
  1512. let moveKeys = {
  1513. 87: [0, -1],
  1514. 38: [0, -1],
  1515. 83: [0, 1],
  1516. 40: [0, 1],
  1517. 65: [-1, 0],
  1518. 37: [-1, 0],
  1519. 68: [1, 0],
  1520. 39: [1, 0],
  1521. };
  1522. let attackState = 0;
  1523. let inGame = false;
  1524.  
  1525. let macro = {};
  1526. let mills = {
  1527. place: 0,
  1528. placeSpawnPads: 0
  1529. };
  1530. let lastDir;
  1531.  
  1532. let lastLeaderboardData = [];
  1533.  
  1534. // ON LOAD:
  1535. let inWindow = true;
  1536. window.onblur = function() {
  1537. inWindow = false;
  1538. };
  1539. window.onfocus = function() {
  1540. inWindow = true;
  1541. if (player && player.alive) {
  1542. // resetMoveDir();
  1543. }
  1544. };
  1545. let ms = {
  1546. avg: 0,
  1547. max: 0,
  1548. min: 0,
  1549. delay: 0
  1550. }
  1551. function pingSocketResponse() {
  1552. let pingTime = window.pingTime;
  1553. const pingDisplay = document.getElementById("pingDisplay")
  1554. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1555. if (pingTime > ms.max || isNaN(ms.max)) {
  1556. ms.max = pingTime;
  1557. }
  1558. if (pingTime < ms.min || isNaN(ms.min)) {
  1559. ms.min = pingTime;
  1560. }
  1561.  
  1562. // if (pingTime >= 90) {
  1563. // doAutoQ = true;
  1564. // } else {
  1565. // doAutoQ = false;
  1566. // }
  1567. }
  1568.  
  1569. let placeVisible = [];
  1570.  
  1571. /** CLASS CODES */
  1572.  
  1573. class Utils {
  1574. constructor() {
  1575.  
  1576. // MATH UTILS:
  1577. let mathABS = Math.abs,
  1578. mathCOS = Math.cos,
  1579. mathSIN = Math.sin,
  1580. mathPOW = Math.pow,
  1581. mathSQRT = Math.sqrt,
  1582. mathATAN2 = Math.atan2,
  1583. mathPI = Math.PI;
  1584.  
  1585. let _this = this;
  1586.  
  1587. // GLOBAL UTILS:
  1588. this.round = function(n, v) {
  1589. return Math.round(n * v) / v;
  1590. };
  1591. this.toRad = function(angle) {
  1592. return angle * (mathPI / 180);
  1593. };
  1594. this.toAng = function(radian) {
  1595. return radian / (mathPI / 180);
  1596. };
  1597. this.randInt = function(min, max) {
  1598. return Math.floor(Math.random() * (max - min + 1)) + min;
  1599. };
  1600. this.randFloat = function(min, max) {
  1601. return Math.random() * (max - min + 1) + min;
  1602. };
  1603. this.lerp = function(value1, value2, amount) {
  1604. return value1 + (value2 - value1) * amount;
  1605. };
  1606. this.decel = function(val, cel) {
  1607. if (val > 0)
  1608. val = Math.max(0, val - cel);
  1609. else if (val < 0)
  1610. val = Math.min(0, val + cel);
  1611. return val;
  1612. };
  1613. this.getDistance = function(x1, y1, x2, y2) {
  1614. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1615. };
  1616. this.getDist = function(tmp1, tmp2, type1, type2) {
  1617. let tmpXY1 = {
  1618. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1619. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1620. };
  1621. let tmpXY2 = {
  1622. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1623. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1624. };
  1625. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1626. };
  1627. this.getDirection = function(x1, y1, x2, y2) {
  1628. return mathATAN2(y1 - y2, x1 - x2);
  1629. };
  1630. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1631. let tmpXY1 = {
  1632. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1633. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1634. };
  1635. let tmpXY2 = {
  1636. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1637. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1638. };
  1639. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1640. };
  1641. this.getAngleDist = function(a, b) {
  1642. let p = mathABS(b - a) % (mathPI * 2);
  1643. return (p > mathPI ? (mathPI * 2) - p : p);
  1644. };
  1645. this.isNumber = function(n) {
  1646. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1647. };
  1648. this.isString = function(s) {
  1649. return (s && typeof s == "string");
  1650. };
  1651. this.kFormat = function(num) {
  1652. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1653. };
  1654. this.sFormat = function(num) {
  1655. let fixs = [{
  1656. num: 1e3,
  1657. string: "k"
  1658. },
  1659. {
  1660. num: 1e6,
  1661. string: "m"
  1662. },
  1663. {
  1664. num: 1e9,
  1665. string: "b"
  1666. },
  1667. {
  1668. num: 1e12,
  1669. string: "q"
  1670. }
  1671. ].reverse();
  1672. let sp = fixs.find(v => num >= v.num);
  1673. if (!sp) return num;
  1674. return (num / sp.num).toFixed(1) + sp.string;
  1675. };
  1676. this.capitalizeFirst = function(string) {
  1677. return string.charAt(0).toUpperCase() + string.slice(1);
  1678. };
  1679. this.fixTo = function(n, v) {
  1680. return parseFloat(n.toFixed(v));
  1681. };
  1682. this.sortByPoints = function(a, b) {
  1683. return parseFloat(b.points) - parseFloat(a.points);
  1684. };
  1685. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1686. let minX = x1;
  1687. let maxX = x2;
  1688. if (x1 > x2) {
  1689. minX = x2;
  1690. maxX = x1;
  1691. }
  1692. if (maxX > recX2)
  1693. maxX = recX2;
  1694. if (minX < recX)
  1695. minX = recX;
  1696. if (minX > maxX)
  1697. return false;
  1698. let minY = y1;
  1699. let maxY = y2;
  1700. let dx = x2 - x1;
  1701. if (Math.abs(dx) > 0.0000001) {
  1702. let a = (y2 - y1) / dx;
  1703. let b = y1 - a * x1;
  1704. minY = a * minX + b;
  1705. maxY = a * maxX + b;
  1706. }
  1707. if (minY > maxY) {
  1708. let tmp = maxY;
  1709. maxY = minY;
  1710. minY = tmp;
  1711. }
  1712. if (maxY > recY2)
  1713. maxY = recY2;
  1714. if (minY < recY)
  1715. minY = recY;
  1716. if (minY > maxY)
  1717. return false;
  1718. return true;
  1719. };
  1720. this.containsPoint = function(element, x, y) {
  1721. let bounds = element.getBoundingClientRect();
  1722. let left = bounds.left + window.scrollX;
  1723. let top = bounds.top + window.scrollY;
  1724. let width = bounds.width;
  1725. let height = bounds.height;
  1726.  
  1727. let insideHorizontal = x > left && x < left + width;
  1728. let insideVertical = y > top && y < top + height;
  1729. return insideHorizontal && insideVertical;
  1730. };
  1731. this.mousifyTouchEvent = function(event) {
  1732. let touch = event.changedTouches[0];
  1733. event.screenX = touch.screenX;
  1734. event.screenY = touch.screenY;
  1735. event.clientX = touch.clientX;
  1736. event.clientY = touch.clientY;
  1737. event.pageX = touch.pageX;
  1738. event.pageY = touch.pageY;
  1739. };
  1740. this.hookTouchEvents = function(element, skipPrevent) {
  1741. let preventDefault = !skipPrevent;
  1742. let isHovering = false;
  1743. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1744. let passive = false;
  1745. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1746. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1747. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1748. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1749. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1750.  
  1751. function touchStart(e) {
  1752. _this.mousifyTouchEvent(e);
  1753. window.setUsingTouch(true);
  1754. if (preventDefault) {
  1755. e.preventDefault();
  1756. e.stopPropagation();
  1757. }
  1758. if (element.onmouseover)
  1759. element.onmouseover(e);
  1760. isHovering = true;
  1761. }
  1762.  
  1763. function touchMove(e) {
  1764. _this.mousifyTouchEvent(e);
  1765. window.setUsingTouch(true);
  1766. if (preventDefault) {
  1767. e.preventDefault();
  1768. e.stopPropagation();
  1769. }
  1770. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1771. if (!isHovering) {
  1772. if (element.onmouseover)
  1773. element.onmouseover(e);
  1774. isHovering = true;
  1775. }
  1776. } else {
  1777. if (isHovering) {
  1778. if (element.onmouseout)
  1779. element.onmouseout(e);
  1780. isHovering = false;
  1781. }
  1782. }
  1783. }
  1784.  
  1785. function touchEnd(e) {
  1786. _this.mousifyTouchEvent(e);
  1787. window.setUsingTouch(true);
  1788. if (preventDefault) {
  1789. e.preventDefault();
  1790. e.stopPropagation();
  1791. }
  1792. if (isHovering) {
  1793. if (element.onclick)
  1794. element.onclick(e);
  1795. if (element.onmouseout)
  1796. element.onmouseout(e);
  1797. isHovering = false;
  1798. }
  1799. }
  1800. };
  1801. this.removeAllChildren = function(element) {
  1802. while (element.hasChildNodes()) {
  1803. element.removeChild(element.lastChild);
  1804. }
  1805. };
  1806. this.generateElement = function(config) {
  1807. let element = document.createElement(config.tag || "div");
  1808.  
  1809. function bind(configValue, elementValue) {
  1810. if (config[configValue])
  1811. element[elementValue] = config[configValue];
  1812. }
  1813. bind("text", "textContent");
  1814. bind("html", "innerHTML");
  1815. bind("class", "className");
  1816. for (let key in config) {
  1817. switch (key) {
  1818. case "tag":
  1819. case "text":
  1820. case "html":
  1821. case "class":
  1822. case "style":
  1823. case "hookTouch":
  1824. case "parent":
  1825. case "children":
  1826. continue;
  1827. default:
  1828. break;
  1829. }
  1830. element[key] = config[key];
  1831. }
  1832. if (element.onclick)
  1833. element.onclick = this.checkTrusted(element.onclick);
  1834. if (element.onmouseover)
  1835. element.onmouseover = this.checkTrusted(element.onmouseover);
  1836. if (element.onmouseout)
  1837. element.onmouseout = this.checkTrusted(element.onmouseout);
  1838. if (config.style) {
  1839. element.style.cssText = config.style;
  1840. }
  1841. if (config.hookTouch) {
  1842. this.hookTouchEvents(element);
  1843. }
  1844. if (config.parent) {
  1845. config.parent.appendChild(element);
  1846. }
  1847. if (config.children) {
  1848. for (let i = 0; i < config.children.length; i++) {
  1849. element.appendChild(config.children[i]);
  1850. }
  1851. }
  1852. return element;
  1853. };
  1854. this.checkTrusted = function(callback) {
  1855. return function(ev) {
  1856. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1857. callback(ev);
  1858. } else {
  1859. //console.error("Event is not trusted.", ev);
  1860. }
  1861. };
  1862. };
  1863. this.randomString = function(length) {
  1864. let text = "";
  1865. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1866. for (let i = 0; i < length; i++) {
  1867. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1868. }
  1869. return text;
  1870. };
  1871. this.countInArray = function(array, val) {
  1872. let count = 0;
  1873. for (let i = 0; i < array.length; i++) {
  1874. if (array[i] === val) count++;
  1875. }
  1876. return count;
  1877. };
  1878. this.hexToRgb = function(hex) {
  1879. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1880. };
  1881. this.getRgb = function(r, g, b) {
  1882. return [r / 255, g / 255, b / 255].join(", ");
  1883. };
  1884. }
  1885. };
  1886. class Animtext {
  1887. // ANIMATED TEXT:
  1888. constructor() {
  1889. // INIT:
  1890. this.init = function(x, y, scale, speed, life, text, color) {
  1891. (this.x = x),
  1892. (this.y = y),
  1893. (this.color = color),
  1894. (this.scale = scale*3.5),
  1895. (this.weight = 50);
  1896. (this.startScale = this.scale * 1.2),
  1897. (this.maxScale = 1.5 * scale),
  1898. (this.minScale = 0.5 * scale),
  1899. (this.scaleSpeed = 0.7),
  1900. (this.speed = speed),
  1901. (this.speedMax = speed),
  1902. (this.life = life),
  1903. (this.maxLife = life),
  1904. (this.text = text),
  1905. this.movSpeed = speed;
  1906. };
  1907.  
  1908. // UPDATE:
  1909. this.update = function(delta) {
  1910. if(this.life){
  1911. this.life -= delta;
  1912. if(this.scaleSpeed != -0.35){
  1913. this.y -= this.speed * delta;
  1914. // (this.x += this.speed * delta);
  1915. } else {
  1916. this.y -= this.speed * delta;
  1917. }
  1918. this.scale -= .8;
  1919. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  1920. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  1921. if(this.scale >= this.maxScale){
  1922. this.scale = this.maxScale;
  1923. this.scaleSpeed *= -.5;
  1924. this.speed = this.speed * .75;
  1925. };
  1926. this.life <= 0 && (this.life = 0)
  1927. };
  1928. };
  1929.  
  1930. // RENDER:
  1931. this.render = function(ctxt, xOff, yOff) {
  1932. ctxt.lineWidth = 10;
  1933. ctxt.strokeStyle = darkOutlineColor; //"black";
  1934. ctxt.fillStyle = this.color;
  1935. ctxt.globalAlpha = 1;
  1936. ctxt.font = this.scale + "px Hammersmith One";
  1937. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1938. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1939. ctxt.globalAlpha = 1;
  1940. };
  1941. }
  1942. };
  1943. class Textmanager {
  1944. // TEXT MANAGER:
  1945. constructor() {
  1946. this.texts = [];
  1947. this.stack = [];
  1948.  
  1949. // UPDATE:
  1950. this.update = function(delta, ctxt, xOff, yOff) {
  1951. ctxt.textBaseline = "middle";
  1952. ctxt.textAlign = "center";
  1953. for (let i = 0; i < this.texts.length; ++i) {
  1954. if (this.texts[i].life) {
  1955. this.texts[i].update(delta);
  1956. this.texts[i].render(ctxt, xOff, yOff);
  1957. }
  1958. }
  1959. };
  1960.  
  1961. // SHOW TEXT:
  1962. this.showText = function(x, y, scale, speed, life, text, color) {
  1963. let tmpText;
  1964. for (let i = 0; i < this.texts.length; ++i) {
  1965. if (!this.texts[i].life) {
  1966. tmpText = this.texts[i];
  1967. break;
  1968. }
  1969. }
  1970. if (!tmpText) {
  1971. tmpText = new Animtext();
  1972. this.texts.push(tmpText);
  1973. }
  1974. tmpText.init(x, y, scale, speed, life, text, color);
  1975. };
  1976. }
  1977. }
  1978.  
  1979. class GameObject {
  1980. constructor(sid) {
  1981. this.sid = sid;
  1982.  
  1983. // INIT:
  1984. this.init = function(x, y, dir, scale, type, data, owner) {
  1985. data = data || {};
  1986. this.sentTo = {};
  1987. this.gridLocations = [];
  1988. this.active = true;
  1989. this.render = true;
  1990. this.doUpdate = data.doUpdate;
  1991. this.x = x;
  1992. this.y = y;
  1993. this.dir = dir;
  1994. this.lastDir = dir;
  1995. this.xWiggle = 0;
  1996. this.yWiggle = 0;
  1997. this.visScale = scale;
  1998. this.scale = scale;
  1999. this.type = type;
  2000. this.id = data.id;
  2001. this.owner = owner;
  2002. this.name = data.name;
  2003. this.isItem = (this.id != undefined);
  2004. this.group = data.group;
  2005. this.maxHealth = data.health;
  2006. this.health = this.maxHealth;
  2007. this.layer = 2;
  2008. if (this.group != undefined) {
  2009. this.layer = this.group.layer;
  2010. } else if (this.type == 0) {
  2011. this.layer = 3;
  2012. } else if (this.type == 2) {
  2013. this.layer = 0;
  2014. } else if (this.type == 4) {
  2015. this.layer = -1;
  2016. }
  2017. this.colDiv = data.colDiv || 1;
  2018. this.blocker = data.blocker;
  2019. this.ignoreCollision = data.ignoreCollision;
  2020. this.dontGather = data.dontGather;
  2021. this.hideFromEnemy = data.hideFromEnemy;
  2022. this.friction = data.friction;
  2023. this.projDmg = data.projDmg;
  2024. this.dmg = data.dmg;
  2025. this.pDmg = data.pDmg;
  2026. this.pps = data.pps;
  2027. this.zIndex = data.zIndex || 0;
  2028. this.turnSpeed = data.turnSpeed;
  2029. this.req = data.req;
  2030. this.trap = data.trap;
  2031. this.healCol = data.healCol;
  2032. this.teleport = data.teleport;
  2033. this.boostSpeed = data.boostSpeed;
  2034. this.projectile = data.projectile;
  2035. this.shootRange = data.shootRange;
  2036. this.shootRate = data.shootRate;
  2037. this.shootCount = this.shootRate;
  2038. this.spawnPoint = data.spawnPoint;
  2039. this.onNear = 0;
  2040. this.breakObj = false;
  2041. this.alpha = data.alpha || 1;
  2042. this.maxAlpha = data.alpha || 1;
  2043. this.damaged = 0;
  2044. };
  2045.  
  2046. // GET HIT:
  2047. this.changeHealth = function(amount, doer) {
  2048. this.health += amount;
  2049. return (this.health <= 0);
  2050. };
  2051.  
  2052. // GET SCALE:
  2053. this.getScale = function(sM, ig) {
  2054. sM = sM || 1;
  2055. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2056. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2057. };
  2058.  
  2059. // VISIBLE TO PLAYER:
  2060. this.visibleToPlayer = function(player) {
  2061. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2062. (this.owner.team && player.team == this.owner.team)));
  2063. };
  2064.  
  2065. // UPDATE:
  2066. this.update = function(delta) {
  2067. if (this.active) {
  2068. if (this.xWiggle) {
  2069. this.xWiggle *= Math.pow(0.99, delta);
  2070. }
  2071. if (this.yWiggle) {
  2072. this.yWiggle *= Math.pow(0.99, delta);
  2073. }
  2074. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2075. if (d2 > 0.01) {
  2076. this.dir += d2 / 5;
  2077. } else {
  2078. this.dir = this.lastDir;
  2079. }
  2080. } else {
  2081. if (this.alive) {
  2082. this.alpha -= delta / (200 / this.maxAlpha);
  2083. this.visScale += delta / (this.scale / 2.5);
  2084. if (this.alpha <= 0) {
  2085. this.alpha = 0;
  2086. this.alive = false;
  2087. }
  2088. }
  2089. }
  2090. };
  2091.  
  2092. // CHECK TEAM:
  2093. this.isTeamObject = function(tmpObj) {
  2094. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2095. };
  2096. }
  2097. }
  2098. class Items {
  2099. constructor() {
  2100. // ITEM GROUPS:
  2101. this.groups = [{
  2102. id: 0,
  2103. name: "food",
  2104. layer: 0
  2105. }, {
  2106. id: 1,
  2107. name: "walls",
  2108. place: true,
  2109. limit: 30,
  2110. layer: 0
  2111. }, {
  2112. id: 2,
  2113. name: "spikes",
  2114. place: true,
  2115. limit: 15,
  2116. layer: 0
  2117. }, {
  2118. id: 3,
  2119. name: "mill",
  2120. place: true,
  2121. limit: 7,
  2122. layer: 1
  2123. }, {
  2124. id: 4,
  2125. name: "mine",
  2126. place: true,
  2127. limit: 1,
  2128. layer: 0
  2129. }, {
  2130. id: 5,
  2131. name: "trap",
  2132. place: true,
  2133. limit: 6,
  2134. layer: -1
  2135. }, {
  2136. id: 6,
  2137. name: "booster",
  2138. place: true,
  2139. limit: 12,
  2140. layer: -1
  2141. }, {
  2142. id: 7,
  2143. name: "turret",
  2144. place: true,
  2145. limit: 2,
  2146. layer: 1
  2147. }, {
  2148. id: 8,
  2149. name: "watchtower",
  2150. place: true,
  2151. limit: 12,
  2152. layer: 1
  2153. }, {
  2154. id: 9,
  2155. name: "buff",
  2156. place: true,
  2157. limit: 4,
  2158. layer: -1
  2159. }, {
  2160. id: 10,
  2161. name: "spawn",
  2162. place: true,
  2163. limit: 1,
  2164. layer: -1
  2165. }, {
  2166. id: 11,
  2167. name: "sapling",
  2168. place: true,
  2169. limit: 2,
  2170. layer: 0
  2171. }, {
  2172. id: 12,
  2173. name: "blocker",
  2174. place: true,
  2175. limit: 3,
  2176. layer: -1
  2177. }, {
  2178. id: 13,
  2179. name: "teleporter",
  2180. place: true,
  2181. limit: 2,
  2182. layer: -1
  2183. }];
  2184.  
  2185. // PROJECTILES:
  2186. this.projectiles = [{
  2187. indx: 0,
  2188. layer: 0,
  2189. src: "arrow_1",
  2190. dmg: 25,
  2191. speed: 1.6,
  2192. scale: 103,
  2193. range: 1000
  2194. }, {
  2195. indx: 1,
  2196. layer: 1,
  2197. dmg: 25,
  2198. scale: 20
  2199. }, {
  2200. indx: 0,
  2201. layer: 0,
  2202. src: "arrow_1",
  2203. dmg: 35,
  2204. speed: 2.5,
  2205. scale: 103,
  2206. range: 1200
  2207. }, {
  2208. indx: 0,
  2209. layer: 0,
  2210. src: "arrow_1",
  2211. dmg: 30,
  2212. speed: 2,
  2213. scale: 103,
  2214. range: 1200
  2215. }, {
  2216. indx: 1,
  2217. layer: 1,
  2218. dmg: 16,
  2219. scale: 20
  2220. }, {
  2221. indx: 0,
  2222. layer: 0,
  2223. src: "bullet_1",
  2224. dmg: 50,
  2225. speed: 3.6,
  2226. scale: 160,
  2227. range: 1400
  2228. }];
  2229.  
  2230. // WEAPONS:
  2231. this.weapons = [{
  2232. id: 0,
  2233. type: 0,
  2234. name: "tool hammer",
  2235. desc: "tool for gathering all resources",
  2236. src: "hammer_1",
  2237. length: 140,
  2238. width: 140,
  2239. xOff: -3,
  2240. yOff: 18,
  2241. dmg: 25,
  2242. range: 65,
  2243. gather: 1,
  2244. speed: 300
  2245. }, {
  2246. id: 1,
  2247. type: 0,
  2248. age: 2,
  2249. name: "hand axe",
  2250. desc: "gathers resources at a higher rate",
  2251. src: "axe_1",
  2252. length: 140,
  2253. width: 140,
  2254. xOff: 3,
  2255. yOff: 24,
  2256. dmg: 30,
  2257. spdMult: 1,
  2258. range: 70,
  2259. gather: 2,
  2260. speed: 400
  2261. }, {
  2262. id: 2,
  2263. type: 0,
  2264. age: 8,
  2265. pre: 1,
  2266. name: "great axe",
  2267. desc: "deal more damage and gather more resources",
  2268. src: "great_axe_1",
  2269. length: 140,
  2270. width: 140,
  2271. xOff: -8,
  2272. yOff: 25,
  2273. dmg: 35,
  2274. spdMult: 1,
  2275. range: 75,
  2276. gather: 4,
  2277. speed: 400
  2278. }, {
  2279. id: 3,
  2280. type: 0,
  2281. age: 2,
  2282. name: "short sword",
  2283. desc: "increased attack power but slower move speed",
  2284. src: "sword_1",
  2285. iPad: 1.3,
  2286. length: 130,
  2287. width: 210,
  2288. xOff: -8,
  2289. yOff: 46,
  2290. dmg: 35,
  2291. spdMult: 0.85,
  2292. range: 110,
  2293. gather: 1,
  2294. speed: 300
  2295. }, {
  2296. id: 4,
  2297. type: 0,
  2298. age: 8,
  2299. pre: 3,
  2300. name: "katana",
  2301. desc: "greater range and damage",
  2302. src: "samurai_1",
  2303. iPad: 1.3,
  2304. length: 130,
  2305. width: 210,
  2306. xOff: -8,
  2307. yOff: 59,
  2308. dmg: 40,
  2309. spdMult: 0.8,
  2310. range: 118,
  2311. gather: 1,
  2312. speed: 300
  2313. }, {
  2314. id: 5,
  2315. type: 0,
  2316. age: 2,
  2317. name: "polearm",
  2318. desc: "long range melee weapon",
  2319. src: "spear_1",
  2320. iPad: 1.3,
  2321. length: 130,
  2322. width: 210,
  2323. xOff: -8,
  2324. yOff: 53,
  2325. dmg: 45,
  2326. knock: 0.2,
  2327. spdMult: 0.82,
  2328. range: 142,
  2329. gather: 1,
  2330. speed: 700
  2331. }, {
  2332. id: 6,
  2333. type: 0,
  2334. age: 2,
  2335. name: "bat",
  2336. desc: "fast long range melee weapon",
  2337. src: "bat_1",
  2338. iPad: 1.3,
  2339. length: 110,
  2340. width: 180,
  2341. xOff: -8,
  2342. yOff: 53,
  2343. dmg: 20,
  2344. knock: 0.7,
  2345. range: 110,
  2346. gather: 1,
  2347. speed: 300
  2348. }, {
  2349. id: 7,
  2350. type: 0,
  2351. age: 2,
  2352. name: "daggers",
  2353. desc: "really fast short range weapon",
  2354. src: "dagger_1",
  2355. iPad: 0.8,
  2356. length: 110,
  2357. width: 110,
  2358. xOff: 18,
  2359. yOff: 0,
  2360. dmg: 20,
  2361. knock: 0.1,
  2362. range: 65,
  2363. gather: 1,
  2364. hitSlow: 0.1,
  2365. spdMult: 1.13,
  2366. speed: 100
  2367. }, {
  2368. id: 8,
  2369. type: 0,
  2370. age: 2,
  2371. name: "stick",
  2372. desc: "great for gathering but very weak",
  2373. src: "stick_1",
  2374. length: 140,
  2375. width: 140,
  2376. xOff: 3,
  2377. yOff: 24,
  2378. dmg: 1,
  2379. spdMult: 1,
  2380. range: 70,
  2381. gather: 7,
  2382. speed: 400
  2383. }, {
  2384. id: 9,
  2385. type: 1,
  2386. age: 6,
  2387. name: "hunting bow",
  2388. desc: "bow used for ranged combat and hunting",
  2389. src: "bow_1",
  2390. req: ["wood", 4],
  2391. length: 120,
  2392. width: 120,
  2393. xOff: -6,
  2394. yOff: 0,
  2395. Pdmg: 25,
  2396. projectile: 0,
  2397. spdMult: 0.75,
  2398. speed: 600
  2399. }, {
  2400. id: 10,
  2401. type: 1,
  2402. age: 6,
  2403. name: "great hammer",
  2404. desc: "hammer used for destroying structures",
  2405. src: "great_hammer_1",
  2406. length: 140,
  2407. width: 140,
  2408. xOff: -9,
  2409. yOff: 25,
  2410. dmg: 10,
  2411. Pdmg: 10,
  2412. spdMult: 0.88,
  2413. range: 75,
  2414. sDmg: 7.5,
  2415. gather: 1,
  2416. speed: 400
  2417. }, {
  2418. id: 11,
  2419. type: 1,
  2420. age: 6,
  2421. name: "wooden shield",
  2422. desc: "blocks projectiles and reduces melee damage",
  2423. src: "shield_1",
  2424. length: 120,
  2425. width: 120,
  2426. shield: 0.2,
  2427. xOff: 6,
  2428. yOff: 0,
  2429. Pdmg: 0,
  2430. spdMult: 0.7
  2431. }, {
  2432. id: 12,
  2433. type: 1,
  2434. age: 8,
  2435. pre: 9,
  2436. name: "crossbow",
  2437. desc: "deals more damage and has greater range",
  2438. src: "crossbow_1",
  2439. req: ["wood", 5],
  2440. aboveHand: true,
  2441. armS: 0.75,
  2442. length: 120,
  2443. width: 120,
  2444. xOff: -4,
  2445. yOff: 0,
  2446. Pdmg: 35,
  2447. projectile: 2,
  2448. spdMult: 0.7,
  2449. speed: 700
  2450. }, {
  2451. id: 13,
  2452. type: 1,
  2453. age: 9,
  2454. pre: 12,
  2455. name: "repeater crossbow",
  2456. desc: "high firerate crossbow with reduced damage",
  2457. src: "crossbow_2",
  2458. req: ["wood", 10],
  2459. aboveHand: true,
  2460. armS: 0.75,
  2461. length: 120,
  2462. width: 120,
  2463. xOff: -4,
  2464. yOff: 0,
  2465. Pdmg: 30,
  2466. projectile: 3,
  2467. spdMult: 0.7,
  2468. speed: 230
  2469. }, {
  2470. id: 14,
  2471. type: 1,
  2472. age: 6,
  2473. name: "mc grabby",
  2474. desc: "steals resources from enemies",
  2475. src: "grab_1",
  2476. length: 130,
  2477. width: 210,
  2478. xOff: -8,
  2479. yOff: 53,
  2480. dmg: 0,
  2481. Pdmg: 0,
  2482. steal: 250,
  2483. knock: 0.2,
  2484. spdMult: 1.05,
  2485. range: 125,
  2486. gather: 0,
  2487. speed: 700
  2488. }, {
  2489. id: 15,
  2490. type: 1,
  2491. age: 9,
  2492. pre: 12,
  2493. name: "musket",
  2494. desc: "slow firerate but high damage and range",
  2495. src: "musket_1",
  2496. req: ["stone", 10],
  2497. aboveHand: true,
  2498. rec: 0.35,
  2499. armS: 0.6,
  2500. hndS: 0.3,
  2501. hndD: 1.6,
  2502. length: 205,
  2503. width: 205,
  2504. xOff: 25,
  2505. yOff: 0,
  2506. Pdmg: 50,
  2507. projectile: 5,
  2508. hideProjectile: true,
  2509. spdMult: 0.6,
  2510. speed: 1500
  2511. }];
  2512.  
  2513. // ITEMS:
  2514. this.list = [{
  2515. group: this.groups[0],
  2516. name: "apple",
  2517. desc: "restores 20 health when consumed",
  2518. req: ["food", 10],
  2519. consume: function(doer) {
  2520. return doer.changeHealth(20, doer);
  2521. },
  2522. scale: 22,
  2523. holdOffset: 15,
  2524. healing: 20,
  2525. itemID: 0,
  2526. itemAID: 16,
  2527. }, {
  2528. age: 3,
  2529. group: this.groups[0],
  2530. name: "cookie",
  2531. desc: "restores 40 health when consumed",
  2532. req: ["food", 15],
  2533. consume: function(doer) {
  2534. return doer.changeHealth(40, doer);
  2535. },
  2536. scale: 27,
  2537. holdOffset: 15,
  2538. healing: 40,
  2539. itemID: 1,
  2540. itemAID: 17,
  2541. }, {
  2542. age: 7,
  2543. group: this.groups[0],
  2544. name: "cheese",
  2545. desc: "restores 30 health and another 50 over 5 seconds",
  2546. req: ["food", 25],
  2547. consume: function(doer) {
  2548. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2549. doer.dmgOverTime.dmg = -10;
  2550. doer.dmgOverTime.doer = doer;
  2551. doer.dmgOverTime.time = 5;
  2552. return true;
  2553. }
  2554. return false;
  2555. },
  2556. scale: 27,
  2557. holdOffset: 15,
  2558. healing: 30,
  2559. itemID: 2,
  2560. itemAID: 18,
  2561. }, {
  2562. group: this.groups[1],
  2563. name: "wood wall",
  2564. desc: "provides protection for your village",
  2565. req: ["wood", 10],
  2566. projDmg: true,
  2567. health: 380,
  2568. scale: 50,
  2569. holdOffset: 20,
  2570. placeOffset: -5,
  2571. itemID: 3,
  2572. itemAID: 19,
  2573. }, {
  2574. age: 3,
  2575. group: this.groups[1],
  2576. name: "stone wall",
  2577. desc: "provides improved protection for your village",
  2578. req: ["stone", 25],
  2579. health: 900,
  2580. scale: 50,
  2581. holdOffset: 20,
  2582. placeOffset: -5,
  2583. itemID: 4,
  2584. itemAID: 20,
  2585. }, {
  2586. age: 7,
  2587. group: this.groups[1],
  2588. name: "castle wall",
  2589. desc: "provides powerful protection for your village",
  2590. req: ["stone", 35],
  2591. health: 1500,
  2592. scale: 52,
  2593. holdOffset: 20,
  2594. placeOffset: -5,
  2595. itemID: 5,
  2596. itemAID: 21,
  2597. }, {
  2598. group: this.groups[2],
  2599. name: "spikes",
  2600. desc: "damages enemies when they touch them",
  2601. req: ["wood", 20, "stone", 5],
  2602. health: 400,
  2603. dmg: 20,
  2604. scale: 49,
  2605. spritePadding: -23,
  2606. holdOffset: 8,
  2607. placeOffset: -5,
  2608. itemID: 6,
  2609. itemAID: 22,
  2610. shadow: {
  2611. offsetX: 5, // Adjust the shadow's X offset as needed
  2612. offsetY: 5, // Adjust the shadow's Y offset as needed
  2613. blur: 20, // Adjust the shadow's blur as needed
  2614. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2615. }
  2616.  
  2617. }, {
  2618. age: 5,
  2619. group: this.groups[2],
  2620. name: "greater spikes",
  2621. desc: "damages enemies when they touch them",
  2622. req: ["wood", 30, "stone", 10],
  2623. health: 500,
  2624. dmg: 35,
  2625. scale: 52,
  2626. spritePadding: -23,
  2627. holdOffset: 8,
  2628. placeOffset: -5,
  2629. itemID: 7,
  2630. itemAID: 23,
  2631. }, {
  2632. age: 9,
  2633. group: this.groups[2],
  2634. name: "poison spikes",
  2635. desc: "poisons enemies when they touch them",
  2636. req: ["wood", 35, "stone", 15],
  2637. health: 600,
  2638. dmg: 30,
  2639. pDmg: 5,
  2640. scale: 52,
  2641. spritePadding: -23,
  2642. holdOffset: 8,
  2643. placeOffset: -5,
  2644. itemID: 8,
  2645. itemAID: 24,
  2646. }, {
  2647. age: 9,
  2648. group: this.groups[2],
  2649. name: "spinning spikes",
  2650. desc: "damages enemies when they touch them",
  2651. req: ["wood", 30, "stone", 20],
  2652. health: 500,
  2653. dmg: 45,
  2654. turnSpeed: 0.003,
  2655. scale: 52,
  2656. spritePadding: -23,
  2657. holdOffset: 8,
  2658. placeOffset: -5,
  2659. itemID: 9,
  2660. itemAID: 25,
  2661. }, {
  2662. group: this.groups[3],
  2663. name: "windmill",
  2664. desc: "generates gold over time",
  2665. req: ["wood", 50, "stone", 10],
  2666. health: 400,
  2667. pps: 1,
  2668. turnSpeed: 0.0016,
  2669. spritePadding: 25,
  2670. iconLineMult: 12,
  2671. scale: 45,
  2672. holdOffset: 20,
  2673. placeOffset: 5,
  2674. itemID: 10,
  2675. itemAID: 26,
  2676. }, {
  2677. age: 5,
  2678. group: this.groups[3],
  2679. name: "faster windmill",
  2680. desc: "generates more gold over time",
  2681. req: ["wood", 60, "stone", 20],
  2682. health: 500,
  2683. pps: 1.5,
  2684. turnSpeed: 0.0025,
  2685. spritePadding: 25,
  2686. iconLineMult: 12,
  2687. scale: 47,
  2688. holdOffset: 20,
  2689. placeOffset: 5,
  2690. itemID: 11,
  2691. itemAID: 27,
  2692. }, {
  2693. age: 8,
  2694. group: this.groups[3],
  2695. name: "power mill",
  2696. desc: "generates more gold over time",
  2697. req: ["wood", 100, "stone", 50],
  2698. health: 800,
  2699. pps: 2,
  2700. turnSpeed: 0.005,
  2701. spritePadding: 25,
  2702. iconLineMult: 12,
  2703. scale: 47,
  2704. holdOffset: 20,
  2705. placeOffset: 5,
  2706. itemID: 12,
  2707. itemAID: 28,
  2708. }, {
  2709. age: 5,
  2710. group: this.groups[4],
  2711. type: 2,
  2712. name: "mine",
  2713. desc: "allows you to mine stone",
  2714. req: ["wood", 20, "stone", 100],
  2715. iconLineMult: 12,
  2716. scale: 65,
  2717. holdOffset: 20,
  2718. placeOffset: 0,
  2719. itemID: 13,
  2720. itemAID: 29,
  2721. }, {
  2722. age: 5,
  2723. group: this.groups[11],
  2724. type: 0,
  2725. name: "sapling",
  2726. desc: "allows you to farm wood",
  2727. req: ["wood", 150],
  2728. iconLineMult: 12,
  2729. colDiv: 0.5,
  2730. scale: 110,
  2731. holdOffset: 50,
  2732. placeOffset: -15,
  2733. itemID: 14,
  2734. itemAID: 30,
  2735. }, {
  2736. age: 4,
  2737. group: this.groups[5],
  2738. name: "pit trap",
  2739. desc: "pit that traps enemies if they walk over it",
  2740. req: ["wood", 30, "stone", 30],
  2741. trap: true,
  2742. ignoreCollision: true,
  2743. hideFromEnemy: true,
  2744. health: 500,
  2745. colDiv: 0.2,
  2746. scale: 50,
  2747. holdOffset: 20,
  2748. placeOffset: -5,
  2749. alpha: 0.6,
  2750. itemID: 15,
  2751. itemAID: 31,
  2752. }, {
  2753. age: 4,
  2754. group: this.groups[6],
  2755. name: "boost pad",
  2756. desc: "provides boost when stepped on",
  2757. req: ["stone", 20, "wood", 5],
  2758. ignoreCollision: true,
  2759. boostSpeed: 1.5,
  2760. health: 150,
  2761. colDiv: 0.7,
  2762. scale: 45,
  2763. holdOffset: 20,
  2764. placeOffset: -5,
  2765. itemID: 16,
  2766. itemAID: 32,
  2767. }, {
  2768. age: 7,
  2769. group: this.groups[7],
  2770. doUpdate: true,
  2771. name: "turret",
  2772. desc: "defensive structure that shoots at enemies",
  2773. req: ["wood", 200, "stone", 150],
  2774. health: 800,
  2775. projectile: 1,
  2776. shootRange: 700,
  2777. shootRate: 2200,
  2778. scale: 43,
  2779. holdOffset: 20,
  2780. placeOffset: -5,
  2781. itemID: 17,
  2782. itemAID: 33,
  2783. }, {
  2784. age: 7,
  2785. group: this.groups[8],
  2786. name: "platform",
  2787. desc: "platform to shoot over walls and cross over water",
  2788. req: ["wood", 20],
  2789. ignoreCollision: true,
  2790. zIndex: 1,
  2791. health: 300,
  2792. scale: 43,
  2793. holdOffset: 20,
  2794. placeOffset: -5,
  2795. itemID: 18,
  2796. itemAID: 34,
  2797. }, {
  2798. age: 7,
  2799. group: this.groups[9],
  2800. name: "healing pad",
  2801. desc: "standing on it will slowly heal you",
  2802. req: ["wood", 30, "food", 10],
  2803. ignoreCollision: true,
  2804. healCol: 15,
  2805. health: 400,
  2806. colDiv: 0.7,
  2807. scale: 45,
  2808. holdOffset: 20,
  2809. placeOffset: -5,
  2810. itemID: 19,
  2811. itemAID: 35,
  2812. }, {
  2813. age: 9,
  2814. group: this.groups[10],
  2815. name: "spawn pad",
  2816. desc: "you will spawn here when you die but it will dissapear",
  2817. req: ["wood", 100, "stone", 100],
  2818. health: 400,
  2819. ignoreCollision: true,
  2820. spawnPoint: true,
  2821. scale: 45,
  2822. holdOffset: 20,
  2823. placeOffset: -5,
  2824. itemID: 20,
  2825. itemAID: 36,
  2826. }, {
  2827. age: 7,
  2828. group: this.groups[12],
  2829. name: "blocker",
  2830. desc: "blocks building in radius",
  2831. req: ["wood", 30, "stone", 25],
  2832. ignoreCollision: true,
  2833. blocker: 300,
  2834. health: 400,
  2835. colDiv: 0.7,
  2836. scale: 45,
  2837. holdOffset: 20,
  2838. placeOffset: -5,
  2839. itemID: 21,
  2840. itemAID: 37,
  2841. }, {
  2842. age: 7,
  2843. group: this.groups[13],
  2844. name: "teleporter",
  2845. desc: "teleports you to a random point on the map",
  2846. req: ["wood", 60, "stone", 60],
  2847. ignoreCollision: true,
  2848. teleport: true,
  2849. health: 200,
  2850. colDiv: 0.7,
  2851. scale: 45,
  2852. holdOffset: 20,
  2853. placeOffset: -5,
  2854. itemID: 22,
  2855. itemAID: 38
  2856. }];
  2857.  
  2858. // CHECK ITEM ID:
  2859. this.checkItem = {
  2860. index: function(id, myItems) {
  2861. 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 :
  2862. 5 :
  2863. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2864. 6 :
  2865. undefined;
  2866. }
  2867. }
  2868.  
  2869. // ASSIGN IDS:
  2870. for (let i = 0; i < this.list.length; ++i) {
  2871. this.list[i].id = i;
  2872. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2873. }
  2874.  
  2875. // TROLOLOLOL:
  2876. if (typeof window !== "undefined") {
  2877. function shuffle(a) {
  2878. for (let i = a.length - 1; i > 0; i--) {
  2879. const j = Math.floor(Math.random() * (i + 1));
  2880. [a[i], a[j]] = [a[j], a[i]];
  2881. }
  2882. return a;
  2883. }
  2884. //shuffle(this.list);
  2885. }
  2886. }
  2887. }
  2888. class Objectmanager {
  2889. constructor(GameObject, liztobj, UTILS, config, players, server) {
  2890. let mathFloor = Math.floor,
  2891. mathABS = Math.abs,
  2892. mathCOS = Math.cos,
  2893. mathSIN = Math.sin,
  2894. mathPOW = Math.pow,
  2895. mathSQRT = Math.sqrt;
  2896.  
  2897. this.ignoreAdd = false;
  2898. this.hitObj = [];
  2899.  
  2900. // DISABLE OBJ:
  2901. this.disableObj = function(obj) {
  2902. obj.active = false;
  2903. };
  2904.  
  2905. // ADD NEW:
  2906. let tmpObj;
  2907. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2908. tmpObj = findObjectBySid(sid);
  2909. if (!tmpObj) {
  2910. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2911. if (!tmpObj) {
  2912. tmpObj = new GameObject(sid);
  2913. gameObjects.push(tmpObj);
  2914. }
  2915. }
  2916. if (setSID) {
  2917. tmpObj.sid = sid;
  2918. }
  2919. tmpObj.init(x, y, dir, s, type, data, owner);
  2920. };
  2921.  
  2922. // DISABLE BY SID:
  2923. this.disableBySid = function(sid) {
  2924. let find = findObjectBySid(sid);
  2925. if (find) {
  2926. this.disableObj(find);
  2927. }
  2928. };
  2929.  
  2930. // REMOVE ALL FROM PLAYER:
  2931. this.removeAllItems = function(sid, server) {
  2932. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2933. };
  2934.  
  2935. // CHECK IF PLACABLE:
  2936. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2937. 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)));
  2938. if (cantPlace) return false;
  2939. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2940. return true;
  2941. };
  2942.  
  2943. }
  2944. }
  2945. class Projectile {
  2946. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2947.  
  2948. // INIT:
  2949. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2950. this.active = true;
  2951. this.tickActive = true;
  2952. this.indx = indx;
  2953. this.x = x;
  2954. this.y = y;
  2955. this.x2 = x;
  2956. this.y2 = y;
  2957. this.dir = dir;
  2958. this.skipMov = true;
  2959. this.speed = spd;
  2960. this.dmg = dmg;
  2961. this.scale = scl;
  2962. this.range = rng;
  2963. this.r2 = rng;
  2964. this.owner = owner;
  2965. };
  2966.  
  2967. // UPDATE:
  2968. this.update = function(delta) {
  2969. if (this.active) {
  2970. let tmpSpeed = this.speed * delta;
  2971. if (!this.skipMov) {
  2972. this.x += tmpSpeed * Math.cos(this.dir);
  2973. this.y += tmpSpeed * Math.sin(this.dir);
  2974. this.range -= tmpSpeed;
  2975. if (this.range <= 0) {
  2976. this.x += this.range * Math.cos(this.dir);
  2977. this.y += this.range * Math.sin(this.dir);
  2978. tmpSpeed = 1;
  2979. this.range = 0;
  2980. this.active = false;
  2981. }
  2982. } else {
  2983. this.skipMov = false;
  2984. }
  2985. }
  2986. };
  2987. this.tickUpdate = function(delta) {
  2988. if (this.tickActive) {
  2989. let tmpSpeed = this.speed * delta;
  2990. if (!this.skipMov) {
  2991. this.x2 += tmpSpeed * Math.cos(this.dir);
  2992. this.y2 += tmpSpeed * Math.sin(this.dir);
  2993. this.r2 -= tmpSpeed;
  2994. if (this.r2 <= 0) {
  2995. this.x2 += this.r2 * Math.cos(this.dir);
  2996. this.y2 += this.r2 * Math.sin(this.dir);
  2997. tmpSpeed = 1;
  2998. this.r2 = 0;
  2999. this.tickActive = false;
  3000. }
  3001. } else {
  3002. this.skipMov = false;
  3003. }
  3004. }
  3005. };
  3006. }
  3007. };
  3008. class Store {
  3009. constructor() {
  3010. // STORE HATS:
  3011. this.hats = [{
  3012. id: 45,
  3013. name: "Shame!",
  3014. dontSell: true,
  3015. price: 0,
  3016. scale: 120,
  3017. desc: "hacks are for winners"
  3018. }, {
  3019. id: 51,
  3020. name: "Moo Cap",
  3021. price: 0,
  3022. scale: 120,
  3023. desc: "coolest mooer around"
  3024. }, {
  3025. id: 50,
  3026. name: "Apple Cap",
  3027. price: 0,
  3028. scale: 120,
  3029. desc: "apple farms remembers"
  3030. }, {
  3031. id: 28,
  3032. name: "Moo Head",
  3033. price: 0,
  3034. scale: 120,
  3035. desc: "no effect"
  3036. }, {
  3037. id: 29,
  3038. name: "Pig Head",
  3039. price: 0,
  3040. scale: 120,
  3041. desc: "no effect"
  3042. }, {
  3043. id: 30,
  3044. name: "Fluff Head",
  3045. price: 0,
  3046. scale: 120,
  3047. desc: "no effect"
  3048. }, {
  3049. id: 36,
  3050. name: "Pandou Head",
  3051. price: 0,
  3052. scale: 120,
  3053. desc: "no effect"
  3054. }, {
  3055. id: 37,
  3056. name: "Bear Head",
  3057. price: 0,
  3058. scale: 120,
  3059. desc: "no effect"
  3060. }, {
  3061. id: 38,
  3062. name: "Monkey Head",
  3063. price: 0,
  3064. scale: 120,
  3065. desc: "no effect"
  3066. }, {
  3067. id: 44,
  3068. name: "Polar Head",
  3069. price: 0,
  3070. scale: 120,
  3071. desc: "no effect"
  3072. }, {
  3073. id: 35,
  3074. name: "Fez Hat",
  3075. price: 0,
  3076. scale: 120,
  3077. desc: "no effect"
  3078. }, {
  3079. id: 42,
  3080. name: "Enigma Hat",
  3081. price: 0,
  3082. scale: 120,
  3083. desc: "join the enigma army"
  3084. }, {
  3085. id: 43,
  3086. name: "Blitz Hat",
  3087. price: 0,
  3088. scale: 120,
  3089. desc: "hey everybody i'm blitz"
  3090. }, {
  3091. id: 49,
  3092. name: "Bob XIII Hat",
  3093. price: 0,
  3094. scale: 120,
  3095. desc: "like and subscribe"
  3096. }, {
  3097. id: 57,
  3098. name: "Pumpkin",
  3099. price: 50,
  3100. scale: 120,
  3101. desc: "Spooooky"
  3102. }, {
  3103. id: 8,
  3104. name: "Bummle Hat",
  3105. price: 100,
  3106. scale: 120,
  3107. desc: "no effect"
  3108. }, {
  3109. id: 2,
  3110. name: "Straw Hat",
  3111. price: 500,
  3112. scale: 120,
  3113. desc: "no effect"
  3114. }, {
  3115. id: 15,
  3116. name: "Winter Cap",
  3117. price: 600,
  3118. scale: 120,
  3119. desc: "allows you to move at normal speed in snow",
  3120. coldM: 1
  3121. }, {
  3122. id: 5,
  3123. name: "Cowboy Hat",
  3124. price: 1000,
  3125. scale: 120,
  3126. desc: "no effect"
  3127. }, {
  3128. id: 4,
  3129. name: "Ranger Hat",
  3130. price: 2000,
  3131. scale: 120,
  3132. desc: "no effect"
  3133. }, {
  3134. id: 18,
  3135. name: "Explorer Hat",
  3136. price: 2000,
  3137. scale: 120,
  3138. desc: "no effect"
  3139. }, {
  3140. id: 31,
  3141. name: "Flipper Hat",
  3142. price: 2500,
  3143. scale: 120,
  3144. desc: "have more control while in water",
  3145. watrImm: true
  3146. }, {
  3147. id: 1,
  3148. name: "Marksman Cap",
  3149. price: 3000,
  3150. scale: 120,
  3151. desc: "increases arrow speed and range",
  3152. aMlt: 1.3
  3153. }, {
  3154. id: 10,
  3155. name: "Bush Gear",
  3156. price: 3000,
  3157. scale: 160,
  3158. desc: "allows you to disguise yourself as a bush"
  3159. }, {
  3160. id: 48,
  3161. name: "Halo",
  3162. price: 3000,
  3163. scale: 120,
  3164. desc: "no effect"
  3165. }, {
  3166. id: 6,
  3167. name: "Soldier Helmet",
  3168. price: 4000,
  3169. scale: 120,
  3170. desc: "reduces damage taken but slows movement",
  3171. spdMult: 0.94,
  3172. dmgMult: 0.75
  3173. }, {
  3174. id: 23,
  3175. name: "Anti Venom Gear",
  3176. price: 4000,
  3177. scale: 120,
  3178. desc: "makes you immune to poison",
  3179. poisonRes: 1
  3180. }, {
  3181. id: 13,
  3182. name: "Medic Gear",
  3183. price: 5000,
  3184. scale: 110,
  3185. desc: "slowly regenerates health over time",
  3186. healthRegen: 3
  3187. }, {
  3188. id: 9,
  3189. name: "Miners Helmet",
  3190. price: 5000,
  3191. scale: 120,
  3192. desc: "earn 1 extra gold per resource",
  3193. extraGold: 1
  3194. }, {
  3195. id: 32,
  3196. name: "Musketeer Hat",
  3197. price: 5000,
  3198. scale: 120,
  3199. desc: "reduces cost of projectiles",
  3200. projCost: 0.5
  3201. }, {
  3202. id: 7,
  3203. name: "Bull Helmet",
  3204. price: 6000,
  3205. scale: 120,
  3206. desc: "increases damage done but drains health",
  3207. healthRegen: -5,
  3208. dmgMultO: 1.5,
  3209. spdMult: 0.96
  3210. }, {
  3211. id: 22,
  3212. name: "Emp Helmet",
  3213. price: 6000,
  3214. scale: 120,
  3215. desc: "turrets won't attack but you move slower",
  3216. antiTurret: 1,
  3217. spdMult: 0.7
  3218. }, {
  3219. id: 12,
  3220. name: "Booster Hat",
  3221. price: 6000,
  3222. scale: 120,
  3223. desc: "increases your movement speed",
  3224. spdMult: 1.16
  3225. }, {
  3226. id: 26,
  3227. name: "Barbarian Armor",
  3228. price: 8000,
  3229. scale: 120,
  3230. desc: "knocks back enemies that attack you",
  3231. dmgK: 0.6
  3232. }, {
  3233. id: 21,
  3234. name: "Plague Mask",
  3235. price: 10000,
  3236. scale: 120,
  3237. desc: "melee attacks deal poison damage",
  3238. poisonDmg: 5,
  3239. poisonTime: 6
  3240. }, {
  3241. id: 46,
  3242. name: "Bull Mask",
  3243. price: 10000,
  3244. scale: 120,
  3245. desc: "bulls won't target you unless you attack them",
  3246. bullRepel: 1
  3247. }, {
  3248. id: 14,
  3249. name: "Windmill Hat",
  3250. topSprite: true,
  3251. price: 10000,
  3252. scale: 120,
  3253. desc: "generates points while worn",
  3254. pps: 1.5
  3255. }, {
  3256. id: 11,
  3257. name: "Spike Gear",
  3258. topSprite: true,
  3259. price: 10000,
  3260. scale: 120,
  3261. desc: "deal damage to players that damage you",
  3262. dmg: 0.45
  3263. }, {
  3264. id: 53,
  3265. name: "Turret Gear",
  3266. topSprite: true,
  3267. price: 10000,
  3268. scale: 120,
  3269. desc: "you become a walking turret",
  3270. turret: {
  3271. proj: 1,
  3272. range: 700,
  3273. rate: 2500
  3274. },
  3275. spdMult: 0.7
  3276. }, {
  3277. id: 20,
  3278. name: "Samurai Armor",
  3279. price: 12000,
  3280. scale: 120,
  3281. desc: "increased attack speed and fire rate",
  3282. atkSpd: 0.78
  3283. }, {
  3284. id: 58,
  3285. name: "Dark Knight",
  3286. price: 12000,
  3287. scale: 120,
  3288. desc: "restores health when you deal damage",
  3289. healD: 0.4
  3290. }, {
  3291. id: 27,
  3292. name: "Scavenger Gear",
  3293. price: 15000,
  3294. scale: 120,
  3295. desc: "earn double points for each kill",
  3296. kScrM: 2
  3297. }, {
  3298. id: 40,
  3299. name: "Tank Gear",
  3300. price: 15000,
  3301. scale: 120,
  3302. desc: "increased damage to buildings but slower movement",
  3303. spdMult: 0.3,
  3304. bDmg: 3.3
  3305. }, {
  3306. id: 52,
  3307. name: "Thief Gear",
  3308. price: 15000,
  3309. scale: 120,
  3310. desc: "steal half of a players gold when you kill them",
  3311. goldSteal: 0.5
  3312. }, {
  3313. id: 55,
  3314. name: "Bloodthirster",
  3315. price: 20000,
  3316. scale: 120,
  3317. desc: "Restore Health when dealing damage. And increased damage",
  3318. healD: 0.25,
  3319. dmgMultO: 1.2,
  3320. }, {
  3321. id: 56,
  3322. name: "Assassin Gear",
  3323. price: 20000,
  3324. scale: 120,
  3325. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3326. noEat: true,
  3327. spdMult: 1.1,
  3328. invisTimer: 1000
  3329. }];
  3330.  
  3331. // STORE ACCESSORIES:
  3332. this.accessories = [{
  3333. id: 12,
  3334. name: "Snowball",
  3335. price: 1000,
  3336. scale: 105,
  3337. xOff: 18,
  3338. desc: "no effect"
  3339. }, {
  3340. id: 9,
  3341. name: "Tree Cape",
  3342. price: 1000,
  3343. scale: 90,
  3344. desc: "no effect"
  3345. }, {
  3346. id: 10,
  3347. name: "Stone Cape",
  3348. price: 1000,
  3349. scale: 90,
  3350. desc: "no effect"
  3351. }, {
  3352. id: 3,
  3353. name: "Cookie Cape",
  3354. price: 1500,
  3355. scale: 90,
  3356. desc: "no effect"
  3357. }, {
  3358. id: 8,
  3359. name: "Cow Cape",
  3360. price: 2000,
  3361. scale: 90,
  3362. desc: "no effect"
  3363. }, {
  3364. id: 11,
  3365. name: "Monkey Tail",
  3366. price: 2000,
  3367. scale: 97,
  3368. xOff: 25,
  3369. desc: "Super speed but reduced damage",
  3370. spdMult: 1.35,
  3371. dmgMultO: 0.2
  3372. }, {
  3373. id: 17,
  3374. name: "Apple Basket",
  3375. price: 3000,
  3376. scale: 80,
  3377. xOff: 12,
  3378. desc: "slowly regenerates health over time",
  3379. healthRegen: 1
  3380. }, {
  3381. id: 6,
  3382. name: "Winter Cape",
  3383. price: 3000,
  3384. scale: 90,
  3385. desc: "no effect"
  3386. }, {
  3387. id: 4,
  3388. name: "Skull Cape",
  3389. price: 4000,
  3390. scale: 90,
  3391. desc: "no effect"
  3392. }, {
  3393. id: 5,
  3394. name: "Dash Cape",
  3395. price: 5000,
  3396. scale: 90,
  3397. desc: "no effect"
  3398. }, {
  3399. id: 2,
  3400. name: "Dragon Cape",
  3401. price: 6000,
  3402. scale: 90,
  3403. desc: "no effect"
  3404. }, {
  3405. id: 1,
  3406. name: "Super Cape",
  3407. price: 8000,
  3408. scale: 90,
  3409. desc: "no effect"
  3410. }, {
  3411. id: 7,
  3412. name: "Troll Cape",
  3413. price: 8000,
  3414. scale: 90,
  3415. desc: "no effect"
  3416. }, {
  3417. id: 14,
  3418. name: "Thorns",
  3419. price: 10000,
  3420. scale: 115,
  3421. xOff: 20,
  3422. desc: "no effect"
  3423. }, {
  3424. id: 15,
  3425. name: "Blockades",
  3426. price: 10000,
  3427. scale: 95,
  3428. xOff: 15,
  3429. desc: "no effect"
  3430. }, {
  3431. id: 20,
  3432. name: "Devils Tail",
  3433. price: 10000,
  3434. scale: 95,
  3435. xOff: 20,
  3436. desc: "no effect"
  3437. }, {
  3438. id: 16,
  3439. name: "Sawblade",
  3440. price: 12000,
  3441. scale: 90,
  3442. spin: true,
  3443. xOff: 0,
  3444. desc: "deal damage to players that damage you",
  3445. dmg: 0.15
  3446. }, {
  3447. id: 13,
  3448. name: "Angel Wings",
  3449. price: 15000,
  3450. scale: 138,
  3451. xOff: 22,
  3452. desc: "slowly regenerates health over time",
  3453. healthRegen: 3
  3454. }, {
  3455. id: 19,
  3456. name: "Shadow Wings",
  3457. price: 15000,
  3458. scale: 138,
  3459. xOff: 22,
  3460. desc: "increased movement speed",
  3461. spdMult: 1.1
  3462. }, {
  3463. id: 18,
  3464. name: "Blood Wings",
  3465. price: 20000,
  3466. scale: 178,
  3467. xOff: 26,
  3468. desc: "restores health when you deal damage",
  3469. healD: 0.2
  3470. }, {
  3471. id: 21,
  3472. name: "Corrupt X Wings",
  3473. price: 20000,
  3474. scale: 178,
  3475. xOff: 26,
  3476. desc: "deal damage to players that damage you",
  3477. dmg: 0.25
  3478. }];
  3479. }
  3480. };
  3481. class ProjectileManager {
  3482. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3483. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3484. let tmpData = items.projectiles[indx];
  3485. let tmpProj;
  3486. for (let i = 0; i < projectiles.length; ++i) {
  3487. if (!projectiles[i].active) {
  3488. tmpProj = projectiles[i];
  3489. break;
  3490. }
  3491. }
  3492. if (!tmpProj) {
  3493. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3494. tmpProj.sid = projectiles.length;
  3495. projectiles.push(tmpProj);
  3496. }
  3497. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3498. tmpProj.ignoreObj = ignoreObj;
  3499. tmpProj.layer = layer || tmpData.layer;
  3500. tmpProj.inWindow = inWindow;
  3501. tmpProj.src = tmpData.src;
  3502. return tmpProj;
  3503. };
  3504. }
  3505. };
  3506. class AiManager {
  3507.  
  3508. // AI MANAGER:
  3509. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3510.  
  3511. // AI TYPES:
  3512. this.aiTypes = [{
  3513. id: 0,
  3514. src: "cow_1",
  3515. killScore: 150,
  3516. health: 500,
  3517. weightM: 0.8,
  3518. speed: 0.00095,
  3519. turnSpeed: 0.001,
  3520. scale: 72,
  3521. drop: ["food", 50]
  3522. }, {
  3523. id: 1,
  3524. src: "pig_1",
  3525. killScore: 200,
  3526. health: 800,
  3527. weightM: 0.6,
  3528. speed: 0.00085,
  3529. turnSpeed: 0.001,
  3530. scale: 72,
  3531. drop: ["food", 80]
  3532. }, {
  3533. id: 2,
  3534. name: "Bull",
  3535. src: "bull_2",
  3536. hostile: true,
  3537. dmg: 20,
  3538. killScore: 1000,
  3539. health: 1800,
  3540. weightM: 0.5,
  3541. speed: 0.00094,
  3542. turnSpeed: 0.00074,
  3543. scale: 78,
  3544. viewRange: 800,
  3545. chargePlayer: true,
  3546. drop: ["food", 100]
  3547. }, {
  3548. id: 3,
  3549. name: "Bully",
  3550. src: "bull_1",
  3551. hostile: true,
  3552. dmg: 20,
  3553. killScore: 2000,
  3554. health: 2800,
  3555. weightM: 0.45,
  3556. speed: 0.001,
  3557. turnSpeed: 0.0008,
  3558. scale: 90,
  3559. viewRange: 900,
  3560. chargePlayer: true,
  3561. drop: ["food", 400]
  3562. }, {
  3563. id: 4,
  3564. name: "Wolf",
  3565. src: "wolf_1",
  3566. hostile: true,
  3567. dmg: 8,
  3568. killScore: 500,
  3569. health: 300,
  3570. weightM: 0.45,
  3571. speed: 0.001,
  3572. turnSpeed: 0.002,
  3573. scale: 84,
  3574. viewRange: 800,
  3575. chargePlayer: true,
  3576. drop: ["food", 200]
  3577. }, {
  3578. id: 5,
  3579. name: "Quack",
  3580. src: "chicken_1",
  3581. dmg: 8,
  3582. killScore: 2000,
  3583. noTrap: true,
  3584. health: 300,
  3585. weightM: 0.2,
  3586. speed: 0.0018,
  3587. turnSpeed: 0.006,
  3588. scale: 70,
  3589. drop: ["food", 100]
  3590. }, {
  3591. id: 6,
  3592. name: "MOOSTAFA",
  3593. nameScale: 50,
  3594. src: "enemy",
  3595. hostile: true,
  3596. dontRun: true,
  3597. fixedSpawn: true,
  3598. spawnDelay: 60000,
  3599. noTrap: true,
  3600. colDmg: 100,
  3601. dmg: 40,
  3602. killScore: 8000,
  3603. health: 18000,
  3604. weightM: 0.4,
  3605. speed: 0.0007,
  3606. turnSpeed: 0.01,
  3607. scale: 80,
  3608. spriteMlt: 1.8,
  3609. leapForce: 0.9,
  3610. viewRange: 1000,
  3611. hitRange: 210,
  3612. hitDelay: 1000,
  3613. chargePlayer: true,
  3614. drop: ["food", 100]
  3615. }, {
  3616. id: 7,
  3617. name: "Treasure",
  3618. hostile: true,
  3619. nameScale: 35,
  3620. src: "crate_1",
  3621. fixedSpawn: true,
  3622. spawnDelay: 120000,
  3623. colDmg: 200,
  3624. killScore: 5000,
  3625. health: 20000,
  3626. weightM: 0.1,
  3627. speed: 0.0,
  3628. turnSpeed: 0.0,
  3629. scale: 70,
  3630. spriteMlt: 1.0
  3631. }, {
  3632. id: 8,
  3633. name: "MOOFIE",
  3634. src: "wolf_2",
  3635. hostile: true,
  3636. fixedSpawn: true,
  3637. dontRun: true,
  3638. hitScare: 4,
  3639. spawnDelay: 30000,
  3640. noTrap: true,
  3641. nameScale: 35,
  3642. dmg: 10,
  3643. colDmg: 100,
  3644. killScore: 3000,
  3645. health: 7000,
  3646. weightM: 0.45,
  3647. speed: 0.0015,
  3648. turnSpeed: 0.002,
  3649. scale: 90,
  3650. viewRange: 800,
  3651. chargePlayer: true,
  3652. drop: ["food", 1000]
  3653. }];
  3654.  
  3655. // SPAWN AI:
  3656. this.spawn = function(x, y, dir, index) {
  3657. let tmpObj = ais.find((tmp) => !tmp.active);
  3658. if (!tmpObj) {
  3659. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3660. ais.push(tmpObj);
  3661. }
  3662. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3663. return tmpObj;
  3664. };
  3665. }
  3666.  
  3667. };
  3668. class AI {
  3669. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3670. this.sid = sid;
  3671. this.isAI = true;
  3672. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3673.  
  3674. // INIT:
  3675. this.init = function(x, y, dir, index, data) {
  3676. this.x = x;
  3677. this.y = y;
  3678. this.startX = data.fixedSpawn ? x : null;
  3679. this.startY = data.fixedSpawn ? y : null;
  3680. this.xVel = 0;
  3681. this.yVel = 0;
  3682. this.zIndex = 0;
  3683. this.dir = dir;
  3684. this.dirPlus = 0;
  3685. this.showName = 'aaa';
  3686. this.index = index;
  3687. this.src = data.src;
  3688. if (data.name) this.name = data.name;
  3689. this.weightM = data.weightM;
  3690. this.speed = data.speed;
  3691. this.killScore = data.killScore;
  3692. this.turnSpeed = data.turnSpeed;
  3693. this.scale = data.scale;
  3694. this.maxHealth = data.health;
  3695. this.leapForce = data.leapForce;
  3696. this.health = this.maxHealth;
  3697. this.chargePlayer = data.chargePlayer;
  3698. this.viewRange = data.viewRange;
  3699. this.drop = data.drop;
  3700. this.dmg = data.dmg;
  3701. this.hostile = data.hostile;
  3702. this.dontRun = data.dontRun;
  3703. this.hitRange = data.hitRange;
  3704. this.hitDelay = data.hitDelay;
  3705. this.hitScare = data.hitScare;
  3706. this.spriteMlt = data.spriteMlt;
  3707. this.nameScale = data.nameScale;
  3708. this.colDmg = data.colDmg;
  3709. this.noTrap = data.noTrap;
  3710. this.spawnDelay = data.spawnDelay;
  3711. this.hitWait = 0;
  3712. this.waitCount = 1000;
  3713. this.moveCount = 0;
  3714. this.targetDir = 0;
  3715. this.active = true;
  3716. this.alive = true;
  3717. this.runFrom = null;
  3718. this.chargeTarget = null;
  3719. this.dmgOverTime = {};
  3720. };
  3721.  
  3722. let tmpRatio = 0;
  3723. let animIndex = 0;
  3724. this.animate = function(delta) {
  3725. if (this.animTime > 0) {
  3726. this.animTime -= delta;
  3727. if (this.animTime <= 0) {
  3728. this.animTime = 0;
  3729. this.dirPlus = 0;
  3730. tmpRatio = 0;
  3731. animIndex = 0;
  3732. } else {
  3733. if (animIndex == 0) {
  3734. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3735. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3736. if (tmpRatio >= 1) {
  3737. tmpRatio = 1;
  3738. animIndex = 1;
  3739. }
  3740. } else {
  3741. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3742. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3743. }
  3744. }
  3745. }
  3746. };
  3747.  
  3748. // ANIMATION:
  3749. this.startAnim = function() {
  3750. this.animTime = this.animSpeed = 600;
  3751. this.targetAngle = Math.PI * 0.8;
  3752. tmpRatio = 0;
  3753. animIndex = 0;
  3754. };
  3755.  
  3756. };
  3757.  
  3758. };
  3759. class addCh {
  3760. constructor(x, y, chat, tmpObj) {
  3761. this.x = x;
  3762. this.y = y;
  3763. this.alpha = 0;
  3764. this.active = true;
  3765. this.alive = false;
  3766. this.chat = chat;
  3767. this.owner = tmpObj;
  3768. };
  3769. };
  3770. class DeadPlayer {
  3771. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3772. this.x = x;
  3773. this.y = y;
  3774. this.lastDir = dir;
  3775. this.dir = dir + Math.PI;
  3776. this.buildIndex = buildIndex;
  3777. this.weaponIndex = weaponIndex;
  3778. this.weaponVariant = weaponVariant;
  3779. this.skinColor = skinColor;
  3780. this.scale = scale;
  3781. this.visScale = 0;
  3782. this.name = name;
  3783. this.alpha = 1;
  3784. this.active = true;
  3785. this.animate = function(delta) {
  3786. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3787. if (d2 > 0.01) {
  3788. this.dir += d2 / 20;
  3789. } else {
  3790. this.dir = this.lastDir;
  3791. }
  3792. if (this.visScale < this.scale) {
  3793. this.visScale += delta / (this.scale / 2);
  3794. if (this.visScale >= this.scale) {
  3795. this.visScale = this.scale;
  3796. }
  3797. }
  3798. this.alpha -= delta / 30000;
  3799. if (this.alpha <= 0) {
  3800. this.alpha = 0;
  3801. this.active = false;
  3802. }
  3803. }
  3804. }
  3805. };
  3806. class Player {
  3807. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3808. this.id = id;
  3809. this.sid = sid;
  3810. this.tmpScore = 0;
  3811. this.team = null;
  3812. this.latestSkin = 0;
  3813. this.oldSkinIndex = 0;
  3814. this.skinIndex = 0;
  3815. this.latestTail = 0;
  3816. this.oldTailIndex = 0;
  3817. this.tailIndex = 0;
  3818. this.hitTime = 0;
  3819. this.lastHit = 0;
  3820. this.showName = 'NOOO';
  3821. this.tails = {};
  3822. for (let i = 0; i < accessories.length; ++i) {
  3823. if (accessories[i].price <= 0)
  3824. this.tails[accessories[i].id] = 1;
  3825. }
  3826. this.skins = {};
  3827. for (let i = 0; i < hats.length; ++i) {
  3828. if (hats[i].price <= 0)
  3829. this.skins[hats[i].id] = 1;
  3830. }
  3831. this.points = 0;
  3832. this.dt = 0;
  3833. this.hidden = false;
  3834. this.itemCounts = {};
  3835. this.isPlayer = true;
  3836. this.pps = 0;
  3837. this.moveDir = undefined;
  3838. this.skinRot = 0;
  3839. this.lastPing = 0;
  3840. this.iconIndex = 0;
  3841. this.skinColor = 0;
  3842. this.dist2 = 0;
  3843. this.aim2 = 0;
  3844. this.maxSpeed = 1;
  3845. this.chat = {
  3846. message: null,
  3847. count: 0
  3848. };
  3849. this.backupNobull = true;
  3850. this.circle = false;
  3851. this.circleRad = 200;
  3852. this.circleRadSpd = 0.1;
  3853. this.cAngle = 0;
  3854. // SPAWN:
  3855. this.spawn = function(moofoll) {
  3856. this.attacked = false;
  3857. this.timeDamaged = 0;
  3858. this.timeHealed = 0;
  3859. this.pinge = 0;
  3860. this.millPlace = 'NOOO';
  3861. this.lastshamecount = 0;
  3862. this.death = false;
  3863. this.spinDir = 0;
  3864. this.sync = false;
  3865. this.antiBull = 0;
  3866. this.bullTimer = 0;
  3867. this.poisonTimer = 0;
  3868. this.active = true;
  3869. this.alive = true;
  3870. this.lockMove = false;
  3871. this.lockDir = false;
  3872. this.minimapCounter = 0;
  3873. this.chatCountdown = 0;
  3874. this.shameCount = 0;
  3875. this.shameTimer = 0;
  3876. this.sentTo = {};
  3877. this.gathering = 0;
  3878. this.gatherIndex = 0;
  3879. this.shooting = {};
  3880. this.shootIndex = 9;
  3881. this.autoGather = 0;
  3882. this.animTime = 0;
  3883. this.animSpeed = 0;
  3884. this.mouseState = 0;
  3885. this.buildIndex = -1;
  3886. this.weaponIndex = 0;
  3887. this.weaponCode = 0;
  3888. this.weaponVariant = 0;
  3889. this.primaryIndex = undefined;
  3890. this.secondaryIndex = undefined;
  3891. this.dmgOverTime = {};
  3892. this.noMovTimer = 0;
  3893. this.maxXP = 300;
  3894. this.XP = 0;
  3895. this.age = 1;
  3896. this.kills = 0;
  3897. this.upgrAge = 2;
  3898. this.upgradePoints = 0;
  3899. this.x = 0;
  3900. this.y = 0;
  3901. this.oldXY = {
  3902. x: 0,
  3903. y: 0
  3904. };
  3905. this.zIndex = 0;
  3906. this.xVel = 0;
  3907. this.yVel = 0;
  3908. this.slowMult = 1;
  3909. this.dir = 0;
  3910. this.dirPlus = 0;
  3911. this.targetDir = 0;
  3912. this.targetAngle = 0;
  3913. this.maxHealth = 100;
  3914. this.health = this.maxHealth;
  3915. this.oldHealth = this.maxHealth;
  3916. this.damaged = 0;
  3917. this.scale = config.playerScale;
  3918. this.speed = config.playerSpeed;
  3919. this.resetMoveDir();
  3920. this.resetResources(moofoll);
  3921. this.items = [0, 3, 6, 10];
  3922. this.weapons = [0];
  3923. this.shootCount = 0;
  3924. this.weaponXP = [];
  3925. this.reloads = {
  3926. 0: 0,
  3927. 1: 0,
  3928. 2: 0,
  3929. 3: 0,
  3930. 4: 0,
  3931. 5: 0,
  3932. 6: 0,
  3933. 7: 0,
  3934. 8: 0,
  3935. 9: 0,
  3936. 10: 0,
  3937. 11: 0,
  3938. 12: 0,
  3939. 13: 0,
  3940. 14: 0,
  3941. 15: 0,
  3942. 53: 0,
  3943. };
  3944. this.bowThreat = {
  3945. 9: 0,
  3946. 12: 0,
  3947. 13: 0,
  3948. 15: 0,
  3949. };
  3950. this.damageThreat = 0;
  3951. this.inTrap = false;
  3952. this.canEmpAnti = false;
  3953. this.empAnti = false;
  3954. this.soldierAnti = false;
  3955. this.poisonTick = 0;
  3956. this.bullTick = 0;
  3957. this.setPoisonTick = false;
  3958. this.setBullTick = false;
  3959. this.antiTimer = 2;
  3960. };
  3961.  
  3962. // RESET MOVE DIR:
  3963. this.resetMoveDir = function() {
  3964. this.moveDir = undefined;
  3965. };
  3966.  
  3967. // RESET RESOURCES:
  3968. this.resetResources = function(moofoll) {
  3969. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3970. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3971. }
  3972. };
  3973.  
  3974. // ADD ITEM:
  3975. this.getItemType = function(id) {
  3976. let findindx = this.items.findIndex((ids) => ids == id);
  3977. if (findindx != -1) {
  3978. return findindx;
  3979. } else {
  3980. return items.checkItem.index(id, this.items);
  3981. }
  3982. };
  3983.  
  3984. // SET DATA:
  3985. this.setData = function(data) {
  3986. this.id = data[0];
  3987. this.sid = data[1];
  3988. this.name = data[2];
  3989. this.x = data[3];
  3990. this.y = data[4];
  3991. this.dir = data[5];
  3992. this.health = data[6];
  3993. this.maxHealth = data[7];
  3994. this.scale = data[8];
  3995. this.skinColor = data[9];
  3996. };
  3997.  
  3998. // UPDATE POISON TICK:
  3999. this.updateTimer = function() {
  4000.  
  4001. this.bullTimer -= 1;
  4002. if (this.bullTimer <= 0) {
  4003. this.setBullTick = false;
  4004. this.bullTick = game.tick - 1;
  4005. this.bullTimer = config.serverUpdateRate;
  4006. }
  4007. this.poisonTimer -= 1;
  4008. if (this.poisonTimer <= 0) {
  4009. this.setPoisonTick = false;
  4010. this.poisonTick = game.tick - 1;
  4011. this.poisonTimer = config.serverUpdateRate;
  4012. }
  4013.  
  4014. };
  4015. this.update = function(delta) {
  4016. if (this.sid == playerSID) {
  4017. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4018. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4019. this.cAngle += this.circleRadSpd;
  4020. }
  4021. if (this.active) {
  4022.  
  4023. // MOVE:
  4024. let gear = {
  4025. skin: findID(hats, this.skinIndex),
  4026. tail: findID(accessories, this.tailIndex)
  4027. }
  4028. 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;
  4029. this.maxSpeed = spdMult;
  4030.  
  4031. }
  4032. };
  4033.  
  4034. let tmpRatio = 0;
  4035. let animIndex = 0;
  4036. this.animate = function(delta) {
  4037. if (this.animTime > 0) {
  4038. this.animTime -= delta;
  4039. if (this.animTime <= 0) {
  4040. this.animTime = 0;
  4041. this.dirPlus = 0;
  4042. tmpRatio = 0;
  4043. animIndex = 0;
  4044. } else {
  4045. if (animIndex == 0) {
  4046. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4047. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4048. if (tmpRatio >= 1) {
  4049. tmpRatio = 1;
  4050. animIndex = 1;
  4051. }
  4052. } else {
  4053. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4054. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4055. }
  4056. }
  4057. }
  4058. };
  4059.  
  4060. // GATHER ANIMATION:
  4061. this.startAnim = function(didHit, index) {
  4062. this.animTime = this.animSpeed = items.weapons[index].speed;
  4063. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4064. tmpRatio = 0;
  4065. animIndex = 0;
  4066. };
  4067.  
  4068. // CAN SEE:
  4069. this.canSee = function(other) {
  4070. if (!other) return false;
  4071. let dx = Math.abs(other.x - this.x) - other.scale;
  4072. let dy = Math.abs(other.y - this.y) - other.scale;
  4073. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4074. };
  4075.  
  4076. // SHAME SYSTEM:
  4077. this.judgeShame = function() {
  4078. this.lastshamecount = this.shameCount;
  4079. if (this.oldHealth < this.health) {
  4080. if (this.hitTime) {
  4081. let timeSinceHit = game.tick - this.hitTime;
  4082. this.lastHit = game.tick;
  4083. this.hitTime = 0;
  4084. if (timeSinceHit < 2) {
  4085. this.shameCount++;
  4086. } else {
  4087. this.shameCount = Math.max(0, this.shameCount - 2);
  4088. }
  4089. }
  4090. } else if (this.oldHealth > this.health) {
  4091. this.hitTime = game.tick;
  4092. }
  4093. };
  4094. this.addShameTimer = function() {
  4095. this.shameCount = 0;
  4096. this.shameTimer = 30;
  4097. let interval = setInterval(() => {
  4098. this.shameTimer--;
  4099. if (this.shameTimer <= 0) {
  4100. clearInterval(interval);
  4101. }
  4102. }, 1000);
  4103. };
  4104.  
  4105. // CHECK TEAM:
  4106. this.isTeam = function(tmpObj) {
  4107. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4108. };
  4109.  
  4110. // FOR THE PLAYER:
  4111. this.findAllianceBySid = function(sid) {
  4112. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4113. };
  4114. this.checkCanInsta = function(nobull) {
  4115. let totally = 0;
  4116. if (this.alive && inGame) {
  4117. let primary = {
  4118. weapon: this.weapons[0],
  4119. variant: this.primaryVariant,
  4120. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4121. };
  4122. let secondary = {
  4123. weapon: this.weapons[1],
  4124. variant: this.secondaryVariant,
  4125. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4126. };
  4127. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4128. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4129. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4130. totally += primary.dmg * pV * bull;
  4131. }
  4132. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4133. totally += secondary.dmg;
  4134. }
  4135. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4136. totally += 25;
  4137. }
  4138. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4139. return totally;
  4140. }
  4141. return 0;
  4142. };
  4143.  
  4144. // UPDATE WEAPON RELOAD:
  4145. this.manageReload = function() {
  4146. if (this.shooting[53]) {
  4147. this.shooting[53] = 0;
  4148. this.reloads[53] = (2500 - game.tickRate);
  4149. } else {
  4150. if (this.reloads[53] > 0) {
  4151. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4152. }
  4153. }
  4154.  
  4155. //preplacer
  4156. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4157. // place(2, getAttackDir());
  4158. let index = this.weaponIndex;
  4159. 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));
  4160. for(let i = 0; i < nearObja.length; i++) {
  4161. let aaa = nearObja[i];
  4162.  
  4163. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4164. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4165. if(aaa.health - (valaa) <= 0 && near.length) {
  4166. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI);
  4167. }
  4168. }
  4169. }
  4170.  
  4171. if (this.gathering || this.shooting[1]) {
  4172. if (this.gathering) {
  4173. this.gathering = 0;
  4174. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4175. this.attacked = true;
  4176. }
  4177. if (this.shooting[1]) {
  4178. this.shooting[1] = 0;
  4179. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4180. this.attacked = true;
  4181. }
  4182. } else {
  4183. this.attacked = false;
  4184. if (this.buildIndex < 0) {
  4185. if (this.reloads[this.weaponIndex] > 0) {
  4186. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4187. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4188. if (this == player) {
  4189. if (getEl("weaponGrind").checked) {
  4190. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4191. checkPlace(player.getItemType(22), i);
  4192. }
  4193. }
  4194. }
  4195. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4196. this.antiBull++;
  4197. game.tickBase(() => {
  4198. this.antiBull = 0;
  4199. }, 1);
  4200. }
  4201. }
  4202. }
  4203. }
  4204. };
  4205.  
  4206. // FOR ANTI INSTA:
  4207. this.addDamageThreat = function(tmpObj) {
  4208. let primary = {
  4209. weapon: this.primaryIndex,
  4210. variant: this.primaryVariant
  4211. };
  4212. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4213. let secondary = {
  4214. weapon: this.secondaryIndex,
  4215. variant: this.secondaryVariant
  4216. };
  4217. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4218. let bull = 1.5;
  4219. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4220. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4221. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4222. this.damageThreat += primary.dmg * pV * bull;
  4223. }
  4224. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4225. this.damageThreat += secondary.dmg * sV;
  4226. }
  4227. if (this.reloads[53] <= game.tickRate) {
  4228. this.damageThreat += 25;
  4229. }
  4230. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4231. if (!this.isTeam(tmpObj)) {
  4232. if (this.dist2 <= 300) {
  4233. tmpObj.damageThreat += this.damageThreat;
  4234. }
  4235. }
  4236. };
  4237.  
  4238. }
  4239. };
  4240.  
  4241. // SOME CODES:
  4242. function sendUpgrade(index) {
  4243. player.reloads[index] = 0;
  4244. packet("H", index);
  4245. }
  4246.  
  4247. function storeEquip(id, index) {
  4248. packet("c", 0, id, index);
  4249. }
  4250.  
  4251. function storeBuy(id, index) {
  4252. packet("c", 1, id, index);
  4253. }
  4254.  
  4255. function buyEquip(id, index) {
  4256. let nID = player.skins[6] ? 6 : 0;
  4257. if (player.alive && inGame) {
  4258. if (index == 0) {
  4259. if (player.skins[id]) {
  4260. if (player.latestSkin != id) {
  4261. packet("c", 0, id, 0);
  4262. }
  4263. } else {
  4264. if (configs.autoBuyEquip) {
  4265. let find = findID(hats, id);
  4266. if (find) {
  4267. if (player.points >= find.price) {
  4268. packet("c", 1, id, 0);
  4269. packet("c", 0, id, 0);
  4270. } else {
  4271. if (player.latestSkin != nID) {
  4272. packet("c", 0, nID, 0);
  4273. }
  4274. }
  4275. } else {
  4276. if (player.latestSkin != nID) {
  4277. packet("c", 0, nID, 0);
  4278. }
  4279. }
  4280. } else {
  4281. if (player.latestSkin != nID) {
  4282. packet("c", 0, nID, 0);
  4283. }
  4284. }
  4285. }
  4286. } else if (index == 1) {
  4287. if (useWasd && (id != 11 && id != 0)) {
  4288. if (player.latestTail != 0) {
  4289. packet("c", 0, 0, 1);
  4290. }
  4291. return;
  4292. }
  4293. if (player.tails[id]) {
  4294. if (player.latestTail != id) {
  4295. packet("c", 0, id, 1);
  4296. }
  4297. } else {
  4298. if (configs.autoBuyEquip) {
  4299. let find = findID(accessories, id);
  4300. if (find) {
  4301. if (player.points >= find.price) {
  4302. packet("c", 1, id, 1);
  4303. packet("c", 0, id, 1);
  4304. } else {
  4305. if (player.latestTail != 0) {
  4306. packet("c", 0, 0, 1);
  4307. }
  4308. }
  4309. } else {
  4310. if (player.latestTail != 0) {
  4311. packet("c", 0, 0, 1);
  4312. }
  4313. }
  4314. } else {
  4315. if (player.latestTail != 0) {
  4316. packet("c", 0, 0, 1);
  4317. }
  4318. }
  4319. }
  4320. }
  4321. }
  4322. }
  4323.  
  4324. function selectToBuild(index, wpn) {
  4325. packet("G", index, wpn);
  4326. }
  4327.  
  4328. function selectWeapon(index, isPlace) {
  4329. if (!isPlace) {
  4330. player.weaponCode = index;
  4331. }
  4332. packet("G", index, 1);
  4333. }
  4334.  
  4335. function sendAutoGather() {
  4336. packet("K", 1, 1);
  4337. }
  4338.  
  4339. function sendAtck(id, angle) {
  4340. packet("d", id, angle, 1);
  4341. }
  4342.  
  4343. // PLACER:
  4344. function place(id, rad, rmd) {
  4345. try {
  4346. if (id == undefined) return;
  4347. let item = items.list[player.items[id]];
  4348. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4349. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4350. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4351. 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))) {
  4352. selectToBuild(player.items[id]);
  4353. sendAtck(1, rad);
  4354. selectWeapon(player.weaponCode, 1);
  4355. if (rmd && getEl("placeVis").checked) {
  4356. placeVisible.push({
  4357. x: tmpX,
  4358. y: tmpY,
  4359. name: item.name,
  4360. scale: item.scale,
  4361. dir: rad
  4362. });
  4363. game.tickBase(() => {
  4364. placeVisible.shift();
  4365. }, 1)
  4366. }
  4367. }
  4368. } catch (e) {}
  4369. }
  4370.  
  4371. function checkPlace(id, rad) {
  4372. try {
  4373. if (id == undefined) return;
  4374. let item = items.list[player.items[id]];
  4375. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4376. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4377. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4378. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4379. place(id, rad, 1);
  4380. }
  4381. } catch (e) {}
  4382. }
  4383.  
  4384. // HEALING:
  4385. function soldierMult() {
  4386. return player.latestSkin == 6 ? 0.75 : 1;
  4387. }
  4388.  
  4389. function healthBased() {
  4390. if (player.health == 100)
  4391. return 0;
  4392. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4393. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4394. }
  4395. return 0;
  4396. }
  4397.  
  4398. function getAttacker(damaged) {
  4399. let attackers = enemy.filter(tmp => {
  4400. //let damages = new Damages(items);
  4401. //let dmg = damages.weapons[tmp.weaponIndex];
  4402. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4403. let rule = {
  4404. //one: tmp.dist2 <= 300,
  4405. //two: by.includes(damaged),
  4406. three: tmp.attacked
  4407. }
  4408. return /*rule.one && rule.two && */ rule.three;
  4409. });
  4410. return attackers;
  4411. }
  4412.  
  4413. function healer() {
  4414. for (let i = 0; i < healthBased(); i++) {
  4415. place(0, getAttackDir());
  4416. }
  4417. }
  4418.  
  4419. function antiSyncHealing(timearg) {
  4420. my.antiSync = true;
  4421. let healAnti = setInterval(() => {
  4422. if (player.shameCount < 5) {
  4423. place(0, getAttackDir());
  4424. }
  4425. }, 75);
  4426. setTimeout(() => {
  4427. clearInterval(healAnti);
  4428. setTimeout(() => {
  4429. my.antiSync = false;
  4430. }, game.tickRate);
  4431. }, game.tickRate);
  4432. }
  4433.  
  4434. function biomeGear(mover, returns) {
  4435. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4436. if (returns) return 31;
  4437. buyEquip(31, 0);
  4438. } else {
  4439. if (player.y2 <= config.snowBiomeTop) {
  4440. if (returns) return 6;
  4441. buyEquip(6, 0);
  4442. } else {
  4443. if (returns) return 6;
  4444. buyEquip(6, 0);
  4445. }
  4446. }
  4447. if (returns) return 0;
  4448. }
  4449.  
  4450. class Traps {
  4451. constructor(UTILS, items) {
  4452. this.dist = 0;
  4453. this.aim = 0;
  4454. this.inTrap = false;
  4455. this.replaced = false;
  4456. this.antiTrapped = false;
  4457. this.info = {};
  4458. this.notFast = function() {
  4459. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4460. }
  4461. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4462. try {
  4463. let item = items.list[player.items[id]];
  4464. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4465. let counts = {
  4466. attempts: 0,
  4467. placed: 0
  4468. };
  4469. let tmpObjects = [];
  4470. liztobj.forEach((p) => {
  4471. tmpObjects.push({
  4472. x: p.x,
  4473. y: p.y,
  4474. active: p.active,
  4475. blocker: p.blocker,
  4476. scale: p.scale,
  4477. isItem: p.isItem,
  4478. type: p.type,
  4479. colDiv: p.colDiv,
  4480. getScale: function(sM, ig) {
  4481. sM = sM || 1;
  4482. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4483. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4484. },
  4485. });
  4486. });
  4487. for (let i = first; i < repeat; i += plus) {
  4488. counts.attempts++;
  4489. let relAim = radian + i;
  4490. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4491. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4492. 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)));
  4493. if (cantPlace) continue;
  4494. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4495. if ((!replacer && yaboi)) {
  4496. if (yaboi.inTrap) {
  4497. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI*1.3) {
  4498. place(2, relAim, 1);
  4499. } else {
  4500. player.items[4] == 15 && place(4, relAim, 1);
  4501. }
  4502. } else {
  4503. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 2.6) {
  4504. place(2, relAim, 1);
  4505. } else {
  4506. player.items[4] == 15 && place(4, relAim, 1);
  4507. }
  4508. }
  4509. } else {
  4510. place(id, relAim, 1);
  4511. }
  4512. tmpObjects.push({
  4513. x: tmpX,
  4514. y: tmpY,
  4515. active: true,
  4516. blocker: item.blocker,
  4517. scale: item.scale,
  4518. isItem: true,
  4519. type: null,
  4520. colDiv: item.colDiv,
  4521. getScale: function() {
  4522. return this.scale;
  4523. },
  4524. });
  4525. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4526. counts.placed++;
  4527. }
  4528. }
  4529. if (counts.placed > 0 && replacer && item.dmg) {
  4530. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4531. instaC.canSpikeTick = true;
  4532. }
  4533. }
  4534. } catch (err) {
  4535. }
  4536. };
  4537. this.checkSpikeTick = function() {
  4538. try {
  4539. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4540. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4541. // more range for safe. also testing near.primaryIndex || 5
  4542. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4543. let item = items.list[9];
  4544. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4545. let danger = 0;
  4546. let counts = {
  4547. attempts: 0,
  4548. block: `unblocked`
  4549. };
  4550. for (let i = -1; i <= 1; i += 1 / 10) {
  4551. counts.attempts++;
  4552. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4553. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4554. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4555. 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)));
  4556. if (cantPlace) continue;
  4557. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4558. danger++;
  4559. counts.block = `blocked`;
  4560. break;
  4561. }
  4562. if (danger) {
  4563. my.anti0Tick = 1;
  4564. // player.chat.message = "Anti SpikeTick " + near.sid;
  4565. //player.chat.count = 2000;
  4566. return true;
  4567. }
  4568. }
  4569. } catch (err) {
  4570. return null;
  4571. }
  4572. return false;
  4573. }
  4574.  
  4575. function getDist(e, t) {
  4576. try {
  4577. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4578. } catch (e) {
  4579. return Infinity;
  4580. }
  4581. }
  4582.  
  4583. this.protect = function(aim) {
  4584. if (!configs.antiTrap) return;
  4585. if(getDist(near, player) > getDist(near, traps.info)) {
  4586. //behind u
  4587. for(let i=-(Math.PI / 2);i<(Math.PI / 2);i+=(Math.PI / 18)) {
  4588. checkPlace(2, near.aim2 + i);
  4589. }
  4590. } else if(getDist(near, traps.info) > getDist(near, player)) {
  4591. //infront of u
  4592. for(let i=-(Math.PI / 2);i<(Math.PI / 2);i+=(Math.PI / 18)) {
  4593. checkPlace(4, near.aim2 + i);
  4594. }
  4595. }
  4596.  
  4597. // if (player.items[4]) {
  4598. // this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4599. // this.antiTrapped = true;
  4600. // }
  4601. };
  4602. this.autoPlace = function() {
  4603. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4604. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4605. if (liztobj.length) {
  4606. let near2 = {
  4607. inTrap: false,
  4608. };
  4609. 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) {
  4610. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4611. })[0];
  4612. if (nearTrap) {
  4613. near2.inTrap = true;
  4614. } else {
  4615. near2.inTrap = false;
  4616. }
  4617. if (near.dist3 <= 450) {
  4618. if (near.dist3 <= 200) {
  4619. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4620. inTrap: near2.inTrap
  4621. });
  4622. } else {
  4623. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4624. }
  4625. }
  4626. } else {
  4627. if (near.dist3 <= 450) {
  4628. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4629. }
  4630. }
  4631. }
  4632. }
  4633. };
  4634. this.replacer = function(findObj) {
  4635. if (!findObj || !configs.autoReplace) return;
  4636. if (!inGame) return;
  4637. if (this.antiTrapped) return;
  4638. game.tickBase(() => {
  4639. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4640. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4641. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4642. if (objDst <= 400 && near.dist2 <= 400) {
  4643. let danger = this.checkSpikeTick();
  4644. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4645. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4646. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4647. } else {
  4648. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4649. }
  4650. this.replaced = true;
  4651. }
  4652. }, 1);
  4653. };
  4654. }
  4655. };
  4656.  
  4657. class Instakill {
  4658. constructor() {
  4659. this.wait = false;
  4660. this.can = false;
  4661. this.isTrue = false;
  4662. this.nobull = false;
  4663. this.ticking = false;
  4664. this.canSpikeTick = false;
  4665. this.startTick = false;
  4666. this.readyTick = false;
  4667. this.canCounter = false;
  4668. this.revTick = false;
  4669. this.syncHit = false;
  4670. this.changeType = function(type) {
  4671. this.wait = false;
  4672. this.isTrue = true;
  4673. my.autoAim = true;
  4674. let instaLog = [type];
  4675. let backupNobull = near.backupNobull;
  4676. near.backupNobull = false;
  4677. if (type == "rev") {
  4678. selectWeapon(player.weapons[1]);
  4679. buyEquip(53, 0);
  4680. sendAutoGather();
  4681. setTimeout(() => {
  4682. selectWeapon(player.weapons[0]);
  4683. buyEquip(7, 0);
  4684. setTimeout(() => {
  4685. sendAutoGather();
  4686. this.isTrue = false;
  4687. my.autoAim = false;
  4688. }, 225);
  4689. }, 100);
  4690. } else if (type == "nobull") {
  4691. selectWeapon(player.weapons[0]);
  4692. buyEquip(7, 0);
  4693. sendAutoGather();
  4694. setTimeout(() => {
  4695. selectWeapon(player.weapons[1]);
  4696. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4697. setTimeout(() => {
  4698. sendAutoGather();
  4699. this.isTrue = false;
  4700. my.autoAim = false;
  4701. }, 255);
  4702. }, 105);
  4703. } else if (type == "normal") {
  4704. selectWeapon(player.weapons[0]);
  4705. buyEquip(7, 0);
  4706. sendAutoGather();
  4707. setTimeout(() => {
  4708. selectWeapon(player.weapons[1]);
  4709. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4710. setTimeout(() => {
  4711. sendAutoGather();
  4712. this.isTrue = false;
  4713. my.autoAim = false;
  4714. }, 255);
  4715. }, 100);
  4716. } else {
  4717. setTimeout(() => {
  4718. this.isTrue = false;
  4719. my.autoAim = false;
  4720. }, 50);
  4721. }
  4722. };
  4723. this.spikeTickType = function() {
  4724. this.isTrue = true;
  4725. my.autoAim = true;
  4726. selectWeapon(player.weapons[0]);
  4727. buyEquip(7, 0);
  4728. sendAutoGather();
  4729. game.tickBase(() => {
  4730. selectWeapon(player.weapons[0]);
  4731. buyEquip(53, 0);
  4732. game.tickBase(() => {
  4733. sendAutoGather();
  4734. this.isTrue = false;
  4735. my.autoAim = false;
  4736. }, 1);
  4737. }, 1);
  4738. };
  4739. this.counterType = function() {
  4740. this.isTrue = true;
  4741. my.autoAim = true;
  4742. selectWeapon(player.weapons[0]);
  4743. buyEquip(7, 0);
  4744. sendAutoGather();
  4745. game.tickBase(() => {
  4746. selectWeapon(player.weapons[0]);
  4747. buyEquip(53, 0);
  4748. game.tickBase(() => {
  4749. sendAutoGather();
  4750. this.isTrue = false;
  4751. my.autoAim = false;
  4752. }, 1);
  4753. }, 1);
  4754. };
  4755. this.rangeType = function(type) {
  4756. this.isTrue = true;
  4757. my.autoAim = true;
  4758. if (type == "ageInsta") {
  4759. my.ageInsta = false;
  4760. if (player.items[5] == 18) {
  4761. place(5, near.aim2);
  4762. }
  4763. packet("a", undefined, 1);
  4764. buyEquip(22, 0);
  4765. buyEquip(21, 1);
  4766. game.tickBase(() => {
  4767. selectWeapon(player.weapons[1]);
  4768. buyEquip(53, 0);
  4769. buyEquip(21, 1);
  4770. sendAutoGather();
  4771. game.tickBase(() => {
  4772. sendUpgrade(12);
  4773. selectWeapon(player.weapons[1]);
  4774. buyEquip(53, 0);
  4775. buyEquip(21, 1);
  4776. game.tickBase(() => {
  4777. sendUpgrade(15);
  4778. selectWeapon(player.weapons[1]);
  4779. buyEquip(53, 0);
  4780. buyEquip(21, 1);
  4781. game.tickBase(() => {
  4782. sendAutoGather();
  4783. this.isTrue = false;
  4784. my.autoAim = false;
  4785. }, 1);
  4786. }, 1);
  4787. }, 1);
  4788. }, 1);
  4789. } else {
  4790. selectWeapon(player.weapons[1]);
  4791. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4792. buyEquip(53, 0);
  4793. } else {
  4794. buyEquip(20, 0);
  4795. }
  4796. buyEquip(11, 1);
  4797. sendAutoGather();
  4798. game.tickBase(() => {
  4799. sendAutoGather();
  4800. this.isTrue = false;
  4801. my.autoAim = false;
  4802. }, 1);
  4803. }
  4804. };
  4805. this.oneTickType = function() {
  4806. this.isTrue = true;
  4807. my.autoAim = true;
  4808. selectWeapon(player.weapons[1]);
  4809. buyEquip(53, 0);
  4810. buyEquip(11, 1);
  4811. packet("a", near.aim2, 1);
  4812. if (player.weapons[1] == 15) {
  4813. my.revAim = true;
  4814. sendAutoGather();
  4815. }
  4816. game.tickBase(() => {
  4817. my.revAim = false;
  4818. selectWeapon(player.weapons[0]);
  4819. buyEquip(7, 0);
  4820. buyEquip(19, 1);
  4821. packet("a", near.aim2, 1);
  4822. if (player.weapons[1] != 15) {
  4823. sendAutoGather();
  4824. }
  4825. game.tickBase(() => {
  4826. sendAutoGather();
  4827. this.isTrue = false;
  4828. my.autoAim = false;
  4829. packet("a", undefined, 1);
  4830. }, 1);
  4831. }, 1);
  4832. };
  4833. this.threeOneTickType = function() {
  4834. this.isTrue = true;
  4835. my.autoAim = true;
  4836. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4837. biomeGear();
  4838. buyEquip(11, 1);
  4839. packet("a", near.aim2, 1);
  4840. game.tickBase(() => {
  4841. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4842. buyEquip(53, 0);
  4843. buyEquip(11, 1);
  4844. packet("a", near.aim2, 1);
  4845. game.tickBase(() => {
  4846. selectWeapon(player.weapons[0]);
  4847. buyEquip(7, 0);
  4848. buyEquip(19, 1);
  4849. sendAutoGather();
  4850. packet("a", near.aim2, 1);
  4851. game.tickBase(() => {
  4852. sendAutoGather();
  4853. this.isTrue = false;
  4854. my.autoAim = false;
  4855. packet("a", undefined, 1);
  4856. }, 1);
  4857. }, 1);
  4858. }, 1);
  4859. };
  4860. this.kmTickType = function() {
  4861. this.isTrue = true;
  4862. my.autoAim = true;
  4863. my.revAim = true;
  4864. selectWeapon(player.weapons[1]);
  4865. buyEquip(53, 0);
  4866. buyEquip(11, 1);
  4867. sendAutoGather();
  4868. packet("a", near.aim2, 1);
  4869. game.tickBase(() => {
  4870. my.revAim = false;
  4871. selectWeapon(player.weapons[0]);
  4872. buyEquip(7, 0);
  4873. buyEquip(19, 1);
  4874. packet("a", near.aim2, 1);
  4875. game.tickBase(() => {
  4876. sendAutoGather();
  4877. this.isTrue = false;
  4878. my.autoAim = false;
  4879. packet("a", undefined, 1);
  4880. }, 1);
  4881. }, 1);
  4882. };
  4883. this.boostTickType = function() {
  4884. /*this.isTrue = true;
  4885. my.autoAim = true;
  4886. selectWeapon(player.weapons[0]);
  4887. buyEquip(53, 0);
  4888. buyEquip(11, 1);
  4889. packet("a", near.aim2);
  4890. game.tickBase(() => {
  4891. place(4, near.aim2);
  4892. selectWeapon(player.weapons[1]);
  4893. biomeGear();
  4894. buyEquip(11, 1);
  4895. sendAutoGather();
  4896. packet("a", near.aim2);
  4897. game.tickBase(() => {
  4898. selectWeapon(player.weapons[0]);
  4899. buyEquip(7, 0);
  4900. buyEquip(19, 1);
  4901. packet("a", near.aim2);
  4902. game.tickBase(() => {
  4903. sendAutoGather();
  4904. this.isTrue = false;
  4905. my.autoAim = false;
  4906. packet("a", undefined);
  4907. }, 1);
  4908. }, 1);
  4909. }, 1);*/
  4910. this.isTrue = true;
  4911. my.autoAim = true;
  4912. biomeGear();
  4913. buyEquip(11, 1);
  4914. packet("a", near.aim2, 1);
  4915. game.tickBase(() => {
  4916. if (player.weapons[1] == 15) {
  4917. my.revAim = true;
  4918. }
  4919. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  4920. buyEquip(53, 0);
  4921. buyEquip(11, 1);
  4922. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  4923. sendAutoGather();
  4924. }
  4925. packet("a", near.aim2, 1);
  4926. place(4, near.aim2);
  4927. game.tickBase(() => {
  4928. my.revAim = false;
  4929. selectWeapon(player.weapons[0]);
  4930. buyEquip(7, 0);
  4931. buyEquip(19, 1);
  4932. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  4933. sendAutoGather();
  4934. }
  4935. packet("a", near.aim2, 1);
  4936. game.tickBase(() => {
  4937. sendAutoGather();
  4938. this.isTrue = false;
  4939. my.autoAim = false;
  4940. packet("a", undefined, 1);
  4941. }, 1);
  4942. }, 1);
  4943. }, 1);
  4944. };
  4945. this.gotoGoal = function(goto, OT) {
  4946. let slowDists = (weeeee) => weeeee * config.playerScale;
  4947. let goal = {
  4948. a: goto - OT,
  4949. b: goto + OT,
  4950. c: goto - slowDists(1),
  4951. d: goto + slowDists(1),
  4952. e: goto - slowDists(2),
  4953. f: goto + slowDists(2),
  4954. g: goto - slowDists(4),
  4955. h: goto + slowDists(4)
  4956. };
  4957. let bQ = function(wwww, awwww) {
  4958. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  4959. buyEquip(31, 0);
  4960. } else {
  4961. buyEquip(wwww, awwww);
  4962. }
  4963. }
  4964. if (enemy.length) {
  4965. let dst = near.dist2;
  4966. this.ticking = true;
  4967. if (dst >= goal.a && dst <= goal.b) {
  4968. bQ(22, 0);
  4969. bQ(11, 1);
  4970. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  4971. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4972. }
  4973. return {
  4974. dir: undefined,
  4975. action: 1
  4976. };
  4977. } else {
  4978. if (dst < goal.a) {
  4979. if (dst >= goal.g) {
  4980. if (dst >= goal.e) {
  4981. if (dst >= goal.c) {
  4982. bQ(40, 0);
  4983. bQ(10, 1);
  4984. if (configs.slowOT) {
  4985. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  4986. } else {
  4987. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4988. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4989. }
  4990. }
  4991. } else {
  4992. bQ(22, 0);
  4993. bQ(19, 1);
  4994. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  4995. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4996. }
  4997. }
  4998. } else {
  4999. bQ(6, 0);
  5000. bQ(12, 1);
  5001. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5002. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5003. }
  5004. }
  5005. } else {
  5006. biomeGear();
  5007. bQ(11, 1);
  5008. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5009. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5010. }
  5011. }
  5012. return {
  5013. dir: near.aim2 + Math.PI,
  5014. action: 0
  5015. };
  5016. } else if (dst > goal.b) {
  5017. if (dst <= goal.h) {
  5018. if (dst <= goal.f) {
  5019. if (dst <= goal.d) {
  5020. bQ(40, 0);
  5021. bQ(9, 1);
  5022. if (configs.slowOT) {
  5023. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5024. } else {
  5025. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5026. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5027. }
  5028. }
  5029. } else {
  5030. bQ(22, 0);
  5031. bQ(19, 1);
  5032. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5033. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5034. }
  5035. }
  5036. } else {
  5037. bQ(6, 0);
  5038. bQ(12, 1);
  5039. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5040. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5041. }
  5042. }
  5043. } else {
  5044. biomeGear();
  5045. bQ(11, 1);
  5046. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5047. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5048. }
  5049. }
  5050. return {
  5051. dir: near.aim2,
  5052. action: 0
  5053. };
  5054. }
  5055. return {
  5056. dir: undefined,
  5057. action: 0
  5058. };
  5059. }
  5060. } else {
  5061. this.ticking = false;
  5062. return {
  5063. dir: undefined,
  5064. action: 0
  5065. };
  5066. }
  5067. }
  5068. /** wait 1 tick for better quality */
  5069. this.bowMovement = function() {
  5070. let moveMent = this.gotoGoal(685, 3);
  5071. if (moveMent.action) {
  5072. if (player.reloads[53] == 0 && !this.isTrue) {
  5073. this.rangeType("ageInsta");
  5074. } else {
  5075. packet("a", moveMent.dir, 1);
  5076. }
  5077. } else {
  5078. packet("a", moveMent.dir, 1);
  5079. }
  5080. },
  5081. this.tickMovement = function() {
  5082. 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);
  5083. if (moveMent.action) {
  5084. if (![6, 22].includes(near.skinIndex) && player.reloads[53] == 0 && !this.isTrue) {
  5085. ([10, 14].includes(player.weapons[1]) && player.y2 > config.snowBiomeTop) || (player.weapons[1] == 15) ? this.oneTickType(): this.threeOneTickType();
  5086. } else {
  5087. packet("a", moveMent.dir, 1);
  5088. }
  5089. } else {
  5090. packet("a", moveMent.dir, 1);
  5091. }
  5092. },
  5093. this.kmTickMovement = function() {
  5094. let moveMent = this.gotoGoal(240, 3);
  5095. if (moveMent.action) {
  5096. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5097. this.kmTickType();
  5098. } else {
  5099. packet("a", moveMent.dir, 1);
  5100. }
  5101. } else {
  5102. packet("a", moveMent.dir, 1);
  5103. }
  5104. },
  5105. this.boostTickMovement = function() {
  5106. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 390 : player.weapons[1] == 15 ? 365 : 370;
  5107. 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;
  5108. let moveMent = this.gotoGoal(dist, actionDist);
  5109. if (moveMent.action) {
  5110. if (player.reloads[53] == 0 && !this.isTrue) {
  5111. this.boostTickType();
  5112. } else {
  5113. packet("a", moveMent.dir, 1);
  5114. }
  5115. } else {
  5116. packet("a", moveMent.dir, 1);
  5117. }
  5118. }
  5119. /** wait 1 tick for better quality */
  5120. this.perfCheck = function(pl, nr) {
  5121. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5122. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5123. let pjs = {
  5124. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5125. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5126. };
  5127. 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)) {
  5128. return true;
  5129. }
  5130. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5131. 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)) {
  5132. return true;
  5133. }
  5134. });
  5135. if (finds) return false;
  5136. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5137. let tmpScale = tmp.getScale();
  5138. 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)) {
  5139. return true;
  5140. }
  5141. });
  5142. if (finds) return false;
  5143. return true;
  5144. }
  5145. }
  5146. };
  5147.  
  5148. class Autobuy {
  5149. constructor(buyHat, buyAcc) {
  5150. this.hat = function() {
  5151. buyHat.forEach((id) => {
  5152. let find = findID(hats, id);
  5153. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5154. });
  5155. };
  5156. this.acc = function() {
  5157. buyAcc.forEach((id) => {
  5158. let find = findID(accessories, id);
  5159. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5160. });
  5161. };
  5162. }
  5163. };
  5164.  
  5165. class Autoupgrade {
  5166. constructor() {
  5167. this.sb = function(upg) {
  5168. upg(3);
  5169. upg(17);
  5170. upg(31);
  5171. upg(23);
  5172. upg(9);
  5173. upg(38);
  5174. };
  5175. this.kh = function(upg) {
  5176. upg(3);
  5177. upg(17);
  5178. upg(31);
  5179. upg(23);
  5180. upg(10);
  5181. upg(38);
  5182. upg(4);
  5183. upg(25);
  5184. };
  5185. this.pb = function(upg) {
  5186. upg(5);
  5187. upg(17);
  5188. upg(32);
  5189. upg(23);
  5190. upg(9);
  5191. upg(38);
  5192. };
  5193. this.ph = function(upg) {
  5194. upg(5);
  5195. upg(17);
  5196. upg(32);
  5197. upg(23);
  5198. upg(10);
  5199. upg(38);
  5200. upg(28);
  5201. upg(25);
  5202. };
  5203. this.db = function(upg) {
  5204. upg(7);
  5205. upg(17);
  5206. upg(31);
  5207. upg(23);
  5208. upg(9);
  5209. upg(34);
  5210. };
  5211. /* old functions */
  5212. this.km = function(upg) {
  5213. upg(7);
  5214. upg(17);
  5215. upg(31);
  5216. upg(23);
  5217. upg(10);
  5218. upg(38);
  5219. upg(4);
  5220. upg(15);
  5221. };
  5222. };
  5223. };
  5224.  
  5225. class Damages {
  5226. constructor(items) {
  5227. // 0.75 1 1.125 1.5
  5228. this.calcDmg = function(dmg, val) {
  5229. return dmg * val;
  5230. };
  5231. this.getAllDamage = function(dmg) {
  5232. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5233. };
  5234. this.weapons = [];
  5235. for (let i = 0; i < items.weapons.length; i++) {
  5236. let wp = items.weapons[i];
  5237. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5238. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5239. this[name] = this.weapons[i];
  5240. }
  5241. }
  5242. }
  5243.  
  5244. /** CLASS CODES */
  5245. // jumpscare code warn
  5246. let tmpList = [];
  5247.  
  5248. // LOADING:
  5249. let UTILS = new Utils();
  5250. let items = new Items();
  5251. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5252. let store = new Store();
  5253. let hats = store.hats;
  5254. let accessories = store.accessories;
  5255. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5256. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5257. let textManager = new Textmanager();
  5258.  
  5259. let traps = new Traps(UTILS, items);
  5260. let instaC = new Instakill();
  5261. let autoBuy = new Autobuy([6, 7, 22, 12, 53, 40, 15, 31, 20], [11, 13, 19, 18, 21]);
  5262. let autoUpgrade = new Autoupgrade();
  5263.  
  5264. let lastDeath;
  5265. let minimapData;
  5266. let mapMarker = {};
  5267. let mapPings = [];
  5268. let tmpPing;
  5269.  
  5270. let breakTrackers = [];
  5271.  
  5272. function sendChat(message) {
  5273. packet("6", message.slice(0, 30));
  5274. }
  5275.  
  5276. let runAtNextTick = [];
  5277.  
  5278. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5279. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5280. let projOffset = config.playerScale * 2;
  5281. let projXY = {
  5282. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5283. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5284. };
  5285. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5286. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5287. })[0];
  5288. if (nearPlayer) {
  5289. if (indx == 1) {
  5290. nearPlayer.shooting[53] = 1;
  5291. } else {
  5292. nearPlayer.shootIndex = weaponIndx;
  5293. nearPlayer.shooting[1] = 1;
  5294. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5295. }
  5296. }
  5297. }
  5298. let projectileCount = 0;
  5299.  
  5300. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5301. if (!tmpObj.isTeam(player)) {
  5302. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5303. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5304. tmpObj.bowThreat[weaponIndex]++;
  5305. if (index == 5) {
  5306. projectileCount++;
  5307. }
  5308. setTimeout(() => {
  5309. tmpObj.bowThreat[weaponIndex]--;
  5310. if (index == 5) {
  5311. projectileCount--;
  5312. }
  5313. }, range / speed);
  5314. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5315. place(1, tmpObj.aim2);
  5316. my.anti0Tick = 4;
  5317. if (!my.antiSync) {
  5318. antiSyncHealing(4);
  5319. }
  5320. } else {
  5321. if (projectileCount >= 2) {
  5322. place(1, tmpObj.aim2);
  5323. my.anti0Tick = 4;
  5324. if (!my.antiSync) {
  5325. antiSyncHealing(4);
  5326. }
  5327. }
  5328. }
  5329. }
  5330. }
  5331. }
  5332.  
  5333. // SHOW ITEM INFO:
  5334. function showItemInfo(item, isWeapon, isStoreItem) {
  5335. if (player && item) {
  5336. UTILS.removeAllChildren(itemInfoHolder);
  5337. itemInfoHolder.classList.add("visible");
  5338. UTILS.generateElement({
  5339. id: "itemInfoName",
  5340. text: UTILS.capitalizeFirst(item.name),
  5341. parent: itemInfoHolder
  5342. });
  5343. UTILS.generateElement({
  5344. id: "itemInfoDesc",
  5345. text: item.desc,
  5346. parent: itemInfoHolder
  5347. });
  5348. if (isStoreItem) {
  5349.  
  5350. } else if (isWeapon) {
  5351. UTILS.generateElement({
  5352. class: "itemInfoReq",
  5353. text: !item.type ? "primary" : "secondary",
  5354. parent: itemInfoHolder
  5355. });
  5356. } else {
  5357. for (let i = 0; i < item.req.length; i += 2) {
  5358. UTILS.generateElement({
  5359. class: "itemInfoReq",
  5360. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5361. parent: itemInfoHolder
  5362. });
  5363. }
  5364. if (item.group.limit) {
  5365. UTILS.generateElement({
  5366. class: "itemInfoLmt",
  5367. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5368. parent: itemInfoHolder
  5369. });
  5370. }
  5371. }
  5372. } else {
  5373. itemInfoHolder.classList.remove("visible");
  5374. }
  5375. }
  5376.  
  5377. // RESIZE:
  5378. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5379.  
  5380. function resize() {
  5381. screenWidth = window.innerWidth;
  5382. screenHeight = window.innerHeight;
  5383. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5384. gameCanvas.width = screenWidth * pixelDensity;
  5385. gameCanvas.height = screenHeight * pixelDensity;
  5386. gameCanvas.style.width = screenWidth + "px";
  5387. gameCanvas.style.height = screenHeight + "px";
  5388. mainContext.setTransform(
  5389. scaleFillNative, 0,
  5390. 0, scaleFillNative,
  5391. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5392. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5393. );
  5394. }
  5395. resize();
  5396.  
  5397. // MOUSE INPUT:
  5398. var usingTouch;
  5399. const mals = document.getElementById('touch-controls-fullscreen');
  5400. mals.style.display = 'block';
  5401. mals.addEventListener("mousemove", gameInput, false);
  5402.  
  5403. function gameInput(e) {
  5404. mouseX = e.clientX;
  5405. mouseY = e.clientY;
  5406. }
  5407. let clicks = {
  5408. left: false,
  5409. middle: false,
  5410. right: false,
  5411. };
  5412. mals.addEventListener("mousedown", mouseDown, false);
  5413.  
  5414. function mouseDown(e) {
  5415. if (attackState != 1) {
  5416. attackState = 1;
  5417. if (e.button == 0) {
  5418. clicks.left = true;
  5419. } else if (e.button == 1) {
  5420. clicks.middle = true;
  5421. } else if (e.button == 2) {
  5422. clicks.right = true;
  5423. }
  5424. }
  5425. }
  5426. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5427.  
  5428. function mouseUp(e) {
  5429. if (attackState != 0) {
  5430. attackState = 0;
  5431. if (e.button == 0) {
  5432. clicks.left = false;
  5433. } else if (e.button == 1) {
  5434. clicks.middle = false;
  5435. } else if (e.button == 2) {
  5436. clicks.right = false;
  5437. }
  5438. }
  5439. }
  5440. mals.addEventListener("wheel", wheel, false);
  5441.  
  5442. function wheel(e) {
  5443. if (e.deltaY < 0) {
  5444. wbe += 0.005
  5445. maxScreenWidth = config.maxScreenWidth * wbe;
  5446. maxScreenHeight = config.maxScreenHeight * wbe;
  5447. resize()
  5448. } else {
  5449. wbe -= 0.005
  5450. maxScreenWidth = config.maxScreenWidth * wbe;
  5451. maxScreenHeight = config.maxScreenHeight * wbe;
  5452. resize()
  5453. }
  5454. }
  5455.  
  5456. // INPUT UTILS:
  5457. function getMoveDir() {
  5458. let dx = 0;
  5459. let dy = 0;
  5460. for (let key in moveKeys) {
  5461. let tmpDir = moveKeys[key];
  5462. dx += !!keys[key] * tmpDir[0];
  5463. dy += !!keys[key] * tmpDir[1];
  5464. }
  5465. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5466. }
  5467.  
  5468. function getSafeDir() {
  5469. if (!player)
  5470. return 0;
  5471. if (!player.lockDir) {
  5472. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5473. }
  5474. return lastDir || 0;
  5475. }
  5476. let plusDir = 0;
  5477. let lastSpin = Date.now();
  5478. function getAttackDir() {
  5479. if(player && Date.now() - lastSpin >= 235 && !(clicks.right || clicks.left)) {
  5480. plusDir += Math.random()*(Math.PI*2);
  5481. lastSpin = Date.now();
  5482. }
  5483. if (!player)
  5484. return "0";
  5485. 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))
  5486. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? near.aim2 : getSafeDir();
  5487. else
  5488. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5489. lastDir = getSafeDir();
  5490. else
  5491. if (traps.inTrap) {
  5492. lastDir = traps.aim;
  5493. } else
  5494. if (!player.lockDir) {
  5495. if (!player.lockDir && autos.stopspin) {
  5496. if(useWasd) {
  5497. lastDir = lastDir;
  5498. } else {
  5499. lastDir = getSafeDir();
  5500. }
  5501. }
  5502. }
  5503. return lastDir;
  5504. }
  5505.  
  5506. function getVisualDir() {
  5507. if (!player)
  5508. return 0;
  5509. lastDir = getSafeDir();
  5510. return lastDir || 0;
  5511. }
  5512.  
  5513. // KEYS:
  5514. function keysActive() {
  5515. return (allianceMenu.style.display != "block" &&
  5516. chatHolder.style.display != "block" &&
  5517. !menuCBFocus);
  5518. }
  5519.  
  5520. function toggleMenuChat() {
  5521. if (menuChatDiv.style.display != "none") {
  5522. // chatHolder.style.display = "none";
  5523. // if (menuChatBox.value != "") {
  5524. //commands[command.slice(1)]
  5525. let cmd = function(command) {
  5526. return {
  5527. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5528. fv: commands[command.slice(1).split(" ")[0]]
  5529. }
  5530. }
  5531. let command = cmd(menuChatBox.value);
  5532. if (command.found) {
  5533. if (typeof command.fv.action === "function") {
  5534. command.fv.action(menuChatBox.value);
  5535. }
  5536. } else {
  5537. sendChat(menuChatBox.value);
  5538. }
  5539. menuChatBox.value = "";
  5540. menuChatBox.blur();
  5541. } else {
  5542. if (menuCBFocus) {
  5543. menuChatBox.blur();
  5544. } else {
  5545. menuChatBox.focus();
  5546. }
  5547. }
  5548. }
  5549.  
  5550. function keyDown(event) {
  5551. let keyNum = event.which || event.keyCode || 0;
  5552. if (player && player.alive && keysActive()) {
  5553. if (!keys[keyNum]) {
  5554. keys[keyNum] = 1;
  5555. macro[event.key] = 1;
  5556. if (keyNum == 27) {
  5557. openMenu = !openMenu;
  5558. $("#menuDiv").toggle();
  5559. $("#menuChatDiv").toggle();
  5560. } else if (keyNum == 69) {
  5561. sendAutoGather();
  5562. } else if (keyNum == 67) {
  5563. updateMapMarker();
  5564. } else if (player.weapons[keyNum - 49] != undefined) {
  5565. player.weaponCode = player.weapons[keyNum - 49];
  5566. } else if (moveKeys[keyNum]) {
  5567. sendMoveDir();
  5568. } else if (event.key == "m") {
  5569. mills.placeSpawnPads = !mills.placeSpawnPads;
  5570. } else if (event.key == "z") {
  5571. mills.place = !mills.place;
  5572. } else if (event.key == "Z") {
  5573. typeof window.debug == "function" && window.debug();
  5574. } else if (keyNum == 32) {
  5575. packet("d", 1, getSafeDir(), 1);
  5576. packet("d", 0, getSafeDir(), 1);
  5577. } else if (event.key == ",") {
  5578. io.send("6", 'syncon')
  5579. project.send(JSON.stringify(["tezt", "ratio"]));
  5580. // botSkts.push([botPlayer]);
  5581. for(let i = 0; i < botz.length; i++) {
  5582. // if(botz[i][0]) {
  5583. botz[i][0].zync(near);
  5584. console.log(botz[i][0])
  5585. }
  5586. // project.send("tezt");
  5587. // botSkts.forEach((bot) => {
  5588. // bot.zync();
  5589. // })
  5590. // io.send("S", 1)
  5591. }
  5592. }
  5593. }
  5594. }
  5595.  
  5596. // let xx = canvaz.width/2;
  5597. // let yy = canvaz.height/2;
  5598.  
  5599. // let mouze = {
  5600. // x: xx - mouzeX,
  5601. // y: yy - mouzeY
  5602. // }
  5603.  
  5604. // let ingamecoorformodabow = {
  5605. // x: player.x + mouze.x,
  5606. // y: player.x + mouze.x
  5607. // }
  5608.  
  5609. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5610.  
  5611. function keyUp(event) {
  5612. if (player && player.alive) {
  5613. let keyNum = event.which || event.keyCode || 0;
  5614. if (keyNum == 13) {
  5615. toggleMenuChat();
  5616. } else if (keysActive()) {
  5617. if (keys[keyNum]) {
  5618. keys[keyNum] = 0;
  5619. macro[event.key] = 0;
  5620. if (moveKeys[keyNum]) {
  5621. sendMoveDir();
  5622. } else if (event.key == ",") {
  5623. player.sync = false;
  5624. }
  5625. }
  5626. }
  5627. }
  5628. }
  5629. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5630.  
  5631. function sendMoveDir() {
  5632. if(found) {
  5633. packet("a", undefined, 1);
  5634. } else {
  5635. let newMoveDir = getMoveDir();
  5636. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5637. if (!my.autoPush && !found) {
  5638. packet("a", newMoveDir, 1);
  5639. }
  5640. lastMoveDir = newMoveDir;
  5641. }
  5642. }
  5643. }
  5644.  
  5645. // BUTTON EVENTS:
  5646. function bindEvents() {}
  5647. bindEvents();
  5648.  
  5649. // ITEM COUNT DISPLAY:
  5650. let isItemSetted = [];
  5651.  
  5652. function updateItemCountDisplay(index = undefined) {
  5653. for (let i = 3; i < items.list.length; ++i) {
  5654. let id = items.list[i].group.id;
  5655. let tmpI = items.weapons.length + i;
  5656. if (!isItemSetted[tmpI]) {
  5657. isItemSetted[tmpI] = document.createElement("div");
  5658. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5659. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5660. isItemSetted[tmpI].style = `
  5661. display: block;
  5662. position: absolute;
  5663. padding-left: 5px;
  5664. font-size: 2em;
  5665. color: #fff;
  5666. `;
  5667. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5668. } else {
  5669. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5670. }
  5671. }
  5672. }
  5673.  
  5674. // AUTOPUSH:
  5675. function autoPush() {
  5676. 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) {
  5677. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5678. })[0];
  5679. if (nearTrap) {
  5680. 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) {
  5681. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5682. })[0];
  5683. if (spike) {
  5684. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  5685.  
  5686. /*let pos = {
  5687. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5688. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5689. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  5690. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  5691. };
  5692. let finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5693. let tmpScale = tmp.getScale();
  5694. 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)) {
  5695. return true;
  5696. }
  5697. });
  5698. if (finds) {
  5699. if (my.autoPush) {
  5700. my.autoPush = false;
  5701. packet("a", lastMoveDir || undefined, 1);
  5702. }
  5703. } else {*/
  5704. my.autoPush = true;
  5705. my.pushData = {
  5706. x: spike.x + Math.cos(pushAngle),
  5707. y: spike.y + Math.sin(pushAngle),
  5708. x2: player.x2+30,
  5709. y2: player.y2+30
  5710. };
  5711.  
  5712. let point = {
  5713. x: near.x2 + Math.cos(pushAngle) * 30,
  5714. y: near.y2 + Math.sin(pushAngle) * 60,
  5715. }
  5716.  
  5717. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  5718.  
  5719. packet("a", dir, 1)
  5720. /*let scale = (player.scale / 10);
  5721. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5722. packet("a", near.aim2, 1);
  5723. } else {
  5724. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  5725. }*/
  5726. //}
  5727. } else {
  5728. if (my.autoPush) {
  5729. my.autoPush = false;
  5730. packet("a", lastMoveDir || undefined, 1);
  5731. }
  5732. }
  5733. } else {
  5734. if (my.autoPush) {
  5735. my.autoPush = false;
  5736. packet("a", lastMoveDir || undefined, 1);
  5737. }
  5738. }
  5739. }
  5740.  
  5741. // ADD DEAD PLAYER:
  5742. function addDeadPlayer(tmpObj) {
  5743. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  5744. }
  5745.  
  5746. /** APPLY SOCKET CODES */
  5747.  
  5748. // SET INIT DATA:
  5749. function setInitData(data) {
  5750. alliances = data.teams;
  5751. }
  5752.  
  5753. // SETUP GAME:
  5754. function setupGame(yourSID) {
  5755. keys = {};
  5756. macro = {};
  5757. playerSID = yourSID;
  5758. attackState = 0;
  5759. inGame = true;
  5760. packet("d", 0, getAttackDir(), 1);
  5761. my.ageInsta = true;
  5762. if (firstSetup) {
  5763. firstSetup = false;
  5764. gameObjects.length = 0;
  5765. liztobj.length = 0;
  5766. }
  5767. }
  5768.  
  5769. // ADD NEW PLAYER:
  5770. function addPlayer(data, isYou) {
  5771. let tmpPlayer = findPlayerByID(data[0]);
  5772. if (!tmpPlayer) {
  5773. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  5774. objectManager, players, ais, items, hats, accessories);
  5775. players.push(tmpPlayer);
  5776. if (data[1] != playerSID) {
  5777. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5778. }
  5779. } else {
  5780. if (data[1] != playerSID) {
  5781. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5782. }
  5783. }
  5784. tmpPlayer.spawn(isYou ? true : null);
  5785. tmpPlayer.visible = false;
  5786. tmpPlayer.oldPos = {
  5787. x2: undefined,
  5788. y2: undefined
  5789. };
  5790. tmpPlayer.x2 = undefined;
  5791. tmpPlayer.y2 = undefined;
  5792. tmpPlayer.x3 = undefined;
  5793. tmpPlayer.y3 = undefined;
  5794. tmpPlayer.setData(data);
  5795. if (isYou) {
  5796. if (!player) {
  5797. window.prepareUI(tmpPlayer);
  5798. }
  5799. player = tmpPlayer;
  5800. camX = player.x;
  5801. camY = player.y;
  5802. my.lastDir = 0;
  5803. updateItems();
  5804. updateAge();
  5805. updateItemCountDisplay();
  5806. if (player.skins[7]) {
  5807. my.reSync = true;
  5808. }
  5809. }
  5810. }
  5811.  
  5812. // REMOVE PLAYER:
  5813. function removePlayer(id) {
  5814. for (let i = 0; i < players.length; i++) {
  5815. if (players[i].id == id) {
  5816. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  5817. players.splice(i, 1);
  5818. break;
  5819. }
  5820. }
  5821. }
  5822.  
  5823. // UPDATE HEALTH:
  5824. function updateHealth(sid, value) {
  5825. tmpObj = findPlayerBySID(sid);
  5826. if (tmpObj) {
  5827. // tmpObj.lastshamecount = tmpObj.shameCount;
  5828. tmpObj.oldHealth = tmpObj.health;
  5829. tmpObj.health = value;
  5830. tmpObj.judgeShame();
  5831. if (tmpObj.oldHealth > tmpObj.health) {
  5832. tmpObj.timeDamaged = Date.now(); //here'
  5833. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  5834. let damaged = tmpObj.damaged;
  5835. tmpObj = findPlayerBySID(sid);
  5836.  
  5837. let bullTicked = false;
  5838.  
  5839. if (tmpObj.health <= 0) {
  5840. if (!tmpObj.death) {
  5841. tmpObj.death = true;
  5842. if (tmpObj != player) {
  5843. if(tmpObj.skinIndex == 45) {
  5844. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to clown`, "red");
  5845. } else if(tmpObj.shameCount >= 5) {
  5846. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died due to high shame`, "red");
  5847. } else {
  5848. addMenuChText("Game", `${tmpObj.name}[${tmpObj.sid}] has died`, "red");
  5849. }
  5850. textManager.showText(tmpObj.x, tmpObj.y, 20, 0.15, 1850, '', 2);
  5851. }
  5852. addDeadPlayer(tmpObj);
  5853. }
  5854. }
  5855. if (tmpObj == player) {
  5856. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  5857. if (my.reSync) {
  5858. my.reSync = false;
  5859. tmpObj.setBullTick = true;
  5860. }
  5861. bullTicked = true;
  5862. }
  5863. if (inGame) {
  5864. let attackers = getAttacker(damaged);
  5865. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  5866. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  5867. let healTimeout = 95;
  5868. let slowHeal = function(timer) {
  5869. setTimeout(() => {
  5870. healer();
  5871. }, timer);
  5872. }
  5873. if (near.length && near.damageThreat(player) - (player.canEmpAnti || player.empAnti ? 25 : 0) >= 85) {
  5874. player.canEmpAnti = true;
  5875. player.antiTimer = game.tick;
  5876. let shame = 4;
  5877. if (player.shameCount < shame) {
  5878. healer();
  5879. } else {
  5880. slowHeal(healTimeout);
  5881. }
  5882. } else {
  5883. slowHeal(healTimeout);
  5884. }
  5885. }
  5886. // if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  5887. } else {
  5888. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  5889. tmpObj.setPoisonTick = true;
  5890. }
  5891. }
  5892. } else {
  5893. tmpObj.timeHealed = Date.now(); //
  5894. // game.tickBase(() => {
  5895. // }, 2)
  5896. }
  5897. if (tmpObj.health <= 0) {
  5898. bots.forEach((hmm) => {
  5899. hmm.whyDie = tmpObj.name;
  5900. });
  5901. }
  5902. }
  5903. }
  5904.  
  5905. // KILL PLAYER:
  5906. function killPlayer() {
  5907. inGame = false;
  5908. lastDeath = {
  5909. x: player.x,
  5910. y: player.y,
  5911. };
  5912. }
  5913.  
  5914. // UPDATE PLAYER ITEM VALUES:
  5915. function updateItemCounts(index, value) {
  5916. if (player) {
  5917. player.itemCounts[index] = value;
  5918. updateItemCountDisplay(index);
  5919. }
  5920. }
  5921.  
  5922. // UPDATE AGE:
  5923. function updateAge(xp, mxp, age) {
  5924. if (xp != undefined)
  5925. player.XP = xp;
  5926. if (mxp != undefined)
  5927. player.maxXP = mxp;
  5928. if (age != undefined)
  5929. player.age = age;
  5930. }
  5931.  
  5932. // UPDATE UPGRADES:
  5933. function updateUpgrades(points, age) {
  5934. player.upgradePoints = points;
  5935. player.upgrAge = age;
  5936. if (points > 0) {
  5937. tmpList.length = 0;
  5938. UTILS.removeAllChildren(upgradeHolder);
  5939. for (let i = 0; i < items.weapons.length; ++i) {
  5940. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  5941. let e = UTILS.generateElement({
  5942. id: "upgradeItem" + i,
  5943. class: "actionBarItem",
  5944. onmouseout: function() {
  5945. showItemInfo();
  5946. },
  5947. parent: upgradeHolder
  5948. });
  5949. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  5950. tmpList.push(i);
  5951. }
  5952. }
  5953. for (let i = 0; i < items.list.length; ++i) {
  5954. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  5955. let tmpI = (items.weapons.length + i);
  5956. let e = UTILS.generateElement({
  5957. id: "upgradeItem" + tmpI,
  5958. class: "actionBarItem",
  5959. onmouseout: function() {
  5960. showItemInfo();
  5961. },
  5962. parent: upgradeHolder
  5963. });
  5964. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  5965. tmpList.push(tmpI);
  5966. }
  5967. }
  5968. for (let i = 0; i < tmpList.length; i++) {
  5969. (function(i) {
  5970. let tmpItem = getEl('upgradeItem' + i);
  5971. // tmpItem.onmouseover = function() {
  5972. // if (items.weapons[i]) {
  5973. // showItemInfo(items.weapons[i], true);
  5974. // } else {
  5975. // showItemInfo(items.list[i - items.weapons.length]);
  5976. // }
  5977. // };
  5978. tmpItem.onclick = UTILS.checkTrusted(function() {
  5979. packet("H", i);
  5980. });
  5981. UTILS.hookTouchEvents(tmpItem);
  5982. })(tmpList[i]);
  5983. }
  5984. if (tmpList.length) {
  5985. upgradeHolder.style.display = "block";
  5986. upgradeCounter.style.display = "block";
  5987. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  5988. } else {
  5989. upgradeHolder.style.display = "none";
  5990. upgradeCounter.style.display = "none";
  5991. showItemInfo();
  5992. }
  5993. } else {
  5994. upgradeHolder.style.display = "none";
  5995. upgradeCounter.style.display = "none";
  5996. showItemInfo();
  5997. }
  5998. }
  5999.  
  6000. // KILL OBJECT:
  6001. function killObject(sid) {
  6002. let findObj = findObjectBySid(sid);
  6003. objectManager.disableBySid(sid);
  6004. if (player) {
  6005. for (let i = 0; i < breakObjects.length; i++) {
  6006. if (breakObjects[i].sid == sid) {
  6007. breakObjects.splice(i, 1);
  6008. break;
  6009. }
  6010. }
  6011. if (!player.canSee(findObj)) {
  6012. breakTrackers.push({
  6013. x: findObj.x,
  6014. y: findObj.y
  6015. });
  6016. }
  6017. if (breakTrackers.length > 8) {
  6018. breakTrackers.shift();
  6019. }
  6020. traps.replacer(findObj);
  6021. }
  6022. }
  6023.  
  6024. // KILL ALL OBJECTS BY A PLAYER:
  6025. function killObjects(sid) {
  6026. if (player) objectManager.removeAllItems(sid);
  6027. }
  6028. function setTickout(doo, timeout) {
  6029. if (!ticks.manage[ticks.tick + timeout]) {
  6030. ticks.manage[ticks.tick + timeout] = [doo];
  6031. } else {
  6032. ticks.manage[ticks.tick + timeout].push(doo);
  6033. }
  6034. }
  6035.  
  6036. function caf(e, t) {
  6037. try {
  6038. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6039. } catch (e) {
  6040. return 0;
  6041. }
  6042. }
  6043.  
  6044. let found = false;
  6045. let autoQ = false;
  6046.  
  6047. let autos = {
  6048. insta: {
  6049. todo: false,
  6050. wait: false,
  6051. count: 4,
  6052. shame: 5
  6053. },
  6054. bull: false,
  6055. antibull: 0,
  6056. reloaded: false,
  6057. stopspin: true
  6058. }
  6059.  
  6060. // UPDATE PLAYER DATA:
  6061. function updatePlayers(data) {
  6062. // if(player.shameCount > 0) {
  6063. // my.reSync = true;
  6064. // } else {
  6065. // my.reSync = false;
  6066. // }
  6067.  
  6068. // let movementPrediction = {
  6069. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6070. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6071. // }
  6072.  
  6073. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6074.  
  6075. // potentialzpiketick.forEach((obj) => {
  6076. // if(cdf(obj, player) <= 200) {
  6077. // packet('a', undefined);
  6078. // }
  6079. // })
  6080.  
  6081. // let newPos = {
  6082. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6083. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6084. // }
  6085.  
  6086. function getAngleDifference(angle1, angle2) {
  6087. // Normalize the angles to be between 0 and 2π
  6088. angle1 = angle1 % (2 * Math.PI);
  6089. angle2 = angle2 % (2 * Math.PI);
  6090.  
  6091. // Calculate the absolute difference between the angles
  6092. let diff = Math.abs(angle1 - angle2);
  6093.  
  6094. // Adjust the difference to be between 0 and π
  6095. if (diff > Math.PI) {
  6096. diff = (2 * Math.PI) - diff;
  6097. }
  6098.  
  6099. return diff;
  6100. }
  6101.  
  6102. // function smartMove(oneTickMove) {
  6103. // let dir = player.moveDir;
  6104.  
  6105. // let found = false
  6106. // 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))
  6107. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6108.  
  6109. // let newPos = {
  6110. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6111. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6112. // }
  6113.  
  6114. // for (let i = 0; i < spikes.length; i++) {
  6115. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6116. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6117. // }
  6118. // }
  6119.  
  6120.  
  6121.  
  6122.  
  6123.  
  6124. // if (found != false && !traps.inTrap) {
  6125. // packet("a", undefined);
  6126. // } else {
  6127. // packet("a", dir);
  6128. // }
  6129. // player.oldPos.x2 = player.x2;
  6130. // player.oldPos.y2 = player.y2;
  6131. // }
  6132. // function detectEnemySpikeCollisions(tmpObj) {
  6133. // 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));
  6134. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6135. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6136. // let enemy = {
  6137. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6138. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6139. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6140. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6141. // }
  6142. // let found = false;
  6143. // for (let i = 0; i < spikes.length; i++) {
  6144. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6145. // found = true;
  6146. // }
  6147. // }
  6148.  
  6149. // // player.oldPos.x2 = tmpObj.x2;
  6150. // // player.oldPos.y2 = tmpObj.y2;
  6151. // }
  6152.  
  6153. game.tick++;
  6154. enemy = [];
  6155. nears = [];
  6156. near = [];
  6157. game.tickSpeed = performance.now() - game.lastTick;
  6158. game.lastTick = performance.now();
  6159. players.forEach((tmp) => {
  6160. tmp.forcePos = !tmp.visible;
  6161. tmp.visible = false;
  6162. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6163. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6164. });
  6165. for (let i = 0; i < data.length;) {
  6166. tmpObj = findPlayerBySID(data[i]);
  6167. if (tmpObj) {
  6168. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6169. tmpObj.t2 = game.lastTick;
  6170. tmpObj.oldPos.x2 = tmpObj.x2;
  6171. tmpObj.oldPos.y2 = tmpObj.y2;
  6172. tmpObj.x1 = tmpObj.x;
  6173. tmpObj.y1 = tmpObj.y;
  6174. tmpObj.x2 = data[i + 1];
  6175. tmpObj.y2 = data[i + 2];
  6176. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6177. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6178. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6179. tmpObj.d2 = data[i + 3];
  6180. tmpObj.dt = 0;
  6181. tmpObj.buildIndex = data[i + 4];
  6182. tmpObj.weaponIndex = data[i + 5];
  6183. tmpObj.weaponVariant = data[i + 6];
  6184. tmpObj.team = data[i + 7];
  6185. tmpObj.isLeader = data[i + 8];
  6186. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6187. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6188. tmpObj.skinIndex = data[i + 9];
  6189. tmpObj.tailIndex = data[i + 10];
  6190. tmpObj.iconIndex = data[i + 11];
  6191. tmpObj.zIndex = data[i + 12];
  6192. tmpObj.visible = true;
  6193. tmpObj.update(game.tickSpeed);
  6194. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6195. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6196. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6197. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6198. tmpObj.damageThreat = 0;
  6199. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6200. tmpObj.addShameTimer();
  6201. }
  6202. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6203. tmpObj.shameTimer = 0;
  6204. tmpObj.shameCount = 0;
  6205. if (tmpObj == player) {
  6206. healer();
  6207. }
  6208. }
  6209.  
  6210. botSkts.forEach((bot) => {
  6211. bot.showName = 'YEAHHH'
  6212. })
  6213.  
  6214. for(let i = 0; i < players.length; i++) {
  6215. for(let aa = 0; aa < botSkts.length; aa++) {
  6216. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6217.  
  6218. }
  6219. }
  6220.  
  6221. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6222. autoQ = true;
  6223. healer();
  6224. } else {
  6225. if (autoQ) {
  6226. healer();
  6227. }
  6228. autoQ = false;
  6229. }
  6230.  
  6231.  
  6232. if (tmpObj == player) {
  6233. if (liztobj.length) {
  6234. liztobj.forEach((tmp) => {
  6235. tmp.onNear = false;
  6236. if (tmp.active) {
  6237. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6238. tmp.onNear = true;
  6239. }
  6240. if (tmp.isItem && tmp.owner) {
  6241. 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)) {
  6242. tmp.breakObj = true;
  6243. breakObjects.push({
  6244. x: tmp.x,
  6245. y: tmp.y,
  6246. sid: tmp.sid
  6247. });
  6248. }
  6249. }
  6250. }
  6251. });
  6252. 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) {
  6253. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6254. })[0];
  6255. if (nearTrap) {
  6256. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6257. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6258. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6259.  
  6260. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6261. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6262. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6263. traps.inTrap = true;
  6264. traps.info = nearTrap;
  6265. } else {
  6266. traps.inTrap = false;
  6267. traps.info = {};
  6268. }
  6269. } else {
  6270. traps.inTrap = false;
  6271. }
  6272. }
  6273. if (tmpObj.weaponIndex < 9) {
  6274. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6275. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6276. } else if (tmpObj.weaponIndex > 8) {
  6277. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6278. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6279. }
  6280. }
  6281. i += 13;
  6282. }
  6283. if (textManager.stack.length) {
  6284. let stacks = [];
  6285. let notstacks = [];
  6286. let num = 0;
  6287. let num2 = 0;
  6288. let pos = {
  6289. x: null,
  6290. y: null
  6291. };
  6292. let pos2 = {
  6293. x: null,
  6294. y: null
  6295. }
  6296. textManager.stack.forEach((text) => {
  6297. if (text.value >= 0) {
  6298. if (num == 0) pos = {
  6299. x: text.x,
  6300. y: text.y
  6301. };
  6302. num += Math.abs(text.value);
  6303. } else {
  6304. if (num2 == 0) pos2 = {
  6305. x: text.x,
  6306. y: text.y
  6307. };
  6308. num2 += Math.abs(text.value);
  6309. }
  6310. });
  6311. if (num2 > 0) {
  6312. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  6313. }
  6314. if (num > 0) {
  6315. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6316. }
  6317. textManager.stack = [];
  6318. }
  6319. if (runAtNextTick.length) {
  6320. runAtNextTick.forEach((tmp) => {
  6321. checkProjectileHolder(...tmp);
  6322. });
  6323. runAtNextTick = [];
  6324. }
  6325. for (let i = 0; i < data.length;) {
  6326. tmpObj = findPlayerBySID(data[i]);
  6327. if (tmpObj) {
  6328. if (!tmpObj.isTeam(player)) {
  6329. enemy.push(tmpObj);
  6330. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6331. nears.push(tmpObj);
  6332. }
  6333. }
  6334. tmpObj.manageReload();
  6335. if (tmpObj != player) {
  6336. tmpObj.addDamageThreat(player);
  6337. }
  6338. }
  6339. i += 13;
  6340. }
  6341. /*projectiles.forEach((proj) => {
  6342. tmpObj = proj;
  6343. if (tmpObj.active) {
  6344. tmpObj.tickUpdate(game.tickSpeed);
  6345. }
  6346. });*/
  6347. if (player && player.alive) {
  6348. if (enemy.length) {
  6349. near = enemy.sort(function(tmp1, tmp2) {
  6350. return tmp1.dist2 - tmp2.dist2;
  6351. })[0];
  6352. } else {
  6353. // console.log("no enemy");
  6354. }
  6355. if (game.tickQueue[game.tick]) {
  6356. game.tickQueue[game.tick].forEach((action) => {
  6357. action();
  6358. });
  6359. game.tickQueue[game.tick] = null;
  6360. }
  6361. players.forEach((tmp) => {
  6362. if (!tmp.visible && player != tmp) {
  6363. tmp.reloads = {
  6364. 0: 0,
  6365. 1: 0,
  6366. 2: 0,
  6367. 3: 0,
  6368. 4: 0,
  6369. 5: 0,
  6370. 6: 0,
  6371. 7: 0,
  6372. 8: 0,
  6373. 9: 0,
  6374. 10: 0,
  6375. 11: 0,
  6376. 12: 0,
  6377. 13: 0,
  6378. 14: 0,
  6379. 15: 0,
  6380. 53: 0,
  6381. };
  6382. }
  6383. if (tmp.setBullTick) {
  6384. tmp.bullTimer = 0;
  6385. }
  6386. if (tmp.setPoisonTick) {
  6387. tmp.poisonTimer = 0;
  6388. }
  6389. tmp.updateTimer();
  6390. });
  6391. if (inGame) {
  6392. if (enemy.length) {
  6393. if (player.canEmpAnti) {
  6394. player.canEmpAnti = false;
  6395. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6396. if (near.reloads[53] == 0) {
  6397. player.empAnti = true;
  6398. player.soldierAnti = false;
  6399. //modLog("EmpAnti");
  6400. } else {
  6401. player.empAnti = false;
  6402. player.soldierAnti = true;
  6403. //modLog("SoldierAnti");
  6404. }
  6405. }
  6406. }
  6407. 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) {
  6408. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6409. })[0];
  6410. if (prehit) {
  6411. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6412. instaC.canSpikeTick = true;
  6413. instaC.syncHit = true;
  6414. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6415. instaC.revTick = true;
  6416. }
  6417. }
  6418. }
  6419. 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) {
  6420. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6421. })[0];
  6422. if (antiSpikeTick && !traps.inTrap) {
  6423. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  6424. my.anti0Tick = 1;
  6425. // player.chat.message = "Anti Vel SpikeTick " + near.sid;
  6426. //player.chat.count = 2000;
  6427. }
  6428. }
  6429. }
  6430. 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)) {
  6431. if (player.checkCanInsta(true) >= 100) {
  6432. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6433. } else {
  6434. instaC.nobull = false;
  6435. }
  6436. instaC.can = true;
  6437. } else {
  6438. instaC.can = false;
  6439. }
  6440. macro.q && place(0, getAttackDir());
  6441. macro.f && place(4, getSafeDir());
  6442. macro.v && place(2, getSafeDir());
  6443. macro.y && place(5, getSafeDir());
  6444. macro.h && place(player.getItemType(22), getSafeDir());
  6445. macro.n && place(3, getSafeDir());
  6446. if (game.tick % 1 == 0) {
  6447. if (mills.place) {
  6448. let plcAng = 7.7;
  6449. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6450. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6451. }
  6452. } else {
  6453. if (mills.placeSpawnPads) {
  6454. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6455. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6456. }
  6457. }
  6458. }
  6459. }
  6460. if (instaC.can) {
  6461. instaC.changeType(player.weapons[1] == 10 ? "rev" : "normal");
  6462. }
  6463. if (instaC.canCounter) {
  6464. instaC.canCounter = false;
  6465. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6466. instaC.counterType();
  6467. }
  6468. }
  6469. if (instaC.canSpikeTick) {
  6470. instaC.canSpikeTick = false;
  6471. if (instaC.revTick) {
  6472. instaC.revTick = false;
  6473. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6474. instaC.changeType("rev");
  6475. chch(null, "[RevSyncHit]", "yellow");
  6476. }
  6477. } else {
  6478. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6479. instaC.spikeTickType();
  6480. if (instaC.syncHit) {
  6481. chch(null, "[SyncHit]", "yellow");
  6482. }
  6483. }
  6484. }
  6485. }
  6486. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6487. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6488. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6489. }
  6490. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6491. sendAutoGather();
  6492. my.waitHit = 1;
  6493. game.tickBase(() => {
  6494. sendAutoGather();
  6495. my.waitHit = 0;
  6496. }, 1);
  6497. }
  6498. }
  6499. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6500. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6501. selectWeapon(player.weapons[0]);
  6502. }
  6503. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6504. sendAutoGather();
  6505. my.waitHit = 1;
  6506. game.tickBase(() => {
  6507. sendAutoGather();
  6508. my.waitHit = 0;
  6509. }, 1);
  6510. }
  6511. }
  6512. if (traps.inTrap) {
  6513. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6514. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6515. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6516. }
  6517. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6518. sendAutoGather();
  6519. my.waitHit = 1;
  6520. game.tickBase(() => {
  6521. sendAutoGather();
  6522. my.waitHit = 0;
  6523. }, 1);
  6524. }
  6525. }
  6526. }
  6527. if (clicks.middle && !traps.inTrap) {
  6528. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6529. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6530. instaC.bowMovement();
  6531. } else {
  6532. instaC.rangeType();
  6533. }
  6534. }
  6535. }
  6536. if (macro.t && !traps.inTrap) {
  6537. 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))) {
  6538. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6539. }
  6540. }
  6541. if (macro["."] && !traps.inTrap) {
  6542. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6543. instaC.boostTickMovement();
  6544. }
  6545. }
  6546. 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)) {
  6547. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6548. if (!my.reloaded) {
  6549. my.reloaded = true;
  6550. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6551. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6552. selectWeapon(player.weapons[fastSpeed]);
  6553. }
  6554. }
  6555. // if(useWasd) {
  6556. // if (!autos.stopspin) {
  6557. // setTimeout(()=>{
  6558. // autos.stopspin = true;
  6559. // }, 375);
  6560. // }
  6561. // }
  6562. } else {
  6563. my.reloaded = false;
  6564. if(useWasd) {
  6565. autos.stopspin = false;
  6566. }
  6567. if (player.reloads[player.weapons[0]] > 0) {
  6568. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6569. selectWeapon(player.weapons[0]);
  6570. }
  6571. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6572. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6573. selectWeapon(player.weapons[1]);
  6574. }
  6575. if(useWasd) {
  6576. if (!autos.stopspin) {
  6577. setTimeout(()=>{
  6578. autos.stopspin = true;
  6579. }, 750);
  6580. }
  6581. }
  6582. }
  6583. }
  6584. }
  6585. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6586. traps.autoPlace();
  6587. }
  6588. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6589. packet("D", getAttackDir());
  6590. }
  6591. let hatChanger = function() {
  6592. if (my.anti0Tick > 0) {
  6593. buyEquip(6, 0);
  6594. } else {
  6595. if (clicks.left || clicks.right) {
  6596. if (clicks.left) {
  6597. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6598. } else if (clicks.right) {
  6599. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6600. }
  6601. } else if (traps.inTrap) {
  6602. // 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) {
  6603. // return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6604. // })[0];
  6605.  
  6606. // if (near.dist3 <= 300 && traps.info.health <= 300) {
  6607. // if (!zpikez.length)
  6608. // buyEquip(6, 0);
  6609. // else if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0))
  6610. // buyEquip(40, 0);
  6611. // } else if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)) {
  6612. // buyEquip(40, 0);
  6613. // } else {
  6614. // buyEquip((player.empAnti) ? 22 : 6, 0);
  6615. // }
  6616.  
  6617. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6618. if (near.dist3 <= 300 && traps.info.health <= 300 && items.weapons[near.weapons[0]] == 0) {
  6619. buyEquip(6, 0);
  6620. } else {
  6621. buyEquip(40, 0);
  6622. }
  6623. } else {
  6624. buyEquip(6, 0);
  6625. }
  6626.  
  6627. } else {
  6628. if (player.empAnti) {
  6629. buyEquip(player.empAnti ? 22 : 6, 0);
  6630. } else {
  6631. buyEquip(6, 0);
  6632. }
  6633. }
  6634. }
  6635. }
  6636. let accChanger = function() {
  6637. if(near.dist2 <= 300){
  6638. buyEquip(0, 1);
  6639. }
  6640. else if(clicks.left){
  6641. buyEquip(0, 1);
  6642. }
  6643. else {
  6644. buyEquip(11, 1);
  6645. }
  6646. }
  6647. let wasdGears = function() {
  6648. if (my.anti0Tick > 0) {
  6649. buyEquip(6, 0);
  6650. } else {
  6651. if (clicks.left || clicks.right) {
  6652. if (clicks.left) {
  6653. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  6654. } else if (clicks.right) {
  6655. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  6656. }
  6657. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  6658. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  6659. } else if (traps.inTrap) {
  6660. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6661. buyEquip(40, 0);
  6662. } else {
  6663. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6664. buyEquip(7, 0);
  6665. } else {
  6666. buyEquip(player.empAnti ? 22 : 6, 0);
  6667. }
  6668. }
  6669. } else {
  6670. if (player.empAnti) {
  6671. buyEquip(22, 0);
  6672. } else {
  6673. if ((player.shameCount > 4320 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6674. buyEquip(7, 0);
  6675. } else {
  6676. buyEquip(6, 0);
  6677. }
  6678. }
  6679. }
  6680. }
  6681. if (clicks.left || clicks.right) {
  6682. if (clicks.left) {
  6683. buyEquip(0, 1);
  6684. }
  6685. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  6686. buyEquip(0, 1);
  6687. } else if (traps.inTrap) {
  6688. buyEquip(0, 1);
  6689. } else {
  6690. buyEquip(11, 1);
  6691. }
  6692. }
  6693. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  6694. if (useWasd) {
  6695. wasdGears();
  6696. } else {
  6697. hatChanger();
  6698. accChanger();
  6699. }
  6700. }
  6701. //lastMoveDir = getSafeDir();
  6702. //packet("a", lastMoveDir, 1);
  6703. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  6704. autoPush();
  6705. } else {
  6706. if (my.autoPush) {
  6707. my.autoPush = false;
  6708. packet("a", lastMoveDir || undefined, 1);
  6709. }
  6710. }
  6711. if (instaC.ticking) {
  6712. instaC.ticking = false;
  6713. }
  6714. if (instaC.syncHit) {
  6715. instaC.syncHit = false;
  6716. }
  6717. if (player.empAnti) {
  6718. player.empAnti = false;
  6719. }
  6720. if (player.soldierAnti) {
  6721. player.soldierAnti = false;
  6722. }
  6723. if (my.anti0Tick > 0) {
  6724. my.anti0Tick--;
  6725. }
  6726. if (traps.replaced) {
  6727. traps.replaced = false;
  6728. }
  6729. if (traps.antiTrapped) {
  6730. traps.antiTrapped = false;
  6731. }
  6732.  
  6733. const getPotentialDamage = (build, user) => {
  6734. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  6735. const weap = user.weapons[weapIndex];
  6736. if (player.reloads[weap]) return 0;
  6737. const weapon = items.weapons[weap];
  6738. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  6739. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  6740. };
  6741.  
  6742. const AutoReplace = () => {
  6743. const replaceable = [];
  6744. const playerX = player.x;
  6745. const playerY = player.y;
  6746. const gameObjectCount = gameObjects.length;
  6747.  
  6748. for (let i = 0; i < gameObjectCount; i++) {
  6749. const build = gameObjects[i];
  6750. if (build.isItem && build.active && build.health > 0) {
  6751. const item = items.list[build.id];
  6752. const posDist = 35 + item.scale + (item.placeOffset || 0);
  6753. const inDistance = cdf(build, player) <= posDist * 2;
  6754. if (inDistance) {
  6755. let canDeal = 0;
  6756. const playersCount = players.length;
  6757. for (let j = 0; j < playersCount; j++) {
  6758. canDeal += getPotentialDamage(build, players[j]);
  6759. }
  6760. if (build.health <= canDeal) {
  6761. replaceable.push(build);
  6762. }
  6763. }
  6764. }
  6765. }
  6766.  
  6767. const findPlacementAngle = (player, itemId, build) => {
  6768. if (!build) return null;
  6769. const MAX_ANGLE = 2 * Math.PI;
  6770. const ANGLE_STEP = Math.PI / 360;
  6771. const item = items.list[player.items[itemId]];
  6772. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  6773. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  6774.  
  6775. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  6776. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  6777. for (let angle of angles) {
  6778. return angle;
  6779. }
  6780. }
  6781. return null;
  6782. };
  6783.  
  6784. const replace = (() => {
  6785. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  6786. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  6787. const buildId = spike ? 4 : 2;
  6788.  
  6789. replaceable.forEach(build => {
  6790. let angle = findPlacementAngle(player, buildId, build);
  6791. if (angle !== null) {
  6792. place(buildId, angle);
  6793. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  6794. }
  6795. });
  6796. });
  6797.  
  6798. if (near && near.dist3 <= 360) {
  6799. replace();
  6800. }
  6801. replace;
  6802. }
  6803. }
  6804. }
  6805. if (botSkts.length) {
  6806. botSkts.forEach((bots) => {
  6807. if (true) {
  6808. bots[0].showName = 'YEAHHH';
  6809. }
  6810. });
  6811. }
  6812. }
  6813. for(var i1 = 0; i1 < liztobj.length; i1++) {
  6814. 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)
  6815.  
  6816. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  6817. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  6818. selectWeapon(player.weapons[1])
  6819. buyEquip(40, 0);
  6820. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  6821. setTickout( () => {
  6822. buyEquip(6, 0)
  6823. }, 1);
  6824. }
  6825. }
  6826. }
  6827. }
  6828. function ez(context, x, y) {
  6829. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  6830. context.beginPath();
  6831. context.arc(x, y, 55, 0, Math.PI * 2);
  6832. context.fill();
  6833. context.closePath();
  6834. context.globalAlpha = 1;
  6835. }
  6836. // UPDATE LEADERBOARD:
  6837. function updateLeaderboard(data) {
  6838. lastLeaderboardData = data;
  6839. return;
  6840. UTILS.removeAllChildren(leaderboardData);
  6841. let tmpC = 1;
  6842. for (let i = 0; i < data.length; i += 3) {
  6843. (function(i) {
  6844. UTILS.generateElement({
  6845. class: "leaderHolder",
  6846. parent: leaderboardData,
  6847. children: [
  6848. UTILS.generateElement({
  6849. class: "leaderboardItem",
  6850. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  6851. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  6852. }),
  6853. UTILS.generateElement({
  6854. class: "leaderScore",
  6855. text: UTILS.sFormat(data[i + 2]) || "0"
  6856. })
  6857. ]
  6858. });
  6859. })(i);
  6860. tmpC++;
  6861. }
  6862. }
  6863.  
  6864. // LOAD GAME OBJECT:
  6865. function loadGameObject(data) {
  6866. for (let i = 0; i < data.length;) {
  6867. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  6868. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  6869. sid: data[i + 7]
  6870. } : null));
  6871. // sid, x, y, dir, s, type, data, setSID, owner
  6872. /*let dist = UTILS.getDist({
  6873. x: data[i + 1],
  6874. y: data[i + 2]
  6875. }, player, 0, 2);
  6876. let aim = UTILS.getDirect({
  6877. x: data[i + 1],
  6878. y: data[i + 2]
  6879. }, player, 0, 2);
  6880. find = findObjectBySid(data[i]);
  6881. if (data[i + 6] == 15) {
  6882. if (find && !find.isTeamObject(player)) {
  6883. if (dist <= 100) {
  6884. traps.dist = dist;
  6885. traps.aim = aim;
  6886. traps.protect(aim);
  6887. }
  6888. }
  6889. }*/
  6890. i += 8;
  6891. }
  6892. }
  6893.  
  6894. // ADD AI:
  6895. function loadAI(data) {
  6896. for (let i = 0; i < ais.length; ++i) {
  6897. ais[i].forcePos = !ais[i].visible;
  6898. ais[i].visible = false;
  6899. }
  6900. if (data) {
  6901. let tmpTime = performance.now();
  6902. for (let i = 0; i < data.length;) {
  6903. tmpObj = findAIBySID(data[i]);
  6904. if (tmpObj) {
  6905. tmpObj.index = data[i + 1];
  6906. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  6907. tmpObj.t2 = tmpTime;
  6908. tmpObj.x1 = tmpObj.x;
  6909. tmpObj.y1 = tmpObj.y;
  6910. tmpObj.x2 = data[i + 2];
  6911. tmpObj.y2 = data[i + 3];
  6912. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  6913. tmpObj.d2 = data[i + 4];
  6914. tmpObj.health = data[i + 5];
  6915. tmpObj.dt = 0;
  6916. tmpObj.visible = true;
  6917. } else {
  6918. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  6919. tmpObj.x2 = tmpObj.x;
  6920. tmpObj.y2 = tmpObj.y;
  6921. tmpObj.d2 = tmpObj.dir;
  6922. tmpObj.health = data[i + 5];
  6923. if (!aiManager.aiTypes[data[i + 1]].name)
  6924. tmpObj.name = config.cowNames[data[i + 6]];
  6925. tmpObj.forcePos = true;
  6926. tmpObj.sid = data[i];
  6927. tmpObj.visible = true;
  6928. }
  6929. i += 7;
  6930. }
  6931. }
  6932. }
  6933.  
  6934. // ANIMATE AI:
  6935. function animateAI(sid) {
  6936. tmpObj = findAIBySID(sid);
  6937. if (tmpObj) tmpObj.startAnim();
  6938. }
  6939.  
  6940. // GATHER ANIMATION:
  6941. function gatherAnimation(sid, didHit, index) {
  6942. tmpObj = findPlayerBySID(sid);
  6943. if (tmpObj) {
  6944. tmpObj.startAnim(didHit, index);
  6945. tmpObj.gatherIndex = index;
  6946. tmpObj.gathering = 1;
  6947.  
  6948. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  6949. // healer();
  6950.  
  6951. if (didHit) {
  6952. let tmpObjects = objectManager.hitObj;
  6953. objectManager.hitObj = [];
  6954. game.tickBase(() => {
  6955. // refind
  6956. tmpObj = findPlayerBySID(sid);
  6957. 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);
  6958. tmpObjects.forEach((healthy) => {
  6959. healthy.health -= val;
  6960. });
  6961. }, 1);
  6962. }
  6963. }
  6964. }
  6965.  
  6966. // WIGGLE GAME OBJECT:
  6967. function wiggleGameObject(dir, sid) {
  6968. tmpObj = findObjectBySid(sid);
  6969. if (tmpObj) {
  6970. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  6971. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  6972. if (tmpObj.health) {
  6973. objectManager.hitObj.push(tmpObj);
  6974. }
  6975. }
  6976. }
  6977.  
  6978. // SHOOT TURRET:
  6979. function shootTurret(sid, dir) {
  6980. tmpObj = findObjectBySid(sid);
  6981. if (tmpObj) {
  6982. if (config.anotherVisual) {
  6983. tmpObj.lastDir = dir;
  6984. } else {
  6985. tmpObj.dir = dir;
  6986. }
  6987. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  6988. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  6989. }
  6990. }
  6991.  
  6992. // UPDATE PLAYER VALUE:
  6993. function updatePlayerValue(index, value, updateView) {
  6994. if (player) {
  6995. player[index] = value;
  6996. if (index == "points") {
  6997. if (configs.autoBuy) {
  6998. autoBuy.hat();
  6999. autoBuy.acc();
  7000. }
  7001. } else if (index == "kills") {
  7002. // Woah Credits To Zod324Myers https://www.youtube.com/@Zod324myers
  7003. if (configs.killChat) {
  7004. sendChat("Dumbasses Down: " + value);
  7005. setTimeout(() => {
  7006. sendChat("I am super pro!");
  7007. }, 600);
  7008. }
  7009. }
  7010. }
  7011. }
  7012.  
  7013.  
  7014. // ACTION BAR:
  7015. function updateItems(data, wpn) {
  7016. if (data) {
  7017. if (wpn) {
  7018. player.weapons = data;
  7019. player.primaryIndex = player.weapons[0];
  7020. player.secondaryIndex = player.weapons[1];
  7021. if (!instaC.isTrue) {
  7022. selectWeapon(player.weapons[0]);
  7023. }
  7024. } else {
  7025. player.items = data;
  7026. }
  7027. }
  7028.  
  7029. for (let i = 0; i < items.list.length; i++) {
  7030. let tmpI = items.weapons.length + i;
  7031. let actionBarItem = getEl("actionBarItem" + tmpI);
  7032. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7033. // Add shadow to the element
  7034. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7035. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7036.  
  7037. }
  7038.  
  7039. for (let i = 0; i < items.weapons.length; i++) {
  7040. let actionBarItem = getEl("actionBarItem" + i);
  7041. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7042. // Add shadow to the element
  7043. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7044. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7045. }
  7046.  
  7047. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7048. if (kms) {
  7049. getEl("actionBarItem3").style.display = "none";
  7050. getEl("actionBarItem4").style.display = "inline-block";
  7051. }
  7052. }
  7053.  
  7054. // ADD PROJECTILE:
  7055. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7056. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7057. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7058. }
  7059.  
  7060. // REMOVE PROJECTILE:
  7061. function remProjectile(sid, range) {
  7062. for (let i = 0; i < projectiles.length; ++i) {
  7063. if (projectiles[i].sid == sid) {
  7064. projectiles[i].range = range;
  7065. let tmpObjects = objectManager.hitObj;
  7066. objectManager.hitObj = [];
  7067. game.tickBase(() => {
  7068. let val = projectiles[i].dmg;
  7069. tmpObjects.forEach((healthy) => {
  7070. if (healthy.projDmg) {
  7071. healthy.health -= val;
  7072. }
  7073. });
  7074. }, 1);
  7075. }
  7076. }
  7077. }
  7078.  
  7079. // lol this useless,,, fr
  7080. let noob = false;
  7081. let serverReady = true;
  7082. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7083. let wssws = isProd ? "wss" : "ws";
  7084. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7085. let withSync = false;
  7086. project.binaryType = "arraybuffer";
  7087. project.onmessage = function(msg) {
  7088. let data = msg.data;
  7089. if (data == "isready") {
  7090. serverReady = true;
  7091. }
  7092. if (data == "fine") {
  7093. noob = false;
  7094. }
  7095.  
  7096. if (data == "tezt") {
  7097. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7098. }
  7099. if (data == "yeswearesyncer") {
  7100. // let delay = Date.now() - wsDelay;
  7101. withSync = true;
  7102. if (player) {
  7103. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7104. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7105. }
  7106. }
  7107. };
  7108. project.onopen = function() {
  7109. var gameTitle = getEl("gameName");
  7110. gameTitle.innerText = "DiaMonD HAckErs";
  7111. };
  7112.  
  7113. // SHOW ALLIANCE MENU:
  7114. function allianceNotification(sid, name) {
  7115. let findBotSID = findSID(bots, sid);
  7116. if (findBotSID) {}
  7117. }
  7118.  
  7119. function setPlayerTeam(team, isOwner) {
  7120. if (player) {
  7121. player.team = team;
  7122. player.isOwner = isOwner;
  7123. if (team == null)
  7124. alliancePlayers = [];
  7125. }
  7126. }
  7127.  
  7128. function setAlliancePlayers(data) {
  7129. alliancePlayers = data;
  7130. }
  7131.  
  7132. // STORE MENU:
  7133. function updateStoreItems(type, id, index) {
  7134. if (index) {
  7135. if (!type)
  7136. player.tails[id] = 1;
  7137. else {
  7138. player.latestTail = id;
  7139. }
  7140. } else {
  7141. if (!type)
  7142. player.skins[id] = 1,
  7143. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7144. else {
  7145. player.latestSkin = id;
  7146. }
  7147. }
  7148. }
  7149.  
  7150. // SEND MESSAGE:
  7151. function receiveChat(sid, message) {
  7152. let kawaii = false;
  7153. let tmpPlayer = findPlayerBySID(sid);
  7154. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7155. tmpPlayer.chatMessage = message;
  7156. tmpPlayer.chatCountdown = config.chatCountdown;
  7157. }
  7158.  
  7159. // MINIMAP:
  7160. function updateMinimap(data) {
  7161. minimapData = data;
  7162. }
  7163.  
  7164. // SHOW ANIM TEXT:
  7165. function showText(x, y, value, type) {
  7166. // if (config.anotherVisual) {
  7167. textManager.stack.push({
  7168. x: x,
  7169. y: y,
  7170. value: value
  7171. });
  7172. // } else {
  7173. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7174. // }
  7175. }
  7176.  
  7177. /** APPLY SOCKET CODES */
  7178.  
  7179. // BOT:
  7180. let bots = [];
  7181. let ranLocation = {
  7182. x: UTILS.randInt(35, 14365),
  7183. y: UTILS.randInt(35, 14365)
  7184. };
  7185. setInterval(() => {
  7186. ranLocation = {
  7187. x: UTILS.randInt(35, 14365),
  7188. y: UTILS.randInt(35, 14365)
  7189. };
  7190. }, 60000);
  7191. class Bot {
  7192. constructor(id, sid, hats, accessories) {
  7193. this.millPlace = true;
  7194. this.id = id;
  7195. this.sid = sid;
  7196. this.team = null;
  7197. this.skinIndex = 0;
  7198. this.tailIndex = 0;
  7199. this.hitTime = 0;
  7200. this.iconIndex = 0;
  7201. this.enemy = [];
  7202. this.near = [];
  7203. this.dist2 = 0;
  7204. this.aim2 = 0;
  7205. this.tick = 0;
  7206. this.itemCounts = {};
  7207. this.latestSkin = 0;
  7208. this.latestTail = 0;
  7209. this.points = 0;
  7210. this.tails = {};
  7211. for (let i = 0; i < accessories.length; ++i) {
  7212. if (accessories[i].price <= 0)
  7213. this.tails[accessories[i].id] = 1;
  7214. }
  7215. this.skins = {};
  7216. for (let i = 0; i < hats.length; ++i) {
  7217. if (hats[i].price <= 0)
  7218. this.skins[hats[i].id] = 1;
  7219. }
  7220. this.spawn = function(moofoll) {
  7221. this.upgraded = 0;
  7222. this.enemy = [];
  7223. this.near = [];
  7224. this.active = true;
  7225. this.alive = true;
  7226. this.lockMove = false;
  7227. this.lockDir = false;
  7228. this.minimapCounter = 0;
  7229. this.chatCountdown = 0;
  7230. this.shameCount = 0;
  7231. this.shameTimer = 0;
  7232. this.sentTo = {};
  7233. this.gathering = 0;
  7234. this.autoGather = 0;
  7235. this.animTime = 0;
  7236. this.animSpeed = 0;
  7237. this.mouseState = 0;
  7238. this.buildIndex = -1;
  7239. this.weaponIndex = 0;
  7240. this.dmgOverTime = {};
  7241. this.noMovTimer = 0;
  7242. this.maxXP = 300;
  7243. this.XP = 0;
  7244. this.age = 1;
  7245. this.kills = 0;
  7246. this.upgrAge = 2;
  7247. this.upgradePoints = 0;
  7248. this.x = 0;
  7249. this.y = 0;
  7250. this.zIndex = 0;
  7251. this.xVel = 0;
  7252. this.yVel = 0;
  7253. this.slowMult = 1;
  7254. this.dir = 0;
  7255. this.nDir = 0;
  7256. this.dirPlus = 0;
  7257. this.targetDir = 0;
  7258. this.targetAngle = 0;
  7259. this.maxHealth = 100;
  7260. this.health = this.maxHealth;
  7261. this.oldHealth = this.maxHealth;
  7262. this.scale = config.playerScale;
  7263. this.speed = config.playerSpeed;
  7264. this.resetMoveDir();
  7265. this.resetResources(moofoll);
  7266. this.items = [0, 3, 6, 10];
  7267. this.weapons = [0];
  7268. this.shootCount = 0;
  7269. this.weaponXP = [];
  7270. this.isBot = false;
  7271. this.reloads = {
  7272. 0: 0,
  7273. 1: 0,
  7274. 2: 0,
  7275. 3: 0,
  7276. 4: 0,
  7277. 5: 0,
  7278. 6: 0,
  7279. 7: 0,
  7280. 8: 0,
  7281. 9: 0,
  7282. 10: 0,
  7283. 11: 0,
  7284. 12: 0,
  7285. 13: 0,
  7286. 14: 0,
  7287. 15: 0,
  7288. 53: 0,
  7289. };
  7290. this.timeZinceZpawn = 0;
  7291. this.whyDie = "";
  7292. this.clearRadius = false;
  7293. this.circlee = 0;
  7294. };
  7295.  
  7296. // RESET MOVE DIR:
  7297. this.resetMoveDir = function() {
  7298. this.moveDir = undefined;
  7299. };
  7300.  
  7301. // RESET RESOURCES:
  7302. this.resetResources = function(moofoll) {
  7303. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7304. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7305. }
  7306. };
  7307.  
  7308. // SET DATA:
  7309. this.setData = function(data) {
  7310. this.id = data[0];
  7311. this.sid = data[1];
  7312. this.name = data[2];
  7313. this.x = data[3];
  7314. this.y = data[4];
  7315. this.dir = data[5];
  7316. this.health = data[6];
  7317. this.maxHealth = data[7];
  7318. this.scale = data[8];
  7319. this.skinColor = data[9];
  7320. };
  7321.  
  7322.  
  7323. // SHAME SYSTEM:
  7324. this.judgeShame = function() {
  7325. if (this.oldHealth < this.health) {
  7326. if (this.hitTime) {
  7327. let timeSinceHit = this.tick - this.hitTime;
  7328. this.hitTime = 0;
  7329. if (timeSinceHit < 2) {
  7330. this.lastshamecount = this.shameCount;
  7331. this.shameCount++;
  7332. } else {
  7333. this.lastshamecount = this.shameCount;
  7334. this.shameCount = Math.max(0, this.shameCount - 2);
  7335. }
  7336. }
  7337. } else if (this.oldHealth > this.health) {
  7338. this.hitTime = this.tick;
  7339. }
  7340. };
  7341.  
  7342. // UPDATE WEAPON RELOAD:
  7343. this.manageReloadaa = function() {
  7344. if (this.shooting[53]) {
  7345. this.shooting[53] = 0;
  7346. this.reloads[53] = (2500 - 1000/9);
  7347. } else {
  7348. if (this.reloads[53] > 0) {
  7349. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7350. }
  7351. }
  7352. if (this.gathering || this.shooting[1]) {
  7353. if (this.gathering) {
  7354. this.gathering = 0;
  7355. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7356. this.attacked = true;
  7357. }
  7358. if (this.shooting[1]) {
  7359. this.shooting[1] = 0;
  7360. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7361. this.attacked = true;
  7362. }
  7363. } else {
  7364. this.attacked = false;
  7365. if (this.buildIndex < 0) {
  7366. if (this.reloads[this.weaponIndex] > 0) {
  7367. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7368. }
  7369. }
  7370. }
  7371. };
  7372.  
  7373. this.closeSockets = function(websc) {
  7374. websc.close();
  7375. };
  7376.  
  7377. this.whyDieChat = function(websc, whydie) {
  7378. websc.sendWS("6", "why die XDDD " + whydie);
  7379. };
  7380. }
  7381. };
  7382.  
  7383. class BotObject {
  7384. constructor(sid) {
  7385. this.sid = sid;
  7386. // INIT:
  7387. this.init = function(x, y, dir, scale, type, data, owner) {
  7388. data = data || {};
  7389. this.active = true;
  7390. this.x = x;
  7391. this.y = y;
  7392. this.scale = scale;
  7393. this.owner = owner;
  7394. this.id = data.id;
  7395. this.dmg = data.dmg;
  7396. this.trap = data.trap;
  7397. this.teleport = data.teleport;
  7398. this.isItem = this.id != undefined;
  7399. };
  7400.  
  7401. }
  7402. };
  7403. class BotObjManager {
  7404. constructor(botObj, fOS) {
  7405. // DISABLE OBJ:
  7406. this.disableObj = function(obj) {
  7407. obj.active = false;
  7408. if (config.anotherVisual) {} else {
  7409. obj.alive = false;
  7410. }
  7411. };
  7412.  
  7413. // ADD NEW:
  7414. let tmpObj;
  7415. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7416. tmpObj = fOS(sid);
  7417. if (!tmpObj) {
  7418. tmpObj = botObj.find((tmp) => !tmp.active);
  7419. if (!tmpObj) {
  7420. tmpObj = new BotObject(sid);
  7421. botObj.push(tmpObj);
  7422. }
  7423. }
  7424. if (setSID) {
  7425. tmpObj.sid = sid;
  7426. }
  7427. tmpObj.init(x, y, dir, s, type, data, owner);
  7428. };
  7429.  
  7430. // DISABLE BY SID:
  7431. this.disableBySid = function(sid) {
  7432. let find = fOS(sid);
  7433. if (find) {
  7434. this.disableObj(find);
  7435. }
  7436. };
  7437.  
  7438. // REMOVE ALL FROM PLAYER:
  7439. this.removeAllItems = function(sid, server) {
  7440. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7441. };
  7442. }
  7443. };
  7444.  
  7445. let botz = [];
  7446.  
  7447. function botSpawn(id) {
  7448. let bot;
  7449. console.log(WS);
  7450. let t = WS.url.split("wss://")[1].split("?")[0];
  7451. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7452. let botPlayer = new Map();
  7453. botSkts.push([botPlayer]);
  7454. botz.push([bot]);
  7455. let botSID;
  7456. let botObj = [];
  7457. let nearObj = [];
  7458. let bD = {
  7459. x: 0,
  7460. y: 0,
  7461. inGame: false,
  7462. closeSocket: false,
  7463. whyDie: ""
  7464. };
  7465. let oldXY = {
  7466. x: 0,
  7467. y: 0,
  7468. };
  7469. let izauto = 0;
  7470. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7471. bot.binaryType = "arraybuffer";
  7472. bot.first = true;
  7473. bot.sendWS = function(type) {
  7474. // EXTRACT DATA ARRAY:
  7475. let data = Array.prototype.slice.call(arguments, 1);
  7476. // SEND MESSAGE:
  7477. let binary = window.msgpack.encode([type, data]);
  7478. bot.send(binary);
  7479. };
  7480. bot.spawn = function() {
  7481. bot.sendWS("M", {
  7482. name: "unknown1l",
  7483. moofoll: 1,
  7484. skin: "__proto__"
  7485. });
  7486. };
  7487. bot.sendUpgrade = function(index) {
  7488. bot.sendWS("H", index);
  7489. };
  7490. bot.place = function(id, a) {
  7491. try {
  7492. let item = items.list[botPlayer.items[id]];
  7493. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7494. bot.sendWS("G", botPlayer.items[id]);
  7495. bot.sendWS("d", 1, a);
  7496. bot.sendWS("G", botPlayer.weaponIndex, true);
  7497. }
  7498. } catch (e) {
  7499. }
  7500. };
  7501. bot.buye = function(id, index) {
  7502. let nID = 0;
  7503. if (botPlayer.alive && botPlayer.inGame) {
  7504. if (index == 0) {
  7505. if (botPlayer.skins[id]) {
  7506. if (botPlayer.latestSkin != id) {
  7507. bot.sendWS("c", 0, id, 0);
  7508. }
  7509. } else {
  7510. let find = findID(hats, id);
  7511. if (find) {
  7512. if (botPlayer.points >= find.price) {
  7513. bot.sendWS("c", 1, id, 0);
  7514. bot.sendWS("c", 0, id, 0);
  7515. } else {
  7516. if (botPlayer.latestSkin != nID) {
  7517. bot.sendWS("c", 0, nID, 0);
  7518. }
  7519. }
  7520. } else {
  7521. if (botPlayer.latestSkin != nID) {
  7522. bot.sendWS("c", 0, nID, 0);
  7523. }
  7524. }
  7525. }
  7526. } else if (index == 1) {
  7527. if (botPlayer.tails[id]) {
  7528. if (botPlayer.latestTail != id) {
  7529. bot.sendWS("c", 0, id, 1);
  7530. }
  7531. } else {
  7532. let find = findID(accessories, id);
  7533. if (find) {
  7534. if (botPlayer.points >= find.price) {
  7535. bot.sendWS("c", 1, id, 1);
  7536. bot.sendWS("c", 0, id, 1);
  7537. } else {
  7538. if (botPlayer.latestTail != 0) {
  7539. bot.sendWS("c", 0, 0, 1);
  7540. }
  7541. }
  7542. } else {
  7543. if (botPlayer.latestTail != 0) {
  7544. bot.sendWS("c", 0, 0, 1);
  7545. }
  7546. }
  7547. }
  7548. }
  7549. }
  7550. };
  7551. bot.fastGear = function() {
  7552. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7553. bot.buye(31, 0);
  7554. } else {
  7555. if (botPlayer.y2 <= config.snowBiomeTop) {
  7556. bot.buye(15, 0);
  7557. } else {
  7558. bot.buye(12, 0);
  7559. }
  7560. }
  7561. };
  7562. bot.selectWeapon = function(a) {
  7563. packet("G", a, 1);
  7564. }
  7565. function caf(e, t) {
  7566. try {
  7567. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7568. } catch (e) {
  7569. return 0;
  7570. }
  7571. }
  7572. bot.heal = function() {
  7573. if (botPlayer.health < 100) {
  7574. bot.place(0, 0)
  7575. }
  7576. }
  7577. function cdf (e, t){
  7578. try {
  7579. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  7580. } catch(e){
  7581. return Infinity;
  7582. }
  7583. }
  7584. let zoon = 'no';
  7585. bot.zync = function(a) {
  7586. if (!botPlayer.millPlace) {
  7587. zoon = 'yeah';
  7588. bot.place(5, caf(botPlayer, a));
  7589. let NextTickLocation = {
  7590. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7591. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7592. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7593. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7594. };
  7595.  
  7596. function calculateDistance(x1, y1, x2, y2) {
  7597. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  7598. return distance;
  7599. }
  7600. function dotherezt() {
  7601. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7602. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  7603. }
  7604.  
  7605. let aa = setInterval(() => {
  7606. bot.sendWS("G", botPlayer.weapons[1], true);
  7607. if (izauto == 0) {
  7608. bot.sendWS("K", 1);
  7609. izauto = 1;
  7610. }
  7611. setTimeout(() => {
  7612. bot.sendWS("G", botPlayer.weapons[0], true);
  7613. }, 2000);
  7614. bot.buye(53, 0);
  7615. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  7616. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  7617. } else {
  7618. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7619. zoon = 'no';
  7620. bot.sendWS("a", undefined);
  7621. dotherezt();
  7622. clearInterval(aa);
  7623. }
  7624. }, 150);
  7625.  
  7626. setTimeout(() => {
  7627. zoon = 'no';
  7628. clearInterval(aa);
  7629. }, 500);
  7630. }
  7631. };
  7632. bot.onmessage = function(message) {
  7633. let data = new Uint8Array(message.data);
  7634. let parsed = window.msgpack.decode(data);
  7635. let type = parsed[0];
  7636. data = parsed[1];
  7637. if (type == "io-init") {
  7638. bot.spawn();
  7639. }
  7640. if (type == "1") {
  7641. botSID = data[0];
  7642. console.log(botSID)
  7643. }
  7644. if (type == "D") {
  7645. if (data[1]) {
  7646. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  7647. botPlayer.setData(data[0]);
  7648. botPlayer.inGame = true;
  7649. botPlayer.alive = true;
  7650. botPlayer.x2 = undefined;
  7651. botPlayer.y2 = undefined;
  7652. botPlayer.spawn(1);
  7653. botPlayer.oldHealth = 100;
  7654. botPlayer.health = 100;
  7655. botPlayer.showName = 'YEAHHH';
  7656. oldXY = {
  7657. x: data[0][3],
  7658. y: data[0][4]
  7659. }
  7660. bD.inGame = true;
  7661. if (bot.first) {
  7662. bot.first = false;
  7663. bots.push(bD);
  7664. }
  7665. }
  7666. }
  7667. if (type == "P") {
  7668. bot.spawn();
  7669. botPlayer.inGame = false;
  7670. bD.inGame = false;
  7671. }
  7672. if (type == "a") {
  7673. let tmpData = data[0];
  7674. botPlayer.tick++;
  7675. botPlayer.enemy = [];
  7676. botPlayer.near = [];
  7677. bot.showName = 'YEAHHH';
  7678. nearObj = [];
  7679. for (let i = 0; i < tmpData.length;) {
  7680. if (tmpData[i] == botPlayer.sid) {
  7681. botPlayer.x2 = tmpData[i + 1];
  7682. botPlayer.y2 = tmpData[i + 2];
  7683. botPlayer.d2 = tmpData[i + 3];
  7684. botPlayer.buildIndex = tmpData[i + 4];
  7685. botPlayer.weaponIndex = tmpData[i + 5];
  7686. botPlayer.weaponVariant = tmpData[i + 6];
  7687. botPlayer.team = tmpData[i + 7];
  7688. botPlayer.isLeader = tmpData[i + 8];
  7689. botPlayer.skinIndex = tmpData[i + 9];
  7690. botPlayer.tailIndex = tmpData[i + 10];
  7691. botPlayer.iconIndex = tmpData[i + 11];
  7692. botPlayer.zIndex = tmpData[i + 12];
  7693. botPlayer.visible = true;
  7694. bD.x2 = botPlayer.x2;
  7695. bD.y2 = botPlayer.y2;
  7696. }
  7697. i += 13;
  7698. }
  7699.  
  7700. for (let i = 0; i < tmpData.length;) {
  7701. tmpObj = findPlayerBySID(tmpData[i]);
  7702. if (tmpObj) {
  7703. if (!tmpObj.isTeam(botPlayer)) {
  7704. enemy.push(tmpObj);
  7705. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  7706. nears.push(tmpObj);
  7707. }
  7708. }
  7709. }
  7710. i += 13;
  7711. }
  7712.  
  7713. if (enemy.length) {
  7714. //console.log(enemy)
  7715. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  7716. return tmp1.dist2 - tmp2.dist2;
  7717. })[0];
  7718. }
  7719.  
  7720. if (izauto == 1) {
  7721. bot.sendWS("K", 1);
  7722. izauto = 0;
  7723. }
  7724.  
  7725. if (bD.closeSocket) {
  7726. botPlayer.closeSockets(bot);
  7727. }
  7728. if (bD.whyDie != "") {
  7729. botPlayer.whyDieChat(bot, bD.whyDie);
  7730. bD.whyDie = "";
  7731. }
  7732. if (botPlayer.alive) {
  7733. if (player.team) {
  7734. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  7735. botPlayer.team && (bot.sendWS("N"));
  7736. bot.sendWS("b", player.team);
  7737. }
  7738. }
  7739.  
  7740. let item = items.list[botPlayer.items[3]];
  7741. let a = botPlayer.itemCounts[item.group.id]
  7742. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  7743. if (botPlayer.inGame) {
  7744. bot.sendWS("D", botPlayer.moveDir);
  7745. if (izauto == 0) {
  7746. bot.sendWS("K", 1);
  7747. izauto = 1;
  7748. }
  7749. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  7750. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  7751. bot.place(3, aim + 7.7);
  7752. bot.place(3, aim - 7.7);
  7753. bot.place(3, aim);
  7754. oldXY = {
  7755. x: botPlayer.x2,
  7756. y: botPlayer.y2
  7757. };
  7758. }
  7759.  
  7760. if (botPlayer.tick % 90 === 0) {
  7761. let rand = Math.random() * Math.PI * 2;
  7762. botPlayer.moveDir = rand;
  7763. bot.sendWS("a", botPlayer.moveDir);
  7764. }
  7765. }
  7766. bot.fastGear();
  7767. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  7768. botPlayer.millPlace = false;
  7769. // bot.sendWS("K", 1);
  7770. bot.fastGear();
  7771. } else {
  7772. if (botPlayer.inGame) {
  7773. if (botObj.length > 0) {
  7774. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  7775. if (getEl("mode").value == 'fuckemup') {
  7776. // if (getEl("mode").value == "clear") {
  7777. bot.selectWeapon(botPlayer.weapons[1]);
  7778. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  7779. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  7780. 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) {
  7781. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7782. })[0];
  7783. if (nearObj) {
  7784. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  7785. if ((gotoDist - isPassed) > 0) {
  7786. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7787. if (botPlayer.moveDir != undefined) {
  7788. botPlayer.moveDir = undefined;
  7789. bot.sendWS("a", botPlayer.moveDir);
  7790. bot.sendWS("D", botPlayer.nDir);
  7791. }
  7792. } else {
  7793. botPlayer.moveDir = gotoAim;
  7794. bot.sendWS("a", botPlayer.moveDir);
  7795. bot.sendWS("D", botPlayer.nDir);
  7796. }
  7797. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7798. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7799. bot.sendWS("D", botPlayer.nDir);
  7800. }
  7801. if (izauto == 0) {
  7802. bot.sendWS("K", 1);
  7803. izauto = 1;
  7804. }
  7805. bot.buye(40, 0);
  7806. } else {
  7807. botPlayer.moveDir = gotoAim;
  7808. bot.sendWS("a", botPlayer.moveDir);
  7809. bot.sendWS("D", botPlayer.nDir);
  7810. bot.fastGear();
  7811. }
  7812. } else {
  7813. botPlayer.moveDir = gotoAim;
  7814. bot.sendWS("a", botPlayer.moveDir);
  7815. bot.sendWS("D", botPlayer.nDir);
  7816. bot.fastGear();
  7817. }
  7818. }
  7819. }
  7820.  
  7821.  
  7822.  
  7823. if (botObj.length > 0) {
  7824. if (getEl("mode").value == 'flex') {
  7825. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  7826. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  7827. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  7828.  
  7829. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  7830.  
  7831. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  7832. if (dist > 22) // 22 is player speed without booster hat
  7833. return;
  7834. }
  7835. }
  7836.  
  7837.  
  7838. if (botObj.length > 0) {
  7839. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  7840. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7841. })[0];
  7842.  
  7843. if (nearObj) {
  7844. if (izauto == 0) {
  7845. bot.sendWS("K", 1);
  7846. izauto = 1;
  7847. }
  7848. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7849. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7850. bot.sendWS("D", botPlayer.nDir);
  7851. }
  7852. bot.buye(40, 0);
  7853. bot.buye(11, 1);
  7854. } else {
  7855. bot.fastGear();
  7856. bot.buye(11, 1);
  7857. }
  7858. bot.buye(11, 1);
  7859. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  7860. // if (getEl("mode").value == "clear") {
  7861. bot.selectWeapon(botPlayer.weapons[1]);
  7862. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  7863. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  7864. 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) {
  7865. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7866. })[0];
  7867. if (nearObj) {
  7868. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  7869. if ((gotoDist - isPassed) > 0) {
  7870. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7871. if (botPlayer.moveDir != undefined) {
  7872. botPlayer.moveDir = undefined;
  7873. bot.sendWS("a", botPlayer.moveDir);
  7874. bot.sendWS("D", botPlayer.nDir);
  7875. }
  7876. } else {
  7877. botPlayer.moveDir = gotoAim;
  7878. bot.sendWS("a", botPlayer.moveDir);
  7879. bot.sendWS("D", botPlayer.nDir);
  7880. }
  7881. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7882. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7883. bot.sendWS("D", botPlayer.nDir);
  7884. }
  7885. if (izauto == 0) {
  7886. bot.sendWS("K", 1);
  7887. izauto = 1;
  7888. }
  7889. bot.buye(40, 0);
  7890. bot.fastGear();
  7891. } else {
  7892. botPlayer.moveDir = gotoAim;
  7893. bot.sendWS("a", botPlayer.moveDir);
  7894. bot.sendWS("D", botPlayer.nDir);
  7895. bot.fastGear();
  7896. }
  7897. } else {
  7898. botPlayer.moveDir = gotoAim;
  7899. bot.sendWS("a", botPlayer.moveDir);
  7900. bot.sendWS("D", botPlayer.nDir);
  7901. bot.fastGear();
  7902. }
  7903. if (gotoDist > 300) {
  7904. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  7905. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  7906. bot.place(3, aim + 7.7);
  7907. bot.place(3, aim - 7.7);
  7908. bot.place(3, aim);
  7909. oldXY = {
  7910. x: botPlayer.x2,
  7911. y: botPlayer.y2
  7912. };
  7913. }
  7914. }
  7915. }
  7916. }
  7917.  
  7918. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  7919. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  7920.  
  7921. if(!wdaawdwad.length) {
  7922. if(zoon == 'no')
  7923. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  7924. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7925. }
  7926.  
  7927. if(wdaawdwad.length) {
  7928. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  7929. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  7930. 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) {
  7931. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  7932. })[0];
  7933. if (nearObj) {
  7934. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  7935. if ((gotoDist - isPassed) > 0) {
  7936. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  7937. if (botPlayer.moveDir != undefined) {
  7938. botPlayer.moveDir = undefined;
  7939. bot.sendWS("a", botPlayer.moveDir);
  7940. bot.sendWS("D", botPlayer.nDir);
  7941. }
  7942. } else {
  7943. bot.sendWS("D", botPlayer.nDir);
  7944. }
  7945. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  7946. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  7947. bot.sendWS("D", botPlayer.nDir);
  7948. }
  7949. if (izauto == 0) {
  7950. bot.sendWS("K", 1);
  7951. izauto = 1;
  7952. }
  7953. bot.buye(40, 0);
  7954. bot.fastGear();
  7955. } else {
  7956. if(zoon == 'no')
  7957. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  7958. if(cdf(player, botPlayer) <= 110)
  7959. bot.sendWS("a", undefined);
  7960. else
  7961. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7962. }
  7963. } else {
  7964. if(wdaawdwad.length) {
  7965. if(zoon == 'no')
  7966. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  7967. if(cdf(player, botPlayer) <= 110)
  7968. bot.sendWS("a", undefined);
  7969. else
  7970. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7971. } else {
  7972. if(zoon == 'no')
  7973. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  7974. if(cdf(player, botPlayer) <= 110)
  7975. bot.sendWS("a", undefined);
  7976. else
  7977. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  7978. }
  7979. }
  7980. }
  7981. }
  7982. }
  7983. }
  7984. }
  7985. }
  7986. if (type == "H") {
  7987. let tmpData = data[0];
  7988. for (let i = 0; i < tmpData.length;) {
  7989. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  7990. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  7991. sid: tmpData[i + 7]
  7992. } : null));
  7993. i += 8;
  7994. }
  7995. }
  7996. if (type == "N") {
  7997. let index = data[0];
  7998. let value = data[1];
  7999. if (botPlayer) {
  8000. botPlayer[index] = value;
  8001. }
  8002. }
  8003. if (type == "O") {
  8004. if (data[0] == botPlayer.sid) {
  8005. botPlayer.oldHealth = botPlayer.health;
  8006. botPlayer.health = data[1];
  8007. botPlayer.judgeShame();
  8008. if (botPlayer.oldHealth > botPlayer.health) {
  8009. if (botPlayer.shameCount < 5) {
  8010. for (let i = 0; i < 2; i++) {
  8011. bot.place(0, botPlayer.nDir);
  8012. }
  8013.  
  8014. } else {
  8015. setTimeout(() => {
  8016. for (let i = 0; i < 2; i++) {
  8017. bot.place(0, botPlayer.nDir);
  8018. }
  8019. }, 95);
  8020. }
  8021. }
  8022. }
  8023. }
  8024. if (type == "Q") {
  8025. let sid = data[0];
  8026. botObjManager.disableBySid(sid);
  8027. }
  8028. if (type == "R") {
  8029. let sid = data[0];
  8030. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8031. }
  8032. if (type == "S") {
  8033. let index = data[0];
  8034. let value = data[1];
  8035. if (botPlayer) {
  8036. botPlayer.itemCounts[index] = value;
  8037. }
  8038. }
  8039. if (type == "U") {
  8040. if (data[0] > 0) {
  8041. if(getEl("setup").value == 'dm') {
  8042. if (botPlayer.upgraded == 0) {
  8043. bot.sendUpgrade(7);
  8044. } else if (botPlayer.upgraded == 1) {
  8045. bot.sendUpgrade(17);
  8046. } else if (botPlayer.upgraded == 2) {
  8047. bot.sendUpgrade(31);
  8048. } else if (botPlayer.upgraded == 3) {
  8049. bot.sendUpgrade(23);
  8050. } else if (botPlayer.upgraded == 4) {
  8051. bot.sendUpgrade(9);
  8052. } else if (botPlayer.upgraded == 5) {
  8053. bot.sendUpgrade(34);
  8054. } else if (botPlayer.upgraded == 6) {
  8055. bot.sendUpgrade(12);
  8056. } else if (botPlayer.upgraded == 7) {
  8057. bot.sendUpgrade(15);
  8058. }
  8059. } else if(getEl("setup").value == 'dr') {
  8060. if (botPlayer.upgraded == 0) {
  8061. bot.sendUpgrade(7);
  8062. } else if (botPlayer.upgraded == 1) {
  8063. bot.sendUpgrade(17);
  8064. } else if (botPlayer.upgraded == 2) {
  8065. bot.sendUpgrade(31);
  8066. } else if (botPlayer.upgraded == 3) {
  8067. bot.sendUpgrade(23);
  8068. } else if (botPlayer.upgraded == 4) {
  8069. bot.sendUpgrade(9);
  8070. } else if (botPlayer.upgraded == 5) {
  8071. bot.sendUpgrade(34);
  8072. } else if (botPlayer.upgraded == 6) {
  8073. bot.sendUpgrade(12);
  8074. } else if (botPlayer.upgraded == 7) {
  8075. bot.sendUpgrade(13);
  8076. }
  8077. } else if(getEl("setup").value == 'kh') {
  8078. if (botPlayer.upgraded == 0) {
  8079. bot.sendUpgrade(3);
  8080. } else if (botPlayer.upgraded == 1) {
  8081. bot.sendUpgrade(17);
  8082. } else if (botPlayer.upgraded == 2) {
  8083. bot.sendUpgrade(31);
  8084. } else if (botPlayer.upgraded == 3) {
  8085. bot.sendUpgrade(27);
  8086. } else if (botPlayer.upgraded == 4) {
  8087. bot.sendUpgrade(10);
  8088. } else if (botPlayer.upgraded == 5) {
  8089. bot.sendUpgrade(34);
  8090. } else if (botPlayer.upgraded == 6) {
  8091. bot.sendUpgrade(4);
  8092. } else if (botPlayer.upgraded == 7) {
  8093. bot.sendUpgrade(25);
  8094. }
  8095. } else if(getEl("setup").value == 'zd') {
  8096. if (botPlayer.upgraded == 0) {
  8097. bot.sendUpgrade(3);
  8098. } else if (botPlayer.upgraded == 1) {
  8099. bot.sendUpgrade(17);
  8100. } else if (botPlayer.upgraded == 2) {
  8101. bot.sendUpgrade(31);
  8102. } else if (botPlayer.upgraded == 3) {
  8103. bot.sendUpgrade(27);
  8104. } else if (botPlayer.upgraded == 4) {
  8105. bot.sendUpgrade(9);
  8106. } else if (botPlayer.upgraded == 5) {
  8107. bot.sendUpgrade(34);
  8108. } else if (botPlayer.upgraded == 6) {
  8109. bot.sendUpgrade(12);
  8110. } else if (botPlayer.upgraded == 7) {
  8111. bot.sendUpgrade(15);
  8112. }
  8113. }
  8114. botPlayer.upgraded++;
  8115. }
  8116. }
  8117. if (type == "V") {
  8118. let tmpData = data[0];
  8119. let wpn = data[1];
  8120. if (tmpData) {
  8121. if (wpn) botPlayer.weapons = tmpData;
  8122. else botPlayer.items = tmpData;
  8123. }
  8124.  
  8125. }
  8126. if (type == "5") {
  8127. let type = data[0];
  8128. let id = data[1];
  8129. let index = data[2];
  8130. if (index) {
  8131. if (!type)
  8132. botPlayer.tails[id] = 1;
  8133. else
  8134. botPlayer.latestTail = id;
  8135. } else {
  8136. if (!type)
  8137. botPlayer.skins[id] = 1;
  8138. else
  8139. botPlayer.latestSkin = id;
  8140. }
  8141. }
  8142.  
  8143. if (type == "6") {
  8144. let id = data[0];
  8145. let mzg = data[1]+'';
  8146. if(id == player.sid && mzg.includes("syncon")) {
  8147. bot.zync(botPlayer.near);
  8148. }
  8149. }
  8150. };
  8151. bot.onclose = function() {
  8152. botPlayer.inGame = false;
  8153. bD.inGame = false;
  8154. };
  8155. }
  8156.  
  8157. // RENDER LEAF:
  8158. function renderLeaf(x, y, l, r, ctxt) {
  8159. let endX = x + (l * Math.cos(r));
  8160. let endY = y + (l * Math.sin(r));
  8161. let width = l * 0.4;
  8162. ctxt.moveTo(x, y);
  8163. ctxt.beginPath();
  8164. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8165. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8166. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8167. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8168. ctxt.closePath();
  8169. ctxt.fill();
  8170. ctxt.stroke();
  8171. }
  8172.  
  8173. // RENDER CIRCLE:
  8174. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8175. tmpContext = tmpContext || mainContext;
  8176. tmpContext.beginPath();
  8177. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8178. if (!dontFill) tmpContext.fill();
  8179. if (!dontStroke) tmpContext.stroke();
  8180. }
  8181.  
  8182. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8183. tmpContext = tmpContext || mainContext;
  8184. tmpContext.beginPath();
  8185. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8186. if (!dontFill) tmpContext.fill();
  8187. if (!dontStroke) tmpContext.stroke();
  8188. }
  8189.  
  8190. // RENDER STAR SHAPE:
  8191. function renderStar(ctxt, spikes, outer, inner) {
  8192. let rot = Math.PI / 2 * 3;
  8193. let x, y;
  8194. let step = Math.PI / spikes;
  8195. ctxt.beginPath();
  8196. ctxt.moveTo(0, -outer);
  8197. for (let i = 0; i < spikes; i++) {
  8198. x = Math.cos(rot) * outer;
  8199. y = Math.sin(rot) * outer;
  8200. ctxt.lineTo(x, y);
  8201. rot += step;
  8202. x = Math.cos(rot) * inner;
  8203. y = Math.sin(rot) * inner;
  8204. ctxt.lineTo(x, y);
  8205. rot += step;
  8206. }
  8207. ctxt.lineTo(0, -outer);
  8208. ctxt.closePath();
  8209. }
  8210.  
  8211. function renderHealthStar(ctxt, spikes, outer, inner) {
  8212. let rot = Math.PI / 2 * 3;
  8213. let x, y;
  8214. let step = Math.PI / spikes;
  8215. ctxt.beginPath();
  8216. ctxt.moveTo(0, -outer);
  8217. for (let i = 0; i < spikes; i++) {
  8218. x = Math.cos(rot) * outer;
  8219. y = Math.sin(rot) * outer;
  8220. ctxt.lineTo(x, y);
  8221. rot += step;
  8222. x = Math.cos(rot) * inner;
  8223. y = Math.sin(rot) * inner;
  8224. ctxt.lineTo(x, y);
  8225. rot += step;
  8226. }
  8227. ctxt.lineTo(0, -outer);
  8228. ctxt.closePath();
  8229. }
  8230.  
  8231. // RENDER RECTANGLE:
  8232. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8233. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8234. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8235. }
  8236.  
  8237. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8238. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8239. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8240. }
  8241.  
  8242. // RENDER RECTCIRCLE:
  8243. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8244. ctxt.save();
  8245. ctxt.translate(x, y);
  8246. seg = Math.ceil(seg / 2);
  8247. for (let i = 0; i < seg; i++) {
  8248. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8249. ctxt.rotate(Math.PI / seg);
  8250. }
  8251. ctxt.restore();
  8252. }
  8253.  
  8254. // RENDER BLOB:
  8255. function renderBlob(ctxt, spikes, outer, inner) {
  8256. let rot = Math.PI / 2 * 3;
  8257. let x, y;
  8258. let step = Math.PI / spikes;
  8259. let tmpOuter;
  8260. ctxt.beginPath();
  8261. ctxt.moveTo(0, -inner);
  8262. for (let i = 0; i < spikes; i++) {
  8263. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8264. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8265. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8266. rot += step * 2;
  8267. }
  8268. ctxt.lineTo(0, -inner);
  8269. ctxt.closePath();
  8270. }
  8271.  
  8272. // RENDER TRIANGLE:
  8273. function renderTriangle(s, ctx) {
  8274. ctx = ctx || mainContext;
  8275. let h = s * (Math.sqrt(3) / 2);
  8276. ctx.beginPath();
  8277. ctx.moveTo(0, -h / 2);
  8278. ctx.lineTo(-s / 2, h / 2);
  8279. ctx.lineTo(s / 2, h / 2);
  8280. ctx.lineTo(0, -h / 2);
  8281. ctx.fill();
  8282. ctx.closePath();
  8283. }
  8284.  
  8285. // PREPARE MENU BACKGROUND:
  8286. function prepareMenuBackground() {
  8287. // let tmpMid = config.mapScale / 2;
  8288. // let attempts = 0;
  8289. // for (let i = 0; i < items.list.length * 3;) {
  8290. // if (attempts >= 1000) break;
  8291. // attempts++;
  8292. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8293. // let data = {
  8294. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  8295. // y: tmpMid + UTILS.randFloat(-600, 600),
  8296. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8297. // };
  8298. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8299. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8300. // } else {
  8301. // continue;
  8302. // }
  8303. // i++;
  8304. // }
  8305. }
  8306.  
  8307. const speed = 1;
  8308. // RENDER PLAYERS:
  8309. function renderDeadPlayers(xOffset, yOffset) {
  8310. mainContext.fillStyle = "#91b2db";
  8311. const currentTime = Date.now();
  8312. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8313. if (!dead.startTime) {
  8314. dead.startTime = currentTime;
  8315. dead.angle = 0;
  8316. dead.radius = 0.1;
  8317. }
  8318. const timeElapsed = currentTime - dead.startTime;
  8319. const maxAlpha = 1;
  8320. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8321. dead.animate(delta);
  8322. mainContext.globalAlpha = dead.alpha;
  8323. mainContext.strokeStyle = outlineColor;
  8324. mainContext.save();
  8325. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8326. dead.radius -= 0.001;
  8327. dead.angle += 0.0174533;
  8328. const moveSpeed = 1;
  8329. const x = dead.radius * Math.cos(dead.angle);
  8330. const y = dead.radius * Math.sin(dead.angle);
  8331. dead.x += x * moveSpeed;
  8332. dead.y += y * moveSpeed;
  8333. mainContext.rotate(dead.angle);
  8334. renderDeadPlayer(dead, mainContext);
  8335. mainContext.restore();
  8336. mainContext.fillStyle = "#91b2db";
  8337. if (timeElapsed >= 3000) {
  8338. dead.active = false;
  8339. dead.startTime = null;
  8340. }
  8341. });
  8342. }
  8343. // RENDER PLAYERS:
  8344. function renderPlayers(xOffset, yOffset, zIndex) {
  8345. mainContext.globalAlpha = 1;
  8346. mainContext.fillStyle = "#91b2db";
  8347. for (var i = 0; i < players.length; ++i) {
  8348. tmpObj = players[i];
  8349. if (tmpObj.zIndex == zIndex) {
  8350. tmpObj.animate(delta);
  8351. if (tmpObj.visible) {
  8352. tmpObj.skinRot += (0.002 * delta);
  8353. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  8354. mainContext.save();
  8355. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8356. // RENDER PLAYER:
  8357. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8358. renderPlayer(tmpObj, mainContext);
  8359. mainContext.restore();
  8360. }
  8361. }
  8362. }
  8363. }
  8364. // RENDER DEAD PLAYER:
  8365. function renderDeadPlayer(obj, ctxt) {
  8366. ctxt = ctxt || mainContext;
  8367. ctxt.lineWidth = outlineWidth;
  8368. ctxt.lineJoin = "miter";
  8369. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8370. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8371. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8372. // TAIL/CAPE:
  8373. renderTail2(13, ctxt, obj);
  8374. // WEAPON BELLOW HANDS:
  8375. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8376. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8377. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8378. renderProjectile(obj.scale, 0,
  8379. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8380. }
  8381. }
  8382. // HANDS:
  8383. ctxt.fillStyle = "#ececec";
  8384. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8385. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8386. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8387. // WEAPON ABOVE HANDS:
  8388. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8389. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8390. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8391. renderProjectile(obj.scale, 0,
  8392. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8393. }
  8394. }
  8395. // BUILD ITEM:
  8396. if (obj.buildIndex >= 0) {
  8397. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8398. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8399. }
  8400. // BODY:
  8401. renderCircle(0, 0, obj.scale, ctxt);
  8402. // SKIN
  8403. renderSkin2(48, ctxt, null, obj)
  8404. }
  8405.  
  8406. // RENDER PLAYER:
  8407. function renderPlayer(obj, ctxt) {
  8408. ctxt = ctxt || mainContext;
  8409. ctxt.lineWidth = outlineWidth;
  8410. ctxt.lineJoin = "miter";
  8411. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8412. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8413. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8414.  
  8415. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8416.  
  8417. // TAIL/CAPE:
  8418. if (obj.tailIndex > 0) {
  8419. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8420. }
  8421.  
  8422. // WEAPON BELLOW HANDS:
  8423. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8424. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8425. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8426. renderProjectile(obj.scale, 0,
  8427. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8428. }
  8429. }
  8430.  
  8431. // HANDS:
  8432. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8433. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8434. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8435. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8436.  
  8437. // WEAPON ABOVE HANDS:
  8438. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8439. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8440. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8441. renderProjectile(obj.scale, 0,
  8442. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8443. }
  8444. }
  8445.  
  8446. // BUILD ITEM:
  8447. if (obj.buildIndex >= 0) {
  8448. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8449. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8450. }
  8451.  
  8452. // BODY:
  8453. renderCircle(0, 0, obj.scale, ctxt);
  8454.  
  8455. // SKIN:
  8456. if (obj.skinIndex > 0) {
  8457. ctxt.rotate(Math.PI / 2);
  8458. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8459. }
  8460.  
  8461. }
  8462.  
  8463. // RENDER NORMAL SKIN
  8464. var skinSprites2 = {};
  8465. var skinPointers2 = {};
  8466. function renderSkin2(index, ctxt, parentSkin, owner) {
  8467. tmpSkin = skinSprites2[index];
  8468. if (!tmpSkin) {
  8469. var tmpImage = new Image();
  8470. tmpImage.onload = function() {
  8471. this.isLoaded = true;
  8472. this.onload = null;
  8473. };
  8474. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8475. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8476. skinSprites2[index] = tmpImage;
  8477. tmpSkin = tmpImage;
  8478. }
  8479. var tmpObj = parentSkin||skinPointers2[index];
  8480. if (!tmpObj) {
  8481. for (var i = 0; i < hats.length; ++i) {
  8482. if (hats[i].id == index) {
  8483. tmpObj = hats[i];
  8484. break;
  8485. }
  8486. }
  8487. skinPointers2[index] = tmpObj;
  8488. }
  8489. if (tmpSkin.isLoaded)
  8490. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8491. if (!parentSkin && tmpObj.topSprite) {
  8492. ctxt.save();
  8493. ctxt.rotate(owner.skinRot);
  8494. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8495. ctxt.restore();
  8496. }
  8497. }
  8498.  
  8499. // RENDER SKIN:
  8500. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8501. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8502. var tmpImage = new Image();
  8503. tmpImage.onload = function() {
  8504. this.isLoaded = true,
  8505. this.onload = null
  8506. }
  8507. ,
  8508. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8509. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8510. tmpSkin = tmpImage
  8511. }
  8512. var tmpObj = parentSkin||skinPointers[index];
  8513. if (!tmpObj) {
  8514. for (var i = 0; i < hats.length; ++i) {
  8515. if (hats[i].id == index) {
  8516. tmpObj = hats[i];
  8517. break;
  8518. }
  8519. }
  8520. skinPointers[index] = tmpObj;
  8521. }
  8522. if (tmpSkin.isLoaded)
  8523. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8524. if (!parentSkin && tmpObj.topSprite) {
  8525. ctxt.save();
  8526. ctxt.rotate(owner.skinRot);
  8527. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8528. ctxt.restore();
  8529. }
  8530. }
  8531.  
  8532. var FlareZHat = {
  8533. 7: "https://i.imgur.com/vAOzlyY.png",
  8534. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8535. 40: "https://i.imgur.com/Xzmg27N.png",
  8536. 26: "https://i.imgur.com/I0xGtyZ.png",
  8537. 55: "https://i.imgur.com/uYgDtcZ.png",
  8538. 20: "https://i.imgur.com/f5uhWCk.png",
  8539. };
  8540.  
  8541. function setSkinTextureImage(id, type, id2) {
  8542. if (true) {
  8543. if(FlareZHat[id] && type == "hat") {
  8544. return FlareZHat[id];
  8545. } else {
  8546. if(type == "acc") {
  8547. return ".././img/accessories/access_" + id + ".png";
  8548. } else if(type == "hat") {
  8549. return ".././img/hats/hat_" + id + ".png";
  8550. } else {
  8551. return ".././img/weapons/" + id + ".png";
  8552. }
  8553. }
  8554. } else {
  8555. if(type == "acc") {
  8556. return ".././img/accessories/access_" + id + ".png";
  8557. } else if(type == "hat") {
  8558. return ".././img/hats/hat_" + id + ".png";
  8559. } else {
  8560. return ".././img/weapons/" + id + ".png";
  8561. }
  8562. }
  8563. }
  8564. // RENDER SKINS:
  8565. let skinSprites = {};
  8566. let skinPointers = {};
  8567. let tmpSkin;
  8568.  
  8569. function renderSkin(index, ctxt, parentSkin, owner) {
  8570. tmpSkin = skinSprites[index];
  8571. if (!tmpSkin) {
  8572. let tmpImage = new Image();
  8573. tmpImage.onload = function() {
  8574. this.isLoaded = true;
  8575. this.onload = null;
  8576. };
  8577. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8578. skinSprites[index] = tmpImage;
  8579. tmpSkin = tmpImage;
  8580. }
  8581. let tmpObj = parentSkin || skinPointers[index];
  8582. if (!tmpObj) {
  8583. for (let i = 0; i < hats.length; ++i) {
  8584. if (hats[i].id == index) {
  8585. tmpObj = hats[i];
  8586. break;
  8587. }
  8588. }
  8589. skinPointers[index] = tmpObj;
  8590. }
  8591. if (tmpSkin.isLoaded)
  8592. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8593. if (!parentSkin && tmpObj.topSprite) {
  8594. ctxt.save();
  8595. ctxt.rotate(owner.skinRot);
  8596. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8597. ctxt.restore();
  8598. }
  8599. }
  8600.  
  8601. // RENDER TAIL:
  8602. var FlareZAcc = {
  8603. 21: "https://i.imgur.com/4ddZert.png",
  8604. 19: "https://i.imgur.com/sULkUZT.png",
  8605. };
  8606. function setTailTextureImage(id, type, id2) {
  8607. if (true) {
  8608. if(FlareZAcc[id] && type == "acc") {
  8609. return FlareZAcc[id];
  8610. } else {
  8611. if(type == "acc") {
  8612. return ".././img/accessories/access_" + id + ".png";
  8613. } else if(type == "hat") {
  8614. return ".././img/hats/hat_" + id + ".png";
  8615. } else {
  8616. return ".././img/weapons/" + id + ".png";
  8617. }
  8618. }
  8619. } else {
  8620. if(type == "acc") {
  8621. return ".././img/accessories/access_" + id + ".png";
  8622. } else if(type == "hat") {
  8623. return ".././img/hats/hat_" + id + ".png";
  8624. } else {
  8625. return ".././img/weapons/" + id + ".png";
  8626. }
  8627. }
  8628. }
  8629. function renderTailTextureImage(index, ctxt, owner) {
  8630. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  8631. var tmpImage = new Image();
  8632. tmpImage.onload = function() {
  8633. this.isLoaded = true,
  8634. this.onload = null
  8635. }
  8636. ,
  8637. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  8638. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8639. tmpSkin = tmpImage;
  8640. }
  8641. var tmpObj = accessPointers[index];
  8642. if (!tmpObj) {
  8643. for (var i = 0; i < accessories.length; ++i) {
  8644. if (accessories[i].id == index) {
  8645. tmpObj = accessories[i];
  8646. break;
  8647. }
  8648. }
  8649. accessPointers[index] = tmpObj;
  8650. }
  8651. if (tmpSkin.isLoaded) {
  8652. ctxt.save();
  8653. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8654. if (tmpObj.spin)
  8655. ctxt.rotate(owner.skinRot);
  8656. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8657. ctxt.restore();
  8658. }
  8659. }
  8660.  
  8661. let accessSprites = {};
  8662. let accessPointers = {};
  8663. var txt = true;
  8664.  
  8665. function renderTail(index, ctxt, owner) {
  8666. tmpSkin = accessSprites[index];
  8667. if (!tmpSkin) {
  8668. let tmpImage = new Image();
  8669. tmpImage.onload = function() {
  8670. this.isLoaded = true;
  8671. this.onload = null;
  8672. };
  8673. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8674. accessSprites[index] = tmpImage;
  8675. tmpSkin = tmpImage;
  8676. }
  8677. let tmpObj = accessPointers[index];
  8678. if (!tmpObj) {
  8679. for (let i = 0; i < accessories.length; ++i) {
  8680. if (accessories[i].id == index) {
  8681. tmpObj = accessories[i];
  8682. break;
  8683. }
  8684. }
  8685. accessPointers[index] = tmpObj;
  8686. }
  8687. if (tmpSkin.isLoaded) {
  8688. ctxt.save();
  8689. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  8690. if (tmpObj.spin)
  8691. ctxt.rotate(owner.skinRot);
  8692. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  8693. ctxt.restore();
  8694. }
  8695. }
  8696.  
  8697. var accessSprites2 = {};
  8698. var accessPointers2 = {};
  8699. function renderTail2(index, ctxt, owner) {
  8700. tmpSkin = accessSprites2[index];
  8701. if (!tmpSkin) {
  8702. var tmpImage = new Image();
  8703. tmpImage.onload = function() {
  8704. this.isLoaded = true;
  8705. this.onload = null;
  8706. };
  8707. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8708. accessSprites2[index] = tmpImage;
  8709. tmpSkin = tmpImage;
  8710. }
  8711. var tmpObj = accessPointers2[index];
  8712. if (!tmpObj) {
  8713. for (var i = 0; i < accessories.length; ++i) {
  8714. if (accessories[i].id == index) {
  8715. tmpObj = accessories[i];
  8716. break;
  8717. }
  8718. }
  8719. accessPointers2[index] = tmpObj;
  8720. }
  8721. if (tmpSkin.isLoaded) {
  8722. ctxt.save();
  8723. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8724. if (tmpObj.spin)
  8725. ctxt.rotate(owner.skinRot);
  8726. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8727. ctxt.restore();
  8728. }
  8729. }
  8730.  
  8731. // RENDER TOOL:
  8732. let toolSprites = {};
  8733. function renderTool(obj, variant, x, y, ctxt) {
  8734. let tmpSrc = obj.src + (variant || "");
  8735. let tmpSprite = toolSprites[tmpSrc];
  8736. if (!tmpSprite) {
  8737. tmpSprite = new Image();
  8738. tmpSprite.onload = function() {
  8739. this.isLoaded = true;
  8740. }
  8741. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8742. toolSprites[tmpSrc] = tmpSprite;
  8743. }
  8744. if (tmpSprite.isLoaded)
  8745. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  8746. }
  8747.  
  8748. // RENDER PROJECTILES:
  8749. function renderProjectiles(layer, xOffset, yOffset) {
  8750. for (let i = 0; i < projectiles.length; i++) {
  8751. tmpObj = projectiles[i];
  8752. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  8753. tmpObj.update(delta);
  8754. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  8755. mainContext.save();
  8756. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8757. mainContext.rotate(tmpObj.dir);
  8758. renderProjectile(0, 0, tmpObj, mainContext, 1);
  8759. mainContext.restore();
  8760. }
  8761. }
  8762. };
  8763. }
  8764.  
  8765. // RENDER PROJECTILE:
  8766. let projectileSprites = {};//fz iz zexy
  8767.  
  8768. function renderProjectile(x, y, obj, ctxt, debug) {
  8769. if (obj.src) {
  8770. let tmpSrc = items.projectiles[obj.indx].src;
  8771. let tmpSprite = projectileSprites[tmpSrc];
  8772. if (!tmpSprite) {
  8773. tmpSprite = new Image();
  8774. tmpSprite.onload = function() {
  8775. this.isLoaded = true;
  8776. }
  8777. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8778. projectileSprites[tmpSrc] = tmpSprite;
  8779. }
  8780. if (tmpSprite.isLoaded)
  8781. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  8782. } else if (obj.indx == 1) {
  8783. ctxt.fillStyle = "#939393";
  8784. renderCircle(x, y, obj.scale, ctxt);
  8785. }
  8786. }
  8787.  
  8788. // RENDER AI:
  8789. let aiSprites = {};
  8790.  
  8791. function renderAI(obj, ctxt) {
  8792. let tmpIndx = obj.index;
  8793. let tmpSprite = aiSprites[tmpIndx];
  8794. if (!tmpSprite) {
  8795. let tmpImg = new Image();
  8796. tmpImg.onload = function() {
  8797. this.isLoaded = true;
  8798. this.onload = null;
  8799. };
  8800. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  8801. tmpSprite = tmpImg;
  8802. aiSprites[tmpIndx] = tmpSprite;
  8803. }
  8804. if (tmpSprite.isLoaded) {
  8805. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  8806. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  8807. }
  8808. }
  8809.  
  8810. // RENDER WATER BODIES:
  8811. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  8812.  
  8813. // MIDDLE RIVER:
  8814. let tmpW = config.riverWidth + padding;
  8815. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  8816. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  8817. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  8818. }
  8819. }
  8820.  
  8821. // RENDER GAME OBJECTS:
  8822. let gameObjectSprites = {};
  8823.  
  8824. function getResSprite(obj) {
  8825. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  8826. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  8827. let tmpSprite = gameObjectSprites[tmpIndex];
  8828. if (!tmpSprite) {
  8829. let blurScale = 6;
  8830. let tmpCanvas = document.createElement("canvas");
  8831. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  8832. let tmpContext = tmpCanvas.getContext('2d');
  8833. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8834. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  8835. tmpContext.strokeStyle = outlineColor;
  8836. tmpContext.lineWidth = outlineWidth;
  8837. // if (isNight) {
  8838. // tmpContext.shadowBlur = blurScale;
  8839. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  8840. // }
  8841. if (obj.type == 0) {
  8842. let tmpScale;
  8843. let tmpCount = 8;
  8844. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  8845. for (let i = 0; i < 2; ++i) {
  8846. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  8847. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  8848. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  8849. tmpContext.fill();
  8850. if (!i) {
  8851. tmpContext.stroke();
  8852. tmpContext.shadowBlur = null;
  8853. tmpContext.shadowColor = null;
  8854. tmpContext.globalAlpha = 1;
  8855. }
  8856. }
  8857. } else if (obj.type == 1) {
  8858. if (biomeID == 2) {
  8859. tmpContext.fillStyle = "#606060";
  8860. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  8861. tmpContext.fill();
  8862. tmpContext.stroke();
  8863.  
  8864. //tmpContext.shadowBlur = null;
  8865. //tmpContext.shadowColor = null;
  8866.  
  8867. tmpContext.fillStyle = "#89a54c";
  8868. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  8869. tmpContext.fillStyle = "#a5c65b";
  8870. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  8871. } else {
  8872. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  8873. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  8874. tmpContext.fill();
  8875. tmpContext.stroke();
  8876.  
  8877. //tmpContext.shadowBlur = null;
  8878. //tmpContext.shadowColor = null;
  8879.  
  8880. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  8881. let tmpRange;
  8882. let berries = 4;
  8883. let rotVal = (Math.PI * 2) / berries;
  8884. for (let i = 0; i < berries; ++i) {
  8885. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  8886. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8887. UTILS.randInt(10, 12), tmpContext);
  8888. }
  8889. }
  8890. } else if (obj.type == 2 || obj.type == 3) {
  8891. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  8892. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8893. tmpContext.fill();
  8894. tmpContext.stroke();
  8895.  
  8896. tmpContext.shadowBlur = null;
  8897. tmpContext.shadowColor = null;
  8898.  
  8899. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  8900. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8901. tmpContext.fill();
  8902. }
  8903. tmpSprite = tmpCanvas;
  8904. gameObjectSprites[tmpIndex] = tmpSprite;
  8905. }
  8906. return tmpSprite;
  8907. }
  8908.  
  8909. // GET ITEM SPRITE:
  8910. let itemSprites = [];
  8911.  
  8912. function getItemSprite(obj, asIcon) {
  8913. let tmpSprite = itemSprites[obj.id];
  8914. if (!tmpSprite || asIcon) {
  8915. let blurScale = !asIcon ? 20 : 5;
  8916. let tmpCanvas = document.createElement("canvas");
  8917. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  8918. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  8919.  
  8920. let tmpContext = tmpCanvas.getContext("2d");
  8921. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8922. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  8923. tmpContext.strokeStyle = outlineColor;
  8924. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  8925. if (!asIcon) {
  8926. tmpContext.shadowBlur = 8;
  8927. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  8928. }
  8929.  
  8930. if (obj.name == "apple") {
  8931. tmpContext.fillStyle = "#c15555";
  8932. renderCircle(0, 0, obj.scale, tmpContext);
  8933. tmpContext.fillStyle = "#89a54c";
  8934. let leafDir = -(Math.PI / 2);
  8935. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  8936. 25, leafDir + Math.PI / 2, tmpContext);
  8937. } else if (obj.name == "cookie") {
  8938. tmpContext.fillStyle = "#cca861";
  8939. renderCircle(0, 0, obj.scale, tmpContext);
  8940. tmpContext.fillStyle = "#937c4b";
  8941. let chips = 4;
  8942. let rotVal = (Math.PI * 2) / chips;
  8943. let tmpRange;
  8944. for (let i = 0; i < chips; ++i) {
  8945. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8946. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8947. UTILS.randInt(4, 5), tmpContext, true);
  8948. }
  8949. } else if (obj.name == "cheese") {
  8950. tmpContext.fillStyle = "#f4f3ac";
  8951. renderCircle(0, 0, obj.scale, tmpContext);
  8952. tmpContext.fillStyle = "#c3c28b";
  8953. let chips = 4;
  8954. let rotVal = (Math.PI * 2) / chips;
  8955. let tmpRange;
  8956. for (let i = 0; i < chips; ++i) {
  8957. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8958. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8959. UTILS.randInt(4, 5), tmpContext, true);
  8960. }
  8961. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  8962. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  8963. "#a5974c" : "#939393";
  8964. let sides = (obj.name == "castle wall") ? 4 : 3;
  8965. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  8966. tmpContext.fill();
  8967. tmpContext.stroke();
  8968. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  8969. "#c9b758" : "#bcbcbc";
  8970. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  8971. tmpContext.fill();
  8972. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  8973. obj.name == "spinning spikes") {
  8974. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#72B2F4" : "#939393";
  8975. let tmpScale = (obj.scale * 0.6);
  8976. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  8977. tmpContext.fill();
  8978. tmpContext.stroke();
  8979. tmpContext.fillStyle = "#72B2F4";
  8980. renderCircle(0, 0, tmpScale, tmpContext);
  8981. tmpContext.fillStyle = "#72B2F4";
  8982. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8983. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8984. tmpContext.fillStyle = "#a5974c";
  8985. renderCircle(0, 0, reScale, tmpContext);
  8986. tmpContext.fillStyle = "#c9b758";
  8987. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  8988. tmpContext.fillStyle = "#a5974c";
  8989. renderCircle(0, 0, reScale * 0.5, tmpContext);
  8990. } else if (obj.name == "mine") {
  8991. tmpContext.fillStyle = "#939393";
  8992. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8993. tmpContext.fill();
  8994. tmpContext.stroke();
  8995. tmpContext.fillStyle = "#bcbcbc";
  8996. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8997. tmpContext.fill();
  8998. } else if (obj.name == "sapling") {
  8999. for (let i = 0; i < 2; ++i) {
  9000. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9001. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9002. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9003. tmpContext.fill();
  9004. if (!i) tmpContext.stroke();
  9005. }
  9006. } else if (obj.name == "pit trap") {
  9007. tmpContext.fillStyle = "#e06666";
  9008. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9009. tmpContext.fill();
  9010. tmpContext.stroke();
  9011. tmpContext.fillStyle = outlineColor;
  9012. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9013. tmpContext.fill();
  9014. } else if (obj.name == "boost pad") {
  9015. tmpContext.fillStyle = "#7e7f82";
  9016. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9017. tmpContext.fill();
  9018. tmpContext.stroke();
  9019. tmpContext.fillStyle = "#dbd97d";
  9020. renderTriangle(obj.scale * 1, tmpContext);
  9021. } else if (obj.name == "turret") {
  9022. tmpContext.fillStyle = "#a5974c";
  9023. renderCircle(0, 0, obj.scale, tmpContext);
  9024. tmpContext.fill();
  9025. tmpContext.stroke();
  9026. tmpContext.fillStyle = "#939393";
  9027. let tmpLen = 50;
  9028. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9029. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9030. tmpContext.fill();
  9031. tmpContext.stroke();
  9032. } else if (obj.name == "platform") {
  9033. tmpContext.fillStyle = "#cebd5f";
  9034. let tmpCount = 4;
  9035. let tmpS = obj.scale * 2;
  9036. let tmpW = tmpS / tmpCount;
  9037. let tmpX = -(obj.scale / 2);
  9038. for (let i = 0; i < tmpCount; ++i) {
  9039. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9040. tmpContext.fill();
  9041. tmpContext.stroke();
  9042. tmpX += tmpS / tmpCount;
  9043. }
  9044. } else if (obj.name == "healing pad") {
  9045. tmpContext.fillStyle = "#7e7f82";
  9046. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9047. tmpContext.fill();
  9048. tmpContext.stroke();
  9049. tmpContext.fillStyle = "#db6e6e";
  9050. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9051. } else if (obj.name == "spawn pad") {
  9052. tmpContext.fillStyle = "#7e7f82";
  9053. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9054. tmpContext.fill();
  9055. tmpContext.stroke();
  9056. tmpContext.fillStyle = "#71aad6";
  9057. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9058. } else if (obj.name == "blocker") {
  9059. tmpContext.fillStyle = "#7e7f82";
  9060. renderCircle(0, 0, obj.scale, tmpContext);
  9061. tmpContext.fill();
  9062. tmpContext.stroke();
  9063. tmpContext.rotate(Math.PI / 4);
  9064. tmpContext.fillStyle = "#db6e6e";
  9065. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9066. } else if (obj.name == "teleporter") {
  9067. tmpContext.fillStyle = "#7e7f82";
  9068. renderCircle(0, 0, obj.scale, tmpContext);
  9069. tmpContext.fill();
  9070. tmpContext.stroke();
  9071. tmpContext.rotate(Math.PI / 4);
  9072. tmpContext.fillStyle = "#d76edb";
  9073. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9074. }
  9075. tmpSprite = tmpCanvas;
  9076. if (!asIcon)
  9077. itemSprites[obj.id] = tmpSprite;
  9078. }
  9079. return tmpSprite;
  9080. }
  9081.  
  9082. function getItemSprite2(obj, tmpX, tmpY) {
  9083. let tmpContext = mainContext;
  9084. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9085. tmpContext.save();
  9086. tmpContext.translate(tmpX, tmpY);
  9087. tmpContext.rotate(obj.dir);
  9088. tmpContext.strokeStyle = outlineColor;
  9089. tmpContext.lineWidth = outlineWidth;
  9090. if (obj.name == "apple") {
  9091. tmpContext.fillStyle = "#c15555";
  9092. renderCircle(0, 0, obj.scale, tmpContext);
  9093. tmpContext.fillStyle = "#89a54c";
  9094. let leafDir = -(Math.PI / 2);
  9095. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9096. 25, leafDir + Math.PI / 2, tmpContext);
  9097. } else if (obj.name == "cookie") {
  9098. tmpContext.fillStyle = "#cca861";
  9099. renderCircle(0, 0, obj.scale, tmpContext);
  9100. tmpContext.fillStyle = "#937c4b";
  9101. let chips = 4;
  9102. let rotVal = (Math.PI * 2) / chips;
  9103. let tmpRange;
  9104. for (let i = 0; i < chips; ++i) {
  9105. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9106. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9107. UTILS.randInt(4, 5), tmpContext, true);
  9108. }
  9109. } else if (obj.name == "cheese") {
  9110. tmpContext.fillStyle = "#f4f3ac";
  9111. renderCircle(0, 0, obj.scale, tmpContext);
  9112. tmpContext.fillStyle = "#c3c28b";
  9113. let chips = 4;
  9114. let rotVal = (Math.PI * 2) / chips;
  9115. let tmpRange;
  9116. for (let i = 0; i < chips; ++i) {
  9117. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9118. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9119. UTILS.randInt(4, 5), tmpContext, true);
  9120. }
  9121. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9122. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9123. "#a5974c" : "#939393";
  9124. let sides = (obj.name == "castle wall") ? 4 : 3;
  9125. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9126. tmpContext.fill();
  9127. tmpContext.stroke();
  9128. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9129. "#c9b758" : "#bcbcbc";
  9130. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9131. tmpContext.fill();
  9132. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9133. obj.name == "spinning spikes") {
  9134. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#72b2f4" : "#845320";
  9135. let tmpScale = (obj.scale * 0.6);
  9136. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9137. tmpContext.fill();
  9138. tmpContext.stroke();
  9139. tmpContext.fillStyle = "#72b2f4";
  9140. renderCircle(0, 0, tmpScale, tmpContext);
  9141. tmpContext.fillStyle = "#72b2f4";
  9142. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9143. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9144. tmpContext.fillStyle = "#a5974c";
  9145. renderCircle(0, 0, reScale, tmpContext);
  9146. tmpContext.fillStyle = "#c9b758";
  9147. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9148. tmpContext.fillStyle = "#a5974c";
  9149. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9150. } else if (obj.name == "mine") {
  9151. tmpContext.fillStyle = "#939393";
  9152. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9153. tmpContext.fill();
  9154. tmpContext.stroke();
  9155. tmpContext.fillStyle = "#bcbcbc";
  9156. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9157. tmpContext.fill();
  9158. } else if (obj.name == "sapling") {
  9159. for (let i = 0; i < 2; ++i) {
  9160. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9161. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9162. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9163. tmpContext.fill();
  9164. if (!i) tmpContext.stroke();
  9165. }
  9166. } else if (obj.name == "pit trap") {
  9167. tmpContext.fillStyle = "#72b2f4";
  9168. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9169. tmpContext.fill();
  9170. tmpContext.stroke();
  9171. tmpContext.fillStyle = outlineColor;
  9172. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9173. tmpContext.fill();
  9174. } else if (obj.name == "boost pad") {
  9175. tmpContext.fillStyle = "#7e7f82";
  9176. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9177. tmpContext.fill();
  9178. tmpContext.stroke();
  9179. tmpContext.fillStyle = "#dbd97d";
  9180. renderTriangle(obj.scale * 1, tmpContext);
  9181. } else if (obj.name == "turret") {
  9182. tmpContext.fillStyle = "#a5974c";
  9183. renderCircle(0, 0, obj.scale, tmpContext);
  9184. tmpContext.fill();
  9185. tmpContext.stroke();
  9186. tmpContext.fillStyle = "#939393";
  9187. let tmpLen = 50;
  9188. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9189. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9190. tmpContext.fill();
  9191. tmpContext.stroke();
  9192. } else if (obj.name == "platform") {
  9193. tmpContext.fillStyle = "#cebd5f";
  9194. let tmpCount = 4;
  9195. let tmpS = obj.scale * 2;
  9196. let tmpW = tmpS / tmpCount;
  9197. let tmpX = -(obj.scale / 2);
  9198. for (let i = 0; i < tmpCount; ++i) {
  9199. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9200. tmpContext.fill();
  9201. tmpContext.stroke();
  9202. tmpX += tmpS / tmpCount;
  9203. }
  9204. } else if (obj.name == "healing pad") {
  9205. tmpContext.fillStyle = "#7e7f82";
  9206. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9207. tmpContext.fill();
  9208. tmpContext.stroke();
  9209. tmpContext.fillStyle = "#db6e6e";
  9210. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9211. } else if (obj.name == "spawn pad") {
  9212. tmpContext.fillStyle = "#7e7f82";
  9213. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9214. tmpContext.fill();
  9215. tmpContext.stroke();
  9216. tmpContext.fillStyle = "#71aad6";
  9217. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9218. } else if (obj.name == "blocker") {
  9219. tmpContext.fillStyle = "#7e7f82";
  9220. renderCircle(0, 0, obj.scale, tmpContext);
  9221. tmpContext.fill();
  9222. tmpContext.stroke();
  9223. tmpContext.rotate(Math.PI / 4);
  9224. tmpContext.fillStyle = "#db6e6e";
  9225. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9226. } else if (obj.name == "teleporter") {
  9227. tmpContext.fillStyle = "#7e7f82";
  9228. renderCircle(0, 0, obj.scale, tmpContext);
  9229. tmpContext.fill();
  9230. tmpContext.stroke();
  9231. tmpContext.rotate(Math.PI / 4);
  9232. tmpContext.fillStyle = "#d76edb";
  9233. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9234. }
  9235. tmpContext.restore();
  9236. }
  9237.  
  9238. let objSprites = [];
  9239.  
  9240. function getObjSprite(obj) {
  9241. let tmpSprite = objSprites[obj.id];
  9242. if (!tmpSprite) {
  9243. // let blurScale = isNight ? 20 : 0;
  9244. let tmpCanvas = document.createElement("canvas");
  9245. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  9246. let tmpContext = tmpCanvas.getContext("2d");
  9247. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9248. tmpContext.rotate(Math.PI / 2);
  9249. tmpContext.strokeStyle = outlineColor;
  9250. tmpContext.lineWidth = outlineWidth;
  9251. // if (isNight) {
  9252. // tmpContext.shadowBlur = 20;
  9253. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9254. // }
  9255. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9256. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#2986cc";
  9257. let tmpScale = obj.scale * 0.6;
  9258. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9259. tmpContext.fill();
  9260. tmpContext.stroke();
  9261. tmpContext.fillStyle = "#f44336";
  9262. renderCircle(0, 0, tmpScale, tmpContext);
  9263. tmpContext.fillStyle = "#3d85c6";
  9264. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9265. } else if (obj.name == "pit trap") {
  9266. tmpContext.fillStyle = "#f44336";
  9267. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9268. tmpContext.fill();
  9269. tmpContext.stroke();
  9270. tmpContext.fillStyle = "#45818e";
  9271. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9272. tmpContext.fill();
  9273. }
  9274. tmpSprite = tmpCanvas;
  9275. objSprites[obj.id] = tmpSprite;
  9276. }
  9277. return tmpSprite;
  9278. }
  9279.  
  9280. // GET MARK SPRITE:
  9281. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9282. let center = {
  9283. x: screenWidth / 2,
  9284. y: screenHeight / 2,
  9285. };
  9286. tmpContext.lineWidth = outlineWidth;
  9287. mainContext.globalAlpha = 0.2;
  9288. tmpContext.strokeStyle = outlineColor;
  9289. tmpContext.save();
  9290. tmpContext.translate(tmpX, tmpY);
  9291. tmpContext.rotate(90**10);
  9292. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9293. tmpContext.fillStyle = (obj.name == "poison spikes")?"#a0d2db":"#6fa8dc";
  9294. var tmpScale = (obj.scale);
  9295. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9296. tmpContext.fill();
  9297. tmpContext.stroke();
  9298. tmpContext.fillStyle = "#6fa8dc";
  9299. renderCircle(0, 0, tmpScale, tmpContext);
  9300. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9301. tmpContext.fillStyle = "#a34040";
  9302. } else {
  9303. tmpContext.fillStyle = "#9fc5e8";
  9304. }
  9305. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9306. } else if (obj.name == "turret") {
  9307. renderCircle(0, 0, obj.scale, tmpContext);
  9308. tmpContext.fill();
  9309. tmpContext.stroke();
  9310. tmpContext.fillStyle = "#939393";
  9311. let tmpLen = 50;
  9312. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9313. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9314. tmpContext.fill();
  9315. tmpContext.stroke();
  9316. } else if (obj.name == "teleporter") {
  9317. tmpContext.fillStyle = "#7e7f82";
  9318. renderCircle(0, 0, obj.scale, tmpContext);
  9319. tmpContext.fill();
  9320. tmpContext.stroke();
  9321. tmpContext.rotate(Math.PI / 4);
  9322. tmpContext.fillStyle = "#d76edb";
  9323. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9324. } else if (obj.name == "platform") {
  9325. tmpContext.fillStyle = "#cebd5f";
  9326. let tmpCount = 4;
  9327. let tmpS = obj.scale * 2;
  9328. let tmpW = tmpS / tmpCount;
  9329. let tmpX = -(obj.scale / 2);
  9330. for (let i = 0; i < tmpCount; ++i) {
  9331. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9332. tmpContext.fill();
  9333. tmpContext.stroke();
  9334. tmpX += tmpS / tmpCount;
  9335. }
  9336. } else if (obj.name == "healing pad") {
  9337. tmpContext.fillStyle = "#7e7f82";
  9338. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9339. tmpContext.fill();
  9340. tmpContext.stroke();
  9341. tmpContext.fillStyle = "#db6e6e";
  9342. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9343. } else if (obj.name == "spawn pad") {
  9344. tmpContext.fillStyle = "#7e7f82";
  9345. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9346. tmpContext.fill();
  9347. tmpContext.stroke();
  9348. tmpContext.fillStyle = "#71aad6";
  9349. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9350. } else if (obj.name == "blocker") {
  9351. tmpContext.fillStyle = "#7e7f82";
  9352. renderCircle(0, 0, obj.scale, tmpContext);
  9353. tmpContext.fill();
  9354. tmpContext.stroke();
  9355. tmpContext.rotate(Math.PI / 4);
  9356. tmpContext.fillStyle = "#db6e6e";
  9357. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9358. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9359. tmpContext.fillStyle = "#a5974c";
  9360. renderCircle(0, 0, obj.scale, tmpContext);
  9361. tmpContext.fillStyle = "#c9b758";
  9362. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9363. tmpContext.fillStyle = "#a5974c";
  9364. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9365.  
  9366. } else if (obj.name == "pit trap") {
  9367. tmpContext.fillStyle = "#a5974c";
  9368. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9369. tmpContext.fill();
  9370. tmpContext.stroke();
  9371. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9372. tmpContext.fillStyle = "#a34040";
  9373. } else {
  9374. tmpContext.fillStyle = outlineColor;
  9375. }
  9376. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9377. tmpContext.fill();
  9378. }
  9379. tmpContext.restore();
  9380. }
  9381.  
  9382. // OBJECT ON SCREEN:
  9383. function isOnScreen(x, y, s) {
  9384. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9385. s,
  9386. maxScreenHeight));
  9387. }
  9388.  
  9389. // RENDER GAME OBJECTS:
  9390. function renderGameObjects(layer, xOffset, yOffset) {
  9391. let tmpSprite;
  9392. let tmpX;
  9393. let tmpY;
  9394. liztobj.forEach((tmp) => {
  9395. tmpObj = tmp;
  9396. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9397. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9398. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9399. if (layer == 0) {
  9400. tmpObj.update(delta);
  9401. }
  9402. mainContext.globalAlpha = tmpObj.alpha;
  9403. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9404. if (tmpObj.isItem) {
  9405. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9406. tmpSprite = getObjSprite(tmpObj);
  9407. } else {
  9408. tmpSprite = getItemSprite(tmpObj);
  9409. }
  9410.  
  9411. mainContext.save();
  9412. mainContext.translate(tmpX, tmpY);
  9413. mainContext.rotate(tmpObj.dir);
  9414. if (!tmpObj.active) {
  9415. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9416. }
  9417. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9418.  
  9419. if (tmpObj.blocker) {
  9420. mainContext.strokeStyle = "#db6e6e";
  9421. mainContext.globalAlpha = 0.3;
  9422. mainContext.lineWidth = 6;
  9423. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9424. }
  9425. mainContext.restore();
  9426. } else {
  9427. tmpSprite = getResSprite(tmpObj);
  9428. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9429. }
  9430. }
  9431. if (layer == 3 && !useWasd) {
  9432. if (tmpObj.health < tmpObj.maxHealth) {
  9433. // HEALTH HOLDER:
  9434. mainContext.fillStyle = darkOutlineColor;
  9435. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9436. mainContext.fill();
  9437.  
  9438. // HEALTH BAR:
  9439. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  9440. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9441. mainContext.fill();
  9442. }
  9443. }
  9444. }
  9445. });
  9446.  
  9447. // PLACE VISIBLE:
  9448. if (layer == 0) {
  9449. if (placeVisible.length) {
  9450. placeVisible.forEach((places) => {
  9451. tmpX = places.x - xOffset;
  9452. tmpY = places.y - yOffset;
  9453. markObject(places, tmpX, tmpY);
  9454. });
  9455. }
  9456. }
  9457. }
  9458.  
  9459. function markObject(tmpObj, tmpX, tmpY) {
  9460. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9461. }
  9462.  
  9463. // RENDER MINIMAP:
  9464. class MapPing {
  9465. constructor(color, scale) {
  9466. this.init = function(x, y) {
  9467. this.scale = 0;
  9468. this.x = x;
  9469. this.y = y;
  9470. this.active = true;
  9471. };
  9472. this.update = function(ctxt, delta) {
  9473. if (this.active) {
  9474. this.scale += 0.05 * delta;
  9475. if (this.scale >= scale) {
  9476. this.active = false;
  9477. } else {
  9478. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9479. ctxt.beginPath();
  9480. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9481. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9482. ctxt.stroke();
  9483. }
  9484. }
  9485. };
  9486. this.color = color;
  9487. }
  9488. }
  9489.  
  9490. function pingMap(x, y) {
  9491. tmpPing = mapPings.find(pings => !pings.active);
  9492. if (!tmpPing) {
  9493. tmpPing = new MapPing("#fff", config.mapPingScale);
  9494. mapPings.push(tmpPing);
  9495. }
  9496. tmpPing.init(x, y);
  9497. }
  9498.  
  9499. function updateMapMarker() {
  9500. mapMarker.x = player.x;
  9501. mapMarker.y = player.y;
  9502. }
  9503.  
  9504. function renderMinimap(delta) {
  9505. if (player && player.alive) {
  9506. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9507.  
  9508. // RENDER PINGS:
  9509. mapContext.lineWidth = 4;
  9510. for (let i = 0; i < mapPings.length; ++i) {
  9511. tmpPing = mapPings[i];
  9512. mapContext.strokeStyle = tmpPing.color;
  9513. tmpPing.update(mapContext, delta);
  9514. }
  9515.  
  9516. // RENDER BREAK TRACKS:
  9517. mapContext.globalAlpha = 1;
  9518. mapContext.fillStyle = "#ff0000";
  9519. if (breakTrackers.length) {
  9520. mapContext.fillStyle = "#abcdef";
  9521. mapContext.font = "34px Hammersmith One";
  9522. mapContext.textBaseline = "middle";
  9523. mapContext.textAlign = "center";
  9524. for (let i = 0; i < breakTrackers.length;) {
  9525. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9526. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9527. i += 2;
  9528. }
  9529. }
  9530.  
  9531. // RENDER PLAYERS:
  9532. mapContext.globalAlpha = 1;
  9533. mapContext.fillStyle = "#fff";
  9534. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9535. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9536. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9537. if (player.team && minimapData) {
  9538. for (let i = 0; i < minimapData.length;) {
  9539. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9540. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9541. i += 2;
  9542. }
  9543. }
  9544.  
  9545. // RENDER BOTS:
  9546. if (bots.length) {
  9547. bots.forEach((tmp) => {
  9548. if (tmp.inGame) {
  9549. mapContext.globalAlpha = 1;
  9550. mapContext.strokeStyle = "#cc5151";
  9551. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9552. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9553. }
  9554. });
  9555. }
  9556.  
  9557. // DEATH LOCATION:
  9558. if (lastDeath) {
  9559. mapContext.fillStyle = "#fc5553";
  9560. mapContext.font = "34px Hammersmith One";
  9561. mapContext.textBaseline = "middle";
  9562. mapContext.textAlign = "center";
  9563. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9564. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9565. }
  9566.  
  9567. // MAP MARKER:
  9568. if (mapMarker) {
  9569. mapContext.fillStyle = "#fff";
  9570. mapContext.font = "34px Hammersmith One";
  9571. mapContext.textBaseline = "middle";
  9572. mapContext.textAlign = "center";
  9573. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9574. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9575. }
  9576. }
  9577. }
  9578.  
  9579. // ICONS:
  9580. let crossHairs = ["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/newawwddd.png", "https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100px-Crosshairs_Red.png"];
  9581. let crossHairSprites = {};
  9582. let iconSprites = {};
  9583. let icons = ["crown", "skull"];
  9584.  
  9585. function loadIcons() {
  9586. for (let i = 0; i < icons.length; ++i) {
  9587. let tmpSprite = new Image();
  9588. tmpSprite.onload = function() {
  9589. this.isLoaded = true;
  9590. };
  9591. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9592. iconSprites[icons[i]] = tmpSprite;
  9593. }
  9594. for (let i = 0; i < crossHairs.length; ++i) {
  9595. let tmpSprite = new Image();
  9596. tmpSprite.onload = function() {
  9597. this.isLoaded = true;
  9598. };
  9599. tmpSprite.src = crossHairs[i];
  9600. crossHairSprites[i] = tmpSprite;
  9601. }
  9602. }
  9603. loadIcons();
  9604.  
  9605. function cdf (e, t){
  9606. try {
  9607. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9608. } catch(e){
  9609. return Infinity;
  9610. }
  9611. }
  9612.  
  9613. // UPDATE GAME:
  9614. function updateGame() {
  9615. if(gameObjects.length && inGame) {
  9616. gameObjects.forEach((tmp) => {
  9617. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  9618. if(!liztobj.includes(tmp)) {
  9619. liztobj.push(tmp);
  9620. tmp.render = true;
  9621. }
  9622. } else {
  9623. if(liztobj.includes(tmp)) {
  9624. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9625. tmp.render = false;
  9626. const index = liztobj.indexOf(tmp);
  9627. if (index > -1) { // only splice array when item is found
  9628. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9629. }
  9630. }
  9631. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9632. tmp.render = false;
  9633. const index = liztobj.indexOf(tmp);
  9634. if (index > -1) { // only splice array when item is found
  9635. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9636. }
  9637. } else {
  9638. tmp.render = false;
  9639. const index = liztobj.indexOf(tmp);
  9640. if (index > -1) { // only splice array when item is found
  9641. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9642. }
  9643. }
  9644. }
  9645. })
  9646. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  9647. }
  9648.  
  9649. // if (config.resetRender) {
  9650. mainContext.beginPath();
  9651. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  9652. // }
  9653. mainContext.globalAlpha = 1;
  9654.  
  9655. // MOVE CAMERA:
  9656. if (player) {
  9657. if (false) {
  9658. camX = player.x;
  9659. camY = player.y;
  9660. } else {
  9661. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  9662. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  9663. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  9664. if (tmpDist > 0.05) {
  9665. camX += camSpd * Math.cos(tmpDir);
  9666. camY += camSpd * Math.sin(tmpDir);
  9667. } else {
  9668. camX = player.x;
  9669. camY = player.y;
  9670. }
  9671. }
  9672. } else {
  9673. camX = config.mapScale / 2 + config.riverWidth;
  9674. camY = config.mapScale / 2;
  9675. }
  9676.  
  9677. // INTERPOLATE PLAYERS AND AI:
  9678. let lastTime = now - (1000 / config.serverUpdateRate);
  9679. let tmpDiff;
  9680. for (let i = 0; i < players.length + ais.length; ++i) {
  9681. tmpObj = players[i] || ais[i - players.length];
  9682. if (tmpObj && tmpObj.visible) {
  9683. if (tmpObj.forcePos) {
  9684. tmpObj.x = tmpObj.x2;
  9685. tmpObj.y = tmpObj.y2;
  9686. tmpObj.dir = tmpObj.d2;
  9687. } else {
  9688. let total = tmpObj.t2 - tmpObj.t1;
  9689. let fraction = lastTime - tmpObj.t1;
  9690. let ratio = (fraction / total);
  9691. let rate = 170;
  9692. tmpObj.dt += delta;
  9693. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  9694. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  9695. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  9696. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  9697. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  9698. if (config.anotherVisual) {
  9699. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9700. } else {
  9701. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9702. }
  9703. }
  9704. }
  9705. }
  9706.  
  9707. // RENDER CORDS:
  9708. let xOffset = camX - (maxScreenWidth / 2);
  9709. let yOffset = camY - (maxScreenHeight / 2);
  9710.  
  9711. // RENDER BACKGROUND:
  9712. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9713. mainContext.fillStyle = "#b6db66";
  9714. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9715. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  9716. mainContext.fillStyle = "#dbc666";
  9717. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9718. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9719. mainContext.fillStyle = "#fff";
  9720. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9721. } else if (config.snowBiomeTop - yOffset >= 0) {
  9722. mainContext.fillStyle = "#fff";
  9723. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  9724. mainContext.fillStyle = "#b6db66";
  9725. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  9726. maxScreenHeight - (config.snowBiomeTop - yOffset));
  9727. } else {
  9728. mainContext.fillStyle = "#b6db66";
  9729. mainContext.fillRect(0, 0, maxScreenWidth,
  9730. (config.mapScale - config.snowBiomeTop - yOffset));
  9731. mainContext.fillStyle = "#dbc666";
  9732. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  9733. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  9734. }
  9735.  
  9736. // RENDER WATER AREAS:
  9737. if (!firstSetup) {
  9738. waterMult += waterPlus * config.waveSpeed * delta;
  9739. if (waterMult >= config.waveMax) {
  9740. waterMult = config.waveMax;
  9741. waterPlus = -1;
  9742. } else if (waterMult <= 1) {
  9743. waterMult = waterPlus = 1;
  9744. }
  9745. mainContext.globalAlpha = 1;
  9746. mainContext.fillStyle = "#dbc666";
  9747. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  9748. mainContext.fillStyle = "#91b2db";
  9749. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  9750. }
  9751.  
  9752. // RENDER DEAD PLAYERS:
  9753. mainContext.globalAlpha = 1;
  9754. mainContext.strokeStyle = outlineColor;
  9755. renderDeadPlayers(xOffset, yOffset);
  9756.  
  9757. // RENDER BOTTOM LAYER:
  9758. mainContext.globalAlpha = 1;
  9759. mainContext.strokeStyle = outlineColor;
  9760. renderGameObjects(-1, xOffset, yOffset);
  9761.  
  9762. // RENDER PROJECTILES:
  9763. mainContext.globalAlpha = 1;
  9764. mainContext.lineWidth = outlineWidth;
  9765. renderProjectiles(0, xOffset, yOffset);
  9766.  
  9767. // RENDER PLAYERS:
  9768. renderPlayers(xOffset, yOffset, 0);
  9769.  
  9770. // RENDER AI:
  9771. mainContext.globalAlpha = 1;
  9772. for (let i = 0; i < ais.length; ++i) {
  9773. tmpObj = ais[i];
  9774. if (tmpObj.active && tmpObj.visible) {
  9775. tmpObj.animate(delta);
  9776. mainContext.save();
  9777. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9778. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  9779. renderAI(tmpObj, mainContext);
  9780. mainContext.restore();
  9781. }
  9782. }
  9783.  
  9784. // RENDER GAME OBJECTS (LAYERED):
  9785. renderGameObjects(0, xOffset, yOffset);
  9786. renderProjectiles(1, xOffset, yOffset);
  9787. renderGameObjects(1, xOffset, yOffset);
  9788. renderPlayers(xOffset, yOffset, 1);
  9789. renderGameObjects(2, xOffset, yOffset);
  9790. renderGameObjects(3, xOffset, yOffset);
  9791.  
  9792. // MAP BOUNDARIES:
  9793. mainContext.fillStyle = "#000";
  9794. mainContext.globalAlpha = 0.09;
  9795. if (xOffset <= 0) {
  9796. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  9797. }
  9798. if (config.mapScale - xOffset <= maxScreenWidth) {
  9799. let tmpY = Math.max(0, -yOffset);
  9800. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  9801. }
  9802. if (yOffset <= 0) {
  9803. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  9804. }
  9805. if (config.mapScale - yOffset <= maxScreenHeight) {
  9806. let tmpX = Math.max(0, -xOffset);
  9807. let tmpMin = 0;
  9808. if (config.mapScale - xOffset <= maxScreenWidth)
  9809. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  9810. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  9811. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  9812. }
  9813.  
  9814. // RENDER DAY/NIGHT TIME:
  9815. mainContext.globalAlpha = 1;
  9816. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  9817. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9818.  
  9819. // RENDER PLAYER AND AI UI:
  9820. mainContext.strokeStyle = darkOutlineColor;
  9821. mainContext.globalAlpha = 1;
  9822.  
  9823. for (let i = 0; i < players.length + ais.length; ++i) {
  9824. tmpObj = players[i] || ais[i - players.length];
  9825. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  9826. mainContext.strokeStyle = darkOutlineColor;
  9827.  
  9828. // NAME AND HEALTH:
  9829.  
  9830. // let izbot = false;
  9831.  
  9832. // bots.forEach((bot) => {
  9833. // if (tmpObj.sid == bot.sid) izbot = true
  9834. // else izbot = false;
  9835. // });
  9836.  
  9837. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  9838. if (tmpText != "" && tmpObj.name != "unknown1l") {
  9839. // bots.forEach((bot) => {
  9840. // if (tmpObj.sid == bot.sid) return;
  9841. // });
  9842.  
  9843. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  9844. mainContext.fillStyle = "#fff";
  9845. mainContext.textBaseline = "middle";
  9846. mainContext.textAlign = "center";
  9847. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  9848. mainContext.lineJoin = "round";
  9849. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9850. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9851. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  9852. let tmpS = config.crownIconScale;
  9853. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  9854. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9855. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9856. }
  9857. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  9858. let tmpS = config.crownIconScale;
  9859. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  9860. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9861. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9862. }
  9863. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length && !useWasd) {
  9864. let tmpS = tmpObj.scale * 2.2;
  9865. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  9866. }
  9867. // izbot = false;
  9868. }
  9869. if (tmpObj.health > 0) {
  9870.  
  9871. if(tmpObj.name != "unknown1l") {
  9872. // HEALTH HOLDER:
  9873. mainContext.fillStyle = darkOutlineColor;
  9874. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  9875. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  9876. (config.healthBarPad * 2), 17, 8);
  9877. mainContext.fill();
  9878.  
  9879. // HEALTH BAR:
  9880. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  9881. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  9882. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  9883. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  9884. mainContext.fill();
  9885. }
  9886.  
  9887. if (tmpObj.isPlayer) {
  9888. mainContext.globalAlpha = 1;
  9889. let targetReloads = {
  9890. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  9891. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  9892. turret: (2500 - tmpObj.reloads[53]) / 2500
  9893. };
  9894. if (!tmpObj.currentReloads) {
  9895. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  9896. primary: targetReloads.primary,
  9897. secondary: targetReloads.secondary,
  9898. turret: targetReloads.turret
  9899. };
  9900. }
  9901. const lerpFactor = 0.3;
  9902. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  9903. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  9904. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  9905.  
  9906. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  9907. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  9908. const centerX = tmpObj.x - xOffset;
  9909. const centerY = tmpObj.y - yOffset;
  9910. const barRadius = 35;
  9911. const barWidth = 15;
  9912. const totalAngle = (Math.PI*2)/3; // Half circle
  9913. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  9914. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  9915. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  9916. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  9917.  
  9918. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  9919. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  9920. function returncoolcolor(RainbowCycle) {
  9921. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  9922. }
  9923.  
  9924. mainContext.save();
  9925. if (tmpObj.currentReloads.primary < 0.999) {
  9926. mainContext.beginPath();
  9927. mainContext.lineCap = 'round';
  9928. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  9929. mainContext.lineWidth = 4;
  9930. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  9931. mainContext.stroke();
  9932. }
  9933. if (tmpObj.currentReloads.secondary < 0.999) {
  9934. mainContext.beginPath();
  9935. mainContext.lineCap = 'round';
  9936. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  9937. mainContext.lineWidth = 4;
  9938. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  9939. mainContext.stroke();
  9940. }
  9941. if (tmpObj.currentReloads.turret < 0.999) {
  9942. mainContext.beginPath();
  9943. mainContext.lineCap = 'round';
  9944. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  9945. mainContext.lineWidth = 4;
  9946. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  9947. mainContext.stroke();
  9948. }
  9949. mainContext.restore();
  9950.  
  9951. if(tmpObj.name != "unknown1l") {
  9952. // SHAME COUNT:
  9953. mainContext.globalAlpha = 1;
  9954. mainContext.font = "24px Hammersmith One";
  9955. mainContext.fillStyle = "#fff";
  9956. mainContext.strokeStyle = darkOutlineColor;
  9957. mainContext.textBaseline = "middle";
  9958. mainContext.textAlign = "center";
  9959. mainContext.lineWidth = 8;
  9960. mainContext.lineJoin = "round";
  9961. let tmpS = config.crownIconScale;
  9962. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  9963. 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);
  9964. 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);
  9965. }
  9966.  
  9967. // PLAYER TRACER:
  9968. if (!tmpObj.isTeam(player)) {
  9969. let center = {
  9970. x: screenWidth / 2,
  9971. y: screenHeight / 2,
  9972. };
  9973. 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);
  9974. let dist = center.y * alpha / 2;
  9975. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  9976. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  9977. mainContext.save();
  9978. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  9979. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  9980. let by = 255 - (tmpObj.sid * 2);
  9981. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  9982. mainContext.globalAlpha = alpha;
  9983. let renderTracer = function(s, ctx) {
  9984. ctx = ctx || mainContext;
  9985. let h = s * (Math.sqrt(3) / 2);
  9986. ctx.beginPath();
  9987. ctx.moveTo(0, -h / 1.5);
  9988. ctx.lineTo(-s / 2, h / 2);
  9989. ctx.lineTo(s / 2, h / 2);
  9990. ctx.lineTo(0, -h / 1.5);
  9991. ctx.fill();
  9992. ctx.closePath();
  9993. }
  9994. renderTracer(25, mainContext);
  9995. mainContext.restore();
  9996. }
  9997.  
  9998. if (getEl("predictType").value == "pre2") {
  9999. mainContext.lineWidth = 3;
  10000. mainContext.strokeStyle = "#fff";
  10001. mainContext.globalAlpha = 1;
  10002. mainContext.beginPath();
  10003. let render = {
  10004. x: tmpObj.x2 - xOffset,
  10005. y: tmpObj.y2 - yOffset
  10006. };
  10007. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10008. mainContext.lineTo(render.x, render.y);
  10009. mainContext.stroke();
  10010. } else if (getEl("predictType").value == "pre3") {
  10011. mainContext.lineWidth = 3;
  10012. mainContext.strokeStyle = "#cc5151";
  10013. mainContext.globalAlpha = 1;
  10014. mainContext.beginPath();
  10015. let render = {
  10016. x: tmpObj.x3 - xOffset,
  10017. y: tmpObj.y3 - yOffset
  10018. };
  10019. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10020. mainContext.lineTo(render.x, render.y);
  10021. mainContext.stroke();
  10022. }
  10023.  
  10024. }
  10025. }
  10026. }
  10027. }
  10028.  
  10029. if (player) {
  10030.  
  10031. // AUTOPUSH LINE:
  10032. if (my.autoPush && my.pushData) {
  10033. mainContext.lineWidth = 5;
  10034. mainContext.globalAlpha = 1;
  10035. mainContext.beginPath();
  10036. mainContext.strokeStyle = "white";
  10037. var x1 = player.x - xOffset;
  10038. var y1 = player.y - yOffset;
  10039. var x2 = my.pushData.x2 - xOffset;
  10040. var y2 = my.pushData.y2 - yOffset;
  10041. var x3 = my.pushData.x - xOffset;
  10042. var y3 = my.pushData.y - yOffset;
  10043.  
  10044. mainContext.moveTo(x1, y1);
  10045. mainContext.lineTo(x2, y2);
  10046. mainContext.lineTo(x3, y3);
  10047. mainContext.stroke();
  10048.  
  10049. var deltaX = x3 - x1;
  10050. var deltaY = y3 - y1;
  10051. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  10052.  
  10053. var maxDistance = 100;
  10054. var percentage = (distance / maxDistance) * 100;
  10055.  
  10056. percentage = Math.min(100, Math.max(0, percentage));
  10057. let spike;
  10058. mainContext.fillStyle = "white";
  10059. mainContext.strokeStyle = "black";
  10060. mainContext.lineWidth = 5;
  10061. mainContext.font = "30px Hammersmith One";
  10062. 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) {
  10063. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10064. })[0];
  10065. if(nearTrap)
  10066. 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) {
  10067. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10068. })[0];
  10069.  
  10070. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  10071. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  10072.  
  10073. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10074. mainContext.strokeText(near.aim2, xx, yy);
  10075. mainContext.fillText(near.aim2, xx, yy);
  10076. }
  10077. }
  10078.  
  10079. mainContext.globalAlpha = 1;
  10080.  
  10081. // RENDER ANIM TEXTS:
  10082. textManager.update(delta, mainContext, xOffset, yOffset);
  10083.  
  10084. // RENDER CHAT MESSAGES:
  10085. for (let i = 0; i < players.length; ++i) {
  10086. tmpObj = players[i];
  10087. if (tmpObj.visible) {
  10088. if (tmpObj.chatCountdown > 0) {
  10089. tmpObj.chatCountdown -= delta;
  10090. if (tmpObj.chatCountdown <= 0)
  10091. tmpObj.chatCountdown = 0;
  10092. mainContext.font = "32px Hammersmith One";
  10093. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10094. mainContext.textBaseline = "middle";
  10095. mainContext.textAlign = "center";
  10096. let tmpX = tmpObj.x - xOffset;
  10097. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10098. let tmpH = 47;
  10099. let tmpW = tmpSize.width + 17;
  10100. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10101. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10102. mainContext.fill();
  10103. mainContext.fillStyle = "#fff";
  10104. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10105. }
  10106. if (tmpObj.chat.count > 0) {
  10107. if (!useWasd) {
  10108. tmpObj.chat.count -= delta;
  10109. if (tmpObj.chat.count <= 0)
  10110. tmpObj.chat.count = 0;
  10111. mainContext.font = "32px Hammersmith One";
  10112. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10113. mainContext.textBaseline = "middle";
  10114. mainContext.textAlign = "center";
  10115. let tmpX = tmpObj.x - xOffset;
  10116. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10117. let tmpH = 47;
  10118. let tmpW = tmpSize.width + 17;
  10119. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10120. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10121. mainContext.fill();
  10122. mainContext.fillStyle = "#ffffff99";
  10123. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10124. } else {
  10125. tmpObj.chat.count = 0;
  10126. }
  10127. }
  10128. }
  10129. }
  10130.  
  10131. if (allChats.length) {
  10132. allChats.filter(ch => ch.active).forEach((ch) => {
  10133. if (!ch.alive) {
  10134. if (ch.alpha <= 1) {
  10135. ch.alpha += delta / 250;
  10136. if (ch.alpha >= 1) {
  10137. ch.alpha = 1;
  10138. ch.alive = true;
  10139. }
  10140. }
  10141. } else {
  10142. ch.alpha -= delta / 5000;
  10143. if (ch.alpha <= 0) {
  10144. ch.alpha = 0;
  10145. ch.active = false;
  10146. }
  10147. }
  10148. if (ch.active) {
  10149. mainContext.font = "20px Ubuntu";
  10150. let tmpSize = mainContext.measureText(ch.chat);
  10151. mainContext.textBaseline = "middle";
  10152. mainContext.textAlign = "center";
  10153. let tmpX = ch.x - xOffset;
  10154. let tmpY = ch.y - yOffset - 90;
  10155. let tmpH = 40;
  10156. let tmpW = tmpSize.width + 15;
  10157.  
  10158. mainContext.globalAlpha = ch.alpha;
  10159.  
  10160. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10161. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10162. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10163. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  10164.  
  10165. mainContext.lineWidth = 5;
  10166. mainContext.fillStyle = "#ccc";
  10167. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10168.  
  10169. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10170. mainContext.stroke();
  10171. mainContext.fill();
  10172.  
  10173. mainContext.fillStyle = "#fff";
  10174. mainContext.strokeStyle = "#000";
  10175. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10176. mainContext.fillText(ch.chat, tmpX, tmpY);
  10177. ch.y -= delta / 100;
  10178. }
  10179. });
  10180. }
  10181.  
  10182. mainContext.globalAlpha = 1;
  10183.  
  10184. // RENDER MINIMAP:
  10185. renderMinimap(delta);
  10186. }
  10187.  
  10188. // UPDATE & ANIMATE:
  10189. window.requestAnimFrame = function() {
  10190. return null;
  10191. }
  10192. window.rAF = (function() {
  10193. return window.requestAnimationFrame ||
  10194. window.webkitRequestAnimationFrame ||
  10195. window.mozRequestAnimationFrame ||
  10196. function(callback) {
  10197. window.setTimeout(callback, 1000/9);
  10198. };
  10199. })();
  10200.  
  10201. function doUpdate() {
  10202. //rape modulus
  10203. now = performance.now();
  10204. delta = now - lastUpdate;
  10205. lastUpdate = now;
  10206. let timer = performance.now();
  10207. let diff = timer - fpsTimer.last;
  10208. if (diff >= 1000) {
  10209.  
  10210. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10211.  
  10212. fpsTimer.last = timer;
  10213. fpsTimer.time = 0;
  10214. }
  10215. fpsTimer.time++;
  10216.  
  10217. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  10218. getEl("packetStatus").innerHTML = secPacket;
  10219. updateGame();
  10220. rAF(doUpdate);
  10221. ms.avg = Math.round((ms.min+ms.max)/2);
  10222. }
  10223.  
  10224. prepareMenuBackground();
  10225. doUpdate();
  10226.  
  10227. function toggleUseless(boolean) {
  10228. getEl("instaType").disabled = boolean;
  10229. getEl("antiBullType").disabled = boolean;
  10230. getEl("predictType").disabled = boolean;
  10231. }
  10232. toggleUseless(useWasd);
  10233.  
  10234. let changeDays = {};
  10235. window.debug = function() {
  10236. my.waitHit = 0;
  10237. my.autoAim = false;
  10238. instaC.isTrue = false;
  10239. traps.inTrap = false;
  10240. itemSprites = [];
  10241. objSprites = [];
  10242. gameObjectSprites = [];
  10243. };
  10244. window.wasdMode = function() {
  10245. useWasd = !useWasd;
  10246. toggleUseless(useWasd);
  10247. };
  10248. window.startGrind = function() {
  10249. if (getEl("weaponGrind").checked) {
  10250. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10251. checkPlace(player.getItemType(22), i);
  10252. }
  10253. }
  10254. };
  10255. // REMOVED!!! so they cant abuse :)
  10256. let projects = [
  10257. "adorable-eight-guppy",
  10258. "galvanized-bittersweet-windshield"
  10259. ];
  10260. let botIDS = 0;
  10261. window.connectFillBots = function() {
  10262. botSkts = [];
  10263. botIDS = 0;
  10264. for (let i = 0; i < projects.length; i++) {
  10265. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10266. test.binaryType = "arraybuffer";
  10267.  
  10268. test.onopen = function() {
  10269. test.ssend = function(type) {
  10270. let data = Array.prototype.slice.call(arguments, 1);
  10271. let binary = window.msgpack.encode([type, data]);
  10272. test.send(binary);
  10273. };
  10274. for (let i = 0; i < 4; i++) {
  10275. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10276. action: "homepage"
  10277. }).then(function(token) {
  10278. let t = WS.url.split("wss://")[1].split("?")[0];
  10279. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10280. botSkts.push([test]);
  10281. botIDS++;
  10282. });
  10283. }
  10284. };
  10285. test.onmessage = function(message) {
  10286. let data = new Uint8Array(message.data);
  10287. let parsed = window.msgpack.decode(data);
  10288. let type = parsed[0];
  10289. data = parsed[1];
  10290. };
  10291. }
  10292. };
  10293. window.destroyFillBots = function() {
  10294. botSkts.forEach((socket) => {
  10295. socket[0].close();
  10296. });
  10297. botSkts = [];
  10298. };
  10299. window.tryConnectBots = function() {
  10300. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10301. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10302. action: "homepage"
  10303. }).then(function(token) {
  10304. // CONNECT SOCKET:
  10305. botSpawn(token);
  10306. });
  10307. }
  10308. };
  10309. window.destroyBots = function() {
  10310. bots.forEach((botyyyyy) => {
  10311. botyyyyy.closeSocket = true;
  10312. });
  10313. bots = [];
  10314. };
  10315. window.resBuild = function() {
  10316. if (gameObjects.length) {
  10317. gameObjects.forEach((tmp) => {
  10318. tmp.breakObj = false;
  10319. });
  10320. breakObjects = [];
  10321. }
  10322. };
  10323. window.toggleBotsCircle = function() {
  10324. player.circle = !player.circle;
  10325. };
  10326. window.toggleVisual = function() {
  10327. config.anotherVisual = !config.anotherVisual;
  10328. gameObjects.forEach((tmp) => {
  10329. if (tmp.active) {
  10330. tmp.dir = tmp.lastDir;
  10331. }
  10332. });
  10333. };
  10334. window.prepareUI = function(tmpObj) {
  10335. resize();
  10336. // CHAT STUFF:
  10337. var chatBox = document.getElementById("chatBox");
  10338. var chatHolder = document.getElementById("chatHolder");
  10339. var suggestBox = document.createElement("div");
  10340. suggestBox.id = "suggestBox";
  10341.  
  10342. var prevChats = [];
  10343. var prevChatsIndex = 0;
  10344.  
  10345. function toggleChat() {
  10346. if (!usingTouch) {
  10347. if (chatHolder.style.display == "block") {
  10348. if (chatBox.value) {
  10349. sendChat(chatBox.value);
  10350. }
  10351. closeChat();
  10352. } else {
  10353. storeMenu.style.display = "none";
  10354. allianceMenu.style.display = "none";
  10355. chatHolder.style.display = "block";
  10356. chatBox.focus();
  10357. resetMoveDir();
  10358. }
  10359. } else {
  10360. setTimeout(function () {
  10361. var chatMessage = prompt("chat message");
  10362. if (chatMessage) {
  10363. sendChat(chatMessage);
  10364. }
  10365. }, 1);
  10366. }
  10367. chatBox.value = "";
  10368. (() => {
  10369. prevChatsIndex = 0;
  10370. })();
  10371. }
  10372.  
  10373. function closeChat() {
  10374. chatBox.value = "";
  10375. chatHolder.style.display = "none";
  10376. }
  10377.  
  10378. // ACTION BAR:
  10379. UTILS.removeAllChildren(actionBar);
  10380.  
  10381. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10382. (function (i) {
  10383. UTILS.generateElement({
  10384. id: "actionBarItem" + i,
  10385. class: "actionBarItem",
  10386. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10387. onmouseout: function () {
  10388. showItemInfo();
  10389. },
  10390. parent: actionBar
  10391. });
  10392. })(i);
  10393. }
  10394.  
  10395. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10396. (function (i) {
  10397. let tmpCanvas = document.createElement("canvas");
  10398. tmpCanvas.width = tmpCanvas.height = 66;
  10399. let tmpContext = tmpCanvas.getContext("2d");
  10400. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10401. tmpContext.imageSmoothingEnabled = false;
  10402. tmpContext.webkitImageSmoothingEnabled = false;
  10403. tmpContext.mozImageSmoothingEnabled = false;
  10404.  
  10405. if (items.weapons[i]) {
  10406. tmpContext.rotate((Math.PI));
  10407. let tmpSprite = new Image();
  10408. toolSprites[items.weapons[i].src] = tmpSprite;
  10409. tmpSprite.onload = function () {
  10410. this.isLoaded = true;
  10411. let tmpPad = 1 / (this.height / this.width);
  10412. let tmpMlt = (items.weapons[i].iPad || 1);
  10413. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10414. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10415. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10416. tmpContext.globalCompositeOperation = "source-atop";
  10417. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10418. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10419. };
  10420. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10421. let tmpUnit = getEl('actionBarItem' + i);
  10422. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10423. // showItemInfo(items.weapons[i], true);
  10424. // });
  10425. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10426. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10427. });
  10428. UTILS.hookTouchEvents(tmpUnit);
  10429. } else {
  10430. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10431. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10432. tmpContext.globalAlpha = 1;
  10433. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10434. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10435. tmpContext.globalCompositeOperation = "source-atop";
  10436. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10437. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10438. let tmpUnit = getEl('actionBarItem' + i);
  10439. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10440. // showItemInfo(items.list[i - items.weapons.length]);
  10441. // });
  10442. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10443. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10444. });
  10445. UTILS.hookTouchEvents(tmpUnit);
  10446. }
  10447. })(i);
  10448. }
  10449. };
  10450. window.profineTest = function(data) {
  10451. if (data) {
  10452. // VALIDATE NAME:
  10453. let name = data + "";
  10454. name = name.slice(0, config.maxNameLength);
  10455.  
  10456. return name;
  10457. }
  10458. };
  10459.  
  10460. 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, " ")