Greasy Fork is available in English.

Saviour Saves

Saviour saved you

  1. // ==UserScript==
  2. // @name Saviour Saves
  3. // @version v1
  4. // @author GOD/Heavenly
  5. // @description Saviour saved you
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @icon https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/0f906cc5-a900-46b5-8b35-5170ff736f4a/dfqc385-3db27370-1cbe-490b-b56f-019902cbb25c.jpg/v1/fill/w_736,h_736,q_75,strp/god_of_light__by_escanor333_dfqc385-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9NzM2IiwicGF0aCI6IlwvZlwvMGY5MDZjYzUtYTkwMC00NmI1LThiMzUtNTE3MGZmNzM2ZjRhXC9kZnFjMzg1LTNkYjI3MzcwLTFjYmUtNDkwYi1iNTZmLTAxOTkwMmNiYjI1Yy5qcGciLCJ3aWR0aCI6Ijw9NzM2In1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmltYWdlLm9wZXJhdGlvbnMiXX0.Af2-qm7Vt-Le4ogtUi3P_CHWU-WxSMZ8L7LWTWysnTE
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/1361862
  11. // ==/UserScript==
  12.  
  13.  
  14.  
  15.  
  16. // Test Auto Reply
  17. let founda = false;
  18. let scriptTags = document.getElementsByTagName("script");
  19. for (let i = 0; i < scriptTags.length; i++) {
  20. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  21. scriptTags[i].remove();
  22. founda = true;
  23. break;
  24. }
  25. }
  26.  
  27. var styleItem = document.createElement("style");
  28. styleItem.type = "text/css";
  29. styleItem.appendChild(document.createTextNode(`
  30. #suggestBox {
  31. width: 355px;
  32. border-radius: 3px;
  33. background-color: rgba(0,0,0,0.5);
  34. margin: auto;
  35. text-align: left;
  36. z-index: 49;
  37. pointer-events: auto;
  38. position: relative;
  39. bottom: 3.5px;
  40. overflow-y: auto;
  41. }
  42. #suggestBox div {
  43. background-color: rgba(255,255,255,0);
  44. color: rgba(255,255,255,1);
  45. transition: background-color 0.3s, color 0.3s;
  46. }
  47. #suggestBox div:hover {
  48. background-color: rgba(255,255,255,0.2);
  49. color: rgba(0,0,0,1);
  50. }
  51. .suggestBoxHard {
  52. color: rgba(255,255,255,1);
  53. font-size: 18px;
  54. }
  55. .suggestBoxLight {
  56. color: rgba(255,255,255,0.7);
  57. font-size: 18px;
  58. }
  59. `));
  60. document.head.appendChild(styleItem);
  61.  
  62. window.addEventListener('load', function() {
  63. var allianceButton = document.getElementById('allianceButton');
  64. var storeButton = document.getElementById('storeButton');
  65. if (storeButton) {
  66. storeButton.style.right = '26px';
  67. storeButton.style.top = '420px';
  68. }
  69. if (allianceButton) {
  70. allianceButton.style.right = '26px';
  71. allianceButton.style.top = '479px';
  72. }
  73. });
  74.  
  75. function getEl(id) {
  76. return document.getElementById(id);
  77. }
  78.  
  79. !function(run) {
  80.  
  81. let newFont = document.createElement("link");
  82. newFont.rel = "stylesheet";
  83. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  84. newFont.type = "text/css";
  85. document.body.append(newFont);
  86.  
  87. let min = document.createElement("script");
  88. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  89. document.body.append(min);
  90. window.oncontextmenu = function() {
  91. return false;
  92. };
  93.  
  94. let config = window.config;
  95.  
  96. // CLIENT:
  97. config.clientSendRate = 9; // Aim Packet Send Rate
  98. config.serverUpdateRate = 9;
  99.  
  100. // UI:
  101. config.deathFadeout = 0;
  102.  
  103. config.playerCapacity = 9999;
  104.  
  105. // CHECK IN SANDBOX:
  106. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  107.  
  108. // CUSTOMIZATION:
  109. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  110. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  111. "#8bc373", "#91b2db"
  112. ];
  113. config.weaponVariants = [{
  114. id: 0,
  115. src: "",
  116. xp: 0,
  117. val: 1,
  118. }, {
  119. id: 1,
  120. src: "_g",
  121. xp: 3000,
  122. val: 1.1,
  123. }, {
  124. id: 2,
  125. src: "_d",
  126. xp: 7000,
  127. val: 1.18,
  128. }, {
  129. id: 3,
  130. src: "_r",
  131. poison: true,
  132. xp: 12000,
  133. val: 1.18,
  134. }, {
  135. id: 4,
  136. src: "_e",
  137. poison: true,
  138. heal: true,
  139. xp: 24000,
  140. val: 1.18,
  141. }];
  142.  
  143. // VISUAL:
  144. config.anotherVisual = true;
  145. config.useWebGl = false;
  146. config.resetRender = true;
  147.  
  148. function waitTime(timeout) {
  149. return new Promise((done) => {
  150. setTimeout(() => {
  151. done();
  152. }, timeout);
  153. });
  154. }
  155.  
  156. let botSkts = [];
  157.  
  158. // STORAGE:
  159. let canStore;
  160. if (typeof(Storage) !== "undefined") {
  161. canStore = true;
  162. }
  163.  
  164. function saveVal(name, val) {
  165. if (canStore)
  166. localStorage.setItem(name, val);
  167. }
  168.  
  169. function deleteVal(name) {
  170. if (canStore)
  171. localStorage.removeItem(name);
  172. }
  173.  
  174. function getSavedVal(name) {
  175. if (canStore)
  176. return localStorage.getItem(name);
  177. return null;
  178. }
  179.  
  180. // CONFIGS:
  181. let gC = function(a, b) {
  182. try {
  183. let res = JSON.parse(getSavedVal(a));
  184. if (typeof res === "object") {
  185. return b;
  186. } else {
  187. return res;
  188. }
  189. } catch (e) {
  190. alert("dieskid");
  191. return b;
  192. }
  193. };
  194.  
  195. function setCommands() {
  196. return {
  197. "help": {
  198. desc: "Show Commands",
  199. action: function(message) {
  200. for (let cmds in commands) {
  201. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  202. }
  203. }
  204. },
  205. "clear": {
  206. desc: "Clear Chats",
  207. action: function(message) {
  208. resetMenuChText();
  209. }
  210. },
  211. "debug": {
  212. desc: "Debug Mod For Development",
  213. action: function(message) {
  214. addDeadPlayer(player);
  215. addMenuChText("Debug", "Done", "#99ee99", 1);
  216. }
  217. },
  218. "play": {
  219. desc: "Play Music ( /play [link] )",
  220. action: function(message) {
  221. let link = message.split(" ");
  222. if (link[1]) {
  223. let audio = new Audio(link[1]);
  224. audio.play();
  225. } else {
  226. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  227. }
  228. }
  229. },
  230. "bye": {
  231. desc: "Leave Game",
  232. action: function(message) {
  233. window.leave();
  234. }
  235. },
  236. };
  237. }
  238.  
  239. function setConfigs() {
  240. return {
  241. killChat: true,
  242. alwaysRev: true,
  243. autoBuy: true,
  244. autoBuyEquip: true,
  245. autoPush: true,
  246. revTick: true,
  247. spikeTick: true,
  248. predictTick: true,
  249. autoPlace: true,
  250. autoReplace: true,
  251. antiTrap: true,
  252. slowOT: false,
  253. attackDir: false,
  254. showDir: false,
  255. noDir: false,
  256. autoRespawn: false
  257. };
  258. };
  259. let commands = setCommands();
  260. let configs = setConfigs();
  261. window.removeConfigs = function() {
  262. for (let cF in configs) {
  263. deleteVal(cF, configs[cF]);
  264. }
  265. };
  266.  
  267. for (let cF in configs) {
  268. configs[cF] = gC(cF, configs[cF]);
  269. }
  270.  
  271. // MENU FUNCTIONS:
  272. window.changeMenu = function() {};
  273. window.debug = function() {};
  274. window.wasdMode = function() {};
  275.  
  276. // PAGE 1:
  277. window.startGrind = function() {};
  278.  
  279. // PAGE 3:
  280. window.connectFillBots = function() {};
  281. window.destroyFillBots = function() {};
  282. window.tryConnectBots = function() {};
  283. window.destroyBots = function() {};
  284. window.resBuild = function() {};
  285. window.toggleBotsCircle = function() {};
  286. window.toggleVisual = function() {};
  287.  
  288. // SOME FUNCTIONS:
  289. window.prepareUI = function() {};
  290. window.leave = function() {};
  291.  
  292. // nah hahahahahhh why good ping
  293. window.ping = 0;
  294.  
  295. class deadfuturechickenmodrevival {
  296. constructor(flarez, lore) {
  297. this.inGame = false;
  298. this.lover = flarez + lore;
  299. this.baby = "ae86";
  300. this.isBlack = 0;
  301. this.webSocket = undefined;
  302. this.checkBaby = function() {
  303. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  304. if (this.isBlack >= 1) return "bl4cky";
  305. return "noting for you";
  306. };
  307. this.x2 = 0;
  308. this.y2 = 0;
  309. this.chat = "Imagine playing this badass game XDDDDD";
  310. this.summon = function(tmpObj) {
  311. this.x2 = tmpObj.x;
  312. this.y2 = tmpObj.y;
  313. this.chat = tmpObj.name + " ur so bad XDDDD";
  314. };
  315. this.commands = function(cmd) {
  316. cmd == "rv3link" && window.open("https://florr.io/");
  317. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  318. return cmd;
  319. };
  320. this.dayte = "11yearold";
  321. this.memeganoob = "69yearold";
  322. this.startDayteSpawn = function(tmpObj) {
  323. let ratio = setInterval(() => {
  324. this.x2 = tmpObj.x + 20;
  325. this.y2 = tmpObj.y - 20;
  326. this.chat = "UR SO BAD LOL";
  327. if (tmpObj.name == "ae86") {
  328. this.chat = "omg ae86 go run";
  329. setTimeout(() => {
  330. this.inGame = false;
  331. clearInterval(ratio);
  332. }, 1000);
  333. }
  334. }, 1234);
  335. };
  336. this.AntiChickenModV69420 = function(tmpObj) {
  337. return "!c!dc user " + tmpObj.name;
  338. };
  339. }
  340. };
  341. class HtmlAction {
  342. constructor(element) {
  343. this.element = element;
  344. };
  345. add(code) {
  346. if (!this.element) return undefined;
  347. this.element.innerHTML += code;
  348. };
  349. newLine(amount) {
  350. let result = `<br>`;
  351. if (amount > 0) {
  352. result = ``;
  353. for (let i = 0; i < amount; i++) {
  354. result += `<br>`;
  355. }
  356. }
  357. this.add(result);
  358. };
  359. checkBox(setting) {
  360. let newCheck = `<input type = "checkbox"`;
  361. setting.id && (newCheck += ` id = ${setting.id}`);
  362. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  363. setting.class && (newCheck += ` class = ${setting.class}`);
  364. setting.checked && (newCheck += ` checked`);
  365. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  366. newCheck += `>`;
  367. this.add(newCheck);
  368. };
  369. text(setting) {
  370. let newText = `<input type = "text"`;
  371. setting.id && (newText += ` id = ${setting.id}`);
  372. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  373. setting.class && (newText += ` class = ${setting.class}`);
  374. setting.size && (newText += ` size = ${setting.size}`);
  375. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  376. setting.value && (newText += ` value = ${setting.value}`);
  377. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  378. newText += `>`;
  379. this.add(newText);
  380. };
  381. select(setting) {
  382. let newSelect = `<select`;
  383. setting.id && (newSelect += ` id = ${setting.id}`);
  384. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  385. setting.class && (newSelect += ` class = ${setting.class}`);
  386. newSelect += `>`;
  387. for (let options in setting.option) {
  388. newSelect += `<option value = ${setting.option[options].id}`
  389. setting.option[options].selected && (newSelect += ` selected`);
  390. newSelect += `>${options}</option>`;
  391. }
  392. newSelect += `</select>`;
  393. this.add(newSelect);
  394. };
  395. button(setting) {
  396. let newButton = `<button`;
  397. setting.id && (newButton += ` id = ${setting.id}`);
  398. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  399. setting.class && (newButton += ` class = ${setting.class}`);
  400. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  401. newButton += `>`;
  402. setting.innerHTML && (newButton += setting.innerHTML);
  403. newButton += `</button>`;
  404. this.add(newButton);
  405. };
  406. selectMenu(setting) {
  407. let newSelect = `<select`;
  408. if (!setting.id) {
  409. alert("please put id skid");
  410. return;
  411. }
  412. window[setting.id + "Func"] = function() {};
  413. setting.id && (newSelect += ` id = ${setting.id}`);
  414. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  415. setting.class && (newSelect += ` class = ${setting.class}`);
  416. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  417. newSelect += `>`;
  418. let last;
  419. let i = 0;
  420. for (let options in setting.menu) {
  421. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  422. setting.menu[options] && (newSelect += ` checked`);
  423. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  424. i++;
  425. }
  426. newSelect += `</select>`;
  427.  
  428. this.add(newSelect);
  429.  
  430. i = 0;
  431. for (let options in setting.menu) {
  432. window[options + "Func"] = function() {
  433. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  434. saveVal(options, setting.menu[options]);
  435.  
  436. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  437. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  438.  
  439. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  440.  
  441. };
  442. this.checkBox({
  443. id: "check_" + options,
  444. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  445. class: "checkB",
  446. onclick: `window.${options + "Func"}()`,
  447. checked: setting.menu[options]
  448. });
  449. i++;
  450. }
  451.  
  452. last = "check_" + getEl(setting.id).value.split("_")[1];
  453. window[setting.id + "Func"] = function() {
  454. getEl(last).style.display = "none";
  455. last = "check_" + getEl(setting.id).value.split("_")[1];
  456. getEl(last).style.display = "inline-block";
  457.  
  458. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  459.  
  460. };
  461. };
  462. };
  463. class Html {
  464. constructor() {
  465. this.element = null;
  466. this.action = null;
  467. this.divElement = null;
  468. this.startDiv = function(setting, func) {
  469.  
  470. let newDiv = document.createElement("div");
  471. setting.id && (newDiv.id = setting.id);
  472. setting.style && (newDiv.style = setting.style);
  473. setting.class && (newDiv.className = setting.class);
  474. this.element.appendChild(newDiv);
  475. this.divElement = newDiv;
  476.  
  477. let addRes = new HtmlAction(newDiv);
  478. typeof func == "function" && func(addRes);
  479.  
  480. };
  481. this.addDiv = function(setting, func) {
  482.  
  483. let newDiv = document.createElement("div");
  484. setting.id && (newDiv.id = setting.id);
  485. setting.style && (newDiv.style = setting.style);
  486. setting.class && (newDiv.className = setting.class);
  487. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  488. this.divElement = newDiv;
  489.  
  490. let addRes = new HtmlAction(newDiv);
  491. typeof func == "function" && func(addRes);
  492.  
  493. };
  494. };
  495. set(id) {
  496. this.element = getEl(id);
  497. this.action = new HtmlAction(this.element);
  498. };
  499. resetHTML(text) {
  500. if (text) {
  501. this.element.innerHTML = ``;
  502. } else {
  503. this.element.innerHTML = ``;
  504. }
  505. };
  506. setStyle(style) {
  507. this.element.style = style;
  508. };
  509. setCSS(style) {
  510. this.action.add(`<style>` + style + `</style>`);
  511. };
  512. };
  513.  
  514. let HTML = new Html();
  515.  
  516. let menuDiv = document.createElement("div");
  517. menuDiv.id = "menuDiv";
  518. document.body.appendChild(menuDiv);
  519. HTML.set("menuDiv");
  520. HTML.setStyle(`
  521. position: absolute;
  522. left: 20px;
  523. top: 20px;
  524. `);
  525. HTML.resetHTML();
  526. HTML.setCSS(`
  527. .menuClass {
  528. color: #fff;
  529. font-size: 22px;
  530. text-align: left;
  531. padding: 20px;
  532. width: 300px;
  533. background-color: rgba(0, 0, 0, 0.25);
  534. border-radius: 4px;
  535. border: 3px solid white;
  536. position: fixed;
  537. }
  538. .menuClass:hover {
  539. border-color: rgb(255,255,255); /* Change border color on hover to RGB red */
  540. }
  541. .menuClass:hover .menuContent {
  542. background-color: #000; /* Change background color of menu content to darker black on hover */
  543. }
  544. .menuContent {
  545. color: #fff;
  546. }
  547. .menuC {
  548. display: none;
  549. font-family: "Hammersmith One";
  550. font-size: 12px;
  551. max-height: 180px;
  552. overflow-y: scroll;
  553. -webkit-touch-callout: none;
  554. -webkit-user-select: none;
  555. -khtml-user-select: none;
  556. -moz-user-select: none;
  557. -ms-user-select: none;
  558. user-select: none;
  559. }
  560. .menuB {
  561. text-align: center;
  562. background-color: rgb(25, 25, 25);
  563. color: #fff;
  564. -webkit-border-radius: 4px;
  565. -moz-border-radius: 4px;
  566. border-radius: 4px;
  567. border: 2px solid #000;
  568. cursor: pointer;
  569. }
  570. .menuB:hover {
  571. border-color: #fff;
  572. }
  573. .menuB:active {
  574. color: #fff;
  575. background-color: #1f1f1f;
  576. }
  577. .customText {
  578. color: #000;
  579. border-radius: 25px;
  580. border: 2px solid #000;
  581. padding: 12px;
  582. transition: background-color 0.3s ease-in-out;
  583. }
  584. .customText:focus {
  585. background-color: rgba(30, 130, 76, 0.3);
  586. }
  587. .checkB {
  588. position: relative;
  589. top: 2px;
  590. accent-color: #888;
  591. cursor: pointer;
  592. }
  593. .Cselect {
  594. border-radius: 25px;
  595. background-color: #1f1f1f;
  596. color: #fff;
  597. border: 1px solid #000;
  598. }
  599. #menuChanger {
  600. position: absolute;
  601. right: 20px;
  602. top: 20px;
  603. background-color: rgba(0, 0, 0, 0);
  604. color: #fff;
  605. border: none;
  606. cursor: pointer;
  607. transition: color 0.3s ease-in-out;
  608. }
  609. #menuChanger:hover {
  610. color: #000;
  611. }
  612.  
  613. ::-webkit-scrollbar {
  614. width: 0; /* Skryje vertikální scrollbar na WebKit prohlížečích */
  615. }
  616. `);
  617.  
  618. HTML.startDiv({
  619. id: "menuHeadLine",
  620. class: "menuClass"
  621. }, (html) => {
  622. html.add(`Saviour`);
  623. html.button({
  624. id: "menuChanger",
  625. class: "material-icons",
  626. innerHTML: `sync`,
  627. onclick: "window.changeMenu()"
  628. });
  629. HTML.addDiv({
  630. id: "menuButtons",
  631. style: "display: block; overflow-y: visible;",
  632. class: "menuC",
  633. appendID: "menuHeadLine"
  634. }, (html) => {
  635. html.button({
  636. class: "menuB",
  637. innerHTML: "Debug",
  638. onclick: "window.debug()"
  639. });
  640. });
  641. HTML.addDiv({
  642. id: "menuMain",
  643. style: "display: block",
  644. class: "menuC",
  645. appendID: "menuHeadLine"
  646. }, (html) => {
  647. html.button({
  648. class: "menuB",
  649. innerHTML: "Toggle Wasd Mode",
  650. onclick: "window.wasdMode()"
  651. });
  652. html.newLine();
  653. html.add(`Ruby Farm:`);
  654. html.checkBox({
  655. id: "weaponGrind",
  656. class: "checkB",
  657. onclick: "window.startGrind()"
  658. });
  659. html.newLine(2);
  660. HTML.addDiv({
  661. style: "font-size: 20px; color: #99ee99;",
  662. appendID: "menuMain"
  663. }, (html) => {
  664. html.add(`Settings:`);
  665. });
  666. html.add(`Push v4:`);
  667. html.checkBox({
  668. id: "antipush",
  669. class: "checkB",
  670. checked: true
  671. });
  672. html.newLine();
  673. html.add(`Anti heal:`);
  674. html.checkBox({
  675. id: "healingBeta",
  676. class: "checkB",
  677. checked: true
  678. });
  679. html.newLine();
  680. });
  681. HTML.addDiv({
  682. id: "menuConfig",
  683. class: "menuC",
  684. appendID: "menuHeadLine"
  685. }, (html) => {
  686. html.add(`Placement Tick: `);
  687. html.text({
  688. id: "autoPlaceTick",
  689. class: "customText",
  690. value: "2",
  691. size: "2em",
  692. maxLength: "1"
  693. });
  694. html.newLine();
  695. html.add(`Options: `);
  696. html.selectMenu({
  697. id: "configsChanger",
  698. class: "Cselect",
  699. menu: configs
  700. });
  701. html.newLine();
  702. html.add(`AntiBull: `);
  703. html.select({
  704. id: "antiBullType",
  705. class: "Cselect",
  706. option: {
  707. "Disable": {
  708. id: "noab",
  709. selected: true,
  710. },
  711. "When Reloaded": {
  712. id: "abreload",
  713. },
  714. "Always": {
  715. id: "abalway",
  716. }
  717. }
  718. });
  719. });
  720. HTML.addDiv({
  721. id: "menuOther",
  722. class: "menuC",
  723. appendID: "menuHeadLine"
  724. }, (html) => {
  725. html.button({
  726. class: "menuB",
  727. innerHTML: "Connect Bots",
  728. onclick: "window.tryConnectBots()"
  729. });
  730. html.button({
  731. class: "menuB",
  732. innerHTML: "Disconnect Bots",
  733. onclick: "window.destroyBots()"
  734. });
  735. html.newLine();
  736. html.add(`Break Objects Range: `);
  737. html.text({
  738. id: "breakRange",
  739. class: "customText",
  740. value: "700",
  741. size: "3em",
  742. maxLength: "4"
  743. });
  744. html.newLine();
  745. html.add(`Render Movement: `);
  746. html.select({
  747. id: "predictType",
  748. class: "Cselect",
  749. option: {
  750. "Disable Render": {
  751. id: "disableRender",
  752. selected: true
  753. },
  754. "X/Y and 2": {
  755. id: "pre2",
  756. },
  757. "X/Y and 3": {
  758. id: "pre3"
  759. }
  760. }
  761. });
  762. html.newLine();
  763. html.add(`Render Placers: `);
  764. html.checkBox({
  765. id: "placeVis",
  766. class: "checkB",
  767. });
  768. html.newLine();
  769. html.add(`Bot Mode: `);
  770. html.select({
  771. id: "mode",
  772. class: "Cselect",
  773. option: {
  774. "Clear Building": {
  775. id: "clear",
  776. selected: true
  777. },
  778. "Sync": {
  779. id: "zync",
  780. },
  781. "Search": {
  782. id: "zearch"
  783. },
  784. "Clear Everything": {
  785. id: "fuckemup"
  786. },
  787. "Flex": {
  788. id: "flex"
  789. }
  790. }
  791. });
  792. html.newLine();
  793. html.add(`Bot Setup: `);
  794. html.select({
  795. id: "setup",
  796. class: "Cselect",
  797. option: {
  798. "Dagger Musket": {
  799. id: "dm",
  800. selected: true
  801. },
  802. "Katana Hammer": {
  803. id: "kh",
  804. },
  805. "Dagger Repeater-Crossbow": {
  806. id: "dr"
  807. },
  808. "Sword Muzket": {
  809. id: "zd"
  810. }
  811. }
  812. });
  813. html.newLine();
  814. html.button({
  815. class: "menuB",
  816. innerHTML: "Toggle Another Visual",
  817. onclick: "window.toggleVisual()"
  818. });
  819. html.newLine();
  820. });
  821. });
  822. function toFancyTimeFormat(time) {
  823. let minutes = ~~((time % 3600) / 60);
  824. let seconds = ~~time % 60;
  825. if (seconds <= 9) seconds = `0${seconds}`;
  826. return `${minutes}:${seconds}`;
  827. }
  828. 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&");
  829. let isPlaying = false;
  830. let currentPart = '';
  831. function toggleSong() {
  832. if (!isPlaying) {
  833. songchat1.play();
  834. songchat1.ontimeupdate = function(time) {
  835. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  836. if (part && part !== currentPart) {
  837. currentPart = part;
  838. io.send("6", part);
  839. }
  840. };
  841. songchat1.onended = function() {
  842. if (isPlaying) {
  843. songchat1.play();
  844. }
  845. };
  846. isPlaying = true;
  847. } else {
  848. songchat1.pause();
  849. isPlaying = false;
  850. }
  851. }
  852. document.addEventListener("keypress", function(e) {
  853. if (e.key === "C") {
  854. toggleSong();
  855. }
  856. });
  857. let menuChatDiv = document.createElement("div");
  858. menuChatDiv.id = "menuChatDiv";
  859. document.body.appendChild(menuChatDiv);
  860. HTML.set("menuChatDiv");
  861. HTML.setStyle(`
  862. position: absolute;
  863. display: none;
  864. left: 0px;
  865. top: 25px;
  866. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  867. `);
  868. HTML.resetHTML();
  869. HTML.setCSS(`
  870. .chDiv {
  871. color: #fff;
  872. padding: 10px;
  873. width: 357px;
  874. height: 217px;
  875. background-color: rgba(0, 0, 0, 0.2);
  876. font-family: "HammerSmith One", monospace;
  877. // border-radius: 15px;
  878. // box-shadow: black 1px 2px 19px;
  879. //backdrop-filter: blur(3px);
  880.  
  881. }
  882. .chMainDiv {
  883. font-family: "Ubuntu";
  884. font-size: 16px;
  885. max-height: 215px;
  886. overflow-y: scroll;
  887. scrollbar-width: thin;
  888. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  889. -webkit-touch-callout: none;
  890. -webkit-user-select: none;
  891. -khtml-user-select: none;
  892. -moz-user-select: none;
  893. -ms-user-select: none;
  894. user-select: none;
  895. overflow-x: hidden;
  896. }
  897. .chMainDiv::-webkit-scrollbar {
  898. width: 8px;
  899. }
  900. .chMainDiv::-webkit-scrollbar-thumb {
  901. background-color: rgba(0, 0, 0, 0.5);
  902. }
  903. .chMainDiv::-webkit-scrollbar-thumb:hover {
  904. background-color: rgba(0, 0, 0, 0.7);
  905. }
  906. .chMainBox {
  907. display:none;
  908. position: absolute;
  909. left: 10px;
  910. bottom: 10px;
  911. width: 380px;
  912. height: 25px;
  913. background-color: rgba(255, 255, 255, 0.1);
  914. border-radius: 5px;
  915. color: rgba(255, 255, 255, 0.75);
  916. font-family: "HammerSmith One";
  917. font-size: 12px;
  918. }
  919. `);
  920. HTML.startDiv({
  921. id: "mChDiv",
  922. class: "chDiv"
  923. }, (html) => {
  924. HTML.addDiv({
  925. id: "mChMain",
  926. class: "chMainDiv",
  927. appendID: "mChDiv"
  928. }, (html) => {});
  929. html.text({
  930. id: "mChBox",
  931. class: "chMainBox",
  932. // placeHolder: `To chat click here or press "Enter" key`
  933. });
  934. });
  935.  
  936. let menuChats = getEl("mChMain");
  937. let menuChatBox = getEl("mChBox");
  938. let menuCBFocus = false;
  939. let menuChCounts = 0;
  940.  
  941. menuChatBox.value = "";
  942. menuChatBox.addEventListener("focus", () => {
  943. menuCBFocus = true;
  944. });
  945. menuChatBox.addEventListener("blur", () => {
  946. menuCBFocus = false;
  947. });
  948.  
  949. function addMenuChText(name, message, color, noTimer) {
  950. HTML.set("menuChatDiv");
  951. color = color || "white";
  952. let time = new Date();
  953. let min = time.getMinutes();
  954. let hour = time.getHours();
  955. let text = ``;
  956. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  957. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  958. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  959. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  960. html.add(text);
  961. });
  962. menuChats.scrollTop = menuChats.scrollHeight;
  963. menuChCounts++;
  964. }
  965. function chch(name, message, color, noTimer) {
  966. HTML.set("menuChatDiv");
  967. color = color || "white";
  968. let time = new Date();
  969. let text = ``;
  970. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  971. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  972. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  973. html.add(text);
  974. });
  975. menuChats.scrollTop = menuChats.scrollHeight;
  976. menuChCounts++;
  977. }
  978.  
  979. function resetMenuChText() {
  980. menuChats.innerHTML = ``;
  981. menuChCounts = 0;
  982. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  983. }
  984. resetMenuChText();
  985.  
  986. let menuIndex = 0;
  987. let menus = ["menuMain", "menuConfig", "menuOther"];
  988. window.changeMenu = function() {
  989. getEl(menus[menuIndex % menus.length]).style.display = "none";
  990. menuIndex++;
  991. getEl(menus[menuIndex % menus.length]).style.display = "block";
  992. };
  993.  
  994. let mStatus = document.createElement("div");
  995. mStatus.id = "status";
  996. getEl("gameUI").appendChild(mStatus);
  997. HTML.set("status");
  998. HTML.setStyle(`
  999. display: block;
  1000. position: absolute;
  1001. color: #ddd;
  1002. font: 15px HammerSmith One;
  1003. bottom: 215px;
  1004. left: 20px;
  1005. `);
  1006. HTML.resetHTML();
  1007. HTML.setCSS(`
  1008. .sizing {
  1009. font-size: 15px;
  1010. }
  1011. .mod {
  1012. font-size: 15px;
  1013. display: inline-block;
  1014. }
  1015. `);
  1016. HTML.startDiv({
  1017. id: "uehmod",
  1018. class: "sizing"
  1019. }, (html) => {
  1020. html.add(`Ping: `);
  1021. HTML.addDiv({
  1022. id: "pingFps",
  1023. class: "mod",
  1024. appendID: "uehmod"
  1025. }, (html) => {
  1026. html.add("None");
  1027. });
  1028. html.newLine();
  1029. html.add(`Packet: `);
  1030. HTML.addDiv({
  1031. id: "packetStatus",
  1032. class: "mod",
  1033. appendID: "uehmod"
  1034. }, (html) => {
  1035. html.add("None");
  1036. });
  1037. });
  1038.  
  1039. /*function modLog() {
  1040. let logs = [];
  1041. for (let i = 0; i < arguments.length; i++) {
  1042. logs.push(arguments[i]);
  1043. }
  1044. getEl("modLog").innerHTML = logs;
  1045. }*/
  1046.  
  1047. let openMenu = false;
  1048.  
  1049. let WS = undefined;
  1050. let socketID = undefined;
  1051.  
  1052. let useWasd = false;
  1053. let secPacket = 0;
  1054. let secMax = 120;
  1055. let secTime = 1000;
  1056. let firstSend = {
  1057. sec: false
  1058. };
  1059. let game = {
  1060. tick: 0,
  1061. tickQueue: [],
  1062. tickBase: function(set, tick) {
  1063. if (this.tickQueue[this.tick + tick]) {
  1064. this.tickQueue[this.tick + tick].push(set);
  1065. } else {
  1066. this.tickQueue[this.tick + tick] = [set];
  1067. }
  1068. },
  1069. tickRate: (1000 / config.serverUpdateRate),
  1070. tickSpeed: 0,
  1071. lastTick: performance.now()
  1072. };
  1073. let modConsole = [];
  1074.  
  1075. let dontSend = false;
  1076. let fpsTimer = {
  1077. last: 0,
  1078. time: 0,
  1079. ltime: 0
  1080. }
  1081. let lastMoveDir = undefined;
  1082. let lastsp = ["cc", 1, "__proto__"];
  1083.  
  1084. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1085. WebSocket.prototype.send = function(message) {
  1086. if (!WS) {
  1087. WS = this;
  1088. WS.addEventListener("message", function(msg) {
  1089. getMessage(msg);
  1090. });
  1091. WS.addEventListener("close", (event) => {
  1092. if (event.code == 4001) {
  1093. window.location.reload();
  1094. }
  1095. });
  1096. }
  1097. if (WS == this) {
  1098. dontSend = false;
  1099.  
  1100. // EXTRACT DATA ARRAY:
  1101. let data = new Uint8Array(message);
  1102. let parsed = window.msgpack.decode(data);
  1103. let type = parsed[0];
  1104. data = parsed[1];
  1105.  
  1106. // SEND MESSAGE:
  1107. if (type == "6") {
  1108.  
  1109. if (data[0]) {
  1110. // ANTI PROFANITY:
  1111. 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", ];
  1112. let tmpString;
  1113. profanity.forEach((profany) => {
  1114. if (data[0].indexOf(profany) > -1) {
  1115. tmpString = "";
  1116. for (let i = 0; i < profany.length; ++i) {
  1117. if (i == 1) {
  1118. tmpString += String.fromCharCode(0);
  1119. }
  1120. tmpString += profany[i];
  1121. }
  1122. let re = new RegExp(profany, "g");
  1123. data[0] = data[0].replace(re, tmpString);
  1124. }
  1125. });
  1126.  
  1127. // FIX CHAT:
  1128. data[0] = data[0].slice(0, 30);
  1129. }
  1130.  
  1131. } else if (type == "L") {
  1132. // MAKE SAME CLAN:
  1133. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1134. data[0] = data[0].slice(0, 7);
  1135. } else if (type == "M") {
  1136. // APPLY CYAN COLOR:
  1137. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1138. data[0].moofoll = true;
  1139. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1140. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1141. } else if (type == "D") {
  1142. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1143. dontSend = true;
  1144. } else {
  1145. my.lastDir = data[0];
  1146. }
  1147. } else if (type == "d") {
  1148. if (!data[2]) {
  1149. dontSend = true;
  1150. } else {
  1151. if (![null, undefined].includes(data[1])) {
  1152. my.lastDir = data[1];
  1153. }
  1154. }
  1155. } else if (type == "K") {
  1156. if (!data[1]) {
  1157. dontSend = true;
  1158. }
  1159. } else if (type == "S") {
  1160. instaC.wait = !instaC.wait;
  1161. dontSend = true;
  1162. } else if (type == "a") {
  1163. if (data[1]) {
  1164. if (player.moveDir == data[0]) {
  1165. dontSend = true;
  1166. }
  1167. player.moveDir = data[0];
  1168. } else {
  1169. dontSend = true;
  1170. }
  1171. }
  1172. if (!dontSend) {
  1173. let binary = window.msgpack.encode([type, data]);
  1174. this.nsend(binary);
  1175.  
  1176. // START COUNT:
  1177. if (!firstSend.sec) {
  1178. firstSend.sec = true;
  1179. setTimeout(() => {
  1180. firstSend.sec = false;
  1181. secPacket = 0;
  1182. }, secTime);
  1183. }
  1184.  
  1185. secPacket++;
  1186. }
  1187. } else {
  1188. this.nsend(message);
  1189. }
  1190. }
  1191.  
  1192. function packet(type) {
  1193. // EXTRACT DATA ARRAY:
  1194. let data = Array.prototype.slice.call(arguments, 1);
  1195.  
  1196. // SEND MESSAGE:
  1197. let binary = window.msgpack.encode([type, data]);
  1198. WS.send(binary);
  1199. }
  1200.  
  1201. function origPacket(type) {
  1202. // EXTRACT DATA ARRAY:
  1203. let data = Array.prototype.slice.call(arguments, 1);
  1204.  
  1205. // SEND MESSAGE:
  1206. let binary = window.msgpack.encode([type, data]);
  1207. WS.nsend(binary);
  1208. }
  1209.  
  1210. window.leave = function() {
  1211. origPacket("kys", {
  1212. "frvr is so bad": true,
  1213. "sidney is too good": true,
  1214. "dev are too weak": true,
  1215. });
  1216. };
  1217.  
  1218. //...lol
  1219. let io = {
  1220. send: packet
  1221. };
  1222.  
  1223. function getMessage(message) {
  1224. let data = new Uint8Array(message.data);
  1225. let parsed = window.msgpack.decode(data);
  1226. let type = parsed[0];
  1227. data = parsed[1];
  1228. let events = {
  1229. A: setInitData, // id: setInitData,
  1230. //B: disconnect,
  1231. C: setupGame, // 1: setupGame,
  1232. D: addPlayer, // 2: addPlayer,
  1233. E: removePlayer, // 4: removePlayer,
  1234. a: updatePlayers, // 33: updatePlayers,
  1235. G: updateLeaderboard, // 5: updateLeaderboard,here
  1236. H: loadGameObject, // 6: loadGameObject,
  1237. I: loadAI, // a: loadAI,
  1238. J: animateAI, // aa: animateAI,
  1239. K: gatherAnimation, // 7: gatherAnimation,
  1240. L: wiggleGameObject, // 8: wiggleGameObject,
  1241. M: shootTurret, // sp: shootTurret,
  1242. N: updatePlayerValue, // 9: updatePlayerValue,
  1243. O: updateHealth, // h: updateHealth,//here
  1244. P: killPlayer, // 11: killPlayer,
  1245. Q: killObject, // 12: killObject,
  1246. R: killObjects, // 13: killObjects,
  1247. S: updateItemCounts, // 14: updateItemCounts,
  1248. T: updateAge, // 15: updateAge,
  1249. U: updateUpgrades, // 16: updateUpgrades,
  1250. V: updateItems, // 17: updateItems,
  1251. X: addProjectile, // 18: addProjectile,
  1252. Y: remProjectile, // 19: remProjectile,
  1253. //Z: serverShutdownNotice,
  1254. //0: addAlliance,
  1255. //1: deleteAlliance,
  1256. 2: allianceNotification, // an: allianceNotification,
  1257. 3: setPlayerTeam, // st: setPlayerTeam,
  1258. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1259. 5: updateStoreItems, // us: updateStoreItems,
  1260. 6: receiveChat, // ch: receiveChat,
  1261. 7: updateMinimap, // mm: updateMinimap,
  1262. 8: showText, // t: showText,
  1263. 9: pingMap, // p: pingMap,
  1264. 0: pingSocketResponse,
  1265. };
  1266. if (type == "io-init") {
  1267. socketID = data[0];
  1268. } else {
  1269. if (events[type]) {
  1270. events[type].apply(undefined, data);
  1271. }
  1272. }
  1273. }
  1274.  
  1275. // MATHS:
  1276. Math.lerpAngle = function(value1, value2, amount) {
  1277. let difference = Math.abs(value2 - value1);
  1278. if (difference > Math.PI) {
  1279. if (value1 > value2) {
  1280. value2 += Math.PI * 2;
  1281. } else {
  1282. value1 += Math.PI * 2;
  1283. }
  1284. }
  1285. let value = value2 + ((value1 - value2) * amount);
  1286. if (value >= 0 && value <= Math.PI * 2) return value;
  1287. return value % (Math.PI * 2);
  1288. };
  1289.  
  1290. // REOUNDED RECTANGLE:
  1291. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1292. if (w < 2 * r) r = w / 2;
  1293. if (h < 2 * r) r = h / 2;
  1294. if (r < 0)
  1295. r = 0;
  1296. this.beginPath();
  1297. this.moveTo(x + r, y);
  1298. this.arcTo(x + w, y, x + w, y + h, r);
  1299. this.arcTo(x + w, y + h, x, y + h, r);
  1300. this.arcTo(x, y + h, x, y, r);
  1301. this.arcTo(x, y, x + w, y, r);
  1302. this.closePath();
  1303. return this;
  1304. };
  1305.  
  1306. // GLOBAL VALUES:
  1307. function resetMoveDir() {
  1308. keys = {};
  1309. io.send("e");
  1310. }
  1311.  
  1312. let allChats = [];
  1313. let ticks = {
  1314. tick: 0,
  1315. delay: 0,
  1316. time: [],
  1317. manage: [],
  1318. };
  1319. let ais = [];
  1320. let players = [];
  1321. let alliances = [];
  1322. let alliancePlayers = [];
  1323. let allianceNotifications = [];
  1324. let gameObjects = [];
  1325. let liztobj = [];
  1326. let projectiles = [];
  1327. let deadPlayers = [];
  1328.  
  1329. let breakObjects = [];
  1330.  
  1331. let player;
  1332. let playerSID;
  1333. let tmpObj;
  1334.  
  1335. let enemy = [];
  1336. let nears = [];
  1337. let near = [];
  1338.  
  1339. let my = {
  1340. reloaded: false,
  1341. waitHit: 0,
  1342. autoAim: false,
  1343. revAim: false,
  1344. ageInsta: true,
  1345. reSync: false,
  1346. bullTick: 0,
  1347. anti0Tick: 0,
  1348. antiSync: false,
  1349. safePrimary: function(tmpObj) {
  1350. return [0, 8].includes(tmpObj.primaryIndex);
  1351. },
  1352. safeSecondary: function(tmpObj) {
  1353. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1354. },
  1355. lastDir: 0,
  1356. autoPush: false,
  1357. pushData: {}
  1358. }
  1359.  
  1360. // FIND OBJECTS BY ID/SID:
  1361. function findID(tmpObj, tmp) {
  1362. return tmpObj.find((THIS) => THIS.id == tmp);
  1363. }
  1364.  
  1365. function findSID(tmpObj, tmp) {
  1366. return tmpObj.find((THIS) => THIS.sid == tmp);
  1367. }
  1368.  
  1369. function findPlayerByID(id) {
  1370. return findID(players, id);
  1371. }
  1372.  
  1373. function findPlayerBySID(sid) {
  1374. return findSID(players, sid);
  1375. }
  1376.  
  1377. function findAIBySID(sid) {
  1378. return findSID(ais, sid);
  1379. }
  1380.  
  1381. function findObjectBySid(sid) {
  1382. return findSID(gameObjects, sid);
  1383. }
  1384.  
  1385. function findProjectileBySid(sid) {
  1386. return findSID(gameObjects, sid);
  1387. }
  1388.  
  1389. let gameName = getEl("gameName");
  1390. gameName.innerText = "SaviourISgod";
  1391. let adCard = getEl("adCard");
  1392. adCard.remove();
  1393. let promoImageHolder = getEl("promoImgHolder");
  1394. promoImageHolder.remove();
  1395.  
  1396. let chatButton = getEl("chatButton");
  1397. chatButton.remove();
  1398. let gameCanvas = getEl("gameCanvas");
  1399. let mainContext = gameCanvas.getContext("2d");
  1400. let mapDisplay = getEl("mapDisplay");
  1401. let mapContext = mapDisplay.getContext("2d");
  1402. mapDisplay.width = 300;
  1403. mapDisplay.height = 300;
  1404. let storeMenu = getEl("storeMenu");
  1405. let storeHolder = getEl("storeHolder");
  1406. let upgradeHolder = getEl("upgradeHolder");
  1407. let upgradeCounter = getEl("upgradeCounter");
  1408. let chatBox = getEl("chatBox");
  1409. chatBox.autocomplete = "off";
  1410. chatBox.style.textAlign = "center";
  1411. chatBox.style.width = "18em";
  1412. let chatHolder = getEl("chatHolder");
  1413. let actionBar = getEl("actionBar");
  1414. let leaderboardData = getEl("leaderboardData");
  1415. let itemInfoHolder = getEl("itemInfoHolder");
  1416. let menuCardHolder = getEl("menuCardHolder");
  1417. let mainMenu = getEl("mainMenu");
  1418. getEl("mainMenu").style.backgroundImage = "";
  1419. let diedText = getEl("diedText");
  1420. let screenWidth;
  1421. let screenHeight;
  1422. let maxScreenWidth = config.maxScreenWidth;
  1423. let maxScreenHeight = config.maxScreenHeight;
  1424. let pixelDensity = 1;
  1425. let delta;
  1426. let now;
  1427. let lastUpdate = performance.now();
  1428. let camX;
  1429. let camY;
  1430. let tmpDir;
  1431. let mouseX = 0;
  1432. let mouseY = 0;
  1433. let allianceMenu = getEl("allianceMenu");
  1434. let waterMult = 1;
  1435. let waterPlus = 0;
  1436.  
  1437. let outlineColor = "#525252";
  1438. let darkOutlineColor = "#3d3f42";
  1439. let outlineWidth = 5.5;
  1440.  
  1441. let firstSetup = true;
  1442. let keys = {};
  1443. let moveKeys = {
  1444. 87: [0, -1],
  1445. 38: [0, -1],
  1446. 83: [0, 1],
  1447. 40: [0, 1],
  1448. 65: [-1, 0],
  1449. 37: [-1, 0],
  1450. 68: [1, 0],
  1451. 39: [1, 0],
  1452. };
  1453. let attackState = 0;
  1454. let inGame = false;
  1455.  
  1456. let macro = {};
  1457. let mills = {
  1458. place: 0,
  1459. placeSpawnPads: 0
  1460. };
  1461. let lastDir;
  1462.  
  1463. let lastLeaderboardData = [];
  1464.  
  1465. // ON LOAD:
  1466. let inWindow = true;
  1467. window.onblur = function() {
  1468. inWindow = false;
  1469. };
  1470. window.onfocus = function() {
  1471. inWindow = true;
  1472. if (player && player.alive) {
  1473. // resetMoveDir();
  1474. }
  1475. };
  1476. let ms = {
  1477. avg: 0,
  1478. max: 0,
  1479. min: 0,
  1480. delay: 0
  1481. }
  1482. function pingSocketResponse() {
  1483. let pingTime = window.pingTime;
  1484. const pingDisplay = document.getElementById("pingDisplay")
  1485. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1486. if (pingTime > ms.max || isNaN(ms.max)) {
  1487. ms.max = pingTime;
  1488. }
  1489. if (pingTime < ms.min || isNaN(ms.min)) {
  1490. ms.min = pingTime;
  1491. }
  1492.  
  1493. // if (pingTime >= 90) {
  1494. // doAutoQ = true;
  1495. // } else {
  1496. // doAutoQ = false;
  1497. // }
  1498. }
  1499.  
  1500. let placeVisible = [];
  1501.  
  1502. /** CLASS CODES */
  1503.  
  1504.  
  1505. class Utils {
  1506. constructor() {
  1507.  
  1508. // MATH UTILS:
  1509. let mathABS = Math.abs,
  1510. mathCOS = Math.cos,
  1511. mathSIN = Math.sin,
  1512. mathPOW = Math.pow,
  1513. mathSQRT = Math.sqrt,
  1514. mathATAN2 = Math.atan2,
  1515. mathPI = Math.PI;
  1516.  
  1517. let _this = this;
  1518.  
  1519. // GLOBAL UTILS:
  1520. this.round = function(n, v) {
  1521. return Math.round(n * v) / v;
  1522. };
  1523. this.toRad = function(angle) {
  1524. return angle * (mathPI / 180);
  1525. };
  1526. this.toAng = function(radian) {
  1527. return radian / (mathPI / 180);
  1528. };
  1529. this.randInt = function(min, max) {
  1530. return Math.floor(Math.random() * (max - min + 1)) + min;
  1531. };
  1532. this.randFloat = function(min, max) {
  1533. return Math.random() * (max - min + 1) + min;
  1534. };
  1535. this.lerp = function(value1, value2, amount) {
  1536. return value1 + (value2 - value1) * amount;
  1537. };
  1538. this.decel = function(val, cel) {
  1539. if (val > 0)
  1540. val = Math.max(0, val - cel);
  1541. else if (val < 0)
  1542. val = Math.min(0, val + cel);
  1543. return val;
  1544. };
  1545. this.getDistance = function(x1, y1, x2, y2) {
  1546. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1547. };
  1548. this.getDist = function(tmp1, tmp2, type1, type2) {
  1549. let tmpXY1 = {
  1550. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1551. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1552. };
  1553. let tmpXY2 = {
  1554. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1555. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1556. };
  1557. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1558. };
  1559. this.getDirection = function(x1, y1, x2, y2) {
  1560. return mathATAN2(y1 - y2, x1 - x2);
  1561. };
  1562. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1563. let tmpXY1 = {
  1564. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1565. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1566. };
  1567. let tmpXY2 = {
  1568. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1569. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1570. };
  1571. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1572. };
  1573. this.getAngleDist = function(a, b) {
  1574. let p = mathABS(b - a) % (mathPI * 2);
  1575. return (p > mathPI ? (mathPI * 2) - p : p);
  1576. };
  1577. this.isNumber = function(n) {
  1578. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1579. };
  1580. this.isString = function(s) {
  1581. return (s && typeof s == "string");
  1582. };
  1583. this.kFormat = function(num) {
  1584. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1585. };
  1586. this.sFormat = function(num) {
  1587. let fixs = [{
  1588. num: 1e3,
  1589. string: "k"
  1590. },
  1591. {
  1592. num: 1e6,
  1593. string: "m"
  1594. },
  1595. {
  1596. num: 1e9,
  1597. string: "b"
  1598. },
  1599. {
  1600. num: 1e12,
  1601. string: "q"
  1602. }
  1603. ].reverse();
  1604. let sp = fixs.find(v => num >= v.num);
  1605. if (!sp) return num;
  1606. return (num / sp.num).toFixed(1) + sp.string;
  1607. };
  1608. this.capitalizeFirst = function(string) {
  1609. return string.charAt(0).toUpperCase() + string.slice(1);
  1610. };
  1611. this.fixTo = function(n, v) {
  1612. return parseFloat(n.toFixed(v));
  1613. };
  1614. this.sortByPoints = function(a, b) {
  1615. return parseFloat(b.points) - parseFloat(a.points);
  1616. };
  1617. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1618. let minX = x1;
  1619. let maxX = x2;
  1620. if (x1 > x2) {
  1621. minX = x2;
  1622. maxX = x1;
  1623. }
  1624. if (maxX > recX2)
  1625. maxX = recX2;
  1626. if (minX < recX)
  1627. minX = recX;
  1628. if (minX > maxX)
  1629. return false;
  1630. let minY = y1;
  1631. let maxY = y2;
  1632. let dx = x2 - x1;
  1633. if (Math.abs(dx) > 0.0000001) {
  1634. let a = (y2 - y1) / dx;
  1635. let b = y1 - a * x1;
  1636. minY = a * minX + b;
  1637. maxY = a * maxX + b;
  1638. }
  1639. if (minY > maxY) {
  1640. let tmp = maxY;
  1641. maxY = minY;
  1642. minY = tmp;
  1643. }
  1644. if (maxY > recY2)
  1645. maxY = recY2;
  1646. if (minY < recY)
  1647. minY = recY;
  1648. if (minY > maxY)
  1649. return false;
  1650. return true;
  1651. };
  1652. this.containsPoint = function(element, x, y) {
  1653. let bounds = element.getBoundingClientRect();
  1654. let left = bounds.left + window.scrollX;
  1655. let top = bounds.top + window.scrollY;
  1656. let width = bounds.width;
  1657. let height = bounds.height;
  1658.  
  1659. let insideHorizontal = x > left && x < left + width;
  1660. let insideVertical = y > top && y < top + height;
  1661. return insideHorizontal && insideVertical;
  1662. };
  1663. this.mousifyTouchEvent = function(event) {
  1664. let touch = event.changedTouches[0];
  1665. event.screenX = touch.screenX;
  1666. event.screenY = touch.screenY;
  1667. event.clientX = touch.clientX;
  1668. event.clientY = touch.clientY;
  1669. event.pageX = touch.pageX;
  1670. event.pageY = touch.pageY;
  1671. };
  1672. this.hookTouchEvents = function(element, skipPrevent) {
  1673. let preventDefault = !skipPrevent;
  1674. let isHovering = false;
  1675. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1676. let passive = false;
  1677. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1678. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1679. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1680. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1681. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1682.  
  1683. function touchStart(e) {
  1684. _this.mousifyTouchEvent(e);
  1685. window.setUsingTouch(true);
  1686. if (preventDefault) {
  1687. e.preventDefault();
  1688. e.stopPropagation();
  1689. }
  1690. if (element.onmouseover)
  1691. element.onmouseover(e);
  1692. isHovering = true;
  1693. }
  1694.  
  1695. function touchMove(e) {
  1696. _this.mousifyTouchEvent(e);
  1697. window.setUsingTouch(true);
  1698. if (preventDefault) {
  1699. e.preventDefault();
  1700. e.stopPropagation();
  1701. }
  1702. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1703. if (!isHovering) {
  1704. if (element.onmouseover)
  1705. element.onmouseover(e);
  1706. isHovering = true;
  1707. }
  1708. } else {
  1709. if (isHovering) {
  1710. if (element.onmouseout)
  1711. element.onmouseout(e);
  1712. isHovering = false;
  1713. }
  1714. }
  1715. }
  1716.  
  1717. function touchEnd(e) {
  1718. _this.mousifyTouchEvent(e);
  1719. window.setUsingTouch(true);
  1720. if (preventDefault) {
  1721. e.preventDefault();
  1722. e.stopPropagation();
  1723. }
  1724. if (isHovering) {
  1725. if (element.onclick)
  1726. element.onclick(e);
  1727. if (element.onmouseout)
  1728. element.onmouseout(e);
  1729. isHovering = false;
  1730. }
  1731. }
  1732. };
  1733. this.removeAllChildren = function(element) {
  1734. while (element.hasChildNodes()) {
  1735. element.removeChild(element.lastChild);
  1736. }
  1737. };
  1738. this.generateElement = function(config) {
  1739. let element = document.createElement(config.tag || "div");
  1740.  
  1741. function bind(configValue, elementValue) {
  1742. if (config[configValue])
  1743. element[elementValue] = config[configValue];
  1744. }
  1745. bind("text", "textContent");
  1746. bind("html", "innerHTML");
  1747. bind("class", "className");
  1748. for (let key in config) {
  1749. switch (key) {
  1750. case "tag":
  1751. case "text":
  1752. case "html":
  1753. case "class":
  1754. case "style":
  1755. case "hookTouch":
  1756. case "parent":
  1757. case "children":
  1758. continue;
  1759. default:
  1760. break;
  1761. }
  1762. element[key] = config[key];
  1763. }
  1764. if (element.onclick)
  1765. element.onclick = this.checkTrusted(element.onclick);
  1766. if (element.onmouseover)
  1767. element.onmouseover = this.checkTrusted(element.onmouseover);
  1768. if (element.onmouseout)
  1769. element.onmouseout = this.checkTrusted(element.onmouseout);
  1770. if (config.style) {
  1771. element.style.cssText = config.style;
  1772. }
  1773. if (config.hookTouch) {
  1774. this.hookTouchEvents(element);
  1775. }
  1776. if (config.parent) {
  1777. config.parent.appendChild(element);
  1778. }
  1779. if (config.children) {
  1780. for (let i = 0; i < config.children.length; i++) {
  1781. element.appendChild(config.children[i]);
  1782. }
  1783. }
  1784. return element;
  1785. };
  1786. this.checkTrusted = function(callback) {
  1787. return function(ev) {
  1788. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1789. callback(ev);
  1790. } else {
  1791. //console.error("Event is not trusted.", ev);
  1792. }
  1793. };
  1794. };
  1795. this.randomString = function(length) {
  1796. let text = "";
  1797. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1798. for (let i = 0; i < length; i++) {
  1799. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1800. }
  1801. return text;
  1802. };
  1803. this.countInArray = function(array, val) {
  1804. let count = 0;
  1805. for (let i = 0; i < array.length; i++) {
  1806. if (array[i] === val) count++;
  1807. }
  1808. return count;
  1809. };
  1810. this.hexToRgb = function(hex) {
  1811. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1812. };
  1813. this.getRgb = function(r, g, b) {
  1814. return [r / 255, g / 255, b / 255].join(", ");
  1815. };
  1816. }
  1817. };
  1818. class Animtext {
  1819. // ANIMATED TEXT:
  1820. constructor() {
  1821. // INIT:
  1822. this.init = function(x, y, scale, speed, life, text, color) {
  1823. (this.x = x),
  1824. (this.y = y),
  1825. (this.color = color),
  1826. (this.scale = scale*3.5),
  1827. (this.weight = 50);
  1828. (this.startScale = this.scale * 1.2),
  1829. (this.maxScale = 1.5 * scale),
  1830. (this.minScale = 0.5 * scale),
  1831. (this.scaleSpeed = 0.7),
  1832. (this.speed = speed),
  1833. (this.speedMax = speed),
  1834. (this.life = life),
  1835. (this.maxLife = life),
  1836. (this.text = text),
  1837. this.movSpeed = speed;
  1838. };
  1839.  
  1840. // UPDATE:
  1841. this.update = function(delta) {
  1842. if(this.life){
  1843. this.life -= delta;
  1844. if(this.scaleSpeed != -0.35){
  1845. this.y -= this.speed * delta;
  1846. // (this.x += this.speed * delta);
  1847. } else {
  1848. this.y -= this.speed * delta;
  1849. }
  1850. this.scale -= .8;
  1851. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  1852. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  1853. if(this.scale >= this.maxScale){
  1854. this.scale = this.maxScale;
  1855. this.scaleSpeed *= -.5;
  1856. this.speed = this.speed * .75;
  1857. };
  1858. this.life <= 0 && (this.life = 0)
  1859. };
  1860. };
  1861.  
  1862. // RENDER:
  1863. this.render = function(ctxt, xOff, yOff) {
  1864. ctxt.lineWidth = 10;
  1865. ctxt.strokeStyle = darkOutlineColor; //"black";
  1866. ctxt.fillStyle = this.color;
  1867. ctxt.globalAlpha = 1;
  1868. ctxt.font = this.scale + "px HammerSmith One";
  1869. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1870. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1871. ctxt.globalAlpha = 1;
  1872. };
  1873. }
  1874. };
  1875. class Textmanager {
  1876. // TEXT MANAGER:
  1877. constructor() {
  1878. this.texts = [];
  1879. this.stack = [];
  1880.  
  1881. // UPDATE:
  1882. this.update = function(delta, ctxt, xOff, yOff) {
  1883. ctxt.textBaseline = "middle";
  1884. ctxt.textAlign = "center";
  1885. for (let i = 0; i < this.texts.length; ++i) {
  1886. if (this.texts[i].life) {
  1887. this.texts[i].update(delta);
  1888. this.texts[i].render(ctxt, xOff, yOff);
  1889. }
  1890. }
  1891. };
  1892.  
  1893. // SHOW TEXT:
  1894. this.showText = function(x, y, scale, speed, life, text, color) {
  1895. let tmpText;
  1896. for (let i = 0; i < this.texts.length; ++i) {
  1897. if (!this.texts[i].life) {
  1898. tmpText = this.texts[i];
  1899. break;
  1900. }
  1901. }
  1902. if (!tmpText) {
  1903. tmpText = new Animtext();
  1904. this.texts.push(tmpText);
  1905. }
  1906. tmpText.init(x, y, scale, speed, life, text, color);
  1907. };
  1908. }
  1909. }
  1910.  
  1911. class GameObject {
  1912. constructor(sid) {
  1913. this.sid = sid;
  1914.  
  1915. // INIT:
  1916. this.init = function(x, y, dir, scale, type, data, owner) {
  1917. data = data || {};
  1918. this.sentTo = {};
  1919. this.gridLocations = [];
  1920. this.active = true;
  1921. this.render = true;
  1922. this.doUpdate = data.doUpdate;
  1923. this.x = x;
  1924. this.y = y;
  1925. this.dir = dir;
  1926. this.lastDir = dir;
  1927. this.xWiggle = 0;
  1928. this.yWiggle = 0;
  1929. this.visScale = scale;
  1930. this.scale = scale;
  1931. this.type = type;
  1932. this.id = data.id;
  1933. this.owner = owner;
  1934. this.name = data.name;
  1935. this.isItem = (this.id != undefined);
  1936. this.group = data.group;
  1937. this.maxHealth = data.health;
  1938. this.health = this.maxHealth;
  1939. this.layer = 2;
  1940. if (this.group != undefined) {
  1941. this.layer = this.group.layer;
  1942. } else if (this.type == 0) {
  1943. this.layer = 3;
  1944. } else if (this.type == 2) {
  1945. this.layer = 0;
  1946. } else if (this.type == 4) {
  1947. this.layer = -1;
  1948. }
  1949. this.colDiv = data.colDiv || 1;
  1950. this.blocker = data.blocker;
  1951. this.ignoreCollision = data.ignoreCollision;
  1952. this.dontGather = data.dontGather;
  1953. this.hideFromEnemy = data.hideFromEnemy;
  1954. this.friction = data.friction;
  1955. this.projDmg = data.projDmg;
  1956. this.dmg = data.dmg;
  1957. this.pDmg = data.pDmg;
  1958. this.pps = data.pps;
  1959. this.zIndex = data.zIndex || 0;
  1960. this.turnSpeed = data.turnSpeed;
  1961. this.req = data.req;
  1962. this.trap = data.trap;
  1963. this.healCol = data.healCol;
  1964. this.teleport = data.teleport;
  1965. this.boostSpeed = data.boostSpeed;
  1966. this.projectile = data.projectile;
  1967. this.shootRange = data.shootRange;
  1968. this.shootRate = data.shootRate;
  1969. this.shootCount = this.shootRate;
  1970. this.spawnPoint = data.spawnPoint;
  1971. this.onNear = 0;
  1972. this.breakObj = false;
  1973. this.alpha = data.alpha || 1;
  1974. this.maxAlpha = data.alpha || 1;
  1975. this.damaged = 0;
  1976. };
  1977.  
  1978. // GET HIT:
  1979. this.changeHealth = function(amount, doer) {
  1980. this.health += amount;
  1981. return (this.health <= 0);
  1982. };
  1983.  
  1984. // GET SCALE:
  1985. this.getScale = function(sM, ig) {
  1986. sM = sM || 1;
  1987. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1988. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1989. };
  1990.  
  1991. // VISIBLE TO PLAYER:
  1992. this.visibleToPlayer = function(player) {
  1993. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1994. (this.owner.team && player.team == this.owner.team)));
  1995. };
  1996.  
  1997. // UPDATE:
  1998. this.update = function(delta) {
  1999. if (this.active) {
  2000. if (this.xWiggle) {
  2001. this.xWiggle *= Math.pow(0.99, delta);
  2002. }
  2003. if (this.yWiggle) {
  2004. this.yWiggle *= Math.pow(0.99, delta);
  2005. }
  2006. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2007. if (d2 > 0.01) {
  2008. this.dir += d2 / 5;
  2009. } else {
  2010. this.dir = this.lastDir;
  2011. }
  2012. } else {
  2013. if (this.alive) {
  2014. this.alpha -= delta / (200 / this.maxAlpha);
  2015. this.visScale += delta / (this.scale / 2.5);
  2016. if (this.alpha <= 0) {
  2017. this.alpha = 0;
  2018. this.alive = false;
  2019. }
  2020. }
  2021. }
  2022. };
  2023.  
  2024. // CHECK TEAM:
  2025. this.isTeamObject = function(tmpObj) {
  2026. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2027. };
  2028. }
  2029. }
  2030. class Items {
  2031. constructor() {
  2032. // ITEM GROUPS:
  2033. this.groups = [{
  2034. id: 0,
  2035. name: "food",
  2036. layer: 0
  2037. }, {
  2038. id: 1,
  2039. name: "walls",
  2040. place: true,
  2041. limit: 30,
  2042. layer: 0
  2043. }, {
  2044. id: 2,
  2045. name: "spikes",
  2046. place: true,
  2047. limit: 15,
  2048. layer: 0
  2049. }, {
  2050. id: 3,
  2051. name: "mill",
  2052. place: true,
  2053. limit: 7,
  2054. layer: 1
  2055. }, {
  2056. id: 4,
  2057. name: "mine",
  2058. place: true,
  2059. limit: 1,
  2060. layer: 0
  2061. }, {
  2062. id: 5,
  2063. name: "trap",
  2064. place: true,
  2065. limit: 6,
  2066. layer: -1
  2067. }, {
  2068. id: 6,
  2069. name: "booster",
  2070. place: true,
  2071. limit: 12,
  2072. layer: -1
  2073. }, {
  2074. id: 7,
  2075. name: "turret",
  2076. place: true,
  2077. limit: 2,
  2078. layer: 1
  2079. }, {
  2080. id: 8,
  2081. name: "watchtower",
  2082. place: true,
  2083. limit: 12,
  2084. layer: 1
  2085. }, {
  2086. id: 9,
  2087. name: "buff",
  2088. place: true,
  2089. limit: 4,
  2090. layer: -1
  2091. }, {
  2092. id: 10,
  2093. name: "spawn",
  2094. place: true,
  2095. limit: 1,
  2096. layer: -1
  2097. }, {
  2098. id: 11,
  2099. name: "sapling",
  2100. place: true,
  2101. limit: 2,
  2102. layer: 0
  2103. }, {
  2104. id: 12,
  2105. name: "blocker",
  2106. place: true,
  2107. limit: 3,
  2108. layer: -1
  2109. }, {
  2110. id: 13,
  2111. name: "teleporter",
  2112. place: true,
  2113. limit: 2,
  2114. layer: -1
  2115. }];
  2116.  
  2117. // PROJECTILES:
  2118. this.projectiles = [{
  2119. indx: 0,
  2120. layer: 0,
  2121. src: "arrow_1",
  2122. dmg: 25,
  2123. speed: 1.6,
  2124. scale: 103,
  2125. range: 1000
  2126. }, {
  2127. indx: 1,
  2128. layer: 1,
  2129. dmg: 25,
  2130. scale: 20
  2131. }, {
  2132. indx: 0,
  2133. layer: 0,
  2134. src: "arrow_1",
  2135. dmg: 35,
  2136. speed: 2.5,
  2137. scale: 103,
  2138. range: 1200
  2139. }, {
  2140. indx: 0,
  2141. layer: 0,
  2142. src: "arrow_1",
  2143. dmg: 30,
  2144. speed: 2,
  2145. scale: 103,
  2146. range: 1200
  2147. }, {
  2148. indx: 1,
  2149. layer: 1,
  2150. dmg: 16,
  2151. scale: 20
  2152. }, {
  2153. indx: 0,
  2154. layer: 0,
  2155. src: "bullet_1",
  2156. dmg: 50,
  2157. speed: 3.6,
  2158. scale: 160,
  2159. range: 1400
  2160. }];
  2161.  
  2162. // WEAPONS:
  2163. this.weapons = [{
  2164. id: 0,
  2165. type: 0,
  2166. name: "tool hammer",
  2167. desc: "tool for gathering all resources",
  2168. src: "hammer_1",
  2169. length: 140,
  2170. width: 140,
  2171. xOff: -3,
  2172. yOff: 18,
  2173. dmg: 25,
  2174. range: 65,
  2175. gather: 1,
  2176. speed: 300
  2177. }, {
  2178. id: 1,
  2179. type: 0,
  2180. age: 2,
  2181. name: "hand axe",
  2182. desc: "gathers resources at a higher rate",
  2183. src: "axe_1",
  2184. length: 140,
  2185. width: 140,
  2186. xOff: 3,
  2187. yOff: 24,
  2188. dmg: 30,
  2189. spdMult: 1,
  2190. range: 70,
  2191. gather: 2,
  2192. speed: 400
  2193. }, {
  2194. id: 2,
  2195. type: 0,
  2196. age: 8,
  2197. pre: 1,
  2198. name: "great axe",
  2199. desc: "deal more damage and gather more resources",
  2200. src: "great_axe_1",
  2201. length: 140,
  2202. width: 140,
  2203. xOff: -8,
  2204. yOff: 25,
  2205. dmg: 35,
  2206. spdMult: 1,
  2207. range: 75,
  2208. gather: 4,
  2209. speed: 400
  2210. }, {
  2211. id: 3,
  2212. type: 0,
  2213. age: 2,
  2214. name: "short sword",
  2215. desc: "increased attack power but slower move speed",
  2216. src: "sword_1",
  2217. iPad: 1.3,
  2218. length: 130,
  2219. width: 210,
  2220. xOff: -8,
  2221. yOff: 46,
  2222. dmg: 35,
  2223. spdMult: 0.85,
  2224. range: 110,
  2225. gather: 1,
  2226. speed: 300
  2227. }, {
  2228. id: 4,
  2229. type: 0,
  2230. age: 8,
  2231. pre: 3,
  2232. name: "katana",
  2233. desc: "greater range and damage",
  2234. src: "samurai_1",
  2235. iPad: 1.3,
  2236. length: 130,
  2237. width: 210,
  2238. xOff: -8,
  2239. yOff: 59,
  2240. dmg: 40,
  2241. spdMult: 0.8,
  2242. range: 118,
  2243. gather: 1,
  2244. speed: 300
  2245. }, {
  2246. id: 5,
  2247. type: 0,
  2248. age: 2,
  2249. name: "polearm",
  2250. desc: "long range melee weapon",
  2251. src: "spear_1",
  2252. iPad: 1.3,
  2253. length: 130,
  2254. width: 210,
  2255. xOff: -8,
  2256. yOff: 53,
  2257. dmg: 45,
  2258. knock: 0.2,
  2259. spdMult: 0.82,
  2260. range: 142,
  2261. gather: 1,
  2262. speed: 700
  2263. }, {
  2264. id: 6,
  2265. type: 0,
  2266. age: 2,
  2267. name: "bat",
  2268. desc: "fast long range melee weapon",
  2269. src: "bat_1",
  2270. iPad: 1.3,
  2271. length: 110,
  2272. width: 180,
  2273. xOff: -8,
  2274. yOff: 53,
  2275. dmg: 20,
  2276. knock: 0.7,
  2277. range: 110,
  2278. gather: 1,
  2279. speed: 300
  2280. }, {
  2281. id: 7,
  2282. type: 0,
  2283. age: 2,
  2284. name: "daggers",
  2285. desc: "really fast short range weapon",
  2286. src: "dagger_1",
  2287. iPad: 0.8,
  2288. length: 110,
  2289. width: 110,
  2290. xOff: 18,
  2291. yOff: 0,
  2292. dmg: 20,
  2293. knock: 0.1,
  2294. range: 65,
  2295. gather: 1,
  2296. hitSlow: 0.1,
  2297. spdMult: 1.13,
  2298. speed: 100
  2299. }, {
  2300. id: 8,
  2301. type: 0,
  2302. age: 2,
  2303. name: "stick",
  2304. desc: "great for gathering but very weak",
  2305. src: "stick_1",
  2306. length: 140,
  2307. width: 140,
  2308. xOff: 3,
  2309. yOff: 24,
  2310. dmg: 1,
  2311. spdMult: 1,
  2312. range: 70,
  2313. gather: 7,
  2314. speed: 400
  2315. }, {
  2316. id: 9,
  2317. type: 1,
  2318. age: 6,
  2319. name: "hunting bow",
  2320. desc: "bow used for ranged combat and hunting",
  2321. src: "bow_1",
  2322. req: ["wood", 4],
  2323. length: 120,
  2324. width: 120,
  2325. xOff: -6,
  2326. yOff: 0,
  2327. Pdmg: 25,
  2328. projectile: 0,
  2329. spdMult: 0.75,
  2330. speed: 600
  2331. }, {
  2332. id: 10,
  2333. type: 1,
  2334. age: 6,
  2335. name: "great hammer",
  2336. desc: "hammer used for destroying structures",
  2337. src: "great_hammer_1",
  2338. length: 140,
  2339. width: 140,
  2340. xOff: -9,
  2341. yOff: 25,
  2342. dmg: 10,
  2343. Pdmg: 10,
  2344. spdMult: 0.88,
  2345. range: 75,
  2346. sDmg: 7.5,
  2347. gather: 1,
  2348. speed: 400
  2349. }, {
  2350. id: 11,
  2351. type: 1,
  2352. age: 6,
  2353. name: "wooden shield",
  2354. desc: "blocks projectiles and reduces melee damage",
  2355. src: "shield_1",
  2356. length: 120,
  2357. width: 120,
  2358. shield: 0.2,
  2359. xOff: 6,
  2360. yOff: 0,
  2361. Pdmg: 0,
  2362. spdMult: 0.7
  2363. }, {
  2364. id: 12,
  2365. type: 1,
  2366. age: 8,
  2367. pre: 9,
  2368. name: "crossbow",
  2369. desc: "deals more damage and has greater range",
  2370. src: "crossbow_1",
  2371. req: ["wood", 5],
  2372. aboveHand: true,
  2373. armS: 0.75,
  2374. length: 120,
  2375. width: 120,
  2376. xOff: -4,
  2377. yOff: 0,
  2378. Pdmg: 35,
  2379. projectile: 2,
  2380. spdMult: 0.7,
  2381. speed: 700
  2382. }, {
  2383. id: 13,
  2384. type: 1,
  2385. age: 9,
  2386. pre: 12,
  2387. name: "repeater crossbow",
  2388. desc: "high firerate crossbow with reduced damage",
  2389. src: "crossbow_2",
  2390. req: ["wood", 10],
  2391. aboveHand: true,
  2392. armS: 0.75,
  2393. length: 120,
  2394. width: 120,
  2395. xOff: -4,
  2396. yOff: 0,
  2397. Pdmg: 30,
  2398. projectile: 3,
  2399. spdMult: 0.7,
  2400. speed: 230
  2401. }, {
  2402. id: 14,
  2403. type: 1,
  2404. age: 6,
  2405. name: "mc grabby",
  2406. desc: "steals resources from enemies",
  2407. src: "grab_1",
  2408. length: 130,
  2409. width: 210,
  2410. xOff: -8,
  2411. yOff: 53,
  2412. dmg: 0,
  2413. Pdmg: 0,
  2414. steal: 250,
  2415. knock: 0.2,
  2416. spdMult: 1.05,
  2417. range: 125,
  2418. gather: 0,
  2419. speed: 700
  2420. }, {
  2421. id: 15,
  2422. type: 1,
  2423. age: 9,
  2424. pre: 12,
  2425. name: "musket",
  2426. desc: "slow firerate but high damage and range",
  2427. src: "musket_1",
  2428. req: ["stone", 10],
  2429. aboveHand: true,
  2430. rec: 0.35,
  2431. armS: 0.6,
  2432. hndS: 0.3,
  2433. hndD: 1.6,
  2434. length: 205,
  2435. width: 205,
  2436. xOff: 25,
  2437. yOff: 0,
  2438. Pdmg: 50,
  2439. projectile: 5,
  2440. hideProjectile: true,
  2441. spdMult: 0.6,
  2442. speed: 1500
  2443. }];
  2444.  
  2445. // ITEMS:
  2446. this.list = [{
  2447. group: this.groups[0],
  2448. name: "apple",
  2449. desc: "restores 20 health when consumed",
  2450. req: ["food", 10],
  2451. consume: function(doer) {
  2452. return doer.changeHealth(20, doer);
  2453. },
  2454. scale: 22,
  2455. holdOffset: 15,
  2456. healing: 20,
  2457. itemID: 0,
  2458. itemAID: 16,
  2459. }, {
  2460. age: 3,
  2461. group: this.groups[0],
  2462. name: "cookie",
  2463. desc: "restores 40 health when consumed",
  2464. req: ["food", 15],
  2465. consume: function(doer) {
  2466. return doer.changeHealth(40, doer);
  2467. },
  2468. scale: 27,
  2469. holdOffset: 15,
  2470. healing: 40,
  2471. itemID: 1,
  2472. itemAID: 17,
  2473. }, {
  2474. age: 7,
  2475. group: this.groups[0],
  2476. name: "cheese",
  2477. desc: "restores 30 health and another 50 over 5 seconds",
  2478. req: ["food", 25],
  2479. consume: function(doer) {
  2480. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2481. doer.dmgOverTime.dmg = -10;
  2482. doer.dmgOverTime.doer = doer;
  2483. doer.dmgOverTime.time = 5;
  2484. return true;
  2485. }
  2486. return false;
  2487. },
  2488. scale: 27,
  2489. holdOffset: 15,
  2490. healing: 30,
  2491. itemID: 2,
  2492. itemAID: 18,
  2493. }, {
  2494. group: this.groups[1],
  2495. name: "wood wall",
  2496. desc: "provides protection for your village",
  2497. req: ["wood", 10],
  2498. projDmg: true,
  2499. health: 380,
  2500. scale: 50,
  2501. holdOffset: 20,
  2502. placeOffset: -5,
  2503. itemID: 3,
  2504. itemAID: 19,
  2505. }, {
  2506. age: 3,
  2507. group: this.groups[1],
  2508. name: "stone wall",
  2509. desc: "provides improved protection for your village",
  2510. req: ["stone", 25],
  2511. health: 900,
  2512. scale: 50,
  2513. holdOffset: 20,
  2514. placeOffset: -5,
  2515. itemID: 4,
  2516. itemAID: 20,
  2517. }, {
  2518. age: 7,
  2519. group: this.groups[1],
  2520. name: "castle wall",
  2521. desc: "provides powerful protection for your village",
  2522. req: ["stone", 35],
  2523. health: 1500,
  2524. scale: 52,
  2525. holdOffset: 20,
  2526. placeOffset: -5,
  2527. itemID: 5,
  2528. itemAID: 21,
  2529. }, {
  2530. group: this.groups[2],
  2531. name: "spikes",
  2532. desc: "damages enemies when they touch them",
  2533. req: ["wood", 20, "stone", 5],
  2534. health: 400,
  2535. dmg: 20,
  2536. scale: 49,
  2537. spritePadding: -23,
  2538. holdOffset: 8,
  2539. placeOffset: -5,
  2540. itemID: 6,
  2541. itemAID: 22,
  2542. shadow: {
  2543. offsetX: 5, // Adjust the shadow's X offset as needed
  2544. offsetY: 5, // Adjust the shadow's Y offset as needed
  2545. blur: 20, // Adjust the shadow's blur as needed
  2546. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2547. }
  2548.  
  2549. }, {
  2550. age: 5,
  2551. group: this.groups[2],
  2552. name: "greater spikes",
  2553. desc: "damages enemies when they touch them",
  2554. req: ["wood", 30, "stone", 10],
  2555. health: 500,
  2556. dmg: 35,
  2557. scale: 52,
  2558. spritePadding: -23,
  2559. holdOffset: 8,
  2560. placeOffset: -5,
  2561. itemID: 7,
  2562. itemAID: 23,
  2563. }, {
  2564. age: 9,
  2565. group: this.groups[2],
  2566. name: "poison spikes",
  2567. desc: "poisons enemies when they touch them",
  2568. req: ["wood", 35, "stone", 15],
  2569. health: 600,
  2570. dmg: 30,
  2571. pDmg: 5,
  2572. scale: 52,
  2573. spritePadding: -23,
  2574. holdOffset: 8,
  2575. placeOffset: -5,
  2576. itemID: 8,
  2577. itemAID: 24,
  2578. }, {
  2579. age: 9,
  2580. group: this.groups[2],
  2581. name: "spinning spikes",
  2582. desc: "damages enemies when they touch them",
  2583. req: ["wood", 30, "stone", 20],
  2584. health: 500,
  2585. dmg: 45,
  2586. turnSpeed: 0.003,
  2587. scale: 52,
  2588. spritePadding: -23,
  2589. holdOffset: 8,
  2590. placeOffset: -5,
  2591. itemID: 9,
  2592. itemAID: 25,
  2593. }, {
  2594. group: this.groups[3],
  2595. name: "windmill",
  2596. desc: "generates gold over time",
  2597. req: ["wood", 50, "stone", 10],
  2598. health: 400,
  2599. pps: 1,
  2600. turnSpeed: 0.0016,
  2601. spritePadding: 25,
  2602. iconLineMult: 12,
  2603. scale: 45,
  2604. holdOffset: 20,
  2605. placeOffset: 5,
  2606. itemID: 10,
  2607. itemAID: 26,
  2608. }, {
  2609. age: 5,
  2610. group: this.groups[3],
  2611. name: "faster windmill",
  2612. desc: "generates more gold over time",
  2613. req: ["wood", 60, "stone", 20],
  2614. health: 500,
  2615. pps: 1.5,
  2616. turnSpeed: 0.0025,
  2617. spritePadding: 25,
  2618. iconLineMult: 12,
  2619. scale: 47,
  2620. holdOffset: 20,
  2621. placeOffset: 5,
  2622. itemID: 11,
  2623. itemAID: 27,
  2624. }, {
  2625. age: 8,
  2626. group: this.groups[3],
  2627. name: "power mill",
  2628. desc: "generates more gold over time",
  2629. req: ["wood", 100, "stone", 50],
  2630. health: 800,
  2631. pps: 2,
  2632. turnSpeed: 0.005,
  2633. spritePadding: 25,
  2634. iconLineMult: 12,
  2635. scale: 47,
  2636. holdOffset: 20,
  2637. placeOffset: 5,
  2638. itemID: 12,
  2639. itemAID: 28,
  2640. }, {
  2641. age: 5,
  2642. group: this.groups[4],
  2643. type: 2,
  2644. name: "mine",
  2645. desc: "allows you to mine stone",
  2646. req: ["wood", 20, "stone", 100],
  2647. iconLineMult: 12,
  2648. scale: 65,
  2649. holdOffset: 20,
  2650. placeOffset: 0,
  2651. itemID: 13,
  2652. itemAID: 29,
  2653. }, {
  2654. age: 5,
  2655. group: this.groups[11],
  2656. type: 0,
  2657. name: "sapling",
  2658. desc: "allows you to farm wood",
  2659. req: ["wood", 150],
  2660. iconLineMult: 12,
  2661. colDiv: 0.5,
  2662. scale: 110,
  2663. holdOffset: 50,
  2664. placeOffset: -15,
  2665. itemID: 14,
  2666. itemAID: 30,
  2667. }, {
  2668. age: 4,
  2669. group: this.groups[5],
  2670. name: "pit trap",
  2671. desc: "pit that traps enemies if they walk over it",
  2672. req: ["wood", 30, "stone", 30],
  2673. trap: true,
  2674. ignoreCollision: true,
  2675. hideFromEnemy: true,
  2676. health: 500,
  2677. colDiv: 0.2,
  2678. scale: 50,
  2679. holdOffset: 20,
  2680. placeOffset: -5,
  2681. alpha: 0.6,
  2682. itemID: 15,
  2683. itemAID: 31,
  2684. }, {
  2685. age: 4,
  2686. group: this.groups[6],
  2687. name: "boost pad",
  2688. desc: "provides boost when stepped on",
  2689. req: ["stone", 20, "wood", 5],
  2690. ignoreCollision: true,
  2691. boostSpeed: 1.5,
  2692. health: 150,
  2693. colDiv: 0.7,
  2694. scale: 45,
  2695. holdOffset: 20,
  2696. placeOffset: -5,
  2697. itemID: 16,
  2698. itemAID: 32,
  2699. }, {
  2700. age: 7,
  2701. group: this.groups[7],
  2702. doUpdate: true,
  2703. name: "turret",
  2704. desc: "defensive structure that shoots at enemies",
  2705. req: ["wood", 200, "stone", 150],
  2706. health: 800,
  2707. projectile: 1,
  2708. shootRange: 700,
  2709. shootRate: 2200,
  2710. scale: 43,
  2711. holdOffset: 20,
  2712. placeOffset: -5,
  2713. itemID: 17,
  2714. itemAID: 33,
  2715. }, {
  2716. age: 7,
  2717. group: this.groups[8],
  2718. name: "platform",
  2719. desc: "platform to shoot over walls and cross over water",
  2720. req: ["wood", 20],
  2721. ignoreCollision: true,
  2722. zIndex: 1,
  2723. health: 300,
  2724. scale: 43,
  2725. holdOffset: 20,
  2726. placeOffset: -5,
  2727. itemID: 18,
  2728. itemAID: 34,
  2729. }, {
  2730. age: 7,
  2731. group: this.groups[9],
  2732. name: "healing pad",
  2733. desc: "standing on it will slowly heal you",
  2734. req: ["wood", 30, "food", 10],
  2735. ignoreCollision: true,
  2736. healCol: 15,
  2737. health: 400,
  2738. colDiv: 0.7,
  2739. scale: 45,
  2740. holdOffset: 20,
  2741. placeOffset: -5,
  2742. itemID: 19,
  2743. itemAID: 35,
  2744. }, {
  2745. age: 9,
  2746. group: this.groups[10],
  2747. name: "spawn pad",
  2748. desc: "you will spawn here when you die but it will dissapear",
  2749. req: ["wood", 100, "stone", 100],
  2750. health: 400,
  2751. ignoreCollision: true,
  2752. spawnPoint: true,
  2753. scale: 45,
  2754. holdOffset: 20,
  2755. placeOffset: -5,
  2756. itemID: 20,
  2757. itemAID: 36,
  2758. }, {
  2759. age: 7,
  2760. group: this.groups[12],
  2761. name: "blocker",
  2762. desc: "blocks building in radius",
  2763. req: ["wood", 30, "stone", 25],
  2764. ignoreCollision: true,
  2765. blocker: 300,
  2766. health: 400,
  2767. colDiv: 0.7,
  2768. scale: 45,
  2769. holdOffset: 20,
  2770. placeOffset: -5,
  2771. itemID: 21,
  2772. itemAID: 37,
  2773. }, {
  2774. age: 7,
  2775. group: this.groups[13],
  2776. name: "teleporter",
  2777. desc: "teleports you to a random point on the map",
  2778. req: ["wood", 60, "stone", 60],
  2779. ignoreCollision: true,
  2780. teleport: true,
  2781. health: 200,
  2782. colDiv: 0.7,
  2783. scale: 45,
  2784. holdOffset: 20,
  2785. placeOffset: -5,
  2786. itemID: 22,
  2787. itemAID: 38
  2788. }];
  2789.  
  2790. // CHECK ITEM ID:
  2791. this.checkItem = {
  2792. index: function(id, myItems) {
  2793. 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 :
  2794. 5 :
  2795. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2796. 6 :
  2797. undefined;
  2798. }
  2799. }
  2800.  
  2801. // ASSIGN IDS:
  2802. for (let i = 0; i < this.list.length; ++i) {
  2803. this.list[i].id = i;
  2804. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2805. }
  2806.  
  2807. // TROLOLOLOL:
  2808. if (typeof window !== "undefined") {
  2809. function shuffle(a) {
  2810. for (let i = a.length - 1; i > 0; i--) {
  2811. const j = Math.floor(Math.random() * (i + 1));
  2812. [a[i], a[j]] = [a[j], a[i]];
  2813. }
  2814. return a;
  2815. }
  2816. //shuffle(this.list);
  2817. }
  2818. }
  2819. }
  2820. class Objectmanager {
  2821. constructor(GameObject, liztobj, UTILS, config, players, server) {
  2822. let mathFloor = Math.floor,
  2823. mathABS = Math.abs,
  2824. mathCOS = Math.cos,
  2825. mathSIN = Math.sin,
  2826. mathPOW = Math.pow,
  2827. mathSQRT = Math.sqrt;
  2828.  
  2829. this.ignoreAdd = false;
  2830. this.hitObj = [];
  2831.  
  2832. // DISABLE OBJ:
  2833. this.disableObj = function(obj) {
  2834. obj.active = false;
  2835. };
  2836.  
  2837. // ADD NEW:
  2838. let tmpObj;
  2839. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2840. tmpObj = findObjectBySid(sid);
  2841. if (!tmpObj) {
  2842. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2843. if (!tmpObj) {
  2844. tmpObj = new GameObject(sid);
  2845. gameObjects.push(tmpObj);
  2846. }
  2847. }
  2848. if (setSID) {
  2849. tmpObj.sid = sid;
  2850. }
  2851. tmpObj.init(x, y, dir, s, type, data, owner);
  2852. };
  2853.  
  2854. // DISABLE BY SID:
  2855. this.disableBySid = function(sid) {
  2856. let find = findObjectBySid(sid);
  2857. if (find) {
  2858. this.disableObj(find);
  2859. }
  2860. };
  2861.  
  2862. // REMOVE ALL FROM PLAYER:
  2863. this.removeAllItems = function(sid, server) {
  2864. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2865. };
  2866.  
  2867. // CHECK IF PLACABLE:
  2868. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2869. 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)));
  2870. if (cantPlace) return false;
  2871. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2872. return true;
  2873. };
  2874.  
  2875. }
  2876. }
  2877. class Projectile {
  2878. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2879.  
  2880. // INIT:
  2881. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2882. this.active = true;
  2883. this.tickActive = true;
  2884. this.indx = indx;
  2885. this.x = x;
  2886. this.y = y;
  2887. this.x2 = x;
  2888. this.y2 = y;
  2889. this.dir = dir;
  2890. this.skipMov = true;
  2891. this.speed = spd;
  2892. this.dmg = dmg;
  2893. this.scale = scl;
  2894. this.range = rng;
  2895. this.r2 = rng;
  2896. this.owner = owner;
  2897. };
  2898.  
  2899. // UPDATE:
  2900. this.update = function(delta) {
  2901. if (this.active) {
  2902. let tmpSpeed = this.speed * delta;
  2903. if (!this.skipMov) {
  2904. this.x += tmpSpeed * Math.cos(this.dir);
  2905. this.y += tmpSpeed * Math.sin(this.dir);
  2906. this.range -= tmpSpeed;
  2907. if (this.range <= 0) {
  2908. this.x += this.range * Math.cos(this.dir);
  2909. this.y += this.range * Math.sin(this.dir);
  2910. tmpSpeed = 1;
  2911. this.range = 0;
  2912. this.active = false;
  2913. }
  2914. } else {
  2915. this.skipMov = false;
  2916. }
  2917. }
  2918. };
  2919. this.tickUpdate = function(delta) {
  2920. if (this.tickActive) {
  2921. let tmpSpeed = this.speed * delta;
  2922. if (!this.skipMov) {
  2923. this.x2 += tmpSpeed * Math.cos(this.dir);
  2924. this.y2 += tmpSpeed * Math.sin(this.dir);
  2925. this.r2 -= tmpSpeed;
  2926. if (this.r2 <= 0) {
  2927. this.x2 += this.r2 * Math.cos(this.dir);
  2928. this.y2 += this.r2 * Math.sin(this.dir);
  2929. tmpSpeed = 1;
  2930. this.r2 = 0;
  2931. this.tickActive = false;
  2932. }
  2933. } else {
  2934. this.skipMov = false;
  2935. }
  2936. }
  2937. };
  2938. }
  2939. };
  2940. class Store {
  2941. constructor() {
  2942. // STORE HATS:
  2943. this.hats = [{
  2944. id: 45,
  2945. name: "Shame!",
  2946. dontSell: true,
  2947. price: 0,
  2948. scale: 120,
  2949. desc: "hacks are for winners"
  2950. }, {
  2951. id: 51,
  2952. name: "Moo Cap",
  2953. price: 0,
  2954. scale: 120,
  2955. desc: "coolest mooer around"
  2956. }, {
  2957. id: 50,
  2958. name: "Apple Cap",
  2959. price: 0,
  2960. scale: 120,
  2961. desc: "apple farms remembers"
  2962. }, {
  2963. id: 28,
  2964. name: "Moo Head",
  2965. price: 0,
  2966. scale: 120,
  2967. desc: "no effect"
  2968. }, {
  2969. id: 29,
  2970. name: "Pig Head",
  2971. price: 0,
  2972. scale: 120,
  2973. desc: "no effect"
  2974. }, {
  2975. id: 30,
  2976. name: "Fluff Head",
  2977. price: 0,
  2978. scale: 120,
  2979. desc: "no effect"
  2980. }, {
  2981. id: 36,
  2982. name: "Pandou Head",
  2983. price: 0,
  2984. scale: 120,
  2985. desc: "no effect"
  2986. }, {
  2987. id: 37,
  2988. name: "Bear Head",
  2989. price: 0,
  2990. scale: 120,
  2991. desc: "no effect"
  2992. }, {
  2993. id: 38,
  2994. name: "Monkey Head",
  2995. price: 0,
  2996. scale: 120,
  2997. desc: "no effect"
  2998. }, {
  2999. id: 44,
  3000. name: "Polar Head",
  3001. price: 0,
  3002. scale: 120,
  3003. desc: "no effect"
  3004. }, {
  3005. id: 35,
  3006. name: "Fez Hat",
  3007. price: 0,
  3008. scale: 120,
  3009. desc: "no effect"
  3010. }, {
  3011. id: 42,
  3012. name: "Enigma Hat",
  3013. price: 0,
  3014. scale: 120,
  3015. desc: "join the enigma army"
  3016. }, {
  3017. id: 43,
  3018. name: "Blitz Hat",
  3019. price: 0,
  3020. scale: 120,
  3021. desc: "hey everybody i'm blitz"
  3022. }, {
  3023. id: 49,
  3024. name: "Bob XIII Hat",
  3025. price: 0,
  3026. scale: 120,
  3027. desc: "like and subscribe"
  3028. }, {
  3029. id: 57,
  3030. name: "Pumpkin",
  3031. price: 50,
  3032. scale: 120,
  3033. desc: "Spooooky"
  3034. }, {
  3035. id: 8,
  3036. name: "Bummle Hat",
  3037. price: 100,
  3038. scale: 120,
  3039. desc: "no effect"
  3040. }, {
  3041. id: 2,
  3042. name: "Straw Hat",
  3043. price: 500,
  3044. scale: 120,
  3045. desc: "no effect"
  3046. }, {
  3047. id: 15,
  3048. name: "Winter Cap",
  3049. price: 600,
  3050. scale: 120,
  3051. desc: "allows you to move at normal speed in snow",
  3052. coldM: 1
  3053. }, {
  3054. id: 5,
  3055. name: "Cowboy Hat",
  3056. price: 1000,
  3057. scale: 120,
  3058. desc: "no effect"
  3059. }, {
  3060. id: 4,
  3061. name: "Ranger Hat",
  3062. price: 2000,
  3063. scale: 120,
  3064. desc: "no effect"
  3065. }, {
  3066. id: 18,
  3067. name: "Explorer Hat",
  3068. price: 2000,
  3069. scale: 120,
  3070. desc: "no effect"
  3071. }, {
  3072. id: 31,
  3073. name: "Flipper Hat",
  3074. price: 2500,
  3075. scale: 120,
  3076. desc: "have more control while in water",
  3077. watrImm: true
  3078. }, {
  3079. id: 1,
  3080. name: "Marksman Cap",
  3081. price: 3000,
  3082. scale: 120,
  3083. desc: "increases arrow speed and range",
  3084. aMlt: 1.3
  3085. }, {
  3086. id: 10,
  3087. name: "Bush Gear",
  3088. price: 3000,
  3089. scale: 160,
  3090. desc: "allows you to disguise yourself as a bush"
  3091. }, {
  3092. id: 48,
  3093. name: "Halo",
  3094. price: 3000,
  3095. scale: 120,
  3096. desc: "no effect"
  3097. }, {
  3098. id: 6,
  3099. name: "Soldier Helmet",
  3100. price: 4000,
  3101. scale: 120,
  3102. desc: "reduces damage taken but slows movement",
  3103. spdMult: 0.94,
  3104. dmgMult: 0.75
  3105. }, {
  3106. id: 23,
  3107. name: "Anti Venom Gear",
  3108. price: 4000,
  3109. scale: 120,
  3110. desc: "makes you immune to poison",
  3111. poisonRes: 1
  3112. }, {
  3113. id: 13,
  3114. name: "Medic Gear",
  3115. price: 5000,
  3116. scale: 110,
  3117. desc: "slowly regenerates health over time",
  3118. healthRegen: 3
  3119. }, {
  3120. id: 9,
  3121. name: "Miners Helmet",
  3122. price: 5000,
  3123. scale: 120,
  3124. desc: "earn 1 extra gold per resource",
  3125. extraGold: 1
  3126. }, {
  3127. id: 32,
  3128. name: "Musketeer Hat",
  3129. price: 5000,
  3130. scale: 120,
  3131. desc: "reduces cost of projectiles",
  3132. projCost: 0.5
  3133. }, {
  3134. id: 7,
  3135. name: "Bull Helmet",
  3136. price: 6000,
  3137. scale: 120,
  3138. desc: "increases damage done but drains health",
  3139. healthRegen: -5,
  3140. dmgMultO: 1.5,
  3141. spdMult: 0.96
  3142. }, {
  3143. id: 22,
  3144. name: "Emp Helmet",
  3145. price: 6000,
  3146. scale: 120,
  3147. desc: "turrets won't attack but you move slower",
  3148. antiTurret: 1,
  3149. spdMult: 0.7
  3150. }, {
  3151. id: 12,
  3152. name: "Booster Hat",
  3153. price: 6000,
  3154. scale: 120,
  3155. desc: "increases your movement speed",
  3156. spdMult: 1.16
  3157. }, {
  3158. id: 26,
  3159. name: "Barbarian Armor",
  3160. price: 8000,
  3161. scale: 120,
  3162. desc: "knocks back enemies that attack you",
  3163. dmgK: 0.6
  3164. }, {
  3165. id: 21,
  3166. name: "Plague Mask",
  3167. price: 10000,
  3168. scale: 120,
  3169. desc: "melee attacks deal poison damage",
  3170. poisonDmg: 5,
  3171. poisonTime: 6
  3172. }, {
  3173. id: 46,
  3174. name: "Bull Mask",
  3175. price: 10000,
  3176. scale: 120,
  3177. desc: "bulls won't target you unless you attack them",
  3178. bullRepel: 1
  3179. }, {
  3180. id: 14,
  3181. name: "Windmill Hat",
  3182. topSprite: true,
  3183. price: 10000,
  3184. scale: 120,
  3185. desc: "generates points while worn",
  3186. pps: 1.5
  3187. }, {
  3188. id: 11,
  3189. name: "Spike Gear",
  3190. topSprite: true,
  3191. price: 10000,
  3192. scale: 120,
  3193. desc: "deal damage to players that damage you",
  3194. dmg: 0.45
  3195. }, {
  3196. id: 53,
  3197. name: "Turret Gear",
  3198. topSprite: true,
  3199. price: 10000,
  3200. scale: 120,
  3201. desc: "you become a walking turret",
  3202. turret: {
  3203. proj: 1,
  3204. range: 700,
  3205. rate: 2500
  3206. },
  3207. spdMult: 0.7
  3208. }, {
  3209. id: 20,
  3210. name: "Samurai Armor",
  3211. price: 12000,
  3212. scale: 120,
  3213. desc: "increased attack speed and fire rate",
  3214. atkSpd: 0.78
  3215. }, {
  3216. id: 58,
  3217. name: "Dark Knight",
  3218. price: 12000,
  3219. scale: 120,
  3220. desc: "restores health when you deal damage",
  3221. healD: 0.4
  3222. }, {
  3223. id: 27,
  3224. name: "Scavenger Gear",
  3225. price: 15000,
  3226. scale: 120,
  3227. desc: "earn double points for each kill",
  3228. kScrM: 2
  3229. }, {
  3230. id: 40,
  3231. name: "Tank Gear",
  3232. price: 15000,
  3233. scale: 120,
  3234. desc: "increased damage to buildings but slower movement",
  3235. spdMult: 0.3,
  3236. bDmg: 3.3
  3237. }, {
  3238. id: 52,
  3239. name: "Thief Gear",
  3240. price: 15000,
  3241. scale: 120,
  3242. desc: "steal half of a players gold when you kill them",
  3243. goldSteal: 0.5
  3244. }, {
  3245. id: 55,
  3246. name: "Bloodthirster",
  3247. price: 20000,
  3248. scale: 120,
  3249. desc: "Restore Health when dealing damage. And increased damage",
  3250. healD: 0.25,
  3251. dmgMultO: 1.2,
  3252. }, {
  3253. id: 56,
  3254. name: "Assassin Gear",
  3255. price: 20000,
  3256. scale: 120,
  3257. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3258. noEat: true,
  3259. spdMult: 1.1,
  3260. invisTimer: 1000
  3261. }];
  3262.  
  3263. // STORE ACCESSORIES:
  3264. this.accessories = [{
  3265. id: 12,
  3266. name: "Snowball",
  3267. price: 1000,
  3268. scale: 105,
  3269. xOff: 18,
  3270. desc: "no effect"
  3271. }, {
  3272. id: 9,
  3273. name: "Tree Cape",
  3274. price: 1000,
  3275. scale: 90,
  3276. desc: "no effect"
  3277. }, {
  3278. id: 10,
  3279. name: "Stone Cape",
  3280. price: 1000,
  3281. scale: 90,
  3282. desc: "no effect"
  3283. }, {
  3284. id: 3,
  3285. name: "Cookie Cape",
  3286. price: 1500,
  3287. scale: 90,
  3288. desc: "no effect"
  3289. }, {
  3290. id: 8,
  3291. name: "Cow Cape",
  3292. price: 2000,
  3293. scale: 90,
  3294. desc: "no effect"
  3295. }, {
  3296. id: 11,
  3297. name: "Monkey Tail",
  3298. price: 2000,
  3299. scale: 97,
  3300. xOff: 25,
  3301. desc: "Super speed but reduced damage",
  3302. spdMult: 1.35,
  3303. dmgMultO: 0.2
  3304. }, {
  3305. id: 17,
  3306. name: "Apple Basket",
  3307. price: 3000,
  3308. scale: 80,
  3309. xOff: 12,
  3310. desc: "slowly regenerates health over time",
  3311. healthRegen: 1
  3312. }, {
  3313. id: 6,
  3314. name: "Winter Cape",
  3315. price: 3000,
  3316. scale: 90,
  3317. desc: "no effect"
  3318. }, {
  3319. id: 4,
  3320. name: "Skull Cape",
  3321. price: 4000,
  3322. scale: 90,
  3323. desc: "no effect"
  3324. }, {
  3325. id: 5,
  3326. name: "Dash Cape",
  3327. price: 5000,
  3328. scale: 90,
  3329. desc: "no effect"
  3330. }, {
  3331. id: 2,
  3332. name: "Dragon Cape",
  3333. price: 6000,
  3334. scale: 90,
  3335. desc: "no effect"
  3336. }, {
  3337. id: 1,
  3338. name: "Super Cape",
  3339. price: 8000,
  3340. scale: 90,
  3341. desc: "no effect"
  3342. }, {
  3343. id: 7,
  3344. name: "Troll Cape",
  3345. price: 8000,
  3346. scale: 90,
  3347. desc: "no effect"
  3348. }, {
  3349. id: 14,
  3350. name: "Thorns",
  3351. price: 10000,
  3352. scale: 115,
  3353. xOff: 20,
  3354. desc: "no effect"
  3355. }, {
  3356. id: 15,
  3357. name: "Blockades",
  3358. price: 10000,
  3359. scale: 95,
  3360. xOff: 15,
  3361. desc: "no effect"
  3362. }, {
  3363. id: 20,
  3364. name: "Devils Tail",
  3365. price: 10000,
  3366. scale: 95,
  3367. xOff: 20,
  3368. desc: "no effect"
  3369. }, {
  3370. id: 16,
  3371. name: "Sawblade",
  3372. price: 12000,
  3373. scale: 90,
  3374. spin: true,
  3375. xOff: 0,
  3376. desc: "deal damage to players that damage you",
  3377. dmg: 0.15
  3378. }, {
  3379. id: 13,
  3380. name: "Angel Wings",
  3381. price: 15000,
  3382. scale: 138,
  3383. xOff: 22,
  3384. desc: "slowly regenerates health over time",
  3385. healthRegen: 3
  3386. }, {
  3387. id: 19,
  3388. name: "Shadow Wings",
  3389. price: 15000,
  3390. scale: 138,
  3391. xOff: 22,
  3392. desc: "increased movement speed",
  3393. spdMult: 1.1
  3394. }, {
  3395. id: 18,
  3396. name: "Blood Wings",
  3397. price: 20000,
  3398. scale: 178,
  3399. xOff: 26,
  3400. desc: "restores health when you deal damage",
  3401. healD: 0.2
  3402. }, {
  3403. id: 21,
  3404. name: "Corrupt X Wings",
  3405. price: 20000,
  3406. scale: 178,
  3407. xOff: 26,
  3408. desc: "deal damage to players that damage you",
  3409. dmg: 0.25
  3410. }];
  3411. }
  3412. };
  3413. class ProjectileManager {
  3414. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3415. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3416. let tmpData = items.projectiles[indx];
  3417. let tmpProj;
  3418. for (let i = 0; i < projectiles.length; ++i) {
  3419. if (!projectiles[i].active) {
  3420. tmpProj = projectiles[i];
  3421. break;
  3422. }
  3423. }
  3424. if (!tmpProj) {
  3425. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3426. tmpProj.sid = projectiles.length;
  3427. projectiles.push(tmpProj);
  3428. }
  3429. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3430. tmpProj.ignoreObj = ignoreObj;
  3431. tmpProj.layer = layer || tmpData.layer;
  3432. tmpProj.inWindow = inWindow;
  3433. tmpProj.src = tmpData.src;
  3434. return tmpProj;
  3435. };
  3436. }
  3437. };
  3438. class AiManager {
  3439.  
  3440. // AI MANAGER:
  3441. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3442.  
  3443. // AI TYPES:
  3444. this.aiTypes = [{
  3445. id: 0,
  3446. src: "cow_1",
  3447. killScore: 150,
  3448. health: 500,
  3449. weightM: 0.8,
  3450. speed: 0.00095,
  3451. turnSpeed: 0.001,
  3452. scale: 72,
  3453. drop: ["food", 50]
  3454. }, {
  3455. id: 1,
  3456. src: "pig_1",
  3457. killScore: 200,
  3458. health: 800,
  3459. weightM: 0.6,
  3460. speed: 0.00085,
  3461. turnSpeed: 0.001,
  3462. scale: 72,
  3463. drop: ["food", 80]
  3464. }, {
  3465. id: 2,
  3466. name: "Bull",
  3467. src: "bull_2",
  3468. hostile: true,
  3469. dmg: 20,
  3470. killScore: 1000,
  3471. health: 1800,
  3472. weightM: 0.5,
  3473. speed: 0.00094,
  3474. turnSpeed: 0.00074,
  3475. scale: 78,
  3476. viewRange: 800,
  3477. chargePlayer: true,
  3478. drop: ["food", 100]
  3479. }, {
  3480. id: 3,
  3481. name: "Bully",
  3482. src: "bull_1",
  3483. hostile: true,
  3484. dmg: 20,
  3485. killScore: 2000,
  3486. health: 2800,
  3487. weightM: 0.45,
  3488. speed: 0.001,
  3489. turnSpeed: 0.0008,
  3490. scale: 90,
  3491. viewRange: 900,
  3492. chargePlayer: true,
  3493. drop: ["food", 400]
  3494. }, {
  3495. id: 4,
  3496. name: "Wolf",
  3497. src: "wolf_1",
  3498. hostile: true,
  3499. dmg: 8,
  3500. killScore: 500,
  3501. health: 300,
  3502. weightM: 0.45,
  3503. speed: 0.001,
  3504. turnSpeed: 0.002,
  3505. scale: 84,
  3506. viewRange: 800,
  3507. chargePlayer: true,
  3508. drop: ["food", 200]
  3509. }, {
  3510. id: 5,
  3511. name: "Quack",
  3512. src: "chicken_1",
  3513. dmg: 8,
  3514. killScore: 2000,
  3515. noTrap: true,
  3516. health: 300,
  3517. weightM: 0.2,
  3518. speed: 0.0018,
  3519. turnSpeed: 0.006,
  3520. scale: 70,
  3521. drop: ["food", 100]
  3522. }, {
  3523. id: 6,
  3524. name: "MOOSTAFA",
  3525. nameScale: 50,
  3526. src: "enemy",
  3527. hostile: true,
  3528. dontRun: true,
  3529. fixedSpawn: true,
  3530. spawnDelay: 60000,
  3531. noTrap: true,
  3532. colDmg: 100,
  3533. dmg: 40,
  3534. killScore: 8000,
  3535. health: 18000,
  3536. weightM: 0.4,
  3537. speed: 0.0007,
  3538. turnSpeed: 0.01,
  3539. scale: 80,
  3540. spriteMlt: 1.8,
  3541. leapForce: 0.9,
  3542. viewRange: 1000,
  3543. hitRange: 210,
  3544. hitDelay: 1000,
  3545. chargePlayer: true,
  3546. drop: ["food", 100]
  3547. }, {
  3548. id: 7,
  3549. name: "Treasure",
  3550. hostile: true,
  3551. nameScale: 35,
  3552. src: "crate_1",
  3553. fixedSpawn: true,
  3554. spawnDelay: 120000,
  3555. colDmg: 200,
  3556. killScore: 5000,
  3557. health: 20000,
  3558. weightM: 0.1,
  3559. speed: 0.0,
  3560. turnSpeed: 0.0,
  3561. scale: 70,
  3562. spriteMlt: 1.0
  3563. }, {
  3564. id: 8,
  3565. name: "MOOFIE",
  3566. src: "wolf_2",
  3567. hostile: true,
  3568. fixedSpawn: true,
  3569. dontRun: true,
  3570. hitScare: 4,
  3571. spawnDelay: 30000,
  3572. noTrap: true,
  3573. nameScale: 35,
  3574. dmg: 10,
  3575. colDmg: 100,
  3576. killScore: 3000,
  3577. health: 7000,
  3578. weightM: 0.45,
  3579. speed: 0.0015,
  3580. turnSpeed: 0.002,
  3581. scale: 90,
  3582. viewRange: 800,
  3583. chargePlayer: true,
  3584. drop: ["food", 1000]
  3585. }];
  3586.  
  3587. // SPAWN AI:
  3588. this.spawn = function(x, y, dir, index) {
  3589. let tmpObj = ais.find((tmp) => !tmp.active);
  3590. if (!tmpObj) {
  3591. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3592. ais.push(tmpObj);
  3593. }
  3594. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3595. return tmpObj;
  3596. };
  3597. }
  3598.  
  3599. };
  3600. class AI {
  3601. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3602. this.sid = sid;
  3603. this.isAI = true;
  3604. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3605.  
  3606. // INIT:
  3607. this.init = function(x, y, dir, index, data) {
  3608. this.x = x;
  3609. this.y = y;
  3610. this.startX = data.fixedSpawn ? x : null;
  3611. this.startY = data.fixedSpawn ? y : null;
  3612. this.xVel = 0;
  3613. this.yVel = 0;
  3614. this.zIndex = 0;
  3615. this.dir = dir;
  3616. this.dirPlus = 0;
  3617. this.showName = 'aaa';
  3618. this.index = index;
  3619. this.src = data.src;
  3620. if (data.name) this.name = data.name;
  3621. this.weightM = data.weightM;
  3622. this.speed = data.speed;
  3623. this.killScore = data.killScore;
  3624. this.turnSpeed = data.turnSpeed;
  3625. this.scale = data.scale;
  3626. this.maxHealth = data.health;
  3627. this.leapForce = data.leapForce;
  3628. this.health = this.maxHealth;
  3629. this.chargePlayer = data.chargePlayer;
  3630. this.viewRange = data.viewRange;
  3631. this.drop = data.drop;
  3632. this.dmg = data.dmg;
  3633. this.hostile = data.hostile;
  3634. this.dontRun = data.dontRun;
  3635. this.hitRange = data.hitRange;
  3636. this.hitDelay = data.hitDelay;
  3637. this.hitScare = data.hitScare;
  3638. this.spriteMlt = data.spriteMlt;
  3639. this.nameScale = data.nameScale;
  3640. this.colDmg = data.colDmg;
  3641. this.noTrap = data.noTrap;
  3642. this.spawnDelay = data.spawnDelay;
  3643. this.hitWait = 0;
  3644. this.waitCount = 1000;
  3645. this.moveCount = 0;
  3646. this.targetDir = 0;
  3647. this.active = true;
  3648. this.alive = true;
  3649. this.runFrom = null;
  3650. this.chargeTarget = null;
  3651. this.dmgOverTime = {};
  3652. };
  3653.  
  3654. let tmpRatio = 0;
  3655. let animIndex = 0;
  3656. this.animate = function(delta) {
  3657. if (this.animTime > 0) {
  3658. this.animTime -= delta;
  3659. if (this.animTime <= 0) {
  3660. this.animTime = 0;
  3661. this.dirPlus = 0;
  3662. tmpRatio = 0;
  3663. animIndex = 0;
  3664. } else {
  3665. if (animIndex == 0) {
  3666. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3667. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3668. if (tmpRatio >= 1) {
  3669. tmpRatio = 1;
  3670. animIndex = 1;
  3671. }
  3672. } else {
  3673. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3674. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3675. }
  3676. }
  3677. }
  3678. };
  3679.  
  3680. // ANIMATION:
  3681. this.startAnim = function() {
  3682. this.animTime = this.animSpeed = 600;
  3683. this.targetAngle = Math.PI * 0.8;
  3684. tmpRatio = 0;
  3685. animIndex = 0;
  3686. };
  3687.  
  3688. };
  3689.  
  3690. };
  3691. class addCh {
  3692. constructor(x, y, chat, tmpObj) {
  3693. this.x = x;
  3694. this.y = y;
  3695. this.alpha = 0;
  3696. this.active = true;
  3697. this.alive = false;
  3698. this.chat = chat;
  3699. this.owner = tmpObj;
  3700. };
  3701. };
  3702. class DeadPlayer {
  3703. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3704. this.x = x;
  3705. this.y = y;
  3706. this.lastDir = dir;
  3707. this.dir = dir + Math.PI;
  3708. this.buildIndex = buildIndex;
  3709. this.weaponIndex = weaponIndex;
  3710. this.weaponVariant = weaponVariant;
  3711. this.skinColor = skinColor;
  3712. this.scale = scale;
  3713. this.visScale = 0;
  3714. this.name = name;
  3715. this.alpha = 1;
  3716. this.active = true;
  3717. this.animate = function(delta) {
  3718. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3719. if (d2 > 0.01) {
  3720. this.dir += d2 / 20;
  3721. } else {
  3722. this.dir = this.lastDir;
  3723. }
  3724. if (this.visScale < this.scale) {
  3725. this.visScale += delta / (this.scale / 2);
  3726. if (this.visScale >= this.scale) {
  3727. this.visScale = this.scale;
  3728. }
  3729. }
  3730. this.alpha -= delta / 30000;
  3731. if (this.alpha <= 0) {
  3732. this.alpha = 0;
  3733. this.active = false;
  3734. }
  3735. }
  3736. }
  3737. };
  3738. class Player {
  3739. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3740. this.id = id;
  3741. this.sid = sid;
  3742. this.tmpScore = 0;
  3743. this.team = null;
  3744. this.latestSkin = 0;
  3745. this.oldSkinIndex = 0;
  3746. this.skinIndex = 0;
  3747. this.latestTail = 0;
  3748. this.oldTailIndex = 0;
  3749. this.tailIndex = 0;
  3750. this.hitTime = 0;
  3751. this.lastHit = 0;
  3752. this.showName = 'NOOO';
  3753. this.tails = {};
  3754. for (let i = 0; i < accessories.length; ++i) {
  3755. if (accessories[i].price <= 0)
  3756. this.tails[accessories[i].id] = 1;
  3757. }
  3758. this.skins = {};
  3759. for (let i = 0; i < hats.length; ++i) {
  3760. if (hats[i].price <= 0)
  3761. this.skins[hats[i].id] = 1;
  3762. }
  3763. this.points = 0;
  3764. this.dt = 0;
  3765. this.hidden = false;
  3766. this.itemCounts = {};
  3767. this.isPlayer = true;
  3768. this.pps = 0;
  3769. this.moveDir = undefined;
  3770. this.skinRot = 0;
  3771. this.lastPing = 0;
  3772. this.iconIndex = 0;
  3773. this.skinColor = 0;
  3774. this.dist2 = 0;
  3775. this.aim2 = 0;
  3776. this.maxSpeed = 1;
  3777. this.chat = {
  3778. message: null,
  3779. count: 0
  3780. };
  3781. this.circle = false;
  3782. this.cAngle = 0;
  3783. // SPAWN:
  3784. this.spawn = function(moofoll) {
  3785. this.attacked = false;
  3786. this.timeDamaged = 0;
  3787. this.timeHealed = 0;
  3788. this.pinge = 0;
  3789. this.millPlace = 'NOOO';
  3790. this.lastshamecount = 0;
  3791. this.death = false;
  3792. this.spinDir = 0;
  3793. this.sync = false;
  3794. this.antiBull = 0;
  3795. this.bullTimer = 0;
  3796. this.poisonTimer = 0;
  3797. this.active = true;
  3798. this.alive = true;
  3799. this.lockMove = false;
  3800. this.lockDir = false;
  3801. this.minimapCounter = 0;
  3802. this.chatCountdown = 0;
  3803. this.shameCount = 0;
  3804. this.shameTimer = 0;
  3805. this.sentTo = {};
  3806. this.gathering = 0;
  3807. this.gatherIndex = 0;
  3808. this.shooting = {};
  3809. this.shootIndex = 9;
  3810. this.autoGather = 0;
  3811. this.animTime = 0;
  3812. this.animSpeed = 0;
  3813. this.mouseState = 0;
  3814. this.buildIndex = -1;
  3815. this.weaponIndex = 0;
  3816. this.weaponCode = 0;
  3817. this.weaponVariant = 0;
  3818. this.primaryIndex = undefined;
  3819. this.secondaryIndex = undefined;
  3820. this.dmgOverTime = {};
  3821. this.noMovTimer = 0;
  3822. this.maxXP = 300;
  3823. this.XP = 0;
  3824. this.age = 1;
  3825. this.kills = 0;
  3826. this.upgrAge = 2;
  3827. this.upgradePoints = 0;
  3828. this.x = 0;
  3829. this.y = 0;
  3830. this.oldXY = {
  3831. x: 0,
  3832. y: 0
  3833. };
  3834. this.zIndex = 0;
  3835. this.xVel = 0;
  3836. this.yVel = 0;
  3837. this.slowMult = 1;
  3838. this.dir = 0;
  3839. this.dirPlus = 0;
  3840. this.targetDir = 0;
  3841. this.targetAngle = 0;
  3842. this.maxHealth = 100;
  3843. this.health = this.maxHealth;
  3844. this.oldHealth = this.maxHealth;
  3845. this.damaged = 0;
  3846. this.scale = config.playerScale;
  3847. this.speed = config.playerSpeed;
  3848. this.resetMoveDir();
  3849. this.resetResources(moofoll);
  3850. this.items = [0, 3, 6, 10];
  3851. this.weapons = [0];
  3852. this.shootCount = 0;
  3853. this.weaponXP = [];
  3854. this.reloads = {
  3855. 0: 0,
  3856. 1: 0,
  3857. 2: 0,
  3858. 3: 0,
  3859. 4: 0,
  3860. 5: 0,
  3861. 6: 0,
  3862. 7: 0,
  3863. 8: 0,
  3864. 9: 0,
  3865. 10: 0,
  3866. 11: 0,
  3867. 12: 0,
  3868. 13: 0,
  3869. 14: 0,
  3870. 15: 0,
  3871. 53: 0,
  3872. };
  3873. this.bowThreat = {
  3874. 9: 0,
  3875. 12: 0,
  3876. 13: 0,
  3877. 15: 0,
  3878. };
  3879. this.damageThreat = 0;
  3880. this.inTrap = false;
  3881. this.canEmpAnti = false;
  3882. this.empAnti = false;
  3883. this.soldierAnti = false;
  3884. this.poisonTick = 0;
  3885. this.bullTick = 0;
  3886. this.setPoisonTick = false;
  3887. this.setBullTick = false;
  3888. this.antiTimer = 2;
  3889. };
  3890.  
  3891. // RESET MOVE DIR:
  3892. this.resetMoveDir = function() {
  3893. this.moveDir = undefined;
  3894. };
  3895.  
  3896. // RESET RESOURCES:
  3897. this.resetResources = function(moofoll) {
  3898. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3899. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3900. }
  3901. };
  3902.  
  3903. // ADD ITEM:
  3904. this.getItemType = function(id) {
  3905. let findindx = this.items.findIndex((ids) => ids == id);
  3906. if (findindx != -1) {
  3907. return findindx;
  3908. } else {
  3909. return items.checkItem.index(id, this.items);
  3910. }
  3911. };
  3912.  
  3913. // SET DATA:
  3914. this.setData = function(data) {
  3915. this.id = data[0];
  3916. this.sid = data[1];
  3917. this.name = data[2];
  3918. this.x = data[3];
  3919. this.y = data[4];
  3920. this.dir = data[5];
  3921. this.health = data[6];
  3922. this.maxHealth = data[7];
  3923. this.scale = data[8];
  3924. this.skinColor = data[9];
  3925. };
  3926.  
  3927. // UPDATE POISON TICK:
  3928. this.updateTimer = function() {
  3929.  
  3930. this.bullTimer -= 1;
  3931. if (this.bullTimer <= 0) {
  3932. this.setBullTick = false;
  3933. this.bullTick = game.tick - 1;
  3934. this.bullTimer = config.serverUpdateRate;
  3935. }
  3936. this.poisonTimer -= 1;
  3937. if (this.poisonTimer <= 0) {
  3938. this.setPoisonTick = false;
  3939. this.poisonTick = game.tick - 1;
  3940. this.poisonTimer = config.serverUpdateRate;
  3941. }
  3942.  
  3943. };
  3944. this.update = function(delta) {
  3945. if (this.active) {
  3946.  
  3947. // MOVE:
  3948. let gear = {
  3949. skin: findID(hats, this.skinIndex),
  3950. tail: findID(accessories, this.tailIndex)
  3951. }
  3952. let spdMult = ((this.buildIndex >= 0) ? 0.5 : 1) * (items.weapons[this.weaponIndex].spdMult || 1) * (gear.skin ? (gear.skin.spdMult || 1) : 1) * (gear.tail ? (gear.tail.spdMult || 1) : 1) * (this.y <= config.snowBiomeTop ? ((gear.skin && gear.skin.coldM) ? 1 : config.snowSpeed) : 1) * this.slowMult;
  3953. this.maxSpeed = spdMult;
  3954.  
  3955. }
  3956. };
  3957.  
  3958. let tmpRatio = 0;
  3959. let animIndex = 0;
  3960. this.animate = function(delta) {
  3961. if (this.animTime > 0) {
  3962. this.animTime -= delta;
  3963. if (this.animTime <= 0) {
  3964. this.animTime = 0;
  3965. this.dirPlus = 0;
  3966. tmpRatio = 0;
  3967. animIndex = 0;
  3968. } else {
  3969. if (animIndex == 0) {
  3970. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3971. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3972. if (tmpRatio >= 1) {
  3973. tmpRatio = 1;
  3974. animIndex = 1;
  3975. }
  3976. } else {
  3977. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3978. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3979. }
  3980. }
  3981. }
  3982. };
  3983.  
  3984. // GATHER ANIMATION:
  3985. this.startAnim = function(didHit, index) {
  3986. this.animTime = this.animSpeed = items.weapons[index].speed;
  3987. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3988. tmpRatio = 0;
  3989. animIndex = 0;
  3990. };
  3991.  
  3992. // CAN SEE:
  3993. this.canSee = function(other) {
  3994. if (!other) return false;
  3995. let dx = Math.abs(other.x - this.x) - other.scale;
  3996. let dy = Math.abs(other.y - this.y) - other.scale;
  3997. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3998. };
  3999.  
  4000. // SHAME SYSTEM:
  4001. this.judgeShame = function() {
  4002. if (this.oldHealth < this.health) {
  4003. if (this.hitTime) {
  4004. let timeSinceHit = game.tick - this.hitTime;
  4005. this.lastHit = game.tick;
  4006. this.hitTime = 0;
  4007. if (timeSinceHit < 2) {
  4008. this.shameCount++;
  4009. } else {
  4010. this.shameCount = Math.max(0, this.shameCount - 2);
  4011. }
  4012. }
  4013. } else if (this.oldHealth > this.health) {
  4014. this.hitTime = game.tick;
  4015. }
  4016. };
  4017. this.addShameTimer = function() {
  4018. this.shameCount = 0;
  4019. this.shameTimer = 30;
  4020. let interval = setInterval(() => {
  4021. this.shameTimer--;
  4022. if (this.shameTimer <= 0) {
  4023. clearInterval(interval);
  4024. }
  4025. }, 1000);
  4026. };
  4027.  
  4028. // CHECK TEAM:
  4029. this.isTeam = function(tmpObj) {
  4030. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4031. };
  4032.  
  4033. // FOR THE PLAYER:
  4034. this.findAllianceBySid = function(sid) {
  4035. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4036. };
  4037. this.checkCanInsta = function(nobull) {
  4038. let totally = 0;
  4039. if (this.alive && inGame) {
  4040. let primary = {
  4041. weapon: this.weapons[0],
  4042. variant: this.primaryVariant,
  4043. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4044. };
  4045. let secondary = {
  4046. weapon: this.weapons[1],
  4047. variant: this.secondaryVariant,
  4048. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4049. };
  4050. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4051. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4052. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4053. totally += primary.dmg * pV * bull;
  4054. }
  4055. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4056. totally += secondary.dmg;
  4057. }
  4058. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4059. totally += 25;
  4060. }
  4061. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4062. return totally;
  4063. }
  4064. return 0;
  4065. };
  4066.  
  4067. // UPDATE WEAPON RELOAD:
  4068. this.manageReload = function() {
  4069. if (this.shooting[53]) {
  4070. this.shooting[53] = 0;
  4071. this.reloads[53] = (2500 - game.tickRate);
  4072. } else {
  4073. if (this.reloads[53] > 0) {
  4074. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4075. }
  4076. }
  4077.  
  4078. // PREPLACER
  4079. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4080. // place(2, getAttackDir());
  4081. let index = this.weaponIndex;
  4082. 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));
  4083. for(let i = 0; i < nearObja.length; i++) {
  4084. let aaa = nearObja[i];
  4085.  
  4086. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4087. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4088. if(aaa.health - (valaa) <= 0 && near.length) {
  4089. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4090. console.log("preplaced");
  4091. }
  4092. }
  4093. }
  4094.  
  4095. if (this.gathering || this.shooting[1]) {
  4096. if (this.gathering) {
  4097. this.gathering = 0;
  4098. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4099. this.attacked = true;
  4100. }
  4101. if (this.shooting[1]) {
  4102. this.shooting[1] = 0;
  4103. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4104. this.attacked = true;
  4105. }
  4106. } else {
  4107. this.attacked = false;
  4108. if (this.buildIndex < 0) {
  4109. if (this.reloads[this.weaponIndex] > 0) {
  4110. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4111. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4112. if (this == player) {
  4113. if (getEl("weaponGrind").checked) {
  4114. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4115. checkPlace(player.getItemType(22), i);
  4116. }
  4117. }
  4118. }
  4119. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4120. this.antiBull++;
  4121. game.tickBase(() => {
  4122. this.antiBull = 0;
  4123. }, 1);
  4124. }
  4125. }
  4126. }
  4127. }
  4128. };
  4129.  
  4130. // FOR ANTI INSTA:
  4131. this.addDamageThreat = function(tmpObj) {
  4132. let primary = {
  4133. weapon: this.primaryIndex,
  4134. variant: this.primaryVariant
  4135. };
  4136. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4137. let secondary = {
  4138. weapon: this.secondaryIndex,
  4139. variant: this.secondaryVariant
  4140. };
  4141. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4142. let bull = 1.5;
  4143. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4144. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4145. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4146. this.damageThreat += primary.dmg * pV * bull;
  4147. }
  4148. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4149. this.damageThreat += secondary.dmg * sV;
  4150. }
  4151. if (this.reloads[53] <= game.tickRate) {
  4152. this.damageThreat += 25;
  4153. }
  4154. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4155. if (!this.isTeam(tmpObj)) {
  4156. if (this.dist2 <= 300) {
  4157. tmpObj.damageThreat += this.damageThreat;
  4158. }
  4159. }
  4160. };
  4161.  
  4162. }
  4163. };
  4164.  
  4165. // SOME CODES:
  4166. function sendUpgrade(index) {
  4167. player.reloads[index] = 0;
  4168. packet("H", index);
  4169. }
  4170.  
  4171. function storeEquip(id, index) {
  4172. packet("c", 0, id, index);
  4173. }
  4174.  
  4175. function storeBuy(id, index) {
  4176. packet("c", 1, id, index);
  4177. }
  4178.  
  4179. function buyEquip(id, index) {
  4180. let nID = player.skins[6] ? 6 : 0;
  4181. if (player.alive && inGame) {
  4182. if (index == 0) {
  4183. if (player.skins[id]) {
  4184. if (player.latestSkin != id) {
  4185. packet("c", 0, id, 0);
  4186. }
  4187. } else {
  4188. if (configs.autoBuyEquip) {
  4189. let find = findID(hats, id);
  4190. if (find) {
  4191. if (player.points >= find.price) {
  4192. packet("c", 1, id, 0);
  4193. packet("c", 0, id, 0);
  4194. } else {
  4195. if (player.latestSkin != nID) {
  4196. packet("c", 0, nID, 0);
  4197. }
  4198. }
  4199. } else {
  4200. if (player.latestSkin != nID) {
  4201. packet("c", 0, nID, 0);
  4202. }
  4203. }
  4204. } else {
  4205. if (player.latestSkin != nID) {
  4206. packet("c", 0, nID, 0);
  4207. }
  4208. }
  4209. }
  4210. } else if (index == 1) {
  4211. if (useWasd && (id != 11 && id != 0)) {
  4212. if (player.latestTail != 0) {
  4213. packet("c", 0, 0, 1);
  4214. }
  4215. return;
  4216. }
  4217. if (player.tails[id]) {
  4218. if (player.latestTail != id) {
  4219. packet("c", 0, id, 1);
  4220. }
  4221. } else {
  4222. if (configs.autoBuyEquip) {
  4223. let find = findID(accessories, id);
  4224. if (find) {
  4225. if (player.points >= find.price) {
  4226. packet("c", 1, id, 1);
  4227. packet("c", 0, id, 1);
  4228. } else {
  4229. if (player.latestTail != 0) {
  4230. packet("c", 0, 0, 1);
  4231. }
  4232. }
  4233. } else {
  4234. if (player.latestTail != 0) {
  4235. packet("c", 0, 0, 1);
  4236. }
  4237. }
  4238. } else {
  4239. if (player.latestTail != 0) {
  4240. packet("c", 0, 0, 1);
  4241. }
  4242. }
  4243. }
  4244. }
  4245. }
  4246. }
  4247.  
  4248. function selectToBuild(index, wpn) {
  4249. packet("G", index, wpn);
  4250. }
  4251.  
  4252. function selectWeapon(index, isPlace) {
  4253. if (!isPlace) {
  4254. player.weaponCode = index;
  4255. }
  4256. packet("G", index, 1);
  4257. }
  4258.  
  4259. function sendAutoGather() {
  4260. packet("K", 1, 1);
  4261. }
  4262.  
  4263. function sendAtck(id, angle) {
  4264. packet("d", id, angle, 1);
  4265. }
  4266.  
  4267. // PLACER:
  4268. function place(id, rad, rmd) {
  4269. try {
  4270. if (id == undefined) return;
  4271. let item = items.list[player.items[id]];
  4272. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4273. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4274. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4275. 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))) {
  4276. selectToBuild(player.items[id]);
  4277. sendAtck(1, rad);
  4278. selectWeapon(player.weaponCode, 1);
  4279. if (rmd && getEl("placeVis").checked) {
  4280. placeVisible.push({
  4281. x: tmpX,
  4282. y: tmpY,
  4283. name: item.name,
  4284. scale: item.scale,
  4285. dir: rad
  4286. });
  4287. game.tickBase(() => {
  4288. placeVisible.shift();
  4289. }, 1)
  4290. }
  4291. }
  4292. } catch (e) {}
  4293. }
  4294.  
  4295. function checkPlace(id, rad) {
  4296. try {
  4297. if (id == undefined) return;
  4298. let item = items.list[player.items[id]];
  4299. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4300. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4301. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4302. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4303. place(id, rad, 1);
  4304. }
  4305. } catch (e) {}
  4306. }
  4307.  
  4308. // HEALING:
  4309. function soldierMult() {
  4310. return player.latestSkin == 6 ? 0.75 : 1;
  4311. }
  4312.  
  4313. function healthBased() {
  4314. if (player.health == 100)
  4315. return 0;
  4316. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4317. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4318. }
  4319. return 0;
  4320. }
  4321.  
  4322. function getAttacker(damaged) {
  4323. let attackers = enemy.filter(tmp => {
  4324. //let damages = new Damages(items);
  4325. //let dmg = damages.weapons[tmp.weaponIndex];
  4326. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4327. let rule = {
  4328. //one: tmp.dist2 <= 300,
  4329. //two: by.includes(damaged),
  4330. three: tmp.attacked
  4331. }
  4332. return /*rule.one && rule.two && */ rule.three;
  4333. });
  4334. return attackers;
  4335. }
  4336.  
  4337. function healer() {
  4338. for (let i = 0; i < healthBased(); i++) {
  4339. place(0, getAttackDir());
  4340. }
  4341. }
  4342.  
  4343. function antiSyncHealing(timearg) {
  4344. my.antiSync = true;
  4345. sendChat("");
  4346. let healAnti = setInterval(() => {
  4347. if (player.shameCount < 5) {
  4348. place(0, getAttackDir());
  4349. }
  4350. }, 75);
  4351. setTimeout(() => {
  4352. clearInterval(healAnti);
  4353. setTimeout(() => {
  4354. my.antiSync = false;
  4355. }, game.tickRate);
  4356. }, game.tickRate);
  4357. }
  4358. function applCxC(value) {
  4359. if (player.health == 100)
  4360. return 0;
  4361. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4362. return Math.ceil(value / items.list[player.items[0]].healing);
  4363. }
  4364. return 0;
  4365. }
  4366. function calcDmg(value) {
  4367. return value * player.skinIndex == 6 ? 0.75 : 1;
  4368. }
  4369. function biomeGear(mover, returns) {
  4370. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4371. if (returns) return 31;
  4372. buyEquip(31, 0);
  4373. } else {
  4374. if (player.y2 <= config.snowBiomeTop) {
  4375. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4376. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4377. } else {
  4378. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4379. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4380. }
  4381. }
  4382. if (returns) return 0;
  4383. }
  4384. let advHeal = [];
  4385.  
  4386. class Traps {
  4387. constructor(UTILS, items) {
  4388. this.dist = 0;
  4389. this.aim = 0;
  4390. this.inTrap = false;
  4391. this.replaced = false;
  4392. this.antiTrapped = false;
  4393. this.info = {};
  4394. this.notFast = function() {
  4395. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4396. }
  4397. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4398. try {
  4399. let item = items.list[player.items[id]];
  4400. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4401. let counts = {
  4402. attempts: 0,
  4403. placed: 0
  4404. };
  4405. let tmpObjects = [];
  4406. gameObjects.forEach((p) => {
  4407. tmpObjects.push({
  4408. x: p.x,
  4409. y: p.y,
  4410. active: p.active,
  4411. blocker: p.blocker,
  4412. scale: p.scale,
  4413. isItem: p.isItem,
  4414. type: p.type,
  4415. colDiv: p.colDiv,
  4416. getScale: function(sM, ig) {
  4417. sM = sM || 1;
  4418. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4419. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4420. },
  4421. });
  4422. });
  4423. for (let i = first; i < repeat; i += plus) {
  4424. counts.attempts++;
  4425. let relAim = radian + i;
  4426. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4427. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4428. 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)));
  4429. if (cantPlace) continue;
  4430. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4431. if ((!replacer && yaboi) || useWasd) {
  4432. if (useWasd ? false : yaboi.inTrap) {
  4433. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4434. place(2, relAim, 1);
  4435. } else {
  4436. player.items[4] == 15 && place(4, relAim, 1);
  4437. }
  4438. } else {
  4439. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  4440. place(2, relAim, 1);
  4441. } else {
  4442. player.items[4] == 15 && place(4, relAim, 1);
  4443. }
  4444. }
  4445. } else {
  4446. place(id, relAim, 1);
  4447. }
  4448. tmpObjects.push({
  4449. x: tmpX,
  4450. y: tmpY,
  4451. active: true,
  4452. blocker: item.blocker,
  4453. scale: item.scale,
  4454. isItem: true,
  4455. type: null,
  4456. colDiv: item.colDiv,
  4457. getScale: function() {
  4458. return this.scale;
  4459. },
  4460. });
  4461. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4462. counts.placed++;
  4463. }
  4464. }
  4465. if (counts.placed > 0 && replacer && item.dmg) {
  4466. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4467. instaC.canSpikeTick = true;
  4468. }
  4469. }
  4470. } catch (err) {
  4471. }
  4472. };
  4473.  
  4474. this.checkSpikeTick = function() {
  4475. try {
  4476. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4477. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4478. // more range for safe. also testing near.primaryIndex || 5
  4479. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4480. let item = items.list[9];
  4481. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4482. let danger = 0;
  4483. let counts = {
  4484. attempts: 0,
  4485. block: `unblocked`
  4486. };
  4487. for (let i = -1; i <= 1; i += 1 / 10) {
  4488. counts.attempts++;
  4489. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4490. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4491. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4492. 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)));
  4493. if (cantPlace) continue;
  4494. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4495. danger++;
  4496. counts.block = `blocked`;
  4497. break;
  4498. }
  4499. if (danger) {
  4500. my.anti0Tick = 1;
  4501. player.chat.count = 100000;
  4502. return true;
  4503. }
  4504. }
  4505. } catch (err) {
  4506. return null;
  4507. }
  4508. return false;
  4509. }
  4510. this.protect = function(aim) {
  4511. sendChat("");
  4512. if (!configs.antiTrap) return;
  4513. if (player.items[4]) {
  4514. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4515. this.antiTrapped = true;
  4516. }
  4517. };
  4518. /*this.autoPlace = function() {
  4519. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4520. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4521. if (gameObjects.length) {
  4522. let near2 = {
  4523. inTrap: false,
  4524. };
  4525. 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) {
  4526. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4527. })[0];
  4528. if (nearTrap) {
  4529. near2.inTrap = true;
  4530. } else {
  4531. near2.inTrap = false;
  4532. }
  4533. if ((near.dist3 <= 450)) {
  4534. if (near.dist3 <= 200) {
  4535. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4536. inTrap: near2.inTrap
  4537. });
  4538. } else {
  4539. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4540. }
  4541. }
  4542. } else {
  4543. if ((near.dist3 <= 450)) {
  4544. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4545. }
  4546. }
  4547. }
  4548. }
  4549. };*/
  4550. this.autoPlace = function () {
  4551. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4552. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  4553. if (gameObjects.length) {
  4554. let near2 = {
  4555. inTrap: true,
  4556. };
  4557. 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) {
  4558. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4559. })[0];
  4560. if (nearTrap) {
  4561. near2.inTrap = true;
  4562. } else {
  4563. near2.inTrap = true;
  4564. }
  4565. if ((near.dist2 <= 375)) {
  4566. if (near.dist2 <= 200) {
  4567. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4568. } else {
  4569. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4570. }
  4571. }
  4572. } else {
  4573. if ((near.dist2 <= 1000)) {
  4574. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4575. }
  4576. }
  4577. }
  4578. }
  4579. };
  4580. this.replacer = function (findObj) {
  4581. if (!findObj || !configs.autoReplace) return;
  4582. if (!inGame) return;
  4583. if (this.antiTrapped) return;
  4584. game.tickBase(() => {
  4585. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4586. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4587. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4588. if (objDst <= 400 && near.dist2 <= 400) {
  4589. let danger = this.checkSpikeTick();
  4590. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4591. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4592. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4593. } else {
  4594. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4595. }
  4596. this.replaced = true;
  4597. }
  4598. }, 1);
  4599. };
  4600. }
  4601. };
  4602. /* this.replacer = function(findObj) {
  4603. if (!findObj || !configs.autoReplace) return;
  4604. if (!inGame) return;
  4605. if (this.antiTrapped) return;
  4606.  
  4607. game.tickBase(() => {
  4608. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4609. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4610.  
  4611. let perfectAngle = calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y);
  4612.  
  4613. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4614.  
  4615. if (objDst <= 400 && near.dist2 <= 400) {
  4616. if (isObjectBroken(findObj)) {
  4617. let danger = this.checkSpikeTick();
  4618. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4619. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  4620. } else {
  4621. if (player.items[4] == 15) {
  4622. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  4623. }
  4624. }
  4625. this.replaced = true;
  4626. }
  4627. }
  4628. }, 1);
  4629. }
  4630. }
  4631. }*/
  4632.  
  4633. function calculatePerfectAngle(x1, y1, x2, y2) {
  4634. return Math.atan2(y2 - y1, x2 - x1);
  4635. }
  4636. function isObjectBroken(object) {
  4637. const healthThreshold = 20;
  4638. return object.health < healthThreshold;
  4639. }
  4640.  
  4641. /*this.replacer = function (findObj) {
  4642. if (!findObj || !configs.autoReplace) return;
  4643. if (!inGame) return;
  4644. if (this.antiTrapped) return;
  4645. game.tickBase(() => {
  4646. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4647. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4648. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4649. if (objDst <= 400 && near.dist2 <= 400) {
  4650. let danger = this.checkSpikeTick();
  4651. if (!danger && near.dist2 <= items.weapons[near.primaryIndex + 5].range + (near.scale * 1.8)) {
  4652. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4653. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4654. } else {
  4655. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4656. }
  4657. this.replaced = true;
  4658. }
  4659. }, 1);
  4660. };
  4661. }
  4662. }*/
  4663. class Instakill {
  4664. constructor() {
  4665. this.wait = false;
  4666. this.can = false;
  4667. this.isTrue = false;
  4668. this.nobull = false;
  4669. this.ticking = false;
  4670. this.canSpikeTick = false;
  4671. this.startTick = false;
  4672. this.readyTick = false;
  4673. this.canCounter = false;
  4674. this.revTick = false;
  4675. this.syncHit = false;
  4676. this.changeType = function(type) {
  4677. this.wait = false;
  4678. this.isTrue = true;
  4679. my.autoAim = true;
  4680. let instaLog = [type];
  4681. if (type == "rev") {
  4682. selectWeapon(player.weapons[1]);
  4683. buyEquip(53, 0);
  4684. sendAutoGather();
  4685. setTimeout(() => {
  4686. selectWeapon(player.weapons[0]);
  4687. buyEquip(7, 0);
  4688. setTimeout(() => {
  4689. sendAutoGather();
  4690. this.isTrue = false;
  4691. my.autoAim = false;
  4692. }, 225);
  4693. }, 100);
  4694. } else if (type == "nobull") {
  4695. selectWeapon(player.weapons[0]);
  4696. buyEquip(7, 0);
  4697. sendAutoGather();
  4698. setTimeout(() => {
  4699. selectWeapon(player.weapons[1]);
  4700. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4701. setTimeout(() => {
  4702. sendAutoGather();
  4703. this.isTrue = false;
  4704. my.autoAim = false;
  4705. }, 255);
  4706. }, 105);
  4707. } else if (type == "normal") {
  4708. selectWeapon(player.weapons[0]);
  4709. buyEquip(7, 0);
  4710. sendAutoGather();
  4711. setTimeout(() => {
  4712. selectWeapon(player.weapons[1]);
  4713. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4714. setTimeout(() => {
  4715. sendAutoGather();
  4716. this.isTrue = false;
  4717. my.autoAim = false;
  4718. }, 255);
  4719. }, 100);
  4720. } else {
  4721. setTimeout(() => {
  4722. this.isTrue = false;
  4723. my.autoAim = false;
  4724. }, 50);
  4725. }
  4726. };
  4727. this.spikeTickType = function() {
  4728. sendChat("GRIM REAPER");
  4729. this.isTrue = true;
  4730. my.autoAim = true;
  4731. selectWeapon(player.weapons[0]);
  4732. buyEquip(7, 0);
  4733. sendAutoGather();
  4734. game.tickBase(() => {
  4735. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4736. buyEquip(53, 0);
  4737. selectWeapon(player.weapons[0]);
  4738. buyEquip(53, 0);
  4739. //buyEquip(21, 1);
  4740. game.tickBase(() => {
  4741. sendAutoGather();
  4742. this.isTrue = false;
  4743. my.autoAim = false;
  4744. buyEquip(6, 0);
  4745. buyEquip(21, 1);
  4746. }, 3);
  4747. }, 1);
  4748. };
  4749. /* this.spikeTickType = function() {
  4750. this.isTrue = true;
  4751. my.autoAim = true;
  4752. selectWeapon(player.weapons[0]);
  4753. buyEquip(7, 0);
  4754. buyEquip(21, 1);
  4755. sendAutoGather();
  4756. game.tickBase(() => {
  4757. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4758. selectWeapon(player.weapons[0]);
  4759. buyEquip(53, 0);
  4760. buyEquip(21, 1);
  4761. game.tickBase(() => {
  4762. sendAutoGather();
  4763. this.isTrue = false;
  4764. my.autoAim = false;
  4765. }, 1);
  4766. } else {
  4767. sendAutoGather();
  4768. this.isTrue = false;
  4769. my.autoAim = false;
  4770. }
  4771. }, 1);
  4772. };*/
  4773. this.counterType = function() {
  4774. this.isTrue = true;
  4775. my.autoAim = true;
  4776. selectWeapon(player.weapons[0]);
  4777. buyEquip(7, 0);
  4778. buyEquip(21, 1);
  4779. sendAutoGather();
  4780. game.tickBase(() => {
  4781. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4782. selectWeapon(player.weapons[0]);
  4783. buyEquip(53, 0);
  4784. buyEquip(21, 1);
  4785. game.tickBase(() => {
  4786. sendAutoGather();
  4787. this.isTrue = false;
  4788. my.autoAim = false;
  4789. }, 1);
  4790. } else {
  4791. sendAutoGather();
  4792. this.isTrue = false;
  4793. my.autoAim = false;
  4794. }
  4795. }, 1);
  4796. };
  4797. this.antiCounterType = function() {
  4798. my.autoAim = true;
  4799. this.isTrue = true;
  4800. inantiantibull = true;
  4801. selectWeapon(player.weapons[0]);
  4802. buyEquip(6, 0);
  4803. buyEquip(21, 1);
  4804. io.send("D", near.aim2);
  4805. sendAutoGather();
  4806. game.tickBase(() => {
  4807. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  4808. buyEquip(21, 1);
  4809. game.tickBase(() => {
  4810. sendAutoGather();
  4811. this.isTrue = false;
  4812. my.autoAim = false;
  4813. inantiantibull = false;
  4814. }, 1);
  4815. }, 1)
  4816. };
  4817. this.rangeType = function(type) {
  4818. this.isTrue = true;
  4819. my.autoAim = true;
  4820. if (type == "ageInsta") {
  4821. sendChat("info gived");
  4822. my.ageInsta = false;
  4823. if (player.items[5] == 18) {
  4824. place(5, near.aim2);
  4825. }
  4826. packet("a", undefined, 1);
  4827. buyEquip(22, 0);
  4828. buyEquip(21, 1);
  4829. game.tickBase(() => {
  4830. selectWeapon(player.weapons[1]);
  4831. buyEquip(53, 0);
  4832. buyEquip(21, 1);
  4833. sendAutoGather();
  4834. game.tickBase(() => {
  4835. sendUpgrade(12);
  4836. selectWeapon(player.weapons[1]);
  4837. buyEquip(53, 0);
  4838. buyEquip(21, 1);
  4839. game.tickBase(() => {
  4840. sendUpgrade(15);
  4841. selectWeapon(player.weapons[1]);
  4842. buyEquip(53, 0);
  4843. buyEquip(21, 1);
  4844. game.tickBase(() => {
  4845. sendAutoGather();
  4846. this.isTrue = false;
  4847. my.autoAim = false;
  4848. }, 1);
  4849. }, 1);
  4850. }, 1);
  4851. }, 1);
  4852. } else {
  4853. selectWeapon(player.weapons[1]);
  4854. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4855. buyEquip(53, 0);
  4856. } else {
  4857. buyEquip(20, 0);
  4858. }
  4859. buyEquip(11, 1);
  4860. sendAutoGather();
  4861. game.tickBase(() => {
  4862. sendAutoGather();
  4863. this.isTrue = false;
  4864. my.autoAim = false;
  4865. }, 1);
  4866. }
  4867. };
  4868. this.oneTickType = function() {
  4869. io.send("7113213.29154");
  4870. this.isTrue = true;
  4871. my.autoAim = true;
  4872. selectWeapon(player.weapons[1]);
  4873. buyEquip(53, 0);
  4874. buyEquip(19, 1);
  4875. packet("a", near.aim2, 1);
  4876. if (player.weapons[1] == 15) {
  4877. my.revAim = true;
  4878. sendAutoGather();
  4879. }
  4880. game.tickBase(() => {
  4881. my.revAim = false;
  4882. selectWeapon(player.weapons[0]);
  4883. buyEquip(7, 0);
  4884. buyEquip(19, 1);
  4885. packet("a", near.aim2, 1);
  4886. if (player.weapons[1] != 15) {
  4887. sendAutoGather();
  4888. }
  4889. game.tickBase(() => {
  4890. sendAutoGather();
  4891. this.isTrue = false;
  4892. my.autoAim = false;
  4893. packet("a", undefined, 1);
  4894. }, 1);
  4895. }, 1);
  4896. };
  4897. this.threeOneTickType = function() {
  4898. io.send("Tick2");
  4899. this.isTrue = true;
  4900. my.autoAim = true;
  4901. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4902. biomeGear();
  4903. buyEquip(19, 1);
  4904. packet("a", near.aim2, 1);
  4905. game.tickBase(() => {
  4906. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4907. buyEquip(53, 0);
  4908. buyEquip(19, 1);
  4909. packet("a", near.aim2, 1);
  4910. game.tickBase(() => {
  4911. selectWeapon(player.weapons[0]);
  4912. buyEquip(7, 0);
  4913. buyEquip(19, 1);
  4914. sendAutoGather();
  4915. packet("a", near.aim2, 1);
  4916. game.tickBase(() => {
  4917. sendAutoGather();
  4918. this.isTrue = false;
  4919. my.autoAim = false;
  4920. packet("a", undefined, 1);
  4921. }, 1);
  4922. }, 1);
  4923. }, 1);
  4924. };
  4925. this.kmTickType = function() {
  4926. this.isTrue = true;
  4927. my.autoAim = true;
  4928. my.revAim = true;
  4929. selectWeapon(player.weapons[1]);
  4930. buyEquip(53, 0);
  4931. buyEquip(19, 1);
  4932. sendAutoGather();
  4933. packet("a", near.aim2, 1);
  4934. game.tickBase(() => {
  4935. my.revAim = false;
  4936. selectWeapon(player.weapons[0]);
  4937. buyEquip(7, 0);
  4938. buyEquip(19, 1);
  4939. packet("a", near.aim2, 1);
  4940. game.tickBase(() => {
  4941. sendAutoGather();
  4942. this.isTrue = false;
  4943. my.autoAim = false;
  4944. packet("a", undefined, 1);
  4945. }, 1);
  4946. }, 1);
  4947. };
  4948. this.boostTickType = function() {
  4949. /*this.isTrue = true;
  4950. my.autoAim = true;
  4951. selectWeapon(player.weapons[0]);
  4952. buyEquip(53, 0);
  4953. buyEquip(19, 1);
  4954. packet("a", near.aim2);
  4955. game.tickBase(() => {
  4956. place(4, near.aim2);
  4957. selectWeapon(player.weapons[1]);
  4958. biomeGear();
  4959. buyEquip(19, 1);
  4960. sendAutoGather();
  4961. packet("a", near.aim2);
  4962. game.tickBase(() => {
  4963. selectWeapon(player.weapons[0]);
  4964. buyEquip(7, 0);
  4965. buyEquip(19, 1);
  4966. packet("a", near.aim2);
  4967. game.tickBase(() => {
  4968. sendAutoGather();
  4969. this.isTrue = false;
  4970. my.autoAim = false;
  4971. packet("a", undefined);
  4972. }, 1);
  4973. }, 1);
  4974. }, 1);*/
  4975. this.isTrue = true;
  4976. my.autoAim = true;
  4977. biomeGear();
  4978. buyEquip(19, 1);
  4979. packet("a", near.aim2, 1);
  4980. game.tickBase(() => {
  4981. if (player.weapons[1] == 15) {
  4982. my.revAim = true;
  4983. }
  4984. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  4985. buyEquip(53, 0);
  4986. buyEquip(19, 1);
  4987. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  4988. sendAutoGather();
  4989. }
  4990. packet("a", near.aim2, 1);
  4991. place(4, near.aim2);
  4992. game.tickBase(() => {
  4993. my.revAim = false;
  4994. selectWeapon(player.weapons[0]);
  4995. buyEquip(7, 0);
  4996. buyEquip(19, 1);
  4997. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  4998. sendAutoGather();
  4999. }
  5000. packet("a", near.aim2, 1);
  5001. game.tickBase(() => {
  5002. sendAutoGather();
  5003. this.isTrue = false;
  5004. my.autoAim = false;
  5005. packet("a", undefined, 1);
  5006. }, 1);
  5007. }, 1);
  5008. }, 1);
  5009. };
  5010. this.gotoGoal = function(goto, OT) {
  5011. let slowDists = (weeeee) => weeeee * config.playerScale;
  5012. let goal = {
  5013. a: goto - OT,
  5014. b: goto + OT,
  5015. c: goto - slowDists(1),
  5016. d: goto + slowDists(1),
  5017. e: goto - slowDists(2),
  5018. f: goto + slowDists(2),
  5019. g: goto - slowDists(4),
  5020. h: goto + slowDists(4)
  5021. };
  5022. let bQ = function(wwww, awwww) {
  5023. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5024. buyEquip(31, 0);
  5025. } else {
  5026. buyEquip(wwww, awwww);
  5027. }
  5028. }
  5029. if (enemy.length) {
  5030. let dst = near.dist2;
  5031. this.ticking = true;
  5032. if (dst >= goal.a && dst <= goal.b) {
  5033. bQ(22, 0);
  5034. bQ(11, 1);
  5035. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5036. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5037. }
  5038. return {
  5039. dir: undefined,
  5040. action: 1
  5041. };
  5042. } else {
  5043. if (dst < goal.a) {
  5044. if (dst >= goal.g) {
  5045. if (dst >= goal.e) {
  5046. if (dst >= goal.c) {
  5047. bQ(40, 0);
  5048. bQ(10, 1);
  5049. if (configs.none) {
  5050. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5051. } else {
  5052. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5053. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5054. }
  5055. }
  5056. } else {
  5057. bQ(22, 0);
  5058. bQ(19, 1);
  5059. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5060. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5061. }
  5062. }
  5063. } else {
  5064. bQ(6, 0);
  5065. bQ(12, 1);
  5066. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5067. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5068. }
  5069. }
  5070. } else {
  5071. biomeGear();
  5072. bQ(11, 1);
  5073. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5074. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5075. }
  5076. }
  5077. return {
  5078. dir: near.aim2 + Math.PI,
  5079. action: 0
  5080. };
  5081. } else if (dst > goal.b) {
  5082. if (dst <= goal.h) {
  5083. if (dst <= goal.f) {
  5084. if (dst <= goal.d) {
  5085. bQ(40, 0);
  5086. bQ(9, 1);
  5087. if (configs.none) {
  5088. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5089. } else {
  5090. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5091. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5092. }
  5093. }
  5094. } else {
  5095. bQ(22, 0);
  5096. bQ(19, 1);
  5097. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5098. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5099. }
  5100. }
  5101. } else {
  5102. bQ(6, 0);
  5103. bQ(12, 1);
  5104. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5105. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5106. }
  5107. }
  5108. } else {
  5109. biomeGear();
  5110. bQ(11, 1);
  5111. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5112. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5113. }
  5114. }
  5115. return {
  5116. dir: near.aim2,
  5117. action: 0
  5118. };
  5119. }
  5120. return {
  5121. dir: undefined,
  5122. action: 0
  5123. };
  5124. }
  5125. } else {
  5126. this.ticking = false;
  5127. return {
  5128. dir: undefined,
  5129. action: 0
  5130. };
  5131. }
  5132. }
  5133. /** wait 1 tick for better quality */
  5134. this.bowMovement = function() {
  5135. let moveMent = this.gotoGoal(685, 3);
  5136. if (moveMent.action) {
  5137. if (player.reloads[53] == 0 && !this.isTrue) {
  5138. this.rangeType("ageInsta");
  5139. } else {
  5140. packet("a", moveMent.dir, 1);
  5141. }
  5142. } else {
  5143. packet("a", moveMent.dir, 1);
  5144. }
  5145. },
  5146. this.tickMovement = function() {
  5147. let dist = player.weapons[1] == 9 ? 240 : 240;
  5148. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5149. let moveMent = this.gotoGoal(238, 3);
  5150. if (moveMent.action) {
  5151. if (player.reloads[53] == 0 && !this.isTrue) {
  5152. this.boostTickType();
  5153. } else {
  5154. packet("a", moveMent.dir, 1);
  5155. }
  5156. } else {
  5157. packet("a", moveMent.dir, 1);
  5158. }
  5159. },
  5160. this.kmTickMovement = function() {
  5161. let moveMent = this.gotoGoal(240, 3);
  5162. if (moveMent.action) {
  5163. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5164. this.kmTickType();
  5165. } else {
  5166. packet("a", moveMent.dir, 1);
  5167. }
  5168. } else {
  5169. packet("a", moveMent.dir, 1);
  5170. }
  5171. },
  5172. this.boostTickMovement = function() {
  5173. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  5174. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5175. let moveMent = this.gotoGoal(372, 3);
  5176. if (moveMent.action) {
  5177. if (player.reloads[53] == 0 && !this.isTrue) {
  5178. this.boostTickType();
  5179. } else {
  5180. packet("a", moveMent.dir, 1);
  5181. }
  5182. } else {
  5183. packet("a", moveMent.dir, 1);
  5184. }
  5185. }
  5186. /** wait 1 tick for better quality */
  5187. this.perfCheck = function(pl, nr) {
  5188. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5189. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5190. let pjs = {
  5191. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5192. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5193. };
  5194. 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)) {
  5195. return true;
  5196. }
  5197. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5198. 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)) {
  5199. return true;
  5200. }
  5201. });
  5202. if (finds) return false;
  5203. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5204. let tmpScale = tmp.getScale();
  5205. 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)) {
  5206. return true;
  5207. }
  5208. });
  5209. if (finds) return false;
  5210. return true;
  5211. }
  5212. }
  5213. };
  5214. class Autobuy {
  5215. constructor(buyHat, buyAcc) {
  5216. this.hat = function() {
  5217. buyHat.forEach((id) => {
  5218. let find = findID(hats, id);
  5219. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5220. });
  5221. };
  5222. this.acc = function() {
  5223. buyAcc.forEach((id) => {
  5224. let find = findID(accessories, id);
  5225. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5226. });
  5227. };
  5228. }
  5229. };
  5230.  
  5231. class Autoupgrade {
  5232. constructor() {
  5233. this.sb = function(upg) {
  5234. upg(3);
  5235. upg(17);
  5236. upg(31);
  5237. upg(23);
  5238. upg(9);
  5239. upg(38);
  5240. };
  5241. this.kh = function(upg) {
  5242. upg(3);
  5243. upg(17);
  5244. upg(31);
  5245. upg(23);
  5246. upg(10);
  5247. upg(38);
  5248. upg(4);
  5249. upg(25);
  5250. };
  5251. this.pb = function(upg) {
  5252. upg(5);
  5253. upg(17);
  5254. upg(32);
  5255. upg(23);
  5256. upg(9);
  5257. upg(38);
  5258. };
  5259. this.ph = function(upg) {
  5260. upg(5);
  5261. upg(17);
  5262. upg(32);
  5263. upg(23);
  5264. upg(10);
  5265. upg(38);
  5266. upg(28);
  5267. upg(25);
  5268. };
  5269. this.db = function(upg) {
  5270. upg(7);
  5271. upg(17);
  5272. upg(31);
  5273. upg(23);
  5274. upg(9);
  5275. upg(34);
  5276. };
  5277. };
  5278. };
  5279.  
  5280. class Damages {
  5281. constructor(items) {
  5282. // 0.75 1 1.125 1.5
  5283. this.calcDmg = function(dmg, val) {
  5284. return dmg * val;
  5285. };
  5286. this.getAllDamage = function(dmg) {
  5287. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5288. };
  5289. this.weapons = [];
  5290. for (let i = 0; i < items.weapons.length; i++) {
  5291. let wp = items.weapons[i];
  5292. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5293. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5294. this[name] = this.weapons[i];
  5295. }
  5296. }
  5297. }
  5298.  
  5299. /** CLASS CODES */
  5300. // jumpscare code warn
  5301. let tmpList = [];
  5302. var bianosTick = false;
  5303.  
  5304.  
  5305. // LOADING:
  5306. let UTILS = new Utils();
  5307. let items = new Items();
  5308. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5309. let store = new Store();
  5310. let hats = store.hats;
  5311. let accessories = store.accessories;
  5312. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5313. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5314. let textManager = new Textmanager();
  5315.  
  5316. let traps = new Traps(UTILS, items);
  5317. let instaC = new Instakill();
  5318. let autoBuy = new Autobuy([6,7, 22, 12, 53, 40], [11 , 13, 19]);
  5319. let autoUpgrade = new Autoupgrade();
  5320.  
  5321. let lastDeath;
  5322. let minimapData;
  5323. let mapMarker = {};
  5324. let mapPings = [];
  5325. let tmpPing;
  5326.  
  5327. let breakTrackers = [];
  5328.  
  5329. let pathFindTest = 0;
  5330. let grid = [];
  5331. let pathFind = {
  5332. active: false,
  5333. grid: 40,
  5334. scale: 1440,
  5335. x: 14400,
  5336. y: 14400,
  5337. chaseNear: false,
  5338. array: [],
  5339. lastX: this.grid / 2,
  5340. lastY: this.grid / 2
  5341. };
  5342.  
  5343. function sendChat(message) {
  5344. packet("6", message.slice(0, 30));
  5345. }
  5346.  
  5347. let runAtNextTick = [];
  5348.  
  5349. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5350. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5351. let projOffset = config.playerScale * 2;
  5352. let projXY = {
  5353. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5354. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5355. };
  5356. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5357. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5358. })[0];
  5359. if (nearPlayer) {
  5360. if (indx == 1) {
  5361. nearPlayer.shooting[53] = 1;
  5362. } else {
  5363. nearPlayer.shootIndex = weaponIndx;
  5364. nearPlayer.shooting[1] = 1;
  5365. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5366. }
  5367. }
  5368. }
  5369. let projectileCount = 0;
  5370.  
  5371. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5372. if (!tmpObj.isTeam(player)) {
  5373. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5374. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5375. tmpObj.bowThreat[weaponIndex]++;
  5376. if (index == 5) {
  5377. projectileCount++;
  5378. }
  5379. setTimeout(() => {
  5380. tmpObj.bowThreat[weaponIndex]--;
  5381. if (index == 5) {
  5382. projectileCount--;
  5383. }
  5384. }, range / speed);
  5385. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5386. place(1, tmpObj.aim2);
  5387. my.anti0Tick = 4;
  5388. if (!my.antiSync) {
  5389. antiSyncHealing(4);
  5390. }
  5391. } else {
  5392. if (projectileCount >= 2) {
  5393. place(1, tmpObj.aim2);
  5394. my.anti0Tick = 4;
  5395. if (!my.antiSync) {
  5396. antiSyncHealing(4);
  5397. }
  5398. }
  5399. }
  5400. }
  5401. }
  5402. }
  5403.  
  5404. // SHOW ITEM INFO:
  5405. function showItemInfo(item, isWeapon, isStoreItem) {
  5406. if (player && item) {
  5407. UTILS.removeAllChildren(itemInfoHolder);
  5408. itemInfoHolder.classList.add("visible");
  5409. UTILS.generateElement({
  5410. id: "itemInfoName",
  5411. text: UTILS.capitalizeFirst(item.name),
  5412. parent: itemInfoHolder
  5413. });
  5414. UTILS.generateElement({
  5415. id: "itemInfoDesc",
  5416. text: item.desc,
  5417. parent: itemInfoHolder
  5418. });
  5419. if (isStoreItem) {
  5420.  
  5421. } else if (isWeapon) {
  5422. UTILS.generateElement({
  5423. class: "itemInfoReq",
  5424. text: !item.type ? "primary" : "secondary",
  5425. parent: itemInfoHolder
  5426. });
  5427. } else {
  5428. for (let i = 0; i < item.req.length; i += 2) {
  5429. UTILS.generateElement({
  5430. class: "itemInfoReq",
  5431. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5432. parent: itemInfoHolder
  5433. });
  5434. }
  5435. if (item.group.limit) {
  5436. UTILS.generateElement({
  5437. class: "itemInfoLmt",
  5438. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5439. parent: itemInfoHolder
  5440. });
  5441. }
  5442. }
  5443. } else {
  5444. itemInfoHolder.classList.remove("visible");
  5445. }
  5446. }
  5447.  
  5448.  
  5449. // RESIZE:
  5450. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5451.  
  5452. function resize() {
  5453. screenWidth = window.innerWidth;
  5454. screenHeight = window.innerHeight;
  5455. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5456. gameCanvas.width = screenWidth * pixelDensity;
  5457. gameCanvas.height = screenHeight * pixelDensity;
  5458. gameCanvas.style.width = screenWidth + "px";
  5459. gameCanvas.style.height = screenHeight + "px";
  5460. mainContext.setTransform(
  5461. scaleFillNative, 0,
  5462. 0, scaleFillNative,
  5463. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5464. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5465. );
  5466. }
  5467. resize();
  5468.  
  5469. // MOUSE INPUT:
  5470. var usingTouch;
  5471. const mals = document.getElementById('touch-controls-fullscreen');
  5472. mals.style.display = 'block';
  5473. mals.addEventListener("mousemove", gameInput, false);
  5474.  
  5475. function gameInput(e) {
  5476. mouseX = e.clientX;
  5477. mouseY = e.clientY;
  5478. }
  5479. let clicks = {
  5480. left: false,
  5481. middle: false,
  5482. right: false,
  5483. };
  5484. let clicked = {
  5485. g: false
  5486. }
  5487. mals.addEventListener("mousedown", mouseDown, false);
  5488.  
  5489. function mouseDown(e) {
  5490. if (attackState != 1) {
  5491. attackState = 1;
  5492. if (e.button == 0) {
  5493. clicks.left = true;
  5494. } else if (e.button == 2) {
  5495. clicks.right = true;
  5496. }
  5497. }
  5498. }
  5499. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5500.  
  5501. function mouseUp(e) {
  5502. if (attackState != 0) {
  5503. attackState = 0;
  5504. if (e.button == 0) {
  5505. clicks.left = false;
  5506. } else if (e.button == 1) {
  5507. clicks.middle = false;
  5508. } else if (e.button == 2) {
  5509. clicks.right = false;
  5510. }
  5511. }
  5512. }
  5513. mals.addEventListener("wheel", wheel, false);
  5514.  
  5515. function wheel(e) {
  5516. if (e.deltaY < 0) {
  5517. wbe += 0.005
  5518. maxScreenWidth = config.maxScreenWidth * wbe;
  5519. maxScreenHeight = config.maxScreenHeight * wbe;
  5520. resize()
  5521. } else {
  5522. wbe -= 0.005
  5523. maxScreenWidth = config.maxScreenWidth * wbe;
  5524. maxScreenHeight = config.maxScreenHeight * wbe;
  5525. resize()
  5526. }
  5527. }
  5528.  
  5529. // INPUT UTILS:
  5530. function getMoveDir() {
  5531. let dx = 0;
  5532. let dy = 0;
  5533. for (let key in moveKeys) {
  5534. let tmpDir = moveKeys[key];
  5535. dx += !!keys[key] * tmpDir[0];
  5536. dy += !!keys[key] * tmpDir[1];
  5537. }
  5538. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5539. }
  5540.  
  5541. function getSafeDir() {
  5542. if (!player)
  5543. return 0;
  5544. if (!player.lockDir) {
  5545. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5546. }
  5547. return lastDir || 0;
  5548. }
  5549. let plusDir = 0;
  5550. let lastSpin = Date.now();
  5551. function getAttackDir(debug) {
  5552. if (debug) {
  5553. if (!player)
  5554. return "0";
  5555. 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))
  5556. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  5557. else
  5558. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5559. lastDir = "getSafeDir()";
  5560. else
  5561. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5562. lastDir = "traps.aim";
  5563. else
  5564. if (!player.lockDir) {
  5565. if (configs.noDir) return "undefined";
  5566. lastDir = "getSafeDir()";
  5567. }
  5568. return lastDir;
  5569. } else {
  5570. if (!player)
  5571. return 0;
  5572. 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))
  5573. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5574. else
  5575. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5576. lastDir = getSafeDir();
  5577. else
  5578. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5579. lastDir = traps.aim;
  5580. else
  5581. if (!player.lockDir) {
  5582. if (configs.noDir) return undefined;
  5583. lastDir = getSafeDir();
  5584. }
  5585. return lastDir || 0;
  5586. }
  5587. }
  5588.  
  5589. function getVisualDir() {
  5590. if (!player)
  5591. return 0;
  5592. lastDir = getSafeDir();
  5593. return lastDir || 0;
  5594. }
  5595.  
  5596. // KEYS:
  5597. function keysActive() {
  5598. return (allianceMenu.style.display != "block" &&
  5599. chatHolder.style.display != "block" &&
  5600. !menuCBFocus);
  5601. }
  5602.  
  5603. function toggleMenuChat() {
  5604. if (menuChatDiv.style.display != "none") {
  5605. // chatHolder.style.display = "none";
  5606. // if (menuChatBox.value != "") {
  5607. //commands[command.slice(1)]
  5608. let cmd = function(command) {
  5609. return {
  5610. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5611. fv: commands[command.slice(1).split(" ")[0]]
  5612. }
  5613. }
  5614. let command = cmd(menuChatBox.value);
  5615. if (command.found) {
  5616. if (typeof command.fv.action === "function") {
  5617. command.fv.action(menuChatBox.value);
  5618. }
  5619. } else {
  5620. sendChat(menuChatBox.value);
  5621. }
  5622. menuChatBox.value = "";
  5623. menuChatBox.blur();
  5624. } else {
  5625. if (menuCBFocus) {
  5626. menuChatBox.blur();
  5627. } else {
  5628. menuChatBox.focus();
  5629. }
  5630. }
  5631. }
  5632.  
  5633. function keyDown(event) {
  5634. let keyNum = event.which || event.keyCode || 0;
  5635. if (player && player.alive && keysActive()) {
  5636. if (!keys[keyNum]) {
  5637. keys[keyNum] = 1;
  5638. macro[event.key] = 1;
  5639. if (keyNum == 27) {
  5640. openMenu = !openMenu;
  5641. $("#menuDiv").toggle();
  5642. } else if (keyNum == 69) {
  5643. sendAutoGather();
  5644. } else if (keyNum == 67) {
  5645. updateMapMarker();
  5646. } else if (keyNum == 71) {
  5647. clicked.g = !clicked.g
  5648. } else if (player.weapons[keyNum - 49] != undefined) {
  5649. player.weaponCode = player.weapons[keyNum - 49];
  5650. } else if (moveKeys[keyNum]) {
  5651. sendMoveDir();
  5652. } else if (event.key == "m") {
  5653. mills.placeSpawnPads = !mills.placeSpawnPads;
  5654. } else if (event.key == "z") {
  5655. mills.place = !mills.place;
  5656. } else if (event.key == "Z") {
  5657. typeof window.debug == "function" && window.debug();
  5658. } else if (keyNum == 32) {
  5659. packet("d", 1, getSafeDir(), 1);
  5660. packet("d", 0, getSafeDir(), 1);
  5661. }
  5662. }
  5663. }
  5664. }
  5665. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5666.  
  5667. function keyUp(event) {
  5668. if (player && player.alive) {
  5669. let keyNum = event.which || event.keyCode || 0;
  5670. if (keyNum == 13) {
  5671. toggleMenuChat();
  5672. } else if (keysActive()) {
  5673. if (keys[keyNum]) {
  5674. keys[keyNum] = 0;
  5675. macro[event.key] = 0;
  5676. if (moveKeys[keyNum]) {
  5677. sendMoveDir();
  5678. }
  5679. }
  5680. }
  5681. }
  5682. }
  5683. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5684.  
  5685. function sendMoveDir() {
  5686. let newMoveDir = getMoveDir();
  5687. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5688. if (!my.autoPush) {
  5689. packet("a", newMoveDir, 1);
  5690. }
  5691. lastMoveDir = newMoveDir;
  5692. }
  5693. }
  5694.  
  5695. // BUTTON EVENTS:
  5696. function bindEvents() {}
  5697. bindEvents();
  5698.  
  5699. /** PATHFIND TEST */
  5700. function chechPathColl(tmp) {
  5701. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  5702. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  5703. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  5704. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  5705. }
  5706.  
  5707. function checkObject() {
  5708. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  5709. for (let y = 0; y < pathFind.grid; y++) {
  5710. grid[y] = [];
  5711. for (let x = 0; x < pathFind.grid; x++) {
  5712. let tmpXY = {
  5713. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  5714. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  5715. }
  5716. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  5717. pathFind.lastX = x;
  5718. pathFind.lastY = y;
  5719. grid[y][x] = 0;
  5720. continue;
  5721. }
  5722. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  5723. if (find) {
  5724. if (find.trap) {
  5725. grid[y][x] = 0;
  5726. continue;
  5727. }
  5728. grid[y][x] = 1;
  5729. } else {
  5730. grid[y][x] = 0;
  5731. }
  5732. }
  5733. }
  5734. }
  5735.  
  5736. function createPath() {
  5737. grid = [];
  5738. checkObject();
  5739. }
  5740.  
  5741. function Pathfinder() {
  5742. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  5743. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  5744. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5745. packet("a", undefined, 1);
  5746. } else {
  5747. createPath();
  5748. easystar.setGrid(grid);
  5749. easystar.setAcceptableTiles([0]);
  5750. easystar.enableDiagonals();
  5751. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  5752. if (path === null) {
  5753. pathFind.array = [];
  5754. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5755. packet("a", undefined, 1);
  5756. } else {
  5757. packet("a", near.aim2, 1);
  5758. }
  5759. } else {
  5760. pathFind.array = path;
  5761. if (pathFind.array.length > 1) {
  5762. let tmpXY = {
  5763. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  5764. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  5765. }
  5766. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  5767. }
  5768. }
  5769. });
  5770. easystar.calculate();
  5771. }
  5772. }
  5773. }
  5774. /** PATHFIND TEST */
  5775.  
  5776. // ITEM COUNT DISPLAY:
  5777. let isItemSetted = [];
  5778.  
  5779. function updateItemCountDisplay(index = undefined) {
  5780. for (let i = 3; i < items.list.length; ++i) {
  5781. let id = items.list[i].group.id;
  5782. let tmpI = items.weapons.length + i;
  5783. if (!isItemSetted[tmpI]) {
  5784. isItemSetted[tmpI] = document.createElement("div");
  5785. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5786. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5787. isItemSetted[tmpI].style = `
  5788. display: block;
  5789. position: absolute;
  5790. padding-left: 5px;
  5791. font-size: 2em;
  5792. color: #fff;
  5793. `;
  5794. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5795. } else {
  5796. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5797. }
  5798. }
  5799. }
  5800.  
  5801. // AUTOPUSH:
  5802. function autoPush() {
  5803. 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) {
  5804. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5805. })[0];
  5806. if (nearTrap) {
  5807. 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) {
  5808. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5809. })[0];
  5810. if (spike) {
  5811. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  5812.  
  5813. /*let pos = {
  5814. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5815. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5816. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  5817. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  5818. };
  5819. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  5820. let tmpScale = tmp.getScale();
  5821. 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)) {
  5822. return true;
  5823. }
  5824. });
  5825. if (finds) {
  5826. if (my.autoPush) {
  5827. my.autoPush = false;
  5828. packet("a", lastMoveDir || undefined, 1);
  5829. }
  5830. } else {*/
  5831. my.autoPush = true;
  5832. sendChat("pulling to underworld!");
  5833. my.pushData = {
  5834. x: spike.x + Math.cos(pushAngle),
  5835. y: spike.y + Math.sin(pushAngle),
  5836. x2: player.x2+30,
  5837. y2: player.y2+30
  5838. };
  5839.  
  5840. let point = {
  5841. x: near.x2 + Math.cos(pushAngle) * 30,
  5842. y: near.y2 + Math.sin(pushAngle) * 60,
  5843. }
  5844.  
  5845. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  5846.  
  5847. packet("a", dir, 1)
  5848. /*let scale = (player.scale / 10);
  5849. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5850. packet("a", near.aim2, 1);
  5851. } else {
  5852. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  5853. }*/
  5854. //}
  5855. } else {
  5856. if (my.autoPush) {
  5857. my.autoPush = false;
  5858. packet("a", lastMoveDir || undefined, 1);
  5859. }
  5860. }
  5861. } else {
  5862. if (my.autoPush) {
  5863. my.autoPush = false;
  5864. packet("a", lastMoveDir || undefined, 1);
  5865. }
  5866. }
  5867. }
  5868.  
  5869.  
  5870. class AutoPush {
  5871. socket = null;
  5872.  
  5873. findIntersect(vec, vec1, vec2) {
  5874. // Find point of vec1 and vec2 intersection
  5875. const delta = Math.hypot(vec1.x - vec2.x, vec1.y - vec2.y) / 2;
  5876. const tang = Math.tan((vec1.y - vec2.y) / (vec1.x - vec2.x));
  5877. const vec3x = Math.cos(tang) * delta;
  5878. const vec3y = Math.sin(tang) * delta;
  5879. // Find angle from vec to vec3
  5880. const theta = Math.tan((vec.y - vec3y) / (vec.x - vec3x));
  5881.  
  5882. return theta;
  5883. };
  5884.  
  5885. pushEnemy(player, enemy, spike) {
  5886. const angle = this.findIntersect(enemy, spike, player);
  5887. const dist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
  5888.  
  5889. if (dist > 180) return;
  5890.  
  5891. this.socket.send("a", angle);
  5892. };
  5893.  
  5894. constructor(socket) {
  5895. this.socket = socket;
  5896. }
  5897. }
  5898.  
  5899. // ADD DEAD PLAYER:
  5900. function addDeadPlayer(tmpObj) {
  5901. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  5902. }
  5903.  
  5904. /** APPLY SOCKET CODES */
  5905.  
  5906. // SET INIT DATA:
  5907. function setInitData(data) {
  5908. alliances = data.teams;
  5909. }
  5910.  
  5911. // SETUP GAME:
  5912. function setupGame(yourSID) {
  5913. keys = {};
  5914. macro = {};
  5915. playerSID = yourSID;
  5916. attackState = 0;
  5917. inGame = true;
  5918. packet("d", 0, getAttackDir(), 1);
  5919. my.ageInsta = true;
  5920. if (firstSetup) {
  5921. firstSetup = false;
  5922. gameObjects.length = 0;
  5923. liztobj.length = 0;
  5924. }
  5925. }
  5926.  
  5927. // ADD NEW PLAYER:
  5928. function addPlayer(data, isYou) {
  5929. let tmpPlayer = findPlayerByID(data[0]);
  5930. if (!tmpPlayer) {
  5931. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  5932. objectManager, players, ais, items, hats, accessories);
  5933. players.push(tmpPlayer);
  5934. if (data[1] != playerSID) {
  5935. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5936. }
  5937. } else {
  5938. if (data[1] != playerSID) {
  5939. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  5940. }
  5941. }
  5942. tmpPlayer.spawn(isYou ? true : null);
  5943. tmpPlayer.visible = false;
  5944. tmpPlayer.oldPos = {
  5945. x2: undefined,
  5946. y2: undefined
  5947. };
  5948. tmpPlayer.x2 = undefined;
  5949. tmpPlayer.y2 = undefined;
  5950. tmpPlayer.x3 = undefined;
  5951. tmpPlayer.y3 = undefined;
  5952. tmpPlayer.setData(data);
  5953. if (isYou) {
  5954. if (!player) {
  5955. window.prepareUI(tmpPlayer);
  5956. }
  5957. player = tmpPlayer;
  5958. camX = player.x;
  5959. camY = player.y;
  5960. my.lastDir = 0;
  5961. updateItems();
  5962. updateAge();
  5963. updateItemCountDisplay();
  5964. if (player.skins[7]) {
  5965. my.reSync = true;
  5966. }
  5967. }
  5968. }
  5969.  
  5970. // REMOVE PLAYER:
  5971. function removePlayer(id) {
  5972. for (let i = 0; i < players.length; i++) {
  5973. if (players[i].id == id) {
  5974. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  5975. players.splice(i, 1);
  5976. break;
  5977. }
  5978. }
  5979. }
  5980.  
  5981. // UPDATE HEALTH:
  5982. function updateHealth(sid, value) {
  5983. tmpObj = findPlayerBySID(sid);
  5984. if (tmpObj) {
  5985. tmpObj.oldHealth = tmpObj.health;
  5986. tmpObj.health = value;
  5987. tmpObj.judgeShame();
  5988. if (tmpObj.oldHealth > tmpObj.health) {
  5989. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  5990. advHeal.push([sid, value, tmpObj.damaged]);
  5991. } else {}
  5992. if (tmpObj.health <= 0) {
  5993. /*bots.forEach((hmm) => {
  5994. hmm.whyDie = tmpObj.name;
  5995. });*/
  5996. }
  5997. }
  5998. }
  5999.  
  6000.  
  6001. // KILL PLAYER:
  6002. function killPlayer() {
  6003. inGame = false;
  6004. lastDeath = {
  6005. x: player.x,
  6006. y: player.y,
  6007. };
  6008. if (configs.autoRespawn) {
  6009. getEl("diedText").style.display = "none";
  6010. packet("M", {
  6011. name: lastsp[0],
  6012. moofoll: lastsp[1],
  6013. skin: lastsp[2]
  6014. });
  6015. }
  6016. }
  6017.  
  6018. // UPDATE PLAYER ITEM VALUES:
  6019. function updateItemCounts(index, value) {
  6020. if (player) {
  6021. player.itemCounts[index] = value;
  6022. updateItemCountDisplay(index);
  6023. }
  6024. }
  6025.  
  6026. // UPDATE AGE:
  6027. function updateAge(xp, mxp, age) {
  6028. if (xp != undefined)
  6029. player.XP = xp;
  6030. if (mxp != undefined)
  6031. player.maxXP = mxp;
  6032. if (age != undefined)
  6033. player.age = age;
  6034. }
  6035.  
  6036. // UPDATE UPGRADES:
  6037. function updateUpgrades(points, age) {
  6038. player.upgradePoints = points;
  6039. player.upgrAge = age;
  6040. if (points > 0) {
  6041. tmpList.length = 0;
  6042. UTILS.removeAllChildren(upgradeHolder);
  6043. for (let i = 0; i < items.weapons.length; ++i) {
  6044. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6045. let e = UTILS.generateElement({
  6046. id: "upgradeItem" + i,
  6047. class: "actionBarItem",
  6048. onmouseout: function() {
  6049. showItemInfo();
  6050. },
  6051. parent: upgradeHolder
  6052. });
  6053. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6054. tmpList.push(i);
  6055. }
  6056. }
  6057. for (let i = 0; i < items.list.length; ++i) {
  6058. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6059. let tmpI = (items.weapons.length + i);
  6060. let e = UTILS.generateElement({
  6061. id: "upgradeItem" + tmpI,
  6062. class: "actionBarItem",
  6063. onmouseout: function() {
  6064. showItemInfo();
  6065. },
  6066. parent: upgradeHolder
  6067. });
  6068. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6069. tmpList.push(tmpI);
  6070. }
  6071. }
  6072. for (let i = 0; i < tmpList.length; i++) {
  6073. (function(i) {
  6074. let tmpItem = getEl('upgradeItem' + i);
  6075. // tmpItem.onmouseover = function() {
  6076. // if (items.weapons[i]) {
  6077. // showItemInfo(items.weapons[i], true);
  6078. // } else {
  6079. // showItemInfo(items.list[i - items.weapons.length]);
  6080. // }
  6081. // };
  6082. tmpItem.onclick = UTILS.checkTrusted(function() {
  6083. packet("H", i);
  6084. });
  6085. UTILS.hookTouchEvents(tmpItem);
  6086. })(tmpList[i]);
  6087. }
  6088. if (tmpList.length) {
  6089. upgradeHolder.style.display = "block";
  6090. upgradeCounter.style.display = "block";
  6091. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6092. } else {
  6093. upgradeHolder.style.display = "none";
  6094. upgradeCounter.style.display = "none";
  6095. showItemInfo();
  6096. }
  6097. } else {
  6098. upgradeHolder.style.display = "none";
  6099. upgradeCounter.style.display = "none";
  6100. showItemInfo();
  6101. }
  6102. }
  6103.  
  6104. // KILL OBJECT:
  6105. function killObject(sid) {
  6106. let findObj = findObjectBySid(sid);
  6107. objectManager.disableBySid(sid);
  6108. if (player) {
  6109. for (let i = 0; i < breakObjects.length; i++) {
  6110. if (breakObjects[i].sid == sid) {
  6111. breakObjects.splice(i, 1);
  6112. break;
  6113. }
  6114. }
  6115. if (!player.canSee(findObj)) {
  6116. breakTrackers.push({
  6117. x: findObj.x,
  6118. y: findObj.y
  6119. });
  6120. }
  6121. if (breakTrackers.length > 8) {
  6122. breakTrackers.shift();
  6123. }
  6124. traps.replacer(findObj);
  6125. }
  6126. }
  6127.  
  6128. // KILL ALL OBJECTS BY A PLAYER:
  6129. function killObjects(sid) {
  6130. if (player) objectManager.removeAllItems(sid);
  6131. }
  6132. function setTickout(doo, timeout) {
  6133. if (!ticks.manage[ticks.tick + timeout]) {
  6134. ticks.manage[ticks.tick + timeout] = [doo];
  6135. } else {
  6136. ticks.manage[ticks.tick + timeout].push(doo);
  6137. }
  6138. }
  6139.  
  6140. function caf(e, t) {
  6141. try {
  6142. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6143. } catch (e) {
  6144. return 0;
  6145. }
  6146. }
  6147.  
  6148. let found = false;
  6149. let autoQ = false;
  6150.  
  6151. let autos = {
  6152. insta: {
  6153. todo: false,
  6154. wait: false,
  6155. count: 4,
  6156. shame: 5
  6157. },
  6158. bull: false,
  6159. antibull: 0,
  6160. reloaded: false,
  6161. stopspin: true
  6162. }
  6163.  
  6164. // UPDATE PLAYER DATA:
  6165. function updatePlayers(data) {
  6166. // if(player.shameCount > 0) {
  6167. // my.reSync = true;
  6168. // } else {
  6169. // my.reSync = false;
  6170. // }
  6171.  
  6172. // let movementPrediction = {
  6173. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6174. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6175. // }
  6176.  
  6177. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6178.  
  6179. // potentialzpiketick.forEach((obj) => {
  6180. // if(cdf(obj, player) <= 200) {
  6181. // packet('a', undefined);
  6182. // }
  6183. // })
  6184.  
  6185. // let newPos = {
  6186. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6187. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6188. // }
  6189.  
  6190. function getAngleDifference(angle1, angle2) {
  6191. // Normalize the angles to be between 0 and 2π
  6192. angle1 = angle1 % (2 * Math.PI);
  6193. angle2 = angle2 % (2 * Math.PI);
  6194.  
  6195. // Calculate the absolute difference between the angles
  6196. let diff = Math.abs(angle1 - angle2);
  6197.  
  6198. // Adjust the difference to be between 0 and π
  6199. if (diff > Math.PI) {
  6200. diff = (2 * Math.PI) - diff;
  6201. }
  6202.  
  6203. return diff;
  6204. }
  6205.  
  6206. // function smartMove(oneTickMove) {
  6207. // let dir = player.moveDir;
  6208.  
  6209. // let found = false
  6210. // 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))
  6211. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6212.  
  6213. // let newPos = {
  6214. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6215. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6216. // }
  6217.  
  6218. // for (let i = 0; i < spikes.length; i++) {
  6219. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6220. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6221. // }
  6222. // }
  6223.  
  6224.  
  6225.  
  6226.  
  6227.  
  6228. // if (found != false && !traps.inTrap) {
  6229. // packet("a", undefined);
  6230. // } else {
  6231. // packet("a", dir);
  6232. // }
  6233. // player.oldPos.x2 = player.x2;
  6234. // player.oldPos.y2 = player.y2;
  6235. // }
  6236. // function detectEnemySpikeCollisions(tmpObj) {
  6237. // 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));
  6238. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6239. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6240. // let enemy = {
  6241. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6242. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6243. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6244. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6245. // }
  6246. // let found = false;
  6247. // for (let i = 0; i < spikes.length; i++) {
  6248. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6249. // found = true;
  6250. // }
  6251. // }
  6252.  
  6253. // // player.oldPos.x2 = tmpObj.x2;
  6254. // // player.oldPos.y2 = tmpObj.y2;
  6255. // }
  6256.  
  6257. game.tick++;
  6258. enemy = [];
  6259. nears = [];
  6260. near = [];
  6261. game.tickSpeed = performance.now() - game.lastTick;
  6262. game.lastTick = performance.now();
  6263. players.forEach((tmp) => {
  6264. tmp.forcePos = !tmp.visible;
  6265. tmp.visible = false;
  6266. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6267. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6268. });
  6269. for (let i = 0; i < data.length;) {
  6270. tmpObj = findPlayerBySID(data[i]);
  6271. if (tmpObj) {
  6272. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6273. tmpObj.t2 = game.lastTick;
  6274. tmpObj.oldPos.x2 = tmpObj.x2;
  6275. tmpObj.oldPos.y2 = tmpObj.y2;
  6276. tmpObj.x1 = tmpObj.x;
  6277. tmpObj.y1 = tmpObj.y;
  6278. tmpObj.x2 = data[i + 1];
  6279. tmpObj.y2 = data[i + 2];
  6280. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6281. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6282. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6283. tmpObj.d2 = data[i + 3];
  6284. tmpObj.dt = 0;
  6285. tmpObj.buildIndex = data[i + 4];
  6286. tmpObj.weaponIndex = data[i + 5];
  6287. tmpObj.weaponVariant = data[i + 6];
  6288. tmpObj.team = data[i + 7];
  6289. tmpObj.isLeader = data[i + 8];
  6290. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6291. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6292. tmpObj.skinIndex = data[i + 9];
  6293. tmpObj.tailIndex = data[i + 10];
  6294. tmpObj.iconIndex = data[i + 11];
  6295. tmpObj.zIndex = data[i + 12];
  6296. tmpObj.visible = true;
  6297. tmpObj.update(game.tickSpeed);
  6298. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6299. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6300. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6301. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6302. tmpObj.damageThreat = 0;
  6303. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6304. tmpObj.addShameTimer();
  6305. }
  6306. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6307. tmpObj.shameTimer = 0;
  6308. tmpObj.shameCount = 0;
  6309. if (tmpObj == player) {
  6310. healer();
  6311. }
  6312. }
  6313.  
  6314. botSkts.forEach((bot) => {
  6315. bot.showName = 'YEAHHH'
  6316. })
  6317.  
  6318. for(let i = 0; i < players.length; i++) {
  6319. for(let aa = 0; aa < botSkts.length; aa++) {
  6320. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6321.  
  6322. }
  6323. }
  6324.  
  6325. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6326. autoQ = true;
  6327. healer();
  6328. } else {
  6329. if (autoQ) {
  6330. healer();
  6331. }
  6332. autoQ = false;
  6333. }
  6334.  
  6335.  
  6336. if (tmpObj == player) {
  6337. if (liztobj.length) {
  6338. liztobj.forEach((tmp) => {
  6339. tmp.onNear = false;
  6340. if (tmp.active) {
  6341. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6342. tmp.onNear = true;
  6343. }
  6344. if (tmp.isItem && tmp.owner) {
  6345. 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)) {
  6346. tmp.breakObj = true;
  6347. breakObjects.push({
  6348. x: tmp.x,
  6349. y: tmp.y,
  6350. sid: tmp.sid
  6351. });
  6352. }
  6353. }
  6354. }
  6355. });
  6356. 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) {
  6357. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6358. })[0];
  6359. if (nearTrap) {
  6360. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6361. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6362. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6363.  
  6364. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6365. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6366. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6367. traps.inTrap = true;
  6368. traps.info = nearTrap;
  6369. } else {
  6370. traps.inTrap = false;
  6371. traps.info = {};
  6372. }
  6373. } else {
  6374. traps.inTrap = false;
  6375. }
  6376. }
  6377. if (tmpObj.weaponIndex < 9) {
  6378. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6379. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6380. } else if (tmpObj.weaponIndex > 8) {
  6381. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6382. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6383. }
  6384. }
  6385. i += 13;
  6386. }
  6387. if (textManager.stack.length) {
  6388. let stacks = [];
  6389. let notstacks = [];
  6390. let num = 0;
  6391. let num2 = 0;
  6392. let pos = {
  6393. x: null,
  6394. y: null
  6395. };
  6396. let pos2 = {
  6397. x: null,
  6398. y: null
  6399. }
  6400. textManager.stack.forEach((text) => {
  6401. if (text.value >= 0) {
  6402. if (num == 0) pos = {
  6403. x: text.x,
  6404. y: text.y
  6405. };
  6406. num += Math.abs(text.value);
  6407. } else {
  6408. if (num2 == 0) pos2 = {
  6409. x: text.x,
  6410. y: text.y
  6411. };
  6412. num2 += Math.abs(text.value);
  6413. }
  6414. });
  6415. if (num2 > 0) {
  6416. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#FF0000");
  6417. }
  6418. if (num > 0) {
  6419. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6420. }
  6421. textManager.stack = [];
  6422. }
  6423. if (runAtNextTick.length) {
  6424. runAtNextTick.forEach((tmp) => {
  6425. checkProjectileHolder(...tmp);
  6426. });
  6427. runAtNextTick = [];
  6428. }
  6429. for (let i = 0; i < data.length;) {
  6430. tmpObj = findPlayerBySID(data[i]);
  6431. if (tmpObj) {
  6432. if (!tmpObj.isTeam(player)) {
  6433. enemy.push(tmpObj);
  6434. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6435. nears.push(tmpObj);
  6436. }
  6437. }
  6438. tmpObj.manageReload();
  6439. if (tmpObj != player) {
  6440. tmpObj.addDamageThreat(player);
  6441. }
  6442. }
  6443. i += 13;
  6444. }
  6445. /*projectiles.forEach((proj) => {
  6446. tmpObj = proj;
  6447. if (tmpObj.active) {
  6448. tmpObj.tickUpdate(game.tickSpeed);
  6449. }
  6450. });*/
  6451. if (player && player.alive) {
  6452. if (enemy.length) {
  6453. near = enemy.sort(function(tmp1, tmp2) {
  6454. return tmp1.dist2 - tmp2.dist2;
  6455. })[0];
  6456. } else {
  6457. // console.log("no enemy");
  6458. }
  6459. if (game.tickQueue[game.tick]) {
  6460. game.tickQueue[game.tick].forEach((action) => {
  6461. action();
  6462. });
  6463. game.tickQueue[game.tick] = null;
  6464. }
  6465. if (advHeal.length) {
  6466. advHeal.forEach((updHealth) => {
  6467. if (window.pingTime < 150) {
  6468. let sid = updHealth[0];
  6469. let value = updHealth[1];
  6470. let totalDamage = 100 - value
  6471. let damaged = updHealth[2];
  6472. tmpObj = findPlayerBySID(sid);
  6473. let bullTicked = false;
  6474. if (tmpObj == player) {
  6475. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6476. if (my.reSync) {
  6477. my.reSync = false;
  6478. tmpObj.setBullTick = true;
  6479. }
  6480. bullTicked = true;
  6481. }
  6482. if (inGame) {
  6483. let attackers = getAttacker(damaged);
  6484. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6485. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6486. let healTimeout = 140 - window.pingTime;
  6487. let dmg = 100 - player.health;
  6488. let slowHeal = function (timer, tickBase) {
  6489. if (!tickBase) {
  6490. setTimeout(() => {
  6491. healer();
  6492. }, timer);
  6493. } else {
  6494. game.tickBase(() => {
  6495. healer()
  6496. }, 2)
  6497. }
  6498. }
  6499. if (getEl("healingBeta").checked) {
  6500. if (enemy.length) {
  6501. if ([0, 7, 8].includes(near.primaryIndex)) {
  6502. if (damaged < 75) {
  6503. slowHeal(healTimeout)
  6504. } else {
  6505. healer()
  6506. }
  6507. }
  6508. if ([1, 2, 6].includes(near.primaryIndex)) {
  6509. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  6510. healer()
  6511. } else {
  6512. slowHeal(healTimeout)
  6513. }
  6514. }
  6515. if (near.primaryIndex == 3) {
  6516. if (near.secondaryIndex == 15) {
  6517. if (near.primaryVariant < 2) {
  6518. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6519. tmpObj.canEmpAnti = true
  6520. tmpObj.antiTimer = game.tick
  6521. healer()
  6522. } else {
  6523. slowHeal(healTimeout)
  6524. }
  6525. } else {
  6526. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6527. tmpObj.canEmpAnti = true
  6528. tmpObj.antiTimer = game.tick
  6529. healer()
  6530. } else {
  6531. slowHeal(healTimeout)
  6532. }
  6533. }
  6534. } else {
  6535. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6536. healer()
  6537. } else {
  6538. slowHeal(healTimeout)
  6539. }
  6540. }
  6541. }
  6542. if (near.primaryIndex == 4) {
  6543. if (near.primaryVariant >= 1) {
  6544. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6545. healer()
  6546. } else {
  6547. slowHeal(healTimeout)
  6548. }
  6549. } else {
  6550. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  6551. healer()
  6552. } else {
  6553. slowHeal(healTimeout)
  6554. }
  6555. }
  6556. }
  6557. if ([undefined, 5].includes(near.primaryIndex)) {
  6558. if (near.secondaryIndex == 10) {
  6559. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  6560. healer()
  6561. } else {
  6562. slowHeal(healTimeout)
  6563. }
  6564. } else
  6565. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  6566. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  6567. healer()
  6568. } else {
  6569. slowHeal(healTimeout)
  6570. }
  6571. } else
  6572. if ([undefined || 15].includes(near.secondaryIndex)) {
  6573. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  6574. if (tmpObj.shameCount < 5) {
  6575. healer()
  6576. } else {
  6577. slowHeal(healTimeout)
  6578. }
  6579. } else {
  6580. slowHeal(healTimeout)
  6581. }
  6582. } else
  6583. if ([9, 12, 13].includes(near.secondaryIndex)) {
  6584. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  6585. healer()
  6586. } else {
  6587. slowHeal(healTimeout)
  6588. }
  6589. } else {
  6590. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  6591. healer()
  6592. } else {
  6593. slowHeal(healTimeout)
  6594. }
  6595. }
  6596. }
  6597. if (near.primaryIndex == 6) {
  6598. if (near.secondaryIndex == 15) {
  6599. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6600. healer()
  6601. } else {
  6602. slowHeal(healTimeout)
  6603. }
  6604. } else {
  6605. if (damaged >= 70 && tmpObj.shameCount < 4) {
  6606. healer()
  6607. } else {
  6608. slowHeal(healTimeout)
  6609. }
  6610. }
  6611. }
  6612. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6613. } else {
  6614. if (damaged >= 70) {
  6615. healer()
  6616. } else {
  6617. slowHeal(healTimeout)
  6618. }
  6619. }
  6620. } else {
  6621. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  6622. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6623. tmpObj.canEmpAnti = true;
  6624. } else {
  6625. player.soldierAnti = true;
  6626. }
  6627. tmpObj.antiTimer = game.tick;
  6628. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  6629. if (tmpObj.shameCount < shame) {
  6630. healer();
  6631. } else {
  6632. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6633. slowHeal(healTimeout)
  6634. } else {
  6635. slowHeal(healTimeout, 1)
  6636. }
  6637. }
  6638. } else {
  6639. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6640. slowHeal(healTimeout)
  6641. } else {
  6642. slowHeal(healTimeout, 1)
  6643. }
  6644. }
  6645. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6646. }
  6647. } else {
  6648. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6649. tmpObj.setPoisonTick = true;
  6650. }
  6651. }
  6652. }
  6653. } else {
  6654. let [sid, value, damaged] = updHealth;
  6655. let totalDamage = 100 - value;
  6656. let tmpObj = findPlayerBySID(sid);
  6657. let bullTicked = false;
  6658.  
  6659. if (tmpObj == player) {
  6660. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6661. if (my.reSync) {
  6662. my.reSync = false;
  6663. tmpObj.setBullTick = true;
  6664. bullTicked = true;
  6665. }
  6666. }
  6667. if (inGame) {
  6668. let attackers = getAttacker(damaged);
  6669. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6670. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6671. let healTimeout = 60;
  6672. let dmg = 100 - player.health;
  6673. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  6674.  
  6675. let slowHeal = function (timer, tickBase) {
  6676. if (!tickBase) setTimeout(() => healer(), timer);
  6677. else game.tickBase(() => healer(), 2);
  6678. };
  6679.  
  6680. if (getEl("healingBeta").checked) {
  6681. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 :
  6682. [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 :
  6683. [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 :
  6684. near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 :
  6685. near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6686. damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 :
  6687. near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6688. damaged >= 25 && player.damageThreat + dmg >= 95;
  6689.  
  6690. canHealFast ? healer() : slowHeal(healTimeout);
  6691. } else {
  6692. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1;
  6693.  
  6694. if (canHealFast) {
  6695. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) tmpObj.canEmpAnti = true;
  6696. else player.soldierAnti = true;
  6697. tmpObj.antiTimer = game.tick;
  6698. if (tmpObj.shameCount < shameCountThreshold) healer();
  6699. else slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6700. } else {
  6701. slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6702. }
  6703. }
  6704. } else {
  6705. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6706. tmpObj.setPoisonTick = true;
  6707. }
  6708. }
  6709. }
  6710. }
  6711. });
  6712. advHeal = [];
  6713. }
  6714. players.forEach((tmp) => {
  6715. if (!tmp.visible && player != tmp) {
  6716. tmp.reloads = {
  6717. 0: 0,
  6718. 1: 0,
  6719. 2: 0,
  6720. 3: 0,
  6721. 4: 0,
  6722. 5: 0,
  6723. 6: 0,
  6724. 7: 0,
  6725. 8: 0,
  6726. 9: 0,
  6727. 10: 0,
  6728. 11: 0,
  6729. 12: 0,
  6730. 13: 0,
  6731. 14: 0,
  6732. 15: 0,
  6733. 53: 0,
  6734. };
  6735. }
  6736. if (tmp.setBullTick) {
  6737. tmp.bullTimer = 0;
  6738. }
  6739. if (tmp.setPoisonTick) {
  6740. tmp.poisonTimer = 0;
  6741. }
  6742. tmp.updateTimer();
  6743. });
  6744. if (inGame) {
  6745. if (enemy.length) {
  6746. if (player.canEmpAnti) {
  6747. player.canEmpAnti = false;
  6748. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6749. if (near.reloads[53] == 0) {
  6750. player.empAnti = true;
  6751. player.soldierAnti = false;
  6752. //modLog("EmpAnti");
  6753. } else {
  6754. player.empAnti = false;
  6755. player.soldierAnti = true;
  6756. //modLog("SoldierAnti");
  6757. }
  6758. }
  6759. }
  6760. 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) {
  6761. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6762. })[0];
  6763. if (prehit) {
  6764. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6765. instaC.canSpikeTick = true;
  6766. instaC.syncHit = true;
  6767. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6768. instaC.revTick = true;
  6769. }
  6770. }
  6771. }
  6772. 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) {
  6773. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6774. })[0];
  6775. if (antiSpikeTick && !traps.inTrap) {
  6776. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  6777. my.anti0Tick = 1;
  6778. player.chat.count = 2000;
  6779. }
  6780. }
  6781. }
  6782. 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)) {
  6783. if (player.checkCanInsta(true) >= 220) {
  6784. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6785. } else {
  6786. instaC.nobull = false;
  6787. }
  6788. instaC.can = true;
  6789. } else {
  6790. instaC.can = false;
  6791. }
  6792. macro.q && place(0, getAttackDir());
  6793. macro.f && place(4, getSafeDir());
  6794. macro.v && place(2, getSafeDir());
  6795. macro.y && place(5, getSafeDir());
  6796. macro.h && place(player.getItemType(22), getSafeDir());
  6797. macro.n && place(3, getSafeDir());
  6798. if (game.tick % 1 == 0) {
  6799. if (mills.place) {
  6800. let plcAng = 7.7;
  6801. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6802. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6803. }
  6804. } else {
  6805. if (mills.placeSpawnPads) {
  6806. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6807. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6808. }
  6809. }
  6810. }
  6811. }
  6812. if (instaC.can) {
  6813. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  6814. }
  6815. if (instaC.canCounter) {
  6816. instaC.canCounter = false;
  6817. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6818. instaC.counterType();
  6819. }
  6820. }
  6821. if (instaC.canSpikeTick) {
  6822. instaC.canSpikeTick = false;
  6823. if (instaC.revTick) {
  6824. instaC.revTick = false;
  6825. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6826. instaC.changeType("rev");
  6827. chch(null, "[RevSyncHit]", "yellow");
  6828. }
  6829. } else {
  6830. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6831. instaC.spikeTickType();
  6832. if (instaC.syncHit) {
  6833. chch(null, "[SyncHit]", "yellow");
  6834. }
  6835. }
  6836. }
  6837. }
  6838. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6839. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6840. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6841. }
  6842. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6843. sendAutoGather();
  6844. my.waitHit = 1;
  6845. game.tickBase(() => {
  6846. sendAutoGather();
  6847. my.waitHit = 0;
  6848. }, 1);
  6849. }
  6850. }
  6851. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6852. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6853. selectWeapon(player.weapons[0]);
  6854. }
  6855. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6856. sendAutoGather();
  6857. my.waitHit = 1;
  6858. game.tickBase(() => {
  6859. sendAutoGather();
  6860. my.waitHit = 0;
  6861. }, 1);
  6862. }
  6863. }
  6864. if (traps.inTrap) {
  6865. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6866. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6867. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6868. }
  6869. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6870. sendAutoGather();
  6871. my.waitHit = 1;
  6872. game.tickBase(() => {
  6873. sendAutoGather();
  6874. my.waitHit = 0;
  6875. }, 1);
  6876. }
  6877. }
  6878. }
  6879. if (clicked.g && !traps.inTrap) {
  6880. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6881. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6882. instaC.bowMovement();
  6883. } else {
  6884. instaC.rangeType();
  6885. }
  6886. }
  6887. }
  6888. if (macro.t && !traps.inTrap) {
  6889. 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))) {
  6890. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6891. }
  6892. }
  6893. if (macro["."] && !traps.inTrap) {
  6894. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6895. instaC.boostTickMovement();
  6896. }
  6897. }
  6898. 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)) {
  6899. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6900. if (!my.reloaded) {
  6901. my.reloaded = true;
  6902. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  6903. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  6904. selectWeapon(player.weapons[fastSpeed]);
  6905. }
  6906. }
  6907. // if(useWasd) {
  6908. // if (!autos.stopspin) {
  6909. // setTimeout(()=>{
  6910. // autos.stopspin = true;
  6911. // }, 375);
  6912. // }
  6913. // }
  6914. } else {
  6915. my.reloaded = false;
  6916. if(useWasd) {
  6917. autos.stopspin = false;
  6918. }
  6919. if (player.reloads[player.weapons[0]] > 0) {
  6920. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  6921. selectWeapon(player.weapons[0]);
  6922. }
  6923. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  6924. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  6925. selectWeapon(player.weapons[1]);
  6926. }
  6927. if(useWasd) {
  6928. if (!autos.stopspin) {
  6929. setTimeout(()=>{
  6930. autos.stopspin = true;
  6931. }, 750);
  6932. }
  6933. }
  6934. }
  6935. }
  6936. }
  6937. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  6938. traps.autoPlace();
  6939. }
  6940. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  6941. packet("D", getAttackDir());
  6942. }
  6943. let hatChanger = function() {
  6944. if (my.anti0Tick > 0) {
  6945. buyEquip(6, 0);
  6946. } else {
  6947. if (clicks.left || clicks.right) {
  6948. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6949. buyEquip(7, 0);
  6950. buyEquip(13, 1);
  6951. } else {
  6952. if (clicks.left) {
  6953. 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);
  6954. } else if (clicks.right) {
  6955. 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);
  6956. }
  6957. }
  6958. } else if (traps.inTrap) {
  6959. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  6960. buyEquip(40, 0);
  6961. } else {
  6962. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6963. buyEquip(7, 0);
  6964. buyEquip(13, 1);
  6965.  
  6966. } else {
  6967. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 22 : 6, 0);
  6968. }
  6969. }
  6970. } else {
  6971. if (player.empAnti || player.soldierAnti) {
  6972. buyEquip(player.empAnti ? 22 : 6, 0);
  6973. buyEquip(13, 1);
  6974. } else {
  6975. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  6976. buyEquip(7, 0);
  6977. buyEquip(13, 1);
  6978. } else {
  6979. if (near.dist2 <= 300) {
  6980. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  6981. } else {
  6982. biomeGear(1);
  6983. }
  6984. }
  6985. }
  6986. }
  6987. }
  6988. }
  6989. let accChanger = function () {
  6990. if (near.dist2 <= 270) {
  6991. if (clicks.left) {
  6992. buyEquip(13, 1);
  6993. } else if (!clicks.left){
  6994. buyEquip(13, 1);
  6995. }
  6996. }
  6997. else if (clicks.left) {
  6998. buyEquip(19,1);
  6999. }
  7000. else {
  7001. buyEquip(11, 1);
  7002. }
  7003. }
  7004. let wasdGears = function() {
  7005. if (my.anti0Tick > 0) {
  7006. buyEquip(12, 0);
  7007. } else {
  7008. if (clicks.left || clicks.right) {
  7009. if (clicks.left) {
  7010. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7011. } else if (clicks.right) {
  7012. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7013. }
  7014. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7015. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7016. } else if (traps.inTrap) {
  7017. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7018. buyEquip(40, 0);
  7019. } else {
  7020. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7021. buyEquip(7, 0);
  7022. } else {
  7023. buyEquip(player.empAnti ? 22 : 6, 0);
  7024. }
  7025. }
  7026. } else {
  7027. if (player.empAnti) {
  7028. buyEquip(22, 0);
  7029. } else {
  7030. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7031. buyEquip(7, 0);
  7032. } else {
  7033. buyEquip(6, 0);
  7034. }
  7035. }
  7036. }
  7037. }
  7038. if (clicks.left || clicks.right) {
  7039. if (clicks.left) {
  7040. buyEquip(0, 1);
  7041. }
  7042. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7043. buyEquip(0, 1);
  7044. } else if (traps.inTrap) {
  7045. buyEquip(0, 1);
  7046. } else {
  7047. buyEquip(11, 1);
  7048. }
  7049. }
  7050. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7051. if (useWasd) {
  7052. wasdGears();
  7053. } else {
  7054. hatChanger();
  7055. accChanger();
  7056. }
  7057. }
  7058. //lastMoveDir = getSafeDir();
  7059. //packet("a", lastMoveDir, 1);
  7060. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7061. autoPush();
  7062. } else {
  7063. if (my.autoPush) {
  7064. my.autoPush = false;
  7065. packet("a", lastMoveDir || undefined, 1);
  7066. }
  7067. }
  7068. if (!my.autoPush && pathFind.active) {
  7069. Pathfinder();
  7070. }
  7071. if (instaC.ticking) {
  7072. instaC.ticking = false;
  7073. }
  7074. if (instaC.syncHit) {
  7075. instaC.syncHit = false;
  7076. }
  7077. if (player.empAnti) {
  7078. player.empAnti = false;
  7079. }
  7080. if (player.soldierAnti) {
  7081. player.soldierAnti = false;
  7082. }
  7083. if (my.anti0Tick > 0) {
  7084. my.anti0Tick--;
  7085. }
  7086. if (traps.replaced) {
  7087. traps.replaced = false;
  7088. }
  7089. if (traps.antiTrapped) {
  7090. traps.antiTrapped = false;
  7091. }
  7092. const getPotentialDamage = (build, user) => {
  7093. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7094. const weap = user.weapons[weapIndex];
  7095. if (player.reloads[weap]) return 0;
  7096. const weapon = items.weapons[weap];
  7097. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7098. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7099. };
  7100.  
  7101. const AutoReplace = () => {
  7102. const replaceable = [];
  7103. const playerX = player.x;
  7104. const playerY = player.y;
  7105. const gameObjectCount = gameObjects.length;
  7106.  
  7107. for (let i = 0; i < gameObjectCount; i++) {
  7108. const build = gameObjects[i];
  7109. if (build.isItem && build.active && build.health > 0) {
  7110. const item = items.list[build.id];
  7111. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7112. const inDistance = cdf(build, player) <= posDist * 2;
  7113. if (inDistance) {
  7114. let canDeal = 0;
  7115. const playersCount = players.length;
  7116. for (let j = 0; j < playersCount; j++) {
  7117. canDeal += getPotentialDamage(build, players[j]);
  7118. }
  7119. if (build.health <= canDeal) {
  7120. replaceable.push(build);
  7121. }
  7122. }
  7123. }
  7124. }
  7125.  
  7126. const findPlacementAngle = (player, itemId, build) => {
  7127. if (!build) return null;
  7128. const MAX_ANGLE = 2 * Math.PI;
  7129. const ANGLE_STEP = Math.PI / 360;
  7130. const item = items.list[player.items[itemId]];
  7131. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7132. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7133.  
  7134. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7135. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7136. for (let angle of angles) {
  7137. return angle;
  7138. }
  7139. }
  7140. return null;
  7141. };
  7142.  
  7143. const replace = (() => {
  7144. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7145. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7146. const buildId = spike ? 4 : 2;
  7147.  
  7148. replaceable.forEach(build => {
  7149. let angle = findPlacementAngle(player, buildId, build);
  7150. if (angle !== null) {
  7151. place(buildId, angle);
  7152. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7153. }
  7154. });
  7155. });
  7156.  
  7157. if (near && near.dist3 <= 360) {
  7158. replace();
  7159. }
  7160. replace;
  7161. }
  7162. }
  7163. }
  7164. if (botSkts.length) {
  7165. botSkts.forEach((bots) => {
  7166. if (true) {
  7167. bots[0].showName = 'YEAHHH';
  7168. }
  7169. });
  7170. }
  7171. }
  7172. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7173. 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)
  7174.  
  7175. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7176. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7177. selectWeapon(player.weapons[1])
  7178. buyEquip(40, 0);
  7179. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7180. setTickout( () => {
  7181. buyEquip(6, 0)
  7182. }, 1);
  7183. }
  7184. }
  7185. }
  7186. }
  7187. function ez(context, x, y) {
  7188. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7189. context.beginPath();
  7190. context.fill();
  7191. context.closePath();
  7192. context.globalAlpha = 1;
  7193. }
  7194. // UPDATE LEADERBOARD:
  7195. function updateLeaderboard(data) {
  7196. lastLeaderboardData = data;
  7197. return;
  7198. UTILS.removeAllChildren(leaderboardData);
  7199. let tmpC = 1;
  7200. for (let i = 0; i < data.length; i += 3) {
  7201. (function(i) {
  7202. UTILS.generateElement({
  7203. class: "leaderHolder",
  7204. parent: leaderboardData,
  7205. children: [
  7206. UTILS.generateElement({
  7207. class: "leaderboardItem",
  7208. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7209. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7210. }),
  7211. UTILS.generateElement({
  7212. class: "leaderScore",
  7213. text: UTILS.sFormat(data[i + 2]) || "0"
  7214. })
  7215. ]
  7216. });
  7217. })(i);
  7218. tmpC++;
  7219. }
  7220. }
  7221.  
  7222. // LOAD GAME OBJECT:
  7223. function loadGameObject(data) {
  7224. for (let i = 0; i < data.length;) {
  7225. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7226. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7227. sid: data[i + 7]
  7228. } : null));
  7229. // sid, x, y, dir, s, type, data, setSID, owner
  7230. /*let dist = UTILS.getDist({
  7231. x: data[i + 1],
  7232. y: data[i + 2]
  7233. }, player, 0, 2);
  7234. let aim = UTILS.getDirect({
  7235. x: data[i + 1],
  7236. y: data[i + 2]
  7237. }, player, 0, 2);
  7238. find = findObjectBySid(data[i]);
  7239. if (data[i + 6] == 15) {
  7240. if (find && !find.isTeamObject(player)) {
  7241. if (dist <= 100) {
  7242. traps.dist = dist;
  7243. traps.aim = aim;
  7244. traps.protect(aim);
  7245. }
  7246. }
  7247. }*/
  7248. i += 8;
  7249. }
  7250. }
  7251.  
  7252. // ADD AI:
  7253. function loadAI(data) {
  7254. for (let i = 0; i < ais.length; ++i) {
  7255. ais[i].forcePos = !ais[i].visible;
  7256. ais[i].visible = false;
  7257. }
  7258. if (data) {
  7259. let tmpTime = performance.now();
  7260. for (let i = 0; i < data.length;) {
  7261. tmpObj = findAIBySID(data[i]);
  7262. if (tmpObj) {
  7263. tmpObj.index = data[i + 1];
  7264. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7265. tmpObj.t2 = tmpTime;
  7266. tmpObj.x1 = tmpObj.x;
  7267. tmpObj.y1 = tmpObj.y;
  7268. tmpObj.x2 = data[i + 2];
  7269. tmpObj.y2 = data[i + 3];
  7270. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7271. tmpObj.d2 = data[i + 4];
  7272. tmpObj.health = data[i + 5];
  7273. tmpObj.dt = 0;
  7274. tmpObj.visible = true;
  7275. } else {
  7276. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7277. tmpObj.x2 = tmpObj.x;
  7278. tmpObj.y2 = tmpObj.y;
  7279. tmpObj.d2 = tmpObj.dir;
  7280. tmpObj.health = data[i + 5];
  7281. if (!aiManager.aiTypes[data[i + 1]].name)
  7282. tmpObj.name = config.cowNames[data[i + 6]];
  7283. tmpObj.forcePos = true;
  7284. tmpObj.sid = data[i];
  7285. tmpObj.visible = true;
  7286. }
  7287. i += 7;
  7288. }
  7289. }
  7290. }
  7291.  
  7292. // ANIMATE AI:
  7293. function animateAI(sid) {
  7294. tmpObj = findAIBySID(sid);
  7295. if (tmpObj) tmpObj.startAnim();
  7296. }
  7297.  
  7298. // GATHER ANIMATION:
  7299. function gatherAnimation(sid, didHit, index) {
  7300. tmpObj = findPlayerBySID(sid);
  7301. if (tmpObj) {
  7302. tmpObj.startAnim(didHit, index);
  7303. tmpObj.gatherIndex = index;
  7304. tmpObj.gathering = 1;
  7305.  
  7306. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7307. // healer();
  7308.  
  7309. if (didHit) {
  7310. let tmpObjects = objectManager.hitObj;
  7311. objectManager.hitObj = [];
  7312. game.tickBase(() => {
  7313. // refind
  7314. tmpObj = findPlayerBySID(sid);
  7315. 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);
  7316. tmpObjects.forEach((healthy) => {
  7317. healthy.health -= val;
  7318. });
  7319. }, 1);
  7320. }
  7321. }
  7322. }
  7323.  
  7324. // WIGGLE GAME OBJECT:
  7325. function wiggleGameObject(dir, sid) {
  7326. tmpObj = findObjectBySid(sid);
  7327. if (tmpObj) {
  7328. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7329. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7330. if (tmpObj.health) {
  7331. objectManager.hitObj.push(tmpObj);
  7332. }
  7333. }
  7334. }
  7335.  
  7336. // SHOOT TURRET:
  7337. function shootTurret(sid, dir) {
  7338. tmpObj = findObjectBySid(sid);
  7339. if (tmpObj) {
  7340. if (config.anotherVisual) {
  7341. tmpObj.lastDir = dir;
  7342. } else {
  7343. tmpObj.dir = dir;
  7344. }
  7345. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7346. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7347. }
  7348. }
  7349.  
  7350. // UPDATE PLAYER VALUE:
  7351. function updatePlayerValue(index, value, updateView) {
  7352. if (player) {
  7353. player[index] = value;
  7354. if (index == "points") {
  7355. if (configs.autoBuy) {
  7356. autoBuy.hat();
  7357. autoBuy.acc();
  7358. }
  7359. } else if (index == "kills") {
  7360. if (configs.killChat) {
  7361. sendChat("Kills:"+value+"");
  7362. setTimeout(() => {
  7363. sendChat("PRAISE ME PRAISE ME UR SAVIOUR!!");
  7364. }, 800);
  7365. }
  7366. }
  7367. }
  7368. }
  7369.  
  7370.  
  7371.  
  7372. // ACTION BAR:
  7373. function updateItems(data, wpn) {
  7374. if (data) {
  7375. if (wpn) {
  7376. player.weapons = data;
  7377. player.primaryIndex = player.weapons[0];
  7378. player.secondaryIndex = player.weapons[1];
  7379. if (!instaC.isTrue) {
  7380. selectWeapon(player.weapons[0]);
  7381. }
  7382. } else {
  7383. player.items = data;
  7384. }
  7385. }
  7386.  
  7387. for (let i = 0; i < items.list.length; i++) {
  7388. let tmpI = items.weapons.length + i;
  7389. let actionBarItem = getEl("actionBarItem" + tmpI);
  7390. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7391. // Add shadow to the element
  7392. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7393. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7394.  
  7395. }
  7396.  
  7397. for (let i = 0; i < items.weapons.length; i++) {
  7398. let actionBarItem = getEl("actionBarItem" + i);
  7399. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7400. // Add shadow to the element
  7401. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7402. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7403. }
  7404.  
  7405. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7406. if (kms) {
  7407. getEl("actionBarItem3").style.display = "none";
  7408. getEl("actionBarItem4").style.display = "inline-block";
  7409. }
  7410. }
  7411.  
  7412. // ADD PROJECTILE:
  7413. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7414. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7415. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7416. }
  7417.  
  7418. // REMOVE PROJECTILE:
  7419. function remProjectile(sid, range) {
  7420. for (let i = 0; i < projectiles.length; ++i) {
  7421. if (projectiles[i].sid == sid) {
  7422. projectiles[i].range = range;
  7423. let tmpObjects = objectManager.hitObj;
  7424. objectManager.hitObj = [];
  7425. game.tickBase(() => {
  7426. let val = projectiles[i].dmg;
  7427. tmpObjects.forEach((healthy) => {
  7428. if (healthy.projDmg) {
  7429. healthy.health -= val;
  7430. }
  7431. });
  7432. }, 1);
  7433. }
  7434. }
  7435. }
  7436.  
  7437. // lol this useless,,, fr
  7438. let noob = false;
  7439. let serverReady = true;
  7440. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7441. let wssws = isProd ? "wss" : "ws";
  7442. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7443. let withSync = false;
  7444. project.binaryType = "arraybuffer";
  7445. project.onmessage = function(msg) {
  7446. let data = msg.data;
  7447. if (data == "isready") {
  7448. serverReady = true;
  7449. }
  7450. if (data == "fine") {
  7451. noob = false;
  7452. }
  7453.  
  7454. if (data == "tezt") {
  7455. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7456. }
  7457. if (data == "yeswearesyncer") {
  7458. // let delay = Date.now() - wsDelay;
  7459. withSync = true;
  7460. if (player) {
  7461. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7462. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7463. }
  7464. }
  7465. };
  7466. project.onopen = function() {
  7467. var gameTitle = getEl("gameName");
  7468. gameTitle.innerText = "Moo Moo";
  7469. };
  7470.  
  7471. // SHOW ALLIANCE MENU:
  7472. function allianceNotification(sid, name) {
  7473. let findBotSID = findSID(bots, sid);
  7474. if (findBotSID) {}
  7475. }
  7476.  
  7477. function setPlayerTeam(team, isOwner) {
  7478. if (player) {
  7479. player.team = team;
  7480. player.isOwner = isOwner;
  7481. if (team == null)
  7482. alliancePlayers = [];
  7483. }
  7484. }
  7485.  
  7486. function setAlliancePlayers(data) {
  7487. alliancePlayers = data;
  7488. }
  7489.  
  7490. // STORE MENU:
  7491. function updateStoreItems(type, id, index) {
  7492. if (index) {
  7493. if (!type)
  7494. player.tails[id] = 1;
  7495. else {
  7496. player.latestTail = id;
  7497. }
  7498. } else {
  7499. if (!type)
  7500. player.skins[id] = 1,
  7501. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7502. else {
  7503. player.latestSkin = id;
  7504. }
  7505. }
  7506. }
  7507.  
  7508.  
  7509. // SEND MESSAGE:
  7510. function receiveChat(sid, message) {
  7511. if (/img/i.test(message)) return; // Anti img kick
  7512. if (/iframe/i.test(message)) return;
  7513. let kawaii = false;
  7514. let tmpPlayer = findPlayerBySID(sid);
  7515. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7516. tmpPlayer.chatMessage = message;
  7517. tmpPlayer.chatCountdown = config.chatCountdown;
  7518. if (message.includes("mod")) {
  7519. setTimeout(() => {
  7520. packet("6", "Saviour saves you");
  7521. }, 55);
  7522. setTimeout(() => {
  7523. packet("6", "Mod made By God");
  7524. }, 55);
  7525. }
  7526. }
  7527.  
  7528. // MINIMAP:
  7529. function updateMinimap(data) {
  7530. minimapData = data;
  7531. }
  7532.  
  7533. // SHOW ANIM TEXT:
  7534. function showText(x, y, value, type) {
  7535. // if (config.anotherVisual) {
  7536. textManager.stack.push({
  7537. x: x,
  7538. y: y,
  7539. value: value
  7540. });
  7541. // } else {
  7542. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7543. // }
  7544. }
  7545.  
  7546. /** APPLY SOCKET CODES */
  7547.  
  7548. // BOT:
  7549. let bots = [];
  7550. let ranLocation = {
  7551. x: UTILS.randInt(35, 14365),
  7552. y: UTILS.randInt(35, 14365)
  7553. };
  7554. setInterval(() => {
  7555. ranLocation = {
  7556. x: UTILS.randInt(35, 14365),
  7557. y: UTILS.randInt(35, 14365)
  7558. };
  7559. }, 60000);
  7560. class Bot {
  7561. constructor(id, sid, hats, accessories) {
  7562. this.millPlace = true;
  7563. this.id = id;
  7564. this.sid = sid;
  7565. this.team = null;
  7566. this.skinIndex = 0;
  7567. this.tailIndex = 0;
  7568. this.hitTime = 0;
  7569. this.iconIndex = 0;
  7570. this.enemy = [];
  7571. this.near = [];
  7572. this.dist2 = 0;
  7573. this.aim2 = 0;
  7574. this.tick = 0;
  7575. this.itemCounts = {};
  7576. this.latestSkin = 0;
  7577. this.latestTail = 0;
  7578. this.points = 0;
  7579. this.tails = {};
  7580. for (let i = 0; i < accessories.length; ++i) {
  7581. if (accessories[i].price <= 0)
  7582. this.tails[accessories[i].id] = 1;
  7583. }
  7584. this.skins = {};
  7585. for (let i = 0; i < hats.length; ++i) {
  7586. if (hats[i].price <= 0)
  7587. this.skins[hats[i].id] = 1;
  7588. }
  7589. this.spawn = function(moofoll) {
  7590. this.upgraded = 0;
  7591. this.enemy = [];
  7592. this.near = [];
  7593. this.active = true;
  7594. this.alive = true;
  7595. this.lockMove = false;
  7596. this.lockDir = false;
  7597. this.minimapCounter = 0;
  7598. this.chatCountdown = 0;
  7599. this.shameCount = 0;
  7600. this.shameTimer = 0;
  7601. this.sentTo = {};
  7602. this.gathering = 0;
  7603. this.autoGather = 0;
  7604. this.animTime = 0;
  7605. this.animSpeed = 0;
  7606. this.mouseState = 0;
  7607. this.buildIndex = -1;
  7608. this.weaponIndex = 0;
  7609. this.dmgOverTime = {};
  7610. this.noMovTimer = 0;
  7611. this.maxXP = 300;
  7612. this.XP = 0;
  7613. this.age = 1;
  7614. this.kills = 0;
  7615. this.upgrAge = 2;
  7616. this.upgradePoints = 0;
  7617. this.x = 0;
  7618. this.y = 0;
  7619. this.zIndex = 0;
  7620. this.xVel = 0;
  7621. this.yVel = 0;
  7622. this.slowMult = 1;
  7623. this.dir = 0;
  7624. this.nDir = 0;
  7625. this.dirPlus = 0;
  7626. this.targetDir = 0;
  7627. this.targetAngle = 0;
  7628. this.maxHealth = 100;
  7629. this.health = this.maxHealth;
  7630. this.oldHealth = this.maxHealth;
  7631. this.scale = config.playerScale;
  7632. this.speed = config.playerSpeed;
  7633. this.resetMoveDir();
  7634. this.resetResources(moofoll);
  7635. this.items = [0, 3, 6, 10];
  7636. this.weapons = [0];
  7637. this.shootCount = 0;
  7638. this.weaponXP = [];
  7639. this.isBot = false;
  7640. this.reloads = {
  7641. 0: 0,
  7642. 1: 0,
  7643. 2: 0,
  7644. 3: 0,
  7645. 4: 0,
  7646. 5: 0,
  7647. 6: 0,
  7648. 7: 0,
  7649. 8: 0,
  7650. 9: 0,
  7651. 10: 0,
  7652. 11: 0,
  7653. 12: 0,
  7654. 13: 0,
  7655. 14: 0,
  7656. 15: 0,
  7657. 53: 0,
  7658. };
  7659. this.timeZinceZpawn = 0;
  7660. this.whyDie = "";
  7661. this.clearRadius = false;
  7662. this.circlee = 0;
  7663. };
  7664.  
  7665. // RESET MOVE DIR:
  7666. this.resetMoveDir = function() {
  7667. this.moveDir = undefined;
  7668. };
  7669.  
  7670. // RESET RESOURCES:
  7671. this.resetResources = function(moofoll) {
  7672. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7673. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7674. }
  7675. };
  7676.  
  7677. // SET DATA:
  7678. this.setData = function(data) {
  7679. this.id = data[0];
  7680. this.sid = data[1];
  7681. this.name = data[2];
  7682. this.x = data[3];
  7683. this.y = data[4];
  7684. this.dir = data[5];
  7685. this.health = data[6];
  7686. this.maxHealth = data[7];
  7687. this.scale = data[8];
  7688. this.skinColor = data[9];
  7689. };
  7690.  
  7691.  
  7692. // SHAME SYSTEM:
  7693. this.judgeShame = function() {
  7694. if (this.oldHealth < this.health) {
  7695. if (this.hitTime) {
  7696. let timeSinceHit = this.tick - this.hitTime;
  7697. this.hitTime = 0;
  7698. if (timeSinceHit < 2) {
  7699. this.lastshamecount = this.shameCount;
  7700. this.shameCount++;
  7701. } else {
  7702. this.lastshamecount = this.shameCount;
  7703. this.shameCount = Math.max(0, this.shameCount - 2);
  7704. }
  7705. }
  7706. } else if (this.oldHealth > this.health) {
  7707. this.hitTime = this.tick;
  7708. }
  7709. };
  7710.  
  7711. // CHECK TEAM
  7712. this.isTeam = function (tmpObj) {
  7713. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  7714.  
  7715. };
  7716. // UPDATE WEAPON RELOAD:
  7717. this.manageReloadaa = function() {
  7718. if (this.shooting[53]) {
  7719. this.shooting[53] = 0;
  7720. this.reloads[53] = (2500 - 1000/9);
  7721. } else {
  7722. if (this.reloads[53] > 0) {
  7723. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7724. }
  7725. }
  7726. if (this.gathering || this.shooting[1]) {
  7727. if (this.gathering) {
  7728. this.gathering = 0;
  7729. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7730. this.attacked = true;
  7731. }
  7732. if (this.shooting[1]) {
  7733. this.shooting[1] = 0;
  7734. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7735. this.attacked = true;
  7736. }
  7737. } else {
  7738. this.attacked = false;
  7739. if (this.buildIndex < 0) {
  7740. if (this.reloads[this.weaponIndex] > 0) {
  7741. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7742. }
  7743. }
  7744. }
  7745. };
  7746.  
  7747. this.closeSockets = function(websc) {
  7748. websc.close();
  7749. };
  7750.  
  7751. this.whyDieChat = function(websc, whydie) {
  7752. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  7753. };
  7754. }
  7755. };
  7756.  
  7757. class BotObject {
  7758. constructor(sid) {
  7759. this.sid = sid;
  7760. // INIT:
  7761. this.init = function(x, y, dir, scale, type, data, owner) {
  7762. data = data || {};
  7763. this.active = true;
  7764. this.x = x;
  7765. this.y = y;
  7766. this.scale = scale;
  7767. this.owner = owner;
  7768. this.id = data.id;
  7769. this.dmg = data.dmg;
  7770. this.trap = data.trap;
  7771. this.teleport = data.teleport;
  7772. this.isItem = this.id != undefined;
  7773. };
  7774.  
  7775. }
  7776. };
  7777. class BotObjManager {
  7778. constructor(botObj, fOS) {
  7779. // DISABLE OBJ:
  7780. this.disableObj = function(obj) {
  7781. obj.active = false;
  7782. if (config.anotherVisual) {} else {
  7783. obj.alive = false;
  7784. }
  7785. };
  7786.  
  7787. // ADD NEW:
  7788. let tmpObj;
  7789. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7790. tmpObj = fOS(sid);
  7791. if (!tmpObj) {
  7792. tmpObj = botObj.find((tmp) => !tmp.active);
  7793. if (!tmpObj) {
  7794. tmpObj = new BotObject(sid);
  7795. botObj.push(tmpObj);
  7796. }
  7797. }
  7798. if (setSID) {
  7799. tmpObj.sid = sid;
  7800. }
  7801. tmpObj.init(x, y, dir, s, type, data, owner);
  7802. };
  7803.  
  7804. // DISABLE BY SID:
  7805. this.disableBySid = function(sid) {
  7806. let find = fOS(sid);
  7807. if (find) {
  7808. this.disableObj(find);
  7809. }
  7810. };
  7811.  
  7812. // REMOVE ALL FROM PLAYER:
  7813. this.removeAllItems = function(sid, server) {
  7814. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7815. };
  7816. }
  7817. };
  7818.  
  7819. let botz = [];
  7820.  
  7821. function botSpawn(id) {
  7822. let bot;
  7823. console.log(WS);
  7824. let t = WS.url.split("wss://")[1].split("?")[0];
  7825. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  7826. let botPlayer = new Map();
  7827. botSkts.push([botPlayer]);
  7828. botz.push([bot]);
  7829. let botSID;
  7830. let botObj = [];
  7831. let nearObj = [];
  7832. let bD = {
  7833. x: 0,
  7834. y: 0,
  7835. inGame: false,
  7836. closeSocket: false,
  7837. whyDie: ""
  7838. };
  7839. let oldXY = {
  7840. x: 0,
  7841. y: 0,
  7842. };
  7843. let izauto = 0;
  7844. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  7845. bot.binaryType = "arraybuffer";
  7846. bot.first = true;
  7847. bot.sendWS = function(type) {
  7848. // EXTRACT DATA ARRAY:
  7849. let data = Array.prototype.slice.call(arguments, 1);
  7850. // SEND MESSAGE:
  7851. let binary = window.msgpack.encode([type, data]);
  7852. bot.send(binary);
  7853. };
  7854. bot.spawn = function() {
  7855. bot.sendWS("M", {
  7856. name: "Trash Slave",
  7857. moofoll: 1,
  7858. skin: "__proto__"
  7859. });
  7860. };
  7861. bot.sendUpgrade = function(index) {
  7862. bot.sendWS("H", index);
  7863. };
  7864. bot.place = function(id, a) {
  7865. try {
  7866. let item = items.list[botPlayer.items[id]];
  7867. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  7868. bot.sendWS("G", botPlayer.items[id]);
  7869. bot.sendWS("d", 1, a);
  7870. bot.sendWS("G", botPlayer.weaponIndex, true);
  7871. }
  7872. } catch (e) {
  7873. }
  7874. };
  7875. bot.buye = function(id, index) {
  7876. let nID = 0;
  7877. if (botPlayer.alive && botPlayer.inGame) {
  7878. if (index == 0) {
  7879. if (botPlayer.skins[id]) {
  7880. if (botPlayer.latestSkin != id) {
  7881. bot.sendWS("c", 0, id, 0);
  7882. }
  7883. } else {
  7884. let find = findID(hats, id);
  7885. if (find) {
  7886. if (botPlayer.points >= find.price) {
  7887. bot.sendWS("c", 1, id, 0);
  7888. bot.sendWS("c", 0, id, 0);
  7889. } else {
  7890. if (botPlayer.latestSkin != nID) {
  7891. bot.sendWS("c", 0, nID, 0);
  7892. }
  7893. }
  7894. } else {
  7895. if (botPlayer.latestSkin != nID) {
  7896. bot.sendWS("c", 0, nID, 0);
  7897. }
  7898. }
  7899. }
  7900. } else if (index == 1) {
  7901. if (botPlayer.tails[id]) {
  7902. if (botPlayer.latestTail != id) {
  7903. bot.sendWS("c", 0, id, 1);
  7904. }
  7905. } else {
  7906. let find = findID(accessories, id);
  7907. if (find) {
  7908. if (botPlayer.points >= find.price) {
  7909. bot.sendWS("c", 1, id, 1);
  7910. bot.sendWS("c", 0, id, 1);
  7911. } else {
  7912. if (botPlayer.latestTail != 0) {
  7913. bot.sendWS("c", 0, 0, 1);
  7914. }
  7915. }
  7916. } else {
  7917. if (botPlayer.latestTail != 0) {
  7918. bot.sendWS("c", 0, 0, 1);
  7919. }
  7920. }
  7921. }
  7922. }
  7923. }
  7924. };
  7925. bot.fastGear = function() {
  7926. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  7927. bot.buye(31, 0);
  7928. } else {
  7929. if (botPlayer.y2 <= config.snowBiomeTop) {
  7930. bot.buye(15, 0);
  7931. } else {
  7932. bot.buye(12, 0);
  7933. }
  7934. }
  7935. };
  7936. bot.selectWeapon = function(a) {
  7937. packet("G", a, 1);
  7938. }
  7939. function caf(e, t) {
  7940. try {
  7941. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7942. } catch (e) {
  7943. return 0;
  7944. }
  7945. }
  7946. bot.heal = function() {
  7947. if (botPlayer.health < 100) {
  7948. bot.place(0, 0)
  7949. }
  7950. }
  7951. function cdf (e, t){
  7952. try {
  7953. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  7954. } catch(e){
  7955. return Infinity;
  7956. }
  7957. }
  7958. let zoon = 'no';
  7959. bot.zync = function(a) {
  7960. if (!botPlayer.millPlace) {
  7961. zoon = 'yeah';
  7962. bot.place(5, caf(botPlayer, a));
  7963. let NextTickLocation = {
  7964. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7965. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7966. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  7967. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  7968. };
  7969.  
  7970. function calculateDistance(x1, y1, x2, y2) {
  7971. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  7972. return distance;
  7973. }
  7974. function dotherezt() {
  7975. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7976. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  7977. }
  7978.  
  7979. let aa = setInterval(() => {
  7980. bot.sendWS("G", botPlayer.weapons[1], true);
  7981. if (izauto == 0) {
  7982. bot.sendWS("K", 1);
  7983. izauto = 1;
  7984. }
  7985. setTimeout(() => {
  7986. bot.sendWS("G", botPlayer.weapons[0], true);
  7987. }, 2000);
  7988. bot.buye(53, 0);
  7989. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  7990. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  7991. } else {
  7992. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  7993. zoon = 'no';
  7994. bot.sendWS("a", undefined);
  7995. dotherezt();
  7996. clearInterval(aa);
  7997. }
  7998. }, 150);
  7999.  
  8000. setTimeout(() => {
  8001. zoon = 'no';
  8002. clearInterval(aa);
  8003. }, 500);
  8004. }
  8005. };
  8006. bot.onmessage = function(message) {
  8007. let data = new Uint8Array(message.data);
  8008. let parsed = window.msgpack.decode(data);
  8009. let type = parsed[0];
  8010. data = parsed[1];
  8011. if (type == "io-init") {
  8012. bot.spawn();
  8013. }
  8014. if (type == "1") {
  8015. botSID = data[0];
  8016. console.log(botSID)
  8017. }
  8018. if (type == "D") {
  8019. if (data[1]) {
  8020. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8021. botPlayer.setData(data[0]);
  8022. botPlayer.inGame = true;
  8023. botPlayer.alive = true;
  8024. botPlayer.x2 = undefined;
  8025. botPlayer.y2 = undefined;
  8026. botPlayer.spawn(1);
  8027. botPlayer.oldHealth = 100;
  8028. botPlayer.health = 100;
  8029. botPlayer.showName = 'YEAHHH';
  8030. oldXY = {
  8031. x: data[0][3],
  8032. y: data[0][4]
  8033. }
  8034. bD.inGame = true;
  8035. if (bot.first) {
  8036. bot.first = false;
  8037. bots.push(bD);
  8038. }
  8039. }
  8040. }
  8041. if (type == "P") {
  8042. bot.spawn();
  8043. botPlayer.inGame = false;
  8044. bD.inGame = false;
  8045. }
  8046. if (type == "a") {
  8047. let tmpData = data[0];
  8048. botPlayer.tick++;
  8049. botPlayer.enemy = [];
  8050. botPlayer.near = [];
  8051. bot.showName = 'YEAHHH';
  8052. nearObj = [];
  8053. for (let i = 0; i < tmpData.length;) {
  8054. if (tmpData[i] == botPlayer.sid) {
  8055. botPlayer.x2 = tmpData[i + 1];
  8056. botPlayer.y2 = tmpData[i + 2];
  8057. botPlayer.d2 = tmpData[i + 3];
  8058. botPlayer.buildIndex = tmpData[i + 4];
  8059. botPlayer.weaponIndex = tmpData[i + 5];
  8060. botPlayer.weaponVariant = tmpData[i + 6];
  8061. botPlayer.team = tmpData[i + 7];
  8062. botPlayer.isLeader = tmpData[i + 8];
  8063. botPlayer.skinIndex = tmpData[i + 9];
  8064. botPlayer.tailIndex = tmpData[i + 10];
  8065. botPlayer.iconIndex = tmpData[i + 11];
  8066. botPlayer.zIndex = tmpData[i + 12];
  8067. botPlayer.visible = true;
  8068. bD.x2 = botPlayer.x2;
  8069. bD.y2 = botPlayer.y2;
  8070. }
  8071. i += 13;
  8072. }
  8073.  
  8074. for (let i = 0; i < tmpData.length;) {
  8075. tmpObj = findPlayerBySID(tmpData[i]);
  8076. if (tmpObj) {
  8077. if (!tmpObj.isTeam(botPlayer)) {
  8078. enemy.push(tmpObj);
  8079. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8080. nears.push(tmpObj);
  8081. }
  8082. }
  8083. }
  8084. i += 13;
  8085. }
  8086.  
  8087. if (enemy.length) {
  8088. //console.log(enemy)
  8089. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8090. return tmp1.dist2 - tmp2.dist2;
  8091. })[0];
  8092. }
  8093.  
  8094. if (izauto == 1) {
  8095. bot.sendWS("K", 1);
  8096. izauto = 0;
  8097. }
  8098.  
  8099. if (bD.closeSocket) {
  8100. botPlayer.closeSockets(bot);
  8101. }
  8102. if (bD.whyDie != "") {
  8103. botPlayer.whyDieChat(bot, bD.whyDie);
  8104. bD.whyDie = "";
  8105. }
  8106. if (botPlayer.alive) {
  8107. if (player.team) {
  8108. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8109. botPlayer.team && (bot.sendWS("N"));
  8110. bot.sendWS("b", player.team);
  8111. }
  8112. }
  8113.  
  8114. let item = items.list[botPlayer.items[3]];
  8115. let a = botPlayer.itemCounts[item.group.id]
  8116. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8117. if (botPlayer.inGame) {
  8118. bot.sendWS("D", botPlayer.moveDir);
  8119. if (izauto == 0) {
  8120. bot.sendWS("K", 1);
  8121. izauto = 1;
  8122. }
  8123. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8124. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8125. bot.place(3, aim + 7.7);
  8126. bot.place(3, aim - 7.7);
  8127. bot.place(3, aim);
  8128. oldXY = {
  8129. x: botPlayer.x2,
  8130. y: botPlayer.y2
  8131. };
  8132. }
  8133.  
  8134. if (botPlayer.tick % 90 === 0) {
  8135. let rand = Math.random() * Math.PI * 2;
  8136. botPlayer.moveDir = rand;
  8137. bot.sendWS("a", botPlayer.moveDir);
  8138. }
  8139. }
  8140. bot.fastGear();
  8141. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  8142. botPlayer.millPlace = false;
  8143. // bot.sendWS("K", 1);
  8144. bot.fastGear();
  8145. } else {
  8146. if (botPlayer.inGame) {
  8147. if (botObj.length > 0) {
  8148. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8149. if (getEl("mode").value == 'fuckemup') {
  8150. // if (getEl("mode").value == "clear") {
  8151. bot.selectWeapon(botPlayer.weapons[1]);
  8152. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8153. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8154. 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) {
  8155. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8156. })[0];
  8157. if (nearObj) {
  8158. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8159. if ((gotoDist - isPassed) > 0) {
  8160. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8161. if (botPlayer.moveDir != undefined) {
  8162. botPlayer.moveDir = undefined;
  8163. bot.sendWS("a", botPlayer.moveDir);
  8164. bot.sendWS("D", botPlayer.nDir);
  8165. }
  8166. } else {
  8167. botPlayer.moveDir = gotoAim;
  8168. bot.sendWS("a", botPlayer.moveDir);
  8169. bot.sendWS("D", botPlayer.nDir);
  8170. }
  8171. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8172. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8173. bot.sendWS("D", botPlayer.nDir);
  8174. }
  8175. if (izauto == 0) {
  8176. bot.sendWS("K", 1);
  8177. izauto = 1;
  8178. }
  8179. bot.buye(40, 0);
  8180. } else {
  8181. botPlayer.moveDir = gotoAim;
  8182. bot.sendWS("a", botPlayer.moveDir);
  8183. bot.sendWS("D", botPlayer.nDir);
  8184. bot.fastGear();
  8185. }
  8186. } else {
  8187. botPlayer.moveDir = gotoAim;
  8188. bot.sendWS("a", botPlayer.moveDir);
  8189. bot.sendWS("D", botPlayer.nDir);
  8190. bot.fastGear();
  8191. }
  8192. }
  8193. }
  8194.  
  8195.  
  8196.  
  8197. if (botObj.length > 0) {
  8198. if (getEl("mode").value == 'flex') {
  8199. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  8200. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  8201. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  8202.  
  8203. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  8204.  
  8205. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  8206. if (dist > 22) // 22 is player speed without booster hat
  8207. return;
  8208. }
  8209. }
  8210.  
  8211.  
  8212. if (botObj.length > 0) {
  8213. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8214. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8215. })[0];
  8216.  
  8217. if (nearObj) {
  8218. if (izauto == 0) {
  8219. bot.sendWS("K", 1);
  8220. izauto = 1;
  8221. }
  8222. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8223. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8224. bot.sendWS("D", botPlayer.nDir);
  8225. }
  8226. bot.buye(40, 0);
  8227. bot.buye(11, 1);
  8228. } else {
  8229. bot.fastGear();
  8230. bot.buye(11, 1);
  8231. }
  8232. bot.buye(11, 1);
  8233. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8234. // if (getEl("mode").value == "clear") {
  8235. bot.selectWeapon(botPlayer.weapons[1]);
  8236. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8237. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8238. 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) {
  8239. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8240. })[0];
  8241. if (nearObj) {
  8242. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8243. if ((gotoDist - isPassed) > 0) {
  8244. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8245. if (botPlayer.moveDir != undefined) {
  8246. botPlayer.moveDir = undefined;
  8247. bot.sendWS("a", botPlayer.moveDir);
  8248. bot.sendWS("D", botPlayer.nDir);
  8249. }
  8250. } else {
  8251. botPlayer.moveDir = gotoAim;
  8252. bot.sendWS("a", botPlayer.moveDir);
  8253. bot.sendWS("D", botPlayer.nDir);
  8254. }
  8255. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8256. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8257. bot.sendWS("D", botPlayer.nDir);
  8258. }
  8259. if (izauto == 0) {
  8260. bot.sendWS("K", 1);
  8261. izauto = 1;
  8262. }
  8263. bot.buye(40, 0);
  8264. bot.fastGear();
  8265. } else {
  8266. botPlayer.moveDir = gotoAim;
  8267. bot.sendWS("a", botPlayer.moveDir);
  8268. bot.sendWS("D", botPlayer.nDir);
  8269. bot.fastGear();
  8270. }
  8271. } else {
  8272. botPlayer.moveDir = gotoAim;
  8273. bot.sendWS("a", botPlayer.moveDir);
  8274. bot.sendWS("D", botPlayer.nDir);
  8275. bot.fastGear();
  8276. }
  8277. if (gotoDist > 300) {
  8278. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8279. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8280. bot.place(3, aim + 7.7);
  8281. bot.place(3, aim - 7.7);
  8282. bot.place(3, aim);
  8283. oldXY = {
  8284. x: botPlayer.x2,
  8285. y: botPlayer.y2
  8286. };
  8287. }
  8288. }
  8289. }
  8290. }
  8291.  
  8292. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8293. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  8294.  
  8295. if(!wdaawdwad.length) {
  8296. if(zoon == 'no')
  8297. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8298. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8299. }
  8300.  
  8301. if(wdaawdwad.length) {
  8302. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8303. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8304. 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) {
  8305. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8306. })[0];
  8307. if (nearObj) {
  8308. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8309. if ((gotoDist - isPassed) > 0) {
  8310. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8311. if (botPlayer.moveDir != undefined) {
  8312. botPlayer.moveDir = undefined;
  8313. bot.sendWS("a", botPlayer.moveDir);
  8314. bot.sendWS("D", botPlayer.nDir);
  8315. }
  8316. } else {
  8317. bot.sendWS("D", botPlayer.nDir);
  8318. }
  8319. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8320. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8321. bot.sendWS("D", botPlayer.nDir);
  8322. }
  8323. if (izauto == 0) {
  8324. bot.sendWS("K", 1);
  8325. izauto = 1;
  8326. }
  8327. bot.buye(40, 0);
  8328. bot.fastGear();
  8329. } else {
  8330. if(zoon == 'no')
  8331. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8332. if(cdf(player, botPlayer) <= 110)
  8333. bot.sendWS("a", undefined);
  8334. else
  8335. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8336. }
  8337. } else {
  8338. if(wdaawdwad.length) {
  8339. if(zoon == 'no')
  8340. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], 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. } else {
  8346. if(zoon == 'no')
  8347. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8348. if(cdf(player, botPlayer) <= 110)
  8349. bot.sendWS("a", undefined);
  8350. else
  8351. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8352. }
  8353. }
  8354. }
  8355. }
  8356. }
  8357. }
  8358. }
  8359. }
  8360. if (type == "H") {
  8361. let tmpData = data[0];
  8362. for (let i = 0; i < tmpData.length;) {
  8363. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8364. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8365. sid: tmpData[i + 7]
  8366. } : null));
  8367. i += 8;
  8368. }
  8369. }
  8370. if (type == "N") {
  8371. let index = data[0];
  8372. let value = data[1];
  8373. if (botPlayer) {
  8374. botPlayer[index] = value;
  8375. }
  8376. }
  8377. if (type == "O") {
  8378. if (data[0] == botPlayer.sid) {
  8379. botPlayer.oldHealth = botPlayer.health;
  8380. botPlayer.health = data[1];
  8381. botPlayer.judgeShame();
  8382. if (botPlayer.oldHealth > botPlayer.health) {
  8383. if (botPlayer.shameCount < 5) {
  8384. for (let i = 0; i < 2; i++) {
  8385. bot.place(0, botPlayer.nDir);
  8386. }
  8387.  
  8388. } else {
  8389. setTimeout(() => {
  8390. for (let i = 0; i < 2; i++) {
  8391. bot.place(0, botPlayer.nDir);
  8392. }
  8393. }, 95);
  8394. }
  8395. }
  8396. }
  8397. }
  8398. if (type == "Q") {
  8399. let sid = data[0];
  8400. botObjManager.disableBySid(sid);
  8401. }
  8402. if (type == "R") {
  8403. let sid = data[0];
  8404. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8405. }
  8406. if (type == "S") {
  8407. let index = data[0];
  8408. let value = data[1];
  8409. if (botPlayer) {
  8410. botPlayer.itemCounts[index] = value;
  8411. }
  8412. }
  8413. if (type == "U") {
  8414. if (data[0] > 0) {
  8415. if(getEl("setup").value == 'dm') {
  8416. if (botPlayer.upgraded == 0) {
  8417. bot.sendUpgrade(7);
  8418. } else if (botPlayer.upgraded == 1) {
  8419. bot.sendUpgrade(17);
  8420. } else if (botPlayer.upgraded == 2) {
  8421. bot.sendUpgrade(31);
  8422. } else if (botPlayer.upgraded == 3) {
  8423. bot.sendUpgrade(23);
  8424. } else if (botPlayer.upgraded == 4) {
  8425. bot.sendUpgrade(9);
  8426. } else if (botPlayer.upgraded == 5) {
  8427. bot.sendUpgrade(34);
  8428. } else if (botPlayer.upgraded == 6) {
  8429. bot.sendUpgrade(12);
  8430. } else if (botPlayer.upgraded == 7) {
  8431. bot.sendUpgrade(15);
  8432. }
  8433. } else if(getEl("setup").value == 'dr') {
  8434. if (botPlayer.upgraded == 0) {
  8435. bot.sendUpgrade(7);
  8436. } else if (botPlayer.upgraded == 1) {
  8437. bot.sendUpgrade(17);
  8438. } else if (botPlayer.upgraded == 2) {
  8439. bot.sendUpgrade(31);
  8440. } else if (botPlayer.upgraded == 3) {
  8441. bot.sendUpgrade(23);
  8442. } else if (botPlayer.upgraded == 4) {
  8443. bot.sendUpgrade(9);
  8444. } else if (botPlayer.upgraded == 5) {
  8445. bot.sendUpgrade(34);
  8446. } else if (botPlayer.upgraded == 6) {
  8447. bot.sendUpgrade(12);
  8448. } else if (botPlayer.upgraded == 7) {
  8449. bot.sendUpgrade(13);
  8450. }
  8451. } else if(getEl("setup").value == 'kh') {
  8452. if (botPlayer.upgraded == 0) {
  8453. bot.sendUpgrade(3);
  8454. } else if (botPlayer.upgraded == 1) {
  8455. bot.sendUpgrade(17);
  8456. } else if (botPlayer.upgraded == 2) {
  8457. bot.sendUpgrade(31);
  8458. } else if (botPlayer.upgraded == 3) {
  8459. bot.sendUpgrade(27);
  8460. } else if (botPlayer.upgraded == 4) {
  8461. bot.sendUpgrade(10);
  8462. } else if (botPlayer.upgraded == 5) {
  8463. bot.sendUpgrade(34);
  8464. } else if (botPlayer.upgraded == 6) {
  8465. bot.sendUpgrade(4);
  8466. } else if (botPlayer.upgraded == 7) {
  8467. bot.sendUpgrade(25);
  8468. }
  8469. } else if(getEl("setup").value == 'zd') {
  8470. if (botPlayer.upgraded == 0) {
  8471. bot.sendUpgrade(3);
  8472. } else if (botPlayer.upgraded == 1) {
  8473. bot.sendUpgrade(17);
  8474. } else if (botPlayer.upgraded == 2) {
  8475. bot.sendUpgrade(31);
  8476. } else if (botPlayer.upgraded == 3) {
  8477. bot.sendUpgrade(27);
  8478. } else if (botPlayer.upgraded == 4) {
  8479. bot.sendUpgrade(9);
  8480. } else if (botPlayer.upgraded == 5) {
  8481. bot.sendUpgrade(34);
  8482. } else if (botPlayer.upgraded == 6) {
  8483. bot.sendUpgrade(12);
  8484. } else if (botPlayer.upgraded == 7) {
  8485. bot.sendUpgrade(15);
  8486. }
  8487. }
  8488. botPlayer.upgraded++;
  8489. }
  8490. }
  8491. if (type == "V") {
  8492. let tmpData = data[0];
  8493. let wpn = data[1];
  8494. if (tmpData) {
  8495. if (wpn) botPlayer.weapons = tmpData;
  8496. else botPlayer.items = tmpData;
  8497. }
  8498.  
  8499. }
  8500. if (type == "5") {
  8501. let type = data[0];
  8502. let id = data[1];
  8503. let index = data[2];
  8504. if (index) {
  8505. if (!type)
  8506. botPlayer.tails[id] = 1;
  8507. else
  8508. botPlayer.latestTail = id;
  8509. } else {
  8510. if (!type)
  8511. botPlayer.skins[id] = 1;
  8512. else
  8513. botPlayer.latestSkin = id;
  8514. }
  8515. }
  8516.  
  8517. if (type == "6") {
  8518. let id = data[0];
  8519. let mzg = data[1]+'';
  8520. if(id == player.sid && mzg.includes("Sync")) {
  8521. bot.zync(botPlayer.near);
  8522. }
  8523. }
  8524. };
  8525. bot.onclose = function() {
  8526. botPlayer.inGame = false;
  8527. bD.inGame = false;
  8528. };
  8529. }
  8530.  
  8531. // RENDER LEAF:
  8532. function renderLeaf(x, y, l, r, ctxt) {
  8533. let endX = x + (l * Math.cos(r));
  8534. let endY = y + (l * Math.sin(r));
  8535. let width = l * 0.4;
  8536. ctxt.moveTo(x, y);
  8537. ctxt.beginPath();
  8538. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8539. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8540. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8541. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8542. ctxt.closePath();
  8543. ctxt.fill();
  8544. ctxt.stroke();
  8545. }
  8546.  
  8547. // RENDER CIRCLE:
  8548. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8549. tmpContext = tmpContext || mainContext;
  8550. tmpContext.beginPath();
  8551. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8552. if (!dontFill) tmpContext.fill();
  8553. if (!dontStroke) tmpContext.stroke();
  8554. }
  8555.  
  8556. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8557. tmpContext = tmpContext || mainContext;
  8558. tmpContext.beginPath();
  8559. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8560. if (!dontFill) tmpContext.fill();
  8561. if (!dontStroke) tmpContext.stroke();
  8562. }
  8563.  
  8564. // RENDER STAR SHAPE:
  8565. function renderStar(ctxt, spikes, outer, inner) {
  8566. let rot = Math.PI / 2 * 3;
  8567. let x, y;
  8568. let step = Math.PI / spikes;
  8569. ctxt.beginPath();
  8570. ctxt.moveTo(0, -outer);
  8571. for (let i = 0; i < spikes; i++) {
  8572. x = Math.cos(rot) * outer;
  8573. y = Math.sin(rot) * outer;
  8574. ctxt.lineTo(x, y);
  8575. rot += step;
  8576. x = Math.cos(rot) * inner;
  8577. y = Math.sin(rot) * inner;
  8578. ctxt.lineTo(x, y);
  8579. rot += step;
  8580. }
  8581. ctxt.lineTo(0, -outer);
  8582. ctxt.closePath();
  8583. }
  8584.  
  8585. function renderHealthStar(ctxt, spikes, outer, inner) {
  8586. let rot = Math.PI / 2 * 3;
  8587. let x, y;
  8588. let step = Math.PI / spikes;
  8589. ctxt.beginPath();
  8590. ctxt.moveTo(0, -outer);
  8591. for (let i = 0; i < spikes; i++) {
  8592. x = Math.cos(rot) * outer;
  8593. y = Math.sin(rot) * outer;
  8594. ctxt.lineTo(x, y);
  8595. rot += step;
  8596. x = Math.cos(rot) * inner;
  8597. y = Math.sin(rot) * inner;
  8598. ctxt.lineTo(x, y);
  8599. rot += step;
  8600. }
  8601. ctxt.lineTo(0, -outer);
  8602. ctxt.closePath();
  8603. }
  8604.  
  8605. // RENDER RECTANGLE:
  8606. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8607. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8608. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8609. }
  8610.  
  8611. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8612. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8613. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8614. }
  8615.  
  8616. // RENDER RECTCIRCLE:
  8617. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8618. ctxt.save();
  8619. ctxt.translate(x, y);
  8620. seg = Math.ceil(seg / 2);
  8621. for (let i = 0; i < seg; i++) {
  8622. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8623. ctxt.rotate(Math.PI / seg);
  8624. }
  8625. ctxt.restore();
  8626. }
  8627.  
  8628. // RENDER BLOB:
  8629. function renderBlob(ctxt, spikes, outer, inner) {
  8630. let rot = Math.PI / 2 * 3;
  8631. let x, y;
  8632. let step = Math.PI / spikes;
  8633. let tmpOuter;
  8634. ctxt.beginPath();
  8635. ctxt.moveTo(0, -inner);
  8636. for (let i = 0; i < spikes; i++) {
  8637. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8638. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8639. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8640. rot += step * 2;
  8641. }
  8642. ctxt.lineTo(0, -inner);
  8643. ctxt.closePath();
  8644. }
  8645.  
  8646. // RENDER TRIANGLE:
  8647. function renderTriangle(s, ctx) {
  8648. ctx = ctx || mainContext;
  8649. let h = s * (Math.sqrt(3) / 2);
  8650. ctx.beginPath();
  8651. ctx.moveTo(0, -h / 2);
  8652. ctx.lineTo(-s / 2, h / 2);
  8653. ctx.lineTo(s / 2, h / 2);
  8654. ctx.lineTo(0, -h / 2);
  8655. ctx.fill();
  8656. ctx.closePath();
  8657. }
  8658.  
  8659. // PREPARE MENU BACKGROUND:
  8660. function prepareMenuBackground() {
  8661. let tmpMid = config.mapScale / 2;
  8662. let attempts = 0;
  8663. for (let i = 0; i < items.list.length * 3;) {
  8664. if (attempts >= 1000) break;
  8665. attempts++;
  8666. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8667. let data = {
  8668. x: tmpMid + UTILS.randFloat(-1000, 1000),
  8669. y: tmpMid + UTILS.randFloat(-600, 600),
  8670. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8671. };
  8672. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8673. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8674. } else {
  8675. continue;
  8676. }
  8677. i++;
  8678. }
  8679. }
  8680. const speed = 35;
  8681. // RENDER PLAYERS:
  8682. function renderDeadPlayers(xOffset, yOffset) {
  8683. mainContext.fillStyle = "#91b2db";
  8684. const currentTime = Date.now();
  8685. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8686. if (!dead.startTime) {
  8687. dead.startTime = currentTime;
  8688. dead.angle = 0;
  8689. dead.radius = 0.1;
  8690. }
  8691. const timeElapsed = currentTime - dead.startTime;
  8692. const maxAlpha = 1;
  8693. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8694. dead.animate(delta);
  8695. mainContext.globalAlpha = dead.alpha;
  8696. mainContext.strokeStyle = outlineColor;
  8697. mainContext.save();
  8698. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8699. dead.radius -= 0.001;
  8700. dead.angle += 0.0174533;
  8701. const moveSpeed = 1;
  8702. const x = dead.radius * Math.cos(dead.angle);
  8703. const y = dead.radius * Math.sin(dead.angle);
  8704. dead.x += x * moveSpeed;
  8705. dead.y += y * moveSpeed;
  8706. mainContext.rotate(dead.angle);
  8707. renderDeadPlayer(dead, mainContext);
  8708. mainContext.restore();
  8709. mainContext.fillStyle = "#91b2db";
  8710. if (timeElapsed >= 3000) {
  8711. dead.active = false;
  8712. dead.startTime = null;
  8713. }
  8714. });
  8715. }
  8716. // RENDER PLAYERS:
  8717. function renderPlayers(xOffset, yOffset, zIndex) {
  8718. mainContext.globalAlpha = 1;
  8719. mainContext.fillStyle = "#91b2db";
  8720. for (var i = 0; i < players.length; ++i) {
  8721. tmpObj = players[i];
  8722. if (tmpObj.zIndex == zIndex) {
  8723. tmpObj.animate(delta);
  8724. if (tmpObj.visible) {
  8725. tmpObj.skinRot += (0.002 * delta);
  8726. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  8727. mainContext.save();
  8728. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8729. // RENDER PLAYER:
  8730. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8731. renderPlayer(tmpObj, mainContext);
  8732. mainContext.restore();
  8733.  
  8734. }
  8735. }
  8736. }
  8737. }
  8738. // RENDER DEAD PLAYER:
  8739. function renderDeadPlayer(obj, ctxt) {
  8740. ctxt = ctxt || mainContext;
  8741. ctxt.lineWidth = outlineWidth;
  8742. ctxt.lineJoin = "miter";
  8743. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8744. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8745. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8746. // TAIL/CAPE:
  8747. renderTail2(13, ctxt, obj);
  8748. // WEAPON BELLOW HANDS:
  8749. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8750. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8751. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8752. renderProjectile(obj.scale, 0,
  8753. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8754. }
  8755. }
  8756. // HANDS:
  8757. ctxt.fillStyle = "#ececec";
  8758. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8759. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8760. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8761. // WEAPON ABOVE HANDS:
  8762. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8763. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8764. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8765. renderProjectile(obj.scale, 0,
  8766. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8767. }
  8768. }
  8769. // BUILD ITEM:
  8770. if (obj.buildIndex >= 0) {
  8771. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8772. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8773. }
  8774. // BODY:
  8775. renderCircle(0, 0, obj.scale, ctxt);
  8776. // SKIN
  8777. renderSkin2(48, ctxt, null, obj)
  8778. }
  8779.  
  8780. // RENDER PLAYER:
  8781. function renderPlayer(obj, ctxt) {
  8782. ctxt = ctxt || mainContext;
  8783. ctxt.lineWidth = outlineWidth;
  8784. ctxt.lineJoin = "miter";
  8785. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8786. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8787. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8788.  
  8789. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8790.  
  8791. // TAIL/CAPE:
  8792. if (obj.tailIndex > 0) {
  8793. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8794. }
  8795.  
  8796. // WEAPON BELLOW HANDS:
  8797. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8798. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8799. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8800. renderProjectile(obj.scale, 0,
  8801. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8802. }
  8803. }
  8804.  
  8805. // HANDS:
  8806. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8807. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8808. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8809. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8810.  
  8811. // WEAPON ABOVE HANDS:
  8812. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8813. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8814. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8815. renderProjectile(obj.scale, 0,
  8816. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8817. }
  8818. }
  8819.  
  8820. // BUILD ITEM:
  8821. if (obj.buildIndex >= 0) {
  8822. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8823. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8824. }
  8825.  
  8826. // BODY:
  8827. renderCircle(0, 0, obj.scale, ctxt);
  8828.  
  8829. // SKIN:
  8830. if (obj.skinIndex > 0) {
  8831. ctxt.rotate(Math.PI / 2);
  8832. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8833. }
  8834.  
  8835. }
  8836.  
  8837. // RENDER NORMAL SKIN
  8838. var skinSprites2 = {};
  8839. var skinPointers2 = {};
  8840. function renderSkin2(index, ctxt, parentSkin, owner) {
  8841. tmpSkin = skinSprites2[index];
  8842. if (!tmpSkin) {
  8843. var tmpImage = new Image();
  8844. tmpImage.onload = function() {
  8845. this.isLoaded = true;
  8846. this.onload = null;
  8847. };
  8848. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8849. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8850. skinSprites2[index] = tmpImage;
  8851. tmpSkin = tmpImage;
  8852. }
  8853. var tmpObj = parentSkin||skinPointers2[index];
  8854. if (!tmpObj) {
  8855. for (var i = 0; i < hats.length; ++i) {
  8856. if (hats[i].id == index) {
  8857. tmpObj = hats[i];
  8858. break;
  8859. }
  8860. }
  8861. skinPointers2[index] = tmpObj;
  8862. }
  8863. if (tmpSkin.isLoaded)
  8864. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8865. if (!parentSkin && tmpObj.topSprite) {
  8866. ctxt.save();
  8867. ctxt.rotate(owner.skinRot);
  8868. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8869. ctxt.restore();
  8870. }
  8871. }
  8872.  
  8873. // RENDER SKIN:
  8874. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8875. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8876. var tmpImage = new Image();
  8877. tmpImage.onload = function() {
  8878. this.isLoaded = true,
  8879. this.onload = null
  8880. }
  8881. ,
  8882. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8883. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8884. tmpSkin = tmpImage
  8885. }
  8886. var tmpObj = parentSkin||skinPointers[index];
  8887. if (!tmpObj) {
  8888. for (var i = 0; i < hats.length; ++i) {
  8889. if (hats[i].id == index) {
  8890. tmpObj = hats[i];
  8891. break;
  8892. }
  8893. }
  8894. skinPointers[index] = tmpObj;
  8895. }
  8896. if (tmpSkin.isLoaded)
  8897. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8898. if (!parentSkin && tmpObj.topSprite) {
  8899. ctxt.save();
  8900. ctxt.rotate(owner.skinRot);
  8901. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8902. ctxt.restore();
  8903. }
  8904. }
  8905.  
  8906. var FlareZHat = {
  8907. 7: "https://i.imgur.com/vAOzlyY.png",
  8908. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8909. 40: "https://i.imgur.com/Xzmg27N.png",
  8910. 26: "https://i.imgur.com/I0xGtyZ.png",
  8911. 55: "https://i.imgur.com/uYgDtcZ.png",
  8912. 20: "https://i.imgur.com/f5uhWCk.png",
  8913. };
  8914.  
  8915. function setSkinTextureImage(id, type, id2) {
  8916. if (true) {
  8917. if(FlareZHat[id] && type == "hat") {
  8918. return FlareZHat[id];
  8919. } else {
  8920. if(type == "acc") {
  8921. return ".././img/accessories/access_" + id + ".png";
  8922. } else if(type == "hat") {
  8923. return ".././img/hats/hat_" + id + ".png";
  8924. } else {
  8925. return ".././img/weapons/" + id + ".png";
  8926. }
  8927. }
  8928. } else {
  8929. if(type == "acc") {
  8930. return ".././img/accessories/access_" + id + ".png";
  8931. } else if(type == "hat") {
  8932. return ".././img/hats/hat_" + id + ".png";
  8933. } else {
  8934. return ".././img/weapons/" + id + ".png";
  8935. }
  8936. }
  8937. }
  8938. // RENDER SKINS:
  8939. let skinSprites = {};
  8940. let skinPointers = {};
  8941. let tmpSkin;
  8942.  
  8943. function renderSkin(index, ctxt, parentSkin, owner) {
  8944. tmpSkin = skinSprites[index];
  8945. if (!tmpSkin) {
  8946. let tmpImage = new Image();
  8947. tmpImage.onload = function() {
  8948. this.isLoaded = true;
  8949. this.onload = null;
  8950. };
  8951. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8952. skinSprites[index] = tmpImage;
  8953. tmpSkin = tmpImage;
  8954. }
  8955. let tmpObj = parentSkin || skinPointers[index];
  8956. if (!tmpObj) {
  8957. for (let i = 0; i < hats.length; ++i) {
  8958. if (hats[i].id == index) {
  8959. tmpObj = hats[i];
  8960. break;
  8961. }
  8962. }
  8963. skinPointers[index] = tmpObj;
  8964. }
  8965. if (tmpSkin.isLoaded)
  8966. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8967. if (!parentSkin && tmpObj.topSprite) {
  8968. ctxt.save();
  8969. ctxt.rotate(owner.skinRot);
  8970. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8971. ctxt.restore();
  8972. }
  8973. }
  8974.  
  8975. // RENDER TAIL:
  8976. var FlareZAcc = {
  8977. 21: "https://i.imgur.com/4ddZert.png",
  8978. 19: "https://i.imgur.com/sULkUZT.png",
  8979. };
  8980. function setTailTextureImage(id, type, id2) {
  8981. if (true) {
  8982. if(FlareZAcc[id] && type == "acc") {
  8983. return FlareZAcc[id];
  8984. } else {
  8985. if(type == "acc") {
  8986. return ".././img/accessories/access_" + id + ".png";
  8987. } else if(type == "hat") {
  8988. return ".././img/hats/hat_" + id + ".png";
  8989. } else {
  8990. return ".././img/weapons/" + id + ".png";
  8991. }
  8992. }
  8993. } else {
  8994. if(type == "acc") {
  8995. return ".././img/accessories/access_" + id + ".png";
  8996. } else if(type == "hat") {
  8997. return ".././img/hats/hat_" + id + ".png";
  8998. } else {
  8999. return ".././img/weapons/" + id + ".png";
  9000. }
  9001. }
  9002. }
  9003. function renderTailTextureImage(index, ctxt, owner) {
  9004. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  9005. var tmpImage = new Image();
  9006. tmpImage.onload = function() {
  9007. this.isLoaded = true,
  9008. this.onload = null
  9009. }
  9010. ,
  9011. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  9012. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9013. tmpSkin = tmpImage;
  9014. }
  9015. var tmpObj = accessPointers[index];
  9016. if (!tmpObj) {
  9017. for (var i = 0; i < accessories.length; ++i) {
  9018. if (accessories[i].id == index) {
  9019. tmpObj = accessories[i];
  9020. break;
  9021. }
  9022. }
  9023. accessPointers[index] = tmpObj;
  9024. }
  9025. if (tmpSkin.isLoaded) {
  9026. ctxt.save();
  9027. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9028. if (tmpObj.spin)
  9029. ctxt.rotate(owner.skinRot);
  9030. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9031. ctxt.restore();
  9032. }
  9033. }
  9034.  
  9035. let accessSprites = {};
  9036. let accessPointers = {};
  9037. var txt = true;
  9038.  
  9039. function renderTail(index, ctxt, owner) {
  9040. tmpSkin = accessSprites[index];
  9041. if (!tmpSkin) {
  9042. let tmpImage = new Image();
  9043. tmpImage.onload = function() {
  9044. this.isLoaded = true;
  9045. this.onload = null;
  9046. };
  9047. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9048. accessSprites[index] = tmpImage;
  9049. tmpSkin = tmpImage;
  9050. }
  9051. let tmpObj = accessPointers[index];
  9052. if (!tmpObj) {
  9053. for (let i = 0; i < accessories.length; ++i) {
  9054. if (accessories[i].id == index) {
  9055. tmpObj = accessories[i];
  9056. break;
  9057. }
  9058. }
  9059. accessPointers[index] = tmpObj;
  9060. }
  9061. if (tmpSkin.isLoaded) {
  9062. ctxt.save();
  9063. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9064. if (tmpObj.spin)
  9065. ctxt.rotate(owner.skinRot);
  9066. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9067. ctxt.restore();
  9068. }
  9069. }
  9070.  
  9071. var accessSprites2 = {};
  9072. var accessPointers2 = {};
  9073. function renderTail2(index, ctxt, owner) {
  9074. tmpSkin = accessSprites2[index];
  9075. if (!tmpSkin) {
  9076. var tmpImage = new Image();
  9077. tmpImage.onload = function() {
  9078. this.isLoaded = true;
  9079. this.onload = null;
  9080. };
  9081. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9082. accessSprites2[index] = tmpImage;
  9083. tmpSkin = tmpImage;
  9084. }
  9085. var tmpObj = accessPointers2[index];
  9086. if (!tmpObj) {
  9087. for (var i = 0; i < accessories.length; ++i) {
  9088. if (accessories[i].id == index) {
  9089. tmpObj = accessories[i];
  9090. break;
  9091. }
  9092. }
  9093. accessPointers2[index] = tmpObj;
  9094. }
  9095. if (tmpSkin.isLoaded) {
  9096. ctxt.save();
  9097. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9098. if (tmpObj.spin)
  9099. ctxt.rotate(owner.skinRot);
  9100. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9101. ctxt.restore();
  9102. }
  9103. }
  9104.  
  9105. // RENDER TOOL:
  9106. let toolSprites = {};
  9107. function renderTool(obj, variant, x, y, ctxt) {
  9108. let tmpSrc = obj.src + (variant || "");
  9109. let tmpSprite = toolSprites[tmpSrc];
  9110. if (!tmpSprite) {
  9111. tmpSprite = new Image();
  9112. tmpSprite.onload = function() {
  9113. this.isLoaded = true;
  9114. }
  9115. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9116. toolSprites[tmpSrc] = tmpSprite;
  9117. }
  9118. if (tmpSprite.isLoaded)
  9119. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9120. }
  9121.  
  9122. // RENDER PROJECTILES:
  9123. function renderProjectiles(layer, xOffset, yOffset) {
  9124. for (let i = 0; i < projectiles.length; i++) {
  9125. tmpObj = projectiles[i];
  9126. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9127. tmpObj.update(delta);
  9128. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9129. mainContext.save();
  9130. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9131. mainContext.rotate(tmpObj.dir);
  9132. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9133. mainContext.restore();
  9134. }
  9135. }
  9136. };
  9137. }
  9138.  
  9139. // RENDER PROJECTILE:
  9140. let projectileSprites = {};//fz iz zexy
  9141.  
  9142. function renderProjectile(x, y, obj, ctxt, debug) {
  9143. if (obj.src) {
  9144. let tmpSrc = items.projectiles[obj.indx].src;
  9145. let tmpSprite = projectileSprites[tmpSrc];
  9146. if (!tmpSprite) {
  9147. tmpSprite = new Image();
  9148. tmpSprite.onload = function() {
  9149. this.isLoaded = true;
  9150. }
  9151. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9152. projectileSprites[tmpSrc] = tmpSprite;
  9153. }
  9154. if (tmpSprite.isLoaded)
  9155. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9156. } else if (obj.indx == 1) {
  9157. ctxt.fillStyle = "#939393";
  9158. renderCircle(x, y, obj.scale, ctxt);
  9159. }
  9160. }
  9161.  
  9162. // RENDER AI:
  9163. let aiSprites = {};
  9164.  
  9165. function renderAI(obj, ctxt) {
  9166. let tmpIndx = obj.index;
  9167. let tmpSprite = aiSprites[tmpIndx];
  9168. if (!tmpSprite) {
  9169. let tmpImg = new Image();
  9170. tmpImg.onload = function() {
  9171. this.isLoaded = true;
  9172. this.onload = null;
  9173. };
  9174. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9175. tmpSprite = tmpImg;
  9176. aiSprites[tmpIndx] = tmpSprite;
  9177. }
  9178. if (tmpSprite.isLoaded) {
  9179. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9180. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9181. }
  9182. }
  9183.  
  9184. // RENDER WATER BODIES:
  9185. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9186.  
  9187. // MIDDLE RIVER:
  9188. let tmpW = config.riverWidth + padding;
  9189. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9190. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9191. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9192. }
  9193. }
  9194.  
  9195. // RENDER GAME OBJECTS:
  9196. let gameObjectSprites = {};
  9197.  
  9198. function getResSprite(obj) {
  9199. let biomeID =
  9200. obj.y >= config.mapScale - config.snowBiomeTop
  9201. ? 2
  9202. : obj.y <= config.snowBiomeTop
  9203. ? 1
  9204. : 0;
  9205. let tmpIndex = obj.type + "_" + obj.scale + "_" + biomeID;
  9206. let tmpSprite = gameObjectSprites[tmpIndex];
  9207. if (!tmpSprite) {
  9208. let blurScale = 6;
  9209. let tmpCanvas = document.createElement("canvas");
  9210. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.1 + outlineWidth;
  9211. let tmpContext = tmpCanvas.getContext("2d");
  9212. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9213. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9214. tmpContext.strokeStyle = outlineColor;
  9215. tmpContext.lineWidth = outlineWidth;
  9216. // if (isNight) {
  9217. // tmpContext.shadowBlur = blurScale;
  9218. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9219. // }
  9220. if (obj.type == 0) {
  9221. let tmpScale;
  9222. let tmpCount = 8;
  9223. tmpContext.globalAlpha = cdf(obj, player) <= 250 ? 0.6 : 1;
  9224. for (let i = 0; i < 2; ++i) {
  9225. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  9226. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9227. tmpContext.fillStyle = !biomeID
  9228. ? !i
  9229. ? "#9ebf57"
  9230. : "#b4db62"
  9231. : !i
  9232. ? "#e3f1f4"
  9233. : "#fff";
  9234. tmpContext.fill();
  9235. if (!i) {
  9236. tmpContext.stroke();
  9237. tmpContext.shadowBlur = null;
  9238. tmpContext.shadowColor = null;
  9239. tmpContext.globalAlpha = 1;
  9240. }
  9241. }
  9242. } else if (obj.type == 1) {
  9243. if (biomeID == 2) {
  9244. tmpContext.fillStyle = "#606060";
  9245. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9246. tmpContext.fill();
  9247. tmpContext.stroke();
  9248.  
  9249. //tmpContext.shadowBlur = null;
  9250. //tmpContext.shadowColor = null;
  9251.  
  9252. tmpContext.fillStyle = "#89A54C";
  9253. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9254. tmpContext.fillStyle = "#a5c65b";
  9255. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9256. } else {
  9257. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9258. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  9259. tmpContext.fill();
  9260. tmpContext.stroke();
  9261.  
  9262. //tmpContext.shadowBlur = null;
  9263. //tmpContext.shadowColor = null;
  9264.  
  9265. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  9266. let tmpRange;
  9267. let berries = 4;
  9268. let rotVal = (Math.PI * 2) / berries;
  9269. for (let i = 0; i < berries; ++i) {
  9270. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  9271. renderCircle(
  9272. tmpRange * Math.cos(rotVal * i),
  9273. tmpRange * Math.sin(rotVal * i),
  9274. UTILS.randInt(10, 12),
  9275. tmpContext
  9276. );
  9277. }
  9278. }
  9279. } else if (obj.type == 2 || obj.type == 3) {
  9280. tmpContext.fillStyle =
  9281. obj.type == 2 ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  9282. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9283. tmpContext.fill();
  9284. tmpContext.stroke();
  9285.  
  9286. tmpContext.shadowBlur = null;
  9287. tmpContext.shadowColor = null;
  9288.  
  9289. tmpContext.fillStyle =
  9290. obj.type == 2 ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  9291. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9292. tmpContext.fill();
  9293. }
  9294. tmpSprite = tmpCanvas;
  9295. gameObjectSprites[tmpIndex] = tmpSprite;
  9296. }
  9297. return tmpSprite;
  9298. }
  9299.  
  9300. // GET ITEM SPRITE:
  9301. let itemSprites = [];
  9302.  
  9303. function getItemSprite(obj, asIcon) {
  9304. let tmpSprite = itemSprites[obj.id];
  9305. if (!tmpSprite || asIcon) {
  9306. let blurScale = !asIcon ? 20 : 5;
  9307. let tmpCanvas = document.createElement("canvas");
  9308. let reScale =
  9309. !asIcon && obj.name == "windmill" ? items.list[4].scale : obj.scale;
  9310. tmpCanvas.width = tmpCanvas.height =
  9311. reScale * 2.5 +
  9312. outlineWidth +
  9313. (items.list[obj.id].spritePadding || 0) +
  9314. blurScale;
  9315.  
  9316. let tmpContext = tmpCanvas.getContext("2d");
  9317. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9318. tmpContext.rotate(asIcon ? 0 : Math.PI / 2);
  9319. tmpContext.strokeStyle = outlineColor;
  9320. tmpContext.lineWidth = outlineWidth * (asIcon ? tmpCanvas.width / 81 : 1);
  9321. if (!asIcon) {
  9322. tmpContext.shadowBlur = 8;
  9323. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  9324. }
  9325.  
  9326. if (obj.name == "apple") {
  9327. tmpContext.fillStyle = "#c15555";
  9328. renderCircle(0, 0, obj.scale, tmpContext);
  9329. tmpContext.fillStyle = "#89a54c";
  9330. let leafDir = -(Math.PI / 2);
  9331. renderLeaf(
  9332. obj.scale * Math.cos(leafDir),
  9333. obj.scale * Math.sin(leafDir),
  9334. 25,
  9335. leafDir + Math.PI / 2,
  9336. tmpContext
  9337. );
  9338. } else if (obj.name == "cookie") {
  9339. tmpContext.fillStyle = "#cca861";
  9340. renderCircle(0, 0, obj.scale, tmpContext);
  9341. tmpContext.fillStyle = "#937c4b";
  9342. let chips = 4;
  9343. let rotVal = (Math.PI * 2) / chips;
  9344. let tmpRange;
  9345. for (let i = 0; i < chips; ++i) {
  9346. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9347. renderCircle(
  9348. tmpRange * Math.cos(rotVal * i),
  9349. tmpRange * Math.sin(rotVal * i),
  9350. UTILS.randInt(4, 5),
  9351. tmpContext,
  9352. true
  9353. );
  9354. }
  9355. } else if (obj.name == "cheese") {
  9356. tmpContext.fillStyle = "#f4f3ac";
  9357. renderCircle(0, 0, obj.scale, tmpContext);
  9358. tmpContext.fillStyle = "#c3c28b";
  9359. let chips = 4;
  9360. let rotVal = (Math.PI * 2) / chips;
  9361. let tmpRange;
  9362. for (let i = 0; i < chips; ++i) {
  9363. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9364. renderCircle(
  9365. tmpRange * Math.cos(rotVal * i),
  9366. tmpRange * Math.sin(rotVal * i),
  9367. UTILS.randInt(4, 5),
  9368. tmpContext,
  9369. true
  9370. );
  9371. }
  9372. } else if (
  9373. obj.name == "wood wall" ||
  9374. obj.name == "stone wall" ||
  9375. obj.name == "castle wall"
  9376. ) {
  9377. tmpContext.fillStyle =
  9378. obj.name == "castle wall"
  9379. ? "#83898e"
  9380. : obj.name == "wood wall"
  9381. ? "#a5974c"
  9382. : "#939393";
  9383. let sides = obj.name == "castle wall" ? 4 : 3;
  9384. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9385. tmpContext.fill();
  9386. tmpContext.stroke();
  9387. tmpContext.fillStyle =
  9388. obj.name == "castle wall"
  9389. ? "#9da4aa"
  9390. : obj.name == "wood wall"
  9391. ? "#c9b758"
  9392. : "#bcbcbc";
  9393. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9394. tmpContext.fill();
  9395. } else if (
  9396. obj.name == "spikes" ||
  9397. obj.name == "greater spikes" ||
  9398. obj.name == "poison spikes" ||
  9399. obj.name == "spinning spikes"
  9400. ) {
  9401. tmpContext.fillStyle =
  9402. obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9403. let tmpScale = obj.scale * 0.6;
  9404. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9405. tmpContext.fill();
  9406. tmpContext.stroke();
  9407. tmpContext.fillStyle = "#a5974c";
  9408. renderCircle(0, 0, tmpScale, tmpContext);
  9409. tmpContext.fillStyle = "#c9b758";
  9410. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9411. } else if (
  9412. obj.name == "windmill" ||
  9413. obj.name == "faster windmill" ||
  9414. obj.name == "power mill"
  9415. ) {
  9416. tmpContext.fillStyle = "#a5974c";
  9417. renderCircle(0, 0, reScale, tmpContext);
  9418. tmpContext.fillStyle = "#c9b758";
  9419. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9420. tmpContext.fillStyle = "#a5974c";
  9421. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9422. } else if (obj.name == "mine") {
  9423. tmpContext.fillStyle = "#939393";
  9424. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9425. tmpContext.fill();
  9426. tmpContext.stroke();
  9427. tmpContext.fillStyle = "#bcbcbc";
  9428. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9429. tmpContext.fill();
  9430. } else if (obj.name == "sapling") {
  9431. for (let i = 0; i < 2; ++i) {
  9432. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9433. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9434. tmpContext.fillStyle = !i ? "#9ebf57" : "#b4db62";
  9435. tmpContext.fill();
  9436. if (!i) tmpContext.stroke();
  9437. }
  9438. } else if (obj.name == "pit trap") {
  9439. tmpContext.fillStyle = "#a5974c";
  9440. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9441. tmpContext.fill();
  9442. tmpContext.stroke();
  9443. tmpContext.fillStyle = outlineColor;
  9444. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9445. tmpContext.fill();
  9446. } else if (obj.name == "boost pad") {
  9447. tmpContext.fillStyle = "#7e7f82";
  9448. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9449. tmpContext.fill();
  9450. tmpContext.stroke();
  9451. tmpContext.fillStyle = "#dbd97d";
  9452. renderTriangle(obj.scale * 1, tmpContext);
  9453. } else if (obj.name == "turret") {
  9454. tmpContext.fillStyle = "#a5974c";
  9455. renderCircle(0, 0, obj.scale, tmpContext);
  9456. tmpContext.fill();
  9457. tmpContext.stroke();
  9458. tmpContext.fillStyle = "#939393";
  9459. let tmpLen = 50;
  9460. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9461. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9462. tmpContext.fill();
  9463. tmpContext.stroke();
  9464. } else if (obj.name == "platform") {
  9465. tmpContext.fillStyle = "#cebd5f";
  9466. let tmpCount = 4;
  9467. let tmpS = obj.scale * 2;
  9468. let tmpW = tmpS / tmpCount;
  9469. let tmpX = -(obj.scale / 2);
  9470. for (let i = 0; i < tmpCount; ++i) {
  9471. renderRect(tmpX - tmpW / 2, 0, tmpW, obj.scale * 2, tmpContext);
  9472. tmpContext.fill();
  9473. tmpContext.stroke();
  9474. tmpX += tmpS / tmpCount;
  9475. }
  9476. } else if (obj.name == "healing pad") {
  9477. tmpContext.fillStyle = "#7e7f82";
  9478. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9479. tmpContext.fill();
  9480. tmpContext.stroke();
  9481. tmpContext.fillStyle = "#db6e6e";
  9482. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9483. } else if (obj.name == "spawn pad") {
  9484. tmpContext.fillStyle = "#7e7f82";
  9485. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9486. tmpContext.fill();
  9487. tmpContext.stroke();
  9488. tmpContext.fillStyle = "#71aad6";
  9489. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9490. } else if (obj.name == "blocker") {
  9491. tmpContext.fillStyle = "#7e7f82";
  9492. renderCircle(0, 0, obj.scale, tmpContext);
  9493. tmpContext.fill();
  9494. tmpContext.stroke();
  9495. tmpContext.rotate(Math.PI / 4);
  9496. tmpContext.fillStyle = "#db6e6e";
  9497. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9498. } else if (obj.name == "teleporter") {
  9499. tmpContext.fillStyle = "#7e7f82";
  9500. renderCircle(0, 0, obj.scale, tmpContext);
  9501. tmpContext.fill();
  9502. tmpContext.stroke();
  9503. tmpContext.rotate(Math.PI / 4);
  9504. tmpContext.fillStyle = "#d76edb";
  9505. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9506. }
  9507. tmpSprite = tmpCanvas;
  9508. if (!asIcon) itemSprites[obj.id] = tmpSprite;
  9509. }
  9510. return tmpSprite;
  9511. }
  9512.  
  9513. function getItemSprite2(obj, tmpX, tmpY) {
  9514. let tmpContext = mainContext;
  9515. let reScale = obj.name == "windmill" ? items.list[4].scale : obj.scale;
  9516. tmpContext.save();
  9517. tmpContext.translate(tmpX, tmpY);
  9518. tmpContext.rotate(obj.dir);
  9519. tmpContext.strokeStyle = outlineColor;
  9520. tmpContext.lineWidth = outlineWidth;
  9521. if (obj.name == "apple") {
  9522. tmpContext.fillStyle = "#c15555";
  9523. renderCircle(0, 0, obj.scale, tmpContext);
  9524. tmpContext.fillStyle = "#89a54c";
  9525. let leafDir = -(Math.PI / 2);
  9526. renderLeaf(
  9527. obj.scale * Math.cos(leafDir),
  9528. obj.scale * Math.sin(leafDir),
  9529. 25,
  9530. leafDir + Math.PI / 2,
  9531. tmpContext
  9532. );
  9533. } else if (obj.name == "cookie") {
  9534. tmpContext.fillStyle = "#cca861";
  9535. renderCircle(0, 0, obj.scale, tmpContext);
  9536. tmpContext.fillStyle = "#937c4b";
  9537. let chips = 4;
  9538. let rotVal = (Math.PI * 2) / chips;
  9539. let tmpRange;
  9540. for (let i = 0; i < chips; ++i) {
  9541. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9542. renderCircle(
  9543. tmpRange * Math.cos(rotVal * i),
  9544. tmpRange * Math.sin(rotVal * i),
  9545. UTILS.randInt(4, 5),
  9546. tmpContext,
  9547. true
  9548. );
  9549. }
  9550. } else if (obj.name == "cheese") {
  9551. tmpContext.fillStyle = "#f4f3ac";
  9552. renderCircle(0, 0, obj.scale, tmpContext);
  9553. tmpContext.fillStyle = "#c3c28b";
  9554. let chips = 4;
  9555. let rotVal = (Math.PI * 2) / chips;
  9556. let tmpRange;
  9557. for (let i = 0; i < chips; ++i) {
  9558. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9559. renderCircle(
  9560. tmpRange * Math.cos(rotVal * i),
  9561. tmpRange * Math.sin(rotVal * i),
  9562. UTILS.randInt(4, 5),
  9563. tmpContext,
  9564. true
  9565. );
  9566. }
  9567. } else if (
  9568. obj.name == "wood wall" ||
  9569. obj.name == "stone wall" ||
  9570. obj.name == "castle wall"
  9571. ) {
  9572. tmpContext.fillStyle =
  9573. obj.name == "castle wall"
  9574. ? "#83898e"
  9575. : obj.name == "wood wall"
  9576. ? "#a5974c"
  9577. : "#939393";
  9578. let sides = obj.name == "castle wall" ? 4 : 3;
  9579. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9580. tmpContext.fill();
  9581. tmpContext.stroke();
  9582. tmpContext.fillStyle =
  9583. obj.name == "castle wall"
  9584. ? "#9da4aa"
  9585. : obj.name == "wood wall"
  9586. ? "#c9b758"
  9587. : "#bcbcbc";
  9588. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9589. tmpContext.fill();
  9590. } else if (
  9591. obj.name == "spikes" ||
  9592. obj.name == "greater spikes" ||
  9593. obj.name == "poison spikes" ||
  9594. obj.name == "spinning spikes"
  9595. ) {
  9596. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9597. let tmpScale = obj.scale * 0.6;
  9598. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9599. tmpContext.fill();
  9600. tmpContext.stroke();
  9601. tmpContext.fillStyle = "#a5974c";
  9602. renderCircle(0, 0, tmpScale, tmpContext);
  9603. tmpContext.fillStyle = "#c9b758";
  9604. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9605. } else if (
  9606. obj.name == "windmill" ||
  9607. obj.name == "faster windmill" ||
  9608. obj.name == "power mill"
  9609. ) {
  9610. tmpContext.fillStyle = "#a5974c";
  9611. renderCircle(0, 0, reScale, tmpContext);
  9612. tmpContext.fillStyle = "#c9b758";
  9613. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9614. tmpContext.fillStyle = "#a5974c";
  9615. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9616. } else if (obj.name == "mine") {
  9617. tmpContext.fillStyle = "#939393";
  9618. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9619. tmpContext.fill();
  9620. tmpContext.stroke();
  9621. tmpContext.fillStyle = "#bcbcbc";
  9622. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9623. tmpContext.fill();
  9624. } else if (obj.name == "sapling") {
  9625. for (let i = 0; i < 2; ++i) {
  9626. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9627. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9628. tmpContext.fillStyle = !i ? "#9ebf57" : "#b4db62";
  9629. tmpContext.fill();
  9630. if (!i) tmpContext.stroke();
  9631. }
  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 = outlineColor;
  9638. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9639. tmpContext.fill();
  9640. } else if (obj.name == "boost pad") {
  9641. tmpContext.fillStyle = "#7e7f82";
  9642. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9643. tmpContext.fill();
  9644. tmpContext.stroke();
  9645. tmpContext.fillStyle = "#dbd97d";
  9646. renderTriangle(obj.scale * 1, tmpContext);
  9647. } else if (obj.name == "turret") {
  9648. tmpContext.fillStyle = "#a5974c";
  9649. renderCircle(0, 0, obj.scale, tmpContext);
  9650. tmpContext.fill();
  9651. tmpContext.stroke();
  9652. tmpContext.fillStyle = "#939393";
  9653. let tmpLen = 50;
  9654. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9655. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9656. tmpContext.fill();
  9657. tmpContext.stroke();
  9658. } else if (obj.name == "platform") {
  9659. tmpContext.fillStyle = "#cebd5f";
  9660. let tmpCount = 4;
  9661. let tmpS = obj.scale * 2;
  9662. let tmpW = tmpS / tmpCount;
  9663. let tmpX = -(obj.scale / 2);
  9664. for (let i = 0; i < tmpCount; ++i) {
  9665. renderRect(tmpX - tmpW / 2, 0, tmpW, obj.scale * 2, tmpContext);
  9666. tmpContext.fill();
  9667. tmpContext.stroke();
  9668. tmpX += tmpS / tmpCount;
  9669. }
  9670. } else if (obj.name == "healing pad") {
  9671. tmpContext.fillStyle = "#7e7f82";
  9672. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9673. tmpContext.fill();
  9674. tmpContext.stroke();
  9675. tmpContext.fillStyle = "#db6e6e";
  9676. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9677. } else if (obj.name == "spawn pad") {
  9678. tmpContext.fillStyle = "#7e7f82";
  9679. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9680. tmpContext.fill();
  9681. tmpContext.stroke();
  9682. tmpContext.fillStyle = "#71aad6";
  9683. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9684. } else if (obj.name == "blocker") {
  9685. tmpContext.fillStyle = "#7e7f82";
  9686. renderCircle(0, 0, obj.scale, tmpContext);
  9687. tmpContext.fill();
  9688. tmpContext.stroke();
  9689. tmpContext.rotate(Math.PI / 4);
  9690. tmpContext.fillStyle = "#db6e6e";
  9691. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9692. } else if (obj.name == "teleporter") {
  9693. tmpContext.fillStyle = "#7e7f82";
  9694. renderCircle(0, 0, obj.scale, tmpContext);
  9695. tmpContext.fill();
  9696. tmpContext.stroke();
  9697. tmpContext.rotate(Math.PI / 4);
  9698. tmpContext.fillStyle = "#d76edb";
  9699. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9700. }
  9701. tmpContext.restore();
  9702. }
  9703.  
  9704. let objSprites = [];
  9705.  
  9706. function getObjSprite(obj) {
  9707. let tmpSprite = objSprites[obj.id];
  9708. if (!tmpSprite) {
  9709. // let blurScale = isNight ? 20 : 0;
  9710. let tmpCanvas = document.createElement("canvas");
  9711. tmpCanvas.width = tmpCanvas.height =
  9712. obj.scale * 2.5 +
  9713. outlineWidth +
  9714. (items.list[obj.id].spritePadding || 0) +
  9715. 0;
  9716. let tmpContext = tmpCanvas.getContext("2d");
  9717. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9718. tmpContext.rotate(Math.PI / 2);
  9719. tmpContext.strokeStyle = outlineColor;
  9720. tmpContext.lineWidth = outlineWidth;
  9721. // if (isNight) {
  9722. // tmpContext.shadowBlur = 20;
  9723. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9724. // }
  9725. if (
  9726. obj.name == "spikes" ||
  9727. obj.name == "greater spikes" ||
  9728. obj.name == "poison spikes" ||
  9729. obj.name == "spinning spikes"
  9730. ) {
  9731. tmpContext.fillStyle =
  9732. obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9733. let tmpScale = obj.scale * 0.6;
  9734. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9735. tmpContext.fill();
  9736. tmpContext.stroke();
  9737. tmpContext.fillStyle = "#a5974c";
  9738. renderCircle(0, 0, tmpScale, tmpContext);
  9739. tmpContext.fillStyle = "#c9b758";
  9740. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9741. } else if (obj.name == "pit trap") {
  9742. tmpContext.fillStyle = "#a5974c";
  9743. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9744. tmpContext.fill();
  9745. tmpContext.stroke();
  9746. tmpContext.fillStyle = outlineColor;
  9747. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9748. tmpContext.fill();
  9749. }
  9750. tmpSprite = tmpCanvas;
  9751. objSprites[obj.id] = tmpSprite;
  9752. }
  9753. return tmpSprite;
  9754. }
  9755.  
  9756. // GET MARK SPRITE:
  9757. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9758. let center = {
  9759. x: screenWidth / 2,
  9760. y: screenHeight / 2,
  9761. };
  9762. tmpContext.lineWidth = outlineWidth;
  9763. mainContext.globalAlpha = 0.2;
  9764. tmpContext.strokeStyle = outlineColor;
  9765. tmpContext.save();
  9766. tmpContext.translate(tmpX, tmpY);
  9767. tmpContext.rotate(90 ** 10);
  9768. if (
  9769. obj.name == "spikes" ||
  9770. obj.name == "greater spikes" ||
  9771. obj.name == "poison spikes" ||
  9772. obj.name == "spinning spikes"
  9773. ) {
  9774. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9775. var tmpScale = obj.scale;
  9776. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9777. tmpContext.fill();
  9778. tmpContext.stroke();
  9779. tmpContext.fillStyle = "#a5974c";
  9780. renderCircle(0, 0, tmpScale, tmpContext);
  9781. if (
  9782. player &&
  9783. obj.owner &&
  9784. player.sid != obj.owner.sid &&
  9785. !tmpObj.findAllianceBySid(obj.owner.sid)
  9786. ) {
  9787. tmpContext.fillStyle = "#a34040";
  9788. } else {
  9789. tmpContext.fillStyle = "#c9b758";
  9790. }
  9791. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9792. } else if (obj.name == "turret") {
  9793. renderCircle(0, 0, obj.scale, tmpContext);
  9794. tmpContext.fill();
  9795. tmpContext.stroke();
  9796. tmpContext.fillStyle = "#939393";
  9797. let tmpLen = 50;
  9798. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9799. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9800. tmpContext.fill();
  9801. tmpContext.stroke();
  9802. } else if (obj.name == "teleporter") {
  9803. tmpContext.fillStyle = "#7e7f82";
  9804. renderCircle(0, 0, obj.scale, tmpContext);
  9805. tmpContext.fill();
  9806. tmpContext.stroke();
  9807. tmpContext.rotate(Math.PI / 4);
  9808. tmpContext.fillStyle = "#d76edb";
  9809. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9810. } else if (obj.name == "platform") {
  9811. tmpContext.fillStyle = "#cebd5f";
  9812. let tmpCount = 4;
  9813. let tmpS = obj.scale * 2;
  9814. let tmpW = tmpS / tmpCount;
  9815. let tmpX = -(obj.scale / 2);
  9816. for (let i = 0; i < tmpCount; ++i) {
  9817. renderRect(tmpX - tmpW / 2, 0, tmpW, obj.scale * 2, tmpContext);
  9818. tmpContext.fill();
  9819. tmpContext.stroke();
  9820. tmpX += tmpS / tmpCount;
  9821. }
  9822. } else if (obj.name == "healing pad") {
  9823. tmpContext.fillStyle = "#7e7f82";
  9824. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9825. tmpContext.fill();
  9826. tmpContext.stroke();
  9827. tmpContext.fillStyle = "#db6e6e";
  9828. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9829. } else if (obj.name == "spawn pad") {
  9830. tmpContext.fillStyle = "#7e7f82";
  9831. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9832. tmpContext.fill();
  9833. tmpContext.stroke();
  9834. tmpContext.fillStyle = "#71aad6";
  9835. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9836. } else if (obj.name == "blocker") {
  9837. tmpContext.fillStyle = "#7e7f82";
  9838. renderCircle(0, 0, obj.scale, tmpContext);
  9839. tmpContext.fill();
  9840. tmpContext.stroke();
  9841. tmpContext.rotate(Math.PI / 4);
  9842. tmpContext.fillStyle = "#db6e6e";
  9843. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9844. } else if (
  9845. obj.name == "windmill" ||
  9846. obj.name == "faster windmill" ||
  9847. obj.name == "power mill"
  9848. ) {
  9849. tmpContext.fillStyle = "#a5974c";
  9850. renderCircle(0, 0, obj.scale, tmpContext);
  9851. tmpContext.fillStyle = "#c9b758";
  9852. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9853. tmpContext.fillStyle = "#a5974c";
  9854. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9855. } else if (obj.name == "pit trap") {
  9856. tmpContext.fillStyle = "#a5974c";
  9857. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9858. tmpContext.fill();
  9859. tmpContext.stroke();
  9860. if (
  9861. player &&
  9862. obj.owner &&
  9863. player.sid != obj.owner.sid &&
  9864. !tmpObj.findAllianceBySid(obj.owner.sid)
  9865. ) {
  9866. tmpContext.fillStyle = "#a34040";
  9867. } else {
  9868. tmpContext.fillStyle = outlineColor;
  9869. }
  9870. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9871. tmpContext.fill();
  9872. }
  9873. tmpContext.restore();
  9874. }
  9875.  
  9876. // OBJECT ON SCREEN:
  9877. function isOnScreen(x, y, s) {
  9878. return (
  9879. x + s >= 0 &&
  9880. x - s <= maxScreenWidth &&
  9881. y + s >= 0 &&
  9882. (y, s, maxScreenHeight)
  9883. );
  9884. }
  9885.  
  9886. // RENDER GAME OBJECTS:
  9887. function renderGameObjects(layer, xOffset, yOffset) {
  9888. let tmpSprite;
  9889. let tmpX;
  9890. let tmpY;
  9891. liztobj.forEach((tmp) => {
  9892. tmpObj = tmp;
  9893. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9894. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9895. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9896. if (layer == 0) {
  9897. tmpObj.update(delta);
  9898. }
  9899. mainContext.globalAlpha = tmpObj.alpha;
  9900. if (
  9901. tmpObj.layer == layer &&
  9902. isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))
  9903. ) {
  9904. if (tmpObj.isItem) {
  9905. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9906. tmpSprite = getObjSprite(tmpObj);
  9907. } else {
  9908. tmpSprite = getItemSprite(tmpObj);
  9909. }
  9910.  
  9911. mainContext.save();
  9912. mainContext.translate(tmpX, tmpY);
  9913. mainContext.rotate(tmpObj.dir);
  9914. if (!tmpObj.active) {
  9915. mainContext.scale(
  9916. tmpObj.visScale / tmpObj.scale,
  9917. tmpObj.visScale / tmpObj.scale
  9918. );
  9919. }
  9920. mainContext.drawImage(
  9921. tmpSprite,
  9922. -(tmpSprite.width / 2),
  9923. -(tmpSprite.height / 2)
  9924. );
  9925.  
  9926. if (tmpObj.blocker) {
  9927. mainContext.strokeStyle = "#db6e6e";
  9928. mainContext.globalAlpha = 0.3;
  9929. mainContext.lineWidth = 6;
  9930. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9931. }
  9932. mainContext.restore();
  9933. } else {
  9934. tmpSprite = getResSprite(tmpObj);
  9935. mainContext.drawImage(
  9936. tmpSprite,
  9937. tmpX - tmpSprite.width / 2,
  9938. tmpY - tmpSprite.height / 2
  9939. );
  9940. }
  9941. }
  9942. if (layer == 3) {
  9943. if (tmpObj.health < tmpObj.maxHealth) {
  9944. // HEALTH HOLDER:
  9945. mainContext.fillStyle = "rgba(0, 0, 0, 0)"; // Transparent fill style
  9946. mainContext.roundRect(
  9947. tmpX - config.healthBarWidth / 2 - config.healthBarPad,
  9948. tmpY - config.healthBarPad,
  9949. config.healthBarWidth + config.healthBarPad * 2,
  9950. 17,
  9951. 8
  9952. );
  9953. mainContext.fill();
  9954.  
  9955. // HEALTH BAR:
  9956. mainContext.fillStyle = "rgba(0, 0, 0, 0)"; // Transparent fill style
  9957. mainContext.roundRect(
  9958. tmpX - config.healthBarWidth / 2,
  9959. tmpY,
  9960. config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth),
  9961. 17 - config.healthBarPad * 2,
  9962. 7
  9963. );
  9964. mainContext.fill();
  9965. }
  9966. }
  9967. }
  9968. });
  9969.  
  9970. // PLACE VISIBLE:
  9971. if (layer == 0) {
  9972. if (placeVisible.length) {
  9973. placeVisible.forEach((places) => {
  9974. tmpX = places.x - xOffset;
  9975. tmpY = places.y - yOffset;
  9976. markObject(places, tmpX, tmpY);
  9977. });
  9978. }
  9979. }
  9980. }
  9981.  
  9982. function markObject(tmpObj, tmpX, tmpY) {
  9983. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9984. }
  9985.  
  9986. // RENDER MINIMAP:
  9987. class MapPing {
  9988. constructor(color, scale) {
  9989. this.init = function(x, y) {
  9990. this.scale = 0;
  9991. this.x = x;
  9992. this.y = y;
  9993. this.active = true;
  9994. };
  9995. this.update = function(ctxt, delta) {
  9996. if (this.active) {
  9997. this.scale += 0.05 * delta;
  9998. if (this.scale >= scale) {
  9999. this.active = false;
  10000. } else {
  10001. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10002. ctxt.beginPath();
  10003. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  10004. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10005. ctxt.stroke();
  10006. }
  10007. }
  10008. };
  10009. this.color = color;
  10010. }
  10011. }
  10012.  
  10013. function pingMap(x, y) {
  10014. tmpPing = mapPings.find(pings => !pings.active);
  10015. if (!tmpPing) {
  10016. tmpPing = new MapPing("#fff", config.mapPingScale);
  10017. mapPings.push(tmpPing);
  10018. }
  10019. tmpPing.init(x, y);
  10020. }
  10021.  
  10022. function updateMapMarker() {
  10023. mapMarker.x = player.x;
  10024. mapMarker.y = player.y;
  10025. }
  10026.  
  10027. function renderMinimap(delta) {
  10028. if (player && player.alive) {
  10029. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10030.  
  10031. // RENDER PINGS:
  10032. mapContext.lineWidth = 4;
  10033. for (let i = 0; i < mapPings.length; ++i) {
  10034. tmpPing = mapPings[i];
  10035. mapContext.strokeStyle = tmpPing.color;
  10036. tmpPing.update(mapContext, delta);
  10037. }
  10038.  
  10039. // RENDER BREAK TRACKS:
  10040. mapContext.globalAlpha = 1;
  10041. mapContext.fillStyle = "#ff0000";
  10042. if (breakTrackers.length) {
  10043. mapContext.fillStyle = "#abcdef";
  10044. mapContext.font = "34px HammerSmith One";
  10045. mapContext.textBaseline = "middle";
  10046. mapContext.textAlign = "center";
  10047. for (let i = 0; i < breakTrackers.length;) {
  10048. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  10049. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  10050. i += 2;
  10051. }
  10052. }
  10053.  
  10054. // RENDER PLAYERS:
  10055. mapContext.globalAlpha = 1;
  10056. mapContext.fillStyle = "#fff";
  10057. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10058. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10059. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10060. if (player.team && minimapData) {
  10061. for (let i = 0; i < minimapData.length;) {
  10062. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10063. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10064. i += 2;
  10065. }
  10066. }
  10067.  
  10068. // RENDER BOTS:
  10069. if (bots.length) {
  10070. bots.forEach((tmp) => {
  10071. if (tmp.inGame) {
  10072. mapContext.globalAlpha = 1;
  10073. mapContext.strokeStyle = "#cc5151";
  10074. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10075. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10076. }
  10077. });
  10078. }
  10079.  
  10080. // DEATH LOCATION:
  10081. if (lastDeath) {
  10082. mapContext.fillStyle = "#fc5553";
  10083. mapContext.font = "34px HammerSmith One";
  10084. mapContext.textBaseline = "middle";
  10085. mapContext.textAlign = "center";
  10086. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10087. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10088. }
  10089.  
  10090. // MAP MARKER:
  10091. if (mapMarker) {
  10092. mapContext.fillStyle = "#fff";
  10093. mapContext.font = "34px HammerSmith One";
  10094. mapContext.textBaseline = "middle";
  10095. mapContext.textAlign = "center";
  10096. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10097. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10098. }
  10099. }
  10100. }
  10101.  
  10102. // ICONS:
  10103. 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&"];
  10104. let crossHairSprites = {};
  10105. let iconSprites = {};
  10106. let icons = ["crown", "skull"];
  10107.  
  10108. function loadIcons() {
  10109. for (let i = 0; i < icons.length; ++i) {
  10110. let tmpSprite = new Image();
  10111. tmpSprite.onload = function() {
  10112. this.isLoaded = true;
  10113. };
  10114. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10115. iconSprites[icons[i]] = tmpSprite;
  10116. }
  10117. for (let i = 0; i < crossHairs.length; ++i) {
  10118. let tmpSprite = new Image();
  10119. tmpSprite.onload = function() {
  10120. this.isLoaded = true;
  10121. };
  10122. tmpSprite.src = crossHairs[i];
  10123. crossHairSprites[i] = tmpSprite;
  10124. }
  10125. }
  10126. loadIcons();
  10127.  
  10128. function cdf (e, t){
  10129. try {
  10130. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  10131. } catch(e){
  10132. return Infinity;
  10133. }
  10134. }
  10135. // UPDATE GAME:
  10136. function updateGame() {
  10137. if(gameObjects.length && inGame) {
  10138. gameObjects.forEach((tmp) => {
  10139. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  10140. if(!liztobj.includes(tmp)) {
  10141. liztobj.push(tmp);
  10142. tmp.render = true;
  10143. }
  10144. } else {
  10145. if(liztobj.includes(tmp)) {
  10146. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10147. tmp.render = false;
  10148. const index = liztobj.indexOf(tmp);
  10149. if (index > -1) { // only splice array when item is found
  10150. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10151. }
  10152. }
  10153. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10154. tmp.render = false;
  10155. const index = liztobj.indexOf(tmp);
  10156. if (index > -1) { // only splice array when item is found
  10157. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10158. }
  10159. } else {
  10160. tmp.render = false;
  10161. const index = liztobj.indexOf(tmp);
  10162. if (index > -1) { // only splice array when item is found
  10163. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10164. }
  10165. }
  10166. }
  10167. })
  10168. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10169. }
  10170.  
  10171. // if (config.resetRender) {
  10172. mainContext.beginPath();
  10173. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10174. // }
  10175. mainContext.globalAlpha = 1;
  10176.  
  10177. // MOVE CAMERA:
  10178. if (player) {
  10179. if (false) {
  10180. camX = player.x;
  10181. camY = player.y;
  10182. } else {
  10183. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10184. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10185. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  10186. if (tmpDist > 0.05) {
  10187. camX += camSpd * Math.cos(tmpDir);
  10188. camY += camSpd * Math.sin(tmpDir);
  10189. } else {
  10190. camX = player.x;
  10191. camY = player.y;
  10192. }
  10193. }
  10194. } else {
  10195. camX = config.mapScale / 2 + config.riverWidth;
  10196. camY = config.mapScale / 2;
  10197. }
  10198. // PATHFINDER LINE
  10199. if (pathFind.active) {
  10200. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10201. mainContext.lineWidth = player.scale / 5;
  10202. mainContext.globalAlpha = 1;
  10203. mainContext.strokeStyle = "red";
  10204. mainContext.beginPath();
  10205. pathFind.array.forEach((path, i) => {
  10206. let pathXY = {
  10207. x: (pathFind.scale / pathFind.grid) * path.x,
  10208. y: (pathFind.scale / pathFind.grid) * path.y
  10209. }
  10210. let render = {
  10211. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10212. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10213. }
  10214. if (i == 0) {
  10215. mainContext.moveTo(render.x, render.y);
  10216. } else {
  10217. mainContext.lineTo(render.x, render.y);
  10218. }
  10219. });
  10220. mainContext.stroke();
  10221. }
  10222. }
  10223. // INTERPOLATE PLAYERS AND AI:
  10224. let lastTime = now - (1000 / config.serverUpdateRate);
  10225. let tmpDiff;
  10226. for (let i = 0; i < players.length + ais.length; ++i) {
  10227. tmpObj = players[i] || ais[i - players.length];
  10228. if (tmpObj && tmpObj.visible) {
  10229. if (tmpObj.forcePos) {
  10230. tmpObj.x = tmpObj.x2;
  10231. tmpObj.y = tmpObj.y2;
  10232. tmpObj.dir = tmpObj.d2;
  10233. } else {
  10234. let total = tmpObj.t2 - tmpObj.t1;
  10235. let fraction = lastTime - tmpObj.t1;
  10236. let ratio = (fraction / total);
  10237. let rate = 170;
  10238. tmpObj.dt += delta;
  10239. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10240. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10241. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10242. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10243. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10244. if (config.anotherVisual) {
  10245. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10246. } else {
  10247. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10248. }
  10249. }
  10250. }
  10251. }
  10252.  
  10253. // RENDER CORDS:
  10254. let xOffset = camX - (maxScreenWidth / 2);
  10255. let yOffset = camY - (maxScreenHeight / 2);
  10256.  
  10257. // RENDER BACKGROUND:
  10258. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10259. mainContext.fillStyle = "#b6db66";
  10260. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10261. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10262. mainContext.fillStyle = "#dbc666";
  10263. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10264. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10265. mainContext.fillStyle = "#fff";
  10266. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10267. } else if (config.snowBiomeTop - yOffset >= 0) {
  10268. mainContext.fillStyle = "#fff";
  10269. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10270. mainContext.fillStyle = "#b6db66";
  10271. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10272. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10273. } else {
  10274. mainContext.fillStyle = "#b6db66";
  10275. mainContext.fillRect(0, 0, maxScreenWidth,
  10276. (config.mapScale - config.snowBiomeTop - yOffset));
  10277. mainContext.fillStyle = "#dbc666";
  10278. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10279. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10280. }
  10281.  
  10282. // RENDER WATER AREAS:
  10283. if (!firstSetup) {
  10284. waterMult += waterPlus * config.waveSpeed * delta;
  10285. if (waterMult >= config.waveMax) {
  10286. waterMult = config.waveMax;
  10287. waterPlus = -1;
  10288. } else if (waterMult <= 1) {
  10289. waterMult = waterPlus = 1;
  10290. }
  10291. mainContext.globalAlpha = 1;
  10292. mainContext.fillStyle = "#dbc666";
  10293. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10294. mainContext.fillStyle = "#91b2db";
  10295. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10296. }
  10297.  
  10298. // RENDER DEAD PLAYERS:
  10299. mainContext.globalAlpha = 1;
  10300. mainContext.strokeStyle = outlineColor;
  10301. renderDeadPlayers(xOffset, yOffset);
  10302.  
  10303. // RENDER BOTTOM LAYER:
  10304. mainContext.globalAlpha = 1;
  10305. mainContext.strokeStyle = outlineColor;
  10306. renderGameObjects(-1, xOffset, yOffset);
  10307.  
  10308. // RENDER PROJECTILES:
  10309. mainContext.globalAlpha = 1;
  10310. mainContext.lineWidth = outlineWidth;
  10311. renderProjectiles(0, xOffset, yOffset);
  10312.  
  10313. // RENDER PLAYERS:
  10314. renderPlayers(xOffset, yOffset, 0);
  10315.  
  10316. // RENDER AI:
  10317. mainContext.globalAlpha = 1;
  10318. for (let i = 0; i < ais.length; ++i) {
  10319. tmpObj = ais[i];
  10320. if (tmpObj.active && tmpObj.visible) {
  10321. tmpObj.animate(delta);
  10322. mainContext.save();
  10323. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10324. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10325. renderAI(tmpObj, mainContext);
  10326. mainContext.restore();
  10327. }
  10328. }
  10329.  
  10330. // RENDER GAME OBJECTS (LAYERED):
  10331. renderGameObjects(0, xOffset, yOffset);
  10332. renderProjectiles(1, xOffset, yOffset);
  10333. renderGameObjects(1, xOffset, yOffset);
  10334. renderPlayers(xOffset, yOffset, 1);
  10335. renderGameObjects(2, xOffset, yOffset);
  10336. renderGameObjects(3, xOffset, yOffset);
  10337.  
  10338. // MAP BOUNDARIES:
  10339. mainContext.fillStyle = "#000";
  10340. mainContext.globalAlpha = 0.09;
  10341. if (xOffset <= 0) {
  10342. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10343. }
  10344. if (config.mapScale - xOffset <= maxScreenWidth) {
  10345. let tmpY = Math.max(0, -yOffset);
  10346. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10347. }
  10348. if (yOffset <= 0) {
  10349. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10350. }
  10351. if (config.mapScale - yOffset <= maxScreenHeight) {
  10352. let tmpX = Math.max(0, -xOffset);
  10353. let tmpMin = 0;
  10354. if (config.mapScale - xOffset <= maxScreenWidth)
  10355. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10356. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10357. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10358. }
  10359.  
  10360. // RENDER DAY/NIGHT TIME:
  10361. mainContext.globalAlpha = 1;
  10362. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  10363. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10364.  
  10365. // RENDER PLAYER AND AI UI:
  10366. mainContext.strokeStyle = darkOutlineColor;
  10367. mainContext.globalAlpha = 1;
  10368.  
  10369. for (let i = 0; i < players.length + ais.length; ++i) {
  10370. tmpObj = players[i] || ais[i - players.length];
  10371. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  10372. mainContext.strokeStyle = darkOutlineColor;
  10373.  
  10374. // NAME AND HEALTH:
  10375.  
  10376. if (tmpObj.skinIndex != 10 || (tmpObj==player) || (tmpObj.team && tmpObj.team==player.team)) {
  10377. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || "") + (tmpObj.isPlayer ? "" : "");
  10378. if (tmpText != "") {
  10379. mainContext.font = (tmpObj.nameScale||30) + "px Hammersmith One";
  10380. mainContext.fillStyle = "#fff";
  10381. mainContext.textBaseline = "middle";
  10382. mainContext.textAlign = "center";
  10383. mainContext.lineWidth = (tmpObj.nameScale?11:8);
  10384. mainContext.lineJoin = "round";
  10385. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10386. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10387. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10388. let tmpS = config.crownIconScale;
  10389. let tmpX = tmpObj.x - xOffset - (tmpS/2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10390. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10391. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10392. } if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10393. let tmpS = config.crownIconScale / 1;
  10394. let tmpX = tmpObj.x - xOffset - (tmpS/2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10395. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10396. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10397. } if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length) {
  10398. let tmpS = tmpObj.scale * 2.2;
  10399. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10400. }
  10401. } if (tmpObj.health > 0) {
  10402.  
  10403. // HEALTH HOLDER:
  10404. var tmpWidth = config.healthBarWidth;
  10405. mainContext.fillStyle = darkOutlineColor;
  10406. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10407. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10408. (config.healthBarPad * 2), 17, 11); // 11
  10409. mainContext.fill();
  10410.  
  10411. // HEALTH BAR:
  10412. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10413. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10414. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10415. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 20); // 20
  10416. mainContext.fill();
  10417. // SHAME COUNT:
  10418. mainContext.globalAlpha = 1;
  10419. mainContext.font = "25px Hammersmith One";
  10420. mainContext.fillStyle = "#fff";
  10421. mainContext.strokeStyle = "darkOutlineColor";
  10422. mainContext.textBaseline = "middle";
  10423. mainContext.textAlign = "center";
  10424. mainContext.lineWidth = tmpObj.nameScale ? 11 : 8;
  10425. mainContext.lineJoin = "round";
  10426. var tmpS = config.crownIconScale;
  10427. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  10428. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + tmpObj.pinge + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  10429. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + tmpObj.pinge + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  10430. /*if (tmpObj === player && tmpObj.team === player.team && tmpObj.enemy === player.enemy) {
  10431. mainContext.beginPath();
  10432. mainContext.lineWidth = maxScreenWidth / 640;
  10433.  
  10434. var startAngle = 0;
  10435. var endAngle = Math.PI * 2;
  10436.  
  10437. mainContext.arc(player.x - xOffset, player.y - yOffset, items.weapons[player.weaponIndex].range, startAngle, endAngle);
  10438.  
  10439. mainContext.strokeStyle = "rgba(0, 0, 0, 1)"; // Průsvitně černý obrys, intenzita 0.5
  10440. mainContext.fillStyle = "rgba(0, 0, 0, 0)"; // Průsvitně černá barva, úplně průhledná
  10441.  
  10442. // Uložení stínového efektu a následné vypnutí
  10443. const originalShadowColor = mainContext.shadowColor;
  10444. const originalShadowBlur = mainContext.shadowBlur;
  10445. mainContext.shadowColor = "transparent";
  10446. mainContext.shadowBlur = 0;
  10447.  
  10448. mainContext.fill(); // Vyplnit kruh (úplně průhledně)
  10449. mainContext.stroke(); // Vykreslit obrys kruhu
  10450.  
  10451. // Obnovení původního stínového efektu
  10452. mainContext.shadowColor = originalShadowColor;
  10453. mainContext.shadowBlur = originalShadowBlur;
  10454. }*/if(tmpObj.isPlayer) {
  10455. mainContext.font = "20px Hammersmith One";
  10456. mainContext.strokeText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10457. mainContext.fillText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10458. }
  10459.  
  10460. if (tmpObj.isPlayer) {
  10461.  
  10462. mainContext.globalAlpha = 1;
  10463.  
  10464. let reloads = {
  10465. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10466. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10467. // turret: (2500 - tmpObj.reloads[53]) / 2500
  10468. };
  10469.  
  10470. // SECONDARY RELOAD HOLDER:
  10471. mainContext.fillStyle = darkOutlineColor;
  10472. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarPad,
  10473. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13, config.healthBarWidth +
  10474. (config.healthBarPad * 2), 17, 8);
  10475. mainContext.fill();
  10476.  
  10477. // SECONDARY RELOAD BAR:
  10478. mainContext.fillStyle = reloads.secondary == 1 ? "#a17a45" : "hsl(" + 50 * reloads.secondary + ", 50%, 60%)";
  10479. mainContext.roundRect(tmpObj.x - xOffset,
  10480. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13 + config.healthBarPad,
  10481. (config.healthBarWidth * reloads.secondary), 17 - config.healthBarPad * 2, 7);
  10482. mainContext.fill();
  10483.  
  10484. // PRIMARY RELOAD HOLDER:
  10485. mainContext.fillStyle = darkOutlineColor;
  10486. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10487. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13, config.healthBarWidth +
  10488. (config.healthBarPad * 2), 17, 8);
  10489. mainContext.fill();
  10490.  
  10491. // PRIMARY RELOAD BAR:
  10492. mainContext.fillStyle = reloads.primary == 1 ? "#a17a45" : "hsl(" + 50 * reloads.primary + ", 50%, 60%)";
  10493. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10494. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY - 13 + config.healthBarPad,
  10495. (config.healthBarWidth * reloads.primary), 17 - config.healthBarPad * 2, 7);
  10496. mainContext.fill();
  10497.  
  10498. if (tmpObj == player) {
  10499.  
  10500. /*
  10501. // TURRET RELOAD HOLDER:
  10502. mainContext.fillStyle = darkOutlineColor;
  10503. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10504. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + 13, (config.healthBarWidth * 2) +
  10505. (config.healthBarPad * 2), 17, 8);
  10506. mainContext.fill();
  10507.  
  10508. // TURRET RELOAD BAR:
  10509. mainContext.fillStyle = "#cc5151";
  10510. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10511. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + 13 + config.healthBarPad,
  10512. ((config.healthBarWidth * 2) * reloads.turret), 17 - config.healthBarPad * 2, 7);
  10513. mainContext.fill();
  10514. */
  10515.  
  10516. // RENDER DIR:
  10517. if (tmpObj.dir != undefined && configs.circleDir) {
  10518. mainContext.fillStyle = "#fff";
  10519. mainContext.globalAlpha = 0.75;
  10520. renderCircle(tmpObj.x + (Math.cos(tmpObj.dir) * items.weapons[player.weapons[0]].range) - xOffset, tmpObj.y + (Math.sin(tmpObj.dir) * items.weapons[player.weapons[0]].range) - yOffset, 5, mainContext, true, false);
  10521. }
  10522.  
  10523. }
  10524.  
  10525. // PLAYER TRACER:
  10526. if (!tmpObj.isTeam(player)) {
  10527. let center = {
  10528. x: screenWidth / 2,
  10529. y: screenHeight / 2,
  10530. };
  10531. 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);
  10532. let dist = center.y * alpha;
  10533. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10534. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10535. mainContext.save();
  10536. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10537. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10538. let by = 255 - (tmpObj.sid * 2);
  10539. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10540. mainContext.globalAlpha = alpha;
  10541. let renderTracer = function(s, ctx) {
  10542. ctx = ctx || mainContext;
  10543. let h = s * (Math.sqrt(3) / 2);
  10544. ctx.beginPath();
  10545. ctx.moveTo(0, -h / 1.5);
  10546. ctx.lineTo(-s / 2, h / 2);
  10547. ctx.lineTo(s / 2, h / 2);
  10548. ctx.lineTo(0, -h / 1.5);
  10549. ctx.fill();
  10550. ctx.closePath();
  10551. }
  10552. renderTracer(25, mainContext);
  10553. mainContext.restore();
  10554. }
  10555.  
  10556. if (getEl("predictType").value == "pre2") {
  10557. mainContext.lineWidth = 3;
  10558. mainContext.strokeStyle = "#cc5151";
  10559. mainContext.globalAlpha = 1;
  10560. mainContext.beginPath();
  10561. let render = {
  10562. x: tmpObj.x2 - xOffset,
  10563. y: tmpObj.y2 - yOffset
  10564. };
  10565. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10566. mainContext.lineTo(render.x, render.y);
  10567. mainContext.stroke();
  10568. } else if (getEl("predictType").value == "pre3") {
  10569. mainContext.lineWidth = 3;
  10570. mainContext.strokeStyle = "#cc5151";
  10571. mainContext.globalAlpha = 1;
  10572. mainContext.beginPath();
  10573. let render = {
  10574. x: tmpObj.x3 - xOffset,
  10575. y: tmpObj.y3 - yOffset
  10576. };
  10577. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10578. mainContext.lineTo(render.x, render.y);
  10579. mainContext.stroke();
  10580. }
  10581.  
  10582. }
  10583. }
  10584. }
  10585. }
  10586. }
  10587.  
  10588. if (player) {
  10589. // AUTOPUSH LINE:
  10590. if (my.autoPush) {
  10591. mainContext.lineWidth = 3; // Increase line width for a thicker line
  10592. mainContext.globalAlpha = 1;
  10593. mainContext.lineCap = "round"; // Make the ends of the line rounded for a more curved appearance
  10594. mainContext.beginPath();
  10595.  
  10596. // Define a gradient to switch between light RGB purple and white
  10597. var gradient = mainContext.createLinearGradient(
  10598. player.x - xOffset,
  10599. player.y - yOffset,
  10600. my.pushData.x - xOffset,
  10601. my.pushData.y - yOffset
  10602. );
  10603. gradient.addColorStop(1, "#fe557a"); // Light purple color
  10604. gradient.addColorStop(0.5, "#fe557a"); // White
  10605. gradient.addColorStop(1, "#fe557a"); // Light purple color
  10606.  
  10607. mainContext.strokeStyle = gradient;
  10608. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10609.  
  10610. // Control points for the curve
  10611. let controlX = (player.x + my.pushData.x) / 2 - xOffset;
  10612. let controlY = (player.y + my.pushData.y) / 2 - yOffset - 40; // Adjust control point for more pronounced curve
  10613.  
  10614. mainContext.quadraticCurveTo(
  10615. controlX,
  10616. controlY,
  10617. my.pushData.x - xOffset,
  10618. my.pushData.y - yOffset
  10619. ); // Use quadraticCurveTo for a curved line
  10620. mainContext.stroke();
  10621. }
  10622. mainContext.globalAlpha = 1;
  10623. }
  10624.  
  10625. // RENDER ANIM TEXTS:
  10626. textManager.update(delta, mainContext, xOffset, yOffset);
  10627.  
  10628. // RENDER CHAT MESSAGES:
  10629. for (let i = 0; i < players.length; ++i) {
  10630. tmpObj = players[i];
  10631. if (tmpObj.visible) {
  10632. if (tmpObj.chatCountdown > 0) {
  10633. tmpObj.chatCountdown -= delta;
  10634. if (tmpObj.chatCountdown <= 0)
  10635. tmpObj.chatCountdown = 0;
  10636. mainContext.font = "32px HammerSmith One";
  10637. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10638. mainContext.textBaseline = "middle";
  10639. mainContext.textAlign = "center";
  10640. let tmpX = tmpObj.x - xOffset;
  10641. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10642. let tmpH = 47;
  10643. let tmpW = tmpSize.width + 17;
  10644. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10645. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10646. mainContext.fill();
  10647. mainContext.fillStyle = "#fff";
  10648. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10649. }
  10650. if (tmpObj.chat.count > 0) {
  10651. if (!useWasd) {
  10652. tmpObj.chat.count -= delta;
  10653. if (tmpObj.chat.count <= 0)
  10654. tmpObj.chat.count = 0;
  10655. mainContext.font = "32px HammerSmith One";
  10656. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10657. mainContext.textBaseline = "middle";
  10658. mainContext.textAlign = "center";
  10659. let tmpX = tmpObj.x - xOffset;
  10660. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10661. let tmpH = 47;
  10662. let tmpW = tmpSize.width + 17;
  10663. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10664. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10665. mainContext.fill();
  10666. mainContext.fillStyle = "#ffffff99";
  10667. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10668. } else {
  10669. tmpObj.chat.count = 0;
  10670. }
  10671. }
  10672. }
  10673. }
  10674.  
  10675. if (allChats.length) {
  10676. allChats.filter(ch => ch.active).forEach((ch) => {
  10677. if (!ch.alive) {
  10678. if (ch.alpha <= 1) {
  10679. ch.alpha += delta / 250;
  10680. if (ch.alpha >= 1) {
  10681. ch.alpha = 1;
  10682. ch.alive = true;
  10683. }
  10684. }
  10685. } else {
  10686. ch.alpha -= delta / 5000;
  10687. if (ch.alpha <= 0) {
  10688. ch.alpha = 0;
  10689. ch.active = false;
  10690. }
  10691. }
  10692. if (ch.active) {
  10693. mainContext.font = "20px Ubuntu";
  10694. let tmpSize = mainContext.measureText(ch.chat);
  10695. mainContext.textBaseline = "middle";
  10696. mainContext.textAlign = "center";
  10697. let tmpX = ch.x - xOffset;
  10698. let tmpY = ch.y - yOffset - 90;
  10699. let tmpH = 40;
  10700. let tmpW = tmpSize.width + 15;
  10701.  
  10702. mainContext.globalAlpha = ch.alpha;
  10703.  
  10704. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10705. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10706. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10707. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  10708.  
  10709. mainContext.lineWidth = 5;
  10710. mainContext.fillStyle = "#ccc";
  10711. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10712.  
  10713. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10714. mainContext.stroke();
  10715. mainContext.fill();
  10716.  
  10717. mainContext.fillStyle = "#fff";
  10718. mainContext.strokeStyle = "#000";
  10719. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10720. mainContext.fillText(ch.chat, tmpX, tmpY);
  10721. ch.y -= delta / 100;
  10722. }
  10723. });
  10724. }
  10725.  
  10726. mainContext.globalAlpha = 1;
  10727.  
  10728. // RENDER MINIMAP:
  10729. renderMinimap(delta);
  10730. }
  10731.  
  10732. // UPDATE & ANIMATE:
  10733. window.requestAnimFrame = function() {
  10734. return null;
  10735. }
  10736. window.rAF = (function() {
  10737. return window.requestAnimationFrame ||
  10738. window.webkitRequestAnimationFrame ||
  10739. window.mozRequestAnimationFrame ||
  10740. function(callback) {
  10741. window.setTimeout(callback, 1000/9);
  10742. };
  10743. })();
  10744.  
  10745. function doUpdate() {
  10746. //rape modulus
  10747. now = performance.now();
  10748. delta = now - lastUpdate;
  10749. lastUpdate = now;
  10750. let timer = performance.now();
  10751. let diff = timer - fpsTimer.last;
  10752. if (diff >= 1000) {
  10753.  
  10754. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10755.  
  10756. fpsTimer.last = timer;
  10757. fpsTimer.time = 0;
  10758. }
  10759. fpsTimer.time++;
  10760.  
  10761. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  10762. getEl("packetStatus").innerHTML = secPacket;
  10763. updateGame();
  10764. rAF(doUpdate);
  10765. ms.avg = Math.round((ms.min+ms.max)/2);
  10766. }
  10767.  
  10768. prepareMenuBackground();
  10769. doUpdate();
  10770.  
  10771. function toggleUseless(boolean) {
  10772. getEl("instaType").disabled = boolean;
  10773. getEl("antiBullType").disabled = boolean;
  10774. getEl("predictType").disabled = boolean;
  10775. }
  10776. toggleUseless(useWasd);
  10777.  
  10778. let changeDays = {};
  10779. window.debug = function() {
  10780. my.waitHit = 0;
  10781. my.autoAim = false;
  10782. instaC.isTrue = false;
  10783. traps.inTrap = false;
  10784. itemSprites = [];
  10785. objSprites = [];
  10786. gameObjectSprites = [];
  10787. };
  10788. window.wasdMode = function() {
  10789. useWasd = !useWasd;
  10790. toggleUseless(useWasd);
  10791. };
  10792. window.startGrind = function() {
  10793. if (getEl("weaponGrind").checked) {
  10794. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10795. checkPlace(player.getItemType(22), i);
  10796. }
  10797. }
  10798. };
  10799. // REMOVED!!! so they cant abuse :)
  10800. let projects = [
  10801. "adorable-eight-guppy",
  10802. "galvanized-bittersweet-windshield"
  10803. ];
  10804. let botIDS = 0;
  10805. window.connectFillBots = function() {
  10806. botSkts = [];
  10807. botIDS = 0;
  10808. for (let i = 0; i < projects.length; i++) {
  10809. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10810. test.binaryType = "arraybuffer";
  10811.  
  10812. test.onopen = function() {
  10813. test.ssend = function(type) {
  10814. let data = Array.prototype.slice.call(arguments, 1);
  10815. let binary = window.msgpack.encode([type, data]);
  10816. test.send(binary);
  10817. };
  10818. for (let i = 0; i < 4; i++) {
  10819. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10820. action: "homepage"
  10821. }).then(function(token) {
  10822. let t = WS.url.split("wss://")[1].split("?")[0];
  10823. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10824. botSkts.push([test]);
  10825. botIDS++;
  10826. });
  10827. }
  10828. };
  10829. test.onmessage = function(message) {
  10830. let data = new Uint8Array(message.data);
  10831. let parsed = window.msgpack.decode(data);
  10832. let type = parsed[0];
  10833. data = parsed[1];
  10834. };
  10835. }
  10836. };
  10837. window.destroyFillBots = function() {
  10838. botSkts.forEach((socket) => {
  10839. socket[0].close();
  10840. });
  10841. botSkts = [];
  10842. };
  10843. window.tryConnectBots = function() {
  10844. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10845. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10846. action: "homepage"
  10847. }).then(function(token) {
  10848. // CONNECT SOCKET:
  10849. botSpawn(token);
  10850. });
  10851. }
  10852. };
  10853. window.destroyBots = function() {
  10854. bots.forEach((botyyyyy) => {
  10855. botyyyyy.closeSocket = true;
  10856. });
  10857. bots = [];
  10858. };
  10859. window.resBuild = function() {
  10860. if (gameObjects.length) {
  10861. gameObjects.forEach((tmp) => {
  10862. tmp.breakObj = false;
  10863. });
  10864. breakObjects = [];
  10865. }
  10866. };
  10867. window.toggleBotsCircle = function() {
  10868. player.circle = !player.circle;
  10869. };
  10870. window.toggleVisual = function() {
  10871. config.anotherVisual = !config.anotherVisual;
  10872. gameObjects.forEach((tmp) => {
  10873. if (tmp.active) {
  10874. tmp.dir = tmp.lastDir;
  10875. }
  10876. });
  10877. };
  10878. window.prepareUI = function(tmpObj) {
  10879. resize();
  10880. // CHAT STUFF:
  10881. var chatBox = document.getElementById("chatBox");
  10882. var chatHolder = document.getElementById("chatHolder");
  10883. var suggestBox = document.createElement("div");
  10884. suggestBox.id = "suggestBox";
  10885.  
  10886. var prevChats = [];
  10887. var prevChatsIndex = 0;
  10888.  
  10889. function toggleChat() {
  10890. if (!usingTouch) {
  10891. if (chatHolder.style.display == "block") {
  10892. if (chatBox.value) {
  10893. sendChat(chatBox.value);
  10894. }
  10895. closeChat();
  10896. } else {
  10897. storeMenu.style.display = "none";
  10898. allianceMenu.style.display = "none";
  10899. chatHolder.style.display = "block";
  10900. chatBox.focus();
  10901. resetMoveDir();
  10902. }
  10903. } else {
  10904. setTimeout(function () {
  10905. var chatMessage = prompt("chat message");
  10906. if (chatMessage) {
  10907. sendChat(chatMessage);
  10908. }
  10909. }, 1);
  10910. }
  10911. chatBox.value = "";
  10912. (() => {
  10913. prevChatsIndex = 0;
  10914. })();
  10915. }
  10916.  
  10917. function closeChat() {
  10918. chatBox.value = "";
  10919. chatHolder.style.display = "none";
  10920. }
  10921.  
  10922. // ACTION BAR:
  10923. UTILS.removeAllChildren(actionBar);
  10924.  
  10925. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10926. (function (i) {
  10927. UTILS.generateElement({
  10928. id: "actionBarItem" + i,
  10929. class: "actionBarItem",
  10930. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10931. onmouseout: function () {
  10932. showItemInfo();
  10933. },
  10934. parent: actionBar
  10935. });
  10936. })(i);
  10937. }
  10938.  
  10939. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10940. (function (i) {
  10941. let tmpCanvas = document.createElement("canvas");
  10942. tmpCanvas.width = tmpCanvas.height = 66;
  10943. let tmpContext = tmpCanvas.getContext("2d");
  10944. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10945. tmpContext.imageSmoothingEnabled = false;
  10946. tmpContext.webkitImageSmoothingEnabled = false;
  10947. tmpContext.mozImageSmoothingEnabled = false;
  10948.  
  10949. if (items.weapons[i]) {
  10950. tmpContext.rotate((Math.PI));
  10951. let tmpSprite = new Image();
  10952. toolSprites[items.weapons[i].src] = tmpSprite;
  10953. tmpSprite.onload = function () {
  10954. this.isLoaded = true;
  10955. let tmpPad = 1 / (this.height / this.width);
  10956. let tmpMlt = (items.weapons[i].iPad || 1);
  10957. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10958. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10959. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10960. tmpContext.globalCompositeOperation = "source-atop";
  10961. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10962. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10963. };
  10964. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10965. let tmpUnit = getEl('actionBarItem' + i);
  10966. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10967. // showItemInfo(items.weapons[i], true);
  10968. // });
  10969. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10970. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10971. });
  10972. UTILS.hookTouchEvents(tmpUnit);
  10973. } else {
  10974. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10975. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10976. tmpContext.globalAlpha = 1;
  10977. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10978. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10979. tmpContext.globalCompositeOperation = "source-atop";
  10980. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10981. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10982. let tmpUnit = getEl('actionBarItem' + i);
  10983. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10984. // showItemInfo(items.list[i - items.weapons.length]);
  10985. // });
  10986. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10987. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10988. });
  10989. UTILS.hookTouchEvents(tmpUnit);
  10990. }
  10991. })(i);
  10992. }
  10993. };
  10994. window.profineTest = function(data) {
  10995. if (data) {
  10996. // VALIDATE NAME:
  10997. let name = data + "";
  10998. name = name.slice(0, config.maxNameLength);
  10999.  
  11000. return name;
  11001. }
  11002. }
  11003. }(1)// ==UserScript==
  11004. // @name New script
  11005. // @namespace Violentmonkey Scripts
  11006. // @match *://example.org/*
  11007. // @grant none
  11008. // @version 1.0
  11009. // @author -
  11010. // @description 8/26/2024, 9:20:03 PM
  11011. // ==/UserScript==
  11012. // ==UserScript==
  11013. // @name New script
  11014. // @namespace Violentmonkey Scripts
  11015. // @match *://example.org/*
  11016. // @grant none
  11017. // @version 1.0
  11018. // @author -
  11019. // @description 9/1/2024, 11:43:30 PM
  11020. // ==/UserScript==