Unreal? mod v3

Ong this mod so op it kell all server

当前为 2024-07-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Unreal? mod v3
  3. // @author wat, viruster dev
  4. // @namespace try and ur gay
  5. // @description Ong this mod so op it kell all server
  6. // @version v.2
  7. // @match *://*.moomoo.io/*
  8. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAMFBMVEX///8AAADw8PCamprp6emysrJNTU18fHzHx8doaGjZ2dnQ0NC9vb3h4eGnp6eMjIzCSNxaAAAErElEQVR4nO2c6baqMAyFKTKIOLz/214v6lF2SidaYK+V77dD04xNA1WlKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKFmp26Heew0ZqFtjTLv3KlYzifGk2Xsh6/iIYcxp76Ws4SvGk9veq0lmJoYx/d7rSaU2wGXvFaVyB0GGvReUilDJOe13RtO3ZR2sPrljaguCdGlZ8aXZx7lYAG+9MbUDSdKy4vC3EfexQIEwdn4HPqNxpaxjbqFDmzdmNH2QA/cgSEpWHAvGjPobkK7OD15QJQl2jsHP/Y9RXMOt5QGrSMiK6GjZAthlmP2u21oaVEm0heMvdMkLn1PjHnuWdoJPR1s4Box78tIB9F/P0oRKYrMi7kQ2y7rhyjxLw4XEmka37usOMIp4/F2oZIz6N9y3bJb19BIMI54fR5XEBS4sc+K2wQ1mKI/drivnB/jyuqUDwt/dm4ybGqMSNMy8B2Zh9m5/FyqJSO9X+GpOy6rkHnv8HT8esa2YtdauHJD+7izQhQaDVYLKzN6Kkf7uXBsGruAYimk9/7E/zt9FERx6LoEdyJgNP8j87twslDv0qJiqyQjQWtwlV+JRES24RAtCxFR3CMboEFY6wm6V6SdhhHf3SERDJeQvcLMyng1/iQrBST0uNMhC/SARipyGn1LNQzYs1qkUIdiVrhLOvPiVxEalHxmCXbpHsf2lI3phuds7EYIfjg9DKH34yz+o4AveFMkq2GUvP8GhuwbsLv56yT62qIJd9vJnKaewigmO1AXKky9RWfH14eEcaOobJZE3Mis6Pvx0qVO4fWASKXxRL7KiY+OaUGVMbOfqE/JgkmnnMN0Wv4AUWTHTiEP5kwggC5UsFdG2rj4hVJKl0YGBfYOZHFCJ5340FAgiJY6Ggl9r7jOl340K+DnfUmLIFlpAIRsN5LxV0uUrs8t3gay8VJJzsgwUstk4zrO8a3OGFcyyxU5UiG+UIxaI6OWTYSEwx26QDMuAKZZ1QBU9hHY+FU8GrArBKotVIeL0zKoQvMVnVYjoMLEqJPVG6GiIFgCpQnIN2O7O6uGugyAaGaRD6GIMwdXcPzJiEIz02RlhWKShV3b2SUNvmUbf9ggHIfX0yHGjwyJvIzkP6jWOYLI+WSbuuUkNS8rBaVhy1JPTsMRQGmkqtMhBWfTKyRxOB7HIQZnSZUJPfepyXyz+Qfm0uE0OxppXTOQYzraJzOeUAau2yUH4XohG1LuccljCrjGEL4GRZSKlHPIp2f/0dHLcxPggp39YzYpPjpstWhHKYVcHnRwL6mDL5/WCOtjqxLM1WD3TB1fdfhE96jdc6aOxpsD/bDI+motavpPgA9PxY9HHudzDIYa587hHYzs9feCJuk4xeKLVuBRwJ1iSedMupD8uLx8X0waTOprlrPHiwXAb1VwXCtw/OoI7A78UmWfoi3Br/VKY/vBWNTqD1MeqCCor+cYXSjEq680Tm3O8sd0REIpRydcV/ZD5OZnCLLoJlxiV7WHXyajYxKgsM3BcvvEFVUIScC3M/H2gFWM2BxfxToQj8nnYNeRtIYdmUkng20KOzanjjFOKoiiKoiiKwss/2hcaejBPt/YAAAAASUVORK5CYII=
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12. //For the mod will work
  13. let newFont = document.createElement("link");
  14. newFont.rel = "stylesheet";
  15. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  16. newFont.type = "text/css";
  17. document.body.append(newFont);
  18. let min = document.createElement("script");
  19. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  20. document.body.append(min);
  21. /*
  22. -Visuals-
  23. Dev: wat
  24. -Make visuals better
  25. -only 1 visuals
  26. -simple
  27. -camera adjustment
  28. -Game object
  29. -Visions
  30.  
  31. -Combats and Misc-
  32. Dev: wat
  33. -make Playstle
  34. -Hat/acc changer
  35.  
  36. -Placers-
  37. Dev: Blox & wat
  38. -autoplace
  39. -autoreplace
  40. -autopreplace
  41. -autoretrap
  42. -AutoSpikeInTrap or autotrapInTrap
  43. -AutoSpikeTick(2) (1)
  44.  
  45. */
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. let ping = 0
  69.  
  70. document.getElementById("gameName").innerHTML = " Unreal mod?";
  71. (function() {
  72. let shadowRadius = 50;
  73. let shadowDirection = 1;
  74. let canShadow = true;
  75. setInterval(() => {
  76. if (canShadow == true) {
  77. shadowRadius = (shadowDirection == 1) ? shadowRadius - 5 : shadowRadius + 5;
  78. if (shadowRadius >= 50 || shadowRadius <= 0) {
  79. shadowDirection = (shadowRadius >= 50) ? 1 : (shadowRadius <= 0) ? 0 : null;
  80. canShadow = false;
  81. setTimeout(() => {
  82. canShadow = true;
  83. }, 100);
  84. }
  85. }
  86. document.getElementById("gameName").style.textShadow = `0px 0px ${shadowRadius + 20}px #ffffff`;
  87. }, 100);
  88. })();
  89.  
  90. (function() {
  91. })();var moomooVer = $('#linksContainer2 .menuLink').html(),
  92. hideSelectors = ['#mobileDownloadButtonContainer',
  93. '#followText',
  94. '#smallLinks',
  95. '#linksContainer1',
  96. '#twitterFollow',
  97. '#youtubeFollow',
  98. '#cdm-zone-02',
  99. '#youtuberOf',
  100. '#downloadButtonContainer',
  101. '#promoImg',
  102. '.menuHeader',
  103. '.menuLink',
  104. '.menuHeader:nth-child(5)',
  105. '.menuHeader:nth-child(6)',
  106. '.menuText',
  107. '#adCard',
  108. '#promoImgHolder',
  109. ],
  110.  
  111. css = '#rightCardHolder {display: block!important}',
  112. head = document.head || document.getElementsByTagName('head')[0],
  113. style = document.createElement('style');
  114.  
  115. style.type = 'text/css';
  116. if (style.styleSheet){
  117. style.styleSheet.cssText = css;
  118. } else {
  119. style.appendChild(document.createTextNode(css));
  120. }
  121.  
  122. for ( let i = 0; i < hideSelectors.length; i++ ) {
  123. $(hideSelectors[i]).hide();
  124. }
  125.  
  126. head.appendChild(style);
  127. $('#linksContainer2').html('<a href="./docs/versions.txt" target="_blank" class="menuLink">' + moomooVer + '</a>');
  128. document.getElementById("storeHolder").style = "height: 500px; width: 435px;";
  129. document.getElementById('enterGame').innerText = "Welcome";
  130. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  131. document.getElementById('enterGame').innerText = "Start?";
  132. });
  133. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  134. document.getElementById('enterGame').innerText = "Wanna play";
  135. });$('#itemInfoHolder').css({
  136. 'text-align': 'center',
  137. 'top': '25px',
  138. 'left': '440px',
  139. 'right': '350px',
  140. 'max-width': '350px'
  141. });
  142.  
  143. $('.menuCard').css({
  144. 'white-space': 'normal',
  145. 'text-align': 'center',
  146. 'background-color': 'rgba(0, 0, 0, 0.74)',
  147. '-moz-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  148. '-webkit-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  149. 'box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  150. '-webkit-border-radius': '10px',
  151. '-moz-border-radius': '10px',
  152. 'border-radius': '10px',
  153. 'margin': '15px',
  154. 'margin-top': '15px'
  155. });
  156.  
  157. $('#menuContainer').css({'white-space': 'normal'});
  158.  
  159. $('#mapDisplay').css({
  160. '-webkit-border-radius': '10px',
  161. '-moz-border-radius': '10px',
  162. 'border-radius': '10px'
  163. });
  164.  
  165. $('.menuHeader').css({
  166. 'color': 'rgba(0, 0, 0, 0.5)'
  167. });
  168.  
  169. $('#killCounter').css({
  170. 'color': '#ededed'
  171. });
  172.  
  173. $('#diedText').css({
  174. 'background-color': 'rgb(255, 255, 255)'
  175. });
  176.  
  177. $('#gameCanvas').css({
  178. 'background-color': '#f4f4f4'
  179. });
  180.  
  181. $('#scoreDisplay').css({
  182. 'color': '#e6b800'
  183. });
  184.  
  185.  
  186. $('#leaderboard').css({'-webkit-border-radius': '0px',
  187. '-moz-border-radius': '0px',
  188. 'border-radius': '0px',
  189. 'background-color': 'rgb((255,240,245))',
  190. 'text-align': 'center'});
  191.  
  192. $('#storeTab, #storeHolder, #allianceHolder').css({
  193. '-webkit-border-radius': '10px',
  194. '-moz-border-radius': '10px',
  195. 'border-radius': '10px',
  196. 'background-color': 'rgba(0, 0, 0, 0.4)'
  197. });
  198.  
  199. $('#storeHolder').css({
  200. 'height': '1500px',
  201. 'width': '450px'
  202. });
  203.  
  204. $('.actionBarItem').css({
  205. '-webkit-border-radius': '10px',
  206. 'border-radius': '10px',
  207. 'background-color': 'rgba(0, 0, 0, 0.4)',
  208. 'border-color': '#FF0000',
  209. 'box-shadow': '0 0 10px 0 rgba(255, 0, 0, 0.5)'
  210. });
  211. // pyroz color theme
  212. let nameColor = "#fff";
  213. let enemyNameColor = "#ffffff";
  214. let reloadBarColor = "";
  215. let healthBarColor = "#60478D";
  216. let shameBarColor = "#60478D";
  217. let enemyHealthBarColor = "#782F44";
  218. let damageTextColor = "#782F44";
  219. let healTextColor = "#60478D";
  220. let myObjectHealth = "#5f9ea0";
  221. let enemyObjectHealth = "#ff6363";
  222. let autoPushLine = "#ffffff";
  223.  
  224. document.addEventListener("keydown", function(event) {
  225. if (event.keyCode === 9) {
  226. const chatHolder = document.getElementById("menuChatDiv");
  227. if (chatHolder) {
  228. const currentDisplay = chatHolder.style.display;
  229. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  230. }
  231. }
  232. });
  233. document.addEventListener("keydown", function(event) {
  234. if (event.keyCode === 192) {
  235. const chatHolder = document.getElementById("gameUI");
  236. if (chatHolder) {
  237. const currentDisplay = chatHolder.style.display;
  238. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  239. }
  240. }
  241. });
  242. document.addEventListener("keydown", function(event) {
  243. if (event.keyCode === 99) {
  244. const chatHolder = document.getElementById("gameCanvas");
  245. if (chatHolder) {
  246. const currentDisplay = chatHolder.style.display;
  247. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  248. }
  249. }
  250. });
  251. let circleScale = 1.5
  252. let namechanger = false;
  253. let inantiantibull = false;
  254. let spin = {
  255. degree: 45,
  256. toggle: false,
  257. angle: 0
  258. }
  259. function getEl(id) {
  260. return document.getElementById(id);
  261. }
  262. window.oncontextmenu = function() {
  263. return false;
  264. };
  265. let config = window.config;
  266. config.serverUpdateRate = 9;
  267. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  268. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  269. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  270. "#8bc373", "#91b2db"
  271. ];
  272. config.weaponVariants = [{
  273. id: 0,
  274. src: "",
  275. xp: 0,
  276. val: 1,
  277. }, {
  278. id: 1,
  279. src: "_g",
  280. xp: 3000,
  281. val: 1.1,
  282. }, {
  283. id: 2,
  284. src: "_d",
  285. xp: 7000,
  286. val: 1.18,
  287. }, {
  288. id: 3,
  289. src: "_r",
  290. poison: true,
  291. xp: 12000,
  292. val: 1.18,
  293. }];
  294. config.resetRender = false;
  295. function waitTime(timeout) {
  296. return new Promise((done) => {
  297. setTimeout(() => {
  298. done();
  299. }, timeout);
  300. });
  301. }
  302. let changed = false;
  303. let botSkts = [];
  304. // STORAGE:
  305. let canStore;
  306. if (typeof (Storage) !== "undefined") {
  307. canStore = true;
  308. }
  309. function saveVal(name, val) {
  310. if (canStore)
  311. localStorage.setItem(name, val);
  312. }
  313. function deleteVal(name) {
  314. if (canStore)
  315. localStorage.removeItem(name);
  316. }
  317. function getSavedVal(name) {
  318. if (canStore)
  319. return localStorage.getItem(name);
  320. return null;
  321. }
  322. // CONFIGS:
  323. let gC = function(a, b) {
  324. try {
  325. let res = JSON.parse(getSavedVal(a));
  326. if (typeof res === "object") {
  327. return b;
  328. } else {
  329. return res;
  330. }
  331. } catch (e) {
  332. return b;
  333. }
  334. };
  335. function setConfigs() {
  336. return {
  337. autochat: false,
  338. killChat: true,
  339. autoBuy: true,
  340. autoBuyEquip: true,
  341. autoRespawn: false,
  342. fpsboost: false,
  343. slowOT: false,
  344. attackDir: true,
  345. noDir: false,
  346. showDir: false,
  347. StopSpin: true,
  348. };
  349. }
  350.  
  351. function setconfig2() {
  352. return {
  353. AutoQonHigh: true,
  354. AutoQonSync: true,
  355. SimpleAnti: true,
  356. AntiBowInsta: true,
  357. AutoPlace: true,
  358. AutoReplace: true,
  359. AutoPreplace: false,
  360. AutoSpikeTick: true,
  361. AntiTrap: true,
  362. AutoPredictTick: true,
  363. AntiSpikeTick: true,
  364. AntiTick: false,
  365. spikeTick: true,
  366. CounterInsta: false,
  367. AutoBullSpam: false,
  368. AutoPush: false,
  369. };
  370. }
  371.  
  372. let configs1 = setconfig2();
  373. let configs = setConfigs();
  374.  
  375. window.removeConfigs = function() {
  376. for (let cF in configs && configs1) {
  377. deleteVal(cF, configs && configs1[cF]);
  378. }
  379. };
  380.  
  381. window.removeConfigs1 = function() {
  382. for (let cF in configs1) {
  383. deleteVal(cF, configs1[cF]);
  384. }
  385. };
  386.  
  387. for (let cF in configs) {
  388. configs[cF] = gC(cF, configs[cF]);
  389. }
  390. for (let cF in configs1) {
  391. configs1[cF] = gC(cF, configs1[cF]);
  392. }
  393.  
  394. class HtmlAction {
  395. constructor(element) {
  396. this.element = element;
  397. };
  398. add(code) {
  399. if (!this.element) return undefined;
  400. this.element.innerHTML += code;
  401. };
  402. newLine(amount) {
  403. let result = `<br>`;
  404. if (amount > 0) {
  405. result = ``;
  406. for (let i = 0; i < amount; i++) {
  407. result += `<br>`;
  408. }
  409. }
  410. this.add(result);
  411. };
  412. checkBox(setting) {
  413. let newCheck = `<input type = "checkbox"`;
  414. setting.id && (newCheck += ` id = ${setting.id}`);
  415. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  416. setting.class && (newCheck += ` class = ${setting.class}`);
  417. setting.checked && (newCheck += ` checked`);
  418. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  419. newCheck += `>`;
  420. this.add(newCheck);
  421. };
  422. text(setting) {
  423. let newText = `<input type = "text"`;
  424. setting.id && (newText += ` id = ${setting.id}`);
  425. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  426. setting.class && (newText += ` class = ${setting.class}`);
  427. setting.size && (newText += ` size = ${setting.size}`);
  428. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  429. setting.value && (newText += ` value = ${setting.value}`);
  430. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  431. newText += `>`;
  432. this.add(newText);
  433. };
  434. select(setting) {
  435. let newSelect = `<select`;
  436. setting.id && (newSelect += ` id = ${setting.id}`);
  437. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  438. setting.class && (newSelect += ` class = ${setting.class}`);
  439. newSelect += `>`;
  440. for (let options in setting.option) {
  441. newSelect += `<option value = ${setting.option[options].id}`
  442. setting.option[options].selected && (newSelect += ` selected`);
  443. newSelect += `>${options}</option>`;
  444. }
  445. newSelect += `</select>`;
  446. this.add(newSelect);
  447. };
  448. button(setting) {
  449. let newButton = `<button`;
  450. setting.id && (newButton += ` id = ${setting.id}`);
  451. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  452. setting.class && (newButton += ` class = ${setting.class}`);
  453. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  454. newButton += `>`;
  455. setting.innerHTML && (newButton += setting.innerHTML);
  456. newButton += `</button>`;
  457. this.add(newButton);
  458. };
  459. selectMenu(setting) {
  460. let newSelect = `<select`;
  461. if (!setting.id) {
  462. alert("please put id skid");
  463. return;
  464. }
  465. window[setting.id + "Func"] = function() {};
  466. setting.id && (newSelect += ` id = ${setting.id}`);
  467. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  468. setting.class && (newSelect += ` class = ${setting.class}`);
  469. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  470. newSelect += `>`;
  471. let last;
  472. let i = 0;
  473. for (let options in setting.menu) {
  474. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  475. setting.menu[options] && (newSelect += ` checked`);
  476. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  477. i++;
  478. }
  479. newSelect += `</select>`;
  480.  
  481. this.add(newSelect);
  482.  
  483. i = 0;
  484. for (let options in setting.menu) {
  485. window[options + "Func"] = function() {
  486. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  487. saveVal(options, setting.menu[options]);
  488.  
  489. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  490. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  491.  
  492. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  493.  
  494. };
  495. this.checkBox({
  496. id: "check_" + options,
  497. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  498. class: "checkB",
  499. onclick: `window.${options + "Func"}()`,
  500. checked: setting.menu[options]
  501. });
  502. i++;
  503. }
  504.  
  505. last = "check_" + getEl(setting.id).value.split("_")[1];
  506. window[setting.id + "Func"] = function() {
  507. getEl(last).style.display = "none";
  508. last = "check_" + getEl(setting.id).value.split("_")[1];
  509. getEl(last).style.display = "inline-block";
  510.  
  511. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  512.  
  513. };
  514. };
  515. };
  516. class Html {
  517. constructor() {
  518. this.element = null;
  519. this.action = null;
  520. this.divElement = null;
  521. this.startDiv = function(setting, func) {
  522.  
  523. let newDiv = document.createElement("div");
  524. setting.id && (newDiv.id = setting.id);
  525. setting.style && (newDiv.style = setting.style);
  526. setting.class && (newDiv.className = setting.class);
  527. this.element.appendChild(newDiv);
  528. this.divElement = newDiv;
  529.  
  530. let addRes = new HtmlAction(newDiv);
  531. typeof func == "function" && func(addRes);
  532.  
  533. };
  534. this.addDiv = function(setting, func) {
  535.  
  536. let newDiv = document.createElement("div");
  537. setting.id && (newDiv.id = setting.id);
  538. setting.style && (newDiv.style = setting.style);
  539. setting.class && (newDiv.className = setting.class);
  540. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  541. this.divElement = newDiv;
  542.  
  543. let addRes = new HtmlAction(newDiv);
  544. typeof func == "function" && func(addRes);
  545.  
  546. };
  547. };
  548. set(id) {
  549. this.element = getEl(id);
  550. this.action = new HtmlAction(this.element);
  551. };
  552. resetHTML(text) {
  553. if (text) {
  554. this.element.innerHTML = ``;
  555. } else {
  556. this.element.innerHTML = ``;
  557. }
  558. };
  559. setStyle(style) {
  560. this.element.style = style;
  561. };
  562. setCSS(style) {
  563. this.action.add(`<style>` + style + `</style>`);
  564. };
  565. };
  566.  
  567. let HTML = new Html();
  568.  
  569.  
  570. let nightMode = document.createElement("div");
  571. nightMode.id = "nightMode";
  572. document.body.appendChild(nightMode);
  573. HTML.set("nightMode");
  574. HTML.setStyle(`
  575. display: none;
  576. position: absolute;
  577. pointer-events: none;
  578. background-color: rgb(0, 0, 100);
  579. opacity: 0;
  580. top: 0%;
  581. width: 100%;
  582. height: 100%;
  583. animation-duration: 5s;
  584. animation-name: night2;
  585. `);
  586. HTML.resetHTML();
  587. HTML.setCSS(`
  588. @keyframes night1 {
  589. from {opacity: 0;}
  590. to {opacity: 0.35;}
  591. }
  592. @keyframes night2 {
  593. from {opacity: 0.35;}
  594. to {opacity: 0;}
  595. }
  596. `);
  597. let menuDiv = document.createElement("div");
  598. menuDiv.id = "menuDiv";
  599. document.body.appendChild(menuDiv);
  600. HTML.set("menuDiv");
  601. HTML.setStyle(`
  602. position: absolute;
  603. left: 20px;
  604. top: 20px;
  605. `);
  606. HTML.resetHTML();
  607. HTML.setCSS(`
  608. .menuClass{
  609. color: #fff;
  610. font-size: 31px;
  611. text-align: left;
  612. padding: 10px;
  613. padding-top: 7px;
  614. padding-bottom: 5px;
  615. width: 300px;
  616. background-color: rgba(0, 0, 0, 0.25);
  617. -webkit-border-radius: 6px;
  618. -moz-border-radius: 6px;
  619. border-radius: 6px;
  620. transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out, box-shadow 0.3s ease-in-out, filter 0.4s ease-in-out;
  621. overflow: visible;
  622. filter: blur(5px);
  623. }
  624. .menuClass:hover {
  625. background-color: rgba(0, 0, 0, 0.25);
  626. transform: translateY(-5px) scale(1.05);
  627. filter: none;
  628. }
  629. .menuC {
  630. display: none;
  631. font-family: "Hammersmith One";
  632. font-size: 12px;
  633. max-height: 180px;
  634. overflow-y: scroll;
  635. -webkit-touch-callout: none;
  636. -webkit-user-select: none;
  637. -khtml-user-select: none;
  638. -moz-user-select: none;
  639. -ms-user-select: none;
  640. user-select: none;
  641. }
  642. .menuB {
  643. text-align: center;
  644. background-color: rgb(25, 25, 25);
  645. color: #fff;
  646. -webkit-border-radius: 4px;
  647. -moz-border-radius: 4px;
  648. border-radius: 4px;
  649. border: 2px solid #000;
  650. cursor: pointer;
  651. }
  652. .menuB:hover {
  653. border: 2px solid #fff;
  654. }
  655. .menuB:active {
  656. color: rgb(25, 25, 25);
  657. background-color: rgb(200, 200, 200);
  658. }
  659. .customText {
  660. color: #000;
  661. -webkit-border-radius: 4px;
  662. -moz-border-radius: 4px;
  663. border-radius: 4px;
  664. border: 2px solid #000;
  665. }
  666. .customText:focus {
  667. background-color: yellow;
  668. }
  669. .checkB {
  670. position: relative;
  671. top: 2px;
  672. accent-color: #888;
  673. cursor: pointer;
  674. }
  675. .Cselect {
  676. -webkit-border-radius: 4px;
  677. -moz-border-radius: 4px;
  678. border-radius: 4px;
  679. background-color: rgb(75, 75, 75);
  680. color: #fff;
  681. border: 1px solid #000;
  682. }
  683. #menuChanger {
  684. position: absolute;
  685. right: 10px;
  686. top: 10px;
  687. background-color: rgba(0, 0, 0, 0);
  688. color: #fff;
  689. border: none;
  690. cursor: pointer;
  691. }
  692. #menuChanger:hover {
  693. color: #000;
  694. }
  695. ::-webkit-scrollbar {
  696. width: 10px;
  697. }
  698. ::-webkit-scrollbar-track {
  699. opacity: 0;
  700. }
  701. ::-webkit-scrollbar-thumb {
  702. background-color: rgb(25, 25, 25);
  703. -webkit-border-radius: 4px;
  704. -moz-border-radius: 4px;
  705. border-radius: 4px;
  706. }
  707. ::-webkit-scrollbar-thumb:active {
  708. background-color: rgb(230, 230, 230);
  709. }
  710. `);
  711. HTML.startDiv({ id: "menuHeadLine", class: "menuClass" }, (html) => {
  712. html.button({ id: "menuChanger", class: "material-icons", innerHTML: `sync`, onclick: "window.changeMenu()" });
  713. HTML.addDiv({ id: "menuButtons", style: "display: block; overflow-y: visible;", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  714. html.button({ class: "menuB", innerHTML: "fix broken mod", onclick: "window.debug()" });
  715. html.button({ class: "menuB", innerHTML: "dark mode", onclick: "window.toggleNight()" });
  716. html.newLine();
  717. });
  718. HTML.addDiv({ id: "menuMain", style: "display: block", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  719. HTML.addDiv({ style: "font-size: 20px; color: #99ee99;", appendID: "menuMain" }, (html) => {
  720. html.add(`wats combat and other stuff`);
  721. });
  722. html.add(`Misc: `);
  723. html.selectMenu({ id: "configsChanger", class: "Cselect", menu: configs });
  724. html.newLine();
  725. html.add(`v1: `);
  726. html.selectMenu({ id: "configsChanger1", class: "Cselect", menu: configs1 });
  727. html.newLine();
  728. html.add(`AntiBull Type: `);
  729. html.select({
  730. id: "antiBullType", class: "Cselect", option: {
  731. "Disable AntiBull": {
  732. id: "noab",
  733. selected: true,
  734. },
  735. "When Reloaded": {
  736. id: "abreload",
  737. },
  738. "Primary Reloaded": {
  739. id: "abalway",
  740. }
  741. }
  742. });
  743. html.newLine();
  744. html.add(`Insta-Type: `);
  745. html.select({
  746. id: "instaType", class: "Cselect", option: {
  747. Normal: {
  748. id: "oneShot",
  749. selected: true
  750. },
  751. RevInsta: {
  752. id: "revTick",
  753. },
  754. Spammer: {
  755. id: "spammer"
  756. },
  757. }
  758. });
  759. html.newLine();
  760. html.add(`AutoOneFrame: `);
  761. html.checkBox({ id: "oneframe", class: "checkB", checked: false });
  762. html.newLine();
  763. html.add(`BackupNoBull: `);
  764. html.checkBox({ id: "backupNobull", class: "checkB", checked: false });
  765. html.newLine();
  766. html.add(`T^G Assist: `);
  767. html.checkBox({ id: "turretCombat", class: "checkB", checked: true });
  768. html.newLine();
  769. html.add(`Grind: `);
  770. html.checkBox({ id: "weaponGrind", class: "checkB", onclick: "window.startGrind()" });
  771. html.newLine();
  772. });
  773. HTML.addDiv({ id: "menuConfig", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  774. HTML.addDiv({ style: "font-size: 20px; color: #99ee99;", appendID: "menuConfig" }, (html) => {
  775. html.add(`wats weird visualsj`);
  776. });
  777. html.add(`Visuals: `);
  778. html.select({
  779. id: "visualType", class: "Cselect", option: {
  780. "Normal visuals": {
  781. id: "simp1",
  782. },
  783. "Advanced visuals": {
  784. id: "simp2",
  785. },
  786. }
  787. });
  788. html.newLine();
  789. html.add(`Render Place Type: `);
  790. html.select({
  791. id: "renderplace",
  792. class: "Cselect",
  793. option: {
  794. disable: {
  795. id: "disable",
  796. },
  797. Show: {
  798. id: "placeVis",
  799. selected: true
  800. },
  801. OutLine: {
  802. id: "outline"
  803. },
  804. }
  805. });
  806. html.newLine();
  807. html.add(`BuildingHealth: `);
  808. html.select({
  809. id: "bh", class: "Cselect", option: {
  810. "Disable": {
  811. id: "0",
  812. },
  813. "Circle": {
  814. id: "1",
  815. selected: true
  816. },
  817. "Rectangle": {
  818. id: "2"
  819. }
  820. }
  821. });
  822. html.newLine();
  823. html.add('Vision-stuff: ');
  824. html.select({
  825. id: "vision",
  826. class: "Cselect",
  827. option: {
  828. '1': {
  829. id: "1",
  830. selected: true
  831. },
  832. '1.1': {
  833. id: "1.1",
  834. },
  835. '1.2': {
  836. id: "1.2",
  837. },
  838. '1.3': {
  839. id: "1.3",
  840. },
  841. '1.4': {
  842. id: "1.4",
  843. },
  844. '1.5': {
  845. id: "1.5",
  846. },
  847. '2': {
  848. id: "2",
  849. }
  850. }
  851. })
  852. html.newLine();
  853. html.add('CameraSped: ');
  854. html.select({
  855. id: "camera", class: "Cselect", option: {
  856. 'FCam': {
  857. id: 'Cam+',
  858. },
  859. 'Normal': {
  860. id: 'Cam1',
  861. selected: true
  862. },
  863. 'medium': {
  864. id: 'Cam2',
  865. },
  866. 'Smooth': {
  867. id: 'Cam3',
  868. },
  869. }
  870. });
  871. html.newLine();
  872. html.add(`Predict-Move: `);
  873. html.select({
  874. id: "predictType", class: "Cselect", option: {
  875. "Disable": {
  876. id: "disableRender",
  877. selected: true
  878. },
  879. "X/Y and 2": {
  880. id: "pre2",
  881. },
  882. "X/Y and 3": {
  883. id: "pre3"
  884. }
  885. }
  886. });
  887. html.newLine();
  888. html.add(`Grids?: `);
  889. html.checkBox({ id: "gridsa", class: "checkB", checked: false });
  890. });
  891. HTML.addDiv({ id: "menuOther", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  892. html.button({ class: "menuB", innerHTML: "Connect Bots", onclick: "window.tryConnectBots()" });
  893. html.button({ class: "menuB", innerHTML: "Disconnect Bots", onclick: "window.destroyBots()" });
  894.  
  895. html.newLine();
  896. html.add(`Socket Bots Mode: `);
  897. html.select({
  898. id: "mode",
  899. class: "Cselect",
  900. option: {
  901. "Stop": {
  902. id: "stopp",
  903. selected: false
  904. },
  905.  
  906. "Stop": {
  907. id: "mouse",
  908. selected: false
  909. },
  910. "Clear Building": {
  911. id: "clear",
  912. selected: false
  913. },
  914. "Mylee rush": {
  915. id: "fight",
  916. selected: false
  917. },
  918. "Sync": {
  919. id: "zync",
  920. selected: true
  921. },
  922. "Search": {
  923. id: "zearch"
  924. },
  925. "Clear Everything": {
  926. id: "fuckemup"
  927. },
  928. "Flex": {
  929. id: "flex"
  930. }
  931. }
  932. });
  933. html.newLine();
  934. html.button({ class: "menuB", innerHTML: "Connect FBots", onclick: "window.connectFillBots()" });
  935. html.button({ class: "menuB", innerHTML: "Disconnect FBots", onclick: "window.destroyFillBots()" });
  936. html.newLine();
  937. html.button({ class: "menuB", innerHTML: "Reset Break Objects", onclick: "window.resBuild()" });
  938. html.newLine();
  939. html.add(`Break Objects Range: `);
  940. html.text({ id: "breakRange", class: "customText", value: "700", size: "3em", maxLength: "4" });
  941. html.newLine();
  942. html.add(`Predict Movement Type: `);
  943.  
  944. html.newLine(2);
  945. html.button({ class: "menuB", innerHTML: "Toggle Fbots Circle", onclick: "window.toggleBotsCircle()" });
  946. html.newLine();
  947. html.add(`Circle Rad: `);
  948. html.text({ id: "circleRad", class: "customText", value: "200", size: "3em", maxLength: "4" });
  949. html.newLine();
  950. html.add(`Rad Speed: `);
  951. html.text({ id: "radSpeed", class: "customText", value: "0.1", size: "2em", maxLength: "3" });
  952. html.newLine(2);
  953. html.add(`Cross World: `);
  954. html.checkBox({ id: "funni", class: "checkB" });
  955. html.newLine();
  956. html.button({ class: "menuB", innerHTML: "Toggle Another Visual", onclick: "window.toggleVisual()" });
  957. html.newLine();
  958. });
  959. });
  960. let menuChatDiv = document.createElement("div");
  961. menuChatDiv.id = "menuChatDiv";
  962. document.body.appendChild(menuChatDiv);
  963. HTML.set("menuChatDiv");
  964. HTML.setStyle(`
  965. position: absolute;
  966. display: none;
  967. left: 0px;
  968. top: 0px;
  969. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0); //0.65
  970. `);
  971. HTML.resetHTML();
  972. HTML.setCSS(`
  973. .chDiv{
  974. color: #fff;
  975. padding: 10px;
  976. width: 400px;
  977. height: 250px;
  978. background-color: rgba(0, 0, 0, 0); //0.35
  979. }
  980. .chMainDiv{
  981. font-family: "Ubuntu";
  982. font-size: 16px;
  983. max-height: 215px;
  984. -webkit-touch-callout: none;
  985. -webkit-user-select: none;
  986. -khtml-user-select: none;
  987. -moz-user-select: none;
  988. -ms-user-select: none;
  989. user-select: none;
  990. overflow-x: hidden;
  991. }
  992. .chMainBox{
  993. position: absolute;
  994. left: 10px;
  995. bottom: 10px;
  996. width: 335px;
  997. height: 25px;
  998. background-color: rgba(255, 255, 255, 0);
  999. -webkit-border-radius: 4px;
  1000. -moz-border-radius: 4px;
  1001. border-radius: 4px;
  1002. color: rgba(255, 255, 255, 0);
  1003. font-family: "Arial";
  1004. font-size: 12px;
  1005. border: none;
  1006. outline: none;
  1007. }
  1008. `);
  1009. HTML.startDiv({id: "mChDiv", class: "chDiv"}, (html) => {
  1010. HTML.addDiv({id: "mChMain", class: "chMainDiv", appendID: "mChDiv"}, (html) => {
  1011. });
  1012. html.text({id: "mChBox", class: "chMainBox", placeHolder: ``});
  1013. });
  1014. let menuChats = getEl("mChMain");
  1015. let menuChatBox = getEl("mChBox");
  1016. let menuCBFocus = false;
  1017. let menuChCounts = 0;
  1018.  
  1019. function addChatLog(e, c, d, v) {
  1020. HTML.set("menuChatDiv");
  1021. let chatLogs = document.getElementById("mChMain");
  1022. const now = new Date();
  1023. const hours = now.getHours();
  1024. const minutes = now.getMinutes();
  1025. const ampm = hours >= 12 ? 'PM' : 'AM';
  1026. const formattedHours = (hours % 12 || 12).toString();
  1027. const formattedMinutes = minutes.toString().padStart(2, '0');
  1028. let time = `${formattedHours}:${formattedMinutes} ${ampm}`;
  1029.  
  1030. let a = document.createElement('div');
  1031. a.className = 'chatEntry';
  1032.  
  1033. let timeSpan = document.createElement('span');
  1034. timeSpan.style.color = 'rgba(255, 255, 255, 0.5)';
  1035. timeSpan.innerText = `${time}`;
  1036. a.appendChild(timeSpan);
  1037.  
  1038. let namething = document.createElement('span');
  1039. namething.style.color = v;
  1040. namething.innerText = ' ' + d;
  1041. a.appendChild(namething);
  1042.  
  1043. let chatSpan = document.createElement('span');
  1044. chatSpan.style.color = c;
  1045. chatSpan.innerText = ' ' + e;
  1046. a.appendChild(chatSpan);
  1047.  
  1048. chatLogs.appendChild(a);
  1049. chatLogs.scrollTop = chatLogs.scrollHeight;
  1050. }
  1051. let menuIndex = 0;
  1052. let menus = ["menuMain", "menuConfig", "menuOther"];
  1053. window.changeMenu = function() {
  1054. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1055. menuIndex++;
  1056. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1057. };
  1058. let mStatus = document.createElement("div");
  1059. mStatus.id = "status";
  1060. getEl("gameUI").appendChild(mStatus);
  1061. HTML.set("status");
  1062. HTML.setStyle(`
  1063. display: block;
  1064. position: absolute;
  1065. color: #ddd;
  1066. font: 15px Hammersmith One;
  1067. bottom: 215px;
  1068. left: 20px;
  1069. `);
  1070. HTML.resetHTML();
  1071. HTML.setCSS(`
  1072. .sizing {
  1073. font-size: 15px;
  1074. }
  1075. .mod {
  1076. font-size: 15px;
  1077. display: inline-block;
  1078. }
  1079. `);
  1080. HTML.startDiv({ id: "uehmod", class: "sizing" }, (html) => {
  1081. html.add(`Ping: `);
  1082. HTML.addDiv({ id: "pingFps", class: "mod", appendID: "uehmod" }, (html) => {
  1083. html.add("None");
  1084. });
  1085. html.newLine();
  1086. html.add(`Packet: `);
  1087. HTML.addDiv({ id: "packetStatus", class: "mod", appendID: "uehmod" }, (html) => {
  1088. html.add("None");
  1089. });
  1090. });
  1091. let openMenu = false;
  1092. let WS = undefined;
  1093. let socketID = undefined;
  1094. let secPacket = 0;
  1095. let secMax = 110;
  1096. let secTime = 1000;
  1097. let firstSend = {
  1098. sec: false
  1099. };
  1100. let game = {
  1101. tick: 0,
  1102. tickQueue: [],
  1103. tickBase: function(set, tick) {
  1104. if (this.tickQueue[this.tick + tick]) {
  1105. this.tickQueue[this.tick + tick].push(set);
  1106. } else {
  1107. this.tickQueue[this.tick + tick] = [set];
  1108. }
  1109. },
  1110. tickRate: (1000 / config.serverUpdateRate),
  1111. tickSpeed: 0,
  1112. lastTick: performance.now()
  1113. };
  1114. let modConsole = [];
  1115. let dontSend = false;
  1116. let fpsTimer = {
  1117. last: 0,
  1118. time: 0,
  1119. ltime: 0
  1120. }
  1121. let lastMoveDir = undefined;
  1122. let lastsp = ["cc", 1, "__proto__"];
  1123. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1124. WebSocket.prototype.send = function(message) {
  1125. if (!WS) {
  1126. WS = this;
  1127. WS.addEventListener("message", function(msg) {
  1128. getMessage(msg);
  1129. });
  1130. WS.addEventListener("close", (event) => {
  1131. if (event.code == 4001) {
  1132. window.location.reload();
  1133. }
  1134. });
  1135. }
  1136. if (WS == this) {
  1137. dontSend = false;
  1138. // EXTRACT DATA ARRAY:
  1139. let data = new Uint8Array(message);
  1140. let parsed = window.msgpack.decode(data);
  1141. let type = parsed[0];
  1142. data = parsed[1];
  1143. // SEND MESSAGE:
  1144. if (type == "6") {
  1145. if (data[0]) {
  1146. 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"];
  1147. let tmpString;
  1148. profanity.forEach((profany) => {
  1149. if (data[0].indexOf(profany) > -1) {
  1150. tmpString = "";
  1151. for (let i = 0; i < profany.length; ++i) {
  1152. if (i == 1) {
  1153. tmpString += String.fromCharCode(0);
  1154. }
  1155. tmpString += profany[i];
  1156. }
  1157. let re = new RegExp(profany, "g");
  1158. data[0] = data[0].replace(re, tmpString);
  1159. }
  1160. });
  1161. data[0] = data[0].slice(0, 30);
  1162. }
  1163. } else if (type == "L") {
  1164. // MAKE SAME CLAN:
  1165. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1166. data[0] = data[0].slice(0, 7);
  1167. } else if (type == "M") {
  1168. // APPLY CYAN COLOR:
  1169. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1170. data[0].moofoll = true;
  1171. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1172. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1173. } else if (type == "D") {
  1174. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1175. dontSend = true;
  1176. } else {
  1177. my.lastDir = data[0];
  1178. }
  1179. } else if (type == "d") {
  1180. if (!data[2]) {
  1181. dontSend = true;
  1182. } else {
  1183. if (![null, undefined].includes(data[1])) {
  1184. my.lastDir = data[1];
  1185. }
  1186. }
  1187. } else if (type == "K") {
  1188. if (!data[1]) {
  1189. dontSend = true;
  1190. }
  1191. } else if (type == "14") {
  1192. instaC.wait = !instaC.wait;
  1193. dontSend = true;
  1194. } else if (type == "a") {
  1195. if (data[1]) {
  1196. if (player.moveDir == data[0]) {
  1197. dontSend = true;
  1198. }
  1199. player.moveDir = data[0];
  1200. } else {
  1201. dontSend = true;
  1202. }
  1203. }
  1204. if (!dontSend) {
  1205. let binary = window.msgpack.encode([type, data]);
  1206. this.nsend(binary);
  1207. // START COUNT:
  1208. if (!firstSend.sec) {
  1209. firstSend.sec = true;
  1210. setTimeout(() => {
  1211. firstSend.sec = false;
  1212. secPacket = 0;
  1213. }, secTime);
  1214. }
  1215. secPacket++;
  1216. }
  1217. } else {
  1218. this.nsend(message);
  1219. }
  1220. }
  1221. function packet(type) {
  1222. // EXTRACT DATA ARRAY:
  1223. let data = Array.prototype.slice.call(arguments, 1);
  1224. // SEND MESSAGE:
  1225. let binary = window.msgpack.encode([type, data]);
  1226. WS.send(binary);
  1227. }
  1228. function getMessage(message) {
  1229. let data = new Uint8Array(message.data);
  1230. let parsed = window.msgpack.decode(data);
  1231. let type = parsed[0];
  1232. data = parsed[1];
  1233. let events = {
  1234. A: setInitData,
  1235. //B: disconnect,
  1236. C: setupGame,
  1237. D: addPlayer,
  1238. E: removePlayer,
  1239. a: updatePlayers,
  1240. G: updateLeaderboard,
  1241. H: loadGameObject,
  1242. I: loadAI,
  1243. J: animateAI,
  1244. K: gatherAnimation,
  1245. L: wiggleGameObject,
  1246. M: shootTurret,
  1247. N: updatePlayerValue,
  1248. O: updateHealth,
  1249. P: killPlayer,
  1250. Q: killObject,
  1251. R: killObjects,
  1252. S: updateItemCounts,
  1253. T: updateAge,
  1254. U: updateUpgrades,
  1255. V: updateItems,
  1256. X: addProjectile,
  1257. Y: remProjectile,
  1258. //Z: serverShutdownNotice,
  1259. //0: addAlliance,
  1260. //1: deleteAlliance,
  1261. 2: allianceNotification,
  1262. 3: setPlayerTeam,
  1263. 4: setAlliancePlayers,
  1264. 5: updateStoreItems,
  1265. 6: receiveChat,
  1266. 7: updateMinimap,
  1267. 8: showText,
  1268. 9: pingMap,
  1269. //0: pingSocketResponse,
  1270. };
  1271. if (type == "io-init") {
  1272. socketID = data[0];
  1273. } else {
  1274. if (events[type]) {
  1275. events[type].apply(undefined, data);
  1276. }
  1277. }
  1278. }
  1279. // MATHS:
  1280. Math.lerpAngle = function(value1, value2, amount) {
  1281. let difference = Math.abs(value2 - value1);
  1282. if (difference > Math.PI) {
  1283. if (value1 > value2) {
  1284. value2 += Math.PI * 2;
  1285. } else {
  1286. value1 += Math.PI * 2;
  1287. }
  1288. }
  1289. let value = value2 + ((value1 - value2) * amount);
  1290. if (value >= 0 && value <= Math.PI * 2) return value;
  1291. return value % (Math.PI * 2);
  1292. };
  1293. // REOUNDED RECTANGLE:
  1294. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1295. if (w < 2 * r) r = w / 2;
  1296. if (h < 2 * r) r = h / 2;
  1297. if (r < 0)
  1298. r = 0;
  1299. this.beginPath();
  1300. this.moveTo(x + r, y);
  1301. this.arcTo(x + w, y, x + w, y + h, r);
  1302. this.arcTo(x + w, y + h, x, y + h, r);
  1303. this.arcTo(x, y + h, x, y, r);
  1304. this.arcTo(x, y, x + w, y, r);
  1305. this.closePath();
  1306. return this;
  1307. };
  1308. // GLOBAL VALUES:
  1309. let allChats = [];
  1310. let ais = [];
  1311. let inWater = false
  1312. let players = [];
  1313. let alliances = [];
  1314. let alliancePlayers = [];
  1315. let allianceNotifications = [];
  1316. let gameObjects = [];
  1317. let projectiles = [];
  1318. let deadPlayers = [];
  1319. let breakObjects = [];
  1320. let player;
  1321. let playerSID;
  1322. let tmpObj;
  1323. let enemy = [];
  1324. //let perfectReplace = [];
  1325. let nears = [];
  1326. let near = [];
  1327. let rKeyPressed = false
  1328. let my = {
  1329. reloaded: false,
  1330. waitHit: 0,
  1331. autoAim: false,
  1332. revAim: false,
  1333. ageInsta: true,
  1334. reSync: false,
  1335. bullTick: 0,
  1336. anti0Tick: 0,
  1337. antiSync: false,
  1338. safePrimary: function(tmpObj) {
  1339. return [0, 8].includes(tmpObj.primaryIndex);
  1340. },
  1341. safeSecondary: function(tmpObj) {
  1342. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1343. },
  1344. lastDir: 0,
  1345. autoPush: false,
  1346. pushData: {}
  1347. }
  1348. // FIND OBJECTS BY ID/SID:
  1349. function findID(tmpObj, tmp) {
  1350. return tmpObj.find((THIS) => THIS.id == tmp);
  1351. }
  1352. function findSID(tmpObj, tmp) {
  1353. return tmpObj.find((THIS) => THIS.sid == tmp);
  1354. }
  1355. function findPlayerByID(id) {
  1356. return findID(players, id);
  1357. }
  1358. function findPlayerBySID(sid) {
  1359. return findSID(players, sid);
  1360. }
  1361. function findAIBySID(sid) {
  1362. return findSID(ais, sid);
  1363. }
  1364. function findObjectBySid(sid) {
  1365. return findSID(gameObjects, sid);
  1366. }
  1367. function findProjectileBySid(sid) {
  1368. return findSID(gameObjects, sid);
  1369. }
  1370. let gameName = getEl("gameName");
  1371. let adCard = getEl("adCard");
  1372. //adCard.remove();
  1373. let promoImageHolder = getEl("promoImgHolder");
  1374. promoImageHolder.remove();
  1375. let chatButton = getEl("chatButton");
  1376. chatButton.remove();
  1377. let gameCanvas = getEl("gameCanvas");
  1378. let mainContext = gameCanvas.getContext("2d");
  1379. let mapDisplay = getEl("mapDisplay");
  1380. let mapContext = mapDisplay.getContext("2d");
  1381. mapDisplay.width = 300;
  1382. mapDisplay.height = 300;
  1383. let storeMenu = getEl("storeMenu");
  1384. let storeHolder = getEl("storeHolder");
  1385. let upgradeHolder = getEl("upgradeHolder");
  1386. let upgradeCounter = getEl("upgradeCounter");
  1387. let chatBox = getEl("chatBox");
  1388. chatBox.autocomplete = "off";
  1389. chatBox.style.textAlign = "center";
  1390. chatBox.style.width = "18em";
  1391. let chatHolder = getEl("chatHolder");
  1392. let actionBar = getEl("actionBar");
  1393. let leaderboardData = getEl("leaderboardData");
  1394. let itemInfoHolder = getEl("itemInfoHolder");
  1395. let menuCardHolder = getEl("menuCardHolder");
  1396. let mainMenu = getEl("mainMenu");
  1397. let diedText = getEl("diedText");
  1398. let screenWidth;
  1399. let screenHeight;
  1400. let maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1401. let maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1402.  
  1403. function zoomVision() {
  1404. if (maxScreenWidth != config.maxScreenWidth * 1.5 || maxScreenHeight != config.maxScreenHeight * 1.5) {
  1405. maxScreenWidth = config.maxScreenWidth * 1.5;
  1406. maxScreenHeight = config.maxScreenHeight * 1.5;
  1407. resize();
  1408. }
  1409. }
  1410. function resetZoom() {
  1411. if (maxScreenWidth != config.maxScreenWidth * parseFloat(getEl("vision").value) || maxScreenHeight != config.maxScreenHeight * parseFloat(getEl("vision").value)) {
  1412. maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1413. maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1414. resize();
  1415. }
  1416. }
  1417. getEl("vision").onchange = function() {
  1418. resetZoom();
  1419. }
  1420. let pixelDensity = 1;
  1421. let delta;
  1422. let now;
  1423. let lastUpdate = performance.now();
  1424. let camX;
  1425. let camY;
  1426. let tmpDir;
  1427. let mouseX = 0;
  1428. let mouseY = 0;
  1429. let allianceMenu = getEl("allianceMenu");
  1430. let waterMult = 1;
  1431. let waterPlus = 0;
  1432. let outlineColor = "#525252";
  1433. let darkOutlineColor = "#3d3f42";
  1434. let outlineWidth = 5.5;
  1435. let isNight = false;
  1436. let firstSetup = true;
  1437. let keys = {};
  1438. let moveKeys = {
  1439. 87: [0, -1],
  1440. 38: [0, -1],
  1441. 83: [0, 1],
  1442. 40: [0, 1],
  1443. 65: [-1, 0],
  1444. 37: [-1, 0],
  1445. 68: [1, 0],
  1446. 39: [1, 0],
  1447. };
  1448. function resetMoveDir() {
  1449. keys = {};
  1450. packet("e");
  1451. }
  1452. let attackState = 0;
  1453. let inGame = false;
  1454. let macro = {};
  1455. let mills = {
  1456. place: 0,
  1457. placeSpawnPads: 0
  1458. };
  1459. let lastDir;
  1460. let lastLeaderboardData = [];
  1461. // ON LOAD:
  1462. let inWindow = true;
  1463. window.onblur = function() {
  1464. inWindow = false;
  1465. };
  1466. window.onfocus = function() {
  1467. inWindow = true;
  1468. if (player && player.alive) {
  1469. resetMoveDir();
  1470. }
  1471. };
  1472. let placeVisible = [];
  1473. let preplaceVisible = [];
  1474. let profanityList = [/*"cunt", "whore", "fuck", "shit", "faggot", "nigger",
  1475. "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex",
  1476. "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune",
  1477. "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard"*/];
  1478. /** CLASS CODES */
  1479. class Utils {
  1480. constructor() {
  1481. // MATH UTILS:
  1482. let mathABS = Math.abs,
  1483. mathCOS = Math.cos,
  1484. mathSIN = Math.sin,
  1485. mathPOW = Math.pow,
  1486. mathSQRT = Math.sqrt,
  1487. mathATAN2 = Math.atan2,
  1488. mathPI = Math.PI;
  1489. let _this = this;
  1490. // GLOBAL UTILS:
  1491. this.round = function(n, v) {
  1492. return Math.round(n * v) / v;
  1493. };
  1494. this.toRad = function(angle) {
  1495. return angle * (mathPI / 180);
  1496. };
  1497. this.toAng = function(radian) {
  1498. return radian / (mathPI / 180);
  1499. };
  1500. this.randInt = function(min, max) {
  1501. return Math.floor(Math.random() * (max - min + 1)) + min;
  1502. };
  1503. this.randFloat = function(min, max) {
  1504. return Math.random() * (max - min + 1) + min;
  1505. };
  1506. this.lerp = function(value1, value2, amount) {
  1507. return value1 + (value2 - value1) * amount;
  1508. };
  1509. this.decel = function(val, cel) {
  1510. if (val > 0)
  1511. val = Math.max(0, val - cel);
  1512. else if (val < 0)
  1513. val = Math.min(0, val + cel);
  1514. return val;
  1515. };
  1516. this.getDistance = function(x1, y1, x2, y2) {
  1517. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1518. };
  1519. this.getDist = function(tmp1, tmp2, type1, type2) {
  1520. let tmpXY1 = {
  1521. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1522. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1523. };
  1524. let tmpXY2 = {
  1525. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1526. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1527. };
  1528. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1529. };
  1530. this.getDirection = function(x1, y1, x2, y2) {
  1531. return mathATAN2(y1 - y2, x1 - x2);
  1532. };
  1533. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1534. let tmpXY1 = {
  1535. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1536. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1537. };
  1538. let tmpXY2 = {
  1539. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1540. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1541. };
  1542. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1543. };
  1544. this.getAngleDist = function(a, b) {
  1545. let p = mathABS(b - a) % (mathPI * 2);
  1546. return (p > mathPI ? (mathPI * 2) - p : p);
  1547. };
  1548. this.isNumber = function(n) {
  1549. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1550. };
  1551. this.isString = function(s) {
  1552. return (s && typeof s == "string");
  1553. };
  1554. this.kFormat = function(num) {
  1555. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1556. };
  1557. this.sFormat = function(num) {
  1558. let fixs = [
  1559. { num: 1e3, string: "k" },
  1560. { num: 1e6, string: "m" },
  1561. { num: 1e9, string: "b" },
  1562. { num: 1e12, string: "q" }
  1563. ].reverse();
  1564. let sp = fixs.find(v => num >= v.num);
  1565. if (!sp) return num;
  1566. return (num / sp.num).toFixed(1) + sp.string;
  1567. };
  1568. this.capitalizeFirst = function(string) {
  1569. return string.charAt(0).toUpperCase() + string.slice(1);
  1570. };
  1571. this.fixTo = function(n, v) {
  1572. return parseFloat(n.toFixed(v));
  1573. };
  1574. this.sortByPoints = function(a, b) {
  1575. return parseFloat(b.points) - parseFloat(a.points);
  1576. };
  1577. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1578. let minX = x1;
  1579. let maxX = x2;
  1580. if (x1 > x2) {
  1581. minX = x2;
  1582. maxX = x1;
  1583. }
  1584. if (maxX > recX2)
  1585. maxX = recX2;
  1586. if (minX < recX)
  1587. minX = recX;
  1588. if (minX > maxX)
  1589. return false;
  1590. let minY = y1;
  1591. let maxY = y2;
  1592. let dx = x2 - x1;
  1593. if (Math.abs(dx) > 0.0000001) {
  1594. let a = (y2 - y1) / dx;
  1595. let b = y1 - a * x1;
  1596. minY = a * minX + b;
  1597. maxY = a * maxX + b;
  1598. }
  1599. if (minY > maxY) {
  1600. let tmp = maxY;
  1601. maxY = minY;
  1602. minY = tmp;
  1603. }
  1604. if (maxY > recY2)
  1605. maxY = recY2;
  1606. if (minY < recY)
  1607. minY = recY;
  1608. if (minY > maxY)
  1609. return false;
  1610. return true;
  1611. };
  1612. this.containsPoint = function(element, x, y) {
  1613. let bounds = element.getBoundingClientRect();
  1614. let left = bounds.left + window.scrollX;
  1615. let top = bounds.top + window.scrollY;
  1616. let width = bounds.width;
  1617. let height = bounds.height;
  1618. let insideHorizontal = x > left && x < left + width;
  1619. let insideVertical = y > top && y < top + height;
  1620. return insideHorizontal && insideVertical;
  1621. };
  1622. this.mousifyTouchEvent = function(event) {
  1623. let touch = event.changedTouches[0];
  1624. event.screenX = touch.screenX;
  1625. event.screenY = touch.screenY;
  1626. event.clientX = touch.clientX;
  1627. event.clientY = touch.clientY;
  1628. event.pageX = touch.pageX;
  1629. event.pageY = touch.pageY;
  1630. };
  1631. this.hookTouchEvents = function(element, skipPrevent) {
  1632. let preventDefault = !skipPrevent;
  1633. let isHovering = false;
  1634. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1635. let passive = false;
  1636. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1637. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1638. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1639. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1640. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1641. function touchStart(e) {
  1642. _this.mousifyTouchEvent(e);
  1643. window.setUsingTouch(true);
  1644. if (preventDefault) {
  1645. e.preventDefault();
  1646. e.stopPropagation();
  1647. }
  1648. if (element.onmouseover)
  1649. element.onmouseover(e);
  1650. isHovering = true;
  1651. }
  1652. function touchMove(e) {
  1653. _this.mousifyTouchEvent(e);
  1654. window.setUsingTouch(true);
  1655. if (preventDefault) {
  1656. e.preventDefault();
  1657. e.stopPropagation();
  1658. }
  1659. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1660. if (!isHovering) {
  1661. if (element.onmouseover)
  1662. element.onmouseover(e);
  1663. isHovering = true;
  1664. }
  1665. } else {
  1666. if (isHovering) {
  1667. if (element.onmouseout)
  1668. element.onmouseout(e);
  1669. isHovering = false;
  1670. }
  1671. }
  1672. }
  1673. function touchEnd(e) {
  1674. _this.mousifyTouchEvent(e);
  1675. window.setUsingTouch(true);
  1676. if (preventDefault) {
  1677. e.preventDefault();
  1678. e.stopPropagation();
  1679. }
  1680. if (isHovering) {
  1681. if (element.onclick)
  1682. element.onclick(e);
  1683. if (element.onmouseout)
  1684. element.onmouseout(e);
  1685. isHovering = false;
  1686. }
  1687. }
  1688. };
  1689. this.removeAllChildren = function(element) {
  1690. while (element.hasChildNodes()) {
  1691. element.removeChild(element.lastChild);
  1692. }
  1693. };
  1694. this.generateElement = function(config) {
  1695. let element = document.createElement(config.tag || "div");
  1696. function bind(configValue, elementValue) {
  1697. if (config[configValue])
  1698. element[elementValue] = config[configValue];
  1699. }
  1700. bind("text", "textContent");
  1701. bind("html", "innerHTML");
  1702. bind("class", "className");
  1703. for (let key in config) {
  1704. switch (key) {
  1705. case "tag":
  1706. case "text":
  1707. case "html":
  1708. case "class":
  1709. case "style":
  1710. case "hookTouch":
  1711. case "parent":
  1712. case "children":
  1713. continue;
  1714. default:
  1715. break;
  1716. }
  1717. element[key] = config[key];
  1718. }
  1719. if (element.onclick)
  1720. element.onclick = this.checkTrusted(element.onclick);
  1721. if (element.onmouseover)
  1722. element.onmouseover = this.checkTrusted(element.onmouseover);
  1723. if (element.onmouseout)
  1724. element.onmouseout = this.checkTrusted(element.onmouseout);
  1725. if (config.style) {
  1726. element.style.cssText = config.style;
  1727. }
  1728. if (config.hookTouch) {
  1729. this.hookTouchEvents(element);
  1730. }
  1731. if (config.parent) {
  1732. config.parent.appendChild(element);
  1733. }
  1734. if (config.children) {
  1735. for (let i = 0; i < config.children.length; i++) {
  1736. element.appendChild(config.children[i]);
  1737. }
  1738. }
  1739. return element;
  1740. };
  1741. this.checkTrusted = function(callback) {
  1742. return function(ev) {
  1743. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1744. callback(ev);
  1745. } else {
  1746. //console.error("Event is not trusted.", ev);
  1747. }
  1748. };
  1749. };
  1750. this.randomString = function(length) {
  1751. let text = "";
  1752. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1753. for (let i = 0; i < length; i++) {
  1754. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1755. }
  1756. return text;
  1757. };
  1758. this.countInArray = function(array, val) {
  1759. let count = 0;
  1760. for (let i = 0; i < array.length; i++) {
  1761. if (array[i] === val) count++;
  1762. }
  1763. return count;
  1764. };
  1765. this.hexToRgb = function(hex) {
  1766. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1767. };
  1768. this.getRgb = function(r, g, b) {
  1769. return [r / 255, g / 255, b / 255].join(", ");
  1770. };
  1771. }
  1772. };
  1773. class Animtext {
  1774. // ANIMATED TEXT:
  1775. constructor() {
  1776. // INIT:
  1777. this.init = function(x, y, scale, speed, life, text, color) {
  1778. this.x = x;
  1779. this.y = y;
  1780. this.color = color;
  1781. this.scale = scale;
  1782. this.startScale = this.scale;
  1783. this.maxScale = scale * 1.5;
  1784. this.scaleSpeed = 0.7;
  1785. this.speed = speed;
  1786. this.life = life;
  1787. this.text = text;
  1788. this.acc = 1;
  1789. this.alpha = 0;
  1790. this.maxLife = life;
  1791. this.ranX = UTILS.randFloat(-1, 1);
  1792. };
  1793. // UPDATE:
  1794. this.update = function(delta) {
  1795. if (this.life) {
  1796. this.life -= delta;
  1797. this.y -= this.speed * delta;
  1798. this.scale += this.scaleSpeed * delta;
  1799. if (this.scale >= this.maxScale) {
  1800. this.scale = this.maxScale;
  1801. this.scaleSpeed *= -1;
  1802. } else if (this.scale <= this.startScale) {
  1803. this.scale = this.startScale;
  1804. this.scaleSpeed = 0;
  1805. }
  1806. if (this.life <= 0) {
  1807. this.life = 0;
  1808. }
  1809. }
  1810. };
  1811. // RENDER:
  1812. this.render = function(ctxt, xOff, yOff) {
  1813. ctxt.lineWidth = 10;
  1814. ctxt.fillStyle = this.color;
  1815. ctxt.font = this.scale + "px " + (this.scale >= 15 ? "Hammersmith One" : "Ubuntu");
  1816. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1817. ctxt.globalAlpha = 1;
  1818. };
  1819. }
  1820. };
  1821. class Textmanager {
  1822. // TEXT MANAGER:
  1823. constructor() {
  1824. this.texts = [];
  1825. this.stack = [];
  1826. // UPDATE:
  1827. this.update = function(delta, ctxt, xOff, yOff) {
  1828. ctxt.textBaseline = "middle";
  1829. ctxt.textAlign = "center";
  1830. for (let i = 0; i < this.texts.length; ++i) {
  1831. if (this.texts[i].life) {
  1832. this.texts[i].update(delta);
  1833. this.texts[i].render(ctxt, xOff, yOff);
  1834. }
  1835. }
  1836. };
  1837. // SHOW TEXT:
  1838. this.showText = function(x, y, scale, speed, life, text, color) {
  1839. let tmpText;
  1840. for (let i = 0; i < this.texts.length; ++i) {
  1841. if (!this.texts[i].life) {
  1842. tmpText = this.texts[i];
  1843. break;
  1844. }
  1845. }
  1846. if (!tmpText) {
  1847. tmpText = new Animtext();
  1848. this.texts.push(tmpText);
  1849. }
  1850. tmpText.init(x, y, scale, speed, life, text, color);
  1851. };
  1852. }
  1853. }
  1854. class GameObject {
  1855. constructor(sid) {
  1856. this.sid = sid;
  1857. // INIT:
  1858. this.init = function(x, y, dir, scale, type, data, owner) {
  1859. data = data || {};
  1860. this.sentTo = {};
  1861. this.gridLocations = [];
  1862. this.active = true;
  1863. this.alive = true;
  1864. this.doUpdate = data.doUpdate;
  1865. this.x = x;
  1866. this.y = y;
  1867. this.dir = dir;
  1868. this.lastDir = dir;
  1869. this.xWiggle = 0;
  1870. this.yWiggle = 0;
  1871. this.visScale = scale;
  1872. this.scale = scale;
  1873. this.type = type;
  1874. this.id = data.id;
  1875. this.owner = owner;
  1876. this.name = data.name;
  1877. this.isItem = (this.id != undefined);
  1878. this.group = data.group;
  1879. this.maxHealth = data.health;
  1880. this.health = this.maxHealth;
  1881. this.healthMov = 100;
  1882. this.layer = 2;
  1883. if (this.group != undefined) {
  1884. this.layer = this.group.layer;
  1885. } else if (this.type == 0) {
  1886. this.layer = 3;
  1887. } else if (this.type == 2) {
  1888. this.layer = 0;
  1889. } else if (this.type == 4) {
  1890. this.layer = -1;
  1891. }
  1892. this.colDiv = data.colDiv || 1;
  1893. this.blocker = data.blocker;
  1894. this.ignoreCollision = data.ignoreCollision;
  1895. this.dontGather = data.dontGather;
  1896. this.hideFromEnemy = data.hideFromEnemy;
  1897. this.friction = data.friction;
  1898. this.projDmg = data.projDmg;
  1899. this.dmg = data.dmg;
  1900. this.pDmg = data.pDmg;
  1901. this.pps = data.pps;
  1902. this.zIndex = data.zIndex || 0;
  1903. this.turnSpeed = data.turnSpeed;
  1904. this.req = data.req;
  1905. this.trap = data.trap;
  1906. this.healCol = data.healCol;
  1907. this.teleport = data.teleport;
  1908. this.boostSpeed = data.boostSpeed;
  1909. this.projectile = data.projectile;
  1910. this.shootRange = data.shootRange;
  1911. this.shootRate = data.shootRate;
  1912. this.shootCount = this.shootRate;
  1913. this.spawnPoint = data.spawnPoint;
  1914. this.onNear = 0;
  1915. this.breakObj = false;
  1916. this.alpha = data.alpha || 1;
  1917. this.maxAlpha = data.alpha || 1;
  1918. this.damaged = 0;
  1919. };
  1920. // GET HIT:
  1921. this.changeHealth = function(amount, doer) {
  1922. this.health += amount;
  1923. return (this.health <= 0);
  1924. };
  1925. // GET SCALE:
  1926. this.getScale = function(sM, ig) {
  1927. sM = sM || 1;
  1928. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1929. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1930. };
  1931. // VISIBLE TO PLAYER:
  1932. this.visibleToPlayer = function(player) {
  1933. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1934. (this.owner.team && player.team == this.owner.team)));
  1935. };
  1936. // UPDATE:
  1937. this.update = function(delta) {
  1938. if (this.health != this.healthMov) {
  1939. this.health < this.healthMov ? (this.healthMov -= 1.9) : (this.healthMov += 1.9);
  1940. if (Math.abs(this.health - this.healthMov) < 1.9) this.healthMov = this.health;
  1941. };
  1942. if (this.active) {
  1943. if (this.xWiggle) {
  1944. this.xWiggle *= Math.pow(0.99, delta);
  1945. }
  1946. if (this.yWiggle) {
  1947. this.yWiggle *= Math.pow(0.99, delta);
  1948. }
  1949. if (this.turnSpeed && this.dmg) {
  1950. this.dir += this.turnSpeed * delta;
  1951. }
  1952. } else {
  1953. if (this.alive) {
  1954. this.alpha -= delta / (200 / this.maxAlpha);
  1955. this.visScale += delta / (this.scale / 2.5);
  1956. if (this.alpha <= 0) {
  1957. this.alpha = 0;
  1958. this.alive = false;
  1959. }
  1960. }
  1961. }
  1962. };
  1963. // CHECK TEAM:
  1964. this.isTeamObject = function(tmpObj) {
  1965. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  1966. };
  1967. }
  1968. }
  1969. class Items {
  1970. constructor() {
  1971. // ITEM GROUPS:
  1972. this.groups = [{
  1973. id: 0,
  1974. name: "food",
  1975. layer: 0
  1976. }, {
  1977. id: 1,
  1978. name: "walls",
  1979. place: true,
  1980. limit: 30,
  1981. layer: 0
  1982. }, {
  1983. id: 2,
  1984. name: "spikes",
  1985. place: true,
  1986. limit: 15,
  1987. layer: 0
  1988. }, {
  1989. id: 3,
  1990. name: "mill",
  1991. place: true,
  1992. limit: 7,
  1993. layer: 1
  1994. }, {
  1995. id: 4,
  1996. name: "mine",
  1997. place: true,
  1998. limit: 1,
  1999. layer: 0
  2000. }, {
  2001. id: 5,
  2002. name: "trap",
  2003. place: true,
  2004. limit: 6,
  2005. layer: -1
  2006. }, {
  2007. id: 6,
  2008. name: "booster",
  2009. place: true,
  2010. limit: 12,
  2011. layer: -1
  2012. }, {
  2013. id: 7,
  2014. name: "turret",
  2015. place: true,
  2016. limit: 2,
  2017. layer: 1
  2018. }, {
  2019. id: 8,
  2020. name: "watchtower",
  2021. place: true,
  2022. limit: 12,
  2023. layer: 1
  2024. }, {
  2025. id: 9,
  2026. name: "buff",
  2027. place: true,
  2028. limit: 4,
  2029. layer: -1
  2030. }, {
  2031. id: 10,
  2032. name: "spawn",
  2033. place: true,
  2034. limit: 1,
  2035. layer: -1
  2036. }, {
  2037. id: 11,
  2038. name: "sapling",
  2039. place: true,
  2040. limit: 2,
  2041. layer: 0
  2042. }, {
  2043. id: 12,
  2044. name: "blocker",
  2045. place: true,
  2046. limit: 3,
  2047. layer: -1
  2048. }, {
  2049. id: 13,
  2050. name: "teleporter",
  2051. place: true,
  2052. limit: 2,
  2053. layer: -1
  2054. }];
  2055. // PROJECTILES:
  2056. this.projectiles = [{
  2057. indx: 0,
  2058. layer: 0,
  2059. src: "arrow_1",
  2060. dmg: 25,
  2061. speed: 1.6,
  2062. scale: 103,
  2063. range: 1000
  2064. }, {
  2065. indx: 1,
  2066. layer: 1,
  2067. dmg: 25,
  2068. scale: 20
  2069. }, {
  2070. indx: 0,
  2071. layer: 0,
  2072. src: "arrow_1",
  2073. dmg: 35,
  2074. speed: 2.5,
  2075. scale: 103,
  2076. range: 1200
  2077. }, {
  2078. indx: 0,
  2079. layer: 0,
  2080. src: "arrow_1",
  2081. dmg: 30,
  2082. speed: 2,
  2083. scale: 103,
  2084. range: 1200
  2085. }, {
  2086. indx: 1,
  2087. layer: 1,
  2088. dmg: 16,
  2089. scale: 20
  2090. }, {
  2091. indx: 0,
  2092. layer: 0,
  2093. src: "bullet_1",
  2094. dmg: 50,
  2095. speed: 3.6,
  2096. scale: 160,
  2097. range: 1400
  2098. }];
  2099. // WEAPONS:
  2100. this.weapons = [{
  2101. id: 0,
  2102. type: 0,
  2103. name: "tool hammer",
  2104. desc: "tool for gathering all resources",
  2105. src: "hammer_1",
  2106. length: 140,
  2107. width: 140,
  2108. xOff: -3,
  2109. yOff: 18,
  2110. dmg: 25,
  2111. range: 65,
  2112. gather: 1,
  2113. speed: 300
  2114. }, {
  2115. id: 1,
  2116. type: 0,
  2117. age: 2,
  2118. name: "hand axe",
  2119. desc: "gathers resources at a higher rate",
  2120. src: "axe_1",
  2121. length: 140,
  2122. width: 140,
  2123. xOff: 3,
  2124. yOff: 24,
  2125. dmg: 30,
  2126. spdMult: 1,
  2127. range: 70,
  2128. gather: 2,
  2129. speed: 400
  2130. }, {
  2131. id: 2,
  2132. type: 0,
  2133. age: 8,
  2134. pre: 1,
  2135. name: "great axe",
  2136. desc: "deal more damage and gather more resources",
  2137. src: "great_axe_1",
  2138. length: 140,
  2139. width: 140,
  2140. xOff: -8,
  2141. yOff: 25,
  2142. dmg: 35,
  2143. spdMult: 1,
  2144. range: 75,
  2145. gather: 4,
  2146. speed: 400
  2147. }, {
  2148. id: 3,
  2149. type: 0,
  2150. age: 2,
  2151. name: "short sword",
  2152. desc: "increased attack power but slower move speed",
  2153. src: "sword_1",
  2154. iPad: 1.3,
  2155. length: 130,
  2156. width: 210,
  2157. xOff: -8,
  2158. yOff: 46,
  2159. dmg: 35,
  2160. spdMult: 0.85,
  2161. range: 110,
  2162. gather: 1,
  2163. speed: 300
  2164. }, {
  2165. id: 4,
  2166. type: 0,
  2167. age: 8,
  2168. pre: 3,
  2169. name: "katana",
  2170. desc: "greater range and damage",
  2171. src: "samurai_1",
  2172. iPad: 1.3,
  2173. length: 130,
  2174. width: 210,
  2175. xOff: -8,
  2176. yOff: 59,
  2177. dmg: 40,
  2178. spdMult: 0.8,
  2179. range: 118,
  2180. gather: 1,
  2181. speed: 300
  2182. }, {
  2183. id: 5,
  2184. type: 0,
  2185. age: 2,
  2186. name: "polearm",
  2187. desc: "long range melee weapon",
  2188. src: "spear_1",
  2189. iPad: 1.3,
  2190. length: 130,
  2191. width: 210,
  2192. xOff: -8,
  2193. yOff: 53,
  2194. dmg: 45,
  2195. knock: 0.2,
  2196. spdMult: 0.82,
  2197. range: 142,
  2198. gather: 1,
  2199. speed: 700
  2200. }, {
  2201. id: 6,
  2202. type: 0,
  2203. age: 2,
  2204. name: "bat",
  2205. desc: "fast long range melee weapon",
  2206. src: "bat_1",
  2207. iPad: 1.3,
  2208. length: 110,
  2209. width: 180,
  2210. xOff: -8,
  2211. yOff: 53,
  2212. dmg: 20,
  2213. knock: 0.7,
  2214. range: 110,
  2215. gather: 1,
  2216. speed: 300
  2217. }, {
  2218. id: 7,
  2219. type: 0,
  2220. age: 2,
  2221. name: "daggers",
  2222. desc: "really fast short range weapon",
  2223. src: "dagger_1",
  2224. iPad: 0.8,
  2225. length: 110,
  2226. width: 110,
  2227. xOff: 18,
  2228. yOff: 0,
  2229. dmg: 20,
  2230. knock: 0.1,
  2231. range: 65,
  2232. gather: 1,
  2233. hitSlow: 0.1,
  2234. spdMult: 1.13,
  2235. speed: 100
  2236. }, {
  2237. id: 8,
  2238. type: 0,
  2239. age: 2,
  2240. name: "stick",
  2241. desc: "great for gathering but very weak",
  2242. src: "stick_1",
  2243. length: 140,
  2244. width: 140,
  2245. xOff: 3,
  2246. yOff: 24,
  2247. dmg: 1,
  2248. spdMult: 1,
  2249. range: 70,
  2250. gather: 7,
  2251. speed: 400
  2252. }, {
  2253. id: 9,
  2254. type: 1,
  2255. age: 6,
  2256. name: "hunting bow",
  2257. desc: "bow used for ranged combat and hunting",
  2258. src: "bow_1",
  2259. req: ["wood", 4],
  2260. length: 120,
  2261. width: 120,
  2262. xOff: -6,
  2263. yOff: 0,
  2264. Pdmg: 25,
  2265. projectile: 0,
  2266. spdMult: 0.75,
  2267. speed: 600
  2268. }, {
  2269. id: 10,
  2270. type: 1,
  2271. age: 6,
  2272. name: "great hammer",
  2273. desc: "hammer used for destroying structures",
  2274. src: "great_hammer_1",
  2275. length: 140,
  2276. width: 140,
  2277. xOff: -9,
  2278. yOff: 25,
  2279. dmg: 10,
  2280. Pdmg: 10,
  2281. spdMult: 0.88,
  2282. range: 75,
  2283. sDmg: 7.5,
  2284. gather: 1,
  2285. speed: 400
  2286. }, {
  2287. id: 11,
  2288. type: 1,
  2289. age: 6,
  2290. name: "wooden shield",
  2291. desc: "blocks projectiles and reduces melee damage",
  2292. src: "shield_1",
  2293. length: 120,
  2294. width: 120,
  2295. shield: 0.2,
  2296. xOff: 6,
  2297. yOff: 0,
  2298. Pdmg: 0,
  2299. spdMult: 0.7
  2300. }, {
  2301. id: 12,
  2302. type: 1,
  2303. age: 8,
  2304. pre: 9,
  2305. name: "crossbow",
  2306. desc: "deals more damage and has greater range",
  2307. src: "crossbow_1",
  2308. req: ["wood", 5],
  2309. aboveHand: true,
  2310. armS: 0.75,
  2311. length: 120,
  2312. width: 120,
  2313. xOff: -4,
  2314. yOff: 0,
  2315. Pdmg: 35,
  2316. projectile: 2,
  2317. spdMult: 0.7,
  2318. speed: 700
  2319. }, {
  2320. id: 13,
  2321. type: 1,
  2322. age: 9,
  2323. pre: 12,
  2324. name: "repeater crossbow",
  2325. desc: "high firerate crossbow with reduced damage",
  2326. src: "crossbow_2",
  2327. req: ["wood", 10],
  2328. aboveHand: true,
  2329. armS: 0.75,
  2330. length: 120,
  2331. width: 120,
  2332. xOff: -4,
  2333. yOff: 0,
  2334. Pdmg: 30,
  2335. projectile: 3,
  2336. spdMult: 0.7,
  2337. speed: 230
  2338. }, {
  2339. id: 14,
  2340. type: 1,
  2341. age: 6,
  2342. name: "mc grabby",
  2343. desc: "steals resources from enemies",
  2344. src: "grab_1",
  2345. length: 130,
  2346. width: 210,
  2347. xOff: -8,
  2348. yOff: 53,
  2349. dmg: 0,
  2350. Pdmg: 0,
  2351. steal: 250,
  2352. knock: 0.2,
  2353. spdMult: 1.05,
  2354. range: 125,
  2355. gather: 0,
  2356. speed: 700
  2357. }, {
  2358. id: 15,
  2359. type: 1,
  2360. age: 9,
  2361. pre: 12,
  2362. name: "musket",
  2363. desc: "slow firerate but high damage and range",
  2364. src: "musket_1",
  2365. req: ["stone", 10],
  2366. aboveHand: true,
  2367. rec: 0.35,
  2368. armS: 0.6,
  2369. hndS: 0.3,
  2370. hndD: 1.6,
  2371. length: 205,
  2372. width: 205,
  2373. xOff: 25,
  2374. yOff: 0,
  2375. Pdmg: 50,
  2376. projectile: 5,
  2377. hideProjectile: true,
  2378. spdMult: 0.6,
  2379. speed: 1500
  2380. }];
  2381. // ITEMS:
  2382. this.list = [{
  2383. group: this.groups[0],
  2384. name: "apple",
  2385. desc: "restores 20 health when consumed",
  2386. req: ["food", 10],
  2387. consume: function(doer) {
  2388. return doer.changeHealth(20, doer);
  2389. },
  2390. scale: 22,
  2391. holdOffset: 15,
  2392. healing: 20,
  2393. itemID: 0,
  2394. itemAID: 16,
  2395. }, {
  2396. age: 3,
  2397. group: this.groups[0],
  2398. name: "cookie",
  2399. desc: "restores 40 health when consumed",
  2400. req: ["food", 15],
  2401. consume: function(doer) {
  2402. return doer.changeHealth(40, doer);
  2403. },
  2404. scale: 27,
  2405. holdOffset: 15,
  2406. healing: 40,
  2407. itemID: 1,
  2408. itemAID: 17,
  2409. }, {
  2410. age: 7,
  2411. group: this.groups[0],
  2412. name: "cheese",
  2413. desc: "restores 30 health and another 50 over 5 seconds",
  2414. req: ["food", 25],
  2415. consume: function(doer) {
  2416. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2417. doer.dmgOverTime.dmg = -10;
  2418. doer.dmgOverTime.doer = doer;
  2419. doer.dmgOverTime.time = 5;
  2420. return true;
  2421. }
  2422. return false;
  2423. },
  2424. scale: 27,
  2425. holdOffset: 15,
  2426. healing: 30,
  2427. itemID: 2,
  2428. itemAID: 18,
  2429. }, {
  2430. group: this.groups[1],
  2431. name: "wood wall",
  2432. desc: "provides protection for your village",
  2433. req: ["wood", 10],
  2434. projDmg: true,
  2435. health: 380,
  2436. scale: 50,
  2437. holdOffset: 20,
  2438. placeOffset: -5,
  2439. itemID: 3,
  2440. itemAID: 19,
  2441. }, {
  2442. age: 3,
  2443. group: this.groups[1],
  2444. name: "stone wall",
  2445. desc: "provides improved protection for your village",
  2446. req: ["stone", 25],
  2447. health: 900,
  2448. scale: 50,
  2449. holdOffset: 20,
  2450. placeOffset: -5,
  2451. itemID: 4,
  2452. itemAID: 20,
  2453. }, {
  2454. age: 7,
  2455. group: this.groups[1],
  2456. name: "castle wall",
  2457. desc: "provides powerful protection for your village",
  2458. req: ["stone", 35],
  2459. health: 1500,
  2460. scale: 52,
  2461. holdOffset: 20,
  2462. placeOffset: -5,
  2463. itemID: 5,
  2464. itemAID: 21,
  2465. }, {
  2466. group: this.groups[2],
  2467. name: "spikes",
  2468. desc: "damages enemies when they touch them",
  2469. req: ["wood", 20, "stone", 5],
  2470. health: 400,
  2471. dmg: 20,
  2472. scale: 49,
  2473. spritePadding: -23,
  2474. holdOffset: 8,
  2475. placeOffset: -5,
  2476. itemID: 6,
  2477. itemAID: 22,
  2478. }, {
  2479. age: 5,
  2480. group: this.groups[2],
  2481. name: "greater spikes",
  2482. desc: "damages enemies when they touch them",
  2483. req: ["wood", 30, "stone", 10],
  2484. health: 500,
  2485. dmg: 35,
  2486. scale: 52,
  2487. spritePadding: -23,
  2488. holdOffset: 8,
  2489. placeOffset: -5,
  2490. itemID: 7,
  2491. itemAID: 23,
  2492. }, {
  2493. age: 9,
  2494. group: this.groups[2],
  2495. name: "poison spikes",
  2496. desc: "poisons enemies when they touch them",
  2497. req: ["wood", 35, "stone", 15],
  2498. health: 600,
  2499. dmg: 30,
  2500. pDmg: 5,
  2501. scale: 52,
  2502. spritePadding: -23,
  2503. holdOffset: 8,
  2504. placeOffset: -5,
  2505. itemID: 8,
  2506. itemAID: 24,
  2507. }, {
  2508. age: 9,
  2509. group: this.groups[2],
  2510. name: "spinning spikes",
  2511. desc: "damages enemies when they touch them",
  2512. req: ["wood", 30, "stone", 20],
  2513. health: 500,
  2514. dmg: 45,
  2515. turnSpeed: 0.003,
  2516. scale: 52,
  2517. spritePadding: -23,
  2518. holdOffset: 8,
  2519. placeOffset: -5,
  2520. itemID: 9,
  2521. itemAID: 25,
  2522. }, {
  2523. group: this.groups[3],
  2524. name: "windmill",
  2525. desc: "generates gold over time",
  2526. req: ["wood", 50, "stone", 10],
  2527. health: 400,
  2528. pps: 1,
  2529. turnSpeed: 0.0016,
  2530. spritePadding: 25,
  2531. iconLineMult: 12,
  2532. scale: 45,
  2533. holdOffset: 20,
  2534. placeOffset: 5,
  2535. itemID: 10,
  2536. itemAID: 26,
  2537. }, {
  2538. age: 5,
  2539. group: this.groups[3],
  2540. name: "faster windmill",
  2541. desc: "generates more gold over time",
  2542. req: ["wood", 60, "stone", 20],
  2543. health: 500,
  2544. pps: 1.5,
  2545. turnSpeed: 0.0025,
  2546. spritePadding: 25,
  2547. iconLineMult: 12,
  2548. scale: 47,
  2549. holdOffset: 20,
  2550. placeOffset: 5,
  2551. itemID: 11,
  2552. itemAID: 27,
  2553. }, {
  2554. age: 8,
  2555. group: this.groups[3],
  2556. name: "power mill",
  2557. desc: "generates more gold over time",
  2558. req: ["wood", 100, "stone", 50],
  2559. health: 800,
  2560. pps: 2,
  2561. turnSpeed: 0.005,
  2562. spritePadding: 25,
  2563. iconLineMult: 12,
  2564. scale: 47,
  2565. holdOffset: 20,
  2566. placeOffset: 5,
  2567. itemID: 12,
  2568. itemAID: 28,
  2569. }, {
  2570. age: 5,
  2571. group: this.groups[4],
  2572. type: 2,
  2573. name: "mine",
  2574. desc: "allows you to mine stone",
  2575. req: ["wood", 20, "stone", 100],
  2576. iconLineMult: 12,
  2577. scale: 65,
  2578. holdOffset: 20,
  2579. placeOffset: 0,
  2580. itemID: 13,
  2581. itemAID: 29,
  2582. }, {
  2583. age: 5,
  2584. group: this.groups[11],
  2585. type: 0,
  2586. name: "sapling",
  2587. desc: "allows you to farm wood",
  2588. req: ["wood", 150],
  2589. iconLineMult: 12,
  2590. colDiv: 0.5,
  2591. scale: 110,
  2592. holdOffset: 50,
  2593. placeOffset: -15,
  2594. itemID: 14,
  2595. itemAID: 30,
  2596. }, {
  2597. age: 4,
  2598. group: this.groups[5],
  2599. name: "pit trap",
  2600. desc: "pit that traps enemies if they walk over it",
  2601. req: ["wood", 30, "stone", 30],
  2602. trap: true,
  2603. ignoreCollision: true,
  2604. hideFromEnemy: true,
  2605. health: 500,
  2606. colDiv: 0.2,
  2607. scale: 50,
  2608. holdOffset: 20,
  2609. placeOffset: -5,
  2610. alpha: 0.6,
  2611. itemID: 15,
  2612. itemAID: 31,
  2613. }, {
  2614. age: 4,
  2615. group: this.groups[6],
  2616. name: "boost pad",
  2617. desc: "provides boost when stepped on",
  2618. req: ["stone", 20, "wood", 5],
  2619. ignoreCollision: true,
  2620. boostSpeed: 1.5,
  2621. health: 150,
  2622. colDiv: 0.7,
  2623. scale: 45,
  2624. holdOffset: 20,
  2625. placeOffset: -5,
  2626. itemID: 16,
  2627. itemAID: 32,
  2628. }, {
  2629. age: 7,
  2630. group: this.groups[7],
  2631. doUpdate: true,
  2632. name: "turret",
  2633. desc: "defensive structure that shoots at enemies",
  2634. req: ["wood", 200, "stone", 150],
  2635. health: 800,
  2636. projectile: 1,
  2637. shootRange: 700,
  2638. shootRate: 2200,
  2639. scale: 43,
  2640. holdOffset: 20,
  2641. placeOffset: -5,
  2642. itemID: 17,
  2643. itemAID: 33,
  2644. }, {
  2645. age: 7,
  2646. group: this.groups[8],
  2647. name: "platform",
  2648. desc: "platform to shoot over walls and cross over water",
  2649. req: ["wood", 20],
  2650. ignoreCollision: true,
  2651. zIndex: 1,
  2652. health: 300,
  2653. scale: 43,
  2654. holdOffset: 20,
  2655. placeOffset: -5,
  2656. itemID: 18,
  2657. itemAID: 34,
  2658. }, {
  2659. age: 7,
  2660. group: this.groups[9],
  2661. name: "healing pad",
  2662. desc: "standing on it will slowly heal you",
  2663. req: ["wood", 30, "food", 10],
  2664. ignoreCollision: true,
  2665. healCol: 15,
  2666. health: 400,
  2667. colDiv: 0.7,
  2668. scale: 45,
  2669. holdOffset: 20,
  2670. placeOffset: -5,
  2671. itemID: 19,
  2672. itemAID: 35,
  2673. }, {
  2674. age: 9,
  2675. group: this.groups[10],
  2676. name: "spawn pad",
  2677. desc: "you will spawn here when you die but it will dissapear",
  2678. req: ["wood", 100, "stone", 100],
  2679. health: 400,
  2680. ignoreCollision: true,
  2681. spawnPoint: true,
  2682. scale: 45,
  2683. holdOffset: 20,
  2684. placeOffset: -5,
  2685. itemID: 20,
  2686. itemAID: 36,
  2687. }, {
  2688. age: 7,
  2689. group: this.groups[12],
  2690. name: "blocker",
  2691. desc: "blocks building in radius",
  2692. req: ["wood", 30, "stone", 25],
  2693. ignoreCollision: true,
  2694. blocker: 300,
  2695. health: 400,
  2696. colDiv: 0.7,
  2697. scale: 45,
  2698. holdOffset: 20,
  2699. placeOffset: -5,
  2700. itemID: 21,
  2701. itemAID: 37,
  2702. }, {
  2703. age: 7,
  2704. group: this.groups[13],
  2705. name: "teleporter",
  2706. desc: "teleports you to a random point on the map",
  2707. req: ["wood", 60, "stone", 60],
  2708. ignoreCollision: true,
  2709. teleport: true,
  2710. health: 200,
  2711. colDiv: 0.7,
  2712. scale: 45,
  2713. holdOffset: 20,
  2714. placeOffset: -5,
  2715. itemID: 22,
  2716. itemAID: 38
  2717. }];
  2718. // CHECK ITEM ID:
  2719. this.checkItem = {
  2720. index: function(id, myItems) {
  2721. return [0, 1, 2].includes(id) ? 0 :
  2722. [3, 4, 5].includes(id) ? 1 :
  2723. [6, 7, 8, 9].includes(id) ? 2 :
  2724. [10, 11, 12].includes(id) ? 3 :
  2725. [13, 14].includes(id) ? 5 :
  2726. [15, 16].includes(id) ? 4 :
  2727. [17, 18, 19, 21, 22].includes(id) ?
  2728. [13, 14].includes(myItems) ? 6 :
  2729. 5 :
  2730. id == 20 ?
  2731. [13, 14].includes(myItems) ? 7 :
  2732. 6 :
  2733. undefined;
  2734. }
  2735. }
  2736. // ASSIGN IDS:
  2737. for (let i = 0; i < this.list.length; ++i) {
  2738. this.list[i].id = i;
  2739. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2740. }
  2741. // TROLOLOLOL:
  2742. if (typeof window !== "undefined") {
  2743. function shuffle(a) {
  2744. for (let i = a.length - 1; i > 0; i--) {
  2745. const j = Math.floor(Math.random() * (i + 1));
  2746. [a[i], a[j]] = [a[j], a[i]];
  2747. }
  2748. return a;
  2749. }
  2750. //shuffle(this.list);
  2751. }
  2752. }
  2753. }
  2754. class Objectmanager {
  2755. constructor(GameObject, gameObjects, UTILS, config, players, server) {
  2756. let mathFloor = Math.floor,
  2757. mathABS = Math.abs,
  2758. mathCOS = Math.cos,
  2759. mathSIN = Math.sin,
  2760. mathPOW = Math.pow,
  2761. mathSQRT = Math.sqrt;
  2762. this.ignoreAdd = false;
  2763. this.hitObj = [];
  2764. // DISABLE OBJ:
  2765. this.disableObj = function(obj) {
  2766. obj.active = false;
  2767. obj.alive = false;
  2768. };
  2769. // ADD NEW:
  2770. let tmpObj;
  2771. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2772. tmpObj = findObjectBySid(sid);
  2773. if (!tmpObj) {
  2774. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2775. if (!tmpObj) {
  2776. tmpObj = new GameObject(sid);
  2777. gameObjects.push(tmpObj);
  2778. }
  2779. }
  2780. if (setSID) {
  2781. tmpObj.sid = sid;
  2782. }
  2783. tmpObj.init(x, y, dir, s, type, data, owner);
  2784. };
  2785. // DISABLE BY SID:
  2786. this.disableBySid = function(sid) {
  2787. let find = findObjectBySid(sid);
  2788. if (find) {
  2789. this.disableObj(find);
  2790. }
  2791. };
  2792. // REMOVE ALL FROM PLAYER:
  2793. this.removeAllItems = function(sid, server) {
  2794. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2795. };
  2796. // CHECK IF PLACABLE:
  2797. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2798. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  2799. if (cantPlace) return false;
  2800. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2801. return true;
  2802. };
  2803. }
  2804. }
  2805. class Projectile {
  2806. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2807. // INIT:
  2808. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2809. this.active = true;
  2810. this.tickActive = true;
  2811. this.indx = indx;
  2812. this.x = x;
  2813. this.y = y;
  2814. this.x2 = x;
  2815. this.y2 = y;
  2816. this.dir = dir;
  2817. this.skipMov = true;
  2818. this.speed = spd;
  2819. this.dmg = dmg;
  2820. this.scale = scl;
  2821. this.range = rng;
  2822. this.r2 = rng;
  2823. this.owner = owner;
  2824. };
  2825. // UPDATE:
  2826. this.update = function(delta) {
  2827. if (this.active) {
  2828. let tmpSpeed = this.speed * delta;
  2829. if (!this.skipMov) {
  2830. this.x += tmpSpeed * Math.cos(this.dir);
  2831. this.y += tmpSpeed * Math.sin(this.dir);
  2832. this.range -= tmpSpeed;
  2833. if (this.range <= 0) {
  2834. this.x += this.range * Math.cos(this.dir);
  2835. this.y += this.range * Math.sin(this.dir);
  2836. tmpSpeed = 1;
  2837. this.range = 0;
  2838. this.active = false;
  2839. }
  2840. } else {
  2841. this.skipMov = false;
  2842. }
  2843. }
  2844. };
  2845. this.tickUpdate = function(delta) {
  2846. if (this.tickActive) {
  2847. let tmpSpeed = this.speed * delta;
  2848. if (!this.skipMov) {
  2849. this.x2 += tmpSpeed * Math.cos(this.dir);
  2850. this.y2 += tmpSpeed * Math.sin(this.dir);
  2851. this.r2 -= tmpSpeed;
  2852. if (this.r2 <= 0) {
  2853. this.x2 += this.r2 * Math.cos(this.dir);
  2854. this.y2 += this.r2 * Math.sin(this.dir);
  2855. tmpSpeed = 1;
  2856. this.r2 = 0;
  2857. this.tickActive = false;
  2858. }
  2859. } else {
  2860. this.skipMov = false;
  2861. }
  2862. }
  2863. };
  2864. }
  2865. };
  2866. class Store {
  2867. constructor() {
  2868. // STORE HATS:
  2869. this.hats = [{
  2870. id: 45,
  2871. name: "Shame!",
  2872. dontSell: true,
  2873. price: 0,
  2874. scale: 120,
  2875. desc: "hacks are for winners"
  2876. }, {
  2877. id: 51,
  2878. name: "Moo Cap",
  2879. price: 0,
  2880. scale: 120,
  2881. desc: "coolest mooer around"
  2882. }, {
  2883. id: 50,
  2884. name: "Apple Cap",
  2885. price: 0,
  2886. scale: 120,
  2887. desc: "apple farms remembers"
  2888. }, {
  2889. id: 28,
  2890. name: "Moo Head",
  2891. price: 0,
  2892. scale: 120,
  2893. desc: "no effect"
  2894. }, {
  2895. id: 29,
  2896. name: "Pig Head",
  2897. price: 0,
  2898. scale: 120,
  2899. desc: "no effect"
  2900. }, {
  2901. id: 30,
  2902. name: "Fluff Head",
  2903. price: 0,
  2904. scale: 120,
  2905. desc: "no effect"
  2906. }, {
  2907. id: 36,
  2908. name: "Pandou Head",
  2909. price: 0,
  2910. scale: 120,
  2911. desc: "no effect"
  2912. }, {
  2913. id: 37,
  2914. name: "Bear Head",
  2915. price: 0,
  2916. scale: 120,
  2917. desc: "no effect"
  2918. }, {
  2919. id: 38,
  2920. name: "Monkey Head",
  2921. price: 0,
  2922. scale: 120,
  2923. desc: "no effect"
  2924. }, {
  2925. id: 44,
  2926. name: "Polar Head",
  2927. price: 0,
  2928. scale: 120,
  2929. desc: "no effect"
  2930. }, {
  2931. id: 35,
  2932. name: "Fez Hat",
  2933. price: 0,
  2934. scale: 120,
  2935. desc: "no effect"
  2936. }, {
  2937. id: 42,
  2938. name: "Enigma Hat",
  2939. price: 0,
  2940. scale: 120,
  2941. desc: "join the enigma army"
  2942. }, {
  2943. id: 43,
  2944. name: "Blitz Hat",
  2945. price: 0,
  2946. scale: 120,
  2947. desc: "hey everybody i'm blitz"
  2948. }, {
  2949. id: 49,
  2950. name: "Bob XIII Hat",
  2951. price: 0,
  2952. scale: 120,
  2953. desc: "like and subscribe"
  2954. }, {
  2955. id: 57,
  2956. name: "Pumpkin",
  2957. price: 50,
  2958. scale: 120,
  2959. desc: "Spooooky"
  2960. }, {
  2961. id: 8,
  2962. name: "Bummle Hat",
  2963. price: 100,
  2964. scale: 120,
  2965. desc: "no effect"
  2966. }, {
  2967. id: 2,
  2968. name: "Straw Hat",
  2969. price: 500,
  2970. scale: 120,
  2971. desc: "no effect"
  2972. }, {
  2973. id: 15,
  2974. name: "Winter Cap",
  2975. price: 600,
  2976. scale: 120,
  2977. desc: "allows you to move at normal speed in snow",
  2978. coldM: 1
  2979. }, {
  2980. id: 5,
  2981. name: "Cowboy Hat",
  2982. price: 1000,
  2983. scale: 120,
  2984. desc: "no effect"
  2985. }, {
  2986. id: 4,
  2987. name: "Ranger Hat",
  2988. price: 2000,
  2989. scale: 120,
  2990. desc: "no effect"
  2991. }, {
  2992. id: 18,
  2993. name: "Explorer Hat",
  2994. price: 2000,
  2995. scale: 120,
  2996. desc: "no effect"
  2997. }, {
  2998. id: 31,
  2999. name: "Flipper Hat",
  3000. price: 2500,
  3001. scale: 120,
  3002. desc: "have more control while in water",
  3003. watrImm: true
  3004. }, {
  3005. id: 1,
  3006. name: "Marksman Cap",
  3007. price: 3000,
  3008. scale: 120,
  3009. desc: "increases arrow speed and range",
  3010. aMlt: 1.3
  3011. }, {
  3012. id: 10,
  3013. name: "Bush Gear",
  3014. price: 3000,
  3015. scale: 160,
  3016. desc: "allows you to disguise yourself as a bush"
  3017. }, {
  3018. id: 48,
  3019. name: "Halo",
  3020. price: 3000,
  3021. scale: 120,
  3022. desc: "no effect"
  3023. }, {
  3024. id: 6,
  3025. name: "Soldier Helmet",
  3026. price: 4000,
  3027. scale: 120,
  3028. desc: "reduces damage taken but slows movement",
  3029. spdMult: 0.94,
  3030. dmgMult: 0.75
  3031. }, {
  3032. id: 23,
  3033. name: "Anti Venom Gear",
  3034. price: 4000,
  3035. scale: 120,
  3036. desc: "makes you immune to poison",
  3037. poisonRes: 1
  3038. }, {
  3039. id: 13,
  3040. name: "Medic Gear",
  3041. price: 5000,
  3042. scale: 110,
  3043. desc: "slowly regenerates health over time",
  3044. healthRegen: 3
  3045. }, {
  3046. id: 9,
  3047. name: "Miners Helmet",
  3048. price: 5000,
  3049. scale: 120,
  3050. desc: "earn 1 extra gold per resource",
  3051. extraGold: 1
  3052. }, {
  3053. id: 32,
  3054. name: "Musketeer Hat",
  3055. price: 5000,
  3056. scale: 120,
  3057. desc: "reduces cost of projectiles",
  3058. projCost: 0.5
  3059. }, {
  3060. id: 7,
  3061. name: "Bull Helmet",
  3062. price: 6000,
  3063. scale: 120,
  3064. desc: "increases damage done but drains health",
  3065. healthRegen: -5,
  3066. dmgMultO: 1.5,
  3067. spdMult: 0.96
  3068. }, {
  3069. id: 22,
  3070. name: "Emp Helmet",
  3071. price: 6000,
  3072. scale: 120,
  3073. desc: "turrets won't attack but you move slower",
  3074. antiTurret: 1,
  3075. spdMult: 0.7
  3076. }, {
  3077. id: 12,
  3078. name: "Booster Hat",
  3079. price: 6000,
  3080. scale: 120,
  3081. desc: "increases your movement speed",
  3082. spdMult: 1.16
  3083. }, {
  3084. id: 26,
  3085. name: "Barbarian Armor",
  3086. price: 8000,
  3087. scale: 120,
  3088. desc: "knocks back enemies that attack you",
  3089. dmgK: 0.6
  3090. }, {
  3091. id: 21,
  3092. name: "Plague Mask",
  3093. price: 10000,
  3094. scale: 120,
  3095. desc: "melee attacks deal poison damage",
  3096. poisonDmg: 5,
  3097. poisonTime: 6
  3098. }, {
  3099. id: 46,
  3100. name: "Bull Mask",
  3101. price: 10000,
  3102. scale: 120,
  3103. desc: "bulls won't target you unless you attack them",
  3104. bullRepel: 1
  3105. }, {
  3106. id: 14,
  3107. name: "Windmill Hat",
  3108. topSprite: true,
  3109. price: 10000,
  3110. scale: 120,
  3111. desc: "generates points while worn",
  3112. pps: 1.5
  3113. }, {
  3114. id: 11,
  3115. name: "Spike Gear",
  3116. topSprite: true,
  3117. price: 10000,
  3118. scale: 120,
  3119. desc: "deal damage to players that damage you",
  3120. dmg: 0.45
  3121. }, {
  3122. id: 53,
  3123. name: "Turret Gear",
  3124. topSprite: true,
  3125. price: 10000,
  3126. scale: 120,
  3127. desc: "you become a walking turret",
  3128. turret: {
  3129. proj: 1,
  3130. range: 700,
  3131. rate: 2500
  3132. },
  3133. spdMult: 0.7
  3134. }, {
  3135. id: 20,
  3136. name: "Samurai Armor",
  3137. price: 12000,
  3138. scale: 120,
  3139. desc: "increased attack speed and fire rate",
  3140. atkSpd: 0.78
  3141. }, {
  3142. id: 58,
  3143. name: "Dark Knight",
  3144. price: 12000,
  3145. scale: 120,
  3146. desc: "restores health when you deal damage",
  3147. healD: 0.4
  3148. }, {
  3149. id: 27,
  3150. name: "Scavenger Gear",
  3151. price: 15000,
  3152. scale: 120,
  3153. desc: "earn double points for each kill",
  3154. kScrM: 2
  3155. }, {
  3156. id: 40,
  3157. name: "Tank Gear",
  3158. price: 15000,
  3159. scale: 120,
  3160. desc: "increased damage to buildings but slower movement",
  3161. spdMult: 0.3,
  3162. bDmg: 3.3
  3163. }, {
  3164. id: 52,
  3165. name: "Thief Gear",
  3166. price: 15000,
  3167. scale: 120,
  3168. desc: "steal half of a players gold when you kill them",
  3169. goldSteal: 0.5
  3170. }, {
  3171. id: 55,
  3172. name: "Bloodthirster",
  3173. price: 20000,
  3174. scale: 120,
  3175. desc: "Restore Health when dealing damage. And increased damage",
  3176. healD: 0.25,
  3177. dmgMultO: 1.2,
  3178. }, {
  3179. id: 56,
  3180. name: "Assassin Gear",
  3181. price: 20000,
  3182. scale: 120,
  3183. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3184. noEat: true,
  3185. spdMult: 1.1,
  3186. invisTimer: 1000
  3187. }];
  3188. // STORE ACCESSORIES:
  3189. this.accessories = [{
  3190. id: 12,
  3191. name: "Snowball",
  3192. price: 1000,
  3193. scale: 105,
  3194. xOff: 18,
  3195. desc: "no effect"
  3196. }, {
  3197. id: 9,
  3198. name: "Tree Cape",
  3199. price: 1000,
  3200. scale: 90,
  3201. desc: "no effect"
  3202. }, {
  3203. id: 10,
  3204. name: "Stone Cape",
  3205. price: 1000,
  3206. scale: 90,
  3207. desc: "no effect"
  3208. }, {
  3209. id: 3,
  3210. name: "Cookie Cape",
  3211. price: 1500,
  3212. scale: 90,
  3213. desc: "no effect"
  3214. }, {
  3215. id: 8,
  3216. name: "Cow Cape",
  3217. price: 2000,
  3218. scale: 90,
  3219. desc: "no effect"
  3220. }, {
  3221. id: 11,
  3222. name: "Monkey Tail",
  3223. price: 2000,
  3224. scale: 97,
  3225. xOff: 25,
  3226. desc: "Super speed but reduced damage",
  3227. spdMult: 1.35,
  3228. dmgMultO: 0.2
  3229. }, {
  3230. id: 17,
  3231. name: "Apple Basket",
  3232. price: 3000,
  3233. scale: 80,
  3234. xOff: 12,
  3235. desc: "slowly regenerates health over time",
  3236. healthRegen: 1
  3237. }, {
  3238. id: 6,
  3239. name: "Winter Cape",
  3240. price: 3000,
  3241. scale: 90,
  3242. desc: "no effect"
  3243. }, {
  3244. id: 4,
  3245. name: "Skull Cape",
  3246. price: 4000,
  3247. scale: 90,
  3248. desc: "no effect"
  3249. }, {
  3250. id: 5,
  3251. name: "Dash Cape",
  3252. price: 5000,
  3253. scale: 90,
  3254. desc: "no effect"
  3255. }, {
  3256. id: 2,
  3257. name: "Dragon Cape",
  3258. price: 6000,
  3259. scale: 90,
  3260. desc: "no effect"
  3261. }, {
  3262. id: 1,
  3263. name: "Super Cape",
  3264. price: 8000,
  3265. scale: 90,
  3266. desc: "no effect"
  3267. }, {
  3268. id: 7,
  3269. name: "Troll Cape",
  3270. price: 8000,
  3271. scale: 90,
  3272. desc: "no effect"
  3273. }, {
  3274. id: 14,
  3275. name: "Thorns",
  3276. price: 10000,
  3277. scale: 115,
  3278. xOff: 20,
  3279. desc: "no effect"
  3280. }, {
  3281. id: 15,
  3282. name: "Blockades",
  3283. price: 10000,
  3284. scale: 95,
  3285. xOff: 15,
  3286. desc: "no effect"
  3287. }, {
  3288. id: 20,
  3289. name: "Devils Tail",
  3290. price: 10000,
  3291. scale: 95,
  3292. xOff: 20,
  3293. desc: "no effect"
  3294. }, {
  3295. id: 16,
  3296. name: "Sawblade",
  3297. price: 12000,
  3298. scale: 90,
  3299. spin: true,
  3300. xOff: 0,
  3301. desc: "deal damage to players that damage you",
  3302. dmg: 0.15
  3303. }, {
  3304. id: 13,
  3305. name: "Angel Wings",
  3306. price: 15000,
  3307. scale: 138,
  3308. xOff: 22,
  3309. desc: "slowly regenerates health over time",
  3310. healthRegen: 3
  3311. }, {
  3312. id: 19,
  3313. name: "Shadow Wings",
  3314. price: 15000,
  3315. scale: 138,
  3316. xOff: 22,
  3317. desc: "increased movement speed",
  3318. spdMult: 1.1
  3319. }, {
  3320. id: 18,
  3321. name: "Blood Wings",
  3322. price: 20000,
  3323. scale: 178,
  3324. xOff: 26,
  3325. desc: "restores health when you deal damage",
  3326. healD: 0.2
  3327. }, {
  3328. id: 21,
  3329. name: "Corrupt X Wings",
  3330. price: 20000,
  3331. scale: 178,
  3332. xOff: 26,
  3333. desc: "deal damage to players that damage you",
  3334. dmg: 0.25
  3335. }];
  3336. }
  3337. };
  3338. class ProjectileManager {
  3339. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3340. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3341. let tmpData = items.projectiles[indx];
  3342. let tmpProj;
  3343. for (let i = 0; i < projectiles.length; ++i) {
  3344. if (!projectiles[i].active) {
  3345. tmpProj = projectiles[i];
  3346. break;
  3347. }
  3348. }
  3349. if (!tmpProj) {
  3350. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3351. tmpProj.sid = projectiles.length;
  3352. projectiles.push(tmpProj);
  3353. }
  3354. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3355. tmpProj.ignoreObj = ignoreObj;
  3356. tmpProj.layer = layer || tmpData.layer;
  3357. tmpProj.inWindow = inWindow;
  3358. tmpProj.src = tmpData.src;
  3359. return tmpProj;
  3360. };
  3361. }
  3362. };
  3363. class AiManager {
  3364. // AI MANAGER:
  3365. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3366. // AI TYPES:
  3367. this.aiTypes = [{
  3368. id: 0,
  3369. src: "cow_1",
  3370. killScore: 150,
  3371. health: 500,
  3372. weightM: 0.8,
  3373. speed: 0.00095,
  3374. turnSpeed: 0.001,
  3375. scale: 72,
  3376. drop: ["food", 50]
  3377. }, {
  3378. id: 1,
  3379. src: "pig_1",
  3380. killScore: 200,
  3381. health: 800,
  3382. weightM: 0.6,
  3383. speed: 0.00085,
  3384. turnSpeed: 0.001,
  3385. scale: 72,
  3386. drop: ["food", 80]
  3387. }, {
  3388. id: 2,
  3389. name: "Bull",
  3390. src: "bull_2",
  3391. hostile: true,
  3392. dmg: 20,
  3393. killScore: 1000,
  3394. health: 1800,
  3395. weightM: 0.5,
  3396. speed: 0.00094,
  3397. turnSpeed: 0.00074,
  3398. scale: 78,
  3399. viewRange: 800,
  3400. chargePlayer: true,
  3401. drop: ["food", 100]
  3402. }, {
  3403. id: 3,
  3404. name: "Bully",
  3405. src: "bull_1",
  3406. hostile: true,
  3407. dmg: 20,
  3408. killScore: 2000,
  3409. health: 2800,
  3410. weightM: 0.45,
  3411. speed: 0.001,
  3412. turnSpeed: 0.0008,
  3413. scale: 90,
  3414. viewRange: 900,
  3415. chargePlayer: true,
  3416. drop: ["food", 400]
  3417. }, {
  3418. id: 4,
  3419. name: "Wolf",
  3420. src: "wolf_1",
  3421. hostile: true,
  3422. dmg: 8,
  3423. killScore: 500,
  3424. health: 300,
  3425. weightM: 0.45,
  3426. speed: 0.001,
  3427. turnSpeed: 0.002,
  3428. scale: 84,
  3429. viewRange: 800,
  3430. chargePlayer: true,
  3431. drop: ["food", 200]
  3432. }, {
  3433. id: 5,
  3434. name: "Quack",
  3435. src: "chicken_1",
  3436. dmg: 8,
  3437. killScore: 2000,
  3438. noTrap: true,
  3439. health: 300,
  3440. weightM: 0.2,
  3441. speed: 0.0018,
  3442. turnSpeed: 0.006,
  3443. scale: 70,
  3444. drop: ["food", 100]
  3445. }, {
  3446. id: 6,
  3447. name: "MOOSTAFA",
  3448. nameScale: 50,
  3449. src: "enemy",
  3450. hostile: true,
  3451. dontRun: true,
  3452. fixedSpawn: true,
  3453. spawnDelay: 60000,
  3454. noTrap: true,
  3455. colDmg: 100,
  3456. dmg: 40,
  3457. killScore: 8000,
  3458. health: 18000,
  3459. weightM: 0.4,
  3460. speed: 0.0007,
  3461. turnSpeed: 0.01,
  3462. scale: 80,
  3463. spriteMlt: 1.8,
  3464. leapForce: 0.9,
  3465. viewRange: 1000,
  3466. hitRange: 210,
  3467. hitDelay: 1000,
  3468. chargePlayer: true,
  3469. drop: ["food", 100]
  3470. }, {
  3471. id: 7,
  3472. name: "Treasure",
  3473. hostile: true,
  3474. nameScale: 35,
  3475. src: "crate_1",
  3476. fixedSpawn: true,
  3477. spawnDelay: 120000,
  3478. colDmg: 200,
  3479. killScore: 5000,
  3480. health: 20000,
  3481. weightM: 0.1,
  3482. speed: 0.0,
  3483. turnSpeed: 0.0,
  3484. scale: 70,
  3485. spriteMlt: 1.0
  3486. }, {
  3487. id: 8,
  3488. name: "MOOFIE",
  3489. src: "wolf_2",
  3490. hostile: true,
  3491. fixedSpawn: true,
  3492. dontRun: true,
  3493. hitScare: 4,
  3494. spawnDelay: 30000,
  3495. noTrap: true,
  3496. nameScale: 35,
  3497. dmg: 10,
  3498. colDmg: 100,
  3499. killScore: 3000,
  3500. health: 7000,
  3501. weightM: 0.45,
  3502. speed: 0.0015,
  3503. turnSpeed: 0.002,
  3504. scale: 90,
  3505. viewRange: 800,
  3506. chargePlayer: true,
  3507. drop: ["food", 1000]
  3508. }];
  3509. // SPAWN AI:
  3510. this.spawn = function(x, y, dir, index) {
  3511. let tmpObj = ais.find((tmp) => !tmp.active);
  3512. if (!tmpObj) {
  3513. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3514. ais.push(tmpObj);
  3515. }
  3516. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3517. return tmpObj;
  3518. };
  3519. }
  3520. };
  3521. class AI {
  3522. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3523. this.sid = sid;
  3524. this.isAI = true;
  3525. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3526. // INIT:
  3527. this.init = function(x, y, dir, index, data) {
  3528. this.x = x;
  3529. this.y = y;
  3530. this.startX = data.fixedSpawn ? x : null;
  3531. this.startY = data.fixedSpawn ? y : null;
  3532. this.xVel = 0;
  3533. this.yVel = 0;
  3534. this.zIndex = 0;
  3535. this.dir = dir;
  3536. this.dirPlus = 0;
  3537. this.index = index;
  3538. this.src = data.src;
  3539. if (data.name) this.name = data.name;
  3540. this.weightM = data.weightM;
  3541. this.speed = data.speed;
  3542. this.killScore = data.killScore;
  3543. this.turnSpeed = data.turnSpeed;
  3544. this.scale = data.scale;
  3545. this.maxHealth = data.health;
  3546. this.leapForce = data.leapForce;
  3547. this.health = this.maxHealth;
  3548. this.chargePlayer = data.chargePlayer;
  3549. this.viewRange = data.viewRange;
  3550. this.drop = data.drop;
  3551. this.dmg = data.dmg;
  3552. this.hostile = data.hostile;
  3553. this.dontRun = data.dontRun;
  3554. this.hitRange = data.hitRange;
  3555. this.hitDelay = data.hitDelay;
  3556. this.hitScare = data.hitScare;
  3557. this.spriteMlt = data.spriteMlt;
  3558. this.nameScale = data.nameScale;
  3559. this.colDmg = data.colDmg;
  3560. this.noTrap = data.noTrap;
  3561. this.spawnDelay = data.spawnDelay;
  3562. this.hitWait = 0;
  3563. this.waitCount = 1000;
  3564. this.moveCount = 0;
  3565. this.targetDir = 0;
  3566. this.active = true;
  3567. this.alive = true;
  3568. this.runFrom = null;
  3569. this.chargeTarget = null;
  3570. this.dmgOverTime = {};
  3571. };
  3572. let tmpRatio = 0;
  3573. let animIndex = 0;
  3574. this.animate = function(delta) {
  3575. if (this.animTime > 0) {
  3576. this.animTime -= delta;
  3577. if (this.animTime <= 0) {
  3578. this.animTime = 0;
  3579. this.dirPlus = 0;
  3580. tmpRatio = 0;
  3581. animIndex = 0;
  3582. } else {
  3583. if (animIndex == 0) {
  3584. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3585. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3586. if (tmpRatio >= 1) {
  3587. tmpRatio = 1;
  3588. animIndex = 1;
  3589. }
  3590. } else {
  3591. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3592. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3593. }
  3594. }
  3595. }
  3596. };
  3597. // ANIMATION:
  3598. this.startAnim = function() {
  3599. this.animTime = this.animSpeed = 600;
  3600. this.targetAngle = Math.PI * 0.8;
  3601. tmpRatio = 0;
  3602. animIndex = 0;
  3603. };
  3604. };
  3605. };
  3606. class addCh {
  3607. constructor(x, y, chat, tmpObj) {
  3608. this.x = x;
  3609. this.y = y;
  3610. this.alpha = 0;
  3611. this.active = true;
  3612. this.alive = false;
  3613. this.chat = chat;
  3614. this.owner = tmpObj;
  3615. };
  3616. };
  3617. class DeadPlayer {
  3618. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3619. this.x = x;
  3620. this.y = y;
  3621. this.lastDir = dir;
  3622. this.dir = dir + Math.PI;
  3623. this.buildIndex = buildIndex;
  3624. this.weaponIndex = weaponIndex;
  3625. this.weaponVariant = weaponVariant;
  3626. this.skinColor = skinColor;
  3627. this.scale = scale;
  3628. this.visScale = 0;
  3629. this.name = name;
  3630. this.alpha = 1;
  3631. this.active = true;
  3632. this.animate = function(delta) {
  3633. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3634. if (d2 > 0.01) {
  3635. this.dir += d2 / 20;
  3636. } else {
  3637. this.dir = this.lastDir;
  3638. }
  3639. if (this.visScale < this.scale) {
  3640. this.visScale += delta / (this.scale / 2);
  3641. if (this.visScale >= this.scale) {
  3642. this.visScale = this.scale;
  3643. }
  3644. }
  3645. this.alpha -= delta / 30000;
  3646. if (this.alpha <= 0) {
  3647. this.alpha = 0;
  3648. this.active = false;
  3649. }
  3650. }
  3651. }
  3652. };
  3653. class Player {
  3654. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3655. this.id = id;
  3656. this.sid = sid;
  3657. this.tmpScore = 0;
  3658. this.team = null;
  3659. this.latestSkin = 0;
  3660. this.oldSkinIndex = 0;
  3661. this.skinIndex = 0;
  3662. this.latestTail = 0;
  3663. this.oldTailIndex = 0;
  3664. this.tailIndex = 0;
  3665. this.hitTime = 0;
  3666. this.lastHit = 0;
  3667. this.tails = {};
  3668. for (let i = 0; i < accessories.length; ++i) {
  3669. if (accessories[i].price <= 0)
  3670. this.tails[accessories[i].id] = 1;
  3671. }
  3672. this.skins = {};
  3673. for (let i = 0; i < hats.length; ++i) {
  3674. if (hats[i].price <= 0)
  3675. this.skins[hats[i].id] = 1;
  3676. }
  3677. this.points = 0;
  3678. this.dt = 0;
  3679. this.hidden = false;
  3680. this.itemCounts = {};
  3681. this.isPlayer = true;
  3682. this.pps = 0;
  3683. this.moveDir = undefined;
  3684. this.skinRot = 0;
  3685. this.lastPing = 0;
  3686. this.iconIndex = 0;
  3687. this.skinColor = 0;
  3688. this.dist2 = 0;
  3689. this.aim2 = 0;
  3690. this.maxSpeed = 1;
  3691. this.chat = {
  3692. message: null,
  3693. count: 0
  3694. };
  3695. this.backupNobull = true;
  3696. this.circle = false;
  3697. this.circleRad = 200;
  3698. this.circleRadSpd = 0.1;
  3699. this.cAngle = 0;
  3700. // SPAWN:
  3701. this.spawn = function(moofoll) {
  3702. this.attacked = false;
  3703. this.death = false;
  3704. this.spinDir = 0;
  3705. this.sync = false;
  3706. this.antiBull = 0;
  3707. this.bullTimer = 0;
  3708. this.poisonTimer = 0;
  3709. this.active = true;
  3710. this.alive = true;
  3711. this.lockMove = false;
  3712. this.lockDir = false;
  3713. this.minimapCounter = 0;
  3714. this.chatCountdown = 0;
  3715. this.shameCount = 0;
  3716. this.shameTimer = 0;
  3717. this.sentTo = {};
  3718. this.gathering = 0;
  3719. this.gatherIndex = 0;
  3720. this.shooting = {};
  3721. this.shootIndex = 9;
  3722. this.autoGather = 0;
  3723. this.animTime = 0;
  3724. this.animSpeed = 0;
  3725. this.mouseState = 0;
  3726. this.buildIndex = -1;
  3727. this.weaponIndex = 0;
  3728. this.weaponCode = 0;
  3729. this.weaponVariant = 0;
  3730. this.primaryIndex = undefined;
  3731. this.secondaryIndex = undefined;
  3732. this.dmgOverTime = {};
  3733. this.noMovTimer = 0;
  3734. this.maxXP = 300;
  3735. this.XP = 0;
  3736. this.age = 1;
  3737. this.kills = 0;
  3738. this.upgrAge = 2;
  3739. this.upgradePoints = 0;
  3740. this.x = 0;
  3741. this.y = 0;
  3742. this.oldXY = {
  3743. x: 0,
  3744. y: 0
  3745. };
  3746. this.zIndex = 0;
  3747. this.xVel = 0;
  3748. this.yVel = 0;
  3749. this.slowMult = 1;
  3750. this.dir = 0;
  3751. this.dirPlus = 0;
  3752. this.targetDir = 0;
  3753. this.targetAngle = 0;
  3754. this.maxHealth = 100;
  3755. this.health = this.maxHealth;
  3756. this.oldHealth = this.maxHealth;
  3757. this.damaged = 0;
  3758. this.scale = config.playerScale;
  3759. this.speed = config.playerSpeed;
  3760. this.resetMoveDir();
  3761. this.resetResources(moofoll);
  3762. this.items = [0, 3, 6, 10];
  3763. this.weapons = [0];
  3764. this.shootCount = 0;
  3765. this.weaponXP = [];
  3766. this.reloads = {
  3767. 0: 0,
  3768. 1: 0,
  3769. 2: 0,
  3770. 3: 0,
  3771. 4: 0,
  3772. 5: 0,
  3773. 6: 0,
  3774. 7: 0,
  3775. 8: 0,
  3776. 9: 0,
  3777. 10: 0,
  3778. 11: 0,
  3779. 12: 0,
  3780. 13: 0,
  3781. 14: 0,
  3782. 15: 0,
  3783. 53: 0,
  3784. };
  3785. this.bowThreat = {
  3786. 9: 0,
  3787. 12: 0,
  3788. 13: 0,
  3789. 15: 0,
  3790. };
  3791. this.damageThreat = 0;
  3792. this.inTrap = false;
  3793. this.canEmpAnti = false;
  3794. this.empAnti = false;
  3795. this.soldierAnti = false;
  3796. this.poisonTick = 0;
  3797. this.bullTick = 0;
  3798. this.setPoisonTick = false;
  3799. this.setBullTick = false;
  3800. this.antiTimer = 2;
  3801. };
  3802. // RESET MOVE DIR:
  3803. this.resetMoveDir = function() {
  3804. this.moveDir = undefined;
  3805. };
  3806. // RESET RESOURCES:
  3807. this.resetResources = function(moofoll) {
  3808. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3809. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3810. }
  3811. };
  3812. // ADD ITEM:
  3813. this.getItemType = function(id) {
  3814. let findindx = this.items.findIndex((ids) => ids == id);
  3815. if (findindx != -1) {
  3816. return findindx;
  3817. } else {
  3818. return items.checkItem.index(id, this.items);
  3819. }
  3820. };
  3821. // SET DATA:
  3822. this.setData = function(data) {
  3823. this.id = data[0];
  3824. this.sid = data[1];
  3825. this.name = data[2];
  3826. this.x = data[3];
  3827. this.y = data[4];
  3828. this.dir = data[5];
  3829. this.health = data[6];
  3830. this.maxHealth = data[7];
  3831. this.scale = data[8];
  3832. this.skinColor = data[9];
  3833. };
  3834. // UPDATE POISON TICK:
  3835. this.updateTimer = function() {
  3836. this.bullTimer -= 1;
  3837. if (this.bullTimer <= 0) {
  3838. this.setBullTick = false;
  3839. this.bullTick = game.tick - 1;
  3840. this.bullTimer = config.serverUpdateRate;
  3841. }
  3842. this.poisonTimer -= 1;
  3843. if (this.poisonTimer < 0) {
  3844. this.setPoisonTick = false;
  3845. this.poisonTick = game.tick - 1;
  3846. this.poisonTimer = config.serverUpdateRate;
  3847. plaguemask = true;
  3848. setTimeout(() => {
  3849. plaguemask = false;
  3850. }, 1000);
  3851. } else if(this.poisonTimer >= 0) {
  3852. plaguemask = false;
  3853. }
  3854. };
  3855. this.update = function(delta) {
  3856. if (this.alive) {
  3857. if (this.health != this.healthMov) {
  3858. this.health < this.healthMov ? (this.healthMov -= 2) : (this.healthMov += 2);
  3859. if (Math.abs(this.health - this.healthMov) < 2) this.healthMov = this.health;
  3860. };
  3861. if (this.shameCount != this.shameMov) this.shameCount < this.shameMov ? (this.shameMov -= .1) : (this.shameMov += .1), Math.abs(this.shameCount - this.shameMov) < .1 && (this.shameMov = this.shameCount);
  3862. }
  3863. if (this.sid == playerSID) {
  3864. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  3865. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  3866. this.cAngle += this.circleRadSpd;
  3867. }
  3868. if (this.active) {
  3869. // MOVE:
  3870. let gear = {
  3871. skin: findID(hats, this.skinIndex),
  3872. tail: findID(accessories, this.tailIndex)
  3873. }
  3874. 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;
  3875. this.maxSpeed = spdMult;
  3876. }
  3877. };
  3878. let tmpRatio = 0;
  3879. let animIndex = 0;
  3880. this.animate = function(delta) {
  3881. if (this.animTime > 0) {
  3882. this.animTime -= delta;
  3883. if (this.animTime <= 0) {
  3884. this.animTime = 0;
  3885. this.dirPlus = 0;
  3886. tmpRatio = 0;
  3887. animIndex = 0;
  3888. } else {
  3889. if (animIndex == 0) {
  3890. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3891. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3892. if (tmpRatio >= 1) {
  3893. tmpRatio = 1;
  3894. animIndex = 1;
  3895. }
  3896. } else {
  3897. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3898. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3899. }
  3900. }
  3901. }
  3902. };
  3903. // GATHER ANIMATION:
  3904. this.startAnim = function(didHit, index) {
  3905. this.animTime = this.animSpeed = items.weapons[index].speed;
  3906. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3907. tmpRatio = 0;
  3908. animIndex = 0;
  3909. };
  3910. // CAN SEE:
  3911. this.canSee = function(other) {
  3912. if (!other) return false;
  3913. let dx = Math.abs(other.x - this.x) - other.scale;
  3914. let dy = Math.abs(other.y - this.y) - other.scale;
  3915. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3916. };
  3917. // SHAME SYSTEM:
  3918. this.judgeShame = function() {
  3919. if (this.oldHealth < this.health) {
  3920. if (this.hitTime) {
  3921. let timeSinceHit = Date.now() - this.hitTime;
  3922. this.lastHit = game.tick;
  3923. this.hitTime = 0;
  3924. if (timeSinceHit < 120) {
  3925. this.shameCount++;
  3926. } else {
  3927. this.shameCount = Math.max(0, this.shameCount - 2);
  3928. }
  3929. }
  3930. } else if (this.oldHealth > this.health) {
  3931. this.hitTime = Date.now();
  3932. }
  3933. };
  3934. this.addShameTimer = function() {
  3935. this.shameCount = 0;
  3936. this.shameTimer = 30;
  3937. let interval = setInterval(() => {
  3938. this.shameTimer--;
  3939. if (this.shameTimer <= 0) {
  3940. clearInterval(interval);
  3941. }
  3942. }, 1000);
  3943. };
  3944. // CHECK TEAM:
  3945. this.isTeam = function(tmpObj) {
  3946. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  3947. };
  3948. // FOR THE PLAYER:
  3949. this.findAllianceBySid = function(sid) {
  3950. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  3951. };
  3952. this.checkCanInsta = function(nobull) {
  3953. let totally = 0;
  3954. if (this.alive && inGame) {
  3955. let primary = {
  3956. weapon: this.weapons[0],
  3957. variant: this.primaryVariant,
  3958. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  3959. };
  3960. let secondary = {
  3961. weapon: this.weapons[1],
  3962. variant: this.secondaryVariant,
  3963. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  3964. };
  3965. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  3966. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  3967. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  3968. totally += primary.dmg * pV * bull;
  3969. }
  3970. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  3971. totally += secondary.dmg;
  3972. }
  3973. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  3974. totally += 25;
  3975. }
  3976. totally *= near.skinIndex == 6 ? 0.75 : 1;
  3977. return totally;
  3978. }
  3979. return 0;
  3980. };
  3981. // UPDATE WEAPON RELOAD:
  3982. this.manageReload = function() {
  3983. if (this.shooting[53]) {
  3984. this.shooting[53] = 0;
  3985. this.reloads[53] = (2500 - game.tickRate);
  3986. } else {
  3987. if (this.reloads[53] > 0) {
  3988. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  3989. }
  3990. }
  3991. if (this.gathering || this.shooting[1]) {
  3992. if (this.gathering) {
  3993. this.gathering = 0;
  3994. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  3995. this.attacked = true;
  3996. }
  3997. if (this.shooting[1]) {
  3998. this.shooting[1] = 0;
  3999. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4000. this.attacked = true;
  4001. }
  4002. } else {
  4003. this.attacked = false;
  4004. if (this.buildIndex < 0) {
  4005. if (this.reloads[this.weaponIndex] > 0) {
  4006. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  4007. if (this == player) {
  4008. if (getEl("weaponGrind").checked) {
  4009. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4010. checkPlace(player.getItemType(22), i);
  4011. }
  4012. }
  4013. }
  4014. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4015. this.antiBull++;
  4016. game.tickBase(() => {
  4017. this.antiBull = 0;
  4018. }, 1);
  4019. }
  4020. }
  4021. }
  4022. }
  4023. };
  4024. // FOR ANTI INSTA:
  4025. this.addDamageThreat = function(tmpObj) {
  4026. let primary = {
  4027. weapon: this.primaryIndex,
  4028. variant: this.primaryVariant
  4029. };
  4030. let secondary = {
  4031. weapon: this.secondaryIndex,
  4032. variant: this.secondaryVariant
  4033. };
  4034. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4035. secondary.dmg = secondary.weapon == undefined ? 50 : 10 ? items.weapons[secondary.weapon].Pdmg : items.weapons[secondary.weapon].Pdmg;
  4036. let bull = 1.5;
  4037. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4038. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4039. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] <= ping*2) {
  4040. this.mostDamageThreat += primary.dmg * pV * bull;
  4041. if (this.reloads[primary.weapon] <= ping) {
  4042. this.damageThreat += primary.dmg * pV * bull;
  4043. }
  4044. }
  4045. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] <= ping * 2) {
  4046. this.mostDamageThreat += secondary.dmg * sV;
  4047. if (this.reloads[secondary.weapon] <= ping) {
  4048. this.damageThreat += secondary.dmg * sV;
  4049. }
  4050. }
  4051. if (this.reloads[53] <= game.tickRate + ping) {
  4052. this.damageThreat += 25;
  4053. this.mostDamageThreat += 25;
  4054. }
  4055. if (traps.checkSpikeTick()) {
  4056. this.damageThreat += secondary.weapon == 10 ? 34 : 26
  4057. this.mostDamageThreat += secondary.weapon == 10 ? 34 : 26
  4058. }
  4059. this.damageThreat *= player.skinIndex == 6 && !clicks.left && !clicks.right && !traps.inTrap ? 0.75 : 1;
  4060. if (!this.isTeam(tmpObj)) {
  4061. if (this.dist2 <= 300) {
  4062. tmpObj.damageThreat += this.damageThreat;
  4063. tmpObj.mostDamageThreat += this.mostDamageThreat
  4064. }
  4065. }
  4066. };
  4067. }
  4068. };
  4069. // SOME CODES:
  4070. function sendUpgrade(index) {
  4071. player.reloads[index] = 0;
  4072. packet("H", index);
  4073. }
  4074. function storeEquip(id, index) {
  4075. packet("c", 0, id, index);
  4076. }
  4077. function storeBuy(id, index) {
  4078. packet("c", 1, id, index);
  4079. }
  4080.  
  4081. function buyEquip(id, index) {
  4082. let nID = player.skins[6] ? 6 : 0;
  4083. if (player.alive && inGame) {
  4084. if (index == 0) {
  4085. if (player.skins[id]) {
  4086. if (player.latestSkin != id) {
  4087. packet("c", 0, id, 0);
  4088. }
  4089. } else {
  4090. if (configs.autoBuyEquip) {
  4091. let find = findID(hats, id);
  4092. if (find) {
  4093. if (player.points >= find.price) {
  4094. //setTimeout(()=>{
  4095. packet("c", 1, id, 0);
  4096. //setTimeout(()=>{
  4097. packet("c", 0, id, 0);
  4098. //}, 120);
  4099. //}, 120);
  4100. } else {
  4101. if (player.latestSkin != nID) {
  4102. packet("c", 0, nID, 0);
  4103. }
  4104. }
  4105. } else {
  4106. if (player.latestSkin != nID) {
  4107. packet("c", 0, nID, 0);
  4108. }
  4109. }
  4110. } else {
  4111. if (player.latestSkin != nID) {
  4112. packet("c", 0, nID, 0);
  4113. }
  4114. }
  4115. }
  4116. } else if (index == 1) {
  4117. if (player.tails[id]) {
  4118. if (player.latestTail != id) {
  4119. packet("c", 0, id, 1);
  4120. }
  4121. } else {
  4122. if (configs.autoBuyEquip) {
  4123. let find = findID(accessories, id);
  4124. if (find) {
  4125. if (player.points >= find.price) {
  4126. packet("c", 1, id, 1);
  4127. // setTimeout(()=>{
  4128. packet("c", 0, id, 1);
  4129. //}, 120);
  4130. } else {
  4131. if (player.latestTail != 0) {
  4132. packet("c", 0, 0, 1);
  4133. }
  4134. }
  4135. } else {
  4136. if (player.latestTail != 0) {
  4137. packet("c", 0, 0, 1);
  4138. }
  4139. }
  4140. } else {
  4141. if (player.latestTail != 0) {
  4142. packet("c", 0, 0, 1);
  4143. }
  4144. }
  4145. }
  4146. }
  4147. }
  4148. }
  4149. function selectToBuild(index, wpn) {
  4150. packet("G", index, wpn);
  4151. }
  4152. function selectWeapon(index, isPlace) {
  4153. if (!isPlace) {
  4154. player.weaponCode = index;
  4155. }
  4156. packet("G", index, 1);
  4157. }
  4158. function sendAutoGather() {
  4159. packet("K", 1, 1);
  4160. }
  4161. function sendAtck(id, angle) {
  4162. packet("d", id, angle, 1);
  4163. }
  4164. function toRadian(angle) {
  4165. let fixedAngle = (angle % 360) * (Math.PI / 180);
  4166. return fixedAngle < 0 ? (2 * Math.PI + fixedAngle) : fixedAngle;
  4167. }
  4168. function Hg(e, t){
  4169. buyEquip(e, 0);
  4170. buyEquip(t, 1);
  4171. }
  4172.  
  4173. // PLACER:
  4174. function place(id, rad, rmd) {
  4175. try {
  4176. if (id == undefined) return;
  4177. let item = items.list[player.items[id]];
  4178. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4179. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4180. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4181. 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))) {
  4182. selectToBuild(player.items[id]);
  4183. sendAtck(1, rad);
  4184. selectWeapon(player.weaponCode, 1);
  4185. if (rmd && getEl("renderplace").value == "placeVis") {
  4186. placeVisible.push({
  4187. x: tmpX,
  4188. y: tmpY,
  4189. name: item.name,
  4190. scale: item.scale,
  4191. dir: rad
  4192. });
  4193. game.tickBase(() => {
  4194. placeVisible.shift();
  4195. }, 1)
  4196. }
  4197. if (rmd && getEl("renderplace").value == "outline") {
  4198. placeVisible.push({
  4199. x: tmpX,
  4200. y: tmpY,
  4201. name: item.name,
  4202. scale: item.scale,
  4203. dir: rad
  4204. });
  4205. game.tickBase(() => {
  4206. placeVisible.shift();
  4207. }, 1)
  4208. }
  4209. if (rmd && getEl("previs").checked) {
  4210. preplaceVisible.push({
  4211. x: tmpX,
  4212. y: tmpY,
  4213. name: item.name,
  4214. scale: item.scale,
  4215. dir: rad
  4216. });
  4217. game.tickBase(() => {
  4218. preplaceVisible.shift();
  4219. }, 1)
  4220.  
  4221.  
  4222.  
  4223.  
  4224. }
  4225. }
  4226. } catch (e) {}
  4227. }
  4228.  
  4229. function getDist(e, t) {
  4230. try {
  4231. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4232. } catch (e) {
  4233. return Infinity;
  4234. }
  4235. }
  4236. // GET DIRECTION
  4237. function getDir(e, t) {
  4238. try {
  4239. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4240. } catch (e) {
  4241. return 0;
  4242. }
  4243. }
  4244.  
  4245. function sortFromSmallest(arr, func) { // dist - dist
  4246. func = typeof func == "function" ? func : (obj) => {
  4247. return obj
  4248. };
  4249. return arr.sort((two, one) => (func(two)) - func(one));
  4250. }
  4251. /*
  4252. tmpList = objectManager.getGridArrays(user.x2, user.y2, 500);
  4253. for (var x = 0; x < tmpList.length; ++x) {
  4254. for (var y = 0; y < tmpList[x].length; ++y) {
  4255. if (tmpList[x][y].active && getDist(player, tmpList[x][y]))
  4256. }
  4257. }
  4258. */
  4259. function getCloseBuildings() {
  4260. let buildings = [];
  4261. let addedBefore = {};
  4262. let filteredBuildings = objectManager.getGridArrays(player.x, player.y, 200);
  4263. //console.log(filteredBuildings);
  4264. for (var x = 0; x < filteredBuildings.length; ++x) {
  4265. for (var y = 0; y < filteredBuildings[x].length; ++y) {
  4266. if (filteredBuildings[x][y].active) {
  4267. buildings.push(filteredBuildings[x][y]);
  4268. }
  4269. }
  4270. }
  4271. //console.log(buildings);
  4272. return buildings;
  4273. }
  4274. function quadSpikeBreak(user, item) {
  4275. try {
  4276. let angles = [];
  4277. let possibleOnes = [];
  4278. for (let angle = 0; angle < 72; angle++) {
  4279. angles.push(toRadian(angle * 5));
  4280. }
  4281. let buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && t.sid != player.inTrap.sid && getDist(player, t) <= 150), (a)=>{
  4282. return getDist(player, a);
  4283. });
  4284. let last = null;
  4285. for (let angle of angles) {
  4286. let position = player.buildItemPosition(item, angle);
  4287. let possibleToPlace = true;
  4288. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4289. possibleToPlace = false;
  4290. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4291. possibleToPlace = false;
  4292. } else {
  4293. for (let building of buildings_) {
  4294. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4295. if (getDist(building, position) < item.scale + range) { // overlap
  4296. possibleToPlace = false;
  4297. last = building;
  4298. break;
  4299. }
  4300. }
  4301. }
  4302. if (possibleToPlace) {
  4303. possibleOnes.push(angle);
  4304. }
  4305. }
  4306. return possibleOnes;
  4307. } catch (e) {
  4308. //console.log(e);
  4309. }
  4310. }
  4311. function getPlaceablePositions(user, item) {
  4312. try {
  4313. let angles = [];
  4314. let possibleOnes = [];
  4315. for (let angle = 0; angle < 72; angle++) {
  4316. angles.push(toRadian(angle * 5));
  4317. }
  4318. let buildings_ = [];
  4319. if (!window.isMohMoh) {
  4320. buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && getDist(player, t) <= 150), (a)=>{
  4321. return getDist(player, a);
  4322. });
  4323. }
  4324. let last = null;
  4325. for (let angle of angles) {
  4326. let position = player.buildItemPosition(item, angle);
  4327. let possibleToPlace = true;
  4328. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4329. possibleToPlace = false;
  4330. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4331. possibleToPlace = false;
  4332. } else if (true) {
  4333. for (let building of buildings_) {
  4334. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4335. if (getDist(building, position) < item.scale + range) { // overlap
  4336. possibleToPlace = false;
  4337. last = building;
  4338. break;
  4339. }
  4340. }
  4341. }
  4342. if (possibleToPlace) {
  4343. possibleOnes.push(angle);
  4344. }
  4345. }
  4346. return possibleOnes;
  4347. } catch (e) {
  4348. //console.log(e);
  4349. }
  4350. }
  4351. let firstCheckPlaceForntiBUg = false;
  4352. function simplePlace(id, radian) {
  4353. checkPlace(id, radian);
  4354. };
  4355.  
  4356.  
  4357. function checkPlace(id, rad) {
  4358. try {
  4359. if (secPacket.count >= 80) return;
  4360. //if (id == undefined) return;
  4361. let item = items.list[player.items[id]];
  4362. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4363. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4364. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4365. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4366. place(id, rad, 1);
  4367. }
  4368. } catch (e) {}
  4369. }
  4370. // Preplacer
  4371. let preplaceDelay = {
  4372. killObject: -1,
  4373. gatherAnimation: -1,
  4374. total: function () {
  4375. return new Date - Math.abs(Math.trunc(this.killObject - this.gatherAnimation))
  4376. }
  4377. };
  4378.  
  4379. function getDist(e, t) {
  4380. try {
  4381. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4382. }
  4383. catch (e) {
  4384. return 1 / 0
  4385. }
  4386. }
  4387.  
  4388. function getDir(e, t) {
  4389. try {
  4390. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4391. }
  4392. catch (e) {
  4393. return 0
  4394. }
  4395. }
  4396. var preplaceOverride = !1;
  4397.  
  4398. function caf(e, t) {
  4399. try {
  4400. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4401. }
  4402. catch (e) {
  4403. return 0
  4404. }
  4405. }
  4406.  
  4407. function cdf(e, t) {
  4408. try {
  4409. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4410. }
  4411. catch (e) {
  4412. return 1 / 0
  4413. }
  4414. }
  4415.  
  4416. function numArr(e = 0, t = 1, i, a = 1) {
  4417. let n = [];
  4418. for (let s = e; s < t; s += a) n.push(s), "function" == typeof i && i(s);
  4419. return n
  4420. }
  4421.  
  4422. function toR(e) {
  4423. var t = e * Math.PI / 180 % (2 * Math.PI);
  4424. return t > Math.PI ? Math.PI - t : t
  4425. }
  4426.  
  4427. function toD(e) {
  4428. var t = e / Math.PI * 360 % 360;
  4429. return t >= 360 ? t - 360 : t
  4430. }
  4431. // HEALING:
  4432. function soldierMult() {
  4433. return player.latestSkin == 6 ? 0.75 : 1;
  4434. }
  4435. function getAttacker(damaged) {
  4436. let attackers = enemy.filter(tmp => {
  4437. //let damages = new Damages(items);
  4438. //let dmg = damages.weapons[tmp.weaponIndex];
  4439. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4440. let rule = {
  4441. //one: tmp.dist2 <= 300,
  4442. //two: by.includes(damaged),
  4443. three: tmp.attacked
  4444. }
  4445. return /*rule.one && rule.two && */rule.three;
  4446. });
  4447. return attackers;
  4448. }
  4449. function healer() {
  4450. for (let i = 0; i < healthBased(); i++) {
  4451. place(0, getAttackDir());
  4452. }
  4453. }
  4454. // ADVANCED:
  4455. function applCxC(value) {
  4456. if (player.health == 100)
  4457. return 0;
  4458. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4459. return Math.ceil(value / items.list[player.items[0]].healing);
  4460. }
  4461. return 0;
  4462. }
  4463. function healthBased() {
  4464. if (player.health == 100)
  4465. return 0;
  4466. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4467. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4468. }
  4469. return 0;
  4470. }
  4471. function calcDmg(value) {
  4472. return value * player.skinIndex == 6 ? 0.75 : 1;
  4473. }
  4474. function antirev() {
  4475. if (tmpObj.isPlayer){
  4476. for (let i = 0; i < healthBased(); i++) {
  4477. place(0, getAttackDir());
  4478. if (player.health == 55 && player.shameCount < 6 && player.skinIndex == 6) {
  4479. place(0, getAttackDir());
  4480. notif("antirev");
  4481. } else if (player.health == 40 && player.shameCount < 6 && player.skinIndex != 6){
  4482. place(0, getAttackDir());
  4483. notif("antirev");
  4484. } else if (player.health == 43.75 && player.shameCount < 5 && player.skinIndex == 6){
  4485. place(0, getAttackDir());
  4486. setTimeout(()=>{
  4487. place(0, getAttackDir());
  4488. },5)
  4489. } else if(player.health == 25 && player.shameCount < 4 && player.skinIndex == 6){
  4490. place(0, getAttackDir());
  4491. setTimeout(()=>{
  4492. place(0, getAttackDir());
  4493. },5)
  4494. } else if (player.health == 58.75 && player.shameCount < 6 && player.skinIndex == 6){
  4495. place(0, getAttackDir());
  4496. setTimeout(()=>{
  4497. place(0, getAttackDir());
  4498. },5)
  4499. } else if (player.health == 45 && player.shameCount < 6 && player.skinIndex != 6){
  4500. place(0, getAttackDir());
  4501. setTimeout(()=>{
  4502. place(0, getAttackDir());
  4503. },5)
  4504. }
  4505. if (player.shameCount < 6) {
  4506. setTimeout(()=>{
  4507. place(0, getAttackDir());
  4508. },30)
  4509. }
  4510. }
  4511. }
  4512. }
  4513. let slowHeal = function(timer) {
  4514. setTimeout(() => {
  4515. healer();
  4516. }, 25);
  4517. }
  4518. let isHealing = false;
  4519. let delay = 20;
  4520. function uziheal() {
  4521. if (!isHealing && player.health < 100) {
  4522. isHealing = true;
  4523. if (player.health < 70) {
  4524. place(0, getAttackDir());
  4525. healer();// fast heal
  4526. isHealing = false;
  4527. } else {
  4528. const healingDelay = 15;
  4529. const healingIterations = Math.ceil((100 - player.health) / 25); // making it have delay so it wont packet spam
  4530. let iterationCount = 0;
  4531. function performHealing() {
  4532. if (iterationCount < healingIterations) {
  4533. setTimeout(() => {
  4534. place(0, getAttackDir()); // slow heal
  4535. iterationCount++;
  4536. performHealing();
  4537. }, healingDelay);
  4538. } else {
  4539. isHealing = false;
  4540. }
  4541. }
  4542. performHealing();
  4543. }
  4544. }
  4545. }
  4546. // LATER:
  4547. function predictHeal() { }
  4548. function antiSyncHealing(timearg) {
  4549. my.antiSync = true;
  4550. let healAnti = setInterval(() => {
  4551. if (player.shameCount < 5) {
  4552. place(0, getAttackDir());
  4553. }
  4554. }, 75);
  4555. setTimeout(() => {
  4556. clearInterval(healAnti);
  4557. setTimeout(() => {
  4558. my.antiSync = false;
  4559. }, game.tickRate);
  4560. }, game.tickRate);
  4561. }
  4562. function biomeGear(mover, returns) {
  4563. if (getEl("hatType").value == "1") {
  4564. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4565. if (returns) return 31;
  4566. buyEquip(31, 0);
  4567. } else {
  4568. if (player.y2 <= config.snowBiomeTop) {
  4569. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4570. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4571. } else {
  4572. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4573. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4574. }
  4575. }
  4576. } else if (getEl("hatType").value == "2") {
  4577. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4578. if (returns) return 31;
  4579. buyEquip(31, 0);
  4580. } else {
  4581. if (player.y2 <= config.snowBiomeTop) {
  4582. if (returns) return mover && player.moveDir == undefined ? 6 : 15;
  4583. buyEquip(mover && player.moveDir == undefined ? 6 : 15, 0);
  4584. } else {
  4585. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  4586. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  4587. }
  4588. }
  4589. }
  4590. if (returns) return 0;
  4591. }
  4592.  
  4593. const placedSpikePositions = new Set();
  4594. const placedTrapPositions = new Set();
  4595. function isPositionValid(position) {
  4596. const playerX = player.x2;
  4597. const playerY = player.y2;
  4598. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  4599. return distToPosition > 35;
  4600. }
  4601. function findAllianceBySid(sid) {
  4602. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4603. }
  4604. function calculatePossibleTrapPositions(x, y, radius) {
  4605. const trapPositions = [];
  4606. const numPositions = 16;
  4607. for (let i = 0; i < numPositions; i++) {
  4608. const angle = (2 * Math.PI * i) / numPositions;
  4609. const offsetX = x + radius * Math.cos(angle);
  4610. const offsetY = y + radius * Math.sin(angle);
  4611. const position = [offsetX, offsetY];
  4612. if (!trapPositions.some((pos) => isPositionTooClose(position, pos))) {
  4613. trapPositions.push(position);
  4614. }
  4615. }
  4616. return trapPositions;
  4617. }
  4618. function isPositionTooClose(position1, position2, minDistance = 50) {
  4619. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  4620. return dist < minDistance;
  4621. }
  4622. function biomeGear(mover, returns) {
  4623. if (inWater) {
  4624. if (returns) return 31;
  4625. buyEquip(31, 0);
  4626. } else {
  4627. if (player.y2 <= config.snowBiomeTop) {
  4628. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4629. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4630. } else {
  4631. if (returns) return mover && player.moveDir == undefined ? 22 : 6;
  4632. buyEquip(mover && player.moveDir == undefined ? 22 : 6, 0);
  4633. }
  4634. }
  4635. if (returns) return 0;
  4636. }
  4637. function woah(mover) {
  4638. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4639. }
  4640. function secondaryCheck(id, radian) {
  4641. try {
  4642. var item = items.list[id];
  4643. var tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4644. var tmpX = player.x2 + tmpS * Math.cos(radian);
  4645. var tmpY = player.y2 + tmpS * Math.sin(radian);
  4646. if (
  4647. objectManager.checkItemLocation(
  4648. tmpX,
  4649. tmpY,
  4650. item.scale,
  4651. 0.6,
  4652. item.id,
  4653. false,
  4654. player
  4655. )
  4656. ) {
  4657. if (
  4658. player.itemCounts[item.group.id] == undefined
  4659. ? true
  4660. : player.itemCounts[item.group.id] <
  4661. (true
  4662. ? 99
  4663. : item.group.limit
  4664. ? 99
  4665. : 99)
  4666. ) {
  4667. return true
  4668. }
  4669. }
  4670. } catch (e) {
  4671.  
  4672. }
  4673. }
  4674. function makeAngles(building, type) {
  4675. let getDist = function (tmp1, tmp2, type1, type2) {
  4676. let tmpXY1 = {
  4677. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4678. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4679. };
  4680. let tmpXY2 = {
  4681. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4682. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4683. };
  4684. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4685. };
  4686. function fgdo(a, b) {
  4687. if (a == player) {
  4688. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4689. } else if (b == player) {
  4690. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4691. } else {
  4692. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4693. }
  4694. }
  4695. let buildings = building.filter(obj => fgdo(player, obj) < player.scale + items.list[type].scale + obj.scale + 50 && obj.active)
  4696. let allAngles = []
  4697. let scale
  4698. let offset = player.scale + items.list[type].scale + (items.list[type].placeOffset || 0)
  4699. for (let i = 0; i < buildings.length; i++) {
  4700.  
  4701. let scale
  4702. if (!buildings[i].isItem) {
  4703. if ((buildings[i].scale != 80 && buildings[i].scale != 85 && buildings[i].scale != 90 || buildings[i].type == 1)) {
  4704. scale = buildings[i].scale * 0.40
  4705.  
  4706. } else {
  4707. scale = buildings[i].scale
  4708. }
  4709. } else {
  4710. scale = buildings[i].scale
  4711. }
  4712. let angles = []
  4713. let dist = (items.list[type].scale + scale + 1)
  4714. let dPTB = fgdo(player, buildings[i])
  4715. let cosLaw
  4716. if (dPTB > dist + offset) {
  4717. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dist, 2)) - Math.pow(dPTB, 2)) / (2 * dist * offset))
  4718. cosLaw = Math.asin((dist * Math.sin(cosLaw)) / dPTB)
  4719. } else {
  4720. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dPTB, 2)) - Math.pow(dist, 2)) / (2 * dPTB * offset))
  4721. }
  4722. let aPTB = Math.atan2(buildings[i].y - player.y2, buildings[i].x - player.x2)
  4723. let ang1 = (aPTB - cosLaw)
  4724. let ang2 = (aPTB + cosLaw)
  4725. if (!isNaN(cosLaw)) {
  4726. angles.push(ang1)
  4727. angles.push(ang2)
  4728. angles.push(buildings[i])
  4729. }
  4730. allAngles.push(angles)
  4731. }
  4732.  
  4733. for (let i = 0; i < allAngles.length * 3; i++) {
  4734. allAngles = manageAngles(allAngles)
  4735.  
  4736. }
  4737. if (!allAngles.length) {
  4738. allAngles = [0, 0.0001]
  4739. }
  4740. for (let i = 0; i < allAngles.length; i++) {
  4741. if (allAngles != false) {
  4742. if (!secondaryCheck(type, allAngles[i][0]) || !secondaryCheck(type, allAngles[i][1])) {
  4743. allAngles = false
  4744. }
  4745. }
  4746. }
  4747. return allAngles
  4748. }
  4749. function inBetween(angle, arra) { // okay the thing i have left to fix is if the first angle is not in the right quadrant i need to make sure that the second one is less far(another checking of which quadrant it is depending on the angle)
  4750. //mental health is not looking good rn
  4751. let array1q
  4752. let array = new Array(2);
  4753. let array2q
  4754.  
  4755. if (Math.sin(angle) > 0 && Math.cos(angle) > 0) {//angle in the first quadrant
  4756. array[0] = arra[0]
  4757. array[1] = arra[1]
  4758. } else if (Math.sin(angle) > 0 && Math.cos(angle) < 0) {//angle is inside the second quadrant
  4759. angle = angle - (Math.PI / 2)
  4760. array[0] = arra[0] - (Math.PI / 2)
  4761. array[1] = arra[1] - (Math.PI / 2)
  4762. } else if (Math.sin(angle) < 0 && Math.cos(angle) < 0) {// angle is in the third quadrant
  4763. angle = angle - Math.PI
  4764. array[0] = arra[0] - Math.PI
  4765. array[1] = arra[1] - Math.PI
  4766.  
  4767. } else if (Math.sin(angle) < 0 && Math.cos(angle) > 0) {//angle is in the fourth quadrant
  4768. angle = angle - ((3 * Math.PI) / 2)
  4769. array[0] = arra[0] - ((3 * Math.PI) / 2)
  4770. array[1] = arra[1] - ((3 * Math.PI) / 2)
  4771. }
  4772. if (Math.sin(array[0]) > 0 && Math.cos(array[0]) > 0) {
  4773. array1q = 1
  4774. } else if (Math.sin(array[0]) > 0 && Math.cos(array[0]) < 0) {
  4775. array1q = 2
  4776. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) < 0) {
  4777. array1q = 3
  4778. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) > 0) {
  4779. array1q = 4
  4780. }
  4781. if (Math.sin(array[1]) > 0 && Math.cos(array[1]) > 0) {
  4782. array2q = 1
  4783. } else if (Math.sin(array[1]) > 0 && Math.cos(array[1]) < 0) {
  4784. array2q = 2
  4785. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) < 0) {
  4786. array2q = 3
  4787. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) > 0) {
  4788. array2q = 4
  4789. }
  4790.  
  4791. if (array1q == 1) {//lowest angle of the not allowed zone in the first quadrant
  4792.  
  4793. if (Math.sin(angle) < Math.sin(array[0])) {//if the angle is lower than the not allowed zone (probably not in between)
  4794. if (array2q == 1) {// if the second part of the not allowed zone is in the first quadrant
  4795. if (Math.sin(angle) < Math.sin(array[2])) {//if it wraps completely around and makes it in between
  4796. return true
  4797. } else {//doesn't wrap around enough
  4798. return false
  4799. }
  4800. } else {//not in the first quadrant, not in between
  4801. return false
  4802. }
  4803. } else {//if the angle is further than the not allowed zone
  4804. if (array2q == 1) {//if the second part of the not allowed zone is in the first quadrant
  4805. if (Math.sin(angle) < Math.sin(array[2])) {//if the angle is lower than the top limit (in between)
  4806.  
  4807. return true
  4808. } else {//is not in between
  4809. return false
  4810. }
  4811.  
  4812. } else {//its gonna be somewhere further so its in between
  4813. return true;
  4814. }
  4815. }
  4816. } else {
  4817. if (array2q == 1) {//if the further part of the not allowed zone is in the first quadrant
  4818. if (Math.sin(angle) < Math.sin(array[1])) {//if it wraps all the way around
  4819. return true
  4820. } else {
  4821. return false
  4822. }
  4823. } else {
  4824. if (array1q == 2) {//if lowest angle is in the second
  4825. if (array2q == 2) {
  4826. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4827. return true
  4828. } else {
  4829. return false
  4830. }
  4831. } else {
  4832. return false
  4833. }
  4834. } else if (array1q == 3) {//if the first one is in the third
  4835. if (array1q > array2q) {
  4836. return true
  4837. } else if (array1q < array2q) {
  4838. return false
  4839. } else {
  4840. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4841. return true
  4842. } else {
  4843. return false
  4844. }
  4845. }
  4846. } else if (array1q == 4) {//if the first one is in the third
  4847. if (array1q > array2q) {
  4848. return true
  4849. } else if (array1q < array2q) {
  4850. return false
  4851. } else {
  4852. if (Math.sin(array[0]) > Math.sin(array[1])) {
  4853. return true
  4854. } else {
  4855. return false
  4856. }
  4857. }
  4858. }
  4859. }
  4860.  
  4861. }
  4862.  
  4863. }
  4864. function manageAngles(angles) {
  4865. let allAngles = []
  4866. for (let i = 0; i < angles.length; i++) {
  4867. if (angles[i].length) {
  4868. if (!allAngles.length) {
  4869. allAngles.push(angles[i])
  4870. } else {
  4871. let used = false
  4872. for (let j = 0; j < allAngles.length; j++) {
  4873.  
  4874. if (inBetween(angles[i][0], allAngles[j])) {
  4875. used = true
  4876. if (inBetween(angles[i][1], allAngles[j])) {
  4877. allAngles[j].push(angles[i][2])
  4878. } else {
  4879. allAngles[j][1] = angles[i][1]
  4880. allAngles[j].push(angles[i][2])
  4881. }
  4882. } else if (inBetween(angles[i][1], allAngles[j])) {
  4883. used = true
  4884. allAngles[j][0] = angles[i][0]
  4885. allAngles[j].push(angles[i][2])
  4886. }
  4887. }
  4888. if (!used) {
  4889. allAngles.push(angles[i])
  4890. }
  4891. }
  4892. }
  4893. }
  4894.  
  4895. return allAngles
  4896.  
  4897. }
  4898. let priorityPlace = [];
  4899. let packetData = {
  4900. place: [],
  4901. placeQ: [],
  4902. }
  4903. function autoplacer() {
  4904. let getDist = function (tmp1, tmp2, type1, type2) {
  4905. let tmpXY1 = {
  4906. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4907. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4908. };
  4909. let tmpXY2 = {
  4910. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4911. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4912. };
  4913. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4914. };
  4915. function fgdo(a, b) {
  4916. if (a == player) {
  4917. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4918. } else if (b == player) {
  4919. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4920. } else {
  4921. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4922. }
  4923. }
  4924. let buildings = gameObjects.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x));
  4925. let nearBuilds = buildings.filter(obj => fgdo(obj, player) < 250);
  4926. const notRiver = !inWater
  4927. /*nearest enemy in trap*/
  4928. if (enemy.length && notRiver) {
  4929. let neit = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.owner.sid == player.sid && getDist(tmp, near, 0, 2) <= (player.scale + tmp.getScale() + 5)).sort(function (a, b) {
  4930. return getDist(a, near, 0, 2) - getDist(b, near, 0, 2);
  4931. })[0];
  4932. let direction = Math.atan2(near.y - player.y2, near.x - player.x2)
  4933. let spikeAngles = makeAngles(nearBuilds, player.items[2])
  4934. let trapAngles = [];
  4935. if (player.items[4]) {
  4936. trapAngles = makeAngles(nearBuilds, player.items[4])
  4937. if (!trapAngles) {
  4938. return
  4939. }
  4940. }
  4941. if (!spikeAngles) {
  4942. return
  4943. }
  4944. if (spikeAngles.length || trapAngles.length) {
  4945. let placed = []
  4946. if (priorityPlace.length) {
  4947. for (let j = 0; j < priorityPlace; j++) {
  4948. let newDir = Math.atan2(priorityPlace[j].y - player.y2, priorityPlace[j].x - player.x2)
  4949. let angFound = 0
  4950. for (let i = 0; i < spikeAngles.length; i++) {
  4951. if (!inBetween(newDir, spikeAngles[i])) {
  4952. angFound += 1
  4953. }
  4954. }
  4955. if (angFound == spikeAngles.length) {
  4956. placed.push([player.items[2], newDir])
  4957. packetData.place.push([2, newDir])
  4958. }
  4959. }
  4960. }
  4961. priorityPlace = []
  4962. if (placed.length) {
  4963. for (let i = 0; i < placed.length; i++) {
  4964. let obj = {
  4965. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4966. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4967. scale: items.list[placed[i][0]].scale / 3,
  4968. isItem: true,
  4969. active: true,
  4970. }
  4971. nearBuilds.push(obj)
  4972. }
  4973. spikeAngles = makeAngles(nearBuilds, player.items[2])
  4974. if (!spikeAngles) {
  4975. return
  4976. }
  4977. trapAngles = []
  4978. if (player.items[4]) {
  4979. trapAngles = makeAngles(nearBuilds, player.items[4])
  4980. if (!trapAngles) {
  4981. return
  4982. }
  4983. }
  4984. placed = []
  4985. }
  4986.  
  4987. if (neit && fgdo(player, near) < 200) {
  4988. let nearestAngle = undefined
  4989. let trapFound = false
  4990. for (let i = 0; i < spikeAngles.length; i++) {
  4991. if (!trapFound) {
  4992. for (let j = 2; j < spikeAngles[i].length; j++) {
  4993. if (neit == spikeAngles[i][j]) {
  4994. trapFound = true
  4995. nearestAngle = ((spikeAngles[i][0] - direction) < (spikeAngles[i][1] - direction) ? spikeAngles[i][0] : spikeAngles[i][1])
  4996. }
  4997. }
  4998. }
  4999. }
  5000. if (trapFound) {
  5001. let objectX = player.x2 + (Math.cos(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  5002. let objectY = player.y2 + (Math.sin(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  5003. if (Math.hypot(objectY - near.y, objectX - near.x) < (player.scale + items.list[player.items[2]].scale + 8)) {
  5004. placed.push([player.items[2], nearestAngle])
  5005. packetData.place.push([2, nearestAngle])
  5006. }
  5007. }
  5008. }
  5009. if (placed.length) {
  5010. for (let i = 0; i < placed.length; i++) {
  5011. let obj = {
  5012. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5013. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5014. scale: items.list[placed[i][0]].scale / 3,
  5015. isItem: true,
  5016. active: true,
  5017. }
  5018. nearBuilds.push(obj)
  5019. }
  5020. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5021. if (!spikeAngles) {
  5022. return
  5023. }
  5024. trapAngles = []
  5025. if (player.items[4]) {
  5026. trapAngles = makeAngles(nearBuilds, player.items[4])
  5027. if (!trapAngles) {
  5028. return
  5029. }
  5030. }
  5031. placed = []
  5032. }
  5033. if (fgdo(player, near) < 400) {
  5034. let ha = false
  5035.  
  5036.  
  5037. if (neit) {
  5038. let buildings = gameObjects.sort((a, b) => fgdo(player, a) - fgdo(player, b))
  5039. let spike = buildings.filter(obj => (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "spinning spikes" || obj.name == "poison spikes") && fgdo(player, obj) < 115 && obj.owner.sid != player.sid /*!isAlly(obj.owner.sid)*/ && obj.active)[0]
  5040. if (spike) {
  5041. ha = true
  5042. }
  5043.  
  5044. }
  5045. if (!neit || ha) {
  5046. let dirFound = 0
  5047. for (let i = 0; i < trapAngles.length; i++) {
  5048. if (!inBetween(direction, trapAngles[i])) {
  5049. dirFound += 1
  5050. }
  5051. }
  5052. if (dirFound == trapAngles.length) {
  5053. if (packetData.place.length < 3 && player.items[4]) {
  5054. placed.push([player.items[4], direction])
  5055. packetData.place.push([4, direction])
  5056. }
  5057. }
  5058. if (placed.length) {
  5059. for (let i = 0; i < placed.length; i++) {
  5060. let obj = {
  5061. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5062. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5063. scale: items.list[placed[i][0]].scale / 3,
  5064. isItem: true,
  5065. active: true,
  5066.  
  5067. }
  5068. nearBuilds.push(obj)
  5069. }
  5070. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5071. if (!spikeAngles) {
  5072. return
  5073. }
  5074. trapAngles = []
  5075. if (player.items[4]) {
  5076. trapAngles = makeAngles(nearBuilds, player.items[4])
  5077. if (!trapAngles) {
  5078. return
  5079. }
  5080. }
  5081. placed = []
  5082. }
  5083.  
  5084. if (fgdo(player, near) < 120) {
  5085. for (let i = 0; i < spikeAngles.length; i++) {
  5086. if (packetData.place.length < 3) {
  5087. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5088. placed.push([player.items[2], closest])
  5089. packetData.place.push([2, closest])
  5090. }
  5091. if (placed.length) {
  5092. for (let i = 0; i < placed.length; i++) {
  5093. let obj = {
  5094. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5095. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5096. scale: items.list[placed[i][0]].scale / 3,
  5097. isItem: true,
  5098. active: true,
  5099.  
  5100. }
  5101. nearBuilds.push(obj)
  5102. }
  5103. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5104. if (!spikeAngles) {
  5105. return
  5106. }
  5107. trapAngles = []
  5108. if (player.items[4]) {
  5109. trapAngles = makeAngles(nearBuilds, player.items[4])
  5110. if (!trapAngles) {
  5111. return
  5112. }
  5113. }
  5114. placed = []
  5115. }
  5116. }
  5117.  
  5118. } else {
  5119. for (let i = 0; i < trapAngles.length; i++) {
  5120. if (packetData.place.length < 3 && player.items[4]) {
  5121. let closest = (direction - trapAngles[i][0] <= direction - trapAngles[i][1] ? trapAngles[i][0] : trapAngles[i][1])
  5122. placed.push([player.items[4], closest])
  5123. packetData.place.push([4, closest])
  5124. }
  5125. if (placed.length) {
  5126. for (let i = 0; i < placed.length; i++) {
  5127. let obj = {
  5128. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5129. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5130. scale: items.list[placed[i][0]].scale / 3,
  5131. isItem: true,
  5132. active: true,
  5133.  
  5134. }
  5135. nearBuilds.push(obj)
  5136. }
  5137. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5138. if (!spikeAngles) {
  5139. return
  5140. }
  5141. trapAngles = []
  5142. if (player.items[4]) {
  5143. trapAngles = makeAngles(nearBuilds, player.items[4])
  5144. if (!trapAngles) {
  5145. return
  5146. }
  5147. }
  5148. placed = []
  5149. }
  5150. }
  5151. }
  5152. } else {
  5153. if (fgdo(player, near) < 180) {
  5154. for (let i = 0; i < spikeAngles.length; i++) {
  5155. if (packetData.place.length < 3) {
  5156. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5157. placed.push([player.items[2], closest])
  5158. packetData.place.push([2, closest])
  5159. }
  5160. if (placed.length) {
  5161. for (let i = 0; i < placed.length; i++) {
  5162. let obj = {
  5163. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5164. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5165. scale: items.list[placed[i][0]].scale / 3,
  5166. isItem: true,
  5167. active: true,
  5168.  
  5169. }
  5170. nearBuilds.push(obj)
  5171. }
  5172. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5173. if (!spikeAngles) {
  5174. return
  5175. }
  5176. trapAngles = []
  5177. if (player.items[4]) {
  5178. trapAngles = makeAngles(nearBuilds, player.items[4])
  5179. if (!trapAngles) {
  5180. return
  5181. }
  5182. }
  5183. placed = []
  5184. }
  5185. }
  5186. }
  5187. }
  5188. }
  5189.  
  5190. }
  5191. }
  5192. priorityPlace = [];
  5193. }
  5194. let advHeal = [];
  5195. class Traps {
  5196. constructor(UTILS, items) {
  5197. this.dist = 0;
  5198. this.aim = 0;
  5199. this.inTrap = false;
  5200. this.replaced = false;
  5201. this.antiTrapped = false;
  5202. this.info = {};
  5203. this.notFast = function() {
  5204. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5205. }
  5206. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5207. try {
  5208. let item = items.list[player.items[id]];
  5209. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5210. let counts = {
  5211. attempts: 0,
  5212. placed: 0
  5213. };
  5214. let tmpObjects = [];
  5215. gameObjects.forEach((p) => {
  5216. tmpObjects.push({
  5217. x: p.x,
  5218. y: p.y,
  5219. active: p.active,
  5220. blocker: p.blocker,
  5221. scale: p.scale,
  5222. isItem: p.isItem,
  5223. type: p.type,
  5224. colDiv: p.colDiv,
  5225. getScale: function(sM, ig) {
  5226. sM = sM || 1;
  5227. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  5228. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  5229. },
  5230. });
  5231. });
  5232. for (let i = first; i < repeat; i += plus) {
  5233. counts.attempts++;
  5234. let relAim = radian + i;
  5235. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5236. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5237. 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)));
  5238. if (cantPlace) continue;
  5239. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5240. place(id, relAim, 1);
  5241. tmpObjects.push({
  5242. x: tmpX,
  5243. y: tmpY,
  5244. active: true,
  5245. blocker: item.blocker,
  5246. scale: item.scale,
  5247. isItem: true,
  5248. type: null,
  5249. colDiv: item.colDiv,
  5250. getScale: function() {
  5251. return this.scale;
  5252. },
  5253. });
  5254. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5255. counts.placed++;
  5256. }
  5257. }
  5258. if (counts.placed > 0 && replacer && item.dmg) {
  5259. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs1.AutoSpikeTick) {
  5260. instaC.canSpikeTick = true;
  5261. }
  5262. }
  5263. } catch (err) {
  5264. }
  5265. };
  5266. this.checkSpikeTick = function() {
  5267. //this is my anti spike tick function which 100% confirms that u cant get spike ticked when breaking a trap
  5268. if (configs1.AntiSpikeTick && this.inTrap && near.dist2 <= items.weapons[near.primaryIndex || 5].range + near.scale * 1.2 && [3, 4, 5].includes(near.primaryIndex) && this.info.health <= items.weapons[player.weaponIndex].dmg * (config.weaponVariants[player[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[player.weaponIndex].sDmg || 1) * 3.3) return true
  5269. try {
  5270. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5271. if ((configs1.AntiSpikeTick || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5272. // more range for safe. also testing near.primaryIndex || 5
  5273. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5274. let item = items.list[9];
  5275. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5276. let danger = 0;
  5277. let counts = {
  5278. attempts: 0,
  5279. block: `unblocked`
  5280. };
  5281. for (let i = -1; i <= 1; i += 1 / 10) {
  5282. counts.attempts++;
  5283. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5284. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5285. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5286. 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)));
  5287. if (cantPlace) continue;
  5288. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5289. danger++;
  5290. counts.block = `blocked`;
  5291. break;
  5292. }
  5293. if (danger) {
  5294. my.anti0Tick = 1;
  5295. packet('6', "pro anti tick huh? " + hir.sid);
  5296. player.chat.count = 2000;
  5297. return true;
  5298. }
  5299. }
  5300. } catch (err) {
  5301. return null;
  5302. }
  5303. return false;
  5304. }
  5305. this.protect = function(aim, trap) {
  5306. if (!configs1.AntiTrap) return;
  5307. if (trap && nears.length) {
  5308. if (getDist(near, player) > getDist(near, trap)) {
  5309. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5310. checkPlace(2, near.aim2 + i);
  5311. }
  5312. }
  5313. if (getDist(near, trap) > getDist(near, player)) {
  5314. if (player.items[4]) {
  5315. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5316. checkPlace(4, near.aim2 + i) && this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5317. }
  5318. } else {
  5319. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5320. checkPlace(2, near.aim2 + i) && this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5321. }
  5322. }
  5323. }
  5324. } else {
  5325. if (player.items[4] && player.items[2]) {
  5326. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5327. this.antiTrapped = true;
  5328. }
  5329. }
  5330. };
  5331. let placedSpikePositions = new Set();
  5332. let placedTrapPositions = new Set();
  5333. this.autoPlace = function () {
  5334. if (!configs1.AutoPlace) return;
  5335. try {
  5336. if (gameObjects.length) {
  5337. let near2 = {
  5338. inTrap: false,
  5339. };
  5340. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))[0];
  5341.  
  5342. if (nearTrap) {
  5343. near2.inTrap = true;
  5344. } else {
  5345. near2.inTrap = false;
  5346. }
  5347.  
  5348. if (near.dist3 <= 450) {
  5349. if (near.dist3 <= 200) {
  5350. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5351. inTrap: near2.inTrap
  5352. });
  5353. } else {
  5354. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5355. }
  5356. }
  5357. } else {
  5358. if (near.dist3 <= 450) {
  5359. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5360. }
  5361. }
  5362. const trap1 = gameObjects
  5363. .filter((e) => e.trap && e.active)
  5364. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5365. .find((trap) => {
  5366. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5367. return (
  5368. trap !== player &&
  5369. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5370. trapDist <= 50
  5371. );
  5372. });
  5373.  
  5374. if (trap1 && near.dist2 <= 160) {
  5375. const trapX = trap1.x;
  5376. const trapY = trap1.y;
  5377. const circleRadius = 102;
  5378. const numPositions = 64;
  5379.  
  5380. for (let i = 0; i < numPositions; i++) {
  5381. const angle = (2 * Math.PI * i) / numPositions;
  5382. const offsetX = trapX + circleRadius * Math.cos(angle);
  5383. const offsetY = trapY + circleRadius * Math.sin(angle);
  5384. const position = [offsetX, offsetY];
  5385. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5386.  
  5387. if (
  5388. !placedSpikePositions.has(JSON.stringify(position)) &&
  5389. isPositionValid(position) &&
  5390. distToPlayer <= 87
  5391. ) {
  5392. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5393. checkPlace(2, angleToPlace);
  5394. placedSpikePositions.add(JSON.stringify(position));
  5395. }
  5396. }
  5397. } else if (!trap1 && near.dist2 <= 206) {
  5398. placedSpikePositions.clear();
  5399. const maxTrapsToPlace = 3;
  5400. const trapRadius = 50;
  5401. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5402. let trapsPlaced = 0;
  5403.  
  5404. for (const position of trapPositions) {
  5405. if (
  5406. trapsPlaced < maxTrapsToPlace &&
  5407. !placedTrapPositions.has(JSON.stringify(position)) &&
  5408. isPositionValid(position)
  5409. ) {
  5410. checkPlace(4, ...position);
  5411. placedTrapPositions.add(JSON.stringify(position));
  5412. trapsPlaced++;
  5413. }
  5414. }
  5415. }
  5416. } catch (e) {
  5417. console.log(e);
  5418. }
  5419. };
  5420. function calculatePerfectAngle(x1, y1, x2, y2) {
  5421. return Math.atan2(y2 - y1, x2 - x1);
  5422. }
  5423. function antiSpikeTickEz() {
  5424. this.info.health <= items.weapons[player.weaponIndex].dmg * (config.weaponVariants[tmpObj[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[player.weaponIndex].sDmg || 1) * 3.3
  5425. }
  5426. function fgdo(a, b) {
  5427. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  5428. }
  5429. let spikSync = false;
  5430. let spikePlaced = false;
  5431.  
  5432. this.replacer = function(findObj) {
  5433. if (!findObj || !configs.autoReplace) return;
  5434. if (!inGame) return;
  5435. if (this.antiTrapped) return;
  5436. game.tickBase(() => {
  5437. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5438. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5439. let perfectAngle = Math.round(calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y) / (Math.PI / 2)) * (Math.PI / 2);
  5440. let canPlaceCondition = [4, 5].includes(player.weapons[0]) && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.2) && player.reloads[player.weapons[0]] == 0;
  5441. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5442. let danger = this.checkSpikeTick();
  5443. if (objDst <= 300 && near.dist2 <= 400) {
  5444. if (near.dist2 <= 70 && canPlaceCondition && configs.spikeTick) {
  5445. this.testCanPlace(2, -Math.PI/4, Math.PI/4, (Math.PI / 20), near.aim2, 1);
  5446. this.testCanPlace(4, -Math.PI/4, Math.PI/4, Math.PI/12, near.aim2+Math.PI, 1)
  5447. } else if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5448. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5449. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5450. } else {
  5451. player.items[4] == 15 && this.testCanPlace(near.dist2 > 250 ? 4 : 2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5452. }
  5453. this.replaced = true;
  5454. }
  5455. }, 1);
  5456. };
  5457. }
  5458. };
  5459. class Instakill {
  5460. constructor() {
  5461. this.wait = false;
  5462. this.can = false;
  5463. this.isTrue = false;
  5464. this.nobull = false;
  5465. this.ticking = false;
  5466. this.canSpikeTick = false;
  5467. this.startTick = false;
  5468. this.readyTick = false;
  5469. this.canCounter = false;
  5470. this.revTick = false;
  5471. this.syncHit = false;
  5472. this.changeType = function (type) {
  5473. this.wait = false;
  5474. this.isTrue = true;
  5475. my.autoAim = true;
  5476. let instaLog = [type];
  5477. let backupNobull = near.backupNobull;
  5478. near.backupNobull = false;
  5479. game.tickBase(() => {
  5480. instaLog.push(player.skinIndex);
  5481. game.tickBase(() => {
  5482. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5483. near.backupNobull = true;
  5484. }
  5485. instaLog.push(player.skinIndex);
  5486. }, 1);
  5487. }, 1);
  5488. if (type == "rev") {
  5489. selectWeapon(player.weapons[1]);
  5490. buyEquip(53, 0);
  5491. buyEquip(21, 1);
  5492. sendAutoGather();
  5493. game.tickBase(() => {
  5494. selectWeapon(player.weapons[0]);
  5495. buyEquip(7, 0);
  5496. buyEquip(21, 1);
  5497. game.tickBase(() => {
  5498. sendAutoGather();
  5499. this.isTrue = false;
  5500. my.autoAim = false;
  5501. }, 1);
  5502. }, 1);
  5503. } else if (type == "nobull") {
  5504. selectWeapon(player.weapons[0]);
  5505. if (getEl("backupNobull").checked && backupNobull) {
  5506. buyEquip(7, 0);
  5507. } else {
  5508. buyEquip(6, 0);
  5509. }
  5510. buyEquip(21, 1);
  5511. sendAutoGather();
  5512. game.tickBase(() => {
  5513. if (near.skinIndex == 22) {
  5514. if (getEl("backupNobull").checked) {
  5515. near.backupNobull = true;
  5516. }
  5517. buyEquip(21, 0);
  5518. } else {
  5519. buyEquip(53, 0);
  5520. }
  5521. selectWeapon(player.weapons[1]);
  5522. buyEquip(21, 1);
  5523. game.tickBase(() => {
  5524. sendAutoGather();
  5525. this.isTrue = false;
  5526. my.autoAim = false;
  5527. }, 1);
  5528. }, 1);
  5529. } else if (type == "normal") {
  5530. selectWeapon(player.weapons[0]);
  5531. buyEquip(7, 0);
  5532. buyEquip(21, 1);
  5533. sendAutoGather();
  5534. game.tickBase(() => {
  5535. selectWeapon(player.weapons[1]);
  5536. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5537. buyEquip(21, 1);
  5538. game.tickBase(() => {
  5539. sendAutoGather();
  5540. this.isTrue = false;
  5541. my.autoAim = false;
  5542. }, 1);
  5543. }, 1);
  5544. } else {
  5545. setTimeout(() => {
  5546. this.isTrue = false;
  5547. my.autoAim = false;
  5548. }, 50);
  5549. }
  5550. };
  5551. this.spikeTickType = function () {
  5552. this.isTrue = true;
  5553. my.autoAim = true;
  5554. selectWeapon(player.weapons[0]);
  5555. buyEquip(7, 0);
  5556. buyEquip(21, 1);
  5557. sendAutoGather();
  5558. game.tickBase(() => {
  5559. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5560. selectWeapon(player.weapons[0]);
  5561. buyEquip(53, 0);
  5562. buyEquip(21, 1);
  5563. game.tickBase(() => {
  5564. sendAutoGather();
  5565. this.isTrue = false;
  5566. my.autoAim = false;
  5567. }, 1);
  5568. } else {
  5569. sendAutoGather();
  5570. this.isTrue = false;
  5571. my.autoAim = false;
  5572. }
  5573. }, 1);
  5574. };
  5575. this.counterType = function () {
  5576. this.isTrue = true;
  5577. my.autoAim = true;
  5578. selectWeapon(player.weapons[0]);
  5579. buyEquip(7, 0);
  5580. buyEquip(21, 1);
  5581. sendAutoGather();
  5582. game.tickBase(() => {
  5583. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5584. selectWeapon(player.weapons[0]);
  5585. buyEquip(53, 0);
  5586. buyEquip(21, 1);
  5587. game.tickBase(() => {
  5588. sendAutoGather();
  5589. this.isTrue = false;
  5590. my.autoAim = false;
  5591. }, 1);
  5592. } else {
  5593. sendAutoGather();
  5594. this.isTrue = false;
  5595. my.autoAim = false;
  5596. }
  5597. }, 1);
  5598. };
  5599. this.rangeType = function (type) {
  5600. this.isTrue = true;
  5601. my.autoAim = true;
  5602. if (type == "ageInsta") {
  5603. my.ageInsta = false;
  5604. if (player.items[5] == 18) {
  5605. place(5, near.aim2);
  5606. }
  5607. packet("I", undefined, 1);
  5608. buyEquip(22, 0);
  5609. buyEquip(21, 1);
  5610. game.tickBase(() => {
  5611. selectWeapon(player.weapons[1]);
  5612. buyEquip(53, 0);
  5613. buyEquip(21, 1);
  5614. sendAutoGather();
  5615. game.tickBase(() => {
  5616. sendUpgrade(12);
  5617. selectWeapon(player.weapons[1]);
  5618. buyEquip(53, 0);
  5619. buyEquip(21, 1);
  5620. game.tickBase(() => {
  5621. sendUpgrade(15);
  5622. selectWeapon(player.weapons[1]);
  5623. buyEquip(53, 0);
  5624. buyEquip(21, 1);
  5625. game.tickBase(() => {
  5626. sendAutoGather();
  5627. this.isTrue = false;
  5628. my.autoAim = false;
  5629. }, 1);
  5630. }, 1);
  5631. }, 1);
  5632. }, 1);
  5633. } else {
  5634. selectWeapon(player.weapons[1]);
  5635. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5636. buyEquip(53, 0);
  5637. } else {
  5638. buyEquip(20, 0);
  5639. }
  5640. buyEquip(11, 1);
  5641. sendAutoGather();
  5642. game.tickBase(() => {
  5643. sendAutoGather();
  5644. this.isTrue = false;
  5645. my.autoAim = false;
  5646. }, 1);
  5647. }
  5648. };
  5649. this.boostTickType = function() {
  5650. /*this.isTrue = true;
  5651. my.autoAim = true;
  5652. selectWeapon(player.weapons[0]);
  5653. buyEquip(53, 0);
  5654. buyEquip(11, 1);
  5655. packet("a", near.aim2);
  5656. game.tickBase(() => {
  5657. place(4, near.aim2);
  5658. selectWeapon(player.weapons[1]);
  5659. biomeGear();
  5660. buyEquip(11, 1);
  5661. sendAutoGather();
  5662. packet("a", near.aim2);
  5663. game.tickBase(() => {
  5664. selectWeapon(player.weapons[0]);
  5665. buyEquip(7, 0);
  5666. buyEquip(19, 1);
  5667. packet("a", near.aim2);
  5668. game.tickBase(() => {
  5669. sendAutoGather();
  5670. this.isTrue = false;
  5671. my.autoAim = false;
  5672. packet("a", undefined);
  5673. }, 1);
  5674. }, 1);
  5675. }, 1);*/
  5676. this.isTrue = true;
  5677. my.autoAim = true;
  5678. biomeGear();
  5679. buyEquip(11, 1);
  5680. packet("a", near.aim2, 1);
  5681. game.tickBase(() => {
  5682. if (player.weapons[1] == 15) {
  5683. my.revAim = true;
  5684. }
  5685. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5686. buyEquip(53, 0);
  5687. buyEquip(11, 1);
  5688. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5689. sendAutoGather();
  5690. }
  5691. packet("a", near.aim2, 1);
  5692. place(4, near.aim2);
  5693. game.tickBase(() => {
  5694. my.revAim = false;
  5695. selectWeapon(player.weapons[0]);
  5696. buyEquip(7, 0);
  5697. buyEquip(19, 1);
  5698. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5699. sendAutoGather();
  5700. }
  5701. packet("a", near.aim2, 1);
  5702. game.tickBase(() => {
  5703. sendAutoGather();
  5704. this.isTrue = false;
  5705. my.autoAim = false;
  5706. packet("a", undefined, 1);
  5707. }, 1);
  5708. }, 1);
  5709. }, 1);
  5710. };
  5711. this.gotoGoal = function(goto, OT) {
  5712. let slowDists = (weeeee) => weeeee * config.playerScale;
  5713. let goal = {
  5714. a: goto - OT,
  5715. b: goto + OT,
  5716. c: goto - slowDists(1),
  5717. d: goto + slowDists(1),
  5718. e: goto - slowDists(2),
  5719. f: goto + slowDists(2),
  5720. g: goto - slowDists(4),
  5721. h: goto + slowDists(4)
  5722. };
  5723. let bQ = function(wwww, awwww) {
  5724. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5725. buyEquip(31, 0);
  5726. } else {
  5727. buyEquip(wwww, awwww);
  5728. }
  5729. }
  5730. if (enemy.length) {
  5731. let dst = near.dist2;
  5732. this.ticking = true;
  5733. if (dst >= goal.a && dst <= goal.b) {
  5734. bQ(22, 0);
  5735. bQ(11, 1);
  5736. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5737. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5738. }
  5739. return {
  5740. dir: undefined,
  5741. action: 1
  5742. };
  5743. } else {
  5744. if (dst < goal.a) {
  5745. if (dst >= goal.g) {
  5746. if (dst >= goal.e) {
  5747. if (dst >= goal.c) {
  5748. bQ(40, 0);
  5749. bQ(10, 1);
  5750. if (configs.none) {
  5751. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5752. } else {
  5753. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5754. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5755. }
  5756. }
  5757. } else {
  5758. bQ(22, 0);
  5759. bQ(19, 1);
  5760. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5761. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5762. }
  5763. }
  5764. } else {
  5765. bQ(6, 0);
  5766. bQ(12, 1);
  5767. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5768. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5769. }
  5770. }
  5771. } else {
  5772. biomeGear();
  5773. bQ(11, 1);
  5774. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5775. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5776. }
  5777. }
  5778. return {
  5779. dir: near.aim2 + Math.PI,
  5780. action: 0
  5781. };
  5782. } else if (dst > goal.b) {
  5783. if (dst <= goal.h) {
  5784. if (dst <= goal.f) {
  5785. if (dst <= goal.d) {
  5786. bQ(40, 0);
  5787. bQ(9, 1);
  5788. if (configs.none) {
  5789. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5790. } else {
  5791. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5792. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5793. }
  5794. }
  5795. } else {
  5796. bQ(22, 0);
  5797. bQ(19, 1);
  5798. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5799. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5800. }
  5801. }
  5802. } else {
  5803. bQ(6, 0);
  5804. bQ(12, 1);
  5805. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5806. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5807. }
  5808. }
  5809. } else {
  5810. biomeGear();
  5811. bQ(11, 1);
  5812. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5813. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5814. }
  5815. }
  5816. return {
  5817. dir: near.aim2,
  5818. action: 0
  5819. };
  5820. }
  5821. return {
  5822. dir: undefined,
  5823. action: 0
  5824. };
  5825. }
  5826. } else {
  5827. this.ticking = false;
  5828. return {
  5829. dir: undefined,
  5830. action: 0
  5831. };
  5832. }
  5833. }
  5834. /** wait 1 tick for better quality */
  5835. this.bowMovement = function() {
  5836. let moveMent = this.gotoGoal(685, 3);
  5837. if (moveMent.action) {
  5838. if (player.reloads[53] == 0 && !this.isTrue) {
  5839. this.rangeType("ageInsta");
  5840. } else {
  5841. packet("a", moveMent.dir, 1);
  5842. }
  5843. } else {
  5844. packet("a", moveMent.dir, 1);
  5845. }
  5846. },
  5847. this.tickMovement = function() {
  5848. let dist = player.weapons[1] == 9 ? 240 : 240;
  5849. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5850. let moveMent = this.gotoGoal(238, 3);
  5851. if (moveMent.action) {
  5852. if (player.reloads[53] == 0 && !this.isTrue) {
  5853. this.boostTickType();
  5854. } else {
  5855. packet("a", moveMent.dir, 1);
  5856. }
  5857. } else {
  5858. packet("a", moveMent.dir, 1);
  5859. }
  5860. },
  5861. this.kmTickMovement = function() {
  5862. let moveMent = this.gotoGoal(240, 3);
  5863. if (moveMent.action) {
  5864. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5865. this.kmTickType();
  5866. } else {
  5867. packet("a", moveMent.dir, 1);
  5868. }
  5869. } else {
  5870. packet("a", moveMent.dir, 1);
  5871. }
  5872. },
  5873. this.boostTickMovement = function() {
  5874. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 140;
  5875. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5876. let moveMent = this.gotoGoal(372, 3);
  5877. if (moveMent.action) {
  5878. if (player.reloads[53] == 0 && !this.isTrue) {
  5879. this.boostTickType();
  5880. } else {
  5881. packet("a", moveMent.dir, 1);
  5882. }
  5883. } else {
  5884. packet("a", moveMent.dir, 1);
  5885. }
  5886. }
  5887. /** wait 1 tick for better quality */
  5888. this.perfCheck = function(pl, nr) {
  5889. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5890. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5891. let pjs = {
  5892. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5893. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5894. };
  5895. 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)) {
  5896. return true;
  5897. }
  5898. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5899. 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)) {
  5900. return true;
  5901. }
  5902. });
  5903. if (finds) return false;
  5904. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5905. let tmpScale = tmp.getScale();
  5906. 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)) {
  5907. return true;
  5908. }
  5909. });
  5910. if (finds) return false;
  5911. return true;
  5912. }
  5913. }
  5914. };
  5915. class Autobuy {
  5916. constructor(buyHat, buyAcc) {
  5917. this.hat = function() {
  5918. buyHat.forEach((id) => {
  5919. let find = findID(hats, id);
  5920. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5921. });
  5922. };
  5923. this.acc = function() {
  5924. buyAcc.forEach((id) => {
  5925. let find = findID(accessories, id);
  5926. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5927. });
  5928. };
  5929. }
  5930. };
  5931.  
  5932. class Autoupgrade {
  5933. constructor() {
  5934. this.sb = function(upg) {
  5935. upg(3);
  5936. upg(17);
  5937. upg(31);
  5938. upg(23);
  5939. upg(9);
  5940. upg(38);
  5941. };
  5942. this.kh = function(upg) {
  5943. upg(3);
  5944. upg(17);
  5945. upg(31);
  5946. upg(23);
  5947. upg(10);
  5948. upg(38);
  5949. upg(4);
  5950. upg(25);
  5951. };
  5952. this.pb = function(upg) {
  5953. upg(5);
  5954. upg(17);
  5955. upg(32);
  5956. upg(23);
  5957. upg(9);
  5958. upg(38);
  5959. };
  5960. this.ph = function(upg) {
  5961. upg(5);
  5962. upg(17);
  5963. upg(32);
  5964. upg(23);
  5965. upg(10);
  5966. upg(38);
  5967. upg(28);
  5968. upg(25);
  5969. };
  5970. this.db = function(upg) {
  5971. upg(7);
  5972. upg(17);
  5973. upg(31);
  5974. upg(23);
  5975. upg(9);
  5976. upg(34);
  5977. };
  5978. };
  5979. };
  5980.  
  5981. class Damages {
  5982. constructor(items) {
  5983. // 0.75 1 1.125 1.5
  5984. this.calcDmg = function(dmg, val) {
  5985. return dmg * val;
  5986. };
  5987. this.getAllDamage = function(dmg) {
  5988. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5989. };
  5990. this.weapons = [];
  5991. for (let i = 0; i < items.weapons.length; i++) {
  5992. let wp = items.weapons[i];
  5993. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5994. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5995. this[name] = this.weapons[i];
  5996. }
  5997. }
  5998. }
  5999.  
  6000. /** CLASS CODES */
  6001. // jumpscare code warn
  6002. let tmpList = [];
  6003. // LOADING:
  6004. let UTILS = new Utils();
  6005. let items = new Items();
  6006. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6007. let store = new Store();
  6008. let hats = store.hats;
  6009. let accessories = store.accessories;
  6010. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6011. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6012. let textManager = new Textmanager();
  6013. let traps = new Traps(UTILS, items);
  6014. let instaC = new Instakill();
  6015. let autoBuy = new Autobuy([15, 31, 6, 7, 22, 12, 53, 26, 20, 40], [11, 13, 19, 18, 21]);
  6016. let autoUpgrade = new Autoupgrade();
  6017. let lastDeath;
  6018. let minimapData;
  6019. let mapMarker = {};
  6020. let mapPings = [];
  6021. let tmpPing;
  6022. let breakTrackers = [];
  6023. let pathFindTest = 0;
  6024. let grid = [];
  6025. let pathFind = {
  6026. active: false,
  6027. grid: 40,
  6028. scale: 1440,
  6029. x: 14400,
  6030. y: 14400,
  6031. chaseNear: false,
  6032. array: [],
  6033. lastX: this.grid / 2,
  6034. lastY: this.grid / 2
  6035. };
  6036. function sendChat(message) {
  6037. packet("6", message.slice(0, 30));
  6038. }
  6039. let runAtNextTick = [];
  6040. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6041. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6042. let projOffset = config.playerScale * 2;
  6043. let projXY = {
  6044. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6045. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6046. };
  6047. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6048. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6049. })[0];
  6050. if (nearPlayer) {
  6051. if (indx == 1) {
  6052. nearPlayer.shooting[53] = 1;
  6053. } else {
  6054. nearPlayer.shootIndex = weaponIndx;
  6055. nearPlayer.shooting[1] = 1;
  6056. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6057. }
  6058. }
  6059. }
  6060. let projectileCount = 0;
  6061. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6062. if (!tmpObj.isTeam(player)) {
  6063. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6064. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6065. tmpObj.bowThreat[weaponIndex]++;
  6066. if (index == 5) {
  6067. projectileCount++;
  6068. }
  6069. setTimeout(() => {
  6070. tmpObj.bowThreat[weaponIndex]--;
  6071. if (index == 5) {
  6072. projectileCount--;
  6073. }
  6074. }, range / speed);
  6075. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6076. place(1, tmpObj.aim2);
  6077. my.anti0Tick = 4;
  6078. if (!my.antiSync) {
  6079. antiSyncHealing(4);
  6080. }
  6081. } else {
  6082. if (projectileCount >= 2) {
  6083. place(1, tmpObj.aim2);
  6084. my.anti0Tick = 4;
  6085. if (!my.antiSync) {
  6086. antiSyncHealing(4);
  6087. }
  6088. }
  6089. }
  6090. }
  6091. }
  6092. }
  6093. // SHOW ITEM INFO:
  6094. function showItemInfo(item, isWeapon, isStoreItem) {
  6095. if (player && item) {
  6096. UTILS.removeAllChildren(itemInfoHolder);
  6097. itemInfoHolder.classList.add("visible");
  6098. UTILS.generateElement({
  6099. id: "itemInfoName",
  6100. text: UTILS.capitalizeFirst(item.name),
  6101. parent: itemInfoHolder
  6102. });
  6103. UTILS.generateElement({
  6104. id: "itemInfoDesc",
  6105. text: item.desc,
  6106. parent: itemInfoHolder
  6107. });
  6108. if (isStoreItem) {
  6109. } else if (isWeapon) {
  6110. UTILS.generateElement({
  6111. class: "itemInfoReq",
  6112. text: !item.type ? "primary" : "secondary",
  6113. parent: itemInfoHolder
  6114. });
  6115. } else {
  6116. for (let i = 0; i < item.req.length; i += 2) {
  6117. UTILS.generateElement({
  6118. class: "itemInfoReq",
  6119. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6120. parent: itemInfoHolder
  6121. });
  6122. }
  6123. if (item.group.limit) {
  6124. UTILS.generateElement({
  6125. class: "itemInfoLmt",
  6126. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6127. parent: itemInfoHolder
  6128. });
  6129. }
  6130. }
  6131. } else {
  6132. itemInfoHolder.classList.remove("visible");
  6133. }
  6134. }
  6135. // RESIZE:
  6136. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6137. function resize() {
  6138. screenWidth = window.innerWidth;
  6139. screenHeight = window.innerHeight;
  6140. var scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6141. gameCanvas.width = screenWidth;
  6142. gameCanvas.height = screenHeight;
  6143. gameCanvas.style.width = screenWidth + "px";
  6144. gameCanvas.style.height = screenHeight + "px";
  6145. gameCanvas.style;
  6146. mainContext.setTransform(scaleFillNative, 0, 0, scaleFillNative, (screenWidth * pixelDensity - maxScreenWidth * scaleFillNative) / 2, (screenHeight * pixelDensity - maxScreenHeight * scaleFillNative) / 2);
  6147. }
  6148. resize();
  6149. // MOUSE INPUT:
  6150. const mals = document.getElementById('touch-controls-fullscreen');
  6151. mals.style.display = 'block';
  6152. mals.addEventListener("mousemove", gameInput, false);
  6153. function gameInput(e) {
  6154. mouseX = e.clientX;
  6155. mouseY = e.clientY;
  6156. }
  6157. let clicks = {
  6158. left: false,
  6159. middle: false,
  6160. right: false,
  6161. };
  6162. mals.addEventListener("mousedown", mouseDown, false);
  6163. function mouseDown(e) {
  6164. if (attackState != 1) {
  6165. attackState = 1;
  6166. if (e.button == 0) {
  6167. clicks.left = true;
  6168. } else if (e.button == 1) {
  6169. clicks.middle = true;
  6170. } else if (e.button == 2) {
  6171. clicks.right = true;
  6172. }
  6173. }
  6174. }
  6175. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6176. function mouseUp(e) {
  6177. if (attackState != 0) {
  6178. attackState = 0;
  6179. if (e.button == 0) {
  6180. clicks.left = false;
  6181. } else if (e.button == 1) {
  6182. clicks.middle = false;
  6183. } else if (e.button == 2) {
  6184. clicks.right = false;
  6185. }
  6186. }
  6187. }
  6188. mals.addEventListener("wheel", wheel, false);
  6189. function wheel(e) {
  6190. if (e.deltaY < 0) {
  6191. my.reSync = true;
  6192. } else {
  6193. my.reSync = false;
  6194. }
  6195. }
  6196. // INPUT UTILS:
  6197. function getMoveDir() {
  6198. let dx = 0;
  6199. let dy = 0;
  6200. for (let key in moveKeys) {
  6201. let tmpDir = moveKeys[key];
  6202. dx += !!keys[key] * tmpDir[0];
  6203. dy += !!keys[key] * tmpDir[1];
  6204. }
  6205. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6206. }
  6207. function getSafeDir() {
  6208. if (!player)
  6209. return 0;
  6210. if (!player.lockDir) {
  6211. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6212. }
  6213. return lastDir || 0;
  6214. }
  6215. function getAttackDir(debug) {
  6216. if (debug) {
  6217. if (!player)
  6218. return "0";
  6219.  
  6220. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6221. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6222. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6223. lastDir = "getSafeDir()";
  6224. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6225. lastDir = "traps.aim";
  6226. } else if (!player.lockDir) {
  6227. if (configs.noDir) return "undefined";
  6228. lastDir = "getSafeDir()";
  6229. }
  6230.  
  6231. return lastDir;
  6232. } else {
  6233. if (!player)
  6234. return 0;
  6235.  
  6236. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6237. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6238. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6239. lastDir = getSafeDir();
  6240. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6241. lastDir = traps.aim;
  6242. } else if (!player.lockDir) {
  6243. if (configs.noDir) return undefined;
  6244. lastDir = getSafeDir();
  6245. }
  6246.  
  6247. return lastDir || 0;
  6248. }
  6249. }
  6250.  
  6251. function getVisualDir() {
  6252. if (!player)
  6253. return 0;
  6254.  
  6255. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6256. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6257. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6258. lastDir = getSafeDir();
  6259. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6260. lastDir = traps.aim;
  6261. } else if (!player.lockDir) {
  6262. lastDir = getSafeDir();
  6263. }
  6264.  
  6265. return lastDir || 0;
  6266. }
  6267.  
  6268. // Funkce pro kontrolu, zda jste pobli? hra?e
  6269. function isNearPlayer() {
  6270. return near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap;
  6271. buyEquip(21, 1);
  6272. }
  6273. // KEYS:
  6274. function keysActive() {
  6275. return (allianceMenu.style.display != "block" &&
  6276. chatHolder.style.display != "block" &&
  6277. !menuCBFocus);
  6278. }
  6279. function toggleMenuChat() {
  6280. if (menuChatDiv.style.display != "none") {
  6281. chatHolder.style.display = "none";
  6282. if (menuChatBox.value != "") {
  6283. //commands[command.slice(1)]
  6284. let cmd = function(command) {
  6285. return {
  6286. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6287. fv: commands[command.slice(1).split(" ")[0]]
  6288. }
  6289. }
  6290. let command = cmd(menuChatBox.value);
  6291. if (command.found) {
  6292. if (typeof command.fv.action === "function") {
  6293. command.fv.action(menuChatBox.value);
  6294. }
  6295. } else {
  6296. sendChat(menuChatBox.value);
  6297. }
  6298. menuChatBox.value = "";
  6299. menuChatBox.blur();
  6300. } else {
  6301. if (menuCBFocus) {
  6302. menuChatBox.blur();
  6303. } else {
  6304. menuChatBox.focus();
  6305. }
  6306. }
  6307. }
  6308. }
  6309. function keyDown(event) {
  6310. let keyNum = event.which || event.keyCode || 0;
  6311. if (player && player.alive && keysActive()) {
  6312. if (!keys[keyNum]) {
  6313. keys[keyNum] = 1;
  6314. macro[event.key] = 1;
  6315. if (keyNum == 27) {
  6316. openMenu = !openMenu;
  6317. $("#menuDiv").toggle();
  6318. $("#menuChatDiv").toggle();
  6319. } else if (keyNum == 69) {
  6320. sendAutoGather();
  6321. } else if (keyNum == 67) {
  6322. updateMapMarker();
  6323. } else if (player.weapons[keyNum - 49] != undefined) {
  6324. player.weaponCode = player.weapons[keyNum - 49];
  6325. } else if (moveKeys[keyNum]) {
  6326. sendMoveDir();
  6327. } else if (event.key == "m") {
  6328. mills.placeSpawnPads = !mills.placeSpawnPads;
  6329. } else if (event.key == "z") {
  6330. mills.place = !mills.place;
  6331. } else if (event.key == "Z") {
  6332. typeof window.debug == "function" && window.debug();
  6333. } else if (keyNum == 32) {
  6334. packet("d", 1, getSafeDir(), 1);
  6335. packet("d", 0, getSafeDir(), 1);
  6336. } else if (event.key == ",") {
  6337. player.sync = true;
  6338. }
  6339. }
  6340. }
  6341. }
  6342. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6343. function keyUp(event) {
  6344. if (player && player.alive) {
  6345. let keyNum = event.which || event.keyCode || 0;
  6346. if (keyNum == 13) {
  6347. // toggleMenuChat();
  6348. } else if (keysActive()) {
  6349. if (keys[keyNum]) {
  6350. keys[keyNum] = 0;
  6351. macro[event.key] = 0;
  6352. if (moveKeys[keyNum]) {
  6353. sendMoveDir();
  6354. } else if (event.key == ",") {
  6355. player.sync = false;
  6356. }
  6357. }
  6358. }
  6359. }
  6360. }
  6361. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6362. function sendMoveDir() {
  6363. let newMoveDir = getMoveDir();
  6364. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6365. if (!my.autoPush) {
  6366. packet("a", newMoveDir, 1);
  6367. }
  6368. lastMoveDir = newMoveDir;
  6369. }
  6370. }
  6371. // BUTTON EVENTS:
  6372. function bindEvents() { }
  6373. bindEvents();
  6374. /** PATHFIND TEST */
  6375. function chechPathColl(tmp) {
  6376. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6377. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6378. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6379. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6380. }
  6381. function checkObject() {
  6382. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6383. for (let y = 0; y < pathFind.grid; y++) {
  6384. grid[y] = [];
  6385. for (let x = 0; x < pathFind.grid; x++) {
  6386. let tmpXY = {
  6387. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6388. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6389. }
  6390. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6391. pathFind.lastX = x;
  6392. pathFind.lastY = y;
  6393. grid[y][x] = 0;
  6394. continue;
  6395. }
  6396. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6397. if (find) {
  6398. if (find.trap) {
  6399. grid[y][x] = 0;
  6400. continue;
  6401. }
  6402. grid[y][x] = 1;
  6403. } else {
  6404. grid[y][x] = 0;
  6405. }
  6406. }
  6407. }
  6408. }
  6409. function toFancyTimeFormat(time) {
  6410. let minutes = ~~((time % 3600) / 60);
  6411. let seconds = ~~time % 60;
  6412. if (seconds <= 9) seconds = `0${seconds}`;
  6413. return `${minutes}:${seconds}`;
  6414. }
  6415. let song = {
  6416. '0:13': 'Clean up gang with a hoover,',
  6417. '0:15': 'pull up and sweep the street',
  6418. '0:17': 'Told bae book Park Chinois,',
  6419. '0:18': 'the bricks came cheap',
  6420. '0:19': 'this week',
  6421. '0:20': 'Brought out the glee',
  6422. '0:21': 'this week,',
  6423. '0:22': 'so somethin might end up',
  6424. '0:23': 'on a tee this week',
  6425. '0:24': 'Done studio time done the re',
  6426. '0:25': 'this week,',
  6427. '0:26': 'big bustdown',
  6428. '0:27': "that ain't no Jesus piece",
  6429. '0:28': 'No G17,G19 had the G17',
  6430. '0:29': 'then the G19',
  6431. '0:30': 'Had an old .44',
  6432. '0:31': 'but the pin was weak,',
  6433. '0:32': 'still gonna spin if need',
  6434. '0:35': 'Sayin no smoke backstage,',
  6435. '0:36': 'but bro still ask',
  6436. '0:37': 'can we bring it please,',
  6437. '0:38': 'or a ZK at least',
  6438. '0:40': 'You could see me',
  6439. '0:41': 'in tape with the Gs,',
  6440. '0:42': 'bro just got in a',
  6441. '0:43': 'striptape with the Gs',
  6442. '0:44': "Get the drop it's go time,",
  6443. '0:45': 'bro came out with the key',
  6444. '0:47': 'Yo, 38 autos gang said',
  6445. '0:48': 'we need more sweets',
  6446. '0:50': 'Before Halloween,',
  6447. '0:51': 'we was out playin',
  6448. '0:52': 'trick or treat',
  6449. '0:53': 'An opp boy swam and drowned,',
  6450. '0:55': "he didn't kick his feet",
  6451. '0:57': 'Heard that news',
  6452. '0:58': 'I was right by the runaway,',
  6453. '0:59': 'made me feel like bree',
  6454. '1:00': 'This C comes like',
  6455. '1:01': 'a pocket rocket,',
  6456. '1:02': 'now the gang',
  6457. '1:03': 'in central with C',
  6458. '1:04': 'Had my case papers printed,',
  6459. '1:05': 'now I got the monogram',
  6460. '1:06': 'print on me',
  6461. '1:07': 'Runnin throught bells,',
  6462. '1:08': 'throwback run with the 12',
  6463. '1:10': 'Whole 1 cover the scales,',
  6464. '1:11': 'bine at the barbeque,',
  6465. '1:12': 'better cover your girl',
  6466. '1:14': "Hate when they're",
  6467. '1:15': 'runnin their mouth,',
  6468. '1:16': 'see them runnin for help',
  6469. '1:17': "I'm in the Bando,",
  6470. '1:18': 'but let me see my man again,',
  6471. '1:19': "and I'll double the L",
  6472. '1:21': 'We really leave shit drownin,',
  6473. '1:22': "you ain't brought 3",
  6474. '1:23': 'on an outin',
  6475. '1:24': 'Shootouts in',
  6476. '1:25': 'the oldest clothes,',
  6477. '1:26': "you wouldn't believe",
  6478. '1:27': 'these outfits',
  6479. '1:28': 'Foot down no breaks,',
  6480. '1:29': 'tryna leave everythin taped',
  6481. '1:30': 'Asked bout the shotty,',
  6482. '1:31': 'told them I got it',
  6483. '1:32': 'from the farm,',
  6484. '1:33': 'now they think I got from H',
  6485. '1:34': 'Clean up gang with a hoover,',
  6486. '1:36': 'pull up and sweep the street',
  6487. '1:38': 'Told bae book Park Chinois,',
  6488. '1:39': 'the bricks came cheap',
  6489. '1:40': 'this week',
  6490. '1:41': 'Brought out the glee',
  6491. '1:42': 'this week,',
  6492. '1:43': 'so somethin might end up',
  6493. '1:44': 'on a tee this week',
  6494. '1:45': 'Done studio time done the re',
  6495. '1:46': 'this week,',
  6496. '1:47': 'big bustdown',
  6497. '1:48': "that ain't no Jesus piece",
  6498. '1:49': 'No G17,G19 had the G17',
  6499. '1:50': 'then the G19',
  6500. '1:51': 'Had an old .44',
  6501. '1:52': 'but the pin was weak,',
  6502. '1:53': 'still gonna spin if need',
  6503. '1:54': 'Sayin no smoke backstage,',
  6504. '1:55': 'but bro still ask',
  6505. '1:56': 'can we bring it please,',
  6506. '1:57': 'or a ZK at least',
  6507. '1:59': 'This opps in this',
  6508. '2:00': "spliff's sativa,",
  6509. '2:01': 'still put smoke in the whiz,',
  6510. '2:02': 'Khalifa',
  6511. '2:03': "Bad B don't wanna",
  6512. '2:04': 'lock the smoke,',
  6513. '2:05': 'I just gotta love her',
  6514. '2:06': 'and leave her',
  6515. '2:07': 'Yo, had the Liz',
  6516. '2:08': 'come like Peter',
  6517. '2:09': 'and the bujj like Cleveland',
  6518. '2:10': 'This ice in my wrist says',
  6519. '2:11': 'whole lotta money,',
  6520. '2:12': "swear it's comin like BIA",
  6521. '2:14': 'O14 me, Zee had the bruc',
  6522. '2:15': 'back in a bruck down Kia',
  6523. '2:16': "Now you'll find me in Venice,",
  6524. '2:17': 'tryin some shellfish',
  6525. '2:18': 'oh mama mia',
  6526. '2:19': 'Old school I was',
  6527. '2:20': 'hoppin out first,',
  6528. '2:21': 'had bro sayin',
  6529. '2:22': 'stop bein selfish',
  6530. '2:23': 'Yo,',
  6531. '2:24': 'now I just leave that stage,',
  6532. '2:25': 'pullin strings like Elvis',
  6533. '2:26': 'Ding dong on an outin,',
  6534. '2:27': "would've been a loss",
  6535. '2:28': 'if we found him',
  6536. '2:29': "Can't record,",
  6537. '2:30': 'need more points on the board',
  6538. '2:31': 'Gang, tape it first,',
  6539. '2:32': "then I'll give them an album",
  6540. '2:33': 'Spoke to the yard man,',
  6541. '2:34': 'wanna know the P for the .45,',
  6542. '2:35': 'like Alhan',
  6543. '2:36': 'Spoke to the runner,',
  6544. '2:37': "said he's got more than a oner",
  6545. '2:39': "and he's still counting",
  6546. '2:40': 'Go get that car,',
  6547. '2:41': 'congestion zone,',
  6548. '2:42': 'gotta step with ours',
  6549. '2:43': 'Pocket rocket,',
  6550. '2:44': 'had it in a pouch',
  6551. '2:45': 'next to the brush',
  6552. '2:46': 'and the metro card',
  6553. '2:47': 'Double R truck,',
  6554. '2:48': 'stars in the roof,',
  6555. '2:49': 'and we got a seperate star',
  6556. '2:50': "Ain't done it in a Tesla yet,",
  6557. '2:51': 'if we do thats lead',
  6558. '2:52': 'in an electric car',
  6559. '2:53': 'Clean up gang with a hoover,',
  6560. '2:55': 'pull up and sweep the street',
  6561. '2:57': 'Told bae book Park Chinois,',
  6562. '2:58': 'the bricks came cheap',
  6563. '2:59': 'this week',
  6564. '3:00': 'Brought out the glee',
  6565. '3:01': 'this week,',
  6566. '3:02': 'so somethin might end up',
  6567. '3:03': 'on a tee this week',
  6568. '3:04': 'Done studio time done the re',
  6569. '3:05': 'this week,',
  6570. '3:06': 'big bustdown',
  6571. '3:07': "that ain't no Jesus piece",
  6572. '3:08': 'No G17,G19 had the G17',
  6573. '3:09': 'then the G19',
  6574. '3:10': 'Had an old .44',
  6575. '3:11': 'but the pin was weak,',
  6576. '3:12': 'still gonna spin if need',
  6577. '3:13': 'Sayin no smoke backstage,',
  6578. '3:14': 'but bro still ask',
  6579. '3:15': 'can we bring it please,',
  6580. '3:16': 'or a ZK at least',
  6581. '3:19': '!End of song'
  6582. };
  6583. const songchat1 = new Audio("https://rr3---sn-aigl6nz7.googlevideo.com/videoplayback?expire=1700524713&ei=SZ5bZYf4FsuJsfIPj8GT0AI&ip=54.149.99.115&id=o-AGt6IyGBR0_abMPEfIJDA2sJr0t_Ka7N_G3ELUfDtfpA&itag=140&source=youtube&requiressl=yes&vprv=1&mime=audio%2Fmp4&gir=yes&clen=3275374&dur=202.338&lmt=1698494464324354&keepalive=yes&fexp=24007246,24350018&beids=24350018&c=ANDROID&txp=5318224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ANLwegAwRQIhAJMEVNVw23NW1KSmfvncINhSJy4-dou4S14nm-yjIxoTAiAkLkM4T9TMcRR-ScUd0GPojP-4t4l7nOgwIht_9sP49g%3D%3D&rm=sn-a5meer7z&req_id=2d0862e1b02da3ee&redirect_counter=2&cm2rm=sn-8vq54vox03-aigs7l&cms_redirect=yes&cmsv=e&ipbypass=yes&mh=Lb&mip=84.70.170.143&mm=29&mn=sn-aigl6nz7&ms=rdu&mt=1700503292&mv=m&mvi=3&pl=20&lsparams=ipbypass,mh,mip,mm,mn,ms,mv,mvi,pl&lsig=AM8Gb2swRQIhAKGwN0vdK-w45uGHTaRheVa_1458z4zwvBNf6wHs5sZMAiA1xsEM3IBCdQ1KsSi2v7ya1PrmriH8GyYcPq78obiEzg%3D%3D");
  6584. let isPlaying = false;
  6585. let currentPart = '';
  6586. function toggleSong() {
  6587. if (!isPlaying) {
  6588. songchat1.play();
  6589. songchat1.ontimeupdate = function(time) {
  6590. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  6591. if (part && part !== currentPart) {
  6592. currentPart = part;
  6593. packet("6", part);
  6594. }
  6595. };
  6596. songchat1.onended = function() {
  6597. if (isPlaying) {
  6598. songchat1.play();
  6599. }
  6600. };
  6601. isPlaying = true;
  6602. } else {
  6603. songchat1.pause();
  6604. isPlaying = false;
  6605. }
  6606. }
  6607. document.addEventListener("keypress", function(e) {
  6608. if (e.key === "C") {
  6609. toggleSong();
  6610. }
  6611. });
  6612. function createPath() {
  6613. grid = [];
  6614. checkObject();
  6615. }
  6616. function Pathfinder() {
  6617. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  6618. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  6619. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6620. packet("a", undefined, 1);
  6621. } else {
  6622. createPath();
  6623. easystar.setGrid(grid);
  6624. easystar.setAcceptableTiles([0]);
  6625. easystar.enableDiagonals();
  6626. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function(path) {
  6627. if (path === null) {
  6628. pathFind.array = [];
  6629. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6630. packet("a", undefined, 1);
  6631. } else {
  6632. packet("a", near.aim2, 1);
  6633. }
  6634. } else {
  6635. pathFind.array = path;
  6636. if (pathFind.array.length > 1) {
  6637. let tmpXY = {
  6638. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  6639. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  6640. }
  6641. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  6642. }
  6643. }
  6644. });
  6645. easystar.calculate();
  6646. }
  6647. }
  6648. }
  6649. /** PATHFIND TEST */
  6650. // ITEM COUNT DISPLAY:
  6651. let isItemSetted = [];
  6652. function updateItemCountDisplay(index = undefined) {
  6653. for (let i = 3; i < items.list.length; ++i) {
  6654. let id = items.list[i].group.id;
  6655. let tmpI = items.weapons.length + i;
  6656. if (!isItemSetted[tmpI]) {
  6657. isItemSetted[tmpI] = document.createElement("div");
  6658. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6659. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6660. isItemSetted[tmpI].style = `
  6661. display: block;
  6662. position: absolute;
  6663. padding-left: 5px;
  6664. font-size: 2em;
  6665. color: #fff;
  6666. `;
  6667. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6668. } else {
  6669. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6670. }
  6671. }
  6672. }
  6673. // AUTOPUSH:
  6674. function autoPush() {
  6675. 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) {
  6676. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6677. })[0];
  6678. if (nearTrap) {
  6679. 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) {
  6680. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6681. })[0];
  6682. if (spike) {
  6683. let pos = {
  6684. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6685. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6686. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6687. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6688. };
  6689. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6690. let tmpScale = tmp.getScale();
  6691. 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)) {
  6692. return true;
  6693. }
  6694. });
  6695. if (finds) {
  6696. if (my.autoPush) {
  6697. my.autoPush = false;
  6698. packet("a", lastMoveDir || undefined, 1);
  6699. }
  6700. } else {
  6701. my.autoPush = true;
  6702. my.pushData = {
  6703. x: spike.x + 70,
  6704. y: spike.y + 70,
  6705. x2: pos.x2 + 30,
  6706. y2: pos.y2 + 30
  6707. };
  6708. let scale = player.scale / 10;
  6709. let secondArg = UTILS.getDirect(near, spike, 2, 0) > 70 ? near.aim2 : undefined;
  6710. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6711. packet("a", secondArg, 1);
  6712. } else {
  6713. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6714. }
  6715. }
  6716. } else {
  6717. if (my.autoPush) {
  6718. my.autoPush = false;
  6719. packet("a", lastMoveDir || undefined, 1);
  6720. }
  6721. }
  6722. } else {
  6723. if (my.autoPush) {
  6724. my.autoPush = false;
  6725. packet("a", lastMoveDir || undefined, 1);
  6726. }
  6727. }
  6728. }
  6729. // AUTOPUSH:
  6730. /* function autoPush() { //LEGACY AUTOPUSH
  6731. 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) {
  6732. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6733. })[0];
  6734. if (nearTrap) {
  6735. 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) {
  6736. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6737. })[0];
  6738. if (spike) {
  6739. let pos = {
  6740. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6741. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6742. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6743. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6744. };
  6745. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6746. let tmpScale = tmp.getScale();
  6747. 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)) {
  6748. return true;
  6749. }
  6750. });
  6751. if (finds) {
  6752. if (my.autoPush) {
  6753. my.autoPush = false;
  6754. packet("33", lastMoveDir||undefined, 1);
  6755. }
  6756. } else {
  6757. my.autoPush = true;
  6758. my.pushData = {
  6759. x: spike.x,
  6760. y: spike.y,
  6761. x2: pos.x2,
  6762. y2: pos.y2
  6763. };
  6764. let scale = (player.scale / 10);
  6765. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6766. packet("33", near.aim2, 1);
  6767. } else {
  6768. packet("33", UTILS.getDirect(pos, player, 2, 2), 1);
  6769. }
  6770. }
  6771. } else {
  6772. if (my.autoPush) {
  6773. my.autoPush = false;
  6774. packet("33", lastMoveDir||undefined, 1);
  6775. }
  6776. }
  6777. } else {
  6778. if (my.autoPush) {
  6779. my.autoPush = false;
  6780. packet("33", lastMoveDir||undefined, 1);
  6781. }
  6782. }
  6783. }*/
  6784. // ADD DEAD PLAYER:
  6785. function addDeadPlayer(tmpObj) {
  6786. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6787. }
  6788. /** APPLY SOCKET CODES */
  6789. // SET INIT DATA:
  6790. function setInitData(data) {
  6791. alliances = data.teams;
  6792. }
  6793. // SETUP GAME:
  6794. var fisrtloadez = false;
  6795. function setupGame(yourSID) {
  6796. keys = {};
  6797. macro = {};
  6798. playerSID = yourSID;
  6799. attackState = 0;
  6800. inGame = true;
  6801. fisrtloadez = true;
  6802. packet("d", 0, getAttackDir(), 1);
  6803. my.ageInsta = true;
  6804. if (firstSetup) {
  6805. firstSetup = false;
  6806. gameObjects.length = 0;
  6807. }
  6808. }
  6809. // ADD NEW PLAYER:
  6810. function addPlayer(data, isYou) {
  6811. let tmpPlayer = findPlayerByID(data[0]);
  6812. if (!tmpPlayer) {
  6813. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6814. objectManager, players, ais, items, hats, accessories);
  6815. players.push(tmpPlayer);
  6816. if (data[1] != playerSID) {
  6817. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6818. }
  6819. } else {
  6820. if (data[1] != playerSID) {
  6821. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6822. }
  6823. }
  6824. tmpPlayer.spawn(isYou ? true : null);
  6825. tmpPlayer.visible = false;
  6826. tmpPlayer.oldPos = {
  6827. x2: undefined,
  6828. y2: undefined
  6829. };
  6830. tmpPlayer.x2 = undefined;
  6831. tmpPlayer.y2 = undefined;
  6832. tmpPlayer.x3 = undefined;
  6833. tmpPlayer.y3 = undefined;
  6834. tmpPlayer.setData(data);
  6835. if (isYou) {
  6836. if (!player) {
  6837. window.prepareUI(tmpPlayer);
  6838. }
  6839. player = tmpPlayer;
  6840. camX = player.x;
  6841. camY = player.y;
  6842. my.lastDir = 0;
  6843. updateItems();
  6844. updateAge();
  6845. updateItemCountDisplay();
  6846. if (player.skins[7]) {
  6847. my.reSync = true;
  6848. }
  6849. }
  6850. }
  6851. // REMOVE PLAYER:
  6852. function removePlayer(id) {
  6853. for (let i = 0; i < players.length; i++) {
  6854. if (players[i].id == id) {
  6855. let tmpPlayer = players[i];
  6856. addChatLog(tmpPlayer.name + " has died", "#db2727", "", "#db2727");
  6857. players.splice(i, 1);
  6858. break;
  6859. }
  6860. }
  6861. }
  6862. // UPDATE HEALTH:
  6863. function updateHealth(sid, value) {
  6864. tmpObj = findPlayerBySID(sid);
  6865. if (tmpObj) {
  6866. tmpObj.oldHealth = tmpObj.health;
  6867. tmpObj.health = value;
  6868. tmpObj.judgeShame();
  6869. if (tmpObj.oldHealth > tmpObj.health) {
  6870. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6871. advHeal.push([sid, value, tmpObj.damaged]);
  6872. } else {
  6873. }
  6874. }
  6875. }
  6876. // KILL PLAYER:
  6877. function killPlayer() {
  6878. inGame = false;
  6879. lastDeath = {
  6880. x: player.x,
  6881. y: player.y,
  6882. };
  6883. if (configs.autoRespawn) {
  6884. getEl("ot-sdk-btn-floating").style.display = "none";
  6885. packet("M", {
  6886. name: lastsp[0],
  6887. moofoll: lastsp[1],
  6888. skin: lastsp[2]
  6889. });
  6890. }
  6891. }
  6892. // UPDATE PLAYER ITEM VALUES:
  6893. function updateItemCounts(index, value) {
  6894. if (player) {
  6895. player.itemCounts[index] = value;
  6896. updateItemCountDisplay(index);
  6897. }
  6898. }
  6899. // UPDATE AGE:
  6900. function updateAge(xp, mxp, age) {
  6901. if (xp != undefined)
  6902. player.XP = xp;
  6903. if (mxp != undefined)
  6904. player.maxXP = mxp;
  6905. if (age != undefined)
  6906. player.age = age;
  6907. }
  6908. // UPDATE UPGRADES:
  6909. function updateUpgrades(points, age) {
  6910. player.upgradePoints = points;
  6911. player.upgrAge = age;
  6912. if (points > 0) {
  6913. tmpList.length = 0;
  6914. UTILS.removeAllChildren(upgradeHolder);
  6915. for (let i = 0; i < items.weapons.length; ++i) {
  6916. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6917. let e = UTILS.generateElement({
  6918. id: "upgradeItem" + i,
  6919. class: "actionBarItem",
  6920. onmouseout: function() {
  6921. showItemInfo();
  6922. },
  6923. parent: upgradeHolder
  6924. });
  6925. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6926. tmpList.push(i);
  6927. }
  6928. }
  6929. for (let i = 0; i < items.list.length; ++i) {
  6930. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6931. let tmpI = (items.weapons.length + i);
  6932. let e = UTILS.generateElement({
  6933. id: "upgradeItem" + tmpI,
  6934. class: "actionBarItem",
  6935. onmouseout: function() {
  6936. showItemInfo();
  6937. },
  6938. parent: upgradeHolder
  6939. });
  6940. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6941. tmpList.push(tmpI);
  6942. }
  6943. }
  6944. for (let i = 0; i < tmpList.length; i++) {
  6945. (function(i) {
  6946. let tmpItem = getEl('upgradeItem' + i);
  6947. tmpItem.onmouseover = function() {
  6948. if (items.weapons[i]) {
  6949. showItemInfo(items.weapons[i], true);
  6950. } else {
  6951. showItemInfo(items.list[i - items.weapons.length]);
  6952. }
  6953. };
  6954. tmpItem.onclick = UTILS.checkTrusted(function() {
  6955. packet("H", i);
  6956. });
  6957. UTILS.hookTouchEvents(tmpItem);
  6958. })(tmpList[i]);
  6959. }
  6960. if (tmpList.length) {
  6961. upgradeHolder.style.display = "block";
  6962. upgradeCounter.style.display = "block";
  6963. upgradeCounter.style.borderRadius = "4px";
  6964. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6965. } else {
  6966. upgradeHolder.style.display = "none";
  6967. upgradeCounter.style.display = "none";
  6968. showItemInfo();
  6969. }
  6970. } else {
  6971. upgradeHolder.style.display = "none";
  6972. upgradeCounter.style.display = "none";
  6973. showItemInfo();
  6974. }
  6975. }
  6976. function cdf(e, t) {
  6977. try {
  6978. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6979. } catch (e) {
  6980. return Infinity;
  6981. }
  6982. }
  6983. function caf(e, t) {
  6984. try {
  6985. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6986. } catch (e) {
  6987. return 0;
  6988. }
  6989. }
  6990. function numArr(e = 0, t = 1, act, n = 1) {
  6991. let arr = [];
  6992. for (let i = e; i < t; i += n) {
  6993. arr.push(i);
  6994. typeof act == "function" && act(i);
  6995. }
  6996. return arr;
  6997. }
  6998. function toR(e) {
  6999. var n = (e * Math.PI / 180) % (2 * Math.PI);
  7000. return n > Math.PI ? Math.PI - n : n
  7001. }
  7002. function toD(e) {
  7003. var n = (e / Math.PI * 360) % 360;
  7004. return n >= 360 ? n - 360 : n;
  7005. }
  7006.  
  7007. // KILL OBJECT:
  7008. function killObject(sid) {
  7009. let findObj = findObjectBySid(sid);
  7010. objectManager.disableBySid(sid);
  7011. if (player) {
  7012. for (let i = 0; i < breakObjects.length; i++) {
  7013. if (breakObjects[i].sid == sid) {
  7014. breakObjects.splice(i, 1);
  7015. break;
  7016. }
  7017. }
  7018. if (!player.canSee(findObj)) {
  7019. breakTrackers.push({x: findObj.x, y: findObj.y});
  7020. }
  7021. if (breakTrackers.length > 8) {
  7022. breakTrackers.shift();
  7023. }
  7024. traps.replacer(findObj);
  7025. }
  7026. }
  7027. // KILL ALL OBJECTS BY A PLAYER:
  7028. function killObjects(sid) {
  7029. if (player) objectManager.removeAllItems(sid);
  7030. }
  7031. function fgdo(a, b) {
  7032. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  7033. }
  7034. function precheckPlace(a, b) {
  7035. checkPlace(a, b);
  7036. console.log('success');
  7037. }
  7038. function perfectReplace() {
  7039. // let range = items.weapons[player.weapons[0]].range + 70;
  7040. // const interval = setInterval(() => {
  7041. // gameObjects.forEach(tmpObj => {
  7042. // let objDst = UTILS.getDist(tmpObj, player, 0, 2);
  7043. // let perfectAngle = UTILS.getDirect(tmpObj, player, 0, 2);
  7044. // if (tmpObj.health <= 272.58 && fgdo(tmpObj, player) <= range && near.dist2 <= 300) {
  7045. // console.log('preplace');
  7046. // place(2, perfectAngle);
  7047. // }
  7048. // });
  7049. // });
  7050. // setTimeout(() => {
  7051. // clearInterval(interval);
  7052. // }, 500);
  7053. }
  7054. let ticks = {
  7055. tick: 0,
  7056. delay: 0,
  7057. time: [],
  7058. manage: [],
  7059. };
  7060. // GAME TICKOUT:
  7061. function setTickout(doo, timeout) {
  7062. if (!ticks.manage[ticks.tick + timeout]) {
  7063. ticks.manage[ticks.tick + timeout] = [doo];
  7064. } else {
  7065. ticks.manage[ticks.tick + timeout].push(doo);
  7066. }
  7067. }
  7068. function doNextTick(doo) {
  7069. waitTicks.push(doo);
  7070. }
  7071. let waitTicks = [];
  7072. // UPDATE PLAYER DATA:
  7073. let nEy;
  7074. let plaguemask = true;
  7075. let placeableSpikes = [];
  7076. let placeableTraps = [];
  7077. let placeableSpikesPREDICTS = [];
  7078. function updatePlayers(data) {
  7079. game.tick++;
  7080. enemy = [];
  7081. perfectReplace();
  7082. nears = [];
  7083. near = [];
  7084. //showPlace = [];
  7085. game.tickSpeed = performance.now() - game.lastTick;
  7086. game.lastTick = performance.now();
  7087. ticks.tick++;
  7088. ticks.time.push(Date.now() - ticks.delay <= 50 || Date.now() - ticks.delay >= 175 ? "lag" : 1);
  7089. if (ticks.tick % 10 === 0) {
  7090. ticks.time = [];
  7091. }
  7092. if (ticks.tick % 300 === 0) {
  7093. }
  7094. ticks.delay = Date.now();
  7095. players.forEach((tmp) => {
  7096. tmp.forcePos = !tmp.visible;
  7097. tmp.visible = false;
  7098. });
  7099. for (let i = 0; i < data.length;) {
  7100. tmpObj = findPlayerBySID(data[i]);
  7101. if (tmpObj) {
  7102. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7103. tmpObj.t2 = game.lastTick;
  7104. tmpObj.oldPos.x2 = tmpObj.x2;
  7105. tmpObj.oldPos.y2 = tmpObj.y2;
  7106. tmpObj.x1 = tmpObj.x;
  7107. tmpObj.y1 = tmpObj.y;
  7108. tmpObj.x2 = data[i + 1];
  7109. tmpObj.y2 = data[i + 2];
  7110. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7111. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7112. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7113. tmpObj.d2 = data[i + 3];
  7114. tmpObj.dt = 0;
  7115. tmpObj.buildIndex = data[i + 4];
  7116. tmpObj.weaponIndex = data[i + 5];
  7117. tmpObj.weaponVariant = data[i + 6];
  7118. tmpObj.team = data[i + 7];
  7119. tmpObj.isLeader = data[i + 8];
  7120. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7121. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7122. tmpObj.skinIndex = data[i + 9];
  7123. tmpObj.tailIndex = data[i + 10];
  7124. tmpObj.iconIndex = data[i + 11];
  7125. tmpObj.zIndex = data[i + 12];
  7126. tmpObj.visible = true;
  7127. tmpObj.update(game.tickSpeed);
  7128. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7129. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7130. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7131. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7132. tmpObj.damageThreat = 0;
  7133. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7134. tmpObj.addShameTimer();
  7135. }
  7136. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7137. tmpObj.shameTimer = 0;
  7138. tmpObj.shameCount = 0;
  7139. if (tmpObj == player) {
  7140. healer();
  7141. }
  7142. }
  7143. nEy = tmpObj;
  7144. if (tmpObj == player) {
  7145. if (gameObjects.length) {
  7146. gameObjects.forEach((tmp) => {
  7147. tmp.onNear = false;
  7148. if (tmp.active) {
  7149. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7150. tmp.onNear = true;
  7151. }
  7152. if (tmp.isItem && tmp.owner) {
  7153. 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)) {
  7154. tmp.breakObj = true;
  7155. breakObjects.push({
  7156. x: tmp.x,
  7157. y: tmp.y,
  7158. sid: tmp.sid
  7159. });
  7160. }
  7161. }
  7162. }
  7163. });
  7164. let nearTrap = gameObjects.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 5) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  7165. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7166. })[0];
  7167. if (nearTrap) {
  7168. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7169. traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7170. if (!traps.inTrap) {
  7171. traps.protect(traps.aim);
  7172. }
  7173. traps.inTrap = true;
  7174. traps.info = nearTrap;
  7175. } else {
  7176. traps.inTrap = false;
  7177. traps.info = {};
  7178. }
  7179. } else {
  7180. traps.inTrap = false;
  7181. }
  7182. }
  7183. if (tmpObj.weaponIndex < 9) {
  7184. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7185. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7186. } else if (tmpObj.weaponIndex > 8) {
  7187. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7188. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7189. }
  7190. }
  7191. i += 13;
  7192. }
  7193. if (waitTicks.length) {
  7194. waitTicks.forEach((ajaj) => {
  7195. ajaj();
  7196. }
  7197. );
  7198. waitTicks = [];
  7199. }
  7200. if (runAtNextTick.length) {
  7201. runAtNextTick.forEach((tmp) => {
  7202. checkProjectileHolder(...tmp);
  7203. }
  7204. );
  7205. runAtNextTick = [];
  7206. }
  7207. if (textManager.stack.length) {
  7208. let stacks = [];
  7209. let notstacks = [];
  7210. let num = 0;
  7211. let num2 = 0;
  7212. let pos = {
  7213. x: null,
  7214. y: null
  7215. };
  7216. let pos2 = {
  7217. x: null,
  7218. y: null
  7219. }
  7220. textManager.stack.forEach((text) => {
  7221. if (text.value >= 0) {
  7222. if (num == 0) pos = {
  7223. x: text.x,
  7224. y: text.y
  7225. };
  7226. num += Math.abs(text.value);
  7227. } else {
  7228. if (num2 == 0) pos2 = {
  7229. x: text.x,
  7230. y: text.y
  7231. };
  7232. num2 += Math.abs(text.value);
  7233. }
  7234. });
  7235. if (num2 > 0) {
  7236. textManager.showText(pos2.x, pos2.y, Math.max(43, Math.min(50, num2)), 0.18, 500, num2, damageTextColor = "#782F44");
  7237. }
  7238. if (num > 0) {
  7239. textManager.showText(pos.x, pos.y, Math.max(43, Math.min(50, num)), 0.18, 500, num, damageTextColor = "#782F44");
  7240. }
  7241. textManager.stack = [];
  7242. }
  7243. if (runAtNextTick.length) {
  7244. runAtNextTick.forEach((tmp) => {
  7245. checkProjectileHolder(...tmp);
  7246. });
  7247. runAtNextTick = [];
  7248. }
  7249. for (let i = 0; i < data.length;) {
  7250. tmpObj = findPlayerBySID(data[i]);
  7251. if (tmpObj) {
  7252. if (!tmpObj.isTeam(player)) {
  7253. enemy.push(tmpObj);
  7254. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7255. nears.push(tmpObj);
  7256. }
  7257. }
  7258. tmpObj.manageReload();
  7259. if (tmpObj != player) {
  7260. tmpObj.addDamageThreat(player);
  7261. }
  7262. }
  7263. i += 13;
  7264. }
  7265. /*projectiles.forEach((proj) => {
  7266. tmpObj = proj;
  7267. if (tmpObj.active) {
  7268. tmpObj.tickUpdate(game.tickSpeed);
  7269. }
  7270. });*/
  7271. if (player && player.alive) {
  7272. if (enemy.length) {
  7273. if (player && player.alive){
  7274. placeableSpikes = getPlaceablePositions(player, items.list[player.items[2]]);
  7275. placeableTraps = player.items[4] == 15 ? getPlaceablePositions(player, items.list[player.items[4]]) : [];
  7276. }
  7277.  
  7278. near = enemy.sort(function(tmp1, tmp2) {
  7279. return tmp1.dist2 - tmp2.dist2;
  7280. })[0];
  7281. } else {
  7282. // console.log("no enemy");
  7283. }
  7284. if (game.tickQueue[game.tick]) {
  7285. game.tickQueue[game.tick].forEach((action) => {
  7286. action();
  7287. });
  7288. game.tickQueue[game.tick] = null;
  7289. }
  7290. if (advHeal.length) {
  7291. advHeal.forEach((updHealth) => {
  7292. let sid = updHealth[0];
  7293. let value = updHealth[1];
  7294. let totalDamage = 100 - value
  7295. let damaged = updHealth[2];
  7296. tmpObj = findPlayerBySID(sid);
  7297. let bullTicked = false;
  7298. if (tmpObj && tmpObj.health <= 0) {
  7299. if (!tmpObj.death) {
  7300. tmpObj.death = true;
  7301. if (tmpObj != player) {
  7302. addChatLog(tmpObj.name + " has died", "#db2727", "", "#db2727");
  7303. }
  7304. addDeadPlayer(tmpObj);
  7305. }
  7306. }
  7307. if (tmpObj == player) {
  7308. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7309. if (my.reSync) {
  7310. my.reSync = false;
  7311. tmpObj.setBullTick = true;
  7312. }
  7313. bullTicked = true;
  7314. }
  7315. if (inGame) {
  7316. let dmg = 100 - player.health;
  7317. let attackers = getAttacker(damaged);
  7318. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7319. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  7320. let heal = function () {
  7321. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && clicks.left)) {
  7322. setTimeout(() => {
  7323. healer();
  7324. }, 140 - window.pingTime);
  7325. } else {
  7326. setTimeout(() => {
  7327. healer()
  7328. }, 222 - window.pingTime);
  7329. }
  7330. }
  7331. if (attackers.length) {
  7332. let by = attackers.filter((tmp) => {
  7333. if (tmp.dist2 <= (tmp.weaponIndex < 9 ? 300 : 700)) {
  7334. tmpDir = UTILS.getDirect(player, tmp, 2, 2);
  7335. if (UTILS.getAngleDist(tmpDir, tmp.d2) <= Math.PI) {
  7336. return tmp;
  7337. }
  7338. }
  7339. });
  7340. if (by.length) {
  7341. let maxDamage = (includeSpikeDmgs ? 10 : 10);
  7342. if (damaged > maxDamage && (game.tick - tmpObj.antiTimer) > 1) {
  7343. tmpObj.canEmpAnti = true;
  7344. tmpObj.antiTimer = game.tick;
  7345. if (tmpObj.shameCount < 5) {
  7346. healer();
  7347. } else {
  7348. heal();
  7349. }
  7350. } else {
  7351. heal();
  7352. }
  7353. } else {
  7354. heal();
  7355. }
  7356. } else {
  7357. heal();
  7358. }
  7359. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7360. }
  7361. } else {
  7362. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7363. tmpObj.setPoisonTick = true;
  7364. }
  7365. }
  7366. });
  7367. advHeal = [];
  7368. }
  7369. players.forEach((tmp) => {
  7370. if (!tmp.visible && player != tmp) {
  7371. tmp.reloads = {
  7372. 0: 0,
  7373. 1: 0,
  7374. 2: 0,
  7375. 3: 0,
  7376. 4: 0,
  7377. 5: 0,
  7378. 6: 0,
  7379. 7: 0,
  7380. 8: 0,
  7381. 9: 0,
  7382. 10: 0,
  7383. 11: 0,
  7384. 12: 0,
  7385. 13: 0,
  7386. 14: 0,
  7387. 15: 0,
  7388. 53: 0,
  7389. };
  7390. }
  7391. if (tmp.setBullTick) {
  7392. tmp.bullTimer = 0;
  7393. }
  7394. if (tmp.setPoisonTick) {
  7395. tmp.poisonTimer = 0;
  7396. }
  7397. tmp.updateTimer();
  7398. });
  7399. if (inGame) {
  7400. ping = window.pingTime
  7401. inWater = player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2
  7402. if (enemy.length) {
  7403. if (configs1.AutoQonSync && nears.length > 1 && player.shameCount < 5 && !nears.some(item => [0, 7, 8, 9].includes(item.primaryIndex)) && secPacket < 40) {
  7404. sendChat("sync detect test")
  7405. tmpObj.canEmpAnti = false
  7406. my.anti0Tick = 3
  7407. predictHeal(2)
  7408. if (player.health < 90) {
  7409. healer()
  7410. }
  7411. }
  7412. if (configs1.AutoQonHigh && ping >= 80) {
  7413. let dmg = 100 - player.health
  7414. if ((tmpObj.damageThreat >= 95 || dmg + tmpObj.damageThreat >= 95) && player.skinIndex != 7 && player.shameCount < 5) {
  7415. predictHeal(2)
  7416. } else {
  7417. setTimeout(() => {
  7418. healer()
  7419. }, 120 - ping)
  7420. }
  7421. }
  7422. if (configs.fpsboost) {
  7423. window.location.native_resolution = true;
  7424. setTimeout(() => {
  7425. console.clear
  7426. }, 2000);
  7427. }
  7428. if (configs1.AutoPlace) {
  7429. autoplacer()
  7430. }
  7431. packetData.placeQ = packetData.place;
  7432. packetData.place = [];
  7433. if (packetData.placeQ.length) for (let i = 0; i < packetData.placeQ.length; i++) {
  7434. if (packetData.placeQ[i][0] != undefined && player.itemCounts[packetData.placeQ[i][0]] ? (player.itemCounts[packetData.placeQ[i][0]] < 99) : true && secondaryCheck(packetData.placeQ[i][0], packetData.placeQ[i][1])) {
  7435. place(packetData.placeQ[i][0], packetData.placeQ[i][1]);
  7436. }
  7437. }
  7438. if (player.canEmpAnti) {
  7439. player.canEmpAnti = false;
  7440. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7441. if (near.reloads[53] == 0) {
  7442. player.empAnti = true;
  7443. player.soldierAnti = false;
  7444. //modLog("EmpAnti");
  7445. } else {
  7446. player.empAnti = false;
  7447. player.soldierAnti = true;
  7448. //modLog("SoldierAnti");
  7449. }
  7450. }
  7451. }
  7452. let prehit = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function(a, b) {
  7453. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7454. })[0];
  7455. if (prehit) {
  7456. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs1.AutoPredictTick) {
  7457. instaC.canSpikeTick = true;
  7458. instaC.syncHit = true;
  7459. if (instaC.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7460. instaC.revTick = true;
  7461. }
  7462. }
  7463. }
  7464. 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) {
  7465. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7466. })[0];
  7467. let moreAntiSpikeTick = traps.checkSpikeTick()
  7468. if (antiSpikeTick && !traps.inTrap) {
  7469. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7470. my.anti0Tick = 1;
  7471. packet("6", "hi : " + near.sid);
  7472. player.chat.count = 2000;
  7473. }
  7474. }
  7475. if (moreAntiSpikeTick) {
  7476. my.anti0Tick = 4;
  7477. sendChat("op anti spike tick wat ofc")
  7478. }
  7479. }
  7480. nears.forEach((tmpPlayer) => {
  7481. if (tmpPlayer.primaryIndex == 5 && tmpPlayer.primaryVariant >= 2) {
  7482. if (tmpPlayer.dist2 >= 160 && tmpPlayer.dist2 < 260) {
  7483. if (tmpPlayer.skinIndex == 53) {
  7484. buyEquip(6, 0);
  7485. }
  7486. }
  7487. }
  7488. })
  7489. if ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100) &&
  7490. near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 &&
  7491. (instaC.wait || (Math.floor(Math.random() * 5) == 0)) &&
  7492. !instaC.isTrue &&
  7493. !my.waitHit &&
  7494. player.reloads[player.weapons[0]] == 0 &&
  7495. player.reloads[player.weapons[1]] == 0 &&
  7496. (getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) &&
  7497. instaC.perfCheck(player, near)) {
  7498.  
  7499. if (player.checkCanInsta(true) >= 100) {
  7500. instaC.nobull = false;
  7501. } else {
  7502. instaC.nobull = false; // Note: This line seems redundant in the original code
  7503. }
  7504.  
  7505. instaC.can = true;
  7506. } else {
  7507. instaC.can = false;
  7508. }
  7509.  
  7510. macro.q && place(0, getAttackDir());
  7511. macro.f && place(4, getSafeDir());
  7512. macro.v && place(2, getSafeDir());
  7513. macro.y && place(5, getSafeDir());
  7514. macro.h && place(player.getItemType(22), getSafeDir());
  7515. macro.n && place(3, getSafeDir());
  7516.  
  7517. if (game.tick % 3 == 0) {
  7518. if (mills.place) {
  7519. let plcAng = 1.25;
  7520. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7521. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7522. }
  7523. } else {
  7524. if (mills.placeSpawnPads) {
  7525. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7526. checkPlace(
  7527. player.getItemType(20),
  7528. UTILS.getDirect(player.oldPos, player, 2, 2) + i
  7529. );
  7530. }
  7531. }
  7532. }
  7533. }
  7534.  
  7535. if (instaC.can) {
  7536. instaC.changeType("rev");
  7537. }
  7538.  
  7539. if (instaC.canCounter) {
  7540. instaC.canCounter = false;
  7541. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7542. instaC.counterType();
  7543. }
  7544. }
  7545.  
  7546. if (instaC.canSpikeTick) {
  7547. instaC.canSpikeTick = false;
  7548. if (instaC.revTick) {
  7549. instaC.revTick = false;
  7550. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7551. instaC.changeType("rev");
  7552. }
  7553. } else {
  7554. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7555. instaC.spikeTickType();
  7556. if (instaC.syncHit) {
  7557. }
  7558. }
  7559. }
  7560. }
  7561. let turretEmp = 0;
  7562. let inbullspam = false;
  7563. let waitTicks = [];
  7564. let anti0Tick = 0;
  7565. let syncCount = 0;
  7566. let doEmpAntiInsta = false;
  7567. let plagueCount = 0;
  7568. if (near.skinIndex !== 26 && configs1.AutoBullSpam && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  7569. setTimeout(() => {
  7570. if (player.weaponIndex !== player.weapons[0] || player.buildIndex > -1) {
  7571. selectWeapon(player.weapons[0]);
  7572. }
  7573. if (player.reloads[player.weapons[0]] === 0 && !my.waitHit) {
  7574. sendAutoGather();
  7575. my.waitHit = 1;
  7576. my.autoAim = true;
  7577. inbullspam = true;
  7578. Hg(!plaguemask ? 7 : 21, 18);
  7579. game.tickBase(() => {
  7580. sendAutoGather();
  7581. my.waitHit = 0;
  7582. my.autoAim = false;
  7583. inbullspam = false;
  7584. Hg(near.skinIndex === 7 ? near.antiBull > 0 ? 11 : 6 : 6, 21);
  7585. }, 10);
  7586. }
  7587. }, 5);
  7588. } else {
  7589. inbullspam = false;
  7590. }
  7591.  
  7592. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7593. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7594. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7595. }
  7596. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7597. sendAutoGather();
  7598. my.waitHit = 1;
  7599. game.tickBase(() => {
  7600. sendAutoGather();
  7601. my.waitHit = 0;
  7602. }, 1);
  7603. }
  7604. }
  7605. if (traps.inTrap) {
  7606. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7607. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7608. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7609. }
  7610. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7611. sendAutoGather();
  7612. my.waitHit = 1;
  7613. invisBody = true;
  7614. game.tickBase(() => {
  7615. sendAutoGather();
  7616. my.waitHit = 0;
  7617. invisBody = false;
  7618. }, 1);
  7619. }
  7620. }
  7621. }
  7622. if (clicks.middle && !traps.inTrap) {
  7623. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7624. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7625. instaC.bowMovement();
  7626. } else {
  7627. instaC.rangeType();
  7628. }
  7629. }
  7630. }
  7631. if (macro.t && !traps.inTrap) {
  7632. 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))) {
  7633. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7634. }
  7635. }
  7636. if (macro["."] && !traps.inTrap) {
  7637. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7638. instaC.boostTickMovement();
  7639. }
  7640. }
  7641. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue) {
  7642. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7643. if (!my.reloaded) {
  7644. my.reloaded = true;
  7645. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7646. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7647. selectWeapon(player.weapons[fastSpeed]);
  7648. }
  7649. }
  7650. } else {
  7651. my.reloaded = false;
  7652. if (player.reloads[player.weapons[0]] > 0) {
  7653. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7654. selectWeapon(player.weapons[0]);
  7655. }
  7656. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7657. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7658. selectWeapon(player.weapons[1]);
  7659. }
  7660. }
  7661. }
  7662. }
  7663. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7664. packet("D", getAttackDir());
  7665. }
  7666. let hatChanger = function() {
  7667. if (my.anti0Tick > 0) {
  7668. buyEquip(6, 0);
  7669. } else {
  7670. if ((!enemy.length || tmpObj.mostDamageThreat <= 95) && player.shameCount > 0 && (player.skinIndex != 45) || my.reSync) {
  7671. buyEquip(7, 0);
  7672. } else {
  7673. if (clicks.left || clicks.right) {
  7674. if (clicks.left) {
  7675. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 6 : player.soldierAnti ? 26 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7676. } else if (clicks.right) {
  7677. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 6 : player.soldierAnti ? 26 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7678. }
  7679. } else if (traps.inTrap) {
  7680. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7681. buyEquip(40, 0);
  7682. if (near.dist2 > 300 && (!player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7683. buyEquip(6, 0);
  7684. }
  7685. } else {
  7686. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 6 : 22, 0);
  7687. }
  7688. } else {
  7689. if (player.empAnti || player.soldierAnti) {
  7690. buyEquip(player.empAnti ? 6 : 40, 0);
  7691. } else {
  7692. if (inWater) {
  7693. if (!configs1.alwaysFlipper) {
  7694. if (near.dist2 <= 300) {
  7695. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7696. } else {
  7697. biomeGear()
  7698. }
  7699. } else {
  7700. biomeGear()
  7701. }
  7702. } else {
  7703. biomeGear()
  7704. }
  7705. }
  7706. }
  7707. }
  7708. }
  7709. }
  7710. let accChanger = function() {
  7711. if (clicks.left) {
  7712. buyEquip(21, 1);
  7713. } else if (clicks.right) {
  7714. buyEquip(21, 1)
  7715. } else if (traps.inTrap) {
  7716. buyEquip(21, 1);
  7717. } else if (near.dist2 < 300) {
  7718. if (getEl("antiBullType").value == "noab") {
  7719. buyEquip(21, 1)
  7720. } else if (inWater) {
  7721. buyEquip(21, 1)
  7722. } else {
  7723. buyEquip(21, 1);
  7724. }
  7725. } else {
  7726. buyEquip(11, 1);
  7727. }
  7728. }
  7729. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7730. hatChanger();
  7731. accChanger();
  7732. }
  7733. if (configs1.AutoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7734. autoPush();
  7735. } else {
  7736. if (my.autoPush) {
  7737. my.autoPush = false;
  7738. packet("a", lastMoveDir || undefined, 1);
  7739. }
  7740. }
  7741. if (!my.autoPush && pathFind.active) {
  7742. Pathfinder();
  7743. }
  7744. if (instaC.ticking) {
  7745. instaC.ticking = false;
  7746. }
  7747. if (instaC.syncHit) {
  7748. instaC.syncHit = false;
  7749. }
  7750. if (player.empAnti) {
  7751. player.empAnti = false;
  7752. }
  7753. if (player.soldierAnti) {
  7754. player.soldierAnti = false;
  7755. }
  7756. if (my.anti0Tick > 0) {
  7757. my.anti0Tick--;
  7758. }
  7759. if (traps.replaced) {
  7760. traps.replaced = false;
  7761. }
  7762. if (traps.antiTrapped) {
  7763. traps.antiTrapped = false;
  7764. }
  7765. }
  7766. }
  7767. if (botSkts.length) {
  7768. botSkts.forEach((bots) => {
  7769. if (true) {
  7770. bots[0].ssend("player", player, near, botIDS);
  7771. }
  7772. });
  7773. }
  7774. }
  7775. // UPDATE LEADERBOARD:
  7776. function updateLeaderboard(data) {
  7777. UTILS.removeAllChildren(leaderboardData);
  7778. var tmpC = 1;
  7779. for (var i = 0; i < data.length; i += 3) {
  7780. // console.log(data);
  7781. (function(i) {
  7782. UTILS.generateElement({
  7783. class: "leaderHolder",
  7784. parent: leaderboardData,
  7785. children: [
  7786. UTILS.generateElement({
  7787. class: "leaderboardItem",
  7788. 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;", //"font-size: 18px;",
  7789. text: (data[i + 1] != "" ? data[i + 1] : "unknown") + " |"
  7790. }),
  7791. UTILS.generateElement({
  7792. class: "a", //class: "leaderScore",
  7793. 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;",
  7794. text: ("? " + UTILS.kFormat(data[i + 2]) || "? 0")
  7795. })
  7796. ]
  7797. });
  7798. })(i);
  7799. tmpC++;
  7800. }
  7801. }
  7802.  
  7803. // LOAD GAME OBJECT:
  7804. function loadGameObject(data) {
  7805. for (let i = 0; i < data.length;) {
  7806. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7807. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7808. sid: data[i + 7]
  7809. } : null));
  7810. i += 8;
  7811. }
  7812. }
  7813. // ADD AI:
  7814. function loadAI(data) {
  7815. for (let i = 0; i < ais.length; ++i) {
  7816. ais[i].forcePos = !ais[i].visible;
  7817. ais[i].visible = false;
  7818. }
  7819. if (data) {
  7820. let tmpTime = performance.now();
  7821. for (let i = 0; i < data.length;) {
  7822. tmpObj = findAIBySID(data[i]);
  7823. if (tmpObj) {
  7824. tmpObj.index = data[i + 1];
  7825. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7826. tmpObj.t2 = tmpTime;
  7827. tmpObj.x1 = tmpObj.x;
  7828. tmpObj.y1 = tmpObj.y;
  7829. tmpObj.x2 = data[i + 2];
  7830. tmpObj.y2 = data[i + 3];
  7831. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7832. tmpObj.d2 = data[i + 4];
  7833. tmpObj.health = data[i + 5];
  7834. tmpObj.dt = 0;
  7835. tmpObj.visible = true;
  7836. } else {
  7837. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7838. tmpObj.x2 = tmpObj.x;
  7839. tmpObj.y2 = tmpObj.y;
  7840. tmpObj.d2 = tmpObj.dir;
  7841. tmpObj.health = data[i + 5];
  7842. if (!aiManager.aiTypes[data[i + 1]].name)
  7843. tmpObj.name = config.cowNames[data[i + 6]];
  7844. tmpObj.forcePos = true;
  7845. tmpObj.sid = data[i];
  7846. tmpObj.visible = true;
  7847. }
  7848. i += 7;
  7849. }
  7850. }
  7851. }
  7852. // ANIMATE AI:
  7853. function animateAI(sid) {
  7854. tmpObj = findAIBySID(sid);
  7855. if (tmpObj) tmpObj.startAnim();
  7856. }
  7857. function gatherAnimation(sid, didHit, index) {
  7858. tmpObj = findPlayerBySID(sid);
  7859. if (tmpObj) {
  7860. tmpObj.startAnim(didHit, index);
  7861. tmpObj.gatherIndex = index;
  7862. tmpObj.gathering = 1;
  7863.  
  7864. // code by Xiaokai [Simple Anti]
  7865. near.dist2>=175&&near.dist2<=275&&!tmpObj.isTeam(player)&&5===tmpObj.weaponIndex&&tmpObj.primaryVariant>=1&&void 0!==!tmpObj.secondaryIndex&&53===tmpObj.skinIndex&&(player.canEmpAnti=!0,buyEquip(6,0),antiSyncHealing(2,setTimeout((()=>111))),player.chat.message="Anti One Frame",player.chat.count=2e3);
  7866.  
  7867. if (didHit) {
  7868. let tmpObjects = objectManager.hitObj;
  7869. //preplacer
  7870. setTickout(() => {
  7871. setTimeout(() => {
  7872. if(getDist(player, enemy) <= 200) {
  7873. place(2, getDir(tmpObjects, player))
  7874. } else {
  7875. place(4, getDir(tmpObjects, player))
  7876. }
  7877. }, items.weapons[index].speed - window.pingTime)
  7878. }, 2)
  7879.  
  7880. objectManager.hitObj = [];
  7881.  
  7882. game.tickBase(() => {
  7883. tmpObj = findPlayerBySID(sid);
  7884. 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);
  7885. tmpObjects.forEach((healthy) => {
  7886. healthy.healthMov = healthy.health - val / 2;
  7887. healthy.health -= val;
  7888. //love to https://gist.github.com/bendc/76c48ce53299e6078a76
  7889. let h, s, l;
  7890. let color = (() => {
  7891. const randomInt = (min, max) => {
  7892. return Math.floor(Math.random() * (max - min + 1)) + min;
  7893. };
  7894. h = randomInt(0, 360);
  7895. s = randomInt(42, 98);
  7896. l = randomInt(40, 90);
  7897. // return `hsl(${h},${s}%,${l}%)`;
  7898. })();
  7899. //and love https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
  7900. function hslToHex(h, s, l) {
  7901. l /= 100;
  7902. const a = s * Math.min(l, 1 - l) / 100;
  7903. const f = n => {
  7904. const k = (n + h / 30) % 12;
  7905. const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
  7906. return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
  7907. };
  7908. return `#${f(0)}${f(8)}${f(4)}`;
  7909. }
  7910. console.log(hslToHex(h, s, l));
  7911. (healthy.x, healthy.y, val, hslToHex(h, s, l));
  7912. });
  7913. }, 1);
  7914. }
  7915. }
  7916. }
  7917. function showDamageText(x, y, value, color) {
  7918. textManager.showText(x, y, 30, 0.15, 550, Math.round(value), color);
  7919. }
  7920.  
  7921. // WIGGLE GAME OBJECT:
  7922. function wiggleGameObject(dir, sid) {
  7923. tmpObj = findObjectBySid(sid);
  7924. if (tmpObj) {
  7925. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7926. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7927. if (tmpObj.health) {
  7928. //tmpObj.damaged = Math.min(255, tmpObj.damaged + 60);
  7929. objectManager.hitObj.push(tmpObj);
  7930. }
  7931. }
  7932. }
  7933. // SHOOT TURRET:
  7934. function shootTurret(sid, dir) {
  7935. tmpObj = findObjectBySid(sid);
  7936. if (tmpObj) {
  7937. tmpObj.dir = dir;
  7938. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7939. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7940. }
  7941. }
  7942. function randomizePhrases2() {
  7943. const phrases = ['were slain...', 'met their demise...', 'life was extinguished...', 'perished...', 'were overwhelmed...', 'were defeated...', 'were vanquished...', 'bit the dust...', 'met a tragic end...', 'were obliterated...', 'met a gruesome fate...', 'were eradicated...', 'were annihilated...', 'were crushed...', 'were overwhelmed...', 'were turned to ash...', 'were reduced to rubble...', 'were shattered...', 'were disintegrated...', 'were torn apart...', 'were consumed by darkness...', 'were consumed by the void...', 'were consumed by the abyss...', 'were consumed by chaos...', 'were consumed by despair...', 'were consumed by madness...', 'were consumed by the unknown...', 'were consumed by the shadows...'];
  7944. return phrases[Math.floor(Math.random() * phrases.length)];
  7945. }
  7946. // UPDATE PLAYER VALUE:
  7947. function updatePlayerValue(index, value, updateView) {
  7948. if (player) {
  7949. player[index] = value;
  7950.  
  7951. if (index == "points") {
  7952. if (configs.autoBuy) {
  7953. autoBuy.hat();
  7954. autoBuy.acc();
  7955. }
  7956. } else if (index == "kills") {
  7957. if (configs.killChat) {
  7958. packet("6", "Wake up to reality.")
  7959. setTimeout(() => {
  7960. packet("6", "Nothing goes as ever planned.")
  7961. setTimeout(() => {
  7962. packet("6", "I ve sent you to the void.")
  7963. setTimeout(() => {
  7964. packet("6", "Kids in the void: " + player.kills)
  7965. }, 1500);
  7966. }, 1500);
  7967. }, 1500);
  7968. }
  7969. }
  7970. }
  7971. }
  7972. // Function to get a varying kill chat message
  7973. // Function to get a varying kill chat message
  7974. function getKillChatMessage(kills) {
  7975. // Calculate the base kill count
  7976. let baseKillCount = Math.floor(kills / 10) * 10;
  7977.  
  7978. if (kills <= 1) {
  7979. return "";
  7980. } else if (kills <= 2) {
  7981. return "";
  7982. } else if (kills <= 3) {
  7983. return "";
  7984. } else if (kills <= 4) {
  7985. return "";
  7986. } else if (kills <= 5) {
  7987. return "";
  7988. } else if (kills <= 6) {
  7989. return "";
  7990. } else if (kills <= 7) {
  7991. return "";
  7992. } else if (kills <= 8) {
  7993. return "";
  7994. } else if (kills <= 9) {
  7995. return "";
  7996. } else if (kills <= 10) {
  7997. return "";
  7998. } else if (kills <= 11) {
  7999. return "";
  8000. } else if (kills <= 12) {
  8001. return "";
  8002. } else if (kills <= 13) {
  8003. return "";
  8004. } else if (kills <= 14) {
  8005. return "";
  8006. } else if (kills <= 15) {
  8007. return "";
  8008. } else if (kills <= 16) {
  8009. return "";
  8010. } else if (kills <= 17) {
  8011. return "";
  8012. } else if (kills <= 18) {
  8013. return "";
  8014. } else if (kills <= 19) {
  8015. return "";
  8016. } else if (kills <= 20) {
  8017. return "";
  8018. } else if (kills <= 21) {
  8019. return "";
  8020. } else if (kills <= 22) {
  8021. return "";
  8022. } else if (kills <= 23) {
  8023. return "";
  8024. } else if (kills <= 24) {
  8025. return "";
  8026. } else if (kills <= 25) {
  8027. return "";
  8028. } else if (kills <= 26) {
  8029. return "";
  8030. } else if (kills <= 27) {
  8031. return "";
  8032. } else if (kills <= 28) {
  8033. return "";
  8034. } else if (kills <= 29) {
  8035. return "";
  8036. } else if (kills <= 30) {
  8037. return "";
  8038. } else {
  8039.  
  8040. // Display additional information when the kill count crosses a multiple of 10
  8041. let additionalInfo = "x" + (Math.floor(kills / 10) - 1);
  8042. return
  8043. }
  8044. }
  8045. // ACTION BAR:
  8046. function updateItems(data, wpn) {
  8047. if (data) {
  8048. if (wpn) {
  8049. player.weapons = data;
  8050. player.primaryIndex = player.weapons[0];
  8051. player.secondaryIndex = player.weapons[1];
  8052. if (!instaC.isTrue) {
  8053. selectWeapon(player.weapons[0]);
  8054. }
  8055. } else {
  8056. player.items = data;
  8057. }
  8058. }
  8059. for (let i = 0; i < items.list.length; i++) {
  8060. let tmpI = items.weapons.length + i;
  8061. getEl("actionBarItem" + tmpI).style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8062. }
  8063. for (let i = 0; i < items.weapons.length; i++) {
  8064. getEl("actionBarItem" + i).style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8065. }
  8066. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8067. if (kms) {
  8068. getEl("actionBarItem3").style.display = "none";
  8069. getEl("actionBarItem4").style.display = "inline-block";
  8070. }
  8071. }
  8072. // ADD PROJECTILE:
  8073. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8074. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8075. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8076. }
  8077. // REMOVE PROJECTILE:
  8078. function remProjectile(sid, range) {
  8079. for (let i = 0; i < projectiles.length; ++i) {
  8080. if (projectiles[i].sid == sid) {
  8081. projectiles[i].range = range;
  8082. let tmpObjects = objectManager.hitObj;
  8083. objectManager.hitObj = [];
  8084. game.tickBase(() => {
  8085. let val = projectiles[i].dmg;
  8086. tmpObjects.forEach((healthy) => {
  8087. if (healthy.projDmg) {
  8088. healthy.health -= val;
  8089. }
  8090. });
  8091. }, 1);
  8092. }
  8093. }
  8094. }
  8095. // SHOW ALLIANCE MENU:
  8096. function allianceNotification(sid, name) {
  8097. let findBotSID = findSID(bots, sid);
  8098. if (findBotSID) { }
  8099. }
  8100. function setPlayerTeam(team, isOwner) {
  8101. if (player) {
  8102. player.team = team;
  8103. player.isOwner = isOwner;
  8104. if (team == null)
  8105. alliancePlayers = [];
  8106. }
  8107. }
  8108. function setAlliancePlayers(data) {
  8109. alliancePlayers = data;
  8110. }
  8111. // STORE MENU:
  8112. function updateStoreItems(type, id, index) {
  8113. if (index) {
  8114. if (!type)
  8115. player.tails[id] = 1;
  8116. else {
  8117. player.latestTail = id;
  8118. }
  8119. } else {
  8120. if (!type)
  8121. player.skins[id] = 1,
  8122. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8123. else {
  8124. player.latestSkin = id;
  8125. }
  8126. }
  8127. }
  8128. // SEND MESSAGE:
  8129. function receiveChat(sid, message) {
  8130. let tmpPlayer = findPlayerBySID(sid);
  8131. if (tmpPlayer) {
  8132. function get() {
  8133. if(tmpPlayer != player && player.team != tmpPlayer.team) {
  8134. return "#c95563";
  8135. } else if (player.team && player.team == tmpPlayer.team) {
  8136. return "#fff";
  8137. } else {
  8138. return "#0949aa"; //2394e8
  8139. }
  8140. }
  8141. let me = false;
  8142. if(tmpPlayer == player) me = true
  8143. else me = false;
  8144. addChatLog(message, "#fff", tmpPlayer.name + "[" + tmpPlayer.sid + "]:", tmpPlayer == player || (tmpPlayer.team && tmpPlayer.team == player.team) ? "#279df1" : "#fff");
  8145. tmpPlayer.chatMessage = ((text) => {
  8146. let tmpString;
  8147. profanityList.forEach((list) => {
  8148. if (text.indexOf(list) > -1) {
  8149. tmpString = "";
  8150. for (var y = 0; y < list.length; ++y) {
  8151. tmpString += tmpString.length ? "o" : "M";
  8152. }
  8153. var re = new RegExp(list, 'g');
  8154. text = text.replace(re, tmpString);
  8155. }
  8156. });
  8157. return text;
  8158. })(message);
  8159. tmpPlayer.chatCountdown = config.chatCountdown;
  8160. }
  8161. }
  8162. // MINIMAP:
  8163. function updateMinimap(data) {
  8164. minimapData = data;
  8165. }
  8166. // SHOW ANIM TEXT:
  8167. function showText(x, y, value, type, color) {
  8168. textManager.showText(x, y, 50, 0.18, 500, Math.abs(value), color);
  8169. }
  8170. /** APPLY SOCKET CODES */// BOT:
  8171. let bots = [];
  8172. let ranLocation = {
  8173. x: UTILS.randInt(35, 14365),
  8174. y: UTILS.randInt(35, 14365)
  8175. };
  8176. setInterval(() => {
  8177. ranLocation = {
  8178. x: UTILS.randInt(35, 14365),
  8179. y: UTILS.randInt(35, 14365)
  8180. };
  8181. }, 60000);
  8182. class Bot {
  8183. constructor(id, sid, hats, accessories) {
  8184. this.millPlace = true;
  8185. this.id = id;
  8186. this.sid = sid;
  8187. this.team = null;
  8188. this.skinIndex = 0;
  8189. this.tailIndex = 0;
  8190. this.hitTime = 0;
  8191. this.iconIndex = 0;
  8192. this.enemy = [];
  8193. this.near = [];
  8194. this.dist2 = 0;
  8195. this.aim2 = 0;
  8196. this.tick = 0;
  8197. this.itemCounts = {};
  8198. this.latestSkin = 0;
  8199. this.latestTail = 0;
  8200. this.points = 0;
  8201. this.tails = {};
  8202. for (let i = 0; i < accessories.length; ++i) {
  8203. if (accessories[i].price <= 0)
  8204. this.tails[accessories[i].id] = 1;
  8205. }
  8206. this.skins = {};
  8207. for (let i = 0; i < hats.length; ++i) {
  8208. if (hats[i].price <= 0)
  8209. this.skins[hats[i].id] = 1;
  8210. }
  8211. this.spawn = function(moofoll) {
  8212. this.upgraded = 0;
  8213. this.enemy = [];
  8214. this.near = [];
  8215. this.active = true;
  8216. this.alive = true;
  8217. this.lockMove = false;
  8218. this.lockDir = false;
  8219. this.minimapCounter = 0;
  8220. this.chatCountdown = 0;
  8221. this.shameCount = 0;
  8222. this.shameTimer = 0;
  8223. this.sentTo = {};
  8224. this.gathering = 0;
  8225. this.autoGather = 0;
  8226. this.animTime = 0;
  8227. this.animSpeed = 0;
  8228. this.mouseState = 0;
  8229. this.buildIndex = -1;
  8230. this.weaponIndex = 0;
  8231. this.dmgOverTime = {};
  8232. this.noMovTimer = 0;
  8233. this.maxXP = 300;
  8234. this.XP = 0;
  8235. this.age = 1;
  8236. this.kills = 0;
  8237. this.upgrAge = 2;
  8238. this.upgradePoints = 0;
  8239. this.x = 0;
  8240. this.y = 0;
  8241. this.zIndex = 0;
  8242. this.xVel = 0;
  8243. this.yVel = 0;
  8244. this.slowMult = 1;
  8245. this.dir = 0;
  8246. this.nDir = 0;
  8247. this.dirPlus = 0;
  8248. this.targetDir = 0;
  8249. this.targetAngle = 0;
  8250. this.maxHealth = 100;
  8251. this.health = this.maxHealth;
  8252. this.oldHealth = this.maxHealth;
  8253. this.scale = config.playerScale;
  8254. this.speed = config.playerSpeed;
  8255. this.resetMoveDir();
  8256. this.resetResources(moofoll);
  8257. this.items = [0, 3, 6, 10];
  8258. this.weapons = [0];
  8259. this.shootCount = 0;
  8260. this.weaponXP = [];
  8261. this.isBot = false;
  8262. this.reloads = {
  8263. 0: 0,
  8264. 1: 0,
  8265. 2: 0,
  8266. 3: 0,
  8267. 4: 0,
  8268. 5: 0,
  8269. 6: 0,
  8270. 7: 0,
  8271. 8: 0,
  8272. 9: 0,
  8273. 10: 0,
  8274. 11: 0,
  8275. 12: 0,
  8276. 13: 0,
  8277. 14: 0,
  8278. 15: 0,
  8279. 53: 0,
  8280. };
  8281. this.timeZinceZpawn = 0;
  8282. this.whyDie = "";
  8283. this.clearRadius = false;
  8284. this.circlee = 0;
  8285. };
  8286. // RESET MOVE DIR:
  8287. this.resetMoveDir = function() {
  8288. this.moveDir = undefined;
  8289. };
  8290. // RESET RESOURCES:
  8291. this.resetResources = function(moofoll) {
  8292. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8293. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8294. }
  8295. };
  8296. // SET DATA:
  8297. this.setData = function(data) {
  8298. this.id = data[0];
  8299. this.sid = data[1];
  8300. this.name = data[2];
  8301. this.x = data[3];
  8302. this.y = data[4];
  8303. this.dir = data[5];
  8304. this.health = data[6];
  8305. this.maxHealth = data[7];
  8306. this.scale = data[8];
  8307. this.skinColor = data[9];
  8308. };
  8309. // SHAME SYSTEM:
  8310. this.judgeShame = function() {
  8311. if (this.oldHealth < this.health) {
  8312. if (this.hitTime) {
  8313. let timeSinceHit = this.tick - this.hitTime;
  8314. this.hitTime = 0;
  8315. if (timeSinceHit < 2) {
  8316. this.lastshamecount = this.shameCount;
  8317. this.shameCount++;
  8318. } else {
  8319. this.lastshamecount = this.shameCount;
  8320. this.shameCount = Math.max(0, this.shameCount - 2);
  8321. }
  8322. }
  8323. } else if (this.oldHealth > this.health) {
  8324. this.hitTime = this.tick;
  8325. }
  8326. };
  8327. // UPDATE WEAPON RELOAD:
  8328. this.manageReloadaa = function() {
  8329. if (this.shooting[53]) {
  8330. this.shooting[53] = 0;
  8331. this.reloads[53] = (2500 - 1000/9);
  8332. } else {
  8333. if (this.reloads[53] > 0) {
  8334. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8335. }
  8336. }
  8337. if (this.gathering || this.shooting[1]) {
  8338. if (this.gathering) {
  8339. this.gathering = 0;
  8340. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8341. this.attacked = true;
  8342. }
  8343. if (this.shooting[1]) {
  8344. this.shooting[1] = 0;
  8345. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8346. this.attacked = true;
  8347. }
  8348. } else {
  8349. this.attacked = false;
  8350. if (this.buildIndex < 0) {
  8351. if (this.reloads[this.weaponIndex] > 0) {
  8352. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8353. }
  8354. }
  8355. }
  8356. };
  8357. this.closeSockets = function(websc) {
  8358. websc.close();
  8359. };
  8360. this.whyDieChat = function(websc, whydie) {
  8361. websc.sendWS("6", "Noob " + whydie);
  8362. };
  8363. }
  8364. };
  8365. class BotObject {
  8366. constructor(sid) {
  8367. this.sid = sid;
  8368. // INIT:
  8369. this.init = function(x, y, dir, scale, type, data, owner) {
  8370. data = data || {};
  8371. this.active = true;
  8372. this.x = x;
  8373. this.y = y;
  8374. this.scale = scale;
  8375. this.owner = owner;
  8376. this.id = data.id;
  8377. this.dmg = data.dmg;
  8378. this.trap = data.trap;
  8379. this.teleport = data.teleport;
  8380. this.isItem = this.id != undefined;
  8381. };
  8382. }
  8383. };
  8384. class BotObjManager {
  8385. constructor(botObj, fOS) {
  8386. // DISABLE OBJ:
  8387. this.disableObj = function(obj) {
  8388. obj.active = false;
  8389. if (config.anotherVisual) {} else {
  8390. obj.alive = false;
  8391. }
  8392. };
  8393. // ADD NEW:
  8394. let tmpObj;
  8395. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8396. tmpObj = fOS(sid);
  8397. if (!tmpObj) {
  8398. tmpObj = botObj.find((tmp) => !tmp.active);
  8399. if (!tmpObj) {
  8400. tmpObj = new BotObject(sid);
  8401. botObj.push(tmpObj);
  8402. }
  8403. }
  8404. if (setSID) {
  8405. tmpObj.sid = sid;
  8406. }
  8407. tmpObj.init(x, y, dir, s, type, data, owner);
  8408. };
  8409. // DISABLE BY SID:
  8410. this.disableBySid = function(sid) {
  8411. let find = fOS(sid);
  8412. if (find) {
  8413. this.disableObj(find);
  8414. }
  8415. };
  8416. // REMOVE ALL FROM PLAYER:
  8417. this.removeAllItems = function(sid, server) {
  8418. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8419. };
  8420. }
  8421. };
  8422. let botz = [];
  8423. function botSpawn(id) {
  8424. let bot;
  8425. console.log(WS);
  8426. let t = WS.url.split("wss://")[1].split("?")[0];
  8427. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8428. let botPlayer = new Map();
  8429. botSkts.push([botPlayer]);
  8430. botz.push([bot]);
  8431. let botSID;
  8432. let botObj = [];
  8433. let nearObj = [];
  8434. let bD = {
  8435. x: 0,
  8436. y: 0,
  8437. inGame: false,
  8438. closeSocket: false,
  8439. whyDie: ""
  8440. };
  8441. let oldXY = {
  8442. x: 0,
  8443. y: 0,
  8444. };
  8445. let izauto = 0;
  8446. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8447. bot.binaryType = "arraybuffer";
  8448. bot.first = true;
  8449. bot.sendWS = function(type) {
  8450. // EXTRACT DATA ARRAY:
  8451. let data = Array.prototype.slice.call(arguments, 1);
  8452. // SEND MESSAGE:
  8453. let binary = window.msgpack.encode([type, data]);
  8454. bot.send(binary);
  8455. };
  8456. bot.spawn = function() {
  8457. bot.sendWS("M", {
  8458. name: "get bagged",
  8459. moofoll: 1,
  8460. skin: "__proto__"
  8461. });
  8462. };
  8463. bot.sendUpgrade = function(index) {
  8464. bot.sendWS("H", index);
  8465. };
  8466. bot.place = function(id, a) {
  8467. try {
  8468. let item = items.list[botPlayer.items[id]];
  8469. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  8470. bot.sendWS("G", botPlayer.items[id]);
  8471. bot.sendWS("d", 1, a);
  8472. bot.sendWS("G", botPlayer.weaponIndex, true);
  8473. }
  8474. } catch (e) {
  8475. }
  8476. };
  8477. bot.buye = function(id, index) {
  8478. let nID = 0;
  8479. if (botPlayer.alive && botPlayer.inGame) {
  8480. if (index == 0) {
  8481. if (botPlayer.skins[id]) {
  8482. if (/*botPlayer.skinIndex != id*/true) {
  8483. bot.sendWS("c", 0, id, 0);
  8484. }
  8485. } else {
  8486. let find = findID(hats, id);
  8487. if (find) {
  8488. if (botPlayer.points >= find.price) {
  8489. bot.sendWS("c", 1, id, 0);
  8490. bot.sendWS("c", 0, id, 0);
  8491. } else {
  8492. if (/*botPlayer.latestSkin != nID*/true) {
  8493. bot.sendWS("c", 0, nID, 0);
  8494. }
  8495. }
  8496. } else {
  8497. if (/*botPlayer.latestSkin != nID*/true) {
  8498. bot.sendWS("c", 0, nID, 0);
  8499. }
  8500. }
  8501. }
  8502. } else if (index == 1) {
  8503. if (botPlayer.tails[id]) {
  8504. if (botPlayer.latestTail != id) {
  8505. bot.sendWS("c", 0, id, 1);
  8506. }
  8507. } else {
  8508. let find = findID(accessories, id);
  8509. if (find) {
  8510. if (botPlayer.points >= find.price) {
  8511. bot.sendWS("c", 1, id, 1);
  8512. bot.sendWS("c", 0, id, 1);
  8513. } else {
  8514. if (botPlayer.latestTail != 0) {
  8515. bot.sendWS("c", 0, 0, 1);
  8516. }
  8517. }
  8518. } else {
  8519. if (botPlayer.latestTail != 0) {
  8520. bot.sendWS("c", 0, 0, 1);
  8521. }
  8522. }
  8523. }
  8524. }
  8525. }
  8526. };
  8527. bot.fastGear = function() {
  8528. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8529. bot.buye(31, 0);
  8530. } else {
  8531. if (botPlayer.y2 <= config.snowBiomeTop) {
  8532. bot.buye(15, 0);
  8533. } else {
  8534. bot.buye(12, 0);
  8535. }
  8536. }
  8537. };
  8538. bot.selectWeapon = function(a) {
  8539. packet("G", a, 1);
  8540. }
  8541. function caf(e, t) {
  8542. try {
  8543. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8544. } catch (e) {
  8545. return 0;
  8546. }
  8547. }
  8548. bot.heal = function() {
  8549. if (botPlayer.health < 100) {
  8550. bot.place(0, 0)
  8551. }
  8552. }
  8553. function cdf (e, t){
  8554. try {
  8555. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8556. } catch(e){
  8557. return Infinity;
  8558. }
  8559. }
  8560. let zoon = 'no';
  8561. bot.zync = function(a) {
  8562. if (!botPlayer.millPlace) {
  8563. zoon = 'yeah';
  8564. bot.place(5, caf(botPlayer, a));
  8565. let NextTickLocation = {
  8566. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8567. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8568. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8569. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8570. };
  8571. function calculateDistance(x1, y1, x2, y2) {
  8572. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8573. return distance;
  8574. }
  8575. function dotherezt() {
  8576. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8577. }
  8578. let turretSpeed = UTILS.getDistance(near.x, near.y, botPlayer.x2, botPlayer.y2) / 1.5, musketSpeed = (UTILS.getDistance(near.x, near.y, botPlayer.x2, botPlayer.y2) - 35) / 3.6;
  8579. bot.buye(53, 0);
  8580. let aa = setInterval(()=>{
  8581. dotherezt();
  8582. },100)
  8583. setTimeout(()=>{
  8584. bot.sendWS("G", botPlayer.weapons[1], true);
  8585. if (izauto == 0) {
  8586. bot.sendWS("K", 1);
  8587. izauto = 1;
  8588. }
  8589. setTimeout(() => {
  8590. bot.sendWS("G", botPlayer.weapons[0], true);
  8591. clearInterval(aa)
  8592. }, 1000);
  8593. setTimeout(() => {
  8594. zoon = 'no';
  8595. }, 500);
  8596. },turretSpeed-(musketSpeed*2))
  8597. bot.buye(53, 0);
  8598. }
  8599. };
  8600. bot.onmessage = function(message) {
  8601. let data = new Uint8Array(message.data);
  8602. let parsed = window.msgpack.decode(data);
  8603. let type = parsed[0];
  8604. data = parsed[1];
  8605. if (type == "io-init") {
  8606. bot.spawn();
  8607. }
  8608. if (type == "1") {
  8609. botSID = data[0];
  8610. console.log(botSID)
  8611. setInterval(()=>{
  8612. bot.fastGear();
  8613. },60000)
  8614. }
  8615. if (type == "D") {
  8616. if (data[1]) {
  8617. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8618. botPlayer.setData(data[0]);
  8619. botPlayer.inGame = true;
  8620. botPlayer.alive = true;
  8621. botPlayer.x2 = undefined;
  8622. botPlayer.y2 = undefined;
  8623. botPlayer.spawn(1);
  8624. botPlayer.oldHealth = 100;
  8625. botPlayer.health = 100;
  8626. botPlayer.showName = 'NOOO';
  8627. oldXY = {
  8628. x: data[0][3],
  8629. y: data[0][4]
  8630. }
  8631. bD.inGame = true;
  8632. if (bot.first) {
  8633. bot.first = false;
  8634. bots.push(bD);
  8635. }
  8636. }
  8637. }
  8638. if (type == "P") {
  8639. bot.spawn();
  8640. botPlayer.inGame = false;
  8641. bD.inGame = false;
  8642. }
  8643. if (type == "a") {
  8644. let tmpData = data[0];
  8645. botPlayer.tick++;
  8646. botPlayer.enemy = [];
  8647. botPlayer.near = [];
  8648. bot.showName = 'NOOO';
  8649. nearObj = [];
  8650. for (let i = 0; i < tmpData.length;) {
  8651. if (tmpData[i] == botPlayer.sid) {
  8652. botPlayer.x2 = tmpData[i + 1];
  8653. botPlayer.y2 = tmpData[i + 2];
  8654. botPlayer.d2 = tmpData[i + 3];
  8655. botPlayer.buildIndex = tmpData[i + 4];
  8656. botPlayer.weaponIndex = tmpData[i + 5];
  8657. botPlayer.weaponVariant = tmpData[i + 6];
  8658. botPlayer.team = tmpData[i + 7];
  8659. botPlayer.isLeader = tmpData[i + 8];
  8660. botPlayer.skinIndex = tmpData[i + 9];
  8661. botPlayer.tailIndex = tmpData[i + 10];
  8662. botPlayer.iconIndex = tmpData[i + 11];
  8663. botPlayer.zIndex = tmpData[i + 12];
  8664. botPlayer.visible = true;
  8665. bD.x2 = botPlayer.x2;
  8666. bD.y2 = botPlayer.y2;
  8667. }
  8668. i += 13;
  8669. }
  8670. for (let i = 0; i < tmpData.length;) {
  8671. tmpObj = findPlayerBySID(tmpData[i]);
  8672. if (tmpObj) {
  8673. if (!tmpObj.isTeam(botPlayer)) {
  8674. enemy.push(tmpObj);
  8675. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8676. nears.push(tmpObj);
  8677. }
  8678. }
  8679. }
  8680. i += 13;
  8681. }
  8682. if (enemy.length) {
  8683. //console.log(enemy)
  8684. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8685. return tmp1.dist2 - tmp2.dist2;
  8686. })[0];
  8687. }
  8688. if (izauto == 1) {
  8689. bot.sendWS("K", 1);
  8690. izauto = 0;
  8691. }
  8692. if (bD.closeSocket) {
  8693. botPlayer.closeSockets(bot);
  8694. }
  8695. if (bD.whyDie != "") {
  8696. botPlayer.whyDieChat(bot, bD.whyDie);
  8697. bD.whyDie = "";
  8698. }
  8699. if (botPlayer.alive) {
  8700. if (player.team) {
  8701. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8702. botPlayer.team && (bot.sendWS("N"));
  8703. bot.sendWS("b", player.team);
  8704. setTimeout(()=>{bottzzz.push(botPlayer.sid)},2000)
  8705. }
  8706. }
  8707. let item = items.list[botPlayer.items[3]];
  8708. let a = botPlayer.itemCounts[item.group.id]
  8709. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8710. if (botPlayer.inGame) {
  8711. bot.sendWS("D", botPlayer.moveDir);
  8712. if (izauto == 0) {
  8713. bot.sendWS("K", 1);
  8714. izauto = 1;
  8715. }
  8716. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 200) {
  8717. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8718. bot.place(3, aim + 7.7);
  8719. bot.place(3, aim - 7.7);
  8720. bot.place(3, aim);
  8721. oldXY = {
  8722. x: botPlayer.x2,
  8723. y: botPlayer.y2
  8724. };
  8725. }
  8726. if (botPlayer.tick % 90 === 0) {
  8727. let rand = Math.random() * Math.PI * 2;
  8728. botPlayer.moveDir = rand;
  8729. bot.sendWS("a", botPlayer.moveDir);
  8730. }
  8731. }
  8732. bot.fastGear();
  8733. } else if((a != undefined ? a : 0) > 198 && botPlayer.millPlace) {
  8734. botPlayer.millPlace = false;
  8735. if (izauto == 0) {
  8736. bot.sendWS("K", 1);
  8737. izauto = 1;
  8738. }
  8739. bot.buye(11, 1);
  8740. bot.fastGear();
  8741. } else {
  8742. if (botPlayer.inGame) {
  8743. if (botObj.length > 0) {
  8744. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8745. if (getEl("mode").value == 'fuckemup') {
  8746. // if (getEl("mode").value == "clear") {
  8747. bot.selectWeapon(botPlayer.weapons[1]);
  8748. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8749. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8750. 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/2)).sort(function(a, b) {
  8751. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8752. })[0];
  8753. if (nearObj) {
  8754. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8755. if ((gotoDist - isPassed) > 0) {
  8756. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8757. if (botPlayer.moveDir != undefined) {
  8758. botPlayer.moveDir = undefined;
  8759. bot.sendWS("a", botPlayer.moveDir);
  8760. bot.sendWS("D", botPlayer.nDir);
  8761. }
  8762. } else {
  8763. botPlayer.moveDir = gotoAim;
  8764. bot.sendWS("a", botPlayer.moveDir);
  8765. bot.sendWS("D", botPlayer.nDir);
  8766. }
  8767. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8768. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8769. bot.sendWS("D", botPlayer.nDir);
  8770. }
  8771. if (izauto == 0) {
  8772. bot.sendWS("K", 1);
  8773. izauto = 1;
  8774. }
  8775. bot.buye(40, 0);
  8776. } else {
  8777. botPlayer.moveDir = gotoAim;
  8778. bot.sendWS("a", botPlayer.moveDir);
  8779. bot.sendWS("D", botPlayer.nDir);
  8780. bot.fastGear();
  8781. }
  8782. } else {
  8783. botPlayer.moveDir = gotoAim;
  8784. bot.sendWS("a", botPlayer.moveDir);
  8785. bot.sendWS("D", botPlayer.nDir);
  8786. bot.fastGear();
  8787. }
  8788. }
  8789. }
  8790. if (botObj.length > 0) {
  8791. if (getEl("mode").value == 'flex') {
  8792. const circleRadius = 300;
  8793. const circleCenterX = player.x2;
  8794. const circleCenterY = player.y2;
  8795. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  8796. angle -= 0.1;
  8797. const x = circleCenterX + circleRadius * Math.cos(angle);
  8798. const y = circleCenterY + circleRadius * Math.sin(angle);
  8799. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8800. }
  8801.  
  8802. }
  8803.  
  8804. if (botObj.length > 0) {
  8805. if (getEl("mode").value == 'mouse') {
  8806. bot.sendWS("a", Math.atan2((player.y2 - botPlayer.y2) + mouseY - (gameCanvas.height / 1.5), (player.x2- botPlayer.x2) + mouseX - (gameCanvas.width / 1.5)));
  8807. }
  8808.  
  8809. }
  8810.  
  8811. if (botObj.length > 0) {
  8812. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8813. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8814. })[0];
  8815. if (nearObj&&((getEl("mode").value == 'fight'?(nearObj.isTeamObject(player)?false:true):true))) {//herenigga
  8816. if (izauto == 0) {
  8817. bot.sendWS("K", 1);
  8818. izauto = 1;
  8819. }
  8820. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8821. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8822. bot.sendWS("D", botPlayer.nDir);
  8823. }
  8824. bot.buye(40, 0);
  8825. bot.buye(11, 1);
  8826. } else {
  8827. bot.fastGear();
  8828. bot.buye(11, 1);
  8829. }
  8830. bot.buye(11, 1);
  8831. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8832. bot.selectWeapon(botPlayer.weapons[1]);
  8833. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8834. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8835. 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) {
  8836. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8837. })[0];
  8838. if (nearObj) {
  8839. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8840. if ((gotoDist - isPassed) > 0) {
  8841. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8842. // botPlayer.moveDir = undefined;
  8843. bot.sendWS("a", caf);
  8844. bot.sendWS("D", botPlayer.nDir);
  8845. } else {
  8846. // botPlayer.moveDir = gotoAim;
  8847. // bot.sendWS("a", botPlayer.moveDir);
  8848. bot.sendWS("D", botPlayer.nDir);
  8849. }
  8850. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8851. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8852. bot.sendWS("D", botPlayer.nDir);
  8853. }
  8854. if (izauto == 0) {
  8855. bot.sendWS("K", 1);
  8856. izauto = 1;
  8857. }
  8858. bot.buye(40, 0);
  8859. // bot.fastGear();
  8860. bot.buye(11, 1);
  8861. } else {
  8862. botPlayer.moveDir = gotoAim;
  8863. bot.sendWS("a", botPlayer.moveDir);
  8864. bot.sendWS("D", botPlayer.nDir);
  8865. bot.fastGear();
  8866. bot.buye(11, 1);
  8867. }
  8868. } else {
  8869. botPlayer.moveDir = gotoAim;
  8870. bot.sendWS("a", botPlayer.moveDir);
  8871. bot.sendWS("D", botPlayer.nDir);
  8872. bot.fastGear();
  8873. bot.buye(11, 1);
  8874. }
  8875. }
  8876. }
  8877. if (botObj.length > 0 && getEl("mode").value == 'stopp') {
  8878. if (cdf(window.stopSpot, botPlayer) <= 220) {
  8879. bot.sendWS("a", undefined);
  8880. bot.fastGear();
  8881. } else {
  8882. bot.sendWS("a", caf(window.stopSpot, botPlayer) + Math.PI);
  8883. }
  8884. }
  8885. if (botObj.length > 0 && getEl("mode").value == 'fight') {
  8886. if(near.sid) {
  8887. const circleRadius = 100;
  8888. const circleCenterX = near.x;
  8889. const circleCenterY = near.y;
  8890. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  8891. angle -= 0.1;
  8892. const x = circleCenterX + circleRadius * Math.cos(angle);
  8893. const y = circleCenterY + circleRadius * Math.sin(angle);
  8894. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8895. if(UTILS.getDist(near, botPlayer, 0, 2) < 200) {
  8896. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8897. }
  8898. if(UTILS.getDist(near, botPlayer, 0, 2) < 400) {
  8899. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8900. }
  8901. } else{
  8902. const circleRadius = 100;
  8903. const circleCenterX = player.x2;
  8904. const circleCenterY = player.y2;
  8905. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  8906. angle -= 0.1;
  8907. const x = circleCenterX + circleRadius * Math.cos(angle);
  8908. const y = circleCenterY + circleRadius * Math.sin(angle);
  8909. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8910. }
  8911. }
  8912. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8913. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2));
  8914. if (!wdaawdwad.length) {
  8915. if (zoon == 'no') {
  8916. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8917. }
  8918. if (cdf(player, botPlayer) <= 220) {
  8919. bot.sendWS("a", undefined);
  8920. bot.fastGear();
  8921. } else {
  8922. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8923. }
  8924. } else {
  8925. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8926. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8927. let nearObjs = 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/2)).sort(function(a, b) {
  8928. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8929. });
  8930. if (nearObjs.length > 0) {
  8931. let nearObj = nearObjs[0];
  8932. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8933. if ((gotoDist - isPassed) > 0) {
  8934. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8935. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8936. // if (botPlayer.moveDir != undefined) {
  8937. // botPlayer.moveDir = undefined;
  8938. // bot.sendWS("a", botPlayer.moveDir);
  8939. bot.sendWS("D", botPlayer.nDir);
  8940. // }
  8941. } else {
  8942. bot.sendWS("D", botPlayer.nDir);
  8943. }
  8944. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8945. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8946. bot.sendWS("D", botPlayer.nDir);
  8947. }
  8948. bot.buye(40, 0);
  8949. // bot.fastGear();
  8950. bot.buye(11, 1);
  8951. if (izauto == 0) {
  8952. bot.sendWS("K", 1);
  8953. izauto = 1;
  8954. }
  8955. } else {
  8956. if (zoon == 'no') {
  8957. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8958. }
  8959. if (cdf(player, botPlayer) <= 220) {
  8960. bot.sendWS("a", undefined);
  8961. } else {
  8962. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8963. }
  8964. }
  8965. } else {
  8966. if (wdaawdwad.length) {
  8967. if (zoon == 'no') {
  8968. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  8969. // if (izauto == 0) {
  8970. // bot.sendWS("K", 1);
  8971. // izauto = 1;
  8972. // }
  8973. }
  8974. if (cdf(player, botPlayer) <= 220) {
  8975. bot.sendWS("a", undefined);
  8976. } else {
  8977. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8978. }
  8979. } else {
  8980. if (zoon == 'no') {
  8981. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8982. }
  8983. if (cdf(player, botPlayer) <= 220) {
  8984. bot.sendWS("a", undefined);
  8985. } else {
  8986. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  8987. }
  8988. }
  8989. }
  8990. }
  8991. }
  8992. }
  8993. }
  8994. }
  8995. }
  8996. if (type == "H") {
  8997. let tmpData = data[0];
  8998. for (let i = 0; i < tmpData.length;) {
  8999. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9000. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9001. sid: tmpData[i + 7]
  9002. } : null));
  9003. i += 8;
  9004. }
  9005. }
  9006. if (type == "N") {
  9007. let index = data[0];
  9008. let value = data[1];
  9009. if (botPlayer) {
  9010. botPlayer[index] = value;
  9011. }
  9012. }
  9013. if (type == "O") {
  9014. if (data[0] == botPlayer.sid) {
  9015. botPlayer.oldHealth = botPlayer.health;
  9016. botPlayer.health = data[1];
  9017. botPlayer.judgeShame();
  9018. if (botPlayer.oldHealth > botPlayer.health) {
  9019. if (botPlayer.shameCount < 5) {
  9020. for (let i = 0; i < 2; i++) {
  9021. bot.place(0, botPlayer.nDir);
  9022. }
  9023. } else {
  9024. setTimeout(() => {
  9025. for (let i = 0; i < 2; i++) {
  9026. bot.place(0, botPlayer.nDir);
  9027. }
  9028. }, 95);
  9029. }
  9030. }
  9031. }
  9032. }
  9033. if (type == "Q") {
  9034. let sid = data[0];
  9035. botObjManager.disableBySid(sid);
  9036. }
  9037. if (type == "R") {
  9038. let sid = data[0];
  9039. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9040. }
  9041. if (type == "S") {
  9042. let index = data[0];
  9043. let value = data[1];
  9044. if (botPlayer) {
  9045. botPlayer.itemCounts[index] = value;
  9046. }
  9047. }
  9048. if (type == "U") {
  9049. if (data[0] > 0) {
  9050. if(getEl("setup").value == 'dm') {
  9051. if (botPlayer.upgraded == 0) {
  9052. bot.sendUpgrade(7);
  9053. } else if (botPlayer.upgraded == 1) {
  9054. bot.sendUpgrade(17);
  9055. } else if (botPlayer.upgraded == 2) {
  9056. bot.sendUpgrade(31);
  9057. } else if (botPlayer.upgraded == 3) {
  9058. bot.sendUpgrade(23);
  9059. } else if (botPlayer.upgraded == 4) {
  9060. bot.sendUpgrade(9);
  9061. } else if (botPlayer.upgraded == 5) {
  9062. bot.sendUpgrade(34);
  9063. } else if (botPlayer.upgraded == 6) {
  9064. bot.sendUpgrade(12);
  9065. } else if (botPlayer.upgraded == 7) {
  9066. bot.sendUpgrade(15);
  9067. }
  9068. } else if(getEl("setup").value == 'dr') {
  9069. if (botPlayer.upgraded == 0) {
  9070. bot.sendUpgrade(7);
  9071. } else if (botPlayer.upgraded == 1) {
  9072. bot.sendUpgrade(17);
  9073. } else if (botPlayer.upgraded == 2) {
  9074. bot.sendUpgrade(31);
  9075. } else if (botPlayer.upgraded == 3) {
  9076. bot.sendUpgrade(23);
  9077. } else if (botPlayer.upgraded == 4) {
  9078. bot.sendUpgrade(9);
  9079. } else if (botPlayer.upgraded == 5) {
  9080. bot.sendUpgrade(34);
  9081. } else if (botPlayer.upgraded == 6) {
  9082. bot.sendUpgrade(12);
  9083. } else if (botPlayer.upgraded == 7) {
  9084. bot.sendUpgrade(13);
  9085. }
  9086. } else if(getEl("setup").value == 'kh') {
  9087. if (botPlayer.upgraded == 0) {
  9088. bot.sendUpgrade(3);
  9089. } else if (botPlayer.upgraded == 1) {
  9090. bot.sendUpgrade(17);
  9091. } else if (botPlayer.upgraded == 2) {
  9092. bot.sendUpgrade(31);
  9093. } else if (botPlayer.upgraded == 3) {
  9094. bot.sendUpgrade(27);
  9095. } else if (botPlayer.upgraded == 4) {
  9096. bot.sendUpgrade(10);
  9097. } else if (botPlayer.upgraded == 5) {
  9098. bot.sendUpgrade(34);
  9099. } else if (botPlayer.upgraded == 6) {
  9100. bot.sendUpgrade(4);
  9101. } else if (botPlayer.upgraded == 7) {
  9102. bot.sendUpgrade(25);
  9103. }
  9104. } else if(getEl("setup").value == 'zd') {
  9105. if (botPlayer.upgraded == 0) {
  9106. bot.sendUpgrade(3);
  9107. } else if (botPlayer.upgraded == 1) {
  9108. bot.sendUpgrade(17);
  9109. } else if (botPlayer.upgraded == 2) {
  9110. bot.sendUpgrade(31);
  9111. } else if (botPlayer.upgraded == 3) {
  9112. bot.sendUpgrade(27);
  9113. } else if (botPlayer.upgraded == 4) {
  9114. bot.sendUpgrade(9);
  9115. } else if (botPlayer.upgraded == 5) {
  9116. bot.sendUpgrade(34);
  9117. } else if (botPlayer.upgraded == 6) {
  9118. bot.sendUpgrade(12);
  9119. } else if (botPlayer.upgraded == 7) {
  9120. bot.sendUpgrade(15);
  9121. }
  9122. }
  9123. botPlayer.upgraded++;
  9124. }
  9125. }
  9126. if (type == "V") {
  9127. let tmpData = data[0];
  9128. let wpn = data[1];
  9129. if (tmpData) {
  9130. if (wpn) botPlayer.weapons = tmpData;
  9131. else botPlayer.items = tmpData;
  9132. }
  9133. }
  9134. if (type == "5") {
  9135. let type = data[0];
  9136. let id = data[1];
  9137. let index = data[2];
  9138. if (index) {
  9139. if (!type)
  9140. botPlayer.tails[id] = 1;
  9141. else
  9142. botPlayer.latestTail = id;
  9143. } else {
  9144. if (!type)
  9145. botPlayer.skins[id] = 1;
  9146. else
  9147. botPlayer.latestSkin = id;
  9148. }
  9149. }
  9150. if (type == "6") {
  9151. let id = data[0];
  9152. let mzg = data[1]+'';
  9153. if(id == player.sid && mzg.includes("!e")) {
  9154. //bot.zync(botPlayer.near);
  9155. }
  9156. }
  9157. };
  9158. bot.onclose = function() {
  9159. botPlayer.inGame = false;
  9160. bD.inGame = false;
  9161. };
  9162. }
  9163. //botend
  9164. // RENDER LEAF:
  9165. function renderLeaf(x, y, l, r, ctxt) {
  9166. let endX = x + (l * Math.cos(r));
  9167. let endY = y + (l * Math.sin(r));
  9168. let width = l * 0.4;
  9169. ctxt.moveTo(x, y);
  9170. ctxt.beginPath();
  9171. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  9172. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  9173. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  9174. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  9175. ctxt.closePath();
  9176. ctxt.fill();
  9177. ctxt.stroke();
  9178. }
  9179. // RENDER CIRCLE:
  9180. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9181. tmpContext = tmpContext || mainContext;
  9182. tmpContext.beginPath();
  9183. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9184. if (!dontFill) tmpContext.fill();
  9185. if (!dontStroke) tmpContext.stroke();
  9186. }
  9187. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9188. tmpContext = tmpContext || mainContext;
  9189. tmpContext.beginPath();
  9190. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9191. if (!dontFill) tmpContext.fill();
  9192. if (!dontStroke) tmpContext.stroke();
  9193. }
  9194. // RENDER STAR SHAPE:
  9195. function renderStar(ctxt, spikes, outer, inner) {
  9196. let rot = Math.PI / 2 * 3;
  9197. let x, y;
  9198. let step = Math.PI / spikes;
  9199. ctxt.beginPath();
  9200. ctxt.moveTo(0, -outer);
  9201. for (let i = 0; i < spikes; i++) {
  9202. x = Math.cos(rot) * outer;
  9203. y = Math.sin(rot) * outer;
  9204. ctxt.lineTo(x, y);
  9205. rot += step;
  9206. x = Math.cos(rot) * inner;
  9207. y = Math.sin(rot) * inner;
  9208. ctxt.lineTo(x, y);
  9209. rot += step;
  9210. }
  9211. ctxt.lineTo(0, -outer);
  9212. ctxt.closePath();
  9213. }
  9214. function renderHealthStar(ctxt, spikes, outer, inner) {
  9215. let rot = Math.PI / 2 * 3;
  9216. let x, y;
  9217. let step = Math.PI / spikes;
  9218. ctxt.beginPath();
  9219. ctxt.moveTo(0, -outer);
  9220. for (let i = 0; i < spikes; i++) {
  9221. x = Math.cos(rot) * outer;
  9222. y = Math.sin(rot) * outer;
  9223. ctxt.lineTo(x, y);
  9224. rot += step;
  9225. x = Math.cos(rot) * inner;
  9226. y = Math.sin(rot) * inner;
  9227. ctxt.lineTo(x, y);
  9228. rot += step;
  9229. }
  9230. ctxt.lineTo(0, -outer);
  9231. ctxt.closePath();
  9232. }
  9233. // RENDER RECTANGLE:
  9234. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9235. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9236. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9237. }
  9238. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9239. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9240. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9241. }
  9242. // RENDER RECTCIRCLE:
  9243. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9244. ctxt.save();
  9245. ctxt.translate(x, y);
  9246. seg = Math.ceil(seg / 2);
  9247. for (let i = 0; i < seg; i++) {
  9248. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9249. ctxt.rotate(Math.PI / seg);
  9250. }
  9251. ctxt.restore();
  9252. }
  9253. // RENDER BLOB:
  9254. function renderBlob(ctxt, spikes, outer, inner) {
  9255. let rot = Math.PI / 2 * 3;
  9256. let x, y;
  9257. let step = Math.PI / spikes;
  9258. let tmpOuter;
  9259. ctxt.beginPath();
  9260. ctxt.moveTo(0, -inner);
  9261. for (let i = 0; i < spikes; i++) {
  9262. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9263. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9264. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9265. rot += step * 2;
  9266. }
  9267. ctxt.lineTo(0, -inner);
  9268. ctxt.closePath();
  9269. }
  9270. // RENDER TRIANGLE:
  9271. function renderTriangle(s, ctx) {
  9272. ctx = ctx || mainContext;
  9273. let h = s * (Math.sqrt(3) / 2);
  9274. ctx.beginPath();
  9275. ctx.moveTo(0, -h / 2);
  9276. ctx.lineTo(-s / 2, h / 2);
  9277. ctx.lineTo(s / 2, h / 2);
  9278. ctx.lineTo(0, -h / 2);
  9279. ctx.fill();
  9280. ctx.closePath();
  9281. }
  9282. // PREPARE MENU BACKGROUND:
  9283. function prepareMenuBackground() {
  9284. let tmpMid = config.mapScale / 2;
  9285. let attempts = 0;
  9286. for (let i = 0; i < items.list.length * 10;) {
  9287. if (attempts >= 1000) break;
  9288. attempts++;
  9289. let type1 = items.list[15];
  9290. let type2 = items.list[9];
  9291. let data1 = {
  9292. x: tmpMid + UTILS.randFloat(-1000, 1000),
  9293. y: tmpMid + UTILS.randFloat(-600, 600),
  9294. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9295. };
  9296. if (objectManager.checkItemLocation(data1.x, data1.y, type1.scale, 0.6, type1.id, true)) {
  9297. objectManager.add(i, data1.x, data1.y, data1.dir, type1.scale, type1.id, type1);
  9298. let offsetX = UTILS.randFloat(-100, 100);
  9299. let offsetY = UTILS.randFloat(-100, 100);
  9300. let data2 = {
  9301. x: data1.x + offsetX,
  9302. y: data1.y + offsetY,
  9303. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9304. };
  9305. if (objectManager.checkItemLocation(data2.x, data2.y, type2.scale, 0.6, type2.id, true)) {
  9306. objectManager.add(i + 1, data2.x, data2.y, data2.dir, type2.scale, type2.id, type2);
  9307. } else {
  9308. continue;
  9309. }
  9310. } else {
  9311. continue;
  9312. }
  9313. i += 2;
  9314. }
  9315. }
  9316. const speed = 35;
  9317. // RENDER PLAYERS:
  9318. function renderDeadPlayers(xOffset, yOffset, deadAngle) {
  9319. mainContext.fillStyle = "#91b2db";
  9320. const currentTime = Date.now();
  9321. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9322. if (!dead.startTime) {
  9323. dead.startTime = currentTime;
  9324. dead.angle = 0;
  9325. dead.radius = 0.1;
  9326. }
  9327. const timeElapsed = currentTime - dead.startTime;
  9328. const maxAlpha = 1;
  9329. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9330. dead.animate(delta);
  9331. mainContext.globalAlpha = dead.alpha;
  9332. mainContext.strokeStyle = outlineColor;
  9333. mainContext.save();
  9334. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9335. dead.radius -= 0.001;
  9336. dead.angle += toRadian(1);
  9337. const moveSpeed = 40;
  9338. const x = dead.radius * Math.cos(deadAngle);
  9339. const y = dead.radius * Math.sin(deadAngle);
  9340. dead.x += x * moveSpeed;
  9341. dead.y += y * moveSpeed;
  9342. mainContext.rotate(dead.angle);
  9343. renderDeadPlayer(dead, mainContext);
  9344. mainContext.restore();
  9345. mainContext.fillStyle = "#bf8f54";
  9346. if (timeElapsed >= 3000) {
  9347. dead.active = false;
  9348. dead.startTime = null;
  9349. }
  9350. });
  9351. }
  9352. // RENDER PLAYERS:
  9353. let invisBody = false;
  9354. // RENDER PLAYERS:
  9355. function renderPlayers(xOffset, yOffset, zIndex) {
  9356. mainContext.globalAlpha = 1;
  9357. mainContext.fillStyle = "#91b2db";
  9358. for (var i = 0; i < players.length; ++i) {
  9359. tmpObj = players[i];
  9360. if (tmpObj.zIndex == zIndex) {
  9361. tmpObj.animate(delta);
  9362. if (tmpObj.visible) {
  9363. tmpObj.skinRot += (0.002 * delta);
  9364. tmpDir = (!configs.showDir && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir || 0);
  9365. mainContext.save();
  9366. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9367. // RENDER PLAYER:
  9368. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9369. if (tmpObj == player && invisBody) {
  9370. null;
  9371. } else {
  9372. renderPlayer(tmpObj, mainContext);
  9373. }
  9374. mainContext.restore();
  9375. }
  9376. }
  9377. }
  9378. }
  9379. // RENDER DEAD PLAYER:
  9380. function renderDeadPlayer(obj, ctxt) {
  9381. ctxt = ctxt || mainContext;
  9382. ctxt.lineWidth = outlineWidth;
  9383. ctxt.lineJoin = "miter";
  9384. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9385. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9386. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9387.  
  9388. // TAIL/CAPE:
  9389. renderTail2(13, ctxt, obj);
  9390.  
  9391. // WEAPON BELLOW HANDS:
  9392. if (obj.buildIndex < 0 && !items.weapons[10].aboveHand) {
  9393. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  9394. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9395. renderProjectile(obj.scale, 0,
  9396. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9397. }
  9398. }
  9399.  
  9400. // HANDS:
  9401. ctxt.fillStyle = "#ececec";
  9402. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9403. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9404. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9405.  
  9406. // WEAPON ABOVE HANDS:
  9407. if (obj.buildIndex < 0 && items.weapons[10].aboveHand) {
  9408. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  9409. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9410. renderProjectile(obj.scale, 0,
  9411. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9412. }
  9413. }
  9414.  
  9415. // BUILD ITEM:
  9416. if (obj.buildIndex >= 0) {
  9417. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9418. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9419. }
  9420.  
  9421. // BODY:
  9422. renderCircle(0, 0, obj.scale, ctxt);
  9423. // SKIN
  9424. renderSkin2(48, ctxt, null, obj)
  9425.  
  9426. }
  9427. // RENDER PLAYER:
  9428. function renderPlayer(obj, ctxt) {
  9429. ctxt = ctxt || mainContext;
  9430. ctxt.lineWidth = outlineWidth;
  9431. ctxt.lineJoin = "miter";
  9432. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9433. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9434. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9435. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9436. // TAIL/CAPE:
  9437. if (obj.tailIndex > 0) {
  9438. renderTail(obj.tailIndex, ctxt, obj);
  9439. }
  9440. // WEAPON BELLOW HANDS:
  9441. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9442. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9443. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9444. renderProjectile(obj.scale, 0,
  9445. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9446. }
  9447. }
  9448. // HANDS:
  9449. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9450. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9451. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9452. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9453. // WEAPON ABOVE HANDS:
  9454. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9455. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9456. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9457. renderProjectile(obj.scale, 0,
  9458. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9459. }
  9460. }
  9461. // BUILD ITEM:
  9462. if (obj.buildIndex >= 0) {
  9463. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9464. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9465. }
  9466. // BODY:
  9467. renderCircle(0, 0, obj.scale, ctxt);
  9468. // SKIN:
  9469. if (obj.skinIndex > 0) {
  9470. ctxt.rotate(Math.PI / 2);
  9471. renderSkin(obj.skinIndex, ctxt, null, obj);
  9472. }
  9473. }
  9474. // RENDER NORMAL SKIN
  9475. var skinSprites2 = {};
  9476. var skinPointers2 = {};
  9477. function renderSkin2(index, ctxt, parentSkin, owner) {
  9478. tmpSkin = skinSprites2[index];
  9479. if (!tmpSkin) {
  9480. var tmpImage = new Image();
  9481. tmpImage.onload = function() {
  9482. this.isLoaded = true;
  9483. this.onload = null;
  9484. };
  9485. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9486. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9487. skinSprites2[index] = tmpImage;
  9488. tmpSkin = tmpImage;
  9489. }
  9490. var tmpObj = parentSkin||skinPointers2[index];
  9491. if (!tmpObj) {
  9492. for (var i = 0; i < hats.length; ++i) {
  9493. if (hats[i].id == index) {
  9494. tmpObj = hats[i];
  9495. break;
  9496. }
  9497. }
  9498. skinPointers2[index] = tmpObj;
  9499. }
  9500. if (tmpSkin.isLoaded)
  9501. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9502. if (!parentSkin && tmpObj.topSprite) {
  9503. ctxt.save();
  9504. ctxt.rotate(owner.skinRot);
  9505. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9506. ctxt.restore();
  9507. }
  9508. }
  9509. // RENDER SKINS:
  9510. let skinSprites = {};
  9511. let skinPointers = {};
  9512. let tmpSkin;
  9513. function renderSkin(index, ctxt, parentSkin, owner) {
  9514. tmpSkin = skinSprites[index];
  9515. if (!tmpSkin) {
  9516. let tmpImage = new Image();
  9517. tmpImage.onload = function() {
  9518. this.isLoaded = true;
  9519. this.onload = null;
  9520. };
  9521. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9522. skinSprites[index] = tmpImage;
  9523. tmpSkin = tmpImage;
  9524. }
  9525. let tmpObj = parentSkin || skinPointers[index];
  9526. if (!tmpObj) {
  9527. for (let i = 0; i < hats.length; ++i) {
  9528. if (hats[i].id == index) {
  9529. tmpObj = hats[i];
  9530. break;
  9531. }
  9532. }
  9533. skinPointers[index] = tmpObj;
  9534. }
  9535. if (tmpSkin.isLoaded)
  9536. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9537. if (!parentSkin && tmpObj.topSprite) {
  9538. ctxt.save();
  9539. ctxt.rotate(owner.skinRot);
  9540. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9541. ctxt.restore();
  9542. }
  9543. }
  9544. // RENDER TAIL:
  9545. let accessSprites = {};
  9546. let accessPointers = {};
  9547. function renderTail(index, ctxt, owner) {
  9548. tmpSkin = accessSprites[index];
  9549. if (!tmpSkin) {
  9550. let tmpImage = new Image();
  9551. tmpImage.onload = function() {
  9552. this.isLoaded = true;
  9553. this.onload = null;
  9554. };
  9555. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9556. accessSprites[index] = tmpImage;
  9557. tmpSkin = tmpImage;
  9558. }
  9559. let tmpObj = accessPointers[index];
  9560. if (!tmpObj) {
  9561. for (let i = 0; i < accessories.length; ++i) {
  9562. if (accessories[i].id == index) {
  9563. tmpObj = accessories[i];
  9564. break;
  9565. }
  9566. }
  9567. accessPointers[index] = tmpObj;
  9568. }
  9569. if (tmpSkin.isLoaded) {
  9570. ctxt.save();
  9571. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9572. if (tmpObj.spin)
  9573. ctxt.rotate(owner.skinRot);
  9574. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9575. ctxt.restore();
  9576. }
  9577. }
  9578. // RENDER NORMAL TAIL
  9579. var accessSprites2 = {};
  9580. var accessPointers2 = {};
  9581. function renderTail2(index, ctxt, owner) {
  9582. tmpSkin = accessSprites2[index];
  9583. if (!tmpSkin) {
  9584. var tmpImage = new Image();
  9585. tmpImage.onload = function() {
  9586. this.isLoaded = true;
  9587. this.onload = null;
  9588. };
  9589. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9590. accessSprites2[index] = tmpImage;
  9591. tmpSkin = tmpImage;
  9592. }
  9593. var tmpObj = accessPointers2[index];
  9594. if (!tmpObj) {
  9595. for (var i = 0; i < accessories.length; ++i) {
  9596. if (accessories[i].id == index) {
  9597. tmpObj = accessories[i];
  9598. break;
  9599. }
  9600. }
  9601. accessPointers2[index] = tmpObj;
  9602. }
  9603. if (tmpSkin.isLoaded) {
  9604. ctxt.save();
  9605. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9606. if (tmpObj.spin)
  9607. ctxt.rotate(owner.skinRot);
  9608. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9609. ctxt.restore();
  9610. }
  9611. }
  9612. // RENDER TOOL:
  9613. let toolSprites = {};
  9614. function renderTool(obj, variant, x, y, ctxt) {
  9615. let tmpSrc = obj.src + (variant || "");
  9616. let tmpSprite = toolSprites[tmpSrc];
  9617. if (!tmpSprite) {
  9618. tmpSprite = new Image();
  9619. tmpSprite.onload = function() {
  9620. this.isLoaded = true;
  9621. }
  9622. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9623. toolSprites[tmpSrc] = tmpSprite;
  9624. }
  9625. if (tmpSprite.isLoaded)
  9626. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9627. }
  9628. // RENDER PROJECTILES:
  9629. function renderProjectiles(layer, xOffset, yOffset) {
  9630. for (let i = 0; i < projectiles.length; i++) {
  9631. tmpObj = projectiles[i];
  9632. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9633. tmpObj.update(delta);
  9634. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9635. mainContext.save();
  9636. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9637. mainContext.rotate(tmpObj.dir);
  9638. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9639. mainContext.restore();
  9640. }
  9641. }
  9642. };
  9643. }
  9644. // RENDER PROJECTILE:
  9645. let projectileSprites = {};
  9646. function renderProjectile(x, y, obj, ctxt, debug) {
  9647. if (obj.src) {
  9648. let tmpSrc = items.projectiles[obj.indx].src;
  9649. let tmpSprite = projectileSprites[tmpSrc];
  9650. if (!tmpSprite) {
  9651. tmpSprite = new Image();
  9652. tmpSprite.onload = function() {
  9653. this.isLoaded = true;
  9654. }
  9655. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9656. projectileSprites[tmpSrc] = tmpSprite;
  9657. }
  9658. if (tmpSprite.isLoaded)
  9659. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9660. } else if (obj.indx == 1) {
  9661. ctxt.fillStyle = "#939393";
  9662. renderCircle(x, y, obj.scale, ctxt);
  9663. }
  9664. }
  9665. // RENDER AI:
  9666. let aiSprites = {};
  9667. function renderAI(obj, ctxt) {
  9668. let tmpIndx = obj.index;
  9669. let tmpSprite = aiSprites[tmpIndx];
  9670. if (!tmpSprite) {
  9671. let tmpImg = new Image();
  9672. tmpImg.onload = function() {
  9673. this.isLoaded = true;
  9674. this.onload = null;
  9675. };
  9676. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9677. tmpSprite = tmpImg;
  9678. aiSprites[tmpIndx] = tmpSprite;
  9679. }
  9680. if (tmpSprite.isLoaded) {
  9681. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9682. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9683. }
  9684. }
  9685. // RENDER WATER BODIES:
  9686. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9687. // MIDDLE RIVER:
  9688. let tmpW = config.riverWidth + padding;
  9689. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9690. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9691. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9692. }
  9693. }
  9694. // RENDER GAME OBJECTS:
  9695. let gameObjectSprites = {};
  9696. function getResSprite(obj) {
  9697. let biomeID = (obj.y>=config.mapScale-config.snowBiomeTop)?2:((obj.y<=config.snowBiomeTop)?1:0);
  9698. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9699. let tmpSprite = gameObjectSprites[tmpIndex];
  9700. if (!tmpSprite) {
  9701. let blurScale = 15;
  9702. let tmpCanvas = document.createElement("canvas");
  9703. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9704. let tmpContext = tmpCanvas.getContext('2d');
  9705. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9706. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9707. tmpContext.strokeStyle = outlineColor;
  9708. tmpContext.lineWidth = outlineWidth;
  9709. if (isNight) {
  9710. tmpContext.shadowBlur = blurScale;
  9711. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9712. }
  9713. if (obj.type == 0) {
  9714. let tmpScale;
  9715. let tmpCount = UTILS.randInt(5, 7);
  9716. tmpContext.globalAlpha = isNight ? 0.6 : 0.8;
  9717. for (let i = 0; i < 2; ++i) {
  9718. tmpScale = tmpObj.scale * (!i?1:0.5);
  9719. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9720. tmpContext.fillStyle = !biomeID?(!i?"#9ebf57":"#b4db62"):(!i?"#e3f1f4":"#fff");
  9721. tmpContext.fill();
  9722. if (!i) {
  9723. tmpContext.stroke();
  9724. tmpContext.shadowBlur = null;
  9725. tmpContext.shadowColor = null;
  9726. tmpContext.globalAlpha = 1;
  9727. }
  9728. }
  9729. } else if (obj.type == 1) {
  9730. if (biomeID == 2) {
  9731. tmpContext.fillStyle = "#606060";
  9732. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9733. tmpContext.fill();
  9734. tmpContext.stroke();
  9735.  
  9736. //tmpContext.shadowBlur = null;
  9737. //tmpContext.shadowColor = null;
  9738.  
  9739. tmpContext.fillStyle = "#89a54c";
  9740. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9741. tmpContext.fillStyle = "#a5c65b";
  9742. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9743. } else {
  9744. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9745. tmpContext.fillStyle = biomeID?"#e3f1f4":"#89a54c";
  9746. tmpContext.fill();
  9747. tmpContext.stroke();
  9748.  
  9749. //tmpContext.shadowBlur = null;
  9750. //tmpContext.shadowColor = null;
  9751.  
  9752. tmpContext.fillStyle = biomeID?"#6a64af":"#c15555";
  9753. let tmpRange;
  9754. let berries = 4;
  9755. let rotVal = (Math.PI * 2) / berries;
  9756. for (let i = 0; i < berries; ++i) {
  9757. tmpRange = UTILS.randInt(tmpObj.scale/3.5, tmpObj.scale/2.3);
  9758. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9759. UTILS.randInt(10, 12), tmpContext);
  9760. }
  9761. }
  9762. } else if (obj.type == 2 || obj.type == 3) {
  9763. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#938d77":"#939393"):"#e0c655";
  9764. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9765. tmpContext.fill();
  9766. tmpContext.stroke();
  9767.  
  9768. tmpContext.shadowBlur = null;
  9769. tmpContext.shadowColor = null;
  9770.  
  9771. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#b2ab90":"#bcbcbc"):"#ebdca3";
  9772. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9773. tmpContext.fill();
  9774. }
  9775. tmpSprite = tmpCanvas;
  9776. gameObjectSprites[tmpIndex] = tmpSprite;
  9777. }
  9778. return tmpSprite;
  9779. }
  9780.  
  9781. // GET ITEM SPRITE:
  9782. let itemSprites = [];
  9783. function getItemSprite(obj, asIcon) {
  9784. let tmpSprite = itemSprites[obj.id];
  9785. if (!tmpSprite || asIcon) {
  9786. let blurScale = !asIcon && isNight ? 15 : 0;
  9787. let tmpCanvas = document.createElement("canvas");
  9788. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9789. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9790. let tmpContext = tmpCanvas.getContext("2d");
  9791. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9792. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9793. tmpContext.strokeStyle = outlineColor;
  9794. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9795. if (isNight && !asIcon) {
  9796. tmpContext.shadowBlur = blurScale;
  9797. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(obj.name == "pit trap" ? 0.6 : 0.3, obj.alpha)})`;
  9798. }
  9799. if (obj.name == "apple") {
  9800. tmpContext.fillStyle = "#c15555";
  9801. renderCircle(0, 0, obj.scale, tmpContext);
  9802. tmpContext.fillStyle = "#89a54c";
  9803. let leafDir = -(Math.PI / 2);
  9804. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9805. 25, leafDir + Math.PI / 2, tmpContext);
  9806. } else if (obj.name == "cookie") {
  9807. tmpContext.fillStyle = "#cca861";
  9808. renderCircle(0, 0, obj.scale, tmpContext);
  9809. tmpContext.fillStyle = "#937c4b";
  9810. let chips = 4;
  9811. let rotVal = (Math.PI * 2) / chips;
  9812. let tmpRange;
  9813. for (let i = 0; i < chips; ++i) {
  9814. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9815. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9816. UTILS.randInt(4, 5), tmpContext, true);
  9817. }
  9818. } else if (obj.name == "cheese") {
  9819. tmpContext.fillStyle = "#f4f3ac";
  9820. renderCircle(0, 0, obj.scale, tmpContext);
  9821. tmpContext.fillStyle = "#c3c28b";
  9822. let chips = 4;
  9823. let rotVal = (Math.PI * 2) / chips;
  9824. let tmpRange;
  9825. for (let i = 0; i < chips; ++i) {
  9826. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9827. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9828. UTILS.randInt(4, 5), tmpContext, true);
  9829. }
  9830. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9831. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9832. "#a5974c" : "#939393";
  9833. let sides = (obj.name == "castle wall") ? 4 : 3;
  9834. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9835. tmpContext.fill();
  9836. tmpContext.stroke();
  9837. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9838. "#c9b758" : "#bcbcbc";
  9839. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9840. tmpContext.fill();
  9841. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9842. obj.name == "spinning spikes") {
  9843. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9844. let tmpScale = (obj.scale * 0.6);
  9845. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9846. tmpContext.fill();
  9847. tmpContext.stroke();
  9848. tmpContext.fillStyle = "#a5974c";
  9849. renderCircle(0, 0, tmpScale, tmpContext);
  9850. tmpContext.fillStyle = "#c9b758";
  9851. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9852. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9853. tmpContext.fillStyle = "#a5974c";
  9854. renderCircle(0, 0, reScale, tmpContext);
  9855. tmpContext.fillStyle = "#c9b758";
  9856. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9857. tmpContext.fillStyle = "#a5974c";
  9858. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9859. } else if (obj.name == "mine") {
  9860. tmpContext.fillStyle = "#939393";
  9861. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9862. tmpContext.fill();
  9863. tmpContext.stroke();
  9864. tmpContext.fillStyle = "#bcbcbc";
  9865. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9866. tmpContext.fill();
  9867. } else if (obj.name == "sapling") {
  9868. for (let i = 0; i < 2; ++i) {
  9869. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9870. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9871. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9872. tmpContext.fill();
  9873. if (!i) tmpContext.stroke();
  9874. }
  9875. } else if (obj.name == "pit trap") {
  9876. tmpContext.fillStyle = "#a5974c";
  9877. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9878. tmpContext.fill();
  9879. tmpContext.stroke();
  9880. tmpContext.fillStyle = outlineColor;
  9881. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9882. tmpContext.fill();
  9883. } else if (obj.name == "boost pad") {
  9884. tmpContext.fillStyle = "#7e7f82";
  9885. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9886. tmpContext.fill();
  9887. tmpContext.stroke();
  9888. tmpContext.fillStyle = "#dbd97d";
  9889. renderTriangle(obj.scale * 1, tmpContext);
  9890. } else if (obj.name == "turret") {
  9891. tmpContext.fillStyle = "#a5974c";
  9892. renderCircle(0, 0, obj.scale, tmpContext);
  9893. tmpContext.fill();
  9894. tmpContext.stroke();
  9895. tmpContext.fillStyle = "#939393";
  9896. let tmpLen = 50;
  9897. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9898. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9899. tmpContext.fill();
  9900. tmpContext.stroke();
  9901. } else if (obj.name == "platform") {
  9902. tmpContext.fillStyle = "#cebd5f";
  9903. let tmpCount = 4;
  9904. let tmpS = obj.scale * 2;
  9905. let tmpW = tmpS / tmpCount;
  9906. let tmpX = -(obj.scale / 2);
  9907. for (let i = 0; i < tmpCount; ++i) {
  9908. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9909. tmpContext.fill();
  9910. tmpContext.stroke();
  9911. tmpX += tmpS / tmpCount;
  9912. }
  9913. } else if (obj.name == "healing pad") {
  9914. tmpContext.fillStyle = "#7e7f82";
  9915. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9916. tmpContext.fill();
  9917. tmpContext.stroke();
  9918. tmpContext.fillStyle = "#db6e6e";
  9919. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9920. } else if (obj.name == "spawn pad") {
  9921. tmpContext.fillStyle = "#7e7f82";
  9922. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9923. tmpContext.fill();
  9924. tmpContext.stroke();
  9925. tmpContext.fillStyle = "#71aad6";
  9926. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9927. } else if (obj.name == "blocker") {
  9928. tmpContext.fillStyle = "#7e7f82";
  9929. renderCircle(0, 0, obj.scale, tmpContext);
  9930. tmpContext.fill();
  9931. tmpContext.stroke();
  9932. tmpContext.rotate(Math.PI / 4);
  9933. tmpContext.fillStyle = "#db6e6e";
  9934. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9935. } else if (obj.name == "teleporter") {
  9936. tmpContext.fillStyle = "#7e7f82";
  9937. renderCircle(0, 0, obj.scale, tmpContext);
  9938. tmpContext.fill();
  9939. tmpContext.stroke();
  9940. tmpContext.rotate(Math.PI / 4);
  9941. tmpContext.fillStyle = "#d76edb";
  9942. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9943. }
  9944. tmpSprite = tmpCanvas;
  9945. if (!asIcon)
  9946. itemSprites[obj.id] = tmpSprite;
  9947. }
  9948. return tmpSprite;
  9949. }
  9950.  
  9951. function getItemSprite2(obj, tmpX, tmpY) {
  9952. let tmpContext = mainContext;
  9953. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9954. tmpContext.save();
  9955. tmpContext.translate(tmpX, tmpY);
  9956. tmpContext.rotate(obj.dir);
  9957. tmpContext.strokeStyle = outlineColor;
  9958. tmpContext.lineWidth = outlineWidth;
  9959. if (obj.name == "apple") {
  9960. tmpContext.fillStyle = "#c15555";
  9961. renderCircle(0, 0, obj.scale, tmpContext);
  9962. tmpContext.fillStyle = "#89a54c";
  9963. let leafDir = -(Math.PI / 2);
  9964. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9965. 25, leafDir + Math.PI / 2, tmpContext);
  9966. } else if (obj.name == "cookie") {
  9967. tmpContext.fillStyle = "#cca861";
  9968. renderCircle(0, 0, obj.scale, tmpContext);
  9969. tmpContext.fillStyle = "#937c4b";
  9970. let chips = 4;
  9971. let rotVal = (Math.PI * 2) / chips;
  9972. let tmpRange;
  9973. for (let i = 0; i < chips; ++i) {
  9974. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9975. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9976. UTILS.randInt(4, 5), tmpContext, true);
  9977. }
  9978. } else if (obj.name == "cheese") {
  9979. tmpContext.fillStyle = "#f4f3ac";
  9980. renderCircle(0, 0, obj.scale, tmpContext);
  9981. tmpContext.fillStyle = "#c3c28b";
  9982. let chips = 4;
  9983. let rotVal = (Math.PI * 2) / chips;
  9984. let tmpRange;
  9985. for (let i = 0; i < chips; ++i) {
  9986. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9987. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9988. UTILS.randInt(4, 5), tmpContext, true);
  9989. }
  9990. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9991. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9992. "#a5974c" : "#939393";
  9993. let sides = (obj.name == "castle wall") ? 4 : 3;
  9994. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9995. tmpContext.fill();
  9996. tmpContext.stroke();
  9997. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9998. "#c9b758" : "#bcbcbc";
  9999. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10000. tmpContext.fill();
  10001. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10002. obj.name == "spinning spikes") {
  10003. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10004. let tmpScale = (obj.scale * 0.6);
  10005. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10006. tmpContext.fill();
  10007. tmpContext.stroke();
  10008. tmpContext.fillStyle = "#a5974c";
  10009. renderCircle(0, 0, tmpScale, tmpContext);
  10010. tmpContext.fillStyle = "#c9b758";
  10011. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10012. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10013. tmpContext.fillStyle = "#a5974c";
  10014. renderCircle(0, 0, reScale, tmpContext);
  10015. tmpContext.fillStyle = "#c9b758";
  10016. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10017. tmpContext.fillStyle = "#a5974c";
  10018. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10019. } else if (obj.name == "mine") {
  10020. tmpContext.fillStyle = "#939393";
  10021. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10022. tmpContext.fill();
  10023. tmpContext.stroke();
  10024. tmpContext.fillStyle = "#bcbcbc";
  10025. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10026. tmpContext.fill();
  10027. } else if (obj.name == "sapling") {
  10028. for (let i = 0; i < 2; ++i) {
  10029. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10030. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10031. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10032. tmpContext.fill();
  10033. if (!i) tmpContext.stroke();
  10034. }
  10035. } else if (obj.name == "pit trap") {
  10036. tmpContext.fillStyle = "#a5974c";
  10037. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10038. tmpContext.fill();
  10039. tmpContext.stroke();
  10040. tmpContext.fillStyle = outlineColor;
  10041. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10042. tmpContext.fill();
  10043. } else if (obj.name == "boost pad") {
  10044. tmpContext.fillStyle = "#7e7f82";
  10045. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10046. tmpContext.fill();
  10047. tmpContext.stroke();
  10048. tmpContext.fillStyle = "#dbd97d";
  10049. renderTriangle(obj.scale * 1, tmpContext);
  10050. } else if (obj.name == "turret") {
  10051. tmpContext.fillStyle = "#a5974c";
  10052. renderCircle(0, 0, obj.scale, tmpContext);
  10053. tmpContext.fill();
  10054. tmpContext.stroke();
  10055. tmpContext.fillStyle = "#939393";
  10056. let tmpLen = 50;
  10057. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10058. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10059. tmpContext.fill();
  10060. tmpContext.stroke();
  10061. } else if (obj.name == "platform") {
  10062. tmpContext.fillStyle = "#cebd5f";
  10063. let tmpCount = 4;
  10064. let tmpS = obj.scale * 2;
  10065. let tmpW = tmpS / tmpCount;
  10066. let tmpX = -(obj.scale / 2);
  10067. for (let i = 0; i < tmpCount; ++i) {
  10068. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10069. tmpContext.fill();
  10070. tmpContext.stroke();
  10071. tmpX += tmpS / tmpCount;
  10072. }
  10073. } else if (obj.name == "healing pad") {
  10074. tmpContext.fillStyle = "#7e7f82";
  10075. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10076. tmpContext.fill();
  10077. tmpContext.stroke();
  10078. tmpContext.fillStyle = "#db6e6e";
  10079. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10080. } else if (obj.name == "spawn pad") {
  10081. tmpContext.fillStyle = "#7e7f82";
  10082. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10083. tmpContext.fill();
  10084. tmpContext.stroke();
  10085. tmpContext.fillStyle = "#71aad6";
  10086. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10087. } else if (obj.name == "blocker") {
  10088. tmpContext.fillStyle = "#7e7f82";
  10089. renderCircle(0, 0, obj.scale, tmpContext);
  10090. tmpContext.fill();
  10091. tmpContext.stroke();
  10092. tmpContext.rotate(Math.PI / 4);
  10093. tmpContext.fillStyle = "#db6e6e";
  10094. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10095. } else if (obj.name == "teleporter") {
  10096. tmpContext.fillStyle = "#7e7f82";
  10097. renderCircle(0, 0, obj.scale, tmpContext);
  10098. tmpContext.fill();
  10099. tmpContext.stroke();
  10100. tmpContext.rotate(Math.PI / 4);
  10101. tmpContext.fillStyle = "#d76edb";
  10102. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10103. }
  10104. tmpContext.restore();
  10105. }
  10106.  
  10107. let objSprites = [];
  10108. function getObjSprite(obj) {
  10109. let tmpSprite = objSprites[obj.id];
  10110. if (!tmpSprite) {
  10111. let blurScale = isNight ? 15 : 0;
  10112. let tmpCanvas = document.createElement("canvas");
  10113. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10114. let tmpContext = tmpCanvas.getContext("2d");
  10115. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10116. tmpContext.rotate(Math.PI / 2);
  10117. tmpContext.strokeStyle = outlineColor;
  10118. tmpContext.lineWidth = outlineWidth;
  10119. if (isNight) {
  10120. tmpContext.shadowBlur = blurScale;
  10121. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10122. }
  10123. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10124. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  10125. let tmpScale = obj.scale * 0.6;
  10126. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10127. tmpContext.fill();
  10128. tmpContext.stroke();
  10129. tmpContext.fillStyle = "#a5974c";
  10130. renderCircle(0, 0, tmpScale, tmpContext);
  10131. tmpContext.fillStyle = "#cc5151";
  10132. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10133. } else if (obj.name == "pit trap") {
  10134. tmpContext.fillStyle = "#a5974c";
  10135. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10136. tmpContext.fill();
  10137. tmpContext.stroke();
  10138. tmpContext.fillStyle = "#cc5151";
  10139. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10140. tmpContext.fill();
  10141. }
  10142. tmpSprite = tmpCanvas;
  10143. objSprites[obj.id] = tmpSprite;
  10144. }
  10145. return tmpSprite;
  10146. }
  10147.  
  10148. // GET MARK SPRITE:
  10149. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10150.  
  10151. let center = {
  10152. x: screenWidth / 2,
  10153. y: screenHeight / 2,
  10154. };
  10155. tmpContext.lineWidth = outlineWidth;
  10156. mainContext.globalAlpha = 0.4;
  10157. tmpContext.strokeStyle = outlineColor;
  10158. tmpContext.save();
  10159. tmpContext.translate(tmpX, tmpY);
  10160. tmpContext.rotate(obj.dir || getAttackDir());
  10161. if (getEl("renderplace").value == "placeVis") {
  10162. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10163. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  10164. var tmpScale = (obj.scale * 0.6);
  10165. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  10166. tmpContext.fill();
  10167. tmpContext.stroke();
  10168. tmpContext.fillStyle = "#a5974c";
  10169. renderCircle(0, 0, tmpScale, tmpContext);
  10170. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10171. tmpContext.fillStyle = "#a34040";
  10172. } else {
  10173. tmpContext.fillStyle = "#c9b758";
  10174. }
  10175. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  10176. } else if (obj.name == "turret") {
  10177. tmpContext.fillStyle = "#a5974c";
  10178. renderCircle(0, 0, obj.scale, tmpContext);
  10179. tmpContext.fill();
  10180. tmpContext.stroke();
  10181. tmpContext.fillStyle = "#939393";
  10182. let tmpLen = 50;
  10183. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10184. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10185. tmpContext.fill();
  10186. tmpContext.stroke();
  10187. } else if (obj.name == "teleporter") {
  10188. tmpContext.fillStyle = "#7e7f82";
  10189. renderCircle(0, 0, obj.scale, tmpContext);
  10190. tmpContext.fill();
  10191. tmpContext.stroke();
  10192. tmpContext.rotate(Math.PI / 4);
  10193. tmpContext.fillStyle = "#d76edb";
  10194. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10195. } else if (obj.name == "platform") {
  10196. tmpContext.fillStyle = "#cebd5f";
  10197. let tmpCount = 4;
  10198. let tmpS = obj.scale * 2;
  10199. let tmpW = tmpS / tmpCount;
  10200. let tmpX = -(obj.scale / 2);
  10201. for (let i = 0; i < tmpCount; ++i) {
  10202. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10203. tmpContext.fill();
  10204. tmpContext.stroke();
  10205. tmpX += tmpS / tmpCount;
  10206. }
  10207. } else if (obj.name == "healing pad") {
  10208. tmpContext.fillStyle = "#7e7f82";
  10209. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10210. tmpContext.fill();
  10211. tmpContext.stroke();
  10212. tmpContext.fillStyle = "#db6e6e";
  10213. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10214. } else if (obj.name == "spawn pad") {
  10215. tmpContext.fillStyle = "#7e7f82";
  10216. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10217. tmpContext.fill();
  10218. tmpContext.stroke();
  10219. tmpContext.fillStyle = "#71aad6";
  10220. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10221. } else if (obj.name == "blocker") {
  10222. tmpContext.fillStyle = "#7e7f82";
  10223. renderCircle(0, 0, obj.scale, tmpContext);
  10224. tmpContext.fill();
  10225. tmpContext.stroke();
  10226. tmpContext.rotate(Math.PI / 4);
  10227. tmpContext.fillStyle = "#db6e6e";
  10228. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10229. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10230. tmpContext.fillStyle = "#a5974c";
  10231. renderCircle(0, 0, obj.scale, tmpContext);
  10232. tmpContext.fillStyle = "#c9b758";
  10233. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10234. tmpContext.fillStyle = "#a5974c";
  10235. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10236. } else if (obj.name == "pit trap") {
  10237. tmpContext.fillStyle = "#a5974c";
  10238. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10239. tmpContext.fill();
  10240. tmpContext.stroke();
  10241. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10242. tmpContext.fillStyle = "#a34040";
  10243. } else {
  10244. tmpContext.fillStyle = outlineColor;
  10245. }
  10246. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10247. tmpContext.fill();
  10248. }
  10249. tmpContext.restore();
  10250. }
  10251. }
  10252. function getMarkSprite2(obj, tmpContext, tmpX, tmpY) {
  10253.  
  10254. if (getEl("renderplace").value == "outline") {
  10255. tmpContext.lineWidth = outlineWidth;
  10256. mainContext.globalAlpha = 1;
  10257. tmpContext.strokeStyle = outlineColor;
  10258. tmpContext.save();
  10259. tmpContext.translate(tmpX, tmpY);
  10260. tmpContext.rotate(obj.dir || getAttackDir());
  10261.  
  10262. if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10263. let sides = obj.name == "castle wall" ? 4 : 3;
  10264. renderHealthStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10265. tmpContext.stroke();
  10266. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10267. let tmpScale = obj.scale * 0.6;
  10268. renderHealthStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10269. tmpContext.stroke();
  10270. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10271. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10272. } else if (obj.name == "mine") {
  10273. renderHealthStar(tmpContext, 3, obj.scale, obj.scale);
  10274. tmpContext.stroke();
  10275. } else if (obj.name == "sapling") {
  10276. let tmpScale = obj.scale * 0.7;
  10277. renderHealthStar(tmpContext, 7, obj.scale, tmpScale);
  10278. tmpContext.stroke();
  10279. } else if (obj.name == "pit trap") {
  10280. renderHealthStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10281. tmpContext.stroke();
  10282. } else if (obj.name == "boost pad") {
  10283. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10284. } else if (obj.name == "turret") {
  10285. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10286. } else if (obj.name == "platform") {
  10287. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10288. } else if (obj.name == "healing pad") {
  10289. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10290. } else if (obj.name == "spawn pad") {
  10291. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10292. } else if (obj.name == "blocker") {
  10293. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10294. } else if (obj.name == "teleporter") {
  10295. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10296. }
  10297. tmpContext.restore();
  10298.  
  10299. }
  10300. }
  10301. //renderCircle(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.getScale(0.6, true), mainContext, false, true);
  10302. // OBJECT ON SCREEN:
  10303. function isOnScreen(x, y, s) {
  10304. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10305. s,
  10306. maxScreenHeight));
  10307. }
  10308. /* function markObject(tmpObj, tmpX, tmpY) {
  10309. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10310. }*/
  10311. function markObject(tmpObj, tmpX, tmpY) {
  10312. yen(mainContext, tmpX, tmpY);
  10313. }
  10314. function yen(context, x, y) {
  10315. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  10316. context.beginPath();
  10317. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  10318. context.fill();
  10319. context.closePath();
  10320. context.globalAlpha = 1;
  10321. }
  10322. // RENDER MINIMAP:
  10323. class MapPing {
  10324. constructor(color, scale) {
  10325. this.init = function(x, y) {
  10326. this.scale = 0;
  10327. this.x = x;
  10328. this.y = y;
  10329. this.active = true;
  10330. };
  10331. this.update = function(ctxt, delta) {
  10332. if (this.active) {
  10333. this.scale += 0.05 * delta;
  10334. if (this.scale >= scale) {
  10335. this.active = false;
  10336. } else {
  10337. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10338. ctxt.beginPath();
  10339. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale)
  10340. * mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10341. ctxt.stroke();
  10342. }
  10343. }
  10344. };
  10345. this.color = color;
  10346. }
  10347. }
  10348. function pingMap(x, y) {
  10349. tmpPing = mapPings.find(pings => !pings.active);
  10350. if (!tmpPing) {
  10351. tmpPing = new MapPing("#fff", config.mapPingScale);
  10352. mapPings.push(tmpPing);
  10353. }
  10354. tmpPing.init(x, y);
  10355. }
  10356. function updateMapMarker() {
  10357. mapMarker.x = player.x;
  10358. mapMarker.y = player.y;
  10359. }
  10360. function renderMinimap(delta) {
  10361. if (player && player.alive) {
  10362. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10363. // RENDER PINGS:
  10364. mapContext.lineWidth = 4;
  10365. for (let i = 0; i < mapPings.length; ++i) {
  10366. tmpPing = mapPings[i];
  10367. mapContext.strokeStyle = tmpPing.color;
  10368. tmpPing.update(mapContext, delta);
  10369. }
  10370. // RENDER BREAK TRACKS:
  10371. mapContext.globalAlpha = 1;
  10372. mapContext.fillStyle = "#ff0000";
  10373. if (breakTrackers.length) {
  10374. mapContext.fillStyle = "#abcdef";
  10375. mapContext.font = "34px Hammersmith One";
  10376. mapContext.textBaseline = "middle";
  10377. mapContext.textAlign = "center";
  10378. for (let i = 0; i < breakTrackers.length;) {
  10379. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  10380. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  10381. i += 2;
  10382. }
  10383. }
  10384. // RENDER PLAYERS:
  10385. mapContext.globalAlpha = 1;
  10386. mapContext.fillStyle = "#fff";
  10387. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10388. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10389. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10390. if (player.team && minimapData) {
  10391. for (let i = 0; i < minimapData.length;) {
  10392. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10393. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10394. i += 2;
  10395. }
  10396. }
  10397. // RENDER BOTS:
  10398. if (bots.length) {
  10399. bots.forEach((tmp) => {
  10400. if (tmp.inGame) {
  10401. mapContext.globalAlpha = 1;
  10402. mapContext.strokeStyle = "#782F44";
  10403. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10404. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10405. }
  10406. });
  10407. }
  10408. // DEATH LOCATION:
  10409. if (lastDeath) {
  10410. mapContext.fillStyle = "#fc5553";
  10411. mapContext.font = "34px Hammersmith One";
  10412. mapContext.textBaseline = "middle";
  10413. mapContext.textAlign = "center";
  10414. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10415. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10416. }
  10417. // MAP MARKER:
  10418. if (mapMarker) {
  10419. mapContext.fillStyle = "#fff";
  10420. mapContext.font = "34px Hammersmith One";
  10421. mapContext.textBaseline = "middle";
  10422. mapContext.textAlign = "center";
  10423. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10424. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10425. }
  10426. }
  10427. }
  10428. // ICONS:
  10429. let crossHairs = ["https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg", "https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg"];
  10430. let crossHairSprites = {};
  10431. let iconSprites = {};
  10432. let icons = ["crown", "skull"];
  10433.  
  10434. function loadIcons() {
  10435. for (let i = 0; i < icons.length; ++i) {
  10436. let tmpSprite = new Image();
  10437. tmpSprite.onload = function() {
  10438. this.isLoaded = true;
  10439. };
  10440. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10441. iconSprites[icons[i]] = tmpSprite;
  10442. }
  10443. let tmpSprite = new Image();
  10444. tmpSprite.onload = function() {
  10445. this.isLoaded = true;
  10446. };
  10447. tmpSprite.src = crossHairs
  10448. crossHairSprites = tmpSprite;
  10449. }
  10450. loadIcons();
  10451. // UPDATE GAME:
  10452. function updateGame() {
  10453. if (config.resetRender) {
  10454. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10455. mainContext.beginPath();
  10456. }
  10457. function add(array) {
  10458. let lmao = 0
  10459. for (let i = 0; i < array.length; i++) {
  10460. lmao += array[i]
  10461. }
  10462. return lmao / array.length
  10463. }
  10464. if (true) {
  10465. function updateCamera() {
  10466. let selectedCamera = document.getElementById("camera").value;
  10467. let damping = 0.35;
  10468. let scalingFactor = 20;
  10469. if (player) {
  10470. if (selectedCamera === 'Cam1') {
  10471. let damping = 0.1;
  10472. let targetCamX = player.x + ((1920 / 2) / 30);
  10473. let targetCamY = player.y + ((1920 / 2) / 30);
  10474. camX += (targetCamX - camX) * damping;
  10475. camY += (targetCamY - camY) * damping;
  10476. } else if (selectedCamera === 'Cam2' || selectedCamera === 'Cam3') {
  10477. let damping2 = 0.016;
  10478. if (player) {
  10479. let targetCamX = player.x + ((1920 / 2) / 30);
  10480. let targetCamY = player.y + ((1920 / 2) / 30);
  10481. camX = lerp(camX, targetCamX, damping2);
  10482. camY = lerp(camY, targetCamY, damping2);
  10483. } else {
  10484. camX = config.mapScale / 2;
  10485. camY = config.mapScale / 2;
  10486. }
  10487. }
  10488. } else {
  10489. camX = config.mapScale / 2;
  10490. camY = config.mapScale / 2;
  10491. }
  10492. }
  10493. updateCamera()
  10494. document.getElementById("camera").addEventListener("change", updateCamera);
  10495. function lerp(start, end, amt) {
  10496. return (1 - amt) * start + amt * end;
  10497. }
  10498. // INTERPOLATE PLAYERS AND AI:
  10499. let lastTime = now - (1000 / config.serverUpdateRate);
  10500. let tmpDiff;
  10501. for (let i = 0; i < players.length + ais.length; ++i) {
  10502. tmpObj = players[i] || ais[i - players.length];
  10503. if (tmpObj && tmpObj.visible) {
  10504. if (tmpObj.forcePos) {
  10505. tmpObj.x = tmpObj.x2;
  10506. tmpObj.y = tmpObj.y2;
  10507. tmpObj.dir = tmpObj.d2;
  10508. } else {
  10509. let total = tmpObj.t2 - tmpObj.t1;
  10510. let fraction = lastTime - tmpObj.t1;
  10511. let ratio = (fraction / total);
  10512. let rate = 170;
  10513. tmpObj.dt += delta;
  10514. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10515. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10516. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10517. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10518. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10519. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10520. }
  10521. }
  10522. }
  10523. // RENDER CORDS:
  10524. let xOffset = camX - (maxScreenWidth / 2);
  10525. let yOffset = camY - (maxScreenHeight / 2);
  10526. // RENDER BACKGROUND:
  10527. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10528. mainContext.fillStyle = "#87b522";
  10529. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10530. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10531. mainContext.fillStyle = "#bfa426";
  10532. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10533. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10534. mainContext.fillStyle = "#defdff";
  10535. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10536. } else if (config.snowBiomeTop - yOffset >= 0) {
  10537. mainContext.fillStyle = "#defdff";
  10538. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10539. mainContext.fillStyle = "#b6db66";
  10540. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10541. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10542. } else {
  10543. mainContext.fillStyle = "#b6db66";
  10544. mainContext.fillRect(0, 0, maxScreenWidth,
  10545. (config.mapScale - config.snowBiomeTop - yOffset));
  10546. mainContext.fillStyle = "#dbc666";
  10547. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10548. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10549. }
  10550.  
  10551. // RENDER WATER AREAS:
  10552. if (!firstSetup) {
  10553. waterMult += waterPlus * config.waveSpeed * delta;
  10554. if (waterMult >= config.waveMax) {
  10555. waterMult = config.waveMax;
  10556. waterPlus = -1;
  10557. } else if (waterMult <= 1) {
  10558. waterMult = waterPlus = 1;
  10559. }
  10560. mainContext.globalAlpha = 1;
  10561. mainContext.fillStyle = "#e8a033";
  10562. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10563. mainContext.fillStyle = "#91c5ff";
  10564. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10565. }
  10566. if (player) {
  10567. // DEATH LOCATION:
  10568. if (lastDeath) {
  10569. mainContext.globalAlpha = 1;
  10570. mainContext.fillStyle = "#fc5553";
  10571. mainContext.font = "100px Hammersmith One";
  10572. mainContext.textBaseline = "middle";
  10573. mainContext.textAlign = "center";
  10574. mainContext.fillText("x", lastDeath.x - xOffset, lastDeath.y - yOffset);
  10575. }
  10576. // PATHFINDER LINE:
  10577. if (pathFind.active) {
  10578. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10579. mainContext.lineWidth = player.scale / 5;
  10580. mainContext.globalAlpha = 1;
  10581. mainContext.strokeStyle = "red";
  10582. mainContext.beginPath();
  10583. pathFind.array.forEach((path, i) => {
  10584. let pathXY = {
  10585. x: (pathFind.scale / pathFind.grid) * path.x,
  10586. y: (pathFind.scale / pathFind.grid) * path.y
  10587. }
  10588. let render = {
  10589. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10590. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10591. }
  10592. if (i == 0) {
  10593. mainContext.moveTo(render.x, render.y);
  10594. } else {
  10595. mainContext.lineTo(render.x, render.y);
  10596. }
  10597. });
  10598. mainContext.stroke();
  10599. }
  10600. }
  10601. }
  10602. // RENDER DEAD PLAYERS:
  10603. if (inWindow && fisrtloadez) {
  10604. mainContext.globalAlpha = 1;
  10605. mainContext.strokeStyle = outlineColor;
  10606. renderDeadPlayers(xOffset, yOffset, Math.random() * Math.PI * 2);
  10607. }
  10608. // RENDER BOTTOM LAYER:
  10609. mainContext.globalAlpha = 1;
  10610. mainContext.strokeStyle = outlineColor;
  10611. renderGameObjects(-1, xOffset, yOffset);
  10612. // RENDER PROJECTILES:
  10613. mainContext.globalAlpha = 1;
  10614. mainContext.lineWidth = outlineWidth;
  10615. renderProjectiles(0, xOffset, yOffset);
  10616. // RENDER PLAYERS:
  10617. renderPlayers(xOffset, yOffset, 0);
  10618. // RENDER AI:
  10619. mainContext.globalAlpha = 1;
  10620. for (let i = 0; i < ais.length; ++i) {
  10621. tmpObj = ais[i];
  10622. if (tmpObj.active && tmpObj.visible) {
  10623. tmpObj.animate(delta);
  10624. mainContext.save();
  10625. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10626. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10627. renderAI(tmpObj, mainContext);
  10628. mainContext.restore();
  10629. }
  10630. }
  10631. // RENDER GRID:
  10632. if (getEl("gridsa").checked) {
  10633. mainContext.lineWidth = 3; // Nastavte ?i?ku ?ary podle pot?eby
  10634. mainContext.strokeStyle = "#000";
  10635. mainContext.globalAlpha = 0.05; // Nastavte pr?hlednost podle pot?eby
  10636. mainContext.beginPath();
  10637. let ratfrr = 60; // Nastavte podle pot?eby
  10638. for (var x = -xOffset % ratfrr; x < maxScreenWidth; x += ratfrr) {
  10639. if (x > 0) {
  10640. mainContext.moveTo(x, 0);
  10641. mainContext.lineTo(x, maxScreenHeight);
  10642. }
  10643. }
  10644. for (var y = -yOffset % ratfrr; y < maxScreenHeight; y += ratfrr) {
  10645. if (y > 0) {
  10646. mainContext.moveTo(0, y);
  10647. mainContext.lineTo(maxScreenWidth, y);
  10648. }
  10649. }
  10650. mainContext.stroke();
  10651. }
  10652. // RENDER GAME OBJECTS (LAYERED):
  10653. renderGameObjects(0, xOffset, yOffset);
  10654. renderProjectiles(1, xOffset, yOffset);
  10655. renderGameObjects(1, xOffset, yOffset);
  10656. renderPlayers(xOffset, yOffset, 1);
  10657. renderGameObjects(2, xOffset, yOffset);
  10658. renderGameObjects(3, xOffset, yOffset);
  10659. // MAP BOUNDARIES:
  10660. mainContext.fillStyle = "#000";
  10661. mainContext.globalAlpha = 0.2;
  10662. if (xOffset <= 0) {
  10663. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10664. } if (config.mapScale - xOffset <= maxScreenWidth) {
  10665. let tmpY = Math.max(0, -yOffset);
  10666. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10667. } if (yOffset <= 0) {
  10668. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10669. } if (config.mapScale - yOffset <= maxScreenHeight) {
  10670. let tmpX = Math.max(0, -xOffset);
  10671. let tmpMin = 0;
  10672. if (config.mapScale - xOffset <= maxScreenWidth)
  10673. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10674. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10675. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10676. }
  10677.  
  10678. // RENDER DAY/NIGHT TIME:
  10679. mainContext.globalAlpha = 1;
  10680. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  10681. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10682.  
  10683. // RENDER PLAYER AND AI UI:
  10684. mainContext.strokeStyle = darkOutlineColor;
  10685. mainContext.globalAlpha = 1;
  10686.  
  10687. for (let i = 0; i < players.length + ais.length; ++i) {
  10688. tmpObj = players[i] || ais[i - players.length];
  10689. if (tmpObj.visible) {
  10690. mainContext.strokeStyle = darkOutlineColor;
  10691. // NAME AND HEALTH:
  10692. if (tmpObj.skinIndex != 10 || (tmpObj == player) || (tmpObj.team && tmpObj.team == player.team)) {
  10693. let tmpText = "";
  10694. if (getEl("visualType").value == "simp1") {
  10695. tmpText = (tmpObj.team ? "/" + tmpObj.team + "/ " : "") + (tmpObj.name || "");
  10696. } else if (getEl("visualType").value == "simp2") {
  10697. tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + tmpObj.name + " {" + tmpObj.shameCount + "}";
  10698. }
  10699. if (tmpText != "") {
  10700. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10701. mainContext.textBaseline = "middle";
  10702. mainContext.textAlign = "center";
  10703. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10704. var tmpS = config.crownIconScale;
  10705. var tmpX = tmpObj.x - xOffset - (tmpS/2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10706. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10707. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10708. } if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10709. let tmpS = config.crownIconScale;
  10710. let tmpX = tmpObj.x - xOffset - (tmpS/2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10711. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10712. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10713. }
  10714. let nameColor;
  10715. if (tmpObj == player) {
  10716. nameColor = "#fff";
  10717. } else if (tmpObj.team && tmpObj.team == player.team) {
  10718. nameColor = "#fff";
  10719. } else {
  10720. nameColor = "#fff";
  10721. }
  10722. mainContext.fillStyle = nameColor;
  10723. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10724. mainContext.lineJoin = "round";
  10725. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10726. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10727.  
  10728. // HEALTH HOLDER:
  10729. mainContext.fillStyle = darkOutlineColor;
  10730. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10731. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10732. (config.healthBarPad * 2), 17, 8);
  10733. mainContext.fill();
  10734.  
  10735. // HEALTH BAR:
  10736. if (getEl("visualType").value == "simp2") {
  10737. mainContext.fillStyle = (tmpObj==player||(tmpObj.team&&tmpObj.team==player.team))? "#8ecc51" : "#cc5151";
  10738. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10739. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10740. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 20); // 20
  10741. mainContext.fill();
  10742. } else if (getEl("visualType").value == "simp1") {
  10743. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10744. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10745. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10746. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10747. mainContext.fill();
  10748. mainContext.font = "20px Hammersmith One";
  10749. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10750. mainContext.textBaseline = "middle";
  10751. mainContext.textAlign = "center";
  10752. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10753. mainContext.lineJoin = "round";
  10754. mainContext.strokeText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10755. mainContext.fillText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10756.  
  10757. mainContext.font = "14px Hammersmith One";
  10758. mainContext.fillStyle = "#FFFFFF";
  10759. mainContext.fillText("Sme: [" + tmpObj.shameCount + "]" + " / " + "Pac: [" + secPacket + "] ", tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 95);
  10760. }
  10761.  
  10762. if (tmpObj.isPlayer && tmpObj.sid === player.sid) {
  10763. mainContext.globalAlpha = 1;
  10764. mainContext.fillStyle = "rgba(143, 131, 104, 1)";
  10765.  
  10766. if(tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10767. mainContext.font = "20px Hammersmith One";
  10768. mainContext.strokeText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10769. mainContext.fillText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10770. } else {
  10771. }
  10772. if (tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10773. mainContext.globalAlpha = 1;
  10774. let targetReloads = {
  10775. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10776. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10777. turret: (2500 - tmpObj.reloads[53]) / 2500
  10778. };
  10779. if (!tmpObj.currentReloads) {
  10780. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10781. primary: targetReloads.primary,
  10782. secondary: targetReloads.secondary,
  10783. turret: targetReloads.turret
  10784. };
  10785. }
  10786. const lerpFactor = 0.3;
  10787. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10788. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10789. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10790.  
  10791. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10792. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10793. const centerX = tmpObj.x - xOffset;
  10794. const centerY = tmpObj.y - yOffset;
  10795. const barRadius = 35;
  10796. const barWidth = 15;
  10797. const totalAngle = (Math.PI*2)/3; // Half circle
  10798. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10799. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10800. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10801. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10802.  
  10803. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10804. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10805. function returncoolcolor(progress) {
  10806. const whiteValue = 255;
  10807. return `rgb(${whiteValue}, ${whiteValue}, ${whiteValue})`;
  10808. }
  10809.  
  10810.  
  10811. mainContext.save();
  10812. if (tmpObj.currentReloads.primary < 0.999) {
  10813. mainContext.beginPath();
  10814. mainContext.lineCap = 'round';
  10815. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10816. mainContext.lineWidth = 4;
  10817. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10818. mainContext.stroke();
  10819. }
  10820. if (tmpObj.currentReloads.secondary < 0.999) {
  10821. mainContext.beginPath();
  10822. mainContext.lineCap = 'round';
  10823. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10824. mainContext.lineWidth = 4;
  10825. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10826. mainContext.stroke();
  10827. }
  10828. if (tmpObj.currentReloads.turret < 0.999) {
  10829. mainContext.beginPath();
  10830. mainContext.lineCap = 'round';
  10831. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10832. mainContext.lineWidth = 4;
  10833. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10834. mainContext.stroke();
  10835. }
  10836. } else if (getEl("visualType").value == "simp2") {
  10837. }
  10838.  
  10839.  
  10840. if (tmpObj == player) {
  10841. if (getEl("predictType").value == "pre2") {
  10842. mainContext.lineWidth = 3;
  10843. mainContext.strokeStyle = "#fff";
  10844. mainContext.globalAlpha = 1;
  10845. mainContext.beginPath();
  10846. let render = {
  10847. x: tmpObj.x2 - xOffset,
  10848. y: tmpObj.y2 - yOffset
  10849. };
  10850. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10851. mainContext.lineTo(render.x, render.y);
  10852. mainContext.stroke();
  10853. } else if (getEl("predictType").value == "pre3") {
  10854. mainContext.lineWidth = 3;
  10855. mainContext.strokeStyle = "#cc5151";
  10856. mainContext.globalAlpha = 1;
  10857. mainContext.beginPath();
  10858. let render = {
  10859. x: tmpObj.x3 - xOffset,
  10860. y: tmpObj.y3 - yOffset
  10861. };
  10862. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10863. mainContext.lineTo(render.x, render.y);
  10864. mainContext.stroke();
  10865. }
  10866. }
  10867.  
  10868.  
  10869. // in here we skid ha thu mod ez(sowwie ha thu i love u <3):
  10870. if (tmpObj.isPlayer && near == tmpObj && enemy.length && rKeyPressed) {
  10871. let tmpS = tmpObj.scale * 2.2;
  10872. mainContext.drawImage(crossHairSprites, tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10873. }
  10874.  
  10875. }
  10876. }
  10877. }
  10878. }
  10879. }
  10880.  
  10881.  
  10882. // RENDER GAME OBJECTS:
  10883. function renderGameObjects(layer, xOffset, yOffset) {
  10884. let tmpSprite;
  10885. let tmpX;
  10886. let tmpY;
  10887. gameObjects.forEach((tmp) => {
  10888. tmpObj = tmp;
  10889. if (tmpObj.alive) {
  10890. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  10891. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  10892. if (layer == 0) {
  10893. tmpObj.update(delta);
  10894. }
  10895. mainContext.globalAlpha = tmpObj.alpha;
  10896. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  10897. if (tmpObj.isItem) {
  10898. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  10899. tmpSprite = getObjSprite(tmpObj);
  10900. } else {
  10901. tmpSprite = getItemSprite(tmpObj);
  10902. }
  10903. mainContext.save();
  10904. mainContext.translate(tmpX, tmpY);
  10905. mainContext.rotate(tmpObj.dir);
  10906. if (!tmpObj.active) {
  10907. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  10908. }
  10909. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  10910. if (tmpObj.blocker) {
  10911. mainContext.strokeStyle = "#db6e6e";
  10912. mainContext.globalAlpha = 0.3;
  10913. mainContext.lineWidth = 6;
  10914. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  10915. }
  10916. mainContext.restore();
  10917. } else {
  10918. tmpSprite = getResSprite(tmpObj);
  10919. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  10920. }
  10921. }
  10922. document.minis = .1;
  10923. document.bigis = 2.95;
  10924. if (getEl("bh").value == 1) {
  10925. if (layer == 3) {
  10926. if (tmpObj.health < tmpObj.maxHealth) {
  10927. const normalScale = tmpObj.scale / 2;
  10928. const normalGap = normalScale * 2 * document.minis;
  10929. const normalStart = normalScale / circleScale;
  10930. const Filler = (2 * Math.PI) / (tmpObj.maxHealth / tmpObj.healthMov);
  10931. mainContext.save();
  10932. mainContext.beginPath();
  10933. mainContext.lineCap = 'round';
  10934. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  10935. mainContext.lineWidth = normalGap * document.bigis;
  10936. mainContext.strokeStyle = darkOutlineColor;
  10937. mainContext.stroke();
  10938. mainContext.beginPath();
  10939. mainContext.lineCap = 'round';
  10940. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  10941. mainContext.lineWidth = 7;
  10942. mainContext.strokeStyle = tmpObj.isTeamObject(player) ? myObjectHealth : enemyObjectHealth;
  10943. mainContext.stroke();
  10944. mainContext.closePath();
  10945. mainContext.restore();
  10946.  
  10947. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#fff" : "#F05C5B";
  10948. mainContext.textBaseline = "middle";
  10949. mainContext.textAlign = "center";
  10950. mainContext.lineWidth = 0;
  10951. mainContext.lineJoin = "round";
  10952.  
  10953. mainContext.strokeStyle = darkOutlineColor;
  10954. mainContext.lineWidth = 5;
  10955.  
  10956. const fontSize = 18;
  10957. mainContext.font = `${fontSize}px Hammersmith One`;
  10958.  
  10959. mainContext.strokeText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  10960. mainContext.fillText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  10961. }
  10962. }
  10963. } else if (getEl("bh").value == "2") {
  10964. if (tmpObj.health < tmpObj.maxHealth) {
  10965. mainContext.fillStyle = darkOutlineColor;
  10966. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  10967. mainContext.fill();
  10968. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  10969. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  10970. mainContext.fill();
  10971. }
  10972. } else {
  10973. }
  10974. }
  10975. });
  10976.  
  10977.  
  10978. mainContext.restore();
  10979. // PLACE VISIBLE:
  10980. if (layer == 0) {
  10981. if (placeVisible.length) {
  10982. placeVisible.forEach((places) => {
  10983. tmpX = places.x - xOffset;
  10984. tmpY = places.y - yOffset;
  10985. if (getEl("renderplace").value == "placeVis") {
  10986. markObject(places, tmpX, tmpY);
  10987. }
  10988. if (getEl("renderplace").value == "outline") {
  10989. markObject2(places, tmpX, tmpY);
  10990. }
  10991. });
  10992.  
  10993.  
  10994.  
  10995. if (preplaceVisible.length) {
  10996. preplaceVisible.forEach((places) => {
  10997. tmpX = places.x - xOffset;
  10998. tmpY = places.y - yOffset;
  10999. ppmarkObject(places, tmpX, tmpY);
  11000. });
  11001. }
  11002. }
  11003. }
  11004. }
  11005. function markObject(tmpObj, tmpX, tmpY) {
  11006.  
  11007. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  11008. }
  11009. function markObject2(tmpObj, tmpX, tmpY) {
  11010. getMarkSprite2(tmpObj, mainContext, tmpX, tmpY);
  11011. }
  11012. function ppmarkObject(tmpObj, tmpX, tmpY) {
  11013. ppyen(mainContext, tmpX, tmpY);
  11014. }
  11015. function ppyen(context, x, y) {
  11016. context.fillStyle = "rgba(255, 0, 0, 0.2)";
  11017. context.beginPath();
  11018. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  11019. context.fill();
  11020. context.closePath();
  11021. context.globalAlpha = 1;
  11022. }
  11023. function yen(context, x, y) {
  11024. context.fillStyle = "rgba(0, 255, 255, 0.6)";
  11025. context.beginPath();
  11026. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  11027. context.fill();
  11028. context.closePath();
  11029. context.globalAlpha = 1;
  11030. }
  11031.  
  11032. function drawArrow(xOffset, yOffset, x, y, arrowWidth, color, angle, lineWidth) {
  11033. mainContext.save()
  11034. mainContext.translate(x - xOffset, y - yOffset)
  11035. mainContext.rotate(Math.PI / 4)
  11036. mainContext.rotate(angle)
  11037. mainContext.globalAlpha = 1
  11038. mainContext.strokeStyle = color
  11039. mainContext.lineCap = "round"
  11040. mainContext.lineWidth = lineWidth
  11041. mainContext.beginPath()
  11042. mainContext.moveTo(-arrowWidth, -arrowWidth)
  11043. mainContext.lineTo(arrowWidth, -arrowWidth)
  11044. mainContext.lineTo(arrowWidth, arrowWidth)
  11045. mainContext.stroke()
  11046. mainContext.closePath()
  11047. mainContext.restore()
  11048. }
  11049. if (player) {
  11050. // AUTOPUSH LINE:
  11051. if (my.autoPush) {
  11052. mainContext.lineWidth = 5;
  11053. mainContext.globalAlpha = 1;
  11054. mainContext.beginPath();
  11055.  
  11056.  
  11057. mainContext.strokeStyle = "black";
  11058. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  11059. mainContext.lineTo(my.pushData.x2 - xOffset, my.pushData.y2 - yOffset);
  11060. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  11061. mainContext.stroke();
  11062. }
  11063. }
  11064. mainContext.globalAlpha = 1;
  11065.  
  11066. // RENDER ANIM TEXTS:
  11067. textManager.update(delta, mainContext, xOffset, yOffset);
  11068. // RENDER CHAT MESSAGES:
  11069. for (let i = 0; i < players.length; ++i) {
  11070. tmpObj = players[i];
  11071. if (tmpObj.visible) {
  11072. if (tmpObj.chatCountdown > 0) {
  11073. tmpObj.chatCountdown -= delta;
  11074. if (tmpObj.chatCountdown <= 0)
  11075. tmpObj.chatCountdown = 0;
  11076. mainContext.font = "32px Hammersmith One";
  11077. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11078. mainContext.textBaseline = "middle";
  11079. mainContext.textAlign = "center";
  11080. let tmpX = tmpObj.x - xOffset;
  11081. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11082. let tmpH = 47;
  11083. let tmpW = tmpSize.width + 17;
  11084. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11085. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11086. mainContext.fill();
  11087. mainContext.fillStyle = "#fff";
  11088. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11089. }
  11090. if (tmpObj.chat.count > 0) {
  11091. tmpObj.chat.count -= delta;
  11092. if (tmpObj.chat.count <= 0)
  11093. tmpObj.chat.count = 0;
  11094. mainContext.font = "32px Hammersmith One";
  11095. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11096. mainContext.textBaseline = "middle";
  11097. mainContext.textAlign = "center";
  11098. let tmpX = tmpObj.x - xOffset;
  11099. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11100. let tmpH = 47;
  11101. let tmpW = tmpSize.width + 17;
  11102. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11103. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11104. mainContext.fill();
  11105. mainContext.fillStyle = "#ffffff99";
  11106. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11107. }
  11108. }
  11109. }
  11110. if (allChats.length) {
  11111. allChats.filter(ch => ch.active).forEach((ch) => {
  11112. if (!ch.alive) {
  11113. if (ch.alpha <= 1) {
  11114. ch.alpha += delta / 250;
  11115. if (ch.alpha >= 1) {
  11116. ch.alpha = 1;
  11117. ch.alive = true;
  11118. }
  11119. }
  11120. } else {
  11121. ch.alpha -= delta / 5000;
  11122. if (ch.alpha <= 0) {
  11123. ch.alpha = 0;
  11124. ch.active = false;
  11125. }
  11126. }
  11127. if (ch.active) {
  11128. mainContext.font = "20px Hammersmith One";
  11129. let tmpSize = mainContext.measureText(ch.chat);
  11130. mainContext.textBaseline = "middle";
  11131. mainContext.textAlign = "center";
  11132. let tmpX = ch.owner.x - xOffset;
  11133. let tmpY = ch.owner.y - ch.owner.scale - yOffset - 90;
  11134. let tmpH = 47;
  11135. let tmpW = tmpSize.width + 17;
  11136. mainContext.globalAlpha = ch.alpha;
  11137. mainContext.fillStyle = ch.owner.isTeam(player) ? "rgba(255,215,0,1)" : "#cc5151";
  11138. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11139. mainContext.lineWidth = 5;
  11140. mainContext.fillStyle = "rgba(0,0,0,0.4)";
  11141. mainContext.strokeStyle = "rgba(0,0,0,0.0)";
  11142. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11143. mainContext.stroke();
  11144. mainContext.fill();
  11145. mainContext.fillStyle = "#fff";
  11146. mainContext.strokeStyle = "#000";
  11147. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11148. mainContext.fillText(ch.chat, tmpX, tmpY);
  11149. ch.y -= delta / 100;
  11150. }
  11151. });
  11152. }
  11153. }
  11154. mainContext.globalAlpha = 1;
  11155. // RENDER MINIMAP:
  11156. renderMinimap(delta);
  11157. }
  11158. // UPDATE & ANIMATE:
  11159. window.requestAnimFrame = function() {
  11160. return null;
  11161. }
  11162. window.rAF = (function() {
  11163. return window.requestAnimationFrame ||
  11164. window.webkitRequestAnimationFrame ||
  11165. window.mozRequestAnimationFrame ||
  11166. function(callback) {
  11167. window.setTimeout(callback, 1000 / 240);
  11168. };
  11169. })();
  11170. function doUpdate() {
  11171. now = performance.now();
  11172. delta = now - lastUpdate;
  11173. lastUpdate = now;
  11174. let timer = performance.now();
  11175. let diff = timer - fpsTimer.last;
  11176. if (diff >= 1000) {
  11177. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11178. fpsTimer.last = timer;
  11179. fpsTimer.time = 0;
  11180. }
  11181. fpsTimer.time++;
  11182. getEl("pingFps").innerHTML = `${window.pingTime}ms | FPS: ${UTILS.round(fpsTimer.ltime, 10)}`;
  11183. getEl("packetStatus").innerHTML = secPacket;
  11184. updateGame();
  11185. rAF(doUpdate);
  11186. }
  11187. prepareMenuBackground();
  11188. doUpdate();
  11189. let changeDays = {};
  11190. window.debug = function() {
  11191. my.waitHit = 0;
  11192. my.autoAim = false;
  11193. instaC.isTrue = false;
  11194. traps.inTrap = false;
  11195. itemSprites = [];
  11196. objSprites = [];
  11197. gameObjectSprites = [];
  11198. };
  11199. window.toggleNight = function() {
  11200. isNight = !isNight;
  11201. itemSprites = [];
  11202. objSprites = [];
  11203. gameObjectSprites = [];
  11204. };
  11205. window.startGrind = function() {
  11206. if (getEl("weaponGrind").checked) {
  11207. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11208. checkPlace(player.getItemType(22), i);
  11209. }
  11210. }
  11211. };
  11212. // REMOVED!!! so they cant abuse :)
  11213. let projects = [];
  11214. let botIDS = 0;
  11215. window.connectFillBots = function() {
  11216. botSkts = [];
  11217. botIDS = 0;
  11218. for (let i = 0; i < projects.length; i++) {
  11219. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11220. test.binaryType = "arraybuffer";
  11221. test.onopen = function() {
  11222. test.ssend = function(type) {
  11223. let data = Array.prototype.slice.call(arguments, 1);
  11224. let binary = window.msgpack.encode([type, data]);
  11225. test.send(binary);
  11226. };
  11227. for (let i = 0; i < 4; i++) {
  11228. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  11229. action: "homepage"
  11230. }).then(function(token) {
  11231. test.ssend("bots", WS.url.split("&")[0] + "&token=" + encodeURIComponent(token), botIDS);
  11232. botSkts.push([test]);
  11233. botIDS++;
  11234. });
  11235. }
  11236. };
  11237. test.onmessage = function(message) {
  11238. let data = new Uint8Array(message.data);
  11239. let parsed = window.msgpack.decode(data);
  11240. let type = parsed[0];
  11241. data = parsed[1];
  11242. };
  11243. }
  11244. };
  11245. window.destroyFillBots = function() {
  11246. botSkts.forEach((socket) => {
  11247. socket[0].close();
  11248. });
  11249. botSkts = [];
  11250. };
  11251. window.tryConnectBots = function() {
  11252. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  11253. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  11254. action: "homepage"
  11255. }).then(function(token) {
  11256. // CONNECT SOCKET:
  11257. botSpawn(token);
  11258. });
  11259. }
  11260. };
  11261. window.destroyBots = function() {
  11262. bots.forEach((botyyyyy) => {
  11263. botyyyyy.closeSocket = true;
  11264. });
  11265. bots = [];
  11266. };
  11267. window.resBuild = function() {
  11268. if (gameObjects.length) {
  11269. gameObjects.forEach((tmp) => {
  11270. tmp.breakObj = false;
  11271. });
  11272. breakObjects = [];
  11273. }
  11274. };
  11275. window.toggleBotsCircle = function() {
  11276. player.circle = !player.circle;
  11277. };
  11278. window.prepareUI = function(tmpObj) {
  11279. resize();
  11280. // ACTION BAR:
  11281. UTILS.removeAllChildren(actionBar);
  11282. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11283. (function(i) {
  11284. UTILS.generateElement({
  11285. id: "actionBarItem" + i,
  11286. class: "actionBarItem",
  11287. style: "display:none",
  11288. onmouseout: function() {
  11289. showItemInfo();
  11290. },
  11291. parent: actionBar
  11292. });
  11293. })(i);
  11294. }
  11295. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11296. (function(i) {
  11297. let tmpCanvas = document.createElement("canvas");
  11298. tmpCanvas.width = tmpCanvas.height = 66;
  11299. let tmpContext = tmpCanvas.getContext("2d");
  11300. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11301. tmpContext.imageSmoothingEnabled = false;
  11302. tmpContext.webkitImageSmoothingEnabled = false;
  11303. tmpContext.mozImageSmoothingEnabled = false;
  11304. if (items.weapons[i]) {
  11305. tmpContext.rotate((Math.PI / 4) + Math.PI);
  11306. let tmpSprite = new Image();
  11307. toolSprites[items.weapons[i].src] = tmpSprite;
  11308. tmpSprite.onload = function() {
  11309. this.isLoaded = true;
  11310. let tmpPad = 1 / (this.height / this.width);
  11311. let tmpMlt = (items.weapons[i].iPad || 1);
  11312. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11313. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11314. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11315. tmpContext.globalCompositeOperation = "source-atop";
  11316. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11317. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11318. };
  11319. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11320. let tmpUnit = getEl('actionBarItem' + i);
  11321. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  11322. showItemInfo(items.weapons[i], true);
  11323. });
  11324. tmpUnit.onclick = UTILS.checkTrusted(function() {
  11325. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11326. });
  11327. UTILS.hookTouchEvents(tmpUnit);
  11328. } else {
  11329. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11330. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11331. tmpContext.globalAlpha = 1;
  11332. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11333. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11334. tmpContext.globalCompositeOperation = "source-atop";
  11335. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11336. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11337. let tmpUnit = getEl('actionBarItem' + i);
  11338. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  11339. showItemInfo(items.list[i - items.weapons.length]);
  11340. });
  11341. tmpUnit.onclick = UTILS.checkTrusted(function() {
  11342. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11343. });
  11344. UTILS.hookTouchEvents(tmpUnit);
  11345. }
  11346. })(i);
  11347. }
  11348. };
  11349. window.toggleNight();
  11350. (function() {
  11351. 'use strict';
  11352.  
  11353. const CORRECT_USERNAME = "wat";
  11354. const CORRECT_PASSWORD = "unrealmodop";
  11355. const CORRECT_KEY = "likesync?";
  11356. const CORRECT_TOKEN = "faxsmate";
  11357.  
  11358. let snowfallInterval;
  11359. let snowflakesEnabled = true;
  11360.  
  11361. function createSnowflake() {
  11362. if (!snowflakesEnabled) return;
  11363.  
  11364. const snowflake = document.createElement('div');
  11365. snowflake.className = 'snowflake';
  11366. snowflake.style.position = 'absolute';
  11367. snowflake.style.top = '-10px';
  11368. snowflake.style.left = Math.random() * window.innerWidth + 'px';
  11369. snowflake.style.opacity = Math.random();
  11370. snowflake.style.fontSize = (Math.random() * 20 + 10) + 'px';
  11371. snowflake.innerHTML = '❄';
  11372. snowflake.style.color = 'white';
  11373. document.body.appendChild(snowflake);
  11374.  
  11375. const animationDuration = Math.random() * 5 + 5;
  11376. snowflake.style.animation = `fall ${animationDuration}s linear`;
  11377.  
  11378. setTimeout(() => {
  11379. document.body.removeChild(snowflake);
  11380. }, animationDuration * 1000);
  11381. }
  11382.  
  11383. function createSnowfall() {
  11384. snowfallInterval = setInterval(createSnowflake, 100);
  11385. }
  11386.  
  11387. function createToggleMenu() {
  11388. const menu = document.createElement('div');
  11389. menu.style.position = 'fixed';
  11390. menu.style.top = '10px';
  11391. menu.style.right = '10px';
  11392. menu.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  11393. menu.style.padding = '10px';
  11394. menu.style.borderRadius = '5px';
  11395. menu.style.zIndex = '10000';
  11396.  
  11397. const toggle = document.createElement('label');
  11398. toggle.style.display = 'flex';
  11399. toggle.style.alignItems = 'center';
  11400. toggle.style.color = 'white';
  11401.  
  11402. const checkbox = document.createElement('input');
  11403. checkbox.type = 'checkbox';
  11404. checkbox.checked = snowflakesEnabled;
  11405. checkbox.style.marginRight = '5px';
  11406.  
  11407. checkbox.addEventListener('change', function() {
  11408. snowflakesEnabled = this.checked;
  11409. if (snowflakesEnabled) {
  11410. createSnowfall();
  11411. } else {
  11412. clearInterval(snowfallInterval);
  11413. }
  11414. });
  11415.  
  11416. toggle.appendChild(checkbox);
  11417. toggle.appendChild(document.createTextNode('Snowflakes'));
  11418.  
  11419. menu.appendChild(toggle);
  11420. document.body.appendChild(menu);
  11421. }
  11422.  
  11423. function createOverlay() {
  11424. const overlay = document.createElement("div");
  11425. overlay.style.position = "fixed";
  11426. overlay.style.top = "0";
  11427. overlay.style.left = "0";
  11428. overlay.style.width = "100%";
  11429. overlay.style.height = "100%";
  11430. overlay.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
  11431. overlay.style.display = "flex";
  11432. overlay.style.alignItems = "center";
  11433. overlay.style.justifyContent = "center";
  11434. overlay.style.zIndex = "9999";
  11435.  
  11436. const box = document.createElement("div");
  11437. box.style.padding = "40px";
  11438. box.style.borderRadius = "10px";
  11439. box.style.backgroundColor = "black";
  11440. box.style.boxShadow = "0 0 20px rgba(128, 0, 128, 0.5)";
  11441. box.style.textAlign = "center";
  11442. box.style.color = "white";
  11443.  
  11444. const inputs = ['username', 'password', 'key', 'token'].map(type => {
  11445. const input = document.createElement("input");
  11446. input.type = type === 'password' ? 'password' : 'text';
  11447. input.placeholder = type.charAt(0).toUpperCase() + type.slice(1);
  11448. input.style.display = "block";
  11449. input.style.margin = "10px auto";
  11450. input.style.padding = "10px";
  11451. input.style.width = "200px";
  11452. return input;
  11453. });
  11454.  
  11455. const submitButton = document.createElement("button");
  11456. submitButton.innerText = "Submit";
  11457. submitButton.style.padding = "10px 20px";
  11458. submitButton.style.marginTop = "20px";
  11459.  
  11460. inputs.forEach(input => box.appendChild(input));
  11461. box.appendChild(submitButton);
  11462. overlay.appendChild(box);
  11463.  
  11464. submitButton.addEventListener("click", function() {
  11465. const [username, password, key, token] = inputs.map(input => input.value);
  11466.  
  11467. if (username === CORRECT_USERNAME &&
  11468. password === CORRECT_PASSWORD &&
  11469. key === CORRECT_KEY &&
  11470. token === CORRECT_TOKEN) {
  11471. document.body.removeChild(overlay);
  11472. } else {
  11473. alert("Incorrect credentials. Refreshing...");
  11474. location.reload();
  11475. }
  11476. });
  11477.  
  11478. document.body.appendChild(overlay);
  11479. }
  11480.  
  11481. // Add snowfall animation
  11482. const style = document.createElement('style');
  11483. style.textContent = `
  11484. @keyframes fall {
  11485. to {
  11486. transform: translateY(100vh);
  11487. }
  11488. }
  11489. `;
  11490. document.head.appendChild(style);
  11491.  
  11492. createOverlay();
  11493. createSnowfall();
  11494. createToggleMenu();
  11495. })();
  11496.  
  11497.