/Project FMA

Good mod

  1. // ==UserScript==
  2. // @name /Project FMA
  3. // @version v0.1
  4. // @author CtrlShift, wat
  5. // @description Good mod
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @icon https://th.bing.com/th/id/R.8aebe3c6c3b50638a4ba0687950b7ec2?rik=UMZz7VH0o%2buk6g&riu=http%3a%2f%2fgetwallpapers.com%2fwallpaper%2ffull%2f1%2fd%2fa%2f977463-cool-fma-wallpaper-1920x1200.jpg&ehk=bgPXpEUzlOnyzdQ%2fMmSFipNkBm8kIARKD8iYW6RXqrQ%3d&risl=&pid=ImgRaw&r=0
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://gf.qytechs.cn/users/1258400
  12. // ==/UserScript==
  13. function showMessage(message, duration, color, callback) {
  14. const frameMsg = Object.assign(document.createElement("div"), {
  15. innerHTML: message,
  16. style: `
  17. position: fixed;
  18. top: 7%; /* Static position */
  19. left: 50%;
  20. transform: translateX(-50%);
  21. font-size: 2rem;
  22. color: #FFFFFF; /* Light white text */
  23. z-index: 9999;
  24. opacity: 1;
  25. transition: opacity 1s ease-in-out; /* Smooth fade-in and fade-out */
  26. padding: 10px;
  27. background-color: rgba(169, 169, 169, 0.5); /* Grey transparent background */
  28. border: 2px solid transparent;
  29. border-radius: 15px; /* Smooth radius for the box */
  30. box-shadow: 0 0 20px 5px #CCCCCC; /* Light grey glow */
  31. text-shadow: 0 0 10px #CCCCCC; /* Light grey text glow */
  32. `
  33. });
  34.  
  35. document.body.appendChild(frameMsg);
  36. setTimeout(() => {
  37. frameMsg.style.opacity = "1";
  38. }, 100);
  39. setTimeout(() => {
  40. frameMsg.style.opacity = "0";
  41. setTimeout(() => {
  42. frameMsg.remove();
  43. if (callback) callback();
  44. }, 1000); /* Adjusted timeout to match the transition duration */
  45. }, duration);
  46. }
  47. document.getElementById("leaderboard").append ('Private!!')
  48. const welcomemsg = document.createElement("div"); //start
  49. welcomemsg.textContent = "Welcome To Project FMA 0.1 BY CtrlShift"; //hello message
  50. welcomemsg.style.position = "fixed"; //position
  51. welcomemsg.style.top = "-100px"; //top position
  52. welcomemsg.style.left = "50%"; //left position
  53. welcomemsg.style.transform = "translateX(-50%)";
  54. welcomemsg.style.backgroundColor = "black"; //backgr color
  55. welcomemsg.style.color = "white";// color
  56. welcomemsg.style.padding = "15px";// padding
  57. welcomemsg.style.fontSize = "15px"; //font size
  58. welcomemsg.style.borderRadius = "10px"; //border
  59. welcomemsg.style.transition = "top 1s, opacity 1s"; //timer
  60. welcomemsg.style.zIndex = "9999"; //zIndex
  61. document.body.appendChild(welcomemsg); //timer
  62. setTimeout(() => {
  63. welcomemsg.style.top = "0";
  64. welcomemsg.style.opacity = "1";
  65. }, 500);
  66.  
  67. setTimeout(() => {
  68. welcomemsg.style.opacity = "0";
  69. setTimeout(() => {
  70. welcomemsg.remove();
  71. }, 1000);
  72. }, 3000);
  73.  
  74. /** FPS BOOSTER **/
  75. let { maxScreenWidth, maxScreenHeight } = config;
  76. let { moveTo, lineTo } = CanvasRenderingContext2D.prototype;
  77.  
  78. CanvasRenderingContext2D.prototype.moveTo = function(x, y) {
  79. if (this.globalAlpha !== 0.06) {
  80. return moveTo.call(this, x, y);
  81. }
  82. };
  83. CanvasRenderingContext2D.prototype.lineTo = function(x, y) {
  84. if (this.globalAlpha !== 0.06) {
  85. return lineTo.call(this, x, y);
  86. }
  87. };
  88.  
  89. class Checker {
  90. check(callback) {
  91. return (event) => {
  92. if (event instanceof Event && (event.isTrusted ?? true)) {
  93. callback(event);
  94. }
  95. };
  96. }
  97. }
  98.  
  99. let checker = new Checker();
  100. let updateScreen = () => {
  101. let currentWidth = window.innerWidth;
  102. let currentHeight = window.innerHeight;
  103.  
  104. let pixelDensity = 0.35;
  105. let scale = Math.max(currentWidth / maxScreenWidth, currentHeight / maxScreenHeight) * pixelDensity;
  106.  
  107. gameCanvas.width = currentWidth * pixelDensity;
  108. gameCanvas.height = currentHeight * pixelDensity;
  109.  
  110. gameCanvas.style.width = `${currentWidth}px`;
  111. gameCanvas.style.height = `${currentHeight}px`;
  112.  
  113. mainContext.setTransform(scale, 0, 0, scale, (currentWidth * pixelDensity - maxScreenWidth * scale) / 2, (currentHeight * pixelDensity - maxScreenHeight * scale) / 2);
  114. };
  115. window.addEventListener("resize", checker.check(updateScreen));
  116. //welcomemsg 2
  117. const welcomemsg2 = document.createElement("div");
  118. welcomemsg2.textContent = "Press 'Tab' to listen Music";
  119. welcomemsg2.style.position = "fixed";
  120. welcomemsg2.style.top = "-200px";
  121. welcomemsg2.style.left = "50%";
  122. welcomemsg2.style.transform = "translateX(-50%)";
  123. welcomemsg2.style.backgroundColor = "Black";
  124. welcomemsg2.style.color = "white";
  125. welcomemsg2.style.padding = "15px";
  126. welcomemsg2.style.fontSize = "15px";
  127. welcomemsg2.style.borderRadius = "10px";
  128. welcomemsg2.style.transition = "top 1s, opacity 1s";
  129. welcomemsg2.style.zIndex = "9999";
  130. document.body.appendChild(welcomemsg2);
  131. setTimeout(() => {
  132. welcomemsg2.style.top = "45px";
  133. welcomemsg2.style.opacity = "1";
  134. }, 1500);
  135. setTimeout(() => {
  136. welcomemsg2.style.top = "0";
  137. welcomemsg2.style.opacity = "1";
  138. }, 3000);
  139.  
  140. setTimeout(() => {
  141. welcomemsg2.style.opacity = "0";
  142. setTimeout(() => {
  143. welcomemsg2.remove();
  144. }, 1000);
  145. }, 5000);
  146.  
  147.  
  148.  
  149. (function() {
  150. 'use strict';
  151.  
  152. // Add custom CSS styles for the scrollbar
  153. const style = document.createElement('style');
  154. style.textContent = `
  155. /* Custom scrollbar styling */
  156. #musicMenuContainer::-webkit-scrollbar {
  157. width: 8px;
  158. }
  159. #musicMenuContainer::-webkit-scrollbar-thumb {
  160. background-color: black;
  161. border-radius: 10px;
  162. border: 2px solid black;
  163. }
  164. #musicMenuContainer::-webkit-scrollbar-track {
  165. background-color: black;
  166. border-radius: 10px;
  167. }
  168. `;
  169. document.head.appendChild(style);
  170.  
  171. // Create the menu container
  172. const menuContainer = document.createElement('div');
  173. menuContainer.id = 'musicMenuContainer'; // Assign ID for custom scrollbar
  174. menuContainer.style.position = 'fixed';
  175. menuContainer.style.top = '50%';
  176. menuContainer.style.left = '50%';
  177. menuContainer.style.transform = 'translate(-50%, -50%)';
  178. menuContainer.style.backgroundColor = 'BLACK';
  179. menuContainer.style.color = 'white';
  180. menuContainer.style.padding = '15px';
  181. menuContainer.style.borderRadius = '10px';
  182. menuContainer.style.display = 'none'; // Hidden by default
  183. menuContainer.style.zIndex = '9999'; // Ensure it's on top of other elements
  184. menuContainer.style.boxShadow = '0 0 15px black'; // Glowing shadow
  185. menuContainer.style.border = '2px solid white'; // Glowing border
  186. menuContainer.style.overflowY = 'auto';
  187. menuContainer.style.maxHeight = '100vh'; // Limit height to viewport height
  188. menuContainer.style.transition = 'opacity 0.5s ease-in-out, transform 0.5s ease-in-out'; // Transition effect
  189. menuContainer.style.opacity = '0'; // Start with invisible
  190. menuContainer.style.transform = 'translate(-50%, -60%)'; // Start from above
  191.  
  192. // Create the menu header
  193. const menuHeader = document.createElement('h3');
  194. menuHeader.textContent = 'Music Menu | By Normal';
  195. menuHeader.style.margin = '0';
  196. menuHeader.style.paddingBottom = '10px';
  197. menuHeader.style.borderBottom = '1px solid black';
  198. menuContainer.appendChild(menuHeader);
  199.  
  200. // List of music genres and their YouTube links
  201. const musicList = [
  202. { name: 'Montagem diamante rosa', url: 'https://www.youtube.com/watch?v=K5gcfucqTjE' },
  203. { name: 'BEEPER FUNK X MONTAGEM VOZES PROFUNDAS (ULTRA SLOWED)', url: 'https://www.youtube.com/watch?v=8--uc9oQ18o' },
  204. { name: 'MONTAGEM - MELODIA ENVOLVENTE 5', url: 'https://www.youtube.com/watch?v=oUEJStHai8Q' },
  205. { name: 'MONTAGEM - MELODIA ENVOLVENTE 4', url: 'https://www.youtube.com/watch?v=wht3KWkM1cs' },
  206. { name: 'Take Over · League of Legends', url: 'https://www.youtube.com/watch?v=vOwVTtoR-9E' },
  207. { name: 'DanceMonkey', url: 'https://www.youtube.com/watch?v=1__CAdTJ5JU' },
  208. { name: 'yay yay yay yay yay yay', url: 'https://www.youtube.com/watch?v=TTwd-ePxVM8' },
  209. { name: 'Imran Khan Satisfya + Now You See Me Scene', url: 'https://www.youtube.com/watch?v=6egm03LoBrM&t=42s' },
  210. { name: 'MONTAGEM VOZES PROFUNDAS', url: 'https://www.youtube.com/watch?v=H1Zshsvccfg' },
  211. { name: 'MONTAGEM CORAL', url: 'https://www.youtube.com/watch?v=9lhYFSRYNiU' },
  212. { name: 'THE - AUTOMOTIVO', url: 'https://www.youtube.com/watch?v=i26G31x_Ick' },
  213. { name: 'AUTOMOTIVO EMPURRA (Slowed)', url: 'https://www.youtube.com/watch?v=7JL3NTROR_0' },
  214. { name: 'Indila - Dernière Danse', url: 'https://www.youtube.com/watch?v=K5KAc5CoCuk' },
  215. { name: 'Slide da Treme Melódica v2 - ( Ultra Slowed )', url: 'https://www.youtube.com/watch?v=zaQhdRla0yM' },
  216. { name: '[1 HOUR] AUTOMOTIVO MAGIA TERRORIFICA - ( Tik - Tok Version )', url: 'https://www.youtube.com/watch?v=u8optXZ3BJg' },
  217. { name: 'Montagem Inter-Celestial 1.0 [Super Slowed + Reverb]', url: 'https://www.youtube.com/watch?v=KUpwywnC3ok' },
  218. { name: 'MONTAGEM CORAL', url: 'https://www.youtube.com/watch?v=yxzHzspf3RU' },
  219. { name: 'Evil Robin - Courtesy Call', url: 'https://www.youtube.com/watch?v=ocpDEOXABWg?feature=shared' },
  220. { name: 'MEEKZ - LIKE ME', url: 'https://youtu.be/hm-MOdLU21M?feature=shared' },
  221. { name: 'Digga D - STFU', url: 'https://youtu.be/dsVdGV1RLqg?feature=shared' },
  222. { name: 'Hanumankind – Big Dawgs', url: 'https://youtu.be/hOHKltAiKXQ?feature=shared' }
  223. ];
  224.  
  225. // Track the currently playing video ID
  226. let currentPlayingID = null;
  227. let currentButton = null;
  228.  
  229. // Add buttons for each music genre
  230. musicList.forEach(music => {
  231. const musicItem = document.createElement('div');
  232. musicItem.style.display = 'flex';
  233. musicItem.style.alignItems = 'center';
  234. musicItem.style.marginBottom = '10px';
  235.  
  236. const musicButton = document.createElement('button');
  237. musicButton.textContent = music.name + ' (Play)';
  238. musicButton.style.flex = '1';
  239. musicButton.style.marginRight = '10px';
  240. musicButton.style.padding = '10px';
  241. musicButton.style.backgroundColor = 'Black';
  242. musicButton.style.color = 'white';
  243. musicButton.style.border = '1px solid White';
  244. musicButton.style.borderRadius = '5px';
  245. musicButton.style.cursor = 'pointer';
  246. musicButton.style.transition = 'background-color 0.3s'; // Transition for background color
  247.  
  248. const stopButton = document.createElement('button');
  249. stopButton.textContent = 'Stop';
  250. stopButton.style.width = '50px';
  251. stopButton.style.padding = '10px';
  252. stopButton.style.backgroundColor = 'Black';
  253. stopButton.style.color = 'white';
  254. stopButton.style.border = '1px solid white';
  255. stopButton.style.borderRadius = '5px';
  256. stopButton.style.cursor = 'pointer';
  257.  
  258. stopButton.addEventListener('click', () => {
  259. if (currentPlayingID) {
  260. player.stopVideo();
  261. currentPlayingID = null;
  262. if (currentButton) {
  263. currentButton.textContent = currentButton.textContent.replace(' (Playing)', ' (Play)');
  264. currentButton.style.backgroundColor = 'white';
  265. }
  266. }
  267. });
  268.  
  269. musicButton.addEventListener('click', () => {
  270. if (currentPlayingID && currentButton) {
  271. player.stopVideo();
  272. currentButton.textContent = currentButton.textContent.replace(' (Playing)', ' (Play)');
  273. currentButton.style.backgroundColor = 'black';
  274. }
  275. const videoID = extractVideoID(music.url);
  276. if (videoID) {
  277. player.loadVideoById(videoID);
  278. player.playVideo();
  279. currentPlayingID = videoID;
  280. currentButton = musicButton;
  281. musicButton.textContent = music.name + ' (Playing)';
  282. musicButton.style.backgroundColor = 'black'; // Highlight color for playing
  283. }
  284. });
  285.  
  286. musicItem.appendChild(musicButton);
  287. musicItem.appendChild(stopButton);
  288. menuContainer.appendChild(musicItem);
  289. });
  290.  
  291. // Add the menu to the page
  292. document.body.appendChild(menuContainer);
  293.  
  294. // Create an invisible player container
  295. const playerContainer = document.createElement('div');
  296. playerContainer.id = 'musicPlayer';
  297. playerContainer.style.position = 'fixed';
  298. playerContainer.style.bottom = '0';
  299. playerContainer.style.right = '0';
  300. playerContainer.style.width = '0';
  301. playerContainer.style.height = '0';
  302. document.body.appendChild(playerContainer);
  303.  
  304. // Load YouTube IFrame Player API
  305. let tag = document.createElement('script');
  306. tag.src = "https://www.youtube.com/iframe_api";
  307. let firstScriptTag = document.getElementsByTagName('script')[0];
  308. firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  309.  
  310. // Create YouTube player
  311. let player;
  312. window.onYouTubeIframeAPIReady = function() {
  313. player = new YT.Player('musicPlayer', {
  314. height: '0',
  315. width: '0',
  316. videoId: '',
  317. playerVars: { 'autoplay': 1, 'controls': 0, 'mute': 0 },
  318. events: {
  319. 'onReady': onPlayerReady
  320. }
  321. });
  322. };
  323.  
  324. function onPlayerReady(event) {
  325. console.log('YouTube Player is ready');
  326. }
  327.  
  328. // Function to extract video ID from YouTube URL
  329. function extractVideoID(url) {
  330. const videoIDMatch = url.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);
  331. return videoIDMatch ? videoIDMatch[1] : null;
  332. }
  333.  
  334. // Handle TAB key to toggle the menu
  335. document.addEventListener('keydown', (event) => {
  336. if (event.key === 'Tab') {
  337. event.preventDefault(); // Prevent default TAB behavior
  338. if (menuContainer.style.display === 'none') {
  339. menuContainer.style.display = 'block';
  340. setTimeout(() => {
  341. menuContainer.style.opacity = '1'; // Fade in effect
  342. menuContainer.style.transform = 'translate(-50%, -50%)'; // Move to final position
  343. }, 10); // Small delay to apply transition
  344. } else {
  345. menuContainer.style.opacity = '0'; // Fade out effect
  346. menuContainer.style.transform = 'translate(-50%, -60%)'; // Move to starting position
  347. setTimeout(() => {
  348. menuContainer.style.display = 'none';
  349. }, 500); // Match transition duration
  350. }
  351. }
  352. });
  353. })();
  354. (function() {
  355. let shadowRadius = 50;
  356. let shadowDirection = 1;
  357. let canShadow = true;
  358. setInterval(() => {
  359. if (canShadow == true) {
  360. shadowRadius = (shadowDirection == 1) ? shadowRadius - 5 : shadowRadius + 5;
  361. if (shadowRadius >= 50 || shadowRadius <= 0) {
  362. shadowDirection = (shadowRadius >= 50) ? 1 : (shadowRadius <= 0) ? 0 : null;
  363. canShadow = false;
  364. setTimeout(() => {
  365. canShadow = true;
  366. }, 100);
  367. }
  368. }
  369. document.getElementById("gameName").style.textShadow = `0px 0px ${shadowRadius + 20}px #ff3700`;
  370. }, 100);
  371. })();
  372. // Game-Ground 2 xD
  373. document.getElementById('enterGame').innerText = "UR HIM";
  374. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  375. document.getElementById('enterGame').innerText = "FUCK ALL BLACK";
  376. document.getElementById("gameName").style.color = "";
  377. });
  378. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  379. document.getElementById('enterGame').innerText = "UR HIM NIGGA";
  380. document.getElementById("gameName").style.color = "";
  381. });
  382.  
  383. document.getElementById('gameName').innerHTML = '';
  384. setTimeout(() => {
  385. document.getElementById('gameName').innerHTML = 'Project FMA';
  386. setTimeout(() => {
  387. document.getElementById('gameName').innerHTML = 'Project FMA';
  388. setTimeout(() => {
  389. document.getElementById('gameName').innerHTML = 'Project FMA';
  390. setTimeout(() => {
  391. document.getElementById('gameName').innerHTML = 'Project FMA';
  392. setTimeout(() => {
  393. document.getElementById('gameName').innerHTML = 'Project FMA ';
  394. setTimeout(() => {
  395. document.getElementById('gameName').innerHTML = 'Project FMA';
  396. setTimeout(() => {
  397. document.getElementById('gameName').innerHTML = 'Project FMA';
  398. setTimeout(() => {
  399. document.getElementById('gameName').innerHTML = 'Project FMA';
  400. setTimeout(() => {
  401. document.getElementById('gameName').innerHTML = 'Project FMA';
  402. setTimeout(() => {
  403. document.getElementById('gameName').innerHTML = 'Project FMA';
  404. setTimeout(() => {
  405. document.getElementById('gameName').innerHTML = 'By CtrlShift...';
  406. setTimeout(() => {
  407. document.getElementById('gameName').innerHTML = 'Project FMA v0.1';
  408. }, 1200);
  409. }, 120);
  410. }, 120);
  411. }, 120);
  412. }, 120);
  413. }, 120);
  414. }, 120);
  415. }, 120);
  416. }, 120);
  417. }, 120);
  418. }, 1200);
  419. }, 120);
  420.  
  421.  
  422.  
  423. document.getElementById('loadingText').innerHTML = 'black';
  424. setTimeout(() => {
  425. document.getElementById('loadingText').innerHTML = 'Wellcome';
  426. }, 710);
  427. document.getElementById("mainMenu").style.backgroundSize = "cover";
  428. document.getElementById("mainMenu").style.backgroundPosition = "center";
  429. document.getElementById("mainMenu").style.width = "100%";
  430. document.getElementById("mainMenu").style.height = "100vh";
  431. document.getElementById("gameName").style.textShadow = "#000000 -2px -2px 10px, black 0px -5px 1px, white 0px -5px 10px";
  432. document.getElementById("loadingText").innerText="";
  433.  
  434.  
  435. // Test Auto Reply
  436. let founda = false;
  437. let scriptTags = document.getElementsByTagName("script");
  438. for (let i = 0; i < scriptTags.length; i++) {
  439. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  440. scriptTags[i].remove();
  441. founda = true;
  442. break;
  443. }
  444. }
  445.  
  446. var styleItem = document.createElement("style");
  447. styleItem.type = "text/css";
  448. styleItem.appendChild(document.createTextNode(`
  449. #suggestBox {
  450. width: 355px;
  451. border-radius: 3px;
  452. background-color: rgba(0,0,0,0.5);
  453. margin: auto;
  454. text-align: left;
  455. z-index: 49;
  456. pointer-events: auto;
  457. position: relative;
  458. bottom: 3.5px;
  459. overflow-y: auto;
  460. }
  461. #suggestBox div {
  462. background-color: rgba(255,255,255,0);
  463. color: rgba(255,255,255,1);
  464. transition: background-color 0.3s, color 0.3s;
  465. }
  466. #suggestBox div:hover {
  467. background-color: rgba(255,255,255,0.2);
  468. color: rgba(0,0,0,1);
  469. }
  470. .suggestBoxHard {
  471. color: rgba(255,255,255,1);
  472. font-size: 18px;
  473. }
  474. .suggestBoxLight {
  475. color: rgba(255,255,255,0.7);
  476. font-size: 18px;
  477. }
  478. `));
  479. document.head.appendChild(styleItem);
  480.  
  481. window.addEventListener('load', function() {
  482. var allianceButton = document.getElementById('allianceButton');
  483. var storeButton = document.getElementById('storeButton');
  484. if (storeButton) {
  485. storeButton.style.right = '26px';
  486. storeButton.style.top = '420px';
  487. }
  488. if (allianceButton) {
  489. allianceButton.style.right = '26px';
  490. allianceButton.style.top = '479px';
  491. }
  492. });
  493.  
  494. function getEl(id) {
  495. return document.getElementById(id);
  496. }
  497.  
  498. !function(run) {
  499.  
  500. let newFont = document.createElement("link");
  501. newFont.rel = "stylesheet";
  502. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  503. newFont.type = "text/css";
  504. document.body.append(newFont);
  505.  
  506. let min = document.createElement("script");
  507. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  508. document.body.append(min);
  509. window.oncontextmenu = function() {
  510. return false;
  511. };
  512.  
  513. let config = window.config;
  514.  
  515. // CLIENT:
  516. config.clientSendRate = 9; // Aim Packet Send Rate
  517. config.serverUpdateRate = 9;
  518.  
  519. // UI:
  520. config.deathFadeout = 0;
  521.  
  522. config.playerCapacity = 9999;
  523.  
  524. // CHECK IN SANDBOX:
  525. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  526.  
  527. // CUSTOMIZATION:
  528. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  529. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  530. "#8bc373", "#91b2db"
  531. ];
  532. config.weaponVariants = [{
  533. id: 0,
  534. src: "",
  535. xp: 0,
  536. val: 1,
  537. }, {
  538. id: 1,
  539. src: "_g",
  540. xp: 3000,
  541. val: 1.1,
  542. }, {
  543. id: 2,
  544. src: "_d",
  545. xp: 7000,
  546. val: 1.18,
  547. }, {
  548. id: 3,
  549. src: "_r",
  550. poison: true,
  551. xp: 12000,
  552. val: 1.18,
  553. }, {
  554. id: 4,
  555. src: "_e",
  556. poison: true,
  557. heal: true,
  558. xp: 24000,
  559. val: 1.18,
  560. }];
  561.  
  562. // VISUAL:
  563. config.anotherVisual = true;
  564. config.useWebGl = false;
  565. config.resetRender = true;
  566.  
  567. function waitTime(timeout) {
  568. return new Promise((done) => {
  569. setTimeout(() => {
  570. done();
  571. }, timeout);
  572. });
  573. }
  574.  
  575. let botSkts = [];
  576.  
  577. // STORAGE:
  578. let canStore;
  579. if (typeof(Storage) !== "undefined") {
  580. canStore = true;
  581. }
  582.  
  583. function saveVal(name, val) {
  584. if (canStore)
  585. localStorage.setItem(name, val);
  586. }
  587.  
  588. function deleteVal(name) {
  589. if (canStore)
  590. localStorage.removeItem(name);
  591. }
  592.  
  593. function getSavedVal(name) {
  594. if (canStore)
  595. return localStorage.getItem(name);
  596. return null;
  597. }
  598.  
  599. // CONFIGS:
  600. let gC = function(a, b) {
  601. try {
  602. let res = JSON.parse(getSavedVal(a));
  603. if (typeof res === "object") {
  604. return b;
  605. } else {
  606. return res;
  607. }
  608. } catch (e) {
  609. alert("dieskid");
  610. return b;
  611. }
  612. };
  613.  
  614. function setCommands() {
  615. return {
  616. "help": {
  617. desc: "Show Commands",
  618. action: function(message) {
  619. for (let cmds in commands) {
  620. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  621. }
  622. }
  623. },
  624. "clear": {
  625. desc: "Clear Chats",
  626. action: function(message) {
  627. resetMenuChText();
  628. }
  629. },
  630. "debug": {
  631. desc: "Debug Mod For Development",
  632. action: function(message) {
  633. addDeadPlayer(player);
  634. addMenuChText("Debug", "Done", "#99ee99", 1);
  635. }
  636. },
  637. "play": {
  638. desc: "Play Music ( /play [link] )",
  639. action: function(message) {
  640. let link = message.split(" ");
  641. if (link[1]) {
  642. let audio = new Audio(link[1]);
  643. audio.play();
  644. } else {
  645. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  646. }
  647. }
  648. },
  649. "bye": {
  650. desc: "Leave Game",
  651. action: function(message) {
  652. window.leave();
  653. }
  654. },
  655. };
  656. }
  657.  
  658. function setConfigs() {
  659. return {
  660. killChat: true,
  661. alwaysRev: true,
  662. autoBuy: true,
  663. autoBuyEquip: true,
  664. autoPush: true,
  665. revTick: true,
  666. spikeTick: true,
  667. predictTick: true,
  668. autoPlace: true,
  669. autoReplace: true,
  670. antiTrap: true,
  671. slowOT: false,
  672. attackDir: false,
  673. showDir: false,
  674. noDir: false,
  675. autoRespawn: false
  676. };
  677. };
  678. let commands = setCommands();
  679. let configs = setConfigs();
  680. window.removeConfigs = function() {
  681. for (let cF in configs) {
  682. deleteVal(cF, configs[cF]);
  683. }
  684. };
  685.  
  686. for (let cF in configs) {
  687. configs[cF] = gC(cF, configs[cF]);
  688. }
  689.  
  690. // MENU FUNCTIONS:
  691. window.changeMenu = function() {};
  692. window.debug = function() {};
  693. window.wasdMode = function() {};
  694.  
  695. // PAGE 1:
  696. window.startGrind = function() {};
  697.  
  698. // PAGE 3:
  699. window.connectFillBots = function() {};
  700. window.destroyFillBots = function() {};
  701. window.tryConnectBots = function() {};
  702. window.destroyBots = function() {};
  703. window.resBuild = function() {};
  704. window.toggleBotsCircle = function() {};
  705. window.toggleVisual = function() {};
  706.  
  707. // SOME FUNCTIONS:
  708. window.prepareUI = function() {};
  709. window.leave = function() {};
  710.  
  711. // nah hahahahahhh why good ping
  712. window.ping = 0;
  713.  
  714. class deadfuturechickenmodrevival {
  715. constructor(flarez, lore) {
  716. this.inGame = false;
  717. this.lover = flarez + lore;
  718. this.baby = "ae86";
  719. this.isBlack = 0;
  720. this.webSocket = undefined;
  721. this.checkBaby = function() {
  722. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  723. if (this.isBlack >= 1) return "bl4cky";
  724. return "noting for you";
  725. };
  726. this.x2 = 0;
  727. this.y2 = 0;
  728. this.chat = "Imagine playing this badass game XDDDDD";
  729. this.summon = function(tmpObj) {
  730. this.x2 = tmpObj.x;
  731. this.y2 = tmpObj.y;
  732. this.chat = tmpObj.name + " ur so bad XDDDD";
  733. };
  734. this.commands = function(cmd) {
  735. cmd == "rv3link" && window.open("https://florr.io/");
  736. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  737. return cmd;
  738. };
  739. this.dayte = "11yearold";
  740. this.memeganoob = "69yearold";
  741. this.startDayteSpawn = function(tmpObj) {
  742. let ratio = setInterval(() => {
  743. this.x2 = tmpObj.x + 20;
  744. this.y2 = tmpObj.y - 20;
  745. this.chat = "UR SO BAD LOL";
  746. if (tmpObj.name == "ae86") {
  747. this.chat = "omg ae86 go run";
  748. setTimeout(() => {
  749. this.inGame = false;
  750. clearInterval(ratio);
  751. }, 1000);
  752. }
  753. }, 1234);
  754. };
  755. this.AntiChickenModV69420 = function(tmpObj) {
  756. return "!c!dc user " + tmpObj.name;
  757. };
  758. }
  759. };
  760. class HtmlAction {
  761. constructor(element) {
  762. this.element = element;
  763. };
  764. add(code) {
  765. if (!this.element) return undefined;
  766. this.element.innerHTML += code;
  767. };
  768. newLine(amount) {
  769. let result = `<br>`;
  770. if (amount > 0) {
  771. result = ``;
  772. for (let i = 0; i < amount; i++) {
  773. result += `<br>`;
  774. }
  775. }
  776. this.add(result);
  777. };
  778. checkBox(setting) {
  779. let newCheck = `<input type = "checkbox"`;
  780. setting.id && (newCheck += ` id = ${setting.id}`);
  781. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  782. setting.class && (newCheck += ` class = ${setting.class}`);
  783. setting.checked && (newCheck += ` checked`);
  784. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  785. newCheck += `>`;
  786. this.add(newCheck);
  787. };
  788. text(setting) {
  789. let newText = `<input type = "text"`;
  790. setting.id && (newText += ` id = ${setting.id}`);
  791. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  792. setting.class && (newText += ` class = ${setting.class}`);
  793. setting.size && (newText += ` size = ${setting.size}`);
  794. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  795. setting.value && (newText += ` value = ${setting.value}`);
  796. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  797. newText += `>`;
  798. this.add(newText);
  799. };
  800. select(setting) {
  801. let newSelect = `<select`;
  802. setting.id && (newSelect += ` id = ${setting.id}`);
  803. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  804. setting.class && (newSelect += ` class = ${setting.class}`);
  805. newSelect += `>`;
  806. for (let options in setting.option) {
  807. newSelect += `<option value = ${setting.option[options].id}`
  808. setting.option[options].selected && (newSelect += ` selected`);
  809. newSelect += `>${options}</option>`;
  810. }
  811. newSelect += `</select>`;
  812. this.add(newSelect);
  813. };
  814. button(setting) {
  815. let newButton = `<button`;
  816. setting.id && (newButton += ` id = ${setting.id}`);
  817. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  818. setting.class && (newButton += ` class = ${setting.class}`);
  819. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  820. newButton += `>`;
  821. setting.innerHTML && (newButton += setting.innerHTML);
  822. newButton += `</button>`;
  823. this.add(newButton);
  824. };
  825. selectMenu(setting) {
  826. let newSelect = `<select`;
  827. if (!setting.id) {
  828. alert("please put id skid");
  829. return;
  830. }
  831. window[setting.id + "Func"] = function() {};
  832. setting.id && (newSelect += ` id = ${setting.id}`);
  833. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  834. setting.class && (newSelect += ` class = ${setting.class}`);
  835. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  836. newSelect += `>`;
  837. let last;
  838. let i = 0;
  839. for (let options in setting.menu) {
  840. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  841. setting.menu[options] && (newSelect += ` checked`);
  842. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  843. i++;
  844. }
  845. newSelect += `</select>`;
  846.  
  847. this.add(newSelect);
  848.  
  849. i = 0;
  850. for (let options in setting.menu) {
  851. window[options + "Func"] = function() {
  852. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  853. saveVal(options, setting.menu[options]);
  854.  
  855. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  856. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  857.  
  858. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  859.  
  860. };
  861. this.checkBox({
  862. id: "check_" + options,
  863. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  864. class: "checkB",
  865. onclick: `window.${options + "Func"}()`,
  866. checked: setting.menu[options]
  867. });
  868. i++;
  869. }
  870.  
  871. last = "check_" + getEl(setting.id).value.split("_")[1];
  872. window[setting.id + "Func"] = function() {
  873. getEl(last).style.display = "none";
  874. last = "check_" + getEl(setting.id).value.split("_")[1];
  875. getEl(last).style.display = "inline-block";
  876.  
  877. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  878.  
  879. };
  880. };
  881. };
  882. class Html {
  883. constructor() {
  884. this.element = null;
  885. this.action = null;
  886. this.divElement = null;
  887. this.startDiv = function(setting, func) {
  888.  
  889. let newDiv = document.createElement("div");
  890. setting.id && (newDiv.id = setting.id);
  891. setting.style && (newDiv.style = setting.style);
  892. setting.class && (newDiv.className = setting.class);
  893. this.element.appendChild(newDiv);
  894. this.divElement = newDiv;
  895.  
  896. let addRes = new HtmlAction(newDiv);
  897. typeof func == "function" && func(addRes);
  898.  
  899. };
  900. this.addDiv = function(setting, func) {
  901.  
  902. let newDiv = document.createElement("div");
  903. setting.id && (newDiv.id = setting.id);
  904. setting.style && (newDiv.style = setting.style);
  905. setting.class && (newDiv.className = setting.class);
  906. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  907. this.divElement = newDiv;
  908.  
  909. let addRes = new HtmlAction(newDiv);
  910. typeof func == "function" && func(addRes);
  911.  
  912. };
  913. };
  914. set(id) {
  915. this.element = getEl(id);
  916. this.action = new HtmlAction(this.element);
  917. };
  918. resetHTML(text) {
  919. if (text) {
  920. this.element.innerHTML = ``;
  921. } else {
  922. this.element.innerHTML = ``;
  923. }
  924. };
  925. setStyle(style) {
  926. this.element.style = style;
  927. };
  928. setCSS(style) {
  929. this.action.add(`<style>` + style + `</style>`);
  930. };
  931. };
  932.  
  933. let HTML = new Html();
  934. let nightMode = document.createElement("div");
  935. nightMode.id = "nightMode";
  936. document.body.appendChild(nightMode);
  937. HTML.set("nightMode");
  938. HTML.setStyle(`
  939. display: none;
  940. position: absolute;
  941. pointer-events: none;
  942. background-color: rgb(0, 0, 100);
  943. opacity: 0;
  944. top: 0%;
  945. width: 100%;
  946. height: 100%;
  947. animation-duration: 5s;
  948. animation-name: night2;
  949. `);
  950. HTML.resetHTML();
  951. HTML.setCSS(`
  952. @keyframes night1 {
  953. from {opacity: 0;}
  954. to {opacity: 0.35;}
  955. }
  956. @keyframes night2 {
  957. from {opacity: 0.35;}
  958. to {opacity: 0;}
  959. }
  960. `);
  961. let menuDiv = document.createElement("div");
  962. menuDiv.id = "menuDiv";
  963. document.body.appendChild(menuDiv);
  964. HTML.set("menuDiv");
  965. HTML.setStyle(`
  966. position: absolute;
  967. left: 100px;
  968. top: 100px;
  969. `);
  970. HTML.resetHTML();
  971. HTML.setCSS(`
  972. .menuClass{
  973. color: #ffffff;
  974. background-image: url('https://th.bing.com/th/id/R.9eedb9ff1ee8864875d13effb259e9b8?rik=kHMDT6Hsbuou0w&riu=http%3a%2f%2fimages4.fanpop.com%2fimage%2fphotos%2f19600000%2fFMA-full-metal-alchemist-19655872-800-600.jpg&ehk=VjtMDp13alLxoP1Zx6V8wDaB%2b%2fud%2fYT1nXzhqg72rcI%3d&risl=&pid=ImgRaw&r=0');
  975. background-size: cover;
  976. background-position: center;
  977. background-repeat: no-repeat;
  978. font-size: 150px;
  979. text-align: left;
  980. padding: 40px;
  981. padding-top: 15px;
  982. padding-bottom: 10px;
  983. width: 320px;
  984. background-color: #ffffff;
  985. -webkit-border-radius: 40px;
  986. -moz-border-radius: 40px;
  987. border-radius: 40px;
  988. }
  989. .menuC {
  990. display: none;
  991. font-family: "HammerSmith One";
  992. font-size: 12px;
  993. max-height: 300px;
  994. overflow-y: scroll;
  995. -webkit-touch-callout: none;
  996. -webkit-user-select: none;
  997. -khtml-user-select: none;
  998. -moz-user-select: none;
  999. -ms-user-select: none;
  1000. user-select: none;
  1001. }
  1002. .menuB {
  1003. box-shadow 0px 0px 20px 5px #89e8e5;
  1004. text-align: center;
  1005. background-color: rgba(0, 0, 0, 0.15);
  1006. color: #ffffff;
  1007. -webkit-border-radius: 55px;
  1008. -moz-border-radius: 55px;
  1009. border-radius: 3px;
  1010. border: 2px solid rgba(0, 0, 0, 0.15);
  1011. cursor: pointer;
  1012. }
  1013. .menuB:hover {
  1014. border: 2px solid rgba(0, 0, 0, 0.15);
  1015. }
  1016. .menuB:active {
  1017. color: rgba(0, 0, 0, 0.15);
  1018. background-color: rgba(0, 0, 0, 0.15);
  1019. }
  1020. .customText {
  1021. color: #030114;
  1022. -webkit-border-radius: 16px;
  1023. -moz-border-radius: 12px;
  1024. border-radius: 3px;
  1025. border: 2px solid rgba(0, 0, 0, 0.15);
  1026. }
  1027. .customText:focus {
  1028. background-color: black;
  1029. }
  1030. .checkB {
  1031. position: relative;
  1032. top: 2px;
  1033. accent-color: rgba(0, 0, 0, 0.15);
  1034. cursor: pointer;
  1035. }
  1036. .Cselect {
  1037. -webkit-border-radius: 4px;
  1038. -moz-border-radius: 4px;
  1039. border-radius: 3px;
  1040. background-color: rgba(0, 0, 0, 0.15);
  1041. color: #ffffff;
  1042. border: 1px solid rgba(0, 0, 0, 0.15);
  1043. }
  1044. ::-webkit-scrollbar {
  1045. width: 10px;
  1046. }
  1047. ::-webkit-scrollbar-track {
  1048. opacity: 0;
  1049. }
  1050. ::-webkit-scrollbar-thumb {
  1051. background-color: rgba(0, 0, 0, 0.15);
  1052. -webkit-border-radius: 4px;
  1053. -moz-border-radius: 4px;
  1054. border-radius: 3px;
  1055. }
  1056. ::-webkit-scrollbar-thumb:active {
  1057. background-color: rgba(0, 0, 0, 0.15);
  1058. }
  1059. `);
  1060.  
  1061. HTML.startDiv({
  1062. id: "menuHeadLine",
  1063. class: "menuClass"
  1064. }, (html) => {
  1065. html.add(`FMA`);
  1066. html.button({
  1067. id: "menuChanger",
  1068. class: "material-icons",
  1069. innerHTML: `sync`,
  1070. onclick: "window.changeMenu()"
  1071. });
  1072. HTML.addDiv({
  1073. id: "menuButtons",
  1074. style: "display: block; overflow-y: visible;",
  1075. class: "menuC",
  1076. appendID: "menuHeadLine"
  1077. }, (html) => {
  1078. html.button({
  1079. class: "menuB",
  1080. innerHTML: "Debug",
  1081. onclick: "window.debug()"
  1082. });
  1083. });
  1084. HTML.addDiv({
  1085. id: "menuMain",
  1086. style: "display: block",
  1087. class: "menuC",
  1088. appendID: "menuHeadLine"
  1089. }, (html) => {
  1090. html.button({
  1091. class: "menuB",
  1092. innerHTML: "Toggle Wasd Mode",
  1093. onclick: "window.wasdMode()"
  1094. });
  1095. html.newLine();
  1096. html.add(`Ruby Farm:`);
  1097. html.checkBox({
  1098. id: "weaponGrind",
  1099. class: "checkB",
  1100. onclick: "window.startGrind()"
  1101. });
  1102. html.newLine(2);
  1103. HTML.addDiv({
  1104. style: "font-size: 20px; color: #99ee99;",
  1105. appendID: "menuMain"
  1106. }, (html) => {
  1107. html.add(`Settings:`);
  1108. });
  1109. html.add(`FMA ANTI PUSH`);
  1110. html.checkBox({
  1111. id: "antipush",
  1112. class: "checkB",
  1113. checked: true
  1114. });
  1115. html.newLine();
  1116. html.add(`OP FMA HEAL?`);
  1117. html.checkBox({
  1118. id: "healingBeta",
  1119. class: "checkB",
  1120. checked: true
  1121. });
  1122. html.newLine();
  1123. });
  1124. HTML.addDiv({
  1125. id: "menuConfig",
  1126. class: "menuC",
  1127. appendID: "menuHeadLine"
  1128. }, (html) => {
  1129. html.add(`Placement Tick: `);
  1130. html.text({
  1131. id: "autoPlaceTick",
  1132. class: "customText",
  1133. value: "3",
  1134. size: "2em",
  1135. maxLength: "1"
  1136. });
  1137. html.newLine();
  1138. html.add(`Options: `);
  1139. html.selectMenu({
  1140. id: "configsChanger",
  1141. class: "Cselect",
  1142. menu: configs
  1143. });
  1144. html.newLine();
  1145. html.add(`AntiBull: `);
  1146. html.select({
  1147. id: "antiBullType",
  1148. class: "Cselect",
  1149. option: {
  1150. "Disable": {
  1151. id: "noab",
  1152. selected: true,
  1153. },
  1154. "When Reloaded": {
  1155. id: "abreload",
  1156. },
  1157. "Always": {
  1158. id: "abalway",
  1159. }
  1160. }
  1161. });
  1162. });
  1163. HTML.addDiv({
  1164. id: "menuOther",
  1165. class: "menuC",
  1166. appendID: "menuHeadLine"
  1167. }, (html) => {
  1168. html.button({
  1169. class: "menuB",
  1170. innerHTML: "Connect Bots",
  1171. onclick: "window.tryConnectBots()"
  1172. });
  1173. html.button({
  1174. class: "menuB",
  1175. innerHTML: "Disconnect Bots",
  1176. onclick: "window.destroyBots()"
  1177. });
  1178. html.newLine();
  1179. html.add(`Break Objects Range: `);
  1180. html.text({
  1181. id: "breakRange",
  1182. class: "customText",
  1183. value: "700",
  1184. size: "3em",
  1185. maxLength: "4"
  1186. });
  1187. html.newLine();
  1188. html.add(`Render Movement: `);
  1189. html.select({
  1190. id: "predictType",
  1191. class: "Cselect",
  1192. option: {
  1193. "Disable Render": {
  1194. id: "disableRender",
  1195. selected: true
  1196. },
  1197. "X/Y and 2": {
  1198. id: "pre2",
  1199. },
  1200. "X/Y and 3": {
  1201. id: "pre3"
  1202. }
  1203. }
  1204. });
  1205. html.newLine();
  1206. html.add(`Render Placers: `);
  1207. html.checkBox({
  1208. id: "placeVis",
  1209. class: "checkB",
  1210. });
  1211. html.newLine();
  1212. html.add(`Bot Mode: `);
  1213. html.select({
  1214. id: "mode",
  1215. class: "Cselect",
  1216. option: {
  1217. "Clear Building": {
  1218. id: "clear",
  1219. selected: true
  1220. },
  1221. "Sync": {
  1222. id: "zync",
  1223. },
  1224. "Search": {
  1225. id: "zearch"
  1226. },
  1227. "Clear Everything": {
  1228. id: "fuckemup"
  1229. },
  1230. "Flex": {
  1231. id: "flex"
  1232. }
  1233. }
  1234. });
  1235. html.newLine();
  1236. html.add(`Bot Setup: `);
  1237. html.select({
  1238. id: "setup",
  1239. class: "Cselect",
  1240. option: {
  1241. "Dagger Musket": {
  1242. id: "dm",
  1243. selected: true
  1244. },
  1245. "Katana Hammer": {
  1246. id: "kh",
  1247. },
  1248. "Dagger Repeater-Crossbow": {
  1249. id: "dr"
  1250. },
  1251. "Sword Muzket": {
  1252. id: "zd"
  1253. }
  1254. }
  1255. });
  1256. html.newLine();
  1257. html.button({
  1258. class: "menuB",
  1259. innerHTML: "Toggle Another Visual",
  1260. onclick: "window.toggleVisual()"
  1261. });
  1262. html.newLine();
  1263. });
  1264. });
  1265. function toFancyTimeFormat(time) {
  1266. let minutes = ~~((time % 3600) / 60);
  1267. let seconds = ~~time % 60;
  1268. if (seconds <= 9) seconds = `0${seconds}`;
  1269. return `${minutes}:${seconds}`;
  1270. }
  1271. const songchat1 = new Audio("https://cdn.discordapp.com/attachments/1175772907931176991/1227645695796969492/Benzz_-_Je_Mappelle_Music_Video_GRM_Daily.mp3?ex=662fc0a6&is=662e6f26&hm=0b1c67270ba28a0298c01b1a3435bcc5e4aac496053bc3e9a73689cef70870bf&");
  1272. let isPlaying = false;
  1273. let currentPart = '';
  1274. function toggleSong() {
  1275. if (!isPlaying) {
  1276. songchat1.play();
  1277. songchat1.ontimeupdate = function(time) {
  1278. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  1279. if (part && part !== currentPart) {
  1280. currentPart = part;
  1281. io.send("6", part);
  1282. }
  1283. };
  1284. songchat1.onended = function() {
  1285. if (isPlaying) {
  1286. songchat1.play();
  1287. }
  1288. };
  1289. isPlaying = true;
  1290. } else {
  1291. songchat1.pause();
  1292. isPlaying = false;
  1293. }
  1294. }
  1295. document.addEventListener("keypress", function(e) {
  1296. if (e.key === "C") {
  1297. toggleSong();
  1298. }
  1299. });
  1300. let menuChatDiv = document.createElement("div");
  1301. menuChatDiv.id = "menuChatDiv";
  1302. document.body.appendChild(menuChatDiv);
  1303. HTML.set("menuChatDiv");
  1304. HTML.setStyle(`
  1305. position: absolute;
  1306. display: none;
  1307. left: 0px;
  1308. top: 25px;
  1309. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1310. `);
  1311. HTML.resetHTML();
  1312. HTML.setCSS(`
  1313. .chDiv {
  1314. color: #fff;
  1315. padding: 10px;
  1316. width: 357px;
  1317. height: 217px;
  1318. background-color: rgba(0, 0, 0, 0.2);
  1319. font-family: "HammerSmith One", monospace;
  1320. // border-radius: 15px;
  1321. // box-shadow: black 1px 2px 19px;
  1322. //backdrop-filter: blur(3px);
  1323.  
  1324. }
  1325. .chMainDiv {
  1326. font-family: "Ubuntu";
  1327. font-size: 16px;
  1328. max-height: 215px;
  1329. overflow-y: scroll;
  1330. scrollbar-width: thin;
  1331. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1332. -webkit-touch-callout: none;
  1333. -webkit-user-select: none;
  1334. -khtml-user-select: none;
  1335. -moz-user-select: none;
  1336. -ms-user-select: none;
  1337. user-select: none;
  1338. overflow-x: hidden;
  1339. }
  1340. .chMainDiv::-webkit-scrollbar {
  1341. width: 8px;
  1342. }
  1343. .chMainDiv::-webkit-scrollbar-thumb {
  1344. background-color: rgba(0, 0, 0, 0.5);
  1345. }
  1346. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1347. background-color: rgba(0, 0, 0, 0.7);
  1348. }
  1349. .chMainBox {
  1350. display:none;
  1351. position: absolute;
  1352. left: 10px;
  1353. bottom: 10px;
  1354. width: 380px;
  1355. height: 25px;
  1356. background-color: rgba(255, 255, 255, 0.1);
  1357. border-radius: 5px;
  1358. color: rgba(255, 255, 255, 0.75);
  1359. font-family: "HammerSmith One";
  1360. font-size: 12px;
  1361. }
  1362. `);
  1363. HTML.startDiv({
  1364. id: "mChDiv",
  1365. class: "chDiv"
  1366. }, (html) => {
  1367. HTML.addDiv({
  1368. id: "mChMain",
  1369. class: "chMainDiv",
  1370. appendID: "mChDiv"
  1371. }, (html) => {});
  1372. html.text({
  1373. id: "mChBox",
  1374. class: "chMainBox",
  1375. // placeHolder: `To chat click here or press "Enter" key`
  1376. });
  1377. });
  1378.  
  1379. let menuChats = getEl("mChMain");
  1380. let menuChatBox = getEl("mChBox");
  1381. let menuCBFocus = false;
  1382. let menuChCounts = 0;
  1383.  
  1384. menuChatBox.value = "";
  1385. menuChatBox.addEventListener("focus", () => {
  1386. menuCBFocus = true;
  1387. });
  1388. menuChatBox.addEventListener("blur", () => {
  1389. menuCBFocus = false;
  1390. });
  1391.  
  1392. function addMenuChText(name, message, color, noTimer) {
  1393. HTML.set("menuChatDiv");
  1394. color = color || "white";
  1395. let time = new Date();
  1396. let min = time.getMinutes();
  1397. let hour = time.getHours();
  1398. let text = ``;
  1399. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1400. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1401. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1402. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1403. html.add(text);
  1404. });
  1405. menuChats.scrollTop = menuChats.scrollHeight;
  1406. menuChCounts++;
  1407. }
  1408. function chch(name, message, color, noTimer) {
  1409. HTML.set("menuChatDiv");
  1410. color = color || "white";
  1411. let time = new Date();
  1412. let text = ``;
  1413. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1414. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1415. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1416. html.add(text);
  1417. });
  1418. menuChats.scrollTop = menuChats.scrollHeight;
  1419. menuChCounts++;
  1420. }
  1421.  
  1422. function resetMenuChText() {
  1423. menuChats.innerHTML = ``;
  1424. menuChCounts = 0;
  1425. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1426. }
  1427. resetMenuChText();
  1428.  
  1429. let menuIndex = 0;
  1430. let menus = ["menuMain", "menuConfig", "menuOther"];
  1431. window.changeMenu = function() {
  1432. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1433. menuIndex++;
  1434. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1435. };
  1436.  
  1437. let mStatus = document.createElement("div");
  1438. mStatus.id = "status";
  1439. getEl("gameUI").appendChild(mStatus);
  1440. HTML.set("status");
  1441. HTML.setStyle(`
  1442. display: block;
  1443. position: absolute;
  1444. color: #ddd;
  1445. font: 15px HammerSmith One;
  1446. bottom: 215px;
  1447. left: 20px;
  1448. `);
  1449. HTML.resetHTML();
  1450. HTML.setCSS(`
  1451. .sizing {
  1452. font-size: 15px;
  1453. }
  1454. .mod {
  1455. font-size: 15px;
  1456. display: inline-block;
  1457. }
  1458. `);
  1459. HTML.startDiv({
  1460. id: "uehmod",
  1461. class: "sizing"
  1462. }, (html) => {
  1463. html.add(`Ping: `);
  1464. HTML.addDiv({
  1465. id: "pingFps",
  1466. class: "mod",
  1467. appendID: "uehmod"
  1468. }, (html) => {
  1469. html.add("None");
  1470. });
  1471. html.newLine();
  1472. html.add(`Packet: `);
  1473. HTML.addDiv({
  1474. id: "packetStatus",
  1475. class: "mod",
  1476. appendID: "uehmod"
  1477. }, (html) => {
  1478. html.add("None");
  1479. });
  1480. });
  1481.  
  1482. /*function modLog() {
  1483. let logs = [];
  1484. for (let i = 0; i < arguments.length; i++) {
  1485. logs.push(arguments[i]);
  1486. }
  1487. getEl("modLog").innerHTML = logs;
  1488. }*/
  1489.  
  1490. let openMenu = false;
  1491.  
  1492. let WS = undefined;
  1493. let socketID = undefined;
  1494.  
  1495. let useWasd = false;
  1496. let secPacket = 0;
  1497. let secMax = 120;
  1498. let secTime = 1000;
  1499. let firstSend = {
  1500. sec: false
  1501. };
  1502. let game = {
  1503. tick: 0,
  1504. tickQueue: [],
  1505. tickBase: function(set, tick) {
  1506. if (this.tickQueue[this.tick + tick]) {
  1507. this.tickQueue[this.tick + tick].push(set);
  1508. } else {
  1509. this.tickQueue[this.tick + tick] = [set];
  1510. }
  1511. },
  1512. tickRate: (1000 / config.serverUpdateRate),
  1513. tickSpeed: 0,
  1514. lastTick: performance.now()
  1515. };
  1516. let modConsole = [];
  1517.  
  1518. let dontSend = false;
  1519. let fpsTimer = {
  1520. last: 0,
  1521. time: 0,
  1522. ltime: 0
  1523. }
  1524. let lastMoveDir = undefined;
  1525. let lastsp = ["cc", 1, "__proto__"];
  1526.  
  1527. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1528. WebSocket.prototype.send = function(message) {
  1529. if (!WS) {
  1530. WS = this;
  1531. WS.addEventListener("message", function(msg) {
  1532. getMessage(msg);
  1533. });
  1534. WS.addEventListener("close", (event) => {
  1535. if (event.code == 4001) {
  1536. window.location.reload();
  1537. }
  1538. });
  1539. }
  1540. if (WS == this) {
  1541. dontSend = false;
  1542.  
  1543. // EXTRACT DATA ARRAY:
  1544. let data = new Uint8Array(message);
  1545. let parsed = window.msgpack.decode(data);
  1546. let type = parsed[0];
  1547. data = parsed[1];
  1548.  
  1549. // SEND MESSAGE:
  1550. if (type == "6") {
  1551.  
  1552. if (data[0]) {
  1553. // ANTI PROFANITY:
  1554. 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", ];
  1555. let tmpString;
  1556. profanity.forEach((profany) => {
  1557. if (data[0].indexOf(profany) > -1) {
  1558. tmpString = "";
  1559. for (let i = 0; i < profany.length; ++i) {
  1560. if (i == 1) {
  1561. tmpString += String.fromCharCode(0);
  1562. }
  1563. tmpString += profany[i];
  1564. }
  1565. let re = new RegExp(profany, "g");
  1566. data[0] = data[0].replace(re, tmpString);
  1567. }
  1568. });
  1569.  
  1570. // FIX CHAT:
  1571. data[0] = data[0].slice(0, 30);
  1572. }
  1573.  
  1574. } else if (type == "L") {
  1575. // MAKE SAME CLAN:
  1576. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1577. data[0] = data[0].slice(0, 7);
  1578. } else if (type == "M") {
  1579. // APPLY CYAN COLOR:
  1580. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1581. data[0].moofoll = true;
  1582. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1583. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1584. } else if (type == "D") {
  1585. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1586. dontSend = true;
  1587. } else {
  1588. my.lastDir = data[0];
  1589. }
  1590. } else if (type == "d") {
  1591. if (!data[2]) {
  1592. dontSend = true;
  1593. } else {
  1594. if (![null, undefined].includes(data[1])) {
  1595. my.lastDir = data[1];
  1596. }
  1597. }
  1598. } else if (type == "K") {
  1599. if (!data[1]) {
  1600. dontSend = true;
  1601. }
  1602. } else if (type == "S") {
  1603. instaC.wait = !instaC.wait;
  1604. dontSend = true;
  1605. } else if (type == "f") {
  1606. if (data[1]) {
  1607. if (player.moveDir == data[0]) {
  1608. dontSend = true;
  1609. }
  1610. player.moveDir = data[0];
  1611. } else {
  1612. dontSend = true;
  1613. }
  1614. }
  1615. if (!dontSend) {
  1616. let binary = window.msgpack.encode([type, data]);
  1617. this.nsend(binary);
  1618.  
  1619. // START COUNT:
  1620. if (!firstSend.sec) {
  1621. firstSend.sec = true;
  1622. setTimeout(() => {
  1623. firstSend.sec = false;
  1624. secPacket = 0;
  1625. }, secTime);
  1626. }
  1627.  
  1628. secPacket++;
  1629. }
  1630. } else {
  1631. this.nsend(message);
  1632. }
  1633. }
  1634.  
  1635. function packet(type) {
  1636. // EXTRACT DATA ARRAY:
  1637. let data = Array.prototype.slice.call(arguments, 1);
  1638.  
  1639. // SEND MESSAGE:
  1640. let binary = window.msgpack.encode([type, data]);
  1641. WS.send(binary);
  1642. }
  1643.  
  1644. function origPacket(type) {
  1645. // EXTRACT DATA ARRAY:
  1646. let data = Array.prototype.slice.call(arguments, 1);
  1647.  
  1648. // SEND MESSAGE:
  1649. let binary = window.msgpack.encode([type, data]);
  1650. WS.nsend(binary);
  1651. }
  1652.  
  1653. window.leave = function() {
  1654. origPacket("kys", {
  1655. "frvr is so bad": true,
  1656. "sidney is too good": true,
  1657. "dev are too weak": true,
  1658. });
  1659. };
  1660.  
  1661. //...lol
  1662. let io = {
  1663. send: packet
  1664. };
  1665.  
  1666. function getMessage(message) {
  1667. let data = new Uint8Array(message.data);
  1668. let parsed = window.msgpack.decode(data);
  1669. let type = parsed[0];
  1670. data = parsed[1];
  1671. let events = {
  1672. A: setInitData, // id: setInitData,
  1673. //B: disconnect,
  1674. C: setupGame, // 1: setupGame,
  1675. D: addPlayer, // 2: addPlayer,
  1676. E: removePlayer, // 4: removePlayer,
  1677. a: updatePlayers, // 33: updatePlayers,
  1678. G: updateLeaderboard, // 5: updateLeaderboard,here
  1679. H: loadGameObject, // 6: loadGameObject,
  1680. I: loadAI, // a: loadAI,
  1681. J: animateAI, // aa: animateAI,
  1682. K: gatherAnimation, // 7: gatherAnimation,
  1683. L: wiggleGameObject, // 8: wiggleGameObject,
  1684. M: shootTurret, // sp: shootTurret,
  1685. N: updatePlayerValue, // 9: updatePlayerValue,
  1686. O: updateHealth, // h: updateHealth,//here
  1687. P: killPlayer, // 11: killPlayer,
  1688. Q: killObject, // 12: killObject,
  1689. R: killObjects, // 13: killObjects,
  1690. S: updateItemCounts, // 14: updateItemCounts,
  1691. T: updateAge, // 15: updateAge,
  1692. U: updateUpgrades, // 16: updateUpgrades,
  1693. V: updateItems, // 17: updateItems,
  1694. X: addProjectile, // 18: addProjectile,
  1695. Y: remProjectile, // 19: remProjectile,
  1696. //Z: serverShutdownNotice,
  1697. //0: addAlliance,
  1698. //1: deleteAlliance,
  1699. 2: allianceNotification, // an: allianceNotification,
  1700. 3: setPlayerTeam, // st: setPlayerTeam,
  1701. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1702. 5: updateStoreItems, // us: updateStoreItems,
  1703. 6: receiveChat, // ch: receiveChat,
  1704. 7: updateMinimap, // mm: updateMinimap,
  1705. 8: showText, // t: showText,
  1706. 9: pingMap, // p: pingMap,
  1707. 0: pingSocketResponse,
  1708. };
  1709. if (type == "io-init") {
  1710. socketID = data[0];
  1711. } else {
  1712. if (events[type]) {
  1713. events[type].apply(undefined, data);
  1714. }
  1715. }
  1716. }
  1717.  
  1718. // MATHS:
  1719. Math.lerpAngle = function(value1, value2, amount) {
  1720. let difference = Math.abs(value2 - value1);
  1721. if (difference > Math.PI) {
  1722. if (value1 > value2) {
  1723. value2 += Math.PI * 2;
  1724. } else {
  1725. value1 += Math.PI * 2;
  1726. }
  1727. }
  1728. let value = value2 + ((value1 - value2) * amount);
  1729. if (value >= 0 && value <= Math.PI * 2) return value;
  1730. return value % (Math.PI * 2);
  1731. };
  1732.  
  1733. // REOUNDED RECTANGLE:
  1734. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1735. if (w < 2 * r) r = w / 2;
  1736. if (h < 2 * r) r = h / 2;
  1737. if (r < 0)
  1738. r = 0;
  1739. this.beginPath();
  1740. this.moveTo(x + r, y);
  1741. this.arcTo(x + w, y, x + w, y + h, r);
  1742. this.arcTo(x + w, y + h, x, y + h, r);
  1743. this.arcTo(x, y + h, x, y, r);
  1744. this.arcTo(x, y, x + w, y, r);
  1745. this.closePath();
  1746. return this;
  1747. };
  1748.  
  1749. // GLOBAL VALUES:
  1750. function resetMoveDir() {
  1751. keys = {};
  1752. io.send("e");
  1753. }
  1754.  
  1755. let allChats = [];
  1756. let ticks = {
  1757. tick: 0,
  1758. delay: 0,
  1759. time: [],
  1760. manage: [],
  1761. };
  1762. let ais = [];
  1763. let players = [];
  1764. let alliances = [];
  1765. let alliancePlayers = [];
  1766. let allianceNotifications = [];
  1767. let gameObjects = [];
  1768. let liztobj = [];
  1769. let projectiles = [];
  1770. let deadPlayers = [];
  1771.  
  1772. let breakObjects = [];
  1773.  
  1774. let player;
  1775. let playerSID;
  1776. let tmpObj;
  1777.  
  1778. let enemy = [];
  1779. let nears = [];
  1780. let near = [];
  1781.  
  1782. let my = {
  1783. reloaded: false,
  1784. waitHit: 0,
  1785. autoAim: false,
  1786. revAim: false,
  1787. ageInsta: true,
  1788. reSync: false,
  1789. bullTick: 0,
  1790. anti0Tick: 0,
  1791. antiSync: false,
  1792. safePrimary: function(tmpObj) {
  1793. return [0, 8].includes(tmpObj.primaryIndex);
  1794. },
  1795. safeSecondary: function(tmpObj) {
  1796. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1797. },
  1798. lastDir: 0,
  1799. autoPush: false,
  1800. pushData: {}
  1801. }
  1802.  
  1803. // FIND OBJECTS BY ID/SID:
  1804. function findID(tmpObj, tmp) {
  1805. return tmpObj.find((THIS) => THIS.id == tmp);
  1806. }
  1807.  
  1808. function findSID(tmpObj, tmp) {
  1809. return tmpObj.find((THIS) => THIS.sid == tmp);
  1810. }
  1811.  
  1812. function findPlayerByID(id) {
  1813. return findID(players, id);
  1814. }
  1815.  
  1816. function findPlayerBySID(sid) {
  1817. return findSID(players, sid);
  1818. }
  1819.  
  1820. function findAIBySID(sid) {
  1821. return findSID(ais, sid);
  1822. }
  1823.  
  1824. function findObjectBySid(sid) {
  1825. return findSID(gameObjects, sid);
  1826. }
  1827.  
  1828. function findProjectileBySid(sid) {
  1829. return findSID(gameObjects, sid);
  1830. }
  1831.  
  1832. let gameName = getEl("gameName");
  1833. gameName.innerText = "!!";
  1834. let adCard = getEl("adCard");
  1835. adCard.remove();
  1836. let promoImageHolder = getEl("promoImgHolder");
  1837. promoImageHolder.remove();
  1838.  
  1839. let chatButton = getEl("chatButton");
  1840. chatButton.remove();
  1841. let gameCanvas = getEl("gameCanvas");
  1842. let mainContext = gameCanvas.getContext("2d");
  1843. let mapDisplay = getEl("mapDisplay");
  1844. let mapContext = mapDisplay.getContext("2d");
  1845. mapDisplay.width = 300;
  1846. mapDisplay.height = 300;
  1847. let storeMenu = getEl("storeMenu");
  1848. let storeHolder = getEl("storeHolder");
  1849. let upgradeHolder = getEl("upgradeHolder");
  1850. let upgradeCounter = getEl("upgradeCounter");
  1851. let chatBox = getEl("chatBox");
  1852. chatBox.autocomplete = "off";
  1853. chatBox.style.textAlign = "center";
  1854. chatBox.style.width = "18em";
  1855. let chatHolder = getEl("chatHolder");
  1856. let actionBar = getEl("actionBar");
  1857. let leaderboardData = getEl("leaderboardData");
  1858. let itemInfoHolder = getEl("itemInfoHolder");
  1859. let menuCardHolder = getEl("menuCardHolder");
  1860. let mainMenu = getEl("mainMenu");
  1861. getEl("mainMenu").style.backgroundImage = "url('https://static3.srcdn.com/wordpress/wp-content/uploads/2021/01/Fullmetal-Alchemist-Brotherhood.jpg')";
  1862. let diedText = getEl("diedText");
  1863. let screenWidth;
  1864. let screenHeight;
  1865. let maxScreenWidth = config.maxScreenWidth;
  1866. let maxScreenHeight = config.maxScreenHeight;
  1867. let pixelDensity = 1;
  1868. let delta;
  1869. let now;
  1870. let lastUpdate = performance.now();
  1871. let camX;
  1872. let camY;
  1873. let tmpDir;
  1874. let mouseX = 0;
  1875. let mouseY = 0;
  1876. let allianceMenu = getEl("allianceMenu");
  1877. let waterMult = 1;
  1878. let waterPlus = 0;
  1879.  
  1880. let outlineColor = "#525252";
  1881. let darkOutlineColor = "#3d3f42";
  1882. let outlineWidth = 5.5;
  1883.  
  1884. let firstSetup = true;
  1885. let keys = {};
  1886. let moveKeys = {
  1887. 87: [0, -1],
  1888. 38: [0, -1],
  1889. 83: [0, 1],
  1890. 40: [0, 1],
  1891. 65: [-1, 0],
  1892. 37: [-1, 0],
  1893. 68: [1, 0],
  1894. 39: [1, 0],
  1895. };
  1896. let attackState = 0;
  1897. let inGame = false;
  1898.  
  1899. let macro = {};
  1900. let mills = {
  1901. place: 0,
  1902. placeSpawnPads: 0
  1903. };
  1904. let lastDir;
  1905.  
  1906. let lastLeaderboardData = [];
  1907.  
  1908. // ON LOAD:
  1909. let inWindow = true;
  1910. window.onblur = function() {
  1911. inWindow = false;
  1912. };
  1913. window.onfocus = function() {
  1914. inWindow = true;
  1915. if (player && player.alive) {
  1916. // resetMoveDir();
  1917. }
  1918. };
  1919. let ms = {
  1920. avg: 0,
  1921. max: 0,
  1922. min: 0,
  1923. delay: 0
  1924. }
  1925. function pingSocketResponse() {
  1926. let pingTime = window.pingTime;
  1927. const pingDisplay = document.getElementById("pingDisplay")
  1928. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1929. if (pingTime > ms.max || isNaN(ms.max)) {
  1930. ms.max = pingTime;
  1931. }
  1932. if (pingTime < ms.min || isNaN(ms.min)) {
  1933. ms.min = pingTime;
  1934. }
  1935.  
  1936. // if (pingTime >= 90) {
  1937. // doAutoQ = true;
  1938. // } else {
  1939. // doAutoQ = false;
  1940. // }
  1941. }
  1942.  
  1943. let placeVisible = [];
  1944.  
  1945. /** CLASS CODES */
  1946.  
  1947.  
  1948. class Utils {
  1949. constructor() {
  1950.  
  1951. // MATH UTILS:
  1952. let mathABS = Math.abs,
  1953. mathCOS = Math.cos,
  1954. mathSIN = Math.sin,
  1955. mathPOW = Math.pow,
  1956. mathSQRT = Math.sqrt,
  1957. mathATAN2 = Math.atan2,
  1958. mathPI = Math.PI;
  1959.  
  1960. let _this = this;
  1961.  
  1962. // GLOBAL UTILS:
  1963. this.round = function(n, v) {
  1964. return Math.round(n * v) / v;
  1965. };
  1966. this.toRad = function(angle) {
  1967. return angle * (mathPI / 180);
  1968. };
  1969. this.toAng = function(radian) {
  1970. return radian / (mathPI / 180);
  1971. };
  1972. this.randInt = function(min, max) {
  1973. return Math.floor(Math.random() * (max - min + 1)) + min;
  1974. };
  1975. this.randFloat = function(min, max) {
  1976. return Math.random() * (max - min + 1) + min;
  1977. };
  1978. this.lerp = function(value1, value2, amount) {
  1979. return value1 + (value2 - value1) * amount;
  1980. };
  1981. this.decel = function(val, cel) {
  1982. if (val > 0)
  1983. val = Math.max(0, val - cel);
  1984. else if (val < 0)
  1985. val = Math.min(0, val + cel);
  1986. return val;
  1987. };
  1988. this.getDistance = function(x1, y1, x2, y2) {
  1989. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1990. };
  1991. this.getDist = function(tmp1, tmp2, type1, type2) {
  1992. let tmpXY1 = {
  1993. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1994. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1995. };
  1996. let tmpXY2 = {
  1997. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1998. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1999. };
  2000. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  2001. };
  2002. this.getDirection = function(x1, y1, x2, y2) {
  2003. return mathATAN2(y1 - y2, x1 - x2);
  2004. };
  2005. this.getDirect = function(tmp1, tmp2, type1, type2) {
  2006. let tmpXY1 = {
  2007. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  2008. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  2009. };
  2010. let tmpXY2 = {
  2011. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  2012. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  2013. };
  2014. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  2015. };
  2016. this.getAngleDist = function(a, b) {
  2017. let p = mathABS(b - a) % (mathPI * 2);
  2018. return (p > mathPI ? (mathPI * 2) - p : p);
  2019. };
  2020. this.isNumber = function(n) {
  2021. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  2022. };
  2023. this.isString = function(s) {
  2024. return (s && typeof s == "string");
  2025. };
  2026. this.kFormat = function(num) {
  2027. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  2028. };
  2029. this.sFormat = function(num) {
  2030. let fixs = [{
  2031. num: 1e3,
  2032. string: "k"
  2033. },
  2034. {
  2035. num: 1e6,
  2036. string: "m"
  2037. },
  2038. {
  2039. num: 1e9,
  2040. string: "b"
  2041. },
  2042. {
  2043. num: 1e12,
  2044. string: "q"
  2045. }
  2046. ].reverse();
  2047. let sp = fixs.find(v => num >= v.num);
  2048. if (!sp) return num;
  2049. return (num / sp.num).toFixed(1) + sp.string;
  2050. };
  2051. this.capitalizeFirst = function(string) {
  2052. return string.charAt(0).toUpperCase() + string.slice(1);
  2053. };
  2054. this.fixTo = function(n, v) {
  2055. return parseFloat(n.toFixed(v));
  2056. };
  2057. this.sortByPoints = function(a, b) {
  2058. return parseFloat(b.points) - parseFloat(a.points);
  2059. };
  2060. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  2061. let minX = x1;
  2062. let maxX = x2;
  2063. if (x1 > x2) {
  2064. minX = x2;
  2065. maxX = x1;
  2066. }
  2067. if (maxX > recX2)
  2068. maxX = recX2;
  2069. if (minX < recX)
  2070. minX = recX;
  2071. if (minX > maxX)
  2072. return false;
  2073. let minY = y1;
  2074. let maxY = y2;
  2075. let dx = x2 - x1;
  2076. if (Math.abs(dx) > 0.0000001) {
  2077. let a = (y2 - y1) / dx;
  2078. let b = y1 - a * x1;
  2079. minY = a * minX + b;
  2080. maxY = a * maxX + b;
  2081. }
  2082. if (minY > maxY) {
  2083. let tmp = maxY;
  2084. maxY = minY;
  2085. minY = tmp;
  2086. }
  2087. if (maxY > recY2)
  2088. maxY = recY2;
  2089. if (minY < recY)
  2090. minY = recY;
  2091. if (minY > maxY)
  2092. return false;
  2093. return true;
  2094. };
  2095. this.containsPoint = function(element, x, y) {
  2096. let bounds = element.getBoundingClientRect();
  2097. let left = bounds.left + window.scrollX;
  2098. let top = bounds.top + window.scrollY;
  2099. let width = bounds.width;
  2100. let height = bounds.height;
  2101.  
  2102. let insideHorizontal = x > left && x < left + width;
  2103. let insideVertical = y > top && y < top + height;
  2104. return insideHorizontal && insideVertical;
  2105. };
  2106. this.mousifyTouchEvent = function(event) {
  2107. let touch = event.changedTouches[0];
  2108. event.screenX = touch.screenX;
  2109. event.screenY = touch.screenY;
  2110. event.clientX = touch.clientX;
  2111. event.clientY = touch.clientY;
  2112. event.pageX = touch.pageX;
  2113. event.pageY = touch.pageY;
  2114. };
  2115. this.hookTouchEvents = function(element, skipPrevent) {
  2116. let preventDefault = !skipPrevent;
  2117. let isHovering = false;
  2118. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  2119. let passive = false;
  2120. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  2121. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  2122. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  2123. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  2124. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  2125.  
  2126. function touchStart(e) {
  2127. _this.mousifyTouchEvent(e);
  2128. window.setUsingTouch(true);
  2129. if (preventDefault) {
  2130. e.preventDefault();
  2131. e.stopPropagation();
  2132. }
  2133. if (element.onmouseover)
  2134. element.onmouseover(e);
  2135. isHovering = true;
  2136. }
  2137.  
  2138. function touchMove(e) {
  2139. _this.mousifyTouchEvent(e);
  2140. window.setUsingTouch(true);
  2141. if (preventDefault) {
  2142. e.preventDefault();
  2143. e.stopPropagation();
  2144. }
  2145. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  2146. if (!isHovering) {
  2147. if (element.onmouseover)
  2148. element.onmouseover(e);
  2149. isHovering = true;
  2150. }
  2151. } else {
  2152. if (isHovering) {
  2153. if (element.onmouseout)
  2154. element.onmouseout(e);
  2155. isHovering = false;
  2156. }
  2157. }
  2158. }
  2159.  
  2160. function touchEnd(e) {
  2161. _this.mousifyTouchEvent(e);
  2162. window.setUsingTouch(true);
  2163. if (preventDefault) {
  2164. e.preventDefault();
  2165. e.stopPropagation();
  2166. }
  2167. if (isHovering) {
  2168. if (element.onclick)
  2169. element.onclick(e);
  2170. if (element.onmouseout)
  2171. element.onmouseout(e);
  2172. isHovering = false;
  2173. }
  2174. }
  2175. };
  2176. this.removeAllChildren = function(element) {
  2177. while (element.hasChildNodes()) {
  2178. element.removeChild(element.lastChild);
  2179. }
  2180. };
  2181. this.generateElement = function(config) {
  2182. let element = document.createElement(config.tag || "div");
  2183.  
  2184. function bind(configValue, elementValue) {
  2185. if (config[configValue])
  2186. element[elementValue] = config[configValue];
  2187. }
  2188. bind("text", "textContent");
  2189. bind("html", "innerHTML");
  2190. bind("class", "className");
  2191. for (let key in config) {
  2192. switch (key) {
  2193. case "tag":
  2194. case "text":
  2195. case "html":
  2196. case "class":
  2197. case "style":
  2198. case "hookTouch":
  2199. case "parent":
  2200. case "children":
  2201. continue;
  2202. default:
  2203. break;
  2204. }
  2205. element[key] = config[key];
  2206. }
  2207. if (element.onclick)
  2208. element.onclick = this.checkTrusted(element.onclick);
  2209. if (element.onmouseover)
  2210. element.onmouseover = this.checkTrusted(element.onmouseover);
  2211. if (element.onmouseout)
  2212. element.onmouseout = this.checkTrusted(element.onmouseout);
  2213. if (config.style) {
  2214. element.style.cssText = config.style;
  2215. }
  2216. if (config.hookTouch) {
  2217. this.hookTouchEvents(element);
  2218. }
  2219. if (config.parent) {
  2220. config.parent.appendChild(element);
  2221. }
  2222. if (config.children) {
  2223. for (let i = 0; i < config.children.length; i++) {
  2224. element.appendChild(config.children[i]);
  2225. }
  2226. }
  2227. return element;
  2228. };
  2229. this.checkTrusted = function(callback) {
  2230. return function(ev) {
  2231. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2232. callback(ev);
  2233. } else {
  2234. //console.error("Event is not trusted.", ev);
  2235. }
  2236. };
  2237. };
  2238. this.randomString = function(length) {
  2239. let text = "";
  2240. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2241. for (let i = 0; i < length; i++) {
  2242. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2243. }
  2244. return text;
  2245. };
  2246. this.countInArray = function(array, val) {
  2247. let count = 0;
  2248. for (let i = 0; i < array.length; i++) {
  2249. if (array[i] === val) count++;
  2250. }
  2251. return count;
  2252. };
  2253. this.hexToRgb = function(hex) {
  2254. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2255. };
  2256. this.getRgb = function(r, g, b) {
  2257. return [r / 255, g / 255, b / 255].join(", ");
  2258. };
  2259. }
  2260. };
  2261. class Animtext {
  2262. // ANIMATED TEXT:
  2263. constructor() {
  2264. // INIT:
  2265. this.init = function(x, y, scale, speed, life, text, color) {
  2266. (this.x = x),
  2267. (this.y = y),
  2268. (this.color = color),
  2269. (this.scale = scale*3.5),
  2270. (this.weight = 50);
  2271. (this.startScale = this.scale * 1.2),
  2272. (this.maxScale = 1.5 * scale),
  2273. (this.minScale = 0.5 * scale),
  2274. (this.scaleSpeed = 0.7),
  2275. (this.speed = speed),
  2276. (this.speedMax = speed),
  2277. (this.life = life),
  2278. (this.maxLife = life),
  2279. (this.text = text),
  2280. this.movSpeed = speed;
  2281. };
  2282.  
  2283. // UPDATE:
  2284. this.update = function(delta) {
  2285. if(this.life){
  2286. this.life -= delta;
  2287. if(this.scaleSpeed != -0.35){
  2288. this.y -= this.speed * delta;
  2289. // (this.x += this.speed * delta);
  2290. } else {
  2291. this.y -= this.speed * delta;
  2292. }
  2293. this.scale -= .8;
  2294. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2295. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2296. if(this.scale >= this.maxScale){
  2297. this.scale = this.maxScale;
  2298. this.scaleSpeed *= -.5;
  2299. this.speed = this.speed * .75;
  2300. };
  2301. this.life <= 0 && (this.life = 0)
  2302. };
  2303. };
  2304.  
  2305. // RENDER:
  2306. this.render = function(ctxt, xOff, yOff) {
  2307. ctxt.lineWidth = 10;
  2308. ctxt.strokeStyle = darkOutlineColor; //"black";
  2309. ctxt.fillStyle = this.color;
  2310. ctxt.globalAlpha = 1;
  2311. ctxt.font = this.scale + "px HammerSmith One";
  2312. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2313. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2314. ctxt.globalAlpha = 1;
  2315. };
  2316. }
  2317. };
  2318. class Textmanager {
  2319. // TEXT MANAGER:
  2320. constructor() {
  2321. this.texts = [];
  2322. this.stack = [];
  2323.  
  2324. // UPDATE:
  2325. this.update = function(delta, ctxt, xOff, yOff) {
  2326. ctxt.textBaseline = "middle";
  2327. ctxt.textAlign = "center";
  2328. for (let i = 0; i < this.texts.length; ++i) {
  2329. if (this.texts[i].life) {
  2330. this.texts[i].update(delta);
  2331. this.texts[i].render(ctxt, xOff, yOff);
  2332. }
  2333. }
  2334. };
  2335.  
  2336. // SHOW TEXT:
  2337. this.showText = function(x, y, scale, speed, life, text, color) {
  2338. let tmpText;
  2339. for (let i = 0; i < this.texts.length; ++i) {
  2340. if (!this.texts[i].life) {
  2341. tmpText = this.texts[i];
  2342. break;
  2343. }
  2344. }
  2345. if (!tmpText) {
  2346. tmpText = new Animtext();
  2347. this.texts.push(tmpText);
  2348. }
  2349. tmpText.init(x, y, scale, speed, life, text, color);
  2350. };
  2351. }
  2352. }
  2353.  
  2354. class GameObject {
  2355. constructor(sid) {
  2356. this.sid = sid;
  2357.  
  2358. // INIT:
  2359. this.init = function(x, y, dir, scale, type, data, owner) {
  2360. data = data || {};
  2361. this.sentTo = {};
  2362. this.gridLocations = [];
  2363. this.active = true;
  2364. this.render = true;
  2365. this.doUpdate = data.doUpdate;
  2366. this.x = x;
  2367. this.y = y;
  2368. this.dir = dir;
  2369. this.lastDir = dir;
  2370. this.xWiggle = 0;
  2371. this.yWiggle = 0;
  2372. this.visScale = scale;
  2373. this.scale = scale;
  2374. this.type = type;
  2375. this.id = data.id;
  2376. this.owner = owner;
  2377. this.name = data.name;
  2378. this.isItem = (this.id != undefined);
  2379. this.group = data.group;
  2380. this.maxHealth = data.health;
  2381. this.health = this.maxHealth;
  2382. this.layer = 2;
  2383. if (this.group != undefined) {
  2384. this.layer = this.group.layer;
  2385. } else if (this.type == 0) {
  2386. this.layer = 3;
  2387. } else if (this.type == 2) {
  2388. this.layer = 0;
  2389. } else if (this.type == 4) {
  2390. this.layer = -1;
  2391. }
  2392. this.colDiv = data.colDiv || 1;
  2393. this.blocker = data.blocker;
  2394. this.ignoreCollision = data.ignoreCollision;
  2395. this.dontGather = data.dontGather;
  2396. this.hideFromEnemy = data.hideFromEnemy;
  2397. this.friction = data.friction;
  2398. this.projDmg = data.projDmg;
  2399. this.dmg = data.dmg;
  2400. this.pDmg = data.pDmg;
  2401. this.pps = data.pps;
  2402. this.zIndex = data.zIndex || 0;
  2403. this.turnSpeed = data.turnSpeed;
  2404. this.req = data.req;
  2405. this.trap = data.trap;
  2406. this.healCol = data.healCol;
  2407. this.teleport = data.teleport;
  2408. this.boostSpeed = data.boostSpeed;
  2409. this.projectile = data.projectile;
  2410. this.shootRange = data.shootRange;
  2411. this.shootRate = data.shootRate;
  2412. this.shootCount = this.shootRate;
  2413. this.spawnPoint = data.spawnPoint;
  2414. this.onNear = 0;
  2415. this.breakObj = false;
  2416. this.alpha = data.alpha || 1;
  2417. this.maxAlpha = data.alpha || 1;
  2418. this.damaged = 0;
  2419. };
  2420.  
  2421. // GET HIT:
  2422. this.changeHealth = function(amount, doer) {
  2423. this.health += amount;
  2424. return (this.health <= 0);
  2425. };
  2426.  
  2427. // GET SCALE:
  2428. this.getScale = function(sM, ig) {
  2429. sM = sM || 1;
  2430. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2431. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2432. };
  2433.  
  2434. // VISIBLE TO PLAYER:
  2435. this.visibleToPlayer = function(player) {
  2436. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2437. (this.owner.team && player.team == this.owner.team)));
  2438. };
  2439.  
  2440. // UPDATE:
  2441. this.update = function(delta) {
  2442. if (this.active) {
  2443. if (this.xWiggle) {
  2444. this.xWiggle *= Math.pow(0.99, delta);
  2445. }
  2446. if (this.yWiggle) {
  2447. this.yWiggle *= Math.pow(0.99, delta);
  2448. }
  2449. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2450. if (d2 > 0.01) {
  2451. this.dir += d2 / 5;
  2452. } else {
  2453. this.dir = this.lastDir;
  2454. }
  2455. } else {
  2456. if (this.alive) {
  2457. this.alpha -= delta / (200 / this.maxAlpha);
  2458. this.visScale += delta / (this.scale / 2.5);
  2459. if (this.alpha <= 0) {
  2460. this.alpha = 0;
  2461. this.alive = false;
  2462. }
  2463. }
  2464. }
  2465. };
  2466.  
  2467. // CHECK TEAM:
  2468. this.isTeamObject = function(tmpObj) {
  2469. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2470. };
  2471. }
  2472. }
  2473. class Items {
  2474. constructor() {
  2475. // ITEM GROUPS:
  2476. this.groups = [{
  2477. id: 0,
  2478. name: "food",
  2479. layer: 0
  2480. }, {
  2481. id: 1,
  2482. name: "walls",
  2483. place: true,
  2484. limit: 30,
  2485. layer: 0
  2486. }, {
  2487. id: 2,
  2488. name: "spikes",
  2489. place: true,
  2490. limit: 15,
  2491. layer: 0
  2492. }, {
  2493. id: 3,
  2494. name: "mill",
  2495. place: true,
  2496. limit: 7,
  2497. layer: 1
  2498. }, {
  2499. id: 4,
  2500. name: "mine",
  2501. place: true,
  2502. limit: 1,
  2503. layer: 0
  2504. }, {
  2505. id: 5,
  2506. name: "trap",
  2507. place: true,
  2508. limit: 6,
  2509. layer: -1
  2510. }, {
  2511. id: 6,
  2512. name: "booster",
  2513. place: true,
  2514. limit: 12,
  2515. layer: -1
  2516. }, {
  2517. id: 7,
  2518. name: "turret",
  2519. place: true,
  2520. limit: 2,
  2521. layer: 1
  2522. }, {
  2523. id: 8,
  2524. name: "watchtower",
  2525. place: true,
  2526. limit: 12,
  2527. layer: 1
  2528. }, {
  2529. id: 9,
  2530. name: "buff",
  2531. place: true,
  2532. limit: 4,
  2533. layer: -1
  2534. }, {
  2535. id: 10,
  2536. name: "spawn",
  2537. place: true,
  2538. limit: 1,
  2539. layer: -1
  2540. }, {
  2541. id: 11,
  2542. name: "sapling",
  2543. place: true,
  2544. limit: 2,
  2545. layer: 0
  2546. }, {
  2547. id: 12,
  2548. name: "blocker",
  2549. place: true,
  2550. limit: 3,
  2551. layer: -1
  2552. }, {
  2553. id: 13,
  2554. name: "teleporter",
  2555. place: true,
  2556. limit: 2,
  2557. layer: -1
  2558. }];
  2559.  
  2560. // PROJECTILES:
  2561. this.projectiles = [{
  2562. indx: 0,
  2563. layer: 0,
  2564. src: "arrow_1",
  2565. dmg: 25,
  2566. speed: 1.6,
  2567. scale: 103,
  2568. range: 1000
  2569. }, {
  2570. indx: 1,
  2571. layer: 1,
  2572. dmg: 25,
  2573. scale: 20
  2574. }, {
  2575. indx: 0,
  2576. layer: 0,
  2577. src: "arrow_1",
  2578. dmg: 35,
  2579. speed: 2.5,
  2580. scale: 103,
  2581. range: 1200
  2582. }, {
  2583. indx: 0,
  2584. layer: 0,
  2585. src: "arrow_1",
  2586. dmg: 30,
  2587. speed: 2,
  2588. scale: 103,
  2589. range: 1200
  2590. }, {
  2591. indx: 1,
  2592. layer: 1,
  2593. dmg: 16,
  2594. scale: 20
  2595. }, {
  2596. indx: 0,
  2597. layer: 0,
  2598. src: "bullet_1",
  2599. dmg: 50,
  2600. speed: 3.6,
  2601. scale: 160,
  2602. range: 1400
  2603. }];
  2604.  
  2605. // WEAPONS:
  2606. this.weapons = [{
  2607. id: 0,
  2608. type: 0,
  2609. name: "tool hammer",
  2610. desc: "tool for gathering all resources",
  2611. src: "hammer_1",
  2612. length: 140,
  2613. width: 140,
  2614. xOff: -3,
  2615. yOff: 18,
  2616. dmg: 25,
  2617. range: 65,
  2618. gather: 1,
  2619. speed: 300
  2620. }, {
  2621. id: 1,
  2622. type: 0,
  2623. age: 2,
  2624. name: "hand axe",
  2625. desc: "gathers resources at a higher rate",
  2626. src: "axe_1",
  2627. length: 140,
  2628. width: 140,
  2629. xOff: 3,
  2630. yOff: 24,
  2631. dmg: 30,
  2632. spdMult: 1,
  2633. range: 70,
  2634. gather: 2,
  2635. speed: 400
  2636. }, {
  2637. id: 2,
  2638. type: 0,
  2639. age: 8,
  2640. pre: 1,
  2641. name: "great axe",
  2642. desc: "deal more damage and gather more resources",
  2643. src: "great_axe_1",
  2644. length: 140,
  2645. width: 140,
  2646. xOff: -8,
  2647. yOff: 25,
  2648. dmg: 35,
  2649. spdMult: 1,
  2650. range: 75,
  2651. gather: 4,
  2652. speed: 400
  2653. }, {
  2654. id: 3,
  2655. type: 0,
  2656. age: 2,
  2657. name: "short sword",
  2658. desc: "increased attack power but slower move speed",
  2659. src: "sword_1",
  2660. iPad: 1.3,
  2661. length: 130,
  2662. width: 210,
  2663. xOff: -8,
  2664. yOff: 46,
  2665. dmg: 35,
  2666. spdMult: 0.85,
  2667. range: 110,
  2668. gather: 1,
  2669. speed: 300
  2670. }, {
  2671. id: 4,
  2672. type: 0,
  2673. age: 8,
  2674. pre: 3,
  2675. name: "katana",
  2676. desc: "greater range and damage",
  2677. src: "samurai_1",
  2678. iPad: 1.3,
  2679. length: 130,
  2680. width: 210,
  2681. xOff: -8,
  2682. yOff: 59,
  2683. dmg: 40,
  2684. spdMult: 0.8,
  2685. range: 118,
  2686. gather: 1,
  2687. speed: 300
  2688. }, {
  2689. id: 5,
  2690. type: 0,
  2691. age: 2,
  2692. name: "polearm",
  2693. desc: "long range melee weapon",
  2694. src: "spear_1",
  2695. iPad: 1.3,
  2696. length: 130,
  2697. width: 210,
  2698. xOff: -8,
  2699. yOff: 53,
  2700. dmg: 45,
  2701. knock: 0.2,
  2702. spdMult: 0.82,
  2703. range: 142,
  2704. gather: 1,
  2705. speed: 700
  2706. }, {
  2707. id: 6,
  2708. type: 0,
  2709. age: 2,
  2710. name: "bat",
  2711. desc: "fast long range melee weapon",
  2712. src: "bat_1",
  2713. iPad: 1.3,
  2714. length: 110,
  2715. width: 180,
  2716. xOff: -8,
  2717. yOff: 53,
  2718. dmg: 20,
  2719. knock: 0.7,
  2720. range: 110,
  2721. gather: 1,
  2722. speed: 300
  2723. }, {
  2724. id: 7,
  2725. type: 0,
  2726. age: 2,
  2727. name: "daggers",
  2728. desc: "really fast short range weapon",
  2729. src: "dagger_1",
  2730. iPad: 0.8,
  2731. length: 110,
  2732. width: 110,
  2733. xOff: 18,
  2734. yOff: 0,
  2735. dmg: 20,
  2736. knock: 0.1,
  2737. range: 65,
  2738. gather: 1,
  2739. hitSlow: 0.1,
  2740. spdMult: 1.13,
  2741. speed: 100
  2742. }, {
  2743. id: 8,
  2744. type: 0,
  2745. age: 2,
  2746. name: "stick",
  2747. desc: "great for gathering but very weak",
  2748. src: "stick_1",
  2749. length: 140,
  2750. width: 140,
  2751. xOff: 3,
  2752. yOff: 24,
  2753. dmg: 1,
  2754. spdMult: 1,
  2755. range: 70,
  2756. gather: 7,
  2757. speed: 400
  2758. }, {
  2759. id: 9,
  2760. type: 1,
  2761. age: 6,
  2762. name: "hunting bow",
  2763. desc: "bow used for ranged combat and hunting",
  2764. src: "bow_1",
  2765. req: ["wood", 4],
  2766. length: 120,
  2767. width: 120,
  2768. xOff: -6,
  2769. yOff: 0,
  2770. Pdmg: 25,
  2771. projectile: 0,
  2772. spdMult: 0.75,
  2773. speed: 600
  2774. }, {
  2775. id: 10,
  2776. type: 1,
  2777. age: 6,
  2778. name: "great hammer",
  2779. desc: "hammer used for destroying structures",
  2780. src: "great_hammer_1",
  2781. length: 140,
  2782. width: 140,
  2783. xOff: -9,
  2784. yOff: 25,
  2785. dmg: 10,
  2786. Pdmg: 10,
  2787. spdMult: 0.88,
  2788. range: 75,
  2789. sDmg: 7.5,
  2790. gather: 1,
  2791. speed: 400
  2792. }, {
  2793. id: 11,
  2794. type: 1,
  2795. age: 6,
  2796. name: "wooden shield",
  2797. desc: "blocks projectiles and reduces melee damage",
  2798. src: "shield_1",
  2799. length: 120,
  2800. width: 120,
  2801. shield: 0.2,
  2802. xOff: 6,
  2803. yOff: 0,
  2804. Pdmg: 0,
  2805. spdMult: 0.7
  2806. }, {
  2807. id: 12,
  2808. type: 1,
  2809. age: 8,
  2810. pre: 9,
  2811. name: "crossbow",
  2812. desc: "deals more damage and has greater range",
  2813. src: "crossbow_1",
  2814. req: ["wood", 5],
  2815. aboveHand: true,
  2816. armS: 0.75,
  2817. length: 120,
  2818. width: 120,
  2819. xOff: -4,
  2820. yOff: 0,
  2821. Pdmg: 35,
  2822. projectile: 2,
  2823. spdMult: 0.7,
  2824. speed: 700
  2825. }, {
  2826. id: 13,
  2827. type: 1,
  2828. age: 9,
  2829. pre: 12,
  2830. name: "repeater crossbow",
  2831. desc: "high firerate crossbow with reduced damage",
  2832. src: "crossbow_2",
  2833. req: ["wood", 10],
  2834. aboveHand: true,
  2835. armS: 0.75,
  2836. length: 120,
  2837. width: 120,
  2838. xOff: -4,
  2839. yOff: 0,
  2840. Pdmg: 30,
  2841. projectile: 3,
  2842. spdMult: 0.7,
  2843. speed: 230
  2844. }, {
  2845. id: 14,
  2846. type: 1,
  2847. age: 6,
  2848. name: "mc grabby",
  2849. desc: "steals resources from enemies",
  2850. src: "grab_1",
  2851. length: 130,
  2852. width: 210,
  2853. xOff: -8,
  2854. yOff: 53,
  2855. dmg: 0,
  2856. Pdmg: 0,
  2857. steal: 250,
  2858. knock: 0.2,
  2859. spdMult: 1.05,
  2860. range: 125,
  2861. gather: 0,
  2862. speed: 700
  2863. }, {
  2864. id: 15,
  2865. type: 1,
  2866. age: 9,
  2867. pre: 12,
  2868. name: "musket",
  2869. desc: "slow firerate but high damage and range",
  2870. src: "musket_1",
  2871. req: ["stone", 10],
  2872. aboveHand: true,
  2873. rec: 0.35,
  2874. armS: 0.6,
  2875. hndS: 0.3,
  2876. hndD: 1.6,
  2877. length: 205,
  2878. width: 205,
  2879. xOff: 25,
  2880. yOff: 0,
  2881. Pdmg: 50,
  2882. projectile: 5,
  2883. hideProjectile: true,
  2884. spdMult: 0.6,
  2885. speed: 1500
  2886. }];
  2887.  
  2888. // ITEMS:
  2889. this.list = [{
  2890. group: this.groups[0],
  2891. name: "apple",
  2892. desc: "restores 20 health when consumed",
  2893. req: ["food", 10],
  2894. consume: function(doer) {
  2895. return doer.changeHealth(20, doer);
  2896. },
  2897. scale: 22,
  2898. holdOffset: 15,
  2899. healing: 20,
  2900. itemID: 0,
  2901. itemAID: 16,
  2902. }, {
  2903. age: 3,
  2904. group: this.groups[0],
  2905. name: "cookie",
  2906. desc: "restores 40 health when consumed",
  2907. req: ["food", 15],
  2908. consume: function(doer) {
  2909. return doer.changeHealth(40, doer);
  2910. },
  2911. scale: 27,
  2912. holdOffset: 15,
  2913. healing: 40,
  2914. itemID: 1,
  2915. itemAID: 17,
  2916. }, {
  2917. age: 7,
  2918. group: this.groups[0],
  2919. name: "cheese",
  2920. desc: "restores 30 health and another 50 over 5 seconds",
  2921. req: ["food", 25],
  2922. consume: function(doer) {
  2923. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2924. doer.dmgOverTime.dmg = -10;
  2925. doer.dmgOverTime.doer = doer;
  2926. doer.dmgOverTime.time = 5;
  2927. return true;
  2928. }
  2929. return false;
  2930. },
  2931. scale: 27,
  2932. holdOffset: 15,
  2933. healing: 30,
  2934. itemID: 2,
  2935. itemAID: 18,
  2936. }, {
  2937. group: this.groups[1],
  2938. name: "wood wall",
  2939. desc: "provides protection for your village",
  2940. req: ["wood", 10],
  2941. projDmg: true,
  2942. health: 380,
  2943. scale: 50,
  2944. holdOffset: 20,
  2945. placeOffset: -5,
  2946. itemID: 3,
  2947. itemAID: 19,
  2948. }, {
  2949. age: 3,
  2950. group: this.groups[1],
  2951. name: "stone wall",
  2952. desc: "provides improved protection for your village",
  2953. req: ["stone", 25],
  2954. health: 900,
  2955. scale: 50,
  2956. holdOffset: 20,
  2957. placeOffset: -5,
  2958. itemID: 4,
  2959. itemAID: 20,
  2960. }, {
  2961. age: 7,
  2962. group: this.groups[1],
  2963. name: "castle wall",
  2964. desc: "provides powerful protection for your village",
  2965. req: ["stone", 35],
  2966. health: 1500,
  2967. scale: 52,
  2968. holdOffset: 20,
  2969. placeOffset: -5,
  2970. itemID: 5,
  2971. itemAID: 21,
  2972. }, {
  2973. group: this.groups[2],
  2974. name: "spikes",
  2975. desc: "damages enemies when they touch them",
  2976. req: ["wood", 20, "stone", 5],
  2977. health: 400,
  2978. dmg: 20,
  2979. scale: 49,
  2980. spritePadding: -23,
  2981. holdOffset: 8,
  2982. placeOffset: -5,
  2983. itemID: 6,
  2984. itemAID: 22,
  2985. shadow: {
  2986. offsetX: 5, // Adjust the shadow's X offset as needed
  2987. offsetY: 5, // Adjust the shadow's Y offset as needed
  2988. blur: 20, // Adjust the shadow's blur as needed
  2989. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2990. }
  2991.  
  2992. }, {
  2993. age: 5,
  2994. group: this.groups[2],
  2995. name: "greater spikes",
  2996. desc: "damages enemies when they touch them",
  2997. req: ["wood", 30, "stone", 10],
  2998. health: 500,
  2999. dmg: 35,
  3000. scale: 52,
  3001. spritePadding: -23,
  3002. holdOffset: 8,
  3003. placeOffset: -5,
  3004. itemID: 7,
  3005. itemAID: 23,
  3006. }, {
  3007. age: 9,
  3008. group: this.groups[2],
  3009. name: "poison spikes",
  3010. desc: "poisons enemies when they touch them",
  3011. req: ["wood", 35, "stone", 15],
  3012. health: 600,
  3013. dmg: 30,
  3014. pDmg: 5,
  3015. scale: 52,
  3016. spritePadding: -23,
  3017. holdOffset: 8,
  3018. placeOffset: -5,
  3019. itemID: 8,
  3020. itemAID: 24,
  3021. }, {
  3022. age: 9,
  3023. group: this.groups[2],
  3024. name: "spinning spikes",
  3025. desc: "damages enemies when they touch them",
  3026. req: ["wood", 30, "stone", 20],
  3027. health: 500,
  3028. dmg: 45,
  3029. turnSpeed: 0.003,
  3030. scale: 52,
  3031. spritePadding: -23,
  3032. holdOffset: 8,
  3033. placeOffset: -5,
  3034. itemID: 9,
  3035. itemAID: 25,
  3036. }, {
  3037. group: this.groups[3],
  3038. name: "windmill",
  3039. desc: "generates gold over time",
  3040. req: ["wood", 50, "stone", 10],
  3041. health: 400,
  3042. pps: 1,
  3043. turnSpeed: 0.0016,
  3044. spritePadding: 25,
  3045. iconLineMult: 12,
  3046. scale: 45,
  3047. holdOffset: 20,
  3048. placeOffset: 5,
  3049. itemID: 10,
  3050. itemAID: 26,
  3051. }, {
  3052. age: 5,
  3053. group: this.groups[3],
  3054. name: "faster windmill",
  3055. desc: "generates more gold over time",
  3056. req: ["wood", 60, "stone", 20],
  3057. health: 500,
  3058. pps: 1.5,
  3059. turnSpeed: 0.0025,
  3060. spritePadding: 25,
  3061. iconLineMult: 12,
  3062. scale: 47,
  3063. holdOffset: 20,
  3064. placeOffset: 5,
  3065. itemID: 11,
  3066. itemAID: 27,
  3067. }, {
  3068. age: 8,
  3069. group: this.groups[3],
  3070. name: "power mill",
  3071. desc: "generates more gold over time",
  3072. req: ["wood", 100, "stone", 50],
  3073. health: 800,
  3074. pps: 2,
  3075. turnSpeed: 0.005,
  3076. spritePadding: 25,
  3077. iconLineMult: 12,
  3078. scale: 47,
  3079. holdOffset: 20,
  3080. placeOffset: 5,
  3081. itemID: 12,
  3082. itemAID: 28,
  3083. }, {
  3084. age: 5,
  3085. group: this.groups[4],
  3086. type: 2,
  3087. name: "mine",
  3088. desc: "allows you to mine stone",
  3089. req: ["wood", 20, "stone", 100],
  3090. iconLineMult: 12,
  3091. scale: 65,
  3092. holdOffset: 20,
  3093. placeOffset: 0,
  3094. itemID: 13,
  3095. itemAID: 29,
  3096. }, {
  3097. age: 5,
  3098. group: this.groups[11],
  3099. type: 0,
  3100. name: "sapling",
  3101. desc: "allows you to farm wood",
  3102. req: ["wood", 150],
  3103. iconLineMult: 12,
  3104. colDiv: 0.5,
  3105. scale: 110,
  3106. holdOffset: 50,
  3107. placeOffset: -15,
  3108. itemID: 14,
  3109. itemAID: 30,
  3110. }, {
  3111. age: 4,
  3112. group: this.groups[5],
  3113. name: "pit trap",
  3114. desc: "pit that traps enemies if they walk over it",
  3115. req: ["wood", 30, "stone", 30],
  3116. trap: true,
  3117. ignoreCollision: true,
  3118. hideFromEnemy: true,
  3119. health: 500,
  3120. colDiv: 0.2,
  3121. scale: 50,
  3122. holdOffset: 20,
  3123. placeOffset: -5,
  3124. alpha: 0.6,
  3125. itemID: 15,
  3126. itemAID: 31,
  3127. }, {
  3128. age: 4,
  3129. group: this.groups[6],
  3130. name: "boost pad",
  3131. desc: "provides boost when stepped on",
  3132. req: ["stone", 20, "wood", 5],
  3133. ignoreCollision: true,
  3134. boostSpeed: 1.5,
  3135. health: 150,
  3136. colDiv: 0.7,
  3137. scale: 45,
  3138. holdOffset: 20,
  3139. placeOffset: -5,
  3140. itemID: 16,
  3141. itemAID: 32,
  3142. }, {
  3143. age: 7,
  3144. group: this.groups[7],
  3145. doUpdate: true,
  3146. name: "turret",
  3147. desc: "defensive structure that shoots at enemies",
  3148. req: ["wood", 200, "stone", 150],
  3149. health: 800,
  3150. projectile: 1,
  3151. shootRange: 700,
  3152. shootRate: 2200,
  3153. scale: 43,
  3154. holdOffset: 20,
  3155. placeOffset: -5,
  3156. itemID: 17,
  3157. itemAID: 33,
  3158. }, {
  3159. age: 7,
  3160. group: this.groups[8],
  3161. name: "platform",
  3162. desc: "platform to shoot over walls and cross over water",
  3163. req: ["wood", 20],
  3164. ignoreCollision: true,
  3165. zIndex: 1,
  3166. health: 300,
  3167. scale: 43,
  3168. holdOffset: 20,
  3169. placeOffset: -5,
  3170. itemID: 18,
  3171. itemAID: 34,
  3172. }, {
  3173. age: 7,
  3174. group: this.groups[9],
  3175. name: "healing pad",
  3176. desc: "standing on it will slowly heal you",
  3177. req: ["wood", 30, "food", 10],
  3178. ignoreCollision: true,
  3179. healCol: 15,
  3180. health: 400,
  3181. colDiv: 0.7,
  3182. scale: 45,
  3183. holdOffset: 20,
  3184. placeOffset: -5,
  3185. itemID: 19,
  3186. itemAID: 35,
  3187. }, {
  3188. age: 9,
  3189. group: this.groups[10],
  3190. name: "spawn pad",
  3191. desc: "you will spawn here when you die but it will dissapear",
  3192. req: ["wood", 100, "stone", 100],
  3193. health: 400,
  3194. ignoreCollision: true,
  3195. spawnPoint: true,
  3196. scale: 45,
  3197. holdOffset: 20,
  3198. placeOffset: -5,
  3199. itemID: 20,
  3200. itemAID: 36,
  3201. }, {
  3202. age: 7,
  3203. group: this.groups[12],
  3204. name: "blocker",
  3205. desc: "blocks building in radius",
  3206. req: ["wood", 30, "stone", 25],
  3207. ignoreCollision: true,
  3208. blocker: 300,
  3209. health: 400,
  3210. colDiv: 0.7,
  3211. scale: 45,
  3212. holdOffset: 20,
  3213. placeOffset: -5,
  3214. itemID: 21,
  3215. itemAID: 37,
  3216. }, {
  3217. age: 7,
  3218. group: this.groups[13],
  3219. name: "teleporter",
  3220. desc: "teleports you to a random point on the map",
  3221. req: ["wood", 60, "stone", 60],
  3222. ignoreCollision: true,
  3223. teleport: true,
  3224. health: 200,
  3225. colDiv: 0.7,
  3226. scale: 45,
  3227. holdOffset: 20,
  3228. placeOffset: -5,
  3229. itemID: 22,
  3230. itemAID: 38
  3231. }];
  3232.  
  3233. // CHECK ITEM ID:
  3234. this.checkItem = {
  3235. index: function(id, myItems) {
  3236. return [0, 1, 2].includes(id) ? 0 : [3, 4, 5].includes(id) ? 1 : [6, 7, 8, 9].includes(id) ? 2 : [10, 11, 12].includes(id) ? 3 : [13, 14].includes(id) ? 5 : [15, 16].includes(id) ? 4 : [17, 18, 19, 21, 22].includes(id) ? [13, 14].includes(myItems) ? 6 :
  3237. 5 :
  3238. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3239. 6 :
  3240. undefined;
  3241. }
  3242. }
  3243.  
  3244. // ASSIGN IDS:
  3245. for (let i = 0; i < this.list.length; ++i) {
  3246. this.list[i].id = i;
  3247. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3248. }
  3249.  
  3250. // TROLOLOLOL:
  3251. if (typeof window !== "undefined") {
  3252. function shuffle(a) {
  3253. for (let i = a.length - 1; i > 0; i--) {
  3254. const j = Math.floor(Math.random() * (i + 1));
  3255. [a[i], a[j]] = [a[j], a[i]];
  3256. }
  3257. return a;
  3258. }
  3259. //shuffle(this.list);
  3260. }
  3261. }
  3262. }
  3263. class Objectmanager {
  3264. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3265. let mathFloor = Math.floor,
  3266. mathABS = Math.abs,
  3267. mathCOS = Math.cos,
  3268. mathSIN = Math.sin,
  3269. mathPOW = Math.pow,
  3270. mathSQRT = Math.sqrt;
  3271.  
  3272. this.ignoreAdd = false;
  3273. this.hitObj = [];
  3274.  
  3275. // DISABLE OBJ:
  3276. this.disableObj = function(obj) {
  3277. obj.active = false;
  3278. };
  3279.  
  3280. // ADD NEW:
  3281. let tmpObj;
  3282. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3283. tmpObj = findObjectBySid(sid);
  3284. if (!tmpObj) {
  3285. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3286. if (!tmpObj) {
  3287. tmpObj = new GameObject(sid);
  3288. gameObjects.push(tmpObj);
  3289. }
  3290. }
  3291. if (setSID) {
  3292. tmpObj.sid = sid;
  3293. }
  3294. tmpObj.init(x, y, dir, s, type, data, owner);
  3295. };
  3296.  
  3297. // DISABLE BY SID:
  3298. this.disableBySid = function(sid) {
  3299. let find = findObjectBySid(sid);
  3300. if (find) {
  3301. this.disableObj(find);
  3302. }
  3303. };
  3304.  
  3305. // REMOVE ALL FROM PLAYER:
  3306. this.removeAllItems = function(sid, server) {
  3307. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3308. };
  3309.  
  3310. // CHECK IF PLACABLE:
  3311. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3312. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  3313. if (cantPlace) return false;
  3314. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3315. return true;
  3316. };
  3317.  
  3318. }
  3319. }
  3320. class Projectile {
  3321. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3322.  
  3323. // INIT:
  3324. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3325. this.active = true;
  3326. this.tickActive = true;
  3327. this.indx = indx;
  3328. this.x = x;
  3329. this.y = y;
  3330. this.x2 = x;
  3331. this.y2 = y;
  3332. this.dir = dir;
  3333. this.skipMov = true;
  3334. this.speed = spd;
  3335. this.dmg = dmg;
  3336. this.scale = scl;
  3337. this.range = rng;
  3338. this.r2 = rng;
  3339. this.owner = owner;
  3340. };
  3341.  
  3342. // UPDATE:
  3343. this.update = function(delta) {
  3344. if (this.active) {
  3345. let tmpSpeed = this.speed * delta;
  3346. if (!this.skipMov) {
  3347. this.x += tmpSpeed * Math.cos(this.dir);
  3348. this.y += tmpSpeed * Math.sin(this.dir);
  3349. this.range -= tmpSpeed;
  3350. if (this.range <= 0) {
  3351. this.x += this.range * Math.cos(this.dir);
  3352. this.y += this.range * Math.sin(this.dir);
  3353. tmpSpeed = 1;
  3354. this.range = 0;
  3355. this.active = false;
  3356. }
  3357. } else {
  3358. this.skipMov = false;
  3359. }
  3360. }
  3361. };
  3362. this.tickUpdate = function(delta) {
  3363. if (this.tickActive) {
  3364. let tmpSpeed = this.speed * delta;
  3365. if (!this.skipMov) {
  3366. this.x2 += tmpSpeed * Math.cos(this.dir);
  3367. this.y2 += tmpSpeed * Math.sin(this.dir);
  3368. this.r2 -= tmpSpeed;
  3369. if (this.r2 <= 0) {
  3370. this.x2 += this.r2 * Math.cos(this.dir);
  3371. this.y2 += this.r2 * Math.sin(this.dir);
  3372. tmpSpeed = 1;
  3373. this.r2 = 0;
  3374. this.tickActive = false;
  3375. }
  3376. } else {
  3377. this.skipMov = false;
  3378. }
  3379. }
  3380. };
  3381. }
  3382. };
  3383. class Store {
  3384. constructor() {
  3385. // STORE HATS:
  3386. this.hats = [{
  3387. id: 45,
  3388. name: "Shame!",
  3389. dontSell: true,
  3390. price: 0,
  3391. scale: 120,
  3392. desc: "hacks are for winners"
  3393. }, {
  3394. id: 51,
  3395. name: "Moo Cap",
  3396. price: 0,
  3397. scale: 120,
  3398. desc: "coolest mooer around"
  3399. }, {
  3400. id: 50,
  3401. name: "Apple Cap",
  3402. price: 0,
  3403. scale: 120,
  3404. desc: "apple farms remembers"
  3405. }, {
  3406. id: 28,
  3407. name: "Moo Head",
  3408. price: 0,
  3409. scale: 120,
  3410. desc: "no effect"
  3411. }, {
  3412. id: 29,
  3413. name: "Pig Head",
  3414. price: 0,
  3415. scale: 120,
  3416. desc: "no effect"
  3417. }, {
  3418. id: 30,
  3419. name: "Fluff Head",
  3420. price: 0,
  3421. scale: 120,
  3422. desc: "no effect"
  3423. }, {
  3424. id: 36,
  3425. name: "Pandou Head",
  3426. price: 0,
  3427. scale: 120,
  3428. desc: "no effect"
  3429. }, {
  3430. id: 37,
  3431. name: "Bear Head",
  3432. price: 0,
  3433. scale: 120,
  3434. desc: "no effect"
  3435. }, {
  3436. id: 38,
  3437. name: "Monkey Head",
  3438. price: 0,
  3439. scale: 120,
  3440. desc: "no effect"
  3441. }, {
  3442. id: 44,
  3443. name: "Polar Head",
  3444. price: 0,
  3445. scale: 120,
  3446. desc: "no effect"
  3447. }, {
  3448. id: 35,
  3449. name: "Fez Hat",
  3450. price: 0,
  3451. scale: 120,
  3452. desc: "no effect"
  3453. }, {
  3454. id: 42,
  3455. name: "Enigma Hat",
  3456. price: 0,
  3457. scale: 120,
  3458. desc: "join the enigma army"
  3459. }, {
  3460. id: 43,
  3461. name: "Blitz Hat",
  3462. price: 0,
  3463. scale: 120,
  3464. desc: "hey everybody i'm blitz"
  3465. }, {
  3466. id: 49,
  3467. name: "Bob XIII Hat",
  3468. price: 0,
  3469. scale: 120,
  3470. desc: "like and subscribe"
  3471. }, {
  3472. id: 57,
  3473. name: "Pumpkin",
  3474. price: 50,
  3475. scale: 120,
  3476. desc: "Spooooky"
  3477. }, {
  3478. id: 8,
  3479. name: "Bummle Hat",
  3480. price: 100,
  3481. scale: 120,
  3482. desc: "no effect"
  3483. }, {
  3484. id: 2,
  3485. name: "Straw Hat",
  3486. price: 500,
  3487. scale: 120,
  3488. desc: "no effect"
  3489. }, {
  3490. id: 15,
  3491. name: "Winter Cap",
  3492. price: 600,
  3493. scale: 120,
  3494. desc: "allows you to move at normal speed in snow",
  3495. coldM: 1
  3496. }, {
  3497. id: 5,
  3498. name: "Cowboy Hat",
  3499. price: 1000,
  3500. scale: 120,
  3501. desc: "no effect"
  3502. }, {
  3503. id: 4,
  3504. name: "Ranger Hat",
  3505. price: 2000,
  3506. scale: 120,
  3507. desc: "no effect"
  3508. }, {
  3509. id: 18,
  3510. name: "Explorer Hat",
  3511. price: 2000,
  3512. scale: 120,
  3513. desc: "no effect"
  3514. }, {
  3515. id: 31,
  3516. name: "Flipper Hat",
  3517. price: 2500,
  3518. scale: 120,
  3519. desc: "have more control while in water",
  3520. watrImm: true
  3521. }, {
  3522. id: 1,
  3523. name: "Marksman Cap",
  3524. price: 3000,
  3525. scale: 120,
  3526. desc: "increases arrow speed and range",
  3527. aMlt: 1.3
  3528. }, {
  3529. id: 10,
  3530. name: "Bush Gear",
  3531. price: 3000,
  3532. scale: 160,
  3533. desc: "allows you to disguise yourself as a bush"
  3534. }, {
  3535. id: 48,
  3536. name: "Halo",
  3537. price: 3000,
  3538. scale: 120,
  3539. desc: "no effect"
  3540. }, {
  3541. id: 6,
  3542. name: "Soldier Helmet",
  3543. price: 4000,
  3544. scale: 120,
  3545. desc: "reduces damage taken but slows movement",
  3546. spdMult: 0.94,
  3547. dmgMult: 0.75
  3548. }, {
  3549. id: 23,
  3550. name: "Anti Venom Gear",
  3551. price: 4000,
  3552. scale: 120,
  3553. desc: "makes you immune to poison",
  3554. poisonRes: 1
  3555. }, {
  3556. id: 13,
  3557. name: "Medic Gear",
  3558. price: 5000,
  3559. scale: 110,
  3560. desc: "slowly regenerates health over time",
  3561. healthRegen: 3
  3562. }, {
  3563. id: 9,
  3564. name: "Miners Helmet",
  3565. price: 5000,
  3566. scale: 120,
  3567. desc: "earn 1 extra gold per resource",
  3568. extraGold: 1
  3569. }, {
  3570. id: 32,
  3571. name: "Musketeer Hat",
  3572. price: 5000,
  3573. scale: 120,
  3574. desc: "reduces cost of projectiles",
  3575. projCost: 0.5
  3576. }, {
  3577. id: 7,
  3578. name: "Bull Helmet",
  3579. price: 6000,
  3580. scale: 120,
  3581. desc: "increases damage done but drains health",
  3582. healthRegen: -5,
  3583. dmgMultO: 1.5,
  3584. spdMult: 0.96
  3585. }, {
  3586. id: 22,
  3587. name: "Emp Helmet",
  3588. price: 6000,
  3589. scale: 120,
  3590. desc: "turrets won't attack but you move slower",
  3591. antiTurret: 1,
  3592. spdMult: 0.7
  3593. }, {
  3594. id: 12,
  3595. name: "Booster Hat",
  3596. price: 6000,
  3597. scale: 120,
  3598. desc: "increases your movement speed",
  3599. spdMult: 1.16
  3600. }, {
  3601. id: 26,
  3602. name: "Barbarian Armor",
  3603. price: 8000,
  3604. scale: 120,
  3605. desc: "knocks back enemies that attack you",
  3606. dmgK: 0.6
  3607. }, {
  3608. id: 21,
  3609. name: "Plague Mask",
  3610. price: 10000,
  3611. scale: 120,
  3612. desc: "melee attacks deal poison damage",
  3613. poisonDmg: 5,
  3614. poisonTime: 6
  3615. }, {
  3616. id: 46,
  3617. name: "Bull Mask",
  3618. price: 10000,
  3619. scale: 120,
  3620. desc: "bulls won't target you unless you attack them",
  3621. bullRepel: 1
  3622. }, {
  3623. id: 14,
  3624. name: "Windmill Hat",
  3625. topSprite: true,
  3626. price: 10000,
  3627. scale: 120,
  3628. desc: "generates points while worn",
  3629. pps: 1.5
  3630. }, {
  3631. id: 11,
  3632. name: "Spike Gear",
  3633. topSprite: true,
  3634. price: 10000,
  3635. scale: 120,
  3636. desc: "deal damage to players that damage you",
  3637. dmg: 0.45
  3638. }, {
  3639. id: 53,
  3640. name: "Turret Gear",
  3641. topSprite: true,
  3642. price: 10000,
  3643. scale: 120,
  3644. desc: "you become a walking turret",
  3645. turret: {
  3646. proj: 1,
  3647. range: 700,
  3648. rate: 2500
  3649. },
  3650. spdMult: 0.7
  3651. }, {
  3652. id: 20,
  3653. name: "Samurai Armor",
  3654. price: 12000,
  3655. scale: 120,
  3656. desc: "increased attack speed and fire rate",
  3657. atkSpd: 0.78
  3658. }, {
  3659. id: 58,
  3660. name: "Dark Knight",
  3661. price: 12000,
  3662. scale: 120,
  3663. desc: "restores health when you deal damage",
  3664. healD: 0.4
  3665. }, {
  3666. id: 27,
  3667. name: "Scavenger Gear",
  3668. price: 15000,
  3669. scale: 120,
  3670. desc: "earn double points for each kill",
  3671. kScrM: 2
  3672. }, {
  3673. id: 40,
  3674. name: "Tank Gear",
  3675. price: 15000,
  3676. scale: 120,
  3677. desc: "increased damage to buildings but slower movement",
  3678. spdMult: 0.3,
  3679. bDmg: 3.3
  3680. }, {
  3681. id: 52,
  3682. name: "Thief Gear",
  3683. price: 15000,
  3684. scale: 120,
  3685. desc: "steal half of a players gold when you kill them",
  3686. goldSteal: 0.5
  3687. }, {
  3688. id: 55,
  3689. name: "Bloodthirster",
  3690. price: 20000,
  3691. scale: 120,
  3692. desc: "Restore Health when dealing damage. And increased damage",
  3693. healD: 0.25,
  3694. dmgMultO: 1.2,
  3695. }, {
  3696. id: 56,
  3697. name: "Assassin Gear",
  3698. price: 20000,
  3699. scale: 120,
  3700. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3701. noEat: true,
  3702. spdMult: 1.1,
  3703. invisTimer: 1000
  3704. }];
  3705.  
  3706. // STORE ACCESSORIES:
  3707. this.accessories = [{
  3708. id: 12,
  3709. name: "Snowball",
  3710. price: 1000,
  3711. scale: 105,
  3712. xOff: 18,
  3713. desc: "no effect"
  3714. }, {
  3715. id: 9,
  3716. name: "Tree Cape",
  3717. price: 1000,
  3718. scale: 90,
  3719. desc: "no effect"
  3720. }, {
  3721. id: 10,
  3722. name: "Stone Cape",
  3723. price: 1000,
  3724. scale: 90,
  3725. desc: "no effect"
  3726. }, {
  3727. id: 3,
  3728. name: "Cookie Cape",
  3729. price: 1500,
  3730. scale: 90,
  3731. desc: "no effect"
  3732. }, {
  3733. id: 8,
  3734. name: "Cow Cape",
  3735. price: 2000,
  3736. scale: 90,
  3737. desc: "no effect"
  3738. }, {
  3739. id: 11,
  3740. name: "Monkey Tail",
  3741. price: 2000,
  3742. scale: 97,
  3743. xOff: 25,
  3744. desc: "Super speed but reduced damage",
  3745. spdMult: 1.35,
  3746. dmgMultO: 0.2
  3747. }, {
  3748. id: 17,
  3749. name: "Apple Basket",
  3750. price: 3000,
  3751. scale: 80,
  3752. xOff: 12,
  3753. desc: "slowly regenerates health over time",
  3754. healthRegen: 1
  3755. }, {
  3756. id: 6,
  3757. name: "Winter Cape",
  3758. price: 3000,
  3759. scale: 90,
  3760. desc: "no effect"
  3761. }, {
  3762. id: 4,
  3763. name: "Skull Cape",
  3764. price: 4000,
  3765. scale: 90,
  3766. desc: "no effect"
  3767. }, {
  3768. id: 5,
  3769. name: "Dash Cape",
  3770. price: 5000,
  3771. scale: 90,
  3772. desc: "no effect"
  3773. }, {
  3774. id: 2,
  3775. name: "Dragon Cape",
  3776. price: 6000,
  3777. scale: 90,
  3778. desc: "no effect"
  3779. }, {
  3780. id: 1,
  3781. name: "Super Cape",
  3782. price: 8000,
  3783. scale: 90,
  3784. desc: "no effect"
  3785. }, {
  3786. id: 7,
  3787. name: "Troll Cape",
  3788. price: 8000,
  3789. scale: 90,
  3790. desc: "no effect"
  3791. }, {
  3792. id: 14,
  3793. name: "Thorns",
  3794. price: 10000,
  3795. scale: 115,
  3796. xOff: 20,
  3797. desc: "no effect"
  3798. }, {
  3799. id: 15,
  3800. name: "Blockades",
  3801. price: 10000,
  3802. scale: 95,
  3803. xOff: 15,
  3804. desc: "no effect"
  3805. }, {
  3806. id: 20,
  3807. name: "Devils Tail",
  3808. price: 10000,
  3809. scale: 95,
  3810. xOff: 20,
  3811. desc: "no effect"
  3812. }, {
  3813. id: 16,
  3814. name: "Sawblade",
  3815. price: 12000,
  3816. scale: 90,
  3817. spin: true,
  3818. xOff: 0,
  3819. desc: "deal damage to players that damage you",
  3820. dmg: 0.15
  3821. }, {
  3822. id: 13,
  3823. name: "Corrupt X Wings",
  3824. price: 20000,
  3825. scale: 178,
  3826. xOff: 26,
  3827. desc: "deal damage to players that damage you",
  3828. healthRegen: 3
  3829. }, {
  3830. id: 19,
  3831. name: "Angel Wings",
  3832. price: 15000,
  3833. scale: 138,
  3834. xOff: 22,
  3835. desc: "increased movement speed",
  3836. spdMult: 1.1
  3837. }, {
  3838. id: 18,
  3839. name: "Blood Wings",
  3840. price: 20000,
  3841. scale: 178,
  3842. xOff: 26,
  3843. desc: "restores health when you deal damage",
  3844. healD: 0.2
  3845. }, {
  3846. id: 21,
  3847. name: "Corrupt X Wings",
  3848. price: 20000,
  3849. scale: 178,
  3850. xOff: 26,
  3851. desc: "deal damage to players that damage you",
  3852. dmg: 0.25
  3853. }];
  3854. }
  3855. };
  3856. class ProjectileManager {
  3857. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3858. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3859. let tmpData = items.projectiles[indx];
  3860. let tmpProj;
  3861. for (let i = 0; i < projectiles.length; ++i) {
  3862. if (!projectiles[i].active) {
  3863. tmpProj = projectiles[i];
  3864. break;
  3865. }
  3866. }
  3867. if (!tmpProj) {
  3868. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3869. tmpProj.sid = projectiles.length;
  3870. projectiles.push(tmpProj);
  3871. }
  3872. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3873. tmpProj.ignoreObj = ignoreObj;
  3874. tmpProj.layer = layer || tmpData.layer;
  3875. tmpProj.inWindow = inWindow;
  3876. tmpProj.src = tmpData.src;
  3877. return tmpProj;
  3878. };
  3879. }
  3880. };
  3881. class AiManager {
  3882.  
  3883. // AI MANAGER:
  3884. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3885.  
  3886. // AI TYPES:
  3887. this.aiTypes = [{
  3888. id: 0,
  3889. src: "cow_1",
  3890. killScore: 150,
  3891. health: 500,
  3892. weightM: 0.8,
  3893. speed: 0.00095,
  3894. turnSpeed: 0.001,
  3895. scale: 72,
  3896. drop: ["food", 50]
  3897. }, {
  3898. id: 1,
  3899. src: "pig_1",
  3900. killScore: 200,
  3901. health: 800,
  3902. weightM: 0.6,
  3903. speed: 0.00085,
  3904. turnSpeed: 0.001,
  3905. scale: 72,
  3906. drop: ["food", 80]
  3907. }, {
  3908. id: 2,
  3909. name: "Bull",
  3910. src: "bull_2",
  3911. hostile: true,
  3912. dmg: 20,
  3913. killScore: 1000,
  3914. health: 1800,
  3915. weightM: 0.5,
  3916. speed: 0.00094,
  3917. turnSpeed: 0.00074,
  3918. scale: 78,
  3919. viewRange: 800,
  3920. chargePlayer: true,
  3921. drop: ["food", 100]
  3922. }, {
  3923. id: 3,
  3924. name: "Bully",
  3925. src: "bull_1",
  3926. hostile: true,
  3927. dmg: 20,
  3928. killScore: 2000,
  3929. health: 2800,
  3930. weightM: 0.45,
  3931. speed: 0.001,
  3932. turnSpeed: 0.0008,
  3933. scale: 90,
  3934. viewRange: 900,
  3935. chargePlayer: true,
  3936. drop: ["food", 400]
  3937. }, {
  3938. id: 4,
  3939. name: "Wolf",
  3940. src: "wolf_1",
  3941. hostile: true,
  3942. dmg: 8,
  3943. killScore: 500,
  3944. health: 300,
  3945. weightM: 0.45,
  3946. speed: 0.001,
  3947. turnSpeed: 0.002,
  3948. scale: 84,
  3949. viewRange: 800,
  3950. chargePlayer: true,
  3951. drop: ["food", 200]
  3952. }, {
  3953. id: 5,
  3954. name: "Quack",
  3955. src: "chicken_1",
  3956. dmg: 8,
  3957. killScore: 2000,
  3958. noTrap: true,
  3959. health: 300,
  3960. weightM: 0.2,
  3961. speed: 0.0018,
  3962. turnSpeed: 0.006,
  3963. scale: 70,
  3964. drop: ["food", 100]
  3965. }, {
  3966. id: 6,
  3967. name: "MOOSTAFA",
  3968. nameScale: 50,
  3969. src: "enemy",
  3970. hostile: true,
  3971. dontRun: true,
  3972. fixedSpawn: true,
  3973. spawnDelay: 60000,
  3974. noTrap: true,
  3975. colDmg: 100,
  3976. dmg: 40,
  3977. killScore: 8000,
  3978. health: 18000,
  3979. weightM: 0.4,
  3980. speed: 0.0007,
  3981. turnSpeed: 0.01,
  3982. scale: 80,
  3983. spriteMlt: 1.8,
  3984. leapForce: 0.9,
  3985. viewRange: 1000,
  3986. hitRange: 210,
  3987. hitDelay: 1000,
  3988. chargePlayer: true,
  3989. drop: ["food", 100]
  3990. }, {
  3991. id: 7,
  3992. name: "Treasure",
  3993. hostile: true,
  3994. nameScale: 35,
  3995. src: "crate_1",
  3996. fixedSpawn: true,
  3997. spawnDelay: 120000,
  3998. colDmg: 200,
  3999. killScore: 5000,
  4000. health: 20000,
  4001. weightM: 0.1,
  4002. speed: 0.0,
  4003. turnSpeed: 0.0,
  4004. scale: 70,
  4005. spriteMlt: 1.0
  4006. }, {
  4007. id: 8,
  4008. name: "MOOFIE",
  4009. src: "wolf_2",
  4010. hostile: true,
  4011. fixedSpawn: true,
  4012. dontRun: true,
  4013. hitScare: 4,
  4014. spawnDelay: 30000,
  4015. noTrap: true,
  4016. nameScale: 35,
  4017. dmg: 10,
  4018. colDmg: 100,
  4019. killScore: 3000,
  4020. health: 7000,
  4021. weightM: 0.45,
  4022. speed: 0.0015,
  4023. turnSpeed: 0.002,
  4024. scale: 90,
  4025. viewRange: 800,
  4026. chargePlayer: true,
  4027. drop: ["food", 1000]
  4028. }];
  4029.  
  4030. // SPAWN AI:
  4031. this.spawn = function(x, y, dir, index) {
  4032. let tmpObj = ais.find((tmp) => !tmp.active);
  4033. if (!tmpObj) {
  4034. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  4035. ais.push(tmpObj);
  4036. }
  4037. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  4038. return tmpObj;
  4039. };
  4040. }
  4041.  
  4042. };
  4043. class AI {
  4044. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  4045. this.sid = sid;
  4046. this.isAI = true;
  4047. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  4048.  
  4049. // INIT:
  4050. this.init = function(x, y, dir, index, data) {
  4051. this.x = x;
  4052. this.y = y;
  4053. this.startX = data.fixedSpawn ? x : null;
  4054. this.startY = data.fixedSpawn ? y : null;
  4055. this.xVel = 0;
  4056. this.yVel = 0;
  4057. this.zIndex = 0;
  4058. this.dir = dir;
  4059. this.dirPlus = 0;
  4060. this.showName = 'aaa';
  4061. this.index = index;
  4062. this.src = data.src;
  4063. if (data.name) this.name = data.name;
  4064. this.weightM = data.weightM;
  4065. this.speed = data.speed;
  4066. this.killScore = data.killScore;
  4067. this.turnSpeed = data.turnSpeed;
  4068. this.scale = data.scale;
  4069. this.maxHealth = data.health;
  4070. this.leapForce = data.leapForce;
  4071. this.health = this.maxHealth;
  4072. this.chargePlayer = data.chargePlayer;
  4073. this.viewRange = data.viewRange;
  4074. this.drop = data.drop;
  4075. this.dmg = data.dmg;
  4076. this.hostile = data.hostile;
  4077. this.dontRun = data.dontRun;
  4078. this.hitRange = data.hitRange;
  4079. this.hitDelay = data.hitDelay;
  4080. this.hitScare = data.hitScare;
  4081. this.spriteMlt = data.spriteMlt;
  4082. this.nameScale = data.nameScale;
  4083. this.colDmg = data.colDmg;
  4084. this.noTrap = data.noTrap;
  4085. this.spawnDelay = data.spawnDelay;
  4086. this.hitWait = 0;
  4087. this.waitCount = 1000;
  4088. this.moveCount = 0;
  4089. this.targetDir = 0;
  4090. this.active = true;
  4091. this.alive = true;
  4092. this.runFrom = null;
  4093. this.chargeTarget = null;
  4094. this.dmgOverTime = {};
  4095. };
  4096.  
  4097. let tmpRatio = 0;
  4098. let animIndex = 0;
  4099. this.animate = function(delta) {
  4100. if (this.animTime > 0) {
  4101. this.animTime -= delta;
  4102. if (this.animTime <= 0) {
  4103. this.animTime = 0;
  4104. this.dirPlus = 0;
  4105. tmpRatio = 0;
  4106. animIndex = 0;
  4107. } else {
  4108. if (animIndex == 0) {
  4109. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4110. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4111. if (tmpRatio >= 1) {
  4112. tmpRatio = 1;
  4113. animIndex = 1;
  4114. }
  4115. } else {
  4116. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4117. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4118. }
  4119. }
  4120. }
  4121. };
  4122.  
  4123. // ANIMATION:
  4124. this.startAnim = function() {
  4125. this.animTime = this.animSpeed = 600;
  4126. this.targetAngle = Math.PI * 0.8;
  4127. tmpRatio = 0;
  4128. animIndex = 0;
  4129. };
  4130.  
  4131. };
  4132.  
  4133. };
  4134. class addCh {
  4135. constructor(x, y, chat, tmpObj) {
  4136. this.x = x;
  4137. this.y = y;
  4138. this.alpha = 0;
  4139. this.active = true;
  4140. this.alive = false;
  4141. this.chat = chat;
  4142. this.owner = tmpObj;
  4143. };
  4144. };
  4145. class DeadPlayer {
  4146. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4147. this.x = x;
  4148. this.y = y;
  4149. this.lastDir = dir;
  4150. this.dir = dir + Math.PI;
  4151. this.buildIndex = buildIndex;
  4152. this.weaponIndex = weaponIndex;
  4153. this.weaponVariant = weaponVariant;
  4154. this.skinColor = skinColor;
  4155. this.scale = scale;
  4156. this.visScale = 0;
  4157. this.name = name;
  4158. this.alpha = 1;
  4159. this.active = true;
  4160. this.animate = function(delta) {
  4161. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4162. if (d2 > 0.01) {
  4163. this.dir += d2 / 20;
  4164. } else {
  4165. this.dir = this.lastDir;
  4166. }
  4167. if (this.visScale < this.scale) {
  4168. this.visScale += delta / (this.scale / 2);
  4169. if (this.visScale >= this.scale) {
  4170. this.visScale = this.scale;
  4171. }
  4172. }
  4173. this.alpha -= delta / 30000;
  4174. if (this.alpha <= 0) {
  4175. this.alpha = 0;
  4176. this.active = false;
  4177. }
  4178. }
  4179. }
  4180. };
  4181. class Player {
  4182. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4183. this.id = id;
  4184. this.sid = sid;
  4185. this.tmpScore = 0;
  4186. this.team = null;
  4187. this.latestSkin = 0;
  4188. this.oldSkinIndex = 0;
  4189. this.skinIndex = 0;
  4190. this.latestTail = 0;
  4191. this.oldTailIndex = 0;
  4192. this.tailIndex = 0;
  4193. this.hitTime = 0;
  4194. this.lastHit = 0;
  4195. this.showName = 'NOOO';
  4196. this.tails = {};
  4197. for (let i = 0; i < accessories.length; ++i) {
  4198. if (accessories[i].price <= 0)
  4199. this.tails[accessories[i].id] = 1;
  4200. }
  4201. this.skins = {};
  4202. for (let i = 0; i < hats.length; ++i) {
  4203. if (hats[i].price <= 0)
  4204. this.skins[hats[i].id] = 1;
  4205. }
  4206. this.points = 0;
  4207. this.dt = 0;
  4208. this.hidden = false;
  4209. this.itemCounts = {};
  4210. this.isPlayer = true;
  4211. this.pps = 0;
  4212. this.moveDir = undefined;
  4213. this.skinRot = 0;
  4214. this.lastPing = 0;
  4215. this.iconIndex = 0;
  4216. this.skinColor = 0;
  4217. this.dist2 = 0;
  4218. this.aim2 = 0;
  4219. this.maxSpeed = 1;
  4220. this.chat = {
  4221. message: null,
  4222. count: 0
  4223. };
  4224. this.circle = false;
  4225. this.cAngle = 0;
  4226. // SPAWN:
  4227. this.spawn = function(moofoll) {
  4228. this.attacked = false;
  4229. this.timeDamaged = 0;
  4230. this.timeHealed = 0;
  4231. this.pinge = 0;
  4232. this.millPlace = 'NOOO';
  4233. this.lastshamecount = 0;
  4234. this.death = false;
  4235. this.spinDir = 0;
  4236. this.sync = false;
  4237. this.antiBull = 0;
  4238. this.bullTimer = 0;
  4239. this.poisonTimer = 0;
  4240. this.active = true;
  4241. this.alive = true;
  4242. this.lockMove = false;
  4243. this.lockDir = false;
  4244. this.minimapCounter = 0;
  4245. this.chatCountdown = 0;
  4246. this.shameCount = 0;
  4247. this.shameTimer = 0;
  4248. this.sentTo = {};
  4249. this.gathering = 0;
  4250. this.gatherIndex = 0;
  4251. this.shooting = {};
  4252. this.shootIndex = 9;
  4253. this.autoGather = 0;
  4254. this.animTime = 0;
  4255. this.animSpeed = 0;
  4256. this.mouseState = 0;
  4257. this.buildIndex = -1;
  4258. this.weaponIndex = 0;
  4259. this.weaponCode = 0;
  4260. this.weaponVariant = 0;
  4261. this.primaryIndex = undefined;
  4262. this.secondaryIndex = undefined;
  4263. this.dmgOverTime = {};
  4264. this.noMovTimer = 0;
  4265. this.maxXP = 300;
  4266. this.XP = 0;
  4267. this.age = 1;
  4268. this.kills = 0;
  4269. this.upgrAge = 2;
  4270. this.upgradePoints = 0;
  4271. this.x = 0;
  4272. this.y = 0;
  4273. this.oldXY = {
  4274. x: 0,
  4275. y: 0
  4276. };
  4277. this.zIndex = 0;
  4278. this.xVel = 0;
  4279. this.yVel = 0;
  4280. this.slowMult = 1;
  4281. this.dir = 0;
  4282. this.dirPlus = 0;
  4283. this.targetDir = 0;
  4284. this.targetAngle = 0;
  4285. this.maxHealth = 100;
  4286. this.health = this.maxHealth;
  4287. this.oldHealth = this.maxHealth;
  4288. this.damaged = 0;
  4289. this.scale = config.playerScale;
  4290. this.speed = config.playerSpeed;
  4291. this.resetMoveDir();
  4292. this.resetResources(moofoll);
  4293. this.items = [0, 3, 6, 10];
  4294. this.weapons = [0];
  4295. this.shootCount = 0;
  4296. this.weaponXP = [];
  4297. this.reloads = {
  4298. 0: 0,
  4299. 1: 0,
  4300. 2: 0,
  4301. 3: 0,
  4302. 4: 0,
  4303. 5: 0,
  4304. 6: 0,
  4305. 7: 0,
  4306. 8: 0,
  4307. 9: 0,
  4308. 10: 0,
  4309. 11: 0,
  4310. 12: 0,
  4311. 13: 0,
  4312. 14: 0,
  4313. 15: 0,
  4314. 53: 0,
  4315. };
  4316. this.bowThreat = {
  4317. 9: 0,
  4318. 12: 0,
  4319. 13: 0,
  4320. 15: 0,
  4321. };
  4322. this.damageThreat = 0;
  4323. this.inTrap = false;
  4324. this.canEmpAnti = false;
  4325. this.empAnti = false;
  4326. this.soldierAnti = false;
  4327. this.poisonTick = 0;
  4328. this.bullTick = 0;
  4329. this.setPoisonTick = false;
  4330. this.setBullTick = false;
  4331. this.antiTimer = 2;
  4332. };
  4333.  
  4334. // RESET MOVE DIR:
  4335. this.resetMoveDir = function() {
  4336. this.moveDir = undefined;
  4337. };
  4338.  
  4339. // RESET RESOURCES:
  4340. this.resetResources = function(moofoll) {
  4341. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4342. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4343. }
  4344. };
  4345.  
  4346. // ADD ITEM:
  4347. this.getItemType = function(id) {
  4348. let findindx = this.items.findIndex((ids) => ids == id);
  4349. if (findindx != -1) {
  4350. return findindx;
  4351. } else {
  4352. return items.checkItem.index(id, this.items);
  4353. }
  4354. };
  4355.  
  4356. // SET DATA:
  4357. this.setData = function(data) {
  4358. this.id = data[0];
  4359. this.sid = data[1];
  4360. this.name = data[2];
  4361. this.x = data[3];
  4362. this.y = data[4];
  4363. this.dir = data[5];
  4364. this.health = data[6];
  4365. this.maxHealth = data[7];
  4366. this.scale = data[8];
  4367. this.skinColor = data[9];
  4368. };
  4369.  
  4370. // UPDATE POISON TICK:
  4371. this.updateTimer = function() {
  4372.  
  4373. this.bullTimer -= 1;
  4374. if (this.bullTimer <= 0) {
  4375. this.setBullTick = false;
  4376. this.bullTick = game.tick - 1;
  4377. this.bullTimer = config.serverUpdateRate;
  4378. }
  4379. this.poisonTimer -= 1;
  4380. if (this.poisonTimer <= 0) {
  4381. this.setPoisonTick = false;
  4382. this.poisonTick = game.tick - 1;
  4383. this.poisonTimer = config.serverUpdateRate;
  4384. }
  4385.  
  4386. };
  4387. this.update = function(delta) {
  4388. if (this.active) {
  4389.  
  4390. // MOVE:
  4391. let gear = {
  4392. skin: findID(hats, this.skinIndex),
  4393. tail: findID(accessories, this.tailIndex)
  4394. }
  4395. 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;
  4396. this.maxSpeed = spdMult;
  4397.  
  4398. }
  4399. };
  4400.  
  4401. let tmpRatio = 0;
  4402. let animIndex = 0;
  4403. this.animate = function(delta) {
  4404. if (this.animTime > 0) {
  4405. this.animTime -= delta;
  4406. if (this.animTime <= 0) {
  4407. this.animTime = 0;
  4408. this.dirPlus = 0;
  4409. tmpRatio = 0;
  4410. animIndex = 0;
  4411. } else {
  4412. if (animIndex == 0) {
  4413. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4414. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4415. if (tmpRatio >= 1) {
  4416. tmpRatio = 1;
  4417. animIndex = 1;
  4418. }
  4419. } else {
  4420. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4421. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4422. }
  4423. }
  4424. }
  4425. };
  4426.  
  4427. // GATHER ANIMATION:
  4428. this.startAnim = function(didHit, index) {
  4429. this.animTime = this.animSpeed = items.weapons[index].speed;
  4430. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4431. tmpRatio = 0;
  4432. animIndex = 0;
  4433. };
  4434.  
  4435. // CAN SEE:
  4436. this.canSee = function(other) {
  4437. if (!other) return false;
  4438. let dx = Math.abs(other.x - this.x) - other.scale;
  4439. let dy = Math.abs(other.y - this.y) - other.scale;
  4440. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4441. };
  4442.  
  4443. // SHAME SYSTEM:
  4444. this.judgeShame = function() {
  4445. if (this.oldHealth < this.health) {
  4446. if (this.hitTime) {
  4447. let timeSinceHit = game.tick - this.hitTime;
  4448. this.lastHit = game.tick;
  4449. this.hitTime = 0;
  4450. if (timeSinceHit < 2) {
  4451. this.shameCount++;
  4452. } else {
  4453. this.shameCount = Math.max(0, this.shameCount - 2);
  4454. }
  4455. }
  4456. } else if (this.oldHealth > this.health) {
  4457. this.hitTime = game.tick;
  4458. }
  4459. };
  4460. this.addShameTimer = function() {
  4461. this.shameCount = 0;
  4462. this.shameTimer = 30;
  4463. let interval = setInterval(() => {
  4464. this.shameTimer--;
  4465. if (this.shameTimer <= 0) {
  4466. clearInterval(interval);
  4467. }
  4468. }, 1000);
  4469. };
  4470.  
  4471. // CHECK TEAM:
  4472. this.isTeam = function(tmpObj) {
  4473. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4474. };
  4475.  
  4476. // FOR THE PLAYER:
  4477. this.findAllianceBySid = function(sid) {
  4478. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4479. };
  4480. this.checkCanInsta = function(nobull) {
  4481. let totally = 0;
  4482. if (this.alive && inGame) {
  4483. let primary = {
  4484. weapon: this.weapons[0],
  4485. variant: this.primaryVariant,
  4486. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4487. };
  4488. let secondary = {
  4489. weapon: this.weapons[1],
  4490. variant: this.secondaryVariant,
  4491. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4492. };
  4493. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4494. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4495. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4496. totally += primary.dmg * pV * bull;
  4497. }
  4498. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4499. totally += secondary.dmg;
  4500. }
  4501. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4502. totally += 25;
  4503. }
  4504. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4505. return totally;
  4506. }
  4507. return 0;
  4508. };
  4509.  
  4510. // UPDATE WEAPON RELOAD:
  4511. this.manageReload = function() {
  4512. if (this.shooting[53]) {
  4513. this.shooting[53] = 0;
  4514. this.reloads[53] = (2500 - game.tickRate);
  4515. } else {
  4516. if (this.reloads[53] > 0) {
  4517. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4518. }
  4519. }
  4520.  
  4521. // PREPLACER
  4522. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4523. // place(2, getAttackDir());
  4524. let index = this.weaponIndex;
  4525. let nearObja = liztobj.filter((e) => (e.active || e.alive) && e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2) <= (items.weapons[player.weaponIndex].range + e.scale));
  4526. for(let i = 0; i < nearObja.length; i++) {
  4527. let aaa = nearObja[i];
  4528.  
  4529. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4530. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4531. if(aaa.health - (valaa) <= 0 && near.length) {
  4532. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4533. console.log("preplaced");
  4534. }
  4535. }
  4536. }
  4537.  
  4538. if (this.gathering || this.shooting[1]) {
  4539. if (this.gathering) {
  4540. this.gathering = 0;
  4541. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4542. this.attacked = true;
  4543. }
  4544. if (this.shooting[1]) {
  4545. this.shooting[1] = 0;
  4546. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4547. this.attacked = true;
  4548. }
  4549. } else {
  4550. this.attacked = false;
  4551. if (this.buildIndex < 0) {
  4552. if (this.reloads[this.weaponIndex] > 0) {
  4553. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4554. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4555. if (this == player) {
  4556. if (getEl("weaponGrind").checked) {
  4557. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4558. checkPlace(player.getItemType(22), i);
  4559. }
  4560. }
  4561. }
  4562. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4563. this.antiBull++;
  4564. game.tickBase(() => {
  4565. this.antiBull = 0;
  4566. }, 1);
  4567. }
  4568. }
  4569. }
  4570. }
  4571. };
  4572.  
  4573. // FOR ANTI INSTA:
  4574. this.addDamageThreat = function(tmpObj) {
  4575. let primary = {
  4576. weapon: this.primaryIndex,
  4577. variant: this.primaryVariant
  4578. };
  4579. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4580. let secondary = {
  4581. weapon: this.secondaryIndex,
  4582. variant: this.secondaryVariant
  4583. };
  4584. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4585. let bull = 1.5;
  4586. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4587. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4588. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4589. this.damageThreat += primary.dmg * pV * bull;
  4590. }
  4591. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4592. this.damageThreat += secondary.dmg * sV;
  4593. }
  4594. if (this.reloads[53] <= game.tickRate) {
  4595. this.damageThreat += 25;
  4596. }
  4597. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4598. if (!this.isTeam(tmpObj)) {
  4599. if (this.dist2 <= 300) {
  4600. tmpObj.damageThreat += this.damageThreat;
  4601. }
  4602. }
  4603. };
  4604.  
  4605. }
  4606. };
  4607.  
  4608. // SOME CODES:
  4609. function sendUpgrade(index) {
  4610. player.reloads[index] = 0;
  4611. packet("H", index);
  4612. }
  4613.  
  4614. function storeEquip(id, index) {
  4615. packet("c", 0, id, index);
  4616. }
  4617.  
  4618. function storeBuy(id, index) {
  4619. packet("c", 1, id, index);
  4620. }
  4621.  
  4622. function buyEquip(id, index) {
  4623. let nID = player.skins[6] ? 6 : 0;
  4624. if (player.alive && inGame) {
  4625. if (index == 0) {
  4626. if (player.skins[id]) {
  4627. if (player.latestSkin != id) {
  4628. packet("c", 0, id, 0);
  4629. }
  4630. } else {
  4631. if (configs.autoBuyEquip) {
  4632. let find = findID(hats, id);
  4633. if (find) {
  4634. if (player.points >= find.price) {
  4635. packet("c", 1, id, 0);
  4636. packet("c", 0, id, 0);
  4637. } else {
  4638. if (player.latestSkin != nID) {
  4639. packet("c", 0, nID, 0);
  4640. }
  4641. }
  4642. } else {
  4643. if (player.latestSkin != nID) {
  4644. packet("c", 0, nID, 0);
  4645. }
  4646. }
  4647. } else {
  4648. if (player.latestSkin != nID) {
  4649. packet("c", 0, nID, 0);
  4650. }
  4651. }
  4652. }
  4653. } else if (index == 1) {
  4654. if (useWasd && (id != 11 && id != 0)) {
  4655. if (player.latestTail != 0) {
  4656. packet("c", 0, 0, 1);
  4657. }
  4658. return;
  4659. }
  4660. if (player.tails[id]) {
  4661. if (player.latestTail != id) {
  4662. packet("c", 0, id, 1);
  4663. }
  4664. } else {
  4665. if (configs.autoBuyEquip) {
  4666. let find = findID(accessories, id);
  4667. if (find) {
  4668. if (player.points >= find.price) {
  4669. packet("c", 1, id, 1);
  4670. packet("c", 0, id, 1);
  4671. } else {
  4672. if (player.latestTail != 0) {
  4673. packet("c", 0, 0, 1);
  4674. }
  4675. }
  4676. } else {
  4677. if (player.latestTail != 0) {
  4678. packet("c", 0, 0, 1);
  4679. }
  4680. }
  4681. } else {
  4682. if (player.latestTail != 0) {
  4683. packet("c", 0, 0, 1);
  4684. }
  4685. }
  4686. }
  4687. }
  4688. }
  4689. }
  4690.  
  4691. function selectToBuild(index, wpn) {
  4692. packet("z", index, wpn);
  4693. }
  4694.  
  4695. function selectWeapon(index, isPlace) {
  4696. if (!isPlace) {
  4697. player.weaponCode = index;
  4698. }
  4699. packet("z", index, 1);
  4700. }
  4701.  
  4702. function sendAutoGather() {
  4703. packet("K", 1, 1);
  4704. }
  4705.  
  4706. function sendAtck(id, angle) {
  4707. packet("F", id, angle, 1);
  4708. }
  4709.  
  4710. // PLACER:
  4711. function place(id, rad, rmd) {
  4712. try {
  4713. if (id == undefined) return;
  4714. let item = items.list[player.items[id]];
  4715. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4716. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4717. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4718. 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))) {
  4719. selectToBuild(player.items[id]);
  4720. sendAtck(1, rad);
  4721. selectWeapon(player.weaponCode, 1);
  4722. if (rmd && getEl("placeVis").checked) {
  4723. placeVisible.push({
  4724. x: tmpX,
  4725. y: tmpY,
  4726. name: item.name,
  4727. scale: item.scale,
  4728. dir: rad
  4729. });
  4730. game.tickBase(() => {
  4731. placeVisible.shift();
  4732. }, 1)
  4733. }
  4734. }
  4735. } catch (e) {}
  4736. }
  4737.  
  4738. function checkPlace(id, rad) {
  4739. try {
  4740. if (id == undefined) return;
  4741. let item = items.list[player.items[id]];
  4742. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4743. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4744. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4745. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4746. place(id, rad, 1);
  4747. }
  4748. } catch (e) {}
  4749. }
  4750.  
  4751. // HEALING:
  4752. function soldierMult() {
  4753. return player.latestSkin == 6 ? 0.75 : 1;
  4754. }
  4755.  
  4756. function healthBased() {
  4757. if (player.health == 100)
  4758. return 0;
  4759. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4760. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4761. }
  4762. return 0;
  4763. }
  4764.  
  4765. function getAttacker(damaged) {
  4766. let attackers = enemy.filter(tmp => {
  4767. //let damages = new Damages(items);
  4768. //let dmg = damages.weapons[tmp.weaponIndex];
  4769. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4770. let rule = {
  4771. //one: tmp.dist2 <= 300,
  4772. //two: by.includes(damaged),
  4773. three: tmp.attacked
  4774. }
  4775. return /*rule.one && rule.two && */ rule.three;
  4776. });
  4777. return attackers;
  4778. }
  4779.  
  4780. function healer() {
  4781. for (let i = 0; i < healthBased(); i++) {
  4782. place(0, getAttackDir());
  4783. }
  4784. }
  4785.  
  4786. function antiSyncHealing(timearg) {
  4787. my.antiSync = true;
  4788. sendChat("");
  4789. let healAnti = setInterval(() => {
  4790. if (player.shameCount < 5) {
  4791. place(0, getAttackDir());
  4792. }
  4793. }, 75);
  4794. setTimeout(() => {
  4795. clearInterval(healAnti);
  4796. setTimeout(() => {
  4797. my.antiSync = false;
  4798. }, game.tickRate);
  4799. }, game.tickRate);
  4800. }
  4801. function applCxC(value) {
  4802. if (player.health == 100)
  4803. return 0;
  4804. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4805. return Math.ceil(value / items.list[player.items[0]].healing);
  4806. }
  4807. return 0;
  4808. }
  4809. function calcDmg(value) {
  4810. return value * player.skinIndex == 6 ? 0.75 : 1;
  4811. }
  4812. function biomeGear(mover, returns) {
  4813. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4814. if (returns) return 31;
  4815. buyEquip(31, 0);
  4816. } else {
  4817. if (player.y2 <= config.snowBiomeTop) {
  4818. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4819. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4820. } else {
  4821. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4822. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4823. }
  4824. }
  4825. if (returns) return 0;
  4826. }
  4827. let advHeal = [];
  4828.  
  4829. class Traps {
  4830. constructor(UTILS, items) {
  4831. this.dist = 0;
  4832. this.aim = 0;
  4833. this.inTrap = false;
  4834. this.replaced = false;
  4835. this.antiTrapped = false;
  4836. this.info = {};
  4837. this.notFast = function() {
  4838. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4839. }
  4840. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4841. try {
  4842. let item = items.list[player.items[id]];
  4843. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4844. let counts = {
  4845. attempts: 0,
  4846. placed: 0
  4847. };
  4848. let tmpObjects = [];
  4849. gameObjects.forEach((p) => {
  4850. tmpObjects.push({
  4851. x: p.x,
  4852. y: p.y,
  4853. active: p.active,
  4854. blocker: p.blocker,
  4855. scale: p.scale,
  4856. isItem: p.isItem,
  4857. type: p.type,
  4858. colDiv: p.colDiv,
  4859. getScale: function(sM, ig) {
  4860. sM = sM || 1;
  4861. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4862. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4863. },
  4864. });
  4865. });
  4866. for (let i = first; i < repeat; i += plus) {
  4867. counts.attempts++;
  4868. let relAim = radian + i;
  4869. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4870. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4871. 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)));
  4872. if (cantPlace) continue;
  4873. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4874. if ((!replacer && yaboi) || useWasd) {
  4875. if (useWasd ? false : yaboi.inTrap) {
  4876. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4877. place(2, relAim, 1);
  4878. } else {
  4879. player.items[4] == 15 && place(4, relAim, 1);
  4880. }
  4881. } else {
  4882. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  4883. place(2, relAim, 1);
  4884. } else {
  4885. player.items[4] == 15 && place(4, relAim, 1);
  4886. }
  4887. }
  4888. } else {
  4889. place(id, relAim, 1);
  4890. }
  4891. tmpObjects.push({
  4892. x: tmpX,
  4893. y: tmpY,
  4894. active: true,
  4895. blocker: item.blocker,
  4896. scale: item.scale,
  4897. isItem: true,
  4898. type: null,
  4899. colDiv: item.colDiv,
  4900. getScale: function() {
  4901. return this.scale;
  4902. },
  4903. });
  4904. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4905. counts.placed++;
  4906. }
  4907. }
  4908. if (counts.placed > 0 && replacer && item.dmg) {
  4909. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4910. instaC.canSpikeTick = true;
  4911. }
  4912. }
  4913. } catch (err) {
  4914. }
  4915. };
  4916.  
  4917. this.checkSpikeTick = function(findObj) {
  4918. try {
  4919. if (getEl("spiketick").checked) {
  4920. if (near.dist2 <= 10) {
  4921. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4922. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4923. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4924. let item = items.list[9];
  4925. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4926. let danger = 0;
  4927. let counts = {
  4928. attempts: 0,
  4929. block: `unblocked`
  4930. };
  4931. for (let i = -1; i <= 1; i += 1 / 10) {
  4932. counts.attempts++;
  4933. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4934. let tmpX = near.x2 + tmpS * waMath.cos(relAim);
  4935. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4936. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4937. if (cantPlace) continue;
  4938. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4939. danger++;
  4940. counts.block = `blocked`;
  4941. break;
  4942. }
  4943. }
  4944. }
  4945. if (danger) {
  4946. return true;
  4947. }
  4948. }
  4949. } catch (err) {
  4950. return null;
  4951. }
  4952. return false;
  4953. }
  4954. this.protect = function(aim) {
  4955. sendChat("");
  4956. if (!configs.antiTrap) return;
  4957. if (player.items[4]) {
  4958. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4959. this.antiTrapped = true;
  4960. }
  4961. };
  4962. /*this.autoPlace = function() {
  4963. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4964. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4965. if (gameObjects.length) {
  4966. let near2 = {
  4967. inTrap: false,
  4968. };
  4969. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function(a, b) {
  4970. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4971. })[0];
  4972. if (nearTrap) {
  4973. near2.inTrap = true;
  4974. } else {
  4975. near2.inTrap = false;
  4976. }
  4977. if ((near.dist3 <= 450)) {
  4978. if (near.dist3 <= 200) {
  4979. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4980. inTrap: near2.inTrap
  4981. });
  4982. } else {
  4983. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4984. }
  4985. }
  4986. } else {
  4987. if ((near.dist3 <= 450)) {
  4988. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4989. }
  4990. }
  4991. }
  4992. }
  4993. };*/
  4994. this.autoPlace = function () {
  4995. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4996. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  4997. if (gameObjects.length) {
  4998. let near2 = {
  4999. inTrap: true,
  5000. };
  5001. let nearTrap = gameObjects.filter(e => e.trap && e.active && e.isTeamObject(player) && UTILS.getDist(e, near, 0, 2) <= (near.scale + e.getScale() + 5)).sort(function (a, b) {
  5002. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5003. })[0];
  5004. if (nearTrap) {
  5005. near2.inTrap = true;
  5006. } else {
  5007. near2.inTrap = true;
  5008. }
  5009. if ((near.dist2 <= 280)) {
  5010. if (near.dist2 <= 200) {
  5011. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  5012. } else {
  5013. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5014. }
  5015. }
  5016. } else {
  5017. if ((near.dist2 <= 1000)) {
  5018. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5019. }
  5020. }
  5021. }
  5022. }
  5023. };
  5024. this.replacer = function (findObj) {
  5025. if (!findObj || !configs.autoReplace) return;
  5026. if (!inGame) return;
  5027. if (this.antiTrapped) return;
  5028. game.tickBase(() => {
  5029. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5030. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5031. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5032. if (objDst <= 400 && near.dist2 <= 400) {
  5033. let danger = this.checkSpikeTick();
  5034. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5035. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5036. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5037. } else {
  5038. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5039. }
  5040. this.replaced = true;
  5041. }
  5042. }, 1);
  5043. };
  5044. }
  5045. };
  5046. /* this.replacer = function(findObj) {
  5047. if (!findObj || !configs.autoReplace) return;
  5048. if (!inGame) return;
  5049. if (this.antiTrapped) return;
  5050.  
  5051. game.tickBase(() => {
  5052. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5053. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5054.  
  5055. let perfectAngle = calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y);
  5056.  
  5057. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5058.  
  5059. if (objDst <= 400 && near.dist2 <= 400) {
  5060. if (isObjectBroken(findObj)) {
  5061. let danger = this.checkSpikeTick();
  5062. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5063. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5064. } else {
  5065. if (player.items[4] == 15) {
  5066. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5067. }
  5068. }
  5069. this.replaced = true;
  5070. }
  5071. }
  5072. }, 1);
  5073. }
  5074. }
  5075. }*/
  5076.  
  5077. function calculatePerfectAngle(x1, y1, x2, y2) {
  5078. return Math.atan2(y2 - y1, x2 - x1);
  5079. }
  5080. function isObjectBroken(object) {
  5081. const healthThreshold = 20;
  5082. return object.health < healthThreshold;
  5083. }
  5084.  
  5085. /*this.replacer = function (findObj) {
  5086. if (!findObj || !configs.autoReplace) return;
  5087. if (!inGame) return;
  5088. if (this.antiTrapped) return;
  5089. game.tickBase(() => {
  5090. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5091. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5092. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5093. if (objDst <= 400 && near.dist2 <= 400) {
  5094. let danger = this.checkSpikeTick();
  5095. if (!danger && near.dist2 <= items.weapons[near.primaryIndex + 5].range + (near.scale * 1.8)) {
  5096. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5097. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5098. } else {
  5099. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5100. }
  5101. this.replaced = true;
  5102. }
  5103. }, 1);
  5104. };
  5105. }
  5106. }*/
  5107. class Instakill {
  5108. constructor() {
  5109. this.wait = false;
  5110. this.can = false;
  5111. this.isTrue = false;
  5112. this.nobull = false;
  5113. this.ticking = false;
  5114. this.canSpikeTick = false;
  5115. this.startTick = false;
  5116. this.readyTick = false;
  5117. this.canCounter = false;
  5118. this.revTick = false;
  5119. this.syncHit = false;
  5120. this.changeType = function(type) {
  5121. this.wait = false;
  5122. this.isTrue = true;
  5123. my.autoAim = true;
  5124. let instaLog = [type];
  5125. if (type == "rev") {
  5126. selectWeapon(player.weapons[1]);
  5127. buyEquip(53, 0);
  5128. sendAutoGather();
  5129. setTimeout(() => {
  5130. selectWeapon(player.weapons[0]);
  5131. buyEquip(7, 0);
  5132. setTimeout(() => {
  5133. sendAutoGather();
  5134. this.isTrue = false;
  5135. my.autoAim = false;
  5136. }, 225);
  5137. }, 100);
  5138. } else if (type == "nobull") {
  5139. selectWeapon(player.weapons[0]);
  5140. buyEquip(7, 0);
  5141. sendAutoGather();
  5142. setTimeout(() => {
  5143. selectWeapon(player.weapons[1]);
  5144. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5145. setTimeout(() => {
  5146. sendAutoGather();
  5147. this.isTrue = false;
  5148. my.autoAim = false;
  5149. }, 255);
  5150. }, 105);
  5151. } else if (type == "normal") {
  5152. selectWeapon(player.weapons[0]);
  5153. buyEquip(7, 0);
  5154. sendAutoGather();
  5155. setTimeout(() => {
  5156. selectWeapon(player.weapons[1]);
  5157. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5158. setTimeout(() => {
  5159. sendAutoGather();
  5160. this.isTrue = false;
  5161. my.autoAim = false;
  5162. }, 255);
  5163. }, 100);
  5164. } else {
  5165. setTimeout(() => {
  5166. this.isTrue = false;
  5167. my.autoAim = false;
  5168. }, 50);
  5169. }
  5170. };
  5171. this.spikeTickType = function() {
  5172. sendChat("<//FMA AUTOMATICLY TICKED//>");
  5173. this.isTrue = true;
  5174. my.autoAim = true;
  5175. selectWeapon(player.weapons[0]);
  5176. buyEquip(7, 0);
  5177. sendAutoGather();
  5178. game.tickBase(() => {
  5179. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5180. buyEquip(53, 0);
  5181. selectWeapon(player.weapons[0]);
  5182. buyEquip(53, 0);
  5183. //buyEquip(21, 1);
  5184. game.tickBase(() => {
  5185. sendAutoGather();
  5186. this.isTrue = false;
  5187. my.autoAim = false;
  5188. buyEquip(6, 0);
  5189. buyEquip(21, 1);
  5190. }, 3);
  5191. }, 1);
  5192. };
  5193. /* this.spikeTickType = function() {
  5194. this.isTrue = true;
  5195. my.autoAim = true;
  5196. selectWeapon(player.weapons[0]);
  5197. buyEquip(7, 0);
  5198. buyEquip(21, 1);
  5199. sendAutoGather();
  5200. game.tickBase(() => {
  5201. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5202. selectWeapon(player.weapons[0]);
  5203. buyEquip(53, 0);
  5204. buyEquip(21, 1);
  5205. game.tickBase(() => {
  5206. sendAutoGather();
  5207. this.isTrue = false;
  5208. my.autoAim = false;
  5209. }, 1);
  5210. } else {
  5211. sendAutoGather();
  5212. this.isTrue = false;
  5213. my.autoAim = false;
  5214. }
  5215. }, 1);
  5216. };*/
  5217. this.counterType = function() {
  5218. this.isTrue = true;
  5219. my.autoAim = true;
  5220. selectWeapon(player.weapons[0]);
  5221. buyEquip(7, 0);
  5222. buyEquip(21, 1);
  5223. sendAutoGather();
  5224. game.tickBase(() => {
  5225. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5226. selectWeapon(player.weapons[0]);
  5227. buyEquip(53, 0);
  5228. buyEquip(21, 1);
  5229. game.tickBase(() => {
  5230. sendAutoGather();
  5231. this.isTrue = false;
  5232. my.autoAim = false;
  5233. }, 1);
  5234. } else {
  5235. sendAutoGather();
  5236. this.isTrue = false;
  5237. my.autoAim = false;
  5238. }
  5239. }, 1);
  5240. };
  5241. this.antiCounterType = function() {
  5242. my.autoAim = true;
  5243. this.isTrue = true;
  5244. inantiantibull = true;
  5245. selectWeapon(player.weapons[0]);
  5246. buyEquip(6, 0);
  5247. buyEquip(21, 1);
  5248. io.send("D", near.aim2);
  5249. sendAutoGather();
  5250. game.tickBase(() => {
  5251. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  5252. buyEquip(21, 1);
  5253. game.tickBase(() => {
  5254. sendAutoGather();
  5255. this.isTrue = false;
  5256. my.autoAim = false;
  5257. inantiantibull = false;
  5258. }, 1);
  5259. }, 1)
  5260. };
  5261. this.rangeType = function(type) {
  5262. this.isTrue = true;
  5263. my.autoAim = true;
  5264. if (type == "ageInsta") {
  5265. sendChat("");
  5266. my.ageInsta = false;
  5267. if (player.items[5] == 18) {
  5268. place(5, near.aim2);
  5269. }
  5270. packet("f", undefined, 1);
  5271. buyEquip(22, 0);
  5272. buyEquip(21, 1);
  5273. game.tickBase(() => {
  5274. selectWeapon(player.weapons[1]);
  5275. buyEquip(53, 0);
  5276. buyEquip(21, 1);
  5277. sendAutoGather();
  5278. game.tickBase(() => {
  5279. sendUpgrade(12);
  5280. selectWeapon(player.weapons[1]);
  5281. buyEquip(53, 0);
  5282. buyEquip(21, 1);
  5283. game.tickBase(() => {
  5284. sendUpgrade(15);
  5285. selectWeapon(player.weapons[1]);
  5286. buyEquip(53, 0);
  5287. buyEquip(21, 1);
  5288. game.tickBase(() => {
  5289. sendAutoGather();
  5290. this.isTrue = false;
  5291. my.autoAim = false;
  5292. }, 1);
  5293. }, 1);
  5294. }, 1);
  5295. }, 1);
  5296. } else {
  5297. selectWeapon(player.weapons[1]);
  5298. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5299. buyEquip(53, 0);
  5300. } else {
  5301. buyEquip(20, 0);
  5302. }
  5303. buyEquip(11, 1);
  5304. sendAutoGather();
  5305. game.tickBase(() => {
  5306. sendAutoGather();
  5307. this.isTrue = false;
  5308. my.autoAim = false;
  5309. }, 1);
  5310. }
  5311. };
  5312. this.oneTickType = function() {
  5313. io.send("7113213.29154");
  5314. this.isTrue = true;
  5315. my.autoAim = true;
  5316. selectWeapon(player.weapons[1]);
  5317. buyEquip(53, 0);
  5318. buyEquip(19, 1);
  5319. packet("f", near.aim2, 1);
  5320. if (player.weapons[1] == 15) {
  5321. my.revAim = true;
  5322. sendAutoGather();
  5323. }
  5324. game.tickBase(() => {
  5325. my.revAim = false;
  5326. selectWeapon(player.weapons[0]);
  5327. buyEquip(7, 0);
  5328. buyEquip(19, 1);
  5329. packet("f", near.aim2, 1);
  5330. if (player.weapons[1] != 15) {
  5331. sendAutoGather();
  5332. }
  5333. game.tickBase(() => {
  5334. sendAutoGather();
  5335. this.isTrue = false;
  5336. my.autoAim = false;
  5337. packet("f", undefined, 1);
  5338. }, 1);
  5339. }, 1);
  5340. };
  5341. this.threeOneTickType = function() {
  5342. io.send("Tick2");
  5343. this.isTrue = true;
  5344. my.autoAim = true;
  5345. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5346. biomeGear();
  5347. buyEquip(19, 1);
  5348. packet("f", near.aim2, 1);
  5349. game.tickBase(() => {
  5350. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5351. buyEquip(53, 0);
  5352. buyEquip(19, 1);
  5353. packet("f", near.aim2, 1);
  5354. game.tickBase(() => {
  5355. selectWeapon(player.weapons[0]);
  5356. buyEquip(7, 0);
  5357. buyEquip(19, 1);
  5358. sendAutoGather();
  5359. packet("f", near.aim2, 1);
  5360. game.tickBase(() => {
  5361. sendAutoGather();
  5362. this.isTrue = false;
  5363. my.autoAim = false;
  5364. packet("f", undefined, 1);
  5365. }, 1);
  5366. }, 1);
  5367. }, 1);
  5368. };
  5369. this.kmTickType = function() {
  5370. this.isTrue = true;
  5371. my.autoAim = true;
  5372. my.revAim = true;
  5373. selectWeapon(player.weapons[1]);
  5374. buyEquip(53, 0);
  5375. buyEquip(19, 1);
  5376. sendAutoGather();
  5377. packet("f", near.aim2, 1);
  5378. game.tickBase(() => {
  5379. my.revAim = false;
  5380. selectWeapon(player.weapons[0]);
  5381. buyEquip(7, 0);
  5382. buyEquip(19, 1);
  5383. packet("f", near.aim2, 1);
  5384. game.tickBase(() => {
  5385. sendAutoGather();
  5386. this.isTrue = false;
  5387. my.autoAim = false;
  5388. packet("f", undefined, 1);
  5389. }, 1);
  5390. }, 1);
  5391. };
  5392. this.boostTickType = function() {
  5393. /*this.isTrue = true;
  5394. my.autoAim = true;
  5395. selectWeapon(player.weapons[0]);
  5396. buyEquip(53, 0);
  5397. buyEquip(19, 1);
  5398. packet("f", near.aim2);
  5399. game.tickBase(() => {
  5400. place(4, near.aim2);
  5401. selectWeapon(player.weapons[1]);
  5402. biomeGear();
  5403. buyEquip(19, 1);
  5404. sendAutoGather();
  5405. packet("f", near.aim2);
  5406. game.tickBase(() => {
  5407. selectWeapon(player.weapons[0]);
  5408. buyEquip(7, 0);
  5409. buyEquip(19, 1);
  5410. packet("f", near.aim2);
  5411. game.tickBase(() => {
  5412. sendAutoGather();
  5413. this.isTrue = false;
  5414. my.autoAim = false;
  5415. packet("f", undefined);
  5416. }, 1);
  5417. }, 1);
  5418. }, 1);*/
  5419. this.isTrue = true;
  5420. my.autoAim = true;
  5421. biomeGear();
  5422. buyEquip(19, 1);
  5423. packet("f", near.aim2, 1);
  5424. game.tickBase(() => {
  5425. if (player.weapons[1] == 15) {
  5426. my.revAim = true;
  5427. }
  5428. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5429. buyEquip(53, 0);
  5430. buyEquip(19, 1);
  5431. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5432. sendAutoGather();
  5433. }
  5434. packet("f", near.aim2, 1);
  5435. place(4, near.aim2);
  5436. game.tickBase(() => {
  5437. my.revAim = false;
  5438. selectWeapon(player.weapons[0]);
  5439. buyEquip(7, 0);
  5440. buyEquip(19, 1);
  5441. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5442. sendAutoGather();
  5443. }
  5444. packet("f", near.aim2, 1);
  5445. game.tickBase(() => {
  5446. sendAutoGather();
  5447. this.isTrue = false;
  5448. my.autoAim = false;
  5449. packet("f", undefined, 1);
  5450. }, 1);
  5451. }, 1);
  5452. }, 1);
  5453. };
  5454. this.gotoGoal = function(goto, OT) {
  5455. let slowDists = (weeeee) => weeeee * config.playerScale;
  5456. let goal = {
  5457. a: goto - OT,
  5458. b: goto + OT,
  5459. c: goto - slowDists(1),
  5460. d: goto + slowDists(1),
  5461. e: goto - slowDists(2),
  5462. f: goto + slowDists(2),
  5463. g: goto - slowDists(4),
  5464. h: goto + slowDists(4)
  5465. };
  5466. let bQ = function(wwww, awwww) {
  5467. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5468. buyEquip(31, 0);
  5469. } else {
  5470. buyEquip(wwww, awwww);
  5471. }
  5472. }
  5473. if (enemy.length) {
  5474. let dst = near.dist2;
  5475. this.ticking = true;
  5476. if (dst >= goal.a && dst <= goal.b) {
  5477. bQ(22, 0);
  5478. bQ(11, 1);
  5479. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5480. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5481. }
  5482. return {
  5483. dir: undefined,
  5484. action: 1
  5485. };
  5486. } else {
  5487. if (dst < goal.a) {
  5488. if (dst >= goal.g) {
  5489. if (dst >= goal.e) {
  5490. if (dst >= goal.c) {
  5491. bQ(40, 0);
  5492. bQ(10, 1);
  5493. if (configs.none) {
  5494. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5495. } else {
  5496. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5497. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5498. }
  5499. }
  5500. } else {
  5501. bQ(22, 0);
  5502. bQ(19, 1);
  5503. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5504. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5505. }
  5506. }
  5507. } else {
  5508. bQ(6, 0);
  5509. bQ(12, 1);
  5510. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5511. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5512. }
  5513. }
  5514. } else {
  5515. biomeGear();
  5516. bQ(11, 1);
  5517. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5518. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5519. }
  5520. }
  5521. return {
  5522. dir: near.aim2 + Math.PI,
  5523. action: 0
  5524. };
  5525. } else if (dst > goal.b) {
  5526. if (dst <= goal.h) {
  5527. if (dst <= goal.f) {
  5528. if (dst <= goal.d) {
  5529. bQ(40, 0);
  5530. bQ(9, 1);
  5531. if (configs.none) {
  5532. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5533. } else {
  5534. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5535. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5536. }
  5537. }
  5538. } else {
  5539. bQ(22, 0);
  5540. bQ(19, 1);
  5541. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5542. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5543. }
  5544. }
  5545. } else {
  5546. bQ(6, 0);
  5547. bQ(12, 1);
  5548. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5549. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5550. }
  5551. }
  5552. } else {
  5553. biomeGear();
  5554. bQ(11, 1);
  5555. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5556. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5557. }
  5558. }
  5559. return {
  5560. dir: near.aim2,
  5561. action: 0
  5562. };
  5563. }
  5564. return {
  5565. dir: undefined,
  5566. action: 0
  5567. };
  5568. }
  5569. } else {
  5570. this.ticking = false;
  5571. return {
  5572. dir: undefined,
  5573. action: 0
  5574. };
  5575. }
  5576. }
  5577. /** wait 1 tick for better quality */
  5578. this.bowMovement = function() {
  5579. let moveMent = this.gotoGoal(685, 3);
  5580. if (moveMent.action) {
  5581. if (player.reloads[53] == 0 && !this.isTrue) {
  5582. this.rangeType("ageInsta");
  5583. } else {
  5584. packet("f", moveMent.dir, 1);
  5585. }
  5586. } else {
  5587. packet("f", moveMent.dir, 1);
  5588. }
  5589. },
  5590. this.tickMovement = function() {
  5591. let dist = player.weapons[1] == 9 ? 240 : 240;
  5592. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5593. let moveMent = this.gotoGoal(238, 3);
  5594. if (moveMent.action) {
  5595. if (player.reloads[53] == 0 && !this.isTrue) {
  5596. this.boostTickType();
  5597. } else {
  5598. packet("f", moveMent.dir, 1);
  5599. }
  5600. } else {
  5601. packet("f", moveMent.dir, 1);
  5602. }
  5603. },
  5604. this.kmTickMovement = function() {
  5605. let moveMent = this.gotoGoal(240, 3);
  5606. if (moveMent.action) {
  5607. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5608. this.kmTickType();
  5609. } else {
  5610. packet("f", moveMent.dir, 1);
  5611. }
  5612. } else {
  5613. packet("f", moveMent.dir, 1);
  5614. }
  5615. },
  5616. this.boostTickMovement = function() {
  5617. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  5618. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5619. let moveMent = this.gotoGoal(372, 3);
  5620. if (moveMent.action) {
  5621. if (player.reloads[53] == 0 && !this.isTrue) {
  5622. this.boostTickType();
  5623. } else {
  5624. packet("f", moveMent.dir, 1);
  5625. }
  5626. } else {
  5627. packet("f", moveMent.dir, 1);
  5628. }
  5629. }
  5630. /** wait 1 tick for better quality */
  5631. this.perfCheck = function(pl, nr) {
  5632. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5633. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5634. let pjs = {
  5635. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5636. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5637. };
  5638. 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)) {
  5639. return true;
  5640. }
  5641. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5642. 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)) {
  5643. return true;
  5644. }
  5645. });
  5646. if (finds) return false;
  5647. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5648. let tmpScale = tmp.getScale();
  5649. 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)) {
  5650. return true;
  5651. }
  5652. });
  5653. if (finds) return false;
  5654. return true;
  5655. }
  5656. }
  5657. };
  5658. class Autobuy {
  5659. constructor(buyHat, buyAcc) {
  5660. this.hat = function() {
  5661. buyHat.forEach((id) => {
  5662. let find = findID(hats, id);
  5663. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5664. });
  5665. };
  5666. this.acc = function() {
  5667. buyAcc.forEach((id) => {
  5668. let find = findID(accessories, id);
  5669. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5670. });
  5671. };
  5672. }
  5673. };
  5674.  
  5675. class Autoupgrade {
  5676. constructor() {
  5677. this.sb = function(upg) {
  5678. upg(3);
  5679. upg(17);
  5680. upg(31);
  5681. upg(23);
  5682. upg(9);
  5683. upg(38);
  5684. };
  5685. this.kh = function(upg) {
  5686. upg(3);
  5687. upg(17);
  5688. upg(31);
  5689. upg(23);
  5690. upg(10);
  5691. upg(38);
  5692. upg(4);
  5693. upg(25);
  5694. };
  5695. this.pb = function(upg) {
  5696. upg(5);
  5697. upg(17);
  5698. upg(32);
  5699. upg(23);
  5700. upg(9);
  5701. upg(38);
  5702. };
  5703. this.ph = function(upg) {
  5704. upg(5);
  5705. upg(17);
  5706. upg(32);
  5707. upg(23);
  5708. upg(10);
  5709. upg(38);
  5710. upg(28);
  5711. upg(25);
  5712. };
  5713. this.db = function(upg) {
  5714. upg(7);
  5715. upg(17);
  5716. upg(31);
  5717. upg(23);
  5718. upg(9);
  5719. upg(34);
  5720. };
  5721. };
  5722. };
  5723.  
  5724. class Damages {
  5725. constructor(items) {
  5726. // 0.75 1 1.125 1.5
  5727. this.calcDmg = function(dmg, val) {
  5728. return dmg * val;
  5729. };
  5730. this.getAllDamage = function(dmg) {
  5731. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5732. };
  5733. this.weapons = [];
  5734. for (let i = 0; i < items.weapons.length; i++) {
  5735. let wp = items.weapons[i];
  5736. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5737. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5738. this[name] = this.weapons[i];
  5739. }
  5740. }
  5741. }
  5742.  
  5743. /** CLASS CODES */
  5744. // jumpscare code warn
  5745. let tmpList = [];
  5746. var bianosTick = false;
  5747.  
  5748.  
  5749. // LOADING:
  5750. let UTILS = new Utils();
  5751. let items = new Items();
  5752. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5753. let store = new Store();
  5754. let hats = store.hats;
  5755. let accessories = store.accessories;
  5756. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5757. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5758. let textManager = new Textmanager();
  5759.  
  5760. let traps = new Traps(UTILS, items);
  5761. let instaC = new Instakill();
  5762. let autoBuy = new Autobuy([6,7, 22, 12, 53, 40], [11 , 13, 19]);
  5763. let autoUpgrade = new Autoupgrade();
  5764.  
  5765. let lastDeath;
  5766. let minimapData;
  5767. let mapMarker = {};
  5768. let mapPings = [];
  5769. let tmpPing;
  5770.  
  5771. let breakTrackers = [];
  5772.  
  5773. let pathFindTest = 0;
  5774. let grid = [];
  5775. let pathFind = {
  5776. active: false,
  5777. grid: 40,
  5778. scale: 1440,
  5779. x: 14400,
  5780. y: 14400,
  5781. chaseNear: false,
  5782. array: [],
  5783. lastX: this.grid / 2,
  5784. lastY: this.grid / 2
  5785. };
  5786.  
  5787. function sendChat(message) {
  5788. packet("6", message.slice(0, 30));
  5789. }
  5790.  
  5791. let runAtNextTick = [];
  5792.  
  5793. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5794. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5795. let projOffset = config.playerScale * 2;
  5796. let projXY = {
  5797. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5798. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5799. };
  5800. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5801. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5802. })[0];
  5803. if (nearPlayer) {
  5804. if (indx == 1) {
  5805. nearPlayer.shooting[53] = 1;
  5806. } else {
  5807. nearPlayer.shootIndex = weaponIndx;
  5808. nearPlayer.shooting[1] = 1;
  5809. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5810. }
  5811. }
  5812. }
  5813. let projectileCount = 0;
  5814.  
  5815. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5816. if (!tmpObj.isTeam(player)) {
  5817. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5818. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5819. tmpObj.bowThreat[weaponIndex]++;
  5820. if (index == 5) {
  5821. projectileCount++;
  5822. }
  5823. setTimeout(() => {
  5824. tmpObj.bowThreat[weaponIndex]--;
  5825. if (index == 5) {
  5826. projectileCount--;
  5827. }
  5828. }, range / speed);
  5829. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5830. place(1, tmpObj.aim2);
  5831. my.anti0Tick = 4;
  5832. if (!my.antiSync) {
  5833. antiSyncHealing(4);
  5834. }
  5835. } else {
  5836. if (projectileCount >= 2) {
  5837. place(1, tmpObj.aim2);
  5838. my.anti0Tick = 4;
  5839. if (!my.antiSync) {
  5840. antiSyncHealing(4);
  5841. }
  5842. }
  5843. }
  5844. }
  5845. }
  5846. }
  5847.  
  5848. // SHOW ITEM INFO:
  5849. function showItemInfo(item, isWeapon, isStoreItem) {
  5850. if (player && item) {
  5851. UTILS.removeAllChildren(itemInfoHolder);
  5852. itemInfoHolder.classList.add("visible");
  5853. UTILS.generateElement({
  5854. id: "itemInfoName",
  5855. text: UTILS.capitalizeFirst(item.name),
  5856. parent: itemInfoHolder
  5857. });
  5858. UTILS.generateElement({
  5859. id: "itemInfoDesc",
  5860. text: item.desc,
  5861. parent: itemInfoHolder
  5862. });
  5863. if (isStoreItem) {
  5864.  
  5865. } else if (isWeapon) {
  5866. UTILS.generateElement({
  5867. class: "itemInfoReq",
  5868. text: !item.type ? "primary" : "secondary",
  5869. parent: itemInfoHolder
  5870. });
  5871. } else {
  5872. for (let i = 0; i < item.req.length; i += 2) {
  5873. UTILS.generateElement({
  5874. class: "itemInfoReq",
  5875. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5876. parent: itemInfoHolder
  5877. });
  5878. }
  5879. if (item.group.limit) {
  5880. UTILS.generateElement({
  5881. class: "itemInfoLmt",
  5882. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5883. parent: itemInfoHolder
  5884. });
  5885. }
  5886. }
  5887. } else {
  5888. itemInfoHolder.classList.remove("visible");
  5889. }
  5890. }
  5891.  
  5892.  
  5893. // RESIZE:
  5894. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5895.  
  5896. function resize() {
  5897. screenWidth = window.innerWidth;
  5898. screenHeight = window.innerHeight;
  5899. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5900. gameCanvas.width = screenWidth * pixelDensity;
  5901. gameCanvas.height = screenHeight * pixelDensity;
  5902. gameCanvas.style.width = screenWidth + "px";
  5903. gameCanvas.style.height = screenHeight + "px";
  5904. mainContext.setTransform(
  5905. scaleFillNative, 0,
  5906. 0, scaleFillNative,
  5907. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5908. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5909. );
  5910. }
  5911. resize();
  5912.  
  5913. // MOUSE INPUT:
  5914. var usingTouch;
  5915. const mals = document.getElementById('touch-controls-fullscreen');
  5916. mals.style.display = 'block';
  5917. mals.addEventListener("mousemove", gameInput, false);
  5918.  
  5919. function gameInput(e) {
  5920. mouseX = e.clientX;
  5921. mouseY = e.clientY;
  5922. }
  5923. let clicks = {
  5924. left: false,
  5925. middle: false,
  5926. right: false,
  5927. };
  5928. let clicked = {
  5929. g: false
  5930. }
  5931. mals.addEventListener("mousedown", mouseDown, false);
  5932.  
  5933. function mouseDown(e) {
  5934. if (attackState != 1) {
  5935. attackState = 1;
  5936. if (e.button == 0) {
  5937. clicks.left = true;
  5938. } else if (e.button == 2) {
  5939. clicks.right = true;
  5940. }
  5941. }
  5942. }
  5943. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5944.  
  5945. function mouseUp(e) {
  5946. if (attackState != 0) {
  5947. attackState = 0;
  5948. if (e.button == 0) {
  5949. clicks.left = false;
  5950. } else if (e.button == 1) {
  5951. clicks.middle = false;
  5952. } else if (e.button == 2) {
  5953. clicks.right = false;
  5954. }
  5955. }
  5956. }
  5957. mals.addEventListener("wheel", wheel, false);
  5958.  
  5959. function wheel(e) {
  5960. if (e.deltaY < 0) {
  5961. wbe += 0.005
  5962. maxScreenWidth = config.maxScreenWidth * wbe;
  5963. maxScreenHeight = config.maxScreenHeight * wbe;
  5964. resize()
  5965. } else {
  5966. wbe -= 0.005
  5967. maxScreenWidth = config.maxScreenWidth * wbe;
  5968. maxScreenHeight = config.maxScreenHeight * wbe;
  5969. resize()
  5970. }
  5971. }
  5972.  
  5973. // INPUT UTILS:
  5974. function getMoveDir() {
  5975. let dx = 0;
  5976. let dy = 0;
  5977. for (let key in moveKeys) {
  5978. let tmpDir = moveKeys[key];
  5979. dx += !!keys[key] * tmpDir[0];
  5980. dy += !!keys[key] * tmpDir[1];
  5981. }
  5982. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5983. }
  5984.  
  5985. function getSafeDir() {
  5986. if (!player)
  5987. return 0;
  5988. if (!player.lockDir) {
  5989. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5990. }
  5991. return lastDir || 0;
  5992. }
  5993. let plusDir = 0;
  5994. let lastSpin = Date.now();
  5995. function getAttackDir(debug) {
  5996. if (debug) {
  5997. if (!player)
  5998. return "0";
  5999. if (my.autoAim || ((clicks.left || (useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap)) && player.reloads[player.weapons[0]] == 0))
  6000. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6001. else
  6002. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6003. lastDir = "getSafeDir()";
  6004. else
  6005. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  6006. lastDir = "traps.aim";
  6007. else
  6008. if (!player.lockDir) {
  6009. if (configs.noDir) return "undefined";
  6010. lastDir = "getSafeDir()";
  6011. }
  6012. return lastDir;
  6013. } else {
  6014. if (!player)
  6015. return 0;
  6016. if (my.autoAim || ((clicks.left || (useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap)) && player.reloads[player.weapons[0]] == 0))
  6017. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6018. else
  6019. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6020. lastDir = getSafeDir();
  6021. else
  6022. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  6023. lastDir = traps.aim;
  6024. else
  6025. if (!player.lockDir) {
  6026. if (configs.noDir) return undefined;
  6027. lastDir = getSafeDir();
  6028. }
  6029. return lastDir || 0;
  6030. }
  6031. }
  6032.  
  6033. function getVisualDir() {
  6034. if (!player)
  6035. return 0;
  6036. lastDir = getSafeDir();
  6037. return lastDir || 0;
  6038. }
  6039.  
  6040. // KEYS:
  6041. function keysActive() {
  6042. return (allianceMenu.style.display != "block" &&
  6043. chatHolder.style.display != "block" &&
  6044. !menuCBFocus);
  6045. }
  6046.  
  6047. function toggleMenuChat() {
  6048. if (menuChatDiv.style.display != "none") {
  6049. // chatHolder.style.display = "none";
  6050. // if (menuChatBox.value != "") {
  6051. //commands[command.slice(1)]
  6052. let cmd = function(command) {
  6053. return {
  6054. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6055. fv: commands[command.slice(1).split(" ")[0]]
  6056. }
  6057. }
  6058. let command = cmd(menuChatBox.value);
  6059. if (command.found) {
  6060. if (typeof command.fv.action === "function") {
  6061. command.fv.action(menuChatBox.value);
  6062. }
  6063. } else {
  6064. sendChat(menuChatBox.value);
  6065. }
  6066. menuChatBox.value = "";
  6067. menuChatBox.blur();
  6068. } else {
  6069. if (menuCBFocus) {
  6070. menuChatBox.blur();
  6071. } else {
  6072. menuChatBox.focus();
  6073. }
  6074. }
  6075. }
  6076.  
  6077. function keyDown(event) {
  6078. let keyNum = event.which || event.keyCode || 0;
  6079. if (player && player.alive && keysActive()) {
  6080. if (!keys[keyNum]) {
  6081. keys[keyNum] = 1;
  6082. macro[event.key] = 1;
  6083. if (keyNum == 27) {
  6084. openMenu = !openMenu;
  6085. $("#menuDiv").toggle();
  6086. } else if (keyNum == 69) {
  6087. sendAutoGather();
  6088. } else if (keyNum == 67) {
  6089. updateMapMarker();
  6090. } else if (keyNum == 71) {
  6091. clicked.g = !clicked.g
  6092. } else if (player.weapons[keyNum - 49] != undefined) {
  6093. player.weaponCode = player.weapons[keyNum - 49];
  6094. } else if (moveKeys[keyNum]) {
  6095. sendMoveDir();
  6096. } else if (event.key == "m") {
  6097. mills.placeSpawnPads = !mills.placeSpawnPads;
  6098. } else if (event.key == "z") {
  6099. mills.place = !mills.place;
  6100. } else if (event.key == "Z") {
  6101. typeof window.debug == "function" && window.debug();
  6102. } else if (keyNum == 32) {
  6103. packet("F", 1, getSafeDir(), 1);
  6104. packet("F", 0, getSafeDir(), 1);
  6105. }
  6106. }
  6107. }
  6108. }
  6109. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6110.  
  6111. function keyUp(event) {
  6112. if (player && player.alive) {
  6113. let keyNum = event.which || event.keyCode || 0;
  6114. if (keyNum == 13) {
  6115. toggleMenuChat();
  6116. } else if (keysActive()) {
  6117. if (keys[keyNum]) {
  6118. keys[keyNum] = 0;
  6119. macro[event.key] = 0;
  6120. if (moveKeys[keyNum]) {
  6121. sendMoveDir();
  6122. }
  6123. }
  6124. }
  6125. }
  6126. }
  6127. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6128.  
  6129. function sendMoveDir() {
  6130. let newMoveDir = getMoveDir();
  6131. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6132. if (!my.autoPush) {
  6133. packet("f", newMoveDir, 1);
  6134. }
  6135. lastMoveDir = newMoveDir;
  6136. }
  6137. }
  6138.  
  6139. // BUTTON EVENTS:
  6140. function bindEvents() {}
  6141. bindEvents();
  6142.  
  6143. /** PATHFIND TEST */
  6144. function chechPathColl(tmp) {
  6145. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6146. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6147. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6148. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6149. }
  6150.  
  6151. function checkObject() {
  6152. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6153. for (let y = 0; y < pathFind.grid; y++) {
  6154. grid[y] = [];
  6155. for (let x = 0; x < pathFind.grid; x++) {
  6156. let tmpXY = {
  6157. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6158. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6159. }
  6160. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6161. pathFind.lastX = x;
  6162. pathFind.lastY = y;
  6163. grid[y][x] = 0;
  6164. continue;
  6165. }
  6166. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6167. if (find) {
  6168. if (find.trap) {
  6169. grid[y][x] = 0;
  6170. continue;
  6171. }
  6172. grid[y][x] = 1;
  6173. } else {
  6174. grid[y][x] = 0;
  6175. }
  6176. }
  6177. }
  6178. }
  6179.  
  6180. function createPath() {
  6181. grid = [];
  6182. checkObject();
  6183. }
  6184.  
  6185. function Pathfinder() {
  6186. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  6187. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  6188. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6189. packet("f", undefined, 1);
  6190. } else {
  6191. createPath();
  6192. easystar.setGrid(grid);
  6193. easystar.setAcceptableTiles([0]);
  6194. easystar.enableDiagonals();
  6195. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  6196. if (path === null) {
  6197. pathFind.array = [];
  6198. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  6199. packet("f", undefined, 1);
  6200. } else {
  6201. packet("f", near.aim2, 1);
  6202. }
  6203. } else {
  6204. pathFind.array = path;
  6205. if (pathFind.array.length > 1) {
  6206. let tmpXY = {
  6207. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  6208. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  6209. }
  6210. packet("f", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  6211. }
  6212. }
  6213. });
  6214. easystar.calculate();
  6215. }
  6216. }
  6217. }
  6218. /** PATHFIND TEST */
  6219.  
  6220. // ITEM COUNT DISPLAY:
  6221. let isItemSetted = [];
  6222.  
  6223. function updateItemCountDisplay(index = undefined) {
  6224. for (let i = 3; i < items.list.length; ++i) {
  6225. let id = items.list[i].group.id;
  6226. let tmpI = items.weapons.length + i;
  6227. if (!isItemSetted[tmpI]) {
  6228. isItemSetted[tmpI] = document.createElement("div");
  6229. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6230. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6231. isItemSetted[tmpI].style = `
  6232. display: block;
  6233. position: absolute;
  6234. padding-left: 5px;
  6235. font-size: 2em;
  6236. color: #fff;
  6237. `;
  6238. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6239. } else {
  6240. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6241. }
  6242. }
  6243. }
  6244.  
  6245. // AUTOPUSH:
  6246. function autoPush() {
  6247. 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) {
  6248. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6249. })[0];
  6250. if (nearTrap) {
  6251. 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) {
  6252. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6253. })[0];
  6254. if (spike) {
  6255. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  6256.  
  6257. /*let pos = {
  6258. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6259. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6260. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  6261. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  6262. };
  6263. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6264. let tmpScale = tmp.getScale();
  6265. 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)) {
  6266. return true;
  6267. }
  6268. });
  6269. if (finds) {
  6270. if (my.autoPush) {
  6271. my.autoPush = false;
  6272. packet("f", lastMoveDir || undefined, 1);
  6273. }
  6274. } else {*/
  6275. my.autoPush = true;
  6276. sendChat("<//FMA PUSHING//>");
  6277. my.pushData = {
  6278. x: spike.x + Math.cos(pushAngle),
  6279. y: spike.y + Math.sin(pushAngle),
  6280. x2: player.x2+30,
  6281. y2: player.y2+30
  6282. };
  6283.  
  6284. let point = {
  6285. x: near.x2 + Math.cos(pushAngle) * 30,
  6286. y: near.y2 + Math.sin(pushAngle) * 60,
  6287. }
  6288.  
  6289. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  6290.  
  6291. packet("f", dir, 1)
  6292. /*let scale = (player.scale / 10);
  6293. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6294. packet("f", near.aim2, 1);
  6295. } else {
  6296. packet("f", UTILS.getDirect(pos, player, 2, 2), 1);
  6297. }*/
  6298. //}
  6299. } else {
  6300. if (my.autoPush) {
  6301. my.autoPush = false;
  6302. packet("f", lastMoveDir || undefined, 1);
  6303. }
  6304. }
  6305. } else {
  6306. if (my.autoPush) {
  6307. my.autoPush = false;
  6308. packet("f", lastMoveDir || undefined, 1);
  6309. }
  6310. }
  6311. }
  6312.  
  6313.  
  6314. class AutoPush {
  6315. socket = null;
  6316.  
  6317. findIntersect(vec, vec1, vec2) {
  6318. // Find point of vec1 and vec2 intersection
  6319. const delta = Math.hypot(vec1.x - vec2.x, vec1.y - vec2.y) / 2;
  6320. const tang = Math.tan((vec1.y - vec2.y) / (vec1.x - vec2.x));
  6321. const vec3x = Math.cos(tang) * delta;
  6322. const vec3y = Math.sin(tang) * delta;
  6323. // Find angle from vec to vec3
  6324. const theta = Math.tan((vec.y - vec3y) / (vec.x - vec3x));
  6325.  
  6326. return theta;
  6327. };
  6328.  
  6329. pushEnemy(player, enemy, spike) {
  6330. const angle = this.findIntersect(enemy, spike, player);
  6331. const dist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
  6332.  
  6333. if (dist > 180) return;
  6334.  
  6335. this.socket.send("f", angle);
  6336. };
  6337.  
  6338. constructor(socket) {
  6339. this.socket = socket;
  6340. }
  6341. }
  6342.  
  6343. // ADD DEAD PLAYER:
  6344. function addDeadPlayer(tmpObj) {
  6345. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6346. }
  6347.  
  6348. /** APPLY SOCKET CODES */
  6349.  
  6350. // SET INIT DATA:
  6351. function setInitData(data) {
  6352. alliances = data.teams;
  6353. }
  6354.  
  6355. // SETUP GAME:
  6356. function setupGame(yourSID) {
  6357. keys = {};
  6358. macro = {};
  6359. playerSID = yourSID;
  6360. attackState = 0;
  6361. inGame = true;
  6362. packet("F", 0, getAttackDir(), 1);
  6363. my.ageInsta = true;
  6364. if (firstSetup) {
  6365. firstSetup = false;
  6366. gameObjects.length = 0;
  6367. liztobj.length = 0;
  6368. }
  6369. }
  6370.  
  6371. // ADD NEW PLAYER:
  6372. function addPlayer(data, isYou) {
  6373. let tmpPlayer = findPlayerByID(data[0]);
  6374. if (!tmpPlayer) {
  6375. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6376. objectManager, players, ais, items, hats, accessories);
  6377. players.push(tmpPlayer);
  6378. if (data[1] != playerSID) {
  6379. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6380. }
  6381. } else {
  6382. if (data[1] != playerSID) {
  6383. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6384. }
  6385. }
  6386. tmpPlayer.spawn(isYou ? true : null);
  6387. tmpPlayer.visible = false;
  6388. tmpPlayer.oldPos = {
  6389. x2: undefined,
  6390. y2: undefined
  6391. };
  6392. tmpPlayer.x2 = undefined;
  6393. tmpPlayer.y2 = undefined;
  6394. tmpPlayer.x3 = undefined;
  6395. tmpPlayer.y3 = undefined;
  6396. tmpPlayer.setData(data);
  6397. if (isYou) {
  6398. if (!player) {
  6399. window.prepareUI(tmpPlayer);
  6400. }
  6401. player = tmpPlayer;
  6402. camX = player.x;
  6403. camY = player.y;
  6404. my.lastDir = 0;
  6405. updateItems();
  6406. updateAge();
  6407. updateItemCountDisplay();
  6408. if (player.skins[7]) {
  6409. my.reSync = true;
  6410. }
  6411. }
  6412. }
  6413.  
  6414. // REMOVE PLAYER:
  6415. function removePlayer(id) {
  6416. for (let i = 0; i < players.length; i++) {
  6417. if (players[i].id == id) {
  6418. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6419. players.splice(i, 1);
  6420. break;
  6421. }
  6422. }
  6423. }
  6424.  
  6425. // UPDATE HEALTH:
  6426. function updateHealth(sid, value) {
  6427. tmpObj = findPlayerBySID(sid);
  6428. if (tmpObj) {
  6429. tmpObj.oldHealth = tmpObj.health;
  6430. tmpObj.health = value;
  6431. tmpObj.judgeShame();
  6432. if (tmpObj.oldHealth > tmpObj.health) {
  6433. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6434. advHeal.push([sid, value, tmpObj.damaged]);
  6435. } else {}
  6436. if (tmpObj.health <= 0) {
  6437. /*bots.forEach((hmm) => {
  6438. hmm.whyDie = tmpObj.name;
  6439. });*/
  6440. }
  6441. }
  6442. }
  6443.  
  6444.  
  6445. // KILL PLAYER:
  6446. function killPlayer() {
  6447. inGame = false;
  6448. lastDeath = {
  6449. x: player.x,
  6450. y: player.y,
  6451. };
  6452. if (configs.autoRespawn) {
  6453. getEl("diedText").style.display = "none";
  6454. packet("M", {
  6455. name: lastsp[0],
  6456. moofoll: lastsp[1],
  6457. skin: lastsp[2]
  6458. });
  6459. }
  6460. }
  6461.  
  6462. // UPDATE PLAYER ITEM VALUES:
  6463. function updateItemCounts(index, value) {
  6464. if (player) {
  6465. player.itemCounts[index] = value;
  6466. updateItemCountDisplay(index);
  6467. }
  6468. }
  6469.  
  6470. // UPDATE AGE:
  6471. function updateAge(xp, mxp, age) {
  6472. if (xp != undefined)
  6473. player.XP = xp;
  6474. if (mxp != undefined)
  6475. player.maxXP = mxp;
  6476. if (age != undefined)
  6477. player.age = age;
  6478. }
  6479.  
  6480. // UPDATE UPGRADES:
  6481. function updateUpgrades(points, age) {
  6482. player.upgradePoints = points;
  6483. player.upgrAge = age;
  6484. if (points > 0) {
  6485. tmpList.length = 0;
  6486. UTILS.removeAllChildren(upgradeHolder);
  6487. for (let i = 0; i < items.weapons.length; ++i) {
  6488. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6489. let e = UTILS.generateElement({
  6490. id: "upgradeItem" + i,
  6491. class: "actionBarItem",
  6492. onmouseout: function() {
  6493. showItemInfo();
  6494. },
  6495. parent: upgradeHolder
  6496. });
  6497. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6498. tmpList.push(i);
  6499. }
  6500. }
  6501. for (let i = 0; i < items.list.length; ++i) {
  6502. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6503. let tmpI = (items.weapons.length + i);
  6504. let e = UTILS.generateElement({
  6505. id: "upgradeItem" + tmpI,
  6506. class: "actionBarItem",
  6507. onmouseout: function() {
  6508. showItemInfo();
  6509. },
  6510. parent: upgradeHolder
  6511. });
  6512. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6513. tmpList.push(tmpI);
  6514. }
  6515. }
  6516. for (let i = 0; i < tmpList.length; i++) {
  6517. (function(i) {
  6518. let tmpItem = getEl('upgradeItem' + i);
  6519. // tmpItem.onmouseover = function() {
  6520. // if (items.weapons[i]) {
  6521. // showItemInfo(items.weapons[i], true);
  6522. // } else {
  6523. // showItemInfo(items.list[i - items.weapons.length]);
  6524. // }
  6525. // };
  6526. tmpItem.onclick = UTILS.checkTrusted(function() {
  6527. packet("H", i);
  6528. });
  6529. UTILS.hookTouchEvents(tmpItem);
  6530. })(tmpList[i]);
  6531. }
  6532. if (tmpList.length) {
  6533. upgradeHolder.style.display = "block";
  6534. upgradeCounter.style.display = "block";
  6535. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6536. } else {
  6537. upgradeHolder.style.display = "none";
  6538. upgradeCounter.style.display = "none";
  6539. showItemInfo();
  6540. }
  6541. } else {
  6542. upgradeHolder.style.display = "none";
  6543. upgradeCounter.style.display = "none";
  6544. showItemInfo();
  6545. }
  6546. }
  6547.  
  6548. // KILL OBJECT:
  6549. function killObject(sid) {
  6550. let findObj = findObjectBySid(sid);
  6551. objectManager.disableBySid(sid);
  6552. if (player) {
  6553. for (let i = 0; i < breakObjects.length; i++) {
  6554. if (breakObjects[i].sid == sid) {
  6555. breakObjects.splice(i, 1);
  6556. break;
  6557. }
  6558. }
  6559. if (!player.canSee(findObj)) {
  6560. breakTrackers.push({
  6561. x: findObj.x,
  6562. y: findObj.y
  6563. });
  6564. }
  6565. if (breakTrackers.length > 8) {
  6566. breakTrackers.shift();
  6567. }
  6568. traps.replacer(findObj);
  6569. }
  6570. }
  6571.  
  6572. // KILL ALL OBJECTS BY A PLAYER:
  6573. function killObjects(sid) {
  6574. if (player) objectManager.removeAllItems(sid);
  6575. }
  6576. function setTickout(doo, timeout) {
  6577. if (!ticks.manage[ticks.tick + timeout]) {
  6578. ticks.manage[ticks.tick + timeout] = [doo];
  6579. } else {
  6580. ticks.manage[ticks.tick + timeout].push(doo);
  6581. }
  6582. }
  6583.  
  6584. function caf(e, t) {
  6585. try {
  6586. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6587. } catch (e) {
  6588. return 0;
  6589. }
  6590. }
  6591.  
  6592. let found = false;
  6593. let autoQ = false;
  6594.  
  6595. let autos = {
  6596. insta: {
  6597. todo: false,
  6598. wait: false,
  6599. count: 4,
  6600. shame: 5
  6601. },
  6602. bull: false,
  6603. antibull: 0,
  6604. reloaded: false,
  6605. stopspin: true
  6606. }
  6607.  
  6608. // UPDATE PLAYER DATA:
  6609. function updatePlayers(data) {
  6610. // if(player.shameCount > 0) {
  6611. // my.reSync = true;
  6612. // } else {
  6613. // my.reSync = false;
  6614. // }
  6615.  
  6616. // let movementPrediction = {
  6617. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6618. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6619. // }
  6620.  
  6621. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6622.  
  6623. // potentialzpiketick.forEach((obj) => {
  6624. // if(cdf(obj, player) <= 200) {
  6625. // packet('a', undefined);
  6626. // }
  6627. // })
  6628.  
  6629. // let newPos = {
  6630. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6631. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6632. // }
  6633.  
  6634. function getAngleDifference(angle1, angle2) {
  6635. // Normalize the angles to be between 0 and 2π
  6636. angle1 = angle1 % (2 * Math.PI);
  6637. angle2 = angle2 % (2 * Math.PI);
  6638.  
  6639. // Calculate the absolute difference between the angles
  6640. let diff = Math.abs(angle1 - angle2);
  6641.  
  6642. // Adjust the difference to be between 0 and π
  6643. if (diff > Math.PI) {
  6644. diff = (2 * Math.PI) - diff;
  6645. }
  6646.  
  6647. return diff;
  6648. }
  6649.  
  6650. // function smartMove(oneTickMove) {
  6651. // let dir = player.moveDir;
  6652.  
  6653. // let found = false
  6654. // let buildings = liztobj.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x))
  6655. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  6656.  
  6657. // let newPos = {
  6658. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  6659. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  6660. // }
  6661.  
  6662. // for (let i = 0; i < spikes.length; i++) {
  6663. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  6664. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  6665. // }
  6666. // }
  6667.  
  6668.  
  6669.  
  6670.  
  6671.  
  6672. // if (found != false && !traps.inTrap) {
  6673. // packet("f", undefined);
  6674. // } else {
  6675. // packet("f", dir);
  6676. // }
  6677. // player.oldPos.x2 = player.x2;
  6678. // player.oldPos.y2 = player.y2;
  6679. // }
  6680. // function detectEnemySpikeCollisions(tmpObj) {
  6681. // let buildings = liztobj.sort((a, b) => Math.hypot(tmpObj.y - a.y, tmpObj.x - a.x) - Math.hypot(tmpObj.y - b.y, tmpObj.x - b.x));
  6682. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  6683. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  6684. // let enemy = {
  6685. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  6686. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  6687. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6688. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6689. // }
  6690. // let found = false;
  6691. // for (let i = 0; i < spikes.length; i++) {
  6692. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  6693. // found = true;
  6694. // }
  6695. // }
  6696.  
  6697. // // player.oldPos.x2 = tmpObj.x2;
  6698. // // player.oldPos.y2 = tmpObj.y2;
  6699. // }
  6700.  
  6701. game.tick++;
  6702. enemy = [];
  6703. nears = [];
  6704. near = [];
  6705. game.tickSpeed = performance.now() - game.lastTick;
  6706. game.lastTick = performance.now();
  6707. players.forEach((tmp) => {
  6708. tmp.forcePos = !tmp.visible;
  6709. tmp.visible = false;
  6710. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6711. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6712. });
  6713. for (let i = 0; i < data.length;) {
  6714. tmpObj = findPlayerBySID(data[i]);
  6715. if (tmpObj) {
  6716. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6717. tmpObj.t2 = game.lastTick;
  6718. tmpObj.oldPos.x2 = tmpObj.x2;
  6719. tmpObj.oldPos.y2 = tmpObj.y2;
  6720. tmpObj.x1 = tmpObj.x;
  6721. tmpObj.y1 = tmpObj.y;
  6722. tmpObj.x2 = data[i + 1];
  6723. tmpObj.y2 = data[i + 2];
  6724. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6725. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6726. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6727. tmpObj.d2 = data[i + 3];
  6728. tmpObj.dt = 0;
  6729. tmpObj.buildIndex = data[i + 4];
  6730. tmpObj.weaponIndex = data[i + 5];
  6731. tmpObj.weaponVariant = data[i + 6];
  6732. tmpObj.team = data[i + 7];
  6733. tmpObj.isLeader = data[i + 8];
  6734. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6735. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6736. tmpObj.skinIndex = data[i + 9];
  6737. tmpObj.tailIndex = data[i + 10];
  6738. tmpObj.iconIndex = data[i + 11];
  6739. tmpObj.zIndex = data[i + 12];
  6740. tmpObj.visible = true;
  6741. tmpObj.update(game.tickSpeed);
  6742. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6743. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6744. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6745. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6746. tmpObj.damageThreat = 0;
  6747. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6748. tmpObj.addShameTimer();
  6749. }
  6750. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6751. tmpObj.shameTimer = 0;
  6752. tmpObj.shameCount = 0;
  6753. if (tmpObj == player) {
  6754. healer();
  6755. }
  6756. }
  6757.  
  6758. botSkts.forEach((bot) => {
  6759. bot.showName = 'YEAHHH'
  6760. })
  6761.  
  6762. for(let i = 0; i < players.length; i++) {
  6763. for(let aa = 0; aa < botSkts.length; aa++) {
  6764. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6765.  
  6766. }
  6767. }
  6768.  
  6769. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6770. autoQ = true;
  6771. healer();
  6772. } else {
  6773. if (autoQ) {
  6774. healer();
  6775. }
  6776. autoQ = false;
  6777. }
  6778.  
  6779.  
  6780. if (tmpObj == player) {
  6781. if (liztobj.length) {
  6782. liztobj.forEach((tmp) => {
  6783. tmp.onNear = false;
  6784. if (tmp.active) {
  6785. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6786. tmp.onNear = true;
  6787. }
  6788. if (tmp.isItem && tmp.owner) {
  6789. 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)) {
  6790. tmp.breakObj = true;
  6791. breakObjects.push({
  6792. x: tmp.x,
  6793. y: tmp.y,
  6794. sid: tmp.sid
  6795. });
  6796. }
  6797. }
  6798. }
  6799. });
  6800. let nearTrap = liztobj.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 25) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  6801. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6802. })[0];
  6803. if (nearTrap) {
  6804. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6805. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6806. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6807.  
  6808. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6809. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6810. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6811. traps.inTrap = true;
  6812. traps.info = nearTrap;
  6813. } else {
  6814. traps.inTrap = false;
  6815. traps.info = {};
  6816. }
  6817. } else {
  6818. traps.inTrap = false;
  6819. }
  6820. }
  6821. if (tmpObj.weaponIndex < 9) {
  6822. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6823. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6824. } else if (tmpObj.weaponIndex > 8) {
  6825. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6826. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6827. }
  6828. }
  6829. i += 13;
  6830. }
  6831. if (textManager.stack.length) {
  6832. let stacks = [];
  6833. let notstacks = [];
  6834. let num = 0;
  6835. let num2 = 0;
  6836. let pos = {
  6837. x: null,
  6838. y: null
  6839. };
  6840. let pos2 = {
  6841. x: null,
  6842. y: null
  6843. }
  6844. textManager.stack.forEach((text) => {
  6845. if (text.value >= 0) {
  6846. if (num == 0) pos = {
  6847. x: text.x,
  6848. y: text.y
  6849. };
  6850. num += Math.abs(text.value);
  6851. } else {
  6852. if (num2 == 0) pos2 = {
  6853. x: text.x,
  6854. y: text.y
  6855. };
  6856. num2 += Math.abs(text.value);
  6857. }
  6858. });
  6859. if (num2 > 0) {
  6860. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#FF0000");
  6861. }
  6862. if (num > 0) {
  6863. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6864. }
  6865. textManager.stack = [];
  6866. }
  6867. if (runAtNextTick.length) {
  6868. runAtNextTick.forEach((tmp) => {
  6869. checkProjectileHolder(...tmp);
  6870. });
  6871. runAtNextTick = [];
  6872. }
  6873. for (let i = 0; i < data.length;) {
  6874. tmpObj = findPlayerBySID(data[i]);
  6875. if (tmpObj) {
  6876. if (!tmpObj.isTeam(player)) {
  6877. enemy.push(tmpObj);
  6878. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6879. nears.push(tmpObj);
  6880. }
  6881. }
  6882. tmpObj.manageReload();
  6883. if (tmpObj != player) {
  6884. tmpObj.addDamageThreat(player);
  6885. }
  6886. }
  6887. i += 13;
  6888. }
  6889. /*projectiles.forEach((proj) => {
  6890. tmpObj = proj;
  6891. if (tmpObj.active) {
  6892. tmpObj.tickUpdate(game.tickSpeed);
  6893. }
  6894. });*/
  6895. if (player && player.alive) {
  6896. if (enemy.length) {
  6897. near = enemy.sort(function(tmp1, tmp2) {
  6898. return tmp1.dist2 - tmp2.dist2;
  6899. })[0];
  6900. } else {
  6901. // console.log("no enemy");
  6902. }
  6903. if (game.tickQueue[game.tick]) {
  6904. game.tickQueue[game.tick].forEach((action) => {
  6905. action();
  6906. });
  6907. game.tickQueue[game.tick] = null;
  6908. }
  6909. if (advHeal.length) {
  6910. advHeal.forEach((updHealth) => {
  6911. if (window.pingTime < 150) {
  6912. let sid = updHealth[0];
  6913. let value = updHealth[1];
  6914. let totalDamage = 100 - value
  6915. let damaged = updHealth[2];
  6916. tmpObj = findPlayerBySID(sid);
  6917. let bullTicked = false;
  6918. if (tmpObj == player) {
  6919. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6920. if (my.reSync) {
  6921. my.reSync = false;
  6922. tmpObj.setBullTick = true;
  6923. }
  6924. bullTicked = true;
  6925. }
  6926. if (inGame) {
  6927. let attackers = getAttacker(damaged);
  6928. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6929. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6930. let healTimeout = 140 - window.pingTime;
  6931. let dmg = 100 - player.health;
  6932. let slowHeal = function (timer, tickBase) {
  6933. if (!tickBase) {
  6934. setTimeout(() => {
  6935. healer();
  6936. }, timer);
  6937. } else {
  6938. game.tickBase(() => {
  6939. healer()
  6940. }, 2)
  6941. }
  6942. }
  6943. if (getEl("healingBeta").checked) {
  6944. if (enemy.length) {
  6945. if ([0, 7, 8].includes(near.primaryIndex)) {
  6946. if (damaged < 75) {
  6947. slowHeal(healTimeout)
  6948. } else {
  6949. healer()
  6950. }
  6951. }
  6952. if ([1, 2, 6].includes(near.primaryIndex)) {
  6953. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  6954. healer()
  6955. } else {
  6956. slowHeal(healTimeout)
  6957. }
  6958. }
  6959. if (near.primaryIndex == 3) {
  6960. if (near.secondaryIndex == 15) {
  6961. if (near.primaryVariant < 2) {
  6962. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6963. tmpObj.canEmpAnti = true
  6964. tmpObj.antiTimer = game.tick
  6965. healer()
  6966. } else {
  6967. slowHeal(healTimeout)
  6968. }
  6969. } else {
  6970. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6971. tmpObj.canEmpAnti = true
  6972. tmpObj.antiTimer = game.tick
  6973. healer()
  6974. } else {
  6975. slowHeal(healTimeout)
  6976. }
  6977. }
  6978. } else {
  6979. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6980. healer()
  6981. } else {
  6982. slowHeal(healTimeout)
  6983. }
  6984. }
  6985. }
  6986. if (near.primaryIndex == 4) {
  6987. if (near.primaryVariant >= 1) {
  6988. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6989. healer()
  6990. } else {
  6991. slowHeal(healTimeout)
  6992. }
  6993. } else {
  6994. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  6995. healer()
  6996. } else {
  6997. slowHeal(healTimeout)
  6998. }
  6999. }
  7000. }
  7001. if ([undefined, 5].includes(near.primaryIndex)) {
  7002. if (near.secondaryIndex == 10) {
  7003. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  7004. healer()
  7005. } else {
  7006. slowHeal(healTimeout)
  7007. }
  7008. } else
  7009. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  7010. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  7011. healer()
  7012. } else {
  7013. slowHeal(healTimeout)
  7014. }
  7015. } else
  7016. if ([undefined || 15].includes(near.secondaryIndex)) {
  7017. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  7018. if (tmpObj.shameCount < 5) {
  7019. healer()
  7020. } else {
  7021. slowHeal(healTimeout)
  7022. }
  7023. } else {
  7024. slowHeal(healTimeout)
  7025. }
  7026. } else
  7027. if ([9, 12, 13].includes(near.secondaryIndex)) {
  7028. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  7029. healer()
  7030. } else {
  7031. slowHeal(healTimeout)
  7032. }
  7033. } else {
  7034. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  7035. healer()
  7036. } else {
  7037. slowHeal(healTimeout)
  7038. }
  7039. }
  7040. }
  7041. if (near.primaryIndex == 6) {
  7042. if (near.secondaryIndex == 15) {
  7043. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7044. healer()
  7045. } else {
  7046. slowHeal(healTimeout)
  7047. }
  7048. } else {
  7049. if (damaged >= 70 && tmpObj.shameCount < 4) {
  7050. healer()
  7051. } else {
  7052. slowHeal(healTimeout)
  7053. }
  7054. }
  7055. }
  7056. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7057. } else {
  7058. if (damaged >= 70) {
  7059. healer()
  7060. } else {
  7061. slowHeal(healTimeout)
  7062. }
  7063. }
  7064. } else {
  7065. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  7066. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  7067. tmpObj.canEmpAnti = true;
  7068. } else {
  7069. player.soldierAnti = true;
  7070. }
  7071. tmpObj.antiTimer = game.tick;
  7072. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  7073. if (tmpObj.shameCount < shame) {
  7074. healer();
  7075. } else {
  7076. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  7077. slowHeal(healTimeout)
  7078. } else {
  7079. slowHeal(healTimeout, 1)
  7080. }
  7081. }
  7082. } else {
  7083. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  7084. slowHeal(healTimeout)
  7085. } else {
  7086. slowHeal(healTimeout, 1)
  7087. }
  7088. }
  7089. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7090. }
  7091. } else {
  7092. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7093. tmpObj.setPoisonTick = true;
  7094. }
  7095. }
  7096. }
  7097. } else {
  7098. let [sid, value, damaged] = updHealth;
  7099. let totalDamage = 100 - value;
  7100. let tmpObj = findPlayerBySID(sid);
  7101. let bullTicked = false;
  7102.  
  7103. if (tmpObj == player) {
  7104. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7105. if (my.reSync) {
  7106. my.reSync = false;
  7107. tmpObj.setBullTick = true;
  7108. bullTicked = true;
  7109. }
  7110. }
  7111. if (inGame) {
  7112. let attackers = getAttacker(damaged);
  7113. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7114. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  7115. let healTimeout = 60;
  7116. let dmg = 100 - player.health;
  7117. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  7118.  
  7119. let slowHeal = function (timer, tickBase) {
  7120. if (!tickBase) setTimeout(() => healer(), timer);
  7121. else game.tickBase(() => healer(), 2);
  7122. };
  7123.  
  7124. if (getEl("healingBeta").checked) {
  7125. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 :
  7126. [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 :
  7127. [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 :
  7128. near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 :
  7129. near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  7130. damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 :
  7131. near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  7132. damaged >= 25 && player.damageThreat + dmg >= 95;
  7133.  
  7134. canHealFast ? healer() : slowHeal(healTimeout);
  7135. } else {
  7136. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1;
  7137.  
  7138. if (canHealFast) {
  7139. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) tmpObj.canEmpAnti = true;
  7140. else player.soldierAnti = true;
  7141. tmpObj.antiTimer = game.tick;
  7142. if (tmpObj.shameCount < shameCountThreshold) healer();
  7143. else slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  7144. } else {
  7145. slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  7146. }
  7147. }
  7148. } else {
  7149. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7150. tmpObj.setPoisonTick = true;
  7151. }
  7152. }
  7153. }
  7154. }
  7155. });
  7156. advHeal = [];
  7157. }
  7158. players.forEach((tmp) => {
  7159. if (!tmp.visible && player != tmp) {
  7160. tmp.reloads = {
  7161. 0: 0,
  7162. 1: 0,
  7163. 2: 0,
  7164. 3: 0,
  7165. 4: 0,
  7166. 5: 0,
  7167. 6: 0,
  7168. 7: 0,
  7169. 8: 0,
  7170. 9: 0,
  7171. 10: 0,
  7172. 11: 0,
  7173. 12: 0,
  7174. 13: 0,
  7175. 14: 0,
  7176. 15: 0,
  7177. 53: 0,
  7178. };
  7179. }
  7180. if (tmp.setBullTick) {
  7181. tmp.bullTimer = 0;
  7182. }
  7183. if (tmp.setPoisonTick) {
  7184. tmp.poisonTimer = 0;
  7185. }
  7186. tmp.updateTimer();
  7187. });
  7188. if (inGame) {
  7189. if (enemy.length) {
  7190. if (player.canEmpAnti) {
  7191. player.canEmpAnti = false;
  7192. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7193. if (near.reloads[53] == 0) {
  7194. player.empAnti = true;
  7195. player.soldierAnti = false;
  7196. //modLog("EmpAnti");
  7197. } else {
  7198. player.empAnti = false;
  7199. player.soldierAnti = true;
  7200. //modLog("SoldierAnti");
  7201. }
  7202. }
  7203. }
  7204. let prehit = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function(a, b) {
  7205. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7206. })[0];
  7207. if (prehit) {
  7208. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  7209. instaC.canSpikeTick = true;
  7210. instaC.syncHit = true;
  7211. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7212. instaC.revTick = true;
  7213. }
  7214. }
  7215. }
  7216. 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) {
  7217. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7218. })[0];
  7219. if (antiSpikeTick && !traps.inTrap) {
  7220. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7221. my.anti0Tick = 1;
  7222. sendChat("");
  7223. player.chat.count = 2000;
  7224. }
  7225. }
  7226. }
  7227. if ((useWasd ? true : ((player.checkCanInsta(true) >= 220 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate))) && instaC.perfCheck(player, near)) {
  7228. if (player.checkCanInsta(true) >= 220) {
  7229. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  7230. } else {
  7231. instaC.nobull = false;
  7232. }
  7233. instaC.can = true;
  7234. } else {
  7235. instaC.can = false;
  7236. }
  7237. macro.q && place(0, getAttackDir());
  7238. macro.f && place(4, getSafeDir());
  7239. macro.v && place(2, getSafeDir());
  7240. macro.y && place(5, getSafeDir());
  7241. macro.h && place(player.getItemType(22), getSafeDir());
  7242. macro.n && place(3, getSafeDir());
  7243. if (game.tick % 1 == 0) {
  7244. if (mills.place) {
  7245. let plcAng = 7.7;
  7246. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7247. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7248. }
  7249. } else {
  7250. if (mills.placeSpawnPads) {
  7251. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7252. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7253. }
  7254. }
  7255. }
  7256. }
  7257. if (instaC.can) {
  7258. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  7259. }
  7260. if (instaC.canCounter) {
  7261. instaC.canCounter = false;
  7262. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7263. instaC.counterType();
  7264. }
  7265. }
  7266. if (instaC.canSpikeTick) {
  7267. instaC.canSpikeTick = false;
  7268. if (instaC.revTick) {
  7269. instaC.revTick = false;
  7270. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7271. instaC.changeType("rev");
  7272. chch(null, "[RevSyncHit]", "yellow");
  7273. }
  7274. } else {
  7275. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7276. instaC.spikeTickType();
  7277. if (instaC.syncHit) {
  7278. chch(null, "[SyncHit]", "yellow");
  7279. }
  7280. }
  7281. }
  7282. }
  7283. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7284. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7285. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7286. }
  7287. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7288. sendAutoGather();
  7289. my.waitHit = 1;
  7290. game.tickBase(() => {
  7291. sendAutoGather();
  7292. my.waitHit = 0;
  7293. }, 1);
  7294. }
  7295. }
  7296. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  7297. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  7298. selectWeapon(player.weapons[0]);
  7299. }
  7300. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  7301. sendAutoGather();
  7302. my.waitHit = 1;
  7303. game.tickBase(() => {
  7304. sendAutoGather();
  7305. my.waitHit = 0;
  7306. }, 1);
  7307. }
  7308. }
  7309. if (traps.inTrap) {
  7310. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7311. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7312. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7313. }
  7314. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7315. sendAutoGather();
  7316. my.waitHit = 1;
  7317. game.tickBase(() => {
  7318. sendAutoGather();
  7319. my.waitHit = 0;
  7320. }, 1);
  7321. }
  7322. }
  7323. }
  7324. if (macro["."] && !traps.inTrap) {
  7325. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7326. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7327. instaC.bowMovement();
  7328. } else {
  7329. instaC.rangeType();
  7330. }
  7331. }
  7332. }
  7333. if (macro.t && !traps.inTrap) {
  7334. 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))) {
  7335. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  7336. }
  7337. }
  7338. if (macro.g && !traps.inTrap) {
  7339. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  7340. instaC.boostTickMovement();
  7341. }
  7342. }
  7343. if (player.weapons[1] && !clicks.left && !clicks.right && !traps.inTrap && !instaC.isTrue && !(useWasd && near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8)) {
  7344. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7345. if (!my.reloaded) {
  7346. my.reloaded = true;
  7347. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7348. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7349. selectWeapon(player.weapons[fastSpeed]);
  7350. }
  7351. }
  7352. // if(useWasd) {
  7353. // if (!autos.stopspin) {
  7354. // setTimeout(()=>{
  7355. // autos.stopspin = true;
  7356. // }, 375);
  7357. // }
  7358. // }
  7359. } else {
  7360. my.reloaded = false;
  7361. if(useWasd) {
  7362. autos.stopspin = false;
  7363. }
  7364. if (player.reloads[player.weapons[0]] > 0) {
  7365. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7366. selectWeapon(player.weapons[0]);
  7367. }
  7368. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7369. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7370. selectWeapon(player.weapons[1]);
  7371. }
  7372. if(useWasd) {
  7373. if (!autos.stopspin) {
  7374. setTimeout(()=>{
  7375. autos.stopspin = true;
  7376. }, 750);
  7377. }
  7378. }
  7379. }
  7380. }
  7381. }
  7382. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  7383. traps.autoPlace();
  7384. }
  7385. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7386. packet("D", getAttackDir());
  7387. }
  7388. let hatChanger = function() {
  7389. if (my.anti0Tick > 0) {
  7390. buyEquip(6, 0);
  7391. } else {
  7392. if (clicks.left || clicks.right) {
  7393. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7394. buyEquip(7, 0);
  7395. buyEquip(13, 1);
  7396. } else {
  7397. if (clicks.left) {
  7398. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7399. } else if (clicks.right) {
  7400. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7401. }
  7402. }
  7403. } else if (traps.inTrap) {
  7404. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7405. buyEquip(40, 0);
  7406. } else {
  7407. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7408. buyEquip(7, 0);
  7409. buyEquip(13, 1);
  7410.  
  7411. } else {
  7412. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 22 : 6, 0);
  7413. }
  7414. }
  7415. } else {
  7416. if (player.empAnti || player.soldierAnti) {
  7417. buyEquip(player.empAnti ? 22 : 6, 0);
  7418. buyEquip(13, 1);
  7419. } else {
  7420. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7421. buyEquip(7, 0);
  7422. buyEquip(13, 1);
  7423. } else {
  7424. if (near.dist2 <= 300) {
  7425. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7426. } else {
  7427. biomeGear(1);
  7428. }
  7429. }
  7430. }
  7431. }
  7432. }
  7433. }
  7434. let accChanger = function () {
  7435. if (near.dist2 <= 270) {
  7436. if (clicks.left) {
  7437. buyEquip(13, 1);
  7438. } else if (!clicks.left){
  7439. buyEquip(13, 1);
  7440. }
  7441. }
  7442. else if (clicks.left) {
  7443. buyEquip(19,1);
  7444. }
  7445. else {
  7446. buyEquip(11, 1);
  7447. }
  7448. }
  7449. let wasdGears = function() {
  7450. if (my.anti0Tick > 0) {
  7451. buyEquip(12, 0);
  7452. } else {
  7453. if (clicks.left || clicks.right) {
  7454. if (clicks.left) {
  7455. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7456. } else if (clicks.right) {
  7457. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7458. }
  7459. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7460. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7461. } else if (traps.inTrap) {
  7462. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7463. buyEquip(40, 0);
  7464. } else {
  7465. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7466. buyEquip(7, 0);
  7467. } else {
  7468. buyEquip(player.empAnti ? 22 : 6, 0);
  7469. }
  7470. }
  7471. } else {
  7472. if (player.empAnti) {
  7473. buyEquip(22, 0);
  7474. } else {
  7475. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7476. buyEquip(7, 0);
  7477. } else {
  7478. buyEquip(6, 0);
  7479. }
  7480. }
  7481. }
  7482. }
  7483. if (clicks.left || clicks.right) {
  7484. if (clicks.left) {
  7485. buyEquip(0, 1);
  7486. }
  7487. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7488. buyEquip(0, 1);
  7489. } else if (traps.inTrap) {
  7490. buyEquip(0, 1);
  7491. } else {
  7492. buyEquip(11, 1);
  7493. }
  7494. }
  7495. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7496. if (useWasd) {
  7497. wasdGears();
  7498. } else {
  7499. hatChanger();
  7500. accChanger();
  7501. }
  7502. }
  7503. //lastMoveDir = getSafeDir();
  7504. //packet("f", lastMoveDir, 1);
  7505. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7506. autoPush();
  7507. } else {
  7508. if (my.autoPush) {
  7509. my.autoPush = false;
  7510. packet("f", lastMoveDir || undefined, 1);
  7511. }
  7512. }
  7513. if (!my.autoPush && pathFind.active) {
  7514. Pathfinder();
  7515. }
  7516. if (instaC.ticking) {
  7517. instaC.ticking = false;
  7518. }
  7519. if (instaC.syncHit) {
  7520. instaC.syncHit = false;
  7521. }
  7522. if (player.empAnti) {
  7523. player.empAnti = false;
  7524. }
  7525. if (player.soldierAnti) {
  7526. player.soldierAnti = false;
  7527. }
  7528. if (my.anti0Tick > 0) {
  7529. my.anti0Tick--;
  7530. }
  7531. if (traps.replaced) {
  7532. traps.replaced = false;
  7533. }
  7534. if (traps.antiTrapped) {
  7535. traps.antiTrapped = false;
  7536. }
  7537. const getPotentialDamage = (build, user) => {
  7538. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7539. const weap = user.weapons[weapIndex];
  7540. if (player.reloads[weap]) return 0;
  7541. const weapon = items.weapons[weap];
  7542. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7543. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7544. };
  7545.  
  7546. const AutoReplace = () => {
  7547. const replaceable = [];
  7548. const playerX = player.x;
  7549. const playerY = player.y;
  7550. const gameObjectCount = gameObjects.length;
  7551.  
  7552. for (let i = 0; i < gameObjectCount; i++) {
  7553. const build = gameObjects[i];
  7554. if (build.isItem && build.active && build.health > 0) {
  7555. const item = items.list[build.id];
  7556. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7557. const inDistance = cdf(build, player) <= posDist * 2;
  7558. if (inDistance) {
  7559. let canDeal = 0;
  7560. const playersCount = players.length;
  7561. for (let j = 0; j < playersCount; j++) {
  7562. canDeal += getPotentialDamage(build, players[j]);
  7563. }
  7564. if (build.health <= canDeal) {
  7565. replaceable.push(build);
  7566. }
  7567. }
  7568. }
  7569. }
  7570.  
  7571. const findPlacementAngle = (player, itemId, build) => {
  7572. if (!build) return null;
  7573. const MAX_ANGLE = 2 * Math.PI;
  7574. const ANGLE_STEP = Math.PI / 360;
  7575. const item = items.list[player.items[itemId]];
  7576. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7577. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7578.  
  7579. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7580. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7581. for (let angle of angles) {
  7582. return angle;
  7583. }
  7584. }
  7585. return null;
  7586. };
  7587.  
  7588. const replace = (() => {
  7589. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 7);
  7590. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 90 && !nearTrap.length);
  7591. const buildId = spike ? 6 : 4;
  7592.  
  7593. replaceable.forEach(build => {
  7594. let angle = findPlacementAngle(player, buildId, build);
  7595. if (angle !== null) {
  7596. place(buildId, angle);
  7597. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7598. }
  7599. });
  7600. });
  7601.  
  7602. if (near && near.dist3 <= 360) {
  7603. replace();
  7604. }
  7605. replace;
  7606. }
  7607. }
  7608. }
  7609. if (botSkts.length) {
  7610. botSkts.forEach((bots) => {
  7611. if (true) {
  7612. bots[0].showName = 'YEAHHH';
  7613. }
  7614. });
  7615. }
  7616. }
  7617. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7618. if (liztobj[i1].active && liztobj[i1].health > 0 && UTILS.getDist(liztobj[i1], player, 0, 2) < 150 && getEl("antipush").checked) { // || liztobj[i1].buildHealth <= items.weapons[nearEnemy.weaponIndex].dmg)
  7619.  
  7620. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7621. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7622. selectWeapon(player.weapons[1])
  7623. buyEquip(40, 0);
  7624. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7625. setTickout( () => {
  7626. buyEquip(6, 0)
  7627. }, 1);
  7628. }
  7629. }
  7630. }
  7631. }
  7632. function ez(context, x, y) {
  7633. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7634. context.beginPath();
  7635. context.fill();
  7636. context.closePath();
  7637. context.globalAlpha = 1;
  7638. }
  7639. // UPDATE LEADERBOARD:
  7640. function updateLeaderboard(data) {
  7641. lastLeaderboardData = data;
  7642. return;
  7643. UTILS.removeAllChildren(leaderboardData);
  7644. let tmpC = 1;
  7645. for (let i = 0; i < data.length; i += 3) {
  7646. (function(i) {
  7647. UTILS.generateElement({
  7648. class: "leaderHolder",
  7649. parent: leaderboardData,
  7650. children: [
  7651. UTILS.generateElement({
  7652. class: "leaderboardItem",
  7653. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7654. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7655. }),
  7656. UTILS.generateElement({
  7657. class: "leaderScore",
  7658. text: UTILS.sFormat(data[i + 2]) || "0"
  7659. })
  7660. ]
  7661. });
  7662. })(i);
  7663. tmpC++;
  7664. }
  7665. }
  7666.  
  7667. // LOAD GAME OBJECT:
  7668. function loadGameObject(data) {
  7669. for (let i = 0; i < data.length;) {
  7670. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7671. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7672. sid: data[i + 7]
  7673. } : null));
  7674. // sid, x, y, dir, s, type, data, setSID, owner
  7675. /*let dist = UTILS.getDist({
  7676. x: data[i + 1],
  7677. y: data[i + 2]
  7678. }, player, 0, 2);
  7679. let aim = UTILS.getDirect({
  7680. x: data[i + 1],
  7681. y: data[i + 2]
  7682. }, player, 0, 2);
  7683. find = findObjectBySid(data[i]);
  7684. if (data[i + 6] == 15) {
  7685. if (find && !find.isTeamObject(player)) {
  7686. if (dist <= 100) {
  7687. traps.dist = dist;
  7688. traps.aim = aim;
  7689. traps.protect(aim);
  7690. }
  7691. }
  7692. }*/
  7693. i += 8;
  7694. }
  7695. }
  7696.  
  7697. // ADD AI:
  7698. function loadAI(data) {
  7699. for (let i = 0; i < ais.length; ++i) {
  7700. ais[i].forcePos = !ais[i].visible;
  7701. ais[i].visible = false;
  7702. }
  7703. if (data) {
  7704. let tmpTime = performance.now();
  7705. for (let i = 0; i < data.length;) {
  7706. tmpObj = findAIBySID(data[i]);
  7707. if (tmpObj) {
  7708. tmpObj.index = data[i + 1];
  7709. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7710. tmpObj.t2 = tmpTime;
  7711. tmpObj.x1 = tmpObj.x;
  7712. tmpObj.y1 = tmpObj.y;
  7713. tmpObj.x2 = data[i + 2];
  7714. tmpObj.y2 = data[i + 3];
  7715. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7716. tmpObj.d2 = data[i + 4];
  7717. tmpObj.health = data[i + 5];
  7718. tmpObj.dt = 0;
  7719. tmpObj.visible = true;
  7720. } else {
  7721. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7722. tmpObj.x2 = tmpObj.x;
  7723. tmpObj.y2 = tmpObj.y;
  7724. tmpObj.d2 = tmpObj.dir;
  7725. tmpObj.health = data[i + 5];
  7726. if (!aiManager.aiTypes[data[i + 1]].name)
  7727. tmpObj.name = config.cowNames[data[i + 6]];
  7728. tmpObj.forcePos = true;
  7729. tmpObj.sid = data[i];
  7730. tmpObj.visible = true;
  7731. }
  7732. i += 7;
  7733. }
  7734. }
  7735. }
  7736.  
  7737. // ANIMATE AI:
  7738. function animateAI(sid) {
  7739. tmpObj = findAIBySID(sid);
  7740. if (tmpObj) tmpObj.startAnim();
  7741. }
  7742.  
  7743. // GATHER ANIMATION:
  7744. function gatherAnimation(sid, didHit, index) {
  7745. tmpObj = findPlayerBySID(sid);
  7746. if (tmpObj) {
  7747. tmpObj.startAnim(didHit, index);
  7748. tmpObj.gatherIndex = index;
  7749. tmpObj.gathering = 1;
  7750.  
  7751. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7752. // healer();
  7753.  
  7754. if (didHit) {
  7755. let tmpObjects = objectManager.hitObj;
  7756. objectManager.hitObj = [];
  7757. game.tickBase(() => {
  7758. // refind
  7759. tmpObj = findPlayerBySID(sid);
  7760. 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);
  7761. tmpObjects.forEach((healthy) => {
  7762. healthy.health -= val;
  7763. });
  7764. }, 1);
  7765. }
  7766. }
  7767. }
  7768.  
  7769. // WIGGLE GAME OBJECT:
  7770. function wiggleGameObject(dir, sid) {
  7771. tmpObj = findObjectBySid(sid);
  7772. if (tmpObj) {
  7773. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7774. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7775. if (tmpObj.health) {
  7776. objectManager.hitObj.push(tmpObj);
  7777. }
  7778. }
  7779. }
  7780.  
  7781. // SHOOT TURRET:
  7782. function shootTurret(sid, dir) {
  7783. tmpObj = findObjectBySid(sid);
  7784. if (tmpObj) {
  7785. if (config.anotherVisual) {
  7786. tmpObj.lastDir = dir;
  7787. } else {
  7788. tmpObj.dir = dir;
  7789. }
  7790. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7791. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7792. }
  7793. }
  7794.  
  7795. // UPDATE PLAYER VALUE:
  7796. function updatePlayerValue(index, value, updateView) {
  7797. if (player) {
  7798. player[index] = value;
  7799. if (index == "points") {
  7800. if (configs.autoBuy) {
  7801. autoBuy.hat();
  7802. autoBuy.acc();
  7803. }
  7804. } else if (index == "kills") {
  7805. if (configs.killChat) {
  7806. sendChat("<//Project FMA//>" + value);
  7807. }
  7808. }
  7809. }
  7810. }
  7811.  
  7812.  
  7813.  
  7814. // ACTION BAR:
  7815. function updateItems(data, wpn) {
  7816. if (data) {
  7817. if (wpn) {
  7818. player.weapons = data;
  7819. player.primaryIndex = player.weapons[0];
  7820. player.secondaryIndex = player.weapons[1];
  7821. if (!instaC.isTrue) {
  7822. selectWeapon(player.weapons[0]);
  7823. }
  7824. } else {
  7825. player.items = data;
  7826. }
  7827. }
  7828.  
  7829. for (let i = 0; i < items.list.length; i++) {
  7830. let tmpI = items.weapons.length + i;
  7831. let actionBarItem = getEl("actionBarItem" + tmpI);
  7832. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7833. // Add shadow to the element
  7834. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7835. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7836.  
  7837. }
  7838.  
  7839. for (let i = 0; i < items.weapons.length; i++) {
  7840. let actionBarItem = getEl("actionBarItem" + i);
  7841. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7842. // Add shadow to the element
  7843. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7844. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7845. }
  7846.  
  7847. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7848. if (kms) {
  7849. getEl("actionBarItem3").style.display = "none";
  7850. getEl("actionBarItem4").style.display = "inline-block";
  7851. }
  7852. }
  7853.  
  7854. // ADD PROJECTILE:
  7855. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7856. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7857. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7858. }
  7859.  
  7860. // REMOVE PROJECTILE:
  7861. function remProjectile(sid, range) {
  7862. for (let i = 0; i < projectiles.length; ++i) {
  7863. if (projectiles[i].sid == sid) {
  7864. projectiles[i].range = range;
  7865. let tmpObjects = objectManager.hitObj;
  7866. objectManager.hitObj = [];
  7867. game.tickBase(() => {
  7868. let val = projectiles[i].dmg;
  7869. tmpObjects.forEach((healthy) => {
  7870. if (healthy.projDmg) {
  7871. healthy.health -= val;
  7872. }
  7873. });
  7874. }, 1);
  7875. }
  7876. }
  7877. }
  7878.  
  7879. // lol this useless,,, fr
  7880. let noob = false;
  7881. let serverReady = true;
  7882. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7883. let wssws = isProd ? "wss" : "ws";
  7884. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7885. let withSync = false;
  7886. project.binaryType = "arraybuffer";
  7887. project.onmessage = function(msg) {
  7888. let data = msg.data;
  7889. if (data == "isready") {
  7890. serverReady = true;
  7891. }
  7892. if (data == "fine") {
  7893. noob = false;
  7894. }
  7895.  
  7896. if (data == "tezt") {
  7897. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7898. }
  7899. if (data == "yeswearesyncer") {
  7900. // let delay = Date.now() - wsDelay;
  7901. withSync = true;
  7902. if (player) {
  7903. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7904. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7905. }
  7906. }
  7907. };
  7908. project.onopen = function() {
  7909. var gameTitle = getEl("gameName");
  7910. gameTitle.innerText = "Moo Moo";
  7911. };
  7912.  
  7913. // SHOW ALLIANCE MENU:
  7914. function allianceNotification(sid, name) {
  7915. let findBotSID = findSID(bots, sid);
  7916. if (findBotSID) {}
  7917. }
  7918.  
  7919. function setPlayerTeam(team, isOwner) {
  7920. if (player) {
  7921. player.team = team;
  7922. player.isOwner = isOwner;
  7923. if (team == null)
  7924. alliancePlayers = [];
  7925. }
  7926. }
  7927.  
  7928. function setAlliancePlayers(data) {
  7929. alliancePlayers = data;
  7930. }
  7931.  
  7932. // STORE MENU:
  7933. function updateStoreItems(type, id, index) {
  7934. if (index) {
  7935. if (!type)
  7936. player.tails[id] = 1;
  7937. else {
  7938. player.latestTail = id;
  7939. }
  7940. } else {
  7941. if (!type)
  7942. player.skins[id] = 1,
  7943. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7944. else {
  7945. player.latestSkin = id;
  7946. }
  7947. }
  7948. }
  7949.  
  7950.  
  7951. // SEND MESSAGE:
  7952. function receiveChat(sid, message) {
  7953. if (/img/i.test(message)) return; // Anti img kick
  7954. if (/iframe/i.test(message)) return;
  7955. let kawaii = false;
  7956. let tmpPlayer = findPlayerBySID(sid);
  7957. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7958. tmpPlayer.chatMessage = message;
  7959. tmpPlayer.chatCountdown = config.chatCountdown;
  7960. if (message.includes("")) {
  7961. setTimeout(() => {
  7962. packet("6", "");
  7963. }, 55);
  7964. setTimeout(() => {
  7965. packet("6", "");
  7966. }, 55);
  7967. }
  7968. }
  7969.  
  7970. // MINIMAP:
  7971. function updateMinimap(data) {
  7972. minimapData = data;
  7973. }
  7974.  
  7975. // SHOW ANIM TEXT:
  7976. function showText(x, y, value, type) {
  7977. // if (config.anotherVisual) {
  7978. textManager.stack.push({
  7979. x: x,
  7980. y: y,
  7981. value: value
  7982. });
  7983. // } else {
  7984. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  7985. // }
  7986. }
  7987.  
  7988. /** APPLY SOCKET CODES */
  7989.  
  7990. // BOT:
  7991. let bots = [];
  7992. let ranLocation = {
  7993. x: UTILS.randInt(35, 14365),
  7994. y: UTILS.randInt(35, 14365)
  7995. };
  7996. setInterval(() => {
  7997. ranLocation = {
  7998. x: UTILS.randInt(35, 14365),
  7999. y: UTILS.randInt(35, 14365)
  8000. };
  8001. }, 60000);
  8002. class Bot {
  8003. constructor(id, sid, hats, accessories) {
  8004. this.millPlace = true;
  8005. this.id = id;
  8006. this.sid = sid;
  8007. this.team = null;
  8008. this.skinIndex = 0;
  8009. this.tailIndex = 0;
  8010. this.hitTime = 0;
  8011. this.iconIndex = 0;
  8012. this.enemy = [];
  8013. this.near = [];
  8014. this.dist2 = 0;
  8015. this.aim2 = 0;
  8016. this.tick = 0;
  8017. this.itemCounts = {};
  8018. this.latestSkin = 0;
  8019. this.latestTail = 0;
  8020. this.points = 0;
  8021. this.tails = {};
  8022. for (let i = 0; i < accessories.length; ++i) {
  8023. if (accessories[i].price <= 0)
  8024. this.tails[accessories[i].id] = 1;
  8025. }
  8026. this.skins = {};
  8027. for (let i = 0; i < hats.length; ++i) {
  8028. if (hats[i].price <= 0)
  8029. this.skins[hats[i].id] = 1;
  8030. }
  8031. this.spawn = function(moofoll) {
  8032. this.upgraded = 0;
  8033. this.enemy = [];
  8034. this.near = [];
  8035. this.active = true;
  8036. this.alive = true;
  8037. this.lockMove = false;
  8038. this.lockDir = false;
  8039. this.minimapCounter = 0;
  8040. this.chatCountdown = 0;
  8041. this.shameCount = 0;
  8042. this.shameTimer = 0;
  8043. this.sentTo = {};
  8044. this.gathering = 0;
  8045. this.autoGather = 0;
  8046. this.animTime = 0;
  8047. this.animSpeed = 0;
  8048. this.mouseState = 0;
  8049. this.buildIndex = -1;
  8050. this.weaponIndex = 0;
  8051. this.dmgOverTime = {};
  8052. this.noMovTimer = 0;
  8053. this.maxXP = 300;
  8054. this.XP = 0;
  8055. this.age = 1;
  8056. this.kills = 0;
  8057. this.upgrAge = 2;
  8058. this.upgradePoints = 0;
  8059. this.x = 0;
  8060. this.y = 0;
  8061. this.zIndex = 0;
  8062. this.xVel = 0;
  8063. this.yVel = 0;
  8064. this.slowMult = 1;
  8065. this.dir = 0;
  8066. this.nDir = 0;
  8067. this.dirPlus = 0;
  8068. this.targetDir = 0;
  8069. this.targetAngle = 0;
  8070. this.maxHealth = 100;
  8071. this.health = this.maxHealth;
  8072. this.oldHealth = this.maxHealth;
  8073. this.scale = config.playerScale;
  8074. this.speed = config.playerSpeed;
  8075. this.resetMoveDir();
  8076. this.resetResources(moofoll);
  8077. this.items = [0, 3, 6, 10];
  8078. this.weapons = [0];
  8079. this.shootCount = 0;
  8080. this.weaponXP = [];
  8081. this.isBot = false;
  8082. this.reloads = {
  8083. 0: 0,
  8084. 1: 0,
  8085. 2: 0,
  8086. 3: 0,
  8087. 4: 0,
  8088. 5: 0,
  8089. 6: 0,
  8090. 7: 0,
  8091. 8: 0,
  8092. 9: 0,
  8093. 10: 0,
  8094. 11: 0,
  8095. 12: 0,
  8096. 13: 0,
  8097. 14: 0,
  8098. 15: 0,
  8099. 53: 0,
  8100. };
  8101. this.timeZinceZpawn = 0;
  8102. this.whyDie = "";
  8103. this.clearRadius = false;
  8104. this.circlee = 0;
  8105. };
  8106.  
  8107. // RESET MOVE DIR:
  8108. this.resetMoveDir = function() {
  8109. this.moveDir = undefined;
  8110. };
  8111.  
  8112. // RESET RESOURCES:
  8113. this.resetResources = function(moofoll) {
  8114. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8115. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8116. }
  8117. };
  8118.  
  8119. // SET DATA:
  8120. this.setData = function(data) {
  8121. this.id = data[0];
  8122. this.sid = data[1];
  8123. this.name = data[2];
  8124. this.x = data[3];
  8125. this.y = data[4];
  8126. this.dir = data[5];
  8127. this.health = data[6];
  8128. this.maxHealth = data[7];
  8129. this.scale = data[8];
  8130. this.skinColor = data[9];
  8131. };
  8132.  
  8133.  
  8134. // SHAME SYSTEM:
  8135. this.judgeShame = function() {
  8136. if (this.oldHealth < this.health) {
  8137. if (this.hitTime) {
  8138. let timeSinceHit = this.tick - this.hitTime;
  8139. this.hitTime = 0;
  8140. if (timeSinceHit < 2) {
  8141. this.lastshamecount = this.shameCount;
  8142. this.shameCount++;
  8143. } else {
  8144. this.lastshamecount = this.shameCount;
  8145. this.shameCount = Math.max(0, this.shameCount - 2);
  8146. }
  8147. }
  8148. } else if (this.oldHealth > this.health) {
  8149. this.hitTime = this.tick;
  8150. }
  8151. };
  8152.  
  8153. // CHECK TEAM
  8154. this.isTeam = function (tmpObj) {
  8155. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  8156.  
  8157. };
  8158. // UPDATE WEAPON RELOAD:
  8159. this.manageReloadaa = function() {
  8160. if (this.shooting[53]) {
  8161. this.shooting[53] = 0;
  8162. this.reloads[53] = (2500 - 1000/9);
  8163. } else {
  8164. if (this.reloads[53] > 0) {
  8165. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8166. }
  8167. }
  8168. if (this.gathering || this.shooting[1]) {
  8169. if (this.gathering) {
  8170. this.gathering = 0;
  8171. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8172. this.attacked = true;
  8173. }
  8174. if (this.shooting[1]) {
  8175. this.shooting[1] = 0;
  8176. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8177. this.attacked = true;
  8178. }
  8179. } else {
  8180. this.attacked = false;
  8181. if (this.buildIndex < 0) {
  8182. if (this.reloads[this.weaponIndex] > 0) {
  8183. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8184. }
  8185. }
  8186. }
  8187. };
  8188.  
  8189. this.closeSockets = function(websc) {
  8190. websc.close();
  8191. };
  8192.  
  8193. this.whyDieChat = function(websc, whydie) {
  8194. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  8195. };
  8196. }
  8197. };
  8198.  
  8199. class BotObject {
  8200. constructor(sid) {
  8201. this.sid = sid;
  8202. // INIT:
  8203. this.init = function(x, y, dir, scale, type, data, owner) {
  8204. data = data || {};
  8205. this.active = true;
  8206. this.x = x;
  8207. this.y = y;
  8208. this.scale = scale;
  8209. this.owner = owner;
  8210. this.id = data.id;
  8211. this.dmg = data.dmg;
  8212. this.trap = data.trap;
  8213. this.teleport = data.teleport;
  8214. this.isItem = this.id != undefined;
  8215. };
  8216.  
  8217. }
  8218. };
  8219. class BotObjManager {
  8220. constructor(botObj, fOS) {
  8221. // DISABLE OBJ:
  8222. this.disableObj = function(obj) {
  8223. obj.active = false;
  8224. if (config.anotherVisual) {} else {
  8225. obj.alive = false;
  8226. }
  8227. };
  8228.  
  8229. // ADD NEW:
  8230. let tmpObj;
  8231. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8232. tmpObj = fOS(sid);
  8233. if (!tmpObj) {
  8234. tmpObj = botObj.find((tmp) => !tmp.active);
  8235. if (!tmpObj) {
  8236. tmpObj = new BotObject(sid);
  8237. botObj.push(tmpObj);
  8238. }
  8239. }
  8240. if (setSID) {
  8241. tmpObj.sid = sid;
  8242. }
  8243. tmpObj.init(x, y, dir, s, type, data, owner);
  8244. };
  8245.  
  8246. // DISABLE BY SID:
  8247. this.disableBySid = function(sid) {
  8248. let find = fOS(sid);
  8249. if (find) {
  8250. this.disableObj(find);
  8251. }
  8252. };
  8253.  
  8254. // REMOVE ALL FROM PLAYER:
  8255. this.removeAllItems = function(sid, server) {
  8256. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8257. };
  8258. }
  8259. };
  8260.  
  8261. let botz = [];
  8262.  
  8263. function botSpawn(id) {
  8264. let bot;
  8265. console.log(WS);
  8266. let t = WS.url.split("wss://")[1].split("?")[0];
  8267. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8268. let botPlayer = new Map();
  8269. botSkts.push([botPlayer]);
  8270. botz.push([bot]);
  8271. let botSID;
  8272. let botObj = [];
  8273. let nearObj = [];
  8274. let bD = {
  8275. x: 0,
  8276. y: 0,
  8277. inGame: false,
  8278. closeSocket: false,
  8279. whyDie: ""
  8280. };
  8281. let oldXY = {
  8282. x: 0,
  8283. y: 0,
  8284. };
  8285. let izauto = 0;
  8286. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8287. bot.binaryType = "arraybuffer";
  8288. bot.first = true;
  8289. bot.sendWS = function(type) {
  8290. // EXTRACT DATA ARRAY:
  8291. let data = Array.prototype.slice.call(arguments, 1);
  8292. // SEND MESSAGE:
  8293. let binary = window.msgpack.encode([type, data]);
  8294. bot.send(binary);
  8295. };
  8296. bot.spawn = function() {
  8297. bot.sendWS("M", {
  8298. name: "Trash Slave",
  8299. moofoll: 1,
  8300. skin: "__proto__"
  8301. });
  8302. };
  8303. bot.sendUpgrade = function(index) {
  8304. bot.sendWS("H", index);
  8305. };
  8306. bot.place = function(id, a) {
  8307. try {
  8308. let item = items.list[botPlayer.items[id]];
  8309. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  8310. bot.sendWS("G", botPlayer.items[id]);
  8311. bot.sendWS("d", 1, a);
  8312. bot.sendWS("G", botPlayer.weaponIndex, true);
  8313. }
  8314. } catch (e) {
  8315. }
  8316. };
  8317. bot.buye = function(id, index) {
  8318. let nID = 0;
  8319. if (botPlayer.alive && botPlayer.inGame) {
  8320. if (index == 0) {
  8321. if (botPlayer.skins[id]) {
  8322. if (botPlayer.latestSkin != id) {
  8323. bot.sendWS("c", 0, id, 0);
  8324. }
  8325. } else {
  8326. let find = findID(hats, id);
  8327. if (find) {
  8328. if (botPlayer.points >= find.price) {
  8329. bot.sendWS("c", 1, id, 0);
  8330. bot.sendWS("c", 0, id, 0);
  8331. } else {
  8332. if (botPlayer.latestSkin != nID) {
  8333. bot.sendWS("c", 0, nID, 0);
  8334. }
  8335. }
  8336. } else {
  8337. if (botPlayer.latestSkin != nID) {
  8338. bot.sendWS("c", 0, nID, 0);
  8339. }
  8340. }
  8341. }
  8342. } else if (index == 1) {
  8343. if (botPlayer.tails[id]) {
  8344. if (botPlayer.latestTail != id) {
  8345. bot.sendWS("c", 0, id, 1);
  8346. }
  8347. } else {
  8348. let find = findID(accessories, id);
  8349. if (find) {
  8350. if (botPlayer.points >= find.price) {
  8351. bot.sendWS("c", 1, id, 1);
  8352. bot.sendWS("c", 0, id, 1);
  8353. } else {
  8354. if (botPlayer.latestTail != 0) {
  8355. bot.sendWS("c", 0, 0, 1);
  8356. }
  8357. }
  8358. } else {
  8359. if (botPlayer.latestTail != 0) {
  8360. bot.sendWS("c", 0, 0, 1);
  8361. }
  8362. }
  8363. }
  8364. }
  8365. }
  8366. };
  8367. bot.fastGear = function() {
  8368. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8369. bot.buye(31, 0);
  8370. } else {
  8371. if (botPlayer.y2 <= config.snowBiomeTop) {
  8372. bot.buye(15, 0);
  8373. } else {
  8374. bot.buye(12, 0);
  8375. }
  8376. }
  8377. };
  8378. bot.selectWeapon = function(a) {
  8379. packet("z", a, 1);
  8380. }
  8381. function caf(e, t) {
  8382. try {
  8383. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  8384. } catch (e) {
  8385. return 0;
  8386. }
  8387. }
  8388. bot.heal = function() {
  8389. if (botPlayer.health < 100) {
  8390. bot.place(0, 0)
  8391. }
  8392. }
  8393. function cdf (e, t){
  8394. try {
  8395. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  8396. } catch(e){
  8397. return Infinity;
  8398. }
  8399. }
  8400. let zoon = 'no';
  8401. bot.zync = function(a) {
  8402. if (!botPlayer.millPlace) {
  8403. zoon = 'yeah';
  8404. bot.place(5, caf(botPlayer, a));
  8405. let NextTickLocation = {
  8406. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8407. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8408. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  8409. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  8410. };
  8411.  
  8412. function calculateDistance(x1, y1, x2, y2) {
  8413. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  8414. return distance;
  8415. }
  8416. function dotherezt() {
  8417. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8418. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  8419. }
  8420.  
  8421. let aa = setInterval(() => {
  8422. bot.sendWS("G", botPlayer.weapons[1], true);
  8423. if (izauto == 0) {
  8424. bot.sendWS("K", 1);
  8425. izauto = 1;
  8426. }
  8427. setTimeout(() => {
  8428. bot.sendWS("G", botPlayer.weapons[0], true);
  8429. }, 2000);
  8430. bot.buye(53, 0);
  8431. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  8432. bot.sendWS("f", caf(botPlayer, NextTickLocation));
  8433. } else {
  8434. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  8435. zoon = 'no';
  8436. bot.sendWS("f", undefined);
  8437. dotherezt();
  8438. clearInterval(aa);
  8439. }
  8440. }, 150);
  8441.  
  8442. setTimeout(() => {
  8443. zoon = 'no';
  8444. clearInterval(aa);
  8445. }, 500);
  8446. }
  8447. };
  8448. bot.onmessage = function(message) {
  8449. let data = new Uint8Array(message.data);
  8450. let parsed = window.msgpack.decode(data);
  8451. let type = parsed[0];
  8452. data = parsed[1];
  8453. if (type == "io-init") {
  8454. bot.spawn();
  8455. }
  8456. if (type == "1") {
  8457. botSID = data[0];
  8458. console.log(botSID)
  8459. }
  8460. if (type == "D") {
  8461. if (data[1]) {
  8462. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8463. botPlayer.setData(data[0]);
  8464. botPlayer.inGame = true;
  8465. botPlayer.alive = true;
  8466. botPlayer.x2 = undefined;
  8467. botPlayer.y2 = undefined;
  8468. botPlayer.spawn(1);
  8469. botPlayer.oldHealth = 100;
  8470. botPlayer.health = 100;
  8471. botPlayer.showName = 'YEAHHH';
  8472. oldXY = {
  8473. x: data[0][3],
  8474. y: data[0][4]
  8475. }
  8476. bD.inGame = true;
  8477. if (bot.first) {
  8478. bot.first = false;
  8479. bots.push(bD);
  8480. }
  8481. }
  8482. }
  8483. if (type == "P") {
  8484. bot.spawn();
  8485. botPlayer.inGame = false;
  8486. bD.inGame = false;
  8487. }
  8488. if (type == "f") {
  8489. let tmpData = data[0];
  8490. botPlayer.tick++;
  8491. botPlayer.enemy = [];
  8492. botPlayer.near = [];
  8493. bot.showName = 'YEAHHH';
  8494. nearObj = [];
  8495. for (let i = 0; i < tmpData.length;) {
  8496. if (tmpData[i] == botPlayer.sid) {
  8497. botPlayer.x2 = tmpData[i + 1];
  8498. botPlayer.y2 = tmpData[i + 2];
  8499. botPlayer.d2 = tmpData[i + 3];
  8500. botPlayer.buildIndex = tmpData[i + 4];
  8501. botPlayer.weaponIndex = tmpData[i + 5];
  8502. botPlayer.weaponVariant = tmpData[i + 6];
  8503. botPlayer.team = tmpData[i + 7];
  8504. botPlayer.isLeader = tmpData[i + 8];
  8505. botPlayer.skinIndex = tmpData[i + 9];
  8506. botPlayer.tailIndex = tmpData[i + 10];
  8507. botPlayer.iconIndex = tmpData[i + 11];
  8508. botPlayer.zIndex = tmpData[i + 12];
  8509. botPlayer.visible = true;
  8510. bD.x2 = botPlayer.x2;
  8511. bD.y2 = botPlayer.y2;
  8512. }
  8513. i += 13;
  8514. }
  8515.  
  8516. for (let i = 0; i < tmpData.length;) {
  8517. tmpObj = findPlayerBySID(tmpData[i]);
  8518. if (tmpObj) {
  8519. if (!tmpObj.isTeam(botPlayer)) {
  8520. enemy.push(tmpObj);
  8521. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  8522. nears.push(tmpObj);
  8523. }
  8524. }
  8525. }
  8526. i += 13;
  8527. }
  8528.  
  8529. if (enemy.length) {
  8530. //console.log(enemy)
  8531. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  8532. return tmp1.dist2 - tmp2.dist2;
  8533. })[0];
  8534. }
  8535.  
  8536. if (izauto == 1) {
  8537. bot.sendWS("K", 1);
  8538. izauto = 0;
  8539. }
  8540.  
  8541. if (bD.closeSocket) {
  8542. botPlayer.closeSockets(bot);
  8543. }
  8544. if (bD.whyDie != "") {
  8545. botPlayer.whyDieChat(bot, bD.whyDie);
  8546. bD.whyDie = "";
  8547. }
  8548. if (botPlayer.alive) {
  8549. if (player.team) {
  8550. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8551. botPlayer.team && (bot.sendWS("N"));
  8552. bot.sendWS("b", player.team);
  8553. }
  8554. }
  8555.  
  8556. let item = items.list[botPlayer.items[3]];
  8557. let a = botPlayer.itemCounts[item.group.id]
  8558. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  8559. if (botPlayer.inGame) {
  8560. bot.sendWS("D", botPlayer.moveDir);
  8561. if (izauto == 0) {
  8562. bot.sendWS("K", 1);
  8563. izauto = 1;
  8564. }
  8565. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8566. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8567. bot.place(3, aim + 7.7);
  8568. bot.place(3, aim - 7.7);
  8569. bot.place(3, aim);
  8570. oldXY = {
  8571. x: botPlayer.x2,
  8572. y: botPlayer.y2
  8573. };
  8574. }
  8575.  
  8576. if (botPlayer.tick % 90 === 0) {
  8577. let rand = Math.random() * Math.PI * 2;
  8578. botPlayer.moveDir = rand;
  8579. bot.sendWS("f", botPlayer.moveDir);
  8580. }
  8581. }
  8582. bot.fastGear();
  8583. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  8584. botPlayer.millPlace = false;
  8585. // bot.sendWS("K", 1);
  8586. bot.fastGear();
  8587. } else {
  8588. if (botPlayer.inGame) {
  8589. if (botObj.length > 0) {
  8590. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  8591. if (getEl("mode").value == 'fuckemup') {
  8592. // if (getEl("mode").value == "clear") {
  8593. bot.selectWeapon(botPlayer.weapons[1]);
  8594. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  8595. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  8596. nearObj = botObj.filter((e) => e.active && (findSID(buldingtoawdoin, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale + 10)).sort(function(a, b) {
  8597. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8598. })[0];
  8599. if (nearObj) {
  8600. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  8601. if ((gotoDist - isPassed) > 0) {
  8602. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8603. if (botPlayer.moveDir != undefined) {
  8604. botPlayer.moveDir = undefined;
  8605. bot.sendWS("f", botPlayer.moveDir);
  8606. bot.sendWS("D", botPlayer.nDir);
  8607. }
  8608. } else {
  8609. botPlayer.moveDir = gotoAim;
  8610. bot.sendWS("f", botPlayer.moveDir);
  8611. bot.sendWS("D", botPlayer.nDir);
  8612. }
  8613. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8614. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8615. bot.sendWS("D", botPlayer.nDir);
  8616. }
  8617. if (izauto == 0) {
  8618. bot.sendWS("K", 1);
  8619. izauto = 1;
  8620. }
  8621. bot.buye(40, 0);
  8622. } else {
  8623. botPlayer.moveDir = gotoAim;
  8624. bot.sendWS("f", botPlayer.moveDir);
  8625. bot.sendWS("D", botPlayer.nDir);
  8626. bot.fastGear();
  8627. }
  8628. } else {
  8629. botPlayer.moveDir = gotoAim;
  8630. bot.sendWS("f", botPlayer.moveDir);
  8631. bot.sendWS("D", botPlayer.nDir);
  8632. bot.fastGear();
  8633. }
  8634. }
  8635. }
  8636.  
  8637.  
  8638.  
  8639. if (botObj.length > 0) {
  8640. if (getEl("mode").value == 'flex') {
  8641. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  8642. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  8643. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  8644.  
  8645. bot.sendWS("f", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  8646.  
  8647. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  8648. if (dist > 22) // 22 is player speed without booster hat
  8649. return;
  8650. }
  8651. }
  8652.  
  8653.  
  8654. if (botObj.length > 0) {
  8655. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  8656. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8657. })[0];
  8658.  
  8659. if (nearObj) {
  8660. if (izauto == 0) {
  8661. bot.sendWS("K", 1);
  8662. izauto = 1;
  8663. }
  8664. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8665. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8666. bot.sendWS("D", botPlayer.nDir);
  8667. }
  8668. bot.buye(40, 0);
  8669. bot.buye(11, 1);
  8670. } else {
  8671. bot.fastGear();
  8672. bot.buye(11, 1);
  8673. }
  8674. bot.buye(11, 1);
  8675. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  8676. // if (getEl("mode").value == "clear") {
  8677. bot.selectWeapon(botPlayer.weapons[1]);
  8678. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8679. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8680. 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) {
  8681. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8682. })[0];
  8683. if (nearObj) {
  8684. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8685. if ((gotoDist - isPassed) > 0) {
  8686. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8687. if (botPlayer.moveDir != undefined) {
  8688. botPlayer.moveDir = undefined;
  8689. bot.sendWS("f", botPlayer.moveDir);
  8690. bot.sendWS("D", botPlayer.nDir);
  8691. }
  8692. } else {
  8693. botPlayer.moveDir = gotoAim;
  8694. bot.sendWS("f", botPlayer.moveDir);
  8695. bot.sendWS("D", botPlayer.nDir);
  8696. }
  8697. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8698. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8699. bot.sendWS("D", botPlayer.nDir);
  8700. }
  8701. if (izauto == 0) {
  8702. bot.sendWS("K", 1);
  8703. izauto = 1;
  8704. }
  8705. bot.buye(40, 0);
  8706. bot.fastGear();
  8707. } else {
  8708. botPlayer.moveDir = gotoAim;
  8709. bot.sendWS("f", botPlayer.moveDir);
  8710. bot.sendWS("D", botPlayer.nDir);
  8711. bot.fastGear();
  8712. }
  8713. } else {
  8714. botPlayer.moveDir = gotoAim;
  8715. bot.sendWS("f", botPlayer.moveDir);
  8716. bot.sendWS("D", botPlayer.nDir);
  8717. bot.fastGear();
  8718. }
  8719. if (gotoDist > 300) {
  8720. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8721. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8722. bot.place(3, aim + 7.7);
  8723. bot.place(3, aim - 7.7);
  8724. bot.place(3, aim);
  8725. oldXY = {
  8726. x: botPlayer.x2,
  8727. y: botPlayer.y2
  8728. };
  8729. }
  8730. }
  8731. }
  8732. }
  8733.  
  8734. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  8735. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  8736.  
  8737. if(!wdaawdwad.length) {
  8738. if(zoon == 'no')
  8739. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8740. bot.sendWS("f", caf(player, botPlayer) + Math.PI);
  8741. }
  8742.  
  8743. if(wdaawdwad.length) {
  8744. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  8745. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  8746. nearObj = botObj.filter((e) => e.active && (findSID(wdaawdwad, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  8747. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8748. })[0];
  8749. if (nearObj) {
  8750. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  8751. if ((gotoDist - isPassed) > 0) {
  8752. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  8753. if (botPlayer.moveDir != undefined) {
  8754. botPlayer.moveDir = undefined;
  8755. bot.sendWS("f", botPlayer.moveDir);
  8756. bot.sendWS("D", botPlayer.nDir);
  8757. }
  8758. } else {
  8759. bot.sendWS("D", botPlayer.nDir);
  8760. }
  8761. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8762. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8763. bot.sendWS("D", botPlayer.nDir);
  8764. }
  8765. if (izauto == 0) {
  8766. bot.sendWS("K", 1);
  8767. izauto = 1;
  8768. }
  8769. bot.buye(40, 0);
  8770. bot.fastGear();
  8771. } else {
  8772. if(zoon == 'no')
  8773. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  8774. if(cdf(player, botPlayer) <= 110)
  8775. bot.sendWS("f", undefined);
  8776. else
  8777. bot.sendWS("f", caf(player, botPlayer) + Math.PI);
  8778. }
  8779. } else {
  8780. if(wdaawdwad.length) {
  8781. if(zoon == 'no')
  8782. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  8783. if(cdf(player, botPlayer) <= 110)
  8784. bot.sendWS("f", undefined);
  8785. else
  8786. bot.sendWS("f", caf(player, botPlayer) + Math.PI);
  8787. } else {
  8788. if(zoon == 'no')
  8789. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  8790. if(cdf(player, botPlayer) <= 110)
  8791. bot.sendWS("f", undefined);
  8792. else
  8793. bot.sendWS("f", caf(player, botPlayer) + Math.PI);
  8794. }
  8795. }
  8796. }
  8797. }
  8798. }
  8799. }
  8800. }
  8801. }
  8802. if (type == "H") {
  8803. let tmpData = data[0];
  8804. for (let i = 0; i < tmpData.length;) {
  8805. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8806. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8807. sid: tmpData[i + 7]
  8808. } : null));
  8809. i += 8;
  8810. }
  8811. }
  8812. if (type == "N") {
  8813. let index = data[0];
  8814. let value = data[1];
  8815. if (botPlayer) {
  8816. botPlayer[index] = value;
  8817. }
  8818. }
  8819. if (type == "O") {
  8820. if (data[0] == botPlayer.sid) {
  8821. botPlayer.oldHealth = botPlayer.health;
  8822. botPlayer.health = data[1];
  8823. botPlayer.judgeShame();
  8824. if (botPlayer.oldHealth > botPlayer.health) {
  8825. if (botPlayer.shameCount < 5) {
  8826. for (let i = 0; i < 2; i++) {
  8827. bot.place(0, botPlayer.nDir);
  8828. }
  8829.  
  8830. } else {
  8831. setTimeout(() => {
  8832. for (let i = 0; i < 2; i++) {
  8833. bot.place(0, botPlayer.nDir);
  8834. }
  8835. }, 95);
  8836. }
  8837. }
  8838. }
  8839. }
  8840. if (type == "Q") {
  8841. let sid = data[0];
  8842. botObjManager.disableBySid(sid);
  8843. }
  8844. if (type == "R") {
  8845. let sid = data[0];
  8846. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8847. }
  8848. if (type == "S") {
  8849. let index = data[0];
  8850. let value = data[1];
  8851. if (botPlayer) {
  8852. botPlayer.itemCounts[index] = value;
  8853. }
  8854. }
  8855. if (type == "U") {
  8856. if (data[0] > 0) {
  8857. if(getEl("setup").value == 'dm') {
  8858. if (botPlayer.upgraded == 0) {
  8859. bot.sendUpgrade(7);
  8860. } else if (botPlayer.upgraded == 1) {
  8861. bot.sendUpgrade(17);
  8862. } else if (botPlayer.upgraded == 2) {
  8863. bot.sendUpgrade(31);
  8864. } else if (botPlayer.upgraded == 3) {
  8865. bot.sendUpgrade(23);
  8866. } else if (botPlayer.upgraded == 4) {
  8867. bot.sendUpgrade(9);
  8868. } else if (botPlayer.upgraded == 5) {
  8869. bot.sendUpgrade(34);
  8870. } else if (botPlayer.upgraded == 6) {
  8871. bot.sendUpgrade(12);
  8872. } else if (botPlayer.upgraded == 7) {
  8873. bot.sendUpgrade(15);
  8874. }
  8875. } else if(getEl("setup").value == 'dr') {
  8876. if (botPlayer.upgraded == 0) {
  8877. bot.sendUpgrade(7);
  8878. } else if (botPlayer.upgraded == 1) {
  8879. bot.sendUpgrade(17);
  8880. } else if (botPlayer.upgraded == 2) {
  8881. bot.sendUpgrade(31);
  8882. } else if (botPlayer.upgraded == 3) {
  8883. bot.sendUpgrade(23);
  8884. } else if (botPlayer.upgraded == 4) {
  8885. bot.sendUpgrade(9);
  8886. } else if (botPlayer.upgraded == 5) {
  8887. bot.sendUpgrade(34);
  8888. } else if (botPlayer.upgraded == 6) {
  8889. bot.sendUpgrade(12);
  8890. } else if (botPlayer.upgraded == 7) {
  8891. bot.sendUpgrade(13);
  8892. }
  8893. } else if(getEl("setup").value == 'kh') {
  8894. if (botPlayer.upgraded == 0) {
  8895. bot.sendUpgrade(3);
  8896. } else if (botPlayer.upgraded == 1) {
  8897. bot.sendUpgrade(17);
  8898. } else if (botPlayer.upgraded == 2) {
  8899. bot.sendUpgrade(31);
  8900. } else if (botPlayer.upgraded == 3) {
  8901. bot.sendUpgrade(27);
  8902. } else if (botPlayer.upgraded == 4) {
  8903. bot.sendUpgrade(10);
  8904. } else if (botPlayer.upgraded == 5) {
  8905. bot.sendUpgrade(34);
  8906. } else if (botPlayer.upgraded == 6) {
  8907. bot.sendUpgrade(4);
  8908. } else if (botPlayer.upgraded == 7) {
  8909. bot.sendUpgrade(25);
  8910. }
  8911. } else if(getEl("setup").value == 'zd') {
  8912. if (botPlayer.upgraded == 0) {
  8913. bot.sendUpgrade(3);
  8914. } else if (botPlayer.upgraded == 1) {
  8915. bot.sendUpgrade(17);
  8916. } else if (botPlayer.upgraded == 2) {
  8917. bot.sendUpgrade(31);
  8918. } else if (botPlayer.upgraded == 3) {
  8919. bot.sendUpgrade(27);
  8920. } else if (botPlayer.upgraded == 4) {
  8921. bot.sendUpgrade(9);
  8922. } else if (botPlayer.upgraded == 5) {
  8923. bot.sendUpgrade(34);
  8924. } else if (botPlayer.upgraded == 6) {
  8925. bot.sendUpgrade(12);
  8926. } else if (botPlayer.upgraded == 7) {
  8927. bot.sendUpgrade(15);
  8928. }
  8929. }
  8930. botPlayer.upgraded++;
  8931. }
  8932. }
  8933. if (type == "V") {
  8934. let tmpData = data[0];
  8935. let wpn = data[1];
  8936. if (tmpData) {
  8937. if (wpn) botPlayer.weapons = tmpData;
  8938. else botPlayer.items = tmpData;
  8939. }
  8940.  
  8941. }
  8942. if (type == "5") {
  8943. let type = data[0];
  8944. let id = data[1];
  8945. let index = data[2];
  8946. if (index) {
  8947. if (!type)
  8948. botPlayer.tails[id] = 1;
  8949. else
  8950. botPlayer.latestTail = id;
  8951. } else {
  8952. if (!type)
  8953. botPlayer.skins[id] = 1;
  8954. else
  8955. botPlayer.latestSkin = id;
  8956. }
  8957. }
  8958.  
  8959. if (type == "6") {
  8960. let id = data[0];
  8961. let mzg = data[1]+'';
  8962. if(id == player.sid && mzg.includes("Sync")) {
  8963. bot.zync(botPlayer.near);
  8964. }
  8965. }
  8966. };
  8967. bot.onclose = function() {
  8968. botPlayer.inGame = false;
  8969. bD.inGame = false;
  8970. };
  8971. }
  8972.  
  8973. // RENDER LEAF:
  8974. function renderLeaf(x, y, l, r, ctxt) {
  8975. let endX = x + (l * Math.cos(r));
  8976. let endY = y + (l * Math.sin(r));
  8977. let width = l * 0.4;
  8978. ctxt.moveTo(x, y);
  8979. ctxt.beginPath();
  8980. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8981. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8982. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8983. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8984. ctxt.closePath();
  8985. ctxt.fill();
  8986. ctxt.stroke();
  8987. }
  8988.  
  8989. // RENDER CIRCLE:
  8990. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8991. tmpContext = tmpContext || mainContext;
  8992. tmpContext.beginPath();
  8993. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8994. if (!dontFill) tmpContext.fill();
  8995. if (!dontStroke) tmpContext.stroke();
  8996. }
  8997.  
  8998. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8999. tmpContext = tmpContext || mainContext;
  9000. tmpContext.beginPath();
  9001. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9002. if (!dontFill) tmpContext.fill();
  9003. if (!dontStroke) tmpContext.stroke();
  9004. }
  9005.  
  9006. // RENDER STAR SHAPE:
  9007. function renderStar(ctxt, spikes, outer, inner) {
  9008. let rot = Math.PI / 2 * 3;
  9009. let x, y;
  9010. let step = Math.PI / spikes;
  9011. ctxt.beginPath();
  9012. ctxt.moveTo(0, -outer);
  9013. for (let i = 0; i < spikes; i++) {
  9014. x = Math.cos(rot) * outer;
  9015. y = Math.sin(rot) * outer;
  9016. ctxt.lineTo(x, y);
  9017. rot += step;
  9018. x = Math.cos(rot) * inner;
  9019. y = Math.sin(rot) * inner;
  9020. ctxt.lineTo(x, y);
  9021. rot += step;
  9022. }
  9023. ctxt.lineTo(0, -outer);
  9024. ctxt.closePath();
  9025. }
  9026.  
  9027. function renderHealthStar(ctxt, spikes, outer, inner) {
  9028. let rot = Math.PI / 2 * 3;
  9029. let x, y;
  9030. let step = Math.PI / spikes;
  9031. ctxt.beginPath();
  9032. ctxt.moveTo(0, -outer);
  9033. for (let i = 0; i < spikes; i++) {
  9034. x = Math.cos(rot) * outer;
  9035. y = Math.sin(rot) * outer;
  9036. ctxt.lineTo(x, y);
  9037. rot += step;
  9038. x = Math.cos(rot) * inner;
  9039. y = Math.sin(rot) * inner;
  9040. ctxt.lineTo(x, y);
  9041. rot += step;
  9042. }
  9043. ctxt.lineTo(0, -outer);
  9044. ctxt.closePath();
  9045. }
  9046.  
  9047. // RENDER RECTANGLE:
  9048. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9049. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9050. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9051. }
  9052.  
  9053. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9054. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9055. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9056. }
  9057.  
  9058. // RENDER RECTCIRCLE:
  9059. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9060. ctxt.save();
  9061. ctxt.translate(x, y);
  9062. seg = Math.ceil(seg / 2);
  9063. for (let i = 0; i < seg; i++) {
  9064. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9065. ctxt.rotate(Math.PI / seg);
  9066. }
  9067. ctxt.restore();
  9068. }
  9069.  
  9070. // RENDER BLOB:
  9071. function renderBlob(ctxt, spikes, outer, inner) {
  9072. let rot = Math.PI / 2 * 3;
  9073. let x, y;
  9074. let step = Math.PI / spikes;
  9075. let tmpOuter;
  9076. ctxt.beginPath();
  9077. ctxt.moveTo(0, -inner);
  9078. for (let i = 0; i < spikes; i++) {
  9079. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9080. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9081. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9082. rot += step * 2;
  9083. }
  9084. ctxt.lineTo(0, -inner);
  9085. ctxt.closePath();
  9086. }
  9087.  
  9088. // RENDER TRIANGLE:
  9089. function renderTriangle(s, ctx) {
  9090. ctx = ctx || mainContext;
  9091. let h = s * (Math.sqrt(3) / 2);
  9092. ctx.beginPath();
  9093. ctx.moveTo(0, -h / 2);
  9094. ctx.lineTo(-s / 2, h / 2);
  9095. ctx.lineTo(s / 2, h / 2);
  9096. ctx.lineTo(0, -h / 2);
  9097. ctx.fill();
  9098. ctx.closePath();
  9099. }
  9100.  
  9101. // PREPARE MENU BACKGROUND:
  9102. function prepareMenuBackground() {
  9103. let tmpMid = config.mapScale / 2;
  9104. let attempts = 0;
  9105. for (let i = 0; i < items.list.length * 3;) {
  9106. if (attempts >= 1000) break;
  9107. attempts++;
  9108. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  9109. let data = {
  9110. x: tmpMid + UTILS.randFloat(-1000, 1000),
  9111. y: tmpMid + UTILS.randFloat(-600, 600),
  9112. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9113. };
  9114. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  9115. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  9116. } else {
  9117. continue;
  9118. }
  9119. i++;
  9120. }
  9121. }
  9122. const speed = 35;
  9123. // RENDER PLAYERS:
  9124. function renderDeadPlayers(xOffset, yOffset) {
  9125. mainContext.fillStyle = "#91b2db";
  9126. const currentTime = Date.now();
  9127. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9128. if (!dead.startTime) {
  9129. dead.startTime = currentTime;
  9130. dead.angle = 0;
  9131. dead.radius = 0.1;
  9132. }
  9133. const timeElapsed = currentTime - dead.startTime;
  9134. const maxAlpha = 1;
  9135. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9136. dead.animate(delta);
  9137. mainContext.globalAlpha = dead.alpha;
  9138. mainContext.strokeStyle = outlineColor;
  9139. mainContext.save();
  9140. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9141. dead.radius -= 0.001;
  9142. dead.angle += 0.0174533;
  9143. const moveSpeed = 1;
  9144. const x = dead.radius * Math.cos(dead.angle);
  9145. const y = dead.radius * Math.sin(dead.angle);
  9146. dead.x += x * moveSpeed;
  9147. dead.y += y * moveSpeed;
  9148. mainContext.rotate(dead.angle);
  9149. renderDeadPlayer(dead, mainContext);
  9150. mainContext.restore();
  9151. mainContext.fillStyle = "#91b2db";
  9152. if (timeElapsed >= 3000) {
  9153. dead.active = false;
  9154. dead.startTime = null;
  9155. }
  9156. });
  9157. }
  9158. // RENDER PLAYERS:
  9159. function renderPlayers(xOffset, yOffset, zIndex) {
  9160. mainContext.globalAlpha = 1;
  9161. mainContext.fillStyle = "#91b2db";
  9162. for (var i = 0; i < players.length; ++i) {
  9163. tmpObj = players[i];
  9164. if (tmpObj.zIndex == zIndex) {
  9165. tmpObj.animate(delta);
  9166. if (tmpObj.visible) {
  9167. tmpObj.skinRot += (0.002 * delta);
  9168. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  9169. mainContext.save();
  9170. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9171. // RENDER PLAYER:
  9172. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9173. renderPlayer(tmpObj, mainContext);
  9174. mainContext.restore();
  9175.  
  9176. }
  9177. }
  9178. }
  9179. }
  9180. // RENDER DEAD PLAYER:
  9181. function renderDeadPlayer(obj, ctxt) {
  9182. ctxt = ctxt || mainContext;
  9183. ctxt.lineWidth = outlineWidth;
  9184. ctxt.lineJoin = "miter";
  9185. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9186. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9187. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9188. // TAIL/CAPE:
  9189. renderTail2(13, ctxt, obj);
  9190. // WEAPON BELLOW HANDS:
  9191. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9192. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  9193. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9194. renderProjectile(obj.scale, 0,
  9195. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9196. }
  9197. }
  9198. // HANDS:
  9199. ctxt.fillStyle = "#ececec";
  9200. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9201. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9202. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9203. // WEAPON ABOVE HANDS:
  9204. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9205. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  9206. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9207. renderProjectile(obj.scale, 0,
  9208. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9209. }
  9210. }
  9211. // BUILD ITEM:
  9212. if (obj.buildIndex >= 0) {
  9213. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9214. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9215. }
  9216. // BODY:
  9217. renderCircle(0, 0, obj.scale, ctxt);
  9218. // SKIN
  9219. renderSkin2(48, ctxt, null, obj)
  9220. }
  9221.  
  9222. // RENDER PLAYER:
  9223. function renderPlayer(obj, ctxt) {
  9224. ctxt = ctxt || mainContext;
  9225. ctxt.lineWidth = outlineWidth;
  9226. ctxt.lineJoin = "miter";
  9227. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9228. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9229. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9230.  
  9231. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9232.  
  9233. // TAIL/CAPE:
  9234. if (obj.tailIndex > 0) {
  9235. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  9236. }
  9237.  
  9238. // WEAPON BELLOW HANDS:
  9239. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9240. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9241. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9242. renderProjectile(obj.scale, 0,
  9243. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9244. }
  9245. }
  9246.  
  9247. // HANDS:
  9248. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9249. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9250. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9251. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9252.  
  9253. // WEAPON ABOVE HANDS:
  9254. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9255. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9256. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9257. renderProjectile(obj.scale, 0,
  9258. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9259. }
  9260. }
  9261.  
  9262. // BUILD ITEM:
  9263. if (obj.buildIndex >= 0) {
  9264. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9265. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9266. }
  9267.  
  9268. // BODY:
  9269. renderCircle(0, 0, obj.scale, ctxt);
  9270.  
  9271. // SKIN:
  9272. if (obj.skinIndex > 0) {
  9273. ctxt.rotate(Math.PI / 2);
  9274. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  9275. }
  9276.  
  9277. }
  9278.  
  9279. // RENDER NORMAL SKIN
  9280. var skinSprites2 = {};
  9281. var skinPointers2 = {};
  9282. function renderSkin2(index, ctxt, parentSkin, owner) {
  9283. tmpSkin = skinSprites2[index];
  9284. if (!tmpSkin) {
  9285. var tmpImage = new Image();
  9286. tmpImage.onload = function() {
  9287. this.isLoaded = true;
  9288. this.onload = null;
  9289. };
  9290. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9291. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9292. skinSprites2[index] = tmpImage;
  9293. tmpSkin = tmpImage;
  9294. }
  9295. var tmpObj = parentSkin||skinPointers2[index];
  9296. if (!tmpObj) {
  9297. for (var i = 0; i < hats.length; ++i) {
  9298. if (hats[i].id == index) {
  9299. tmpObj = hats[i];
  9300. break;
  9301. }
  9302. }
  9303. skinPointers2[index] = tmpObj;
  9304. }
  9305. if (tmpSkin.isLoaded)
  9306. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9307. if (!parentSkin && tmpObj.topSprite) {
  9308. ctxt.save();
  9309. ctxt.rotate(owner.skinRot);
  9310. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9311. ctxt.restore();
  9312. }
  9313. }
  9314.  
  9315. // RENDER SKIN:
  9316. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  9317. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  9318. var tmpImage = new Image();
  9319. tmpImage.onload = function() {
  9320. this.isLoaded = true,
  9321. this.onload = null
  9322. }
  9323. ,
  9324. tmpImage.src = setSkinTextureImage(index, "hat", index),
  9325. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9326. tmpSkin = tmpImage
  9327. }
  9328. var tmpObj = parentSkin||skinPointers[index];
  9329. if (!tmpObj) {
  9330. for (var i = 0; i < hats.length; ++i) {
  9331. if (hats[i].id == index) {
  9332. tmpObj = hats[i];
  9333. break;
  9334. }
  9335. }
  9336. skinPointers[index] = tmpObj;
  9337. }
  9338. if (tmpSkin.isLoaded)
  9339. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9340. if (!parentSkin && tmpObj.topSprite) {
  9341. ctxt.save();
  9342. ctxt.rotate(owner.skinRot);
  9343. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9344. ctxt.restore();
  9345. }
  9346. }
  9347.  
  9348. var FlareZHat = {
  9349. 7: "https://i.imgur.com/vAOzlyY.png",
  9350. 15: "https://i.imgur.com/YRQ8Ybq.png",
  9351. 40: "https://i.imgur.com/Xzmg27N.png",
  9352. 26: "https://i.imgur.com/I0xGtyZ.png",
  9353. 55: "https://i.imgur.com/uYgDtcZ.png",
  9354. 20: "https://i.imgur.com/f5uhWCk.png",
  9355. };
  9356.  
  9357. function setSkinTextureImage(id, type, id2) {
  9358. if (true) {
  9359. if(FlareZHat[id] && type == "hat") {
  9360. return FlareZHat[id];
  9361. } else {
  9362. if(type == "acc") {
  9363. return ".././img/accessories/access_" + id + ".png";
  9364. } else if(type == "hat") {
  9365. return ".././img/hats/hat_" + id + ".png";
  9366. } else {
  9367. return ".././img/weapons/" + id + ".png";
  9368. }
  9369. }
  9370. } else {
  9371. if(type == "acc") {
  9372. return ".././img/accessories/access_" + id + ".png";
  9373. } else if(type == "hat") {
  9374. return ".././img/hats/hat_" + id + ".png";
  9375. } else {
  9376. return ".././img/weapons/" + id + ".png";
  9377. }
  9378. }
  9379. }
  9380. // RENDER SKINS:
  9381. let skinSprites = {};
  9382. let skinPointers = {};
  9383. let tmpSkin;
  9384.  
  9385. function renderSkin(index, ctxt, parentSkin, owner) {
  9386. tmpSkin = skinSprites[index];
  9387. if (!tmpSkin) {
  9388. let tmpImage = new Image();
  9389. tmpImage.onload = function() {
  9390. this.isLoaded = true;
  9391. this.onload = null;
  9392. };
  9393. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9394. skinSprites[index] = tmpImage;
  9395. tmpSkin = tmpImage;
  9396. }
  9397. let tmpObj = parentSkin || skinPointers[index];
  9398. if (!tmpObj) {
  9399. for (let i = 0; i < hats.length; ++i) {
  9400. if (hats[i].id == index) {
  9401. tmpObj = hats[i];
  9402. break;
  9403. }
  9404. }
  9405. skinPointers[index] = tmpObj;
  9406. }
  9407. if (tmpSkin.isLoaded)
  9408. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  9409. if (!parentSkin && tmpObj.topSprite) {
  9410. ctxt.save();
  9411. ctxt.rotate(owner.skinRot);
  9412. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9413. ctxt.restore();
  9414. }
  9415. }
  9416.  
  9417. // RENDER TAIL:
  9418. var FlareZAcc = {
  9419. 21: "https://i.imgur.com/4ddZert.png",
  9420. 19: "https://i.imgur.com/sULkUZT.png",
  9421. };
  9422. function setTailTextureImage(id, type, id2) {
  9423. if (true) {
  9424. if(FlareZAcc[id] && type == "acc") {
  9425. return FlareZAcc[id];
  9426. } else {
  9427. if(type == "acc") {
  9428. return ".././img/accessories/access_" + id + ".png";
  9429. } else if(type == "hat") {
  9430. return ".././img/hats/hat_" + id + ".png";
  9431. } else {
  9432. return ".././img/weapons/" + id + ".png";
  9433. }
  9434. }
  9435. } else {
  9436. if(type == "acc") {
  9437. return ".././img/accessories/access_" + id + ".png";
  9438. } else if(type == "hat") {
  9439. return ".././img/hats/hat_" + id + ".png";
  9440. } else {
  9441. return ".././img/weapons/" + id + ".png";
  9442. }
  9443. }
  9444. }
  9445. function renderTailTextureImage(index, ctxt, owner) {
  9446. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  9447. var tmpImage = new Image();
  9448. tmpImage.onload = function() {
  9449. this.isLoaded = true,
  9450. this.onload = null
  9451. }
  9452. ,
  9453. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  9454. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9455. tmpSkin = tmpImage;
  9456. }
  9457. var tmpObj = accessPointers[index];
  9458. if (!tmpObj) {
  9459. for (var i = 0; i < accessories.length; ++i) {
  9460. if (accessories[i].id == index) {
  9461. tmpObj = accessories[i];
  9462. break;
  9463. }
  9464. }
  9465. accessPointers[index] = tmpObj;
  9466. }
  9467. if (tmpSkin.isLoaded) {
  9468. ctxt.save();
  9469. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9470. if (tmpObj.spin)
  9471. ctxt.rotate(owner.skinRot);
  9472. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9473. ctxt.restore();
  9474. }
  9475. }
  9476.  
  9477. let accessSprites = {};
  9478. let accessPointers = {};
  9479. var txt = true;
  9480.  
  9481. function renderTail(index, ctxt, owner) {
  9482. tmpSkin = accessSprites[index];
  9483. if (!tmpSkin) {
  9484. let tmpImage = new Image();
  9485. tmpImage.onload = function() {
  9486. this.isLoaded = true;
  9487. this.onload = null;
  9488. };
  9489. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9490. accessSprites[index] = tmpImage;
  9491. tmpSkin = tmpImage;
  9492. }
  9493. let tmpObj = accessPointers[index];
  9494. if (!tmpObj) {
  9495. for (let i = 0; i < accessories.length; ++i) {
  9496. if (accessories[i].id == index) {
  9497. tmpObj = accessories[i];
  9498. break;
  9499. }
  9500. }
  9501. accessPointers[index] = tmpObj;
  9502. }
  9503. if (tmpSkin.isLoaded) {
  9504. ctxt.save();
  9505. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  9506. if (tmpObj.spin)
  9507. ctxt.rotate(owner.skinRot);
  9508. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  9509. ctxt.restore();
  9510. }
  9511. }
  9512.  
  9513. var accessSprites2 = {};
  9514. var accessPointers2 = {};
  9515. function renderTail2(index, ctxt, owner) {
  9516. tmpSkin = accessSprites2[index];
  9517. if (!tmpSkin) {
  9518. var tmpImage = new Image();
  9519. tmpImage.onload = function() {
  9520. this.isLoaded = true;
  9521. this.onload = null;
  9522. };
  9523. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9524. accessSprites2[index] = tmpImage;
  9525. tmpSkin = tmpImage;
  9526. }
  9527. var tmpObj = accessPointers2[index];
  9528. if (!tmpObj) {
  9529. for (var i = 0; i < accessories.length; ++i) {
  9530. if (accessories[i].id == index) {
  9531. tmpObj = accessories[i];
  9532. break;
  9533. }
  9534. }
  9535. accessPointers2[index] = tmpObj;
  9536. }
  9537. if (tmpSkin.isLoaded) {
  9538. ctxt.save();
  9539. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  9540. if (tmpObj.spin)
  9541. ctxt.rotate(owner.skinRot);
  9542. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  9543. ctxt.restore();
  9544. }
  9545. }
  9546.  
  9547. // RENDER TOOL:
  9548. let toolSprites = {};
  9549. function renderTool(obj, variant, x, y, ctxt) {
  9550. let tmpSrc = obj.src + (variant || "");
  9551. let tmpSprite = toolSprites[tmpSrc];
  9552. if (!tmpSprite) {
  9553. tmpSprite = new Image();
  9554. tmpSprite.onload = function() {
  9555. this.isLoaded = true;
  9556. }
  9557. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9558. toolSprites[tmpSrc] = tmpSprite;
  9559. }
  9560. if (tmpSprite.isLoaded)
  9561. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9562. }
  9563.  
  9564. // RENDER PROJECTILES:
  9565. function renderProjectiles(layer, xOffset, yOffset) {
  9566. for (let i = 0; i < projectiles.length; i++) {
  9567. tmpObj = projectiles[i];
  9568. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  9569. tmpObj.update(delta);
  9570. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  9571. mainContext.save();
  9572. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9573. mainContext.rotate(tmpObj.dir);
  9574. renderProjectile(0, 0, tmpObj, mainContext, 1);
  9575. mainContext.restore();
  9576. }
  9577. }
  9578. };
  9579. }
  9580.  
  9581. // RENDER PROJECTILE:
  9582. let projectileSprites = {};//fz iz zexy
  9583.  
  9584. function renderProjectile(x, y, obj, ctxt, debug) {
  9585. if (obj.src) {
  9586. let tmpSrc = items.projectiles[obj.indx].src;
  9587. let tmpSprite = projectileSprites[tmpSrc];
  9588. if (!tmpSprite) {
  9589. tmpSprite = new Image();
  9590. tmpSprite.onload = function() {
  9591. this.isLoaded = true;
  9592. }
  9593. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9594. projectileSprites[tmpSrc] = tmpSprite;
  9595. }
  9596. if (tmpSprite.isLoaded)
  9597. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9598. } else if (obj.indx == 1) {
  9599. ctxt.fillStyle = "#939393";
  9600. renderCircle(x, y, obj.scale, ctxt);
  9601. }
  9602. }
  9603.  
  9604. // RENDER AI:
  9605. let aiSprites = {};
  9606.  
  9607. function renderAI(obj, ctxt) {
  9608. let tmpIndx = obj.index;
  9609. let tmpSprite = aiSprites[tmpIndx];
  9610. if (!tmpSprite) {
  9611. let tmpImg = new Image();
  9612. tmpImg.onload = function() {
  9613. this.isLoaded = true;
  9614. this.onload = null;
  9615. };
  9616. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9617. tmpSprite = tmpImg;
  9618. aiSprites[tmpIndx] = tmpSprite;
  9619. }
  9620. if (tmpSprite.isLoaded) {
  9621. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9622. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9623. }
  9624. }
  9625.  
  9626. // RENDER WATER BODIES:
  9627. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  9628.  
  9629. // MIDDLE RIVER:
  9630. let tmpW = config.riverWidth + padding;
  9631. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  9632. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9633. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9634. }
  9635. }
  9636.  
  9637. // RENDER GAME OBJECTS:
  9638. let gameObjectSprites = {};
  9639.  
  9640. function getResSprite(obj) {
  9641. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  9642. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  9643. let tmpSprite = gameObjectSprites[tmpIndex];
  9644. if (!tmpSprite) {
  9645. let blurScale = 6;
  9646. let tmpCanvas = document.createElement("canvas");
  9647. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  9648. let tmpContext = tmpCanvas.getContext('2d');
  9649. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9650. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9651. tmpContext.strokeStyle = outlineColor;
  9652. tmpContext.lineWidth = outlineWidth;
  9653. // if (isNight) {
  9654. // tmpContext.shadowBlur = blurScale;
  9655. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  9656. // }
  9657. if (obj.type == 0) {
  9658. let tmpScale;
  9659. let tmpCount = 8;
  9660. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  9661. for (let i = 0; i < 2; ++i) {
  9662. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  9663. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  9664. tmpContext.fillStyle = !biomeID ? (!i ? "#220b73" : "#100145") : (!i ? "#220b73" : "#100145");
  9665. tmpContext.fill();
  9666. if (!i) {
  9667. tmpContext.stroke();
  9668. tmpContext.shadowBlur = null;
  9669. tmpContext.shadowColor = null;
  9670. tmpContext.globalAlpha = 1;
  9671. }
  9672. }
  9673. } else if (obj.type == 1) {
  9674. if (biomeID == 2) {
  9675. tmpContext.fillStyle = "#0f0d0d";
  9676. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9677. tmpContext.fill();
  9678. tmpContext.stroke();
  9679.  
  9680. //tmpContext.shadowBlur = null;
  9681. //tmpContext.shadowColor = null;
  9682.  
  9683. tmpContext.fillStyle = "#2cf257";
  9684. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9685. tmpContext.fillStyle = "#33ed2d";
  9686. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9687. } else {
  9688. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  9689. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  9690. tmpContext.fill();
  9691. tmpContext.stroke();
  9692.  
  9693. //tmpContext.shadowBlur = null;
  9694. //tmpContext.shadowColor = null;
  9695.  
  9696. tmpContext.fillStyle = biomeID ? "#fc0fc0 " : "#fc0fc0 ";
  9697. let tmpRange;
  9698. let berries = 4;
  9699. let rotVal = (Math.PI * 2) / berries;
  9700. for (let i = 0; i < berries; ++i) {
  9701. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  9702. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9703. UTILS.randInt(10, 12), tmpContext);
  9704. }
  9705. }
  9706. } else if (obj.type == 2 || obj.type == 3) {
  9707. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  9708. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9709. tmpContext.fill();
  9710. tmpContext.stroke();
  9711.  
  9712. tmpContext.shadowBlur = null;
  9713. tmpContext.shadowColor = null;
  9714.  
  9715. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  9716. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9717. tmpContext.fill();
  9718. }
  9719. tmpSprite = tmpCanvas;
  9720. gameObjectSprites[tmpIndex] = tmpSprite;
  9721. }
  9722. return tmpSprite;
  9723. }
  9724.  
  9725. // GET ITEM SPRITE:
  9726. let itemSprites = [];
  9727.  
  9728. function getItemSprite(obj, asIcon) {
  9729. let tmpSprite = itemSprites[obj.id];
  9730. if (!tmpSprite || asIcon) {
  9731. let blurScale = !asIcon ? 20 : 5;
  9732. let tmpCanvas = document.createElement("canvas");
  9733. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  9734. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  9735.  
  9736. let tmpContext = tmpCanvas.getContext("2d");
  9737. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  9738. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  9739. tmpContext.strokeStyle = outlineColor;
  9740. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  9741. if (!asIcon) {
  9742. tmpContext.shadowBlur = 8;
  9743. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  9744. }
  9745.  
  9746. if (obj.name == "apple") {
  9747. tmpContext.fillStyle = "#c15555";
  9748. renderCircle(0, 0, obj.scale, tmpContext);
  9749. tmpContext.fillStyle = "#89a54c";
  9750. let leafDir = -(Math.PI / 2);
  9751. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9752. 25, leafDir + Math.PI / 2, tmpContext);
  9753. } else if (obj.name == "cookie") {
  9754. tmpContext.fillStyle = "#cca861";
  9755. renderCircle(0, 0, obj.scale, tmpContext);
  9756. tmpContext.fillStyle = "#937c4b";
  9757. let chips = 4;
  9758. let rotVal = (Math.PI * 2) / chips;
  9759. let tmpRange;
  9760. for (let i = 0; i < chips; ++i) {
  9761. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9762. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9763. UTILS.randInt(4, 5), tmpContext, true);
  9764. }
  9765. } else if (obj.name == "cheese") {
  9766. tmpContext.fillStyle = "#f4f3ac";
  9767. renderCircle(0, 0, obj.scale, tmpContext);
  9768. tmpContext.fillStyle = "#c3c28b";
  9769. let chips = 4;
  9770. let rotVal = (Math.PI * 2) / chips;
  9771. let tmpRange;
  9772. for (let i = 0; i < chips; ++i) {
  9773. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9774. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9775. UTILS.randInt(4, 5), tmpContext, true);
  9776. }
  9777. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9778. tmpContext.fillStyle = (obj.name == "castle wall") ? "#ff69b4" : (obj.name == "wood wall") ?
  9779. "#a5974c" : "#a5974c";
  9780. let sides = (obj.name == "castle wall") ? 4 : 3;
  9781. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9782. tmpContext.fill();
  9783. tmpContext.stroke();
  9784. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9785. "#ff1493" : "#ff1493";
  9786. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9787. tmpContext.fill();
  9788. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9789. obj.name == "spinning spikes") {
  9790. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#fc0fc0 " : "#fc0fc0 ";
  9791. let tmpScale = (obj.scale * 0.6)
  9792. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9793. tmpContext.fill();
  9794. tmpContext.stroke();
  9795. tmpContext.fillStyle = "#fc0fc0";
  9796. renderCircle(0, 0, tmpScale, tmpContext);
  9797. tmpContext.fillStyle = "#fc0fc0";
  9798. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9799. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9800. tmpContext.fillStyle = "#fc0fc0";
  9801. renderCircle(0, 0, reScale, tmpContext);
  9802. tmpContext.fillStyle = "#fc0fc0";
  9803. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9804. tmpContext.fillStyle = "#fc0fc0";
  9805. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9806. } else if (obj.name == "mine") {
  9807. tmpContext.fillStyle = "#fc0fc0";
  9808. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9809. tmpContext.fill();
  9810. tmpContext.stroke();
  9811. tmpContext.fillStyle = "#bcbcbc";
  9812. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9813. tmpContext.fill();
  9814. } else if (obj.name == "sapling") {
  9815. for (let i = 0; i < 2; ++i) {
  9816. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9817. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9818. tmpContext.fillStyle = (!i ? "#fc0fc0" : "#fc0fc0");
  9819. tmpContext.fill();
  9820. if (!i) tmpContext.stroke();
  9821. }
  9822. } else if (obj.name == "pit trap") {
  9823. tmpContext.fillStyle = "#00FFFF ";
  9824. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9825. tmpContext.fill();
  9826. tmpContext.stroke();
  9827. tmpContext.fillStyle = outlineColor;
  9828. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9829. tmpContext.fill();
  9830. } else if (obj.name == "boost pad") {
  9831. tmpContext.fillStyle = "#fc0fc0";
  9832. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9833. tmpContext.fill();
  9834. tmpContext.stroke();
  9835. tmpContext.fillStyle = "#dbd97d";
  9836. renderTriangle(obj.scale * 1, tmpContext);
  9837. } else if (obj.name == "turret") {
  9838. tmpContext.fillStyle = "#fc0fc0";
  9839. renderCircle(0, 0, obj.scale, tmpContext);
  9840. tmpContext.fillSyle
  9841. tmpContext.stroke();
  9842. tmpContext.fillStyle = "#ff0000";
  9843. let tmpLen = 50;
  9844. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9845. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9846. tmpContext.fill();
  9847. tmpContext.stroke();
  9848. } else if (obj.name == "platform") {
  9849. tmpContext.fillStyle = "#cebd5f";
  9850. let tmpCount = 4;
  9851. let tmpS = obj.scale * 2;
  9852. let tmpW = tmpS / tmpCount;
  9853. let tmpX = -(obj.scale / 2);
  9854. for (let i = 0; i < tmpCount; ++i) {
  9855. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9856. tmpContext.fill();
  9857. tmpContext.stroke();
  9858. tmpX += tmpS / tmpCount;
  9859. }
  9860. } else if (obj.name == "healing pad") {
  9861. tmpContext.fillStyle = "#fc0fc0";
  9862. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9863. tmpContext.fill();
  9864. tmpContext.stroke();
  9865. tmpContext.fillStyle = "#db6e6e";
  9866. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9867. } else if (obj.name == "spawn pad") {
  9868. tmpContext.fillStyle = "#fc0fc0";
  9869. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9870. tmpContext.fill();
  9871. tmpContext.stroke();
  9872. tmpContext.fillStyle = "#fc0fc0";
  9873. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9874. } else if (obj.name == "blocker") {
  9875. tmpContext.fillStyle = "#fc0fc0";
  9876. renderCircle(0, 0, obj.scale, tmpContext);
  9877. tmpContext.fill();
  9878. tmpContext.stroke();
  9879. tmpContext.rotate(Math.PI / 4);
  9880. tmpContext.fillStyle = "#db6e6e";
  9881. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9882. } else if (obj.name == "teleporter") {
  9883. tmpContext.fillStyle = "#7e7f82";
  9884. renderCircle(0, 0, obj.scale, tmpContext);
  9885. tmpContext.fill();
  9886. tmpContext.stroke();
  9887. tmpContext.rotate(Math.PI / 4);
  9888. tmpContext.fillStyle = "#d76edb";
  9889. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9890. }
  9891. tmpSprite = tmpCanvas;
  9892. if (!asIcon)
  9893. itemSprites[obj.id] = tmpSprite;
  9894. }
  9895. return tmpSprite;
  9896. }
  9897.  
  9898. function getItemSprite2(obj, tmpX, tmpY) {
  9899. let tmpContext = mainContext;
  9900. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  9901. tmpContext.save();
  9902. tmpContext.translate(tmpX, tmpY);
  9903. tmpContext.rotate(obj.dir);
  9904. tmpContext.strokeStyle = outlineColor;
  9905. tmpContext.lineWidth = outlineWidth;
  9906. if (obj.name == "apple") {
  9907. tmpContext.fillStyle = "#00FFFF";
  9908. renderCircle(0, 0, obj.scale, tmpContext);
  9909. tmpContext.fillStyle = "#00FFFF";
  9910. let leafDir = -(Math.PI / 2);
  9911. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  9912. 25, leafDir + Math.PI / 2, tmpContext);
  9913. } else if (obj.name == "cookie") {
  9914. tmpContext.fillStyle = "#fc0fc0";
  9915. renderCircle(0, 0, obj.scale, tmpContext);
  9916. tmpContext.fillStyle = "#fc0fc0";
  9917. let chips = 4;
  9918. let rotVal = (Math.PI * 2) / chips;
  9919. let tmpRange;
  9920. for (let i = 0; i < chips; ++i) {
  9921. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9922. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9923. UTILS.randInt(4, 5), tmpContext, true);
  9924. }
  9925. } else if (obj.name == "cheese") {
  9926. tmpContext.fillStyle = "#f4f3ac";
  9927. renderCircle(0, 0, obj.scale, tmpContext);
  9928. tmpContext.fillStyle = "#c3c28b";
  9929. let chips = 4;
  9930. let rotVal = (Math.PI * 2) / chips;
  9931. let tmpRange;
  9932. for (let i = 0; i < chips; ++i) {
  9933. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9934. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  9935. UTILS.randInt(4, 5), tmpContext, true);
  9936. }
  9937. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9938. tmpContext.fillStyle = (obj.name == "castle wall") ? "#00FFFF" : (obj.name == "wood wall") ?
  9939. "#00FFFF" : "#00FFFF";
  9940. let sides = (obj.name == "castle wall") ? 4 : 3;
  9941. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9942. tmpContext.fill();
  9943. tmpContext.stroke();
  9944. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  9945. "#00FFFF" : "#00FFFF";
  9946. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9947. tmpContext.fill();
  9948. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  9949. obj.name == "spinning spikes") {
  9950. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#0cf0e4" : "#0cf0e4";
  9951. let tmpScale = (obj.scale * 0.6);
  9952. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  9953. tmpContext.fill();
  9954. tmpContext.stroke();
  9955. tmpContext.fillStyle = "#00FFFF";
  9956. renderCircle(0, 0, tmpScale, tmpContext);
  9957. tmpContext.fillStyle = "#00FFFF";
  9958. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9959. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9960. tmpContext.fillStyle = "#808080";
  9961. renderCircle(0, 0, reScale, tmpContext);
  9962. tmpContext.fillStyle = "#ffffff";
  9963. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  9964. tmpContext.fillStyle = "#ffffff";
  9965. renderCircle(0, 0, reScale * 0.5, tmpContext);
  9966. } else if (obj.name == "mine") {
  9967. tmpContext.fillStyle = "#bbffff";
  9968. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9969. tmpContext.fill();
  9970. tmpContext.stroke();
  9971. tmpContext.fillStyle = "#bbffff";
  9972. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9973. tmpContext.fill();
  9974. } else if (obj.name == "sapling") {
  9975. for (let i = 0; i < 2; ++i) {
  9976. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  9977. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9978. tmpContext.fillStyle = (!i ? "#fc0fc0" : "#fc0fc0");
  9979. tmpContext.fill();
  9980. if (!i) tmpContext.stroke();
  9981. }
  9982. } else if (obj.name == "pit trap") {
  9983. tmpContext.fillStyle = "#ff2800";
  9984. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9985. tmpContext.fill();
  9986. tmpContext.stroke();
  9987. tmpContext.fillStyle = outlineColor;
  9988. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9989. tmpContext.fill();
  9990. } else if (obj.name == "boost pad") {
  9991. tmpContext.fillStyle = "#7e7f82";
  9992. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9993. tmpContext.fill();
  9994. tmpContext.stroke();
  9995. tmpContext.fillStyle = "#dbd97d";
  9996. renderTriangle(obj.scale * 1, tmpContext);
  9997. } else if (obj.name == "turret") {
  9998. tmpContext.fillStyle = "#a5974c";
  9999. renderCircle(0, 0, obj.scale, tmpContext);
  10000. tmpContext.fill();
  10001. tmpContext.stroke();
  10002. tmpContext.fillStyle = "#939393";
  10003. let tmpLen = 50;
  10004. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10005. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10006. tmpContext.fill();
  10007. tmpContext.stroke();
  10008. } else if (obj.name == "platform") {
  10009. tmpContext.fillStyle = "#cebd5f";
  10010. let tmpCount = 4;
  10011. let tmpS = obj.scale * 2;
  10012. let tmpW = tmpS / tmpCount;
  10013. let tmpX = -(obj.scale / 2);
  10014. for (let i = 0; i < tmpCount; ++i) {
  10015. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10016. tmpContext.fill();
  10017. tmpContext.stroke();
  10018. tmpX += tmpS / tmpCount;
  10019. }
  10020. } else if (obj.name == "healing pad") {
  10021. tmpContext.fillStyle = "#7e7f82";
  10022. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10023. tmpContext.fill();
  10024. tmpContext.stroke();
  10025. tmpContext.fillStyle = "#db6e6e";
  10026. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10027. } else if (obj.name == "spawn pad") {
  10028. tmpContext.fillStyle = "#7e7f82";
  10029. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10030. tmpContext.fill();
  10031. tmpContext.stroke();
  10032. tmpContext.fillStyle = "#71aad6";
  10033. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10034. } else if (obj.name == "blocker") {
  10035. tmpContext.fillStyle = "#7e7f82";
  10036. renderCircle(0, 0, obj.scale, tmpContext);
  10037. tmpContext.fill();
  10038. tmpContext.stroke();
  10039. tmpContext.rotate(Math.PI / 4);
  10040. tmpContext.fillStyle = "#db6e6e";
  10041. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10042. } else if (obj.name == "teleporter") {
  10043. tmpContext.fillStyle = "#7e7f82";
  10044. renderCircle(0, 0, obj.scale, tmpContext);
  10045. tmpContext.fill();
  10046. tmpContext.stroke();
  10047. tmpContext.rotate(Math.PI / 4);
  10048. tmpContext.fillStyle = "#d76edb";
  10049. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10050. }
  10051. tmpContext.restore();
  10052. }
  10053.  
  10054. let objSprites = [];
  10055.  
  10056. function getObjSprite(obj) {
  10057. let tmpSprite = objSprites[obj.id];
  10058. if (!tmpSprite) {
  10059. // let blurScale = isNight ? 20 : 0;
  10060. let tmpCanvas = document.createElement("canvas");
  10061. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  10062. let tmpContext = tmpCanvas.getContext("2d");
  10063. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10064. tmpContext.rotate(Math.PI / 2);
  10065. tmpContext.strokeStyle = outlineColor;
  10066. tmpContext.lineWidth = outlineWidth;
  10067. // if (isNight) {
  10068. // tmpContext.shadowBlur = 20;
  10069. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10070. // }
  10071. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10072. tmpContext.fillStyle = obj.name == "poison spikes" ? "#690f05" : "#690f05";
  10073. let tmpScale = obj.scale * 0.6;
  10074. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10075. tmpContext.fill();
  10076. tmpContext.stroke();
  10077. tmpContext.fillStyle = "#a5974c";
  10078. renderCircle(0, 0, tmpScale, tmpContext);
  10079. tmpContext.fillStyle = "#cc5151";
  10080. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10081. } else if (obj.name == "pit trap") {
  10082. tmpContext.fillStyle = "#a5974c";
  10083. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10084. tmpContext.fill();
  10085. tmpContext.stroke();
  10086. tmpContext.fillStyle = "#a5974c";
  10087. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10088. tmpContext.fill();
  10089. }
  10090. tmpSprite = tmpCanvas;
  10091. objSprites[obj.id] = tmpSprite;
  10092. }
  10093. return tmpSprite;
  10094. }
  10095.  
  10096. // GET MARK SPRITE:
  10097. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10098. let center = {
  10099. x: screenWidth / 2,
  10100. y: screenHeight / 2,
  10101. };
  10102. tmpContext.lineWidth = outlineWidth;
  10103. mainContext.globalAlpha = 0.2;
  10104. tmpContext.strokeStyle = outlineColor;
  10105. tmpContext.save();
  10106. tmpContext.translate(tmpX, tmpY);
  10107. tmpContext.rotate(90**10);
  10108. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10109. tmpContext.fillStyle = (obj.name == "poison spikes")?"#690f05":"#690f05";
  10110. var tmpScale = (obj.scale);
  10111. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  10112. tmpContext.fill();
  10113. tmpContext.stroke();
  10114. tmpContext.fillStyle = "#a5974c";
  10115. renderCircle(0, 0, tmpScale, tmpContext);
  10116. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10117. tmpContext.fillStyle = "#a34040";
  10118. } else {
  10119. tmpContext.fillStyle = "#c9b758";
  10120. }
  10121. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  10122. } else if (obj.name == "turret") {
  10123. renderCircle(0, 0, obj.scale, tmpContext);
  10124. tmpContext.fill();
  10125. tmpContext.stroke();
  10126. tmpContext.fillStyle = "#939393";
  10127. let tmpLen = 50;
  10128. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10129. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10130. tmpContext.fill();
  10131. tmpContext.stroke();
  10132. } else if (obj.name == "teleporter") {
  10133. tmpContext.fillStyle = "#7e7f82";
  10134. renderCircle(0, 0, obj.scale, tmpContext);
  10135. tmpContext.fill();
  10136. tmpContext.stroke();
  10137. tmpContext.rotate(Math.PI / 4);
  10138. tmpContext.fillStyle = "#d76edb";
  10139. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10140. } else if (obj.name == "platform") {
  10141. tmpContext.fillStyle = "#cebd5f";
  10142. let tmpCount = 4;
  10143. let tmpS = obj.scale * 2;
  10144. let tmpW = tmpS / tmpCount;
  10145. let tmpX = -(obj.scale / 2);
  10146. for (let i = 0; i < tmpCount; ++i) {
  10147. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10148. tmpContext.fill();
  10149. tmpContext.stroke();
  10150. tmpX += tmpS / tmpCount;
  10151. }
  10152. } else if (obj.name == "healing pad") {
  10153. tmpContext.fillStyle = "#7e7f82";
  10154. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10155. tmpContext.fill();
  10156. tmpContext.stroke();
  10157. tmpContext.fillStyle = "#db6e6e";
  10158. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10159. } else if (obj.name == "spawn pad") {
  10160. tmpContext.fillStyle = "#7e7f82";
  10161. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10162. tmpContext.fill();
  10163. tmpContext.stroke();
  10164. tmpContext.fillStyle = "#71aad6";
  10165. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10166. } else if (obj.name == "blocker") {
  10167. tmpContext.fillStyle = "#7e7f82";
  10168. renderCircle(0, 0, obj.scale, tmpContext);
  10169. tmpContext.fill();
  10170. tmpContext.stroke();
  10171. tmpContext.rotate(Math.PI / 4);
  10172. tmpContext.fillStyle = "#808080";
  10173. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10174. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10175. tmpContext.fillStyle = "#ffffff";
  10176. renderCircle(0, 0, obj.scale, tmpContext);
  10177. tmpContext.fillStyle = "#808080";
  10178. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10179. tmpContext.fillStyle = "#800080";
  10180. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10181.  
  10182. } else if (obj.name == "pit trap") {
  10183. tmpContext.fillStyle = "#a5974c";
  10184. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10185. tmpContext.fill();
  10186. tmpContext.stroke();
  10187. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10188. tmpContext.fillStyle = "#a34040";
  10189. } else {
  10190. tmpContext.fillStyle = outlineColor;
  10191. }
  10192. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10193. tmpContext.fill();
  10194. }
  10195. tmpContext.restore();
  10196. }
  10197.  
  10198. // OBJECT ON SCREEN:
  10199. function isOnScreen(x, y, s) {
  10200. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10201. s,
  10202. maxScreenHeight));
  10203. }
  10204.  
  10205. // RENDER GAME OBJECTS:
  10206. function renderGameObjects(layer, xOffset, yOffset) {
  10207. let tmpSprite;
  10208. let tmpX;
  10209. let tmpY;
  10210. liztobj.forEach((tmp) => {
  10211. tmpObj = tmp;
  10212. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  10213. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  10214. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  10215. if (layer == 0) {
  10216. tmpObj.update(delta);
  10217. }
  10218. mainContext.globalAlpha = tmpObj.alpha;
  10219. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  10220. if (tmpObj.isItem) {
  10221. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  10222. tmpSprite = getObjSprite(tmpObj);
  10223. } else {
  10224. tmpSprite = getItemSprite(tmpObj);
  10225. }
  10226.  
  10227. mainContext.save();
  10228. mainContext.translate(tmpX, tmpY);
  10229. mainContext.rotate(tmpObj.dir);
  10230. if (!tmpObj.active) {
  10231. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  10232. }
  10233. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  10234.  
  10235. if (tmpObj.blocker) {
  10236. mainContext.strokeStyle = "#Ffff00";
  10237. mainContext.globalAlpha = 0.3;
  10238. mainContext.lineWidth = 6;
  10239. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  10240. }
  10241. mainContext.restore();
  10242. } else {
  10243. tmpSprite = getResSprite(tmpObj);
  10244. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  10245. }
  10246. }
  10247. if (layer == 3 && !useWasd) {
  10248. if (tmpObj.health < tmpObj.maxHealth) {
  10249. // HEALTH HOLDER:
  10250. mainContext.fillStyle = darkOutlineColor;
  10251. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  10252. mainContext.fill();
  10253.  
  10254. // HEALTH BAR:
  10255. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#ff69b4" : "#ff69b4";
  10256. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  10257. mainContext.fill();
  10258. }
  10259. }
  10260. }
  10261. });
  10262.  
  10263. // PLACE VISIBLE:
  10264. if (layer == 0) {
  10265. if (placeVisible.length) {
  10266. placeVisible.forEach((places) => {
  10267. tmpX = places.x - xOffset;
  10268. tmpY = places.y - yOffset;
  10269. markObject(places, tmpX, tmpY);
  10270. });
  10271. }
  10272. }
  10273. }
  10274.  
  10275. function markObject(tmpObj, tmpX, tmpY) {
  10276. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10277. }
  10278.  
  10279. // RENDER MINIMAP:
  10280. class MapPing {
  10281. constructor(color, scale) {
  10282. this.init = function(x, y) {
  10283. this.scale = 0;
  10284. this.x = x;
  10285. this.y = y;
  10286. this.active = true;
  10287. };
  10288. this.update = function(ctxt, delta) {
  10289. if (this.active) {
  10290. this.scale += 0.05 * delta;
  10291. if (this.scale >= scale) {
  10292. this.active = false;
  10293. } else {
  10294. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10295. ctxt.beginPath();
  10296. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  10297. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10298. ctxt.stroke();
  10299. }
  10300. }
  10301. };
  10302. this.color = color;
  10303. }
  10304. }
  10305.  
  10306. function pingMap(x, y) {
  10307. tmpPing = mapPings.find(pings => !pings.active);
  10308. if (!tmpPing) {
  10309. tmpPing = new MapPing("#fff", config.mapPingScale);
  10310. mapPings.push(tmpPing);
  10311. }
  10312. tmpPing.init(x, y);
  10313. }
  10314.  
  10315. function updateMapMarker() {
  10316. mapMarker.x = player.x;
  10317. mapMarker.y = player.y;
  10318. }
  10319.  
  10320. function renderMinimap(delta) {
  10321. if (player && player.alive) {
  10322. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10323.  
  10324. // RENDER PINGS:
  10325. mapContext.lineWidth = 4;
  10326. for (let i = 0; i < mapPings.length; ++i) {
  10327. tmpPing = mapPings[i];
  10328. mapContext.strokeStyle = tmpPing.color;
  10329. tmpPing.update(mapContext, delta);
  10330. }
  10331.  
  10332. // RENDER BREAK TRACKS:
  10333. mapContext.globalAlpha = 1;
  10334. mapContext.fillStyle = "#ff0000";
  10335. if (breakTrackers.length) {
  10336. mapContext.fillStyle = "#abcdef";
  10337. mapContext.font = "34px HammerSmith One";
  10338. mapContext.textBaseline = "middle";
  10339. mapContext.textAlign = "center";
  10340. for (let i = 0; i < breakTrackers.length;) {
  10341. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  10342. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  10343. i += 2;
  10344. }
  10345. }
  10346.  
  10347. // RENDER PLAYERS:
  10348. mapContext.globalAlpha = 1;
  10349. mapContext.fillStyle = "#fff";
  10350. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10351. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10352. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10353. if (player.team && minimapData) {
  10354. for (let i = 0; i < minimapData.length;) {
  10355. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10356. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10357. i += 2;
  10358. }
  10359. }
  10360.  
  10361. // RENDER BOTS:
  10362. if (bots.length) {
  10363. bots.forEach((tmp) => {
  10364. if (tmp.inGame) {
  10365. mapContext.globalAlpha = 1;
  10366. mapContext.strokeStyle = "#cc5151";
  10367. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10368. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10369. }
  10370. });
  10371. }
  10372.  
  10373. // DEATH LOCATION:
  10374. if (lastDeath) {
  10375. mapContext.fillStyle = "#fc5553";
  10376. mapContext.font = "34px HammerSmith One";
  10377. mapContext.textBaseline = "middle";
  10378. mapContext.textAlign = "center";
  10379. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10380. (lastDeath.y / config.mapScale) * mapDisplay.height);
  10381. }
  10382.  
  10383. // MAP MARKER:
  10384. if (mapMarker) {
  10385. mapContext.fillStyle = "#fff";
  10386. mapContext.font = "34px HammerSmith One";
  10387. mapContext.textBaseline = "middle";
  10388. mapContext.textAlign = "center";
  10389. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  10390. (mapMarker.y / config.mapScale) * mapDisplay.height);
  10391. }
  10392. }
  10393. }
  10394.  
  10395. // ICONS:
  10396. let crossHairs = [
  10397. "https://media.discordapp.net/attachments/1303774996140654645/1305246530072084480/Daco_5877090.png?ex=6732550f&is=6731038f&hm=2017af86a39efcec2fc68e473f103fed8eedb62d8edea10e5321950777029da9&=&format=webp&quality=lossless&width=601&height=601",
  10398. "https://media.discordapp.net/attachments/1303774996140654645/1305246530072084480/Daco_5877090.png?ex=6732550f&is=6731038f&hm=2017af86a39efcec2fc68e473f103fed8eedb62d8edea10e5321950777029da9&=&format=webp&quality=lossless&width=601&height=601"
  10399. ];
  10400. let crossHairSprites = {};
  10401. let iconSprites = {};
  10402. let icons = ["crown", "skull"];
  10403.  
  10404. function loadIcons() {
  10405. for (let i = 0; i < icons.length; ++i) {
  10406. let tmpSprite = new Image();
  10407. tmpSprite.onload = function() {
  10408. this.isLoaded = true;
  10409. };
  10410. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  10411. iconSprites[icons[i]] = tmpSprite;
  10412. }
  10413. for (let i = 0; i < crossHairs.length; ++i) {
  10414. let tmpSprite = new Image();
  10415. tmpSprite.onload = function() {
  10416. this.isLoaded = true;
  10417. };
  10418. tmpSprite.src = crossHairs[i];
  10419. crossHairSprites[i] = tmpSprite;
  10420. }
  10421. }
  10422. loadIcons();
  10423.  
  10424. function cdf (e, t){
  10425. try {
  10426. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  10427. } catch(e){
  10428. return Infinity;
  10429. }
  10430. }
  10431. // UPDATE GAME:
  10432. function updateGame() {
  10433. if(gameObjects.length && inGame) {
  10434. gameObjects.forEach((tmp) => {
  10435. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  10436. if(!liztobj.includes(tmp)) {
  10437. liztobj.push(tmp);
  10438. tmp.render = true;
  10439. }
  10440. } else {
  10441. if(liztobj.includes(tmp)) {
  10442. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10443. tmp.render = false;
  10444. const index = liztobj.indexOf(tmp);
  10445. if (index > -1) { // only splice array when item is found
  10446. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10447. }
  10448. }
  10449. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  10450. tmp.render = false;
  10451. const index = liztobj.indexOf(tmp);
  10452. if (index > -1) { // only splice array when item is found
  10453. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10454. }
  10455. } else {
  10456. tmp.render = false;
  10457. const index = liztobj.indexOf(tmp);
  10458. if (index > -1) { // only splice array when item is found
  10459. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  10460. }
  10461. }
  10462. }
  10463. })
  10464. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  10465. }
  10466.  
  10467. // if (config.resetRender) {
  10468. mainContext.beginPath();
  10469. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  10470. // }
  10471. mainContext.globalAlpha = 1;
  10472.  
  10473. // MOVE CAMERA:
  10474. if (player) {
  10475. if (false) {
  10476. camX = player.x;
  10477. camY = player.y;
  10478. } else {
  10479. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  10480. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  10481. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  10482. if (tmpDist > 0.05) {
  10483. camX += camSpd * Math.cos(tmpDir);
  10484. camY += camSpd * Math.sin(tmpDir);
  10485. } else {
  10486. camX = player.x;
  10487. camY = player.y;
  10488. }
  10489. }
  10490. } else {
  10491. camX = config.mapScale / 2 + config.riverWidth;
  10492. camY = config.mapScale / 2;
  10493. }
  10494. // PATHFINDER LINE
  10495. if (pathFind.active) {
  10496. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  10497. mainContext.lineWidth = player.scale / 5;
  10498. mainContext.globalAlpha = 1;
  10499. mainContext.strokeStyle = "red";
  10500. mainContext.beginPath();
  10501. pathFind.array.forEach((path, i) => {
  10502. let pathXY = {
  10503. x: (pathFind.scale / pathFind.grid) * path.x,
  10504. y: (pathFind.scale / pathFind.grid) * path.y
  10505. }
  10506. let render = {
  10507. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  10508. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  10509. }
  10510. if (i == 0) {
  10511. mainContext.moveTo(render.x, render.y);
  10512. } else {
  10513. mainContext.lineTo(render.x, render.y);
  10514. }
  10515. });
  10516. mainContext.stroke();
  10517. }
  10518. }
  10519. // INTERPOLATE PLAYERS AND AI:
  10520. let lastTime = now - (1000 / config.serverUpdateRate);
  10521. let tmpDiff;
  10522. for (let i = 0; i < players.length + ais.length; ++i) {
  10523. tmpObj = players[i] || ais[i - players.length];
  10524. if (tmpObj && tmpObj.visible) {
  10525. if (tmpObj.forcePos) {
  10526. tmpObj.x = tmpObj.x2;
  10527. tmpObj.y = tmpObj.y2;
  10528. tmpObj.dir = tmpObj.d2;
  10529. } else {
  10530. let total = tmpObj.t2 - tmpObj.t1;
  10531. let fraction = lastTime - tmpObj.t1;
  10532. let ratio = (fraction / total);
  10533. let rate = 170;
  10534. tmpObj.dt += delta;
  10535. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  10536. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  10537. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  10538. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  10539. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  10540. if (config.anotherVisual) {
  10541. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10542. } else {
  10543. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  10544. }
  10545. }
  10546. }
  10547. }
  10548.  
  10549. // RENDER CORDS:
  10550. let xOffset = camX - (maxScreenWidth / 2);
  10551. let yOffset = camY - (maxScreenHeight / 2);
  10552.  
  10553. // RENDER BACKGROUND:
  10554. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10555. mainContext.fillStyle = "#b6db66";
  10556. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10557. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  10558. mainContext.fillStyle = "#dbc666";
  10559. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10560. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  10561. mainContext.fillStyle = "#fff";
  10562. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10563. } else if (config.snowBiomeTop - yOffset >= 0) {
  10564. mainContext.fillStyle = "#fff";
  10565. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  10566. mainContext.fillStyle = "#b6db66";
  10567. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  10568. maxScreenHeight - (config.snowBiomeTop - yOffset));
  10569. } else {
  10570. mainContext.fillStyle = "#b6db66";
  10571. mainContext.fillRect(0, 0, maxScreenWidth,
  10572. (config.mapScale - config.snowBiomeTop - yOffset));
  10573. mainContext.fillStyle = "#dbc666";
  10574. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  10575. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  10576. }
  10577.  
  10578. // RENDER WATER AREAS:
  10579. if (!firstSetup) {
  10580. waterMult += waterPlus * config.waveSpeed * delta;
  10581. if (waterMult >= config.waveMax) {
  10582. waterMult = config.waveMax;
  10583. waterPlus = -1;
  10584. } else if (waterMult <= 1) {
  10585. waterMult = waterPlus = 1;
  10586. }
  10587. mainContext.globalAlpha = 1;
  10588. mainContext.fillStyle = "#dbc666";
  10589. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  10590. mainContext.fillStyle = "#91b2db";
  10591. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  10592. }
  10593.  
  10594. // RENDER DEAD PLAYERS:
  10595. mainContext.globalAlpha = 1;
  10596. mainContext.strokeStyle = outlineColor;
  10597. renderDeadPlayers(xOffset, yOffset);
  10598.  
  10599. // RENDER BOTTOM LAYER:
  10600. mainContext.globalAlpha = 1;
  10601. mainContext.strokeStyle = outlineColor;
  10602. renderGameObjects(-1, xOffset, yOffset);
  10603.  
  10604. // RENDER PROJECTILES:
  10605. mainContext.globalAlpha = 1;
  10606. mainContext.lineWidth = outlineWidth;
  10607. renderProjectiles(0, xOffset, yOffset);
  10608.  
  10609. // RENDER PLAYERS:
  10610. renderPlayers(xOffset, yOffset, 0);
  10611.  
  10612. // RENDER AI:
  10613. mainContext.globalAlpha = 1;
  10614. for (let i = 0; i < ais.length; ++i) {
  10615. tmpObj = ais[i];
  10616. if (tmpObj.active && tmpObj.visible) {
  10617. tmpObj.animate(delta);
  10618. mainContext.save();
  10619. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10620. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  10621. renderAI(tmpObj, mainContext);
  10622. mainContext.restore();
  10623. }
  10624. }
  10625.  
  10626. // RENDER GAME OBJECTS (LAYERED):
  10627. renderGameObjects(0, xOffset, yOffset);
  10628. renderProjectiles(1, xOffset, yOffset);
  10629. renderGameObjects(1, xOffset, yOffset);
  10630. renderPlayers(xOffset, yOffset, 1);
  10631. renderGameObjects(2, xOffset, yOffset);
  10632. renderGameObjects(3, xOffset, yOffset);
  10633.  
  10634. // MAP BOUNDARIES:
  10635. mainContext.fillStyle = "#000";
  10636. mainContext.globalAlpha = 0.09;
  10637. if (xOffset <= 0) {
  10638. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  10639. }
  10640. if (config.mapScale - xOffset <= maxScreenWidth) {
  10641. let tmpY = Math.max(0, -yOffset);
  10642. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  10643. }
  10644. if (yOffset <= 0) {
  10645. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  10646. }
  10647. if (config.mapScale - yOffset <= maxScreenHeight) {
  10648. let tmpX = Math.max(0, -xOffset);
  10649. let tmpMin = 0;
  10650. if (config.mapScale - xOffset <= maxScreenWidth)
  10651. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  10652. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  10653. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  10654. }
  10655.  
  10656. // RENDER DAY/NIGHT TIME:
  10657. mainContext.globalAlpha = 1;
  10658. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  10659. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10660.  
  10661. // RENDER PLAYER AND AI UI:
  10662. mainContext.strokeStyle = darkOutlineColor;
  10663. mainContext.globalAlpha = 1;
  10664.  
  10665. for (let i = 0; i < players.length + ais.length; ++i) {
  10666. tmpObj = players[i] || ais[i - players.length];
  10667. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  10668. mainContext.strokeStyle = darkOutlineColor;
  10669.  
  10670. // NAME AND HEALTH:
  10671.  
  10672. // let izbot = false;
  10673.  
  10674. // bots.forEach((bot) => {
  10675. // if (tmpObj.sid == bot.sid) izbot = true
  10676. // else izbot = false;
  10677. // });
  10678.  
  10679. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  10680. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  10681. // bots.forEach((bot) => {
  10682. // if (tmpObj.sid == bot.sid) return;
  10683. // });
  10684.  
  10685. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  10686. mainContext.fillStyle = "#fff";
  10687. mainContext.textBaseline = "middle";
  10688. mainContext.textAlign = "center";
  10689. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  10690. mainContext.lineJoin = "round";
  10691. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10692. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  10693. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  10694. let tmpS = config.crownIconScale;
  10695. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  10696. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10697. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10698. }
  10699. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10700. let tmpS = config.crownIconScale;
  10701. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  10702. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  10703. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10704. }
  10705. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  10706. let tmpS = tmpObj.scale * 2.2;
  10707. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  10708. }
  10709. // izbot = false;
  10710. }
  10711. if (tmpObj.health > 0) {
  10712.  
  10713. if(tmpObj.name != "Trash Slave") {
  10714. // HEALTH HOLDER:
  10715. mainContext.fillStyle = darkOutlineColor;
  10716. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  10717. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  10718. (config.healthBarPad * 2), 17, 8);
  10719. mainContext.fill();
  10720.  
  10721. // HEALTH BAR:
  10722. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  10723. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  10724. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  10725. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  10726. mainContext.fill();
  10727. }
  10728.  
  10729. if (tmpObj.isPlayer) {
  10730. mainContext.globalAlpha = 1;
  10731. let targetReloads = {
  10732. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  10733. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  10734. turret: (2500 - tmpObj.reloads[53]) / 2500
  10735. };
  10736. if (!tmpObj.currentReloads) {
  10737. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  10738. primary: targetReloads.primary,
  10739. secondary: targetReloads.secondary,
  10740. turret: targetReloads.turret
  10741. };
  10742. }
  10743. const lerpFactor = 0.3;
  10744. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  10745. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  10746. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  10747.  
  10748. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  10749. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  10750. const centerX = tmpObj.x - xOffset;
  10751. const centerY = tmpObj.y - yOffset;
  10752. const barRadius = 35;
  10753. const barWidth = 15;
  10754. const totalAngle = (Math.PI*2)/3; // Half circle
  10755. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  10756. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  10757. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  10758. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  10759.  
  10760. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  10761. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  10762. function returncoolcolor(RainbowCycle) {
  10763.  
  10764. }
  10765.  
  10766. mainContext.save();
  10767. if (tmpObj.currentReloads.primary < 0.999) {
  10768. mainContext.beginPath();
  10769. mainContext.lineCap = 'round';
  10770. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  10771. mainContext.lineWidth = 4;
  10772. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  10773. mainContext.stroke();
  10774. }
  10775. if (tmpObj.currentReloads.secondary < 0.999) {
  10776. mainContext.beginPath();
  10777. mainContext.lineCap = 'round';
  10778. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  10779. mainContext.lineWidth = 4;
  10780. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  10781. mainContext.stroke();
  10782. }
  10783. if (tmpObj.currentReloads.turret < 0.999) {
  10784. mainContext.beginPath();
  10785. mainContext.lineCap = 'round';
  10786. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  10787. mainContext.lineWidth = 4;
  10788. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  10789. mainContext.stroke();
  10790. }
  10791. mainContext.restore();
  10792.  
  10793. if(tmpObj.name != "Trash Slave") {
  10794. // SHAME COUNT:
  10795. mainContext.globalAlpha = 1;
  10796. mainContext.font = "24px HammerSmith One";
  10797. mainContext.fillStyle = "#fff";
  10798. mainContext.strokeStyle = darkOutlineColor;
  10799. mainContext.textBaseline = "middle";
  10800. mainContext.textAlign = "center";
  10801. mainContext.lineWidth = 8;
  10802. mainContext.lineJoin = "round";
  10803. let tmpS = config.crownIconScale;
  10804. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  10805. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  10806. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  10807. }
  10808.  
  10809. // PLAYER TRACER:
  10810. if (!tmpObj.isTeam(player)) {
  10811. let center = {
  10812. x: screenWidth / 2,
  10813. y: screenHeight / 2,
  10814. };
  10815. let alpha = Math.min(1, (UTILS.getDistance(0, 0, player.x - tmpObj.x, (player.y - tmpObj.y) * (16 / 9)) * 100) / (config.maxScreenHeight / 2) / center.y);
  10816. let dist = center.y * alpha / 2;
  10817. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  10818. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  10819. mainContext.save();
  10820. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  10821. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  10822. let by = 255 - (tmpObj.sid * 2);
  10823. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10824. mainContext.globalAlpha = alpha;
  10825. let renderTracer = function(s, ctx) {
  10826. ctx = ctx || mainContext;
  10827. let h = s * (Math.sqrt(3) / 2);
  10828. ctx.beginPath();
  10829. ctx.moveTo(0, -h / 1.5);
  10830. ctx.lineTo(-s / 2, h / 2);
  10831. ctx.lineTo(s / 2, h / 2);
  10832. ctx.lineTo(0, -h / 1.5);
  10833. ctx.fill();
  10834. ctx.closePath();
  10835. }
  10836. renderTracer(25, mainContext);
  10837. mainContext.restore();
  10838. }
  10839.  
  10840. if (getEl("predictType").value == "pre2") {
  10841. mainContext.lineWidth = 3;
  10842. mainContext.strokeStyle = "#fff";
  10843. mainContext.globalAlpha = 1;
  10844. mainContext.beginPath();
  10845. let render = {
  10846. x: tmpObj.x2 - xOffset,
  10847. y: tmpObj.y2 - yOffset
  10848. };
  10849. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10850. mainContext.lineTo(render.x, render.y);
  10851. mainContext.stroke();
  10852. } else if (getEl("predictType").value == "pre3") {
  10853. mainContext.lineWidth = 3;
  10854. mainContext.strokeStyle = "#cc5151";
  10855. mainContext.globalAlpha = 1;
  10856. mainContext.beginPath();
  10857. let render = {
  10858. x: tmpObj.x3 - xOffset,
  10859. y: tmpObj.y3 - yOffset
  10860. };
  10861. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10862. mainContext.lineTo(render.x, render.y);
  10863. mainContext.stroke();
  10864. }
  10865.  
  10866. }
  10867. }
  10868. }
  10869. }
  10870.  
  10871. if (player) {
  10872.  
  10873. // AUTOPUSH LINE:
  10874. if (my.autoPush && my.pushData) {
  10875. mainContext.lineWidth = 5;
  10876. mainContext.globalAlpha = 1;
  10877. mainContext.beginPath();
  10878. var x1 = player.x - xOffset;
  10879. var y1 = player.y - yOffset;
  10880. var x2 = my.pushData.x2 - xOffset;
  10881. var y2 = my.pushData.y2 - yOffset;
  10882. var x3 = my.pushData.x - xOffset;
  10883. var y3 = my.pushData.y - yOffset;
  10884.  
  10885. mainContext.moveTo(x1, y1);
  10886. mainContext.lineTo(x2, y2);
  10887. mainContext.lineTo(x3, y3);
  10888. mainContext.stroke();
  10889.  
  10890. var deltaX = x3 - x1;
  10891. var deltaY = y3 - y1;
  10892. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  10893.  
  10894. var maxDistance = 100;
  10895. var percentage = (distance / maxDistance) * 100;
  10896.  
  10897. percentage = Math.min(100, Math.max(0, percentage));
  10898. let spike;
  10899. mainContext.fillStyle = "white";
  10900. mainContext.strokeStyle = "black";
  10901. mainContext.lineWidth = 5;
  10902. mainContext.font = "27px Times New Roman";
  10903. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  10904. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10905. })[0];
  10906. if(nearTrap)
  10907. spike = liztobj.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) {
  10908. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  10909. })[0];
  10910.  
  10911. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  10912. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  10913.  
  10914. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  10915. mainContext.strokeText(near.aim2, xx, yy);
  10916. mainContext.fillText(near.aim2, xx, yy);
  10917. }
  10918. }
  10919.  
  10920. mainContext.globalAlpha = 1;
  10921.  
  10922. // RENDER ANIM TEXTS:
  10923. textManager.update(delta, mainContext, xOffset, yOffset);
  10924.  
  10925. // RENDER CHAT MESSAGES:
  10926. for (let i = 0; i < players.length; ++i) {
  10927. tmpObj = players[i];
  10928. if (tmpObj.visible) {
  10929. if (tmpObj.chatCountdown > 0) {
  10930. tmpObj.chatCountdown -= delta;
  10931. if (tmpObj.chatCountdown <= 0)
  10932. tmpObj.chatCountdown = 0;
  10933. mainContext.font = "32px HammerSmith One";
  10934. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  10935. mainContext.textBaseline = "middle";
  10936. mainContext.textAlign = "center";
  10937. let tmpX = tmpObj.x - xOffset;
  10938. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  10939. let tmpH = 47;
  10940. let tmpW = tmpSize.width + 17;
  10941. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10942. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10943. mainContext.fill();
  10944. mainContext.fillStyle = "#ff69b4";
  10945. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  10946. }
  10947. if (tmpObj.chat.count > 0) {
  10948. if (!useWasd) {
  10949. tmpObj.chat.count -= delta;
  10950. if (tmpObj.chat.count <= 0)
  10951. tmpObj.chat.count = 0;
  10952. mainContext.font = "32px HammerSmith One";
  10953. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  10954. mainContext.textBaseline = "middle";
  10955. mainContext.textAlign = "center";
  10956. let tmpX = tmpObj.x - xOffset;
  10957. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  10958. let tmpH = 47;
  10959. let tmpW = tmpSize.width + 17;
  10960. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  10961. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10962. mainContext.fill();
  10963. mainContext.fillStyle = "#ff69b4";
  10964. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  10965. } else {
  10966. tmpObj.chat.count = 0;
  10967. }
  10968. }
  10969. }
  10970. }
  10971.  
  10972. if (allChats.length) {
  10973. allChats.filter(ch => ch.active).forEach((ch) => {
  10974. if (!ch.alive) {
  10975. if (ch.alpha <= 1) {
  10976. ch.alpha += delta / 250;
  10977. if (ch.alpha >= 1) {
  10978. ch.alpha = 1;
  10979. ch.alive = true;
  10980. }
  10981. }
  10982. } else {
  10983. ch.alpha -= delta / 5000;
  10984. if (ch.alpha <= 0) {
  10985. ch.alpha = 0;
  10986. ch.active = false;
  10987. }
  10988. }
  10989. if (ch.active) {
  10990. mainContext.font = "20px Ubuntu";
  10991. let tmpSize = mainContext.measureText(ch.chat);
  10992. mainContext.textBaseline = "middle";
  10993. mainContext.textAlign = "center";
  10994. let tmpX = ch.x - xOffset;
  10995. let tmpY = ch.y - yOffset - 90;
  10996. let tmpH = 40;
  10997. let tmpW = tmpSize.width + 15;
  10998.  
  10999. mainContext.globalAlpha = ch.alpha;
  11000.  
  11001. mainContext.fillStyle = ch.owner.isTeam(player) ? "#ff69b4" : "#cc5151";
  11002. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11003. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  11004. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  11005.  
  11006. mainContext.lineWidth = 5;
  11007. mainContext.fillStyle = "#ccc";
  11008. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11009.  
  11010. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11011. mainContext.stroke();
  11012. mainContext.fill();
  11013.  
  11014. mainContext.fillStyle = "#ff1493";
  11015. mainContext.strokeStyle = "#ff1493";
  11016. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11017. mainContext.fillText(ch.chat, tmpX, tmpY);
  11018. ch.y -= delta / 100;
  11019. }
  11020. });
  11021. }
  11022.  
  11023. mainContext.globalAlpha = 1;
  11024.  
  11025. // RENDER MINIMAP:
  11026. renderMinimap(delta);
  11027. }
  11028.  
  11029. // UPDATE & ANIMATE:
  11030. window.requestAnimFrame = function() {
  11031. return null;
  11032. }
  11033. window.rAF = (function() {
  11034. return window.requestAnimationFrame ||
  11035. window.webkitRequestAnimationFrame ||
  11036. window.mozRequestAnimationFrame ||
  11037. function(callback) {
  11038. window.setTimeout(callback, 1000/9);
  11039. };
  11040. })();
  11041.  
  11042. function doUpdate() {
  11043. //rape modulus
  11044. now = performance.now();
  11045. delta = now - lastUpdate;
  11046. lastUpdate = now;
  11047. let timer = performance.now();
  11048. let diff = timer - fpsTimer.last;
  11049. if (diff >= 1000) {
  11050.  
  11051. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11052.  
  11053. fpsTimer.last = timer;
  11054. fpsTimer.time = 0;
  11055. }
  11056. fpsTimer.time++;
  11057.  
  11058. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  11059. getEl("packetStatus").innerHTML = secPacket;
  11060. updateGame();
  11061. rAF(doUpdate);
  11062. ms.avg = Math.round((ms.min+ms.max)/2);
  11063. }
  11064.  
  11065. prepareMenuBackground();
  11066. doUpdate();
  11067.  
  11068. function toggleUseless(boolean) {
  11069. getEl("instaType").disabled = boolean;
  11070. getEl("antiBullType").disabled = boolean;
  11071. getEl("predictType").disabled = boolean;
  11072. }
  11073. toggleUseless(useWasd);
  11074.  
  11075. let changeDays = {};
  11076. window.debug = function() {
  11077. my.waitHit = 0;
  11078. my.autoAim = false;
  11079. instaC.isTrue = false;
  11080. traps.inTrap = false;
  11081. itemSprites = [];
  11082. objSprites = [];
  11083. gameObjectSprites = [];
  11084. };
  11085. window.wasdMode = function() {
  11086. useWasd = !useWasd;
  11087. toggleUseless(useWasd);
  11088. };
  11089. window.startGrind = function() {
  11090. if (getEl("weaponGrind").checked) {
  11091. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11092. checkPlace(player.getItemType(22), i);
  11093. }
  11094. }
  11095. };
  11096. // REMOVED!!! so they cant abuse :)
  11097. let projects = [
  11098. "adorable-eight-guppy",
  11099. "galvanized-bittersweet-windshield"
  11100. ];
  11101. let botIDS = 0;
  11102. window.connectFillBots = function() {
  11103. botSkts = [];
  11104. botIDS = 0;
  11105. for (let i = 0; i < projects.length; i++) {
  11106. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11107. test.binaryType = "arraybuffer";
  11108.  
  11109. test.onopen = function() {
  11110. test.ssend = function(type) {
  11111. let data = Array.prototype.slice.call(arguments, 1);
  11112. let binary = window.msgpack.encode([type, data]);
  11113. test.send(binary);
  11114. };
  11115. for (let i = 0; i < 4; i++) {
  11116. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11117. action: "homepage"
  11118. }).then(function(token) {
  11119. let t = WS.url.split("wss://")[1].split("?")[0];
  11120. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  11121. botSkts.push([test]);
  11122. botIDS++;
  11123. });
  11124. }
  11125. };
  11126. test.onmessage = function(message) {
  11127. let data = new Uint8Array(message.data);
  11128. let parsed = window.msgpack.decode(data);
  11129. let type = parsed[0];
  11130. data = parsed[1];
  11131. };
  11132. }
  11133. };
  11134. window.destroyFillBots = function() {
  11135. botSkts.forEach((socket) => {
  11136. socket[0].close();
  11137. });
  11138. botSkts = [];
  11139. };
  11140. window.tryConnectBots = function() {
  11141. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  11142. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11143. action: "homepage"
  11144. }).then(function(token) {
  11145. // CONNECT SOCKET:
  11146. botSpawn(token);
  11147. });
  11148. }
  11149. };
  11150. window.destroyBots = function() {
  11151. bots.forEach((botyyyyy) => {
  11152. botyyyyy.closeSocket = true;
  11153. });
  11154. bots = [];
  11155. };
  11156. window.resBuild = function() {
  11157. if (gameObjects.length) {
  11158. gameObjects.forEach((tmp) => {
  11159. tmp.breakObj = false;
  11160. });
  11161. breakObjects = [];
  11162. }
  11163. };
  11164. window.toggleBotsCircle = function() {
  11165. player.circle = !player.circle;
  11166. };
  11167. window.toggleVisual = function() {
  11168. config.anotherVisual = !config.anotherVisual;
  11169. gameObjects.forEach((tmp) => {
  11170. if (tmp.active) {
  11171. tmp.dir = tmp.lastDir;
  11172. }
  11173. });
  11174. };
  11175. window.prepareUI = function(tmpObj) {
  11176. resize();
  11177. // CHAT STUFF:
  11178. var chatBox = document.getElementById("chatBox");
  11179. var chatHolder = document.getElementById("chatHolder");
  11180. var suggestBox = document.createElement("div");
  11181. suggestBox.id = "suggestBox";
  11182.  
  11183. var prevChats = [];
  11184. var prevChatsIndex = 0;
  11185.  
  11186. function toggleChat() {
  11187. if (!usingTouch) {
  11188. if (chatHolder.style.display == "block") {
  11189. if (chatBox.value) {
  11190. sendChat(chatBox.value);
  11191. }
  11192. closeChat();
  11193. } else {
  11194. storeMenu.style.display = "none";
  11195. allianceMenu.style.display = "none";
  11196. chatHolder.style.display = "block";
  11197. chatBox.focus();
  11198. resetMoveDir();
  11199. }
  11200. } else {
  11201. setTimeout(function () {
  11202. var chatMessage = prompt("chat message");
  11203. if (chatMessage) {
  11204. sendChat(chatMessage);
  11205. }
  11206. }, 1);
  11207. }
  11208. chatBox.value = "";
  11209. (() => {
  11210. prevChatsIndex = 0;
  11211. })();
  11212. }
  11213.  
  11214. function closeChat() {
  11215. chatBox.value = "";
  11216. chatHolder.style.display = "none";
  11217. }
  11218.  
  11219. // ACTION BAR:
  11220. UTILS.removeAllChildren(actionBar);
  11221.  
  11222. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11223. (function (i) {
  11224. UTILS.generateElement({
  11225. id: "actionBarItem" + i,
  11226. class: "actionBarItem",
  11227. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  11228. onmouseout: function () {
  11229. showItemInfo();
  11230. },
  11231. parent: actionBar
  11232. });
  11233. })(i);
  11234. }
  11235.  
  11236. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11237. (function (i) {
  11238. let tmpCanvas = document.createElement("canvas");
  11239. tmpCanvas.width = tmpCanvas.height = 66;
  11240. let tmpContext = tmpCanvas.getContext("2d");
  11241. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11242. tmpContext.imageSmoothingEnabled = false;
  11243. tmpContext.webkitImageSmoothingEnabled = false;
  11244. tmpContext.mozImageSmoothingEnabled = false;
  11245.  
  11246. if (items.weapons[i]) {
  11247. tmpContext.rotate((Math.PI));
  11248. let tmpSprite = new Image();
  11249. toolSprites[items.weapons[i].src] = tmpSprite;
  11250. tmpSprite.onload = function () {
  11251. this.isLoaded = true;
  11252. let tmpPad = 1 / (this.height / this.width);
  11253. let tmpMlt = (items.weapons[i].iPad || 1);
  11254. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11255. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11256. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  11257. tmpContext.globalCompositeOperation = "source-atop";
  11258. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11259. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11260. };
  11261. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11262. let tmpUnit = getEl('actionBarItem' + i);
  11263. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11264. // showItemInfo(items.weapons[i], true);
  11265. // });
  11266. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11267. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11268. });
  11269. UTILS.hookTouchEvents(tmpUnit);
  11270. } else {
  11271. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11272. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11273. tmpContext.globalAlpha = 1;
  11274. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11275. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11276. tmpContext.globalCompositeOperation = "source-atop";
  11277. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11278. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11279. let tmpUnit = getEl('actionBarItem' + i);
  11280. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11281. // showItemInfo(items.list[i - items.weapons.length]);
  11282. // });
  11283. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11284. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11285. });
  11286. UTILS.hookTouchEvents(tmpUnit);
  11287. }
  11288. })(i);
  11289. }
  11290. };
  11291. window.profineTest = function(data) {
  11292. if (data) {
  11293. // VALIDATE NAME:
  11294. let name = data + "";
  11295. name = name.slice(0, config.maxNameLength);
  11296.  
  11297. return name;
  11298. }
  11299. }
  11300. }(1)// ==UserScript==
  11301. // @name New Userscript
  11302. // @namespace http://tampermonkey.net/
  11303. // @version 2024-05-09
  11304. // @description try to take over the world!
  11305. // @author You
  11306. // @match http://*/*
  11307. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11308. // @grant none
  11309. // ==/UserScript==
  11310.  
  11311. (function() {
  11312. 'use strict';
  11313.  
  11314. // Your code here...
  11315. })();

QingJ © 2025

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