Greasy Fork镜像 还支持 简体中文。

! Unreal? mod v8

Ong this mod so op it kell all server

  1. // ==UserScript==
  2. // @name ! Unreal? mod v8
  3. // @author wat, VirusterDev
  4. // @namespace try and ur gay
  5. // @description Ong this mod so op it kell all server
  6. // @version v.8
  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: wat
  38. -autoplace
  39. -autoreplace
  40. -autopreplace
  41. -autoretrap
  42. -AutoSpikeInTrap or autotrapInTrap
  43. -AutoSpikeTick(2) (1)
  44.  
  45. -Update-
  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. 7/23/2024
  58. -socket bots updated&fixed
  59. -autobreak spikes
  60. -heal re-coded
  61. */
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. let ping = 0, proheal = [];
  85.  
  86. document.getElementById("gameName").innerHTML = " Unreal mod?";
  87. (function() {
  88. let shadowRadius = 50;
  89. let shadowDirection = 1;
  90. let canShadow = true;
  91. setInterval(() => {
  92. if (canShadow == true) {
  93. shadowRadius = (shadowDirection == 1) ? shadowRadius - 5 : shadowRadius + 5;
  94. if (shadowRadius >= 50 || shadowRadius <= 0) {
  95. shadowDirection = (shadowRadius >= 50) ? 1 : (shadowRadius <= 0) ? 0 : null;
  96. canShadow = false;
  97. setTimeout(() => {
  98. canShadow = true;
  99. }, 100);
  100. }
  101. }
  102. document.getElementById("gameName").style.textShadow = `0px 0px ${shadowRadius + 20}px #ffffff`;
  103. }, 100);
  104. })();
  105.  
  106. (function() {
  107. })();var moomooVer = $('#linksContainer2 .menuLink').html(),
  108. hideSelectors = ['#mobileDownloadButtonContainer',
  109. '#followText',
  110. '#smallLinks',
  111. '#linksContainer1',
  112. '#twitterFollow',
  113. '#youtubeFollow',
  114. '#cdm-zone-02',
  115. '#youtuberOf',
  116. '#downloadButtonContainer',
  117. '#promoImg',
  118. '.menuHeader',
  119. '.menuLink',
  120. '.menuHeader:nth-child(5)',
  121. '.menuHeader:nth-child(6)',
  122. '.menuText',
  123. '#adCard',
  124. '#promoImgHolder',
  125. ],
  126.  
  127. css = '#rightCardHolder {display: block!important}',
  128. head = document.head || document.getElementsByTagName('head')[0],
  129. style = document.createElement('style');
  130.  
  131. style.type = 'text/css';
  132. if (style.styleSheet){
  133. style.styleSheet.cssText = css;
  134. } else {
  135. style.appendChild(document.createTextNode(css));
  136. }
  137.  
  138. for ( let i = 0; i < hideSelectors.length; i++ ) {
  139. $(hideSelectors[i]).hide();
  140. }
  141.  
  142. head.appendChild(style);
  143. $('#linksContainer2').html('<a href="./docs/versions.txt" target="_blank" class="menuLink">' + moomooVer + '</a>');
  144. document.getElementById("storeHolder").style = "height: 500px; width: 435px;";
  145. document.getElementById('enterGame').innerText = "Welcome";
  146. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  147. document.getElementById('enterGame').innerText = "Start?";
  148. });
  149. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  150. document.getElementById('enterGame').innerText = "Wanna play";
  151. });$('#itemInfoHolder').css({
  152. 'text-align': 'center',
  153. 'top': '25px',
  154. 'left': '440px',
  155. 'right': '350px',
  156. 'max-width': '350px'
  157. });
  158.  
  159. $('.menuCard').css({
  160. 'white-space': 'normal',
  161. 'text-align': 'center',
  162. 'background-color': 'rgba(0, 0, 0, 0.74)',
  163. '-moz-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  164. '-webkit-box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  165. 'box-shadow': '0px 0px rgba(255, 255, 255, 0)',
  166. '-webkit-border-radius': '10px',
  167. '-moz-border-radius': '10px',
  168. 'border-radius': '10px',
  169. 'margin': '15px',
  170. 'margin-top': '15px'
  171. });
  172.  
  173. $('#menuContainer').css({'white-space': 'normal'});
  174.  
  175. $('#mapDisplay').css({
  176. '-webkit-border-radius': '10px',
  177. '-moz-border-radius': '10px',
  178. 'border-radius': '10px'
  179. });
  180.  
  181. $('.menuHeader').css({
  182. 'color': 'rgba(0, 0, 0, 0.5)'
  183. });
  184.  
  185. $('#killCounter').css({
  186. 'color': '#ededed'
  187. });
  188.  
  189. $('#diedText').css({
  190. 'background-color': 'rgb(255, 255, 255)'
  191. });
  192.  
  193. $('#gameCanvas').css({
  194. 'background-color': '#f4f4f4'
  195. });
  196.  
  197. $('#scoreDisplay').css({
  198. 'color': '#e6b800'
  199. });
  200.  
  201.  
  202. $('#leaderboard').css({'-webkit-border-radius': '0px',
  203. '-moz-border-radius': '0px',
  204. 'border-radius': '0px',
  205. 'background-color': 'rgb((255,240,245))',
  206. 'text-align': 'center'});
  207.  
  208. $('#storeTab, #storeHolder, #allianceHolder').css({
  209. '-webkit-border-radius': '10px',
  210. '-moz-border-radius': '10px',
  211. 'border-radius': '10px',
  212. 'background-color': 'rgba(0, 0, 0, 0.4)'
  213. });
  214.  
  215. $('#storeHolder').css({
  216. 'height': '1500px',
  217. 'width': '450px'
  218. });
  219.  
  220. $('.actionBarItem').css({
  221. '-webkit-border-radius': '10px',
  222. 'border-radius': '10px',
  223. 'background-color': 'rgba(0, 0, 0, 0.4)',
  224. 'border-color': '#FF0000',
  225. 'box-shadow': '0 0 10px 0 rgba(255, 0, 0, 0.5)'
  226. });
  227. // pyroz color theme
  228. let nameColor = "#fff";
  229. let enemyNameColor = "#ffffff";
  230. let reloadBarColor = "";
  231. let healthBarColor = "#60478D";
  232. let shameBarColor = "#60478D";
  233. let enemyHealthBarColor = "#782F44";
  234. let damageTextColor = "#782F44";
  235. let healTextColor = "#60478D";
  236. let myObjectHealth = "#5f9ea0";
  237. let enemyObjectHealth = "#ff6363";
  238. let autoPushLine = "#ffffff";
  239.  
  240. document.addEventListener("keydown", function(event) {
  241. if(!window.VirusterDev){
  242. if (event.keyCode === 192) {
  243. const chatHolder = document.getElementById("gameUI");
  244. if (chatHolder) {
  245. const currentDisplay = chatHolder.style.display;
  246. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  247. }
  248. }
  249. if (event.keyCode === 99) {
  250. const chatHolder = document.getElementById("gameCanvas");
  251. if (chatHolder) {
  252. const currentDisplay = chatHolder.style.display;
  253. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  254. }
  255. }
  256. if (event.keyCode === 9) {
  257. const chatHolder = document.getElementById("menuChatDiv");
  258. if (chatHolder) {
  259. const currentDisplay = chatHolder.style.display;
  260. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  261. }
  262. }
  263. }
  264. });//virusterdev: some drunk dude had 3 keydown listeners for single conditions so i combined into one
  265. let circleScale = 1.5
  266. let namechanger = false;
  267. let inantiantibull = false;
  268. let spin = {
  269. degree: 45,
  270. toggle: false,
  271. angle: 0
  272. }
  273. function getEl(id) {
  274. return document.getElementById(id);
  275. }
  276. window.oncontextmenu = function() {
  277. return false;
  278. };
  279. let config = window.config;
  280. config.serverUpdateRate = 9;
  281. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  282. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  283. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  284. "#8bc373", "#91b2db"
  285. ];
  286. config.weaponVariants = [{
  287. id: 0,
  288. src: "",
  289. xp: 0,
  290. val: 1,
  291. }, {
  292. id: 1,
  293. src: "_g",
  294. xp: 3000,
  295. val: 1.1,
  296. }, {
  297. id: 2,
  298. src: "_d",
  299. xp: 7000,
  300. val: 1.18,
  301. }, {
  302. id: 3,
  303. src: "_r",
  304. poison: true,
  305. xp: 12000,
  306. val: 1.18,
  307. }];
  308. config.resetRender = false;
  309. function waitTime(timeout) {
  310. return new Promise((done) => {
  311. setTimeout(() => {
  312. done();
  313. }, timeout);
  314. });
  315. }
  316. let changed = false;
  317. let botSkts = [];
  318. // STORAGE:
  319. let canStore;
  320. if (typeof (Storage) !== "undefined") {
  321. canStore = true;
  322. }
  323. function saveVal(name, val) {
  324. if (canStore)
  325. localStorage.setItem(name, val);
  326. }
  327. function deleteVal(name) {
  328. if (canStore)
  329. localStorage.removeItem(name);
  330. }
  331. function getSavedVal(name) {
  332. if (canStore)
  333. return localStorage.getItem(name);
  334. return null;
  335. }
  336. // CONFIGS:
  337. let gC = function(a, b) {
  338. try {
  339. let res = JSON.parse(getSavedVal(a));
  340. if (typeof res === "object") {
  341. return b;
  342. } else {
  343. return res;
  344. }
  345. } catch (e) {
  346. return b;
  347. }
  348. };
  349. function setConfigs() {
  350. return {
  351. autochat: false,
  352. killChat: true,
  353. autoBuy: true,
  354. autoBuyEquip: true,
  355. autoRespawn: false,
  356. fpsboost: false,
  357. slowOT: false,
  358. attackDir: true,
  359. noDir: false,
  360. showDir: false,
  361. StopSpin: true,
  362. };
  363. }
  364.  
  365. function setconfig2() {
  366. return {
  367. AutoQonHigh: true,
  368. AutoQonSync: true,
  369. SimpleAnti: true,
  370. AntiBowInsta: true,
  371. AutoPlace: true,
  372. AutoReplace: true,
  373. AutoPreplace: false,
  374. AutoSpikeTick: true,
  375. AntiTrap: true,
  376. AutoPredictTick: true,
  377. AntiSpikeTick: true,
  378. AntiTick: false,
  379. spikeTick: true,
  380. CounterInsta: false,
  381. AutoBullSpam: false,
  382. AutoPush: false,
  383. };
  384. }
  385.  
  386. let configs1 = setconfig2();
  387. let configs = setConfigs();
  388.  
  389. window.removeConfigs = function() {
  390. for (let cF in configs && configs1) {
  391. deleteVal(cF, configs && configs1[cF]);
  392. }
  393. };
  394.  
  395. window.removeConfigs1 = function() {
  396. for (let cF in configs1) {
  397. deleteVal(cF, configs1[cF]);
  398. }
  399. };
  400.  
  401. for (let cF in configs) {
  402. configs[cF] = gC(cF, configs[cF]);
  403. }
  404. for (let cF in configs1) {
  405. configs1[cF] = gC(cF, configs1[cF]);
  406. }
  407.  
  408. class HtmlAction {
  409. constructor(element) {
  410. this.element = element;
  411. };
  412. add(code) {
  413. if (!this.element) return undefined;
  414. this.element.innerHTML += code;
  415. };
  416. newLine(amount) {
  417. let result = `<br>`;
  418. if (amount > 0) {
  419. result = ``;
  420. for (let i = 0; i < amount; i++) {
  421. result += `<br>`;
  422. }
  423. }
  424. this.add(result);
  425. };
  426. checkBox(setting) {
  427. let newCheck = `<input type = "checkbox"`;
  428. setting.id && (newCheck += ` id = ${setting.id}`);
  429. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  430. setting.class && (newCheck += ` class = ${setting.class}`);
  431. setting.checked && (newCheck += ` checked`);
  432. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  433. newCheck += `>`;
  434. this.add(newCheck);
  435. };
  436. text(setting) {
  437. let newText = `<input type = "text"`;
  438. setting.id && (newText += ` id = ${setting.id}`);
  439. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  440. setting.class && (newText += ` class = ${setting.class}`);
  441. setting.size && (newText += ` size = ${setting.size}`);
  442. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  443. setting.value && (newText += ` value = ${setting.value}`);
  444. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  445. newText += `>`;
  446. this.add(newText);
  447. };
  448. select(setting) {
  449. let newSelect = `<select`;
  450. setting.id && (newSelect += ` id = ${setting.id}`);
  451. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  452. setting.class && (newSelect += ` class = ${setting.class}`);
  453. newSelect += `>`;
  454. for (let options in setting.option) {
  455. newSelect += `<option value = ${setting.option[options].id}`
  456. setting.option[options].selected && (newSelect += ` selected`);
  457. newSelect += `>${options}</option>`;
  458. }
  459. newSelect += `</select>`;
  460. this.add(newSelect);
  461. };
  462. button(setting) {
  463. let newButton = `<button`;
  464. setting.id && (newButton += ` id = ${setting.id}`);
  465. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  466. setting.class && (newButton += ` class = ${setting.class}`);
  467. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  468. newButton += `>`;
  469. setting.innerHTML && (newButton += setting.innerHTML);
  470. newButton += `</button>`;
  471. this.add(newButton);
  472. };
  473. selectMenu(setting) {
  474. let newSelect = `<select`;
  475. if (!setting.id) {
  476. alert("please put id skid");
  477. return;
  478. }
  479. window[setting.id + "Func"] = function() {};
  480. setting.id && (newSelect += ` id = ${setting.id}`);
  481. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  482. setting.class && (newSelect += ` class = ${setting.class}`);
  483. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  484. newSelect += `>`;
  485. let last;
  486. let i = 0;
  487. for (let options in setting.menu) {
  488. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  489. setting.menu[options] && (newSelect += ` checked`);
  490. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  491. i++;
  492. }
  493. newSelect += `</select>`;
  494.  
  495. this.add(newSelect);
  496.  
  497. i = 0;
  498. for (let options in setting.menu) {
  499. window[options + "Func"] = function() {
  500. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  501. saveVal(options, setting.menu[options]);
  502.  
  503. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  504. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  505.  
  506. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  507.  
  508. };
  509. this.checkBox({
  510. id: "check_" + options,
  511. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  512. class: "checkB",
  513. onclick: `window.${options + "Func"}()`,
  514. checked: setting.menu[options]
  515. });
  516. i++;
  517. }
  518.  
  519. last = "check_" + getEl(setting.id).value.split("_")[1];
  520. window[setting.id + "Func"] = function() {
  521. getEl(last).style.display = "none";
  522. last = "check_" + getEl(setting.id).value.split("_")[1];
  523. getEl(last).style.display = "inline-block";
  524.  
  525. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  526.  
  527. };
  528. };
  529. };
  530. class Html {
  531. constructor() {
  532. this.element = null;
  533. this.action = null;
  534. this.divElement = null;
  535. this.startDiv = function(setting, func) {
  536.  
  537. let newDiv = document.createElement("div");
  538. setting.id && (newDiv.id = setting.id);
  539. setting.style && (newDiv.style = setting.style);
  540. setting.class && (newDiv.className = setting.class);
  541. this.element.appendChild(newDiv);
  542. this.divElement = newDiv;
  543.  
  544. let addRes = new HtmlAction(newDiv);
  545. typeof func == "function" && func(addRes);
  546.  
  547. };
  548. this.addDiv = function(setting, func) {
  549.  
  550. let newDiv = document.createElement("div");
  551. setting.id && (newDiv.id = setting.id);
  552. setting.style && (newDiv.style = setting.style);
  553. setting.class && (newDiv.className = setting.class);
  554. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  555. this.divElement = newDiv;
  556.  
  557. let addRes = new HtmlAction(newDiv);
  558. typeof func == "function" && func(addRes);
  559.  
  560. };
  561. };
  562. set(id) {
  563. this.element = getEl(id);
  564. this.action = new HtmlAction(this.element);
  565. };
  566. resetHTML(text) {
  567. if (text) {
  568. this.element.innerHTML = ``;
  569. } else {
  570. this.element.innerHTML = ``;
  571. }
  572. };
  573. setStyle(style) {
  574. this.element.style = style;
  575. };
  576. setCSS(style) {
  577. this.action.add(`<style>` + style + `</style>`);
  578. };
  579. };
  580. window.VirusterDev = false;
  581. window.TVDV = ()=>{
  582. window.VirusterDev = !window.VirusterDev
  583. }
  584. let HTML = new Html();
  585.  
  586.  
  587. let nightMode = document.createElement("div");
  588. nightMode.id = "nightMode";
  589. document.body.appendChild(nightMode);
  590. HTML.set("nightMode");
  591. HTML.setStyle(`
  592. display: none;
  593. position: absolute;
  594. pointer-events: none;
  595. background-color: rgb(0, 0, 100);
  596. opacity: 0;
  597. top: 0%;
  598. width: 100%;
  599. height: 100%;
  600. animation-duration: 5s;
  601. animation-name: night2;
  602. `);
  603. HTML.resetHTML();
  604. HTML.setCSS(`
  605. @keyframes night1 {
  606. from {opacity: 0;}
  607. to {opacity: 0.35;}
  608. }
  609. @keyframes night2 {
  610. from {opacity: 0.35;}
  611. to {opacity: 0;}
  612. }
  613. `);
  614. let menuDiv = document.createElement("div");
  615. menuDiv.id = "menuDiv";
  616. document.body.appendChild(menuDiv);
  617. HTML.set("menuDiv");
  618. HTML.setStyle(`
  619. position: absolute;
  620. left: 20px;
  621. top: 20px;
  622. `);
  623. HTML.resetHTML();
  624. HTML.setCSS(`
  625. .menuClass{
  626. color: #fff;
  627. font-size: 31px;
  628. text-align: left;
  629. padding: 10px;
  630. padding-top: 7px;
  631. padding-bottom: 5px;
  632. width: 300px;
  633. background-color: rgba(0, 0, 0, 0.25);
  634. -webkit-border-radius: 6px;
  635. -moz-border-radius: 6px;
  636. border-radius: 6px;
  637. 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;
  638. overflow: visible;
  639. filter: blur(5px);
  640. }
  641. .menuClass:hover {
  642. background-color: rgba(0, 0, 0, 0.25);
  643. transform: translateY(-5px) scale(1.05);
  644. filter: none;
  645. }
  646. .menuC {
  647. display: none;
  648. font-family: "Hammersmith One";
  649. font-size: 12px;
  650. max-height: 180px;
  651. overflow-y: scroll;
  652. -webkit-touch-callout: none;
  653. -webkit-user-select: none;
  654. -khtml-user-select: none;
  655. -moz-user-select: none;
  656. -ms-user-select: none;
  657. user-select: none;
  658. }
  659. .menuB {
  660. text-align: center;
  661. background-color: rgb(25, 25, 25);
  662. color: #fff;
  663. -webkit-border-radius: 4px;
  664. -moz-border-radius: 4px;
  665. border-radius: 4px;
  666. border: 2px solid #000;
  667. cursor: pointer;
  668. }
  669. .menuB:hover {
  670. border: 2px solid #fff;
  671. }
  672. .menuB:active {
  673. color: rgb(25, 25, 25);
  674. background-color: rgb(200, 200, 200);
  675. }
  676. .customText {
  677. color: #000;
  678. -webkit-border-radius: 4px;
  679. -moz-border-radius: 4px;
  680. border-radius: 4px;
  681. border: 2px solid #000;
  682. }
  683. .customText:focus {
  684. background-color: yellow;
  685. }
  686. .checkB {
  687. position: relative;
  688. top: 2px;
  689. accent-color: #888;
  690. cursor: pointer;
  691. }
  692. .Cselect {
  693. -webkit-border-radius: 4px;
  694. -moz-border-radius: 4px;
  695. border-radius: 4px;
  696. background-color: rgb(75, 75, 75);
  697. color: #fff;
  698. border: 1px solid #000;
  699. }
  700. #menuChanger {
  701. position: absolute;
  702. right: 10px;
  703. top: 10px;
  704. background-color: rgba(0, 0, 0, 0);
  705. color: #fff;
  706. border: none;
  707. cursor: pointer;
  708. }
  709. #menuChanger:hover {
  710. color: #000;
  711. }
  712. ::-webkit-scrollbar {
  713. width: 10px;
  714. }
  715. ::-webkit-scrollbar-track {
  716. opacity: 0;
  717. }
  718. ::-webkit-scrollbar-thumb {
  719. background-color: rgb(25, 25, 25);
  720. -webkit-border-radius: 4px;
  721. -moz-border-radius: 4px;
  722. border-radius: 4px;
  723. }
  724. ::-webkit-scrollbar-thumb:active {
  725. background-color: rgb(230, 230, 230);
  726. }
  727. `);
  728. HTML.startDiv({ id: "menuHeadLine", class: "menuClass" }, (html) => {
  729. html.button({ id: "menuChanger", class: "material-icons", innerHTML: `sync`, onclick: "window.changeMenu()" });
  730. HTML.addDiv({ id: "menuButtons", style: "display: block; overflow-y: visible;", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  731. html.button({ class: "menuB", innerHTML: "fix broken mod", onclick: "window.debug()" });
  732. html.button({ class: "menuB", innerHTML: "dark mode", onclick: "window.toggleNight()" });
  733. html.newLine();
  734. });
  735. HTML.addDiv({ id: "menuMain", style: "display: block", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  736. HTML.addDiv({ style: "font-size: 20px; color: #99ee99;", appendID: "menuMain" }, (html) => {
  737. html.add(`wats combat and other stuff`);
  738. });
  739. html.add(`Misc: `);
  740. html.selectMenu({ id: "configsChanger", class: "Cselect", menu: configs });
  741. html.newLine();
  742. html.add(`v1: `);
  743. html.selectMenu({ id: "configsChanger1", class: "Cselect", menu: configs1 });
  744. html.newLine();
  745. html.add(`AntiBull Type: `);
  746. html.select({
  747. id: "antiBullType", class: "Cselect", option: {
  748. "Disable AntiBull": {
  749. id: "noab",
  750. selected: true,
  751. },
  752. "When Reloaded": {
  753. id: "abreload",
  754. },
  755. "Primary Reloaded": {
  756. id: "abalway",
  757. }
  758. }
  759. });
  760. html.newLine();
  761. html.add(`Insta-Type: `);
  762. html.select({
  763. id: "instaType", class: "Cselect", option: {
  764. Normal: {
  765. id: "oneShot",
  766. selected: true
  767. },
  768. RevInsta: {
  769. id: "revTick",
  770. },
  771. Spammer: {
  772. id: "spammer"
  773. },
  774. }
  775. });
  776. html.newLine();
  777. html.add(`AutoOneFrame: `);
  778. html.checkBox({ id: "oneframe", class: "checkB", checked: false });
  779. html.newLine();
  780. html.add(`BackupNoBull: `);
  781. html.checkBox({ id: "backupNobull", class: "checkB", checked: false });
  782. html.newLine();
  783. html.add(`T^G Assist: `);
  784. html.checkBox({ id: "turretCombat", class: "checkB", checked: true });
  785. html.newLine();
  786. html.add(`Grind: `);
  787. html.checkBox({ id: "weaponGrind", class: "checkB", onclick: "window.startGrind()" });
  788. html.newLine();
  789. });
  790. HTML.addDiv({ id: "menuConfig", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  791. HTML.addDiv({ style: "font-size: 20px; color: #99ee99;", appendID: "menuConfig" }, (html) => {
  792. html.add(`wats weird visualsj`);
  793. });
  794. html.add(`Visuals: `);
  795. html.select({
  796. id: "visualType", class: "Cselect", option: {
  797. "Normal visuals": {
  798. id: "simp1",
  799. },
  800. "Advanced visuals": {
  801. id: "simp2",
  802. },
  803. }
  804. });
  805. html.newLine();
  806. html.add(`Render Place Type: `);
  807. html.select({
  808. id: "renderplace",
  809. class: "Cselect",
  810. option: {
  811. disable: {
  812. id: "disable",
  813. },
  814. Show: {
  815. id: "placeVis",
  816. selected: true
  817. },
  818. OutLine: {
  819. id: "outline"
  820. },
  821. }
  822. });
  823. html.newLine();
  824. html.add(`BuildingHealth: `);
  825. html.select({
  826. id: "bh", class: "Cselect", option: {
  827. "Disable": {
  828. id: "0",
  829. },
  830. "Circle": {
  831. id: "1",
  832. selected: true
  833. },
  834. "Rectangle": {
  835. id: "2"
  836. }
  837. }
  838. });
  839. html.newLine();
  840. html.add('Vision-stuff: ');
  841. html.select({
  842. id: "vision",
  843. class: "Cselect",
  844. option: {
  845. '1': {
  846. id: "1",
  847. selected: true
  848. },
  849. '1.1': {
  850. id: "1.1",
  851. },
  852. '1.2': {
  853. id: "1.2",
  854. },
  855. '1.3': {
  856. id: "1.3",
  857. },
  858. '1.4': {
  859. id: "1.4",
  860. },
  861. '1.5': {
  862. id: "1.5",
  863. },
  864. '2': {
  865. id: "2",
  866. }
  867. }
  868. })
  869. html.newLine();
  870. html.add('CameraSped: ');
  871. html.select({
  872. id: "camera", class: "Cselect", option: {
  873. 'FCam': {
  874. id: 'Cam+',
  875. },
  876. 'Normal': {
  877. id: 'Cam1',
  878. selected: true
  879. },
  880. 'medium': {
  881. id: 'Cam2',
  882. },
  883. 'Smooth': {
  884. id: 'Cam3',
  885. },
  886. }
  887. });
  888. html.newLine();
  889. html.add(`Predict-Move: `);
  890. html.select({
  891. id: "predictType", class: "Cselect", option: {
  892. "Disable": {
  893. id: "disableRender",
  894. selected: true
  895. },
  896. "X/Y and 2": {
  897. id: "pre2",
  898. },
  899. "X/Y and 3": {
  900. id: "pre3"
  901. }
  902. }
  903. });
  904. html.newLine();
  905. html.add(`Grids?: `);
  906. html.checkBox({ id: "gridsa", class: "checkB", checked: false });
  907. });
  908. HTML.addDiv({ id: "menuOther", class: "menuC", appendID: "menuHeadLine" }, (html) => {
  909. html.button({ class: "menuB", innerHTML: "Connect Bots", onclick: "window.tryConnectBots()" });
  910. html.button({ class: "menuB", innerHTML: "Disconnect Bots", onclick: "window.destroyBots()" });
  911.  
  912. html.newLine();
  913. html.add(`Socket Bots Mode: `);
  914. html.select({
  915. id: "mode",
  916. class: "Cselect",
  917. option: {
  918. "Stop": {
  919. id: "stopp",
  920. selected: false
  921. },
  922.  
  923. "Stop": {
  924. id: "mouse",
  925. selected: false
  926. },
  927. "Clear Building": {
  928. id: "clear",
  929. selected: false
  930. },
  931. "Mylee rush": {
  932. id: "fight",
  933. selected: false
  934. },
  935. "Sync": {
  936. id: "zync",
  937. selected: true
  938. },
  939. "Search": {
  940. id: "zearch"
  941. },
  942. "Clear Everything": {
  943. id: "fuckemup"
  944. },
  945. "Flex": {
  946. id: "flex"
  947. }
  948. }
  949. });
  950. html.newLine();
  951. html.button({ class: "menuB", innerHTML: "Connect FBots", onclick: "window.connectFillBots()" });
  952. html.button({ class: "menuB", innerHTML: "Disconnect FBots", onclick: "window.destroyFillBots()" });
  953. html.newLine();
  954. html.button({ class: "menuB", innerHTML: "Reset Break Objects", onclick: "window.resBuild()" });
  955. html.newLine();
  956. html.add(`Break Objects Range: `);
  957. html.text({ id: "breakRange", class: "customText", value: "700", size: "3em", maxLength: "4" });
  958. html.newLine();
  959. html.add(`Predict Movement Type: `);
  960.  
  961. html.newLine(2);
  962. html.button({ class: "menuB", innerHTML: "Toggle Fbots Circle", onclick: "window.toggleBotsCircle()" });
  963. html.newLine();
  964. html.add(`Circle Rad: `);
  965. html.text({ id: "circleRad", class: "customText", value: "200", size: "3em", maxLength: "4" });
  966. html.newLine();
  967. html.add(`Rad Speed: `);
  968. html.text({ id: "radSpeed", class: "customText", value: "0.1", size: "2em", maxLength: "3" });
  969. html.newLine(2);
  970. html.add(`Cross World: `);
  971. html.checkBox({ id: "funni", class: "checkB" });
  972. html.newLine();
  973. html.button({ class: "menuB", innerHTML: "Toggle Another Visual", onclick: "window.toggleVisual()" });
  974. html.newLine();
  975. html.button({ class: "menuB", innerHTML: "Toggle VirusterDev mode", onclick: "window.TVDV()" });
  976. html.newLine();
  977. });
  978. });
  979. let menuChatDiv = document.createElement("div");
  980. menuChatDiv.id = "menuChatDiv";
  981. document.body.appendChild(menuChatDiv);
  982. HTML.set("menuChatDiv");
  983. HTML.setStyle(`
  984. position: absolute;
  985. display: none;
  986. left: 0px;
  987. top: 0px;
  988. box-shadow: 0px 0px 10px rgba(0, 0, 0, 0); //0.65
  989. `);
  990. HTML.resetHTML();
  991. HTML.setCSS(`
  992. .chDiv{
  993. color: #fff;
  994. padding: 10px;
  995. width: 400px;
  996. height: 250px;
  997. background-color: rgba(0, 0, 0, 0); //0.35
  998. }
  999. .chMainDiv{
  1000. font-family: "Ubuntu";
  1001. font-size: 16px;
  1002. max-height: 215px;
  1003. -webkit-touch-callout: none;
  1004. -webkit-user-select: none;
  1005. -khtml-user-select: none;
  1006. -moz-user-select: none;
  1007. -ms-user-select: none;
  1008. user-select: none;
  1009. overflow-x: hidden;
  1010. }
  1011. .chMainBox{
  1012. position: absolute;
  1013. left: 10px;
  1014. bottom: 10px;
  1015. width: 335px;
  1016. height: 25px;
  1017. background-color: rgba(255, 255, 255, 0);
  1018. -webkit-border-radius: 4px;
  1019. -moz-border-radius: 4px;
  1020. border-radius: 4px;
  1021. color: rgba(255, 255, 255, 0);
  1022. font-family: "Arial";
  1023. font-size: 12px;
  1024. border: none;
  1025. outline: none;
  1026. }
  1027. `);
  1028. HTML.startDiv({id: "mChDiv", class: "chDiv"}, (html) => {
  1029. HTML.addDiv({id: "mChMain", class: "chMainDiv", appendID: "mChDiv"}, (html) => {
  1030. });
  1031. html.text({id: "mChBox", class: "chMainBox", placeHolder: ``});
  1032. });
  1033. let menuChats = getEl("mChMain");
  1034. let menuChatBox = getEl("mChBox");
  1035. let menuCBFocus = false;
  1036. let menuChCounts = 0;
  1037.  
  1038. function addChatLog(e, c, d, v) {
  1039. HTML.set("menuChatDiv");
  1040. let chatLogs = document.getElementById("mChMain");
  1041. const now = new Date();
  1042. const hours = now.getHours();
  1043. const minutes = now.getMinutes();
  1044. const ampm = hours >= 12 ? 'PM' : 'AM';
  1045. const formattedHours = (hours % 12 || 12).toString();
  1046. const formattedMinutes = minutes.toString().padStart(2, '0');
  1047. let time = `${formattedHours}:${formattedMinutes} ${ampm}`;
  1048.  
  1049. let a = document.createElement('div');
  1050. a.className = 'chatEntry';
  1051.  
  1052. let timeSpan = document.createElement('span');
  1053. timeSpan.style.color = 'rgba(255, 255, 255, 0.5)';
  1054. timeSpan.innerText = `${time}`;
  1055. a.appendChild(timeSpan);
  1056.  
  1057. let namething = document.createElement('span');
  1058. namething.style.color = v;
  1059. namething.innerText = ' ' + d;
  1060. a.appendChild(namething);
  1061.  
  1062. let chatSpan = document.createElement('span');
  1063. chatSpan.style.color = c;
  1064. chatSpan.innerText = ' ' + e;
  1065. a.appendChild(chatSpan);
  1066.  
  1067. chatLogs.appendChild(a);
  1068. chatLogs.scrollTop = chatLogs.scrollHeight;
  1069. }
  1070. let menuIndex = 0;
  1071. let menus = ["menuMain", "menuConfig", "menuOther"];
  1072. window.changeMenu = function() {
  1073. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1074. menuIndex++;
  1075. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1076. };
  1077. let mStatus = document.createElement("div");
  1078. mStatus.id = "status";
  1079. getEl("gameUI").appendChild(mStatus);
  1080. HTML.set("status");
  1081. HTML.setStyle(`
  1082. display: block;
  1083. position: absolute;
  1084. color: #ddd;
  1085. font: 15px Hammersmith One;
  1086. bottom: 215px;
  1087. left: 20px;
  1088. `);
  1089. HTML.resetHTML();
  1090. HTML.setCSS(`
  1091. .sizing {
  1092. font-size: 15px;
  1093. }
  1094. .mod {
  1095. font-size: 15px;
  1096. display: inline-block;
  1097. }
  1098. `);
  1099. HTML.startDiv({ id: "uehmod", class: "sizing" }, (html) => {
  1100. html.add(`Ping: `);
  1101. HTML.addDiv({ id: "pingFps", class: "mod", appendID: "uehmod" }, (html) => {
  1102. html.add("None");
  1103. });
  1104. html.newLine();
  1105. html.add(`Packet: `);
  1106. HTML.addDiv({ id: "packetStatus", class: "mod", appendID: "uehmod" }, (html) => {
  1107. html.add("None");
  1108. });
  1109. });
  1110. let openMenu = false;
  1111. let WS = undefined;
  1112. let socketID = undefined;
  1113. let secPacket = 0;
  1114. let secMax = 110;
  1115. let secTime = 1000;
  1116. let firstSend = {
  1117. sec: false
  1118. };
  1119. let game = {
  1120. tick: 0,
  1121. tickQueue: [],
  1122. tickBase: function(set, tick) {
  1123. if (this.tickQueue[this.tick + tick]) {
  1124. this.tickQueue[this.tick + tick].push(set);
  1125. } else {
  1126. this.tickQueue[this.tick + tick] = [set];
  1127. }
  1128. },
  1129. tickRate: (1000 / config.serverUpdateRate),
  1130. tickSpeed: 0,
  1131. lastTick: performance.now()
  1132. };
  1133. let modConsole = [];
  1134. let dontSend = false;
  1135. let fpsTimer = {
  1136. last: 0,
  1137. time: 0,
  1138. ltime: 0
  1139. }
  1140. let lastMoveDir = undefined;
  1141. let lastsp = ["cc", 1, "__proto__"];
  1142. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1143. WebSocket.prototype.send = function(message) {
  1144. if (!WS) {
  1145. WS = this;
  1146. WS.addEventListener("message", function(msg) {
  1147. getMessage(msg);
  1148. });
  1149. WS.addEventListener("close", (event) => {
  1150. if (event.code == 4001) {
  1151. window.location.reload();
  1152. }
  1153. });
  1154. }
  1155. if (WS == this) {
  1156. dontSend = false;
  1157. // EXTRACT DATA ARRAY:
  1158. let data = new Uint8Array(message);
  1159. let parsed = window.msgpack.decode(data);
  1160. let type = parsed[0];
  1161. data = parsed[1];
  1162. // SEND MESSAGE:
  1163. if (type == "6") {
  1164. if (data[0]) {
  1165. 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"];
  1166. let tmpString;
  1167. profanity.forEach((profany) => {
  1168. if (data[0].indexOf(profany) > -1) {
  1169. tmpString = "";
  1170. for (let i = 0; i < profany.length; ++i) {
  1171. if (i == 1) {
  1172. tmpString += String.fromCharCode(0);
  1173. }
  1174. tmpString += profany[i];
  1175. }
  1176. let re = new RegExp(profany, "g");
  1177. data[0] = data[0].replace(re, tmpString);
  1178. }
  1179. });
  1180. data[0] = data[0].slice(0, 30);
  1181. }
  1182. } else if (type == "L") {
  1183. // MAKE SAME CLAN:
  1184. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1185. data[0] = data[0].slice(0, 7);
  1186. } else if (type == "M") {
  1187. // APPLY CYAN COLOR:
  1188. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1189. data[0].moofoll = true;
  1190. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1191. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1192. } else if (type == "D") {
  1193. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1194. dontSend = true;
  1195. } else {
  1196. my.lastDir = data[0];
  1197. }
  1198. } else if (type == "d") {
  1199. if (!data[2]) {
  1200. dontSend = true;
  1201. } else {
  1202. if (![null, undefined].includes(data[1])) {
  1203. my.lastDir = data[1];
  1204. }
  1205. }
  1206. } else if (type == "K") {
  1207. if (!data[1]) {
  1208. dontSend = true;
  1209. }
  1210. } else if (type == "14") {
  1211. instaC.wait = !instaC.wait;
  1212. dontSend = true;
  1213. } else if (type == "a") {
  1214. if (data[1]) {
  1215. if (player.moveDir == data[0]) {
  1216. dontSend = true;
  1217. }
  1218. player.moveDir = data[0];
  1219. } else {
  1220. dontSend = true;
  1221. }
  1222. }
  1223. if (!dontSend) {
  1224. let binary = window.msgpack.encode([type, data]);
  1225. this.nsend(binary);
  1226. // START COUNT:
  1227. if (!firstSend.sec) {
  1228. firstSend.sec = true;
  1229. setTimeout(() => {
  1230. firstSend.sec = false;
  1231. secPacket = 0;
  1232. }, secTime);
  1233. }
  1234. secPacket++;
  1235. }
  1236. } else {
  1237. this.nsend(message);
  1238. }
  1239. }
  1240. function packet(type) {
  1241. // EXTRACT DATA ARRAY:
  1242. let data = Array.prototype.slice.call(arguments, 1);
  1243. // SEND MESSAGE:
  1244. let binary = window.msgpack.encode([type, data]);
  1245. WS.send(binary);
  1246. }
  1247. function getMessage(message) {
  1248. let data = new Uint8Array(message.data);
  1249. let parsed = window.msgpack.decode(data);
  1250. let type = parsed[0];
  1251. data = parsed[1];
  1252. let events = {
  1253. A: setInitData,
  1254. //B: disconnect,
  1255. C: setupGame,
  1256. D: addPlayer,
  1257. E: removePlayer,
  1258. a: updatePlayers,
  1259. G: updateLeaderboard,
  1260. H: loadGameObject,
  1261. I: loadAI,
  1262. J: animateAI,
  1263. K: gatherAnimation,
  1264. L: wiggleGameObject,
  1265. M: shootTurret,
  1266. N: updatePlayerValue,
  1267. O: updateHealth,
  1268. P: killPlayer,
  1269. Q: killObject,
  1270. R: killObjects,
  1271. S: updateItemCounts,
  1272. T: updateAge,
  1273. U: updateUpgrades,
  1274. V: updateItems,
  1275. X: addProjectile,
  1276. Y: remProjectile,
  1277. //Z: serverShutdownNotice,
  1278. //0: addAlliance,
  1279. //1: deleteAlliance,
  1280. 2: allianceNotification,
  1281. 3: setPlayerTeam,
  1282. 4: setAlliancePlayers,
  1283. 5: updateStoreItems,
  1284. 6: receiveChat,
  1285. 7: updateMinimap,
  1286. 8: showText,
  1287. 9: pingMap,
  1288. //0: pingSocketResponse,
  1289. };
  1290. if (type == "io-init") {
  1291. socketID = data[0];
  1292. } else {
  1293. if (events[type]) {
  1294. events[type].apply(undefined, data);
  1295. }
  1296. }
  1297. }
  1298. // MATHS:
  1299. Math.lerpAngle = function(value1, value2, amount) {
  1300. let difference = Math.abs(value2 - value1);
  1301. if (difference > Math.PI) {
  1302. if (value1 > value2) {
  1303. value2 += Math.PI * 2;
  1304. } else {
  1305. value1 += Math.PI * 2;
  1306. }
  1307. }
  1308. let value = value2 + ((value1 - value2) * amount);
  1309. if (value >= 0 && value <= Math.PI * 2) return value;
  1310. return value % (Math.PI * 2);
  1311. };
  1312. // REOUNDED RECTANGLE:
  1313. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1314. if (w < 2 * r) r = w / 2;
  1315. if (h < 2 * r) r = h / 2;
  1316. if (r < 0)
  1317. r = 0;
  1318. this.beginPath();
  1319. this.moveTo(x + r, y);
  1320. this.arcTo(x + w, y, x + w, y + h, r);
  1321. this.arcTo(x + w, y + h, x, y + h, r);
  1322. this.arcTo(x, y + h, x, y, r);
  1323. this.arcTo(x, y, x + w, y, r);
  1324. this.closePath();
  1325. return this;
  1326. };
  1327. // GLOBAL VALUES:
  1328. let allChats = [];
  1329. let ais = [];
  1330. let inWater = false
  1331. let players = [];
  1332. let alliances = [];
  1333. let alliancePlayers = [];
  1334. let allianceNotifications = [];
  1335. let gameObjects = [];
  1336. let projectiles = [];
  1337. let deadPlayers = [];
  1338. let breakObjects = [];
  1339. let player;
  1340. let playerSID;
  1341. let tmpObj;
  1342. let enemy = [];
  1343. //let perfectReplace = [];
  1344. let nears = [];
  1345. let near = [];
  1346. let rKeyPressed = false
  1347. let my = {
  1348. reloaded: false,
  1349. waitHit: 0,
  1350. autoAim: false,
  1351. revAim: false,
  1352. ageInsta: true,
  1353. reSync: false,
  1354. bullTick: 0,
  1355. anti0Tick: 0,
  1356. antiSync: false,
  1357. safePrimary: function(tmpObj) {
  1358. return [0, 8].includes(tmpObj.primaryIndex);
  1359. },
  1360. safeSecondary: function(tmpObj) {
  1361. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1362. },
  1363. lastDir: 0,
  1364. autoPush: false,
  1365. pushData: {}
  1366. }
  1367. // FIND OBJECTS BY ID/SID:
  1368. function findID(tmpObj, tmp) {
  1369. return tmpObj.find((THIS) => THIS.id == tmp);
  1370. }
  1371. function findSID(tmpObj, tmp) {
  1372. return tmpObj.find((THIS) => THIS.sid == tmp);
  1373. }
  1374. function findPlayerByID(id) {
  1375. return findID(players, id);
  1376. }
  1377. function findPlayerBySID(sid) {
  1378. return findSID(players, sid);
  1379. }
  1380. function findAIBySID(sid) {
  1381. return findSID(ais, sid);
  1382. }
  1383. function findObjectBySid(sid) {
  1384. return findSID(gameObjects, sid);
  1385. }
  1386. function findProjectileBySid(sid) {
  1387. return findSID(gameObjects, sid);
  1388. }
  1389. let gameName = getEl("gameName");
  1390. let adCard = getEl("adCard");
  1391. //adCard.remove();
  1392. let promoImageHolder = getEl("promoImgHolder");
  1393. promoImageHolder.remove();
  1394. let chatButton = getEl("chatButton");
  1395. chatButton.remove();
  1396. let gameCanvas = getEl("gameCanvas");
  1397. let mainContext = gameCanvas.getContext("2d");
  1398. let mapDisplay = getEl("mapDisplay");
  1399. let mapContext = mapDisplay.getContext("2d");
  1400. mapDisplay.width = 300;
  1401. mapDisplay.height = 300;
  1402. let storeMenu = getEl("storeMenu");
  1403. let storeHolder = getEl("storeHolder");
  1404. let upgradeHolder = getEl("upgradeHolder");
  1405. let upgradeCounter = getEl("upgradeCounter");
  1406. let chatBox = getEl("chatBox");
  1407. chatBox.autocomplete = "off";
  1408. chatBox.style.textAlign = "center";
  1409. chatBox.style.width = "18em";
  1410. let chatHolder = getEl("chatHolder");
  1411. let actionBar = getEl("actionBar");
  1412. let leaderboardData = getEl("leaderboardData");
  1413. let itemInfoHolder = getEl("itemInfoHolder");
  1414. let menuCardHolder = getEl("menuCardHolder");
  1415. let mainMenu = getEl("mainMenu");
  1416. let diedText = getEl("diedText");
  1417. let screenWidth;
  1418. let screenHeight;
  1419. let maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1420. let maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1421.  
  1422. function zoomVision() {
  1423. if (maxScreenWidth != config.maxScreenWidth * 1.5 || maxScreenHeight != config.maxScreenHeight * 1.5) {
  1424. maxScreenWidth = config.maxScreenWidth * 1.5;
  1425. maxScreenHeight = config.maxScreenHeight * 1.5;
  1426. resize();
  1427. }
  1428. }
  1429. function resetZoom() {
  1430. if (maxScreenWidth != config.maxScreenWidth * parseFloat(getEl("vision").value) || maxScreenHeight != config.maxScreenHeight * parseFloat(getEl("vision").value)) {
  1431. maxScreenWidth = config.maxScreenWidth * parseFloat(getEl("vision").value);
  1432. maxScreenHeight = config.maxScreenHeight * parseFloat(getEl("vision").value);
  1433. resize();
  1434. }
  1435. }
  1436. getEl("vision").onchange = function() {
  1437. resetZoom();
  1438. }
  1439. let pixelDensity = 1;
  1440. let delta;
  1441. let now;
  1442. let lastUpdate = performance.now();
  1443. let camX;
  1444. let camY;
  1445. let tmpDir;
  1446. let mouseX = 0;
  1447. let mouseY = 0;
  1448. let allianceMenu = getEl("allianceMenu");
  1449. let waterMult = 1;
  1450. let waterPlus = 0;
  1451. let outlineColor = "#525252";
  1452. let darkOutlineColor = "#3d3f42";
  1453. let outlineWidth = 5.5;
  1454. let isNight = false;
  1455. let firstSetup = true;
  1456. let keys = {};
  1457. let moveKeys = {
  1458. 87: [0, -1],
  1459. 38: [0, -1],
  1460. 83: [0, 1],
  1461. 40: [0, 1],
  1462. 65: [-1, 0],
  1463. 37: [-1, 0],
  1464. 68: [1, 0],
  1465. 39: [1, 0],
  1466. };
  1467. function resetMoveDir() {
  1468. keys = {};
  1469. packet("e");
  1470. }
  1471. let attackState = 0;
  1472. let inGame = false;
  1473. let macro = {};
  1474. let mills = {
  1475. place: 0,
  1476. placeSpawnPads: 0
  1477. };
  1478. let lastDir;
  1479. let lastLeaderboardData = [];
  1480. // ON LOAD:
  1481. let inWindow = true;
  1482. window.onblur = function() {
  1483. inWindow = false;
  1484. };
  1485. window.onfocus = function() {
  1486. inWindow = true;
  1487. if (player && player.alive) {
  1488. resetMoveDir();
  1489. }
  1490. };
  1491. let placeVisible = [];
  1492. let preplaceVisible = [];
  1493. let profanityList = [/*"cunt", "whore", "fuck", "shit", "faggot", "nigger",
  1494. "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex",
  1495. "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune",
  1496. "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard"*/];
  1497. /** CLASS CODES */
  1498. class Utils {
  1499. constructor() {
  1500. // MATH UTILS:
  1501. let mathABS = Math.abs,
  1502. mathCOS = Math.cos,
  1503. mathSIN = Math.sin,
  1504. mathPOW = Math.pow,
  1505. mathSQRT = Math.sqrt,
  1506. mathATAN2 = Math.atan2,
  1507. mathPI = Math.PI;
  1508. let _this = this;
  1509. // GLOBAL UTILS:
  1510. this.round = function(n, v) {
  1511. return Math.round(n * v) / v;
  1512. };
  1513. this.toRad = function(angle) {
  1514. return angle * (mathPI / 180);
  1515. };
  1516. this.toAng = function(radian) {
  1517. return radian / (mathPI / 180);
  1518. };
  1519. this.randInt = function(min, max) {
  1520. return Math.floor(Math.random() * (max - min + 1)) + min;
  1521. };
  1522. this.randFloat = function(min, max) {
  1523. return Math.random() * (max - min + 1) + min;
  1524. };
  1525. this.lerp = function(value1, value2, amount) {
  1526. return value1 + (value2 - value1) * amount;
  1527. };
  1528. this.decel = function(val, cel) {
  1529. if (val > 0)
  1530. val = Math.max(0, val - cel);
  1531. else if (val < 0)
  1532. val = Math.min(0, val + cel);
  1533. return val;
  1534. };
  1535. this.getDistance = function(x1, y1, x2, y2) {
  1536. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1537. };
  1538. this.getDist = function(tmp1, tmp2, type1, type2) {
  1539. let tmpXY1 = {
  1540. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1541. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1542. };
  1543. let tmpXY2 = {
  1544. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1545. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1546. };
  1547. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1548. };
  1549. this.getDirection = function(x1, y1, x2, y2) {
  1550. return mathATAN2(y1 - y2, x1 - x2);
  1551. };
  1552. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1553. let tmpXY1 = {
  1554. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1555. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1556. };
  1557. let tmpXY2 = {
  1558. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1559. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1560. };
  1561. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1562. };
  1563. this.getAngleDist = function(a, b) {
  1564. let p = mathABS(b - a) % (mathPI * 2);
  1565. return (p > mathPI ? (mathPI * 2) - p : p);
  1566. };
  1567. this.isNumber = function(n) {
  1568. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1569. };
  1570. this.isString = function(s) {
  1571. return (s && typeof s == "string");
  1572. };
  1573. this.kFormat = function(num) {
  1574. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1575. };
  1576. this.sFormat = function(num) {
  1577. let fixs = [
  1578. { num: 1e3, string: "k" },
  1579. { num: 1e6, string: "m" },
  1580. { num: 1e9, string: "b" },
  1581. { num: 1e12, string: "q" }
  1582. ].reverse();
  1583. let sp = fixs.find(v => num >= v.num);
  1584. if (!sp) return num;
  1585. return (num / sp.num).toFixed(1) + sp.string;
  1586. };
  1587. this.capitalizeFirst = function(string) {
  1588. return string.charAt(0).toUpperCase() + string.slice(1);
  1589. };
  1590. this.fixTo = function(n, v) {
  1591. return parseFloat(n.toFixed(v));
  1592. };
  1593. this.sortByPoints = function(a, b) {
  1594. return parseFloat(b.points) - parseFloat(a.points);
  1595. };
  1596. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1597. let minX = x1;
  1598. let maxX = x2;
  1599. if (x1 > x2) {
  1600. minX = x2;
  1601. maxX = x1;
  1602. }
  1603. if (maxX > recX2)
  1604. maxX = recX2;
  1605. if (minX < recX)
  1606. minX = recX;
  1607. if (minX > maxX)
  1608. return false;
  1609. let minY = y1;
  1610. let maxY = y2;
  1611. let dx = x2 - x1;
  1612. if (Math.abs(dx) > 0.0000001) {
  1613. let a = (y2 - y1) / dx;
  1614. let b = y1 - a * x1;
  1615. minY = a * minX + b;
  1616. maxY = a * maxX + b;
  1617. }
  1618. if (minY > maxY) {
  1619. let tmp = maxY;
  1620. maxY = minY;
  1621. minY = tmp;
  1622. }
  1623. if (maxY > recY2)
  1624. maxY = recY2;
  1625. if (minY < recY)
  1626. minY = recY;
  1627. if (minY > maxY)
  1628. return false;
  1629. return true;
  1630. };
  1631. this.containsPoint = function(element, x, y) {
  1632. let bounds = element.getBoundingClientRect();
  1633. let left = bounds.left + window.scrollX;
  1634. let top = bounds.top + window.scrollY;
  1635. let width = bounds.width;
  1636. let height = bounds.height;
  1637. let insideHorizontal = x > left && x < left + width;
  1638. let insideVertical = y > top && y < top + height;
  1639. return insideHorizontal && insideVertical;
  1640. };
  1641. this.mousifyTouchEvent = function(event) {
  1642. let touch = event.changedTouches[0];
  1643. event.screenX = touch.screenX;
  1644. event.screenY = touch.screenY;
  1645. event.clientX = touch.clientX;
  1646. event.clientY = touch.clientY;
  1647. event.pageX = touch.pageX;
  1648. event.pageY = touch.pageY;
  1649. };
  1650. this.hookTouchEvents = function(element, skipPrevent) {
  1651. let preventDefault = !skipPrevent;
  1652. let isHovering = false;
  1653. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1654. let passive = false;
  1655. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1656. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1657. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1658. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1659. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1660. function touchStart(e) {
  1661. _this.mousifyTouchEvent(e);
  1662. window.setUsingTouch(true);
  1663. if (preventDefault) {
  1664. e.preventDefault();
  1665. e.stopPropagation();
  1666. }
  1667. if (element.onmouseover)
  1668. element.onmouseover(e);
  1669. isHovering = true;
  1670. }
  1671. function touchMove(e) {
  1672. _this.mousifyTouchEvent(e);
  1673. window.setUsingTouch(true);
  1674. if (preventDefault) {
  1675. e.preventDefault();
  1676. e.stopPropagation();
  1677. }
  1678. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1679. if (!isHovering) {
  1680. if (element.onmouseover)
  1681. element.onmouseover(e);
  1682. isHovering = true;
  1683. }
  1684. } else {
  1685. if (isHovering) {
  1686. if (element.onmouseout)
  1687. element.onmouseout(e);
  1688. isHovering = false;
  1689. }
  1690. }
  1691. }
  1692. function touchEnd(e) {
  1693. _this.mousifyTouchEvent(e);
  1694. window.setUsingTouch(true);
  1695. if (preventDefault) {
  1696. e.preventDefault();
  1697. e.stopPropagation();
  1698. }
  1699. if (isHovering) {
  1700. if (element.onclick)
  1701. element.onclick(e);
  1702. if (element.onmouseout)
  1703. element.onmouseout(e);
  1704. isHovering = false;
  1705. }
  1706. }
  1707. };
  1708. this.removeAllChildren = function(element) {
  1709. while (element.hasChildNodes()) {
  1710. element.removeChild(element.lastChild);
  1711. }
  1712. };
  1713. this.generateElement = function(config) {
  1714. let element = document.createElement(config.tag || "div");
  1715. function bind(configValue, elementValue) {
  1716. if (config[configValue])
  1717. element[elementValue] = config[configValue];
  1718. }
  1719. bind("text", "textContent");
  1720. bind("html", "innerHTML");
  1721. bind("class", "className");
  1722. for (let key in config) {
  1723. switch (key) {
  1724. case "tag":
  1725. case "text":
  1726. case "html":
  1727. case "class":
  1728. case "style":
  1729. case "hookTouch":
  1730. case "parent":
  1731. case "children":
  1732. continue;
  1733. default:
  1734. break;
  1735. }
  1736. element[key] = config[key];
  1737. }
  1738. if (element.onclick)
  1739. element.onclick = this.checkTrusted(element.onclick);
  1740. if (element.onmouseover)
  1741. element.onmouseover = this.checkTrusted(element.onmouseover);
  1742. if (element.onmouseout)
  1743. element.onmouseout = this.checkTrusted(element.onmouseout);
  1744. if (config.style) {
  1745. element.style.cssText = config.style;
  1746. }
  1747. if (config.hookTouch) {
  1748. this.hookTouchEvents(element);
  1749. }
  1750. if (config.parent) {
  1751. config.parent.appendChild(element);
  1752. }
  1753. if (config.children) {
  1754. for (let i = 0; i < config.children.length; i++) {
  1755. element.appendChild(config.children[i]);
  1756. }
  1757. }
  1758. return element;
  1759. };
  1760. this.checkTrusted = function(callback) {
  1761. return function(ev) {
  1762. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1763. callback(ev);
  1764. } else {
  1765. //console.error("Event is not trusted.", ev);
  1766. }
  1767. };
  1768. };
  1769. this.randomString = function(length) {
  1770. let text = "";
  1771. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1772. for (let i = 0; i < length; i++) {
  1773. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1774. }
  1775. return text;
  1776. };
  1777. this.countInArray = function(array, val) {
  1778. let count = 0;
  1779. for (let i = 0; i < array.length; i++) {
  1780. if (array[i] === val) count++;
  1781. }
  1782. return count;
  1783. };
  1784. this.hexToRgb = function(hex) {
  1785. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1786. };
  1787. this.getRgb = function(r, g, b) {
  1788. return [r / 255, g / 255, b / 255].join(", ");
  1789. };
  1790. }
  1791. };
  1792. class Animtext {
  1793. // ANIMATED TEXT:
  1794. constructor() {
  1795. // INIT:
  1796. this.init = function(x, y, scale, speed, life, text, color) {
  1797. this.x = x;
  1798. this.y = y;
  1799. this.color = color;
  1800. this.scale = scale;
  1801. this.startScale = this.scale;
  1802. this.maxScale = scale * 1.5;
  1803. this.scaleSpeed = 0.7;
  1804. this.speed = speed;
  1805. this.life = life;
  1806. this.text = text;
  1807. this.acc = 1;
  1808. this.alpha = 0;
  1809. this.maxLife = life;
  1810. this.ranX = UTILS.randFloat(-1, 1);
  1811. };
  1812. // UPDATE:
  1813. this.update = function(delta) {
  1814. if (this.life) {
  1815. this.life -= delta;
  1816. this.y -= this.speed * delta;
  1817. this.scale += this.scaleSpeed * delta;
  1818. if (this.scale >= this.maxScale) {
  1819. this.scale = this.maxScale;
  1820. this.scaleSpeed *= -1;
  1821. } else if (this.scale <= this.startScale) {
  1822. this.scale = this.startScale;
  1823. this.scaleSpeed = 0;
  1824. }
  1825. if (this.life <= 0) {
  1826. this.life = 0;
  1827. }
  1828. }
  1829. };
  1830. // RENDER:
  1831. this.render = function(ctxt, xOff, yOff) {
  1832. ctxt.lineWidth = 10;
  1833. ctxt.fillStyle = this.color;
  1834. ctxt.font = this.scale + "px " + (this.scale >= 15 ? "Hammersmith One" : "Ubuntu");
  1835. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1836. ctxt.globalAlpha = 1;
  1837. };
  1838. }
  1839. };
  1840. class Textmanager {
  1841. // TEXT MANAGER:
  1842. constructor() {
  1843. this.texts = [];
  1844. this.stack = [];
  1845. // UPDATE:
  1846. this.update = function(delta, ctxt, xOff, yOff) {
  1847. ctxt.textBaseline = "middle";
  1848. ctxt.textAlign = "center";
  1849. for (let i = 0; i < this.texts.length; ++i) {
  1850. if (this.texts[i].life) {
  1851. this.texts[i].update(delta);
  1852. this.texts[i].render(ctxt, xOff, yOff);
  1853. }
  1854. }
  1855. };
  1856. // SHOW TEXT:
  1857. this.showText = function(x, y, scale, speed, life, text, color) {
  1858. let tmpText;
  1859. for (let i = 0; i < this.texts.length; ++i) {
  1860. if (!this.texts[i].life) {
  1861. tmpText = this.texts[i];
  1862. break;
  1863. }
  1864. }
  1865. if (!tmpText) {
  1866. tmpText = new Animtext();
  1867. this.texts.push(tmpText);
  1868. }
  1869. tmpText.init(x, y, scale, speed, life, text, color);
  1870. };
  1871. }
  1872. }
  1873. class GameObject {
  1874. constructor(sid) {
  1875. this.sid = sid;
  1876. // INIT:
  1877. this.init = function(x, y, dir, scale, type, data, owner) {
  1878. data = data || {};
  1879. this.sentTo = {};
  1880. this.gridLocations = [];
  1881. this.active = true;
  1882. this.alive = true;
  1883. this.doUpdate = data.doUpdate;
  1884. this.x = x;
  1885. this.y = y;
  1886. this.dir = dir;
  1887. this.lastDir = dir;
  1888. this.xWiggle = 0;
  1889. this.yWiggle = 0;
  1890. this.visScale = scale;
  1891. this.scale = scale;
  1892. this.type = type;
  1893. this.id = data.id;
  1894. this.owner = owner;
  1895. this.name = data.name;
  1896. this.isItem = (this.id != undefined);
  1897. this.group = data.group;
  1898. this.maxHealth = data.health;
  1899. this.health = this.maxHealth;
  1900. this.healthMov = 100;
  1901. this.layer = 2;
  1902. if (this.group != undefined) {
  1903. this.layer = this.group.layer;
  1904. } else if (this.type == 0) {
  1905. this.layer = 3;
  1906. } else if (this.type == 2) {
  1907. this.layer = 0;
  1908. } else if (this.type == 4) {
  1909. this.layer = -1;
  1910. }
  1911. this.colDiv = data.colDiv || 1;
  1912. this.blocker = data.blocker;
  1913. this.ignoreCollision = data.ignoreCollision;
  1914. this.dontGather = data.dontGather;
  1915. this.hideFromEnemy = data.hideFromEnemy;
  1916. this.friction = data.friction;
  1917. this.projDmg = data.projDmg;
  1918. this.dmg = data.dmg;
  1919. this.pDmg = data.pDmg;
  1920. this.pps = data.pps;
  1921. this.zIndex = data.zIndex || 0;
  1922. this.turnSpeed = data.turnSpeed;
  1923. this.req = data.req;
  1924. this.trap = data.trap;
  1925. this.healCol = data.healCol;
  1926. this.teleport = data.teleport;
  1927. this.boostSpeed = data.boostSpeed;
  1928. this.projectile = data.projectile;
  1929. this.shootRange = data.shootRange;
  1930. this.shootRate = data.shootRate;
  1931. this.shootCount = this.shootRate;
  1932. this.spawnPoint = data.spawnPoint;
  1933. this.onNear = 0;
  1934. this.breakObj = false;
  1935. this.alpha = data.alpha || 1;
  1936. this.maxAlpha = data.alpha || 1;
  1937. this.damaged = 0;
  1938. };
  1939. // GET HIT:
  1940. this.changeHealth = function(amount, doer) {
  1941. this.health += amount;
  1942. return (this.health <= 0);
  1943. };
  1944. // GET SCALE:
  1945. this.getScale = function(sM, ig) {
  1946. sM = sM || 1;
  1947. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  1948. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  1949. };
  1950. // VISIBLE TO PLAYER:
  1951. this.visibleToPlayer = function(player) {
  1952. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  1953. (this.owner.team && player.team == this.owner.team)));
  1954. };
  1955. // UPDATE:
  1956. this.update = function(delta) {
  1957. if (this.health != this.healthMov) {
  1958. this.health < this.healthMov ? (this.healthMov -= 1.9) : (this.healthMov += 1.9);
  1959. if (Math.abs(this.health - this.healthMov) < 1.9) this.healthMov = this.health;
  1960. };
  1961. if (this.active) {
  1962. if (this.xWiggle) {
  1963. this.xWiggle *= Math.pow(0.99, delta);
  1964. }
  1965. if (this.yWiggle) {
  1966. this.yWiggle *= Math.pow(0.99, delta);
  1967. }
  1968. if (this.turnSpeed && this.dmg) {
  1969. this.dir += this.turnSpeed * delta;
  1970. }
  1971. } else {
  1972. if (this.alive) {
  1973. this.alpha -= delta / (200 / this.maxAlpha);
  1974. this.visScale += delta / (this.scale / 2.5);
  1975. if (this.alpha <= 0) {
  1976. this.alpha = 0;
  1977. this.alive = false;
  1978. }
  1979. }
  1980. }
  1981. };
  1982. // CHECK TEAM:
  1983. this.isTeamObject = function(tmpObj) {
  1984. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  1985. };
  1986. }
  1987. }
  1988. class Items {
  1989. constructor() {
  1990. // ITEM GROUPS:
  1991. this.groups = [{
  1992. id: 0,
  1993. name: "food",
  1994. layer: 0
  1995. }, {
  1996. id: 1,
  1997. name: "walls",
  1998. place: true,
  1999. limit: 30,
  2000. layer: 0
  2001. }, {
  2002. id: 2,
  2003. name: "spikes",
  2004. place: true,
  2005. limit: 15,
  2006. layer: 0
  2007. }, {
  2008. id: 3,
  2009. name: "mill",
  2010. place: true,
  2011. limit: 7,
  2012. layer: 1
  2013. }, {
  2014. id: 4,
  2015. name: "mine",
  2016. place: true,
  2017. limit: 1,
  2018. layer: 0
  2019. }, {
  2020. id: 5,
  2021. name: "trap",
  2022. place: true,
  2023. limit: 6,
  2024. layer: -1
  2025. }, {
  2026. id: 6,
  2027. name: "booster",
  2028. place: true,
  2029. limit: 12,
  2030. layer: -1
  2031. }, {
  2032. id: 7,
  2033. name: "turret",
  2034. place: true,
  2035. limit: 2,
  2036. layer: 1
  2037. }, {
  2038. id: 8,
  2039. name: "watchtower",
  2040. place: true,
  2041. limit: 12,
  2042. layer: 1
  2043. }, {
  2044. id: 9,
  2045. name: "buff",
  2046. place: true,
  2047. limit: 4,
  2048. layer: -1
  2049. }, {
  2050. id: 10,
  2051. name: "spawn",
  2052. place: true,
  2053. limit: 1,
  2054. layer: -1
  2055. }, {
  2056. id: 11,
  2057. name: "sapling",
  2058. place: true,
  2059. limit: 2,
  2060. layer: 0
  2061. }, {
  2062. id: 12,
  2063. name: "blocker",
  2064. place: true,
  2065. limit: 3,
  2066. layer: -1
  2067. }, {
  2068. id: 13,
  2069. name: "teleporter",
  2070. place: true,
  2071. limit: 2,
  2072. layer: -1
  2073. }];
  2074. // PROJECTILES:
  2075. this.projectiles = [{
  2076. indx: 0,
  2077. layer: 0,
  2078. src: "arrow_1",
  2079. dmg: 25,
  2080. speed: 1.6,
  2081. scale: 103,
  2082. range: 1000
  2083. }, {
  2084. indx: 1,
  2085. layer: 1,
  2086. dmg: 25,
  2087. scale: 20
  2088. }, {
  2089. indx: 0,
  2090. layer: 0,
  2091. src: "arrow_1",
  2092. dmg: 35,
  2093. speed: 2.5,
  2094. scale: 103,
  2095. range: 1200
  2096. }, {
  2097. indx: 0,
  2098. layer: 0,
  2099. src: "arrow_1",
  2100. dmg: 30,
  2101. speed: 2,
  2102. scale: 103,
  2103. range: 1200
  2104. }, {
  2105. indx: 1,
  2106. layer: 1,
  2107. dmg: 16,
  2108. scale: 20
  2109. }, {
  2110. indx: 0,
  2111. layer: 0,
  2112. src: "bullet_1",
  2113. dmg: 50,
  2114. speed: 3.6,
  2115. scale: 160,
  2116. range: 1400
  2117. }];
  2118. // WEAPONS:
  2119. this.weapons = [{
  2120. id: 0,
  2121. type: 0,
  2122. name: "tool hammer",
  2123. desc: "tool for gathering all resources",
  2124. src: "hammer_1",
  2125. length: 140,
  2126. width: 140,
  2127. xOff: -3,
  2128. yOff: 18,
  2129. dmg: 25,
  2130. range: 65,
  2131. gather: 1,
  2132. speed: 300
  2133. }, {
  2134. id: 1,
  2135. type: 0,
  2136. age: 2,
  2137. name: "hand axe",
  2138. desc: "gathers resources at a higher rate",
  2139. src: "axe_1",
  2140. length: 140,
  2141. width: 140,
  2142. xOff: 3,
  2143. yOff: 24,
  2144. dmg: 30,
  2145. spdMult: 1,
  2146. range: 70,
  2147. gather: 2,
  2148. speed: 400
  2149. }, {
  2150. id: 2,
  2151. type: 0,
  2152. age: 8,
  2153. pre: 1,
  2154. name: "great axe",
  2155. desc: "deal more damage and gather more resources",
  2156. src: "great_axe_1",
  2157. length: 140,
  2158. width: 140,
  2159. xOff: -8,
  2160. yOff: 25,
  2161. dmg: 35,
  2162. spdMult: 1,
  2163. range: 75,
  2164. gather: 4,
  2165. speed: 400
  2166. }, {
  2167. id: 3,
  2168. type: 0,
  2169. age: 2,
  2170. name: "short sword",
  2171. desc: "increased attack power but slower move speed",
  2172. src: "sword_1",
  2173. iPad: 1.3,
  2174. length: 130,
  2175. width: 210,
  2176. xOff: -8,
  2177. yOff: 46,
  2178. dmg: 35,
  2179. spdMult: 0.85,
  2180. range: 110,
  2181. gather: 1,
  2182. speed: 300
  2183. }, {
  2184. id: 4,
  2185. type: 0,
  2186. age: 8,
  2187. pre: 3,
  2188. name: "katana",
  2189. desc: "greater range and damage",
  2190. src: "samurai_1",
  2191. iPad: 1.3,
  2192. length: 130,
  2193. width: 210,
  2194. xOff: -8,
  2195. yOff: 59,
  2196. dmg: 40,
  2197. spdMult: 0.8,
  2198. range: 118,
  2199. gather: 1,
  2200. speed: 300
  2201. }, {
  2202. id: 5,
  2203. type: 0,
  2204. age: 2,
  2205. name: "polearm",
  2206. desc: "long range melee weapon",
  2207. src: "spear_1",
  2208. iPad: 1.3,
  2209. length: 130,
  2210. width: 210,
  2211. xOff: -8,
  2212. yOff: 53,
  2213. dmg: 45,
  2214. knock: 0.2,
  2215. spdMult: 0.82,
  2216. range: 142,
  2217. gather: 1,
  2218. speed: 700
  2219. }, {
  2220. id: 6,
  2221. type: 0,
  2222. age: 2,
  2223. name: "bat",
  2224. desc: "fast long range melee weapon",
  2225. src: "bat_1",
  2226. iPad: 1.3,
  2227. length: 110,
  2228. width: 180,
  2229. xOff: -8,
  2230. yOff: 53,
  2231. dmg: 20,
  2232. knock: 0.7,
  2233. range: 110,
  2234. gather: 1,
  2235. speed: 300
  2236. }, {
  2237. id: 7,
  2238. type: 0,
  2239. age: 2,
  2240. name: "daggers",
  2241. desc: "really fast short range weapon",
  2242. src: "dagger_1",
  2243. iPad: 0.8,
  2244. length: 110,
  2245. width: 110,
  2246. xOff: 18,
  2247. yOff: 0,
  2248. dmg: 20,
  2249. knock: 0.1,
  2250. range: 65,
  2251. gather: 1,
  2252. hitSlow: 0.1,
  2253. spdMult: 1.13,
  2254. speed: 100
  2255. }, {
  2256. id: 8,
  2257. type: 0,
  2258. age: 2,
  2259. name: "stick",
  2260. desc: "great for gathering but very weak",
  2261. src: "stick_1",
  2262. length: 140,
  2263. width: 140,
  2264. xOff: 3,
  2265. yOff: 24,
  2266. dmg: 1,
  2267. spdMult: 1,
  2268. range: 70,
  2269. gather: 7,
  2270. speed: 400
  2271. }, {
  2272. id: 9,
  2273. type: 1,
  2274. age: 6,
  2275. name: "hunting bow",
  2276. desc: "bow used for ranged combat and hunting",
  2277. src: "bow_1",
  2278. req: ["wood", 4],
  2279. length: 120,
  2280. width: 120,
  2281. xOff: -6,
  2282. yOff: 0,
  2283. Pdmg: 25,
  2284. projectile: 0,
  2285. spdMult: 0.75,
  2286. speed: 600
  2287. }, {
  2288. id: 10,
  2289. type: 1,
  2290. age: 6,
  2291. name: "great hammer",
  2292. desc: "hammer used for destroying structures",
  2293. src: "great_hammer_1",
  2294. length: 140,
  2295. width: 140,
  2296. xOff: -9,
  2297. yOff: 25,
  2298. dmg: 10,
  2299. Pdmg: 10,
  2300. spdMult: 0.88,
  2301. range: 75,
  2302. sDmg: 7.5,
  2303. gather: 1,
  2304. speed: 400
  2305. }, {
  2306. id: 11,
  2307. type: 1,
  2308. age: 6,
  2309. name: "wooden shield",
  2310. desc: "blocks projectiles and reduces melee damage",
  2311. src: "shield_1",
  2312. length: 120,
  2313. width: 120,
  2314. shield: 0.2,
  2315. xOff: 6,
  2316. yOff: 0,
  2317. Pdmg: 0,
  2318. spdMult: 0.7
  2319. }, {
  2320. id: 12,
  2321. type: 1,
  2322. age: 8,
  2323. pre: 9,
  2324. name: "crossbow",
  2325. desc: "deals more damage and has greater range",
  2326. src: "crossbow_1",
  2327. req: ["wood", 5],
  2328. aboveHand: true,
  2329. armS: 0.75,
  2330. length: 120,
  2331. width: 120,
  2332. xOff: -4,
  2333. yOff: 0,
  2334. Pdmg: 35,
  2335. projectile: 2,
  2336. spdMult: 0.7,
  2337. speed: 700
  2338. }, {
  2339. id: 13,
  2340. type: 1,
  2341. age: 9,
  2342. pre: 12,
  2343. name: "repeater crossbow",
  2344. desc: "high firerate crossbow with reduced damage",
  2345. src: "crossbow_2",
  2346. req: ["wood", 10],
  2347. aboveHand: true,
  2348. armS: 0.75,
  2349. length: 120,
  2350. width: 120,
  2351. xOff: -4,
  2352. yOff: 0,
  2353. Pdmg: 30,
  2354. projectile: 3,
  2355. spdMult: 0.7,
  2356. speed: 230
  2357. }, {
  2358. id: 14,
  2359. type: 1,
  2360. age: 6,
  2361. name: "mc grabby",
  2362. desc: "steals resources from enemies",
  2363. src: "grab_1",
  2364. length: 130,
  2365. width: 210,
  2366. xOff: -8,
  2367. yOff: 53,
  2368. dmg: 0,
  2369. Pdmg: 0,
  2370. steal: 250,
  2371. knock: 0.2,
  2372. spdMult: 1.05,
  2373. range: 125,
  2374. gather: 0,
  2375. speed: 700
  2376. }, {
  2377. id: 15,
  2378. type: 1,
  2379. age: 9,
  2380. pre: 12,
  2381. name: "musket",
  2382. desc: "slow firerate but high damage and range",
  2383. src: "musket_1",
  2384. req: ["stone", 10],
  2385. aboveHand: true,
  2386. rec: 0.35,
  2387. armS: 0.6,
  2388. hndS: 0.3,
  2389. hndD: 1.6,
  2390. length: 205,
  2391. width: 205,
  2392. xOff: 25,
  2393. yOff: 0,
  2394. Pdmg: 50,
  2395. projectile: 5,
  2396. hideProjectile: true,
  2397. spdMult: 0.6,
  2398. speed: 1500
  2399. }];
  2400. // ITEMS:
  2401. this.list = [{
  2402. group: this.groups[0],
  2403. name: "apple",
  2404. desc: "restores 20 health when consumed",
  2405. req: ["food", 10],
  2406. consume: function(doer) {
  2407. return doer.changeHealth(20, doer);
  2408. },
  2409. scale: 22,
  2410. holdOffset: 15,
  2411. healing: 20,
  2412. itemID: 0,
  2413. itemAID: 16,
  2414. }, {
  2415. age: 3,
  2416. group: this.groups[0],
  2417. name: "cookie",
  2418. desc: "restores 40 health when consumed",
  2419. req: ["food", 15],
  2420. consume: function(doer) {
  2421. return doer.changeHealth(40, doer);
  2422. },
  2423. scale: 27,
  2424. holdOffset: 15,
  2425. healing: 40,
  2426. itemID: 1,
  2427. itemAID: 17,
  2428. }, {
  2429. age: 7,
  2430. group: this.groups[0],
  2431. name: "cheese",
  2432. desc: "restores 30 health and another 50 over 5 seconds",
  2433. req: ["food", 25],
  2434. consume: function(doer) {
  2435. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2436. doer.dmgOverTime.dmg = -10;
  2437. doer.dmgOverTime.doer = doer;
  2438. doer.dmgOverTime.time = 5;
  2439. return true;
  2440. }
  2441. return false;
  2442. },
  2443. scale: 27,
  2444. holdOffset: 15,
  2445. healing: 30,
  2446. itemID: 2,
  2447. itemAID: 18,
  2448. }, {
  2449. group: this.groups[1],
  2450. name: "wood wall",
  2451. desc: "provides protection for your village",
  2452. req: ["wood", 10],
  2453. projDmg: true,
  2454. health: 380,
  2455. scale: 50,
  2456. holdOffset: 20,
  2457. placeOffset: -5,
  2458. itemID: 3,
  2459. itemAID: 19,
  2460. }, {
  2461. age: 3,
  2462. group: this.groups[1],
  2463. name: "stone wall",
  2464. desc: "provides improved protection for your village",
  2465. req: ["stone", 25],
  2466. health: 900,
  2467. scale: 50,
  2468. holdOffset: 20,
  2469. placeOffset: -5,
  2470. itemID: 4,
  2471. itemAID: 20,
  2472. }, {
  2473. age: 7,
  2474. group: this.groups[1],
  2475. name: "castle wall",
  2476. desc: "provides powerful protection for your village",
  2477. req: ["stone", 35],
  2478. health: 1500,
  2479. scale: 52,
  2480. holdOffset: 20,
  2481. placeOffset: -5,
  2482. itemID: 5,
  2483. itemAID: 21,
  2484. }, {
  2485. group: this.groups[2],
  2486. name: "spikes",
  2487. desc: "damages enemies when they touch them",
  2488. req: ["wood", 20, "stone", 5],
  2489. health: 400,
  2490. dmg: 20,
  2491. scale: 49,
  2492. spritePadding: -23,
  2493. holdOffset: 8,
  2494. placeOffset: -5,
  2495. itemID: 6,
  2496. itemAID: 22,
  2497. }, {
  2498. age: 5,
  2499. group: this.groups[2],
  2500. name: "greater spikes",
  2501. desc: "damages enemies when they touch them",
  2502. req: ["wood", 30, "stone", 10],
  2503. health: 500,
  2504. dmg: 35,
  2505. scale: 52,
  2506. spritePadding: -23,
  2507. holdOffset: 8,
  2508. placeOffset: -5,
  2509. itemID: 7,
  2510. itemAID: 23,
  2511. }, {
  2512. age: 9,
  2513. group: this.groups[2],
  2514. name: "poison spikes",
  2515. desc: "poisons enemies when they touch them",
  2516. req: ["wood", 35, "stone", 15],
  2517. health: 600,
  2518. dmg: 30,
  2519. pDmg: 5,
  2520. scale: 52,
  2521. spritePadding: -23,
  2522. holdOffset: 8,
  2523. placeOffset: -5,
  2524. itemID: 8,
  2525. itemAID: 24,
  2526. }, {
  2527. age: 9,
  2528. group: this.groups[2],
  2529. name: "spinning spikes",
  2530. desc: "damages enemies when they touch them",
  2531. req: ["wood", 30, "stone", 20],
  2532. health: 500,
  2533. dmg: 45,
  2534. turnSpeed: 0.003,
  2535. scale: 52,
  2536. spritePadding: -23,
  2537. holdOffset: 8,
  2538. placeOffset: -5,
  2539. itemID: 9,
  2540. itemAID: 25,
  2541. }, {
  2542. group: this.groups[3],
  2543. name: "windmill",
  2544. desc: "generates gold over time",
  2545. req: ["wood", 50, "stone", 10],
  2546. health: 400,
  2547. pps: 1,
  2548. turnSpeed: 0.0016,
  2549. spritePadding: 25,
  2550. iconLineMult: 12,
  2551. scale: 45,
  2552. holdOffset: 20,
  2553. placeOffset: 5,
  2554. itemID: 10,
  2555. itemAID: 26,
  2556. }, {
  2557. age: 5,
  2558. group: this.groups[3],
  2559. name: "faster windmill",
  2560. desc: "generates more gold over time",
  2561. req: ["wood", 60, "stone", 20],
  2562. health: 500,
  2563. pps: 1.5,
  2564. turnSpeed: 0.0025,
  2565. spritePadding: 25,
  2566. iconLineMult: 12,
  2567. scale: 47,
  2568. holdOffset: 20,
  2569. placeOffset: 5,
  2570. itemID: 11,
  2571. itemAID: 27,
  2572. }, {
  2573. age: 8,
  2574. group: this.groups[3],
  2575. name: "power mill",
  2576. desc: "generates more gold over time",
  2577. req: ["wood", 100, "stone", 50],
  2578. health: 800,
  2579. pps: 2,
  2580. turnSpeed: 0.005,
  2581. spritePadding: 25,
  2582. iconLineMult: 12,
  2583. scale: 47,
  2584. holdOffset: 20,
  2585. placeOffset: 5,
  2586. itemID: 12,
  2587. itemAID: 28,
  2588. }, {
  2589. age: 5,
  2590. group: this.groups[4],
  2591. type: 2,
  2592. name: "mine",
  2593. desc: "allows you to mine stone",
  2594. req: ["wood", 20, "stone", 100],
  2595. iconLineMult: 12,
  2596. scale: 65,
  2597. holdOffset: 20,
  2598. placeOffset: 0,
  2599. itemID: 13,
  2600. itemAID: 29,
  2601. }, {
  2602. age: 5,
  2603. group: this.groups[11],
  2604. type: 0,
  2605. name: "sapling",
  2606. desc: "allows you to farm wood",
  2607. req: ["wood", 150],
  2608. iconLineMult: 12,
  2609. colDiv: 0.5,
  2610. scale: 110,
  2611. holdOffset: 50,
  2612. placeOffset: -15,
  2613. itemID: 14,
  2614. itemAID: 30,
  2615. }, {
  2616. age: 4,
  2617. group: this.groups[5],
  2618. name: "pit trap",
  2619. desc: "pit that traps enemies if they walk over it",
  2620. req: ["wood", 30, "stone", 30],
  2621. trap: true,
  2622. ignoreCollision: true,
  2623. hideFromEnemy: true,
  2624. health: 500,
  2625. colDiv: 0.2,
  2626. scale: 50,
  2627. holdOffset: 20,
  2628. placeOffset: -5,
  2629. alpha: 0.6,
  2630. itemID: 15,
  2631. itemAID: 31,
  2632. }, {
  2633. age: 4,
  2634. group: this.groups[6],
  2635. name: "boost pad",
  2636. desc: "provides boost when stepped on",
  2637. req: ["stone", 20, "wood", 5],
  2638. ignoreCollision: true,
  2639. boostSpeed: 1.5,
  2640. health: 150,
  2641. colDiv: 0.7,
  2642. scale: 45,
  2643. holdOffset: 20,
  2644. placeOffset: -5,
  2645. itemID: 16,
  2646. itemAID: 32,
  2647. }, {
  2648. age: 7,
  2649. group: this.groups[7],
  2650. doUpdate: true,
  2651. name: "turret",
  2652. desc: "defensive structure that shoots at enemies",
  2653. req: ["wood", 200, "stone", 150],
  2654. health: 800,
  2655. projectile: 1,
  2656. shootRange: 700,
  2657. shootRate: 2200,
  2658. scale: 43,
  2659. holdOffset: 20,
  2660. placeOffset: -5,
  2661. itemID: 17,
  2662. itemAID: 33,
  2663. }, {
  2664. age: 7,
  2665. group: this.groups[8],
  2666. name: "platform",
  2667. desc: "platform to shoot over walls and cross over water",
  2668. req: ["wood", 20],
  2669. ignoreCollision: true,
  2670. zIndex: 1,
  2671. health: 300,
  2672. scale: 43,
  2673. holdOffset: 20,
  2674. placeOffset: -5,
  2675. itemID: 18,
  2676. itemAID: 34,
  2677. }, {
  2678. age: 7,
  2679. group: this.groups[9],
  2680. name: "healing pad",
  2681. desc: "standing on it will slowly heal you",
  2682. req: ["wood", 30, "food", 10],
  2683. ignoreCollision: true,
  2684. healCol: 15,
  2685. health: 400,
  2686. colDiv: 0.7,
  2687. scale: 45,
  2688. holdOffset: 20,
  2689. placeOffset: -5,
  2690. itemID: 19,
  2691. itemAID: 35,
  2692. }, {
  2693. age: 9,
  2694. group: this.groups[10],
  2695. name: "spawn pad",
  2696. desc: "you will spawn here when you die but it will dissapear",
  2697. req: ["wood", 100, "stone", 100],
  2698. health: 400,
  2699. ignoreCollision: true,
  2700. spawnPoint: true,
  2701. scale: 45,
  2702. holdOffset: 20,
  2703. placeOffset: -5,
  2704. itemID: 20,
  2705. itemAID: 36,
  2706. }, {
  2707. age: 7,
  2708. group: this.groups[12],
  2709. name: "blocker",
  2710. desc: "blocks building in radius",
  2711. req: ["wood", 30, "stone", 25],
  2712. ignoreCollision: true,
  2713. blocker: 300,
  2714. health: 400,
  2715. colDiv: 0.7,
  2716. scale: 45,
  2717. holdOffset: 20,
  2718. placeOffset: -5,
  2719. itemID: 21,
  2720. itemAID: 37,
  2721. }, {
  2722. age: 7,
  2723. group: this.groups[13],
  2724. name: "teleporter",
  2725. desc: "teleports you to a random point on the map",
  2726. req: ["wood", 60, "stone", 60],
  2727. ignoreCollision: true,
  2728. teleport: true,
  2729. health: 200,
  2730. colDiv: 0.7,
  2731. scale: 45,
  2732. holdOffset: 20,
  2733. placeOffset: -5,
  2734. itemID: 22,
  2735. itemAID: 38
  2736. }];
  2737. // CHECK ITEM ID:
  2738. this.checkItem = {
  2739. index: function(id, myItems) {
  2740. return [0, 1, 2].includes(id) ? 0 :
  2741. [3, 4, 5].includes(id) ? 1 :
  2742. [6, 7, 8, 9].includes(id) ? 2 :
  2743. [10, 11, 12].includes(id) ? 3 :
  2744. [13, 14].includes(id) ? 5 :
  2745. [15, 16].includes(id) ? 4 :
  2746. [17, 18, 19, 21, 22].includes(id) ?
  2747. [13, 14].includes(myItems) ? 6 :
  2748. 5 :
  2749. id == 20 ?
  2750. [13, 14].includes(myItems) ? 7 :
  2751. 6 :
  2752. undefined;
  2753. }
  2754. }
  2755. // ASSIGN IDS:
  2756. for (let i = 0; i < this.list.length; ++i) {
  2757. this.list[i].id = i;
  2758. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2759. }
  2760. // TROLOLOLOL:
  2761. if (typeof window !== "undefined") {
  2762. function shuffle(a) {
  2763. for (let i = a.length - 1; i > 0; i--) {
  2764. const j = Math.floor(Math.random() * (i + 1));
  2765. [a[i], a[j]] = [a[j], a[i]];
  2766. }
  2767. return a;
  2768. }
  2769. //shuffle(this.list);
  2770. }
  2771. }
  2772. }
  2773. class Objectmanager {
  2774. constructor(GameObject, gameObjects, UTILS, config, players, server) {
  2775. let mathFloor = Math.floor,
  2776. mathABS = Math.abs,
  2777. mathCOS = Math.cos,
  2778. mathSIN = Math.sin,
  2779. mathPOW = Math.pow,
  2780. mathSQRT = Math.sqrt;
  2781. this.ignoreAdd = false;
  2782. this.hitObj = [];
  2783. // DISABLE OBJ:
  2784. this.disableObj = function(obj) {
  2785. obj.active = false;
  2786. obj.alive = false;
  2787. };
  2788. // ADD NEW:
  2789. let tmpObj;
  2790. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2791. tmpObj = findObjectBySid(sid);
  2792. if (!tmpObj) {
  2793. tmpObj = gameObjects.find((tmp) => !tmp.active);
  2794. if (!tmpObj) {
  2795. tmpObj = new GameObject(sid);
  2796. gameObjects.push(tmpObj);
  2797. }
  2798. }
  2799. if (setSID) {
  2800. tmpObj.sid = sid;
  2801. }
  2802. tmpObj.init(x, y, dir, s, type, data, owner);
  2803. };
  2804. // DISABLE BY SID:
  2805. this.disableBySid = function(sid) {
  2806. let find = findObjectBySid(sid);
  2807. if (find) {
  2808. this.disableObj(find);
  2809. }
  2810. };
  2811. // REMOVE ALL FROM PLAYER:
  2812. this.removeAllItems = function(sid, server) {
  2813. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2814. };
  2815. // CHECK IF PLACABLE:
  2816. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2817. 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)));
  2818. if (cantPlace) return false;
  2819. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  2820. return true;
  2821. };
  2822. }
  2823. }
  2824. class Projectile {
  2825. constructor(players, ais, objectManager, items, config, UTILS, server) {
  2826. // INIT:
  2827. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2828. this.active = true;
  2829. this.tickActive = true;
  2830. this.indx = indx;
  2831. this.x = x;
  2832. this.y = y;
  2833. this.x2 = x;
  2834. this.y2 = y;
  2835. this.dir = dir;
  2836. this.skipMov = true;
  2837. this.speed = spd;
  2838. this.dmg = dmg;
  2839. this.scale = scl;
  2840. this.range = rng;
  2841. this.r2 = rng;
  2842. this.owner = owner;
  2843. };
  2844. // UPDATE:
  2845. this.update = function(delta) {
  2846. if (this.active) {
  2847. let tmpSpeed = this.speed * delta;
  2848. if (!this.skipMov) {
  2849. this.x += tmpSpeed * Math.cos(this.dir);
  2850. this.y += tmpSpeed * Math.sin(this.dir);
  2851. this.range -= tmpSpeed;
  2852. if (this.range <= 0) {
  2853. this.x += this.range * Math.cos(this.dir);
  2854. this.y += this.range * Math.sin(this.dir);
  2855. tmpSpeed = 1;
  2856. this.range = 0;
  2857. this.active = false;
  2858. }
  2859. } else {
  2860. this.skipMov = false;
  2861. }
  2862. }
  2863. };
  2864. this.tickUpdate = function(delta) {
  2865. if (this.tickActive) {
  2866. let tmpSpeed = this.speed * delta;
  2867. if (!this.skipMov) {
  2868. this.x2 += tmpSpeed * Math.cos(this.dir);
  2869. this.y2 += tmpSpeed * Math.sin(this.dir);
  2870. this.r2 -= tmpSpeed;
  2871. if (this.r2 <= 0) {
  2872. this.x2 += this.r2 * Math.cos(this.dir);
  2873. this.y2 += this.r2 * Math.sin(this.dir);
  2874. tmpSpeed = 1;
  2875. this.r2 = 0;
  2876. this.tickActive = false;
  2877. }
  2878. } else {
  2879. this.skipMov = false;
  2880. }
  2881. }
  2882. };
  2883. }
  2884. };
  2885. class Store {
  2886. constructor() {
  2887. // STORE HATS:
  2888. this.hats = [{
  2889. id: 45,
  2890. name: "Shame!",
  2891. dontSell: true,
  2892. price: 0,
  2893. scale: 120,
  2894. desc: "hacks are for winners"
  2895. }, {
  2896. id: 51,
  2897. name: "Moo Cap",
  2898. price: 0,
  2899. scale: 120,
  2900. desc: "coolest mooer around"
  2901. }, {
  2902. id: 50,
  2903. name: "Apple Cap",
  2904. price: 0,
  2905. scale: 120,
  2906. desc: "apple farms remembers"
  2907. }, {
  2908. id: 28,
  2909. name: "Moo Head",
  2910. price: 0,
  2911. scale: 120,
  2912. desc: "no effect"
  2913. }, {
  2914. id: 29,
  2915. name: "Pig Head",
  2916. price: 0,
  2917. scale: 120,
  2918. desc: "no effect"
  2919. }, {
  2920. id: 30,
  2921. name: "Fluff Head",
  2922. price: 0,
  2923. scale: 120,
  2924. desc: "no effect"
  2925. }, {
  2926. id: 36,
  2927. name: "Pandou Head",
  2928. price: 0,
  2929. scale: 120,
  2930. desc: "no effect"
  2931. }, {
  2932. id: 37,
  2933. name: "Bear Head",
  2934. price: 0,
  2935. scale: 120,
  2936. desc: "no effect"
  2937. }, {
  2938. id: 38,
  2939. name: "Monkey Head",
  2940. price: 0,
  2941. scale: 120,
  2942. desc: "no effect"
  2943. }, {
  2944. id: 44,
  2945. name: "Polar Head",
  2946. price: 0,
  2947. scale: 120,
  2948. desc: "no effect"
  2949. }, {
  2950. id: 35,
  2951. name: "Fez Hat",
  2952. price: 0,
  2953. scale: 120,
  2954. desc: "no effect"
  2955. }, {
  2956. id: 42,
  2957. name: "Enigma Hat",
  2958. price: 0,
  2959. scale: 120,
  2960. desc: "join the enigma army"
  2961. }, {
  2962. id: 43,
  2963. name: "Blitz Hat",
  2964. price: 0,
  2965. scale: 120,
  2966. desc: "hey everybody i'm blitz"
  2967. }, {
  2968. id: 49,
  2969. name: "Bob XIII Hat",
  2970. price: 0,
  2971. scale: 120,
  2972. desc: "like and subscribe"
  2973. }, {
  2974. id: 57,
  2975. name: "Pumpkin",
  2976. price: 50,
  2977. scale: 120,
  2978. desc: "Spooooky"
  2979. }, {
  2980. id: 8,
  2981. name: "Bummle Hat",
  2982. price: 100,
  2983. scale: 120,
  2984. desc: "no effect"
  2985. }, {
  2986. id: 2,
  2987. name: "Straw Hat",
  2988. price: 500,
  2989. scale: 120,
  2990. desc: "no effect"
  2991. }, {
  2992. id: 15,
  2993. name: "Winter Cap",
  2994. price: 600,
  2995. scale: 120,
  2996. desc: "allows you to move at normal speed in snow",
  2997. coldM: 1
  2998. }, {
  2999. id: 5,
  3000. name: "Cowboy Hat",
  3001. price: 1000,
  3002. scale: 120,
  3003. desc: "no effect"
  3004. }, {
  3005. id: 4,
  3006. name: "Ranger Hat",
  3007. price: 2000,
  3008. scale: 120,
  3009. desc: "no effect"
  3010. }, {
  3011. id: 18,
  3012. name: "Explorer Hat",
  3013. price: 2000,
  3014. scale: 120,
  3015. desc: "no effect"
  3016. }, {
  3017. id: 31,
  3018. name: "Flipper Hat",
  3019. price: 2500,
  3020. scale: 120,
  3021. desc: "have more control while in water",
  3022. watrImm: true
  3023. }, {
  3024. id: 1,
  3025. name: "Marksman Cap",
  3026. price: 3000,
  3027. scale: 120,
  3028. desc: "increases arrow speed and range",
  3029. aMlt: 1.3
  3030. }, {
  3031. id: 10,
  3032. name: "Bush Gear",
  3033. price: 3000,
  3034. scale: 160,
  3035. desc: "allows you to disguise yourself as a bush"
  3036. }, {
  3037. id: 48,
  3038. name: "Halo",
  3039. price: 3000,
  3040. scale: 120,
  3041. desc: "no effect"
  3042. }, {
  3043. id: 6,
  3044. name: "Soldier Helmet",
  3045. price: 4000,
  3046. scale: 120,
  3047. desc: "reduces damage taken but slows movement",
  3048. spdMult: 0.94,
  3049. dmgMult: 0.75
  3050. }, {
  3051. id: 23,
  3052. name: "Anti Venom Gear",
  3053. price: 4000,
  3054. scale: 120,
  3055. desc: "makes you immune to poison",
  3056. poisonRes: 1
  3057. }, {
  3058. id: 13,
  3059. name: "Medic Gear",
  3060. price: 5000,
  3061. scale: 110,
  3062. desc: "slowly regenerates health over time",
  3063. healthRegen: 3
  3064. }, {
  3065. id: 9,
  3066. name: "Miners Helmet",
  3067. price: 5000,
  3068. scale: 120,
  3069. desc: "earn 1 extra gold per resource",
  3070. extraGold: 1
  3071. }, {
  3072. id: 32,
  3073. name: "Musketeer Hat",
  3074. price: 5000,
  3075. scale: 120,
  3076. desc: "reduces cost of projectiles",
  3077. projCost: 0.5
  3078. }, {
  3079. id: 7,
  3080. name: "Bull Helmet",
  3081. price: 6000,
  3082. scale: 120,
  3083. desc: "increases damage done but drains health",
  3084. healthRegen: -5,
  3085. dmgMultO: 1.5,
  3086. spdMult: 0.96
  3087. }, {
  3088. id: 22,
  3089. name: "Emp Helmet",
  3090. price: 6000,
  3091. scale: 120,
  3092. desc: "turrets won't attack but you move slower",
  3093. antiTurret: 1,
  3094. spdMult: 0.7
  3095. }, {
  3096. id: 12,
  3097. name: "Booster Hat",
  3098. price: 6000,
  3099. scale: 120,
  3100. desc: "increases your movement speed",
  3101. spdMult: 1.16
  3102. }, {
  3103. id: 26,
  3104. name: "Barbarian Armor",
  3105. price: 8000,
  3106. scale: 120,
  3107. desc: "knocks back enemies that attack you",
  3108. dmgK: 0.6
  3109. }, {
  3110. id: 21,
  3111. name: "Plague Mask",
  3112. price: 10000,
  3113. scale: 120,
  3114. desc: "melee attacks deal poison damage",
  3115. poisonDmg: 5,
  3116. poisonTime: 6
  3117. }, {
  3118. id: 46,
  3119. name: "Bull Mask",
  3120. price: 10000,
  3121. scale: 120,
  3122. desc: "bulls won't target you unless you attack them",
  3123. bullRepel: 1
  3124. }, {
  3125. id: 14,
  3126. name: "Windmill Hat",
  3127. topSprite: true,
  3128. price: 10000,
  3129. scale: 120,
  3130. desc: "generates points while worn",
  3131. pps: 1.5
  3132. }, {
  3133. id: 11,
  3134. name: "Spike Gear",
  3135. topSprite: true,
  3136. price: 10000,
  3137. scale: 120,
  3138. desc: "deal damage to players that damage you",
  3139. dmg: 0.45
  3140. }, {
  3141. id: 53,
  3142. name: "Turret Gear",
  3143. topSprite: true,
  3144. price: 10000,
  3145. scale: 120,
  3146. desc: "you become a walking turret",
  3147. turret: {
  3148. proj: 1,
  3149. range: 700,
  3150. rate: 2500
  3151. },
  3152. spdMult: 0.7
  3153. }, {
  3154. id: 20,
  3155. name: "Samurai Armor",
  3156. price: 12000,
  3157. scale: 120,
  3158. desc: "increased attack speed and fire rate",
  3159. atkSpd: 0.78
  3160. }, {
  3161. id: 58,
  3162. name: "Dark Knight",
  3163. price: 12000,
  3164. scale: 120,
  3165. desc: "restores health when you deal damage",
  3166. healD: 0.4
  3167. }, {
  3168. id: 27,
  3169. name: "Scavenger Gear",
  3170. price: 15000,
  3171. scale: 120,
  3172. desc: "earn double points for each kill",
  3173. kScrM: 2
  3174. }, {
  3175. id: 40,
  3176. name: "Tank Gear",
  3177. price: 15000,
  3178. scale: 120,
  3179. desc: "increased damage to buildings but slower movement",
  3180. spdMult: 0.3,
  3181. bDmg: 3.3
  3182. }, {
  3183. id: 52,
  3184. name: "Thief Gear",
  3185. price: 15000,
  3186. scale: 120,
  3187. desc: "steal half of a players gold when you kill them",
  3188. goldSteal: 0.5
  3189. }, {
  3190. id: 55,
  3191. name: "Bloodthirster",
  3192. price: 20000,
  3193. scale: 120,
  3194. desc: "Restore Health when dealing damage. And increased damage",
  3195. healD: 0.25,
  3196. dmgMultO: 1.2,
  3197. }, {
  3198. id: 56,
  3199. name: "Assassin Gear",
  3200. price: 20000,
  3201. scale: 120,
  3202. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3203. noEat: true,
  3204. spdMult: 1.1,
  3205. invisTimer: 1000
  3206. }];
  3207. // STORE ACCESSORIES:
  3208. this.accessories = [{
  3209. id: 12,
  3210. name: "Snowball",
  3211. price: 1000,
  3212. scale: 105,
  3213. xOff: 18,
  3214. desc: "no effect"
  3215. }, {
  3216. id: 9,
  3217. name: "Tree Cape",
  3218. price: 1000,
  3219. scale: 90,
  3220. desc: "no effect"
  3221. }, {
  3222. id: 10,
  3223. name: "Stone Cape",
  3224. price: 1000,
  3225. scale: 90,
  3226. desc: "no effect"
  3227. }, {
  3228. id: 3,
  3229. name: "Cookie Cape",
  3230. price: 1500,
  3231. scale: 90,
  3232. desc: "no effect"
  3233. }, {
  3234. id: 8,
  3235. name: "Cow Cape",
  3236. price: 2000,
  3237. scale: 90,
  3238. desc: "no effect"
  3239. }, {
  3240. id: 11,
  3241. name: "Monkey Tail",
  3242. price: 2000,
  3243. scale: 97,
  3244. xOff: 25,
  3245. desc: "Super speed but reduced damage",
  3246. spdMult: 1.35,
  3247. dmgMultO: 0.2
  3248. }, {
  3249. id: 17,
  3250. name: "Apple Basket",
  3251. price: 3000,
  3252. scale: 80,
  3253. xOff: 12,
  3254. desc: "slowly regenerates health over time",
  3255. healthRegen: 1
  3256. }, {
  3257. id: 6,
  3258. name: "Winter Cape",
  3259. price: 3000,
  3260. scale: 90,
  3261. desc: "no effect"
  3262. }, {
  3263. id: 4,
  3264. name: "Skull Cape",
  3265. price: 4000,
  3266. scale: 90,
  3267. desc: "no effect"
  3268. }, {
  3269. id: 5,
  3270. name: "Dash Cape",
  3271. price: 5000,
  3272. scale: 90,
  3273. desc: "no effect"
  3274. }, {
  3275. id: 2,
  3276. name: "Dragon Cape",
  3277. price: 6000,
  3278. scale: 90,
  3279. desc: "no effect"
  3280. }, {
  3281. id: 1,
  3282. name: "Super Cape",
  3283. price: 8000,
  3284. scale: 90,
  3285. desc: "no effect"
  3286. }, {
  3287. id: 7,
  3288. name: "Troll Cape",
  3289. price: 8000,
  3290. scale: 90,
  3291. desc: "no effect"
  3292. }, {
  3293. id: 14,
  3294. name: "Thorns",
  3295. price: 10000,
  3296. scale: 115,
  3297. xOff: 20,
  3298. desc: "no effect"
  3299. }, {
  3300. id: 15,
  3301. name: "Blockades",
  3302. price: 10000,
  3303. scale: 95,
  3304. xOff: 15,
  3305. desc: "no effect"
  3306. }, {
  3307. id: 20,
  3308. name: "Devils Tail",
  3309. price: 10000,
  3310. scale: 95,
  3311. xOff: 20,
  3312. desc: "no effect"
  3313. }, {
  3314. id: 16,
  3315. name: "Sawblade",
  3316. price: 12000,
  3317. scale: 90,
  3318. spin: true,
  3319. xOff: 0,
  3320. desc: "deal damage to players that damage you",
  3321. dmg: 0.15
  3322. }, {
  3323. id: 13,
  3324. name: "Angel Wings",
  3325. price: 15000,
  3326. scale: 138,
  3327. xOff: 22,
  3328. desc: "slowly regenerates health over time",
  3329. healthRegen: 3
  3330. }, {
  3331. id: 19,
  3332. name: "Shadow Wings",
  3333. price: 15000,
  3334. scale: 138,
  3335. xOff: 22,
  3336. desc: "increased movement speed",
  3337. spdMult: 1.1
  3338. }, {
  3339. id: 18,
  3340. name: "Blood Wings",
  3341. price: 20000,
  3342. scale: 178,
  3343. xOff: 26,
  3344. desc: "restores health when you deal damage",
  3345. healD: 0.2
  3346. }, {
  3347. id: 21,
  3348. name: "Corrupt X Wings",
  3349. price: 20000,
  3350. scale: 178,
  3351. xOff: 26,
  3352. desc: "deal damage to players that damage you",
  3353. dmg: 0.25
  3354. }];
  3355. }
  3356. };
  3357. class ProjectileManager {
  3358. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3359. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3360. let tmpData = items.projectiles[indx];
  3361. let tmpProj;
  3362. for (let i = 0; i < projectiles.length; ++i) {
  3363. if (!projectiles[i].active) {
  3364. tmpProj = projectiles[i];
  3365. break;
  3366. }
  3367. }
  3368. if (!tmpProj) {
  3369. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3370. tmpProj.sid = projectiles.length;
  3371. projectiles.push(tmpProj);
  3372. }
  3373. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3374. tmpProj.ignoreObj = ignoreObj;
  3375. tmpProj.layer = layer || tmpData.layer;
  3376. tmpProj.inWindow = inWindow;
  3377. tmpProj.src = tmpData.src;
  3378. return tmpProj;
  3379. };
  3380. }
  3381. };
  3382. class AiManager {
  3383. // AI MANAGER:
  3384. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3385. // AI TYPES:
  3386. this.aiTypes = [{
  3387. id: 0,
  3388. src: "cow_1",
  3389. killScore: 150,
  3390. health: 500,
  3391. weightM: 0.8,
  3392. speed: 0.00095,
  3393. turnSpeed: 0.001,
  3394. scale: 72,
  3395. drop: ["food", 50]
  3396. }, {
  3397. id: 1,
  3398. src: "pig_1",
  3399. killScore: 200,
  3400. health: 800,
  3401. weightM: 0.6,
  3402. speed: 0.00085,
  3403. turnSpeed: 0.001,
  3404. scale: 72,
  3405. drop: ["food", 80]
  3406. }, {
  3407. id: 2,
  3408. name: "Bull",
  3409. src: "bull_2",
  3410. hostile: true,
  3411. dmg: 20,
  3412. killScore: 1000,
  3413. health: 1800,
  3414. weightM: 0.5,
  3415. speed: 0.00094,
  3416. turnSpeed: 0.00074,
  3417. scale: 78,
  3418. viewRange: 800,
  3419. chargePlayer: true,
  3420. drop: ["food", 100]
  3421. }, {
  3422. id: 3,
  3423. name: "Bully",
  3424. src: "bull_1",
  3425. hostile: true,
  3426. dmg: 20,
  3427. killScore: 2000,
  3428. health: 2800,
  3429. weightM: 0.45,
  3430. speed: 0.001,
  3431. turnSpeed: 0.0008,
  3432. scale: 90,
  3433. viewRange: 900,
  3434. chargePlayer: true,
  3435. drop: ["food", 400]
  3436. }, {
  3437. id: 4,
  3438. name: "Wolf",
  3439. src: "wolf_1",
  3440. hostile: true,
  3441. dmg: 8,
  3442. killScore: 500,
  3443. health: 300,
  3444. weightM: 0.45,
  3445. speed: 0.001,
  3446. turnSpeed: 0.002,
  3447. scale: 84,
  3448. viewRange: 800,
  3449. chargePlayer: true,
  3450. drop: ["food", 200]
  3451. }, {
  3452. id: 5,
  3453. name: "Quack",
  3454. src: "chicken_1",
  3455. dmg: 8,
  3456. killScore: 2000,
  3457. noTrap: true,
  3458. health: 300,
  3459. weightM: 0.2,
  3460. speed: 0.0018,
  3461. turnSpeed: 0.006,
  3462. scale: 70,
  3463. drop: ["food", 100]
  3464. }, {
  3465. id: 6,
  3466. name: "MOOSTAFA",
  3467. nameScale: 50,
  3468. src: "enemy",
  3469. hostile: true,
  3470. dontRun: true,
  3471. fixedSpawn: true,
  3472. spawnDelay: 60000,
  3473. noTrap: true,
  3474. colDmg: 100,
  3475. dmg: 40,
  3476. killScore: 8000,
  3477. health: 18000,
  3478. weightM: 0.4,
  3479. speed: 0.0007,
  3480. turnSpeed: 0.01,
  3481. scale: 80,
  3482. spriteMlt: 1.8,
  3483. leapForce: 0.9,
  3484. viewRange: 1000,
  3485. hitRange: 210,
  3486. hitDelay: 1000,
  3487. chargePlayer: true,
  3488. drop: ["food", 100]
  3489. }, {
  3490. id: 7,
  3491. name: "Treasure",
  3492. hostile: true,
  3493. nameScale: 35,
  3494. src: "crate_1",
  3495. fixedSpawn: true,
  3496. spawnDelay: 120000,
  3497. colDmg: 200,
  3498. killScore: 5000,
  3499. health: 20000,
  3500. weightM: 0.1,
  3501. speed: 0.0,
  3502. turnSpeed: 0.0,
  3503. scale: 70,
  3504. spriteMlt: 1.0
  3505. }, {
  3506. id: 8,
  3507. name: "MOOFIE",
  3508. src: "wolf_2",
  3509. hostile: true,
  3510. fixedSpawn: true,
  3511. dontRun: true,
  3512. hitScare: 4,
  3513. spawnDelay: 30000,
  3514. noTrap: true,
  3515. nameScale: 35,
  3516. dmg: 10,
  3517. colDmg: 100,
  3518. killScore: 3000,
  3519. health: 7000,
  3520. weightM: 0.45,
  3521. speed: 0.0015,
  3522. turnSpeed: 0.002,
  3523. scale: 90,
  3524. viewRange: 800,
  3525. chargePlayer: true,
  3526. drop: ["food", 1000]
  3527. }];
  3528. // SPAWN AI:
  3529. this.spawn = function(x, y, dir, index) {
  3530. let tmpObj = ais.find((tmp) => !tmp.active);
  3531. if (!tmpObj) {
  3532. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3533. ais.push(tmpObj);
  3534. }
  3535. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3536. return tmpObj;
  3537. };
  3538. }
  3539. };
  3540. class AI {
  3541. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3542. this.sid = sid;
  3543. this.isAI = true;
  3544. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3545. // INIT:
  3546. this.init = function(x, y, dir, index, data) {
  3547. this.x = x;
  3548. this.y = y;
  3549. this.startX = data.fixedSpawn ? x : null;
  3550. this.startY = data.fixedSpawn ? y : null;
  3551. this.xVel = 0;
  3552. this.yVel = 0;
  3553. this.zIndex = 0;
  3554. this.dir = dir;
  3555. this.dirPlus = 0;
  3556. this.index = index;
  3557. this.src = data.src;
  3558. if (data.name) this.name = data.name;
  3559. this.weightM = data.weightM;
  3560. this.speed = data.speed;
  3561. this.killScore = data.killScore;
  3562. this.turnSpeed = data.turnSpeed;
  3563. this.scale = data.scale;
  3564. this.maxHealth = data.health;
  3565. this.leapForce = data.leapForce;
  3566. this.health = this.maxHealth;
  3567. this.chargePlayer = data.chargePlayer;
  3568. this.viewRange = data.viewRange;
  3569. this.drop = data.drop;
  3570. this.dmg = data.dmg;
  3571. this.hostile = data.hostile;
  3572. this.dontRun = data.dontRun;
  3573. this.hitRange = data.hitRange;
  3574. this.hitDelay = data.hitDelay;
  3575. this.hitScare = data.hitScare;
  3576. this.spriteMlt = data.spriteMlt;
  3577. this.nameScale = data.nameScale;
  3578. this.colDmg = data.colDmg;
  3579. this.noTrap = data.noTrap;
  3580. this.spawnDelay = data.spawnDelay;
  3581. this.hitWait = 0;
  3582. this.waitCount = 1000;
  3583. this.moveCount = 0;
  3584. this.targetDir = 0;
  3585. this.active = true;
  3586. this.alive = true;
  3587. this.runFrom = null;
  3588. this.chargeTarget = null;
  3589. this.dmgOverTime = {};
  3590. };
  3591. let tmpRatio = 0;
  3592. let animIndex = 0;
  3593. this.animate = function(delta) {
  3594. if (this.animTime > 0) {
  3595. this.animTime -= delta;
  3596. if (this.animTime <= 0) {
  3597. this.animTime = 0;
  3598. this.dirPlus = 0;
  3599. tmpRatio = 0;
  3600. animIndex = 0;
  3601. } else {
  3602. if (animIndex == 0) {
  3603. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3604. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3605. if (tmpRatio >= 1) {
  3606. tmpRatio = 1;
  3607. animIndex = 1;
  3608. }
  3609. } else {
  3610. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3611. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3612. }
  3613. }
  3614. }
  3615. };
  3616. // ANIMATION:
  3617. this.startAnim = function() {
  3618. this.animTime = this.animSpeed = 600;
  3619. this.targetAngle = Math.PI * 0.8;
  3620. tmpRatio = 0;
  3621. animIndex = 0;
  3622. };
  3623. };
  3624. };
  3625. class addCh {
  3626. constructor(x, y, chat, tmpObj) {
  3627. this.x = x;
  3628. this.y = y;
  3629. this.alpha = 0;
  3630. this.active = true;
  3631. this.alive = false;
  3632. this.chat = chat;
  3633. this.owner = tmpObj;
  3634. };
  3635. };
  3636. class DeadPlayer {
  3637. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3638. this.x = x;
  3639. this.y = y;
  3640. this.lastDir = dir;
  3641. this.dir = dir + Math.PI;
  3642. this.buildIndex = buildIndex;
  3643. this.weaponIndex = weaponIndex;
  3644. this.weaponVariant = weaponVariant;
  3645. this.skinColor = skinColor;
  3646. this.scale = scale;
  3647. this.visScale = 0;
  3648. this.name = name;
  3649. this.alpha = 1;
  3650. this.active = true;
  3651. this.animate = function(delta) {
  3652. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3653. if (d2 > 0.01) {
  3654. this.dir += d2 / 20;
  3655. } else {
  3656. this.dir = this.lastDir;
  3657. }
  3658. if (this.visScale < this.scale) {
  3659. this.visScale += delta / (this.scale / 2);
  3660. if (this.visScale >= this.scale) {
  3661. this.visScale = this.scale;
  3662. }
  3663. }
  3664. this.alpha -= delta / 30000;
  3665. if (this.alpha <= 0) {
  3666. this.alpha = 0;
  3667. this.active = false;
  3668. }
  3669. }
  3670. }
  3671. };
  3672. class Player {
  3673. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3674. this.id = id;
  3675. this.sid = sid;
  3676. this.tmpScore = 0;
  3677. this.team = null;
  3678. this.latestSkin = 0;
  3679. this.oldSkinIndex = 0;
  3680. this.skinIndex = 0;
  3681. this.latestTail = 0;
  3682. this.oldTailIndex = 0;
  3683. this.tailIndex = 0;
  3684. this.hitTime = 0;
  3685. this.lastHit = 0;
  3686. this.tails = {};
  3687. for (let i = 0; i < accessories.length; ++i) {
  3688. if (accessories[i].price <= 0)
  3689. this.tails[accessories[i].id] = 1;
  3690. }
  3691. this.skins = {};
  3692. for (let i = 0; i < hats.length; ++i) {
  3693. if (hats[i].price <= 0)
  3694. this.skins[hats[i].id] = 1;
  3695. }
  3696. this.points = 0;
  3697. this.dt = 0;
  3698. this.hidden = false;
  3699. this.itemCounts = {};
  3700. this.isPlayer = true;
  3701. this.pps = 0;
  3702. this.moveDir = undefined;
  3703. this.skinRot = 0;
  3704. this.lastPing = 0;
  3705. this.iconIndex = 0;
  3706. this.skinColor = 0;
  3707. this.dist2 = 0;
  3708. this.aim2 = 0;
  3709. this.maxSpeed = 1;
  3710. this.chat = {
  3711. message: null,
  3712. count: 0
  3713. };
  3714. this.backupNobull = true;
  3715. this.circle = false;
  3716. this.circleRad = 200;
  3717. this.circleRadSpd = 0.1;
  3718. this.cAngle = 0;
  3719. // SPAWN:
  3720. this.spawn = function(moofoll) {
  3721. this.attacked = false;
  3722. this.death = false;
  3723. this.spinDir = 0;
  3724. this.sync = false;
  3725. this.antiBull = 0;
  3726. this.bullTimer = 0;
  3727. this.poisonTimer = 0;
  3728. this.active = true;
  3729. this.alive = true;
  3730. this.lockMove = false;
  3731. this.lockDir = false;
  3732. this.minimapCounter = 0;
  3733. this.chatCountdown = 0;
  3734. this.shameCount = 0;
  3735. this.shameTimer = 0;
  3736. this.sentTo = {};
  3737. this.gathering = 0;
  3738. this.gatherIndex = 0;
  3739. this.shooting = {};
  3740. this.shootIndex = 9;
  3741. this.autoGather = 0;
  3742. this.animTime = 0;
  3743. this.animSpeed = 0;
  3744. this.mouseState = 0;
  3745. this.buildIndex = -1;
  3746. this.weaponIndex = 0;
  3747. this.weaponCode = 0;
  3748. this.weaponVariant = 0;
  3749. this.primaryIndex = undefined;
  3750. this.secondaryIndex = undefined;
  3751. this.dmgOverTime = {};
  3752. this.noMovTimer = 0;
  3753. this.maxXP = 300;
  3754. this.XP = 0;
  3755. this.age = 1;
  3756. this.kills = 0;
  3757. this.upgrAge = 2;
  3758. this.upgradePoints = 0;
  3759. this.x = 0;
  3760. this.y = 0;
  3761. this.oldXY = {
  3762. x: 0,
  3763. y: 0
  3764. };
  3765. this.zIndex = 0;
  3766. this.xVel = 0;
  3767. this.yVel = 0;
  3768. this.slowMult = 1;
  3769. this.dir = 0;
  3770. this.dirPlus = 0;
  3771. this.targetDir = 0;
  3772. this.targetAngle = 0;
  3773. this.maxHealth = 100;
  3774. this.health = this.maxHealth;
  3775. this.oldHealth = this.maxHealth;
  3776. this.damaged = 0;
  3777. this.scale = config.playerScale;
  3778. this.speed = config.playerSpeed;
  3779. this.resetMoveDir();
  3780. this.resetResources(moofoll);
  3781. this.items = [0, 3, 6, 10];
  3782. this.weapons = [0];
  3783. this.shootCount = 0;
  3784. this.weaponXP = [];
  3785. this.reloads = {
  3786. 0: 0,
  3787. 1: 0,
  3788. 2: 0,
  3789. 3: 0,
  3790. 4: 0,
  3791. 5: 0,
  3792. 6: 0,
  3793. 7: 0,
  3794. 8: 0,
  3795. 9: 0,
  3796. 10: 0,
  3797. 11: 0,
  3798. 12: 0,
  3799. 13: 0,
  3800. 14: 0,
  3801. 15: 0,
  3802. 53: 0,
  3803. };
  3804. this.bowThreat = {
  3805. 9: 0,
  3806. 12: 0,
  3807. 13: 0,
  3808. 15: 0,
  3809. };
  3810. this.damageThreat = 0;
  3811. this.inTrap = false;
  3812. this.canEmpAnti = false;
  3813. this.empAnti = false;
  3814. this.soldierAnti = false;
  3815. this.poisonTick = 0;
  3816. this.bullTick = 0;
  3817. this.setPoisonTick = false;
  3818. this.setBullTick = false;
  3819. this.antiTimer = 2;
  3820. };
  3821. // RESET MOVE DIR:
  3822. this.resetMoveDir = function() {
  3823. this.moveDir = undefined;
  3824. };
  3825. // RESET RESOURCES:
  3826. this.resetResources = function(moofoll) {
  3827. for (let i = 0; i < config.resourceTypes.length; ++i) {
  3828. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  3829. }
  3830. };
  3831. // ADD ITEM:
  3832. this.getItemType = function(id) {
  3833. let findindx = this.items.findIndex((ids) => ids == id);
  3834. if (findindx != -1) {
  3835. return findindx;
  3836. } else {
  3837. return items.checkItem.index(id, this.items);
  3838. }
  3839. };
  3840. // SET DATA:
  3841. this.setData = function(data) {
  3842. this.id = data[0];
  3843. this.sid = data[1];
  3844. this.name = data[2];
  3845. this.x = data[3];
  3846. this.y = data[4];
  3847. this.dir = data[5];
  3848. this.health = data[6];
  3849. this.maxHealth = data[7];
  3850. this.scale = data[8];
  3851. this.skinColor = data[9];
  3852. };
  3853. // UPDATE POISON TICK:
  3854. this.updateTimer = function() {
  3855. this.bullTimer -= 1;
  3856. if (this.bullTimer <= 0) {
  3857. this.setBullTick = false;
  3858. this.bullTick = game.tick - 1;
  3859. this.bullTimer = config.serverUpdateRate;
  3860. }
  3861. this.poisonTimer -= 1;
  3862. if (this.poisonTimer < 0) {
  3863. this.setPoisonTick = false;
  3864. this.poisonTick = game.tick - 1;
  3865. this.poisonTimer = config.serverUpdateRate;
  3866. plaguemask = true;
  3867. setTimeout(() => {
  3868. plaguemask = false;
  3869. }, 1000);
  3870. } else if(this.poisonTimer >= 0) {
  3871. plaguemask = false;
  3872. }
  3873. };
  3874. this.update = function(delta) {
  3875. if (this.alive) {
  3876. if (this.health != this.healthMov) {
  3877. this.health < this.healthMov ? (this.healthMov -= 2) : (this.healthMov += 2);
  3878. if (Math.abs(this.health - this.healthMov) < 2) this.healthMov = this.health;
  3879. };
  3880. 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);
  3881. }
  3882. if (this.sid == playerSID) {
  3883. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  3884. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  3885. this.cAngle += this.circleRadSpd;
  3886. }
  3887. if (this.active) {
  3888. // MOVE:
  3889. let gear = {
  3890. skin: findID(hats, this.skinIndex),
  3891. tail: findID(accessories, this.tailIndex)
  3892. }
  3893. 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;
  3894. this.maxSpeed = spdMult;
  3895. }
  3896. };
  3897. let tmpRatio = 0;
  3898. let animIndex = 0;
  3899. this.animate = function(delta) {
  3900. if (this.animTime > 0) {
  3901. this.animTime -= delta;
  3902. if (this.animTime <= 0) {
  3903. this.animTime = 0;
  3904. this.dirPlus = 0;
  3905. tmpRatio = 0;
  3906. animIndex = 0;
  3907. } else {
  3908. if (animIndex == 0) {
  3909. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3910. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3911. if (tmpRatio >= 1) {
  3912. tmpRatio = 1;
  3913. animIndex = 1;
  3914. }
  3915. } else {
  3916. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3917. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3918. }
  3919. }
  3920. }
  3921. };
  3922. // GATHER ANIMATION:
  3923. this.startAnim = function(didHit, index) {
  3924. this.animTime = this.animSpeed = items.weapons[index].speed;
  3925. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  3926. tmpRatio = 0;
  3927. animIndex = 0;
  3928. };
  3929. // CAN SEE:
  3930. this.canSee = function(other) {
  3931. if (!other) return false;
  3932. let dx = Math.abs(other.x - this.x) - other.scale;
  3933. let dy = Math.abs(other.y - this.y) - other.scale;
  3934. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  3935. };
  3936. // SHAME SYSTEM:
  3937. this.judgeShame = function() {
  3938. if (this.oldHealth < this.health) {
  3939. if (this.hitTime) {
  3940. let timeSinceHit = Date.now() - this.hitTime;
  3941. this.lastHit = game.tick;
  3942. this.hitTime = 0;
  3943. if (timeSinceHit < 120) {
  3944. this.shameCount++;
  3945. } else {
  3946. this.shameCount = Math.max(0, this.shameCount - 2);
  3947. }
  3948. }
  3949. } else if (this.oldHealth > this.health) {
  3950. this.hitTime = Date.now();
  3951. }
  3952. };
  3953. this.addShameTimer = function() {
  3954. this.shameCount = 0;
  3955. this.shameTimer = 30;
  3956. let interval = setInterval(() => {
  3957. this.shameTimer--;
  3958. if (this.shameTimer <= 0) {
  3959. clearInterval(interval);
  3960. }
  3961. }, 1000);
  3962. };
  3963. // CHECK TEAM:
  3964. this.isTeam = function(tmpObj) {
  3965. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  3966. };
  3967. // FOR THE PLAYER:
  3968. this.findAllianceBySid = function(sid) {
  3969. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  3970. };
  3971. this.checkCanInsta = function(nobull) {
  3972. let totally = 0;
  3973. if (this.alive && inGame) {
  3974. let primary = {
  3975. weapon: this.weapons[0],
  3976. variant: this.primaryVariant,
  3977. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  3978. };
  3979. let secondary = {
  3980. weapon: this.weapons[1],
  3981. variant: this.secondaryVariant,
  3982. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  3983. };
  3984. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  3985. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  3986. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  3987. totally += primary.dmg * pV * bull;
  3988. }
  3989. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  3990. totally += secondary.dmg;
  3991. }
  3992. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  3993. totally += 25;
  3994. }
  3995. totally *= near.skinIndex == 6 ? 0.75 : 1;
  3996. return totally;
  3997. }
  3998. return 0;
  3999. };
  4000. // UPDATE WEAPON RELOAD:
  4001. this.manageReload = function() {
  4002. if (this.shooting[53]) {
  4003. this.shooting[53] = 0;
  4004. this.reloads[53] = (2500 - game.tickRate);
  4005. } else {
  4006. if (this.reloads[53] > 0) {
  4007. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4008. }
  4009. }
  4010. if (this.gathering || this.shooting[1]) {
  4011. if (this.gathering) {
  4012. this.gathering = 0;
  4013. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4014. this.attacked = true;
  4015. }
  4016. if (this.shooting[1]) {
  4017. this.shooting[1] = 0;
  4018. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4019. this.attacked = true;
  4020. }
  4021. } else {
  4022. this.attacked = false;
  4023. if (this.buildIndex < 0) {
  4024. if (this.reloads[this.weaponIndex] > 0) {
  4025. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  4026. if (this == player) {
  4027. if (getEl("weaponGrind").checked) {
  4028. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4029. checkPlace(player.getItemType(22), i);
  4030. }
  4031. }
  4032. }
  4033. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4034. this.antiBull++;
  4035. game.tickBase(() => {
  4036. this.antiBull = 0;
  4037. }, 1);
  4038. }
  4039. }
  4040. }
  4041. }
  4042. };
  4043. // FOR ANTI INSTA:
  4044. this.addDamageThreat = function(tmpObj) {
  4045. let primary = {
  4046. weapon: this.primaryIndex,
  4047. variant: this.primaryVariant
  4048. };
  4049. let secondary = {
  4050. weapon: this.secondaryIndex,
  4051. variant: this.secondaryVariant
  4052. };
  4053. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4054. secondary.dmg = secondary.weapon == undefined ? 50 : 10 ? items.weapons[secondary.weapon].Pdmg : items.weapons[secondary.weapon].Pdmg;
  4055. let bull = 1.5;
  4056. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4057. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4058. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] <= ping*2) {
  4059. this.mostDamageThreat += primary.dmg * pV * bull;
  4060. if (this.reloads[primary.weapon] <= ping) {
  4061. this.damageThreat += primary.dmg * pV * bull;
  4062. }
  4063. }
  4064. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] <= ping * 2) {
  4065. this.mostDamageThreat += secondary.dmg * sV;
  4066. if (this.reloads[secondary.weapon] <= ping) {
  4067. this.damageThreat += secondary.dmg * sV;
  4068. }
  4069. }
  4070. if (this.reloads[53] <= game.tickRate + ping) {
  4071. this.damageThreat += 25;
  4072. this.mostDamageThreat += 25;
  4073. }
  4074. if (traps.checkSpikeTick()) {
  4075. this.damageThreat += secondary.weapon == 10 ? 34 : 26
  4076. this.mostDamageThreat += secondary.weapon == 10 ? 34 : 26
  4077. }
  4078. this.damageThreat *= player.skinIndex == 6 && !clicks.left && !clicks.right && !traps.inTrap ? 0.75 : 1;
  4079. if (!this.isTeam(tmpObj)) {
  4080. if (this.dist2 <= 300) {
  4081. tmpObj.damageThreat += this.damageThreat;
  4082. tmpObj.mostDamageThreat += this.mostDamageThreat
  4083. }
  4084. }
  4085. };
  4086. }
  4087. };
  4088. // SOME CODES:
  4089. function sendUpgrade(index) {
  4090. player.reloads[index] = 0;
  4091. packet("H", index);
  4092. }
  4093. function storeEquip(id, index) {
  4094. packet("c", 0, id, index);
  4095. }
  4096. function storeBuy(id, index) {
  4097. packet("c", 1, id, index);
  4098. }
  4099.  
  4100. function buyEquip(id, index) {
  4101. let nID = player.skins[6] ? 6 : 0;
  4102. if (player.alive && inGame) {
  4103. if (index == 0) {
  4104. if (player.skins[id]) {
  4105. if (player.latestSkin != id) {
  4106. packet("c", 0, id, 0);
  4107. }
  4108. } else {
  4109. if (configs.autoBuyEquip) {
  4110. let find = findID(hats, id);
  4111. if (find) {
  4112. if (player.points >= find.price) {
  4113. //setTimeout(()=>{
  4114. packet("c", 1, id, 0);
  4115. //setTimeout(()=>{
  4116. packet("c", 0, id, 0);
  4117. //}, 120);
  4118. //}, 120);
  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. } else {
  4130. if (player.latestSkin != nID) {
  4131. packet("c", 0, nID, 0);
  4132. }
  4133. }
  4134. }
  4135. } else if (index == 1) {
  4136. if (player.tails[id]) {
  4137. if (player.latestTail != id) {
  4138. packet("c", 0, id, 1);
  4139. }
  4140. } else {
  4141. if (configs.autoBuyEquip) {
  4142. let find = findID(accessories, id);
  4143. if (find) {
  4144. if (player.points >= find.price) {
  4145. packet("c", 1, id, 1);
  4146. // setTimeout(()=>{
  4147. packet("c", 0, id, 1);
  4148. //}, 120);
  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. } else {
  4160. if (player.latestTail != 0) {
  4161. packet("c", 0, 0, 1);
  4162. }
  4163. }
  4164. }
  4165. }
  4166. }
  4167. }
  4168. function selectToBuild(index, wpn) {
  4169. packet("G", index, wpn);
  4170. }
  4171. function selectWeapon(index, isPlace) {
  4172. if (!isPlace) {
  4173. player.weaponCode = index;
  4174. }
  4175. packet("G", index, 1);
  4176. }
  4177. function sendAutoGather() {
  4178. packet("K", 1, 1);
  4179. }
  4180. function sendAtck(id, angle) {
  4181. packet("d", id, angle, 1);
  4182. }
  4183. function toRadian(angle) {
  4184. let fixedAngle = (angle % 360) * (Math.PI / 180);
  4185. return fixedAngle < 0 ? (2 * Math.PI + fixedAngle) : fixedAngle;
  4186. }
  4187. function Hg(e, t){
  4188. buyEquip(e, 0);
  4189. buyEquip(t, 1);
  4190. }
  4191.  
  4192. // PLACER:
  4193. function place(id, rad, rmd) {
  4194. try {
  4195. if (id == undefined) return;
  4196. let item = items.list[player.items[id]];
  4197. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4198. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4199. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4200. 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))) {
  4201. selectToBuild(player.items[id]);
  4202. sendAtck(1, rad);
  4203. selectWeapon(player.weaponCode, 1);
  4204. if (rmd && getEl("renderplace").value == "placeVis") {
  4205. placeVisible.push({
  4206. x: tmpX,
  4207. y: tmpY,
  4208. name: item.name,
  4209. scale: item.scale,
  4210. dir: rad
  4211. });
  4212. game.tickBase(() => {
  4213. placeVisible.shift();
  4214. }, 1)
  4215. }
  4216. if (rmd && getEl("renderplace").value == "outline") {
  4217. placeVisible.push({
  4218. x: tmpX,
  4219. y: tmpY,
  4220. name: item.name,
  4221. scale: item.scale,
  4222. dir: rad
  4223. });
  4224. game.tickBase(() => {
  4225. placeVisible.shift();
  4226. }, 1)
  4227. }
  4228. if (rmd && getEl("previs").checked) {
  4229. preplaceVisible.push({
  4230. x: tmpX,
  4231. y: tmpY,
  4232. name: item.name,
  4233. scale: item.scale,
  4234. dir: rad
  4235. });
  4236. game.tickBase(() => {
  4237. preplaceVisible.shift();
  4238. }, 1)
  4239.  
  4240.  
  4241.  
  4242.  
  4243. }
  4244. }
  4245. } catch (e) {}
  4246. }
  4247.  
  4248. function getDist(e, t) {
  4249. try {
  4250. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4251. } catch (e) {
  4252. return Infinity;
  4253. }
  4254. }
  4255. // GET DIRECTION
  4256. function getDir(e, t) {
  4257. try {
  4258. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  4259. } catch (e) {
  4260. return 0;
  4261. }
  4262. }
  4263.  
  4264. function sortFromSmallest(arr, func) { // dist - dist
  4265. func = typeof func == "function" ? func : (obj) => {
  4266. return obj
  4267. };
  4268. return arr.sort((two, one) => (func(two)) - func(one));
  4269. }
  4270. /*
  4271. tmpList = objectManager.getGridArrays(user.x2, user.y2, 500);
  4272. for (var x = 0; x < tmpList.length; ++x) {
  4273. for (var y = 0; y < tmpList[x].length; ++y) {
  4274. if (tmpList[x][y].active && getDist(player, tmpList[x][y]))
  4275. }
  4276. }
  4277. */
  4278. function getCloseBuildings() {
  4279. let buildings = [];
  4280. let addedBefore = {};
  4281. let filteredBuildings = objectManager.getGridArrays(player.x, player.y, 200);
  4282. //console.log(filteredBuildings);
  4283. for (var x = 0; x < filteredBuildings.length; ++x) {
  4284. for (var y = 0; y < filteredBuildings[x].length; ++y) {
  4285. if (filteredBuildings[x][y].active) {
  4286. buildings.push(filteredBuildings[x][y]);
  4287. }
  4288. }
  4289. }
  4290. //console.log(buildings);
  4291. return buildings;
  4292. }
  4293. function quadSpikeBreak(user, item) {
  4294. try {
  4295. let angles = [];
  4296. let possibleOnes = [];
  4297. for (let angle = 0; angle < 72; angle++) {
  4298. angles.push(toRadian(angle * 5));
  4299. }
  4300. let buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && t.sid != player.inTrap.sid && getDist(player, t) <= 150), (a)=>{
  4301. return getDist(player, a);
  4302. });
  4303. let last = null;
  4304. for (let angle of angles) {
  4305. let position = player.buildItemPosition(item, angle);
  4306. let possibleToPlace = true;
  4307. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4308. possibleToPlace = false;
  4309. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4310. possibleToPlace = false;
  4311. } else {
  4312. for (let building of buildings_) {
  4313. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4314. if (getDist(building, position) < item.scale + range) { // overlap
  4315. possibleToPlace = false;
  4316. last = building;
  4317. break;
  4318. }
  4319. }
  4320. }
  4321. if (possibleToPlace) {
  4322. possibleOnes.push(angle);
  4323. }
  4324. }
  4325. return possibleOnes;
  4326. } catch (e) {
  4327. //console.log(e);
  4328. }
  4329. }
  4330. function getPlaceablePositions(user, item) {
  4331. try {
  4332. let angles = [];
  4333. let possibleOnes = [];
  4334. for (let angle = 0; angle < 72; angle++) {
  4335. angles.push(toRadian(angle * 5));
  4336. }
  4337. let buildings_ = [];
  4338. if (!window.isMohMoh) {
  4339. buildings_ = sortFromSmallest(gameObjects.filter(t => t.active && getDist(player, t) <= 150), (a)=>{
  4340. return getDist(player, a);
  4341. });
  4342. }
  4343. let last = null;
  4344. for (let angle of angles) {
  4345. let position = player.buildItemPosition(item, angle);
  4346. let possibleToPlace = true;
  4347. if (18 != item.id && position.y >= config.mapScale / 2 - config.riverWidth / 2 && position.y <= config.mapScale / 2 + config.riverWidth / 2) {
  4348. possibleToPlace = false;
  4349. } else if(last && getDist(last, position) < item.scale + (last.blocker ? last.blocker : last.getScale(0.6, last.isItem))){
  4350. possibleToPlace = false;
  4351. } else if (true) {
  4352. for (let building of buildings_) {
  4353. let range = building.blocker ? building.blocker : building.getScale(0.6, building.isItem);
  4354. if (getDist(building, position) < item.scale + range) { // overlap
  4355. possibleToPlace = false;
  4356. last = building;
  4357. break;
  4358. }
  4359. }
  4360. }
  4361. if (possibleToPlace) {
  4362. possibleOnes.push(angle);
  4363. }
  4364. }
  4365. return possibleOnes;
  4366. } catch (e) {
  4367. //console.log(e);
  4368. }
  4369. }
  4370. let firstCheckPlaceForntiBUg = false;
  4371. function simplePlace(id, radian) {
  4372. checkPlace(id, radian);
  4373. };
  4374.  
  4375.  
  4376. function checkPlace(id, rad) {
  4377. try {
  4378. if (secPacket.count >= 80) return;
  4379. //if (id == undefined) return;
  4380. let item = items.list[player.items[id]];
  4381. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4382. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4383. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4384. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4385. place(id, rad, 1);
  4386. }
  4387. } catch (e) {}
  4388. }
  4389. // Preplacer
  4390. let preplaceDelay = {
  4391. killObject: -1,
  4392. gatherAnimation: -1,
  4393. total: function () {
  4394. return new Date - Math.abs(Math.trunc(this.killObject - this.gatherAnimation))
  4395. }
  4396. };
  4397.  
  4398. function getDist(e, t) {
  4399. try {
  4400. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4401. }
  4402. catch (e) {
  4403. return 1 / 0
  4404. }
  4405. }
  4406.  
  4407. function getDir(e, t) {
  4408. try {
  4409. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4410. }
  4411. catch (e) {
  4412. return 0
  4413. }
  4414. }
  4415. var preplaceOverride = !1;
  4416.  
  4417. function caf(e, t) {
  4418. try {
  4419. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4420. }
  4421. catch (e) {
  4422. return 0
  4423. }
  4424. }
  4425.  
  4426. function cdf(e, t) {
  4427. try {
  4428. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x))
  4429. }
  4430. catch (e) {
  4431. return 1 / 0
  4432. }
  4433. }
  4434.  
  4435. function numArr(e = 0, t = 1, i, a = 1) {
  4436. let n = [];
  4437. for (let s = e; s < t; s += a) n.push(s), "function" == typeof i && i(s);
  4438. return n
  4439. }
  4440.  
  4441. function toR(e) {
  4442. var t = e * Math.PI / 180 % (2 * Math.PI);
  4443. return t > Math.PI ? Math.PI - t : t
  4444. }
  4445.  
  4446. function toD(e) {
  4447. var t = e / Math.PI * 360 % 360;
  4448. return t >= 360 ? t - 360 : t
  4449. }
  4450. // HEALING:
  4451. function soldierMult() {
  4452. return player.latestSkin == 6 ? 0.75 : 1;
  4453. }
  4454. function getAttacker(damaged) {
  4455. let attackers = enemy.filter(tmp => {
  4456. //let damages = new Damages(items);
  4457. //let dmg = damages.weapons[tmp.weaponIndex];
  4458. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4459. let rule = {
  4460. //one: tmp.dist2 <= 300,
  4461. //two: by.includes(damaged),
  4462. three: tmp.attacked
  4463. }
  4464. return /*rule.one && rule.two && */rule.three;
  4465. });
  4466. return attackers;
  4467. }
  4468. function healer() {
  4469. for (let i = 0; i < healthBased(); i++) {
  4470. place(0, getAttackDir());
  4471. }
  4472. }
  4473. // ADVANCED:
  4474. function applCxC(value) {
  4475. if (player.health == 100)
  4476. return 0;
  4477. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4478. return Math.ceil(value / items.list[player.items[0]].healing);
  4479. }
  4480. return 0;
  4481. }
  4482. function healthBased() {
  4483. if (player.health == 100)
  4484. return 0;
  4485. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4486. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4487. }
  4488. return 0;
  4489. }
  4490. function calcDmg(value) {
  4491. return value * player.skinIndex == 6 ? 0.75 : 1;
  4492. }
  4493. function antirev() {
  4494. if (tmpObj.isPlayer){
  4495. for (let i = 0; i < healthBased(); i++) {
  4496. place(0, getAttackDir());
  4497. if (player.health == 55 && player.shameCount < 6 && player.skinIndex == 6) {
  4498. place(0, getAttackDir());
  4499. notif("antirev");
  4500. } else if (player.health == 40 && player.shameCount < 6 && player.skinIndex != 6){
  4501. place(0, getAttackDir());
  4502. notif("antirev");
  4503. } else if (player.health == 43.75 && player.shameCount < 5 && player.skinIndex == 6){
  4504. place(0, getAttackDir());
  4505. setTimeout(()=>{
  4506. place(0, getAttackDir());
  4507. },5)
  4508. } else if(player.health == 25 && player.shameCount < 4 && player.skinIndex == 6){
  4509. place(0, getAttackDir());
  4510. setTimeout(()=>{
  4511. place(0, getAttackDir());
  4512. },5)
  4513. } else if (player.health == 58.75 && player.shameCount < 6 && player.skinIndex == 6){
  4514. place(0, getAttackDir());
  4515. setTimeout(()=>{
  4516. place(0, getAttackDir());
  4517. },5)
  4518. } else if (player.health == 45 && player.shameCount < 6 && player.skinIndex != 6){
  4519. place(0, getAttackDir());
  4520. setTimeout(()=>{
  4521. place(0, getAttackDir());
  4522. },5)
  4523. }
  4524. if (player.shameCount < 6) {
  4525. setTimeout(()=>{
  4526. place(0, getAttackDir());
  4527. },30)
  4528. }
  4529. }
  4530. }
  4531. }
  4532. let slowHeal = function(timer) {
  4533. setTimeout(() => {
  4534. //healer();
  4535. }, 25);
  4536. }
  4537. let isHealing = false;
  4538. let delay = 20;
  4539. function uziheal() {
  4540. if (!isHealing && player.health < 100) {
  4541. isHealing = true;
  4542. if (player.health < 70) {
  4543. //place(0, getAttackDir());
  4544. //healer();// fast heal
  4545. isHealing = false;
  4546. } else {
  4547. const healingDelay = 15;
  4548. const healingIterations = Math.ceil((100 - player.health) / 25); // making it have delay so it wont packet spam
  4549. let iterationCount = 0;
  4550. function performHealing() {
  4551. if (iterationCount < healingIterations) {
  4552. setTimeout(() => {
  4553. //place(0, getAttackDir()); // slow heal
  4554. iterationCount++;
  4555. //performHealing();
  4556. }, healingDelay);
  4557. } else {
  4558. isHealing = false;
  4559. }
  4560. }
  4561. performHealing();
  4562. }
  4563. }
  4564. }
  4565. // LATER:
  4566. function predictHeal() { }
  4567. function antiSyncHealing(timearg) {
  4568. my.antiSync = true;
  4569. let healAnti = setInterval(() => {
  4570. if (player.shameCount < 5) {
  4571. place(0, getAttackDir());
  4572. }
  4573. }, 75);
  4574. setTimeout(() => {
  4575. clearInterval(healAnti);
  4576. setTimeout(() => {
  4577. my.antiSync = false;
  4578. }, game.tickRate);
  4579. }, game.tickRate);
  4580. }
  4581. function biomeGear(mover, returns) {
  4582. if (getEl("hatType").value == "1") {
  4583. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4584. if (returns) return 31;
  4585. buyEquip(31, 0);
  4586. } else {
  4587. if (player.y2 <= config.snowBiomeTop) {
  4588. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4589. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4590. } else {
  4591. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4592. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4593. }
  4594. }
  4595. } else if (getEl("hatType").value == "2") {
  4596. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4597. if (returns) return 31;
  4598. buyEquip(31, 0);
  4599. } else {
  4600. if (player.y2 <= config.snowBiomeTop) {
  4601. if (returns) return mover && player.moveDir == undefined ? 6 : 15;
  4602. buyEquip(mover && player.moveDir == undefined ? 6 : 15, 0);
  4603. } else {
  4604. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  4605. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  4606. }
  4607. }
  4608. }
  4609. if (returns) return 0;
  4610. }
  4611.  
  4612. const placedSpikePositions = new Set();
  4613. const placedTrapPositions = new Set();
  4614. function isPositionValid(position) {
  4615. const playerX = player.x2;
  4616. const playerY = player.y2;
  4617. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  4618. return distToPosition > 35;
  4619. }
  4620. function findAllianceBySid(sid) {
  4621. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4622. }
  4623. function calculatePossibleTrapPositions(x, y, radius) {
  4624. const trapPositions = [];
  4625. const numPositions = 16;
  4626. for (let i = 0; i < numPositions; i++) {
  4627. const angle = (2 * Math.PI * i) / numPositions;
  4628. const offsetX = x + radius * Math.cos(angle);
  4629. const offsetY = y + radius * Math.sin(angle);
  4630. const position = [offsetX, offsetY];
  4631. if (!trapPositions.some((pos) => isPositionTooClose(position, pos))) {
  4632. trapPositions.push(position);
  4633. }
  4634. }
  4635. return trapPositions;
  4636. }
  4637. function isPositionTooClose(position1, position2, minDistance = 50) {
  4638. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  4639. return dist < minDistance;
  4640. }
  4641. function biomeGear(mover, returns) {
  4642. if (inWater) {
  4643. if (returns) return 31;
  4644. buyEquip(31, 0);
  4645. } else {
  4646. if (player.y2 <= config.snowBiomeTop) {
  4647. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4648. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4649. } else {
  4650. if (returns) return mover && player.moveDir == undefined ? 22 : 6;
  4651. buyEquip(mover && player.moveDir == undefined ? 22 : 6, 0);
  4652. }
  4653. }
  4654. if (returns) return 0;
  4655. }
  4656. function woah(mover) {
  4657. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4658. }
  4659. function secondaryCheck(id, radian) {
  4660. try {
  4661. var item = items.list[id];
  4662. var tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4663. var tmpX = player.x2 + tmpS * Math.cos(radian);
  4664. var tmpY = player.y2 + tmpS * Math.sin(radian);
  4665. if (
  4666. objectManager.checkItemLocation(
  4667. tmpX,
  4668. tmpY,
  4669. item.scale,
  4670. 0.6,
  4671. item.id,
  4672. false,
  4673. player
  4674. )
  4675. ) {
  4676. if (
  4677. player.itemCounts[item.group.id] == undefined
  4678. ? true
  4679. : player.itemCounts[item.group.id] <
  4680. (true
  4681. ? 99
  4682. : item.group.limit
  4683. ? 99
  4684. : 99)
  4685. ) {
  4686. return true
  4687. }
  4688. }
  4689. } catch (e) {
  4690.  
  4691. }
  4692. }
  4693. function makeAngles(building, type) {
  4694. let getDist = function (tmp1, tmp2, type1, type2) {
  4695. let tmpXY1 = {
  4696. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4697. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4698. };
  4699. let tmpXY2 = {
  4700. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4701. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4702. };
  4703. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4704. };
  4705. function fgdo(a, b) {
  4706. if (a == player) {
  4707. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4708. } else if (b == player) {
  4709. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4710. } else {
  4711. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4712. }
  4713. }
  4714. let buildings = building.filter(obj => fgdo(player, obj) < player.scale + items.list[type].scale + obj.scale + 50 && obj.active)
  4715. let allAngles = []
  4716. let scale
  4717. let offset = player.scale + items.list[type].scale + (items.list[type].placeOffset || 0)
  4718. for (let i = 0; i < buildings.length; i++) {
  4719.  
  4720. let scale
  4721. if (!buildings[i].isItem) {
  4722. if ((buildings[i].scale != 80 && buildings[i].scale != 85 && buildings[i].scale != 90 || buildings[i].type == 1)) {
  4723. scale = buildings[i].scale * 0.40
  4724.  
  4725. } else {
  4726. scale = buildings[i].scale
  4727. }
  4728. } else {
  4729. scale = buildings[i].scale
  4730. }
  4731. let angles = []
  4732. let dist = (items.list[type].scale + scale + 1)
  4733. let dPTB = fgdo(player, buildings[i])
  4734. let cosLaw
  4735. if (dPTB > dist + offset) {
  4736. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dist, 2)) - Math.pow(dPTB, 2)) / (2 * dist * offset))
  4737. cosLaw = Math.asin((dist * Math.sin(cosLaw)) / dPTB)
  4738. } else {
  4739. cosLaw = Math.acos(((Math.pow(offset, 2) + Math.pow(dPTB, 2)) - Math.pow(dist, 2)) / (2 * dPTB * offset))
  4740. }
  4741. let aPTB = Math.atan2(buildings[i].y - player.y2, buildings[i].x - player.x2)
  4742. let ang1 = (aPTB - cosLaw)
  4743. let ang2 = (aPTB + cosLaw)
  4744. if (!isNaN(cosLaw)) {
  4745. angles.push(ang1)
  4746. angles.push(ang2)
  4747. angles.push(buildings[i])
  4748. }
  4749. allAngles.push(angles)
  4750. }
  4751.  
  4752. for (let i = 0; i < allAngles.length * 3; i++) {
  4753. allAngles = manageAngles(allAngles)
  4754.  
  4755. }
  4756. if (!allAngles.length) {
  4757. allAngles = [0, 0.0001]
  4758. }
  4759. for (let i = 0; i < allAngles.length; i++) {
  4760. if (allAngles != false) {
  4761. if (!secondaryCheck(type, allAngles[i][0]) || !secondaryCheck(type, allAngles[i][1])) {
  4762. allAngles = false
  4763. }
  4764. }
  4765. }
  4766. return allAngles
  4767. }
  4768. 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)
  4769. //mental health is not looking good rn
  4770. let array1q
  4771. let array = new Array(2);
  4772. let array2q
  4773.  
  4774. if (Math.sin(angle) > 0 && Math.cos(angle) > 0) {//angle in the first quadrant
  4775. array[0] = arra[0]
  4776. array[1] = arra[1]
  4777. } else if (Math.sin(angle) > 0 && Math.cos(angle) < 0) {//angle is inside the second quadrant
  4778. angle = angle - (Math.PI / 2)
  4779. array[0] = arra[0] - (Math.PI / 2)
  4780. array[1] = arra[1] - (Math.PI / 2)
  4781. } else if (Math.sin(angle) < 0 && Math.cos(angle) < 0) {// angle is in the third quadrant
  4782. angle = angle - Math.PI
  4783. array[0] = arra[0] - Math.PI
  4784. array[1] = arra[1] - Math.PI
  4785.  
  4786. } else if (Math.sin(angle) < 0 && Math.cos(angle) > 0) {//angle is in the fourth quadrant
  4787. angle = angle - ((3 * Math.PI) / 2)
  4788. array[0] = arra[0] - ((3 * Math.PI) / 2)
  4789. array[1] = arra[1] - ((3 * Math.PI) / 2)
  4790. }
  4791. if (Math.sin(array[0]) > 0 && Math.cos(array[0]) > 0) {
  4792. array1q = 1
  4793. } else if (Math.sin(array[0]) > 0 && Math.cos(array[0]) < 0) {
  4794. array1q = 2
  4795. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) < 0) {
  4796. array1q = 3
  4797. } else if (Math.sin(array[0]) < 0 && Math.cos(array[0]) > 0) {
  4798. array1q = 4
  4799. }
  4800. if (Math.sin(array[1]) > 0 && Math.cos(array[1]) > 0) {
  4801. array2q = 1
  4802. } else if (Math.sin(array[1]) > 0 && Math.cos(array[1]) < 0) {
  4803. array2q = 2
  4804. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) < 0) {
  4805. array2q = 3
  4806. } else if (Math.sin(array[1]) < 0 && Math.cos(array[1]) > 0) {
  4807. array2q = 4
  4808. }
  4809.  
  4810. if (array1q == 1) {//lowest angle of the not allowed zone in the first quadrant
  4811.  
  4812. if (Math.sin(angle) < Math.sin(array[0])) {//if the angle is lower than the not allowed zone (probably not in between)
  4813. if (array2q == 1) {// if the second part of the not allowed zone is in the first quadrant
  4814. if (Math.sin(angle) < Math.sin(array[2])) {//if it wraps completely around and makes it in between
  4815. return true
  4816. } else {//doesn't wrap around enough
  4817. return false
  4818. }
  4819. } else {//not in the first quadrant, not in between
  4820. return false
  4821. }
  4822. } else {//if the angle is further than the not allowed zone
  4823. if (array2q == 1) {//if the second part of the not allowed zone is in the first quadrant
  4824. if (Math.sin(angle) < Math.sin(array[2])) {//if the angle is lower than the top limit (in between)
  4825.  
  4826. return true
  4827. } else {//is not in between
  4828. return false
  4829. }
  4830.  
  4831. } else {//its gonna be somewhere further so its in between
  4832. return true;
  4833. }
  4834. }
  4835. } else {
  4836. if (array2q == 1) {//if the further part of the not allowed zone is in the first quadrant
  4837. if (Math.sin(angle) < Math.sin(array[1])) {//if it wraps all the way around
  4838. return true
  4839. } else {
  4840. return false
  4841. }
  4842. } else {
  4843. if (array1q == 2) {//if lowest angle is in the second
  4844. if (array2q == 2) {
  4845. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4846. return true
  4847. } else {
  4848. return false
  4849. }
  4850. } else {
  4851. return false
  4852. }
  4853. } else if (array1q == 3) {//if the first one is in the third
  4854. if (array1q > array2q) {
  4855. return true
  4856. } else if (array1q < array2q) {
  4857. return false
  4858. } else {
  4859. if (Math.sin(array[0]) < Math.sin(array[1])) {
  4860. return true
  4861. } else {
  4862. return false
  4863. }
  4864. }
  4865. } else if (array1q == 4) {//if the first one is in the third
  4866. if (array1q > array2q) {
  4867. return true
  4868. } else if (array1q < array2q) {
  4869. return false
  4870. } else {
  4871. if (Math.sin(array[0]) > Math.sin(array[1])) {
  4872. return true
  4873. } else {
  4874. return false
  4875. }
  4876. }
  4877. }
  4878. }
  4879.  
  4880. }
  4881.  
  4882. }
  4883. function manageAngles(angles) {
  4884. let allAngles = []
  4885. for (let i = 0; i < angles.length; i++) {
  4886. if (angles[i].length) {
  4887. if (!allAngles.length) {
  4888. allAngles.push(angles[i])
  4889. } else {
  4890. let used = false
  4891. for (let j = 0; j < allAngles.length; j++) {
  4892.  
  4893. if (inBetween(angles[i][0], allAngles[j])) {
  4894. used = true
  4895. if (inBetween(angles[i][1], allAngles[j])) {
  4896. allAngles[j].push(angles[i][2])
  4897. } else {
  4898. allAngles[j][1] = angles[i][1]
  4899. allAngles[j].push(angles[i][2])
  4900. }
  4901. } else if (inBetween(angles[i][1], allAngles[j])) {
  4902. used = true
  4903. allAngles[j][0] = angles[i][0]
  4904. allAngles[j].push(angles[i][2])
  4905. }
  4906. }
  4907. if (!used) {
  4908. allAngles.push(angles[i])
  4909. }
  4910. }
  4911. }
  4912. }
  4913.  
  4914. return allAngles
  4915.  
  4916. }
  4917. let priorityPlace = [];
  4918. let packetData = {
  4919. place: [],
  4920. placeQ: [],
  4921. }
  4922. function autoplacer() {
  4923. let getDist = function (tmp1, tmp2, type1, type2) {
  4924. let tmpXY1 = {
  4925. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  4926. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  4927. };
  4928. let tmpXY2 = {
  4929. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  4930. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  4931. };
  4932. return Math.sqrt((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  4933. };
  4934. function fgdo(a, b) {
  4935. if (a == player) {
  4936. return Math.sqrt(Math.pow((b.y - a.y2), 2) + Math.pow((b.x - a.x2), 2));
  4937. } else if (b == player) {
  4938. return Math.sqrt(Math.pow((b.y2 - a.y), 2) + Math.pow((b.x2 - a.x), 2));
  4939. } else {
  4940. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  4941. }
  4942. }
  4943. 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));
  4944. let nearBuilds = buildings.filter(obj => fgdo(obj, player) < 250);
  4945. const notRiver = !inWater
  4946. /*nearest enemy in trap*/
  4947. if (enemy.length && notRiver) {
  4948. 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) {
  4949. return getDist(a, near, 0, 2) - getDist(b, near, 0, 2);
  4950. })[0];
  4951. let direction = Math.atan2(near.y - player.y2, near.x - player.x2)
  4952. let spikeAngles = makeAngles(nearBuilds, player.items[2])
  4953. let trapAngles = [];
  4954. if (player.items[4]) {
  4955. trapAngles = makeAngles(nearBuilds, player.items[4])
  4956. if (!trapAngles) {
  4957. return
  4958. }
  4959. }
  4960. if (!spikeAngles) {
  4961. return
  4962. }
  4963. if (spikeAngles.length || trapAngles.length) {
  4964. let placed = []
  4965. if (priorityPlace.length) {
  4966. for (let j = 0; j < priorityPlace; j++) {
  4967. let newDir = Math.atan2(priorityPlace[j].y - player.y2, priorityPlace[j].x - player.x2)
  4968. let angFound = 0
  4969. for (let i = 0; i < spikeAngles.length; i++) {
  4970. if (!inBetween(newDir, spikeAngles[i])) {
  4971. angFound += 1
  4972. }
  4973. }
  4974. if (angFound == spikeAngles.length) {
  4975. placed.push([player.items[2], newDir])
  4976. packetData.place.push([2, newDir])
  4977. }
  4978. }
  4979. }
  4980. priorityPlace = []
  4981. if (placed.length) {
  4982. for (let i = 0; i < placed.length; i++) {
  4983. let obj = {
  4984. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4985. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  4986. scale: items.list[placed[i][0]].scale / 3,
  4987. isItem: true,
  4988. active: true,
  4989. }
  4990. nearBuilds.push(obj)
  4991. }
  4992. spikeAngles = makeAngles(nearBuilds, player.items[2])
  4993. if (!spikeAngles) {
  4994. return
  4995. }
  4996. trapAngles = []
  4997. if (player.items[4]) {
  4998. trapAngles = makeAngles(nearBuilds, player.items[4])
  4999. if (!trapAngles) {
  5000. return
  5001. }
  5002. }
  5003. placed = []
  5004. }
  5005.  
  5006. if (neit && fgdo(player, near) < 200) {
  5007. let nearestAngle = undefined
  5008. let trapFound = false
  5009. for (let i = 0; i < spikeAngles.length; i++) {
  5010. if (!trapFound) {
  5011. for (let j = 2; j < spikeAngles[i].length; j++) {
  5012. if (neit == spikeAngles[i][j]) {
  5013. trapFound = true
  5014. nearestAngle = ((spikeAngles[i][0] - direction) < (spikeAngles[i][1] - direction) ? spikeAngles[i][0] : spikeAngles[i][1])
  5015. }
  5016. }
  5017. }
  5018. }
  5019. if (trapFound) {
  5020. let objectX = player.x2 + (Math.cos(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  5021. let objectY = player.y2 + (Math.sin(nearestAngle) * (player.scale + items.list[player.items[2]].scale + (items.list[player.items[2]].placeOffset || 0)))
  5022. if (Math.hypot(objectY - near.y, objectX - near.x) < (player.scale + items.list[player.items[2]].scale + 8)) {
  5023. placed.push([player.items[2], nearestAngle])
  5024. packetData.place.push([2, nearestAngle])
  5025. }
  5026. }
  5027. }
  5028. if (placed.length) {
  5029. for (let i = 0; i < placed.length; i++) {
  5030. let obj = {
  5031. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5032. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5033. scale: items.list[placed[i][0]].scale / 3,
  5034. isItem: true,
  5035. active: true,
  5036. }
  5037. nearBuilds.push(obj)
  5038. }
  5039. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5040. if (!spikeAngles) {
  5041. return
  5042. }
  5043. trapAngles = []
  5044. if (player.items[4]) {
  5045. trapAngles = makeAngles(nearBuilds, player.items[4])
  5046. if (!trapAngles) {
  5047. return
  5048. }
  5049. }
  5050. placed = []
  5051. }
  5052. if (fgdo(player, near) < 400) {
  5053. let ha = false
  5054.  
  5055.  
  5056. if (neit) {
  5057. let buildings = gameObjects.sort((a, b) => fgdo(player, a) - fgdo(player, b))
  5058. 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]
  5059. if (spike) {
  5060. ha = true
  5061. }
  5062.  
  5063. }
  5064. if (!neit || ha) {
  5065. let dirFound = 0
  5066. for (let i = 0; i < trapAngles.length; i++) {
  5067. if (!inBetween(direction, trapAngles[i])) {
  5068. dirFound += 1
  5069. }
  5070. }
  5071. if (dirFound == trapAngles.length) {
  5072. if (packetData.place.length < 3 && player.items[4]) {
  5073. placed.push([player.items[4], direction])
  5074. packetData.place.push([4, direction])
  5075. }
  5076. }
  5077. if (placed.length) {
  5078. for (let i = 0; i < placed.length; i++) {
  5079. let obj = {
  5080. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5081. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5082. scale: items.list[placed[i][0]].scale / 3,
  5083. isItem: true,
  5084. active: true,
  5085.  
  5086. }
  5087. nearBuilds.push(obj)
  5088. }
  5089. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5090. if (!spikeAngles) {
  5091. return
  5092. }
  5093. trapAngles = []
  5094. if (player.items[4]) {
  5095. trapAngles = makeAngles(nearBuilds, player.items[4])
  5096. if (!trapAngles) {
  5097. return
  5098. }
  5099. }
  5100. placed = []
  5101. }
  5102.  
  5103. if (fgdo(player, near) < 120) {
  5104. for (let i = 0; i < spikeAngles.length; i++) {
  5105. if (packetData.place.length < 3) {
  5106. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5107. placed.push([player.items[2], closest])
  5108. packetData.place.push([2, closest])
  5109. }
  5110. if (placed.length) {
  5111. for (let i = 0; i < placed.length; i++) {
  5112. let obj = {
  5113. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5114. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5115. scale: items.list[placed[i][0]].scale / 3,
  5116. isItem: true,
  5117. active: true,
  5118.  
  5119. }
  5120. nearBuilds.push(obj)
  5121. }
  5122. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5123. if (!spikeAngles) {
  5124. return
  5125. }
  5126. trapAngles = []
  5127. if (player.items[4]) {
  5128. trapAngles = makeAngles(nearBuilds, player.items[4])
  5129. if (!trapAngles) {
  5130. return
  5131. }
  5132. }
  5133. placed = []
  5134. }
  5135. }
  5136.  
  5137. } else {
  5138. for (let i = 0; i < trapAngles.length; i++) {
  5139. if (packetData.place.length < 3 && player.items[4]) {
  5140. let closest = (direction - trapAngles[i][0] <= direction - trapAngles[i][1] ? trapAngles[i][0] : trapAngles[i][1])
  5141. placed.push([player.items[4], closest])
  5142. packetData.place.push([4, closest])
  5143. }
  5144. if (placed.length) {
  5145. for (let i = 0; i < placed.length; i++) {
  5146. let obj = {
  5147. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5148. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5149. scale: items.list[placed[i][0]].scale / 3,
  5150. isItem: true,
  5151. active: true,
  5152.  
  5153. }
  5154. nearBuilds.push(obj)
  5155. }
  5156. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5157. if (!spikeAngles) {
  5158. return
  5159. }
  5160. trapAngles = []
  5161. if (player.items[4]) {
  5162. trapAngles = makeAngles(nearBuilds, player.items[4])
  5163. if (!trapAngles) {
  5164. return
  5165. }
  5166. }
  5167. placed = []
  5168. }
  5169. }
  5170. }
  5171. } else {
  5172. if (fgdo(player, near) < 180) {
  5173. for (let i = 0; i < spikeAngles.length; i++) {
  5174. if (packetData.place.length < 3) {
  5175. let closest = (direction - spikeAngles[i][0] <= direction - spikeAngles[i][1] ? spikeAngles[i][0] : spikeAngles[i][1])
  5176. placed.push([player.items[2], closest])
  5177. packetData.place.push([2, closest])
  5178. }
  5179. if (placed.length) {
  5180. for (let i = 0; i < placed.length; i++) {
  5181. let obj = {
  5182. x: player.x2 + (Math.cos(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5183. y: player.y2 + (Math.sin(placed[i][1]) * (player.scale + items.list[placed[i][0]].scale + (items.list[placed[i][0]].placeOffset || 0))),
  5184. scale: items.list[placed[i][0]].scale / 3,
  5185. isItem: true,
  5186. active: true,
  5187.  
  5188. }
  5189. nearBuilds.push(obj)
  5190. }
  5191. spikeAngles = makeAngles(nearBuilds, player.items[2])
  5192. if (!spikeAngles) {
  5193. return
  5194. }
  5195. trapAngles = []
  5196. if (player.items[4]) {
  5197. trapAngles = makeAngles(nearBuilds, player.items[4])
  5198. if (!trapAngles) {
  5199. return
  5200. }
  5201. }
  5202. placed = []
  5203. }
  5204. }
  5205. }
  5206. }
  5207. }
  5208.  
  5209. }
  5210. }
  5211. priorityPlace = [];
  5212. }
  5213. let advHeal = [];
  5214. class Traps {
  5215. constructor(UTILS, items) {
  5216. this.dist = 0;
  5217. this.aim = 0;
  5218. this.inTrap = false;
  5219. this.replaced = false;
  5220. this.antiTrapped = false;
  5221. this.info = {};
  5222. this.notFast = function() {
  5223. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5224. }
  5225. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5226. try {
  5227. let item = items.list[player.items[id]];
  5228. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5229. let counts = {
  5230. attempts: 0,
  5231. placed: 0
  5232. };
  5233. let tmpObjects = [];
  5234. gameObjects.forEach((p) => {
  5235. tmpObjects.push({
  5236. x: p.x,
  5237. y: p.y,
  5238. active: p.active,
  5239. blocker: p.blocker,
  5240. scale: p.scale,
  5241. isItem: p.isItem,
  5242. type: p.type,
  5243. colDiv: p.colDiv,
  5244. getScale: function(sM, ig) {
  5245. sM = sM || 1;
  5246. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  5247. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  5248. },
  5249. });
  5250. });
  5251. for (let i = first; i < repeat; i += plus) {
  5252. counts.attempts++;
  5253. let relAim = radian + i;
  5254. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5255. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5256. 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)));
  5257. if (cantPlace) continue;
  5258. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5259. place(id, relAim, 1);
  5260. tmpObjects.push({
  5261. x: tmpX,
  5262. y: tmpY,
  5263. active: true,
  5264. blocker: item.blocker,
  5265. scale: item.scale,
  5266. isItem: true,
  5267. type: null,
  5268. colDiv: item.colDiv,
  5269. getScale: function() {
  5270. return this.scale;
  5271. },
  5272. });
  5273. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5274. counts.placed++;
  5275. }
  5276. }
  5277. if (counts.placed > 0 && replacer && item.dmg) {
  5278. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs1.AutoSpikeTick) {
  5279. instaC.canSpikeTick = true;
  5280. }
  5281. }
  5282. } catch (err) {
  5283. }
  5284. };
  5285. this.checkSpikeTick = function() {
  5286. //this is my anti spike tick function which 100% confirms that u cant get spike ticked when breaking a trap
  5287. 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
  5288. try {
  5289. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5290. if ((configs1.AntiSpikeTick || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5291. // more range for safe. also testing near.primaryIndex || 5
  5292. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5293. let item = items.list[9];
  5294. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5295. let danger = 0;
  5296. let counts = {
  5297. attempts: 0,
  5298. block: `unblocked`
  5299. };
  5300. for (let i = -1; i <= 1; i += 1 / 10) {
  5301. counts.attempts++;
  5302. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5303. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5304. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5305. 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)));
  5306. if (cantPlace) continue;
  5307. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5308. danger++;
  5309. counts.block = `blocked`;
  5310. break;
  5311. }
  5312. if (danger) {
  5313. my.anti0Tick = 1;
  5314. packet('6', "pro anti tick huh? " + hir.sid);
  5315. player.chat.count = 2000;
  5316. return true;
  5317. }
  5318. }
  5319. } catch (err) {
  5320. return null;
  5321. }
  5322. return false;
  5323. }
  5324. this.protect = function(aim, trap) {
  5325. if (!configs1.AntiTrap) return;
  5326. if (trap && nears.length) {
  5327. if (getDist(near, player) > getDist(near, trap)) {
  5328. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5329. checkPlace(2, near.aim2 + i);
  5330. }
  5331. }
  5332. if (getDist(near, trap) > getDist(near, player)) {
  5333. if (player.items[4]) {
  5334. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5335. checkPlace(4, near.aim2 + i) && this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5336. }
  5337. } else {
  5338. for (let i = -(Math.PI / 2); i < (Math.PI / 2); i += (Math.PI / 18)) {
  5339. checkPlace(2, near.aim2 + i) && this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5340. }
  5341. }
  5342. }
  5343. } else {
  5344. if (player.items[4] && player.items[2]) {
  5345. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5346. this.antiTrapped = true;
  5347. }
  5348. }
  5349. };
  5350. let placedSpikePositions = new Set();
  5351. let placedTrapPositions = new Set();
  5352. this.autoPlace = function () {
  5353. if (!configs1.AutoPlace) return;
  5354. try {
  5355. if (gameObjects.length) {
  5356. let near2 = {
  5357. inTrap: false,
  5358. };
  5359. 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];
  5360.  
  5361. if (nearTrap) {
  5362. near2.inTrap = true;
  5363. } else {
  5364. near2.inTrap = false;
  5365. }
  5366.  
  5367. if (near.dist3 <= 450) {
  5368. if (near.dist3 <= 200) {
  5369. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5370. inTrap: near2.inTrap
  5371. });
  5372. } else {
  5373. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5374. }
  5375. }
  5376. } else {
  5377. if (near.dist3 <= 450) {
  5378. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5379. }
  5380. }
  5381. const trap1 = gameObjects
  5382. .filter((e) => e.trap && e.active)
  5383. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5384. .find((trap) => {
  5385. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5386. return (
  5387. trap !== player &&
  5388. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5389. trapDist <= 50
  5390. );
  5391. });
  5392.  
  5393. if (trap1 && near.dist2 <= 160) {
  5394. const trapX = trap1.x;
  5395. const trapY = trap1.y;
  5396. const circleRadius = 102;
  5397. const numPositions = 64;
  5398.  
  5399. for (let i = 0; i < numPositions; i++) {
  5400. const angle = (2 * Math.PI * i) / numPositions;
  5401. const offsetX = trapX + circleRadius * Math.cos(angle);
  5402. const offsetY = trapY + circleRadius * Math.sin(angle);
  5403. const position = [offsetX, offsetY];
  5404. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5405.  
  5406. if (
  5407. !placedSpikePositions.has(JSON.stringify(position)) &&
  5408. isPositionValid(position) &&
  5409. distToPlayer <= 87
  5410. ) {
  5411. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5412. checkPlace(2, angleToPlace);
  5413. placedSpikePositions.add(JSON.stringify(position));
  5414. }
  5415. }
  5416. } else if (!trap1 && near.dist2 <= 206) {
  5417. placedSpikePositions.clear();
  5418. const maxTrapsToPlace = 3;
  5419. const trapRadius = 50;
  5420. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5421. let trapsPlaced = 0;
  5422.  
  5423. for (const position of trapPositions) {
  5424. if (
  5425. trapsPlaced < maxTrapsToPlace &&
  5426. !placedTrapPositions.has(JSON.stringify(position)) &&
  5427. isPositionValid(position)
  5428. ) {
  5429. checkPlace(4, ...position);
  5430. placedTrapPositions.add(JSON.stringify(position));
  5431. trapsPlaced++;
  5432. }
  5433. }
  5434. }
  5435. } catch (e) {
  5436. console.log(e);
  5437. }
  5438. };
  5439. function calculatePerfectAngle(x1, y1, x2, y2) {
  5440. return Math.atan2(y2 - y1, x2 - x1);
  5441. }
  5442. function antiSpikeTickEz() {
  5443. 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
  5444. }
  5445. function fgdo(a, b) {
  5446. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  5447. }
  5448. let spikSync = false;
  5449. let spikePlaced = false;
  5450.  
  5451. this.replacer = function(findObj) {
  5452. if (!findObj || !configs.autoReplace) return;
  5453. if (!inGame) return;
  5454. if (this.antiTrapped) return;
  5455. game.tickBase(() => {
  5456. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5457. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5458. let perfectAngle = Math.round(calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y) / (Math.PI / 2)) * (Math.PI / 2);
  5459. 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;
  5460. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5461. let danger = this.checkSpikeTick();
  5462. if (objDst <= 300 && near.dist2 <= 400) {
  5463. if (near.dist2 <= 70 && canPlaceCondition && configs.spikeTick) {
  5464. this.testCanPlace(2, -Math.PI/4, Math.PI/4, (Math.PI / 20), near.aim2, 1);
  5465. this.testCanPlace(4, -Math.PI/4, Math.PI/4, Math.PI/12, near.aim2+Math.PI, 1)
  5466. } else if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5467. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5468. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5469. } else {
  5470. player.items[4] == 15 && this.testCanPlace(near.dist2 > 250 ? 4 : 2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5471. }
  5472. this.replaced = true;
  5473. }
  5474. }, 1);
  5475. };
  5476. }
  5477. };
  5478. class Instakill {
  5479. constructor() {
  5480. this.wait = false;
  5481. this.can = false;
  5482. this.isTrue = false;
  5483. this.nobull = false;
  5484. this.ticking = false;
  5485. this.canSpikeTick = false;
  5486. this.startTick = false;
  5487. this.readyTick = false;
  5488. this.canCounter = false;
  5489. this.revTick = false;
  5490. this.syncHit = false;
  5491. this.changeType = function (type) {
  5492. this.wait = false;
  5493. this.isTrue = true;
  5494. my.autoAim = true;
  5495. let instaLog = [type];
  5496. let backupNobull = near.backupNobull;
  5497. near.backupNobull = false;
  5498. game.tickBase(() => {
  5499. instaLog.push(player.skinIndex);
  5500. game.tickBase(() => {
  5501. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5502. near.backupNobull = true;
  5503. }
  5504. instaLog.push(player.skinIndex);
  5505. }, 1);
  5506. }, 1);
  5507. if (type == "rev") {
  5508. selectWeapon(player.weapons[1]);
  5509. buyEquip(53, 0);
  5510. buyEquip(21, 1);
  5511. sendAutoGather();
  5512. game.tickBase(() => {
  5513. selectWeapon(player.weapons[0]);
  5514. buyEquip(7, 0);
  5515. buyEquip(21, 1);
  5516. game.tickBase(() => {
  5517. sendAutoGather();
  5518. this.isTrue = false;
  5519. my.autoAim = false;
  5520. }, 1);
  5521. }, 1);
  5522. } else if (type == "nobull") {
  5523. selectWeapon(player.weapons[0]);
  5524. if (getEl("backupNobull").checked && backupNobull) {
  5525. buyEquip(7, 0);
  5526. } else {
  5527. buyEquip(6, 0);
  5528. }
  5529. buyEquip(21, 1);
  5530. sendAutoGather();
  5531. game.tickBase(() => {
  5532. if (near.skinIndex == 22) {
  5533. if (getEl("backupNobull").checked) {
  5534. near.backupNobull = true;
  5535. }
  5536. buyEquip(21, 0);
  5537. } else {
  5538. buyEquip(53, 0);
  5539. }
  5540. selectWeapon(player.weapons[1]);
  5541. buyEquip(21, 1);
  5542. game.tickBase(() => {
  5543. sendAutoGather();
  5544. this.isTrue = false;
  5545. my.autoAim = false;
  5546. }, 1);
  5547. }, 1);
  5548. } else if (type == "normal") {
  5549. selectWeapon(player.weapons[0]);
  5550. buyEquip(7, 0);
  5551. buyEquip(21, 1);
  5552. sendAutoGather();
  5553. game.tickBase(() => {
  5554. selectWeapon(player.weapons[1]);
  5555. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5556. buyEquip(21, 1);
  5557. game.tickBase(() => {
  5558. sendAutoGather();
  5559. this.isTrue = false;
  5560. my.autoAim = false;
  5561. }, 1);
  5562. }, 1);
  5563. } else {
  5564. setTimeout(() => {
  5565. this.isTrue = false;
  5566. my.autoAim = false;
  5567. }, 50);
  5568. }
  5569. };
  5570. this.spikeTickType = function () {
  5571. this.isTrue = true;
  5572. my.autoAim = true;
  5573. selectWeapon(player.weapons[0]);
  5574. buyEquip(7, 0);
  5575. buyEquip(21, 1);
  5576. sendAutoGather();
  5577. game.tickBase(() => {
  5578. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5579. selectWeapon(player.weapons[0]);
  5580. buyEquip(53, 0);
  5581. buyEquip(21, 1);
  5582. game.tickBase(() => {
  5583. sendAutoGather();
  5584. this.isTrue = false;
  5585. my.autoAim = false;
  5586. }, 1);
  5587. } else {
  5588. sendAutoGather();
  5589. this.isTrue = false;
  5590. my.autoAim = false;
  5591. }
  5592. }, 1);
  5593. };
  5594. this.counterType = function () {
  5595. this.isTrue = true;
  5596. my.autoAim = true;
  5597. selectWeapon(player.weapons[0]);
  5598. buyEquip(7, 0);
  5599. buyEquip(21, 1);
  5600. sendAutoGather();
  5601. game.tickBase(() => {
  5602. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5603. selectWeapon(player.weapons[0]);
  5604. buyEquip(53, 0);
  5605. buyEquip(21, 1);
  5606. game.tickBase(() => {
  5607. sendAutoGather();
  5608. this.isTrue = false;
  5609. my.autoAim = false;
  5610. }, 1);
  5611. } else {
  5612. sendAutoGather();
  5613. this.isTrue = false;
  5614. my.autoAim = false;
  5615. }
  5616. }, 1);
  5617. };
  5618. this.rangeType = function (type) {
  5619. this.isTrue = true;
  5620. my.autoAim = true;
  5621. if (type == "ageInsta") {
  5622. my.ageInsta = false;
  5623. if (player.items[5] == 18) {
  5624. place(5, near.aim2);
  5625. }
  5626. packet("I", undefined, 1);
  5627. buyEquip(22, 0);
  5628. buyEquip(21, 1);
  5629. game.tickBase(() => {
  5630. selectWeapon(player.weapons[1]);
  5631. buyEquip(53, 0);
  5632. buyEquip(21, 1);
  5633. sendAutoGather();
  5634. game.tickBase(() => {
  5635. sendUpgrade(12);
  5636. selectWeapon(player.weapons[1]);
  5637. buyEquip(53, 0);
  5638. buyEquip(21, 1);
  5639. game.tickBase(() => {
  5640. sendUpgrade(15);
  5641. selectWeapon(player.weapons[1]);
  5642. buyEquip(53, 0);
  5643. buyEquip(21, 1);
  5644. game.tickBase(() => {
  5645. sendAutoGather();
  5646. this.isTrue = false;
  5647. my.autoAim = false;
  5648. }, 1);
  5649. }, 1);
  5650. }, 1);
  5651. }, 1);
  5652. } else {
  5653. selectWeapon(player.weapons[1]);
  5654. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5655. buyEquip(53, 0);
  5656. } else {
  5657. buyEquip(20, 0);
  5658. }
  5659. buyEquip(11, 1);
  5660. sendAutoGather();
  5661. game.tickBase(() => {
  5662. sendAutoGather();
  5663. this.isTrue = false;
  5664. my.autoAim = false;
  5665. }, 1);
  5666. }
  5667. };
  5668. this.boostTickType = function() {
  5669. /*this.isTrue = true;
  5670. my.autoAim = true;
  5671. selectWeapon(player.weapons[0]);
  5672. buyEquip(53, 0);
  5673. buyEquip(11, 1);
  5674. packet("a", near.aim2);
  5675. game.tickBase(() => {
  5676. place(4, near.aim2);
  5677. selectWeapon(player.weapons[1]);
  5678. biomeGear();
  5679. buyEquip(11, 1);
  5680. sendAutoGather();
  5681. packet("a", near.aim2);
  5682. game.tickBase(() => {
  5683. selectWeapon(player.weapons[0]);
  5684. buyEquip(7, 0);
  5685. buyEquip(19, 1);
  5686. packet("a", near.aim2);
  5687. game.tickBase(() => {
  5688. sendAutoGather();
  5689. this.isTrue = false;
  5690. my.autoAim = false;
  5691. packet("a", undefined);
  5692. }, 1);
  5693. }, 1);
  5694. }, 1);*/
  5695. this.isTrue = true;
  5696. my.autoAim = true;
  5697. biomeGear();
  5698. buyEquip(11, 1);
  5699. packet("a", near.aim2, 1);
  5700. game.tickBase(() => {
  5701. if (player.weapons[1] == 15) {
  5702. my.revAim = true;
  5703. }
  5704. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5705. buyEquip(53, 0);
  5706. buyEquip(11, 1);
  5707. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5708. sendAutoGather();
  5709. }
  5710. packet("a", near.aim2, 1);
  5711. place(4, near.aim2);
  5712. game.tickBase(() => {
  5713. my.revAim = false;
  5714. selectWeapon(player.weapons[0]);
  5715. buyEquip(7, 0);
  5716. buyEquip(19, 1);
  5717. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5718. sendAutoGather();
  5719. }
  5720. packet("a", near.aim2, 1);
  5721. game.tickBase(() => {
  5722. sendAutoGather();
  5723. this.isTrue = false;
  5724. my.autoAim = false;
  5725. packet("a", undefined, 1);
  5726. }, 1);
  5727. }, 1);
  5728. }, 1);
  5729. };
  5730. this.gotoGoal = function(goto, OT) {
  5731. let slowDists = (weeeee) => weeeee * config.playerScale;
  5732. let goal = {
  5733. a: goto - OT,
  5734. b: goto + OT,
  5735. c: goto - slowDists(1),
  5736. d: goto + slowDists(1),
  5737. e: goto - slowDists(2),
  5738. f: goto + slowDists(2),
  5739. g: goto - slowDists(4),
  5740. h: goto + slowDists(4)
  5741. };
  5742. let bQ = function(wwww, awwww) {
  5743. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5744. buyEquip(31, 0);
  5745. } else {
  5746. buyEquip(wwww, awwww);
  5747. }
  5748. }
  5749. if (enemy.length) {
  5750. let dst = near.dist2;
  5751. this.ticking = true;
  5752. if (dst >= goal.a && dst <= goal.b) {
  5753. bQ(22, 0);
  5754. bQ(11, 1);
  5755. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5756. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5757. }
  5758. return {
  5759. dir: undefined,
  5760. action: 1
  5761. };
  5762. } else {
  5763. if (dst < goal.a) {
  5764. if (dst >= goal.g) {
  5765. if (dst >= goal.e) {
  5766. if (dst >= goal.c) {
  5767. bQ(40, 0);
  5768. bQ(10, 1);
  5769. if (configs.none) {
  5770. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5771. } else {
  5772. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5773. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5774. }
  5775. }
  5776. } else {
  5777. bQ(22, 0);
  5778. bQ(19, 1);
  5779. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5780. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5781. }
  5782. }
  5783. } else {
  5784. bQ(6, 0);
  5785. bQ(12, 1);
  5786. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5787. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5788. }
  5789. }
  5790. } else {
  5791. biomeGear();
  5792. bQ(11, 1);
  5793. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5794. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5795. }
  5796. }
  5797. return {
  5798. dir: near.aim2 + Math.PI,
  5799. action: 0
  5800. };
  5801. } else if (dst > goal.b) {
  5802. if (dst <= goal.h) {
  5803. if (dst <= goal.f) {
  5804. if (dst <= goal.d) {
  5805. bQ(40, 0);
  5806. bQ(9, 1);
  5807. if (configs.none) {
  5808. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5809. } else {
  5810. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5811. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5812. }
  5813. }
  5814. } else {
  5815. bQ(22, 0);
  5816. bQ(19, 1);
  5817. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5818. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5819. }
  5820. }
  5821. } else {
  5822. bQ(6, 0);
  5823. bQ(12, 1);
  5824. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5825. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5826. }
  5827. }
  5828. } else {
  5829. biomeGear();
  5830. bQ(11, 1);
  5831. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5832. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5833. }
  5834. }
  5835. return {
  5836. dir: near.aim2,
  5837. action: 0
  5838. };
  5839. }
  5840. return {
  5841. dir: undefined,
  5842. action: 0
  5843. };
  5844. }
  5845. } else {
  5846. this.ticking = false;
  5847. return {
  5848. dir: undefined,
  5849. action: 0
  5850. };
  5851. }
  5852. }
  5853. /** wait 1 tick for better quality */
  5854. this.bowMovement = function() {
  5855. let moveMent = this.gotoGoal(685, 3);
  5856. if (moveMent.action) {
  5857. if (player.reloads[53] == 0 && !this.isTrue) {
  5858. this.rangeType("ageInsta");
  5859. } else {
  5860. packet("a", moveMent.dir, 1);
  5861. }
  5862. } else {
  5863. packet("a", moveMent.dir, 1);
  5864. }
  5865. },
  5866. this.tickMovement = function() {
  5867. let dist = player.weapons[1] == 9 ? 240 : 240;
  5868. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5869. let moveMent = this.gotoGoal(238, 3);
  5870. if (moveMent.action) {
  5871. if (player.reloads[53] == 0 && !this.isTrue) {
  5872. this.boostTickType();
  5873. } else {
  5874. packet("a", moveMent.dir, 1);
  5875. }
  5876. } else {
  5877. packet("a", moveMent.dir, 1);
  5878. }
  5879. },
  5880. this.kmTickMovement = function() {
  5881. let moveMent = this.gotoGoal(240, 3);
  5882. if (moveMent.action) {
  5883. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5884. this.kmTickType();
  5885. } else {
  5886. packet("a", moveMent.dir, 1);
  5887. }
  5888. } else {
  5889. packet("a", moveMent.dir, 1);
  5890. }
  5891. },
  5892. this.boostTickMovement = function() {
  5893. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 140;
  5894. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5895. let moveMent = this.gotoGoal(372, 3);
  5896. if (moveMent.action) {
  5897. if (player.reloads[53] == 0 && !this.isTrue) {
  5898. this.boostTickType();
  5899. } else {
  5900. packet("a", moveMent.dir, 1);
  5901. }
  5902. } else {
  5903. packet("a", moveMent.dir, 1);
  5904. }
  5905. }
  5906. /** wait 1 tick for better quality */
  5907. this.perfCheck = function(pl, nr) {
  5908. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5909. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5910. let pjs = {
  5911. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5912. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5913. };
  5914. 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)) {
  5915. return true;
  5916. }
  5917. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5918. 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)) {
  5919. return true;
  5920. }
  5921. });
  5922. if (finds) return false;
  5923. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5924. let tmpScale = tmp.getScale();
  5925. 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)) {
  5926. return true;
  5927. }
  5928. });
  5929. if (finds) return false;
  5930. return true;
  5931. }
  5932. }
  5933. };
  5934. class Autobuy {
  5935. constructor(buyHat, buyAcc) {
  5936. this.hat = function() {
  5937. buyHat.forEach((id) => {
  5938. let find = findID(hats, id);
  5939. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5940. });
  5941. };
  5942. this.acc = function() {
  5943. buyAcc.forEach((id) => {
  5944. let find = findID(accessories, id);
  5945. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5946. });
  5947. };
  5948. }
  5949. };
  5950.  
  5951. class Autoupgrade {
  5952. constructor() {
  5953. this.sb = function(upg) {
  5954. upg(3);
  5955. upg(17);
  5956. upg(31);
  5957. upg(23);
  5958. upg(9);
  5959. upg(38);
  5960. };
  5961. this.kh = function(upg) {
  5962. upg(3);
  5963. upg(17);
  5964. upg(31);
  5965. upg(23);
  5966. upg(10);
  5967. upg(38);
  5968. upg(4);
  5969. upg(25);
  5970. };
  5971. this.pb = function(upg) {
  5972. upg(5);
  5973. upg(17);
  5974. upg(32);
  5975. upg(23);
  5976. upg(9);
  5977. upg(38);
  5978. };
  5979. this.ph = function(upg) {
  5980. upg(5);
  5981. upg(17);
  5982. upg(32);
  5983. upg(23);
  5984. upg(10);
  5985. upg(38);
  5986. upg(28);
  5987. upg(25);
  5988. };
  5989. this.db = function(upg) {
  5990. upg(7);
  5991. upg(17);
  5992. upg(31);
  5993. upg(23);
  5994. upg(9);
  5995. upg(34);
  5996. };
  5997. };
  5998. };
  5999.  
  6000. class Damages {
  6001. constructor(items) {
  6002. // 0.75 1 1.125 1.5
  6003. this.calcDmg = function(dmg, val) {
  6004. return dmg * val;
  6005. };
  6006. this.getAllDamage = function(dmg) {
  6007. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  6008. };
  6009. this.weapons = [];
  6010. for (let i = 0; i < items.weapons.length; i++) {
  6011. let wp = items.weapons[i];
  6012. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  6013. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  6014. this[name] = this.weapons[i];
  6015. }
  6016. }
  6017. }
  6018.  
  6019. /** CLASS CODES */
  6020. // jumpscare code warn
  6021. let tmpList = [];
  6022. // LOADING:
  6023. let UTILS = new Utils();
  6024. let items = new Items();
  6025. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6026. let store = new Store();
  6027. let hats = store.hats;
  6028. let accessories = store.accessories;
  6029. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6030. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6031. let textManager = new Textmanager();
  6032. let traps = new Traps(UTILS, items);
  6033. let instaC = new Instakill();
  6034. let autoBuy = new Autobuy([15, 31, 6, 7, 22, 12, 53, 26, 20, 40], [11, 13, 19, 18, 21]);
  6035. let autoUpgrade = new Autoupgrade();
  6036. let lastDeath;
  6037. let minimapData;
  6038. let mapMarker = {};
  6039. let mapPings = [];
  6040. let tmpPing;
  6041. let breakTrackers = [];
  6042. let pathFindTest = 0;
  6043. let grid = [];
  6044. let pathFind = {
  6045. active: false,
  6046. grid: 40,
  6047. scale: 1440,
  6048. x: 14400,
  6049. y: 14400,
  6050. chaseNear: false,
  6051. array: [],
  6052. lastX: this.grid / 2,
  6053. lastY: this.grid / 2
  6054. };
  6055. function sendChat(message) {
  6056. packet("6", message.slice(0, 30));
  6057. }
  6058. let runAtNextTick = [];
  6059. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6060. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6061. let projOffset = config.playerScale * 2;
  6062. let projXY = {
  6063. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6064. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6065. };
  6066. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6067. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6068. })[0];
  6069. if (nearPlayer) {
  6070. if (indx == 1) {
  6071. nearPlayer.shooting[53] = 1;
  6072. } else {
  6073. nearPlayer.shootIndex = weaponIndx;
  6074. nearPlayer.shooting[1] = 1;
  6075. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6076. }
  6077. }
  6078. }
  6079. let projectileCount = 0;
  6080. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6081. if (!tmpObj.isTeam(player)) {
  6082. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6083. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6084. tmpObj.bowThreat[weaponIndex]++;
  6085. if (index == 5) {
  6086. projectileCount++;
  6087. }
  6088. setTimeout(() => {
  6089. tmpObj.bowThreat[weaponIndex]--;
  6090. if (index == 5) {
  6091. projectileCount--;
  6092. }
  6093. }, range / speed);
  6094. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6095. place(1, tmpObj.aim2);
  6096. my.anti0Tick = 4;
  6097. if (!my.antiSync) {
  6098. antiSyncHealing(4);
  6099. }
  6100. } else {
  6101. if (projectileCount >= 2) {
  6102. place(1, tmpObj.aim2);
  6103. my.anti0Tick = 4;
  6104. if (!my.antiSync) {
  6105. antiSyncHealing(4);
  6106. }
  6107. }
  6108. }
  6109. }
  6110. }
  6111. }
  6112. // SHOW ITEM INFO:
  6113. function showItemInfo(item, isWeapon, isStoreItem) {
  6114. if (player && item) {
  6115. UTILS.removeAllChildren(itemInfoHolder);
  6116. itemInfoHolder.classList.add("visible");
  6117. UTILS.generateElement({
  6118. id: "itemInfoName",
  6119. text: UTILS.capitalizeFirst(item.name),
  6120. parent: itemInfoHolder
  6121. });
  6122. UTILS.generateElement({
  6123. id: "itemInfoDesc",
  6124. text: item.desc,
  6125. parent: itemInfoHolder
  6126. });
  6127. if (isStoreItem) {
  6128. } else if (isWeapon) {
  6129. UTILS.generateElement({
  6130. class: "itemInfoReq",
  6131. text: !item.type ? "primary" : "secondary",
  6132. parent: itemInfoHolder
  6133. });
  6134. } else {
  6135. for (let i = 0; i < item.req.length; i += 2) {
  6136. UTILS.generateElement({
  6137. class: "itemInfoReq",
  6138. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6139. parent: itemInfoHolder
  6140. });
  6141. }
  6142. if (item.group.limit) {
  6143. UTILS.generateElement({
  6144. class: "itemInfoLmt",
  6145. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6146. parent: itemInfoHolder
  6147. });
  6148. }
  6149. }
  6150. } else {
  6151. itemInfoHolder.classList.remove("visible");
  6152. }
  6153. }
  6154. // RESIZE:
  6155. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6156. function resize() {
  6157. screenWidth = window.innerWidth;
  6158. screenHeight = window.innerHeight;
  6159. var scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6160. gameCanvas.width = screenWidth;
  6161. gameCanvas.height = screenHeight;
  6162. gameCanvas.style.width = screenWidth + "px";
  6163. gameCanvas.style.height = screenHeight + "px";
  6164. gameCanvas.style;
  6165. mainContext.setTransform(scaleFillNative, 0, 0, scaleFillNative, (screenWidth * pixelDensity - maxScreenWidth * scaleFillNative) / 2, (screenHeight * pixelDensity - maxScreenHeight * scaleFillNative) / 2);
  6166. }
  6167. resize();
  6168. // MOUSE INPUT:
  6169. const mals = document.getElementById('touch-controls-fullscreen');
  6170. mals.style.display = 'block';
  6171. mals.addEventListener("mousemove", gameInput, false);
  6172. function gameInput(e) {
  6173. mouseX = e.clientX;
  6174. mouseY = e.clientY;
  6175. }
  6176. let clicks = {
  6177. left: false,
  6178. middle: false,
  6179. right: false,
  6180. };
  6181. mals.addEventListener("mousedown", mouseDown, false);
  6182. function mouseDown(e) {
  6183. if (attackState != 1) {
  6184. attackState = 1;
  6185. if (e.button == 0) {
  6186. clicks.left = true;
  6187. } else if (e.button == 1) {
  6188. clicks.middle = true;
  6189. } else if (e.button == 2) {
  6190. clicks.right = true;
  6191. }
  6192. }
  6193. }
  6194. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6195. function mouseUp(e) {
  6196. if (attackState != 0) {
  6197. attackState = 0;
  6198. if (e.button == 0) {
  6199. clicks.left = false;
  6200. } else if (e.button == 1) {
  6201. clicks.middle = false;
  6202. } else if (e.button == 2) {
  6203. clicks.right = false;
  6204. }
  6205. }
  6206. }
  6207. mals.addEventListener("wheel", wheel, false);
  6208. function wheel(e) {
  6209. if (e.deltaY < 0) {
  6210. my.reSync = true;
  6211. } else {
  6212. my.reSync = false;
  6213. }
  6214. }
  6215. // INPUT UTILS:
  6216. function getMoveDir() {
  6217. let dx = 0;
  6218. let dy = 0;
  6219. for (let key in moveKeys) {
  6220. let tmpDir = moveKeys[key];
  6221. dx += !!keys[key] * tmpDir[0];
  6222. dy += !!keys[key] * tmpDir[1];
  6223. }
  6224. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6225. }
  6226. function getSafeDir() {
  6227. if (!player)
  6228. return 0;
  6229. if (!player.lockDir) {
  6230. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6231. }
  6232. return lastDir || 0;
  6233. }
  6234. function getAttackDir(debug) {
  6235. if (debug) {
  6236. if (!player)
  6237. return "0";
  6238.  
  6239. if (!traps.antiPush&&(my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0))) {
  6240. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6241. } else if (!traps.antiPush&&clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6242. lastDir = "getSafeDir()";
  6243.  
  6244. }else if(traps.antiPush){
  6245. lastDir = traps.antiPush;
  6246. }else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6247. lastDir = "traps.aim";
  6248. } else if (!player.lockDir) {
  6249. if (configs.noDir) return "undefined";
  6250. lastDir = "getSafeDir()";
  6251. }
  6252.  
  6253. return lastDir;
  6254. } else {
  6255. if (!player)
  6256. return 0;
  6257.  
  6258. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6259. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6260. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6261. lastDir = getSafeDir();
  6262. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6263. lastDir = traps.aim;
  6264. } else if (!player.lockDir) {
  6265. if (configs.noDir) return undefined;
  6266. lastDir = getSafeDir();
  6267. }
  6268.  
  6269. return lastDir || 0;
  6270. }
  6271. }
  6272.  
  6273. function getVisualDir() {
  6274. if (!player)
  6275. return 0;
  6276.  
  6277. if (my.autoAim || (isNearPlayer() && clicks.left && player.reloads[player.weapons[0]] == 0)) {
  6278. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6279. } else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  6280. lastDir = getSafeDir();
  6281. } else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0) {
  6282. lastDir = traps.aim;
  6283. } else if (!player.lockDir) {
  6284. lastDir = getSafeDir();
  6285. }
  6286.  
  6287. return lastDir || 0;
  6288. }
  6289.  
  6290. // Funkce pro kontrolu, zda jste pobli? hra?e
  6291. function isNearPlayer() {
  6292. return near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap;
  6293. buyEquip(21, 1);
  6294. }
  6295. // KEYS:
  6296. function keysActive() {
  6297. return (allianceMenu.style.display != "block" &&
  6298. chatHolder.style.display != "block" &&
  6299. !menuCBFocus);
  6300. }
  6301. function toggleMenuChat() {
  6302. if (menuChatDiv.style.display != "none") {
  6303. chatHolder.style.display = "none";
  6304. if (menuChatBox.value != "") {
  6305. //commands[command.slice(1)]
  6306. let cmd = function(command) {
  6307. return {
  6308. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6309. fv: commands[command.slice(1).split(" ")[0]]
  6310. }
  6311. }
  6312. let command = cmd(menuChatBox.value);
  6313. if (command.found) {
  6314. if (typeof command.fv.action === "function") {
  6315. command.fv.action(menuChatBox.value);
  6316. }
  6317. } else {
  6318. sendChat(menuChatBox.value);
  6319. }
  6320. menuChatBox.value = "";
  6321. menuChatBox.blur();
  6322. } else {
  6323. if (menuCBFocus) {
  6324. menuChatBox.blur();
  6325. } else {
  6326. menuChatBox.focus();
  6327. }
  6328. }
  6329. }
  6330. }
  6331.  
  6332. window.botMove = false;
  6333. window.freeCam = {x:null,y:null}
  6334. let switchBotMode = ()=>{
  6335. window.botMove = !window.botMove;
  6336. if(window.botMove){
  6337. window.freeCam = {x:player.x2,y:player.y2}
  6338. }
  6339. }
  6340. window.allowCombo = false;
  6341. window.botVisual = false;
  6342. function keyDown(event) {
  6343. let keyNum = event.which || event.keyCode || 0;
  6344. if (player && player.alive && keysActive()) {
  6345. if (!keys[keyNum]) {
  6346. keys[keyNum] = 1;
  6347. macro[event.key] = 1;
  6348. if (keyNum == 27) {
  6349. openMenu = !openMenu;
  6350. $("#menuDiv").toggle();
  6351. $("#menuChatDiv").toggle();
  6352. } else if (keyNum == 69) {
  6353. sendAutoGather();
  6354. } else if (keyNum == 67) {
  6355. updateMapMarker();
  6356. } else if (player.weapons[keyNum - 49] != undefined) {
  6357. player.weaponCode = player.weapons[keyNum - 49];
  6358. } else if (moveKeys[keyNum]) {
  6359. sendMoveDir();
  6360. } else if (event.key == "m") {
  6361. mills.placeSpawnPads = !mills.placeSpawnPads;
  6362. } else if (event.key == "z") {
  6363. mills.place = !mills.place;
  6364. } else if (event.key == "Z") {
  6365. typeof window.debug == "function" && window.debug();
  6366. } else if (keyNum == 32) {
  6367. packet("d", 1, getSafeDir(), 1);
  6368. packet("d", 0, getSafeDir(), 1);
  6369. } else if (event.key == ",") {
  6370. player.sync = true;
  6371. }else if(event.key == 'x'&&window.VirusterDev){
  6372. sendChat('HaHa'+window.pingTime.toString()+'L'+UTILS.getDistance(near.x, near.y, player.x, player.y))
  6373. window.syncMode = true;
  6374. setTimeout(()=>{
  6375. window.syncMode = false;
  6376. },1000)
  6377. }
  6378.  
  6379. if(window.VirusterDev){//virusterdevs keycombos for bots, u can use if want. is op
  6380. if(event.key == 'q'){
  6381. window.allowCombo = !window.allowCombo
  6382. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'keystroke combo '+(window.allowCombo?'on':'off'), '#fff', 2);
  6383. }
  6384. if(event.key=='1'&&window.allowCombo){
  6385. getEl("mode").value = 'zync'
  6386. window.allowCombo = false
  6387. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'follow', '#fff', 2);
  6388. }
  6389. if(event.key=='2'&&window.allowCombo){
  6390. getEl("mode").value = 'fuckemup'
  6391. window.allowCombo = false
  6392. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'break', '#fff', 2);
  6393. }
  6394. if(event.key=='3'&&window.allowCombo){
  6395. getEl("mode").value = 'fight'
  6396. window.allowCombo = false
  6397. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'on sight', '#fff', 2);
  6398. }
  6399. if(event.key=='4'&&window.allowCombo){
  6400. getEl("mode").value = 'flex'
  6401. window.allowCombo = false
  6402. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'flex', '#fff', 2);
  6403. }
  6404. if(event.key=='5'&&window.allowCombo){
  6405. getEl("mode").value = 'stopp'
  6406. window.stopSpot = {x2:player.x2,y2:player.y2}
  6407. window.allowCombo = false
  6408. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'stop', '#fff', 2);
  6409. }
  6410. if(event.key=='`'&&window.allowCombo){
  6411. getEl("mode").value = 'mouse'
  6412. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'mouse', '#fff', 2);
  6413. window.allowCombo = false
  6414. }
  6415.  
  6416. if(event.key=='x'&&window.allowCombo&&bots.length>1){
  6417.  
  6418. if(window.botVisual == false){
  6419. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'bot freecam on', '#fff', 2);
  6420. window.botVisual = botz[Math.floor(Math.random()*botz.length)].sid
  6421. }else{
  6422. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'bot freecam off', '#fff', 2);
  6423. window.botVisual = false;
  6424. }
  6425. window.allowCombo = false
  6426. } else if(event.key=='x'&&!window.allowCombo&&bots.length>1&&window.botVisual!==false){
  6427. window.botVisual = botz[Math.floor(Math.random()*botz.length)].sid
  6428. window.allowCombo = false
  6429. }
  6430. }
  6431. }
  6432. }
  6433. }
  6434. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6435. function keyUp(event) {
  6436. if (player && player.alive) {
  6437. let keyNum = event.which || event.keyCode || 0;
  6438. if (keyNum == 13) {
  6439. // toggleMenuChat();
  6440. } else if (keysActive()) {
  6441. if (keys[keyNum]) {
  6442. keys[keyNum] = 0;
  6443. macro[event.key] = 0;
  6444. if (moveKeys[keyNum]) {
  6445. sendMoveDir();
  6446. } else if (event.key == ",") {
  6447. player.sync = false;
  6448. }
  6449. }
  6450. }
  6451. }
  6452. }
  6453. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6454. function sendMoveDir() {
  6455. let newMoveDir = getMoveDir();
  6456. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6457. if (!my.autoPush) {
  6458. packet("a", newMoveDir, 1);
  6459. }
  6460. lastMoveDir = newMoveDir;
  6461. }
  6462. }
  6463. // BUTTON EVENTS:
  6464. function bindEvents() { }
  6465. bindEvents();
  6466. /** PATHFIND TEST */
  6467. function chechPathColl(tmp) {
  6468. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6469. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6470. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6471. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6472. }
  6473. function checkObject() {
  6474. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6475. for (let y = 0; y < pathFind.grid; y++) {
  6476. grid[y] = [];
  6477. for (let x = 0; x < pathFind.grid; x++) {
  6478. let tmpXY = {
  6479. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6480. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6481. }
  6482. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6483. pathFind.lastX = x;
  6484. pathFind.lastY = y;
  6485. grid[y][x] = 0;
  6486. continue;
  6487. }
  6488. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6489. if (find) {
  6490. if (find.trap) {
  6491. grid[y][x] = 0;
  6492. continue;
  6493. }
  6494. grid[y][x] = 1;
  6495. } else {
  6496. grid[y][x] = 0;
  6497. }
  6498. }
  6499. }
  6500. }
  6501. function toFancyTimeFormat(time) {
  6502. let minutes = ~~((time % 3600) / 60);
  6503. let seconds = ~~time % 60;
  6504. if (seconds <= 9) seconds = `0${seconds}`;
  6505. return `${minutes}:${seconds}`;
  6506. }
  6507. let song = {
  6508. '0:13': 'Clean up gang with a hoover,',
  6509. '0:15': 'pull up and sweep the street',
  6510. '0:17': 'Told bae book Park Chinois,',
  6511. '0:18': 'the bricks came cheap',
  6512. '0:19': 'this week',
  6513. '0:20': 'Brought out the glee',
  6514. '0:21': 'this week,',
  6515. '0:22': 'so somethin might end up',
  6516. '0:23': 'on a tee this week',
  6517. '0:24': 'Done studio time done the re',
  6518. '0:25': 'this week,',
  6519. '0:26': 'big bustdown',
  6520. '0:27': "that ain't no Jesus piece",
  6521. '0:28': 'No G17,G19 had the G17',
  6522. '0:29': 'then the G19',
  6523. '0:30': 'Had an old .44',
  6524. '0:31': 'but the pin was weak,',
  6525. '0:32': 'still gonna spin if need',
  6526. '0:35': 'Sayin no smoke backstage,',
  6527. '0:36': 'but bro still ask',
  6528. '0:37': 'can we bring it please,',
  6529. '0:38': 'or a ZK at least',
  6530. '0:40': 'You could see me',
  6531. '0:41': 'in tape with the Gs,',
  6532. '0:42': 'bro just got in a',
  6533. '0:43': 'striptape with the Gs',
  6534. '0:44': "Get the drop it's go time,",
  6535. '0:45': 'bro came out with the key',
  6536. '0:47': 'Yo, 38 autos gang said',
  6537. '0:48': 'we need more sweets',
  6538. '0:50': 'Before Halloween,',
  6539. '0:51': 'we was out playin',
  6540. '0:52': 'trick or treat',
  6541. '0:53': 'An opp boy swam and drowned,',
  6542. '0:55': "he didn't kick his feet",
  6543. '0:57': 'Heard that news',
  6544. '0:58': 'I was right by the runaway,',
  6545. '0:59': 'made me feel like bree',
  6546. '1:00': 'This C comes like',
  6547. '1:01': 'a pocket rocket,',
  6548. '1:02': 'now the gang',
  6549. '1:03': 'in central with C',
  6550. '1:04': 'Had my case papers printed,',
  6551. '1:05': 'now I got the monogram',
  6552. '1:06': 'print on me',
  6553. '1:07': 'Runnin throught bells,',
  6554. '1:08': 'throwback run with the 12',
  6555. '1:10': 'Whole 1 cover the scales,',
  6556. '1:11': 'bine at the barbeque,',
  6557. '1:12': 'better cover your girl',
  6558. '1:14': "Hate when they're",
  6559. '1:15': 'runnin their mouth,',
  6560. '1:16': 'see them runnin for help',
  6561. '1:17': "I'm in the Bando,",
  6562. '1:18': 'but let me see my man again,',
  6563. '1:19': "and I'll double the L",
  6564. '1:21': 'We really leave shit drownin,',
  6565. '1:22': "you ain't brought 3",
  6566. '1:23': 'on an outin',
  6567. '1:24': 'Shootouts in',
  6568. '1:25': 'the oldest clothes,',
  6569. '1:26': "you wouldn't believe",
  6570. '1:27': 'these outfits',
  6571. '1:28': 'Foot down no breaks,',
  6572. '1:29': 'tryna leave everythin taped',
  6573. '1:30': 'Asked bout the shotty,',
  6574. '1:31': 'told them I got it',
  6575. '1:32': 'from the farm,',
  6576. '1:33': 'now they think I got from H',
  6577. '1:34': 'Clean up gang with a hoover,',
  6578. '1:36': 'pull up and sweep the street',
  6579. '1:38': 'Told bae book Park Chinois,',
  6580. '1:39': 'the bricks came cheap',
  6581. '1:40': 'this week',
  6582. '1:41': 'Brought out the glee',
  6583. '1:42': 'this week,',
  6584. '1:43': 'so somethin might end up',
  6585. '1:44': 'on a tee this week',
  6586. '1:45': 'Done studio time done the re',
  6587. '1:46': 'this week,',
  6588. '1:47': 'big bustdown',
  6589. '1:48': "that ain't no Jesus piece",
  6590. '1:49': 'No G17,G19 had the G17',
  6591. '1:50': 'then the G19',
  6592. '1:51': 'Had an old .44',
  6593. '1:52': 'but the pin was weak,',
  6594. '1:53': 'still gonna spin if need',
  6595. '1:54': 'Sayin no smoke backstage,',
  6596. '1:55': 'but bro still ask',
  6597. '1:56': 'can we bring it please,',
  6598. '1:57': 'or a ZK at least',
  6599. '1:59': 'This opps in this',
  6600. '2:00': "spliff's sativa,",
  6601. '2:01': 'still put smoke in the whiz,',
  6602. '2:02': 'Khalifa',
  6603. '2:03': "Bad B don't wanna",
  6604. '2:04': 'lock the smoke,',
  6605. '2:05': 'I just gotta love her',
  6606. '2:06': 'and leave her',
  6607. '2:07': 'Yo, had the Liz',
  6608. '2:08': 'come like Peter',
  6609. '2:09': 'and the bujj like Cleveland',
  6610. '2:10': 'This ice in my wrist says',
  6611. '2:11': 'whole lotta money,',
  6612. '2:12': "swear it's comin like BIA",
  6613. '2:14': 'O14 me, Zee had the bruc',
  6614. '2:15': 'back in a bruck down Kia',
  6615. '2:16': "Now you'll find me in Venice,",
  6616. '2:17': 'tryin some shellfish',
  6617. '2:18': 'oh mama mia',
  6618. '2:19': 'Old school I was',
  6619. '2:20': 'hoppin out first,',
  6620. '2:21': 'had bro sayin',
  6621. '2:22': 'stop bein selfish',
  6622. '2:23': 'Yo,',
  6623. '2:24': 'now I just leave that stage,',
  6624. '2:25': 'pullin strings like Elvis',
  6625. '2:26': 'Ding dong on an outin,',
  6626. '2:27': "would've been a loss",
  6627. '2:28': 'if we found him',
  6628. '2:29': "Can't record,",
  6629. '2:30': 'need more points on the board',
  6630. '2:31': 'Gang, tape it first,',
  6631. '2:32': "then I'll give them an album",
  6632. '2:33': 'Spoke to the yard man,',
  6633. '2:34': 'wanna know the P for the .45,',
  6634. '2:35': 'like Alhan',
  6635. '2:36': 'Spoke to the runner,',
  6636. '2:37': "said he's got more than a oner",
  6637. '2:39': "and he's still counting",
  6638. '2:40': 'Go get that car,',
  6639. '2:41': 'congestion zone,',
  6640. '2:42': 'gotta step with ours',
  6641. '2:43': 'Pocket rocket,',
  6642. '2:44': 'had it in a pouch',
  6643. '2:45': 'next to the brush',
  6644. '2:46': 'and the metro card',
  6645. '2:47': 'Double R truck,',
  6646. '2:48': 'stars in the roof,',
  6647. '2:49': 'and we got a seperate star',
  6648. '2:50': "Ain't done it in a Tesla yet,",
  6649. '2:51': 'if we do thats lead',
  6650. '2:52': 'in an electric car',
  6651. '2:53': 'Clean up gang with a hoover,',
  6652. '2:55': 'pull up and sweep the street',
  6653. '2:57': 'Told bae book Park Chinois,',
  6654. '2:58': 'the bricks came cheap',
  6655. '2:59': 'this week',
  6656. '3:00': 'Brought out the glee',
  6657. '3:01': 'this week,',
  6658. '3:02': 'so somethin might end up',
  6659. '3:03': 'on a tee this week',
  6660. '3:04': 'Done studio time done the re',
  6661. '3:05': 'this week,',
  6662. '3:06': 'big bustdown',
  6663. '3:07': "that ain't no Jesus piece",
  6664. '3:08': 'No G17,G19 had the G17',
  6665. '3:09': 'then the G19',
  6666. '3:10': 'Had an old .44',
  6667. '3:11': 'but the pin was weak,',
  6668. '3:12': 'still gonna spin if need',
  6669. '3:13': 'Sayin no smoke backstage,',
  6670. '3:14': 'but bro still ask',
  6671. '3:15': 'can we bring it please,',
  6672. '3:16': 'or a ZK at least',
  6673. '3:19': '!End of song'
  6674. };
  6675. 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");
  6676. let isPlaying = false;
  6677. let currentPart = '';
  6678. function toggleSong() {
  6679. if (!isPlaying) {
  6680. songchat1.play();
  6681. songchat1.ontimeupdate = function(time) {
  6682. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  6683. if (part && part !== currentPart) {
  6684. currentPart = part;
  6685. packet("6", part);
  6686. }
  6687. };
  6688. songchat1.onended = function() {
  6689. if (isPlaying) {
  6690. songchat1.play();
  6691. }
  6692. };
  6693. isPlaying = true;
  6694. } else {
  6695. songchat1.pause();
  6696. isPlaying = false;
  6697. }
  6698. }
  6699. document.addEventListener("keypress", function(e) {
  6700. if (e.key === "C") {
  6701. toggleSong();
  6702. }
  6703. });
  6704. function createPath() {
  6705. grid = [];
  6706. checkObject();
  6707. }
  6708. function Pathfinder() {
  6709. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  6710. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  6711. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6712. packet("a", undefined, 1);
  6713. } else {
  6714. createPath();
  6715. easystar.setGrid(grid);
  6716. easystar.setAcceptableTiles([0]);
  6717. easystar.enableDiagonals();
  6718. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function(path) {
  6719. if (path === null) {
  6720. pathFind.array = [];
  6721. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6722. packet("a", undefined, 1);
  6723. } else {
  6724. packet("a", near.aim2, 1);
  6725. }
  6726. } else {
  6727. pathFind.array = path;
  6728. if (pathFind.array.length > 1) {
  6729. let tmpXY = {
  6730. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  6731. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  6732. }
  6733. packet("a", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  6734. }
  6735. }
  6736. });
  6737. easystar.calculate();
  6738. }
  6739. }
  6740. }
  6741. /** PATHFIND TEST */
  6742. // ITEM COUNT DISPLAY:
  6743. let isItemSetted = [];
  6744. function updateItemCountDisplay(index = undefined) {
  6745. for (let i = 3; i < items.list.length; ++i) {
  6746. let id = items.list[i].group.id;
  6747. let tmpI = items.weapons.length + i;
  6748. if (!isItemSetted[tmpI]) {
  6749. isItemSetted[tmpI] = document.createElement("div");
  6750. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6751. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6752. isItemSetted[tmpI].style = `
  6753. display: block;
  6754. position: absolute;
  6755. padding-left: 5px;
  6756. font-size: 2em;
  6757. color: #fff;
  6758. `;
  6759. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6760. } else {
  6761. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6762. }
  6763. }
  6764. }
  6765. // AUTOPUSH:
  6766. function autoPush() {
  6767. 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) {
  6768. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6769. })[0];
  6770. if (nearTrap) {
  6771. 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) {
  6772. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6773. })[0];
  6774. if (spike) {
  6775. let pos = {
  6776. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6777. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6778. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6779. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6780. };
  6781. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6782. let tmpScale = tmp.getScale();
  6783. 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)) {
  6784. return true;
  6785. }
  6786. });
  6787. if (finds) {
  6788. if (my.autoPush) {
  6789. my.autoPush = false;
  6790. packet("a", lastMoveDir || undefined, 1);
  6791. }
  6792. } else {
  6793. my.autoPush = true;
  6794. my.pushData = {
  6795. x: spike.x + 70,
  6796. y: spike.y + 70,
  6797. x2: pos.x2 + 30,
  6798. y2: pos.y2 + 30
  6799. };
  6800. let scale = player.scale / 10;
  6801. let secondArg = UTILS.getDirect(near, spike, 2, 0) > 70 ? near.aim2 : undefined;
  6802. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6803. packet("a", secondArg, 1);
  6804. } else {
  6805. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6806. }
  6807. }
  6808. } else {
  6809. if (my.autoPush) {
  6810. my.autoPush = false;
  6811. packet("a", lastMoveDir || undefined, 1);
  6812. }
  6813. }
  6814. } else {
  6815. if (my.autoPush) {
  6816. my.autoPush = false;
  6817. packet("a", lastMoveDir || undefined, 1);
  6818. }
  6819. }
  6820. }
  6821. // AUTOPUSH:
  6822. /* function autoPush() { //LEGACY AUTOPUSH
  6823. 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) {
  6824. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6825. })[0];
  6826. if (nearTrap) {
  6827. 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) {
  6828. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6829. })[0];
  6830. if (spike) {
  6831. let pos = {
  6832. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6833. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6834. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6835. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6836. };
  6837. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6838. let tmpScale = tmp.getScale();
  6839. 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)) {
  6840. return true;
  6841. }
  6842. });
  6843. if (finds) {
  6844. if (my.autoPush) {
  6845. my.autoPush = false;
  6846. packet("33", lastMoveDir||undefined, 1);
  6847. }
  6848. } else {
  6849. my.autoPush = true;
  6850. my.pushData = {
  6851. x: spike.x,
  6852. y: spike.y,
  6853. x2: pos.x2,
  6854. y2: pos.y2
  6855. };
  6856. let scale = (player.scale / 10);
  6857. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6858. packet("33", near.aim2, 1);
  6859. } else {
  6860. packet("33", UTILS.getDirect(pos, player, 2, 2), 1);
  6861. }
  6862. }
  6863. } else {
  6864. if (my.autoPush) {
  6865. my.autoPush = false;
  6866. packet("33", lastMoveDir||undefined, 1);
  6867. }
  6868. }
  6869. } else {
  6870. if (my.autoPush) {
  6871. my.autoPush = false;
  6872. packet("33", lastMoveDir||undefined, 1);
  6873. }
  6874. }
  6875. }*/
  6876. // ADD DEAD PLAYER:
  6877. function addDeadPlayer(tmpObj) {
  6878. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6879. }
  6880. /** APPLY SOCKET CODES */
  6881. // SET INIT DATA:
  6882. function setInitData(data) {
  6883. alliances = data.teams;
  6884. }
  6885. // SETUP GAME:
  6886. var fisrtloadez = false;
  6887. function setupGame(yourSID) {
  6888. keys = {};
  6889. macro = {};
  6890. playerSID = yourSID;
  6891. attackState = 0;
  6892. inGame = true;
  6893. fisrtloadez = true;
  6894. packet("d", 0, getAttackDir(), 1);
  6895. my.ageInsta = true;
  6896. if (firstSetup) {
  6897. firstSetup = false;
  6898. gameObjects.length = 0;
  6899. }
  6900. }
  6901. // ADD NEW PLAYER:
  6902. function addPlayer(data, isYou) {
  6903. let tmpPlayer = findPlayerByID(data[0]);
  6904. if (!tmpPlayer) {
  6905. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6906. objectManager, players, ais, items, hats, accessories);
  6907. players.push(tmpPlayer);
  6908. if (data[1] != playerSID) {
  6909. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6910. }
  6911. } else {
  6912. if (data[1] != playerSID) {
  6913. addChatLog("Encountered " + data[2], "#23BD86", "", "#23BD86");
  6914. }
  6915. }
  6916. tmpPlayer.spawn(isYou ? true : null);
  6917. tmpPlayer.visible = false;
  6918. tmpPlayer.oldPos = {
  6919. x2: undefined,
  6920. y2: undefined
  6921. };
  6922. tmpPlayer.x2 = undefined;
  6923. tmpPlayer.y2 = undefined;
  6924. tmpPlayer.x3 = undefined;
  6925. tmpPlayer.y3 = undefined;
  6926. tmpPlayer.setData(data);
  6927. if (isYou) {
  6928. if (!player) {
  6929. window.prepareUI(tmpPlayer);
  6930. }
  6931. player = tmpPlayer;
  6932. camX = player.x;
  6933. camY = player.y;
  6934. my.lastDir = 0;
  6935. updateItems();
  6936. updateAge();
  6937. updateItemCountDisplay();
  6938. if (player.skins[7]) {
  6939. my.reSync = true;
  6940. }
  6941. }
  6942. }
  6943. // REMOVE PLAYER:
  6944. function removePlayer(id) {
  6945. for (let i = 0; i < players.length; i++) {
  6946. if (players[i].id == id) {
  6947. let tmpPlayer = players[i];
  6948. addChatLog(tmpPlayer.name + " has died", "#db2727", "", "#db2727");
  6949. players.splice(i, 1);
  6950. break;
  6951. }
  6952. }
  6953. }
  6954. // UPDATE HEALTH:
  6955. function updateHealth(sid, value) {
  6956. tmpObj = findPlayerBySID(sid);
  6957. if (tmpObj) {
  6958. tmpObj.oldHealth = tmpObj.health;
  6959. tmpObj.health = value;
  6960. tmpObj.judgeShame();
  6961. if (tmpObj.oldHealth > tmpObj.health) {
  6962. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6963. if(sid == player.sid){
  6964. proheal[0] = Date.now()
  6965. proheal[1] = value;
  6966. }
  6967. advHeal.push([sid, value, tmpObj.damaged]);
  6968. } else {
  6969. }
  6970. }
  6971. }
  6972. // KILL PLAYER:
  6973. function killPlayer() {
  6974. inGame = false;
  6975. lastDeath = {
  6976. x: player.x,
  6977. y: player.y,
  6978. };
  6979. if (configs.autoRespawn) {
  6980. getEl("ot-sdk-btn-floating").style.display = "none";
  6981. packet("M", {
  6982. name: lastsp[0],
  6983. moofoll: lastsp[1],
  6984. skin: lastsp[2]
  6985. });
  6986. }
  6987. }
  6988. // UPDATE PLAYER ITEM VALUES:
  6989. function updateItemCounts(index, value) {
  6990. if (player) {
  6991. player.itemCounts[index] = value;
  6992. updateItemCountDisplay(index);
  6993. }
  6994. }
  6995. // UPDATE AGE:
  6996. function updateAge(xp, mxp, age) {
  6997. if (xp != undefined)
  6998. player.XP = xp;
  6999. if (mxp != undefined)
  7000. player.maxXP = mxp;
  7001. if (age != undefined)
  7002. player.age = age;
  7003. }
  7004. // UPDATE UPGRADES:
  7005. function updateUpgrades(points, age) {
  7006. player.upgradePoints = points;
  7007. player.upgrAge = age;
  7008. if (points > 0) {
  7009. tmpList.length = 0;
  7010. UTILS.removeAllChildren(upgradeHolder);
  7011. for (let i = 0; i < items.weapons.length; ++i) {
  7012. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  7013. let e = UTILS.generateElement({
  7014. id: "upgradeItem" + i,
  7015. class: "actionBarItem",
  7016. onmouseout: function() {
  7017. showItemInfo();
  7018. },
  7019. parent: upgradeHolder
  7020. });
  7021. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  7022. tmpList.push(i);
  7023. }
  7024. }
  7025. for (let i = 0; i < items.list.length; ++i) {
  7026. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  7027. let tmpI = (items.weapons.length + i);
  7028. let e = UTILS.generateElement({
  7029. id: "upgradeItem" + tmpI,
  7030. class: "actionBarItem",
  7031. onmouseout: function() {
  7032. showItemInfo();
  7033. },
  7034. parent: upgradeHolder
  7035. });
  7036. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  7037. tmpList.push(tmpI);
  7038. }
  7039. }
  7040. for (let i = 0; i < tmpList.length; i++) {
  7041. (function(i) {
  7042. let tmpItem = getEl('upgradeItem' + i);
  7043. tmpItem.onmouseover = function() {
  7044. if (items.weapons[i]) {
  7045. showItemInfo(items.weapons[i], true);
  7046. } else {
  7047. showItemInfo(items.list[i - items.weapons.length]);
  7048. }
  7049. };
  7050. tmpItem.onclick = UTILS.checkTrusted(function() {
  7051. packet("H", i);
  7052. });
  7053. UTILS.hookTouchEvents(tmpItem);
  7054. })(tmpList[i]);
  7055. }
  7056. if (tmpList.length) {
  7057. upgradeHolder.style.display = "block";
  7058. upgradeCounter.style.display = "block";
  7059. upgradeCounter.style.borderRadius = "4px";
  7060. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  7061. } else {
  7062. upgradeHolder.style.display = "none";
  7063. upgradeCounter.style.display = "none";
  7064. showItemInfo();
  7065. }
  7066. } else {
  7067. upgradeHolder.style.display = "none";
  7068. upgradeCounter.style.display = "none";
  7069. showItemInfo();
  7070. }
  7071. }
  7072. function cdf(e, t) {
  7073. try {
  7074. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7075. } catch (e) {
  7076. return Infinity;
  7077. }
  7078. }
  7079. function caf(e, t) {
  7080. try {
  7081. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7082. } catch (e) {
  7083. return 0;
  7084. }
  7085. }
  7086. function numArr(e = 0, t = 1, act, n = 1) {
  7087. let arr = [];
  7088. for (let i = e; i < t; i += n) {
  7089. arr.push(i);
  7090. typeof act == "function" && act(i);
  7091. }
  7092. return arr;
  7093. }
  7094. function toR(e) {
  7095. var n = (e * Math.PI / 180) % (2 * Math.PI);
  7096. return n > Math.PI ? Math.PI - n : n
  7097. }
  7098. function toD(e) {
  7099. var n = (e / Math.PI * 360) % 360;
  7100. return n >= 360 ? n - 360 : n;
  7101. }
  7102.  
  7103. // KILL OBJECT:
  7104. function killObject(sid) {
  7105. let findObj = findObjectBySid(sid);
  7106. objectManager.disableBySid(sid);
  7107. if (player) {
  7108. for (let i = 0; i < breakObjects.length; i++) {
  7109. if (breakObjects[i].sid == sid) {
  7110. breakObjects.splice(i, 1);
  7111. break;
  7112. }
  7113. }
  7114. if (!player.canSee(findObj)) {
  7115. breakTrackers.push({x: findObj.x, y: findObj.y});
  7116. }
  7117. if (breakTrackers.length > 8) {
  7118. breakTrackers.shift();
  7119. }
  7120. traps.replacer(findObj);
  7121. }
  7122. }
  7123. // KILL ALL OBJECTS BY A PLAYER:
  7124. function killObjects(sid) {
  7125. if (player) objectManager.removeAllItems(sid);
  7126. }
  7127. function fgdo(a, b) {
  7128. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  7129. }
  7130. function precheckPlace(a, b) {
  7131. checkPlace(a, b);
  7132. console.log('success');
  7133. }
  7134. function perfectReplace() {
  7135. // let range = items.weapons[player.weapons[0]].range + 70;
  7136. // const interval = setInterval(() => {
  7137. // gameObjects.forEach(tmpObj => {
  7138. // let objDst = UTILS.getDist(tmpObj, player, 0, 2);
  7139. // let perfectAngle = UTILS.getDirect(tmpObj, player, 0, 2);
  7140. // if (tmpObj.health <= 272.58 && fgdo(tmpObj, player) <= range && near.dist2 <= 300) {
  7141. // console.log('preplace');
  7142. // place(2, perfectAngle);
  7143. // }
  7144. // });
  7145. // });
  7146. // setTimeout(() => {
  7147. // clearInterval(interval);
  7148. // }, 500);
  7149. }
  7150. let ticks = {
  7151. tick: 0,
  7152. delay: 0,
  7153. time: [],
  7154. manage: [],
  7155. };
  7156. // GAME TICKOUT:
  7157. function setTickout(doo, timeout) {
  7158. if (!ticks.manage[ticks.tick + timeout]) {
  7159. ticks.manage[ticks.tick + timeout] = [doo];
  7160. } else {
  7161. ticks.manage[ticks.tick + timeout].push(doo);
  7162. }
  7163. }
  7164. function doNextTick(doo) {
  7165. waitTicks.push(doo);
  7166. }
  7167. let waitTicks = [];
  7168. // UPDATE PLAYER DATA:
  7169. let nEy;
  7170. let plaguemask = true;
  7171. let placeableSpikes = [];
  7172. let placeableTraps = [];
  7173. let placeableSpikesPREDICTS = [];
  7174. function updatePlayers(data) {
  7175. game.tick++;
  7176. enemy = [];
  7177. perfectReplace();
  7178. nears = [];
  7179. near = [];
  7180. //showPlace = [];
  7181. game.tickSpeed = performance.now() - game.lastTick;
  7182. game.lastTick = performance.now();
  7183. if(proheal[1]!==100&&Date.now()-proheal[0]>=130-window.pingTime){//i was too lazy to add ping scopes and calculate average ping
  7184. healer();
  7185. proheal[1] = 100;
  7186. }
  7187. ticks.tick++;
  7188. ticks.time.push(Date.now() - ticks.delay <= 50 || Date.now() - ticks.delay >= 175 ? "lag" : 1);
  7189. if (ticks.tick % 10 === 0) {
  7190. ticks.time = [];
  7191. }
  7192. if (ticks.tick % 300 === 0) {
  7193. }
  7194. ticks.delay = Date.now();
  7195. players.forEach((tmp) => {
  7196. tmp.forcePos = !tmp.visible;
  7197. tmp.visible = false;
  7198. });
  7199. for (let i = 0; i < data.length;) {
  7200. tmpObj = findPlayerBySID(data[i]);
  7201. if (tmpObj) {
  7202. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7203. tmpObj.t2 = game.lastTick;
  7204. tmpObj.oldPos.x2 = tmpObj.x2;
  7205. tmpObj.oldPos.y2 = tmpObj.y2;
  7206. tmpObj.x1 = tmpObj.x;
  7207. tmpObj.y1 = tmpObj.y;
  7208. tmpObj.x2 = data[i + 1];
  7209. tmpObj.y2 = data[i + 2];
  7210. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7211. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7212. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7213. tmpObj.d2 = data[i + 3];
  7214. tmpObj.dt = 0;
  7215. tmpObj.buildIndex = data[i + 4];
  7216. tmpObj.weaponIndex = data[i + 5];
  7217. tmpObj.weaponVariant = data[i + 6];
  7218. tmpObj.team = data[i + 7];
  7219. tmpObj.isLeader = data[i + 8];
  7220. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7221. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7222. tmpObj.skinIndex = data[i + 9];
  7223. tmpObj.tailIndex = data[i + 10];
  7224. tmpObj.iconIndex = data[i + 11];
  7225. tmpObj.zIndex = data[i + 12];
  7226. tmpObj.visible = true;
  7227. tmpObj.update(game.tickSpeed);
  7228. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7229. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7230. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7231. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7232. tmpObj.damageThreat = 0;
  7233. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7234. tmpObj.addShameTimer();
  7235. }
  7236. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7237. tmpObj.shameTimer = 0;
  7238. tmpObj.shameCount = 0;
  7239. if (tmpObj == player) {
  7240. healer();
  7241. }
  7242. }
  7243. nEy = tmpObj;
  7244. if (tmpObj == player) {
  7245. if (gameObjects.length) {
  7246. gameObjects.forEach((tmp) => {
  7247. if(true && tmp.active && tmp.dmg &&tmp.owner.sid!==player.sid&&!player.isTeam(tmp.owner) && player.secondaryIndex == 10 &&player.skins[40]&& /*UTILS.getDist(tmp, player, 0, 2)*/UTILS.getDistance(tmp.x, tmp.y, player.x2 + (player.oldPos.x2 - player.x2) * -1, player.y2 + (player.oldPos.y2 - player.y2) * -1) <= (tmp.scale + items.weapons[player.weapons[1]].range) && /*player.reloads[player.weapons[0]] == 0*/ player.reloads[player.secondaryIndex] == 0 /* && player.reloads[player.primaryIndex] >= 0.90*/){
  7248. //console.log('test')
  7249. let can = true;
  7250. if(window.lastBreakTrigger){
  7251. if(Date.now() - window.lastBreakTrigger > 400){
  7252. can = true
  7253. }else{
  7254. can=false
  7255. }
  7256. window.lastBreakTrigger = Date.now()
  7257. }else{
  7258. can = true;
  7259. window.lastBreakTrigger = Date.now()
  7260. }
  7261. traps.antiPush = UTILS.getDirect(tmp, player, 0, 2);
  7262. selectWeapon(player.weapons[1])
  7263. buyEquip(40, 0);
  7264. clicks.right = true;
  7265. game.tickBase(() => {
  7266. clicks.right = false
  7267. traps.antiPush = false
  7268. buyEquip(6, 0);
  7269. }, 1);
  7270. }
  7271. tmp.onNear = false;
  7272. if (tmp.active) {
  7273. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7274. tmp.onNear = true;
  7275. }
  7276. if (tmp.isItem && tmp.owner) {
  7277. 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)) {
  7278. tmp.breakObj = true;
  7279. breakObjects.push({
  7280. x: tmp.x,
  7281. y: tmp.y,
  7282. sid: tmp.sid
  7283. });
  7284. }
  7285. }
  7286. }
  7287. });
  7288. 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) {
  7289. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7290. })[0];
  7291. if (nearTrap) {
  7292. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7293. traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7294. if (!traps.inTrap) {
  7295. traps.protect(traps.aim);
  7296. }
  7297. traps.inTrap = true;
  7298. traps.info = nearTrap;
  7299. } else {
  7300. traps.inTrap = false;
  7301. traps.info = {};
  7302. }
  7303. } else {
  7304. traps.inTrap = false;
  7305. }
  7306. }
  7307. if (tmpObj.weaponIndex < 9) {
  7308. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7309. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7310. } else if (tmpObj.weaponIndex > 8) {
  7311. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7312. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7313. }
  7314. }
  7315. i += 13;
  7316. }
  7317. if (waitTicks.length) {
  7318. waitTicks.forEach((ajaj) => {
  7319. ajaj();
  7320. }
  7321. );
  7322. waitTicks = [];
  7323. }
  7324. if (runAtNextTick.length) {
  7325. runAtNextTick.forEach((tmp) => {
  7326. checkProjectileHolder(...tmp);
  7327. }
  7328. );
  7329. runAtNextTick = [];
  7330. }
  7331. if (textManager.stack.length) {
  7332. let stacks = [];
  7333. let notstacks = [];
  7334. let num = 0;
  7335. let num2 = 0;
  7336. let pos = {
  7337. x: null,
  7338. y: null
  7339. };
  7340. let pos2 = {
  7341. x: null,
  7342. y: null
  7343. }
  7344. textManager.stack.forEach((text) => {
  7345. if (text.value >= 0) {
  7346. if (num == 0) pos = {
  7347. x: text.x,
  7348. y: text.y
  7349. };
  7350. num += Math.abs(text.value);
  7351. } else {
  7352. if (num2 == 0) pos2 = {
  7353. x: text.x,
  7354. y: text.y
  7355. };
  7356. num2 += Math.abs(text.value);
  7357. }
  7358. });
  7359. if (num2 > 0) {
  7360. textManager.showText(pos2.x, pos2.y, Math.max(43, Math.min(50, num2)), 0.18, 500, num2, damageTextColor = "#782F44");
  7361. }
  7362. if (num > 0) {
  7363. textManager.showText(pos.x, pos.y, Math.max(43, Math.min(50, num)), 0.18, 500, num, damageTextColor = "#782F44");
  7364. }
  7365. textManager.stack = [];
  7366. }
  7367. if (runAtNextTick.length) {
  7368. runAtNextTick.forEach((tmp) => {
  7369. checkProjectileHolder(...tmp);
  7370. });
  7371. runAtNextTick = [];
  7372. }
  7373. let teams = []
  7374. for (let i = 0; i < data.length;) {
  7375. tmpObj = findPlayerBySID(data[i]);
  7376. if (tmpObj) {
  7377. if (!tmpObj.isTeam(player)) {
  7378. enemy.push(tmpObj);
  7379. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7380. nears.push(tmpObj);
  7381. }
  7382. }else if(tmpObj.sid !== player.sid){
  7383. teams.push(tmpObj)
  7384. }
  7385. tmpObj.manageReload();
  7386. if (tmpObj != player) {
  7387. tmpObj.addDamageThreat(player);
  7388. }
  7389. }
  7390. i += 13;
  7391. }
  7392. /*projectiles.forEach((proj) => {
  7393. tmpObj = proj;
  7394. if (tmpObj.active) {
  7395. tmpObj.tickUpdate(game.tickSpeed);
  7396. }
  7397. });*/
  7398. if (player && player.alive) {
  7399. if (enemy.length) {
  7400. if (player && player.alive){
  7401. placeableSpikes = getPlaceablePositions(player, items.list[player.items[2]]);
  7402. placeableTraps = player.items[4] == 15 ? getPlaceablePositions(player, items.list[player.items[4]]) : [];
  7403. }
  7404.  
  7405. near = enemy.sort(function(tmp1, tmp2) {
  7406. return tmp1.dist2 - tmp2.dist2;
  7407. })[0];
  7408. if(teams.length&&window.VirusterDev){
  7409. teams.forEach((teammate)=>{
  7410. let tmp = near;
  7411. 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){
  7412. if(teammate.weaponIndex == teammate.primaryIndex && player.weaponIndex == player.primaryIndex){
  7413. clicks.left = true
  7414. top.sycin = true
  7415. top.lastSync = Date.now();
  7416. }else if(player.weaponIndex !== player.primaryIndex){
  7417. selectWeapon(player.primaryIndex)
  7418. }
  7419. }
  7420. //ezz
  7421. })
  7422. }
  7423. } else {
  7424. // console.log("no enemy");
  7425. }
  7426. if (game.tickQueue[game.tick]) {
  7427. game.tickQueue[game.tick].forEach((action) => {
  7428. action();
  7429. });
  7430. game.tickQueue[game.tick] = null;
  7431. }
  7432. if (advHeal.length) {
  7433. advHeal.forEach((updHealth) => {
  7434. let sid = updHealth[0];
  7435. let value = updHealth[1];
  7436. let totalDamage = 100 - value
  7437. let damaged = updHealth[2];
  7438. tmpObj = findPlayerBySID(sid);
  7439. let bullTicked = false;
  7440. if (tmpObj && tmpObj.health <= 0) {
  7441. if (!tmpObj.death) {
  7442. tmpObj.death = true;
  7443. if(top.lastSync&&(Date.now() - top.lastSync) < 500){
  7444. textManager.showText(tmpObj.x, tmpObj.y, 20, 0.15, 1850, 'Get Synced Nub', '#f00', 2);
  7445. setTimeout(()=>{sendChat('what is sync?')},500)
  7446. }
  7447. if (tmpObj != player) {
  7448. addChatLog(tmpObj.name + " has died", "#db2727", "", "#db2727");
  7449. }
  7450. addDeadPlayer(tmpObj);
  7451. }
  7452. }
  7453. if (tmpObj == player) {
  7454. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7455. if (my.reSync) {
  7456. my.reSync = false;
  7457. tmpObj.setBullTick = true;
  7458. }
  7459. bullTicked = true;
  7460. }
  7461. if (inGame) {
  7462. let dmg = 100 - player.health;
  7463. let attackers = getAttacker(damaged);
  7464. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7465. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  7466. let heal = function () {
  7467. /*
  7468. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && clicks.left)) {
  7469. setTimeout(() => {
  7470. healer();
  7471. }, 140 - window.pingTime);
  7472. } else {
  7473. setTimeout(() => {
  7474. healer()
  7475. }, 222 - window.pingTime);
  7476. }*/
  7477. }
  7478. if (attackers.length) {
  7479. let by = attackers.filter((tmp) => {
  7480. if (tmp.dist2 <= (tmp.weaponIndex < 9 ? 300 : 700)) {
  7481. tmpDir = UTILS.getDirect(player, tmp, 2, 2);
  7482. if (UTILS.getAngleDist(tmpDir, tmp.d2) <= Math.PI) {
  7483. return tmp;
  7484. }
  7485. }
  7486. });
  7487. if (by.length) {
  7488. let maxDamage = (includeSpikeDmgs ? 10 : 10);
  7489. if (damaged > maxDamage && (game.tick - tmpObj.antiTimer) > 1) {
  7490. tmpObj.canEmpAnti = true;
  7491. tmpObj.antiTimer = game.tick;
  7492. if (tmpObj.shameCount < 4) {
  7493. //healer();
  7494. } else {
  7495. heal();
  7496. }
  7497. } else {
  7498. heal();
  7499. }
  7500. } else {
  7501. heal();
  7502. }
  7503. } else {
  7504. heal();
  7505. }
  7506. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7507. }
  7508. } else {
  7509. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7510. tmpObj.setPoisonTick = true;
  7511. }
  7512. }
  7513. });
  7514. advHeal = [];
  7515. }
  7516. players.forEach((tmp) => {
  7517. if (!tmp.visible && player != tmp) {
  7518. tmp.reloads = {
  7519. 0: 0,
  7520. 1: 0,
  7521. 2: 0,
  7522. 3: 0,
  7523. 4: 0,
  7524. 5: 0,
  7525. 6: 0,
  7526. 7: 0,
  7527. 8: 0,
  7528. 9: 0,
  7529. 10: 0,
  7530. 11: 0,
  7531. 12: 0,
  7532. 13: 0,
  7533. 14: 0,
  7534. 15: 0,
  7535. 53: 0,
  7536. };
  7537. }
  7538. if (tmp.setBullTick) {
  7539. tmp.bullTimer = 0;
  7540. }
  7541. if (tmp.setPoisonTick) {
  7542. tmp.poisonTimer = 0;
  7543. }
  7544. tmp.updateTimer();
  7545. });
  7546. if (inGame) {
  7547. ping = window.pingTime
  7548. inWater = player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2
  7549. if (enemy.length) {
  7550. if (configs1.AutoQonSync && nears.length > 1 && player.shameCount < 5 && !nears.some(item => [0, 7, 8, 9].includes(item.primaryIndex)) && secPacket < 40) {
  7551. sendChat("sync detect test")
  7552. tmpObj.canEmpAnti = false
  7553. my.anti0Tick = 3
  7554. predictHeal(2)
  7555. if (player.health < 90) {
  7556. //healer()
  7557. }
  7558. }
  7559. if (configs1.AutoQonHigh && ping >= 80) {
  7560. let dmg = 100 - player.health
  7561. if ((tmpObj.damageThreat >= 95 || dmg + tmpObj.damageThreat >= 95) && player.skinIndex != 7 && player.shameCount < 5) {
  7562. //predictHeal(2)
  7563. } else {
  7564. setTimeout(() => {
  7565. //healer()
  7566. }, 120 - ping)
  7567. }
  7568. }
  7569. if (configs.fpsboost) {
  7570. window.location.native_resolution = true;
  7571. setTimeout(() => {
  7572. console.clear
  7573. }, 2000);
  7574. }
  7575. if (configs1.AutoPlace) {
  7576. autoplacer()
  7577. }
  7578. packetData.placeQ = packetData.place;
  7579. packetData.place = [];
  7580. if (packetData.placeQ.length) for (let i = 0; i < packetData.placeQ.length; i++) {
  7581. 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])) {
  7582. place(packetData.placeQ[i][0], packetData.placeQ[i][1]);
  7583. }
  7584. }
  7585. if (player.canEmpAnti) {
  7586. player.canEmpAnti = false;
  7587. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7588. if (near.reloads[53] == 0) {
  7589. player.empAnti = true;
  7590. player.soldierAnti = false;
  7591. //modLog("EmpAnti");
  7592. } else {
  7593. player.empAnti = false;
  7594. player.soldierAnti = true;
  7595. //modLog("SoldierAnti");
  7596. }
  7597. }
  7598. }
  7599. 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) {
  7600. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7601. })[0];
  7602. if (prehit) {
  7603. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs1.AutoPredictTick) {
  7604. instaC.canSpikeTick = true;
  7605. instaC.syncHit = true;
  7606. if (instaC.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7607. instaC.revTick = true;
  7608. }
  7609. }
  7610. }
  7611. 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) {
  7612. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7613. })[0];
  7614. let moreAntiSpikeTick = traps.checkSpikeTick()
  7615. if (antiSpikeTick && !traps.inTrap) {
  7616. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7617. my.anti0Tick = 1;
  7618. }
  7619. }
  7620. if (moreAntiSpikeTick) {
  7621. my.anti0Tick = 4;
  7622. }
  7623. }
  7624. nears.forEach((tmpPlayer) => {
  7625. if (tmpPlayer.primaryIndex == 5 && tmpPlayer.primaryVariant >= 2) {
  7626. if (tmpPlayer.dist2 >= 160 && tmpPlayer.dist2 < 260) {
  7627. if (tmpPlayer.skinIndex == 53) {
  7628. buyEquip(6, 0);
  7629. }
  7630. }
  7631. }
  7632. })
  7633. if ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100) &&
  7634. near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 &&
  7635. (instaC.wait || (Math.floor(Math.random() * 5) == 0)) &&
  7636. !instaC.isTrue &&
  7637. !my.waitHit &&
  7638. player.reloads[player.weapons[0]] == 0 &&
  7639. player.reloads[player.weapons[1]] == 0 &&
  7640. (getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) &&
  7641. instaC.perfCheck(player, near)) {
  7642.  
  7643. if (player.checkCanInsta(true) >= 100) {
  7644. instaC.nobull = false;
  7645. } else {
  7646. instaC.nobull = false; // Note: This line seems redundant in the original code
  7647. }
  7648.  
  7649. instaC.can = true;
  7650. } else {
  7651. instaC.can = false;
  7652. }
  7653.  
  7654. macro.q && place(0, getAttackDir());
  7655. macro.f && place(4, getSafeDir());
  7656. macro.v && place(2, getSafeDir());
  7657. macro.y && place(5, getSafeDir());
  7658. macro.h && place(player.getItemType(22), getSafeDir());
  7659. macro.n && place(3, getSafeDir());
  7660.  
  7661. if (game.tick % 3 == 0) {
  7662. if (mills.place) {
  7663. let plcAng = 1.25;
  7664. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7665. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7666. }
  7667. } else {
  7668. if (mills.placeSpawnPads) {
  7669. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7670. checkPlace(
  7671. player.getItemType(20),
  7672. UTILS.getDirect(player.oldPos, player, 2, 2) + i
  7673. );
  7674. }
  7675. }
  7676. }
  7677. }
  7678.  
  7679. if (instaC.can) {
  7680. instaC.changeType("rev");
  7681. }
  7682.  
  7683. if (instaC.canCounter) {
  7684. instaC.canCounter = false;
  7685. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7686. instaC.counterType();
  7687. }
  7688. }
  7689.  
  7690. if (instaC.canSpikeTick) {
  7691. instaC.canSpikeTick = false;
  7692. if (instaC.revTick) {
  7693. instaC.revTick = false;
  7694. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7695. instaC.changeType("rev");
  7696. }
  7697. } else {
  7698. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7699. instaC.spikeTickType();
  7700. if (instaC.syncHit) {
  7701. }
  7702. }
  7703. }
  7704. }
  7705. let turretEmp = 0;
  7706. let inbullspam = false;
  7707. let waitTicks = [];
  7708. let anti0Tick = 0;
  7709. let syncCount = 0;
  7710. let doEmpAntiInsta = false;
  7711. let plagueCount = 0;
  7712. 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) {
  7713. setTimeout(() => {
  7714. if (player.weaponIndex !== player.weapons[0] || player.buildIndex > -1) {
  7715. selectWeapon(player.weapons[0]);
  7716. }
  7717. if (player.reloads[player.weapons[0]] === 0 && !my.waitHit) {
  7718. sendAutoGather();
  7719. my.waitHit = 1;
  7720. my.autoAim = true;
  7721. inbullspam = true;
  7722. Hg(!plaguemask ? 7 : 21, 18);
  7723. game.tickBase(() => {
  7724. sendAutoGather();
  7725. my.waitHit = 0;
  7726. my.autoAim = false;
  7727. inbullspam = false;
  7728. Hg(near.skinIndex === 7 ? near.antiBull > 0 ? 11 : 6 : 6, 21);
  7729. }, 10);
  7730. }
  7731. }, 5);
  7732. } else {
  7733. inbullspam = false;
  7734. }
  7735.  
  7736. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7737. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7738. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7739. }
  7740. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7741. sendAutoGather();
  7742. my.waitHit = 1;
  7743. game.tickBase(() => {
  7744. sendAutoGather();
  7745. my.waitHit = 0;
  7746. if(clicks.left && top.sycin){
  7747. clicks.left = false
  7748. top.sycin = false
  7749. }
  7750. }, 1);
  7751. }
  7752. }
  7753. if (traps.inTrap) {
  7754. if(traps.antiPush == undefined || traps.antiPush == null){
  7755. traps.antiPush = false
  7756. }
  7757. if (!clicks.left && !clicks.right && !instaC.isTrue&&!traps.antiPush) {
  7758. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7759. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7760. }
  7761. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7762. sendAutoGather();
  7763. my.waitHit = 1;
  7764. invisBody = true;
  7765. game.tickBase(() => {
  7766. sendAutoGather();
  7767. my.waitHit = 0;
  7768. invisBody = false;
  7769. }, 1);
  7770. }
  7771. }
  7772. }
  7773. if (clicks.middle && !traps.inTrap) {
  7774. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7775. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7776. instaC.bowMovement();
  7777. } else {
  7778. instaC.rangeType();
  7779. }
  7780. }
  7781. }
  7782. if (macro.t && !traps.inTrap) {
  7783. 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))) {
  7784. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7785. }
  7786. }
  7787. if (macro["."] && !traps.inTrap) {
  7788. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7789. instaC.boostTickMovement();
  7790. }
  7791. }
  7792. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue) {
  7793. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7794. if (!my.reloaded) {
  7795. my.reloaded = true;
  7796. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7797. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7798. selectWeapon(player.weapons[fastSpeed]);
  7799. }
  7800. }
  7801. } else {
  7802. my.reloaded = false;
  7803. if (player.reloads[player.weapons[0]] > 0) {
  7804. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7805. selectWeapon(player.weapons[0]);
  7806. }
  7807. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7808. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7809. selectWeapon(player.weapons[1]);
  7810. }
  7811. }
  7812. }
  7813. }
  7814. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7815. packet("D", getAttackDir());
  7816. }
  7817. let hatChanger = function() {
  7818. if (my.anti0Tick > 0) {
  7819. buyEquip(6, 0);
  7820. } else {
  7821. if ((!enemy.length || tmpObj.mostDamageThreat <= 95) && player.shameCount > 0 && (player.skinIndex != 45) || my.reSync) {
  7822. buyEquip(7, 0);
  7823. } else {
  7824. if (clicks.left || clicks.right || traps.antiPush) {
  7825. if (clicks.left) {
  7826. 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);
  7827. } else if (clicks.right||traps.antiPush) {
  7828. 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);
  7829. }
  7830. } else if (traps.inTrap) {
  7831. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7832. buyEquip(40, 0);
  7833. if (near.dist2 > 300 && (!player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7834. buyEquip(6, 0);
  7835. }
  7836. } else {
  7837. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 6 : 22, 0);
  7838. }
  7839. } else {
  7840. if (player.empAnti || player.soldierAnti) {
  7841. buyEquip(player.empAnti ? 6 : 40, 0);
  7842. } else {
  7843. if (inWater) {
  7844. if (!configs1.alwaysFlipper) {
  7845. if (near.dist2 <= 300) {
  7846. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7847. } else {
  7848. biomeGear()
  7849. }
  7850. } else {
  7851. biomeGear()
  7852. }
  7853. } else {
  7854. biomeGear()
  7855. }
  7856. }
  7857. }
  7858. }
  7859. }
  7860. }
  7861. let accChanger = function() {
  7862. if (clicks.left) {
  7863. buyEquip(21, 1);
  7864. } else if (clicks.right) {
  7865. buyEquip(21, 1)
  7866. } else if (traps.inTrap) {
  7867. buyEquip(21, 1);
  7868. } else if (near.dist2 < 300) {
  7869. if (getEl("antiBullType").value == "noab") {
  7870. buyEquip(21, 1)
  7871. } else if (inWater) {
  7872. buyEquip(21, 1)
  7873. } else {
  7874. buyEquip(21, 1);
  7875. }
  7876. } else {
  7877. buyEquip(11, 1);
  7878. }
  7879. }
  7880. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7881. hatChanger();
  7882. accChanger();
  7883. }
  7884. if (configs1.AutoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7885. autoPush();
  7886. } else {
  7887. if (my.autoPush) {
  7888. my.autoPush = false;
  7889. packet("a", lastMoveDir || undefined, 1);
  7890. }
  7891. }
  7892. if (!my.autoPush && pathFind.active) {
  7893. Pathfinder();
  7894. }
  7895. if (instaC.ticking) {
  7896. instaC.ticking = false;
  7897. }
  7898. if (instaC.syncHit) {
  7899. instaC.syncHit = false;
  7900. }
  7901. if (player.empAnti) {
  7902. player.empAnti = false;
  7903. }
  7904. if (player.soldierAnti) {
  7905. player.soldierAnti = false;
  7906. }
  7907. if (my.anti0Tick > 0) {
  7908. my.anti0Tick--;
  7909. }
  7910. if (traps.replaced) {
  7911. traps.replaced = false;
  7912. }
  7913. if (traps.antiTrapped) {
  7914. traps.antiTrapped = false;
  7915. }
  7916. }
  7917. }
  7918. if (botSkts.length) {
  7919. botSkts.forEach((bots) => {
  7920. if (true) {
  7921. bots[0].ssend("player", player, near, botIDS);
  7922. }
  7923. });
  7924. }
  7925. }
  7926. // UPDATE LEADERBOARD:
  7927. function updateLeaderboard(data) {
  7928. UTILS.removeAllChildren(leaderboardData);
  7929. var tmpC = 1;
  7930. for (var i = 0; i < data.length; i += 3) {
  7931. // console.log(data);
  7932. (function(i) {
  7933. UTILS.generateElement({
  7934. class: "leaderHolder",
  7935. parent: leaderboardData,
  7936. children: [
  7937. UTILS.generateElement({
  7938. class: "leaderboardItem",
  7939. 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;",
  7940. text: (data[i + 1] != "" ? data[i + 1] : "unknown") + " |"
  7941. }),
  7942. UTILS.generateElement({
  7943. class: "a", //class: "leaderScore",
  7944. 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;",
  7945. text: ("? " + UTILS.kFormat(data[i + 2]) || "? 0")
  7946. })
  7947. ]
  7948. });
  7949. })(i);
  7950. tmpC++;
  7951. }
  7952. }
  7953.  
  7954. // LOAD GAME OBJECT:
  7955. function loadGameObject(data) {
  7956. for (let i = 0; i < data.length;) {
  7957. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7958. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7959. sid: data[i + 7]
  7960. } : null));
  7961. i += 8;
  7962. }
  7963. }
  7964. // ADD AI:
  7965. function loadAI(data) {
  7966. for (let i = 0; i < ais.length; ++i) {
  7967. ais[i].forcePos = !ais[i].visible;
  7968. ais[i].visible = false;
  7969. }
  7970. if (data) {
  7971. let tmpTime = performance.now();
  7972. for (let i = 0; i < data.length;) {
  7973. tmpObj = findAIBySID(data[i]);
  7974. if (tmpObj) {
  7975. tmpObj.index = data[i + 1];
  7976. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7977. tmpObj.t2 = tmpTime;
  7978. tmpObj.x1 = tmpObj.x;
  7979. tmpObj.y1 = tmpObj.y;
  7980. tmpObj.x2 = data[i + 2];
  7981. tmpObj.y2 = data[i + 3];
  7982. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7983. tmpObj.d2 = data[i + 4];
  7984. tmpObj.health = data[i + 5];
  7985. tmpObj.dt = 0;
  7986. tmpObj.visible = true;
  7987. } else {
  7988. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7989. tmpObj.x2 = tmpObj.x;
  7990. tmpObj.y2 = tmpObj.y;
  7991. tmpObj.d2 = tmpObj.dir;
  7992. tmpObj.health = data[i + 5];
  7993. if (!aiManager.aiTypes[data[i + 1]].name)
  7994. tmpObj.name = config.cowNames[data[i + 6]];
  7995. tmpObj.forcePos = true;
  7996. tmpObj.sid = data[i];
  7997. tmpObj.visible = true;
  7998. }
  7999. i += 7;
  8000. }
  8001. }
  8002. }
  8003. // ANIMATE AI:
  8004. function animateAI(sid) {
  8005. tmpObj = findAIBySID(sid);
  8006. if (tmpObj) tmpObj.startAnim();
  8007. }
  8008. function gatherAnimation(sid, didHit, index) {
  8009. tmpObj = findPlayerBySID(sid);
  8010. if (tmpObj) {
  8011. tmpObj.startAnim(didHit, index);
  8012. tmpObj.gatherIndex = index;
  8013. tmpObj.gathering = 1;
  8014.  
  8015. // code by Xiaokai [Simple Anti]
  8016. 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);
  8017.  
  8018. if (didHit) {
  8019. let tmpObjects = objectManager.hitObj;
  8020. //preplacer
  8021. setTickout(() => {
  8022. setTimeout(() => {
  8023. if(getDist(player, enemy) <= 200) {
  8024. place(2, getDir(tmpObjects, player))
  8025. } else {
  8026. place(4, getDir(tmpObjects, player))
  8027. }
  8028. }, items.weapons[index].speed - window.pingTime)
  8029. }, 2)
  8030.  
  8031. objectManager.hitObj = [];
  8032.  
  8033. game.tickBase(() => {
  8034. tmpObj = findPlayerBySID(sid);
  8035. 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);
  8036. tmpObjects.forEach((healthy) => {
  8037. healthy.healthMov = healthy.health - val / 2;
  8038. healthy.health -= val;
  8039. //love to https://gist.github.com/bendc/76c48ce53299e6078a76
  8040. let h, s, l;
  8041. let color = (() => {
  8042. const randomInt = (min, max) => {
  8043. return Math.floor(Math.random() * (max - min + 1)) + min;
  8044. };
  8045. h = randomInt(0, 360);
  8046. s = randomInt(42, 98);
  8047. l = randomInt(40, 90);
  8048. // return `hsl(${h},${s}%,${l}%)`;
  8049. })();
  8050. //and love https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
  8051. function hslToHex(h, s, l) {
  8052. l /= 100;
  8053. const a = s * Math.min(l, 1 - l) / 100;
  8054. const f = n => {
  8055. const k = (n + h / 30) % 12;
  8056. const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
  8057. return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
  8058. };
  8059. return `#${f(0)}${f(8)}${f(4)}`;
  8060. }
  8061. console.log(hslToHex(h, s, l));
  8062. (healthy.x, healthy.y, val, hslToHex(h, s, l));
  8063. });
  8064. }, 1);
  8065. }
  8066. }
  8067. }
  8068. function showDamageText(x, y, value, color) {
  8069. textManager.showText(x, y, 30, 0.15, 550, Math.round(value), color);
  8070. }
  8071.  
  8072. // WIGGLE GAME OBJECT:
  8073. function wiggleGameObject(dir, sid) {
  8074. tmpObj = findObjectBySid(sid);
  8075. if (tmpObj) {
  8076. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  8077. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  8078. if (tmpObj.health) {
  8079. //tmpObj.damaged = Math.min(255, tmpObj.damaged + 60);
  8080. objectManager.hitObj.push(tmpObj);
  8081. }
  8082. }
  8083. }
  8084. // SHOOT TURRET:
  8085. function shootTurret(sid, dir) {
  8086. tmpObj = findObjectBySid(sid);
  8087. if (tmpObj) {
  8088. tmpObj.dir = dir;
  8089. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  8090. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  8091. }
  8092. }
  8093. function randomizePhrases2() {
  8094. 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...'];
  8095. return phrases[Math.floor(Math.random() * phrases.length)];
  8096. }
  8097. // UPDATE PLAYER VALUE:
  8098. function updatePlayerValue(index, value, updateView) {
  8099. if (player) {
  8100. player[index] = value;
  8101.  
  8102. if (index == "points") {
  8103. if (configs.autoBuy) {
  8104. autoBuy.hat();
  8105. autoBuy.acc();
  8106. }
  8107. } else if (index == "kills") {
  8108. if (configs.killChat) {
  8109. packet("6", "Wake up to reality.")
  8110. setTimeout(() => {
  8111. packet("6", "Nothing goes as ever planned.")
  8112. setTimeout(() => {
  8113. packet("6", "I ve sent you to the void.")
  8114. setTimeout(() => {
  8115. packet("6", "Kids in the void: " + player.kills)
  8116. }, 1500);
  8117. }, 1500);
  8118. }, 1500);
  8119. }
  8120. }
  8121. }
  8122. }
  8123. // Function to get a varying kill chat message
  8124. // Function to get a varying kill chat message
  8125. function getKillChatMessage(kills) {
  8126. // Calculate the base kill count
  8127. let baseKillCount = Math.floor(kills / 10) * 10;
  8128.  
  8129. if (kills <= 1) {
  8130. return "";
  8131. } else if (kills <= 2) {
  8132. return "";
  8133. } else if (kills <= 3) {
  8134. return "";
  8135. } else if (kills <= 4) {
  8136. return "";
  8137. } else if (kills <= 5) {
  8138. return "";
  8139. } else if (kills <= 6) {
  8140. return "";
  8141. } else if (kills <= 7) {
  8142. return "";
  8143. } else if (kills <= 8) {
  8144. return "";
  8145. } else if (kills <= 9) {
  8146. return "";
  8147. } else if (kills <= 10) {
  8148. return "";
  8149. } else if (kills <= 11) {
  8150. return "";
  8151. } else if (kills <= 12) {
  8152. return "";
  8153. } else if (kills <= 13) {
  8154. return "";
  8155. } else if (kills <= 14) {
  8156. return "";
  8157. } else if (kills <= 15) {
  8158. return "";
  8159. } else if (kills <= 16) {
  8160. return "";
  8161. } else if (kills <= 17) {
  8162. return "";
  8163. } else if (kills <= 18) {
  8164. return "";
  8165. } else if (kills <= 19) {
  8166. return "";
  8167. } else if (kills <= 20) {
  8168. return "";
  8169. } else if (kills <= 21) {
  8170. return "";
  8171. } else if (kills <= 22) {
  8172. return "";
  8173. } else if (kills <= 23) {
  8174. return "";
  8175. } else if (kills <= 24) {
  8176. return "";
  8177. } else if (kills <= 25) {
  8178. return "";
  8179. } else if (kills <= 26) {
  8180. return "";
  8181. } else if (kills <= 27) {
  8182. return "";
  8183. } else if (kills <= 28) {
  8184. return "";
  8185. } else if (kills <= 29) {
  8186. return "";
  8187. } else if (kills <= 30) {
  8188. return "";
  8189. } else {
  8190.  
  8191. // Display additional information when the kill count crosses a multiple of 10
  8192. let additionalInfo = "x" + (Math.floor(kills / 10) - 1);
  8193. return
  8194. }
  8195. }
  8196. // ACTION BAR:
  8197. function updateItems(data, wpn) {
  8198. if (data) {
  8199. if (wpn) {
  8200. player.weapons = data;
  8201. player.primaryIndex = player.weapons[0];
  8202. player.secondaryIndex = player.weapons[1];
  8203. if (!instaC.isTrue) {
  8204. selectWeapon(player.weapons[0]);
  8205. }
  8206. } else {
  8207. player.items = data;
  8208. }
  8209. }
  8210. for (let i = 0; i < items.list.length; i++) {
  8211. let tmpI = items.weapons.length + i;
  8212. getEl("actionBarItem" + tmpI).style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8213. }
  8214. for (let i = 0; i < items.weapons.length; i++) {
  8215. getEl("actionBarItem" + i).style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8216. }
  8217. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8218. if (kms) {
  8219. getEl("actionBarItem3").style.display = "none";
  8220. getEl("actionBarItem4").style.display = "inline-block";
  8221. }
  8222. }
  8223. // ADD PROJECTILE:
  8224. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8225. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8226. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8227. }
  8228. // REMOVE PROJECTILE:
  8229. function remProjectile(sid, range) {
  8230. for (let i = 0; i < projectiles.length; ++i) {
  8231. if (projectiles[i].sid == sid) {
  8232. projectiles[i].range = range;
  8233. let tmpObjects = objectManager.hitObj;
  8234. objectManager.hitObj = [];
  8235. game.tickBase(() => {
  8236. let val = projectiles[i].dmg;
  8237. tmpObjects.forEach((healthy) => {
  8238. if (healthy.projDmg) {
  8239. healthy.health -= val;
  8240. }
  8241. });
  8242. }, 1);
  8243. }
  8244. }
  8245. }
  8246. // SHOW ALLIANCE MENU:
  8247. function allianceNotification(sid, name) {
  8248. let findBotSID = findSID(bots, sid);
  8249. if (findBotSID) { }
  8250. }
  8251. function setPlayerTeam(team, isOwner) {
  8252. if (player) {
  8253. player.team = team;
  8254. player.isOwner = isOwner;
  8255. if (team == null)
  8256. alliancePlayers = [];
  8257. }
  8258. }
  8259. function setAlliancePlayers(data) {
  8260. alliancePlayers = data;
  8261. }
  8262. // STORE MENU:
  8263. function updateStoreItems(type, id, index) {
  8264. if (index) {
  8265. if (!type)
  8266. player.tails[id] = 1;
  8267. else {
  8268. player.latestTail = id;
  8269. }
  8270. } else {
  8271. if (!type)
  8272. player.skins[id] = 1,
  8273. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8274. else {
  8275. player.latestSkin = id;
  8276. }
  8277. }
  8278. }
  8279. // SEND MESSAGE:
  8280. function receiveChat(sid, message) {
  8281. let tmpPlayer = findPlayerBySID(sid);
  8282. if(message.startsWith('HaHa') && (player.isTeam(tmpPlayer) || sid == player.sid) &&window.VirusterDev){
  8283. textManager.showText(player.x, player.y, 20, 0.15, 1850, 'Sync Trigger', '#f00', 2);
  8284. let teammate = tmpPlayer
  8285. top.lastSync = Date.now();
  8286. let teamPing = parseInt(message.split('HaHa')[1]), teamDist = UTILS.getDistance(near.x, near.y, teammate.x, teammate.y)
  8287. // |||||||
  8288. //turret and musket MS calculation formula by memeganoob big thanks to him vvvvvvv
  8289. 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;
  8290. 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;
  8291. //console.log(turretSpeed, teamTurretSpeed, teamDist)
  8292. let Clapped = ()=>{
  8293. buyEquip(53, 0);
  8294. selectWeapon(player.secondaryIndex)
  8295. my.autoAim = true;
  8296. setTimeout(() => {
  8297. sendAutoGather();
  8298. setTimeout(()=>{
  8299. my.autoAim = false;
  8300. sendAutoGather();
  8301. },250)
  8302. }, turretSpeed - musketSpeed);
  8303. };
  8304. //Clapped();
  8305. if(turretSpeed > teamTurretSpeed){
  8306. Clapped();
  8307. }else{
  8308. setTimeout(()=>{
  8309. Clapped();
  8310. },teamTurretSpeed - turretSpeed)
  8311. }
  8312. }else{
  8313. if (tmpPlayer) {
  8314.  
  8315. function get() {
  8316. if(tmpPlayer != player && player.team != tmpPlayer.team) {
  8317. return "#c95563";
  8318. } else if (player.team && player.team == tmpPlayer.team) {
  8319. return "#fff";
  8320. } else {
  8321. return "#0949aa"; //2394e8
  8322. }
  8323. }
  8324. let me = false;
  8325. if(tmpPlayer == player) me = true
  8326. else me = false;
  8327. addChatLog(message, "#fff", tmpPlayer.name + "[" + tmpPlayer.sid + "]:", tmpPlayer == player || (tmpPlayer.team && tmpPlayer.team == player.team) ? "#279df1" : "#fff");
  8328. tmpPlayer.chatMessage = ((text) => {
  8329. let tmpString;
  8330. profanityList.forEach((list) => {
  8331. if (text.indexOf(list) > -1) {
  8332. tmpString = "";
  8333. for (var y = 0; y < list.length; ++y) {
  8334. tmpString += tmpString.length ? "o" : "M";
  8335. }
  8336. var re = new RegExp(list, 'g');
  8337. text = text.replace(re, tmpString);
  8338. }
  8339. });
  8340. return text;
  8341. })(message);
  8342. tmpPlayer.chatCountdown = config.chatCountdown;
  8343. }
  8344. }
  8345. }
  8346. // MINIMAP:
  8347. function updateMinimap(data) {
  8348. minimapData = data;
  8349. }
  8350. // SHOW ANIM TEXT:
  8351. function showText(x, y, value, type, color) {
  8352. textManager.showText(x, y, 50, 0.18, 500, Math.abs(value), color);
  8353. }
  8354. /** APPLY SOCKET CODES */// BOT:
  8355. let bots = [];
  8356. let ranLocation = {
  8357. x: UTILS.randInt(35, 14365),
  8358. y: UTILS.randInt(35, 14365)
  8359. };
  8360. setInterval(() => {
  8361. ranLocation = {
  8362. x: UTILS.randInt(35, 14365),
  8363. y: UTILS.randInt(35, 14365)
  8364. };
  8365. }, 60000);
  8366. class Bot {
  8367. constructor(id, sid, hats, accessories) {
  8368. this.millPlace = true;
  8369. this.id = id;
  8370. this.sid = sid;
  8371. this.team = null;
  8372. this.skinIndex = 0;
  8373. this.tailIndex = 0;
  8374. this.hitTime = 0;
  8375. this.iconIndex = 0;
  8376. this.enemy = [];
  8377. this.near = [];
  8378. this.dist2 = 0;
  8379. this.aim2 = 0;
  8380. this.tick = 0;
  8381. this.itemCounts = {};
  8382. this.latestSkin = 0;
  8383. this.latestTail = 0;
  8384. this.points = 0;
  8385. this.tails = {};
  8386. for (let i = 0; i < accessories.length; ++i) {
  8387. if (accessories[i].price <= 0)
  8388. this.tails[accessories[i].id] = 1;
  8389. }
  8390. this.skins = {};
  8391. for (let i = 0; i < hats.length; ++i) {
  8392. if (hats[i].price <= 0)
  8393. this.skins[hats[i].id] = 1;
  8394. }
  8395. this.spawn = function(moofoll) {
  8396. this.upgraded = 0;
  8397. this.enemy = [];
  8398. this.near = [];
  8399. this.active = true;
  8400. this.alive = true;
  8401. this.lockMove = false;
  8402. this.lockDir = false;
  8403. this.minimapCounter = 0;
  8404. this.chatCountdown = 0;
  8405. this.shameCount = 0;
  8406. this.shameTimer = 0;
  8407. this.sentTo = {};
  8408. this.gathering = 0;
  8409. this.autoGather = 0;
  8410. this.animTime = 0;
  8411. this.animSpeed = 0;
  8412. this.mouseState = 0;
  8413. this.buildIndex = -1;
  8414. this.weaponIndex = 0;
  8415. this.dmgOverTime = {};
  8416. this.noMovTimer = 0;
  8417. this.maxXP = 300;
  8418. this.XP = 0;
  8419. this.age = 1;
  8420. this.kills = 0;
  8421. this.upgrAge = 2;
  8422. this.upgradePoints = 0;
  8423. this.x = 0;
  8424. this.y = 0;
  8425. this.zIndex = 0;
  8426. this.xVel = 0;
  8427. this.yVel = 0;
  8428. this.slowMult = 1;
  8429. this.dir = 0;
  8430. this.nDir = 0;
  8431. this.dirPlus = 0;
  8432. this.targetDir = 0;
  8433. this.targetAngle = 0;
  8434. this.maxHealth = 100;
  8435. this.health = this.maxHealth;
  8436. this.oldHealth = this.maxHealth;
  8437. this.scale = config.playerScale;
  8438. this.speed = config.playerSpeed;
  8439. this.resetMoveDir();
  8440. this.resetResources(moofoll);
  8441. this.items = [0, 3, 6, 10];
  8442. this.weapons = [0];
  8443. this.shootCount = 0;
  8444. this.weaponXP = [];
  8445. this.isBot = false;
  8446. this.reloads = {
  8447. 0: 0,
  8448. 1: 0,
  8449. 2: 0,
  8450. 3: 0,
  8451. 4: 0,
  8452. 5: 0,
  8453. 6: 0,
  8454. 7: 0,
  8455. 8: 0,
  8456. 9: 0,
  8457. 10: 0,
  8458. 11: 0,
  8459. 12: 0,
  8460. 13: 0,
  8461. 14: 0,
  8462. 15: 0,
  8463. 53: 0,
  8464. };
  8465. this.timeZinceZpawn = 0;
  8466. this.whyDie = "";
  8467. this.clearRadius = false;
  8468. this.circlee = 0;
  8469. };
  8470. // RESET MOVE DIR:
  8471. this.resetMoveDir = function() {
  8472. this.moveDir = undefined;
  8473. };
  8474. // RESET RESOURCES:
  8475. this.resetResources = function(moofoll) {
  8476. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8477. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8478. }
  8479. };
  8480. // SET DATA:
  8481. this.setData = function(data) {
  8482. this.id = data[0];
  8483. this.sid = data[1];
  8484. this.name = data[2];
  8485. this.x = data[3];
  8486. this.y = data[4];
  8487. this.dir = data[5];
  8488. this.health = data[6];
  8489. this.maxHealth = data[7];
  8490. this.scale = data[8];
  8491. this.skinColor = data[9];
  8492. };
  8493. // SHAME SYSTEM:
  8494. this.judgeShame = function() {
  8495. if (this.oldHealth < this.health) {
  8496. if (this.hitTime) {
  8497. let timeSinceHit = this.tick - this.hitTime;
  8498. this.hitTime = 0;
  8499. if (timeSinceHit < 2) {
  8500. this.lastshamecount = this.shameCount;
  8501. this.shameCount++;
  8502. } else {
  8503. this.lastshamecount = this.shameCount;
  8504. this.shameCount = Math.max(0, this.shameCount - 2);
  8505. }
  8506. }
  8507. } else if (this.oldHealth > this.health) {
  8508. this.hitTime = this.tick;
  8509. }
  8510. };
  8511. // UPDATE WEAPON RELOAD:
  8512. this.manageReloadaa = function() {
  8513. if (this.shooting[53]) {
  8514. this.shooting[53] = 0;
  8515. this.reloads[53] = (2500 - 1000/9);
  8516. } else {
  8517. if (this.reloads[53] > 0) {
  8518. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8519. }
  8520. }
  8521. if (this.gathering || this.shooting[1]) {
  8522. if (this.gathering) {
  8523. this.gathering = 0;
  8524. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8525. this.attacked = true;
  8526. }
  8527. if (this.shooting[1]) {
  8528. this.shooting[1] = 0;
  8529. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8530. this.attacked = true;
  8531. }
  8532. } else {
  8533. this.attacked = false;
  8534. if (this.buildIndex < 0) {
  8535. if (this.reloads[this.weaponIndex] > 0) {
  8536. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8537. }
  8538. }
  8539. }
  8540. };
  8541. this.closeSockets = function(websc) {
  8542. websc.close();
  8543. };
  8544. this.whyDieChat = function(websc, whydie) {
  8545. websc.sendWS("6", "Noob " + whydie);
  8546. };
  8547. }
  8548. };
  8549. class BotObject {
  8550. constructor(sid) {
  8551. this.sid = sid;
  8552. // INIT:
  8553. this.init = function(x, y, dir, scale, type, data, owner) {
  8554. data = data || {};
  8555. this.active = true;
  8556. this.x = x;
  8557. this.y = y;
  8558. this.scale = scale;
  8559. this.owner = owner;
  8560. this.id = data.id;
  8561. this.dmg = data.dmg;
  8562. this.trap = data.trap;
  8563. this.teleport = data.teleport;
  8564. this.isItem = this.id != undefined;
  8565. };
  8566. }
  8567. };
  8568. class BotObjManager {
  8569. constructor(botObj, fOS) {
  8570. // DISABLE OBJ:
  8571. this.disableObj = function(obj) {
  8572. obj.active = false;
  8573. if (config.anotherVisual) {} else {
  8574. obj.alive = false;
  8575. }
  8576. };
  8577. // ADD NEW:
  8578. let tmpObj;
  8579. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8580. tmpObj = fOS(sid);
  8581. if (!tmpObj) {
  8582. tmpObj = botObj.find((tmp) => !tmp.active);
  8583. if (!tmpObj) {
  8584. tmpObj = new BotObject(sid);
  8585. botObj.push(tmpObj);
  8586. }
  8587. }
  8588. if (setSID) {
  8589. tmpObj.sid = sid;
  8590. }
  8591. tmpObj.init(x, y, dir, s, type, data, owner);
  8592. };
  8593. // DISABLE BY SID:
  8594. this.disableBySid = function(sid) {
  8595. let find = fOS(sid);
  8596. if (find) {
  8597. this.disableObj(find);
  8598. }
  8599. };
  8600. // REMOVE ALL FROM PLAYER:
  8601. this.removeAllItems = function(sid, server) {
  8602. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8603. };
  8604. }
  8605. };
  8606. let botz = [];
  8607. function botSpawn(id) {
  8608. let bot;
  8609. console.log(WS);
  8610. let t = WS.url.split("wss://")[1].split("?")[0];
  8611. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8612. let botPlayer = new Map();
  8613. botSkts.push([botPlayer]);
  8614. botz.push([bot]);
  8615. let botSID;
  8616. let botObj = [];
  8617. let nearObj = [];
  8618. let bD = {
  8619. x: 0,
  8620. y: 0,
  8621. inGame: false,
  8622. closeSocket: false,
  8623. whyDie: ""
  8624. };
  8625. let oldXY = {
  8626. x: 0,
  8627. y: 0,
  8628. };
  8629. let izauto = 0;
  8630. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8631. bot.binaryType = "arraybuffer";
  8632. bot.first = true;
  8633. bot.sendWS = function(type) {
  8634. // EXTRACT DATA ARRAY:
  8635. let data = Array.prototype.slice.call(arguments, 1);
  8636. // SEND MESSAGE:
  8637. let binary = window.msgpack.encode([type, data]);
  8638. bot.send(binary);
  8639. };
  8640. bot.spawn = function() {
  8641. bot.sendWS("M", {
  8642. name: "get bagged",
  8643. moofoll: 1,
  8644. skin: "__proto__"
  8645. });
  8646. };
  8647. bot.sendUpgrade = function(index) {
  8648. bot.sendWS("H", index);
  8649. };
  8650. bot.place = function(id, a) {
  8651. try {
  8652. let item = items.list[botPlayer.items[id]];
  8653. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  8654. bot.sendWS("G", botPlayer.items[id]);
  8655. bot.sendWS("d", 1, a);
  8656. bot.sendWS("G", botPlayer.weaponIndex, true);
  8657. }
  8658. } catch (e) {
  8659. }
  8660. };
  8661. bot.buye = function(id, index) {
  8662. let nID = 0;
  8663. if (botPlayer.alive && botPlayer.inGame) {
  8664. if (index == 0) {
  8665. if (botPlayer.skins[id]) {
  8666. if (/*botPlayer.skinIndex != id*/true) {
  8667. bot.sendWS("c", 0, id, 0);
  8668. }
  8669. } else {
  8670. let find = findID(hats, id);
  8671. if (find) {
  8672. if (botPlayer.points >= find.price) {
  8673. bot.sendWS("c", 1, id, 0);
  8674. bot.sendWS("c", 0, id, 0);
  8675. } else {
  8676. if (/*botPlayer.latestSkin != nID*/true) {
  8677. bot.sendWS("c", 0, nID, 0);
  8678. }
  8679. }
  8680. } else {
  8681. if (/*botPlayer.latestSkin != nID*/true) {
  8682. bot.sendWS("c", 0, nID, 0);
  8683. }
  8684. }
  8685. }
  8686. } else if (index == 1) {
  8687. if (botPlayer.tails[id]) {
  8688. if (botPlayer.latestTail != id) {
  8689. bot.sendWS("c", 0, id, 1);
  8690. }
  8691. } else {
  8692. let find = findID(accessories, id);
  8693. if (find) {
  8694. if (botPlayer.points >= find.price) {
  8695. bot.sendWS("c", 1, id, 1);
  8696. bot.sendWS("c", 0, id, 1);
  8697. } else {
  8698. if (botPlayer.latestTail != 0) {
  8699. bot.sendWS("c", 0, 0, 1);
  8700. }
  8701. }
  8702. } else {
  8703. if (botPlayer.latestTail != 0) {
  8704. bot.sendWS("c", 0, 0, 1);
  8705. }
  8706. }
  8707. }
  8708. }
  8709. }
  8710. };
  8711. bot.fastGear = function() {
  8712. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8713. bot.buye(31, 0);
  8714. } else {
  8715. if (botPlayer.y2 <= config.snowBiomeTop) {
  8716. bot.buye(15, 0);
  8717. } else {
  8718. bot.buye(12, 0);
  8719. }
  8720. }
  8721. };
  8722. bot.selectWeapon = function(a) {
  8723. packet("G", a, 1);
  8724. }
  8725. function caf(e, t) {
  8726. try {
  8727. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8728. } catch (e) {
  8729. return 0;
  8730. }
  8731. }
  8732. bot.heal = function() {
  8733. if (botPlayer.health < 100) {
  8734. bot.place(0, 0)
  8735. }
  8736. }
  8737. function cdf (e, t){
  8738. try {
  8739. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8740. } catch(e){
  8741. return Infinity;
  8742. }
  8743. }
  8744. let zoon = 'no';
  8745. bot.zync = function(a) {
  8746. if (!botPlayer.millPlace) {
  8747. zoon = 'yeah';
  8748. bot.place(5, caf(botPlayer, a));
  8749. let NextTickLocation = {
  8750. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8751. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8752. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8753. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8754. };
  8755. function calculateDistance(x1, y1, x2, y2) {
  8756. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8757. return distance;
  8758. }
  8759. function dotherezt() {
  8760. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8761. }
  8762. 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;
  8763. bot.buye(53, 0);
  8764. let aa = setInterval(()=>{
  8765. dotherezt();
  8766. },100)
  8767. setTimeout(()=>{
  8768. bot.sendWS("G", botPlayer.weapons[1], true);
  8769. if (izauto == 0) {
  8770. bot.sendWS("K", 1);
  8771. izauto = 1;
  8772. }
  8773. setTimeout(() => {
  8774. bot.sendWS("G", botPlayer.weapons[0], true);
  8775. clearInterval(aa)
  8776. }, 1000);
  8777. setTimeout(() => {
  8778. zoon = 'no';
  8779. }, 500);
  8780. },turretSpeed-(musketSpeed*2))
  8781. bot.buye(53, 0);
  8782. }
  8783. };
  8784. bot.onmessage = function(message) {
  8785. let data = new Uint8Array(message.data);
  8786. let parsed = window.msgpack.decode(data);
  8787. let type = parsed[0];
  8788. data = parsed[1];
  8789. if (type == "io-init") {
  8790. bot.spawn();
  8791. }
  8792. if (type == "1") {
  8793. botSID = data[0];
  8794. console.log(botSID)
  8795. setInterval(()=>{
  8796. bot.fastGear();
  8797. },60000)
  8798. }
  8799. if (type == "D") {
  8800. if (data[1]) {
  8801. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8802. botPlayer.setData(data[0]);
  8803. botPlayer.inGame = true;
  8804. botPlayer.alive = true;
  8805. botPlayer.x2 = undefined;
  8806. botPlayer.y2 = undefined;
  8807. botPlayer.spawn(1);
  8808. botPlayer.oldHealth = 100;
  8809. botPlayer.health = 100;
  8810. botPlayer.showName = 'NOOO';
  8811. oldXY = {
  8812. x: data[0][3],
  8813. y: data[0][4]
  8814. }
  8815. bD.inGame = true;
  8816. if (bot.first) {
  8817. bot.first = false;
  8818. bots.push(bD);
  8819. }
  8820. }
  8821. }
  8822. if (type == "P") {
  8823. bot.spawn();
  8824. botPlayer.inGame = false;
  8825. bD.inGame = false;
  8826. }
  8827. if (type == "a") {
  8828. let tmpData = data[0];
  8829. botPlayer.tick++;
  8830. botPlayer.enemy = [];
  8831. botPlayer.near = [];
  8832. bot.showName = 'NOOO';
  8833. nearObj = [];
  8834. for (let i = 0; i < tmpData.length;) {
  8835. if (tmpData[i] == botPlayer.sid) {
  8836. botPlayer.x2 = tmpData[i + 1];
  8837. botPlayer.y2 = tmpData[i + 2];
  8838. botPlayer.d2 = tmpData[i + 3];
  8839. botPlayer.buildIndex = tmpData[i + 4];
  8840. botPlayer.weaponIndex = tmpData[i + 5];
  8841. botPlayer.weaponVariant = tmpData[i + 6];
  8842. botPlayer.team = tmpData[i + 7];
  8843. botPlayer.isLeader = tmpData[i + 8];
  8844. botPlayer.skinIndex = tmpData[i + 9];
  8845. botPlayer.tailIndex = tmpData[i + 10];
  8846. botPlayer.iconIndex = tmpData[i + 11];
  8847. botPlayer.zIndex = tmpData[i + 12];
  8848. botPlayer.visible = true;
  8849. bD.x2 = botPlayer.x2;
  8850. bD.y2 = botPlayer.y2;
  8851. }
  8852. i += 13;
  8853. }
  8854. for (let i = 0; i < tmpData.length;) {
  8855. tmpObj = findPlayerBySID(tmpData[i]);
  8856. if (tmpObj) {
  8857. if (!tmpObj.isTeam(botPlayer)) {
  8858. enemy.push(tmpObj);
  8859. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8860. nears.push(tmpObj);
  8861. }
  8862. }
  8863. }
  8864. i += 13;
  8865. }
  8866. if (enemy.length) {
  8867. //console.log(enemy)
  8868. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8869. return tmp1.dist2 - tmp2.dist2;
  8870. })[0];
  8871. }
  8872. if (izauto == 1) {
  8873. bot.sendWS("K", 1);
  8874. izauto = 0;
  8875. }
  8876. if (bD.closeSocket) {
  8877. botPlayer.closeSockets(bot);
  8878. }
  8879. if (bD.whyDie != "") {
  8880. botPlayer.whyDieChat(bot, bD.whyDie);
  8881. bD.whyDie = "";
  8882. }
  8883. if (botPlayer.alive) {
  8884. if (player.team) {
  8885. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8886. botPlayer.team && (bot.sendWS("N"));
  8887. bot.sendWS("b", player.team);
  8888. setTimeout(()=>{bottzzz.push(botPlayer.sid)},2000)
  8889. }
  8890. }
  8891. let item = items.list[botPlayer.items[3]];
  8892. let a = botPlayer.itemCounts[item.group.id]
  8893. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8894. if (botPlayer.inGame) {
  8895. bot.sendWS("D", botPlayer.moveDir);
  8896. if (izauto == 0) {
  8897. bot.sendWS("K", 1);
  8898. izauto = 1;
  8899. }
  8900. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 200) {
  8901. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8902. bot.place(3, aim + 7.7);
  8903. bot.place(3, aim - 7.7);
  8904. bot.place(3, aim);
  8905. oldXY = {
  8906. x: botPlayer.x2,
  8907. y: botPlayer.y2
  8908. };
  8909. }
  8910. if (botPlayer.tick % 90 === 0) {
  8911. let rand = Math.random() * Math.PI * 2;
  8912. botPlayer.moveDir = rand;
  8913. bot.sendWS("a", botPlayer.moveDir);
  8914. }
  8915. }
  8916. bot.fastGear();
  8917. } else if((a != undefined ? a : 0) > 198 && botPlayer.millPlace) {
  8918. botPlayer.millPlace = false;
  8919. if (izauto == 0) {
  8920. bot.sendWS("K", 1);
  8921. izauto = 1;
  8922. }
  8923. bot.buye(11, 1);
  8924. bot.fastGear();
  8925. } else {
  8926. if (botPlayer.inGame) {
  8927. if (botObj.length > 0) {
  8928. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8929. if (getEl("mode").value == 'fuckemup') {
  8930. // if (getEl("mode").value == "clear") {
  8931. bot.selectWeapon(botPlayer.weapons[1]);
  8932. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8933. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8934. 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) {
  8935. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8936. })[0];
  8937. if (nearObj) {
  8938. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8939. if ((gotoDist - isPassed) > 0) {
  8940. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8941. if (botPlayer.moveDir != undefined) {
  8942. botPlayer.moveDir = undefined;
  8943. bot.sendWS("a", botPlayer.moveDir);
  8944. bot.sendWS("D", botPlayer.nDir);
  8945. }
  8946. } else {
  8947. botPlayer.moveDir = gotoAim;
  8948. bot.sendWS("a", botPlayer.moveDir);
  8949. bot.sendWS("D", botPlayer.nDir);
  8950. }
  8951. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8952. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8953. bot.sendWS("D", botPlayer.nDir);
  8954. }
  8955. if (izauto == 0) {
  8956. bot.sendWS("K", 1);
  8957. izauto = 1;
  8958. }
  8959. bot.buye(40, 0);
  8960. } else {
  8961. botPlayer.moveDir = gotoAim;
  8962. bot.sendWS("a", botPlayer.moveDir);
  8963. bot.sendWS("D", botPlayer.nDir);
  8964. bot.fastGear();
  8965. }
  8966. } else {
  8967. botPlayer.moveDir = gotoAim;
  8968. bot.sendWS("a", botPlayer.moveDir);
  8969. bot.sendWS("D", botPlayer.nDir);
  8970. bot.fastGear();
  8971. }
  8972. }
  8973. }
  8974. if (botObj.length > 0) {
  8975. if (getEl("mode").value == 'flex') {
  8976. const circleRadius = 300;
  8977. const circleCenterX = player.x2;
  8978. const circleCenterY = player.y2;
  8979. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  8980. angle -= 0.1;
  8981. const x = circleCenterX + circleRadius * Math.cos(angle);
  8982. const y = circleCenterY + circleRadius * Math.sin(angle);
  8983. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  8984. }
  8985.  
  8986. }
  8987.  
  8988. if (botObj.length > 0) {
  8989. if (getEl("mode").value == 'mouse') {
  8990. bot.sendWS("a", Math.atan2((player.y2 - botPlayer.y2) + mouseY - (gameCanvas.height / 1.5), (player.x2- botPlayer.x2) + mouseX - (gameCanvas.width / 1.5)));
  8991. }
  8992.  
  8993. }
  8994.  
  8995. if (botObj.length > 0) {
  8996. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8997. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8998. })[0];
  8999. if (nearObj&&((getEl("mode").value == 'fight'?(nearObj.isTeamObject(player)?false:true):true))) {//herenigga
  9000. if (izauto == 0) {
  9001. bot.sendWS("K", 1);
  9002. izauto = 1;
  9003. }
  9004. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9005. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9006. bot.sendWS("D", botPlayer.nDir);
  9007. }
  9008. bot.buye(40, 0);
  9009. bot.buye(11, 1);
  9010. } else {
  9011. bot.fastGear();
  9012. bot.buye(11, 1);
  9013. }
  9014. bot.buye(11, 1);
  9015. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9016. bot.selectWeapon(botPlayer.weapons[1]);
  9017. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9018. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9019. 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) {
  9020. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9021. })[0];
  9022. if (nearObj) {
  9023. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9024. if ((gotoDist - isPassed) > 0) {
  9025. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9026. // botPlayer.moveDir = undefined;
  9027. bot.sendWS("a", caf);
  9028. bot.sendWS("D", botPlayer.nDir);
  9029. } else {
  9030. // botPlayer.moveDir = gotoAim;
  9031. // bot.sendWS("a", botPlayer.moveDir);
  9032. bot.sendWS("D", botPlayer.nDir);
  9033. }
  9034. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9035. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9036. bot.sendWS("D", botPlayer.nDir);
  9037. }
  9038. if (izauto == 0) {
  9039. bot.sendWS("K", 1);
  9040. izauto = 1;
  9041. }
  9042. bot.buye(40, 0);
  9043. // bot.fastGear();
  9044. bot.buye(11, 1);
  9045. } else {
  9046. botPlayer.moveDir = gotoAim;
  9047. bot.sendWS("a", botPlayer.moveDir);
  9048. bot.sendWS("D", botPlayer.nDir);
  9049. bot.fastGear();
  9050. bot.buye(11, 1);
  9051. }
  9052. } else {
  9053. botPlayer.moveDir = gotoAim;
  9054. bot.sendWS("a", botPlayer.moveDir);
  9055. bot.sendWS("D", botPlayer.nDir);
  9056. bot.fastGear();
  9057. bot.buye(11, 1);
  9058. }
  9059. }
  9060. }
  9061. if (botObj.length > 0 && getEl("mode").value == 'stopp') {
  9062. if (cdf(window.stopSpot, botPlayer) <= 220) {
  9063. bot.sendWS("a", undefined);
  9064. bot.fastGear();
  9065. } else {
  9066. bot.sendWS("a", caf(window.stopSpot, botPlayer) + Math.PI);
  9067. }
  9068. }
  9069. if (botObj.length > 0 && getEl("mode").value == 'fight') {
  9070. if(near.sid) {
  9071. const circleRadius = 100;
  9072. const circleCenterX = near.x;
  9073. const circleCenterY = near.y;
  9074. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9075. angle -= 0.1;
  9076. const x = circleCenterX + circleRadius * Math.cos(angle);
  9077. const y = circleCenterY + circleRadius * Math.sin(angle);
  9078. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9079. if(UTILS.getDist(near, botPlayer, 0, 2) < 200) {
  9080. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9081. }
  9082. if(UTILS.getDist(near, botPlayer, 0, 2) < 400) {
  9083. bot.place(2, Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9084. }
  9085. } else{
  9086. const circleRadius = 100;
  9087. const circleCenterX = player.x2;
  9088. const circleCenterY = player.y2;
  9089. let angle = Math.atan2(botPlayer.y2 - circleCenterY, botPlayer.x2 - circleCenterX);
  9090. angle -= 0.1;
  9091. const x = circleCenterX + circleRadius * Math.cos(angle);
  9092. const y = circleCenterY + circleRadius * Math.sin(angle);
  9093. bot.sendWS("a", Math.atan2(y - botPlayer.y2, x - botPlayer.x2));
  9094. }
  9095. }
  9096. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9097. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale/2));
  9098. if (!wdaawdwad.length) {
  9099. if (zoon == 'no') {
  9100. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9101. }
  9102. if (cdf(player, botPlayer) <= 220) {
  9103. bot.sendWS("a", undefined);
  9104. bot.fastGear();
  9105. } else {
  9106. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9107. }
  9108. } else {
  9109. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9110. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9111. 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) {
  9112. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9113. });
  9114. if (nearObjs.length > 0) {
  9115. let nearObj = nearObjs[0];
  9116. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9117. if ((gotoDist - isPassed) > 0) {
  9118. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9119. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9120. // if (botPlayer.moveDir != undefined) {
  9121. // botPlayer.moveDir = undefined;
  9122. // bot.sendWS("a", botPlayer.moveDir);
  9123. bot.sendWS("D", botPlayer.nDir);
  9124. // }
  9125. } else {
  9126. bot.sendWS("D", botPlayer.nDir);
  9127. }
  9128. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9129. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9130. bot.sendWS("D", botPlayer.nDir);
  9131. }
  9132. bot.buye(40, 0);
  9133. // bot.fastGear();
  9134. bot.buye(11, 1);
  9135. if (izauto == 0) {
  9136. bot.sendWS("K", 1);
  9137. izauto = 1;
  9138. }
  9139. } else {
  9140. if (zoon == 'no') {
  9141. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  9142. }
  9143. if (cdf(player, botPlayer) <= 220) {
  9144. bot.sendWS("a", undefined);
  9145. } else {
  9146. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9147. }
  9148. }
  9149. } else {
  9150. if (wdaawdwad.length) {
  9151. if (zoon == 'no') {
  9152. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  9153. // if (izauto == 0) {
  9154. // bot.sendWS("K", 1);
  9155. // izauto = 1;
  9156. // }
  9157. }
  9158. if (cdf(player, botPlayer) <= 220) {
  9159. bot.sendWS("a", undefined);
  9160. } else {
  9161. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9162. }
  9163. } else {
  9164. if (zoon == 'no') {
  9165. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9166. }
  9167. if (cdf(player, botPlayer) <= 220) {
  9168. bot.sendWS("a", undefined);
  9169. } else {
  9170. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9171. }
  9172. }
  9173. }
  9174. }
  9175. }
  9176. }
  9177. }
  9178. }
  9179. }
  9180. if (type == "H") {
  9181. let tmpData = data[0];
  9182. for (let i = 0; i < tmpData.length;) {
  9183. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9184. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9185. sid: tmpData[i + 7]
  9186. } : null));
  9187. i += 8;
  9188. }
  9189. }
  9190. if (type == "N") {
  9191. let index = data[0];
  9192. let value = data[1];
  9193. if (botPlayer) {
  9194. botPlayer[index] = value;
  9195. }
  9196. }
  9197. if (type == "O") {
  9198. if (data[0] == botPlayer.sid) {
  9199. botPlayer.oldHealth = botPlayer.health;
  9200. botPlayer.health = data[1];
  9201. botPlayer.judgeShame();
  9202. if (botPlayer.oldHealth > botPlayer.health) {
  9203. if (botPlayer.shameCount < 5) {
  9204. for (let i = 0; i < 2; i++) {
  9205. bot.place(0, botPlayer.nDir);
  9206. }
  9207. } else {
  9208. setTimeout(() => {
  9209. for (let i = 0; i < 2; i++) {
  9210. bot.place(0, botPlayer.nDir);
  9211. }
  9212. }, 95);
  9213. }
  9214. }
  9215. }
  9216. }
  9217. if (type == "Q") {
  9218. let sid = data[0];
  9219. botObjManager.disableBySid(sid);
  9220. }
  9221. if (type == "R") {
  9222. let sid = data[0];
  9223. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9224. }
  9225. if (type == "S") {
  9226. let index = data[0];
  9227. let value = data[1];
  9228. if (botPlayer) {
  9229. botPlayer.itemCounts[index] = value;
  9230. }
  9231. }
  9232. if (type == "U") {
  9233. if (data[0] > 0) {
  9234. if(true) {
  9235. if (botPlayer.upgraded == 0) {
  9236. bot.sendUpgrade(3);
  9237. } else if (botPlayer.upgraded == 1) {
  9238. bot.sendUpgrade(17);
  9239. } else if (botPlayer.upgraded == 2) {
  9240. bot.sendUpgrade(31);
  9241. } else if (botPlayer.upgraded == 3) {
  9242. bot.sendUpgrade(27);
  9243. } else if (botPlayer.upgraded == 4) {
  9244. bot.sendUpgrade(9);
  9245. } else if (botPlayer.upgraded == 5) {
  9246. bot.sendUpgrade(34);
  9247. } else if (botPlayer.upgraded == 6) {
  9248. bot.sendUpgrade(12);
  9249. } else if (botPlayer.upgraded == 7) {
  9250. bot.sendUpgrade(15);
  9251. }
  9252. }
  9253. botPlayer.upgraded++;
  9254. }
  9255. }
  9256. if (type == "V") {
  9257. let tmpData = data[0];
  9258. let wpn = data[1];
  9259. if (tmpData) {
  9260. if (wpn) botPlayer.weapons = tmpData;
  9261. else botPlayer.items = tmpData;
  9262. }
  9263. }
  9264. if (type == "5") {
  9265. let type = data[0];
  9266. let id = data[1];
  9267. let index = data[2];
  9268. if (index) {
  9269. if (!type)
  9270. botPlayer.tails[id] = 1;
  9271. else
  9272. botPlayer.latestTail = id;
  9273. } else {
  9274. if (!type)
  9275. botPlayer.skins[id] = 1;
  9276. else
  9277. botPlayer.latestSkin = id;
  9278. }
  9279. }
  9280. if (type == "6") {
  9281. let id = data[0];
  9282. let mzg = data[1]+'';
  9283. if(id == player.sid && mzg.includes("!e")) {
  9284. //bot.zync(botPlayer.near);
  9285. }
  9286. }
  9287. };
  9288. bot.onclose = function() {
  9289. botPlayer.inGame = false;
  9290. bD.inGame = false;
  9291. };
  9292. }
  9293. //botend
  9294. // RENDER LEAF:
  9295. function renderLeaf(x, y, l, r, ctxt) {
  9296. let endX = x + (l * Math.cos(r));
  9297. let endY = y + (l * Math.sin(r));
  9298. let width = l * 0.4;
  9299. ctxt.moveTo(x, y);
  9300. ctxt.beginPath();
  9301. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  9302. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  9303. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  9304. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  9305. ctxt.closePath();
  9306. ctxt.fill();
  9307. ctxt.stroke();
  9308. }
  9309. // RENDER CIRCLE:
  9310. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9311. tmpContext = tmpContext || mainContext;
  9312. tmpContext.beginPath();
  9313. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9314. if (!dontFill) tmpContext.fill();
  9315. if (!dontStroke) tmpContext.stroke();
  9316. }
  9317. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9318. tmpContext = tmpContext || mainContext;
  9319. tmpContext.beginPath();
  9320. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9321. if (!dontFill) tmpContext.fill();
  9322. if (!dontStroke) tmpContext.stroke();
  9323. }
  9324. // RENDER STAR SHAPE:
  9325. function renderStar(ctxt, spikes, outer, inner) {
  9326. let rot = Math.PI / 2 * 3;
  9327. let x, y;
  9328. let step = Math.PI / spikes;
  9329. ctxt.beginPath();
  9330. ctxt.moveTo(0, -outer);
  9331. for (let i = 0; i < spikes; i++) {
  9332. x = Math.cos(rot) * outer;
  9333. y = Math.sin(rot) * outer;
  9334. ctxt.lineTo(x, y);
  9335. rot += step;
  9336. x = Math.cos(rot) * inner;
  9337. y = Math.sin(rot) * inner;
  9338. ctxt.lineTo(x, y);
  9339. rot += step;
  9340. }
  9341. ctxt.lineTo(0, -outer);
  9342. ctxt.closePath();
  9343. }
  9344. function renderHealthStar(ctxt, spikes, outer, inner) {
  9345. let rot = Math.PI / 2 * 3;
  9346. let x, y;
  9347. let step = Math.PI / spikes;
  9348. ctxt.beginPath();
  9349. ctxt.moveTo(0, -outer);
  9350. for (let i = 0; i < spikes; i++) {
  9351. x = Math.cos(rot) * outer;
  9352. y = Math.sin(rot) * outer;
  9353. ctxt.lineTo(x, y);
  9354. rot += step;
  9355. x = Math.cos(rot) * inner;
  9356. y = Math.sin(rot) * inner;
  9357. ctxt.lineTo(x, y);
  9358. rot += step;
  9359. }
  9360. ctxt.lineTo(0, -outer);
  9361. ctxt.closePath();
  9362. }
  9363. // RENDER RECTANGLE:
  9364. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9365. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9366. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9367. }
  9368. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9369. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9370. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9371. }
  9372. // RENDER RECTCIRCLE:
  9373. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9374. ctxt.save();
  9375. ctxt.translate(x, y);
  9376. seg = Math.ceil(seg / 2);
  9377. for (let i = 0; i < seg; i++) {
  9378. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9379. ctxt.rotate(Math.PI / seg);
  9380. }
  9381. ctxt.restore();
  9382. }
  9383. // RENDER BLOB:
  9384. function renderBlob(ctxt, spikes, outer, inner) {
  9385. let rot = Math.PI / 2 * 3;
  9386. let x, y;
  9387. let step = Math.PI / spikes;
  9388. let tmpOuter;
  9389. ctxt.beginPath();
  9390. ctxt.moveTo(0, -inner);
  9391. for (let i = 0; i < spikes; i++) {
  9392. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9393. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9394. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9395. rot += step * 2;
  9396. }
  9397. ctxt.lineTo(0, -inner);
  9398. ctxt.closePath();
  9399. }
  9400. // RENDER TRIANGLE:
  9401. function renderTriangle(s, ctx) {
  9402. ctx = ctx || mainContext;
  9403. let h = s * (Math.sqrt(3) / 2);
  9404. ctx.beginPath();
  9405. ctx.moveTo(0, -h / 2);
  9406. ctx.lineTo(-s / 2, h / 2);
  9407. ctx.lineTo(s / 2, h / 2);
  9408. ctx.lineTo(0, -h / 2);
  9409. ctx.fill();
  9410. ctx.closePath();
  9411. }
  9412. // PREPARE MENU BACKGROUND:
  9413. function prepareMenuBackground() {
  9414. let tmpMid = config.mapScale / 2;
  9415. let attempts = 0;
  9416. for (let i = 0; i < items.list.length * 10;) {
  9417. if (attempts >= 1000) break;
  9418. attempts++;
  9419. let type1 = items.list[15];
  9420. let type2 = items.list[9];
  9421. let data1 = {
  9422. x: tmpMid + UTILS.randFloat(-1000, 1000),
  9423. y: tmpMid + UTILS.randFloat(-600, 600),
  9424. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9425. };
  9426. if (objectManager.checkItemLocation(data1.x, data1.y, type1.scale, 0.6, type1.id, true)) {
  9427. objectManager.add(i, data1.x, data1.y, data1.dir, type1.scale, type1.id, type1);
  9428. let offsetX = UTILS.randFloat(-100, 100);
  9429. let offsetY = UTILS.randFloat(-100, 100);
  9430. let data2 = {
  9431. x: data1.x + offsetX,
  9432. y: data1.y + offsetY,
  9433. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9434. };
  9435. if (objectManager.checkItemLocation(data2.x, data2.y, type2.scale, 0.6, type2.id, true)) {
  9436. objectManager.add(i + 1, data2.x, data2.y, data2.dir, type2.scale, type2.id, type2);
  9437. } else {
  9438. continue;
  9439. }
  9440. } else {
  9441. continue;
  9442. }
  9443. i += 2;
  9444. }
  9445. }
  9446. const speed = 35;
  9447. // RENDER PLAYERS:
  9448. function renderDeadPlayers(xOffset, yOffset, deadAngle) {
  9449. mainContext.fillStyle = "#91b2db";
  9450. const currentTime = Date.now();
  9451. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9452. if (!dead.startTime) {
  9453. dead.startTime = currentTime;
  9454. dead.angle = 0;
  9455. dead.radius = 0.1;
  9456. }
  9457. const timeElapsed = currentTime - dead.startTime;
  9458. const maxAlpha = 1;
  9459. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9460. dead.animate(delta);
  9461. mainContext.globalAlpha = dead.alpha;
  9462. mainContext.strokeStyle = outlineColor;
  9463. mainContext.save();
  9464. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9465. dead.radius -= 0.001;
  9466. dead.angle += toRadian(1);
  9467. const moveSpeed = 40;
  9468. const x = dead.radius * Math.cos(deadAngle);
  9469. const y = dead.radius * Math.sin(deadAngle);
  9470. dead.x += x * moveSpeed;
  9471. dead.y += y * moveSpeed;
  9472. mainContext.rotate(dead.angle);
  9473. renderDeadPlayer(dead, mainContext);
  9474. mainContext.restore();
  9475. mainContext.fillStyle = "#bf8f54";
  9476. if (timeElapsed >= 3000) {
  9477. dead.active = false;
  9478. dead.startTime = null;
  9479. }
  9480. });
  9481. }
  9482. // RENDER PLAYERS:
  9483. let invisBody = false;
  9484. // RENDER PLAYERS:
  9485. function renderPlayers(xOffset, yOffset, zIndex) {
  9486. mainContext.globalAlpha = 1;
  9487. mainContext.fillStyle = "#91b2db";
  9488. for (var i = 0; i < players.length; ++i) {
  9489. tmpObj = players[i];
  9490. if (tmpObj.zIndex == zIndex) {
  9491. tmpObj.animate(delta);
  9492. if (tmpObj.visible) {
  9493. tmpObj.skinRot += (0.002 * delta);
  9494. tmpDir = (!configs.showDir && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir || 0);
  9495. mainContext.save();
  9496. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9497. // RENDER PLAYER:
  9498. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9499. if (tmpObj == player && invisBody) {
  9500. null;
  9501. } else {
  9502. renderPlayer(tmpObj, mainContext);
  9503. }
  9504. mainContext.restore();
  9505. }
  9506. }
  9507. }
  9508. }
  9509. // RENDER DEAD PLAYER:
  9510. function renderDeadPlayer(obj, ctxt) {
  9511. ctxt = ctxt || mainContext;
  9512. ctxt.lineWidth = outlineWidth;
  9513. ctxt.lineJoin = "miter";
  9514. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9515. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9516. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9517.  
  9518. // TAIL/CAPE:
  9519. renderTail2(13, ctxt, obj);
  9520.  
  9521. // WEAPON BELLOW HANDS:
  9522. if (obj.buildIndex < 0 && !items.weapons[10].aboveHand) {
  9523. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  9524. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9525. renderProjectile(obj.scale, 0,
  9526. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9527. }
  9528. }
  9529.  
  9530. // HANDS:
  9531. ctxt.fillStyle = "#ececec";
  9532. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9533. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9534. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9535.  
  9536. // WEAPON ABOVE HANDS:
  9537. if (obj.buildIndex < 0 && items.weapons[10].aboveHand) {
  9538. renderTool(items.weapons[10], config.weaponVariants[1].src || "", obj.scale, 0, ctxt);
  9539. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9540. renderProjectile(obj.scale, 0,
  9541. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9542. }
  9543. }
  9544.  
  9545. // BUILD ITEM:
  9546. if (obj.buildIndex >= 0) {
  9547. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9548. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9549. }
  9550.  
  9551. // BODY:
  9552. renderCircle(0, 0, obj.scale, ctxt);
  9553. // SKIN
  9554. renderSkin2(48, ctxt, null, obj)
  9555.  
  9556. }
  9557. // RENDER PLAYER:
  9558. function renderPlayer(obj, ctxt) {
  9559. ctxt = ctxt || mainContext;
  9560. ctxt.lineWidth = outlineWidth;
  9561. ctxt.lineJoin = "miter";
  9562. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9563. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9564. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9565. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9566. // TAIL/CAPE:
  9567. if (obj.tailIndex > 0) {
  9568. renderTail(obj.tailIndex, ctxt, obj);
  9569. }
  9570. // WEAPON BELLOW HANDS:
  9571. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9572. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9573. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9574. renderProjectile(obj.scale, 0,
  9575. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9576. }
  9577. }
  9578. // HANDS:
  9579. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9580. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9581. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9582. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9583. // WEAPON ABOVE HANDS:
  9584. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9585. renderTool(items.weapons[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. // BUILD ITEM:
  9592. if (obj.buildIndex >= 0) {
  9593. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9594. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9595. }
  9596. // BODY:
  9597. renderCircle(0, 0, obj.scale, ctxt);
  9598. // SKIN:
  9599. if (obj.skinIndex > 0) {
  9600. ctxt.rotate(Math.PI / 2);
  9601. renderSkin(obj.skinIndex, ctxt, null, obj);
  9602. }
  9603. }
  9604. // RENDER NORMAL SKIN
  9605. var skinSprites2 = {};
  9606. var skinPointers2 = {};
  9607. function renderSkin2(index, ctxt, parentSkin, owner) {
  9608. tmpSkin = skinSprites2[index];
  9609. if (!tmpSkin) {
  9610. var tmpImage = new Image();
  9611. tmpImage.onload = function() {
  9612. this.isLoaded = true;
  9613. this.onload = null;
  9614. };
  9615. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9616. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9617. skinSprites2[index] = tmpImage;
  9618. tmpSkin = tmpImage;
  9619. }
  9620. var tmpObj = parentSkin||skinPointers2[index];
  9621. if (!tmpObj) {
  9622. for (var i = 0; i < hats.length; ++i) {
  9623. if (hats[i].id == index) {
  9624. tmpObj = hats[i];
  9625. break;
  9626. }
  9627. }
  9628. skinPointers2[index] = tmpObj;
  9629. }
  9630. if (tmpSkin.isLoaded)
  9631. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9632. if (!parentSkin && tmpObj.topSprite) {
  9633. ctxt.save();
  9634. ctxt.rotate(owner.skinRot);
  9635. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9636. ctxt.restore();
  9637. }
  9638. }
  9639. // RENDER SKINS:
  9640. let skinSprites = {};
  9641. let skinPointers = {};
  9642. let tmpSkin;
  9643. function renderSkin(index, ctxt, parentSkin, owner) {
  9644. tmpSkin = skinSprites[index];
  9645. if (!tmpSkin) {
  9646. let tmpImage = new Image();
  9647. tmpImage.onload = function() {
  9648. this.isLoaded = true;
  9649. this.onload = null;
  9650. };
  9651. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9652. skinSprites[index] = tmpImage;
  9653. tmpSkin = tmpImage;
  9654. }
  9655. let tmpObj = parentSkin || skinPointers[index];
  9656. if (!tmpObj) {
  9657. for (let i = 0; i < hats.length; ++i) {
  9658. if (hats[i].id == index) {
  9659. tmpObj = hats[i];
  9660. break;
  9661. }
  9662. }
  9663. skinPointers[index] = tmpObj;
  9664. }
  9665. if (tmpSkin.isLoaded)
  9666. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9667. if (!parentSkin && tmpObj.topSprite) {
  9668. ctxt.save();
  9669. ctxt.rotate(owner.skinRot);
  9670. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9671. ctxt.restore();
  9672. }
  9673. }
  9674. // RENDER TAIL:
  9675. let accessSprites = {};
  9676. let accessPointers = {};
  9677. function renderTail(index, ctxt, owner) {
  9678. tmpSkin = accessSprites[index];
  9679. if (!tmpSkin) {
  9680. let tmpImage = new Image();
  9681. tmpImage.onload = function() {
  9682. this.isLoaded = true;
  9683. this.onload = null;
  9684. };
  9685. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9686. accessSprites[index] = tmpImage;
  9687. tmpSkin = tmpImage;
  9688. }
  9689. let tmpObj = accessPointers[index];
  9690. if (!tmpObj) {
  9691. for (let i = 0; i < accessories.length; ++i) {
  9692. if (accessories[i].id == index) {
  9693. tmpObj = accessories[i];
  9694. break;
  9695. }
  9696. }
  9697. accessPointers[index] = tmpObj;
  9698. }
  9699. if (tmpSkin.isLoaded) {
  9700. ctxt.save();
  9701. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9702. if (tmpObj.spin)
  9703. ctxt.rotate(owner.skinRot);
  9704. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9705. ctxt.restore();
  9706. }
  9707. }
  9708. // RENDER NORMAL TAIL
  9709. var accessSprites2 = {};
  9710. var accessPointers2 = {};
  9711. function renderTail2(index, ctxt, owner) {
  9712. tmpSkin = accessSprites2[index];
  9713. if (!tmpSkin) {
  9714. var tmpImage = new Image();
  9715. tmpImage.onload = function() {
  9716. this.isLoaded = true;
  9717. this.onload = null;
  9718. };
  9719. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9720. accessSprites2[index] = tmpImage;
  9721. tmpSkin = tmpImage;
  9722. }
  9723. var tmpObj = accessPointers2[index];
  9724. if (!tmpObj) {
  9725. for (var i = 0; i < accessories.length; ++i) {
  9726. if (accessories[i].id == index) {
  9727. tmpObj = accessories[i];
  9728. break;
  9729. }
  9730. }
  9731. accessPointers2[index] = tmpObj;
  9732. }
  9733. if (tmpSkin.isLoaded) {
  9734. ctxt.save();
  9735. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9736. if (tmpObj.spin)
  9737. ctxt.rotate(owner.skinRot);
  9738. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9739. ctxt.restore();
  9740. }
  9741. }
  9742. // RENDER TOOL:
  9743. let toolSprites = {};
  9744. function renderTool(obj, variant, x, y, ctxt) {
  9745. let tmpSrc = obj.src + (variant || "");
  9746. let tmpSprite = toolSprites[tmpSrc];
  9747. if (!tmpSprite) {
  9748. tmpSprite = new Image();
  9749. tmpSprite.onload = function() {
  9750. this.isLoaded = true;
  9751. }
  9752. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9753. toolSprites[tmpSrc] = tmpSprite;
  9754. }
  9755. if (tmpSprite.isLoaded)
  9756. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9757. }
  9758. // RENDER PROJECTILES:
  9759. function renderProjectiles(layer, xOffset, yOffset) {
  9760. for (let i = 0; i < projectiles.length; i++) {
  9761. tmpObj = projectiles[i];
  9762. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9763. tmpObj.update(delta);
  9764. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9765. mainContext.save();
  9766. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9767. mainContext.rotate(tmpObj.dir);
  9768. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9769. mainContext.restore();
  9770. }
  9771. }
  9772. };
  9773. }
  9774. // RENDER PROJECTILE:
  9775. let projectileSprites = {};
  9776. function renderProjectile(x, y, obj, ctxt, debug) {
  9777. if (obj.src) {
  9778. let tmpSrc = items.projectiles[obj.indx].src;
  9779. let tmpSprite = projectileSprites[tmpSrc];
  9780. if (!tmpSprite) {
  9781. tmpSprite = new Image();
  9782. tmpSprite.onload = function() {
  9783. this.isLoaded = true;
  9784. }
  9785. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9786. projectileSprites[tmpSrc] = tmpSprite;
  9787. }
  9788. if (tmpSprite.isLoaded)
  9789. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9790. } else if (obj.indx == 1) {
  9791. ctxt.fillStyle = "#939393";
  9792. renderCircle(x, y, obj.scale, ctxt);
  9793. }
  9794. }
  9795. // RENDER AI:
  9796. let aiSprites = {};
  9797. function renderAI(obj, ctxt) {
  9798. let tmpIndx = obj.index;
  9799. let tmpSprite = aiSprites[tmpIndx];
  9800. if (!tmpSprite) {
  9801. let tmpImg = new Image();
  9802. tmpImg.onload = function() {
  9803. this.isLoaded = true;
  9804. this.onload = null;
  9805. };
  9806. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9807. tmpSprite = tmpImg;
  9808. aiSprites[tmpIndx] = tmpSprite;
  9809. }
  9810. if (tmpSprite.isLoaded) {
  9811. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9812. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9813. }
  9814. }
  9815. // RENDER WATER BODIES:
  9816. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9817. // MIDDLE RIVER:
  9818. let tmpW = config.riverWidth + padding;
  9819. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9820. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9821. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9822. }
  9823. }
  9824. // RENDER GAME OBJECTS:
  9825. let gameObjectSprites = {};
  9826. function getResSprite(obj) {
  9827. let biomeID = (obj.y>=config.mapScale-config.snowBiomeTop)?2:((obj.y<=config.snowBiomeTop)?1:0);
  9828. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9829. let tmpSprite = gameObjectSprites[tmpIndex];
  9830. if (!tmpSprite) {
  9831. let blurScale = 15;
  9832. let tmpCanvas = document.createElement("canvas");
  9833. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9834. let tmpContext = tmpCanvas.getContext('2d');
  9835. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9836. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9837. tmpContext.strokeStyle = outlineColor;
  9838. tmpContext.lineWidth = outlineWidth;
  9839. if (isNight) {
  9840. tmpContext.shadowBlur = blurScale;
  9841. tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9842. }
  9843. if (obj.type == 0) {
  9844. let tmpScale;
  9845. let tmpCount = UTILS.randInt(5, 7);
  9846. tmpContext.globalAlpha = isNight ? 0.6 : 0.8;
  9847. for (let i = 0; i < 2; ++i) {
  9848. tmpScale = tmpObj.scale * (!i?1:0.5);
  9849. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9850. tmpContext.fillStyle = !biomeID?(!i?"#9ebf57":"#b4db62"):(!i?"#e3f1f4":"#fff");
  9851. tmpContext.fill();
  9852. if (!i) {
  9853. tmpContext.stroke();
  9854. tmpContext.shadowBlur = null;
  9855. tmpContext.shadowColor = null;
  9856. tmpContext.globalAlpha = 1;
  9857. }
  9858. }
  9859. } else if (obj.type == 1) {
  9860. if (biomeID == 2) {
  9861. tmpContext.fillStyle = "#606060";
  9862. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9863. tmpContext.fill();
  9864. tmpContext.stroke();
  9865.  
  9866. //tmpContext.shadowBlur = null;
  9867. //tmpContext.shadowColor = null;
  9868.  
  9869. tmpContext.fillStyle = "#89a54c";
  9870. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9871. tmpContext.fillStyle = "#a5c65b";
  9872. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9873. } else {
  9874. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9875. tmpContext.fillStyle = biomeID?"#e3f1f4":"#89a54c";
  9876. tmpContext.fill();
  9877. tmpContext.stroke();
  9878.  
  9879. //tmpContext.shadowBlur = null;
  9880. //tmpContext.shadowColor = null;
  9881.  
  9882. tmpContext.fillStyle = biomeID?"#6a64af":"#c15555";
  9883. let tmpRange;
  9884. let berries = 4;
  9885. let rotVal = (Math.PI * 2) / berries;
  9886. for (let i = 0; i < berries; ++i) {
  9887. tmpRange = UTILS.randInt(tmpObj.scale/3.5, tmpObj.scale/2.3);
  9888. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9889. UTILS.randInt(10, 12), tmpContext);
  9890. }
  9891. }
  9892. } else if (obj.type == 2 || obj.type == 3) {
  9893. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#938d77":"#939393"):"#e0c655";
  9894. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9895. tmpContext.fill();
  9896. tmpContext.stroke();
  9897.  
  9898. tmpContext.shadowBlur = null;
  9899. tmpContext.shadowColor = null;
  9900.  
  9901. tmpContext.fillStyle = (obj.type==2)?(biomeID==2?"#b2ab90":"#bcbcbc"):"#ebdca3";
  9902. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9903. tmpContext.fill();
  9904. }
  9905. tmpSprite = tmpCanvas;
  9906. gameObjectSprites[tmpIndex] = tmpSprite;
  9907. }
  9908. return tmpSprite;
  9909. }
  9910.  
  9911. // GET ITEM SPRITE:
  9912. let itemSprites = [];
  9913. function getItemSprite(obj, asIcon) {
  9914. let tmpSprite = itemSprites[obj.id];
  9915. if (!tmpSprite || asIcon) {
  9916. let blurScale = !asIcon && isNight ? 15 : 0;
  9917. let tmpCanvas = document.createElement("canvas");
  9918. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9919. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9920. let tmpContext = tmpCanvas.getContext("2d");
  9921. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9922. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9923. tmpContext.strokeStyle = outlineColor;
  9924. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9925. if (isNight && !asIcon) {
  9926. tmpContext.shadowBlur = blurScale;
  9927. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(obj.name == "pit trap" ? 0.6 : 0.3, obj.alpha)})`;
  9928. }
  9929. if (obj.name == "apple") {
  9930. tmpContext.fillStyle = "#c15555";
  9931. renderCircle(0, 0, obj.scale, tmpContext);
  9932. tmpContext.fillStyle = "#89a54c";
  9933. let leafDir = -(Math.PI / 2);
  9934. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9935. 25, leafDir + Math.PI / 2, tmpContext);
  9936. } else if (obj.name == "cookie") {
  9937. tmpContext.fillStyle = "#cca861";
  9938. renderCircle(0, 0, obj.scale, tmpContext);
  9939. tmpContext.fillStyle = "#937c4b";
  9940. let chips = 4;
  9941. let rotVal = (Math.PI * 2) / chips;
  9942. let tmpRange;
  9943. for (let i = 0; i < chips; ++i) {
  9944. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9945. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9946. UTILS.randInt(4, 5), tmpContext, true);
  9947. }
  9948. } else if (obj.name == "cheese") {
  9949. tmpContext.fillStyle = "#f4f3ac";
  9950. renderCircle(0, 0, obj.scale, tmpContext);
  9951. tmpContext.fillStyle = "#c3c28b";
  9952. let chips = 4;
  9953. let rotVal = (Math.PI * 2) / chips;
  9954. let tmpRange;
  9955. for (let i = 0; i < chips; ++i) {
  9956. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9957. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9958. UTILS.randInt(4, 5), tmpContext, true);
  9959. }
  9960. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9961. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  9962. "#a5974c" : "#939393";
  9963. let sides = (obj.name == "castle wall") ? 4 : 3;
  9964. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9965. tmpContext.fill();
  9966. tmpContext.stroke();
  9967. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9968. "#c9b758" : "#bcbcbc";
  9969. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9970. tmpContext.fill();
  9971. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9972. obj.name == "spinning spikes") {
  9973. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  9974. let tmpScale = (obj.scale * 0.6);
  9975. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9976. tmpContext.fill();
  9977. tmpContext.stroke();
  9978. tmpContext.fillStyle = "#a5974c";
  9979. renderCircle(0, 0, tmpScale, tmpContext);
  9980. tmpContext.fillStyle = "#c9b758";
  9981. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9982. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9983. tmpContext.fillStyle = "#a5974c";
  9984. renderCircle(0, 0, reScale, tmpContext);
  9985. tmpContext.fillStyle = "#c9b758";
  9986. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9987. tmpContext.fillStyle = "#a5974c";
  9988. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9989. } else if (obj.name == "mine") {
  9990. tmpContext.fillStyle = "#939393";
  9991. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9992. tmpContext.fill();
  9993. tmpContext.stroke();
  9994. tmpContext.fillStyle = "#bcbcbc";
  9995. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9996. tmpContext.fill();
  9997. } else if (obj.name == "sapling") {
  9998. for (let i = 0; i < 2; ++i) {
  9999. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10000. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10001. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10002. tmpContext.fill();
  10003. if (!i) tmpContext.stroke();
  10004. }
  10005. } else if (obj.name == "pit trap") {
  10006. tmpContext.fillStyle = "#a5974c";
  10007. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10008. tmpContext.fill();
  10009. tmpContext.stroke();
  10010. tmpContext.fillStyle = outlineColor;
  10011. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10012. tmpContext.fill();
  10013. } else if (obj.name == "boost pad") {
  10014. tmpContext.fillStyle = "#7e7f82";
  10015. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10016. tmpContext.fill();
  10017. tmpContext.stroke();
  10018. tmpContext.fillStyle = "#dbd97d";
  10019. renderTriangle(obj.scale * 1, tmpContext);
  10020. } else if (obj.name == "turret") {
  10021. tmpContext.fillStyle = "#a5974c";
  10022. renderCircle(0, 0, obj.scale, tmpContext);
  10023. tmpContext.fill();
  10024. tmpContext.stroke();
  10025. tmpContext.fillStyle = "#939393";
  10026. let tmpLen = 50;
  10027. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10028. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10029. tmpContext.fill();
  10030. tmpContext.stroke();
  10031. } else if (obj.name == "platform") {
  10032. tmpContext.fillStyle = "#cebd5f";
  10033. let tmpCount = 4;
  10034. let tmpS = obj.scale * 2;
  10035. let tmpW = tmpS / tmpCount;
  10036. let tmpX = -(obj.scale / 2);
  10037. for (let i = 0; i < tmpCount; ++i) {
  10038. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10039. tmpContext.fill();
  10040. tmpContext.stroke();
  10041. tmpX += tmpS / tmpCount;
  10042. }
  10043. } else if (obj.name == "healing pad") {
  10044. tmpContext.fillStyle = "#7e7f82";
  10045. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10046. tmpContext.fill();
  10047. tmpContext.stroke();
  10048. tmpContext.fillStyle = "#db6e6e";
  10049. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10050. } else if (obj.name == "spawn pad") {
  10051. tmpContext.fillStyle = "#7e7f82";
  10052. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10053. tmpContext.fill();
  10054. tmpContext.stroke();
  10055. tmpContext.fillStyle = "#71aad6";
  10056. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10057. } else if (obj.name == "blocker") {
  10058. tmpContext.fillStyle = "#7e7f82";
  10059. renderCircle(0, 0, obj.scale, tmpContext);
  10060. tmpContext.fill();
  10061. tmpContext.stroke();
  10062. tmpContext.rotate(Math.PI / 4);
  10063. tmpContext.fillStyle = "#db6e6e";
  10064. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10065. } else if (obj.name == "teleporter") {
  10066. tmpContext.fillStyle = "#7e7f82";
  10067. renderCircle(0, 0, obj.scale, tmpContext);
  10068. tmpContext.fill();
  10069. tmpContext.stroke();
  10070. tmpContext.rotate(Math.PI / 4);
  10071. tmpContext.fillStyle = "#d76edb";
  10072. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10073. }
  10074. tmpSprite = tmpCanvas;
  10075. if (!asIcon)
  10076. itemSprites[obj.id] = tmpSprite;
  10077. }
  10078. return tmpSprite;
  10079. }
  10080.  
  10081. function getItemSprite2(obj, tmpX, tmpY) {
  10082. let tmpContext = mainContext;
  10083. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  10084. tmpContext.save();
  10085. tmpContext.translate(tmpX, tmpY);
  10086. tmpContext.rotate(obj.dir);
  10087. tmpContext.strokeStyle = outlineColor;
  10088. tmpContext.lineWidth = outlineWidth;
  10089. if (obj.name == "apple") {
  10090. tmpContext.fillStyle = "#c15555";
  10091. renderCircle(0, 0, obj.scale, tmpContext);
  10092. tmpContext.fillStyle = "#89a54c";
  10093. let leafDir = -(Math.PI / 2);
  10094. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10095. 25, leafDir + Math.PI / 2, tmpContext);
  10096. } else if (obj.name == "cookie") {
  10097. tmpContext.fillStyle = "#cca861";
  10098. renderCircle(0, 0, obj.scale, tmpContext);
  10099. tmpContext.fillStyle = "#937c4b";
  10100. let chips = 4;
  10101. let rotVal = (Math.PI * 2) / chips;
  10102. let tmpRange;
  10103. for (let i = 0; i < chips; ++i) {
  10104. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10105. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10106. UTILS.randInt(4, 5), tmpContext, true);
  10107. }
  10108. } else if (obj.name == "cheese") {
  10109. tmpContext.fillStyle = "#f4f3ac";
  10110. renderCircle(0, 0, obj.scale, tmpContext);
  10111. tmpContext.fillStyle = "#c3c28b";
  10112. let chips = 4;
  10113. let rotVal = (Math.PI * 2) / chips;
  10114. let tmpRange;
  10115. for (let i = 0; i < chips; ++i) {
  10116. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10117. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10118. UTILS.randInt(4, 5), tmpContext, true);
  10119. }
  10120. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10121. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10122. "#a5974c" : "#939393";
  10123. let sides = (obj.name == "castle wall") ? 4 : 3;
  10124. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10125. tmpContext.fill();
  10126. tmpContext.stroke();
  10127. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10128. "#c9b758" : "#bcbcbc";
  10129. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10130. tmpContext.fill();
  10131. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10132. obj.name == "spinning spikes") {
  10133. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10134. let tmpScale = (obj.scale * 0.6);
  10135. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10136. tmpContext.fill();
  10137. tmpContext.stroke();
  10138. tmpContext.fillStyle = "#a5974c";
  10139. renderCircle(0, 0, tmpScale, tmpContext);
  10140. tmpContext.fillStyle = "#c9b758";
  10141. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10142. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10143. tmpContext.fillStyle = "#a5974c";
  10144. renderCircle(0, 0, reScale, tmpContext);
  10145. tmpContext.fillStyle = "#c9b758";
  10146. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10147. tmpContext.fillStyle = "#a5974c";
  10148. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10149. } else if (obj.name == "mine") {
  10150. tmpContext.fillStyle = "#939393";
  10151. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10152. tmpContext.fill();
  10153. tmpContext.stroke();
  10154. tmpContext.fillStyle = "#bcbcbc";
  10155. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10156. tmpContext.fill();
  10157. } else if (obj.name == "sapling") {
  10158. for (let i = 0; i < 2; ++i) {
  10159. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10160. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10161. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10162. tmpContext.fill();
  10163. if (!i) tmpContext.stroke();
  10164. }
  10165. } else if (obj.name == "pit trap") {
  10166. tmpContext.fillStyle = "#a5974c";
  10167. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10168. tmpContext.fill();
  10169. tmpContext.stroke();
  10170. tmpContext.fillStyle = outlineColor;
  10171. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10172. tmpContext.fill();
  10173. } else if (obj.name == "boost pad") {
  10174. tmpContext.fillStyle = "#7e7f82";
  10175. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10176. tmpContext.fill();
  10177. tmpContext.stroke();
  10178. tmpContext.fillStyle = "#dbd97d";
  10179. renderTriangle(obj.scale * 1, tmpContext);
  10180. } else if (obj.name == "turret") {
  10181. tmpContext.fillStyle = "#a5974c";
  10182. renderCircle(0, 0, obj.scale, tmpContext);
  10183. tmpContext.fill();
  10184. tmpContext.stroke();
  10185. tmpContext.fillStyle = "#939393";
  10186. let tmpLen = 50;
  10187. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10188. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10189. tmpContext.fill();
  10190. tmpContext.stroke();
  10191. } else if (obj.name == "platform") {
  10192. tmpContext.fillStyle = "#cebd5f";
  10193. let tmpCount = 4;
  10194. let tmpS = obj.scale * 2;
  10195. let tmpW = tmpS / tmpCount;
  10196. let tmpX = -(obj.scale / 2);
  10197. for (let i = 0; i < tmpCount; ++i) {
  10198. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10199. tmpContext.fill();
  10200. tmpContext.stroke();
  10201. tmpX += tmpS / tmpCount;
  10202. }
  10203. } else if (obj.name == "healing pad") {
  10204. tmpContext.fillStyle = "#7e7f82";
  10205. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10206. tmpContext.fill();
  10207. tmpContext.stroke();
  10208. tmpContext.fillStyle = "#db6e6e";
  10209. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10210. } else if (obj.name == "spawn pad") {
  10211. tmpContext.fillStyle = "#7e7f82";
  10212. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10213. tmpContext.fill();
  10214. tmpContext.stroke();
  10215. tmpContext.fillStyle = "#71aad6";
  10216. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10217. } else if (obj.name == "blocker") {
  10218. tmpContext.fillStyle = "#7e7f82";
  10219. renderCircle(0, 0, obj.scale, tmpContext);
  10220. tmpContext.fill();
  10221. tmpContext.stroke();
  10222. tmpContext.rotate(Math.PI / 4);
  10223. tmpContext.fillStyle = "#db6e6e";
  10224. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10225. } else if (obj.name == "teleporter") {
  10226. tmpContext.fillStyle = "#7e7f82";
  10227. renderCircle(0, 0, obj.scale, tmpContext);
  10228. tmpContext.fill();
  10229. tmpContext.stroke();
  10230. tmpContext.rotate(Math.PI / 4);
  10231. tmpContext.fillStyle = "#d76edb";
  10232. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10233. }
  10234. tmpContext.restore();
  10235. }
  10236.  
  10237. let objSprites = [];
  10238. function getObjSprite(obj) {
  10239. let tmpSprite = objSprites[obj.id];
  10240. if (!tmpSprite) {
  10241. let blurScale = isNight ? 15 : 0;
  10242. let tmpCanvas = document.createElement("canvas");
  10243. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10244. let tmpContext = tmpCanvas.getContext("2d");
  10245. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10246. tmpContext.rotate(Math.PI / 2);
  10247. tmpContext.strokeStyle = outlineColor;
  10248. tmpContext.lineWidth = outlineWidth;
  10249. if (isNight) {
  10250. tmpContext.shadowBlur = blurScale;
  10251. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10252. }
  10253. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10254. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  10255. let tmpScale = obj.scale * 0.6;
  10256. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10257. tmpContext.fill();
  10258. tmpContext.stroke();
  10259. tmpContext.fillStyle = "#a5974c";
  10260. renderCircle(0, 0, tmpScale, tmpContext);
  10261. tmpContext.fillStyle = "#cc5151";
  10262. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10263. } else if (obj.name == "pit trap") {
  10264. tmpContext.fillStyle = "#a5974c";
  10265. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10266. tmpContext.fill();
  10267. tmpContext.stroke();
  10268. tmpContext.fillStyle = "#cc5151";
  10269. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10270. tmpContext.fill();
  10271. }
  10272. tmpSprite = tmpCanvas;
  10273. objSprites[obj.id] = tmpSprite;
  10274. }
  10275. return tmpSprite;
  10276. }
  10277.  
  10278. // GET MARK SPRITE:
  10279. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10280.  
  10281. let center = {
  10282. x: screenWidth / 2,
  10283. y: screenHeight / 2,
  10284. };
  10285. tmpContext.lineWidth = outlineWidth;
  10286. mainContext.globalAlpha = 0.4;
  10287. tmpContext.strokeStyle = outlineColor;
  10288. tmpContext.save();
  10289. tmpContext.translate(tmpX, tmpY);
  10290. tmpContext.rotate(obj.dir || getAttackDir());
  10291. if (getEl("renderplace").value == "placeVis") {
  10292. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10293. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  10294. var tmpScale = (obj.scale * 0.6);
  10295. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  10296. tmpContext.fill();
  10297. tmpContext.stroke();
  10298. tmpContext.fillStyle = "#a5974c";
  10299. renderCircle(0, 0, tmpScale, tmpContext);
  10300. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10301. tmpContext.fillStyle = "#a34040";
  10302. } else {
  10303. tmpContext.fillStyle = "#c9b758";
  10304. }
  10305. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  10306. } else if (obj.name == "turret") {
  10307. tmpContext.fillStyle = "#a5974c";
  10308. renderCircle(0, 0, obj.scale, tmpContext);
  10309. tmpContext.fill();
  10310. tmpContext.stroke();
  10311. tmpContext.fillStyle = "#939393";
  10312. let tmpLen = 50;
  10313. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10314. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10315. tmpContext.fill();
  10316. tmpContext.stroke();
  10317. } else if (obj.name == "teleporter") {
  10318. tmpContext.fillStyle = "#7e7f82";
  10319. renderCircle(0, 0, obj.scale, tmpContext);
  10320. tmpContext.fill();
  10321. tmpContext.stroke();
  10322. tmpContext.rotate(Math.PI / 4);
  10323. tmpContext.fillStyle = "#d76edb";
  10324. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10325. } else if (obj.name == "platform") {
  10326. tmpContext.fillStyle = "#cebd5f";
  10327. let tmpCount = 4;
  10328. let tmpS = obj.scale * 2;
  10329. let tmpW = tmpS / tmpCount;
  10330. let tmpX = -(obj.scale / 2);
  10331. for (let i = 0; i < tmpCount; ++i) {
  10332. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10333. tmpContext.fill();
  10334. tmpContext.stroke();
  10335. tmpX += tmpS / tmpCount;
  10336. }
  10337. } else if (obj.name == "healing pad") {
  10338. tmpContext.fillStyle = "#7e7f82";
  10339. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10340. tmpContext.fill();
  10341. tmpContext.stroke();
  10342. tmpContext.fillStyle = "#db6e6e";
  10343. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10344. } else if (obj.name == "spawn pad") {
  10345. tmpContext.fillStyle = "#7e7f82";
  10346. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10347. tmpContext.fill();
  10348. tmpContext.stroke();
  10349. tmpContext.fillStyle = "#71aad6";
  10350. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10351. } else if (obj.name == "blocker") {
  10352. tmpContext.fillStyle = "#7e7f82";
  10353. renderCircle(0, 0, obj.scale, tmpContext);
  10354. tmpContext.fill();
  10355. tmpContext.stroke();
  10356. tmpContext.rotate(Math.PI / 4);
  10357. tmpContext.fillStyle = "#db6e6e";
  10358. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10359. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10360. tmpContext.fillStyle = "#a5974c";
  10361. renderCircle(0, 0, obj.scale, tmpContext);
  10362. tmpContext.fillStyle = "#c9b758";
  10363. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10364. tmpContext.fillStyle = "#a5974c";
  10365. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10366. } else if (obj.name == "pit trap") {
  10367. tmpContext.fillStyle = "#a5974c";
  10368. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10369. tmpContext.fill();
  10370. tmpContext.stroke();
  10371. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10372. tmpContext.fillStyle = "#a34040";
  10373. } else {
  10374. tmpContext.fillStyle = outlineColor;
  10375. }
  10376. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10377. tmpContext.fill();
  10378. }
  10379. tmpContext.restore();
  10380. }
  10381. }
  10382. function getMarkSprite2(obj, tmpContext, tmpX, tmpY) {
  10383.  
  10384. if (getEl("renderplace").value == "outline") {
  10385. tmpContext.lineWidth = outlineWidth;
  10386. mainContext.globalAlpha = 1;
  10387. tmpContext.strokeStyle = outlineColor;
  10388. tmpContext.save();
  10389. tmpContext.translate(tmpX, tmpY);
  10390. tmpContext.rotate(obj.dir || getAttackDir());
  10391.  
  10392. if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10393. let sides = obj.name == "castle wall" ? 4 : 3;
  10394. renderHealthStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10395. tmpContext.stroke();
  10396. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10397. let tmpScale = obj.scale * 0.6;
  10398. renderHealthStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10399. tmpContext.stroke();
  10400. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10401. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10402. } else if (obj.name == "mine") {
  10403. renderHealthStar(tmpContext, 3, obj.scale, obj.scale);
  10404. tmpContext.stroke();
  10405. } else if (obj.name == "sapling") {
  10406. let tmpScale = obj.scale * 0.7;
  10407. renderHealthStar(tmpContext, 7, obj.scale, tmpScale);
  10408. tmpContext.stroke();
  10409. } else if (obj.name == "pit trap") {
  10410. renderHealthStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10411. tmpContext.stroke();
  10412. } else if (obj.name == "boost pad") {
  10413. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10414. } else if (obj.name == "turret") {
  10415. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10416. } else if (obj.name == "platform") {
  10417. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10418. } else if (obj.name == "healing pad") {
  10419. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10420. } else if (obj.name == "spawn pad") {
  10421. renderHealthRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext, false, true);
  10422. } else if (obj.name == "blocker") {
  10423. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10424. } else if (obj.name == "teleporter") {
  10425. renderHealthCircle(0, 0, obj.scale, tmpContext, false, true);
  10426. }
  10427. tmpContext.restore();
  10428.  
  10429. }
  10430. }
  10431. //renderCircle(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.getScale(0.6, true), mainContext, false, true);
  10432. // OBJECT ON SCREEN:
  10433. function isOnScreen(x, y, s) {
  10434. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10435. s,
  10436. maxScreenHeight));
  10437. }
  10438. /* function markObject(tmpObj, tmpX, tmpY) {
  10439. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10440. }*/
  10441. function markObject(tmpObj, tmpX, tmpY) {
  10442. yen(mainContext, tmpX, tmpY);
  10443. }
  10444. function yen(context, x, y) {
  10445. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  10446. context.beginPath();
  10447. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  10448. context.fill();
  10449. context.closePath();
  10450. context.globalAlpha = 1;
  10451. }
  10452. // RENDER MINIMAP:
  10453. class MapPing {
  10454. constructor(color, scale) {
  10455. this.init = function(x, y) {
  10456. this.scale = 0;
  10457. this.x = x;
  10458. this.y = y;
  10459. this.active = true;
  10460. };
  10461. this.update = function(ctxt, delta) {
  10462. if (this.active) {
  10463. this.scale += 0.05 * delta;
  10464. if (this.scale >= scale) {
  10465. this.active = false;
  10466. } else {
  10467. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10468. ctxt.beginPath();
  10469. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale)
  10470. * mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10471. ctxt.stroke();
  10472. }
  10473. }
  10474. };
  10475. this.color = color;
  10476. }
  10477. }
  10478. function pingMap(x, y) {
  10479. tmpPing = mapPings.find(pings => !pings.active);
  10480. if (!tmpPing) {
  10481. tmpPing = new MapPing("#fff", config.mapPingScale);
  10482. mapPings.push(tmpPing);
  10483. }
  10484. tmpPing.init(x, y);
  10485. }
  10486. function updateMapMarker() {
  10487. mapMarker.x = player.x;
  10488. mapMarker.y = player.y;
  10489. }
  10490. function renderMinimap(delta) {
  10491. if (player && player.alive) {
  10492. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10493. // RENDER PINGS:
  10494. mapContext.lineWidth = 4;
  10495. for (let i = 0; i < mapPings.length; ++i) {
  10496. tmpPing = mapPings[i];
  10497. mapContext.strokeStyle = tmpPing.color;
  10498. tmpPing.update(mapContext, delta);
  10499. }
  10500. // RENDER BREAK TRACKS:
  10501. mapContext.globalAlpha = 1;
  10502. mapContext.fillStyle = "#ff0000";
  10503. if (breakTrackers.length) {
  10504. mapContext.fillStyle = "#abcdef";
  10505. mapContext.font = "34px Hammersmith One";
  10506. mapContext.textBaseline = "middle";
  10507. mapContext.textAlign = "center";
  10508. for (let i = 0; i < breakTrackers.length;) {
  10509. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  10510. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  10511. i += 2;
  10512. }
  10513. }
  10514. // RENDER PLAYERS:
  10515. mapContext.globalAlpha = 1;
  10516. mapContext.fillStyle = "#fff";
  10517. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10518. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10519. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10520. if (player.team && minimapData) {
  10521. for (let i = 0; i < minimapData.length;) {
  10522. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10523. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10524. i += 2;
  10525. }
  10526. }
  10527. // RENDER BOTS:
  10528. if (bots.length) {
  10529. bots.forEach((tmp) => {
  10530. if (tmp.inGame) {
  10531. mapContext.globalAlpha = 1;
  10532. mapContext.strokeStyle = "#782F44";
  10533. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10534. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10535. }
  10536. });
  10537. }
  10538. // DEATH LOCATION:
  10539. if (lastDeath) {
  10540. mapContext.fillStyle = "#fc5553";
  10541. mapContext.font = "34px Hammersmith One";
  10542. mapContext.textBaseline = "middle";
  10543. mapContext.textAlign = "center";
  10544. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10545. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10546. }
  10547. // MAP MARKER:
  10548. if (mapMarker) {
  10549. mapContext.fillStyle = "#fff";
  10550. mapContext.font = "34px Hammersmith One";
  10551. mapContext.textBaseline = "middle";
  10552. mapContext.textAlign = "center";
  10553. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10554. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10555. }
  10556. }
  10557. }
  10558. // ICONS:
  10559. 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.
  10560. let crossHairSprites = {};
  10561. let iconSprites = {};
  10562. let icons = ["crown", "skull"];
  10563.  
  10564. function loadIcons() {
  10565. for (let i = 0; i < icons.length; ++i) {
  10566. let tmpSprite = new Image();
  10567. tmpSprite.onload = function() {
  10568. this.isLoaded = true;
  10569. };
  10570. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10571. iconSprites[icons[i]] = tmpSprite;
  10572. }
  10573. let tmpSprite = new Image();
  10574. tmpSprite.onload = function() {
  10575. this.isLoaded = true;
  10576. };
  10577. tmpSprite.src = crossHairs
  10578. crossHairSprites = tmpSprite;
  10579. }
  10580. loadIcons();
  10581. // UPDATE GAME:
  10582. function updateGame() {
  10583. if (config.resetRender) {
  10584. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10585. mainContext.beginPath();
  10586. }
  10587. function add(array) {
  10588. let lmao = 0
  10589. for (let i = 0; i < array.length; i++) {
  10590. lmao += array[i]
  10591. }
  10592. return lmao / array.length
  10593. }
  10594. if (true) {
  10595. function updateCamera() {
  10596. let selectedCamera = document.getElementById("camera").value;
  10597. let damping = 0.35;
  10598. let scalingFactor = 20;
  10599. if (player) {
  10600. if (selectedCamera === 'Cam1') {
  10601. let damping = 0.1;
  10602. let targetCamX = player.x + ((1920 / 2) / 30);
  10603. let targetCamY = player.y + ((1920 / 2) / 30);
  10604. camX += (targetCamX - camX) * damping;
  10605. camY += (targetCamY - camY) * damping;
  10606. } else if (selectedCamera === 'Cam2' || selectedCamera === 'Cam3') {
  10607. let damping2 = 0.016;
  10608. if (player) {
  10609. let targetCamX = player.x + ((1920 / 2) / 30);
  10610. let targetCamY = player.y + ((1920 / 2) / 30);
  10611. camX = lerp(camX, targetCamX, damping2);
  10612. camY = lerp(camY, targetCamY, damping2);
  10613. } else {
  10614. camX = config.mapScale / 2;
  10615. camY = config.mapScale / 2;
  10616. }
  10617. }
  10618. } else {
  10619. camX = config.mapScale / 2;
  10620. camY = config.mapScale / 2;
  10621. }
  10622. }
  10623. updateCamera()
  10624. document.getElementById("camera").addEventListener("change", updateCamera);
  10625. function lerp(start, end, amt) {
  10626. return (1 - amt) * start + amt * end;
  10627. }
  10628. // INTERPOLATE PLAYERS AND AI:
  10629. let lastTime = now - (1000 / config.serverUpdateRate);
  10630. let tmpDiff;
  10631. for (let i = 0; i < players.length + ais.length; ++i) {
  10632. tmpObj = players[i] || ais[i - players.length];
  10633. if (tmpObj && tmpObj.visible) {
  10634. if (tmpObj.forcePos) {
  10635. tmpObj.x = tmpObj.x2;
  10636. tmpObj.y = tmpObj.y2;
  10637. tmpObj.dir = tmpObj.d2;
  10638. } else {
  10639. let total = tmpObj.t2 - tmpObj.t1;
  10640. let fraction = lastTime - tmpObj.t1;
  10641. let ratio = (fraction / total);
  10642. let rate = 170;
  10643. tmpObj.dt += delta;
  10644. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10645. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10646. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10647. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10648. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10649. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10650. }
  10651. }
  10652. }
  10653. // RENDER CORDS:
  10654. let xOffset = camX - (maxScreenWidth / 2);
  10655. let yOffset = camY - (maxScreenHeight / 2);
  10656. // RENDER BACKGROUND:
  10657. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10658. mainContext.fillStyle = "#87b522";
  10659. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10660. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10661. mainContext.fillStyle = "#bfa426";
  10662. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10663. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10664. mainContext.fillStyle = "#defdff";
  10665. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10666. } else if (config.snowBiomeTop - yOffset >= 0) {
  10667. mainContext.fillStyle = "#defdff";
  10668. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10669. mainContext.fillStyle = "#b6db66";
  10670. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10671. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10672. } else {
  10673. mainContext.fillStyle = "#b6db66";
  10674. mainContext.fillRect(0, 0, maxScreenWidth,
  10675. (config.mapScale - config.snowBiomeTop - yOffset));
  10676. mainContext.fillStyle = "#dbc666";
  10677. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10678. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10679. }
  10680.  
  10681. // RENDER WATER AREAS:
  10682. if (!firstSetup) {
  10683. waterMult += waterPlus * config.waveSpeed * delta;
  10684. if (waterMult >= config.waveMax) {
  10685. waterMult = config.waveMax;
  10686. waterPlus = -1;
  10687. } else if (waterMult <= 1) {
  10688. waterMult = waterPlus = 1;
  10689. }
  10690. mainContext.globalAlpha = 1;
  10691. mainContext.fillStyle = "#e8a033";
  10692. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10693. mainContext.fillStyle = "#91c5ff";
  10694. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10695. }
  10696. if (player) {
  10697. // DEATH LOCATION:
  10698. if (lastDeath) {
  10699. mainContext.globalAlpha = 1;
  10700. mainContext.fillStyle = "#fc5553";
  10701. mainContext.font = "100px Hammersmith One";
  10702. mainContext.textBaseline = "middle";
  10703. mainContext.textAlign = "center";
  10704. mainContext.fillText("x", lastDeath.x - xOffset, lastDeath.y - yOffset);
  10705. }
  10706. // PATHFINDER LINE:
  10707. if (pathFind.active) {
  10708. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10709. mainContext.lineWidth = player.scale / 5;
  10710. mainContext.globalAlpha = 1;
  10711. mainContext.strokeStyle = "red";
  10712. mainContext.beginPath();
  10713. pathFind.array.forEach((path, i) => {
  10714. let pathXY = {
  10715. x: (pathFind.scale / pathFind.grid) * path.x,
  10716. y: (pathFind.scale / pathFind.grid) * path.y
  10717. }
  10718. let render = {
  10719. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10720. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10721. }
  10722. if (i == 0) {
  10723. mainContext.moveTo(render.x, render.y);
  10724. } else {
  10725. mainContext.lineTo(render.x, render.y);
  10726. }
  10727. });
  10728. mainContext.stroke();
  10729. }
  10730. }
  10731. }
  10732. // RENDER DEAD PLAYERS:
  10733. if (inWindow && fisrtloadez) {
  10734. mainContext.globalAlpha = 1;
  10735. mainContext.strokeStyle = outlineColor;
  10736. renderDeadPlayers(xOffset, yOffset, Math.random() * Math.PI * 2);
  10737. }
  10738. // RENDER BOTTOM LAYER:
  10739. mainContext.globalAlpha = 1;
  10740. mainContext.strokeStyle = outlineColor;
  10741. renderGameObjects(-1, xOffset, yOffset);
  10742. // RENDER PROJECTILES:
  10743. mainContext.globalAlpha = 1;
  10744. mainContext.lineWidth = outlineWidth;
  10745. renderProjectiles(0, xOffset, yOffset);
  10746. // RENDER PLAYERS:
  10747. renderPlayers(xOffset, yOffset, 0);
  10748. // RENDER AI:
  10749. mainContext.globalAlpha = 1;
  10750. for (let i = 0; i < ais.length; ++i) {
  10751. tmpObj = ais[i];
  10752. if (tmpObj.active && tmpObj.visible) {
  10753. tmpObj.animate(delta);
  10754. mainContext.save();
  10755. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10756. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10757. renderAI(tmpObj, mainContext);
  10758. mainContext.restore();
  10759. }
  10760. }
  10761. // RENDER GRID:
  10762. if (getEl("gridsa").checked) {
  10763. mainContext.lineWidth = 3; // Nastavte ?i?ku ?ary podle pot?eby
  10764. mainContext.strokeStyle = "#000";
  10765. mainContext.globalAlpha = 0.05; // Nastavte pr?hlednost podle pot?eby
  10766. mainContext.beginPath();
  10767. let ratfrr = 60; // Nastavte podle pot?eby
  10768. for (var x = -xOffset % ratfrr; x < maxScreenWidth; x += ratfrr) {
  10769. if (x > 0) {
  10770. mainContext.moveTo(x, 0);
  10771. mainContext.lineTo(x, maxScreenHeight);
  10772. }
  10773. }
  10774. for (var y = -yOffset % ratfrr; y < maxScreenHeight; y += ratfrr) {
  10775. if (y > 0) {
  10776. mainContext.moveTo(0, y);
  10777. mainContext.lineTo(maxScreenWidth, y);
  10778. }
  10779. }
  10780. mainContext.stroke();
  10781. }
  10782. // RENDER GAME OBJECTS (LAYERED):
  10783. renderGameObjects(0, xOffset, yOffset);
  10784. renderProjectiles(1, xOffset, yOffset);
  10785. renderGameObjects(1, xOffset, yOffset);
  10786. renderPlayers(xOffset, yOffset, 1);
  10787. renderGameObjects(2, xOffset, yOffset);
  10788. renderGameObjects(3, xOffset, yOffset);
  10789. // MAP BOUNDARIES:
  10790. mainContext.fillStyle = "#000";
  10791. mainContext.globalAlpha = 0.2;
  10792. if (xOffset <= 0) {
  10793. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10794. } if (config.mapScale - xOffset <= maxScreenWidth) {
  10795. let tmpY = Math.max(0, -yOffset);
  10796. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10797. } if (yOffset <= 0) {
  10798. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10799. } if (config.mapScale - yOffset <= maxScreenHeight) {
  10800. let tmpX = Math.max(0, -xOffset);
  10801. let tmpMin = 0;
  10802. if (config.mapScale - xOffset <= maxScreenWidth)
  10803. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10804. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10805. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10806. }
  10807.  
  10808. // RENDER DAY/NIGHT TIME:
  10809. mainContext.globalAlpha = 1;
  10810. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  10811. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10812.  
  10813. // RENDER PLAYER AND AI UI:
  10814. mainContext.strokeStyle = darkOutlineColor;
  10815. mainContext.globalAlpha = 1;
  10816.  
  10817. for (let i = 0; i < players.length + ais.length; ++i) {
  10818. tmpObj = players[i] || ais[i - players.length];
  10819. if (tmpObj.visible) {
  10820. mainContext.strokeStyle = darkOutlineColor;
  10821. // NAME AND HEALTH:
  10822. let ggezz = true;
  10823. botz.forEach((e)=>{
  10824. if(tmpObj.sid == e.sid){
  10825. ggezz = false
  10826. }
  10827. })
  10828. if (tmpObj.skinIndex != 10 || (tmpObj == player) || (tmpObj.team && tmpObj.team == player.team)&&ggezz) {
  10829. let tmpText = "";
  10830. if (getEl("visualType").value == "simp1") {
  10831. tmpText = (tmpObj.team ? "/" + tmpObj.team + "/ " : "") + (tmpObj.name || "");
  10832. } else if (getEl("visualType").value == "simp2") {
  10833. tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + tmpObj.name + " {" + tmpObj.shameCount + "}";
  10834. }
  10835. if (tmpText != "") {
  10836. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  10837. mainContext.textBaseline = "middle";
  10838. mainContext.textAlign = "center";
  10839. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10840. var tmpS = config.crownIconScale;
  10841. var tmpX = tmpObj.x - xOffset - (tmpS/2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10842. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10843. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10844. } if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10845. let tmpS = config.crownIconScale;
  10846. let tmpX = tmpObj.x - xOffset - (tmpS/2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10847. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale)
  10848. - config.nameY - (tmpS/2) - 5, tmpS, tmpS);
  10849. }
  10850. let nameColor;
  10851. if (tmpObj == player) {
  10852. nameColor = "#fff";
  10853. } else if (tmpObj.team && tmpObj.team == player.team) {
  10854. nameColor = "#fff";
  10855. } else {
  10856. nameColor = "#fff";
  10857. }
  10858. mainContext.fillStyle = nameColor;
  10859. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10860. mainContext.lineJoin = "round";
  10861. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10862. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10863.  
  10864. // HEALTH HOLDER:
  10865. mainContext.fillStyle = darkOutlineColor;
  10866. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10867. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10868. (config.healthBarPad * 2), 17, 8);
  10869. mainContext.fill();
  10870. if(!window.VirusterDev){
  10871. // HEALTH BAR:
  10872. if (getEl("visualType").value == "simp2") {
  10873. mainContext.fillStyle = (tmpObj==player||(tmpObj.team&&tmpObj.team==player.team))? "#8ecc51" : "#cc5151";
  10874. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10875. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10876. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 20); // 20
  10877. mainContext.fill();
  10878. } else if (getEl("visualType").value == "simp1") {
  10879. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10880. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10881. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10882. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10883. mainContext.fill();
  10884. mainContext.font = "20px Hammersmith One";
  10885. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10886. mainContext.textBaseline = "middle";
  10887. mainContext.textAlign = "center";
  10888. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10889. mainContext.lineJoin = "round";
  10890. mainContext.strokeText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10891. mainContext.fillText(tmpObj.health + " / " + tmpObj.maxHealth, tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 135);
  10892.  
  10893. mainContext.font = "14px Hammersmith One";
  10894. mainContext.fillStyle = "#FFFFFF";
  10895. mainContext.fillText("Sme: [" + tmpObj.shameCount + "]" + " / " + "Pac: [" + secPacket + "] ", tmpObj.x - xOffset, tmpObj.y - yOffset - tmpObj.scale + 95);
  10896. }
  10897.  
  10898. if (tmpObj.isPlayer && tmpObj.sid === player.sid) {
  10899. mainContext.globalAlpha = 1;
  10900. mainContext.fillStyle = "rgba(143, 131, 104, 1)";
  10901.  
  10902. if(tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10903. mainContext.font = "20px Hammersmith One";
  10904. mainContext.strokeText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10905. mainContext.fillText(tmpObj.sid, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) + 40);
  10906. } else {
  10907. }
  10908. if (tmpObj.isPlayer && getEl("visualType").value == "simp1") {
  10909. mainContext.globalAlpha = 1;
  10910. let targetReloads = {
  10911. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10912. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10913. turret: (2500 - tmpObj.reloads[53]) / 2500
  10914. };
  10915. if (!tmpObj.currentReloads) {
  10916. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10917. primary: targetReloads.primary,
  10918. secondary: targetReloads.secondary,
  10919. turret: targetReloads.turret
  10920. };
  10921. }
  10922. const lerpFactor = 0.3;
  10923. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10924. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10925. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10926.  
  10927. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10928. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10929. const centerX = tmpObj.x - xOffset;
  10930. const centerY = tmpObj.y - yOffset;
  10931. const barRadius = 35;
  10932. const barWidth = 15;
  10933. const totalAngle = (Math.PI*2)/3; // Half circle
  10934. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10935. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10936. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10937. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10938.  
  10939. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10940. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10941. function returncoolcolor(progress) {
  10942. const whiteValue = 255;
  10943. return `rgb(${whiteValue}, ${whiteValue}, ${whiteValue})`;
  10944. }
  10945.  
  10946.  
  10947. mainContext.save();
  10948. if (tmpObj.currentReloads.primary < 0.999) {
  10949. mainContext.beginPath();
  10950. mainContext.lineCap = 'round';
  10951. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10952. mainContext.lineWidth = 4;
  10953. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10954. mainContext.stroke();
  10955. }
  10956. if (tmpObj.currentReloads.secondary < 0.999) {
  10957. mainContext.beginPath();
  10958. mainContext.lineCap = 'round';
  10959. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10960. mainContext.lineWidth = 4;
  10961. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10962. mainContext.stroke();
  10963. }
  10964. if (tmpObj.currentReloads.turret < 0.999) {
  10965. mainContext.beginPath();
  10966. mainContext.lineCap = 'round';
  10967. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10968. mainContext.lineWidth = 4;
  10969. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10970. mainContext.stroke();
  10971. }
  10972. } else if (getEl("visualType").value == "simp2") {
  10973. }
  10974. }
  10975.  
  10976. if (tmpObj == player) {
  10977. if (getEl("predictType").value == "pre2") {
  10978. mainContext.lineWidth = 3;
  10979. mainContext.strokeStyle = "#fff";
  10980. mainContext.globalAlpha = 1;
  10981. mainContext.beginPath();
  10982. let render = {
  10983. x: tmpObj.x2 - xOffset,
  10984. y: tmpObj.y2 - yOffset
  10985. };
  10986. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10987. mainContext.lineTo(render.x, render.y);
  10988. mainContext.stroke();
  10989. } else if (getEl("predictType").value == "pre3") {
  10990. mainContext.lineWidth = 3;
  10991. mainContext.strokeStyle = "#cc5151";
  10992. mainContext.globalAlpha = 1;
  10993. mainContext.beginPath();
  10994. let render = {
  10995. x: tmpObj.x3 - xOffset,
  10996. y: tmpObj.y3 - yOffset
  10997. };
  10998. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10999. mainContext.lineTo(render.x, render.y);
  11000. mainContext.stroke();
  11001. }
  11002. }
  11003.  
  11004.  
  11005. // in here we skid ha thu mod ez(sowwie ha thu i love u <3):
  11006. // virusterdev: "what"
  11007. if (tmpObj.isPlayer && near == tmpObj && enemy.length && rKeyPressed) {
  11008. let tmpS = tmpObj.scale * 2.2;
  11009. mainContext.drawImage(crossHairSprites, tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11010. }
  11011.  
  11012. }
  11013. }
  11014. }
  11015. }
  11016. }
  11017.  
  11018.  
  11019. // RENDER GAME OBJECTS:
  11020. function renderGameObjects(layer, xOffset, yOffset) {
  11021. let tmpSprite;
  11022. let tmpX;
  11023. let tmpY;
  11024. gameObjects.forEach((tmp) => {
  11025. tmpObj = tmp;
  11026. if (tmpObj.alive) {
  11027. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  11028. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  11029. if (layer == 0) {
  11030. tmpObj.update(delta);
  11031. }
  11032. mainContext.globalAlpha = tmpObj.alpha;
  11033. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  11034. if (tmpObj.isItem) {
  11035. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  11036. tmpSprite = getObjSprite(tmpObj);
  11037. } else {
  11038. tmpSprite = getItemSprite(tmpObj);
  11039. }
  11040. mainContext.save();
  11041. mainContext.translate(tmpX, tmpY);
  11042. mainContext.rotate(tmpObj.dir);
  11043. if (!tmpObj.active) {
  11044. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  11045. }
  11046. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  11047. if (tmpObj.blocker) {
  11048. mainContext.strokeStyle = "#db6e6e";
  11049. mainContext.globalAlpha = 0.3;
  11050. mainContext.lineWidth = 6;
  11051. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  11052. }
  11053. mainContext.restore();
  11054. } else {
  11055. tmpSprite = getResSprite(tmpObj);
  11056. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  11057. }
  11058. }
  11059. document.minis = .1;
  11060. document.bigis = 2.95;
  11061. if (getEl("bh").value == 1) {
  11062. if (layer == 3) {
  11063. if (tmpObj.health < tmpObj.maxHealth) {
  11064. const normalScale = tmpObj.scale / 2;
  11065. const normalGap = normalScale * 2 * document.minis;
  11066. const normalStart = normalScale / circleScale;
  11067. const Filler = (2 * Math.PI) / (tmpObj.maxHealth / tmpObj.healthMov);
  11068. mainContext.save();
  11069. mainContext.beginPath();
  11070. mainContext.lineCap = 'round';
  11071. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  11072. mainContext.lineWidth = normalGap * document.bigis;
  11073. mainContext.strokeStyle = darkOutlineColor;
  11074. mainContext.stroke();
  11075. mainContext.beginPath();
  11076. mainContext.lineCap = 'round';
  11077. mainContext.arc(tmpX, tmpY, normalStart, 0, Filler);
  11078. mainContext.lineWidth = 7;
  11079. mainContext.strokeStyle = tmpObj.isTeamObject(player) ? myObjectHealth : enemyObjectHealth;
  11080. mainContext.stroke();
  11081. mainContext.closePath();
  11082. mainContext.restore();
  11083.  
  11084. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#fff" : "#F05C5B";
  11085. mainContext.textBaseline = "middle";
  11086. mainContext.textAlign = "center";
  11087. mainContext.lineWidth = 0;
  11088. mainContext.lineJoin = "round";
  11089.  
  11090. mainContext.strokeStyle = darkOutlineColor;
  11091. mainContext.lineWidth = 5;
  11092.  
  11093. const fontSize = 18;
  11094. mainContext.font = `${fontSize}px Hammersmith One`;
  11095.  
  11096. mainContext.strokeText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  11097. mainContext.fillText(tmpObj.owner.sid, tmpObj.x - xOffset, tmpObj.y - yOffset + 32.6);
  11098. }
  11099. }
  11100. } else if (getEl("bh").value == "2") {
  11101. if (tmpObj.health < tmpObj.maxHealth) {
  11102. mainContext.fillStyle = darkOutlineColor;
  11103. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  11104. mainContext.fill();
  11105. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  11106. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  11107. mainContext.fill();
  11108. }
  11109. } else {
  11110. }
  11111. }
  11112. });
  11113.  
  11114.  
  11115. mainContext.restore();
  11116. // PLACE VISIBLE:
  11117. if (layer == 0&&!window.VirusterDev) {
  11118. if (placeVisible.length) {
  11119. placeVisible.forEach((places) => {
  11120. tmpX = places.x - xOffset;
  11121. tmpY = places.y - yOffset;
  11122. if (getEl("renderplace").value == "placeVis") {
  11123. markObject(places, tmpX, tmpY);
  11124. }
  11125. if (getEl("renderplace").value == "outline") {
  11126. markObject2(places, tmpX, tmpY);
  11127. }
  11128. });
  11129.  
  11130.  
  11131.  
  11132. if (preplaceVisible.length) {
  11133. preplaceVisible.forEach((places) => {
  11134. tmpX = places.x - xOffset;
  11135. tmpY = places.y - yOffset;
  11136. ppmarkObject(places, tmpX, tmpY);
  11137. });
  11138. }
  11139. }
  11140. }
  11141. }
  11142. function markObject(tmpObj, tmpX, tmpY) {
  11143.  
  11144. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  11145. }
  11146. function markObject2(tmpObj, tmpX, tmpY) {
  11147. getMarkSprite2(tmpObj, mainContext, tmpX, tmpY);
  11148. }
  11149. function ppmarkObject(tmpObj, tmpX, tmpY) {
  11150. ppyen(mainContext, tmpX, tmpY);
  11151. }
  11152. function ppyen(context, x, y) {
  11153. context.fillStyle = "rgba(255, 0, 0, 0.2)";
  11154. context.beginPath();
  11155. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  11156. context.fill();
  11157. context.closePath();
  11158. context.globalAlpha = 1;
  11159. }
  11160. function yen(context, x, y) {
  11161. context.fillStyle = "rgba(0, 255, 255, 0.6)";
  11162. context.beginPath();
  11163. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  11164. context.fill();
  11165. context.closePath();
  11166. context.globalAlpha = 1;
  11167. }
  11168.  
  11169. function drawArrow(xOffset, yOffset, x, y, arrowWidth, color, angle, lineWidth) {
  11170. mainContext.save()
  11171. mainContext.translate(x - xOffset, y - yOffset)
  11172. mainContext.rotate(Math.PI / 4)
  11173. mainContext.rotate(angle)
  11174. mainContext.globalAlpha = 1
  11175. mainContext.strokeStyle = color
  11176. mainContext.lineCap = "round"
  11177. mainContext.lineWidth = lineWidth
  11178. mainContext.beginPath()
  11179. mainContext.moveTo(-arrowWidth, -arrowWidth)
  11180. mainContext.lineTo(arrowWidth, -arrowWidth)
  11181. mainContext.lineTo(arrowWidth, arrowWidth)
  11182. mainContext.stroke()
  11183. mainContext.closePath()
  11184. mainContext.restore()
  11185. }
  11186. if (player) {
  11187. // AUTOPUSH LINE:
  11188. if (my.autoPush) {
  11189. mainContext.lineWidth = 5;
  11190. mainContext.globalAlpha = 1;
  11191. mainContext.beginPath();
  11192.  
  11193.  
  11194. mainContext.strokeStyle = "black";
  11195. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  11196. mainContext.lineTo(my.pushData.x2 - xOffset, my.pushData.y2 - yOffset);
  11197. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  11198. mainContext.stroke();
  11199. }
  11200. }
  11201. mainContext.globalAlpha = 1;
  11202.  
  11203. // RENDER ANIM TEXTS:
  11204. textManager.update(delta, mainContext, xOffset, yOffset);
  11205. // RENDER CHAT MESSAGES:
  11206. for (let i = 0; i < players.length; ++i) {
  11207. tmpObj = players[i];
  11208. if (tmpObj.visible) {
  11209. if (tmpObj.chatCountdown > 0) {
  11210. tmpObj.chatCountdown -= delta;
  11211. if (tmpObj.chatCountdown <= 0)
  11212. tmpObj.chatCountdown = 0;
  11213. mainContext.font = "32px Hammersmith One";
  11214. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11215. mainContext.textBaseline = "middle";
  11216. mainContext.textAlign = "center";
  11217. let tmpX = tmpObj.x - xOffset;
  11218. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11219. let tmpH = 47;
  11220. let tmpW = tmpSize.width + 17;
  11221. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11222. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11223. mainContext.fill();
  11224. mainContext.fillStyle = "#fff";
  11225. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11226. }
  11227. if (tmpObj.chat.count > 0) {
  11228. tmpObj.chat.count -= delta;
  11229. if (tmpObj.chat.count <= 0)
  11230. tmpObj.chat.count = 0;
  11231. mainContext.font = "32px Hammersmith One";
  11232. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11233. mainContext.textBaseline = "middle";
  11234. mainContext.textAlign = "center";
  11235. let tmpX = tmpObj.x - xOffset;
  11236. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11237. let tmpH = 47;
  11238. let tmpW = tmpSize.width + 17;
  11239. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11240. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11241. mainContext.fill();
  11242. mainContext.fillStyle = "#ffffff99";
  11243. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11244. }
  11245. }
  11246. }
  11247. if (allChats.length) {
  11248. allChats.filter(ch => ch.active).forEach((ch) => {
  11249. if (!ch.alive) {
  11250. if (ch.alpha <= 1) {
  11251. ch.alpha += delta / 250;
  11252. if (ch.alpha >= 1) {
  11253. ch.alpha = 1;
  11254. ch.alive = true;
  11255. }
  11256. }
  11257. } else {
  11258. ch.alpha -= delta / 5000;
  11259. if (ch.alpha <= 0) {
  11260. ch.alpha = 0;
  11261. ch.active = false;
  11262. }
  11263. }
  11264. if (ch.active) {
  11265. mainContext.font = "20px Hammersmith One";
  11266. let tmpSize = mainContext.measureText(ch.chat);
  11267. mainContext.textBaseline = "middle";
  11268. mainContext.textAlign = "center";
  11269. let tmpX = ch.owner.x - xOffset;
  11270. let tmpY = ch.owner.y - ch.owner.scale - yOffset - 90;
  11271. let tmpH = 47;
  11272. let tmpW = tmpSize.width + 17;
  11273. mainContext.globalAlpha = ch.alpha;
  11274. mainContext.fillStyle = ch.owner.isTeam(player) ? "rgba(255,215,0,1)" : "#cc5151";
  11275. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11276. mainContext.lineWidth = 5;
  11277. mainContext.fillStyle = "rgba(0,0,0,0.4)";
  11278. mainContext.strokeStyle = "rgba(0,0,0,0.0)";
  11279. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11280. mainContext.stroke();
  11281. mainContext.fill();
  11282. mainContext.fillStyle = "#fff";
  11283. mainContext.strokeStyle = "#000";
  11284. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11285. mainContext.fillText(ch.chat, tmpX, tmpY);
  11286. ch.y -= delta / 100;
  11287. }
  11288. });
  11289. }
  11290. }
  11291. mainContext.globalAlpha = 1;
  11292. // RENDER MINIMAP:
  11293. renderMinimap(delta);
  11294. }
  11295. // UPDATE & ANIMATE:
  11296. window.requestAnimFrame = function() {
  11297. return null;
  11298. }
  11299. window.rAF = (function() {
  11300. return window.requestAnimationFrame ||
  11301. window.webkitRequestAnimationFrame ||
  11302. window.mozRequestAnimationFrame ||
  11303. function(callback) {
  11304. window.setTimeout(callback, 1000 / 240);
  11305. };
  11306. })();
  11307. function doUpdate() {
  11308. now = performance.now();
  11309. delta = now - lastUpdate;
  11310. lastUpdate = now;
  11311. let timer = performance.now();
  11312. let diff = timer - fpsTimer.last;
  11313. if (diff >= 1000) {
  11314. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11315. fpsTimer.last = timer;
  11316. fpsTimer.time = 0;
  11317. }
  11318. fpsTimer.time++;
  11319. getEl("pingFps").innerHTML = `${window.pingTime}ms | FPS: ${UTILS.round(fpsTimer.ltime, 10)}`;
  11320. getEl("packetStatus").innerHTML = secPacket;
  11321. updateGame();
  11322. rAF(doUpdate);
  11323. }
  11324. prepareMenuBackground();
  11325. doUpdate();
  11326. let changeDays = {};
  11327. window.debug = function() {
  11328. my.waitHit = 0;
  11329. my.autoAim = false;
  11330. instaC.isTrue = false;
  11331. traps.inTrap = false;
  11332. itemSprites = [];
  11333. objSprites = [];
  11334. gameObjectSprites = [];
  11335. };
  11336. window.toggleNight = function() {
  11337. isNight = !isNight;
  11338. itemSprites = [];
  11339. objSprites = [];
  11340. gameObjectSprites = [];
  11341. };
  11342. window.startGrind = function() {
  11343. if (getEl("weaponGrind").checked) {
  11344. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11345. checkPlace(player.getItemType(22), i);
  11346. }
  11347. }
  11348. };
  11349. // REMOVED!!! so they cant abuse :)
  11350. let projects = [];
  11351. let botIDS = 0;
  11352. window.connectFillBots = function() {
  11353. botSkts = [];
  11354. botIDS = 0;
  11355. for (let i = 0; i < projects.length; i++) {
  11356. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11357. test.binaryType = "arraybuffer";
  11358. test.onopen = function() {
  11359. test.ssend = function(type) {
  11360. let data = Array.prototype.slice.call(arguments, 1);
  11361. let binary = window.msgpack.encode([type, data]);
  11362. test.send(binary);
  11363. };
  11364. for (let i = 0; i < 4; i++) {
  11365. window.grecaptcha.execute("6LevKusUAAAAAAFknhlV8sPtXAk5Z5dGP5T2FYIZ", {
  11366. action: "homepage"
  11367. }).then(function(token) {
  11368. test.ssend("bots", WS.url.split("&")[0] + "&token=" + encodeURIComponent(token), botIDS);
  11369. botSkts.push([test]);
  11370. botIDS++;
  11371. });
  11372. }
  11373. };
  11374. test.onmessage = function(message) {
  11375. let data = new Uint8Array(message.data);
  11376. let parsed = window.msgpack.decode(data);
  11377. let type = parsed[0];
  11378. data = parsed[1];
  11379. };
  11380. }
  11381. };
  11382. window.destroyFillBots = function() {
  11383. botSkts.forEach((socket) => {
  11384. socket[0].close();
  11385. });
  11386. botSkts = [];
  11387. };
  11388. window.tryConnectBots = function() {
  11389. for (let i = 0; i < 4; i++) {
  11390. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11391. action: "homepage"
  11392. }).then(function(token) {
  11393. // CONNECT SOCKET:
  11394. botSpawn(token);
  11395. });
  11396. }
  11397. };
  11398. window.destroyBots = function() {
  11399. bots.forEach((botyyyyy) => {
  11400. botyyyyy.closeSocket = true;
  11401. });
  11402. bots = [];
  11403. };
  11404. window.resBuild = function() {
  11405. if (gameObjects.length) {
  11406. gameObjects.forEach((tmp) => {
  11407. tmp.breakObj = false;
  11408. });
  11409. breakObjects = [];
  11410. }
  11411. };
  11412. window.toggleBotsCircle = function() {
  11413. player.circle = !player.circle;
  11414. };
  11415. window.prepareUI = function(tmpObj) {
  11416. resize();
  11417. // ACTION BAR:
  11418. UTILS.removeAllChildren(actionBar);
  11419. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11420. (function(i) {
  11421. UTILS.generateElement({
  11422. id: "actionBarItem" + i,
  11423. class: "actionBarItem",
  11424. style: "display:none",
  11425. onmouseout: function() {
  11426. showItemInfo();
  11427. },
  11428. parent: actionBar
  11429. });
  11430. })(i);
  11431. }
  11432. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11433. (function(i) {
  11434. let tmpCanvas = document.createElement("canvas");
  11435. tmpCanvas.width = tmpCanvas.height = 66;
  11436. let tmpContext = tmpCanvas.getContext("2d");
  11437. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11438. tmpContext.imageSmoothingEnabled = false;
  11439. tmpContext.webkitImageSmoothingEnabled = false;
  11440. tmpContext.mozImageSmoothingEnabled = false;
  11441. if (items.weapons[i]) {
  11442. tmpContext.rotate((Math.PI / 4) + Math.PI);
  11443. let tmpSprite = new Image();
  11444. toolSprites[items.weapons[i].src] = tmpSprite;
  11445. tmpSprite.onload = function() {
  11446. this.isLoaded = true;
  11447. let tmpPad = 1 / (this.height / this.width);
  11448. let tmpMlt = (items.weapons[i].iPad || 1);
  11449. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11450. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11451. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11452. tmpContext.globalCompositeOperation = "source-atop";
  11453. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11454. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11455. };
  11456. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11457. let tmpUnit = getEl('actionBarItem' + i);
  11458. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  11459. showItemInfo(items.weapons[i], true);
  11460. });
  11461. tmpUnit.onclick = UTILS.checkTrusted(function() {
  11462. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11463. });
  11464. UTILS.hookTouchEvents(tmpUnit);
  11465. } else {
  11466. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11467. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11468. tmpContext.globalAlpha = 1;
  11469. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11470. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11471. tmpContext.globalCompositeOperation = "source-atop";
  11472. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11473. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11474. let tmpUnit = getEl('actionBarItem' + i);
  11475. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  11476. showItemInfo(items.list[i - items.weapons.length]);
  11477. });
  11478. tmpUnit.onclick = UTILS.checkTrusted(function() {
  11479. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11480. });
  11481. UTILS.hookTouchEvents(tmpUnit);
  11482. }
  11483. })(i);
  11484. }
  11485. };
  11486. window.toggleNight();
  11487. (function() {
  11488. 'use strict';
  11489.  
  11490. const CORRECT_USERNAME = "wat";
  11491. const CORRECT_PASSWORD = "pro";
  11492.  
  11493. let snowfallInterval;
  11494. let snowflakesEnabled = true;
  11495.  
  11496. function createSnowflake() {
  11497. if (!snowflakesEnabled) return;
  11498.  
  11499. const snowflake = document.createElement("div");
  11500. snowflake.className = "snowflake";
  11501. snowflake.style.position = "absolute";
  11502. snowflake.style.width = "10px";
  11503. snowflake.style.height = "10px";
  11504. snowflake.style.background = "#fff";
  11505. snowflake.style.borderRadius = "50%";
  11506. snowflake.style.zIndex = "9998";
  11507. snowflake.style.opacity = Math.random();
  11508. snowflake.style.left = Math.random() * 100 + "vw";
  11509. snowflake.style.animation = `fall ${Math.random() * 2 + 1}s linear infinite`;
  11510.  
  11511. snowflake.addEventListener("animationiteration", function() {
  11512. snowflake.style.left = Math.random() * 100 + "vw";
  11513. snowflake.style.opacity = Math.random();
  11514. });
  11515.  
  11516. return snowflake;
  11517. }
  11518.  
  11519. function createSnowfall() {
  11520. const snowflakeContainer = document.createElement("div");
  11521. snowflakeContainer.id = "snowflake-container";
  11522. snowflakeContainer.style.position = "absolute";
  11523. snowflakeContainer.style.top = "0";
  11524. snowflakeContainer.style.left = "0";
  11525. snowflakeContainer.style.width = "100%";
  11526. snowflakeContainer.style.height = "100%";
  11527. snowflakeContainer.style.pointerEvents = "none";
  11528. snowflakeContainer.style.zIndex = "9998";
  11529. document.body.appendChild(snowflakeContainer);
  11530.  
  11531. const maxSnowflakes = 40;
  11532. for (let i = 0; i < maxSnowflakes; i++) {
  11533. const snowflake = createSnowflake();
  11534. if (Math.random() > 0.7) {
  11535. snowflake.classList.add("fast-fall");
  11536. }
  11537. snowflakeContainer.appendChild(snowflake);
  11538. }
  11539. }
  11540.  
  11541. function createToggleMenu() {
  11542. const menu = document.createElement('div');
  11543. menu.style.position = 'fixed';
  11544. menu.style.top = '10px';
  11545. menu.style.right = '10px';
  11546. menu.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
  11547. menu.style.padding = '10px';
  11548. menu.style.borderRadius = '5px';
  11549. menu.style.zIndex = '10000';
  11550.  
  11551. const toggle = document.createElement('label');
  11552. toggle.style.display = 'flex';
  11553. toggle.style.alignItems = 'center';
  11554. toggle.style.color = 'white';
  11555.  
  11556. const checkbox = document.createElement('input');
  11557. checkbox.type = 'checkbox';
  11558. checkbox.checked = snowflakesEnabled;
  11559. checkbox.style.marginRight = '5px';
  11560.  
  11561. checkbox.addEventListener('change', function() {
  11562. snowflakesEnabled = this.checked;
  11563. const snowflakeContainer = document.getElementById("snowflake-container");
  11564.  
  11565. if (snowflakesEnabled) {
  11566. if (!snowflakeContainer) createSnowfall();
  11567. } else {
  11568. if (snowflakeContainer) snowflakeContainer.remove();
  11569. }
  11570. });
  11571.  
  11572. toggle.appendChild(checkbox);
  11573. toggle.appendChild(document.createTextNode('Snowflakes'));
  11574.  
  11575. menu.appendChild(toggle);
  11576. document.body.appendChild(menu);
  11577. }
  11578.  
  11579. function createOverlay() {
  11580. const overlay = document.createElement("div");
  11581. overlay.style.position = "fixed";
  11582. overlay.style.top = "0";
  11583. overlay.style.left = "0";
  11584. overlay.style.width = "100%";
  11585. overlay.style.height = "100%";
  11586. overlay.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
  11587. overlay.style.display = "flex";
  11588. overlay.style.alignItems = "center";
  11589. overlay.style.justifyContent = "center";
  11590. overlay.style.zIndex = "9999";
  11591.  
  11592. const box = document.createElement("div");
  11593. box.style.padding = "40px";
  11594. box.style.borderRadius = "10px";
  11595. box.style.backgroundColor = "black";
  11596. box.style.boxShadow = "0 0 30px rgba(128, 0, 255, 0.5)";
  11597. box.style.textAlign = "center";
  11598. box.style.color = "white";
  11599. box.style.width = "400px";
  11600. box.style.animation = "pulse 1.5s infinite";
  11601.  
  11602. const inputs = ['username', 'password'].map(type => {
  11603. const input = document.createElement("input");
  11604. input.type = type === 'password' ? 'password' : 'text';
  11605. input.placeholder = type.charAt(0).toUpperCase() + type.slice(1);
  11606. input.style.display = "block";
  11607. input.style.margin = "15px auto";
  11608. input.style.padding = "15px";
  11609. input.style.width = "80%";
  11610. input.style.borderRadius = "5px";
  11611. input.style.border = "none";
  11612. input.style.fontSize = "16px";
  11613. input.style.color = "black";
  11614. return input;
  11615. });
  11616.  
  11617. const submitButton = document.createElement("button");
  11618. submitButton.innerText = "Submit";
  11619. submitButton.style.padding = "12px 25px";
  11620. submitButton.style.marginTop = "20px";
  11621. submitButton.style.border = "none";
  11622. submitButton.style.borderRadius = "5px";
  11623. submitButton.style.backgroundColor = "#8000ff";
  11624. submitButton.style.color = "white";
  11625. submitButton.style.fontSize = "16px";
  11626. submitButton.style.cursor = "pointer";
  11627.  
  11628. inputs.forEach(input => box.appendChild(input));
  11629. box.appendChild(submitButton);
  11630. overlay.appendChild(box);
  11631.  
  11632. const keyCombination = { u: false, h: false, m: false };
  11633. document.addEventListener('keydown', (e) => {
  11634. if (e.key.toLowerCase() in keyCombination) keyCombination[e.key.toLowerCase()] = true;
  11635. if (keyCombination.u && keyCombination.h && keyCombination.m) document.body.removeChild(overlay);
  11636. });
  11637. document.addEventListener('keyup', (e) => {
  11638. if (e.key.toLowerCase() in keyCombination) keyCombination[e.key.toLowerCase()] = false;
  11639. });
  11640.  
  11641. submitButton.addEventListener("click", function() {
  11642. const [username, password] = inputs.map(input => input.value);
  11643.  
  11644. if (username === CORRECT_USERNAME &&
  11645. password === CORRECT_PASSWORD) {
  11646. document.body.removeChild(overlay);
  11647. } else {
  11648. alert("Incorrect credentials. Refreshing...");
  11649. location.reload();
  11650. }
  11651. });
  11652.  
  11653. document.body.appendChild(overlay);
  11654. }
  11655.  
  11656. // Add snowfall animation styles
  11657. const style = document.createElement('style');
  11658. style.textContent = `
  11659. @keyframes fall {
  11660. 0% { transform: translateY(-10vh); opacity: 1; }
  11661. 100% { transform: translateY(110vh); opacity: 0; }
  11662. }
  11663. @keyframes pulse {
  11664. 0%, 100% { transform: scale(1); }
  11665. 50% { transform: scale(1.05); }
  11666. }
  11667. .fast-fall { animation-duration: ${Math.random() * 1 + 1}s; }
  11668. `;
  11669. document.head.appendChild(style);
  11670.  
  11671. createOverlay();
  11672. createSnowfall();
  11673. createToggleMenu();
  11674. })();

QingJ © 2025

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