Unreal? mod v4

Ong this mod so op it kell all server

  1. // ==UserScript==
  2. // @name Unreal? mod v4
  3. // @author wat, VirusterDev
  4. // @namespace try and ur gay
  5. // @description Ong this mod so op it kell all server
  6. // @version v.4
  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. -Bots-
  46. Dev: VirusterDev
  47.  
  48. 7/21/2024
  49. -socket bots replaced
  50. -menu edited
  51. -visuals toggle
  52. -login bypass for dev (hold down u, h, and m)
  53. -auto-mylee sync
  54. -ranged sync
  55. -performance optimization
  56. */
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. let ping = 0
  80.  
  81. document.getElementById("gameName").innerHTML = " Unreal mod?";
  82. (function() {
  83. let shadowRadius = 50;
  84. let shadowDirection = 1;
  85. let canShadow = true;
  86. setInterval(() => {
  87. if (canShadow == true) {
  88. shadowRadius = (shadowDirection == 1) ? shadowRadius - 5 : shadowRadius + 5;
  89. if (shadowRadius >= 50 || shadowRadius <= 0) {
  90. shadowDirection = (shadowRadius >= 50) ? 1 : (shadowRadius <= 0) ? 0 : null;
  91. canShadow = false;
  92. setTimeout(() => {
  93. canShadow = true;
  94. }, 100);
  95. }
  96. }
  97. document.getElementById("gameName").style.textShadow = `0px 0px ${shadowRadius + 20}px #ffffff`;
  98. }, 100);
  99. })();
  100.  
  101. (function() {
  102. })();var moomooVer = $('#linksContainer2 .menuLink').html(),
  103. hideSelectors = ['#mobileDownloadButtonContainer',
  104. '#followText',
  105. '#smallLinks',
  106. '#linksContainer1',
  107. '#twitterFollow',
  108. '#youtubeFollow',
  109. '#cdm-zone-02',
  110. '#youtuberOf',
  111. '#downloadButtonContainer',
  112. '#promoImg',
  113. '.menuHeader',
  114. '.menuLink',
  115. '.menuHeader:nth-child(5)',
  116. '.menuHeader:nth-child(6)',
  117. '.menuText',
  118. '#adCard',
  119. '#promoImgHolder',
  120. ],
  121.  
  122. css = '#rightCardHolder {display: block!important}',
  123. head = document.head || document.getElementsByTagName('head')[0],
  124. style = document.createElement('style');
  125.  
  126. style.type = 'text/css';
  127. if (style.styleSheet){
  128. style.styleSheet.cssText = css;
  129. } else {
  130. style.appendChild(document.createTextNode(css));
  131. }
  132.  
  133. for ( let i = 0; i < hideSelectors.length; i++ ) {
  134. $(hideSelectors[i]).hide();
  135. }
  136.  
  137. head.appendChild(style);
  138. $('#linksContainer2').html('<a href="./docs/versions.txt" target="_blank" class="menuLink">' + moomooVer + '</a>');
  139. document.getElementById("storeHolder").style = "height: 500px; width: 435px;";
  140. document.getElementById('enterGame').innerText = "Welcome";
  141. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  142. document.getElementById('enterGame').innerText = "Start?";
  143. });
  144. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  145. document.getElementById('enterGame').innerText = "Wanna play";
  146. });$('#itemInfoHolder').css({
  147. 'text-align': 'center',
  148. 'top': '25px',
  149. 'left': '440px',
  150. 'right': '350px',
  151. 'max-width': '350px'
  152. });
  153.  
  154. $('.menuCard').css({
  155. 'white-space': 'normal',
  156. 'text-align': 'center',
  157. 'background-color': 'rgba(0, 0, 0, 0.74)',
  158. '-moz-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  159. '-webkit-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  160. 'box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  161. '-webkit-border-radius': '10px',
  162. '-moz-border-radius': '10px',
  163. 'border-radius': '10px',
  164. 'margin': '15px',
  165. 'margin-top': '15px'
  166. });
  167.  
  168. $('#menuContainer').css({'white-space': 'normal'});
  169.  
  170. $('#mapDisplay').css({
  171. '-webkit-border-radius': '10px',
  172. '-moz-border-radius': '10px',
  173. 'border-radius': '10px'
  174. });
  175.  
  176. $('.menuHeader').css({
  177. 'color': 'rgba(0, 0, 0, 0.5)'
  178. });
  179.  
  180. $('#killCounter').css({
  181. 'color': '#ededed'
  182. });
  183.  
  184. $('#diedText').css({
  185. 'background-color': 'rgb(255, 255, 255)'
  186. });
  187.  
  188. $('#gameCanvas').css({
  189. 'background-color': '#f4f4f4'
  190. });
  191.  
  192. $('#scoreDisplay').css({
  193. 'color': '#e6b800'
  194. });
  195.  
  196.  
  197. $('#leaderboard').css({'-webkit-border-radius': '0px',
  198. '-moz-border-radius': '0px',
  199. 'border-radius': '0px',
  200. 'background-color': 'rgb((255,240,245))',
  201. 'text-align': 'center'});
  202.  
  203. $('#storeTab, #storeHolder, #allianceHolder').css({
  204. '-webkit-border-radius': '10px',
  205. '-moz-border-radius': '10px',
  206. 'border-radius': '10px',
  207. 'background-color': 'rgba(0, 0, 0, 0.4)'
  208. });
  209.  
  210. $('#storeHolder').css({
  211. 'height': '1500px',
  212. 'width': '450px'
  213. });
  214.  
  215. $('.actionBarItem').css({
  216. '-webkit-border-radius': '10px',
  217. 'border-radius': '10px',
  218. 'background-color': 'rgba(0, 0, 0, 0.4)',
  219. 'border-color': '#FF0000',
  220. 'box-shadow': '0 0 10px 0 rgba(255, 0, 0, 0.5)'
  221. });
  222. // pyroz color theme
  223. let nameColor = "#fff";
  224. let enemyNameColor = "#ffffff";
  225. let reloadBarColor = "";
  226. let healthBarColor = "#60478D";
  227. let shameBarColor = "#60478D";
  228. let enemyHealthBarColor = "#782F44";
  229. let damageTextColor = "#782F44";
  230. let healTextColor = "#60478D";
  231. let myObjectHealth = "#5f9ea0";
  232. let enemyObjectHealth = "#ff6363";
  233. let autoPushLine = "#ffffff";
  234.  
  235. document.addEventListener("keydown", function(event) {
  236. if(!window.VirusterDev){
  237. if (event.keyCode === 192) {
  238. const chatHolder = document.getElementById("gameUI");
  239. if (chatHolder) {
  240. const currentDisplay = chatHolder.style.display;
  241. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  242. }
  243. }
  244. if (event.keyCode === 99) {
  245. const chatHolder = document.getElementById("gameCanvas");
  246. if (chatHolder) {
  247. const currentDisplay = chatHolder.style.display;
  248. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  249. }
  250. }
  251. if (event.keyCode === 9) {
  252. const chatHolder = document.getElementById("menuChatDiv");
  253. if (chatHolder) {
  254. const currentDisplay = chatHolder.style.display;
  255. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  256. }
  257. }
  258. }
  259. });//virusterdev: some drunk dude had 3 keydown listeners for single conditions so i combined into one
  260. let circleScale = 1.5
  261. let namechanger = false;
  262. let inantiantibull = false;
  263. let spin = {
  264. degree: 45,
  265. toggle: false,
  266. angle: 0
  267. }
  268. function getEl(id) {
  269. return document.getElementById(id);
  270. }
  271. window.oncontextmenu = function() {
  272. return false;
  273. };
  274. let config = window.config;
  275. config.serverUpdateRate = 9;
  276. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  277. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  278. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  279. "#8bc373", "#91b2db"
  280. ];
  281. config.weaponVariants = [{
  282. id: 0,
  283. src: "",
  284. xp: 0,
  285. val: 1,
  286. }, {
  287. id: 1,
  288. src: "_g",
  289. xp: 3000,
  290. val: 1.1,
  291. }, {
  292. id: 2,
  293. src: "_d",
  294. xp: 7000,
  295. val: 1.18,
  296. }, {
  297. id: 3,
  298. src: "_r",
  299. poison: true,
  300. xp: 12000,
  301. val: 1.18,
  302. }];
  303. config.resetRender = false;
  304. function waitTime(timeout) {
  305. return new Promise((done) => {
  306. setTimeout(() => {
  307. done();
  308. }, timeout);
  309. });
  310. }
  311. let changed = false;
  312. let botSkts = [];
  313. // STORAGE:
  314. let canStore;
  315. if (typeof (Storage) !== "undefined") {
  316. canStore = true;
  317. }
  318. function saveVal(name, val) {
  319. if (canStore)
  320. localStorage.setItem(name, val);
  321. }
  322. function deleteVal(name) {
  323. if (canStore)
  324. localStorage.removeItem(name);
  325. }
  326. function getSavedVal(name) {
  327. if (canStore)
  328. return localStorage.getItem(name);
  329. return null;
  330. }
  331. // CONFIGS:
  332. let gC = function(a, b) {
  333. try {
  334. let res = JSON.parse(getSavedVal(a));
  335. if (typeof res === "object") {
  336. return b;
  337. } else {
  338. return res;
  339. }
  340. } catch (e) {
  341. return b;
  342. }
  343. };
  344. function setConfigs() {
  345. return {
  346. autochat: false,
  347. killChat: true,
  348. autoBuy: true,
  349. autoBuyEquip: true,
  350. autoRespawn: false,
  351. fpsboost: false,
  352. slowOT: false,
  353. attackDir: true,
  354. noDir: false,
  355. showDir: false,
  356. StopSpin: true,
  357. };
  358. }
  359.  
  360. function setconfig2() {
  361. return {
  362. AutoQonHigh: true,
  363. AutoQonSync: true,
  364. SimpleAnti: true,
  365. AntiBowInsta: true,
  366. AutoPlace: true,
  367. AutoReplace: true,
  368. AutoPreplace: false,
  369. AutoSpikeTick: true,
  370. AntiTrap: true,
  371. AutoPredictTick: true,
  372. AntiSpikeTick: true,
  373. AntiTick: false,
  374. spikeTick: true,
  375. CounterInsta: false,
  376. AutoBullSpam: false,
  377. AutoPush: false,
  378. };
  379. }
  380.  
  381. let configs1 = setconfig2();
  382. let configs = setConfigs();
  383.  
  384. window.removeConfigs = function() {
  385. for (let cF in configs && configs1) {
  386. deleteVal(cF, configs && configs1[cF]);
  387. }
  388. };
  389.  
  390. window.removeConfigs1 = function() {
  391. for (let cF in configs1) {
  392. deleteVal(cF, configs1[cF]);
  393. }
  394. };
  395.  
  396. for (let cF in configs) {
  397. configs[cF] = gC(cF, configs[cF]);
  398. }
  399. for (let cF in configs1) {
  400. configs1[cF] = gC(cF, configs1[cF]);
  401. }
  402.  
  403. class HtmlAction {
  404. constructor(element) {
  405. this.element = element;
  406. };
  407. add(code) {
  408. if (!this.element) return undefined;
  409. this.element.innerHTML += code;
  410. };
  411. newLine(amount) {
  412. let result = `<br>`;
  413. if (amount > 0) {
  414. result = ``;
  415. for (let i = 0; i < amount; i++) {
  416. result += `<br>`;
  417. }
  418. }
  419. this.add(result);
  420. };
  421. checkBox(setting) {
  422. let newCheck = `<input type = "checkbox"`;
  423. setting.id && (newCheck += ` id = ${setting.id}`);
  424. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  425. setting.class && (newCheck += ` class = ${setting.class}`);
  426. setting.checked && (newCheck += ` checked`);
  427. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  428. newCheck += `>`;
  429. this.add(newCheck);
  430. };
  431. text(setting) {
  432. let newText = `<input type = "text"`;
  433. setting.id && (newText += ` id = ${setting.id}`);
  434. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  435. setting.class && (newText += ` class = ${setting.class}`);
  436. setting.size && (newText += ` size = ${setting.size}`);
  437. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  438. setting.value && (newText += ` value = ${setting.value}`);
  439. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  440. newText += `>`;
  441. this.add(newText);
  442. };
  443. select(setting) {
  444. let newSelect = `<select`;
  445. setting.id && (newSelect += ` id = ${setting.id}`);
  446. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  447. setting.class && (newSelect += ` class = ${setting.class}`);
  448. newSelect += `>`;
  449. for (let options in setting.option) {
  450. newSelect += `<option value = ${setting.option[options].id}`
  451. setting.option[options].selected && (newSelect += ` selected`);
  452. newSelect += `>${options}</option>`;
  453. }
  454. newSelect += `</select>`;
  455. this.add(newSelect);
  456. };
  457. button(setting) {
  458. let newButton = `<button`;
  459. setting.id && (newButton += ` id = ${setting.id}`);
  460. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  461. setting.class && (newButton += ` class = ${setting.class}`);
  462. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  463. newButton += `>`;
  464. setting.innerHTML && (newButton += setting.innerHTML);
  465. newButton += `</button>`;
  466. this.add(newButton);
  467. };
  468. selectMenu(setting) {
  469. let newSelect = `<select`;
  470. if (!setting.id) {
  471. alert("please put id skid");
  472. return;
  473. }
  474. window[setting.id + "Func"] = function() {};
  475. setting.id && (newSelect += ` id = ${setting.id}`);
  476. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  477. setting.class && (newSelect += ` class = ${setting.class}`);
  478. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  479. newSelect += `>`;
  480. let last;
  481. let i = 0;
  482. for (let options in setting.menu) {
  483. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  484. setting.menu[options] && (newSelect += ` checked`);
  485. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  486. i++;
  487. }
  488. newSelect += `</select>`;
  489.  
  490. this.add(newSelect);
  491.  
  492. i = 0;
  493. for (let options in setting.menu) {
  494. window[options + "Func"] = function() {
  495. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  496. saveVal(options, setting.menu[options]);
  497.  
  498. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  499. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  500.  
  501. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  502.  
  503. };
  504. this.checkBox({
  505. id: "check_" + options,
  506. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  507. class: "checkB",
  508. onclick: `window.${options + "Func"}()`,
  509. checked: setting.menu[options]
  510. });
  511. i++;
  512. }
  513.  
  514. last = "check_" + getEl(setting.id).value.split("_")[1];
  515. window[setting.id + "Func"] = function() {
  516. getEl(last).style.display = "none";
  517. last = "check_" + getEl(setting.id).value.split("_")[1];
  518. getEl(last).style.display = "inline-block";
  519.  
  520. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  521.  
  522. };
  523. };
  524. };
  525. class Html {
  526. constructor() {
  527. this.element = null;
  528. this.action = null;
  529. this.divElement = null;
  530. this.startDiv = function(setting, func) {
  531.  
  532. let newDiv = document.createElement("div");
  533. setting.id && (newDiv.id = setting.id);
  534. setting.style && (newDiv.style = setting.style);
  535. setting.class && (newDiv.className = setting.class);
  536. this.element.appendChild(newDiv);
  537. this.divElement = newDiv;
  538.  
  539. let addRes = new HtmlAction(newDiv);
  540. typeof func == "function" && func(addRes);
  541.  
  542. };
  543. this.addDiv = function(setting, func) {
  544.  
  545. let newDiv = document.createElement("div");
  546. setting.id && (newDiv.id = setting.id);
  547. setting.style && (newDiv.style = setting.style);
  548. setting.class && (newDiv.className = setting.class);
  549. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  550. this.divElement = newDiv;
  551.  
  552. let addRes = new HtmlAction(newDiv);
  553. typeof func == "function" && func(addRes);
  554.  
  555. };
  556. };
  557. set(id) {
  558. this.element = getEl(id);
  559. this.action = new HtmlAction(this.element);
  560. };
  561. resetHTML(text) {
  562. if (text) {
  563. this.element.innerHTML = ``;
  564. } else {
  565. this.element.innerHTML = ``;
  566. }
  567. };
  568. setStyle(style) {
  569. this.element.style = style;
  570. };
  571. setCSS(style) {
  572. this.action.add(`<style>` + style + `</style>`);
  573. };
  574. };
  575. window.VirusterDev = false;
  576. window.TVDV = ()=>{
  577. window.VirusterDev = !window.VirusterDev
  578. }
  579. let HTML = new Html();
  580.  
  581.  
  582. let nightMode = document.createElement("div");
  583. nightMode.id = "nightMode";
  584. document.body.appendChild(nightMode);
  585. HTML.set("nightMode");
  586. HTML.setStyle(`
  587. display: none;
  588. position: absolute;
  589. pointer-events: none;
  590. background-color: rgb(0, 0, 100);
  591. opacity: 0;
  592. top: 0%;
  593. width: 100%;
  594. height: 100%;
  595. animation-duration: 5s;
  596. animation-name: night2;
  597. `);
  598. HTML.resetHTML();
  599. HTML.setCSS(`
  600. @keyframes night1 {
  601. from {opacity: 0;}
  602. to {opacity: 0.35;}
  603. }
  604. @keyframes night2 {
  605. from {opacity: 0.35;}
  606. to {opacity: 0;}
  607. }
  608. `);
  609. let menuDiv = document.createElement("div");
  610. menuDiv.id = "menuDiv";
  611. document.body.appendChild(menuDiv);
  612. HTML.set("menuDiv");
  613. HTML.setStyle(`
  614. position: absolute;
  615. left: 20px;
  616. top: 20px;
  617. `);
  618. HTML.resetHTML();
  619. HTML.setCSS(`
  620. .menuClass{
  621. color: #fff;
  622. font-size: 31px;
  623. text-align: left;
  624. padding: 10px;
  625. padding-top: 7px;
  626. padding-bottom: 5px;
  627. width: 300px;
  628. background-color: rgba(0, 0, 0, 0.25);
  629. -webkit-border-radius: 6px;
  630. -moz-border-radius: 6px;
  631. border-radius: 6px;
  632. 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;
  633. overflow: visible;
  634. filter: blur(5px);
  635. }
  636. .menuClass:hover {
  637. background-color: rgba(0, 0, 0, 0.25);
  638. transform: translateY(-5px) scale(1.05);
  639. filter: none;
  640. }
  641. .menuC {
  642. display: none;
  643. font-family: "Hammersmith One";
  644. font-size: 12px;
  645. max-height: 180px;
  646. overflow-y: scroll;
  647. -webkit-touch-callout: none;
  648. -webkit-user-select: none;
  649. -khtml-user-select: none;
  650. -moz-user-select: none;
  651. -ms-user-select: none;
  652. user-select: none;
  653. }
  654. .menuB {
  655. text-align: center;
  656. background-color: rgb(25, 25, 25);
  657. color: #fff;
  658. -webkit-border-radius: 4px;
  659. -moz-border-radius: 4px;
  660. border-radius: 4px;
  661. border: 2px solid #000;
  662. cursor: pointer;
  663. }
  664. .menuB:hover {
  665. border: 2px solid #fff;
  666. }
  667. .menuB:active {
  668. color: rgb(25, 25, 25);
  669. background-color: rgb(200, 200, 200);
  670. }
  671. .customText {
  672. color: #000;
  673. -webkit-border-radius: 4px;
  674. -moz-border-radius: 4px;
  675. border-radius: 4px;
  676. border: 2px solid #000;
  677. }
  678. .customText:focus {
  679. background-color: yellow;
  680. }
  681. .checkB {
  682. position: relative;
  683. top: 2px;
  684. accent-color: #888;
  685. cursor: pointer;
  686. }
  687. .Cselect {
  688. -webkit-border-radius: 4px;
  689. -moz-border-radius: 4px;
  690. border-radius: 4px;
  691. background-color: rgb(75, 75, 75);
  692. color: #fff;
  693. border: 1px solid #000;
  694. }
  695. #menuChanger {
  696. position: absolute;
  697. right: 10px;
  698. top: 10px;
  699. background-color: rgba(0, 0, 0, 0);
  700. color: #fff;
  701. border: none;
  702. cursor: pointer;
  703. }
  704. #menuChanger:hover {
  705. color: #000;
  706. }
  707. ::-webkit-scrollbar {
  708. width: 10px;
  709. }
  710. ::-webkit-scrollbar-track {
  711. opacity: 0;
  712. }
  713. ::-webkit-scrollbar-thumb {
  714. background-color: rgb(25, 25, 25);
  715. -webkit-border-radius: 4px;
  716. -moz-border-radius: 4px;
  717. border-radius: 4px;
  718. }
  719. ::-webkit-scrollbar-thumb:active {
  720. background-color: rgb(230, 230, 230);
  721. }
  722. `);
  723. HTML.startDiv({ id: "menuHeadLine", class: "menuClass" }, (html) => {
  724. html.button({ id: "menuChanger", class: "material-icons", innerHTML: `sync`, onclick: "window.changeMenu()" });
  725. HTML.addDiv({ id: "menuButtons", style: "display: block; overflow-y: visible;", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  726. html.button({ class: "menuB", innerHTML: "fix broken mod", onclick: "window.debug()" });
  727. html.button({ class: "menuB", innerHTML: "dark mode", onclick: "window.toggleNight()" });
  728. html.newLine();
  729. });
  730. HTML.addDiv({ id: "menuMain", style: "display: block", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  731. HTML.addDiv({ style: "font-size: 20px; color: #99ee99;", appendID: "menuMain" }, (html) => {
  732. html.add(`wats combat and other stuff`);
  733. });
  734. html.add(`Misc: `);
  735. html.selectMenu({ id: "configsChanger", class: "Cselect", menu: configs });
  736. html.newLine();
  737. html.add(`v1: `);
  738. html.selectMenu({ id: "configsChanger1", class: "Cselect", menu: configs1 });
  739. html.newLine();
  740. html.add(`AntiBull Type: `);
  741. html.select({
  742. id: "antiBullType", class: "Cselect", option: {
  743. "Disable AntiBull": {
  744. id: "noab",
  745. selected: true,
  746. },
  747. "When Reloaded": {
  748. id: "abreload",
  749. },
  750. "Primary Reloaded": {
  751. id: "abalway",
  752. }
  753. }
  754. });
  755. html.newLine();
  756. html.add(`Insta-Type: `);
  757. html.select({
  758. id: "instaType", class: "Cselect", option: {
  759. Normal: {
  760. id: "oneShot",
  761. selected: true
  762. },
  763. RevInsta: {
  764. id: "revTick",
  765. },
  766. Spammer: {
  767. id: "spammer"
  768. },
  769. }
  770. });
  771. html.newLine();
  772. html.add(`AutoOneFrame: `);
  773. html.checkBox({ id: "oneframe", class: "checkB", checked: false });
  774. html.newLine();
  775. html.add(`BackupNoBull: `);
  776. html.checkBox({ id: "backupNobull", class: "checkB", checked: false });
  777. html.newLine();
  778. html.add(`T^G Assist: `);
  779. html.checkBox({ id: "turretCombat", class: "checkB", checked: true });
  780. html.newLine();
  781. html.add(`Grind: `);
  782. html.checkBox({ id: "weaponGrind", class: "checkB", onclick: "window.startGrind()" });
  783. html.newLine();
  784. });
  785. HTML.addDiv({ id: "menuConfig", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  786. HTML.addDiv({ style: "font-size: 20px; color: #99ee99;", appendID: "menuConfig" }, (html) => {
  787. html.add(`wats weird visualsj`);
  788. });
  789. html.add(`Visuals: `);
  790. html.select({
  791. id: "visualType", class: "Cselect", option: {
  792. "Normal visuals": {
  793. id: "simp1",
  794. },
  795. "Advanced visuals": {
  796. id: "simp2",
  797. },
  798. }
  799. });
  800. html.newLine();
  801. html.add(`Render Place Type: `);
  802. html.select({
  803. id: "renderplace",
  804. class: "Cselect",
  805. option: {
  806. disable: {
  807. id: "disable",
  808. },
  809. Show: {
  810. id: "placeVis",
  811. selected: true
  812. },
  813. OutLine: {
  814. id: "outline"
  815. },
  816. }
  817. });
  818. html.newLine();
  819. html.add(`BuildingHealth: `);
  820. html.select({
  821. id: "bh", class: "Cselect", option: {
  822. "Disable": {
  823. id: "0",
  824. },
  825. "Circle": {
  826. id: "1",
  827. selected: true
  828. },
  829. "Rectangle": {
  830. id: "2"
  831. }
  832. }
  833. });
  834. html.newLine();
  835. html.add('Vision-stuff: ');
  836. html.select({
  837. id: "vision",
  838. class: "Cselect",
  839. option: {
  840. '1': {
  841. id: "1",
  842. selected: true
  843. },
  844. '1.1': {
  845. id: "1.1",
  846. },
  847. '1.2': {
  848. id: "1.2",
  849. },
  850. '1.3': {
  851. id: "1.3",
  852. },
  853. '1.4': {
  854. id: "1.4",
  855. },
  856. '1.5': {
  857. id: "1.5",
  858. },
  859. '2': {
  860. id: "2",
  861. }
  862. }
  863. })
  864. html.newLine();
  865. html.add('CameraSped: ');
  866. html.select({
  867. id: "camera", class: "Cselect", option: {
  868. 'FCam': {
  869. id: 'Cam+',
  870. },
  871. 'Normal': {
  872. id: 'Cam1',
  873. selected: true
  874. },
  875. 'medium': {
  876. id: 'Cam2',
  877. },
  878. 'Smooth': {
  879. id: 'Cam3',
  880. },
  881. }
  882. });
  883. html.newLine();
  884. html.add(`Predict-Move: `);
  885. html.select({
  886. id: "predictType", class: "Cselect", option: {
  887. "Disable": {
  888. id: "disableRender",
  889. selected: true
  890. },
  891. "X/Y and 2": {
  892. id: "pre2",
  893. },
  894. "X/Y and 3": {
  895. id: "pre3"
  896. }
  897. }
  898. });
  899. html.newLine();
  900. html.add(`Grids?: `);
  901. html.checkBox({ id: "gridsa", class: "checkB", checked: false });
  902. });
  903. HTML.addDiv({ id: "menuOther", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  904. html.button({ class: "menuB", innerHTML: "Connect Bots", onclick: "window.tryConnectBots()" });
  905. html.button({ class: "menuB", innerHTML: "Disconnect Bots", onclick: "window.destroyBots()" });
  906.  
  907. html.newLine();
  908. html.add(`Socket Bots Mode: `);
  909. html.select({
  910. id: "mode",
  911. class: "Cselect",
  912. option: {
  913. "Stop": {
  914. id: "stopp",
  915. selected: false
  916. },
  917.  
  918. "Stop": {
  919. id: "mouse",
  920. selected: false
  921. },
  922. "Clear Building": {
  923. id: "clear",
  924. selected: false
  925. },
  926. "Mylee rush": {
  927. id: "fight",
  928. selected: false
  929. },
  930. "Sync": {
  931. id: "zync",
  932. selected: true
  933. },
  934. "Search": {
  935. id: "zearch"
  936. },
  937. "Clear Everything": {
  938. id: "fuckemup"
  939. },
  940. "Flex": {
  941. id: "flex"
  942. }
  943. }
  944. });
  945. html.newLine();
  946. html.button({ class: "menuB", innerHTML: "Connect FBots", onclick: "window.connectFillBots()" });
  947. html.button({ class: "menuB", innerHTML: "Disconnect FBots", onclick: "window.destroyFillBots()" });
  948. html.newLine();
  949. html.button({ class: "menuB", innerHTML: "Reset Break Objects", onclick: "window.resBuild()" });
  950. html.newLine();
  951. html.add(`Break Objects Range: `);
  952. html.text({ id: "breakRange", class: "customText", value: "700", size: "3em", maxLength: "4" });
  953. html.newLine();
  954. html.add(`Predict Movement Type: `);
  955.  
  956. html.newLine(2);
  957. html.button({ class: "menuB", innerHTML: "Toggle Fbots Circle", onclick: "window.toggleBotsCircle()" });
  958. html.newLine();
  959. html.add(`Circle Rad: `);
  960. html.text({ id: "circleRad", class: "customText", value: "200", size: "3em", maxLength: "4" });
  961. html.newLine();
  962. html.add(`Rad Speed: `);
  963. html.text({ id: "radSpeed", class: "customText", value: "0.1", size: "2em", maxLength: "3" });
  964. html.newLine(2);
  965. html.add(`Cross World: `);
  966. html.checkBox({ id: "funni", class: "checkB" });
  967. html.newLine();
  968. html.button({ class: "menuB", innerHTML: "Toggle Another Visual", onclick: "window.toggleVisual()" });
  969. html.newLine();
  970. html.button({ class: "menuB", innerHTML: "Toggle VirusterDev mode", onclick: "window.TVDV()" });
  971. html.newLine();
  972. });
  973. });
  974. let menuChatDiv = document.createElement("div");
  975. menuChatDiv.id = "menuChatDiv";
  976. document.body.appendChild(menuChatDiv);
  977. HTML.set("menuChatDiv");
  978. HTML.setStyle(`
  979. position: absolute;
  980. display: none;
  981. left: 0px;
  982. top: 0px;
  983. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0); //0.65
  984. `);
  985. HTML.resetHTML();
  986. HTML.setCSS(`
  987. .chDiv{
  988. color: #fff;
  989. padding: 10px;
  990. width: 400px;
  991. height: 250px;
  992. background-color: rgba(0, 0, 0, 0); //0.35
  993. }
  994. .chMainDiv{
  995. font-family: "Ubuntu";
  996. font-size: 16px;
  997. max-height: 215px;
  998. -webkit-touch-callout: none;
  999. -webkit-user-select: none;
  1000. -khtml-user-select: none;
  1001. -moz-user-select: none;
  1002. -ms-user-select: none;
  1003. user-select: none;
  1004. overflow-x: hidden;
  1005. }
  1006. .chMainBox{
  1007. position: absolute;
  1008. left: 10px;
  1009. bottom: 10px;
  1010. width: 335px;
  1011. height: 25px;
  1012. background-color: rgba(255, 255, 255, 0);
  1013. -webkit-border-radius: 4px;
  1014. -moz-border-radius: 4px;
  1015. border-radius: 4px;
  1016. color: rgba(255, 255, 255, 0);
  1017. font-family: "Arial";
  1018. font-size: 12px;
  1019. border: none;
  1020. outline: none;
  1021. }
  1022. `);
  1023. HTML.startDiv({id: "mChDiv", class: "chDiv"}, (html) => {
  1024. HTML.addDiv({id: "mChMain", class: "chMainDiv", appendID: "mChDiv"}, (html) => {
  1025. });
  1026. html.text({id: "mChBox", class: "chMainBox", placeHolder: ``});
  1027. });
  1028. let menuChats = getEl("mChMain");
  1029. let menuChatBox = getEl("mChBox");
  1030. let menuCBFocus = false;
  1031. let menuChCounts = 0;
  1032.  
  1033. function addChatLog(e, c, d, v) {
  1034. HTML.set("menuChatDiv");
  1035. let chatLogs = document.getElementById("mChMain");
  1036. const now = new Date();
  1037. const hours = now.getHours();
  1038. const minutes = now.getMinutes();
  1039. const ampm = hours >= 12 ? 'PM' : 'AM';
  1040. const formattedHours = (hours % 12 || 12).toString();
  1041. const formattedMinutes = minutes.toString().padStart(2, '0');
  1042. let time = `${formattedHours}:${formattedMinutes} ${ampm}`;
  1043.  
  1044. let a = document.createElement('div');
  1045. a.className = 'chatEntry';
  1046.  
  1047. let timeSpan = document.createElement('span');
  1048. timeSpan.style.color = 'rgba(255, 255, 255, 0.5)';
  1049. timeSpan.innerText = `${time}`;
  1050. a.appendChild(timeSpan);
  1051.  
  1052. let namething = document.createElement('span');
  1053. namething.style.color = v;
  1054. namething.innerText = ' ' + d;
  1055. a.appendChild(namething);
  1056.  
  1057. let chatSpan = document.createElement('span');
  1058. chatSpan.style.color = c;
  1059. chatSpan.innerText = ' ' + e;
  1060. a.appendChild(chatSpan);
  1061.  
  1062. chatLogs.appendChild(a);
  1063. chatLogs.scrollTop = chatLogs.scrollHeight;
  1064. }
  1065. let menuIndex = 0;
  1066. let menus = ["menuMain", "menuConfig", "menuOther"];
  1067. window.changeMenu = function() {
  1068. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1069. menuIndex++;
  1070. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1071. };
  1072. let mStatus = document.createElement("div");
  1073. mStatus.id = "status";
  1074. getEl("gameUI").appendChild(mStatus);
  1075. HTML.set("status");
  1076. HTML.setStyle(`
  1077. display: block;
  1078. position: absolute;
  1079. color: #ddd;
  1080. font: 15px Hammersmith One;
  1081. bottom: 215px;
  1082. left: 20px;
  1083. `);
  1084. HTML.resetHTML();
  1085. HTML.setCSS(`
  1086. .sizing {
  1087. font-size: 15px;
  1088. }
  1089. .mod {
  1090. font-size: 15px;
  1091. display: inline-block;
  1092. }
  1093. `);
  1094. HTML.startDiv({ id: "uehmod", class: "sizing" }, (html) => {
  1095. html.add(`Ping: `);
  1096. HTML.addDiv({ id: "pingFps", class: "mod", appendID: "uehmod" }, (html) => {
  1097. html.add("None");
  1098. });
  1099. html.newLine();
  1100. html.add(`Packet: `);
  1101. HTML.addDiv({ id: "packetStatus", class: "mod", appendID: "uehmod" }, (html) => {
  1102. html.add("None");
  1103. });
  1104. });
  1105. let openMenu = false;
  1106. let WS = undefined;
  1107. let socketID = undefined;
  1108. let secPacket = 0;
  1109. let secMax = 110;
  1110. let secTime = 1000;
  1111. let firstSend = {
  1112. sec: false
  1113. };
  1114. let game = {
  1115. tick: 0,
  1116. tickQueue: [],
  1117. tickBase: function(set, tick) {
  1118. if (this.tickQueue[this.tick + tick]) {
  1119. this.tickQueue[this.tick + tick].push(set);
  1120. } else {
  1121. this.tickQueue[this.tick + tick] = [set];
  1122. }
  1123. },
  1124. tickRate: (1000 / config.serverUpdateRate),
  1125. tickSpeed: 0,
  1126. lastTick: performance.now()
  1127. };
  1128. let modConsole = [];
  1129. let dontSend = false;
  1130. let fpsTimer = {
  1131. last: 0,
  1132. time: 0,
  1133. ltime: 0
  1134. }
  1135. let lastMoveDir = undefined;
  1136. let lastsp = ["cc", 1, "__proto__"];
  1137. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1138. WebSocket.prototype.send = function(message) {
  1139. if (!WS) {
  1140. WS = this;
  1141. WS.addEventListener("message", function(msg) {
  1142. getMessage(msg);
  1143. });
  1144. WS.addEventListener("close", (event) => {
  1145. if (event.code == 4001) {
  1146. window.location.reload();
  1147. }
  1148. });
  1149. }
  1150. if (WS == this) {
  1151. dontSend = false;
  1152. // EXTRACT DATA ARRAY:
  1153. let data = new Uint8Array(message);
  1154. let parsed = window.msgpack.decode(data);
  1155. let type = parsed[0];
  1156. data = parsed[1];
  1157. // SEND MESSAGE:
  1158. if (type == "6") {
  1159. if (data[0]) {
  1160. 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"];
  1161. let tmpString;
  1162. profanity.forEach((profany) => {
  1163. if (data[0].indexOf(profany) > -1) {
  1164. tmpString = "";
  1165. for (let i = 0; i < profany.length; ++i) {
  1166. if (i == 1) {
  1167. tmpString += String.fromCharCode(0);
  1168. }
  1169. tmpString += profany[i];
  1170. }
  1171. let re = new RegExp(profany, "g");
  1172. data[0] = data[0].replace(re, tmpString);
  1173. }
  1174. });
  1175. data[0] = data[0].slice(0, 30);
  1176. }
  1177. } else if (type == "L") {
  1178. // MAKE SAME CLAN:
  1179. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1180. data[0] = data[0].slice(0, 7);
  1181. } else if (type == "M") {
  1182. // APPLY CYAN COLOR:
  1183. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1184. data[0].moofoll = true;
  1185. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1186. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1187. } else if (type == "D") {
  1188. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1189. dontSend = true;
  1190. } else {
  1191. my.lastDir = data[0];
  1192. }
  1193. } else if (type == "d") {
  1194. if (!data[2]) {
  1195. dontSend = true;
  1196. } else {
  1197. if (![null, undefined].includes(data[1])) {
  1198. my.lastDir = data[1];
  1199. }
  1200. }
  1201. } else if (type == "K") {
  1202. if (!data[1]) {
  1203. dontSend = true;
  1204. }
  1205. } else if (type == "14") {
  1206. instaC.wait = !instaC.wait;
  1207. dontSend = true;
  1208. } else if (type == "a") {
  1209. if (data[1]) {
  1210. if (player.moveDir == data[0]) {
  1211. dontSend = true;
  1212. }
  1213. player.moveDir = data[0];
  1214. } else {
  1215. dontSend = true;
  1216. }
  1217. }
  1218. if (!dontSend) {
  1219. let binary = window.msgpack.encode([type, data]);
  1220. this.nsend(binary);
  1221. // START COUNT:
  1222. if (!firstSend.sec) {
  1223. firstSend.sec = true;
  1224. setTimeout(() => {
  1225. firstSend.sec = false;
  1226. secPacket = 0;
  1227. }, secTime);
  1228. }
  1229. secPacket++;
  1230. }
  1231. } else {
  1232. this.nsend(message);
  1233. }
  1234. }
  1235. function packet(type) {
  1236. // EXTRACT DATA ARRAY:
  1237. let data = Array.prototype.slice.call(arguments, 1);
  1238. // SEND MESSAGE:
  1239. let binary = window.msgpack.encode([type, data]);
  1240. WS.send(binary);
  1241. }
  1242. function getMessage(message) {
  1243. let data = new Uint8Array(message.data);
  1244. let parsed = window.msgpack.decode(data);
  1245. let type = parsed[0];
  1246. data = parsed[1];
  1247. let events = {
  1248. A: setInitData,
  1249. //B: disconnect,
  1250. C: setupGame,
  1251. D: addPlayer,
  1252. E: removePlayer,
  1253. a: updatePlayers,
  1254. G: updateLeaderboard,
  1255. H: loadGameObject,
  1256. I: loadAI,
  1257. J: animateAI,
  1258. K: gatherAnimation,
  1259. L: wiggleGameObject,
  1260. M: shootTurret,
  1261. N: updatePlayerValue,
  1262. O: updateHealth,
  1263. P: killPlayer,
  1264. Q: killObject,
  1265. R: killObjects,
  1266. S: updateItemCounts,
  1267. T: updateAge,
  1268. U: updateUpgrades,
  1269. V: updateItems,
  1270. X: addProjectile,
  1271. Y: remProjectile,
  1272. //Z: serverShutdownNotice,
  1273. //0: addAlliance,
  1274. //1: deleteAlliance,
  1275. 2: allianceNotification,
  1276. 3: setPlayerTeam,
  1277. 4: setAlliancePlayers,
  1278. 5: updateStoreItems,
  1279. 6: receiveChat,
  1280. 7: updateMinimap,
  1281. 8: showText,
  1282. 9: pingMap,
  1283. //0: pingSocketResponse,
  1284. };
  1285. if (type == "io-init") {
  1286. socketID = data[0];
  1287. } else {
  1288. if (events[type]) {
  1289. events[type].apply(undefined, data);
  1290. }
  1291. }
  1292. }
  1293. // MATHS:
  1294. Math.lerpAngle = function(value1, value2, amount) {
  1295. let difference = Math.abs(value2 - value1);
  1296. if (difference > Math.PI) {
  1297. if (value1 > value2) {
  1298. value2 += Math.PI * 2;
  1299. } else {
  1300. value1 += Math.PI * 2;
  1301. }
  1302. }
  1303. let value = value2 + ((value1 - value2) * amount);
  1304. if (value >= 0 && value <= Math.PI * 2) return value;
  1305. return value % (Math.PI * 2);
  1306. };
  1307. // REOUNDED RECTANGLE:
  1308. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1309. if (w < 2 * r) r = w / 2;
  1310. if (h < 2 * r) r = h / 2;
  1311. if (r < 0)
  1312. r = 0;
  1313. this.beginPath();
  1314. this.moveTo(x + r, y);
  1315. this.arcTo(x + w, y, x + w, y + h, r);
  1316. this.arcTo(x + w, y + h, x, y + h, r);
  1317. this.arcTo(x, y + h, x, y, r);
  1318. this.arcTo(x, y, x + w, y, r);
  1319. this.closePath();
  1320. return this;
  1321. };
  1322. // GLOBAL VALUES:
  1323. let allChats = [];
  1324. let ais = [];
  1325. let inWater = false
  1326. let players = [];
  1327. let alliances = [];
  1328. let alliancePlayers = [];
  1329. let allianceNotifications = [];
  1330. let gameObjects = [];
  1331. let projectiles = [];
  1332. let deadPlayers = [];
  1333. let breakObjects = [];
  1334. let player;
  1335. let playerSID;
  1336. let tmpObj;
  1337. let enemy = [];
  1338. //let perfectReplace = [];
  1339. let nears = [];
  1340. let near = [];
  1341. let rKeyPressed = false
  1342. let my = {
  1343. reloaded: false,
  1344. waitHit: 0,
  1345. autoAim: false,
  1346. revAim: false,
  1347. ageInsta: true,
  1348. reSync: false,
  1349. bullTick: 0,
  1350. anti0Tick: 0,
  1351. antiSync: false,
  1352. safePrimary: function(tmpObj) {
  1353. return [0, 8].includes(tmpObj.primaryIndex);
  1354. },
  1355. safeSecondary: function(tmpObj) {
  1356. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1357. },
  1358. lastDir: 0,
  1359. autoPush: false,
  1360. pushData: {}
  1361. }
  1362. // FIND OBJECTS BY ID/SID:
  1363. function findID(tmpObj, tmp) {
  1364. return tmpObj.find((THIS) => THIS.id == tmp);
  1365. }
  1366. function findSID(tmpObj, tmp) {
  1367. return tmpObj.find((THIS) => THIS.sid == tmp);
  1368. }
  1369. function findPlayerByID(id) {
  1370. return findID(players, id);
  1371. }
  1372. function findPlayerBySID(sid) {
  1373. return findSID(players, sid);
  1374. }
  1375. function findAIBySID(sid) {
  1376. return findSID(ais, sid);
  1377. }
  1378. function findObjectBySid(sid) {
  1379. return findSID(gameObjects, sid);
  1380. }
  1381. function findProjectileBySid(sid) {
  1382. return findSID(gameObjects, sid);
  1383. }
  1384. let gameName = getEl("gameName");
  1385. let adCard = getEl("adCard");
  1386. //adCard.remove();
  1387. let promoImageHolder = getEl("promoImgHolder");
  1388. promoImageHolder.remove();
  1389. let chatButton = getEl("chatButton");
  1390. chatButton.remove();
  1391. let gameCanvas = getEl("gameCanvas");
  1392. let mainContext = gameCanvas.getContext("2d");
  1393. let mapDisplay = getEl("mapDisplay");
  1394. let mapContext = mapDisplay.getContext("2d");
  1395. mapDisplay.width = 300;
  1396. mapDisplay.height = 300;
  1397. let storeMenu = getEl("storeMenu");
  1398. let storeHolder = getEl("storeHolder");
  1399. let upgradeHolder = getEl("upgradeHolder");
  1400. let upgradeCounter = getEl("upgradeCounter");
  1401. let chatBox = getEl("chatBox");
  1402. chatBox.autocomplete = "off";
  1403. chatBox.style.textAlign = "center";
  1404. chatBox.style.width = "18em";
  1405. let chatHolder = getEl("chatHolder");
  1406. let actionBar = getEl("actionBar");
  1407. let leaderboardData = getEl("leaderboardData");
  1408. let itemInfoHolder = getEl("itemInfoHolder");
  1409. let menuCardHolder = getEl("menuCardHolder");
  1410. let mainMenu = getEl("mainMenu");
  1411. let diedText = getEl("diedText");
  1412. let screenWidth;
  1413. let screenHeight;
  1414. let maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1415. let maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1416.  
  1417. function zoomVision() {
  1418. if (maxScreenWidth != config.maxScreenWidth * 1.5 || maxScreenHeight != config.maxScreenHeight * 1.5) {
  1419. maxScreenWidth = config.maxScreenWidth * 1.5;
  1420. maxScreenHeight = config.maxScreenHeight * 1.5;
  1421. resize();
  1422. }
  1423. }
  1424. function resetZoom() {
  1425. if (maxScreenWidth != config.maxScreenWidth * parseFloat(getEl("vision").value) || maxScreenHeight != config.maxScreenHeight * parseFloat(getEl("vision").value)) {
  1426. maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1427. maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1428. resize();
  1429. }
  1430. }
  1431. getEl("vision").onchange = function() {
  1432. resetZoom();
  1433. }
  1434. let pixelDensity = 1;
  1435. let delta;
  1436. let now;
  1437. let lastUpdate = performance.now();
  1438. let camX;
  1439. let camY;
  1440. let tmpDir;
  1441. let mouseX = 0;
  1442. let mouseY = 0;
  1443. let allianceMenu = getEl("allianceMenu");
  1444. let waterMult = 1;
  1445. let waterPlus = 0;
  1446. let outlineColor = "#525252";
  1447. let darkOutlineColor = "#3d3f42";
  1448. let outlineWidth = 5.5;
  1449. let isNight = false;
  1450. let firstSetup = true;
  1451. let keys = {};
  1452. let moveKeys = {
  1453. 87: [0, -1],
  1454. 38: [0, -1],
  1455. 83: [0, 1],
  1456. 40: [0, 1],
  1457. 65: [-1, 0],
  1458. 37: [-1, 0],
  1459. 68: [1, 0],
  1460. 39: [1, 0],
  1461. };
  1462. function resetMoveDir() {
  1463. keys = {};
  1464. packet("e");
  1465. }
  1466. let attackState = 0;
  1467. let inGame = false;
  1468. let macro = {};
  1469. let mills = {
  1470. place: 0,
  1471. placeSpawnPads: 0
  1472. };
  1473. let lastDir;
  1474. let lastLeaderboardData = [];
  1475. // ON LOAD:
  1476. let inWindow = true;
  1477. window.onblur = function() {
  1478. inWindow = false;
  1479. };
  1480. window.onfocus = function() {
  1481. inWindow = true;
  1482. if (player && player.alive) {
  1483. resetMoveDir();
  1484. }
  1485. };
  1486. let placeVisible = [];
  1487. let preplaceVisible = [];
  1488. let profanityList = [/*"cunt", "whore", "fuck", "shit", "faggot", "nigger",
  1489. "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex",
  1490. "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune",
  1491. "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard"*/];
  1492. /** CLASS CODES */
  1493. class Utils {
  1494. constructor() {
  1495. // MATH UTILS:
  1496. let mathABS = Math.abs,
  1497. mathCOS = Math.cos,
  1498. mathSIN = Math.sin,
  1499. mathPOW = Math.pow,
  1500. mathSQRT = Math.sqrt,
  1501. mathATAN2 = Math.atan2,
  1502. mathPI = Math.PI;
  1503. let _this = this;
  1504. // GLOBAL UTILS:
  1505. this.round = function(n, v) {
  1506. return Math.round(n * v) / v;
  1507. };
  1508. this.toRad = function(angle) {
  1509. return angle * (mathPI / 180);
  1510. };
  1511. this.toAng = function(radian) {
  1512. return radian / (mathPI / 180);
  1513. };
  1514. this.randInt = function(min, max) {
  1515. return Math.floor(Math.random() * (max - min + 1)) + min;
  1516. };
  1517. this.randFloat = function(min, max) {
  1518. return Math.random() * (max - min + 1) + min;
  1519. };
  1520. this.lerp = function(value1, value2, amount) {
  1521. return value1 + (value2 - value1) * amount;
  1522. };
  1523. this.decel = function(val, cel) {
  1524. if (val > 0)
  1525. val = Math.max(0, val - cel);
  1526. else if (val < 0)
  1527. val = Math.min(0, val + cel);
  1528. return val;
  1529. };
  1530. this.getDistance = function(x1, y1, x2, y2) {
  1531. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1532. };
  1533. this.getDist = function(tmp1, tmp2, type1, type2) {
  1534. let tmpXY1 = {
  1535. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1536. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1537. };
  1538. let tmpXY2 = {
  1539. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1540. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1541. };
  1542. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1543. };
  1544. this.getDirection = function(x1, y1, x2, y2) {
  1545. return mathATAN2(y1 - y2, x1 - x2);
  1546. };
  1547. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1548. let tmpXY1 = {
  1549. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1550. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1551. };
  1552. let tmpXY2 = {
  1553. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1554. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1555. };
  1556. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1557. };
  1558. this.getAngleDist = function(a, b) {
  1559. let p = mathABS(b - a) % (mathPI * 2);
  1560. return (p > mathPI ? (mathPI * 2) - p : p);
  1561. };
  1562. this.isNumber = function(n) {
  1563. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1564. };
  1565. this.isString = function(s) {
  1566. return (s && typeof s == "string");
  1567. };
  1568. this.kFormat = function(num) {
  1569. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1570. };
  1571. this.sFormat = function(num) {
  1572. let fixs = [
  1573. { num: 1e3, string: "k" },
  1574. { num: 1e6, string: "m" },
  1575. { num: 1e9, string: "b" },
  1576. { num: 1e12, string: "q" }
  1577. ].reverse();
  1578. let sp = fixs.find(v => num >= v.num);
  1579. if (!sp) return num;
  1580. return (num / sp.num).toFixed(1) + sp.string;
  1581. };
  1582. this.capitalizeFirst = function(string) {
  1583. return string.charAt(0).toUpperCase() + string.slice(1);
  1584. };
  1585. this.fixTo = function(n, v) {
  1586. return parseFloat(n.toFixed(v));
  1587. };
  1588. this.sortByPoints = function(a, b) {
  1589. return parseFloat(b.points) - parseFloat(a.points);
  1590. };
  1591. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1592. let minX = x1;
  1593. let maxX = x2;
  1594. if (x1 > x2) {
  1595. minX = x2;
  1596. maxX = x1;
  1597. }
  1598. if (maxX > recX2)
  1599. maxX = recX2;
  1600. if (minX < recX)
  1601. minX = recX;
  1602. if (minX > maxX)
  1603. return false;
  1604. let minY = y1;
  1605. let maxY = y2;
  1606. let dx = x2 - x1;
  1607. if (Math.abs(dx) > 0.0000001) {
  1608. let a = (y2 - y1) / dx;
  1609. let b = y1 - a * x1;
  1610. minY = a * minX + b;
  1611. maxY = a * maxX + b;
  1612. }
  1613. if (minY > maxY) {
  1614. let tmp = maxY;
  1615. maxY = minY;
  1616. minY = tmp;
  1617. }
  1618. if (maxY > recY2)
  1619. maxY = recY2;
  1620. if (minY < recY)
  1621. minY = recY;
  1622. if (minY > maxY)
  1623. return false;
  1624. return true;
  1625. };
  1626. this.containsPoint = function(element, x, y) {
  1627. let bounds = element.getBoundingClientRect();
  1628. let left = bounds.left + window.scrollX;
  1629. let top = bounds.top + window.scrollY;
  1630. let width = bounds.width;
  1631. let height = bounds.height;
  1632. let insideHorizontal = x > left && x < left + width;
  1633. let insideVertical = y > top && y < top + height;
  1634. return insideHorizontal && insideVertical;
  1635. };
  1636. this.mousifyTouchEvent = function(event) {
  1637. let touch = event.changedTouches[0];
  1638. event.screenX = touch.screenX;
  1639. event.screenY = touch.screenY;
  1640. event.clientX = touch.clientX;
  1641. event.clientY = touch.clientY;
  1642. event.pageX = touch.pageX;
  1643. event.pageY = touch.pageY;
  1644. };
  1645. this.hookTouchEvents = function(element, skipPrevent) {
  1646. let preventDefault = !skipPrevent;
  1647. let isHovering = false;
  1648. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1649. let passive = false;
  1650. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1651. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1652. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1653. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1654. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1655. function touchStart(e) {
  1656. _this.mousifyTouchEvent(e);
  1657. window.setUsingTouch(true);
  1658. if (preventDefault) {
  1659. e.preventDefault();
  1660. e.stopPropagation();
  1661. }
  1662. if (element.onmouseover)
  1663. element.onmouseover(e);
  1664. isHovering = true;
  1665. }
  1666. function touchMove(e) {
  1667. _this.mousifyTouchEvent(e);
  1668. window.setUsingTouch(true);
  1669. if (preventDefault) {
  1670. e.preventDefault();
  1671. e.stopPropagation();
  1672. }
  1673. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1674. if (!isHovering) {
  1675. if (element.onmouseover)
  1676. element.onmouseover(e);
  1677. isHovering = true;
  1678. }
  1679. } else {
  1680. if (isHovering) {
  1681. if (element.onmouseout)
  1682. element.onmouseout(e);
  1683. isHovering = false;
  1684. }
  1685. }
  1686. }
  1687. function touchEnd(e) {
  1688. _this.mousifyTouchEvent(e);
  1689. window.setUsingTouch(true);
  1690. if (preventDefault) {
  1691. e.preventDefault();
  1692. e.stopPropagation();
  1693. }
  1694. if (isHovering) {
  1695. if (element.onclick)
  1696. element.onclick(e);
  1697. if (element.onmouseout)
  1698. element.onmouseout(e);
  1699. isHovering = false;
  1700. }
  1701. }
  1702. };
  1703. this.removeAllChildren = function(element) {
  1704. while (element.hasChildNodes()) {
  1705. element.removeChild(element.lastChild);
  1706. }
  1707. };
  1708. this.generateElement = function(config) {
  1709. let element = document.createElement(config.tag || "div");
  1710. function bind(configValue, elementValue) {
  1711. if (config[configValue])
  1712. element[elementValue] = config[configValue];
  1713. }
  1714. bind("text", "textContent");
  1715. bind("html", "innerHTML");
  1716. bind("class", "className");
  1717. for (let key in config) {
  1718. switch (key) {
  1719. case "tag":
  1720. case "text":
  1721. case "html":
  1722. case "class":
  1723. case "style":
  1724. case "hookTouch":
  1725. case "parent":
  1726. case "children":
  1727. continue;
  1728. default:
  1729. break;
  1730. }
  1731. element[key] = config[key];
  1732. }
  1733. if (element.onclick)
  1734. element.onclick = this.checkTrusted(element.onclick);
  1735. if (element.onmouseover)
  1736. element.onmouseover = this.checkTrusted(element.onmouseover);
  1737. if (element.onmouseout)
  1738. element.onmouseout = this.checkTrusted(element.onmouseout);
  1739. if (config.style) {
  1740. element.style.cssText = config.style;
  1741. }
  1742. if (config.hookTouch) {
  1743. this.hookTouchEvents(element);
  1744. }
  1745. if (config.parent) {
  1746. config.parent.appendChild(element);
  1747. }
  1748. if (config.children) {
  1749. for (let i = 0; i < config.children.length; i++) {
  1750. element.appendChild(config.children[i]);
  1751. }
  1752. }
  1753. return element;
  1754. };
  1755. this.checkTrusted = function(callback) {
  1756. return function(ev) {
  1757. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1758. callback(ev);
  1759. } else {
  1760. //console.error("Event is not trusted.", ev);
  1761. }
  1762. };
  1763. };
  1764. this.randomString = function(length) {
  1765. let text = "";
  1766. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1767. for (let i = 0; i < length; i++) {
  1768. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1769. }
  1770. return text;
  1771. };
  1772. this.countInArray = function(array, val) {
  1773. let count = 0;
  1774. for (let i = 0; i < array.length; i++) {
  1775. if (array[i] === val) count++;
  1776. }
  1777. return count;
  1778. };
  1779. this.hexToRgb = function(hex) {
  1780. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1781. };
  1782. this.getRgb = function(r, g, b) {
  1783. return [r / 255, g / 255, b / 255].join(", ");
  1784. };
  1785. }
  1786. };
  1787. class Animtext {
  1788. // ANIMATED TEXT:
  1789. constructor() {
  1790. // INIT:
  1791. this.init = function(x, y, scale, speed, life, text, color) {
  1792. this.x = x;
  1793. this.y = y;
  1794. this.color = color;
  1795. this.scale = scale;
  1796. this.startScale = this.scale;
  1797. this.maxScale = scale * 1.5;
  1798. this.scaleSpeed = 0.7;
  1799. this.speed = speed;
  1800. this.life = life;
  1801. this.text = text;
  1802. this.acc = 1;
  1803. this.alpha = 0;
  1804. this.maxLife = life;
  1805. this.ranX = UTILS.randFloat(-1, 1);
  1806. };
  1807. // UPDATE:
  1808. this.update = function(delta) {
  1809. if (this.life) {
  1810. this.life -= delta;
  1811. this.y -= this.speed * delta;
  1812. this.scale += this.scaleSpeed * delta;
  1813. if (this.scale >= this.maxScale) {
  1814. this.scale = this.maxScale;
  1815. this.scaleSpeed *= -1;
  1816. } else if (this.scale <= this.startScale) {
  1817. this.scale = this.startScale;
  1818. this.scaleSpeed = 0;
  1819. }
  1820. if (this.life <= 0) {
  1821. this.life = 0;
  1822. }
  1823. }
  1824. };
  1825. // RENDER:
  1826. this.render = function(ctxt, xOff, yOff) {
  1827. ctxt.lineWidth = 10;
  1828. ctxt.fillStyle = this.color;
  1829. ctxt.font = this.scale + "px " + (this.scale >= 15 ? "Hammersmith One" : "Ubuntu");
  1830. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1831. ctxt.globalAlpha = 1;
  1832. };
  1833. }
  1834. };
  1835. class Textmanager {
  1836. // TEXT MANAGER:
  1837. constructor() {
  1838. this.texts = [];
  1839. this.stack = [];
  1840. // UPDATE:
  1841. this.update = function(delta, ctxt, xOff, yOff) {
  1842. ctxt.textBaseline = "middle";
  1843. ctxt.textAlign = "center";
  1844. for (let i = 0; i < this.texts.length; ++i) {
  1845. if (this.texts[i].life) {
  1846. this.texts[i].update(delta);
  1847. this.texts[i].render(ctxt, xOff, yOff);
  1848. }
  1849. }
  1850. };
  1851. // SHOW TEXT:
  1852. this.showText = function(x, y, scale, speed, life, text, color) {
  1853. let tmpText;
  1854. for (let i = 0; i < this.texts.length; ++i) {
  1855. if (!this.texts[i].life) {
  1856. tmpText = this.texts[i];
  1857. break;
  1858. }
  1859. }
  1860. if (!tmpText) {
  1861. tmpText = new Animtext();
  1862. this.texts.push(tmpText);
  1863. }
  1864. tmpText.init(x, y, scale, speed, life, text, color);
  1865. };
  1866. }
  1867. }
  1868. class GameObject {
  1869. constructor(sid) {
  1870. this.sid = sid;
  1871. // INIT:
  1872. this.init = function(x, y, dir, scale, type, data, owner) {
  1873. data = data || {};
  1874. this.sentTo = {};
  1875. this.gridLocations = [];
  1876. this.active = true;
  1877. this.alive = true;
  1878. this.doUpdate = data.doUpdate;
  1879. this.x = x;
  1880. this.y = y;
  1881. this.dir = dir;
  1882. this.lastDir = dir;
  1883. this.xWiggle = 0;
  1884. this.yWiggle = 0;
  1885. this.visScale = scale;
  1886. this.scale = scale;
  1887. this.type = type;
  1888. this.id = data.id;
  1889. this.owner = owner;
  1890. this.name = data.name;
  1891. this.isItem = (this.id != undefined);
  1892. this.group = data.group;
  1893. this.maxHealth = data.health;
  1894. this.health = this.maxHealth;
  1895. this.healthMov = 100;
  1896. this.layer = 2;
  1897. if (this.group != undefined) {
  1898. this.layer = this.group.layer;
  1899. } else if (this.type == 0) {
  1900. this.layer = 3;
  1901. } else if (this.type == 2) {
  1902. this.layer = 0;
  1903. } else if (this.type == 4) {
  1904. this.layer = -1;
  1905. }
  1906. this.colDiv = data.colDiv || 1;
  1907. this.blocker = data.blocker;
  1908. this.ignoreCollision = data.ignoreCollision;
  1909. this.dontGather = data.dontGather;
  1910. this.hideFromEnemy = data.hideFromEnemy;
  1911. this.friction = data.friction;
  1912. this.projDmg = data.projDmg;
  1913. this.dmg = data.dmg;
  1914. this.pDmg = data.pDmg;
  1915. this.pps = data.pps;
  1916. this.zIndex = data.zIndex || 0;
  1917. this.turnSpeed = data.turnSpeed;
  1918. this.req = data.req;
  1919. this.trap = data.trap;
  1920. this.healCol = data.healCol;
  1921. this.teleport = data.teleport;
  1922. this.boostSpeed = data.boostSpeed;
  1923. this.projectile = data.projectile;
  1924. this.shootRange = data.shootRange;
  1925. this.shootRate = data.shootRate;
  1926. this.shootCount = this.shootRate;
  1927. this.spawnPoint = data.spawnPoint;
  1928. this.onNear = 0;
  1929. this.breakObj = false;
  1930. this.alpha = data.alpha || 1;
  1931. this.maxAlpha = data.alpha || 1;
  1932. this.damaged = 0;
  1933. };
  1934. // GET HIT:
  1935. this.changeHealth = function(amount, doer) {
  1936. this.health += amount;
  1937. return (this.health <= 0);
  1938. };
  1939. // GET SCALE:
  1940. this.getScale = function(sM, ig) {
  1941. sM = sM || 1;
  1942. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1943. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1944. };
  1945. // VISIBLE TO PLAYER:
  1946. this.visibleToPlayer = function(player) {
  1947. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1948. (this.owner.team && player.team == this.owner.team)));
  1949. };
  1950. // UPDATE:
  1951. this.update = function(delta) {
  1952. if (this.health != this.healthMov) {
  1953. this.health < this.healthMov ? (this.healthMov -= 1.9) : (this.healthMov += 1.9);
  1954. if (Math.abs(this.health - this.healthMov) < 1.9) this.healthMov = this.health;
  1955. };
  1956. if (this.active) {
  1957. if (this.xWiggle) {
  1958. this.xWiggle *= Math.pow(0.99, delta);
  1959. }
  1960. if (this.yWiggle) {
  1961. this.yWiggle *= Math.pow(0.99, delta);
  1962. }
  1963. if (this.turnSpeed && this.dmg) {
  1964. this.dir += this.turnSpeed * delta;
  1965. }
  1966. } else {
  1967. if (this.alive) {
  1968. this.alpha -= delta / (200 / this.maxAlpha);
  1969. this.visScale += delta / (this.scale / 2.5);
  1970. if (this.alpha <= 0) {
  1971. this.alpha = 0;
  1972. this.alive = false;
  1973. }
  1974. }
  1975. }
  1976. };
  1977. // CHECK TEAM:
  1978. this.isTeamObject = function(tmpObj) {
  1979. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  1980. };
  1981. }
  1982. }
  1983. class Items {
  1984. constructor() {
  1985. // ITEM GROUPS:
  1986. this.groups = [{
  1987. id: 0,
  1988. name: "food",
  1989. layer: 0
  1990. }, {
  1991. id: 1,
  1992. name: "walls",
  1993. place: true,
  1994. limit: 30,
  1995. layer: 0
  1996. }, {
  1997. id: 2,
  1998. name: "spikes",
  1999. place: true,
  2000. limit: 15,
  2001. layer: 0
  2002. }, {
  2003. id: 3,
  2004. name: "mill",
  2005. place: true,
  2006. limit: 7,
  2007. layer: 1
  2008. }, {
  2009. id: 4,
  2010. name: "mine",
  2011. place: true,
  2012. limit: 1,
  2013. layer: 0
  2014. }, {
  2015. id: 5,
  2016. name: "trap",
  2017. place: true,
  2018. limit: 6,
  2019. layer: -1
  2020. }, {
  2021. id: 6,
  2022. name: "booster",
  2023. place: true,
  2024. limit: 12,
  2025. layer: -1
  2026. }, {
  2027. id: 7,
  2028. name: "turret",
  2029. place: true,
  2030. limit: 2,
  2031. layer: 1
  2032. }, {
  2033. id: 8,
  2034. name: "watchtower",
  2035. place: true,
  2036. limit: 12,
  2037. layer: 1
  2038. }, {
  2039. id: 9,
  2040. name: "buff",
  2041. place: true,
  2042. limit: 4,
  2043. layer: -1
  2044. }, {
  2045. id: 10,
  2046. name: "spawn",
  2047. place: true,
  2048. limit: 1,
  2049. layer: -1
  2050. }, {
  2051. id: 11,
  2052. name: "sapling",
  2053. place: true,
  2054. limit: 2,
  2055. layer: 0
  2056. }, {
  2057. id: 12,
  2058. name: "blocker",
  2059. place: true,
  2060. limit: 3,
  2061. layer: -1
  2062. }, {
  2063. id: 13,
  2064. name: "teleporter",
  2065. place: true,
  2066. limit: 2,
  2067. layer: -1
  2068. }];
  2069. // PROJECTILES:
  2070. this.projectiles = [{
  2071. indx: 0,
  2072. layer: 0,
  2073. src: "arrow_1",
  2074. dmg: 25,
  2075. speed: 1.6,
  2076. scale: 103,
  2077. range: 1000
  2078. }, {
  2079. indx: 1,
  2080. layer: 1,
  2081. dmg: 25,
  2082. scale: 20
  2083. }, {
  2084. indx: 0,
  2085. layer: 0,
  2086. src: "arrow_1",
  2087. dmg: 35,
  2088. speed: 2.5,
  2089. scale: 103,
  2090. range: 1200
  2091. }, {
  2092. indx: 0,
  2093. layer: 0,
  2094. src: "arrow_1",
  2095. dmg: 30,
  2096. speed: 2,
  2097. scale: 103,
  2098. range: 1200
  2099. }, {
  2100. indx: 1,
  2101. layer: 1,
  2102. dmg: 16,
  2103. scale: 20
  2104. }, {
  2105. indx: 0,
  2106. layer: 0,
  2107. src: "bullet_1",
  2108. dmg: 50,
  2109. speed: 3.6,
  2110. scale: 160,
  2111. range: 1400
  2112. }];
  2113. // WEAPONS:
  2114. this.weapons = [{
  2115. id: 0,
  2116. type: 0,
  2117. name: "tool hammer",
  2118. desc: "tool for gathering all resources",
  2119. src: "hammer_1",
  2120. length: 140,
  2121. width: 140,
  2122. xOff: -3,
  2123. yOff: 18,
  2124. dmg: 25,
  2125. range: 65,
  2126. gather: 1,
  2127. speed: 300
  2128. }, {
  2129. id: 1,
  2130. type: 0,
  2131. age: 2,
  2132. name: "hand axe",
  2133. desc: "gathers resources at a higher rate",
  2134. src: "axe_1",
  2135. length: 140,
  2136. width: 140,
  2137. xOff: 3,
  2138. yOff: 24,
  2139. dmg: 30,
  2140. spdMult: 1,
  2141. range: 70,
  2142. gather: 2,
  2143. speed: 400
  2144. }, {
  2145. id: 2,
  2146. type: 0,
  2147. age: 8,
  2148. pre: 1,
  2149. name: "great axe",
  2150. desc: "deal more damage and gather more resources",
  2151. src: "great_axe_1",
  2152. length: 140,
  2153. width: 140,
  2154. xOff: -8,
  2155. yOff: 25,
  2156. dmg: 35,
  2157. spdMult: 1,
  2158. range: 75,
  2159. gather: 4,
  2160. speed: 400
  2161. }, {
  2162. id: 3,
  2163. type: 0,
  2164. age: 2,
  2165. name: "short sword",
  2166. desc: "increased attack power but slower move speed",
  2167. src: "sword_1",
  2168. iPad: 1.3,
  2169. length: 130,
  2170. width: 210,
  2171. xOff: -8,
  2172. yOff: 46,
  2173. dmg: 35,
  2174. spdMult: 0.85,
  2175. range: 110,
  2176. gather: 1,
  2177. speed: 300
  2178. }, {
  2179. id: 4,
  2180. type: 0,
  2181. age: 8,
  2182. pre: 3,
  2183. name: "katana",
  2184. desc: "greater range and damage",
  2185. src: "samurai_1",
  2186. iPad: 1.3,
  2187. length: 130,
  2188. width: 210,
  2189. xOff: -8,
  2190. yOff: 59,
  2191. dmg: 40,
  2192. spdMult: 0.8,
  2193. range: 118,
  2194. gather: 1,
  2195. speed: 300
  2196. }, {
  2197. id: 5,
  2198. type: 0,
  2199. age: 2,
  2200. name: "polearm",
  2201. desc: "long range melee weapon",
  2202. src: "spear_1",
  2203. iPad: 1.3,
  2204. length: 130,
  2205. width: 210,
  2206. xOff: -8,
  2207. yOff: 53,
  2208. dmg: 45,
  2209. knock: 0.2,
  2210. spdMult: 0.82,
  2211. range: 142,
  2212. gather: 1,
  2213. speed: 700
  2214. }, {
  2215. id: 6,
  2216. type: 0,
  2217. age: 2,
  2218. name: "bat",
  2219. desc: "fast long range melee weapon",
  2220. src: "bat_1",
  2221. iPad: 1.3,
  2222. length: 110,
  2223. width: 180,
  2224. xOff: -8,
  2225. yOff: 53,
  2226. dmg: 20,
  2227. knock: 0.7,
  2228. range: 110,
  2229. gather: 1,
  2230. speed: 300
  2231. }, {
  2232. id: 7,
  2233. type: 0,
  2234. age: 2,
  2235. name: "daggers",
  2236. desc: "really fast short range weapon",
  2237. src: "dagger_1",
  2238. iPad: 0.8,
  2239. length: 110,
  2240. width: 110,
  2241. xOff: 18,
  2242. yOff: 0,
  2243. dmg: 20,
  2244. knock: 0.1,
  2245. range: 65,
  2246. gather: 1,
  2247. hitSlow: 0.1,
  2248. spdMult: 1.13,
  2249. speed: 100
  2250. }, {
  2251. id: 8,
  2252. type: 0,
  2253. age: 2,
  2254. name: "stick",
  2255. desc: "great for gathering but very weak",
  2256. src: "stick_1",
  2257. length: 140,
  2258. width: 140,
  2259. xOff: 3,
  2260. yOff: 24,
  2261. dmg: 1,
  2262. spdMult: 1,
  2263. range: 70,
  2264. gather: 7,
  2265. speed: 400
  2266. }, {
  2267. id: 9,
  2268. type: 1,
  2269. age: 6,
  2270. name: "hunting bow",
  2271. desc: "bow used for ranged combat and hunting",
  2272. src: "bow_1",
  2273. req: ["wood", 4],
  2274. length: 120,
  2275. width: 120,
  2276. xOff: -6,
  2277. yOff: 0,
  2278. Pdmg: 25,
  2279. projectile: 0,
  2280. spdMult: 0.75,
  2281. speed: 600
  2282. }, {
  2283. id: 10,
  2284. type: 1,
  2285. age: 6,
  2286. name: "great hammer",
  2287. desc: "hammer used for destroying structures",
  2288. src: "great_hammer_1",
  2289. length: 140,
  2290. width: 140,
  2291. xOff: -9,
  2292. yOff: 25,
  2293. dmg: 10,
  2294. Pdmg: 10,
  2295. spdMult: 0.88,
  2296. range: 75,
  2297. sDmg: 7.5,
  2298. gather: 1,
  2299. speed: 400
  2300. }, {
  2301. id: 11,
  2302. type: 1,
  2303. age: 6,
  2304. name: "wooden shield",
  2305. desc: "blocks projectiles and reduces melee damage",
  2306. src: "shield_1",
  2307. length: 120,
  2308. width: 120,
  2309. shield: 0.2,
  2310. xOff: 6,
  2311. yOff: 0,
  2312. Pdmg: 0,
  2313. spdMult: 0.7
  2314. }, {
  2315. id: 12,
  2316. type: 1,
  2317. age: 8,
  2318. pre: 9,
  2319. name: "crossbow",
  2320. desc: "deals more damage and has greater range",
  2321. src: "crossbow_1",
  2322. req: ["wood", 5],
  2323. aboveHand: true,
  2324. armS: 0.75,
  2325. length: 120,
  2326. width: 120,
  2327. xOff: -4,
  2328. yOff: 0,
  2329. Pdmg: 35,
  2330. projectile: 2,
  2331. spdMult: 0.7,
  2332. speed: 700
  2333. }, {
  2334. id: 13,
  2335. type: 1,
  2336. age: 9,
  2337. pre: 12,
  2338. name: "repeater crossbow",
  2339. desc: "high firerate crossbow with reduced damage",
  2340. src: "crossbow_2",
  2341. req: ["wood", 10],
  2342. aboveHand: true,
  2343. armS: 0.75,
  2344. length: 120,
  2345. width: 120,
  2346. xOff: -4,
  2347. yOff: 0,
  2348. Pdmg: 30,
  2349. projectile: 3,
  2350. spdMult: 0.7,
  2351. speed: 230
  2352. }, {
  2353. id: 14,
  2354. type: 1,
  2355. age: 6,
  2356. name: "mc grabby",
  2357. desc: "steals resources from enemies",
  2358. src: "grab_1",
  2359. length: 130,
  2360. width: 210,
  2361. xOff: -8,
  2362. yOff: 53,
  2363. dmg: 0,
  2364. Pdmg: 0,
  2365. steal: 250,
  2366. knock: 0.2,
  2367. spdMult: 1.05,
  2368. range: 125,
  2369. gather: 0,
  2370. speed: 700
  2371. }, {
  2372. id: 15,
  2373. type: 1,
  2374. age: 9,
  2375. pre: 12,
  2376. name: "musket",
  2377. desc: "slow firerate but high damage and range",
  2378. src: "musket_1",
  2379. req: ["stone", 10],
  2380. aboveHand: true,
  2381. rec: 0.35,
  2382. armS: 0.6,
  2383. hndS: 0.3,
  2384. hndD: 1.6,
  2385. length: 205,
  2386. width: 205,
  2387. xOff: 25,
  2388. yOff: 0,
  2389. Pdmg: 50,
  2390. projectile: 5,
  2391. hideProjectile: true,
  2392. spdMult: 0.6,
  2393. speed: 1500
  2394. }];
  2395. // ITEMS:
  2396. this.list = [{
  2397. group: this.groups[0],
  2398. name: "apple",
  2399. desc: "restores 20 health when consumed",
  2400. req: ["food", 10],
  2401. consume: function(doer) {
  2402. return doer.changeHealth(20, doer);
  2403. },
  2404. scale: 22,
  2405. holdOffset: 15,
  2406. healing: 20,
  2407. itemID: 0,
  2408. itemAID: 16,
  2409. }, {
  2410. age: 3,
  2411. group: this.groups[0],
  2412. name: "cookie",
  2413. desc: "restores 40 health when consumed",
  2414. req: ["food", 15],
  2415. consume: function(doer) {
  2416. return doer.changeHealth(40, doer);
  2417. },
  2418. scale: 27,
  2419. holdOffset: 15,
  2420. healing: 40,
  2421. itemID: 1,
  2422. itemAID: 17,
  2423. }, {
  2424. age: 7,
  2425. group: this.groups[0],
  2426. name: "cheese",
  2427. desc: "restores 30 health and another 50 over 5 seconds",
  2428. req: ["food", 25],
  2429. consume: function(doer) {
  2430. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2431. doer.dmgOverTime.dmg = -10;
  2432. doer.dmgOverTime.doer = doer;
  2433. doer.dmgOverTime.time = 5;
  2434. return true;
  2435. }
  2436. return false;
  2437. },
  2438. scale: 27,
  2439. holdOffset: 15,
  2440. healing: 30,
  2441. itemID: 2,
  2442. itemAID: 18,
  2443. }, {
  2444. group: this.groups[1],
  2445. name: "wood wall",
  2446. desc: "provides protection for your village",
  2447. req: ["wood", 10],
  2448. projDmg: true,
  2449. health: 380,
  2450. scale: 50,
  2451. holdOffset: 20,
  2452. placeOffset: -5,
  2453. itemID: 3,
  2454. itemAID: 19,
  2455. }, {
  2456. age: 3,
  2457. group: this.groups[1],
  2458. name: "stone wall",
  2459. desc: "provides improved protection for your village",
  2460. req: ["stone", 25],
  2461. health: 900,
  2462. scale: 50,
  2463. holdOffset: 20,
  2464. placeOffset: -5,
  2465. itemID: 4,
  2466. itemAID: 20,
  2467. }, {
  2468. age: 7,
  2469. group: this.groups[1],
  2470. name: "castle wall",
  2471. desc: "provides powerful protection for your village",
  2472. req: ["stone", 35],
  2473. health: 1500,
  2474. scale: 52,
  2475. holdOffset: 20,
  2476. placeOffset: -5,
  2477. itemID: 5,
  2478. itemAID: 21,
  2479. }, {
  2480. group: this.groups[2],
  2481. name: "spikes",
  2482. desc: "damages enemies when they touch them",
  2483. req: ["wood", 20, "stone", 5],
  2484. health: 400,
  2485. dmg: 20,
  2486. scale: 49,
  2487. spritePadding: -23,
  2488. holdOffset: 8,
  2489. placeOffset: -5,
  2490. itemID: 6,
  2491. itemAID: 22,
  2492. }, {
  2493. age: 5,
  2494. group: this.groups[2],
  2495. name: "greater spikes",
  2496. desc: "damages enemies when they touch them",
  2497. req: ["wood", 30, "stone", 10],
  2498. health: 500,
  2499. dmg: 35,
  2500. scale: 52,
  2501. spritePadding: -23,
  2502. holdOffset: 8,
  2503. placeOffset: -5,
  2504. itemID: 7,
  2505. itemAID: 23,
  2506. }, {
  2507. age: 9,
  2508. group: this.groups[2],
  2509. name: "poison spikes",
  2510. desc: "poisons enemies when they touch them",
  2511. req: ["wood", 35, "stone", 15],
  2512. health: 600,
  2513. dmg: 30,
  2514. pDmg: 5,
  2515. scale: 52,
  2516. spritePadding: -23,
  2517. holdOffset: 8,
  2518. placeOffset: -5,
  2519. itemID: 8,
  2520. itemAID: 24,
  2521. }, {
  2522. age: 9,
  2523. group: this.groups[2],
  2524. name: "spinning spikes",
  2525. desc: "damages enemies when they touch them",
  2526. req: ["wood", 30, "stone", 20],
  2527. health: 500,
  2528. dmg: 45,
  2529. turnSpeed: 0.003,
  2530. scale: 52,
  2531. spritePadding: -23,
  2532. holdOffset: 8,
  2533. placeOffset: -5,
  2534. itemID: 9,
  2535. itemAID: 25,
  2536. }, {
  2537. group: this.groups[3],
  2538. name: "windmill",
  2539. desc: "generates gold over time",
  2540. req: ["wood", 50, "stone", 10],
  2541. health: 400,
  2542. pps: 1,
  2543. turnSpeed: 0.0016,
  2544. spritePadding: 25,
  2545. iconLineMult: 12,
  2546. scale: 45,
  2547. holdOffset: 20,
  2548. placeOffset: 5,
  2549. itemID: 10,
  2550. itemAID: 26,
  2551. }, {
  2552. age: 5,
  2553. group: this.groups[3],
  2554. name: "faster windmill",
  2555. desc: "generates more gold over time",
  2556. req: ["wood", 60, "stone", 20],
  2557. health: 500,
  2558. pps: 1.5,
  2559. turnSpeed: 0.0025,
  2560. spritePadding: 25,
  2561. iconLineMult: 12,
  2562. scale: 47,
  2563. holdOffset: 20,
  2564. placeOffset: 5,
  2565. itemID: 11,
  2566. itemAID: 27,
  2567. }, {
  2568. age: 8,
  2569. group: this.groups[3],
  2570. name: "power mill",
  2571. desc: "generates more gold over time",
  2572. req: ["wood", 100, "stone", 50],
  2573. health: 800,
  2574. pps: 2,
  2575. turnSpeed: 0.005,
  2576. spritePadding: 25,
  2577. iconLineMult: 12,
  2578. scale: 47,
  2579. holdOffset: 20,
  2580. placeOffset: 5,
  2581. itemID: 12,
  2582. itemAID: 28,
  2583. }, {
  2584. age: 5,
  2585. group: this.groups[4],
  2586. type: 2,
  2587. name: "mine",
  2588. desc: "allows you to mine stone",
  2589. req: ["wood", 20, "stone", 100],
  2590. iconLineMult: 12,
  2591. scale: 65,
  2592. holdOffset: 20,
  2593. placeOffset: 0,
  2594. itemID: 13,
  2595. itemAID: 29,
  2596. }, {
  2597. age: 5,
  2598. group: this.groups[11],
  2599. type: 0,
  2600. name: "sapling",
  2601. desc: "allows you to farm wood",
  2602. req: ["wood", 150],
  2603. iconLineMult: 12,
  2604. colDiv: 0.5,
  2605. scale: 110,
  2606. holdOffset: 50,
  2607. placeOffset: -15,
  2608. itemID: 14,
  2609. itemAID: 30,
  2610. }, {
  2611. age: 4,
  2612. group: this.groups[5],
  2613. name: "pit trap",
  2614. desc: "pit that traps enemies if they walk over it",
  2615. req: ["wood", 30, "stone", 30],
  2616. trap: true,
  2617. ignoreCollision: true,
  2618. hideFromEnemy: true,
  2619. health: 500,
  2620. colDiv: 0.2,
  2621. scale: 50,
  2622. holdOffset: 20,
  2623. placeOffset: -5,
  2624. alpha: 0.6,
  2625. itemID: 15,
  2626. itemAID: 31,
  2627. }, {
  2628. age: 4,
  2629. group: this.groups[6],
  2630. name: "boost pad",
  2631. desc: "provides boost when stepped on",
  2632. req: ["stone", 20, "wood", 5],
  2633. ignoreCollision: true,
  2634. boostSpeed: 1.5,
  2635. health: 150,
  2636. colDiv: 0.7,
  2637. scale: 45,
  2638. holdOffset: 20,
  2639. placeOffset: -5,
  2640. itemID: 16,
  2641. itemAID: 32,
  2642. }, {
  2643. age: 7,
  2644. group: this.groups[7],
  2645. doUpdate: true,
  2646. name: "turret",
  2647. desc: "defensive structure that shoots at enemies",
  2648. req: ["wood", 200, "stone", 150],
  2649. health: 800,
  2650. projectile: 1,
  2651. shootRange: 700,
  2652. shootRate: 2200,
  2653. scale: 43,
  2654. holdOffset: 20,
  2655. placeOffset: -5,
  2656. itemID: 17,
  2657. itemAID: 33,
  2658. }, {
  2659. age: 7,
  2660. group: this.groups[8],
  2661. name: "platform",
  2662. desc: "platform to shoot over walls and cross over water",
  2663. req: ["wood", 20],
  2664. ignoreCollision: true,
  2665. zIndex: 1,
  2666. health: 300,
  2667. scale: 43,
  2668. holdOffset: 20,
  2669. placeOffset: -5,
  2670. itemID: 18,
  2671. itemAID: 34,
  2672. }, {
  2673. age: 7,
  2674. group: this.groups[9],
  2675. name: "healing pad",
  2676. desc: "standing on it will slowly heal you",
  2677. req: ["wood", 30, "food", 10],
  2678. ignoreCollision: true,
  2679. healCol: 15,
  2680. health: 400,
  2681. colDiv: 0.7,
  2682. scale: 45,
  2683. holdOffset: 20,
  2684. placeOffset: -5,
  2685. itemID: 19,
  2686. itemAID: 35,
  2687. }, {
  2688. age: 9,
  2689. group: this.groups[10],
  2690. name: "spawn pad",
  2691. desc: "you will spawn here when you die but it will dissapear",
  2692. req: ["wood", 100, "stone", 100],
  2693. health: 400,
  2694. ignoreCollision: true,
  2695. spawnPoint: true,
  2696. scale: 45,
  2697. holdOffset: 20,
  2698. placeOffset: -5,
  2699. itemID: 20,
  2700. itemAID: 36,
  2701. }, {
  2702. age: 7,
  2703. group: this.groups[12],
  2704. name: "blocker",
  2705. desc: "blocks building in radius",
  2706. req: ["wood", 30, "stone", 25],
  2707. ignoreCollision: true,
  2708. blocker: 300,
  2709. health: 400,
  2710. colDiv: 0.7,
  2711. scale: 45,
  2712. holdOffset: 20,
  2713. placeOffset: -5,
  2714. itemID: 21,
  2715. itemAID: 37,
  2716. }, {
  2717. age: 7,
  2718. group: this.groups[13],
  2719. name: "teleporter",
  2720. desc: "teleports you to a random point on the map",
  2721. req: ["wood", 60, "stone", 60],
  2722. ignoreCollision: true,
  2723. teleport: true,
  2724. health: 200,
  2725. colDiv: 0.7,
  2726. scale: 45,
  2727. holdOffset: 20,
  2728. placeOffset: -5,
  2729. itemID: 22,
  2730. itemAID: 38
  2731. }];
  2732. // CHECK ITEM ID:
  2733. this.checkItem = {
  2734. index: function(id, myItems) {
  2735. return [0, 1, 2].includes(id) ? 0 :
  2736. [3, 4, 5].includes(id) ? 1 :
  2737. [6, 7, 8, 9].includes(id) ? 2 :
  2738. [10, 11, 12].includes(id) ? 3 :
  2739. [13, 14].includes(id) ? 5 :
  2740. [15, 16].includes(id) ? 4 :
  2741. [17, 18, 19, 21, 22].includes(id) ?
  2742. [13, 14].includes(myItems) ? 6 :
  2743. 5 :
  2744. id == 20 ?
  2745. [13, 14].includes(myItems) ? 7 :
  2746. 6 :
  2747. undefined;
  2748. }
  2749. }
  2750. // ASSIGN IDS:
  2751. for (let i = 0; i < this.list.length; ++i) {
  2752. this.list[i].id = i;
  2753. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2754. }
  2755. // TROLOLOLOL:
  2756. if (typeof window !== "undefined") {
  2757. function shuffle(a) {
  2758. for (let i = a.length - 1; i > 0; i--) {
  2759. const j = Math.floor(Math.random() * (i + 1));
  2760. [a[i], a[j]] = [a[j], a[i]];
  2761. }
  2762. return a;
  2763. }
  2764. //shuffle(this.list);
  2765. }
  2766. }
  2767. }
  2768. class Objectmanager {
  2769. constructor(GameObject, gameObjects, UTILS, config, players, server) {
  2770. let mathFloor = Math.floor,
  2771. mathABS = Math.abs,
  2772. mathCOS = Math.cos,
  2773. mathSIN = Math.sin,
  2774. mathPOW = Math.pow,
  2775. mathSQRT = Math.sqrt;
  2776. this.ignoreAdd = false;
  2777. this.hitObj = [];
  2778. // DISABLE OBJ:
  2779. this.disableObj = function(obj) {
  2780. obj.active = false;
  2781. obj.alive = false;
  2782. };
  2783. // ADD NEW:
  2784. let tmpObj;
  2785. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2786. tmpObj = findObjectBySid(sid);
  2787. if (!tmpObj) {
  2788. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2789. if (!tmpObj) {
  2790. tmpObj = new GameObject(sid);
  2791. gameObjects.push(tmpObj);
  2792. }
  2793. }
  2794. if (setSID) {
  2795. tmpObj.sid = sid;
  2796. }
  2797. tmpObj.init(x, y, dir, s, type, data, owner);
  2798. };
  2799. // DISABLE BY SID:
  2800. this.disableBySid = function(sid) {
  2801. let find = findObjectBySid(sid);
  2802. if (find) {
  2803. this.disableObj(find);
  2804. }
  2805. };
  2806. // REMOVE ALL FROM PLAYER:
  2807. this.removeAllItems = function(sid, server) {
  2808. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2809. };
  2810. // CHECK IF PLACABLE:
  2811. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2812. 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)));
  2813. if (cantPlace) return false;
  2814. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2815. return true;
  2816. };
  2817. }
  2818. }
  2819. class Projectile {
  2820. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2821. // INIT:
  2822. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2823. this.active = true;
  2824. this.tickActive = true;
  2825. this.indx = indx;
  2826. this.x = x;
  2827. this.y = y;
  2828. this.x2 = x;
  2829. this.y2 = y;
  2830. this.dir = dir;
  2831. this.skipMov = true;
  2832. this.speed = spd;
  2833. this.dmg = dmg;
  2834. this.scale = scl;
  2835. this.range = rng;
  2836. this.r2 = rng;
  2837. this.owner = owner;
  2838. };
  2839. // UPDATE:
  2840. this.update = function(delta) {
  2841. if (this.active) {
  2842. let tmpSpeed = this.speed * delta;
  2843. if (!this.skipMov) {
  2844. this.x += tmpSpeed * Math.cos(this.dir);
  2845. this.y += tmpSpeed * Math.sin(this.dir);
  2846. this.range -= tmpSpeed;
  2847. if (this.range <= 0) {
  2848. this.x += this.range * Math.cos(this.dir);
  2849. this.y += this.range * Math.sin(this.dir);
  2850. tmpSpeed = 1;
  2851. this.range = 0;
  2852. this.active = false;
  2853. }
  2854. } else {
  2855. this.skipMov = false;
  2856. }
  2857. }
  2858. };
  2859. this.tickUpdate = function(delta) {
  2860. if (this.tickActive) {
  2861. let tmpSpeed = this.speed * delta;
  2862. if (!this.skipMov) {
  2863. this.x2 += tmpSpeed * Math.cos(this.dir);
  2864. this.y2 += tmpSpeed * Math.sin(this.dir);
  2865. this.r2 -= tmpSpeed;
  2866. if (this.r2 <= 0) {
  2867. this.x2 += this.r2 * Math.cos(this.dir);
  2868. this.y2 += this.r2 * Math.sin(this.dir);
  2869. tmpSpeed = 1;
  2870. this.r2 = 0;
  2871. this.tickActive = false;
  2872. }
  2873. } else {
  2874. this.skipMov = false;
  2875. }
  2876. }
  2877. };
  2878. }
  2879. };
  2880. class Store {
  2881. constructor() {
  2882. // STORE HATS:
  2883. this.hats = [{
  2884. id: 45,
  2885. name: "Shame!",
  2886. dontSell: true,
  2887. price: 0,
  2888. scale: 120,
  2889. desc: "hacks are for winners"
  2890. }, {
  2891. id: 51,
  2892. name: "Moo Cap",
  2893. price: 0,
  2894. scale: 120,
  2895. desc: "coolest mooer around"
  2896. }, {
  2897. id: 50,
  2898. name: "Apple Cap",
  2899. price: 0,
  2900. scale: 120,
  2901. desc: "apple farms remembers"
  2902. }, {
  2903. id: 28,
  2904. name: "Moo Head",
  2905. price: 0,
  2906. scale: 120,
  2907. desc: "no effect"
  2908. }, {
  2909. id: 29,
  2910. name: "Pig Head",
  2911. price: 0,
  2912. scale: 120,
  2913. desc: "no effect"
  2914. }, {
  2915. id: 30,
  2916. name: "Fluff Head",
  2917. price: 0,
  2918. scale: 120,
  2919. desc: "no effect"
  2920. }, {
  2921. id: 36,
  2922. name: "Pandou Head",
  2923. price: 0,
  2924. scale: 120,
  2925. desc: "no effect"
  2926. }, {
  2927. id: 37,
  2928. name: "Bear Head",
  2929. price: 0,
  2930. scale: 120,
  2931. desc: "no effect"
  2932. }, {
  2933. id: 38,
  2934. name: "Monkey Head",
  2935. price: 0,
  2936. scale: 120,
  2937. desc: "no effect"
  2938. }, {
  2939. id: 44,
  2940. name: "Polar Head",
  2941. price: 0,
  2942. scale: 120,
  2943. desc: "no effect"
  2944. }, {
  2945. id: 35,
  2946. name: "Fez Hat",
  2947. price: 0,
  2948. scale: 120,
  2949. desc: "no effect"
  2950. }, {
  2951. id: 42,
  2952. name: "Enigma Hat",
  2953. price: 0,
  2954. scale: 120,
  2955. desc: "join the enigma army"
  2956. }, {
  2957. id: 43,
  2958. name: "Blitz Hat",
  2959. price: 0,
  2960. scale: 120,
  2961. desc: "hey everybody i'm blitz"
  2962. }, {
  2963. id: 49,
  2964. name: "Bob XIII Hat",
  2965. price: 0,
  2966. scale: 120,
  2967. desc: "like and subscribe"
  2968. }, {
  2969. id: 57,
  2970. name: "Pumpkin",
  2971. price: 50,
  2972. scale: 120,
  2973. desc: "Spooooky"
  2974. }, {
  2975. id: 8,
  2976. name: "Bummle Hat",
  2977. price: 100,
  2978. scale: 120,
  2979. desc: "no effect"
  2980. }, {
  2981. id: 2,
  2982. name: "Straw Hat",
  2983. price: 500,
  2984. scale: 120,
  2985. desc: "no effect"
  2986. }, {
  2987. id: 15,
  2988. name: "Winter Cap",
  2989. price: 600,
  2990. scale: 120,
  2991. desc: "allows you to move at normal speed in snow",
  2992. coldM: 1
  2993. }, {
  2994. id: 5,
  2995. name: "Cowboy Hat",
  2996. price: 1000,
  2997. scale: 120,
  2998. desc: "no effect"
  2999. }, {
  3000. id: 4,
  3001. name: "Ranger Hat",
  3002. price: 2000,
  3003. scale: 120,
  3004. desc: "no effect"
  3005. }, {
  3006. id: 18,
  3007. name: "Explorer Hat",
  3008. price: 2000,
  3009. scale: 120,
  3010. desc: "no effect"
  3011. }, {
  3012. id: 31,
  3013. name: "Flipper Hat",
  3014. price: 2500,
  3015. scale: 120,
  3016. desc: "have more control while in water",
  3017. watrImm: true
  3018. }, {
  3019. id: 1,
  3020. name: "Marksman Cap",
  3021. price: 3000,
  3022. scale: 120,
  3023. desc: "increases arrow speed and range",
  3024. aMlt: 1.3
  3025. }, {
  3026. id: 10,
  3027. name: "Bush Gear",
  3028. price: 3000,
  3029. scale: 160,
  3030. desc: "allows you to disguise yourself as a bush"
  3031. }, {
  3032. id: 48,
  3033. name: "Halo",
  3034. price: 3000,
  3035. scale: 120,
  3036. desc: "no effect"
  3037. }, {
  3038. id: 6,
  3039. name: "Soldier Helmet",
  3040. price: 4000,
  3041. scale: 120,
  3042. desc: "reduces damage taken but slows movement",
  3043. spdMult: 0.94,
  3044. dmgMult: 0.75
  3045. }, {
  3046. id: 23,
  3047. name: "Anti Venom Gear",
  3048. price: 4000,
  3049. scale: 120,
  3050. desc: "makes you immune to poison",
  3051. poisonRes: 1
  3052. }, {
  3053. id: 13,
  3054. name: "Medic Gear",
  3055. price: 5000,
  3056. scale: 110,
  3057. desc: "slowly regenerates health over time",
  3058. healthRegen: 3
  3059. }, {
  3060. id: 9,
  3061. name: "Miners Helmet",
  3062. price: 5000,
  3063. scale: 120,
  3064. desc: "earn 1 extra gold per resource",
  3065. extraGold: 1
  3066. }, {
  3067. id: 32,
  3068. name: "Musketeer Hat",
  3069. price: 5000,
  3070. scale: 120,
  3071. desc: "reduces cost of projectiles",
  3072. projCost: 0.5
  3073. }, {
  3074. id: 7,
  3075. name: "Bull Helmet",
  3076. price: 6000,
  3077. scale: 120,
  3078. desc: "increases damage done but drains health",
  3079. healthRegen: -5,
  3080. dmgMultO: 1.5,
  3081. spdMult: 0.96
  3082. }, {
  3083. id: 22,
  3084. name: "Emp Helmet",
  3085. price: 6000,
  3086. scale: 120,
  3087. desc: "turrets won't attack but you move slower",
  3088. antiTurret: 1,
  3089. spdMult: 0.7
  3090. }, {
  3091. id: 12,
  3092. name: "Booster Hat",
  3093. price: 6000,
  3094. scale: 120,
  3095. desc: "increases your movement speed",
  3096. spdMult: 1.16
  3097. }, {
  3098. id: 26,
  3099. name: "Barbarian Armor",
  3100. price: 8000,
  3101. scale: 120,
  3102. desc: "knocks back enemies that attack you",
  3103. dmgK: 0.6
  3104. }, {
  3105. id: 21,
  3106. name: "Plague Mask",
  3107. price: 10000,
  3108. scale: 120,
  3109. desc: "melee attacks deal poison damage",
  3110. poisonDmg: 5,
  3111. poisonTime: 6
  3112. }, {
  3113. id: 46,
  3114. name: "Bull Mask",
  3115. price: 10000,
  3116. scale: 120,
  3117. desc: "bulls won't target you unless you attack them",
  3118. bullRepel: 1
  3119. }, {
  3120. id: 14,
  3121. name: "Windmill Hat",
  3122. topSprite: true,
  3123. price: 10000,
  3124. scale: 120,
  3125. desc: "generates points while worn",
  3126. pps: 1.5
  3127. }, {
  3128. id: 11,
  3129. name: "Spike Gear",
  3130. topSprite: true,
  3131. price: 10000,
  3132. scale: 120,
  3133. desc: "deal damage to players that damage you",
  3134. dmg: 0.45
  3135. }, {
  3136. id: 53,
  3137. name: "Turret Gear",
  3138. topSprite: true,
  3139. price: 10000,
  3140. scale: 120,
  3141. desc: "you become a walking turret",
  3142. turret: {
  3143. proj: 1,
  3144. range: 700,
  3145. rate: 2500
  3146. },
  3147. spdMult: 0.7
  3148. }, {
  3149. id: 20,
  3150. name: "Samurai Armor",
  3151. price: 12000,
  3152. scale: 120,
  3153. desc: "increased attack speed and fire rate",
  3154. atkSpd: 0.78
  3155. }, {
  3156. id: 58,
  3157. name: "Dark Knight",
  3158. price: 12000,
  3159. scale: 120,
  3160. desc: "restores health when you deal damage",
  3161. healD: 0.4
  3162. }, {
  3163. id: 27,
  3164. name: "Scavenger Gear",
  3165. price: 15000,
  3166. scale: 120,
  3167. desc: "earn double points for each kill",
  3168. kScrM: 2
  3169. }, {
  3170. id: 40,
  3171. name: "Tank Gear",
  3172. price: 15000,
  3173. scale: 120,
  3174. desc: "increased damage to buildings but slower movement",
  3175. spdMult: 0.3,
  3176. bDmg: 3.3
  3177. }, {
  3178. id: 52,
  3179. name: "Thief Gear",
  3180. price: 15000,
  3181. scale: 120,
  3182. desc: "steal half of a players gold when you kill them",
  3183. goldSteal: 0.5
  3184. }, {
  3185. id: 55,
  3186. name: "Bloodthirster",
  3187. price: 20000,
  3188. scale: 120,
  3189. desc: "Restore Health when dealing damage. And increased damage",
  3190. healD: 0.25,
  3191. dmgMultO: 1.2,
  3192. }, {
  3193. id: 56,
  3194. name: "Assassin Gear",
  3195. price: 20000,
  3196. scale: 120,
  3197. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3198. noEat: true,
  3199. spdMult: 1.1,
  3200. invisTimer: 1000
  3201. }];
  3202. // STORE ACCESSORIES:
  3203. this.accessories = [{
  3204. id: 12,
  3205. name: "Snowball",
  3206. price: 1000,
  3207. scale: 105,
  3208. xOff: 18,
  3209. desc: "no effect"
  3210. }, {
  3211. id: 9,
  3212. name: "Tree Cape",
  3213. price: 1000,
  3214. scale: 90,
  3215. desc: "no effect"
  3216. }, {
  3217. id: 10,
  3218. name: "Stone Cape",
  3219. price: 1000,
  3220. scale: 90,
  3221. desc: "no effect"
  3222. }, {
  3223. id: 3,
  3224. name: "Cookie Cape",
  3225. price: 1500,
  3226. scale: 90,
  3227. desc: "no effect"
  3228. }, {
  3229. id: 8,
  3230. name: "Cow Cape",
  3231. price: 2000,
  3232. scale: 90,
  3233. desc: "no effect"
  3234. }, {
  3235. id: 11,
  3236. name: "Monkey Tail",
  3237. price: 2000,
  3238. scale: 97,
  3239. xOff: 25,
  3240. desc: "Super speed but reduced damage",
  3241. spdMult: 1.35,
  3242. dmgMultO: 0.2
  3243. }, {
  3244. id: 17,
  3245. name: "Apple Basket",
  3246. price: 3000,
  3247. scale: 80,
  3248. xOff: 12,
  3249. desc: "slowly regenerates health over time",
  3250. healthRegen: 1
  3251. }, {
  3252. id: 6,
  3253. name: "Winter Cape",
  3254. price: 3000,
  3255. scale: 90,
  3256. desc: "no effect"
  3257. }, {
  3258. id: 4,
  3259. name: "Skull Cape",
  3260. price: 4000,
  3261. scale: 90,
  3262. desc: "no effect"
  3263. }, {
  3264. id: 5,
  3265. name: "Dash Cape",
  3266. price: 5000,
  3267. scale: 90,
  3268. desc: "no effect"
  3269. }, {
  3270. id: 2,
  3271. name: "Dragon Cape",
  3272. price: 6000,
  3273. scale: 90,
  3274. desc: "no effect"
  3275. }, {
  3276. id: 1,
  3277. name: "Super Cape",
  3278. price: 8000,
  3279. scale: 90,
  3280. desc: "no effect"
  3281. }, {
  3282. id: 7,
  3283. name: "Troll Cape",
  3284. price: 8000,
  3285. scale: 90,
  3286. desc: "no effect"
  3287. }, {
  3288. id: 14,
  3289. name: "Thorns",
  3290. price: 10000,
  3291. scale: 115,
  3292. xOff: 20,
  3293. desc: "no effect"
  3294. }, {
  3295. id: 15,
  3296. name: "Blockades",
  3297. price: 10000,
  3298. scale: 95,
  3299. xOff: 15,
  3300. desc: "no effect"
  3301. }, {
  3302. id: 20,
  3303. name: "Devils Tail",
  3304. price: 10000,
  3305. scale: 95,
  3306. xOff: 20,
  3307. desc: "no effect"
  3308. }, {
  3309. id: 16,
  3310. name: "Sawblade",
  3311. price: 12000,
  3312. scale: 90,
  3313. spin: true,
  3314. xOff: 0,
  3315. desc: "deal damage to players that damage you",
  3316. dmg: 0.15
  3317. }, {
  3318. id: 13,
  3319. name: "Angel Wings",
  3320. price: 15000,
  3321. scale: 138,
  3322. xOff: 22,
  3323. desc: "slowly regenerates health over time",
  3324. healthRegen: 3
  3325. }, {
  3326. id: 19,
  3327. name: "Shadow Wings",
  3328. price: 15000,
  3329. scale: 138,
  3330. xOff: 22,
  3331. desc: "increased movement speed",
  3332. spdMult: 1.1
  3333. }, {
  3334. id: 18,
  3335. name: "Blood Wings",
  3336. price: 20000,
  3337. scale: 178,
  3338. xOff: 26,
  3339. desc: "restores health when you deal damage",
  3340. healD: 0.2
  3341. }, {
  3342. id: 21,
  3343. name: "Corrupt X Wings",
  3344. price: 20000,
  3345. scale: 178,
  3346. xOff: 26,
  3347. desc: "deal damage to players that damage you",
  3348. dmg: 0.25
  3349. }];
  3350. }
  3351. };
  3352. class ProjectileManager {
  3353. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3354. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3355. let tmpData = items.projectiles[indx];
  3356. let tmpProj;
  3357. for (let i = 0; i < projectiles.length; ++i) {
  3358. if (!projectiles[i].active) {
  3359. tmpProj = projectiles[i];
  3360. break;
  3361. }
  3362. }
  3363. if (!tmpProj) {
  3364. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3365. tmpProj.sid = projectiles.length;
  3366. projectiles.push(tmpProj);
  3367. }
  3368. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3369. tmpProj.ignoreObj = ignoreObj;
  3370. tmpProj.layer = layer || tmpData.layer;
  3371. tmpProj.inWindow = inWindow;
  3372. tmpProj.src = tmpData.src;
  3373. return tmpProj;
  3374. };
  3375. }
  3376. };
  3377. class AiManager {
  3378. // AI MANAGER:
  3379. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3380. // AI TYPES:
  3381. this.aiTypes = [{
  3382. id: 0,
  3383. src: "cow_1",
  3384. killScore: 150,
  3385. health: 500,
  3386. weightM: 0.8,
  3387. speed: 0.00095,
  3388. turnSpeed: 0.001,
  3389. scale: 72,
  3390. drop: ["food", 50]
  3391. }, {
  3392. id: 1,
  3393. src: "pig_1",
  3394. killScore: 200,
  3395. health: 800,
  3396. weightM: 0.6,
  3397. speed: 0.00085,
  3398. turnSpeed: 0.001,
  3399. scale: 72,
  3400. drop: ["food", 80]
  3401. }, {
  3402. id: 2,
  3403. name: "Bull",
  3404. src: "bull_2",
  3405. hostile: true,
  3406. dmg: 20,
  3407. killScore: 1000,
  3408. health: 1800,
  3409. weightM: 0.5,
  3410. speed: 0.00094,
  3411. turnSpeed: 0.00074,
  3412. scale: 78,
  3413. viewRange: 800,
  3414. chargePlayer: true,
  3415. drop: ["food", 100]
  3416. }, {
  3417. id: 3,
  3418. name: "Bully",
  3419. src: "bull_1",
  3420. hostile: true,
  3421. dmg: 20,
  3422. killScore: 2000,
  3423. health: 2800,
  3424. weightM: 0.45,
  3425. speed: 0.001,
  3426. turnSpeed: 0.0008,
  3427. scale: 90,
  3428. viewRange: 900,
  3429. chargePlayer: true,
  3430. drop: ["food", 400]
  3431. }, {
  3432. id: 4,
  3433. name: "Wolf",
  3434. src: "wolf_1",
  3435. hostile: true,
  3436. dmg: 8,
  3437. killScore: 500,
  3438. health: 300,
  3439. weightM: 0.45,
  3440. speed: 0.001,
  3441. turnSpeed: 0.002,
  3442. scale: 84,
  3443. viewRange: 800,
  3444. chargePlayer: true,
  3445. drop: ["food", 200]
  3446. }, {
  3447. id: 5,
  3448. name: "Quack",
  3449. src: "chicken_1",
  3450. dmg: 8,
  3451. killScore: 2000,
  3452. noTrap: true,
  3453. health: 300,
  3454. weightM: 0.2,
  3455. speed: 0.0018,
  3456. turnSpeed: 0.006,
  3457. scale: 70,
  3458. drop: ["food", 100]
  3459. }, {
  3460. id: 6,
  3461. name: "MOOSTAFA",
  3462. nameScale: 50,
  3463. src: "enemy",
  3464. hostile: true,
  3465. dontRun: true,
  3466. fixedSpawn: true,
  3467. spawnDelay: 60000,
  3468. noTrap: true,
  3469. colDmg: 100,
  3470. dmg: 40,
  3471. killScore: 8000,
  3472. health: 18000,
  3473. weightM: 0.4,
  3474. speed: 0.0007,
  3475. turnSpeed: 0.01,
  3476. scale: 80,
  3477. spriteMlt: 1.8,
  3478. leapForce: 0.9,
  3479. viewRange: 1000,
  3480. hitRange: 210,
  3481. hitDelay: 1000,
  3482. chargePlayer: true,
  3483. drop: ["food", 100]
  3484. }, {
  3485. id: 7,
  3486. name: "Treasure",
  3487. hostile: true,
  3488. nameScale: 35,
  3489. src: "crate_1",
  3490. fixedSpawn: true,
  3491. spawnDelay: 120000,
  3492. colDmg: 200,
  3493. killScore: 5000,
  3494. health: 20000,
  3495. weightM: 0.1,
  3496. speed: 0.0,
  3497. turnSpeed: 0.0,
  3498. scale: 70,
  3499. spriteMlt: 1.0
  3500. }, {
  3501. id: 8,
  3502. name: "MOOFIE",
  3503. src: "wolf_2",
  3504. hostile: true,
  3505. fixedSpawn: true,
  3506. dontRun: true,
  3507. hitScare: 4,
  3508. spawnDelay: 30000,
  3509. noTrap: true,
  3510. nameScale: 35,
  3511. dmg: 10,
  3512. colDmg: 100,
  3513. killScore: 3000,
  3514. health: 7000,
  3515. weightM: 0.45,
  3516. speed: 0.0015,
  3517. turnSpeed: 0.002,
  3518. scale: 90,
  3519. viewRange: 800,
  3520. chargePlayer: true,
  3521. drop: ["food", 1000]
  3522. }];
  3523. // SPAWN AI:
  3524. this.spawn = function(x, y, dir, index) {
  3525. let tmpObj = ais.find((tmp) => !tmp.active);
  3526. if (!tmpObj) {
  3527. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3528. ais.push(tmpObj);
  3529. }
  3530. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3531. return tmpObj;
  3532. };
  3533. }
  3534. };
  3535. class AI {
  3536. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3537. this.sid = sid;
  3538. this.isAI = true;
  3539. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3540. // INIT:
  3541. this.init = function(x, y, dir, index, data) {
  3542. this.x = x;
  3543. this.y = y;
  3544. this.startX = data.fixedSpawn ? x : null;
  3545. this.startY = data.fixedSpawn ? y : null;
  3546. this.xVel = 0;
  3547. this.yVel = 0;
  3548. this.zIndex = 0;
  3549. this.dir = dir;
  3550. this.dirPlus = 0;
  3551. this.index = index;
  3552. this.src = data.src;
  3553. if (data.name) this.name = data.name;
  3554. this.weightM = data.weightM;
  3555. this.speed = data.speed;
  3556. this.killScore = data.killScore;
  3557. this.turnSpeed = data.turnSpeed;
  3558. this.scale = data.scale;
  3559. this.maxHealth = data.health;
  3560. this.leapForce = data.leapForce;
  3561. this.health = this.maxHealth;
  3562. this.chargePlayer = data.chargePlayer;
  3563. this.viewRange = data.viewRange;
  3564. this.drop = data.drop;
  3565. this.dmg = data.dmg;
  3566. this.hostile = data.hostile;
  3567. this.dontRun = data.dontRun;
  3568. this.hitRange = data.hitRange;
  3569. this.hitDelay = data.hitDelay;
  3570. this.hitScare = data.hitScare;
  3571. this.spriteMlt = data.spriteMlt;
  3572. this.nameScale = data.nameScale;
  3573. this.colDmg = data.colDmg;
  3574. this.noTrap = data.noTrap;
  3575. this.spawnDelay = data.spawnDelay;
  3576. this.hitWait = 0;
  3577. this.waitCount = 1000;
  3578. this.moveCount = 0;
  3579. this.targetDir = 0;
  3580. this.active = true;
  3581. this.alive = true;
  3582. this.runFrom = null;
  3583. this.chargeTarget = null;
  3584. this.dmgOverTime = {};
  3585. };
  3586. let tmpRatio = 0;
  3587. let animIndex = 0;
  3588. this.animate = function(delta) {
  3589. if (this.animTime > 0) {
  3590. this.animTime -= delta;
  3591. if (this.animTime <= 0) {
  3592. this.animTime = 0;
  3593. this.dirPlus = 0;
  3594. tmpRatio = 0;
  3595. animIndex = 0;
  3596. } else {
  3597. if (animIndex == 0) {
  3598. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3599. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3600. if (tmpRatio >= 1) {
  3601. tmpRatio = 1;
  3602. animIndex = 1;
  3603. }
  3604. } else {
  3605. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3606. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3607. }
  3608. }
  3609. }
  3610. };
  3611. // ANIMATION:
  3612. this.startAnim = function() {
  3613. this.animTime = this.animSpeed = 600;
  3614. this.targetAngle = Math.PI * 0.8;
  3615. tmpRatio = 0;
  3616. animIndex = 0;
  3617. };
  3618. };
  3619. };
  3620. class addCh {
  3621. constructor(x, y, chat, tmpObj) {
  3622. this.x = x;
  3623. this.y = y;
  3624. this.alpha = 0;
  3625. this.active = true;
  3626. this.alive = false;
  3627. this.chat = chat;
  3628. this.owner = tmpObj;
  3629. };
  3630. };
  3631. class DeadPlayer {
  3632. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3633. this.x = x;
  3634. this.y = y;
  3635. this.lastDir = dir;
  3636. this.dir = dir + Math.PI;
  3637. this.buildIndex = buildIndex;
  3638. this.weaponIndex = weaponIndex;
  3639. this.weaponVariant = weaponVariant;
  3640. this.skinColor = skinColor;
  3641. this.scale = scale;
  3642. this.visScale = 0;
  3643. this.name = name;
  3644. this.alpha = 1;
  3645. this.active = true;
  3646. this.animate = function(delta) {
  3647. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3648. if (d2 > 0.01) {
  3649. this.dir += d2 / 20;
  3650. } else {
  3651. this.dir = this.lastDir;
  3652. }
  3653. if (this.visScale < this.scale) {
  3654. this.visScale += delta / (this.scale / 2);
  3655. if (this.visScale >= this.scale) {
  3656. this.visScale = this.scale;
  3657. }
  3658. }
  3659. this.alpha -= delta / 30000;
  3660. if (this.alpha <= 0) {
  3661. this.alpha = 0;
  3662. this.active = false;
  3663. }
  3664. }
  3665. }
  3666. };
  3667. class Player {
  3668. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3669. this.id = id;
  3670. this.sid = sid;
  3671. this.tmpScore = 0;
  3672. this.team = null;
  3673. this.latestSkin = 0;
  3674. this.oldSkinIndex = 0;
  3675. this.skinIndex = 0;
  3676. this.latestTail = 0;
  3677. this.oldTailIndex = 0;
  3678. this.tailIndex = 0;
  3679. this.hitTime = 0;
  3680. this.lastHit = 0;
  3681. this.tails = {};
  3682. for (let i = 0; i < accessories.length; ++i) {
  3683. if (accessories[i].price <= 0)
  3684. this.tails[accessories[i].id] = 1;
  3685. }
  3686. this.skins = {};
  3687. for (let i = 0; i < hats.length; ++i) {
  3688. if (hats[i].price <= 0)
  3689. this.skins[hats[i].id] = 1;
  3690. }
  3691. this.points = 0;
  3692. this.dt = 0;
  3693. this.hidden = false;
  3694. this.itemCounts = {};
  3695. this.isPlayer = true;
  3696. this.pps = 0;
  3697. this.moveDir = undefined;
  3698. this.skinRot = 0;
  3699. this.lastPing = 0;
  3700. this.iconIndex = 0;
  3701. this.skinColor = 0;
  3702. this.dist2 = 0;
  3703. this.aim2 = 0;
  3704. this.maxSpeed = 1;
  3705. this.chat = {
  3706. message: null,
  3707. count: 0
  3708. };
  3709. this.backupNobull = true;
  3710. this.circle = false;
  3711. this.circleRad = 200;
  3712. this.circleRadSpd = 0.1;
  3713. this.cAngle = 0;
  3714. // SPAWN:
  3715. this.spawn = function(moofoll) {
  3716. this.attacked = false;
  3717. this.death = false;
  3718. this.spinDir = 0;
  3719. this.sync = false;
  3720. this.antiBull = 0;
  3721. this.bullTimer = 0;
  3722. this.poisonTimer = 0;
  3723. this.active = true;
  3724. this.alive = true;
  3725. this.lockMove = false;
  3726. this.lockDir = false;
  3727. this.minimapCounter = 0;
  3728. this.chatCountdown = 0;
  3729. this.shameCount = 0;
  3730. this.shameTimer = 0;
  3731. this.sentTo = {};
  3732. this.gathering = 0;
  3733. this.gatherIndex = 0;
  3734. this.shooting = {};
  3735. this.shootIndex = 9;
  3736. this.autoGather = 0;
  3737. this.animTime = 0;
  3738. this.animSpeed = 0;
  3739. this.mouseState = 0;
  3740. this.buildIndex = -1;
  3741. this.weaponIndex = 0;
  3742. this.weaponCode = 0;
  3743. this.weaponVariant = 0;
  3744. this.primaryIndex = undefined;
  3745. this.secondaryIndex = undefined;
  3746. this.dmgOverTime = {};
  3747. this.noMovTimer = 0;
  3748. this.maxXP = 300;
  3749. this.XP = 0;
  3750. this.age = 1;
  3751. this.kills = 0;
  3752. this.upgrAge = 2;
  3753. this.upgradePoints = 0;
  3754. this.x = 0;
  3755. this.y = 0;
  3756. this.oldXY = {
  3757. x: 0,
  3758. y: 0
  3759. };
  3760. this.zIndex = 0;
  3761. this.xVel = 0;
  3762. this.yVel = 0;
  3763. this.slowMult = 1;
  3764. this.dir = 0;
  3765. this.dirPlus = 0;
  3766. this.targetDir = 0;
  3767. this.targetAngle = 0;
  3768. this.maxHealth = 100;
  3769. this.health = this.maxHealth;
  3770. this.oldHealth = this.maxHealth;
  3771. this.damaged = 0;
  3772. this.scale = config.playerScale;
  3773. this.speed = config.playerSpeed;
  3774. this.resetMoveDir();
  3775. this.resetResources(moofoll);
  3776. this.items = [0, 3, 6, 10];
  3777. this.weapons = [0];
  3778. this.shootCount = 0;
  3779. this.weaponXP = [];
  3780. this.reloads = {
  3781. 0: 0,
  3782. 1: 0,
  3783. 2: 0,
  3784. 3: 0,
  3785. 4: 0,
  3786. 5: 0,
  3787. 6: 0,
  3788. 7: 0,
  3789. 8: 0,
  3790. 9: 0,
  3791. 10: 0,
  3792. 11: 0,
  3793. 12: 0,
  3794. 13: 0,
  3795. 14: 0,
  3796. 15: 0,
  3797. 53: 0,
  3798. };
  3799. this.bowThreat = {
  3800. 9: 0,
  3801. 12: 0,
  3802. 13: 0,
  3803. 15: 0,
  3804. };
  3805. this.damageThreat = 0;
  3806. this.inTrap = false;
  3807. this.canEmpAnti = false;
  3808. this.empAnti = false;
  3809. this.soldierAnti = false;
  3810. this.poisonTick = 0;
  3811. this.bullTick = 0;
  3812. this.setPoisonTick = false;
  3813. this.setBullTick = false;
  3814. this.antiTimer = 2;
  3815. };
  3816. // RESET MOVE DIR:
  3817. this.resetMoveDir = function() {
  3818. this.moveDir = undefined;
  3819. };
  3820. // RESET RESOURCES:
  3821. this.resetResources = function(moofoll) {
  3822. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3823. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3824. }
  3825. };
  3826. // ADD ITEM:
  3827. this.getItemType = function(id) {
  3828. let findindx = this.items.findIndex((ids) => ids == id);
  3829. if (findindx != -1) {
  3830. return findindx;
  3831. } else {
  3832. return items.checkItem.index(id, this.items);
  3833. }
  3834. };
  3835. // SET DATA:
  3836. this.setData = function(data) {
  3837. this.id = data[0];
  3838. this.sid = data[1];
  3839. this.name = data[2];
  3840. this.x = data[3];
  3841. this.y = data[4];
  3842. this.dir = data[5];
  3843. this.health = data[6];
  3844. this.maxHealth = data[7];
  3845. this.scale = data[8];
  3846. this.skinColor = data[9];
  3847. };
  3848. // UPDATE POISON TICK:
  3849. this.updateTimer = function() {
  3850. this.bullTimer -= 1;
  3851. if (this.bullTimer <= 0) {
  3852. this.setBullTick = false;
  3853. this.bullTick = game.tick - 1;
  3854. this.bullTimer = config.serverUpdateRate;
  3855. }
  3856. this.poisonTimer -= 1;
  3857. if (this.poisonTimer < 0) {
  3858. this.setPoisonTick = false;
  3859. this.poisonTick = game.tick - 1;
  3860. this.poisonTimer = config.serverUpdateRate;
  3861. plaguemask = true;
  3862. setTimeout(() => {
  3863. plaguemask = false;
  3864. }, 1000);
  3865. } else if(this.poisonTimer >= 0) {
  3866. plaguemask = false;
  3867. }
  3868. };
  3869. this.update = function(delta) {
  3870. if (this.alive) {
  3871. if (this.health != this.healthMov) {
  3872. this.health < this.healthMov ? (this.healthMov -= 2) : (this.healthMov += 2);
  3873. if (Math.abs(this.health - this.healthMov) < 2) this.healthMov = this.health;
  3874. };
  3875. 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);
  3876. }
  3877. if (this.sid == playerSID) {
  3878. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  3879. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  3880. this.cAngle += this.circleRadSpd;
  3881. }
  3882. if (this.active) {
  3883. // MOVE:
  3884. let gear = {
  3885. skin: findID(hats, this.skinIndex),
  3886. tail: findID(accessories, this.tailIndex)
  3887. }
  3888. 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;
  3889. this.maxSpeed = spdMult;
  3890. }
  3891. };
  3892. let tmpRatio = 0;
  3893. let animIndex = 0;
  3894. this.animate = function(delta) {
  3895. if (this.animTime > 0) {
  3896. this.animTime -= delta;
  3897. if (this.animTime <= 0) {
  3898. this.animTime = 0;
  3899. this.dirPlus = 0;
  3900. tmpRatio = 0;
  3901. animIndex = 0;
  3902. } else {
  3903. if (animIndex == 0) {
  3904. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3905. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3906. if (tmpRatio >= 1) {
  3907. tmpRatio = 1;
  3908. animIndex = 1;
  3909. }
  3910. } else {
  3911. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3912. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3913. }
  3914. }
  3915. }
  3916. };
  3917. // GATHER ANIMATION:
  3918. this.startAnim = function(didHit, index) {
  3919. this.animTime = this.animSpeed = items.weapons[index].speed;
  3920. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3921. tmpRatio = 0;
  3922. animIndex = 0;
  3923. };
  3924. // CAN SEE:
  3925. this.canSee = function(other) {
  3926. if (!other) return false;
  3927. let dx = Math.abs(other.x - this.x) - other.scale;
  3928. let dy = Math.abs(other.y - this.y) - other.scale;
  3929. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3930. };
  3931. // SHAME SYSTEM:
  3932. this.judgeShame = function() {
  3933. if (this.oldHealth < this.health) {
  3934. if (this.hitTime) {
  3935. let timeSinceHit = Date.now() - this.hitTime;
  3936. this.lastHit = game.tick;
  3937. this.hitTime = 0;
  3938. if (timeSinceHit < 120) {
  3939. this.shameCount++;
  3940. } else {
  3941. this.shameCount = Math.max(0, this.shameCount - 2);
  3942. }
  3943. }
  3944. } else if (this.oldHealth > this.health) {
  3945. this.hitTime = Date.now();
  3946. }
  3947. };
  3948. this.addShameTimer = function() {
  3949. this.shameCount = 0;
  3950. this.shameTimer = 30;
  3951. let interval = setInterval(() => {
  3952. this.shameTimer--;
  3953. if (this.shameTimer <= 0) {
  3954. clearInterval(interval);
  3955. }
  3956. }, 1000);
  3957. };
  3958. // CHECK TEAM:
  3959. this.isTeam = function(tmpObj) {
  3960. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  3961. };
  3962. // FOR THE PLAYER:
  3963. this.findAllianceBySid = function(sid) {
  3964. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  3965. };
  3966. this.checkCanInsta = function(nobull) {
  3967. let totally = 0;
  3968. if (this.alive && inGame) {
  3969. let primary = {
  3970. weapon: this.weapons[0],
  3971. variant: this.primaryVariant,
  3972. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  3973. };
  3974. let secondary = {
  3975. weapon: this.weapons[1],
  3976. variant: this.secondaryVariant,
  3977. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  3978. };
  3979. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  3980. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  3981. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  3982. totally += primary.dmg * pV * bull;
  3983. }
  3984. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  3985. totally += secondary.dmg;
  3986. }
  3987. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  3988. totally += 25;
  3989. }
  3990. totally *= near.skinIndex == 6 ? 0.75 : 1;
  3991. return totally;
  3992. }
  3993. return 0;
  3994. };
  3995. // UPDATE WEAPON RELOAD:
  3996. this.manageReload = function() {
  3997. if (this.shooting[53]) {
  3998. this.shooting[53] = 0;
  3999. this.reloads[53] = (2500 - game.tickRate);
  4000. } else {
  4001. if (this.reloads[53] > 0) {
  4002. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4003. }
  4004. }
  4005. if (this.gathering || this.shooting[1]) {
  4006. if (this.gathering) {
  4007. this.gathering = 0;
  4008. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4009. this.attacked = true;
  4010. }
  4011. if (this.shooting[1]) {
  4012. this.shooting[1] = 0;
  4013. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4014. this.attacked = true;
  4015. }
  4016. } else {
  4017. this.attacked = false;
  4018. if (this.buildIndex < 0) {
  4019. if (this.reloads[this.weaponIndex] > 0) {
  4020. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  4021. if (this == player) {
  4022. if (getEl("weaponGrind").checked) {
  4023. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4024. checkPlace(player.getItemType(22), i);
  4025. }
  4026. }
  4027. }
  4028. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4029. this.antiBull++;
  4030. game.tickBase(() => {
  4031. this.antiBull = 0;
  4032. }, 1);
  4033. }
  4034. }
  4035. }
  4036. }
  4037. };
  4038. // FOR ANTI INSTA:
  4039. this.addDamageThreat = function(tmpObj) {
  4040. let primary = {
  4041. weapon: this.primaryIndex,
  4042. variant: this.primaryVariant
  4043. };
  4044. let secondary = {
  4045. weapon: this.secondaryIndex,
  4046. variant: this.secondaryVariant
  4047. };
  4048. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4049. secondary.dmg = secondary.weapon == undefined ? 50 : 10 ? items.weapons[secondary.weapon].Pdmg : items.weapons[secondary.weapon].Pdmg;
  4050. let bull = 1.5;
  4051. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4052. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4053. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] <= ping*2) {
  4054. this.mostDamageThreat += primary.dmg * pV * bull;
  4055. if (this.reloads[primary.weapon] <= ping) {
  4056. this.damageThreat += primary.dmg * pV * bull;
  4057. }
  4058. }
  4059. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] <= ping * 2) {
  4060. this.mostDamageThreat += secondary.dmg * sV;
  4061. if (this.reloads[secondary.weapon] <= ping) {
  4062. this.damageThreat += secondary.dmg * sV;
  4063. }
  4064. }
  4065. if (this.reloads[53] <= game.tickRate + ping) {
  4066. this.damageThreat += 25;
  4067. this.mostDamageThreat += 25;
  4068. }
  4069. if (traps.checkSpikeTick()) {
  4070. this.damageThreat += secondary.weapon == 10 ? 34 : 26
  4071. this.mostDamageThreat += secondary.weapon == 10 ? 34 : 26
  4072. }
  4073. this.damageThreat *= player.skinIndex == 6 && !clicks.left && !clicks.right && !traps.inTrap ? 0.75 : 1;
  4074. if (!this.isTeam(tmpObj)) {
  4075. if (this.dist2 <= 300) {
  4076. tmpObj.damageThreat += this.damageThreat;
  4077. tmpObj.mostDamageThreat += this.mostDamageThreat
  4078. }
  4079. }
  4080. };
  4081. }
  4082. };
  4083. // SOME CODES:
  4084. function sendUpgrade(index) {
  4085. player.reloads[index] = 0;
  4086. packet("H", index);
  4087. }
  4088. function storeEquip(id, index) {
  4089. packet("c", 0, id, index);
  4090. }
  4091. function storeBuy(id, index) {
  4092. packet("c", 1, id, index);
  4093. }
  4094.  
  4095. function buyEquip(id, index) {
  4096. let nID = player.skins[6] ? 6 : 0;
  4097. if (player.alive && inGame) {
  4098. if (index == 0) {
  4099. if (player.skins[id]) {
  4100. if (player.latestSkin != id) {
  4101. packet("c", 0, id, 0);
  4102. }
  4103. } else {
  4104. if (configs.autoBuyEquip) {
  4105. let find = findID(hats, id);
  4106. if (find) {
  4107. if (player.points >= find.price) {
  4108. //setTimeout(()=>{
  4109. packet("c", 1, id, 0);
  4110. //setTimeout(()=>{
  4111. packet("c", 0, id, 0);
  4112. //}, 120);
  4113. //}, 120);
  4114. } else {
  4115. if (player.latestSkin != nID) {
  4116. packet("c", 0, nID, 0);
  4117. }
  4118. }
  4119. } else {
  4120. if (player.latestSkin != nID) {
  4121. packet("c", 0, nID, 0);
  4122. }
  4123. }
  4124. } else {
  4125. if (player.latestSkin != nID) {
  4126. packet("c", 0, nID, 0);
  4127. }
  4128. }
  4129. }
  4130. } else if (index == 1) {
  4131. if (player.tails[id]) {
  4132. if (player.latestTail != id) {
  4133. packet("c", 0, id, 1);
  4134. }
  4135. } else {
  4136. if (configs.autoBuyEquip) {
  4137. let find = findID(accessories, id);
  4138. if (find) {
  4139. if (player.points >= find.price) {
  4140. packet("c", 1, id, 1);
  4141. // setTimeout(()=>{
  4142. packet("c", 0, id, 1);
  4143. //}, 120);
  4144. } else {
  4145. if (player.latestTail != 0) {
  4146. packet("c", 0, 0, 1);
  4147. }
  4148. }
  4149. } else {
  4150. if (player.latestTail != 0) {
  4151. packet("c", 0, 0, 1);
  4152. }
  4153. }
  4154. } else {
  4155. if (player.latestTail != 0) {
  4156. packet("c", 0, 0, 1);
  4157. }
  4158. }
  4159. }
  4160. }
  4161. }
  4162. }
  4163. function selectToBuild(index, wpn) {
  4164. packet("G", index, wpn);
  4165. }
  4166. function selectWeapon(index, isPlace) {
  4167. if (!isPlace) {
  4168. player.weaponCode = index;
  4169. }
  4170. packet("G", index, 1);
  4171. }
  4172. function sendAutoGather() {
  4173. packet("K", 1, 1);
  4174. }
  4175. function sendAtck(id, angle) {
  4176. packet("d", id, angle, 1);
  4177. }
  4178. function toRadian(angle) {
  4179. let fixedAngle = (angle % 360) * (Math.PI / 180);
  4180. return fixedAngle < 0 ? (2 * Math.PI + fixedAngle) : fixedAngle;
  4181. }
  4182. function Hg(e, t){
  4183. buyEquip(e, 0);
  4184. buyEquip(t, 1);
  4185. }
  4186.  
  4187. // PLACER:
  4188. function place(id, rad, rmd) {
  4189. try {
  4190. if (id == undefined) return;
  4191. let item = items.list[player.items[id]];
  4192. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4193. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4194. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4195. 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))) {
  4196. selectToBuild(player.items[id]);
  4197. sendAtck(1, rad);
  4198. selectWeapon(player.weaponCode, 1);
  4199. if (rmd && getEl("renderplace").value == "placeVis") {
  4200. placeVisible.push({
  4201. x: tmpX,
  4202. y: tmpY,
  4203. name: item.name,
  4204. scale: item.scale,
  4205. dir: rad
  4206. });
  4207. game.tickBase(() => {
  4208. placeVisible.shift();
  4209. }, 1)
  4210. }
  4211. if (rmd && getEl("renderplace").value == "outline") {
  4212. placeVisible.push({
  4213. x: tmpX,
  4214. y: tmpY,
  4215. name: item.name,
  4216. scale: item.scale,
  4217. dir: rad
  4218. });
  4219. game.tickBase(() => {
  4220. placeVisible.shift();
  4221. }, 1)
  4222. }
  4223. if (rmd && getEl("previs").checked) {
  4224. preplaceVisible.push({
  4225. x: tmpX,
  4226. y: tmpY,
  4227. name: item.name,
  4228. scale: item.scale,
  4229. dir: rad
  4230. });
  4231. game.tickBase(() => {
  4232. preplaceVisible.shift();
  4233. }, 1)
  4234.  
  4235.  
  4236.  
  4237.  
  4238. }
  4239. }
  4240. } catch (e) {}
  4241. }
  4242.  
  4243. function getDist(e, t) {
  4244. try {
  4245. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4246. } catch (e) {
  4247. return Infinity;
  4248. }
  4249. }
  4250. // GET DIRECTION
  4251. function getDir(e, t) {
  4252. try {
  4253. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4254. } catch (e) {
  4255. return 0;
  4256. }
  4257. }
  4258.  
  4259. function sortFromSmallest(arr, func) { // dist - dist
  4260. func = typeof func == "function" ? func : (obj) => {
  4261. return obj
  4262. };
  4263. return arr.sort((two, one) => (func(two)) - func(one));
  4264. }
  4265. /*
  4266. tmpList = objectManager.getGridArrays(user.x2, user.y2, 500);
  4267. for (var x = 0; x < tmpList.length; ++x) {
  4268. for (var y = 0; y < tmpList[x].length; ++y) {
  4269. if (tmpList[x][y].active && getDist(player, tmpList[x][y]))
  4270. }
  4271. }
  4272. */
  4273. function getCloseBuildings() {
  4274. let buildings = [];
  4275. let addedBefore = {};
  4276. let filteredBuildings = objectManager.getGridArrays(player.x, player.y, 200);
  4277. //console.log(filteredBuildings);
  4278. for (var x = 0; x < filteredBuildings.length; ++x) {
  4279. for (var y = 0; y < filteredBuildings[x].length; ++y) {
  4280. if (filteredBuildings[x][y].active) {
  4281. buildings.push(filteredBuildings[x][y]);
  4282. }
  4283. }
  4284. }
  4285. //console.log(buildings);
  4286. return buildings;
  4287. }
  4288. function quadSpikeBreak(user, item) {
  4289. try {
  4290. let angles = [];
  4291. let possibleOnes = [];
  4292. for (let angle = 0; angle < 72; angle++) {
  4293. angles.push(toRadian(angle * 5));
  4294. }
  4295. let buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && t.sid != player.inTrap.sid && getDist(player, t) <= 150), (a)=>{
  4296. return getDist(player, a);
  4297. });
  4298. let last = null;
  4299. for (let angle of angles) {
  4300. let position = player.buildItemPosition(item, angle);
  4301. let possibleToPlace = true;
  4302. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4303. possibleToPlace = false;
  4304. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4305. possibleToPlace = false;
  4306. } else {
  4307. for (let building of buildings_) {
  4308. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4309. if (getDist(building, position) < item.scale + range) { // overlap
  4310. possibleToPlace = false;
  4311. last = building;
  4312. break;
  4313. }
  4314. }
  4315. }
  4316. if (possibleToPlace) {
  4317. possibleOnes.push(angle);
  4318. }
  4319. }
  4320. return possibleOnes;
  4321. } catch (e) {
  4322. //console.log(e);
  4323. }
  4324. }
  4325. function getPlaceablePositions(user, item) {
  4326. try {
  4327. let angles = [];
  4328. let possibleOnes = [];
  4329. for (let angle = 0; angle < 72; angle++) {
  4330. angles.push(toRadian(angle * 5));
  4331. }
  4332. let buildings_ = [];
  4333. if (!window.isMohMoh) {
  4334. buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && getDist(player, t) <= 150), (a)=>{
  4335. return getDist(player, a);
  4336. });
  4337. }
  4338. let last = null;
  4339. for (let angle of angles) {
  4340. let position = player.buildItemPosition(item, angle);
  4341. let possibleToPlace = true;
  4342. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4343. possibleToPlace = false;
  4344. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4345. possibleToPlace = false;
  4346. } else if (true) {
  4347. for (let building of buildings_) {
  4348. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4349. if (getDist(building, position) < item.scale + range) { // overlap
  4350. possibleToPlace = false;
  4351. last = building;
  4352. break;
  4353. }
  4354. }
  4355. }
  4356. if (possibleToPlace) {
  4357. possibleOnes.push(angle);
  4358. }
  4359. }
  4360. return possibleOnes;
  4361. } catch (e) {
  4362. //console.log(e);
  4363. }
  4364. }
  4365. let firstCheckPlaceForntiBUg = false;
  4366. function simplePlace(id, radian) {
  4367. checkPlace(id, radian);
  4368. };
  4369.  
  4370.  
  4371. function checkPlace(id, rad) {
  4372. try {
  4373. if (secPacket.count >= 80) return;
  4374. //if (id == undefined) return;
  4375. let item = items.list[player.items[id]];
  4376. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4377. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4378. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4379. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4380. place(id, rad, 1);
  4381. }
  4382. } catch (e) {}
  4383. }
  4384. // Preplacer
  4385. let preplaceDelay = {
  4386. killObject: -1,
  4387. gatherAnimation: -1,
  4388. total: function () {
  4389. return new Date - Math.abs(Math.trunc(this.killObject - this.gatherAnimation))
  4390. }
  4391. };
  4392.  
  4393. function getDist(e, t) {
  4394. try {
  4395. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4396. }
  4397. catch (e) {
  4398. return 1 / 0
  4399. }
  4400. }
  4401.  
  4402. function getDir(e, t) {
  4403. try {
  4404. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4405. }
  4406. catch (e) {
  4407. return 0
  4408. }
  4409. }
  4410. var preplaceOverride = !1;
  4411.  
  4412. function caf(e, t) {
  4413. try {
  4414. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4415. }
  4416. catch (e) {
  4417. return 0
  4418. }
  4419. }
  4420.  
  4421. function cdf(e, t) {
  4422. try {
  4423. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4424. }
  4425. catch (e) {
  4426. return 1 / 0
  4427. }
  4428. }
  4429.  
  4430. function numArr(e = 0, t = 1, i, a = 1) {
  4431. let n = [];
  4432. for (let s = e; s < t; s += a) n.push(s), "function" == typeof i && i(s);
  4433. return n
  4434. }
  4435.  
  4436. function toR(e) {
  4437. var t = e * Math.PI / 180 % (2 * Math.PI);
  4438. return t > Math.PI ? Math.PI - t : t
  4439. }
  4440.  
  4441. function toD(e) {
  4442. var t = e / Math.PI * 360 % 360;
  4443. return t >= 360 ? t - 360 : t
  4444. }
  4445. // HEALING:
  4446. function soldierMult() {
  4447. return player.latestSkin == 6 ? 0.75 : 1;
  4448. }
  4449. function getAttacker(damaged) {
  4450. let attackers = enemy.filter(tmp => {
  4451. //let damages = new Damages(items);
  4452. //let dmg = damages.weapons[tmp.weaponIndex];
  4453. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4454. let rule = {
  4455. //one: tmp.dist2 <= 300,
  4456. //two: by.includes(damaged),
  4457. three: tmp.attacked
  4458. }
  4459. return /*rule.one && rule.two && */rule.three;
  4460. });
  4461. return attackers;
  4462. }
  4463. function healer() {
  4464. for (let i = 0; i < healthBased(); i++) {
  4465. place(0, getAttackDir());
  4466. }
  4467. }
  4468. // ADVANCED:
  4469. function applCxC(value) {
  4470. if (player.health == 100)
  4471. return 0;
  4472. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4473. return Math.ceil(value / items.list[player.items[0]].healing);
  4474. }
  4475. return 0;
  4476. }
  4477. function healthBased() {
  4478. if (player.health == 100)
  4479. return 0;
  4480. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4481. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4482. }
  4483. return 0;
  4484. }
  4485. function calcDmg(value) {
  4486. return value * player.skinIndex == 6 ? 0.75 : 1;
  4487. }
  4488. function antirev() {
  4489. if (tmpObj.isPlayer){
  4490. for (let i = 0; i < healthBased(); i++) {
  4491. place(0, getAttackDir());
  4492. if (player.health == 55 && player.shameCount < 6 && player.skinIndex == 6) {
  4493. place(0, getAttackDir());
  4494. notif("antirev");
  4495. } else if (player.health == 40 && player.shameCount < 6 && player.skinIndex != 6){
  4496. place(0, getAttackDir());
  4497. notif("antirev");
  4498. } else if (player.health == 43.75 && player.shameCount < 5 && player.skinIndex == 6){
  4499. place(0, getAttackDir());
  4500. setTimeout(()=>{
  4501. place(0, getAttackDir());
  4502. },5)
  4503. } else if(player.health == 25 && player.shameCount < 4 && player.skinIndex == 6){
  4504. place(0, getAttackDir());
  4505. setTimeout(()=>{
  4506. place(0, getAttackDir());
  4507. },5)
  4508. } else if (player.health == 58.75 && player.shameCount < 6 && player.skinIndex == 6){
  4509. place(0, getAttackDir());
  4510. setTimeout(()=>{
  4511. place(0, getAttackDir());
  4512. },5)
  4513. } else if (player.health == 45 && player.shameCount < 6 && player.skinIndex != 6){
  4514. place(0, getAttackDir());
  4515. setTimeout(()=>{
  4516. place(0, getAttackDir());
  4517. },5)
  4518. }
  4519. if (player.shameCount < 6) {
  4520. setTimeout(()=>{
  4521. place(0, getAttackDir());
  4522. },30)
  4523. }
  4524. }
  4525. }
  4526. }
  4527. let slowHeal = function(timer) {
  4528. setTimeout(() => {
  4529. healer();
  4530. }, 25);
  4531. }
  4532. let isHealing = false;
  4533. let delay = 20;
  4534. function uziheal() {
  4535. if (!isHealing && player.health < 100) {
  4536. isHealing = true;
  4537. if (player.health < 70) {
  4538. place(0, getAttackDir());
  4539. healer();// fast heal
  4540. isHealing = false;
  4541. } else {
  4542. const healingDelay = 15;
  4543. const healingIterations = Math.ceil((100 - player.health) / 25); // making it have delay so it wont packet spam
  4544. let iterationCount = 0;
  4545. function performHealing() {
  4546. if (iterationCount < healingIterations) {
  4547. setTimeout(() => {
  4548. place(0, getAttackDir()); // slow heal
  4549. iterationCount++;
  4550. performHealing();
  4551. }, healingDelay);
  4552. } else {
  4553. isHealing = false;
  4554. }
  4555. }
  4556. performHealing();
  4557. }
  4558. }
  4559. }
  4560. // LATER:
  4561. function predictHeal() { }
  4562. function antiSyncHealing(timearg) {
  4563. my.antiSync = true;
  4564. let healAnti = setInterval(() => {
  4565. if (player.shameCount < 5) {
  4566. place(0, getAttackDir());
  4567. }
  4568. }, 75);
  4569. setTimeout(() => {
  4570. clearInterval(healAnti);
  4571. setTimeout(() => {
  4572. my.antiSync = false;
  4573. }, game.tickRate);
  4574. }, game.tickRate);
  4575. }
  4576. function biomeGear(mover, returns) {
  4577. if (getEl("hatType").value == "1") {
  4578. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4579. if (returns) return 31;
  4580. buyEquip(31, 0);
  4581. } else {
  4582. if (player.y2 <= config.snowBiomeTop) {
  4583. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4584. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4585. } else {
  4586. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4587. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4588. }
  4589. }
  4590. } else if (getEl("hatType").value == "2") {
  4591. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4592. if (returns) return 31;
  4593. buyEquip(31, 0);
  4594. } else {
  4595. if (player.y2 <= config.snowBiomeTop) {
  4596. if (returns) return mover && player.moveDir == undefined ? 6 : 15;
  4597. buyEquip(mover && player.moveDir == undefined ? 6 : 15, 0);
  4598. } else {
  4599. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  4600. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  4601. }
  4602. }
  4603. }
  4604. if (returns) return 0;
  4605. }
  4606.  
  4607. const placedSpikePositions = new Set();
  4608. const placedTrapPositions = new Set();
  4609. function isPositionValid(position) {
  4610. const playerX = player.x2;
  4611. const playerY = player.y2;
  4612. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  4613. return distToPosition > 35;
  4614. }
  4615. function findAllianceBySid(sid) {
  4616. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4617. }
  4618. function calculatePossibleTrapPositions(x, y, radius) {
  4619. const trapPositions = [];
  4620. const numPositions = 16;
  4621. for (let i = 0; i < numPositions; i++) {
  4622. const angle = (2 * Math.PI * i) / numPositions;
  4623. const offsetX = x + radius * Math.cos(angle);
  4624. const offsetY = y + radius * Math.sin(angle);
  4625. const position = [offsetX, offsetY];
  4626. if (!trapPositions.some((pos) => isPositionTooClose(position, pos))) {
  4627. trapPositions.push(position);
  4628. }
  4629. }
  4630. return trapPositions;
  4631. }
  4632. function isPositionTooClose(position1, position2, minDistance = 50) {
  4633. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  4634. return dist < minDistance;
  4635. }
  4636. function biomeGear(mover, returns) {
  4637. if (inWater) {
  4638. if (returns) return 31;
  4639. buyEquip(31, 0);
  4640. } else {
  4641. if (player.y2 <= config.snowBiomeTop) {
  4642. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4643. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4644. } else {
  4645. if (returns) return mover && player.moveDir == undefined ? 22 : 6;
  4646. buyEquip(mover && player.moveDir == undefined ? 22 : 6, 0);
  4647. }
  4648. }
  4649. if (returns) return 0;
  4650. }
  4651. function woah(mover) {
  4652. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4653. }
  4654. function secondaryCheck(id, radian) {
  4655. try {
  4656. var item = items.list[id];
  4657. var tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4658. var tmpX = player.x2 + tmpS * Math.cos(radian);
  4659. var tmpY = player.y2 + tmpS * Math.sin(radian);
  4660. if (
  4661. objectManager.checkItemLocation(
  4662. tmpX,
  4663. tmpY,
  4664. item.scale,
  4665. 0.6,
  4666. item.id,
  4667. false,
  4668. player
  4669. )
  4670. ) {
  4671. if (
  4672. player.itemCounts[item.group.id] == undefined
  4673. ? true
  4674. : player.itemCounts[item.group.id] <
  4675. (true
  4676. ? 99
  4677. : item.group.limit
  4678. ? 99
  4679. : 99)
  4680. ) {
  4681. return true
  4682. }
  4683. }
  4684. } catch (e) {
  4685.  
  4686. }
  4687. }
  4688. function makeAngles(building, type) {
  4689. let getDist = function (tmp1, tmp2, type1, type2) {
  4690. let tmpXY1 = {
  4691. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4692. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4693. };
  4694. let tmpXY2 = {
  4695. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4696. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4697. };
  4698. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4699. };
  4700. function fgdo(a, b) {
  4701. if (a == player) {
  4702. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4703. } else if (b == player) {
  4704. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4705. } else {
  4706. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4707. }
  4708. }
  4709. let buildings = building.filter(obj => fgdo(player, obj) < player.scale + items.list[type].scale + obj.scale + 50 && obj.active)
  4710. let allAngles = []
  4711. let scale
  4712. let offset = player.scale + items.list[type].scale + (items.list[type].placeOffset || 0)
  4713. for (let i = 0; i < buildings.length; i++) {
  4714.  
  4715. let scale
  4716. if (!buildings[i].isItem) {
  4717. if ((buildings[i].scale != 80 && buildings[i].scale != 85 && buildings[i].scale != 90 || buildings[i].type == 1)) {
  4718. scale = buildings[i].scale * 0.40
  4719.  
  4720. } else {
  4721. scale = buildings[i].scale
  4722. }
  4723. } else {
  4724. scale = buildings[i].scale
  4725. }
  4726. let angles = []
  4727. let dist = (items.list[type].scale + scale + 1)
  4728. let dPTB = fgdo(player, buildings[i])
  4729. let cosLaw
  4730. if (dPTB > dist + offset) {
  4731. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dist, 2)) - Math.pow(dPTB, 2)) / (2 * dist * offset))
  4732. cosLaw = Math.asin((dist * Math.sin(cosLaw)) / dPTB)
  4733. } else {
  4734. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dPTB, 2)) - Math.pow(dist, 2)) / (2 * dPTB * offset))
  4735. }
  4736. let aPTB = Math.atan2(buildings[i].y - player.y2, buildings[i].x - player.x2)
  4737. let ang1 = (aPTB - cosLaw)
  4738. let ang2 = (aPTB + cosLaw)
  4739. if (!isNaN(cosLaw)) {
  4740. angles.push(ang1)
  4741. angles.push(ang2)
  4742. angles.push(buildings[i])
  4743. }
  4744. allAngles.push(angles)
  4745. }
  4746.  
  4747. for (let i = 0; i < allAngles.length * 3; i++) {
  4748. allAngles = manageAngles(allAngles)
  4749.  
  4750. }
  4751. if (!allAngles.length) {
  4752. allAngles = [0, 0.0001]
  4753. }
  4754. for (let i = 0; i < allAngles.length; i++) {
  4755. if (allAngles != false) {
  4756. if (!secondaryCheck(type, allAngles[i][0]) || !secondaryCheck(type, allAngles[i][1])) {
  4757. allAngles = false
  4758. }
  4759. }
  4760. }
  4761. return allAngles
  4762. }
  4763. 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)
  4764. //mental health is not looking good rn
  4765. let array1q
  4766. let array = new Array(2);
  4767. let array2q
  4768.  
  4769. if (Math.sin(angle) > 0 && Math.cos(angle) > 0) {//angle in the first quadrant
  4770. array[0] = arra[0]
  4771. array[1] = arra[1]
  4772. } else if (Math.sin(angle) > 0 && Math.cos(angle) < 0) {//angle is inside the second quadrant
  4773. angle = angle - (Math.PI / 2)
  4774. array[0] = arra[0] - (Math.PI / 2)
  4775. array[1] = arra[1] - (Math.PI / 2)
  4776. } else if (Math.sin(angle) < 0 && Math.cos(angle) < 0) {// angle is in the third quadrant
  4777. angle = angle - Math.PI
  4778. array[0] = arra[0] - Math.PI
  4779. array[1] = arra[1] - Math.PI
  4780.  
  4781. } else if (Math.sin(angle) < 0 && Math.cos(angle) > 0) {//angle is in the fourth quadrant
  4782. angle = angle - ((3 * Math.PI) / 2)
  4783. array[0] = arra[0] - ((3 * Math.PI) / 2)
  4784. array[1] = arra[1] - ((3 * Math.PI) / 2)
  4785. }
  4786. if (Math.sin(array[0]) > 0 && Math.cos(array[0]) > 0) {
  4787. array1q = 1
  4788. } else if (Math.sin(array[0]) > 0 && Math.cos(array[0]) < 0) {
  4789. array1q = 2
  4790. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) < 0) {
  4791. array1q = 3
  4792. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) > 0) {
  4793. array1q = 4
  4794. }
  4795. if (Math.sin(array[1]) > 0 && Math.cos(array[1]) > 0) {
  4796. array2q = 1
  4797. } else if (Math.sin(array[1]) > 0 && Math.cos(array[1]) < 0) {
  4798. array2q = 2
  4799. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) < 0) {
  4800. array2q = 3
  4801. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) > 0) {
  4802. array2q = 4
  4803. }
  4804.  
  4805. if (array1q == 1) {//lowest angle of the not allowed zone in the first quadrant
  4806.  
  4807. if (Math.sin(angle) < Math.sin(array[0])) {//if the angle is lower than the not allowed zone (probably not in between)
  4808. if (array2q == 1) {// if the second part of the not allowed zone is in the first quadrant
  4809. if (Math.sin(angle) < Math.sin(array[2])) {//if it wraps completely around and makes it in between
  4810. return true
  4811. } else {//doesn't wrap around enough
  4812. return false
  4813. }
  4814. } else {//not in the first quadrant, not in between
  4815. return false
  4816. }
  4817. } else {//if the angle is further than the not allowed zone
  4818. if (array2q == 1) {//if the second part of the not allowed zone is in the first quadrant
  4819. if (Math.sin(angle) < Math.sin(array[2])) {//if the angle is lower than the top limit (in between)
  4820.  
  4821. return true
  4822. } else {//is not in between
  4823. return false
  4824. }
  4825.  
  4826. } else {//its gonna be somewhere further so its in between
  4827. return true;
  4828. }
  4829. }
  4830. } else {
  4831. if (array2q == 1) {//if the further part of the not allowed zone is in the first quadrant
  4832. if (Math.sin(angle) < Math.sin(array[1])) {//if it wraps all the way around
  4833. return true
  4834. } else {
  4835. return false
  4836. }
  4837. } else {
  4838. if (array1q == 2) {//if lowest angle is in the second
  4839. if (array2q == 2) {
  4840. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4841. return true
  4842. } else {
  4843. return false
  4844. }
  4845. } else {
  4846. return false
  4847. }
  4848. } else if (array1q == 3) {//if the first one is in the third
  4849. if (array1q > array2q) {
  4850. return true
  4851. } else if (array1q < array2q) {
  4852. return false
  4853. } else {
  4854. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4855. return true
  4856. } else {
  4857. return false
  4858. }
  4859. }
  4860. } else if (array1q == 4) {//if the first one is in the third
  4861. if (array1q > array2q) {
  4862. return true
  4863. } else if (array1q < array2q) {
  4864. return false
  4865. } else {
  4866. if (Math.sin(array[0]) > Math.sin(array[1])) {
  4867. return true
  4868. } else {
  4869. return false
  4870. }
  4871. }
  4872. }
  4873. }
  4874.  
  4875. }
  4876.  
  4877. }
  4878. function manageAngles(angles) {
  4879. let allAngles = []
  4880. for (let i = 0; i < angles.length; i++) {
  4881. if (angles[i].length) {
  4882. if (!allAngles.length) {
  4883. allAngles.push(angles[i])
  4884. } else {
  4885. let used = false
  4886. for (let j = 0; j < allAngles.length; j++) {
  4887.  
  4888. if (inBetween(angles[i][0], allAngles[j])) {
  4889. used = true
  4890. if (inBetween(angles[i][1], allAngles[j])) {
  4891. allAngles[j].push(angles[i][2])
  4892. } else {
  4893. allAngles[j][1] = angles[i][1]
  4894. allAngles[j].push(angles[i][2])
  4895. }
  4896. } else if (inBetween(angles[i][1], allAngles[j])) {
  4897. used = true
  4898. allAngles[j][0] = angles[i][0]
  4899. allAngles[j].push(angles[i][2])
  4900. }
  4901. }
  4902. if (!used) {
  4903. allAngles.push(angles[i])
  4904. }
  4905. }
  4906. }
  4907. }
  4908.  
  4909. return allAngles
  4910.  
  4911. }
  4912. let priorityPlace = [];
  4913. let packetData = {
  4914. place: [],
  4915. placeQ: [],
  4916. }
  4917. function autoplacer() {
  4918. let getDist = function (tmp1, tmp2, type1, type2) {
  4919. let tmpXY1 = {
  4920. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4921. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4922. };
  4923. let tmpXY2 = {
  4924. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4925. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4926. };
  4927. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4928. };
  4929. function fgdo(a, b) {
  4930. if (a == player) {
  4931. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4932. } else if (b == player) {
  4933. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4934. } else {
  4935. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4936. }
  4937. }
  4938. 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));
  4939. let nearBuilds = buildings.filter(obj => fgdo(obj, player) < 250);
  4940. const notRiver = !inWater
  4941. /*nearest enemy in trap*/
  4942. if (enemy.length && notRiver) {
  4943. 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) {
  4944. return getDist(a, near, 0, 2) - getDist(b, near, 0, 2);
  4945. })[0];
  4946. let direction = Math.atan2(near.y - player.y2, near.x - player.x2)
  4947. let spikeAngles = makeAngles(nearBuilds, player.items[2])
  4948. let trapAngles = [];
  4949. if (player.items[4]) {
  4950. trapAngles = makeAngles(nearBuilds, player.items[4])
  4951. if (!trapAngles) {
  4952. return
  4953. }
  4954. }
  4955. if (!spikeAngles) {
  4956. return
  4957. }
  4958. if (spikeAngles.length || trapAngles.length) {
  4959. let placed = []
  4960. if (priorityPlace.length) {
  4961. for (let j = 0; j < priorityPlace; j++) {
  4962. let newDir = Math.atan2(priorityPlace[j].y - player.y2, priorityPlace[j].x - player.x2)
  4963. let angFound = 0
  4964. for (let i = 0; i < spikeAngles.length; i++) {
  4965. if (!inBetween(newDir, spikeAngles[i])) {
  4966. angFound += 1
  4967. }
  4968. }
  4969. if (angFound == spikeAngles.length) {
  4970. placed.push([player.items[2], newDir])
  4971. packetData.place.push([2, newDir])
  4972. }
  4973. }
  4974. }
  4975. priorityPlace = []
  4976. if (placed.length) {
  4977. for (let i = 0; i < placed.length; i++) {
  4978. let obj = {
  4979. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4980. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4981. scale: items.list[placed[i][0]].scale / 3,
  4982. isItem: true,
  4983. active: true,
  4984. }
  4985. nearBuilds.push(obj)
  4986. }
  4987. spikeAngles = makeAngles(nearBuilds, player.items[2])
  4988. if (!spikeAngles) {
  4989. return
  4990. }
  4991. trapAngles = []
  4992. if (player.items[4]) {
  4993. trapAngles = makeAngles(nearBuilds, player.items[4])
  4994. if (!trapAngles) {
  4995. return
  4996. }
  4997. }
  4998. placed = []
  4999. }
  5000.  
  5001. if (neit && fgdo(player, near) < 200) {
  5002. let nearestAngle = undefined
  5003. let trapFound = false
  5004. for (let i = 0; i < spikeAngles.length; i++) {
  5005. if (!trapFound) {
  5006. for (let j = 2; j < spikeAngles[i].length; j++) {
  5007. if (neit == spikeAngles[i][j]) {
  5008. trapFound = true
  5009. nearestAngle = ((spikeAngles[i][0] - direction) < (spikeAngles[i][1] - direction) ? spikeAngles[i][0] : spikeAngles[i][1])
  5010. }
  5011. }
  5012. }
  5013. }
  5014. if (trapFound) {
  5015. let objectX = player.x2 + (Math.cos(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  5016. let objectY = player.y2 + (Math.sin(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  5017. if (Math.hypot(objectY - near.y, objectX - near.x) < (player.scale + items.list[player.items[2]].scale + 8)) {
  5018. placed.push([player.items[2], nearestAngle])
  5019. packetData.place.push([2, nearestAngle])
  5020. }
  5021. }
  5022. }
  5023. if (placed.length) {
  5024. for (let i = 0; i < placed.length; i++) {
  5025. let obj = {
  5026. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5027. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5028. scale: items.list[placed[i][0]].scale / 3,
  5029. isItem: true,
  5030. active: true,
  5031. }
  5032. nearBuilds.push(obj)
  5033. }
  5034. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5035. if (!spikeAngles) {
  5036. return
  5037. }
  5038. trapAngles = []
  5039. if (player.items[4]) {
  5040. trapAngles = makeAngles(nearBuilds, player.items[4])
  5041. if (!trapAngles) {
  5042. return
  5043. }
  5044. }
  5045. placed = []
  5046. }
  5047. if (fgdo(player, near) < 400) {
  5048. let ha = false
  5049.  
  5050.  
  5051. if (neit) {
  5052. let buildings = gameObjects.sort((a, b) => fgdo(player, a) - fgdo(player, b))
  5053. 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]
  5054. if (spike) {
  5055. ha = true
  5056. }
  5057.  
  5058. }
  5059. if (!neit || ha) {
  5060. let dirFound = 0
  5061. for (let i = 0; i < trapAngles.length; i++) {
  5062. if (!inBetween(direction, trapAngles[i])) {
  5063. dirFound += 1
  5064. }
  5065. }
  5066. if (dirFound == trapAngles.length) {
  5067. if (packetData.place.length < 3 && player.items[4]) {
  5068. placed.push([player.items[4], direction])
  5069. packetData.place.push([4, direction])
  5070. }
  5071. }
  5072. if (placed.length) {
  5073. for (let i = 0; i < placed.length; i++) {
  5074. let obj = {
  5075. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5076. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5077. scale: items.list[placed[i][0]].scale / 3,
  5078. isItem: true,
  5079. active: true,
  5080.  
  5081. }
  5082. nearBuilds.push(obj)
  5083. }
  5084. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5085. if (!spikeAngles) {
  5086. return
  5087. }
  5088. trapAngles = []
  5089. if (player.items[4]) {
  5090. trapAngles = makeAngles(nearBuilds, player.items[4])
  5091. if (!trapAngles) {
  5092. return
  5093. }
  5094. }
  5095. placed = []
  5096. }
  5097.  
  5098. if (fgdo(player, near) < 120) {
  5099. for (let i = 0; i < spikeAngles.length; i++) {
  5100. if (packetData.place.length < 3) {
  5101. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5102. placed.push([player.items[2], closest])
  5103. packetData.place.push([2, closest])
  5104. }
  5105. if (placed.length) {
  5106. for (let i = 0; i < placed.length; i++) {
  5107. let obj = {
  5108. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5109. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5110. scale: items.list[placed[i][0]].scale / 3,
  5111. isItem: true,
  5112. active: true,
  5113.  
  5114. }
  5115. nearBuilds.push(obj)
  5116. }
  5117. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5118. if (!spikeAngles) {
  5119. return
  5120. }
  5121. trapAngles = []
  5122. if (player.items[4]) {
  5123. trapAngles = makeAngles(nearBuilds, player.items[4])
  5124. if (!trapAngles) {
  5125. return
  5126. }
  5127. }
  5128. placed = []
  5129. }
  5130. }
  5131.  
  5132. } else {
  5133. for (let i = 0; i < trapAngles.length; i++) {
  5134. if (packetData.place.length < 3 && player.items[4]) {
  5135. let closest = (direction - trapAngles[i][0] <= direction - trapAngles[i][1] ? trapAngles[i][0] : trapAngles[i][1])
  5136. placed.push([player.items[4], closest])
  5137. packetData.place.push([4, closest])
  5138. }
  5139. if (placed.length) {
  5140. for (let i = 0; i < placed.length; i++) {
  5141. let obj = {
  5142. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5143. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5144. scale: items.list[placed[i][0]].scale / 3,
  5145. isItem: true,
  5146. active: true,
  5147.  
  5148. }
  5149. nearBuilds.push(obj)
  5150. }
  5151. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5152. if (!spikeAngles) {
  5153. return
  5154. }
  5155. trapAngles = []
  5156. if (player.items[4]) {
  5157. trapAngles = makeAngles(nearBuilds, player.items[4])
  5158. if (!trapAngles) {
  5159. return
  5160. }
  5161. }
  5162. placed = []
  5163. }
  5164. }
  5165. }
  5166. } else {
  5167. if (fgdo(player, near) < 180) {
  5168. for (let i = 0; i < spikeAngles.length; i++) {
  5169. if (packetData.place.length < 3) {
  5170. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5171. placed.push([player.items[2], closest])
  5172. packetData.place.push([2, closest])
  5173. }
  5174. if (placed.length) {
  5175. for (let i = 0; i < placed.length; i++) {
  5176. let obj = {
  5177. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5178. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5179. scale: items.list[placed[i][0]].scale / 3,
  5180. isItem: true,
  5181. active: true,
  5182.  
  5183. }
  5184. nearBuilds.push(obj)
  5185. }
  5186. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5187. if (!spikeAngles) {
  5188. return
  5189. }
  5190. trapAngles = []
  5191. if (player.items[4]) {
  5192. trapAngles = makeAngles(nearBuilds, player.items[4])
  5193. if (!trapAngles) {
  5194. return
  5195. }
  5196. }
  5197. placed = []
  5198. }
  5199. }
  5200. }
  5201. }
  5202. }
  5203.  
  5204. }
  5205. }
  5206. priorityPlace = [];
  5207. }
  5208. let advHeal = [];
  5209. class Traps {
  5210. constructor(UTILS, items) {
  5211. this.dist = 0;
  5212. this.aim = 0;
  5213. this.inTrap = false;
  5214. this.replaced = false;
  5215. this.antiTrapped = false;
  5216. this.info = {};
  5217. this.notFast = function() {
  5218. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5219. }
  5220. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5221. try {
  5222. let item = items.list[player.items[id]];
  5223. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5224. let counts = {
  5225. attempts: 0,
  5226. placed: 0
  5227. };
  5228. let tmpObjects = [];
  5229. gameObjects.forEach((p) => {
  5230. tmpObjects.push({
  5231. x: p.x,
  5232. y: p.y,
  5233. active: p.active,
  5234. blocker: p.blocker,
  5235. scale: p.scale,
  5236. isItem: p.isItem,
  5237. type: p.type,
  5238. colDiv: p.colDiv,
  5239. getScale: function(sM, ig) {
  5240. sM = sM || 1;
  5241. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  5242. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  5243. },
  5244. });
  5245. });
  5246. for (let i = first; i < repeat; i += plus) {
  5247. counts.attempts++;
  5248. let relAim = radian + i;
  5249. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5250. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5251. 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)));
  5252. if (cantPlace) continue;
  5253. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5254. place(id, relAim, 1);
  5255. tmpObjects.push({
  5256. x: tmpX,
  5257. y: tmpY,
  5258. active: true,
  5259. blocker: item.blocker,
  5260. scale: item.scale,
  5261. isItem: true,
  5262. type: null,
  5263. colDiv: item.colDiv,
  5264. getScale: function() {
  5265. return this.scale;
  5266. },
  5267. });
  5268. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5269. counts.placed++;
  5270. }
  5271. }
  5272. if (counts.placed > 0 && replacer && item.dmg) {
  5273. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs1.AutoSpikeTick) {
  5274. instaC.canSpikeTick = true;
  5275. }
  5276. }
  5277. } catch (err) {
  5278. }
  5279. };
  5280. this.checkSpikeTick = function() {
  5281. //this is my anti spike tick function which 100% confirms that u cant get spike ticked when breaking a trap
  5282. 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
  5283. try {
  5284. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5285. if ((configs1.AntiSpikeTick || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5286. // more range for safe. also testing near.primaryIndex || 5
  5287. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5288. let item = items.list[9];
  5289. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5290. let danger = 0;
  5291. let counts = {
  5292. attempts: 0,
  5293. block: `unblocked`
  5294. };
  5295. for (let i = -1; i <= 1; i += 1 / 10) {
  5296. counts.attempts++;
  5297. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5298. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5299. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5300. 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)));
  5301. if (cantPlace) continue;
  5302. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5303. danger++;
  5304. counts.block = `blocked`;
  5305. break;
  5306. }
  5307. if (danger) {
  5308. my.anti0Tick = 1;
  5309. packet('6', "pro anti tick huh? " + hir.sid);
  5310. player.chat.count = 2000;
  5311. return true;
  5312. }
  5313. }
  5314. } catch (err) {
  5315. return null;
  5316. }
  5317. return false;
  5318. }
  5319. this.protect = function(aim, trap) {
  5320. if (!configs1.AntiTrap) return;
  5321. if (trap && nears.length) {
  5322. if (getDist(near, player) > getDist(near, trap)) {
  5323. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5324. checkPlace(2, near.aim2 + i);
  5325. }
  5326. }
  5327. if (getDist(near, trap) > getDist(near, player)) {
  5328. if (player.items[4]) {
  5329. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5330. checkPlace(4, near.aim2 + i) && this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5331. }
  5332. } else {
  5333. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5334. checkPlace(2, near.aim2 + i) && this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5335. }
  5336. }
  5337. }
  5338. } else {
  5339. if (player.items[4] && player.items[2]) {
  5340. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5341. this.antiTrapped = true;
  5342. }
  5343. }
  5344. };
  5345. let placedSpikePositions = new Set();
  5346. let placedTrapPositions = new Set();
  5347. this.autoPlace = function () {
  5348. if (!configs1.AutoPlace) return;
  5349. try {
  5350. if (gameObjects.length) {
  5351. let near2 = {
  5352. inTrap: false,
  5353. };
  5354. 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];
  5355.  
  5356. if (nearTrap) {
  5357. near2.inTrap = true;
  5358. } else {
  5359. near2.inTrap = false;
  5360. }
  5361.  
  5362. if (near.dist3 <= 450) {
  5363. if (near.dist3 <= 200) {
  5364. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5365. inTrap: near2.inTrap
  5366. });
  5367. } else {
  5368. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5369. }
  5370. }
  5371. } else {
  5372. if (near.dist3 <= 450) {
  5373. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5374. }
  5375. }
  5376. const trap1 = gameObjects
  5377. .filter((e) => e.trap && e.active)
  5378. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5379. .find((trap) => {
  5380. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5381. return (
  5382. trap !== player &&
  5383. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5384. trapDist <= 50
  5385. );
  5386. });
  5387.  
  5388. if (trap1 && near.dist2 <= 160) {
  5389. const trapX = trap1.x;
  5390. const trapY = trap1.y;
  5391. const circleRadius = 102;
  5392. const numPositions = 64;
  5393.  
  5394. for (let i = 0; i < numPositions; i++) {
  5395. const angle = (2 * Math.PI * i) / numPositions;
  5396. const offsetX = trapX + circleRadius * Math.cos(angle);
  5397. const offsetY = trapY + circleRadius * Math.sin(angle);
  5398. const position = [offsetX, offsetY];
  5399. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5400.  
  5401. if (
  5402. !placedSpikePositions.has(JSON.stringify(position)) &&
  5403. isPositionValid(position) &&
  5404. distToPlayer <= 87
  5405. ) {
  5406. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5407. checkPlace(2, angleToPlace);
  5408. placedSpikePositions.add(JSON.stringify(position));
  5409. }
  5410. }
  5411. } else if (!trap1 && near.dist2 <= 206) {
  5412. placedSpikePositions.clear();
  5413. const maxTrapsToPlace = 3;
  5414. const trapRadius = 50;
  5415. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5416. let trapsPlaced = 0;
  5417.  
  5418. for (const position of trapPositions) {
  5419. if (
  5420. trapsPlaced < maxTrapsToPlace &&
  5421. !placedTrapPositions.has(JSON.stringify(position)) &&
  5422. isPositionValid(position)
  5423. ) {
  5424. checkPlace(4, ...position);
  5425. placedTrapPositions.add(JSON.stringify(position));
  5426. trapsPlaced++;
  5427. }
  5428. }
  5429. }
  5430. } catch (e) {
  5431. console.log(e);
  5432. }
  5433. };
  5434. function calculatePerfectAngle(x1, y1, x2, y2) {
  5435. return Math.atan2(y2 - y1, x2 - x1);
  5436. }
  5437. function antiSpikeTickEz() {
  5438. 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
  5439. }
  5440. function fgdo(a, b) {
  5441. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  5442. }
  5443. let spikSync = false;
  5444. let spikePlaced = false;
  5445.  
  5446. this.replacer = function(findObj) {
  5447. if (!findObj || !configs.autoReplace) return;
  5448. if (!inGame) return;
  5449. if (this.antiTrapped) return;
  5450. game.tickBase(() => {
  5451. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5452. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5453. let perfectAngle = Math.round(calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y) / (Math.PI / 2)) * (Math.PI / 2);
  5454. 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;
  5455. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5456. let danger = this.checkSpikeTick();
  5457. if (objDst <= 300 && near.dist2 <= 400) {
  5458. if (near.dist2 <= 70 && canPlaceCondition && configs.spikeTick) {
  5459. this.testCanPlace(2, -Math.PI/4, Math.PI/4, (Math.PI / 20), near.aim2, 1);
  5460. this.testCanPlace(4, -Math.PI/4, Math.PI/4, Math.PI/12, near.aim2+Math.PI, 1)
  5461. } else if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5462. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5463. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5464. } else {
  5465. player.items[4] == 15 && this.testCanPlace(near.dist2 > 250 ? 4 : 2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5466. }
  5467. this.replaced = true;
  5468. }
  5469. }, 1);
  5470. };
  5471. }
  5472. };
  5473. class Instakill {
  5474. constructor() {
  5475. this.wait = false;
  5476. this.can = false;
  5477. this.isTrue = false;
  5478. this.nobull = false;
  5479. this.ticking = false;
  5480. this.canSpikeTick = false;
  5481. this.startTick = false;
  5482. this.readyTick = false;
  5483. this.canCounter = false;
  5484. this.revTick = false;
  5485. this.syncHit = false;
  5486. this.changeType = function (type) {
  5487. this.wait = false;
  5488. this.isTrue = true;
  5489. my.autoAim = true;
  5490. let instaLog = [type];
  5491. let backupNobull = near.backupNobull;
  5492. near.backupNobull = false;
  5493. game.tickBase(() => {
  5494. instaLog.push(player.skinIndex);
  5495. game.tickBase(() => {
  5496. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5497. near.backupNobull = true;
  5498. }
  5499. instaLog.push(player.skinIndex);
  5500. }, 1);
  5501. }, 1);
  5502. if (type == "rev") {
  5503. selectWeapon(player.weapons[1]);
  5504. buyEquip(53, 0);
  5505. buyEquip(21, 1);
  5506. sendAutoGather();
  5507. game.tickBase(() => {
  5508. selectWeapon(player.weapons[0]);
  5509. buyEquip(7, 0);
  5510. buyEquip(21, 1);
  5511. game.tickBase(() => {
  5512. sendAutoGather();
  5513. this.isTrue = false;
  5514. my.autoAim = false;
  5515. }, 1);
  5516. }, 1);
  5517. } else if (type == "nobull") {
  5518. selectWeapon(player.weapons[0]);
  5519. if (getEl("backupNobull").checked && backupNobull) {
  5520. buyEquip(7, 0);
  5521. } else {
  5522. buyEquip(6, 0);
  5523. }
  5524. buyEquip(21, 1);
  5525. sendAutoGather();
  5526. game.tickBase(() => {
  5527. if (near.skinIndex == 22) {
  5528. if (getEl("backupNobull").checked) {
  5529. near.backupNobull = true;
  5530. }
  5531. buyEquip(21, 0);
  5532. } else {
  5533. buyEquip(53, 0);
  5534. }
  5535. selectWeapon(player.weapons[1]);
  5536. buyEquip(21, 1);
  5537. game.tickBase(() => {
  5538. sendAutoGather();
  5539. this.isTrue = false;
  5540. my.autoAim = false;
  5541. }, 1);
  5542. }, 1);
  5543. } else if (type == "normal") {
  5544. selectWeapon(player.weapons[0]);
  5545. buyEquip(7, 0);
  5546. buyEquip(21, 1);
  5547. sendAutoGather();
  5548. game.tickBase(() => {
  5549. selectWeapon(player.weapons[1]);
  5550. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5551. buyEquip(21, 1);
  5552. game.tickBase(() => {
  5553. sendAutoGather();
  5554. this.isTrue = false;
  5555. my.autoAim = false;
  5556. }, 1);
  5557. }, 1);
  5558. } else {
  5559. setTimeout(() => {
  5560. this.isTrue = false;
  5561. my.autoAim = false;
  5562. }, 50);
  5563. }
  5564. };
  5565. this.spikeTickType = function () {
  5566. this.isTrue = true;
  5567. my.autoAim = true;
  5568. selectWeapon(player.weapons[0]);
  5569. buyEquip(7, 0);
  5570. buyEquip(21, 1);
  5571. sendAutoGather();
  5572. game.tickBase(() => {
  5573. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5574. selectWeapon(player.weapons[0]);
  5575. buyEquip(53, 0);
  5576. buyEquip(21, 1);
  5577. game.tickBase(() => {
  5578. sendAutoGather();
  5579. this.isTrue = false;
  5580. my.autoAim = false;
  5581. }, 1);
  5582. } else {
  5583. sendAutoGather();
  5584. this.isTrue = false;
  5585. my.autoAim = false;
  5586. }
  5587. }, 1);
  5588. };
  5589. this.counterType = function () {
  5590. this.isTrue = true;
  5591. my.autoAim = true;
  5592. selectWeapon(player.weapons[0]);
  5593. buyEquip(7, 0);
  5594. buyEquip(21, 1);
  5595. sendAutoGather();
  5596. game.tickBase(() => {
  5597. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5598. selectWeapon(player.weapons[0]);
  5599. buyEquip(53, 0);
  5600. buyEquip(21, 1);
  5601. game.tickBase(() => {
  5602. sendAutoGather();
  5603. this.isTrue = false;
  5604. my.autoAim = false;
  5605. }, 1);
  5606. } else {
  5607. sendAutoGather();
  5608. this.isTrue = false;
  5609. my.autoAim = false;
  5610. }
  5611. }, 1);
  5612. };
  5613. this.rangeType = function (type) {
  5614. this.isTrue = true;
  5615. my.autoAim = true;
  5616. if (type == "ageInsta") {
  5617. my.ageInsta = false;
  5618. if (player.items[5] == 18) {
  5619. place(5, near.aim2);
  5620. }
  5621. packet("I", undefined, 1);
  5622. buyEquip(22, 0);
  5623. buyEquip(21, 1);
  5624. game.tickBase(() => {
  5625. selectWeapon(player.weapons[1]);
  5626. buyEquip(53, 0);
  5627. buyEquip(21, 1);
  5628. sendAutoGather();
  5629. game.tickBase(() => {
  5630. sendUpgrade(12);
  5631. selectWeapon(player.weapons[1]);
  5632. buyEquip(53, 0);
  5633. buyEquip(21, 1);
  5634. game.tickBase(() => {
  5635. sendUpgrade(15);
  5636. selectWeapon(player.weapons[1]);
  5637. buyEquip(53, 0);
  5638. buyEquip(21, 1);
  5639. game.tickBase(() => {
  5640. sendAutoGather();
  5641. this.isTrue = false;
  5642. my.autoAim = false;
  5643. }, 1);
  5644. }, 1);
  5645. }, 1);
  5646. }, 1);
  5647. } else {
  5648. selectWeapon(player.weapons[1]);
  5649. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5650. buyEquip(53, 0);
  5651. } else {
  5652. buyEquip(20, 0);
  5653. }
  5654. buyEquip(11, 1);
  5655. sendAutoGather();
  5656. game.tickBase(() => {
  5657. sendAutoGather();
  5658. this.isTrue = false;
  5659. my.autoAim = false;
  5660. }, 1);
  5661. }
  5662. };
  5663. this.boostTickType = function() {
  5664. /*this.isTrue = true;
  5665. my.autoAim = true;
  5666. selectWeapon(player.weapons[0]);
  5667. buyEquip(53, 0);
  5668. buyEquip(11, 1);
  5669. packet("a", near.aim2);
  5670. game.tickBase(() => {
  5671. place(4, near.aim2);
  5672. selectWeapon(player.weapons[1]);
  5673. biomeGear();
  5674. buyEquip(11, 1);
  5675. sendAutoGather();
  5676. packet("a", near.aim2);
  5677. game.tickBase(() => {
  5678. selectWeapon(player.weapons[0]);
  5679. buyEquip(7, 0);
  5680. buyEquip(19, 1);
  5681. packet("a", near.aim2);
  5682. game.tickBase(() => {
  5683. sendAutoGather();
  5684. this.isTrue = false;
  5685. my.autoAim = false;
  5686. packet("a", undefined);
  5687. }, 1);
  5688. }, 1);
  5689. }, 1);*/
  5690. this.isTrue = true;
  5691. my.autoAim = true;
  5692. biomeGear();
  5693. buyEquip(11, 1);
  5694. packet("a", near.aim2, 1);
  5695. game.tickBase(() => {
  5696. if (player.weapons[1] == 15) {
  5697. my.revAim = true;
  5698. }
  5699. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5700. buyEquip(53, 0);
  5701. buyEquip(11, 1);
  5702. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5703. sendAutoGather();
  5704. }
  5705. packet("a", near.aim2, 1);
  5706. place(4, near.aim2);
  5707. game.tickBase(() => {
  5708. my.revAim = false;
  5709. selectWeapon(player.weapons[0]);
  5710. buyEquip(7, 0);
  5711. buyEquip(19, 1);
  5712. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5713. sendAutoGather();
  5714. }
  5715. packet("a", near.aim2, 1);
  5716. game.tickBase(() => {
  5717. sendAutoGather();
  5718. this.isTrue = false;
  5719. my.autoAim = false;
  5720. packet("a", undefined, 1);
  5721. }, 1);
  5722. }, 1);
  5723. }, 1);
  5724. };
  5725. this.gotoGoal = function(goto, OT) {
  5726. let slowDists = (weeeee) => weeeee * config.playerScale;
  5727. let goal = {
  5728. a: goto - OT,
  5729. b: goto + OT,
  5730. c: goto - slowDists(1),
  5731. d: goto + slowDists(1),
  5732. e: goto - slowDists(2),
  5733. f: goto + slowDists(2),
  5734. g: goto - slowDists(4),
  5735. h: goto + slowDists(4)
  5736. };
  5737. let bQ = function(wwww, awwww) {
  5738. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5739. buyEquip(31, 0);
  5740. } else {
  5741. buyEquip(wwww, awwww);
  5742. }
  5743. }
  5744. if (enemy.length) {
  5745. let dst = near.dist2;
  5746. this.ticking = true;
  5747. if (dst >= goal.a && dst <= goal.b) {
  5748. bQ(22, 0);
  5749. bQ(11, 1);
  5750. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5751. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5752. }
  5753. return {
  5754. dir: undefined,
  5755. action: 1
  5756. };
  5757. } else {
  5758. if (dst < goal.a) {
  5759. if (dst >= goal.g) {
  5760. if (dst >= goal.e) {
  5761. if (dst >= goal.c) {
  5762. bQ(40, 0);
  5763. bQ(10, 1);
  5764. if (configs.none) {
  5765. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5766. } else {
  5767. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5768. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5769. }
  5770. }
  5771. } else {
  5772. bQ(22, 0);
  5773. bQ(19, 1);
  5774. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5775. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5776. }
  5777. }
  5778. } else {
  5779. bQ(6, 0);
  5780. bQ(12, 1);
  5781. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5782. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5783. }
  5784. }
  5785. } else {
  5786. biomeGear();
  5787. bQ(11, 1);
  5788. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5789. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5790. }
  5791. }
  5792. return {
  5793. dir: near.aim2 + Math.PI,
  5794. action: 0
  5795. };
  5796. } else if (dst > goal.b) {
  5797. if (dst <= goal.h) {
  5798. if (dst <= goal.f) {
  5799. if (dst <= goal.d) {
  5800. bQ(40, 0);
  5801. bQ(9, 1);
  5802. if (configs.none) {
  5803. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5804. } else {
  5805. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5806. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5807. }
  5808. }
  5809. } else {
  5810. bQ(22, 0);
  5811. bQ(19, 1);
  5812. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5813. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5814. }
  5815. }
  5816. } else {
  5817. bQ(6, 0);
  5818. bQ(12, 1);
  5819. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5820. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5821. }
  5822. }
  5823. } else {
  5824. biomeGear();
  5825. bQ(11, 1);
  5826. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5827. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5828. }
  5829. }
  5830. return {
  5831. dir: near.aim2,
  5832. action: 0
  5833. };
  5834. }
  5835. return {
  5836. dir: undefined,
  5837. action: 0
  5838. };
  5839. }
  5840. } else {
  5841. this.ticking = false;
  5842. return {
  5843. dir: undefined,
  5844. action: 0
  5845. };
  5846. }
  5847. }
  5848. /** wait 1 tick for better quality */
  5849. this.bowMovement = function() {
  5850. let moveMent = this.gotoGoal(685, 3);
  5851. if (moveMent.action) {
  5852. if (player.reloads[53] == 0 && !this.isTrue) {
  5853. this.rangeType("ageInsta");
  5854. } else {
  5855. packet("a", moveMent.dir, 1);
  5856. }
  5857. } else {
  5858. packet("a", moveMent.dir, 1);
  5859. }
  5860. },
  5861. this.tickMovement = function() {
  5862. let dist = player.weapons[1] == 9 ? 240 : 240;
  5863. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5864. let moveMent = this.gotoGoal(238, 3);
  5865. if (moveMent.action) {
  5866. if (player.reloads[53] == 0 && !this.isTrue) {
  5867. this.boostTickType();
  5868. } else {
  5869. packet("a", moveMent.dir, 1);
  5870. }
  5871. } else {
  5872. packet("a", moveMent.dir, 1);
  5873. }
  5874. },
  5875. this.kmTickMovement = function() {
  5876. let moveMent = this.gotoGoal(240, 3);
  5877. if (moveMent.action) {
  5878. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5879. this.kmTickType();
  5880. } else {
  5881. packet("a", moveMent.dir, 1);
  5882. }
  5883. } else {
  5884. packet("a", moveMent.dir, 1);
  5885. }
  5886. },
  5887. this.boostTickMovement = function() {
  5888. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 140;
  5889. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5890. let moveMent = this.gotoGoal(372, 3);
  5891. if (moveMent.action) {
  5892. if (player.reloads[53] == 0 && !this.isTrue) {
  5893. this.boostTickType();
  5894. } else {
  5895. packet("a", moveMent.dir, 1);
  5896. }
  5897. } else {
  5898. packet("a", moveMent.dir, 1);
  5899. }
  5900. }
  5901. /** wait 1 tick for better quality */
  5902. this.perfCheck = function(pl, nr) {
  5903. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5904. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5905. let pjs = {
  5906. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5907. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5908. };
  5909. 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)) {
  5910. return true;
  5911. }
  5912. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5913. 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)) {
  5914. return true;
  5915. }
  5916. });
  5917. if (finds) return false;
  5918. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5919. let tmpScale = tmp.getScale();
  5920. 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)) {
  5921. return true;
  5922. }
  5923. });
  5924. if (finds) return false;
  5925. return true;
  5926. }
  5927. }
  5928. };
  5929. class Autobuy {
  5930. constructor(buyHat, buyAcc) {
  5931. this.hat = function() {
  5932. buyHat.forEach((id) => {
  5933. let find = findID(hats, id);
  5934. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5935. });
  5936. };
  5937. this.acc = function() {
  5938. buyAcc.forEach((id) => {
  5939. let find = findID(accessories, id);
  5940. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5941. });
  5942. };
  5943. }
  5944. };
  5945.  
  5946. class Autoupgrade {
  5947. constructor() {
  5948. this.sb = function(upg) {
  5949. upg(3);
  5950. upg(17);
  5951. upg(31);
  5952. upg(23);
  5953. upg(9);
  5954. upg(38);
  5955. };
  5956. this.kh = function(upg) {
  5957. upg(3);
  5958. upg(17);
  5959. upg(31);
  5960. upg(23);
  5961. upg(10);
  5962. upg(38);
  5963. upg(4);
  5964. upg(25);
  5965. };
  5966. this.pb = function(upg) {
  5967. upg(5);
  5968. upg(17);
  5969. upg(32);
  5970. upg(23);
  5971. upg(9);
  5972. upg(38);
  5973. };
  5974. this.ph = function(upg) {
  5975. upg(5);
  5976. upg(17);
  5977. upg(32);
  5978. upg(23);
  5979. upg(10);
  5980. upg(38);
  5981. upg(28);
  5982. upg(25);
  5983. };
  5984. this.db = function(upg) {
  5985. upg(7);
  5986. upg(17);
  5987. upg(31);
  5988. upg(23);
  5989. upg(9);
  5990. upg(34);
  5991. };
  5992. };
  5993. };
  5994.  
  5995. class Damages {
  5996. constructor(items) {
  5997. // 0.75 1 1.125 1.5
  5998. this.calcDmg = function(dmg, val) {
  5999. return dmg * val;
  6000. };
  6001. this.getAllDamage = function(dmg) {
  6002. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  6003. };
  6004. this.weapons = [];
  6005. for (let i = 0; i < items.weapons.length; i++) {
  6006. let wp = items.weapons[i];
  6007. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  6008. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  6009. this[name] = this.weapons[i];
  6010. }
  6011. }
  6012. }
  6013.  
  6014. /** CLASS CODES */
  6015. // jumpscare code warn
  6016. let tmpList = [];
  6017. // LOADING:
  6018. let UTILS = new Utils();
  6019. let items = new Items();
  6020. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6021. let store = new Store();
  6022. let hats = store.hats;
  6023. let accessories = store.accessories;
  6024. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6025. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6026. let textManager = new Textmanager();
  6027. let traps = new Traps(UTILS, items);
  6028. let instaC = new Instakill();
  6029. let autoBuy = new Autobuy([15, 31, 6, 7, 22, 12, 53, 26, 20, 40], [11, 13, 19, 18, 21]);
  6030. let autoUpgrade = new Autoupgrade();
  6031. let lastDeath;
  6032. let minimapData;
  6033. let mapMarker = {};
  6034. let mapPings = [];
  6035. let tmpPing;
  6036. let breakTrackers = [];
  6037. let pathFindTest = 0;
  6038. let grid = [];
  6039. let pathFind = {
  6040. active: false,
  6041. grid: 40,
  6042. scale: 1440,
  6043. x: 14400,
  6044. y: 14400,
  6045. chaseNear: false,
  6046. array: [],
  6047. lastX: this.grid / 2,
  6048. lastY: this.grid / 2
  6049. };
  6050. function sendChat(message) {
  6051. packet("6", message.slice(0, 30));
  6052. }
  6053. let runAtNextTick = [];
  6054. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6055. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6056. let projOffset = config.playerScale * 2;
  6057. let projXY = {
  6058. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6059. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6060. };
  6061. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6062. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6063. })[0];
  6064. if (nearPlayer) {
  6065. if (indx == 1) {
  6066. nearPlayer.shooting[53] = 1;
  6067. } else {
  6068. nearPlayer.shootIndex = weaponIndx;
  6069. nearPlayer.shooting[1] = 1;
  6070. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6071. }
  6072. }
  6073. }
  6074. let projectileCount = 0;
  6075. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6076. if (!tmpObj.isTeam(player)) {
  6077. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6078. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6079. tmpObj.bowThreat[weaponIndex]++;
  6080. if (index == 5) {
  6081. projectileCount++;
  6082. }
  6083. setTimeout(() => {
  6084. tmpObj.bowThreat[weaponIndex]--;
  6085. if (index == 5) {
  6086. projectileCount--;
  6087. }
  6088. }, range / speed);
  6089. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6090. place(1, tmpObj.aim2);
  6091. my.anti0Tick = 4;
  6092. if (!my.antiSync) {
  6093. antiSyncHealing(4);
  6094. }
  6095. } else {
  6096. if (projectileCount >= 2) {
  6097. place(1, tmpObj.aim2);
  6098. my.anti0Tick = 4;
  6099. if (!my.antiSync) {
  6100. antiSyncHealing(4);
  6101. }
  6102. }
  6103. }
  6104. }
  6105. }
  6106. }
  6107. // SHOW ITEM INFO:
  6108. function showItemInfo(item, isWeapon, isStoreItem) {
  6109. if (player && item) {
  6110. UTILS.removeAllChildren(itemInfoHolder);
  6111. itemInfoHolder.classList.add("visible");
  6112. UTILS.generateElement({
  6113. id: "itemInfoName",
  6114. text: UTILS.capitalizeFirst(item.name),
  6115. parent: itemInfoHolder
  6116. });
  6117. UTILS.generateElement({
  6118. id: "itemInfoDesc",
  6119. text: item.desc,
  6120. parent: itemInfoHolder
  6121. });
  6122. if (isStoreItem) {
  6123. } else if (isWeapon) {
  6124. UTILS.generateElement({
  6125. class: "itemInfoReq",
  6126. text: !item.type ? "primary" : "secondary",
  6127. parent: itemInfoHolder
  6128. });
  6129. } else {
  6130. for (let i = 0; i < item.req.length; i += 2) {
  6131. UTILS.generateElement({
  6132. class: "itemInfoReq",
  6133. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6134. parent: itemInfoHolder
  6135. });
  6136. }
  6137. if (item.group.limit) {
  6138. UTILS.generateElement({
  6139. class: "itemInfoLmt",
  6140. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6141. parent: itemInfoHolder
  6142. });
  6143. }
  6144. }
  6145. } else {
  6146. itemInfoHolder.classList.remove("visible");
  6147. }
  6148. }
  6149. // RESIZE:
  6150. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6151. function resize() {
  6152. screenWidth = window.innerWidth;
  6153. screenHeight = window.innerHeight;
  6154. var scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6155. gameCanvas.width = screenWidth;
  6156. gameCanvas.height = screenHeight;
  6157. gameCanvas.style.width = screenWidth + "px";
  6158. gameCanvas.style.height = screenHeight + "px";
  6159. gameCanvas.style;
  6160. mainContext.setTransform(scaleFillNative, 0, 0, scaleFillNative, (screenWidth * pixelDensity - maxScreenWidth * scaleFillNative) / 2, (screenHeight * pixelDensity - maxScreenHeight * scaleFillNative) / 2);
  6161. }
  6162. resize();
  6163. // MOUSE INPUT:
  6164. const mals = document.getElementById('touch-controls-fullscreen');
  6165. mals.style.display = 'block';
  6166. mals.addEventListener("mousemove", gameInput, false);
  6167. function gameInput(e) {
  6168. mouseX = e.clientX;
  6169. mouseY = e.clientY;
  6170. }
  6171. let clicks = {
  6172. left: false,
  6173. middle: false,
  6174. right: false,
  6175. };
  6176. mals.addEventListener("mousedown", mouseDown, false);
  6177. function mouseDown(e) {
  6178. if (attackState != 1) {
  6179. attackState = 1;
  6180. if (e.button == 0) {
  6181. clicks.left = true;
  6182. } else if (e.button == 1) {
  6183. clicks.middle = true;
  6184. } else if (e.button == 2) {
  6185. clicks.right = true;
  6186. }
  6187. }
  6188. }
  6189. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6190. function mouseUp(e) {
  6191. if (attackState != 0) {
  6192. attackState = 0;
  6193. if (e.button == 0) {
  6194. clicks.left = false;
  6195. } else if (e.button == 1) {
  6196. clicks.middle = false;
  6197. } else if (e.button == 2) {
  6198. clicks.right = false;
  6199. }
  6200. }
  6201. }
  6202. mals.addEventListener("wheel", wheel, false);
  6203. function wheel(e) {
  6204. if (e.deltaY < 0) {
  6205. my.reSync = true;
  6206. } else {
  6207. my.reSync = false;
  6208. }
  6209. }
  6210. // INPUT UTILS:
  6211. function getMoveDir() {
  6212. let dx = 0;
  6213. let dy = 0;
  6214. for (let key in moveKeys) {
  6215. let tmpDir = moveKeys[key];
  6216. dx += !!keys[key] * tmpDir[0];
  6217. dy += !!keys[key] * tmpDir[1];
  6218. }
  6219. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6220. }
  6221. function getSafeDir() {
  6222. if (!player)
  6223. return 0;
  6224. if (!player.lockDir) {
  6225. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6226. }
  6227. return lastDir || 0;
  6228. }
  6229. function getAttackDir(debug) {
  6230. if (debug) {
  6231. if (!player)
  6232. return "0";
  6233.  
  6234. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6235. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6236. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6237. lastDir = "getSafeDir()";
  6238. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6239. lastDir = "traps.aim";
  6240. } else if (!player.lockDir) {
  6241. if (configs.noDir) return "undefined";
  6242. lastDir = "getSafeDir()";
  6243. }
  6244.  
  6245. return lastDir;
  6246. } else {
  6247. if (!player)
  6248. return 0;
  6249.  
  6250. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6251. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6252. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6253. lastDir = getSafeDir();
  6254. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6255. lastDir = traps.aim;
  6256. } else if (!player.lockDir) {
  6257. if (configs.noDir) return undefined;
  6258. lastDir = getSafeDir();
  6259. }
  6260.  
  6261. return lastDir || 0;
  6262. }
  6263. }
  6264.  
  6265. function getVisualDir() {
  6266. if (!player)
  6267. return 0;
  6268.  
  6269. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6270. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6271. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6272. lastDir = getSafeDir();
  6273. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6274. lastDir = traps.aim;
  6275. } else if (!player.lockDir) {
  6276. lastDir = getSafeDir();
  6277. }
  6278.  
  6279. return lastDir || 0;
  6280. }
  6281.  
  6282. // Funkce pro kontrolu, zda jste pobli? hra?e
  6283. function isNearPlayer() {
  6284. return near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap;
  6285. buyEquip(21, 1);
  6286. }
  6287. // KEYS:
  6288. function keysActive() {
  6289. return (allianceMenu.style.display != "block" &&
  6290. chatHolder.style.display != "block" &&
  6291. !menuCBFocus);
  6292. }
  6293. function toggleMenuChat() {
  6294. if (menuChatDiv.style.display != "none") {
  6295. chatHolder.style.display = "none";
  6296. if (menuChatBox.value != "") {
  6297. //commands[command.slice(1)]
  6298. let cmd = function(command) {
  6299. return {
  6300. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6301. fv: commands[command.slice(1).split(" ")[0]]
  6302. }
  6303. }
  6304. let command = cmd(menuChatBox.value);
  6305. if (command.found) {
  6306. if (typeof command.fv.action === "function") {
  6307. command.fv.action(menuChatBox.value);
  6308. }
  6309. } else {
  6310. sendChat(menuChatBox.value);
  6311. }
  6312. menuChatBox.value = "";
  6313. menuChatBox.blur();
  6314. } else {
  6315. if (menuCBFocus) {
  6316. menuChatBox.blur();
  6317. } else {
  6318. menuChatBox.focus();
  6319. }
  6320. }
  6321. }
  6322. }
  6323.  
  6324. window.botMove = false;
  6325. window.freeCam = {x:null,y:null}
  6326. let switchBotMode = ()=>{
  6327. window.botMove = !window.botMove;
  6328. if(window.botMove){
  6329. window.freeCam = {x:player.x2,y:player.y2}
  6330. }
  6331. }
  6332. window.allowCombo = false;
  6333. window.botVisual = false;
  6334. function keyDown(event) {
  6335. let keyNum = event.which || event.keyCode || 0;
  6336. if (player && player.alive && keysActive()) {
  6337. if (!keys[keyNum]) {
  6338. keys[keyNum] = 1;
  6339. macro[event.key] = 1;
  6340. if (keyNum == 27) {
  6341. openMenu = !openMenu;
  6342. $("#menuDiv").toggle();
  6343. $("#menuChatDiv").toggle();
  6344. } else if (keyNum == 69) {
  6345. sendAutoGather();
  6346. } else if (keyNum == 67) {
  6347. updateMapMarker();
  6348. } else if (player.weapons[keyNum - 49] != undefined) {
  6349. player.weaponCode = player.weapons[keyNum - 49];
  6350. } else if (moveKeys[keyNum]) {
  6351. sendMoveDir();
  6352. } else if (event.key == "m") {
  6353. mills.placeSpawnPads = !mills.placeSpawnPads;
  6354. } else if (event.key == "z") {
  6355. mills.place = !mills.place;
  6356. } else if (event.key == "Z") {
  6357. typeof window.debug == "function" && window.debug();
  6358. } else if (keyNum == 32) {
  6359. packet("d", 1, getSafeDir(), 1);
  6360. packet("d", 0, getSafeDir(), 1);
  6361. } else if (event.key == ",") {
  6362. player.sync = true;
  6363. }else if(event.key == 'x'&&window.VirusterDev){
  6364. sendChat('HaHa'+window.pingTime.toString()+'L'+UTILS.getDistance(near.x, near.y, player.x, player.y))
  6365. window.syncMode = true;
  6366. setTimeout(()=>{
  6367. window.syncMode = false;
  6368. },1000)
  6369. }
  6370.  
  6371. if(window.VirusterDev){//virusterdevs keycombos for bots, u can use if want. is op
  6372. if(event.key == 'q'){
  6373. window.allowCombo = !window.allowCombo
  6374. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'keystroke combo '+(window.allowCombo?'on':'off'), '#fff', 2);
  6375. }
  6376. if(event.key=='1'&&window.allowCombo){
  6377. getEl("mode").value = 'zync'
  6378. window.allowCombo = false
  6379. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'follow', '#fff', 2);
  6380. }
  6381. if(event.key=='2'&&window.allowCombo){
  6382. getEl("mode").value = 'fuckemup'
  6383. window.allowCombo = false
  6384. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'break', '#fff', 2);
  6385. }
  6386. if(event.key=='3'&&window.allowCombo){
  6387. getEl("mode").value = 'fight'
  6388. window.allowCombo = false
  6389. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'on sight', '#fff', 2);
  6390. }
  6391. if(event.key=='4'&&window.allowCombo){
  6392. getEl("mode").value = 'flex'
  6393. window.allowCombo = false
  6394. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'flex', '#fff', 2);
  6395. }
  6396. if(event.key=='5'&&window.allowCombo){
  6397. getEl("mode").value = 'stopp'
  6398. window.stopSpot = {x2:player.x2,y2:player.y2}
  6399. window.allowCombo = false
  6400. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'stop', '#fff', 2);
  6401. }
  6402. if(event.key=='`'&&window.allowCombo){
  6403. getEl("mode").value = 'mouse'
  6404. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'mouse', '#fff', 2);
  6405. window.allowCombo = false
  6406. }
  6407.  
  6408. if(event.key=='x'&&window.allowCombo&&bots.length>1){
  6409.  
  6410. if(window.botVisual == false){
  6411. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'bot freecam on', '#fff', 2);
  6412. window.botVisual = botz[Math.floor(Math.random()*botz.length)].sid
  6413. }else{
  6414. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'bot freecam off', '#fff', 2);
  6415. window.botVisual = false;
  6416. }
  6417. window.allowCombo = false
  6418. } else if(event.key=='x'&&!window.allowCombo&&bots.length>1&&window.botVisual!==false){
  6419. window.botVisual = botz[Math.floor(Math.random()*botz.length)].sid
  6420. window.allowCombo = false
  6421. }
  6422. }
  6423. }
  6424. }
  6425. }
  6426. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6427. function keyUp(event) {
  6428. if (player && player.alive) {
  6429. let keyNum = event.which || event.keyCode || 0;
  6430. if (keyNum == 13) {
  6431. // toggleMenuChat();
  6432. } else if (keysActive()) {
  6433. if (keys[keyNum]) {
  6434. keys[keyNum] = 0;
  6435. macro[event.key] = 0;
  6436. if (moveKeys[keyNum]) {
  6437. sendMoveDir();
  6438. } else if (event.key == ",") {
  6439. player.sync = false;
  6440. }
  6441. }
  6442. }
  6443. }
  6444. }
  6445. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6446. function sendMoveDir() {
  6447. let newMoveDir = getMoveDir();
  6448. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6449. if (!my.autoPush) {
  6450. packet("a", newMoveDir, 1);
  6451. }
  6452. lastMoveDir = newMoveDir;
  6453. }
  6454. }
  6455. // BUTTON EVENTS:
  6456. function bindEvents() { }
  6457. bindEvents();
  6458. /** PATHFIND TEST */
  6459. function chechPathColl(tmp) {
  6460. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6461. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6462. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6463. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6464. }
  6465. function checkObject() {
  6466. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6467. for (let y = 0; y < pathFind.grid; y++) {
  6468. grid[y] = [];
  6469. for (let x = 0; x < pathFind.grid; x++) {
  6470. let tmpXY = {
  6471. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6472. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6473. }
  6474. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6475. pathFind.lastX = x;
  6476. pathFind.lastY = y;
  6477. grid[y][x] = 0;
  6478. continue;
  6479. }
  6480. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6481. if (find) {
  6482. if (find.trap) {
  6483. grid[y][x] = 0;
  6484. continue;
  6485. }
  6486. grid[y][x] = 1;
  6487. } else {
  6488. grid[y][x] = 0;
  6489. }
  6490. }
  6491. }
  6492. }
  6493. function toFancyTimeFormat(time) {
  6494. let minutes = ~~((time % 3600) / 60);
  6495. let seconds = ~~time % 60;
  6496. if (seconds <= 9) seconds = `0${seconds}`;
  6497. return `${minutes}:${seconds}`;
  6498. }
  6499. let song = {
  6500. '0:13': 'Clean up gang with a hoover,',
  6501. '0:15': 'pull up and sweep the street',
  6502. '0:17': 'Told bae book Park Chinois,',
  6503. '0:18': 'the bricks came cheap',
  6504. '0:19': 'this week',
  6505. '0:20': 'Brought out the glee',
  6506. '0:21': 'this week,',
  6507. '0:22': 'so somethin might end up',
  6508. '0:23': 'on a tee this week',
  6509. '0:24': 'Done studio time done the re',
  6510. '0:25': 'this week,',
  6511. '0:26': 'big bustdown',
  6512. '0:27': "that ain't no Jesus piece",
  6513. '0:28': 'No G17,G19 had the G17',
  6514. '0:29': 'then the G19',
  6515. '0:30': 'Had an old .44',
  6516. '0:31': 'but the pin was weak,',
  6517. '0:32': 'still gonna spin if need',
  6518. '0:35': 'Sayin no smoke backstage,',
  6519. '0:36': 'but bro still ask',
  6520. '0:37': 'can we bring it please,',
  6521. '0:38': 'or a ZK at least',
  6522. '0:40': 'You could see me',
  6523. '0:41': 'in tape with the Gs,',
  6524. '0:42': 'bro just got in a',
  6525. '0:43': 'striptape with the Gs',
  6526. '0:44': "Get the drop it's go time,",
  6527. '0:45': 'bro came out with the key',
  6528. '0:47': 'Yo, 38 autos gang said',
  6529. '0:48': 'we need more sweets',
  6530. '0:50': 'Before Halloween,',
  6531. '0:51': 'we was out playin',
  6532. '0:52': 'trick or treat',
  6533. '0:53': 'An opp boy swam and drowned,',
  6534. '0:55': "he didn't kick his feet",
  6535. '0:57': 'Heard that news',
  6536. '0:58': 'I was right by the runaway,',
  6537. '0:59': 'made me feel like bree',
  6538. '1:00': 'This C comes like',
  6539. '1:01': 'a pocket rocket,',
  6540. '1:02': 'now the gang',
  6541. '1:03': 'in central with C',
  6542. '1:04': 'Had my case papers printed,',
  6543. '1:05': 'now I got the monogram',
  6544. '1:06': 'print on me',
  6545. '1:07': 'Runnin throught bells,',
  6546. '1:08': 'throwback run with the 12',
  6547. '1:10': 'Whole 1 cover the scales,',
  6548. '1:11': 'bine at the barbeque,',
  6549. '1:12': 'better cover your girl',
  6550. '1:14': "Hate when they're",
  6551. '1:15': 'runnin their mouth,',
  6552. '1:16': 'see them runnin for help',
  6553. '1:17': "I'm in the Bando,",
  6554. '1:18': 'but let me see my man again,',
  6555. '1:19': "and I'll double the L",
  6556. '1:21': 'We really leave shit drownin,',
  6557. '1:22': "you ain't brought 3",
  6558. '1:23': 'on an outin',
  6559. '1:24': 'Shootouts in',
  6560. '1:25': 'the oldest clothes,',
  6561. '1:26': "you wouldn't believe",
  6562. '1:27': 'these outfits',
  6563. '1:28': 'Foot down no breaks,',
  6564. '1:29': 'tryna leave everythin taped',
  6565. '1:30': 'Asked bout the shotty,',
  6566. '1:31': 'told them I got it',
  6567. '1:32': 'from the farm,',
  6568. '1:33': 'now they think I got from H',
  6569. '1:34': 'Clean up gang with a hoover,',
  6570. '1:36': 'pull up and sweep the street',
  6571. '1:38': 'Told bae book Park Chinois,',
  6572. '1:39': 'the bricks came cheap',
  6573. '1:40': 'this week',
  6574. '1:41': 'Brought out the glee',
  6575. '1:42': 'this week,',
  6576. '1:43': 'so somethin might end up',
  6577. '1:44': 'on a tee this week',
  6578. '1:45': 'Done studio time done the re',
  6579. '1:46': 'this week,',
  6580. '1:47': 'big bustdown',
  6581. '1:48': "that ain't no Jesus piece",
  6582. '1:49': 'No G17,G19 had the G17',
  6583. '1:50': 'then the G19',
  6584. '1:51': 'Had an old .44',
  6585. '1:52': 'but the pin was weak,',
  6586. '1:53': 'still gonna spin if need',
  6587. '1:54': 'Sayin no smoke backstage,',
  6588. '1:55': 'but bro still ask',
  6589. '1:56': 'can we bring it please,',
  6590. '1:57': 'or a ZK at least',
  6591. '1:59': 'This opps in this',
  6592. '2:00': "spliff's sativa,",
  6593. '2:01': 'still put smoke in the whiz,',
  6594. '2:02': 'Khalifa',
  6595. '2:03': "Bad B don't wanna",
  6596. '2:04': 'lock the smoke,',
  6597. '2:05': 'I just gotta love her',
  6598. '2:06': 'and leave her',
  6599. '2:07': 'Yo, had the Liz',
  6600. '2:08': 'come like Peter',
  6601. '2:09': 'and the bujj like Cleveland',
  6602. '2:10': 'This ice in my wrist says',
  6603. '2:11': 'whole lotta money,',
  6604. '2:12': "swear it's comin like BIA",
  6605. '2:14': 'O14 me, Zee had the bruc',
  6606. '2:15': 'back in a bruck down Kia',
  6607. '2:16': "Now you'll find me in Venice,",
  6608. '2:17': 'tryin some shellfish',
  6609. '2:18': 'oh mama mia',
  6610. '2:19': 'Old school I was',
  6611. '2:20': 'hoppin out first,',
  6612. '2:21': 'had bro sayin',
  6613. '2:22': 'stop bein selfish',
  6614. '2:23': 'Yo,',
  6615. '2:24': 'now I just leave that stage,',
  6616. '2:25': 'pullin strings like Elvis',
  6617. '2:26': 'Ding dong on an outin,',
  6618. '2:27': "would've been a loss",
  6619. '2:28': 'if we found him',
  6620. '2:29': "Can't record,",
  6621. '2:30': 'need more points on the board',
  6622. '2:31': 'Gang, tape it first,',
  6623. '2:32': "then I'll give them an album",
  6624. '2:33': 'Spoke to the yard man,',
  6625. '2:34': 'wanna know the P for the .45,',
  6626. '2:35': 'like Alhan',
  6627. '2:36': 'Spoke to the runner,',
  6628. '2:37': "said he's got more than a oner",
  6629. '2:39': "and he's still counting",
  6630. '2:40': 'Go get that car,',
  6631. '2:41': 'congestion zone,',
  6632. '2:42': 'gotta step with ours',
  6633. '2:43': 'Pocket rocket,',
  6634. '2:44': 'had it in a pouch',
  6635. '2:45': 'next to the brush',
  6636. '2:46': 'and the metro card',
  6637. '2:47': 'Double R truck,',
  6638. '2:48': 'stars in the roof,',
  6639. '2:49': 'and we got a seperate star',
  6640. '2:50': "Ain't done it in a Tesla yet,",
  6641. '2:51': 'if we do thats lead',
  6642. '2:52': 'in an electric car',
  6643. '2:53': 'Clean up gang with a hoover,',
  6644. '2:55': 'pull up and sweep the street',
  6645. '2:57': 'Told bae book Park Chinois,',
  6646. '2:58': 'the bricks came cheap',
  6647. '2:59': 'this week',
  6648. '3:00': 'Brought out the glee',
  6649. '3:01': 'this week,',
  6650. '3:02': 'so somethin might end up',
  6651. '3:03': 'on a tee this week',
  6652. '3:04': 'Done studio time done the re',
  6653. '3:05': 'this week,',
  6654. '3:06': 'big bustdown',
  6655. '3:07': "that ain't no Jesus piece",
  6656. '3:08': 'No G17,G19 had the G17',
  6657. '3:09': 'then the G19',
  6658. '3:10': 'Had an old .44',
  6659. '3:11': 'but the pin was weak,',
  6660. '3:12': 'still gonna spin if need',
  6661. '3:13': 'Sayin no smoke backstage,',
  6662. '3:14': 'but bro still ask',
  6663. '3:15': 'can we bring it please,',
  6664. '3:16': 'or a ZK at least',
  6665. '3:19': '!End of song'
  6666. };
  6667. 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");
  6668. let isPlaying = false;
  6669. let currentPart = '';
  6670. function toggleSong() {
  6671. if (!isPlaying) {
  6672. songchat1.play();
  6673. songchat1.ontimeupdate = function(time) {
  6674. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  6675. if (part && part !== currentPart) {
  6676. currentPart = part;
  6677. packet("6", part);
  6678. }
  6679. };
  6680. songchat1.onended = function() {
  6681. if (isPlaying) {
  6682. songchat1.play();
  6683. }
  6684. };
  6685. isPlaying = true;
  6686. } else {
  6687. songchat1.pause();
  6688. isPlaying = false;
  6689. }
  6690. }
  6691. document.addEventListener("keypress", function(e) {
  6692. if (e.key === "C") {
  6693. toggleSong();
  6694. }
  6695. });
  6696. function createPath() {
  6697. grid = [];
  6698. checkObject();
  6699. }
  6700. function Pathfinder() {
  6701. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  6702. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  6703. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6704. packet("a", undefined, 1);
  6705. } else {
  6706. createPath();
  6707. easystar.setGrid(grid);
  6708. easystar.setAcceptableTiles([0]);
  6709. easystar.enableDiagonals();
  6710. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function(path) {
  6711. if (path === null) {
  6712. pathFind.array = [];
  6713. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6714. packet("a", undefined, 1);
  6715. } else {
  6716. packet("a", near.aim2, 1);
  6717. }
  6718. } else {
  6719. pathFind.array = path;
  6720. if (pathFind.array.length > 1) {
  6721. let tmpXY = {
  6722. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  6723. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  6724. }
  6725. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  6726. }
  6727. }
  6728. });
  6729. easystar.calculate();
  6730. }
  6731. }
  6732. }
  6733. /** PATHFIND TEST */
  6734. // ITEM COUNT DISPLAY:
  6735. let isItemSetted = [];
  6736. function updateItemCountDisplay(index = undefined) {
  6737. for (let i = 3; i < items.list.length; ++i) {
  6738. let id = items.list[i].group.id;
  6739. let tmpI = items.weapons.length + i;
  6740. if (!isItemSetted[tmpI]) {
  6741. isItemSetted[tmpI] = document.createElement("div");
  6742. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6743. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6744. isItemSetted[tmpI].style = `
  6745. display: block;
  6746. position: absolute;
  6747. padding-left: 5px;
  6748. font-size: 2em;
  6749. color: #fff;
  6750. `;
  6751. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6752. } else {
  6753. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6754. }
  6755. }
  6756. }
  6757. // AUTOPUSH:
  6758. function autoPush() {
  6759. 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) {
  6760. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6761. })[0];
  6762. if (nearTrap) {
  6763. 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) {
  6764. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6765. })[0];
  6766. if (spike) {
  6767. let pos = {
  6768. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6769. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6770. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6771. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6772. };
  6773. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6774. let tmpScale = tmp.getScale();
  6775. 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)) {
  6776. return true;
  6777. }
  6778. });
  6779. if (finds) {
  6780. if (my.autoPush) {
  6781. my.autoPush = false;
  6782. packet("a", lastMoveDir || undefined, 1);
  6783. }
  6784. } else {
  6785. my.autoPush = true;
  6786. my.pushData = {
  6787. x: spike.x + 70,
  6788. y: spike.y + 70,
  6789. x2: pos.x2 + 30,
  6790. y2: pos.y2 + 30
  6791. };
  6792. let scale = player.scale / 10;
  6793. let secondArg = UTILS.getDirect(near, spike, 2, 0) > 70 ? near.aim2 : undefined;
  6794. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6795. packet("a", secondArg, 1);
  6796. } else {
  6797. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6798. }
  6799. }
  6800. } else {
  6801. if (my.autoPush) {
  6802. my.autoPush = false;
  6803. packet("a", lastMoveDir || undefined, 1);
  6804. }
  6805. }
  6806. } else {
  6807. if (my.autoPush) {
  6808. my.autoPush = false;
  6809. packet("a", lastMoveDir || undefined, 1);
  6810. }
  6811. }
  6812. }
  6813. // AUTOPUSH:
  6814. /* function autoPush() { //LEGACY AUTOPUSH
  6815. 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) {
  6816. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6817. })[0];
  6818. if (nearTrap) {
  6819. 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) {
  6820. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6821. })[0];
  6822. if (spike) {
  6823. let pos = {
  6824. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6825. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6826. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6827. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6828. };
  6829. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6830. let tmpScale = tmp.getScale();
  6831. 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)) {
  6832. return true;
  6833. }
  6834. });
  6835. if (finds) {
  6836. if (my.autoPush) {
  6837. my.autoPush = false;
  6838. packet("33", lastMoveDir||undefined, 1);
  6839. }
  6840. } else {
  6841. my.autoPush = true;
  6842. my.pushData = {
  6843. x: spike.x,
  6844. y: spike.y,
  6845. x2: pos.x2,
  6846. y2: pos.y2
  6847. };
  6848. let scale = (player.scale / 10);
  6849. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6850. packet("33", near.aim2, 1);
  6851. } else {
  6852. packet("33", UTILS.getDirect(pos, player, 2, 2), 1);
  6853. }
  6854. }
  6855. } else {
  6856. if (my.autoPush) {
  6857. my.autoPush = false;
  6858. packet("33", lastMoveDir||undefined, 1);
  6859. }
  6860. }
  6861. } else {
  6862. if (my.autoPush) {
  6863. my.autoPush = false;
  6864. packet("33", lastMoveDir||undefined, 1);
  6865. }
  6866. }
  6867. }*/
  6868. // ADD DEAD PLAYER:
  6869. function addDeadPlayer(tmpObj) {
  6870. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6871. }
  6872. /** APPLY SOCKET CODES */
  6873. // SET INIT DATA:
  6874. function setInitData(data) {
  6875. alliances = data.teams;
  6876. }
  6877. // SETUP GAME:
  6878. var fisrtloadez = false;
  6879. function setupGame(yourSID) {
  6880. keys = {};
  6881. macro = {};
  6882. playerSID = yourSID;
  6883. attackState = 0;
  6884. inGame = true;
  6885. fisrtloadez = true;
  6886. packet("d", 0, getAttackDir(), 1);
  6887. my.ageInsta = true;
  6888. if (firstSetup) {
  6889. firstSetup = false;
  6890. gameObjects.length = 0;
  6891. }
  6892. }
  6893. // ADD NEW PLAYER:
  6894. function addPlayer(data, isYou) {
  6895. let tmpPlayer = findPlayerByID(data[0]);
  6896. if (!tmpPlayer) {
  6897. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6898. objectManager, players, ais, items, hats, accessories);
  6899. players.push(tmpPlayer);
  6900. if (data[1] != playerSID) {
  6901. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6902. }
  6903. } else {
  6904. if (data[1] != playerSID) {
  6905. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6906. }
  6907. }
  6908. tmpPlayer.spawn(isYou ? true : null);
  6909. tmpPlayer.visible = false;
  6910. tmpPlayer.oldPos = {
  6911. x2: undefined,
  6912. y2: undefined
  6913. };
  6914. tmpPlayer.x2 = undefined;
  6915. tmpPlayer.y2 = undefined;
  6916. tmpPlayer.x3 = undefined;
  6917. tmpPlayer.y3 = undefined;
  6918. tmpPlayer.setData(data);
  6919. if (isYou) {
  6920. if (!player) {
  6921. window.prepareUI(tmpPlayer);
  6922. }
  6923. player = tmpPlayer;
  6924. camX = player.x;
  6925. camY = player.y;
  6926. my.lastDir = 0;
  6927. updateItems();
  6928. updateAge();
  6929. updateItemCountDisplay();
  6930. if (player.skins[7]) {
  6931. my.reSync = true;
  6932. }
  6933. }
  6934. }
  6935. // REMOVE PLAYER:
  6936. function removePlayer(id) {
  6937. for (let i = 0; i < players.length; i++) {
  6938. if (players[i].id == id) {
  6939. let tmpPlayer = players[i];
  6940. addChatLog(tmpPlayer.name + " has died", "#db2727", "", "#db2727");
  6941. players.splice(i, 1);
  6942. break;
  6943. }
  6944. }
  6945. }
  6946. // UPDATE HEALTH:
  6947. function updateHealth(sid, value) {
  6948. tmpObj = findPlayerBySID(sid);
  6949. if (tmpObj) {
  6950. tmpObj.oldHealth = tmpObj.health;
  6951. tmpObj.health = value;
  6952. tmpObj.judgeShame();
  6953. if (tmpObj.oldHealth > tmpObj.health) {
  6954. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6955. advHeal.push([sid, value, tmpObj.damaged]);
  6956. } else {
  6957. }
  6958. }
  6959. }
  6960. // KILL PLAYER:
  6961. function killPlayer() {
  6962. inGame = false;
  6963. lastDeath = {
  6964. x: player.x,
  6965. y: player.y,
  6966. };
  6967. if (configs.autoRespawn) {
  6968. getEl("ot-sdk-btn-floating").style.display = "none";
  6969. packet("M", {
  6970. name: lastsp[0],
  6971. moofoll: lastsp[1],
  6972. skin: lastsp[2]
  6973. });
  6974. }
  6975. }
  6976. // UPDATE PLAYER ITEM VALUES:
  6977. function updateItemCounts(index, value) {
  6978. if (player) {
  6979. player.itemCounts[index] = value;
  6980. updateItemCountDisplay(index);
  6981. }
  6982. }
  6983. // UPDATE AGE:
  6984. function updateAge(xp, mxp, age) {
  6985. if (xp != undefined)
  6986. player.XP = xp;
  6987. if (mxp != undefined)
  6988. player.maxXP = mxp;
  6989. if (age != undefined)
  6990. player.age = age;
  6991. }
  6992. // UPDATE UPGRADES:
  6993. function updateUpgrades(points, age) {
  6994. player.upgradePoints = points;
  6995. player.upgrAge = age;
  6996. if (points > 0) {
  6997. tmpList.length = 0;
  6998. UTILS.removeAllChildren(upgradeHolder);
  6999. for (let i = 0; i < items.weapons.length; ++i) {
  7000. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  7001. let e = UTILS.generateElement({
  7002. id: "upgradeItem" + i,
  7003. class: "actionBarItem",
  7004. onmouseout: function() {
  7005. showItemInfo();
  7006. },
  7007. parent: upgradeHolder
  7008. });
  7009. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  7010. tmpList.push(i);
  7011. }
  7012. }
  7013. for (let i = 0; i < items.list.length; ++i) {
  7014. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  7015. let tmpI = (items.weapons.length + i);
  7016. let e = UTILS.generateElement({
  7017. id: "upgradeItem" + tmpI,
  7018. class: "actionBarItem",
  7019. onmouseout: function() {
  7020. showItemInfo();
  7021. },
  7022. parent: upgradeHolder
  7023. });
  7024. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  7025. tmpList.push(tmpI);
  7026. }
  7027. }
  7028. for (let i = 0; i < tmpList.length; i++) {
  7029. (function(i) {
  7030. let tmpItem = getEl('upgradeItem' + i);
  7031. tmpItem.onmouseover = function() {
  7032. if (items.weapons[i]) {
  7033. showItemInfo(items.weapons[i], true);
  7034. } else {
  7035. showItemInfo(items.list[i - items.weapons.length]);
  7036. }
  7037. };
  7038. tmpItem.onclick = UTILS.checkTrusted(function() {
  7039. packet("H", i);
  7040. });
  7041. UTILS.hookTouchEvents(tmpItem);
  7042. })(tmpList[i]);
  7043. }
  7044. if (tmpList.length) {
  7045. upgradeHolder.style.display = "block";
  7046. upgradeCounter.style.display = "block";
  7047. upgradeCounter.style.borderRadius = "4px";
  7048. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  7049. } else {
  7050. upgradeHolder.style.display = "none";
  7051. upgradeCounter.style.display = "none";
  7052. showItemInfo();
  7053. }
  7054. } else {
  7055. upgradeHolder.style.display = "none";
  7056. upgradeCounter.style.display = "none";
  7057. showItemInfo();
  7058. }
  7059. }
  7060. function cdf(e, t) {
  7061. try {
  7062. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7063. } catch (e) {
  7064. return Infinity;
  7065. }
  7066. }
  7067. function caf(e, t) {
  7068. try {
  7069. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7070. } catch (e) {
  7071. return 0;
  7072. }
  7073. }
  7074. function numArr(e = 0, t = 1, act, n = 1) {
  7075. let arr = [];
  7076. for (let i = e; i < t; i += n) {
  7077. arr.push(i);
  7078. typeof act == "function" && act(i);
  7079. }
  7080. return arr;
  7081. }
  7082. function toR(e) {
  7083. var n = (e * Math.PI / 180) % (2 * Math.PI);
  7084. return n > Math.PI ? Math.PI - n : n
  7085. }
  7086. function toD(e) {
  7087. var n = (e / Math.PI * 360) % 360;
  7088. return n >= 360 ? n - 360 : n;
  7089. }
  7090.  
  7091. // KILL OBJECT:
  7092. function killObject(sid) {
  7093. let findObj = findObjectBySid(sid);
  7094. objectManager.disableBySid(sid);
  7095. if (player) {
  7096. for (let i = 0; i < breakObjects.length; i++) {
  7097. if (breakObjects[i].sid == sid) {
  7098. breakObjects.splice(i, 1);
  7099. break;
  7100. }
  7101. }
  7102. if (!player.canSee(findObj)) {
  7103. breakTrackers.push({x: findObj.x, y: findObj.y});
  7104. }
  7105. if (breakTrackers.length > 8) {
  7106. breakTrackers.shift();
  7107. }
  7108. traps.replacer(findObj);
  7109. }
  7110. }
  7111. // KILL ALL OBJECTS BY A PLAYER:
  7112. function killObjects(sid) {
  7113. if (player) objectManager.removeAllItems(sid);
  7114. }
  7115. function fgdo(a, b) {
  7116. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  7117. }
  7118. function precheckPlace(a, b) {
  7119. checkPlace(a, b);
  7120. console.log('success');
  7121. }
  7122. function perfectReplace() {
  7123. // let range = items.weapons[player.weapons[0]].range + 70;
  7124. // const interval = setInterval(() => {
  7125. // gameObjects.forEach(tmpObj => {
  7126. // let objDst = UTILS.getDist(tmpObj, player, 0, 2);
  7127. // let perfectAngle = UTILS.getDirect(tmpObj, player, 0, 2);
  7128. // if (tmpObj.health <= 272.58 && fgdo(tmpObj, player) <= range && near.dist2 <= 300) {
  7129. // console.log('preplace');
  7130. // place(2, perfectAngle);
  7131. // }
  7132. // });
  7133. // });
  7134. // setTimeout(() => {
  7135. // clearInterval(interval);
  7136. // }, 500);
  7137. }
  7138. let ticks = {
  7139. tick: 0,
  7140. delay: 0,
  7141. time: [],
  7142. manage: [],
  7143. };
  7144. // GAME TICKOUT:
  7145. function setTickout(doo, timeout) {
  7146. if (!ticks.manage[ticks.tick + timeout]) {
  7147. ticks.manage[ticks.tick + timeout] = [doo];
  7148. } else {
  7149. ticks.manage[ticks.tick + timeout].push(doo);
  7150. }
  7151. }
  7152. function doNextTick(doo) {
  7153. waitTicks.push(doo);
  7154. }
  7155. let waitTicks = [];
  7156. // UPDATE PLAYER DATA:
  7157. let nEy;
  7158. let plaguemask = true;
  7159. let placeableSpikes = [];
  7160. let placeableTraps = [];
  7161. let placeableSpikesPREDICTS = [];
  7162. function updatePlayers(data) {
  7163. game.tick++;
  7164. enemy = [];
  7165. perfectReplace();
  7166. nears = [];
  7167. near = [];
  7168. //showPlace = [];
  7169. game.tickSpeed = performance.now() - game.lastTick;
  7170. game.lastTick = performance.now();
  7171. ticks.tick++;
  7172. ticks.time.push(Date.now() - ticks.delay <= 50 || Date.now() - ticks.delay >= 175 ? "lag" : 1);
  7173. if (ticks.tick % 10 === 0) {
  7174. ticks.time = [];
  7175. }
  7176. if (ticks.tick % 300 === 0) {
  7177. }
  7178. ticks.delay = Date.now();
  7179. players.forEach((tmp) => {
  7180. tmp.forcePos = !tmp.visible;
  7181. tmp.visible = false;
  7182. });
  7183. for (let i = 0; i < data.length;) {
  7184. tmpObj = findPlayerBySID(data[i]);
  7185. if (tmpObj) {
  7186. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7187. tmpObj.t2 = game.lastTick;
  7188. tmpObj.oldPos.x2 = tmpObj.x2;
  7189. tmpObj.oldPos.y2 = tmpObj.y2;
  7190. tmpObj.x1 = tmpObj.x;
  7191. tmpObj.y1 = tmpObj.y;
  7192. tmpObj.x2 = data[i + 1];
  7193. tmpObj.y2 = data[i + 2];
  7194. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7195. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7196. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7197. tmpObj.d2 = data[i + 3];
  7198. tmpObj.dt = 0;
  7199. tmpObj.buildIndex = data[i + 4];
  7200. tmpObj.weaponIndex = data[i + 5];
  7201. tmpObj.weaponVariant = data[i + 6];
  7202. tmpObj.team = data[i + 7];
  7203. tmpObj.isLeader = data[i + 8];
  7204. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7205. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7206. tmpObj.skinIndex = data[i + 9];
  7207. tmpObj.tailIndex = data[i + 10];
  7208. tmpObj.iconIndex = data[i + 11];
  7209. tmpObj.zIndex = data[i + 12];
  7210. tmpObj.visible = true;
  7211. tmpObj.update(game.tickSpeed);
  7212. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7213. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7214. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7215. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7216. tmpObj.damageThreat = 0;
  7217. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7218. tmpObj.addShameTimer();
  7219. }
  7220. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7221. tmpObj.shameTimer = 0;
  7222. tmpObj.shameCount = 0;
  7223. if (tmpObj == player) {
  7224. healer();
  7225. }
  7226. }
  7227. nEy = tmpObj;
  7228. if (tmpObj == player) {
  7229. if (gameObjects.length) {
  7230. gameObjects.forEach((tmp) => {
  7231. tmp.onNear = false;
  7232. if (tmp.active) {
  7233. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7234. tmp.onNear = true;
  7235. }
  7236. if (tmp.isItem && tmp.owner) {
  7237. 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)) {
  7238. tmp.breakObj = true;
  7239. breakObjects.push({
  7240. x: tmp.x,
  7241. y: tmp.y,
  7242. sid: tmp.sid
  7243. });
  7244. }
  7245. }
  7246. }
  7247. });
  7248. 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) {
  7249. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7250. })[0];
  7251. if (nearTrap) {
  7252. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7253. traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7254. if (!traps.inTrap) {
  7255. traps.protect(traps.aim);
  7256. }
  7257. traps.inTrap = true;
  7258. traps.info = nearTrap;
  7259. } else {
  7260. traps.inTrap = false;
  7261. traps.info = {};
  7262. }
  7263. } else {
  7264. traps.inTrap = false;
  7265. }
  7266. }
  7267. if (tmpObj.weaponIndex < 9) {
  7268. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7269. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7270. } else if (tmpObj.weaponIndex > 8) {
  7271. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7272. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7273. }
  7274. }
  7275. i += 13;
  7276. }
  7277. if (waitTicks.length) {
  7278. waitTicks.forEach((ajaj) => {
  7279. ajaj();
  7280. }
  7281. );
  7282. waitTicks = [];
  7283. }
  7284. if (runAtNextTick.length) {
  7285. runAtNextTick.forEach((tmp) => {
  7286. checkProjectileHolder(...tmp);
  7287. }
  7288. );
  7289. runAtNextTick = [];
  7290. }
  7291. if (textManager.stack.length) {
  7292. let stacks = [];
  7293. let notstacks = [];
  7294. let num = 0;
  7295. let num2 = 0;
  7296. let pos = {
  7297. x: null,
  7298. y: null
  7299. };
  7300. let pos2 = {
  7301. x: null,
  7302. y: null
  7303. }
  7304. textManager.stack.forEach((text) => {
  7305. if (text.value >= 0) {
  7306. if (num == 0) pos = {
  7307. x: text.x,
  7308. y: text.y
  7309. };
  7310. num += Math.abs(text.value);
  7311. } else {
  7312. if (num2 == 0) pos2 = {
  7313. x: text.x,
  7314. y: text.y
  7315. };
  7316. num2 += Math.abs(text.value);
  7317. }
  7318. });
  7319. if (num2 > 0) {
  7320. textManager.showText(pos2.x, pos2.y, Math.max(43, Math.min(50, num2)), 0.18, 500, num2, damageTextColor = "#782F44");
  7321. }
  7322. if (num > 0) {
  7323. textManager.showText(pos.x, pos.y, Math.max(43, Math.min(50, num)), 0.18, 500, num, damageTextColor = "#782F44");
  7324. }
  7325. textManager.stack = [];
  7326. }
  7327. if (runAtNextTick.length) {
  7328. runAtNextTick.forEach((tmp) => {
  7329. checkProjectileHolder(...tmp);
  7330. });
  7331. runAtNextTick = [];
  7332. }
  7333. let teams = []
  7334. for (let i = 0; i < data.length;) {
  7335. tmpObj = findPlayerBySID(data[i]);
  7336. if (tmpObj) {
  7337. if (!tmpObj.isTeam(player)) {
  7338. enemy.push(tmpObj);
  7339. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7340. nears.push(tmpObj);
  7341. }
  7342. }else if(tmpObj.sid !== player.sid){
  7343. teams.push(tmpObj)
  7344. }
  7345. tmpObj.manageReload();
  7346. if (tmpObj != player) {
  7347. tmpObj.addDamageThreat(player);
  7348. }
  7349. }
  7350. i += 13;
  7351. }
  7352. /*projectiles.forEach((proj) => {
  7353. tmpObj = proj;
  7354. if (tmpObj.active) {
  7355. tmpObj.tickUpdate(game.tickSpeed);
  7356. }
  7357. });*/
  7358. if (player && player.alive) {
  7359. if (enemy.length) {
  7360. if (player && player.alive){
  7361. placeableSpikes = getPlaceablePositions(player, items.list[player.items[2]]);
  7362. placeableTraps = player.items[4] == 15 ? getPlaceablePositions(player, items.list[player.items[4]]) : [];
  7363. }
  7364.  
  7365. near = enemy.sort(function(tmp1, tmp2) {
  7366. return tmp1.dist2 - tmp2.dist2;
  7367. })[0];
  7368. if(teams.length&&window.VirusterDev){
  7369. teams.forEach((teammate)=>{
  7370. let tmp = near;
  7371. if(UTILS.getDistance(tmp.x, tmp.y, teammate.x, teammate.y) <= ((tmp.scale*2) + items.weapons[teammate.weapons[0]].range) && UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= ((tmp.scale*2) + items.weapons[player.weapons[0]].range) && player.reloads[player.primaryIndex] == 0 && teammate.reloads[teammate.primaryIndex] == 0){
  7372. if(teammate.weaponIndex == teammate.primaryIndex && player.weaponIndex == player.primaryIndex){
  7373. clicks.left = true
  7374. top.sycin = true
  7375. top.lastSync = Date.now();
  7376. }else if(player.weaponIndex !== player.primaryIndex){
  7377. selectWeapon(player.primaryIndex)
  7378. }
  7379. }
  7380. //ezz
  7381. })
  7382. }
  7383. } else {
  7384. // console.log("no enemy");
  7385. }
  7386. if (game.tickQueue[game.tick]) {
  7387. game.tickQueue[game.tick].forEach((action) => {
  7388. action();
  7389. });
  7390. game.tickQueue[game.tick] = null;
  7391. }
  7392. if (advHeal.length) {
  7393. advHeal.forEach((updHealth) => {
  7394. let sid = updHealth[0];
  7395. let value = updHealth[1];
  7396. let totalDamage = 100 - value
  7397. let damaged = updHealth[2];
  7398. tmpObj = findPlayerBySID(sid);
  7399. let bullTicked = false;
  7400. if (tmpObj && tmpObj.health <= 0) {
  7401. if (!tmpObj.death) {
  7402. tmpObj.death = true;
  7403. if(top.lastSync&&(Date.now() - top.lastSync) < 500){
  7404. textManager.showText(tmpObj.x, tmpObj.y, 20, 0.15, 1850, 'Get Synced Nub', '#f00', 2);
  7405. setTimeout(()=>{sendChat('what is sync?')},500)
  7406. }
  7407. if (tmpObj != player) {
  7408. addChatLog(tmpObj.name + " has died", "#db2727", "", "#db2727");
  7409. }
  7410. addDeadPlayer(tmpObj);
  7411. }
  7412. }
  7413. if (tmpObj == player) {
  7414. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7415. if (my.reSync) {
  7416. my.reSync = false;
  7417. tmpObj.setBullTick = true;
  7418. }
  7419. bullTicked = true;
  7420. }
  7421. if (inGame) {
  7422. let dmg = 100 - player.health;
  7423. let attackers = getAttacker(damaged);
  7424. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7425. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  7426. let heal = function () {
  7427. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && clicks.left)) {
  7428. setTimeout(() => {
  7429. healer();
  7430. }, 140 - window.pingTime);
  7431. } else {
  7432. setTimeout(() => {
  7433. healer()
  7434. }, 222 - window.pingTime);
  7435. }
  7436. }
  7437. if (attackers.length) {
  7438. let by = attackers.filter((tmp) => {
  7439. if (tmp.dist2 <= (tmp.weaponIndex < 9 ? 300 : 700)) {
  7440. tmpDir = UTILS.getDirect(player, tmp, 2, 2);
  7441. if (UTILS.getAngleDist(tmpDir, tmp.d2) <= Math.PI) {
  7442. return tmp;
  7443. }
  7444. }
  7445. });
  7446. if (by.length) {
  7447. let maxDamage = (includeSpikeDmgs ? 10 : 10);
  7448. if (damaged > maxDamage && (game.tick - tmpObj.antiTimer) > 1) {
  7449. tmpObj.canEmpAnti = true;
  7450. tmpObj.antiTimer = game.tick;
  7451. if (tmpObj.shameCount < 5) {
  7452. healer();
  7453. } else {
  7454. heal();
  7455. }
  7456. } else {
  7457. heal();
  7458. }
  7459. } else {
  7460. heal();
  7461. }
  7462. } else {
  7463. heal();
  7464. }
  7465. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7466. }
  7467. } else {
  7468. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7469. tmpObj.setPoisonTick = true;
  7470. }
  7471. }
  7472. });
  7473. advHeal = [];
  7474. }
  7475. players.forEach((tmp) => {
  7476. if (!tmp.visible && player != tmp) {
  7477. tmp.reloads = {
  7478. 0: 0,
  7479. 1: 0,
  7480. 2: 0,
  7481. 3: 0,
  7482. 4: 0,
  7483. 5: 0,
  7484. 6: 0,
  7485. 7: 0,
  7486. 8: 0,
  7487. 9: 0,
  7488. 10: 0,
  7489. 11: 0,
  7490. 12: 0,
  7491. 13: 0,
  7492. 14: 0,
  7493. 15: 0,
  7494. 53: 0,
  7495. };
  7496. }
  7497. if (tmp.setBullTick) {
  7498. tmp.bullTimer = 0;
  7499. }
  7500. if (tmp.setPoisonTick) {
  7501. tmp.poisonTimer = 0;
  7502. }
  7503. tmp.updateTimer();
  7504. });
  7505. if (inGame) {
  7506. ping = window.pingTime
  7507. inWater = player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2
  7508. if (enemy.length) {
  7509. if (configs1.AutoQonSync && nears.length > 1 && player.shameCount < 5 && !nears.some(item => [0, 7, 8, 9].includes(item.primaryIndex)) && secPacket < 40) {
  7510. sendChat("sync detect test")
  7511. tmpObj.canEmpAnti = false
  7512. my.anti0Tick = 3
  7513. predictHeal(2)
  7514. if (player.health < 90) {
  7515. healer()
  7516. }
  7517. }
  7518. if (configs1.AutoQonHigh && ping >= 80) {
  7519. let dmg = 100 - player.health
  7520. if ((tmpObj.damageThreat >= 95 || dmg + tmpObj.damageThreat >= 95) && player.skinIndex != 7 && player.shameCount < 5) {
  7521. predictHeal(2)
  7522. } else {
  7523. setTimeout(() => {
  7524. healer()
  7525. }, 120 - ping)
  7526. }
  7527. }
  7528. if (configs.fpsboost) {
  7529. window.location.native_resolution = true;
  7530. setTimeout(() => {
  7531. console.clear
  7532. }, 2000);
  7533. }
  7534. if (configs1.AutoPlace) {
  7535. autoplacer()
  7536. }
  7537. packetData.placeQ = packetData.place;
  7538. packetData.place = [];
  7539. if (packetData.placeQ.length) for (let i = 0; i < packetData.placeQ.length; i++) {
  7540. 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])) {
  7541. place(packetData.placeQ[i][0], packetData.placeQ[i][1]);
  7542. }
  7543. }
  7544. if (player.canEmpAnti) {
  7545. player.canEmpAnti = false;
  7546. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7547. if (near.reloads[53] == 0) {
  7548. player.empAnti = true;
  7549. player.soldierAnti = false;
  7550. //modLog("EmpAnti");
  7551. } else {
  7552. player.empAnti = false;
  7553. player.soldierAnti = true;
  7554. //modLog("SoldierAnti");
  7555. }
  7556. }
  7557. }
  7558. 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) {
  7559. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7560. })[0];
  7561. if (prehit) {
  7562. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs1.AutoPredictTick) {
  7563. instaC.canSpikeTick = true;
  7564. instaC.syncHit = true;
  7565. if (instaC.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7566. instaC.revTick = true;
  7567. }
  7568. }
  7569. }
  7570. 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) {
  7571. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7572. })[0];
  7573. let moreAntiSpikeTick = traps.checkSpikeTick()
  7574. if (antiSpikeTick && !traps.inTrap) {
  7575. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7576. my.anti0Tick = 1;
  7577. packet("6", "hi : " + near.sid);
  7578. player.chat.count = 2000;
  7579. }
  7580. }
  7581. if (moreAntiSpikeTick) {
  7582. my.anti0Tick = 4;
  7583. sendChat("op anti spike tick wat ofc")
  7584. }
  7585. }
  7586. nears.forEach((tmpPlayer) => {
  7587. if (tmpPlayer.primaryIndex == 5 && tmpPlayer.primaryVariant >= 2) {
  7588. if (tmpPlayer.dist2 >= 160 && tmpPlayer.dist2 < 260) {
  7589. if (tmpPlayer.skinIndex == 53) {
  7590. buyEquip(6, 0);
  7591. }
  7592. }
  7593. }
  7594. })
  7595. if ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100) &&
  7596. near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 &&
  7597. (instaC.wait || (Math.floor(Math.random() * 5) == 0)) &&
  7598. !instaC.isTrue &&
  7599. !my.waitHit &&
  7600. player.reloads[player.weapons[0]] == 0 &&
  7601. player.reloads[player.weapons[1]] == 0 &&
  7602. (getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) &&
  7603. instaC.perfCheck(player, near)) {
  7604.  
  7605. if (player.checkCanInsta(true) >= 100) {
  7606. instaC.nobull = false;
  7607. } else {
  7608. instaC.nobull = false; // Note: This line seems redundant in the original code
  7609. }
  7610.  
  7611. instaC.can = true;
  7612. } else {
  7613. instaC.can = false;
  7614. }
  7615.  
  7616. macro.q && place(0, getAttackDir());
  7617. macro.f && place(4, getSafeDir());
  7618. macro.v && place(2, getSafeDir());
  7619. macro.y && place(5, getSafeDir());
  7620. macro.h && place(player.getItemType(22), getSafeDir());
  7621. macro.n && place(3, getSafeDir());
  7622.  
  7623. if (game.tick % 3 == 0) {
  7624. if (mills.place) {
  7625. let plcAng = 1.25;
  7626. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7627. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7628. }
  7629. } else {
  7630. if (mills.placeSpawnPads) {
  7631. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7632. checkPlace(
  7633. player.getItemType(20),
  7634. UTILS.getDirect(player.oldPos, player, 2, 2) + i
  7635. );
  7636. }
  7637. }
  7638. }
  7639. }
  7640.  
  7641. if (instaC.can) {
  7642. instaC.changeType("rev");
  7643. }
  7644.  
  7645. if (instaC.canCounter) {
  7646. instaC.canCounter = false;
  7647. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7648. instaC.counterType();
  7649. }
  7650. }
  7651.  
  7652. if (instaC.canSpikeTick) {
  7653. instaC.canSpikeTick = false;
  7654. if (instaC.revTick) {
  7655. instaC.revTick = false;
  7656. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7657. instaC.changeType("rev");
  7658. }
  7659. } else {
  7660. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7661. instaC.spikeTickType();
  7662. if (instaC.syncHit) {
  7663. }
  7664. }
  7665. }
  7666. }
  7667. let turretEmp = 0;
  7668. let inbullspam = false;
  7669. let waitTicks = [];
  7670. let anti0Tick = 0;
  7671. let syncCount = 0;
  7672. let doEmpAntiInsta = false;
  7673. let plagueCount = 0;
  7674. 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) {
  7675. setTimeout(() => {
  7676. if (player.weaponIndex !== player.weapons[0] || player.buildIndex > -1) {
  7677. selectWeapon(player.weapons[0]);
  7678. }
  7679. if (player.reloads[player.weapons[0]] === 0 && !my.waitHit) {
  7680. sendAutoGather();
  7681. my.waitHit = 1;
  7682. my.autoAim = true;
  7683. inbullspam = true;
  7684. Hg(!plaguemask ? 7 : 21, 18);
  7685. game.tickBase(() => {
  7686. sendAutoGather();
  7687. my.waitHit = 0;
  7688. my.autoAim = false;
  7689. inbullspam = false;
  7690. Hg(near.skinIndex === 7 ? near.antiBull > 0 ? 11 : 6 : 6, 21);
  7691. }, 10);
  7692. }
  7693. }, 5);
  7694. } else {
  7695. inbullspam = false;
  7696. }
  7697.  
  7698. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7699. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7700. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7701. }
  7702. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7703. sendAutoGather();
  7704. my.waitHit = 1;
  7705. game.tickBase(() => {
  7706. sendAutoGather();
  7707. my.waitHit = 0;
  7708. if(clicks.left && top.sycin){
  7709. clicks.left = false
  7710. top.sycin = false
  7711. }
  7712. }, 1);
  7713. }
  7714. }
  7715. if (traps.inTrap) {
  7716. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7717. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7718. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7719. }
  7720. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7721. sendAutoGather();
  7722. my.waitHit = 1;
  7723. invisBody = true;
  7724. game.tickBase(() => {
  7725. sendAutoGather();
  7726. my.waitHit = 0;
  7727. invisBody = false;
  7728. }, 1);
  7729. }
  7730. }
  7731. }
  7732. if (clicks.middle && !traps.inTrap) {
  7733. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7734. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7735. instaC.bowMovement();
  7736. } else {
  7737. instaC.rangeType();
  7738. }
  7739. }
  7740. }
  7741. if (macro.t && !traps.inTrap) {
  7742. 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))) {
  7743. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7744. }
  7745. }
  7746. if (macro["."] && !traps.inTrap) {
  7747. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7748. instaC.boostTickMovement();
  7749. }
  7750. }
  7751. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue) {
  7752. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7753. if (!my.reloaded) {
  7754. my.reloaded = true;
  7755. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7756. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7757. selectWeapon(player.weapons[fastSpeed]);
  7758. }
  7759. }
  7760. } else {
  7761. my.reloaded = false;
  7762. if (player.reloads[player.weapons[0]] > 0) {
  7763. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7764. selectWeapon(player.weapons[0]);
  7765. }
  7766. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7767. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7768. selectWeapon(player.weapons[1]);
  7769. }
  7770. }
  7771. }
  7772. }
  7773. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7774. packet("D", getAttackDir());
  7775. }
  7776. let hatChanger = function() {
  7777. if (my.anti0Tick > 0) {
  7778. buyEquip(6, 0);
  7779. } else {
  7780. if ((!enemy.length || tmpObj.mostDamageThreat <= 95) && player.shameCount > 0 && (player.skinIndex != 45) || my.reSync) {
  7781. buyEquip(7, 0);
  7782. } else {
  7783. if (clicks.left || clicks.right) {
  7784. if (clicks.left) {
  7785. 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);
  7786. } else if (clicks.right) {
  7787. 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);
  7788. }
  7789. } else if (traps.inTrap) {
  7790. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7791. buyEquip(40, 0);
  7792. if (near.dist2 > 300 && (!player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7793. buyEquip(6, 0);
  7794. }
  7795. } else {
  7796. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 6 : 22, 0);
  7797. }
  7798. } else {
  7799. if (player.empAnti || player.soldierAnti) {
  7800. buyEquip(player.empAnti ? 6 : 40, 0);
  7801. } else {
  7802. if (inWater) {
  7803. if (!configs1.alwaysFlipper) {
  7804. if (near.dist2 <= 300) {
  7805. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7806. } else {
  7807. biomeGear()
  7808. }
  7809. } else {
  7810. biomeGear()
  7811. }
  7812. } else {
  7813. biomeGear()
  7814. }
  7815. }
  7816. }
  7817. }
  7818. }
  7819. }
  7820. let accChanger = function() {
  7821. if (clicks.left) {
  7822. buyEquip(21, 1);
  7823. } else if (clicks.right) {
  7824. buyEquip(21, 1)
  7825. } else if (traps.inTrap) {
  7826. buyEquip(21, 1);
  7827. } else if (near.dist2 < 300) {
  7828. if (getEl("antiBullType").value == "noab") {
  7829. buyEquip(21, 1)
  7830. } else if (inWater) {
  7831. buyEquip(21, 1)
  7832. } else {
  7833. buyEquip(21, 1);
  7834. }
  7835. } else {
  7836. buyEquip(11, 1);
  7837. }
  7838. }
  7839. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7840. hatChanger();
  7841. accChanger();
  7842. }
  7843. if (configs1.AutoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7844. autoPush();
  7845. } else {
  7846. if (my.autoPush) {
  7847. my.autoPush = false;
  7848. packet("a", lastMoveDir || undefined, 1);
  7849. }
  7850. }
  7851. if (!my.autoPush && pathFind.active) {
  7852. Pathfinder();
  7853. }
  7854. if (instaC.ticking) {
  7855. instaC.ticking = false;
  7856. }
  7857. if (instaC.syncHit) {
  7858. instaC.syncHit = false;
  7859. }
  7860. if (player.empAnti) {
  7861. player.empAnti = false;
  7862. }
  7863. if (player.soldierAnti) {
  7864. player.soldierAnti = false;
  7865. }
  7866. if (my.anti0Tick > 0) {
  7867. my.anti0Tick--;
  7868. }
  7869. if (traps.replaced) {
  7870. traps.replaced = false;
  7871. }
  7872. if (traps.antiTrapped) {
  7873. traps.antiTrapped = false;
  7874. }
  7875. }
  7876. }
  7877. if (botSkts.length) {
  7878. botSkts.forEach((bots) => {
  7879. if (true) {
  7880. bots[0].ssend("player", player, near, botIDS);
  7881. }
  7882. });
  7883. }
  7884. }
  7885. // UPDATE LEADERBOARD:
  7886. function updateLeaderboard(data) {
  7887. UTILS.removeAllChildren(leaderboardData);
  7888. var tmpC = 1;
  7889. for (var i = 0; i < data.length; i += 3) {
  7890. // console.log(data);
  7891. (function(i) {
  7892. UTILS.generateElement({
  7893. class: "leaderHolder",
  7894. parent: leaderboardData,
  7895. children: [
  7896. UTILS.generateElement({
  7897. class: "leaderboardItem",
  7898. 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;",
  7899. text: (data[i + 1] != "" ? data[i + 1] : "unknown") + " |"
  7900. }),
  7901. UTILS.generateElement({
  7902. class: "a", //class: "leaderScore",
  7903. 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;",
  7904. text: ("? " + UTILS.kFormat(data[i + 2]) || "? 0")
  7905. })
  7906. ]
  7907. });
  7908. })(i);
  7909. tmpC++;
  7910. }
  7911. }
  7912.  
  7913. // LOAD GAME OBJECT:
  7914. function loadGameObject(data) {
  7915. for (let i = 0; i < data.length;) {
  7916. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7917. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7918. sid: data[i + 7]
  7919. } : null));
  7920. i += 8;
  7921. }
  7922. }
  7923. // ADD AI:
  7924. function loadAI(data) {
  7925. for (let i = 0; i < ais.length; ++i) {
  7926. ais[i].forcePos = !ais[i].visible;
  7927. ais[i].visible = false;
  7928. }
  7929. if (data) {
  7930. let tmpTime = performance.now();
  7931. for (let i = 0; i < data.length;) {
  7932. tmpObj = findAIBySID(data[i]);
  7933. if (tmpObj) {
  7934. tmpObj.index = data[i + 1];
  7935. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7936. tmpObj.t2 = tmpTime;
  7937. tmpObj.x1 = tmpObj.x;
  7938. tmpObj.y1 = tmpObj.y;
  7939. tmpObj.x2 = data[i + 2];
  7940. tmpObj.y2 = data[i + 3];
  7941. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7942. tmpObj.d2 = data[i + 4];
  7943. tmpObj.health = data[i + 5];
  7944. tmpObj.dt = 0;
  7945. tmpObj.visible = true;
  7946. } else {
  7947. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7948. tmpObj.x2 = tmpObj.x;
  7949. tmpObj.y2 = tmpObj.y;
  7950. tmpObj.d2 = tmpObj.dir;
  7951. tmpObj.health = data[i + 5];
  7952. if (!aiManager.aiTypes[data[i + 1]].name)
  7953. tmpObj.name = config.cowNames[data[i + 6]];
  7954. tmpObj.forcePos = true;
  7955. tmpObj.sid = data[i];
  7956. tmpObj.visible = true;
  7957. }
  7958. i += 7;
  7959. }
  7960. }
  7961. }
  7962. // ANIMATE AI:
  7963. function animateAI(sid) {
  7964. tmpObj = findAIBySID(sid);
  7965. if (tmpObj) tmpObj.startAnim();
  7966. }
  7967. function gatherAnimation(sid, didHit, index) {
  7968. tmpObj = findPlayerBySID(sid);
  7969. if (tmpObj) {
  7970. tmpObj.startAnim(didHit, index);
  7971. tmpObj.gatherIndex = index;
  7972. tmpObj.gathering = 1;
  7973.  
  7974. // code by Xiaokai [Simple Anti]
  7975. 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);
  7976.  
  7977. if (didHit) {
  7978. let tmpObjects = objectManager.hitObj;
  7979. //preplacer
  7980. setTickout(() => {
  7981. setTimeout(() => {
  7982. if(getDist(player, enemy) <= 200) {
  7983. place(2, getDir(tmpObjects, player))
  7984. } else {
  7985. place(4, getDir(tmpObjects, player))
  7986. }
  7987. }, items.weapons[index].speed - window.pingTime)
  7988. }, 2)
  7989.  
  7990. objectManager.hitObj = [];
  7991.  
  7992. game.tickBase(() => {
  7993. tmpObj = findPlayerBySID(sid);
  7994. 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);
  7995. tmpObjects.forEach((healthy) => {
  7996. healthy.healthMov = healthy.health - val / 2;
  7997. healthy.health -= val;
  7998. //love to https://gist.github.com/bendc/76c48ce53299e6078a76
  7999. let h, s, l;
  8000. let color = (() => {
  8001. const randomInt = (min, max) => {
  8002. return Math.floor(Math.random() * (max - min + 1)) + min;
  8003. };
  8004. h = randomInt(0, 360);
  8005. s = randomInt(42, 98);
  8006. l = randomInt(40, 90);
  8007. // return `hsl(${h},${s}%,${l}%)`;
  8008. })();
  8009. //and love https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
  8010. function hslToHex(h, s, l) {
  8011. l /= 100;
  8012. const a = s * Math.min(l, 1 - l) / 100;
  8013. const f = n => {
  8014. const k = (n + h / 30) % 12;
  8015. const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
  8016. return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
  8017. };
  8018. return `#${f(0)}${f(8)}${f(4)}`;
  8019. }
  8020. console.log(hslToHex(h, s, l));
  8021. (healthy.x, healthy.y, val, hslToHex(h, s, l));
  8022. });
  8023. }, 1);
  8024. }
  8025. }
  8026. }
  8027. function showDamageText(x, y, value, color) {
  8028. textManager.showText(x, y, 30, 0.15, 550, Math.round(value), color);
  8029. }
  8030.  
  8031. // WIGGLE GAME OBJECT:
  8032. function wiggleGameObject(dir, sid) {
  8033. tmpObj = findObjectBySid(sid);
  8034. if (tmpObj) {
  8035. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  8036. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  8037. if (tmpObj.health) {
  8038. //tmpObj.damaged = Math.min(255, tmpObj.damaged + 60);
  8039. objectManager.hitObj.push(tmpObj);
  8040. }
  8041. }
  8042. }
  8043. // SHOOT TURRET:
  8044. function shootTurret(sid, dir) {
  8045. tmpObj = findObjectBySid(sid);
  8046. if (tmpObj) {
  8047. tmpObj.dir = dir;
  8048. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  8049. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  8050. }
  8051. }
  8052. function randomizePhrases2() {
  8053. 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...'];
  8054. return phrases[Math.floor(Math.random() * phrases.length)];
  8055. }
  8056. // UPDATE PLAYER VALUE:
  8057. function updatePlayerValue(index, value, updateView) {
  8058. if (player) {
  8059. player[index] = value;
  8060.  
  8061. if (index == "points") {
  8062. if (configs.autoBuy) {
  8063. autoBuy.hat();
  8064. autoBuy.acc();
  8065. }
  8066. } else if (index == "kills") {
  8067. if (configs.killChat) {
  8068. packet("6", "Wake up to reality.")
  8069. setTimeout(() => {
  8070. packet("6", "Nothing goes as ever planned.")
  8071. setTimeout(() => {
  8072. packet("6", "I ve sent you to the void.")
  8073. setTimeout(() => {
  8074. packet("6", "Kids in the void: " + player.kills)
  8075. }, 1500);
  8076. }, 1500);
  8077. }, 1500);
  8078. }
  8079. }
  8080. }
  8081. }
  8082. // Function to get a varying kill chat message
  8083. // Function to get a varying kill chat message
  8084. function getKillChatMessage(kills) {
  8085. // Calculate the base kill count
  8086. let baseKillCount = Math.floor(kills / 10) * 10;
  8087.  
  8088. if (kills <= 1) {
  8089. return "";
  8090. } else if (kills <= 2) {
  8091. return "";
  8092. } else if (kills <= 3) {
  8093. return "";
  8094. } else if (kills <= 4) {
  8095. return "";
  8096. } else if (kills <= 5) {
  8097. return "";
  8098. } else if (kills <= 6) {
  8099. return "";
  8100. } else if (kills <= 7) {
  8101. return "";
  8102. } else if (kills <= 8) {
  8103. return "";
  8104. } else if (kills <= 9) {
  8105. return "";
  8106. } else if (kills <= 10) {
  8107. return "";
  8108. } else if (kills <= 11) {
  8109. return "";
  8110. } else if (kills <= 12) {
  8111. return "";
  8112. } else if (kills <= 13) {
  8113. return "";
  8114. } else if (kills <= 14) {
  8115. return "";
  8116. } else if (kills <= 15) {
  8117. return "";
  8118. } else if (kills <= 16) {
  8119. return "";
  8120. } else if (kills <= 17) {
  8121. return "";
  8122. } else if (kills <= 18) {
  8123. return "";
  8124. } else if (kills <= 19) {
  8125. return "";
  8126. } else if (kills <= 20) {
  8127. return "";
  8128. } else if (kills <= 21) {
  8129. return "";
  8130. } else if (kills <= 22) {
  8131. return "";
  8132. } else if (kills <= 23) {
  8133. return "";
  8134. } else if (kills <= 24) {
  8135. return "";
  8136. } else if (kills <= 25) {
  8137. return "";
  8138. } else if (kills <= 26) {
  8139. return "";
  8140. } else if (kills <= 27) {
  8141. return "";
  8142. } else if (kills <= 28) {
  8143. return "";
  8144. } else if (kills <= 29) {
  8145. return "";
  8146. } else if (kills <= 30) {
  8147. return "";
  8148. } else {
  8149.  
  8150. // Display additional information when the kill count crosses a multiple of 10
  8151. let additionalInfo = "x" + (Math.floor(kills / 10) - 1);
  8152. return
  8153. }
  8154. }
  8155. // ACTION BAR:
  8156. function updateItems(data, wpn) {
  8157. if (data) {
  8158. if (wpn) {
  8159. player.weapons = data;
  8160. player.primaryIndex = player.weapons[0];
  8161. player.secondaryIndex = player.weapons[1];
  8162. if (!instaC.isTrue) {
  8163. selectWeapon(player.weapons[0]);
  8164. }
  8165. } else {
  8166. player.items = data;
  8167. }
  8168. }
  8169. for (let i = 0; i < items.list.length; i++) {
  8170. let tmpI = items.weapons.length + i;
  8171. getEl("actionBarItem" + tmpI).style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8172. }
  8173. for (let i = 0; i < items.weapons.length; i++) {
  8174. getEl("actionBarItem" + i).style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8175. }
  8176. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8177. if (kms) {
  8178. getEl("actionBarItem3").style.display = "none";
  8179. getEl("actionBarItem4").style.display = "inline-block";
  8180. }
  8181. }
  8182. // ADD PROJECTILE:
  8183. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8184. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8185. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8186. }
  8187. // REMOVE PROJECTILE:
  8188. function remProjectile(sid, range) {
  8189. for (let i = 0; i < projectiles.length; ++i) {
  8190. if (projectiles[i].sid == sid) {
  8191. projectiles[i].range = range;
  8192. let tmpObjects = objectManager.hitObj;
  8193. objectManager.hitObj = [];
  8194. game.tickBase(() => {
  8195. let val = projectiles[i].dmg;
  8196. tmpObjects.forEach((healthy) => {
  8197. if (healthy.projDmg) {
  8198. healthy.health -= val;
  8199. }
  8200. });
  8201. }, 1);
  8202. }
  8203. }
  8204. }
  8205. // SHOW ALLIANCE MENU:
  8206. function allianceNotification(sid, name) {
  8207. let findBotSID = findSID(bots, sid);
  8208. if (findBotSID) { }
  8209. }
  8210. function setPlayerTeam(team, isOwner) {
  8211. if (player) {
  8212. player.team = team;
  8213. player.isOwner = isOwner;
  8214. if (team == null)
  8215. alliancePlayers = [];
  8216. }
  8217. }
  8218. function setAlliancePlayers(data) {
  8219. alliancePlayers = data;
  8220. }
  8221. // STORE MENU:
  8222. function updateStoreItems(type, id, index) {
  8223. if (index) {
  8224. if (!type)
  8225. player.tails[id] = 1;
  8226. else {
  8227. player.latestTail = id;
  8228. }
  8229. } else {
  8230. if (!type)
  8231. player.skins[id] = 1,
  8232. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8233. else {
  8234. player.latestSkin = id;
  8235. }
  8236. }
  8237. }
  8238. // SEND MESSAGE:
  8239. function receiveChat(sid, message) {
  8240. let tmpPlayer = findPlayerBySID(sid);
  8241. if(message.startsWith('HaHa') && (player.isTeam(tmpPlayer) || sid == player.sid) &&window.VirusterDev){
  8242. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'Sync Trigger', '#f00', 2);
  8243. let teammate = tmpPlayer
  8244. top.lastSync = Date.now();
  8245. let teamPing = parseInt(message.split('HaHa')[1]), teamDist = UTILS.getDistance(near.x, near.y, teammate.x, teammate.y)
  8246. // |||||||
  8247. //turret and musket MS calculation formula by memeganoob big thanks to him vvvvvvv
  8248. let turretSpeed = UTILS.getDistance(near.x, near.y, player.x, player.y) / 1.5, musketSpeed = (UTILS.getDistance(near.x, near.y, player.x, player.y) - 35) / 3.6;
  8249. let teamTurretSpeed = UTILS.getDistance(near.x, near.y, teammate.x, teammate.y) / 1.5, teamMusketSpeed = (UTILS.getDistance(near.x, near.y, teammate.x, teammate.y) - 35) / 3.6;
  8250. //console.log(turretSpeed, teamTurretSpeed, teamDist)
  8251. let Clapped = ()=>{
  8252. buyEquip(53, 0);
  8253. selectWeapon(player.secondaryIndex)
  8254. my.autoAim = true;
  8255. setTimeout(() => {
  8256. sendAutoGather();
  8257. setTimeout(()=>{
  8258. my.autoAim = false;
  8259. sendAutoGather();
  8260. },250)
  8261. }, turretSpeed - musketSpeed);
  8262. };
  8263. //Clapped();
  8264. if(turretSpeed > teamTurretSpeed){
  8265. Clapped();
  8266. }else{
  8267. setTimeout(()=>{
  8268. Clapped();
  8269. },teamTurretSpeed - turretSpeed)
  8270. }
  8271. }else{
  8272. if (tmpPlayer) {
  8273.  
  8274. function get() {
  8275. if(tmpPlayer != player && player.team != tmpPlayer.team) {
  8276. return "#c95563";
  8277. } else if (player.team && player.team == tmpPlayer.team) {
  8278. return "#fff";
  8279. } else {
  8280. return "#0949aa"; //2394e8
  8281. }
  8282. }
  8283. let me = false;
  8284. if(tmpPlayer == player) me = true
  8285. else me = false;
  8286. addChatLog(message, "#fff", tmpPlayer.name + "[" + tmpPlayer.sid + "]:", tmpPlayer == player || (tmpPlayer.team && tmpPlayer.team == player.team) ? "#279df1" : "#fff");
  8287. tmpPlayer.chatMessage = ((text) => {
  8288. let tmpString;
  8289. profanityList.forEach((list) => {
  8290. if (text.indexOf(list) > -1) {
  8291. tmpString = "";
  8292. for (var y = 0; y < list.length; ++y) {
  8293. tmpString += tmpString.length ? "o" : "M";
  8294. }
  8295. var re = new RegExp(list, 'g');
  8296. text = text.replace(re, tmpString);
  8297. }
  8298. });
  8299. return text;
  8300. })(message);
  8301. tmpPlayer.chatCountdown = config.chatCountdown;
  8302. }
  8303. }
  8304. }
  8305. // MINIMAP:
  8306. function updateMinimap(data) {
  8307. minimapData = data;
  8308. }
  8309. // SHOW ANIM TEXT:
  8310. function showText(x, y, value, type, color) {
  8311. textManager.showText(x, y, 50, 0.18, 500, Math.abs(value), color);
  8312. }
  8313. /** APPLY SOCKET CODES */// BOT:
  8314. let bots = [];
  8315. let ranLocation = {
  8316. x: UTILS.randInt(35, 14365),
  8317. y: UTILS.randInt(35, 14365)
  8318. };
  8319. setInterval(() => {
  8320. ranLocation = {
  8321. x: UTILS.randInt(35, 14365),
  8322. y: UTILS.randInt(35, 14365)
  8323. };
  8324. }, 60000);
  8325. class Bot {
  8326. constructor(id, sid, hats, accessories) {
  8327. this.millPlace = true;
  8328. this.id = id;
  8329. this.sid = sid;
  8330. this.team = null;
  8331. this.skinIndex = 0;
  8332. this.tailIndex = 0;
  8333. this.hitTime = 0;
  8334. this.iconIndex = 0;
  8335. this.enemy = [];
  8336. this.near = [];
  8337. this.dist2 = 0;
  8338. this.aim2 = 0;
  8339. this.tick = 0;
  8340. this.itemCounts = {};
  8341. this.latestSkin = 0;
  8342. this.latestTail = 0;
  8343. this.points = 0;
  8344. this.tails = {};
  8345. for (let i = 0; i < accessories.length; ++i) {
  8346. if (accessories[i].price <= 0)
  8347. this.tails[accessories[i].id] = 1;
  8348. }
  8349. this.skins = {};
  8350. for (let i = 0; i < hats.length; ++i) {
  8351. if (hats[i].price <= 0)
  8352. this.skins[hats[i].id] = 1;
  8353. }
  8354. this.spawn = function(moofoll) {
  8355. this.upgraded = 0;
  8356. this.enemy = [];
  8357. this.near = [];
  8358. this.active = true;
  8359. this.alive = true;
  8360. this.lockMove = false;
  8361. this.lockDir = false;
  8362. this.minimapCounter = 0;
  8363. this.chatCountdown = 0;
  8364. this.shameCount = 0;
  8365. this.shameTimer = 0;
  8366. this.sentTo = {};
  8367. this.gathering = 0;
  8368. this.autoGather = 0;
  8369. this.animTime = 0;
  8370. this.animSpeed = 0;
  8371. this.mouseState = 0;
  8372. this.buildIndex = -1;
  8373. this.weaponIndex = 0;
  8374. this.dmgOverTime = {};
  8375. this.noMovTimer = 0;
  8376. this.maxXP = 300;
  8377. this.XP = 0;
  8378. this.age = 1;
  8379. this.kills = 0;
  8380. this.upgrAge = 2;
  8381. this.upgradePoints = 0;
  8382. this.x = 0;
  8383. this.y = 0;
  8384. this.zIndex = 0;
  8385. this.xVel = 0;
  8386. this.yVel = 0;
  8387. this.slowMult = 1;
  8388. this.dir = 0;
  8389. this.nDir = 0;
  8390. this.dirPlus = 0;
  8391. this.targetDir = 0;
  8392. this.targetAngle = 0;
  8393. this.maxHealth = 100;
  8394. this.health = this.maxHealth;
  8395. this.oldHealth = this.maxHealth;
  8396. this.scale = config.playerScale;
  8397. this.speed = config.playerSpeed;
  8398. this.resetMoveDir();
  8399. this.resetResources(moofoll);
  8400. this.items = [0, 3, 6, 10];
  8401. this.weapons = [0];
  8402. this.shootCount = 0;
  8403. this.weaponXP = [];
  8404. this.isBot = false;
  8405. this.reloads = {
  8406. 0: 0,
  8407. 1: 0,
  8408. 2: 0,
  8409. 3: 0,
  8410. 4: 0,
  8411. 5: 0,
  8412. 6: 0,
  8413. 7: 0,
  8414. 8: 0,
  8415. 9: 0,
  8416. 10: 0,
  8417. 11: 0,
  8418. 12: 0,
  8419. 13: 0,
  8420. 14: 0,
  8421. 15: 0,
  8422. 53: 0,
  8423. };
  8424. this.timeZinceZpawn = 0;
  8425. this.whyDie = "";
  8426. this.clearRadius = false;
  8427. this.circlee = 0;
  8428. };
  8429. // RESET MOVE DIR:
  8430. this.resetMoveDir = function() {
  8431. this.moveDir = undefined;
  8432. };
  8433. // RESET RESOURCES:
  8434. this.resetResources = function(moofoll) {
  8435. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8436. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8437. }
  8438. };
  8439. // SET DATA:
  8440. this.setData = function(data) {
  8441. this.id = data[0];
  8442. this.sid = data[1];
  8443. this.name = data[2];
  8444. this.x = data[3];
  8445. this.y = data[4];
  8446. this.dir = data[5];
  8447. this.health = data[6];
  8448. this.maxHealth = data[7];
  8449. this.scale = data[8];
  8450. this.skinColor = data[9];
  8451. };
  8452. // SHAME SYSTEM:
  8453. this.judgeShame = function() {
  8454. if (this.oldHealth < this.health) {
  8455. if (this.hitTime) {
  8456. let timeSinceHit = this.tick - this.hitTime;
  8457. this.hitTime = 0;
  8458. if (timeSinceHit < 2) {
  8459. this.lastshamecount = this.shameCount;
  8460. this.shameCount++;
  8461. } else {
  8462. this.lastshamecount = this.shameCount;
  8463. this.shameCount = Math.max(0, this.shameCount - 2);
  8464. }
  8465. }
  8466. } else if (this.oldHealth > this.health) {
  8467. this.hitTime = this.tick;
  8468. }
  8469. };
  8470. // UPDATE WEAPON RELOAD:
  8471. this.manageReloadaa = function() {
  8472. if (this.shooting[53]) {
  8473. this.shooting[53] = 0;
  8474. this.reloads[53] = (2500 - 1000/9);
  8475. } else {
  8476. if (this.reloads[53] > 0) {
  8477. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8478. }
  8479. }
  8480. if (this.gathering || this.shooting[1]) {
  8481. if (this.gathering) {
  8482. this.gathering = 0;
  8483. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8484. this.attacked = true;
  8485. }
  8486. if (this.shooting[1]) {
  8487. this.shooting[1] = 0;
  8488. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8489. this.attacked = true;
  8490. }
  8491. } else {
  8492. this.attacked = false;
  8493. if (this.buildIndex < 0) {
  8494. if (this.reloads[this.weaponIndex] > 0) {
  8495. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8496. }
  8497. }
  8498. }
  8499. };
  8500. this.closeSockets = function(websc) {
  8501. websc.close();
  8502. };
  8503. this.whyDieChat = function(websc, whydie) {
  8504. websc.sendWS("6", "Noob " + whydie);
  8505. };
  8506. }
  8507. };
  8508. class BotObject {
  8509. constructor(sid) {
  8510. this.sid = sid;
  8511. // INIT:
  8512. this.init = function(x, y, dir, scale, type, data, owner) {
  8513. data = data || {};
  8514. this.active = true;
  8515. this.x = x;
  8516. this.y = y;
  8517. this.scale = scale;
  8518. this.owner = owner;
  8519. this.id = data.id;
  8520. this.dmg = data.dmg;
  8521. this.trap = data.trap;
  8522. this.teleport = data.teleport;
  8523. this.isItem = this.id != undefined;
  8524. };
  8525. }
  8526. };
  8527. class BotObjManager {
  8528. constructor(botObj, fOS) {
  8529. // DISABLE OBJ:
  8530. this.disableObj = function(obj) {
  8531. obj.active = false;
  8532. if (config.anotherVisual) {} else {
  8533. obj.alive = false;
  8534. }
  8535. };
  8536. // ADD NEW:
  8537. let tmpObj;
  8538. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8539. tmpObj = fOS(sid);
  8540. if (!tmpObj) {
  8541. tmpObj = botObj.find((tmp) => !tmp.active);
  8542. if (!tmpObj) {
  8543. tmpObj = new BotObject(sid);
  8544. botObj.push(tmpObj);
  8545. }
  8546. }
  8547. if (setSID) {
  8548. tmpObj.sid = sid;
  8549. }
  8550. tmpObj.init(x, y, dir, s, type, data, owner);
  8551. };
  8552. // DISABLE BY SID:
  8553. this.disableBySid = function(sid) {
  8554. let find = fOS(sid);
  8555. if (find) {
  8556. this.disableObj(find);
  8557. }
  8558. };
  8559. // REMOVE ALL FROM PLAYER:
  8560. this.removeAllItems = function(sid, server) {
  8561. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8562. };
  8563. }
  8564. };
  8565. let botz = [];
  8566. function botSpawn(id) {
  8567. let bot;
  8568. console.log(WS);
  8569. let t = WS.url.split("wss://")[1].split("?")[0];
  8570. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8571. let botPlayer = new Map();
  8572. botSkts.push([botPlayer]);
  8573. botz.push([bot]);
  8574. let botSID;
  8575. let botObj = [];
  8576. let nearObj = [];
  8577. let bD = {
  8578. x: 0,
  8579. y: 0,
  8580. inGame: false,
  8581. closeSocket: false,
  8582. whyDie: ""
  8583. };
  8584. let oldXY = {
  8585. x: 0,
  8586. y: 0,
  8587. };
  8588. let izauto = 0;
  8589. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8590. bot.binaryType = "arraybuffer";
  8591. bot.first = true;
  8592. bot.sendWS = function(type) {
  8593. // EXTRACT DATA ARRAY:
  8594. let data = Array.prototype.slice.call(arguments, 1);
  8595. // SEND MESSAGE:
  8596. let binary = window.msgpack.encode([type, data]);
  8597. bot.send(binary);
  8598. };
  8599. bot.spawn = function() {
  8600. bot.sendWS("M", {
  8601. name: "get bagged",
  8602. moofoll: 1,
  8603. skin: "__proto__"
  8604. });
  8605. };
  8606. bot.sendUpgrade = function(index) {
  8607. bot.sendWS("H", index);
  8608. };
  8609. bot.place = function(id, a) {
  8610. try {
  8611. let item = items.list[botPlayer.items[id]];
  8612. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  8613. bot.sendWS("G", botPlayer.items[id]);
  8614. bot.sendWS("d", 1, a);
  8615. bot.sendWS("G", botPlayer.weaponIndex, true);
  8616. }
  8617. } catch (e) {
  8618. }
  8619. };
  8620. bot.buye = function(id, index) {
  8621. let nID = 0;
  8622. if (botPlayer.alive && botPlayer.inGame) {
  8623. if (index == 0) {
  8624. if (botPlayer.skins[id]) {
  8625. if (/*botPlayer.skinIndex != id*/true) {
  8626. bot.sendWS("c", 0, id, 0);
  8627. }
  8628. } else {
  8629. let find = findID(hats, id);
  8630. if (find) {
  8631. if (botPlayer.points >= find.price) {
  8632. bot.sendWS("c", 1, id, 0);
  8633. bot.sendWS("c", 0, id, 0);
  8634. } else {
  8635. if (/*botPlayer.latestSkin != nID*/true) {
  8636. bot.sendWS("c", 0, nID, 0);
  8637. }
  8638. }
  8639. } else {
  8640. if (/*botPlayer.latestSkin != nID*/true) {
  8641. bot.sendWS("c", 0, nID, 0);
  8642. }
  8643. }
  8644. }
  8645. } else if (index == 1) {
  8646. if (botPlayer.tails[id]) {
  8647. if (botPlayer.latestTail != id) {
  8648. bot.sendWS("c", 0, id, 1);
  8649. }
  8650. } else {
  8651. let find = findID(accessories, id);
  8652. if (find) {
  8653. if (botPlayer.points >= find.price) {
  8654. bot.sendWS("c", 1, id, 1);
  8655. bot.sendWS("c", 0, id, 1);
  8656. } else {
  8657. if (botPlayer.latestTail != 0) {
  8658. bot.sendWS("c", 0, 0, 1);
  8659. }
  8660. }
  8661. } else {
  8662. if (botPlayer.latestTail != 0) {
  8663. bot.sendWS("c", 0, 0, 1);
  8664. }
  8665. }
  8666. }
  8667. }
  8668. }
  8669. };
  8670. bot.fastGear = function() {
  8671. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8672. bot.buye(31, 0);
  8673. } else {
  8674. if (botPlayer.y2 <= config.snowBiomeTop) {
  8675. bot.buye(15, 0);
  8676. } else {
  8677. bot.buye(12, 0);
  8678. }
  8679. }
  8680. };
  8681. bot.selectWeapon = function(a) {
  8682. packet("G", a, 1);
  8683. }
  8684. function caf(e, t) {
  8685. try {
  8686. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8687. } catch (e) {
  8688. return 0;
  8689. }
  8690. }
  8691. bot.heal = function() {
  8692. if (botPlayer.health < 100) {
  8693. bot.place(0, 0)
  8694. }
  8695. }
  8696. function cdf (e, t){
  8697. try {
  8698. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8699. } catch(e){
  8700. return Infinity;
  8701. }
  8702. }
  8703. let zoon = 'no';
  8704. bot.zync = function(a) {
  8705. if (!botPlayer.millPlace) {
  8706. zoon = 'yeah';
  8707. bot.place(5, caf(botPlayer, a));
  8708. let NextTickLocation = {
  8709. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8710. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8711. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8712. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8713. };
  8714. function calculateDistance(x1, y1, x2, y2) {
  8715. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8716. return distance;
  8717. }
  8718. function dotherezt() {
  8719. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8720. }
  8721. let turretSpeed = UTILS.getDistance(near.x, near.y, botPlayer.x2, botPlayer.y2) / 1.5, musketSpeed = (UTILS.getDistance(near.x, near.y, botPlayer.x2, botPlayer.y2) - 35) / 3.6;
  8722. bot.buye(53, 0);
  8723. let aa = setInterval(()=>{
  8724. dotherezt();
  8725. },100)
  8726. setTimeout(()=>{
  8727. bot.sendWS("G", botPlayer.weapons[1], true);
  8728. if (izauto == 0) {
  8729. bot.sendWS("K", 1);
  8730. izauto = 1;
  8731. }
  8732. setTimeout(() => {
  8733. bot.sendWS("G", botPlayer.weapons[0], true);
  8734. clearInterval(aa)
  8735. }, 1000);
  8736. setTimeout(() => {
  8737. zoon = 'no';
  8738. }, 500);
  8739. },turretSpeed-(musketSpeed*2))
  8740. bot.buye(53, 0);
  8741. }
  8742. };
  8743. bot.onmessage = function(message) {
  8744. let data = new Uint8Array(message.data);
  8745. let parsed = window.msgpack.decode(data);
  8746. let type = parsed[0];
  8747. data = parsed[1];
  8748. if (type == "io-init") {
  8749. bot.spawn();
  8750. }
  8751. if (type == "1") {
  8752. botSID = data[0];
  8753. console.log(botSID)
  8754. setInterval(()=>{
  8755. bot.fastGear();
  8756. },60000)
  8757. }
  8758. if (type == "D") {
  8759. if (data[1]) {
  8760. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8761. botPlayer.setData(data[0]);
  8762. botPlayer.inGame = true;
  8763. botPlayer.alive = true;
  8764. botPlayer.x2 = undefined;
  8765. botPlayer.y2 = undefined;
  8766. botPlayer.spawn(1);
  8767. botPlayer.oldHealth = 100;
  8768. botPlayer.health = 100;
  8769. botPlayer.showName = 'NOOO';
  8770. oldXY = {
  8771. x: data[0][3],
  8772. y: data[0][4]
  8773. }
  8774. bD.inGame = true;
  8775. if (bot.first) {
  8776. bot.first = false;
  8777. bots.push(bD);
  8778. }
  8779. }
  8780. }
  8781. if (type == "P") {
  8782. bot.spawn();
  8783. botPlayer.inGame = false;
  8784. bD.inGame = false;
  8785. }
  8786. if (type == "a") {
  8787. let tmpData = data[0];
  8788. botPlayer.tick++;
  8789. botPlayer.enemy = [];
  8790. botPlayer.near = [];
  8791. bot.showName = 'NOOO';
  8792. nearObj = [];
  8793. for (let i = 0; i < tmpData.length;) {
  8794. if (tmpData[i] == botPlayer.sid) {
  8795. botPlayer.x2 = tmpData[i + 1];
  8796. botPlayer.y2 = tmpData[i + 2];
  8797. botPlayer.d2 = tmpData[i + 3];
  8798. botPlayer.buildIndex = tmpData[i + 4];
  8799. botPlayer.weaponIndex = tmpData[i + 5];
  8800. botPlayer.weaponVariant = tmpData[i + 6];
  8801. botPlayer.team = tmpData[i + 7];
  8802. botPlayer.isLeader = tmpData[i + 8];
  8803. botPlayer.skinIndex = tmpData[i + 9];
  8804. botPlayer.tailIndex = tmpData[i + 10];
  8805. botPlayer.iconIndex = tmpData[i + 11];
  8806. botPlayer.zIndex = tmpData[i + 12];
  8807. botPlayer.visible = true;
  8808. bD.x2 = botPlayer.x2;
  8809. bD.y2 = botPlayer.y2;
  8810. }
  8811. i += 13;
  8812. }
  8813. for (let i = 0; i < tmpData.length;) {
  8814. tmpObj = findPlayerBySID(tmpData[i]);
  8815. if (tmpObj) {
  8816. if (!tmpObj.isTeam(botPlayer)) {
  8817. enemy.push(tmpObj);
  8818. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8819. nears.push(tmpObj);
  8820. }
  8821. }
  8822. }
  8823. i += 13;
  8824. }
  8825. if (enemy.length) {
  8826. //console.log(enemy)
  8827. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8828. return tmp1.dist2 - tmp2.dist2;
  8829. })[0];
  8830. }
  8831. if (izauto == 1) {
  8832. bot.sendWS("K", 1);
  8833. izauto = 0;
  8834. }
  8835. if (bD.closeSocket) {
  8836. botPlayer.closeSockets(bot);
  8837. }
  8838. if (bD.whyDie != "") {
  8839. botPlayer.whyDieChat(bot, bD.whyDie);
  8840. bD.whyDie = "";
  8841. }
  8842. if (botPlayer.alive) {
  8843. if (player.team) {
  8844. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8845. botPlayer.team && (bot.sendWS("N"));
  8846. bot.sendWS("b", player.team);
  8847. setTimeout(()=>{bottzzz.push(botPlayer.sid)},2000)
  8848. }
  8849. }
  8850. let item = items.list[botPlayer.items[3]];
  8851. let a = botPlayer.itemCounts[item.group.id]
  8852. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8853. if (botPlayer.inGame) {
  8854. bot.sendWS("D", botPlayer.moveDir);
  8855. if (izauto == 0) {
  8856. bot.sendWS("K", 1);
  8857. izauto = 1;
  8858. }
  8859. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 200) {
  8860. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8861. bot.place(3, aim + 7.7);
  8862. bot.place(3, aim - 7.7);
  8863. bot.place(3, aim);
  8864. oldXY = {
  8865. x: botPlayer.x2,
  8866. y: botPlayer.y2
  8867. };
  8868. }
  8869. if (botPlayer.tick % 90 === 0) {
  8870. let rand = Math.random() * Math.PI * 2;
  8871. botPlayer.moveDir = rand;
  8872. bot.sendWS("a", botPlayer.moveDir);
  8873. }
  8874. }
  8875. bot.fastGear();
  8876. } else if((a != undefined ? a : 0) > 198 && botPlayer.millPlace) {
  8877. botPlayer.millPlace = false;
  8878. if (izauto == 0) {
  8879. bot.sendWS("K", 1);
  8880. izauto = 1;
  8881. }
  8882. bot.buye(11, 1);
  8883. bot.fastGear();
  8884. } else {
  8885. if (botPlayer.inGame) {
  8886. if (botObj.length > 0) {
  8887. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8888. if (getEl("mode").value == 'fuckemup') {
  8889. // if (getEl("mode").value == "clear") {
  8890. bot.selectWeapon(botPlayer.weapons[1]);
  8891. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8892. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8893. nearObj = botObj.filter((e) => e.active && (findSID(buldingtoawdoin, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2)).sort(function(a, b) {
  8894. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8895. })[0];
  8896. if (nearObj) {
  8897. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8898. if ((gotoDist - isPassed) > 0) {
  8899. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8900. if (botPlayer.moveDir != undefined) {
  8901. botPlayer.moveDir = undefined;
  8902. bot.sendWS("a", botPlayer.moveDir);
  8903. bot.sendWS("D", botPlayer.nDir);
  8904. }
  8905. } else {
  8906. botPlayer.moveDir = gotoAim;
  8907. bot.sendWS("a", botPlayer.moveDir);
  8908. bot.sendWS("D", botPlayer.nDir);
  8909. }
  8910. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8911. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8912. bot.sendWS("D", botPlayer.nDir);
  8913. }
  8914. if (izauto == 0) {
  8915. bot.sendWS("K", 1);
  8916. izauto = 1;
  8917. }
  8918. bot.buye(40, 0);
  8919. } else {
  8920. botPlayer.moveDir = gotoAim;
  8921. bot.sendWS("a", botPlayer.moveDir);
  8922. bot.sendWS("D", botPlayer.nDir);
  8923. bot.fastGear();
  8924. }
  8925. } else {
  8926. botPlayer.moveDir = gotoAim;
  8927. bot.sendWS("a", botPlayer.moveDir);
  8928. bot.sendWS("D", botPlayer.nDir);
  8929. bot.fastGear();
  8930. }
  8931. }
  8932. }
  8933. if (botObj.length > 0) {
  8934. if (getEl("mode").value == 'flex') {
  8935. const circleRadius = 300;
  8936. const circleCenterX = player.x2;
  8937. const circleCenterY = player.y2;
  8938. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  8939. angle -= 0.1;
  8940. const x = circleCenterX + circleRadius * Math.cos(angle);
  8941. const y = circleCenterY + circleRadius * Math.sin(angle);
  8942. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8943. }
  8944.  
  8945. }
  8946.  
  8947. if (botObj.length > 0) {
  8948. if (getEl("mode").value == 'mouse') {
  8949. bot.sendWS("a", Math.atan2((player.y2 - botPlayer.y2) + mouseY - (gameCanvas.height / 1.5), (player.x2- botPlayer.x2) + mouseX - (gameCanvas.width / 1.5)));
  8950. }
  8951.  
  8952. }
  8953.  
  8954. if (botObj.length > 0) {
  8955. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8956. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8957. })[0];
  8958. if (nearObj&&((getEl("mode").value == 'fight'?(nearObj.isTeamObject(player)?false:true):true))) {//herenigga
  8959. if (izauto == 0) {
  8960. bot.sendWS("K", 1);
  8961. izauto = 1;
  8962. }
  8963. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8964. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8965. bot.sendWS("D", botPlayer.nDir);
  8966. }
  8967. bot.buye(40, 0);
  8968. bot.buye(11, 1);
  8969. } else {
  8970. bot.fastGear();
  8971. bot.buye(11, 1);
  8972. }
  8973. bot.buye(11, 1);
  8974. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8975. bot.selectWeapon(botPlayer.weapons[1]);
  8976. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8977. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8978. 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) {
  8979. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8980. })[0];
  8981. if (nearObj) {
  8982. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8983. if ((gotoDist - isPassed) > 0) {
  8984. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8985. // botPlayer.moveDir = undefined;
  8986. bot.sendWS("a", caf);
  8987. bot.sendWS("D", botPlayer.nDir);
  8988. } else {
  8989. // botPlayer.moveDir = gotoAim;
  8990. // bot.sendWS("a", botPlayer.moveDir);
  8991. bot.sendWS("D", botPlayer.nDir);
  8992. }
  8993. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8994. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8995. bot.sendWS("D", botPlayer.nDir);
  8996. }
  8997. if (izauto == 0) {
  8998. bot.sendWS("K", 1);
  8999. izauto = 1;
  9000. }
  9001. bot.buye(40, 0);
  9002. // bot.fastGear();
  9003. bot.buye(11, 1);
  9004. } else {
  9005. botPlayer.moveDir = gotoAim;
  9006. bot.sendWS("a", botPlayer.moveDir);
  9007. bot.sendWS("D", botPlayer.nDir);
  9008. bot.fastGear();
  9009. bot.buye(11, 1);
  9010. }
  9011. } else {
  9012. botPlayer.moveDir = gotoAim;
  9013. bot.sendWS("a", botPlayer.moveDir);
  9014. bot.sendWS("D", botPlayer.nDir);
  9015. bot.fastGear();
  9016. bot.buye(11, 1);
  9017. }
  9018. }
  9019. }
  9020. if (botObj.length > 0 && getEl("mode").value == 'stopp') {
  9021. if (cdf(window.stopSpot, botPlayer) <= 220) {
  9022. bot.sendWS("a", undefined);
  9023. bot.fastGear();
  9024. } else {
  9025. bot.sendWS("a", caf(window.stopSpot, botPlayer) + Math.PI);
  9026. }
  9027. }
  9028. if (botObj.length > 0 && getEl("mode").value == 'fight') {
  9029. if(near.sid) {
  9030. const circleRadius = 100;
  9031. const circleCenterX = near.x;
  9032. const circleCenterY = near.y;
  9033. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9034. angle -= 0.1;
  9035. const x = circleCenterX + circleRadius * Math.cos(angle);
  9036. const y = circleCenterY + circleRadius * Math.sin(angle);
  9037. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9038. if(UTILS.getDist(near, botPlayer, 0, 2) < 200) {
  9039. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9040. }
  9041. if(UTILS.getDist(near, botPlayer, 0, 2) < 400) {
  9042. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9043. }
  9044. } else{
  9045. const circleRadius = 100;
  9046. const circleCenterX = player.x2;
  9047. const circleCenterY = player.y2;
  9048. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9049. angle -= 0.1;
  9050. const x = circleCenterX + circleRadius * Math.cos(angle);
  9051. const y = circleCenterY + circleRadius * Math.sin(angle);
  9052. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9053. }
  9054. }
  9055. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9056. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2));
  9057. if (!wdaawdwad.length) {
  9058. if (zoon == 'no') {
  9059. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9060. }
  9061. if (cdf(player, botPlayer) <= 220) {
  9062. bot.sendWS("a", undefined);
  9063. bot.fastGear();
  9064. } else {
  9065. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9066. }
  9067. } else {
  9068. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9069. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9070. let nearObjs = botObj.filter((e) => e.active && (findSID(wdaawdwad, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2)).sort(function(a, b) {
  9071. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9072. });
  9073. if (nearObjs.length > 0) {
  9074. let nearObj = nearObjs[0];
  9075. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9076. if ((gotoDist - isPassed) > 0) {
  9077. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9078. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9079. // if (botPlayer.moveDir != undefined) {
  9080. // botPlayer.moveDir = undefined;
  9081. // bot.sendWS("a", botPlayer.moveDir);
  9082. bot.sendWS("D", botPlayer.nDir);
  9083. // }
  9084. } else {
  9085. bot.sendWS("D", botPlayer.nDir);
  9086. }
  9087. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9088. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9089. bot.sendWS("D", botPlayer.nDir);
  9090. }
  9091. bot.buye(40, 0);
  9092. // bot.fastGear();
  9093. bot.buye(11, 1);
  9094. if (izauto == 0) {
  9095. bot.sendWS("K", 1);
  9096. izauto = 1;
  9097. }
  9098. } else {
  9099. if (zoon == 'no') {
  9100. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  9101. }
  9102. if (cdf(player, botPlayer) <= 220) {
  9103. bot.sendWS("a", undefined);
  9104. } else {
  9105. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9106. }
  9107. }
  9108. } else {
  9109. if (wdaawdwad.length) {
  9110. if (zoon == 'no') {
  9111. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  9112. // if (izauto == 0) {
  9113. // bot.sendWS("K", 1);
  9114. // izauto = 1;
  9115. // }
  9116. }
  9117. if (cdf(player, botPlayer) <= 220) {
  9118. bot.sendWS("a", undefined);
  9119. } else {
  9120. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9121. }
  9122. } else {
  9123. if (zoon == 'no') {
  9124. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9125. }
  9126. if (cdf(player, botPlayer) <= 220) {
  9127. bot.sendWS("a", undefined);
  9128. } else {
  9129. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9130. }
  9131. }
  9132. }
  9133. }
  9134. }
  9135. }
  9136. }
  9137. }
  9138. }
  9139. if (type == "H") {
  9140. let tmpData = data[0];
  9141. for (let i = 0; i < tmpData.length;) {
  9142. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9143. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9144. sid: tmpData[i + 7]
  9145. } : null));
  9146. i += 8;
  9147. }
  9148. }
  9149. if (type == "N") {
  9150. let index = data[0];
  9151. let value = data[1];
  9152. if (botPlayer) {
  9153. botPlayer[index] = value;
  9154. }
  9155. }
  9156. if (type == "O") {
  9157. if (data[0] == botPlayer.sid) {
  9158. botPlayer.oldHealth = botPlayer.health;
  9159. botPlayer.health = data[1];
  9160. botPlayer.judgeShame();
  9161. if (botPlayer.oldHealth > botPlayer.health) {
  9162. if (botPlayer.shameCount < 5) {
  9163. for (let i = 0; i < 2; i++) {
  9164. bot.place(0, botPlayer.nDir);
  9165. }
  9166. } else {
  9167. setTimeout(() => {
  9168. for (let i = 0; i < 2; i++) {
  9169. bot.place(0, botPlayer.nDir);
  9170. }
  9171. }, 95);
  9172. }
  9173. }
  9174. }
  9175. }
  9176. if (type == "Q") {
  9177. let sid = data[0];
  9178. botObjManager.disableBySid(sid);
  9179. }
  9180. if (type == "R") {
  9181. let sid = data[0];
  9182. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9183. }
  9184. if (type == "S") {
  9185. let index = data[0];
  9186. let value = data[1];
  9187. if (botPlayer) {
  9188. botPlayer.itemCounts[index] = value;
  9189. }
  9190. }
  9191. if (type == "U") {
  9192. if (data[0] > 0) {
  9193. if(getEl("setup").value == 'dm') {
  9194. if (botPlayer.upgraded == 0) {
  9195. bot.sendUpgrade(7);
  9196. } else if (botPlayer.upgraded == 1) {
  9197. bot.sendUpgrade(17);
  9198. } else if (botPlayer.upgraded == 2) {
  9199. bot.sendUpgrade(31);
  9200. } else if (botPlayer.upgraded == 3) {
  9201. bot.sendUpgrade(23);
  9202. } else if (botPlayer.upgraded == 4) {
  9203. bot.sendUpgrade(9);
  9204. } else if (botPlayer.upgraded == 5) {
  9205. bot.sendUpgrade(34);
  9206. } else if (botPlayer.upgraded == 6) {
  9207. bot.sendUpgrade(12);
  9208. } else if (botPlayer.upgraded == 7) {
  9209. bot.sendUpgrade(15);
  9210. }
  9211. } else if(getEl("setup").value == 'dr') {
  9212. if (botPlayer.upgraded == 0) {
  9213. bot.sendUpgrade(7);
  9214. } else if (botPlayer.upgraded == 1) {
  9215. bot.sendUpgrade(17);
  9216. } else if (botPlayer.upgraded == 2) {
  9217. bot.sendUpgrade(31);
  9218. } else if (botPlayer.upgraded == 3) {
  9219. bot.sendUpgrade(23);
  9220. } else if (botPlayer.upgraded == 4) {
  9221. bot.sendUpgrade(9);
  9222. } else if (botPlayer.upgraded == 5) {
  9223. bot.sendUpgrade(34);
  9224. } else if (botPlayer.upgraded == 6) {
  9225. bot.sendUpgrade(12);
  9226. } else if (botPlayer.upgraded == 7) {
  9227. bot.sendUpgrade(13);
  9228. }
  9229. } else if(getEl("setup").value == 'kh') {
  9230. if (botPlayer.upgraded == 0) {
  9231. bot.sendUpgrade(3);
  9232. } else if (botPlayer.upgraded == 1) {
  9233. bot.sendUpgrade(17);
  9234. } else if (botPlayer.upgraded == 2) {
  9235. bot.sendUpgrade(31);
  9236. } else if (botPlayer.upgraded == 3) {
  9237. bot.sendUpgrade(27);
  9238. } else if (botPlayer.upgraded == 4) {
  9239. bot.sendUpgrade(10);
  9240. } else if (botPlayer.upgraded == 5) {
  9241. bot.sendUpgrade(34);
  9242. } else if (botPlayer.upgraded == 6) {
  9243. bot.sendUpgrade(4);
  9244. } else if (botPlayer.upgraded == 7) {
  9245. bot.sendUpgrade(25);
  9246. }
  9247. } else if(getEl("setup").value == 'zd') {
  9248. if (botPlayer.upgraded == 0) {
  9249. bot.sendUpgrade(3);
  9250. } else if (botPlayer.upgraded == 1) {
  9251. bot.sendUpgrade(17);
  9252. } else if (botPlayer.upgraded == 2) {
  9253. bot.sendUpgrade(31);
  9254. } else if (botPlayer.upgraded == 3) {
  9255. bot.sendUpgrade(27);
  9256. } else if (botPlayer.upgraded == 4) {
  9257. bot.sendUpgrade(9);
  9258. } else if (botPlayer.upgraded == 5) {
  9259. bot.sendUpgrade(34);
  9260. } else if (botPlayer.upgraded == 6) {
  9261. bot.sendUpgrade(12);
  9262. } else if (botPlayer.upgraded == 7) {
  9263. bot.sendUpgrade(15);
  9264. }
  9265. }
  9266. botPlayer.upgraded++;
  9267. }
  9268. }
  9269. if (type == "V") {
  9270. let tmpData = data[0];
  9271. let wpn = data[1];
  9272. if (tmpData) {
  9273. if (wpn) botPlayer.weapons = tmpData;
  9274. else botPlayer.items = tmpData;
  9275. }
  9276. }
  9277. if (type == "5") {
  9278. let type = data[0];
  9279. let id = data[1];
  9280. let index = data[2];
  9281. if (index) {
  9282. if (!type)
  9283. botPlayer.tails[id] = 1;
  9284. else
  9285. botPlayer.latestTail = id;
  9286. } else {
  9287. if (!type)
  9288. botPlayer.skins[id] = 1;
  9289. else
  9290. botPlayer.latestSkin = id;
  9291. }
  9292. }
  9293. if (type == "6") {
  9294. let id = data[0];
  9295. let mzg = data[1]+'';
  9296. if(id == player.sid && mzg.includes("!e")) {
  9297. //bot.zync(botPlayer.near);
  9298. }
  9299. }
  9300. };
  9301. bot.onclose = function() {
  9302. botPlayer.inGame = false;
  9303. bD.inGame = false;
  9304. };
  9305. }
  9306. //botend
  9307. // RENDER LEAF:
  9308. function renderLeaf(x, y, l, r, ctxt) {
  9309. let endX = x + (l * Math.cos(r));
  9310. let endY = y + (l * Math.sin(r));
  9311. let width = l * 0.4;
  9312. ctxt.moveTo(x, y);
  9313. ctxt.beginPath();
  9314. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  9315. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  9316. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  9317. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  9318. ctxt.closePath();
  9319. ctxt.fill();
  9320. ctxt.stroke();
  9321. }
  9322. // RENDER CIRCLE:
  9323. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9324. tmpContext = tmpContext || mainContext;
  9325. tmpContext.beginPath();
  9326. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9327. if (!dontFill) tmpContext.fill();
  9328. if (!dontStroke) tmpContext.stroke();
  9329. }
  9330. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9331. tmpContext = tmpContext || mainContext;
  9332. tmpContext.beginPath();
  9333. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9334. if (!dontFill) tmpContext.fill();
  9335. if (!dontStroke) tmpContext.stroke();
  9336. }
  9337. // RENDER STAR SHAPE:
  9338. function renderStar(ctxt, spikes, outer, inner) {
  9339. let rot = Math.PI / 2 * 3;
  9340. let x, y;
  9341. let step = Math.PI / spikes;
  9342. ctxt.beginPath();
  9343. ctxt.moveTo(0, -outer);
  9344. for (let i = 0; i < spikes; i++) {
  9345. x = Math.cos(rot) * outer;
  9346. y = Math.sin(rot) * outer;
  9347. ctxt.lineTo(x, y);
  9348. rot += step;
  9349. x = Math.cos(rot) * inner;
  9350. y = Math.sin(rot) * inner;
  9351. ctxt.lineTo(x, y);
  9352. rot += step;
  9353. }
  9354. ctxt.lineTo(0, -outer);
  9355. ctxt.closePath();
  9356. }
  9357. function renderHealthStar(ctxt, spikes, outer, inner) {
  9358. let rot = Math.PI / 2 * 3;
  9359. let x, y;
  9360. let step = Math.PI / spikes;
  9361. ctxt.beginPath();
  9362. ctxt.moveTo(0, -outer);
  9363. for (let i = 0; i < spikes; i++) {
  9364. x = Math.cos(rot) * outer;
  9365. y = Math.sin(rot) * outer;
  9366. ctxt.lineTo(x, y);
  9367. rot += step;
  9368. x = Math.cos(rot) * inner;
  9369. y = Math.sin(rot) * inner;
  9370. ctxt.lineTo(x, y);
  9371. rot += step;
  9372. }
  9373. ctxt.lineTo(0, -outer);
  9374. ctxt.closePath();
  9375. }
  9376. // RENDER RECTANGLE:
  9377. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9378. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9379. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9380. }
  9381. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9382. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9383. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9384. }
  9385. // RENDER RECTCIRCLE:
  9386. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9387. ctxt.save();
  9388. ctxt.translate(x, y);
  9389. seg = Math.ceil(seg / 2);
  9390. for (let i = 0; i < seg; i++) {
  9391. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9392. ctxt.rotate(Math.PI / seg);
  9393. }
  9394. ctxt.restore();
  9395. }
  9396. // RENDER BLOB:
  9397. function renderBlob(ctxt, spikes, outer, inner) {
  9398. let rot = Math.PI / 2 * 3;
  9399. let x, y;
  9400. let step = Math.PI / spikes;
  9401. let tmpOuter;
  9402. ctxt.beginPath();
  9403. ctxt.moveTo(0, -inner);
  9404. for (let i = 0; i < spikes; i++) {
  9405. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9406. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9407. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9408. rot += step * 2;
  9409. }
  9410. ctxt.lineTo(0, -inner);
  9411. ctxt.closePath();
  9412. }
  9413. // RENDER TRIANGLE:
  9414. function renderTriangle(s, ctx) {
  9415. ctx = ctx || mainContext;
  9416. let h = s * (Math.sqrt(3) / 2);
  9417. ctx.beginPath();
  9418. ctx.moveTo(0, -h / 2);
  9419. ctx.lineTo(-s / 2, h / 2);
  9420. ctx.lineTo(s / 2, h / 2);
  9421. ctx.lineTo(0, -h / 2);
  9422. ctx.fill();
  9423. ctx.closePath();
  9424. }
  9425. // PREPARE MENU BACKGROUND:
  9426. function prepareMenuBackground() {
  9427. let tmpMid = config.mapScale / 2;
  9428. let attempts = 0;
  9429. for (let i = 0; i < items.list.length * 10;) {
  9430. if (attempts >= 1000) break;
  9431. attempts++;
  9432. let type1 = items.list[15];
  9433. let type2 = items.list[9];
  9434. let data1 = {
  9435. x: tmpMid + UTILS.randFloat(-1000, 1000),
  9436. y: tmpMid + UTILS.randFloat(-600, 600),
  9437. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9438. };
  9439. if (objectManager.checkItemLocation(data1.x, data1.y, type1.scale, 0.6, type1.id, true)) {
  9440. objectManager.add(i, data1.x, data1.y, data1.dir, type1.scale, type1.id, type1);
  9441. let offsetX = UTILS.randFloat(-100, 100);
  9442. let offsetY = UTILS.randFloat(-100, 100);
  9443. let data2 = {
  9444. x: data1.x + offsetX,
  9445. y: data1.y + offsetY,
  9446. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9447. };
  9448. if (objectManager.checkItemLocation(data2.x, data2.y, type2.scale, 0.6, type2.id, true)) {
  9449. objectManager.add(i + 1, data2.x, data2.y, data2.dir, type2.scale, type2.id, type2);
  9450. } else {
  9451. continue;
  9452. }
  9453. } else {
  9454. continue;
  9455. }
  9456. i += 2;
  9457. }
  9458. }
  9459. const speed = 35;
  9460. // RENDER PLAYERS:
  9461. function renderDeadPlayers(xOffset, yOffset, deadAngle) {
  9462. mainContext.fillStyle = "#91b2db";
  9463. const currentTime = Date.now();
  9464. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9465. if (!dead.startTime) {
  9466. dead.startTime = currentTime;
  9467. dead.angle = 0;
  9468. dead.radius = 0.1;
  9469. }
  9470. const timeElapsed = currentTime - dead.startTime;
  9471. const maxAlpha = 1;
  9472. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9473. dead.animate(delta);
  9474. mainContext.globalAlpha = dead.alpha;
  9475. mainContext.strokeStyle = outlineColor;
  9476. mainContext.save();
  9477. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9478. dead.radius -= 0.001;
  9479. dead.angle += toRadian(1);
  9480. const moveSpeed = 40;
  9481. const x = dead.radius * Math.cos(deadAngle);
  9482. const y = dead.radius * Math.sin(deadAngle);
  9483. dead.x += x * moveSpeed;
  9484. dead.y += y * moveSpeed;
  9485. mainContext.rotate(dead.angle);
  9486. renderDeadPlayer(dead, mainContext);
  9487. mainContext.restore();
  9488. mainContext.fillStyle = "#bf8f54";
  9489. if (timeElapsed >= 3000) {
  9490. dead.active = false;
  9491. dead.startTime = null;
  9492. }
  9493. });
  9494. }
  9495. // RENDER PLAYERS:
  9496. let invisBody = false;
  9497. // RENDER PLAYERS:
  9498. function renderPlayers(xOffset, yOffset, zIndex) {
  9499. mainContext.globalAlpha = 1;
  9500. mainContext.fillStyle = "#91b2db";
  9501. for (var i = 0; i < players.length; ++i) {
  9502. tmpObj = players[i];
  9503. if (tmpObj.zIndex == zIndex) {
  9504. tmpObj.animate(delta);
  9505. if (tmpObj.visible) {
  9506. tmpObj.skinRot += (0.002 * delta);
  9507. tmpDir = (!configs.showDir && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir || 0);
  9508. mainContext.save();
  9509. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9510. // RENDER PLAYER:
  9511. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9512. if (tmpObj == player && invisBody) {
  9513. null;
  9514. } else {
  9515. renderPlayer(tmpObj, mainContext);
  9516. }
  9517. mainContext.restore();
  9518. }
  9519. }
  9520. }
  9521. }
  9522. // RENDER DEAD PLAYER:
  9523. function renderDeadPlayer(obj, ctxt) {
  9524. ctxt = ctxt || mainContext;
  9525. ctxt.lineWidth = outlineWidth;
  9526. ctxt.lineJoin = "miter";
  9527. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9528. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9529. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9530.  
  9531. // TAIL/CAPE:
  9532. renderTail2(13, ctxt, obj);
  9533.  
  9534. // WEAPON BELLOW HANDS:
  9535. if (obj.buildIndex < 0 && !items.weapons[10].aboveHand) {
  9536. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  9537. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9538. renderProjectile(obj.scale, 0,
  9539. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9540. }
  9541. }
  9542.  
  9543. // HANDS:
  9544. ctxt.fillStyle = "#ececec";
  9545. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9546. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9547. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9548.  
  9549. // WEAPON ABOVE HANDS:
  9550. if (obj.buildIndex < 0 && items.weapons[10].aboveHand) {
  9551. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  9552. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9553. renderProjectile(obj.scale, 0,
  9554. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9555. }
  9556. }
  9557.  
  9558. // BUILD ITEM:
  9559. if (obj.buildIndex >= 0) {
  9560. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9561. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9562. }
  9563.  
  9564. // BODY:
  9565. renderCircle(0, 0, obj.scale, ctxt);
  9566. // SKIN
  9567. renderSkin2(48, ctxt, null, obj)
  9568.  
  9569. }
  9570. // RENDER PLAYER:
  9571. function renderPlayer(obj, ctxt) {
  9572. ctxt = ctxt || mainContext;
  9573. ctxt.lineWidth = outlineWidth;
  9574. ctxt.lineJoin = "miter";
  9575. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9576. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9577. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9578. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9579. // TAIL/CAPE:
  9580. if (obj.tailIndex > 0) {
  9581. renderTail(obj.tailIndex, ctxt, obj);
  9582. }
  9583. // WEAPON BELLOW HANDS:
  9584. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9585. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9586. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9587. renderProjectile(obj.scale, 0,
  9588. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9589. }
  9590. }
  9591. // HANDS:
  9592. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9593. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9594. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9595. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9596. // WEAPON ABOVE HANDS:
  9597. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9598. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9599. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9600. renderProjectile(obj.scale, 0,
  9601. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9602. }
  9603. }
  9604. // BUILD ITEM:
  9605. if (obj.buildIndex >= 0) {
  9606. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9607. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9608. }
  9609. // BODY:
  9610. renderCircle(0, 0, obj.scale, ctxt);
  9611. // SKIN:
  9612. if (obj.skinIndex > 0) {
  9613. ctxt.rotate(Math.PI / 2);
  9614. renderSkin(obj.skinIndex, ctxt, null, obj);
  9615. }
  9616. }
  9617. // RENDER NORMAL SKIN
  9618. var skinSprites2 = {};
  9619. var skinPointers2 = {};
  9620. function renderSkin2(index, ctxt, parentSkin, owner) {
  9621. tmpSkin = skinSprites2[index];
  9622. if (!tmpSkin) {
  9623. var tmpImage = new Image();
  9624. tmpImage.onload = function() {
  9625. this.isLoaded = true;
  9626. this.onload = null;
  9627. };
  9628. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9629. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9630. skinSprites2[index] = tmpImage;
  9631. tmpSkin = tmpImage;
  9632. }
  9633. var tmpObj = parentSkin||skinPointers2[index];
  9634. if (!tmpObj) {
  9635. for (var i = 0; i < hats.length; ++i) {
  9636. if (hats[i].id == index) {
  9637. tmpObj = hats[i];
  9638. break;
  9639. }
  9640. }
  9641. skinPointers2[index] = tmpObj;
  9642. }
  9643. if (tmpSkin.isLoaded)
  9644. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9645. if (!parentSkin && tmpObj.topSprite) {
  9646. ctxt.save();
  9647. ctxt.rotate(owner.skinRot);
  9648. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9649. ctxt.restore();
  9650. }
  9651. }
  9652. // RENDER SKINS:
  9653. let skinSprites = {};
  9654. let skinPointers = {};
  9655. let tmpSkin;
  9656. function renderSkin(index, ctxt, parentSkin, owner) {
  9657. tmpSkin = skinSprites[index];
  9658. if (!tmpSkin) {
  9659. let tmpImage = new Image();
  9660. tmpImage.onload = function() {
  9661. this.isLoaded = true;
  9662. this.onload = null;
  9663. };
  9664. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9665. skinSprites[index] = tmpImage;
  9666. tmpSkin = tmpImage;
  9667. }
  9668. let tmpObj = parentSkin || skinPointers[index];
  9669. if (!tmpObj) {
  9670. for (let i = 0; i < hats.length; ++i) {
  9671. if (hats[i].id == index) {
  9672. tmpObj = hats[i];
  9673. break;
  9674. }
  9675. }
  9676. skinPointers[index] = tmpObj;
  9677. }
  9678. if (tmpSkin.isLoaded)
  9679. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9680. if (!parentSkin && tmpObj.topSprite) {
  9681. ctxt.save();
  9682. ctxt.rotate(owner.skinRot);
  9683. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9684. ctxt.restore();
  9685. }
  9686. }
  9687. // RENDER TAIL:
  9688. let accessSprites = {};
  9689. let accessPointers = {};
  9690. function renderTail(index, ctxt, owner) {
  9691. tmpSkin = accessSprites[index];
  9692. if (!tmpSkin) {
  9693. let tmpImage = new Image();
  9694. tmpImage.onload = function() {
  9695. this.isLoaded = true;
  9696. this.onload = null;
  9697. };
  9698. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9699. accessSprites[index] = tmpImage;
  9700. tmpSkin = tmpImage;
  9701. }
  9702. let tmpObj = accessPointers[index];
  9703. if (!tmpObj) {
  9704. for (let i = 0; i < accessories.length; ++i) {
  9705. if (accessories[i].id == index) {
  9706. tmpObj = accessories[i];
  9707. break;
  9708. }
  9709. }
  9710. accessPointers[index] = tmpObj;
  9711. }
  9712. if (tmpSkin.isLoaded) {
  9713. ctxt.save();
  9714. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9715. if (tmpObj.spin)
  9716. ctxt.rotate(owner.skinRot);
  9717. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9718. ctxt.restore();
  9719. }
  9720. }
  9721. // RENDER NORMAL TAIL
  9722. var accessSprites2 = {};
  9723. var accessPointers2 = {};
  9724. function renderTail2(index, ctxt, owner) {
  9725. tmpSkin = accessSprites2[index];
  9726. if (!tmpSkin) {
  9727. var tmpImage = new Image();
  9728. tmpImage.onload = function() {
  9729. this.isLoaded = true;
  9730. this.onload = null;
  9731. };
  9732. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9733. accessSprites2[index] = tmpImage;
  9734. tmpSkin = tmpImage;
  9735. }
  9736. var tmpObj = accessPointers2[index];
  9737. if (!tmpObj) {
  9738. for (var i = 0; i < accessories.length; ++i) {
  9739. if (accessories[i].id == index) {
  9740. tmpObj = accessories[i];
  9741. break;
  9742. }
  9743. }
  9744. accessPointers2[index] = tmpObj;
  9745. }
  9746. if (tmpSkin.isLoaded) {
  9747. ctxt.save();
  9748. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9749. if (tmpObj.spin)
  9750. ctxt.rotate(owner.skinRot);
  9751. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9752. ctxt.restore();
  9753. }
  9754. }
  9755. // RENDER TOOL:
  9756. let toolSprites = {};
  9757. function renderTool(obj, variant, x, y, ctxt) {
  9758. let tmpSrc = obj.src + (variant || "");
  9759. let tmpSprite = toolSprites[tmpSrc];
  9760. if (!tmpSprite) {
  9761. tmpSprite = new Image();
  9762. tmpSprite.onload = function() {
  9763. this.isLoaded = true;
  9764. }
  9765. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9766. toolSprites[tmpSrc] = tmpSprite;
  9767. }
  9768. if (tmpSprite.isLoaded)
  9769. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9770. }
  9771. // RENDER PROJECTILES:
  9772. function renderProjectiles(layer, xOffset, yOffset) {
  9773. for (let i = 0; i < projectiles.length; i++) {
  9774. tmpObj = projectiles[i];
  9775. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9776. tmpObj.update(delta);
  9777. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9778. mainContext.save();
  9779. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9780. mainContext.rotate(tmpObj.dir);
  9781. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9782. mainContext.restore();
  9783. }
  9784. }
  9785. };
  9786. }
  9787. // RENDER PROJECTILE:
  9788. let projectileSprites = {};
  9789. function renderProjectile(x, y, obj, ctxt, debug) {
  9790. if (obj.src) {
  9791. let tmpSrc = items.projectiles[obj.indx].src;
  9792. let tmpSprite = projectileSprites[tmpSrc];
  9793. if (!tmpSprite) {
  9794. tmpSprite = new Image();
  9795. tmpSprite.onload = function() {
  9796. this.isLoaded = true;
  9797. }
  9798. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9799. projectileSprites[tmpSrc] = tmpSprite;
  9800. }
  9801. if (tmpSprite.isLoaded)
  9802. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9803. } else if (obj.indx == 1) {
  9804. ctxt.fillStyle = "#939393";
  9805. renderCircle(x, y, obj.scale, ctxt);
  9806. }
  9807. }
  9808. // RENDER AI:
  9809. let aiSprites = {};
  9810. function renderAI(obj, ctxt) {
  9811. let tmpIndx = obj.index;
  9812. let tmpSprite = aiSprites[tmpIndx];
  9813. if (!tmpSprite) {
  9814. let tmpImg = new Image();
  9815. tmpImg.onload = function() {
  9816. this.isLoaded = true;
  9817. this.onload = null;
  9818. };
  9819. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9820. tmpSprite = tmpImg;
  9821. aiSprites[tmpIndx] = tmpSprite;
  9822. }
  9823. if (tmpSprite.isLoaded) {
  9824. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9825. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9826. }
  9827. }
  9828. // RENDER WATER BODIES:
  9829. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9830. // MIDDLE RIVER:
  9831. let tmpW = config.riverWidth + padding;
  9832. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9833. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9834. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9835. }
  9836. }
  9837. // RENDER GAME OBJECTS:
  9838. let gameObjectSprites = {};
  9839. function getResSprite(obj) {
  9840. let biomeID = (obj.y>=config.mapScale-config.snowBiomeTop)?2:((obj.y<=config.snowBiomeTop)?1:0);
  9841. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9842. let tmpSprite = gameObjectSprites[tmpIndex];
  9843. if (!tmpSprite) {
  9844. let blurScale = 15;
  9845. let tmpCanvas = document.createElement("canvas");
  9846. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9847. let tmpContext = tmpCanvas.getContext('2d');
  9848. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9849. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9850. tmpContext.strokeStyle = outlineColor;
  9851. tmpContext.lineWidth = outlineWidth;
  9852. if (isNight) {
  9853. tmpContext.shadowBlur = blurScale;
  9854. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9855. }
  9856. if (obj.type == 0) {
  9857. let tmpScale;
  9858. let tmpCount = UTILS.randInt(5, 7);
  9859. tmpContext.globalAlpha = isNight ? 0.6 : 0.8;
  9860. for (let i = 0; i < 2; ++i) {
  9861. tmpScale = tmpObj.scale * (!i?1:0.5);
  9862. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9863. tmpContext.fillStyle = !biomeID?(!i?"#9ebf57":"#b4db62"):(!i?"#e3f1f4":"#fff");
  9864. tmpContext.fill();
  9865. if (!i) {
  9866. tmpContext.stroke();
  9867. tmpContext.shadowBlur = null;
  9868. tmpContext.shadowColor = null;
  9869. tmpContext.globalAlpha = 1;
  9870. }
  9871. }
  9872. } else if (obj.type == 1) {
  9873. if (biomeID == 2) {
  9874. tmpContext.fillStyle = "#606060";
  9875. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9876. tmpContext.fill();
  9877. tmpContext.stroke();
  9878.  
  9879. //tmpContext.shadowBlur = null;
  9880. //tmpContext.shadowColor = null;
  9881.  
  9882. tmpContext.fillStyle = "#89a54c";
  9883. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9884. tmpContext.fillStyle = "#a5c65b";
  9885. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9886. } else {
  9887. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9888. tmpContext.fillStyle = biomeID?"#e3f1f4":"#89a54c";
  9889. tmpContext.fill();
  9890. tmpContext.stroke();
  9891.  
  9892. //tmpContext.shadowBlur = null;
  9893. //tmpContext.shadowColor = null;
  9894.  
  9895. tmpContext.fillStyle = biomeID?"#6a64af":"#c15555";
  9896. let tmpRange;
  9897. let berries = 4;
  9898. let rotVal = (Math.PI * 2) / berries;
  9899. for (let i = 0; i < berries; ++i) {
  9900. tmpRange = UTILS.randInt(tmpObj.scale/3.5, tmpObj.scale/2.3);
  9901. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9902. UTILS.randInt(10, 12), tmpContext);
  9903. }
  9904. }
  9905. } else if (obj.type == 2 || obj.type == 3) {
  9906. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#938d77":"#939393"):"#e0c655";
  9907. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9908. tmpContext.fill();
  9909. tmpContext.stroke();
  9910.  
  9911. tmpContext.shadowBlur = null;
  9912. tmpContext.shadowColor = null;
  9913.  
  9914. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#b2ab90":"#bcbcbc"):"#ebdca3";
  9915. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9916. tmpContext.fill();
  9917. }
  9918. tmpSprite = tmpCanvas;
  9919. gameObjectSprites[tmpIndex] = tmpSprite;
  9920. }
  9921. return tmpSprite;
  9922. }
  9923.  
  9924. // GET ITEM SPRITE:
  9925. let itemSprites = [];
  9926. function getItemSprite(obj, asIcon) {
  9927. let tmpSprite = itemSprites[obj.id];
  9928. if (!tmpSprite || asIcon) {
  9929. let blurScale = !asIcon && isNight ? 15 : 0;
  9930. let tmpCanvas = document.createElement("canvas");
  9931. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9932. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9933. let tmpContext = tmpCanvas.getContext("2d");
  9934. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9935. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9936. tmpContext.strokeStyle = outlineColor;
  9937. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9938. if (isNight && !asIcon) {
  9939. tmpContext.shadowBlur = blurScale;
  9940. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(obj.name == "pit trap" ? 0.6 : 0.3, obj.alpha)})`;
  9941. }
  9942. if (obj.name == "apple") {
  9943. tmpContext.fillStyle = "#c15555";
  9944. renderCircle(0, 0, obj.scale, tmpContext);
  9945. tmpContext.fillStyle = "#89a54c";
  9946. let leafDir = -(Math.PI / 2);
  9947. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9948. 25, leafDir + Math.PI / 2, tmpContext);
  9949. } else if (obj.name == "cookie") {
  9950. tmpContext.fillStyle = "#cca861";
  9951. renderCircle(0, 0, obj.scale, tmpContext);
  9952. tmpContext.fillStyle = "#937c4b";
  9953. let chips = 4;
  9954. let rotVal = (Math.PI * 2) / chips;
  9955. let tmpRange;
  9956. for (let i = 0; i < chips; ++i) {
  9957. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9958. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9959. UTILS.randInt(4, 5), tmpContext, true);
  9960. }
  9961. } else if (obj.name == "cheese") {
  9962. tmpContext.fillStyle = "#f4f3ac";
  9963. renderCircle(0, 0, obj.scale, tmpContext);
  9964. tmpContext.fillStyle = "#c3c28b";
  9965. let chips = 4;
  9966. let rotVal = (Math.PI * 2) / chips;
  9967. let tmpRange;
  9968. for (let i = 0; i < chips; ++i) {
  9969. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9970. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9971. UTILS.randInt(4, 5), tmpContext, true);
  9972. }
  9973. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9974. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9975. "#a5974c" : "#939393";
  9976. let sides = (obj.name == "castle wall") ? 4 : 3;
  9977. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9978. tmpContext.fill();
  9979. tmpContext.stroke();
  9980. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9981. "#c9b758" : "#bcbcbc";
  9982. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9983. tmpContext.fill();
  9984. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9985. obj.name == "spinning spikes") {
  9986. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9987. let tmpScale = (obj.scale * 0.6);
  9988. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9989. tmpContext.fill();
  9990. tmpContext.stroke();
  9991. tmpContext.fillStyle = "#a5974c";
  9992. renderCircle(0, 0, tmpScale, tmpContext);
  9993. tmpContext.fillStyle = "#c9b758";
  9994. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9995. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9996. tmpContext.fillStyle = "#a5974c";
  9997. renderCircle(0, 0, reScale, tmpContext);
  9998. tmpContext.fillStyle = "#c9b758";
  9999. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10000. tmpContext.fillStyle = "#a5974c";
  10001. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10002. } else if (obj.name == "mine") {
  10003. tmpContext.fillStyle = "#939393";
  10004. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10005. tmpContext.fill();
  10006. tmpContext.stroke();
  10007. tmpContext.fillStyle = "#bcbcbc";
  10008. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10009. tmpContext.fill();
  10010. } else if (obj.name == "sapling") {
  10011. for (let i = 0; i < 2; ++i) {
  10012. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10013. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10014. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10015. tmpContext.fill();
  10016. if (!i) tmpContext.stroke();
  10017. }
  10018. } else if (obj.name == "pit trap") {
  10019. tmpContext.fillStyle = "#a5974c";
  10020. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10021. tmpContext.fill();
  10022. tmpContext.stroke();
  10023. tmpContext.fillStyle = outlineColor;
  10024. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10025. tmpContext.fill();
  10026. } else if (obj.name == "boost pad") {
  10027. tmpContext.fillStyle = "#7e7f82";
  10028. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10029. tmpContext.fill();
  10030. tmpContext.stroke();
  10031. tmpContext.fillStyle = "#dbd97d";
  10032. renderTriangle(obj.scale * 1, tmpContext);
  10033. } else if (obj.name == "turret") {
  10034. tmpContext.fillStyle = "#a5974c";
  10035. renderCircle(0, 0, obj.scale, tmpContext);
  10036. tmpContext.fill();
  10037. tmpContext.stroke();
  10038. tmpContext.fillStyle = "#939393";
  10039. let tmpLen = 50;
  10040. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10041. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10042. tmpContext.fill();
  10043. tmpContext.stroke();
  10044. } else if (obj.name == "platform") {
  10045. tmpContext.fillStyle = "#cebd5f";
  10046. let tmpCount = 4;
  10047. let tmpS = obj.scale * 2;
  10048. let tmpW = tmpS / tmpCount;
  10049. let tmpX = -(obj.scale / 2);
  10050. for (let i = 0; i < tmpCount; ++i) {
  10051. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10052. tmpContext.fill();
  10053. tmpContext.stroke();
  10054. tmpX += tmpS / tmpCount;
  10055. }
  10056. } else if (obj.name == "healing pad") {
  10057. tmpContext.fillStyle = "#7e7f82";
  10058. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10059. tmpContext.fill();
  10060. tmpContext.stroke();
  10061. tmpContext.fillStyle = "#db6e6e";
  10062. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10063. } else if (obj.name == "spawn pad") {
  10064. tmpContext.fillStyle = "#7e7f82";
  10065. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10066. tmpContext.fill();
  10067. tmpContext.stroke();
  10068. tmpContext.fillStyle = "#71aad6";
  10069. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10070. } else if (obj.name == "blocker") {
  10071. tmpContext.fillStyle = "#7e7f82";
  10072. renderCircle(0, 0, obj.scale, tmpContext);
  10073. tmpContext.fill();
  10074. tmpContext.stroke();
  10075. tmpContext.rotate(Math.PI / 4);
  10076. tmpContext.fillStyle = "#db6e6e";
  10077. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10078. } else if (obj.name == "teleporter") {
  10079. tmpContext.fillStyle = "#7e7f82";
  10080. renderCircle(0, 0, obj.scale, tmpContext);
  10081. tmpContext.fill();
  10082. tmpContext.stroke();
  10083. tmpContext.rotate(Math.PI / 4);
  10084. tmpContext.fillStyle = "#d76edb";
  10085. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10086. }
  10087. tmpSprite = tmpCanvas;
  10088. if (!asIcon)
  10089. itemSprites[obj.id] = tmpSprite;
  10090. }
  10091. return tmpSprite;
  10092. }
  10093.  
  10094. function getItemSprite2(obj, tmpX, tmpY) {
  10095. let tmpContext = mainContext;
  10096. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  10097. tmpContext.save();
  10098. tmpContext.translate(tmpX, tmpY);
  10099. tmpContext.rotate(obj.dir);
  10100. tmpContext.strokeStyle = outlineColor;
  10101. tmpContext.lineWidth = outlineWidth;
  10102. if (obj.name == "apple") {
  10103. tmpContext.fillStyle = "#c15555";
  10104. renderCircle(0, 0, obj.scale, tmpContext);
  10105. tmpContext.fillStyle = "#89a54c";
  10106. let leafDir = -(Math.PI / 2);
  10107. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10108. 25, leafDir + Math.PI / 2, tmpContext);
  10109. } else if (obj.name == "cookie") {
  10110. tmpContext.fillStyle = "#cca861";
  10111. renderCircle(0, 0, obj.scale, tmpContext);
  10112. tmpContext.fillStyle = "#937c4b";
  10113. let chips = 4;
  10114. let rotVal = (Math.PI * 2) / chips;
  10115. let tmpRange;
  10116. for (let i = 0; i < chips; ++i) {
  10117. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10118. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10119. UTILS.randInt(4, 5), tmpContext, true);
  10120. }
  10121. } else if (obj.name == "cheese") {
  10122. tmpContext.fillStyle = "#f4f3ac";
  10123. renderCircle(0, 0, obj.scale, tmpContext);
  10124. tmpContext.fillStyle = "#c3c28b";
  10125. let chips = 4;
  10126. let rotVal = (Math.PI * 2) / chips;
  10127. let tmpRange;
  10128. for (let i = 0; i < chips; ++i) {
  10129. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10130. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10131. UTILS.randInt(4, 5), tmpContext, true);
  10132. }
  10133. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10134. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10135. "#a5974c" : "#939393";
  10136. let sides = (obj.name == "castle wall") ? 4 : 3;
  10137. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10138. tmpContext.fill();
  10139. tmpContext.stroke();
  10140. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10141. "#c9b758" : "#bcbcbc";
  10142. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10143. tmpContext.fill();
  10144. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10145. obj.name == "spinning spikes") {
  10146. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10147. let tmpScale = (obj.scale * 0.6);
  10148. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10149. tmpContext.fill();
  10150. tmpContext.stroke();
  10151. tmpContext.fillStyle = "#a5974c";
  10152. renderCircle(0, 0, tmpScale, tmpContext);
  10153. tmpContext.fillStyle = "#c9b758";
  10154. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10155. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10156. tmpContext.fillStyle = "#a5974c";
  10157. renderCircle(0, 0, reScale, tmpContext);
  10158. tmpContext.fillStyle = "#c9b758";
  10159. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10160. tmpContext.fillStyle = "#a5974c";
  10161. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10162. } else if (obj.name == "mine") {
  10163. tmpContext.fillStyle = "#939393";
  10164. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10165. tmpContext.fill();
  10166. tmpContext.stroke();
  10167. tmpContext.fillStyle = "#bcbcbc";
  10168. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10169. tmpContext.fill();
  10170. } else if (obj.name == "sapling") {
  10171. for (let i = 0; i < 2; ++i) {
  10172. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10173. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10174. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10175. tmpContext.fill();
  10176. if (!i) tmpContext.stroke();
  10177. }
  10178. } else if (obj.name == "pit trap") {
  10179. tmpContext.fillStyle = "#a5974c";
  10180. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10181. tmpContext.fill();
  10182. tmpContext.stroke();
  10183. tmpContext.fillStyle = outlineColor;
  10184. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10185. tmpContext.fill();
  10186. } else if (obj.name == "boost pad") {
  10187. tmpContext.fillStyle = "#7e7f82";
  10188. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10189. tmpContext.fill();
  10190. tmpContext.stroke();
  10191. tmpContext.fillStyle = "#dbd97d";
  10192. renderTriangle(obj.scale * 1, tmpContext);
  10193. } else if (obj.name == "turret") {
  10194. tmpContext.fillStyle = "#a5974c";
  10195. renderCircle(0, 0, obj.scale, tmpContext);
  10196. tmpContext.fill();
  10197. tmpContext.stroke();
  10198. tmpContext.fillStyle = "#939393";
  10199. let tmpLen = 50;
  10200. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10201. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10202. tmpContext.fill();
  10203. tmpContext.stroke();
  10204. } else if (obj.name == "platform") {
  10205. tmpContext.fillStyle = "#cebd5f";
  10206. let tmpCount = 4;
  10207. let tmpS = obj.scale * 2;
  10208. let tmpW = tmpS / tmpCount;
  10209. let tmpX = -(obj.scale / 2);
  10210. for (let i = 0; i < tmpCount; ++i) {
  10211. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10212. tmpContext.fill();
  10213. tmpContext.stroke();
  10214. tmpX += tmpS / tmpCount;
  10215. }
  10216. } else if (obj.name == "healing pad") {
  10217. tmpContext.fillStyle = "#7e7f82";
  10218. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10219. tmpContext.fill();
  10220. tmpContext.stroke();
  10221. tmpContext.fillStyle = "#db6e6e";
  10222. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10223. } else if (obj.name == "spawn pad") {
  10224. tmpContext.fillStyle = "#7e7f82";
  10225. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10226. tmpContext.fill();
  10227. tmpContext.stroke();
  10228. tmpContext.fillStyle = "#71aad6";
  10229. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10230. } else if (obj.name == "blocker") {
  10231. tmpContext.fillStyle = "#7e7f82";
  10232. renderCircle(0, 0, obj.scale, tmpContext);
  10233. tmpContext.fill();
  10234. tmpContext.stroke();
  10235. tmpContext.rotate(Math.PI / 4);
  10236. tmpContext.fillStyle = "#db6e6e";
  10237. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10238. } else if (obj.name == "teleporter") {
  10239. tmpContext.fillStyle = "#7e7f82";
  10240. renderCircle(0, 0, obj.scale, tmpContext);
  10241. tmpContext.fill();
  10242. tmpContext.stroke();
  10243. tmpContext.rotate(Math.PI / 4);
  10244. tmpContext.fillStyle = "#d76edb";
  10245. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10246. }
  10247. tmpContext.restore();
  10248. }
  10249.  
  10250. let objSprites = [];
  10251. function getObjSprite(obj) {
  10252. let tmpSprite = objSprites[obj.id];
  10253. if (!tmpSprite) {
  10254. let blurScale = isNight ? 15 : 0;
  10255. let tmpCanvas = document.createElement("canvas");
  10256. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10257. let tmpContext = tmpCanvas.getContext("2d");
  10258. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10259. tmpContext.rotate(Math.PI / 2);
  10260. tmpContext.strokeStyle = outlineColor;
  10261. tmpContext.lineWidth = outlineWidth;
  10262. if (isNight) {
  10263. tmpContext.shadowBlur = blurScale;
  10264. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10265. }
  10266. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10267. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  10268. let tmpScale = obj.scale * 0.6;
  10269. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10270. tmpContext.fill();
  10271. tmpContext.stroke();
  10272. tmpContext.fillStyle = "#a5974c";
  10273. renderCircle(0, 0, tmpScale, tmpContext);
  10274. tmpContext.fillStyle = "#cc5151";
  10275. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10276. } else if (obj.name == "pit trap") {
  10277. tmpContext.fillStyle = "#a5974c";
  10278. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10279. tmpContext.fill();
  10280. tmpContext.stroke();
  10281. tmpContext.fillStyle = "#cc5151";
  10282. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10283. tmpContext.fill();
  10284. }
  10285. tmpSprite = tmpCanvas;
  10286. objSprites[obj.id] = tmpSprite;
  10287. }
  10288. return tmpSprite;
  10289. }
  10290.  
  10291. // GET MARK SPRITE:
  10292. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10293.  
  10294. let center = {
  10295. x: screenWidth / 2,
  10296. y: screenHeight / 2,
  10297. };
  10298. tmpContext.lineWidth = outlineWidth;
  10299. mainContext.globalAlpha = 0.4;
  10300. tmpContext.strokeStyle = outlineColor;
  10301. tmpContext.save();
  10302. tmpContext.translate(tmpX, tmpY);
  10303. tmpContext.rotate(obj.dir || getAttackDir());
  10304. if (getEl("renderplace").value == "placeVis") {
  10305. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10306. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  10307. var tmpScale = (obj.scale * 0.6);
  10308. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  10309. tmpContext.fill();
  10310. tmpContext.stroke();
  10311. tmpContext.fillStyle = "#a5974c";
  10312. renderCircle(0, 0, tmpScale, tmpContext);
  10313. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10314. tmpContext.fillStyle = "#a34040";
  10315. } else {
  10316. tmpContext.fillStyle = "#c9b758";
  10317. }
  10318. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  10319. } else if (obj.name == "turret") {
  10320. tmpContext.fillStyle = "#a5974c";
  10321. renderCircle(0, 0, obj.scale, tmpContext);
  10322. tmpContext.fill();
  10323. tmpContext.stroke();
  10324. tmpContext.fillStyle = "#939393";
  10325. let tmpLen = 50;
  10326. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10327. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10328. tmpContext.fill();
  10329. tmpContext.stroke();
  10330. } else if (obj.name == "teleporter") {
  10331. tmpContext.fillStyle = "#7e7f82";
  10332. renderCircle(0, 0, obj.scale, tmpContext);
  10333. tmpContext.fill();
  10334. tmpContext.stroke();
  10335. tmpContext.rotate(Math.PI / 4);
  10336. tmpContext.fillStyle = "#d76edb";
  10337. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10338. } else if (obj.name == "platform") {
  10339. tmpContext.fillStyle = "#cebd5f";
  10340. let tmpCount = 4;
  10341. let tmpS = obj.scale * 2;
  10342. let tmpW = tmpS / tmpCount;
  10343. let tmpX = -(obj.scale / 2);
  10344. for (let i = 0; i < tmpCount; ++i) {
  10345. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10346. tmpContext.fill();
  10347. tmpContext.stroke();
  10348. tmpX += tmpS / tmpCount;
  10349. }
  10350. } else if (obj.name == "healing pad") {
  10351. tmpContext.fillStyle = "#7e7f82";
  10352. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10353. tmpContext.fill();
  10354. tmpContext.stroke();
  10355. tmpContext.fillStyle = "#db6e6e";
  10356. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10357. } else if (obj.name == "spawn pad") {
  10358. tmpContext.fillStyle = "#7e7f82";
  10359. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10360. tmpContext.fill();
  10361. tmpContext.stroke();
  10362. tmpContext.fillStyle = "#71aad6";
  10363. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10364. } else if (obj.name == "blocker") {
  10365. tmpContext.fillStyle = "#7e7f82";
  10366. renderCircle(0, 0, obj.scale, tmpContext);
  10367. tmpContext.fill();
  10368. tmpContext.stroke();
  10369. tmpContext.rotate(Math.PI / 4);
  10370. tmpContext.fillStyle = "#db6e6e";
  10371. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10372. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10373. tmpContext.fillStyle = "#a5974c";
  10374. renderCircle(0, 0, obj.scale, tmpContext);
  10375. tmpContext.fillStyle = "#c9b758";
  10376. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10377. tmpContext.fillStyle = "#a5974c";
  10378. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10379. } else if (obj.name == "pit trap") {
  10380. tmpContext.fillStyle = "#a5974c";
  10381. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10382. tmpContext.fill();
  10383. tmpContext.stroke();
  10384. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10385. tmpContext.fillStyle = "#a34040";
  10386. } else {
  10387. tmpContext.fillStyle = outlineColor;
  10388. }
  10389. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10390. tmpContext.fill();
  10391. }
  10392. tmpContext.restore();
  10393. }
  10394. }
  10395. function getMarkSprite2(obj, tmpContext, tmpX, tmpY) {
  10396.  
  10397. if (getEl("renderplace").value == "outline") {
  10398. tmpContext.lineWidth = outlineWidth;
  10399. mainContext.globalAlpha = 1;
  10400. tmpContext.strokeStyle = outlineColor;
  10401. tmpContext.save();
  10402. tmpContext.translate(tmpX, tmpY);
  10403. tmpContext.rotate(obj.dir || getAttackDir());
  10404.  
  10405. if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10406. let sides = obj.name == "castle wall" ? 4 : 3;
  10407. renderHealthStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10408. tmpContext.stroke();
  10409. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10410. let tmpScale = obj.scale * 0.6;
  10411. renderHealthStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10412. tmpContext.stroke();
  10413. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10414. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10415. } else if (obj.name == "mine") {
  10416. renderHealthStar(tmpContext, 3, obj.scale, obj.scale);
  10417. tmpContext.stroke();
  10418. } else if (obj.name == "sapling") {
  10419. let tmpScale = obj.scale * 0.7;
  10420. renderHealthStar(tmpContext, 7, obj.scale, tmpScale);
  10421. tmpContext.stroke();
  10422. } else if (obj.name == "pit trap") {
  10423. renderHealthStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10424. tmpContext.stroke();
  10425. } else if (obj.name == "boost pad") {
  10426. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10427. } else if (obj.name == "turret") {
  10428. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10429. } else if (obj.name == "platform") {
  10430. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10431. } else if (obj.name == "healing pad") {
  10432. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10433. } else if (obj.name == "spawn pad") {
  10434. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10435. } else if (obj.name == "blocker") {
  10436. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10437. } else if (obj.name == "teleporter") {
  10438. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10439. }
  10440. tmpContext.restore();
  10441.  
  10442. }
  10443. }
  10444. //renderCircle(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.getScale(0.6, true), mainContext, false, true);
  10445. // OBJECT ON SCREEN:
  10446. function isOnScreen(x, y, s) {
  10447. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10448. s,
  10449. maxScreenHeight));
  10450. }
  10451. /* function markObject(tmpObj, tmpX, tmpY) {
  10452. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10453. }*/
  10454. function markObject(tmpObj, tmpX, tmpY) {
  10455. yen(mainContext, tmpX, tmpY);
  10456. }
  10457. function yen(context, x, y) {
  10458. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  10459. context.beginPath();
  10460. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  10461. context.fill();
  10462. context.closePath();
  10463. context.globalAlpha = 1;
  10464. }
  10465. // RENDER MINIMAP:
  10466. class MapPing {
  10467. constructor(color, scale) {
  10468. this.init = function(x, y) {
  10469. this.scale = 0;
  10470. this.x = x;
  10471. this.y = y;
  10472. this.active = true;
  10473. };
  10474. this.update = function(ctxt, delta) {
  10475. if (this.active) {
  10476. this.scale += 0.05 * delta;
  10477. if (this.scale >= scale) {
  10478. this.active = false;
  10479. } else {
  10480. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10481. ctxt.beginPath();
  10482. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale)
  10483. * mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10484. ctxt.stroke();
  10485. }
  10486. }
  10487. };
  10488. this.color = color;
  10489. }
  10490. }
  10491. function pingMap(x, y) {
  10492. tmpPing = mapPings.find(pings => !pings.active);
  10493. if (!tmpPing) {
  10494. tmpPing = new MapPing("#fff", config.mapPingScale);
  10495. mapPings.push(tmpPing);
  10496. }
  10497. tmpPing.init(x, y);
  10498. }
  10499. function updateMapMarker() {
  10500. mapMarker.x = player.x;
  10501. mapMarker.y = player.y;
  10502. }
  10503. function renderMinimap(delta) {
  10504. if (player && player.alive) {
  10505. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10506. // RENDER PINGS:
  10507. mapContext.lineWidth = 4;
  10508. for (let i = 0; i < mapPings.length; ++i) {
  10509. tmpPing = mapPings[i];
  10510. mapContext.strokeStyle = tmpPing.color;
  10511. tmpPing.update(mapContext, delta);
  10512. }
  10513. // RENDER BREAK TRACKS:
  10514. mapContext.globalAlpha = 1;
  10515. mapContext.fillStyle = "#ff0000";
  10516. if (breakTrackers.length) {
  10517. mapContext.fillStyle = "#abcdef";
  10518. mapContext.font = "34px Hammersmith One";
  10519. mapContext.textBaseline = "middle";
  10520. mapContext.textAlign = "center";
  10521. for (let i = 0; i < breakTrackers.length;) {
  10522. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  10523. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  10524. i += 2;
  10525. }
  10526. }
  10527. // RENDER PLAYERS:
  10528. mapContext.globalAlpha = 1;
  10529. mapContext.fillStyle = "#fff";
  10530. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10531. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10532. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10533. if (player.team && minimapData) {
  10534. for (let i = 0; i < minimapData.length;) {
  10535. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10536. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10537. i += 2;
  10538. }
  10539. }
  10540. // RENDER BOTS:
  10541. if (bots.length) {
  10542. bots.forEach((tmp) => {
  10543. if (tmp.inGame) {
  10544. mapContext.globalAlpha = 1;
  10545. mapContext.strokeStyle = "#782F44";
  10546. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10547. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10548. }
  10549. });
  10550. }
  10551. // DEATH LOCATION:
  10552. if (lastDeath) {
  10553. mapContext.fillStyle = "#fc5553";
  10554. mapContext.font = "34px Hammersmith One";
  10555. mapContext.textBaseline = "middle";
  10556. mapContext.textAlign = "center";
  10557. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10558. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10559. }
  10560. // MAP MARKER:
  10561. if (mapMarker) {
  10562. mapContext.fillStyle = "#fff";
  10563. mapContext.font = "34px Hammersmith One";
  10564. mapContext.textBaseline = "middle";
  10565. mapContext.textAlign = "center";
  10566. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10567. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10568. }
  10569. }
  10570. }
  10571. // ICONS:
  10572. let crossHairs = ["https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg", "https://upload.wikimedia.org/wikipedia/commons/9/95/Crosshairs_Red.svg"]; // never use discord-hosted files. they expire.
  10573. let crossHairSprites = {};
  10574. let iconSprites = {};
  10575. let icons = ["crown", "skull"];
  10576.  
  10577. function loadIcons() {
  10578. for (let i = 0; i < icons.length; ++i) {
  10579. let tmpSprite = new Image();
  10580. tmpSprite.onload = function() {
  10581. this.isLoaded = true;
  10582. };
  10583. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10584. iconSprites[icons[i]] = tmpSprite;
  10585. }
  10586. let tmpSprite = new Image();
  10587. tmpSprite.onload = function() {
  10588. this.isLoaded = true;
  10589. };
  10590. tmpSprite.src = crossHairs
  10591. crossHairSprites = tmpSprite;
  10592. }
  10593. loadIcons();
  10594. // UPDATE GAME:
  10595. function updateGame() {
  10596. if (config.resetRender) {
  10597. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10598. mainContext.beginPath();
  10599. }
  10600. function add(array) {
  10601. let lmao = 0
  10602. for (let i = 0; i < array.length; i++) {
  10603. lmao += array[i]
  10604. }
  10605. return lmao / array.length
  10606. }
  10607. if (true) {
  10608. function updateCamera() {
  10609. let selectedCamera = document.getElementById("camera").value;
  10610. let damping = 0.35;
  10611. let scalingFactor = 20;
  10612. if (player) {
  10613. if (selectedCamera === 'Cam1') {
  10614. let damping = 0.1;
  10615. let targetCamX = player.x + ((1920 / 2) / 30);
  10616. let targetCamY = player.y + ((1920 / 2) / 30);
  10617. camX += (targetCamX - camX) * damping;
  10618. camY += (targetCamY - camY) * damping;
  10619. } else if (selectedCamera === 'Cam2' || selectedCamera === 'Cam3') {
  10620. let damping2 = 0.016;
  10621. if (player) {
  10622. let targetCamX = player.x + ((1920 / 2) / 30);
  10623. let targetCamY = player.y + ((1920 / 2) / 30);
  10624. camX = lerp(camX, targetCamX, damping2);
  10625. camY = lerp(camY, targetCamY, damping2);
  10626. } else {
  10627. camX = config.mapScale / 2;
  10628. camY = config.mapScale / 2;
  10629. }
  10630. }
  10631. } else {
  10632. camX = config.mapScale / 2;
  10633. camY = config.mapScale / 2;
  10634. }
  10635. }
  10636. updateCamera()
  10637. document.getElementById("camera").addEventListener("change", updateCamera);
  10638. function lerp(start, end, amt) {
  10639. return (1 - amt) * start + amt * end;
  10640. }
  10641. // INTERPOLATE PLAYERS AND AI:
  10642. let lastTime = now - (1000 / config.serverUpdateRate);
  10643. let tmpDiff;
  10644. for (let i = 0; i < players.length + ais.length; ++i) {
  10645. tmpObj = players[i] || ais[i - players.length];
  10646. if (tmpObj && tmpObj.visible) {
  10647. if (tmpObj.forcePos) {
  10648. tmpObj.x = tmpObj.x2;
  10649. tmpObj.y = tmpObj.y2;
  10650. tmpObj.dir = tmpObj.d2;
  10651. } else {
  10652. let total = tmpObj.t2 - tmpObj.t1;
  10653. let fraction = lastTime - tmpObj.t1;
  10654. let ratio = (fraction / total);
  10655. let rate = 170;
  10656. tmpObj.dt += delta;
  10657. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10658. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10659. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10660. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10661. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10662. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10663. }
  10664. }
  10665. }
  10666. // RENDER CORDS:
  10667. let xOffset = camX - (maxScreenWidth / 2);
  10668. let yOffset = camY - (maxScreenHeight / 2);
  10669. // RENDER BACKGROUND:
  10670. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10671. mainContext.fillStyle = "#87b522";
  10672. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10673. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10674. mainContext.fillStyle = "#bfa426";
  10675. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10676. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10677. mainContext.fillStyle = "#defdff";
  10678. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10679. } else if (config.snowBiomeTop - yOffset >= 0) {
  10680. mainContext.fillStyle = "#defdff";
  10681. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10682. mainContext.fillStyle = "#b6db66";
  10683. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10684. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10685. } else {
  10686. mainContext.fillStyle = "#b6db66";
  10687. mainContext.fillRect(0, 0, maxScreenWidth,
  10688. (config.mapScale - config.snowBiomeTop - yOffset));
  10689. mainContext.fillStyle = "#dbc666";
  10690. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10691. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10692. }
  10693.  
  10694. // RENDER WATER AREAS:
  10695. if (!firstSetup) {
  10696. waterMult += waterPlus * config.waveSpeed * delta;
  10697. if (waterMult >= config.waveMax) {
  10698. waterMult = config.waveMax;
  10699. waterPlus = -1;
  10700. } else if (waterMult <= 1) {
  10701. waterMult = waterPlus = 1;
  10702. }
  10703. mainContext.globalAlpha = 1;
  10704. mainContext.fillStyle = "#e8a033";
  10705. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10706. mainContext.fillStyle = "#91c5ff";
  10707. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10708. }
  10709. if (player) {
  10710. // DEATH LOCATION:
  10711. if (lastDeath) {
  10712. mainContext.globalAlpha = 1;
  10713. mainContext.fillStyle = "#fc5553";
  10714. mainContext.font = "100px Hammersmith One";
  10715. mainContext.textBaseline = "middle";
  10716. mainContext.textAlign = "center";
  10717. mainContext.fillText("x", lastDeath.x - xOffset, lastDeath.y - yOffset);
  10718. }
  10719. // PATHFINDER LINE:
  10720. if (pathFind.active) {
  10721. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10722. mainContext.lineWidth = player.scale / 5;
  10723. mainContext.globalAlpha = 1;
  10724. mainContext.strokeStyle = "red";
  10725. mainContext.beginPath();
  10726. pathFind.array.forEach((path, i) => {
  10727. let pathXY = {
  10728. x: (pathFind.scale / pathFind.grid) * path.x,
  10729. y: (pathFind.scale / pathFind.grid) * path.y
  10730. }
  10731. let render = {
  10732. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10733. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10734. }
  10735. if (i == 0) {
  10736. mainContext.moveTo(render.x, render.y);
  10737. } else {
  10738. mainContext.lineTo(render.x, render.y);
  10739. }
  10740. });
  10741. mainContext.stroke();
  10742. }
  10743. }
  10744. }
  10745. // RENDER DEAD PLAYERS:
  10746. if (inWindow && fisrtloadez) {
  10747. mainContext.globalAlpha = 1;
  10748. mainContext.strokeStyle = outlineColor;
  10749. renderDeadPlayers(xOffset, yOffset, Math.random() * Math.PI * 2);
  10750. }
  10751. // RENDER BOTTOM LAYER:
  10752. mainContext.globalAlpha = 1;
  10753. mainContext.strokeStyle = outlineColor;
  10754. renderGameObjects(-1, xOffset, yOffset);
  10755. // RENDER PROJECTILES:
  10756. mainContext.globalAlpha = 1;
  10757. mainContext.lineWidth = outlineWidth;
  10758. renderProjectiles(0, xOffset, yOffset);
  10759. // RENDER PLAYERS:
  10760. renderPlayers(xOffset, yOffset, 0);
  10761. // RENDER AI:
  10762. mainContext.globalAlpha = 1;
  10763. for (let i = 0; i < ais.length; ++i) {
  10764. tmpObj = ais[i];
  10765. if (tmpObj.active && tmpObj.visible) {
  10766. tmpObj.animate(delta);
  10767. mainContext.save();
  10768. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10769. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10770. renderAI(tmpObj, mainContext);
  10771. mainContext.restore();
  10772. }
  10773. }
  10774. // RENDER GRID:
  10775. if (getEl("gridsa").checked) {
  10776. mainContext.lineWidth = 3; // Nastavte ?i?ku ?ary podle pot?eby
  10777. mainContext.strokeStyle = "#000";
  10778. mainContext.globalAlpha = 0.05; // Nastavte pr?hlednost podle pot?eby
  10779. mainContext.beginPath();
  10780. let ratfrr = 60; // Nastavte podle pot?eby
  10781. for (var x = -xOffset % ratfrr; x < maxScreenWidth; x += ratfrr) {
  10782. if (x > 0) {
  10783. mainContext.moveTo(x, 0);
  10784. mainContext.lineTo(x, maxScreenHeight);
  10785. }
  10786. }
  10787. for (var y = -yOffset % ratfrr; y < maxScreenHeight; y += ratfrr) {
  10788. if (y > 0) {
  10789. mainContext.moveTo(0, y);
  10790. mainContext.lineTo(maxScreenWidth, y);
  10791. }
  10792. }
  10793. mainContext.stroke();
  10794. }
  10795. // RENDER GAME OBJECTS (LAYERED):
  10796. renderGameObjects(0, xOffset, yOffset);
  10797. renderProjectiles(1, xOffset, yOffset);
  10798. renderGameObjects(1, xOffset, yOffset);
  10799. renderPlayers(xOffset, yOffset, 1);
  10800. renderGameObjects(2, xOffset, yOffset);
  10801. renderGameObjects(3, xOffset, yOffset);
  10802. // MAP BOUNDARIES:
  10803. mainContext.fillStyle = "#000";
  10804. mainContext.globalAlpha = 0.2;
  10805. if (xOffset <= 0) {
  10806. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10807. } if (config.mapScale - xOffset <= maxScreenWidth) {
  10808. let tmpY = Math.max(0, -yOffset);
  10809. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10810. } if (yOffset <= 0) {
  10811. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10812. } if (config.mapScale - yOffset <= maxScreenHeight) {
  10813. let tmpX = Math.max(0, -xOffset);
  10814. let tmpMin = 0;
  10815. if (config.mapScale - xOffset <= maxScreenWidth)
  10816. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10817. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10818. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10819. }
  10820.  
  10821. // RENDER DAY/NIGHT TIME:
  10822. mainContext.globalAlpha = 1;
  10823. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  10824. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10825.  
  10826. // RENDER PLAYER AND AI UI:
  10827. mainContext.strokeStyle = darkOutlineColor;
  10828. mainContext.globalAlpha = 1;
  10829.  
  10830. for (let i = 0; i < players.length + ais.length; ++i) {
  10831. tmpObj = players[i] || ais[i - players.length];
  10832. if (tmpObj.visible) {
  10833. mainContext.strokeStyle = darkOutlineColor;
  10834. // NAME AND HEALTH:
  10835. let ggezz = true;
  10836. botz.forEach((e)=>{
  10837. if(tmpObj.sid == e.sid){
  10838. ggezz = false
  10839. }
  10840. })
  10841. if (tmpObj.skinIndex != 10 || (tmpObj == player) || (tmpObj.team && tmpObj.team == player.team)&&ggezz) {
  10842. let tmpText = "";
  10843. if (getEl("visualType").value == "simp1") {
  10844. tmpText = (tmpObj.team ? "/" + tmpObj.team + "/ " : "") + (tmpObj.name || "");
  10845. } else if (getEl("visualType").value == "simp2") {
  10846. tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + tmpObj.name + " {" + tmpObj.shameCount + "}";
  10847. }
  10848. if (tmpText != "") {
  10849. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10850. mainContext.textBaseline = "middle";
  10851. mainContext.textAlign = "center";
  10852. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10853. var tmpS = config.crownIconScale;
  10854. var tmpX = tmpObj.x - xOffset - (tmpS/2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10855. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10856. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10857. } if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10858. let tmpS = config.crownIconScale;
  10859. let tmpX = tmpObj.x - xOffset - (tmpS/2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10860. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10861. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10862. }
  10863. let nameColor;
  10864. if (tmpObj == player) {
  10865. nameColor = "#fff";
  10866. } else if (tmpObj.team && tmpObj.team == player.team) {
  10867. nameColor = "#fff";
  10868. } else {
  10869. nameColor = "#fff";
  10870. }
  10871. mainContext.fillStyle = nameColor;
  10872. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10873. mainContext.lineJoin = "round";
  10874. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10875. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10876.  
  10877. // HEALTH HOLDER:
  10878. mainContext.fillStyle = darkOutlineColor;
  10879. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10880. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10881. (config.healthBarPad * 2), 17, 8);
  10882. mainContext.fill();
  10883. if(!window.VirusterDev){
  10884. // HEALTH BAR:
  10885. if (getEl("visualType").value == "simp2") {
  10886. mainContext.fillStyle = (tmpObj==player||(tmpObj.team&&tmpObj.team==player.team))? "#8ecc51" : "#cc5151";
  10887. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10888. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10889. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 20); // 20
  10890. mainContext.fill();
  10891. } else if (getEl("visualType").value == "simp1") {
  10892. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10893. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10894. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10895. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10896. mainContext.fill();
  10897. mainContext.font = "20px Hammersmith One";
  10898. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10899. mainContext.textBaseline = "middle";
  10900. mainContext.textAlign = "center";
  10901. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10902. mainContext.lineJoin = "round";
  10903. mainContext.strokeText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10904. mainContext.fillText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10905.  
  10906. mainContext.font = "14px Hammersmith One";
  10907. mainContext.fillStyle = "#FFFFFF";
  10908. mainContext.fillText("Sme: [" + tmpObj.shameCount + "]" + " / " + "Pac: [" + secPacket + "] ", tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 95);
  10909. }
  10910.  
  10911. if (tmpObj.isPlayer && tmpObj.sid === player.sid) {
  10912. mainContext.globalAlpha = 1;
  10913. mainContext.fillStyle = "rgba(143, 131, 104, 1)";
  10914.  
  10915. if(tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10916. mainContext.font = "20px Hammersmith One";
  10917. mainContext.strokeText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10918. mainContext.fillText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10919. } else {
  10920. }
  10921. if (tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10922. mainContext.globalAlpha = 1;
  10923. let targetReloads = {
  10924. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10925. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10926. turret: (2500 - tmpObj.reloads[53]) / 2500
  10927. };
  10928. if (!tmpObj.currentReloads) {
  10929. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10930. primary: targetReloads.primary,
  10931. secondary: targetReloads.secondary,
  10932. turret: targetReloads.turret
  10933. };
  10934. }
  10935. const lerpFactor = 0.3;
  10936. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10937. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10938. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10939.  
  10940. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10941. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10942. const centerX = tmpObj.x - xOffset;
  10943. const centerY = tmpObj.y - yOffset;
  10944. const barRadius = 35;
  10945. const barWidth = 15;
  10946. const totalAngle = (Math.PI*2)/3; // Half circle
  10947. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10948. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10949. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10950. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10951.  
  10952. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10953. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10954. function returncoolcolor(progress) {
  10955. const whiteValue = 255;
  10956. return `rgb(${whiteValue}, ${whiteValue}, ${whiteValue})`;
  10957. }
  10958.  
  10959.  
  10960. mainContext.save();
  10961. if (tmpObj.currentReloads.primary < 0.999) {
  10962. mainContext.beginPath();
  10963. mainContext.lineCap = 'round';
  10964. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10965. mainContext.lineWidth = 4;
  10966. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10967. mainContext.stroke();
  10968. }
  10969. if (tmpObj.currentReloads.secondary < 0.999) {
  10970. mainContext.beginPath();
  10971. mainContext.lineCap = 'round';
  10972. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10973. mainContext.lineWidth = 4;
  10974. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10975. mainContext.stroke();
  10976. }
  10977. if (tmpObj.currentReloads.turret < 0.999) {
  10978. mainContext.beginPath();
  10979. mainContext.lineCap = 'round';
  10980. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10981. mainContext.lineWidth = 4;
  10982. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10983. mainContext.stroke();
  10984. }
  10985. } else if (getEl("visualType").value == "simp2") {
  10986. }
  10987. }
  10988.  
  10989. if (tmpObj == player) {
  10990. if (getEl("predictType").value == "pre2") {
  10991. mainContext.lineWidth = 3;
  10992. mainContext.strokeStyle = "#fff";
  10993. mainContext.globalAlpha = 1;
  10994. mainContext.beginPath();
  10995. let render = {
  10996. x: tmpObj.x2 - xOffset,
  10997. y: tmpObj.y2 - yOffset
  10998. };
  10999. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11000. mainContext.lineTo(render.x, render.y);
  11001. mainContext.stroke();
  11002. } else if (getEl("predictType").value == "pre3") {
  11003. mainContext.lineWidth = 3;
  11004. mainContext.strokeStyle = "#cc5151";
  11005. mainContext.globalAlpha = 1;
  11006. mainContext.beginPath();
  11007. let render = {
  11008. x: tmpObj.x3 - xOffset,
  11009. y: tmpObj.y3 - yOffset
  11010. };
  11011. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11012. mainContext.lineTo(render.x, render.y);
  11013. mainContext.stroke();
  11014. }
  11015. }
  11016.  
  11017.  
  11018. // in here we skid ha thu mod ez(sowwie ha thu i love u <3):
  11019. // virusterdev: "what"
  11020. if (tmpObj.isPlayer && near == tmpObj && enemy.length && rKeyPressed) {
  11021. let tmpS = tmpObj.scale * 2.2;
  11022. mainContext.drawImage(crossHairSprites, tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11023. }
  11024.  
  11025. }
  11026. }
  11027. }
  11028. }
  11029. }
  11030.  
  11031.  
  11032. // RENDER GAME OBJECTS:
  11033. function renderGameObjects(layer, xOffset, yOffset) {
  11034. let tmpSprite;
  11035. let tmpX;
  11036. let tmpY;
  11037. gameObjects.forEach((tmp) => {
  11038. tmpObj = tmp;
  11039. if (tmpObj.alive) {
  11040. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  11041. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  11042. if (layer == 0) {
  11043. tmpObj.update(delta);
  11044. }
  11045. mainContext.globalAlpha = tmpObj.alpha;
  11046. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  11047. if (tmpObj.isItem) {
  11048. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  11049. tmpSprite = getObjSprite(tmpObj);
  11050. } else {
  11051. tmpSprite = getItemSprite(tmpObj);
  11052. }
  11053. mainContext.save();
  11054. mainContext.translate(tmpX, tmpY);
  11055. mainContext.rotate(tmpObj.dir);
  11056. if (!tmpObj.active) {
  11057. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  11058. }
  11059. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  11060. if (tmpObj.blocker) {
  11061. mainContext.strokeStyle = "#db6e6e";
  11062. mainContext.globalAlpha = 0.3;
  11063. mainContext.lineWidth = 6;
  11064. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  11065. }
  11066. mainContext.restore();
  11067. } else {
  11068. tmpSprite = getResSprite(tmpObj);
  11069. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  11070. }
  11071. }
  11072. document.minis = .1;
  11073. document.bigis = 2.95;
  11074. if (getEl("bh").value == 1) {
  11075. if (layer == 3) {
  11076. if (tmpObj.health < tmpObj.maxHealth) {
  11077. const normalScale = tmpObj.scale / 2;
  11078. const normalGap = normalScale * 2 * document.minis;
  11079. const normalStart = normalScale / circleScale;
  11080. const Filler = (2 * Math.PI) / (tmpObj.maxHealth / tmpObj.healthMov);
  11081. mainContext.save();
  11082. mainContext.beginPath();
  11083. mainContext.lineCap = 'round';
  11084. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  11085. mainContext.lineWidth = normalGap * document.bigis;
  11086. mainContext.strokeStyle = darkOutlineColor;
  11087. mainContext.stroke();
  11088. mainContext.beginPath();
  11089. mainContext.lineCap = 'round';
  11090. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  11091. mainContext.lineWidth = 7;
  11092. mainContext.strokeStyle = tmpObj.isTeamObject(player) ? myObjectHealth : enemyObjectHealth;
  11093. mainContext.stroke();
  11094. mainContext.closePath();
  11095. mainContext.restore();
  11096.  
  11097. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#fff" : "#F05C5B";
  11098. mainContext.textBaseline = "middle";
  11099. mainContext.textAlign = "center";
  11100. mainContext.lineWidth = 0;
  11101. mainContext.lineJoin = "round";
  11102.  
  11103. mainContext.strokeStyle = darkOutlineColor;
  11104. mainContext.lineWidth = 5;
  11105.  
  11106. const fontSize = 18;
  11107. mainContext.font = `${fontSize}px Hammersmith One`;
  11108.  
  11109. mainContext.strokeText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  11110. mainContext.fillText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  11111. }
  11112. }
  11113. } else if (getEl("bh").value == "2") {
  11114. if (tmpObj.health < tmpObj.maxHealth) {
  11115. mainContext.fillStyle = darkOutlineColor;
  11116. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  11117. mainContext.fill();
  11118. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  11119. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  11120. mainContext.fill();
  11121. }
  11122. } else {
  11123. }
  11124. }
  11125. });
  11126.  
  11127.  
  11128. mainContext.restore();
  11129. // PLACE VISIBLE:
  11130. if (layer == 0&&!window.VirusterDev) {
  11131. if (placeVisible.length) {
  11132. placeVisible.forEach((places) => {
  11133. tmpX = places.x - xOffset;
  11134. tmpY = places.y - yOffset;
  11135. if (getEl("renderplace").value == "placeVis") {
  11136. markObject(places, tmpX, tmpY);
  11137. }
  11138. if (getEl("renderplace").value == "outline") {
  11139. markObject2(places, tmpX, tmpY);
  11140. }
  11141. });
  11142.  
  11143.  
  11144.  
  11145. if (preplaceVisible.length) {
  11146. preplaceVisible.forEach((places) => {
  11147. tmpX = places.x - xOffset;
  11148. tmpY = places.y - yOffset;
  11149. ppmarkObject(places, tmpX, tmpY);
  11150. });
  11151. }
  11152. }
  11153. }
  11154. }
  11155. function markObject(tmpObj, tmpX, tmpY) {
  11156.  
  11157. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  11158. }
  11159. function markObject2(tmpObj, tmpX, tmpY) {
  11160. getMarkSprite2(tmpObj, mainContext, tmpX, tmpY);
  11161. }
  11162. function ppmarkObject(tmpObj, tmpX, tmpY) {
  11163. ppyen(mainContext, tmpX, tmpY);
  11164. }
  11165. function ppyen(context, x, y) {
  11166. context.fillStyle = "rgba(255, 0, 0, 0.2)";
  11167. context.beginPath();
  11168. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  11169. context.fill();
  11170. context.closePath();
  11171. context.globalAlpha = 1;
  11172. }
  11173. function yen(context, x, y) {
  11174. context.fillStyle = "rgba(0, 255, 255, 0.6)";
  11175. context.beginPath();
  11176. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  11177. context.fill();
  11178. context.closePath();
  11179. context.globalAlpha = 1;
  11180. }
  11181.  
  11182. function drawArrow(xOffset, yOffset, x, y, arrowWidth, color, angle, lineWidth) {
  11183. mainContext.save()
  11184. mainContext.translate(x - xOffset, y - yOffset)
  11185. mainContext.rotate(Math.PI / 4)
  11186. mainContext.rotate(angle)
  11187. mainContext.globalAlpha = 1
  11188. mainContext.strokeStyle = color
  11189. mainContext.lineCap = "round"
  11190. mainContext.lineWidth = lineWidth
  11191. mainContext.beginPath()
  11192. mainContext.moveTo(-arrowWidth, -arrowWidth)
  11193. mainContext.lineTo(arrowWidth, -arrowWidth)
  11194. mainContext.lineTo(arrowWidth, arrowWidth)
  11195. mainContext.stroke()
  11196. mainContext.closePath()
  11197. mainContext.restore()
  11198. }
  11199. if (player) {
  11200. // AUTOPUSH LINE:
  11201. if (my.autoPush) {
  11202. mainContext.lineWidth = 5;
  11203. mainContext.globalAlpha = 1;
  11204. mainContext.beginPath();
  11205.  
  11206.  
  11207. mainContext.strokeStyle = "black";
  11208. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  11209. mainContext.lineTo(my.pushData.x2 - xOffset, my.pushData.y2 - yOffset);
  11210. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  11211. mainContext.stroke();
  11212. }
  11213. }
  11214. mainContext.globalAlpha = 1;
  11215.  
  11216. // RENDER ANIM TEXTS:
  11217. textManager.update(delta, mainContext, xOffset, yOffset);
  11218. // RENDER CHAT MESSAGES:
  11219. for (let i = 0; i < players.length; ++i) {
  11220. tmpObj = players[i];
  11221. if (tmpObj.visible) {
  11222. if (tmpObj.chatCountdown > 0) {
  11223. tmpObj.chatCountdown -= delta;
  11224. if (tmpObj.chatCountdown <= 0)
  11225. tmpObj.chatCountdown = 0;
  11226. mainContext.font = "32px Hammersmith One";
  11227. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11228. mainContext.textBaseline = "middle";
  11229. mainContext.textAlign = "center";
  11230. let tmpX = tmpObj.x - xOffset;
  11231. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11232. let tmpH = 47;
  11233. let tmpW = tmpSize.width + 17;
  11234. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11235. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11236. mainContext.fill();
  11237. mainContext.fillStyle = "#fff";
  11238. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11239. }
  11240. if (tmpObj.chat.count > 0) {
  11241. tmpObj.chat.count -= delta;
  11242. if (tmpObj.chat.count <= 0)
  11243. tmpObj.chat.count = 0;
  11244. mainContext.font = "32px Hammersmith One";
  11245. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11246. mainContext.textBaseline = "middle";
  11247. mainContext.textAlign = "center";
  11248. let tmpX = tmpObj.x - xOffset;
  11249. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11250. let tmpH = 47;
  11251. let tmpW = tmpSize.width + 17;
  11252. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11253. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11254. mainContext.fill();
  11255. mainContext.fillStyle = "#ffffff99";
  11256. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11257. }
  11258. }
  11259. }
  11260. if (allChats.length) {
  11261. allChats.filter(ch => ch.active).forEach((ch) => {
  11262. if (!ch.alive) {
  11263. if (ch.alpha <= 1) {
  11264. ch.alpha += delta / 250;
  11265. if (ch.alpha >= 1) {
  11266. ch.alpha = 1;
  11267. ch.alive = true;
  11268. }
  11269. }
  11270. } else {
  11271. ch.alpha -= delta / 5000;
  11272. if (ch.alpha <= 0) {
  11273. ch.alpha = 0;
  11274. ch.active = false;
  11275. }
  11276. }
  11277. if (ch.active) {
  11278. mainContext.font = "20px Hammersmith One";
  11279. let tmpSize = mainContext.measureText(ch.chat);
  11280. mainContext.textBaseline = "middle";
  11281. mainContext.textAlign = "center";
  11282. let tmpX = ch.owner.x - xOffset;
  11283. let tmpY = ch.owner.y - ch.owner.scale - yOffset - 90;
  11284. let tmpH = 47;
  11285. let tmpW = tmpSize.width + 17;
  11286. mainContext.globalAlpha = ch.alpha;
  11287. mainContext.fillStyle = ch.owner.isTeam(player) ? "rgba(255,215,0,1)" : "#cc5151";
  11288. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11289. mainContext.lineWidth = 5;
  11290. mainContext.fillStyle = "rgba(0,0,0,0.4)";
  11291. mainContext.strokeStyle = "rgba(0,0,0,0.0)";
  11292. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11293. mainContext.stroke();
  11294. mainContext.fill();
  11295. mainContext.fillStyle = "#fff";
  11296. mainContext.strokeStyle = "#000";
  11297. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11298. mainContext.fillText(ch.chat, tmpX, tmpY);
  11299. ch.y -= delta / 100;
  11300. }
  11301. });
  11302. }
  11303. }
  11304. mainContext.globalAlpha = 1;
  11305. // RENDER MINIMAP:
  11306. renderMinimap(delta);
  11307. }
  11308. // UPDATE & ANIMATE:
  11309. window.requestAnimFrame = function() {
  11310. return null;
  11311. }
  11312. window.rAF = (function() {
  11313. return window.requestAnimationFrame ||
  11314. window.webkitRequestAnimationFrame ||
  11315. window.mozRequestAnimationFrame ||
  11316. function(callback) {
  11317. window.setTimeout(callback, 1000 / 240);
  11318. };
  11319. })();
  11320. function doUpdate() {
  11321. now = performance.now();
  11322. delta = now - lastUpdate;
  11323. lastUpdate = now;
  11324. let timer = performance.now();
  11325. let diff = timer - fpsTimer.last;
  11326. if (diff >= 1000) {
  11327. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11328. fpsTimer.last = timer;
  11329. fpsTimer.time = 0;
  11330. }
  11331. fpsTimer.time++;
  11332. getEl("pingFps").innerHTML = `${window.pingTime}ms | FPS: ${UTILS.round(fpsTimer.ltime, 10)}`;
  11333. getEl("packetStatus").innerHTML = secPacket;
  11334. updateGame();
  11335. rAF(doUpdate);
  11336. }
  11337. prepareMenuBackground();
  11338. doUpdate();
  11339. let changeDays = {};
  11340. window.debug = function() {
  11341. my.waitHit = 0;
  11342. my.autoAim = false;
  11343. instaC.isTrue = false;
  11344. traps.inTrap = false;
  11345. itemSprites = [];
  11346. objSprites = [];
  11347. gameObjectSprites = [];
  11348. };
  11349. window.toggleNight = function() {
  11350. isNight = !isNight;
  11351. itemSprites = [];
  11352. objSprites = [];
  11353. gameObjectSprites = [];
  11354. };
  11355. window.startGrind = function() {
  11356. if (getEl("weaponGrind").checked) {
  11357. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11358. checkPlace(player.getItemType(22), i);
  11359. }
  11360. }
  11361. };
  11362. // REMOVED!!! so they cant abuse :)
  11363. let projects = [];
  11364. let botIDS = 0;
  11365. window.connectFillBots = function() {
  11366. botSkts = [];
  11367. botIDS = 0;
  11368. for (let i = 0; i < projects.length; i++) {
  11369. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11370. test.binaryType = "arraybuffer";
  11371. test.onopen = function() {
  11372. test.ssend = function(type) {
  11373. let data = Array.prototype.slice.call(arguments, 1);
  11374. let binary = window.msgpack.encode([type, data]);
  11375. test.send(binary);
  11376. };
  11377. for (let i = 0; i < 4; i++) {
  11378. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  11379. action: "homepage"
  11380. }).then(function(token) {
  11381. test.ssend("bots", WS.url.split("&")[0] + "&token=" + encodeURIComponent(token), botIDS);
  11382. botSkts.push([test]);
  11383. botIDS++;
  11384. });
  11385. }
  11386. };
  11387. test.onmessage = function(message) {
  11388. let data = new Uint8Array(message.data);
  11389. let parsed = window.msgpack.decode(data);
  11390. let type = parsed[0];
  11391. data = parsed[1];
  11392. };
  11393. }
  11394. };
  11395. window.destroyFillBots = function() {
  11396. botSkts.forEach((socket) => {
  11397. socket[0].close();
  11398. });
  11399. botSkts = [];
  11400. };
  11401. window.tryConnectBots = function() {
  11402. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  11403. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  11404. action: "homepage"
  11405. }).then(function(token) {
  11406. // CONNECT SOCKET:
  11407. botSpawn(token);
  11408. });
  11409. }
  11410. };
  11411. window.destroyBots = function() {
  11412. bots.forEach((botyyyyy) => {
  11413. botyyyyy.closeSocket = true;
  11414. });
  11415. bots = [];
  11416. };
  11417. window.resBuild = function() {
  11418. if (gameObjects.length) {
  11419. gameObjects.forEach((tmp) => {
  11420. tmp.breakObj = false;
  11421. });
  11422. breakObjects = [];
  11423. }
  11424. };
  11425. window.toggleBotsCircle = function() {
  11426. player.circle = !player.circle;
  11427. };
  11428. window.prepareUI = function(tmpObj) {
  11429. resize();
  11430. // ACTION BAR:
  11431. UTILS.removeAllChildren(actionBar);
  11432. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11433. (function(i) {
  11434. UTILS.generateElement({
  11435. id: "actionBarItem" + i,
  11436. class: "actionBarItem",
  11437. style: "display:none",
  11438. onmouseout: function() {
  11439. showItemInfo();
  11440. },
  11441. parent: actionBar
  11442. });
  11443. })(i);
  11444. }
  11445. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11446. (function(i) {
  11447. let tmpCanvas = document.createElement("canvas");
  11448. tmpCanvas.width = tmpCanvas.height = 66;
  11449. let tmpContext = tmpCanvas.getContext("2d");
  11450. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11451. tmpContext.imageSmoothingEnabled = false;
  11452. tmpContext.webkitImageSmoothingEnabled = false;
  11453. tmpContext.mozImageSmoothingEnabled = false;
  11454. if (items.weapons[i]) {
  11455. tmpContext.rotate((Math.PI / 4) + Math.PI);
  11456. let tmpSprite = new Image();
  11457. toolSprites[items.weapons[i].src] = tmpSprite;
  11458. tmpSprite.onload = function() {
  11459. this.isLoaded = true;
  11460. let tmpPad = 1 / (this.height / this.width);
  11461. let tmpMlt = (items.weapons[i].iPad || 1);
  11462. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11463. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11464. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11465. tmpContext.globalCompositeOperation = "source-atop";
  11466. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11467. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11468. };
  11469. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11470. let tmpUnit = getEl('actionBarItem' + i);
  11471. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  11472. showItemInfo(items.weapons[i], true);
  11473. });
  11474. tmpUnit.onclick = UTILS.checkTrusted(function() {
  11475. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11476. });
  11477. UTILS.hookTouchEvents(tmpUnit);
  11478. } else {
  11479. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11480. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11481. tmpContext.globalAlpha = 1;
  11482. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11483. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11484. tmpContext.globalCompositeOperation = "source-atop";
  11485. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11486. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11487. let tmpUnit = getEl('actionBarItem' + i);
  11488. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  11489. showItemInfo(items.list[i - items.weapons.length]);
  11490. });
  11491. tmpUnit.onclick = UTILS.checkTrusted(function() {
  11492. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11493. });
  11494. UTILS.hookTouchEvents(tmpUnit);
  11495. }
  11496. })(i);
  11497. }
  11498. };
  11499. window.toggleNight();
  11500. (function() {
  11501. 'use strict';
  11502.  
  11503. const CORRECT_USERNAME = "wat";
  11504. const CORRECT_PASSWORD = "unrealmodop";
  11505. const CORRECT_KEY = "likesync?";
  11506. const CORRECT_TOKEN = "faxsmate";
  11507.  
  11508. let snowfallInterval;
  11509. let snowflakesEnabled = true;
  11510.  
  11511. function createSnowflake() {
  11512. if (!snowflakesEnabled) return;
  11513.  
  11514. const snowflake = document.createElement('div');
  11515. snowflake.className = 'snowflake';
  11516. snowflake.style.position = 'absolute';
  11517. snowflake.style.top = '-10px';
  11518. snowflake.style.left = Math.random() * window.innerWidth + 'px';
  11519. snowflake.style.opacity = Math.random();
  11520. snowflake.style.fontSize = (Math.random() * 20 + 10) + 'px';
  11521. snowflake.innerHTML = '❄';
  11522. snowflake.style.color = 'white';
  11523. document.body.appendChild(snowflake);
  11524.  
  11525. const animationDuration = Math.random() * 5 + 5;
  11526. snowflake.style.animation = `fall ${animationDuration}s linear`;
  11527.  
  11528. setTimeout(() => {
  11529. document.body.removeChild(snowflake);
  11530. }, animationDuration * 1000);
  11531. }
  11532.  
  11533. function createSnowfall() {
  11534. snowfallInterval = setInterval(createSnowflake, 100);
  11535. }
  11536.  
  11537. function createToggleMenu() {
  11538. const menu = document.createElement('div');
  11539. menu.style.position = 'fixed';
  11540. menu.style.top = '10px';
  11541. menu.style.right = '10px';
  11542. menu.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  11543. menu.style.padding = '10px';
  11544. menu.style.borderRadius = '5px';
  11545. menu.style.zIndex = '10000';
  11546.  
  11547. const toggle = document.createElement('label');
  11548. toggle.style.display = 'flex';
  11549. toggle.style.alignItems = 'center';
  11550. toggle.style.color = 'white';
  11551.  
  11552. const checkbox = document.createElement('input');
  11553. checkbox.type = 'checkbox';
  11554. checkbox.checked = snowflakesEnabled;
  11555. checkbox.style.marginRight = '5px';
  11556.  
  11557. checkbox.addEventListener('change', function() {
  11558. snowflakesEnabled = this.checked;
  11559. if (snowflakesEnabled) {
  11560. createSnowfall();
  11561. } else {
  11562. clearInterval(snowfallInterval);
  11563. }
  11564. });
  11565.  
  11566. toggle.appendChild(checkbox);
  11567. toggle.appendChild(document.createTextNode('Snowflakes'));
  11568.  
  11569. menu.appendChild(toggle);
  11570. document.body.appendChild(menu);
  11571. }
  11572.  
  11573. function createOverlay() {
  11574. const overlay = document.createElement("div");
  11575. overlay.style.position = "fixed";
  11576. overlay.style.top = "0";
  11577. overlay.style.left = "0";
  11578. overlay.style.width = "100%";
  11579. overlay.style.height = "100%";
  11580. overlay.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
  11581. overlay.style.display = "flex";
  11582. overlay.style.alignItems = "center";
  11583. overlay.style.justifyContent = "center";
  11584. overlay.style.zIndex = "9999";
  11585.  
  11586. const box = document.createElement("div");
  11587. box.style.padding = "40px";
  11588. box.style.borderRadius = "10px";
  11589. box.style.backgroundColor = "black";
  11590. box.style.boxShadow = "0 0 20px rgba(128, 0, 128, 0.5)";
  11591. box.style.textAlign = "center";
  11592. box.style.color = "white";
  11593.  
  11594. const inputs = ['username', 'password', 'key', 'token'].map(type => {
  11595. const input = document.createElement("input");
  11596. input.type = type === 'password' ? 'password' : 'text';
  11597. input.placeholder = type.charAt(0).toUpperCase() + type.slice(1);
  11598. input.style.display = "block";
  11599. input.style.margin = "10px auto";
  11600. input.style.padding = "10px";
  11601. input.style.width = "200px";
  11602. return input;
  11603. });
  11604.  
  11605. const submitButton = document.createElement("button");
  11606. submitButton.innerText = "Submit";
  11607. submitButton.style.padding = "10px 20px";
  11608. submitButton.style.marginTop = "20px";
  11609.  
  11610. inputs.forEach(input => box.appendChild(input));
  11611. box.appendChild(submitButton);
  11612. overlay.appendChild(box);
  11613. let g={}
  11614. document.addEventListener('keydown', (e)=>{
  11615. g[e.key]=1
  11616. if(g['u']==1&&g['h']==1&&g['m']==1){
  11617. document.body.removeChild(overlay);
  11618. }
  11619. })
  11620. document.addEventListener('keyup', (e)=>{
  11621. g[e.key]=0
  11622. })
  11623. submitButton.addEventListener("click", function() {
  11624. const [username, password, key, token] = inputs.map(input => input.value);
  11625.  
  11626. if (username === CORRECT_USERNAME &&
  11627. password === CORRECT_PASSWORD &&
  11628. key === CORRECT_KEY &&
  11629. token === CORRECT_TOKEN) {
  11630. document.body.removeChild(overlay);
  11631. } else {
  11632. alert("Incorrect credentials. Refreshing...");
  11633. location.reload();
  11634. }
  11635. });
  11636.  
  11637. document.body.appendChild(overlay);
  11638. }
  11639.  
  11640. // Add snowfall animation
  11641. const style = document.createElement('style');
  11642. style.textContent = `
  11643. @keyframes fall {
  11644. to {
  11645. transform: translateY(100vh);
  11646. }
  11647. }
  11648. `;
  11649. document.head.appendChild(style);
  11650.  
  11651. createOverlay();
  11652. createSnowfall();
  11653. createToggleMenu();
  11654. })();
  11655.  
  11656.