Star Client v3(fixed)

Star client v3(fixed)

  1. // ==UserScript==
  2. // @name Star Client v3(fixed)
  3. // @icon https://banner2.cleanpng.com/20200411/vb/transparent-purple-violet-blue-star-pink-5e91c47a8e9573.929211131586611322584.jpg
  4. // @match *://*.moomoo.io/*
  5. // @match https://mohmoh.eu/
  6. // @license GNU
  7. // @run-at document_start
  8. // @grant none
  9. // @version V3
  10. // @description Star client v3(fixed)
  11. // @author Ultra hack
  12. // @namespace https://gf.qytechs.cn/users/1361862
  13. // ==/UserScript==
  14. let editMainMenu = `
  15. <style>
  16. /* ╨κ╤Γ╨╕╨╗╨╕ ╨┤╨╗╤Π ╨╝╨╡╨╜╤Ο #setupCard */
  17. #setupCard {
  18. border-radius: 10px;
  19. position: absolute;
  20. left: 350px;
  21. top: 0px;
  22. background: #1a1919;
  23. box-shadow: 0px 0px 5px #fff;
  24. transition: box-shadow 0.3s ease;
  25. }
  26.  
  27. #setupCard:hover,
  28. #setupCard:active {
  29. box-shadow: 0px 0px 10px #ffffff;
  30. }
  31.  
  32. #mainMenu {
  33. background-image: url('https://c1.wallpaperflare.com/preview/747/358/397/love-hart-night-view-thumbnail.jpg');
  34. background-size: cover;
  35. background-repeat: no-repeat;
  36. background-position: center;
  37.  
  38. }
  39.  
  40. /* ╨κ╤Γ╨╕╨╗╨╕ ╨┤╨╗╤Π ╨╝╨╡╨╜╤Ο #guideCard */
  41. #guideCard {
  42. border-radius: 10px;
  43. position: absolute;
  44. left: 700px;
  45. top: 0px;
  46. background: #1a1919;
  47. box-shadow: 0px 0px 5px #ffffff;
  48. transition: box-shadow 0.3s ease;
  49. }
  50.  
  51. #guideCard:hover,
  52. #guideCard:active {
  53. box-shadow: 0px 0px 10px #ffffff;
  54. }
  55.  
  56.  
  57.  
  58. /* ╨θ╤Α╨╛╤Θ╨╕╨╡ ╤Β╤Γ╨╕╨╗╨╕ ╨╛╤Β╤Γ╨░╤Ο╤Γ╤Β╤Π ╨▒╨╡╨╖ ╨╕╨╖╨╝╨╡╨╜╨╡╨╜╨╕╨╣ */
  59. #nameInput::selection {
  60. background: #1a1919;
  61. }
  62.  
  63. #guideCard::-webkit-scrollbar {
  64. width: 0px;
  65. height: 0px;
  66. background-color: rgba(0, 0, 0, 0);
  67. }
  68.  
  69. #mainMenu {
  70. background-color: #1a1919;
  71.  
  72. }
  73.  
  74. .menuCard {
  75. background: #1a1919;
  76. text-align: center;
  77. box-shadow: inset 0px 0px 0px black;
  78. }
  79.  
  80. })();
  81. </script>
  82.  
  83. </style>
  84.  
  85.  
  86. `
  87. $("#mainMenu").append(editMainMenu)
  88.  
  89.  
  90.  
  91.  
  92.  
  93. document.getElementById("partyButton").remove();
  94. document.getElementById("joinPartyButton").remove();
  95.  
  96. document.getElementById("linksContainer2").remove();
  97.  
  98. document.getElementById("gameName").style.font = "120px zamruds";
  99.  
  100. document.getElementById("gameName").style.textShadow = "0px 0px 10px rgba(255, 255, 255, 1)"; // ╨α╤Β╨┐╨╛╨╗╤Ν╨╖╤Δ╨╡╨╝ rgba ╨┤╨╗╤Π ╨╖╨░╨┤╨░╨╜╨╕╤Π ╨┐╤Α╨╛╨╖╤Α╨░╤Θ╨╜╨╛╨│╨╛ ╨│╨╛╨╗╤Δ╨▒╨╛╨│╨╛ ╤Η╨▓╨╡╤Γ╨░
  101. document.getElementById('gameName').style.marginTop = '-200px';
  102. document.getElementById('gameName').innerHTML = 'ΏζΡΤΏζΡφΏζΡγΏζΡτΏζΡΓΏζΡξΏζΡλΏζΡηΏζΡπΏζΡφ';
  103. document.getElementById("leaderboard").append ('ΏζΡΜΏζΡηΏζΡγΏζΡζΏζΡηΏζΡτΏζΡΒΏζΡρΏζΡγΏζΡτΏζΡζ');
  104. document.getElementById("leaderboard").style.color = "text-shadow: green 1px 1px 40px;";
  105.  
  106.  
  107. let founda = false;
  108. let testMode = window.location.hostname == "127.0.0.1";
  109.  
  110. let scriptTags = document.getElementsByTagName("script");
  111. for (let i = 0; i < scriptTags.length; i++) {
  112. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  113. scriptTags[i].remove();
  114. founda = true;
  115. break;
  116. }
  117. }
  118.  
  119.  
  120. document.addEventListener("keydown", function(event) {
  121. if (event.keyCode === 192) {
  122. const chatHolder = document.getElementById("gameUI");
  123. if (chatHolder) {
  124. const currentDisplay = chatHolder.style.display;
  125. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  126. }
  127. }
  128. });
  129. var styleItem = document.createElement("style");
  130. styleItem.type = "text/css";
  131. styleItem.appendChild(document.createTextNode(`
  132. #suggestBox {
  133. width: 355px;
  134. border-radius: 3px;
  135. background-color: rgba(0,0,0,0.5);
  136. margin: auto;
  137. text-align: left;
  138. z-index: 49;
  139. pointer-events: auto;
  140. position: relative;
  141. bottom: 3.5px;
  142. overflow-y: auto;
  143. }
  144. #suggestBox div {
  145. background-color: rgba(255,255,255,0);
  146. color: rgba(255,255,255,1);
  147. transition: background-color 0.3s, color 0.3s;
  148. }
  149. #suggestBox div:hover {
  150. background-color: rgba(255,255,255,0.2);
  151. color: rgba(0,0,0,1);
  152. }
  153. .suggestBoxHard {
  154. color: rgba(255,255,255,1);
  155. font-size: 18px;
  156. }
  157. .suggestBoxLight {
  158. color: rgba(255,255,255,0.7);
  159. font-size: 18px;
  160. }
  161. `));
  162. document.head.appendChild(styleItem);
  163.  
  164. window.addEventListener('load', function() {
  165. var allianceButton = document.getElementById('allianceButton');
  166. var storeButton = document.getElementById('storeButton');
  167. if (storeButton) {
  168. storeButton.style.right = '26px';
  169. storeButton.style.top = '420px';
  170. }
  171. if (allianceButton) {
  172. allianceButton.style.right = '26px';
  173. allianceButton.style.top = '479px';
  174. }
  175. });
  176.  
  177. function getEl(id) {
  178. return document.getElementById(id);
  179. }
  180.  
  181. let newFont = document.createElement("link");
  182. newFont.rel = "stylesheet";
  183. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  184. newFont.type = "text/css";
  185. document.body.append(newFont);
  186.  
  187. let min = document.createElement("script");
  188. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  189. document.body.append(min);
  190. window.oncontextmenu = function() {
  191. return false;
  192. };
  193.  
  194. let config = window.config;
  195.  
  196. // CLIENT:
  197. config.clientSendRate = 9; // Aim Packet Send Rate
  198. config.serverUpdateRate = 9;
  199.  
  200. // UI:
  201. config.deathFadeout = 0;
  202.  
  203. config.playerCapacity = 9999;
  204.  
  205. // CHECK IN SANDBOX:
  206. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  207.  
  208. // CUSTOMIZATION:
  209. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  210. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  211. "#8bc373", "#91b2db"
  212. ];
  213. config.weaponVariants = [{
  214. id: 0,
  215. src: "",
  216. xp: 0,
  217. val: 1,
  218. }, {
  219. id: 1,
  220. src: "_g",
  221. xp: 3000,
  222. val: 1.1,
  223. }, {
  224. id: 2,
  225. src: "_d",
  226. xp: 7000,
  227. val: 1.18,
  228. }, {
  229. id: 3,
  230. src: "_r",
  231. poison: true,
  232. xp: 12000,
  233. val: 1.18,
  234. }, {
  235. id: 4,
  236. src: "_e",
  237. poison: true,
  238. heal: true,
  239. xp: 24000,
  240. val: 1.18,
  241. }];
  242.  
  243. // VISUAL:
  244. config.anotherVisual = true;
  245. config.useWebGl = false;
  246. config.resetRender = true;
  247.  
  248. function waitTime(timeout) {
  249. return new Promise((done) => {
  250. setTimeout(() => {
  251. done();
  252. }, timeout);
  253. });
  254. }
  255.  
  256. let botSkts = [];
  257.  
  258. // STORAGE:
  259. let canStore;
  260. if (typeof(Storage) !== "undefined") {
  261. canStore = true;
  262. }
  263.  
  264. function saveVal(name, val) {
  265. if (canStore)
  266. localStorage.setItem(name, val);
  267. }
  268.  
  269. function deleteVal(name) {
  270. if (canStore)
  271. localStorage.removeItem(name);
  272. }
  273.  
  274. function getSavedVal(name) {
  275. if (canStore)
  276. return localStorage.getItem(name);
  277. return null;
  278. }
  279.  
  280. // CONFIGS:
  281. let gC = function(a, b) {
  282. try {
  283. let res = JSON.parse(getSavedVal(a));
  284. if (typeof res === "object") {
  285. return b;
  286. } else {
  287. return res;
  288. }
  289. } catch (e) {
  290. alert("dieskid");
  291. return b;
  292. }
  293. };
  294.  
  295. function setCommands() {
  296. return {
  297. "help": {
  298. desc: "Show Commands",
  299. action: function(message) {
  300. for (let cmds in commands) {
  301. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  302. }
  303. }
  304. },
  305. "clear": {
  306. desc: "Clear Chats",
  307. action: function(message) {
  308. resetMenuChText();
  309. }
  310. },
  311. "debug": {
  312. desc: "Debug Mod For Development",
  313. action: function(message) {
  314. addDeadPlayer(player);
  315. addMenuChText("Debug", "Done", "#99ee99", 1);
  316. }
  317. },
  318. "play": {
  319. desc: "Play Music ( /play [link] )",
  320. action: function(message) {
  321. let link = message.split(" ");
  322. if (link[1]) {
  323. let audio = new Audio(link[1]);
  324. audio.play();
  325. } else {
  326. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  327. }
  328. }
  329. },
  330. "bye": {
  331. desc: "Leave Game",
  332. action: function(message) {
  333. window.leave();
  334. }
  335. },
  336. };
  337. }
  338.  
  339. function setConfigs() {
  340. return {
  341. killChat: true,
  342. autoBuy: true,
  343. autoBuyEquip: true,
  344. autoPush: true,
  345. revTick: true,
  346. spikeTick: true,
  347. predictTick: true,
  348. autoPlace: true,
  349. autoReplace: true,
  350. autoPrePlace: true,
  351. antiTrap: true,
  352. slowOT: false,
  353. attackDir: false,
  354. showDir: false,
  355. autoRespawn: false
  356. };
  357. }
  358.  
  359. let commands = setCommands();
  360. let configs = setConfigs();
  361.  
  362. window.removeConfigs = function() {
  363. for (let cF in configs) {
  364. deleteVal(cF, configs[cF]);
  365. }
  366. };
  367.  
  368. for (let cF in configs) {
  369. configs[cF] = gC(cF, configs[cF]);
  370. }
  371.  
  372. // MENU FUNCTIONS:
  373. window.changeMenu = function() {};
  374. window.debug = function() {};
  375. window.freezePlayer = function() {};
  376. window.wasdMode = function() {};
  377.  
  378. // PAGE 1:
  379. window.startGrind = function() {};
  380.  
  381. // PAGE 3:
  382. window.connectFillBots = function() {};
  383. window.destroyFillBots = function() {};
  384. window.tryConnectBots = function() {};
  385. window.destroyBots = function() {};
  386. window.resBuild = function() {};
  387. window.toggleBotsCircle = function() {};
  388. window.toggleVisual = function() {};
  389.  
  390. // SOME FUNCTIONS:
  391. window.prepareUI = function() {};
  392. window.leave = function() {};
  393.  
  394. // nah hahahahahhh why good ping
  395. window.ping = 0;
  396.  
  397. class deadfuturechickenmodrevival {
  398. constructor(flarez, lore) {
  399. this.inGame = false;
  400. this.lover = flarez + lore;
  401. this.baby = "ae86";
  402. this.isBlack = 0;
  403. this.webSocket = undefined;
  404. this.checkBaby = function() {
  405. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  406. if (this.isBlack >= 1) return "bl4cky";
  407. return "noting for you";
  408. };
  409. this.x2 = 0;
  410. this.y2 = 0;
  411. this.chat = "Imagine playing this badass game XDDDDD";
  412. this.summon = function(tmpObj) {
  413. this.x2 = tmpObj.x;
  414. this.y2 = tmpObj.y;
  415. this.chat = tmpObj.name + " ur so bad XDDDD";
  416. };
  417. this.commands = function(cmd) {
  418. cmd == "rv3link" && window.open("https://florr.io/");
  419. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  420. return cmd;
  421. };
  422. this.dayte = "11yearold";
  423. this.memeganoob = "69yearold";
  424. this.startDayteSpawn = function(tmpObj) {
  425. let ratio = setInterval(() => {
  426. this.x2 = tmpObj.x + 20;
  427. this.y2 = tmpObj.y - 20;
  428. this.chat = "UR SO BAD LOL";
  429. if (tmpObj.name == "ae86") {
  430. this.chat = "omg ae86 go run";
  431. setTimeout(() => {
  432. this.inGame = false;
  433. clearInterval(ratio);
  434. }, 1000);
  435. }
  436. }, 1234);
  437. };
  438. this.AntiChickenModV69420 = function(tmpObj) {
  439. return "!c!dc user " + tmpObj.name;
  440. };
  441. }
  442. };
  443. class HtmlAction {
  444. constructor(element) {
  445. this.element = element;
  446. };
  447. add(code) {
  448. if (!this.element) return undefined;
  449. this.element.innerHTML += code;
  450. };
  451. newLine(amount) {
  452. let result = `<br>`;
  453. if (amount > 0) {
  454. result = ``;
  455. for (let i = 0; i < amount; i++) {
  456. result += `<br>`;
  457. }
  458. }
  459. this.add(result);
  460. };
  461. checkBox(setting) {
  462. let newCheck = `<input type = "checkbox"`;
  463. setting.id && (newCheck += ` id = ${setting.id}`);
  464. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  465. setting.class && (newCheck += ` class = ${setting.class}`);
  466. setting.checked && (newCheck += ` checked`);
  467. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  468. newCheck += `>`;
  469. this.add(newCheck);
  470. };
  471. text(setting) {
  472. let newText = `<input type = "text"`;
  473. setting.id && (newText += ` id = ${setting.id}`);
  474. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  475. setting.class && (newText += ` class = ${setting.class}`);
  476. setting.size && (newText += ` size = ${setting.size}`);
  477. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  478. setting.value && (newText += ` value = ${setting.value}`);
  479. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  480. newText += `>`;
  481. this.add(newText);
  482. };
  483. select(setting) {
  484. let newSelect = `<select`;
  485. setting.id && (newSelect += ` id = ${setting.id}`);
  486. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  487. setting.class && (newSelect += ` class = ${setting.class}`);
  488. newSelect += `>`;
  489. for (let options in setting.option) {
  490. newSelect += `<option value = ${setting.option[options].id}`
  491. setting.option[options].selected && (newSelect += ` selected`);
  492. newSelect += `>${options}</option>`;
  493. }
  494. newSelect += `</select>`;
  495. this.add(newSelect);
  496. };
  497. button(setting) {
  498. let newButton = `<button`;
  499. setting.id && (newButton += ` id = ${setting.id}`);
  500. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  501. setting.class && (newButton += ` class = ${setting.class}`);
  502. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  503. newButton += `>`;
  504. setting.innerHTML && (newButton += setting.innerHTML);
  505. newButton += `</button>`;
  506. this.add(newButton);
  507. };
  508. selectMenu(setting) {
  509. let newSelect = `<select`;
  510. if (!setting.id) {
  511. alert("please put id skid");
  512. return;
  513. }
  514. window[setting.id + "Func"] = function() {};
  515. setting.id && (newSelect += ` id = ${setting.id}`);
  516. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  517. setting.class && (newSelect += ` class = ${setting.class}`);
  518. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  519. newSelect += `>`;
  520. let last;
  521. let i = 0;
  522. for (let options in setting.menu) {
  523. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  524. setting.menu[options] && (newSelect += ` checked`);
  525. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  526. i++;
  527. }
  528. newSelect += `</select>`;
  529.  
  530. this.add(newSelect);
  531.  
  532. i = 0;
  533. for (let options in setting.menu) {
  534. window[options + "Func"] = function() {
  535. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  536. saveVal(options, setting.menu[options]);
  537.  
  538. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  539. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  540.  
  541. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  542.  
  543. };
  544. this.checkBox({
  545. id: "check_" + options,
  546. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  547. class: "checkB",
  548. onclick: `window.${options + "Func"}()`,
  549. checked: setting.menu[options]
  550. });
  551. i++;
  552. }
  553.  
  554. last = "check_" + getEl(setting.id).value.split("_")[1];
  555. window[setting.id + "Func"] = function() {
  556. getEl(last).style.display = "none";
  557. last = "check_" + getEl(setting.id).value.split("_")[1];
  558. getEl(last).style.display = "inline-block";
  559.  
  560. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  561.  
  562. };
  563. };
  564. };
  565. class Html {
  566. constructor() {
  567. this.element = null;
  568. this.action = null;
  569. this.divElement = null;
  570. this.startDiv = function(setting, func) {
  571.  
  572. let newDiv = document.createElement("div");
  573. setting.id && (newDiv.id = setting.id);
  574. setting.style && (newDiv.style = setting.style);
  575. setting.class && (newDiv.className = setting.class);
  576. this.element.appendChild(newDiv);
  577. this.divElement = newDiv;
  578.  
  579. let addRes = new HtmlAction(newDiv);
  580. typeof func == "function" && func(addRes);
  581.  
  582. };
  583. this.addDiv = function(setting, func) {
  584.  
  585. let newDiv = document.createElement("div");
  586. setting.id && (newDiv.id = setting.id);
  587. setting.style && (newDiv.style = setting.style);
  588. setting.class && (newDiv.className = setting.class);
  589. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  590. this.divElement = newDiv;
  591.  
  592. let addRes = new HtmlAction(newDiv);
  593. typeof func == "function" && func(addRes);
  594.  
  595. };
  596. };
  597. set(id) {
  598. this.element = getEl(id);
  599. this.action = new HtmlAction(this.element);
  600. };
  601. resetHTML(text) {
  602. if (text) {
  603. this.element.innerHTML = ``;
  604. } else {
  605. this.element.innerHTML = ``;
  606. }
  607. };
  608. setStyle(style) {
  609. this.element.style = style;
  610. };
  611. setCSS(style) {
  612. this.action.add(`<style>` + style + `</style>`);
  613. };
  614. };
  615.  
  616. let menuDiv = document.createElement("div");
  617. menuDiv.id = "menuDiv";
  618. menuDiv.draggable = false;
  619. menuDiv.style.top = "0";
  620. menuDiv.style.right = "0";
  621. menuDiv.style.left = "auto";
  622. menuDiv.style.transform = "translateY(-50%) translateX(-50%) scale(1)";
  623. document.body.appendChild(menuDiv);
  624.  
  625. menuDiv.addEventListener("click", function(e) {
  626. let target = e.target;
  627. if (target.tagName === "BUTTON" || target.tagName === "INPUT") {
  628. target.parentElement.style.boxShadow = "0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff";
  629. setTimeout(function() {
  630. target.parentElement.style.boxShadow = "";
  631. }, 200);
  632. }
  633. });
  634. let HTML = new Html();
  635. HTML.set("menuDiv");
  636. HTML.setStyle(`
  637. position: fixed;
  638. top: 19%;
  639. right: 66%;
  640. transform: translateY(-50%) translateX(-50%) scale(1);
  641. transition: none;
  642. background-color: rgba(50, 50, 50, 0.8);
  643. padding: 10px;
  644. border-radius: 10px;
  645. box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.3);
  646. overflow-y: scroll;
  647. max-height: 40vh;
  648. color: white;
  649. text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  650. width: 50vw;
  651. max-width: 350px;
  652. font-size: 1.5rem;
  653. border: 2px solid rgba(255, 255, 255, 0.1);
  654. box-sizing: border-box;
  655.  
  656. :root {
  657. --primary-color: #50afef;
  658. --secondary-color: #875de7;
  659. --tertiary-color: #e75d5a;
  660. --background-color: #242424;
  661. --foreground-color: #e0e0e0;
  662. --selection-color: #494b48;
  663. }
  664.  
  665. code,
  666. pre {
  667. background-color: var(--background-color);
  668. color: var(--foreground-color);
  669. font-family: 'Fira Code', monospace;
  670. }
  671.  
  672. ::selection {
  673. background-color: var(--selection-color);
  674. }
  675.  
  676. a {
  677. color: var(--primary-color);
  678. text-decoration: none;
  679. }
  680.  
  681. button,
  682. input[type="submit"],
  683. input[type="button"] {
  684. background-color: var(--primary-color);
  685. color: var(--background-color);
  686. border: none;
  687. padding: 0.5rem 1rem;
  688. border-radius: 0.25rem;
  689. cursor: pointer;
  690. transition: background-color 0.2s ease-out;
  691. }
  692.  
  693. button:hover,
  694. input[type="submit"]:hover,
  695. input[type="button"]:hover {
  696. background-color: #3b9cfc;
  697. }
  698.  
  699. button:active,
  700. input[type="submit"]:active,
  701. input[type="button"]:active {
  702. background-color: #2280e6;
  703. }
  704.  
  705. input[type="text"],
  706. input[type="number"],
  707. input[type="password"] {
  708. background-color: var(--foreground-color);
  709. color: var(--background-color);
  710. border: none;
  711. padding: 0.5rem 1rem;
  712. border-radius: 0.25rem;
  713. width: 100%;
  714. box-sizing: border-box;
  715. margin-bottom: 1rem;
  716. transition: background-color 0.2s ease-out;
  717. }
  718.  
  719. input[type="text"]:focus,
  720. input[type="number"]:focus,
  721. input[type="password"]:focus {
  722. background-color: #494b48;
  723. }
  724. `);
  725. HTML.startDiv({
  726. id: "menuHeadLine",
  727. class: "menuClass"
  728. }, (html) => {
  729. html.add(`Starclient`);
  730. HTML.addDiv({
  731. id: "menuButtons",
  732. style: "display: block; overflow-y: visible;",
  733. class: "menuC",
  734. appendID: "menuHeadLine"
  735. }, (html) => {
  736. html.button({
  737. class: "menuB",
  738. innerHTML: "Debug",
  739. onclick: "window.debug()"
  740. });
  741. html.button({
  742. class: "menuB",
  743. innerHTML: "Freeze Player",
  744. onclick: "window.freezePlayer()"
  745. });
  746. html.button({
  747. class: "menuB",
  748. innerHTML: "Dagger optiomazation",
  749. oneclick: "window.rushmode()"
  750. });
  751. });
  752. HTML.addDiv({
  753. id: "menuMain",
  754. style: "display: block",
  755. class: "menuC",
  756. appendID: "menuHeadLine"
  757. }, (html) => {
  758. html.newLine();
  759. html.add(`Auto-Grinder: `);
  760. html.checkBox({
  761. id: "weaponGrind",
  762. class: "checkB",
  763. onclick: "window.startGrind()"
  764. });
  765. html.newLine(2);
  766. html.add(`AutoHeal:`);
  767. html.checkBox({
  768. id: "healingBeta",
  769. class: "checkB",
  770. checked: true
  771. });
  772. html.newLine(2);
  773. html.add(` ASpin :`);
  774. html.checkBox({
  775. id: "spin",
  776. class: "checkB",
  777. value: "spin",
  778. checked: false
  779. });
  780. html.newLine();
  781. html.add(`BrightnessType: `);
  782. html.select({
  783. id: "brightnesstype", class: "Cselect", option: {
  784. "Morning": {
  785. id: "fz",
  786. selected:true
  787.  
  788. },
  789. }
  790. });
  791.  
  792. });
  793. HTML.addDiv({
  794. id: "menuMain",
  795. style: "display: block",
  796. class: "menuC",
  797. appendID: "menuHeadLine"
  798. }, (html) => {
  799. html.add(`Sync/Anti`);
  800. html.newLine(2);
  801. html.add(`SyncType: `);
  802. html.select({
  803. id: "syncType", class: "Cselect", option: {
  804. "InstaSync": {
  805. id: "s1",
  806. },
  807. "BullHitSync": {
  808. id: "s2",
  809. selected: true
  810. }
  811. }
  812. });
  813. html.newLine();
  814. html.add("Sync: ");
  815. html.checkBox({
  816. id: "musketSync",
  817. class: "checkB",
  818. checked: true
  819. });
  820. html.newLine();
  821. html.add("Auto Sync On Second: ");
  822. html.checkBox({
  823. id: "autosyncsec",
  824. class: "checkB",
  825. checked: true
  826. });
  827. html.newLine();
  828. html.add("Auto Sync On Hited: ");
  829. html.checkBox({
  830. id: "autosyncHited",
  831. class: "checkB",
  832. checked: true
  833. });
  834. html.newLine();
  835. html.add("Anti Sync2: ");
  836. html.checkBox({
  837. id: "antisync",
  838. class: "checkB",
  839. checked: true
  840. });
  841. html.newLine();
  842. html.add("Emp Anti: ");
  843. html.checkBox({
  844. id: "SmartEmpSoldierAnti",
  845. class: "checkB",
  846. checked: false
  847. });
  848. html.newLine();
  849. html.add("Soldier anti: ");
  850. html.checkBox({
  851. id: "SmartEmpSoldierAnti",
  852. class: "checkB",
  853. checked: true
  854. });
  855.  
  856. html.newLine(2);
  857. html.add("AntiKick:");
  858. html.checkBox({
  859. id: "antikick",
  860. class: "checkB",
  861. checked: false
  862. });
  863. html.newLine(2);
  864. html.add(`avoid function:`);
  865. html.checkBox({
  866. id: "avoidspike",
  867. class: "checkB",
  868. checked: true
  869. });
  870. html.newLine();
  871. });
  872. HTML.addDiv({
  873. id: "menuConfig",
  874. class: "menuC",
  875. appendID: "menuHeadLine"
  876. }, (html) => {
  877. html.add(`AutoPlacer Placement Tick: `);
  878. html.text({
  879. id: "autoPlaceTick",
  880. class: "customText",
  881. value: "2",
  882. size: "2em",
  883. maxLength: "1"
  884. });
  885. html.newLine();
  886. html.add(`Configs: `);
  887. html.selectMenu({
  888. id: "configsChanger",
  889. class: "Cselect",
  890. menu: configs
  891. });
  892. html.newLine();
  893. html.add(`InstaKill Type: `);
  894. html.select({
  895. id: "instaType",
  896. class: "Cselect",
  897. option: {
  898. AE86: {
  899. id: "normal",
  900. selected: true
  901. },
  902. revtick: {
  903. id: "rev"
  904. }
  905. }
  906. });
  907. html.newLine();
  908. html.add(`AntiBull Type: `);
  909. html.select({
  910. id: "antiBullType",
  911. class: "Cselect",
  912. option: {
  913. "Disable AntiBull": {
  914. id: "noab",
  915. selected: true
  916. },
  917. "When Reloaded": {
  918. id: "abreload",
  919. },
  920. "Primary Reloaded": {
  921. id: "abalway"
  922. }
  923. }
  924. });
  925. html.newLine();
  926. html.add(`Pre placer Type: `);
  927. html.select({
  928. id: "preplacerType", class: "Cselect", option: {
  929. Spike: {
  930. id: "preplacerspike",
  931. selected: true
  932. },
  933. Trap: {
  934. id: "preplacertrap"
  935. }
  936. }
  937. });
  938. html.newLine();
  939. html.add(`AutoPlaceType: `);
  940. html.select({
  941. id: "autoPlacetype", class: "Cselect", option: {
  942. Smart: {
  943. id: "smart",
  944. selected: true
  945. },
  946. MagicPlace: {
  947. id: "magicplace",
  948. },
  949. AiPlace: {
  950. id: "aiplace",
  951. },
  952. Spamtrap: {
  953. id: "spamtrap",
  954. },
  955. Spamtrap2: {
  956. id: "spamtrap2",
  957. },
  958. Honor: {
  959. id: "ramdomplc",
  960.  
  961. }
  962. }
  963. });
  964. html.newLine();
  965. html.add(`Backup Nobull Insta: `);
  966. html.checkBox({
  967. id: "backupNobull",
  968. class: "checkB",
  969. checked: true
  970. });
  971. html.newLine();
  972. html.add(`Turret Gear Combat Assistance: `);
  973. html.checkBox({
  974. id: "turretCombat",
  975. class: "checkB"
  976. });
  977. html.newLine();
  978. html.add(`Safe AntiSpikeTick: `);
  979. html.checkBox({
  980. id: "safeAntiSpikeTick",
  981. class: "checkB",
  982. checked: true
  983. });
  984. html.newLine();
  985. });
  986. HTML.addDiv({
  987. id: "menuOther",
  988. class: "menuC",
  989. appendID: "menuHeadLine"
  990. }, (html) => {
  991. html.button({
  992. class: "menuB",
  993. innerHTML: "Connect Bots",
  994. onclick: "window.tryConnectBots()"
  995. });
  996. html.button({
  997. class: "menuB",
  998. innerHTML: "Disconnect Bots",
  999. onclick: "window.destroyBots()"
  1000. });
  1001. html.newLine();
  1002. html.button({
  1003. class: "menuB",
  1004. innerHTML: "Connect FBots",
  1005. onclick: "window.connectFillBots()"
  1006. });
  1007. html.button({
  1008. class: "menuB",
  1009. innerHTML: "Disconnect FBots",
  1010. onclick: "window.destroyFillBots()"
  1011. });
  1012. html.newLine();
  1013. html.button({
  1014. class: "menuB",
  1015. innerHTML: "Reset Break Objects",
  1016. onclick: "window.resBuild()"
  1017. });
  1018. html.newLine();
  1019. html.add(`Break Objects Range: `);
  1020. html.text({
  1021. id: "breakRange",
  1022. class: "customText",
  1023. value: "700",
  1024. size: "3em",
  1025. maxLength: "4"
  1026. });
  1027. html.newLine();
  1028. html.add(`Predict Movement Type: `);
  1029. html.select({
  1030. id: "predictType",
  1031. class: "Cselect",
  1032. option: {
  1033. "Disable Render": {
  1034. id: "disableRender",
  1035. selected: true
  1036. },
  1037. "X/Y and 2": {
  1038. id: "pre2",
  1039. },
  1040. "X/Y and 3": {
  1041. id: "pre3"
  1042. }
  1043. }
  1044. });
  1045. html.newLine();
  1046. html.add(`Render Placers: `);
  1047. html.checkBox({
  1048. id: "placeVis",
  1049. class: "checkB",
  1050. });
  1051. html.newLine();
  1052. html.add(`Bot Mode: `);
  1053. html.select({
  1054. id: "mode",
  1055. class: "Cselect",
  1056. option: {
  1057. "Clear Building": {
  1058. id: "clear",
  1059. selected: true
  1060. },
  1061. "Sync": {
  1062. id: "zync",
  1063. },
  1064. "Search": {
  1065. id: "zearch"
  1066. },
  1067. "Clear Everything": {
  1068. id: "fuckemup"
  1069. },
  1070. "Flex": {
  1071. id: "flex"
  1072. }
  1073. }
  1074. });
  1075. html.newLine(2);
  1076. html.button({
  1077. class: "menuB",
  1078. innerHTML: "Toggle Fbots Circle",
  1079. onclick: "window.toggleBotsCircle()"
  1080. });
  1081. html.newLine();
  1082. html.add(`Circle Rad: `);
  1083. html.text({
  1084. id: "circleRad",
  1085. class: "customText",
  1086. value: "200",
  1087. size: "3em",
  1088. maxLength: "4"
  1089. });
  1090. html.newLine();
  1091. html.add(`Rad Speed: `);
  1092. html.text({
  1093. id: "radSpeed",
  1094. class: "customText",
  1095. value: "0.1",
  1096. size: "2em",
  1097. maxLength: "3"
  1098. });
  1099. html.newLine();
  1100. html.add(`Bot Zetup Type: `);
  1101. html.select({
  1102. id: "setup",
  1103. class: "Cselect",
  1104. option: {
  1105. "Dagger Musket": {
  1106. id: "dm",
  1107. selected: true
  1108. },
  1109. "Katana Hammer": {
  1110. id: "kh",
  1111. },
  1112. "Dagger Repeater-Crossbow": {
  1113. id: "dr"
  1114. },
  1115. "Zhort-Zword Muzket": {
  1116. id: "zd"
  1117. }
  1118. }
  1119. });
  1120. html.newLine(2);
  1121. html.add(`Cross World: `);
  1122. html.checkBox({
  1123. id: "funni",
  1124. class: "checkB"
  1125. });
  1126. html.newLine();
  1127. html.add("Show Grid: ");
  1128. html.checkBox({
  1129. id: "gridshow",
  1130. class: "checkB",
  1131. checked: true
  1132. });
  1133. html.newLine();
  1134. html.button({
  1135. class: "menuB",
  1136. innerHTML: "Toggle Another Visual",
  1137. onclick: "window.toggleVisual()"
  1138. });
  1139. html.newLine();
  1140. });
  1141. });
  1142.  
  1143. let menuChatDiv = document.createElement("div");
  1144. menuChatDiv.id = "menuChatDiv";
  1145. document.body.appendChild(menuChatDiv);
  1146. HTML.set("menuChatDiv");
  1147. HTML.setStyle(`
  1148. color: #fff;
  1149. position: absolute;
  1150. display: none;
  1151. left: -1px;
  1152. top: 0px;
  1153. box-shadow: 0px 0px 10px #ffffff;
  1154. `);
  1155. HTML.resetHTML();
  1156. HTML.setCSS(`
  1157. .chDiv{
  1158. color: #fff;
  1159. padding: 5px;
  1160. width: 340px;
  1161. height: 280px;
  1162. background-color: rgba(0, 0, 0, 0.35);
  1163. }
  1164. .chMainDiv{
  1165. font-family: "Sans Serif";
  1166. font-size: 12px;
  1167. max-height: 235px;
  1168. overflow-y: scroll;
  1169. -webkit-touch-callout: none;
  1170. -webkit-user-select: none;
  1171. -khtml-user-select: none;
  1172. -moz-user-select: none;
  1173. -ms-user-select: none;
  1174. user-select: none;
  1175. }
  1176. .chMainBox{
  1177. position: absolute;
  1178. left: -1px;
  1179. bottom: 10px;
  1180. width: 340px;
  1181. height: 30px;
  1182. background-color: rgb(128, 128, 128, 0.35);
  1183. -webkit-border-radius: 4px;
  1184. -moz-border-radius: 4px;
  1185. border-radius: 4px;
  1186. color: #fff;
  1187. font-family: "Sans Serif";
  1188. font-size: 12px;
  1189. border: none;
  1190. outline: none;
  1191. }
  1192. `);
  1193. HTML.startDiv({id: "mChDiv", class: "chDiv"}, (html) => {
  1194. HTML.addDiv({id: "mChMain", class: "chMainDiv", appendID: "mChDiv"}, (html) => {
  1195. });
  1196. html.text({id: "mChBox", class: "chMainBox", placeHolder: `To chat click here or press "Enter" key`});
  1197. });
  1198.  
  1199. let menuChats = getEl("mChMain");
  1200. let menuChatBox = getEl("mChBox");
  1201. let menuCBFocus = false;
  1202. let menuChCounts = 0;
  1203.  
  1204. menuChatBox.value = "";
  1205. menuChatBox.addEventListener("focus", () => {
  1206. menuCBFocus = true;
  1207. });
  1208. menuChatBox.addEventListener("blur", () => {
  1209. menuCBFocus = false;
  1210. });
  1211.  
  1212. function addMenuChText(name, message, color, noTimer) {
  1213. HTML.set("menuChatDiv");
  1214. color = color || "white";
  1215. let time = new Date();
  1216. let min = time.getMinutes();
  1217. let hour = time.getHours();
  1218. let text = ``;
  1219. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1220. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1221. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1222. text = `<plaintext>${text}`;
  1223. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1224. html.add(text);
  1225. });
  1226. menuChats.scrollTop = menuChats.scrollHeight;
  1227. menuChCounts++;
  1228. }
  1229. function chch(name, message, color, noTimer) {
  1230. HTML.set("menuChatDiv");
  1231. color = color || "white";
  1232. let time = new Date();
  1233. let text = ``;
  1234. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1235. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1236. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1237. html.add(text);
  1238. });
  1239. menuChats.scrollTop = menuChats.scrollHeight;
  1240. menuChCounts++;
  1241. }
  1242.  
  1243. function resetMenuChText() {
  1244. menuChats.innerHTML = ``;
  1245. menuChCounts = 0;
  1246. addMenuChText(null, "", "white", 1) // chat history
  1247. }
  1248. resetMenuChText();
  1249.  
  1250. let menuIndex = 0;
  1251. let menus = ["menuMain", "menuConfig", "menuOther"];
  1252. window.changeMenu = function() {
  1253. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1254. menuIndex++;
  1255. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1256. };
  1257.  
  1258. let mStatus = document.createElement("div");
  1259. mStatus.id = "status";
  1260. getEl("gameUI").appendChild(mStatus);
  1261. HTML.set("status");
  1262. HTML.setStyle(`
  1263. display: block;
  1264. position: absolute;
  1265. color: #ddd;
  1266. font: 15px Hammersmith One;
  1267. bottom: 215px;
  1268. left: 20px;
  1269. `);
  1270. HTML.resetHTML();
  1271. HTML.setCSS(`
  1272. .sizing {
  1273. font-size: 15px;
  1274. }
  1275. .mod {
  1276. font-size: 15px;
  1277. display: inline-block;
  1278. }
  1279. `);
  1280. HTML.startDiv({
  1281. id: "uehmod",
  1282. class: "sizing"
  1283. }, (html) => {
  1284. html.add(`Ping: `);
  1285. HTML.addDiv({
  1286. id: "pingFps",
  1287. class: "mod",
  1288. appendID: "uehmod"
  1289. }, (html) => {
  1290. html.add("None");
  1291. });
  1292. html.newLine();
  1293. html.add(`Packet: `);
  1294. HTML.addDiv({
  1295. id: "packetStatus",
  1296. class: "mod",
  1297. appendID: "uehmod"
  1298. }, (html) => {
  1299. html.add("None");
  1300. });
  1301. });
  1302.  
  1303. /*function modLog() {
  1304. let logs = [];
  1305. for (let i = 0; i < arguments.length; i++) {
  1306. logs.push(arguments[i]);
  1307. }
  1308. getEl("modLog").innerHTML = logs;
  1309. }*/
  1310.  
  1311. let openMenu = false;
  1312.  
  1313. let WS = undefined;
  1314. let socketID = undefined;
  1315.  
  1316. let useWasd = false;
  1317. let secPacket = 0;
  1318. let secMax = 120;
  1319. let secTime = 1000;
  1320. let firstSend = {
  1321. sec: false
  1322. };
  1323. let game = {
  1324. tick: 0,
  1325. tickQueue: [],
  1326. tickBase: function(set, tick) {
  1327. if (this.tickQueue[this.tick + tick]) {
  1328. this.tickQueue[this.tick + tick].push(set);
  1329. } else {
  1330. this.tickQueue[this.tick + tick] = [set];
  1331. }
  1332. },
  1333. tickRate: (1000 / config.serverUpdateRate),
  1334. tickSpeed: 0,
  1335. lastTick: performance.now()
  1336. };
  1337. let modConsole = [];
  1338.  
  1339. let dontSend = false;
  1340. let fpsTimer = {
  1341. last: 0,
  1342. time: 0,
  1343. ltime: 0
  1344. }
  1345. let lastMoveDir = undefined;
  1346. let lastsp = ["cc", 1, "__proto__"];
  1347.  
  1348. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1349. WebSocket.prototype.send = function(message) {
  1350. if (!WS) {
  1351. WS = this;
  1352. WS.addEventListener("message", function(msg) {
  1353. getMessage(msg);
  1354. });
  1355. WS.addEventListener("close", (event) => {
  1356. if (event.code == 4001) {
  1357. window.location.reload();
  1358. }
  1359. });
  1360. }
  1361. if (WS == this) {
  1362. dontSend = false;
  1363.  
  1364. // EXTRACT DATA ARRAY:
  1365. let data = new Uint8Array(message);
  1366. let parsed = window.msgpack.decode(data);
  1367. let type = parsed[0];
  1368. data = parsed[1];
  1369.  
  1370. // SEND MESSAGE:
  1371. if (type == "6") {
  1372.  
  1373. if (data[0]) {
  1374.  
  1375. // ANTI PROFANITY:
  1376. 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", ];
  1377. let tmpString;
  1378. profanity.forEach((profany) => {
  1379. if (data[0].indexOf(profany) > -1) {
  1380. tmpString = "";
  1381. for (let i = 0; i < profany.length; ++i) {
  1382. if (i == 1) {
  1383. tmpString += String.fromCharCode(0);
  1384. }
  1385. tmpString += profany[i];
  1386. }
  1387. let re = new RegExp(profany, "g");
  1388. data[0] = data[0].replace(re, tmpString);
  1389. }
  1390. });
  1391.  
  1392. // FIX CHAT:
  1393. data[0] = data[0].slice(0, 30);
  1394. }
  1395.  
  1396. } else if (type == "L") {
  1397. // MAKE SAME CLAN:
  1398. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1399. data[0] = data[0].slice(0, 7);
  1400. } else if (type == "M") {
  1401. // APPLY CYAN COLOR:
  1402. data[0].name = data[0].name == "" ? "Botss" : data[0].name;
  1403. data[0].moofoll = true;
  1404. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1405. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1406. } else if (type == "D") {
  1407. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1408. dontSend = true;
  1409. } else {
  1410. my.lastDir = data[0];
  1411. }
  1412. } else if (type == "d") {
  1413. if (!data[2]) {
  1414. dontSend = true;
  1415. } else {
  1416. if (![null, undefined].includes(data[1])) {
  1417. my.lastDir = data[1];
  1418. }
  1419. }
  1420. } else if (type == "K") {
  1421. if (!data[1]) {
  1422. dontSend = true;
  1423. }
  1424. } else if (type == "S") {
  1425. instaC.wait = !instaC.wait;
  1426. dontSend = true;
  1427. } else if (type == "a") {
  1428. if (data[1]) {
  1429. if (player.moveDir == data[0]) {
  1430. dontSend = true;
  1431. }
  1432. player.moveDir = data[0];
  1433. } else {
  1434. dontSend = true;
  1435. }
  1436. }
  1437. if (!dontSend) {
  1438. let binary = window.msgpack.encode([type, data]);
  1439. this.nsend(binary);
  1440.  
  1441. // START COUNT:
  1442. if (!firstSend.sec) {
  1443. firstSend.sec = true;
  1444. setTimeout(() => {
  1445. firstSend.sec = false;
  1446. secPacket = 0;
  1447. }, secTime);
  1448. }
  1449.  
  1450. if (secPacket == 100) {
  1451. addMenuChText("Warn", "Sending Too Many Packets", "#cc5151", 1);
  1452. }
  1453.  
  1454.  
  1455.  
  1456. secPacket++;
  1457. }
  1458. } else {
  1459. this.nsend(message);
  1460. }
  1461. }
  1462.  
  1463. function packet(type) {
  1464. // EXTRACT DATA ARRAY:
  1465. let data = Array.prototype.slice.call(arguments, 1);
  1466.  
  1467. // SEND MESSAGE:
  1468. let binary = window.msgpack.encode([type, data]);
  1469. WS.send(binary);
  1470. }
  1471.  
  1472. function origPacket(type) {
  1473. // EXTRACT DATA ARRAY:
  1474. let data = Array.prototype.slice.call(arguments, 1);
  1475.  
  1476. // SEND MESSAGE:
  1477. let binary = window.msgpack.encode([type, data]);
  1478. WS.nsend(binary);
  1479. }
  1480.  
  1481. window.leave = function() {
  1482. origPacket("kys", {
  1483. "frvr is so bad": true,
  1484. "sidney is too good": true,
  1485. "dev are too weak": true,
  1486. });
  1487. };
  1488.  
  1489. //...lol
  1490. let io = {
  1491. send: packet
  1492. };
  1493.  
  1494. function getMessage(message) {
  1495. let data = new Uint8Array(message.data);
  1496. let parsed = window.msgpack.decode(data);
  1497. let type = parsed[0];
  1498. data = parsed[1];
  1499. let events = {
  1500. A: setInitData, // id: setInitData,
  1501. //B: disconnect,
  1502. C: setupGame, // 1: setupGame,
  1503. D: addPlayer, // 2: addPlayer,
  1504. E: removePlayer, // 4: removePlayer,
  1505. a: updatePlayers, // 33: updatePlayers,
  1506. G: updateLeaderboard, // 5: updateLeaderboard,here
  1507. H: loadGameObject, // 6: loadGameObject,
  1508. I: loadAI, // a: loadAI,
  1509. J: animateAI, // aa: animateAI,
  1510. K: gatherAnimation, // 7: gatherAnimation,
  1511. L: wiggleGameObject, // 8: wiggleGameObject,
  1512. M: shootTurret, // sp: shootTurret,
  1513. N: updatePlayerValue, // 9: updatePlayerValue,
  1514. O: updateHealth, // h: updateHealth,//here
  1515. P: killPlayer, // 11: killPlayer,
  1516. Q: killObject, // 12: killObject,
  1517. R: killObjects, // 13: killObjects,
  1518. S: updateItemCounts, // 14: updateItemCounts,
  1519. T: updateAge, // 15: updateAge,
  1520. U: updateUpgrades, // 16: updateUpgrades,
  1521. V: updateItems, // 17: updateItems,
  1522. X: addProjectile, // 18: addProjectile,
  1523. // Y: remProjectile, // 19: remProjectile,
  1524. //Z: serverShutdownNotice,
  1525. //0: addAlliance,
  1526. //1: deleteAlliance,
  1527. 2: allianceNotification, // an: allianceNotification,
  1528. 3: setPlayerTeam, // st: setPlayerTeam,
  1529. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1530. 5: updateStoreItems, // us: updateStoreItems,
  1531. 6: receiveChat, // ch: receiveChat,
  1532. 7: updateMinimap, // mm: updateMinimap,
  1533. 8: showText, // t: showText,
  1534. 9: pingMap, // p: pingMap,
  1535. 0: pingSocketResponse,
  1536. };
  1537. if (type == "io-init") {
  1538. socketID = data[0];
  1539. } else {
  1540. if (events[type]) {
  1541. events[type].apply(undefined, data);
  1542. }
  1543. }
  1544. }
  1545.  
  1546. // MATHS:
  1547. Math.lerpAngle = function(value1, value2, amount) {
  1548. let difference = Math.abs(value2 - value1);
  1549. if (difference > Math.PI) {
  1550. if (value1 > value2) {
  1551. value2 += Math.PI * 2;
  1552. } else {
  1553. value1 += Math.PI * 2;
  1554. }
  1555. }
  1556. let value = value2 + ((value1 - value2) * amount);
  1557. if (value >= 0 && value <= Math.PI * 2) return value;
  1558. return value % (Math.PI * 2);
  1559. };
  1560.  
  1561. // REOUNDED RECTANGLE:
  1562. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1563. if (w < 2 * r) r = w / 2;
  1564. if (h < 2 * r) r = h / 2;
  1565. if (r < 0)
  1566. r = 0;
  1567. this.beginPath();
  1568. this.moveTo(x + r, y);
  1569. this.arcTo(x + w, y, x + w, y + h, r);
  1570. this.arcTo(x + w, y + h, x, y + h, r);
  1571. this.arcTo(x, y + h, x, y, r);
  1572. this.arcTo(x, y, x + w, y, r);
  1573. this.closePath();
  1574. return this;
  1575. };
  1576. //preplacer tests for better results
  1577. let preplaceDelay = {
  1578. killObject: -1,
  1579. gatherAnimation: -1,
  1580. total: function() {
  1581. return (new Date() - Math.abs(Math.trunc(this.killObject - this.gatherAnimation)));
  1582. },
  1583. }
  1584. // GLOBAL VALUES:
  1585. function resetMoveDir() {
  1586. keys = {};
  1587. io.send("e");
  1588. }
  1589.  
  1590. let allChats = [];
  1591. let ticks = {
  1592. tick: 0,
  1593. delay: 0,
  1594. time: [],
  1595. manage: [],
  1596. };
  1597. let ais = [];
  1598. let players = [];
  1599. let alliances = [];
  1600. let alliancePlayers = [];
  1601. let allianceNotifications = [];
  1602. let gameObjects = [];
  1603. let liztobj = [];
  1604. let projectiles = [];
  1605. let deadPlayers = [];
  1606.  
  1607. let breakObjects = [];
  1608.  
  1609. let player;
  1610. let playerSID;
  1611. let tmpObj;
  1612.  
  1613. let enemy = [];
  1614. let nears = [];
  1615. let near = [];
  1616.  
  1617. let my = {
  1618. reloaded: false,
  1619. waitHit: 0,
  1620. autoAim: false,
  1621. revAim: false,
  1622. ageInsta: true,
  1623. reSync: false,
  1624. bullTick: 0,
  1625. anti0Tick: 0,
  1626. antiSync: false,
  1627. safePrimary: function(tmpObj) {
  1628. return [0, 8].includes(tmpObj.primaryIndex);
  1629. },
  1630. safeSecondary: function(tmpObj) {
  1631. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1632. },
  1633. lastDir: 0,
  1634. autoPush: false,
  1635. pushData: {}
  1636. }
  1637.  
  1638. // FIND OBJECTS BY ID/SID:
  1639. function findID(tmpObj, tmp) {
  1640. return tmpObj.find((THIS) => THIS.id == tmp);
  1641. }
  1642.  
  1643. function findSID(tmpObj, tmp) {
  1644. return tmpObj.find((THIS) => THIS.sid == tmp);
  1645. }
  1646.  
  1647. function findPlayerByID(id) {
  1648. return findID(players, id);
  1649. }
  1650.  
  1651. function findPlayerBySID(sid) {
  1652. return findSID(players, sid);
  1653. }
  1654.  
  1655. function findAIBySID(sid) {
  1656. return findSID(ais, sid);
  1657. }
  1658.  
  1659. function findObjectBySid(sid) {
  1660. return findSID(gameObjects, sid);
  1661. }
  1662.  
  1663. function findProjectileBySid(sid) {
  1664. return findSID(gameObjects, sid);
  1665. }
  1666.  
  1667. let adCard = getEl("adCard");
  1668. adCard.remove();
  1669. let promoImageHolder = getEl("promoImgHolder");
  1670. promoImageHolder.remove();
  1671.  
  1672. let chatButton = getEl("chatButton");
  1673. chatButton.remove();
  1674. let gameCanvas = getEl("gameCanvas");
  1675. let mainContext = gameCanvas.getContext("2d");
  1676. let mapDisplay = getEl("mapDisplay");
  1677. let mapContext = mapDisplay.getContext("2d");
  1678. mapDisplay.width = 300;
  1679. mapDisplay.height = 300;
  1680. let storeMenu = getEl("storeMenu");
  1681. let storeHolder = getEl("storeHolder");
  1682. let upgradeHolder = getEl("upgradeHolder");
  1683. let upgradeCounter = getEl("upgradeCounter");
  1684. let chatBox = getEl("chatBox");
  1685. chatBox.autocomplete = "off";
  1686. chatBox.style.textAlign = "center";
  1687. chatBox.style.width = "18em";
  1688. let chatHolder = getEl("chatHolder");
  1689. let actionBar = getEl("actionBar");
  1690. let leaderboardData = getEl("leaderboardData");
  1691. let itemInfoHolder = getEl("itemInfoHolder");
  1692. let menuCardHolder = getEl("menuCardHolder");
  1693. let mainMenu = getEl("mainMenu");
  1694. let diedText = getEl("diedText");
  1695. let screenWidth;
  1696. let screenHeight;
  1697. let maxScreenWidth = config.maxScreenWidth;
  1698. let maxScreenHeight = config.maxScreenHeight;
  1699. let pixelDensity = 1;
  1700. let delta;
  1701. let now;
  1702. let lastUpdate = performance.now();
  1703. let camX;
  1704. let camY;
  1705. let tmpDir;
  1706. let mouseX = 0;
  1707. let mouseY = 0;
  1708. let allianceMenu = getEl("allianceMenu");
  1709. let waterMult = 1;
  1710. let waterPlus = 0;
  1711.  
  1712. let outlineColor = "#525252";
  1713. let darkOutlineColor = "#3d3f42";
  1714. let outlineWidth = 5.5;
  1715.  
  1716. let firstSetup = true;
  1717. let keys = {};
  1718. let moveKeys = {
  1719. 87: [0, -1],
  1720. 38: [0, -1],
  1721. 83: [0, 1],
  1722. 40: [0, 1],
  1723. 65: [-1, 0],
  1724. 37: [-1, 0],
  1725. 68: [1, 0],
  1726. 39: [1, 0],
  1727. };
  1728. let attackState = 0;
  1729. let inGame = false;
  1730.  
  1731. let macro = {};
  1732. let mills = {
  1733. place: 0,
  1734. placeSpawnPads: 0
  1735. };
  1736. let lastDir;
  1737.  
  1738. let lastLeaderboardData = [];
  1739.  
  1740. // ON LOAD:
  1741. let inWindow = true;
  1742. window.onblur = function() {
  1743. inWindow = false;
  1744. };
  1745. window.onfocus = function() {
  1746. inWindow = true;
  1747. if (player && player.alive) {
  1748. // resetMoveDir();
  1749. }
  1750. };
  1751. let ms = {
  1752. avg: 0,
  1753. max: 0,
  1754. min: 0,
  1755. delay: 0
  1756. }
  1757. function pingSocketResponse() {
  1758. let pingTime = window.pingTime;
  1759. const pingDisplay = document.getElementById("pingDisplay")
  1760. pingDisplay.innerText = "";
  1761. if (pingTime > ms.max || isNaN(ms.max)) {
  1762. ms.max = pingTime;
  1763. }
  1764. if (pingTime < ms.min || isNaN(ms.min)) {
  1765. ms.min = pingTime;
  1766. }
  1767.  
  1768. // if (pingTime >= 90) {
  1769. // doAutoQ = true;
  1770. // } else {
  1771. // doAutoQ = false;
  1772. // }
  1773. }
  1774.  
  1775. let placeVisible = [];
  1776.  
  1777. /** CLASS CODES */
  1778.  
  1779. class Utils {
  1780. constructor() {
  1781.  
  1782. // MATH UTILS:
  1783. let mathABS = Math.abs,
  1784. mathCOS = Math.cos,
  1785. mathSIN = Math.sin,
  1786. mathPOW = Math.pow,
  1787. mathSQRT = Math.sqrt,
  1788. mathATAN2 = Math.atan2,
  1789. mathPI = Math.PI;
  1790.  
  1791. let _this = this;
  1792.  
  1793. // GLOBAL UTILS:
  1794. this.round = function(n, v) {
  1795. return Math.round(n * v) / v;
  1796. };
  1797. this.toRad = function(angle) {
  1798. return angle * (mathPI / 180);
  1799. };
  1800. this.toAng = function(radian) {
  1801. return radian / (mathPI / 180);
  1802. };
  1803. this.randInt = function(min, max) {
  1804. return Math.floor(Math.random() * (max - min + 1)) + min;
  1805. };
  1806. this.randFloat = function(min, max) {
  1807. return Math.random() * (max - min + 1) + min;
  1808. };
  1809. this.lerp = function(value1, value2, amount) {
  1810. return value1 + (value2 - value1) * amount;
  1811. };
  1812. this.decel = function(val, cel) {
  1813. if (val > 0)
  1814. val = Math.max(0, val - cel);
  1815. else if (val < 0)
  1816. val = Math.min(0, val + cel);
  1817. return val;
  1818. };
  1819. this.getDistance = function(x1, y1, x2, y2) {
  1820. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1821. };
  1822. this.getDist = function(tmp1, tmp2, type1, type2) {
  1823. let tmpXY1 = {
  1824. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1825. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1826. };
  1827. let tmpXY2 = {
  1828. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1829. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1830. };
  1831. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1832. };
  1833. this.getDirection = function(x1, y1, x2, y2) {
  1834. return mathATAN2(y1 - y2, x1 - x2);
  1835. };
  1836. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1837. let tmpXY1 = {
  1838. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1839. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1840. };
  1841. let tmpXY2 = {
  1842. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1843. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1844. };
  1845. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1846. };
  1847. this.getAngleDist = function(a, b) {
  1848. let p = mathABS(b - a) % (mathPI * 2);
  1849. return (p > mathPI ? (mathPI * 2) - p : p);
  1850. };
  1851. this.isNumber = function(n) {
  1852. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1853. };
  1854. this.isString = function(s) {
  1855. return (s && typeof s == "string");
  1856. };
  1857. this.kFormat = function(num) {
  1858. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1859. };
  1860. this.sFormat = function(num) {
  1861. let fixs = [{
  1862. num: 1e3,
  1863. string: "k"
  1864. },
  1865. {
  1866. num: 1e6,
  1867. string: "m"
  1868. },
  1869. {
  1870. num: 1e9,
  1871. string: "b"
  1872. },
  1873. {
  1874. num: 1e12,
  1875. string: "q"
  1876. }
  1877. ].reverse();
  1878. let sp = fixs.find(v => num >= v.num);
  1879. if (!sp) return num;
  1880. return (num / sp.num).toFixed(1) + sp.string;
  1881. };
  1882. this.capitalizeFirst = function(string) {
  1883. return string.charAt(0).toUpperCase() + string.slice(1);
  1884. };
  1885. this.fixTo = function(n, v) {
  1886. return parseFloat(n.toFixed(v));
  1887. };
  1888. this.sortByPoints = function(a, b) {
  1889. return parseFloat(b.points) - parseFloat(a.points);
  1890. };
  1891. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1892. let minX = x1;
  1893. let maxX = x2;
  1894. if (x1 > x2) {
  1895. minX = x2;
  1896. maxX = x1;
  1897. }
  1898. if (maxX > recX2)
  1899. maxX = recX2;
  1900. if (minX < recX)
  1901. minX = recX;
  1902. if (minX > maxX)
  1903. return false;
  1904. let minY = y1;
  1905. let maxY = y2;
  1906. let dx = x2 - x1;
  1907. if (Math.abs(dx) > 0.0000001) {
  1908. let a = (y2 - y1) / dx;
  1909. let b = y1 - a * x1;
  1910. minY = a * minX + b;
  1911. maxY = a * maxX + b;
  1912. }
  1913. if (minY > maxY) {
  1914. let tmp = maxY;
  1915. maxY = minY;
  1916. minY = tmp;
  1917. }
  1918. if (maxY > recY2)
  1919. maxY = recY2;
  1920. if (minY < recY)
  1921. minY = recY;
  1922. if (minY > maxY)
  1923. return false;
  1924. return true;
  1925. };
  1926. this.containsPoint = function(element, x, y) {
  1927. let bounds = element.getBoundingClientRect();
  1928. let left = bounds.left + window.scrollX;
  1929. let top = bounds.top + window.scrollY;
  1930. let width = bounds.width;
  1931. let height = bounds.height;
  1932.  
  1933. let insideHorizontal = x > left && x < left + width;
  1934. let insideVertical = y > top && y < top + height;
  1935. return insideHorizontal && insideVertical;
  1936. };
  1937. this.mousifyTouchEvent = function(event) {
  1938. let touch = event.changedTouches[0];
  1939. event.screenX = touch.screenX;
  1940. event.screenY = touch.screenY;
  1941. event.clientX = touch.clientX;
  1942. event.clientY = touch.clientY;
  1943. event.pageX = touch.pageX;
  1944. event.pageY = touch.pageY;
  1945. };
  1946. this.hookTouchEvents = function(element, skipPrevent) {
  1947. let preventDefault = !skipPrevent;
  1948. let isHovering = false;
  1949. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1950. let passive = false;
  1951. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1952. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1953. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1954. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1955. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1956.  
  1957. function touchStart(e) {
  1958. _this.mousifyTouchEvent(e);
  1959. window.setUsingTouch(true);
  1960. if (preventDefault) {
  1961. e.preventDefault();
  1962. e.stopPropagation();
  1963. }
  1964. if (element.onmouseover)
  1965. element.onmouseover(e);
  1966. isHovering = true;
  1967. }
  1968.  
  1969. function touchMove(e) {
  1970. _this.mousifyTouchEvent(e);
  1971. window.setUsingTouch(true);
  1972. if (preventDefault) {
  1973. e.preventDefault();
  1974. e.stopPropagation();
  1975. }
  1976. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1977. if (!isHovering) {
  1978. if (element.onmouseover)
  1979. element.onmouseover(e);
  1980. isHovering = true;
  1981. }
  1982. } else {
  1983. if (isHovering) {
  1984. if (element.onmouseout)
  1985. element.onmouseout(e);
  1986. isHovering = false;
  1987. }
  1988. }
  1989. }
  1990.  
  1991. function touchEnd(e) {
  1992. _this.mousifyTouchEvent(e);
  1993. window.setUsingTouch(true);
  1994. if (preventDefault) {
  1995. e.preventDefault();
  1996. e.stopPropagation();
  1997. }
  1998. if (isHovering) {
  1999. if (element.onclick)
  2000. element.onclick(e);
  2001. if (element.onmouseout)
  2002. element.onmouseout(e);
  2003. isHovering = false;
  2004. }
  2005. }
  2006. };
  2007. this.removeAllChildren = function(element) {
  2008. while (element.hasChildNodes()) {
  2009. element.removeChild(element.lastChild);
  2010. }
  2011. };
  2012. this.generateElement = function(config) {
  2013. let element = document.createElement(config.tag || "div");
  2014.  
  2015. function bind(configValue, elementValue) {
  2016. if (config[configValue])
  2017. element[elementValue] = config[configValue];
  2018. }
  2019. bind("text", "textContent");
  2020. bind("html", "innerHTML");
  2021. bind("class", "className");
  2022. for (let key in config) {
  2023. switch (key) {
  2024. case "tag":
  2025. case "text":
  2026. case "html":
  2027. case "class":
  2028. case "style":
  2029. case "hookTouch":
  2030. case "parent":
  2031. case "children":
  2032. continue;
  2033. default:
  2034. break;
  2035. }
  2036. element[key] = config[key];
  2037. }
  2038. if (element.onclick)
  2039. element.onclick = this.checkTrusted(element.onclick);
  2040. if (element.onmouseover)
  2041. element.onmouseover = this.checkTrusted(element.onmouseover);
  2042. if (element.onmouseout)
  2043. element.onmouseout = this.checkTrusted(element.onmouseout);
  2044. if (config.style) {
  2045. element.style.cssText = config.style;
  2046. }
  2047. if (config.hookTouch) {
  2048. this.hookTouchEvents(element);
  2049. }
  2050. if (config.parent) {
  2051. config.parent.appendChild(element);
  2052. }
  2053. if (config.children) {
  2054. for (let i = 0; i < config.children.length; i++) {
  2055. element.appendChild(config.children[i]);
  2056. }
  2057. }
  2058. return element;
  2059. };
  2060. this.checkTrusted = function(callback) {
  2061. return function(ev) {
  2062. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2063. callback(ev);
  2064. } else {
  2065. //console.error("Event is not trusted.", ev);
  2066. }
  2067. };
  2068. };
  2069. this.randomString = function(length) {
  2070. let text = "";
  2071. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2072. for (let i = 0; i < length; i++) {
  2073. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2074. }
  2075. return text;
  2076. };
  2077. this.countInArray = function(array, val) {
  2078. let count = 0;
  2079. for (let i = 0; i < array.length; i++) {
  2080. if (array[i] === val) count++;
  2081. }
  2082. return count;
  2083. };
  2084. this.hexToRgb = function(hex) {
  2085. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2086. };
  2087. this.getRgb = function(r, g, b) {
  2088. return [r / 255, g / 255, b / 255].join(", ");
  2089. };
  2090. }
  2091. };
  2092. class Animtext {
  2093. // ANIMATED TEXT:
  2094. constructor() {
  2095. // INIT:
  2096. this.init = function(x, y, scale, speed, life, text, color) {
  2097. (this.x = x),
  2098. (this.y = y),
  2099. (this.color = color),
  2100. (this.scale = scale*3.5),
  2101. (this.weight = 50);
  2102. (this.startScale = this.scale * 1.2),
  2103. (this.maxScale = 1.5 * scale),
  2104. (this.minScale = 0.5 * scale),
  2105. (this.scaleSpeed = 0.7),
  2106. (this.speed = speed),
  2107. (this.speedMax = speed),
  2108. (this.life = life),
  2109. (this.maxLife = life),
  2110. (this.text = text),
  2111. this.movSpeed = speed;
  2112. };
  2113.  
  2114. // UPDATE:
  2115. this.update = function(delta) {
  2116. if(this.life){
  2117. this.life -= delta;
  2118. if(this.scaleSpeed != -0.35){
  2119. this.y -= this.speed * delta;
  2120. // (this.x += this.speed * delta);
  2121. } else {
  2122. this.y -= this.speed * delta;
  2123. }
  2124. this.scale -= .8;
  2125. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2126. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2127. if(this.scale >= this.maxScale){
  2128. this.scale = this.maxScale;
  2129. this.scaleSpeed *= -.5;
  2130. this.speed = this.speed * .75;
  2131. };
  2132. this.life <= 0 && (this.life = 0)
  2133. };
  2134. };
  2135.  
  2136. // RENDER:
  2137. this.render = function(ctxt, xOff, yOff) {
  2138. ctxt.lineWidth = 10;
  2139. ctxt.strokeStyle = darkOutlineColor; //"black";
  2140. ctxt.fillStyle = this.color;
  2141. ctxt.globalAlpha = 1;
  2142. ctxt.font = this.scale + "px Hammersmith One";
  2143. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2144. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2145. ctxt.globalAlpha = 1;
  2146. };
  2147. }
  2148. };
  2149. class Textmanager {
  2150. // TEXT MANAGER:
  2151. constructor() {
  2152. this.texts = [];
  2153. this.stack = [];
  2154.  
  2155. // UPDATE:
  2156. this.update = function(delta, ctxt, xOff, yOff) {
  2157. ctxt.textBaseline = "middle";
  2158. ctxt.textAlign = "center";
  2159. for (let i = 0; i < this.texts.length; ++i) {
  2160. if (this.texts[i].life) {
  2161. this.texts[i].update(delta);
  2162. this.texts[i].render(ctxt, xOff, yOff);
  2163. }
  2164. }
  2165. };
  2166.  
  2167. // SHOW TEXT:
  2168. this.showText = function(x, y, scale, speed, life, text, color) {
  2169. let tmpText;
  2170. for (let i = 0; i < this.texts.length; ++i) {
  2171. if (!this.texts[i].life) {
  2172. tmpText = this.texts[i];
  2173. break;
  2174. }
  2175. }
  2176. if (!tmpText) {
  2177. tmpText = new Animtext();
  2178. this.texts.push(tmpText);
  2179. }
  2180. tmpText.init(x, y, scale, speed, life, text, color);
  2181. };
  2182. }
  2183. }
  2184.  
  2185. class GameObject {
  2186. constructor(sid) {
  2187. this.sid = sid;
  2188.  
  2189. // INIT:
  2190. this.init = function(x, y, dir, scale, type, data, owner) {
  2191. data = data || {};
  2192. this.sentTo = {};
  2193. this.gridLocations = [];
  2194. this.active = true;
  2195. this.render = true;
  2196. this.doUpdate = data.doUpdate;
  2197. this.x = x;
  2198. this.y = y;
  2199. this.dir = dir;
  2200. this.lastDir = dir;
  2201. this.xWiggle = 0;
  2202. this.yWiggle = 0;
  2203. this.visScale = scale;
  2204. this.scale = scale;
  2205. this.type = type;
  2206. this.id = data.id;
  2207. this.owner = owner;
  2208. this.name = data.name;
  2209. this.isItem = (this.id != undefined);
  2210. this.group = data.group;
  2211. this.maxHealth = data.health;
  2212. this.health = this.maxHealth;
  2213. this.layer = 2;
  2214. if (this.group != undefined) {
  2215. this.layer = this.group.layer;
  2216. } else if (this.type == 0) {
  2217. this.layer = 3;
  2218. } else if (this.type == 2) {
  2219. this.layer = 0;
  2220. } else if (this.type == 4) {
  2221. this.layer = -1;
  2222. }
  2223. this.colDiv = data.colDiv || 1;
  2224. this.blocker = data.blocker;
  2225. this.ignoreCollision = data.ignoreCollision;
  2226. this.dontGather = data.dontGather;
  2227. this.hideFromEnemy = data.hideFromEnemy;
  2228. this.friction = data.friction;
  2229. this.projDmg = data.projDmg;
  2230. this.dmg = data.dmg;
  2231. this.pDmg = data.pDmg;
  2232. this.pps = data.pps;
  2233. this.zIndex = data.zIndex || 0;
  2234. this.turnSpeed = data.turnSpeed;
  2235. this.req = data.req;
  2236. this.trap = data.trap;
  2237. this.healCol = data.healCol;
  2238. this.teleport = data.teleport;
  2239. this.boostSpeed = data.boostSpeed;
  2240. this.projectile = data.projectile;
  2241. this.shootRange = data.shootRange;
  2242. this.shootRate = data.shootRate;
  2243. this.shootCount = this.shootRate;
  2244. this.spawnPoint = data.spawnPoint;
  2245. this.onNear = 0;
  2246. this.breakObj = false;
  2247. this.alpha = data.alpha || 1;
  2248. this.maxAlpha = data.alpha || 1;
  2249. this.damaged = 0;
  2250. };
  2251.  
  2252. // GET HIT:
  2253. this.changeHealth = function(amount, doer) {
  2254. this.health += amount;
  2255. return (this.health <= 100);
  2256. };
  2257.  
  2258. // GET SCALE:
  2259. this.getScale = function(sM, ig) {
  2260. sM = sM || 1;
  2261. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2262. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2263. };
  2264.  
  2265. // VISIBLE TO PLAYER:
  2266. this.visibleToPlayer = function(player) {
  2267. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2268. (this.owner.team && player.team == this.owner.team)));
  2269. };
  2270.  
  2271. // UPDATE:
  2272. this.update = function(delta) {
  2273. if (this.active) {
  2274. if (this.xWiggle) {
  2275. this.xWiggle *= Math.pow(0.99, delta);
  2276. }
  2277. if (this.yWiggle) {
  2278. this.yWiggle *= Math.pow(0.99, delta);
  2279. }
  2280. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2281. if (d2 > 0.01) {
  2282. this.dir += d2 / 5;
  2283. } else {
  2284. this.dir = this.lastDir;
  2285. }
  2286. } else {
  2287. if (this.alive) {
  2288. this.alpha -= delta / (200 / this.maxAlpha);
  2289. this.visScale += delta / (this.scale / 2.5);
  2290. if (this.alpha <= 0) {
  2291. this.alpha = 0;
  2292. this.alive = false;
  2293. }
  2294. }
  2295. }
  2296. };
  2297.  
  2298. // CHECK TEAM:
  2299. this.isTeamObject = function(tmpObj) {
  2300. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2301. };
  2302. }
  2303. }
  2304. class Items {
  2305. constructor() {
  2306. // ITEM GROUPS:
  2307. this.groups = [{
  2308. id: 0,
  2309. name: "food",
  2310. layer: 0
  2311. }, {
  2312. id: 1,
  2313. name: "walls",
  2314. place: true,
  2315. limit: 30,
  2316. layer: 0
  2317. }, {
  2318. id: 2,
  2319. name: "spikes",
  2320. place: true,
  2321. limit: 15,
  2322. layer: 0
  2323. }, {
  2324. id: 3,
  2325. name: "mill",
  2326. place: true,
  2327. limit: 7,
  2328. layer: 1
  2329. }, {
  2330. id: 4,
  2331. name: "mine",
  2332. place: true,
  2333. limit: 1,
  2334. layer: 0
  2335. }, {
  2336. id: 5,
  2337. name: "trap",
  2338. place: true,
  2339. limit: 6,
  2340. layer: -1
  2341. }, {
  2342. id: 6,
  2343. name: "booster",
  2344. place: true,
  2345. limit: 12,
  2346. layer: -1
  2347. }, {
  2348. id: 7,
  2349. name: "turret",
  2350. place: true,
  2351. limit: 2,
  2352. layer: 1
  2353. }, {
  2354. id: 8,
  2355. name: "watchtower",
  2356. place: true,
  2357. limit: 12,
  2358. layer: 1
  2359. }, {
  2360. id: 9,
  2361. name: "buff",
  2362. place: true,
  2363. limit: 4,
  2364. layer: -1
  2365. }, {
  2366. id: 10,
  2367. name: "spawn",
  2368. place: true,
  2369. limit: 1,
  2370. layer: -1
  2371. }, {
  2372. id: 11,
  2373. name: "sapling",
  2374. place: true,
  2375. limit: 2,
  2376. layer: 0
  2377. }, {
  2378. id: 12,
  2379. name: "blocker",
  2380. place: true,
  2381. limit: 3,
  2382. layer: -1
  2383. }, {
  2384. id: 13,
  2385. name: "teleporter",
  2386. place: true,
  2387. limit: 2,
  2388. layer: -1
  2389. }];
  2390.  
  2391. // PROJECTILES:
  2392. this.projectiles = [{
  2393. indx: 0,
  2394. layer: 0,
  2395. src: "arrow_1",
  2396. dmg: 25,
  2397. speed: 1.6,
  2398. scale: 103,
  2399. range: 1000
  2400. }, {
  2401. indx: 1,
  2402. layer: 1,
  2403. dmg: 25,
  2404. scale: 20
  2405. }, {
  2406. indx: 0,
  2407. layer: 0,
  2408. src: "arrow_1",
  2409. dmg: 35,
  2410. speed: 2.5,
  2411. scale: 103,
  2412. range: 1200
  2413. }, {
  2414. indx: 0,
  2415. layer: 0,
  2416. src: "arrow_1",
  2417. dmg: 30,
  2418. speed: 2,
  2419. scale: 103,
  2420. range: 1200
  2421. }, {
  2422. indx: 1,
  2423. layer: 1,
  2424. dmg: 16,
  2425. scale: 20
  2426. }, {
  2427. indx: 0,
  2428. layer: 0,
  2429. src: "bullet_1",
  2430. dmg: 50,
  2431. speed: 3.6,
  2432. scale: 160,
  2433. range: 1400
  2434. }];
  2435.  
  2436. // WEAPONS:
  2437. this.weapons = [{
  2438. id: 0,
  2439. type: 0,
  2440. name: "tool hammer",
  2441. desc: "tool for gathering all resources",
  2442. src: "hammer_1",
  2443. length: 140,
  2444. width: 140,
  2445. xOff: -3,
  2446. yOff: 18,
  2447. dmg: 25,
  2448. range: 65,
  2449. gather: 1,
  2450. speed: 300
  2451. }, {
  2452. id: 1,
  2453. type: 0,
  2454. age: 2,
  2455. name: "hand axe",
  2456. desc: "gathers resources at a higher rate",
  2457. src: "axe_1",
  2458. length: 140,
  2459. width: 140,
  2460. xOff: 3,
  2461. yOff: 24,
  2462. dmg: 30,
  2463. spdMult: 1,
  2464. range: 70,
  2465. gather: 2,
  2466. speed: 400
  2467. }, {
  2468. id: 2,
  2469. type: 0,
  2470. age: 8,
  2471. pre: 1,
  2472. name: "great axe",
  2473. desc: "deal more damage and gather more resources",
  2474. src: "great_axe_1",
  2475. length: 140,
  2476. width: 140,
  2477. xOff: -8,
  2478. yOff: 25,
  2479. dmg: 35,
  2480. spdMult: 1,
  2481. range: 75,
  2482. gather: 4,
  2483. speed: 400
  2484. }, {
  2485. id: 3,
  2486. type: 0,
  2487. age: 2,
  2488. name: "short sword",
  2489. desc: "increased attack power but slower move speed",
  2490. src: "sword_1",
  2491. iPad: 1.3,
  2492. length: 130,
  2493. width: 210,
  2494. xOff: -8,
  2495. yOff: 46,
  2496. dmg: 35,
  2497. spdMult: 0.85,
  2498. range: 110,
  2499. gather: 1,
  2500. speed: 300
  2501. }, {
  2502. id: 4,
  2503. type: 0,
  2504. age: 8,
  2505. pre: 3,
  2506. name: "katana",
  2507. desc: "greater range and damage",
  2508. src: "samurai_1",
  2509. iPad: 1.3,
  2510. length: 130,
  2511. width: 210,
  2512. xOff: -8,
  2513. yOff: 59,
  2514. dmg: 40,
  2515. spdMult: 0.8,
  2516. range: 118,
  2517. gather: 1,
  2518. speed: 300
  2519. }, {
  2520. id: 5,
  2521. type: 0,
  2522. age: 2,
  2523. name: "polearm",
  2524. desc: "long range melee weapon",
  2525. src: "spear_1",
  2526. iPad: 1.3,
  2527. length: 130,
  2528. width: 210,
  2529. xOff: -8,
  2530. yOff: 53,
  2531. dmg: 45,
  2532. knock: 0.2,
  2533. spdMult: 0.82,
  2534. range: 142,
  2535. gather: 1,
  2536. speed: 700
  2537. }, {
  2538. id: 6,
  2539. type: 0,
  2540. age: 2,
  2541. name: "bat",
  2542. desc: "fast long range melee weapon",
  2543. src: "bat_1",
  2544. iPad: 1.3,
  2545. length: 110,
  2546. width: 180,
  2547. xOff: -8,
  2548. yOff: 53,
  2549. dmg: 20,
  2550. knock: 0.7,
  2551. range: 110,
  2552. gather: 1,
  2553. speed: 300
  2554. }, {
  2555. id: 7,
  2556. type: 0,
  2557. age: 2,
  2558. name: "daggers",
  2559. desc: "really fast short range weapon",
  2560. src: "dagger_1",
  2561. iPad: 0.8,
  2562. length: 110,
  2563. width: 110,
  2564. xOff: 18,
  2565. yOff: 0,
  2566. dmg: 20,
  2567. knock: 0.1,
  2568. range: 65,
  2569. gather: 1,
  2570. hitSlow: 0.1,
  2571. spdMult: 1.13,
  2572. speed: 100
  2573. }, {
  2574. id: 8,
  2575. type: 0,
  2576. age: 2,
  2577. name: "stick",
  2578. desc: "great for gathering but very weak",
  2579. src: "stick_1",
  2580. length: 140,
  2581. width: 140,
  2582. xOff: 3,
  2583. yOff: 24,
  2584. dmg: 1,
  2585. spdMult: 1,
  2586. range: 70,
  2587. gather: 7,
  2588. speed: 400
  2589. }, {
  2590. id: 9,
  2591. type: 1,
  2592. age: 6,
  2593. name: "hunting bow",
  2594. desc: "bow used for ranged combat and hunting",
  2595. src: "bow_1",
  2596. req: ["wood", 4],
  2597. length: 120,
  2598. width: 120,
  2599. xOff: -6,
  2600. yOff: 0,
  2601. Pdmg: 25,
  2602. projectile: 0,
  2603. spdMult: 0.75,
  2604. speed: 600
  2605. }, {
  2606. id: 10,
  2607. type: 1,
  2608. age: 6,
  2609. name: "great hammer",
  2610. desc: "hammer used for destroying structures",
  2611. src: "great_hammer_1",
  2612. length: 140,
  2613. width: 140,
  2614. xOff: -9,
  2615. yOff: 25,
  2616. dmg: 10,
  2617. Pdmg: 10,
  2618. spdMult: 0.88,
  2619. range: 75,
  2620. sDmg: 7.5,
  2621. gather: 1,
  2622. speed: 400
  2623. }, {
  2624. id: 11,
  2625. type: 1,
  2626. age: 6,
  2627. name: "wooden shield",
  2628. desc: "blocks projectiles and reduces melee damage",
  2629. src: "shield_1",
  2630. length: 120,
  2631. width: 120,
  2632. shield: 0.2,
  2633. xOff: 6,
  2634. yOff: 0,
  2635. Pdmg: 0,
  2636. spdMult: 0.7
  2637. }, {
  2638. id: 12,
  2639. type: 1,
  2640. age: 8,
  2641. pre: 9,
  2642. name: "crossbow",
  2643. desc: "deals more damage and has greater range",
  2644. src: "crossbow_1",
  2645. req: ["wood", 5],
  2646. aboveHand: true,
  2647. armS: 0.75,
  2648. length: 120,
  2649. width: 120,
  2650. xOff: -4,
  2651. yOff: 0,
  2652. Pdmg: 35,
  2653. projectile: 2,
  2654. spdMult: 0.7,
  2655. speed: 700
  2656. }, {
  2657. id: 13,
  2658. type: 1,
  2659. age: 9,
  2660. pre: 12,
  2661. name: "repeater crossbow",
  2662. desc: "high firerate crossbow with reduced damage",
  2663. src: "crossbow_2",
  2664. req: ["wood", 10],
  2665. aboveHand: true,
  2666. armS: 0.75,
  2667. length: 120,
  2668. width: 120,
  2669. xOff: -4,
  2670. yOff: 0,
  2671. Pdmg: 30,
  2672. projectile: 3,
  2673. spdMult: 0.7,
  2674. speed: 230
  2675. }, {
  2676. id: 14,
  2677. type: 1,
  2678. age: 6,
  2679. name: "mc grabby",
  2680. desc: "steals resources from enemies",
  2681. src: "grab_1",
  2682. length: 130,
  2683. width: 210,
  2684. xOff: -8,
  2685. yOff: 53,
  2686. dmg: 0,
  2687. Pdmg: 0,
  2688. steal: 250,
  2689. knock: 0.2,
  2690. spdMult: 1.05,
  2691. range: 125,
  2692. gather: 0,
  2693. speed: 700
  2694. }, {
  2695. id: 15,
  2696. type: 1,
  2697. age: 9,
  2698. pre: 12,
  2699. name: "musket",
  2700. desc: "slow firerate but high damage and range",
  2701. src: "musket_1",
  2702. req: ["stone", 10],
  2703. aboveHand: true,
  2704. rec: 0.35,
  2705. armS: 0.6,
  2706. hndS: 0.3,
  2707. hndD: 1.6,
  2708. length: 205,
  2709. width: 205,
  2710. xOff: 25,
  2711. yOff: 0,
  2712. Pdmg: 50,
  2713. projectile: 5,
  2714. hideProjectile: true,
  2715. spdMult: 0.6,
  2716. speed: 1500
  2717. }];
  2718.  
  2719. // ITEMS:
  2720. this.list = [{
  2721. group: this.groups[0],
  2722. name: "apple",
  2723. desc: "restores 20 health when consumed",
  2724. req: ["food", 10],
  2725. consume: function(doer) {
  2726. return doer.changeHealth(20, doer);
  2727. },
  2728. scale: 22,
  2729. holdOffset: 15,
  2730. healing: 20,
  2731. itemID: 0,
  2732. itemAID: 16,
  2733. }, {
  2734. age: 3,
  2735. group: this.groups[0],
  2736. name: "cookie",
  2737. desc: "restores 40 health when consumed",
  2738. req: ["food", 15],
  2739. consume: function(doer) {
  2740. return doer.changeHealth(40, doer);
  2741. },
  2742. scale: 27,
  2743. holdOffset: 15,
  2744. healing: 40,
  2745. itemID: 1,
  2746. itemAID: 17,
  2747. }, {
  2748. age: 7,
  2749. group: this.groups[0],
  2750. name: "cheese",
  2751. desc: "restores 30 health and another 50 over 5 seconds",
  2752. req: ["food", 25],
  2753. consume: function(doer) {
  2754. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2755. doer.dmgOverTime.dmg = -10;
  2756. doer.dmgOverTime.doer = doer;
  2757. doer.dmgOverTime.time = 5;
  2758. return true;
  2759. }
  2760. return false;
  2761. },
  2762. scale: 27,
  2763. holdOffset: 15,
  2764. healing: 30,
  2765. itemID: 2,
  2766. itemAID: 18,
  2767. }, {
  2768. group: this.groups[1],
  2769. name: "wood wall",
  2770. desc: "provides protection for your village",
  2771. req: ["wood", 10],
  2772. projDmg: true,
  2773. health: 380,
  2774. scale: 50,
  2775. holdOffset: 20,
  2776. placeOffset: -5,
  2777. itemID: 3,
  2778. itemAID: 19,
  2779. }, {
  2780. age: 3,
  2781. group: this.groups[1],
  2782. name: "stone wall",
  2783. desc: "provides improved protection for your village",
  2784. req: ["stone", 25],
  2785. health: 900,
  2786. scale: 50,
  2787. holdOffset: 20,
  2788. placeOffset: -5,
  2789. itemID: 4,
  2790. itemAID: 20,
  2791. }, {
  2792. age: 7,
  2793. group: this.groups[1],
  2794. name: "castle wall",
  2795. desc: "provides powerful protection for your village",
  2796. req: ["stone", 35],
  2797. health: 1500,
  2798. scale: 52,
  2799. holdOffset: 20,
  2800. placeOffset: -5,
  2801. itemID: 5,
  2802. itemAID: 21,
  2803. }, {
  2804. group: this.groups[2],
  2805. name: "spikes",
  2806. desc: "damages enemies when they touch them",
  2807. req: ["wood", 20, "stone", 5],
  2808. health: 400,
  2809. dmg: 20,
  2810. scale: 49,
  2811. spritePadding: -23,
  2812. holdOffset: 8,
  2813. placeOffset: -5,
  2814. itemID: 6,
  2815. itemAID: 22,
  2816. shadow: {
  2817. offsetX: 5, // Adjust the shadow's X offset as needed
  2818. offsetY: 5, // Adjust the shadow's Y offset as needed
  2819. blur: 20, // Adjust the shadow's blur as needed
  2820. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2821. }
  2822.  
  2823. }, {
  2824. age: 5,
  2825. group: this.groups[2],
  2826. name: "greater spikes",
  2827. desc: "damages enemies when they touch them",
  2828. req: ["wood", 30, "stone", 10],
  2829. health: 500,
  2830. dmg: 35,
  2831. scale: 52,
  2832. spritePadding: -23,
  2833. holdOffset: 8,
  2834. placeOffset: -5,
  2835. itemID: 7,
  2836. itemAID: 23,
  2837. }, {
  2838. age: 9,
  2839. group: this.groups[2],
  2840. name: "poison spikes",
  2841. desc: "poisons enemies when they touch them",
  2842. req: ["wood", 35, "stone", 15],
  2843. health: 600,
  2844. dmg: 30,
  2845. pDmg: 5,
  2846. scale: 52,
  2847. spritePadding: -23,
  2848. holdOffset: 8,
  2849. placeOffset: -5,
  2850. itemID: 8,
  2851. itemAID: 24,
  2852. }, {
  2853. age: 9,
  2854. group: this.groups[2],
  2855. name: "spinning spikes",
  2856. desc: "damages enemies when they touch them",
  2857. req: ["wood", 30, "stone", 20],
  2858. health: 500,
  2859. dmg: 45,
  2860. turnSpeed: 0.003,
  2861. scale: 52,
  2862. spritePadding: -23,
  2863. holdOffset: 8,
  2864. placeOffset: -5,
  2865. itemID: 9,
  2866. itemAID: 25,
  2867. }, {
  2868. group: this.groups[3],
  2869. name: "windmill",
  2870. desc: "generates gold over time",
  2871. req: ["wood", 50, "stone", 10],
  2872. health: 400,
  2873. pps: 1,
  2874. turnSpeed: 0.0016,
  2875. spritePadding: 25,
  2876. iconLineMult: 12,
  2877. scale: 45,
  2878. holdOffset: 20,
  2879. placeOffset: 5,
  2880. itemID: 10,
  2881. itemAID: 26,
  2882. }, {
  2883. age: 5,
  2884. group: this.groups[3],
  2885. name: "faster windmill",
  2886. desc: "generates more gold over time",
  2887. req: ["wood", 60, "stone", 20],
  2888. health: 500,
  2889. pps: 1.5,
  2890. turnSpeed: 0.0025,
  2891. spritePadding: 25,
  2892. iconLineMult: 12,
  2893. scale: 47,
  2894. holdOffset: 20,
  2895. placeOffset: 5,
  2896. itemID: 11,
  2897. itemAID: 27,
  2898. }, {
  2899. age: 8,
  2900. group: this.groups[3],
  2901. name: "power mill",
  2902. desc: "generates more gold over time",
  2903. req: ["wood", 100, "stone", 50],
  2904. health: 800,
  2905. pps: 2,
  2906. turnSpeed: 0.005,
  2907. spritePadding: 25,
  2908. iconLineMult: 12,
  2909. scale: 47,
  2910. holdOffset: 20,
  2911. placeOffset: 5,
  2912. itemID: 12,
  2913. itemAID: 28,
  2914. }, {
  2915. age: 5,
  2916. group: this.groups[4],
  2917. type: 2,
  2918. name: "mine",
  2919. desc: "allows you to mine stone",
  2920. req: ["wood", 20, "stone", 100],
  2921. iconLineMult: 12,
  2922. scale: 65,
  2923. holdOffset: 20,
  2924. placeOffset: 0,
  2925. itemID: 13,
  2926. itemAID: 29,
  2927. }, {
  2928. age: 5,
  2929. group: this.groups[11],
  2930. type: 0,
  2931. name: "sapling",
  2932. desc: "allows you to farm wood",
  2933. req: ["wood", 150],
  2934. iconLineMult: 12,
  2935. colDiv: 0.5,
  2936. scale: 110,
  2937. holdOffset: 50,
  2938. placeOffset: -15,
  2939. itemID: 14,
  2940. itemAID: 30,
  2941. }, {
  2942. age: 4,
  2943. group: this.groups[5],
  2944. name: "pit trap",
  2945. desc: "pit that traps enemies if they walk over it",
  2946. req: ["wood", 30, "stone", 30],
  2947. trap: true,
  2948. ignoreCollision: true,
  2949. hideFromEnemy: true,
  2950. health: 500,
  2951. colDiv: 0.2,
  2952. scale: 50,
  2953. holdOffset: 20,
  2954. placeOffset: -5,
  2955. alpha: 0.6,
  2956. itemID: 15,
  2957. itemAID: 31,
  2958. }, {
  2959. age: 4,
  2960. group: this.groups[6],
  2961. name: "boost pad",
  2962. desc: "provides boost when stepped on",
  2963. req: ["stone", 20, "wood", 5],
  2964. ignoreCollision: true,
  2965. boostSpeed: 1.5,
  2966. health: 150,
  2967. colDiv: 0.7,
  2968. scale: 45,
  2969. holdOffset: 20,
  2970. placeOffset: -5,
  2971. itemID: 16,
  2972. itemAID: 32,
  2973. }, {
  2974. age: 7,
  2975. group: this.groups[7],
  2976. doUpdate: true,
  2977. name: "turret",
  2978. desc: "defensive structure that shoots at enemies",
  2979. req: ["wood", 200, "stone", 150],
  2980. health: 800,
  2981. projectile: 1,
  2982. shootRange: 700,
  2983. shootRate: 2200,
  2984. scale: 43,
  2985. holdOffset: 20,
  2986. placeOffset: -5,
  2987. itemID: 17,
  2988. itemAID: 33,
  2989. }, {
  2990. age: 7,
  2991. group: this.groups[8],
  2992. name: "platform",
  2993. desc: "platform to shoot over walls and cross over water",
  2994. req: ["wood", 20],
  2995. ignoreCollision: true,
  2996. zIndex: 1,
  2997. health: 300,
  2998. scale: 43,
  2999. holdOffset: 20,
  3000. placeOffset: -5,
  3001. itemID: 18,
  3002. itemAID: 34,
  3003. }, {
  3004. age: 7,
  3005. group: this.groups[9],
  3006. name: "healing pad",
  3007. desc: "standing on it will slowly heal you",
  3008. req: ["wood", 30, "food", 10],
  3009. ignoreCollision: true,
  3010. healCol: 15,
  3011. health: 400,
  3012. colDiv: 0.7,
  3013. scale: 45,
  3014. holdOffset: 20,
  3015. placeOffset: -5,
  3016. itemID: 19,
  3017. itemAID: 35,
  3018. }, {
  3019. age: 9,
  3020. group: this.groups[10],
  3021. name: "spawn pad",
  3022. desc: "you will spawn here when you die but it will dissapear",
  3023. req: ["wood", 100, "stone", 100],
  3024. health: 400,
  3025. ignoreCollision: true,
  3026. spawnPoint: true,
  3027. scale: 45,
  3028. holdOffset: 20,
  3029. placeOffset: -5,
  3030. itemID: 20,
  3031. itemAID: 36,
  3032. }, {
  3033. age: 7,
  3034. group: this.groups[12],
  3035. name: "blocker",
  3036. desc: "blocks building in radius",
  3037. req: ["wood", 30, "stone", 25],
  3038. ignoreCollision: true,
  3039. blocker: 300,
  3040. health: 400,
  3041. colDiv: 0.7,
  3042. scale: 45,
  3043. holdOffset: 20,
  3044. placeOffset: -5,
  3045. itemID: 21,
  3046. itemAID: 37,
  3047. }, {
  3048. age: 7,
  3049. group: this.groups[13],
  3050. name: "teleporter",
  3051. desc: "teleports you to a random point on the map",
  3052. req: ["wood", 60, "stone", 60],
  3053. ignoreCollision: true,
  3054. teleport: true,
  3055. health: 200,
  3056. colDiv: 0.7,
  3057. scale: 45,
  3058. holdOffset: 20,
  3059. placeOffset: -5,
  3060. itemID: 22,
  3061. itemAID: 38
  3062. }];
  3063.  
  3064. // CHECK ITEM ID:
  3065. this.checkItem = {
  3066. index: function(id, myItems) {
  3067. 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 :
  3068. 5 :
  3069. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3070. 6 :
  3071. undefined;
  3072. }
  3073. }
  3074.  
  3075. // ASSIGN IDS:
  3076. for (let i = 0; i < this.list.length; ++i) {
  3077. this.list[i].id = i;
  3078. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3079. }
  3080.  
  3081. // TROLOLOLOL:
  3082. if (typeof window !== "undefined") {
  3083. function shuffle(a) {
  3084. for (let i = a.length - 1; i > 0; i--) {
  3085. const j = Math.floor(Math.random() * (i + 1));
  3086. [a[i], a[j]] = [a[j], a[i]];
  3087. }
  3088. return a;
  3089. }
  3090. //shuffle(this.list);
  3091. }
  3092. }
  3093. }
  3094. class Objectmanager {
  3095. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3096. let mathFloor = Math.floor,
  3097. mathABS = Math.abs,
  3098. mathCOS = Math.cos,
  3099. mathSIN = Math.sin,
  3100. mathPOW = Math.pow,
  3101. mathSQRT = Math.sqrt;
  3102.  
  3103. this.ignoreAdd = false;
  3104. this.hitObj = [];
  3105.  
  3106. // DISABLE OBJ:
  3107. this.disableObj = function(obj) {
  3108. obj.active = false;
  3109. };
  3110.  
  3111. // ADD NEW:
  3112. let tmpObj;
  3113. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3114. tmpObj = findObjectBySid(sid);
  3115. if (!tmpObj) {
  3116. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3117. if (!tmpObj) {
  3118. tmpObj = new GameObject(sid);
  3119. gameObjects.push(tmpObj);
  3120. }
  3121. }
  3122. if (setSID) {
  3123. tmpObj.sid = sid;
  3124. }
  3125. tmpObj.init(x, y, dir, s, type, data, owner);
  3126. };
  3127.  
  3128. // DISABLE BY SID:
  3129. this.disableBySid = function(sid) {
  3130. let find = findObjectBySid(sid);
  3131. if (find) {
  3132. this.disableObj(find);
  3133. }
  3134. };
  3135.  
  3136. // REMOVE ALL FROM PLAYER:
  3137. this.removeAllItems = function(sid, server) {
  3138. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3139. };
  3140.  
  3141. // CHECK IF PLACABLE:
  3142. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3143. 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)));
  3144. if (cantPlace) return false;
  3145. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3146. return true;
  3147. };
  3148.  
  3149. }
  3150. }
  3151. class Projectile {
  3152. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3153.  
  3154. // INIT:
  3155. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3156. this.active = true;
  3157. this.tickActive = true;
  3158. this.indx = indx;
  3159. this.x = x;
  3160. this.y = y;
  3161. this.x2 = x;
  3162. this.y2 = y;
  3163. this.dir = dir;
  3164. this.skipMov = true;
  3165. this.speed = spd;
  3166. this.dmg = dmg;
  3167. this.scale = scl;
  3168. this.range = rng;
  3169. this.r2 = rng;
  3170. this.owner = owner;
  3171. };
  3172.  
  3173. // UPDATE:
  3174. this.update = function(delta) {
  3175. if (this.active) {
  3176. let tmpSpeed = this.speed * delta;
  3177. if (!this.skipMov) {
  3178. this.x += tmpSpeed * Math.cos(this.dir);
  3179. this.y += tmpSpeed * Math.sin(this.dir);
  3180. this.range -= tmpSpeed;
  3181. if (this.range <= 0) {
  3182. this.x += this.range * Math.cos(this.dir);
  3183. this.y += this.range * Math.sin(this.dir);
  3184. tmpSpeed = 1;
  3185. this.range = 0;
  3186. this.active = false;
  3187. }
  3188. } else {
  3189. this.skipMov = false;
  3190. }
  3191. }
  3192. };
  3193. this.tickUpdate = function(delta) {
  3194. if (this.tickActive) {
  3195. let tmpSpeed = this.speed * delta;
  3196. if (!this.skipMov) {
  3197. this.x2 += tmpSpeed * Math.cos(this.dir);
  3198. this.y2 += tmpSpeed * Math.sin(this.dir);
  3199. this.r2 -= tmpSpeed;
  3200. if (this.r2 <= 0) {
  3201. this.x2 += this.r2 * Math.cos(this.dir);
  3202. this.y2 += this.r2 * Math.sin(this.dir);
  3203. tmpSpeed = 1;
  3204. this.r2 = 0;
  3205. this.tickActive = false;
  3206. }
  3207. } else {
  3208. this.skipMov = false;
  3209. }
  3210. }
  3211. };
  3212. }
  3213. };
  3214. class Store {
  3215. constructor() {
  3216. // STORE HATS:
  3217. this.hats = [{
  3218. id: 45,
  3219. name: "Shame!",
  3220. dontSell: true,
  3221. price: 0,
  3222. scale: 120,
  3223. desc: "hacks are for winners"
  3224. }, {
  3225. id: 51,
  3226. name: "Moo Cap",
  3227. price: 0,
  3228. scale: 120,
  3229. desc: "coolest mooer around"
  3230. }, {
  3231. id: 50,
  3232. name: "Apple Cap",
  3233. price: 0,
  3234. scale: 120,
  3235. desc: "apple farms remembers"
  3236. }, {
  3237. id: 28,
  3238. name: "Moo Head",
  3239. price: 0,
  3240. scale: 120,
  3241. desc: "no effect"
  3242. }, {
  3243. id: 29,
  3244. name: "Pig Head",
  3245. price: 0,
  3246. scale: 120,
  3247. desc: "no effect"
  3248. }, {
  3249. id: 30,
  3250. name: "Fluff Head",
  3251. price: 0,
  3252. scale: 120,
  3253. desc: "no effect"
  3254. }, {
  3255. id: 36,
  3256. name: "Pandou Head",
  3257. price: 0,
  3258. scale: 120,
  3259. desc: "no effect"
  3260. }, {
  3261. id: 37,
  3262. name: "Bear Head",
  3263. price: 0,
  3264. scale: 120,
  3265. desc: "no effect"
  3266. }, {
  3267. id: 38,
  3268. name: "Monkey Head",
  3269. price: 0,
  3270. scale: 120,
  3271. desc: "no effect"
  3272. }, {
  3273. id: 44,
  3274. name: "Polar Head",
  3275. price: 0,
  3276. scale: 120,
  3277. desc: "no effect"
  3278. }, {
  3279. id: 35,
  3280. name: "Fez Hat",
  3281. price: 0,
  3282. scale: 120,
  3283. desc: "no effect"
  3284. }, {
  3285. id: 42,
  3286. name: "Enigma Hat",
  3287. price: 0,
  3288. scale: 120,
  3289. desc: "join the enigma army"
  3290. }, {
  3291. id: 43,
  3292. name: "Blitz Hat",
  3293. price: 0,
  3294. scale: 120,
  3295. desc: "hey everybody i'm blitz"
  3296. }, {
  3297. id: 49,
  3298. name: "Bob XIII Hat",
  3299. price: 0,
  3300. scale: 120,
  3301. desc: "like and subscribe"
  3302. }, {
  3303. id: 57,
  3304. name: "Pumpkin",
  3305. price: 50,
  3306. scale: 120,
  3307. desc: "Spooooky"
  3308. }, {
  3309. id: 8,
  3310. name: "Bummle Hat",
  3311. price: 100,
  3312. scale: 120,
  3313. desc: "no effect"
  3314. }, {
  3315. id: 2,
  3316. name: "Straw Hat",
  3317. price: 500,
  3318. scale: 120,
  3319. desc: "no effect"
  3320. }, {
  3321. id: 15,
  3322. name: "Winter Cap",
  3323. price: 600,
  3324. scale: 120,
  3325. desc: "allows you to move at normal speed in snow",
  3326. coldM: 1
  3327. }, {
  3328. id: 5,
  3329. name: "Cowboy Hat",
  3330. price: 1000,
  3331. scale: 120,
  3332. desc: "no effect"
  3333. }, {
  3334. id: 4,
  3335. name: "Ranger Hat",
  3336. price: 2000,
  3337. scale: 120,
  3338. desc: "no effect"
  3339. }, {
  3340. id: 18,
  3341. name: "Explorer Hat",
  3342. price: 2000,
  3343. scale: 120,
  3344. desc: "no effect"
  3345. }, {
  3346. id: 31,
  3347. name: "Flipper Hat",
  3348. price: 2500,
  3349. scale: 120,
  3350. desc: "have more control while in water",
  3351. watrImm: true
  3352. }, {
  3353. id: 1,
  3354. name: "Marksman Cap",
  3355. price: 3000,
  3356. scale: 120,
  3357. desc: "increases arrow speed and range",
  3358. aMlt: 1.3
  3359. }, {
  3360. id: 10,
  3361. name: "Bush Gear",
  3362. price: 3000,
  3363. scale: 160,
  3364. desc: "allows you to disguise yourself as a bush"
  3365. }, {
  3366. id: 48,
  3367. name: "Halo",
  3368. price: 3000,
  3369. scale: 120,
  3370. desc: "no effect"
  3371. }, {
  3372. id: 6,
  3373. name: "Soldier Helmet",
  3374. price: 4000,
  3375. scale: 120,
  3376. desc: "reduces damage taken but slows movement",
  3377. spdMult: 0.94,
  3378. dmgMult: 0.75
  3379. }, {
  3380. id: 23,
  3381. name: "Anti Venom Gear",
  3382. price: 4000,
  3383. scale: 120,
  3384. desc: "makes you immune to poison",
  3385. poisonRes: 1
  3386. }, {
  3387. id: 13,
  3388. name: "Medic Gear",
  3389. price: 5000,
  3390. scale: 110,
  3391. desc: "slowly regenerates health over time",
  3392. healthRegen: 3
  3393. }, {
  3394. id: 9,
  3395. name: "Miners Helmet",
  3396. price: 5000,
  3397. scale: 120,
  3398. desc: "earn 1 extra gold per resource",
  3399. extraGold: 1
  3400. }, {
  3401. id: 32,
  3402. name: "Musketeer Hat",
  3403. price: 5000,
  3404. scale: 120,
  3405. desc: "reduces cost of projectiles",
  3406. projCost: 0.5
  3407. }, {
  3408. id: 7,
  3409. name: "Bull Helmet",
  3410. price: 6000,
  3411. scale: 120,
  3412. desc: "increases damage done but drains health",
  3413. healthRegen: -5,
  3414. dmgMultO: 1.5,
  3415. spdMult: 0.96
  3416. }, {
  3417. id: 22,
  3418. name: "Emp Helmet",
  3419. price: 6000,
  3420. scale: 120,
  3421. desc: "turrets won't attack but you move slower",
  3422. antiTurret: 1,
  3423. spdMult: 0.7
  3424. }, {
  3425. id: 12,
  3426. name: "Booster Hat",
  3427. price: 6000,
  3428. scale: 120,
  3429. desc: "increases your movement speed",
  3430. spdMult: 1.16
  3431. }, {
  3432. id: 26,
  3433. name: "Barbarian Armor",
  3434. price: 8000,
  3435. scale: 120,
  3436. desc: "knocks back enemies that attack you",
  3437. dmgK: 0.6
  3438. }, {
  3439. id: 21,
  3440. name: "Plague Mask",
  3441. price: 10000,
  3442. scale: 120,
  3443. desc: "melee attacks deal poison damage",
  3444. poisonDmg: 5,
  3445. poisonTime: 6
  3446. }, {
  3447. id: 46,
  3448. name: "Bull Mask",
  3449. price: 10000,
  3450. scale: 120,
  3451. desc: "bulls won't target you unless you attack them",
  3452. bullRepel: 1
  3453. }, {
  3454. id: 14,
  3455. name: "Windmill Hat",
  3456. topSprite: true,
  3457. price: 10000,
  3458. scale: 120,
  3459. desc: "generates points while worn",
  3460. pps: 1.5
  3461. }, {
  3462. id: 11,
  3463. name: "Spike Gear",
  3464. topSprite: true,
  3465. price: 10000,
  3466. scale: 120,
  3467. desc: "deal damage to players that damage you",
  3468. dmg: 0.45
  3469. }, {
  3470. id: 53,
  3471. name: "Turret Gear",
  3472. topSprite: true,
  3473. price: 10000,
  3474. scale: 120,
  3475. desc: "you become a walking turret",
  3476. turret: {
  3477. proj: 1,
  3478. range: 700,
  3479. rate: 2500
  3480. },
  3481. spdMult: 0.7
  3482. }, {
  3483. id: 20,
  3484. name: "Samurai Armor",
  3485. price: 12000,
  3486. scale: 120,
  3487. desc: "increased attack speed and fire rate",
  3488. atkSpd: 0.78
  3489. }, {
  3490. id: 58,
  3491. name: "Dark Knight",
  3492. price: 12000,
  3493. scale: 120,
  3494. desc: "restores health when you deal damage",
  3495. healD: 0.4
  3496. }, {
  3497. id: 27,
  3498. name: "Scavenger Gear",
  3499. price: 15000,
  3500. scale: 120,
  3501. desc: "earn double points for each kill",
  3502. kScrM: 2
  3503. }, {
  3504. id: 40,
  3505. name: "Tank Gear",
  3506. price: 15000,
  3507. scale: 120,
  3508. desc: "increased damage to buildings but slower movement",
  3509. spdMult: 0.3,
  3510. bDmg: 3.3
  3511. }, {
  3512. id: 52,
  3513. name: "Thief Gear",
  3514. price: 15000,
  3515. scale: 120,
  3516. desc: "steal half of a players gold when you kill them",
  3517. goldSteal: 0.5
  3518. }, {
  3519. id: 55,
  3520. name: "Bloodthirster",
  3521. price: 20000,
  3522. scale: 120,
  3523. desc: "Restore Health when dealing damage. And increased damage",
  3524. healD: 0.25,
  3525. dmgMultO: 1.2,
  3526. }, {
  3527. id: 56,
  3528. name: "Assassin Gear",
  3529. price: 20000,
  3530. scale: 120,
  3531. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3532. noEat: true,
  3533. spdMult: 1.1,
  3534. invisTimer: 1000
  3535. }];
  3536.  
  3537. // STORE ACCESSORIES:
  3538. this.accessories = [{
  3539. id: 12,
  3540. name: "Snowball",
  3541. price: 1000,
  3542. scale: 105,
  3543. xOff: 18,
  3544. desc: "no effect"
  3545. }, {
  3546. id: 9,
  3547. name: "Tree Cape",
  3548. price: 1000,
  3549. scale: 90,
  3550. desc: "no effect"
  3551. }, {
  3552. id: 10,
  3553. name: "Stone Cape",
  3554. price: 1000,
  3555. scale: 90,
  3556. desc: "no effect"
  3557. }, {
  3558. id: 3,
  3559. name: "Cookie Cape",
  3560. price: 1500,
  3561. scale: 90,
  3562. desc: "no effect"
  3563. }, {
  3564. id: 8,
  3565. name: "Cow Cape",
  3566. price: 2000,
  3567. scale: 90,
  3568. desc: "no effect"
  3569. }, {
  3570. id: 11,
  3571. name: "Monkey Tail",
  3572. price: 2000,
  3573. scale: 97,
  3574. xOff: 25,
  3575. desc: "Super speed but reduced damage",
  3576. spdMult: 1.35,
  3577. dmgMultO: 0.2
  3578. }, {
  3579. id: 17,
  3580. name: "Apple Basket",
  3581. price: 3000,
  3582. scale: 80,
  3583. xOff: 12,
  3584. desc: "slowly regenerates health over time",
  3585. healthRegen: 1
  3586. }, {
  3587. id: 6,
  3588. name: "Winter Cape",
  3589. price: 3000,
  3590. scale: 90,
  3591. desc: "no effect"
  3592. }, {
  3593. id: 4,
  3594. name: "Skull Cape",
  3595. price: 4000,
  3596. scale: 90,
  3597. desc: "no effect"
  3598. }, {
  3599. id: 5,
  3600. name: "Dash Cape",
  3601. price: 5000,
  3602. scale: 90,
  3603. desc: "no effect"
  3604. }, {
  3605. id: 2,
  3606. name: "Dragon Cape",
  3607. price: 6000,
  3608. scale: 90,
  3609. desc: "no effect"
  3610. }, {
  3611. id: 1,
  3612. name: "Super Cape",
  3613. price: 8000,
  3614. scale: 90,
  3615. desc: "no effect"
  3616. }, {
  3617. id: 7,
  3618. name: "Troll Cape",
  3619. price: 8000,
  3620. scale: 90,
  3621. desc: "no effect"
  3622. }, {
  3623. id: 14,
  3624. name: "Thorns",
  3625. price: 10000,
  3626. scale: 115,
  3627. xOff: 20,
  3628. desc: "no effect"
  3629. }, {
  3630. id: 15,
  3631. name: "Blockades",
  3632. price: 10000,
  3633. scale: 95,
  3634. xOff: 15,
  3635. desc: "no effect"
  3636. }, {
  3637. id: 20,
  3638. name: "Devils Tail",
  3639. price: 10000,
  3640. scale: 95,
  3641. xOff: 20,
  3642. desc: "no effect"
  3643. }, {
  3644. id: 16,
  3645. name: "Sawblade",
  3646. price: 12000,
  3647. scale: 90,
  3648. spin: true,
  3649. xOff: 0,
  3650. desc: "deal damage to players that damage you",
  3651. dmg: 0.15
  3652. }, {
  3653. id: 13,
  3654. name: "Angel Wings",
  3655. price: 15000,
  3656. scale: 138,
  3657. xOff: 22,
  3658. desc: "slowly regenerates health over time",
  3659. healthRegen: 3
  3660. }, {
  3661. id: 19,
  3662. name: "Shadow Wings",
  3663. price: 15000,
  3664. scale: 138,
  3665. xOff: 22,
  3666. desc: "increased movement speed",
  3667. spdMult: 1.1
  3668. }, {
  3669. id: 18,
  3670. name: "Blood Wings",
  3671. price: 20000,
  3672. scale: 178,
  3673. xOff: 26,
  3674. desc: "restores health when you deal damage",
  3675. healD: 0.2
  3676. }, {
  3677. id: 21,
  3678. name: "Corrupt X Wings",
  3679. price: 20000,
  3680. scale: 178,
  3681. xOff: 26,
  3682. desc: "deal damage to players that damage you",
  3683. dmg: 0.25
  3684. }];
  3685. }
  3686. };
  3687. class ProjectileManager {
  3688. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3689. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3690. let tmpData = items.projectiles[indx];
  3691. let tmpProj;
  3692. for (let i = 0; i < projectiles.length; ++i) {
  3693. if (!projectiles[i].active) {
  3694. tmpProj = projectiles[i];
  3695. break;
  3696. }
  3697. }
  3698. if (!tmpProj) {
  3699. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3700. tmpProj.sid = projectiles.length;
  3701. projectiles.push(tmpProj);
  3702. }
  3703. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3704. tmpProj.ignoreObj = ignoreObj;
  3705. tmpProj.layer = layer || tmpData.layer;
  3706. tmpProj.inWindow = inWindow;
  3707. tmpProj.src = tmpData.src;
  3708. return tmpProj;
  3709. };
  3710. }
  3711. };
  3712. class AiManager {
  3713.  
  3714. // AI MANAGER:
  3715. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3716.  
  3717. // AI TYPES:
  3718. this.aiTypes = [{
  3719. id: 0,
  3720. src: "cow_1",
  3721. killScore: 150,
  3722. health: 500,
  3723. weightM: 0.8,
  3724. speed: 0.00095,
  3725. turnSpeed: 0.001,
  3726. scale: 72,
  3727. drop: ["food", 50]
  3728. }, {
  3729. id: 1,
  3730. src: "pig_1",
  3731. killScore: 200,
  3732. health: 800,
  3733. weightM: 0.6,
  3734. speed: 0.00085,
  3735. turnSpeed: 0.001,
  3736. scale: 72,
  3737. drop: ["food", 80]
  3738. }, {
  3739. id: 2,
  3740. name: "Bull",
  3741. src: "bull_2",
  3742. hostile: true,
  3743. dmg: 20,
  3744. killScore: 1000,
  3745. health: 1800,
  3746. weightM: 0.5,
  3747. speed: 0.00094,
  3748. turnSpeed: 0.00074,
  3749. scale: 78,
  3750. viewRange: 800,
  3751. chargePlayer: true,
  3752. drop: ["food", 100]
  3753. }, {
  3754. id: 3,
  3755. name: "Bully",
  3756. src: "bull_1",
  3757. hostile: true,
  3758. dmg: 20,
  3759. killScore: 2000,
  3760. health: 2800,
  3761. weightM: 0.45,
  3762. speed: 0.001,
  3763. turnSpeed: 0.0008,
  3764. scale: 90,
  3765. viewRange: 900,
  3766. chargePlayer: true,
  3767. drop: ["food", 400]
  3768. }, {
  3769. id: 4,
  3770. name: "Wolf",
  3771. src: "wolf_1",
  3772. hostile: true,
  3773. dmg: 8,
  3774. killScore: 500,
  3775. health: 300,
  3776. weightM: 0.45,
  3777. speed: 0.001,
  3778. turnSpeed: 0.002,
  3779. scale: 84,
  3780. viewRange: 800,
  3781. chargePlayer: true,
  3782. drop: ["food", 200]
  3783. }, {
  3784. id: 5,
  3785. name: "Quack",
  3786. src: "chicken_1",
  3787. dmg: 8,
  3788. killScore: 2000,
  3789. noTrap: true,
  3790. health: 300,
  3791. weightM: 0.2,
  3792. speed: 0.0018,
  3793. turnSpeed: 0.006,
  3794. scale: 70,
  3795. drop: ["food", 100]
  3796. }, {
  3797. id: 6,
  3798. name: "MOOSTAFA",
  3799. nameScale: 50,
  3800. src: "enemy",
  3801. hostile: true,
  3802. dontRun: true,
  3803. fixedSpawn: true,
  3804. spawnDelay: 60000,
  3805. noTrap: true,
  3806. colDmg: 100,
  3807. dmg: 40,
  3808. killScore: 8000,
  3809. health: 18000,
  3810. weightM: 0.4,
  3811. speed: 0.0007,
  3812. turnSpeed: 0.01,
  3813. scale: 80,
  3814. spriteMlt: 1.8,
  3815. leapForce: 0.9,
  3816. viewRange: 1000,
  3817. hitRange: 210,
  3818. hitDelay: 1000,
  3819. chargePlayer: true,
  3820. drop: ["food", 100]
  3821. }, {
  3822. id: 7,
  3823. name: "Treasure",
  3824. hostile: true,
  3825. nameScale: 35,
  3826. src: "crate_1",
  3827. fixedSpawn: true,
  3828. spawnDelay: 120000,
  3829. colDmg: 200,
  3830. killScore: 5000,
  3831. health: 20000,
  3832. weightM: 0.1,
  3833. speed: 0.0,
  3834. turnSpeed: 0.0,
  3835. scale: 70,
  3836. spriteMlt: 1.0
  3837. }, {
  3838. id: 8,
  3839. name: "MOOFIE",
  3840. src: "wolf_2",
  3841. hostile: true,
  3842. fixedSpawn: true,
  3843. dontRun: true,
  3844. hitScare: 4,
  3845. spawnDelay: 30000,
  3846. noTrap: true,
  3847. nameScale: 35,
  3848. dmg: 10,
  3849. colDmg: 100,
  3850. killScore: 3000,
  3851. health: 7000,
  3852. weightM: 0.45,
  3853. speed: 0.0015,
  3854. turnSpeed: 0.002,
  3855. scale: 90,
  3856. viewRange: 800,
  3857. chargePlayer: true,
  3858. drop: ["food", 1000]
  3859. }, {
  3860. id: 9,
  3861. name: "ΏθΤΑMOOFIE",
  3862. src: "wolf_2",
  3863. hostile: !0,
  3864. fixedSpawn: !0,
  3865. dontRun: !0,
  3866. hitScare: 50,
  3867. spawnDelay: 6e4,
  3868. noTrap: !0,
  3869. nameScale: 35,
  3870. dmg: 12,
  3871. colDmg: 100,
  3872. killScore: 3e3,
  3873. health: 9e3,
  3874. weightM: .45,
  3875. speed: .0015,
  3876. turnSpeed: .0025,
  3877. scale: 94,
  3878. viewRange: 1440,
  3879. chargePlayer: !0,
  3880. drop: ["food", 3e3],
  3881. minSpawnRange: .85,
  3882. maxSpawnRange: .9
  3883. }, {
  3884. id: 10,
  3885. name: "ΏθΤΑWolf",
  3886. src: "wolf_1",
  3887. hostile: !0,
  3888. fixedSpawn: !0,
  3889. dontRun: !0,
  3890. hitScare: 50,
  3891. spawnDelay: 3e4,
  3892. dmg: 10,
  3893. killScore: 700,
  3894. health: 500,
  3895. weightM: .45,
  3896. speed: .00115,
  3897. turnSpeed: .0025,
  3898. scale: 88,
  3899. viewRange: 1440,
  3900. chargePlayer: !0,
  3901. drop: ["food", 400],
  3902. minSpawnRange: .85,
  3903. maxSpawnRange: .9
  3904. }, {
  3905. id: 11,
  3906. name: "ΏθΤΑBully",
  3907. src: "bull_1",
  3908. hostile: !0,
  3909. fixedSpawn: !0,
  3910. dontRun: !0,
  3911. hitScare: 50,
  3912. dmg: 20,
  3913. killScore: 5e3,
  3914. health: 5e3,
  3915. spawnDelay: 1e5,
  3916. weightM: .45,
  3917. speed: .00115,
  3918. turnSpeed: .0025,
  3919. scale: 94,
  3920. viewRange: 1440,
  3921. chargePlayer: !0,
  3922. drop: ["food", 800],
  3923. minSpawnRange: .85,
  3924. maxSpawnRange: .9
  3925. }];
  3926.  
  3927. // SPAWN AI:
  3928. this.spawn = function(x, y, dir, index) {
  3929. let tmpObj = ais.find((tmp) => !tmp.active);
  3930. if (!tmpObj) {
  3931. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3932. ais.push(tmpObj);
  3933. }
  3934. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3935. return tmpObj;
  3936. };
  3937. }
  3938.  
  3939. };
  3940. class AI {
  3941. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3942. this.sid = sid;
  3943. this.isAI = true;
  3944. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3945.  
  3946. // INIT:
  3947. this.init = function(x, y, dir, index, data) {
  3948. this.x = x;
  3949. this.y = y;
  3950. this.startX = data.fixedSpawn ? x : null;
  3951. this.startY = data.fixedSpawn ? y : null;
  3952. this.xVel = 0;
  3953. this.yVel = 0;
  3954. this.zIndex = 0;
  3955. this.dir = dir;
  3956. this.dirPlus = 0;
  3957. this.showName = 'aaa';
  3958. this.index = index;
  3959. this.src = data.src;
  3960. if (data.name) this.name = data.name;
  3961. this.weightM = data.weightM;
  3962. this.speed = data.speed;
  3963. this.killScore = data.killScore;
  3964. this.turnSpeed = data.turnSpeed;
  3965. this.scale = data.scale;
  3966. this.maxHealth = data.health;
  3967. this.leapForce = data.leapForce;
  3968. this.health = this.maxHealth;
  3969. this.chargePlayer = data.chargePlayer;
  3970. this.viewRange = data.viewRange;
  3971. this.drop = data.drop;
  3972. this.dmg = data.dmg;
  3973. this.hostile = data.hostile;
  3974. this.dontRun = data.dontRun;
  3975. this.hitRange = data.hitRange;
  3976. this.hitDelay = data.hitDelay;
  3977. this.hitScare = data.hitScare;
  3978. this.spriteMlt = data.spriteMlt;
  3979. this.nameScale = data.nameScale;
  3980. this.colDmg = data.colDmg;
  3981. this.noTrap = data.noTrap;
  3982. this.spawnDelay = data.spawnDelay;
  3983. this.hitWait = 0;
  3984. this.waitCount = 1000;
  3985. this.moveCount = 0;
  3986. this.targetDir = 0;
  3987. this.active = true;
  3988. this.alive = true;
  3989. this.runFrom = null;
  3990. this.chargeTarget = null;
  3991. this.dmgOverTime = {};
  3992. };
  3993.  
  3994. let tmpRatio = 0;
  3995. let animIndex = 0;
  3996. this.animate = function(delta) {
  3997. if (this.animTime > 0) {
  3998. this.animTime -= delta;
  3999. if (this.animTime <= 0) {
  4000. this.animTime = 0;
  4001. this.dirPlus = 0;
  4002. tmpRatio = 0;
  4003. animIndex = 0;
  4004. } else {
  4005. if (animIndex == 0) {
  4006. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4007. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4008. if (tmpRatio >= 1) {
  4009. tmpRatio = 1;
  4010. animIndex = 1;
  4011. }
  4012. } else {
  4013. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4014. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4015. }
  4016. }
  4017. }
  4018. };
  4019.  
  4020. // ANIMATION:
  4021. this.startAnim = function() {
  4022. this.animTime = this.animSpeed = 600;
  4023. this.targetAngle = Math.PI * 0.8;
  4024. tmpRatio = 0;
  4025. animIndex = 0;
  4026. };
  4027.  
  4028. };
  4029.  
  4030. };
  4031. class addCh {
  4032. constructor(x, y, chat, tmpObj) {
  4033. this.x = x;
  4034. this.y = y;
  4035. this.alpha = 0;
  4036. this.active = true;
  4037. this.alive = false;
  4038. this.chat = chat;
  4039. this.owner = tmpObj;
  4040. };
  4041. };
  4042. class DeadPlayer {
  4043. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4044. this.x = x;
  4045. this.y = y;
  4046. this.lastDir = dir;
  4047. this.dir = dir + Math.PI;
  4048. this.buildIndex = buildIndex;
  4049. this.weaponIndex = weaponIndex;
  4050. this.weaponVariant = weaponVariant;
  4051. this.skinColor = skinColor;
  4052. this.scale = scale;
  4053. this.visScale = 0;
  4054. this.name = name;
  4055. this.alpha = 1;
  4056. this.active = true;
  4057. this.animate = function(delta) {
  4058. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4059. if (d2 > 0.01) {
  4060. this.dir += d2 / 20;
  4061. } else {
  4062. this.dir = this.lastDir;
  4063. }
  4064. if (this.visScale < this.scale) {
  4065. this.visScale += delta / (this.scale / 2);
  4066. if (this.visScale >= this.scale) {
  4067. this.visScale = this.scale;
  4068. }
  4069. }
  4070. this.alpha -= delta / 30000;
  4071. if (this.alpha <= 0) {
  4072. this.alpha = 0;
  4073. this.active = false;
  4074. }
  4075. }
  4076. }
  4077. };
  4078. class Player {
  4079. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4080. this.id = id;
  4081. this.sid = sid;
  4082. this.tmpScore = 0;
  4083. this.team = null;
  4084. this.latestSkin = 0;
  4085. this.oldSkinIndex = 0;
  4086. this.skinIndex = 0;
  4087. this.latestTail = 0;
  4088. this.oldTailIndex = 0;
  4089. this.tailIndex = 0;
  4090. this.hitTime = 0;
  4091. this.lastHit = 0;
  4092. this.showName = 'NOOO';
  4093. this.tails = {};
  4094. for (let i = 0; i < accessories.length; ++i) {
  4095. if (accessories[i].price <= 0)
  4096. this.tails[accessories[i].id] = 1;
  4097. }
  4098. this.skins = {};
  4099. for (let i = 0; i < hats.length; ++i) {
  4100. if (hats[i].price <= 0)
  4101. this.skins[hats[i].id] = 1;
  4102. }
  4103. this.points = 0;
  4104. this.dt = 0;
  4105. this.hidden = false;
  4106. this.itemCounts = {};
  4107. this.isPlayer = true;
  4108. this.pps = 0;
  4109. this.moveDir = undefined;
  4110. this.skinRot = 0;
  4111. this.lastPing = 0;
  4112. this.iconIndex = 0;
  4113. this.skinColor = 0;
  4114. this.dist2 = 0;
  4115. this.aim2 = 0;
  4116. this.maxSpeed = 1;
  4117. this.chat = {
  4118. message: null,
  4119. count: 0
  4120. };
  4121. this.backupNobull = true;
  4122. this.circle = false;
  4123. this.circleRad = 200;
  4124. this.circleRadSpd = 0.1;
  4125. this.cAngle = 0;
  4126. // SPAWN:
  4127. this.spawn = function(moofoll) {
  4128. this.attacked = false;
  4129. this.timeDamaged = 0;
  4130. this.timeHealed = 100;
  4131. this.pinge = 0;
  4132. this.millPlace = 'NOOO';
  4133. this.lastshamecount = 0;
  4134. this.death = false;
  4135. this.spinDir = 0;
  4136. this.sync = false;
  4137. this.antiBull = 0;
  4138. this.bullTimer = 0;
  4139. this.poisonTimer = 0;
  4140. this.active = true;
  4141. this.alive = true;
  4142. this.lockMove = false;
  4143. this.lockDir = false;
  4144. this.minimapCounter = 0;
  4145. this.chatCountdown = 0;
  4146. this.shameCount = 0;
  4147. this.shameTimer = 0;
  4148. this.sentTo = {};
  4149. this.gathering = 0;
  4150. this.gatherIndex = 0;
  4151. this.shooting = {};
  4152. this.shootIndex = 9;
  4153. this.autoGather = 0;
  4154. this.animTime = 0;
  4155. this.animSpeed = 0;
  4156. this.mouseState = 0;
  4157. this.buildIndex = -1;
  4158. this.weaponIndex = 0;
  4159. this.weaponCode = 0;
  4160. this.weaponVariant = 0;
  4161. this.primaryIndex = undefined;
  4162. this.secondaryIndex = undefined;
  4163. this.dmgOverTime = {};
  4164. this.noMovTimer = 0;
  4165. this.maxXP = 300;
  4166. this.XP = 0;
  4167. this.age = 1;
  4168. this.kills = 0;
  4169. this.upgrAge = 2;
  4170. this.upgradePoints = 0;
  4171. this.x = 0;
  4172. this.y = 0;
  4173. this.oldXY = {
  4174. x: 0,
  4175. y: 0
  4176. };
  4177. this.zIndex = 0;
  4178. this.xVel = 0;
  4179. this.yVel = 0;
  4180. this.slowMult = 1;
  4181. this.dir = 0;
  4182. this.dirPlus = 0;
  4183. this.targetDir = 0;
  4184. this.targetAngle = 0;
  4185. this.maxHealth = 100;
  4186. this.health = this.maxHealth;
  4187. this.oldHealth = this.maxHealth;
  4188. this.damaged = 0;
  4189. this.scale = config.playerScale;
  4190. this.speed = config.playerSpeed;
  4191. this.resetMoveDir();
  4192. this.resetResources(moofoll);
  4193. this.items = [0, 3, 6, 10];
  4194. this.weapons = [0];
  4195. this.shootCount = 0;
  4196. this.weaponXP = [];
  4197. this.reloads = {
  4198. 0: 0,
  4199. 1: 0,
  4200. 2: 0,
  4201. 3: 0,
  4202. 4: 0,
  4203. 5: 0,
  4204. 6: 0,
  4205. 7: 0,
  4206. 8: 0,
  4207. 9: 0,
  4208. 10: 0,
  4209. 11: 0,
  4210. 12: 0,
  4211. 13: 0,
  4212. 14: 0,
  4213. 15: 0,
  4214. 53: 0,
  4215. };
  4216. this.bowThreat = {
  4217. 9: 0,
  4218. 12: 0,
  4219. 13: 0,
  4220. 15: 0,
  4221. };
  4222. this.damageThreat = 0;
  4223. this.inTrap = false;
  4224. this.canEmpAnti = false;
  4225. this.empAnti = false;
  4226. this.soldierAnti = false;
  4227. this.poisonTick = 0;
  4228. this.bullTick = 0;
  4229. this.setPoisonTick = false;
  4230. this.setBullTick = false;
  4231. this.antiTimer = 2;
  4232. };
  4233.  
  4234. // RESET MOVE DIR:
  4235. this.resetMoveDir = function() {
  4236. this.moveDir = undefined;
  4237. };
  4238.  
  4239. // RESET RESOURCES:
  4240. this.resetResources = function(moofoll) {
  4241. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4242. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4243. }
  4244. };
  4245.  
  4246. // ADD ITEM:
  4247. this.getItemType = function(id) {
  4248. let findindx = this.items.findIndex((ids) => ids == id);
  4249. if (findindx != -1) {
  4250. return findindx;
  4251. } else {
  4252. return items.checkItem.index(id, this.items);
  4253. }
  4254. };
  4255.  
  4256. // SET DATA:
  4257. this.setData = function(data) {
  4258. this.id = data[0];
  4259. this.sid = data[1];
  4260. this.name = data[2];
  4261. this.x = data[3];
  4262. this.y = data[4];
  4263. this.dir = data[5];
  4264. this.health = data[6];
  4265. this.maxHealth = data[7];
  4266. this.scale = data[8];
  4267. this.skinColor = data[9];
  4268. };
  4269.  
  4270. // UPDATE POISON TICK:
  4271. this.updateTimer = function() {
  4272.  
  4273. this.bullTimer -= 1;
  4274. if (this.bullTimer <= 0) {
  4275. this.setBullTick = false;
  4276. this.bullTick = game.tick - 1;
  4277. this.bullTimer = config.serverUpdateRate;
  4278. }
  4279. this.poisonTimer -= 1;
  4280. if (this.poisonTimer <= 0) {
  4281. this.setPoisonTick = false;
  4282. this.poisonTick = game.tick - 1;
  4283. this.poisonTimer = config.serverUpdateRate;
  4284. }
  4285.  
  4286. };
  4287. this.update = function(delta) {
  4288. if (this.sid == playerSID) {
  4289. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4290. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4291. this.cAngle += this.circleRadSpd;
  4292. }
  4293. if (this.active) {
  4294.  
  4295. // MOVE:
  4296. let gear = {
  4297. skin: findID(hats, this.skinIndex),
  4298. tail: findID(accessories, this.tailIndex)
  4299. }
  4300. 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;
  4301. this.maxSpeed = spdMult;
  4302.  
  4303. }
  4304. };
  4305.  
  4306. let tmpRatio = 0;
  4307. let animIndex = 0;
  4308. this.animate = function(delta) {
  4309. if (this.animTime > 0) {
  4310. this.animTime -= delta;
  4311. if (this.animTime <= 0) {
  4312. this.animTime = 0;
  4313. this.dirPlus = 0;
  4314. tmpRatio = 0;
  4315. animIndex = 0;
  4316. } else {
  4317. if (animIndex == 0) {
  4318. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4319. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4320. if (tmpRatio >= 1) {
  4321. tmpRatio = 1;
  4322. animIndex = 1;
  4323. }
  4324. } else {
  4325. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4326. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4327. }
  4328. }
  4329. }
  4330. };
  4331.  
  4332. // GATHER ANIMATION:
  4333. this.startAnim = function(didHit, index) {
  4334. this.animTime = this.animSpeed = items.weapons[index].speed;
  4335. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4336. tmpRatio = 0;
  4337. animIndex = 0;
  4338. };
  4339.  
  4340. // CAN SEE:
  4341. this.canSee = function(other) {
  4342. if (!other) return false;
  4343. let dx = Math.abs(other.x - this.x) - other.scale;
  4344. let dy = Math.abs(other.y - this.y) - other.scale;
  4345. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4346. };
  4347.  
  4348. // SHAME SYSTEM:
  4349. this.judgeShame = function() {
  4350. this.lastshamecount = this.shameCount;
  4351. if (this.oldHealth < this.health) {
  4352. if (this.hitTime) {
  4353. let timeSinceHit = game.tick - this.hitTime;
  4354. this.lastHit = game.tick;
  4355. this.hitTime = 0;
  4356. if (timeSinceHit < 2) {
  4357. this.shameCount++;
  4358. } else {
  4359. this.shameCount = Math.max(0, this.shameCount - 2);
  4360. }
  4361. }
  4362. } else if (this.oldHealth > this.health) {
  4363. this.hitTime = game.tick;
  4364. }
  4365. };
  4366. this.addShameTimer = function() {
  4367. this.shameCount = 0;
  4368. this.shameTimer = 30;
  4369. let interval = setInterval(() => {
  4370. this.shameTimer--;
  4371. if (this.shameTimer <= 0) {
  4372. clearInterval(interval);
  4373. }
  4374. }, 1000);
  4375. };
  4376.  
  4377. // CHECK TEAM:
  4378. this.isTeam = function(tmpObj) {
  4379. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4380. };
  4381.  
  4382. // FOR THE PLAYER:
  4383. this.findAllianceBySid = function(sid) {
  4384. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4385. };
  4386. this.checkCanInsta = function(nobull) {
  4387. let totally = 0;
  4388. if (this.alive && inGame) {
  4389. let primary = {
  4390. weapon: this.weapons[0],
  4391. variant: this.primaryVariant,
  4392. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4393. };
  4394. let secondary = {
  4395. weapon: this.weapons[1],
  4396. variant: this.secondaryVariant,
  4397. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4398. };
  4399. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4400. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4401. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4402. totally += primary.dmg * pV * bull;
  4403. }
  4404. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4405. totally += secondary.dmg;
  4406. }
  4407. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4408. totally += 25;
  4409. }
  4410. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4411. return totally;
  4412. }
  4413. return 0;
  4414. };
  4415.  
  4416. // UPDATE WEAPON RELOAD:
  4417. this.manageReload = function() {
  4418. if (this.shooting[53]) {
  4419. this.shooting[53] = 0;
  4420. this.reloads[53] = (2500 - game.tickRate);
  4421. } else {
  4422. if (this.reloads[53] > 0) {
  4423. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4424. }
  4425. }
  4426.  
  4427. // PREPLACER
  4428. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4429. // place(2, getAttackDir());
  4430. let index = this.weaponIndex;
  4431. 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));
  4432. for(let i = 0; i < nearObja.length; i++) {
  4433. let aaa = nearObja[i];
  4434.  
  4435. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4436. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4437. if(aaa.health - (valaa) <= 0 && near.length) {
  4438. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4439. console.log("preplaced");
  4440. }
  4441. }
  4442. }
  4443.  
  4444. if (this.gathering || this.shooting[1]) {
  4445. if (this.gathering) {
  4446. this.gathering = 0;
  4447. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4448. this.attacked = true;
  4449. }
  4450. if (this.shooting[1]) {
  4451. this.shooting[1] = 0;
  4452. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4453. this.attacked = true;
  4454. }
  4455. } else {
  4456. this.attacked = false;
  4457. if (this.buildIndex < 0) {
  4458. if (this.reloads[this.weaponIndex] > 0) {
  4459. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4460. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4461. if (this == player) {
  4462. if (getEl("weaponGrind").checked) {
  4463. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4464. checkPlace(player.getItemType(22), i);
  4465. }
  4466. }
  4467. }
  4468. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4469. this.antiBull++;
  4470. game.tickBase(() => {
  4471. this.antiBull = 0;
  4472. }, 1);
  4473. }
  4474. }
  4475. }
  4476. }
  4477. };
  4478. // PREPLACER
  4479. let closestBuild = [];
  4480.  
  4481. function findTargetBuildToSpike(checkSpike, trapDistance, targetDistance, targetAngle) {
  4482. if (!document.getElementById('sp').checked) return;
  4483. if (!enemy.length) return;
  4484.  
  4485. // En yak─▒n in┼θa edilebilir nesneyi bul
  4486. closestBuild = gameObjects.filter(obj => obj.active && obj.buildHealth)
  4487. .sort((a, b) => UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2))[0];
  4488.  
  4489. if (!closestBuild) return;
  4490.  
  4491. // Parametreleri ayarla (b├╝y├╝k ihtimalle mesafe, a├π─▒ gibi)
  4492. checkSpike = 250;
  4493. trapDistance = 250;
  4494. targetDistance = UTILS.getDist(closestBuild, player, 0, 2);
  4495. targetAngle = UTILS.getDirect(closestBuild, player, 0, 2);
  4496.  
  4497. // Spike atma ko┼θullar─▒n─▒ kontrol et
  4498. if (player.alive && targetDistance < checkSpike && near.dist2 < trapDistance &&
  4499. !traps.in && !instaC.isTrue && !instaC.canSpikeTick && !clicks.middle && !clicks.left) {
  4500.  
  4501. // Hedefin can─▒ yeterince d├╝┼θ├╝kse...
  4502. if (closestBuild.buildHealth < items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].dmg * 2) {
  4503.  
  4504. if (document.getElementById('stype').value == "D") {
  4505. // D tu┼θu stiline g├╢re spike yerle┼θtir
  4506. for (let i = 0; i < 6; i++) {
  4507. let angle = i + 45 * (i % 2 ? -1 : 1) / 180 * Math.PI + near.aim2;
  4508. checkPlace(2, i);
  4509. }
  4510. } else {
  4511. // Farkl─▒ bir spike stili
  4512. for (let i = 0; i < 4; i++) {
  4513. let angle = i + 45 * (i % 2 ? -1 : 1) / 180 * Math.PI + near.aim2;
  4514. checkPlace(2, i);
  4515. }
  4516. }
  4517. }
  4518. }
  4519. }
  4520.  
  4521. this.preplacer = function () {
  4522. if (traps.inTrap) return;
  4523. if (!configs.autoPrePlace) return;
  4524.  
  4525. const weaponRange = items.weapons[player.weaponIndex].range + 70;
  4526. const rangeSquared = weaponRange ** 2;
  4527. const { x2: playerX, y2: playerY } = player;
  4528.  
  4529. const lowHealthGameObjects = gameObjects.filter(gameObject => {
  4530. const { x2, y2, buildHealth } = gameObject;
  4531. const distSquared = (x2 - playerX) ** 2 + (y2 - playerY) ** 2;
  4532. return near && buildHealth <= 272.58 && distSquared <= rangeSquared;
  4533. });
  4534.  
  4535. if (lowHealthGameObjects.length > 0) {
  4536. const { x2, y2 } = lowHealthGameObjects[0];
  4537. const objAim = UTILS.getDirect({ x2, y2 }, player, 0, 2);
  4538. const trapPlacementRadius = 70;
  4539.  
  4540. let enemyVelocity = Math.sqrt(near.xVel * near.xVel + near.yVel * near.yVel);
  4541. let enemyDirection = Math.atan2(near.yVel, near.xVel);
  4542.  
  4543. let bestAngle = null;
  4544. let bestDistance = Infinity;
  4545.  
  4546. for (let i = 0; i < 360; i += 30) {
  4547. let simulatedAngle = UTILS.deg2rad(i);
  4548. let distance =
  4549. UTILS.getDist(near, player, 0, 2) +
  4550. enemyVelocity * Math.sin(enemyDirection) +
  4551. trapPlacementRadius;
  4552.  
  4553. if (distance < bestDistance) {
  4554. bestDistance = distance;
  4555. bestAngle = simulatedAngle;
  4556. }
  4557. }
  4558.  
  4559. const trapPlacementTime = 5;
  4560. const timeToBreak = (lowHealthGameObjects[0].buildHealth - player.damage) / (player.damagePerShot - lowHealthGameObjects[0].absorb);
  4561. const enemyTimeToMoveOut = bestDistance / enemyVelocity;
  4562.  
  4563. if (timeToBreak + trapPlacementTime <= enemyTimeToMoveOut) {
  4564. this.testCanPlace(4, bestAngle, bestAngle + Math.PI * 2, Math.PI / 24, objAim, trapPlacementRadius);
  4565. }
  4566. }
  4567. };
  4568.  
  4569. // FOR ANTI INSTA:
  4570. this.addDamageThreat = function(tmpObj) {
  4571. let primary = {
  4572. weapon: this.primaryIndex,
  4573. variant: this.primaryVariant
  4574. };
  4575. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4576. let secondary = {
  4577. weapon: this.secondaryIndex,
  4578. variant: this.secondaryVariant
  4579. };
  4580. secondary.dmg = secondary.weapon == undefined ? 35 : items.weapons[secondary.weapon].Pdmg;
  4581. let bull = 1.5;
  4582. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4583. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4584. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4585. this.damageThreat += primary.dmg * pV * bull;
  4586. }
  4587. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4588. this.damageThreat += secondary.dmg * sV;
  4589. }
  4590. if (this.reloads[53] <= game.tickRate) {
  4591. this.damageThreat += 25;
  4592. }
  4593. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4594. if (!this.isTeam(tmpObj)) {
  4595. if (this.dist2 <= 300) {
  4596. tmpObj.damageThreat += this.damageThreat;
  4597. }
  4598. }
  4599. };
  4600. // ANTI
  4601. this.addDamageProbability = function(tmpObj) {
  4602. let primary = {
  4603. weapon: this.primaryIndex,
  4604. variant: this.primaryVariant
  4605. };
  4606. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4607. let secondary = {
  4608. weapon: this.secondaryIndex,
  4609. variant: this.secondaryVariant
  4610. };
  4611. secondary.dmg = secondary.weapon == undefined ? 50 : items.weapons[secondary.weapon].Pdmg;
  4612. let bull = 1.5;
  4613. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4614. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4615. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4616. this.damageProbably += primary.dmg * pV * bull * 0.75;
  4617. }
  4618. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4619. this.damageProbably += secondary.dmg * sV;
  4620. }
  4621. this.damageProbably *= 0.75;
  4622. if (!this.isTeam(tmpObj)) {
  4623. if (this.dist2 <= 300) {
  4624. tmpObj.damageProbably += this.damageProbably;
  4625. }
  4626. }
  4627. };
  4628. }
  4629. };
  4630.  
  4631. // SOME CODES:
  4632. function sendUpgrade(index) {
  4633. player.reloads[index] = 0;
  4634. packet("H", index);
  4635. }
  4636.  
  4637. function storeEquip(id, index) {
  4638. packet("c", 0, id, index);
  4639. }
  4640.  
  4641. function storeBuy(id, index) {
  4642. packet("c", 1, id, index);
  4643. }
  4644.  
  4645. function buyEquip(id, index) {
  4646. let nID = player.skins[6] ? 6 : 0;
  4647. if (player.alive && inGame) {
  4648. if (index == 0) {
  4649. if (player.skins[id]) {
  4650. if (player.latestSkin != id) {
  4651. packet("c", 0, id, 0);
  4652. }
  4653. } else {
  4654. if (configs.autoBuyEquip) {
  4655. let find = findID(hats, id);
  4656. if (find) {
  4657. if (player.points >= find.price) {
  4658. packet("c", 1, id, 0);
  4659. packet("c", 0, id, 0);
  4660. } else {
  4661. if (player.latestSkin != nID) {
  4662. packet("c", 0, nID, 0);
  4663. }
  4664. }
  4665. } else {
  4666. if (player.latestSkin != nID) {
  4667. packet("c", 0, nID, 0);
  4668. }
  4669. }
  4670. } else {
  4671. if (player.latestSkin != nID) {
  4672. packet("c", 0, nID, 0);
  4673. }
  4674. }
  4675. }
  4676. } else if (index == 1) {
  4677. if (useWasd && (id != 11 && id != 0)) {
  4678. if (player.latestTail != 0) {
  4679. packet("c", 0, 0, 1);
  4680. }
  4681. return;
  4682. }
  4683. if (player.tails[id]) {
  4684. if (player.latestTail != id) {
  4685. packet("c", 0, id, 1);
  4686. }
  4687. } else {
  4688. if (configs.autoBuyEquip) {
  4689. let find = findID(accessories, id);
  4690. if (find) {
  4691. if (player.points >= find.price) {
  4692. packet("c", 1, id, 1);
  4693. packet("c", 0, id, 1);
  4694. } else {
  4695. if (player.latestTail != 0) {
  4696. packet("c", 0, 0, 1);
  4697. }
  4698. }
  4699. } else {
  4700. if (player.latestTail != 0) {
  4701. packet("c", 0, 0, 1);
  4702. }
  4703. }
  4704. } else {
  4705. if (player.latestTail != 0) {
  4706. packet("c", 0, 0, 1);
  4707. }
  4708. }
  4709. }
  4710. }
  4711. }
  4712. }
  4713.  
  4714. function selectToBuild(index, wpn) {
  4715. packet("G", index, wpn);
  4716. }
  4717.  
  4718. function selectWeapon(index, isPlace) {
  4719. if (!isPlace) {
  4720. player.weaponCode = index;
  4721. }
  4722. packet("G", index, 1);
  4723. }
  4724.  
  4725. function sendAutoGather() {
  4726. packet("K", 1, 1);
  4727. }
  4728.  
  4729. function sendAtck(id, angle) {
  4730. packet("d", id, angle, 1);
  4731. }
  4732.  
  4733. // PLACER:
  4734. function place(id, rad, rmd) {
  4735. try {
  4736. if (id == undefined) return;
  4737. let item = items.list[player.items[id]];
  4738. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4739. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4740. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4741. 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))) {
  4742. selectToBuild(player.items[id]);
  4743. sendAtck(1, rad);
  4744. selectWeapon(player.weaponCode, 1);
  4745. if (rmd && getEl("placeVis").checked) {
  4746. placeVisible.push({
  4747. x: tmpX,
  4748. y: tmpY,
  4749. name: item.name,
  4750. scale: item.scale,
  4751. dir: rad
  4752. });
  4753. game.tickBase(() => {
  4754. placeVisible.shift();
  4755. }, 1)
  4756. }
  4757. }
  4758. } catch (e) {}
  4759. }
  4760.  
  4761. function checkPlace(id, rad) {
  4762. try {
  4763. if (id == undefined) return;
  4764. let item = items.list[player.items[id]];
  4765. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4766. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4767. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4768. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4769. place(id, rad, 1);
  4770. }
  4771. } catch (e) {}
  4772. }
  4773. // SYNC:
  4774. function musketSync() {
  4775. if (getEl("syncType").value === "s1") {
  4776. var musketCheckbox = document.getElementById("musketSync");
  4777. if (musketCheckbox && musketCheckbox.checked) {
  4778. my.autoAim = true;
  4779. selectWeapon(player.weapons[0]);
  4780. buyEquip(7, 0);
  4781. sendAutoGather();
  4782. game.tickBase(() => {
  4783. selectWeapon(player.weapons[1]);
  4784. buyEquip(player.reloads[53] === 0 ? 53 : 6, 0);
  4785. game.tickBase(() => {
  4786. sendAutoGather();
  4787. my.autoAim = false;
  4788. }, 3);
  4789. }, 2);
  4790. }
  4791. }
  4792. if (getEl("syncType").value === "s2") {
  4793. my.autoAim = true;
  4794. selectWeapon(player.weapons[0]);
  4795. buyEquip(7, 0);
  4796. buyEquip(18, 0);
  4797. sendAutoGather();
  4798. game.tickBase(() => {
  4799. sendAutoGather();
  4800. my.autoAim = false;
  4801. }, 1);
  4802. }
  4803. }
  4804.  
  4805. // HEALING:
  4806. function soldierMult() {
  4807. return player.latestSkin == 6 ? 0.75 : 1;
  4808. }
  4809.  
  4810. function healthBased() {
  4811. if (player.health == 100) {
  4812. return 0;
  4813. }
  4814. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4815. return Math.ceil(
  4816. (100 - player.health) / items.list[player.items[0]].healing
  4817. );
  4818. }
  4819. return 0;
  4820. }
  4821.  
  4822. function getAttacker(damaged) {
  4823. let attackers = enemy.filter((tmp) => {
  4824. let damages = new Damages(items);
  4825. let dmg = damages.weapons[tmp.weaponIndex];
  4826. let by =
  4827. tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4828. let rule = {
  4829. one: tmp.dist2 <= 300,
  4830. two: by.includes(damaged),
  4831. three: tmp.attacked,
  4832. };
  4833. return rule.one && rule.two && rule.three;
  4834. });
  4835. return attackers;
  4836. }
  4837.  
  4838. function healer() {
  4839. for (let i = 0; i < healthBased(); i++) {
  4840. place(0, getAttackDir());
  4841. }
  4842. }
  4843.  
  4844. // LATER:
  4845. function predictHeal(random) {
  4846. for (let Preidict in random) {
  4847. place(0, getAttackDir());
  4848. console.log("health predicted");
  4849. }
  4850. }
  4851. function antiSyncHealing(timearg) {
  4852. my.antiSync = true;
  4853. let healAnti = setInterval(() => {
  4854. if (player.shameCount < 5) {
  4855. place(0, getAttackDir());
  4856. }
  4857. }, 25);
  4858. setTimeout(() => {
  4859. clearInterval(healAnti);
  4860. setTimeout(() => {
  4861. my.antiSync = false;
  4862. }, game.tickRate);
  4863. }, game.tickRate);
  4864. }
  4865. // LATER:
  4866. function predictHeal1() {}
  4867. function antiSyncHealing1(timearg) {
  4868. my.antiSync = true;
  4869. let healAnti = setInterval(() => {
  4870. if (player.shameCount < 0) {
  4871. place(0, getAttackDir());
  4872. }
  4873. }, 75);
  4874. setTimeout(() => {
  4875. clearInterval(healAnti);
  4876. setTimeout(() => {
  4877. my.antiSync = false;
  4878. }, game.tickRate);
  4879. }, game.tickRate);
  4880. }
  4881. function findAllianceBySid(sid) {
  4882. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4883. }
  4884. function applCxC(value) {
  4885. if (player.health == 100) {
  4886. return 0;
  4887. }
  4888. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4889. return Math.ceil(value / items.list[player.items[0]].healing);
  4890. }
  4891. return 0;
  4892. }
  4893. function calcDmg(value) {
  4894. return value * player.skinIndex == 6 ? 0.75 : 1;
  4895. }
  4896. function biomeGear(mover, returns) {
  4897. if (
  4898. player.y2 >= config.mapScale / 2 - config.riverWidth / 2 &&
  4899. player.y2 <= config.mapScale / 2 + config.riverWidth / 2
  4900. ) {
  4901. if (returns) return 31;
  4902. buyEquip(31, 0);
  4903. } else {
  4904. if (player.y2 <= config.snowBiomeTop) {
  4905. if (returns) return enemy && near.dist2 <= 300 ? 6 : 15;
  4906. buyEquip(15, 0);
  4907. } else {
  4908. if (returns) return enemy && near.dist2 <= 300 ? 6 : 12;
  4909. buyEquip(enemy ? 6 : 12, 0);
  4910. }
  4911. }
  4912. if (returns) return 0;
  4913. }
  4914. let advHeal = [];
  4915.  
  4916. function woah(mover) {
  4917. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4918. }
  4919.  
  4920. let info = {};
  4921.  
  4922. let spikeKT = function() {
  4923. return player.weapons[1] == 10 && ((info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4924. }
  4925.  
  4926. let aimSpike = 0;
  4927.  
  4928. let nearspiker = false;
  4929.  
  4930. class Traps {
  4931. constructor(UTILS, items) {
  4932. this.dist = 0;
  4933. this.aim = 0;
  4934. this.inTrap = false;
  4935. this.replaced = false;
  4936. this.antiTrapped = false;
  4937. this.info = {};
  4938. this.notFast = function() {
  4939. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4940. }
  4941. this.testCanPlace = function (id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4942. try {
  4943. let item = items.list[player.items[id]];
  4944. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4945. let counts = {
  4946. attempts: 0,
  4947. placed: 0
  4948. };
  4949. let tmpObjects = [];
  4950. gameObjects.forEach((p) => {
  4951. tmpObjects.push({
  4952. x: p.x,
  4953. y: p.y,
  4954. active: p.active,
  4955. blocker: p.blocker,
  4956. scale: p.scale,
  4957. isItem: p.isItem,
  4958. type: p.type,
  4959. colDiv: p.colDiv,
  4960. getScale: function(sM, ig) {
  4961. sM = sM||1;
  4962. return this.scale * ((this.isItem||this.type==2||this.type==3||this.type==4)
  4963. ?1:(0.6*sM)) * (ig?1:this.colDiv);
  4964. },
  4965. });
  4966. });
  4967. for (let i = first; i < repeat; i += plus) {
  4968. counts.attempts++;
  4969. let relAim = radian + i;
  4970. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4971. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4972. 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)));
  4973. if (cantPlace) continue;
  4974. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4975. if ((!replacer && yaboi) || useWasd) {
  4976. if (useWasd ? false : yaboi.inTrap) {
  4977. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4978. place(2, relAim, 1);
  4979. } else {
  4980. player.items[4] == 15 && place(4, relAim, 1);
  4981. }
  4982. } else {
  4983. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  4984. place(2, relAim, 1);
  4985. } else {
  4986. player.items[4] == 15 && place(4, relAim, 1);
  4987. }
  4988. }
  4989. } else {
  4990. place(id, relAim, 1);
  4991. }
  4992. tmpObjects.push({
  4993. x: tmpX,
  4994. y: tmpY,
  4995. active: true,
  4996. blocker: item.blocker,
  4997. scale: item.scale,
  4998. isItem: true,
  4999. type: null,
  5000. colDiv: item.colDiv,
  5001. getScale: function() {
  5002. return this.scale;
  5003. },
  5004. });
  5005. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5006. counts.placed++;
  5007. }
  5008. }
  5009. if (counts.placed > 0 && replacer && item.dmg) {
  5010. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  5011. instaC.canSpikeTick = true;
  5012. }
  5013. }
  5014. } catch (err) {
  5015. }
  5016. };
  5017. this.checkSpikeTick = function() {
  5018. try {
  5019. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5020. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5021. // more range for safe. also testing near.primaryIndex || 5
  5022. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5023. let item = items.list[9];
  5024. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5025. let danger = 0;
  5026. let counts = {
  5027. attempts: 0,
  5028. block: `unblocked`
  5029. };
  5030. for (let i = -1; i <= 1; i += 1/10) {
  5031. counts.attempts++;
  5032. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5033. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5034. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5035. 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)));
  5036. if (cantPlace) continue;
  5037. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5038. danger++;
  5039. counts.block = `blocked`;
  5040. break;
  5041. }
  5042. if (danger) {
  5043. my.anti0Tick = 1;
  5044. player.chat.message = "Anti " + near.sid;
  5045. player.chat.count = 2000;
  5046. return true;
  5047. }
  5048. }
  5049. } catch (err) {
  5050. return null;
  5051. }
  5052. return false;
  5053. }
  5054. this.protect = function (aim) {
  5055. if (!configs.antiTrap) return;
  5056. if (player.items[4]) {
  5057. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5058. this.antiTrapped = true;
  5059. }
  5060. };
  5061. let placedSpikePositions = new Set();
  5062. let placedTrapPositions = new Set();
  5063.  
  5064. function isBroken() {
  5065.  
  5066. }
  5067. this.testPrePlace = function () {
  5068.  
  5069. }
  5070. function isPositionValid(x, y, objectRadius, gameObjects, walls) {
  5071. const isInsideWall = checkCollisionWithWalls(x, y, objectRadius, walls);
  5072.  
  5073. if (isInsideWall) {
  5074. return false;
  5075. }
  5076.  
  5077. const isOverlapping = checkOverlapWithObjects(x, y, objectRadius, gameObjects);
  5078.  
  5079. if (isOverlapping) {
  5080. return false;
  5081. }
  5082.  
  5083. return true;
  5084. }
  5085.  
  5086. function checkCollisionWithWalls(x, y, radius, walls) {
  5087. for (let i = 0; i < walls.length; i++) {
  5088. const wall = walls[i];
  5089. const dx = x - wall.x;
  5090. const dy = y - wall.y;
  5091. const distance = Math.sqrt(dx * dx + dy * dy);
  5092.  
  5093. if (distance <= radius + wall.width / 2) {
  5094. return true;
  5095. }
  5096. }
  5097.  
  5098. return false;
  5099. }
  5100.  
  5101. function checkOverlapWithObjects(x, y, radius, gameObjects) {
  5102. for (let i = 0; i < gameObjects.length; i++) {
  5103. const obj = gameObjects[i];
  5104. if (obj.x - obj.radius <= x && x <= obj.x + obj.radius &&
  5105. obj.y - obj.radius <= y && y <= obj.y + obj.radius) {
  5106. return true;
  5107. }
  5108. }
  5109.  
  5110. return false;
  5111. }
  5112. function calculatePossibleTrapPositions(x, y, numPositions, objectRadius, gameObjects, walls) {
  5113. const possiblePositions = [];
  5114.  
  5115. const angleIncrement = (2 * Math.PI) / numPositions;
  5116.  
  5117. for (let i = 0; i < numPositions; i++) {
  5118. const angle = i * angleIncrement;
  5119. const dx = x + objectRadius * Math.cos(angle);
  5120. const dy = y + objectRadius * Math.sin(angle);
  5121.  
  5122. if (isPositionValid(dx, dy, objectRadius, gameObjects, walls)) {
  5123. possiblePositions.push({ x: dx, y: dy });
  5124. }
  5125. }
  5126.  
  5127. return possiblePositions;
  5128. }
  5129. this.autoPlace = function () {
  5130. if (configs.autoPlace && game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5131. try {
  5132. const trap1 = gameObjects
  5133. .filter((e) => e.trap && e.active)
  5134. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5135. .find((trap) => {
  5136. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5137. return (
  5138. trap !== player &&
  5139. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5140. trapDist <= 50
  5141. );
  5142. });
  5143. if (this.inTrap) {
  5144. let antiTrapAngles = Math.PI / Math.floor(Math.random() * (20 - 10 + 1)) + 10;
  5145. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), antiTrapAngles, near.aim2);
  5146. } else {
  5147. if (trap1 && near.dist2 <= 180) {
  5148. const trapX = trap1.x;
  5149. const trapY = trap1.y;
  5150. const circleRadius = 102;
  5151. const numPositions = 64;
  5152. for (let i = 0; i < numPositions; i++) {
  5153. const angle = (2 * Math.PI * i) / numPositions;
  5154. const offsetX = trapX + circleRadius * Math.cos(angle);
  5155. const offsetY = trapY + circleRadius * Math.sin(angle);
  5156. const position = [offsetX, offsetY];
  5157. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5158. if (
  5159. isPositionValid(position) &&
  5160. distToPlayer <= 87
  5161. ) {
  5162. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5163. checkPlace(2, angleToPlace);
  5164. }
  5165. }
  5166. } else if (!trap1 && near.dist2 <= 206) {
  5167. const maxTrapsToPlace = 3;
  5168. const trapRadius = 50;
  5169. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5170. let trapsPlaced = 0;
  5171. for (const position of trapPositions) {
  5172. if (
  5173. trapsPlaced < maxTrapsToPlace &&
  5174. isPositionValid(position)
  5175. ) {
  5176. checkPlace(4, ...position);
  5177. trapsPlaced++;
  5178. }
  5179. }
  5180. }
  5181. }
  5182. } catch (e) {
  5183. console.log(e);
  5184. }
  5185. }
  5186. };
  5187. this.autoPlace = function () {
  5188. if (getEl("autoPlacetype").value === "spamtrap2") {
  5189. if (game.tick % 0.5 === 0)
  5190. try {
  5191. if (configs.autoPlace) {
  5192. const dist = near.dist2;
  5193. const trap = gameObjects
  5194. .filter((e) => e.trap && e.active)
  5195. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5196. .find((trap) => {
  5197. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5198. return (
  5199. trap !== player &&
  5200. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5201. trapDist <= near.scale * 1.8
  5202. );
  5203. });
  5204. if (trap && dist <= 250) {
  5205. checkPlace(2, Math.atan2(player.y - trap.y, player.x - trap.x) + Math.PI);
  5206. } else if (!trap && dist <= 400) {
  5207. const angles = dist < 200 ? [0, 55, 110, 165, -55, -110, -165] : [0, 90, 180, 270];
  5208. for (let i = 0; i < angles.length; i++) {
  5209. checkPlace(2, near.aim2 + toR(angles[i]));
  5210. }
  5211. }
  5212. }
  5213. } catch (e) {}
  5214. } else if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5215. if (getEl("autoPlacetype").value === "spamtrap") {
  5216. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5217. if (gameObjects.length) {
  5218. let near2 = {
  5219. inTrap: false,
  5220. };
  5221. 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) {
  5222. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5223. })[0];
  5224. if (nearTrap) {
  5225. near2.inTrap = true;
  5226. } else {
  5227. near2.inTrap = false;
  5228. }
  5229. if (testMode ? enemy.length : (near.dist2 <= 300)) {
  5230. const numTries = near.dist2 <= 200 ? 12 : 4;
  5231. for (let i = 0; i < numTries; i++) {
  5232. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, i / numTries, {inTrap: near2.inTrap});
  5233. }
  5234. }
  5235. } else {
  5236. if (testMode ? enemy.length : (near.dist2 <= 300)) {
  5237. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5238. }
  5239. }
  5240. }
  5241. }
  5242. }
  5243. };
  5244.  
  5245.  
  5246. this.autoPlace = function () {
  5247. if (getEl("autoPlacetype").value == "ramdomplc") {
  5248. try {
  5249. const dist = near.dist2;
  5250. const trap = gameObjects
  5251. .filter((e) => e.trap && e.active)
  5252. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5253. .find((trap) => {
  5254. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5255. return (
  5256. trap !== player &&
  5257. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5258. trapDist <= near.scale * 1.8
  5259. );
  5260. });
  5261.  
  5262. if (trap && near.dist2 <= 250) {
  5263. const angleToTrap = Math.atan2(player.y - trap.y, player.x - trap.x);
  5264. checkPlace(2, angleToTrap + Math.PI);
  5265. } else if (!trap && dist <= 300) {
  5266. if (dist < 200) {
  5267. const maxAngle = Math.PI / 6;
  5268. const angleMultiplier = Math.min(1, Math.max(0, (dist - 150) / 130));
  5269. const adjustedAngle = maxAngle * angleMultiplier;
  5270.  
  5271. for (let i = -55; i < 55; i += 55) {
  5272. const perfectAngle = calculatePerfectAngle(near.x2, near.y2, player.x2, player.y2);
  5273. checkPlace(2, perfectAngle + adjustedAngle + toR(i));
  5274. }
  5275. }
  5276. if (dist >= 200) {
  5277. const maxAngle = Math.PI / 6;
  5278. const angleMultiplier = Math.min(1, Math.max(0, (dist - 150) / 130));
  5279. const adjustedAngle = maxAngle * angleMultiplier;
  5280.  
  5281. for (let i = -90; i < 270; i += 90) {
  5282. const perfectAngle = calculatePerfectAngle(near.x2, near.y2, player.x2, player.y2);
  5283. checkPlace(4, perfectAngle + adjustedAngle + toR(i));
  5284. }
  5285. }
  5286. }
  5287. } catch (e) {}
  5288. };
  5289. }
  5290.  
  5291. this.autoPlace = function () {
  5292. if (configs.autoPlace && game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5293. if (getEl("autoPlacetype").value == "aiplace") {
  5294. try {
  5295. const trap1 = gameObjects
  5296. .filter((e) => e.trap && e.active)
  5297. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5298. .find((trap) => {
  5299. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5300. return (
  5301. trap !== player &&
  5302. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5303. trapDist <= 50
  5304. );
  5305. });
  5306. if (this.inTrap) {
  5307. let antiTrapAngles = Math.PI / Math.floor(Math.random() * (20 - 10 + 1)) + 10;
  5308. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), antiTrapAngles, near.aim2);
  5309. } else {
  5310. if (trap1 && near.dist2 <= 180) {
  5311. const trapX = trap1.x;
  5312. const trapY = trap1.y;
  5313. const circleRadius = 102;
  5314. const numPositions = 64;
  5315. for (let i = 0; i < numPositions; i++) {
  5316. const angle = (2 * Math.PI * i) / numPositions;
  5317. const offsetX = trapX + circleRadius * Math.cos(angle);
  5318. const offsetY = trapY + circleRadius * Math.sin(angle);
  5319. const position = [offsetX, offsetY];
  5320. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5321. if (
  5322. isPositionValid(position) &&
  5323. distToPlayer <= 87
  5324. ) {
  5325. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5326. checkPlace(2, angleToPlace);
  5327. }
  5328. }
  5329. } else if (!trap1 && near.dist2 <= 206) {
  5330. const maxTrapsToPlace = 3;
  5331. const trapRadius = 50;
  5332. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5333. let trapsPlaced = 0;
  5334. for (const position of trapPositions) {
  5335. if (
  5336. trapsPlaced < maxTrapsToPlace &&
  5337. isPositionValid(position)
  5338. ) {
  5339. checkPlace(4, ...position);
  5340. trapsPlaced++;
  5341. }
  5342. }
  5343. }
  5344. }
  5345. } catch (e) {
  5346. console.log(e);
  5347. }
  5348. }
  5349. };
  5350. }
  5351.  
  5352. this.autoPlace = function() {
  5353. if (!configs.autoPlace) return;
  5354. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5355. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5356. if (gameObjects.length) {
  5357. let near2 = {
  5358. inTrap: false,
  5359. };
  5360. 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) {
  5361. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5362. })[0];
  5363. if (nearTrap) {
  5364. near2.inTrap = true;
  5365. } else {
  5366. near2.inTrap = false;
  5367. }
  5368. if (near.dist3 <= 450) {
  5369. if (near.dist3 <= 200) {
  5370. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5371. inTrap: near2.inTrap
  5372. });
  5373. } else {
  5374. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5375. }
  5376. }
  5377. } else {
  5378. if (near.dist3 <= 450) {
  5379. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5380. }
  5381. }
  5382. }
  5383. }
  5384. };
  5385.  
  5386. function autoPlace() { // bug place
  5387. let nearObj = [];
  5388. if (gameObjects.length && enemy.length) {
  5389. let inTrap = false;
  5390. nearObj = gameObjects.filter((e)=>e.trap).sort(function(a, b) {
  5391. return (UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2));
  5392. })[0];
  5393. if (nearObj) {
  5394. if (!(player.sid != nearObj.owner.sid && !findAllianceBySid(nearObj.owner.sid)) && UTILS.getDist(nearObj, near, 0, 2) <= 70 && nearObj.active) {
  5395. inTrap = true;
  5396. } else {
  5397. inTrap = false;
  5398. }
  5399. if (near.dist2 <= 350) {
  5400. if (inTrap && near.dist2 <= 200) {
  5401. if (near.dist2 <= player.scale + near.scale + Math.PI * 2) {
  5402. checkPlace(2, near.aim2 - UTILS.getDirect(nearObj, near, 0, 2));
  5403. checkPlace(2, near.aim2 + UTILS.getDirect(nearObj, near, 0, 2));
  5404. }
  5405. }
  5406. if (near.dist2 <= near.scale + player.scale) {
  5407. checkPlace(2, near.aim2);
  5408. } else {
  5409. if (near.dist2 <= 200 && !instaC.canSpikeTick && !traps.in && !inTrap) {
  5410. checkPlace(2, near.aim2 + UTILS.toRad(90));
  5411. checkPlace(2, near.aim2 - UTILS.toRad(90));
  5412. } else {
  5413. if (near.dist2 <= 250) {
  5414. checkPlace(2, near.aim2 + Math.PI);
  5415. } else {
  5416. for (let i = 0; i < 360; i += 90) {
  5417. checkPlace(4, UTILS.toRad(i));
  5418. }
  5419. }
  5420. }
  5421. }
  5422. }
  5423. }
  5424. }
  5425. }
  5426.  
  5427.  
  5428.  
  5429.  
  5430.  
  5431. this.autoplace = function () {
  5432. let oldXY = {
  5433. x: undefined,
  5434. y: undefined,
  5435. };
  5436. if (getEl("autoPlacetype").value == "magicplace") {
  5437.  
  5438.  
  5439.  
  5440. let nearObj = [];
  5441. let randomDir = Math.random() * Math.PI * 2;
  5442. if (gameObjects.length && enemy.length) {
  5443. let nearsa = {
  5444. inTrap: false,
  5445. };
  5446. nearObj = gameObjects.filter((e)=>e.trap).sort(function(a, b) {
  5447. return (UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2));
  5448. })[0];
  5449. 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) {
  5450. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5451. })[0];
  5452. let near2 = {
  5453. inTrap: false,
  5454. };
  5455. if (nearTrap) {
  5456. near2.inTrap = true;
  5457. } else {
  5458. near2.inTrap = false;
  5459. }
  5460. if (nearObj) {
  5461. if (!(player.sid != nearObj.owner.sid && !findAllianceBySid(nearObj.owner.sid)) && UTILS.getDist(nearObj, near, 0, 2) <= 70 && nearObj.active) {
  5462. nearsa.inTrap = true;
  5463. } else {
  5464. nearsa.inTrap = false;
  5465. }
  5466. if (near.dist2 <= 600) {
  5467. if (nearsa.inTrap || near.dist2 <= 60 + near.scale) {
  5468. if (near.dist2 <= 250) {
  5469. for (let i = 0; i < Math.PI * 2; i += Math.PI / 1.5) {
  5470. checkPlace(2, near.aim2 + i);
  5471. }
  5472. } else {
  5473. for (let i = Math.PI / 1.5; i < Math.PI * 2; i += Math.PI / 1.5) {
  5474. checkPlace(2, near.aim2 + i);
  5475. }
  5476. }
  5477. } else {
  5478. if (player.items[4] == 15) {
  5479. if (near.dist2 <= 200) {
  5480. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  5481. checkPlace(4, randomDir + i);
  5482. }
  5483. }
  5484. }
  5485. }
  5486. }
  5487. } else {
  5488. if (near.dist2 <= 400) {
  5489. if (player.items[4] == 15) {
  5490. checkPlace(4, near.aim2);
  5491. }
  5492. }
  5493. }
  5494. }
  5495. }
  5496. }
  5497.  
  5498.  
  5499.  
  5500. this.replacer1 = function(findObj) {
  5501. if (!findObj || !configs.autoReplace) return;
  5502. if (!inGame) return;
  5503. if (this.antiTrapped) return;
  5504. game.tickBase(() => {
  5505. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5506. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5507. if (configs.autoGrind && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5508. if (objDst <= 400 && near.dist2 <= 400) {
  5509. let danger = this.checkSpikeTick();
  5510. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5511. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5512. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5513. } else {
  5514. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5515. }
  5516. this.replaced = true;
  5517. }
  5518. }, 1);
  5519. }
  5520. function calculatePerfectAngle(x1, y1, x2, y2) {
  5521. return Math.atan2(y2 - y1, x2 - x1);
  5522. }
  5523. let spikePlaced = false;
  5524. let spikSync = false;
  5525.  
  5526.  
  5527.  
  5528. this.replacer = function(findObj) {
  5529. if (!findObj || !configs.autoReplace) return;
  5530. if (!inGame) return;
  5531. if (this.antiTrapped) return;
  5532. game.tickBase(() => {
  5533. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5534. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5535. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5536.  
  5537. if(spikePlaced){
  5538. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5539. spikePlaced = false;
  5540. }
  5541. if (near.dist2 <= 250 && !spikSync) {
  5542. for (let i = 0; i < 24; i++) {
  5543. let angle = (Math.PI * 2) * i / 24;
  5544. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1);
  5545. spikePlaced = true;
  5546. }
  5547. }
  5548. if (objDst <= 250 && near.dist2 <= 250) {
  5549. let danger = this.checkSpikeTick();
  5550. if (!danger && near.dist3 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5551.  
  5552. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1)
  5553. for (let i = 0; i < 24; i++) {
  5554. let angle = (Math.PI * 2) * i / 24;
  5555. this.testCanPlace(2, angle, angle + (Math.PI / 24), (Math.PI / 24), objAim, 1);
  5556. this.testCanPlace(2, (Math.PI / 2), (Math.PI / 2), (Math.PI / 2), near, objAim, 1)
  5557. spikSync = true;
  5558.  
  5559. }
  5560. } else {
  5561. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5562. }
  5563.  
  5564. this.replaced = true;
  5565. }
  5566. }, 1);
  5567. };
  5568. }
  5569. };
  5570. class Instakill {
  5571. constructor() {
  5572. if (secPacket > 60) return
  5573. this.wait = false;
  5574. this.can = false;
  5575. this.isTrue = false;
  5576. this.nobull = false;
  5577. this.ticking = false;
  5578. this.canSpikeTick = false;
  5579. this.startTick = false;
  5580. this.readyTick = false;
  5581. this.canCounter = false;
  5582. this.revTick = false;
  5583. this.syncHit = false;
  5584. this.changeType = function(type) {
  5585. this.wait = false;
  5586. this.isTrue = true;
  5587. my.autoAim = true;
  5588. let instaLog = [type];
  5589. let backupNobull = near.backupNobull;
  5590. near.backupNobull = false;
  5591. game.tickBase(() => {
  5592. instaLog.push(player.skinIndex);
  5593. game.tickBase(() => {
  5594. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5595. near.backupNobull = true;
  5596. }
  5597. instaLog.push(player.skinIndex);
  5598. }, 1);
  5599. }, 1);
  5600. if (type == "rev") {
  5601. selectWeapon(player.weapons[1]);
  5602. buyEquip(53, 0);
  5603. buyEquip(21, 1);
  5604. sendAutoGather();
  5605. game.tickBase(() => {
  5606. if (near.dist2 <= 140 && configs.doSpikeOnReverse) place(2, getAttackDir());
  5607. selectWeapon(player.weapons[0]);
  5608. buyEquip(7, 0);
  5609. game.tickBase(() => {
  5610. sendAutoGather();
  5611. this.isTrue = false;
  5612. my.autoAim = false;
  5613. }, 1);
  5614. }, 1);
  5615. } else if (type == "nobull") {
  5616. selectWeapon(player.weapons[0]);
  5617. sendAutoGather();
  5618. game.tickBase(() => {
  5619. selectWeapon(player.weapons[1]);
  5620. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5621. buyEquip(21, 1);
  5622. game.tickBase(() => {
  5623. sendAutoGather();
  5624. this.isTrue = false;
  5625. my.autoAim = false;
  5626. }, 1);
  5627. }, 1);
  5628.  
  5629. } else if (type == "normal") {
  5630. selectWeapon(player.weapons[0]);
  5631. buyEquip(7, 0);
  5632. sendAutoGather();
  5633. game.tickBase(() => {
  5634. selectWeapon(player.weapons[1]);
  5635. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5636. buyEquip(21, 1);
  5637. game.tickBase(() => {
  5638. sendAutoGather();
  5639. this.isTrue = false;
  5640. my.autoAim = false;
  5641. }, 1);
  5642. }, 1);
  5643. } else {
  5644. setTimeout(() => {
  5645. this.isTrue = false;
  5646. my.autoAim = false;
  5647. }, 50);
  5648. }
  5649. };
  5650. this.spikeTickType = function() {
  5651. sendChat("yes spike tick ");
  5652. this.isTrue = true;
  5653. my.autoAim = true;
  5654. selectWeapon(player.weapons[0]);
  5655. buyEquip(7, 0);
  5656. sendAutoGather();
  5657. game.tickBase(() => {
  5658. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5659. buyEquip(53, 0);
  5660. selectWeapon(player.weapons[0]);
  5661. buyEquip(53, 0);
  5662. //buyEquip(21, 1);
  5663. game.tickBase(() => {
  5664. sendAutoGather();
  5665. this.isTrue = false;
  5666. my.autoAim = false;
  5667. buyEquip(6, 0);
  5668. buyEquip(21, 1);
  5669. }, 1);
  5670. }, 1);
  5671. };
  5672. this.counterType = function() {
  5673. this.isTrue = true;
  5674. my.autoAim = true;
  5675. selectWeapon(player.weapons[0]);
  5676. buyEquip(7, 0);
  5677. sendAutoGather();
  5678. game.tickBase(() => {
  5679. selectWeapon(player.weapons[0]);
  5680. buyEquip(53, 0);
  5681. game.tickBase(() => {
  5682. sendAutoGather();
  5683. this.isTrue = false;
  5684. my.autoAim = false;
  5685. }, 1);
  5686. }, 1);
  5687. };
  5688. function Hg(hat, acc){
  5689. buyEquip(hat, 0);
  5690. buyEquip(acc, 1);
  5691. }
  5692. this.syncTry = function(syncType = "sec", time = 2) {
  5693. setTimeout(() => {
  5694. if (syncType == "sec") {
  5695. if (player.weapons[1] == 15) {
  5696. packet("D", near.aim2);
  5697. this.isTrue = true;
  5698. my.autoAim = true;
  5699. selectWeapon(player.weapons[1]);
  5700. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5701. Hg(53, 21);
  5702. } else {
  5703. Hg(20, 21);
  5704. }2
  5705. sendAutoGather();
  5706. game.tickBase(() => {
  5707. this.isTrue = false;
  5708. my.autoAim = false;
  5709. sendAutoGather();
  5710. }, 2);
  5711. }
  5712. }
  5713. }, time);
  5714. };
  5715. this.rangeType = function(type) {
  5716. this.isTrue = true;
  5717. my.autoAim = true;
  5718. if (type == "ageInsta") {
  5719. my.ageInsta = false;
  5720. if (player.items[5] == 18) {
  5721. place(5, near.aim2);
  5722. }
  5723. packet("a", undefined, 1);
  5724. buyEquip(22, 0);
  5725. buyEquip(21, 1);
  5726. game.tickBase(() => {
  5727. selectWeapon(player.weapons[1]);
  5728. buyEquip(53, 0);
  5729. buyEquip(21, 1);
  5730. sendAutoGather();
  5731. game.tickBase(() => {
  5732. sendUpgrade(12);
  5733. selectWeapon(player.weapons[1]);
  5734. buyEquip(53, 0);
  5735. buyEquip(21, 1);
  5736. game.tickBase(() => {
  5737. sendUpgrade(15);
  5738. selectWeapon(player.weapons[1]);
  5739. buyEquip(53, 0);
  5740. buyEquip(21, 1);
  5741. game.tickBase(() => {
  5742. sendAutoGather();
  5743. this.isTrue = false;
  5744. my.autoAim = false;
  5745. }, 1);
  5746. }, 1);
  5747. }, 1);
  5748. }, 1);
  5749. } else {
  5750. selectWeapon(player.weapons[1]);
  5751. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5752. buyEquip(53, 0);
  5753. } else {
  5754. buyEquip(20, 0);
  5755. }
  5756. buyEquip(11, 1);
  5757. sendAutoGather();
  5758. game.tickBase(() => {
  5759. sendAutoGather();
  5760. this.isTrue = false;
  5761. my.autoAim = false;
  5762. }, 1);
  5763. }
  5764. };
  5765. this.oneTickType = function() {
  5766. this.isTrue = true;
  5767. my.autoAim = true;
  5768. biomeGear();
  5769. buyEquip(19, 1);
  5770. packet("a", near.aim2, 1);
  5771. game.tickBase(() => {
  5772. if (player.weapons[1] == 15) {
  5773. my.revAim = true;
  5774. }
  5775. selectWeapon(player.weapons[[15].includes(player.weapons[1]) ? 1 : 0]);
  5776. buyEquip(53, 0);
  5777. buyEquip(19, 1);
  5778. if ([15].includes(player.weapons[1])) {
  5779. sendAutoGather();
  5780. }
  5781. packet("a", near.aim2, 1);
  5782. game.tickBase(() => {
  5783. my.revAim = false;
  5784. selectWeapon(player.weapons[0]);
  5785. buyEquip(7, 0);
  5786. buyEquip(19, 1);
  5787. if (![15].includes(player.weapons[1])) {
  5788. sendAutoGather();
  5789. }
  5790. packet("a", near.aim2, 1);
  5791. game.tickBase(() => {
  5792. sendAutoGather();
  5793. this.isTrue = false;
  5794. my.autoAim = false;
  5795. packet("a", undefined, 1);
  5796. this.readyTick = false;
  5797. }, 3);
  5798. }, 1);
  5799. }, 1);
  5800. };
  5801. this.threeOneTickType = function() {
  5802. this.isTrue = true;
  5803. my.autoAim = true;
  5804. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5805. biomeGear();
  5806. buyEquip(11, 1);
  5807. packet("a", near.aim2, 1);
  5808. game.tickBase(() => {
  5809. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5810. buyEquip(53, 0);
  5811. buyEquip(11, 1);
  5812. packet("a", near.aim2, 1);
  5813. game.tickBase(() => {
  5814. selectWeapon(player.weapons[0]);
  5815. buyEquip(7, 0);
  5816. buyEquip(19, 1);
  5817. sendAutoGather();
  5818. packet("a", near.aim2, 1);
  5819. game.tickBase(() => {
  5820. sendAutoGather();
  5821. this.isTrue = false;
  5822. my.autoAim = false;
  5823. packet("a", undefined, 1);
  5824. }, 1);
  5825. }, 1);
  5826. }, 1);
  5827. };
  5828. this.kmTickType = function() {
  5829. this.isTrue = true;
  5830. my.autoAim = true;
  5831. my.revAim = true;
  5832. selectWeapon(player.weapons[1]);
  5833. buyEquip(53, 0);
  5834. buyEquip(11, 1);
  5835. sendAutoGather();
  5836. packet("a", near.aim2, 1);
  5837. game.tickBase(() => {
  5838. my.revAim = false;
  5839. selectWeapon(player.weapons[0]);
  5840. buyEquip(7, 0);
  5841. buyEquip(19, 1);
  5842. packet("a", near.aim2, 1);
  5843. game.tickBase(() => {
  5844. sendAutoGather();
  5845. this.isTrue = false;
  5846. my.autoAim = false;
  5847. packet("a", undefined, 1);
  5848. }, 1);
  5849. }, 1);
  5850. };
  5851. this.boostTickType = function() {
  5852. /*this.isTrue = true;
  5853. my.autoAim = true;
  5854. selectWeapon(player.weapons[0]);
  5855. buyEquip(53, 0);
  5856. buyEquip(11, 1);
  5857. packet("a", near.aim2);
  5858. game.tickBase(() => {
  5859. place(4, near.aim2);
  5860. selectWeapon(player.weapons[1]);
  5861. biomeGear();
  5862. buyEquip(11, 1);
  5863. sendAutoGather();
  5864. packet("a", near.aim2);
  5865. game.tickBase(() => {
  5866. selectWeapon(player.weapons[0]);
  5867. buyEquip(7, 0);
  5868. buyEquip(19, 1);
  5869. packet("a", near.aim2);
  5870. game.tickBase(() => {
  5871. sendAutoGather();
  5872. this.isTrue = false;
  5873. my.autoAim = false;
  5874. packet("a", undefined);
  5875. }, 1);
  5876. }, 1);
  5877. }, 1);*/
  5878. this.isTrue = true;
  5879. my.autoAim = true;
  5880. biomeGear();
  5881. buyEquip(11, 1);
  5882. packet("a", near.aim2, 1);
  5883. game.tickBase(() => {
  5884. if (player.weapons[1] == 15) {
  5885. my.revAim = true;
  5886. }
  5887. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5888. buyEquip(53, 0);
  5889. buyEquip(11, 1);
  5890. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5891. sendAutoGather();
  5892. }
  5893. packet("a", near.aim2, 1);
  5894. place(4, near.aim2);
  5895. game.tickBase(() => {
  5896. my.revAim = false;
  5897. selectWeapon(player.weapons[0]);
  5898. buyEquip(7, 0);
  5899. buyEquip(19, 1);
  5900. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5901. sendAutoGather();
  5902. }
  5903. packet("a", near.aim2, 1);
  5904. game.tickBase(() => {
  5905. sendAutoGather();
  5906. this.isTrue = false;
  5907. my.autoAim = false;
  5908. packet("a", undefined, 1);
  5909. }, 1);
  5910. }, 1);
  5911. }, 1);
  5912. };
  5913. this.gotoGoal = function(goto, OT) {
  5914. let slowDists = (weeeee) => weeeee * config.playerScale;
  5915. let goal = {
  5916. a: goto - OT,
  5917. b: goto + OT,
  5918. c: goto - slowDists(1),
  5919. d: goto + slowDists(1),
  5920. e: goto - slowDists(2),
  5921. f: goto + slowDists(2),
  5922. g: goto - slowDists(4),
  5923. h: goto + slowDists(4)
  5924. };
  5925. let bQ = function (wwww, awwww) {
  5926. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5927. buyEquip(31, 0);
  5928. } else {
  5929. buyEquip(wwww, awwww);
  5930. }
  5931. }
  5932. if (enemy.length) {
  5933. let dst = near.dist2;
  5934. this.ticking = true;
  5935. if (dst >= goal.a && dst <= goal.b) {
  5936. bQ(22, 0);
  5937. bQ(11, 1);
  5938. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5939. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5940. }
  5941. return {
  5942. dir: undefined,
  5943. action: 1
  5944. };
  5945. } else {
  5946. if (dst < goal.a) {
  5947. if (dst >= goal.g) {
  5948. if (dst >= goal.e) {
  5949. if (dst >= goal.c) {
  5950. bQ(40, 0);
  5951. bQ(10, 1);
  5952. if (configs.slowOT) {
  5953. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5954. } else {
  5955. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5956. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5957. }
  5958. }
  5959. } else {
  5960. bQ(22, 0);
  5961. bQ(19, 1);
  5962. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5963. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5964. }
  5965. }
  5966. } else {
  5967. bQ(6, 0);
  5968. bQ(12, 1);
  5969. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5970. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5971. }
  5972. }
  5973. } else {
  5974. biomeGear();
  5975. bQ(11, 1);
  5976. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5977. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5978. }
  5979. }
  5980. return {
  5981. dir: near.aim2 + Math.PI,
  5982. action: 0
  5983. };
  5984. } else if (dst > goal.b) {
  5985. if (dst <= goal.h) {
  5986. if (dst <= goal.f) {
  5987. if (dst <= goal.d) {
  5988. bQ(40, 0);
  5989. bQ(9, 1);
  5990. if (configs.slowOT) {
  5991. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5992. } else {
  5993. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5994. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5995. }
  5996. }
  5997. } else {
  5998. bQ(22, 0);
  5999. bQ(19, 1);
  6000. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6001. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6002. }
  6003. }
  6004. } else {
  6005. bQ(6, 0);
  6006. bQ(12, 1);
  6007. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6008. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6009. }
  6010. }
  6011. } else {
  6012. biomeGear();
  6013. bQ(11, 1);
  6014. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6015. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6016. }
  6017. }
  6018. return {
  6019. dir: near.aim2,
  6020. action: 0
  6021. };
  6022. }
  6023. return {
  6024. dir: undefined,
  6025. action: 0
  6026. };
  6027. }
  6028. } else {
  6029. this.ticking = false;
  6030. return {
  6031. dir: undefined,
  6032. action: 0
  6033. };
  6034. }
  6035. }
  6036. /** wait 1 tick for better quality */
  6037. this.bowMovement = function() {
  6038. let moveMent = this.gotoGoal(685, 3);
  6039. if (moveMent.action) {
  6040. if (player.reloads[53] == 0 && !this.isTrue) {
  6041. this.rangeType("ageInsta");
  6042. } else {
  6043. packet("a", moveMent.dir, 1);
  6044. }
  6045. } else {
  6046. packet("a", moveMent.dir, 1);
  6047. }
  6048. },
  6049. this.tickMovement = function() {
  6050. let dist = player.weapons[1] == 9 ? 240 : 240;
  6051. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  6052. let moveMent = this.gotoGoal(238, 3);
  6053. if (moveMent.action) {
  6054. if (player.reloads[53] == 0 && !this.isTrue) {
  6055. this.boostTickType();
  6056. } else {
  6057. packet("a", moveMent.dir, 1);
  6058. }
  6059. } else {
  6060. packet("a", moveMent.dir, 1);
  6061. }
  6062. },
  6063. this.kmTickMovement = function() {
  6064. let moveMent = this.gotoGoal(240, 3);
  6065. if (moveMent.action) {
  6066. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  6067. this.kmTickType();
  6068. } else {
  6069. packet("a", moveMent.dir, 1);
  6070. }
  6071. } else {
  6072. packet("a", moveMent.dir, 1);
  6073. }
  6074. },
  6075. this.boostTickMovement = function() {
  6076. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  6077. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  6078. let moveMent = this.gotoGoal(372, 3);
  6079. if (moveMent.action) {
  6080. if (player.reloads[53] == 0 && !this.isTrue) {
  6081. this.boostTickType();
  6082. } else {
  6083. packet("a", moveMent.dir, 1);
  6084. }
  6085. } else {
  6086. packet("a", moveMent.dir, 1);
  6087. }
  6088. }
  6089. /** wait 1 tick for better quality */
  6090. this.perfCheck = function(pl, nr) {
  6091. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  6092. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  6093. let pjs = {
  6094. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  6095. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  6096. };
  6097. 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)) {
  6098. return true;
  6099. }
  6100. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  6101. 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)) {
  6102. return true;
  6103. }
  6104. });
  6105. if (finds) return false;
  6106. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  6107. let tmpScale = tmp.getScale();
  6108. 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)) {
  6109. return true;
  6110. }
  6111. });
  6112. if (finds) return false;
  6113. return true;
  6114. }
  6115. }
  6116. };
  6117. class Autobuy {
  6118. constructor(buyHat, buyAcc) {
  6119. this.hat = function() {
  6120. buyHat.forEach((id) => {
  6121. let find = findID(hats, id);
  6122. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  6123. });
  6124. };
  6125. this.acc = function() {
  6126. buyAcc.forEach((id) => {
  6127. let find = findID(accessories, id);
  6128. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  6129. });
  6130. };
  6131. }
  6132. };
  6133.  
  6134. class Autoupgrade {
  6135. constructor() {
  6136. this.sb = function(upg) {
  6137. upg(3);
  6138. upg(17);
  6139. upg(31);
  6140. upg(23);
  6141. upg(9);
  6142. upg(38);
  6143. };
  6144. this.kh = function(upg) {
  6145. upg(3);
  6146. upg(17);
  6147. upg(31);
  6148. upg(23);
  6149. upg(10);
  6150. upg(38);
  6151. upg(4);
  6152. upg(25);
  6153. };
  6154. this.pb = function(upg) {
  6155. upg(5);
  6156. upg(17);
  6157. upg(32);
  6158. upg(23);
  6159. upg(9);
  6160. upg(38);
  6161. };
  6162. this.ph = function(upg) {
  6163. upg(5);
  6164. upg(17);
  6165. upg(32);
  6166. upg(23);
  6167. upg(10);
  6168. upg(38);
  6169. upg(28);
  6170. upg(25);
  6171. };
  6172. this.db = function(upg) {
  6173. upg(7);
  6174. upg(17);
  6175. upg(31);
  6176. upg(23);
  6177. upg(9);
  6178. upg(34);
  6179. };
  6180. /* old functions */
  6181. this.km = function(upg) {
  6182. upg(7);
  6183. upg(17);
  6184. upg(31);
  6185. upg(23);
  6186. upg(10);
  6187. upg(38);
  6188. upg(4);
  6189. upg(15);
  6190. };
  6191. };
  6192. };
  6193.  
  6194. class Damages {
  6195. constructor(items) {
  6196. // 0.75 1 1.125 1.5
  6197. this.calcDmg = function(dmg, val) {
  6198. return dmg * val;
  6199. };
  6200. this.getAllDamage = function(dmg) {
  6201. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  6202. };
  6203. this.weapons = [];
  6204. for (let i = 0; i < items.weapons.length; i++) {
  6205. let wp = items.weapons[i];
  6206. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  6207. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  6208. this[name] = this.weapons[i];
  6209. }
  6210. }
  6211. }
  6212.  
  6213. let greetings = false;
  6214.  
  6215. function getGreeting() {
  6216. const hour = new Date().getHours();
  6217. if (hour < 12) {
  6218. return "Good Morning!";
  6219. } else if (hour < 18) {
  6220. return "Good Afternoon!";
  6221. } else {
  6222. return "Good Evening!";
  6223. }
  6224. }
  6225.  
  6226. function greeting() {
  6227. if (!greetings) {
  6228. greetings = true;
  6229. const frameMsg = Object.assign(document.createElement("div"), {
  6230. innerHTML: `${getGreeting()}`,
  6231. style: `
  6232. position: fixed;
  6233. top: -100px;
  6234. left: 50%;
  6235. transform: translateX(-50%);
  6236. font-size: 2rem;
  6237. color: white;
  6238. z-index: 9999;
  6239. opacity: 3;
  6240. transition: top 0.5s ease-in-out, opacity 0.5s ease-in-out;
  6241. padding: 10px;
  6242. background-color: rgba(0, 0, 0, 0.2);
  6243. border: 2px solid #0000;
  6244. border-radius: 5px;
  6245. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  6246. `
  6247. });
  6248. document.body.appendChild(frameMsg);
  6249. setTimeout(function() {
  6250. frameMsg.style.top = "7%";
  6251. frameMsg.style.opacity = "1";
  6252. }, 100);
  6253. setTimeout(function() {
  6254. frameMsg.style.top = "-100px";
  6255. frameMsg.style.opacity = "0";
  6256. setTimeout(function() {
  6257. frameMsg.remove();
  6258. greetings = false;
  6259. }, 500);
  6260. }, 3000);
  6261. }
  6262. }
  6263. greeting();
  6264.  
  6265.  
  6266. /** CLASS CODES */
  6267. // jumpscare code warn
  6268. let tmpList = [];
  6269.  
  6270. // LOADING:
  6271. let UTILS = new Utils();
  6272. let items = new Items();
  6273. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6274. let store = new Store();
  6275. let hats = store.hats;
  6276. let accessories = store.accessories;
  6277. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6278. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6279. let textManager = new Textmanager();
  6280.  
  6281. let traps = new Traps(UTILS, items);
  6282. let instaC = new Instakill();
  6283. let autoBuy = new Autobuy([40, 6, 7, 22, 53, 15, 31], [11, 21, 18, 13]);
  6284. let autoUpgrade = new Autoupgrade();
  6285.  
  6286. let lastDeath;
  6287. let minimapData;
  6288. let mapMarker = {};
  6289. let mapPings = [];
  6290. let tmpPing;
  6291.  
  6292. let breakTrackers = [];
  6293.  
  6294. function sendChat(message) {
  6295. packet("6", message.slice(0, 30));
  6296. }
  6297.  
  6298. let runAtNextTick = [];
  6299.  
  6300. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6301. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6302. let projOffset = config.playerScale * 2;
  6303. let projXY = {
  6304. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6305. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6306. };
  6307. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6308. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6309. })[0];
  6310. if (nearPlayer) {
  6311. if (indx == 1) {
  6312. nearPlayer.shooting[53] = 1;
  6313. } else {
  6314. nearPlayer.shootIndex = weaponIndx;
  6315. nearPlayer.shooting[1] = 1;
  6316. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6317. }
  6318. }
  6319. }
  6320. let projectileCount = 0;
  6321.  
  6322. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6323. if (!tmpObj.isTeam(player)) {
  6324. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6325. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6326. tmpObj.bowThreat[weaponIndex]++;
  6327. if (index == 5) {
  6328. projectileCount++;
  6329. }
  6330. setTimeout(() => {
  6331. tmpObj.bowThreat[weaponIndex]--;
  6332. if (index == 5) {
  6333. projectileCount--;
  6334. }
  6335. }, range / speed);
  6336. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6337. place(1, tmpObj.aim2);
  6338. my.anti0Tick = 4;
  6339. if (!my.antiSync) {
  6340. antiSyncHealing(4);
  6341. }
  6342. } else {
  6343. if (projectileCount >= 2) {
  6344. place(1, tmpObj.aim2);
  6345. healer();
  6346. sendChat("Sync for gays");
  6347. buyEquip(22, 0);
  6348. buyEquip(13, 1);
  6349. my.anti0Tick = 4;
  6350. if (!my.antiSync) {
  6351. antiSyncHealing(4);
  6352. }
  6353. } else {
  6354. if (projectileCount === 1) { // anti reverse or anti 1 tick with reaper
  6355. buyEquip(6, 0);
  6356. buyEquip(13, 1);
  6357. }
  6358. /*} else {
  6359. if (projectileCount >= 2) { // anti sync ╨╗╨╕╨╜╨╕╤Π ╨╛╨▒╨╛╤Α╨╛╨╜╤Μ N1
  6360. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  6361. player.chat.message = "pSyD";
  6362. healer();
  6363. buyEquip(6, 0);
  6364. }
  6365. }*/
  6366. }
  6367. }
  6368. }
  6369. }
  6370. }
  6371.  
  6372. // SHOW ITEM INFO:
  6373. function showItemInfo(item, isWeapon, isStoreItem) {
  6374. if (player && item) {
  6375. UTILS.removeAllChildren(itemInfoHolder);
  6376. itemInfoHolder.classList.add("visible");
  6377. UTILS.generateElement({
  6378. id: "itemInfoName",
  6379. text: UTILS.capitalizeFirst(item.name),
  6380. parent: itemInfoHolder
  6381. });
  6382. UTILS.generateElement({
  6383. id: "itemInfoDesc",
  6384. text: item.desc,
  6385. parent: itemInfoHolder
  6386. });
  6387. if (isStoreItem) {
  6388.  
  6389. } else if (isWeapon) {
  6390. UTILS.generateElement({
  6391. class: "itemInfoReq",
  6392. text: !item.type ? "primary" : "secondary",
  6393. parent: itemInfoHolder
  6394. });
  6395. } else {
  6396. for (let i = 0; i < item.req.length; i += 2) {
  6397. UTILS.generateElement({
  6398. class: "itemInfoReq",
  6399. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6400. parent: itemInfoHolder
  6401. });
  6402. }
  6403. if (item.group.limit) {
  6404. UTILS.generateElement({
  6405. class: "itemInfoLmt",
  6406. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6407. parent: itemInfoHolder
  6408. });
  6409. }
  6410. }
  6411. } else {
  6412. itemInfoHolder.classList.remove("visible");
  6413. }
  6414. }
  6415.  
  6416. // RESIZE:
  6417. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6418.  
  6419. function resize() {
  6420. screenWidth = window.innerWidth;
  6421. screenHeight = window.innerHeight;
  6422. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6423. gameCanvas.width = screenWidth * pixelDensity;
  6424. gameCanvas.height = screenHeight * pixelDensity;
  6425. gameCanvas.style.width = screenWidth + "px";
  6426. gameCanvas.style.height = screenHeight + "px";
  6427. mainContext.setTransform(
  6428. scaleFillNative, 0,
  6429. 0, scaleFillNative,
  6430. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  6431. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  6432. );
  6433. }
  6434. resize();
  6435.  
  6436. // MOUSE INPUT:
  6437. var usingTouch;
  6438. const mals = document.getElementById('touch-controls-fullscreen');
  6439. mals.style.display = 'block';
  6440. mals.addEventListener("mousemove", gameInput, false);
  6441.  
  6442. function gameInput(e) {
  6443. mouseX = e.clientX;
  6444. mouseY = e.clientY;
  6445. }
  6446. let clicks = {
  6447. left: false,
  6448. middle: false,
  6449. right: false,
  6450. };
  6451. mals.addEventListener("mousedown", mouseDown, false);
  6452.  
  6453. function mouseDown(e) {
  6454. if (attackState != 1) {
  6455. attackState = 1;
  6456. if (e.button == 0) {
  6457. clicks.left = true;
  6458. } else if (e.button == 1 || e.key === 'b') {
  6459. clicks.middle = true;
  6460. } else if (e.button == 2) {
  6461. clicks.right = true;
  6462. }
  6463. }
  6464. }
  6465. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6466.  
  6467. function mouseUp(e) {
  6468. if (attackState != 0) {
  6469. attackState = 0;
  6470. if (e.button == 0) {
  6471. clicks.left = false;
  6472. } else if (e.button == 1 || e.key === 'b') {
  6473. clicks.middle = false;
  6474. } else if (e.button == 2) {
  6475. clicks.right = false;
  6476. }
  6477. }
  6478. }
  6479. mals.addEventListener("wheel", wheel, false);
  6480.  
  6481. let wbe = 1;
  6482. function wheel(e) {
  6483. if (e.deltaY < 0) {
  6484. wbe -= 0.05;
  6485. maxScreenWidth = config.maxScreenWidth * wbe;
  6486. maxScreenHeight = config.maxScreenHeight * wbe;
  6487. resize()
  6488. } else {
  6489. wbe += 0.05;
  6490. maxScreenWidth = config.maxScreenWidth * wbe;
  6491. maxScreenHeight = config.maxScreenHeight * wbe;
  6492. resize()
  6493. }
  6494. }
  6495.  
  6496.  
  6497. // INPUT UTILS:
  6498. function getMoveDir() {
  6499. let dx = 0;
  6500. let dy = 0;
  6501. for (let key in moveKeys) {
  6502. let tmpDir = moveKeys[key];
  6503. dx += !!keys[key] * tmpDir[0];
  6504. dy += !!keys[key] * tmpDir[1];
  6505. }
  6506. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6507. }
  6508.  
  6509. function getSafeDir() {
  6510. if (!player)
  6511. return 0;
  6512. if (!player.lockDir) {
  6513. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6514. }
  6515. return lastDir || 0;
  6516. }
  6517. let plusDir = 0;
  6518. let lastSpin = Date.now();
  6519. let spinDir = 0;
  6520. function getAttackDir(debug) {
  6521. if (debug) {
  6522. if (!player)
  6523. return "0";
  6524. 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))
  6525. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6526. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6527. lastDir = getSafeDir();
  6528. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  6529. lastDir = traps.aim;
  6530. else if (!player.lockDir) {
  6531. if (os.noDir) return "undefined";
  6532. lastDir = getSafeDir();
  6533. }
  6534. return lastDir;
  6535. } else {
  6536. if (!player)
  6537. return 0;
  6538. 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))
  6539. lastDir = getEl("weaponGrind").checked ? getVisualDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getVisualDir();
  6540. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6541. lastDir = getVisualDir();
  6542. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  6543. lastDir = traps.aim;
  6544. else if (spinner == true) {
  6545. spinDir += (Math.PI * 2) / (9 / 4);
  6546. return spinDir;
  6547. } else {
  6548. if (!player.lockDir) {
  6549. if(useWasd) {
  6550. lastDir = getVisualDir();
  6551. } else {
  6552. lastDir = getSafeDir();
  6553. }
  6554. }
  6555. }
  6556. return lastDir || 0;
  6557. }
  6558. }
  6559.  
  6560. function getVisualDir() {
  6561. if (!player) return 0;
  6562. let dx = mouseX - (screenWidth / 2);
  6563. let dy = mouseY - (screenHeight / 2);
  6564. let direction = Math.atan2(dy, dx);
  6565. return direction;
  6566. }
  6567. // Random Spin:
  6568. function spin() {// PPL code
  6569. let random = [2, 3, 4, 5, 7, 3, 23, -1];
  6570. setTickout(() => {
  6571. spinner = true;
  6572. setTickout(() => {
  6573. spinner = false;
  6574. }, random[Math.floor(Math.random() * (random.length + 1))]);
  6575. }, 1);
  6576. }
  6577.  
  6578. // KEYS:
  6579. function keysActive() {
  6580. return (allianceMenu.style.display != "block" &&
  6581. chatHolder.style.display != "block" &&
  6582. !menuCBFocus);
  6583. }
  6584.  
  6585. function toggleMenuChat() {
  6586. if (menuChatDiv.style.display != "none") {
  6587. // chatHolder.style.display = "none";
  6588. // if (menuChatBox.value != "") {
  6589. //commands[command.slice(1)]
  6590. let cmd = function(command) {
  6591. return {
  6592. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6593. fv: commands[command.slice(1).split(" ")[0]]
  6594. }
  6595. }
  6596. let command = cmd(menuChatBox.value);
  6597. if (command.found) {
  6598. if (typeof command.fv.action === "function") {
  6599. command.fv.action(menuChatBox.value);
  6600. }
  6601. } else {
  6602. sendChat(menuChatBox.value);
  6603. }
  6604. menuChatBox.value = "";
  6605. menuChatBox.blur();
  6606. } else {
  6607. if (menuCBFocus) {
  6608. menuChatBox.blur();
  6609. } else {
  6610. menuChatBox.focus();
  6611. }
  6612. }
  6613. }
  6614.  
  6615. function keyDown(event) {
  6616. let keyNum = event.which || event.keyCode || 0;
  6617. if (player && player.alive && keysActive()) {
  6618. if (!keys[keyNum]) {
  6619. keys[keyNum] = 1;
  6620. macro[event.key] = 1;
  6621. if (keyNum == 27) {
  6622. openMenu = !openMenu;
  6623. $("#menuDiv").toggle();
  6624. $("#menuChatDiv").toggle();
  6625. } else if (keyNum == 69) {
  6626. sendAutoGather();
  6627. } else if (keyNum == 67) {
  6628. updateMapMarker();
  6629. } else if (player.weapons[keyNum - 49] != undefined) {
  6630. player.weaponCode = player.weapons[keyNum - 49];
  6631. } else if (moveKeys[keyNum]) {
  6632. sendMoveDir();
  6633. } else if (event.key == "m") {
  6634. mills.placeSpawnPads = !mills.placeSpawnPads;
  6635. } else if (event.key === "r") {
  6636. packet("6", "Insta/On");
  6637. } else if (event.key === "t") {
  6638. packet("6", "WhY OnEtIcK/On");
  6639. } else if (event.key === "x") {
  6640. var musketCheckbox = document.getElementById("musketSync");
  6641. if (musketCheckbox && musketCheckbox.checked) {
  6642. packet("6", "!Sync");
  6643. }
  6644. } else if (event.key == 'b') {
  6645. clicks.middle = true;
  6646. } else if (event.key == "z") {
  6647. mills.place = !mills.place;
  6648. } else if (event.key == "Z") {
  6649. typeof window.debug == "function" && window.debug();
  6650. } else if (keyNum == 32) {
  6651. packet("d", 1, getSafeDir(), 1);
  6652. packet("d", 0, getSafeDir(), 1);
  6653. } else if (event.key == ",") {
  6654. io.send("6", 'syncon')
  6655. project.send(JSON.stringify(["tezt", "ratio"]));
  6656. // botSkts.push([botPlayer]);
  6657. for(let i = 0; i < botz.length; i++) {
  6658. // if(botz[i][0]) {
  6659. botz[i][0].zync(near);
  6660. console.log(botz[i][0])
  6661. }
  6662. // project.send("tezt");
  6663. // botSkts.forEach((bot) => {
  6664. // bot.zync();
  6665. // })
  6666. // io.send("S", 1)
  6667. }
  6668. }
  6669. }
  6670. }
  6671. // let yy = canvaz.height/2;
  6672.  
  6673. // let mouze = {
  6674. // x: xx - mouzeX,
  6675. // y: yy - mouzeY
  6676. // }
  6677.  
  6678. // let ingamecoorformodabow = {
  6679. // x: player.x + mouze.x,
  6680. // y: player.x + mouze.x
  6681. // }
  6682.  
  6683. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6684.  
  6685. function keyUp(event) {
  6686. if (player && player.alive) {
  6687. let keyNum = event.which || event.keyCode || 0;
  6688. if (keyNum == 13) {
  6689. toggleMenuChat();
  6690. } else if (keysActive()) {
  6691. if (keys[keyNum]) {
  6692. keys[keyNum] = 0;
  6693. macro[event.key] = 0;
  6694. if (moveKeys[keyNum]) {
  6695. sendMoveDir();
  6696. } else if (event.key == ",") {
  6697. player.sync = false;
  6698. } else if (event.key == 'b') {
  6699. clicks.middle = false;
  6700. }
  6701. }
  6702. }
  6703. }
  6704. }
  6705.  
  6706.  
  6707. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6708.  
  6709. function sendMoveDir() {
  6710. if(found) {
  6711. packet("a", undefined, 1);
  6712. } else {
  6713. let newMoveDir = getMoveDir();
  6714. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6715. if (!my.autoPush && !found) {
  6716. packet("a", newMoveDir, 1);
  6717. }
  6718. lastMoveDir = newMoveDir;
  6719. }
  6720. }
  6721. }
  6722.  
  6723. // BUTTON EVENTS:
  6724. function bindEvents() {}
  6725. bindEvents();
  6726.  
  6727. // ITEM COUNT DISPLAY:
  6728. let isItemSetted = [];
  6729.  
  6730. function updateItemCountDisplay(index = undefined) {
  6731. for (let i = 3; i < items.list.length; ++i) {
  6732. let id = items.list[i].group.id;
  6733. let tmpI = items.weapons.length + i;
  6734. if (!isItemSetted[tmpI]) {
  6735. isItemSetted[tmpI] = document.createElement("div");
  6736. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6737. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6738. isItemSetted[tmpI].style = `
  6739. display: block;
  6740. position: absolute;
  6741. padding-left: 5px;
  6742. font-size: 2em;
  6743. color: #fff;
  6744. `;
  6745. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6746. } else {
  6747. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6748. }
  6749. }
  6750. }
  6751.  
  6752. // AUTOPUSH:
  6753. var retrappable = false;
  6754. function autoPush() {
  6755. retrappable = true;
  6756. 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) {
  6757. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6758. })[0];
  6759. if (nearTrap) {
  6760. 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) {
  6761. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6762. })[0];
  6763. if (spike) {
  6764. let pos = {
  6765. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6766. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6767. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6768. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6769. };
  6770. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6771. let tmpScale = tmp.getScale();
  6772. 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)) {
  6773. return true;
  6774. }
  6775. });
  6776. if (finds) {
  6777. if (my.autoPush) {
  6778. my.autoPush = false;
  6779. packet("a", lastMoveDir || undefined, 1);
  6780. }
  6781. } else {
  6782. my.autoPush = true;
  6783. my.pushData = {
  6784. x: spike.x,
  6785. y: spike.y,
  6786. x2: pos.x2,
  6787. y2: pos.y2
  6788. };
  6789. let scale = (player.scale / 10);
  6790. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6791. packet("a", near.aim2, 1);
  6792. } else {
  6793. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6794. }
  6795. }
  6796. } else {
  6797. if (my.autoPush) {
  6798. my.autoPush = false;
  6799. packet("a", lastMoveDir || undefined, 1);
  6800. }
  6801. }
  6802. } else {
  6803. if (my.autoPush) {
  6804. my.autoPush = false;
  6805. packet("a", lastMoveDir || undefined, 1);
  6806. }
  6807. }
  6808. }
  6809.  
  6810. // ADD DEAD PLAYER:
  6811. function addDeadPlayer(tmpObj) {
  6812. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6813. }
  6814.  
  6815. /** APPLY SOCKET CODES */
  6816.  
  6817. // SET INIT DATA:
  6818. function setInitData(data) {
  6819. alliances = data.teams;
  6820. }
  6821.  
  6822. // SETUP GAME:
  6823. function setupGame(yourSID) {
  6824. keys = {};
  6825. macro = {};
  6826. playerSID = yourSID;
  6827. attackState = 0;
  6828. inGame = true;
  6829. packet("d", 0, getAttackDir(), 1);
  6830. my.ageInsta = true;
  6831. if (firstSetup) {
  6832. firstSetup = false;
  6833. gameObjects.length = 0;
  6834. liztobj.length = 0;
  6835. }
  6836. }
  6837.  
  6838. // ADD NEW PLAYER:
  6839. function addPlayer(data, isYou) {
  6840. let tmpPlayer = findPlayerByID(data[0]);
  6841. if (!tmpPlayer) {
  6842. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6843. objectManager, players, ais, items, hats, accessories);
  6844. players.push(tmpPlayer);
  6845. if (data[1] != playerSID) {
  6846. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6847. }
  6848. } else {
  6849. if (data[1] != playerSID) {
  6850. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6851. }
  6852. }
  6853. tmpPlayer.spawn(isYou ? true : null);
  6854. tmpPlayer.visible = false;
  6855. tmpPlayer.oldPos = {
  6856. x2: undefined,
  6857. y2: undefined
  6858. };
  6859. tmpPlayer.x2 = undefined;
  6860. tmpPlayer.y2 = undefined;
  6861. tmpPlayer.x3 = undefined;
  6862. tmpPlayer.y3 = undefined;
  6863. tmpPlayer.setData(data);
  6864. if (isYou) {
  6865. if (!player) {
  6866. window.prepareUI(tmpPlayer);
  6867. }
  6868. player = tmpPlayer;
  6869. camX = player.x;
  6870. camY = player.y;
  6871. my.lastDir = 0;
  6872. updateItems();
  6873. updateAge();
  6874. updateItemCountDisplay();
  6875. if (player.skins[7]) {
  6876. my.reSync = true;
  6877. }
  6878. }
  6879. }
  6880.  
  6881. // REMOVE PLAYER:
  6882. function removePlayer(id) {
  6883. for (let i = 0; i < players.length; i++) {
  6884. if (players[i].id == id) {
  6885. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6886. players.splice(i, 1);
  6887. break;
  6888. }
  6889. }
  6890. }
  6891. // dune mod dmgpot
  6892. function sortWeaponVariant(id) {
  6893. switch (id) {
  6894. case 0:
  6895. return 1
  6896. break;
  6897. case 1:
  6898. return 1.1
  6899. break;
  6900. case 2:
  6901. return 1.18
  6902. break;
  6903. case 3:
  6904. return 1.18
  6905. break;
  6906. default:
  6907. return 1
  6908. break;
  6909. }
  6910. }
  6911. function sortSecondaryAmmoDamage(weapon) {
  6912. switch (weapon) {
  6913. case 10:
  6914. return 12
  6915. break
  6916. case 15:
  6917. return 50
  6918. break;
  6919. case 9:
  6920. return 25
  6921. break;
  6922. case 12:
  6923. return 35
  6924. break;
  6925. case 13:
  6926. return 30
  6927. break;
  6928. default:
  6929. return 0
  6930. }
  6931. }
  6932. function potdmg(tmpObj, t) {
  6933. let d = t - tmpObj.health;
  6934. if (d >= 100) {
  6935. } else {
  6936. if (player == tmpObj) {
  6937. if (tmpObj.skinIndex == 7 && (Math.abs(d) == 5 || (tmpObj.latestTail == 13 && Math.abs(d) == 2))) {
  6938. tmpObj.bullTick = game.tick
  6939. if (my.reSync) {
  6940. my.reSync = false;
  6941. }
  6942. }
  6943. dmgpotwowwowow();
  6944. }
  6945. }
  6946. }
  6947. function dmgpotwowwowow() {
  6948. let potential = DmgPotWorkfrfrfr();
  6949. if (nears.length) {
  6950. addMenuChText("Dev", `Dmg potential: ${potential}`, "red");
  6951. // notif(`Dmg potential: ${potential}`)
  6952. if (Math.round(player.health - potential <= 0)) {
  6953. if ((player.health - (potential * player.skinIndex == 6 ? 0.75 : 1) >= 0)) {
  6954. game.tickBase(() => {
  6955. heal();
  6956. }, 2);
  6957. } else {
  6958. if(player.shameCount < 5) {
  6959. heal();
  6960. } else {
  6961. game.tickBase(() => {
  6962. heal();
  6963. }, 2);
  6964. }
  6965. }
  6966. } else {
  6967. game.tickBase(() => {
  6968. heal();
  6969. }, 2);
  6970. }
  6971. } else {
  6972. game.tickBase(() => {
  6973. heal();
  6974. }, 2);
  6975. }
  6976. }
  6977. function heal() {
  6978. for (let i = 0; i < Math.ceil((100 - player.health) / items.list[player.items[0]].healing); i++) {
  6979. place(0, getAttackDir());
  6980. }
  6981. }
  6982. function DmgPotWorkfrfrfr() {
  6983. let predictedDamage = 0;
  6984. let weapon1Dmg, weapon2Dmg;
  6985. let weapon1Reload, weapon2Reload;
  6986. for (let i = 0; i < nears.length; i++) {
  6987. let singleIndividual = nears[i];
  6988. weapon1Dmg = items.weapons[singleIndividual.weapons[0]].dmg * sortWeaponVariant(singleIndividual.weaponVariant);
  6989. weapon2Dmg = singleIndividual.weapons[1] == 10 ? items.weapons[singleIndividual.weapons[1]].dmg : items.weapons[singleIndividual.weapons[1]].Pdmg;
  6990. weapon1Reload = singleIndividual.reloads[singleIndividual.weapons[0]] == 0;
  6991. weapon2Reload = singleIndividual.reloads[singleIndividual.weapons[1]] == 0;
  6992. if (singleIndividual.primaryIndex !== undefined) {
  6993. predictedDamage += weapon1Reload ? weapon1Dmg * 1.5 : 0;
  6994. } else {
  6995. predictedDamage += 45;
  6996. }
  6997. if (singleIndividual.secondaryIndex !== undefined) {
  6998. predictedDamage += weapon2Reload ? weapon2Dmg : 0;
  6999. } else {
  7000. predictedDamage += 50;
  7001. }
  7002. predictedDamage += singleIndividual.reloads[53] == 0 ? 25 : 0;
  7003. }
  7004. }
  7005. // UPDATE HEALTH:
  7006. function updateHealth(sid, value) {
  7007. let tmpObj = findPlayerBySID(sid);
  7008. let secondary = {
  7009. weapon: this.secondaryIndex,
  7010. variant: this.secondaryVariant
  7011. };
  7012. if (!tmpObj) return;
  7013.  
  7014. let oldHealth = tmpObj.health;
  7015. tmpObj.oldHealth = oldHealth;
  7016. tmpObj.health = value;
  7017. tmpObj.judgeShame();
  7018. if (oldHealth > value) {
  7019. tmpObj.timeDamaged = Date.now();
  7020. if (tmpObj === near) {
  7021. let damage = oldHealth - value;
  7022. let shame = tmpObj.shameCount
  7023. if (tmpObj.skinIndex === 7 && (damage === 5 || (tmpObj.latestTail === 13 && damage === 2))) {
  7024. tmpObj.bullTick = game.tick;
  7025. }
  7026. }
  7027. tmpObj.damaged = oldHealth - value;
  7028. advHeal.push([sid, value, tmpObj.damaged]);
  7029. } else if (tmpObj !== player) {
  7030. tmpObj.maxShameCount = Math.max(tmpObj.maxShameCount, tmpObj.shameCount);
  7031. }
  7032. if (nears.length && tmpObj.shameCount <= 5 && nears.some(items => [9, 12, 13, 15].includes(secondary.weapon))) {
  7033. if (near.reloads[near.secondaryIndex] == 0) {
  7034. my.empAnti = true;
  7035. my.soldierAnti = false;
  7036. } else {
  7037. my.soldierAnti = true
  7038. my.empAnti = false;
  7039. }
  7040. }
  7041. }
  7042. // KILL PLAYER:
  7043. function killPlayer() {
  7044. inGame = false;
  7045. lastDeath = {
  7046. x: player.x,
  7047. y: player.y,
  7048. };
  7049. }
  7050.  
  7051. // UPDATE PLAYER ITEM VALUES:
  7052. function updateItemCounts(index, value) {
  7053. if (player) {
  7054. player.itemCounts[index] = value;
  7055. updateItemCountDisplay(index);
  7056. }
  7057. }
  7058.  
  7059. // UPDATE AGE:
  7060. function updateAge(xp, mxp, age) {
  7061. if (xp != undefined)
  7062. player.XP = xp;
  7063. if (mxp != undefined)
  7064. player.maxXP = mxp;
  7065. if (age != undefined)
  7066. player.age = age;
  7067. }
  7068.  
  7069. // UPDATE UPGRADES:
  7070. function updateUpgrades(points, age) {
  7071. player.upgradePoints = points;
  7072. player.upgrAge = age;
  7073. if (points > 0) {
  7074. tmpList.length = 0;
  7075. UTILS.removeAllChildren(upgradeHolder);
  7076. for (let i = 0; i < items.weapons.length; ++i) {
  7077. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  7078. let e = UTILS.generateElement({
  7079. id: "upgradeItem" + i,
  7080. class: "actionBarItem",
  7081. onmouseout: function() {
  7082. showItemInfo();
  7083. },
  7084. parent: upgradeHolder
  7085. });
  7086. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  7087. tmpList.push(i);
  7088. }
  7089. }
  7090. for (let i = 0; i < items.list.length; ++i) {
  7091. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  7092. let tmpI = (items.weapons.length + i);
  7093. let e = UTILS.generateElement({
  7094. id: "upgradeItem" + tmpI,
  7095. class: "actionBarItem",
  7096. onmouseout: function() {
  7097. showItemInfo();
  7098. },
  7099. parent: upgradeHolder
  7100. });
  7101. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  7102. tmpList.push(tmpI);
  7103. }
  7104. }
  7105. for (let i = 0; i < tmpList.length; i++) {
  7106. (function(i) {
  7107. let tmpItem = getEl('upgradeItem' + i);
  7108. // tmpItem.onmouseover = function() {
  7109. // if (items.weapons[i]) {
  7110. // showItemInfo(items.weapons[i], true);
  7111. // } else {
  7112. // showItemInfo(items.list[i - items.weapons.length]);
  7113. // }
  7114. // };
  7115. tmpItem.onclick = UTILS.checkTrusted(function() {
  7116. packet("H", i);
  7117. });
  7118. UTILS.hookTouchEvents(tmpItem);
  7119. })(tmpList[i]);
  7120. }
  7121. if (tmpList.length) {
  7122. upgradeHolder.style.display = "block";
  7123. upgradeCounter.style.display = "block";
  7124. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  7125. } else {
  7126. upgradeHolder.style.display = "none";
  7127. upgradeCounter.style.display = "none";
  7128. showItemInfo();
  7129. }
  7130. } else {
  7131. upgradeHolder.style.display = "none";
  7132. upgradeCounter.style.display = "none";
  7133. showItemInfo();
  7134. }
  7135. }
  7136. function toR(e) {
  7137. var n = (e * Math.PI / 180) % (2 * Math.PI);
  7138. return n > Math.PI ? Math.PI - n : n
  7139. }
  7140. function toD(e) {
  7141. var n = (e / Math.PI * 360) % 360;
  7142. return n >= 360 ? n - 360 : n;
  7143. }
  7144. // KILL OBJECT:
  7145. function killObject(sid) {
  7146. let findObj = findObjectBySid(sid);
  7147. objectManager.disableBySid(sid);
  7148. if (player) {
  7149. for (let i = 0; i < breakObjects.length; i++) {
  7150. if (breakObjects[i].sid == sid) {
  7151. breakObjects.splice(i, 1);
  7152. break;
  7153. }
  7154. }
  7155. if (!player.canSee(findObj)) {
  7156. breakTrackers.push({
  7157. x: findObj.x,
  7158. y: findObj.y
  7159. });
  7160. }
  7161. if (breakTrackers.length > 8) {
  7162. breakTrackers.shift();
  7163. }
  7164. traps.replacer(findObj);
  7165. }
  7166. }
  7167.  
  7168. // KILL ALL OBJECTS BY A PLAYER:
  7169. function killObjects(sid) {
  7170. if (player) objectManager.removeAllItems(sid);
  7171. }
  7172. function fgdo(a, b) {
  7173. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  7174. }
  7175. function setTickout(doo, timeout) {
  7176. if (!ticks.manage[ticks.tick + timeout]) {
  7177. ticks.manage[ticks.tick + timeout] = [doo];
  7178. } else {
  7179. ticks.manage[ticks.tick + timeout].push(doo);
  7180. }
  7181. }
  7182.  
  7183. function caf(e, t) {
  7184. try {
  7185. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7186. } catch (e) {
  7187. return 0;
  7188. }
  7189. }
  7190.  
  7191. let found = false;
  7192. let autoQ = false;
  7193.  
  7194. let autos = {
  7195. insta: {
  7196. todo: false,
  7197. wait: false,
  7198. count: 4,
  7199. shame: 5
  7200. },
  7201. bull: false,
  7202. antibull: 0,
  7203. reloaded: false,
  7204. stopspin: true
  7205. }
  7206.  
  7207. // UPDATE PLAYER DATA:
  7208. let autoZoom = true;
  7209. let FT = 0;
  7210. let AutoOneTicked = false;
  7211. let lppc = 0, ntpp = false, lppc2 = 0, ntpp2 = false;
  7212. let boostspike = false;
  7213. let doAutoQ = false;
  7214. let spinner = false;
  7215.  
  7216. let nEy;
  7217. let placeableSpikes = [];
  7218. let placeableTraps = [];
  7219. let placeableSpikesPREDICTS = [];
  7220. let DmgPotStuff = {
  7221. predictedDamage: 0
  7222. };
  7223.  
  7224. function mgPotWorkfrfrfr() {
  7225. DmgPotStuff.predictedDamage = 0;
  7226. for (let i = 0; i < nears.length; i++) {
  7227. let singleIndividual = nears[i];
  7228. if (singleIndividual.primaryIndex != undefined) {
  7229. if (singleIndividual.reloads[singleIndividual.weapons[0]] == 0) {
  7230. DmgPotStuff.predictedDamage += items.weapons[singleIndividual.weapons[0]].dmg * sortWeaponVariant(singleIndividual.weaponVariant) * 1.5
  7231. }
  7232. } else {
  7233. DmgPotStuff.predictedDamage += 45
  7234. }
  7235. if (singleIndividual.secondaryIndex != undefined) {
  7236. if (singleIndividual.reloads[singleIndividual.weapons[1]] == 0) {
  7237. if (items.weapons[singleIndividual.weapons[1]] == 10) {
  7238. DmgPotStuff.predictedDamage += items.weapons[singleIndividual.weapons[1]].dmg * sortWeaponVariant(singleIndividual.weaponVariant)
  7239. } else {
  7240. DmgPotStuff.predictedDamage += items.weapons[singleIndividual.weapons[1]].Pdmg
  7241. }
  7242. }
  7243. } else {
  7244. DmgPotStuff.predictedDamage += 50
  7245. }
  7246. if (singleIndividual.reloads[53] == 0) {
  7247. DmgPotStuff.predictedDamage += 25
  7248. }
  7249. }
  7250. return DmgPotStuff.predictedDamage
  7251. }
  7252. const getDistance = (x1, y1, x2, y2) => {
  7253. let dx = x2 - x1;
  7254. let dy = y2 - y1;
  7255. return Math.sqrt(dx * dx + dy * dy);
  7256. };
  7257. const getPotentialDamage = (build, user) => {
  7258. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7259. const weap = user.weapons[weapIndex];
  7260. if (player.reloads[weap]) return 0;
  7261. const weapon = items.weapons[weap];
  7262. const inDist = getDistance(build.x, build.y, user.x2, user.y2) <= build.getScale() + weapon.range;
  7263. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7264. };
  7265.  
  7266. const findPlacementAngle = (player, itemId, build) => {
  7267. if (!build) return null;
  7268. const MAX_ANGLE = 2 * Math.PI;
  7269. const ANGLE_STEP = Math.PI / 360;
  7270. const item = items.list[player.items[itemId]];
  7271. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7272. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7273.  
  7274. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7275. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7276. for (let angle of angles) {
  7277. let tmpX = player.x + tmpS * Math.cos(angle);
  7278. let tmpY = player.y + tmpS * Math.sin(angle);
  7279. if (objectManager.customCheckItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player, build, gameObjects, UTILS, config)) {
  7280. return angle;
  7281. }
  7282. }
  7283. }
  7284. return null;
  7285. };
  7286. const AutoReplace = () => {
  7287. const replaceable = [];
  7288. const playerX = player.x;
  7289. const playerY = player.y;
  7290. const gameObjectCount = gameObjects.length;
  7291. for (let i = 0; i < gameObjectCount; i++) {
  7292. const build = gameObjects[i];
  7293. if (build.isItem && build.active && build.health > 0) {
  7294. let potentialDamage = players.reduce((total, p) => total + getPotentialDamage(build, p), 0);
  7295. if (build.health <= potentialDamage) {
  7296. replaceable.push(build);
  7297. }
  7298. }
  7299. }
  7300. const replace = () => {
  7301. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && getDistance(tmp.x, tmp.y, playerX, playerY) <= tmp.getScale() + 5);
  7302. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && getDistance(tmp.x, tmp.y, playerX, playerY) < 87 && !nearTrap.length);
  7303. const buildId = spike ? 4 : 2;
  7304.  
  7305. replaceable.forEach(build => {
  7306. let angle = findPlacementAngle(player, buildId, build);
  7307. if (angle !== null) {
  7308. place(buildId, angle);
  7309. }
  7310. });
  7311. };
  7312. const replaceDelay = game.tickSpeed - (window.pingTime || 0) + (game.tickSpeed < 110 ? 5 : 0);
  7313. if (near && near.dist2 <= 360) {
  7314. setTimeout(replace, replaceDelay);
  7315. }
  7316. };
  7317. // let movementPrediction = {
  7318. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7319. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7320. // }
  7321.  
  7322. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  7323.  
  7324. // potentialzpiketick.forEach((obj) => {
  7325. // if(cdf(obj, player) <= 200) {
  7326. // packet('a', undefined);
  7327. // }
  7328. // })
  7329.  
  7330. // let newPos = {
  7331. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  7332. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  7333. // }
  7334.  
  7335. function getAngleDifference(angle1, angle2) {
  7336. // Normalize the angles to be between 0 and 2╧Α
  7337. angle1 = angle1 % (2 * Math.PI);
  7338. angle2 = angle2 % (2 * Math.PI);
  7339.  
  7340. // Calculate the absolute difference between the angles
  7341. let diff = Math.abs(angle1 - angle2);
  7342.  
  7343. // Adjust the difference to be between 0 and ╧Α
  7344. if (diff > Math.PI) {
  7345. diff = (2 * Math.PI) - diff;
  7346. }
  7347.  
  7348. return diff;
  7349. }
  7350.  
  7351. // function smartMove(oneTickMove) {
  7352. // let dir = player.moveDir;
  7353.  
  7354. // let found = false
  7355. // 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))
  7356. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  7357.  
  7358. // let newPos = {
  7359. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  7360. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  7361. // }
  7362.  
  7363. // for (let i = 0; i < spikes.length; i++) {
  7364. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  7365. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  7366. // }
  7367. // }
  7368.  
  7369.  
  7370.  
  7371.  
  7372.  
  7373. // if (found != false && !traps.inTrap) {
  7374. // packet("a", undefined);
  7375. // } else {
  7376. // packet("a", dir);
  7377. // }
  7378. // player.oldPos.x2 = player.x2;
  7379. // player.oldPos.y2 = player.y2;
  7380. // }
  7381. // function detectEnemySpikeCollisions(tmpObj) {
  7382. // 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));
  7383. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  7384. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  7385. // let enemy = {
  7386. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  7387. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  7388. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7389. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7390. // }
  7391. // let found = false;
  7392. // for (let i = 0; i < spikes.length; i++) {
  7393. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  7394. // found = true;
  7395. // }
  7396. // }
  7397.  
  7398. // // player.oldPos.x2 = tmpObj.x2;
  7399. // // player.oldPos.y2 = tmpObj.y2;
  7400. // }
  7401. function updatePlayers(data) {
  7402. game.tick++;
  7403. enemy = [];
  7404. nears = [];
  7405. near = [];
  7406. game.tickSpeed = performance.now() - game.lastTick;
  7407. game.lastTick = performance.now();
  7408. players.forEach((tmp) => {
  7409. tmp.forcePos = !tmp.visible;
  7410. tmp.visible = false;
  7411. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  7412. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  7413. });
  7414. for (let i = 0; i < data.length;) {
  7415. tmpObj = findPlayerBySID(data[i]);
  7416. if (tmpObj) {
  7417. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7418. tmpObj.t2 = game.lastTick;
  7419. tmpObj.oldPos.x2 = tmpObj.x2;
  7420. tmpObj.oldPos.y2 = tmpObj.y2;
  7421. tmpObj.x1 = tmpObj.x;
  7422. tmpObj.y1 = tmpObj.y;
  7423. tmpObj.x2 = data[i + 1];
  7424. tmpObj.y2 = data[i + 2];
  7425. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7426. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7427. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7428. tmpObj.d2 = data[i + 3];
  7429. tmpObj.dt = 0;
  7430. tmpObj.buildIndex = data[i + 4];
  7431. tmpObj.weaponIndex = data[i + 5];
  7432. tmpObj.weaponVariant = data[i + 6];
  7433. tmpObj.team = data[i + 7];
  7434. tmpObj.isLeader = data[i + 8];
  7435. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7436. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7437. tmpObj.skinIndex = data[i + 9];
  7438. tmpObj.tailIndex = data[i + 10];
  7439. tmpObj.iconIndex = data[i + 11];
  7440. tmpObj.zIndex = data[i + 12];
  7441. tmpObj.visible = true;
  7442. tmpObj.update(game.tickSpeed);
  7443. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7444. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7445. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7446. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7447. tmpObj.damageThreat = 0;
  7448. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7449. tmpObj.addShameTimer();
  7450. }
  7451. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7452. tmpObj.shameTimer = 0;
  7453. tmpObj.shameCount = 0;
  7454. if (tmpObj == player) {
  7455. healer();
  7456. }
  7457. }
  7458.  
  7459. botSkts.forEach((bot) => {
  7460. bot.showName = 'YEAHHH'
  7461. })
  7462.  
  7463. for(let i = 0; i < players.length; i++) {
  7464. for(let aa = 0; aa < botSkts.length; aa++) {
  7465. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  7466.  
  7467. }
  7468. }
  7469.  
  7470. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  7471. autoQ = true;
  7472. healer();
  7473. } else {
  7474. if (autoQ) {
  7475. healer();
  7476. }
  7477. autoQ = false;
  7478. }
  7479.  
  7480.  
  7481. if (tmpObj == player) {
  7482. if (liztobj.length) {
  7483. liztobj.forEach((tmp) => {
  7484. tmp.onNear = false;
  7485. if (tmp.active) {
  7486. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7487. tmp.onNear = true;
  7488. }
  7489. if (tmp.isItem && tmp.owner) {
  7490. 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)) {
  7491. tmp.breakObj = true;
  7492. breakObjects.push({
  7493. x: tmp.x,
  7494. y: tmp.y,
  7495. sid: tmp.sid
  7496. });
  7497. }
  7498. }
  7499. }
  7500. });
  7501. 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) {
  7502. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7503. })[0];
  7504. if (nearTrap) {
  7505. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  7506. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7507. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  7508.  
  7509. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7510. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7511. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  7512. traps.inTrap = true;
  7513. traps.info = nearTrap;
  7514. } else {
  7515. traps.inTrap = false;
  7516. traps.info = {};
  7517. }
  7518. } else {
  7519. traps.inTrap = false;
  7520. }
  7521. }
  7522. if (tmpObj.weaponIndex < 9) {
  7523. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7524. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7525. } else if (tmpObj.weaponIndex > 8) {
  7526. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7527. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7528. }
  7529. }
  7530. i += 13;
  7531. }
  7532. if (textManager.stack.length) {
  7533. let stacks = [];
  7534. let notstacks = [];
  7535. let num = 0;
  7536. let num2 = 0;
  7537. let pos = {
  7538. x: null,
  7539. y: null
  7540. };
  7541. let pos2 = {
  7542. x: null,
  7543. y: null
  7544. }
  7545. textManager.stack.forEach((text, value, x, y) => {
  7546. if (text.value >= 0) {
  7547. if (num == 0) pos = {
  7548. x: text.x,
  7549. y: text.y
  7550. };
  7551. num += Math.abs(text.value);
  7552. } else {
  7553. if (num2 == 0) pos2 = {
  7554. x: text.x,
  7555. y: text.y
  7556. };
  7557. num2 += Math.abs(text.value);
  7558. }
  7559. });
  7560. let value;
  7561. let x;
  7562. let y;
  7563. if (num2 > 0) {
  7564. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  7565. }
  7566. if (num > 0) {
  7567. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  7568. }
  7569. textManager.stack = [];
  7570. }
  7571. if (runAtNextTick.length) {
  7572. runAtNextTick.forEach((tmp) => {
  7573. checkProjectileHolder(...tmp);
  7574. });
  7575. runAtNextTick = [];
  7576. }
  7577. for (let i = 0; i < data.length;) {
  7578. tmpObj = findPlayerBySID(data[i]);
  7579. if (tmpObj) {
  7580. if (!tmpObj.isTeam(player)) {
  7581. enemy.push(tmpObj);
  7582. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7583. nears.push(tmpObj);
  7584. }
  7585. }
  7586. tmpObj.manageReload();
  7587. if (tmpObj != player) {
  7588. tmpObj.addDamageThreat(player);
  7589. }
  7590. }
  7591. i += 13;
  7592. }
  7593. /*projectiles.forEach((proj) => {
  7594. tmpObj = proj;
  7595. if (tmpObj.active) {
  7596. tmpObj.tickUpdate(game.tickSpeed);
  7597. }
  7598. });*/
  7599. if (player && player.alive) {
  7600. // Spin for international.terrorist
  7601. if (getEl("spin").checked && !(clicks.middle || clicks.left || clicks.right) && !my.waitHit && !traps.inTrap) {
  7602. spinner = true;
  7603. } else {
  7604. spinner = false;
  7605. }
  7606.  
  7607. if (enemy.length) {
  7608. near = enemy.sort(function(tmp1, tmp2) {
  7609. return tmp1.dist2 - tmp2.dist2;
  7610. })[0];
  7611. } else {
  7612. // console.log("no enemy");
  7613. }
  7614. if (game.tickQueue[game.tick]) {
  7615. game.tickQueue[game.tick].forEach((action) => {
  7616. action();
  7617. });
  7618. game.tickQueue[game.tick] = null;
  7619. }
  7620. if (advHeal.length) {
  7621. advHeal.forEach((updHealth) => {
  7622. let sid = updHealth[0];
  7623. let value = updHealth[1];
  7624. let totalDamage = 100 - value
  7625. let damaged = updHealth[2];
  7626. tmpObj = findPlayerBySID(sid);
  7627. let bullTicked = false;
  7628. if (tmpObj && tmpObj.health <= 0) {
  7629. if (!tmpObj.death) {
  7630. tmpObj.death = true;
  7631. if (tmpObj != player) {
  7632. //addChatLog(tmpObj.name + " has died", "#db2727", "", "#db2727");
  7633. }
  7634. addDeadPlayer(tmpObj);
  7635. }
  7636. }
  7637. if (tmpObj == player) {
  7638. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7639. if (my.reSync) {
  7640. my.reSync = false;
  7641. tmpObj.setBullTick = true;
  7642. }
  7643. bullTicked = true;
  7644. }
  7645. if (inGame) {
  7646. let attackers = getAttacker(damaged);
  7647. let gearDmgs = [0.25, 0.45].map(
  7648. (val) =>
  7649. val * items.weapons[player.weapons[0]].dmg * soldierMult()
  7650. );
  7651. let includeSpikeDmgs = enemy.length
  7652. ? !bullTicked &&
  7653. (gearDmgs.includes(damaged) && near.skinIndex != 11)
  7654. : false;
  7655. let healTimeout = 140 - window.pingTime;
  7656. let dmg = 100 - player.health;
  7657. let slowHeal = function (timer, tickBase) {
  7658. if (!tickBase) {
  7659. setTimeout(() => {
  7660. healer();
  7661. }, timer);
  7662. } else {
  7663. game.tickBase(() => {
  7664. healer();
  7665. }, 2);
  7666. }
  7667. };
  7668. if (getEl("healingBeta").checked) {
  7669. if (enemy.length) {
  7670. if ([0, 7, 8].includes(near.primaryIndex)) {
  7671. if (damaged < 75) {
  7672. slowHeal(healTimeout);
  7673. } else {
  7674. healer();
  7675. }
  7676. }
  7677. if ([1, 2, 6].includes(near.primaryIndex)) {
  7678. if (
  7679. damaged >= 25 &&
  7680. player.damageThreat + dmg >= 95 &&
  7681. tmpObj.shameCount < 1
  7682. ) {
  7683. healer();
  7684. } else {
  7685. slowHeal(healTimeout);
  7686. }
  7687. }
  7688. if (near.primaryIndex == 3) {
  7689. if (near.secondaryIndex == 15) {
  7690. if (near.primaryVariant < 2) {
  7691. if (
  7692. damaged >= 35 &&
  7693. player.damageThreat + dmg >= 95 &&
  7694. tmpObj.shameCount < 1 &&
  7695. game.tick - player.antiTimer > 1
  7696. ) {
  7697. tmpObj.canEmpAnti = true;
  7698. tmpObj.antiTimer = game.tick;
  7699. healer();
  7700. } else {
  7701. slowHeal(healTimeout);
  7702. }
  7703. } else {
  7704. if (
  7705. damaged > 35 &&
  7706. player.damageThreat + dmg >= 95 &&
  7707. tmpObj.shameCount < 1 &&
  7708. game.tick - player.antiTimer > 1
  7709. ) {
  7710. tmpObj.canEmpAnti = true;
  7711. tmpObj.antiTimer = game.tick;
  7712. healer();
  7713. } else {
  7714. slowHeal(healTimeout);
  7715. }
  7716. }
  7717. } else {
  7718. if (
  7719. damaged >= 25 &&
  7720. player.damageThreat + dmg >= 95 &&
  7721. tmpObj.shameCount < 1
  7722. ) {
  7723. healer();
  7724. } else {
  7725. slowHeal(healTimeout);
  7726. }
  7727. }
  7728. }
  7729. if (near.primaryIndex == 4) {
  7730. if (near.primaryVariant >= 1) {
  7731. if (
  7732. damaged >= 10 &&
  7733. player.damageThreat + dmg >= 95 &&
  7734. tmpObj.shameCount < 1
  7735. ) {
  7736. healer();
  7737. } else {
  7738. slowHeal(healTimeout);
  7739. }
  7740. } else {
  7741. if (
  7742. damaged >= 35 &&
  7743. player.damageThreat + dmg >= 95 &&
  7744. tmpObj.shameCount < 1
  7745. ) {
  7746. healer();
  7747. } else {
  7748. slowHeal(healTimeout);
  7749. }
  7750. }
  7751. }
  7752. if ([undefined, 5].includes(near.primaryIndex)) {
  7753. if (near.secondaryIndex == 10) {
  7754. if (
  7755. dmg >= (includeSpikeDmgs ? 10 : 20) &&
  7756. tmpObj.damageThreat + dmg >= 80 &&
  7757. tmpObj.shameCount < 1
  7758. ) {
  7759. healer();
  7760. } else {
  7761. slowHeal(healTimeout);
  7762. }
  7763. } else if (
  7764. near.primaryVariant >= 2 ||
  7765. near.primaryVariant == undefined
  7766. ) {
  7767. if (
  7768. dmg >= (includeSpikeDmgs ? 15 : 20) &&
  7769. tmpObj.damageThreat + dmg >= 50 &&
  7770. tmpObj.shameCount < 1
  7771. ) {
  7772. healer();
  7773. } else {
  7774. slowHeal(healTimeout);
  7775. }
  7776. } else if ([undefined || 15].includes(near.secondaryIndex)) {
  7777. if (
  7778. damaged > (includeSpikeDmgs ? 8 : 20) &&
  7779. player.damageThreat >= 25 &&
  7780. game.tick - player.antiTimer > 1
  7781. ) {
  7782. if (tmpObj.shameCount < 1) {
  7783. healer();
  7784. } else {
  7785. slowHeal(healTimeout);
  7786. }
  7787. } else {
  7788. slowHeal(healTimeout);
  7789. }
  7790. } else if ([9, 12, 13].includes(near.secondaryIndex)) {
  7791. if (
  7792. dmg >= 25 &&
  7793. player.damageThreat + dmg >= 70 &&
  7794. tmpObj.shameCount < 1
  7795. ) {
  7796. healer();
  7797. } else {
  7798. slowHeal(healTimeout);
  7799. }
  7800. } else {
  7801. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  7802. healer();
  7803. } else {
  7804. slowHeal(healTimeout);
  7805. }
  7806. }
  7807. }
  7808. if (near.primaryIndex == 6) {
  7809. if (near.secondaryIndex == 15) {
  7810. if (
  7811. damaged >= 25 &&
  7812. tmpObj.damageThreat + dmg >= 95 &&
  7813. tmpObj.shameCount < 1
  7814. ) {
  7815. healer();
  7816. } else {
  7817. slowHeal(healTimeout);
  7818. }
  7819. } else {
  7820. if (damaged >= 70 && tmpObj.shameCount < 1) {
  7821. healer();
  7822. } else {
  7823. slowHeal(healTimeout);
  7824. }
  7825. }
  7826. }
  7827. if (
  7828. damaged >= 30 &&
  7829. near.reloads[near.secondaryIndex] == 0 &&
  7830. near.dist2 <= 150 &&
  7831. player.skinIndex == 11 &&
  7832. player.tailIndex == 21
  7833. )
  7834. instaC.canCounter = true;
  7835. } else {
  7836. if (damaged >= 70) {
  7837. healer();
  7838. } else {
  7839. slowHeal(healTimeout);
  7840. }
  7841. }
  7842. } else {
  7843. if (
  7844. damaged >= (includeSpikeDmgs ? 8 : 25) &&
  7845. dmg + player.damageThreat >= 80 &&
  7846. game.tick - player.antiTimer > 1
  7847. ) {
  7848. if (
  7849. tmpObj.reloads[53] == 0 &&
  7850. tmpObj.reloads[tmpObj.weapons[1]] == 0
  7851. ) {
  7852. tmpObj.canEmpAnti = true;
  7853. } else {
  7854. player.soldierAnti = true;
  7855. }
  7856. tmpObj.antiTimer = game.tick;
  7857. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  7858. if (tmpObj.shameCount < shame) {
  7859. healer();
  7860. } else {
  7861. if (
  7862. near.primaryIndex == 7 ||
  7863. (player.weapons[0] == 7 &&
  7864. (near.skinIndex == 11 || near.tailIndex == 21))
  7865. ) {
  7866. slowHeal(healTimeout);
  7867. } else {
  7868. slowHeal(healTimeout, 1);
  7869. }
  7870. }
  7871. } else {
  7872. if (
  7873. near.primaryIndex == 7 ||
  7874. (player.weapons[0] == 7 &&
  7875. (near.skinIndex == 11 || near.tailIndex == 21))
  7876. ) {
  7877. slowHeal(healTimeout);
  7878. } else {
  7879. slowHeal(healTimeout, 1);
  7880. }
  7881. }
  7882. if (
  7883. damaged >= 25 &&
  7884. near.dist2 <= 140 &&
  7885. player.skinIndex == 11 &&
  7886. player.tailIndex == 21
  7887. )
  7888. instaC.canCounter = true;
  7889. }
  7890. } else {
  7891. if (
  7892. !tmpObj.setPoisonTick &&
  7893. (tmpObj.damaged == 5 ||
  7894. (tmpObj.latestTail == 13 && tmpObj.damaged == 2))
  7895. ) {
  7896. tmpObj.setPoisonTick = true;
  7897. }
  7898. }
  7899. } else {
  7900. let [sid, value, damaged] = updHealth;
  7901. let totalDamage = 100 - value;
  7902. let tmpObj = findPlayerBySID(sid);
  7903. let bullTicked = false;
  7904.  
  7905. if (tmpObj == player) {
  7906. if (
  7907. tmpObj.skinIndex == 7 &&
  7908. (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))
  7909. ) {
  7910. if (my.reSync) {
  7911. my.reSync = false;
  7912. tmpObj.setBullTick = true;
  7913. bullTicked = true;
  7914. }
  7915. }
  7916. if (inGame) {
  7917. let attackers = getAttacker(damaged);
  7918. let gearDmgs = [0.25, 0.45].map(
  7919. (val) =>
  7920. val * items.weapons[player.weapons[0]].dmg * soldierMult()
  7921. );
  7922. let includeSpikeDmgs = enemy.length
  7923. ? !bullTicked &&
  7924. gearDmgs.includes(damaged) &&
  7925. near.skinIndex == 11
  7926. : false;
  7927. let healTimeout = 60;
  7928. let dmg = 100 - player.health;
  7929. let shameCountThreshold = [2, 5][
  7930. [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1
  7931. ];
  7932.  
  7933. let slowHeal = function (timer, tickBase) {
  7934. if (!tickBase) setTimeout(() => healer(), timer);
  7935. else game.tickBase(() => healer(), 2);
  7936. };
  7937.  
  7938. if (getEl("healingBeta").checked) {
  7939. let canHealFast = [0, 7, 8].includes(near.primaryIndex)
  7940. ? damaged < 75
  7941. : [1, 2, 6].includes(near.primaryIndex)
  7942. ? damaged >= 25 &&
  7943. player.damageThreat + dmg >= 95 &&
  7944. tmpObj.shameCount < 5
  7945. : [undefined, 5].includes(near.primaryIndex)
  7946. ? dmg >= (includeSpikeDmgs ? 15 : 20) &&
  7947. tmpObj.damageThreat + dmg >= 50 &&
  7948. tmpObj.shameCount < 6
  7949. : near.primaryIndex == 3 && near.secondaryIndex == 15
  7950. ? damaged >= 35 &&
  7951. player.damageThreat + dmg >= 95 &&
  7952. tmpObj.shameCount < 5 &&
  7953. game.tick - player.antiTimer > 1
  7954. : near.primaryIndex == 4
  7955. ? near.primaryVariant >= 1
  7956. ? damaged >= 10 &&
  7957. player.damageThreat + dmg >= 95 &&
  7958. tmpObj.shameCount < 4
  7959. : damaged >= 35 &&
  7960. player.damageThreat + dmg >= 95 &&
  7961. tmpObj.shameCount < 3
  7962. : near.primaryIndex == 6 && near.secondaryIndex == 15
  7963. ? damaged >= 25 &&
  7964. tmpObj.damageThreat + dmg >= 95 &&
  7965. tmpObj.shameCount < 4
  7966. : damaged >= 25 && player.damageThreat + dmg >= 95;
  7967.  
  7968. canHealFast ? healer() : slowHeal(healTimeout);
  7969. } else {
  7970. let canHealFast =
  7971. damaged >= (includeSpikeDmgs ? 8 : 25) &&
  7972. dmg + player.damageThreat >= 80 &&
  7973. game.tick - player.antiTimer > 1;
  7974.  
  7975. if (canHealFast) {
  7976. if (
  7977. tmpObj.reloads[53] == 0 &&
  7978. tmpObj.reloads[tmpObj.weapons[1]] == 0
  7979. )
  7980. tmpObj.canEmpAnti = true;
  7981. else player.soldierAnti = true;
  7982. tmpObj.antiTimer = game.tick;
  7983. if (tmpObj.shameCount < shameCountThreshold) healer();
  7984. else
  7985. slowHeal(
  7986. healTimeout,
  7987. near.primaryIndex == 7 ||
  7988. (player.weapons[0] == 7 &&
  7989. (near.skinIndex == 11 || near.tailIndex == 21))
  7990. ? 0
  7991. : 1
  7992. );
  7993. } else {
  7994. slowHeal(
  7995. healTimeout,
  7996. near.primaryIndex == 7 ||
  7997. (player.weapons[0] == 7 &&
  7998. (near.skinIndex == 11 || near.tailIndex == 21))
  7999. ? 0
  8000. : 1
  8001. );
  8002. }
  8003. }
  8004. } else {
  8005. if (
  8006. !tmpObj.setPoisonTick &&
  8007. (tmpObj.damaged == 5 ||
  8008. (tmpObj.latestTail == 13 && tmpObj.damaged == 2))
  8009. ) {
  8010. tmpObj.setPoisonTick = true;
  8011. }
  8012. }
  8013. }
  8014. }
  8015. });
  8016. advHeal = [];
  8017. }
  8018. players.forEach((tmp) => {
  8019. if (!tmp.visible && player != tmp) {
  8020. tmp.reloads = {
  8021. 0: 0,
  8022. 1: 0,
  8023. 2: 0,
  8024. 3: 0,
  8025. 4: 0,
  8026. 5: 0,
  8027. 6: 0,
  8028. 7: 0,
  8029. 8: 0,
  8030. 9: 0,
  8031. 10: 0,
  8032. 11: 0,
  8033. 12: 0,
  8034. 13: 0,
  8035. 14: 0,
  8036. 15: 0,
  8037. 53: 0,
  8038. };
  8039. }
  8040. if (tmp.setBullTick) {
  8041. tmp.bullTimer = 0;
  8042. }
  8043. if (tmp.setPoisonTick) {
  8044. tmp.poisonTimer = 0;
  8045. }
  8046. tmp.updateTimer();
  8047. });
  8048. if (inGame) {
  8049. if (enemy.length) {
  8050. function Hg(hat, acc){
  8051. buyEquip(hat, 0);
  8052. buyEquip(acc, 1);
  8053. }
  8054. function ch(e) {
  8055. io.send("6", e.slice(0, 30));
  8056. }
  8057. function ch2(text, waitCount = 3000) {
  8058. player.chat.message = text;
  8059. player.chat.count = waitCount;
  8060. }
  8061. function ch3(text, time = 500, color = "#fff") {
  8062. textManager.showText(player.x2, player.y2, 30, 0.15, time, text, color, 2);
  8063. }
  8064. // Dir:
  8065. function toDeg(a) {
  8066. return a / (Math.PI / 180)
  8067. }
  8068. // Angel:
  8069. function angleDist(angle1, angle2) {
  8070. if(angle1 < 0) angle1 += Math.PI*2;
  8071. if(angle2 < 0) angle2 += Math.PI*2;
  8072. return Math.abs(angle1 - angle2);
  8073. }
  8074. function fixAngle(a) {
  8075. return (360 + (a % 360)) % 360;
  8076. }
  8077. function calcAngle(xs, ys, xe, ye) {
  8078. return Math.atan2(ye - ys, xe - xs);
  8079. }
  8080. // Dist:
  8081. function getDistance(x1, y1, x2, y2) {
  8082. return Math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
  8083. }
  8084. // Synced:
  8085. let Synced = {
  8086. SyncShotPri: 0,
  8087. SyncShotSec: 0,
  8088. bultect: false,
  8089. }
  8090. function isAlly(sid){
  8091. _ = findPlayerBySID(sid)
  8092. if(!_){
  8093. return
  8094. }
  8095. if(player.sid == sid){
  8096. return true
  8097. }else if(_.team){
  8098. return _.team === player.team ? true : false
  8099. } else {
  8100. return false
  8101. }
  8102. }
  8103. function canSyncHit() {
  8104. let N = gameObjects;
  8105. let _ = findPlayerByID(near);
  8106. if(player.reloads[player.weapons[0]] != 1) return false;
  8107. if(near.dist2/1.56 > items.weapons[player.weapons[0]].range) return false;
  8108. let x = (_.velX || _.x2), y = (_.velY || _.y2);
  8109. let isEnemyTraped = false;
  8110. for(let i = 0; i < N.length; i++) {
  8111. if(N[i] && N[i].name == "pit trap" && N[i].active && (N[i].owner.sid == player.sid || isAlly(N[i].owner.sid)) && Math.hypot(N[i].y - _.y2, N[i].x - _.x2) < 70) {
  8112. isEnemyTraped = true;
  8113. }
  8114. if(N[i] && N[i].dmg && N[i].active && isEnemyTraped == false && (N[i].owner.sid == player.sid || isAlly(N[i].owner.sid))) {
  8115. if(Math.hypot(N[i].y - y, N[i].x - x) <= 35 + N[i].scale) {
  8116. return true;
  8117. }
  8118. }
  8119. }
  8120. if(_.health - (Math.round(items.weapons[player.weapons[0]].dmg * 1.5 * window.variantMulti(items.weapons[player.weapons[0]].variant) * (_.skinIndex == 6 ? .75 : 1))) <= 0) {
  8121. return true;
  8122. }
  8123. return false;
  8124. }
  8125. // Anti
  8126. if (true) {
  8127.  
  8128. let edetect = false;
  8129. players.forEach(_ => {
  8130. if (_ == player) return;
  8131. let angle = calcAngle(player.x, player.y, _.x, _.y);
  8132. if (near && near.primaryVariant >= 1 && near.primaryIndex === 5 && near.dist2 < 350 && angleDist(
  8133. (angle), toDeg(arguments[2])) < 50 && getDistance(_.x, _.y, arguments[0], arguments[1]) < 130) {
  8134. edetect = true;
  8135. }
  8136. });
  8137. if (edetect && arguments[3] === 1400 && arguments[4] === 3.6) {
  8138. ch("AOT detect");
  8139. Hg(6, 21);
  8140. setTimeout(() => {
  8141. edetect = false;
  8142. }, 600);
  8143. }
  8144. }
  8145. // Auto Sync:
  8146. if (true) {
  8147. // autoSync
  8148. if (getEl("autosyncsec").checked) {
  8149. if (Synced.SyncShotSec >= 1 && player.weapons[1] == 15) {
  8150. instaC.syncTry();
  8151. Synced.SyncShotSec = 0;
  8152. }
  8153. /*
  8154. if (Synced.SyncShotPri >= 1 && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && player.weapons[1] == 15) {
  8155. instaC.syncTry("insta", 5);
  8156. Synced.SyncShotPri = 0;
  8157. }
  8158. */
  8159. }
  8160. // autoHit:
  8161. if(getEl("autosyncHited").checked && canSyncHit() && !my.waitHit && near.dist2 <= 250 && !traps.inTrap) {
  8162. setTimeout(() => {
  8163. my.autoAim = true;
  8164. my.waitHit = true;
  8165. Hg(7, 18);
  8166. sendAutoGather();
  8167. // Add your custom logic or function calls here
  8168. setTimeout(() => {
  8169. my.autoAim = false;
  8170. my.waitHit = false;
  8171. sendAutoGather();
  8172. }, 1);
  8173. }, 1);
  8174. ch("sync :3");
  8175. }
  8176. // near bullTciked:
  8177. if((game.tick - near.bullTick) % 9 == 0 && near.skinIndex == 7) {
  8178. //Synced.bultect = true;
  8179. game.tickBase(() => {
  8180. //Synced.bultect = false;
  8181. }, 1)
  8182. }
  8183. }
  8184. // Anti Sync:
  8185. if (player.syncThreats >= 2 && getEl("antisync").checked && !my.antiSync) {
  8186. ch("sync detect test");
  8187. antiSyncHealing(3);
  8188. } else if (player.syncThreats >= 4 && !my.antiSync) {
  8189. ch("multibox stupid tactic");
  8190. antiSyncHealing(5);
  8191. }
  8192. // Anti Insta:
  8193. if (player.canEmpAnti) {
  8194. player.canEmpAnti = false;
  8195. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  8196. if (near.reloads[53] == 0) {
  8197. player.empAnti = true;
  8198. player.soldierAnti = false;
  8199. if (getEl("SmartEmpSoldierAnti").checked) {//anti insta
  8200. Hg(22, 21);
  8201. }
  8202. } else {
  8203. player.empAnti = false;
  8204. player.soldierAnti = true;
  8205. if (getEl("SmartEmpSoldierAnti").checked) {//anti insta
  8206. Hg(6, 21);
  8207. }
  8208. }
  8209. }
  8210. }
  8211. 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) {
  8212. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  8213. })[0];
  8214. if (prehit) {
  8215. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  8216. instaC.canSpikeTick = true;
  8217. instaC.syncHit = true;
  8218. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  8219. instaC.revTick = true;
  8220. }
  8221. }
  8222. }
  8223. 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) {
  8224. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  8225. })[0];
  8226. if (antiSpikeTick && !traps.inTrap) {
  8227. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  8228. my.anti0Tick = 1;
  8229. player.chat.count = 2000;
  8230. }
  8231. }
  8232. }
  8233. 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)) {
  8234. if (player.checkCanInsta(true) >= 220) {
  8235. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  8236. } else {
  8237. instaC.nobull = false;
  8238. }
  8239. instaC.can = true;
  8240. } else {
  8241. instaC.can = false;
  8242. }
  8243. macro.q && place(0, getAttackDir());
  8244. macro.f && place(4, getSafeDir());
  8245. macro.v && place(2, getSafeDir());
  8246. macro.y && place(5, getSafeDir());
  8247. macro.h && place(player.getItemType(22), getSafeDir());
  8248. macro.n && place(3, getSafeDir());
  8249. if (game.tick % 1 == 0) {
  8250. if (mills.place) {
  8251. let plcAng = 7.7;
  8252. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  8253. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  8254. }
  8255. } else {
  8256. if (mills.placeSpawnPads) {
  8257. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  8258. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  8259. }
  8260. }
  8261. }
  8262. }
  8263. if (instaC.can) {
  8264. instaC.changeType(getEl("instaType").value == "rev" || player.weapons[1] == 10 ? "rev" : getEl("backupNobull").checked ? "nobull" : "normal");
  8265. }
  8266. if (instaC.canCounter) {
  8267. instaC.canCounter = false;
  8268. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  8269. instaC.counterType();
  8270. }
  8271. }
  8272. if (instaC.canSpikeTick) {
  8273. instaC.canSpikeTick = false;
  8274. if (instaC.revTick) {
  8275. instaC.revTick = false;
  8276. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  8277. instaC.changeType("rev");
  8278. chch(null, "[RevSyncHit]", "yellow");
  8279. }
  8280. } else {
  8281. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  8282. instaC.spikeTickType();
  8283. if (instaC.syncHit) {
  8284. chch(null, "[SyncHit]", "yellow");
  8285. }
  8286. }
  8287. }
  8288. }
  8289. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  8290. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  8291. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  8292. }
  8293. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8294. sendAutoGather();
  8295. my.waitHit = 1;
  8296. game.tickBase(() => {
  8297. sendAutoGather();
  8298. my.waitHit = 0;
  8299. }, 1);
  8300. }
  8301. }
  8302. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  8303. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  8304. selectWeapon(player.weapons[0]);
  8305. }
  8306. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  8307. sendAutoGather();
  8308. my.waitHit = 1;
  8309. game.tickBase(() => {
  8310. sendAutoGather();
  8311. my.waitHit = 0;
  8312. }, 1);
  8313. }
  8314. }
  8315. if (getEl("avoidspike").checked) {
  8316. let dir = lastMoveDir;
  8317. let newPos = {
  8318. x: player.x2 + (player.x2 - tracker.lastPos.x) * 1.3 + (Math.cos(dir) * 50),
  8319. y: player.y2 + (player.y2 - tracker.lastPos.y) * 1.3 + (Math.sin(dir) * 50),
  8320. };
  8321. let found = false;
  8322. 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));
  8323. let spikes = buildings.filter(obj =>
  8324. ["spikes", "greater spikes", "spinning spikes", "poison spikes"].includes(obj.name) &&
  8325. fgdo(player, obj) < 250 &&
  8326. !obj.isTeamObject(player) &&
  8327. obj.active
  8328. );
  8329. for (let i = 0; i < spikes.length; i++) {
  8330. if (fgdo(spikes[i], newPos) < spikes[i].scale + player.scale + 5) {
  8331. found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x);
  8332. tracker.draw3.active = true;
  8333. tracker.draw3.x = spikes[i].x;
  8334. tracker.draw3.y = spikes[i].y;
  8335. tracker.draw3.scale = spikes[i].scale;
  8336. // Prevent movement towards the spike
  8337. dir = found;
  8338. }
  8339. }
  8340. if (found !== false && !traps.inTrap) {
  8341. io.send("e");
  8342. io.send("e");
  8343. io.send("e");
  8344. } else {
  8345. packet("a", dir, 1);
  8346. tracker.draw3.active = false;
  8347. }
  8348. } else {
  8349. packet("a", tracker.moveDir, 1);
  8350. packet("a", tracker.moveDir, 1);
  8351. }
  8352. tracker.lastPos.x = player.x2;
  8353. tracker.lastPos.y = player.y2;
  8354. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[1]].range + near.scale * 1.8) && !traps.inTrap) {
  8355. if (player.weaponIndex !== player.weapons[1] || player.buildIndex > -1) {
  8356. selectWeapon(player.weapons[1]);
  8357. }
  8358. if (player.reloads[player.weapons[1]] === 0 && !my.waitHit) {
  8359. sendAutoGather();
  8360. my.waitHit = 1;
  8361. game.tickBase(() => {
  8362. sendAutoGather();
  8363. my.waitHit = 0;
  8364. }, 1);
  8365. }
  8366. }
  8367.  
  8368. if (traps.inTrap) {
  8369. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  8370. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  8371. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  8372. }
  8373. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8374. sendAutoGather();
  8375. my.waitHit = 1;
  8376. game.tickBase(() => {
  8377. sendAutoGather();
  8378. my.waitHit = 0;
  8379. }, 1);
  8380. }
  8381. }
  8382. }
  8383. if (clicks.middle && !traps.inTrap) {
  8384. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  8385. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  8386. instaC.bowMovement();
  8387. } else {
  8388. instaC.rangeType();
  8389. }
  8390. }
  8391. }
  8392. if (macro.t && !traps.inTrap) {
  8393. 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))) {
  8394. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  8395. }
  8396. }
  8397. if (macro["."] && !traps.inTrap) {
  8398. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  8399. instaC.boostTickMovement();
  8400. }
  8401. }
  8402. 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)) {
  8403. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  8404. if (!my.reloaded) {
  8405. my.reloaded = true;
  8406. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  8407. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  8408. selectWeapon(player.weapons[fastSpeed]);
  8409. }
  8410. }
  8411. // if(useWasd) {
  8412. // if (!autos.stopspin) {
  8413. // setTimeout(()=>{
  8414. // autos.stopspin = true;
  8415. // }, 375);
  8416. // }
  8417. // }
  8418. } else {
  8419. my.reloaded = false;
  8420. if(useWasd) {
  8421. autos.stopspin = false;
  8422. }
  8423. if (player.reloads[player.weapons[0]] > 0) {
  8424. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  8425. selectWeapon(player.weapons[0]);
  8426. }
  8427. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  8428. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  8429. selectWeapon(player.weapons[1]);
  8430. }
  8431. if(useWasd) {
  8432. if (!autos.stopspin) {
  8433. setTimeout(()=>{
  8434. autos.stopspin = true;
  8435. }, 750);
  8436. }
  8437. }
  8438. }
  8439. }
  8440. }
  8441. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  8442. traps.autoPlace();
  8443. }
  8444. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  8445. packet("D", getAttackDir());
  8446. }
  8447. let hatChanger = function () {
  8448. if (my.anti0Tick > 0) {
  8449. buyEquip(6, 0);
  8450. } else {
  8451. if (clicks.left || clicks.right) {
  8452. if (((!enemy.length || near.dist2 >= 500) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8453. buyEquip(7, 0);
  8454.  
  8455. } else if (clicks.left) {
  8456. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 6 : player.soldierAnti ? 6 : getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : near.dist2 <= 195 ? getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6 : buyEquip(21, 1), 0);
  8457. } else if (clicks.right) {
  8458. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 6 : 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 : buyEquip(21, 1), 0);
  8459. }
  8460. } else if (traps.inTrap) {
  8461. if ((traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) && my.anti0Tick == 0) {
  8462. buyEquip(40, 0);
  8463.  
  8464. } else if (traps.inTrap) {
  8465. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  8466. buyEquip(6, 0);
  8467. buyEquip(16, 1)
  8468. } else {
  8469. if (((!enemy.length || near.dist2 >= 100) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8470. buyEquip(7, 0);
  8471. } else {
  8472. buyEquip((player.empAnti || near.dist2 > 500 || !enemy.length) ? 6 : 6, 0);
  8473. }
  8474. }
  8475. }
  8476. } else {
  8477. if (player.empAnti || player.soldierAnti) {
  8478. buyEquip(player.empAnti ? 6 : 6, 0);
  8479. } else {
  8480. if (((!enemy.length || near.dist2 >= 100) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8481. buyEquip(7, 0);
  8482. } else {
  8483. if (player.y2 >= config.mapScale / 5 - config.riverWidth / 5 && player.y2 <= config.mapScale / 5 + config.riverWidth / 5) {
  8484. if (!configs.alwaysFlipper) {
  8485. if (near.dist2 <= 195) {
  8486. buyEquip(getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6, 0);
  8487. } else {
  8488. biomeGear(1);
  8489. }
  8490. } else {
  8491. biomeGear(1);
  8492. }
  8493. } else if (near.dist2 <= 195) {
  8494. buyEquip(getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6, 0);
  8495. } else {
  8496. biomeGear(1);
  8497. }
  8498. }
  8499. }
  8500. }
  8501. }
  8502. }
  8503.  
  8504. let accChanger = function() {
  8505. if (clicks.left) {
  8506. // Left mouse button is clicked
  8507. buyEquip(21, 1);
  8508. } else if (clicks.right) {
  8509. buyEquip(21, 1)
  8510. // Right mouse button is clicked
  8511. // Do nothing for right mouse button click
  8512. } else if (traps.inTrap) {
  8513. // Neither left nor right mouse button is clicked
  8514. // Check if in a trap and buy equipment accordingly
  8515. buyEquip(21, 1);
  8516. } else if (near.dist2 < 300){
  8517. if (getEl("antiBullType").value == "noab") {
  8518. buyEquip(16, 1)
  8519. } else if (configs.alwaysFlipper && player.y2 >= config.mapScale / 5 - config.riverWidth / 5 && player.y2 <= config.mapScale / 5 + config.riverWidth / 5) {
  8520. buyEquip(16, 1)
  8521. } else {
  8522. buyEquip(21, 1);
  8523. }
  8524. } else {
  8525. buyEquip(11, 1);
  8526. }
  8527. };
  8528. //ANTI SHAME & ANTI INSTA
  8529. function autobulltickandantiinsta () {
  8530. if (my.reSync && player.bullTick && tmpObj.shameCount > 1) {
  8531. my.reSync = true;
  8532. buyEquip(7, 0);
  8533. buyEquip(6, 0);
  8534. } else if (tmpObj.shameCount < 1 && tmpObj.shameCount > 1) {
  8535. my.reSync = false;
  8536. buyEquip(6, 0);
  8537. }
  8538. }
  8539. if (near.weaponIndex > 1 && near.dist2 <= 150) {
  8540. buyEquip(6, 0);
  8541. }
  8542.  
  8543. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  8544. if (useWasd) {
  8545. wasdGears();
  8546. } else {
  8547. hatChanger();
  8548. accChanger();
  8549. }
  8550. }
  8551.  
  8552. //
  8553. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  8554. hatChanger();
  8555. accChanger();
  8556. }
  8557. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  8558. autoPush();
  8559. } else {
  8560. if (my.autoPush) {
  8561. my.autoPush = false;
  8562. packet("a", lastMoveDir || undefined, 1);
  8563. }
  8564. }
  8565. if (instaC.ticking) {
  8566. instaC.ticking = false;
  8567. }
  8568. if (instaC.syncHit) {
  8569. instaC.syncHit = false;
  8570. }
  8571. if (player.empAnti) {
  8572. player.empAnti = false;
  8573. }
  8574. if (player.soldierAnti) {
  8575. player.soldierAnti = false;
  8576. }
  8577. if (my.anti0Tick > 0) {
  8578. my.anti0Tick--
  8579. }
  8580. if (traps.replaced) {
  8581. traps.replaced = false;
  8582. }
  8583. if (traps.antiTrapped) {
  8584. traps.antiTrapped = false;
  8585. }
  8586. }
  8587. }
  8588. if (botSkts.length) {
  8589. botSkts.forEach((bots) => {
  8590. if (true) {
  8591. bots[0].showName = 'YEAHHH';
  8592. }
  8593. });
  8594. }
  8595. }
  8596. // UPDATE LEADERBOARD:
  8597. /* function updateLeaderboard(data) {
  8598. UTILS.removeAllChildren(leaderboardData);
  8599. var tmpC = 1;
  8600. for (var i = 0; i < data.length; i += 3) {
  8601. // console.log(data);
  8602. (function(i) {
  8603. UTILS.generateElement({
  8604. class: "leaderHolder",
  8605. parent: leaderboardData,
  8606. children: [
  8607. UTILS.generateElement({
  8608. class: "leaderboardItem",
  8609. style: data[i] == player.sid ? "color: rgba(); font-size: 18px;" : "color: rgba(); font-size: 18px; padding: 1px;", //"font-size: 18px;",
  8610. text: (data[i + 1] != "" ? data[i + 1] : "unknown") + " |"
  8611. }),
  8612. UTILS.generateElement({
  8613. class: "a", //class: "leaderScore",
  8614. style: data[i] == player.sid ? "color: rgba(255,255,255,1); font-size: 18px;" : "color: rgba(255,255,255,0.6); font-size: 18px; padding: 1px;",
  8615. text: ("έΑΟ " + UTILS.kFormat(data[i + 2]) || "έΑΟ 0")
  8616. })
  8617. ]
  8618. });
  8619. })(i);
  8620. tmpC++;
  8621. }
  8622. }*/
  8623. // UPDATE LEADERBOARD:
  8624. function updateLeaderboard(data) {
  8625. lastLeaderboardData = data;
  8626. return;
  8627. UTILS.removeAllChildren(leaderboardData);
  8628. let tmpC = 1;
  8629. for (let i = 0; i < data.length; i += 3) {
  8630. (function(i) {
  8631. UTILS.generateElement({
  8632. class: "leaderHolder",
  8633. parent: leaderboardData,
  8634. children: [
  8635. UTILS.generateElement({
  8636. class: "leaderboardItem",
  8637. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  8638. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  8639. }),
  8640. UTILS.generateElement({
  8641. class: "leaderScore",
  8642. text: UTILS.sFormat(data[i + 2]) || "0"
  8643. })
  8644. ]
  8645. });
  8646. })(i);
  8647. tmpC++;
  8648. }
  8649. }
  8650.  
  8651. // LOAD GAME OBJECT:
  8652. function loadGameObject(data) {
  8653. for (let i = 0; i < data.length;) {
  8654. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  8655. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  8656. sid: data[i + 7]
  8657. } : null));
  8658. // sid, x, y, dir, s, type, data, setSID, owner
  8659. /*let dist = UTILS.getDist({
  8660. x: data[i + 1],
  8661. y: data[i + 2]
  8662. }, player, 0, 2);
  8663. let aim = UTILS.getDirect({
  8664. x: data[i + 1],
  8665. y: data[i + 2]
  8666. }, player, 0, 2);
  8667. find = findObjectBySid(data[i]);
  8668. if (data[i + 6] == 15) {
  8669. if (find && !find.isTeamObject(player)) {
  8670. if (dist <= 100) {
  8671. traps.dist = dist;
  8672. traps.aim = aim;
  8673. traps.protect(aim);
  8674. }
  8675. }
  8676. }*/
  8677. i += 8;
  8678. }
  8679. }
  8680.  
  8681. // ADD AI:
  8682. function loadAI(data) {
  8683. for (let i = 0; i < ais.length; ++i) {
  8684. ais[i].forcePos = !ais[i].visible;
  8685. ais[i].visible = false;
  8686. }
  8687. if (data) {
  8688. let tmpTime = performance.now();
  8689. for (let i = 0; i < data.length;) {
  8690. tmpObj = findAIBySID(data[i]);
  8691. if (tmpObj) {
  8692. tmpObj.index = data[i + 1];
  8693. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  8694. tmpObj.t2 = tmpTime;
  8695. tmpObj.x1 = tmpObj.x;
  8696. tmpObj.y1 = tmpObj.y;
  8697. tmpObj.x2 = data[i + 2];
  8698. tmpObj.y2 = data[i + 3];
  8699. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  8700. tmpObj.d2 = data[i + 4];
  8701. tmpObj.health = data[i + 5];
  8702. tmpObj.dt = 0;
  8703. tmpObj.visible = true;
  8704. } else {
  8705. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  8706. tmpObj.x2 = tmpObj.x;
  8707. tmpObj.y2 = tmpObj.y;
  8708. tmpObj.d2 = tmpObj.dir;
  8709. tmpObj.health = data[i + 5];
  8710. if (!aiManager.aiTypes[data[i + 1]].name)
  8711. tmpObj.name = config.cowNames[data[i + 6]];
  8712. tmpObj.forcePos = true;
  8713. tmpObj.sid = data[i];
  8714. tmpObj.visible = true;
  8715. }
  8716. i += 7;
  8717. }
  8718. }
  8719. }
  8720.  
  8721. // ANIMATE AI:
  8722. function animateAI(sid) {
  8723. tmpObj = findAIBySID(sid);
  8724. if (tmpObj) tmpObj.startAnim();
  8725. }
  8726.  
  8727. // GATHER ANIMATION:
  8728. function gatherAnimation(sid, didHit, index) {
  8729. tmpObj = findPlayerBySID(sid);
  8730. if (tmpObj) {
  8731. tmpObj.startAnim(didHit, index);
  8732. tmpObj.gatherIndex = index;
  8733. tmpObj.gathering = 1;
  8734. if (didHit) {
  8735. let tmpObjects = objectManager.hitObj;
  8736. objectManager.hitObj = [];
  8737. game.tickBase(() => {
  8738. // refind
  8739. tmpObj = findPlayerBySID(sid);
  8740. 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);
  8741. tmpObjects.forEach((healthy) => {
  8742. healthy.health -= val;
  8743. });
  8744. }, 1);
  8745. }
  8746. }
  8747. }
  8748.  
  8749. // WIGGLE GAME OBJECT:
  8750. function wiggleGameObject(dir, sid) {
  8751. tmpObj = findObjectBySid(sid);
  8752. if (tmpObj) {
  8753. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  8754. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  8755. if (tmpObj.health) {
  8756. objectManager.hitObj.push(tmpObj);
  8757. }
  8758. }
  8759. }
  8760.  
  8761. // SHOOT TURRET:
  8762. function shootTurret(sid, dir) {
  8763. tmpObj = findObjectBySid(sid);
  8764. if (tmpObj) {
  8765. if (config.anotherVisual) {
  8766. tmpObj.lastDir = dir;
  8767. } else {
  8768. tmpObj.dir = dir;
  8769. }
  8770. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  8771. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  8772. }
  8773. }
  8774.  
  8775. // UPDATE PLAYER VALUE:
  8776. function updatePlayerValue(index, value, updateView) {
  8777. if (player) {
  8778. player[index] = value;
  8779. if (index == "points") {
  8780. if (configs.autoBuy) {
  8781. autoBuy.hat();
  8782. autoBuy.acc();
  8783. }
  8784. } else if (index == "kills") {
  8785. if (configs.killChat) {
  8786. io.send("6", "gg - StarClient autoGG")
  8787. setTimeout(() => {
  8788. io.send("6", "Old Starclient BaCk?")
  8789. setTimeout(() => {
  8790. io.send("6", "kills: "+value+"")
  8791. setTimeout(() => {
  8792. io.send("6", "Thats Crazy")
  8793. }, 1500);
  8794. }, 1500);
  8795. }, 1500);
  8796. }
  8797. }
  8798. }
  8799. }
  8800.  
  8801.  
  8802. function clearConsole() {
  8803. if (configs.fpsBoost) {
  8804. console.clear();
  8805. }
  8806. }
  8807.  
  8808. // Function to get a varying kill chat message
  8809. function getKillChatMessage(kills) {
  8810. // Calculate the base kill count
  8811. let baseKillCount = Math.floor(kills / 10) * 10;
  8812.  
  8813. if (kills <= 1) {
  8814. return "";
  8815. } else {
  8816. // Display additional information when the kill count crosses a multiple of 10
  8817. let additionalInfo = "x" + (Math.floor(kills / 10)); // Adjusted the calculation
  8818. return additionalInfo; // Return the additionalInfo
  8819. }
  8820. }
  8821.  
  8822. // ACTION BAR:
  8823. function updateItems(data, wpn) {
  8824. if (data) {
  8825. if (wpn) {
  8826. player.weapons = data;
  8827. player.primaryIndex = player.weapons[0];
  8828. player.secondaryIndex = player.weapons[1];
  8829. if (!instaC.isTrue) {
  8830. selectWeapon(player.weapons[0]);
  8831. }
  8832. } else {
  8833. player.items = data;
  8834. }
  8835. }
  8836.  
  8837. for (let i = 0; i < items.list.length; i++) {
  8838. let tmpI = items.weapons.length + i;
  8839. let actionBarItem = getEl("actionBarItem" + tmpI);
  8840. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8841. // Add shadow to the element
  8842. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8843. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8844.  
  8845. }
  8846.  
  8847. for (let i = 0; i < items.weapons.length; i++) {
  8848. let actionBarItem = getEl("actionBarItem" + i);
  8849. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8850. // Add shadow to the element
  8851. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8852. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8853. }
  8854.  
  8855. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8856. if (kms) {
  8857. getEl("actionBarItem3").style.display = "none";
  8858. getEl("actionBarItem4").style.display = "inline-block";
  8859. }
  8860. }
  8861.  
  8862. // ADD PROJECTILE:
  8863. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8864. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8865. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8866. }
  8867.  
  8868. // REMOVE PROJECTILE:
  8869. function remProjectile(sid, range) {
  8870. for (let i = 0; i < projectiles.length; ++i) {
  8871. if (projectiles[i].sid == sid) {
  8872. projectiles[i].range = range;
  8873. let tmpObjects = objectManager.hitObj;
  8874. objectManager.hitObj = [];
  8875. game.tickBase(() => {
  8876. let val = projectiles[i].dmg;
  8877. tmpObjects.forEach((healthy) => {
  8878. if (healthy.projDmg) {
  8879. healthy.health -= val;
  8880. }
  8881. });
  8882. }, 1);
  8883. }
  8884. }
  8885. }
  8886.  
  8887. // lol this useless,,, fr
  8888. let noob = false;
  8889. let serverReady = true;
  8890. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  8891. let wssws = isProd ? "wss" : "ws";
  8892. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  8893. let withSync = false;
  8894. project.binaryType = "arraybuffer";
  8895. project.onmessage = function(msg) {
  8896. let data = msg.data;
  8897. if (data == "isready") {
  8898. serverReady = true;
  8899. }
  8900. if (data == "fine") {
  8901. noob = false;
  8902. }
  8903.  
  8904. if (data == "tezt") {
  8905. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  8906. }
  8907. if (data == "yeswearesyncer") {
  8908. // let delay = Date.now() - wsDelay;
  8909. withSync = true;
  8910. if (player) {
  8911. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#ffffff");
  8912. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  8913. }
  8914. }
  8915. };
  8916.  
  8917. // SHOW ALLIANCE MENU:
  8918. function allianceNotification(sid, name) {
  8919. let findBotSID = findSID(bots, sid);
  8920. if (findBotSID) {}
  8921. }
  8922.  
  8923. function setPlayerTeam(team, isOwner) {
  8924. if (player) {
  8925. player.team = team;
  8926. player.isOwner = isOwner;
  8927. if (team == null)
  8928. alliancePlayers = [];
  8929. }
  8930. }
  8931.  
  8932. function setAlliancePlayers(data) {
  8933. alliancePlayers = data;
  8934. }
  8935.  
  8936. // STORE MENU:
  8937. function updateStoreItems(type, id, index) {
  8938. if (index) {
  8939. if (!type)
  8940. player.tails[id] = 1;
  8941. else {
  8942. player.latestTail = id;
  8943. }
  8944. } else {
  8945. if (!type)
  8946. player.skins[id] = 1,
  8947. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8948. else {
  8949. player.latestSkin = id;
  8950. }
  8951. }
  8952. }
  8953.  
  8954. // SEND MESSAGE:
  8955. function receiveChat(sid, message) {
  8956. let kawaii = false;
  8957. let tmpPlayer = findPlayerBySID(sid);
  8958. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  8959. tmpPlayer.chatMessage = message;
  8960. tmpPlayer.chatCountdown = config.chatCountdown;
  8961. var antikick = document.getElementById("antikick");
  8962. if (antikick && antikick.checked && message.includes('<img onerror="for(;;){}" src=>')) {
  8963. io.send("6", '<iframe src="//moomoo.io">');
  8964. }
  8965. var musketCheckbox = document.getElementById("musketSync");
  8966. if (musketCheckbox && musketCheckbox.checked && message === "!Sync") {
  8967. musketSync();
  8968. io.send("6", "!Sync");
  8969. }
  8970. if (message === 'insta em!' && player.reloads[player.weapons[0]] === 0 && player.reloads[player.weapons[1]] === 0) {
  8971. packet("6", "");
  8972. my.autoAim = true;
  8973. selectWeapon(player.weapons[0]);
  8974. buyEquip(7, 0);
  8975. sendAutoGather();
  8976. game.tickBase(() => {
  8977. selectWeapon(player.weapons[1]);
  8978. buyEquip(player.reloads[53] === 0 ? 53 : 6, 0);
  8979. game.tickBase(() => {
  8980. sendAutoGather();
  8981. my.autoAim = false;
  8982. }, 3);
  8983. }, 2);
  8984. }
  8985. }
  8986.  
  8987. // MINIMAP:
  8988. function updateMinimap(data) {
  8989. minimapData = data;
  8990. }
  8991.  
  8992. // SHOW ANIM TEXT:
  8993. function showText(x, y, value, type) {
  8994. if (config.anotherVisual) {
  8995. textManager.stack.push({
  8996. x: x,
  8997. y: y,
  8998. value: value
  8999. });
  9000. } else {
  9001. textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  9002. }
  9003. }
  9004.  
  9005. /** APPLY SOCKET CODES */
  9006.  
  9007. // BOT:
  9008. let bots = [];
  9009. let ranLocation = {
  9010. x: UTILS.randInt(35, 14365),
  9011. y: UTILS.randInt(35, 14365)
  9012. };
  9013. setInterval(() => {
  9014. ranLocation = {
  9015. x: UTILS.randInt(35, 14365),
  9016. y: UTILS.randInt(35, 14365)
  9017. };
  9018. }, 60000);
  9019. class Bot {
  9020. constructor(id, sid, hats, accessories) {
  9021. this.millPlace = true;
  9022. this.id = id;
  9023. this.sid = sid;
  9024. this.team = null;
  9025. this.skinIndex = 0;
  9026. this.tailIndex = 0;
  9027. this.hitTime = 0;
  9028. this.iconIndex = 0;
  9029. this.enemy = [];
  9030. this.near = [];
  9031. this.dist2 = 0;
  9032. this.aim2 = 0;
  9033. this.tick = 0;
  9034. this.itemCounts = {};
  9035. this.latestSkin = 0;
  9036. this.latestTail = 0;
  9037. this.points = 0;
  9038. this.tails = {};
  9039. for (let i = 0; i < accessories.length; ++i) {
  9040. if (accessories[i].price <= 0)
  9041. this.tails[accessories[i].id] = 1;
  9042. }
  9043. this.skins = {};
  9044. for (let i = 0; i < hats.length; ++i) {
  9045. if (hats[i].price <= 0)
  9046. this.skins[hats[i].id] = 1;
  9047. }
  9048. this.spawn = function(moofoll) {
  9049. this.upgraded = 0;
  9050. this.enemy = [];
  9051. this.near = [];
  9052. this.active = true;
  9053. this.alive = true;
  9054. this.lockMove = false;
  9055. this.lockDir = false;
  9056. this.minimapCounter = 0;
  9057. this.chatCountdown = 0;
  9058. this.shameCount = 0;
  9059. this.shameTimer = 0;
  9060. this.sentTo = {};
  9061. this.gathering = 0;
  9062. this.autoGather = 0;
  9063. this.animTime = 0;
  9064. this.animSpeed = 0;
  9065. this.mouseState = 0;
  9066. this.buildIndex = -1;
  9067. this.weaponIndex = 0;
  9068. this.dmgOverTime = {};
  9069. this.noMovTimer = 0;
  9070. this.maxXP = 300;
  9071. this.XP = 0;
  9072. this.age = 1;
  9073. this.kills = 0;
  9074. this.upgrAge = 2;
  9075. this.upgradePoints = 0;
  9076. this.x = 0;
  9077. this.y = 0;
  9078. this.zIndex = 0;
  9079. this.xVel = 0;
  9080. this.yVel = 0;
  9081. this.slowMult = 1;
  9082. this.dir = 0;
  9083. this.nDir = 0;
  9084. this.dirPlus = 0;
  9085. this.targetDir = 0;
  9086. this.targetAngle = 0;
  9087. this.maxHealth = 100;
  9088. this.health = this.maxHealth;
  9089. this.oldHealth = this.maxHealth;
  9090. this.scale = config.playerScale;
  9091. this.speed = config.playerSpeed;
  9092. this.resetMoveDir();
  9093. this.resetResources(moofoll);
  9094. this.items = [0, 3, 6, 10];
  9095. this.weapons = [0];
  9096. this.shootCount = 0;
  9097. this.weaponXP = [];
  9098. this.isBot = false;
  9099. this.reloads = {
  9100. 0: 0,
  9101. 1: 0,
  9102. 2: 0,
  9103. 3: 0,
  9104. 4: 0,
  9105. 5: 0,
  9106. 6: 0,
  9107. 7: 0,
  9108. 8: 0,
  9109. 9: 0,
  9110. 10: 0,
  9111. 11: 0,
  9112. 12: 0,
  9113. 13: 0,
  9114. 14: 0,
  9115. 15: 0,
  9116. 53: 0,
  9117. };
  9118. this.timeZinceZpawn = 0;
  9119. this.whyDie = "";
  9120. this.clearRadius = false;
  9121. this.circlee = 0;
  9122. };
  9123.  
  9124. // RESET MOVE DIR:
  9125. this.resetMoveDir = function() {
  9126. this.moveDir = undefined;
  9127. };
  9128.  
  9129. // RESET RESOURCES:
  9130. this.resetResources = function(moofoll) {
  9131. for (let i = 0; i < config.resourceTypes.length; ++i) {
  9132. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  9133. }
  9134. };
  9135.  
  9136. // SET DATA:
  9137. this.setData = function(data) {
  9138. this.id = data[0];
  9139. this.sid = data[1];
  9140. this.name = data[2];
  9141. this.x = data[3];
  9142. this.y = data[4];
  9143. this.dir = data[5];
  9144. this.health = data[6];
  9145. this.maxHealth = data[7];
  9146. this.scale = data[8];
  9147. this.skinColor = data[9];
  9148. };
  9149.  
  9150.  
  9151. // SHAME SYSTEM:
  9152. this.judgeShame = function() {
  9153. if (this.oldHealth < this.health) {
  9154. if (this.hitTime) {
  9155. let timeSinceHit = this.tick - this.hitTime;
  9156. this.hitTime = 0;
  9157. if (timeSinceHit < 2) {
  9158. this.lastshamecount = this.shameCount;
  9159. this.shameCount++;
  9160. } else {
  9161. this.lastshamecount = this.shameCount;
  9162. this.shameCount = Math.max(0, this.shameCount - 2);
  9163. }
  9164. }
  9165. } else if (this.oldHealth > this.health) {
  9166. this.hitTime = this.tick;
  9167. }
  9168. };
  9169.  
  9170. // UPDATE WEAPON RELOAD:
  9171. this.manageReloadaa = function() {
  9172. if (this.shooting[53]) {
  9173. this.shooting[53] = 0;
  9174. this.reloads[53] = (2500 - 1000/9);
  9175. } else {
  9176. if (this.reloads[53] > 0) {
  9177. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  9178. }
  9179. }
  9180. if (this.gathering || this.shooting[1]) {
  9181. if (this.gathering) {
  9182. this.gathering = 0;
  9183. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  9184. this.attacked = true;
  9185. }
  9186. if (this.shooting[1]) {
  9187. this.shooting[1] = 0;
  9188. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  9189. this.attacked = true;
  9190. }
  9191. } else {
  9192. this.attacked = false;
  9193. if (this.buildIndex < 0) {
  9194. if (this.reloads[this.weaponIndex] > 0) {
  9195. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  9196. }
  9197. }
  9198. }
  9199. };
  9200.  
  9201. this.closeSockets = function(websc) {
  9202. websc.close();
  9203. };
  9204.  
  9205. this.whyDieChat = function(websc, whydie) {
  9206. websc.sendWS("6", "why die XDDD " + whydie);
  9207. };
  9208. }
  9209. };
  9210.  
  9211. class BotObject {
  9212. constructor(sid) {
  9213. this.sid = sid;
  9214. // INIT:
  9215. this.init = function(x, y, dir, scale, type, data, owner) {
  9216. data = data || {};
  9217. this.active = true;
  9218. this.x = x;
  9219. this.y = y;
  9220. this.scale = scale;
  9221. this.owner = owner;
  9222. this.id = data.id;
  9223. this.dmg = data.dmg;
  9224. this.trap = data.trap;
  9225. this.teleport = data.teleport;
  9226. this.isItem = this.id != undefined;
  9227. };
  9228.  
  9229. }
  9230. };
  9231. class BotObjManager {
  9232. constructor(botObj, fOS) {
  9233. // DISABLE OBJ:
  9234. this.disableObj = function(obj) {
  9235. obj.active = false;
  9236. if (config.anotherVisual) {} else {
  9237. obj.alive = false;
  9238. }
  9239. };
  9240.  
  9241. // ADD NEW:
  9242. let tmpObj;
  9243. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  9244. tmpObj = fOS(sid);
  9245. if (!tmpObj) {
  9246. tmpObj = botObj.find((tmp) => !tmp.active);
  9247. if (!tmpObj) {
  9248. tmpObj = new BotObject(sid);
  9249. botObj.push(tmpObj);
  9250. }
  9251. }
  9252. if (setSID) {
  9253. tmpObj.sid = sid;
  9254. }
  9255. tmpObj.init(x, y, dir, s, type, data, owner);
  9256. };
  9257.  
  9258. // DISABLE BY SID:
  9259. this.disableBySid = function(sid) {
  9260. let find = fOS(sid);
  9261. if (find) {
  9262. this.disableObj(find);
  9263. }
  9264. };
  9265.  
  9266. // REMOVE ALL FROM PLAYER:
  9267. this.removeAllItems = function(sid, server) {
  9268. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  9269. };
  9270. }
  9271. };
  9272.  
  9273. let botz = [];
  9274.  
  9275. function botSpawn(id) {
  9276. let bot;
  9277. console.log(WS);
  9278. let t = WS.url.split("wss://")[1].split("?")[0];
  9279. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  9280. let botPlayer = new Map();
  9281. botSkts.push([botPlayer]);
  9282. botz.push([bot]);
  9283. let botSID;
  9284. let botObj = [];
  9285. let nearObj = [];
  9286. let bD = {
  9287. x: 0,
  9288. y: 0,
  9289. inGame: false,
  9290. closeSocket: false,
  9291. whyDie: ""
  9292. };
  9293. let oldXY = {
  9294. x: 0,
  9295. y: 0,
  9296. };
  9297. let izauto = 0;
  9298. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  9299. bot.binaryType = "arraybuffer";
  9300. bot.first = true;
  9301. bot.sendWS = function(type) {
  9302. // EXTRACT DATA ARRAY:
  9303. let data = Array.prototype.slice.call(arguments, 1);
  9304. // SEND MESSAGE:
  9305. let binary = window.msgpack.encode([type, data]);
  9306. bot.send(binary);
  9307. };
  9308. bot.spawn = function() {
  9309. bot.sendWS("M", {
  9310. name: "Botss",
  9311. moofoll: 1,
  9312. skin: "__proto__"
  9313. });
  9314. };
  9315. bot.sendUpgrade = function(index) {
  9316. bot.sendWS("H", index);
  9317. };
  9318. bot.place = function(id, a) {
  9319. try {
  9320. let item = items.list[botPlayer.items[id]];
  9321. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  9322. bot.sendWS("G", botPlayer.items[id]);
  9323. bot.sendWS("d", 1, a);
  9324. bot.sendWS("G", botPlayer.weaponIndex, true);
  9325. }
  9326. } catch (e) {
  9327. }
  9328. };
  9329. bot.buye = function(id, index) {
  9330. let nID = 0;
  9331. if (botPlayer.alive && botPlayer.inGame) {
  9332. if (index == 0) {
  9333. if (botPlayer.skins[id]) {
  9334. if (botPlayer.latestSkin != id) {
  9335. bot.sendWS("c", 0, id, 0);
  9336. }
  9337. } else {
  9338. let find = findID(hats, id);
  9339. if (find) {
  9340. if (botPlayer.points >= find.price) {
  9341. bot.sendWS("c", 1, id, 0);
  9342. bot.sendWS("c", 0, id, 0);
  9343. } else {
  9344. if (botPlayer.latestSkin != nID) {
  9345. bot.sendWS("c", 0, nID, 0);
  9346. }
  9347. }
  9348. } else {
  9349. if (botPlayer.latestSkin != nID) {
  9350. bot.sendWS("c", 0, nID, 0);
  9351. }
  9352. }
  9353. }
  9354. } else if (index == 1) {
  9355. if (botPlayer.tails[id]) {
  9356. if (botPlayer.latestTail != id) {
  9357. bot.sendWS("c", 0, id, 1);
  9358. }
  9359. } else {
  9360. let find = findID(accessories, id);
  9361. if (find) {
  9362. if (botPlayer.points >= find.price) {
  9363. bot.sendWS("c", 1, id, 1);
  9364. bot.sendWS("c", 0, id, 1);
  9365. } else {
  9366. if (botPlayer.latestTail != 0) {
  9367. bot.sendWS("c", 0, 0, 1);
  9368. }
  9369. }
  9370. } else {
  9371. if (botPlayer.latestTail != 0) {
  9372. bot.sendWS("c", 0, 0, 1);
  9373. }
  9374. }
  9375. }
  9376. }
  9377. }
  9378. };
  9379. bot.fastGear = function () {
  9380. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  9381. bot.buye(31, 0);
  9382. } else {
  9383. if (botPlayer.moveDir == undefined) {
  9384. bot.buye(22, 0);
  9385. } else {
  9386. if (botPlayer.y2 <= config.snowBiomeTop) {
  9387. bot.buye(15, 0);
  9388. } else {
  9389. bot.buye(12, 0);
  9390. }
  9391. }
  9392. }
  9393. };
  9394. bot.selectWeapon = function(a) {
  9395. packet("G", a, 1);
  9396. }
  9397. function caf(e, t) {
  9398. try {
  9399. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  9400. } catch (e) {
  9401. return 0;
  9402. }
  9403. }
  9404. bot.heal = function() {
  9405. if (botPlayer.health < 100) {
  9406. bot.place(0, 0)
  9407. }
  9408. }
  9409. function cdf (e, t){
  9410. try {
  9411. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9412. } catch(e){
  9413. return Infinity;
  9414. }
  9415. }
  9416. let zoon = 'no';
  9417. bot.zync = function(a) {
  9418. if (!botPlayer.millPlace) {
  9419. zoon = 'yeah';
  9420. bot.place(5, caf(botPlayer, a));
  9421. let NextTickLocation = {
  9422. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9423. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9424. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9425. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9426. };
  9427.  
  9428. function calculateDistance(x1, y1, x2, y2) {
  9429. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  9430. return distance;
  9431. }
  9432. function dotherezt() {
  9433. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9434. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  9435. }
  9436.  
  9437. let aa = setInterval(() => {
  9438. bot.sendWS("G", botPlayer.weapons[1], true);
  9439. if (izauto == 0) {
  9440. bot.sendWS("K", 1);
  9441. izauto = 1;
  9442. }
  9443. setTimeout(() => {
  9444. bot.sendWS("G", botPlayer.weapons[0], true);
  9445. }, 2000);
  9446. bot.buye(53, 0);
  9447. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  9448. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  9449. } else {
  9450. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9451. zoon = 'no';
  9452. bot.sendWS("a", undefined);
  9453. dotherezt();
  9454. clearInterval(aa);
  9455. }
  9456. }, 150);
  9457.  
  9458. setTimeout(() => {
  9459. zoon = 'no';
  9460. clearInterval(aa);
  9461. }, 500);
  9462. }
  9463. };
  9464. bot.onmessage = function(message) {
  9465. let data = new Uint8Array(message.data);
  9466. let parsed = window.msgpack.decode(data);
  9467. let type = parsed[0];
  9468. data = parsed[1];
  9469. if (type == "io-init") {
  9470. bot.spawn();
  9471. }
  9472. if (type == "1") {
  9473. botSID = data[0];
  9474. console.log(botSID)
  9475. }
  9476. if (type == "D") {
  9477. if (data[1]) {
  9478. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  9479. botPlayer.setData(data[0]);
  9480. botPlayer.inGame = true;
  9481. botPlayer.alive = true;
  9482. botPlayer.x2 = undefined;
  9483. botPlayer.y2 = undefined;
  9484. botPlayer.spawn(1);
  9485. botPlayer.oldHealth = 100;
  9486. botPlayer.health = 100;
  9487. botPlayer.showName = 'YEAHHH';
  9488. oldXY = {
  9489. x: data[0][3],
  9490. y: data[0][4]
  9491. }
  9492. bD.inGame = true;
  9493. if (bot.first) {
  9494. bot.first = false;
  9495. bots.push(bD);
  9496. }
  9497. }
  9498. }
  9499. if (type == "P") {
  9500. bot.spawn();
  9501. botPlayer.inGame = false;
  9502. bD.inGame = false;
  9503. }
  9504. if (type == "a") {
  9505. let tmpData = data[0];
  9506. botPlayer.tick++;
  9507. botPlayer.enemy = [];
  9508. botPlayer.near = [];
  9509. bot.showName = 'YEAHHH';
  9510. nearObj = [];
  9511. for (let i = 0; i < tmpData.length;) {
  9512. if (tmpData[i] == botPlayer.sid) {
  9513. botPlayer.x2 = tmpData[i + 1];
  9514. botPlayer.y2 = tmpData[i + 2];
  9515. botPlayer.d2 = tmpData[i + 3];
  9516. botPlayer.buildIndex = tmpData[i + 4];
  9517. botPlayer.weaponIndex = tmpData[i + 5];
  9518. botPlayer.weaponVariant = tmpData[i + 6];
  9519. botPlayer.team = tmpData[i + 7];
  9520. botPlayer.isLeader = tmpData[i + 8];
  9521. botPlayer.skinIndex = tmpData[i + 9];
  9522. botPlayer.tailIndex = tmpData[i + 10];
  9523. botPlayer.iconIndex = tmpData[i + 11];
  9524. botPlayer.zIndex = tmpData[i + 12];
  9525. botPlayer.visible = true;
  9526. bD.x2 = botPlayer.x2;
  9527. bD.y2 = botPlayer.y2;
  9528. }
  9529. i += 13;
  9530. }
  9531.  
  9532. for (let i = 0; i < tmpData.length;) {
  9533. tmpObj = findPlayerBySID(tmpData[i]);
  9534. if (tmpObj) {
  9535. if (!tmpObj.isTeam(botPlayer)) {
  9536. enemy.push(tmpObj);
  9537. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  9538. nears.push(tmpObj);
  9539. }
  9540. }
  9541. }
  9542. i += 13;
  9543. }
  9544.  
  9545. if (enemy.length) {
  9546. //console.log(enemy)
  9547. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  9548. return tmp1.dist2 - tmp2.dist2;
  9549. })[0];
  9550. }
  9551.  
  9552. if (izauto == 1) {
  9553. bot.sendWS("K", 1);
  9554. izauto = 0;
  9555. }
  9556.  
  9557. if (bD.closeSocket) {
  9558. botPlayer.closeSockets(bot);
  9559. }
  9560. if (bD.whyDie != "") {
  9561. botPlayer.whyDieChat(bot, bD.whyDie);
  9562. bD.whyDie = "";
  9563. }
  9564. if (botPlayer.alive) {
  9565. if (player.team) {
  9566. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  9567. botPlayer.team && (bot.sendWS("N"));
  9568. bot.sendWS("b", player.team);
  9569. }
  9570. }
  9571.  
  9572. let item = items.list[botPlayer.items[3]];
  9573. let a = botPlayer.itemCounts[item.group.id]
  9574. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  9575. if (botPlayer.inGame) {
  9576. bot.sendWS("D", botPlayer.moveDir);
  9577. if (izauto == 0) {
  9578. bot.sendWS("K", 1);
  9579. izauto = 1;
  9580. }
  9581. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9582. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9583. bot.place(3, aim + 7.7);
  9584. bot.place(3, aim - 7.7);
  9585. bot.place(3, aim);
  9586. oldXY = {
  9587. x: botPlayer.x2,
  9588. y: botPlayer.y2
  9589. };
  9590. }
  9591.  
  9592. if (botPlayer.tick % 90 === 0) {
  9593. let rand = Math.random() * Math.PI * 2;
  9594. botPlayer.moveDir = rand;
  9595. bot.sendWS("a", botPlayer.moveDir);
  9596. }
  9597. }
  9598. bot.fastGear();
  9599. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  9600. botPlayer.millPlace = false;
  9601. // bot.sendWS("K", 1);
  9602. bot.fastGear();
  9603. } else {
  9604. if (botPlayer.inGame) {
  9605. if (botObj.length > 0) {
  9606. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  9607. if (getEl("mode").value == 'fuckemup') {
  9608. // if (getEl("mode").value == "clear") {
  9609. bot.selectWeapon(botPlayer.weapons[1]);
  9610. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  9611. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  9612. 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) {
  9613. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9614. })[0];
  9615. if (nearObj) {
  9616. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  9617. if ((gotoDist - isPassed) > 0) {
  9618. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9619. if (botPlayer.moveDir != undefined) {
  9620. botPlayer.moveDir = undefined;
  9621. bot.sendWS("a", botPlayer.moveDir);
  9622. bot.sendWS("D", botPlayer.nDir);
  9623. }
  9624. } else {
  9625. botPlayer.moveDir = gotoAim;
  9626. bot.sendWS("a", botPlayer.moveDir);
  9627. bot.sendWS("D", botPlayer.nDir);
  9628. }
  9629. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9630. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9631. bot.sendWS("D", botPlayer.nDir);
  9632. }
  9633. if (izauto == 0) {
  9634. bot.sendWS("K", 1);
  9635. izauto = 1;
  9636. }
  9637. bot.buye(40, 0);
  9638. } else {
  9639. botPlayer.moveDir = gotoAim;
  9640. bot.sendWS("a", botPlayer.moveDir);
  9641. bot.sendWS("D", botPlayer.nDir);
  9642. bot.fastGear();
  9643. }
  9644. } else {
  9645. botPlayer.moveDir = gotoAim;
  9646. bot.sendWS("a", botPlayer.moveDir);
  9647. bot.sendWS("D", botPlayer.nDir);
  9648. bot.fastGear();
  9649. }
  9650. }
  9651. }
  9652.  
  9653.  
  9654.  
  9655. if (botObj.length > 0) {
  9656. if (getEl("mode").value == 'flex') {
  9657. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  9658. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  9659. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  9660.  
  9661. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  9662.  
  9663. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  9664. if (dist > 22) // 22 is player speed without booster hat
  9665. return;
  9666. }
  9667. }
  9668.  
  9669.  
  9670. if (botObj.length > 0) {
  9671. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  9672. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9673. })[0];
  9674.  
  9675. if (nearObj) {
  9676. if (izauto == 0) {
  9677. bot.sendWS("K", 1);
  9678. izauto = 1;
  9679. }
  9680. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9681. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9682. bot.sendWS("D", botPlayer.nDir);
  9683. }
  9684. bot.buye(40, 0);
  9685. bot.buye(11, 1);
  9686. } else {
  9687. bot.fastGear();
  9688. bot.buye(11, 1);
  9689. }
  9690. bot.buye(11, 1);
  9691. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9692. // if (getEl("mode").value == "clear") {
  9693. bot.selectWeapon(botPlayer.weapons[1]);
  9694. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9695. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9696. 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) {
  9697. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9698. })[0];
  9699. if (nearObj) {
  9700. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9701. if ((gotoDist - isPassed) > 0) {
  9702. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9703. if (botPlayer.moveDir != undefined) {
  9704. botPlayer.moveDir = undefined;
  9705. bot.sendWS("a", botPlayer.moveDir);
  9706. bot.sendWS("D", botPlayer.nDir);
  9707. }
  9708. } else {
  9709. botPlayer.moveDir = gotoAim;
  9710. bot.sendWS("a", botPlayer.moveDir);
  9711. bot.sendWS("D", botPlayer.nDir);
  9712. }
  9713. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9714. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9715. bot.sendWS("D", botPlayer.nDir);
  9716. }
  9717. if (izauto == 0) {
  9718. bot.sendWS("K", 1);
  9719. izauto = 1;
  9720. }
  9721. bot.buye(40, 0);
  9722. bot.fastGear();
  9723. } else {
  9724. botPlayer.moveDir = gotoAim;
  9725. bot.sendWS("a", botPlayer.moveDir);
  9726. bot.sendWS("D", botPlayer.nDir);
  9727. bot.fastGear();
  9728. }
  9729. } else {
  9730. botPlayer.moveDir = gotoAim;
  9731. bot.sendWS("a", botPlayer.moveDir);
  9732. bot.sendWS("D", botPlayer.nDir);
  9733. bot.fastGear();
  9734. }
  9735. if (gotoDist > 300) {
  9736. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9737. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9738. bot.place(3, aim + 7.7);
  9739. bot.place(3, aim - 7.7);
  9740. bot.place(3, aim);
  9741. oldXY = {
  9742. x: botPlayer.x2,
  9743. y: botPlayer.y2
  9744. };
  9745. }
  9746. }
  9747. }
  9748. }
  9749.  
  9750. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9751. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  9752.  
  9753. if(!wdaawdwad.length) {
  9754. if(zoon == 'no')
  9755. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9756. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9757. }
  9758.  
  9759. if(wdaawdwad.length) {
  9760. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9761. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9762. 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) {
  9763. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9764. })[0];
  9765. if (nearObj) {
  9766. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9767. if ((gotoDist - isPassed) > 0) {
  9768. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9769. if (botPlayer.moveDir != undefined) {
  9770. botPlayer.moveDir = undefined;
  9771. bot.sendWS("a", botPlayer.moveDir);
  9772. bot.sendWS("D", botPlayer.nDir);
  9773. }
  9774. } else {
  9775. bot.sendWS("D", botPlayer.nDir);
  9776. }
  9777. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9778. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9779. bot.sendWS("D", botPlayer.nDir);
  9780. }
  9781. if (izauto == 0) {
  9782. bot.sendWS("K", 1);
  9783. izauto = 1;
  9784. }
  9785. bot.buye(40, 0);
  9786. bot.fastGear();
  9787. } else {
  9788. if(zoon == 'no')
  9789. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  9790. if(cdf(player, botPlayer) <= 110)
  9791. bot.sendWS("a", undefined);
  9792. else
  9793. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9794. }
  9795. } else {
  9796. if(wdaawdwad.length) {
  9797. if(zoon == 'no')
  9798. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  9799. if(cdf(player, botPlayer) <= 110)
  9800. bot.sendWS("a", undefined);
  9801. else
  9802. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9803. } else {
  9804. if(zoon == 'no')
  9805. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9806. if(cdf(player, botPlayer) <= 110)
  9807. bot.sendWS("a", undefined);
  9808. else
  9809. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9810. }
  9811. }
  9812. }
  9813. }
  9814. }
  9815. }
  9816. }
  9817. }
  9818. if (type == "H") {
  9819. let tmpData = data[0];
  9820. for (let i = 0; i < tmpData.length;) {
  9821. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9822. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9823. sid: tmpData[i + 7]
  9824. } : null));
  9825. i += 8;
  9826. }
  9827. }
  9828. if (type == "N") {
  9829. let index = data[0];
  9830. let value = data[1];
  9831. if (botPlayer) {
  9832. botPlayer[index] = value;
  9833. }
  9834. }
  9835. if (type == "O") {
  9836. if (data[0] == botPlayer.sid) {
  9837. botPlayer.oldHealth = botPlayer.health;
  9838. botPlayer.health = data[1];
  9839. botPlayer.judgeShame();
  9840. if (botPlayer.oldHealth > botPlayer.health) {
  9841. if (botPlayer.shameCount < 5) {
  9842. for (let i = 0; i < 2; i++) {
  9843. bot.place(0, botPlayer.nDir);
  9844. }
  9845.  
  9846. } else {
  9847. setTimeout(() => {
  9848. for (let i = 0; i < 2; i++) {
  9849. bot.place(0, botPlayer.nDir);
  9850. }
  9851. }, 95);
  9852. }
  9853. }
  9854. }
  9855. }
  9856. if (type == "Q") {
  9857. let sid = data[0];
  9858. botObjManager.disableBySid(sid);
  9859. }
  9860. if (type == "R") {
  9861. let sid = data[0];
  9862. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9863. }
  9864. if (type == "S") {
  9865. let index = data[0];
  9866. let value = data[1];
  9867. if (botPlayer) {
  9868. botPlayer.itemCounts[index] = value;
  9869. }
  9870. }
  9871. if (type == "U") {
  9872. if (data[0] > 0) {
  9873. if(getEl("setup").value == 'dm') {
  9874. if (botPlayer.upgraded == 0) {
  9875. bot.sendUpgrade(7);
  9876. } else if (botPlayer.upgraded == 1) {
  9877. bot.sendUpgrade(17);
  9878. } else if (botPlayer.upgraded == 2) {
  9879. bot.sendUpgrade(31);
  9880. } else if (botPlayer.upgraded == 3) {
  9881. bot.sendUpgrade(23);
  9882. } else if (botPlayer.upgraded == 4) {
  9883. bot.sendUpgrade(9);
  9884. } else if (botPlayer.upgraded == 5) {
  9885. bot.sendUpgrade(34);
  9886. } else if (botPlayer.upgraded == 6) {
  9887. bot.sendUpgrade(12);
  9888. } else if (botPlayer.upgraded == 7) {
  9889. bot.sendUpgrade(15);
  9890. }
  9891. } else if(getEl("setup").value == 'dr') {
  9892. if (botPlayer.upgraded == 0) {
  9893. bot.sendUpgrade(7);
  9894. } else if (botPlayer.upgraded == 1) {
  9895. bot.sendUpgrade(17);
  9896. } else if (botPlayer.upgraded == 2) {
  9897. bot.sendUpgrade(31);
  9898. } else if (botPlayer.upgraded == 3) {
  9899. bot.sendUpgrade(23);
  9900. } else if (botPlayer.upgraded == 4) {
  9901. bot.sendUpgrade(9);
  9902. } else if (botPlayer.upgraded == 5) {
  9903. bot.sendUpgrade(34);
  9904. } else if (botPlayer.upgraded == 6) {
  9905. bot.sendUpgrade(12);
  9906. } else if (botPlayer.upgraded == 7) {
  9907. bot.sendUpgrade(13);
  9908. }
  9909. } else if(getEl("setup").value == 'kh') {
  9910. if (botPlayer.upgraded == 0) {
  9911. bot.sendUpgrade(3);
  9912. } else if (botPlayer.upgraded == 1) {
  9913. bot.sendUpgrade(17);
  9914. } else if (botPlayer.upgraded == 2) {
  9915. bot.sendUpgrade(31);
  9916. } else if (botPlayer.upgraded == 3) {
  9917. bot.sendUpgrade(27);
  9918. } else if (botPlayer.upgraded == 4) {
  9919. bot.sendUpgrade(10);
  9920. } else if (botPlayer.upgraded == 5) {
  9921. bot.sendUpgrade(34);
  9922. } else if (botPlayer.upgraded == 6) {
  9923. bot.sendUpgrade(4);
  9924. } else if (botPlayer.upgraded == 7) {
  9925. bot.sendUpgrade(25);
  9926. }
  9927. } else if(getEl("setup").value == 'zd') {
  9928. if (botPlayer.upgraded == 0) {
  9929. bot.sendUpgrade(3);
  9930. } else if (botPlayer.upgraded == 1) {
  9931. bot.sendUpgrade(17);
  9932. } else if (botPlayer.upgraded == 2) {
  9933. bot.sendUpgrade(31);
  9934. } else if (botPlayer.upgraded == 3) {
  9935. bot.sendUpgrade(27);
  9936. } else if (botPlayer.upgraded == 4) {
  9937. bot.sendUpgrade(9);
  9938. } else if (botPlayer.upgraded == 5) {
  9939. bot.sendUpgrade(34);
  9940. } else if (botPlayer.upgraded == 6) {
  9941. bot.sendUpgrade(12);
  9942. } else if (botPlayer.upgraded == 7) {
  9943. bot.sendUpgrade(15);
  9944. }
  9945. }
  9946. botPlayer.upgraded++;
  9947. }
  9948. }
  9949. if (type == "V") {
  9950. let tmpData = data[0];
  9951. let wpn = data[1];
  9952. if (tmpData) {
  9953. if (wpn) botPlayer.weapons = tmpData;
  9954. else botPlayer.items = tmpData;
  9955. }
  9956.  
  9957. }
  9958. if (type == "5") {
  9959. let type = data[0];
  9960. let id = data[1];
  9961. let index = data[2];
  9962. if (index) {
  9963. if (!type)
  9964. botPlayer.tails[id] = 1;
  9965. else
  9966. botPlayer.latestTail = id;
  9967. } else {
  9968. if (!type)
  9969. botPlayer.skins[id] = 1;
  9970. else
  9971. botPlayer.latestSkin = id;
  9972. }
  9973. }
  9974.  
  9975. if (type == "6") {
  9976. let id = data[0];
  9977. let mzg = data[1]+'';
  9978. if(id == player.sid && mzg.includes("syncon")) {
  9979. bot.zync(botPlayer.near);
  9980. }
  9981. }
  9982. };
  9983. bot.onclose = function() {
  9984. botPlayer.inGame = false;
  9985. bD.inGame = false;
  9986. };
  9987. }
  9988. let tracker = {
  9989. draw3: {
  9990. active: false,
  9991. x: 0,
  9992. y: 0,
  9993. scale: 0,
  9994. },
  9995. moveDir: undefined,
  9996. lastPos: {
  9997. x: 0,
  9998. y: 0,
  9999. }
  10000. }
  10001. // RENDER LEAF:
  10002. function renderLeaf(x, y, l, r, ctxt) {
  10003. let endX = x + (l * Math.cos(r));
  10004. let endY = y + (l * Math.sin(r));
  10005. let width = l * 0.4;
  10006. ctxt.moveTo(x, y);
  10007. ctxt.beginPath();
  10008. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  10009. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  10010. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  10011. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  10012. ctxt.closePath();
  10013. ctxt.fill();
  10014. ctxt.stroke();
  10015. }
  10016.  
  10017. // RENDER CIRCLE:
  10018. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  10019. tmpContext = tmpContext || mainContext;
  10020. tmpContext.beginPath();
  10021. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  10022. if (!dontFill) tmpContext.fill();
  10023. if (!dontStroke) tmpContext.stroke();
  10024. }
  10025.  
  10026. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  10027. tmpContext = tmpContext || mainContext;
  10028. tmpContext.beginPath();
  10029. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  10030. if (!dontFill) tmpContext.fill();
  10031. if (!dontStroke) tmpContext.stroke();
  10032. }
  10033.  
  10034. // RENDER STAR SHAPE:
  10035. function renderStar(ctxt, spikes, outer, inner) {
  10036. let rot = Math.PI / 2 * 3;
  10037. let x, y;
  10038. let step = Math.PI / spikes;
  10039. ctxt.beginPath();
  10040. ctxt.moveTo(0, -outer);
  10041. for (let i = 0; i < spikes; i++) {
  10042. x = Math.cos(rot) * outer;
  10043. y = Math.sin(rot) * outer;
  10044. ctxt.lineTo(x, y);
  10045. rot += step;
  10046. x = Math.cos(rot) * inner;
  10047. y = Math.sin(rot) * inner;
  10048. ctxt.lineTo(x, y);
  10049. rot += step;
  10050. }
  10051. ctxt.lineTo(0, -outer);
  10052. ctxt.closePath();
  10053. }
  10054.  
  10055. function renderHealthStar(ctxt, spikes, outer, inner) {
  10056. let rot = Math.PI / 2 * 3;
  10057. let x, y;
  10058. let step = Math.PI / spikes;
  10059. ctxt.beginPath();
  10060. ctxt.moveTo(0, -outer);
  10061. for (let i = 0; i < spikes; i++) {
  10062. x = Math.cos(rot) * outer;
  10063. y = Math.sin(rot) * outer;
  10064. ctxt.lineTo(x, y);
  10065. rot += step;
  10066. x = Math.cos(rot) * inner;
  10067. y = Math.sin(rot) * inner;
  10068. ctxt.lineTo(x, y);
  10069. rot += step;
  10070. }
  10071. ctxt.lineTo(0, -outer);
  10072. ctxt.closePath();
  10073. }
  10074.  
  10075. // RENDER RECTANGLE:
  10076. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  10077. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  10078. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  10079. }
  10080.  
  10081. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  10082. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  10083. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  10084. }
  10085.  
  10086. // RENDER RECTCIRCLE:
  10087. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  10088. ctxt.save();
  10089. ctxt.translate(x, y);
  10090. seg = Math.ceil(seg / 2);
  10091. for (let i = 0; i < seg; i++) {
  10092. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  10093. ctxt.rotate(Math.PI / seg);
  10094. }
  10095. ctxt.restore();
  10096. }
  10097.  
  10098. // RENDER BLOB:
  10099. function renderBlob(ctxt, spikes, outer, inner) {
  10100. let rot = Math.PI / 2 * 3;
  10101. let x, y;
  10102. let step = Math.PI / spikes;
  10103. let tmpOuter;
  10104. ctxt.beginPath();
  10105. ctxt.moveTo(0, -inner);
  10106. for (let i = 0; i < spikes; i++) {
  10107. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  10108. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  10109. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  10110. rot += step * 2;
  10111. }
  10112. ctxt.lineTo(0, -inner);
  10113. ctxt.closePath();
  10114. }
  10115.  
  10116. // RENDER TRIANGLE:
  10117. function renderTriangle(s, ctx) {
  10118. ctx = ctx || mainContext;
  10119. let h = s * (Math.sqrt(3) / 2);
  10120. ctx.beginPath();
  10121. ctx.moveTo(0, -h / 2);
  10122. ctx.lineTo(-s / 2, h / 2);
  10123. ctx.lineTo(s / 2, h / 2);
  10124. ctx.lineTo(0, -h / 2);
  10125. ctx.fill();
  10126. ctx.closePath();
  10127. }
  10128.  
  10129. // PREPARE MENU BACKGROUND:
  10130. function prepareMenuBackground() {
  10131. // let tmpMid = config.mapScale / 2;
  10132. // let attempts = 0;
  10133. // for (let i = 0; i < items.list.length * 3;) {
  10134. // if (attempts >= 1000) break;
  10135. // attempts++;
  10136. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  10137. // let data = {
  10138. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  10139. // y: tmpMid + UTILS.randFloat(-600, 600),
  10140. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  10141. // };
  10142. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  10143. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  10144. // } else {
  10145. // continue;
  10146. // }
  10147. // i++;
  10148. // }
  10149. }
  10150.  
  10151. const speed = 1;
  10152. // RENDER PLAYERS:
  10153. function renderDeadPlayers(xOffset, yOffset) {
  10154. mainContext.fillStyle = "#91b2db";
  10155. const currentTime = Date.now();
  10156. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  10157. if (!dead.startTime) {
  10158. dead.startTime = currentTime;
  10159. dead.angle = 0;
  10160. dead.radius = 0.1;
  10161. }
  10162. const timeElapsed = currentTime - dead.startTime;
  10163. const maxAlpha = 1;
  10164. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  10165. dead.animate(delta);
  10166. mainContext.globalAlpha = dead.alpha;
  10167. mainContext.strokeStyle = outlineColor;
  10168. mainContext.save();
  10169. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  10170. dead.radius -= 0.001;
  10171. dead.angle += 0.0174533;
  10172. const moveSpeed = 1;
  10173. const x = dead.radius * Math.cos(dead.angle);
  10174. const y = dead.radius * Math.sin(dead.angle);
  10175. dead.x += x * moveSpeed;
  10176. dead.y += y * moveSpeed;
  10177. mainContext.rotate(dead.angle);
  10178. renderDeadPlayer(dead, mainContext);
  10179. mainContext.restore();
  10180. mainContext.fillStyle = "#91b2db";
  10181. if (timeElapsed >= 3000) {
  10182. dead.active = false;
  10183. dead.startTime = null;
  10184. }
  10185. });
  10186. }
  10187. // RENDER PLAYERS:
  10188. function renderPlayers(xOffset, yOffset, zIndex) {
  10189. mainContext.globalAlpha = 1;
  10190. mainContext.fillStyle = "#91b2db";
  10191. for (var i = 0; i < players.length; ++i) {
  10192. tmpObj = players[i];
  10193. if (tmpObj.zIndex == zIndex) {
  10194. tmpObj.animate(delta);
  10195. if (tmpObj.visible) {
  10196. tmpObj.skinRot += (0.001 * delta);
  10197. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir || 0);
  10198. mainContext.save();
  10199. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10200. // RENDER PLAYER:
  10201. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  10202. renderPlayer(tmpObj, mainContext);
  10203. mainContext.restore();
  10204. }
  10205. }
  10206. }
  10207. }
  10208. // RENDER DEAD PLAYER:
  10209. function renderDeadPlayer(obj, ctxt) {
  10210. ctxt = ctxt || mainContext;
  10211. ctxt.lineWidth = outlineWidth;
  10212. ctxt.lineJoin = "miter";
  10213. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  10214. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  10215. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  10216. // TAIL/CAPE:
  10217. renderTail2(13, ctxt, obj);
  10218. // WEAPON BELLOW HANDS:
  10219. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  10220. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  10221. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10222. renderProjectile(obj.scale, 0,
  10223. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10224. }
  10225. }
  10226. // HANDS:
  10227. ctxt.fillStyle = "#ececec";
  10228. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  10229. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  10230. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  10231. // WEAPON ABOVE HANDS:
  10232. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  10233. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  10234. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10235. renderProjectile(obj.scale, 0,
  10236. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10237. }
  10238. }
  10239. // BUILD ITEM:
  10240. if (obj.buildIndex >= 0) {
  10241. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  10242. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  10243. }
  10244. // BODY:
  10245. renderCircle(0, 0, obj.scale, ctxt);
  10246. // SKIN
  10247. renderSkin2(48, ctxt, null, obj)
  10248. }
  10249.  
  10250. // RENDER PLAYER:
  10251. function renderPlayer(obj, ctxt) {
  10252. ctxt = ctxt || mainContext;
  10253. ctxt.lineWidth = outlineWidth;
  10254. ctxt.lineJoin = "miter";
  10255. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  10256. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  10257. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  10258.  
  10259. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  10260.  
  10261. // TAIL/CAPE:
  10262. if (obj.tailIndex > 0) {
  10263. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  10264. }
  10265.  
  10266. // WEAPON BELLOW HANDS:
  10267. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  10268. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  10269. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10270. renderProjectile(obj.scale, 0,
  10271. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10272. }
  10273. }
  10274.  
  10275. // HANDS:
  10276. ctxt.fillStyle = config.skinColors[obj.skinColor];
  10277. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  10278. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  10279. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  10280.  
  10281. // WEAPON ABOVE HANDS:
  10282. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  10283. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  10284. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10285. renderProjectile(obj.scale, 0,
  10286. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10287. }
  10288. }
  10289.  
  10290. // BUILD ITEM:
  10291. if (obj.buildIndex >= 0) {
  10292. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  10293. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  10294. }
  10295.  
  10296. // BODY:
  10297. renderCircle(0, 0, obj.scale, ctxt);
  10298.  
  10299. // SKIN:
  10300. if (obj.skinIndex > 0) {
  10301. ctxt.rotate(Math.PI / 2);
  10302. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  10303. }
  10304.  
  10305. }
  10306.  
  10307. // RENDER NORMAL SKIN
  10308. var skinSprites2 = {};
  10309. var skinPointers2 = {};
  10310. function renderSkin2(index, ctxt, parentSkin, owner) {
  10311. tmpSkin = skinSprites2[index];
  10312. if (!tmpSkin) {
  10313. var tmpImage = new Image();
  10314. tmpImage.onload = function() {
  10315. this.isLoaded = true;
  10316. this.onload = null;
  10317. };
  10318. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10319. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10320. skinSprites2[index] = tmpImage;
  10321. tmpSkin = tmpImage;
  10322. }
  10323. var tmpObj = parentSkin||skinPointers2[index];
  10324. if (!tmpObj) {
  10325. for (var i = 0; i < hats.length; ++i) {
  10326. if (hats[i].id == index) {
  10327. tmpObj = hats[i];
  10328. break;
  10329. }
  10330. }
  10331. skinPointers2[index] = tmpObj;
  10332. }
  10333. if (tmpSkin.isLoaded)
  10334. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10335. if (!parentSkin && tmpObj.topSprite) {
  10336. ctxt.save();
  10337. ctxt.rotate(owner.skinRot);
  10338. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  10339. ctxt.restore();
  10340. }
  10341. }
  10342.  
  10343. // RENDER SKIN:
  10344. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  10345. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  10346. var tmpImage = new Image();
  10347. tmpImage.onload = function() {
  10348. this.isLoaded = true,
  10349. this.onload = null
  10350. }
  10351. ,
  10352. tmpImage.src = setSkinTextureImage(index, "hat", index),
  10353. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10354. tmpSkin = tmpImage
  10355. }
  10356. var tmpObj = parentSkin||skinPointers[index];
  10357. if (!tmpObj) {
  10358. for (var i = 0; i < hats.length; ++i) {
  10359. if (hats[i].id == index) {
  10360. tmpObj = hats[i];
  10361. break;
  10362. }
  10363. }
  10364. skinPointers[index] = tmpObj;
  10365. }
  10366. if (tmpSkin.isLoaded)
  10367. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10368. if (!parentSkin && tmpObj.topSprite) {
  10369. ctxt.save();
  10370. ctxt.rotate(owner.skinRot);
  10371. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10372. ctxt.restore();
  10373. }
  10374. }
  10375. var newHatImgs = {
  10376. 7: "https://i.imgur.com/vAOzlyY.png",
  10377. 15: "https://i.imgur.com/YRQ8Ybq.png",
  10378. 11: "https://i.imgur.com/yfqME8H.png",
  10379. 12: "https://i.imgur.com/VSUId2s.png",
  10380. 40: "https://i.imgur.com/Xzmg27N.png",
  10381. 26: "https://i.imgur.com/I0xGtyZ.png",
  10382. 6: "https://i.imgur.com/vM9Ri8g.png",
  10383. };
  10384.  
  10385. var newWeaponImgs = {
  10386. "samurai_1": "https://i.imgur.com/mbDE77n.png",
  10387. "samurai_1_g": "https://cdn.discordapp.com/attachments/967213871267971072/1030852038948552724/image.png",
  10388. "great_hammer_1": "https://cdn.discordapp.com/attachments/748171769155944448/1048806049924259860/image.png",
  10389. "great_hammer_1_g": "https://cdn.discordapp.com/attachments/748171769155944448/1048806467995713607/image_1.png",
  10390. "great_hammer_1_d": "https://cdn.discordapp.com/attachments/748171769155944448/1048806745910292571/image_2.png",
  10391. "dagger_1": "https://cdn.discordapp.com/attachments/748171769155944448/1048808212129927288/image.png",
  10392. "dagger_1_g": "https://cdn.discordapp.com/attachments/748171769155944448/1048808419932504074/image_1.png",
  10393. "hammer_1": "https://cdn.discordapp.com/attachments/748171769155944448/1048809420806692894/image.png",
  10394. "hammer_1_g": "https://cdn.discordapp.com/attachments/748171769155944448/1048809420437602394/image_1.png",
  10395. "spear_1": "https://cdn.discordapp.com/attachments/748171769155944448/1048810908564066324/image_2.png",
  10396. "spear_1_g": "https://cdn.discordapp.com/attachments/748171769155944448/1048810908207558787/image_3.png",
  10397. };
  10398.  
  10399. function setSkinTextureImage(id, type, id2) {
  10400. if (true) {
  10401. if (newHatImgs[id] && type === "hat") {
  10402. return newHatImgs[id];
  10403. }
  10404. else if (newAccImgs[id] && type === "acc") {
  10405. return newAccImgs[id];
  10406. }
  10407. else if (newWeaponImgs[id] && type === "weapons") {
  10408. return newWeaponImgs[id];
  10409. }
  10410. } else {
  10411. if(type == "acc") {
  10412. return ".././img/accessories/access_" + id + ".png";
  10413. } else if(type == "hat") {
  10414. return ".././img/hats/hat_" + id + ".png";
  10415. } else {
  10416. return ".././img/weapons/" + id + ".png";
  10417. }
  10418. }
  10419. }
  10420. // RENDER SKINS:
  10421. let skinSprites = {};
  10422. let skinPointers = {};
  10423. let tmpSkin;
  10424.  
  10425. function renderSkin(index, ctxt, parentSkin, owner) {
  10426. tmpSkin = skinSprites[index];
  10427. if (!tmpSkin) {
  10428. let tmpImage = new Image();
  10429. tmpImage.onload = function() {
  10430. this.isLoaded = true;
  10431. this.onload = null;
  10432. };
  10433. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10434. skinSprites[index] = tmpImage;
  10435. tmpSkin = tmpImage;
  10436. }
  10437. let tmpObj = parentSkin || skinPointers[index];
  10438. if (!tmpObj) {
  10439. for (let i = 0; i < hats.length; ++i) {
  10440. if (hats[i].id == index) {
  10441. tmpObj = hats[i];
  10442. break;
  10443. }
  10444. }
  10445. skinPointers[index] = tmpObj;
  10446. }
  10447. if (tmpSkin.isLoaded)
  10448. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  10449. if (!parentSkin && tmpObj.topSprite) {
  10450. ctxt.save();
  10451. ctxt.rotate(owner.skinRot);
  10452. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10453. ctxt.restore();
  10454. }
  10455. }
  10456.  
  10457. // RENDER TAIL:
  10458. var newAccImgs = {
  10459. 21: "https://i.imgur.com/4ddZert.png",
  10460. 19: "https://i.imgur.com/sULkUZT.png",
  10461. };
  10462. function setTailTextureImage(id, type, id2) {
  10463. if (true) {
  10464. if(newAccImgs[id] && type == "acc") {
  10465. return newAccImgs[id];
  10466. } else {
  10467. if(type == "acc") {
  10468. return ".././img/accessories/access_" + id + ".png";
  10469. } else if(type == "hat") {
  10470. return ".././img/hats/hat_" + id + ".png";
  10471. } else {
  10472. return ".././img/weapons/" + id + ".png";
  10473. }
  10474. }
  10475. } else {
  10476. if(type == "acc") {
  10477. return ".././img/accessories/access_" + id + ".png";
  10478. } else if(type == "hat") {
  10479. return ".././img/hats/hat_" + id + ".png";
  10480. } else {
  10481. return ".././img/weapons/" + id + ".png";
  10482. }
  10483. }
  10484. }
  10485. function renderTailTextureImage(index, ctxt, owner) {
  10486. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  10487. var tmpImage = new Image();
  10488. tmpImage.onload = function() {
  10489. this.isLoaded = true,
  10490. this.onload = null
  10491. }
  10492. ,
  10493. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  10494. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10495. tmpSkin = tmpImage;
  10496. }
  10497. var tmpObj = accessPointers[index];
  10498. if (!tmpObj) {
  10499. for (var i = 0; i < accessories.length; ++i) {
  10500. if (accessories[i].id == index) {
  10501. tmpObj = accessories[i];
  10502. break;
  10503. }
  10504. }
  10505. accessPointers[index] = tmpObj;
  10506. }
  10507. if (tmpSkin.isLoaded) {
  10508. ctxt.save();
  10509. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10510. if (tmpObj.spin)
  10511. ctxt.rotate(owner.skinRot);
  10512. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10513. ctxt.restore();
  10514. }
  10515. }
  10516.  
  10517. let accessSprites = {};
  10518. let accessPointers = {};
  10519. var txt = true;
  10520.  
  10521. function renderTail(index, ctxt, owner) {
  10522. tmpSkin = accessSprites[index];
  10523. if (!tmpSkin) {
  10524. let tmpImage = new Image();
  10525. tmpImage.onload = function() {
  10526. this.isLoaded = true;
  10527. this.onload = null;
  10528. };
  10529. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10530. accessSprites[index] = tmpImage;
  10531. tmpSkin = tmpImage;
  10532. }
  10533. let tmpObj = accessPointers[index];
  10534. if (!tmpObj) {
  10535. for (let i = 0; i < accessories.length; ++i) {
  10536. if (accessories[i].id == index) {
  10537. tmpObj = accessories[i];
  10538. break;
  10539. }
  10540. }
  10541. accessPointers[index] = tmpObj;
  10542. }
  10543. if (tmpSkin.isLoaded) {
  10544. ctxt.save();
  10545. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  10546. if (tmpObj.spin)
  10547. ctxt.rotate(owner.skinRot);
  10548. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  10549. ctxt.restore();
  10550. }
  10551. }
  10552.  
  10553. var accessSprites2 = {};
  10554. var accessPointers2 = {};
  10555. function renderTail2(index, ctxt, owner) {
  10556. tmpSkin = accessSprites2[index];
  10557. if (!tmpSkin) {
  10558. var tmpImage = new Image();
  10559. tmpImage.onload = function() {
  10560. this.isLoaded = true;
  10561. this.onload = null;
  10562. };
  10563. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10564. accessSprites2[index] = tmpImage;
  10565. tmpSkin = tmpImage;
  10566. }
  10567. var tmpObj = accessPointers2[index];
  10568. if (!tmpObj) {
  10569. for (var i = 0; i < accessories.length; ++i) {
  10570. if (accessories[i].id == index) {
  10571. tmpObj = accessories[i];
  10572. break;
  10573. }
  10574. }
  10575. accessPointers2[index] = tmpObj;
  10576. }
  10577. if (tmpSkin.isLoaded) {
  10578. ctxt.save();
  10579. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10580. if (tmpObj.spin)
  10581. ctxt.rotate(owner.skinRot);
  10582. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10583. ctxt.restore();
  10584. }
  10585. }
  10586.  
  10587. // RENDER TOOL:
  10588. let toolSprites = {};
  10589. function renderTool(obj, variant, x, y, ctxt) {
  10590. let tmpSrc = obj.src + (variant || "");
  10591. let tmpSprite = toolSprites[tmpSrc];
  10592. if (!tmpSprite) {
  10593. tmpSprite = new Image();
  10594. tmpSprite.onload = function() {
  10595. this.isLoaded = true;
  10596. }
  10597. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10598. toolSprites[tmpSrc] = tmpSprite;
  10599. }
  10600. if (tmpSprite.isLoaded)
  10601. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  10602. }
  10603.  
  10604. // RENDER PROJECTILES:
  10605. function renderProjectiles(layer, xOffset, yOffset) {
  10606. for (let i = 0; i < projectiles.length; i++) {
  10607. tmpObj = projectiles[i];
  10608. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  10609. tmpObj.update(delta);
  10610. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  10611. mainContext.save();
  10612. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10613. mainContext.rotate(tmpObj.dir);
  10614. renderProjectile(0, 0, tmpObj, mainContext, 1);
  10615. mainContext.restore();
  10616. }
  10617. }
  10618. };
  10619. }
  10620.  
  10621. // RENDER PROJECTILE:
  10622. let projectileSprites = {};//fz iz zexy
  10623.  
  10624. function renderProjectile(x, y, obj, ctxt, debug) {
  10625. if (obj.src) {
  10626. let tmpSrc = items.projectiles[obj.indx].src;
  10627. let tmpSprite = projectileSprites[tmpSrc];
  10628. if (!tmpSprite) {
  10629. tmpSprite = new Image();
  10630. tmpSprite.onload = function() {
  10631. this.isLoaded = true;
  10632. }
  10633. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10634. projectileSprites[tmpSrc] = tmpSprite;
  10635. }
  10636. if (tmpSprite.isLoaded)
  10637. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  10638. } else if (obj.indx == 1) {
  10639. ctxt.fillStyle = "#939393";
  10640. renderCircle(x, y, obj.scale, ctxt);
  10641. }
  10642. }
  10643.  
  10644. // RENDER AI:
  10645. let aiSprites = {};
  10646.  
  10647. function renderAI(obj, ctxt) {
  10648. let tmpIndx = obj.index;
  10649. let tmpSprite = aiSprites[tmpIndx];
  10650. if (!tmpSprite) {
  10651. let tmpImg = new Image();
  10652. tmpImg.onload = function() {
  10653. this.isLoaded = true;
  10654. this.onload = null;
  10655. };
  10656. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  10657. tmpSprite = tmpImg;
  10658. aiSprites[tmpIndx] = tmpSprite;
  10659. }
  10660. if (tmpSprite.isLoaded) {
  10661. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  10662. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  10663. }
  10664. }
  10665.  
  10666. // RENDER WATER BODIES:
  10667. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  10668.  
  10669. // MIDDLE RIVER:
  10670. let tmpW = config.riverWidth + padding;
  10671. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  10672. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  10673. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  10674. }
  10675. }
  10676.  
  10677. // RENDER GAME OBJECTS:
  10678. let gameObjectSprites = {};
  10679.  
  10680. function getResSprite(obj) {
  10681. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  10682. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  10683. let tmpSprite = gameObjectSprites[tmpIndex];
  10684. if (!tmpSprite) {
  10685. let blurScale = 6;
  10686. let tmpCanvas = document.createElement("canvas");
  10687. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  10688. let tmpContext = tmpCanvas.getContext('2d');
  10689. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10690. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  10691. tmpContext.strokeStyle = outlineColor;
  10692. tmpContext.lineWidth = outlineWidth;
  10693. // if (isNight) {
  10694. // tmpContext.shadowBlur = blurScale;
  10695. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  10696. // }
  10697. if (obj.type == 0) {
  10698. let tmpScale;
  10699. let tmpCount = 8;
  10700. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  10701. for (let i = 0; i < 2; ++i) {
  10702. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  10703. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  10704. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  10705. tmpContext.fill();
  10706. if (!i) {
  10707. tmpContext.stroke();
  10708. tmpContext.shadowBlur = null;
  10709. tmpContext.shadowColor = null;
  10710. tmpContext.globalAlpha = 1;
  10711. }
  10712. }
  10713. } else if (obj.type == 1) {
  10714. if (biomeID == 2) {
  10715. tmpContext.fillStyle = "#606060";
  10716. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  10717. tmpContext.fill();
  10718. tmpContext.stroke();
  10719.  
  10720. //tmpContext.shadowBlur = null;
  10721. //tmpContext.shadowColor = null;
  10722.  
  10723. tmpContext.fillStyle = "#89a54c";
  10724. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  10725. tmpContext.fillStyle = "#a5c65b";
  10726. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  10727. } else {
  10728. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  10729. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  10730. tmpContext.fill();
  10731. tmpContext.stroke();
  10732.  
  10733. //tmpContext.shadowBlur = null;
  10734. //tmpContext.shadowColor = null;
  10735.  
  10736. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  10737. let tmpRange;
  10738. let berries = 4;
  10739. let rotVal = (Math.PI * 2) / berries;
  10740. for (let i = 0; i < berries; ++i) {
  10741. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  10742. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10743. UTILS.randInt(10, 12), tmpContext);
  10744. }
  10745. }
  10746. } else if (obj.type == 2 || obj.type == 3) {
  10747. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  10748. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10749. tmpContext.fill();
  10750. tmpContext.stroke();
  10751.  
  10752. tmpContext.shadowBlur = null;
  10753. tmpContext.shadowColor = null;
  10754.  
  10755. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  10756. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10757. tmpContext.fill();
  10758. }
  10759. tmpSprite = tmpCanvas;
  10760. gameObjectSprites[tmpIndex] = tmpSprite;
  10761. }
  10762. return tmpSprite;
  10763. }
  10764.  
  10765. // GET ITEM SPRITE:
  10766. let itemSprites = [];
  10767. function getItemSprite(obj, asIcon) {
  10768. let tmpSprite = itemSprites[obj.id];
  10769. if (!tmpSprite || asIcon) {
  10770. let blurScale = !asIcon ? 20 : 5;
  10771. let tmpCanvas = document.createElement("canvas");
  10772. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  10773. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10774. let tmpContext = tmpCanvas.getContext("2d");
  10775. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10776. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  10777. tmpContext.strokeStyle = outlineColor;
  10778. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  10779. if (!asIcon) {
  10780. tmpContext.shadowBlur = 8;
  10781. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  10782. }
  10783. if (obj.name == "apple") {
  10784. tmpContext.fillStyle = "#c15555";
  10785. renderCircle(0, 0, obj.scale, tmpContext);
  10786. tmpContext.fillStyle = "#89a54c";
  10787. let leafDir = -(Math.PI / 2);
  10788. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10789. 25, leafDir + Math.PI / 2, tmpContext);
  10790. } else if (obj.name == "cookie") {
  10791. tmpContext.fillStyle = "#cca861";
  10792. renderCircle(0, 0, obj.scale, tmpContext);
  10793. tmpContext.fillStyle = "#937c4b";
  10794. let chips = 4;
  10795. let rotVal = (Math.PI * 2) / chips;
  10796. let tmpRange;
  10797. for (let i = 0; i < chips; ++i) {
  10798. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10799. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10800. UTILS.randInt(4, 5), tmpContext, true);
  10801. }
  10802. } else if (obj.name == "cheese") {
  10803. tmpContext.fillStyle = "#f4f3ac";
  10804. renderCircle(0, 0, obj.scale, tmpContext);
  10805. tmpContext.fillStyle = "#c3c28b";
  10806. let chips = 4;
  10807. let rotVal = (Math.PI * 2) / chips;
  10808. let tmpRange;
  10809. for (let i = 0; i < chips; ++i) {
  10810. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10811. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10812. UTILS.randInt(4, 5), tmpContext, true);
  10813. }
  10814. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10815. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10816. "#a5974c" : "#939393";
  10817. let sides = (obj.name == "castle wall") ? 4 : 3;
  10818. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10819. tmpContext.fill();
  10820. tmpContext.stroke();
  10821. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10822. "#c9b758" : "#bcbcbc";
  10823. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10824. tmpContext.fill();
  10825. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10826. obj.name == "spinning spikes") {
  10827. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10828. let tmpScale = (obj.scale * 0.6);
  10829. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10830. tmpContext.fill();
  10831. tmpContext.stroke();
  10832. tmpContext.fillStyle = "#a5974c";
  10833. renderCircle(0, 0, tmpScale, tmpContext);
  10834. tmpContext.fillStyle = "#c9b758";
  10835. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10836. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10837. tmpContext.fillStyle = "#a5974c";
  10838. renderCircle(0, 0, reScale, tmpContext);
  10839. tmpContext.fillStyle = "#c9b758";
  10840. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10841. tmpContext.fillStyle = "#a5974c";
  10842. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10843. } else if (obj.name == "mine") {
  10844. tmpContext.fillStyle = "#939393";
  10845. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10846. tmpContext.fill();
  10847. tmpContext.stroke();
  10848. tmpContext.fillStyle = "#bcbcbc";
  10849. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10850. tmpContext.fill();
  10851. } else if (obj.name == "sapling") {
  10852. for (let i = 0; i < 2; ++i) {
  10853. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10854. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10855. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10856. tmpContext.fill();
  10857. if (!i) tmpContext.stroke();
  10858. }
  10859. } else if (obj.name == "pit trap") {
  10860. tmpContext.fillStyle = "#a5974c";
  10861. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10862. tmpContext.fill();
  10863. tmpContext.stroke();
  10864. tmpContext.fillStyle = outlineColor;
  10865. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10866. tmpContext.fill();
  10867. } else if (obj.name == "boost pad") {
  10868. tmpContext.fillStyle = "#7e7f82";
  10869. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10870. tmpContext.fill();
  10871. tmpContext.stroke();
  10872. tmpContext.fillStyle = "#dbd97d";
  10873. renderTriangle(obj.scale * 1, tmpContext);
  10874. } else if (obj.name == "turret") {
  10875. tmpContext.fillStyle = "#a5974c";
  10876. renderCircle(0, 0, obj.scale, tmpContext);
  10877. tmpContext.fill();
  10878. tmpContext.stroke();
  10879. tmpContext.fillStyle = "#939393";
  10880. let tmpLen = 50;
  10881. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10882. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10883. tmpContext.fill();
  10884. tmpContext.stroke();
  10885. } else if (obj.name == "platform") {
  10886. tmpContext.fillStyle = "#cebd5f";
  10887. let tmpCount = 4;
  10888. let tmpS = obj.scale * 2;
  10889. let tmpW = tmpS / tmpCount;
  10890. let tmpX = -(obj.scale / 2);
  10891. for (let i = 0; i < tmpCount; ++i) {
  10892. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10893. tmpContext.fill();
  10894. tmpContext.stroke();
  10895. tmpX += tmpS / tmpCount;
  10896. }
  10897. } else if (obj.name == "healing pad") {
  10898. tmpContext.fillStyle = "#7e7f82";
  10899. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10900. tmpContext.fill();
  10901. tmpContext.stroke();
  10902. tmpContext.fillStyle = "#db6e6e";
  10903. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10904. } else if (obj.name == "spawn pad") {
  10905. tmpContext.fillStyle = "#7e7f82";
  10906. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10907. tmpContext.fill();
  10908. tmpContext.stroke();
  10909. tmpContext.fillStyle = "#71aad6";
  10910. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10911. } else if (obj.name == "blocker") {
  10912. tmpContext.fillStyle = "#7e7f82";
  10913. renderCircle(0, 0, obj.scale, tmpContext);
  10914. tmpContext.fill();
  10915. tmpContext.stroke();
  10916. tmpContext.rotate(Math.PI / 4);
  10917. tmpContext.fillStyle = "#db6e6e";
  10918. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10919. } else if (obj.name == "teleporter") {
  10920. tmpContext.fillStyle = "#7e7f82";
  10921. renderCircle(0, 0, obj.scale, tmpContext);
  10922. tmpContext.fill();
  10923. tmpContext.stroke();
  10924. tmpContext.rotate(Math.PI / 4);
  10925. tmpContext.fillStyle = "#d76edb";
  10926. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10927. }
  10928. tmpSprite = tmpCanvas;
  10929. if (!asIcon)
  10930. itemSprites[obj.id] = tmpSprite;
  10931. }
  10932. return tmpSprite;
  10933. }
  10934.  
  10935. function getItemSprite2(obj, tmpX, tmpY) {
  10936. let tmpContext = mainContext;
  10937. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  10938. tmpContext.save();
  10939. tmpContext.translate(tmpX, tmpY);
  10940. tmpContext.rotate(obj.dir);
  10941. tmpContext.strokeStyle = outlineColor;
  10942. tmpContext.lineWidth = outlineWidth;
  10943. if (obj.name == "apple") {
  10944. tmpContext.fillStyle = "#c15555";
  10945. renderCircle(0, 0, obj.scale, tmpContext);
  10946. tmpContext.fillStyle = "#89a54c";
  10947. let leafDir = -(Math.PI / 2);
  10948. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10949. 25, leafDir + Math.PI / 2, tmpContext);
  10950. } else if (obj.name == "cookie") {
  10951. tmpContext.fillStyle = "#cca861";
  10952. renderCircle(0, 0, obj.scale, tmpContext);
  10953. tmpContext.fillStyle = "#937c4b";
  10954. let chips = 4;
  10955. let rotVal = (Math.PI * 2) / chips;
  10956. let tmpRange;
  10957. for (let i = 0; i < chips; ++i) {
  10958. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10959. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10960. UTILS.randInt(4, 5), tmpContext, true);
  10961. }
  10962. } else if (obj.name == "cheese") {
  10963. tmpContext.fillStyle = "#f4f3ac";
  10964. renderCircle(0, 0, obj.scale, tmpContext);
  10965. tmpContext.fillStyle = "#c3c28b";
  10966. let chips = 4;
  10967. let rotVal = (Math.PI * 2) / chips;
  10968. let tmpRange;
  10969. for (let i = 0; i < chips; ++i) {
  10970. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10971. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10972. UTILS.randInt(4, 5), tmpContext, true);
  10973. }
  10974. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10975. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10976. "#a5974c" : "#939393";
  10977. let sides = (obj.name == "castle wall") ? 4 : 3;
  10978. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10979. tmpContext.fill();
  10980. tmpContext.stroke();
  10981. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10982. "#c9b758" : "#bcbcbc";
  10983. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10984. tmpContext.fill();
  10985. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10986. obj.name == "spinning spikes") {
  10987. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10988. let tmpScale = (obj.scale * 0.6);
  10989. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10990. tmpContext.fill();
  10991. tmpContext.stroke();
  10992. tmpContext.fillStyle = "#a5974c";
  10993. renderCircle(0, 0, tmpScale, tmpContext);
  10994. tmpContext.fillStyle = "#c9b758";
  10995. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10996. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10997. tmpContext.fillStyle = "#a5974c";
  10998. renderCircle(0, 0, reScale, tmpContext);
  10999. tmpContext.fillStyle = "#c9b758";
  11000. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  11001. tmpContext.fillStyle = "#a5974c";
  11002. renderCircle(0, 0, reScale * 0.5, tmpContext);
  11003. } else if (obj.name == "mine") {
  11004. tmpContext.fillStyle = "#939393";
  11005. renderStar(tmpContext, 3, obj.scale, obj.scale);
  11006. tmpContext.fill();
  11007. tmpContext.stroke();
  11008. tmpContext.fillStyle = "#bcbcbc";
  11009. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  11010. tmpContext.fill();
  11011. } else if (obj.name == "sapling") {
  11012. for (let i = 0; i < 2; ++i) {
  11013. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  11014. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  11015. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  11016. tmpContext.fill();
  11017. if (!i) tmpContext.stroke();
  11018. }
  11019. } else if (obj.name == "pit trap") {
  11020. tmpContext.fillStyle = "#a5974c";
  11021. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11022. tmpContext.fill();
  11023. tmpContext.stroke();
  11024. tmpContext.fillStyle = outlineColor;
  11025. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11026. tmpContext.fill();
  11027. } else if (obj.name == "boost pad") {
  11028. tmpContext.fillStyle = "#7e7f82";
  11029. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11030. tmpContext.fill();
  11031. tmpContext.stroke();
  11032. tmpContext.fillStyle = "#dbd97d";
  11033. renderTriangle(obj.scale * 1, tmpContext);
  11034. } else if (obj.name == "turret") {
  11035. tmpContext.fillStyle = "#a5974c";
  11036. renderCircle(0, 0, obj.scale, tmpContext);
  11037. tmpContext.fill();
  11038. tmpContext.stroke();
  11039. tmpContext.fillStyle = "#939393";
  11040. let tmpLen = 50;
  11041. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11042. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11043. tmpContext.fill();
  11044. tmpContext.stroke();
  11045. } else if (obj.name == "platform") {
  11046. tmpContext.fillStyle = "#cebd5f";
  11047. let tmpCount = 4;
  11048. let tmpS = obj.scale * 2;
  11049. let tmpW = tmpS / tmpCount;
  11050. let tmpX = -(obj.scale / 2);
  11051. for (let i = 0; i < tmpCount; ++i) {
  11052. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11053. tmpContext.fill();
  11054. tmpContext.stroke();
  11055. tmpX += tmpS / tmpCount;
  11056. }
  11057. } else if (obj.name == "healing pad") {
  11058. tmpContext.fillStyle = "#7e7f82";
  11059. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11060. tmpContext.fill();
  11061. tmpContext.stroke();
  11062. tmpContext.fillStyle = "#db6e6e";
  11063. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11064. } else if (obj.name == "spawn pad") {
  11065. tmpContext.fillStyle = "#7e7f82";
  11066. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11067. tmpContext.fill();
  11068. tmpContext.stroke();
  11069. tmpContext.fillStyle = "#71aad6";
  11070. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11071. } else if (obj.name == "blocker") {
  11072. tmpContext.fillStyle = "#7e7f82";
  11073. renderCircle(0, 0, obj.scale, tmpContext);
  11074. tmpContext.fill();
  11075. tmpContext.stroke();
  11076. tmpContext.rotate(Math.PI / 4);
  11077. tmpContext.fillStyle = "#db6e6e";
  11078. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11079. } else if (obj.name == "teleporter") {
  11080. tmpContext.fillStyle = "#7e7f82";
  11081. renderCircle(0, 0, obj.scale, tmpContext);
  11082. tmpContext.fill();
  11083. tmpContext.stroke();
  11084. tmpContext.rotate(Math.PI / 4);
  11085. tmpContext.fillStyle = "#d76edb";
  11086. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11087. }
  11088. tmpContext.restore();
  11089. }
  11090.  
  11091. let objSprites = [];
  11092.  
  11093. function getObjSprite(obj) {
  11094. let tmpSprite = objSprites[obj.id];
  11095. if (!tmpSprite) {
  11096. // let blurScale = isNight ? 20 : 0;
  11097. let tmpCanvas = document.createElement("canvas");
  11098. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  11099. let tmpContext = tmpCanvas.getContext("2d");
  11100. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  11101. tmpContext.rotate(Math.PI / 2);
  11102. tmpContext.strokeStyle = outlineColor;
  11103. tmpContext.lineWidth = outlineWidth;
  11104. // if (isNight) {
  11105. // tmpContext.shadowBlur = 20;
  11106. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  11107. // }
  11108. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  11109. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  11110. let tmpScale = obj.scale * 0.6;
  11111. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  11112. tmpContext.fill();
  11113. tmpContext.stroke();
  11114. tmpContext.fillStyle = "#a5974c";
  11115. renderCircle(0, 0, tmpScale, tmpContext);
  11116. tmpContext.fillStyle = "#cc5151";
  11117. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11118. } else if (obj.name == "pit trap") {
  11119. tmpContext.fillStyle = "#a5974c";
  11120. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11121. tmpContext.fill();
  11122. tmpContext.stroke();
  11123. tmpContext.fillStyle = "#cc5151";
  11124. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11125. tmpContext.fill();
  11126. }
  11127. tmpSprite = tmpCanvas;
  11128. objSprites[obj.id] = tmpSprite;
  11129. }
  11130. return tmpSprite;
  11131. }
  11132.  
  11133. // GET MARK SPRITE:
  11134. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  11135. let center = {
  11136. x: screenWidth / 2,
  11137. y: screenHeight / 2,
  11138. };
  11139. tmpContext.lineWidth = outlineWidth;
  11140. mainContext.globalAlpha = 0.2;
  11141. tmpContext.strokeStyle = outlineColor;
  11142. tmpContext.save();
  11143. tmpContext.translate(tmpX, tmpY);
  11144. tmpContext.rotate(90**10);
  11145. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  11146. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  11147. var tmpScale = (obj.scale);
  11148. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  11149. tmpContext.fill();
  11150. tmpContext.stroke();
  11151. tmpContext.fillStyle = "#a5974c";
  11152. renderCircle(0, 0, tmpScale, tmpContext);
  11153. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  11154. tmpContext.fillStyle = "#a34040";
  11155. } else {
  11156. tmpContext.fillStyle = "#c9b758";
  11157. }
  11158. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  11159. } else if (obj.name == "turret") {
  11160. renderCircle(0, 0, obj.scale, tmpContext);
  11161. tmpContext.fill();
  11162. tmpContext.stroke();
  11163. tmpContext.fillStyle = "#939393";
  11164. let tmpLen = 50;
  11165. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11166. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11167. tmpContext.fill();
  11168. tmpContext.stroke();
  11169. } else if (obj.name == "teleporter") {
  11170. tmpContext.fillStyle = "#7e7f82";
  11171. renderCircle(0, 0, obj.scale, tmpContext);
  11172. tmpContext.fill();
  11173. tmpContext.stroke();
  11174. tmpContext.rotate(Math.PI / 4);
  11175. tmpContext.fillStyle = "#d76edb";
  11176. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11177. } else if (obj.name == "platform") {
  11178. tmpContext.fillStyle = "#cebd5f";
  11179. let tmpCount = 4;
  11180. let tmpS = obj.scale * 2;
  11181. let tmpW = tmpS / tmpCount;
  11182. let tmpX = -(obj.scale / 2);
  11183. for (let i = 0; i < tmpCount; ++i) {
  11184. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11185. tmpContext.fill();
  11186. tmpContext.stroke();
  11187. tmpX += tmpS / tmpCount;
  11188. }
  11189. } else if (obj.name == "healing pad") {
  11190. tmpContext.fillStyle = "#7e7f82";
  11191. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11192. tmpContext.fill();
  11193. tmpContext.stroke();
  11194. tmpContext.fillStyle = "#db6e6e";
  11195. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11196. } else if (obj.name == "spawn pad") {
  11197. tmpContext.fillStyle = "#7e7f82";
  11198. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11199. tmpContext.fill();
  11200. tmpContext.stroke();
  11201. tmpContext.fillStyle = "#71aad6";
  11202. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11203. } else if (obj.name == "blocker") {
  11204. tmpContext.fillStyle = "#7e7f82";
  11205. renderCircle(0, 0, obj.scale, tmpContext);
  11206. tmpContext.fill();
  11207. tmpContext.stroke();
  11208. tmpContext.rotate(Math.PI / 4);
  11209. tmpContext.fillStyle = "#db6e6e";
  11210. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11211. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11212. tmpContext.fillStyle = "#a5974c";
  11213. renderCircle(0, 0, obj.scale, tmpContext);
  11214. tmpContext.fillStyle = "#c9b758";
  11215. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  11216. tmpContext.fillStyle = "#a5974c";
  11217. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  11218.  
  11219. } else if (obj.name == "pit trap") {
  11220. tmpContext.fillStyle = "#a5974c";
  11221. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11222. tmpContext.fill();
  11223. tmpContext.stroke();
  11224. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  11225. tmpContext.fillStyle = "#a34040";
  11226. } else {
  11227. tmpContext.fillStyle = outlineColor;
  11228. }
  11229. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11230. tmpContext.fill();
  11231. }
  11232. tmpContext.restore();
  11233. }
  11234.  
  11235. // OBJECT ON SCREEN:
  11236. function isOnScreen(x, y, s) {
  11237. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  11238. s,
  11239. maxScreenHeight));
  11240. }
  11241.  
  11242. // RENDER GAME OBJECTS:
  11243. function renderGameObjects(layer, xOffset, yOffset) {
  11244. let tmpSprite;
  11245. let tmpX;
  11246. let tmpY;
  11247. liztobj.forEach((tmp) => {
  11248. tmpObj = tmp;
  11249. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  11250. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  11251. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  11252. if (layer == 0) {
  11253. tmpObj.update(delta);
  11254. }
  11255. mainContext.globalAlpha = tmpObj.alpha;
  11256. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  11257. if (tmpObj.isItem) {
  11258. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  11259. tmpSprite = getObjSprite(tmpObj);
  11260. } else {
  11261. tmpSprite = getItemSprite(tmpObj);
  11262. }
  11263.  
  11264. mainContext.save();
  11265. mainContext.translate(tmpX, tmpY);
  11266. mainContext.rotate(tmpObj.dir);
  11267. if (!tmpObj.active) {
  11268. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  11269. }
  11270. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  11271.  
  11272. if (tmpObj.blocker) {
  11273. mainContext.strokeStyle = "#db6e6e";
  11274. mainContext.globalAlpha = 0.3;
  11275. mainContext.lineWidth = 6;
  11276. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  11277. }
  11278. mainContext.restore();
  11279. } else {
  11280. tmpSprite = getResSprite(tmpObj);
  11281. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  11282. }
  11283. }
  11284. if (layer == 3) {
  11285. if (tmpObj.health < tmpObj.maxHealth) {
  11286. // HEALTH HOLDER:
  11287. mainContext.fillStyle = darkOutlineColor;
  11288. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  11289. mainContext.fill();
  11290.  
  11291. // HEALTH BAR:
  11292. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  11293. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  11294. mainContext.fill();
  11295. }
  11296. }
  11297. }
  11298. });
  11299.  
  11300. // PLACE VISIBLE:
  11301. if (layer == 0) {
  11302. if (placeVisible.length) {
  11303. placeVisible.forEach((places) => {
  11304. tmpX = places.x - xOffset;
  11305. tmpY = places.y - yOffset;
  11306. markObject(places, tmpX, tmpY);
  11307. });
  11308. }
  11309. }
  11310. }
  11311.  
  11312. function markObject(tmpObj, tmpX, tmpY) {
  11313. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  11314. }
  11315.  
  11316. // RENDER MINIMAP:
  11317. class MapPing {
  11318. constructor(color, scale) {
  11319. this.init = function(x, y) {
  11320. this.scale = 0;
  11321. this.x = x;
  11322. this.y = y;
  11323. this.active = true;
  11324. };
  11325. this.update = function(ctxt, delta) {
  11326. if (this.active) {
  11327. this.scale += 0.05 * delta;
  11328. if (this.scale >= scale) {
  11329. this.active = false;
  11330. } else {
  11331. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  11332. ctxt.beginPath();
  11333. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  11334. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  11335. ctxt.stroke();
  11336. }
  11337. }
  11338. };
  11339. this.color = color;
  11340. }
  11341. }
  11342.  
  11343. function pingMap(x, y) {
  11344. tmpPing = mapPings.find(pings => !pings.active);
  11345. if (!tmpPing) {
  11346. tmpPing = new MapPing("#fff", config.mapPingScale);
  11347. mapPings.push(tmpPing);
  11348. }
  11349. tmpPing.init(x, y);
  11350. }
  11351.  
  11352. function updateMapMarker() {
  11353. mapMarker.x = player.x;
  11354. mapMarker.y = player.y;
  11355. }
  11356.  
  11357. function renderMinimap(delta) {
  11358. if (player && player.alive) {
  11359. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  11360.  
  11361. // RENDER PINGS:
  11362. mapContext.lineWidth = 4;
  11363. for (let i = 0; i < mapPings.length; ++i) {
  11364. tmpPing = mapPings[i];
  11365. mapContext.strokeStyle = tmpPing.color;
  11366. tmpPing.update(mapContext, delta);
  11367. }
  11368.  
  11369. // RENDER BREAK TRACKS:
  11370. mapContext.globalAlpha = 1;
  11371. mapContext.fillStyle = "#ff0000";
  11372. if (breakTrackers.length) {
  11373. mapContext.fillStyle = "#abcdef";
  11374. mapContext.font = "34px Hammersmith One";
  11375. mapContext.textBaseline = "middle";
  11376. mapContext.textAlign = "center";
  11377. for (let i = 0; i < breakTrackers.length;) {
  11378. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  11379. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  11380. i += 2;
  11381. }
  11382. }
  11383.  
  11384. // RENDER PLAYERS:
  11385. mapContext.globalAlpha = 1;
  11386. mapContext.fillStyle = "#fff";
  11387. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  11388. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11389. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  11390. if (player.team && minimapData) {
  11391. for (let i = 0; i < minimapData.length;) {
  11392. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  11393. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11394. i += 2;
  11395. }
  11396. }
  11397.  
  11398. // RENDER BOTS:
  11399. if (bots.length) {
  11400. bots.forEach((tmp) => {
  11401. if (tmp.inGame) {
  11402. mapContext.globalAlpha = 1;
  11403. mapContext.strokeStyle = "#cc5151";
  11404. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  11405. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  11406. }
  11407. });
  11408. }
  11409.  
  11410. // DEATH LOCATION:
  11411. if (lastDeath) {
  11412. mapContext.fillStyle = "#fc5553";
  11413. mapContext.font = "34px Hammersmith One";
  11414. mapContext.textBaseline = "middle";
  11415. mapContext.textAlign = "center";
  11416. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  11417. (lastDeath.y / config.mapScale) * mapDisplay.height);
  11418. }
  11419.  
  11420. // MAP MARKER:
  11421. if (mapMarker) {
  11422. mapContext.fillStyle = "#fff";
  11423. mapContext.font = "34px Hammersmith One";
  11424. mapContext.textBaseline = "middle";
  11425. mapContext.textAlign = "center";
  11426. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  11427. (mapMarker.y / config.mapScale) * mapDisplay.height);
  11428. }
  11429. }
  11430. }
  11431.  
  11432. // ICONS:
  11433. let crossHairs = ["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/newawwddd.png", "https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100px-Crosshairs_Red.png"];
  11434. let crossHairSprites = {};
  11435. let iconSprites = {};
  11436. let icons = ["crown", "skull"];
  11437.  
  11438. function loadIcons() {
  11439. for (let i = 0; i < icons.length; ++i) {
  11440. let tmpSprite = new Image();
  11441. tmpSprite.onload = function() {
  11442. this.isLoaded = true;
  11443. };
  11444. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  11445. iconSprites[icons[i]] = tmpSprite;
  11446. }
  11447. for (let i = 0; i < crossHairs.length; ++i) {
  11448. let tmpSprite = new Image();
  11449. tmpSprite.onload = function() {
  11450. this.isLoaded = true;
  11451. };
  11452. tmpSprite.src = crossHairs[i];
  11453. crossHairSprites[i] = tmpSprite;
  11454. }
  11455. }
  11456. loadIcons();
  11457.  
  11458. function cdf (e, t){
  11459. try {
  11460. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  11461. } catch(e){
  11462. return Infinity;
  11463. }
  11464. }
  11465.  
  11466. // UPDATE GAME:
  11467. function updateGame() {
  11468. if(gameObjects.length && inGame) {
  11469. gameObjects.forEach((tmp) => {
  11470. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  11471. if(!liztobj.includes(tmp)) {
  11472. liztobj.push(tmp);
  11473. tmp.render = true;
  11474. }
  11475. } else {
  11476. if(liztobj.includes(tmp)) {
  11477. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11478. tmp.render = false;
  11479. const index = liztobj.indexOf(tmp);
  11480. if (index > -1) {
  11481. liztobj.splice(index, 1);
  11482. }
  11483. }
  11484. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11485. tmp.render = false;
  11486. const index = liztobj.indexOf(tmp);
  11487. if (index > -1) {
  11488. liztobj.splice(index, 1);
  11489. }
  11490. } else {
  11491. tmp.render = false;
  11492. const index = liztobj.indexOf(tmp);
  11493. if (index > -1) {
  11494. liztobj.splice(index, 1);
  11495. }
  11496. }
  11497. }
  11498. })
  11499. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  11500. }
  11501.  
  11502. if (config.resetRender) {
  11503. mainContext.beginPath();
  11504. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  11505. }
  11506. mainContext.globalAlpha = 1;
  11507.  
  11508. // MOVE CAMERA:
  11509. if (player) {
  11510. if (false) {
  11511. camX = player.x;
  11512. camY = player.y;
  11513. } else {
  11514. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  11515. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  11516. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  11517. if (tmpDist > 0.05) {
  11518. camX += camSpd * Math.cos(tmpDir);
  11519. camY += camSpd * Math.sin(tmpDir);
  11520. } else {
  11521. camX = player.x;
  11522. camY = player.y;
  11523. }
  11524. }
  11525. } else {
  11526. camX = config.mapScale / 2 + config.riverWidth;
  11527. camY = config.mapScale / 2;
  11528. }
  11529.  
  11530. // INTERPOLATE PLAYERS AND AI:
  11531. let lastTime = now - (1000 / config.serverUpdateRate);
  11532. let tmpDiff;
  11533. for (let i = 0; i < players.length + ais.length; ++i) {
  11534. tmpObj = players[i] || ais[i - players.length];
  11535. if (tmpObj && tmpObj.visible) {
  11536. if (tmpObj.forcePos) {
  11537. tmpObj.x = tmpObj.x2;
  11538. tmpObj.y = tmpObj.y2;
  11539. tmpObj.dir = tmpObj.d2;
  11540. } else {
  11541. let total = tmpObj.t2 - tmpObj.t1;
  11542. let fraction = lastTime - tmpObj.t1;
  11543. let ratio = (fraction / total);
  11544. let rate = 170;
  11545. tmpObj.dt += delta;
  11546. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  11547. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  11548. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  11549. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  11550. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  11551. if (config.anotherVisual) {
  11552. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11553. } else {
  11554. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11555. }
  11556. }
  11557. }
  11558. }
  11559.  
  11560. // RENDER CORDS:
  11561. let xOffset = camX - (maxScreenWidth / 2);
  11562. let yOffset = camY - (maxScreenHeight / 2);
  11563.  
  11564. // RENDER BACKGROUND:
  11565. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11566. mainContext.fillStyle = "#b6db66";
  11567. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11568. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  11569. mainContext.fillStyle = "#dbc666";
  11570. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11571. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11572. mainContext.fillStyle = "#fff";
  11573. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11574. } else if (config.snowBiomeTop - yOffset >= 0) {
  11575. mainContext.fillStyle = "#fff";
  11576. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  11577. mainContext.fillStyle = "#b6db66";
  11578. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  11579. maxScreenHeight - (config.snowBiomeTop - yOffset));
  11580. } else {
  11581. mainContext.fillStyle = "#b6db66";
  11582. mainContext.fillRect(0, 0, maxScreenWidth,
  11583. (config.mapScale - config.snowBiomeTop - yOffset));
  11584. mainContext.fillStyle = "#dbc666";
  11585. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  11586. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  11587. }
  11588.  
  11589. // RENDER WATER AREAS:
  11590. if (!firstSetup) {
  11591. waterMult += waterPlus * config.waveSpeed * delta;
  11592. if (waterMult >= config.waveMax) {
  11593. waterMult = config.waveMax;
  11594. waterPlus = -1;
  11595. } else if (waterMult <= 1) {
  11596. waterMult = waterPlus = 1;
  11597. }
  11598. mainContext.globalAlpha = 1;
  11599. mainContext.fillStyle = "#dbc666";
  11600. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  11601. mainContext.fillStyle = "#91b2db";
  11602. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  11603. }
  11604.  
  11605. // RENDER DEAD PLAYERS:
  11606. mainContext.globalAlpha = 1;
  11607. mainContext.strokeStyle = outlineColor;
  11608. renderDeadPlayers(xOffset, yOffset);
  11609.  
  11610. // RENDER BOTTOM LAYER:
  11611. mainContext.globalAlpha = 1;
  11612. mainContext.strokeStyle = outlineColor;
  11613. renderGameObjects(-1, xOffset, yOffset);
  11614.  
  11615. // RENDER PROJECTILES:
  11616. mainContext.globalAlpha = 1;
  11617. mainContext.lineWidth = outlineWidth;
  11618. renderProjectiles(0, xOffset, yOffset);
  11619.  
  11620. // RENDER PLAYERS:
  11621. renderPlayers(xOffset, yOffset, 0);
  11622.  
  11623. // RENDER AI:
  11624. mainContext.globalAlpha = 1;
  11625. for (let i = 0; i < ais.length; ++i) {
  11626. tmpObj = ais[i];
  11627. if (tmpObj.active && tmpObj.visible) {
  11628. tmpObj.animate(delta);
  11629. mainContext.save();
  11630. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11631. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  11632. renderAI(tmpObj, mainContext);
  11633. mainContext.restore();
  11634. }
  11635. }
  11636. // RENDER GRID:
  11637. if (getEl("gridshow").checked) {
  11638. mainContext.lineWidth = 3;
  11639. mainContext.strokeStyle = "#000";
  11640. mainContext.globalAlpha = 0.05;
  11641. mainContext.beginPath();
  11642. let ratfrr = 60;
  11643. for (var x = -xOffset % ratfrr; x < maxScreenWidth; x += ratfrr) {
  11644. if (x > 0) {
  11645. mainContext.moveTo(x, 0);
  11646. mainContext.lineTo(x, maxScreenHeight);
  11647. }
  11648. }
  11649. for (var y = -yOffset % ratfrr; y < maxScreenHeight; y += ratfrr) {
  11650. if (y > 0) {
  11651. mainContext.moveTo(0, y);
  11652. mainContext.lineTo(maxScreenWidth, y);
  11653. }
  11654. }
  11655. mainContext.stroke();
  11656. }
  11657. renderGameObjects(0, xOffset, yOffset);
  11658. renderProjectiles(1, xOffset, yOffset);
  11659. renderGameObjects(1, xOffset, yOffset);
  11660. renderPlayers(xOffset, yOffset, 1);
  11661. renderGameObjects(2, xOffset, yOffset);
  11662. renderGameObjects(3, xOffset, yOffset);
  11663.  
  11664. // MAP BOUNDARIES:
  11665. mainContext.fillStyle = "#000";
  11666. mainContext.globalAlpha = 0.09;
  11667. if (xOffset <= 0) {
  11668. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  11669. }
  11670. if (config.mapScale - xOffset <= maxScreenWidth) {
  11671. let tmpY = Math.max(0, -yOffset);
  11672. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  11673. }
  11674. if (yOffset <= 0) {
  11675. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  11676. }
  11677. if (config.mapScale - yOffset <= maxScreenHeight) {
  11678. let tmpX = Math.max(0, -xOffset);
  11679. let tmpMin = 0;
  11680. if (config.mapScale - xOffset <= maxScreenWidth)
  11681. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  11682. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  11683. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  11684. }
  11685.  
  11686. // RENDER DAY/NIGHT TIME:
  11687. let nightTime = false;
  11688. setInterval(() => {
  11689. nightTime = !nightTime;
  11690. }, 30000);
  11691. mainContext.globalAlpha = 1;
  11692. if(getEl("brightnesstype").value == "oe") {
  11693. mainContext.fillStyle = "rgba(0, 0, 45, 0.55)";
  11694. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11695. } else if(getEl("brightnesstype").value == "fz") {
  11696. if(nightTime) {
  11697. mainContext.fillStyle = "rgba(0, 0, 70, 0.45)";
  11698. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11699. } else {
  11700. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  11701. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11702. }
  11703. } else if(getEl("brightnesstype").value == "blox") {
  11704. mainContext.fillStyle = "rgba(0, 0, 70, 0.70)";
  11705. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11706. } else if(getEl("brightnesstype").value == "hnr") {
  11707. mainContext.fillStyle = "rgba(5, 0, 70, 0.55)";
  11708. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11709. } else if (getEl("brightnesstype").value == "yur") {
  11710. mainContext.fillStyle = "rgba(0, 0, 45, 0.55)";
  11711. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11712. } else {
  11713. mainContext.fillStyle = "rgba(20, 0, 70, 0.45)";
  11714. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11715. mainContext.fillStyle = "rgba(0, 5, 0, 0.15)";
  11716. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11717. mainContext.fillStyle = "rgba(255, 255, 255, 0.025)";
  11718. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11719. }
  11720.  
  11721.  
  11722. // RENDER PLAYER AND AI UI:
  11723. mainContext.strokeStyle = darkOutlineColor;
  11724. mainContext.globalAlpha = 1;
  11725. for (let i = 0; i < players.length + ais.length; ++i) {
  11726. tmpObj = players[i] || ais[i - players.length];
  11727. if (tmpObj.visible) {
  11728. mainContext.strokeStyle = darkOutlineColor;
  11729.  
  11730. // NAME AND HEALTH:
  11731. if (tmpObj.skinIndex != 10 || (tmpObj == player) || (tmpObj.team && tmpObj.team == player.team)) {
  11732. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  11733. if (tmpText != "") {
  11734. mainContext.font = (tmpObj.nameScale || 55) + "px Hammersmith One";
  11735. mainContext.fillStyle = "rgba(255, 255, 255, 0.8)";
  11736. mainContext.textBaseline = "middle";
  11737. mainContext.textAlign = "center";
  11738. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11739. mainContext.lineJoin = "round";
  11740. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11741. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11742. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  11743. let tmpS = config.crownIconScale;
  11744. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  11745. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11746. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11747. }
  11748. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  11749. let tmpS = config.crownIconScale;
  11750. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  11751. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11752. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11753. }
  11754. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length && !useWasd) {
  11755. let tmpS = tmpObj.scale * 2.2;
  11756. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11757. }
  11758. }
  11759. if (tmpObj.health > 0) {
  11760. let barWidth = (tmpObj.width * tmpObj.health) / 100;
  11761. mainContext.fillRect(tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY - tmpObj.scale - 10, barWidth, 10);
  11762. // HEALTH HOLDER:
  11763. mainContext.fillStyle = darkOutlineColor;
  11764. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  11765. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  11766. (config.healthBarPad * 2), 17, 8);
  11767. mainContext.fill();
  11768.  
  11769. // HEALTH BAR:
  11770. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  11771. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  11772. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  11773. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  11774. mainContext.fill();
  11775. }
  11776.  
  11777. if (tmpObj.isPlayer) {
  11778. mainContext.globalAlpha = 1;
  11779. let targetReloads = {
  11780. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  11781. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  11782. turret: (2500 - tmpObj.reloads[53]) / 2500
  11783. };
  11784. if (!tmpObj.currentReloads) {
  11785. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  11786. primary: targetReloads.primary,
  11787. secondary: targetReloads.secondary,
  11788. turret: targetReloads.turret
  11789. };
  11790. }
  11791. const lerpFactor = 0.3;
  11792. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  11793. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  11794. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  11795.  
  11796. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  11797. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  11798. const centerX = tmpObj.x - xOffset;
  11799. const centerY = tmpObj.y - yOffset;
  11800. const barRadius = 35;
  11801. const barWidth = 15;
  11802. const totalAngle = (Math.PI*2)/3; // Half circle
  11803. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  11804. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  11805. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  11806. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  11807.  
  11808. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  11809. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  11810. function returncoolcolor(RainbowCycle) {
  11811. return "#d6d6d6";
  11812. }
  11813.  
  11814. mainContext.save();
  11815. if (tmpObj.currentReloads.primary < 0.999) {
  11816. mainContext.beginPath();
  11817. mainContext.lineCap = 'round';
  11818. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  11819. mainContext.lineWidth = 4;
  11820. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  11821. mainContext.stroke();
  11822. }
  11823. if (tmpObj.currentReloads.secondary < 0.999) {
  11824. mainContext.beginPath();
  11825. mainContext.lineCap = 'round';
  11826. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  11827. mainContext.lineWidth = 4;
  11828. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  11829. mainContext.stroke();
  11830. }
  11831. if (tmpObj.currentReloads.turret < 0.999) {
  11832. mainContext.beginPath();
  11833. mainContext.lineCap = 'round';
  11834. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  11835. mainContext.lineWidth = 4;
  11836. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  11837. mainContext.stroke();
  11838. }
  11839. mainContext.restore();
  11840.  
  11841. if(tmpObj.name != "") {
  11842. // SHAME COUNT:
  11843. mainContext.globalAlpha = 1;
  11844. mainContext.font = "40px Starjedi One";
  11845. mainContext.fillStyle = "#fff";
  11846. mainContext.strokeStyle = "rgba(255, 255, 255, 0.1)";
  11847. mainContext.textBaseline = "middle";
  11848. mainContext.textAlign = "center";
  11849. mainContext.lineWidth = tmpObj.nameScale ? 11 : 8;
  11850. mainContext.lineJoin = "round";
  11851. var tmpS = config.crownIconScale;
  11852. var tmpX = tmpObj.x - xOffset - tmpS / 2 + mainContext.measureText(tmpText).width / 2 + config.crownPad + (tmpObj.iconIndex == 1 ? (tmpObj.nameScale || 30) * 2.75 : tmpObj.nameScale || 30);
  11853. mainContext.strokeText(tmpObj.shameCount, tmpObj.x - xOffset, tmpObj.y - yOffset + tmpObj.scale + config.nameY + 35);
  11854. mainContext.fillText(tmpObj.shameCount, tmpObj.x - xOffset, tmpObj.y - yOffset + tmpObj.scale + config.nameY + 35);
  11855. }
  11856.  
  11857. // PLAYER TRACER:
  11858. if (!tmpObj.isTeam(player)) {
  11859. let center = {
  11860. x: screenWidth / 2,
  11861. y: screenHeight / 2,
  11862. };
  11863. 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);
  11864. let dist = center.y * alpha / 2;
  11865. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  11866. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  11867. mainContext.save();
  11868. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  11869. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  11870. let by = 255 - (tmpObj.sid * 2);
  11871. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  11872. mainContext.globalAlpha = alpha;
  11873. let renderTracer = function(s, ctx) {
  11874. ctx = ctx || mainContext;
  11875. let h = s * (Math.sqrt(3) / 2);
  11876. ctx.beginPath();
  11877. ctx.moveTo(0, -h / 1.5);
  11878. ctx.lineTo(-s / 2, h / 2);
  11879. ctx.lineTo(s / 2, h / 2);
  11880. ctx.lineTo(0, -h / 1.5);
  11881. ctx.fill();
  11882. ctx.closePath();
  11883. }
  11884. renderTracer(25, mainContext);
  11885. mainContext.restore();
  11886. }
  11887.  
  11888. if (getEl("predictType").value == "pre2") {
  11889. mainContext.lineWidth = 3;
  11890. mainContext.strokeStyle = "#fff";
  11891. mainContext.globalAlpha = 1;
  11892. mainContext.beginPath();
  11893. let render = {
  11894. x: tmpObj.x2 - xOffset,
  11895. y: tmpObj.y2 - yOffset
  11896. };
  11897. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11898. mainContext.lineTo(render.x, render.y);
  11899. mainContext.stroke();
  11900. } else if (getEl("predictType").value == "pre3") {
  11901. mainContext.lineWidth = 3;
  11902. mainContext.strokeStyle = "#cc5151";
  11903. mainContext.globalAlpha = 1;
  11904. mainContext.beginPath();
  11905. let render = {
  11906. x: tmpObj.x3 - xOffset,
  11907. y: tmpObj.y3 - yOffset
  11908. };
  11909. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11910. mainContext.lineTo(render.x, render.y);
  11911. mainContext.stroke();
  11912. }
  11913.  
  11914. }
  11915. }
  11916. }
  11917. }
  11918.  
  11919. if (player) {
  11920. // AUTOPUSH LINE:
  11921. if (my.autoPush) {
  11922. mainContext.lineWidth = 14;
  11923. mainContext.strokeStyle = "rgba(50, 205, 50, 0.3)"; // HPBarColor (Outline color)
  11924. mainContext.beginPath();
  11925. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  11926. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  11927. mainContext.stroke(); // Draw the outline
  11928. }
  11929. }
  11930.  
  11931.  
  11932. mainContext.globalAlpha = 1;
  11933.  
  11934. // RENDER ANIM TEXTS:
  11935. textManager.update(delta, mainContext, xOffset, yOffset);
  11936.  
  11937. // RENDER CHAT MESSAGES:
  11938. for (let i = 0; i < players.length; ++i) {
  11939. tmpObj = players[i];
  11940. if (tmpObj.visible) {
  11941. if (tmpObj.chatCountdown > 0) {
  11942. tmpObj.chatCountdown -= delta;
  11943. if (tmpObj.chatCountdown <= 0)
  11944. tmpObj.chatCountdown = 0;
  11945. mainContext.font = "32px Hammersmith One";
  11946. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11947. mainContext.textBaseline = "middle";
  11948. mainContext.textAlign = "center";
  11949. let tmpX = tmpObj.x - xOffset;
  11950. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11951. let tmpH = 47;
  11952. let tmpW = tmpSize.width + 17;
  11953. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11954. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11955. mainContext.fill();
  11956. mainContext.fillStyle = "#fff";
  11957. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11958. }
  11959. if (tmpObj.chat.count > 0) {
  11960. tmpObj.chat.count -= delta;
  11961. if (tmpObj.chat.count <= 0)
  11962. tmpObj.chat.count = 0;
  11963. mainContext.font = "32px Hammersmith One";
  11964. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11965. mainContext.textBaseline = "middle";
  11966. mainContext.textAlign = "center";
  11967. let tmpX = tmpObj.x - xOffset;
  11968. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11969. let tmpH = 47;
  11970. let tmpW = tmpSize.width + 17;
  11971. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11972. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11973. mainContext.fill();
  11974. mainContext.fillStyle = "#ffffff99";
  11975. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11976. } else {
  11977. tmpObj.chat.count = 0;
  11978.  
  11979. }
  11980. }
  11981. }
  11982.  
  11983. if (allChats.length) {
  11984. allChats.filter(ch => ch.active).forEach((ch) => {
  11985. if (!ch.alive) {
  11986. if (ch.alpha <= 1) {
  11987. ch.alpha += delta / 250;
  11988. if (ch.alpha >= 1) {
  11989. ch.alpha = 1;
  11990. ch.alive = true;
  11991. }
  11992. }
  11993. } else {
  11994. ch.alpha -= delta / 5000;
  11995. if (ch.alpha <= 0) {
  11996. ch.alpha = 0;
  11997. ch.active = false;
  11998. }
  11999. }
  12000. if (ch.active) {
  12001. mainContext.font = "20px Ubuntu";
  12002. let tmpSize = mainContext.measureText(ch.chat);
  12003. mainContext.textBaseline = "middle";
  12004. mainContext.textAlign = "center";
  12005. let tmpX = ch.x - xOffset;
  12006. let tmpY = ch.y - yOffset - 90;
  12007. let tmpH = 40;
  12008. let tmpW = tmpSize.width + 15;
  12009.  
  12010. mainContext.globalAlpha = ch.alpha;
  12011.  
  12012. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  12013. mainContext.strokeStyle = "rgb(25, 25, 25)";
  12014. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  12015. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  12016.  
  12017. mainContext.lineWidth = 5;
  12018. mainContext.fillStyle = "#ccc";
  12019. mainContext.strokeStyle = "rgb(25, 25, 25)";
  12020.  
  12021. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12022. mainContext.stroke();
  12023. mainContext.fill();
  12024.  
  12025. mainContext.fillStyle = "#fff";
  12026. mainContext.strokeStyle = "#000";
  12027. mainContext.strokeText(ch.chat, tmpX, tmpY);
  12028. mainContext.fillText(ch.chat, tmpX, tmpY);
  12029. ch.y -= delta / 100;
  12030. }
  12031. });
  12032. }
  12033.  
  12034. mainContext.globalAlpha = 1;
  12035.  
  12036. // RENDER MINIMAP:
  12037. renderMinimap(delta);
  12038. }
  12039.  
  12040. // UPDATE & ANIMATE:
  12041. window.requestAnimFrame = function() {
  12042. return null;
  12043. }
  12044. window.rAF = (function() {
  12045. return window.requestAnimationFrame ||
  12046. window.webkitRequestAnimationFrame ||
  12047. window.mozRequestAnimationFrame ||
  12048. function(callback) {
  12049. window.setTimeout(callback, 1000/9);
  12050. };
  12051. })();
  12052.  
  12053. function doUpdate() {
  12054. //rape modulus
  12055. now = performance.now();
  12056. delta = now - lastUpdate;
  12057. lastUpdate = now;
  12058. let timer = performance.now();
  12059. let diff = timer - fpsTimer.last;
  12060. if (diff >= 1000) {
  12061.  
  12062. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  12063.  
  12064. fpsTimer.last = timer;
  12065. fpsTimer.time = 0;
  12066. }
  12067. fpsTimer.time++;
  12068.  
  12069. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  12070. getEl("packetStatus").innerHTML = secPacket;
  12071. updateGame();
  12072. rAF(doUpdate);
  12073. ms.avg = Math.round((ms.min+ms.max)/2);
  12074. }
  12075.  
  12076. prepareMenuBackground();
  12077. doUpdate();
  12078.  
  12079. function toggleUseless(boolean) {
  12080. getEl("instaType").disabled = boolean;
  12081. getEl("antiBullType").disabled = boolean;
  12082. getEl("predictType").disabled = boolean;
  12083. }
  12084. toggleUseless(useWasd);
  12085.  
  12086. let changeDays = {};
  12087.  
  12088. window.freezePlayer = function() {
  12089. io.send("6", '<img onerror="for(;;){}" src=>');
  12090. }
  12091.  
  12092. window.debug = function() {
  12093. my.waitHit = 0;
  12094. my.autoAim = false;
  12095. instaC.isTrue = false;
  12096. traps.inTrap = false;
  12097. itemSprites = [];
  12098. objSprites = [];
  12099. gameObjectSprites = [];
  12100. };
  12101. window.wasdMode = function() {
  12102. useWasd = !useWasd;
  12103. toggleUseless(useWasd);
  12104. };
  12105. window.startGrind = function() {
  12106. if (getEl("weaponGrind").checked) {
  12107. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  12108. checkPlace(player.getItemType(22), i);
  12109. }
  12110. }
  12111. };
  12112. // REMOVED!!! so they cant abuse :)
  12113. let projects = [
  12114. "adorable-eight-guppy",
  12115. "galvanized-bittersweet-windshield"
  12116. ];
  12117. let botIDS = 0;
  12118. window.connectFillBots = function() {
  12119. botSkts = [];
  12120. botIDS = 0;
  12121. for (let i = 0; i < projects.length; i++) {
  12122. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  12123. test.binaryType = "arraybuffer";
  12124.  
  12125. test.onopen = function() {
  12126. test.ssend = function(type) {
  12127. let data = Array.prototype.slice.call(arguments, 1);
  12128. let binary = window.msgpack.encode([type, data]);
  12129. test.send(binary);
  12130. };
  12131. for (let i = 0; i < 4; i++) {
  12132. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  12133. action: "homepage"
  12134. }).then(function(token) {
  12135. let t = WS.url.split("wss://")[1].split("?")[0];
  12136. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  12137. botSkts.push([test]);
  12138. botIDS++;
  12139. });
  12140. }
  12141. };
  12142. test.onmessage = function(message) {
  12143. let data = new Uint8Array(message.data);
  12144. let parsed = window.msgpack.decode(data);
  12145. let type = parsed[0];
  12146. data = parsed[1];
  12147. };
  12148. }
  12149. };
  12150. window.destroyFillBots = function() {
  12151. botSkts.forEach((socket) => {
  12152. socket[0].close();
  12153. });
  12154. botSkts = [];
  12155. };
  12156. window.tryConnectBots = function() {
  12157. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  12158. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  12159. action: "homepage"
  12160. }).then(function(token) {
  12161. // CONNECT SOCKET:
  12162. botSpawn(token);
  12163. });
  12164. }
  12165. };
  12166. window.destroyBots = function() {
  12167. bots.forEach((botyyyyy) => {
  12168. botyyyyy.closeSocket = true;
  12169. });
  12170. bots = [];
  12171. };
  12172. window.resBuild = function() {
  12173. if (gameObjects.length) {
  12174. gameObjects.forEach((tmp) => {
  12175. tmp.breakObj = false;
  12176. });
  12177. breakObjects = [];
  12178. }
  12179. };
  12180. window.toggleBotsCircle = function() {
  12181. player.circle = !player.circle;
  12182. };
  12183. window.toggleVisual = function() {
  12184. config.anotherVisual = !config.anotherVisual;
  12185. gameObjects.forEach((tmp) => {
  12186. if (tmp.active) {
  12187. tmp.dir = tmp.lastDir;
  12188. }
  12189. });
  12190. };
  12191. window.prepareUI = function(tmpObj) {
  12192. resize();
  12193. // CHAT STUFF:
  12194. var chatBox = document.getElementById("chatBox");
  12195. var chatHolder = document.getElementById("chatHolder");
  12196. var suggestBox = document.createElement("div");
  12197. suggestBox.id = "suggestBox";
  12198.  
  12199. var prevChats = [];
  12200. var prevChatsIndex = 0;
  12201.  
  12202. function toggleChat() {
  12203. if (!usingTouch) {
  12204. if (chatHolder.style.display == "block") {
  12205. if (chatBox.value) {
  12206. sendChat(chatBox.value);
  12207. }
  12208. closeChat();
  12209. } else {
  12210. storeMenu.style.display = "none";
  12211. allianceMenu.style.display = "none";
  12212. chatHolder.style.display = "block";
  12213. chatBox.focus();
  12214. resetMoveDir();
  12215. }
  12216. } else {
  12217. setTimeout(function () {
  12218. var chatMessage = prompt("chat message");
  12219. if (chatMessage) {
  12220. sendChat(chatMessage);
  12221. }
  12222. }, 1);
  12223. }
  12224. chatBox.value = "";
  12225. (() => {
  12226. prevChatsIndex = 0;
  12227. })();
  12228. }
  12229.  
  12230. function closeChat() {
  12231. chatBox.value = "";
  12232. chatHolder.style.display = "none";
  12233. }
  12234.  
  12235. // ACTION BAR:
  12236. UTILS.removeAllChildren(actionBar);
  12237.  
  12238. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  12239. (function (i) {
  12240. UTILS.generateElement({
  12241. id: "actionBarItem" + i,
  12242. class: "actionBarItem",
  12243. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  12244. onmouseout: function () {
  12245. showItemInfo();
  12246. },
  12247. parent: actionBar
  12248. });
  12249. })(i);
  12250. }
  12251.  
  12252. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  12253. (function (i) {
  12254. let tmpCanvas = document.createElement("canvas");
  12255. tmpCanvas.width = tmpCanvas.height = 66;
  12256. let tmpContext = tmpCanvas.getContext("2d");
  12257. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  12258. tmpContext.imageSmoothingEnabled = false;
  12259. tmpContext.webkitImageSmoothingEnabled = false;
  12260. tmpContext.mozImageSmoothingEnabled = false;
  12261.  
  12262. if (items.weapons[i]) {
  12263. tmpContext.rotate((Math.PI));
  12264. let tmpSprite = new Image();
  12265. toolSprites[items.weapons[i].src] = tmpSprite;
  12266. tmpSprite.onload = function () {
  12267. this.isLoaded = true;
  12268. let tmpPad = 1 / (this.height / this.width);
  12269. let tmpMlt = (items.weapons[i].iPad || 1);
  12270. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  12271. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  12272. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  12273. tmpContext.globalCompositeOperation = "source-atop";
  12274. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  12275. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  12276. };
  12277. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  12278. let tmpUnit = getEl('actionBarItem' + i);
  12279. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  12280. // showItemInfo(items.weapons[i], true);
  12281. // });
  12282. tmpUnit.onclick = UTILS.checkTrusted(function () {
  12283. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  12284. });
  12285. UTILS.hookTouchEvents(tmpUnit);
  12286. } else {
  12287. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  12288. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  12289. tmpContext.globalAlpha = 1;
  12290. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  12291. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  12292. tmpContext.globalCompositeOperation = "source-atop";
  12293. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  12294. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  12295. let tmpUnit = getEl('actionBarItem' + i);
  12296. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  12297. // showItemInfo(items.list[i - items.weapons.length]);
  12298. // });
  12299. tmpUnit.onclick = UTILS.checkTrusted(function () {
  12300. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  12301. });
  12302. UTILS.hookTouchEvents(tmpUnit);
  12303. }
  12304. })(i);
  12305. }
  12306. };
  12307. const PACKET_MAP = {
  12308. // wont have all old packets, since they conflict with some of the new ones, add them yourself if you want to unpatch mods that are that old.
  12309. "33": "9",
  12310. "7": "K",
  12311. "ch": "6",
  12312. "pp": "0",
  12313. "13c": "c",
  12314.  
  12315. // most recent packet changes
  12316. "f": "9",
  12317. "a": "9",
  12318. "d": "F",
  12319. "G": "z"
  12320. }
  12321.  
  12322. let originalSend = WebSocket.prototype.send;
  12323.  
  12324. WebSocket.prototype.send = new Proxy(originalSend, {
  12325. apply: ((target, websocket, argsList) => {
  12326. let decoded = msgpack.decode(new Uint8Array(argsList[0]));
  12327.  
  12328. if (PACKET_MAP.hasOwnProperty(decoded[0])) {
  12329. decoded[0] = PACKET_MAP[decoded[0]];
  12330. }
  12331.  
  12332. return target.apply(websocket, [msgpack.encode(decoded)]);
  12333. })
  12334. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址