Unreal? mod v2

Ong this mod so op it kell all server

  1. // ==UserScript==
  2. // @name Unreal? mod v2
  3. // @author wat
  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. html.newLine();
  895. html.button({ class: "menuB", innerHTML: "Connect FBots", onclick: "window.connectFillBots()" });
  896. html.button({ class: "menuB", innerHTML: "Disconnect FBots", onclick: "window.destroyFillBots()" });
  897. html.newLine();
  898. html.button({ class: "menuB", innerHTML: "Reset Break Objects", onclick: "window.resBuild()" });
  899. html.newLine();
  900. html.add(`Break Objects Range: `);
  901. html.text({ id: "breakRange", class: "customText", value: "700", size: "3em", maxLength: "4" });
  902. html.newLine();
  903. html.add(`Predict Movement Type: `);
  904.  
  905. html.newLine(2);
  906. html.button({ class: "menuB", innerHTML: "Toggle Fbots Circle", onclick: "window.toggleBotsCircle()" });
  907. html.newLine();
  908. html.add(`Circle Rad: `);
  909. html.text({ id: "circleRad", class: "customText", value: "200", size: "3em", maxLength: "4" });
  910. html.newLine();
  911. html.add(`Rad Speed: `);
  912. html.text({ id: "radSpeed", class: "customText", value: "0.1", size: "2em", maxLength: "3" });
  913. html.newLine(2);
  914. html.add(`Cross World: `);
  915. html.checkBox({ id: "funni", class: "checkB" });
  916. html.newLine();
  917. html.button({ class: "menuB", innerHTML: "Toggle Another Visual", onclick: "window.toggleVisual()" });
  918. html.newLine();
  919. });
  920. });
  921. let menuChatDiv = document.createElement("div");
  922. menuChatDiv.id = "menuChatDiv";
  923. document.body.appendChild(menuChatDiv);
  924. HTML.set("menuChatDiv");
  925. HTML.setStyle(`
  926. position: absolute;
  927. display: none;
  928. left: 0px;
  929. top: 0px;
  930. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0); //0.65
  931. `);
  932. HTML.resetHTML();
  933. HTML.setCSS(`
  934. .chDiv{
  935. color: #fff;
  936. padding: 10px;
  937. width: 400px;
  938. height: 250px;
  939. background-color: rgba(0, 0, 0, 0); //0.35
  940. }
  941. .chMainDiv{
  942. font-family: "Ubuntu";
  943. font-size: 16px;
  944. max-height: 215px;
  945. -webkit-touch-callout: none;
  946. -webkit-user-select: none;
  947. -khtml-user-select: none;
  948. -moz-user-select: none;
  949. -ms-user-select: none;
  950. user-select: none;
  951. overflow-x: hidden;
  952. }
  953. .chMainBox{
  954. position: absolute;
  955. left: 10px;
  956. bottom: 10px;
  957. width: 335px;
  958. height: 25px;
  959. background-color: rgba(255, 255, 255, 0);
  960. -webkit-border-radius: 4px;
  961. -moz-border-radius: 4px;
  962. border-radius: 4px;
  963. color: rgba(255, 255, 255, 0);
  964. font-family: "Arial";
  965. font-size: 12px;
  966. border: none;
  967. outline: none;
  968. }
  969. `);
  970. HTML.startDiv({id: "mChDiv", class: "chDiv"}, (html) => {
  971. HTML.addDiv({id: "mChMain", class: "chMainDiv", appendID: "mChDiv"}, (html) => {
  972. });
  973. html.text({id: "mChBox", class: "chMainBox", placeHolder: ``});
  974. });
  975. let menuChats = getEl("mChMain");
  976. let menuChatBox = getEl("mChBox");
  977. let menuCBFocus = false;
  978. let menuChCounts = 0;
  979.  
  980. function addChatLog(e, c, d, v) {
  981. HTML.set("menuChatDiv");
  982. let chatLogs = document.getElementById("mChMain");
  983. const now = new Date();
  984. const hours = now.getHours();
  985. const minutes = now.getMinutes();
  986. const ampm = hours >= 12 ? 'PM' : 'AM';
  987. const formattedHours = (hours % 12 || 12).toString();
  988. const formattedMinutes = minutes.toString().padStart(2, '0');
  989. let time = `${formattedHours}:${formattedMinutes} ${ampm}`;
  990.  
  991. let a = document.createElement('div');
  992. a.className = 'chatEntry';
  993.  
  994. let timeSpan = document.createElement('span');
  995. timeSpan.style.color = 'rgba(255, 255, 255, 0.5)';
  996. timeSpan.innerText = `${time}`;
  997. a.appendChild(timeSpan);
  998.  
  999. let namething = document.createElement('span');
  1000. namething.style.color = v;
  1001. namething.innerText = ' ' + d;
  1002. a.appendChild(namething);
  1003.  
  1004. let chatSpan = document.createElement('span');
  1005. chatSpan.style.color = c;
  1006. chatSpan.innerText = ' ' + e;
  1007. a.appendChild(chatSpan);
  1008.  
  1009. chatLogs.appendChild(a);
  1010. chatLogs.scrollTop = chatLogs.scrollHeight;
  1011. }
  1012. let menuIndex = 0;
  1013. let menus = ["menuMain", "menuConfig", "menuOther"];
  1014. window.changeMenu = function() {
  1015. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1016. menuIndex++;
  1017. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1018. };
  1019. let mStatus = document.createElement("div");
  1020. mStatus.id = "status";
  1021. getEl("gameUI").appendChild(mStatus);
  1022. HTML.set("status");
  1023. HTML.setStyle(`
  1024. display: block;
  1025. position: absolute;
  1026. color: #ddd;
  1027. font: 15px Hammersmith One;
  1028. bottom: 215px;
  1029. left: 20px;
  1030. `);
  1031. HTML.resetHTML();
  1032. HTML.setCSS(`
  1033. .sizing {
  1034. font-size: 15px;
  1035. }
  1036. .mod {
  1037. font-size: 15px;
  1038. display: inline-block;
  1039. }
  1040. `);
  1041. HTML.startDiv({ id: "uehmod", class: "sizing" }, (html) => {
  1042. html.add(`Ping: `);
  1043. HTML.addDiv({ id: "pingFps", class: "mod", appendID: "uehmod" }, (html) => {
  1044. html.add("None");
  1045. });
  1046. html.newLine();
  1047. html.add(`Packet: `);
  1048. HTML.addDiv({ id: "packetStatus", class: "mod", appendID: "uehmod" }, (html) => {
  1049. html.add("None");
  1050. });
  1051. });
  1052. let openMenu = false;
  1053. let WS = undefined;
  1054. let socketID = undefined;
  1055. let secPacket = 0;
  1056. let secMax = 110;
  1057. let secTime = 1000;
  1058. let firstSend = {
  1059. sec: false
  1060. };
  1061. let game = {
  1062. tick: 0,
  1063. tickQueue: [],
  1064. tickBase: function(set, tick) {
  1065. if (this.tickQueue[this.tick + tick]) {
  1066. this.tickQueue[this.tick + tick].push(set);
  1067. } else {
  1068. this.tickQueue[this.tick + tick] = [set];
  1069. }
  1070. },
  1071. tickRate: (1000 / config.serverUpdateRate),
  1072. tickSpeed: 0,
  1073. lastTick: performance.now()
  1074. };
  1075. let modConsole = [];
  1076. let dontSend = false;
  1077. let fpsTimer = {
  1078. last: 0,
  1079. time: 0,
  1080. ltime: 0
  1081. }
  1082. let lastMoveDir = undefined;
  1083. let lastsp = ["cc", 1, "__proto__"];
  1084. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1085. WebSocket.prototype.send = function(message) {
  1086. if (!WS) {
  1087. WS = this;
  1088. WS.addEventListener("message", function(msg) {
  1089. getMessage(msg);
  1090. });
  1091. WS.addEventListener("close", (event) => {
  1092. if (event.code == 4001) {
  1093. window.location.reload();
  1094. }
  1095. });
  1096. }
  1097. if (WS == this) {
  1098. dontSend = false;
  1099. // EXTRACT DATA ARRAY:
  1100. let data = new Uint8Array(message);
  1101. let parsed = window.msgpack.decode(data);
  1102. let type = parsed[0];
  1103. data = parsed[1];
  1104. // SEND MESSAGE:
  1105. if (type == "6") {
  1106. if (data[0]) {
  1107. 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"];
  1108. let tmpString;
  1109. profanity.forEach((profany) => {
  1110. if (data[0].indexOf(profany) > -1) {
  1111. tmpString = "";
  1112. for (let i = 0; i < profany.length; ++i) {
  1113. if (i == 1) {
  1114. tmpString += String.fromCharCode(0);
  1115. }
  1116. tmpString += profany[i];
  1117. }
  1118. let re = new RegExp(profany, "g");
  1119. data[0] = data[0].replace(re, tmpString);
  1120. }
  1121. });
  1122. data[0] = data[0].slice(0, 30);
  1123. }
  1124. } else if (type == "L") {
  1125. // MAKE SAME CLAN:
  1126. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1127. data[0] = data[0].slice(0, 7);
  1128. } else if (type == "M") {
  1129. // APPLY CYAN COLOR:
  1130. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1131. data[0].moofoll = true;
  1132. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1133. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1134. } else if (type == "D") {
  1135. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1136. dontSend = true;
  1137. } else {
  1138. my.lastDir = data[0];
  1139. }
  1140. } else if (type == "d") {
  1141. if (!data[2]) {
  1142. dontSend = true;
  1143. } else {
  1144. if (![null, undefined].includes(data[1])) {
  1145. my.lastDir = data[1];
  1146. }
  1147. }
  1148. } else if (type == "K") {
  1149. if (!data[1]) {
  1150. dontSend = true;
  1151. }
  1152. } else if (type == "14") {
  1153. instaC.wait = !instaC.wait;
  1154. dontSend = true;
  1155. } else if (type == "a") {
  1156. if (data[1]) {
  1157. if (player.moveDir == data[0]) {
  1158. dontSend = true;
  1159. }
  1160. player.moveDir = data[0];
  1161. } else {
  1162. dontSend = true;
  1163. }
  1164. }
  1165. if (!dontSend) {
  1166. let binary = window.msgpack.encode([type, data]);
  1167. this.nsend(binary);
  1168. // START COUNT:
  1169. if (!firstSend.sec) {
  1170. firstSend.sec = true;
  1171. setTimeout(() => {
  1172. firstSend.sec = false;
  1173. secPacket = 0;
  1174. }, secTime);
  1175. }
  1176. secPacket++;
  1177. }
  1178. } else {
  1179. this.nsend(message);
  1180. }
  1181. }
  1182. function packet(type) {
  1183. // EXTRACT DATA ARRAY:
  1184. let data = Array.prototype.slice.call(arguments, 1);
  1185. // SEND MESSAGE:
  1186. let binary = window.msgpack.encode([type, data]);
  1187. WS.send(binary);
  1188. }
  1189. function getMessage(message) {
  1190. let data = new Uint8Array(message.data);
  1191. let parsed = window.msgpack.decode(data);
  1192. let type = parsed[0];
  1193. data = parsed[1];
  1194. let events = {
  1195. A: setInitData,
  1196. //B: disconnect,
  1197. C: setupGame,
  1198. D: addPlayer,
  1199. E: removePlayer,
  1200. a: updatePlayers,
  1201. G: updateLeaderboard,
  1202. H: loadGameObject,
  1203. I: loadAI,
  1204. J: animateAI,
  1205. K: gatherAnimation,
  1206. L: wiggleGameObject,
  1207. M: shootTurret,
  1208. N: updatePlayerValue,
  1209. O: updateHealth,
  1210. P: killPlayer,
  1211. Q: killObject,
  1212. R: killObjects,
  1213. S: updateItemCounts,
  1214. T: updateAge,
  1215. U: updateUpgrades,
  1216. V: updateItems,
  1217. X: addProjectile,
  1218. Y: remProjectile,
  1219. //Z: serverShutdownNotice,
  1220. //0: addAlliance,
  1221. //1: deleteAlliance,
  1222. 2: allianceNotification,
  1223. 3: setPlayerTeam,
  1224. 4: setAlliancePlayers,
  1225. 5: updateStoreItems,
  1226. 6: receiveChat,
  1227. 7: updateMinimap,
  1228. 8: showText,
  1229. 9: pingMap,
  1230. //0: pingSocketResponse,
  1231. };
  1232. if (type == "io-init") {
  1233. socketID = data[0];
  1234. } else {
  1235. if (events[type]) {
  1236. events[type].apply(undefined, data);
  1237. }
  1238. }
  1239. }
  1240. // MATHS:
  1241. Math.lerpAngle = function(value1, value2, amount) {
  1242. let difference = Math.abs(value2 - value1);
  1243. if (difference > Math.PI) {
  1244. if (value1 > value2) {
  1245. value2 += Math.PI * 2;
  1246. } else {
  1247. value1 += Math.PI * 2;
  1248. }
  1249. }
  1250. let value = value2 + ((value1 - value2) * amount);
  1251. if (value >= 0 && value <= Math.PI * 2) return value;
  1252. return value % (Math.PI * 2);
  1253. };
  1254. // REOUNDED RECTANGLE:
  1255. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1256. if (w < 2 * r) r = w / 2;
  1257. if (h < 2 * r) r = h / 2;
  1258. if (r < 0)
  1259. r = 0;
  1260. this.beginPath();
  1261. this.moveTo(x + r, y);
  1262. this.arcTo(x + w, y, x + w, y + h, r);
  1263. this.arcTo(x + w, y + h, x, y + h, r);
  1264. this.arcTo(x, y + h, x, y, r);
  1265. this.arcTo(x, y, x + w, y, r);
  1266. this.closePath();
  1267. return this;
  1268. };
  1269. // GLOBAL VALUES:
  1270. let allChats = [];
  1271. let ais = [];
  1272. let inWater = false
  1273. let players = [];
  1274. let alliances = [];
  1275. let alliancePlayers = [];
  1276. let allianceNotifications = [];
  1277. let gameObjects = [];
  1278. let projectiles = [];
  1279. let deadPlayers = [];
  1280. let breakObjects = [];
  1281. let player;
  1282. let playerSID;
  1283. let tmpObj;
  1284. let enemy = [];
  1285. //let perfectReplace = [];
  1286. let nears = [];
  1287. let near = [];
  1288. let rKeyPressed = false
  1289. let my = {
  1290. reloaded: false,
  1291. waitHit: 0,
  1292. autoAim: false,
  1293. revAim: false,
  1294. ageInsta: true,
  1295. reSync: false,
  1296. bullTick: 0,
  1297. anti0Tick: 0,
  1298. antiSync: false,
  1299. safePrimary: function(tmpObj) {
  1300. return [0, 8].includes(tmpObj.primaryIndex);
  1301. },
  1302. safeSecondary: function(tmpObj) {
  1303. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1304. },
  1305. lastDir: 0,
  1306. autoPush: false,
  1307. pushData: {}
  1308. }
  1309. // FIND OBJECTS BY ID/SID:
  1310. function findID(tmpObj, tmp) {
  1311. return tmpObj.find((THIS) => THIS.id == tmp);
  1312. }
  1313. function findSID(tmpObj, tmp) {
  1314. return tmpObj.find((THIS) => THIS.sid == tmp);
  1315. }
  1316. function findPlayerByID(id) {
  1317. return findID(players, id);
  1318. }
  1319. function findPlayerBySID(sid) {
  1320. return findSID(players, sid);
  1321. }
  1322. function findAIBySID(sid) {
  1323. return findSID(ais, sid);
  1324. }
  1325. function findObjectBySid(sid) {
  1326. return findSID(gameObjects, sid);
  1327. }
  1328. function findProjectileBySid(sid) {
  1329. return findSID(gameObjects, sid);
  1330. }
  1331. let gameName = getEl("gameName");
  1332. let adCard = getEl("adCard");
  1333. //adCard.remove();
  1334. let promoImageHolder = getEl("promoImgHolder");
  1335. promoImageHolder.remove();
  1336. let chatButton = getEl("chatButton");
  1337. chatButton.remove();
  1338. let gameCanvas = getEl("gameCanvas");
  1339. let mainContext = gameCanvas.getContext("2d");
  1340. let mapDisplay = getEl("mapDisplay");
  1341. let mapContext = mapDisplay.getContext("2d");
  1342. mapDisplay.width = 300;
  1343. mapDisplay.height = 300;
  1344. let storeMenu = getEl("storeMenu");
  1345. let storeHolder = getEl("storeHolder");
  1346. let upgradeHolder = getEl("upgradeHolder");
  1347. let upgradeCounter = getEl("upgradeCounter");
  1348. let chatBox = getEl("chatBox");
  1349. chatBox.autocomplete = "off";
  1350. chatBox.style.textAlign = "center";
  1351. chatBox.style.width = "18em";
  1352. let chatHolder = getEl("chatHolder");
  1353. let actionBar = getEl("actionBar");
  1354. let leaderboardData = getEl("leaderboardData");
  1355. let itemInfoHolder = getEl("itemInfoHolder");
  1356. let menuCardHolder = getEl("menuCardHolder");
  1357. let mainMenu = getEl("mainMenu");
  1358. let diedText = getEl("diedText");
  1359. let screenWidth;
  1360. let screenHeight;
  1361. let maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1362. let maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1363.  
  1364. function zoomVision() {
  1365. if (maxScreenWidth != config.maxScreenWidth * 1.5 || maxScreenHeight != config.maxScreenHeight * 1.5) {
  1366. maxScreenWidth = config.maxScreenWidth * 1.5;
  1367. maxScreenHeight = config.maxScreenHeight * 1.5;
  1368. resize();
  1369. }
  1370. }
  1371. function resetZoom() {
  1372. if (maxScreenWidth != config.maxScreenWidth * parseFloat(getEl("vision").value) || maxScreenHeight != config.maxScreenHeight * parseFloat(getEl("vision").value)) {
  1373. maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1374. maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1375. resize();
  1376. }
  1377. }
  1378. getEl("vision").onchange = function() {
  1379. resetZoom();
  1380. }
  1381. let pixelDensity = 1;
  1382. let delta;
  1383. let now;
  1384. let lastUpdate = performance.now();
  1385. let camX;
  1386. let camY;
  1387. let tmpDir;
  1388. let mouseX = 0;
  1389. let mouseY = 0;
  1390. let allianceMenu = getEl("allianceMenu");
  1391. let waterMult = 1;
  1392. let waterPlus = 0;
  1393. let outlineColor = "#525252";
  1394. let darkOutlineColor = "#3d3f42";
  1395. let outlineWidth = 5.5;
  1396. let isNight = false;
  1397. let firstSetup = true;
  1398. let keys = {};
  1399. let moveKeys = {
  1400. 87: [0, -1],
  1401. 38: [0, -1],
  1402. 83: [0, 1],
  1403. 40: [0, 1],
  1404. 65: [-1, 0],
  1405. 37: [-1, 0],
  1406. 68: [1, 0],
  1407. 39: [1, 0],
  1408. };
  1409. function resetMoveDir() {
  1410. keys = {};
  1411. packet("e");
  1412. }
  1413. let attackState = 0;
  1414. let inGame = false;
  1415. let macro = {};
  1416. let mills = {
  1417. place: 0,
  1418. placeSpawnPads: 0
  1419. };
  1420. let lastDir;
  1421. let lastLeaderboardData = [];
  1422. // ON LOAD:
  1423. let inWindow = true;
  1424. window.onblur = function() {
  1425. inWindow = false;
  1426. };
  1427. window.onfocus = function() {
  1428. inWindow = true;
  1429. if (player && player.alive) {
  1430. resetMoveDir();
  1431. }
  1432. };
  1433. let placeVisible = [];
  1434. let preplaceVisible = [];
  1435. let profanityList = [/*"cunt", "whore", "fuck", "shit", "faggot", "nigger",
  1436. "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex",
  1437. "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune",
  1438. "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard"*/];
  1439. /** CLASS CODES */
  1440. class Utils {
  1441. constructor() {
  1442. // MATH UTILS:
  1443. let mathABS = Math.abs,
  1444. mathCOS = Math.cos,
  1445. mathSIN = Math.sin,
  1446. mathPOW = Math.pow,
  1447. mathSQRT = Math.sqrt,
  1448. mathATAN2 = Math.atan2,
  1449. mathPI = Math.PI;
  1450. let _this = this;
  1451. // GLOBAL UTILS:
  1452. this.round = function(n, v) {
  1453. return Math.round(n * v) / v;
  1454. };
  1455. this.toRad = function(angle) {
  1456. return angle * (mathPI / 180);
  1457. };
  1458. this.toAng = function(radian) {
  1459. return radian / (mathPI / 180);
  1460. };
  1461. this.randInt = function(min, max) {
  1462. return Math.floor(Math.random() * (max - min + 1)) + min;
  1463. };
  1464. this.randFloat = function(min, max) {
  1465. return Math.random() * (max - min + 1) + min;
  1466. };
  1467. this.lerp = function(value1, value2, amount) {
  1468. return value1 + (value2 - value1) * amount;
  1469. };
  1470. this.decel = function(val, cel) {
  1471. if (val > 0)
  1472. val = Math.max(0, val - cel);
  1473. else if (val < 0)
  1474. val = Math.min(0, val + cel);
  1475. return val;
  1476. };
  1477. this.getDistance = function(x1, y1, x2, y2) {
  1478. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1479. };
  1480. this.getDist = function(tmp1, tmp2, type1, type2) {
  1481. let tmpXY1 = {
  1482. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1483. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1484. };
  1485. let tmpXY2 = {
  1486. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1487. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1488. };
  1489. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1490. };
  1491. this.getDirection = function(x1, y1, x2, y2) {
  1492. return mathATAN2(y1 - y2, x1 - x2);
  1493. };
  1494. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1495. let tmpXY1 = {
  1496. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1497. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1498. };
  1499. let tmpXY2 = {
  1500. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1501. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1502. };
  1503. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1504. };
  1505. this.getAngleDist = function(a, b) {
  1506. let p = mathABS(b - a) % (mathPI * 2);
  1507. return (p > mathPI ? (mathPI * 2) - p : p);
  1508. };
  1509. this.isNumber = function(n) {
  1510. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1511. };
  1512. this.isString = function(s) {
  1513. return (s && typeof s == "string");
  1514. };
  1515. this.kFormat = function(num) {
  1516. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1517. };
  1518. this.sFormat = function(num) {
  1519. let fixs = [
  1520. { num: 1e3, string: "k" },
  1521. { num: 1e6, string: "m" },
  1522. { num: 1e9, string: "b" },
  1523. { num: 1e12, string: "q" }
  1524. ].reverse();
  1525. let sp = fixs.find(v => num >= v.num);
  1526. if (!sp) return num;
  1527. return (num / sp.num).toFixed(1) + sp.string;
  1528. };
  1529. this.capitalizeFirst = function(string) {
  1530. return string.charAt(0).toUpperCase() + string.slice(1);
  1531. };
  1532. this.fixTo = function(n, v) {
  1533. return parseFloat(n.toFixed(v));
  1534. };
  1535. this.sortByPoints = function(a, b) {
  1536. return parseFloat(b.points) - parseFloat(a.points);
  1537. };
  1538. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1539. let minX = x1;
  1540. let maxX = x2;
  1541. if (x1 > x2) {
  1542. minX = x2;
  1543. maxX = x1;
  1544. }
  1545. if (maxX > recX2)
  1546. maxX = recX2;
  1547. if (minX < recX)
  1548. minX = recX;
  1549. if (minX > maxX)
  1550. return false;
  1551. let minY = y1;
  1552. let maxY = y2;
  1553. let dx = x2 - x1;
  1554. if (Math.abs(dx) > 0.0000001) {
  1555. let a = (y2 - y1) / dx;
  1556. let b = y1 - a * x1;
  1557. minY = a * minX + b;
  1558. maxY = a * maxX + b;
  1559. }
  1560. if (minY > maxY) {
  1561. let tmp = maxY;
  1562. maxY = minY;
  1563. minY = tmp;
  1564. }
  1565. if (maxY > recY2)
  1566. maxY = recY2;
  1567. if (minY < recY)
  1568. minY = recY;
  1569. if (minY > maxY)
  1570. return false;
  1571. return true;
  1572. };
  1573. this.containsPoint = function(element, x, y) {
  1574. let bounds = element.getBoundingClientRect();
  1575. let left = bounds.left + window.scrollX;
  1576. let top = bounds.top + window.scrollY;
  1577. let width = bounds.width;
  1578. let height = bounds.height;
  1579. let insideHorizontal = x > left && x < left + width;
  1580. let insideVertical = y > top && y < top + height;
  1581. return insideHorizontal && insideVertical;
  1582. };
  1583. this.mousifyTouchEvent = function(event) {
  1584. let touch = event.changedTouches[0];
  1585. event.screenX = touch.screenX;
  1586. event.screenY = touch.screenY;
  1587. event.clientX = touch.clientX;
  1588. event.clientY = touch.clientY;
  1589. event.pageX = touch.pageX;
  1590. event.pageY = touch.pageY;
  1591. };
  1592. this.hookTouchEvents = function(element, skipPrevent) {
  1593. let preventDefault = !skipPrevent;
  1594. let isHovering = false;
  1595. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1596. let passive = false;
  1597. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1598. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1599. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1600. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1601. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1602. function touchStart(e) {
  1603. _this.mousifyTouchEvent(e);
  1604. window.setUsingTouch(true);
  1605. if (preventDefault) {
  1606. e.preventDefault();
  1607. e.stopPropagation();
  1608. }
  1609. if (element.onmouseover)
  1610. element.onmouseover(e);
  1611. isHovering = true;
  1612. }
  1613. function touchMove(e) {
  1614. _this.mousifyTouchEvent(e);
  1615. window.setUsingTouch(true);
  1616. if (preventDefault) {
  1617. e.preventDefault();
  1618. e.stopPropagation();
  1619. }
  1620. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1621. if (!isHovering) {
  1622. if (element.onmouseover)
  1623. element.onmouseover(e);
  1624. isHovering = true;
  1625. }
  1626. } else {
  1627. if (isHovering) {
  1628. if (element.onmouseout)
  1629. element.onmouseout(e);
  1630. isHovering = false;
  1631. }
  1632. }
  1633. }
  1634. function touchEnd(e) {
  1635. _this.mousifyTouchEvent(e);
  1636. window.setUsingTouch(true);
  1637. if (preventDefault) {
  1638. e.preventDefault();
  1639. e.stopPropagation();
  1640. }
  1641. if (isHovering) {
  1642. if (element.onclick)
  1643. element.onclick(e);
  1644. if (element.onmouseout)
  1645. element.onmouseout(e);
  1646. isHovering = false;
  1647. }
  1648. }
  1649. };
  1650. this.removeAllChildren = function(element) {
  1651. while (element.hasChildNodes()) {
  1652. element.removeChild(element.lastChild);
  1653. }
  1654. };
  1655. this.generateElement = function(config) {
  1656. let element = document.createElement(config.tag || "div");
  1657. function bind(configValue, elementValue) {
  1658. if (config[configValue])
  1659. element[elementValue] = config[configValue];
  1660. }
  1661. bind("text", "textContent");
  1662. bind("html", "innerHTML");
  1663. bind("class", "className");
  1664. for (let key in config) {
  1665. switch (key) {
  1666. case "tag":
  1667. case "text":
  1668. case "html":
  1669. case "class":
  1670. case "style":
  1671. case "hookTouch":
  1672. case "parent":
  1673. case "children":
  1674. continue;
  1675. default:
  1676. break;
  1677. }
  1678. element[key] = config[key];
  1679. }
  1680. if (element.onclick)
  1681. element.onclick = this.checkTrusted(element.onclick);
  1682. if (element.onmouseover)
  1683. element.onmouseover = this.checkTrusted(element.onmouseover);
  1684. if (element.onmouseout)
  1685. element.onmouseout = this.checkTrusted(element.onmouseout);
  1686. if (config.style) {
  1687. element.style.cssText = config.style;
  1688. }
  1689. if (config.hookTouch) {
  1690. this.hookTouchEvents(element);
  1691. }
  1692. if (config.parent) {
  1693. config.parent.appendChild(element);
  1694. }
  1695. if (config.children) {
  1696. for (let i = 0; i < config.children.length; i++) {
  1697. element.appendChild(config.children[i]);
  1698. }
  1699. }
  1700. return element;
  1701. };
  1702. this.checkTrusted = function(callback) {
  1703. return function(ev) {
  1704. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1705. callback(ev);
  1706. } else {
  1707. //console.error("Event is not trusted.", ev);
  1708. }
  1709. };
  1710. };
  1711. this.randomString = function(length) {
  1712. let text = "";
  1713. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1714. for (let i = 0; i < length; i++) {
  1715. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1716. }
  1717. return text;
  1718. };
  1719. this.countInArray = function(array, val) {
  1720. let count = 0;
  1721. for (let i = 0; i < array.length; i++) {
  1722. if (array[i] === val) count++;
  1723. }
  1724. return count;
  1725. };
  1726. this.hexToRgb = function(hex) {
  1727. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1728. };
  1729. this.getRgb = function(r, g, b) {
  1730. return [r / 255, g / 255, b / 255].join(", ");
  1731. };
  1732. }
  1733. };
  1734. class Animtext {
  1735. // ANIMATED TEXT:
  1736. constructor() {
  1737. // INIT:
  1738. this.init = function(x, y, scale, speed, life, text, color) {
  1739. this.x = x;
  1740. this.y = y;
  1741. this.color = color;
  1742. this.scale = scale;
  1743. this.startScale = this.scale;
  1744. this.maxScale = scale * 1.5;
  1745. this.scaleSpeed = 0.7;
  1746. this.speed = speed;
  1747. this.life = life;
  1748. this.text = text;
  1749. this.acc = 1;
  1750. this.alpha = 0;
  1751. this.maxLife = life;
  1752. this.ranX = UTILS.randFloat(-1, 1);
  1753. };
  1754. // UPDATE:
  1755. this.update = function(delta) {
  1756. if (this.life) {
  1757. this.life -= delta;
  1758. this.y -= this.speed * delta;
  1759. this.scale += this.scaleSpeed * delta;
  1760. if (this.scale >= this.maxScale) {
  1761. this.scale = this.maxScale;
  1762. this.scaleSpeed *= -1;
  1763. } else if (this.scale <= this.startScale) {
  1764. this.scale = this.startScale;
  1765. this.scaleSpeed = 0;
  1766. }
  1767. if (this.life <= 0) {
  1768. this.life = 0;
  1769. }
  1770. }
  1771. };
  1772. // RENDER:
  1773. this.render = function(ctxt, xOff, yOff) {
  1774. ctxt.lineWidth = 10;
  1775. ctxt.fillStyle = this.color;
  1776. ctxt.font = this.scale + "px " + (this.scale >= 15 ? "Hammersmith One" : "Ubuntu");
  1777. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1778. ctxt.globalAlpha = 1;
  1779. };
  1780. }
  1781. };
  1782. class Textmanager {
  1783. // TEXT MANAGER:
  1784. constructor() {
  1785. this.texts = [];
  1786. this.stack = [];
  1787. // UPDATE:
  1788. this.update = function(delta, ctxt, xOff, yOff) {
  1789. ctxt.textBaseline = "middle";
  1790. ctxt.textAlign = "center";
  1791. for (let i = 0; i < this.texts.length; ++i) {
  1792. if (this.texts[i].life) {
  1793. this.texts[i].update(delta);
  1794. this.texts[i].render(ctxt, xOff, yOff);
  1795. }
  1796. }
  1797. };
  1798. // SHOW TEXT:
  1799. this.showText = function(x, y, scale, speed, life, text, color) {
  1800. let tmpText;
  1801. for (let i = 0; i < this.texts.length; ++i) {
  1802. if (!this.texts[i].life) {
  1803. tmpText = this.texts[i];
  1804. break;
  1805. }
  1806. }
  1807. if (!tmpText) {
  1808. tmpText = new Animtext();
  1809. this.texts.push(tmpText);
  1810. }
  1811. tmpText.init(x, y, scale, speed, life, text, color);
  1812. };
  1813. }
  1814. }
  1815. class GameObject {
  1816. constructor(sid) {
  1817. this.sid = sid;
  1818. // INIT:
  1819. this.init = function(x, y, dir, scale, type, data, owner) {
  1820. data = data || {};
  1821. this.sentTo = {};
  1822. this.gridLocations = [];
  1823. this.active = true;
  1824. this.alive = true;
  1825. this.doUpdate = data.doUpdate;
  1826. this.x = x;
  1827. this.y = y;
  1828. this.dir = dir;
  1829. this.lastDir = dir;
  1830. this.xWiggle = 0;
  1831. this.yWiggle = 0;
  1832. this.visScale = scale;
  1833. this.scale = scale;
  1834. this.type = type;
  1835. this.id = data.id;
  1836. this.owner = owner;
  1837. this.name = data.name;
  1838. this.isItem = (this.id != undefined);
  1839. this.group = data.group;
  1840. this.maxHealth = data.health;
  1841. this.health = this.maxHealth;
  1842. this.healthMov = 100;
  1843. this.layer = 2;
  1844. if (this.group != undefined) {
  1845. this.layer = this.group.layer;
  1846. } else if (this.type == 0) {
  1847. this.layer = 3;
  1848. } else if (this.type == 2) {
  1849. this.layer = 0;
  1850. } else if (this.type == 4) {
  1851. this.layer = -1;
  1852. }
  1853. this.colDiv = data.colDiv || 1;
  1854. this.blocker = data.blocker;
  1855. this.ignoreCollision = data.ignoreCollision;
  1856. this.dontGather = data.dontGather;
  1857. this.hideFromEnemy = data.hideFromEnemy;
  1858. this.friction = data.friction;
  1859. this.projDmg = data.projDmg;
  1860. this.dmg = data.dmg;
  1861. this.pDmg = data.pDmg;
  1862. this.pps = data.pps;
  1863. this.zIndex = data.zIndex || 0;
  1864. this.turnSpeed = data.turnSpeed;
  1865. this.req = data.req;
  1866. this.trap = data.trap;
  1867. this.healCol = data.healCol;
  1868. this.teleport = data.teleport;
  1869. this.boostSpeed = data.boostSpeed;
  1870. this.projectile = data.projectile;
  1871. this.shootRange = data.shootRange;
  1872. this.shootRate = data.shootRate;
  1873. this.shootCount = this.shootRate;
  1874. this.spawnPoint = data.spawnPoint;
  1875. this.onNear = 0;
  1876. this.breakObj = false;
  1877. this.alpha = data.alpha || 1;
  1878. this.maxAlpha = data.alpha || 1;
  1879. this.damaged = 0;
  1880. };
  1881. // GET HIT:
  1882. this.changeHealth = function(amount, doer) {
  1883. this.health += amount;
  1884. return (this.health <= 0);
  1885. };
  1886. // GET SCALE:
  1887. this.getScale = function(sM, ig) {
  1888. sM = sM || 1;
  1889. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1890. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1891. };
  1892. // VISIBLE TO PLAYER:
  1893. this.visibleToPlayer = function(player) {
  1894. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1895. (this.owner.team && player.team == this.owner.team)));
  1896. };
  1897. // UPDATE:
  1898. this.update = function(delta) {
  1899. if (this.health != this.healthMov) {
  1900. this.health < this.healthMov ? (this.healthMov -= 1.9) : (this.healthMov += 1.9);
  1901. if (Math.abs(this.health - this.healthMov) < 1.9) this.healthMov = this.health;
  1902. };
  1903. if (this.active) {
  1904. if (this.xWiggle) {
  1905. this.xWiggle *= Math.pow(0.99, delta);
  1906. }
  1907. if (this.yWiggle) {
  1908. this.yWiggle *= Math.pow(0.99, delta);
  1909. }
  1910. if (this.turnSpeed && this.dmg) {
  1911. this.dir += this.turnSpeed * delta;
  1912. }
  1913. } else {
  1914. if (this.alive) {
  1915. this.alpha -= delta / (200 / this.maxAlpha);
  1916. this.visScale += delta / (this.scale / 2.5);
  1917. if (this.alpha <= 0) {
  1918. this.alpha = 0;
  1919. this.alive = false;
  1920. }
  1921. }
  1922. }
  1923. };
  1924. // CHECK TEAM:
  1925. this.isTeamObject = function(tmpObj) {
  1926. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  1927. };
  1928. }
  1929. }
  1930. class Items {
  1931. constructor() {
  1932. // ITEM GROUPS:
  1933. this.groups = [{
  1934. id: 0,
  1935. name: "food",
  1936. layer: 0
  1937. }, {
  1938. id: 1,
  1939. name: "walls",
  1940. place: true,
  1941. limit: 30,
  1942. layer: 0
  1943. }, {
  1944. id: 2,
  1945. name: "spikes",
  1946. place: true,
  1947. limit: 15,
  1948. layer: 0
  1949. }, {
  1950. id: 3,
  1951. name: "mill",
  1952. place: true,
  1953. limit: 7,
  1954. layer: 1
  1955. }, {
  1956. id: 4,
  1957. name: "mine",
  1958. place: true,
  1959. limit: 1,
  1960. layer: 0
  1961. }, {
  1962. id: 5,
  1963. name: "trap",
  1964. place: true,
  1965. limit: 6,
  1966. layer: -1
  1967. }, {
  1968. id: 6,
  1969. name: "booster",
  1970. place: true,
  1971. limit: 12,
  1972. layer: -1
  1973. }, {
  1974. id: 7,
  1975. name: "turret",
  1976. place: true,
  1977. limit: 2,
  1978. layer: 1
  1979. }, {
  1980. id: 8,
  1981. name: "watchtower",
  1982. place: true,
  1983. limit: 12,
  1984. layer: 1
  1985. }, {
  1986. id: 9,
  1987. name: "buff",
  1988. place: true,
  1989. limit: 4,
  1990. layer: -1
  1991. }, {
  1992. id: 10,
  1993. name: "spawn",
  1994. place: true,
  1995. limit: 1,
  1996. layer: -1
  1997. }, {
  1998. id: 11,
  1999. name: "sapling",
  2000. place: true,
  2001. limit: 2,
  2002. layer: 0
  2003. }, {
  2004. id: 12,
  2005. name: "blocker",
  2006. place: true,
  2007. limit: 3,
  2008. layer: -1
  2009. }, {
  2010. id: 13,
  2011. name: "teleporter",
  2012. place: true,
  2013. limit: 2,
  2014. layer: -1
  2015. }];
  2016. // PROJECTILES:
  2017. this.projectiles = [{
  2018. indx: 0,
  2019. layer: 0,
  2020. src: "arrow_1",
  2021. dmg: 25,
  2022. speed: 1.6,
  2023. scale: 103,
  2024. range: 1000
  2025. }, {
  2026. indx: 1,
  2027. layer: 1,
  2028. dmg: 25,
  2029. scale: 20
  2030. }, {
  2031. indx: 0,
  2032. layer: 0,
  2033. src: "arrow_1",
  2034. dmg: 35,
  2035. speed: 2.5,
  2036. scale: 103,
  2037. range: 1200
  2038. }, {
  2039. indx: 0,
  2040. layer: 0,
  2041. src: "arrow_1",
  2042. dmg: 30,
  2043. speed: 2,
  2044. scale: 103,
  2045. range: 1200
  2046. }, {
  2047. indx: 1,
  2048. layer: 1,
  2049. dmg: 16,
  2050. scale: 20
  2051. }, {
  2052. indx: 0,
  2053. layer: 0,
  2054. src: "bullet_1",
  2055. dmg: 50,
  2056. speed: 3.6,
  2057. scale: 160,
  2058. range: 1400
  2059. }];
  2060. // WEAPONS:
  2061. this.weapons = [{
  2062. id: 0,
  2063. type: 0,
  2064. name: "tool hammer",
  2065. desc: "tool for gathering all resources",
  2066. src: "hammer_1",
  2067. length: 140,
  2068. width: 140,
  2069. xOff: -3,
  2070. yOff: 18,
  2071. dmg: 25,
  2072. range: 65,
  2073. gather: 1,
  2074. speed: 300
  2075. }, {
  2076. id: 1,
  2077. type: 0,
  2078. age: 2,
  2079. name: "hand axe",
  2080. desc: "gathers resources at a higher rate",
  2081. src: "axe_1",
  2082. length: 140,
  2083. width: 140,
  2084. xOff: 3,
  2085. yOff: 24,
  2086. dmg: 30,
  2087. spdMult: 1,
  2088. range: 70,
  2089. gather: 2,
  2090. speed: 400
  2091. }, {
  2092. id: 2,
  2093. type: 0,
  2094. age: 8,
  2095. pre: 1,
  2096. name: "great axe",
  2097. desc: "deal more damage and gather more resources",
  2098. src: "great_axe_1",
  2099. length: 140,
  2100. width: 140,
  2101. xOff: -8,
  2102. yOff: 25,
  2103. dmg: 35,
  2104. spdMult: 1,
  2105. range: 75,
  2106. gather: 4,
  2107. speed: 400
  2108. }, {
  2109. id: 3,
  2110. type: 0,
  2111. age: 2,
  2112. name: "short sword",
  2113. desc: "increased attack power but slower move speed",
  2114. src: "sword_1",
  2115. iPad: 1.3,
  2116. length: 130,
  2117. width: 210,
  2118. xOff: -8,
  2119. yOff: 46,
  2120. dmg: 35,
  2121. spdMult: 0.85,
  2122. range: 110,
  2123. gather: 1,
  2124. speed: 300
  2125. }, {
  2126. id: 4,
  2127. type: 0,
  2128. age: 8,
  2129. pre: 3,
  2130. name: "katana",
  2131. desc: "greater range and damage",
  2132. src: "samurai_1",
  2133. iPad: 1.3,
  2134. length: 130,
  2135. width: 210,
  2136. xOff: -8,
  2137. yOff: 59,
  2138. dmg: 40,
  2139. spdMult: 0.8,
  2140. range: 118,
  2141. gather: 1,
  2142. speed: 300
  2143. }, {
  2144. id: 5,
  2145. type: 0,
  2146. age: 2,
  2147. name: "polearm",
  2148. desc: "long range melee weapon",
  2149. src: "spear_1",
  2150. iPad: 1.3,
  2151. length: 130,
  2152. width: 210,
  2153. xOff: -8,
  2154. yOff: 53,
  2155. dmg: 45,
  2156. knock: 0.2,
  2157. spdMult: 0.82,
  2158. range: 142,
  2159. gather: 1,
  2160. speed: 700
  2161. }, {
  2162. id: 6,
  2163. type: 0,
  2164. age: 2,
  2165. name: "bat",
  2166. desc: "fast long range melee weapon",
  2167. src: "bat_1",
  2168. iPad: 1.3,
  2169. length: 110,
  2170. width: 180,
  2171. xOff: -8,
  2172. yOff: 53,
  2173. dmg: 20,
  2174. knock: 0.7,
  2175. range: 110,
  2176. gather: 1,
  2177. speed: 300
  2178. }, {
  2179. id: 7,
  2180. type: 0,
  2181. age: 2,
  2182. name: "daggers",
  2183. desc: "really fast short range weapon",
  2184. src: "dagger_1",
  2185. iPad: 0.8,
  2186. length: 110,
  2187. width: 110,
  2188. xOff: 18,
  2189. yOff: 0,
  2190. dmg: 20,
  2191. knock: 0.1,
  2192. range: 65,
  2193. gather: 1,
  2194. hitSlow: 0.1,
  2195. spdMult: 1.13,
  2196. speed: 100
  2197. }, {
  2198. id: 8,
  2199. type: 0,
  2200. age: 2,
  2201. name: "stick",
  2202. desc: "great for gathering but very weak",
  2203. src: "stick_1",
  2204. length: 140,
  2205. width: 140,
  2206. xOff: 3,
  2207. yOff: 24,
  2208. dmg: 1,
  2209. spdMult: 1,
  2210. range: 70,
  2211. gather: 7,
  2212. speed: 400
  2213. }, {
  2214. id: 9,
  2215. type: 1,
  2216. age: 6,
  2217. name: "hunting bow",
  2218. desc: "bow used for ranged combat and hunting",
  2219. src: "bow_1",
  2220. req: ["wood", 4],
  2221. length: 120,
  2222. width: 120,
  2223. xOff: -6,
  2224. yOff: 0,
  2225. Pdmg: 25,
  2226. projectile: 0,
  2227. spdMult: 0.75,
  2228. speed: 600
  2229. }, {
  2230. id: 10,
  2231. type: 1,
  2232. age: 6,
  2233. name: "great hammer",
  2234. desc: "hammer used for destroying structures",
  2235. src: "great_hammer_1",
  2236. length: 140,
  2237. width: 140,
  2238. xOff: -9,
  2239. yOff: 25,
  2240. dmg: 10,
  2241. Pdmg: 10,
  2242. spdMult: 0.88,
  2243. range: 75,
  2244. sDmg: 7.5,
  2245. gather: 1,
  2246. speed: 400
  2247. }, {
  2248. id: 11,
  2249. type: 1,
  2250. age: 6,
  2251. name: "wooden shield",
  2252. desc: "blocks projectiles and reduces melee damage",
  2253. src: "shield_1",
  2254. length: 120,
  2255. width: 120,
  2256. shield: 0.2,
  2257. xOff: 6,
  2258. yOff: 0,
  2259. Pdmg: 0,
  2260. spdMult: 0.7
  2261. }, {
  2262. id: 12,
  2263. type: 1,
  2264. age: 8,
  2265. pre: 9,
  2266. name: "crossbow",
  2267. desc: "deals more damage and has greater range",
  2268. src: "crossbow_1",
  2269. req: ["wood", 5],
  2270. aboveHand: true,
  2271. armS: 0.75,
  2272. length: 120,
  2273. width: 120,
  2274. xOff: -4,
  2275. yOff: 0,
  2276. Pdmg: 35,
  2277. projectile: 2,
  2278. spdMult: 0.7,
  2279. speed: 700
  2280. }, {
  2281. id: 13,
  2282. type: 1,
  2283. age: 9,
  2284. pre: 12,
  2285. name: "repeater crossbow",
  2286. desc: "high firerate crossbow with reduced damage",
  2287. src: "crossbow_2",
  2288. req: ["wood", 10],
  2289. aboveHand: true,
  2290. armS: 0.75,
  2291. length: 120,
  2292. width: 120,
  2293. xOff: -4,
  2294. yOff: 0,
  2295. Pdmg: 30,
  2296. projectile: 3,
  2297. spdMult: 0.7,
  2298. speed: 230
  2299. }, {
  2300. id: 14,
  2301. type: 1,
  2302. age: 6,
  2303. name: "mc grabby",
  2304. desc: "steals resources from enemies",
  2305. src: "grab_1",
  2306. length: 130,
  2307. width: 210,
  2308. xOff: -8,
  2309. yOff: 53,
  2310. dmg: 0,
  2311. Pdmg: 0,
  2312. steal: 250,
  2313. knock: 0.2,
  2314. spdMult: 1.05,
  2315. range: 125,
  2316. gather: 0,
  2317. speed: 700
  2318. }, {
  2319. id: 15,
  2320. type: 1,
  2321. age: 9,
  2322. pre: 12,
  2323. name: "musket",
  2324. desc: "slow firerate but high damage and range",
  2325. src: "musket_1",
  2326. req: ["stone", 10],
  2327. aboveHand: true,
  2328. rec: 0.35,
  2329. armS: 0.6,
  2330. hndS: 0.3,
  2331. hndD: 1.6,
  2332. length: 205,
  2333. width: 205,
  2334. xOff: 25,
  2335. yOff: 0,
  2336. Pdmg: 50,
  2337. projectile: 5,
  2338. hideProjectile: true,
  2339. spdMult: 0.6,
  2340. speed: 1500
  2341. }];
  2342. // ITEMS:
  2343. this.list = [{
  2344. group: this.groups[0],
  2345. name: "apple",
  2346. desc: "restores 20 health when consumed",
  2347. req: ["food", 10],
  2348. consume: function(doer) {
  2349. return doer.changeHealth(20, doer);
  2350. },
  2351. scale: 22,
  2352. holdOffset: 15,
  2353. healing: 20,
  2354. itemID: 0,
  2355. itemAID: 16,
  2356. }, {
  2357. age: 3,
  2358. group: this.groups[0],
  2359. name: "cookie",
  2360. desc: "restores 40 health when consumed",
  2361. req: ["food", 15],
  2362. consume: function(doer) {
  2363. return doer.changeHealth(40, doer);
  2364. },
  2365. scale: 27,
  2366. holdOffset: 15,
  2367. healing: 40,
  2368. itemID: 1,
  2369. itemAID: 17,
  2370. }, {
  2371. age: 7,
  2372. group: this.groups[0],
  2373. name: "cheese",
  2374. desc: "restores 30 health and another 50 over 5 seconds",
  2375. req: ["food", 25],
  2376. consume: function(doer) {
  2377. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2378. doer.dmgOverTime.dmg = -10;
  2379. doer.dmgOverTime.doer = doer;
  2380. doer.dmgOverTime.time = 5;
  2381. return true;
  2382. }
  2383. return false;
  2384. },
  2385. scale: 27,
  2386. holdOffset: 15,
  2387. healing: 30,
  2388. itemID: 2,
  2389. itemAID: 18,
  2390. }, {
  2391. group: this.groups[1],
  2392. name: "wood wall",
  2393. desc: "provides protection for your village",
  2394. req: ["wood", 10],
  2395. projDmg: true,
  2396. health: 380,
  2397. scale: 50,
  2398. holdOffset: 20,
  2399. placeOffset: -5,
  2400. itemID: 3,
  2401. itemAID: 19,
  2402. }, {
  2403. age: 3,
  2404. group: this.groups[1],
  2405. name: "stone wall",
  2406. desc: "provides improved protection for your village",
  2407. req: ["stone", 25],
  2408. health: 900,
  2409. scale: 50,
  2410. holdOffset: 20,
  2411. placeOffset: -5,
  2412. itemID: 4,
  2413. itemAID: 20,
  2414. }, {
  2415. age: 7,
  2416. group: this.groups[1],
  2417. name: "castle wall",
  2418. desc: "provides powerful protection for your village",
  2419. req: ["stone", 35],
  2420. health: 1500,
  2421. scale: 52,
  2422. holdOffset: 20,
  2423. placeOffset: -5,
  2424. itemID: 5,
  2425. itemAID: 21,
  2426. }, {
  2427. group: this.groups[2],
  2428. name: "spikes",
  2429. desc: "damages enemies when they touch them",
  2430. req: ["wood", 20, "stone", 5],
  2431. health: 400,
  2432. dmg: 20,
  2433. scale: 49,
  2434. spritePadding: -23,
  2435. holdOffset: 8,
  2436. placeOffset: -5,
  2437. itemID: 6,
  2438. itemAID: 22,
  2439. }, {
  2440. age: 5,
  2441. group: this.groups[2],
  2442. name: "greater spikes",
  2443. desc: "damages enemies when they touch them",
  2444. req: ["wood", 30, "stone", 10],
  2445. health: 500,
  2446. dmg: 35,
  2447. scale: 52,
  2448. spritePadding: -23,
  2449. holdOffset: 8,
  2450. placeOffset: -5,
  2451. itemID: 7,
  2452. itemAID: 23,
  2453. }, {
  2454. age: 9,
  2455. group: this.groups[2],
  2456. name: "poison spikes",
  2457. desc: "poisons enemies when they touch them",
  2458. req: ["wood", 35, "stone", 15],
  2459. health: 600,
  2460. dmg: 30,
  2461. pDmg: 5,
  2462. scale: 52,
  2463. spritePadding: -23,
  2464. holdOffset: 8,
  2465. placeOffset: -5,
  2466. itemID: 8,
  2467. itemAID: 24,
  2468. }, {
  2469. age: 9,
  2470. group: this.groups[2],
  2471. name: "spinning spikes",
  2472. desc: "damages enemies when they touch them",
  2473. req: ["wood", 30, "stone", 20],
  2474. health: 500,
  2475. dmg: 45,
  2476. turnSpeed: 0.003,
  2477. scale: 52,
  2478. spritePadding: -23,
  2479. holdOffset: 8,
  2480. placeOffset: -5,
  2481. itemID: 9,
  2482. itemAID: 25,
  2483. }, {
  2484. group: this.groups[3],
  2485. name: "windmill",
  2486. desc: "generates gold over time",
  2487. req: ["wood", 50, "stone", 10],
  2488. health: 400,
  2489. pps: 1,
  2490. turnSpeed: 0.0016,
  2491. spritePadding: 25,
  2492. iconLineMult: 12,
  2493. scale: 45,
  2494. holdOffset: 20,
  2495. placeOffset: 5,
  2496. itemID: 10,
  2497. itemAID: 26,
  2498. }, {
  2499. age: 5,
  2500. group: this.groups[3],
  2501. name: "faster windmill",
  2502. desc: "generates more gold over time",
  2503. req: ["wood", 60, "stone", 20],
  2504. health: 500,
  2505. pps: 1.5,
  2506. turnSpeed: 0.0025,
  2507. spritePadding: 25,
  2508. iconLineMult: 12,
  2509. scale: 47,
  2510. holdOffset: 20,
  2511. placeOffset: 5,
  2512. itemID: 11,
  2513. itemAID: 27,
  2514. }, {
  2515. age: 8,
  2516. group: this.groups[3],
  2517. name: "power mill",
  2518. desc: "generates more gold over time",
  2519. req: ["wood", 100, "stone", 50],
  2520. health: 800,
  2521. pps: 2,
  2522. turnSpeed: 0.005,
  2523. spritePadding: 25,
  2524. iconLineMult: 12,
  2525. scale: 47,
  2526. holdOffset: 20,
  2527. placeOffset: 5,
  2528. itemID: 12,
  2529. itemAID: 28,
  2530. }, {
  2531. age: 5,
  2532. group: this.groups[4],
  2533. type: 2,
  2534. name: "mine",
  2535. desc: "allows you to mine stone",
  2536. req: ["wood", 20, "stone", 100],
  2537. iconLineMult: 12,
  2538. scale: 65,
  2539. holdOffset: 20,
  2540. placeOffset: 0,
  2541. itemID: 13,
  2542. itemAID: 29,
  2543. }, {
  2544. age: 5,
  2545. group: this.groups[11],
  2546. type: 0,
  2547. name: "sapling",
  2548. desc: "allows you to farm wood",
  2549. req: ["wood", 150],
  2550. iconLineMult: 12,
  2551. colDiv: 0.5,
  2552. scale: 110,
  2553. holdOffset: 50,
  2554. placeOffset: -15,
  2555. itemID: 14,
  2556. itemAID: 30,
  2557. }, {
  2558. age: 4,
  2559. group: this.groups[5],
  2560. name: "pit trap",
  2561. desc: "pit that traps enemies if they walk over it",
  2562. req: ["wood", 30, "stone", 30],
  2563. trap: true,
  2564. ignoreCollision: true,
  2565. hideFromEnemy: true,
  2566. health: 500,
  2567. colDiv: 0.2,
  2568. scale: 50,
  2569. holdOffset: 20,
  2570. placeOffset: -5,
  2571. alpha: 0.6,
  2572. itemID: 15,
  2573. itemAID: 31,
  2574. }, {
  2575. age: 4,
  2576. group: this.groups[6],
  2577. name: "boost pad",
  2578. desc: "provides boost when stepped on",
  2579. req: ["stone", 20, "wood", 5],
  2580. ignoreCollision: true,
  2581. boostSpeed: 1.5,
  2582. health: 150,
  2583. colDiv: 0.7,
  2584. scale: 45,
  2585. holdOffset: 20,
  2586. placeOffset: -5,
  2587. itemID: 16,
  2588. itemAID: 32,
  2589. }, {
  2590. age: 7,
  2591. group: this.groups[7],
  2592. doUpdate: true,
  2593. name: "turret",
  2594. desc: "defensive structure that shoots at enemies",
  2595. req: ["wood", 200, "stone", 150],
  2596. health: 800,
  2597. projectile: 1,
  2598. shootRange: 700,
  2599. shootRate: 2200,
  2600. scale: 43,
  2601. holdOffset: 20,
  2602. placeOffset: -5,
  2603. itemID: 17,
  2604. itemAID: 33,
  2605. }, {
  2606. age: 7,
  2607. group: this.groups[8],
  2608. name: "platform",
  2609. desc: "platform to shoot over walls and cross over water",
  2610. req: ["wood", 20],
  2611. ignoreCollision: true,
  2612. zIndex: 1,
  2613. health: 300,
  2614. scale: 43,
  2615. holdOffset: 20,
  2616. placeOffset: -5,
  2617. itemID: 18,
  2618. itemAID: 34,
  2619. }, {
  2620. age: 7,
  2621. group: this.groups[9],
  2622. name: "healing pad",
  2623. desc: "standing on it will slowly heal you",
  2624. req: ["wood", 30, "food", 10],
  2625. ignoreCollision: true,
  2626. healCol: 15,
  2627. health: 400,
  2628. colDiv: 0.7,
  2629. scale: 45,
  2630. holdOffset: 20,
  2631. placeOffset: -5,
  2632. itemID: 19,
  2633. itemAID: 35,
  2634. }, {
  2635. age: 9,
  2636. group: this.groups[10],
  2637. name: "spawn pad",
  2638. desc: "you will spawn here when you die but it will dissapear",
  2639. req: ["wood", 100, "stone", 100],
  2640. health: 400,
  2641. ignoreCollision: true,
  2642. spawnPoint: true,
  2643. scale: 45,
  2644. holdOffset: 20,
  2645. placeOffset: -5,
  2646. itemID: 20,
  2647. itemAID: 36,
  2648. }, {
  2649. age: 7,
  2650. group: this.groups[12],
  2651. name: "blocker",
  2652. desc: "blocks building in radius",
  2653. req: ["wood", 30, "stone", 25],
  2654. ignoreCollision: true,
  2655. blocker: 300,
  2656. health: 400,
  2657. colDiv: 0.7,
  2658. scale: 45,
  2659. holdOffset: 20,
  2660. placeOffset: -5,
  2661. itemID: 21,
  2662. itemAID: 37,
  2663. }, {
  2664. age: 7,
  2665. group: this.groups[13],
  2666. name: "teleporter",
  2667. desc: "teleports you to a random point on the map",
  2668. req: ["wood", 60, "stone", 60],
  2669. ignoreCollision: true,
  2670. teleport: true,
  2671. health: 200,
  2672. colDiv: 0.7,
  2673. scale: 45,
  2674. holdOffset: 20,
  2675. placeOffset: -5,
  2676. itemID: 22,
  2677. itemAID: 38
  2678. }];
  2679. // CHECK ITEM ID:
  2680. this.checkItem = {
  2681. index: function(id, myItems) {
  2682. return [0, 1, 2].includes(id) ? 0 :
  2683. [3, 4, 5].includes(id) ? 1 :
  2684. [6, 7, 8, 9].includes(id) ? 2 :
  2685. [10, 11, 12].includes(id) ? 3 :
  2686. [13, 14].includes(id) ? 5 :
  2687. [15, 16].includes(id) ? 4 :
  2688. [17, 18, 19, 21, 22].includes(id) ?
  2689. [13, 14].includes(myItems) ? 6 :
  2690. 5 :
  2691. id == 20 ?
  2692. [13, 14].includes(myItems) ? 7 :
  2693. 6 :
  2694. undefined;
  2695. }
  2696. }
  2697. // ASSIGN IDS:
  2698. for (let i = 0; i < this.list.length; ++i) {
  2699. this.list[i].id = i;
  2700. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2701. }
  2702. // TROLOLOLOL:
  2703. if (typeof window !== "undefined") {
  2704. function shuffle(a) {
  2705. for (let i = a.length - 1; i > 0; i--) {
  2706. const j = Math.floor(Math.random() * (i + 1));
  2707. [a[i], a[j]] = [a[j], a[i]];
  2708. }
  2709. return a;
  2710. }
  2711. //shuffle(this.list);
  2712. }
  2713. }
  2714. }
  2715. class Objectmanager {
  2716. constructor(GameObject, gameObjects, UTILS, config, players, server) {
  2717. let mathFloor = Math.floor,
  2718. mathABS = Math.abs,
  2719. mathCOS = Math.cos,
  2720. mathSIN = Math.sin,
  2721. mathPOW = Math.pow,
  2722. mathSQRT = Math.sqrt;
  2723. this.ignoreAdd = false;
  2724. this.hitObj = [];
  2725. // DISABLE OBJ:
  2726. this.disableObj = function(obj) {
  2727. obj.active = false;
  2728. obj.alive = false;
  2729. };
  2730. // ADD NEW:
  2731. let tmpObj;
  2732. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2733. tmpObj = findObjectBySid(sid);
  2734. if (!tmpObj) {
  2735. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2736. if (!tmpObj) {
  2737. tmpObj = new GameObject(sid);
  2738. gameObjects.push(tmpObj);
  2739. }
  2740. }
  2741. if (setSID) {
  2742. tmpObj.sid = sid;
  2743. }
  2744. tmpObj.init(x, y, dir, s, type, data, owner);
  2745. };
  2746. // DISABLE BY SID:
  2747. this.disableBySid = function(sid) {
  2748. let find = findObjectBySid(sid);
  2749. if (find) {
  2750. this.disableObj(find);
  2751. }
  2752. };
  2753. // REMOVE ALL FROM PLAYER:
  2754. this.removeAllItems = function(sid, server) {
  2755. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2756. };
  2757. // CHECK IF PLACABLE:
  2758. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2759. 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)));
  2760. if (cantPlace) return false;
  2761. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2762. return true;
  2763. };
  2764. }
  2765. }
  2766. class Projectile {
  2767. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2768. // INIT:
  2769. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2770. this.active = true;
  2771. this.tickActive = true;
  2772. this.indx = indx;
  2773. this.x = x;
  2774. this.y = y;
  2775. this.x2 = x;
  2776. this.y2 = y;
  2777. this.dir = dir;
  2778. this.skipMov = true;
  2779. this.speed = spd;
  2780. this.dmg = dmg;
  2781. this.scale = scl;
  2782. this.range = rng;
  2783. this.r2 = rng;
  2784. this.owner = owner;
  2785. };
  2786. // UPDATE:
  2787. this.update = function(delta) {
  2788. if (this.active) {
  2789. let tmpSpeed = this.speed * delta;
  2790. if (!this.skipMov) {
  2791. this.x += tmpSpeed * Math.cos(this.dir);
  2792. this.y += tmpSpeed * Math.sin(this.dir);
  2793. this.range -= tmpSpeed;
  2794. if (this.range <= 0) {
  2795. this.x += this.range * Math.cos(this.dir);
  2796. this.y += this.range * Math.sin(this.dir);
  2797. tmpSpeed = 1;
  2798. this.range = 0;
  2799. this.active = false;
  2800. }
  2801. } else {
  2802. this.skipMov = false;
  2803. }
  2804. }
  2805. };
  2806. this.tickUpdate = function(delta) {
  2807. if (this.tickActive) {
  2808. let tmpSpeed = this.speed * delta;
  2809. if (!this.skipMov) {
  2810. this.x2 += tmpSpeed * Math.cos(this.dir);
  2811. this.y2 += tmpSpeed * Math.sin(this.dir);
  2812. this.r2 -= tmpSpeed;
  2813. if (this.r2 <= 0) {
  2814. this.x2 += this.r2 * Math.cos(this.dir);
  2815. this.y2 += this.r2 * Math.sin(this.dir);
  2816. tmpSpeed = 1;
  2817. this.r2 = 0;
  2818. this.tickActive = false;
  2819. }
  2820. } else {
  2821. this.skipMov = false;
  2822. }
  2823. }
  2824. };
  2825. }
  2826. };
  2827. class Store {
  2828. constructor() {
  2829. // STORE HATS:
  2830. this.hats = [{
  2831. id: 45,
  2832. name: "Shame!",
  2833. dontSell: true,
  2834. price: 0,
  2835. scale: 120,
  2836. desc: "hacks are for winners"
  2837. }, {
  2838. id: 51,
  2839. name: "Moo Cap",
  2840. price: 0,
  2841. scale: 120,
  2842. desc: "coolest mooer around"
  2843. }, {
  2844. id: 50,
  2845. name: "Apple Cap",
  2846. price: 0,
  2847. scale: 120,
  2848. desc: "apple farms remembers"
  2849. }, {
  2850. id: 28,
  2851. name: "Moo Head",
  2852. price: 0,
  2853. scale: 120,
  2854. desc: "no effect"
  2855. }, {
  2856. id: 29,
  2857. name: "Pig Head",
  2858. price: 0,
  2859. scale: 120,
  2860. desc: "no effect"
  2861. }, {
  2862. id: 30,
  2863. name: "Fluff Head",
  2864. price: 0,
  2865. scale: 120,
  2866. desc: "no effect"
  2867. }, {
  2868. id: 36,
  2869. name: "Pandou Head",
  2870. price: 0,
  2871. scale: 120,
  2872. desc: "no effect"
  2873. }, {
  2874. id: 37,
  2875. name: "Bear Head",
  2876. price: 0,
  2877. scale: 120,
  2878. desc: "no effect"
  2879. }, {
  2880. id: 38,
  2881. name: "Monkey Head",
  2882. price: 0,
  2883. scale: 120,
  2884. desc: "no effect"
  2885. }, {
  2886. id: 44,
  2887. name: "Polar Head",
  2888. price: 0,
  2889. scale: 120,
  2890. desc: "no effect"
  2891. }, {
  2892. id: 35,
  2893. name: "Fez Hat",
  2894. price: 0,
  2895. scale: 120,
  2896. desc: "no effect"
  2897. }, {
  2898. id: 42,
  2899. name: "Enigma Hat",
  2900. price: 0,
  2901. scale: 120,
  2902. desc: "join the enigma army"
  2903. }, {
  2904. id: 43,
  2905. name: "Blitz Hat",
  2906. price: 0,
  2907. scale: 120,
  2908. desc: "hey everybody i'm blitz"
  2909. }, {
  2910. id: 49,
  2911. name: "Bob XIII Hat",
  2912. price: 0,
  2913. scale: 120,
  2914. desc: "like and subscribe"
  2915. }, {
  2916. id: 57,
  2917. name: "Pumpkin",
  2918. price: 50,
  2919. scale: 120,
  2920. desc: "Spooooky"
  2921. }, {
  2922. id: 8,
  2923. name: "Bummle Hat",
  2924. price: 100,
  2925. scale: 120,
  2926. desc: "no effect"
  2927. }, {
  2928. id: 2,
  2929. name: "Straw Hat",
  2930. price: 500,
  2931. scale: 120,
  2932. desc: "no effect"
  2933. }, {
  2934. id: 15,
  2935. name: "Winter Cap",
  2936. price: 600,
  2937. scale: 120,
  2938. desc: "allows you to move at normal speed in snow",
  2939. coldM: 1
  2940. }, {
  2941. id: 5,
  2942. name: "Cowboy Hat",
  2943. price: 1000,
  2944. scale: 120,
  2945. desc: "no effect"
  2946. }, {
  2947. id: 4,
  2948. name: "Ranger Hat",
  2949. price: 2000,
  2950. scale: 120,
  2951. desc: "no effect"
  2952. }, {
  2953. id: 18,
  2954. name: "Explorer Hat",
  2955. price: 2000,
  2956. scale: 120,
  2957. desc: "no effect"
  2958. }, {
  2959. id: 31,
  2960. name: "Flipper Hat",
  2961. price: 2500,
  2962. scale: 120,
  2963. desc: "have more control while in water",
  2964. watrImm: true
  2965. }, {
  2966. id: 1,
  2967. name: "Marksman Cap",
  2968. price: 3000,
  2969. scale: 120,
  2970. desc: "increases arrow speed and range",
  2971. aMlt: 1.3
  2972. }, {
  2973. id: 10,
  2974. name: "Bush Gear",
  2975. price: 3000,
  2976. scale: 160,
  2977. desc: "allows you to disguise yourself as a bush"
  2978. }, {
  2979. id: 48,
  2980. name: "Halo",
  2981. price: 3000,
  2982. scale: 120,
  2983. desc: "no effect"
  2984. }, {
  2985. id: 6,
  2986. name: "Soldier Helmet",
  2987. price: 4000,
  2988. scale: 120,
  2989. desc: "reduces damage taken but slows movement",
  2990. spdMult: 0.94,
  2991. dmgMult: 0.75
  2992. }, {
  2993. id: 23,
  2994. name: "Anti Venom Gear",
  2995. price: 4000,
  2996. scale: 120,
  2997. desc: "makes you immune to poison",
  2998. poisonRes: 1
  2999. }, {
  3000. id: 13,
  3001. name: "Medic Gear",
  3002. price: 5000,
  3003. scale: 110,
  3004. desc: "slowly regenerates health over time",
  3005. healthRegen: 3
  3006. }, {
  3007. id: 9,
  3008. name: "Miners Helmet",
  3009. price: 5000,
  3010. scale: 120,
  3011. desc: "earn 1 extra gold per resource",
  3012. extraGold: 1
  3013. }, {
  3014. id: 32,
  3015. name: "Musketeer Hat",
  3016. price: 5000,
  3017. scale: 120,
  3018. desc: "reduces cost of projectiles",
  3019. projCost: 0.5
  3020. }, {
  3021. id: 7,
  3022. name: "Bull Helmet",
  3023. price: 6000,
  3024. scale: 120,
  3025. desc: "increases damage done but drains health",
  3026. healthRegen: -5,
  3027. dmgMultO: 1.5,
  3028. spdMult: 0.96
  3029. }, {
  3030. id: 22,
  3031. name: "Emp Helmet",
  3032. price: 6000,
  3033. scale: 120,
  3034. desc: "turrets won't attack but you move slower",
  3035. antiTurret: 1,
  3036. spdMult: 0.7
  3037. }, {
  3038. id: 12,
  3039. name: "Booster Hat",
  3040. price: 6000,
  3041. scale: 120,
  3042. desc: "increases your movement speed",
  3043. spdMult: 1.16
  3044. }, {
  3045. id: 26,
  3046. name: "Barbarian Armor",
  3047. price: 8000,
  3048. scale: 120,
  3049. desc: "knocks back enemies that attack you",
  3050. dmgK: 0.6
  3051. }, {
  3052. id: 21,
  3053. name: "Plague Mask",
  3054. price: 10000,
  3055. scale: 120,
  3056. desc: "melee attacks deal poison damage",
  3057. poisonDmg: 5,
  3058. poisonTime: 6
  3059. }, {
  3060. id: 46,
  3061. name: "Bull Mask",
  3062. price: 10000,
  3063. scale: 120,
  3064. desc: "bulls won't target you unless you attack them",
  3065. bullRepel: 1
  3066. }, {
  3067. id: 14,
  3068. name: "Windmill Hat",
  3069. topSprite: true,
  3070. price: 10000,
  3071. scale: 120,
  3072. desc: "generates points while worn",
  3073. pps: 1.5
  3074. }, {
  3075. id: 11,
  3076. name: "Spike Gear",
  3077. topSprite: true,
  3078. price: 10000,
  3079. scale: 120,
  3080. desc: "deal damage to players that damage you",
  3081. dmg: 0.45
  3082. }, {
  3083. id: 53,
  3084. name: "Turret Gear",
  3085. topSprite: true,
  3086. price: 10000,
  3087. scale: 120,
  3088. desc: "you become a walking turret",
  3089. turret: {
  3090. proj: 1,
  3091. range: 700,
  3092. rate: 2500
  3093. },
  3094. spdMult: 0.7
  3095. }, {
  3096. id: 20,
  3097. name: "Samurai Armor",
  3098. price: 12000,
  3099. scale: 120,
  3100. desc: "increased attack speed and fire rate",
  3101. atkSpd: 0.78
  3102. }, {
  3103. id: 58,
  3104. name: "Dark Knight",
  3105. price: 12000,
  3106. scale: 120,
  3107. desc: "restores health when you deal damage",
  3108. healD: 0.4
  3109. }, {
  3110. id: 27,
  3111. name: "Scavenger Gear",
  3112. price: 15000,
  3113. scale: 120,
  3114. desc: "earn double points for each kill",
  3115. kScrM: 2
  3116. }, {
  3117. id: 40,
  3118. name: "Tank Gear",
  3119. price: 15000,
  3120. scale: 120,
  3121. desc: "increased damage to buildings but slower movement",
  3122. spdMult: 0.3,
  3123. bDmg: 3.3
  3124. }, {
  3125. id: 52,
  3126. name: "Thief Gear",
  3127. price: 15000,
  3128. scale: 120,
  3129. desc: "steal half of a players gold when you kill them",
  3130. goldSteal: 0.5
  3131. }, {
  3132. id: 55,
  3133. name: "Bloodthirster",
  3134. price: 20000,
  3135. scale: 120,
  3136. desc: "Restore Health when dealing damage. And increased damage",
  3137. healD: 0.25,
  3138. dmgMultO: 1.2,
  3139. }, {
  3140. id: 56,
  3141. name: "Assassin Gear",
  3142. price: 20000,
  3143. scale: 120,
  3144. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3145. noEat: true,
  3146. spdMult: 1.1,
  3147. invisTimer: 1000
  3148. }];
  3149. // STORE ACCESSORIES:
  3150. this.accessories = [{
  3151. id: 12,
  3152. name: "Snowball",
  3153. price: 1000,
  3154. scale: 105,
  3155. xOff: 18,
  3156. desc: "no effect"
  3157. }, {
  3158. id: 9,
  3159. name: "Tree Cape",
  3160. price: 1000,
  3161. scale: 90,
  3162. desc: "no effect"
  3163. }, {
  3164. id: 10,
  3165. name: "Stone Cape",
  3166. price: 1000,
  3167. scale: 90,
  3168. desc: "no effect"
  3169. }, {
  3170. id: 3,
  3171. name: "Cookie Cape",
  3172. price: 1500,
  3173. scale: 90,
  3174. desc: "no effect"
  3175. }, {
  3176. id: 8,
  3177. name: "Cow Cape",
  3178. price: 2000,
  3179. scale: 90,
  3180. desc: "no effect"
  3181. }, {
  3182. id: 11,
  3183. name: "Monkey Tail",
  3184. price: 2000,
  3185. scale: 97,
  3186. xOff: 25,
  3187. desc: "Super speed but reduced damage",
  3188. spdMult: 1.35,
  3189. dmgMultO: 0.2
  3190. }, {
  3191. id: 17,
  3192. name: "Apple Basket",
  3193. price: 3000,
  3194. scale: 80,
  3195. xOff: 12,
  3196. desc: "slowly regenerates health over time",
  3197. healthRegen: 1
  3198. }, {
  3199. id: 6,
  3200. name: "Winter Cape",
  3201. price: 3000,
  3202. scale: 90,
  3203. desc: "no effect"
  3204. }, {
  3205. id: 4,
  3206. name: "Skull Cape",
  3207. price: 4000,
  3208. scale: 90,
  3209. desc: "no effect"
  3210. }, {
  3211. id: 5,
  3212. name: "Dash Cape",
  3213. price: 5000,
  3214. scale: 90,
  3215. desc: "no effect"
  3216. }, {
  3217. id: 2,
  3218. name: "Dragon Cape",
  3219. price: 6000,
  3220. scale: 90,
  3221. desc: "no effect"
  3222. }, {
  3223. id: 1,
  3224. name: "Super Cape",
  3225. price: 8000,
  3226. scale: 90,
  3227. desc: "no effect"
  3228. }, {
  3229. id: 7,
  3230. name: "Troll Cape",
  3231. price: 8000,
  3232. scale: 90,
  3233. desc: "no effect"
  3234. }, {
  3235. id: 14,
  3236. name: "Thorns",
  3237. price: 10000,
  3238. scale: 115,
  3239. xOff: 20,
  3240. desc: "no effect"
  3241. }, {
  3242. id: 15,
  3243. name: "Blockades",
  3244. price: 10000,
  3245. scale: 95,
  3246. xOff: 15,
  3247. desc: "no effect"
  3248. }, {
  3249. id: 20,
  3250. name: "Devils Tail",
  3251. price: 10000,
  3252. scale: 95,
  3253. xOff: 20,
  3254. desc: "no effect"
  3255. }, {
  3256. id: 16,
  3257. name: "Sawblade",
  3258. price: 12000,
  3259. scale: 90,
  3260. spin: true,
  3261. xOff: 0,
  3262. desc: "deal damage to players that damage you",
  3263. dmg: 0.15
  3264. }, {
  3265. id: 13,
  3266. name: "Angel Wings",
  3267. price: 15000,
  3268. scale: 138,
  3269. xOff: 22,
  3270. desc: "slowly regenerates health over time",
  3271. healthRegen: 3
  3272. }, {
  3273. id: 19,
  3274. name: "Shadow Wings",
  3275. price: 15000,
  3276. scale: 138,
  3277. xOff: 22,
  3278. desc: "increased movement speed",
  3279. spdMult: 1.1
  3280. }, {
  3281. id: 18,
  3282. name: "Blood Wings",
  3283. price: 20000,
  3284. scale: 178,
  3285. xOff: 26,
  3286. desc: "restores health when you deal damage",
  3287. healD: 0.2
  3288. }, {
  3289. id: 21,
  3290. name: "Corrupt X Wings",
  3291. price: 20000,
  3292. scale: 178,
  3293. xOff: 26,
  3294. desc: "deal damage to players that damage you",
  3295. dmg: 0.25
  3296. }];
  3297. }
  3298. };
  3299. class ProjectileManager {
  3300. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3301. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3302. let tmpData = items.projectiles[indx];
  3303. let tmpProj;
  3304. for (let i = 0; i < projectiles.length; ++i) {
  3305. if (!projectiles[i].active) {
  3306. tmpProj = projectiles[i];
  3307. break;
  3308. }
  3309. }
  3310. if (!tmpProj) {
  3311. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3312. tmpProj.sid = projectiles.length;
  3313. projectiles.push(tmpProj);
  3314. }
  3315. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3316. tmpProj.ignoreObj = ignoreObj;
  3317. tmpProj.layer = layer || tmpData.layer;
  3318. tmpProj.inWindow = inWindow;
  3319. tmpProj.src = tmpData.src;
  3320. return tmpProj;
  3321. };
  3322. }
  3323. };
  3324. class AiManager {
  3325. // AI MANAGER:
  3326. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3327. // AI TYPES:
  3328. this.aiTypes = [{
  3329. id: 0,
  3330. src: "cow_1",
  3331. killScore: 150,
  3332. health: 500,
  3333. weightM: 0.8,
  3334. speed: 0.00095,
  3335. turnSpeed: 0.001,
  3336. scale: 72,
  3337. drop: ["food", 50]
  3338. }, {
  3339. id: 1,
  3340. src: "pig_1",
  3341. killScore: 200,
  3342. health: 800,
  3343. weightM: 0.6,
  3344. speed: 0.00085,
  3345. turnSpeed: 0.001,
  3346. scale: 72,
  3347. drop: ["food", 80]
  3348. }, {
  3349. id: 2,
  3350. name: "Bull",
  3351. src: "bull_2",
  3352. hostile: true,
  3353. dmg: 20,
  3354. killScore: 1000,
  3355. health: 1800,
  3356. weightM: 0.5,
  3357. speed: 0.00094,
  3358. turnSpeed: 0.00074,
  3359. scale: 78,
  3360. viewRange: 800,
  3361. chargePlayer: true,
  3362. drop: ["food", 100]
  3363. }, {
  3364. id: 3,
  3365. name: "Bully",
  3366. src: "bull_1",
  3367. hostile: true,
  3368. dmg: 20,
  3369. killScore: 2000,
  3370. health: 2800,
  3371. weightM: 0.45,
  3372. speed: 0.001,
  3373. turnSpeed: 0.0008,
  3374. scale: 90,
  3375. viewRange: 900,
  3376. chargePlayer: true,
  3377. drop: ["food", 400]
  3378. }, {
  3379. id: 4,
  3380. name: "Wolf",
  3381. src: "wolf_1",
  3382. hostile: true,
  3383. dmg: 8,
  3384. killScore: 500,
  3385. health: 300,
  3386. weightM: 0.45,
  3387. speed: 0.001,
  3388. turnSpeed: 0.002,
  3389. scale: 84,
  3390. viewRange: 800,
  3391. chargePlayer: true,
  3392. drop: ["food", 200]
  3393. }, {
  3394. id: 5,
  3395. name: "Quack",
  3396. src: "chicken_1",
  3397. dmg: 8,
  3398. killScore: 2000,
  3399. noTrap: true,
  3400. health: 300,
  3401. weightM: 0.2,
  3402. speed: 0.0018,
  3403. turnSpeed: 0.006,
  3404. scale: 70,
  3405. drop: ["food", 100]
  3406. }, {
  3407. id: 6,
  3408. name: "MOOSTAFA",
  3409. nameScale: 50,
  3410. src: "enemy",
  3411. hostile: true,
  3412. dontRun: true,
  3413. fixedSpawn: true,
  3414. spawnDelay: 60000,
  3415. noTrap: true,
  3416. colDmg: 100,
  3417. dmg: 40,
  3418. killScore: 8000,
  3419. health: 18000,
  3420. weightM: 0.4,
  3421. speed: 0.0007,
  3422. turnSpeed: 0.01,
  3423. scale: 80,
  3424. spriteMlt: 1.8,
  3425. leapForce: 0.9,
  3426. viewRange: 1000,
  3427. hitRange: 210,
  3428. hitDelay: 1000,
  3429. chargePlayer: true,
  3430. drop: ["food", 100]
  3431. }, {
  3432. id: 7,
  3433. name: "Treasure",
  3434. hostile: true,
  3435. nameScale: 35,
  3436. src: "crate_1",
  3437. fixedSpawn: true,
  3438. spawnDelay: 120000,
  3439. colDmg: 200,
  3440. killScore: 5000,
  3441. health: 20000,
  3442. weightM: 0.1,
  3443. speed: 0.0,
  3444. turnSpeed: 0.0,
  3445. scale: 70,
  3446. spriteMlt: 1.0
  3447. }, {
  3448. id: 8,
  3449. name: "MOOFIE",
  3450. src: "wolf_2",
  3451. hostile: true,
  3452. fixedSpawn: true,
  3453. dontRun: true,
  3454. hitScare: 4,
  3455. spawnDelay: 30000,
  3456. noTrap: true,
  3457. nameScale: 35,
  3458. dmg: 10,
  3459. colDmg: 100,
  3460. killScore: 3000,
  3461. health: 7000,
  3462. weightM: 0.45,
  3463. speed: 0.0015,
  3464. turnSpeed: 0.002,
  3465. scale: 90,
  3466. viewRange: 800,
  3467. chargePlayer: true,
  3468. drop: ["food", 1000]
  3469. }];
  3470. // SPAWN AI:
  3471. this.spawn = function(x, y, dir, index) {
  3472. let tmpObj = ais.find((tmp) => !tmp.active);
  3473. if (!tmpObj) {
  3474. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3475. ais.push(tmpObj);
  3476. }
  3477. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3478. return tmpObj;
  3479. };
  3480. }
  3481. };
  3482. class AI {
  3483. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3484. this.sid = sid;
  3485. this.isAI = true;
  3486. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3487. // INIT:
  3488. this.init = function(x, y, dir, index, data) {
  3489. this.x = x;
  3490. this.y = y;
  3491. this.startX = data.fixedSpawn ? x : null;
  3492. this.startY = data.fixedSpawn ? y : null;
  3493. this.xVel = 0;
  3494. this.yVel = 0;
  3495. this.zIndex = 0;
  3496. this.dir = dir;
  3497. this.dirPlus = 0;
  3498. this.index = index;
  3499. this.src = data.src;
  3500. if (data.name) this.name = data.name;
  3501. this.weightM = data.weightM;
  3502. this.speed = data.speed;
  3503. this.killScore = data.killScore;
  3504. this.turnSpeed = data.turnSpeed;
  3505. this.scale = data.scale;
  3506. this.maxHealth = data.health;
  3507. this.leapForce = data.leapForce;
  3508. this.health = this.maxHealth;
  3509. this.chargePlayer = data.chargePlayer;
  3510. this.viewRange = data.viewRange;
  3511. this.drop = data.drop;
  3512. this.dmg = data.dmg;
  3513. this.hostile = data.hostile;
  3514. this.dontRun = data.dontRun;
  3515. this.hitRange = data.hitRange;
  3516. this.hitDelay = data.hitDelay;
  3517. this.hitScare = data.hitScare;
  3518. this.spriteMlt = data.spriteMlt;
  3519. this.nameScale = data.nameScale;
  3520. this.colDmg = data.colDmg;
  3521. this.noTrap = data.noTrap;
  3522. this.spawnDelay = data.spawnDelay;
  3523. this.hitWait = 0;
  3524. this.waitCount = 1000;
  3525. this.moveCount = 0;
  3526. this.targetDir = 0;
  3527. this.active = true;
  3528. this.alive = true;
  3529. this.runFrom = null;
  3530. this.chargeTarget = null;
  3531. this.dmgOverTime = {};
  3532. };
  3533. let tmpRatio = 0;
  3534. let animIndex = 0;
  3535. this.animate = function(delta) {
  3536. if (this.animTime > 0) {
  3537. this.animTime -= delta;
  3538. if (this.animTime <= 0) {
  3539. this.animTime = 0;
  3540. this.dirPlus = 0;
  3541. tmpRatio = 0;
  3542. animIndex = 0;
  3543. } else {
  3544. if (animIndex == 0) {
  3545. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3546. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3547. if (tmpRatio >= 1) {
  3548. tmpRatio = 1;
  3549. animIndex = 1;
  3550. }
  3551. } else {
  3552. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3553. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3554. }
  3555. }
  3556. }
  3557. };
  3558. // ANIMATION:
  3559. this.startAnim = function() {
  3560. this.animTime = this.animSpeed = 600;
  3561. this.targetAngle = Math.PI * 0.8;
  3562. tmpRatio = 0;
  3563. animIndex = 0;
  3564. };
  3565. };
  3566. };
  3567. class addCh {
  3568. constructor(x, y, chat, tmpObj) {
  3569. this.x = x;
  3570. this.y = y;
  3571. this.alpha = 0;
  3572. this.active = true;
  3573. this.alive = false;
  3574. this.chat = chat;
  3575. this.owner = tmpObj;
  3576. };
  3577. };
  3578. class DeadPlayer {
  3579. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3580. this.x = x;
  3581. this.y = y;
  3582. this.lastDir = dir;
  3583. this.dir = dir + Math.PI;
  3584. this.buildIndex = buildIndex;
  3585. this.weaponIndex = weaponIndex;
  3586. this.weaponVariant = weaponVariant;
  3587. this.skinColor = skinColor;
  3588. this.scale = scale;
  3589. this.visScale = 0;
  3590. this.name = name;
  3591. this.alpha = 1;
  3592. this.active = true;
  3593. this.animate = function(delta) {
  3594. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3595. if (d2 > 0.01) {
  3596. this.dir += d2 / 20;
  3597. } else {
  3598. this.dir = this.lastDir;
  3599. }
  3600. if (this.visScale < this.scale) {
  3601. this.visScale += delta / (this.scale / 2);
  3602. if (this.visScale >= this.scale) {
  3603. this.visScale = this.scale;
  3604. }
  3605. }
  3606. this.alpha -= delta / 30000;
  3607. if (this.alpha <= 0) {
  3608. this.alpha = 0;
  3609. this.active = false;
  3610. }
  3611. }
  3612. }
  3613. };
  3614. class Player {
  3615. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3616. this.id = id;
  3617. this.sid = sid;
  3618. this.tmpScore = 0;
  3619. this.team = null;
  3620. this.latestSkin = 0;
  3621. this.oldSkinIndex = 0;
  3622. this.skinIndex = 0;
  3623. this.latestTail = 0;
  3624. this.oldTailIndex = 0;
  3625. this.tailIndex = 0;
  3626. this.hitTime = 0;
  3627. this.lastHit = 0;
  3628. this.tails = {};
  3629. for (let i = 0; i < accessories.length; ++i) {
  3630. if (accessories[i].price <= 0)
  3631. this.tails[accessories[i].id] = 1;
  3632. }
  3633. this.skins = {};
  3634. for (let i = 0; i < hats.length; ++i) {
  3635. if (hats[i].price <= 0)
  3636. this.skins[hats[i].id] = 1;
  3637. }
  3638. this.points = 0;
  3639. this.dt = 0;
  3640. this.hidden = false;
  3641. this.itemCounts = {};
  3642. this.isPlayer = true;
  3643. this.pps = 0;
  3644. this.moveDir = undefined;
  3645. this.skinRot = 0;
  3646. this.lastPing = 0;
  3647. this.iconIndex = 0;
  3648. this.skinColor = 0;
  3649. this.dist2 = 0;
  3650. this.aim2 = 0;
  3651. this.maxSpeed = 1;
  3652. this.chat = {
  3653. message: null,
  3654. count: 0
  3655. };
  3656. this.backupNobull = true;
  3657. this.circle = false;
  3658. this.circleRad = 200;
  3659. this.circleRadSpd = 0.1;
  3660. this.cAngle = 0;
  3661. // SPAWN:
  3662. this.spawn = function(moofoll) {
  3663. this.attacked = false;
  3664. this.death = false;
  3665. this.spinDir = 0;
  3666. this.sync = false;
  3667. this.antiBull = 0;
  3668. this.bullTimer = 0;
  3669. this.poisonTimer = 0;
  3670. this.active = true;
  3671. this.alive = true;
  3672. this.lockMove = false;
  3673. this.lockDir = false;
  3674. this.minimapCounter = 0;
  3675. this.chatCountdown = 0;
  3676. this.shameCount = 0;
  3677. this.shameTimer = 0;
  3678. this.sentTo = {};
  3679. this.gathering = 0;
  3680. this.gatherIndex = 0;
  3681. this.shooting = {};
  3682. this.shootIndex = 9;
  3683. this.autoGather = 0;
  3684. this.animTime = 0;
  3685. this.animSpeed = 0;
  3686. this.mouseState = 0;
  3687. this.buildIndex = -1;
  3688. this.weaponIndex = 0;
  3689. this.weaponCode = 0;
  3690. this.weaponVariant = 0;
  3691. this.primaryIndex = undefined;
  3692. this.secondaryIndex = undefined;
  3693. this.dmgOverTime = {};
  3694. this.noMovTimer = 0;
  3695. this.maxXP = 300;
  3696. this.XP = 0;
  3697. this.age = 1;
  3698. this.kills = 0;
  3699. this.upgrAge = 2;
  3700. this.upgradePoints = 0;
  3701. this.x = 0;
  3702. this.y = 0;
  3703. this.oldXY = {
  3704. x: 0,
  3705. y: 0
  3706. };
  3707. this.zIndex = 0;
  3708. this.xVel = 0;
  3709. this.yVel = 0;
  3710. this.slowMult = 1;
  3711. this.dir = 0;
  3712. this.dirPlus = 0;
  3713. this.targetDir = 0;
  3714. this.targetAngle = 0;
  3715. this.maxHealth = 100;
  3716. this.health = this.maxHealth;
  3717. this.oldHealth = this.maxHealth;
  3718. this.damaged = 0;
  3719. this.scale = config.playerScale;
  3720. this.speed = config.playerSpeed;
  3721. this.resetMoveDir();
  3722. this.resetResources(moofoll);
  3723. this.items = [0, 3, 6, 10];
  3724. this.weapons = [0];
  3725. this.shootCount = 0;
  3726. this.weaponXP = [];
  3727. this.reloads = {
  3728. 0: 0,
  3729. 1: 0,
  3730. 2: 0,
  3731. 3: 0,
  3732. 4: 0,
  3733. 5: 0,
  3734. 6: 0,
  3735. 7: 0,
  3736. 8: 0,
  3737. 9: 0,
  3738. 10: 0,
  3739. 11: 0,
  3740. 12: 0,
  3741. 13: 0,
  3742. 14: 0,
  3743. 15: 0,
  3744. 53: 0,
  3745. };
  3746. this.bowThreat = {
  3747. 9: 0,
  3748. 12: 0,
  3749. 13: 0,
  3750. 15: 0,
  3751. };
  3752. this.damageThreat = 0;
  3753. this.inTrap = false;
  3754. this.canEmpAnti = false;
  3755. this.empAnti = false;
  3756. this.soldierAnti = false;
  3757. this.poisonTick = 0;
  3758. this.bullTick = 0;
  3759. this.setPoisonTick = false;
  3760. this.setBullTick = false;
  3761. this.antiTimer = 2;
  3762. };
  3763. // RESET MOVE DIR:
  3764. this.resetMoveDir = function() {
  3765. this.moveDir = undefined;
  3766. };
  3767. // RESET RESOURCES:
  3768. this.resetResources = function(moofoll) {
  3769. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3770. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3771. }
  3772. };
  3773. // ADD ITEM:
  3774. this.getItemType = function(id) {
  3775. let findindx = this.items.findIndex((ids) => ids == id);
  3776. if (findindx != -1) {
  3777. return findindx;
  3778. } else {
  3779. return items.checkItem.index(id, this.items);
  3780. }
  3781. };
  3782. // SET DATA:
  3783. this.setData = function(data) {
  3784. this.id = data[0];
  3785. this.sid = data[1];
  3786. this.name = data[2];
  3787. this.x = data[3];
  3788. this.y = data[4];
  3789. this.dir = data[5];
  3790. this.health = data[6];
  3791. this.maxHealth = data[7];
  3792. this.scale = data[8];
  3793. this.skinColor = data[9];
  3794. };
  3795. // UPDATE POISON TICK:
  3796. this.updateTimer = function() {
  3797. this.bullTimer -= 1;
  3798. if (this.bullTimer <= 0) {
  3799. this.setBullTick = false;
  3800. this.bullTick = game.tick - 1;
  3801. this.bullTimer = config.serverUpdateRate;
  3802. }
  3803. this.poisonTimer -= 1;
  3804. if (this.poisonTimer < 0) {
  3805. this.setPoisonTick = false;
  3806. this.poisonTick = game.tick - 1;
  3807. this.poisonTimer = config.serverUpdateRate;
  3808. plaguemask = true;
  3809. setTimeout(() => {
  3810. plaguemask = false;
  3811. }, 1000);
  3812. } else if(this.poisonTimer >= 0) {
  3813. plaguemask = false;
  3814. }
  3815. };
  3816. this.update = function(delta) {
  3817. if (this.alive) {
  3818. if (this.health != this.healthMov) {
  3819. this.health < this.healthMov ? (this.healthMov -= 2) : (this.healthMov += 2);
  3820. if (Math.abs(this.health - this.healthMov) < 2) this.healthMov = this.health;
  3821. };
  3822. 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);
  3823. }
  3824. if (this.sid == playerSID) {
  3825. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  3826. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  3827. this.cAngle += this.circleRadSpd;
  3828. }
  3829. if (this.active) {
  3830. // MOVE:
  3831. let gear = {
  3832. skin: findID(hats, this.skinIndex),
  3833. tail: findID(accessories, this.tailIndex)
  3834. }
  3835. 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;
  3836. this.maxSpeed = spdMult;
  3837. }
  3838. };
  3839. let tmpRatio = 0;
  3840. let animIndex = 0;
  3841. this.animate = function(delta) {
  3842. if (this.animTime > 0) {
  3843. this.animTime -= delta;
  3844. if (this.animTime <= 0) {
  3845. this.animTime = 0;
  3846. this.dirPlus = 0;
  3847. tmpRatio = 0;
  3848. animIndex = 0;
  3849. } else {
  3850. if (animIndex == 0) {
  3851. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3852. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3853. if (tmpRatio >= 1) {
  3854. tmpRatio = 1;
  3855. animIndex = 1;
  3856. }
  3857. } else {
  3858. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3859. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3860. }
  3861. }
  3862. }
  3863. };
  3864. // GATHER ANIMATION:
  3865. this.startAnim = function(didHit, index) {
  3866. this.animTime = this.animSpeed = items.weapons[index].speed;
  3867. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3868. tmpRatio = 0;
  3869. animIndex = 0;
  3870. };
  3871. // CAN SEE:
  3872. this.canSee = function(other) {
  3873. if (!other) return false;
  3874. let dx = Math.abs(other.x - this.x) - other.scale;
  3875. let dy = Math.abs(other.y - this.y) - other.scale;
  3876. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3877. };
  3878. // SHAME SYSTEM:
  3879. this.judgeShame = function() {
  3880. if (this.oldHealth < this.health) {
  3881. if (this.hitTime) {
  3882. let timeSinceHit = Date.now() - this.hitTime;
  3883. this.lastHit = game.tick;
  3884. this.hitTime = 0;
  3885. if (timeSinceHit < 120) {
  3886. this.shameCount++;
  3887. } else {
  3888. this.shameCount = Math.max(0, this.shameCount - 2);
  3889. }
  3890. }
  3891. } else if (this.oldHealth > this.health) {
  3892. this.hitTime = Date.now();
  3893. }
  3894. };
  3895. this.addShameTimer = function() {
  3896. this.shameCount = 0;
  3897. this.shameTimer = 30;
  3898. let interval = setInterval(() => {
  3899. this.shameTimer--;
  3900. if (this.shameTimer <= 0) {
  3901. clearInterval(interval);
  3902. }
  3903. }, 1000);
  3904. };
  3905. // CHECK TEAM:
  3906. this.isTeam = function(tmpObj) {
  3907. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  3908. };
  3909. // FOR THE PLAYER:
  3910. this.findAllianceBySid = function(sid) {
  3911. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  3912. };
  3913. this.checkCanInsta = function(nobull) {
  3914. let totally = 0;
  3915. if (this.alive && inGame) {
  3916. let primary = {
  3917. weapon: this.weapons[0],
  3918. variant: this.primaryVariant,
  3919. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  3920. };
  3921. let secondary = {
  3922. weapon: this.weapons[1],
  3923. variant: this.secondaryVariant,
  3924. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  3925. };
  3926. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  3927. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  3928. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  3929. totally += primary.dmg * pV * bull;
  3930. }
  3931. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  3932. totally += secondary.dmg;
  3933. }
  3934. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  3935. totally += 25;
  3936. }
  3937. totally *= near.skinIndex == 6 ? 0.75 : 1;
  3938. return totally;
  3939. }
  3940. return 0;
  3941. };
  3942. // UPDATE WEAPON RELOAD:
  3943. this.manageReload = function() {
  3944. if (this.shooting[53]) {
  3945. this.shooting[53] = 0;
  3946. this.reloads[53] = (2500 - game.tickRate);
  3947. } else {
  3948. if (this.reloads[53] > 0) {
  3949. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  3950. }
  3951. }
  3952. if (this.gathering || this.shooting[1]) {
  3953. if (this.gathering) {
  3954. this.gathering = 0;
  3955. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  3956. this.attacked = true;
  3957. }
  3958. if (this.shooting[1]) {
  3959. this.shooting[1] = 0;
  3960. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  3961. this.attacked = true;
  3962. }
  3963. } else {
  3964. this.attacked = false;
  3965. if (this.buildIndex < 0) {
  3966. if (this.reloads[this.weaponIndex] > 0) {
  3967. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  3968. if (this == player) {
  3969. if (getEl("weaponGrind").checked) {
  3970. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  3971. checkPlace(player.getItemType(22), i);
  3972. }
  3973. }
  3974. }
  3975. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  3976. this.antiBull++;
  3977. game.tickBase(() => {
  3978. this.antiBull = 0;
  3979. }, 1);
  3980. }
  3981. }
  3982. }
  3983. }
  3984. };
  3985. // FOR ANTI INSTA:
  3986. this.addDamageThreat = function(tmpObj) {
  3987. let primary = {
  3988. weapon: this.primaryIndex,
  3989. variant: this.primaryVariant
  3990. };
  3991. let secondary = {
  3992. weapon: this.secondaryIndex,
  3993. variant: this.secondaryVariant
  3994. };
  3995. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  3996. secondary.dmg = secondary.weapon == undefined ? 50 : 10 ? items.weapons[secondary.weapon].Pdmg : items.weapons[secondary.weapon].Pdmg;
  3997. let bull = 1.5;
  3998. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  3999. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4000. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] <= ping*2) {
  4001. this.mostDamageThreat += primary.dmg * pV * bull;
  4002. if (this.reloads[primary.weapon] <= ping) {
  4003. this.damageThreat += primary.dmg * pV * bull;
  4004. }
  4005. }
  4006. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] <= ping * 2) {
  4007. this.mostDamageThreat += secondary.dmg * sV;
  4008. if (this.reloads[secondary.weapon] <= ping) {
  4009. this.damageThreat += secondary.dmg * sV;
  4010. }
  4011. }
  4012. if (this.reloads[53] <= game.tickRate + ping) {
  4013. this.damageThreat += 25;
  4014. this.mostDamageThreat += 25;
  4015. }
  4016. if (traps.checkSpikeTick()) {
  4017. this.damageThreat += secondary.weapon == 10 ? 34 : 26
  4018. this.mostDamageThreat += secondary.weapon == 10 ? 34 : 26
  4019. }
  4020. this.damageThreat *= player.skinIndex == 6 && !clicks.left && !clicks.right && !traps.inTrap ? 0.75 : 1;
  4021. if (!this.isTeam(tmpObj)) {
  4022. if (this.dist2 <= 300) {
  4023. tmpObj.damageThreat += this.damageThreat;
  4024. tmpObj.mostDamageThreat += this.mostDamageThreat
  4025. }
  4026. }
  4027. };
  4028. }
  4029. };
  4030. // SOME CODES:
  4031. function sendUpgrade(index) {
  4032. player.reloads[index] = 0;
  4033. packet("H", index);
  4034. }
  4035. function storeEquip(id, index) {
  4036. packet("c", 0, id, index);
  4037. }
  4038. function storeBuy(id, index) {
  4039. packet("c", 1, id, index);
  4040. }
  4041.  
  4042. function buyEquip(id, index) {
  4043. let nID = player.skins[6] ? 6 : 0;
  4044. if (player.alive && inGame) {
  4045. if (index == 0) {
  4046. if (player.skins[id]) {
  4047. if (player.latestSkin != id) {
  4048. packet("c", 0, id, 0);
  4049. }
  4050. } else {
  4051. if (configs.autoBuyEquip) {
  4052. let find = findID(hats, id);
  4053. if (find) {
  4054. if (player.points >= find.price) {
  4055. //setTimeout(()=>{
  4056. packet("c", 1, id, 0);
  4057. //setTimeout(()=>{
  4058. packet("c", 0, id, 0);
  4059. //}, 120);
  4060. //}, 120);
  4061. } else {
  4062. if (player.latestSkin != nID) {
  4063. packet("c", 0, nID, 0);
  4064. }
  4065. }
  4066. } else {
  4067. if (player.latestSkin != nID) {
  4068. packet("c", 0, nID, 0);
  4069. }
  4070. }
  4071. } else {
  4072. if (player.latestSkin != nID) {
  4073. packet("c", 0, nID, 0);
  4074. }
  4075. }
  4076. }
  4077. } else if (index == 1) {
  4078. if (player.tails[id]) {
  4079. if (player.latestTail != id) {
  4080. packet("c", 0, id, 1);
  4081. }
  4082. } else {
  4083. if (configs.autoBuyEquip) {
  4084. let find = findID(accessories, id);
  4085. if (find) {
  4086. if (player.points >= find.price) {
  4087. packet("c", 1, id, 1);
  4088. // setTimeout(()=>{
  4089. packet("c", 0, id, 1);
  4090. //}, 120);
  4091. } else {
  4092. if (player.latestTail != 0) {
  4093. packet("c", 0, 0, 1);
  4094. }
  4095. }
  4096. } else {
  4097. if (player.latestTail != 0) {
  4098. packet("c", 0, 0, 1);
  4099. }
  4100. }
  4101. } else {
  4102. if (player.latestTail != 0) {
  4103. packet("c", 0, 0, 1);
  4104. }
  4105. }
  4106. }
  4107. }
  4108. }
  4109. }
  4110. function selectToBuild(index, wpn) {
  4111. packet("G", index, wpn);
  4112. }
  4113. function selectWeapon(index, isPlace) {
  4114. if (!isPlace) {
  4115. player.weaponCode = index;
  4116. }
  4117. packet("G", index, 1);
  4118. }
  4119. function sendAutoGather() {
  4120. packet("K", 1, 1);
  4121. }
  4122. function sendAtck(id, angle) {
  4123. packet("d", id, angle, 1);
  4124. }
  4125. function toRadian(angle) {
  4126. let fixedAngle = (angle % 360) * (Math.PI / 180);
  4127. return fixedAngle < 0 ? (2 * Math.PI + fixedAngle) : fixedAngle;
  4128. }
  4129. function Hg(e, t){
  4130. buyEquip(e, 0);
  4131. buyEquip(t, 1);
  4132. }
  4133.  
  4134. // PLACER:
  4135. function place(id, rad, rmd) {
  4136. try {
  4137. if (id == undefined) return;
  4138. let item = items.list[player.items[id]];
  4139. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4140. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4141. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4142. 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))) {
  4143. selectToBuild(player.items[id]);
  4144. sendAtck(1, rad);
  4145. selectWeapon(player.weaponCode, 1);
  4146. if (rmd && getEl("renderplace").value == "placeVis") {
  4147. placeVisible.push({
  4148. x: tmpX,
  4149. y: tmpY,
  4150. name: item.name,
  4151. scale: item.scale,
  4152. dir: rad
  4153. });
  4154. game.tickBase(() => {
  4155. placeVisible.shift();
  4156. }, 1)
  4157. }
  4158. if (rmd && getEl("renderplace").value == "outline") {
  4159. placeVisible.push({
  4160. x: tmpX,
  4161. y: tmpY,
  4162. name: item.name,
  4163. scale: item.scale,
  4164. dir: rad
  4165. });
  4166. game.tickBase(() => {
  4167. placeVisible.shift();
  4168. }, 1)
  4169. }
  4170. if (rmd && getEl("previs").checked) {
  4171. preplaceVisible.push({
  4172. x: tmpX,
  4173. y: tmpY,
  4174. name: item.name,
  4175. scale: item.scale,
  4176. dir: rad
  4177. });
  4178. game.tickBase(() => {
  4179. preplaceVisible.shift();
  4180. }, 1)
  4181.  
  4182.  
  4183.  
  4184.  
  4185. }
  4186. }
  4187. } catch (e) {}
  4188. }
  4189.  
  4190. function getDist(e, t) {
  4191. try {
  4192. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4193. } catch (e) {
  4194. return Infinity;
  4195. }
  4196. }
  4197. // GET DIRECTION
  4198. function getDir(e, t) {
  4199. try {
  4200. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4201. } catch (e) {
  4202. return 0;
  4203. }
  4204. }
  4205.  
  4206. function sortFromSmallest(arr, func) { // dist - dist
  4207. func = typeof func == "function" ? func : (obj) => {
  4208. return obj
  4209. };
  4210. return arr.sort((two, one) => (func(two)) - func(one));
  4211. }
  4212. /*
  4213. tmpList = objectManager.getGridArrays(user.x2, user.y2, 500);
  4214. for (var x = 0; x < tmpList.length; ++x) {
  4215. for (var y = 0; y < tmpList[x].length; ++y) {
  4216. if (tmpList[x][y].active && getDist(player, tmpList[x][y]))
  4217. }
  4218. }
  4219. */
  4220. function getCloseBuildings() {
  4221. let buildings = [];
  4222. let addedBefore = {};
  4223. let filteredBuildings = objectManager.getGridArrays(player.x, player.y, 200);
  4224. //console.log(filteredBuildings);
  4225. for (var x = 0; x < filteredBuildings.length; ++x) {
  4226. for (var y = 0; y < filteredBuildings[x].length; ++y) {
  4227. if (filteredBuildings[x][y].active) {
  4228. buildings.push(filteredBuildings[x][y]);
  4229. }
  4230. }
  4231. }
  4232. //console.log(buildings);
  4233. return buildings;
  4234. }
  4235. function quadSpikeBreak(user, item) {
  4236. try {
  4237. let angles = [];
  4238. let possibleOnes = [];
  4239. for (let angle = 0; angle < 72; angle++) {
  4240. angles.push(toRadian(angle * 5));
  4241. }
  4242. let buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && t.sid != player.inTrap.sid && getDist(player, t) <= 150), (a)=>{
  4243. return getDist(player, a);
  4244. });
  4245. let last = null;
  4246. for (let angle of angles) {
  4247. let position = player.buildItemPosition(item, angle);
  4248. let possibleToPlace = true;
  4249. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4250. possibleToPlace = false;
  4251. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4252. possibleToPlace = false;
  4253. } else {
  4254. for (let building of buildings_) {
  4255. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4256. if (getDist(building, position) < item.scale + range) { // overlap
  4257. possibleToPlace = false;
  4258. last = building;
  4259. break;
  4260. }
  4261. }
  4262. }
  4263. if (possibleToPlace) {
  4264. possibleOnes.push(angle);
  4265. }
  4266. }
  4267. return possibleOnes;
  4268. } catch (e) {
  4269. //console.log(e);
  4270. }
  4271. }
  4272. function getPlaceablePositions(user, item) {
  4273. try {
  4274. let angles = [];
  4275. let possibleOnes = [];
  4276. for (let angle = 0; angle < 72; angle++) {
  4277. angles.push(toRadian(angle * 5));
  4278. }
  4279. let buildings_ = [];
  4280. if (!window.isMohMoh) {
  4281. buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && getDist(player, t) <= 150), (a)=>{
  4282. return getDist(player, a);
  4283. });
  4284. }
  4285. let last = null;
  4286. for (let angle of angles) {
  4287. let position = player.buildItemPosition(item, angle);
  4288. let possibleToPlace = true;
  4289. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4290. possibleToPlace = false;
  4291. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4292. possibleToPlace = false;
  4293. } else if (true) {
  4294. for (let building of buildings_) {
  4295. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4296. if (getDist(building, position) < item.scale + range) { // overlap
  4297. possibleToPlace = false;
  4298. last = building;
  4299. break;
  4300. }
  4301. }
  4302. }
  4303. if (possibleToPlace) {
  4304. possibleOnes.push(angle);
  4305. }
  4306. }
  4307. return possibleOnes;
  4308. } catch (e) {
  4309. //console.log(e);
  4310. }
  4311. }
  4312. let firstCheckPlaceForntiBUg = false;
  4313. function simplePlace(id, radian) {
  4314. checkPlace(id, radian);
  4315. };
  4316.  
  4317.  
  4318. function checkPlace(id, rad) {
  4319. try {
  4320. if (secPacket.count >= 80) return;
  4321. //if (id == undefined) return;
  4322. let item = items.list[player.items[id]];
  4323. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4324. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4325. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4326. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4327. place(id, rad, 1);
  4328. }
  4329. } catch (e) {}
  4330. }
  4331. // Preplacer
  4332. let preplaceDelay = {
  4333. killObject: -1,
  4334. gatherAnimation: -1,
  4335. total: function () {
  4336. return new Date - Math.abs(Math.trunc(this.killObject - this.gatherAnimation))
  4337. }
  4338. };
  4339.  
  4340. function getDist(e, t) {
  4341. try {
  4342. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4343. }
  4344. catch (e) {
  4345. return 1 / 0
  4346. }
  4347. }
  4348.  
  4349. function getDir(e, t) {
  4350. try {
  4351. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4352. }
  4353. catch (e) {
  4354. return 0
  4355. }
  4356. }
  4357. var preplaceOverride = !1;
  4358.  
  4359. function caf(e, t) {
  4360. try {
  4361. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4362. }
  4363. catch (e) {
  4364. return 0
  4365. }
  4366. }
  4367.  
  4368. function cdf(e, t) {
  4369. try {
  4370. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4371. }
  4372. catch (e) {
  4373. return 1 / 0
  4374. }
  4375. }
  4376.  
  4377. function numArr(e = 0, t = 1, i, a = 1) {
  4378. let n = [];
  4379. for (let s = e; s < t; s += a) n.push(s), "function" == typeof i && i(s);
  4380. return n
  4381. }
  4382.  
  4383. function toR(e) {
  4384. var t = e * Math.PI / 180 % (2 * Math.PI);
  4385. return t > Math.PI ? Math.PI - t : t
  4386. }
  4387.  
  4388. function toD(e) {
  4389. var t = e / Math.PI * 360 % 360;
  4390. return t >= 360 ? t - 360 : t
  4391. }
  4392. // HEALING:
  4393. function soldierMult() {
  4394. return player.latestSkin == 6 ? 0.75 : 1;
  4395. }
  4396. function getAttacker(damaged) {
  4397. let attackers = enemy.filter(tmp => {
  4398. //let damages = new Damages(items);
  4399. //let dmg = damages.weapons[tmp.weaponIndex];
  4400. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4401. let rule = {
  4402. //one: tmp.dist2 <= 300,
  4403. //two: by.includes(damaged),
  4404. three: tmp.attacked
  4405. }
  4406. return /*rule.one && rule.two && */rule.three;
  4407. });
  4408. return attackers;
  4409. }
  4410. function healer() {
  4411. for (let i = 0; i < healthBased(); i++) {
  4412. place(0, getAttackDir());
  4413. }
  4414. }
  4415. // ADVANCED:
  4416. function applCxC(value) {
  4417. if (player.health == 100)
  4418. return 0;
  4419. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4420. return Math.ceil(value / items.list[player.items[0]].healing);
  4421. }
  4422. return 0;
  4423. }
  4424. function healthBased() {
  4425. if (player.health == 100)
  4426. return 0;
  4427. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4428. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4429. }
  4430. return 0;
  4431. }
  4432. function calcDmg(value) {
  4433. return value * player.skinIndex == 6 ? 0.75 : 1;
  4434. }
  4435. function antirev() {
  4436. if (tmpObj.isPlayer){
  4437. for (let i = 0; i < healthBased(); i++) {
  4438. place(0, getAttackDir());
  4439. if (player.health == 55 && player.shameCount < 6 && player.skinIndex == 6) {
  4440. place(0, getAttackDir());
  4441. notif("antirev");
  4442. } else if (player.health == 40 && player.shameCount < 6 && player.skinIndex != 6){
  4443. place(0, getAttackDir());
  4444. notif("antirev");
  4445. } else if (player.health == 43.75 && player.shameCount < 5 && player.skinIndex == 6){
  4446. place(0, getAttackDir());
  4447. setTimeout(()=>{
  4448. place(0, getAttackDir());
  4449. },5)
  4450. } else if(player.health == 25 && player.shameCount < 4 && player.skinIndex == 6){
  4451. place(0, getAttackDir());
  4452. setTimeout(()=>{
  4453. place(0, getAttackDir());
  4454. },5)
  4455. } else if (player.health == 58.75 && player.shameCount < 6 && player.skinIndex == 6){
  4456. place(0, getAttackDir());
  4457. setTimeout(()=>{
  4458. place(0, getAttackDir());
  4459. },5)
  4460. } else if (player.health == 45 && player.shameCount < 6 && player.skinIndex != 6){
  4461. place(0, getAttackDir());
  4462. setTimeout(()=>{
  4463. place(0, getAttackDir());
  4464. },5)
  4465. }
  4466. if (player.shameCount < 6) {
  4467. setTimeout(()=>{
  4468. place(0, getAttackDir());
  4469. },30)
  4470. }
  4471. }
  4472. }
  4473. }
  4474. let slowHeal = function(timer) {
  4475. setTimeout(() => {
  4476. healer();
  4477. }, 25);
  4478. }
  4479. let isHealing = false;
  4480. let delay = 20;
  4481. function uziheal() {
  4482. if (!isHealing && player.health < 100) {
  4483. isHealing = true;
  4484. if (player.health < 70) {
  4485. place(0, getAttackDir());
  4486. healer();// fast heal
  4487. isHealing = false;
  4488. } else {
  4489. const healingDelay = 15;
  4490. const healingIterations = Math.ceil((100 - player.health) / 25); // making it have delay so it wont packet spam
  4491. let iterationCount = 0;
  4492. function performHealing() {
  4493. if (iterationCount < healingIterations) {
  4494. setTimeout(() => {
  4495. place(0, getAttackDir()); // slow heal
  4496. iterationCount++;
  4497. performHealing();
  4498. }, healingDelay);
  4499. } else {
  4500. isHealing = false;
  4501. }
  4502. }
  4503. performHealing();
  4504. }
  4505. }
  4506. }
  4507. // LATER:
  4508. function predictHeal() { }
  4509. function antiSyncHealing(timearg) {
  4510. my.antiSync = true;
  4511. let healAnti = setInterval(() => {
  4512. if (player.shameCount < 5) {
  4513. place(0, getAttackDir());
  4514. }
  4515. }, 75);
  4516. setTimeout(() => {
  4517. clearInterval(healAnti);
  4518. setTimeout(() => {
  4519. my.antiSync = false;
  4520. }, game.tickRate);
  4521. }, game.tickRate);
  4522. }
  4523. function biomeGear(mover, returns) {
  4524. if (getEl("hatType").value == "1") {
  4525. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4526. if (returns) return 31;
  4527. buyEquip(31, 0);
  4528. } else {
  4529. if (player.y2 <= config.snowBiomeTop) {
  4530. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4531. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4532. } else {
  4533. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4534. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4535. }
  4536. }
  4537. } else if (getEl("hatType").value == "2") {
  4538. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4539. if (returns) return 31;
  4540. buyEquip(31, 0);
  4541. } else {
  4542. if (player.y2 <= config.snowBiomeTop) {
  4543. if (returns) return mover && player.moveDir == undefined ? 6 : 15;
  4544. buyEquip(mover && player.moveDir == undefined ? 6 : 15, 0);
  4545. } else {
  4546. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  4547. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  4548. }
  4549. }
  4550. }
  4551. if (returns) return 0;
  4552. }
  4553.  
  4554. const placedSpikePositions = new Set();
  4555. const placedTrapPositions = new Set();
  4556. function isPositionValid(position) {
  4557. const playerX = player.x2;
  4558. const playerY = player.y2;
  4559. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  4560. return distToPosition > 35;
  4561. }
  4562. function findAllianceBySid(sid) {
  4563. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4564. }
  4565. function calculatePossibleTrapPositions(x, y, radius) {
  4566. const trapPositions = [];
  4567. const numPositions = 16;
  4568. for (let i = 0; i < numPositions; i++) {
  4569. const angle = (2 * Math.PI * i) / numPositions;
  4570. const offsetX = x + radius * Math.cos(angle);
  4571. const offsetY = y + radius * Math.sin(angle);
  4572. const position = [offsetX, offsetY];
  4573. if (!trapPositions.some((pos) => isPositionTooClose(position, pos))) {
  4574. trapPositions.push(position);
  4575. }
  4576. }
  4577. return trapPositions;
  4578. }
  4579. function isPositionTooClose(position1, position2, minDistance = 50) {
  4580. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  4581. return dist < minDistance;
  4582. }
  4583. function biomeGear(mover, returns) {
  4584. if (inWater) {
  4585. if (returns) return 31;
  4586. buyEquip(31, 0);
  4587. } else {
  4588. if (player.y2 <= config.snowBiomeTop) {
  4589. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4590. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4591. } else {
  4592. if (returns) return mover && player.moveDir == undefined ? 22 : 6;
  4593. buyEquip(mover && player.moveDir == undefined ? 22 : 6, 0);
  4594. }
  4595. }
  4596. if (returns) return 0;
  4597. }
  4598. function woah(mover) {
  4599. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4600. }
  4601. function secondaryCheck(id, radian) {
  4602. try {
  4603. var item = items.list[id];
  4604. var tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4605. var tmpX = player.x2 + tmpS * Math.cos(radian);
  4606. var tmpY = player.y2 + tmpS * Math.sin(radian);
  4607. if (
  4608. objectManager.checkItemLocation(
  4609. tmpX,
  4610. tmpY,
  4611. item.scale,
  4612. 0.6,
  4613. item.id,
  4614. false,
  4615. player
  4616. )
  4617. ) {
  4618. if (
  4619. player.itemCounts[item.group.id] == undefined
  4620. ? true
  4621. : player.itemCounts[item.group.id] <
  4622. (true
  4623. ? 99
  4624. : item.group.limit
  4625. ? 99
  4626. : 99)
  4627. ) {
  4628. return true
  4629. }
  4630. }
  4631. } catch (e) {
  4632.  
  4633. }
  4634. }
  4635. function makeAngles(building, type) {
  4636. let getDist = function (tmp1, tmp2, type1, type2) {
  4637. let tmpXY1 = {
  4638. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4639. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4640. };
  4641. let tmpXY2 = {
  4642. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4643. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4644. };
  4645. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4646. };
  4647. function fgdo(a, b) {
  4648. if (a == player) {
  4649. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4650. } else if (b == player) {
  4651. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4652. } else {
  4653. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4654. }
  4655. }
  4656. let buildings = building.filter(obj => fgdo(player, obj) < player.scale + items.list[type].scale + obj.scale + 50 && obj.active)
  4657. let allAngles = []
  4658. let scale
  4659. let offset = player.scale + items.list[type].scale + (items.list[type].placeOffset || 0)
  4660. for (let i = 0; i < buildings.length; i++) {
  4661.  
  4662. let scale
  4663. if (!buildings[i].isItem) {
  4664. if ((buildings[i].scale != 80 && buildings[i].scale != 85 && buildings[i].scale != 90 || buildings[i].type == 1)) {
  4665. scale = buildings[i].scale * 0.40
  4666.  
  4667. } else {
  4668. scale = buildings[i].scale
  4669. }
  4670. } else {
  4671. scale = buildings[i].scale
  4672. }
  4673. let angles = []
  4674. let dist = (items.list[type].scale + scale + 1)
  4675. let dPTB = fgdo(player, buildings[i])
  4676. let cosLaw
  4677. if (dPTB > dist + offset) {
  4678. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dist, 2)) - Math.pow(dPTB, 2)) / (2 * dist * offset))
  4679. cosLaw = Math.asin((dist * Math.sin(cosLaw)) / dPTB)
  4680. } else {
  4681. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dPTB, 2)) - Math.pow(dist, 2)) / (2 * dPTB * offset))
  4682. }
  4683. let aPTB = Math.atan2(buildings[i].y - player.y2, buildings[i].x - player.x2)
  4684. let ang1 = (aPTB - cosLaw)
  4685. let ang2 = (aPTB + cosLaw)
  4686. if (!isNaN(cosLaw)) {
  4687. angles.push(ang1)
  4688. angles.push(ang2)
  4689. angles.push(buildings[i])
  4690. }
  4691. allAngles.push(angles)
  4692. }
  4693.  
  4694. for (let i = 0; i < allAngles.length * 3; i++) {
  4695. allAngles = manageAngles(allAngles)
  4696.  
  4697. }
  4698. if (!allAngles.length) {
  4699. allAngles = [0, 0.0001]
  4700. }
  4701. for (let i = 0; i < allAngles.length; i++) {
  4702. if (allAngles != false) {
  4703. if (!secondaryCheck(type, allAngles[i][0]) || !secondaryCheck(type, allAngles[i][1])) {
  4704. allAngles = false
  4705. }
  4706. }
  4707. }
  4708. return allAngles
  4709. }
  4710. 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)
  4711. //mental health is not looking good rn
  4712. let array1q
  4713. let array = new Array(2);
  4714. let array2q
  4715.  
  4716. if (Math.sin(angle) > 0 && Math.cos(angle) > 0) {//angle in the first quadrant
  4717. array[0] = arra[0]
  4718. array[1] = arra[1]
  4719. } else if (Math.sin(angle) > 0 && Math.cos(angle) < 0) {//angle is inside the second quadrant
  4720. angle = angle - (Math.PI / 2)
  4721. array[0] = arra[0] - (Math.PI / 2)
  4722. array[1] = arra[1] - (Math.PI / 2)
  4723. } else if (Math.sin(angle) < 0 && Math.cos(angle) < 0) {// angle is in the third quadrant
  4724. angle = angle - Math.PI
  4725. array[0] = arra[0] - Math.PI
  4726. array[1] = arra[1] - Math.PI
  4727.  
  4728. } else if (Math.sin(angle) < 0 && Math.cos(angle) > 0) {//angle is in the fourth quadrant
  4729. angle = angle - ((3 * Math.PI) / 2)
  4730. array[0] = arra[0] - ((3 * Math.PI) / 2)
  4731. array[1] = arra[1] - ((3 * Math.PI) / 2)
  4732. }
  4733. if (Math.sin(array[0]) > 0 && Math.cos(array[0]) > 0) {
  4734. array1q = 1
  4735. } else if (Math.sin(array[0]) > 0 && Math.cos(array[0]) < 0) {
  4736. array1q = 2
  4737. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) < 0) {
  4738. array1q = 3
  4739. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) > 0) {
  4740. array1q = 4
  4741. }
  4742. if (Math.sin(array[1]) > 0 && Math.cos(array[1]) > 0) {
  4743. array2q = 1
  4744. } else if (Math.sin(array[1]) > 0 && Math.cos(array[1]) < 0) {
  4745. array2q = 2
  4746. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) < 0) {
  4747. array2q = 3
  4748. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) > 0) {
  4749. array2q = 4
  4750. }
  4751.  
  4752. if (array1q == 1) {//lowest angle of the not allowed zone in the first quadrant
  4753.  
  4754. if (Math.sin(angle) < Math.sin(array[0])) {//if the angle is lower than the not allowed zone (probably not in between)
  4755. if (array2q == 1) {// if the second part of the not allowed zone is in the first quadrant
  4756. if (Math.sin(angle) < Math.sin(array[2])) {//if it wraps completely around and makes it in between
  4757. return true
  4758. } else {//doesn't wrap around enough
  4759. return false
  4760. }
  4761. } else {//not in the first quadrant, not in between
  4762. return false
  4763. }
  4764. } else {//if the angle is further than the not allowed zone
  4765. if (array2q == 1) {//if the second part of the not allowed zone is in the first quadrant
  4766. if (Math.sin(angle) < Math.sin(array[2])) {//if the angle is lower than the top limit (in between)
  4767.  
  4768. return true
  4769. } else {//is not in between
  4770. return false
  4771. }
  4772.  
  4773. } else {//its gonna be somewhere further so its in between
  4774. return true;
  4775. }
  4776. }
  4777. } else {
  4778. if (array2q == 1) {//if the further part of the not allowed zone is in the first quadrant
  4779. if (Math.sin(angle) < Math.sin(array[1])) {//if it wraps all the way around
  4780. return true
  4781. } else {
  4782. return false
  4783. }
  4784. } else {
  4785. if (array1q == 2) {//if lowest angle is in the second
  4786. if (array2q == 2) {
  4787. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4788. return true
  4789. } else {
  4790. return false
  4791. }
  4792. } else {
  4793. return false
  4794. }
  4795. } else if (array1q == 3) {//if the first one is in the third
  4796. if (array1q > array2q) {
  4797. return true
  4798. } else if (array1q < array2q) {
  4799. return false
  4800. } else {
  4801. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4802. return true
  4803. } else {
  4804. return false
  4805. }
  4806. }
  4807. } else if (array1q == 4) {//if the first one is in the third
  4808. if (array1q > array2q) {
  4809. return true
  4810. } else if (array1q < array2q) {
  4811. return false
  4812. } else {
  4813. if (Math.sin(array[0]) > Math.sin(array[1])) {
  4814. return true
  4815. } else {
  4816. return false
  4817. }
  4818. }
  4819. }
  4820. }
  4821.  
  4822. }
  4823.  
  4824. }
  4825. function manageAngles(angles) {
  4826. let allAngles = []
  4827. for (let i = 0; i < angles.length; i++) {
  4828. if (angles[i].length) {
  4829. if (!allAngles.length) {
  4830. allAngles.push(angles[i])
  4831. } else {
  4832. let used = false
  4833. for (let j = 0; j < allAngles.length; j++) {
  4834.  
  4835. if (inBetween(angles[i][0], allAngles[j])) {
  4836. used = true
  4837. if (inBetween(angles[i][1], allAngles[j])) {
  4838. allAngles[j].push(angles[i][2])
  4839. } else {
  4840. allAngles[j][1] = angles[i][1]
  4841. allAngles[j].push(angles[i][2])
  4842. }
  4843. } else if (inBetween(angles[i][1], allAngles[j])) {
  4844. used = true
  4845. allAngles[j][0] = angles[i][0]
  4846. allAngles[j].push(angles[i][2])
  4847. }
  4848. }
  4849. if (!used) {
  4850. allAngles.push(angles[i])
  4851. }
  4852. }
  4853. }
  4854. }
  4855.  
  4856. return allAngles
  4857.  
  4858. }
  4859. let priorityPlace = [];
  4860. let packetData = {
  4861. place: [],
  4862. placeQ: [],
  4863. }
  4864. function autoplacer() {
  4865. let getDist = function (tmp1, tmp2, type1, type2) {
  4866. let tmpXY1 = {
  4867. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4868. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4869. };
  4870. let tmpXY2 = {
  4871. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4872. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4873. };
  4874. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4875. };
  4876. function fgdo(a, b) {
  4877. if (a == player) {
  4878. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4879. } else if (b == player) {
  4880. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4881. } else {
  4882. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4883. }
  4884. }
  4885. 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));
  4886. let nearBuilds = buildings.filter(obj => fgdo(obj, player) < 250);
  4887. const notRiver = !inWater
  4888. /*nearest enemy in trap*/
  4889. if (enemy.length && notRiver) {
  4890. 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) {
  4891. return getDist(a, near, 0, 2) - getDist(b, near, 0, 2);
  4892. })[0];
  4893. let direction = Math.atan2(near.y - player.y2, near.x - player.x2)
  4894. let spikeAngles = makeAngles(nearBuilds, player.items[2])
  4895. let trapAngles = [];
  4896. if (player.items[4]) {
  4897. trapAngles = makeAngles(nearBuilds, player.items[4])
  4898. if (!trapAngles) {
  4899. return
  4900. }
  4901. }
  4902. if (!spikeAngles) {
  4903. return
  4904. }
  4905. if (spikeAngles.length || trapAngles.length) {
  4906. let placed = []
  4907. if (priorityPlace.length) {
  4908. for (let j = 0; j < priorityPlace; j++) {
  4909. let newDir = Math.atan2(priorityPlace[j].y - player.y2, priorityPlace[j].x - player.x2)
  4910. let angFound = 0
  4911. for (let i = 0; i < spikeAngles.length; i++) {
  4912. if (!inBetween(newDir, spikeAngles[i])) {
  4913. angFound += 1
  4914. }
  4915. }
  4916. if (angFound == spikeAngles.length) {
  4917. placed.push([player.items[2], newDir])
  4918. packetData.place.push([2, newDir])
  4919. }
  4920. }
  4921. }
  4922. priorityPlace = []
  4923. if (placed.length) {
  4924. for (let i = 0; i < placed.length; i++) {
  4925. let obj = {
  4926. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4927. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4928. scale: items.list[placed[i][0]].scale / 3,
  4929. isItem: true,
  4930. active: true,
  4931. }
  4932. nearBuilds.push(obj)
  4933. }
  4934. spikeAngles = makeAngles(nearBuilds, player.items[2])
  4935. if (!spikeAngles) {
  4936. return
  4937. }
  4938. trapAngles = []
  4939. if (player.items[4]) {
  4940. trapAngles = makeAngles(nearBuilds, player.items[4])
  4941. if (!trapAngles) {
  4942. return
  4943. }
  4944. }
  4945. placed = []
  4946. }
  4947.  
  4948. if (neit && fgdo(player, near) < 200) {
  4949. let nearestAngle = undefined
  4950. let trapFound = false
  4951. for (let i = 0; i < spikeAngles.length; i++) {
  4952. if (!trapFound) {
  4953. for (let j = 2; j < spikeAngles[i].length; j++) {
  4954. if (neit == spikeAngles[i][j]) {
  4955. trapFound = true
  4956. nearestAngle = ((spikeAngles[i][0] - direction) < (spikeAngles[i][1] - direction) ? spikeAngles[i][0] : spikeAngles[i][1])
  4957. }
  4958. }
  4959. }
  4960. }
  4961. if (trapFound) {
  4962. let objectX = player.x2 + (Math.cos(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  4963. let objectY = player.y2 + (Math.sin(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  4964. if (Math.hypot(objectY - near.y, objectX - near.x) < (player.scale + items.list[player.items[2]].scale + 8)) {
  4965. placed.push([player.items[2], nearestAngle])
  4966. packetData.place.push([2, nearestAngle])
  4967. }
  4968. }
  4969. }
  4970. if (placed.length) {
  4971. for (let i = 0; i < placed.length; i++) {
  4972. let obj = {
  4973. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4974. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4975. scale: items.list[placed[i][0]].scale / 3,
  4976. isItem: true,
  4977. active: true,
  4978. }
  4979. nearBuilds.push(obj)
  4980. }
  4981. spikeAngles = makeAngles(nearBuilds, player.items[2])
  4982. if (!spikeAngles) {
  4983. return
  4984. }
  4985. trapAngles = []
  4986. if (player.items[4]) {
  4987. trapAngles = makeAngles(nearBuilds, player.items[4])
  4988. if (!trapAngles) {
  4989. return
  4990. }
  4991. }
  4992. placed = []
  4993. }
  4994. if (fgdo(player, near) < 400) {
  4995. let ha = false
  4996.  
  4997.  
  4998. if (neit) {
  4999. let buildings = gameObjects.sort((a, b) => fgdo(player, a) - fgdo(player, b))
  5000. 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]
  5001. if (spike) {
  5002. ha = true
  5003. }
  5004.  
  5005. }
  5006. if (!neit || ha) {
  5007. let dirFound = 0
  5008. for (let i = 0; i < trapAngles.length; i++) {
  5009. if (!inBetween(direction, trapAngles[i])) {
  5010. dirFound += 1
  5011. }
  5012. }
  5013. if (dirFound == trapAngles.length) {
  5014. if (packetData.place.length < 3 && player.items[4]) {
  5015. placed.push([player.items[4], direction])
  5016. packetData.place.push([4, direction])
  5017. }
  5018. }
  5019. if (placed.length) {
  5020. for (let i = 0; i < placed.length; i++) {
  5021. let obj = {
  5022. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5023. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5024. scale: items.list[placed[i][0]].scale / 3,
  5025. isItem: true,
  5026. active: true,
  5027.  
  5028. }
  5029. nearBuilds.push(obj)
  5030. }
  5031. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5032. if (!spikeAngles) {
  5033. return
  5034. }
  5035. trapAngles = []
  5036. if (player.items[4]) {
  5037. trapAngles = makeAngles(nearBuilds, player.items[4])
  5038. if (!trapAngles) {
  5039. return
  5040. }
  5041. }
  5042. placed = []
  5043. }
  5044.  
  5045. if (fgdo(player, near) < 120) {
  5046. for (let i = 0; i < spikeAngles.length; i++) {
  5047. if (packetData.place.length < 3) {
  5048. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5049. placed.push([player.items[2], closest])
  5050. packetData.place.push([2, closest])
  5051. }
  5052. if (placed.length) {
  5053. for (let i = 0; i < placed.length; i++) {
  5054. let obj = {
  5055. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5056. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5057. scale: items.list[placed[i][0]].scale / 3,
  5058. isItem: true,
  5059. active: true,
  5060.  
  5061. }
  5062. nearBuilds.push(obj)
  5063. }
  5064. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5065. if (!spikeAngles) {
  5066. return
  5067. }
  5068. trapAngles = []
  5069. if (player.items[4]) {
  5070. trapAngles = makeAngles(nearBuilds, player.items[4])
  5071. if (!trapAngles) {
  5072. return
  5073. }
  5074. }
  5075. placed = []
  5076. }
  5077. }
  5078.  
  5079. } else {
  5080. for (let i = 0; i < trapAngles.length; i++) {
  5081. if (packetData.place.length < 3 && player.items[4]) {
  5082. let closest = (direction - trapAngles[i][0] <= direction - trapAngles[i][1] ? trapAngles[i][0] : trapAngles[i][1])
  5083. placed.push([player.items[4], closest])
  5084. packetData.place.push([4, closest])
  5085. }
  5086. if (placed.length) {
  5087. for (let i = 0; i < placed.length; i++) {
  5088. let obj = {
  5089. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5090. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5091. scale: items.list[placed[i][0]].scale / 3,
  5092. isItem: true,
  5093. active: true,
  5094.  
  5095. }
  5096. nearBuilds.push(obj)
  5097. }
  5098. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5099. if (!spikeAngles) {
  5100. return
  5101. }
  5102. trapAngles = []
  5103. if (player.items[4]) {
  5104. trapAngles = makeAngles(nearBuilds, player.items[4])
  5105. if (!trapAngles) {
  5106. return
  5107. }
  5108. }
  5109. placed = []
  5110. }
  5111. }
  5112. }
  5113. } else {
  5114. if (fgdo(player, near) < 180) {
  5115. for (let i = 0; i < spikeAngles.length; i++) {
  5116. if (packetData.place.length < 3) {
  5117. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5118. placed.push([player.items[2], closest])
  5119. packetData.place.push([2, closest])
  5120. }
  5121. if (placed.length) {
  5122. for (let i = 0; i < placed.length; i++) {
  5123. let obj = {
  5124. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5125. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5126. scale: items.list[placed[i][0]].scale / 3,
  5127. isItem: true,
  5128. active: true,
  5129.  
  5130. }
  5131. nearBuilds.push(obj)
  5132. }
  5133. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5134. if (!spikeAngles) {
  5135. return
  5136. }
  5137. trapAngles = []
  5138. if (player.items[4]) {
  5139. trapAngles = makeAngles(nearBuilds, player.items[4])
  5140. if (!trapAngles) {
  5141. return
  5142. }
  5143. }
  5144. placed = []
  5145. }
  5146. }
  5147. }
  5148. }
  5149. }
  5150.  
  5151. }
  5152. }
  5153. priorityPlace = [];
  5154. }
  5155. let advHeal = [];
  5156. class Traps {
  5157. constructor(UTILS, items) {
  5158. this.dist = 0;
  5159. this.aim = 0;
  5160. this.inTrap = false;
  5161. this.replaced = false;
  5162. this.antiTrapped = false;
  5163. this.info = {};
  5164. this.notFast = function() {
  5165. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5166. }
  5167. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5168. try {
  5169. let item = items.list[player.items[id]];
  5170. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5171. let counts = {
  5172. attempts: 0,
  5173. placed: 0
  5174. };
  5175. let tmpObjects = [];
  5176. gameObjects.forEach((p) => {
  5177. tmpObjects.push({
  5178. x: p.x,
  5179. y: p.y,
  5180. active: p.active,
  5181. blocker: p.blocker,
  5182. scale: p.scale,
  5183. isItem: p.isItem,
  5184. type: p.type,
  5185. colDiv: p.colDiv,
  5186. getScale: function(sM, ig) {
  5187. sM = sM || 1;
  5188. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  5189. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  5190. },
  5191. });
  5192. });
  5193. for (let i = first; i < repeat; i += plus) {
  5194. counts.attempts++;
  5195. let relAim = radian + i;
  5196. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5197. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5198. 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)));
  5199. if (cantPlace) continue;
  5200. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5201. place(id, relAim, 1);
  5202. tmpObjects.push({
  5203. x: tmpX,
  5204. y: tmpY,
  5205. active: true,
  5206. blocker: item.blocker,
  5207. scale: item.scale,
  5208. isItem: true,
  5209. type: null,
  5210. colDiv: item.colDiv,
  5211. getScale: function() {
  5212. return this.scale;
  5213. },
  5214. });
  5215. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5216. counts.placed++;
  5217. }
  5218. }
  5219. if (counts.placed > 0 && replacer && item.dmg) {
  5220. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs1.AutoSpikeTick) {
  5221. instaC.canSpikeTick = true;
  5222. }
  5223. }
  5224. } catch (err) {
  5225. }
  5226. };
  5227. this.checkSpikeTick = function() {
  5228. //this is my anti spike tick function which 100% confirms that u cant get spike ticked when breaking a trap
  5229. 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
  5230. try {
  5231. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5232. if ((configs1.AntiSpikeTick || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5233. // more range for safe. also testing near.primaryIndex || 5
  5234. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5235. let item = items.list[9];
  5236. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5237. let danger = 0;
  5238. let counts = {
  5239. attempts: 0,
  5240. block: `unblocked`
  5241. };
  5242. for (let i = -1; i <= 1; i += 1 / 10) {
  5243. counts.attempts++;
  5244. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5245. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5246. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5247. 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)));
  5248. if (cantPlace) continue;
  5249. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5250. danger++;
  5251. counts.block = `blocked`;
  5252. break;
  5253. }
  5254. if (danger) {
  5255. my.anti0Tick = 1;
  5256. packet('6', "pro anti tick huh? " + hir.sid);
  5257. player.chat.count = 2000;
  5258. return true;
  5259. }
  5260. }
  5261. } catch (err) {
  5262. return null;
  5263. }
  5264. return false;
  5265. }
  5266. this.protect = function(aim, trap) {
  5267. if (!configs1.AntiTrap) return;
  5268. if (trap && nears.length) {
  5269. if (getDist(near, player) > getDist(near, trap)) {
  5270. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5271. checkPlace(2, near.aim2 + i);
  5272. }
  5273. }
  5274. if (getDist(near, trap) > getDist(near, player)) {
  5275. if (player.items[4]) {
  5276. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5277. checkPlace(4, near.aim2 + i) && this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5278. }
  5279. } else {
  5280. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5281. checkPlace(2, near.aim2 + i) && this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5282. }
  5283. }
  5284. }
  5285. } else {
  5286. if (player.items[4] && player.items[2]) {
  5287. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5288. this.antiTrapped = true;
  5289. }
  5290. }
  5291. };
  5292. let placedSpikePositions = new Set();
  5293. let placedTrapPositions = new Set();
  5294. this.autoPlace = function () {
  5295. if (!configs1.AutoPlace) return;
  5296. try {
  5297. if (gameObjects.length) {
  5298. let near2 = {
  5299. inTrap: false,
  5300. };
  5301. 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];
  5302.  
  5303. if (nearTrap) {
  5304. near2.inTrap = true;
  5305. } else {
  5306. near2.inTrap = false;
  5307. }
  5308.  
  5309. if (near.dist3 <= 450) {
  5310. if (near.dist3 <= 200) {
  5311. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5312. inTrap: near2.inTrap
  5313. });
  5314. } else {
  5315. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5316. }
  5317. }
  5318. } else {
  5319. if (near.dist3 <= 450) {
  5320. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5321. }
  5322. }
  5323. const trap1 = gameObjects
  5324. .filter((e) => e.trap && e.active)
  5325. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5326. .find((trap) => {
  5327. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5328. return (
  5329. trap !== player &&
  5330. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5331. trapDist <= 50
  5332. );
  5333. });
  5334.  
  5335. if (trap1 && near.dist2 <= 160) {
  5336. const trapX = trap1.x;
  5337. const trapY = trap1.y;
  5338. const circleRadius = 102;
  5339. const numPositions = 64;
  5340.  
  5341. for (let i = 0; i < numPositions; i++) {
  5342. const angle = (2 * Math.PI * i) / numPositions;
  5343. const offsetX = trapX + circleRadius * Math.cos(angle);
  5344. const offsetY = trapY + circleRadius * Math.sin(angle);
  5345. const position = [offsetX, offsetY];
  5346. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5347.  
  5348. if (
  5349. !placedSpikePositions.has(JSON.stringify(position)) &&
  5350. isPositionValid(position) &&
  5351. distToPlayer <= 87
  5352. ) {
  5353. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5354. checkPlace(2, angleToPlace);
  5355. placedSpikePositions.add(JSON.stringify(position));
  5356. }
  5357. }
  5358. } else if (!trap1 && near.dist2 <= 206) {
  5359. placedSpikePositions.clear();
  5360. const maxTrapsToPlace = 3;
  5361. const trapRadius = 50;
  5362. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5363. let trapsPlaced = 0;
  5364.  
  5365. for (const position of trapPositions) {
  5366. if (
  5367. trapsPlaced < maxTrapsToPlace &&
  5368. !placedTrapPositions.has(JSON.stringify(position)) &&
  5369. isPositionValid(position)
  5370. ) {
  5371. checkPlace(4, ...position);
  5372. placedTrapPositions.add(JSON.stringify(position));
  5373. trapsPlaced++;
  5374. }
  5375. }
  5376. }
  5377. } catch (e) {
  5378. console.log(e);
  5379. }
  5380. };
  5381. function calculatePerfectAngle(x1, y1, x2, y2) {
  5382. return Math.atan2(y2 - y1, x2 - x1);
  5383. }
  5384. function antiSpikeTickEz() {
  5385. 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
  5386. }
  5387. function fgdo(a, b) {
  5388. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  5389. }
  5390. let spikSync = false;
  5391. let spikePlaced = false;
  5392.  
  5393. this.replacer = function(findObj) {
  5394. if (!findObj || !configs.autoReplace) return;
  5395. if (!inGame) return;
  5396. if (this.antiTrapped) return;
  5397. game.tickBase(() => {
  5398. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5399. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5400. let perfectAngle = Math.round(calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y) / (Math.PI / 2)) * (Math.PI / 2);
  5401. 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;
  5402. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5403. let danger = this.checkSpikeTick();
  5404. if (objDst <= 300 && near.dist2 <= 400) {
  5405. if (near.dist2 <= 70 && canPlaceCondition && configs.spikeTick) {
  5406. this.testCanPlace(2, -Math.PI/4, Math.PI/4, (Math.PI / 20), near.aim2, 1);
  5407. this.testCanPlace(4, -Math.PI/4, Math.PI/4, Math.PI/12, near.aim2+Math.PI, 1)
  5408. } else if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5409. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5410. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5411. } else {
  5412. player.items[4] == 15 && this.testCanPlace(near.dist2 > 250 ? 4 : 2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5413. }
  5414. this.replaced = true;
  5415. }
  5416. }, 1);
  5417. };
  5418. }
  5419. };
  5420. class Instakill {
  5421. constructor() {
  5422. this.wait = false;
  5423. this.can = false;
  5424. this.isTrue = false;
  5425. this.nobull = false;
  5426. this.ticking = false;
  5427. this.canSpikeTick = false;
  5428. this.startTick = false;
  5429. this.readyTick = false;
  5430. this.canCounter = false;
  5431. this.revTick = false;
  5432. this.syncHit = false;
  5433. this.changeType = function (type) {
  5434. this.wait = false;
  5435. this.isTrue = true;
  5436. my.autoAim = true;
  5437. let instaLog = [type];
  5438. let backupNobull = near.backupNobull;
  5439. near.backupNobull = false;
  5440. game.tickBase(() => {
  5441. instaLog.push(player.skinIndex);
  5442. game.tickBase(() => {
  5443. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5444. near.backupNobull = true;
  5445. }
  5446. instaLog.push(player.skinIndex);
  5447. }, 1);
  5448. }, 1);
  5449. if (type == "rev") {
  5450. selectWeapon(player.weapons[1]);
  5451. buyEquip(53, 0);
  5452. buyEquip(21, 1);
  5453. sendAutoGather();
  5454. game.tickBase(() => {
  5455. selectWeapon(player.weapons[0]);
  5456. buyEquip(7, 0);
  5457. buyEquip(21, 1);
  5458. game.tickBase(() => {
  5459. sendAutoGather();
  5460. this.isTrue = false;
  5461. my.autoAim = false;
  5462. }, 1);
  5463. }, 1);
  5464. } else if (type == "nobull") {
  5465. selectWeapon(player.weapons[0]);
  5466. if (getEl("backupNobull").checked && backupNobull) {
  5467. buyEquip(7, 0);
  5468. } else {
  5469. buyEquip(6, 0);
  5470. }
  5471. buyEquip(21, 1);
  5472. sendAutoGather();
  5473. game.tickBase(() => {
  5474. if (near.skinIndex == 22) {
  5475. if (getEl("backupNobull").checked) {
  5476. near.backupNobull = true;
  5477. }
  5478. buyEquip(21, 0);
  5479. } else {
  5480. buyEquip(53, 0);
  5481. }
  5482. selectWeapon(player.weapons[1]);
  5483. buyEquip(21, 1);
  5484. game.tickBase(() => {
  5485. sendAutoGather();
  5486. this.isTrue = false;
  5487. my.autoAim = false;
  5488. }, 1);
  5489. }, 1);
  5490. } else if (type == "normal") {
  5491. selectWeapon(player.weapons[0]);
  5492. buyEquip(7, 0);
  5493. buyEquip(21, 1);
  5494. sendAutoGather();
  5495. game.tickBase(() => {
  5496. selectWeapon(player.weapons[1]);
  5497. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5498. buyEquip(21, 1);
  5499. game.tickBase(() => {
  5500. sendAutoGather();
  5501. this.isTrue = false;
  5502. my.autoAim = false;
  5503. }, 1);
  5504. }, 1);
  5505. } else {
  5506. setTimeout(() => {
  5507. this.isTrue = false;
  5508. my.autoAim = false;
  5509. }, 50);
  5510. }
  5511. };
  5512. this.spikeTickType = function () {
  5513. this.isTrue = true;
  5514. my.autoAim = true;
  5515. selectWeapon(player.weapons[0]);
  5516. buyEquip(7, 0);
  5517. buyEquip(21, 1);
  5518. sendAutoGather();
  5519. game.tickBase(() => {
  5520. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5521. selectWeapon(player.weapons[0]);
  5522. buyEquip(53, 0);
  5523. buyEquip(21, 1);
  5524. game.tickBase(() => {
  5525. sendAutoGather();
  5526. this.isTrue = false;
  5527. my.autoAim = false;
  5528. }, 1);
  5529. } else {
  5530. sendAutoGather();
  5531. this.isTrue = false;
  5532. my.autoAim = false;
  5533. }
  5534. }, 1);
  5535. };
  5536. this.counterType = function () {
  5537. this.isTrue = true;
  5538. my.autoAim = true;
  5539. selectWeapon(player.weapons[0]);
  5540. buyEquip(7, 0);
  5541. buyEquip(21, 1);
  5542. sendAutoGather();
  5543. game.tickBase(() => {
  5544. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5545. selectWeapon(player.weapons[0]);
  5546. buyEquip(53, 0);
  5547. buyEquip(21, 1);
  5548. game.tickBase(() => {
  5549. sendAutoGather();
  5550. this.isTrue = false;
  5551. my.autoAim = false;
  5552. }, 1);
  5553. } else {
  5554. sendAutoGather();
  5555. this.isTrue = false;
  5556. my.autoAim = false;
  5557. }
  5558. }, 1);
  5559. };
  5560. this.rangeType = function (type) {
  5561. this.isTrue = true;
  5562. my.autoAim = true;
  5563. if (type == "ageInsta") {
  5564. my.ageInsta = false;
  5565. if (player.items[5] == 18) {
  5566. place(5, near.aim2);
  5567. }
  5568. packet("I", undefined, 1);
  5569. buyEquip(22, 0);
  5570. buyEquip(21, 1);
  5571. game.tickBase(() => {
  5572. selectWeapon(player.weapons[1]);
  5573. buyEquip(53, 0);
  5574. buyEquip(21, 1);
  5575. sendAutoGather();
  5576. game.tickBase(() => {
  5577. sendUpgrade(12);
  5578. selectWeapon(player.weapons[1]);
  5579. buyEquip(53, 0);
  5580. buyEquip(21, 1);
  5581. game.tickBase(() => {
  5582. sendUpgrade(15);
  5583. selectWeapon(player.weapons[1]);
  5584. buyEquip(53, 0);
  5585. buyEquip(21, 1);
  5586. game.tickBase(() => {
  5587. sendAutoGather();
  5588. this.isTrue = false;
  5589. my.autoAim = false;
  5590. }, 1);
  5591. }, 1);
  5592. }, 1);
  5593. }, 1);
  5594. } else {
  5595. selectWeapon(player.weapons[1]);
  5596. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5597. buyEquip(53, 0);
  5598. } else {
  5599. buyEquip(20, 0);
  5600. }
  5601. buyEquip(11, 1);
  5602. sendAutoGather();
  5603. game.tickBase(() => {
  5604. sendAutoGather();
  5605. this.isTrue = false;
  5606. my.autoAim = false;
  5607. }, 1);
  5608. }
  5609. };
  5610. this.boostTickType = function() {
  5611. /*this.isTrue = true;
  5612. my.autoAim = true;
  5613. selectWeapon(player.weapons[0]);
  5614. buyEquip(53, 0);
  5615. buyEquip(11, 1);
  5616. packet("a", near.aim2);
  5617. game.tickBase(() => {
  5618. place(4, near.aim2);
  5619. selectWeapon(player.weapons[1]);
  5620. biomeGear();
  5621. buyEquip(11, 1);
  5622. sendAutoGather();
  5623. packet("a", near.aim2);
  5624. game.tickBase(() => {
  5625. selectWeapon(player.weapons[0]);
  5626. buyEquip(7, 0);
  5627. buyEquip(19, 1);
  5628. packet("a", near.aim2);
  5629. game.tickBase(() => {
  5630. sendAutoGather();
  5631. this.isTrue = false;
  5632. my.autoAim = false;
  5633. packet("a", undefined);
  5634. }, 1);
  5635. }, 1);
  5636. }, 1);*/
  5637. this.isTrue = true;
  5638. my.autoAim = true;
  5639. biomeGear();
  5640. buyEquip(11, 1);
  5641. packet("a", near.aim2, 1);
  5642. game.tickBase(() => {
  5643. if (player.weapons[1] == 15) {
  5644. my.revAim = true;
  5645. }
  5646. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5647. buyEquip(53, 0);
  5648. buyEquip(11, 1);
  5649. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5650. sendAutoGather();
  5651. }
  5652. packet("a", near.aim2, 1);
  5653. place(4, near.aim2);
  5654. game.tickBase(() => {
  5655. my.revAim = false;
  5656. selectWeapon(player.weapons[0]);
  5657. buyEquip(7, 0);
  5658. buyEquip(19, 1);
  5659. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5660. sendAutoGather();
  5661. }
  5662. packet("a", near.aim2, 1);
  5663. game.tickBase(() => {
  5664. sendAutoGather();
  5665. this.isTrue = false;
  5666. my.autoAim = false;
  5667. packet("a", undefined, 1);
  5668. }, 1);
  5669. }, 1);
  5670. }, 1);
  5671. };
  5672. this.gotoGoal = function(goto, OT) {
  5673. let slowDists = (weeeee) => weeeee * config.playerScale;
  5674. let goal = {
  5675. a: goto - OT,
  5676. b: goto + OT,
  5677. c: goto - slowDists(1),
  5678. d: goto + slowDists(1),
  5679. e: goto - slowDists(2),
  5680. f: goto + slowDists(2),
  5681. g: goto - slowDists(4),
  5682. h: goto + slowDists(4)
  5683. };
  5684. let bQ = function(wwww, awwww) {
  5685. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5686. buyEquip(31, 0);
  5687. } else {
  5688. buyEquip(wwww, awwww);
  5689. }
  5690. }
  5691. if (enemy.length) {
  5692. let dst = near.dist2;
  5693. this.ticking = true;
  5694. if (dst >= goal.a && dst <= goal.b) {
  5695. bQ(22, 0);
  5696. bQ(11, 1);
  5697. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5698. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5699. }
  5700. return {
  5701. dir: undefined,
  5702. action: 1
  5703. };
  5704. } else {
  5705. if (dst < goal.a) {
  5706. if (dst >= goal.g) {
  5707. if (dst >= goal.e) {
  5708. if (dst >= goal.c) {
  5709. bQ(40, 0);
  5710. bQ(10, 1);
  5711. if (configs.none) {
  5712. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5713. } else {
  5714. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5715. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5716. }
  5717. }
  5718. } else {
  5719. bQ(22, 0);
  5720. bQ(19, 1);
  5721. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5722. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5723. }
  5724. }
  5725. } else {
  5726. bQ(6, 0);
  5727. bQ(12, 1);
  5728. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5729. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5730. }
  5731. }
  5732. } else {
  5733. biomeGear();
  5734. bQ(11, 1);
  5735. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5736. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5737. }
  5738. }
  5739. return {
  5740. dir: near.aim2 + Math.PI,
  5741. action: 0
  5742. };
  5743. } else if (dst > goal.b) {
  5744. if (dst <= goal.h) {
  5745. if (dst <= goal.f) {
  5746. if (dst <= goal.d) {
  5747. bQ(40, 0);
  5748. bQ(9, 1);
  5749. if (configs.none) {
  5750. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5751. } else {
  5752. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5753. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5754. }
  5755. }
  5756. } else {
  5757. bQ(22, 0);
  5758. bQ(19, 1);
  5759. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5760. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5761. }
  5762. }
  5763. } else {
  5764. bQ(6, 0);
  5765. bQ(12, 1);
  5766. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5767. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5768. }
  5769. }
  5770. } else {
  5771. biomeGear();
  5772. bQ(11, 1);
  5773. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5774. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5775. }
  5776. }
  5777. return {
  5778. dir: near.aim2,
  5779. action: 0
  5780. };
  5781. }
  5782. return {
  5783. dir: undefined,
  5784. action: 0
  5785. };
  5786. }
  5787. } else {
  5788. this.ticking = false;
  5789. return {
  5790. dir: undefined,
  5791. action: 0
  5792. };
  5793. }
  5794. }
  5795. /** wait 1 tick for better quality */
  5796. this.bowMovement = function() {
  5797. let moveMent = this.gotoGoal(685, 3);
  5798. if (moveMent.action) {
  5799. if (player.reloads[53] == 0 && !this.isTrue) {
  5800. this.rangeType("ageInsta");
  5801. } else {
  5802. packet("a", moveMent.dir, 1);
  5803. }
  5804. } else {
  5805. packet("a", moveMent.dir, 1);
  5806. }
  5807. },
  5808. this.tickMovement = function() {
  5809. let dist = player.weapons[1] == 9 ? 240 : 240;
  5810. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5811. let moveMent = this.gotoGoal(238, 3);
  5812. if (moveMent.action) {
  5813. if (player.reloads[53] == 0 && !this.isTrue) {
  5814. this.boostTickType();
  5815. } else {
  5816. packet("a", moveMent.dir, 1);
  5817. }
  5818. } else {
  5819. packet("a", moveMent.dir, 1);
  5820. }
  5821. },
  5822. this.kmTickMovement = function() {
  5823. let moveMent = this.gotoGoal(240, 3);
  5824. if (moveMent.action) {
  5825. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5826. this.kmTickType();
  5827. } else {
  5828. packet("a", moveMent.dir, 1);
  5829. }
  5830. } else {
  5831. packet("a", moveMent.dir, 1);
  5832. }
  5833. },
  5834. this.boostTickMovement = function() {
  5835. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 140;
  5836. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5837. let moveMent = this.gotoGoal(372, 3);
  5838. if (moveMent.action) {
  5839. if (player.reloads[53] == 0 && !this.isTrue) {
  5840. this.boostTickType();
  5841. } else {
  5842. packet("a", moveMent.dir, 1);
  5843. }
  5844. } else {
  5845. packet("a", moveMent.dir, 1);
  5846. }
  5847. }
  5848. /** wait 1 tick for better quality */
  5849. this.perfCheck = function(pl, nr) {
  5850. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5851. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5852. let pjs = {
  5853. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5854. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5855. };
  5856. 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)) {
  5857. return true;
  5858. }
  5859. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5860. 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)) {
  5861. return true;
  5862. }
  5863. });
  5864. if (finds) return false;
  5865. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5866. let tmpScale = tmp.getScale();
  5867. 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)) {
  5868. return true;
  5869. }
  5870. });
  5871. if (finds) return false;
  5872. return true;
  5873. }
  5874. }
  5875. };
  5876. class Autobuy {
  5877. constructor(buyHat, buyAcc) {
  5878. this.hat = function() {
  5879. buyHat.forEach((id) => {
  5880. let find = findID(hats, id);
  5881. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5882. });
  5883. };
  5884. this.acc = function() {
  5885. buyAcc.forEach((id) => {
  5886. let find = findID(accessories, id);
  5887. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5888. });
  5889. };
  5890. }
  5891. };
  5892.  
  5893. class Autoupgrade {
  5894. constructor() {
  5895. this.sb = function(upg) {
  5896. upg(3);
  5897. upg(17);
  5898. upg(31);
  5899. upg(23);
  5900. upg(9);
  5901. upg(38);
  5902. };
  5903. this.kh = function(upg) {
  5904. upg(3);
  5905. upg(17);
  5906. upg(31);
  5907. upg(23);
  5908. upg(10);
  5909. upg(38);
  5910. upg(4);
  5911. upg(25);
  5912. };
  5913. this.pb = function(upg) {
  5914. upg(5);
  5915. upg(17);
  5916. upg(32);
  5917. upg(23);
  5918. upg(9);
  5919. upg(38);
  5920. };
  5921. this.ph = function(upg) {
  5922. upg(5);
  5923. upg(17);
  5924. upg(32);
  5925. upg(23);
  5926. upg(10);
  5927. upg(38);
  5928. upg(28);
  5929. upg(25);
  5930. };
  5931. this.db = function(upg) {
  5932. upg(7);
  5933. upg(17);
  5934. upg(31);
  5935. upg(23);
  5936. upg(9);
  5937. upg(34);
  5938. };
  5939. };
  5940. };
  5941.  
  5942. class Damages {
  5943. constructor(items) {
  5944. // 0.75 1 1.125 1.5
  5945. this.calcDmg = function(dmg, val) {
  5946. return dmg * val;
  5947. };
  5948. this.getAllDamage = function(dmg) {
  5949. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5950. };
  5951. this.weapons = [];
  5952. for (let i = 0; i < items.weapons.length; i++) {
  5953. let wp = items.weapons[i];
  5954. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5955. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5956. this[name] = this.weapons[i];
  5957. }
  5958. }
  5959. }
  5960.  
  5961. /** CLASS CODES */
  5962. // jumpscare code warn
  5963. let tmpList = [];
  5964. // LOADING:
  5965. let UTILS = new Utils();
  5966. let items = new Items();
  5967. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5968. let store = new Store();
  5969. let hats = store.hats;
  5970. let accessories = store.accessories;
  5971. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5972. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5973. let textManager = new Textmanager();
  5974. let traps = new Traps(UTILS, items);
  5975. let instaC = new Instakill();
  5976. let autoBuy = new Autobuy([15, 31, 6, 7, 22, 12, 53, 26, 20, 40], [11, 13, 19, 18, 21]);
  5977. let autoUpgrade = new Autoupgrade();
  5978. let lastDeath;
  5979. let minimapData;
  5980. let mapMarker = {};
  5981. let mapPings = [];
  5982. let tmpPing;
  5983. let breakTrackers = [];
  5984. let pathFindTest = 0;
  5985. let grid = [];
  5986. let pathFind = {
  5987. active: false,
  5988. grid: 40,
  5989. scale: 1440,
  5990. x: 14400,
  5991. y: 14400,
  5992. chaseNear: false,
  5993. array: [],
  5994. lastX: this.grid / 2,
  5995. lastY: this.grid / 2
  5996. };
  5997. function sendChat(message) {
  5998. packet("6", message.slice(0, 30));
  5999. }
  6000. let runAtNextTick = [];
  6001. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6002. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6003. let projOffset = config.playerScale * 2;
  6004. let projXY = {
  6005. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6006. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6007. };
  6008. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6009. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6010. })[0];
  6011. if (nearPlayer) {
  6012. if (indx == 1) {
  6013. nearPlayer.shooting[53] = 1;
  6014. } else {
  6015. nearPlayer.shootIndex = weaponIndx;
  6016. nearPlayer.shooting[1] = 1;
  6017. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6018. }
  6019. }
  6020. }
  6021. let projectileCount = 0;
  6022. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6023. if (!tmpObj.isTeam(player)) {
  6024. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6025. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6026. tmpObj.bowThreat[weaponIndex]++;
  6027. if (index == 5) {
  6028. projectileCount++;
  6029. }
  6030. setTimeout(() => {
  6031. tmpObj.bowThreat[weaponIndex]--;
  6032. if (index == 5) {
  6033. projectileCount--;
  6034. }
  6035. }, range / speed);
  6036. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6037. place(1, tmpObj.aim2);
  6038. my.anti0Tick = 4;
  6039. if (!my.antiSync) {
  6040. antiSyncHealing(4);
  6041. }
  6042. } else {
  6043. if (projectileCount >= 2) {
  6044. place(1, tmpObj.aim2);
  6045. my.anti0Tick = 4;
  6046. if (!my.antiSync) {
  6047. antiSyncHealing(4);
  6048. }
  6049. }
  6050. }
  6051. }
  6052. }
  6053. }
  6054. // SHOW ITEM INFO:
  6055. function showItemInfo(item, isWeapon, isStoreItem) {
  6056. if (player && item) {
  6057. UTILS.removeAllChildren(itemInfoHolder);
  6058. itemInfoHolder.classList.add("visible");
  6059. UTILS.generateElement({
  6060. id: "itemInfoName",
  6061. text: UTILS.capitalizeFirst(item.name),
  6062. parent: itemInfoHolder
  6063. });
  6064. UTILS.generateElement({
  6065. id: "itemInfoDesc",
  6066. text: item.desc,
  6067. parent: itemInfoHolder
  6068. });
  6069. if (isStoreItem) {
  6070. } else if (isWeapon) {
  6071. UTILS.generateElement({
  6072. class: "itemInfoReq",
  6073. text: !item.type ? "primary" : "secondary",
  6074. parent: itemInfoHolder
  6075. });
  6076. } else {
  6077. for (let i = 0; i < item.req.length; i += 2) {
  6078. UTILS.generateElement({
  6079. class: "itemInfoReq",
  6080. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6081. parent: itemInfoHolder
  6082. });
  6083. }
  6084. if (item.group.limit) {
  6085. UTILS.generateElement({
  6086. class: "itemInfoLmt",
  6087. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6088. parent: itemInfoHolder
  6089. });
  6090. }
  6091. }
  6092. } else {
  6093. itemInfoHolder.classList.remove("visible");
  6094. }
  6095. }
  6096. // RESIZE:
  6097. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6098. function resize() {
  6099. screenWidth = window.innerWidth;
  6100. screenHeight = window.innerHeight;
  6101. var scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6102. gameCanvas.width = screenWidth;
  6103. gameCanvas.height = screenHeight;
  6104. gameCanvas.style.width = screenWidth + "px";
  6105. gameCanvas.style.height = screenHeight + "px";
  6106. gameCanvas.style;
  6107. mainContext.setTransform(scaleFillNative, 0, 0, scaleFillNative, (screenWidth * pixelDensity - maxScreenWidth * scaleFillNative) / 2, (screenHeight * pixelDensity - maxScreenHeight * scaleFillNative) / 2);
  6108. }
  6109. resize();
  6110. // MOUSE INPUT:
  6111. const mals = document.getElementById('touch-controls-fullscreen');
  6112. mals.style.display = 'block';
  6113. mals.addEventListener("mousemove", gameInput, false);
  6114. function gameInput(e) {
  6115. mouseX = e.clientX;
  6116. mouseY = e.clientY;
  6117. }
  6118. let clicks = {
  6119. left: false,
  6120. middle: false,
  6121. right: false,
  6122. };
  6123. mals.addEventListener("mousedown", mouseDown, false);
  6124. function mouseDown(e) {
  6125. if (attackState != 1) {
  6126. attackState = 1;
  6127. if (e.button == 0) {
  6128. clicks.left = true;
  6129. } else if (e.button == 1) {
  6130. clicks.middle = true;
  6131. } else if (e.button == 2) {
  6132. clicks.right = true;
  6133. }
  6134. }
  6135. }
  6136. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6137. function mouseUp(e) {
  6138. if (attackState != 0) {
  6139. attackState = 0;
  6140. if (e.button == 0) {
  6141. clicks.left = false;
  6142. } else if (e.button == 1) {
  6143. clicks.middle = false;
  6144. } else if (e.button == 2) {
  6145. clicks.right = false;
  6146. }
  6147. }
  6148. }
  6149. mals.addEventListener("wheel", wheel, false);
  6150. function wheel(e) {
  6151. if (e.deltaY < 0) {
  6152. my.reSync = true;
  6153. } else {
  6154. my.reSync = false;
  6155. }
  6156. }
  6157. // INPUT UTILS:
  6158. function getMoveDir() {
  6159. let dx = 0;
  6160. let dy = 0;
  6161. for (let key in moveKeys) {
  6162. let tmpDir = moveKeys[key];
  6163. dx += !!keys[key] * tmpDir[0];
  6164. dy += !!keys[key] * tmpDir[1];
  6165. }
  6166. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6167. }
  6168. function getSafeDir() {
  6169. if (!player)
  6170. return 0;
  6171. if (!player.lockDir) {
  6172. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6173. }
  6174. return lastDir || 0;
  6175. }
  6176. function getAttackDir(debug) {
  6177. if (debug) {
  6178. if (!player)
  6179. return "0";
  6180.  
  6181. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6182. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6183. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6184. lastDir = "getSafeDir()";
  6185. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6186. lastDir = "traps.aim";
  6187. } else if (!player.lockDir) {
  6188. if (configs.noDir) return "undefined";
  6189. lastDir = "getSafeDir()";
  6190. }
  6191.  
  6192. return lastDir;
  6193. } else {
  6194. if (!player)
  6195. return 0;
  6196.  
  6197. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6198. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6199. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6200. lastDir = getSafeDir();
  6201. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6202. lastDir = traps.aim;
  6203. } else if (!player.lockDir) {
  6204. if (configs.noDir) return undefined;
  6205. lastDir = getSafeDir();
  6206. }
  6207.  
  6208. return lastDir || 0;
  6209. }
  6210. }
  6211.  
  6212. function getVisualDir() {
  6213. if (!player)
  6214. return 0;
  6215.  
  6216. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6217. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6218. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6219. lastDir = getSafeDir();
  6220. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6221. lastDir = traps.aim;
  6222. } else if (!player.lockDir) {
  6223. lastDir = getSafeDir();
  6224. }
  6225.  
  6226. return lastDir || 0;
  6227. }
  6228.  
  6229. // Funkce pro kontrolu, zda jste pobli? hra?e
  6230. function isNearPlayer() {
  6231. return near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap;
  6232. buyEquip(21, 1);
  6233. }
  6234. // KEYS:
  6235. function keysActive() {
  6236. return (allianceMenu.style.display != "block" &&
  6237. chatHolder.style.display != "block" &&
  6238. !menuCBFocus);
  6239. }
  6240. function toggleMenuChat() {
  6241. if (menuChatDiv.style.display != "none") {
  6242. chatHolder.style.display = "none";
  6243. if (menuChatBox.value != "") {
  6244. //commands[command.slice(1)]
  6245. let cmd = function(command) {
  6246. return {
  6247. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6248. fv: commands[command.slice(1).split(" ")[0]]
  6249. }
  6250. }
  6251. let command = cmd(menuChatBox.value);
  6252. if (command.found) {
  6253. if (typeof command.fv.action === "function") {
  6254. command.fv.action(menuChatBox.value);
  6255. }
  6256. } else {
  6257. sendChat(menuChatBox.value);
  6258. }
  6259. menuChatBox.value = "";
  6260. menuChatBox.blur();
  6261. } else {
  6262. if (menuCBFocus) {
  6263. menuChatBox.blur();
  6264. } else {
  6265. menuChatBox.focus();
  6266. }
  6267. }
  6268. }
  6269. }
  6270. function keyDown(event) {
  6271. let keyNum = event.which || event.keyCode || 0;
  6272. if (player && player.alive && keysActive()) {
  6273. if (!keys[keyNum]) {
  6274. keys[keyNum] = 1;
  6275. macro[event.key] = 1;
  6276. if (keyNum == 27) {
  6277. openMenu = !openMenu;
  6278. $("#menuDiv").toggle();
  6279. $("#menuChatDiv").toggle();
  6280. } else if (keyNum == 69) {
  6281. sendAutoGather();
  6282. } else if (keyNum == 67) {
  6283. updateMapMarker();
  6284. } else if (player.weapons[keyNum - 49] != undefined) {
  6285. player.weaponCode = player.weapons[keyNum - 49];
  6286. } else if (moveKeys[keyNum]) {
  6287. sendMoveDir();
  6288. } else if (event.key == "m") {
  6289. mills.placeSpawnPads = !mills.placeSpawnPads;
  6290. } else if (event.key == "z") {
  6291. mills.place = !mills.place;
  6292. } else if (event.key == "Z") {
  6293. typeof window.debug == "function" && window.debug();
  6294. } else if (keyNum == 32) {
  6295. packet("d", 1, getSafeDir(), 1);
  6296. packet("d", 0, getSafeDir(), 1);
  6297. } else if (event.key == ",") {
  6298. player.sync = true;
  6299. }
  6300. }
  6301. }
  6302. }
  6303. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6304. function keyUp(event) {
  6305. if (player && player.alive) {
  6306. let keyNum = event.which || event.keyCode || 0;
  6307. if (keyNum == 13) {
  6308. // toggleMenuChat();
  6309. } else if (keysActive()) {
  6310. if (keys[keyNum]) {
  6311. keys[keyNum] = 0;
  6312. macro[event.key] = 0;
  6313. if (moveKeys[keyNum]) {
  6314. sendMoveDir();
  6315. } else if (event.key == ",") {
  6316. player.sync = false;
  6317. }
  6318. }
  6319. }
  6320. }
  6321. }
  6322. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6323. function sendMoveDir() {
  6324. let newMoveDir = getMoveDir();
  6325. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6326. if (!my.autoPush) {
  6327. packet("a", newMoveDir, 1);
  6328. }
  6329. lastMoveDir = newMoveDir;
  6330. }
  6331. }
  6332. // BUTTON EVENTS:
  6333. function bindEvents() { }
  6334. bindEvents();
  6335. /** PATHFIND TEST */
  6336. function chechPathColl(tmp) {
  6337. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6338. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6339. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6340. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6341. }
  6342. function checkObject() {
  6343. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6344. for (let y = 0; y < pathFind.grid; y++) {
  6345. grid[y] = [];
  6346. for (let x = 0; x < pathFind.grid; x++) {
  6347. let tmpXY = {
  6348. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6349. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6350. }
  6351. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6352. pathFind.lastX = x;
  6353. pathFind.lastY = y;
  6354. grid[y][x] = 0;
  6355. continue;
  6356. }
  6357. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6358. if (find) {
  6359. if (find.trap) {
  6360. grid[y][x] = 0;
  6361. continue;
  6362. }
  6363. grid[y][x] = 1;
  6364. } else {
  6365. grid[y][x] = 0;
  6366. }
  6367. }
  6368. }
  6369. }
  6370. function toFancyTimeFormat(time) {
  6371. let minutes = ~~((time % 3600) / 60);
  6372. let seconds = ~~time % 60;
  6373. if (seconds <= 9) seconds = `0${seconds}`;
  6374. return `${minutes}:${seconds}`;
  6375. }
  6376. let song = {
  6377. '0:13': 'Clean up gang with a hoover,',
  6378. '0:15': 'pull up and sweep the street',
  6379. '0:17': 'Told bae book Park Chinois,',
  6380. '0:18': 'the bricks came cheap',
  6381. '0:19': 'this week',
  6382. '0:20': 'Brought out the glee',
  6383. '0:21': 'this week,',
  6384. '0:22': 'so somethin might end up',
  6385. '0:23': 'on a tee this week',
  6386. '0:24': 'Done studio time done the re',
  6387. '0:25': 'this week,',
  6388. '0:26': 'big bustdown',
  6389. '0:27': "that ain't no Jesus piece",
  6390. '0:28': 'No G17,G19 had the G17',
  6391. '0:29': 'then the G19',
  6392. '0:30': 'Had an old .44',
  6393. '0:31': 'but the pin was weak,',
  6394. '0:32': 'still gonna spin if need',
  6395. '0:35': 'Sayin no smoke backstage,',
  6396. '0:36': 'but bro still ask',
  6397. '0:37': 'can we bring it please,',
  6398. '0:38': 'or a ZK at least',
  6399. '0:40': 'You could see me',
  6400. '0:41': 'in tape with the Gs,',
  6401. '0:42': 'bro just got in a',
  6402. '0:43': 'striptape with the Gs',
  6403. '0:44': "Get the drop it's go time,",
  6404. '0:45': 'bro came out with the key',
  6405. '0:47': 'Yo, 38 autos gang said',
  6406. '0:48': 'we need more sweets',
  6407. '0:50': 'Before Halloween,',
  6408. '0:51': 'we was out playin',
  6409. '0:52': 'trick or treat',
  6410. '0:53': 'An opp boy swam and drowned,',
  6411. '0:55': "he didn't kick his feet",
  6412. '0:57': 'Heard that news',
  6413. '0:58': 'I was right by the runaway,',
  6414. '0:59': 'made me feel like bree',
  6415. '1:00': 'This C comes like',
  6416. '1:01': 'a pocket rocket,',
  6417. '1:02': 'now the gang',
  6418. '1:03': 'in central with C',
  6419. '1:04': 'Had my case papers printed,',
  6420. '1:05': 'now I got the monogram',
  6421. '1:06': 'print on me',
  6422. '1:07': 'Runnin throught bells,',
  6423. '1:08': 'throwback run with the 12',
  6424. '1:10': 'Whole 1 cover the scales,',
  6425. '1:11': 'bine at the barbeque,',
  6426. '1:12': 'better cover your girl',
  6427. '1:14': "Hate when they're",
  6428. '1:15': 'runnin their mouth,',
  6429. '1:16': 'see them runnin for help',
  6430. '1:17': "I'm in the Bando,",
  6431. '1:18': 'but let me see my man again,',
  6432. '1:19': "and I'll double the L",
  6433. '1:21': 'We really leave shit drownin,',
  6434. '1:22': "you ain't brought 3",
  6435. '1:23': 'on an outin',
  6436. '1:24': 'Shootouts in',
  6437. '1:25': 'the oldest clothes,',
  6438. '1:26': "you wouldn't believe",
  6439. '1:27': 'these outfits',
  6440. '1:28': 'Foot down no breaks,',
  6441. '1:29': 'tryna leave everythin taped',
  6442. '1:30': 'Asked bout the shotty,',
  6443. '1:31': 'told them I got it',
  6444. '1:32': 'from the farm,',
  6445. '1:33': 'now they think I got from H',
  6446. '1:34': 'Clean up gang with a hoover,',
  6447. '1:36': 'pull up and sweep the street',
  6448. '1:38': 'Told bae book Park Chinois,',
  6449. '1:39': 'the bricks came cheap',
  6450. '1:40': 'this week',
  6451. '1:41': 'Brought out the glee',
  6452. '1:42': 'this week,',
  6453. '1:43': 'so somethin might end up',
  6454. '1:44': 'on a tee this week',
  6455. '1:45': 'Done studio time done the re',
  6456. '1:46': 'this week,',
  6457. '1:47': 'big bustdown',
  6458. '1:48': "that ain't no Jesus piece",
  6459. '1:49': 'No G17,G19 had the G17',
  6460. '1:50': 'then the G19',
  6461. '1:51': 'Had an old .44',
  6462. '1:52': 'but the pin was weak,',
  6463. '1:53': 'still gonna spin if need',
  6464. '1:54': 'Sayin no smoke backstage,',
  6465. '1:55': 'but bro still ask',
  6466. '1:56': 'can we bring it please,',
  6467. '1:57': 'or a ZK at least',
  6468. '1:59': 'This opps in this',
  6469. '2:00': "spliff's sativa,",
  6470. '2:01': 'still put smoke in the whiz,',
  6471. '2:02': 'Khalifa',
  6472. '2:03': "Bad B don't wanna",
  6473. '2:04': 'lock the smoke,',
  6474. '2:05': 'I just gotta love her',
  6475. '2:06': 'and leave her',
  6476. '2:07': 'Yo, had the Liz',
  6477. '2:08': 'come like Peter',
  6478. '2:09': 'and the bujj like Cleveland',
  6479. '2:10': 'This ice in my wrist says',
  6480. '2:11': 'whole lotta money,',
  6481. '2:12': "swear it's comin like BIA",
  6482. '2:14': 'O14 me, Zee had the bruc',
  6483. '2:15': 'back in a bruck down Kia',
  6484. '2:16': "Now you'll find me in Venice,",
  6485. '2:17': 'tryin some shellfish',
  6486. '2:18': 'oh mama mia',
  6487. '2:19': 'Old school I was',
  6488. '2:20': 'hoppin out first,',
  6489. '2:21': 'had bro sayin',
  6490. '2:22': 'stop bein selfish',
  6491. '2:23': 'Yo,',
  6492. '2:24': 'now I just leave that stage,',
  6493. '2:25': 'pullin strings like Elvis',
  6494. '2:26': 'Ding dong on an outin,',
  6495. '2:27': "would've been a loss",
  6496. '2:28': 'if we found him',
  6497. '2:29': "Can't record,",
  6498. '2:30': 'need more points on the board',
  6499. '2:31': 'Gang, tape it first,',
  6500. '2:32': "then I'll give them an album",
  6501. '2:33': 'Spoke to the yard man,',
  6502. '2:34': 'wanna know the P for the .45,',
  6503. '2:35': 'like Alhan',
  6504. '2:36': 'Spoke to the runner,',
  6505. '2:37': "said he's got more than a oner",
  6506. '2:39': "and he's still counting",
  6507. '2:40': 'Go get that car,',
  6508. '2:41': 'congestion zone,',
  6509. '2:42': 'gotta step with ours',
  6510. '2:43': 'Pocket rocket,',
  6511. '2:44': 'had it in a pouch',
  6512. '2:45': 'next to the brush',
  6513. '2:46': 'and the metro card',
  6514. '2:47': 'Double R truck,',
  6515. '2:48': 'stars in the roof,',
  6516. '2:49': 'and we got a seperate star',
  6517. '2:50': "Ain't done it in a Tesla yet,",
  6518. '2:51': 'if we do thats lead',
  6519. '2:52': 'in an electric car',
  6520. '2:53': 'Clean up gang with a hoover,',
  6521. '2:55': 'pull up and sweep the street',
  6522. '2:57': 'Told bae book Park Chinois,',
  6523. '2:58': 'the bricks came cheap',
  6524. '2:59': 'this week',
  6525. '3:00': 'Brought out the glee',
  6526. '3:01': 'this week,',
  6527. '3:02': 'so somethin might end up',
  6528. '3:03': 'on a tee this week',
  6529. '3:04': 'Done studio time done the re',
  6530. '3:05': 'this week,',
  6531. '3:06': 'big bustdown',
  6532. '3:07': "that ain't no Jesus piece",
  6533. '3:08': 'No G17,G19 had the G17',
  6534. '3:09': 'then the G19',
  6535. '3:10': 'Had an old .44',
  6536. '3:11': 'but the pin was weak,',
  6537. '3:12': 'still gonna spin if need',
  6538. '3:13': 'Sayin no smoke backstage,',
  6539. '3:14': 'but bro still ask',
  6540. '3:15': 'can we bring it please,',
  6541. '3:16': 'or a ZK at least',
  6542. '3:19': '!End of song'
  6543. };
  6544. 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");
  6545. let isPlaying = false;
  6546. let currentPart = '';
  6547. function toggleSong() {
  6548. if (!isPlaying) {
  6549. songchat1.play();
  6550. songchat1.ontimeupdate = function(time) {
  6551. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  6552. if (part && part !== currentPart) {
  6553. currentPart = part;
  6554. packet("6", part);
  6555. }
  6556. };
  6557. songchat1.onended = function() {
  6558. if (isPlaying) {
  6559. songchat1.play();
  6560. }
  6561. };
  6562. isPlaying = true;
  6563. } else {
  6564. songchat1.pause();
  6565. isPlaying = false;
  6566. }
  6567. }
  6568. document.addEventListener("keypress", function(e) {
  6569. if (e.key === "C") {
  6570. toggleSong();
  6571. }
  6572. });
  6573. function createPath() {
  6574. grid = [];
  6575. checkObject();
  6576. }
  6577. function Pathfinder() {
  6578. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  6579. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  6580. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6581. packet("a", undefined, 1);
  6582. } else {
  6583. createPath();
  6584. easystar.setGrid(grid);
  6585. easystar.setAcceptableTiles([0]);
  6586. easystar.enableDiagonals();
  6587. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function(path) {
  6588. if (path === null) {
  6589. pathFind.array = [];
  6590. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6591. packet("a", undefined, 1);
  6592. } else {
  6593. packet("a", near.aim2, 1);
  6594. }
  6595. } else {
  6596. pathFind.array = path;
  6597. if (pathFind.array.length > 1) {
  6598. let tmpXY = {
  6599. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  6600. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  6601. }
  6602. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  6603. }
  6604. }
  6605. });
  6606. easystar.calculate();
  6607. }
  6608. }
  6609. }
  6610. /** PATHFIND TEST */
  6611. // ITEM COUNT DISPLAY:
  6612. let isItemSetted = [];
  6613. function updateItemCountDisplay(index = undefined) {
  6614. for (let i = 3; i < items.list.length; ++i) {
  6615. let id = items.list[i].group.id;
  6616. let tmpI = items.weapons.length + i;
  6617. if (!isItemSetted[tmpI]) {
  6618. isItemSetted[tmpI] = document.createElement("div");
  6619. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6620. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6621. isItemSetted[tmpI].style = `
  6622. display: block;
  6623. position: absolute;
  6624. padding-left: 5px;
  6625. font-size: 2em;
  6626. color: #fff;
  6627. `;
  6628. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6629. } else {
  6630. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6631. }
  6632. }
  6633. }
  6634. // AUTOPUSH:
  6635. function autoPush() {
  6636. 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) {
  6637. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6638. })[0];
  6639. if (nearTrap) {
  6640. 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) {
  6641. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6642. })[0];
  6643. if (spike) {
  6644. let pos = {
  6645. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6646. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6647. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6648. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6649. };
  6650. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6651. let tmpScale = tmp.getScale();
  6652. 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)) {
  6653. return true;
  6654. }
  6655. });
  6656. if (finds) {
  6657. if (my.autoPush) {
  6658. my.autoPush = false;
  6659. packet("a", lastMoveDir || undefined, 1);
  6660. }
  6661. } else {
  6662. my.autoPush = true;
  6663. my.pushData = {
  6664. x: spike.x + 70,
  6665. y: spike.y + 70,
  6666. x2: pos.x2 + 30,
  6667. y2: pos.y2 + 30
  6668. };
  6669. let scale = player.scale / 10;
  6670. let secondArg = UTILS.getDirect(near, spike, 2, 0) > 70 ? near.aim2 : undefined;
  6671. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6672. packet("a", secondArg, 1);
  6673. } else {
  6674. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6675. }
  6676. }
  6677. } else {
  6678. if (my.autoPush) {
  6679. my.autoPush = false;
  6680. packet("a", lastMoveDir || undefined, 1);
  6681. }
  6682. }
  6683. } else {
  6684. if (my.autoPush) {
  6685. my.autoPush = false;
  6686. packet("a", lastMoveDir || undefined, 1);
  6687. }
  6688. }
  6689. }
  6690. // AUTOPUSH:
  6691. /* function autoPush() { //LEGACY AUTOPUSH
  6692. 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) {
  6693. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6694. })[0];
  6695. if (nearTrap) {
  6696. 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) {
  6697. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6698. })[0];
  6699. if (spike) {
  6700. let pos = {
  6701. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6702. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6703. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6704. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6705. };
  6706. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6707. let tmpScale = tmp.getScale();
  6708. 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)) {
  6709. return true;
  6710. }
  6711. });
  6712. if (finds) {
  6713. if (my.autoPush) {
  6714. my.autoPush = false;
  6715. packet("33", lastMoveDir||undefined, 1);
  6716. }
  6717. } else {
  6718. my.autoPush = true;
  6719. my.pushData = {
  6720. x: spike.x,
  6721. y: spike.y,
  6722. x2: pos.x2,
  6723. y2: pos.y2
  6724. };
  6725. let scale = (player.scale / 10);
  6726. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6727. packet("33", near.aim2, 1);
  6728. } else {
  6729. packet("33", UTILS.getDirect(pos, player, 2, 2), 1);
  6730. }
  6731. }
  6732. } else {
  6733. if (my.autoPush) {
  6734. my.autoPush = false;
  6735. packet("33", lastMoveDir||undefined, 1);
  6736. }
  6737. }
  6738. } else {
  6739. if (my.autoPush) {
  6740. my.autoPush = false;
  6741. packet("33", lastMoveDir||undefined, 1);
  6742. }
  6743. }
  6744. }*/
  6745. // ADD DEAD PLAYER:
  6746. function addDeadPlayer(tmpObj) {
  6747. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6748. }
  6749. /** APPLY SOCKET CODES */
  6750. // SET INIT DATA:
  6751. function setInitData(data) {
  6752. alliances = data.teams;
  6753. }
  6754. // SETUP GAME:
  6755. var fisrtloadez = false;
  6756. function setupGame(yourSID) {
  6757. keys = {};
  6758. macro = {};
  6759. playerSID = yourSID;
  6760. attackState = 0;
  6761. inGame = true;
  6762. fisrtloadez = true;
  6763. packet("d", 0, getAttackDir(), 1);
  6764. my.ageInsta = true;
  6765. if (firstSetup) {
  6766. firstSetup = false;
  6767. gameObjects.length = 0;
  6768. }
  6769. }
  6770. // ADD NEW PLAYER:
  6771. function addPlayer(data, isYou) {
  6772. let tmpPlayer = findPlayerByID(data[0]);
  6773. if (!tmpPlayer) {
  6774. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6775. objectManager, players, ais, items, hats, accessories);
  6776. players.push(tmpPlayer);
  6777. if (data[1] != playerSID) {
  6778. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6779. }
  6780. } else {
  6781. if (data[1] != playerSID) {
  6782. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6783. }
  6784. }
  6785. tmpPlayer.spawn(isYou ? true : null);
  6786. tmpPlayer.visible = false;
  6787. tmpPlayer.oldPos = {
  6788. x2: undefined,
  6789. y2: undefined
  6790. };
  6791. tmpPlayer.x2 = undefined;
  6792. tmpPlayer.y2 = undefined;
  6793. tmpPlayer.x3 = undefined;
  6794. tmpPlayer.y3 = undefined;
  6795. tmpPlayer.setData(data);
  6796. if (isYou) {
  6797. if (!player) {
  6798. window.prepareUI(tmpPlayer);
  6799. }
  6800. player = tmpPlayer;
  6801. camX = player.x;
  6802. camY = player.y;
  6803. my.lastDir = 0;
  6804. updateItems();
  6805. updateAge();
  6806. updateItemCountDisplay();
  6807. if (player.skins[7]) {
  6808. my.reSync = true;
  6809. }
  6810. }
  6811. }
  6812. // REMOVE PLAYER:
  6813. function removePlayer(id) {
  6814. for (let i = 0; i < players.length; i++) {
  6815. if (players[i].id == id) {
  6816. let tmpPlayer = players[i];
  6817. addChatLog(tmpPlayer.name + " has died", "#db2727", "", "#db2727");
  6818. players.splice(i, 1);
  6819. break;
  6820. }
  6821. }
  6822. }
  6823. // UPDATE HEALTH:
  6824. function updateHealth(sid, value) {
  6825. tmpObj = findPlayerBySID(sid);
  6826. if (tmpObj) {
  6827. tmpObj.oldHealth = tmpObj.health;
  6828. tmpObj.health = value;
  6829. tmpObj.judgeShame();
  6830. if (tmpObj.oldHealth > tmpObj.health) {
  6831. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6832. advHeal.push([sid, value, tmpObj.damaged]);
  6833. } else {
  6834. }
  6835. }
  6836. }
  6837. // KILL PLAYER:
  6838. function killPlayer() {
  6839. inGame = false;
  6840. lastDeath = {
  6841. x: player.x,
  6842. y: player.y,
  6843. };
  6844. if (configs.autoRespawn) {
  6845. getEl("ot-sdk-btn-floating").style.display = "none";
  6846. packet("M", {
  6847. name: lastsp[0],
  6848. moofoll: lastsp[1],
  6849. skin: lastsp[2]
  6850. });
  6851. }
  6852. }
  6853. // UPDATE PLAYER ITEM VALUES:
  6854. function updateItemCounts(index, value) {
  6855. if (player) {
  6856. player.itemCounts[index] = value;
  6857. updateItemCountDisplay(index);
  6858. }
  6859. }
  6860. // UPDATE AGE:
  6861. function updateAge(xp, mxp, age) {
  6862. if (xp != undefined)
  6863. player.XP = xp;
  6864. if (mxp != undefined)
  6865. player.maxXP = mxp;
  6866. if (age != undefined)
  6867. player.age = age;
  6868. }
  6869. // UPDATE UPGRADES:
  6870. function updateUpgrades(points, age) {
  6871. player.upgradePoints = points;
  6872. player.upgrAge = age;
  6873. if (points > 0) {
  6874. tmpList.length = 0;
  6875. UTILS.removeAllChildren(upgradeHolder);
  6876. for (let i = 0; i < items.weapons.length; ++i) {
  6877. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6878. let e = UTILS.generateElement({
  6879. id: "upgradeItem" + i,
  6880. class: "actionBarItem",
  6881. onmouseout: function() {
  6882. showItemInfo();
  6883. },
  6884. parent: upgradeHolder
  6885. });
  6886. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6887. tmpList.push(i);
  6888. }
  6889. }
  6890. for (let i = 0; i < items.list.length; ++i) {
  6891. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6892. let tmpI = (items.weapons.length + i);
  6893. let e = UTILS.generateElement({
  6894. id: "upgradeItem" + tmpI,
  6895. class: "actionBarItem",
  6896. onmouseout: function() {
  6897. showItemInfo();
  6898. },
  6899. parent: upgradeHolder
  6900. });
  6901. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6902. tmpList.push(tmpI);
  6903. }
  6904. }
  6905. for (let i = 0; i < tmpList.length; i++) {
  6906. (function(i) {
  6907. let tmpItem = getEl('upgradeItem' + i);
  6908. tmpItem.onmouseover = function() {
  6909. if (items.weapons[i]) {
  6910. showItemInfo(items.weapons[i], true);
  6911. } else {
  6912. showItemInfo(items.list[i - items.weapons.length]);
  6913. }
  6914. };
  6915. tmpItem.onclick = UTILS.checkTrusted(function() {
  6916. packet("H", i);
  6917. });
  6918. UTILS.hookTouchEvents(tmpItem);
  6919. })(tmpList[i]);
  6920. }
  6921. if (tmpList.length) {
  6922. upgradeHolder.style.display = "block";
  6923. upgradeCounter.style.display = "block";
  6924. upgradeCounter.style.borderRadius = "4px";
  6925. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6926. } else {
  6927. upgradeHolder.style.display = "none";
  6928. upgradeCounter.style.display = "none";
  6929. showItemInfo();
  6930. }
  6931. } else {
  6932. upgradeHolder.style.display = "none";
  6933. upgradeCounter.style.display = "none";
  6934. showItemInfo();
  6935. }
  6936. }
  6937. function cdf(e, t) {
  6938. try {
  6939. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6940. } catch (e) {
  6941. return Infinity;
  6942. }
  6943. }
  6944. function caf(e, t) {
  6945. try {
  6946. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6947. } catch (e) {
  6948. return 0;
  6949. }
  6950. }
  6951. function numArr(e = 0, t = 1, act, n = 1) {
  6952. let arr = [];
  6953. for (let i = e; i < t; i += n) {
  6954. arr.push(i);
  6955. typeof act == "function" && act(i);
  6956. }
  6957. return arr;
  6958. }
  6959. function toR(e) {
  6960. var n = (e * Math.PI / 180) % (2 * Math.PI);
  6961. return n > Math.PI ? Math.PI - n : n
  6962. }
  6963. function toD(e) {
  6964. var n = (e / Math.PI * 360) % 360;
  6965. return n >= 360 ? n - 360 : n;
  6966. }
  6967.  
  6968. // KILL OBJECT:
  6969. function killObject(sid) {
  6970. let findObj = findObjectBySid(sid);
  6971. objectManager.disableBySid(sid);
  6972. if (player) {
  6973. for (let i = 0; i < breakObjects.length; i++) {
  6974. if (breakObjects[i].sid == sid) {
  6975. breakObjects.splice(i, 1);
  6976. break;
  6977. }
  6978. }
  6979. if (!player.canSee(findObj)) {
  6980. breakTrackers.push({x: findObj.x, y: findObj.y});
  6981. }
  6982. if (breakTrackers.length > 8) {
  6983. breakTrackers.shift();
  6984. }
  6985. traps.replacer(findObj);
  6986. }
  6987. }
  6988. // KILL ALL OBJECTS BY A PLAYER:
  6989. function killObjects(sid) {
  6990. if (player) objectManager.removeAllItems(sid);
  6991. }
  6992. function fgdo(a, b) {
  6993. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  6994. }
  6995. function precheckPlace(a, b) {
  6996. checkPlace(a, b);
  6997. console.log('success');
  6998. }
  6999. function perfectReplace() {
  7000. // let range = items.weapons[player.weapons[0]].range + 70;
  7001. // const interval = setInterval(() => {
  7002. // gameObjects.forEach(tmpObj => {
  7003. // let objDst = UTILS.getDist(tmpObj, player, 0, 2);
  7004. // let perfectAngle = UTILS.getDirect(tmpObj, player, 0, 2);
  7005. // if (tmpObj.health <= 272.58 && fgdo(tmpObj, player) <= range && near.dist2 <= 300) {
  7006. // console.log('preplace');
  7007. // place(2, perfectAngle);
  7008. // }
  7009. // });
  7010. // });
  7011. // setTimeout(() => {
  7012. // clearInterval(interval);
  7013. // }, 500);
  7014. }
  7015. let ticks = {
  7016. tick: 0,
  7017. delay: 0,
  7018. time: [],
  7019. manage: [],
  7020. };
  7021. // GAME TICKOUT:
  7022. function setTickout(doo, timeout) {
  7023. if (!ticks.manage[ticks.tick + timeout]) {
  7024. ticks.manage[ticks.tick + timeout] = [doo];
  7025. } else {
  7026. ticks.manage[ticks.tick + timeout].push(doo);
  7027. }
  7028. }
  7029. function doNextTick(doo) {
  7030. waitTicks.push(doo);
  7031. }
  7032. let waitTicks = [];
  7033. // UPDATE PLAYER DATA:
  7034. let nEy;
  7035. let plaguemask = true;
  7036. let placeableSpikes = [];
  7037. let placeableTraps = [];
  7038. let placeableSpikesPREDICTS = [];
  7039. function updatePlayers(data) {
  7040. game.tick++;
  7041. enemy = [];
  7042. perfectReplace();
  7043. nears = [];
  7044. near = [];
  7045. //showPlace = [];
  7046. game.tickSpeed = performance.now() - game.lastTick;
  7047. game.lastTick = performance.now();
  7048. ticks.tick++;
  7049. ticks.time.push(Date.now() - ticks.delay <= 50 || Date.now() - ticks.delay >= 175 ? "lag" : 1);
  7050. if (ticks.tick % 10 === 0) {
  7051. ticks.time = [];
  7052. }
  7053. if (ticks.tick % 300 === 0) {
  7054. }
  7055. ticks.delay = Date.now();
  7056. players.forEach((tmp) => {
  7057. tmp.forcePos = !tmp.visible;
  7058. tmp.visible = false;
  7059. });
  7060. for (let i = 0; i < data.length;) {
  7061. tmpObj = findPlayerBySID(data[i]);
  7062. if (tmpObj) {
  7063. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7064. tmpObj.t2 = game.lastTick;
  7065. tmpObj.oldPos.x2 = tmpObj.x2;
  7066. tmpObj.oldPos.y2 = tmpObj.y2;
  7067. tmpObj.x1 = tmpObj.x;
  7068. tmpObj.y1 = tmpObj.y;
  7069. tmpObj.x2 = data[i + 1];
  7070. tmpObj.y2 = data[i + 2];
  7071. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7072. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7073. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7074. tmpObj.d2 = data[i + 3];
  7075. tmpObj.dt = 0;
  7076. tmpObj.buildIndex = data[i + 4];
  7077. tmpObj.weaponIndex = data[i + 5];
  7078. tmpObj.weaponVariant = data[i + 6];
  7079. tmpObj.team = data[i + 7];
  7080. tmpObj.isLeader = data[i + 8];
  7081. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7082. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7083. tmpObj.skinIndex = data[i + 9];
  7084. tmpObj.tailIndex = data[i + 10];
  7085. tmpObj.iconIndex = data[i + 11];
  7086. tmpObj.zIndex = data[i + 12];
  7087. tmpObj.visible = true;
  7088. tmpObj.update(game.tickSpeed);
  7089. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7090. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7091. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7092. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7093. tmpObj.damageThreat = 0;
  7094. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7095. tmpObj.addShameTimer();
  7096. }
  7097. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7098. tmpObj.shameTimer = 0;
  7099. tmpObj.shameCount = 0;
  7100. if (tmpObj == player) {
  7101. healer();
  7102. }
  7103. }
  7104. nEy = tmpObj;
  7105. if (tmpObj == player) {
  7106. if (gameObjects.length) {
  7107. gameObjects.forEach((tmp) => {
  7108. tmp.onNear = false;
  7109. if (tmp.active) {
  7110. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7111. tmp.onNear = true;
  7112. }
  7113. if (tmp.isItem && tmp.owner) {
  7114. 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)) {
  7115. tmp.breakObj = true;
  7116. breakObjects.push({
  7117. x: tmp.x,
  7118. y: tmp.y,
  7119. sid: tmp.sid
  7120. });
  7121. }
  7122. }
  7123. }
  7124. });
  7125. 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) {
  7126. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7127. })[0];
  7128. if (nearTrap) {
  7129. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7130. traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7131. if (!traps.inTrap) {
  7132. traps.protect(traps.aim);
  7133. }
  7134. traps.inTrap = true;
  7135. traps.info = nearTrap;
  7136. } else {
  7137. traps.inTrap = false;
  7138. traps.info = {};
  7139. }
  7140. } else {
  7141. traps.inTrap = false;
  7142. }
  7143. }
  7144. if (tmpObj.weaponIndex < 9) {
  7145. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7146. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7147. } else if (tmpObj.weaponIndex > 8) {
  7148. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7149. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7150. }
  7151. }
  7152. i += 13;
  7153. }
  7154. if (waitTicks.length) {
  7155. waitTicks.forEach((ajaj) => {
  7156. ajaj();
  7157. }
  7158. );
  7159. waitTicks = [];
  7160. }
  7161. if (runAtNextTick.length) {
  7162. runAtNextTick.forEach((tmp) => {
  7163. checkProjectileHolder(...tmp);
  7164. }
  7165. );
  7166. runAtNextTick = [];
  7167. }
  7168. if (textManager.stack.length) {
  7169. let stacks = [];
  7170. let notstacks = [];
  7171. let num = 0;
  7172. let num2 = 0;
  7173. let pos = {
  7174. x: null,
  7175. y: null
  7176. };
  7177. let pos2 = {
  7178. x: null,
  7179. y: null
  7180. }
  7181. textManager.stack.forEach((text) => {
  7182. if (text.value >= 0) {
  7183. if (num == 0) pos = {
  7184. x: text.x,
  7185. y: text.y
  7186. };
  7187. num += Math.abs(text.value);
  7188. } else {
  7189. if (num2 == 0) pos2 = {
  7190. x: text.x,
  7191. y: text.y
  7192. };
  7193. num2 += Math.abs(text.value);
  7194. }
  7195. });
  7196. if (num2 > 0) {
  7197. textManager.showText(pos2.x, pos2.y, Math.max(43, Math.min(50, num2)), 0.18, 500, num2, damageTextColor = "#782F44");
  7198. }
  7199. if (num > 0) {
  7200. textManager.showText(pos.x, pos.y, Math.max(43, Math.min(50, num)), 0.18, 500, num, damageTextColor = "#782F44");
  7201. }
  7202. textManager.stack = [];
  7203. }
  7204. if (runAtNextTick.length) {
  7205. runAtNextTick.forEach((tmp) => {
  7206. checkProjectileHolder(...tmp);
  7207. });
  7208. runAtNextTick = [];
  7209. }
  7210. for (let i = 0; i < data.length;) {
  7211. tmpObj = findPlayerBySID(data[i]);
  7212. if (tmpObj) {
  7213. if (!tmpObj.isTeam(player)) {
  7214. enemy.push(tmpObj);
  7215. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7216. nears.push(tmpObj);
  7217. }
  7218. }
  7219. tmpObj.manageReload();
  7220. if (tmpObj != player) {
  7221. tmpObj.addDamageThreat(player);
  7222. }
  7223. }
  7224. i += 13;
  7225. }
  7226. /*projectiles.forEach((proj) => {
  7227. tmpObj = proj;
  7228. if (tmpObj.active) {
  7229. tmpObj.tickUpdate(game.tickSpeed);
  7230. }
  7231. });*/
  7232. if (player && player.alive) {
  7233. if (enemy.length) {
  7234. if (player && player.alive){
  7235. placeableSpikes = getPlaceablePositions(player, items.list[player.items[2]]);
  7236. placeableTraps = player.items[4] == 15 ? getPlaceablePositions(player, items.list[player.items[4]]) : [];
  7237. }
  7238.  
  7239. near = enemy.sort(function(tmp1, tmp2) {
  7240. return tmp1.dist2 - tmp2.dist2;
  7241. })[0];
  7242. } else {
  7243. // console.log("no enemy");
  7244. }
  7245. if (game.tickQueue[game.tick]) {
  7246. game.tickQueue[game.tick].forEach((action) => {
  7247. action();
  7248. });
  7249. game.tickQueue[game.tick] = null;
  7250. }
  7251. if (advHeal.length) {
  7252. advHeal.forEach((updHealth) => {
  7253. let sid = updHealth[0];
  7254. let value = updHealth[1];
  7255. let totalDamage = 100 - value
  7256. let damaged = updHealth[2];
  7257. tmpObj = findPlayerBySID(sid);
  7258. let bullTicked = false;
  7259. if (tmpObj && tmpObj.health <= 0) {
  7260. if (!tmpObj.death) {
  7261. tmpObj.death = true;
  7262. if (tmpObj != player) {
  7263. addChatLog(tmpObj.name + " has died", "#db2727", "", "#db2727");
  7264. }
  7265. addDeadPlayer(tmpObj);
  7266. }
  7267. }
  7268. if (tmpObj == player) {
  7269. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7270. if (my.reSync) {
  7271. my.reSync = false;
  7272. tmpObj.setBullTick = true;
  7273. }
  7274. bullTicked = true;
  7275. }
  7276. if (inGame) {
  7277. let dmg = 100 - player.health;
  7278. let attackers = getAttacker(damaged);
  7279. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7280. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  7281. let heal = function () {
  7282. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && clicks.left)) {
  7283. setTimeout(() => {
  7284. healer();
  7285. }, 140 - window.pingTime);
  7286. } else {
  7287. setTimeout(() => {
  7288. healer()
  7289. }, 222 - window.pingTime);
  7290. }
  7291. }
  7292. if (attackers.length) {
  7293. let by = attackers.filter((tmp) => {
  7294. if (tmp.dist2 <= (tmp.weaponIndex < 9 ? 300 : 700)) {
  7295. tmpDir = UTILS.getDirect(player, tmp, 2, 2);
  7296. if (UTILS.getAngleDist(tmpDir, tmp.d2) <= Math.PI) {
  7297. return tmp;
  7298. }
  7299. }
  7300. });
  7301. if (by.length) {
  7302. let maxDamage = (includeSpikeDmgs ? 10 : 10);
  7303. if (damaged > maxDamage && (game.tick - tmpObj.antiTimer) > 1) {
  7304. tmpObj.canEmpAnti = true;
  7305. tmpObj.antiTimer = game.tick;
  7306. if (tmpObj.shameCount < 5) {
  7307. healer();
  7308. } else {
  7309. heal();
  7310. }
  7311. } else {
  7312. heal();
  7313. }
  7314. } else {
  7315. heal();
  7316. }
  7317. } else {
  7318. heal();
  7319. }
  7320. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7321. }
  7322. } else {
  7323. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7324. tmpObj.setPoisonTick = true;
  7325. }
  7326. }
  7327. });
  7328. advHeal = [];
  7329. }
  7330. players.forEach((tmp) => {
  7331. if (!tmp.visible && player != tmp) {
  7332. tmp.reloads = {
  7333. 0: 0,
  7334. 1: 0,
  7335. 2: 0,
  7336. 3: 0,
  7337. 4: 0,
  7338. 5: 0,
  7339. 6: 0,
  7340. 7: 0,
  7341. 8: 0,
  7342. 9: 0,
  7343. 10: 0,
  7344. 11: 0,
  7345. 12: 0,
  7346. 13: 0,
  7347. 14: 0,
  7348. 15: 0,
  7349. 53: 0,
  7350. };
  7351. }
  7352. if (tmp.setBullTick) {
  7353. tmp.bullTimer = 0;
  7354. }
  7355. if (tmp.setPoisonTick) {
  7356. tmp.poisonTimer = 0;
  7357. }
  7358. tmp.updateTimer();
  7359. });
  7360. if (inGame) {
  7361. ping = window.pingTime
  7362. inWater = player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2
  7363. if (enemy.length) {
  7364. if (configs1.AutoQonSync && nears.length > 1 && player.shameCount < 5 && !nears.some(item => [0, 7, 8, 9].includes(item.primaryIndex)) && secPacket < 40) {
  7365. sendChat("sync detect test")
  7366. tmpObj.canEmpAnti = false
  7367. my.anti0Tick = 3
  7368. predictHeal(2)
  7369. if (player.health < 90) {
  7370. healer()
  7371. }
  7372. }
  7373. if (configs1.AutoQonHigh && ping >= 80) {
  7374. let dmg = 100 - player.health
  7375. if ((tmpObj.damageThreat >= 95 || dmg + tmpObj.damageThreat >= 95) && player.skinIndex != 7 && player.shameCount < 5) {
  7376. predictHeal(2)
  7377. } else {
  7378. setTimeout(() => {
  7379. healer()
  7380. }, 120 - ping)
  7381. }
  7382. }
  7383. if (configs.fpsboost) {
  7384. window.location.native_resolution = true;
  7385. setTimeout(() => {
  7386. console.clear
  7387. }, 2000);
  7388. }
  7389. if (configs1.AutoPlace) {
  7390. autoplacer()
  7391. }
  7392. packetData.placeQ = packetData.place;
  7393. packetData.place = [];
  7394. if (packetData.placeQ.length) for (let i = 0; i < packetData.placeQ.length; i++) {
  7395. 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])) {
  7396. place(packetData.placeQ[i][0], packetData.placeQ[i][1]);
  7397. }
  7398. }
  7399. if (player.canEmpAnti) {
  7400. player.canEmpAnti = false;
  7401. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7402. if (near.reloads[53] == 0) {
  7403. player.empAnti = true;
  7404. player.soldierAnti = false;
  7405. //modLog("EmpAnti");
  7406. } else {
  7407. player.empAnti = false;
  7408. player.soldierAnti = true;
  7409. //modLog("SoldierAnti");
  7410. }
  7411. }
  7412. }
  7413. 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) {
  7414. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7415. })[0];
  7416. if (prehit) {
  7417. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs1.AutoPredictTick) {
  7418. instaC.canSpikeTick = true;
  7419. instaC.syncHit = true;
  7420. if (instaC.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7421. instaC.revTick = true;
  7422. }
  7423. }
  7424. }
  7425. 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) {
  7426. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7427. })[0];
  7428. let moreAntiSpikeTick = traps.checkSpikeTick()
  7429. if (antiSpikeTick && !traps.inTrap) {
  7430. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7431. my.anti0Tick = 1;
  7432. packet("6", "hi : " + near.sid);
  7433. player.chat.count = 2000;
  7434. }
  7435. }
  7436. if (moreAntiSpikeTick) {
  7437. my.anti0Tick = 4;
  7438. sendChat("op anti spike tick wat ofc")
  7439. }
  7440. }
  7441. nears.forEach((tmpPlayer) => {
  7442. if (tmpPlayer.primaryIndex == 5 && tmpPlayer.primaryVariant >= 2) {
  7443. if (tmpPlayer.dist2 >= 160 && tmpPlayer.dist2 < 260) {
  7444. if (tmpPlayer.skinIndex == 53) {
  7445. buyEquip(6, 0);
  7446. }
  7447. }
  7448. }
  7449. })
  7450. if ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100) &&
  7451. near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 &&
  7452. (instaC.wait || (Math.floor(Math.random() * 5) == 0)) &&
  7453. !instaC.isTrue &&
  7454. !my.waitHit &&
  7455. player.reloads[player.weapons[0]] == 0 &&
  7456. player.reloads[player.weapons[1]] == 0 &&
  7457. (getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) &&
  7458. instaC.perfCheck(player, near)) {
  7459.  
  7460. if (player.checkCanInsta(true) >= 100) {
  7461. instaC.nobull = false;
  7462. } else {
  7463. instaC.nobull = false; // Note: This line seems redundant in the original code
  7464. }
  7465.  
  7466. instaC.can = true;
  7467. } else {
  7468. instaC.can = false;
  7469. }
  7470.  
  7471. macro.q && place(0, getAttackDir());
  7472. macro.f && place(4, getSafeDir());
  7473. macro.v && place(2, getSafeDir());
  7474. macro.y && place(5, getSafeDir());
  7475. macro.h && place(player.getItemType(22), getSafeDir());
  7476. macro.n && place(3, getSafeDir());
  7477.  
  7478. if (game.tick % 3 == 0) {
  7479. if (mills.place) {
  7480. let plcAng = 1.25;
  7481. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7482. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7483. }
  7484. } else {
  7485. if (mills.placeSpawnPads) {
  7486. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7487. checkPlace(
  7488. player.getItemType(20),
  7489. UTILS.getDirect(player.oldPos, player, 2, 2) + i
  7490. );
  7491. }
  7492. }
  7493. }
  7494. }
  7495.  
  7496. if (instaC.can) {
  7497. instaC.changeType("rev");
  7498. }
  7499.  
  7500. if (instaC.canCounter) {
  7501. instaC.canCounter = false;
  7502. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7503. instaC.counterType();
  7504. }
  7505. }
  7506.  
  7507. if (instaC.canSpikeTick) {
  7508. instaC.canSpikeTick = false;
  7509. if (instaC.revTick) {
  7510. instaC.revTick = false;
  7511. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7512. instaC.changeType("rev");
  7513. }
  7514. } else {
  7515. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7516. instaC.spikeTickType();
  7517. if (instaC.syncHit) {
  7518. }
  7519. }
  7520. }
  7521. }
  7522. let turretEmp = 0;
  7523. let inbullspam = false;
  7524. let waitTicks = [];
  7525. let anti0Tick = 0;
  7526. let syncCount = 0;
  7527. let doEmpAntiInsta = false;
  7528. let plagueCount = 0;
  7529. 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) {
  7530. setTimeout(() => {
  7531. if (player.weaponIndex !== player.weapons[0] || player.buildIndex > -1) {
  7532. selectWeapon(player.weapons[0]);
  7533. }
  7534. if (player.reloads[player.weapons[0]] === 0 && !my.waitHit) {
  7535. sendAutoGather();
  7536. my.waitHit = 1;
  7537. my.autoAim = true;
  7538. inbullspam = true;
  7539. Hg(!plaguemask ? 7 : 21, 18);
  7540. game.tickBase(() => {
  7541. sendAutoGather();
  7542. my.waitHit = 0;
  7543. my.autoAim = false;
  7544. inbullspam = false;
  7545. Hg(near.skinIndex === 7 ? near.antiBull > 0 ? 11 : 6 : 6, 21);
  7546. }, 10);
  7547. }
  7548. }, 5);
  7549. } else {
  7550. inbullspam = false;
  7551. }
  7552.  
  7553. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7554. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7555. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7556. }
  7557. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7558. sendAutoGather();
  7559. my.waitHit = 1;
  7560. game.tickBase(() => {
  7561. sendAutoGather();
  7562. my.waitHit = 0;
  7563. }, 1);
  7564. }
  7565. }
  7566. if (traps.inTrap) {
  7567. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7568. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7569. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7570. }
  7571. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7572. sendAutoGather();
  7573. my.waitHit = 1;
  7574. invisBody = true;
  7575. game.tickBase(() => {
  7576. sendAutoGather();
  7577. my.waitHit = 0;
  7578. invisBody = false;
  7579. }, 1);
  7580. }
  7581. }
  7582. }
  7583. if (clicks.middle && !traps.inTrap) {
  7584. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7585. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7586. instaC.bowMovement();
  7587. } else {
  7588. instaC.rangeType();
  7589. }
  7590. }
  7591. }
  7592. if (macro.t && !traps.inTrap) {
  7593. 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))) {
  7594. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7595. }
  7596. }
  7597. if (macro["."] && !traps.inTrap) {
  7598. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7599. instaC.boostTickMovement();
  7600. }
  7601. }
  7602. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue) {
  7603. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7604. if (!my.reloaded) {
  7605. my.reloaded = true;
  7606. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7607. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7608. selectWeapon(player.weapons[fastSpeed]);
  7609. }
  7610. }
  7611. } else {
  7612. my.reloaded = false;
  7613. if (player.reloads[player.weapons[0]] > 0) {
  7614. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7615. selectWeapon(player.weapons[0]);
  7616. }
  7617. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7618. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7619. selectWeapon(player.weapons[1]);
  7620. }
  7621. }
  7622. }
  7623. }
  7624. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7625. packet("D", getAttackDir());
  7626. }
  7627. let hatChanger = function() {
  7628. if (my.anti0Tick > 0) {
  7629. buyEquip(6, 0);
  7630. } else {
  7631. if ((!enemy.length || tmpObj.mostDamageThreat <= 95) && player.shameCount > 0 && (player.skinIndex != 45) || my.reSync) {
  7632. buyEquip(7, 0);
  7633. } else {
  7634. if (clicks.left || clicks.right) {
  7635. if (clicks.left) {
  7636. 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);
  7637. } else if (clicks.right) {
  7638. 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);
  7639. }
  7640. } else if (traps.inTrap) {
  7641. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7642. buyEquip(40, 0);
  7643. if (near.dist2 > 300 && (!player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7644. buyEquip(6, 0);
  7645. }
  7646. } else {
  7647. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 6 : 22, 0);
  7648. }
  7649. } else {
  7650. if (player.empAnti || player.soldierAnti) {
  7651. buyEquip(player.empAnti ? 6 : 40, 0);
  7652. } else {
  7653. if (inWater) {
  7654. if (!configs1.alwaysFlipper) {
  7655. if (near.dist2 <= 300) {
  7656. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7657. } else {
  7658. biomeGear()
  7659. }
  7660. } else {
  7661. biomeGear()
  7662. }
  7663. } else {
  7664. biomeGear()
  7665. }
  7666. }
  7667. }
  7668. }
  7669. }
  7670. }
  7671. let accChanger = function() {
  7672. if (clicks.left) {
  7673. buyEquip(21, 1);
  7674. } else if (clicks.right) {
  7675. buyEquip(21, 1)
  7676. } else if (traps.inTrap) {
  7677. buyEquip(21, 1);
  7678. } else if (near.dist2 < 300) {
  7679. if (getEl("antiBullType").value == "noab") {
  7680. buyEquip(21, 1)
  7681. } else if (inWater) {
  7682. buyEquip(21, 1)
  7683. } else {
  7684. buyEquip(21, 1);
  7685. }
  7686. } else {
  7687. buyEquip(11, 1);
  7688. }
  7689. }
  7690. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7691. hatChanger();
  7692. accChanger();
  7693. }
  7694. if (configs1.AutoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7695. autoPush();
  7696. } else {
  7697. if (my.autoPush) {
  7698. my.autoPush = false;
  7699. packet("a", lastMoveDir || undefined, 1);
  7700. }
  7701. }
  7702. if (!my.autoPush && pathFind.active) {
  7703. Pathfinder();
  7704. }
  7705. if (instaC.ticking) {
  7706. instaC.ticking = false;
  7707. }
  7708. if (instaC.syncHit) {
  7709. instaC.syncHit = false;
  7710. }
  7711. if (player.empAnti) {
  7712. player.empAnti = false;
  7713. }
  7714. if (player.soldierAnti) {
  7715. player.soldierAnti = false;
  7716. }
  7717. if (my.anti0Tick > 0) {
  7718. my.anti0Tick--;
  7719. }
  7720. if (traps.replaced) {
  7721. traps.replaced = false;
  7722. }
  7723. if (traps.antiTrapped) {
  7724. traps.antiTrapped = false;
  7725. }
  7726. }
  7727. }
  7728. if (botSkts.length) {
  7729. botSkts.forEach((bots) => {
  7730. if (true) {
  7731. bots[0].ssend("player", player, near, botIDS);
  7732. }
  7733. });
  7734. }
  7735. }
  7736. // UPDATE LEADERBOARD:
  7737. function updateLeaderboard(data) {
  7738. UTILS.removeAllChildren(leaderboardData);
  7739. var tmpC = 1;
  7740. for (var i = 0; i < data.length; i += 3) {
  7741. // console.log(data);
  7742. (function(i) {
  7743. UTILS.generateElement({
  7744. class: "leaderHolder",
  7745. parent: leaderboardData,
  7746. children: [
  7747. UTILS.generateElement({
  7748. class: "leaderboardItem",
  7749. 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;",
  7750. text: (data[i + 1] != "" ? data[i + 1] : "unknown") + " |"
  7751. }),
  7752. UTILS.generateElement({
  7753. class: "a", //class: "leaderScore",
  7754. 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;",
  7755. text: ("? " + UTILS.kFormat(data[i + 2]) || "? 0")
  7756. })
  7757. ]
  7758. });
  7759. })(i);
  7760. tmpC++;
  7761. }
  7762. }
  7763.  
  7764. // LOAD GAME OBJECT:
  7765. function loadGameObject(data) {
  7766. for (let i = 0; i < data.length;) {
  7767. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7768. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7769. sid: data[i + 7]
  7770. } : null));
  7771. i += 8;
  7772. }
  7773. }
  7774. // ADD AI:
  7775. function loadAI(data) {
  7776. for (let i = 0; i < ais.length; ++i) {
  7777. ais[i].forcePos = !ais[i].visible;
  7778. ais[i].visible = false;
  7779. }
  7780. if (data) {
  7781. let tmpTime = performance.now();
  7782. for (let i = 0; i < data.length;) {
  7783. tmpObj = findAIBySID(data[i]);
  7784. if (tmpObj) {
  7785. tmpObj.index = data[i + 1];
  7786. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7787. tmpObj.t2 = tmpTime;
  7788. tmpObj.x1 = tmpObj.x;
  7789. tmpObj.y1 = tmpObj.y;
  7790. tmpObj.x2 = data[i + 2];
  7791. tmpObj.y2 = data[i + 3];
  7792. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7793. tmpObj.d2 = data[i + 4];
  7794. tmpObj.health = data[i + 5];
  7795. tmpObj.dt = 0;
  7796. tmpObj.visible = true;
  7797. } else {
  7798. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7799. tmpObj.x2 = tmpObj.x;
  7800. tmpObj.y2 = tmpObj.y;
  7801. tmpObj.d2 = tmpObj.dir;
  7802. tmpObj.health = data[i + 5];
  7803. if (!aiManager.aiTypes[data[i + 1]].name)
  7804. tmpObj.name = config.cowNames[data[i + 6]];
  7805. tmpObj.forcePos = true;
  7806. tmpObj.sid = data[i];
  7807. tmpObj.visible = true;
  7808. }
  7809. i += 7;
  7810. }
  7811. }
  7812. }
  7813. // ANIMATE AI:
  7814. function animateAI(sid) {
  7815. tmpObj = findAIBySID(sid);
  7816. if (tmpObj) tmpObj.startAnim();
  7817. }
  7818. function gatherAnimation(sid, didHit, index) {
  7819. tmpObj = findPlayerBySID(sid);
  7820. if (tmpObj) {
  7821. tmpObj.startAnim(didHit, index);
  7822. tmpObj.gatherIndex = index;
  7823. tmpObj.gathering = 1;
  7824.  
  7825. // code by Xiaokai [Simple Anti]
  7826. 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);
  7827.  
  7828. if (didHit) {
  7829. let tmpObjects = objectManager.hitObj;
  7830. //preplacer
  7831. setTickout(() => {
  7832. setTimeout(() => {
  7833. if(getDist(player, enemy) <= 200) {
  7834. place(2, getDir(tmpObjects, player))
  7835. } else {
  7836. place(4, getDir(tmpObjects, player))
  7837. }
  7838. }, items.weapons[index].speed - window.pingTime)
  7839. }, 2)
  7840.  
  7841. objectManager.hitObj = [];
  7842.  
  7843. game.tickBase(() => {
  7844. tmpObj = findPlayerBySID(sid);
  7845. 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);
  7846. tmpObjects.forEach((healthy) => {
  7847. healthy.healthMov = healthy.health - val / 2;
  7848. healthy.health -= val;
  7849. //love to https://gist.github.com/bendc/76c48ce53299e6078a76
  7850. let h, s, l;
  7851. let color = (() => {
  7852. const randomInt = (min, max) => {
  7853. return Math.floor(Math.random() * (max - min + 1)) + min;
  7854. };
  7855. h = randomInt(0, 360);
  7856. s = randomInt(42, 98);
  7857. l = randomInt(40, 90);
  7858. // return `hsl(${h},${s}%,${l}%)`;
  7859. })();
  7860. //and love https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
  7861. function hslToHex(h, s, l) {
  7862. l /= 100;
  7863. const a = s * Math.min(l, 1 - l) / 100;
  7864. const f = n => {
  7865. const k = (n + h / 30) % 12;
  7866. const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
  7867. return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
  7868. };
  7869. return `#${f(0)}${f(8)}${f(4)}`;
  7870. }
  7871. console.log(hslToHex(h, s, l));
  7872. (healthy.x, healthy.y, val, hslToHex(h, s, l));
  7873. });
  7874. }, 1);
  7875. }
  7876. }
  7877. }
  7878. function showDamageText(x, y, value, color) {
  7879. textManager.showText(x, y, 30, 0.15, 550, Math.round(value), color);
  7880. }
  7881.  
  7882. // WIGGLE GAME OBJECT:
  7883. function wiggleGameObject(dir, sid) {
  7884. tmpObj = findObjectBySid(sid);
  7885. if (tmpObj) {
  7886. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7887. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7888. if (tmpObj.health) {
  7889. //tmpObj.damaged = Math.min(255, tmpObj.damaged + 60);
  7890. objectManager.hitObj.push(tmpObj);
  7891. }
  7892. }
  7893. }
  7894. // SHOOT TURRET:
  7895. function shootTurret(sid, dir) {
  7896. tmpObj = findObjectBySid(sid);
  7897. if (tmpObj) {
  7898. tmpObj.dir = dir;
  7899. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7900. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7901. }
  7902. }
  7903. function randomizePhrases2() {
  7904. 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...'];
  7905. return phrases[Math.floor(Math.random() * phrases.length)];
  7906. }
  7907. // UPDATE PLAYER VALUE:
  7908. function updatePlayerValue(index, value, updateView) {
  7909. if (player) {
  7910. player[index] = value;
  7911.  
  7912. if (index == "points") {
  7913. if (configs.autoBuy) {
  7914. autoBuy.hat();
  7915. autoBuy.acc();
  7916. }
  7917. } else if (index == "kills") {
  7918. if (configs.killChat) {
  7919. packet("6", "Wake up to reality.")
  7920. setTimeout(() => {
  7921. packet("6", "Nothing goes as ever planned.")
  7922. setTimeout(() => {
  7923. packet("6", "I��ve sent you to the void.")
  7924. setTimeout(() => {
  7925. packet("6", "Kids in the void: " + player.kills)
  7926. }, 1500);
  7927. }, 1500);
  7928. }, 1500);
  7929. }
  7930. }
  7931. }
  7932. }
  7933. // Function to get a varying kill chat message
  7934. // Function to get a varying kill chat message
  7935. function getKillChatMessage(kills) {
  7936. // Calculate the base kill count
  7937. let baseKillCount = Math.floor(kills / 10) * 10;
  7938.  
  7939. if (kills <= 1) {
  7940. return "";
  7941. } else if (kills <= 2) {
  7942. return "";
  7943. } else if (kills <= 3) {
  7944. return "";
  7945. } else if (kills <= 4) {
  7946. return "";
  7947. } else if (kills <= 5) {
  7948. return "";
  7949. } else if (kills <= 6) {
  7950. return "";
  7951. } else if (kills <= 7) {
  7952. return "";
  7953. } else if (kills <= 8) {
  7954. return "";
  7955. } else if (kills <= 9) {
  7956. return "";
  7957. } else if (kills <= 10) {
  7958. return "";
  7959. } else if (kills <= 11) {
  7960. return "";
  7961. } else if (kills <= 12) {
  7962. return "";
  7963. } else if (kills <= 13) {
  7964. return "";
  7965. } else if (kills <= 14) {
  7966. return "";
  7967. } else if (kills <= 15) {
  7968. return "";
  7969. } else if (kills <= 16) {
  7970. return "";
  7971. } else if (kills <= 17) {
  7972. return "";
  7973. } else if (kills <= 18) {
  7974. return "";
  7975. } else if (kills <= 19) {
  7976. return "";
  7977. } else if (kills <= 20) {
  7978. return "";
  7979. } else if (kills <= 21) {
  7980. return "";
  7981. } else if (kills <= 22) {
  7982. return "";
  7983. } else if (kills <= 23) {
  7984. return "";
  7985. } else if (kills <= 24) {
  7986. return "";
  7987. } else if (kills <= 25) {
  7988. return "";
  7989. } else if (kills <= 26) {
  7990. return "";
  7991. } else if (kills <= 27) {
  7992. return "";
  7993. } else if (kills <= 28) {
  7994. return "";
  7995. } else if (kills <= 29) {
  7996. return "";
  7997. } else if (kills <= 30) {
  7998. return "";
  7999. } else {
  8000.  
  8001. // Display additional information when the kill count crosses a multiple of 10
  8002. let additionalInfo = "x" + (Math.floor(kills / 10) - 1);
  8003. return
  8004. }
  8005. }
  8006. // ACTION BAR:
  8007. function updateItems(data, wpn) {
  8008. if (data) {
  8009. if (wpn) {
  8010. player.weapons = data;
  8011. player.primaryIndex = player.weapons[0];
  8012. player.secondaryIndex = player.weapons[1];
  8013. if (!instaC.isTrue) {
  8014. selectWeapon(player.weapons[0]);
  8015. }
  8016. } else {
  8017. player.items = data;
  8018. }
  8019. }
  8020. for (let i = 0; i < items.list.length; i++) {
  8021. let tmpI = items.weapons.length + i;
  8022. getEl("actionBarItem" + tmpI).style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8023. }
  8024. for (let i = 0; i < items.weapons.length; i++) {
  8025. getEl("actionBarItem" + i).style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8026. }
  8027. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8028. if (kms) {
  8029. getEl("actionBarItem3").style.display = "none";
  8030. getEl("actionBarItem4").style.display = "inline-block";
  8031. }
  8032. }
  8033. // ADD PROJECTILE:
  8034. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8035. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8036. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8037. }
  8038. // REMOVE PROJECTILE:
  8039. function remProjectile(sid, range) {
  8040. for (let i = 0; i < projectiles.length; ++i) {
  8041. if (projectiles[i].sid == sid) {
  8042. projectiles[i].range = range;
  8043. let tmpObjects = objectManager.hitObj;
  8044. objectManager.hitObj = [];
  8045. game.tickBase(() => {
  8046. let val = projectiles[i].dmg;
  8047. tmpObjects.forEach((healthy) => {
  8048. if (healthy.projDmg) {
  8049. healthy.health -= val;
  8050. }
  8051. });
  8052. }, 1);
  8053. }
  8054. }
  8055. }
  8056. // SHOW ALLIANCE MENU:
  8057. function allianceNotification(sid, name) {
  8058. let findBotSID = findSID(bots, sid);
  8059. if (findBotSID) { }
  8060. }
  8061. function setPlayerTeam(team, isOwner) {
  8062. if (player) {
  8063. player.team = team;
  8064. player.isOwner = isOwner;
  8065. if (team == null)
  8066. alliancePlayers = [];
  8067. }
  8068. }
  8069. function setAlliancePlayers(data) {
  8070. alliancePlayers = data;
  8071. }
  8072. // STORE MENU:
  8073. function updateStoreItems(type, id, index) {
  8074. if (index) {
  8075. if (!type)
  8076. player.tails[id] = 1;
  8077. else {
  8078. player.latestTail = id;
  8079. }
  8080. } else {
  8081. if (!type)
  8082. player.skins[id] = 1,
  8083. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8084. else {
  8085. player.latestSkin = id;
  8086. }
  8087. }
  8088. }
  8089. // SEND MESSAGE:
  8090. function receiveChat(sid, message) {
  8091. let tmpPlayer = findPlayerBySID(sid);
  8092. if (tmpPlayer) {
  8093. function get() {
  8094. if(tmpPlayer != player && player.team != tmpPlayer.team) {
  8095. return "#c95563";
  8096. } else if (player.team && player.team == tmpPlayer.team) {
  8097. return "#fff";
  8098. } else {
  8099. return "#0949aa"; //2394e8
  8100. }
  8101. }
  8102. let me = false;
  8103. if(tmpPlayer == player) me = true
  8104. else me = false;
  8105. addChatLog(message, "#fff", tmpPlayer.name + "[" + tmpPlayer.sid + "]:", tmpPlayer == player || (tmpPlayer.team && tmpPlayer.team == player.team) ? "#279df1" : "#fff");
  8106. tmpPlayer.chatMessage = ((text) => {
  8107. let tmpString;
  8108. profanityList.forEach((list) => {
  8109. if (text.indexOf(list) > -1) {
  8110. tmpString = "";
  8111. for (var y = 0; y < list.length; ++y) {
  8112. tmpString += tmpString.length ? "o" : "M";
  8113. }
  8114. var re = new RegExp(list, 'g');
  8115. text = text.replace(re, tmpString);
  8116. }
  8117. });
  8118. return text;
  8119. })(message);
  8120. tmpPlayer.chatCountdown = config.chatCountdown;
  8121. }
  8122. }
  8123. // MINIMAP:
  8124. function updateMinimap(data) {
  8125. minimapData = data;
  8126. }
  8127. // SHOW ANIM TEXT:
  8128. function showText(x, y, value, type, color) {
  8129. textManager.showText(x, y, 50, 0.18, 500, Math.abs(value), color);
  8130. }
  8131. /** APPLY SOCKET CODES */
  8132. // BOT:
  8133. let bots = [];
  8134. let ranLocation = {
  8135. x: UTILS.randInt(35, 14365),
  8136. y: UTILS.randInt(35, 14365)
  8137. };
  8138. setInterval(() => {
  8139. ranLocation = {
  8140. x: UTILS.randInt(35, 14365),
  8141. y: UTILS.randInt(35, 14365)
  8142. };
  8143. }, 60000);
  8144. class Bot {
  8145. constructor(id, sid, hats, accessories) {
  8146. this.id = id;
  8147. this.sid = sid;
  8148. this.team = null;
  8149. this.skinIndex = 0;
  8150. this.tailIndex = 0;
  8151. this.hitTime = 0;
  8152. this.iconIndex = 0;
  8153. this.enemy = [];
  8154. // this.perfectReplace();
  8155. this.near = [];
  8156. this.dist2 = 0;
  8157. this.aim2 = 0;
  8158. this.tick = 0;
  8159. this.itemCounts = {};
  8160. this.latestSkin = 0;
  8161. this.latestTail = 0;
  8162. this.points = 0;
  8163. this.tails = {};
  8164. for (let i = 0; i < accessories.length; ++i) {
  8165. if (accessories[i].price <= 0)
  8166. this.tails[accessories[i].id] = 1;
  8167. }
  8168. this.skins = {};
  8169. for (let i = 0; i < hats.length; ++i) {
  8170. if (hats[i].price <= 0)
  8171. this.skins[hats[i].id] = 1;
  8172. }
  8173. this.spawn = function(moofoll) {
  8174. this.upgraded = 0;
  8175. this.enemy = [];
  8176. this.near = [];
  8177. this.active = true;
  8178. this.alive = true;
  8179. this.lockMove = false;
  8180. this.lockDir = false;
  8181. this.minimapCounter = 0;
  8182. this.chatCountdown = 0;
  8183. this.shameCount = 0;
  8184. this.shameTimer = 0;
  8185. this.sentTo = {};
  8186. this.gathering = 0;
  8187. this.autoGather = 0;
  8188. this.animTime = 0;
  8189. this.animSpeed = 0;
  8190. this.mouseState = 0;
  8191. this.buildIndex = -1;
  8192. this.weaponIndex = 0;
  8193. this.dmgOverTime = {};
  8194. this.noMovTimer = 0;
  8195. this.maxXP = 300;
  8196. this.XP = 0;
  8197. this.age = 1;
  8198. this.kills = 0;
  8199. this.upgrAge = 2;
  8200. this.upgradePoints = 0;
  8201. this.x = 0;
  8202. this.y = 0;
  8203. this.zIndex = 0;
  8204. this.xVel = 0;
  8205. this.yVel = 0;
  8206. this.slowMult = 1;
  8207. this.dir = 0;
  8208. this.nDir = 0;
  8209. this.dirPlus = 0;
  8210. this.targetDir = 0;
  8211. this.targetAngle = 0;
  8212. this.maxHealth = 100;
  8213. this.health = this.maxHealth;
  8214. this.oldHealth = this.maxHealth;
  8215. this.scale = config.playerScale;
  8216. this.speed = config.playerSpeed;
  8217. this.resetMoveDir();
  8218. this.resetResources(moofoll);
  8219. this.items = [0, 3, 6, 10];
  8220. this.weapons = [0];
  8221. this.shootCount = 0;
  8222. this.weaponXP = [];
  8223. this.reloads = {};
  8224. this.whyDie = "";
  8225. };
  8226. // RESET MOVE DIR:
  8227. this.resetMoveDir = function() {
  8228. this.moveDir = undefined;
  8229. };
  8230. // RESET RESOURCES:
  8231. this.resetResources = function(moofoll) {
  8232. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8233. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8234. }
  8235. };
  8236. // SET DATA:
  8237. this.setData = function(data) {
  8238. this.id = data[0];
  8239. this.sid = data[1];
  8240. this.name = data[2];
  8241. this.x = data[3];
  8242. this.y = data[4];
  8243. this.dir = data[5];
  8244. this.health = data[6];
  8245. this.maxHealth = data[7];
  8246. this.scale = data[8];
  8247. this.skinColor = data[9];
  8248. };
  8249. this.closeSockets = function(websc) {
  8250. websc.close();
  8251. };
  8252. this.whyDieChat = function(websc, whydie) {
  8253. websc.sendWS("6", "XDDD why die " + whydie);
  8254. };
  8255. }
  8256. };
  8257. class BotObject {
  8258. constructor(sid) {
  8259. this.sid = sid;
  8260. // INIT:
  8261. this.init = function(x, y, dir, scale, type, data, owner) {
  8262. data = data || {};
  8263. this.active = true;
  8264. this.x = x;
  8265. this.y = y;
  8266. this.scale = scale;
  8267. this.owner = owner;
  8268. this.id = data.id;
  8269. this.dmg = data.dmg;
  8270. this.trap = data.trap;
  8271. this.teleport = data.teleport;
  8272. this.isItem = this.id != undefined;
  8273. };
  8274. }
  8275. };
  8276. class BotObjManager {
  8277. constructor(botObj, fOS) {
  8278. // DISABLE OBJ:
  8279. this.disableObj = function(obj) {
  8280. obj.active = false;
  8281. obj.alive = false;
  8282. };
  8283. // ADD NEW:
  8284. let tmpObj;
  8285. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8286. tmpObj = fOS(sid);
  8287. if (!tmpObj) {
  8288. tmpObj = botObj.find((tmp) => !tmp.active);
  8289. if (!tmpObj) {
  8290. tmpObj = new BotObject(sid);
  8291. botObj.push(tmpObj);
  8292. }
  8293. }
  8294. if (setSID) {
  8295. tmpObj.sid = sid;
  8296. }
  8297. tmpObj.init(x, y, dir, s, type, data, owner);
  8298. };
  8299. // DISABLE BY SID:
  8300. this.disableBySid = function(sid) {
  8301. let find = fOS(sid);
  8302. if (find) {
  8303. this.disableObj(find);
  8304. }
  8305. };
  8306. // REMOVE ALL FROM PLAYER:
  8307. this.removeAllItems = function(sid, server) {
  8308. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8309. };
  8310. }
  8311. };
  8312. function botSpawn(id) {
  8313. let bot;
  8314. bot = id && new WebSocket(WS.url.split("&")[0] + "&token=" + encodeURIComponent(id));
  8315. let botPlayer = new Map();
  8316. let botSID;
  8317. let botObj = [];
  8318. let nearObj = [];
  8319. let bD = {
  8320. x: 0,
  8321. y: 0,
  8322. inGame: false,
  8323. closeSocket: false,
  8324. whyDie: ""
  8325. };
  8326. let oldXY = {
  8327. x: 0,
  8328. y: 0,
  8329. };
  8330. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8331. bot.binaryType = "arraybuffer";
  8332. bot.first = true;
  8333. bot.sendWS = function(type) {
  8334. // EXTRACT DATA ARRAY:
  8335. let data = Array.prototype.slice.call(arguments, 1);
  8336. // SEND MESSAGE:
  8337. let binary = window.msgpack.encode([type, data]);
  8338. bot.send(binary);
  8339. };
  8340. bot.spawn = function() {
  8341. bot.sendWS("M", {
  8342. name: "AAAAAAAAAAAAAAA",
  8343. moofoll: 1,
  8344. skin: "__proto__"
  8345. });
  8346. };
  8347. bot.sendUpgrade = function(index) {
  8348. bot.sendWS("H", index);
  8349. };
  8350. bot.place = function(id, a) {
  8351. try {
  8352. let item = items.list[botPlayer.items[id]];
  8353. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 99 : item.group.limit ? item.group.limit : 99)) {
  8354. bot.sendWS("G", botPlayer.items[id]);
  8355. bot.sendWS("d", 1, a);
  8356. bot.sendWS("G", botPlayer.weaponIndex, true);
  8357. }
  8358. } catch (e) {
  8359. }
  8360. };
  8361. bot.buye = function(id, index) {
  8362. let nID = 0;
  8363. if (botPlayer.alive && botPlayer.inGame) {
  8364. if (index == 0) {
  8365. if (botPlayer.skins[id]) {
  8366. if (botPlayer.latestSkin != id) {
  8367. bot.sendWS("c", 0, id, 0);
  8368. }
  8369. } else {
  8370. let find = findID(hats, id);
  8371. if (find) {
  8372. if (botPlayer.points >= find.price) {
  8373. bot.sendWS("c", 1, id, 0);
  8374. bot.sendWS("c", 0, id, 0);
  8375. } else {
  8376. if (botPlayer.latestSkin != nID) {
  8377. bot.sendWS("c", 0, nID, 0);
  8378. }
  8379. }
  8380. } else {
  8381. if (botPlayer.latestSkin != nID) {
  8382. bot.sendWS("c", 0, nID, 0);
  8383. }
  8384. }
  8385. }
  8386. } else if (index == 1) {
  8387. if (botPlayer.tails[id]) {
  8388. if (botPlayer.latestTail != id) {
  8389. bot.sendWS("c", 0, id, 1);
  8390. }
  8391. } else {
  8392. let find = findID(accessories, id);
  8393. if (find) {
  8394. if (botPlayer.points >= find.price) {
  8395. bot.sendWS("c", 1, id, 1);
  8396. bot.sendWS("c", 0, id, 1);
  8397. } else {
  8398. if (botPlayer.latestTail != 0) {
  8399. bot.sendWS("c", 0, 0, 1);
  8400. }
  8401. }
  8402. } else {
  8403. if (botPlayer.latestTail != 0) {
  8404. bot.sendWS("c", 0, 0, 1);
  8405. }
  8406. }
  8407. }
  8408. }
  8409. }
  8410. };
  8411. bot.fastGear = function() {
  8412. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8413. bot.buye(31, 0);
  8414. } else {
  8415. if (botPlayer.moveDir == undefined) {
  8416. bot.buye(22, 0);
  8417. } else {
  8418. if (botPlayer.y2 <= config.snowBiomeTop) {
  8419. bot.buye(15, 0);
  8420. } else {
  8421. bot.buye(12, 0);
  8422. }
  8423. }
  8424. }
  8425. };
  8426. let heal = function() {
  8427. let healthBased2 = function() {
  8428. if (botPlayer.health == 100)
  8429. return 0;
  8430. if (botPlayer.skinIndex != 45 && botPlayer.skinIndex != 56) {
  8431. return Math.ceil((100 - botPlayer.health) / items.list[botPlayer.items[0]].healing);
  8432. }
  8433. return 0;
  8434. };
  8435. for (let i = 0; i < healthBased2(); i++) {
  8436. bot.place(0, botPlayer.nDir);
  8437. }
  8438. };
  8439. bot.onmessage = function(message) {
  8440. let data = new Uint8Array(message.data);
  8441. let parsed = window.msgpack.decode(data);
  8442. let type = parsed[0];
  8443. data = parsed[1];
  8444. if (type == "1") {
  8445. bot.spawn();
  8446. }
  8447. if (type == "1") {
  8448. botSID = data[0];
  8449. }
  8450. if (type == "D") {
  8451. if (data[1]) {
  8452. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8453. botPlayer.setData(data[0]);
  8454. botPlayer.inGame = true;
  8455. botPlayer.alive = true;
  8456. botPlayer.x2 = undefined;
  8457. botPlayer.y2 = undefined;
  8458. botPlayer.spawn(1);
  8459. oldXY = {
  8460. x: data[0][3],
  8461. y: data[0][4]
  8462. }
  8463. bD.inGame = true;
  8464. bot.sendWS("K", 1);
  8465. if (bot.first) {
  8466. bot.first = false;
  8467. bots.push(bD);
  8468. }
  8469. }
  8470. }
  8471. if (type == "P") {
  8472. bot.spawn();
  8473. botPlayer.inGame = false;
  8474. bD.inGame = false;
  8475. }
  8476. if (type == "a") {
  8477. let tmpData = data[0];
  8478. botPlayer.tick++;
  8479. botPlayer.enemy = [];
  8480. //botPlayer.perfectReplace();
  8481. botPlayer.near = [];
  8482. nearObj = [];
  8483. for (let i = 0; i < tmpData.length;) {
  8484. if (tmpData[i] == botPlayer.sid) {
  8485. botPlayer.x2 = tmpData[i + 1];
  8486. botPlayer.y2 = tmpData[i + 2];
  8487. botPlayer.d2 = tmpData[i + 3];
  8488. botPlayer.buildIndex = tmpData[i + 4];
  8489. botPlayer.weaponIndex = tmpData[i + 5];
  8490. botPlayer.weaponVariant = tmpData[i + 6];
  8491. botPlayer.team = tmpData[i + 7];
  8492. botPlayer.isLeader = tmpData[i + 8];
  8493. botPlayer.skinIndex = tmpData[i + 9];
  8494. botPlayer.tailIndex = tmpData[i + 10];
  8495. botPlayer.iconIndex = tmpData[i + 11];
  8496. botPlayer.zIndex = tmpData[i + 12];
  8497. botPlayer.visible = true;
  8498. bD.x2 = botPlayer.x2;
  8499. bD.y2 = botPlayer.y2;
  8500. }
  8501. i += 13;
  8502. }
  8503. if (bD.closeSocket) {
  8504. botPlayer.closeSockets(bot);
  8505. }
  8506. if (bD.whyDie != "") {
  8507. botPlayer.whyDieChat(bot, bD.whyDie);
  8508. bD.whyDie = "";
  8509. }
  8510. if (botPlayer.alive) {
  8511. if (player.team) {
  8512. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8513. botPlayer.team && (bot.sendWS("N"));
  8514. bot.sendWS("b", player.team);
  8515. }
  8516. }
  8517. if (botPlayer.inGame) {
  8518. if (botObj.length > 0) {
  8519. if (breakObjects.length > 0) {
  8520. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8521. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8522. 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) {
  8523. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8524. })[0];
  8525. if (nearObj) {
  8526. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8527. if ((gotoDist - isPassed) > 0) {
  8528. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap || nearObj.teleport)) {
  8529. if (botPlayer.moveDir != undefined) {
  8530. botPlayer.moveDir = undefined;
  8531. bot.sendWS("a", botPlayer.moveDir);
  8532. }
  8533. } else {
  8534. botPlayer.moveDir = gotoAim;
  8535. bot.sendWS("a", botPlayer.moveDir);
  8536. }
  8537. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8538. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8539. bot.sendWS("D", botPlayer.nDir);
  8540. }
  8541. bot.buye(40, 0);
  8542. bot.buye(11, 1);
  8543. } else {
  8544. botPlayer.moveDir = gotoAim;
  8545. bot.sendWS("a", botPlayer.moveDir);
  8546. bot.fastGear();
  8547. bot.buye(11, 1);
  8548. }
  8549. } else {
  8550. botPlayer.moveDir = gotoAim;
  8551. bot.sendWS("a", botPlayer.moveDir);
  8552. bot.fastGear();
  8553. bot.buye(11, 1);
  8554. }
  8555. if (gotoDist > 300) {
  8556. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8557. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8558. bot.place(3, aim + (Math.PI / 2.3));
  8559. bot.place(3, aim - (Math.PI / 2.3));
  8560. bot.place(3, aim);
  8561. oldXY = {
  8562. x: botPlayer.x2,
  8563. y: botPlayer.y2
  8564. };
  8565. }
  8566. }
  8567. } else {
  8568. if (botPlayer.moveDir != undefined) {
  8569. botPlayer.moveDir = undefined;
  8570. bot.sendWS("a", botPlayer.moveDir);
  8571. }
  8572. 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) {
  8573. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8574. })[0];
  8575. if (nearObj) {
  8576. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8577. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8578. bot.sendWS("D", botPlayer.nDir);
  8579. }
  8580. bot.buye(40, 0);
  8581. bot.buye(11, 1);
  8582. } else {
  8583. bot.fastGear();
  8584. bot.buye(11, 1);
  8585. }
  8586. }
  8587. } else {
  8588. if (botPlayer.moveDir != undefined) {
  8589. botPlayer.moveDir = undefined;
  8590. bot.sendWS("a", botPlayer.moveDir);
  8591. }
  8592. }
  8593. }
  8594. }
  8595. }
  8596. if (type == "H") {
  8597. let tmpData = data[0];
  8598. for (let i = 0; i < tmpData.length;) {
  8599. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8600. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8601. sid: tmpData[i + 7]
  8602. } : null));
  8603. i += 8;
  8604. }
  8605. }
  8606. if (type == "N") {
  8607. let index = data[0];
  8608. let value = data[1];
  8609. if (botPlayer) {
  8610. botPlayer[index] = value;
  8611. }
  8612. }
  8613. if (type == "O") {
  8614. if (data[0] == botSID) {
  8615. botPlayer.oldHealth = botPlayer.health;
  8616. botPlayer.health = data[1];
  8617. botPlayer.judgeShame();
  8618. if (botPlayer.oldHealth > botPlayer.health) {
  8619. if (botPlayer.shameCount < 5) {
  8620. heal();
  8621. } else {
  8622. setTimeout(() => {
  8623. heal();
  8624. }, 70);
  8625. }
  8626. }
  8627. }
  8628. }
  8629. if (type == "Q") {
  8630. let sid = data[0];
  8631. botObjManager.disableBySid(sid);
  8632. }
  8633. if (type == "13") {
  8634. let sid = data[0];
  8635. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8636. }
  8637. if (type == "14") {
  8638. let index = data[0];
  8639. let value = data[1];
  8640. if (botPlayer) {
  8641. botPlayer.itemCounts[index] = value;
  8642. }
  8643. }
  8644. if (type == "16") {
  8645. if (data[0] > 0) {
  8646. if (botPlayer.upgraded == 0) {
  8647. bot.sendUpgrade(3);
  8648. } else if (botPlayer.upgraded == 1) {
  8649. bot.sendUpgrade(17);
  8650. } else if (botPlayer.upgraded == 2) {
  8651. bot.sendUpgrade(31);
  8652. } else if (botPlayer.upgraded == 3) {
  8653. bot.sendUpgrade(27);
  8654. } else if (botPlayer.upgraded == 4) {
  8655. bot.sendUpgrade(9);
  8656. } else if (botPlayer.upgraded == 5) {
  8657. bot.sendUpgrade(38);
  8658. } else if (botPlayer.upgraded == 6) {
  8659. bot.sendUpgrade(4);
  8660. } else if (botPlayer.upgraded == 7) {
  8661. bot.sendUpgrade(25);
  8662. }
  8663. botPlayer.upgraded++;
  8664. }
  8665. }
  8666. if (type == "17") {
  8667. let tmpData = data[0];
  8668. let wpn = data[1];
  8669. if (tmpData) {
  8670. if (wpn) botPlayer.weapons = tmpData;
  8671. else botPlayer.items = tmpData;
  8672. }
  8673. bot.sendWS("G", botPlayer.weapons[0], true);
  8674. }
  8675. if (type == "us") {
  8676. let type = data[0];
  8677. let id = data[1];
  8678. let index = data[2];
  8679. if (index) {
  8680. if (!type)
  8681. botPlayer.tails[id] = 1;
  8682. else
  8683. botPlayer.latestTail = id;
  8684. } else {
  8685. if (!type)
  8686. botPlayer.skins[id] = 1;
  8687. else
  8688. botPlayer.latestSkin = id;
  8689. }
  8690. }
  8691. };
  8692. bot.onclose = function() {
  8693. botPlayer.inGame = false;
  8694. bD.inGame = false;
  8695. };
  8696. }
  8697. // RENDER LEAF:
  8698. function renderLeaf(x, y, l, r, ctxt) {
  8699. let endX = x + (l * Math.cos(r));
  8700. let endY = y + (l * Math.sin(r));
  8701. let width = l * 0.4;
  8702. ctxt.moveTo(x, y);
  8703. ctxt.beginPath();
  8704. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8705. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8706. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8707. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8708. ctxt.closePath();
  8709. ctxt.fill();
  8710. ctxt.stroke();
  8711. }
  8712. // RENDER CIRCLE:
  8713. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8714. tmpContext = tmpContext || mainContext;
  8715. tmpContext.beginPath();
  8716. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8717. if (!dontFill) tmpContext.fill();
  8718. if (!dontStroke) tmpContext.stroke();
  8719. }
  8720. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8721. tmpContext = tmpContext || mainContext;
  8722. tmpContext.beginPath();
  8723. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8724. if (!dontFill) tmpContext.fill();
  8725. if (!dontStroke) tmpContext.stroke();
  8726. }
  8727. // RENDER STAR SHAPE:
  8728. function renderStar(ctxt, spikes, outer, inner) {
  8729. let rot = Math.PI / 2 * 3;
  8730. let x, y;
  8731. let step = Math.PI / spikes;
  8732. ctxt.beginPath();
  8733. ctxt.moveTo(0, -outer);
  8734. for (let i = 0; i < spikes; i++) {
  8735. x = Math.cos(rot) * outer;
  8736. y = Math.sin(rot) * outer;
  8737. ctxt.lineTo(x, y);
  8738. rot += step;
  8739. x = Math.cos(rot) * inner;
  8740. y = Math.sin(rot) * inner;
  8741. ctxt.lineTo(x, y);
  8742. rot += step;
  8743. }
  8744. ctxt.lineTo(0, -outer);
  8745. ctxt.closePath();
  8746. }
  8747. function renderHealthStar(ctxt, spikes, outer, inner) {
  8748. let rot = Math.PI / 2 * 3;
  8749. let x, y;
  8750. let step = Math.PI / spikes;
  8751. ctxt.beginPath();
  8752. ctxt.moveTo(0, -outer);
  8753. for (let i = 0; i < spikes; i++) {
  8754. x = Math.cos(rot) * outer;
  8755. y = Math.sin(rot) * outer;
  8756. ctxt.lineTo(x, y);
  8757. rot += step;
  8758. x = Math.cos(rot) * inner;
  8759. y = Math.sin(rot) * inner;
  8760. ctxt.lineTo(x, y);
  8761. rot += step;
  8762. }
  8763. ctxt.lineTo(0, -outer);
  8764. ctxt.closePath();
  8765. }
  8766. // RENDER RECTANGLE:
  8767. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8768. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8769. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8770. }
  8771. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8772. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8773. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8774. }
  8775. // RENDER RECTCIRCLE:
  8776. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8777. ctxt.save();
  8778. ctxt.translate(x, y);
  8779. seg = Math.ceil(seg / 2);
  8780. for (let i = 0; i < seg; i++) {
  8781. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8782. ctxt.rotate(Math.PI / seg);
  8783. }
  8784. ctxt.restore();
  8785. }
  8786. // RENDER BLOB:
  8787. function renderBlob(ctxt, spikes, outer, inner) {
  8788. let rot = Math.PI / 2 * 3;
  8789. let x, y;
  8790. let step = Math.PI / spikes;
  8791. let tmpOuter;
  8792. ctxt.beginPath();
  8793. ctxt.moveTo(0, -inner);
  8794. for (let i = 0; i < spikes; i++) {
  8795. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8796. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8797. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8798. rot += step * 2;
  8799. }
  8800. ctxt.lineTo(0, -inner);
  8801. ctxt.closePath();
  8802. }
  8803. // RENDER TRIANGLE:
  8804. function renderTriangle(s, ctx) {
  8805. ctx = ctx || mainContext;
  8806. let h = s * (Math.sqrt(3) / 2);
  8807. ctx.beginPath();
  8808. ctx.moveTo(0, -h / 2);
  8809. ctx.lineTo(-s / 2, h / 2);
  8810. ctx.lineTo(s / 2, h / 2);
  8811. ctx.lineTo(0, -h / 2);
  8812. ctx.fill();
  8813. ctx.closePath();
  8814. }
  8815. // PREPARE MENU BACKGROUND:
  8816. function prepareMenuBackground() {
  8817. let tmpMid = config.mapScale / 2;
  8818. let attempts = 0;
  8819. for (let i = 0; i < items.list.length * 10;) {
  8820. if (attempts >= 1000) break;
  8821. attempts++;
  8822. let type1 = items.list[15];
  8823. let type2 = items.list[9];
  8824. let data1 = {
  8825. x: tmpMid + UTILS.randFloat(-1000, 1000),
  8826. y: tmpMid + UTILS.randFloat(-600, 600),
  8827. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8828. };
  8829. if (objectManager.checkItemLocation(data1.x, data1.y, type1.scale, 0.6, type1.id, true)) {
  8830. objectManager.add(i, data1.x, data1.y, data1.dir, type1.scale, type1.id, type1);
  8831. let offsetX = UTILS.randFloat(-100, 100);
  8832. let offsetY = UTILS.randFloat(-100, 100);
  8833. let data2 = {
  8834. x: data1.x + offsetX,
  8835. y: data1.y + offsetY,
  8836. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8837. };
  8838. if (objectManager.checkItemLocation(data2.x, data2.y, type2.scale, 0.6, type2.id, true)) {
  8839. objectManager.add(i + 1, data2.x, data2.y, data2.dir, type2.scale, type2.id, type2);
  8840. } else {
  8841. continue;
  8842. }
  8843. } else {
  8844. continue;
  8845. }
  8846. i += 2;
  8847. }
  8848. }
  8849. const speed = 35;
  8850. // RENDER PLAYERS:
  8851. function renderDeadPlayers(xOffset, yOffset, deadAngle) {
  8852. mainContext.fillStyle = "#91b2db";
  8853. const currentTime = Date.now();
  8854. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8855. if (!dead.startTime) {
  8856. dead.startTime = currentTime;
  8857. dead.angle = 0;
  8858. dead.radius = 0.1;
  8859. }
  8860. const timeElapsed = currentTime - dead.startTime;
  8861. const maxAlpha = 1;
  8862. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8863. dead.animate(delta);
  8864. mainContext.globalAlpha = dead.alpha;
  8865. mainContext.strokeStyle = outlineColor;
  8866. mainContext.save();
  8867. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8868. dead.radius -= 0.001;
  8869. dead.angle += toRadian(1);
  8870. const moveSpeed = 40;
  8871. const x = dead.radius * Math.cos(deadAngle);
  8872. const y = dead.radius * Math.sin(deadAngle);
  8873. dead.x += x * moveSpeed;
  8874. dead.y += y * moveSpeed;
  8875. mainContext.rotate(dead.angle);
  8876. renderDeadPlayer(dead, mainContext);
  8877. mainContext.restore();
  8878. mainContext.fillStyle = "#bf8f54";
  8879. if (timeElapsed >= 3000) {
  8880. dead.active = false;
  8881. dead.startTime = null;
  8882. }
  8883. });
  8884. }
  8885. // RENDER PLAYERS:
  8886. let invisBody = false;
  8887. // RENDER PLAYERS:
  8888. function renderPlayers(xOffset, yOffset, zIndex) {
  8889. mainContext.globalAlpha = 1;
  8890. mainContext.fillStyle = "#91b2db";
  8891. for (var i = 0; i < players.length; ++i) {
  8892. tmpObj = players[i];
  8893. if (tmpObj.zIndex == zIndex) {
  8894. tmpObj.animate(delta);
  8895. if (tmpObj.visible) {
  8896. tmpObj.skinRot += (0.002 * delta);
  8897. tmpDir = (!configs.showDir && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir || 0);
  8898. mainContext.save();
  8899. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8900. // RENDER PLAYER:
  8901. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8902. if (tmpObj == player && invisBody) {
  8903. null;
  8904. } else {
  8905. renderPlayer(tmpObj, mainContext);
  8906. }
  8907. mainContext.restore();
  8908. }
  8909. }
  8910. }
  8911. }
  8912. // RENDER DEAD PLAYER:
  8913. function renderDeadPlayer(obj, ctxt) {
  8914. ctxt = ctxt || mainContext;
  8915. ctxt.lineWidth = outlineWidth;
  8916. ctxt.lineJoin = "miter";
  8917. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8918. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8919. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8920.  
  8921. // TAIL/CAPE:
  8922. renderTail2(13, ctxt, obj);
  8923.  
  8924. // WEAPON BELLOW HANDS:
  8925. if (obj.buildIndex < 0 && !items.weapons[10].aboveHand) {
  8926. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  8927. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8928. renderProjectile(obj.scale, 0,
  8929. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8930. }
  8931. }
  8932.  
  8933. // HANDS:
  8934. ctxt.fillStyle = "#ececec";
  8935. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8936. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8937. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8938.  
  8939. // WEAPON ABOVE HANDS:
  8940. if (obj.buildIndex < 0 && items.weapons[10].aboveHand) {
  8941. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  8942. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8943. renderProjectile(obj.scale, 0,
  8944. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8945. }
  8946. }
  8947.  
  8948. // BUILD ITEM:
  8949. if (obj.buildIndex >= 0) {
  8950. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8951. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8952. }
  8953.  
  8954. // BODY:
  8955. renderCircle(0, 0, obj.scale, ctxt);
  8956. // SKIN
  8957. renderSkin2(48, ctxt, null, obj)
  8958.  
  8959. }
  8960. // RENDER PLAYER:
  8961. function renderPlayer(obj, ctxt) {
  8962. ctxt = ctxt || mainContext;
  8963. ctxt.lineWidth = outlineWidth;
  8964. ctxt.lineJoin = "miter";
  8965. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8966. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8967. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8968. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8969. // TAIL/CAPE:
  8970. if (obj.tailIndex > 0) {
  8971. renderTail(obj.tailIndex, ctxt, obj);
  8972. }
  8973. // WEAPON BELLOW HANDS:
  8974. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8975. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8976. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8977. renderProjectile(obj.scale, 0,
  8978. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8979. }
  8980. }
  8981. // HANDS:
  8982. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8983. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8984. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8985. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8986. // WEAPON ABOVE HANDS:
  8987. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8988. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8989. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8990. renderProjectile(obj.scale, 0,
  8991. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8992. }
  8993. }
  8994. // BUILD ITEM:
  8995. if (obj.buildIndex >= 0) {
  8996. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8997. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8998. }
  8999. // BODY:
  9000. renderCircle(0, 0, obj.scale, ctxt);
  9001. // SKIN:
  9002. if (obj.skinIndex > 0) {
  9003. ctxt.rotate(Math.PI / 2);
  9004. renderSkin(obj.skinIndex, ctxt, null, obj);
  9005. }
  9006. }
  9007. // RENDER NORMAL SKIN
  9008. var skinSprites2 = {};
  9009. var skinPointers2 = {};
  9010. function renderSkin2(index, ctxt, parentSkin, owner) {
  9011. tmpSkin = skinSprites2[index];
  9012. if (!tmpSkin) {
  9013. var tmpImage = new Image();
  9014. tmpImage.onload = function() {
  9015. this.isLoaded = true;
  9016. this.onload = null;
  9017. };
  9018. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9019. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9020. skinSprites2[index] = tmpImage;
  9021. tmpSkin = tmpImage;
  9022. }
  9023. var tmpObj = parentSkin||skinPointers2[index];
  9024. if (!tmpObj) {
  9025. for (var i = 0; i < hats.length; ++i) {
  9026. if (hats[i].id == index) {
  9027. tmpObj = hats[i];
  9028. break;
  9029. }
  9030. }
  9031. skinPointers2[index] = tmpObj;
  9032. }
  9033. if (tmpSkin.isLoaded)
  9034. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9035. if (!parentSkin && tmpObj.topSprite) {
  9036. ctxt.save();
  9037. ctxt.rotate(owner.skinRot);
  9038. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9039. ctxt.restore();
  9040. }
  9041. }
  9042. // RENDER SKINS:
  9043. let skinSprites = {};
  9044. let skinPointers = {};
  9045. let tmpSkin;
  9046. function renderSkin(index, ctxt, parentSkin, owner) {
  9047. tmpSkin = skinSprites[index];
  9048. if (!tmpSkin) {
  9049. let tmpImage = new Image();
  9050. tmpImage.onload = function() {
  9051. this.isLoaded = true;
  9052. this.onload = null;
  9053. };
  9054. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9055. skinSprites[index] = tmpImage;
  9056. tmpSkin = tmpImage;
  9057. }
  9058. let tmpObj = parentSkin || skinPointers[index];
  9059. if (!tmpObj) {
  9060. for (let i = 0; i < hats.length; ++i) {
  9061. if (hats[i].id == index) {
  9062. tmpObj = hats[i];
  9063. break;
  9064. }
  9065. }
  9066. skinPointers[index] = tmpObj;
  9067. }
  9068. if (tmpSkin.isLoaded)
  9069. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9070. if (!parentSkin && tmpObj.topSprite) {
  9071. ctxt.save();
  9072. ctxt.rotate(owner.skinRot);
  9073. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9074. ctxt.restore();
  9075. }
  9076. }
  9077. // RENDER TAIL:
  9078. let accessSprites = {};
  9079. let accessPointers = {};
  9080. function renderTail(index, ctxt, owner) {
  9081. tmpSkin = accessSprites[index];
  9082. if (!tmpSkin) {
  9083. let tmpImage = new Image();
  9084. tmpImage.onload = function() {
  9085. this.isLoaded = true;
  9086. this.onload = null;
  9087. };
  9088. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9089. accessSprites[index] = tmpImage;
  9090. tmpSkin = tmpImage;
  9091. }
  9092. let tmpObj = accessPointers[index];
  9093. if (!tmpObj) {
  9094. for (let i = 0; i < accessories.length; ++i) {
  9095. if (accessories[i].id == index) {
  9096. tmpObj = accessories[i];
  9097. break;
  9098. }
  9099. }
  9100. accessPointers[index] = tmpObj;
  9101. }
  9102. if (tmpSkin.isLoaded) {
  9103. ctxt.save();
  9104. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9105. if (tmpObj.spin)
  9106. ctxt.rotate(owner.skinRot);
  9107. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9108. ctxt.restore();
  9109. }
  9110. }
  9111. // RENDER NORMAL TAIL
  9112. var accessSprites2 = {};
  9113. var accessPointers2 = {};
  9114. function renderTail2(index, ctxt, owner) {
  9115. tmpSkin = accessSprites2[index];
  9116. if (!tmpSkin) {
  9117. var tmpImage = new Image();
  9118. tmpImage.onload = function() {
  9119. this.isLoaded = true;
  9120. this.onload = null;
  9121. };
  9122. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9123. accessSprites2[index] = tmpImage;
  9124. tmpSkin = tmpImage;
  9125. }
  9126. var tmpObj = accessPointers2[index];
  9127. if (!tmpObj) {
  9128. for (var i = 0; i < accessories.length; ++i) {
  9129. if (accessories[i].id == index) {
  9130. tmpObj = accessories[i];
  9131. break;
  9132. }
  9133. }
  9134. accessPointers2[index] = tmpObj;
  9135. }
  9136. if (tmpSkin.isLoaded) {
  9137. ctxt.save();
  9138. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9139. if (tmpObj.spin)
  9140. ctxt.rotate(owner.skinRot);
  9141. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9142. ctxt.restore();
  9143. }
  9144. }
  9145. // RENDER TOOL:
  9146. let toolSprites = {};
  9147. function renderTool(obj, variant, x, y, ctxt) {
  9148. let tmpSrc = obj.src + (variant || "");
  9149. let tmpSprite = toolSprites[tmpSrc];
  9150. if (!tmpSprite) {
  9151. tmpSprite = new Image();
  9152. tmpSprite.onload = function() {
  9153. this.isLoaded = true;
  9154. }
  9155. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9156. toolSprites[tmpSrc] = tmpSprite;
  9157. }
  9158. if (tmpSprite.isLoaded)
  9159. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9160. }
  9161. // RENDER PROJECTILES:
  9162. function renderProjectiles(layer, xOffset, yOffset) {
  9163. for (let i = 0; i < projectiles.length; i++) {
  9164. tmpObj = projectiles[i];
  9165. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9166. tmpObj.update(delta);
  9167. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9168. mainContext.save();
  9169. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9170. mainContext.rotate(tmpObj.dir);
  9171. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9172. mainContext.restore();
  9173. }
  9174. }
  9175. };
  9176. }
  9177. // RENDER PROJECTILE:
  9178. let projectileSprites = {};
  9179. function renderProjectile(x, y, obj, ctxt, debug) {
  9180. if (obj.src) {
  9181. let tmpSrc = items.projectiles[obj.indx].src;
  9182. let tmpSprite = projectileSprites[tmpSrc];
  9183. if (!tmpSprite) {
  9184. tmpSprite = new Image();
  9185. tmpSprite.onload = function() {
  9186. this.isLoaded = true;
  9187. }
  9188. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9189. projectileSprites[tmpSrc] = tmpSprite;
  9190. }
  9191. if (tmpSprite.isLoaded)
  9192. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9193. } else if (obj.indx == 1) {
  9194. ctxt.fillStyle = "#939393";
  9195. renderCircle(x, y, obj.scale, ctxt);
  9196. }
  9197. }
  9198. // RENDER AI:
  9199. let aiSprites = {};
  9200. function renderAI(obj, ctxt) {
  9201. let tmpIndx = obj.index;
  9202. let tmpSprite = aiSprites[tmpIndx];
  9203. if (!tmpSprite) {
  9204. let tmpImg = new Image();
  9205. tmpImg.onload = function() {
  9206. this.isLoaded = true;
  9207. this.onload = null;
  9208. };
  9209. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9210. tmpSprite = tmpImg;
  9211. aiSprites[tmpIndx] = tmpSprite;
  9212. }
  9213. if (tmpSprite.isLoaded) {
  9214. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9215. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9216. }
  9217. }
  9218. // RENDER WATER BODIES:
  9219. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9220. // MIDDLE RIVER:
  9221. let tmpW = config.riverWidth + padding;
  9222. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9223. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9224. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9225. }
  9226. }
  9227. // RENDER GAME OBJECTS:
  9228. let gameObjectSprites = {};
  9229. function getResSprite(obj) {
  9230. let biomeID = (obj.y>=config.mapScale-config.snowBiomeTop)?2:((obj.y<=config.snowBiomeTop)?1:0);
  9231. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9232. let tmpSprite = gameObjectSprites[tmpIndex];
  9233. if (!tmpSprite) {
  9234. let blurScale = 15;
  9235. let tmpCanvas = document.createElement("canvas");
  9236. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9237. let tmpContext = tmpCanvas.getContext('2d');
  9238. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9239. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9240. tmpContext.strokeStyle = outlineColor;
  9241. tmpContext.lineWidth = outlineWidth;
  9242. if (isNight) {
  9243. tmpContext.shadowBlur = blurScale;
  9244. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9245. }
  9246. if (obj.type == 0) {
  9247. let tmpScale;
  9248. let tmpCount = UTILS.randInt(5, 7);
  9249. tmpContext.globalAlpha = isNight ? 0.6 : 0.8;
  9250. for (let i = 0; i < 2; ++i) {
  9251. tmpScale = tmpObj.scale * (!i?1:0.5);
  9252. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9253. tmpContext.fillStyle = !biomeID?(!i?"#9ebf57":"#b4db62"):(!i?"#e3f1f4":"#fff");
  9254. tmpContext.fill();
  9255. if (!i) {
  9256. tmpContext.stroke();
  9257. tmpContext.shadowBlur = null;
  9258. tmpContext.shadowColor = null;
  9259. tmpContext.globalAlpha = 1;
  9260. }
  9261. }
  9262. } else if (obj.type == 1) {
  9263. if (biomeID == 2) {
  9264. tmpContext.fillStyle = "#606060";
  9265. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9266. tmpContext.fill();
  9267. tmpContext.stroke();
  9268.  
  9269. //tmpContext.shadowBlur = null;
  9270. //tmpContext.shadowColor = null;
  9271.  
  9272. tmpContext.fillStyle = "#89a54c";
  9273. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9274. tmpContext.fillStyle = "#a5c65b";
  9275. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9276. } else {
  9277. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9278. tmpContext.fillStyle = biomeID?"#e3f1f4":"#89a54c";
  9279. tmpContext.fill();
  9280. tmpContext.stroke();
  9281.  
  9282. //tmpContext.shadowBlur = null;
  9283. //tmpContext.shadowColor = null;
  9284.  
  9285. tmpContext.fillStyle = biomeID?"#6a64af":"#c15555";
  9286. let tmpRange;
  9287. let berries = 4;
  9288. let rotVal = (Math.PI * 2) / berries;
  9289. for (let i = 0; i < berries; ++i) {
  9290. tmpRange = UTILS.randInt(tmpObj.scale/3.5, tmpObj.scale/2.3);
  9291. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9292. UTILS.randInt(10, 12), tmpContext);
  9293. }
  9294. }
  9295. } else if (obj.type == 2 || obj.type == 3) {
  9296. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#938d77":"#939393"):"#e0c655";
  9297. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9298. tmpContext.fill();
  9299. tmpContext.stroke();
  9300.  
  9301. tmpContext.shadowBlur = null;
  9302. tmpContext.shadowColor = null;
  9303.  
  9304. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#b2ab90":"#bcbcbc"):"#ebdca3";
  9305. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9306. tmpContext.fill();
  9307. }
  9308. tmpSprite = tmpCanvas;
  9309. gameObjectSprites[tmpIndex] = tmpSprite;
  9310. }
  9311. return tmpSprite;
  9312. }
  9313.  
  9314. // GET ITEM SPRITE:
  9315. let itemSprites = [];
  9316. function getItemSprite(obj, asIcon) {
  9317. let tmpSprite = itemSprites[obj.id];
  9318. if (!tmpSprite || asIcon) {
  9319. let blurScale = !asIcon && isNight ? 15 : 0;
  9320. let tmpCanvas = document.createElement("canvas");
  9321. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9322. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9323. let tmpContext = tmpCanvas.getContext("2d");
  9324. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9325. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9326. tmpContext.strokeStyle = outlineColor;
  9327. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9328. if (isNight && !asIcon) {
  9329. tmpContext.shadowBlur = blurScale;
  9330. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(obj.name == "pit trap" ? 0.6 : 0.3, obj.alpha)})`;
  9331. }
  9332. if (obj.name == "apple") {
  9333. tmpContext.fillStyle = "#c15555";
  9334. renderCircle(0, 0, obj.scale, tmpContext);
  9335. tmpContext.fillStyle = "#89a54c";
  9336. let leafDir = -(Math.PI / 2);
  9337. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9338. 25, leafDir + Math.PI / 2, tmpContext);
  9339. } else if (obj.name == "cookie") {
  9340. tmpContext.fillStyle = "#cca861";
  9341. renderCircle(0, 0, obj.scale, tmpContext);
  9342. tmpContext.fillStyle = "#937c4b";
  9343. let chips = 4;
  9344. let rotVal = (Math.PI * 2) / chips;
  9345. let tmpRange;
  9346. for (let i = 0; i < chips; ++i) {
  9347. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9348. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9349. UTILS.randInt(4, 5), tmpContext, true);
  9350. }
  9351. } else if (obj.name == "cheese") {
  9352. tmpContext.fillStyle = "#f4f3ac";
  9353. renderCircle(0, 0, obj.scale, tmpContext);
  9354. tmpContext.fillStyle = "#c3c28b";
  9355. let chips = 4;
  9356. let rotVal = (Math.PI * 2) / chips;
  9357. let tmpRange;
  9358. for (let i = 0; i < chips; ++i) {
  9359. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9360. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9361. UTILS.randInt(4, 5), tmpContext, true);
  9362. }
  9363. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9364. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9365. "#a5974c" : "#939393";
  9366. let sides = (obj.name == "castle wall") ? 4 : 3;
  9367. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9368. tmpContext.fill();
  9369. tmpContext.stroke();
  9370. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9371. "#c9b758" : "#bcbcbc";
  9372. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9373. tmpContext.fill();
  9374. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9375. obj.name == "spinning spikes") {
  9376. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9377. let tmpScale = (obj.scale * 0.6);
  9378. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9379. tmpContext.fill();
  9380. tmpContext.stroke();
  9381. tmpContext.fillStyle = "#a5974c";
  9382. renderCircle(0, 0, tmpScale, tmpContext);
  9383. tmpContext.fillStyle = "#c9b758";
  9384. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9385. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9386. tmpContext.fillStyle = "#a5974c";
  9387. renderCircle(0, 0, reScale, tmpContext);
  9388. tmpContext.fillStyle = "#c9b758";
  9389. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9390. tmpContext.fillStyle = "#a5974c";
  9391. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9392. } else if (obj.name == "mine") {
  9393. tmpContext.fillStyle = "#939393";
  9394. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9395. tmpContext.fill();
  9396. tmpContext.stroke();
  9397. tmpContext.fillStyle = "#bcbcbc";
  9398. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9399. tmpContext.fill();
  9400. } else if (obj.name == "sapling") {
  9401. for (let i = 0; i < 2; ++i) {
  9402. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9403. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9404. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9405. tmpContext.fill();
  9406. if (!i) tmpContext.stroke();
  9407. }
  9408. } else if (obj.name == "pit trap") {
  9409. tmpContext.fillStyle = "#a5974c";
  9410. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9411. tmpContext.fill();
  9412. tmpContext.stroke();
  9413. tmpContext.fillStyle = outlineColor;
  9414. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9415. tmpContext.fill();
  9416. } else if (obj.name == "boost pad") {
  9417. tmpContext.fillStyle = "#7e7f82";
  9418. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9419. tmpContext.fill();
  9420. tmpContext.stroke();
  9421. tmpContext.fillStyle = "#dbd97d";
  9422. renderTriangle(obj.scale * 1, tmpContext);
  9423. } else if (obj.name == "turret") {
  9424. tmpContext.fillStyle = "#a5974c";
  9425. renderCircle(0, 0, obj.scale, tmpContext);
  9426. tmpContext.fill();
  9427. tmpContext.stroke();
  9428. tmpContext.fillStyle = "#939393";
  9429. let tmpLen = 50;
  9430. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9431. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9432. tmpContext.fill();
  9433. tmpContext.stroke();
  9434. } else if (obj.name == "platform") {
  9435. tmpContext.fillStyle = "#cebd5f";
  9436. let tmpCount = 4;
  9437. let tmpS = obj.scale * 2;
  9438. let tmpW = tmpS / tmpCount;
  9439. let tmpX = -(obj.scale / 2);
  9440. for (let i = 0; i < tmpCount; ++i) {
  9441. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9442. tmpContext.fill();
  9443. tmpContext.stroke();
  9444. tmpX += tmpS / tmpCount;
  9445. }
  9446. } else if (obj.name == "healing pad") {
  9447. tmpContext.fillStyle = "#7e7f82";
  9448. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9449. tmpContext.fill();
  9450. tmpContext.stroke();
  9451. tmpContext.fillStyle = "#db6e6e";
  9452. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9453. } else if (obj.name == "spawn pad") {
  9454. tmpContext.fillStyle = "#7e7f82";
  9455. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9456. tmpContext.fill();
  9457. tmpContext.stroke();
  9458. tmpContext.fillStyle = "#71aad6";
  9459. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9460. } else if (obj.name == "blocker") {
  9461. tmpContext.fillStyle = "#7e7f82";
  9462. renderCircle(0, 0, obj.scale, tmpContext);
  9463. tmpContext.fill();
  9464. tmpContext.stroke();
  9465. tmpContext.rotate(Math.PI / 4);
  9466. tmpContext.fillStyle = "#db6e6e";
  9467. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9468. } else if (obj.name == "teleporter") {
  9469. tmpContext.fillStyle = "#7e7f82";
  9470. renderCircle(0, 0, obj.scale, tmpContext);
  9471. tmpContext.fill();
  9472. tmpContext.stroke();
  9473. tmpContext.rotate(Math.PI / 4);
  9474. tmpContext.fillStyle = "#d76edb";
  9475. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9476. }
  9477. tmpSprite = tmpCanvas;
  9478. if (!asIcon)
  9479. itemSprites[obj.id] = tmpSprite;
  9480. }
  9481. return tmpSprite;
  9482. }
  9483.  
  9484. function getItemSprite2(obj, tmpX, tmpY) {
  9485. let tmpContext = mainContext;
  9486. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9487. tmpContext.save();
  9488. tmpContext.translate(tmpX, tmpY);
  9489. tmpContext.rotate(obj.dir);
  9490. tmpContext.strokeStyle = outlineColor;
  9491. tmpContext.lineWidth = outlineWidth;
  9492. if (obj.name == "apple") {
  9493. tmpContext.fillStyle = "#c15555";
  9494. renderCircle(0, 0, obj.scale, tmpContext);
  9495. tmpContext.fillStyle = "#89a54c";
  9496. let leafDir = -(Math.PI / 2);
  9497. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9498. 25, leafDir + Math.PI / 2, tmpContext);
  9499. } else if (obj.name == "cookie") {
  9500. tmpContext.fillStyle = "#cca861";
  9501. renderCircle(0, 0, obj.scale, tmpContext);
  9502. tmpContext.fillStyle = "#937c4b";
  9503. let chips = 4;
  9504. let rotVal = (Math.PI * 2) / chips;
  9505. let tmpRange;
  9506. for (let i = 0; i < chips; ++i) {
  9507. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9508. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9509. UTILS.randInt(4, 5), tmpContext, true);
  9510. }
  9511. } else if (obj.name == "cheese") {
  9512. tmpContext.fillStyle = "#f4f3ac";
  9513. renderCircle(0, 0, obj.scale, tmpContext);
  9514. tmpContext.fillStyle = "#c3c28b";
  9515. let chips = 4;
  9516. let rotVal = (Math.PI * 2) / chips;
  9517. let tmpRange;
  9518. for (let i = 0; i < chips; ++i) {
  9519. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9520. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9521. UTILS.randInt(4, 5), tmpContext, true);
  9522. }
  9523. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9524. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9525. "#a5974c" : "#939393";
  9526. let sides = (obj.name == "castle wall") ? 4 : 3;
  9527. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9528. tmpContext.fill();
  9529. tmpContext.stroke();
  9530. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9531. "#c9b758" : "#bcbcbc";
  9532. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9533. tmpContext.fill();
  9534. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9535. obj.name == "spinning spikes") {
  9536. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9537. let tmpScale = (obj.scale * 0.6);
  9538. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9539. tmpContext.fill();
  9540. tmpContext.stroke();
  9541. tmpContext.fillStyle = "#a5974c";
  9542. renderCircle(0, 0, tmpScale, tmpContext);
  9543. tmpContext.fillStyle = "#c9b758";
  9544. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9545. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9546. tmpContext.fillStyle = "#a5974c";
  9547. renderCircle(0, 0, reScale, tmpContext);
  9548. tmpContext.fillStyle = "#c9b758";
  9549. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9550. tmpContext.fillStyle = "#a5974c";
  9551. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9552. } else if (obj.name == "mine") {
  9553. tmpContext.fillStyle = "#939393";
  9554. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9555. tmpContext.fill();
  9556. tmpContext.stroke();
  9557. tmpContext.fillStyle = "#bcbcbc";
  9558. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9559. tmpContext.fill();
  9560. } else if (obj.name == "sapling") {
  9561. for (let i = 0; i < 2; ++i) {
  9562. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9563. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9564. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  9565. tmpContext.fill();
  9566. if (!i) tmpContext.stroke();
  9567. }
  9568. } else if (obj.name == "pit trap") {
  9569. tmpContext.fillStyle = "#a5974c";
  9570. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9571. tmpContext.fill();
  9572. tmpContext.stroke();
  9573. tmpContext.fillStyle = outlineColor;
  9574. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9575. tmpContext.fill();
  9576. } else if (obj.name == "boost pad") {
  9577. tmpContext.fillStyle = "#7e7f82";
  9578. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9579. tmpContext.fill();
  9580. tmpContext.stroke();
  9581. tmpContext.fillStyle = "#dbd97d";
  9582. renderTriangle(obj.scale * 1, tmpContext);
  9583. } else if (obj.name == "turret") {
  9584. tmpContext.fillStyle = "#a5974c";
  9585. renderCircle(0, 0, obj.scale, tmpContext);
  9586. tmpContext.fill();
  9587. tmpContext.stroke();
  9588. tmpContext.fillStyle = "#939393";
  9589. let tmpLen = 50;
  9590. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9591. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9592. tmpContext.fill();
  9593. tmpContext.stroke();
  9594. } else if (obj.name == "platform") {
  9595. tmpContext.fillStyle = "#cebd5f";
  9596. let tmpCount = 4;
  9597. let tmpS = obj.scale * 2;
  9598. let tmpW = tmpS / tmpCount;
  9599. let tmpX = -(obj.scale / 2);
  9600. for (let i = 0; i < tmpCount; ++i) {
  9601. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9602. tmpContext.fill();
  9603. tmpContext.stroke();
  9604. tmpX += tmpS / tmpCount;
  9605. }
  9606. } else if (obj.name == "healing pad") {
  9607. tmpContext.fillStyle = "#7e7f82";
  9608. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9609. tmpContext.fill();
  9610. tmpContext.stroke();
  9611. tmpContext.fillStyle = "#db6e6e";
  9612. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9613. } else if (obj.name == "spawn pad") {
  9614. tmpContext.fillStyle = "#7e7f82";
  9615. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9616. tmpContext.fill();
  9617. tmpContext.stroke();
  9618. tmpContext.fillStyle = "#71aad6";
  9619. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9620. } else if (obj.name == "blocker") {
  9621. tmpContext.fillStyle = "#7e7f82";
  9622. renderCircle(0, 0, obj.scale, tmpContext);
  9623. tmpContext.fill();
  9624. tmpContext.stroke();
  9625. tmpContext.rotate(Math.PI / 4);
  9626. tmpContext.fillStyle = "#db6e6e";
  9627. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9628. } else if (obj.name == "teleporter") {
  9629. tmpContext.fillStyle = "#7e7f82";
  9630. renderCircle(0, 0, obj.scale, tmpContext);
  9631. tmpContext.fill();
  9632. tmpContext.stroke();
  9633. tmpContext.rotate(Math.PI / 4);
  9634. tmpContext.fillStyle = "#d76edb";
  9635. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9636. }
  9637. tmpContext.restore();
  9638. }
  9639.  
  9640. let objSprites = [];
  9641. function getObjSprite(obj) {
  9642. let tmpSprite = objSprites[obj.id];
  9643. if (!tmpSprite) {
  9644. let blurScale = isNight ? 15 : 0;
  9645. let tmpCanvas = document.createElement("canvas");
  9646. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9647. let tmpContext = tmpCanvas.getContext("2d");
  9648. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9649. tmpContext.rotate(Math.PI / 2);
  9650. tmpContext.strokeStyle = outlineColor;
  9651. tmpContext.lineWidth = outlineWidth;
  9652. if (isNight) {
  9653. tmpContext.shadowBlur = blurScale;
  9654. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9655. }
  9656. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9657. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9658. let tmpScale = obj.scale * 0.6;
  9659. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9660. tmpContext.fill();
  9661. tmpContext.stroke();
  9662. tmpContext.fillStyle = "#a5974c";
  9663. renderCircle(0, 0, tmpScale, tmpContext);
  9664. tmpContext.fillStyle = "#cc5151";
  9665. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9666. } else if (obj.name == "pit trap") {
  9667. tmpContext.fillStyle = "#a5974c";
  9668. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9669. tmpContext.fill();
  9670. tmpContext.stroke();
  9671. tmpContext.fillStyle = "#cc5151";
  9672. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9673. tmpContext.fill();
  9674. }
  9675. tmpSprite = tmpCanvas;
  9676. objSprites[obj.id] = tmpSprite;
  9677. }
  9678. return tmpSprite;
  9679. }
  9680.  
  9681. // GET MARK SPRITE:
  9682. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9683.  
  9684. let center = {
  9685. x: screenWidth / 2,
  9686. y: screenHeight / 2,
  9687. };
  9688. tmpContext.lineWidth = outlineWidth;
  9689. mainContext.globalAlpha = 0.4;
  9690. tmpContext.strokeStyle = outlineColor;
  9691. tmpContext.save();
  9692. tmpContext.translate(tmpX, tmpY);
  9693. tmpContext.rotate(obj.dir || getAttackDir());
  9694. if (getEl("renderplace").value == "placeVis") {
  9695. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9696. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9697. var tmpScale = (obj.scale * 0.6);
  9698. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9699. tmpContext.fill();
  9700. tmpContext.stroke();
  9701. tmpContext.fillStyle = "#a5974c";
  9702. renderCircle(0, 0, tmpScale, tmpContext);
  9703. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9704. tmpContext.fillStyle = "#a34040";
  9705. } else {
  9706. tmpContext.fillStyle = "#c9b758";
  9707. }
  9708. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9709. } else if (obj.name == "turret") {
  9710. tmpContext.fillStyle = "#a5974c";
  9711. renderCircle(0, 0, obj.scale, tmpContext);
  9712. tmpContext.fill();
  9713. tmpContext.stroke();
  9714. tmpContext.fillStyle = "#939393";
  9715. let tmpLen = 50;
  9716. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9717. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9718. tmpContext.fill();
  9719. tmpContext.stroke();
  9720. } else if (obj.name == "teleporter") {
  9721. tmpContext.fillStyle = "#7e7f82";
  9722. renderCircle(0, 0, obj.scale, tmpContext);
  9723. tmpContext.fill();
  9724. tmpContext.stroke();
  9725. tmpContext.rotate(Math.PI / 4);
  9726. tmpContext.fillStyle = "#d76edb";
  9727. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9728. } else if (obj.name == "platform") {
  9729. tmpContext.fillStyle = "#cebd5f";
  9730. let tmpCount = 4;
  9731. let tmpS = obj.scale * 2;
  9732. let tmpW = tmpS / tmpCount;
  9733. let tmpX = -(obj.scale / 2);
  9734. for (let i = 0; i < tmpCount; ++i) {
  9735. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9736. tmpContext.fill();
  9737. tmpContext.stroke();
  9738. tmpX += tmpS / tmpCount;
  9739. }
  9740. } else if (obj.name == "healing pad") {
  9741. tmpContext.fillStyle = "#7e7f82";
  9742. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9743. tmpContext.fill();
  9744. tmpContext.stroke();
  9745. tmpContext.fillStyle = "#db6e6e";
  9746. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9747. } else if (obj.name == "spawn pad") {
  9748. tmpContext.fillStyle = "#7e7f82";
  9749. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9750. tmpContext.fill();
  9751. tmpContext.stroke();
  9752. tmpContext.fillStyle = "#71aad6";
  9753. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9754. } else if (obj.name == "blocker") {
  9755. tmpContext.fillStyle = "#7e7f82";
  9756. renderCircle(0, 0, obj.scale, tmpContext);
  9757. tmpContext.fill();
  9758. tmpContext.stroke();
  9759. tmpContext.rotate(Math.PI / 4);
  9760. tmpContext.fillStyle = "#db6e6e";
  9761. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9762. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9763. tmpContext.fillStyle = "#a5974c";
  9764. renderCircle(0, 0, obj.scale, tmpContext);
  9765. tmpContext.fillStyle = "#c9b758";
  9766. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9767. tmpContext.fillStyle = "#a5974c";
  9768. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9769. } else if (obj.name == "pit trap") {
  9770. tmpContext.fillStyle = "#a5974c";
  9771. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9772. tmpContext.fill();
  9773. tmpContext.stroke();
  9774. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9775. tmpContext.fillStyle = "#a34040";
  9776. } else {
  9777. tmpContext.fillStyle = outlineColor;
  9778. }
  9779. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9780. tmpContext.fill();
  9781. }
  9782. tmpContext.restore();
  9783. }
  9784. }
  9785. function getMarkSprite2(obj, tmpContext, tmpX, tmpY) {
  9786.  
  9787. if (getEl("renderplace").value == "outline") {
  9788. tmpContext.lineWidth = outlineWidth;
  9789. mainContext.globalAlpha = 1;
  9790. tmpContext.strokeStyle = outlineColor;
  9791. tmpContext.save();
  9792. tmpContext.translate(tmpX, tmpY);
  9793. tmpContext.rotate(obj.dir || getAttackDir());
  9794.  
  9795. if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9796. let sides = obj.name == "castle wall" ? 4 : 3;
  9797. renderHealthStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9798. tmpContext.stroke();
  9799. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9800. let tmpScale = obj.scale * 0.6;
  9801. renderHealthStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9802. tmpContext.stroke();
  9803. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9804. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  9805. } else if (obj.name == "mine") {
  9806. renderHealthStar(tmpContext, 3, obj.scale, obj.scale);
  9807. tmpContext.stroke();
  9808. } else if (obj.name == "sapling") {
  9809. let tmpScale = obj.scale * 0.7;
  9810. renderHealthStar(tmpContext, 7, obj.scale, tmpScale);
  9811. tmpContext.stroke();
  9812. } else if (obj.name == "pit trap") {
  9813. renderHealthStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9814. tmpContext.stroke();
  9815. } else if (obj.name == "boost pad") {
  9816. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  9817. } else if (obj.name == "turret") {
  9818. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  9819. } else if (obj.name == "platform") {
  9820. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  9821. } else if (obj.name == "healing pad") {
  9822. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  9823. } else if (obj.name == "spawn pad") {
  9824. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  9825. } else if (obj.name == "blocker") {
  9826. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  9827. } else if (obj.name == "teleporter") {
  9828. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  9829. }
  9830. tmpContext.restore();
  9831.  
  9832. }
  9833. }
  9834. //renderCircle(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.getScale(0.6, true), mainContext, false, true);
  9835. // OBJECT ON SCREEN:
  9836. function isOnScreen(x, y, s) {
  9837. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9838. s,
  9839. maxScreenHeight));
  9840. }
  9841. /* function markObject(tmpObj, tmpX, tmpY) {
  9842. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9843. }*/
  9844. function markObject(tmpObj, tmpX, tmpY) {
  9845. yen(mainContext, tmpX, tmpY);
  9846. }
  9847. function yen(context, x, y) {
  9848. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  9849. context.beginPath();
  9850. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  9851. context.fill();
  9852. context.closePath();
  9853. context.globalAlpha = 1;
  9854. }
  9855. // RENDER MINIMAP:
  9856. class MapPing {
  9857. constructor(color, scale) {
  9858. this.init = function(x, y) {
  9859. this.scale = 0;
  9860. this.x = x;
  9861. this.y = y;
  9862. this.active = true;
  9863. };
  9864. this.update = function(ctxt, delta) {
  9865. if (this.active) {
  9866. this.scale += 0.05 * delta;
  9867. if (this.scale >= scale) {
  9868. this.active = false;
  9869. } else {
  9870. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9871. ctxt.beginPath();
  9872. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale)
  9873. * mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9874. ctxt.stroke();
  9875. }
  9876. }
  9877. };
  9878. this.color = color;
  9879. }
  9880. }
  9881. function pingMap(x, y) {
  9882. tmpPing = mapPings.find(pings => !pings.active);
  9883. if (!tmpPing) {
  9884. tmpPing = new MapPing("#fff", config.mapPingScale);
  9885. mapPings.push(tmpPing);
  9886. }
  9887. tmpPing.init(x, y);
  9888. }
  9889. function updateMapMarker() {
  9890. mapMarker.x = player.x;
  9891. mapMarker.y = player.y;
  9892. }
  9893. function renderMinimap(delta) {
  9894. if (player && player.alive) {
  9895. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9896. // RENDER PINGS:
  9897. mapContext.lineWidth = 4;
  9898. for (let i = 0; i < mapPings.length; ++i) {
  9899. tmpPing = mapPings[i];
  9900. mapContext.strokeStyle = tmpPing.color;
  9901. tmpPing.update(mapContext, delta);
  9902. }
  9903. // RENDER BREAK TRACKS:
  9904. mapContext.globalAlpha = 1;
  9905. mapContext.fillStyle = "#ff0000";
  9906. if (breakTrackers.length) {
  9907. mapContext.fillStyle = "#abcdef";
  9908. mapContext.font = "34px Hammersmith One";
  9909. mapContext.textBaseline = "middle";
  9910. mapContext.textAlign = "center";
  9911. for (let i = 0; i < breakTrackers.length;) {
  9912. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9913. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9914. i += 2;
  9915. }
  9916. }
  9917. // RENDER PLAYERS:
  9918. mapContext.globalAlpha = 1;
  9919. mapContext.fillStyle = "#fff";
  9920. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9921. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9922. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9923. if (player.team && minimapData) {
  9924. for (let i = 0; i < minimapData.length;) {
  9925. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9926. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9927. i += 2;
  9928. }
  9929. }
  9930. // RENDER BOTS:
  9931. if (bots.length) {
  9932. bots.forEach((tmp) => {
  9933. if (tmp.inGame) {
  9934. mapContext.globalAlpha = 1;
  9935. mapContext.strokeStyle = "#782F44";
  9936. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9937. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9938. }
  9939. });
  9940. }
  9941. // DEATH LOCATION:
  9942. if (lastDeath) {
  9943. mapContext.fillStyle = "#fc5553";
  9944. mapContext.font = "34px Hammersmith One";
  9945. mapContext.textBaseline = "middle";
  9946. mapContext.textAlign = "center";
  9947. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9948. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9949. }
  9950. // MAP MARKER:
  9951. if (mapMarker) {
  9952. mapContext.fillStyle = "#fff";
  9953. mapContext.font = "34px Hammersmith One";
  9954. mapContext.textBaseline = "middle";
  9955. mapContext.textAlign = "center";
  9956. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9957. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9958. }
  9959. }
  9960. }
  9961. // ICONS:
  9962. let crossHairs = ["https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg", "https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg"];
  9963. let crossHairSprites = {};
  9964. let iconSprites = {};
  9965. let icons = ["crown", "skull"];
  9966.  
  9967. function loadIcons() {
  9968. for (let i = 0; i < icons.length; ++i) {
  9969. let tmpSprite = new Image();
  9970. tmpSprite.onload = function() {
  9971. this.isLoaded = true;
  9972. };
  9973. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9974. iconSprites[icons[i]] = tmpSprite;
  9975. }
  9976. let tmpSprite = new Image();
  9977. tmpSprite.onload = function() {
  9978. this.isLoaded = true;
  9979. };
  9980. tmpSprite.src = crossHairs
  9981. crossHairSprites = tmpSprite;
  9982. }
  9983. loadIcons();
  9984. // UPDATE GAME:
  9985. function updateGame() {
  9986. if (config.resetRender) {
  9987. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  9988. mainContext.beginPath();
  9989. }
  9990. function add(array) {
  9991. let lmao = 0
  9992. for (let i = 0; i < array.length; i++) {
  9993. lmao += array[i]
  9994. }
  9995. return lmao / array.length
  9996. }
  9997. if (true) {
  9998. function updateCamera() {
  9999. let selectedCamera = document.getElementById("camera").value;
  10000. let damping = 0.35;
  10001. let scalingFactor = 20;
  10002. if (player) {
  10003. if (selectedCamera === 'Cam1') {
  10004. let damping = 0.1;
  10005. let targetCamX = player.x + ((1920 / 2) / 30);
  10006. let targetCamY = player.y + ((1920 / 2) / 30);
  10007. camX += (targetCamX - camX) * damping;
  10008. camY += (targetCamY - camY) * damping;
  10009. } else if (selectedCamera === 'Cam2' || selectedCamera === 'Cam3') {
  10010. let damping2 = 0.016;
  10011. if (player) {
  10012. let targetCamX = player.x + ((1920 / 2) / 30);
  10013. let targetCamY = player.y + ((1920 / 2) / 30);
  10014. camX = lerp(camX, targetCamX, damping2);
  10015. camY = lerp(camY, targetCamY, damping2);
  10016. } else {
  10017. camX = config.mapScale / 2;
  10018. camY = config.mapScale / 2;
  10019. }
  10020. }
  10021. } else {
  10022. camX = config.mapScale / 2;
  10023. camY = config.mapScale / 2;
  10024. }
  10025. }
  10026. updateCamera()
  10027. document.getElementById("camera").addEventListener("change", updateCamera);
  10028. function lerp(start, end, amt) {
  10029. return (1 - amt) * start + amt * end;
  10030. }
  10031. // INTERPOLATE PLAYERS AND AI:
  10032. let lastTime = now - (1000 / config.serverUpdateRate);
  10033. let tmpDiff;
  10034. for (let i = 0; i < players.length + ais.length; ++i) {
  10035. tmpObj = players[i] || ais[i - players.length];
  10036. if (tmpObj && tmpObj.visible) {
  10037. if (tmpObj.forcePos) {
  10038. tmpObj.x = tmpObj.x2;
  10039. tmpObj.y = tmpObj.y2;
  10040. tmpObj.dir = tmpObj.d2;
  10041. } else {
  10042. let total = tmpObj.t2 - tmpObj.t1;
  10043. let fraction = lastTime - tmpObj.t1;
  10044. let ratio = (fraction / total);
  10045. let rate = 170;
  10046. tmpObj.dt += delta;
  10047. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10048. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10049. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10050. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10051. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10052. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10053. }
  10054. }
  10055. }
  10056. // RENDER CORDS:
  10057. let xOffset = camX - (maxScreenWidth / 2);
  10058. let yOffset = camY - (maxScreenHeight / 2);
  10059. // RENDER BACKGROUND:
  10060. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10061. mainContext.fillStyle = "#87b522";
  10062. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10063. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10064. mainContext.fillStyle = "#bfa426";
  10065. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10066. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10067. mainContext.fillStyle = "#defdff";
  10068. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10069. } else if (config.snowBiomeTop - yOffset >= 0) {
  10070. mainContext.fillStyle = "#defdff";
  10071. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10072. mainContext.fillStyle = "#b6db66";
  10073. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10074. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10075. } else {
  10076. mainContext.fillStyle = "#b6db66";
  10077. mainContext.fillRect(0, 0, maxScreenWidth,
  10078. (config.mapScale - config.snowBiomeTop - yOffset));
  10079. mainContext.fillStyle = "#dbc666";
  10080. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10081. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10082. }
  10083.  
  10084. // RENDER WATER AREAS:
  10085. if (!firstSetup) {
  10086. waterMult += waterPlus * config.waveSpeed * delta;
  10087. if (waterMult >= config.waveMax) {
  10088. waterMult = config.waveMax;
  10089. waterPlus = -1;
  10090. } else if (waterMult <= 1) {
  10091. waterMult = waterPlus = 1;
  10092. }
  10093. mainContext.globalAlpha = 1;
  10094. mainContext.fillStyle = "#e8a033";
  10095. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10096. mainContext.fillStyle = "#91c5ff";
  10097. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10098. }
  10099. if (player) {
  10100. // DEATH LOCATION:
  10101. if (lastDeath) {
  10102. mainContext.globalAlpha = 1;
  10103. mainContext.fillStyle = "#fc5553";
  10104. mainContext.font = "100px Hammersmith One";
  10105. mainContext.textBaseline = "middle";
  10106. mainContext.textAlign = "center";
  10107. mainContext.fillText("x", lastDeath.x - xOffset, lastDeath.y - yOffset);
  10108. }
  10109. // PATHFINDER LINE:
  10110. if (pathFind.active) {
  10111. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10112. mainContext.lineWidth = player.scale / 5;
  10113. mainContext.globalAlpha = 1;
  10114. mainContext.strokeStyle = "red";
  10115. mainContext.beginPath();
  10116. pathFind.array.forEach((path, i) => {
  10117. let pathXY = {
  10118. x: (pathFind.scale / pathFind.grid) * path.x,
  10119. y: (pathFind.scale / pathFind.grid) * path.y
  10120. }
  10121. let render = {
  10122. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10123. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10124. }
  10125. if (i == 0) {
  10126. mainContext.moveTo(render.x, render.y);
  10127. } else {
  10128. mainContext.lineTo(render.x, render.y);
  10129. }
  10130. });
  10131. mainContext.stroke();
  10132. }
  10133. }
  10134. }
  10135. // RENDER DEAD PLAYERS:
  10136. if (inWindow && fisrtloadez) {
  10137. mainContext.globalAlpha = 1;
  10138. mainContext.strokeStyle = outlineColor;
  10139. renderDeadPlayers(xOffset, yOffset, Math.random() * Math.PI * 2);
  10140. }
  10141. // RENDER BOTTOM LAYER:
  10142. mainContext.globalAlpha = 1;
  10143. mainContext.strokeStyle = outlineColor;
  10144. renderGameObjects(-1, xOffset, yOffset);
  10145. // RENDER PROJECTILES:
  10146. mainContext.globalAlpha = 1;
  10147. mainContext.lineWidth = outlineWidth;
  10148. renderProjectiles(0, xOffset, yOffset);
  10149. // RENDER PLAYERS:
  10150. renderPlayers(xOffset, yOffset, 0);
  10151. // RENDER AI:
  10152. mainContext.globalAlpha = 1;
  10153. for (let i = 0; i < ais.length; ++i) {
  10154. tmpObj = ais[i];
  10155. if (tmpObj.active && tmpObj.visible) {
  10156. tmpObj.animate(delta);
  10157. mainContext.save();
  10158. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10159. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10160. renderAI(tmpObj, mainContext);
  10161. mainContext.restore();
  10162. }
  10163. }
  10164. // RENDER GRID:
  10165. if (getEl("gridsa").checked) {
  10166. mainContext.lineWidth = 3; // Nastavte ?i?ku ?ary podle pot?eby
  10167. mainContext.strokeStyle = "#000";
  10168. mainContext.globalAlpha = 0.05; // Nastavte pr?hlednost podle pot?eby
  10169. mainContext.beginPath();
  10170. let ratfrr = 60; // Nastavte podle pot?eby
  10171. for (var x = -xOffset % ratfrr; x < maxScreenWidth; x += ratfrr) {
  10172. if (x > 0) {
  10173. mainContext.moveTo(x, 0);
  10174. mainContext.lineTo(x, maxScreenHeight);
  10175. }
  10176. }
  10177. for (var y = -yOffset % ratfrr; y < maxScreenHeight; y += ratfrr) {
  10178. if (y > 0) {
  10179. mainContext.moveTo(0, y);
  10180. mainContext.lineTo(maxScreenWidth, y);
  10181. }
  10182. }
  10183. mainContext.stroke();
  10184. }
  10185. // RENDER GAME OBJECTS (LAYERED):
  10186. renderGameObjects(0, xOffset, yOffset);
  10187. renderProjectiles(1, xOffset, yOffset);
  10188. renderGameObjects(1, xOffset, yOffset);
  10189. renderPlayers(xOffset, yOffset, 1);
  10190. renderGameObjects(2, xOffset, yOffset);
  10191. renderGameObjects(3, xOffset, yOffset);
  10192. // MAP BOUNDARIES:
  10193. mainContext.fillStyle = "#000";
  10194. mainContext.globalAlpha = 0.2;
  10195. if (xOffset <= 0) {
  10196. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10197. } if (config.mapScale - xOffset <= maxScreenWidth) {
  10198. let tmpY = Math.max(0, -yOffset);
  10199. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10200. } if (yOffset <= 0) {
  10201. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10202. } if (config.mapScale - yOffset <= maxScreenHeight) {
  10203. let tmpX = Math.max(0, -xOffset);
  10204. let tmpMin = 0;
  10205. if (config.mapScale - xOffset <= maxScreenWidth)
  10206. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10207. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10208. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10209. }
  10210.  
  10211. // RENDER DAY/NIGHT TIME:
  10212. mainContext.globalAlpha = 1;
  10213. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  10214. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10215.  
  10216. // RENDER PLAYER AND AI UI:
  10217. mainContext.strokeStyle = darkOutlineColor;
  10218. mainContext.globalAlpha = 1;
  10219.  
  10220. for (let i = 0; i < players.length + ais.length; ++i) {
  10221. tmpObj = players[i] || ais[i - players.length];
  10222. if (tmpObj.visible) {
  10223. mainContext.strokeStyle = darkOutlineColor;
  10224. // NAME AND HEALTH:
  10225. if (tmpObj.skinIndex != 10 || (tmpObj == player) || (tmpObj.team && tmpObj.team == player.team)) {
  10226. let tmpText = "";
  10227. if (getEl("visualType").value == "simp1") {
  10228. tmpText = (tmpObj.team ? "/" + tmpObj.team + "/ " : "") + (tmpObj.name || "");
  10229. } else if (getEl("visualType").value == "simp2") {
  10230. tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + tmpObj.name + " {" + tmpObj.shameCount + "}";
  10231. }
  10232. if (tmpText != "") {
  10233. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10234. mainContext.textBaseline = "middle";
  10235. mainContext.textAlign = "center";
  10236. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10237. var tmpS = config.crownIconScale;
  10238. var tmpX = tmpObj.x - xOffset - (tmpS/2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10239. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10240. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10241. } if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10242. let tmpS = config.crownIconScale;
  10243. let tmpX = tmpObj.x - xOffset - (tmpS/2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10244. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10245. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10246. }
  10247. let nameColor;
  10248. if (tmpObj == player) {
  10249. nameColor = "#fff";
  10250. } else if (tmpObj.team && tmpObj.team == player.team) {
  10251. nameColor = "#fff";
  10252. } else {
  10253. nameColor = "#fff";
  10254. }
  10255. mainContext.fillStyle = nameColor;
  10256. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10257. mainContext.lineJoin = "round";
  10258. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10259. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10260.  
  10261. // HEALTH HOLDER:
  10262. mainContext.fillStyle = darkOutlineColor;
  10263. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10264. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10265. (config.healthBarPad * 2), 17, 8);
  10266. mainContext.fill();
  10267.  
  10268. // HEALTH BAR:
  10269. if (getEl("visualType").value == "simp2") {
  10270. mainContext.fillStyle = (tmpObj==player||(tmpObj.team&&tmpObj.team==player.team))? "#8ecc51" : "#cc5151";
  10271. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10272. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10273. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 20); // 20
  10274. mainContext.fill();
  10275. } else if (getEl("visualType").value == "simp1") {
  10276. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10277. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10278. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10279. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10280. mainContext.fill();
  10281. mainContext.font = "20px Hammersmith One";
  10282. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10283. mainContext.textBaseline = "middle";
  10284. mainContext.textAlign = "center";
  10285. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10286. mainContext.lineJoin = "round";
  10287. mainContext.strokeText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10288. mainContext.fillText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10289.  
  10290. mainContext.font = "14px Hammersmith One";
  10291. mainContext.fillStyle = "#FFFFFF";
  10292. mainContext.fillText("Sme: [" + tmpObj.shameCount + "]" + " / " + "Pac: [" + secPacket + "] ", tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 95);
  10293. }
  10294.  
  10295. if (tmpObj.isPlayer && tmpObj.sid === player.sid) {
  10296. mainContext.globalAlpha = 1;
  10297. mainContext.fillStyle = "rgba(143, 131, 104, 1)";
  10298.  
  10299. if(tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10300. mainContext.font = "20px Hammersmith One";
  10301. mainContext.strokeText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10302. mainContext.fillText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10303. } else {
  10304. }
  10305. if (tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10306. mainContext.globalAlpha = 1;
  10307. let targetReloads = {
  10308. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10309. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10310. turret: (2500 - tmpObj.reloads[53]) / 2500
  10311. };
  10312. if (!tmpObj.currentReloads) {
  10313. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10314. primary: targetReloads.primary,
  10315. secondary: targetReloads.secondary,
  10316. turret: targetReloads.turret
  10317. };
  10318. }
  10319. const lerpFactor = 0.3;
  10320. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10321. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10322. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10323.  
  10324. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10325. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10326. const centerX = tmpObj.x - xOffset;
  10327. const centerY = tmpObj.y - yOffset;
  10328. const barRadius = 35;
  10329. const barWidth = 15;
  10330. const totalAngle = (Math.PI*2)/3; // Half circle
  10331. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10332. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10333. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10334. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10335.  
  10336. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10337. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10338. function returncoolcolor(progress) {
  10339. const whiteValue = 255;
  10340. return `rgb(${whiteValue}, ${whiteValue}, ${whiteValue})`;
  10341. }
  10342.  
  10343.  
  10344. mainContext.save();
  10345. if (tmpObj.currentReloads.primary < 0.999) {
  10346. mainContext.beginPath();
  10347. mainContext.lineCap = 'round';
  10348. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10349. mainContext.lineWidth = 4;
  10350. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10351. mainContext.stroke();
  10352. }
  10353. if (tmpObj.currentReloads.secondary < 0.999) {
  10354. mainContext.beginPath();
  10355. mainContext.lineCap = 'round';
  10356. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10357. mainContext.lineWidth = 4;
  10358. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10359. mainContext.stroke();
  10360. }
  10361. if (tmpObj.currentReloads.turret < 0.999) {
  10362. mainContext.beginPath();
  10363. mainContext.lineCap = 'round';
  10364. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10365. mainContext.lineWidth = 4;
  10366. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10367. mainContext.stroke();
  10368. }
  10369. } else if (getEl("visualType").value == "simp2") {
  10370. }
  10371.  
  10372.  
  10373. if (tmpObj == player) {
  10374. if (getEl("predictType").value == "pre2") {
  10375. mainContext.lineWidth = 3;
  10376. mainContext.strokeStyle = "#fff";
  10377. mainContext.globalAlpha = 1;
  10378. mainContext.beginPath();
  10379. let render = {
  10380. x: tmpObj.x2 - xOffset,
  10381. y: tmpObj.y2 - yOffset
  10382. };
  10383. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10384. mainContext.lineTo(render.x, render.y);
  10385. mainContext.stroke();
  10386. } else if (getEl("predictType").value == "pre3") {
  10387. mainContext.lineWidth = 3;
  10388. mainContext.strokeStyle = "#cc5151";
  10389. mainContext.globalAlpha = 1;
  10390. mainContext.beginPath();
  10391. let render = {
  10392. x: tmpObj.x3 - xOffset,
  10393. y: tmpObj.y3 - yOffset
  10394. };
  10395. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10396. mainContext.lineTo(render.x, render.y);
  10397. mainContext.stroke();
  10398. }
  10399. }
  10400.  
  10401.  
  10402. // in here we skid ha thu mod ez(sowwie ha thu i love u <3):
  10403. if (tmpObj.isPlayer && near == tmpObj && enemy.length && rKeyPressed) {
  10404. let tmpS = tmpObj.scale * 2.2;
  10405. mainContext.drawImage(crossHairSprites, tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10406. }
  10407.  
  10408. }
  10409. }
  10410. }
  10411. }
  10412. }
  10413.  
  10414.  
  10415. // RENDER GAME OBJECTS:
  10416. function renderGameObjects(layer, xOffset, yOffset) {
  10417. let tmpSprite;
  10418. let tmpX;
  10419. let tmpY;
  10420. gameObjects.forEach((tmp) => {
  10421. tmpObj = tmp;
  10422. if (tmpObj.alive) {
  10423. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  10424. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  10425. if (layer == 0) {
  10426. tmpObj.update(delta);
  10427. }
  10428. mainContext.globalAlpha = tmpObj.alpha;
  10429. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  10430. if (tmpObj.isItem) {
  10431. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  10432. tmpSprite = getObjSprite(tmpObj);
  10433. } else {
  10434. tmpSprite = getItemSprite(tmpObj);
  10435. }
  10436. mainContext.save();
  10437. mainContext.translate(tmpX, tmpY);
  10438. mainContext.rotate(tmpObj.dir);
  10439. if (!tmpObj.active) {
  10440. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  10441. }
  10442. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  10443. if (tmpObj.blocker) {
  10444. mainContext.strokeStyle = "#db6e6e";
  10445. mainContext.globalAlpha = 0.3;
  10446. mainContext.lineWidth = 6;
  10447. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  10448. }
  10449. mainContext.restore();
  10450. } else {
  10451. tmpSprite = getResSprite(tmpObj);
  10452. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  10453. }
  10454. }
  10455. document.minis = .1;
  10456. document.bigis = 2.95;
  10457. if (getEl("bh").value == 1) {
  10458. if (layer == 3) {
  10459. if (tmpObj.health < tmpObj.maxHealth) {
  10460. const normalScale = tmpObj.scale / 2;
  10461. const normalGap = normalScale * 2 * document.minis;
  10462. const normalStart = normalScale / circleScale;
  10463. const Filler = (2 * Math.PI) / (tmpObj.maxHealth / tmpObj.healthMov);
  10464. mainContext.save();
  10465. mainContext.beginPath();
  10466. mainContext.lineCap = 'round';
  10467. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  10468. mainContext.lineWidth = normalGap * document.bigis;
  10469. mainContext.strokeStyle = darkOutlineColor;
  10470. mainContext.stroke();
  10471. mainContext.beginPath();
  10472. mainContext.lineCap = 'round';
  10473. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  10474. mainContext.lineWidth = 7;
  10475. mainContext.strokeStyle = tmpObj.isTeamObject(player) ? myObjectHealth : enemyObjectHealth;
  10476. mainContext.stroke();
  10477. mainContext.closePath();
  10478. mainContext.restore();
  10479.  
  10480. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#fff" : "#F05C5B";
  10481. mainContext.textBaseline = "middle";
  10482. mainContext.textAlign = "center";
  10483. mainContext.lineWidth = 0;
  10484. mainContext.lineJoin = "round";
  10485.  
  10486. mainContext.strokeStyle = darkOutlineColor;
  10487. mainContext.lineWidth = 5;
  10488.  
  10489. const fontSize = 18;
  10490. mainContext.font = `${fontSize}px Hammersmith One`;
  10491.  
  10492. mainContext.strokeText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  10493. mainContext.fillText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  10494. }
  10495. }
  10496. } else if (getEl("bh").value == "2") {
  10497. if (tmpObj.health < tmpObj.maxHealth) {
  10498. mainContext.fillStyle = darkOutlineColor;
  10499. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  10500. mainContext.fill();
  10501. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  10502. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  10503. mainContext.fill();
  10504. }
  10505. } else {
  10506. }
  10507. }
  10508. });
  10509.  
  10510.  
  10511. mainContext.restore();
  10512. // PLACE VISIBLE:
  10513. if (layer == 0) {
  10514. if (placeVisible.length) {
  10515. placeVisible.forEach((places) => {
  10516. tmpX = places.x - xOffset;
  10517. tmpY = places.y - yOffset;
  10518. if (getEl("renderplace").value == "placeVis") {
  10519. markObject(places, tmpX, tmpY);
  10520. }
  10521. if (getEl("renderplace").value == "outline") {
  10522. markObject2(places, tmpX, tmpY);
  10523. }
  10524. });
  10525.  
  10526.  
  10527.  
  10528. if (preplaceVisible.length) {
  10529. preplaceVisible.forEach((places) => {
  10530. tmpX = places.x - xOffset;
  10531. tmpY = places.y - yOffset;
  10532. ppmarkObject(places, tmpX, tmpY);
  10533. });
  10534. }
  10535. }
  10536. }
  10537. }
  10538. function markObject(tmpObj, tmpX, tmpY) {
  10539.  
  10540. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10541. }
  10542. function markObject2(tmpObj, tmpX, tmpY) {
  10543. getMarkSprite2(tmpObj, mainContext, tmpX, tmpY);
  10544. }
  10545. function ppmarkObject(tmpObj, tmpX, tmpY) {
  10546. ppyen(mainContext, tmpX, tmpY);
  10547. }
  10548. function ppyen(context, x, y) {
  10549. context.fillStyle = "rgba(255, 0, 0, 0.2)";
  10550. context.beginPath();
  10551. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  10552. context.fill();
  10553. context.closePath();
  10554. context.globalAlpha = 1;
  10555. }
  10556. function yen(context, x, y) {
  10557. context.fillStyle = "rgba(0, 255, 255, 0.6)";
  10558. context.beginPath();
  10559. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  10560. context.fill();
  10561. context.closePath();
  10562. context.globalAlpha = 1;
  10563. }
  10564.  
  10565. function drawArrow(xOffset, yOffset, x, y, arrowWidth, color, angle, lineWidth) {
  10566. mainContext.save()
  10567. mainContext.translate(x - xOffset, y - yOffset)
  10568. mainContext.rotate(Math.PI / 4)
  10569. mainContext.rotate(angle)
  10570. mainContext.globalAlpha = 1
  10571. mainContext.strokeStyle = color
  10572. mainContext.lineCap = "round"
  10573. mainContext.lineWidth = lineWidth
  10574. mainContext.beginPath()
  10575. mainContext.moveTo(-arrowWidth, -arrowWidth)
  10576. mainContext.lineTo(arrowWidth, -arrowWidth)
  10577. mainContext.lineTo(arrowWidth, arrowWidth)
  10578. mainContext.stroke()
  10579. mainContext.closePath()
  10580. mainContext.restore()
  10581. }
  10582. if (player) {
  10583. // AUTOPUSH LINE:
  10584. if (my.autoPush) {
  10585. mainContext.lineWidth = 5;
  10586. mainContext.globalAlpha = 1;
  10587. mainContext.beginPath();
  10588.  
  10589.  
  10590. mainContext.strokeStyle = "black";
  10591. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10592. mainContext.lineTo(my.pushData.x2 - xOffset, my.pushData.y2 - yOffset);
  10593. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  10594. mainContext.stroke();
  10595. }
  10596. }
  10597. mainContext.globalAlpha = 1;
  10598.  
  10599. // RENDER ANIM TEXTS:
  10600. textManager.update(delta, mainContext, xOffset, yOffset);
  10601. // RENDER CHAT MESSAGES:
  10602. for (let i = 0; i < players.length; ++i) {
  10603. tmpObj = players[i];
  10604. if (tmpObj.visible) {
  10605. if (tmpObj.chatCountdown > 0) {
  10606. tmpObj.chatCountdown -= delta;
  10607. if (tmpObj.chatCountdown <= 0)
  10608. tmpObj.chatCountdown = 0;
  10609. mainContext.font = "32px Hammersmith One";
  10610. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10611. mainContext.textBaseline = "middle";
  10612. mainContext.textAlign = "center";
  10613. let tmpX = tmpObj.x - xOffset;
  10614. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10615. let tmpH = 47;
  10616. let tmpW = tmpSize.width + 17;
  10617. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10618. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10619. mainContext.fill();
  10620. mainContext.fillStyle = "#fff";
  10621. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10622. }
  10623. if (tmpObj.chat.count > 0) {
  10624. tmpObj.chat.count -= delta;
  10625. if (tmpObj.chat.count <= 0)
  10626. tmpObj.chat.count = 0;
  10627. mainContext.font = "32px Hammersmith One";
  10628. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10629. mainContext.textBaseline = "middle";
  10630. mainContext.textAlign = "center";
  10631. let tmpX = tmpObj.x - xOffset;
  10632. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10633. let tmpH = 47;
  10634. let tmpW = tmpSize.width + 17;
  10635. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10636. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10637. mainContext.fill();
  10638. mainContext.fillStyle = "#ffffff99";
  10639. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10640. }
  10641. }
  10642. }
  10643. if (allChats.length) {
  10644. allChats.filter(ch => ch.active).forEach((ch) => {
  10645. if (!ch.alive) {
  10646. if (ch.alpha <= 1) {
  10647. ch.alpha += delta / 250;
  10648. if (ch.alpha >= 1) {
  10649. ch.alpha = 1;
  10650. ch.alive = true;
  10651. }
  10652. }
  10653. } else {
  10654. ch.alpha -= delta / 5000;
  10655. if (ch.alpha <= 0) {
  10656. ch.alpha = 0;
  10657. ch.active = false;
  10658. }
  10659. }
  10660. if (ch.active) {
  10661. mainContext.font = "20px Hammersmith One";
  10662. let tmpSize = mainContext.measureText(ch.chat);
  10663. mainContext.textBaseline = "middle";
  10664. mainContext.textAlign = "center";
  10665. let tmpX = ch.owner.x - xOffset;
  10666. let tmpY = ch.owner.y - ch.owner.scale - yOffset - 90;
  10667. let tmpH = 47;
  10668. let tmpW = tmpSize.width + 17;
  10669. mainContext.globalAlpha = ch.alpha;
  10670. mainContext.fillStyle = ch.owner.isTeam(player) ? "rgba(255,215,0,1)" : "#cc5151";
  10671. mainContext.strokeStyle = "rgb(25, 25, 25)";
  10672. mainContext.lineWidth = 5;
  10673. mainContext.fillStyle = "rgba(0,0,0,0.4)";
  10674. mainContext.strokeStyle = "rgba(0,0,0,0.0)";
  10675. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10676. mainContext.stroke();
  10677. mainContext.fill();
  10678. mainContext.fillStyle = "#fff";
  10679. mainContext.strokeStyle = "#000";
  10680. mainContext.strokeText(ch.chat, tmpX, tmpY);
  10681. mainContext.fillText(ch.chat, tmpX, tmpY);
  10682. ch.y -= delta / 100;
  10683. }
  10684. });
  10685. }
  10686. }
  10687. mainContext.globalAlpha = 1;
  10688. // RENDER MINIMAP:
  10689. renderMinimap(delta);
  10690. }
  10691. // UPDATE & ANIMATE:
  10692. window.requestAnimFrame = function() {
  10693. return null;
  10694. }
  10695. window.rAF = (function() {
  10696. return window.requestAnimationFrame ||
  10697. window.webkitRequestAnimationFrame ||
  10698. window.mozRequestAnimationFrame ||
  10699. function(callback) {
  10700. window.setTimeout(callback, 1000 / 240);
  10701. };
  10702. })();
  10703. function doUpdate() {
  10704. now = performance.now();
  10705. delta = now - lastUpdate;
  10706. lastUpdate = now;
  10707. let timer = performance.now();
  10708. let diff = timer - fpsTimer.last;
  10709. if (diff >= 1000) {
  10710. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10711. fpsTimer.last = timer;
  10712. fpsTimer.time = 0;
  10713. }
  10714. fpsTimer.time++;
  10715. getEl("pingFps").innerHTML = `${window.pingTime}ms | FPS: ${UTILS.round(fpsTimer.ltime, 10)}`;
  10716. getEl("packetStatus").innerHTML = secPacket;
  10717. updateGame();
  10718. rAF(doUpdate);
  10719. }
  10720. prepareMenuBackground();
  10721. doUpdate();
  10722. let changeDays = {};
  10723. window.debug = function() {
  10724. my.waitHit = 0;
  10725. my.autoAim = false;
  10726. instaC.isTrue = false;
  10727. traps.inTrap = false;
  10728. itemSprites = [];
  10729. objSprites = [];
  10730. gameObjectSprites = [];
  10731. };
  10732. window.toggleNight = function() {
  10733. isNight = !isNight;
  10734. itemSprites = [];
  10735. objSprites = [];
  10736. gameObjectSprites = [];
  10737. };
  10738. window.startGrind = function() {
  10739. if (getEl("weaponGrind").checked) {
  10740. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10741. checkPlace(player.getItemType(22), i);
  10742. }
  10743. }
  10744. };
  10745. // REMOVED!!! so they cant abuse :)
  10746. let projects = [];
  10747. let botIDS = 0;
  10748. window.connectFillBots = function() {
  10749. botSkts = [];
  10750. botIDS = 0;
  10751. for (let i = 0; i < projects.length; i++) {
  10752. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10753. test.binaryType = "arraybuffer";
  10754. test.onopen = function() {
  10755. test.ssend = function(type) {
  10756. let data = Array.prototype.slice.call(arguments, 1);
  10757. let binary = window.msgpack.encode([type, data]);
  10758. test.send(binary);
  10759. };
  10760. for (let i = 0; i < 4; i++) {
  10761. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  10762. action: "homepage"
  10763. }).then(function(token) {
  10764. test.ssend("bots", WS.url.split("&")[0] + "&token=" + encodeURIComponent(token), botIDS);
  10765. botSkts.push([test]);
  10766. botIDS++;
  10767. });
  10768. }
  10769. };
  10770. test.onmessage = function(message) {
  10771. let data = new Uint8Array(message.data);
  10772. let parsed = window.msgpack.decode(data);
  10773. let type = parsed[0];
  10774. data = parsed[1];
  10775. };
  10776. }
  10777. };
  10778. window.destroyFillBots = function() {
  10779. botSkts.forEach((socket) => {
  10780. socket[0].close();
  10781. });
  10782. botSkts = [];
  10783. };
  10784. window.tryConnectBots = function() {
  10785. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10786. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  10787. action: "homepage"
  10788. }).then(function(token) {
  10789. // CONNECT SOCKET:
  10790. botSpawn(token);
  10791. });
  10792. }
  10793. };
  10794. window.destroyBots = function() {
  10795. bots.forEach((botyyyyy) => {
  10796. botyyyyy.closeSocket = true;
  10797. });
  10798. bots = [];
  10799. };
  10800. window.resBuild = function() {
  10801. if (gameObjects.length) {
  10802. gameObjects.forEach((tmp) => {
  10803. tmp.breakObj = false;
  10804. });
  10805. breakObjects = [];
  10806. }
  10807. };
  10808. window.toggleBotsCircle = function() {
  10809. player.circle = !player.circle;
  10810. };
  10811. window.prepareUI = function(tmpObj) {
  10812. resize();
  10813. // ACTION BAR:
  10814. UTILS.removeAllChildren(actionBar);
  10815. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10816. (function(i) {
  10817. UTILS.generateElement({
  10818. id: "actionBarItem" + i,
  10819. class: "actionBarItem",
  10820. style: "display:none",
  10821. onmouseout: function() {
  10822. showItemInfo();
  10823. },
  10824. parent: actionBar
  10825. });
  10826. })(i);
  10827. }
  10828. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10829. (function(i) {
  10830. let tmpCanvas = document.createElement("canvas");
  10831. tmpCanvas.width = tmpCanvas.height = 66;
  10832. let tmpContext = tmpCanvas.getContext("2d");
  10833. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10834. tmpContext.imageSmoothingEnabled = false;
  10835. tmpContext.webkitImageSmoothingEnabled = false;
  10836. tmpContext.mozImageSmoothingEnabled = false;
  10837. if (items.weapons[i]) {
  10838. tmpContext.rotate((Math.PI / 4) + Math.PI);
  10839. let tmpSprite = new Image();
  10840. toolSprites[items.weapons[i].src] = tmpSprite;
  10841. tmpSprite.onload = function() {
  10842. this.isLoaded = true;
  10843. let tmpPad = 1 / (this.height / this.width);
  10844. let tmpMlt = (items.weapons[i].iPad || 1);
  10845. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10846. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10847. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10848. tmpContext.globalCompositeOperation = "source-atop";
  10849. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10850. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10851. };
  10852. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10853. let tmpUnit = getEl('actionBarItem' + i);
  10854. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  10855. showItemInfo(items.weapons[i], true);
  10856. });
  10857. tmpUnit.onclick = UTILS.checkTrusted(function() {
  10858. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10859. });
  10860. UTILS.hookTouchEvents(tmpUnit);
  10861. } else {
  10862. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10863. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10864. tmpContext.globalAlpha = 1;
  10865. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10866. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10867. tmpContext.globalCompositeOperation = "source-atop";
  10868. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10869. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10870. let tmpUnit = getEl('actionBarItem' + i);
  10871. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  10872. showItemInfo(items.list[i - items.weapons.length]);
  10873. });
  10874. tmpUnit.onclick = UTILS.checkTrusted(function() {
  10875. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10876. });
  10877. UTILS.hookTouchEvents(tmpUnit);
  10878. }
  10879. })(i);
  10880. }
  10881. };
  10882. window.toggleNight();
  10883. (function() {
  10884. 'use strict';
  10885.  
  10886. const CORRECT_USERNAME = "wat";
  10887. const CORRECT_PASSWORD = "unrealmodop";
  10888. const CORRECT_KEY = "likesync?";
  10889. const CORRECT_TOKEN = "faxsmate";
  10890.  
  10891. let snowfallInterval;
  10892. let snowflakesEnabled = true;
  10893.  
  10894. function createSnowflake() {
  10895. if (!snowflakesEnabled) return;
  10896.  
  10897. const snowflake = document.createElement('div');
  10898. snowflake.className = 'snowflake';
  10899. snowflake.style.position = 'absolute';
  10900. snowflake.style.top = '-10px';
  10901. snowflake.style.left = Math.random() * window.innerWidth + 'px';
  10902. snowflake.style.opacity = Math.random();
  10903. snowflake.style.fontSize = (Math.random() * 20 + 10) + 'px';
  10904. snowflake.innerHTML = '❄';
  10905. snowflake.style.color = 'white';
  10906. document.body.appendChild(snowflake);
  10907.  
  10908. const animationDuration = Math.random() * 5 + 5;
  10909. snowflake.style.animation = `fall ${animationDuration}s linear`;
  10910.  
  10911. setTimeout(() => {
  10912. document.body.removeChild(snowflake);
  10913. }, animationDuration * 1000);
  10914. }
  10915.  
  10916. function createSnowfall() {
  10917. snowfallInterval = setInterval(createSnowflake, 100);
  10918. }
  10919.  
  10920. function createToggleMenu() {
  10921. const menu = document.createElement('div');
  10922. menu.style.position = 'fixed';
  10923. menu.style.top = '10px';
  10924. menu.style.right = '10px';
  10925. menu.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  10926. menu.style.padding = '10px';
  10927. menu.style.borderRadius = '5px';
  10928. menu.style.zIndex = '10000';
  10929.  
  10930. const toggle = document.createElement('label');
  10931. toggle.style.display = 'flex';
  10932. toggle.style.alignItems = 'center';
  10933. toggle.style.color = 'white';
  10934.  
  10935. const checkbox = document.createElement('input');
  10936. checkbox.type = 'checkbox';
  10937. checkbox.checked = snowflakesEnabled;
  10938. checkbox.style.marginRight = '5px';
  10939.  
  10940. checkbox.addEventListener('change', function() {
  10941. snowflakesEnabled = this.checked;
  10942. if (snowflakesEnabled) {
  10943. createSnowfall();
  10944. } else {
  10945. clearInterval(snowfallInterval);
  10946. }
  10947. });
  10948.  
  10949. toggle.appendChild(checkbox);
  10950. toggle.appendChild(document.createTextNode('Snowflakes'));
  10951.  
  10952. menu.appendChild(toggle);
  10953. document.body.appendChild(menu);
  10954. }
  10955.  
  10956. function createOverlay() {
  10957. const overlay = document.createElement("div");
  10958. overlay.style.position = "fixed";
  10959. overlay.style.top = "0";
  10960. overlay.style.left = "0";
  10961. overlay.style.width = "100%";
  10962. overlay.style.height = "100%";
  10963. overlay.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
  10964. overlay.style.display = "flex";
  10965. overlay.style.alignItems = "center";
  10966. overlay.style.justifyContent = "center";
  10967. overlay.style.zIndex = "9999";
  10968.  
  10969. const box = document.createElement("div");
  10970. box.style.padding = "40px";
  10971. box.style.borderRadius = "10px";
  10972. box.style.backgroundColor = "black";
  10973. box.style.boxShadow = "0 0 20px rgba(128, 0, 128, 0.5)";
  10974. box.style.textAlign = "center";
  10975. box.style.color = "white";
  10976.  
  10977. const inputs = ['username', 'password', 'key', 'token'].map(type => {
  10978. const input = document.createElement("input");
  10979. input.type = type === 'password' ? 'password' : 'text';
  10980. input.placeholder = type.charAt(0).toUpperCase() + type.slice(1);
  10981. input.style.display = "block";
  10982. input.style.margin = "10px auto";
  10983. input.style.padding = "10px";
  10984. input.style.width = "200px";
  10985. return input;
  10986. });
  10987.  
  10988. const submitButton = document.createElement("button");
  10989. submitButton.innerText = "Submit";
  10990. submitButton.style.padding = "10px 20px";
  10991. submitButton.style.marginTop = "20px";
  10992.  
  10993. inputs.forEach(input => box.appendChild(input));
  10994. box.appendChild(submitButton);
  10995. overlay.appendChild(box);
  10996.  
  10997. submitButton.addEventListener("click", function() {
  10998. const [username, password, key, token] = inputs.map(input => input.value);
  10999.  
  11000. if (username === CORRECT_USERNAME &&
  11001. password === CORRECT_PASSWORD &&
  11002. key === CORRECT_KEY &&
  11003. token === CORRECT_TOKEN) {
  11004. document.body.removeChild(overlay);
  11005. } else {
  11006. alert("Incorrect credentials. Refreshing...");
  11007. location.reload();
  11008. }
  11009. });
  11010.  
  11011. document.body.appendChild(overlay);
  11012. }
  11013.  
  11014. // Add snowfall animation
  11015. const style = document.createElement('style');
  11016. style.textContent = `
  11017. @keyframes fall {
  11018. to {
  11019. transform: translateY(100vh);
  11020. }
  11021. }
  11022. `;
  11023. document.head.appendChild(style);
  11024.  
  11025. createOverlay();
  11026. createSnowfall();
  11027. createToggleMenu();
  11028. })();
  11029.  
  11030.  

QingJ © 2025

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