IADO Skidded Mod

I literally just stole Chimken Mod cuz I could. Lol

当前为 2024-09-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IADO Skidded Mod
  3. // @version V1.123456
  4. // @author IAmDaOne
  5. // @description I literally just stole Chimken Mod cuz I could. Lol
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @icon https://th.bing.com/th/id/OIP.hS7NpdTI-AQFguwmFsrauwHaHa?rs=1&pid=ImgDetMain
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://greasyfork.org/en/users/1362611
  12. // ==/UserScript==
  13.  
  14. // Game-Ground 2 xD
  15. document.getElementById('gameName').innerHTML = '';
  16. setTimeout(() => {
  17. document.getElementById('gameName').innerHTML = 'C';
  18. setTimeout(() => {
  19. document.getElementById('gameName').innerHTML = 'Ch';
  20. setTimeout(() => {
  21. document.getElementById('gameName').innerHTML = 'Chim';
  22. setTimeout(() => {
  23. document.getElementById('gameName').innerHTML = 'Chimk';
  24. setTimeout(() => {
  25. document.getElementById('gameName').innerHTML = 'Chimke';
  26. setTimeout(() => {
  27. document.getElementById('gameName').innerHTML = 'Chimken';
  28. setTimeout(() => {
  29. document.getElementById('gameName').innerHTML = 'Chimken Mo';
  30. setTimeout(() => {
  31. document.getElementById('gameName').innerHTML = 'Chimken Mod';
  32. setTimeout(() => {
  33. document.getElementById('gameName').innerHTML = ':) Just kidding';
  34. setTimeout(() => {
  35. document.getElementById('gameName').innerHTML = 'Get pranked';
  36. setTimeout(() => {
  37. document.getElementById('gameName').innerHTML = 'IADO Mod :)';
  38. }, 1200);
  39. }, 1200);
  40. }, 1200);
  41. }, 120);
  42. }, 120);
  43. }, 120);
  44. }, 120);
  45. }, 120);
  46. }, 120);
  47. }, 120);
  48. }, 120);
  49.  
  50.  
  51. document.getElementById("mainMenu").style.backgroundPosition = "center";
  52. document.getElementById("mainMenu").style.width = "100%";
  53. document.getElementById("mainMenu").style.height = "100vh";
  54. document.getElementById("gameName").style.textShadow = "#000000 -2px -2px 10px, black 0px -5px 1px, white 0px -5px 10px";
  55. document.getElementById("loadingText").innerText="";
  56.  
  57. // Test Auto Reply
  58. let founda = false;
  59. let scriptTags = document.getElementsByTagName("script");
  60. for (let i = 0; i < scriptTags.length; i++) {
  61. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  62. scriptTags[i].remove();
  63. founda = true;
  64. break;
  65. }
  66. }
  67.  
  68. var styleItem = document.createElement("style");
  69. styleItem.type = "text/css";
  70. styleItem.appendChild(document.createTextNode(`
  71. #suggestBox {
  72. width: 355px;
  73. border-radius: 3px;
  74. background-color: rgba(0,0,0,0.5);
  75. margin: auto;
  76. text-align: left;
  77. z-index: 49;
  78. pointer-events: auto;
  79. position: relative;
  80. bottom: 3.5px;
  81. overflow-y: auto;
  82. }
  83. #suggestBox div {
  84. background-color: rgba(255,255,255,0);
  85. color: rgba(255,255,255,1);
  86. transition: background-color 0.3s, color 0.3s;
  87. }
  88. #suggestBox div:hover {
  89. background-color: rgba(255,255,255,0.2);
  90. color: rgba(0,0,0,1);
  91. }
  92. .suggestBoxHard {
  93. color: rgba(255,255,255,1);
  94. font-size: 18px;
  95. }
  96. .suggestBoxLight {
  97. color: rgba(255,255,255,0.7);
  98. font-size: 18px;
  99. }
  100. `));
  101. document.head.appendChild(styleItem);
  102.  
  103. window.addEventListener('load', function() {
  104. var allianceButton = document.getElementById('allianceButton');
  105. var storeButton = document.getElementById('storeButton');
  106. if (storeButton) {
  107. storeButton.style.right = '26px';
  108. storeButton.style.top = '420px';
  109. }
  110. if (allianceButton) {
  111. allianceButton.style.right = '26px';
  112. allianceButton.style.top = '479px';
  113. }
  114. });
  115.  
  116. function getEl(id) {
  117. return document.getElementById(id);
  118. }
  119.  
  120. !function(run) {
  121.  
  122. let newFont = document.createElement("link");
  123. newFont.rel = "stylesheet";
  124. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  125. newFont.type = "text/css";
  126. document.body.append(newFont);
  127.  
  128. let min = document.createElement("script");
  129. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  130. document.body.append(min);
  131. window.oncontextmenu = function() {
  132. return false;
  133. };
  134.  
  135. let config = window.config;
  136.  
  137. // CLIENT:
  138. config.clientSendRate = 9; // Aim Packet Send Rate
  139. config.serverUpdateRate = 9;
  140.  
  141. // UI:
  142. config.deathFadeout = 0;
  143.  
  144. config.playerCapacity = 9999;
  145.  
  146. // CHECK IN SANDBOX:
  147. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  148.  
  149. // CUSTOMIZATION:
  150. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  151. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  152. "#8bc373", "#91b2db"
  153. ];
  154. config.weaponVariants = [{
  155. id: 0,
  156. src: "",
  157. xp: 0,
  158. val: 1,
  159. }, {
  160. id: 1,
  161. src: "_g",
  162. xp: 3000,
  163. val: 1.1,
  164. }, {
  165. id: 2,
  166. src: "_d",
  167. xp: 7000,
  168. val: 1.18,
  169. }, {
  170. id: 3,
  171. src: "_r",
  172. poison: true,
  173. xp: 12000,
  174. val: 1.18,
  175. }, {
  176. id: 4,
  177. src: "_e",
  178. poison: true,
  179. heal: true,
  180. xp: 24000,
  181. val: 1.18,
  182. }];
  183.  
  184. // VISUAL:
  185. config.anotherVisual = true;
  186. config.useWebGl = false;
  187. config.resetRender = true;
  188.  
  189. function waitTime(timeout) {
  190. return new Promise((done) => {
  191. setTimeout(() => {
  192. done();
  193. }, timeout);
  194. });
  195. }
  196.  
  197. let botSkts = [];
  198.  
  199. // STORAGE:
  200. let canStore;
  201. if (typeof(Storage) !== "undefined") {
  202. canStore = true;
  203. }
  204.  
  205. function saveVal(name, val) {
  206. if (canStore)
  207. localStorage.setItem(name, val);
  208. }
  209.  
  210. function deleteVal(name) {
  211. if (canStore)
  212. localStorage.removeItem(name);
  213. }
  214.  
  215. function getSavedVal(name) {
  216. if (canStore)
  217. return localStorage.getItem(name);
  218. return null;
  219. }
  220.  
  221. // CONFIGS:
  222. let gC = function(a, b) {
  223. try {
  224. let res = JSON.parse(getSavedVal(a));
  225. if (typeof res === "object") {
  226. return b;
  227. } else {
  228. return res;
  229. }
  230. } catch (e) {
  231. alert("dieskid");
  232. return b;
  233. }
  234. };
  235.  
  236. function setCommands() {
  237. return {
  238. "help": {
  239. desc: "Show Commands",
  240. action: function(message) {
  241. for (let cmds in commands) {
  242. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  243. }
  244. }
  245. },
  246. "clear": {
  247. desc: "Clear Chats",
  248. action: function(message) {
  249. resetMenuChText();
  250. }
  251. },
  252. "debug": {
  253. desc: "Debug Mod For Development",
  254. action: function(message) {
  255. addDeadPlayer(player);
  256. addMenuChText("Debug", "Done", "#99ee99", 1);
  257. }
  258. },
  259. "play": {
  260. desc: "Play Music ( /play [link] )",
  261. action: function(message) {
  262. let link = message.split(" ");
  263. if (link[1]) {
  264. let audio = new Audio(link[1]);
  265. audio.play();
  266. } else {
  267. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  268. }
  269. }
  270. },
  271. "bye": {
  272. desc: "Leave Game",
  273. action: function(message) {
  274. window.leave();
  275. }
  276. },
  277. };
  278. }
  279.  
  280. function setConfigs() {
  281. return {
  282. killChat: true,
  283. alwaysRev: true,
  284. autoBuy: true,
  285. autoBuyEquip: true,
  286. autoPush: true,
  287. revTick: true,
  288. spikeTick: true,
  289. predictTick: true,
  290. autoPlace: true,
  291. autoReplace: true,
  292. antiTrap: true,
  293. slowOT: false,
  294. attackDir: false,
  295. showDir: false,
  296. noDir: false,
  297. autoRespawn: false
  298. };
  299. };
  300. let commands = setCommands();
  301. let configs = setConfigs();
  302. window.removeConfigs = function() {
  303. for (let cF in configs) {
  304. deleteVal(cF, configs[cF]);
  305. }
  306. };
  307.  
  308. for (let cF in configs) {
  309. configs[cF] = gC(cF, configs[cF]);
  310. }
  311.  
  312. // MENU FUNCTIONS:
  313. window.changeMenu = function() {};
  314. window.debug = function() {};
  315. window.wasdMode = function() {};
  316.  
  317. // PAGE 1:
  318. window.startGrind = function() {};
  319.  
  320. // PAGE 3:
  321. window.connectFillBots = function() {};
  322. window.destroyFillBots = function() {};
  323. window.tryConnectBots = function() {};
  324. window.destroyBots = function() {};
  325. window.resBuild = function() {};
  326. window.toggleBotsCircle = function() {};
  327. window.toggleVisual = function() {};
  328.  
  329. // SOME FUNCTIONS:
  330. window.prepareUI = function() {};
  331. window.leave = function() {};
  332.  
  333. // nah hahahahahhh why good ping
  334. window.ping = 0;
  335.  
  336. class deadfuturechickenmodrevival {
  337. constructor(flarez, lore) {
  338. this.inGame = false;
  339. this.lover = flarez + lore;
  340. this.baby = "ae86";
  341. this.isBlack = 0;
  342. this.webSocket = undefined;
  343. this.checkBaby = function() {
  344. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  345. if (this.isBlack >= 1) return "bl4cky";
  346. return "noting for you";
  347. };
  348. this.x2 = 0;
  349. this.y2 = 0;
  350. this.chat = "Imagine playing this badass game XDDDDD";
  351. this.summon = function(tmpObj) {
  352. this.x2 = tmpObj.x;
  353. this.y2 = tmpObj.y;
  354. this.chat = tmpObj.name + " ur so bad XDDDD";
  355. };
  356. this.commands = function(cmd) {
  357. cmd == "rv3link" && window.open("https://florr.io/");
  358. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  359. return cmd;
  360. };
  361. this.dayte = "11yearold";
  362. this.memeganoob = "69yearold";
  363. this.startDayteSpawn = function(tmpObj) {
  364. let ratio = setInterval(() => {
  365. this.x2 = tmpObj.x + 20;
  366. this.y2 = tmpObj.y - 20;
  367. this.chat = "UR SO BAD LOL";
  368. if (tmpObj.name == "ae86") {
  369. this.chat = "omg ae86 go run";
  370. setTimeout(() => {
  371. this.inGame = false;
  372. clearInterval(ratio);
  373. }, 1000);
  374. }
  375. }, 1234);
  376. };
  377. this.AntiChickenModV69420 = function(tmpObj) {
  378. return "!c!dc user " + tmpObj.name;
  379. };
  380. }
  381. };
  382. class HtmlAction {
  383. constructor(element) {
  384. this.element = element;
  385. };
  386. add(code) {
  387. if (!this.element) return undefined;
  388. this.element.innerHTML += code;
  389. };
  390. newLine(amount) {
  391. let result = `<br>`;
  392. if (amount > 0) {
  393. result = ``;
  394. for (let i = 0; i < amount; i++) {
  395. result += `<br>`;
  396. }
  397. }
  398. this.add(result);
  399. };
  400. checkBox(setting) {
  401. let newCheck = `<input type = "checkbox"`;
  402. setting.id && (newCheck += ` id = ${setting.id}`);
  403. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  404. setting.class && (newCheck += ` class = ${setting.class}`);
  405. setting.checked && (newCheck += ` checked`);
  406. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  407. newCheck += `>`;
  408. this.add(newCheck);
  409. };
  410. text(setting) {
  411. let newText = `<input type = "text"`;
  412. setting.id && (newText += ` id = ${setting.id}`);
  413. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  414. setting.class && (newText += ` class = ${setting.class}`);
  415. setting.size && (newText += ` size = ${setting.size}`);
  416. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  417. setting.value && (newText += ` value = ${setting.value}`);
  418. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  419. newText += `>`;
  420. this.add(newText);
  421. };
  422. select(setting) {
  423. let newSelect = `<select`;
  424. setting.id && (newSelect += ` id = ${setting.id}`);
  425. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  426. setting.class && (newSelect += ` class = ${setting.class}`);
  427. newSelect += `>`;
  428. for (let options in setting.option) {
  429. newSelect += `<option value = ${setting.option[options].id}`
  430. setting.option[options].selected && (newSelect += ` selected`);
  431. newSelect += `>${options}</option>`;
  432. }
  433. newSelect += `</select>`;
  434. this.add(newSelect);
  435. };
  436. button(setting) {
  437. let newButton = `<button`;
  438. setting.id && (newButton += ` id = ${setting.id}`);
  439. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  440. setting.class && (newButton += ` class = ${setting.class}`);
  441. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  442. newButton += `>`;
  443. setting.innerHTML && (newButton += setting.innerHTML);
  444. newButton += `</button>`;
  445. this.add(newButton);
  446. };
  447. selectMenu(setting) {
  448. let newSelect = `<select`;
  449. if (!setting.id) {
  450. alert("please put id skid");
  451. return;
  452. }
  453. window[setting.id + "Func"] = function() {};
  454. setting.id && (newSelect += ` id = ${setting.id}`);
  455. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  456. setting.class && (newSelect += ` class = ${setting.class}`);
  457. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  458. newSelect += `>`;
  459. let last;
  460. let i = 0;
  461. for (let options in setting.menu) {
  462. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  463. setting.menu[options] && (newSelect += ` checked`);
  464. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  465. i++;
  466. }
  467. newSelect += `</select>`;
  468.  
  469. this.add(newSelect);
  470.  
  471. i = 0;
  472. for (let options in setting.menu) {
  473. window[options + "Func"] = function() {
  474. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  475. saveVal(options, setting.menu[options]);
  476.  
  477. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  478. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  479.  
  480. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  481.  
  482. };
  483. this.checkBox({
  484. id: "check_" + options,
  485. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  486. class: "checkB",
  487. onclick: `window.${options + "Func"}()`,
  488. checked: setting.menu[options]
  489. });
  490. i++;
  491. }
  492.  
  493. last = "check_" + getEl(setting.id).value.split("_")[1];
  494. window[setting.id + "Func"] = function() {
  495. getEl(last).style.display = "none";
  496. last = "check_" + getEl(setting.id).value.split("_")[1];
  497. getEl(last).style.display = "inline-block";
  498.  
  499. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  500.  
  501. };
  502. };
  503. };
  504. class Html {
  505. constructor() {
  506. this.element = null;
  507. this.action = null;
  508. this.divElement = null;
  509. this.startDiv = function(setting, func) {
  510.  
  511. let newDiv = document.createElement("div");
  512. setting.id && (newDiv.id = setting.id);
  513. setting.style && (newDiv.style = setting.style);
  514. setting.class && (newDiv.className = setting.class);
  515. this.element.appendChild(newDiv);
  516. this.divElement = newDiv;
  517.  
  518. let addRes = new HtmlAction(newDiv);
  519. typeof func == "function" && func(addRes);
  520.  
  521. };
  522. this.addDiv = function(setting, func) {
  523.  
  524. let newDiv = document.createElement("div");
  525. setting.id && (newDiv.id = setting.id);
  526. setting.style && (newDiv.style = setting.style);
  527. setting.class && (newDiv.className = setting.class);
  528. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  529. this.divElement = newDiv;
  530.  
  531. let addRes = new HtmlAction(newDiv);
  532. typeof func == "function" && func(addRes);
  533.  
  534. };
  535. };
  536. set(id) {
  537. this.element = getEl(id);
  538. this.action = new HtmlAction(this.element);
  539. };
  540. resetHTML(text) {
  541. if (text) {
  542. this.element.innerHTML = ``;
  543. } else {
  544. this.element.innerHTML = ``;
  545. }
  546. };
  547. setStyle(style) {
  548. this.element.style = style;
  549. };
  550. setCSS(style) {
  551. this.action.add(`<style>` + style + `</style>`);
  552. };
  553. };
  554.  
  555. let HTML = new Html();
  556.  
  557. let menuDiv = document.createElement("div");
  558. menuDiv.id = "menuDiv";
  559. document.body.appendChild(menuDiv);
  560. HTML.set("menuDiv");
  561. HTML.setStyle(`
  562. position: absolute;
  563. left: 20px;
  564. top: 20px;
  565. `);
  566. HTML.resetHTML();
  567. HTML.setCSS(`
  568. .menuClass {
  569. color: #fff;
  570. background-image: url('');
  571. background-size: cover;
  572. background-position: center;
  573. background-repeat: no-repeat;
  574. font-size: 28px;
  575. text-align: center;
  576. padding: 20px;
  577. max-height: 200px;
  578. width: 300px;
  579. background-color: #1f1f1f;
  580. border-radius: 15px;
  581. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  582. transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out, box-shadow 0.3s ease-in-out, filter 0.4s ease-in-out, border-color 0.3s ease-in-out;
  583. overflow: auto;
  584. filter: none;
  585. border: 2px solid transparent; /* Add a border */
  586. }
  587. .menuClass:hover {
  588. border-color: rgb(255,255,255); /* Change border color on hover to RGB red */
  589. }
  590. .menuClass:hover .menuContent {
  591. background-color: #000; /* Change background color of menu content to darker black on hover */
  592. }
  593. .menuContent {
  594. color: #fff;
  595. }
  596. .menuC {
  597. display: none;
  598. font-family: "Hammersmith One", sans-serif;
  599. font-size: 14px;
  600. max-height: 200px;
  601. overflow-y: auto;
  602. }
  603. .menuB {
  604. text-align: center;
  605. background-color: #1f1f1f;
  606. color: #fff;
  607. border-radius: 25px;
  608. border: 2px solid transparent;
  609. cursor: pointer;
  610. overflow-y: auto;
  611. transition: border-color 0.3s ease-in-out;
  612. }
  613. .menuB:hover {
  614. border-color: #fff;
  615. }
  616. .menuB:active {
  617. color: #fff;
  618. background-color: #1f1f1f;
  619. }
  620. .customText {
  621. color: #000;
  622. border-radius: 25px;
  623. border: 2px solid #000;
  624. padding: 12px;
  625. transition: background-color 0.3s ease-in-out;
  626. }
  627. .customText:focus {
  628. background-color: rgba(30, 130, 76, 0.3);
  629. }
  630. .checkB {
  631. position: relative;
  632. top: 2px;
  633. accent-color: #888;
  634. cursor: pointer;
  635. }
  636. .Cselect {
  637. border-radius: 25px;
  638. background-color: #1f1f1f;
  639. color: #fff;
  640. border: 1px solid #000;
  641. }
  642. #menuChanger {
  643. position: absolute;
  644. right: 20px;
  645. top: 20px;
  646. background-color: rgba(0, 0, 0, 0);
  647. color: #fff;
  648. border: none;
  649. cursor: pointer;
  650. transition: color 0.3s ease-in-out;
  651. }
  652. #menuChanger:hover {
  653. color: #000;
  654. }
  655.  
  656. ::-webkit-scrollbar {
  657. width: 0; /* Skryje vertikální scrollbar na WebKit prohlížečích */
  658. }
  659. `);
  660.  
  661. HTML.startDiv({
  662. id: "menuHeadLine",
  663. class: "menuClass"
  664. }, (html) => {
  665. html.add(`IADO Mod Menu`);
  666. html.button({
  667. id: "menuChanger",
  668. class: "material-icons",
  669. innerHTML: `sync`,
  670. onclick: "window.changeMenu()"
  671. });
  672. HTML.addDiv({
  673. id: "menuButtons",
  674. style: "display: block; overflow-y: visible;",
  675. class: "menuC",
  676. appendID: "menuHeadLine"
  677. }, (html) => {
  678. html.button({
  679. class: "menuB",
  680. innerHTML: "This doesn't work",
  681. onclick: "window.debug()"
  682. });
  683. });
  684. HTML.addDiv({
  685. id: "menuMain",
  686. style: "display: block",
  687. class: "menuC",
  688. appendID: "menuHeadLine"
  689. }, (html) => {
  690. html.button({
  691. class: "menuB",
  692. innerHTML: "This doesn't work",
  693. onclick: "window.wasdMode()"
  694. });
  695. html.newLine();
  696. html.add(`Ruby Farm:`);
  697. html.checkBox({
  698. id: "weaponGrind",
  699. class: "checkB",
  700. onclick: "window.startGrind()"
  701. });
  702. html.newLine(2);
  703. HTML.addDiv({
  704. style: "font-size: 20px; color: #99ee99;",
  705. appendID: "menuMain"
  706. }, (html) => {
  707. html.add(`Settings:`);
  708. });
  709. html.add(`Push v4:`);
  710. html.checkBox({
  711. id: "antipush",
  712. class: "checkB",
  713. checked: true
  714. });
  715. html.newLine();
  716. html.add(`Anti heal:`);
  717. html.checkBox({
  718. id: "healingBeta",
  719. class: "checkB",
  720. checked: true
  721. });
  722. html.newLine();
  723. });
  724. HTML.addDiv({
  725. id: "menuConfig",
  726. class: "menuC",
  727. appendID: "menuHeadLine"
  728. }, (html) => {
  729. html.add(`Placement Tick: `);
  730. html.text({
  731. id: "autoPlaceTick",
  732. class: "customText",
  733. value: "1",
  734. size: "2em",
  735. maxLength: "1"
  736. });
  737. html.newLine();
  738. html.add(`Options: `);
  739. html.selectMenu({
  740. id: "configsChanger",
  741. class: "Cselect",
  742. menu: configs
  743. });
  744. html.newLine();
  745. html.add(`AntiBull: `);
  746. html.select({
  747. id: "antiBullType",
  748. class: "Cselect",
  749. option: {
  750. "Disable": {
  751. id: "noab",
  752. selected: true,
  753. },
  754. "When Reloaded": {
  755. id: "abreload",
  756. },
  757. "Always": {
  758. id: "abalway",
  759. }
  760. }
  761. });
  762. });
  763. HTML.addDiv({
  764. id: "menuOther",
  765. class: "menuC",
  766. appendID: "menuHeadLine"
  767. }, (html) => {
  768. html.newLine();
  769. html.add(`Break Objects Range: `);
  770. html.text({
  771. id: "breakRange",
  772. class: "customText",
  773. value: "700",
  774. size: "3em",
  775. maxLength: "4"
  776. });
  777. html.newLine();
  778. html.add(`Render Movement: `);
  779. html.select({
  780. id: "predictType",
  781. class: "Cselect",
  782. option: {
  783. "Disable Render": {
  784. id: "disableRender",
  785. selected: true
  786. },
  787. "X/Y and 2": {
  788. id: "pre2",
  789. },
  790. "X/Y and 3": {
  791. id: "pre3"
  792. }
  793. }
  794. });
  795. html.newLine();
  796. html.add(`Render Placers: `);
  797. html.checkBox({
  798. id: "placeVis",
  799. class: "checkB",
  800. });
  801. html.newLine();
  802. html.button({
  803. class: "menuB",
  804. innerHTML: "This doesn't work",
  805. onclick: "window.toggleVisual()"
  806. });
  807. html.newLine();
  808. });
  809. });
  810. function toFancyTimeFormat(time) {
  811. let minutes = ~~((time % 3600) / 60);
  812. let seconds = ~~time % 60;
  813. if (seconds <= 9) seconds = `0${seconds}`;
  814. return `${minutes}:${seconds}`;
  815. }
  816. const songchat1 = new Audio("https://cdn.discordapp.com/attachments/1175772907931176991/1227645695796969492/Benzz_-_Je_Mappelle_Music_Video_GRM_Daily.mp3?ex=662fc0a6&is=662e6f26&hm=0b1c67270ba28a0298c01b1a3435bcc5e4aac496053bc3e9a73689cef70870bf&");
  817. let isPlaying = false;
  818. let currentPart = '';
  819. function toggleSong() {
  820. if (!isPlaying) {
  821. songchat1.play();
  822. songchat1.ontimeupdate = function(time) {
  823. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  824. if (part && part !== currentPart) {
  825. currentPart = part;
  826. io.send("6", part);
  827. }
  828. };
  829. songchat1.onended = function() {
  830. if (isPlaying) {
  831. songchat1.play();
  832. }
  833. };
  834. isPlaying = true;
  835. } else {
  836. songchat1.pause();
  837. isPlaying = false;
  838. }
  839. }
  840. document.addEventListener("keypress", function(e) {
  841. if (e.key === "C") {
  842. toggleSong();
  843. }
  844. });
  845. let menuChatDiv = document.createElement("div");
  846. menuChatDiv.id = "menuChatDiv";
  847. document.body.appendChild(menuChatDiv);
  848. HTML.set("menuChatDiv");
  849. HTML.setStyle(`
  850. position: absolute;
  851. display: none;
  852. left: 0px;
  853. top: 25px;
  854. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  855. `);
  856. HTML.resetHTML();
  857. HTML.setCSS(`
  858. .chDiv {
  859. color: #fff;
  860. padding: 10px;
  861. width: 357px;
  862. height: 217px;
  863. background-color: rgba(0, 0, 0, 0.2);
  864. font-family: "HammerSmith One", monospace;
  865. // border-radius: 15px;
  866. // box-shadow: black 1px 2px 19px;
  867. //backdrop-filter: blur(3px);
  868.  
  869. }
  870. .chMainDiv {
  871. font-family: "Ubuntu";
  872. font-size: 16px;
  873. max-height: 215px;
  874. overflow-y: scroll;
  875. scrollbar-width: thin;
  876. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  877. -webkit-touch-callout: none;
  878. -webkit-user-select: none;
  879. -khtml-user-select: none;
  880. -moz-user-select: none;
  881. -ms-user-select: none;
  882. user-select: none;
  883. overflow-x: hidden;
  884. }
  885. .chMainDiv::-webkit-scrollbar {
  886. width: 8px;
  887. }
  888. .chMainDiv::-webkit-scrollbar-thumb {
  889. background-color: rgba(0, 0, 0, 0.5);
  890. }
  891. .chMainDiv::-webkit-scrollbar-thumb:hover {
  892. background-color: rgba(0, 0, 0, 0.7);
  893. }
  894. .chMainBox {
  895. display:none;
  896. position: absolute;
  897. left: 10px;
  898. bottom: 10px;
  899. width: 380px;
  900. height: 25px;
  901. background-color: rgba(255, 255, 255, 0.1);
  902. border-radius: 5px;
  903. color: rgba(255, 255, 255, 0.75);
  904. font-family: "HammerSmith One";
  905. font-size: 12px;
  906. }
  907. `);
  908. HTML.startDiv({
  909. id: "mChDiv",
  910. class: "chDiv"
  911. }, (html) => {
  912. HTML.addDiv({
  913. id: "mChMain",
  914. class: "chMainDiv",
  915. appendID: "mChDiv"
  916. }, (html) => {});
  917. html.text({
  918. id: "mChBox",
  919. class: "chMainBox",
  920. // placeHolder: `To chat click here or press "Enter" key`
  921. });
  922. });
  923.  
  924. let menuChats = getEl("mChMain");
  925. let menuChatBox = getEl("mChBox");
  926. let menuCBFocus = false;
  927. let menuChCounts = 0;
  928.  
  929. menuChatBox.value = "";
  930. menuChatBox.addEventListener("focus", () => {
  931. menuCBFocus = true;
  932. });
  933. menuChatBox.addEventListener("blur", () => {
  934. menuCBFocus = false;
  935. });
  936.  
  937. function addMenuChText(name, message, color, noTimer) {
  938. HTML.set("menuChatDiv");
  939. color = color || "white";
  940. let time = new Date();
  941. let min = time.getMinutes();
  942. let hour = time.getHours();
  943. let text = ``;
  944. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  945. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  946. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  947. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  948. html.add(text);
  949. });
  950. menuChats.scrollTop = menuChats.scrollHeight;
  951. menuChCounts++;
  952. }
  953. function chch(name, message, color, noTimer) {
  954. HTML.set("menuChatDiv");
  955. color = color || "white";
  956. let time = new Date();
  957. let text = ``;
  958. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  959. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  960. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  961. html.add(text);
  962. });
  963. menuChats.scrollTop = menuChats.scrollHeight;
  964. menuChCounts++;
  965. }
  966.  
  967. function resetMenuChText() {
  968. menuChats.innerHTML = ``;
  969. menuChCounts = 0;
  970. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  971. }
  972. resetMenuChText();
  973.  
  974. let menuIndex = 0;
  975. let menus = ["menuMain", "menuConfig", "menuOther"];
  976. window.changeMenu = function() {
  977. getEl(menus[menuIndex % menus.length]).style.display = "none";
  978. menuIndex++;
  979. getEl(menus[menuIndex % menus.length]).style.display = "block";
  980. };
  981.  
  982. let mStatus = document.createElement("div");
  983. mStatus.id = "status";
  984. getEl("gameUI").appendChild(mStatus);
  985. HTML.set("status");
  986. HTML.setStyle(`
  987. display: block;
  988. position: absolute;
  989. color: #ddd;
  990. font: 15px HammerSmith One;
  991. bottom: 215px;
  992. left: 20px;
  993. `);
  994. HTML.resetHTML();
  995. HTML.setCSS(`
  996. .sizing {
  997. font-size: 15px;
  998. }
  999. .mod {
  1000. font-size: 15px;
  1001. display: inline-block;
  1002. }
  1003. `);
  1004. HTML.startDiv({
  1005. id: "uehmod",
  1006. class: "sizing"
  1007. }, (html) => {
  1008. html.add(`Ping: `);
  1009. HTML.addDiv({
  1010. id: "pingFps",
  1011. class: "mod",
  1012. appendID: "uehmod"
  1013. }, (html) => {
  1014. html.add("None");
  1015. });
  1016. html.newLine();
  1017. html.add(`Packet: `);
  1018. HTML.addDiv({
  1019. id: "packetStatus",
  1020. class: "mod",
  1021. appendID: "uehmod"
  1022. }, (html) => {
  1023. html.add("None");
  1024. });
  1025. });
  1026.  
  1027. /*function modLog() {
  1028. let logs = [];
  1029. for (let i = 0; i < arguments.length; i++) {
  1030. logs.push(arguments[i]);
  1031. }
  1032. getEl("modLog").innerHTML = logs;
  1033. }*/
  1034.  
  1035. let openMenu = false;
  1036.  
  1037. let WS = undefined;
  1038. let socketID = undefined;
  1039.  
  1040. let useWasd = false;
  1041. let secPacket = 0;
  1042. let secMax = 120;
  1043. let secTime = 1000;
  1044. let firstSend = {
  1045. sec: false
  1046. };
  1047. let game = {
  1048. tick: 0,
  1049. tickQueue: [],
  1050. tickBase: function(set, tick) {
  1051. if (this.tickQueue[this.tick + tick]) {
  1052. this.tickQueue[this.tick + tick].push(set);
  1053. } else {
  1054. this.tickQueue[this.tick + tick] = [set];
  1055. }
  1056. },
  1057. tickRate: (1000 / config.serverUpdateRate),
  1058. tickSpeed: 0,
  1059. lastTick: performance.now()
  1060. };
  1061. let modConsole = [];
  1062.  
  1063. let dontSend = false;
  1064. let fpsTimer = {
  1065. last: 0,
  1066. time: 0,
  1067. ltime: 0
  1068. }
  1069. let lastMoveDir = undefined;
  1070. let lastsp = ["cc", 1, "__proto__"];
  1071.  
  1072. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1073. WebSocket.prototype.send = function(message) {
  1074. if (!WS) {
  1075. WS = this;
  1076. WS.addEventListener("message", function(msg) {
  1077. getMessage(msg);
  1078. });
  1079. WS.addEventListener("close", (event) => {
  1080. if (event.code == 4001) {
  1081. window.location.reload();
  1082. }
  1083. });
  1084. }
  1085. if (WS == this) {
  1086. dontSend = false;
  1087.  
  1088. // EXTRACT DATA ARRAY:
  1089. let data = new Uint8Array(message);
  1090. let parsed = window.msgpack.decode(data);
  1091. let type = parsed[0];
  1092. data = parsed[1];
  1093.  
  1094. // SEND MESSAGE:
  1095. if (type == "6") {
  1096.  
  1097. if (data[0]) {
  1098. // ANTI PROFANITY:
  1099. 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", ];
  1100. let tmpString;
  1101. profanity.forEach((profany) => {
  1102. if (data[0].indexOf(profany) > -1) {
  1103. tmpString = "";
  1104. for (let i = 0; i < profany.length; ++i) {
  1105. if (i == 1) {
  1106. tmpString += String.fromCharCode(0);
  1107. }
  1108. tmpString += profany[i];
  1109. }
  1110. let re = new RegExp(profany, "g");
  1111. data[0] = data[0].replace(re, tmpString);
  1112. }
  1113. });
  1114.  
  1115. // FIX CHAT:
  1116. data[0] = data[0].slice(0, 30);
  1117. }
  1118.  
  1119. } else if (type == "L") {
  1120. // MAKE SAME CLAN:
  1121. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1122. data[0] = data[0].slice(0, 7);
  1123. } else if (type == "M") {
  1124. // APPLY CYAN COLOR:
  1125. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1126. data[0].moofoll = true;
  1127. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1128. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1129. } else if (type == "D") {
  1130. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1131. dontSend = true;
  1132. } else {
  1133. my.lastDir = data[0];
  1134. }
  1135. } else if (type == "d") {
  1136. if (!data[2]) {
  1137. dontSend = true;
  1138. } else {
  1139. if (![null, undefined].includes(data[1])) {
  1140. my.lastDir = data[1];
  1141. }
  1142. }
  1143. } else if (type == "K") {
  1144. if (!data[1]) {
  1145. dontSend = true;
  1146. }
  1147. } else if (type == "S") {
  1148. instaC.wait = !instaC.wait;
  1149. dontSend = true;
  1150. } else if (type == "a") {
  1151. if (data[1]) {
  1152. if (player.moveDir == data[0]) {
  1153. dontSend = true;
  1154. }
  1155. player.moveDir = data[0];
  1156. } else {
  1157. dontSend = true;
  1158. }
  1159. }
  1160. if (!dontSend) {
  1161. let binary = window.msgpack.encode([type, data]);
  1162. this.nsend(binary);
  1163.  
  1164. // START COUNT:
  1165. if (!firstSend.sec) {
  1166. firstSend.sec = true;
  1167. setTimeout(() => {
  1168. firstSend.sec = false;
  1169. secPacket = 0;
  1170. }, secTime);
  1171. }
  1172.  
  1173. secPacket++;
  1174. }
  1175. } else {
  1176. this.nsend(message);
  1177. }
  1178. }
  1179.  
  1180. function packet(type) {
  1181. // EXTRACT DATA ARRAY:
  1182. let data = Array.prototype.slice.call(arguments, 1);
  1183.  
  1184. // SEND MESSAGE:
  1185. let binary = window.msgpack.encode([type, data]);
  1186. WS.send(binary);
  1187. }
  1188.  
  1189. function origPacket(type) {
  1190. // EXTRACT DATA ARRAY:
  1191. let data = Array.prototype.slice.call(arguments, 1);
  1192.  
  1193. // SEND MESSAGE:
  1194. let binary = window.msgpack.encode([type, data]);
  1195. WS.nsend(binary);
  1196. }
  1197.  
  1198. window.leave = function() {
  1199. origPacket("kys", {
  1200. "frvr is so bad": true,
  1201. "sidney is too good": true,
  1202. "dev are too weak": true,
  1203. });
  1204. };
  1205.  
  1206. //...lol
  1207. let io = {
  1208. send: packet
  1209. };
  1210.  
  1211. function getMessage(message) {
  1212. let data = new Uint8Array(message.data);
  1213. let parsed = window.msgpack.decode(data);
  1214. let type = parsed[0];
  1215. data = parsed[1];
  1216. let events = {
  1217. A: setInitData, // id: setInitData,
  1218. //B: disconnect,
  1219. C: setupGame, // 1: setupGame,
  1220. D: addPlayer, // 2: addPlayer,
  1221. E: removePlayer, // 4: removePlayer,
  1222. a: updatePlayers, // 33: updatePlayers,
  1223. G: updateLeaderboard, // 5: updateLeaderboard,here
  1224. H: loadGameObject, // 6: loadGameObject,
  1225. I: loadAI, // a: loadAI,
  1226. J: animateAI, // aa: animateAI,
  1227. K: gatherAnimation, // 7: gatherAnimation,
  1228. L: wiggleGameObject, // 8: wiggleGameObject,
  1229. M: shootTurret, // sp: shootTurret,
  1230. N: updatePlayerValue, // 9: updatePlayerValue,
  1231. O: updateHealth, // h: updateHealth,//here
  1232. P: killPlayer, // 11: killPlayer,
  1233. Q: killObject, // 12: killObject,
  1234. R: killObjects, // 13: killObjects,
  1235. S: updateItemCounts, // 14: updateItemCounts,
  1236. T: updateAge, // 15: updateAge,
  1237. U: updateUpgrades, // 16: updateUpgrades,
  1238. V: updateItems, // 17: updateItems,
  1239. X: addProjectile, // 18: addProjectile,
  1240. Y: remProjectile, // 19: remProjectile,
  1241. //Z: serverShutdownNotice,
  1242. //0: addAlliance,
  1243. //1: deleteAlliance,
  1244. 2: allianceNotification, // an: allianceNotification,
  1245. 3: setPlayerTeam, // st: setPlayerTeam,
  1246. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1247. 5: updateStoreItems, // us: updateStoreItems,
  1248. 6: receiveChat, // ch: receiveChat,
  1249. 7: updateMinimap, // mm: updateMinimap,
  1250. 8: showText, // t: showText,
  1251. 9: pingMap, // p: pingMap,
  1252. 0: pingSocketResponse,
  1253. };
  1254. if (type == "io-init") {
  1255. socketID = data[0];
  1256. } else {
  1257. if (events[type]) {
  1258. events[type].apply(undefined, data);
  1259. }
  1260. }
  1261. }
  1262.  
  1263. // MATHS:
  1264. Math.lerpAngle = function(value1, value2, amount) {
  1265. let difference = Math.abs(value2 - value1);
  1266. if (difference > Math.PI) {
  1267. if (value1 > value2) {
  1268. value2 += Math.PI * 2;
  1269. } else {
  1270. value1 += Math.PI * 2;
  1271. }
  1272. }
  1273. let value = value2 + ((value1 - value2) * amount);
  1274. if (value >= 0 && value <= Math.PI * 2) return value;
  1275. return value % (Math.PI * 2);
  1276. };
  1277.  
  1278. // REOUNDED RECTANGLE:
  1279. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1280. if (w < 2 * r) r = w / 2;
  1281. if (h < 2 * r) r = h / 2;
  1282. if (r < 0)
  1283. r = 0;
  1284. this.beginPath();
  1285. this.moveTo(x + r, y);
  1286. this.arcTo(x + w, y, x + w, y + h, r);
  1287. this.arcTo(x + w, y + h, x, y + h, r);
  1288. this.arcTo(x, y + h, x, y, r);
  1289. this.arcTo(x, y, x + w, y, r);
  1290. this.closePath();
  1291. return this;
  1292. };
  1293.  
  1294. // GLOBAL VALUES:
  1295. function resetMoveDir() {
  1296. keys = {};
  1297. io.send("e");
  1298. }
  1299.  
  1300. let allChats = [];
  1301. let ticks = {
  1302. tick: 0,
  1303. delay: 0,
  1304. time: [],
  1305. manage: [],
  1306. };
  1307. let ais = [];
  1308. let players = [];
  1309. let alliances = [];
  1310. let alliancePlayers = [];
  1311. let allianceNotifications = [];
  1312. let gameObjects = [];
  1313. let liztobj = [];
  1314. let projectiles = [];
  1315. let deadPlayers = [];
  1316.  
  1317. let breakObjects = [];
  1318.  
  1319. let player;
  1320. let playerSID;
  1321. let tmpObj;
  1322.  
  1323. let enemy = [];
  1324. let nears = [];
  1325. let near = [];
  1326.  
  1327. let my = {
  1328. reloaded: false,
  1329. waitHit: 0,
  1330. autoAim: false,
  1331. revAim: false,
  1332. ageInsta: true,
  1333. reSync: false,
  1334. bullTick: 0,
  1335. anti0Tick: 0,
  1336. antiSync: false,
  1337. safePrimary: function(tmpObj) {
  1338. return [0, 8].includes(tmpObj.primaryIndex);
  1339. },
  1340. safeSecondary: function(tmpObj) {
  1341. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1342. },
  1343. lastDir: 0,
  1344. autoPush: false,
  1345. pushData: {}
  1346. }
  1347.  
  1348. // FIND OBJECTS BY ID/SID:
  1349. function findID(tmpObj, tmp) {
  1350. return tmpObj.find((THIS) => THIS.id == tmp);
  1351. }
  1352.  
  1353. function findSID(tmpObj, tmp) {
  1354. return tmpObj.find((THIS) => THIS.sid == tmp);
  1355. }
  1356.  
  1357. function findPlayerByID(id) {
  1358. return findID(players, id);
  1359. }
  1360.  
  1361. function findPlayerBySID(sid) {
  1362. return findSID(players, sid);
  1363. }
  1364.  
  1365. function findAIBySID(sid) {
  1366. return findSID(ais, sid);
  1367. }
  1368.  
  1369. function findObjectBySid(sid) {
  1370. return findSID(gameObjects, sid);
  1371. }
  1372.  
  1373. function findProjectileBySid(sid) {
  1374. return findSID(gameObjects, sid);
  1375. }
  1376.  
  1377. let gameName = getEl("gameName");
  1378. gameName.innerText = "!!";
  1379. let adCard = getEl("adCard");
  1380. adCard.remove();
  1381. let promoImageHolder = getEl("promoImgHolder");
  1382. promoImageHolder.remove();
  1383.  
  1384. let chatButton = getEl("chatButton");
  1385. chatButton.remove();
  1386. let gameCanvas = getEl("gameCanvas");
  1387. let mainContext = gameCanvas.getContext("2d");
  1388. let mapDisplay = getEl("mapDisplay");
  1389. let mapContext = mapDisplay.getContext("2d");
  1390. mapDisplay.width = 300;
  1391. mapDisplay.height = 300;
  1392. let storeMenu = getEl("storeMenu");
  1393. let storeHolder = getEl("storeHolder");
  1394. let upgradeHolder = getEl("upgradeHolder");
  1395. let upgradeCounter = getEl("upgradeCounter");
  1396. let chatBox = getEl("chatBox");
  1397. chatBox.autocomplete = "off";
  1398. chatBox.style.textAlign = "center";
  1399. chatBox.style.width = "18em";
  1400. let chatHolder = getEl("chatHolder");
  1401. let actionBar = getEl("actionBar");
  1402. let leaderboardData = getEl("leaderboardData");
  1403. let itemInfoHolder = getEl("itemInfoHolder");
  1404. let menuCardHolder = getEl("menuCardHolder");
  1405. let mainMenu = getEl("mainMenu");
  1406. getEl("mainMenu").style.backgroundImage = "url('https://giffiles.alphacoders.com/219/219000.gif')"
  1407. let diedText = getEl("diedText");
  1408. let screenWidth;
  1409. let screenHeight;
  1410. let maxScreenWidth = config.maxScreenWidth;
  1411. let maxScreenHeight = config.maxScreenHeight;
  1412. let pixelDensity = 1;
  1413. let delta;
  1414. let now;
  1415. let lastUpdate = performance.now();
  1416. let camX;
  1417. let camY;
  1418. let tmpDir;
  1419. let mouseX = 0;
  1420. let mouseY = 0;
  1421. let allianceMenu = getEl("allianceMenu");
  1422. let waterMult = 1;
  1423. let waterPlus = 0;
  1424.  
  1425. let outlineColor = "#525252";
  1426. let darkOutlineColor = "#3d3f42";
  1427. let outlineWidth = 5.5;
  1428.  
  1429. let firstSetup = true;
  1430. let keys = {};
  1431. let moveKeys = {
  1432. 87: [0, -1],
  1433. 38: [0, -1],
  1434. 83: [0, 1],
  1435. 40: [0, 1],
  1436. 65: [-1, 0],
  1437. 37: [-1, 0],
  1438. 68: [1, 0],
  1439. 39: [1, 0],
  1440. };
  1441. let attackState = 0;
  1442. let inGame = false;
  1443.  
  1444. let macro = {};
  1445. let mills = {
  1446. place: 0,
  1447. placeSpawnPads: 0
  1448. };
  1449. let lastDir;
  1450.  
  1451. let lastLeaderboardData = [];
  1452.  
  1453. // ON LOAD:
  1454. let inWindow = true;
  1455. window.onblur = function() {
  1456. inWindow = false;
  1457. };
  1458. window.onfocus = function() {
  1459. inWindow = true;
  1460. if (player && player.alive) {
  1461. // resetMoveDir();
  1462. }
  1463. };
  1464. let ms = {
  1465. avg: 0,
  1466. max: 0,
  1467. min: 0,
  1468. delay: 0
  1469. }
  1470. function pingSocketResponse() {
  1471. let pingTime = window.pingTime;
  1472. const pingDisplay = document.getElementById("pingDisplay")
  1473. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1474. if (pingTime > ms.max || isNaN(ms.max)) {
  1475. ms.max = pingTime;
  1476. }
  1477. if (pingTime < ms.min || isNaN(ms.min)) {
  1478. ms.min = pingTime;
  1479. }
  1480.  
  1481. // if (pingTime >= 90) {
  1482. // doAutoQ = true;
  1483. // } else {
  1484. // doAutoQ = false;
  1485. // }
  1486. }
  1487.  
  1488. let placeVisible = [];
  1489.  
  1490. /** CLASS CODES */
  1491.  
  1492.  
  1493. class Utils {
  1494. constructor() {
  1495.  
  1496. // MATH UTILS:
  1497. let mathABS = Math.abs,
  1498. mathCOS = Math.cos,
  1499. mathSIN = Math.sin,
  1500. mathPOW = Math.pow,
  1501. mathSQRT = Math.sqrt,
  1502. mathATAN2 = Math.atan2,
  1503. mathPI = Math.PI;
  1504.  
  1505. let _this = this;
  1506.  
  1507. // GLOBAL UTILS:
  1508. this.round = function(n, v) {
  1509. return Math.round(n * v) / v;
  1510. };
  1511. this.toRad = function(angle) {
  1512. return angle * (mathPI / 180);
  1513. };
  1514. this.toAng = function(radian) {
  1515. return radian / (mathPI / 180);
  1516. };
  1517. this.randInt = function(min, max) {
  1518. return Math.floor(Math.random() * (max - min + 1)) + min;
  1519. };
  1520. this.randFloat = function(min, max) {
  1521. return Math.random() * (max - min + 1) + min;
  1522. };
  1523. this.lerp = function(value1, value2, amount) {
  1524. return value1 + (value2 - value1) * amount;
  1525. };
  1526. this.decel = function(val, cel) {
  1527. if (val > 0)
  1528. val = Math.max(0, val - cel);
  1529. else if (val < 0)
  1530. val = Math.min(0, val + cel);
  1531. return val;
  1532. };
  1533. this.getDistance = function(x1, y1, x2, y2) {
  1534. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1535. };
  1536. this.getDist = function(tmp1, tmp2, type1, type2) {
  1537. let tmpXY1 = {
  1538. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1539. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1540. };
  1541. let tmpXY2 = {
  1542. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1543. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1544. };
  1545. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1546. };
  1547. this.getDirection = function(x1, y1, x2, y2) {
  1548. return mathATAN2(y1 - y2, x1 - x2);
  1549. };
  1550. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1551. let tmpXY1 = {
  1552. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1553. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1554. };
  1555. let tmpXY2 = {
  1556. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1557. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1558. };
  1559. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1560. };
  1561. this.getAngleDist = function(a, b) {
  1562. let p = mathABS(b - a) % (mathPI * 2);
  1563. return (p > mathPI ? (mathPI * 2) - p : p);
  1564. };
  1565. this.isNumber = function(n) {
  1566. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1567. };
  1568. this.isString = function(s) {
  1569. return (s && typeof s == "string");
  1570. };
  1571. this.kFormat = function(num) {
  1572. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1573. };
  1574. this.sFormat = function(num) {
  1575. let fixs = [{
  1576. num: 1e3,
  1577. string: "k"
  1578. },
  1579. {
  1580. num: 1e6,
  1581. string: "m"
  1582. },
  1583. {
  1584. num: 1e9,
  1585. string: "b"
  1586. },
  1587. {
  1588. num: 1e12,
  1589. string: "q"
  1590. }
  1591. ].reverse();
  1592. let sp = fixs.find(v => num >= v.num);
  1593. if (!sp) return num;
  1594. return (num / sp.num).toFixed(1) + sp.string;
  1595. };
  1596. this.capitalizeFirst = function(string) {
  1597. return string.charAt(0).toUpperCase() + string.slice(1);
  1598. };
  1599. this.fixTo = function(n, v) {
  1600. return parseFloat(n.toFixed(v));
  1601. };
  1602. this.sortByPoints = function(a, b) {
  1603. return parseFloat(b.points) - parseFloat(a.points);
  1604. };
  1605. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1606. let minX = x1;
  1607. let maxX = x2;
  1608. if (x1 > x2) {
  1609. minX = x2;
  1610. maxX = x1;
  1611. }
  1612. if (maxX > recX2)
  1613. maxX = recX2;
  1614. if (minX < recX)
  1615. minX = recX;
  1616. if (minX > maxX)
  1617. return false;
  1618. let minY = y1;
  1619. let maxY = y2;
  1620. let dx = x2 - x1;
  1621. if (Math.abs(dx) > 0.0000001) {
  1622. let a = (y2 - y1) / dx;
  1623. let b = y1 - a * x1;
  1624. minY = a * minX + b;
  1625. maxY = a * maxX + b;
  1626. }
  1627. if (minY > maxY) {
  1628. let tmp = maxY;
  1629. maxY = minY;
  1630. minY = tmp;
  1631. }
  1632. if (maxY > recY2)
  1633. maxY = recY2;
  1634. if (minY < recY)
  1635. minY = recY;
  1636. if (minY > maxY)
  1637. return false;
  1638. return true;
  1639. };
  1640. this.containsPoint = function(element, x, y) {
  1641. let bounds = element.getBoundingClientRect();
  1642. let left = bounds.left + window.scrollX;
  1643. let top = bounds.top + window.scrollY;
  1644. let width = bounds.width;
  1645. let height = bounds.height;
  1646.  
  1647. let insideHorizontal = x > left && x < left + width;
  1648. let insideVertical = y > top && y < top + height;
  1649. return insideHorizontal && insideVertical;
  1650. };
  1651. this.mousifyTouchEvent = function(event) {
  1652. let touch = event.changedTouches[0];
  1653. event.screenX = touch.screenX;
  1654. event.screenY = touch.screenY;
  1655. event.clientX = touch.clientX;
  1656. event.clientY = touch.clientY;
  1657. event.pageX = touch.pageX;
  1658. event.pageY = touch.pageY;
  1659. };
  1660. this.hookTouchEvents = function(element, skipPrevent) {
  1661. let preventDefault = !skipPrevent;
  1662. let isHovering = false;
  1663. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1664. let passive = false;
  1665. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1666. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1667. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1668. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1669. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1670.  
  1671. function touchStart(e) {
  1672. _this.mousifyTouchEvent(e);
  1673. window.setUsingTouch(true);
  1674. if (preventDefault) {
  1675. e.preventDefault();
  1676. e.stopPropagation();
  1677. }
  1678. if (element.onmouseover)
  1679. element.onmouseover(e);
  1680. isHovering = true;
  1681. }
  1682.  
  1683. function touchMove(e) {
  1684. _this.mousifyTouchEvent(e);
  1685. window.setUsingTouch(true);
  1686. if (preventDefault) {
  1687. e.preventDefault();
  1688. e.stopPropagation();
  1689. }
  1690. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1691. if (!isHovering) {
  1692. if (element.onmouseover)
  1693. element.onmouseover(e);
  1694. isHovering = true;
  1695. }
  1696. } else {
  1697. if (isHovering) {
  1698. if (element.onmouseout)
  1699. element.onmouseout(e);
  1700. isHovering = false;
  1701. }
  1702. }
  1703. }
  1704.  
  1705. function touchEnd(e) {
  1706. _this.mousifyTouchEvent(e);
  1707. window.setUsingTouch(true);
  1708. if (preventDefault) {
  1709. e.preventDefault();
  1710. e.stopPropagation();
  1711. }
  1712. if (isHovering) {
  1713. if (element.onclick)
  1714. element.onclick(e);
  1715. if (element.onmouseout)
  1716. element.onmouseout(e);
  1717. isHovering = false;
  1718. }
  1719. }
  1720. };
  1721. this.removeAllChildren = function(element) {
  1722. while (element.hasChildNodes()) {
  1723. element.removeChild(element.lastChild);
  1724. }
  1725. };
  1726. this.generateElement = function(config) {
  1727. let element = document.createElement(config.tag || "div");
  1728.  
  1729. function bind(configValue, elementValue) {
  1730. if (config[configValue])
  1731. element[elementValue] = config[configValue];
  1732. }
  1733. bind("text", "textContent");
  1734. bind("html", "innerHTML");
  1735. bind("class", "className");
  1736. for (let key in config) {
  1737. switch (key) {
  1738. case "tag":
  1739. case "text":
  1740. case "html":
  1741. case "class":
  1742. case "style":
  1743. case "hookTouch":
  1744. case "parent":
  1745. case "children":
  1746. continue;
  1747. default:
  1748. break;
  1749. }
  1750. element[key] = config[key];
  1751. }
  1752. if (element.onclick)
  1753. element.onclick = this.checkTrusted(element.onclick);
  1754. if (element.onmouseover)
  1755. element.onmouseover = this.checkTrusted(element.onmouseover);
  1756. if (element.onmouseout)
  1757. element.onmouseout = this.checkTrusted(element.onmouseout);
  1758. if (config.style) {
  1759. element.style.cssText = config.style;
  1760. }
  1761. if (config.hookTouch) {
  1762. this.hookTouchEvents(element);
  1763. }
  1764. if (config.parent) {
  1765. config.parent.appendChild(element);
  1766. }
  1767. if (config.children) {
  1768. for (let i = 0; i < config.children.length; i++) {
  1769. element.appendChild(config.children[i]);
  1770. }
  1771. }
  1772. return element;
  1773. };
  1774. this.checkTrusted = function(callback) {
  1775. return function(ev) {
  1776. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1777. callback(ev);
  1778. } else {
  1779. //console.error("Event is not trusted.", ev);
  1780. }
  1781. };
  1782. };
  1783. this.randomString = function(length) {
  1784. let text = "";
  1785. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1786. for (let i = 0; i < length; i++) {
  1787. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1788. }
  1789. return text;
  1790. };
  1791. this.countInArray = function(array, val) {
  1792. let count = 0;
  1793. for (let i = 0; i < array.length; i++) {
  1794. if (array[i] === val) count++;
  1795. }
  1796. return count;
  1797. };
  1798. this.hexToRgb = function(hex) {
  1799. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1800. };
  1801. this.getRgb = function(r, g, b) {
  1802. return [r / 255, g / 255, b / 255].join(", ");
  1803. };
  1804. }
  1805. };
  1806. class Animtext {
  1807. // ANIMATED TEXT:
  1808. constructor() {
  1809. // INIT:
  1810. this.init = function(x, y, scale, speed, life, text, color) {
  1811. (this.x = x),
  1812. (this.y = y),
  1813. (this.color = color),
  1814. (this.scale = scale*3.5),
  1815. (this.weight = 50);
  1816. (this.startScale = this.scale * 1.2),
  1817. (this.maxScale = 1.5 * scale),
  1818. (this.minScale = 0.5 * scale),
  1819. (this.scaleSpeed = 0.7),
  1820. (this.speed = speed),
  1821. (this.speedMax = speed),
  1822. (this.life = life),
  1823. (this.maxLife = life),
  1824. (this.text = text),
  1825. this.movSpeed = speed;
  1826. };
  1827.  
  1828. // UPDATE:
  1829. this.update = function(delta) {
  1830. if(this.life){
  1831. this.life -= delta;
  1832. if(this.scaleSpeed != -0.35){
  1833. this.y -= this.speed * delta;
  1834. // (this.x += this.speed * delta);
  1835. } else {
  1836. this.y -= this.speed * delta;
  1837. }
  1838. this.scale -= .8;
  1839. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  1840. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  1841. if(this.scale >= this.maxScale){
  1842. this.scale = this.maxScale;
  1843. this.scaleSpeed *= -.5;
  1844. this.speed = this.speed * .75;
  1845. };
  1846. this.life <= 0 && (this.life = 0)
  1847. };
  1848. };
  1849.  
  1850. // RENDER:
  1851. this.render = function(ctxt, xOff, yOff) {
  1852. ctxt.lineWidth = 10;
  1853. ctxt.strokeStyle = darkOutlineColor; //"black";
  1854. ctxt.fillStyle = this.color;
  1855. ctxt.globalAlpha = 1;
  1856. ctxt.font = this.scale + "px HammerSmith One";
  1857. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1858. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1859. ctxt.globalAlpha = 1;
  1860. };
  1861. }
  1862. };
  1863. class Textmanager {
  1864. // TEXT MANAGER:
  1865. constructor() {
  1866. this.texts = [];
  1867. this.stack = [];
  1868.  
  1869. // UPDATE:
  1870. this.update = function(delta, ctxt, xOff, yOff) {
  1871. ctxt.textBaseline = "middle";
  1872. ctxt.textAlign = "center";
  1873. for (let i = 0; i < this.texts.length; ++i) {
  1874. if (this.texts[i].life) {
  1875. this.texts[i].update(delta);
  1876. this.texts[i].render(ctxt, xOff, yOff);
  1877. }
  1878. }
  1879. };
  1880.  
  1881. // SHOW TEXT:
  1882. this.showText = function(x, y, scale, speed, life, text, color) {
  1883. let tmpText;
  1884. for (let i = 0; i < this.texts.length; ++i) {
  1885. if (!this.texts[i].life) {
  1886. tmpText = this.texts[i];
  1887. break;
  1888. }
  1889. }
  1890. if (!tmpText) {
  1891. tmpText = new Animtext();
  1892. this.texts.push(tmpText);
  1893. }
  1894. tmpText.init(x, y, scale, speed, life, text, color);
  1895. };
  1896. }
  1897. }
  1898.  
  1899. class GameObject {
  1900. constructor(sid) {
  1901. this.sid = sid;
  1902.  
  1903. // INIT:
  1904. this.init = function(x, y, dir, scale, type, data, owner) {
  1905. data = data || {};
  1906. this.sentTo = {};
  1907. this.gridLocations = [];
  1908. this.active = true;
  1909. this.render = true;
  1910. this.doUpdate = data.doUpdate;
  1911. this.x = x;
  1912. this.y = y;
  1913. this.dir = dir;
  1914. this.lastDir = dir;
  1915. this.xWiggle = 0;
  1916. this.yWiggle = 0;
  1917. this.visScale = scale;
  1918. this.scale = scale;
  1919. this.type = type;
  1920. this.id = data.id;
  1921. this.owner = owner;
  1922. this.name = data.name;
  1923. this.isItem = (this.id != undefined);
  1924. this.group = data.group;
  1925. this.maxHealth = data.health;
  1926. this.health = this.maxHealth;
  1927. this.layer = 2;
  1928. if (this.group != undefined) {
  1929. this.layer = this.group.layer;
  1930. } else if (this.type == 0) {
  1931. this.layer = 3;
  1932. } else if (this.type == 2) {
  1933. this.layer = 0;
  1934. } else if (this.type == 4) {
  1935. this.layer = -1;
  1936. }
  1937. this.colDiv = data.colDiv || 1;
  1938. this.blocker = data.blocker;
  1939. this.ignoreCollision = data.ignoreCollision;
  1940. this.dontGather = data.dontGather;
  1941. this.hideFromEnemy = data.hideFromEnemy;
  1942. this.friction = data.friction;
  1943. this.projDmg = data.projDmg;
  1944. this.dmg = data.dmg;
  1945. this.pDmg = data.pDmg;
  1946. this.pps = data.pps;
  1947. this.zIndex = data.zIndex || 0;
  1948. this.turnSpeed = data.turnSpeed;
  1949. this.req = data.req;
  1950. this.trap = data.trap;
  1951. this.healCol = data.healCol;
  1952. this.teleport = data.teleport;
  1953. this.boostSpeed = data.boostSpeed;
  1954. this.projectile = data.projectile;
  1955. this.shootRange = data.shootRange;
  1956. this.shootRate = data.shootRate;
  1957. this.shootCount = this.shootRate;
  1958. this.spawnPoint = data.spawnPoint;
  1959. this.onNear = 0;
  1960. this.breakObj = false;
  1961. this.alpha = data.alpha || 1;
  1962. this.maxAlpha = data.alpha || 1;
  1963. this.damaged = 0;
  1964. };
  1965.  
  1966. // GET HIT:
  1967. this.changeHealth = function(amount, doer) {
  1968. this.health += amount;
  1969. return (this.health <= 0);
  1970. };
  1971.  
  1972. // GET SCALE:
  1973. this.getScale = function(sM, ig) {
  1974. sM = sM || 1;
  1975. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1976. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1977. };
  1978.  
  1979. // VISIBLE TO PLAYER:
  1980. this.visibleToPlayer = function(player) {
  1981. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1982. (this.owner.team && player.team == this.owner.team)));
  1983. };
  1984.  
  1985. // UPDATE:
  1986. this.update = function(delta) {
  1987. if (this.active) {
  1988. if (this.xWiggle) {
  1989. this.xWiggle *= Math.pow(0.99, delta);
  1990. }
  1991. if (this.yWiggle) {
  1992. this.yWiggle *= Math.pow(0.99, delta);
  1993. }
  1994. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  1995. if (d2 > 0.01) {
  1996. this.dir += d2 / 5;
  1997. } else {
  1998. this.dir = this.lastDir;
  1999. }
  2000. } else {
  2001. if (this.alive) {
  2002. this.alpha -= delta / (200 / this.maxAlpha);
  2003. this.visScale += delta / (this.scale / 2.5);
  2004. if (this.alpha <= 0) {
  2005. this.alpha = 0;
  2006. this.alive = false;
  2007. }
  2008. }
  2009. }
  2010. };
  2011.  
  2012. // CHECK TEAM:
  2013. this.isTeamObject = function(tmpObj) {
  2014. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2015. };
  2016. }
  2017. }
  2018. class Items {
  2019. constructor() {
  2020. // ITEM GROUPS:
  2021. this.groups = [{
  2022. id: 0,
  2023. name: "food",
  2024. layer: 0
  2025. }, {
  2026. id: 1,
  2027. name: "walls",
  2028. place: true,
  2029. limit: 30,
  2030. layer: 0
  2031. }, {
  2032. id: 2,
  2033. name: "spikes",
  2034. place: true,
  2035. limit: 15,
  2036. layer: 0
  2037. }, {
  2038. id: 3,
  2039. name: "mill",
  2040. place: true,
  2041. limit: 7,
  2042. layer: 1
  2043. }, {
  2044. id: 4,
  2045. name: "mine",
  2046. place: true,
  2047. limit: 1,
  2048. layer: 0
  2049. }, {
  2050. id: 5,
  2051. name: "trap",
  2052. place: true,
  2053. limit: 6,
  2054. layer: -1
  2055. }, {
  2056. id: 6,
  2057. name: "booster",
  2058. place: true,
  2059. limit: 12,
  2060. layer: -1
  2061. }, {
  2062. id: 7,
  2063. name: "turret",
  2064. place: true,
  2065. limit: 2,
  2066. layer: 1
  2067. }, {
  2068. id: 8,
  2069. name: "watchtower",
  2070. place: true,
  2071. limit: 12,
  2072. layer: 1
  2073. }, {
  2074. id: 9,
  2075. name: "buff",
  2076. place: true,
  2077. limit: 4,
  2078. layer: -1
  2079. }, {
  2080. id: 10,
  2081. name: "spawn",
  2082. place: true,
  2083. limit: 1,
  2084. layer: -1
  2085. }, {
  2086. id: 11,
  2087. name: "sapling",
  2088. place: true,
  2089. limit: 2,
  2090. layer: 0
  2091. }, {
  2092. id: 12,
  2093. name: "blocker",
  2094. place: true,
  2095. limit: 3,
  2096. layer: -1
  2097. }, {
  2098. id: 13,
  2099. name: "teleporter",
  2100. place: true,
  2101. limit: 2,
  2102. layer: -1
  2103. }];
  2104.  
  2105. // PROJECTILES:
  2106. this.projectiles = [{
  2107. indx: 0,
  2108. layer: 0,
  2109. src: "arrow_1",
  2110. dmg: 25,
  2111. speed: 1.6,
  2112. scale: 103,
  2113. range: 1000
  2114. }, {
  2115. indx: 1,
  2116. layer: 1,
  2117. dmg: 25,
  2118. scale: 20
  2119. }, {
  2120. indx: 0,
  2121. layer: 0,
  2122. src: "arrow_1",
  2123. dmg: 35,
  2124. speed: 2.5,
  2125. scale: 103,
  2126. range: 1200
  2127. }, {
  2128. indx: 0,
  2129. layer: 0,
  2130. src: "arrow_1",
  2131. dmg: 30,
  2132. speed: 2,
  2133. scale: 103,
  2134. range: 1200
  2135. }, {
  2136. indx: 1,
  2137. layer: 1,
  2138. dmg: 16,
  2139. scale: 20
  2140. }, {
  2141. indx: 0,
  2142. layer: 0,
  2143. src: "bullet_1",
  2144. dmg: 50,
  2145. speed: 3.6,
  2146. scale: 160,
  2147. range: 1400
  2148. }];
  2149.  
  2150. // WEAPONS:
  2151. this.weapons = [{
  2152. id: 0,
  2153. type: 0,
  2154. name: "tool hammer",
  2155. desc: "tool for gathering all resources",
  2156. src: "hammer_1",
  2157. length: 140,
  2158. width: 140,
  2159. xOff: -3,
  2160. yOff: 18,
  2161. dmg: 25,
  2162. range: 65,
  2163. gather: 1,
  2164. speed: 300
  2165. }, {
  2166. id: 1,
  2167. type: 0,
  2168. age: 2,
  2169. name: "hand axe",
  2170. desc: "gathers resources at a higher rate",
  2171. src: "axe_1",
  2172. length: 140,
  2173. width: 140,
  2174. xOff: 3,
  2175. yOff: 24,
  2176. dmg: 30,
  2177. spdMult: 1,
  2178. range: 70,
  2179. gather: 2,
  2180. speed: 400
  2181. }, {
  2182. id: 2,
  2183. type: 0,
  2184. age: 8,
  2185. pre: 1,
  2186. name: "great axe",
  2187. desc: "deal more damage and gather more resources",
  2188. src: "great_axe_1",
  2189. length: 140,
  2190. width: 140,
  2191. xOff: -8,
  2192. yOff: 25,
  2193. dmg: 35,
  2194. spdMult: 1,
  2195. range: 75,
  2196. gather: 4,
  2197. speed: 400
  2198. }, {
  2199. id: 3,
  2200. type: 0,
  2201. age: 2,
  2202. name: "short sword",
  2203. desc: "increased attack power but slower move speed",
  2204. src: "sword_1",
  2205. iPad: 1.3,
  2206. length: 130,
  2207. width: 210,
  2208. xOff: -8,
  2209. yOff: 46,
  2210. dmg: 35,
  2211. spdMult: 0.85,
  2212. range: 110,
  2213. gather: 1,
  2214. speed: 300
  2215. }, {
  2216. id: 4,
  2217. type: 0,
  2218. age: 8,
  2219. pre: 3,
  2220. name: "katana",
  2221. desc: "greater range and damage",
  2222. src: "samurai_1",
  2223. iPad: 1.3,
  2224. length: 130,
  2225. width: 210,
  2226. xOff: -8,
  2227. yOff: 59,
  2228. dmg: 40,
  2229. spdMult: 0.8,
  2230. range: 118,
  2231. gather: 1,
  2232. speed: 300
  2233. }, {
  2234. id: 5,
  2235. type: 0,
  2236. age: 2,
  2237. name: "polearm",
  2238. desc: "long range melee weapon",
  2239. src: "spear_1",
  2240. iPad: 1.3,
  2241. length: 130,
  2242. width: 210,
  2243. xOff: -8,
  2244. yOff: 53,
  2245. dmg: 45,
  2246. knock: 0.2,
  2247. spdMult: 0.82,
  2248. range: 142,
  2249. gather: 1,
  2250. speed: 700
  2251. }, {
  2252. id: 6,
  2253. type: 0,
  2254. age: 2,
  2255. name: "bat",
  2256. desc: "fast long range melee weapon",
  2257. src: "bat_1",
  2258. iPad: 1.3,
  2259. length: 110,
  2260. width: 180,
  2261. xOff: -8,
  2262. yOff: 53,
  2263. dmg: 20,
  2264. knock: 0.7,
  2265. range: 110,
  2266. gather: 1,
  2267. speed: 300
  2268. }, {
  2269. id: 7,
  2270. type: 0,
  2271. age: 2,
  2272. name: "daggers",
  2273. desc: "really fast short range weapon",
  2274. src: "dagger_1",
  2275. iPad: 0.8,
  2276. length: 110,
  2277. width: 110,
  2278. xOff: 18,
  2279. yOff: 0,
  2280. dmg: 20,
  2281. knock: 0.1,
  2282. range: 65,
  2283. gather: 1,
  2284. hitSlow: 0.1,
  2285. spdMult: 1.13,
  2286. speed: 100
  2287. }, {
  2288. id: 8,
  2289. type: 0,
  2290. age: 2,
  2291. name: "stick",
  2292. desc: "great for gathering but very weak",
  2293. src: "stick_1",
  2294. length: 140,
  2295. width: 140,
  2296. xOff: 3,
  2297. yOff: 24,
  2298. dmg: 1,
  2299. spdMult: 1,
  2300. range: 70,
  2301. gather: 7,
  2302. speed: 400
  2303. }, {
  2304. id: 9,
  2305. type: 1,
  2306. age: 6,
  2307. name: "hunting bow",
  2308. desc: "bow used for ranged combat and hunting",
  2309. src: "bow_1",
  2310. req: ["wood", 4],
  2311. length: 120,
  2312. width: 120,
  2313. xOff: -6,
  2314. yOff: 0,
  2315. Pdmg: 25,
  2316. projectile: 0,
  2317. spdMult: 0.75,
  2318. speed: 600
  2319. }, {
  2320. id: 10,
  2321. type: 1,
  2322. age: 6,
  2323. name: "great hammer",
  2324. desc: "hammer used for destroying structures",
  2325. src: "great_hammer_1",
  2326. length: 140,
  2327. width: 140,
  2328. xOff: -9,
  2329. yOff: 25,
  2330. dmg: 10,
  2331. Pdmg: 10,
  2332. spdMult: 0.88,
  2333. range: 75,
  2334. sDmg: 7.5,
  2335. gather: 1,
  2336. speed: 400
  2337. }, {
  2338. id: 11,
  2339. type: 1,
  2340. age: 6,
  2341. name: "wooden shield",
  2342. desc: "blocks projectiles and reduces melee damage",
  2343. src: "shield_1",
  2344. length: 120,
  2345. width: 120,
  2346. shield: 0.2,
  2347. xOff: 6,
  2348. yOff: 0,
  2349. Pdmg: 0,
  2350. spdMult: 0.7
  2351. }, {
  2352. id: 12,
  2353. type: 1,
  2354. age: 8,
  2355. pre: 9,
  2356. name: "crossbow",
  2357. desc: "deals more damage and has greater range",
  2358. src: "crossbow_1",
  2359. req: ["wood", 5],
  2360. aboveHand: true,
  2361. armS: 0.75,
  2362. length: 120,
  2363. width: 120,
  2364. xOff: -4,
  2365. yOff: 0,
  2366. Pdmg: 35,
  2367. projectile: 2,
  2368. spdMult: 0.7,
  2369. speed: 700
  2370. }, {
  2371. id: 13,
  2372. type: 1,
  2373. age: 9,
  2374. pre: 12,
  2375. name: "repeater crossbow",
  2376. desc: "high firerate crossbow with reduced damage",
  2377. src: "crossbow_2",
  2378. req: ["wood", 10],
  2379. aboveHand: true,
  2380. armS: 0.75,
  2381. length: 120,
  2382. width: 120,
  2383. xOff: -4,
  2384. yOff: 0,
  2385. Pdmg: 30,
  2386. projectile: 3,
  2387. spdMult: 0.7,
  2388. speed: 230
  2389. }, {
  2390. id: 14,
  2391. type: 1,
  2392. age: 6,
  2393. name: "mc grabby",
  2394. desc: "steals resources from enemies",
  2395. src: "grab_1",
  2396. length: 130,
  2397. width: 210,
  2398. xOff: -8,
  2399. yOff: 53,
  2400. dmg: 0,
  2401. Pdmg: 0,
  2402. steal: 250,
  2403. knock: 0.2,
  2404. spdMult: 1.05,
  2405. range: 125,
  2406. gather: 0,
  2407. speed: 700
  2408. }, {
  2409. id: 15,
  2410. type: 1,
  2411. age: 9,
  2412. pre: 12,
  2413. name: "musket",
  2414. desc: "slow firerate but high damage and range",
  2415. src: "musket_1",
  2416. req: ["stone", 10],
  2417. aboveHand: true,
  2418. rec: 0.35,
  2419. armS: 0.6,
  2420. hndS: 0.3,
  2421. hndD: 1.6,
  2422. length: 205,
  2423. width: 205,
  2424. xOff: 25,
  2425. yOff: 0,
  2426. Pdmg: 50,
  2427. projectile: 5,
  2428. hideProjectile: true,
  2429. spdMult: 0.6,
  2430. speed: 1500
  2431. }];
  2432.  
  2433. // ITEMS:
  2434. this.list = [{
  2435. group: this.groups[0],
  2436. name: "apple",
  2437. desc: "restores 20 health when consumed",
  2438. req: ["food", 10],
  2439. consume: function(doer) {
  2440. return doer.changeHealth(20, doer);
  2441. },
  2442. scale: 22,
  2443. holdOffset: 15,
  2444. healing: 20,
  2445. itemID: 0,
  2446. itemAID: 16,
  2447. }, {
  2448. age: 3,
  2449. group: this.groups[0],
  2450. name: "cookie",
  2451. desc: "restores 40 health when consumed",
  2452. req: ["food", 15],
  2453. consume: function(doer) {
  2454. return doer.changeHealth(40, doer);
  2455. },
  2456. scale: 27,
  2457. holdOffset: 15,
  2458. healing: 40,
  2459. itemID: 1,
  2460. itemAID: 17,
  2461. }, {
  2462. age: 7,
  2463. group: this.groups[0],
  2464. name: "cheese",
  2465. desc: "restores 30 health and another 50 over 5 seconds",
  2466. req: ["food", 25],
  2467. consume: function(doer) {
  2468. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2469. doer.dmgOverTime.dmg = -10;
  2470. doer.dmgOverTime.doer = doer;
  2471. doer.dmgOverTime.time = 5;
  2472. return true;
  2473. }
  2474. return false;
  2475. },
  2476. scale: 27,
  2477. holdOffset: 15,
  2478. healing: 30,
  2479. itemID: 2,
  2480. itemAID: 18,
  2481. }, {
  2482. group: this.groups[1],
  2483. name: "wood wall",
  2484. desc: "provides protection for your village",
  2485. req: ["wood", 10],
  2486. projDmg: true,
  2487. health: 380,
  2488. scale: 50,
  2489. holdOffset: 20,
  2490. placeOffset: -5,
  2491. itemID: 3,
  2492. itemAID: 19,
  2493. }, {
  2494. age: 3,
  2495. group: this.groups[1],
  2496. name: "stone wall",
  2497. desc: "provides improved protection for your village",
  2498. req: ["stone", 25],
  2499. health: 900,
  2500. scale: 50,
  2501. holdOffset: 20,
  2502. placeOffset: -5,
  2503. itemID: 4,
  2504. itemAID: 20,
  2505. }, {
  2506. age: 7,
  2507. group: this.groups[1],
  2508. name: "castle wall",
  2509. desc: "provides powerful protection for your village",
  2510. req: ["stone", 35],
  2511. health: 1500,
  2512. scale: 52,
  2513. holdOffset: 20,
  2514. placeOffset: -5,
  2515. itemID: 5,
  2516. itemAID: 21,
  2517. }, {
  2518. group: this.groups[2],
  2519. name: "spikes",
  2520. desc: "damages enemies when they touch them",
  2521. req: ["wood", 20, "stone", 5],
  2522. health: 400,
  2523. dmg: 20,
  2524. scale: 49,
  2525. spritePadding: -23,
  2526. holdOffset: 8,
  2527. placeOffset: -5,
  2528. itemID: 6,
  2529. itemAID: 22,
  2530. shadow: {
  2531. offsetX: 5, // Adjust the shadow's X offset as needed
  2532. offsetY: 5, // Adjust the shadow's Y offset as needed
  2533. blur: 20, // Adjust the shadow's blur as needed
  2534. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2535. }
  2536.  
  2537. }, {
  2538. age: 5,
  2539. group: this.groups[2],
  2540. name: "greater spikes",
  2541. desc: "damages enemies when they touch them",
  2542. req: ["wood", 30, "stone", 10],
  2543. health: 500,
  2544. dmg: 35,
  2545. scale: 52,
  2546. spritePadding: -23,
  2547. holdOffset: 8,
  2548. placeOffset: -5,
  2549. itemID: 7,
  2550. itemAID: 23,
  2551. }, {
  2552. age: 9,
  2553. group: this.groups[2],
  2554. name: "poison spikes",
  2555. desc: "poisons enemies when they touch them",
  2556. req: ["wood", 35, "stone", 15],
  2557. health: 600,
  2558. dmg: 30,
  2559. pDmg: 5,
  2560. scale: 52,
  2561. spritePadding: -23,
  2562. holdOffset: 8,
  2563. placeOffset: -5,
  2564. itemID: 8,
  2565. itemAID: 24,
  2566. }, {
  2567. age: 9,
  2568. group: this.groups[2],
  2569. name: "spinning spikes",
  2570. desc: "damages enemies when they touch them",
  2571. req: ["wood", 30, "stone", 20],
  2572. health: 500,
  2573. dmg: 45,
  2574. turnSpeed: 0.003,
  2575. scale: 52,
  2576. spritePadding: -23,
  2577. holdOffset: 8,
  2578. placeOffset: -5,
  2579. itemID: 9,
  2580. itemAID: 25,
  2581. }, {
  2582. group: this.groups[3],
  2583. name: "windmill",
  2584. desc: "generates gold over time",
  2585. req: ["wood", 50, "stone", 10],
  2586. health: 400,
  2587. pps: 1,
  2588. turnSpeed: 0.0016,
  2589. spritePadding: 25,
  2590. iconLineMult: 12,
  2591. scale: 45,
  2592. holdOffset: 20,
  2593. placeOffset: 5,
  2594. itemID: 10,
  2595. itemAID: 26,
  2596. }, {
  2597. age: 5,
  2598. group: this.groups[3],
  2599. name: "faster windmill",
  2600. desc: "generates more gold over time",
  2601. req: ["wood", 60, "stone", 20],
  2602. health: 500,
  2603. pps: 1.5,
  2604. turnSpeed: 0.0025,
  2605. spritePadding: 25,
  2606. iconLineMult: 12,
  2607. scale: 47,
  2608. holdOffset: 20,
  2609. placeOffset: 5,
  2610. itemID: 11,
  2611. itemAID: 27,
  2612. }, {
  2613. age: 8,
  2614. group: this.groups[3],
  2615. name: "power mill",
  2616. desc: "generates more gold over time",
  2617. req: ["wood", 100, "stone", 50],
  2618. health: 800,
  2619. pps: 2,
  2620. turnSpeed: 0.005,
  2621. spritePadding: 25,
  2622. iconLineMult: 12,
  2623. scale: 47,
  2624. holdOffset: 20,
  2625. placeOffset: 5,
  2626. itemID: 12,
  2627. itemAID: 28,
  2628. }, {
  2629. age: 5,
  2630. group: this.groups[4],
  2631. type: 2,
  2632. name: "mine",
  2633. desc: "allows you to mine stone",
  2634. req: ["wood", 20, "stone", 100],
  2635. iconLineMult: 12,
  2636. scale: 65,
  2637. holdOffset: 20,
  2638. placeOffset: 0,
  2639. itemID: 13,
  2640. itemAID: 29,
  2641. }, {
  2642. age: 5,
  2643. group: this.groups[11],
  2644. type: 0,
  2645. name: "sapling",
  2646. desc: "allows you to farm wood",
  2647. req: ["wood", 150],
  2648. iconLineMult: 12,
  2649. colDiv: 0.5,
  2650. scale: 110,
  2651. holdOffset: 50,
  2652. placeOffset: -15,
  2653. itemID: 14,
  2654. itemAID: 30,
  2655. }, {
  2656. age: 4,
  2657. group: this.groups[5],
  2658. name: "pit trap",
  2659. desc: "pit that traps enemies if they walk over it",
  2660. req: ["wood", 30, "stone", 30],
  2661. trap: true,
  2662. ignoreCollision: true,
  2663. hideFromEnemy: true,
  2664. health: 500,
  2665. colDiv: 0.2,
  2666. scale: 50,
  2667. holdOffset: 20,
  2668. placeOffset: -5,
  2669. alpha: 0.6,
  2670. itemID: 15,
  2671. itemAID: 31,
  2672. }, {
  2673. age: 4,
  2674. group: this.groups[6],
  2675. name: "boost pad",
  2676. desc: "provides boost when stepped on",
  2677. req: ["stone", 20, "wood", 5],
  2678. ignoreCollision: true,
  2679. boostSpeed: 1.5,
  2680. health: 150,
  2681. colDiv: 0.7,
  2682. scale: 45,
  2683. holdOffset: 20,
  2684. placeOffset: -5,
  2685. itemID: 16,
  2686. itemAID: 32,
  2687. }, {
  2688. age: 7,
  2689. group: this.groups[7],
  2690. doUpdate: true,
  2691. name: "turret",
  2692. desc: "defensive structure that shoots at enemies",
  2693. req: ["wood", 200, "stone", 150],
  2694. health: 800,
  2695. projectile: 1,
  2696. shootRange: 700,
  2697. shootRate: 2200,
  2698. scale: 43,
  2699. holdOffset: 20,
  2700. placeOffset: -5,
  2701. itemID: 17,
  2702. itemAID: 33,
  2703. }, {
  2704. age: 7,
  2705. group: this.groups[8],
  2706. name: "platform",
  2707. desc: "platform to shoot over walls and cross over water",
  2708. req: ["wood", 20],
  2709. ignoreCollision: true,
  2710. zIndex: 1,
  2711. health: 300,
  2712. scale: 43,
  2713. holdOffset: 20,
  2714. placeOffset: -5,
  2715. itemID: 18,
  2716. itemAID: 34,
  2717. }, {
  2718. age: 7,
  2719. group: this.groups[9],
  2720. name: "healing pad",
  2721. desc: "standing on it will slowly heal you",
  2722. req: ["wood", 30, "food", 10],
  2723. ignoreCollision: true,
  2724. healCol: 15,
  2725. health: 400,
  2726. colDiv: 0.7,
  2727. scale: 45,
  2728. holdOffset: 20,
  2729. placeOffset: -5,
  2730. itemID: 19,
  2731. itemAID: 35,
  2732. }, {
  2733. age: 9,
  2734. group: this.groups[10],
  2735. name: "spawn pad",
  2736. desc: "you will spawn here when you die but it will dissapear",
  2737. req: ["wood", 100, "stone", 100],
  2738. health: 400,
  2739. ignoreCollision: true,
  2740. spawnPoint: true,
  2741. scale: 45,
  2742. holdOffset: 20,
  2743. placeOffset: -5,
  2744. itemID: 20,
  2745. itemAID: 36,
  2746. }, {
  2747. age: 7,
  2748. group: this.groups[12],
  2749. name: "blocker",
  2750. desc: "blocks building in radius",
  2751. req: ["wood", 30, "stone", 25],
  2752. ignoreCollision: true,
  2753. blocker: 300,
  2754. health: 400,
  2755. colDiv: 0.7,
  2756. scale: 45,
  2757. holdOffset: 20,
  2758. placeOffset: -5,
  2759. itemID: 21,
  2760. itemAID: 37,
  2761. }, {
  2762. age: 7,
  2763. group: this.groups[13],
  2764. name: "teleporter",
  2765. desc: "teleports you to a random point on the map",
  2766. req: ["wood", 60, "stone", 60],
  2767. ignoreCollision: true,
  2768. teleport: true,
  2769. health: 200,
  2770. colDiv: 0.7,
  2771. scale: 45,
  2772. holdOffset: 20,
  2773. placeOffset: -5,
  2774. itemID: 22,
  2775. itemAID: 38
  2776. }];
  2777.  
  2778. // CHECK ITEM ID:
  2779. this.checkItem = {
  2780. index: function(id, myItems) {
  2781. 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 :
  2782. 5 :
  2783. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2784. 6 :
  2785. undefined;
  2786. }
  2787. }
  2788.  
  2789. // ASSIGN IDS:
  2790. for (let i = 0; i < this.list.length; ++i) {
  2791. this.list[i].id = i;
  2792. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2793. }
  2794.  
  2795. // TROLOLOLOL:
  2796. if (typeof window !== "undefined") {
  2797. function shuffle(a) {
  2798. for (let i = a.length - 1; i > 0; i--) {
  2799. const j = Math.floor(Math.random() * (i + 1));
  2800. [a[i], a[j]] = [a[j], a[i]];
  2801. }
  2802. return a;
  2803. }
  2804. //shuffle(this.list);
  2805. }
  2806. }
  2807. }
  2808. class Objectmanager {
  2809. constructor(GameObject, liztobj, UTILS, config, players, server) {
  2810. let mathFloor = Math.floor,
  2811. mathABS = Math.abs,
  2812. mathCOS = Math.cos,
  2813. mathSIN = Math.sin,
  2814. mathPOW = Math.pow,
  2815. mathSQRT = Math.sqrt;
  2816.  
  2817. this.ignoreAdd = false;
  2818. this.hitObj = [];
  2819.  
  2820. // DISABLE OBJ:
  2821. this.disableObj = function(obj) {
  2822. obj.active = false;
  2823. };
  2824.  
  2825. // ADD NEW:
  2826. let tmpObj;
  2827. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2828. tmpObj = findObjectBySid(sid);
  2829. if (!tmpObj) {
  2830. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2831. if (!tmpObj) {
  2832. tmpObj = new GameObject(sid);
  2833. gameObjects.push(tmpObj);
  2834. }
  2835. }
  2836. if (setSID) {
  2837. tmpObj.sid = sid;
  2838. }
  2839. tmpObj.init(x, y, dir, s, type, data, owner);
  2840. };
  2841.  
  2842. // DISABLE BY SID:
  2843. this.disableBySid = function(sid) {
  2844. let find = findObjectBySid(sid);
  2845. if (find) {
  2846. this.disableObj(find);
  2847. }
  2848. };
  2849.  
  2850. // REMOVE ALL FROM PLAYER:
  2851. this.removeAllItems = function(sid, server) {
  2852. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2853. };
  2854.  
  2855. // CHECK IF PLACABLE:
  2856. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2857. 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)));
  2858. if (cantPlace) return false;
  2859. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2860. return true;
  2861. };
  2862.  
  2863. }
  2864. }
  2865. class Projectile {
  2866. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2867.  
  2868. // INIT:
  2869. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2870. this.active = true;
  2871. this.tickActive = true;
  2872. this.indx = indx;
  2873. this.x = x;
  2874. this.y = y;
  2875. this.x2 = x;
  2876. this.y2 = y;
  2877. this.dir = dir;
  2878. this.skipMov = true;
  2879. this.speed = spd;
  2880. this.dmg = dmg;
  2881. this.scale = scl;
  2882. this.range = rng;
  2883. this.r2 = rng;
  2884. this.owner = owner;
  2885. };
  2886.  
  2887. // UPDATE:
  2888. this.update = function(delta) {
  2889. if (this.active) {
  2890. let tmpSpeed = this.speed * delta;
  2891. if (!this.skipMov) {
  2892. this.x += tmpSpeed * Math.cos(this.dir);
  2893. this.y += tmpSpeed * Math.sin(this.dir);
  2894. this.range -= tmpSpeed;
  2895. if (this.range <= 0) {
  2896. this.x += this.range * Math.cos(this.dir);
  2897. this.y += this.range * Math.sin(this.dir);
  2898. tmpSpeed = 1;
  2899. this.range = 0;
  2900. this.active = false;
  2901. }
  2902. } else {
  2903. this.skipMov = false;
  2904. }
  2905. }
  2906. };
  2907. this.tickUpdate = function(delta) {
  2908. if (this.tickActive) {
  2909. let tmpSpeed = this.speed * delta;
  2910. if (!this.skipMov) {
  2911. this.x2 += tmpSpeed * Math.cos(this.dir);
  2912. this.y2 += tmpSpeed * Math.sin(this.dir);
  2913. this.r2 -= tmpSpeed;
  2914. if (this.r2 <= 0) {
  2915. this.x2 += this.r2 * Math.cos(this.dir);
  2916. this.y2 += this.r2 * Math.sin(this.dir);
  2917. tmpSpeed = 1;
  2918. this.r2 = 0;
  2919. this.tickActive = false;
  2920. }
  2921. } else {
  2922. this.skipMov = false;
  2923. }
  2924. }
  2925. };
  2926. }
  2927. };
  2928. class Store {
  2929. constructor() {
  2930. // STORE HATS:
  2931. this.hats = [{
  2932. id: 45,
  2933. name: "Shame!",
  2934. dontSell: true,
  2935. price: 0,
  2936. scale: 120,
  2937. desc: "hacks are for winners"
  2938. }, {
  2939. id: 51,
  2940. name: "Moo Cap",
  2941. price: 0,
  2942. scale: 120,
  2943. desc: "coolest mooer around"
  2944. }, {
  2945. id: 50,
  2946. name: "Apple Cap",
  2947. price: 0,
  2948. scale: 120,
  2949. desc: "apple farms remembers"
  2950. }, {
  2951. id: 28,
  2952. name: "Moo Head",
  2953. price: 0,
  2954. scale: 120,
  2955. desc: "no effect"
  2956. }, {
  2957. id: 29,
  2958. name: "Pig Head",
  2959. price: 0,
  2960. scale: 120,
  2961. desc: "no effect"
  2962. }, {
  2963. id: 30,
  2964. name: "Fluff Head",
  2965. price: 0,
  2966. scale: 120,
  2967. desc: "no effect"
  2968. }, {
  2969. id: 36,
  2970. name: "Pandou Head",
  2971. price: 0,
  2972. scale: 120,
  2973. desc: "no effect"
  2974. }, {
  2975. id: 37,
  2976. name: "Bear Head",
  2977. price: 0,
  2978. scale: 120,
  2979. desc: "no effect"
  2980. }, {
  2981. id: 38,
  2982. name: "Monkey Head",
  2983. price: 0,
  2984. scale: 120,
  2985. desc: "no effect"
  2986. }, {
  2987. id: 44,
  2988. name: "Polar Head",
  2989. price: 0,
  2990. scale: 120,
  2991. desc: "no effect"
  2992. }, {
  2993. id: 35,
  2994. name: "Fez Hat",
  2995. price: 0,
  2996. scale: 120,
  2997. desc: "no effect"
  2998. }, {
  2999. id: 42,
  3000. name: "Enigma Hat",
  3001. price: 0,
  3002. scale: 120,
  3003. desc: "join the enigma army"
  3004. }, {
  3005. id: 43,
  3006. name: "Blitz Hat",
  3007. price: 0,
  3008. scale: 120,
  3009. desc: "hey everybody i'm blitz"
  3010. }, {
  3011. id: 49,
  3012. name: "Bob XIII Hat",
  3013. price: 0,
  3014. scale: 120,
  3015. desc: "like and subscribe"
  3016. }, {
  3017. id: 57,
  3018. name: "Pumpkin",
  3019. price: 50,
  3020. scale: 120,
  3021. desc: "Spooooky"
  3022. }, {
  3023. id: 8,
  3024. name: "Bummle Hat",
  3025. price: 100,
  3026. scale: 120,
  3027. desc: "no effect"
  3028. }, {
  3029. id: 2,
  3030. name: "Straw Hat",
  3031. price: 500,
  3032. scale: 120,
  3033. desc: "no effect"
  3034. }, {
  3035. id: 15,
  3036. name: "Winter Cap",
  3037. price: 600,
  3038. scale: 120,
  3039. desc: "allows you to move at normal speed in snow",
  3040. coldM: 1
  3041. }, {
  3042. id: 5,
  3043. name: "Cowboy Hat",
  3044. price: 1000,
  3045. scale: 120,
  3046. desc: "no effect"
  3047. }, {
  3048. id: 4,
  3049. name: "Ranger Hat",
  3050. price: 2000,
  3051. scale: 120,
  3052. desc: "no effect"
  3053. }, {
  3054. id: 18,
  3055. name: "Explorer Hat",
  3056. price: 2000,
  3057. scale: 120,
  3058. desc: "no effect"
  3059. }, {
  3060. id: 31,
  3061. name: "Flipper Hat",
  3062. price: 2500,
  3063. scale: 120,
  3064. desc: "have more control while in water",
  3065. watrImm: true
  3066. }, {
  3067. id: 1,
  3068. name: "Marksman Cap",
  3069. price: 3000,
  3070. scale: 120,
  3071. desc: "increases arrow speed and range",
  3072. aMlt: 1.3
  3073. }, {
  3074. id: 10,
  3075. name: "Bush Gear",
  3076. price: 3000,
  3077. scale: 160,
  3078. desc: "allows you to disguise yourself as a bush"
  3079. }, {
  3080. id: 48,
  3081. name: "Halo",
  3082. price: 3000,
  3083. scale: 120,
  3084. desc: "no effect"
  3085. }, {
  3086. id: 6,
  3087. name: "Soldier Helmet",
  3088. price: 4000,
  3089. scale: 120,
  3090. desc: "reduces damage taken but slows movement",
  3091. spdMult: 0.94,
  3092. dmgMult: 0.75
  3093. }, {
  3094. id: 23,
  3095. name: "Anti Venom Gear",
  3096. price: 4000,
  3097. scale: 120,
  3098. desc: "makes you immune to poison",
  3099. poisonRes: 1
  3100. }, {
  3101. id: 13,
  3102. name: "Medic Gear",
  3103. price: 5000,
  3104. scale: 110,
  3105. desc: "slowly regenerates health over time",
  3106. healthRegen: 3
  3107. }, {
  3108. id: 9,
  3109. name: "Miners Helmet",
  3110. price: 5000,
  3111. scale: 120,
  3112. desc: "earn 1 extra gold per resource",
  3113. extraGold: 1
  3114. }, {
  3115. id: 32,
  3116. name: "Musketeer Hat",
  3117. price: 5000,
  3118. scale: 120,
  3119. desc: "reduces cost of projectiles",
  3120. projCost: 0.5
  3121. }, {
  3122. id: 7,
  3123. name: "Bull Helmet",
  3124. price: 6000,
  3125. scale: 120,
  3126. desc: "increases damage done but drains health",
  3127. healthRegen: -5,
  3128. dmgMultO: 1.5,
  3129. spdMult: 0.96
  3130. }, {
  3131. id: 22,
  3132. name: "Emp Helmet",
  3133. price: 6000,
  3134. scale: 120,
  3135. desc: "turrets won't attack but you move slower",
  3136. antiTurret: 1,
  3137. spdMult: 0.7
  3138. }, {
  3139. id: 12,
  3140. name: "Booster Hat",
  3141. price: 6000,
  3142. scale: 120,
  3143. desc: "increases your movement speed",
  3144. spdMult: 1.16
  3145. }, {
  3146. id: 26,
  3147. name: "Barbarian Armor",
  3148. price: 8000,
  3149. scale: 120,
  3150. desc: "knocks back enemies that attack you",
  3151. dmgK: 0.6
  3152. }, {
  3153. id: 21,
  3154. name: "Plague Mask",
  3155. price: 10000,
  3156. scale: 120,
  3157. desc: "melee attacks deal poison damage",
  3158. poisonDmg: 5,
  3159. poisonTime: 6
  3160. }, {
  3161. id: 46,
  3162. name: "Bull Mask",
  3163. price: 10000,
  3164. scale: 120,
  3165. desc: "bulls won't target you unless you attack them",
  3166. bullRepel: 1
  3167. }, {
  3168. id: 14,
  3169. name: "Windmill Hat",
  3170. topSprite: true,
  3171. price: 10000,
  3172. scale: 120,
  3173. desc: "generates points while worn",
  3174. pps: 1.5
  3175. }, {
  3176. id: 11,
  3177. name: "Spike Gear",
  3178. topSprite: true,
  3179. price: 10000,
  3180. scale: 120,
  3181. desc: "deal damage to players that damage you",
  3182. dmg: 0.45
  3183. }, {
  3184. id: 53,
  3185. name: "Turret Gear",
  3186. topSprite: true,
  3187. price: 10000,
  3188. scale: 120,
  3189. desc: "you become a walking turret",
  3190. turret: {
  3191. proj: 1,
  3192. range: 700,
  3193. rate: 2500
  3194. },
  3195. spdMult: 0.7
  3196. }, {
  3197. id: 20,
  3198. name: "Samurai Armor",
  3199. price: 12000,
  3200. scale: 120,
  3201. desc: "increased attack speed and fire rate",
  3202. atkSpd: 0.78
  3203. }, {
  3204. id: 58,
  3205. name: "Dark Knight",
  3206. price: 12000,
  3207. scale: 120,
  3208. desc: "restores health when you deal damage",
  3209. healD: 0.4
  3210. }, {
  3211. id: 27,
  3212. name: "Scavenger Gear",
  3213. price: 15000,
  3214. scale: 120,
  3215. desc: "earn double points for each kill",
  3216. kScrM: 2
  3217. }, {
  3218. id: 40,
  3219. name: "Tank Gear",
  3220. price: 15000,
  3221. scale: 120,
  3222. desc: "increased damage to buildings but slower movement",
  3223. spdMult: 0.3,
  3224. bDmg: 3.3
  3225. }, {
  3226. id: 52,
  3227. name: "Thief Gear",
  3228. price: 15000,
  3229. scale: 120,
  3230. desc: "steal half of a players gold when you kill them",
  3231. goldSteal: 0.5
  3232. }, {
  3233. id: 55,
  3234. name: "Bloodthirster",
  3235. price: 20000,
  3236. scale: 120,
  3237. desc: "Restore Health when dealing damage. And increased damage",
  3238. healD: 0.25,
  3239. dmgMultO: 1.2,
  3240. }, {
  3241. id: 56,
  3242. name: "Assassin Gear",
  3243. price: 20000,
  3244. scale: 120,
  3245. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3246. noEat: true,
  3247. spdMult: 1.1,
  3248. invisTimer: 1000
  3249. }];
  3250.  
  3251. // STORE ACCESSORIES:
  3252. this.accessories = [{
  3253. id: 12,
  3254. name: "Snowball",
  3255. price: 1000,
  3256. scale: 105,
  3257. xOff: 18,
  3258. desc: "no effect"
  3259. }, {
  3260. id: 9,
  3261. name: "Tree Cape",
  3262. price: 1000,
  3263. scale: 90,
  3264. desc: "no effect"
  3265. }, {
  3266. id: 10,
  3267. name: "Stone Cape",
  3268. price: 1000,
  3269. scale: 90,
  3270. desc: "no effect"
  3271. }, {
  3272. id: 3,
  3273. name: "Cookie Cape",
  3274. price: 1500,
  3275. scale: 90,
  3276. desc: "no effect"
  3277. }, {
  3278. id: 8,
  3279. name: "Cow Cape",
  3280. price: 2000,
  3281. scale: 90,
  3282. desc: "no effect"
  3283. }, {
  3284. id: 11,
  3285. name: "Monkey Tail",
  3286. price: 2000,
  3287. scale: 97,
  3288. xOff: 25,
  3289. desc: "Super speed but reduced damage",
  3290. spdMult: 1.35,
  3291. dmgMultO: 0.2
  3292. }, {
  3293. id: 17,
  3294. name: "Apple Basket",
  3295. price: 3000,
  3296. scale: 80,
  3297. xOff: 12,
  3298. desc: "slowly regenerates health over time",
  3299. healthRegen: 1
  3300. }, {
  3301. id: 6,
  3302. name: "Winter Cape",
  3303. price: 3000,
  3304. scale: 90,
  3305. desc: "no effect"
  3306. }, {
  3307. id: 4,
  3308. name: "Skull Cape",
  3309. price: 4000,
  3310. scale: 90,
  3311. desc: "no effect"
  3312. }, {
  3313. id: 5,
  3314. name: "Dash Cape",
  3315. price: 5000,
  3316. scale: 90,
  3317. desc: "no effect"
  3318. }, {
  3319. id: 2,
  3320. name: "Dragon Cape",
  3321. price: 6000,
  3322. scale: 90,
  3323. desc: "no effect"
  3324. }, {
  3325. id: 1,
  3326. name: "Super Cape",
  3327. price: 8000,
  3328. scale: 90,
  3329. desc: "no effect"
  3330. }, {
  3331. id: 7,
  3332. name: "Troll Cape",
  3333. price: 8000,
  3334. scale: 90,
  3335. desc: "no effect"
  3336. }, {
  3337. id: 14,
  3338. name: "Thorns",
  3339. price: 10000,
  3340. scale: 115,
  3341. xOff: 20,
  3342. desc: "no effect"
  3343. }, {
  3344. id: 15,
  3345. name: "Blockades",
  3346. price: 10000,
  3347. scale: 95,
  3348. xOff: 15,
  3349. desc: "no effect"
  3350. }, {
  3351. id: 20,
  3352. name: "Devils Tail",
  3353. price: 10000,
  3354. scale: 95,
  3355. xOff: 20,
  3356. desc: "no effect"
  3357. }, {
  3358. id: 16,
  3359. name: "Sawblade",
  3360. price: 12000,
  3361. scale: 90,
  3362. spin: true,
  3363. xOff: 0,
  3364. desc: "deal damage to players that damage you",
  3365. dmg: 0.15
  3366. }, {
  3367. id: 13,
  3368. name: "Angel Wings",
  3369. price: 15000,
  3370. scale: 138,
  3371. xOff: 22,
  3372. desc: "slowly regenerates health over time",
  3373. healthRegen: 3
  3374. }, {
  3375. id: 19,
  3376. name: "Shadow Wings",
  3377. price: 15000,
  3378. scale: 138,
  3379. xOff: 22,
  3380. desc: "increased movement speed",
  3381. spdMult: 1.1
  3382. }, {
  3383. id: 18,
  3384. name: "Blood Wings",
  3385. price: 20000,
  3386. scale: 178,
  3387. xOff: 26,
  3388. desc: "restores health when you deal damage",
  3389. healD: 0.2
  3390. }, {
  3391. id: 21,
  3392. name: "Corrupt X Wings",
  3393. price: 20000,
  3394. scale: 178,
  3395. xOff: 26,
  3396. desc: "deal damage to players that damage you",
  3397. dmg: 0.25
  3398. }];
  3399. }
  3400. };
  3401. class ProjectileManager {
  3402. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3403. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3404. let tmpData = items.projectiles[indx];
  3405. let tmpProj;
  3406. for (let i = 0; i < projectiles.length; ++i) {
  3407. if (!projectiles[i].active) {
  3408. tmpProj = projectiles[i];
  3409. break;
  3410. }
  3411. }
  3412. if (!tmpProj) {
  3413. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3414. tmpProj.sid = projectiles.length;
  3415. projectiles.push(tmpProj);
  3416. }
  3417. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3418. tmpProj.ignoreObj = ignoreObj;
  3419. tmpProj.layer = layer || tmpData.layer;
  3420. tmpProj.inWindow = inWindow;
  3421. tmpProj.src = tmpData.src;
  3422. return tmpProj;
  3423. };
  3424. }
  3425. };
  3426. class AiManager {
  3427.  
  3428. // AI MANAGER:
  3429. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3430.  
  3431. // AI TYPES:
  3432. this.aiTypes = [{
  3433. id: 0,
  3434. src: "cow_1",
  3435. killScore: 150,
  3436. health: 500,
  3437. weightM: 0.8,
  3438. speed: 0.00095,
  3439. turnSpeed: 0.001,
  3440. scale: 72,
  3441. drop: ["food", 50]
  3442. }, {
  3443. id: 1,
  3444. src: "pig_1",
  3445. killScore: 200,
  3446. health: 800,
  3447. weightM: 0.6,
  3448. speed: 0.00085,
  3449. turnSpeed: 0.001,
  3450. scale: 72,
  3451. drop: ["food", 80]
  3452. }, {
  3453. id: 2,
  3454. name: "Bull",
  3455. src: "bull_2",
  3456. hostile: true,
  3457. dmg: 20,
  3458. killScore: 1000,
  3459. health: 1800,
  3460. weightM: 0.5,
  3461. speed: 0.00094,
  3462. turnSpeed: 0.00074,
  3463. scale: 78,
  3464. viewRange: 800,
  3465. chargePlayer: true,
  3466. drop: ["food", 100]
  3467. }, {
  3468. id: 3,
  3469. name: "Bully",
  3470. src: "bull_1",
  3471. hostile: true,
  3472. dmg: 20,
  3473. killScore: 2000,
  3474. health: 2800,
  3475. weightM: 0.45,
  3476. speed: 0.001,
  3477. turnSpeed: 0.0008,
  3478. scale: 90,
  3479. viewRange: 900,
  3480. chargePlayer: true,
  3481. drop: ["food", 400]
  3482. }, {
  3483. id: 4,
  3484. name: "Wolf",
  3485. src: "wolf_1",
  3486. hostile: true,
  3487. dmg: 8,
  3488. killScore: 500,
  3489. health: 300,
  3490. weightM: 0.45,
  3491. speed: 0.001,
  3492. turnSpeed: 0.002,
  3493. scale: 84,
  3494. viewRange: 800,
  3495. chargePlayer: true,
  3496. drop: ["food", 200]
  3497. }, {
  3498. id: 5,
  3499. name: "Quack",
  3500. src: "chicken_1",
  3501. dmg: 8,
  3502. killScore: 2000,
  3503. noTrap: true,
  3504. health: 300,
  3505. weightM: 0.2,
  3506. speed: 0.0018,
  3507. turnSpeed: 0.006,
  3508. scale: 70,
  3509. drop: ["food", 100]
  3510. }, {
  3511. id: 6,
  3512. name: "MOOSTAFA",
  3513. nameScale: 50,
  3514. src: "enemy",
  3515. hostile: true,
  3516. dontRun: true,
  3517. fixedSpawn: true,
  3518. spawnDelay: 60000,
  3519. noTrap: true,
  3520. colDmg: 100,
  3521. dmg: 40,
  3522. killScore: 8000,
  3523. health: 18000,
  3524. weightM: 0.4,
  3525. speed: 0.0007,
  3526. turnSpeed: 0.01,
  3527. scale: 80,
  3528. spriteMlt: 1.8,
  3529. leapForce: 0.9,
  3530. viewRange: 1000,
  3531. hitRange: 210,
  3532. hitDelay: 1000,
  3533. chargePlayer: true,
  3534. drop: ["food", 100]
  3535. }, {
  3536. id: 7,
  3537. name: "Treasure",
  3538. hostile: true,
  3539. nameScale: 35,
  3540. src: "crate_1",
  3541. fixedSpawn: true,
  3542. spawnDelay: 120000,
  3543. colDmg: 200,
  3544. killScore: 5000,
  3545. health: 20000,
  3546. weightM: 0.1,
  3547. speed: 0.0,
  3548. turnSpeed: 0.0,
  3549. scale: 70,
  3550. spriteMlt: 1.0
  3551. }, {
  3552. id: 8,
  3553. name: "MOOFIE",
  3554. src: "wolf_2",
  3555. hostile: true,
  3556. fixedSpawn: true,
  3557. dontRun: true,
  3558. hitScare: 4,
  3559. spawnDelay: 30000,
  3560. noTrap: true,
  3561. nameScale: 35,
  3562. dmg: 10,
  3563. colDmg: 100,
  3564. killScore: 3000,
  3565. health: 7000,
  3566. weightM: 0.45,
  3567. speed: 0.0015,
  3568. turnSpeed: 0.002,
  3569. scale: 90,
  3570. viewRange: 800,
  3571. chargePlayer: true,
  3572. drop: ["food", 1000]
  3573. }];
  3574.  
  3575. // SPAWN AI:
  3576. this.spawn = function(x, y, dir, index) {
  3577. let tmpObj = ais.find((tmp) => !tmp.active);
  3578. if (!tmpObj) {
  3579. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3580. ais.push(tmpObj);
  3581. }
  3582. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3583. return tmpObj;
  3584. };
  3585. }
  3586.  
  3587. };
  3588. class AI {
  3589. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3590. this.sid = sid;
  3591. this.isAI = true;
  3592. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3593.  
  3594. // INIT:
  3595. this.init = function(x, y, dir, index, data) {
  3596. this.x = x;
  3597. this.y = y;
  3598. this.startX = data.fixedSpawn ? x : null;
  3599. this.startY = data.fixedSpawn ? y : null;
  3600. this.xVel = 0;
  3601. this.yVel = 0;
  3602. this.zIndex = 0;
  3603. this.dir = dir;
  3604. this.dirPlus = 0;
  3605. this.showName = 'aaa';
  3606. this.index = index;
  3607. this.src = data.src;
  3608. if (data.name) this.name = data.name;
  3609. this.weightM = data.weightM;
  3610. this.speed = data.speed;
  3611. this.killScore = data.killScore;
  3612. this.turnSpeed = data.turnSpeed;
  3613. this.scale = data.scale;
  3614. this.maxHealth = data.health;
  3615. this.leapForce = data.leapForce;
  3616. this.health = this.maxHealth;
  3617. this.chargePlayer = data.chargePlayer;
  3618. this.viewRange = data.viewRange;
  3619. this.drop = data.drop;
  3620. this.dmg = data.dmg;
  3621. this.hostile = data.hostile;
  3622. this.dontRun = data.dontRun;
  3623. this.hitRange = data.hitRange;
  3624. this.hitDelay = data.hitDelay;
  3625. this.hitScare = data.hitScare;
  3626. this.spriteMlt = data.spriteMlt;
  3627. this.nameScale = data.nameScale;
  3628. this.colDmg = data.colDmg;
  3629. this.noTrap = data.noTrap;
  3630. this.spawnDelay = data.spawnDelay;
  3631. this.hitWait = 0;
  3632. this.waitCount = 1000;
  3633. this.moveCount = 0;
  3634. this.targetDir = 0;
  3635. this.active = true;
  3636. this.alive = true;
  3637. this.runFrom = null;
  3638. this.chargeTarget = null;
  3639. this.dmgOverTime = {};
  3640. };
  3641.  
  3642. let tmpRatio = 0;
  3643. let animIndex = 0;
  3644. this.animate = function(delta) {
  3645. if (this.animTime > 0) {
  3646. this.animTime -= delta;
  3647. if (this.animTime <= 0) {
  3648. this.animTime = 0;
  3649. this.dirPlus = 0;
  3650. tmpRatio = 0;
  3651. animIndex = 0;
  3652. } else {
  3653. if (animIndex == 0) {
  3654. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3655. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3656. if (tmpRatio >= 1) {
  3657. tmpRatio = 1;
  3658. animIndex = 1;
  3659. }
  3660. } else {
  3661. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3662. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3663. }
  3664. }
  3665. }
  3666. };
  3667.  
  3668. // ANIMATION:
  3669. this.startAnim = function() {
  3670. this.animTime = this.animSpeed = 600;
  3671. this.targetAngle = Math.PI * 0.8;
  3672. tmpRatio = 0;
  3673. animIndex = 0;
  3674. };
  3675.  
  3676. };
  3677.  
  3678. };
  3679. class addCh {
  3680. constructor(x, y, chat, tmpObj) {
  3681. this.x = x;
  3682. this.y = y;
  3683. this.alpha = 0;
  3684. this.active = true;
  3685. this.alive = false;
  3686. this.chat = chat;
  3687. this.owner = tmpObj;
  3688. };
  3689. };
  3690. class DeadPlayer {
  3691. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3692. this.x = x;
  3693. this.y = y;
  3694. this.lastDir = dir;
  3695. this.dir = dir + Math.PI;
  3696. this.buildIndex = buildIndex;
  3697. this.weaponIndex = weaponIndex;
  3698. this.weaponVariant = weaponVariant;
  3699. this.skinColor = skinColor;
  3700. this.scale = scale;
  3701. this.visScale = 0;
  3702. this.name = name;
  3703. this.alpha = 1;
  3704. this.active = true;
  3705. this.animate = function(delta) {
  3706. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3707. if (d2 > 0.01) {
  3708. this.dir += d2 / 20;
  3709. } else {
  3710. this.dir = this.lastDir;
  3711. }
  3712. if (this.visScale < this.scale) {
  3713. this.visScale += delta / (this.scale / 2);
  3714. if (this.visScale >= this.scale) {
  3715. this.visScale = this.scale;
  3716. }
  3717. }
  3718. this.alpha -= delta / 30000;
  3719. if (this.alpha <= 0) {
  3720. this.alpha = 0;
  3721. this.active = false;
  3722. }
  3723. }
  3724. }
  3725. };
  3726. class Player {
  3727. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3728. this.id = id;
  3729. this.sid = sid;
  3730. this.tmpScore = 0;
  3731. this.team = null;
  3732. this.latestSkin = 0;
  3733. this.oldSkinIndex = 0;
  3734. this.skinIndex = 0;
  3735. this.latestTail = 0;
  3736. this.oldTailIndex = 0;
  3737. this.tailIndex = 0;
  3738. this.hitTime = 0;
  3739. this.lastHit = 0;
  3740. this.showName = 'NOOO';
  3741. this.tails = {};
  3742. for (let i = 0; i < accessories.length; ++i) {
  3743. if (accessories[i].price <= 0)
  3744. this.tails[accessories[i].id] = 1;
  3745. }
  3746. this.skins = {};
  3747. for (let i = 0; i < hats.length; ++i) {
  3748. if (hats[i].price <= 0)
  3749. this.skins[hats[i].id] = 1;
  3750. }
  3751. this.points = 0;
  3752. this.dt = 0;
  3753. this.hidden = false;
  3754. this.itemCounts = {};
  3755. this.isPlayer = true;
  3756. this.pps = 0;
  3757. this.moveDir = undefined;
  3758. this.skinRot = 0;
  3759. this.lastPing = 0;
  3760. this.iconIndex = 0;
  3761. this.skinColor = 0;
  3762. this.dist2 = 0;
  3763. this.aim2 = 0;
  3764. this.maxSpeed = 1;
  3765. this.chat = {
  3766. message: null,
  3767. count: 0
  3768. };
  3769. this.circle = false;
  3770. this.cAngle = 0;
  3771. // SPAWN:
  3772. this.spawn = function(moofoll) {
  3773. this.attacked = false;
  3774. this.timeDamaged = 0;
  3775. this.timeHealed = 0;
  3776. this.pinge = 0;
  3777. this.millPlace = 'NOOO';
  3778. this.lastshamecount = 0;
  3779. this.death = false;
  3780. this.spinDir = 0;
  3781. this.sync = false;
  3782. this.antiBull = 0;
  3783. this.bullTimer = 0;
  3784. this.poisonTimer = 0;
  3785. this.active = true;
  3786. this.alive = true;
  3787. this.lockMove = false;
  3788. this.lockDir = false;
  3789. this.minimapCounter = 0;
  3790. this.chatCountdown = 0;
  3791. this.shameCount = 0;
  3792. this.shameTimer = 0;
  3793. this.sentTo = {};
  3794. this.gathering = 0;
  3795. this.gatherIndex = 0;
  3796. this.shooting = {};
  3797. this.shootIndex = 9;
  3798. this.autoGather = 0;
  3799. this.animTime = 0;
  3800. this.animSpeed = 0;
  3801. this.mouseState = 0;
  3802. this.buildIndex = -1;
  3803. this.weaponIndex = 0;
  3804. this.weaponCode = 0;
  3805. this.weaponVariant = 0;
  3806. this.primaryIndex = undefined;
  3807. this.secondaryIndex = undefined;
  3808. this.dmgOverTime = {};
  3809. this.noMovTimer = 0;
  3810. this.maxXP = 300;
  3811. this.XP = 0;
  3812. this.age = 1;
  3813. this.kills = 0;
  3814. this.upgrAge = 2;
  3815. this.upgradePoints = 0;
  3816. this.x = 0;
  3817. this.y = 0;
  3818. this.oldXY = {
  3819. x: 0,
  3820. y: 0
  3821. };
  3822. this.zIndex = 0;
  3823. this.xVel = 0;
  3824. this.yVel = 0;
  3825. this.slowMult = 1;
  3826. this.dir = 0;
  3827. this.dirPlus = 0;
  3828. this.targetDir = 0;
  3829. this.targetAngle = 0;
  3830. this.maxHealth = 100;
  3831. this.health = this.maxHealth;
  3832. this.oldHealth = this.maxHealth;
  3833. this.damaged = 0;
  3834. this.scale = config.playerScale;
  3835. this.speed = config.playerSpeed;
  3836. this.resetMoveDir();
  3837. this.resetResources(moofoll);
  3838. this.items = [0, 3, 6, 10];
  3839. this.weapons = [0];
  3840. this.shootCount = 0;
  3841. this.weaponXP = [];
  3842. this.reloads = {
  3843. 0: 0,
  3844. 1: 0,
  3845. 2: 0,
  3846. 3: 0,
  3847. 4: 0,
  3848. 5: 0,
  3849. 6: 0,
  3850. 7: 0,
  3851. 8: 0,
  3852. 9: 0,
  3853. 10: 0,
  3854. 11: 0,
  3855. 12: 0,
  3856. 13: 0,
  3857. 14: 0,
  3858. 15: 0,
  3859. 53: 0,
  3860. };
  3861. this.bowThreat = {
  3862. 9: 0,
  3863. 12: 0,
  3864. 13: 0,
  3865. 15: 0,
  3866. };
  3867. this.damageThreat = 0;
  3868. this.inTrap = false;
  3869. this.canEmpAnti = false;
  3870. this.empAnti = false;
  3871. this.soldierAnti = false;
  3872. this.poisonTick = 0;
  3873. this.bullTick = 0;
  3874. this.setPoisonTick = false;
  3875. this.setBullTick = false;
  3876. this.antiTimer = 2;
  3877. };
  3878.  
  3879. // RESET MOVE DIR:
  3880. this.resetMoveDir = function() {
  3881. this.moveDir = undefined;
  3882. };
  3883.  
  3884. // RESET RESOURCES:
  3885. this.resetResources = function(moofoll) {
  3886. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3887. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3888. }
  3889. };
  3890.  
  3891. // ADD ITEM:
  3892. this.getItemType = function(id) {
  3893. let findindx = this.items.findIndex((ids) => ids == id);
  3894. if (findindx != -1) {
  3895. return findindx;
  3896. } else {
  3897. return items.checkItem.index(id, this.items);
  3898. }
  3899. };
  3900.  
  3901. // SET DATA:
  3902. this.setData = function(data) {
  3903. this.id = data[0];
  3904. this.sid = data[1];
  3905. this.name = data[2];
  3906. this.x = data[3];
  3907. this.y = data[4];
  3908. this.dir = data[5];
  3909. this.health = data[6];
  3910. this.maxHealth = data[7];
  3911. this.scale = data[8];
  3912. this.skinColor = data[9];
  3913. };
  3914.  
  3915. // UPDATE POISON TICK:
  3916. this.updateTimer = function() {
  3917.  
  3918. this.bullTimer -= 1;
  3919. if (this.bullTimer <= 0) {
  3920. this.setBullTick = false;
  3921. this.bullTick = game.tick - 1;
  3922. this.bullTimer = config.serverUpdateRate;
  3923. }
  3924. this.poisonTimer -= 1;
  3925. if (this.poisonTimer <= 0) {
  3926. this.setPoisonTick = false;
  3927. this.poisonTick = game.tick - 1;
  3928. this.poisonTimer = config.serverUpdateRate;
  3929. }
  3930.  
  3931. };
  3932. this.update = function(delta) {
  3933. if (this.active) {
  3934.  
  3935. // MOVE:
  3936. let gear = {
  3937. skin: findID(hats, this.skinIndex),
  3938. tail: findID(accessories, this.tailIndex)
  3939. }
  3940. 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;
  3941. this.maxSpeed = spdMult;
  3942.  
  3943. }
  3944. };
  3945.  
  3946. let tmpRatio = 0;
  3947. let animIndex = 0;
  3948. this.animate = function(delta) {
  3949. if (this.animTime > 0) {
  3950. this.animTime -= delta;
  3951. if (this.animTime <= 0) {
  3952. this.animTime = 0;
  3953. this.dirPlus = 0;
  3954. tmpRatio = 0;
  3955. animIndex = 0;
  3956. } else {
  3957. if (animIndex == 0) {
  3958. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3959. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3960. if (tmpRatio >= 1) {
  3961. tmpRatio = 1;
  3962. animIndex = 1;
  3963. }
  3964. } else {
  3965. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3966. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3967. }
  3968. }
  3969. }
  3970. };
  3971.  
  3972. // GATHER ANIMATION:
  3973. this.startAnim = function(didHit, index) {
  3974. this.animTime = this.animSpeed = items.weapons[index].speed;
  3975. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3976. tmpRatio = 0;
  3977. animIndex = 0;
  3978. };
  3979.  
  3980. // CAN SEE:
  3981. this.canSee = function(other) {
  3982. if (!other) return false;
  3983. let dx = Math.abs(other.x - this.x) - other.scale;
  3984. let dy = Math.abs(other.y - this.y) - other.scale;
  3985. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3986. };
  3987.  
  3988. // SHAME SYSTEM:
  3989. this.judgeShame = function() {
  3990. if (this.oldHealth < this.health) {
  3991. if (this.hitTime) {
  3992. let timeSinceHit = game.tick - this.hitTime;
  3993. this.lastHit = game.tick;
  3994. this.hitTime = 0;
  3995. if (timeSinceHit < 2) {
  3996. this.shameCount++;
  3997. } else {
  3998. this.shameCount = Math.max(0, this.shameCount - 2);
  3999. }
  4000. }
  4001. } else if (this.oldHealth > this.health) {
  4002. this.hitTime = game.tick;
  4003. }
  4004. };
  4005. this.addShameTimer = function() {
  4006. this.shameCount = 0;
  4007. this.shameTimer = 30;
  4008. let interval = setInterval(() => {
  4009. this.shameTimer--;
  4010. if (this.shameTimer <= 0) {
  4011. clearInterval(interval);
  4012. }
  4013. }, 1000);
  4014. };
  4015.  
  4016. // CHECK TEAM:
  4017. this.isTeam = function(tmpObj) {
  4018. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4019. };
  4020.  
  4021. // FOR THE PLAYER:
  4022. this.findAllianceBySid = function(sid) {
  4023. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4024. };
  4025. this.checkCanInsta = function(nobull) {
  4026. let totally = 0;
  4027. if (this.alive && inGame) {
  4028. let primary = {
  4029. weapon: this.weapons[0],
  4030. variant: this.primaryVariant,
  4031. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4032. };
  4033. let secondary = {
  4034. weapon: this.weapons[1],
  4035. variant: this.secondaryVariant,
  4036. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4037. };
  4038. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4039. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4040. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4041. totally += primary.dmg * pV * bull;
  4042. }
  4043. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4044. totally += secondary.dmg;
  4045. }
  4046. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4047. totally += 25;
  4048. }
  4049. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4050. return totally;
  4051. }
  4052. return 0;
  4053. };
  4054.  
  4055. // UPDATE WEAPON RELOAD:
  4056. this.manageReload = function() {
  4057. if (this.shooting[53]) {
  4058. this.shooting[53] = 0;
  4059. this.reloads[53] = (2500 - game.tickRate);
  4060. } else {
  4061. if (this.reloads[53] > 0) {
  4062. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4063. }
  4064. }
  4065.  
  4066. // PREPLACER
  4067. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4068. // place(2, getAttackDir());
  4069. let index = this.weaponIndex;
  4070. 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));
  4071. for(let i = 0; i < nearObja.length; i++) {
  4072. let aaa = nearObja[i];
  4073.  
  4074. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4075. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4076. if(aaa.health - (valaa) <= 0 && near.length) {
  4077. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4078. console.log("preplaced");
  4079. }
  4080. }
  4081. }
  4082.  
  4083. if (this.gathering || this.shooting[1]) {
  4084. if (this.gathering) {
  4085. this.gathering = 0;
  4086. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4087. this.attacked = true;
  4088. }
  4089. if (this.shooting[1]) {
  4090. this.shooting[1] = 0;
  4091. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4092. this.attacked = true;
  4093. }
  4094. } else {
  4095. this.attacked = false;
  4096. if (this.buildIndex < 0) {
  4097. if (this.reloads[this.weaponIndex] > 0) {
  4098. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4099. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4100. if (this == player) {
  4101. if (getEl("weaponGrind").checked) {
  4102. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4103. checkPlace(player.getItemType(22), i);
  4104. }
  4105. }
  4106. }
  4107. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4108. this.antiBull++;
  4109. game.tickBase(() => {
  4110. this.antiBull = 0;
  4111. }, 1);
  4112. }
  4113. }
  4114. }
  4115. }
  4116. };
  4117.  
  4118. // FOR ANTI INSTA:
  4119. this.addDamageThreat = function(tmpObj) {
  4120. let primary = {
  4121. weapon: this.primaryIndex,
  4122. variant: this.primaryVariant
  4123. };
  4124. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4125. let secondary = {
  4126. weapon: this.secondaryIndex,
  4127. variant: this.secondaryVariant
  4128. };
  4129. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4130. let bull = 1.5;
  4131. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4132. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4133. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4134. this.damageThreat += primary.dmg * pV * bull;
  4135. }
  4136. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4137. this.damageThreat += secondary.dmg * sV;
  4138. }
  4139. if (this.reloads[53] <= game.tickRate) {
  4140. this.damageThreat += 25;
  4141. }
  4142. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4143. if (!this.isTeam(tmpObj)) {
  4144. if (this.dist2 <= 300) {
  4145. tmpObj.damageThreat += this.damageThreat;
  4146. }
  4147. }
  4148. };
  4149.  
  4150. }
  4151. };
  4152.  
  4153. // SOME CODES:
  4154. function sendUpgrade(index) {
  4155. player.reloads[index] = 0;
  4156. packet("H", index);
  4157. }
  4158.  
  4159. function storeEquip(id, index) {
  4160. packet("c", 0, id, index);
  4161. }
  4162.  
  4163. function storeBuy(id, index) {
  4164. packet("c", 1, id, index);
  4165. }
  4166.  
  4167. function buyEquip(id, index) {
  4168. let nID = player.skins[6] ? 6 : 0;
  4169. if (player.alive && inGame) {
  4170. if (index == 0) {
  4171. if (player.skins[id]) {
  4172. if (player.latestSkin != id) {
  4173. packet("c", 0, id, 0);
  4174. }
  4175. } else {
  4176. if (configs.autoBuyEquip) {
  4177. let find = findID(hats, id);
  4178. if (find) {
  4179. if (player.points >= find.price) {
  4180. packet("c", 1, id, 0);
  4181. packet("c", 0, id, 0);
  4182. } else {
  4183. if (player.latestSkin != nID) {
  4184. packet("c", 0, nID, 0);
  4185. }
  4186. }
  4187. } else {
  4188. if (player.latestSkin != nID) {
  4189. packet("c", 0, nID, 0);
  4190. }
  4191. }
  4192. } else {
  4193. if (player.latestSkin != nID) {
  4194. packet("c", 0, nID, 0);
  4195. }
  4196. }
  4197. }
  4198. } else if (index == 1) {
  4199. if (useWasd && (id != 11 && id != 0)) {
  4200. if (player.latestTail != 0) {
  4201. packet("c", 0, 0, 1);
  4202. }
  4203. return;
  4204. }
  4205. if (player.tails[id]) {
  4206. if (player.latestTail != id) {
  4207. packet("c", 0, id, 1);
  4208. }
  4209. } else {
  4210. if (configs.autoBuyEquip) {
  4211. let find = findID(accessories, id);
  4212. if (find) {
  4213. if (player.points >= find.price) {
  4214. packet("c", 1, id, 1);
  4215. packet("c", 0, id, 1);
  4216. } else {
  4217. if (player.latestTail != 0) {
  4218. packet("c", 0, 0, 1);
  4219. }
  4220. }
  4221. } else {
  4222. if (player.latestTail != 0) {
  4223. packet("c", 0, 0, 1);
  4224. }
  4225. }
  4226. } else {
  4227. if (player.latestTail != 0) {
  4228. packet("c", 0, 0, 1);
  4229. }
  4230. }
  4231. }
  4232. }
  4233. }
  4234. }
  4235.  
  4236. function selectToBuild(index, wpn) {
  4237. packet("G", index, wpn);
  4238. }
  4239.  
  4240. function selectWeapon(index, isPlace) {
  4241. if (!isPlace) {
  4242. player.weaponCode = index;
  4243. }
  4244. packet("G", index, 1);
  4245. }
  4246.  
  4247. function sendAutoGather() {
  4248. packet("K", 1, 1);
  4249. }
  4250.  
  4251. function sendAtck(id, angle) {
  4252. packet("d", id, angle, 1);
  4253. }
  4254.  
  4255. // PLACER:
  4256. function place(id, rad, rmd) {
  4257. try {
  4258. if (id == undefined) return;
  4259. let item = items.list[player.items[id]];
  4260. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4261. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4262. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4263. 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))) {
  4264. selectToBuild(player.items[id]);
  4265. sendAtck(1, rad);
  4266. selectWeapon(player.weaponCode, 1);
  4267. if (rmd && getEl("placeVis").checked) {
  4268. placeVisible.push({
  4269. x: tmpX,
  4270. y: tmpY,
  4271. name: item.name,
  4272. scale: item.scale,
  4273. dir: rad
  4274. });
  4275. game.tickBase(() => {
  4276. placeVisible.shift();
  4277. }, 1)
  4278. }
  4279. }
  4280. } catch (e) {}
  4281. }
  4282.  
  4283. function checkPlace(id, rad) {
  4284. try {
  4285. if (id == undefined) return;
  4286. let item = items.list[player.items[id]];
  4287. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4288. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4289. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4290. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4291. place(id, rad, 1);
  4292. }
  4293. } catch (e) {}
  4294. }
  4295.  
  4296. // HEALING:
  4297. function soldierMult() {
  4298. return player.latestSkin == 6 ? 0.75 : 1;
  4299. }
  4300.  
  4301. function healthBased() {
  4302. if (player.health == 100)
  4303. return 0;
  4304. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4305. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4306. }
  4307. return 0;
  4308. }
  4309.  
  4310. function getAttacker(damaged) {
  4311. let attackers = enemy.filter(tmp => {
  4312. //let damages = new Damages(items);
  4313. //let dmg = damages.weapons[tmp.weaponIndex];
  4314. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4315. let rule = {
  4316. //one: tmp.dist2 <= 300,
  4317. //two: by.includes(damaged),
  4318. three: tmp.attacked
  4319. }
  4320. return /*rule.one && rule.two && */ rule.three;
  4321. });
  4322. return attackers;
  4323. }
  4324.  
  4325. function healer() {
  4326. for (let i = 0; i < healthBased(); i++) {
  4327. place(0, getAttackDir());
  4328. }
  4329. }
  4330.  
  4331. function antiSyncHealing(timearg) {
  4332. my.antiSync = true;
  4333. sendChat("");
  4334. let healAnti = setInterval(() => {
  4335. if (player.shameCount < 5) {
  4336. place(0, getAttackDir());
  4337. }
  4338. }, 75);
  4339. setTimeout(() => {
  4340. clearInterval(healAnti);
  4341. setTimeout(() => {
  4342. my.antiSync = false;
  4343. }, game.tickRate);
  4344. }, game.tickRate);
  4345. }
  4346. function applCxC(value) {
  4347. if (player.health == 100)
  4348. return 0;
  4349. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4350. return Math.ceil(value / items.list[player.items[0]].healing);
  4351. }
  4352. return 0;
  4353. }
  4354. function calcDmg(value) {
  4355. return value * player.skinIndex == 6 ? 0.75 : 1;
  4356. }
  4357. function biomeGear(mover, returns) {
  4358. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4359. if (returns) return 31;
  4360. buyEquip(31, 0);
  4361. } else {
  4362. if (player.y2 <= config.snowBiomeTop) {
  4363. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4364. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4365. } else {
  4366. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4367. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4368. }
  4369. }
  4370. if (returns) return 0;
  4371. }
  4372. let advHeal = [];
  4373.  
  4374. class Traps {
  4375. constructor(UTILS, items) {
  4376. this.dist = 0;
  4377. this.aim = 0;
  4378. this.inTrap = false;
  4379. this.replaced = false;
  4380. this.antiTrapped = false;
  4381. this.info = {};
  4382. this.notFast = function() {
  4383. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4384. }
  4385. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4386. try {
  4387. let item = items.list[player.items[id]];
  4388. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4389. let counts = {
  4390. attempts: 0,
  4391. placed: 0
  4392. };
  4393. let tmpObjects = [];
  4394. gameObjects.forEach((p) => {
  4395. tmpObjects.push({
  4396. x: p.x,
  4397. y: p.y,
  4398. active: p.active,
  4399. blocker: p.blocker,
  4400. scale: p.scale,
  4401. isItem: p.isItem,
  4402. type: p.type,
  4403. colDiv: p.colDiv,
  4404. getScale: function(sM, ig) {
  4405. sM = sM || 1;
  4406. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4407. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4408. },
  4409. });
  4410. });
  4411. for (let i = first; i < repeat; i += plus) {
  4412. counts.attempts++;
  4413. let relAim = radian + i;
  4414. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4415. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4416. 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)));
  4417. if (cantPlace) continue;
  4418. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4419. if ((!replacer && yaboi) || useWasd) {
  4420. if (useWasd ? false : yaboi.inTrap) {
  4421. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4422. place(2, relAim, 1);
  4423. } else {
  4424. player.items[4] == 15 && place(4, relAim, 1);
  4425. }
  4426. } else {
  4427. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  4428. place(2, relAim, 1);
  4429. } else {
  4430. player.items[4] == 15 && place(4, relAim, 1);
  4431. }
  4432. }
  4433. } else {
  4434. place(id, relAim, 1);
  4435. }
  4436. tmpObjects.push({
  4437. x: tmpX,
  4438. y: tmpY,
  4439. active: true,
  4440. blocker: item.blocker,
  4441. scale: item.scale,
  4442. isItem: true,
  4443. type: null,
  4444. colDiv: item.colDiv,
  4445. getScale: function() {
  4446. return this.scale;
  4447. },
  4448. });
  4449. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4450. counts.placed++;
  4451. }
  4452. }
  4453. if (counts.placed > 0 && replacer && item.dmg) {
  4454. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4455. instaC.canSpikeTick = true;
  4456. }
  4457. }
  4458. } catch (err) {
  4459. }
  4460. };
  4461.  
  4462. this.checkSpikeTick = function() {
  4463. try {
  4464. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4465. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4466. // more range for safe. also testing near.primaryIndex || 5
  4467. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4468. let item = items.list[9];
  4469. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4470. let danger = 0;
  4471. let counts = {
  4472. attempts: 0,
  4473. block: `unblocked`
  4474. };
  4475. for (let i = -1; i <= 1; i += 1 / 10) {
  4476. counts.attempts++;
  4477. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4478. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4479. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4480. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4481. if (cantPlace) continue;
  4482. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4483. danger++;
  4484. counts.block = `blocked`;
  4485. break;
  4486. }
  4487. if (danger) {
  4488. my.anti0Tick = 1;
  4489. player.chat.count = 100000;
  4490. return true;
  4491. }
  4492. }
  4493. } catch (err) {
  4494. return null;
  4495. }
  4496. return false;
  4497. }
  4498. this.protect = function(aim) {
  4499. sendChat("Can't kill what's already dead");
  4500. if (!configs.antiTrap) return;
  4501. if (player.items[4]) {
  4502. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4503. this.antiTrapped = true;
  4504. }
  4505. };
  4506. /*this.autoPlace = function() {
  4507. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4508. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4509. if (gameObjects.length) {
  4510. let near2 = {
  4511. inTrap: false,
  4512. };
  4513. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function(a, b) {
  4514. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4515. })[0];
  4516. if (nearTrap) {
  4517. near2.inTrap = true;
  4518. } else {
  4519. near2.inTrap = false;
  4520. }
  4521. if ((near.dist3 <= 450)) {
  4522. if (near.dist3 <= 200) {
  4523. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4524. inTrap: near2.inTrap
  4525. });
  4526. } else {
  4527. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4528. }
  4529. }
  4530. } else {
  4531. if ((near.dist3 <= 450)) {
  4532. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4533. }
  4534. }
  4535. }
  4536. }
  4537. };*/
  4538. this.autoPlace = function () {
  4539. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4540. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  4541. if (gameObjects.length) {
  4542. let near2 = {
  4543. inTrap: true,
  4544. };
  4545. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function (a, b) {
  4546. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4547. })[0];
  4548. if (nearTrap) {
  4549. near2.inTrap = true;
  4550. } else {
  4551. near2.inTrap = true;
  4552. }
  4553. if ((near.dist2 <= 375)) {
  4554. if (near.dist2 <= 200) {
  4555. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4556. } else {
  4557. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4558. }
  4559. }
  4560. } else {
  4561. if ((near.dist2 <= 1000)) {
  4562. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4563. }
  4564. }
  4565. }
  4566. }
  4567. };
  4568. this.replacer = function (findObj) {
  4569. if (!findObj || !configs.autoReplace) return;
  4570. if (!inGame) return;
  4571. if (this.antiTrapped) return;
  4572. game.tickBase(() => {
  4573. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4574. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4575. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4576. if (objDst <= 400 && near.dist2 <= 400) {
  4577. let danger = this.checkSpikeTick();
  4578. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4579. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4580. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4581. } else {
  4582. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4583. }
  4584. this.replaced = true;
  4585. }
  4586. }, 1);
  4587. };
  4588. }
  4589. };
  4590. /* this.replacer = function(findObj) {
  4591. if (!findObj || !configs.autoReplace) return;
  4592. if (!inGame) return;
  4593. if (this.antiTrapped) return;
  4594.  
  4595. game.tickBase(() => {
  4596. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4597. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4598.  
  4599. let perfectAngle = calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y);
  4600.  
  4601. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4602.  
  4603. if (objDst <= 400 && near.dist2 <= 400) {
  4604. if (isObjectBroken(findObj)) {
  4605. let danger = this.checkSpikeTick();
  4606. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4607. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  4608. } else {
  4609. if (player.items[4] == 15) {
  4610. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  4611. }
  4612. }
  4613. this.replaced = true;
  4614. }
  4615. }
  4616. }, 1);
  4617. }
  4618. }
  4619. }*/
  4620.  
  4621. function calculatePerfectAngle(x1, y1, x2, y2) {
  4622. return Math.atan2(y2 - y1, x2 - x1);
  4623. }
  4624. function isObjectBroken(object) {
  4625. const healthThreshold = 20;
  4626. return object.health < healthThreshold;
  4627. }
  4628.  
  4629. /*this.replacer = function (findObj) {
  4630. if (!findObj || !configs.autoReplace) return;
  4631. if (!inGame) return;
  4632. if (this.antiTrapped) return;
  4633. game.tickBase(() => {
  4634. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4635. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4636. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4637. if (objDst <= 400 && near.dist2 <= 400) {
  4638. let danger = this.checkSpikeTick();
  4639. if (!danger && near.dist2 <= items.weapons[near.primaryIndex + 5].range + (near.scale * 1.8)) {
  4640. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4641. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4642. } else {
  4643. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4644. }
  4645. this.replaced = true;
  4646. }
  4647. }, 1);
  4648. };
  4649. }
  4650. }*/
  4651. class Instakill {
  4652. constructor() {
  4653. this.wait = false;
  4654. this.can = false;
  4655. this.isTrue = false;
  4656. this.nobull = false;
  4657. this.ticking = false;
  4658. this.canSpikeTick = false;
  4659. this.startTick = false;
  4660. this.readyTick = false;
  4661. this.canCounter = false;
  4662. this.revTick = false;
  4663. this.syncHit = false;
  4664. this.changeType = function(type) {
  4665. this.wait = false;
  4666. this.isTrue = true;
  4667. my.autoAim = true;
  4668. let instaLog = [type];
  4669. if (type == "rev") {
  4670. selectWeapon(player.weapons[1]);
  4671. buyEquip(53, 0);
  4672. sendAutoGather();
  4673. setTimeout(() => {
  4674. selectWeapon(player.weapons[0]);
  4675. buyEquip(7, 0);
  4676. setTimeout(() => {
  4677. sendAutoGather();
  4678. this.isTrue = false;
  4679. my.autoAim = false;
  4680. }, 225);
  4681. }, 100);
  4682. } else if (type == "nobull") {
  4683. selectWeapon(player.weapons[0]);
  4684. buyEquip(7, 0);
  4685. sendAutoGather();
  4686. setTimeout(() => {
  4687. selectWeapon(player.weapons[1]);
  4688. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4689. setTimeout(() => {
  4690. sendAutoGather();
  4691. this.isTrue = false;
  4692. my.autoAim = false;
  4693. }, 255);
  4694. }, 105);
  4695. } else if (type == "normal") {
  4696. selectWeapon(player.weapons[0]);
  4697. buyEquip(7, 0);
  4698. sendAutoGather();
  4699. setTimeout(() => {
  4700. selectWeapon(player.weapons[1]);
  4701. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4702. setTimeout(() => {
  4703. sendAutoGather();
  4704. this.isTrue = false;
  4705. my.autoAim = false;
  4706. }, 255);
  4707. }, 100);
  4708. } else {
  4709. setTimeout(() => {
  4710. this.isTrue = false;
  4711. my.autoAim = false;
  4712. }, 50);
  4713. }
  4714. };
  4715. this.spikeTickType = function() {
  4716. sendChat("Joe mama almost ticked you!");
  4717. this.isTrue = true;
  4718. my.autoAim = true;
  4719. selectWeapon(player.weapons[0]);
  4720. buyEquip(7, 0);
  4721. sendAutoGather();
  4722. game.tickBase(() => {
  4723. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4724. buyEquip(53, 0);
  4725. selectWeapon(player.weapons[0]);
  4726. buyEquip(53, 0);
  4727. //buyEquip(21, 1);
  4728. game.tickBase(() => {
  4729. sendAutoGather();
  4730. this.isTrue = false;
  4731. my.autoAim = false;
  4732. buyEquip(6, 0);
  4733. buyEquip(21, 1);
  4734. }, 3);
  4735. }, 1);
  4736. };
  4737. /* this.spikeTickType = function() {
  4738. this.isTrue = true;
  4739. my.autoAim = true;
  4740. selectWeapon(player.weapons[0]);
  4741. buyEquip(7, 0);
  4742. buyEquip(21, 1);
  4743. sendAutoGather();
  4744. game.tickBase(() => {
  4745. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4746. selectWeapon(player.weapons[0]);
  4747. buyEquip(53, 0);
  4748. buyEquip(21, 1);
  4749. game.tickBase(() => {
  4750. sendAutoGather();
  4751. this.isTrue = false;
  4752. my.autoAim = false;
  4753. }, 1);
  4754. } else {
  4755. sendAutoGather();
  4756. this.isTrue = false;
  4757. my.autoAim = false;
  4758. }
  4759. }, 1);
  4760. };*/
  4761. this.counterType = function() {
  4762. this.isTrue = true;
  4763. my.autoAim = true;
  4764. selectWeapon(player.weapons[0]);
  4765. buyEquip(7, 0);
  4766. buyEquip(21, 1);
  4767. sendAutoGather();
  4768. game.tickBase(() => {
  4769. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4770. selectWeapon(player.weapons[0]);
  4771. buyEquip(53, 0);
  4772. buyEquip(21, 1);
  4773. game.tickBase(() => {
  4774. sendAutoGather();
  4775. this.isTrue = false;
  4776. my.autoAim = false;
  4777. }, 1);
  4778. } else {
  4779. sendAutoGather();
  4780. this.isTrue = false;
  4781. my.autoAim = false;
  4782. }
  4783. }, 1);
  4784. };
  4785. this.antiCounterType = function() {
  4786. my.autoAim = true;
  4787. this.isTrue = true;
  4788. inantiantibull = true;
  4789. selectWeapon(player.weapons[0]);
  4790. buyEquip(6, 0);
  4791. buyEquip(21, 1);
  4792. io.send("D", near.aim2);
  4793. sendAutoGather();
  4794. game.tickBase(() => {
  4795. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  4796. buyEquip(21, 1);
  4797. game.tickBase(() => {
  4798. sendAutoGather();
  4799. this.isTrue = false;
  4800. my.autoAim = false;
  4801. inantiantibull = false;
  4802. }, 1);
  4803. }, 1)
  4804. };
  4805. this.rangeType = function(type) {
  4806. this.isTrue = true;
  4807. my.autoAim = true;
  4808. if (type == "ageInsta") {
  4809. sendChat("info gived");
  4810. my.ageInsta = false;
  4811. if (player.items[5] == 18) {
  4812. place(5, near.aim2);
  4813. }
  4814. packet("a", undefined, 1);
  4815. buyEquip(22, 0);
  4816. buyEquip(21, 1);
  4817. game.tickBase(() => {
  4818. selectWeapon(player.weapons[1]);
  4819. buyEquip(53, 0);
  4820. buyEquip(21, 1);
  4821. sendAutoGather();
  4822. game.tickBase(() => {
  4823. sendUpgrade(12);
  4824. selectWeapon(player.weapons[1]);
  4825. buyEquip(53, 0);
  4826. buyEquip(21, 1);
  4827. game.tickBase(() => {
  4828. sendUpgrade(15);
  4829. selectWeapon(player.weapons[1]);
  4830. buyEquip(53, 0);
  4831. buyEquip(21, 1);
  4832. game.tickBase(() => {
  4833. sendAutoGather();
  4834. this.isTrue = false;
  4835. my.autoAim = false;
  4836. }, 1);
  4837. }, 1);
  4838. }, 1);
  4839. }, 1);
  4840. } else {
  4841. selectWeapon(player.weapons[1]);
  4842. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4843. buyEquip(53, 0);
  4844. } else {
  4845. buyEquip(20, 0);
  4846. }
  4847. buyEquip(11, 1);
  4848. sendAutoGather();
  4849. game.tickBase(() => {
  4850. sendAutoGather();
  4851. this.isTrue = false;
  4852. my.autoAim = false;
  4853. }, 1);
  4854. }
  4855. };
  4856. this.oneTickType = function() {
  4857. io.send("7113213.29154");
  4858. this.isTrue = true;
  4859. my.autoAim = true;
  4860. selectWeapon(player.weapons[1]);
  4861. buyEquip(53, 0);
  4862. buyEquip(19, 1);
  4863. packet("a", near.aim2, 1);
  4864. if (player.weapons[1] == 15) {
  4865. my.revAim = true;
  4866. sendAutoGather();
  4867. }
  4868. game.tickBase(() => {
  4869. my.revAim = false;
  4870. selectWeapon(player.weapons[0]);
  4871. buyEquip(7, 0);
  4872. buyEquip(19, 1);
  4873. packet("a", near.aim2, 1);
  4874. if (player.weapons[1] != 15) {
  4875. sendAutoGather();
  4876. }
  4877. game.tickBase(() => {
  4878. sendAutoGather();
  4879. this.isTrue = false;
  4880. my.autoAim = false;
  4881. packet("a", undefined, 1);
  4882. }, 1);
  4883. }, 1);
  4884. };
  4885. this.threeOneTickType = function() {
  4886. io.send("Tick2");
  4887. this.isTrue = true;
  4888. my.autoAim = true;
  4889. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4890. biomeGear();
  4891. buyEquip(19, 1);
  4892. packet("a", near.aim2, 1);
  4893. game.tickBase(() => {
  4894. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4895. buyEquip(53, 0);
  4896. buyEquip(19, 1);
  4897. packet("a", near.aim2, 1);
  4898. game.tickBase(() => {
  4899. selectWeapon(player.weapons[0]);
  4900. buyEquip(7, 0);
  4901. buyEquip(19, 1);
  4902. sendAutoGather();
  4903. packet("a", near.aim2, 1);
  4904. game.tickBase(() => {
  4905. sendAutoGather();
  4906. this.isTrue = false;
  4907. my.autoAim = false;
  4908. packet("a", undefined, 1);
  4909. }, 1);
  4910. }, 1);
  4911. }, 1);
  4912. };
  4913. this.kmTickType = function() {
  4914. this.isTrue = true;
  4915. my.autoAim = true;
  4916. my.revAim = true;
  4917. selectWeapon(player.weapons[1]);
  4918. buyEquip(53, 0);
  4919. buyEquip(19, 1);
  4920. sendAutoGather();
  4921. packet("a", near.aim2, 1);
  4922. game.tickBase(() => {
  4923. my.revAim = false;
  4924. selectWeapon(player.weapons[0]);
  4925. buyEquip(7, 0);
  4926. buyEquip(19, 1);
  4927. packet("a", near.aim2, 1);
  4928. game.tickBase(() => {
  4929. sendAutoGather();
  4930. this.isTrue = false;
  4931. my.autoAim = false;
  4932. packet("a", undefined, 1);
  4933. }, 1);
  4934. }, 1);
  4935. };
  4936. this.boostTickType = function() {
  4937. /*this.isTrue = true;
  4938. my.autoAim = true;
  4939. selectWeapon(player.weapons[0]);
  4940. buyEquip(53, 0);
  4941. buyEquip(19, 1);
  4942. packet("a", near.aim2);
  4943. game.tickBase(() => {
  4944. place(4, near.aim2);
  4945. selectWeapon(player.weapons[1]);
  4946. biomeGear();
  4947. buyEquip(19, 1);
  4948. sendAutoGather();
  4949. packet("a", near.aim2);
  4950. game.tickBase(() => {
  4951. selectWeapon(player.weapons[0]);
  4952. buyEquip(7, 0);
  4953. buyEquip(19, 1);
  4954. packet("a", near.aim2);
  4955. game.tickBase(() => {
  4956. sendAutoGather();
  4957. this.isTrue = false;
  4958. my.autoAim = false;
  4959. packet("a", undefined);
  4960. }, 1);
  4961. }, 1);
  4962. }, 1);*/
  4963. this.isTrue = true;
  4964. my.autoAim = true;
  4965. biomeGear();
  4966. buyEquip(19, 1);
  4967. packet("a", near.aim2, 1);
  4968. game.tickBase(() => {
  4969. if (player.weapons[1] == 15) {
  4970. my.revAim = true;
  4971. }
  4972. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  4973. buyEquip(53, 0);
  4974. buyEquip(19, 1);
  4975. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  4976. sendAutoGather();
  4977. }
  4978. packet("a", near.aim2, 1);
  4979. place(4, near.aim2);
  4980. game.tickBase(() => {
  4981. my.revAim = false;
  4982. selectWeapon(player.weapons[0]);
  4983. buyEquip(7, 0);
  4984. buyEquip(19, 1);
  4985. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  4986. sendAutoGather();
  4987. }
  4988. packet("a", near.aim2, 1);
  4989. game.tickBase(() => {
  4990. sendAutoGather();
  4991. this.isTrue = false;
  4992. my.autoAim = false;
  4993. packet("a", undefined, 1);
  4994. }, 1);
  4995. }, 1);
  4996. }, 1);
  4997. };
  4998. this.gotoGoal = function(goto, OT) {
  4999. let slowDists = (weeeee) => weeeee * config.playerScale;
  5000. let goal = {
  5001. a: goto - OT,
  5002. b: goto + OT,
  5003. c: goto - slowDists(1),
  5004. d: goto + slowDists(1),
  5005. e: goto - slowDists(2),
  5006. f: goto + slowDists(2),
  5007. g: goto - slowDists(4),
  5008. h: goto + slowDists(4)
  5009. };
  5010. let bQ = function(wwww, awwww) {
  5011. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5012. buyEquip(31, 0);
  5013. } else {
  5014. buyEquip(wwww, awwww);
  5015. }
  5016. }
  5017. if (enemy.length) {
  5018. let dst = near.dist2;
  5019. this.ticking = true;
  5020. if (dst >= goal.a && dst <= goal.b) {
  5021. bQ(22, 0);
  5022. bQ(11, 1);
  5023. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5024. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5025. }
  5026. return {
  5027. dir: undefined,
  5028. action: 1
  5029. };
  5030. } else {
  5031. if (dst < goal.a) {
  5032. if (dst >= goal.g) {
  5033. if (dst >= goal.e) {
  5034. if (dst >= goal.c) {
  5035. bQ(40, 0);
  5036. bQ(10, 1);
  5037. if (configs.none) {
  5038. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5039. } else {
  5040. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5041. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5042. }
  5043. }
  5044. } else {
  5045. bQ(22, 0);
  5046. bQ(19, 1);
  5047. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5048. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5049. }
  5050. }
  5051. } else {
  5052. bQ(6, 0);
  5053. bQ(12, 1);
  5054. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5055. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5056. }
  5057. }
  5058. } else {
  5059. biomeGear();
  5060. bQ(11, 1);
  5061. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5062. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5063. }
  5064. }
  5065. return {
  5066. dir: near.aim2 + Math.PI,
  5067. action: 0
  5068. };
  5069. } else if (dst > goal.b) {
  5070. if (dst <= goal.h) {
  5071. if (dst <= goal.f) {
  5072. if (dst <= goal.d) {
  5073. bQ(40, 0);
  5074. bQ(9, 1);
  5075. if (configs.none) {
  5076. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5077. } else {
  5078. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5079. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5080. }
  5081. }
  5082. } else {
  5083. bQ(22, 0);
  5084. bQ(19, 1);
  5085. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5086. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5087. }
  5088. }
  5089. } else {
  5090. bQ(6, 0);
  5091. bQ(12, 1);
  5092. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5093. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5094. }
  5095. }
  5096. } else {
  5097. biomeGear();
  5098. bQ(11, 1);
  5099. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5100. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5101. }
  5102. }
  5103. return {
  5104. dir: near.aim2,
  5105. action: 0
  5106. };
  5107. }
  5108. return {
  5109. dir: undefined,
  5110. action: 0
  5111. };
  5112. }
  5113. } else {
  5114. this.ticking = false;
  5115. return {
  5116. dir: undefined,
  5117. action: 0
  5118. };
  5119. }
  5120. }
  5121. /** wait 1 tick for better quality */
  5122. this.bowMovement = function() {
  5123. let moveMent = this.gotoGoal(685, 3);
  5124. if (moveMent.action) {
  5125. if (player.reloads[53] == 0 && !this.isTrue) {
  5126. this.rangeType("ageInsta");
  5127. } else {
  5128. packet("a", moveMent.dir, 1);
  5129. }
  5130. } else {
  5131. packet("a", moveMent.dir, 1);
  5132. }
  5133. },
  5134. this.tickMovement = function() {
  5135. let dist = player.weapons[1] == 9 ? 240 : 240;
  5136. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5137. let moveMent = this.gotoGoal(238, 3);
  5138. if (moveMent.action) {
  5139. if (player.reloads[53] == 0 && !this.isTrue) {
  5140. this.boostTickType();
  5141. } else {
  5142. packet("a", moveMent.dir, 1);
  5143. }
  5144. } else {
  5145. packet("a", moveMent.dir, 1);
  5146. }
  5147. },
  5148. this.kmTickMovement = function() {
  5149. let moveMent = this.gotoGoal(240, 3);
  5150. if (moveMent.action) {
  5151. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5152. this.kmTickType();
  5153. } else {
  5154. packet("a", moveMent.dir, 1);
  5155. }
  5156. } else {
  5157. packet("a", moveMent.dir, 1);
  5158. }
  5159. },
  5160. this.boostTickMovement = function() {
  5161. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  5162. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5163. let moveMent = this.gotoGoal(372, 3);
  5164. if (moveMent.action) {
  5165. if (player.reloads[53] == 0 && !this.isTrue) {
  5166. this.boostTickType();
  5167. } else {
  5168. packet("a", moveMent.dir, 1);
  5169. }
  5170. } else {
  5171. packet("a", moveMent.dir, 1);
  5172. }
  5173. }
  5174. /** wait 1 tick for better quality */
  5175. this.perfCheck = function(pl, nr) {
  5176. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5177. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5178. let pjs = {
  5179. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5180. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5181. };
  5182. 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)) {
  5183. return true;
  5184. }
  5185. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5186. 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)) {
  5187. return true;
  5188. }
  5189. });
  5190. if (finds) return false;
  5191. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5192. let tmpScale = tmp.getScale();
  5193. 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)) {
  5194. return true;
  5195. }
  5196. });
  5197. if (finds) return false;
  5198. return true;
  5199. }
  5200. }
  5201. };
  5202. class Autobuy {
  5203. constructor(buyHat, buyAcc) {
  5204. this.hat = function() {
  5205. buyHat.forEach((id) => {
  5206. let find = findID(hats, id);
  5207. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5208. });
  5209. };
  5210. this.acc = function() {
  5211. buyAcc.forEach((id) => {
  5212. let find = findID(accessories, id);
  5213. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5214. });
  5215. };
  5216. }
  5217. };
  5218.  
  5219. class Autoupgrade {
  5220. constructor() {
  5221. this.sb = function(upg) {
  5222. upg(3);
  5223. upg(17);
  5224. upg(31);
  5225. upg(23);
  5226. upg(9);
  5227. upg(38);
  5228. };
  5229. this.kh = function(upg) {
  5230. upg(3);
  5231. upg(17);
  5232. upg(31);
  5233. upg(23);
  5234. upg(10);
  5235. upg(38);
  5236. upg(4);
  5237. upg(25);
  5238. };
  5239. this.pb = function(upg) {
  5240. upg(5);
  5241. upg(17);
  5242. upg(32);
  5243. upg(23);
  5244. upg(9);
  5245. upg(38);
  5246. };
  5247. this.ph = function(upg) {
  5248. upg(5);
  5249. upg(17);
  5250. upg(32);
  5251. upg(23);
  5252. upg(10);
  5253. upg(38);
  5254. upg(28);
  5255. upg(25);
  5256. };
  5257. this.db = function(upg) {
  5258. upg(7);
  5259. upg(17);
  5260. upg(31);
  5261. upg(23);
  5262. upg(9);
  5263. upg(34);
  5264. };
  5265. };
  5266. };
  5267.  
  5268. class Damages {
  5269. constructor(items) {
  5270. // 0.75 1 1.125 1.5
  5271. this.calcDmg = function(dmg, val) {
  5272. return dmg * val;
  5273. };
  5274. this.getAllDamage = function(dmg) {
  5275. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5276. };
  5277. this.weapons = [];
  5278. for (let i = 0; i < items.weapons.length; i++) {
  5279. let wp = items.weapons[i];
  5280. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5281. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5282. this[name] = this.weapons[i];
  5283. }
  5284. }
  5285. }
  5286.  
  5287. /** CLASS CODES */
  5288. // jumpscare code warn
  5289. let tmpList = [];
  5290. var bianosTick = false;
  5291.  
  5292.  
  5293. // LOADING:
  5294. let UTILS = new Utils();
  5295. let items = new Items();
  5296. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5297. let store = new Store();
  5298. let hats = store.hats;
  5299. let accessories = store.accessories;
  5300. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5301. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5302. let textManager = new Textmanager();
  5303.  
  5304. let traps = new Traps(UTILS, items);
  5305. let instaC = new Instakill();
  5306. let autoBuy = new Autobuy([6,7, 22, 12, 53, 40], [11 , 13, 19]);
  5307. let autoUpgrade = new Autoupgrade();
  5308.  
  5309. let lastDeath;
  5310. let minimapData;
  5311. let mapMarker = {};
  5312. let mapPings = [];
  5313. let tmpPing;
  5314.  
  5315. let breakTrackers = [];
  5316.  
  5317. let pathFindTest = 0;
  5318. let grid = [];
  5319. let pathFind = {
  5320. active: false,
  5321. grid: 40,
  5322. scale: 1440,
  5323. x: 14400,
  5324. y: 14400,
  5325. chaseNear: false,
  5326. array: [],
  5327. lastX: this.grid / 2,
  5328. lastY: this.grid / 2
  5329. };
  5330.  
  5331. function sendChat(message) {
  5332. packet("6", message.slice(0, 30));
  5333. }
  5334.  
  5335. let runAtNextTick = [];
  5336.  
  5337. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5338. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5339. let projOffset = config.playerScale * 2;
  5340. let projXY = {
  5341. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5342. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5343. };
  5344. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5345. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5346. })[0];
  5347. if (nearPlayer) {
  5348. if (indx == 1) {
  5349. nearPlayer.shooting[53] = 1;
  5350. } else {
  5351. nearPlayer.shootIndex = weaponIndx;
  5352. nearPlayer.shooting[1] = 1;
  5353. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5354. }
  5355. }
  5356. }
  5357. let projectileCount = 0;
  5358.  
  5359. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5360. if (!tmpObj.isTeam(player)) {
  5361. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5362. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5363. tmpObj.bowThreat[weaponIndex]++;
  5364. if (index == 5) {
  5365. projectileCount++;
  5366. }
  5367. setTimeout(() => {
  5368. tmpObj.bowThreat[weaponIndex]--;
  5369. if (index == 5) {
  5370. projectileCount--;
  5371. }
  5372. }, range / speed);
  5373. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5374. place(1, tmpObj.aim2);
  5375. my.anti0Tick = 4;
  5376. if (!my.antiSync) {
  5377. antiSyncHealing(4);
  5378. }
  5379. } else {
  5380. if (projectileCount >= 2) {
  5381. place(1, tmpObj.aim2);
  5382. my.anti0Tick = 4;
  5383. if (!my.antiSync) {
  5384. antiSyncHealing(4);
  5385. }
  5386. }
  5387. }
  5388. }
  5389. }
  5390. }
  5391.  
  5392. // SHOW ITEM INFO:
  5393. function showItemInfo(item, isWeapon, isStoreItem) {
  5394. if (player && item) {
  5395. UTILS.removeAllChildren(itemInfoHolder);
  5396. itemInfoHolder.classList.add("visible");
  5397. UTILS.generateElement({
  5398. id: "itemInfoName",
  5399. text: UTILS.capitalizeFirst(item.name),
  5400. parent: itemInfoHolder
  5401. });
  5402. UTILS.generateElement({
  5403. id: "itemInfoDesc",
  5404. text: item.desc,
  5405. parent: itemInfoHolder
  5406. });
  5407. if (isStoreItem) {
  5408.  
  5409. } else if (isWeapon) {
  5410. UTILS.generateElement({
  5411. class: "itemInfoReq",
  5412. text: !item.type ? "primary" : "secondary",
  5413. parent: itemInfoHolder
  5414. });
  5415. } else {
  5416. for (let i = 0; i < item.req.length; i += 2) {
  5417. UTILS.generateElement({
  5418. class: "itemInfoReq",
  5419. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5420. parent: itemInfoHolder
  5421. });
  5422. }
  5423. if (item.group.limit) {
  5424. UTILS.generateElement({
  5425. class: "itemInfoLmt",
  5426. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5427. parent: itemInfoHolder
  5428. });
  5429. }
  5430. }
  5431. } else {
  5432. itemInfoHolder.classList.remove("visible");
  5433. }
  5434. }
  5435.  
  5436.  
  5437. // RESIZE:
  5438. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5439.  
  5440. function resize() {
  5441. screenWidth = window.innerWidth;
  5442. screenHeight = window.innerHeight;
  5443. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5444. gameCanvas.width = screenWidth * pixelDensity;
  5445. gameCanvas.height = screenHeight * pixelDensity;
  5446. gameCanvas.style.width = screenWidth + "px";
  5447. gameCanvas.style.height = screenHeight + "px";
  5448. mainContext.setTransform(
  5449. scaleFillNative, 0,
  5450. 0, scaleFillNative,
  5451. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5452. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5453. );
  5454. }
  5455. resize();
  5456.  
  5457. // MOUSE INPUT:
  5458. var usingTouch;
  5459. const mals = document.getElementById('touch-controls-fullscreen');
  5460. mals.style.display = 'block';
  5461. mals.addEventListener("mousemove", gameInput, false);
  5462.  
  5463. function gameInput(e) {
  5464. mouseX = e.clientX;
  5465. mouseY = e.clientY;
  5466. }
  5467. let clicks = {
  5468. left: false,
  5469. middle: false,
  5470. right: false,
  5471. };
  5472. let clicked = {
  5473. g: false
  5474. }
  5475. mals.addEventListener("mousedown", mouseDown, false);
  5476.  
  5477. function mouseDown(e) {
  5478. if (attackState != 1) {
  5479. attackState = 1;
  5480. if (e.button == 0) {
  5481. clicks.left = true;
  5482. } else if (e.button == 2) {
  5483. clicks.right = true;
  5484. }
  5485. }
  5486. }
  5487. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5488.  
  5489. function mouseUp(e) {
  5490. if (attackState != 0) {
  5491. attackState = 0;
  5492. if (e.button == 0) {
  5493. clicks.left = false;
  5494. } else if (e.button == 1) {
  5495. clicks.middle = false;
  5496. } else if (e.button == 2) {
  5497. clicks.right = false;
  5498. }
  5499. }
  5500. }
  5501. mals.addEventListener("wheel", wheel, false);
  5502.  
  5503. function wheel(e) {
  5504. if (e.deltaY < 0) {
  5505. wbe += 0.005
  5506. maxScreenWidth = config.maxScreenWidth * wbe;
  5507. maxScreenHeight = config.maxScreenHeight * wbe;
  5508. resize()
  5509. } else {
  5510. wbe -= 0.005
  5511. maxScreenWidth = config.maxScreenWidth * wbe;
  5512. maxScreenHeight = config.maxScreenHeight * wbe;
  5513. resize()
  5514. }
  5515. }
  5516.  
  5517. // INPUT UTILS:
  5518. function getMoveDir() {
  5519. let dx = 0;
  5520. let dy = 0;
  5521. for (let key in moveKeys) {
  5522. let tmpDir = moveKeys[key];
  5523. dx += !!keys[key] * tmpDir[0];
  5524. dy += !!keys[key] * tmpDir[1];
  5525. }
  5526. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5527. }
  5528.  
  5529. function getSafeDir() {
  5530. if (!player)
  5531. return 0;
  5532. if (!player.lockDir) {
  5533. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5534. }
  5535. return lastDir || 0;
  5536. }
  5537. let plusDir = 0;
  5538. let lastSpin = Date.now();
  5539. function getAttackDir(debug) {
  5540. if (debug) {
  5541. if (!player)
  5542. return "0";
  5543. 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))
  5544. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  5545. else
  5546. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5547. lastDir = "getSafeDir()";
  5548. else
  5549. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5550. lastDir = "traps.aim";
  5551. else
  5552. if (!player.lockDir) {
  5553. if (configs.noDir) return "undefined";
  5554. lastDir = "getSafeDir()";
  5555. }
  5556. return lastDir;
  5557. } else {
  5558. if (!player)
  5559. return 0;
  5560. 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))
  5561. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5562. else
  5563. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5564. lastDir = getSafeDir();
  5565. else
  5566. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5567. lastDir = traps.aim;
  5568. else
  5569. if (!player.lockDir) {
  5570. if (configs.noDir) return undefined;
  5571. lastDir = getSafeDir();
  5572. }
  5573. return lastDir || 0;
  5574. }
  5575. }
  5576.  
  5577. function getVisualDir() {
  5578. if (!player)
  5579. return 0;
  5580. lastDir = getSafeDir();
  5581. return lastDir || 0;
  5582. }
  5583.  
  5584. // KEYS:
  5585. function keysActive() {
  5586. return (allianceMenu.style.display != "block" &&
  5587. chatHolder.style.display != "block" &&
  5588. !menuCBFocus);
  5589. }
  5590.  
  5591. function toggleMenuChat() {
  5592. if (menuChatDiv.style.display != "none") {
  5593. // chatHolder.style.display = "none";
  5594. // if (menuChatBox.value != "") {
  5595. //commands[command.slice(1)]
  5596. let cmd = function(command) {
  5597. return {
  5598. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5599. fv: commands[command.slice(1).split(" ")[0]]
  5600. }
  5601. }
  5602. let command = cmd(menuChatBox.value);
  5603. if (command.found) {
  5604. if (typeof command.fv.action === "function") {
  5605. command.fv.action(menuChatBox.value);
  5606. }
  5607. } else {
  5608. sendChat(menuChatBox.value);
  5609. }
  5610. menuChatBox.value = "";
  5611. menuChatBox.blur();
  5612. } else {
  5613. if (menuCBFocus) {
  5614. menuChatBox.blur();
  5615. } else {
  5616. menuChatBox.focus();
  5617. }
  5618. }
  5619. }
  5620.  
  5621. function keyDown(event) {
  5622. let keyNum = event.which || event.keyCode || 0;
  5623. if (player && player.alive && keysActive()) {
  5624. if (!keys[keyNum]) {
  5625. keys[keyNum] = 1;
  5626. macro[event.key] = 1;
  5627. if (keyNum == 27) {
  5628. openMenu = !openMenu;
  5629. $("#menuDiv").toggle();
  5630. } else if (keyNum == 69) {
  5631. sendAutoGather();
  5632. } else if (keyNum == 67) {
  5633. updateMapMarker();
  5634. } else if (keyNum == 71) {
  5635. clicked.g = !clicked.g
  5636. } else if (player.weapons[keyNum - 49] != undefined) {
  5637. player.weaponCode = player.weapons[keyNum - 49];
  5638. } else if (moveKeys[keyNum]) {
  5639. sendMoveDir();
  5640. } else if (event.key == "m") {
  5641. mills.placeSpawnPads = !mills.placeSpawnPads;
  5642. } else if (event.key == "z") {
  5643. mills.place = !mills.place;
  5644. } else if (event.key == "Z") {
  5645. typeof window.debug == "function" && window.debug();
  5646. } else if (keyNum == 32) {
  5647. packet("d", 1, getSafeDir(), 1);
  5648. packet("d", 0, getSafeDir(), 1);
  5649. }
  5650. }
  5651. }
  5652. }
  5653. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5654.  
  5655. function keyUp(event) {
  5656. if (player && player.alive) {
  5657. let keyNum = event.which || event.keyCode || 0;
  5658. if (keyNum == 13) {
  5659. toggleMenuChat();
  5660. } else if (keysActive()) {
  5661. if (keys[keyNum]) {
  5662. keys[keyNum] = 0;
  5663. macro[event.key] = 0;
  5664. if (moveKeys[keyNum]) {
  5665. sendMoveDir();
  5666. }
  5667. }
  5668. }
  5669. }
  5670. }
  5671. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5672.  
  5673. function sendMoveDir() {
  5674. let newMoveDir = getMoveDir();
  5675. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5676. if (!my.autoPush) {
  5677. packet("a", newMoveDir, 1);
  5678. }
  5679. lastMoveDir = newMoveDir;
  5680. }
  5681. }
  5682.  
  5683. // BUTTON EVENTS:
  5684. function bindEvents() {}
  5685. bindEvents();
  5686.  
  5687. /** PATHFIND TEST */
  5688. function chechPathColl(tmp) {
  5689. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  5690. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  5691. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  5692. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  5693. }
  5694.  
  5695. function checkObject() {
  5696. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  5697. for (let y = 0; y < pathFind.grid; y++) {
  5698. grid[y] = [];
  5699. for (let x = 0; x < pathFind.grid; x++) {
  5700. let tmpXY = {
  5701. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  5702. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  5703. }
  5704. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  5705. pathFind.lastX = x;
  5706. pathFind.lastY = y;
  5707. grid[y][x] = 0;
  5708. continue;
  5709. }
  5710. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  5711. if (find) {
  5712. if (find.trap) {
  5713. grid[y][x] = 0;
  5714. continue;
  5715. }
  5716. grid[y][x] = 1;
  5717. } else {
  5718. grid[y][x] = 0;
  5719. }
  5720. }
  5721. }
  5722. }
  5723.  
  5724. function createPath() {
  5725. grid = [];
  5726. checkObject();
  5727. }
  5728.  
  5729. function Pathfinder() {
  5730. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  5731. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  5732. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5733. packet("a", undefined, 1);
  5734. } else {
  5735. createPath();
  5736. easystar.setGrid(grid);
  5737. easystar.setAcceptableTiles([0]);
  5738. easystar.enableDiagonals();
  5739. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  5740. if (path === null) {
  5741. pathFind.array = [];
  5742. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5743. packet("a", undefined, 1);
  5744. } else {
  5745. packet("a", near.aim2, 1);
  5746. }
  5747. } else {
  5748. pathFind.array = path;
  5749. if (pathFind.array.length > 1) {
  5750. let tmpXY = {
  5751. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  5752. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  5753. }
  5754. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  5755. }
  5756. }
  5757. });
  5758. easystar.calculate();
  5759. }
  5760. }
  5761. }
  5762. /** PATHFIND TEST */
  5763.  
  5764. // ITEM COUNT DISPLAY:
  5765. let isItemSetted = [];
  5766.  
  5767. function updateItemCountDisplay(index = undefined) {
  5768. for (let i = 3; i < items.list.length; ++i) {
  5769. let id = items.list[i].group.id;
  5770. let tmpI = items.weapons.length + i;
  5771. if (!isItemSetted[tmpI]) {
  5772. isItemSetted[tmpI] = document.createElement("div");
  5773. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5774. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5775. isItemSetted[tmpI].style = `
  5776. display: block;
  5777. position: absolute;
  5778. padding-left: 5px;
  5779. font-size: 2em;
  5780. color: #fff;
  5781. `;
  5782. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5783. } else {
  5784. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5785. }
  5786. }
  5787. }
  5788.  
  5789. // AUTOPUSH:
  5790. function autoPush() {
  5791. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  5792. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5793. })[0];
  5794. if (nearTrap) {
  5795. let spike = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  5796. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5797. })[0];
  5798. if (spike) {
  5799. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  5800.  
  5801. /*let pos = {
  5802. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5803. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5804. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  5805. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  5806. };
  5807. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  5808. let tmpScale = tmp.getScale();
  5809. 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)) {
  5810. return true;
  5811. }
  5812. });
  5813. if (finds) {
  5814. if (my.autoPush) {
  5815. my.autoPush = false;
  5816. packet("a", lastMoveDir || undefined, 1);
  5817. }
  5818. } else {*/
  5819. my.autoPush = true;
  5820. sendChat("!I'm pushing you :3!");
  5821. my.pushData = {
  5822. x: spike.x + Math.cos(pushAngle),
  5823. y: spike.y + Math.sin(pushAngle),
  5824. x2: player.x2+30,
  5825. y2: player.y2+30
  5826. };
  5827.  
  5828. let point = {
  5829. x: near.x2 + Math.cos(pushAngle) * 30,
  5830. y: near.y2 + Math.sin(pushAngle) * 60,
  5831. }
  5832.  
  5833. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  5834.  
  5835. packet("a", dir, 1)
  5836. /*let scale = (player.scale / 10);
  5837. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5838. packet("a", near.aim2, 1);
  5839. } else {
  5840. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  5841. }*/
  5842. //}
  5843. } else {
  5844. if (my.autoPush) {
  5845. my.autoPush = false;
  5846. packet("a", lastMoveDir || undefined, 1);
  5847. }
  5848. }
  5849. } else {
  5850. if (my.autoPush) {
  5851. my.autoPush = false;
  5852. packet("a", lastMoveDir || undefined, 1);
  5853. }
  5854. }
  5855. }
  5856.  
  5857.  
  5858. class AutoPush {
  5859. socket = null;
  5860.  
  5861. findIntersect(vec, vec1, vec2) {
  5862. // Find point of vec1 and vec2 intersection
  5863. const delta = Math.hypot(vec1.x - vec2.x, vec1.y - vec2.y) / 2;
  5864. const tang = Math.tan((vec1.y - vec2.y) / (vec1.x - vec2.x));
  5865. const vec3x = Math.cos(tang) * delta;
  5866. const vec3y = Math.sin(tang) * delta;
  5867. // Find angle from vec to vec3
  5868. const theta = Math.tan((vec.y - vec3y) / (vec.x - vec3x));
  5869.  
  5870. return theta;
  5871. };
  5872.  
  5873. pushEnemy(player, enemy, spike) {
  5874. const angle = this.findIntersect(enemy, spike, player);
  5875. const dist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
  5876.  
  5877. if (dist > 180) return;
  5878.  
  5879. this.socket.send("a", angle);
  5880. };
  5881.  
  5882. constructor(socket) {
  5883. this.socket = socket;
  5884. }
  5885. }
  5886.  
  5887. // ADD DEAD PLAYER:
  5888. function addDeadPlayer(tmpObj) {
  5889. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  5890. }
  5891.  
  5892. /** APPLY SOCKET CODES */
  5893.  
  5894. // SET INIT DATA:
  5895. function setInitData(data) {
  5896. alliances = data.teams;
  5897. }
  5898.  
  5899. // SETUP GAME:
  5900. function setupGame(yourSID) {
  5901. keys = {};
  5902. macro = {};
  5903. playerSID = yourSID;
  5904. attackState = 0;
  5905. inGame = true;
  5906. packet("d", 0, getAttackDir(), 1);
  5907. my.ageInsta = true;
  5908. if (firstSetup) {
  5909. firstSetup = false;
  5910. gameObjects.length = 0;
  5911. liztobj.length = 0;
  5912. }
  5913. }
  5914.  
  5915. // ADD NEW PLAYER:
  5916. function addPlayer(data, isYou) {
  5917. let tmpPlayer = findPlayerByID(data[0]);
  5918. if (!tmpPlayer) {
  5919. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  5920. objectManager, players, ais, items, hats, accessories);
  5921. players.push(tmpPlayer);
  5922. if (data[1] != playerSID) {
  5923. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5924. }
  5925. } else {
  5926. if (data[1] != playerSID) {
  5927. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5928. }
  5929. }
  5930. tmpPlayer.spawn(isYou ? true : null);
  5931. tmpPlayer.visible = false;
  5932. tmpPlayer.oldPos = {
  5933. x2: undefined,
  5934. y2: undefined
  5935. };
  5936. tmpPlayer.x2 = undefined;
  5937. tmpPlayer.y2 = undefined;
  5938. tmpPlayer.x3 = undefined;
  5939. tmpPlayer.y3 = undefined;
  5940. tmpPlayer.setData(data);
  5941. if (isYou) {
  5942. if (!player) {
  5943. window.prepareUI(tmpPlayer);
  5944. }
  5945. player = tmpPlayer;
  5946. camX = player.x;
  5947. camY = player.y;
  5948. my.lastDir = 0;
  5949. updateItems();
  5950. updateAge();
  5951. updateItemCountDisplay();
  5952. if (player.skins[7]) {
  5953. my.reSync = true;
  5954. }
  5955. }
  5956. }
  5957.  
  5958. // REMOVE PLAYER:
  5959. function removePlayer(id) {
  5960. for (let i = 0; i < players.length; i++) {
  5961. if (players[i].id == id) {
  5962. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  5963. players.splice(i, 1);
  5964. break;
  5965. }
  5966. }
  5967. }
  5968.  
  5969. // UPDATE HEALTH:
  5970. function updateHealth(sid, value) {
  5971. tmpObj = findPlayerBySID(sid);
  5972. if (tmpObj) {
  5973. tmpObj.oldHealth = tmpObj.health;
  5974. tmpObj.health = value;
  5975. tmpObj.judgeShame();
  5976. if (tmpObj.oldHealth > tmpObj.health) {
  5977. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  5978. advHeal.push([sid, value, tmpObj.damaged]);
  5979. } else {}
  5980. if (tmpObj.health <= 0) {
  5981. /*bots.forEach((hmm) => {
  5982. hmm.whyDie = tmpObj.name;
  5983. });*/
  5984. }
  5985. }
  5986. }
  5987.  
  5988.  
  5989. // KILL PLAYER:
  5990. function killPlayer() {
  5991. inGame = false;
  5992. lastDeath = {
  5993. x: player.x,
  5994. y: player.y,
  5995. };
  5996. if (configs.autoRespawn) {
  5997. getEl("diedText").style.display = "none";
  5998. packet("M", {
  5999. name: lastsp[0],
  6000. moofoll: lastsp[1],
  6001. skin: lastsp[2]
  6002. });
  6003. }
  6004. }
  6005.  
  6006. // UPDATE PLAYER ITEM VALUES:
  6007. function updateItemCounts(index, value) {
  6008. if (player) {
  6009. player.itemCounts[index] = value;
  6010. updateItemCountDisplay(index);
  6011. }
  6012. }
  6013.  
  6014. // UPDATE AGE:
  6015. function updateAge(xp, mxp, age) {
  6016. if (xp != undefined)
  6017. player.XP = xp;
  6018. if (mxp != undefined)
  6019. player.maxXP = mxp;
  6020. if (age != undefined)
  6021. player.age = age;
  6022. }
  6023.  
  6024. // UPDATE UPGRADES:
  6025. function updateUpgrades(points, age) {
  6026. player.upgradePoints = points;
  6027. player.upgrAge = age;
  6028. if (points > 0) {
  6029. tmpList.length = 0;
  6030. UTILS.removeAllChildren(upgradeHolder);
  6031. for (let i = 0; i < items.weapons.length; ++i) {
  6032. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6033. let e = UTILS.generateElement({
  6034. id: "upgradeItem" + i,
  6035. class: "actionBarItem",
  6036. onmouseout: function() {
  6037. showItemInfo();
  6038. },
  6039. parent: upgradeHolder
  6040. });
  6041. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6042. tmpList.push(i);
  6043. }
  6044. }
  6045. for (let i = 0; i < items.list.length; ++i) {
  6046. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6047. let tmpI = (items.weapons.length + i);
  6048. let e = UTILS.generateElement({
  6049. id: "upgradeItem" + tmpI,
  6050. class: "actionBarItem",
  6051. onmouseout: function() {
  6052. showItemInfo();
  6053. },
  6054. parent: upgradeHolder
  6055. });
  6056. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6057. tmpList.push(tmpI);
  6058. }
  6059. }
  6060. for (let i = 0; i < tmpList.length; i++) {
  6061. (function(i) {
  6062. let tmpItem = getEl('upgradeItem' + i);
  6063. // tmpItem.onmouseover = function() {
  6064. // if (items.weapons[i]) {
  6065. // showItemInfo(items.weapons[i], true);
  6066. // } else {
  6067. // showItemInfo(items.list[i - items.weapons.length]);
  6068. // }
  6069. // };
  6070. tmpItem.onclick = UTILS.checkTrusted(function() {
  6071. packet("H", i);
  6072. });
  6073. UTILS.hookTouchEvents(tmpItem);
  6074. })(tmpList[i]);
  6075. }
  6076. if (tmpList.length) {
  6077. upgradeHolder.style.display = "block";
  6078. upgradeCounter.style.display = "block";
  6079. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6080. } else {
  6081. upgradeHolder.style.display = "none";
  6082. upgradeCounter.style.display = "none";
  6083. showItemInfo();
  6084. }
  6085. } else {
  6086. upgradeHolder.style.display = "none";
  6087. upgradeCounter.style.display = "none";
  6088. showItemInfo();
  6089. }
  6090. }
  6091.  
  6092. // KILL OBJECT:
  6093. function killObject(sid) {
  6094. let findObj = findObjectBySid(sid);
  6095. objectManager.disableBySid(sid);
  6096. if (player) {
  6097. for (let i = 0; i < breakObjects.length; i++) {
  6098. if (breakObjects[i].sid == sid) {
  6099. breakObjects.splice(i, 1);
  6100. break;
  6101. }
  6102. }
  6103. if (!player.canSee(findObj)) {
  6104. breakTrackers.push({
  6105. x: findObj.x,
  6106. y: findObj.y
  6107. });
  6108. }
  6109. if (breakTrackers.length > 8) {
  6110. breakTrackers.shift();
  6111. }
  6112. traps.replacer(findObj);
  6113. }
  6114. }
  6115.  
  6116. // KILL ALL OBJECTS BY A PLAYER:
  6117. function killObjects(sid) {
  6118. if (player) objectManager.removeAllItems(sid);
  6119. }
  6120. function setTickout(doo, timeout) {
  6121. if (!ticks.manage[ticks.tick + timeout]) {
  6122. ticks.manage[ticks.tick + timeout] = [doo];
  6123. } else {
  6124. ticks.manage[ticks.tick + timeout].push(doo);
  6125. }
  6126. }
  6127.  
  6128. function caf(e, t) {
  6129. try {
  6130. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6131. } catch (e) {
  6132. return 0;
  6133. }
  6134. }
  6135.  
  6136. let found = false;
  6137. let autoQ = false;
  6138.  
  6139. let autos = {
  6140. insta: {
  6141. todo: false,
  6142. wait: false,
  6143. count: 4,
  6144. shame: 5
  6145. },
  6146. bull: false,
  6147. antibull: 0,
  6148. reloaded: false,
  6149. stopspin: true
  6150. }
  6151.  
  6152. // UPDATE PLAYER DATA:
  6153. function updatePlayers(data) {
  6154. // if(player.shameCount > 0) {
  6155. // my.reSync = true;
  6156. // } else {
  6157. // my.reSync = false;
  6158. // }
  6159.  
  6160. // let movementPrediction = {
  6161. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6162. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6163. // }
  6164.  
  6165. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6166.  
  6167. // potentialzpiketick.forEach((obj) => {
  6168. // if(cdf(obj, player) <= 200) {
  6169. // packet('a', undefined);
  6170. // }
  6171. // })
  6172.  
  6173. // let newPos = {
  6174. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6175. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6176. // }
  6177.  
  6178. function getAngleDifference(angle1, angle2) {
  6179. // Normalize the angles to be between 0 and 2π
  6180. angle1 = angle1 % (2 * Math.PI);
  6181. angle2 = angle2 % (2 * Math.PI);
  6182.  
  6183. // Calculate the absolute difference between the angles
  6184. let diff = Math.abs(angle1 - angle2);
  6185.  
  6186. // Adjust the difference to be between 0 and π
  6187. if (diff > Math.PI) {
  6188. diff = (2 * Math.PI) - diff;
  6189. }
  6190.  
  6191. return diff;
  6192. }
  6193.  
  6194. // function smartMove(oneTickMove) {
  6195. // let dir = player.moveDir;
  6196.  
  6197. // let found = false
  6198. // 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))
  6199. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6200.  
  6201. // let newPos = {
  6202. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6203. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6204. // }
  6205.  
  6206. // for (let i = 0; i < spikes.length; i++) {
  6207. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6208. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6209. // }
  6210. // }
  6211.  
  6212.  
  6213.  
  6214.  
  6215.  
  6216. // if (found != false && !traps.inTrap) {
  6217. // packet("a", undefined);
  6218. // } else {
  6219. // packet("a", dir);
  6220. // }
  6221. // player.oldPos.x2 = player.x2;
  6222. // player.oldPos.y2 = player.y2;
  6223. // }
  6224. // function detectEnemySpikeCollisions(tmpObj) {
  6225. // 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));
  6226. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6227. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6228. // let enemy = {
  6229. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6230. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6231. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6232. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6233. // }
  6234. // let found = false;
  6235. // for (let i = 0; i < spikes.length; i++) {
  6236. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6237. // found = true;
  6238. // }
  6239. // }
  6240.  
  6241. // // player.oldPos.x2 = tmpObj.x2;
  6242. // // player.oldPos.y2 = tmpObj.y2;
  6243. // }
  6244.  
  6245. game.tick++;
  6246. enemy = [];
  6247. nears = [];
  6248. near = [];
  6249. game.tickSpeed = performance.now() - game.lastTick;
  6250. game.lastTick = performance.now();
  6251. players.forEach((tmp) => {
  6252. tmp.forcePos = !tmp.visible;
  6253. tmp.visible = false;
  6254. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6255. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6256. });
  6257. for (let i = 0; i < data.length;) {
  6258. tmpObj = findPlayerBySID(data[i]);
  6259. if (tmpObj) {
  6260. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6261. tmpObj.t2 = game.lastTick;
  6262. tmpObj.oldPos.x2 = tmpObj.x2;
  6263. tmpObj.oldPos.y2 = tmpObj.y2;
  6264. tmpObj.x1 = tmpObj.x;
  6265. tmpObj.y1 = tmpObj.y;
  6266. tmpObj.x2 = data[i + 1];
  6267. tmpObj.y2 = data[i + 2];
  6268. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6269. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6270. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6271. tmpObj.d2 = data[i + 3];
  6272. tmpObj.dt = 0;
  6273. tmpObj.buildIndex = data[i + 4];
  6274. tmpObj.weaponIndex = data[i + 5];
  6275. tmpObj.weaponVariant = data[i + 6];
  6276. tmpObj.team = data[i + 7];
  6277. tmpObj.isLeader = data[i + 8];
  6278. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6279. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6280. tmpObj.skinIndex = data[i + 9];
  6281. tmpObj.tailIndex = data[i + 10];
  6282. tmpObj.iconIndex = data[i + 11];
  6283. tmpObj.zIndex = data[i + 12];
  6284. tmpObj.visible = true;
  6285. tmpObj.update(game.tickSpeed);
  6286. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6287. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6288. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6289. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6290. tmpObj.damageThreat = 0;
  6291. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6292. tmpObj.addShameTimer();
  6293. }
  6294. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6295. tmpObj.shameTimer = 0;
  6296. tmpObj.shameCount = 0;
  6297. if (tmpObj == player) {
  6298. healer();
  6299. }
  6300. }
  6301.  
  6302. botSkts.forEach((bot) => {
  6303. bot.showName = 'YEAHHH'
  6304. })
  6305.  
  6306. for(let i = 0; i < players.length; i++) {
  6307. for(let aa = 0; aa < botSkts.length; aa++) {
  6308. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6309.  
  6310. }
  6311. }
  6312.  
  6313. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6314. autoQ = true;
  6315. healer();
  6316. } else {
  6317. if (autoQ) {
  6318. healer();
  6319. }
  6320. autoQ = false;
  6321. }
  6322.  
  6323.  
  6324. if (tmpObj == player) {
  6325. if (liztobj.length) {
  6326. liztobj.forEach((tmp) => {
  6327. tmp.onNear = false;
  6328. if (tmp.active) {
  6329. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6330. tmp.onNear = true;
  6331. }
  6332. if (tmp.isItem && tmp.owner) {
  6333. 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)) {
  6334. tmp.breakObj = true;
  6335. breakObjects.push({
  6336. x: tmp.x,
  6337. y: tmp.y,
  6338. sid: tmp.sid
  6339. });
  6340. }
  6341. }
  6342. }
  6343. });
  6344. 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) {
  6345. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6346. })[0];
  6347. if (nearTrap) {
  6348. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6349. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6350. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6351.  
  6352. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6353. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6354. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6355. traps.inTrap = true;
  6356. sendChat("IADO's anti:on");
  6357. traps.info = nearTrap;
  6358. } else {
  6359. traps.inTrap = false;
  6360. traps.info = {};
  6361. }
  6362. } else {
  6363. traps.inTrap = false;
  6364. }
  6365. }
  6366. if (tmpObj.weaponIndex < 9) {
  6367. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6368. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6369. } else if (tmpObj.weaponIndex > 8) {
  6370. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6371. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6372. }
  6373. }
  6374. i += 13;
  6375. }
  6376. if (textManager.stack.length) {
  6377. let stacks = [];
  6378. let notstacks = [];
  6379. let num = 0;
  6380. let num2 = 0;
  6381. let pos = {
  6382. x: null,
  6383. y: null
  6384. };
  6385. let pos2 = {
  6386. x: null,
  6387. y: null
  6388. }
  6389. textManager.stack.forEach((text) => {
  6390. if (text.value >= 0) {
  6391. if (num == 0) pos = {
  6392. x: text.x,
  6393. y: text.y
  6394. };
  6395. num += Math.abs(text.value);
  6396. } else {
  6397. if (num2 == 0) pos2 = {
  6398. x: text.x,
  6399. y: text.y
  6400. };
  6401. num2 += Math.abs(text.value);
  6402. }
  6403. });
  6404. if (num2 > 0) {
  6405. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#FF0000");
  6406. }
  6407. if (num > 0) {
  6408. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6409. }
  6410. textManager.stack = [];
  6411. }
  6412. if (runAtNextTick.length) {
  6413. runAtNextTick.forEach((tmp) => {
  6414. checkProjectileHolder(...tmp);
  6415. });
  6416. runAtNextTick = [];
  6417. }
  6418. for (let i = 0; i < data.length;) {
  6419. tmpObj = findPlayerBySID(data[i]);
  6420. if (tmpObj) {
  6421. if (!tmpObj.isTeam(player)) {
  6422. enemy.push(tmpObj);
  6423. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6424. nears.push(tmpObj);
  6425. }
  6426. }
  6427. tmpObj.manageReload();
  6428. if (tmpObj != player) {
  6429. tmpObj.addDamageThreat(player);
  6430. }
  6431. }
  6432. i += 13;
  6433. }
  6434. /*projectiles.forEach((proj) => {
  6435. tmpObj = proj;
  6436. if (tmpObj.active) {
  6437. tmpObj.tickUpdate(game.tickSpeed);
  6438. }
  6439. });*/
  6440. if (player && player.alive) {
  6441. if (enemy.length) {
  6442. near = enemy.sort(function(tmp1, tmp2) {
  6443. return tmp1.dist2 - tmp2.dist2;
  6444. })[0];
  6445. } else {
  6446. // console.log("no enemy");
  6447. }
  6448. if (game.tickQueue[game.tick]) {
  6449. game.tickQueue[game.tick].forEach((action) => {
  6450. action();
  6451. });
  6452. game.tickQueue[game.tick] = null;
  6453. }
  6454. if (advHeal.length) {
  6455. advHeal.forEach((updHealth) => {
  6456. if (window.pingTime < 150) {
  6457. let sid = updHealth[0];
  6458. let value = updHealth[1];
  6459. let totalDamage = 100 - value
  6460. let damaged = updHealth[2];
  6461. tmpObj = findPlayerBySID(sid);
  6462. let bullTicked = false;
  6463. if (tmpObj == player) {
  6464. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6465. if (my.reSync) {
  6466. my.reSync = false;
  6467. tmpObj.setBullTick = true;
  6468. }
  6469. bullTicked = true;
  6470. }
  6471. if (inGame) {
  6472. let attackers = getAttacker(damaged);
  6473. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6474. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6475. let healTimeout = 140 - window.pingTime;
  6476. let dmg = 100 - player.health;
  6477. let slowHeal = function (timer, tickBase) {
  6478. if (!tickBase) {
  6479. setTimeout(() => {
  6480. healer();
  6481. }, timer);
  6482. } else {
  6483. game.tickBase(() => {
  6484. healer()
  6485. }, 2)
  6486. }
  6487. }
  6488. if (getEl("healingBeta").checked) {
  6489. if (enemy.length) {
  6490. if ([0, 7, 8].includes(near.primaryIndex)) {
  6491. if (damaged < 75) {
  6492. slowHeal(healTimeout)
  6493. } else {
  6494. healer()
  6495. }
  6496. }
  6497. if ([1, 2, 6].includes(near.primaryIndex)) {
  6498. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  6499. healer()
  6500. } else {
  6501. slowHeal(healTimeout)
  6502. }
  6503. }
  6504. if (near.primaryIndex == 3) {
  6505. if (near.secondaryIndex == 15) {
  6506. if (near.primaryVariant < 2) {
  6507. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6508. tmpObj.canEmpAnti = true
  6509. tmpObj.antiTimer = game.tick
  6510. healer()
  6511. } else {
  6512. slowHeal(healTimeout)
  6513. }
  6514. } else {
  6515. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6516. tmpObj.canEmpAnti = true
  6517. tmpObj.antiTimer = game.tick
  6518. healer()
  6519. } else {
  6520. slowHeal(healTimeout)
  6521. }
  6522. }
  6523. } else {
  6524. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6525. healer()
  6526. } else {
  6527. slowHeal(healTimeout)
  6528. }
  6529. }
  6530. }
  6531. if (near.primaryIndex == 4) {
  6532. if (near.primaryVariant >= 1) {
  6533. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6534. healer()
  6535. } else {
  6536. slowHeal(healTimeout)
  6537. }
  6538. } else {
  6539. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  6540. healer()
  6541. } else {
  6542. slowHeal(healTimeout)
  6543. }
  6544. }
  6545. }
  6546. if ([undefined, 5].includes(near.primaryIndex)) {
  6547. if (near.secondaryIndex == 10) {
  6548. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  6549. healer()
  6550. } else {
  6551. slowHeal(healTimeout)
  6552. }
  6553. } else
  6554. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  6555. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  6556. healer()
  6557. } else {
  6558. slowHeal(healTimeout)
  6559. }
  6560. } else
  6561. if ([undefined || 15].includes(near.secondaryIndex)) {
  6562. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  6563. if (tmpObj.shameCount < 5) {
  6564. healer()
  6565. } else {
  6566. slowHeal(healTimeout)
  6567. }
  6568. } else {
  6569. slowHeal(healTimeout)
  6570. }
  6571. } else
  6572. if ([9, 12, 13].includes(near.secondaryIndex)) {
  6573. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  6574. healer()
  6575. } else {
  6576. slowHeal(healTimeout)
  6577. }
  6578. } else {
  6579. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  6580. healer()
  6581. } else {
  6582. slowHeal(healTimeout)
  6583. }
  6584. }
  6585. }
  6586. if (near.primaryIndex == 6) {
  6587. if (near.secondaryIndex == 15) {
  6588. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6589. healer()
  6590. } else {
  6591. slowHeal(healTimeout)
  6592. }
  6593. } else {
  6594. if (damaged >= 70 && tmpObj.shameCount < 4) {
  6595. healer()
  6596. } else {
  6597. slowHeal(healTimeout)
  6598. }
  6599. }
  6600. }
  6601. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6602. } else {
  6603. if (damaged >= 70) {
  6604. healer()
  6605. } else {
  6606. slowHeal(healTimeout)
  6607. }
  6608. }
  6609. } else {
  6610. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  6611. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6612. tmpObj.canEmpAnti = true;
  6613. } else {
  6614. player.soldierAnti = true;
  6615. }
  6616. tmpObj.antiTimer = game.tick;
  6617. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  6618. if (tmpObj.shameCount < shame) {
  6619. healer();
  6620. } else {
  6621. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6622. slowHeal(healTimeout)
  6623. } else {
  6624. slowHeal(healTimeout, 1)
  6625. }
  6626. }
  6627. } else {
  6628. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6629. slowHeal(healTimeout)
  6630. } else {
  6631. slowHeal(healTimeout, 1)
  6632. }
  6633. }
  6634. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6635. }
  6636. } else {
  6637. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6638. tmpObj.setPoisonTick = true;
  6639. }
  6640. }
  6641. }
  6642. } else {
  6643. let [sid, value, damaged] = updHealth;
  6644. let totalDamage = 100 - value;
  6645. let tmpObj = findPlayerBySID(sid);
  6646. let bullTicked = false;
  6647.  
  6648. if (tmpObj == player) {
  6649. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6650. if (my.reSync) {
  6651. my.reSync = false;
  6652. tmpObj.setBullTick = true;
  6653. bullTicked = true;
  6654. }
  6655. }
  6656. if (inGame) {
  6657. let attackers = getAttacker(damaged);
  6658. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6659. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6660. let healTimeout = 60;
  6661. let dmg = 100 - player.health;
  6662. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  6663.  
  6664. let slowHeal = function (timer, tickBase) {
  6665. if (!tickBase) setTimeout(() => healer(), timer);
  6666. else game.tickBase(() => healer(), 2);
  6667. };
  6668.  
  6669. if (getEl("healingBeta").checked) {
  6670. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 :
  6671. [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 :
  6672. [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 :
  6673. near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 :
  6674. near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6675. damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 :
  6676. near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6677. damaged >= 25 && player.damageThreat + dmg >= 95;
  6678.  
  6679. canHealFast ? healer() : slowHeal(healTimeout);
  6680. } else {
  6681. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1;
  6682.  
  6683. if (canHealFast) {
  6684. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) tmpObj.canEmpAnti = true;
  6685. else player.soldierAnti = true;
  6686. tmpObj.antiTimer = game.tick;
  6687. if (tmpObj.shameCount < shameCountThreshold) healer();
  6688. else slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6689. } else {
  6690. slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6691. }
  6692. }
  6693. } else {
  6694. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6695. tmpObj.setPoisonTick = true;
  6696. }
  6697. }
  6698. }
  6699. }
  6700. });
  6701. advHeal = [];
  6702. }
  6703. players.forEach((tmp) => {
  6704. if (!tmp.visible && player != tmp) {
  6705. tmp.reloads = {
  6706. 0: 0,
  6707. 1: 0,
  6708. 2: 0,
  6709. 3: 0,
  6710. 4: 0,
  6711. 5: 0,
  6712. 6: 0,
  6713. 7: 0,
  6714. 8: 0,
  6715. 9: 0,
  6716. 10: 0,
  6717. 11: 0,
  6718. 12: 0,
  6719. 13: 0,
  6720. 14: 0,
  6721. 15: 0,
  6722. 53: 0,
  6723. };
  6724. }
  6725. if (tmp.setBullTick) {
  6726. tmp.bullTimer = 0;
  6727. }
  6728. if (tmp.setPoisonTick) {
  6729. tmp.poisonTimer = 0;
  6730. }
  6731. tmp.updateTimer();
  6732. });
  6733. if (inGame) {
  6734. if (enemy.length) {
  6735. if (player.canEmpAnti) {
  6736. player.canEmpAnti = false;
  6737. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6738. if (near.reloads[53] == 0) {
  6739. player.empAnti = true;
  6740. player.soldierAnti = false;
  6741. //modLog("EmpAnti");
  6742. } else {
  6743. player.empAnti = false;
  6744. player.soldierAnti = true;
  6745. //modLog("SoldierAnti");
  6746. }
  6747. }
  6748. }
  6749. 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) {
  6750. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6751. })[0];
  6752. if (prehit) {
  6753. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6754. instaC.canSpikeTick = true;
  6755. instaC.syncHit = true;
  6756. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6757. instaC.revTick = true;
  6758. }
  6759. }
  6760. }
  6761. let antiSpikeTick = gameObjects.filter(tmp => tmp.dmg && tmp.active && !tmp.isTeamObject(player) && UTILS.getDist(tmp, player, 0, 3) < (tmp.scale + player.scale)).sort(function(a, b) {
  6762. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6763. })[0];
  6764. if (antiSpikeTick && !traps.inTrap) {
  6765. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  6766. my.anti0Tick = 1;
  6767. sendChat("What a lucky ducky you are!");
  6768. player.chat.count = 2000;
  6769. }
  6770. }
  6771. }
  6772. if ((useWasd ? true : ((player.checkCanInsta(true) >= 220 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate))) && instaC.perfCheck(player, near)) {
  6773. if (player.checkCanInsta(true) >= 220) {
  6774. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6775. } else {
  6776. instaC.nobull = false;
  6777. }
  6778. instaC.can = true;
  6779. } else {
  6780. instaC.can = false;
  6781. }
  6782. macro.q && place(0, getAttackDir());
  6783. macro.f && place(4, getSafeDir());
  6784. macro.v && place(2, getSafeDir());
  6785. macro.y && place(5, getSafeDir());
  6786. macro.h && place(player.getItemType(22), getSafeDir());
  6787. macro.n && place(3, getSafeDir());
  6788. if (game.tick % 1 == 0) {
  6789. if (mills.place) {
  6790. let plcAng = 7.7;
  6791. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6792. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6793. }
  6794. } else {
  6795. if (mills.placeSpawnPads) {
  6796. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6797. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6798. }
  6799. }
  6800. }
  6801. }
  6802. if (instaC.can) {
  6803. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  6804. }
  6805. if (instaC.canCounter) {
  6806. instaC.canCounter = false;
  6807. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6808. instaC.counterType();
  6809. }
  6810. }
  6811. if (instaC.canSpikeTick) {
  6812. instaC.canSpikeTick = false;
  6813. if (instaC.revTick) {
  6814. instaC.revTick = false;
  6815. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6816. instaC.changeType("rev");
  6817. chch(null, "[RevSyncHit]", "yellow");
  6818. }
  6819. } else {
  6820. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6821. instaC.spikeTickType();
  6822. if (instaC.syncHit) {
  6823. chch(null, "[SyncHit]", "yellow");
  6824. }
  6825. }
  6826. }
  6827. }
  6828. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6829. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6830. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6831. }
  6832. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6833. sendAutoGather();
  6834. my.waitHit = 1;
  6835. game.tickBase(() => {
  6836. sendAutoGather();
  6837. my.waitHit = 0;
  6838. }, 1);
  6839. }
  6840. }
  6841. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6842. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6843. selectWeapon(player.weapons[0]);
  6844. }
  6845. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6846. sendAutoGather();
  6847. my.waitHit = 1;
  6848. game.tickBase(() => {
  6849. sendAutoGather();
  6850. my.waitHit = 0;
  6851. }, 1);
  6852. }
  6853. }
  6854. if (traps.inTrap) {
  6855. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6856. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6857. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6858. }
  6859. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6860. sendAutoGather();
  6861. my.waitHit = 1;
  6862. game.tickBase(() => {
  6863. sendAutoGather();
  6864. my.waitHit = 0;
  6865. }, 1);
  6866. }
  6867. }
  6868. }
  6869. if (clicked.g && !traps.inTrap) {
  6870. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6871. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6872. instaC.bowMovement();
  6873. } else {
  6874. instaC.rangeType();
  6875. }
  6876. }
  6877. }
  6878. if (macro.t && !traps.inTrap) {
  6879. 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))) {
  6880. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6881. }
  6882. }
  6883. if (macro["."] && !traps.inTrap) {
  6884. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6885. instaC.boostTickMovement();
  6886. }
  6887. }
  6888. 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)) {
  6889. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6890. if (!my.reloaded) {
  6891. my.reloaded = true;
  6892. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6893. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6894. selectWeapon(player.weapons[fastSpeed]);
  6895. }
  6896. }
  6897. // if(useWasd) {
  6898. // if (!autos.stopspin) {
  6899. // setTimeout(()=>{
  6900. // autos.stopspin = true;
  6901. // }, 375);
  6902. // }
  6903. // }
  6904. } else {
  6905. my.reloaded = false;
  6906. if(useWasd) {
  6907. autos.stopspin = false;
  6908. }
  6909. if (player.reloads[player.weapons[0]] > 0) {
  6910. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6911. selectWeapon(player.weapons[0]);
  6912. }
  6913. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6914. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6915. selectWeapon(player.weapons[1]);
  6916. }
  6917. if(useWasd) {
  6918. if (!autos.stopspin) {
  6919. setTimeout(()=>{
  6920. autos.stopspin = true;
  6921. }, 750);
  6922. }
  6923. }
  6924. }
  6925. }
  6926. }
  6927. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6928. traps.autoPlace();
  6929. }
  6930. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6931. packet("D", getAttackDir());
  6932. }
  6933. let hatChanger = function() {
  6934. if (my.anti0Tick > 0) {
  6935. buyEquip(6, 0);
  6936. } else {
  6937. if (clicks.left || clicks.right) {
  6938. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6939. buyEquip(7, 0);
  6940. buyEquip(13, 1);
  6941. } else {
  6942. if (clicks.left) {
  6943. 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);
  6944. } else if (clicks.right) {
  6945. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  6946. }
  6947. }
  6948. } else if (traps.inTrap) {
  6949. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6950. buyEquip(40, 0);
  6951. } else {
  6952. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6953. buyEquip(7, 0);
  6954. buyEquip(13, 1);
  6955.  
  6956. } else {
  6957. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 22 : 6, 0);
  6958. }
  6959. }
  6960. } else {
  6961. if (player.empAnti || player.soldierAnti) {
  6962. buyEquip(player.empAnti ? 22 : 6, 0);
  6963. buyEquip(13, 1);
  6964. } else {
  6965. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6966. buyEquip(7, 0);
  6967. buyEquip(13, 1);
  6968. } else {
  6969. if (near.dist2 <= 300) {
  6970. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  6971. } else {
  6972. biomeGear(1);
  6973. }
  6974. }
  6975. }
  6976. }
  6977. }
  6978. }
  6979. let accChanger = function () {
  6980. if (near.dist2 <= 270) {
  6981. if (clicks.left) {
  6982. buyEquip(13, 1);
  6983. } else if (!clicks.left){
  6984. buyEquip(13, 1);
  6985. }
  6986. }
  6987. else if (clicks.left) {
  6988. buyEquip(19,1);
  6989. }
  6990. else {
  6991. buyEquip(11, 1);
  6992. }
  6993. }
  6994. let wasdGears = function() {
  6995. if (my.anti0Tick > 0) {
  6996. buyEquip(12, 0);
  6997. } else {
  6998. if (clicks.left || clicks.right) {
  6999. if (clicks.left) {
  7000. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7001. } else if (clicks.right) {
  7002. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7003. }
  7004. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7005. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7006. } else if (traps.inTrap) {
  7007. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7008. buyEquip(40, 0);
  7009. } else {
  7010. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7011. buyEquip(7, 0);
  7012. } else {
  7013. buyEquip(player.empAnti ? 22 : 6, 0);
  7014. }
  7015. }
  7016. } else {
  7017. if (player.empAnti) {
  7018. buyEquip(22, 0);
  7019. } else {
  7020. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7021. buyEquip(7, 0);
  7022. } else {
  7023. buyEquip(6, 0);
  7024. }
  7025. }
  7026. }
  7027. }
  7028. if (clicks.left || clicks.right) {
  7029. if (clicks.left) {
  7030. buyEquip(0, 1);
  7031. }
  7032. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7033. buyEquip(0, 1);
  7034. } else if (traps.inTrap) {
  7035. buyEquip(0, 1);
  7036. } else {
  7037. buyEquip(11, 1);
  7038. }
  7039. }
  7040. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7041. if (useWasd) {
  7042. wasdGears();
  7043. } else {
  7044. hatChanger();
  7045. accChanger();
  7046. }
  7047. }
  7048. //lastMoveDir = getSafeDir();
  7049. //packet("a", lastMoveDir, 1);
  7050. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7051. autoPush();
  7052. } else {
  7053. if (my.autoPush) {
  7054. my.autoPush = false;
  7055. packet("a", lastMoveDir || undefined, 1);
  7056. }
  7057. }
  7058. if (!my.autoPush && pathFind.active) {
  7059. Pathfinder();
  7060. }
  7061. if (instaC.ticking) {
  7062. instaC.ticking = false;
  7063. }
  7064. if (instaC.syncHit) {
  7065. instaC.syncHit = false;
  7066. }
  7067. if (player.empAnti) {
  7068. player.empAnti = false;
  7069. }
  7070. if (player.soldierAnti) {
  7071. player.soldierAnti = false;
  7072. }
  7073. if (my.anti0Tick > 0) {
  7074. my.anti0Tick--;
  7075. }
  7076. if (traps.replaced) {
  7077. traps.replaced = false;
  7078. }
  7079. if (traps.antiTrapped) {
  7080. traps.antiTrapped = false;
  7081. }
  7082. const getPotentialDamage = (build, user) => {
  7083. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7084. const weap = user.weapons[weapIndex];
  7085. if (player.reloads[weap]) return 0;
  7086. const weapon = items.weapons[weap];
  7087. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7088. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7089. };
  7090.  
  7091. const AutoReplace = () => {
  7092. const replaceable = [];
  7093. const playerX = player.x;
  7094. const playerY = player.y;
  7095. const gameObjectCount = gameObjects.length;
  7096.  
  7097. for (let i = 0; i < gameObjectCount; i++) {
  7098. const build = gameObjects[i];
  7099. if (build.isItem && build.active && build.health > 0) {
  7100. const item = items.list[build.id];
  7101. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7102. const inDistance = cdf(build, player) <= posDist * 2;
  7103. if (inDistance) {
  7104. let canDeal = 0;
  7105. const playersCount = players.length;
  7106. for (let j = 0; j < playersCount; j++) {
  7107. canDeal += getPotentialDamage(build, players[j]);
  7108. }
  7109. if (build.health <= canDeal) {
  7110. replaceable.push(build);
  7111. }
  7112. }
  7113. }
  7114. }
  7115.  
  7116. const findPlacementAngle = (player, itemId, build) => {
  7117. if (!build) return null;
  7118. const MAX_ANGLE = 2 * Math.PI;
  7119. const ANGLE_STEP = Math.PI / 360;
  7120. const item = items.list[player.items[itemId]];
  7121. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7122. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7123.  
  7124. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7125. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7126. for (let angle of angles) {
  7127. return angle;
  7128. }
  7129. }
  7130. return null;
  7131. };
  7132.  
  7133. const replace = (() => {
  7134. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7135. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7136. const buildId = spike ? 4 : 2;
  7137.  
  7138. replaceable.forEach(build => {
  7139. let angle = findPlacementAngle(player, buildId, build);
  7140. if (angle !== null) {
  7141. place(buildId, angle);
  7142. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7143. }
  7144. });
  7145. });
  7146.  
  7147. if (near && near.dist3 <= 360) {
  7148. replace();
  7149. }
  7150. replace;
  7151. }
  7152. }
  7153. }
  7154. if (botSkts.length) {
  7155. botSkts.forEach((bots) => {
  7156. if (true) {
  7157. bots[0].showName = 'YEAHHH';
  7158. }
  7159. });
  7160. }
  7161. }
  7162. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7163. 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)
  7164.  
  7165. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7166. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7167. selectWeapon(player.weapons[1])
  7168. buyEquip(40, 0);
  7169. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7170. setTickout( () => {
  7171. buyEquip(6, 0)
  7172. }, 1);
  7173. }
  7174. }
  7175. }
  7176. }
  7177. function ez(context, x, y) {
  7178. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7179. context.beginPath();
  7180. context.fill();
  7181. context.closePath();
  7182. context.globalAlpha = 1;
  7183. }
  7184. // UPDATE LEADERBOARD:
  7185. function updateLeaderboard(data) {
  7186. lastLeaderboardData = data;
  7187. return;
  7188. UTILS.removeAllChildren(leaderboardData);
  7189. let tmpC = 1;
  7190. for (let i = 0; i < data.length; i += 3) {
  7191. (function(i) {
  7192. UTILS.generateElement({
  7193. class: "leaderHolder",
  7194. parent: leaderboardData,
  7195. children: [
  7196. UTILS.generateElement({
  7197. class: "leaderboardItem",
  7198. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7199. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7200. }),
  7201. UTILS.generateElement({
  7202. class: "leaderScore",
  7203. text: UTILS.sFormat(data[i + 2]) || "0"
  7204. })
  7205. ]
  7206. });
  7207. })(i);
  7208. tmpC++;
  7209. }
  7210. }
  7211.  
  7212. // LOAD GAME OBJECT:
  7213. function loadGameObject(data) {
  7214. for (let i = 0; i < data.length;) {
  7215. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7216. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7217. sid: data[i + 7]
  7218. } : null));
  7219. // sid, x, y, dir, s, type, data, setSID, owner
  7220. /*let dist = UTILS.getDist({
  7221. x: data[i + 1],
  7222. y: data[i + 2]
  7223. }, player, 0, 2);
  7224. let aim = UTILS.getDirect({
  7225. x: data[i + 1],
  7226. y: data[i + 2]
  7227. }, player, 0, 2);
  7228. find = findObjectBySid(data[i]);
  7229. if (data[i + 6] == 15) {
  7230. if (find && !find.isTeamObject(player)) {
  7231. if (dist <= 100) {
  7232. traps.dist = dist;
  7233. traps.aim = aim;
  7234. traps.protect(aim);
  7235. }
  7236. }
  7237. }*/
  7238. i += 8;
  7239. }
  7240. }
  7241.  
  7242. // ADD AI:
  7243. function loadAI(data) {
  7244. for (let i = 0; i < ais.length; ++i) {
  7245. ais[i].forcePos = !ais[i].visible;
  7246. ais[i].visible = false;
  7247. }
  7248. if (data) {
  7249. let tmpTime = performance.now();
  7250. for (let i = 0; i < data.length;) {
  7251. tmpObj = findAIBySID(data[i]);
  7252. if (tmpObj) {
  7253. tmpObj.index = data[i + 1];
  7254. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7255. tmpObj.t2 = tmpTime;
  7256. tmpObj.x1 = tmpObj.x;
  7257. tmpObj.y1 = tmpObj.y;
  7258. tmpObj.x2 = data[i + 2];
  7259. tmpObj.y2 = data[i + 3];
  7260. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7261. tmpObj.d2 = data[i + 4];
  7262. tmpObj.health = data[i + 5];
  7263. tmpObj.dt = 0;
  7264. tmpObj.visible = true;
  7265. } else {
  7266. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7267. tmpObj.x2 = tmpObj.x;
  7268. tmpObj.y2 = tmpObj.y;
  7269. tmpObj.d2 = tmpObj.dir;
  7270. tmpObj.health = data[i + 5];
  7271. if (!aiManager.aiTypes[data[i + 1]].name)
  7272. tmpObj.name = config.cowNames[data[i + 6]];
  7273. tmpObj.forcePos = true;
  7274. tmpObj.sid = data[i];
  7275. tmpObj.visible = true;
  7276. }
  7277. i += 7;
  7278. }
  7279. }
  7280. }
  7281.  
  7282. // ANIMATE AI:
  7283. function animateAI(sid) {
  7284. tmpObj = findAIBySID(sid);
  7285. if (tmpObj) tmpObj.startAnim();
  7286. }
  7287.  
  7288. // GATHER ANIMATION:
  7289. function gatherAnimation(sid, didHit, index) {
  7290. tmpObj = findPlayerBySID(sid);
  7291. if (tmpObj) {
  7292. tmpObj.startAnim(didHit, index);
  7293. tmpObj.gatherIndex = index;
  7294. tmpObj.gathering = 1;
  7295.  
  7296. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7297. // healer();
  7298.  
  7299. if (didHit) {
  7300. let tmpObjects = objectManager.hitObj;
  7301. objectManager.hitObj = [];
  7302. game.tickBase(() => {
  7303. // refind
  7304. tmpObj = findPlayerBySID(sid);
  7305. 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);
  7306. tmpObjects.forEach((healthy) => {
  7307. healthy.health -= val;
  7308. });
  7309. }, 1);
  7310. }
  7311. }
  7312. }
  7313.  
  7314. // WIGGLE GAME OBJECT:
  7315. function wiggleGameObject(dir, sid) {
  7316. tmpObj = findObjectBySid(sid);
  7317. if (tmpObj) {
  7318. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7319. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7320. if (tmpObj.health) {
  7321. objectManager.hitObj.push(tmpObj);
  7322. }
  7323. }
  7324. }
  7325.  
  7326. // SHOOT TURRET:
  7327. function shootTurret(sid, dir) {
  7328. tmpObj = findObjectBySid(sid);
  7329. if (tmpObj) {
  7330. if (config.anotherVisual) {
  7331. tmpObj.lastDir = dir;
  7332. } else {
  7333. tmpObj.dir = dir;
  7334. }
  7335. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7336. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7337. }
  7338. }
  7339.  
  7340. // UPDATE PLAYER VALUE:
  7341. function updatePlayerValue(index, value, updateView) {
  7342. if (player) {
  7343. player[index] = value;
  7344. if (index == "points") {
  7345. if (configs.autoBuy) {
  7346. autoBuy.hat();
  7347. autoBuy.acc();
  7348. }
  7349. } else if (index == "kills") {
  7350. if (configs.killChat) {
  7351. sendChat("Kids Annihilated: "+value+"");
  7352. setTimeout(() => {
  7353. sendChat(" - Get good - ");
  7354. setTimeout(() => {
  7355. sendChat("Mod by Mr-IADO lol");
  7356. }, 1000);
  7357. }, 1000);
  7358. }
  7359. }
  7360. }
  7361. }
  7362.  
  7363.  
  7364.  
  7365. // ACTION BAR:
  7366. function updateItems(data, wpn) {
  7367. if (data) {
  7368. if (wpn) {
  7369. player.weapons = data;
  7370. player.primaryIndex = player.weapons[0];
  7371. player.secondaryIndex = player.weapons[1];
  7372. if (!instaC.isTrue) {
  7373. selectWeapon(player.weapons[0]);
  7374. }
  7375. } else {
  7376. player.items = data;
  7377. }
  7378. }
  7379.  
  7380. for (let i = 0; i < items.list.length; i++) {
  7381. let tmpI = items.weapons.length + i;
  7382. let actionBarItem = getEl("actionBarItem" + tmpI);
  7383. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7384. // Add shadow to the element
  7385. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7386. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7387.  
  7388. }
  7389.  
  7390. for (let i = 0; i < items.weapons.length; i++) {
  7391. let actionBarItem = getEl("actionBarItem" + i);
  7392. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7393. // Add shadow to the element
  7394. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7395. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7396. }
  7397.  
  7398. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7399. if (kms) {
  7400. getEl("actionBarItem3").style.display = "none";
  7401. getEl("actionBarItem4").style.display = "inline-block";
  7402. }
  7403. }
  7404.  
  7405. // ADD PROJECTILE:
  7406. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7407. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7408. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7409. }
  7410.  
  7411. // REMOVE PROJECTILE:
  7412. function remProjectile(sid, range) {
  7413. for (let i = 0; i < projectiles.length; ++i) {
  7414. if (projectiles[i].sid == sid) {
  7415. projectiles[i].range = range;
  7416. let tmpObjects = objectManager.hitObj;
  7417. objectManager.hitObj = [];
  7418. game.tickBase(() => {
  7419. let val = projectiles[i].dmg;
  7420. tmpObjects.forEach((healthy) => {
  7421. if (healthy.projDmg) {
  7422. healthy.health -= val;
  7423. }
  7424. });
  7425. }, 1);
  7426. }
  7427. }
  7428. }
  7429.  
  7430. // lol this useless,,, fr
  7431. let noob = false;
  7432. let serverReady = true;
  7433. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7434. let wssws = isProd ? "wss" : "ws";
  7435. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7436. let withSync = false;
  7437. project.binaryType = "arraybuffer";
  7438. project.onmessage = function(msg) {
  7439. let data = msg.data;
  7440. if (data == "isready") {
  7441. serverReady = true;
  7442. }
  7443. if (data == "fine") {
  7444. noob = false;
  7445. }
  7446.  
  7447. if (data == "tezt") {
  7448. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7449. }
  7450. if (data == "yeswearesyncer") {
  7451. // let delay = Date.now() - wsDelay;
  7452. withSync = true;
  7453. if (player) {
  7454. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7455. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7456. }
  7457. }
  7458. };
  7459. project.onopen = function() {
  7460. var gameTitle = getEl("gameName");
  7461. gameTitle.innerText = "Moo Moo";
  7462. };
  7463.  
  7464. // SHOW ALLIANCE MENU:
  7465. function allianceNotification(sid, name) {
  7466. let findBotSID = findSID(bots, sid);
  7467. if (findBotSID) {}
  7468. }
  7469.  
  7470. function setPlayerTeam(team, isOwner) {
  7471. if (player) {
  7472. player.team = team;
  7473. player.isOwner = isOwner;
  7474. if (team == null)
  7475. alliancePlayers = [];
  7476. }
  7477. }
  7478.  
  7479. function setAlliancePlayers(data) {
  7480. alliancePlayers = data;
  7481. }
  7482.  
  7483. // STORE MENU:
  7484. function updateStoreItems(type, id, index) {
  7485. if (index) {
  7486. if (!type)
  7487. player.tails[id] = 1;
  7488. else {
  7489. player.latestTail = id;
  7490. }
  7491. } else {
  7492. if (!type)
  7493. player.skins[id] = 1,
  7494. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7495. else {
  7496. player.latestSkin = id;
  7497. }
  7498. }
  7499. }
  7500.  
  7501.  
  7502. // SEND MESSAGE:
  7503. function receiveChat(sid, message) {
  7504. if (/img/i.test(message)) return; // Anti img kick
  7505. if (/iframe/i.test(message)) return;
  7506. let kawaii = false;
  7507. let tmpPlayer = findPlayerBySID(sid);
  7508. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7509. tmpPlayer.chatMessage = message;
  7510. tmpPlayer.chatCountdown = config.chatCountdown;
  7511. if (message.includes("mod")) {
  7512. setTimeout(() => {
  7513. packet("6", "IADO's Skidded mod");
  7514. }, 200);
  7515. setTimeout(() => {
  7516. packet("6", "Mod edited by IADO");
  7517. }, 200);
  7518. }
  7519. }
  7520.  
  7521. // MINIMAP:
  7522. function updateMinimap(data) {
  7523. minimapData = data;
  7524. }
  7525.  
  7526. // SHOW ANIM TEXT:
  7527. function showText(x, y, value, type) {
  7528. // if (config.anotherVisual) {
  7529. textManager.stack.push({
  7530. x: x,
  7531. y: y,
  7532. value: value
  7533. });
  7534. // } else {
  7535. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7536. // }
  7537. }
  7538.  
  7539. /** APPLY SOCKET CODES */
  7540.  
  7541. // BOT:
  7542. let bots = [];
  7543. let ranLocation = {
  7544. x: UTILS.randInt(35, 14365),
  7545. y: UTILS.randInt(35, 14365)
  7546. };
  7547. setInterval(() => {
  7548. ranLocation = {
  7549. x: UTILS.randInt(35, 14365),
  7550. y: UTILS.randInt(35, 14365)
  7551. };
  7552. }, 60000);
  7553. class Bot {
  7554. constructor(id, sid, hats, accessories) {
  7555. this.millPlace = true;
  7556. this.id = id;
  7557. this.sid = sid;
  7558. this.team = null;
  7559. this.skinIndex = 0;
  7560. this.tailIndex = 0;
  7561. this.hitTime = 0;
  7562. this.iconIndex = 0;
  7563. this.enemy = [];
  7564. this.near = [];
  7565. this.dist2 = 0;
  7566. this.aim2 = 0;
  7567. this.tick = 0;
  7568. this.itemCounts = {};
  7569. this.latestSkin = 0;
  7570. this.latestTail = 0;
  7571. this.points = 0;
  7572. this.tails = {};
  7573. for (let i = 0; i < accessories.length; ++i) {
  7574. if (accessories[i].price <= 0)
  7575. this.tails[accessories[i].id] = 1;
  7576. }
  7577. this.skins = {};
  7578. for (let i = 0; i < hats.length; ++i) {
  7579. if (hats[i].price <= 0)
  7580. this.skins[hats[i].id] = 1;
  7581. }
  7582. this.spawn = function(moofoll) {
  7583. this.upgraded = 0;
  7584. this.enemy = [];
  7585. this.near = [];
  7586. this.active = true;
  7587. this.alive = true;
  7588. this.lockMove = false;
  7589. this.lockDir = false;
  7590. this.minimapCounter = 0;
  7591. this.chatCountdown = 0;
  7592. this.shameCount = 0;
  7593. this.shameTimer = 0;
  7594. this.sentTo = {};
  7595. this.gathering = 0;
  7596. this.autoGather = 0;
  7597. this.animTime = 0;
  7598. this.animSpeed = 0;
  7599. this.mouseState = 0;
  7600. this.buildIndex = -1;
  7601. this.weaponIndex = 0;
  7602. this.dmgOverTime = {};
  7603. this.noMovTimer = 0;
  7604. this.maxXP = 300;
  7605. this.XP = 0;
  7606. this.age = 1;
  7607. this.kills = 0;
  7608. this.upgrAge = 2;
  7609. this.upgradePoints = 0;
  7610. this.x = 0;
  7611. this.y = 0;
  7612. this.zIndex = 0;
  7613. this.xVel = 0;
  7614. this.yVel = 0;
  7615. this.slowMult = 1;
  7616. this.dir = 0;
  7617. this.nDir = 0;
  7618. this.dirPlus = 0;
  7619. this.targetDir = 0;
  7620. this.targetAngle = 0;
  7621. this.maxHealth = 100;
  7622. this.health = this.maxHealth;
  7623. this.oldHealth = this.maxHealth;
  7624. this.scale = config.playerScale;
  7625. this.speed = config.playerSpeed;
  7626. this.resetMoveDir();
  7627. this.resetResources(moofoll);
  7628. this.items = [0, 3, 6, 10];
  7629. this.weapons = [0];
  7630. this.shootCount = 0;
  7631. this.weaponXP = [];
  7632. this.isBot = false;
  7633. this.reloads = {
  7634. 0: 0,
  7635. 1: 0,
  7636. 2: 0,
  7637. 3: 0,
  7638. 4: 0,
  7639. 5: 0,
  7640. 6: 0,
  7641. 7: 0,
  7642. 8: 0,
  7643. 9: 0,
  7644. 10: 0,
  7645. 11: 0,
  7646. 12: 0,
  7647. 13: 0,
  7648. 14: 0,
  7649. 15: 0,
  7650. 53: 0,
  7651. };
  7652. this.timeZinceZpawn = 0;
  7653. this.whyDie = "";
  7654. this.clearRadius = false;
  7655. this.circlee = 0;
  7656. };
  7657.  
  7658. // RESET MOVE DIR:
  7659. this.resetMoveDir = function() {
  7660. this.moveDir = undefined;
  7661. };
  7662.  
  7663. // RESET RESOURCES:
  7664. this.resetResources = function(moofoll) {
  7665. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7666. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7667. }
  7668. };
  7669.  
  7670. // SET DATA:
  7671. this.setData = function(data) {
  7672. this.id = data[0];
  7673. this.sid = data[1];
  7674. this.name = data[2];
  7675. this.x = data[3];
  7676. this.y = data[4];
  7677. this.dir = data[5];
  7678. this.health = data[6];
  7679. this.maxHealth = data[7];
  7680. this.scale = data[8];
  7681. this.skinColor = data[9];
  7682. };
  7683.  
  7684.  
  7685. // SHAME SYSTEM:
  7686. this.judgeShame = function() {
  7687. if (this.oldHealth < this.health) {
  7688. if (this.hitTime) {
  7689. let timeSinceHit = this.tick - this.hitTime;
  7690. this.hitTime = 0;
  7691. if (timeSinceHit < 2) {
  7692. this.lastshamecount = this.shameCount;
  7693. this.shameCount++;
  7694. } else {
  7695. this.lastshamecount = this.shameCount;
  7696. this.shameCount = Math.max(0, this.shameCount - 2);
  7697. }
  7698. }
  7699. } else if (this.oldHealth > this.health) {
  7700. this.hitTime = this.tick;
  7701. }
  7702. };
  7703.  
  7704. // CHECK TEAM
  7705. this.isTeam = function (tmpObj) {
  7706. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  7707.  
  7708. };
  7709. // UPDATE WEAPON RELOAD:
  7710. this.manageReloadaa = function() {
  7711. if (this.shooting[53]) {
  7712. this.shooting[53] = 0;
  7713. this.reloads[53] = (2500 - 1000/9);
  7714. } else {
  7715. if (this.reloads[53] > 0) {
  7716. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7717. }
  7718. }
  7719. if (this.gathering || this.shooting[1]) {
  7720. if (this.gathering) {
  7721. this.gathering = 0;
  7722. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7723. this.attacked = true;
  7724. }
  7725. if (this.shooting[1]) {
  7726. this.shooting[1] = 0;
  7727. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7728. this.attacked = true;
  7729. }
  7730. } else {
  7731. this.attacked = false;
  7732. if (this.buildIndex < 0) {
  7733. if (this.reloads[this.weaponIndex] > 0) {
  7734. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7735. }
  7736. }
  7737. }
  7738. };
  7739.  
  7740. this.closeSockets = function(websc) {
  7741. websc.close();
  7742. };
  7743.  
  7744. this.whyDieChat = function(websc, whydie) {
  7745. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  7746. };
  7747. }
  7748. };
  7749.  
  7750. class BotObject {
  7751. constructor(sid) {
  7752. this.sid = sid;
  7753. // INIT:
  7754. this.init = function(x, y, dir, scale, type, data, owner) {
  7755. data = data || {};
  7756. this.active = true;
  7757. this.x = x;
  7758. this.y = y;
  7759. this.scale = scale;
  7760. this.owner = owner;
  7761. this.id = data.id;
  7762. this.dmg = data.dmg;
  7763. this.trap = data.trap;
  7764. this.teleport = data.teleport;
  7765. this.isItem = this.id != undefined;
  7766. };
  7767.  
  7768. }
  7769. };
  7770. class BotObjManager {
  7771. constructor(botObj, fOS) {
  7772. // DISABLE OBJ:
  7773. this.disableObj = function(obj) {
  7774. obj.active = false;
  7775. if (config.anotherVisual) {} else {
  7776. obj.alive = false;
  7777. }
  7778. };
  7779.  
  7780. // ADD NEW:
  7781. let tmpObj;
  7782. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7783. tmpObj = fOS(sid);
  7784. if (!tmpObj) {
  7785. tmpObj = botObj.find((tmp) => !tmp.active);
  7786. if (!tmpObj) {
  7787. tmpObj = new BotObject(sid);
  7788. botObj.push(tmpObj);
  7789. }
  7790. }
  7791. if (setSID) {
  7792. tmpObj.sid = sid;
  7793. }
  7794. tmpObj.init(x, y, dir, s, type, data, owner);
  7795. };
  7796.  
  7797. // DISABLE BY SID:
  7798. this.disableBySid = function(sid) {
  7799. let find = fOS(sid);
  7800. if (find) {
  7801. this.disableObj(find);
  7802. }
  7803. };
  7804.  
  7805. // REMOVE ALL FROM PLAYER:
  7806. this.removeAllItems = function(sid, server) {
  7807. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7808. };
  7809. }
  7810. };
  7811.  
  7812. let botz = [];
  7813.  
  7814. function botSpawn(id) {
  7815. let bot;
  7816. console.log(WS);
  7817. let t = WS.url.split("wss://")[1].split("?")[0];
  7818. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7819. let botPlayer = new Map();
  7820. botSkts.push([botPlayer]);
  7821. botz.push([bot]);
  7822. let botSID;
  7823. let botObj = [];
  7824. let nearObj = [];
  7825. let bD = {
  7826. x: 0,
  7827. y: 0,
  7828. inGame: false,
  7829. closeSocket: false,
  7830. whyDie: ""
  7831. };
  7832. let oldXY = {
  7833. x: 0,
  7834. y: 0,
  7835. };
  7836. let izauto = 0;
  7837. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7838. bot.binaryType = "arraybuffer";
  7839. bot.first = true;
  7840. bot.sendWS = function(type) {
  7841. // EXTRACT DATA ARRAY:
  7842. let data = Array.prototype.slice.call(arguments, 1);
  7843. // SEND MESSAGE:
  7844. let binary = window.msgpack.encode([type, data]);
  7845. bot.send(binary);
  7846. };
  7847. bot.spawn = function() {
  7848. bot.sendWS("M", {
  7849. name: "Trash Slave",
  7850. moofoll: 1,
  7851. skin: "__proto__"
  7852. });
  7853. };
  7854. bot.sendUpgrade = function(index) {
  7855. bot.sendWS("H", index);
  7856. };
  7857. bot.place = function(id, a) {
  7858. try {
  7859. let item = items.list[botPlayer.items[id]];
  7860. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7861. bot.sendWS("G", botPlayer.items[id]);
  7862. bot.sendWS("d", 1, a);
  7863. bot.sendWS("G", botPlayer.weaponIndex, true);
  7864. }
  7865. } catch (e) {
  7866. }
  7867. };
  7868. bot.buye = function(id, index) {
  7869. let nID = 0;
  7870. if (botPlayer.alive && botPlayer.inGame) {
  7871. if (index == 0) {
  7872. if (botPlayer.skins[id]) {
  7873. if (botPlayer.latestSkin != id) {
  7874. bot.sendWS("c", 0, id, 0);
  7875. }
  7876. } else {
  7877. let find = findID(hats, id);
  7878. if (find) {
  7879. if (botPlayer.points >= find.price) {
  7880. bot.sendWS("c", 1, id, 0);
  7881. bot.sendWS("c", 0, id, 0);
  7882. } else {
  7883. if (botPlayer.latestSkin != nID) {
  7884. bot.sendWS("c", 0, nID, 0);
  7885. }
  7886. }
  7887. } else {
  7888. if (botPlayer.latestSkin != nID) {
  7889. bot.sendWS("c", 0, nID, 0);
  7890. }
  7891. }
  7892. }
  7893. } else if (index == 1) {
  7894. if (botPlayer.tails[id]) {
  7895. if (botPlayer.latestTail != id) {
  7896. bot.sendWS("c", 0, id, 1);
  7897. }
  7898. } else {
  7899. let find = findID(accessories, id);
  7900. if (find) {
  7901. if (botPlayer.points >= find.price) {
  7902. bot.sendWS("c", 1, id, 1);
  7903. bot.sendWS("c", 0, id, 1);
  7904. } else {
  7905. if (botPlayer.latestTail != 0) {
  7906. bot.sendWS("c", 0, 0, 1);
  7907. }
  7908. }
  7909. } else {
  7910. if (botPlayer.latestTail != 0) {
  7911. bot.sendWS("c", 0, 0, 1);
  7912. }
  7913. }
  7914. }
  7915. }
  7916. }
  7917. };
  7918. bot.fastGear = function() {
  7919. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7920. bot.buye(31, 0);
  7921. } else {
  7922. if (botPlayer.y2 <= config.snowBiomeTop) {
  7923. bot.buye(15, 0);
  7924. } else {
  7925. bot.buye(12, 0);
  7926. }
  7927. }
  7928. };
  7929. bot.selectWeapon = function(a) {
  7930. packet("G", a, 1);
  7931. }
  7932. function caf(e, t) {
  7933. try {
  7934. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7935. } catch (e) {
  7936. return 0;
  7937. }
  7938. }
  7939. bot.heal = function() {
  7940. if (botPlayer.health < 100) {
  7941. bot.place(0, 0)
  7942. }
  7943. }
  7944. function cdf (e, t){
  7945. try {
  7946. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  7947. } catch(e){
  7948. return Infinity;
  7949. }
  7950. }
  7951. let zoon = 'no';
  7952. bot.zync = function(a) {
  7953. if (!botPlayer.millPlace) {
  7954. zoon = 'yeah';
  7955. bot.place(5, caf(botPlayer, a));
  7956. let NextTickLocation = {
  7957. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7958. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7959. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7960. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7961. };
  7962.  
  7963. function calculateDistance(x1, y1, x2, y2) {
  7964. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  7965. return distance;
  7966. }
  7967. function dotherezt() {
  7968. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7969. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  7970. }
  7971.  
  7972. let aa = setInterval(() => {
  7973. bot.sendWS("G", botPlayer.weapons[1], true);
  7974. if (izauto == 0) {
  7975. bot.sendWS("K", 1);
  7976. izauto = 1;
  7977. }
  7978. setTimeout(() => {
  7979. bot.sendWS("G", botPlayer.weapons[0], true);
  7980. }, 2000);
  7981. bot.buye(53, 0);
  7982. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  7983. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  7984. } else {
  7985. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7986. zoon = 'no';
  7987. bot.sendWS("a", undefined);
  7988. dotherezt();
  7989. clearInterval(aa);
  7990. }
  7991. }, 150);
  7992.  
  7993. setTimeout(() => {
  7994. zoon = 'no';
  7995. clearInterval(aa);
  7996. }, 500);
  7997. }
  7998. };
  7999. bot.onmessage = function(message) {
  8000. let data = new Uint8Array(message.data);
  8001. let parsed = window.msgpack.decode(data);
  8002. let type = parsed[0];
  8003. data = parsed[1];
  8004. if (type == "io-init") {
  8005. bot.spawn();
  8006. }
  8007. if (type == "1") {
  8008. botSID = data[0];
  8009. console.log(botSID)
  8010. }
  8011. if (type == "D") {
  8012. if (data[1]) {
  8013. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8014. botPlayer.setData(data[0]);
  8015. botPlayer.inGame = true;
  8016. botPlayer.alive = true;
  8017. botPlayer.x2 = undefined;
  8018. botPlayer.y2 = undefined;
  8019. botPlayer.spawn(1);
  8020. botPlayer.oldHealth = 100;
  8021. botPlayer.health = 100;
  8022. botPlayer.showName = 'YEAHHH';
  8023. oldXY = {
  8024. x: data[0][3],
  8025. y: data[0][4]
  8026. }
  8027. bD.inGame = true;
  8028. if (bot.first) {
  8029. bot.first = false;
  8030. bots.push(bD);
  8031. }
  8032. }
  8033. }
  8034. if (type == "P") {
  8035. bot.spawn();
  8036. botPlayer.inGame = false;
  8037. bD.inGame = false;
  8038. }
  8039. if (type == "a") {
  8040. let tmpData = data[0];
  8041. botPlayer.tick++;
  8042. botPlayer.enemy = [];
  8043. botPlayer.near = [];
  8044. bot.showName = 'YEAHHH';
  8045. nearObj = [];
  8046. for (let i = 0; i < tmpData.length;) {
  8047. if (tmpData[i] == botPlayer.sid) {
  8048. botPlayer.x2 = tmpData[i + 1];
  8049. botPlayer.y2 = tmpData[i + 2];
  8050. botPlayer.d2 = tmpData[i + 3];
  8051. botPlayer.buildIndex = tmpData[i + 4];
  8052. botPlayer.weaponIndex = tmpData[i + 5];
  8053. botPlayer.weaponVariant = tmpData[i + 6];
  8054. botPlayer.team = tmpData[i + 7];
  8055. botPlayer.isLeader = tmpData[i + 8];
  8056. botPlayer.skinIndex = tmpData[i + 9];
  8057. botPlayer.tailIndex = tmpData[i + 10];
  8058. botPlayer.iconIndex = tmpData[i + 11];
  8059. botPlayer.zIndex = tmpData[i + 12];
  8060. botPlayer.visible = true;
  8061. bD.x2 = botPlayer.x2;
  8062. bD.y2 = botPlayer.y2;
  8063. }
  8064. i += 13;
  8065. }
  8066.  
  8067. for (let i = 0; i < tmpData.length;) {
  8068. tmpObj = findPlayerBySID(tmpData[i]);
  8069. if (tmpObj) {
  8070. if (!tmpObj.isTeam(botPlayer)) {
  8071. enemy.push(tmpObj);
  8072. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8073. nears.push(tmpObj);
  8074. }
  8075. }
  8076. }
  8077. i += 13;
  8078. }
  8079.  
  8080. if (enemy.length) {
  8081. //console.log(enemy)
  8082. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8083. return tmp1.dist2 - tmp2.dist2;
  8084. })[0];
  8085. }
  8086.  
  8087. if (izauto == 1) {
  8088. bot.sendWS("K", 1);
  8089. izauto = 0;
  8090. }
  8091.  
  8092. if (bD.closeSocket) {
  8093. botPlayer.closeSockets(bot);
  8094. }
  8095. if (bD.whyDie != "") {
  8096. botPlayer.whyDieChat(bot, bD.whyDie);
  8097. bD.whyDie = "";
  8098. }
  8099. if (botPlayer.alive) {
  8100. if (player.team) {
  8101. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8102. botPlayer.team && (bot.sendWS("N"));
  8103. bot.sendWS("b", player.team);
  8104. }
  8105. }
  8106.  
  8107. let item = items.list[botPlayer.items[3]];
  8108. let a = botPlayer.itemCounts[item.group.id]
  8109. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8110. if (botPlayer.inGame) {
  8111. bot.sendWS("D", botPlayer.moveDir);
  8112. if (izauto == 0) {
  8113. bot.sendWS("K", 1);
  8114. izauto = 1;
  8115. }
  8116. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8117. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8118. bot.place(3, aim + 7.7);
  8119. bot.place(3, aim - 7.7);
  8120. bot.place(3, aim);
  8121. oldXY = {
  8122. x: botPlayer.x2,
  8123. y: botPlayer.y2
  8124. };
  8125. }
  8126.  
  8127. if (botPlayer.tick % 90 === 0) {
  8128. let rand = Math.random() * Math.PI * 2;
  8129. botPlayer.moveDir = rand;
  8130. bot.sendWS("a", botPlayer.moveDir);
  8131. }
  8132. }
  8133. bot.fastGear();
  8134. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  8135. botPlayer.millPlace = false;
  8136. // bot.sendWS("K", 1);
  8137. bot.fastGear();
  8138. } else {
  8139. if (botPlayer.inGame) {
  8140. if (botObj.length > 0) {
  8141. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8142. if (getEl("mode").value == 'fuckemup') {
  8143. // if (getEl("mode").value == "clear") {
  8144. bot.selectWeapon(botPlayer.weapons[1]);
  8145. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8146. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8147. 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) {
  8148. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8149. })[0];
  8150. if (nearObj) {
  8151. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8152. if ((gotoDist - isPassed) > 0) {
  8153. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8154. if (botPlayer.moveDir != undefined) {
  8155. botPlayer.moveDir = undefined;
  8156. bot.sendWS("a", botPlayer.moveDir);
  8157. bot.sendWS("D", botPlayer.nDir);
  8158. }
  8159. } else {
  8160. botPlayer.moveDir = gotoAim;
  8161. bot.sendWS("a", botPlayer.moveDir);
  8162. bot.sendWS("D", botPlayer.nDir);
  8163. }
  8164. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8165. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8166. bot.sendWS("D", botPlayer.nDir);
  8167. }
  8168. if (izauto == 0) {
  8169. bot.sendWS("K", 1);
  8170. izauto = 1;
  8171. }
  8172. bot.buye(40, 0);
  8173. } else {
  8174. botPlayer.moveDir = gotoAim;
  8175. bot.sendWS("a", botPlayer.moveDir);
  8176. bot.sendWS("D", botPlayer.nDir);
  8177. bot.fastGear();
  8178. }
  8179. } else {
  8180. botPlayer.moveDir = gotoAim;
  8181. bot.sendWS("a", botPlayer.moveDir);
  8182. bot.sendWS("D", botPlayer.nDir);
  8183. bot.fastGear();
  8184. }
  8185. }
  8186. }
  8187.  
  8188.  
  8189.  
  8190. if (botObj.length > 0) {
  8191. if (getEl("mode").value == 'flex') {
  8192. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  8193. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  8194. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  8195.  
  8196. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  8197.  
  8198. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  8199. if (dist > 22) // 22 is player speed without booster hat
  8200. return;
  8201. }
  8202. }
  8203.  
  8204.  
  8205. if (botObj.length > 0) {
  8206. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8207. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8208. })[0];
  8209.  
  8210. if (nearObj) {
  8211. if (izauto == 0) {
  8212. bot.sendWS("K", 1);
  8213. izauto = 1;
  8214. }
  8215. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8216. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8217. bot.sendWS("D", botPlayer.nDir);
  8218. }
  8219. bot.buye(40, 0);
  8220. bot.buye(11, 1);
  8221. } else {
  8222. bot.fastGear();
  8223. bot.buye(11, 1);
  8224. }
  8225. bot.buye(11, 1);
  8226. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8227. // if (getEl("mode").value == "clear") {
  8228. bot.selectWeapon(botPlayer.weapons[1]);
  8229. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8230. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8231. 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) {
  8232. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8233. })[0];
  8234. if (nearObj) {
  8235. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8236. if ((gotoDist - isPassed) > 0) {
  8237. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8238. if (botPlayer.moveDir != undefined) {
  8239. botPlayer.moveDir = undefined;
  8240. bot.sendWS("a", botPlayer.moveDir);
  8241. bot.sendWS("D", botPlayer.nDir);
  8242. }
  8243. } else {
  8244. botPlayer.moveDir = gotoAim;
  8245. bot.sendWS("a", botPlayer.moveDir);
  8246. bot.sendWS("D", botPlayer.nDir);
  8247. }
  8248. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8249. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8250. bot.sendWS("D", botPlayer.nDir);
  8251. }
  8252. if (izauto == 0) {
  8253. bot.sendWS("K", 1);
  8254. izauto = 1;
  8255. }
  8256. bot.buye(40, 0);
  8257. bot.fastGear();
  8258. } else {
  8259. botPlayer.moveDir = gotoAim;
  8260. bot.sendWS("a", botPlayer.moveDir);
  8261. bot.sendWS("D", botPlayer.nDir);
  8262. bot.fastGear();
  8263. }
  8264. } else {
  8265. botPlayer.moveDir = gotoAim;
  8266. bot.sendWS("a", botPlayer.moveDir);
  8267. bot.sendWS("D", botPlayer.nDir);
  8268. bot.fastGear();
  8269. }
  8270. if (gotoDist > 300) {
  8271. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8272. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8273. bot.place(3, aim + 7.7);
  8274. bot.place(3, aim - 7.7);
  8275. bot.place(3, aim);
  8276. oldXY = {
  8277. x: botPlayer.x2,
  8278. y: botPlayer.y2
  8279. };
  8280. }
  8281. }
  8282. }
  8283. }
  8284.  
  8285. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8286. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  8287.  
  8288. if(!wdaawdwad.length) {
  8289. if(zoon == 'no')
  8290. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8291. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8292. }
  8293.  
  8294. if(wdaawdwad.length) {
  8295. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8296. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8297. 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) {
  8298. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8299. })[0];
  8300. if (nearObj) {
  8301. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8302. if ((gotoDist - isPassed) > 0) {
  8303. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8304. if (botPlayer.moveDir != undefined) {
  8305. botPlayer.moveDir = undefined;
  8306. bot.sendWS("a", botPlayer.moveDir);
  8307. bot.sendWS("D", botPlayer.nDir);
  8308. }
  8309. } else {
  8310. bot.sendWS("D", botPlayer.nDir);
  8311. }
  8312. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8313. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8314. bot.sendWS("D", botPlayer.nDir);
  8315. }
  8316. if (izauto == 0) {
  8317. bot.sendWS("K", 1);
  8318. izauto = 1;
  8319. }
  8320. bot.buye(40, 0);
  8321. bot.fastGear();
  8322. } else {
  8323. if(zoon == 'no')
  8324. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8325. if(cdf(player, botPlayer) <= 110)
  8326. bot.sendWS("a", undefined);
  8327. else
  8328. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8329. }
  8330. } else {
  8331. if(wdaawdwad.length) {
  8332. if(zoon == 'no')
  8333. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  8334. if(cdf(player, botPlayer) <= 110)
  8335. bot.sendWS("a", undefined);
  8336. else
  8337. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8338. } else {
  8339. if(zoon == 'no')
  8340. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8341. if(cdf(player, botPlayer) <= 110)
  8342. bot.sendWS("a", undefined);
  8343. else
  8344. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8345. }
  8346. }
  8347. }
  8348. }
  8349. }
  8350. }
  8351. }
  8352. }
  8353. if (type == "H") {
  8354. let tmpData = data[0];
  8355. for (let i = 0; i < tmpData.length;) {
  8356. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8357. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8358. sid: tmpData[i + 7]
  8359. } : null));
  8360. i += 8;
  8361. }
  8362. }
  8363. if (type == "N") {
  8364. let index = data[0];
  8365. let value = data[1];
  8366. if (botPlayer) {
  8367. botPlayer[index] = value;
  8368. }
  8369. }
  8370. if (type == "O") {
  8371. if (data[0] == botPlayer.sid) {
  8372. botPlayer.oldHealth = botPlayer.health;
  8373. botPlayer.health = data[1];
  8374. botPlayer.judgeShame();
  8375. if (botPlayer.oldHealth > botPlayer.health) {
  8376. if (botPlayer.shameCount < 5) {
  8377. for (let i = 0; i < 2; i++) {
  8378. bot.place(0, botPlayer.nDir);
  8379. }
  8380.  
  8381. } else {
  8382. setTimeout(() => {
  8383. for (let i = 0; i < 2; i++) {
  8384. bot.place(0, botPlayer.nDir);
  8385. }
  8386. }, 95);
  8387. }
  8388. }
  8389. }
  8390. }
  8391. if (type == "Q") {
  8392. let sid = data[0];
  8393. botObjManager.disableBySid(sid);
  8394. }
  8395. if (type == "R") {
  8396. let sid = data[0];
  8397. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8398. }
  8399. if (type == "S") {
  8400. let index = data[0];
  8401. let value = data[1];
  8402. if (botPlayer) {
  8403. botPlayer.itemCounts[index] = value;
  8404. }
  8405. }
  8406. if (type == "U") {
  8407. if (data[0] > 0) {
  8408. if(getEl("setup").value == 'dm') {
  8409. if (botPlayer.upgraded == 0) {
  8410. bot.sendUpgrade(7);
  8411. } else if (botPlayer.upgraded == 1) {
  8412. bot.sendUpgrade(17);
  8413. } else if (botPlayer.upgraded == 2) {
  8414. bot.sendUpgrade(31);
  8415. } else if (botPlayer.upgraded == 3) {
  8416. bot.sendUpgrade(23);
  8417. } else if (botPlayer.upgraded == 4) {
  8418. bot.sendUpgrade(9);
  8419. } else if (botPlayer.upgraded == 5) {
  8420. bot.sendUpgrade(34);
  8421. } else if (botPlayer.upgraded == 6) {
  8422. bot.sendUpgrade(12);
  8423. } else if (botPlayer.upgraded == 7) {
  8424. bot.sendUpgrade(15);
  8425. }
  8426. } else if(getEl("setup").value == 'dr') {
  8427. if (botPlayer.upgraded == 0) {
  8428. bot.sendUpgrade(7);
  8429. } else if (botPlayer.upgraded == 1) {
  8430. bot.sendUpgrade(17);
  8431. } else if (botPlayer.upgraded == 2) {
  8432. bot.sendUpgrade(31);
  8433. } else if (botPlayer.upgraded == 3) {
  8434. bot.sendUpgrade(23);
  8435. } else if (botPlayer.upgraded == 4) {
  8436. bot.sendUpgrade(9);
  8437. } else if (botPlayer.upgraded == 5) {
  8438. bot.sendUpgrade(34);
  8439. } else if (botPlayer.upgraded == 6) {
  8440. bot.sendUpgrade(12);
  8441. } else if (botPlayer.upgraded == 7) {
  8442. bot.sendUpgrade(13);
  8443. }
  8444. } else if(getEl("setup").value == 'kh') {
  8445. if (botPlayer.upgraded == 0) {
  8446. bot.sendUpgrade(3);
  8447. } else if (botPlayer.upgraded == 1) {
  8448. bot.sendUpgrade(17);
  8449. } else if (botPlayer.upgraded == 2) {
  8450. bot.sendUpgrade(31);
  8451. } else if (botPlayer.upgraded == 3) {
  8452. bot.sendUpgrade(27);
  8453. } else if (botPlayer.upgraded == 4) {
  8454. bot.sendUpgrade(10);
  8455. } else if (botPlayer.upgraded == 5) {
  8456. bot.sendUpgrade(34);
  8457. } else if (botPlayer.upgraded == 6) {
  8458. bot.sendUpgrade(4);
  8459. } else if (botPlayer.upgraded == 7) {
  8460. bot.sendUpgrade(25);
  8461. }
  8462. } else if(getEl("setup").value == 'zd') {
  8463. if (botPlayer.upgraded == 0) {
  8464. bot.sendUpgrade(3);
  8465. } else if (botPlayer.upgraded == 1) {
  8466. bot.sendUpgrade(17);
  8467. } else if (botPlayer.upgraded == 2) {
  8468. bot.sendUpgrade(31);
  8469. } else if (botPlayer.upgraded == 3) {
  8470. bot.sendUpgrade(27);
  8471. } else if (botPlayer.upgraded == 4) {
  8472. bot.sendUpgrade(9);
  8473. } else if (botPlayer.upgraded == 5) {
  8474. bot.sendUpgrade(34);
  8475. } else if (botPlayer.upgraded == 6) {
  8476. bot.sendUpgrade(12);
  8477. } else if (botPlayer.upgraded == 7) {
  8478. bot.sendUpgrade(15);
  8479. }
  8480. }
  8481. botPlayer.upgraded++;
  8482. }
  8483. }
  8484. if (type == "V") {
  8485. let tmpData = data[0];
  8486. let wpn = data[1];
  8487. if (tmpData) {
  8488. if (wpn) botPlayer.weapons = tmpData;
  8489. else botPlayer.items = tmpData;
  8490. }
  8491.  
  8492. }
  8493. if (type == "5") {
  8494. let type = data[0];
  8495. let id = data[1];
  8496. let index = data[2];
  8497. if (index) {
  8498. if (!type)
  8499. botPlayer.tails[id] = 1;
  8500. else
  8501. botPlayer.latestTail = id;
  8502. } else {
  8503. if (!type)
  8504. botPlayer.skins[id] = 1;
  8505. else
  8506. botPlayer.latestSkin = id;
  8507. }
  8508. }
  8509.  
  8510. if (type == "6") {
  8511. let id = data[0];
  8512. let mzg = data[1]+'';
  8513. if(id == player.sid && mzg.includes("Sync")) {
  8514. bot.zync(botPlayer.near);
  8515. }
  8516. }
  8517. };
  8518. bot.onclose = function() {
  8519. botPlayer.inGame = false;
  8520. bD.inGame = false;
  8521. };
  8522. }
  8523.  
  8524. // RENDER LEAF:
  8525. function renderLeaf(x, y, l, r, ctxt) {
  8526. let endX = x + (l * Math.cos(r));
  8527. let endY = y + (l * Math.sin(r));
  8528. let width = l * 0.4;
  8529. ctxt.moveTo(x, y);
  8530. ctxt.beginPath();
  8531. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8532. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8533. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8534. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8535. ctxt.closePath();
  8536. ctxt.fill();
  8537. ctxt.stroke();
  8538. }
  8539.  
  8540. // RENDER CIRCLE:
  8541. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8542. tmpContext = tmpContext || mainContext;
  8543. tmpContext.beginPath();
  8544. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8545. if (!dontFill) tmpContext.fill();
  8546. if (!dontStroke) tmpContext.stroke();
  8547. }
  8548.  
  8549. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8550. tmpContext = tmpContext || mainContext;
  8551. tmpContext.beginPath();
  8552. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8553. if (!dontFill) tmpContext.fill();
  8554. if (!dontStroke) tmpContext.stroke();
  8555. }
  8556.  
  8557. // RENDER STAR SHAPE:
  8558. function renderStar(ctxt, spikes, outer, inner) {
  8559. let rot = Math.PI / 2 * 3;
  8560. let x, y;
  8561. let step = Math.PI / spikes;
  8562. ctxt.beginPath();
  8563. ctxt.moveTo(0, -outer);
  8564. for (let i = 0; i < spikes; i++) {
  8565. x = Math.cos(rot) * outer;
  8566. y = Math.sin(rot) * outer;
  8567. ctxt.lineTo(x, y);
  8568. rot += step;
  8569. x = Math.cos(rot) * inner;
  8570. y = Math.sin(rot) * inner;
  8571. ctxt.lineTo(x, y);
  8572. rot += step;
  8573. }
  8574. ctxt.lineTo(0, -outer);
  8575. ctxt.closePath();
  8576. }
  8577.  
  8578. function renderHealthStar(ctxt, spikes, outer, inner) {
  8579. let rot = Math.PI / 2 * 3;
  8580. let x, y;
  8581. let step = Math.PI / spikes;
  8582. ctxt.beginPath();
  8583. ctxt.moveTo(0, -outer);
  8584. for (let i = 0; i < spikes; i++) {
  8585. x = Math.cos(rot) * outer;
  8586. y = Math.sin(rot) * outer;
  8587. ctxt.lineTo(x, y);
  8588. rot += step;
  8589. x = Math.cos(rot) * inner;
  8590. y = Math.sin(rot) * inner;
  8591. ctxt.lineTo(x, y);
  8592. rot += step;
  8593. }
  8594. ctxt.lineTo(0, -outer);
  8595. ctxt.closePath();
  8596. }
  8597.  
  8598. // RENDER RECTANGLE:
  8599. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8600. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8601. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8602. }
  8603.  
  8604. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8605. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8606. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8607. }
  8608.  
  8609. // RENDER RECTCIRCLE:
  8610. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8611. ctxt.save();
  8612. ctxt.translate(x, y);
  8613. seg = Math.ceil(seg / 2);
  8614. for (let i = 0; i < seg; i++) {
  8615. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8616. ctxt.rotate(Math.PI / seg);
  8617. }
  8618. ctxt.restore();
  8619. }
  8620.  
  8621. // RENDER BLOB:
  8622. function renderBlob(ctxt, spikes, outer, inner) {
  8623. let rot = Math.PI / 2 * 3;
  8624. let x, y;
  8625. let step = Math.PI / spikes;
  8626. let tmpOuter;
  8627. ctxt.beginPath();
  8628. ctxt.moveTo(0, -inner);
  8629. for (let i = 0; i < spikes; i++) {
  8630. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8631. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8632. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8633. rot += step * 2;
  8634. }
  8635. ctxt.lineTo(0, -inner);
  8636. ctxt.closePath();
  8637. }
  8638.  
  8639. // RENDER TRIANGLE:
  8640. function renderTriangle(s, ctx) {
  8641. ctx = ctx || mainContext;
  8642. let h = s * (Math.sqrt(3) / 2);
  8643. ctx.beginPath();
  8644. ctx.moveTo(0, -h / 2);
  8645. ctx.lineTo(-s / 2, h / 2);
  8646. ctx.lineTo(s / 2, h / 2);
  8647. ctx.lineTo(0, -h / 2);
  8648. ctx.fill();
  8649. ctx.closePath();
  8650. }
  8651.  
  8652. // PREPARE MENU BACKGROUND:
  8653. function prepareMenuBackground() {
  8654. let tmpMid = config.mapScale / 2;
  8655. let attempts = 0;
  8656. for (let i = 0; i < items.list.length * 3;) {
  8657. if (attempts >= 1000) break;
  8658. attempts++;
  8659. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8660. let data = {
  8661. x: tmpMid + UTILS.randFloat(-1000, 1000),
  8662. y: tmpMid + UTILS.randFloat(-600, 600),
  8663. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8664. };
  8665. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8666. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8667. } else {
  8668. continue;
  8669. }
  8670. i++;
  8671. }
  8672. }
  8673. const speed = 35;
  8674. // RENDER PLAYERS:
  8675. function renderDeadPlayers(xOffset, yOffset) {
  8676. mainContext.fillStyle = "#91b2db";
  8677. const currentTime = Date.now();
  8678. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8679. if (!dead.startTime) {
  8680. dead.startTime = currentTime;
  8681. dead.angle = 0;
  8682. dead.radius = 0.1;
  8683. }
  8684. const timeElapsed = currentTime - dead.startTime;
  8685. const maxAlpha = 1;
  8686. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8687. dead.animate(delta);
  8688. mainContext.globalAlpha = dead.alpha;
  8689. mainContext.strokeStyle = outlineColor;
  8690. mainContext.save();
  8691. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8692. dead.radius -= 0.001;
  8693. dead.angle += 0.0174533;
  8694. const moveSpeed = 1;
  8695. const x = dead.radius * Math.cos(dead.angle);
  8696. const y = dead.radius * Math.sin(dead.angle);
  8697. dead.x += x * moveSpeed;
  8698. dead.y += y * moveSpeed;
  8699. mainContext.rotate(dead.angle);
  8700. renderDeadPlayer(dead, mainContext);
  8701. mainContext.restore();
  8702. mainContext.fillStyle = "#91b2db";
  8703. if (timeElapsed >= 3000) {
  8704. dead.active = false;
  8705. dead.startTime = null;
  8706. }
  8707. });
  8708. }
  8709. // RENDER PLAYERS:
  8710. function renderPlayers(xOffset, yOffset, zIndex) {
  8711. mainContext.globalAlpha = 1;
  8712. mainContext.fillStyle = "#91b2db";
  8713. for (var i = 0; i < players.length; ++i) {
  8714. tmpObj = players[i];
  8715. if (tmpObj.zIndex == zIndex) {
  8716. tmpObj.animate(delta);
  8717. if (tmpObj.visible) {
  8718. tmpObj.skinRot += (0.002 * delta);
  8719. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  8720. mainContext.save();
  8721. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8722. // RENDER PLAYER:
  8723. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8724. renderPlayer(tmpObj, mainContext);
  8725. mainContext.restore();
  8726.  
  8727. }
  8728. }
  8729. }
  8730. }
  8731. // RENDER DEAD PLAYER:
  8732. function renderDeadPlayer(obj, ctxt) {
  8733. ctxt = ctxt || mainContext;
  8734. ctxt.lineWidth = outlineWidth;
  8735. ctxt.lineJoin = "miter";
  8736. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8737. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8738. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8739. // TAIL/CAPE:
  8740. renderTail2(13, ctxt, obj);
  8741. // WEAPON BELLOW HANDS:
  8742. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8743. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8744. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8745. renderProjectile(obj.scale, 0,
  8746. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8747. }
  8748. }
  8749. // HANDS:
  8750. ctxt.fillStyle = "#ececec";
  8751. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8752. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8753. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8754. // WEAPON ABOVE HANDS:
  8755. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8756. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8757. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8758. renderProjectile(obj.scale, 0,
  8759. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8760. }
  8761. }
  8762. // BUILD ITEM:
  8763. if (obj.buildIndex >= 0) {
  8764. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8765. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8766. }
  8767. // BODY:
  8768. renderCircle(0, 0, obj.scale, ctxt);
  8769. // SKIN
  8770. renderSkin2(48, ctxt, null, obj)
  8771. }
  8772.  
  8773. // RENDER PLAYER:
  8774. function renderPlayer(obj, ctxt) {
  8775. ctxt = ctxt || mainContext;
  8776. ctxt.lineWidth = outlineWidth;
  8777. ctxt.lineJoin = "miter";
  8778. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8779. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8780. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8781.  
  8782. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8783.  
  8784. // TAIL/CAPE:
  8785. if (obj.tailIndex > 0) {
  8786. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8787. }
  8788.  
  8789. // WEAPON BELLOW HANDS:
  8790. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8791. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8792. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8793. renderProjectile(obj.scale, 0,
  8794. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8795. }
  8796. }
  8797.  
  8798. // HANDS:
  8799. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8800. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8801. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8802. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8803.  
  8804. // WEAPON ABOVE HANDS:
  8805. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8806. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8807. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8808. renderProjectile(obj.scale, 0,
  8809. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8810. }
  8811. }
  8812.  
  8813. // BUILD ITEM:
  8814. if (obj.buildIndex >= 0) {
  8815. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8816. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8817. }
  8818.  
  8819. // BODY:
  8820. renderCircle(0, 0, obj.scale, ctxt);
  8821.  
  8822. // SKIN:
  8823. if (obj.skinIndex > 0) {
  8824. ctxt.rotate(Math.PI / 2);
  8825. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8826. }
  8827.  
  8828. }
  8829.  
  8830. // RENDER NORMAL SKIN
  8831. var skinSprites2 = {};
  8832. var skinPointers2 = {};
  8833. function renderSkin2(index, ctxt, parentSkin, owner) {
  8834. tmpSkin = skinSprites2[index];
  8835. if (!tmpSkin) {
  8836. var tmpImage = new Image();
  8837. tmpImage.onload = function() {
  8838. this.isLoaded = true;
  8839. this.onload = null;
  8840. };
  8841. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8842. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8843. skinSprites2[index] = tmpImage;
  8844. tmpSkin = tmpImage;
  8845. }
  8846. var tmpObj = parentSkin||skinPointers2[index];
  8847. if (!tmpObj) {
  8848. for (var i = 0; i < hats.length; ++i) {
  8849. if (hats[i].id == index) {
  8850. tmpObj = hats[i];
  8851. break;
  8852. }
  8853. }
  8854. skinPointers2[index] = tmpObj;
  8855. }
  8856. if (tmpSkin.isLoaded)
  8857. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8858. if (!parentSkin && tmpObj.topSprite) {
  8859. ctxt.save();
  8860. ctxt.rotate(owner.skinRot);
  8861. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8862. ctxt.restore();
  8863. }
  8864. }
  8865.  
  8866. // RENDER SKIN:
  8867. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8868. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8869. var tmpImage = new Image();
  8870. tmpImage.onload = function() {
  8871. this.isLoaded = true,
  8872. this.onload = null
  8873. }
  8874. ,
  8875. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8876. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8877. tmpSkin = tmpImage
  8878. }
  8879. var tmpObj = parentSkin||skinPointers[index];
  8880. if (!tmpObj) {
  8881. for (var i = 0; i < hats.length; ++i) {
  8882. if (hats[i].id == index) {
  8883. tmpObj = hats[i];
  8884. break;
  8885. }
  8886. }
  8887. skinPointers[index] = tmpObj;
  8888. }
  8889. if (tmpSkin.isLoaded)
  8890. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8891. if (!parentSkin && tmpObj.topSprite) {
  8892. ctxt.save();
  8893. ctxt.rotate(owner.skinRot);
  8894. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8895. ctxt.restore();
  8896. }
  8897. }
  8898.  
  8899. var FlareZHat = {
  8900. 7: "https://i.imgur.com/vAOzlyY.png",
  8901. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8902. 40: "https://i.imgur.com/Xzmg27N.png",
  8903. 26: "https://i.imgur.com/I0xGtyZ.png",
  8904. 55: "https://i.imgur.com/uYgDtcZ.png",
  8905. 20: "https://i.imgur.com/f5uhWCk.png",
  8906. };
  8907.  
  8908. function setSkinTextureImage(id, type, id2) {
  8909. if (true) {
  8910. if(FlareZHat[id] && type == "hat") {
  8911. return FlareZHat[id];
  8912. } else {
  8913. if(type == "acc") {
  8914. return ".././img/accessories/access_" + id + ".png";
  8915. } else if(type == "hat") {
  8916. return ".././img/hats/hat_" + id + ".png";
  8917. } else {
  8918. return ".././img/weapons/" + id + ".png";
  8919. }
  8920. }
  8921. } else {
  8922. if(type == "acc") {
  8923. return ".././img/accessories/access_" + id + ".png";
  8924. } else if(type == "hat") {
  8925. return ".././img/hats/hat_" + id + ".png";
  8926. } else {
  8927. return ".././img/weapons/" + id + ".png";
  8928. }
  8929. }
  8930. }
  8931. // RENDER SKINS:
  8932. let skinSprites = {};
  8933. let skinPointers = {};
  8934. let tmpSkin;
  8935.  
  8936. function renderSkin(index, ctxt, parentSkin, owner) {
  8937. tmpSkin = skinSprites[index];
  8938. if (!tmpSkin) {
  8939. let tmpImage = new Image();
  8940. tmpImage.onload = function() {
  8941. this.isLoaded = true;
  8942. this.onload = null;
  8943. };
  8944. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8945. skinSprites[index] = tmpImage;
  8946. tmpSkin = tmpImage;
  8947. }
  8948. let tmpObj = parentSkin || skinPointers[index];
  8949. if (!tmpObj) {
  8950. for (let i = 0; i < hats.length; ++i) {
  8951. if (hats[i].id == index) {
  8952. tmpObj = hats[i];
  8953. break;
  8954. }
  8955. }
  8956. skinPointers[index] = tmpObj;
  8957. }
  8958. if (tmpSkin.isLoaded)
  8959. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8960. if (!parentSkin && tmpObj.topSprite) {
  8961. ctxt.save();
  8962. ctxt.rotate(owner.skinRot);
  8963. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8964. ctxt.restore();
  8965. }
  8966. }
  8967.  
  8968. // RENDER TAIL:
  8969. var FlareZAcc = {
  8970. 21: "https://i.imgur.com/4ddZert.png",
  8971. 19: "https://i.imgur.com/sULkUZT.png",
  8972. };
  8973. function setTailTextureImage(id, type, id2) {
  8974. if (true) {
  8975. if(FlareZAcc[id] && type == "acc") {
  8976. return FlareZAcc[id];
  8977. } else {
  8978. if(type == "acc") {
  8979. return ".././img/accessories/access_" + id + ".png";
  8980. } else if(type == "hat") {
  8981. return ".././img/hats/hat_" + id + ".png";
  8982. } else {
  8983. return ".././img/weapons/" + id + ".png";
  8984. }
  8985. }
  8986. } else {
  8987. if(type == "acc") {
  8988. return ".././img/accessories/access_" + id + ".png";
  8989. } else if(type == "hat") {
  8990. return ".././img/hats/hat_" + id + ".png";
  8991. } else {
  8992. return ".././img/weapons/" + id + ".png";
  8993. }
  8994. }
  8995. }
  8996. function renderTailTextureImage(index, ctxt, owner) {
  8997. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  8998. var tmpImage = new Image();
  8999. tmpImage.onload = function() {
  9000. this.isLoaded = true,
  9001. this.onload = null
  9002. }
  9003. ,
  9004. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  9005. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9006. tmpSkin = tmpImage;
  9007. }
  9008. var tmpObj = accessPointers[index];
  9009. if (!tmpObj) {
  9010. for (var i = 0; i < accessories.length; ++i) {
  9011. if (accessories[i].id == index) {
  9012. tmpObj = accessories[i];
  9013. break;
  9014. }
  9015. }
  9016. accessPointers[index] = tmpObj;
  9017. }
  9018. if (tmpSkin.isLoaded) {
  9019. ctxt.save();
  9020. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9021. if (tmpObj.spin)
  9022. ctxt.rotate(owner.skinRot);
  9023. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9024. ctxt.restore();
  9025. }
  9026. }
  9027.  
  9028. let accessSprites = {};
  9029. let accessPointers = {};
  9030. var txt = true;
  9031.  
  9032. function renderTail(index, ctxt, owner) {
  9033. tmpSkin = accessSprites[index];
  9034. if (!tmpSkin) {
  9035. let tmpImage = new Image();
  9036. tmpImage.onload = function() {
  9037. this.isLoaded = true;
  9038. this.onload = null;
  9039. };
  9040. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9041. accessSprites[index] = tmpImage;
  9042. tmpSkin = tmpImage;
  9043. }
  9044. let tmpObj = accessPointers[index];
  9045. if (!tmpObj) {
  9046. for (let i = 0; i < accessories.length; ++i) {
  9047. if (accessories[i].id == index) {
  9048. tmpObj = accessories[i];
  9049. break;
  9050. }
  9051. }
  9052. accessPointers[index] = tmpObj;
  9053. }
  9054. if (tmpSkin.isLoaded) {
  9055. ctxt.save();
  9056. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9057. if (tmpObj.spin)
  9058. ctxt.rotate(owner.skinRot);
  9059. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9060. ctxt.restore();
  9061. }
  9062. }
  9063.  
  9064. var accessSprites2 = {};
  9065. var accessPointers2 = {};
  9066. function renderTail2(index, ctxt, owner) {
  9067. tmpSkin = accessSprites2[index];
  9068. if (!tmpSkin) {
  9069. var tmpImage = new Image();
  9070. tmpImage.onload = function() {
  9071. this.isLoaded = true;
  9072. this.onload = null;
  9073. };
  9074. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9075. accessSprites2[index] = tmpImage;
  9076. tmpSkin = tmpImage;
  9077. }
  9078. var tmpObj = accessPointers2[index];
  9079. if (!tmpObj) {
  9080. for (var i = 0; i < accessories.length; ++i) {
  9081. if (accessories[i].id == index) {
  9082. tmpObj = accessories[i];
  9083. break;
  9084. }
  9085. }
  9086. accessPointers2[index] = tmpObj;
  9087. }
  9088. if (tmpSkin.isLoaded) {
  9089. ctxt.save();
  9090. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9091. if (tmpObj.spin)
  9092. ctxt.rotate(owner.skinRot);
  9093. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9094. ctxt.restore();
  9095. }
  9096. }
  9097.  
  9098. // RENDER TOOL:
  9099. let toolSprites = {};
  9100. function renderTool(obj, variant, x, y, ctxt) {
  9101. let tmpSrc = obj.src + (variant || "");
  9102. let tmpSprite = toolSprites[tmpSrc];
  9103. if (!tmpSprite) {
  9104. tmpSprite = new Image();
  9105. tmpSprite.onload = function() {
  9106. this.isLoaded = true;
  9107. }
  9108. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9109. toolSprites[tmpSrc] = tmpSprite;
  9110. }
  9111. if (tmpSprite.isLoaded)
  9112. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9113. }
  9114.  
  9115. // RENDER PROJECTILES:
  9116. function renderProjectiles(layer, xOffset, yOffset) {
  9117. for (let i = 0; i < projectiles.length; i++) {
  9118. tmpObj = projectiles[i];
  9119. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9120. tmpObj.update(delta);
  9121. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9122. mainContext.save();
  9123. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9124. mainContext.rotate(tmpObj.dir);
  9125. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9126. mainContext.restore();
  9127. }
  9128. }
  9129. };
  9130. }
  9131.  
  9132. // RENDER PROJECTILE:
  9133. let projectileSprites = {};//fz iz zexy
  9134.  
  9135. function renderProjectile(x, y, obj, ctxt, debug) {
  9136. if (obj.src) {
  9137. let tmpSrc = items.projectiles[obj.indx].src;
  9138. let tmpSprite = projectileSprites[tmpSrc];
  9139. if (!tmpSprite) {
  9140. tmpSprite = new Image();
  9141. tmpSprite.onload = function() {
  9142. this.isLoaded = true;
  9143. }
  9144. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9145. projectileSprites[tmpSrc] = tmpSprite;
  9146. }
  9147. if (tmpSprite.isLoaded)
  9148. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9149. } else if (obj.indx == 1) {
  9150. ctxt.fillStyle = "#939393";
  9151. renderCircle(x, y, obj.scale, ctxt);
  9152. }
  9153. }
  9154.  
  9155. // RENDER AI:
  9156. let aiSprites = {};
  9157.  
  9158. function renderAI(obj, ctxt) {
  9159. let tmpIndx = obj.index;
  9160. let tmpSprite = aiSprites[tmpIndx];
  9161. if (!tmpSprite) {
  9162. let tmpImg = new Image();
  9163. tmpImg.onload = function() {
  9164. this.isLoaded = true;
  9165. this.onload = null;
  9166. };
  9167. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9168. tmpSprite = tmpImg;
  9169. aiSprites[tmpIndx] = tmpSprite;
  9170. }
  9171. if (tmpSprite.isLoaded) {
  9172. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9173. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9174. }
  9175. }
  9176.  
  9177. // RENDER WATER BODIES:
  9178. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9179.  
  9180. // MIDDLE RIVER:
  9181. let tmpW = config.riverWidth + padding;
  9182. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9183. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9184. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9185. }
  9186. }
  9187.  
  9188. // RENDER GAME OBJECTS:
  9189. let gameObjectSprites = {};
  9190.  
  9191. function getResSprite(obj) {
  9192. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  9193. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9194. let tmpSprite = gameObjectSprites[tmpIndex];
  9195. if (!tmpSprite) {
  9196. let blurScale = 6;
  9197. let tmpCanvas = document.createElement("canvas");
  9198. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9199. let tmpContext = tmpCanvas.getContext('2d');
  9200. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9201. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9202. tmpContext.strokeStyle = outlineColor;
  9203. tmpContext.lineWidth = outlineWidth;
  9204. // if (isNight) {
  9205. // tmpContext.shadowBlur = blurScale;
  9206. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9207. // }
  9208. if (obj.type == 0) {
  9209. let tmpScale;
  9210. let tmpCount = 8;
  9211. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  9212. for (let i = 0; i < 2; ++i) {
  9213. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  9214. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9215. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  9216. tmpContext.fill();
  9217. if (!i) {
  9218. tmpContext.stroke();
  9219. tmpContext.shadowBlur = null;
  9220. tmpContext.shadowColor = null;
  9221. tmpContext.globalAlpha = 1;
  9222. }
  9223. }
  9224. } else if (obj.type == 1) {
  9225. if (biomeID == 2) {
  9226. tmpContext.fillStyle = "#606060";
  9227. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9228. tmpContext.fill();
  9229. tmpContext.stroke();
  9230.  
  9231. //tmpContext.shadowBlur = null;
  9232. //tmpContext.shadowColor = null;
  9233.  
  9234. tmpContext.fillStyle = "#89a54c";
  9235. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9236. tmpContext.fillStyle = "#a5c65b";
  9237. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9238. } else {
  9239. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9240. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  9241. tmpContext.fill();
  9242. tmpContext.stroke();
  9243.  
  9244. //tmpContext.shadowBlur = null;
  9245. //tmpContext.shadowColor = null;
  9246.  
  9247. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  9248. let tmpRange;
  9249. let berries = 4;
  9250. let rotVal = (Math.PI * 2) / berries;
  9251. for (let i = 0; i < berries; ++i) {
  9252. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  9253. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9254. UTILS.randInt(10, 12), tmpContext);
  9255. }
  9256. }
  9257. } else if (obj.type == 2 || obj.type == 3) {
  9258. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  9259. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9260. tmpContext.fill();
  9261. tmpContext.stroke();
  9262.  
  9263. tmpContext.shadowBlur = null;
  9264. tmpContext.shadowColor = null;
  9265.  
  9266. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  9267. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9268. tmpContext.fill();
  9269. }
  9270. tmpSprite = tmpCanvas;
  9271. gameObjectSprites[tmpIndex] = tmpSprite;
  9272. }
  9273. return tmpSprite;
  9274. }
  9275.  
  9276. // GET ITEM SPRITE:
  9277. let itemSprites = [];
  9278.  
  9279. function getItemSprite(obj, asIcon) {
  9280. let tmpSprite = itemSprites[obj.id];
  9281. if (!tmpSprite || asIcon) {
  9282. let blurScale = !asIcon ? 20 : 5;
  9283. let tmpCanvas = document.createElement("canvas");
  9284. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9285. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9286.  
  9287. let tmpContext = tmpCanvas.getContext("2d");
  9288. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9289. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9290. tmpContext.strokeStyle = outlineColor;
  9291. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9292. if (!asIcon) {
  9293. tmpContext.shadowBlur = 8;
  9294. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  9295. }
  9296.  
  9297. if (obj.name == "apple") {
  9298. tmpContext.fillStyle = "#c15555";
  9299. renderCircle(0, 0, obj.scale, tmpContext);
  9300. tmpContext.fillStyle = "#89a54c";
  9301. let leafDir = -(Math.PI / 2);
  9302. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9303. 25, leafDir + Math.PI / 2, tmpContext);
  9304. } else if (obj.name == "cookie") {
  9305. tmpContext.fillStyle = "#cca861";
  9306. renderCircle(0, 0, obj.scale, tmpContext);
  9307. tmpContext.fillStyle = "#937c4b";
  9308. let chips = 4;
  9309. let rotVal = (Math.PI * 2) / chips;
  9310. let tmpRange;
  9311. for (let i = 0; i < chips; ++i) {
  9312. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9313. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9314. UTILS.randInt(4, 5), tmpContext, true);
  9315. }
  9316. } else if (obj.name == "cheese") {
  9317. tmpContext.fillStyle = "#f4f3ac";
  9318. renderCircle(0, 0, obj.scale, tmpContext);
  9319. tmpContext.fillStyle = "#c3c28b";
  9320. let chips = 4;
  9321. let rotVal = (Math.PI * 2) / chips;
  9322. let tmpRange;
  9323. for (let i = 0; i < chips; ++i) {
  9324. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9325. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9326. UTILS.randInt(4, 5), tmpContext, true);
  9327. }
  9328. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9329. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9330. "#a5974c" : "#939393";
  9331. let sides = (obj.name == "castle wall") ? 4 : 3;
  9332. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9333. tmpContext.fill();
  9334. tmpContext.stroke();
  9335. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9336. "#c9b758" : "#bcbcbc";
  9337. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9338. tmpContext.fill();
  9339. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9340. obj.name == "spinning spikes") {
  9341. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9342. let tmpScale = (obj.scale * 0.6);
  9343. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9344. tmpContext.fill();
  9345. tmpContext.stroke();
  9346. tmpContext.fillStyle = "#a5974c";
  9347. renderCircle(0, 0, tmpScale, tmpContext);
  9348. tmpContext.fillStyle = "#c9b758";
  9349. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9350. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9351. tmpContext.fillStyle = "#a5974c";
  9352. renderCircle(0, 0, reScale, tmpContext);
  9353. tmpContext.fillStyle = "#c9b758";
  9354. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9355. tmpContext.fillStyle = "#a5974c";
  9356. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9357. } else if (obj.name == "mine") {
  9358. tmpContext.fillStyle = "#939393";
  9359. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9360. tmpContext.fill();
  9361. tmpContext.stroke();
  9362. tmpContext.fillStyle = "#bcbcbc";
  9363. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9364. tmpContext.fill();
  9365. } else if (obj.name == "sapling") {
  9366. for (let i = 0; i < 2; ++i) {
  9367. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9368. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9369. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9370. tmpContext.fill();
  9371. if (!i) tmpContext.stroke();
  9372. }
  9373. } else if (obj.name == "pit trap") {
  9374. tmpContext.fillStyle = "#a5974c";
  9375. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9376. tmpContext.fill();
  9377. tmpContext.stroke();
  9378. tmpContext.fillStyle = outlineColor;
  9379. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9380. tmpContext.fill();
  9381. } else if (obj.name == "boost pad") {
  9382. tmpContext.fillStyle = "#7e7f82";
  9383. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9384. tmpContext.fill();
  9385. tmpContext.stroke();
  9386. tmpContext.fillStyle = "#dbd97d";
  9387. renderTriangle(obj.scale * 1, tmpContext);
  9388. } else if (obj.name == "turret") {
  9389. tmpContext.fillStyle = "#a5974c";
  9390. renderCircle(0, 0, obj.scale, tmpContext);
  9391. tmpContext.fill();
  9392. tmpContext.stroke();
  9393. tmpContext.fillStyle = "#939393";
  9394. let tmpLen = 50;
  9395. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9396. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9397. tmpContext.fill();
  9398. tmpContext.stroke();
  9399. } else if (obj.name == "platform") {
  9400. tmpContext.fillStyle = "#cebd5f";
  9401. let tmpCount = 4;
  9402. let tmpS = obj.scale * 2;
  9403. let tmpW = tmpS / tmpCount;
  9404. let tmpX = -(obj.scale / 2);
  9405. for (let i = 0; i < tmpCount; ++i) {
  9406. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9407. tmpContext.fill();
  9408. tmpContext.stroke();
  9409. tmpX += tmpS / tmpCount;
  9410. }
  9411. } else if (obj.name == "healing pad") {
  9412. tmpContext.fillStyle = "#7e7f82";
  9413. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9414. tmpContext.fill();
  9415. tmpContext.stroke();
  9416. tmpContext.fillStyle = "#db6e6e";
  9417. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9418. } else if (obj.name == "spawn pad") {
  9419. tmpContext.fillStyle = "#7e7f82";
  9420. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9421. tmpContext.fill();
  9422. tmpContext.stroke();
  9423. tmpContext.fillStyle = "#71aad6";
  9424. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9425. } else if (obj.name == "blocker") {
  9426. tmpContext.fillStyle = "#7e7f82";
  9427. renderCircle(0, 0, obj.scale, tmpContext);
  9428. tmpContext.fill();
  9429. tmpContext.stroke();
  9430. tmpContext.rotate(Math.PI / 4);
  9431. tmpContext.fillStyle = "#db6e6e";
  9432. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9433. } else if (obj.name == "teleporter") {
  9434. tmpContext.fillStyle = "#7e7f82";
  9435. renderCircle(0, 0, obj.scale, tmpContext);
  9436. tmpContext.fill();
  9437. tmpContext.stroke();
  9438. tmpContext.rotate(Math.PI / 4);
  9439. tmpContext.fillStyle = "#d76edb";
  9440. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9441. }
  9442. tmpSprite = tmpCanvas;
  9443. if (!asIcon)
  9444. itemSprites[obj.id] = tmpSprite;
  9445. }
  9446. return tmpSprite;
  9447. }
  9448.  
  9449. function getItemSprite2(obj, tmpX, tmpY) {
  9450. let tmpContext = mainContext;
  9451. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9452. tmpContext.save();
  9453. tmpContext.translate(tmpX, tmpY);
  9454. tmpContext.rotate(obj.dir);
  9455. tmpContext.strokeStyle = outlineColor;
  9456. tmpContext.lineWidth = outlineWidth;
  9457. if (obj.name == "apple") {
  9458. tmpContext.fillStyle = "#c15555";
  9459. renderCircle(0, 0, obj.scale, tmpContext);
  9460. tmpContext.fillStyle = "#89a54c";
  9461. let leafDir = -(Math.PI / 2);
  9462. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9463. 25, leafDir + Math.PI / 2, tmpContext);
  9464. } else if (obj.name == "cookie") {
  9465. tmpContext.fillStyle = "#cca861";
  9466. renderCircle(0, 0, obj.scale, tmpContext);
  9467. tmpContext.fillStyle = "#937c4b";
  9468. let chips = 4;
  9469. let rotVal = (Math.PI * 2) / chips;
  9470. let tmpRange;
  9471. for (let i = 0; i < chips; ++i) {
  9472. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9473. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9474. UTILS.randInt(4, 5), tmpContext, true);
  9475. }
  9476. } else if (obj.name == "cheese") {
  9477. tmpContext.fillStyle = "#f4f3ac";
  9478. renderCircle(0, 0, obj.scale, tmpContext);
  9479. tmpContext.fillStyle = "#c3c28b";
  9480. let chips = 4;
  9481. let rotVal = (Math.PI * 2) / chips;
  9482. let tmpRange;
  9483. for (let i = 0; i < chips; ++i) {
  9484. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9485. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9486. UTILS.randInt(4, 5), tmpContext, true);
  9487. }
  9488. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9489. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9490. "#a5974c" : "#939393";
  9491. let sides = (obj.name == "castle wall") ? 4 : 3;
  9492. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9493. tmpContext.fill();
  9494. tmpContext.stroke();
  9495. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9496. "#c9b758" : "#bcbcbc";
  9497. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9498. tmpContext.fill();
  9499. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9500. obj.name == "spinning spikes") {
  9501. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9502. let tmpScale = (obj.scale * 0.6);
  9503. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9504. tmpContext.fill();
  9505. tmpContext.stroke();
  9506. tmpContext.fillStyle = "#a5974c";
  9507. renderCircle(0, 0, tmpScale, tmpContext);
  9508. tmpContext.fillStyle = "#c9b758";
  9509. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9510. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9511. tmpContext.fillStyle = "#a5974c";
  9512. renderCircle(0, 0, reScale, tmpContext);
  9513. tmpContext.fillStyle = "#c9b758";
  9514. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9515. tmpContext.fillStyle = "#a5974c";
  9516. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9517. } else if (obj.name == "mine") {
  9518. tmpContext.fillStyle = "#939393";
  9519. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9520. tmpContext.fill();
  9521. tmpContext.stroke();
  9522. tmpContext.fillStyle = "#bcbcbc";
  9523. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9524. tmpContext.fill();
  9525. } else if (obj.name == "sapling") {
  9526. for (let i = 0; i < 2; ++i) {
  9527. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9528. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9529. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9530. tmpContext.fill();
  9531. if (!i) tmpContext.stroke();
  9532. }
  9533. } else if (obj.name == "pit trap") {
  9534. tmpContext.fillStyle = "#a5974c";
  9535. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9536. tmpContext.fill();
  9537. tmpContext.stroke();
  9538. tmpContext.fillStyle = outlineColor;
  9539. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9540. tmpContext.fill();
  9541. } else if (obj.name == "boost pad") {
  9542. tmpContext.fillStyle = "#7e7f82";
  9543. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9544. tmpContext.fill();
  9545. tmpContext.stroke();
  9546. tmpContext.fillStyle = "#dbd97d";
  9547. renderTriangle(obj.scale * 1, tmpContext);
  9548. } else if (obj.name == "turret") {
  9549. tmpContext.fillStyle = "#a5974c";
  9550. renderCircle(0, 0, obj.scale, tmpContext);
  9551. tmpContext.fill();
  9552. tmpContext.stroke();
  9553. tmpContext.fillStyle = "#939393";
  9554. let tmpLen = 50;
  9555. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9556. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9557. tmpContext.fill();
  9558. tmpContext.stroke();
  9559. } else if (obj.name == "platform") {
  9560. tmpContext.fillStyle = "#cebd5f";
  9561. let tmpCount = 4;
  9562. let tmpS = obj.scale * 2;
  9563. let tmpW = tmpS / tmpCount;
  9564. let tmpX = -(obj.scale / 2);
  9565. for (let i = 0; i < tmpCount; ++i) {
  9566. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9567. tmpContext.fill();
  9568. tmpContext.stroke();
  9569. tmpX += tmpS / tmpCount;
  9570. }
  9571. } else if (obj.name == "healing pad") {
  9572. tmpContext.fillStyle = "#7e7f82";
  9573. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9574. tmpContext.fill();
  9575. tmpContext.stroke();
  9576. tmpContext.fillStyle = "#db6e6e";
  9577. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9578. } else if (obj.name == "spawn pad") {
  9579. tmpContext.fillStyle = "#7e7f82";
  9580. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9581. tmpContext.fill();
  9582. tmpContext.stroke();
  9583. tmpContext.fillStyle = "#71aad6";
  9584. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9585. } else if (obj.name == "blocker") {
  9586. tmpContext.fillStyle = "#7e7f82";
  9587. renderCircle(0, 0, obj.scale, tmpContext);
  9588. tmpContext.fill();
  9589. tmpContext.stroke();
  9590. tmpContext.rotate(Math.PI / 4);
  9591. tmpContext.fillStyle = "#db6e6e";
  9592. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9593. } else if (obj.name == "teleporter") {
  9594. tmpContext.fillStyle = "#7e7f82";
  9595. renderCircle(0, 0, obj.scale, tmpContext);
  9596. tmpContext.fill();
  9597. tmpContext.stroke();
  9598. tmpContext.rotate(Math.PI / 4);
  9599. tmpContext.fillStyle = "#d76edb";
  9600. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9601. }
  9602. tmpContext.restore();
  9603. }
  9604.  
  9605. let objSprites = [];
  9606.  
  9607. function getObjSprite(obj) {
  9608. let tmpSprite = objSprites[obj.id];
  9609. if (!tmpSprite) {
  9610. // let blurScale = isNight ? 20 : 0;
  9611. let tmpCanvas = document.createElement("canvas");
  9612. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  9613. let tmpContext = tmpCanvas.getContext("2d");
  9614. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9615. tmpContext.rotate(Math.PI / 2);
  9616. tmpContext.strokeStyle = outlineColor;
  9617. tmpContext.lineWidth = outlineWidth;
  9618. // if (isNight) {
  9619. // tmpContext.shadowBlur = 20;
  9620. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9621. // }
  9622. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9623. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9624. let tmpScale = obj.scale * 0.6;
  9625. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9626. tmpContext.fill();
  9627. tmpContext.stroke();
  9628. tmpContext.fillStyle = "#a5974c";
  9629. renderCircle(0, 0, tmpScale, tmpContext);
  9630. tmpContext.fillStyle = "#cc5151";
  9631. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9632. } else if (obj.name == "pit trap") {
  9633. tmpContext.fillStyle = "#a5974c";
  9634. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9635. tmpContext.fill();
  9636. tmpContext.stroke();
  9637. tmpContext.fillStyle = "#cc5151";
  9638. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9639. tmpContext.fill();
  9640. }
  9641. tmpSprite = tmpCanvas;
  9642. objSprites[obj.id] = tmpSprite;
  9643. }
  9644. return tmpSprite;
  9645. }
  9646.  
  9647. // GET MARK SPRITE:
  9648. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9649. let center = {
  9650. x: screenWidth / 2,
  9651. y: screenHeight / 2,
  9652. };
  9653. tmpContext.lineWidth = outlineWidth;
  9654. mainContext.globalAlpha = 0.2;
  9655. tmpContext.strokeStyle = outlineColor;
  9656. tmpContext.save();
  9657. tmpContext.translate(tmpX, tmpY);
  9658. tmpContext.rotate(90**10);
  9659. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9660. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9661. var tmpScale = (obj.scale);
  9662. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9663. tmpContext.fill();
  9664. tmpContext.stroke();
  9665. tmpContext.fillStyle = "#a5974c";
  9666. renderCircle(0, 0, tmpScale, tmpContext);
  9667. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9668. tmpContext.fillStyle = "#a34040";
  9669. } else {
  9670. tmpContext.fillStyle = "#c9b758";
  9671. }
  9672. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9673. } else if (obj.name == "turret") {
  9674. renderCircle(0, 0, obj.scale, tmpContext);
  9675. tmpContext.fill();
  9676. tmpContext.stroke();
  9677. tmpContext.fillStyle = "#939393";
  9678. let tmpLen = 50;
  9679. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9680. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9681. tmpContext.fill();
  9682. tmpContext.stroke();
  9683. } else if (obj.name == "teleporter") {
  9684. tmpContext.fillStyle = "#7e7f82";
  9685. renderCircle(0, 0, obj.scale, tmpContext);
  9686. tmpContext.fill();
  9687. tmpContext.stroke();
  9688. tmpContext.rotate(Math.PI / 4);
  9689. tmpContext.fillStyle = "#d76edb";
  9690. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9691. } else if (obj.name == "platform") {
  9692. tmpContext.fillStyle = "#cebd5f";
  9693. let tmpCount = 4;
  9694. let tmpS = obj.scale * 2;
  9695. let tmpW = tmpS / tmpCount;
  9696. let tmpX = -(obj.scale / 2);
  9697. for (let i = 0; i < tmpCount; ++i) {
  9698. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9699. tmpContext.fill();
  9700. tmpContext.stroke();
  9701. tmpX += tmpS / tmpCount;
  9702. }
  9703. } else if (obj.name == "healing pad") {
  9704. tmpContext.fillStyle = "#7e7f82";
  9705. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9706. tmpContext.fill();
  9707. tmpContext.stroke();
  9708. tmpContext.fillStyle = "#db6e6e";
  9709. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9710. } else if (obj.name == "spawn pad") {
  9711. tmpContext.fillStyle = "#7e7f82";
  9712. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9713. tmpContext.fill();
  9714. tmpContext.stroke();
  9715. tmpContext.fillStyle = "#71aad6";
  9716. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9717. } else if (obj.name == "blocker") {
  9718. tmpContext.fillStyle = "#7e7f82";
  9719. renderCircle(0, 0, obj.scale, tmpContext);
  9720. tmpContext.fill();
  9721. tmpContext.stroke();
  9722. tmpContext.rotate(Math.PI / 4);
  9723. tmpContext.fillStyle = "#db6e6e";
  9724. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9725. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9726. tmpContext.fillStyle = "#a5974c";
  9727. renderCircle(0, 0, obj.scale, tmpContext);
  9728. tmpContext.fillStyle = "#c9b758";
  9729. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9730. tmpContext.fillStyle = "#a5974c";
  9731. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9732.  
  9733. } else if (obj.name == "pit trap") {
  9734. tmpContext.fillStyle = "#a5974c";
  9735. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9736. tmpContext.fill();
  9737. tmpContext.stroke();
  9738. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9739. tmpContext.fillStyle = "#a34040";
  9740. } else {
  9741. tmpContext.fillStyle = outlineColor;
  9742. }
  9743. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9744. tmpContext.fill();
  9745. }
  9746. tmpContext.restore();
  9747. }
  9748.  
  9749. // OBJECT ON SCREEN:
  9750. function isOnScreen(x, y, s) {
  9751. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9752. s,
  9753. maxScreenHeight));
  9754. }
  9755.  
  9756. // RENDER GAME OBJECTS:
  9757. function renderGameObjects(layer, xOffset, yOffset) {
  9758. let tmpSprite;
  9759. let tmpX;
  9760. let tmpY;
  9761. liztobj.forEach((tmp) => {
  9762. tmpObj = tmp;
  9763. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9764. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9765. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9766. if (layer == 0) {
  9767. tmpObj.update(delta);
  9768. }
  9769. mainContext.globalAlpha = tmpObj.alpha;
  9770. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9771. if (tmpObj.isItem) {
  9772. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9773. tmpSprite = getObjSprite(tmpObj);
  9774. } else {
  9775. tmpSprite = getItemSprite(tmpObj);
  9776. }
  9777.  
  9778. mainContext.save();
  9779. mainContext.translate(tmpX, tmpY);
  9780. mainContext.rotate(tmpObj.dir);
  9781. if (!tmpObj.active) {
  9782. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9783. }
  9784. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9785.  
  9786. if (tmpObj.blocker) {
  9787. mainContext.strokeStyle = "#db6e6e";
  9788. mainContext.globalAlpha = 0.3;
  9789. mainContext.lineWidth = 6;
  9790. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9791. }
  9792. mainContext.restore();
  9793. } else {
  9794. tmpSprite = getResSprite(tmpObj);
  9795. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9796. }
  9797. }
  9798. if (layer == 3 && !useWasd) {
  9799. if (tmpObj.health < tmpObj.maxHealth) {
  9800. // HEALTH HOLDER:
  9801. mainContext.fillStyle = darkOutlineColor;
  9802. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9803. mainContext.fill();
  9804.  
  9805. // HEALTH BAR:
  9806. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  9807. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9808. mainContext.fill();
  9809. }
  9810. }
  9811. }
  9812. });
  9813.  
  9814. // PLACE VISIBLE:
  9815. if (layer == 0) {
  9816. if (placeVisible.length) {
  9817. placeVisible.forEach((places) => {
  9818. tmpX = places.x - xOffset;
  9819. tmpY = places.y - yOffset;
  9820. markObject(places, tmpX, tmpY);
  9821. });
  9822. }
  9823. }
  9824. }
  9825.  
  9826. function markObject(tmpObj, tmpX, tmpY) {
  9827. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9828. }
  9829.  
  9830. // RENDER MINIMAP:
  9831. class MapPing {
  9832. constructor(color, scale) {
  9833. this.init = function(x, y) {
  9834. this.scale = 0;
  9835. this.x = x;
  9836. this.y = y;
  9837. this.active = true;
  9838. };
  9839. this.update = function(ctxt, delta) {
  9840. if (this.active) {
  9841. this.scale += 0.05 * delta;
  9842. if (this.scale >= scale) {
  9843. this.active = false;
  9844. } else {
  9845. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9846. ctxt.beginPath();
  9847. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9848. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9849. ctxt.stroke();
  9850. }
  9851. }
  9852. };
  9853. this.color = color;
  9854. }
  9855. }
  9856.  
  9857. function pingMap(x, y) {
  9858. tmpPing = mapPings.find(pings => !pings.active);
  9859. if (!tmpPing) {
  9860. tmpPing = new MapPing("#fff", config.mapPingScale);
  9861. mapPings.push(tmpPing);
  9862. }
  9863. tmpPing.init(x, y);
  9864. }
  9865.  
  9866. function updateMapMarker() {
  9867. mapMarker.x = player.x;
  9868. mapMarker.y = player.y;
  9869. }
  9870.  
  9871. function renderMinimap(delta) {
  9872. if (player && player.alive) {
  9873. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9874.  
  9875. // RENDER PINGS:
  9876. mapContext.lineWidth = 4;
  9877. for (let i = 0; i < mapPings.length; ++i) {
  9878. tmpPing = mapPings[i];
  9879. mapContext.strokeStyle = tmpPing.color;
  9880. tmpPing.update(mapContext, delta);
  9881. }
  9882.  
  9883. // RENDER BREAK TRACKS:
  9884. mapContext.globalAlpha = 1;
  9885. mapContext.fillStyle = "#ff0000";
  9886. if (breakTrackers.length) {
  9887. mapContext.fillStyle = "#abcdef";
  9888. mapContext.font = "34px HammerSmith One";
  9889. mapContext.textBaseline = "middle";
  9890. mapContext.textAlign = "center";
  9891. for (let i = 0; i < breakTrackers.length;) {
  9892. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9893. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9894. i += 2;
  9895. }
  9896. }
  9897.  
  9898. // RENDER PLAYERS:
  9899. mapContext.globalAlpha = 1;
  9900. mapContext.fillStyle = "#fff";
  9901. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9902. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9903. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9904. if (player.team && minimapData) {
  9905. for (let i = 0; i < minimapData.length;) {
  9906. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9907. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9908. i += 2;
  9909. }
  9910. }
  9911.  
  9912. // RENDER BOTS:
  9913. if (bots.length) {
  9914. bots.forEach((tmp) => {
  9915. if (tmp.inGame) {
  9916. mapContext.globalAlpha = 1;
  9917. mapContext.strokeStyle = "#cc5151";
  9918. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9919. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9920. }
  9921. });
  9922. }
  9923.  
  9924. // DEATH LOCATION:
  9925. if (lastDeath) {
  9926. mapContext.fillStyle = "#fc5553";
  9927. mapContext.font = "34px HammerSmith One";
  9928. mapContext.textBaseline = "middle";
  9929. mapContext.textAlign = "center";
  9930. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9931. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9932. }
  9933.  
  9934. // MAP MARKER:
  9935. if (mapMarker) {
  9936. mapContext.fillStyle = "#fff";
  9937. mapContext.font = "34px HammerSmith One";
  9938. mapContext.textBaseline = "middle";
  9939. mapContext.textAlign = "center";
  9940. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9941. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9942. }
  9943. }
  9944. }
  9945.  
  9946. // ICONS:
  9947. let crossHairs = ["https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&", "https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&"];
  9948. let crossHairSprites = {};
  9949. let iconSprites = {};
  9950. let icons = ["crown", "skull"];
  9951.  
  9952. function loadIcons() {
  9953. for (let i = 0; i < icons.length; ++i) {
  9954. let tmpSprite = new Image();
  9955. tmpSprite.onload = function() {
  9956. this.isLoaded = true;
  9957. };
  9958. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9959. iconSprites[icons[i]] = tmpSprite;
  9960. }
  9961. for (let i = 0; i < crossHairs.length; ++i) {
  9962. let tmpSprite = new Image();
  9963. tmpSprite.onload = function() {
  9964. this.isLoaded = true;
  9965. };
  9966. tmpSprite.src = crossHairs[i];
  9967. crossHairSprites[i] = tmpSprite;
  9968. }
  9969. }
  9970. loadIcons();
  9971.  
  9972. function cdf (e, t){
  9973. try {
  9974. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9975. } catch(e){
  9976. return Infinity;
  9977. }
  9978. }
  9979. // UPDATE GAME:
  9980. function updateGame() {
  9981. if(gameObjects.length && inGame) {
  9982. gameObjects.forEach((tmp) => {
  9983. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  9984. if(!liztobj.includes(tmp)) {
  9985. liztobj.push(tmp);
  9986. tmp.render = true;
  9987. }
  9988. } else {
  9989. if(liztobj.includes(tmp)) {
  9990. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9991. tmp.render = false;
  9992. const index = liztobj.indexOf(tmp);
  9993. if (index > -1) { // only splice array when item is found
  9994. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9995. }
  9996. }
  9997. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9998. tmp.render = false;
  9999. const index = liztobj.indexOf(tmp);
  10000. if (index > -1) { // only splice array when item is found
  10001. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10002. }
  10003. } else {
  10004. tmp.render = false;
  10005. const index = liztobj.indexOf(tmp);
  10006. if (index > -1) { // only splice array when item is found
  10007. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10008. }
  10009. }
  10010. }
  10011. })
  10012. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10013. }
  10014.  
  10015. // if (config.resetRender) {
  10016. mainContext.beginPath();
  10017. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10018. // }
  10019. mainContext.globalAlpha = 1;
  10020.  
  10021. // MOVE CAMERA:
  10022. if (player) {
  10023. if (false) {
  10024. camX = player.x;
  10025. camY = player.y;
  10026. } else {
  10027. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10028. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10029. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  10030. if (tmpDist > 0.05) {
  10031. camX += camSpd * Math.cos(tmpDir);
  10032. camY += camSpd * Math.sin(tmpDir);
  10033. } else {
  10034. camX = player.x;
  10035. camY = player.y;
  10036. }
  10037. }
  10038. } else {
  10039. camX = config.mapScale / 2 + config.riverWidth;
  10040. camY = config.mapScale / 2;
  10041. }
  10042. // PATHFINDER LINE
  10043. if (pathFind.active) {
  10044. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10045. mainContext.lineWidth = player.scale / 5;
  10046. mainContext.globalAlpha = 1;
  10047. mainContext.strokeStyle = "red";
  10048. mainContext.beginPath();
  10049. pathFind.array.forEach((path, i) => {
  10050. let pathXY = {
  10051. x: (pathFind.scale / pathFind.grid) * path.x,
  10052. y: (pathFind.scale / pathFind.grid) * path.y
  10053. }
  10054. let render = {
  10055. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10056. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10057. }
  10058. if (i == 0) {
  10059. mainContext.moveTo(render.x, render.y);
  10060. } else {
  10061. mainContext.lineTo(render.x, render.y);
  10062. }
  10063. });
  10064. mainContext.stroke();
  10065. }
  10066. }
  10067. // INTERPOLATE PLAYERS AND AI:
  10068. let lastTime = now - (1000 / config.serverUpdateRate);
  10069. let tmpDiff;
  10070. for (let i = 0; i < players.length + ais.length; ++i) {
  10071. tmpObj = players[i] || ais[i - players.length];
  10072. if (tmpObj && tmpObj.visible) {
  10073. if (tmpObj.forcePos) {
  10074. tmpObj.x = tmpObj.x2;
  10075. tmpObj.y = tmpObj.y2;
  10076. tmpObj.dir = tmpObj.d2;
  10077. } else {
  10078. let total = tmpObj.t2 - tmpObj.t1;
  10079. let fraction = lastTime - tmpObj.t1;
  10080. let ratio = (fraction / total);
  10081. let rate = 170;
  10082. tmpObj.dt += delta;
  10083. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10084. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10085. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10086. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10087. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10088. if (config.anotherVisual) {
  10089. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10090. } else {
  10091. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10092. }
  10093. }
  10094. }
  10095. }
  10096.  
  10097. // RENDER CORDS:
  10098. let xOffset = camX - (maxScreenWidth / 2);
  10099. let yOffset = camY - (maxScreenHeight / 2);
  10100.  
  10101. // RENDER BACKGROUND:
  10102. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10103. mainContext.fillStyle = "#b6db66";
  10104. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10105. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10106. mainContext.fillStyle = "#dbc666";
  10107. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10108. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10109. mainContext.fillStyle = "#fff";
  10110. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10111. } else if (config.snowBiomeTop - yOffset >= 0) {
  10112. mainContext.fillStyle = "#fff";
  10113. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10114. mainContext.fillStyle = "#b6db66";
  10115. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10116. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10117. } else {
  10118. mainContext.fillStyle = "#b6db66";
  10119. mainContext.fillRect(0, 0, maxScreenWidth,
  10120. (config.mapScale - config.snowBiomeTop - yOffset));
  10121. mainContext.fillStyle = "#dbc666";
  10122. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10123. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10124. }
  10125.  
  10126. // RENDER WATER AREAS:
  10127. if (!firstSetup) {
  10128. waterMult += waterPlus * config.waveSpeed * delta;
  10129. if (waterMult >= config.waveMax) {
  10130. waterMult = config.waveMax;
  10131. waterPlus = -1;
  10132. } else if (waterMult <= 1) {
  10133. waterMult = waterPlus = 1;
  10134. }
  10135. mainContext.globalAlpha = 1;
  10136. mainContext.fillStyle = "#dbc666";
  10137. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10138. mainContext.fillStyle = "#91b2db";
  10139. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10140. }
  10141.  
  10142. // RENDER DEAD PLAYERS:
  10143. mainContext.globalAlpha = 1;
  10144. mainContext.strokeStyle = outlineColor;
  10145. renderDeadPlayers(xOffset, yOffset);
  10146.  
  10147. // RENDER BOTTOM LAYER:
  10148. mainContext.globalAlpha = 1;
  10149. mainContext.strokeStyle = outlineColor;
  10150. renderGameObjects(-1, xOffset, yOffset);
  10151.  
  10152. // RENDER PROJECTILES:
  10153. mainContext.globalAlpha = 1;
  10154. mainContext.lineWidth = outlineWidth;
  10155. renderProjectiles(0, xOffset, yOffset);
  10156.  
  10157. // RENDER PLAYERS:
  10158. renderPlayers(xOffset, yOffset, 0);
  10159.  
  10160. // RENDER AI:
  10161. mainContext.globalAlpha = 1;
  10162. for (let i = 0; i < ais.length; ++i) {
  10163. tmpObj = ais[i];
  10164. if (tmpObj.active && tmpObj.visible) {
  10165. tmpObj.animate(delta);
  10166. mainContext.save();
  10167. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10168. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10169. renderAI(tmpObj, mainContext);
  10170. mainContext.restore();
  10171. }
  10172. }
  10173.  
  10174. // RENDER GAME OBJECTS (LAYERED):
  10175. renderGameObjects(0, xOffset, yOffset);
  10176. renderProjectiles(1, xOffset, yOffset);
  10177. renderGameObjects(1, xOffset, yOffset);
  10178. renderPlayers(xOffset, yOffset, 1);
  10179. renderGameObjects(2, xOffset, yOffset);
  10180. renderGameObjects(3, xOffset, yOffset);
  10181.  
  10182. // MAP BOUNDARIES:
  10183. mainContext.fillStyle = "#000";
  10184. mainContext.globalAlpha = 0.09;
  10185. if (xOffset <= 0) {
  10186. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10187. }
  10188. if (config.mapScale - xOffset <= maxScreenWidth) {
  10189. let tmpY = Math.max(0, -yOffset);
  10190. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10191. }
  10192. if (yOffset <= 0) {
  10193. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10194. }
  10195. if (config.mapScale - yOffset <= maxScreenHeight) {
  10196. let tmpX = Math.max(0, -xOffset);
  10197. let tmpMin = 0;
  10198. if (config.mapScale - xOffset <= maxScreenWidth)
  10199. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10200. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10201. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10202. }
  10203.  
  10204. // RENDER DAY/NIGHT TIME:
  10205. mainContext.globalAlpha = 1;
  10206. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  10207. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10208.  
  10209. // RENDER PLAYER AND AI UI:
  10210. mainContext.strokeStyle = darkOutlineColor;
  10211. mainContext.globalAlpha = 1;
  10212.  
  10213. for (let i = 0; i < players.length + ais.length; ++i) {
  10214. tmpObj = players[i] || ais[i - players.length];
  10215. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  10216. mainContext.strokeStyle = darkOutlineColor;
  10217.  
  10218. // NAME AND HEALTH:
  10219.  
  10220. // let izbot = false;
  10221.  
  10222. // bots.forEach((bot) => {
  10223. // if (tmpObj.sid == bot.sid) izbot = true
  10224. // else izbot = false;
  10225. // });
  10226.  
  10227. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  10228. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  10229. // bots.forEach((bot) => {
  10230. // if (tmpObj.sid == bot.sid) return;
  10231. // });
  10232.  
  10233. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  10234. mainContext.fillStyle = "#fff";
  10235. mainContext.textBaseline = "middle";
  10236. mainContext.textAlign = "center";
  10237. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10238. mainContext.lineJoin = "round";
  10239. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10240. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10241. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10242. let tmpS = config.crownIconScale;
  10243. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10244. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10245. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10246. }
  10247. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10248. let tmpS = config.crownIconScale;
  10249. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10250. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10251. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10252. }
  10253. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  10254. let tmpS = tmpObj.scale * 2.2;
  10255. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10256. }
  10257. // izbot = false;
  10258. }
  10259. if (tmpObj.health > 0) {
  10260.  
  10261. if(tmpObj.name != "Trash Slave") {
  10262. // HEALTH HOLDER:
  10263. mainContext.fillStyle = darkOutlineColor;
  10264. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10265. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10266. (config.healthBarPad * 2), 17, 8);
  10267. mainContext.fill();
  10268.  
  10269. // HEALTH BAR:
  10270. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10271. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10272. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10273. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10274. mainContext.fill();
  10275. }
  10276.  
  10277. if (tmpObj.isPlayer) {
  10278. mainContext.globalAlpha = 1;
  10279. let targetReloads = {
  10280. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10281. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10282. turret: (2500 - tmpObj.reloads[53]) / 2500
  10283. };
  10284. if (!tmpObj.currentReloads) {
  10285. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10286. primary: targetReloads.primary,
  10287. secondary: targetReloads.secondary,
  10288. turret: targetReloads.turret
  10289. };
  10290. }
  10291. const lerpFactor = 0.3;
  10292. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10293. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10294. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10295.  
  10296. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10297. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10298. const centerX = tmpObj.x - xOffset;
  10299. const centerY = tmpObj.y - yOffset;
  10300. const barRadius = 35;
  10301. const barWidth = 15;
  10302. const totalAngle = (Math.PI*2)/3; // Half circle
  10303. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10304. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10305. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10306. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10307.  
  10308. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10309. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10310. function returncoolcolor(RainbowCycle) {
  10311. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  10312. }
  10313.  
  10314. mainContext.save();
  10315. if (tmpObj.currentReloads.primary < 0.999) {
  10316. mainContext.beginPath();
  10317. mainContext.lineCap = 'round';
  10318. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10319. mainContext.lineWidth = 4;
  10320. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10321. mainContext.stroke();
  10322. }
  10323. if (tmpObj.currentReloads.secondary < 0.999) {
  10324. mainContext.beginPath();
  10325. mainContext.lineCap = 'round';
  10326. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10327. mainContext.lineWidth = 4;
  10328. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10329. mainContext.stroke();
  10330. }
  10331. if (tmpObj.currentReloads.turret < 0.999) {
  10332. mainContext.beginPath();
  10333. mainContext.lineCap = 'round';
  10334. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10335. mainContext.lineWidth = 4;
  10336. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10337. mainContext.stroke();
  10338. }
  10339. mainContext.restore();
  10340.  
  10341. if(tmpObj.name != "Trash Slave") {
  10342. // SHAME COUNT:
  10343. mainContext.globalAlpha = 1;
  10344. mainContext.font = "24px HammerSmith One";
  10345. mainContext.fillStyle = "#fff";
  10346. mainContext.strokeStyle = darkOutlineColor;
  10347. mainContext.textBaseline = "middle";
  10348. mainContext.textAlign = "center";
  10349. mainContext.lineWidth = 8;
  10350. mainContext.lineJoin = "round";
  10351. let tmpS = config.crownIconScale;
  10352. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  10353. 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);
  10354. 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);
  10355. }
  10356.  
  10357. // PLAYER TRACER:
  10358. if (!tmpObj.isTeam(player)) {
  10359. let center = {
  10360. x: screenWidth / 2,
  10361. y: screenHeight / 2,
  10362. };
  10363. 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);
  10364. let dist = center.y * alpha / 2;
  10365. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10366. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10367. mainContext.save();
  10368. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10369. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10370. let by = 255 - (tmpObj.sid * 2);
  10371. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10372. mainContext.globalAlpha = alpha;
  10373. let renderTracer = function(s, ctx) {
  10374. ctx = ctx || mainContext;
  10375. let h = s * (Math.sqrt(3) / 2);
  10376. ctx.beginPath();
  10377. ctx.moveTo(0, -h / 1.5);
  10378. ctx.lineTo(-s / 2, h / 2);
  10379. ctx.lineTo(s / 2, h / 2);
  10380. ctx.lineTo(0, -h / 1.5);
  10381. ctx.fill();
  10382. ctx.closePath();
  10383. }
  10384. renderTracer(25, mainContext);
  10385. mainContext.restore();
  10386. }
  10387.  
  10388. if (getEl("predictType").value == "pre2") {
  10389. mainContext.lineWidth = 3;
  10390. mainContext.strokeStyle = "#fff";
  10391. mainContext.globalAlpha = 1;
  10392. mainContext.beginPath();
  10393. let render = {
  10394. x: tmpObj.x2 - xOffset,
  10395. y: tmpObj.y2 - yOffset
  10396. };
  10397. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10398. mainContext.lineTo(render.x, render.y);
  10399. mainContext.stroke();
  10400. } else if (getEl("predictType").value == "pre3") {
  10401. mainContext.lineWidth = 3;
  10402. mainContext.strokeStyle = "#cc5151";
  10403. mainContext.globalAlpha = 1;
  10404. mainContext.beginPath();
  10405. let render = {
  10406. x: tmpObj.x3 - xOffset,
  10407. y: tmpObj.y3 - yOffset
  10408. };
  10409. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10410. mainContext.lineTo(render.x, render.y);
  10411. mainContext.stroke();
  10412. }
  10413.  
  10414. }
  10415. }
  10416. }
  10417. }
  10418.  
  10419. if (player) {
  10420.  
  10421. // AUTOPUSH LINE:
  10422. if (my.autoPush && my.pushData) {
  10423. mainContext.lineWidth = 5;
  10424. mainContext.globalAlpha = 1;
  10425. mainContext.beginPath();
  10426. var x1 = player.x - xOffset;
  10427. var y1 = player.y - yOffset;
  10428. var x2 = my.pushData.x2 - xOffset;
  10429. var y2 = my.pushData.y2 - yOffset;
  10430. var x3 = my.pushData.x - xOffset;
  10431. var y3 = my.pushData.y - yOffset;
  10432.  
  10433. mainContext.moveTo(x1, y1);
  10434. mainContext.lineTo(x2, y2);
  10435. mainContext.lineTo(x3, y3);
  10436. mainContext.stroke();
  10437.  
  10438. var deltaX = x3 - x1;
  10439. var deltaY = y3 - y1;
  10440. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  10441.  
  10442. var maxDistance = 100;
  10443. var percentage = (distance / maxDistance) * 100;
  10444.  
  10445. percentage = Math.min(100, Math.max(0, percentage));
  10446. let spike;
  10447. mainContext.fillStyle = "white";
  10448. mainContext.strokeStyle = "black";
  10449. mainContext.lineWidth = 5;
  10450. mainContext.font = "27px Times New Roman";
  10451. 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) {
  10452. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10453. })[0];
  10454. if(nearTrap)
  10455. 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) {
  10456. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10457. })[0];
  10458.  
  10459. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  10460. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  10461.  
  10462. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10463. mainContext.strokeText(near.aim2, xx, yy);
  10464. mainContext.fillText(near.aim2, xx, yy);
  10465. }
  10466. }
  10467.  
  10468. mainContext.globalAlpha = 1;
  10469.  
  10470. // RENDER ANIM TEXTS:
  10471. textManager.update(delta, mainContext, xOffset, yOffset);
  10472.  
  10473. // RENDER CHAT MESSAGES:
  10474. for (let i = 0; i < players.length; ++i) {
  10475. tmpObj = players[i];
  10476. if (tmpObj.visible) {
  10477. if (tmpObj.chatCountdown > 0) {
  10478. tmpObj.chatCountdown -= delta;
  10479. if (tmpObj.chatCountdown <= 0)
  10480. tmpObj.chatCountdown = 0;
  10481. mainContext.font = "32px HammerSmith One";
  10482. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10483. mainContext.textBaseline = "middle";
  10484. mainContext.textAlign = "center";
  10485. let tmpX = tmpObj.x - xOffset;
  10486. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10487. let tmpH = 47;
  10488. let tmpW = tmpSize.width + 17;
  10489. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10490. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10491. mainContext.fill();
  10492. mainContext.fillStyle = "#fff";
  10493. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10494. }
  10495. if (tmpObj.chat.count > 0) {
  10496. if (!useWasd) {
  10497. tmpObj.chat.count -= delta;
  10498. if (tmpObj.chat.count <= 0)
  10499. tmpObj.chat.count = 0;
  10500. mainContext.font = "32px HammerSmith One";
  10501. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10502. mainContext.textBaseline = "middle";
  10503. mainContext.textAlign = "center";
  10504. let tmpX = tmpObj.x - xOffset;
  10505. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10506. let tmpH = 47;
  10507. let tmpW = tmpSize.width + 17;
  10508. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10509. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10510. mainContext.fill();
  10511. mainContext.fillStyle = "#ffffff99";
  10512. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10513. } else {
  10514. tmpObj.chat.count = 0;
  10515. }
  10516. }
  10517. }
  10518. }
  10519.  
  10520. if (allChats.length) {
  10521. allChats.filter(ch => ch.active).forEach((ch) => {
  10522. if (!ch.alive) {
  10523. if (ch.alpha <= 1) {
  10524. ch.alpha += delta / 250;
  10525. if (ch.alpha >= 1) {
  10526. ch.alpha = 1;
  10527. ch.alive = true;
  10528. }
  10529. }
  10530. } else {
  10531. ch.alpha -= delta / 5000;
  10532. if (ch.alpha <= 0) {
  10533. ch.alpha = 0;
  10534. ch.active = false;
  10535. }
  10536. }
  10537. if (ch.active) {
  10538. mainContext.font = "20px Ubuntu";
  10539. let tmpSize = mainContext.measureText(ch.chat);
  10540. mainContext.textBaseline = "middle";
  10541. mainContext.textAlign = "center";
  10542. let tmpX = ch.x - xOffset;
  10543. let tmpY = ch.y - yOffset - 90;
  10544. let tmpH = 40;
  10545. let tmpW = tmpSize.width + 15;
  10546.  
  10547. mainContext.globalAlpha = ch.alpha;
  10548.  
  10549. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10550. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10551. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10552. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  10553.  
  10554. mainContext.lineWidth = 5;
  10555. mainContext.fillStyle = "#ccc";
  10556. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10557.  
  10558. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10559. mainContext.stroke();
  10560. mainContext.fill();
  10561.  
  10562. mainContext.fillStyle = "#fff";
  10563. mainContext.strokeStyle = "#000";
  10564. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10565. mainContext.fillText(ch.chat, tmpX, tmpY);
  10566. ch.y -= delta / 100;
  10567. }
  10568. });
  10569. }
  10570.  
  10571. mainContext.globalAlpha = 1;
  10572.  
  10573. // RENDER MINIMAP:
  10574. renderMinimap(delta);
  10575. }
  10576.  
  10577. // UPDATE & ANIMATE:
  10578. window.requestAnimFrame = function() {
  10579. return null;
  10580. }
  10581. window.rAF = (function() {
  10582. return window.requestAnimationFrame ||
  10583. window.webkitRequestAnimationFrame ||
  10584. window.mozRequestAnimationFrame ||
  10585. function(callback) {
  10586. window.setTimeout(callback, 1000/9);
  10587. };
  10588. })();
  10589.  
  10590. function doUpdate() {
  10591. //rape modulus
  10592. now = performance.now();
  10593. delta = now - lastUpdate;
  10594. lastUpdate = now;
  10595. let timer = performance.now();
  10596. let diff = timer - fpsTimer.last;
  10597. if (diff >= 1000) {
  10598.  
  10599. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10600.  
  10601. fpsTimer.last = timer;
  10602. fpsTimer.time = 0;
  10603. }
  10604. fpsTimer.time++;
  10605.  
  10606. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  10607. getEl("packetStatus").innerHTML = secPacket;
  10608. updateGame();
  10609. rAF(doUpdate);
  10610. ms.avg = Math.round((ms.min+ms.max)/2);
  10611. }
  10612.  
  10613. prepareMenuBackground();
  10614. doUpdate();
  10615.  
  10616. function toggleUseless(boolean) {
  10617. getEl("instaType").disabled = boolean;
  10618. getEl("antiBullType").disabled = boolean;
  10619. getEl("predictType").disabled = boolean;
  10620. }
  10621. toggleUseless(useWasd);
  10622.  
  10623. let changeDays = {};
  10624. window.debug = function() {
  10625. my.waitHit = 0;
  10626. my.autoAim = false;
  10627. instaC.isTrue = false;
  10628. traps.inTrap = false;
  10629. itemSprites = [];
  10630. objSprites = [];
  10631. gameObjectSprites = [];
  10632. };
  10633. window.wasdMode = function() {
  10634. useWasd = !useWasd;
  10635. toggleUseless(useWasd);
  10636. };
  10637. window.startGrind = function() {
  10638. if (getEl("weaponGrind").checked) {
  10639. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10640. checkPlace(player.getItemType(22), i);
  10641. }
  10642. }
  10643. };
  10644. // REMOVED!!! so they cant abuse :)
  10645. let projects = [
  10646. "adorable-eight-guppy",
  10647. "galvanized-bittersweet-windshield"
  10648. ];
  10649. let botIDS = 0;
  10650. window.connectFillBots = function() {
  10651. botSkts = [];
  10652. botIDS = 0;
  10653. for (let i = 0; i < projects.length; i++) {
  10654. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10655. test.binaryType = "arraybuffer";
  10656.  
  10657. test.onopen = function() {
  10658. test.ssend = function(type) {
  10659. let data = Array.prototype.slice.call(arguments, 1);
  10660. let binary = window.msgpack.encode([type, data]);
  10661. test.send(binary);
  10662. };
  10663. for (let i = 0; i < 4; i++) {
  10664. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10665. action: "homepage"
  10666. }).then(function(token) {
  10667. let t = WS.url.split("wss://")[1].split("?")[0];
  10668. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10669. botSkts.push([test]);
  10670. botIDS++;
  10671. });
  10672. }
  10673. };
  10674. test.onmessage = function(message) {
  10675. let data = new Uint8Array(message.data);
  10676. let parsed = window.msgpack.decode(data);
  10677. let type = parsed[0];
  10678. data = parsed[1];
  10679. };
  10680. }
  10681. };
  10682. window.destroyFillBots = function() {
  10683. botSkts.forEach((socket) => {
  10684. socket[0].close();
  10685. });
  10686. botSkts = [];
  10687. };
  10688. window.tryConnectBots = function() {
  10689. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10690. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10691. action: "homepage"
  10692. }).then(function(token) {
  10693. // CONNECT SOCKET:
  10694. botSpawn(token);
  10695. });
  10696. }
  10697. };
  10698. window.destroyBots = function() {
  10699. bots.forEach((botyyyyy) => {
  10700. botyyyyy.closeSocket = true;
  10701. });
  10702. bots = [];
  10703. };
  10704. window.resBuild = function() {
  10705. if (gameObjects.length) {
  10706. gameObjects.forEach((tmp) => {
  10707. tmp.breakObj = false;
  10708. });
  10709. breakObjects = [];
  10710. }
  10711. };
  10712. window.toggleBotsCircle = function() {
  10713. player.circle = !player.circle;
  10714. };
  10715. window.toggleVisual = function() {
  10716. config.anotherVisual = !config.anotherVisual;
  10717. gameObjects.forEach((tmp) => {
  10718. if (tmp.active) {
  10719. tmp.dir = tmp.lastDir;
  10720. }
  10721. });
  10722. };
  10723. window.prepareUI = function(tmpObj) {
  10724. resize();
  10725. // CHAT STUFF:
  10726. var chatBox = document.getElementById("chatBox");
  10727. var chatHolder = document.getElementById("chatHolder");
  10728. var suggestBox = document.createElement("div");
  10729. suggestBox.id = "suggestBox";
  10730.  
  10731. var prevChats = [];
  10732. var prevChatsIndex = 0;
  10733.  
  10734. function toggleChat() {
  10735. if (!usingTouch) {
  10736. if (chatHolder.style.display == "block") {
  10737. if (chatBox.value) {
  10738. sendChat(chatBox.value);
  10739. }
  10740. closeChat();
  10741. } else {
  10742. storeMenu.style.display = "none";
  10743. allianceMenu.style.display = "none";
  10744. chatHolder.style.display = "block";
  10745. chatBox.focus();
  10746. resetMoveDir();
  10747. }
  10748. } else {
  10749. setTimeout(function () {
  10750. var chatMessage = prompt("chat message");
  10751. if (chatMessage) {
  10752. sendChat(chatMessage);
  10753. }
  10754. }, 1);
  10755. }
  10756. chatBox.value = "";
  10757. (() => {
  10758. prevChatsIndex = 0;
  10759. })();
  10760. }
  10761.  
  10762. function closeChat() {
  10763. chatBox.value = "";
  10764. chatHolder.style.display = "none";
  10765. }
  10766.  
  10767. // ACTION BAR:
  10768. UTILS.removeAllChildren(actionBar);
  10769.  
  10770. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10771. (function (i) {
  10772. UTILS.generateElement({
  10773. id: "actionBarItem" + i,
  10774. class: "actionBarItem",
  10775. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10776. onmouseout: function () {
  10777. showItemInfo();
  10778. },
  10779. parent: actionBar
  10780. });
  10781. })(i);
  10782. }
  10783.  
  10784. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10785. (function (i) {
  10786. let tmpCanvas = document.createElement("canvas");
  10787. tmpCanvas.width = tmpCanvas.height = 66;
  10788. let tmpContext = tmpCanvas.getContext("2d");
  10789. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10790. tmpContext.imageSmoothingEnabled = false;
  10791. tmpContext.webkitImageSmoothingEnabled = false;
  10792. tmpContext.mozImageSmoothingEnabled = false;
  10793.  
  10794. if (items.weapons[i]) {
  10795. tmpContext.rotate((Math.PI));
  10796. let tmpSprite = new Image();
  10797. toolSprites[items.weapons[i].src] = tmpSprite;
  10798. tmpSprite.onload = function () {
  10799. this.isLoaded = true;
  10800. let tmpPad = 1 / (this.height / this.width);
  10801. let tmpMlt = (items.weapons[i].iPad || 1);
  10802. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10803. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10804. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10805. tmpContext.globalCompositeOperation = "source-atop";
  10806. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10807. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10808. };
  10809. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10810. let tmpUnit = getEl('actionBarItem' + i);
  10811. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10812. // showItemInfo(items.weapons[i], true);
  10813. // });
  10814. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10815. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10816. });
  10817. UTILS.hookTouchEvents(tmpUnit);
  10818. } else {
  10819. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10820. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10821. tmpContext.globalAlpha = 1;
  10822. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10823. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10824. tmpContext.globalCompositeOperation = "source-atop";
  10825. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10826. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10827. let tmpUnit = getEl('actionBarItem' + i);
  10828. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10829. // showItemInfo(items.list[i - items.weapons.length]);
  10830. // });
  10831. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10832. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10833. });
  10834. UTILS.hookTouchEvents(tmpUnit);
  10835. }
  10836. })(i);
  10837. }
  10838. };
  10839. window.profineTest = function(data) {
  10840. if (data) {
  10841. // VALIDATE NAME:
  10842. let name = data + "";
  10843. name = name.slice(0, config.maxNameLength);
  10844.  
  10845. return name;
  10846. }
  10847. }
  10848. }(1)